int die = 0;
char *usageDesc;
int alt_dirs = 0;
+ int known_opt;
#ifdef WIN32
SERVICE_TABLE_ENTRY dispatchTable[] = {
#endif
for (x = 1; x < argc; x++) {
- if (argv[x] && !strcmp(argv[x], "-help")) {
- printf("%s\n", usageDesc);
- exit(0);
- }
+ known_opt = 0;
#ifdef WIN32
if (x == 1) {
if (argv[x] && !strcmp(argv[x], "-service")) {
+ known_opt++;
if (StartServiceCtrlDispatcher(dispatchTable) == 0) {
/* Not loaded as a service */
fprintf(stderr, "Error Freeswitch loaded as a console app with -service option\n");
char servicePath[1024];
SC_HANDLE handle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ known_opt++;
GetModuleFileName(NULL, exePath, 1024);
snprintf(servicePath, sizeof(servicePath), "%s -service", exePath);
CreateService(handle,
if (argv[x] && !strcmp(argv[x], "-uninstall")) {
SC_HANDLE handle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE service = OpenService(handle, SERVICENAME, DELETE);
+ known_opt++;
if (service != NULL) {
/* remove the service! */
DeleteService(service);
if (argv[x] && !strcmp(argv[x], "-nf")) {
nf++;
+ known_opt++;
}
#endif
if (argv[x] && !strcmp(argv[x], "-hp")) {
set_high_priority();
+ known_opt++;
}
if (argv[x] && !strcmp(argv[x], "-stop")) {
die++;
+ known_opt++;
}
if (argv[x] && !strcmp(argv[x], "-nc")) {
nc++;
+ known_opt++;
}
fprintf(stderr, "When using -conf you must specify a config directory\n");
return 255;
}
+ known_opt++;
}
if (argv[x] && !strcmp(argv[x], "-log")) {
fprintf(stderr, "When using -log you must specify a log directory\n");
return 255;
}
+ known_opt++;
}
if (argv[x] && !strcmp(argv[x], "-db")) {
fprintf(stderr, "When using -db you must specify a db directory\n");
return 255;
}
+ known_opt++;
+ }
+
+ if (!known_opt || argv[x] && !strcmp(argv[x], "-help")) {
+ printf("%s\n", usageDesc);
+ exit(0);
}
}