Version 1.8.0.0
[socat.git] / procan_main.c
blob7f7040217357cd1159ec9b7c87f18b17a61df5c3
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() */
10 #include <string.h>
11 #include <stdio.h>
12 #include "config.h"
13 #if HAVE_SYS_SELECT_H
14 #include <sys/select.h> /* select(), fdset on FreeBSD */
15 #endif
16 #include "mytypes.h"
17 #include "error.h"
18 #include "procan.h"
19 #include "hostan.h"
22 #define WITH_HELP 1
24 static void procan_usage(FILE *fd);
27 int main(int argc, const char *argv[]) {
28 const char **arg1;
29 #if 0
30 unsigned int n = 1024; /* this is default on my Linux */
31 #endif
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] == '-')) {
37 switch (arg1[0][1]) {
38 #if WITH_HELP
39 case '?': case 'h': procan_usage(stdout); exit(0);
40 #endif /* WITH_HELP */
41 case 'c': procan_cdefs(stdout); exit(0);
42 #if LATER
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;
46 #endif
47 #if 0
48 case 'n': n = strtoul(&arg1[0][2], NULL, 0); break;
49 #endif
50 case '\0': break;
51 default:
52 diag_set_int('e', E_FATAL);
53 Error1("unknown option \"%s\"", arg1[0]);
54 #if WITH_HELP
55 procan_usage(stderr);
56 #endif
57 exit(1);
59 if (arg1[0][1] == '\0')
60 break;
61 ++arg1; --argc;
63 if (argc != 0) {
64 Error1("%d superfluous arguments", argc);
65 #if WITH_HELP
66 procan_usage(stderr);
67 #endif
68 exit(1);
70 procan(stdout);
71 hostan(stdout);
72 return 0;
76 #if WITH_HELP
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);
83 #if LATER
84 fputs(" -V print version information to stdout, and exit\n", fd);
85 #endif
86 #if WITH_HELP
87 fputs(" -?|-h print a help text describing command line options\n", fd);
88 #endif
89 fputs(" -c print values of compile time C defines\n", fd);
90 #if LATER
91 fputs(" -d increase verbosity (use up to 4 times; 2 are recommended)\n", fd);
92 #endif
93 #if 0
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);
97 #endif
98 #if 0
99 fputs(" -n<fdnum> first file descriptor number not analyzed\n", fd);
100 #endif
102 #endif /* WITH_HELP */