| 96 | static Thread swap_icons_thd; |
| 97 | |
| 98 | int WINAPI WinMain(HINSTANCE hInstance, |
| 99 | HINSTANCE /*hPrevInstance*/, LPSTR lpszCmdLine, int /*nCmdShow*/) |
| 100 | { |
| 101 | /************************************** |
| 102 | * |
| 103 | * m a i n |
| 104 | * |
| 105 | ************************************** |
| 106 | * |
| 107 | * Functional description |
| 108 | * The main routine for Windows based server guardian. |
| 109 | * |
| 110 | **************************************/ |
| 111 | |
| 112 | strcpy(instance, FB_DEFAULT_INSTANCE); |
| 113 | |
| 114 | service_flag = parse_args(lpszCmdLine); |
| 115 | |
| 116 | service_name->printf(ISCGUARD_SERVICE, instance); |
| 117 | remote_name->printf(REMOTE_SERVICE, instance); |
| 118 | mutex_name->printf(GUARDIAN_MUTEX, instance); |
| 119 | |
| 120 | // set the global HINSTANCE as we need it in WINDOW_main |
| 121 | hInstance_gbl = hInstance; |
| 122 | |
| 123 | // allocate space for the event list |
| 124 | log_entry = static_cast<log_info*>(malloc(sizeof(log_info))); |
| 125 | log_entry->next = NULL; |
| 126 | |
| 127 | // since the flag is set we run as a service |
| 128 | if (service_flag) |
| 129 | { |
| 130 | CNTL_init(WINDOW_main, instance); |
| 131 | |
| 132 | const SERVICE_TABLE_ENTRY service_table[] = |
| 133 | { |
| 134 | {const_cast<char*>(service_name->c_str()), CNTL_main_thread}, |
| 135 | {NULL, NULL} |
| 136 | }; |
| 137 | |
| 138 | // BRS There is a error in MinGW (3.1.0) headers |
| 139 | // the parameter of StartServiceCtrlDispatcher is declared const in msvc headers |
| 140 | #if defined(MINGW) |
| 141 | if (!StartServiceCtrlDispatcher(const_cast<SERVICE_TABLE_ENTRY*>(service_table))) |
| 142 | #else |
| 143 | if (!StartServiceCtrlDispatcher(service_table)) |
| 144 | #endif |
| 145 | { |
| 146 | if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) |
| 147 | CNTL_shutdown_service("StartServiceCtrlDispatcher failed"); |
| 148 | } |
| 149 | |
| 150 | if (watcher_thd.isValid()) |
| 151 | watcher_thd.waitFor(5000); |
| 152 | } |
| 153 | else { |
| 154 | return WINDOW_main(0); |
| 155 | } |
nothing calls this directly
no test coverage detected