blob: c732a04c6cd6a3af20bb7822f5eb5fc01a510dbd [file] [log] [blame]
Lev Walkinc6cac8e2016-03-14 02:57:07 -07001#ifndef ASN1_COMPILER_INTERNAL_H
2#define ASN1_COMPILER_INTERNAL_H
Lev Walkinf15320b2004-06-03 03:38:44 +00003
Lev Walkin79f54952004-08-13 16:58:19 +00004#ifdef HAVE_CONFIG_H
5#include <config.h>
6#endif
7
Lev Walkinf15320b2004-06-03 03:38:44 +00008#include <stdio.h>
9#include <stdlib.h>
Lev Walkin84cd58e2004-08-19 13:29:46 +000010#include <string.h> /* for strlen(3) and memset(3) */
Lev Walkinf15320b2004-06-03 03:38:44 +000011#include <ctype.h> /* for isalnum(3) */
Lev Walkin4efbfb72005-02-25 14:20:30 +000012#include <sys/types.h> /* for fstat(2) */
Lev Walkinf15320b2004-06-03 03:38:44 +000013#include <stdarg.h>
14#include <errno.h>
15#include <assert.h>
16
Lev Walkin4efbfb72005-02-25 14:20:30 +000017#ifdef HAVE_SYS_STAT_H
18#include <sys/stat.h> /* for fstat(2) */
19#endif
20
21#ifdef HAVE_UNISTD_H
22#include <unistd.h> /* for unlink(2) */
23#endif
24
Lev Walkin93659562010-11-20 09:47:13 -080025#ifdef _WIN32
Lev Walkin4efbfb72005-02-25 14:20:30 +000026#include <io.h>
Lev Walkinc5a5d222007-06-23 17:35:56 +000027#include <malloc.h>
28#include <fcntl.h>
Lev Walkin4efbfb72005-02-25 14:20:30 +000029#define open _open
30#define close _close
Lev Walkin4efbfb72005-02-25 14:20:30 +000031#define snprintf _snprintf
32#define vsnprintf _vsnprintf
33#else
Lev Walkin4efbfb72005-02-25 14:20:30 +000034#include <glob.h> /* for glob(3) */
35#endif
Lev Walkinc5a5d222007-06-23 17:35:56 +000036#include <fcntl.h> /* for open(2) */
Lev Walkin4efbfb72005-02-25 14:20:30 +000037
38#ifdef HAVE_SYS_PARAM_H
39#include <sys/param.h> /* For MAXPATHLEN */
40#endif
41
Lev Walkinf15320b2004-06-03 03:38:44 +000042#include "asn1compiler.h"
43
Lev Walkin9de6cd82017-08-10 05:47:46 -070044struct asn1c_ioc_table_and_objset_s;
45
Lev Walkinf15320b2004-06-03 03:38:44 +000046typedef struct arg_s {
47
48 enum asn1c_flags flags;
49
50 void (*logger_cb)(int _severity, const char *fmt, ...);
51
Lev Walkin9de6cd82017-08-10 05:47:46 -070052 int (*default_cb)(struct arg_s *, const struct asn1c_ioc_table_and_objset_s *opt);
Lev Walkinf15320b2004-06-03 03:38:44 +000053
54 struct compiler_streams *target;
55
56 asn1p_t *asn;
Lev Walkinf15320b2004-06-03 03:38:44 +000057 asn1p_expr_t *expr;
58
Lev Walkinf15320b2004-06-03 03:38:44 +000059 int embed;
60} arg_t;
61
Lev Walkinf15320b2004-06-03 03:38:44 +000062/*
63 * Logging.
64 */
65#define LOG(ll, fmt, args...) do { \
66 arg->logger_cb(ll, fmt, ##args); \
67 } while(0)
68#define DEBUG(fmt, args...) do { \
69 if(arg->flags & A1C_DEBUG) \
70 LOG(-1, fmt, ##args); \
71 } while(0)
72#define WARNING(fmt, args...) LOG(0, fmt, ##args);
73#define FATAL(fmt, args...) LOG(1, fmt, ##args);
74
Lev Walkinc6cac8e2016-03-14 02:57:07 -070075#endif /* ASN1_COMPILER_INTERNAL_H */