Debian Codegraph @

libasn1parser/expr-h.pl

raw
1 #!/usr/bin/env perl
2
3
4 print<<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
12 #include <assert.h>
13
14 #ifndef __GNUC__
15 #define __attribute__(x) /* unused */
16 #endif
17
18 static char *asn1p_expr_type2str[] __attribute__ ((unused)) = {
19 EOM
20
21 while(<>) {
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
39 print<<EOM;
40 };
41
42 /*
43 * Convert the ASN.1 expression type back into the string representation.
44 */
45 #define ASN_EXPR_TYPE2STR(type) _asn1p_expr_type2string(type)
46
47 static inline char * __attribute__((unused))
48 _asn1p_expr_type2string(asn1p_expr_type_e type) {
49 assert((signed int)type >= 0);
50 if(type < sizeof(asn1p_expr_type2str)/sizeof(asn1p_expr_type2str[0]))
51 return asn1p_expr_type2str[type];
52 return NULL;
53 }
54
55 #endif /* ASN1_PARSER_EXPR_STR_H */
56 EOM