]> git.pond.sub.org Git - empserver/blobdiff - src/server/main.c
Update known contributors comments
[empserver] / src / server / main.c
index d4f5c21dc1ae8be6482849738164751674f63844..5ce3b02ece6c81dbe9819466d51cdd3bc7578a0e 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -32,7 +31,7 @@
  *     Steve McClure, 1996, 1998
  *     Doug Hay, 1998
  *     Ron Koenderink, 2004-2009
- *     Markus Armbruster, 2005-2008
+ *     Markus Armbruster, 2005-2010
  */
 
 #include <config.h>
 #include <unistd.h>
 
 #if defined(_WIN32)
-#include <winsock2.h>
-#undef NS_ALL
 #include <process.h>
 #include "service.h"
+#include "sys/socket.h"
 #endif
 
 #include "empio.h"
@@ -77,7 +75,6 @@ static void create_pidfile(char *, pid_t);
 
 #if defined(_WIN32)
 static void loc_NTInit(void);
-static void loc_NTTerm(void);
 #endif
 
 /*
@@ -107,7 +104,6 @@ print_usage(char *program_name)
           "  -e CONFIG-FILE  configuration file\n"
           "                  (default %s)\n"
           "  -E ACTION       what to do on oops: abort, crash-dump, nothing (default)\n"
-          "  -h              display this help and exit\n"
 #ifdef _WIN32
           "  -i              install service `%s'\n"
           "  -I NAME         install service NAME\n"
@@ -119,6 +115,7 @@ print_usage(char *program_name)
 #endif
           "  -s              enable stack checking\n"
           "  -R RANDOM-SEED  random seed\n"
+          "  -h              display this help and exit\n"
           "  -v              display version information and exit\n",
           program_name, dflt_econfig
 #ifdef _WIN32
@@ -202,26 +199,27 @@ main(int argc, char **argv)
        }
     }
 
+    /* silently ignore operands for backward compatibility */
+
 #if defined(_WIN32)
-    if ((!daemonize || flags || config_file != NULL) &&
-       remove_service_set) {
+    if ((!daemonize || flags || config_file != NULL)
+       && remove_service_set) {
        fprintf(stderr, "Can't use -p, -s, -d or -e with either "
            "-u or -U options\n");
        exit(EXIT_FAILURE);
     }
     if ((!daemonize || flags) && install_service_set) {
-       fprintf(stderr, "Can't use -d, -p or -s with either "
-           "-i or -I options\n");
+       fprintf(stderr,
+               "Can't use -d, -p or -s with either -i or -I options\n");
        exit(EXIT_FAILURE);
     }
     if (install_service_set && remove_service_set) {
-       fprintf(stderr, "Can't use both -u or -U and -i or -I "
-           "options\n");
+       fprintf(stderr, "Can't use both -u or -U and -i or -I options\n");
        exit(EXIT_FAILURE);
     }
 
     if (remove_service_set)
-        return remove_service(service_name);
+       return remove_service(service_name);
     if (install_service_set) {
        program_name = _fullpath(NULL, argv[0], 0);
        if (config_file != NULL)
@@ -387,9 +385,6 @@ void
 finish_server(void)
 {
     ef_fin_srv();
-#if defined(_WIN32)
-    loc_NTTerm();
-#endif
     journal_shutdown();
     remove(pidfname);
 }
@@ -456,7 +451,7 @@ shutdwn(int sig)
 
 #if defined(_WIN32)
     if (daemonize)
-        stop_service();
+       stop_service();
 #endif
     exit(0);
 }
@@ -466,20 +461,11 @@ static void
 loc_NTInit(void)
 {
     int rc;
-    WORD wVersionRequested;
-    WSADATA wsaData;
 
-    wVersionRequested = MAKEWORD(2, 0);
-    rc = WSAStartup(wVersionRequested, &wsaData);
+    rc = w32_socket_init();
     if (rc != 0) {
-       logerror("WSAStartup failed.  %d", rc);
+       logerror("WSAStartup Failed, error code %d\n", rc);
        exit(1);
     }
 }
-
-static void
-loc_NTTerm(void)
-{
-    WSACleanup();
-}
 #endif