1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-17 02:05:21 +03:00
Samba Release Account 8bc7d6bebd Makefile: Changes to split Solaris into Solaris2.3 and previous, and 2.4 and after from Paul Eggert.
Makefile: Added AMIGA changes from Rask Ingemann Lambertsen <rask@k4315.kampsax.dtu.dk>.
charset.c: Patch for Western European Languages from Josef Hinteregger <joehtg@joehtg.co.at>
charset.h: Patch for Western European Languages from Josef Hinteregger <joehtg@joehtg.co.at>
clitar.c: Patch to re-sync after read fail from (lost contributor name, sorry).
includes.h: Patch for AMIGA from Rask Ingemann Lambertsen <rask@k4315.kampsax.dtu.dk>
includes.h: Patch for SunOS atexit by Jeremy (jra@cygnus.com)
interface.c: Patch for AMIGA from Rask Ingemann Lambertsen <rask@k4315.kampsax.dtu.dk>
kanji.h: Patch for Western European Languages from Josef Hinteregger <joehtg@joehtg.co.at>
locking.c: Patch to fix file locking from Jeremy (jra@cygnus.com)
locking.c: Patch to add granularity of lock files to usec by Jeremy (jra@cygnus.com)
pipes.c: Patch to fix file locking from Jeremy (jra@cygnus.com)
proto.h: Patch to fix file locking from Jeremy (jra@cygnus.com)
reply.c: Patch to fix file locking from Jeremy (jra@cygnus.com)
server.c: Patch to fix file locking from Jeremy (jra@cygnus.com)
server.c: Patch for FAST_SHARE_MODE fix from (lost contributor name, sorry).
smb.h: Patch to fix file locking from Jeremy (jra@cygnus.com)
smb.h: Patch to add granularity of lock files to usec by Jeremy (jra@cygnus.com)
status.c: Patch to fix file locking from Jeremy (jra@cygnus.com)
statuc.c: Patch to add granularity of lock files to usec by Jeremy (jra@cygnus.com)
system.c: Patch for Western European Languages from Josef Hinteregger <joehtg@joehtg.co.at>
trans2.c: Patch to fix file locking from Jeremy (jra@cygnus.com)
trans2.c: Patch to fix volume name reported to Win95 from Jeremy (jra@cygnus.com)
util.c: Patch for Western European Languages from Josef Hinteregger <joehtg@joehtg.co.at>
util.c: Patch to fix client_name from continuously returning UNKNOWN (from various contributors).
version.h: Update to 1.9.16p10.
(This used to be commit 03d28fa32eb094affa33133ebe2602fdb70f6361)
1997-01-09 18:02:17 +00:00

135 lines
3.6 KiB
C

/*
Unix SMB/Netbios implementation.
Version 1.9.
Character set conversion Extensions
Copyright (C) Andrew Tridgell 1992-1994
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#define CTRLZ 26
extern int DEBUGLEVEL;
static char cvtbuf[1024];
static mapsinited = 0;
static char unix2dos[256];
static char dos2unix[256];
static void initmaps() {
int k;
for (k = 0; k < 256; k++) unix2dos[k] = k;
for (k = 0; k < 256; k++) dos2unix[k] = k;
mapsinited = 1;
}
static void update_map(char * str) {
char *p;
for (p = str; *p; p++) {
if (p[1]) {
unix2dos[(unsigned char)*p] = p[1];
dos2unix[(unsigned char)p[1]] = *p;
p++;
}
}
}
static void initiso() {
int i;
if (!mapsinited) initmaps();
/* Do not map undefined characters to some accidental code */
for (i = 128; i < 256; i++)
{
unix2dos[i] = CTRLZ;
dos2unix[i] = CTRLZ;
}
/* MSDOS Code Page 850 -> ISO-8859 */
update_map("\240\377\241\255\242\275\243\234\244\317\245\276\246\335\247\365");
update_map("\250\371\251\270\252\246\253\256\254\252\255\360\256\251\257\356");
update_map("\260\370\261\361\262\375\263\374\264\357\265\346\266\364\267\372");
update_map("\270\367\271\373\272\247\273\257\274\254\275\253\276\363\277\250");
update_map("\300\267\301\265\302\266\303\307\304\216\305\217\306\222\307\200");
update_map("\310\324\311\220\312\322\313\323\314\336\315\326\316\327\317\330");
update_map("\320\321\321\245\322\343\323\340\324\342\325\345\326\231\327\236");
update_map("\330\235\331\353\332\351\333\352\334\232\335\355\336\350\337\341");
update_map("\340\205\341\240\342\203\343\306\344\204\345\206\346\221\347\207");
update_map("\350\212\351\202\352\210\353\211\354\215\355\241\356\214\357\213");
update_map("\360\320\361\244\362\225\363\242\364\223\365\344\366\224\367\366");
update_map("\370\233\371\227\372\243\373\226\374\201\375\354\376\347\377\230");
}
/*
* Convert unix to dos
*/
char *unix2dos_format(char *str,BOOL overwrite)
{
char *p;
char *dp;
if (!mapsinited) initmaps();
if (overwrite) {
for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
return str;
} else {
for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
*dp = 0;
return cvtbuf;
}
}
/*
* Convert dos to unix
*/
char *dos2unix_format(char *str, BOOL overwrite)
{
char *p;
char *dp;
if (!mapsinited) initmaps();
if (overwrite) {
for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
return str;
} else {
for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
*dp = 0;
return cvtbuf;
}
}
/*
* Interpret character set.
*/
int interpret_character_set(char *str, int def)
{
if (strequal (str, "iso8859-1")) {
initiso();
return def;
} else {
DEBUG(0,("unrecognized character set\n"));
}
return def;
}