keysets.pl 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #!/usr/local/bin/perl
  2. $NUMBER=0x01;
  3. $UPPER=0x02;
  4. $LOWER=0x04;
  5. $UNDER=0x100;
  6. $PUNCTUATION=0x200;
  7. $WS=0x10;
  8. $ESC=0x20;
  9. $QUOTE=0x40;
  10. $DQUOTE=0x400;
  11. $COMMENT=0x80;
  12. $FCOMMENT=0x800;
  13. $EOF=0x08;
  14. $HIGHBIT=0x1000;
  15. foreach (0 .. 255)
  16. {
  17. $v=0;
  18. $c=sprintf("%c",$_);
  19. $v|=$NUMBER if ($c =~ /[0-9]/);
  20. $v|=$UPPER if ($c =~ /[A-Z]/);
  21. $v|=$LOWER if ($c =~ /[a-z]/);
  22. $v|=$UNDER if ($c =~ /_/);
  23. $v|=$PUNCTUATION if ($c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/);
  24. $v|=$WS if ($c =~ /[ \t\r\n]/);
  25. $v|=$ESC if ($c =~ /\\/);
  26. $v|=$QUOTE if ($c =~ /['`"]/); # for emacs: "`'}/)
  27. $v|=$COMMENT if ($c =~ /\#/);
  28. $v|=$EOF if ($c =~ /\0/);
  29. $v|=$HIGHBIT if ($c =~/[\x80-\xff]/);
  30. push(@V_def,$v);
  31. }
  32. foreach (0 .. 255)
  33. {
  34. $v=0;
  35. $c=sprintf("%c",$_);
  36. $v|=$NUMBER if ($c =~ /[0-9]/);
  37. $v|=$UPPER if ($c =~ /[A-Z]/);
  38. $v|=$LOWER if ($c =~ /[a-z]/);
  39. $v|=$UNDER if ($c =~ /_/);
  40. $v|=$PUNCTUATION if ($c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/);
  41. $v|=$WS if ($c =~ /[ \t\r\n]/);
  42. $v|=$DQUOTE if ($c =~ /["]/); # for emacs: "}/)
  43. $v|=$FCOMMENT if ($c =~ /;/);
  44. $v|=$EOF if ($c =~ /\0/);
  45. $v|=$HIGHBIT if ($c =~/[\x80-\xff]/);
  46. push(@V_w32,$v);
  47. }
  48. print <<"EOF";
  49. /* crypto/conf/conf_def.h */
  50. /* Copyright (C) 1995-1998 Eric Young (eay\@cryptsoft.com)
  51. * All rights reserved.
  52. *
  53. * This package is an SSL implementation written
  54. * by Eric Young (eay\@cryptsoft.com).
  55. * The implementation was written so as to conform with Netscapes SSL.
  56. *
  57. * This library is free for commercial and non-commercial use as long as
  58. * the following conditions are aheared to. The following conditions
  59. * apply to all code found in this distribution, be it the RC4, RSA,
  60. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  61. * included with this distribution is covered by the same copyright terms
  62. * except that the holder is Tim Hudson (tjh\@cryptsoft.com).
  63. *
  64. * Copyright remains Eric Young's, and as such any Copyright notices in
  65. * the code are not to be removed.
  66. * If this package is used in a product, Eric Young should be given attribution
  67. * as the author of the parts of the library used.
  68. * This can be in the form of a textual message at program startup or
  69. * in documentation (online or textual) provided with the package.
  70. *
  71. * Redistribution and use in source and binary forms, with or without
  72. * modification, are permitted provided that the following conditions
  73. * are met:
  74. * 1. Redistributions of source code must retain the copyright
  75. * notice, this list of conditions and the following disclaimer.
  76. * 2. Redistributions in binary form must reproduce the above copyright
  77. * notice, this list of conditions and the following disclaimer in the
  78. * documentation and/or other materials provided with the distribution.
  79. * 3. All advertising materials mentioning features or use of this software
  80. * must display the following acknowledgement:
  81. * "This product includes cryptographic software written by
  82. * Eric Young (eay\@cryptsoft.com)"
  83. * The word 'cryptographic' can be left out if the rouines from the library
  84. * being used are not cryptographic related :-).
  85. * 4. If you include any Windows specific code (or a derivative thereof) from
  86. * the apps directory (application code) you must include an acknowledgement:
  87. * "This product includes software written by Tim Hudson (tjh\@cryptsoft.com)"
  88. *
  89. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  90. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  91. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  92. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  93. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  94. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  95. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  96. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  97. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  98. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  99. * SUCH DAMAGE.
  100. *
  101. * The licence and distribution terms for any publically available version or
  102. * derivative of this code cannot be changed. i.e. this code cannot simply be
  103. * copied and put under another distribution licence
  104. * [including the GNU Public Licence.]
  105. */
  106. /*
  107. * THIS FILE WAS AUTOMAGICALLY GENERATED! Please modify and use keysets.pl to
  108. * regenerate it.
  109. */
  110. #define CONF_NUMBER $NUMBER
  111. #define CONF_UPPER $UPPER
  112. #define CONF_LOWER $LOWER
  113. #define CONF_UNDER $UNDER
  114. #define CONF_PUNCTUATION $PUNCTUATION
  115. #define CONF_WS $WS
  116. #define CONF_ESC $ESC
  117. #define CONF_QUOTE $QUOTE
  118. #define CONF_DQUOTE $DQUOTE
  119. #define CONF_COMMENT $COMMENT
  120. #define CONF_FCOMMENT $FCOMMENT
  121. #define CONF_EOF $EOF
  122. #define CONF_HIGHBIT $HIGHBIT
  123. #define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
  124. #define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
  125. #define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \\
  126. CONF_PUNCTUATION)
  127. #define KEYTYPES(c) ((unsigned short *)((c)->meth_data))
  128. #ifndef CHARSET_EBCDIC
  129. # define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
  130. # define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
  131. # define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
  132. # define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
  133. # define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
  134. # define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
  135. # define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
  136. # define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
  137. (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
  138. # define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
  139. # define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
  140. # define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
  141. #else /*CHARSET_EBCDIC*/
  142. # define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
  143. # define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
  144. # define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
  145. # define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
  146. # define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
  147. # define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
  148. # define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
  149. # define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
  150. (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
  151. # define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
  152. # define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
  153. # define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
  154. #endif /*CHARSET_EBCDIC*/
  155. EOF
  156. print "static unsigned short CONF_type_default[256] = {";
  157. for ($i=0; $i<256; $i++)
  158. {
  159. print "\n " if ($i % 8) == 0;
  160. printf " 0x%04X,",$V_def[$i];
  161. }
  162. print "\n};\n\n";
  163. print "static unsigned short CONF_type_win32[256] = {";
  164. for ($i=0; $i<256; $i++)
  165. {
  166. print "\n " if ($i % 8) == 0;
  167. printf " 0x%04X,",$V_w32[$i];
  168. }
  169. print "\n};\n";