]> eyrie.org Git - kerberos/krb5-strength.git/blob - cracklib/packer.c
Merge branch 'debian' into squeeze
[kerberos/krb5-strength.git] / cracklib / packer.c
1 /*
2  * This program is copyright Alec Muffett 1993. The author disclaims all 
3  * responsibility or liability with respect to it's usage or its effect 
4  * upon hardware or computer systems, and maintains copyright as set out 
5  * in the "LICENCE" document which accompanies distributions of Crack v4.0 
6  * and upwards.
7  */
8
9 /*
10  * Modified as part of the krb5-strength project as follows:
11  *
12  * 2009-10-14  Russ Allbery <eagle@eyrie.org>
13  *   - Add ANSI C protototypes for all functions.
14  * 2010-03-14  Russ Allbery <eagle@eyrie.org>
15  *   - Use unsigned long instead of int32 to avoid printf warnings.
16  */
17
18 #include "packer.h"
19
20 int
21 main(int argc, char *argv[])
22 {
23     unsigned long readed;
24     unsigned long wrote;
25     PWDICT *pwp;
26     char buffer[STRINGSIZE];
27
28     if (argc <= 1)
29     {
30         fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
31         return (-1);
32     }
33
34     if (!(pwp = PWOpen(argv[1], "w")))
35     {
36         perror(argv[1]);
37         return (-1);
38     }
39
40     wrote = 0;
41
42     for (readed = 0; fgets(buffer, STRINGSIZE, stdin); /* nothing */)
43     {
44         readed++;
45
46         buffer[MAXWORDLEN - 1] = '\0';
47
48         Chop(buffer);
49
50         if (!buffer[0])
51         {
52             fprintf(stderr, "skipping line: %lu\n", readed);
53             continue;
54         }
55
56         if (PutPW(pwp, buffer))
57         {
58             fprintf(stderr, "error: PutPW '%s' line %luy\n", buffer, readed);
59         }
60
61         wrote++;
62     }
63
64     PWClose(pwp);
65
66     printf("%lu %lu\n", readed, wrote);
67
68     return (0);
69 }