blob: 4489ae13ad00c3bb08dd2396023f9d5c7a5a1430 [file] [log] [blame]
Lev Walkinc6cac8e2016-03-14 02:57:07 -07001#ifndef ASN1_COMPILER_MISC_H
2#define ASN1_COMPILER_MISC_H
Lev Walkinf15320b2004-06-03 03:38:44 +00003
4/*
5 * Make the target language identifier out of one or more names.
6 * The function will concatenate the names and replace unsafe characters
7 * with safe ones.
8 */
Lev Walkin801fabc2005-01-28 12:18:50 +00009enum ami_flags_e {
10 AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */
11 AMI_CHECK_RESERVED = 2, /* Check against reserved keywords */
Lev Walkin22b5ed42006-09-13 02:51:20 +000012 AMI_NODELIMITER = 4, /* Do not put delimiter, just concatenate */
Harald Welte5e2364f2015-09-10 09:31:18 +020013 AMI_USE_PREFIX = 8, /* Use Prefix when generating identifier */
Lev Walkin801fabc2005-01-28 12:18:50 +000014};
Lev Walkina00d6b32006-03-21 03:40:38 +000015char *asn1c_make_identifier(enum ami_flags_e, asn1p_expr_t *expr, ...);
Lev Walkinf15320b2004-06-03 03:38:44 +000016
17/*
18 * Return the type name of the specified expression.
19 */
20enum tnfmt {
Lev Walkin801fabc2005-01-28 12:18:50 +000021 TNF_UNMODIFIED = 0x10, /* Return unmodified type name */
22 TNF_INCLUDE = 0x20, /* Format for #include <> */
23 TNF_CTYPE = 0x30, /* Format as normal C-ish type (append "_t") */
24 TNF_SAFE = 0x40, /* Replace unsafe characters with _ */
25 TNF_RSAFE = 0x50, /* Recursion-safe C type format */
Lev Walkinf15320b2004-06-03 03:38:44 +000026};
27char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
28
Lev Walkin082cadc2005-08-14 02:18:27 +000029/*
30 * Check whether the specified INTEGER or ENUMERATED type can be represented
31 * using the generic 'long' type.
32 * Return values:
33 * FL_NOTFIT: No, it cannot be represented using long.
Lev Walkin8bb57a22007-12-03 13:41:36 +000034 * FL_FITS_SIGNED: It can be represented using signed long.
35 * FL_FITS_UNSIGN: It can be represented using unsigned long.
Lev Walkin2a744a72013-03-27 01:56:23 -070036 * FL_PRESUMED: Probably can't, but -fwide-types is not in effect.
Lev Walkin082cadc2005-08-14 02:18:27 +000037 */
38enum asn1c_fitslong_e {
39 FL_NOTFIT,
Lev Walkin8bb57a22007-12-03 13:41:36 +000040 FL_FITS_SIGNED,
41 FL_FITS_UNSIGN,
Lev Walkin2a744a72013-03-27 01:56:23 -070042 FL_PRESUMED,
Lev Walkin082cadc2005-08-14 02:18:27 +000043};
44enum asn1c_fitslong_e asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr);
45
Lev Walkinc6cac8e2016-03-14 02:57:07 -070046#endif /* ASN1_COMPILER_MISC_H */