BOOL ProcessCmdLine(LPSTR lpCmdLine) { REGEDIT_ACTION action = ACTION_UNDEF; LPSTR s = lpCmdLine; /* command line pointer */ CHAR ch = *s; /* current character */ while (ch && ((ch == '-') || (ch == '/'))) { char chu; char ch2; s++; ch = *s; if (!ch || isspace(ch)) { /* '-' is a file name. It indicates we should use stdin */ s--; break; } ch2 = *(s+1); chu = toupper(ch); if (!ch2 || isspace(ch2)) { if (chu == 'S' || chu == 'V') { /* ignore these switches */ } else { switch (chu) { case 'D': action = ACTION_DELETE; break; case 'E': action = ACTION_EXPORT; break; case '?': fprintf(stderr,usage); exit(0); break; default: error_unknown_switch(chu, s); break; } } s++; } else { if (ch2 == ':') { switch (chu) { case 'L': /* fall through */ case 'R': s += 2; while (*s && !isspace(*s)) { s++; } break; default: error_unknown_switch(chu, s); break; } } else { /* this is a file name, starting from '/' */ s--; break; } } /* skip spaces to the next parameter */ ch = *s; while (ch && isspace(ch)) { s++; ch = *s; } } if (*s && action == ACTION_UNDEF) action = ACTION_ADD; if (action == ACTION_UNDEF) return FALSE; return PerformRegAction(action, s); }
BOOL ProcessCmdLine(LPWSTR lpCmdLine) { BOOL silent = FALSE; REGEDIT_ACTION action = ACTION_UNDEF; LPWSTR s = lpCmdLine; /* command line pointer */ WCHAR ch = *s; /* current character */ while (ch && ((ch == L'-') || (ch == L'/'))) { WCHAR chu; WCHAR ch2; s++; ch = *s; ch2 = *(s + 1); chu = towupper(ch); if (!ch2 || iswspace(ch2)) { if (chu == L'S') { /* Silence dialogs */ silent = TRUE; } else if (chu == L'V') { /* Ignore this switch */ } else { switch (chu) { case L'D': action = ACTION_DELETE; break; case L'E': action = ACTION_EXPORT; break; case L'?': InfoMessageBox(NULL, MB_OK | MB_ICONINFORMATION, NULL, usage); exit(3); break; default: error_unknown_switch(chu, s); break; } } s++; } else { if (ch2 == L':') { switch (chu) { case L'L': /* fall through */ case L'R': s += 2; while (*s && !iswspace(*s)) { s++; } break; default: error_unknown_switch(chu, s); break; } } else { /* this is a file name, starting from '/' */ s--; break; } } /* skip spaces to the next parameter */ ch = *s; while (ch && iswspace(ch)) { s++; ch = *s; } } if (*s && action == ACTION_UNDEF) action = ACTION_ADD; if (action != ACTION_UNDEF) return PerformRegAction(action, s, silent); else return FALSE; }