This commit was generated by cvs2svn to track changes on a CVS vendor
[openssl.git] / crypto / conf / keysets.pl
1 #!/usr/local/bin/perl
2
3 $NUMBER=0x01;
4 $UPPER=0x02;
5 $LOWER=0x04;
6 $EOF=0x08;
7 $WS=0x10;
8 $ESC=0x20;
9 $QUOTE=0x40;
10 $COMMENT=0x80;
11 $UNDER=0x100;
12
13 foreach (0 .. 127)
14         {
15         $v=0;
16         $c=sprintf("%c",$_);
17         $v|=$NUMBER     if ($c =~ /[0-9]/);
18         $v|=$UPPER      if ($c =~ /[A-Z]/);
19         $v|=$LOWER      if ($c =~ /[a-z]/);
20         $v|=$UNDER      if ($c =~ /_/);
21         $v|=$WS         if ($c =~ / \t\r\n/);
22         $v|=$ESC        if ($c =~ /\\/);
23         $v|=$QUOTE      if ($c =~ /['`"]/);
24         $v|=$COMMENT    if ($c =~ /\#/);
25         $v|=$EOF        if ($c =~ /\0/);
26
27         push(@V,$v);
28         }
29
30 print <<"EOF";
31 #define CONF_NUMBER             $NUMBER
32 #define CONF_UPPER              $UPPER
33 #define CONF_LOWER              $LOWER
34 #define CONF_EOF                $EOF
35 #define CONF_WS                 $WS
36 #define CONF_ESC                $ESC
37 #define CONF_QUOTE              $QUOTE
38 #define CONF_COMMENT            $COMMENT
39 #define CONF_ALPHA              (CONF_UPPER|CONF_LOWER)
40 #define CONF_ALPHA_NUMERIC      (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
41 #define CONF_UNDER              $UNDER
42
43 #define IS_COMMENT(a)           (CONF_COMMENT&(CONF_type[(a)&0x7f]))
44 #define IS_EOF(a)               ((a) == '\\0')
45 #define IS_ESC(a)               ((a) == '\\\\')
46 #define IS_NUMER(a)             (CONF_type[(a)&0x7f]&CONF_NUMBER)
47 #define IS_WS(a)                (CONF_type[(a)&0x7f]&CONF_WS)
48 #define IS_ALPHA_NUMERIC(a)     (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC)
49 #define IS_QUOTE(a)             (CONF_type[(a)&0x7f]&CONF_QUOTE)
50
51 EOF
52
53 print "static unsigned short CONF_type[128]={";
54
55 for ($i=0; $i<128; $i++)
56         {
57         print "\n\t" if ($i % 8) == 0;
58         printf "0x%03X,",$V[$i];
59         }
60
61 print "\n\t};\n";