"Fossies" - the Fresh Open Source Software Archive

Member "socat-1.7.3.2/procan_main.c" (6 Jan 2017, 2813 Bytes) of package /linux/privat/socat-1.7.3.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "procan_main.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.7.3.1_vs_1.7.3.2.

    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 */
    4 
    5 const char copyright[] = "procan by Gerhard Rieger and contributors - send bug reports to socat@dest-unreach.org";
    6 
    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"
   20 
   21 
   22 #define WITH_HELP 1
   23 
   24 static void procan_usage(FILE *fd);
   25 
   26 
   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
   32 
   33    diag_set('p', strchr(argv[0], '/') ? strrchr(argv[0], '/')+1 : argv[0]);
   34 
   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);
   58       }
   59       if (arg1[0][1] == '\0')
   60      break;
   61       ++arg1; --argc;
   62    }
   63    if (argc != 0) {
   64       Error1("%d superfluous arguments", argc);
   65 #if WITH_HELP
   66       procan_usage(stderr);
   67 #endif
   68       exit(1);
   69    }
   70    procan(stdout);
   71    hostan(stdout);
   72    return 0;
   73 }
   74 
   75 
   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
  101 }
  102 #endif /* WITH_HELP */