Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

229 lignes
7.0 KiB

  1. #!/usr/local/bin/perl
  2. open (NUMIN,"$ARGV[1]") || die "Can't open number file $ARGV[1]";
  3. $max_nid=0;
  4. $o=0;
  5. while(<NUMIN>)
  6. {
  7. chop;
  8. $o++;
  9. s/#.*$//;
  10. next if /^\s*$/;
  11. $_ = 'X'.$_;
  12. ($Cname,$mynum) = split;
  13. $Cname =~ s/^X//;
  14. if (defined($nidn{$mynum}))
  15. { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; }
  16. if (defined($nid{$Cname}))
  17. { die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; }
  18. $nid{$Cname} = $mynum;
  19. $nidn{$mynum} = $Cname;
  20. $order{$mynum} = $o;
  21. $max_nid = $mynum if $mynum > $max_nid;
  22. }
  23. close NUMIN;
  24. open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
  25. $Cname="";
  26. $o=0;
  27. while (<IN>)
  28. {
  29. chop;
  30. $o++;
  31. if (/^!module\s+(.*)$/)
  32. {
  33. $module = $1."-";
  34. $module =~ s/\./_/g;
  35. $module =~ s/-/_/g;
  36. }
  37. if (/^!global$/)
  38. { $module = ""; }
  39. if (/^!Cname\s+(.*)$/)
  40. { $Cname = $1; }
  41. if (/^!Alias\s+(.+?)\s+(.*)$/)
  42. {
  43. $Cname = $module.$1;
  44. $myoid = $2;
  45. $myoid = &process_oid($myoid);
  46. $Cname =~ s/-/_/g;
  47. $ordern{$o} = $Cname;
  48. $order{$Cname} = $o;
  49. $obj{$Cname} = $myoid;
  50. $_ = "";
  51. $Cname = "";
  52. }
  53. s/!.*$//;
  54. s/#.*$//;
  55. next if /^\s*$/;
  56. ($myoid,$mysn,$myln) = split ':';
  57. $mysn =~ s/^\s*//;
  58. $mysn =~ s/\s*$//;
  59. $myln =~ s/^\s*//;
  60. $myln =~ s/\s*$//;
  61. $myoid =~ s/^\s*//;
  62. $myoid =~ s/\s*$//;
  63. if ($myoid ne "")
  64. {
  65. $myoid = &process_oid($myoid);
  66. }
  67. if ($Cname eq "" && !($myln =~ / /))
  68. {
  69. $Cname = $myln;
  70. $Cname =~ s/\./_/g;
  71. $Cname =~ s/-/_/g;
  72. if ($Cname ne "" && defined($ln{$module.$Cname}))
  73. { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
  74. }
  75. if ($Cname eq "")
  76. {
  77. $Cname = $mysn;
  78. $Cname =~ s/-/_/g;
  79. if ($Cname ne "" && defined($sn{$module.$Cname}))
  80. { die "objects.txt:$o:There's already an object with short name ",$sn{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
  81. }
  82. if ($Cname eq "")
  83. {
  84. $Cname = $myln;
  85. $Cname =~ s/-/_/g;
  86. $Cname =~ s/\./_/g;
  87. $Cname =~ s/ /_/g;
  88. if ($Cname ne "" && defined($ln{$module.$Cname}))
  89. { die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
  90. }
  91. $Cname =~ s/\./_/g;
  92. $Cname =~ s/-/_/g;
  93. $Cname = $module.$Cname;
  94. $ordern{$o} = $Cname;
  95. $order{$Cname} = $o;
  96. $sn{$Cname} = $mysn;
  97. $ln{$Cname} = $myln;
  98. $obj{$Cname} = $myoid;
  99. if (!defined($nid{$Cname}))
  100. {
  101. $max_nid++;
  102. $nid{$Cname} = $max_nid;
  103. $nidn{$max_nid} = $Cname;
  104. print STDERR "Added OID $Cname\n";
  105. }
  106. $Cname="";
  107. }
  108. close IN;
  109. open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
  110. foreach (sort { $a <=> $b } keys %nidn)
  111. {
  112. print NUMOUT $nidn{$_},"\t\t",$_,"\n";
  113. }
  114. close NUMOUT;
  115. open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]";
  116. print OUT <<'EOF';
  117. /* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
  118. * following command:
  119. * perl objects.pl objects.txt obj_mac.num obj_mac.h */
  120. /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
  121. * All rights reserved.
  122. *
  123. * This package is an SSL implementation written
  124. * by Eric Young (eay@cryptsoft.com).
  125. * The implementation was written so as to conform with Netscapes SSL.
  126. *
  127. * This library is free for commercial and non-commercial use as long as
  128. * the following conditions are aheared to. The following conditions
  129. * apply to all code found in this distribution, be it the RC4, RSA,
  130. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  131. * included with this distribution is covered by the same copyright terms
  132. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  133. *
  134. * Copyright remains Eric Young's, and as such any Copyright notices in
  135. * the code are not to be removed.
  136. * If this package is used in a product, Eric Young should be given attribution
  137. * as the author of the parts of the library used.
  138. * This can be in the form of a textual message at program startup or
  139. * in documentation (online or textual) provided with the package.
  140. *
  141. * Redistribution and use in source and binary forms, with or without
  142. * modification, are permitted provided that the following conditions
  143. * are met:
  144. * 1. Redistributions of source code must retain the copyright
  145. * notice, this list of conditions and the following disclaimer.
  146. * 2. Redistributions in binary form must reproduce the above copyright
  147. * notice, this list of conditions and the following disclaimer in the
  148. * documentation and/or other materials provided with the distribution.
  149. * 3. All advertising materials mentioning features or use of this software
  150. * must display the following acknowledgement:
  151. * "This product includes cryptographic software written by
  152. * Eric Young (eay@cryptsoft.com)"
  153. * The word 'cryptographic' can be left out if the rouines from the library
  154. * being used are not cryptographic related :-).
  155. * 4. If you include any Windows specific code (or a derivative thereof) from
  156. * the apps directory (application code) you must include an acknowledgement:
  157. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  158. *
  159. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  160. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  161. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  162. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  163. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  164. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  165. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  166. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  167. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  168. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  169. * SUCH DAMAGE.
  170. *
  171. * The licence and distribution terms for any publically available version or
  172. * derivative of this code cannot be changed. i.e. this code cannot simply be
  173. * copied and put under another distribution licence
  174. * [including the GNU Public Licence.] */
  175. #define SN_undef "UNDEF"
  176. #define LN_undef "undefined"
  177. #define NID_undef 0
  178. #define OBJ_undef 0L
  179. EOF
  180. foreach (sort { $a <=> $b } keys %ordern)
  181. {
  182. $Cname=$ordern{$_};
  183. print OUT "#define SN_",$Cname,"\t\t\"",$sn{$Cname},"\"\n" if $sn{$Cname} ne "";
  184. print OUT "#define LN_",$Cname,"\t\t\"",$ln{$Cname},"\"\n" if $ln{$Cname} ne "";
  185. print OUT "#define NID_",$Cname,"\t\t",$nid{$Cname},"\n" if $nid{$Cname} ne "";
  186. print OUT "#define OBJ_",$Cname,"\t\t",$obj{$Cname},"\n" if $obj{$Cname} ne "";
  187. print OUT "\n";
  188. }
  189. close OUT;
  190. sub process_oid
  191. {
  192. local($oid)=@_;
  193. local(@a,$oid_pref);
  194. @a = split(/\s+/,$myoid);
  195. $pref_oid = "";
  196. $pref_sep = "";
  197. if (!($a[0] =~ /^[0-9]+$/))
  198. {
  199. $a[0] =~ s/-/_/g;
  200. if (!defined($obj{$a[0]}))
  201. { die "$ARGV[0]:$o:Undefined identifier ",$a[0],"\n"; }
  202. $pref_oid = "OBJ_" . $a[0];
  203. $pref_sep = ",";
  204. shift @a;
  205. }
  206. $oids = join('L,',@a) . "L";
  207. if ($oids ne "L")
  208. {
  209. $oids = $pref_oid . $pref_sep . $oids;
  210. }
  211. else
  212. {
  213. $oids = $pref_oid;
  214. }
  215. return($oids);
  216. }