blob: 7a07e3540f493813c7dcbd7711927e7135e00b47 [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 Walkin7d5d9302017-11-13 22:17:20 -080013#include <limits.h> /* for PATH_MAX */
Lev Walkinf15320b2004-06-03 03:38:44 +000014#include <stdarg.h>
15#include <errno.h>
16#include <assert.h>
17
Lev Walkin4efbfb72005-02-25 14:20:30 +000018#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
Lev Walkin7d5d9302017-11-13 22:17:20 -080026#ifndef PATH_MAX
27#define PATH_MAX 1024
28#endif
29
Lev Walkin93659562010-11-20 09:47:13 -080030#ifdef _WIN32
Lev Walkin4efbfb72005-02-25 14:20:30 +000031#include <io.h>
Lev Walkinc5a5d222007-06-23 17:35:56 +000032#include <malloc.h>
33#include <fcntl.h>
Lev Walkin4efbfb72005-02-25 14:20:30 +000034#define open _open
35#define close _close
Lev Walkin4efbfb72005-02-25 14:20:30 +000036#define snprintf _snprintf
37#define vsnprintf _vsnprintf
38#else
Lev Walkin4efbfb72005-02-25 14:20:30 +000039#include <glob.h> /* for glob(3) */
40#endif
Lev Walkinc5a5d222007-06-23 17:35:56 +000041#include <fcntl.h> /* for open(2) */
Lev Walkin4efbfb72005-02-25 14:20:30 +000042
Lev Walkinf15320b2004-06-03 03:38:44 +000043#include "asn1compiler.h"
Lev Walkinc0e03b92017-08-22 01:48:23 -070044#include "asn1_namespace.h"
Lev Walkinf15320b2004-06-03 03:38:44 +000045
Lev Walkin9de6cd82017-08-10 05:47:46 -070046struct asn1c_ioc_table_and_objset_s;
47
Lev Walkinf15320b2004-06-03 03:38:44 +000048typedef struct arg_s {
49
50 enum asn1c_flags flags;
51
52 void (*logger_cb)(int _severity, const char *fmt, ...);
53
Lev Walkin9de6cd82017-08-10 05:47:46 -070054 int (*default_cb)(struct arg_s *, const struct asn1c_ioc_table_and_objset_s *opt);
Lev Walkinf15320b2004-06-03 03:38:44 +000055
56 struct compiler_streams *target;
57
Lev Walkinc0e03b92017-08-22 01:48:23 -070058 asn1p_t *asn;
59 asn1_namespace_t *ns;
60 asn1p_expr_t *expr;
Lev Walkinf15320b2004-06-03 03:38:44 +000061
Lev Walkinc0e03b92017-08-22 01:48:23 -070062 int embed;
Lev Walkinf15320b2004-06-03 03:38:44 +000063} arg_t;
64
Lev Walkinf15320b2004-06-03 03:38:44 +000065/*
66 * Logging.
67 */
68#define LOG(ll, fmt, args...) do { \
Lev Walkinc17e14e2017-09-05 03:31:46 -070069 arg->logger_cb(ll, fmt, ##args); \
Lev Walkinf15320b2004-06-03 03:38:44 +000070 } 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
Lev Walkinc6cac8e2016-03-14 02:57:07 -070078#endif /* ASN1_COMPILER_INTERNAL_H */