Initial Revision
[ohcount] / ext / ohcount_native / common.h
1 /*
2  *  common.h
3  *  Ohcount
4  *
5  *  Created by Jason Allen on 6/23/06.
6  *  Copyright 2006 Ohloh. All rights reserved.
7  *
8  */
9 #ifndef __common_h__
10 #define __common_h__
11
12 /*******************************************
13  Limits
14 *******************************************/
15 // The Parser's CompiledState Stack
16 #define MAX_CS_STACK 20
17 // Parser's Maximum number of LanguageBreakdowns it can return
18 #define MAX_LANGUAGE_BREAKDOWN_SIZE 8
19 // How large can a CompiledState's regex term be?
20 #define MAX_REGEX 200
21 // CompiledState's number of transitions
22 #define MAX_TRANSITIONS 10
23 // The longest a language name can be
24 #define MAX_LANGUAGE_NAME 20
25
26 /*******************************************
27  Common Headers
28 *******************************************/
29 #include <stdbool.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <pcre.h>
33 #include "transition.h"
34 #include "state.h"
35 #include "compiled_state.h"
36 #include "polyglot.h"
37 #include "polyglots.h"
38 #include "language_breakdown.h"
39 #include "parser.h"
40
41 /*******************************************
42  Error Handling
43 *******************************************/
44 void die(char *err, int exit_code);
45
46 enum EXIT_CODES {
47         ERR_PCRE_OUT_OF_MEMORY = 15,
48         ERR_PCRE_GENERIC,
49         ERR_UNKNOWN_SEMANTIC
50 };
51
52
53 /*******************************************
54  Logging
55 *******************************************/
56
57 #ifdef NDEBUG
58 #define log(e, arg) ((void)0)
59 #define log0(e) ((void)0)
60 #define log2(e, arg1, arg2) ((void)0)
61 #else
62 #define log(e, arg) (fprintf(stderr, e, arg))
63 #define log0(e) (fprintf(stderr, e))
64 #define log2(e, arg1, arg2) (fprintf(stderr, e, arg1, arg2))
65 #endif
66
67
68 #endif /* common_h */