add listen-timeout to function as an accept timeout
[socat/sam.git] / procan_main.c
blobb4823066b26edd0612490d348cdb6444cb43ac3c
1 /* source: procan_main.c */
2 /* Copyright Gerhard Rieger 2001-2008 */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 const char copyright[] = "procan by Gerhard Rieger - send bug reports to socat@dest-unreach.org";
7 #include <stdlib.h> /* strtoul() */
8 #include <string.h>
9 #include <stdio.h>
10 #include "mytypes.h"
11 #include "error.h"
12 #include "procan.h"
13 #include "hostan.h"
16 #define WITH_HELP 1
18 static void procan_usage(FILE *fd);
21 int main(int argc, const char *argv[]) {
22 const char **arg1;
23 #if 0
24 unsigned int n = 1024; /* this is default on my Linux */
25 #endif
27 diag_set('p', strchr(argv[0], '/') ? strrchr(argv[0], '/')+1 : argv[0]);
29 arg1 = argv+1; --argc;
30 while (arg1[0] && (arg1[0][0] == '-')) {
31 switch (arg1[0][1]) {
32 #if WITH_HELP
33 case '?': case 'h': procan_usage(stdout); exit(0);
34 #endif /* WITH_HELP */
35 case 'c': procan_cdefs(stdout); exit(0);
36 #if LATER
37 case 'V': procan_version(stdout); exit(0);
38 case 'l': diag_set(arg1[0][2], &arg1[0][3]); break;
39 case 'd': diag_set('d', NULL); break;
40 #endif
41 #if 0
42 case 'n': n = strtoul(&arg1[0][2], NULL, 0); break;
43 #endif
44 case '\0': break;
45 default:
46 diag_set_int('e', E_FATAL);
47 Error1("unknown option \"%s\"", arg1[0]);
48 #if WITH_HELP
49 procan_usage(stderr);
50 #endif
51 exit(1);
53 if (arg1[0][1] == '\0')
54 break;
55 ++arg1; --argc;
57 if (argc != 0) {
58 Error1("%d superfluous arguments", argc);
59 #if WITH_HELP
60 procan_usage(stderr);
61 #endif
62 exit(1);
64 procan(stdout);
65 hostan(stdout);
66 return 0;
70 #if WITH_HELP
71 static void procan_usage(FILE *fd) {
72 fputs(copyright, fd); fputc('\n', fd);
73 fputs("Analyze system parameters of process\n", fd);
74 fputs("Usage:\n", fd);
75 fputs("procan [options]\n", fd);
76 fputs(" options:\n", fd);
77 #if LATER
78 fputs(" -V print version information to stdout, and exit\n", fd);
79 #endif
80 #if WITH_HELP
81 fputs(" -?|-h print a help text describing command line options\n", fd);
82 #endif
83 fputs(" -c print values of compile time C defines\n", fd);
84 #if LATER
85 fputs(" -d increase verbosity (use up to 4 times; 2 are recommended)\n", fd);
86 #endif
87 #if 0
88 fputs(" -ly[facility] log to syslog, using facility (default is daemon)\n", fd);
89 fputs(" -lf<logfile> log to file\n", fd);
90 fputs(" -ls log to stderr (default if no other log)\n", fd);
91 #endif
92 #if 0
93 fputs(" -n<fdnum> first file descriptor number not analyzed\n", fd);
94 #endif
96 #endif /* WITH_HELP */