| 158 | } |
| 159 | |
| 160 | static bool parse_args(LPCSTR lpszArgs) |
| 161 | { |
| 162 | /************************************** |
| 163 | * |
| 164 | * p a r s e _ a r g s |
| 165 | * |
| 166 | ************************************** |
| 167 | * |
| 168 | * Functional description |
| 169 | * WinMain gives us a stupid command string, not |
| 170 | * a cool argv. Parse through the string and |
| 171 | * set the options. |
| 172 | * Returns |
| 173 | * A value of true or false depending on if -s is specified. |
| 174 | * CVC: Service is the default for NT, use -a for application. |
| 175 | * |
| 176 | * |
| 177 | **************************************/ |
| 178 | bool is_service = true; |
| 179 | bool delimited = false; |
| 180 | |
| 181 | for (const char* p = lpszArgs; *p; p++) |
| 182 | { |
| 183 | if (*p++ == '-') |
| 184 | { |
| 185 | char c; |
| 186 | while (c = *p++) |
| 187 | { |
| 188 | switch (UPPER(c)) |
| 189 | { |
| 190 | case 'A': |
| 191 | is_service = false; |
| 192 | break; |
| 193 | |
| 194 | case 'S': |
| 195 | delimited = false; |
| 196 | while (*p && *p == ' ') |
| 197 | p++; |
| 198 | if (*p && *p == '"') |
| 199 | { |
| 200 | p++; |
| 201 | delimited = true; |
| 202 | } |
| 203 | |
| 204 | if (delimited) |
| 205 | { |
| 206 | char* pi = instance; |
| 207 | const char* pend = instance + sizeof(instance) - 1; |
| 208 | while (*p && *p != '"' && pi < pend) { |
| 209 | *pi++ = *p++; |
| 210 | } |
| 211 | *pi++ = '\0'; |
| 212 | if (*p && *p == '"') |
| 213 | p++; |
| 214 | } |
| 215 | else |
| 216 | { |
| 217 | if (*p && *p != '-') |
no outgoing calls
no test coverage detected