Unix SMB/Netbios implementation.
Version 1.9.
Character set handling
- Copyright (C) Andrew Tridgell 1992-1997
+ Copyright (C) Andrew Tridgell 1992-1998
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
{
lower &= 0xff;
upper &= 0xff;
- DEBUG(6,("Adding chars 0x%x 0x%x (l->u = %s) (u->l = %s)\n",lower,upper,
- map_lower_to_upper ? "True" : "False",
- map_upper_to_lower ? "True" : "False"));
+ DEBUGADD( 6, ( "Adding chars 0x%x 0x%x (l->u = %s) (u->l = %s)\n",
+ lower, upper,
+ map_lower_to_upper ? "True" : "False",
+ map_upper_to_lower ? "True" : "False" ) );
if (lower) dos_char_map[lower] = 1;
if (upper) dos_char_map[upper] = 1;
lower_char_map[lower] = (char)lower; /* Define tolower(lower) */
/****************************************************************************
initialise the charset arrays
****************************************************************************/
-void charset_initialise()
+void charset_initialise(void)
{
int i;
for (i=0; i<=255; i++) {
char c = (char)i;
upper_char_map[i] = lower_char_map[i] = c;
- if (isupper(c)) lower_char_map[i] = tolower(c);
- if (islower(c)) upper_char_map[i] = toupper(c);
+
+ /* Some systems have buggy isupper/islower for characters
+ above 127. Best not to rely on them. */
+ if(i < 128) {
+ if (isupper(c)) lower_char_map[i] = tolower(c);
+ if (islower(c)) upper_char_map[i] = toupper(c);
+ }
}
}
return NULL;
}
- strcpy(codepage_file_name, CODEPAGEDIR);
- strcat(codepage_file_name, "/");
- strcat(codepage_file_name, "codepage.");
- sprintf( &codepage_file_name[strlen(codepage_file_name)], "%03d",
+ pstrcpy(codepage_file_name, CODEPAGEDIR);
+ pstrcat(codepage_file_name, "/");
+ pstrcat(codepage_file_name, "codepage.");
+ slprintf(&codepage_file_name[strlen(codepage_file_name)],
+ sizeof(pstring)-(strlen(codepage_file_name)+1),
+ "%03d",
client_codepage);
if(!file_exist(codepage_file_name,&st))
/* Check if it is at least big enough to hold the required
data. Should be 2 byte version, 2 byte codepage, 4 byte length,
plus zero or more bytes of data. Note that the data cannot be more
- than 512 bytes - giving a max size of 520.
+ than 4 * MAXCODEPAGELINES bytes.
*/
size = (unsigned int)st.st_size;
- if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 256))
+ if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 4 * MAXCODEPAGELINES))
{
DEBUG(0,("load_client_codepage: file %s is an incorrect size for a \
code page file.\n", codepage_file_name));
void codepage_initialise(int client_codepage)
{
int i;
- codepage_p cp = NULL;
- static BOOL done = False;
+ static codepage_p cp = NULL;
- if(done == True)
+ if(cp != NULL)
{
DEBUG(6,
("codepage_initialise: called twice - ignoring second client code page = %d\n",
for code page %d failed. Using default client codepage 932\n",
CODEPAGEDIR, client_codepage, client_codepage));
cp = cp_932;
+ client_codepage = KANJI_CODEPAGE;
#else /* KANJI */
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
for code page %d failed. Using default client codepage 850\n",
CODEPAGEDIR, client_codepage, client_codepage));
cp = cp_850;
+ client_codepage = MSDOS_LATIN_1_CODEPAGE;
#endif /* KANJI */
}
+ /*
+ * Setup the function pointers for the loaded codepage.
+ */
+ initialize_multibyte_vectors( client_codepage );
+
if(cp)
{
for(i = 0; !((cp[i][0] == '\0') && (cp[i][1] == '\0')); i++)
add_dos_char(cp[i][0], (BOOL)cp[i][2], cp[i][1], (BOOL)cp[i][3]);
}
-
- done = True;
}
/*******************************************************************