.


:




:

































 

 

 

 


.7. Options




/* . */

#include "EvryThng.h"

#include <stdarg.h>

 

DWORD Options(int argc, LPCTSTR argv[], LPCTSTR OptStr,...)

/* argv . (), , '-' argv[1], argv[2], .

OptStr , , - (...). , argv[1], argv[2], ( argv) , . */

{

va_list pFlagList;

LPBOOL pFlag;

int iFlag = 0, iArg;

va_start(pFlagList, OptStr);

while ((pFlag = va_arg(pFlagList, LPBOOL))!= NULL && iFlag < (int)_tcslen(OptStr)) {

*pFlag = FALSE;

for (iArg = 1;!(*pFlag) && iArg < argc && argv[iArg][0] == '-'; iArg++) *pFlag = _memtchr(argv[iArg], OptStr[iFlag], _tcslen(argv[iArg]))!= NULL;

iFlag++;

}

va_end(pFlagList);

for (iArg = 1; iArg < argc && argv[iArg][0] == '-'; iArg++);

return iArg;

}

SkipArg.

, , . timep ( 6.2).

.8. SkipArg

/* SkipArg.

. */

#include "EvryThng.h"

 

LPTSTR SkipArg(LPCTSTR targv) {

LPTSTR p;

p = (LPTSTR)targv;

/* . */

while (*!= '\0' && *!= TSPACE && *!= TAB) p++;

/* . */

while (*!= '\0' && (* == TSPACE || * == TAB)) p++;

return ;

}

GetArgs.

, , , , . argv[] JobShell 6. Win32 CommandLineToArgW , Unicode.

.9. GetArgs

/* GetArgs. argc/argv. */

#include "EvryThng.h"

 

VOID GetArgs(LPCTSTR Command, int *pArgc, LPTSTR argstr[]) {

int i, icm = 0;

DWORD ic = 0;

for (i = 0; ic < _tcslen(Command); i++) {

while (ic < _tcslen(Command) && Command[ic]!= TSPACE && Command [ic]!= TAB) {

argstr[i][icm] = Command[ic];

ic++;

icm++;

}

argstr[i][icm] = '\0';

while (ic < _tcslen(Command) && (Command[ic] == TSPACE || Command[ic] == TAB)) ic++;

icm = 0;

}

if (pArgc!= NULL) *pArgc = i;

return;

}






:


: 2015-09-20; !; : 578 |


:

:

, , . , .
==> ...

1690 - | 1527 -


© 2015-2024 lektsii.org - -

: 0.008 .