~ubuntu-branches/ubuntu/wily/luatex/wily

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/zziplib/bins/zzdir.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-04-29 00:47:19 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100429004719-o42etkqe90n97b9e
Tags: 0.60.1-1
* new upstream release, adapt build-script patch
* disable patch: upstream-epstopdf_cc_no_xpdf_patching, included upstream
* disable patch: libpoppler-0.12, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *      Copyright (c) 2000,2001,2002 Guido Draheim <guidod@gmx.de>
3
 
 *      Use freely under the restrictions of the ZLIB license.
4
 
 */
5
 
 
6
 
#include <zzip/zzip.h>
7
 
#include <stdio.h>
8
 
#include <string.h>
9
 
 
10
 
#ifndef O_BINARY
11
 
#define O_BINARY 0
12
 
#endif
13
 
 
14
 
static const char usage[] = 
15
 
{
16
 
    "zzdir <dir>.. \n"
17
 
    "  - prints a content table to stdout, but the dir can also be a zip-arch."
18
 
    "\n"
19
 
    " To show the contents of a zip-archive named 'test.zip', you may write \n"
20
 
    "     zzdir test \n"
21
 
};
22
 
 
23
 
int 
24
 
main (int argc, char ** argv)
25
 
{
26
 
    int argn;
27
 
    int exitcode = 0; 
28
 
    
29
 
    if (argc <= 1 || ! strcmp (argv[1], "--help"))
30
 
    {
31
 
        printf (usage);
32
 
        return 0;
33
 
    }
34
 
    if (! strcmp (argv[1], "--version"))
35
 
    {
36
 
        printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
37
 
        return 0;
38
 
    }
39
 
 
40
 
    for (argn=1; argn < argc; argn++)
41
 
    {
42
 
        ZZIP_DIR * dir;
43
 
        ZZIP_DIRENT * d;
44
 
  
45
 
        dir = zzip_opendir(argv[argn]);
46
 
        if (! dir)
47
 
        {
48
 
            fprintf (stderr, "did not open %s: ", argv[argn]);
49
 
            perror(argv[argn]);
50
 
            exitcode++;
51
 
            continue;
52
 
        }
53
 
  
54
 
        if (argc > 2) printf ("%s: \n", argv[argn]);
55
 
 
56
 
        /* read each dir entry and show one line of info per file */
57
 
        while ((d = zzip_readdir (dir)))
58
 
        {
59
 
            /* orignalsize / compression-type / compression-ratio / filename */
60
 
            if (d->st_size > 999999)
61
 
            {
62
 
                printf ("%5dK %-9s %2d%% %s \n", 
63
 
                        d->st_size>>10, 
64
 
                        zzip_compr_str(d->d_compr), 
65
 
                        100 - (d->d_csize|1)/((d->st_size/100)|1),
66
 
                        d->d_name);
67
 
            }else{
68
 
                printf ("%6d %-9s %2d%% %s \n", 
69
 
                        d->st_size, 
70
 
                        zzip_compr_str(d->d_compr), 
71
 
                        100 - (d->d_csize|1)*100/(d->st_size|1),
72
 
                        d->d_name);
73
 
            }
74
 
        }
75
 
 
76
 
        zzip_closedir(dir);
77
 
    }
78
 
    
79
 
    return exitcode;
80
 
81
 
 
82
 
/* 
83
 
 * Local variables:
84
 
 * c-file-style: "stroustrup"
85
 
 * End:
86
 
 */