2 Unix SMB/Netbios implementation.
4 Character set conversion Extensions
5 Copyright (C) Andrew Tridgell 1992-1994
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.
23 extern int DEBUGLEVEL
;
25 static char cvtbuf
[1024];
27 static mapsinited
= 0;
29 static char unix2dos
[256];
30 static char dos2unix
[256];
32 static void initmaps() {
35 for (k
= 0; k
< 256; k
++) unix2dos
[k
] = k
;
36 for (k
= 0; k
< 256; k
++) dos2unix
[k
] = k
;
41 static void update_map(char * str
) {
44 for (p
= str
; *p
; p
++) {
46 unix2dos
[(unsigned char)*p
] = p
[1];
47 dos2unix
[(unsigned char)p
[1]] = *p
;
53 static void initiso() {
55 if (!mapsinited
) initmaps();
57 update_map("\241\255\242\233\243\234\244\236\245\235\246\272\247\025\250\251");
58 update_map("\251\273\252\246\253\256\254\252\255\274\256\310\257\257\260\370");
59 update_map("\261\361\262\375\263\264\264\265\265\266\266\024\267\371\270\267");
60 update_map("\271\270\272\247\273\275\274\254\275\253\276\276\277\250\200\277");
61 update_map("\301\300\302\301\303\302\304\216\305\217\306\222\307\200\310\303");
62 update_map("\311\220\312\305\313\306\314\307\315\315\316\317\317\320\320\311");
63 update_map("\321\245\322\321\323\322\324\323\325\324\326\231\327\312\330\325");
64 update_map("\331\326\332\327\333\330\334\232\335\313\336\314\337\341\340\205");
65 update_map("\341\240\342\203\343\331\344\204\345\206\346\221\347\207\350\212");
66 update_map("\351\202\352\210\353\211\354\215\355\241\356\214\357\213\360\316");
67 update_map("\361\244\362\225\363\242\364\223\365\332\366\224\367\366\370\362");
68 update_map("\371\227\372\243\373\226\374\201\375\304\376\263\377\230");
74 char *unix2dos_format(char *str
,BOOL overwrite
)
79 if (!mapsinited
) initmaps();
81 for (p
= str
; *p
; p
++) *p
= unix2dos
[(unsigned char)*p
];
84 for (p
= str
, dp
= cvtbuf
; *p
; p
++,dp
++) *dp
= unix2dos
[(unsigned char)*p
];
93 char *dos2unix_format(char *str
, BOOL overwrite
)
98 if (!mapsinited
) initmaps();
100 for (p
= str
; *p
; p
++) *p
= dos2unix
[(unsigned char)*p
];
103 for (p
= str
, dp
= cvtbuf
; *p
; p
++,dp
++) *dp
= dos2unix
[(unsigned char)*p
];
111 * Interpret character set.
113 int interpret_character_set(char *str
, int def
)
116 if (strequal (str
, "iso8859-1")) {
120 DEBUG(0,("unrecognized character set\n"));