mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 04:43:03 +01:00
Style.
This commit is contained in:
parent
88372841b4
commit
d4d91c5f2a
@ -145,7 +145,8 @@ void CNTL_shutdown_service(const TEXT* message)
|
||||
sprintf(buffer, "%s error: %lu", service_name->c_str(), GetLastError());
|
||||
|
||||
HANDLE event_source = RegisterEventSource(NULL, service_name->c_str());
|
||||
if (event_source) {
|
||||
if (event_source)
|
||||
{
|
||||
strings[0] = buffer;
|
||||
strings[1] = message;
|
||||
ReportEvent(event_source,
|
||||
@ -176,7 +177,8 @@ void CNTL_stop_service() //const TEXT* service) // unused param
|
||||
**************************************/
|
||||
|
||||
SC_HANDLE servicemgr_handle = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
if (servicemgr_handle == NULL) {
|
||||
if (servicemgr_handle == NULL)
|
||||
{
|
||||
// return error
|
||||
int error = GetLastError();
|
||||
gds__log("SC manager error %d", error);
|
||||
@ -184,16 +186,17 @@ void CNTL_stop_service() //const TEXT* service) // unused param
|
||||
}
|
||||
|
||||
SC_HANDLE service_handleL =
|
||||
OpenService(servicemgr_handle, service_name->c_str(),
|
||||
GENERIC_READ | GENERIC_EXECUTE);
|
||||
OpenService(servicemgr_handle, service_name->c_str(), GENERIC_READ | GENERIC_EXECUTE);
|
||||
|
||||
if (service_handleL == NULL) {
|
||||
if (service_handleL == NULL)
|
||||
{
|
||||
// return error
|
||||
int error = GetLastError();
|
||||
gds__log("open services error %d", error);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
SERVICE_STATUS status_info;
|
||||
if (!ControlService
|
||||
(service_handleL, SERVICE_CONTROL_STOP, &status_info))
|
||||
|
@ -190,7 +190,8 @@ static bool parse_args(LPCSTR lpszArgs)
|
||||
delimited = false;
|
||||
while (*p && *p == ' ')
|
||||
p++;
|
||||
if (*p && *p == '"') {
|
||||
if (*p && *p == '"')
|
||||
{
|
||||
p++;
|
||||
delimited = true;
|
||||
}
|
||||
@ -208,7 +209,8 @@ static bool parse_args(LPCSTR lpszArgs)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*p && *p != '-') {
|
||||
if (*p && *p != '-')
|
||||
{
|
||||
char* pi = instance;
|
||||
const char* pend = instance + sizeof(instance) - 1;
|
||||
while (*p && *p != ' ' && pi < pend) {
|
||||
@ -253,7 +255,8 @@ static THREAD_ENTRY_DECLARE WINDOW_main(THREAD_ENTRY_PARAM)
|
||||
{
|
||||
gds__thread_start(start_and_watch_server, 0, THREAD_medium, 0, &thread_id);
|
||||
|
||||
if (thread_id == (DWORD) -1) {
|
||||
if (thread_id == (DWORD) -1)
|
||||
{
|
||||
/* error starting server thread */
|
||||
char szMsgString[256];
|
||||
LoadString(hInstance_gbl, IDS_CANT_START_THREAD, szMsgString, 256);
|
||||
@ -265,7 +268,8 @@ static THREAD_ENTRY_DECLARE WINDOW_main(THREAD_ENTRY_PARAM)
|
||||
|
||||
/* Make sure that there is only 1 instance of the guardian running */
|
||||
HWND hWnd = FindWindow(GUARDIAN_CLASS_NAME, GUARDIAN_APP_NAME);
|
||||
if (hWnd) {
|
||||
if (hWnd)
|
||||
{
|
||||
char szMsgString[256];
|
||||
LoadString(hInstance_gbl, IDS_ALREADYSTARTED, szMsgString, 256);
|
||||
MessageBox(NULL, szMsgString, GUARDIAN_APP_LABEL, MB_OK | MB_ICONHAND);
|
||||
@ -286,7 +290,8 @@ static THREAD_ENTRY_DECLARE WINDOW_main(THREAD_ENTRY_PARAM)
|
||||
wcl.cbWndExtra = 0;
|
||||
wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
|
||||
|
||||
if (!RegisterClass(&wcl)) {
|
||||
if (!RegisterClass(&wcl))
|
||||
{
|
||||
char szMsgString[256];
|
||||
LoadString(hInstance_gbl, IDS_REGERROR, szMsgString, 256);
|
||||
MessageBox(NULL, szMsgString, GUARDIAN_APP_LABEL, MB_OK);
|
||||
@ -332,7 +337,8 @@ static THREAD_ENTRY_DECLARE WINDOW_main(THREAD_ENTRY_PARAM)
|
||||
BOOL bPSMsg = PropSheet_IsDialogMessage(hPSDlg, &message);
|
||||
|
||||
/* Check if the property sheet dialog is still valid, if not destroy it */
|
||||
if (!PropSheet_GetCurrentPageHwnd(hPSDlg)) {
|
||||
if (!PropSheet_GetCurrentPageHwnd(hPSDlg))
|
||||
{
|
||||
DestroyWindow(hPSDlg);
|
||||
hPSDlg = NULL;
|
||||
}
|
||||
@ -370,16 +376,15 @@ static LRESULT CALLBACK WindowFunc(HWND hWnd, UINT message, WPARAM wParam, LPARA
|
||||
switch (message)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
/* Clean up memory for log_entry */
|
||||
while (log_entry->next)
|
||||
{
|
||||
/* Clean up memory for log_entry */
|
||||
while (log_entry->next) {
|
||||
log_info* tmp = log_entry->next;
|
||||
free(log_entry);
|
||||
log_entry = tmp;
|
||||
}
|
||||
log_info* tmp = log_entry->next;
|
||||
free(log_entry);
|
||||
DestroyWindow(hWnd);
|
||||
log_entry = tmp;
|
||||
}
|
||||
free(log_entry);
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
@ -448,7 +453,8 @@ static LRESULT CALLBACK WindowFunc(HWND hWnd, UINT message, WPARAM wParam, LPARA
|
||||
break;
|
||||
|
||||
case ON_NOTIFYICON:
|
||||
if (bStartup) {
|
||||
if (bStartup)
|
||||
{
|
||||
SendMessage(hWnd, WM_COMMAND, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@ -468,7 +474,8 @@ static LRESULT CALLBACK WindowFunc(HWND hWnd, UINT message, WPARAM wParam, LPARA
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
if (!service_flag) {
|
||||
if (!service_flag)
|
||||
{
|
||||
HICON hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_IBGUARD),
|
||||
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
||||
|
||||
@ -675,7 +682,8 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM)
|
||||
DWORD server_pid;
|
||||
GetWindowThreadProcessId(hTmpWnd, &server_pid);
|
||||
procHandle = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, server_pid);
|
||||
if (procHandle == NULL) {
|
||||
if (procHandle == NULL)
|
||||
{
|
||||
error = GetLastError();
|
||||
success = FALSE;
|
||||
}
|
||||
@ -727,7 +735,8 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM)
|
||||
DWORD exit_status;
|
||||
if (service_flag)
|
||||
{
|
||||
while (WaitForSingleObject(procHandle, 500) == WAIT_OBJECT_0) {
|
||||
while (WaitForSingleObject(procHandle, 500) == WAIT_OBJECT_0)
|
||||
{
|
||||
ReleaseMutex(procHandle);
|
||||
Sleep(100);
|
||||
}
|
||||
@ -773,7 +782,8 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM)
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
/* Normal shutdown - ie: via ibmgr - don't restart the server */
|
||||
char szMsgString[256];
|
||||
LoadString(hInstance_gbl, IDS_NORMAL_TERM, szMsgString, 256);
|
||||
@ -788,7 +798,8 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM)
|
||||
|
||||
|
||||
/* If on WINNT */
|
||||
if (service_flag) {
|
||||
if (service_flag)
|
||||
{
|
||||
CloseServiceHandle(hScManager);
|
||||
CloseServiceHandle(hService);
|
||||
CNTL_stop_service(); //(service_name->c_str());
|
||||
@ -847,7 +858,7 @@ HWND DisplayPropSheet(HWND hParentWnd, HINSTANCE hInst)
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK GeneralPage(HWND hDlg, UINT unMsg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CALLBACK GeneralPage(HWND hDlg, UINT unMsg, WPARAM /*wParam*/, LPARAM lParam)
|
||||
{
|
||||
/******************************************************************************
|
||||
*
|
||||
@ -934,8 +945,7 @@ LRESULT CALLBACK GeneralPage(HWND hDlg, UINT unMsg, WPARAM wParam, LPARAM lParam
|
||||
*/
|
||||
lvC.iSubItem = index;
|
||||
lvC.cx = 85;
|
||||
LoadString(hInstance, IDS_ACTION + (index * 10), szText,
|
||||
sizeof(szText));
|
||||
LoadString(hInstance, IDS_ACTION + (index * 10), szText, sizeof(szText));
|
||||
ListView_InsertColumn(hWndLog, index, &lvC);
|
||||
}
|
||||
|
||||
@ -1095,14 +1105,13 @@ void write_log(int log_action, const char* buff)
|
||||
LoadString(hInstance_gbl, log_action + 1, tmp_buff, sizeof(tmp_buff));
|
||||
sprintf(act_buff[0], "%s", buff);
|
||||
|
||||
LPVOID lpMsgBuf;
|
||||
LPTSTR lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_ARGUMENT_ARRAY |
|
||||
FORMAT_MESSAGE_FROM_STRING,
|
||||
tmp_buff, 0, 0, (LPTSTR) &lpMsgBuf, 0,
|
||||
reinterpret_cast<va_list*>(act_buff));
|
||||
strncpy(act_buff[0], (LPTSTR) lpMsgBuf,
|
||||
strlen(static_cast<const char*>(lpMsgBuf)) - 1);
|
||||
strncpy(act_buff[0], lpMsgBuf, strlen(lpMsgBuf) - 1);
|
||||
LocalFree(lpMsgBuf);
|
||||
WORD wLogType;
|
||||
|
||||
@ -1125,8 +1134,7 @@ void write_log(int log_action, const char* buff)
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
||||
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) & lpMsgBuf, 0, NULL);
|
||||
gds__log("Unable to update NT Event Log.\n\tOS Message: %s",
|
||||
lpMsgBuf);
|
||||
gds__log("Unable to update NT Event Log.\n\tOS Message: %s", lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
// CVC: free(act_buff[0]); ???
|
||||
|
Loading…
Reference in New Issue
Block a user