4 * Copyright (C) 1998 Alexandre Julliard
20 /* command-line options */
22 int persistent_server
= 0;
24 unsigned int server_start_ticks
= 0;
27 /* FIXME: should probably use getopt, and add a (more complete?) help option */
29 static void usage(const char *exeName
)
31 fprintf(stderr
, "\nusage: %s [options]\n\n", exeName
);
32 fprintf(stderr
, "options:\n");
33 fprintf(stderr
, " -d<n> set debug level to <n>\n");
34 fprintf(stderr
, " -p make server persistent\n");
35 fprintf(stderr
, " -h display this help message\n");
36 fprintf(stderr
, "\n");
39 static void parse_args( int argc
, char *argv
[] )
42 for (i
= 1; i
< argc
; i
++)
44 if (argv
[i
][0] == '-')
49 if (isdigit(argv
[i
][2])) debug_level
= atoi( argv
[i
] + 2 );
57 persistent_server
= 1;
60 fprintf( stderr
, "Unknown option '%s'\n", argv
[i
] );
67 fprintf( stderr
, "Unknown argument '%s'. Your version of wine may be too old.\n", argv
[i
] );
74 static void sigterm_handler()
76 exit(1); /* make sure atexit functions get called */
79 /* initialize signal handling */
80 static void signal_init(void)
82 signal( SIGPIPE
, SIG_IGN
);
83 signal( SIGHUP
, sigterm_handler
);
84 signal( SIGINT
, sigterm_handler
);
85 signal( SIGQUIT
, sigterm_handler
);
86 signal( SIGTERM
, sigterm_handler
);
87 signal( SIGABRT
, sigterm_handler
);
90 /* get server start ticks used to calculate GetTickCount() in Wine clients */
91 static void get_start_ticks(void)
94 gettimeofday( &t
, NULL
);
95 server_start_ticks
= (t
.tv_sec
* 1000) + (t
.tv_usec
/ 1000);
98 int main( int argc
, char *argv
[] )
100 parse_args( argc
, argv
);
102 open_master_socket();
103 setvbuf( stderr
, NULL
, _IOLBF
, 0 );
105 if (debug_level
) fprintf( stderr
, "Server: starting (pid=%ld)\n", (long) getpid() );
110 if (debug_level
) fprintf( stderr
, "Server: exiting (pid=%ld)\n", (long) getpid() );
114 dump_objects(); /* dump any remaining objects */