]> eyrie.org Git - kerberos/krb5-strength.git/blob - cracklib/packer.h
New upstream version 3.1
[kerberos/krb5-strength.git] / cracklib / packer.h
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  * 2007-03-23  Russ Allbery <eagle@eyrie.org>
13  *   - Add ANSI C prototypes and prototype additional functions.
14  * 2009-10-14  Russ Allbery <eagle@eyrie.org>
15  *   - Prototype changes for const cleanliness.
16  * 2010-03-14  Russ Allbery <eagle@eyrie.org>
17  *   - Fix int8, int16, and int32 definitions.
18  * 2013-10-01  Russ Allbery <eagle@eyrie.org>
19  *   - Set hidden visibility on all symbols by default.
20  */
21
22 #include <config.h>
23 #include <portable/system.h>
24
25 #include <ctype.h>
26
27 #define STRINGSIZE      1024
28 #define TRUNCSTRINGSIZE (STRINGSIZE/4)
29
30 typedef uint8_t int8;
31 typedef uint16_t int16;
32 typedef uint32_t int32;
33 #ifndef NUMWORDS
34 #define NUMWORDS        16
35 #endif
36 #define MAXWORDLEN      32
37 #define MAXBLOCKLEN     (MAXWORDLEN * NUMWORDS)
38
39 struct pi_header
40 {
41     int32 pih_magic;
42     int32 pih_numwords;
43     int16 pih_blocklen;
44     int16 pih_pad;
45 };
46
47 typedef struct
48 {
49     FILE *ifp;
50     FILE *dfp;
51     FILE *wfp;
52
53     int32 flags;
54 #define PFOR_WRITE      0x0001
55 #define PFOR_FLUSH      0x0002
56 #define PFOR_USEHWMS    0x0004
57
58     int32 hwms[256];
59
60     struct pi_header header;
61
62     int count;
63     char data[NUMWORDS][MAXWORDLEN];
64 } PWDICT;
65
66 #define PW_WORDS(x) ((x)->header.pih_numwords)
67 #define PIH_MAGIC 0x70775631
68
69 /* Default to a hidden visibility for all CrackLib functions. */
70 #pragma GCC visibility push(hidden)
71
72 extern PWDICT *PWOpen(const char *, const char *);
73 extern int32 FindPW(PWDICT *, const char *);
74 extern int PutPW(PWDICT *, const char *);
75 extern int PWClose(PWDICT *);
76 extern char *Mangle(const char *, const char *);
77 extern const char *FascistCheck(const char *, const char *);
78 extern char Chop(char *);
79 extern char *Trim(char *);
80 extern int PMatch(const char *, const char *);
81 extern char *Reverse(const char *);
82 extern char *Lowercase(const char *);
83
84 /* Undo default visibility change. */
85 #pragma GCC visibility pop
86
87 #define CRACK_TOLOWER(a)        (isupper(a)?tolower(a):(a)) 
88 #define CRACK_TOUPPER(a)        (islower(a)?toupper(a):(a)) 
89 #define STRCMP(a,b)             strcmp((a),(b))