/[webpac]/trunk/openisis/lcs.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/openisis/lcs.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 239 - (hide annotations)
Mon Mar 8 17:49:13 2004 UTC (20 years ago) by dpavlin
File MIME type: text/plain
File size: 6566 byte(s)
including openisis 0.9.0 into webpac tree

1 dpavlin 237 /*
2     openisis - an open implementation of the CDS/ISIS database
3     Version 0.8.x (patchlevel see file Version)
4     Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
5    
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Lesser General Public
8     License as published by the Free Software Foundation; either
9     version 2.1 of the License, or (at your option) any later version.
10    
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     Lesser General Public License for more details.
15    
16     You should have received a copy of the GNU Lesser General Public
17     License along with this library; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19    
20     see README for more information
21     EOH */
22    
23     /*
24     $Id: lcs.c,v 1.8 2003/04/08 00:20:52 kripke Exp $
25     charset support
26     */
27    
28     #include <string.h> /* memset */
29    
30     #include "luti.h"
31     #include "lio.h"
32     #include "lcs.h"
33    
34    
35     /* ************************************************************
36     private types
37     */
38     /* ************************************************************
39     private data
40     */
41     /* ************************************************************
42     private functions
43     */
44     /* ************************************************************
45     package functions
46     */
47     unsigned char lcs_latin1_uc[256] = {
48     0,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
49     ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
50     ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',
51     '0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?',
52     '@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
53     'P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_',
54     '`','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
55     'P','Q','R','S','T','U','V','W','X','Y','Z','{','|','}','~',' ',
56     ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
57     ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
58     ' ',161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
59     176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
60     'A','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I',
61     'T','N','O','O','O','O','O',215,'O','U','U','U','U','Y','T','S',
62     'A','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I',
63     'T','N','O','O','O','O','O',247,'O','U','U','U','U','Y','T','Y'
64     };
65    
66     unsigned char lcs_latin1_ct[256] = {
67     /* NUL STX SOT ETX EOT ENQ ACK BEL */
68     LCS_F,LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,
69     /* BS HT LF VT FF CR SO SI */
70     LCS_C,LCS_C,LCS_F,LCS_C,LCS_R,LCS_F,LCS_C,LCS_C,
71     /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
72     LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,
73     /* CAN EM SUB ESC FS GS RS US */
74     LCS_C,LCS_C,LCS_C,LCS_C,LCS_C,LCS_R,LCS_F,LCS_C,
75     /*blank ! " # $ % & ' */
76     LCS_S,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,
77     /* ( ) * + , - . / */
78     LCS_P,LCS_P,LCS_P,LCS_P,LCS_T,LCS_P,LCS_P,LCS_P,
79     /* 0 1 2 3 4 5 6 7 */
80     LCS_D,LCS_D,LCS_D,LCS_D,LCS_D,LCS_D,LCS_D,LCS_D,
81     /* 8 9 : ; < = > ? */
82     LCS_D,LCS_D,LCS_T,LCS_T,LCS_P,LCS_T,LCS_P,LCS_P,
83     /* @ A B C D E F G */
84     LCS_P,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
85     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A, /* H-O */
86     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A, /* P-W */
87     /* X Y Z [ \ ] ^ _ */
88     LCS_A,LCS_A,LCS_A,LCS_P,LCS_P,LCS_P,LCS_P,LCS_I,
89     /* ` a b c d e f g */
90     LCS_P,LCS_L,LCS_A,LCS_L,LCS_A,LCS_A,LCS_A,LCS_A,
91     LCS_A,LCS_L,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
92     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
93     /* x y z { | } ~ DEL */
94     LCS_L,LCS_A,LCS_A,LCS_P,LCS_P,LCS_P,LCS_P,LCS_C,
95     /* 32 C0 controls */
96     LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,
97     LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,
98     LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,
99     LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,LCS_P,
100     /* 32 mostly symbols */
101     LCS_S,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,
102     LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,
103     LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,
104     LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,LCS_Y,
105     /* 64 Latin alphas including 2 symbols */
106     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
107     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
108     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_Y,
109     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
110     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
111     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,
112     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_Y,
113     LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A,LCS_A
114     };
115    
116    
117     /* ************************************************************
118     package functions
119     */
120     int lcs_mktab ( LcsTab *dst, char *n, int l, int bits )
121     {
122     int ret = 0;
123     unsigned char *c = dst->c;
124     unsigned short *u = dst->u;
125     int line = 1;
126     int i = 0;
127     memset( dst, 0, sizeof(*dst) );
128     for (;; i++ ) {
129     unsigned short in = 0;
130     for ( ; l && (*n < '0' || '9' < *n); n++, l-- ) /* skip nondigs */
131     if ( '\n' == *n )
132     line++;
133     if ( ! l )
134     break;
135     for ( ; l && '0' <= *n && *n <= '9'; n++, l--)
136     in = 10*in + *n - '0';
137     if ( bits < 0 ) {
138     if ( i > 127 ) {
139     log_msg( LOG_WARN, "too many unicode values in input" );
140     return 0;
141     }
142     if ( in <= 0xffff )
143     u[i] = in;
144     else
145     log_msg( ERR_INVAL, "unicode %d too big %dth value line %d",
146     in, i, line );
147     continue;
148     }
149     if ( in > 0xff )
150     log_msg( ERR_INVAL, "byte %d too big %dth value line %d",
151     in, i, line );
152     else if ( bits )
153     c[in] |= bits;
154     else if ( i > 255 ) {
155     log_msg( LOG_WARN, "too many values in input" );
156     return 0;
157     } else
158     c[i] = (unsigned char)in;
159     }
160     return ret;
161     } /* lcs_mktab */
162    
163    
164     int lcs_mkrecod ( unsigned char *dst, unsigned short *from,
165     unsigned short *to )
166     {
167     int i = 0, j;
168     for ( i=0; i<128; i++ )
169     dst[i] = (unsigned char)i; /* identity */
170     for ( ; i<256; i++ ) {
171     unsigned short s = from[ i - 128 ];
172     dst[i] = ' ';
173     if ( to )
174     for ( j=128; j--; ) {
175     if ( s == to[j] ) {
176     dst[i] = (unsigned char)128+j;
177     break;
178     }
179     }
180     else if ( 256 > s ) /* map to latin 1 */
181     dst[i] = (unsigned char)s;
182     }
183     return 0;
184     } /* lcs_mkrecod */
185    
186    
187     /* ************************************************************
188     public functions
189     */

  ViewVC Help
Powered by ViewVC 1.1.26