/** exit with windows error */ static void fatal_win(FILE* out, const char* str) { char e[256]; wsvc_err2str(e, sizeof(e), str, (int)GetLastError()); if(out) fprintf(out, "%s\n", e); else fprintf(stderr, "%s\n", e); exit(1); }
/** * report event to system event log * For use during startup and shutdown. * @param str: the error */ static void reportev(const char* str) { char b[256]; char e[256]; HANDLE* s; LPCTSTR msg = b; /* print quickly to keep GetLastError value */ wsvc_err2str(e, sizeof(e), str, GetLastError()); snprintf(b, sizeof(b), "%s: %s", SERVICE_NAME, e); s = RegisterEventSource(NULL, SERVICE_NAME); if(!s) return; ReportEvent(s, /* event log */ EVENTLOG_ERROR_TYPE, /* event type */ 0, /* event category */ MSG_GENERIC_ERR, /* event ID (from gen_msg.mc) */ NULL, /* user security context */ 1, /* numstrings */ 0, /* binary size */ &msg, /* strings */ NULL); /* binary data */ DeregisterEventSource(s); }