int main(int argc, char **argv) { int argn; int do_huffman, do_hist; int cnt; cnt = 0; argn = tino_getopt(argc, argv, 1, 0, TINO_GETOPT_VERSION(HISTOGRAM_VERSION) TINO_GETOPT_LLOPT " file [..]\n" " Use - as filename to read stdin", TINO_GETOPT_USAGE "help this help" , TINO_GETOPT_FLAG TINO_GETOPT_COUNT "huff print huffman tree" , &cnt , &do_huffman, TINO_GETOPT_FLAG TINO_GETOPT_COUNT "hist print histogram (default if nothing else given)" , &cnt , &do_hist, NULL ); if (argn<=0) return 1; for (; argn<argc; argn++) readfile(argv[argn]); if (do_huffman) huffman(); if (do_hist || !cnt) histogram(); return 0; }
int main(int argc, char **argv) { return tino_main_g1(unbuffered, NULL, argc, argv, 0, -1, TINO_GETOPT_VERSION(UNBUFFERED_VERSION) " [command args...]\n" "\t# producer | unbuffered 2>>file | consumer\n" "\t\tfile gets copy of stdin appended\n" "\t# producer | unbuffered -a file | consumer\n" "\t\tAs before, but file is not kept open for easy rotation\n" "\t# producer | unbuffered -cq$'\\n' | consumer\n" "\t\tAdd LF on read boundaries (consumer sees partial lines as lines)\n" "\t# producer | unbuffered -xuca file\n" "\t\tHexdump producer's output with timestamp to file, allow rotation\n" "\t# var=\"`unbuffered producer [producerargs]`\"; echo $?\n" "\t\tDisplay producer's output while catching it and it's return code\n" "\t# ./unbuffered -ci2 -bbp 'OUT ' ./unbuffered -ci2 -bbp 'ERR ' ./testfile.sh; echo $?\n" "\t\tPrefix producer's STDIN with 'OUT ' and STDERR with 'ERR ' and get result\n" "\t\t(Hint: The 1st unbuffered gets STDOUT of testfile on STDERR from 2nd)\n" "\t\tNote that producer should not produce output on both channels too fast." , TINO_GETOPT_USAGE "h this help" , TINO_GETOPT_STRING "a file Append STDERR to file. It is closed and reopened\n" " from time to time to allow easy logfile rotation.\n" " With option -c this becomes a data sink." , &append_file, TINO_GETOPT_FLAG TINO_GETOPT_MAX "b Buffer partial lines\n" " Buffer incomplete lines which remain after reading STDIN.\n" " Give it twice to buffer all incomplete lines up to 100kB.\n" " Triple it to force buffering even on longer lines" , &flag_buffer, 3, TINO_GETOPT_FLAG "c Change (or cat) mode, do the dumping to stdout, faster than:\n" " producer | unbuffered 2>&1 >/dev/null | consumer\n" " Without this option input is copied to output unchanged" , &flag_cat, TINO_GETOPT_FLAG "d Debug forked producer by redirecting it's STDERR to STDOUT.\n" " This option only has an effect on producers." , &flag_both, #ifdef HAVE_ESCAPE_XML TINO_GETOPT_FLAG TINO_GETOPT_MAX "e Escape mode, XML compatible. Give twice for CDATA.\n" " Use with -p and -s to add XML tags\n" " Does not work with option -x (latter takes precedence)\n" , &flag_xml, 2, #endif #if 0 TINO_GETOPT_ENV TINO_GETOPT_STRING TINO_GETOPT_DEFAULT "f str comma separated order of the line Fields (letter=option).\n" " Use ,, to get a comma. c stands for line contents." , "UNBUFFERD_FORMAT", , &field_format, , "p,[l],[u],n5 ,cs" #endif /* g */ TINO_GETOPT_INT TINO_GETOPT_DEFAULT TINO_GETOPT_MIN TINO_GETOPT_MAX "i Input file descriptor instead of the default, usually STDIN (0).\n" " With producers this is STDOUT (1). See also -d.\n" " With -i2 on producers STDIN and STDERR swap positions" , &fd_in, -1, 0, TINO_OPEN_MAX-1, #ifdef HAVE_ESCAPE_JSON TINO_GETOPT_FLAG "j Escape mode, JSON compatible\n" " Use with -p and -s to add JSON framing\n" " Does not work with option -x (latter takes precedence)\n" , &flag_json, #endif /* k */ TINO_GETOPT_FLAG "l Local timestamp each line" , &flag_localtime, TINO_GETOPT_FLAG "m Microseconds accuracy for timestamps." , &flag_micro, TINO_GETOPT_FLAG TINO_GETOPT_MAX "n print line Numbers, twice with 0, triple unindented." , &flag_linecount, 3, TINO_GETOPT_INT TINO_GETOPT_DEFAULT TINO_GETOPT_MIN TINO_GETOPT_MAX "o fd Output file descriptor instead of STDERR\n" " This is used instead of STDOUT in cat mode (option -c)" , &fd_out, -1, 0, TINO_OPEN_MAX-1, TINO_GETOPT_STRING "p str line Prefix" , &line_prefix, TINO_GETOPT_STRING "q str line suffix on incomplete lines\n" " (Unless -x this defaults to LF for options: l n u v)" , &line_cont_suffix, TINO_GETOPT_STRING "r str line prefix on continuation lines" , &line_cont_prefix, TINO_GETOPT_STRING "s str line Suffix (unless -x this defaults to LF)" , &line_suffix, TINO_GETOPT_DEFAULT TINO_GETOPT_CHAR "t char line Termination character on input" , &line_terminator, '\n', TINO_GETOPT_FLAG "u UTC timestamp each line" , &flag_utc, TINO_GETOPT_FLAG "v Verbosely report return code of forked producer.\n" " Also adds a marker after the prefixes:\n" " '-' for informational, ' ' for complete, '+' for incomplete lines." , &flag_verbose, /* w */ TINO_GETOPT_FLAG "x heXdump output" , &flag_hexdump, /* yz */ NULL ); }