9 * Description: Convert a NULL string terminated UNIX environment block to
10 * an environment block suitable for a windows32 system call
12 * Returns: TRUE= success, FALSE=fail
14 * Notes/Dependencies: the environment block is sorted in case-insensitive
15 * order, is double-null terminated, and is a char *, not a char **
17 int _cdecl
compare(const void *a1
, const void *a2
)
19 return _stricoll(*((char**)a1
),*((char**)a2
));
22 arr2envblk(char **arr
, char **envblk_out
)
34 tmp
= (char**) calloc(arrcnt
+ 1, sizeof(char *));
42 tmp
[arrcnt
] = arr
[arrcnt
];
43 size_needed
+= strlen(arr
[arrcnt
]) + 1;
48 qsort((void *) tmp
, (size_t) arrcnt
, sizeof (char*), compare
);
50 ptr
= *envblk_out
= calloc(size_needed
, 1);
58 strcpy(ptr
, tmp
[arrcnt
]);
59 ptr
+= strlen(tmp
[arrcnt
]) + 1;