source: zzuf/trunk/src/zzcat.c @ 4253

Last change on this file since 4253 was 4253, checked in by Sam Hocevar, 10 years ago

Fix copyright information and remove Id tag everywhere.

  • Property svn:keywords set to Id
File size: 19.9 KB
Line 
1/*
2 *  zzcat - various cat reimplementations for testing purposes
3 *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13/*
14 * TODO: fsetpos64, fgetln
15 */
16
17#include "config.h"
18
19/* Needed for lseek64() */
20#define _LARGEFILE64_SOURCE
21/* Needed for O_RDONLY on HP-UX */
22#define _INCLUDE_POSIX_SOURCE
23/* Needed for fgets_unlocked() */
24#define _GNU_SOURCE
25
26#if defined HAVE_STDINT_H
27#   include <stdint.h>
28#elif defined HAVE_INTTYPES_H
29#   include <inttypes.h>
30#endif
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <fcntl.h>
34#if defined HAVE_UNISTD_H
35#   include <unistd.h>
36#endif
37#if defined HAVE_SYS_MMAN_H
38#   include <sys/mman.h>
39#endif
40#include <stdlib.h>
41#include <stdio.h>
42#include <string.h>
43
44#if !defined HAVE_GETOPT_LONG
45#   include "mygetopt.h"
46#elif defined HAVE_GETOPT_H
47#   include <getopt.h>
48#endif
49
50#if defined HAVE_GETOPT_LONG
51#   define mygetopt getopt_long
52#   define myoptind optind
53#   define myoptarg optarg
54#   define myoption option
55#endif
56
57static int run(char const *sequence, char const *file);
58
59static void syntax(void);
60static void version(void);
61static void usage(void);
62
63/*
64 * Main program.
65 */
66
67int main(int argc, char *argv[])
68{
69    char const *sequence = "repeat(-1, fgetc(), feof(1))";
70    int i;
71
72    for (;;)
73    {
74#define OPTSTR "+x:lhV"
75#define MOREINFO "Try `%s --help' for more information.\n"
76        int option_index = 0;
77        static struct myoption long_options[] =
78        {
79            { "execute",     1, NULL, 'x' },
80            { "list",        0, NULL, 'l' },
81            { "help",        0, NULL, 'h' },
82            { "version",     0, NULL, 'V' },
83            { NULL,          0, NULL,  0  }
84        };
85        int c = mygetopt(argc, argv, OPTSTR, long_options, &option_index);
86
87        if (c == -1)
88            break;
89
90        switch (c)
91        {
92        case 'x': /* --execute */
93            if (myoptarg[0] == '=')
94                myoptarg++;
95            sequence = myoptarg;
96            break;
97        case 'l': /* --list */
98            syntax();
99            return 0;
100        case 'h': /* --help */
101            usage();
102            return 0;
103        case 'V': /* --version */
104            version();
105            return 0;
106        default:
107            fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
108            printf(MOREINFO, argv[0]);
109            return EXIT_FAILURE;
110        }
111    }
112
113    if (myoptind >= argc)
114    {
115        fprintf(stderr, "E: zzcat: too few arguments\n");
116        return EXIT_FAILURE;
117    }
118
119    for (i = myoptind; i < argc; i++)
120    {
121        int ret = run(sequence, argv[i]);
122        if (ret)
123            return ret;
124    }
125
126    return EXIT_SUCCESS;
127}
128
129/*
130 * Command intepreter
131 */
132
133#define MY_FOPEN(cmd) \
134    do { \
135        cmd; \
136        if (!f) \
137        { \
138            fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \
139            return EXIT_FAILURE; \
140        } \
141        retoff = 0; \
142        sequence = strchr(sequence, ')') + 1; \
143    } while(0)
144
145#define MY_FCLOSE(cmd) \
146    do { \
147        cmd; \
148        f = NULL; \
149        sequence = strchr(sequence, ')') + 1; \
150    } while(0)
151
152#define MERGE(address, cnt, off) \
153    do { \
154        size_t _cnt = cnt, _off = off; \
155        if (_cnt && retoff + _cnt > retlen) \
156        { \
157            retlen = retoff + _cnt; \
158            retbuf = realloc(retbuf, retlen); \
159        } \
160        if (_cnt > 0) \
161            memcpy(retbuf + retoff, address, _cnt); \
162        retoff += _off; \
163    } while(0)
164
165#define MY_FREAD(cmd, buf, cnt) MY_FCALL(cmd, buf, cnt, cnt)
166#define MY_FSEEK(cmd, off) MY_FCALL(cmd, /* unused */ "", 0, off)
167
168#define MY_FCALL(cmd, buf, cnt, off) \
169    do { \
170        if (!f) \
171        { \
172            f = fopen(file, "r"); \
173            if (!f) \
174            { \
175                fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \
176                return EXIT_FAILURE; \
177            } \
178        } \
179        /* fprintf(stderr, "debug: %s\n", #cmd); */ \
180        cmd; \
181        MERGE(buf, cnt, off); \
182        sequence = strchr(sequence, ')') + 1; \
183    } while(0)
184
185#define MY_FEOF() \
186    do { \
187        if (!f) \
188        { \
189            f = fopen(file, "r"); \
190            if (!f) \
191            { \
192                fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \
193                return EXIT_FAILURE; \
194            } \
195        } \
196        if (feof(f)) \
197            feofs++; \
198        if (feofs >= l1) \
199            finish = 1; \
200        sequence = strchr(sequence, ')') + 1; \
201    } while(0)
202
203/*
204 * Command parser. We rewrite fmt by replacing the last character with
205 * '%c' and check that the sscanf() call returns the expected number of
206 * matches plus one (for the last character). We use this macro trick to
207 * avoid using vsscanf() which does not exist on all platforms.
208 */
209
210struct parser
211{
212    char tmpfmt[1024], ch, lastch;
213};
214
215static int make_fmt(struct parser *p, char const *fmt)
216{
217    char const *tmp;
218    size_t len;
219    int ret = 0;
220
221    len = strlen(fmt);
222    p->lastch = fmt[len - 1];
223
224    memcpy(p->tmpfmt, fmt, len - 1);
225    p->tmpfmt[len - 1] = '%';
226    p->tmpfmt[len] = 'c';
227    p->tmpfmt[len + 1] = '\0';
228
229    for (tmp = p->tmpfmt; *tmp; tmp++)
230        if (*tmp == '%')
231            tmp++, ret++;
232
233    return ret;
234}
235
236#define PARSECMD(fmt, arg...) \
237    (make_fmt(&parser, fmt) == sscanf(sequence, parser.tmpfmt, \
238                                      ##arg, &parser.ch) \
239         && parser.ch == parser.lastch)
240
241/*
242 * File reader. We parse a command line and perform all the operations it
243 * contains on the specified file.
244 */
245
246static int run(char const *sequence, char const *file)
247{
248    struct { char const *p; int count; } loops[128];
249    char *retbuf = NULL, *tmp;
250    FILE *f = NULL;
251    size_t retlen = 0, retoff = 0;
252    int nloops = 0, fd = -1, feofs = 0, finish = 0;
253
254    /* Allocate 32MB for our temporary buffer. Any larger value will crash. */
255    tmp = malloc(32 * 1024 * 1024);
256
257    while (*sequence)
258    {
259        struct parser parser;
260        long int l1, l2;
261        char *s, *lineptr = NULL;
262        size_t k;
263        ssize_t l;
264        int n;
265        char ch;
266
267        (void)k;
268
269        /* Ignore punctuation */
270        if (strchr(" \t,;\r\n", *sequence))
271            sequence++;
272
273        /* Loop handling */
274        else if (PARSECMD("repeat ( %li ,", &l1))
275        {
276            sequence = strchr(sequence, ',') + 1;
277            loops[nloops].p = sequence;
278            loops[nloops].count = l1;
279            nloops++;
280        }
281        else if (PARSECMD(")"))
282        {
283            if (nloops == 0)
284            {
285                fprintf(stderr, "E: zzcat: ')' outside a loop\n");
286                return EXIT_FAILURE;
287            }
288            if (loops[nloops - 1].count == 1 || finish)
289            {
290                nloops--;
291                sequence = strchr(sequence, ')') + 1;
292            }
293            else
294            {
295                loops[nloops - 1].count--;
296                sequence = loops[nloops - 1].p;
297            }
298
299            finish = 0;
300        }
301
302        /* FILE * opening functions */
303        else if (PARSECMD("fopen ( )"))
304            MY_FOPEN(f = fopen(file, "r"));
305#if defined HAVE_FOPEN64
306        else if (PARSECMD("fopen64 ( )"))
307            MY_FOPEN(f = fopen64(file, "r"));
308#endif
309#if defined HAVE___FOPEN64
310        else if (PARSECMD("__fopen64 ( )"))
311            MY_FOPEN(f = __fopen64(file, "r"));
312#endif
313        else if (PARSECMD("freopen ( )"))
314            MY_FOPEN(f = freopen(file, "r", f));
315#if defined HAVE_FREOPEN64
316        else if (PARSECMD("freopen64 ( )"))
317            MY_FOPEN(f = freopen64(file, "r", f));
318#endif
319#if defined HAVE___FREOPEN64
320        else if (PARSECMD("__freopen64 ( )"))
321            MY_FOPEN(f = __freopen64(file, "r", f));
322#endif
323
324        /* FILE * EOF detection */
325        else if (PARSECMD("feof ( %li )", &l1))
326            MY_FEOF();
327
328        /* FILE * closing functions */
329        else if (PARSECMD("fclose ( )"))
330            MY_FCLOSE(fclose(f));
331
332        /* FILE * reading functions */
333        else if (PARSECMD("fread ( %li , %li )", &l1, &l2))
334            MY_FREAD(l = fread(tmp, l1, l2, f), tmp, l > 0 ? l * l1 : 0);
335        else if (PARSECMD("getc ( )"))
336            MY_FREAD(ch = (n = getc(f)), &ch, (n != EOF));
337        else if (PARSECMD("fgetc ( )"))
338            MY_FREAD(ch = (n = fgetc(f)), &ch, (n != EOF));
339        else if (PARSECMD("fgets ( %li )", &l1))
340            MY_FREAD(s = fgets(tmp, l1, f), tmp, s ? strlen(tmp) : 0);
341#if defined HAVE__IO_GETC
342        else if (PARSECMD("_IO_getc ( )"))
343            MY_FREAD(ch = (n = _IO_getc(f)), &ch, (n != EOF));
344#endif
345#if defined HAVE_FREAD_UNLOCKED
346        else if (PARSECMD("fread_unlocked ( %li , %li )", &l1, &l2))
347            MY_FREAD(l = fread_unlocked(tmp, l1, l2, f), tmp, l > 0 ? l * l1 : 0);
348#endif
349#if defined HAVE_FGETS_UNLOCKED
350        else if (PARSECMD("fgets_unlocked ( %li )", &l1))
351            MY_FREAD(s = fgets_unlocked(tmp, l1, f), tmp, s ? strlen(tmp) : 0);
352#endif
353#if defined HAVE_GETC_UNLOCKED
354        else if (PARSECMD("getc_unlocked ( )"))
355            MY_FREAD(ch = (n = getc_unlocked(f)), &ch, (n != EOF));
356#endif
357#if defined HAVE_FGETC_UNLOCKED
358        else if (PARSECMD("fgetc_unlocked ( )"))
359            MY_FREAD(ch = (n = fgetc_unlocked(f)), &ch, (n != EOF));
360#endif
361
362        /* FILE * getdelim functions */
363#if defined HAVE_GETLINE
364        else if (PARSECMD("getline ( )"))
365            MY_FREAD(l = getline(&lineptr, &k, f), lineptr, l >= 0 ? l : 0);
366#endif
367#if defined HAVE_GETDELIM
368        else if (PARSECMD("getdelim ( '%c' )", &ch))
369            MY_FREAD(l = getdelim(&lineptr, &k, ch, f), lineptr, l >= 0 ? l : 0);
370        else if (PARSECMD("getdelim ( %i )", &n))
371            MY_FREAD(l = getdelim(&lineptr, &k, n, f), lineptr, l >= 0 ? l : 0);
372#endif
373#if defined HAVE___GETDELIM
374        else if (PARSECMD("__getdelim ( '%c' )", &ch))
375            MY_FREAD(l = __getdelim(&lineptr, &k, ch, f), lineptr, l >= 0 ? l : 0);
376        else if (PARSECMD("__getdelim ( %i )", &n))
377            MY_FREAD(l = __getdelim(&lineptr, &k, n, f), lineptr, l >= 0 ? l : 0);
378#endif
379
380        /* FILE * seeking functions */
381        else if (PARSECMD("fseek ( %li , SEEK_CUR )", &l1))
382            MY_FSEEK(l = fseek(f, l1, SEEK_CUR),
383                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
384        else if (PARSECMD("fseek ( %li , SEEK_SET )", &l1))
385            MY_FSEEK(l = fseek(f, l1, SEEK_SET),
386                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
387        else if (PARSECMD("fseek ( %li , SEEK_END )", &l1))
388            MY_FSEEK(l = fseek(f, l1, SEEK_END),
389                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
390#if defined HAVE_FSEEKO
391        else if (PARSECMD("fseeko ( %li , SEEK_CUR )", &l1))
392            MY_FSEEK(l = fseeko(f, l1, SEEK_CUR),
393                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
394        else if (PARSECMD("fseeko ( %li , SEEK_SET )", &l1))
395            MY_FSEEK(l = fseeko(f, l1, SEEK_SET),
396                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
397        else if (PARSECMD("fseeko ( %li , SEEK_END )", &l1))
398            MY_FSEEK(l = fseeko(f, l1, SEEK_END),
399                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
400#endif
401#if defined HAVE_FSEEKO64
402        else if (PARSECMD("fseeko64 ( %li , SEEK_CUR )", &l1))
403            MY_FSEEK(l = fseeko64(f, l1, SEEK_CUR),
404                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
405        else if (PARSECMD("fseeko64 ( %li , SEEK_SET )", &l1))
406            MY_FSEEK(l = fseeko64(f, l1, SEEK_SET),
407                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
408        else if (PARSECMD("fseeko64 ( %li , SEEK_END )", &l1))
409            MY_FSEEK(l = fseeko64(f, l1, SEEK_END),
410                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
411#endif
412#if defined HAVE___FSEEKO64
413        else if (PARSECMD("__fseeko64 ( %li , SEEK_CUR )", &l1))
414            MY_FSEEK(l = __fseeko64(f, l1, SEEK_CUR),
415                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
416        else if (PARSECMD("__fseeko64 ( %li , SEEK_SET )", &l1))
417            MY_FSEEK(l = __fseeko64(f, l1, SEEK_SET),
418                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
419        else if (PARSECMD("__fseeko64 ( %li , SEEK_END )", &l1))
420            MY_FSEEK(l = __fseeko64(f, l1, SEEK_END),
421                     ftell(f) >= 0 ? ftell(f) - retoff : 0);
422#endif
423        else if (PARSECMD("rewind ( )"))
424            MY_FSEEK(rewind(f), -retlen);
425        else if (PARSECMD("ungetc ( )"))
426            MY_FSEEK(if(retoff) ungetc((unsigned char)retbuf[retoff - 1], f),
427                     retoff ? -1 : 0);
428
429        /* Unrecognised sequence */
430        else
431        {
432            char buf[16];
433            snprintf(buf, 16, strlen(sequence) < 16 ? "%s" : "%.12s...",
434                     sequence);
435            fprintf(stderr, "E: zzcat: syntax error near `%s'\n", buf);
436            return EXIT_FAILURE;
437        }
438
439        /* Clean up our mess */
440        if (lineptr)
441            free(lineptr);
442
443        if (finish && !nloops)
444            break;
445    }
446
447    if (f)
448        fclose(f);
449
450    if (fd >= 0)
451        close(fd);
452
453    fwrite(retbuf, retlen, 1, stdout);
454
455    free(retbuf);
456    free(tmp);
457
458    return EXIT_SUCCESS;
459}
460
461#if 0
462/* Only read() calls */
463static int zzcat_read(char const *name, unsigned char *data, int64_t len,
464                      int64_t chunk)
465{
466    int i, fd = open(name, O_RDONLY);
467    if(fd < 0)
468        return EXIT_FAILURE;
469    for(i = 0; i < len; i += chunk)
470        read(fd, data + i, chunk);
471    close(fd);
472    return EXIT_SUCCESS;
473}
474
475/* Socket seeks and reads */
476static int zzcat_random_socket(char const *name, unsigned char *data,
477                               int64_t len)
478{
479    int i, j, fd = open(name, O_RDONLY);
480    if(fd < 0)
481        return EXIT_FAILURE;
482    for(i = 0; i < 128; i++)
483    {
484        lseek(fd, myrand() % len, SEEK_SET);
485        for(j = 0; j < 4; j++)
486            read(fd, data + lseek(fd, 0, SEEK_CUR), myrand() % 4096);
487#ifdef HAVE_LSEEK64
488        lseek64(fd, myrand() % len, SEEK_SET);
489        for(j = 0; j < 4; j++)
490            read(fd, data + lseek(fd, 0, SEEK_CUR), myrand() % 4096);
491#endif
492    }
493    close(fd);
494    return EXIT_SUCCESS;
495}
496
497/* Standard stream seeks and reads */
498static int zzcat_random_stream(char const *name, unsigned char *data,
499                               int64_t len)
500{
501    FILE *stream = fopen(name, "r");
502    int i, j;
503    if(!stream)
504        return EXIT_FAILURE;
505    for(i = 0; i < 128; i++)
506    {
507        long int now;
508        fseek(stream, myrand() % len, SEEK_SET);
509        for(j = 0; j < 4; j++)
510            fread(data + ftell(stream),
511                  myrand() % (len - ftell(stream)), 1, stream);
512        fseek(stream, myrand() % len, SEEK_SET);
513        now = ftell(stream);
514        for(j = 0; j < 16; j++)
515            data[now + j] = getc(stream);
516        now = ftell(stream);
517        for(j = 0; j < 16; j++)
518            data[now + j] = fgetc(stream);
519    }
520    fclose(stream);
521    return EXIT_SUCCESS;
522}
523
524#ifdef HAVE_MMAP
525/* mmap() followed by random memory reads */
526static int zzcat_random_mmap(char const *name, unsigned char *data,
527                               int64_t len)
528{
529    int i, j, fd = open(name, O_RDONLY);
530    if(fd < 0)
531        return EXIT_FAILURE;
532    for(i = 0; i < 128; i++)
533    {
534        char *map;
535        int moff, mlen, pgsz = len + 1;
536#ifdef HAVE_GETPAGESIZE
537        pgsz = getpagesize();
538#endif
539        moff = len < pgsz ? 0 : (myrand() % (len / pgsz)) * pgsz;
540        mlen = 1 + (myrand() % (len - moff));
541        map = mmap(NULL, mlen, PROT_READ, MAP_PRIVATE, fd, moff);
542        if(map == MAP_FAILED)
543            return EXIT_FAILURE;
544        for(j = 0; j < 128; j++)
545        {
546            int x = myrand() % mlen;
547            data[moff + x] = map[x];
548        }
549        munmap(map, mlen);
550    }
551    close(fd);
552    return EXIT_SUCCESS;
553}
554#endif
555#endif
556
557static char const *keyword_list[] =
558{
559    "repeat", "(<int>,<sequence>)", "loop <int> times through <sequence>",
560    "feof", "(<int>)", "break out of loop or sequence after <int> EOFs",
561    NULL
562};
563
564static char const *function_list[] =
565{
566    "fopen", "()", "open file",
567#if defined HAVE_FOPEN64
568    "fopen64", "()", "same as fopen()",
569#endif
570#if defined HAVE___FOPEN64
571    "__fopen64", "()", "same as fopen()",
572#endif
573    "freopen", "()", "reopen file",
574#if defined HAVE_FREOPEN64
575    "freopen64", "()", "same as reopen()",
576#endif
577#if defined HAVE___FREOPEN64
578    "__freopen64", "()", "same as reopen()",
579#endif
580    "fclose", "()", "close file",
581    "fread", "(<inta>,<intb>)", "read <intb> chunks of <inta> bytes",
582    "getc", "()", "get one character (can be a macro)",
583    "fgetc", "()", "get one character",
584    "fgets", "(<int>)", "read one line no longer than <int> bytes",
585#if defined HAVE__IO_GETC
586    "_IO_getc", "()", "get one character",
587#endif
588#if defined HAVE_FREAD_UNLOCKED
589    "fread_unlocked", "(<inta>,<intb>)", "same as fread(), unlocked I/O version",
590#endif
591#if defined HAVE_FGETS_UNLOCKED
592    "fgets_unlocked", "(<int>)", "same as fgets(), unlocked I/O version",
593#endif
594#if defined HAVE_GETC_UNLOCKED
595    "getc_unlocked", "()", "same as getc(), unlocked I/O version",
596#endif
597#if defined HAVE_FGETC_UNLOCKED
598    "fgetc_unlocked", "()", "same as fgetc(), unlocked I/O version",
599#endif
600#if defined HAVE_GETLINE
601    "getline", "()", "read one complete line of text",
602#endif
603#if defined HAVE_GETDELIM
604    "getdelim", "('<char>')", "read all data until delimiter character <char>",
605    "getdelim", "(<int>)", "read all data until delimiter character <int>",
606#endif
607#if defined HAVE___GETDELIM
608    "__getdelim", "('<char>')", "same as getdelim()",
609    "__getdelim", "(<int>)", "same as getdelim()",
610#endif
611    "fseek", "(<int>,<whence>)", "seek using SEEK_CUR, SEEK_SET or SEEK_END",
612#if defined HAVE_FSEEKO
613    "fseeko", "(<int>,<whence>)", "same as fseek()",
614#endif
615#if defined HAVE_FSEEKO64
616    "fseeko64", "(<int>,<whence>)", "same as fseek()",
617#endif
618#if defined HAVE___FSEEKO64
619    "__fseeko64", "(<int>,<whence>)", "same as fseek()",
620#endif
621    "rewind", "()", "rewind to the beginning of the stream",
622    "ungetc", "()", "put one byte back in the stream",
623    NULL
624};
625
626static void print_list(char const **list)
627{
628    static char const spaces[] = "                                ";
629
630    while (*list)
631    {
632        size_t len = printf("  %s%s", list[0], list[1]);
633        if (len < strlen(spaces))
634            printf("%s", spaces + len);
635        printf("%s\n", list[2]);
636        list += 3;
637    }
638}
639
640static void syntax(void)
641{
642    printf("Available control keywords:\n");
643    print_list(keyword_list);
644    printf("\n");
645    printf("Available functions:\n");
646    print_list(function_list);
647}
648
649static void version(void)
650{
651    printf("zzcat %s\n", PACKAGE_VERSION);
652    printf("Copyright (C) 2002-2010 Sam Hocevar <sam@hocevar.net>\n");
653    printf("This program is free software. It comes without any warranty, to the extent\n");
654    printf("permitted by applicable law. You can redistribute it and/or modify it under\n");
655    printf("the terms of the Do What The Fuck You Want To Public License, Version 2, as\n");
656    printf("published by Sam Hocevar. See <http://sam.zoy.org/wtfpl/> for more details.\n");
657    printf("\n");
658    printf("Written by Sam Hocevar. Report bugs to <sam@hocevar.net>.\n");
659}
660
661static void usage(void)
662{
663    printf("Usage: zzcat [-x sequence] [FILE...]\n");
664    printf("       zzcat -l | --list\n");
665    printf("       zzcat -h | --help\n");
666    printf("       zzcat -V | --version\n");
667    printf("Read FILE using a sequence of various I/O methods.\n");
668    printf("\n");
669    printf("Mandatory arguments to long options are mandatory for short options too.\n");
670    printf("  -x, --execute <sequence>  execute commands in <sequence>\n");
671    printf("  -l, --list                list available program functions\n");
672    printf("  -h, --help                display this help and exit\n");
673    printf("  -V, --version             output version information and exit\n");
674    printf("\n");
675    printf("Written by Sam Hocevar. Report bugs to <sam@hocevar.net>.\n");
676}
677
Note: See TracBrowser for help on using the repository browser.