Lev Walkin | 27fd0b6 | 2007-08-27 23:57:45 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 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 | |
Lev Walkin | 04abdb2 | 2016-01-10 20:03:04 -0800 | [diff] [blame] | 12 | #include <assert.h> |
| 13 | |
Lev Walkin | 4efbfb7 | 2005-02-25 14:20:30 +0000 | [diff] [blame] | 14 | #ifndef __GNUC__ |
| 15 | #define __attribute__(x) /* unused */ |
| 16 | #endif |
| 17 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 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 | */ |
Lev Walkin | 483c14f | 2016-01-10 20:41:57 -0800 | [diff] [blame] | 45 | #define ASN_EXPR_TYPE2STR(type) _asn1p_expr_type2string(type) |
Lev Walkin | 04abdb2 | 2016-01-10 20:03:04 -0800 | [diff] [blame] | 46 | |
Lev Walkin | 483c14f | 2016-01-10 20:41:57 -0800 | [diff] [blame] | 47 | static inline char * __attribute__((unused)) |
| 48 | _asn1p_expr_type2string(asn1p_expr_type_e type) { |
| 49 | assert((signed int)type >= 0); |
Lev Walkin | 04abdb2 | 2016-01-10 20:03:04 -0800 | [diff] [blame] | 50 | if(type < sizeof(asn1p_expr_type2str)/sizeof(asn1p_expr_type2str[0])) |
| 51 | return asn1p_expr_type2str[type]; |
| 52 | return NULL; |
| 53 | } |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 54 | |
| 55 | #endif /* ASN1_PARSER_EXPR_STR_H */ |
| 56 | EOM |