blob: 99520b6bed4cfbab54bcf650bb2986319e14bad4 [file] [log] [blame]
Lev Walkin27fd0b62007-08-27 23:57:45 +00001#!/usr/bin/env perl
Lev Walkinf15320b2004-06-03 03:38:44 +00002
3
4print<<EOM;
5/*
6 * This file is automatically generated by $0
7 * DO NOT EDIT MANUALLY, fix the $0 instead if necessary.
8 */
9#ifndef ASN1_PARSER_EXPR_STR_H
10#define ASN1_PARSER_EXPR_STR_H
11
Lev Walkin04abdb22016-01-10 20:03:04 -080012#include <assert.h>
13
Lev Walkin4efbfb72005-02-25 14:20:30 +000014#ifndef __GNUC__
15#define __attribute__(x) /* unused */
16#endif
17
Lev Walkinf15320b2004-06-03 03:38:44 +000018static char *asn1p_expr_type2str[] __attribute__ ((unused)) = {
19EOM
20
21while(<>) {
22 chomp;
23 next if(/TYPE_MAX/);
24 next unless(/^[ \t]+(ASN_[A-Z]+_([A-Za-z0-9_]+))/);
25
26 print "\t[ $1 ]\t = ";
27
28 $_ = $2;
29 if($_ eq "RELATIVE_OID") {
30 print '"RELATIVE-OID"';
31 } else {
32 s/_/ /;
33 print '"'.$_.'"';
34 }
35
36 print ",\n";
37}
38
39print<<EOM;
40};
41
42/*
43 * Convert the ASN.1 expression type back into the string representation.
44 */
Lev Walkin483c14f2016-01-10 20:41:57 -080045#define ASN_EXPR_TYPE2STR(type) _asn1p_expr_type2string(type)
Lev Walkin04abdb22016-01-10 20:03:04 -080046
Lev Walkin483c14f2016-01-10 20:41:57 -080047static inline char * __attribute__((unused))
48_asn1p_expr_type2string(asn1p_expr_type_e type) {
49 assert((signed int)type >= 0);
Lev Walkin04abdb22016-01-10 20:03:04 -080050 if(type < sizeof(asn1p_expr_type2str)/sizeof(asn1p_expr_type2str[0]))
51 return asn1p_expr_type2str[type];
52 return NULL;
53}
Lev Walkinf15320b2004-06-03 03:38:44 +000054
55#endif /* ASN1_PARSER_EXPR_STR_H */
56EOM