| 1 | /*
|
|---|
| 2 | * This program is copyright Alec Muffett 1993, portions copyright other authors.
|
|---|
| 3 | * The authors disclaim all responsibility or liability with respect to it's usage
|
|---|
| 4 | * or its effect upon hardware or computer systems.
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | #ifndef CRACKLIB_PACKER_H
|
|---|
| 8 | #define CRACKLIB_PACKER_H
|
|---|
| 9 |
|
|---|
| 10 | /* Moved here cause needed by mod_php */
|
|---|
| 11 | #define STRINGSIZE 1024
|
|---|
| 12 | #define TRUNCSTRINGSIZE (STRINGSIZE/4)
|
|---|
| 13 |
|
|---|
| 14 | #ifndef NUMWORDS
|
|---|
| 15 | #define NUMWORDS 16
|
|---|
| 16 | #endif
|
|---|
| 17 | #define MAXWORDLEN 32
|
|---|
| 18 | #define MAXBLOCKLEN (MAXWORDLEN * NUMWORDS)
|
|---|
| 19 |
|
|---|
| 20 | #ifdef IN_CRACKLIB
|
|---|
| 21 |
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 | #include <ctype.h>
|
|---|
| 24 | #include <crack.h>
|
|---|
| 25 |
|
|---|
| 26 | #if defined(ENABLE_NLS)
|
|---|
| 27 | #include <libintl.h>
|
|---|
| 28 | #define _(String) dgettext("cracklib", String)
|
|---|
| 29 | #else
|
|---|
| 30 | #define _(String) (String)
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | #if defined(HAVE_INTTYPES_H)
|
|---|
| 34 | #include <inttypes.h>
|
|---|
| 35 | #else
|
|---|
| 36 | #if defined(HAVE_STDINT_H)
|
|---|
| 37 | #include <stdint.h>
|
|---|
| 38 | #else
|
|---|
| 39 | typedef unsigned int uint32_t;
|
|---|
| 40 | typedef unsigned short uint16_t;
|
|---|
| 41 | #endif
|
|---|
| 42 | #endif
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | struct pi_header
|
|---|
| 46 | {
|
|---|
| 47 | uint32_t pih_magic;
|
|---|
| 48 | uint32_t pih_numwords;
|
|---|
| 49 | uint16_t pih_blocklen;
|
|---|
| 50 | uint16_t pih_pad;
|
|---|
| 51 | };
|
|---|
| 52 |
|
|---|
| 53 | typedef struct
|
|---|
| 54 | {
|
|---|
| 55 | FILE *ifp;
|
|---|
| 56 | FILE *dfp;
|
|---|
| 57 | FILE *wfp;
|
|---|
| 58 |
|
|---|
| 59 | uint32_t flags;
|
|---|
| 60 | #define PFOR_WRITE 0x0001
|
|---|
| 61 | #define PFOR_FLUSH 0x0002
|
|---|
| 62 | #define PFOR_USEHWMS 0x0004
|
|---|
| 63 | #define PFOR_USEZLIB 0x0008
|
|---|
| 64 |
|
|---|
| 65 | uint32_t hwms[256];
|
|---|
| 66 |
|
|---|
| 67 | struct pi_header header;
|
|---|
| 68 |
|
|---|
| 69 | int count;
|
|---|
| 70 | char data[NUMWORDS][MAXWORDLEN];
|
|---|
| 71 | } PWDICT;
|
|---|
| 72 |
|
|---|
| 73 | #define PW_WORDS(x) ((x)->header.pih_numwords)
|
|---|
| 74 | #define PIH_MAGIC 0x70775631
|
|---|
| 75 |
|
|---|
| 76 | /* Internal routines */
|
|---|
| 77 | extern char *GetPW(PWDICT *pwp, uint32_t number);
|
|---|
| 78 |
|
|---|
| 79 | #else
|
|---|
| 80 |
|
|---|
| 81 | /* Dummy structure, this is an internal only opaque data type */
|
|---|
| 82 | typedef struct {
|
|---|
| 83 | int dummy;
|
|---|
| 84 | } PWDICT;
|
|---|
| 85 |
|
|---|
| 86 | #endif
|
|---|
| 87 |
|
|---|
| 88 | extern PWDICT *PWOpen(const char *prefix, char *mode);
|
|---|
| 89 | extern int PWClose(PWDICT *pwp);
|
|---|
| 90 | extern unsigned int FindPW(PWDICT *pwp, char *string);
|
|---|
| 91 | extern int PutPW(PWDICT *pwp, char *string);
|
|---|
| 92 | extern int PMatch(char *control, char *string);
|
|---|
| 93 | extern char *Mangle(char *input, char *control);
|
|---|
| 94 | extern char Chop(char *string);
|
|---|
| 95 | extern char *Trim(char *string);
|
|---|
| 96 |
|
|---|
| 97 | #endif
|
|---|