Browse Source

main.c must be C89 compliant for Visual Studio < 2013

See #138
bel 10 năm trước cách đây
mục cha
commit
40dfb432cd
1 tập tin đã thay đổi với 8 bổ sung5 xóa
  1. 8 5
      src/main.c

+ 8 - 5
src/main.c

@@ -1175,8 +1175,6 @@ static int get_password(const char *user,
 	int ok;
 	int ok;
 	short y;
 	short y;
 	struct tstring_input_buf dlgprms;
 	struct tstring_input_buf dlgprms;
-	dlgprms.buffer = passwd;
-	dlgprms.buflen = passwd_len;
 
 
 	static struct {
 	static struct {
 		DLGTEMPLATE template; /* 18 bytes */
 		DLGTEMPLATE template; /* 18 bytes */
@@ -1198,6 +1196,9 @@ static int get_password(const char *user,
 	                   8,
 	                   8,
 	                   L"Tahoma"};
 	                   L"Tahoma"};
 
 
+	dlgprms.buffer = passwd;
+	dlgprms.buflen = passwd_len;
+
 	assert((user != NULL) && (realm != NULL) && (passwd != NULL));
 	assert((user != NULL) && (realm != NULL) && (passwd != NULL));
 
 
 	if (guard < 100) {
 	if (guard < 100) {
@@ -1813,10 +1814,11 @@ static int manage_service(int action)
 	    "Civetweb"; /* TODO: check using server_name instead of service_name */
 	    "Civetweb"; /* TODO: check using server_name instead of service_name */
 	SC_HANDLE hSCM = NULL, hService = NULL;
 	SC_HANDLE hSCM = NULL, hService = NULL;
 	SERVICE_DESCRIPTION descr;
 	SERVICE_DESCRIPTION descr;
-	descr.lpDescription = g_server_name;
 	char path[PATH_MAX + 20] = ""; /* Path to executable plus magic argument */
 	char path[PATH_MAX + 20] = ""; /* Path to executable plus magic argument */
 	int success = 1;
 	int success = 1;
 
 
+	descr.lpDescription = g_server_name;
+
 	if ((hSCM = OpenSCManager(NULL,
 	if ((hSCM = OpenSCManager(NULL,
 	                          NULL,
 	                          NULL,
 	                          action == ID_INSTALL_SERVICE ? GENERIC_WRITE
 	                          action == ID_INSTALL_SERVICE ? GENERIC_WRITE
@@ -1871,12 +1873,13 @@ WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 	static SERVICE_TABLE_ENTRY service_table[2];
 	static SERVICE_TABLE_ENTRY service_table[2];
 	int service_installed;
 	int service_installed;
 	char buf[200], *service_argv[2];
 	char buf[200], *service_argv[2];
-	service_argv[0] = __argv[0];
-	service_argv[1] = NULL;
 	POINT pt;
 	POINT pt;
 	HMENU hMenu;
 	HMENU hMenu;
 	static UINT s_uTaskbarRestart; /* for taskbar creation */
 	static UINT s_uTaskbarRestart; /* for taskbar creation */
 
 
+	service_argv[0] = __argv[0];
+	service_argv[1] = NULL;
+
 	memset(service_table, 0, sizeof(service_table));
 	memset(service_table, 0, sizeof(service_table));
 	service_table[0].lpServiceName = g_server_name;
 	service_table[0].lpServiceName = g_server_name;
 	service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
 	service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;