1 /*
2  * This file is part of John the Ripper password cracker,
3  * Copyright (c) 1996-2000 by Solar Designer
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted.
7  *
8  * There's ABSOLUTELY NO WARRANTY, express or implied.
9  */
10 
11 /*
12  * Simple C compiler.
13  */
14 
15 #ifndef _JOHN_COMPILER_H
16 #define _JOHN_COMPILER_H
17 
18 /*
19  * Error codes.
20  */
21 #define C_ERROR_NONE			0
22 #define C_ERROR_UNKNOWN			1
23 #define C_ERROR_UNEXPECTED		2
24 #define C_ERROR_COUNT			3
25 #define C_ERROR_TOOLONG			4
26 #define C_ERROR_TOOCOMPLEX		5
27 #define C_ERROR_ARRAYSIZE		6
28 #define C_ERROR_DATASIZE		7
29 #define C_ERROR_RANGE			8
30 #define C_ERROR_DUPE			9
31 #define C_ERROR_RESERVED		10
32 #define C_ERROR_NOTINFUNC		11
33 #define C_ERROR_NESTEDFUNC		12
34 #define C_ERROR_NOTINIF			13
35 #define C_ERROR_NOTINLOOP		14
36 #define C_ERROR_EOF			15
37 #define C_ERROR_INTERNAL		16
38 
39 /*
40  * Error names.
41  */
42 extern char *c_errors[];
43 
44 /*
45  * Last error code.
46  */
47 extern int c_errno;
48 
49 /*
50  * Data type used by compiled programs.
51  */
52 typedef int c_int;
53 
54 /*
55  * Identifier list entry.
56  */
57 struct c_ident {
58 /* Pointer to next entry */
59 	struct c_ident *next;
60 
61 /* This identifier */
62 	char *name;
63 
64 /* Its address */
65 	void *addr;
66 };
67 
68 /*
69  * Runs the compiler, and allocates some memory for its output and the
70  * program's data. Returns one of the error codes.
71  */
72 extern int c_compile(int (*ext_getchar)(void), void (*ext_rewind)(void),
73 	struct c_ident *externs);
74 
75 /*
76  * Returns the function's address or NULL if not found.
77  */
78 extern void *c_lookup(const char *name);
79 
80 /*
81  * Executes a function previously compiled with c_compile().
82  */
83 #define c_execute(addr) \
84 	if (addr) \
85 		c_execute_fast(addr)
86 extern void c_execute_fast(void *addr);
87 
88 extern void c_cleanup();
89 
90 #endif
91