2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-1995
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 extern int DEBUGLEVEL;
27 char xx_dos_char_map[256];
28 char xx_upper_char_map[256];
29 char xx_lower_char_map[256];
31 char *dos_char_map = NULL;
32 char *upper_char_map = NULL;
33 char *lower_char_map = NULL;
35 static void add_dos_char(int lower, int upper)
37 DEBUG(6,("Adding chars 0%o 0%o\n",lower,upper));
38 if (lower) dos_char_map[(char)lower] = 1;
39 if (upper) dos_char_map[(char)upper] = 1;
41 lower_char_map[(char)upper] = (char)lower;
42 upper_char_map[(char)lower] = (char)upper;
43 lower_char_map[(char)lower] = (char)lower;
44 upper_char_map[(char)upper] = (char)upper;
48 /****************************************************************************
49 initialise the charset arrays
50 ****************************************************************************/
51 void charset_initialise(void)
55 dos_char_map = &xx_dos_char_map[128];
56 upper_char_map = &xx_upper_char_map[128];
57 lower_char_map = &xx_lower_char_map[128];
59 for (i= -128;i<=127;i++) {
60 dos_char_map[(char)i] = 0;
63 for (i=0;i<=127;i++) {
64 if (isalnum((char)i) || strchr("._^$~!#%&-{}()@'`",(char)i))
68 for (i= -128;i<=127;i++) {
70 upper_char_map[i] = lower_char_map[i] = c;
71 if (isupper(c)) lower_char_map[c] = tolower(c);
72 if (islower(c)) upper_char_map[c] = toupper(c);
75 /* valid for all DOS PC */
76 add_dos_char(142,0); /* A trema */
77 add_dos_char(143,0); /* A o */
78 add_dos_char(144,0); /* E ' */
79 add_dos_char(146,0); /* AE */
80 add_dos_char(153,0); /* O trema */
81 add_dos_char(154,0); /* U trema */
82 add_dos_char(165,0); /* N tilda */
83 add_dos_char(128,0); /* C cedille */
84 add_dos_char(156,0); /* Pound */
85 add_dos_char(183,0); /* A ` (WIN)*/
86 add_dos_char(157,0); /* Phi (WIN)*/
87 add_dos_char(212,0); /* E` (WIN)*/
91 /*******************************************************************
92 add characters depending on a string passed by the user
93 ********************************************************************/
94 void add_char_string(char *s)
96 char *extra_chars = (char *)strdup(s);
98 if (!extra_chars) return;
100 for (t=strtok(extra_chars," \t\r\n"); t; t=strtok(NULL," \t\r\n")) {
103 if (isdigit(*t) || (*t)=='-') {
104 sscanf(t,"%i:%i",&i1,&i2);
107 sscanf(t,"%c:%c",&c1,&c2);