1 /* source: procan_main.c */
2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 const char copyright
[] = "procan by Gerhard Rieger and contributors - send bug reports to socat@dest-unreach.org";
7 #include <signal.h> /* sig_atomic_t for error.h */
8 #include <time.h> /* struct timespec for error.h */
9 #include <stdlib.h> /* strtoul() */
14 #include <sys/select.h> /* select(), fdset on FreeBSD */
24 static void procan_usage(FILE *fd
);
27 int main(int argc
, const char *argv
[]) {
30 unsigned int n
= 1024; /* this is default on my Linux */
33 diag_set('p', strchr(argv
[0], '/') ? strrchr(argv
[0], '/')+1 : argv
[0]);
35 arg1
= argv
+1; --argc
;
36 while (arg1
[0] && (arg1
[0][0] == '-')) {
39 case '?': case 'h': procan_usage(stdout
); exit(0);
40 #endif /* WITH_HELP */
41 case 'c': procan_cdefs(stdout
); exit(0);
43 case 'V': procan_version(stdout
); exit(0);
44 case 'l': diag_set(arg1
[0][2], &arg1
[0][3]); break;
45 case 'd': diag_set('d', NULL
); break;
48 case 'n': n
= strtoul(&arg1
[0][2], NULL
, 0); break;
52 diag_set_int('e', E_FATAL
);
53 Error1("unknown option \"%s\"", arg1
[0]);
59 if (arg1
[0][1] == '\0')
64 Error1("%d superfluous arguments", argc
);
77 static void procan_usage(FILE *fd
) {
78 fputs(copyright
, fd
); fputc('\n', fd
);
79 fputs("Analyze system parameters of process\n", fd
);
80 fputs("Usage:\n", fd
);
81 fputs("procan [options]\n", fd
);
82 fputs(" options:\n", fd
);
84 fputs(" -V print version information to stdout, and exit\n", fd
);
87 fputs(" -?|-h print a help text describing command line options\n", fd
);
89 fputs(" -c print values of compile time C defines\n", fd
);
91 fputs(" -d increase verbosity (use up to 4 times; 2 are recommended)\n", fd
);
94 fputs(" -ly[facility] log to syslog, using facility (default is daemon)\n", fd
);
95 fputs(" -lf<logfile> log to file\n", fd
);
96 fputs(" -ls log to stderr (default if no other log)\n", fd
);
99 fputs(" -n<fdnum> first file descriptor number not analyzed\n", fd
);
102 #endif /* WITH_HELP */