Changeset 1434:8850d29960aa in freeDiameter
- Timestamp:
- Feb 19, 2020, 4:05:01 PM (4 years ago)
- Branch:
- default
- Phase:
- public
- committer:
- Luke Mewburn <luke@mewburn.net> 1582097521 -39600
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/tools/org_to_fd.pl
r1433 r1434 1 1 #!/usr/bin/env perl 2 2 use strict; 3 use File::Basename; 3 4 use Getopt::Std; 5 6 my ($progname) = basename($0); 4 7 5 8 our ($opt_V, $opt_v); 6 9 7 # default to 3GPP8 my ($vendor) = 10415;9 my ($vendor_name) = " 3GPP";10 # default to Base 11 my ($vendor) = 0; 12 my ($vendor_name) = ""; 10 13 11 14 sub convert_must_to_flags($) { … … 33 36 } 34 37 38 39 my ($comment_width) = 64; 40 41 sub print_header() { 42 printf "\t/*=%s=*/\n", '=' x $comment_width; 43 } 44 45 sub print_comment($) { 46 my ($str) = @_; 47 printf "\t/* %-*s */\n", $comment_width, $str; 48 } 49 35 50 sub print_insert($$) { 36 51 my ($type, $name) = @_; … … 40 55 $avp_type = "NULL"; 41 56 } elsif ($type =~ m/Enumerated/) { 42 print "\t\tstruct dict_object 43 print "\t\tstruct dict_type_data 57 print "\t\tstruct dict_object\t*type;\n"; 58 print "\t\tstruct dict_type_data\t tdata = { AVP_TYPE_INTEGER32, \"Enumerated(" . ($vendor_name ? "$vendor_name/" : "") ."$name)\", NULL, NULL, NULL };\n"; 44 59 # XXX: add enumerated values 45 60 print "\t\tCHECK_dict_new(DICT_TYPE, &tdata, NULL, &type);\n"; … … 53 68 54 69 sub usage($) { 55 die( "usage: org_to_fd.pl [-V vendor_name -v vendor_code] [file ...]\n");70 die(sprintf("usage: %s [-V vendor_name] [-v vendor_code] [file ...]\n", $progname)); 56 71 exit(@_); 57 72 } … … 62 77 $vendor = $opt_v; 63 78 if (!defined($opt_V)) { 64 79 usage(1); 65 80 } 66 81 $vendor_name = $opt_V; 67 82 } 68 83 69 print "\t/* The following is created automatically. Do not modify. */\n"; 70 print "\t/* Changes will be lost during the next update. Modify the source org file instead. */\n\n"; 84 print_header(); 85 print_comment("Start of generated data."); 86 print_comment(""); 87 print_comment("The following is created automatically with:"); 88 print_comment(sprintf(" org_to_fd.pl -V '%s' -v %s", $vendor_name, $vendor)); 89 print_comment("Changes will be lost during the next update."); 90 print_comment("Do not modify; modify the source .org file instead."); 91 print_header(); 92 print "\n"; 71 93 72 94 while (<>) { … … 75 97 next if ($name =~ m/Attribute Name/); 76 98 if ($name =~ m/# (.*)/) { 77 print f "\t/* %-60s */\n", $1;99 print_comment($1); 78 100 next; 79 101 } 80 102 81 103 if ($name =~ m/\s/) { 82 104 die(sprintf("name '%s' contains space", $name)); 83 105 } 84 106 85 print "\t/* $name */\n\t{\n\t\tstruct dict_avp_data data = {\n"; 107 my ($desc) = $name; 108 $desc .= ", " . $type; 109 $desc .= ", code " . $code; 110 $desc .= ", section " . $section if $section != ""; 111 print_comment($desc); 112 print "\t{\n"; 113 print "\t\tstruct dict_avp_data data = {\n"; 86 114 print "\t\t\t$code,\t/* Code */\n"; 87 115 print "\t\t\t$vendor,\t/* Vendor */\n"; … … 94 122 print "\t};\n\n"; 95 123 } 124 125 print_header(); 126 print_comment("End of generated data."); 127 print_header();
Note: See TracChangeset
for help on using the changeset viewer.