Exemple #1
0
int
main(
	int argc,
	char *argv[]
	)
{
	return ntpdmain(argc, argv);
}
Exemple #2
0
/*
 * This is the entry point for the executable 
 * We can call ntpdmain() explicitly or via StartServiceCtrlDispatcher()
 * as we need to.
 */
int main( int argc, char *argv[] )
{
	int rc;
	int i = 1;

	/* Save the command line parameters */
	glb_argc = argc;
	glb_argv = argv;

	/* Command line users should put -f in the options */
	while (argv[i]) {
		if (!_strnicmp(argv[i], "-d", 2) ||
			!strcmp(argv[i], "-q") ||
			!strcmp(argv[i], "--help") ||
			!strcmp(argv[i], "-n")) {
			foreground = TRUE;
			break;
		}
		i++;
	}

	if (foreground) {
		/* run in console window */
		exit(ntpdmain(argc, argv));
	} else {
		/* Start up as service */

		SERVICE_TABLE_ENTRY dispatchTable[] = {
			{ TEXT(NTP_DISPLAY_NAME), (LPSERVICE_MAIN_FUNCTION) service_main },
			{ NULL, NULL }
		};

		rc = StartServiceCtrlDispatcher(dispatchTable);
		if (!rc) {
			progname = argv[0];
			rc = GetLastError();
#ifdef DEBUG
			fprintf(stderr, "%s: unable to start as service, rc: %i\n\n", progname, rc);
#endif
			fprintf(stderr, "\nUse -d, -q, --help or -n to run from the command line.\n");
			exit(rc);
		}
	}
	exit(0);
}
Exemple #3
0
void WINAPI service_main( DWORD argc, LPTSTR *argv )
{
  /* pass the global command line options on to the service */
  ntpdmain( glb_argc, glb_argv );
}