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