keysets.pl 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. /* THIS FILE WAS AUTOMAGICALLY GENERATED!
  107. Please modify and use keysets.pl to regenerate it. */
  108. #define CONF_NUMBER $NUMBER
  109. #define CONF_UPPER $UPPER
  110. #define CONF_LOWER $LOWER
  111. #define CONF_UNDER $UNDER
  112. #define CONF_PUNCTUATION $PUNCTUATION
  113. #define CONF_WS $WS
  114. #define CONF_ESC $ESC
  115. #define CONF_QUOTE $QUOTE
  116. #define CONF_DQUOTE $DQUOTE
  117. #define CONF_COMMENT $COMMENT
  118. #define CONF_FCOMMENT $FCOMMENT
  119. #define CONF_EOF $EOF
  120. #define CONF_HIGHBIT $HIGHBIT
  121. #define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
  122. #define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
  123. #define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \\
  124. CONF_PUNCTUATION)
  125. #define KEYTYPES(c) ((const unsigned short *)((c)->meth_data))
  126. #ifndef CHARSET_EBCDIC
  127. #define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
  128. #define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
  129. #define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
  130. #define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
  131. #define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
  132. #define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
  133. #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
  134. #define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
  135. (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
  136. #define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
  137. #define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
  138. #define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
  139. #else /*CHARSET_EBCDIC*/
  140. #define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
  141. #define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
  142. #define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
  143. #define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
  144. #define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
  145. #define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
  146. #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
  147. #define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
  148. (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
  149. #define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
  150. #define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
  151. #define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
  152. #endif /*CHARSET_EBCDIC*/
  153. EOF
  154. print "static const unsigned short CONF_type_default[256]={";
  155. for ($i=0; $i<256; $i++)
  156. {
  157. print "\n\t" if ($i % 8) == 0;
  158. printf "0x%04X,",$V_def[$i];
  159. }
  160. print "\n\t};\n\n";
  161. print "static const unsigned short CONF_type_win32[256]={";
  162. for ($i=0; $i<256; $i++)
  163. {
  164. print "\n\t" if ($i % 8) == 0;
  165. printf "0x%04X,",$V_w32[$i];
  166. }
  167. print "\n\t};\n\n";