int main(int argc,char **argv) { int c; extern char *optarg; extern int optind; int errflg=0; int i; char test1[500],test2[500]; while ((c = getopt(argc, argv, "xvLEb:s:p:c:f:i:P:")) != EOF) switch (c) { case 'x': extendedoutput++; break; case 'v': verbose++; break; case 'L': liss2++; break; case 'E': ignoreeof++; break; case 'b': i = atoi(optarg); switch(i) { case 256: case 512: case 4096: seed_size = i; break; default: fprintf(stderr,"Block size must be 256, 512, or 4096\n"); errflg++; break; } break; case 'p': tel_port = atoi(optarg); break; case 's': select_file = strdup(optarg); break; case 'P': pidfile = strdup(optarg); break; case 'c': capture = strdup(optarg); break; case 'f': flushint = atoi(optarg); if (flushint<=5) { fprintf(stderr,"Flush interval must be >= 5 seconds\n"); errflg++; } break; case 'i': startint = atoi(optarg); if (startint<0) { fprintf(stderr,"Starting sequence must be >= 0\n"); errflg++; } break; case '?': errflg++; } if (capture) { sprintf(test1,capture,1); sprintf(test2,capture,9999); if (strcmp(test1,test2)==0) { fprintf(stderr,"You must specify capture masks with the %%d operator - like out%%d.seed\n"); errflg++; } } if (liss2) { printf("LISS2 server connections not supported yet\n"); errflg++; } if (extendedoutput) { printf("Extended (LISS2) mode not yet supported\n"); errflg++; } if (errflg) usage(argc,argv); if (pidfile) watchdog(pidfile); SelectInit(&dumproot); if (select_file) { SelectLoadup(&dumproot, select_file); if (verbose) SelectList(&dumproot); } for (; optind < argc; optind++) { ifil[num_files++] = strdup(argv[optind]); if (num_files+1>MAX_FILES) bombout(EXIT_ABORT,"Too many files - only supports %d",MAX_FILES); } if (num_files<=0) usage(argc,argv); if (num_files>1) usage(argc,argv); now = 0; while(1) { i = process_telemetry(ifil[0], tel_port); if (!ignoreeof) break; sleep(20); } exit(0); }
int main(int argc,char **argv) { extern char *optarg; extern int optind; char *match = '\0'; char *netcode = 0; int errflg=0; int i, c; int sleeptime = 30; if (argc < 2) { errflg++; } while ((c = getopt(argc, argv, "vEr:p:s:m:n:")) != EOF) switch (c) { case 'v': verbose++; break; case 'E': ignoreeof++; break; case 'p': port = atoi(optarg); break; case 'm': match = (char *) strdup(optarg); break; case 'n': if ( strlen(optarg) > 2 ) { lprintf(0,"Network code can only be 1 or 2 characters"); exit (1); } netcode = (char *) malloc (3); sprintf (netcode, "%-2.2s", optarg); netcode[2] = '\0'; break; case 's': host = (char *) strdup(optarg); break; case 'r': sleeptime = atoi(optarg); ignoreeof++; break; default: errflg++; } if ( errflg ) usage(argc,argv); if ( host == '\0' ) { lprintf(0,"Remote hostname is required! Use the -s argument"); exit(1); } lprintf(2,"Run time parameters:"); lprintf(2,"verbose: %d", verbose); if ( netcode ) lprintf(1,"Forcing network code: '%s'", netcode); lprintf(2,"ignoreeof: %d", ignoreeof); lprintf(2,"host: %s", host); lprintf(2,"port: %d", port); while ( 1 ) { i = process_telemetry(host, port, buf, match, netcode, seed_size); if (!ignoreeof && !i) break; sleep(sleeptime); } exit(0); }