7a07e3540f493813c7dcbd7711927e7135e00b47
[com/asn1c.git] / libasn1compiler / asn1c_internal.h
1 #ifndef ASN1_COMPILER_INTERNAL_H
2 #define ASN1_COMPILER_INTERNAL_H
3
4 #ifdef  HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>             /* for strlen(3) and memset(3) */
11 #include <ctype.h>              /* for isalnum(3) */
12 #include <sys/types.h>          /* for fstat(2) */
13 #include <limits.h>             /* for PATH_MAX */
14 #include <stdarg.h>
15 #include <errno.h>
16 #include <assert.h>
17
18 #ifdef  HAVE_SYS_STAT_H
19 #include <sys/stat.h>           /* for fstat(2) */
20 #endif
21
22 #ifdef  HAVE_UNISTD_H
23 #include <unistd.h>             /* for unlink(2) */
24 #endif
25
26 #ifndef PATH_MAX
27 #define PATH_MAX    1024
28 #endif
29
30 #ifdef  _WIN32
31 #include <io.h>
32 #include <malloc.h>
33 #include <fcntl.h>
34 #define open    _open
35 #define close   _close
36 #define snprintf        _snprintf
37 #define vsnprintf       _vsnprintf
38 #else
39 #include <glob.h>               /* for glob(3) */
40 #endif
41 #include <fcntl.h>              /* for open(2) */
42
43 #include "asn1compiler.h"
44 #include "asn1_namespace.h"
45
46 struct asn1c_ioc_table_and_objset_s;
47
48 typedef struct arg_s {
49
50         enum asn1c_flags flags;
51
52         void (*logger_cb)(int _severity, const char *fmt, ...);
53
54         int (*default_cb)(struct arg_s *, const struct asn1c_ioc_table_and_objset_s *opt);
55
56         struct compiler_streams *target;
57
58     asn1p_t *asn;
59     asn1_namespace_t *ns;
60     asn1p_expr_t *expr;
61
62     int embed;
63 } arg_t;
64
65 /*
66  * Logging.
67  */
68 #define LOG(ll, fmt, args...)   do {                    \
69                 arg->logger_cb(ll, fmt, ##args);        \
70         } while(0)
71 #define DEBUG(fmt, args...)     do {            \
72                 if(arg->flags & A1C_DEBUG)      \
73                         LOG(-1, fmt, ##args);   \
74         } while(0)
75 #define WARNING(fmt, args...)   LOG(0, fmt, ##args);
76 #define FATAL(fmt, args...)     LOG(1, fmt, ##args);
77
78 #endif  /* ASN1_COMPILER_INTERNAL_H */