void Init(char *langs, char *dialects, int anamorph) { Starting = 1; GenOnAssert = 1; LexEntryOff = 0; SaveTime = 1; /* SaveTime = 1: no spell correction hashing or phrase derivation, * saves memory. * SaveTime = 0: uses more time and memory. */ qallocInit(); DbgInit(); DbgSet(DBGALL, DBGBAD); DbgSetStdoutLevel(DBGOK); NoticePrint(stderr); NoticePrint(Log); EnvInit(); StringInit(); RandomInit(); GridInit(); ObjInit(); ObjListInit(); DbInit(); ContextInit(); TsInit(); TsRangeInit(); LexEntryInit(); Lex_WordForm2Init(); MorphInit(anamorph); WordFormInit(); InferenceInit(); ReportInit(); CommentaryInit(); TranslateInit(); LearnInit(); StopAtInit(); TT_HTML_Init(); StdDiscourse = DiscourseCreate(langs, dialects); DiscourseSetLang(StdDiscourse, F_ENGLISH); Starting = 0; }
void PC_Report::ReportInit() { ReportInit("Data"); }
int main(int argc, char **argv) { /* Get this now so we can use the event log. */ ReportInit(); serverOptions(argc, argv); if (0 < server_quit) { pid_t pid; int length; HANDLE signal_quit; char event_name[128]; pid = pidLoad(pid_file); length = snprintf(event_name, sizeof (event_name), "Global\\%ld-%s", (long) pid, server_quit == 1 ? "QUIT" : "TERM"); if (sizeof (event_name) <= length) { ReportLog(EVENTLOG_ERROR_TYPE, "service %s pid file name too long", _NAME); return EX_SOFTWARE; } signal_quit = OpenEvent(EVENT_MODIFY_STATE , 0, event_name); if (signal_quit == NULL) { ReportLog(EVENTLOG_ERROR_TYPE, "service %s quit error: %s (%d)", _NAME, strerror(errno), errno); return EX_OSERR; } SetEvent(signal_quit); CloseHandle(signal_quit); return EXIT_SUCCESS; } if (windows_service != NULL) { if (winServiceInstall(*windows_service == 'a', _NAME, NULL) < 0) { ReportLog(EVENTLOG_ERROR_TYPE, "service %s %s error: %s (%d)", _NAME, windows_service, strerror(errno), errno); return EX_OSERR; } return EXIT_SUCCESS; } openlog(_NAME, LOG_PID|LOG_NDELAY, log_facility); if (daemon_mode) { if (pidSave(pid_file)) { syslog(LOG_ERR, log_init, SERVER_FILE_LINENO, strerror(errno), errno); return EX_SOFTWARE; } if (pidLock(pid_file) < 0) { syslog(LOG_ERR, log_init, SERVER_FILE_LINENO, strerror(errno), errno); return EX_SOFTWARE; } winServiceSetSignals(&signals); if (winServiceStart(_NAME, argc, argv) < 0) { ReportLog(EVENTLOG_ERROR_TYPE, "service %s start error: %s (%d)", _NAME, strerror(errno), errno); return EX_OSERR; } return EXIT_SUCCESS; } #ifdef NOT_USED { long length; char *cwd, *backslash, *server_root, default_root[256]; /* Get the absolute path of this executable and set the working * directory to correspond to it so that we can find the options * configuration file along side the executable, when running as * a service. (I hate using the registry.) */ if ((length = GetModuleFileName(NULL, default_root, sizeof default_root)) == 0 || length == sizeof default_root) { ReportLog(EVENTLOG_ERROR_TYPE, "failed to find default server root"); return EXIT_FAILURE; } /* Strip off the executable filename, leaving its parent directory. */ for (backslash = default_root+length; default_root < backslash && *backslash != '\\'; backslash--) ; server_root = default_root; *backslash = '\0'; /* Remember where we are in case we are running in application mode. */ cwd = getcwd(NULL, 0); /* Change to the executable's directory for default configuration file. */ if (chdir(server_root)) { ReportLog(EVENTLOG_ERROR_TYPE, "failed to change directory to '%s': %s (%d)\n", server_root, strerror(errno), errno); exit(EX_OSERR); } if (cwd != NULL) { (void) chdir(cwd); free(cwd); } } #endif return serverMain(); }