1 /* Process handling for Windows
2 Copyright (C) 1996-2012 Free Software Foundation, Inc.
3 This file is part of GNU Make.
5 GNU Make is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3 of the License, or (at your option) any later
10 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see <http://www.gnu.org/licenses/>. */
26 * Description: Convert a NULL string terminated UNIX environment block to
27 * an environment block suitable for a windows32 system call
29 * Returns: TRUE= success, FALSE=fail
31 * Notes/Dependencies: the environment block is sorted in case-insensitive
32 * order, is double-null terminated, and is a char *, not a char **
34 int _cdecl
compare(const void *a1
, const void *a2
)
36 return _stricoll(*((char**)a1
),*((char**)a2
));
39 arr2envblk(char **arr
, char **envblk_out
)
51 tmp
= (char**) calloc(arrcnt
+ 1, sizeof(char *));
59 tmp
[arrcnt
] = arr
[arrcnt
];
60 size_needed
+= strlen(arr
[arrcnt
]) + 1;
65 qsort((void *) tmp
, (size_t) arrcnt
, sizeof (char*), compare
);
67 ptr
= *envblk_out
= calloc(size_needed
, 1);
75 strcpy(ptr
, tmp
[arrcnt
]);
76 ptr
+= strlen(tmp
[arrcnt
]) + 1;