39 const char *
nextArgument(BOOL getprog,
const char *argptr, PULONG ndx, PULONG len, BOOL allocate)
42 if (argptr[*ndx] ==
' ')
44 while ((argptr[*ndx] ==
' ') && argptr[*ndx])
50 const char *tmp = &argptr[*ndx];
54 while ((argptr[*ndx] !=
' ') && argptr[*ndx])
56 if (argptr[*ndx] ==
'\"')
do
58 if (argptr[*ndx] !=
'\"')
63 }
while ((argptr[*ndx] !=
'\"') && argptr[*ndx]);
66 if (argptr[*ndx] !=
'\"')
77 if (argptr[*ndx] ==
'\"')
82 }
while ((argptr[*ndx] !=
'\"') && argptr[*ndx]);
83 while (argptr[*ndx] && (argptr[*ndx] !=
' '))
103 if (getprog && (tmp[0] ==
'\"'))
108 ret = (PCHAR) GlobalAlloc(GMEM_FIXED, (*len)+1);
109 memcpy(ret, tmp, (*len)+1);
137 (*program) =
nextArgument(TRUE, argptr, &i, &len, TRUE);
141 const char *tmp =
nextArgument(FALSE, argptr, &i, &len, FALSE);
145 if (tmp && strlen(tmp) > 1 && (tmp[0] ==
'/' || tmp[0] ==
'-') && (tmp[1] ==
'e' || tmp[1] ==
'E') )
151 retarr->strptr = NULL;
162 retarr->strptr =
nextArgument(FALSE, argptr, &i, &len, TRUE);
163 retarr->strlength = len;
171 if (arguments->strptr) GlobalFree((HGLOBAL)arguments->strptr);
172 if (program) GlobalFree((HGLOBAL)program);
192 len = strlen(CmdLine);
193 i = ((len+2)/2)*
sizeof(
void *) +
sizeof(
void *);
195 argv = (
char**)GlobalAlloc(GMEM_FIXED,
196 i + (len+2)*
sizeof(char));
198 _argv = (PCHAR)(((PUCHAR)argv)+i);
208 while ( a = CmdLine[i] )
231 argv[argc] = _argv+j;
252 argv[argc] = _argv+j;
PCONSTRXSTRING getArguments(const char **program, const char *argptr, size_t *count, PCONSTRXSTRING retarr)
PCHAR * CommandLineToArgvA(PCHAR CmdLine, int32_t *_argc)
void freeArguments(const char *program, PCONSTRXSTRING arguments)
const char * nextArgument(BOOL getprog, const char *argptr, PULONG ndx, PULONG len, BOOL allocate)
CONSTANT_RXSTRING * PCONSTRXSTRING