~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/server/main.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Server main function
  3  *
  4  * Copyright (C) 1998 Alexandre Julliard
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 
 23 #include <assert.h>
 24 #include <ctype.h>
 25 #include <fcntl.h>
 26 #include <signal.h>
 27 #include <stdio.h>
 28 #include <stdlib.h>
 29 #include <sys/time.h>
 30 #include <unistd.h>
 31 #ifdef HAVE_GETOPT_H
 32 # include <getopt.h>
 33 #endif
 34 
 35 #include "object.h"
 36 #include "file.h"
 37 #include "thread.h"
 38 #include "request.h"
 39 
 40 /* command-line options */
 41 int debug_level = 0;
 42 int foreground = 0;
 43 timeout_t master_socket_timeout = 3 * -TICKS_PER_SEC;  /* master socket timeout, default is 3 seconds */
 44 const char *server_argv0;
 45 
 46 /* parse-line args */
 47 
 48 static void usage(void)
 49 {
 50     fprintf(stderr, "Usage: %s [options]\n\n", server_argv0);
 51     fprintf(stderr, "Options:\n");
 52     fprintf(stderr, "   -d[n], --debug[=n]       set debug level to n or +1 if n not specified\n");
 53     fprintf(stderr, "   -f,    --foreground      remain in the foreground for debugging\n");
 54     fprintf(stderr, "   -h,    --help            display this help message\n");
 55     fprintf(stderr, "   -k[n], --kill[=n]        kill the current wineserver, optionally with signal n\n");
 56     fprintf(stderr, "   -p[n], --persistent[=n]  make server persistent, optionally for n seconds\n");
 57     fprintf(stderr, "   -v,    --version         display version information and exit\n");
 58     fprintf(stderr, "   -w,    --wait            wait until the current wineserver terminates\n");
 59     fprintf(stderr, "\n");
 60 }
 61 
 62 static void parse_args( int argc, char *argv[] )
 63 {
 64     int ret, optc;
 65 
 66     static struct option long_options[] =
 67     {
 68         {"debug",       2, 0, 'd'},
 69         {"foreground",  0, 0, 'f'},
 70         {"help",        0, 0, 'h'},
 71         {"kill",        2, 0, 'k'},
 72         {"persistent",  2, 0, 'p'},
 73         {"version",     0, 0, 'v'},
 74         {"wait",        0, 0, 'w'},
 75         { NULL,         0, 0, 0}
 76     };
 77 
 78     server_argv0 = argv[0];
 79 
 80     while ((optc = getopt_long( argc, argv, "d::fhk::p::vw", long_options, NULL )) != -1)
 81     {
 82         switch(optc)
 83         {
 84             case 'd':
 85                 if (optarg && isdigit(*optarg))
 86                     debug_level = atoi( optarg );
 87                 else
 88                     debug_level++;
 89                 break;
 90             case 'f':
 91                 foreground = 1;
 92                 break;
 93             case 'h':
 94                 usage();
 95                 exit(0);
 96                 break;
 97             case 'k':
 98                 if (optarg && isdigit(*optarg))
 99                     ret = kill_lock_owner( atoi( optarg ) );
100                 else
101                     ret = kill_lock_owner(-1);
102                 exit( !ret );
103             case 'p':
104                 if (optarg && isdigit(*optarg))
105                     master_socket_timeout = (timeout_t)atoi( optarg ) * -TICKS_PER_SEC;
106                 else
107                     master_socket_timeout = TIMEOUT_INFINITE;
108                 break;
109             case 'v':
110                 fprintf( stderr, "%s\n", PACKAGE_STRING );
111                 exit(0);
112             case 'w':
113                 wait_for_lock();
114                 exit(0);
115             default:
116                 usage();
117                 exit(1);
118         }
119     }
120 }
121 
122 static void sigterm_handler( int signum )
123 {
124     exit(1);  /* make sure atexit functions get called */
125 }
126 
127 int main( int argc, char *argv[] )
128 {
129     setvbuf( stderr, NULL, _IOLBF, 0 );
130     parse_args( argc, argv );
131 
132     /* setup temporary handlers before the real signal initialization is done */
133     signal( SIGPIPE, SIG_IGN );
134     signal( SIGHUP, sigterm_handler );
135     signal( SIGINT, sigterm_handler );
136     signal( SIGQUIT, sigterm_handler );
137     signal( SIGTERM, sigterm_handler );
138     signal( SIGABRT, sigterm_handler );
139 
140     sock_init();
141     open_master_socket();
142 
143     if (debug_level) fprintf( stderr, "wineserver: starting (pid=%ld)\n", (long) getpid() );
144     init_signals();
145     init_directories();
146     init_registry();
147     main_loop();
148     return 0;
149 }
150 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.