mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
Jeremy can you check lib/util_unistr.c for codepages support ?
I added 2 UNICODE <-> ASCII functions which _don't_ honor codepage support. J.F.
This commit is contained in:
parent
bd9d4cdde9
commit
b81dc7b7f8
@ -1661,6 +1661,18 @@ void *Realloc(void *p,size_t size)
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
free memory, checks for NULL
|
||||
****************************************************************************/
|
||||
void safe_free(void *p)
|
||||
{
|
||||
if (p != NULL)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
get my own name and IP
|
||||
****************************************************************************/
|
||||
|
@ -78,6 +78,61 @@ int dos_PutUniCode(char *dst,const char *src, ssize_t len)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Put an ASCII string into a UNICODE array (uint16's).
|
||||
|
||||
Warning: doesn't do any codepage !!! BAD !!!
|
||||
|
||||
Help ! Fix Me ! Fix Me !
|
||||
********************************************************************/
|
||||
|
||||
void ascii_to_unistr(uint16 *dest, const char *src, int maxlen)
|
||||
{
|
||||
uint16 *destend = dest + maxlen;
|
||||
register char c;
|
||||
|
||||
while (dest < destend)
|
||||
{
|
||||
c = *(src++);
|
||||
if (c == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
*(dest++) = (uint16)c;
|
||||
}
|
||||
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Pull an ASCII string out of a UNICODE array (uint16's).
|
||||
|
||||
Warning: doesn't do any codepage !!! BAD !!!
|
||||
|
||||
Help ! Fix Me ! Fix Me !
|
||||
********************************************************************/
|
||||
|
||||
void unistr_to_ascii(char *dest, const uint16 *src, int len)
|
||||
{
|
||||
char *destend = dest + len;
|
||||
register uint16 c;
|
||||
|
||||
while (dest < destend)
|
||||
{
|
||||
c = *(src++);
|
||||
if (c == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
*(dest++) = (char)c;
|
||||
}
|
||||
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Skip past some unicode strings in a buffer.
|
||||
********************************************************************/
|
||||
@ -182,6 +237,48 @@ char *dos_unistr2_to_str(UNISTR2 *str)
|
||||
return lbuf;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Convert a UNISTR2 structure to an ASCII string
|
||||
Warning: this version does DOS codepage.
|
||||
********************************************************************/
|
||||
|
||||
void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
|
||||
{
|
||||
char *destend;
|
||||
const uint16 *src;
|
||||
size_t len;
|
||||
register uint16 c;
|
||||
|
||||
src = str->buffer;
|
||||
len = MIN(str->uni_str_len, maxlen);
|
||||
destend = dest + len;
|
||||
|
||||
while (dest < destend)
|
||||
{
|
||||
uint16 ucs2_val;
|
||||
uint16 cp_val;
|
||||
|
||||
c = *(src++);
|
||||
if (c == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ucs2_val = SVAL(src,0);
|
||||
cp_val = ucs2_to_doscp[ucs2_val];
|
||||
|
||||
if (cp_val < 256)
|
||||
*(dest++) = (char)cp_val;
|
||||
else {
|
||||
*dest= (cp_val >> 8) & 0xff;
|
||||
*(dest++) = (cp_val & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Return a number stored in a buffer
|
||||
********************************************************************/
|
||||
|
@ -159,6 +159,8 @@ typedef struct
|
||||
char *szAddUserScript;
|
||||
char *szDelUserScript;
|
||||
char *szWINSHook;
|
||||
char *szNtForms;
|
||||
char *szNtDriverFile;
|
||||
#ifdef WITH_UTMP
|
||||
char *szUtmpDir;
|
||||
#endif /* WITH_UTMP */
|
||||
@ -721,6 +723,8 @@ static struct parm_struct parm_table[] =
|
||||
{"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, 0},
|
||||
{"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL, FLAG_PRINT},
|
||||
{"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL, FLAG_PRINT|FLAG_GLOBAL},
|
||||
{"nt forms file", P_STRING, P_GLOBAL, &Globals.szNtForms, NULL, NULL, FLAG_GLOBAL},
|
||||
{"nt printer driver",P_STRING, P_GLOBAL, &Globals.szNtDriverFile, NULL, NULL, FLAG_GLOBAL},
|
||||
|
||||
|
||||
{"Filename Handling", P_SEP, P_SEPARATOR},
|
||||
@ -908,6 +912,8 @@ static void init_globals(void)
|
||||
string_set(&Globals.szPasswdProgram, PASSWD_PROGRAM);
|
||||
string_set(&Globals.szPrintcapname, PRINTCAP_NAME);
|
||||
string_set(&Globals.szDriverFile, DRIVERFILE);
|
||||
string_set(&Globals.szNtForms, FORMSFILE);
|
||||
string_set(&Globals.szNtDriverFile, NTDRIVERSDIR);
|
||||
string_set(&Globals.szLockDir, LOCKDIR);
|
||||
string_set(&Globals.szRootdir, "/");
|
||||
#ifdef WITH_UTMP
|
||||
@ -1222,6 +1228,9 @@ FN_GLOBAL_STRING(lp_domain_guest_group,&Globals.szDomainGuestGroup)
|
||||
FN_GLOBAL_STRING(lp_domain_admin_users,&Globals.szDomainAdminUsers)
|
||||
FN_GLOBAL_STRING(lp_domain_guest_users,&Globals.szDomainGuestUsers)
|
||||
|
||||
FN_GLOBAL_STRING(lp_nt_forms,&Globals.szNtForms)
|
||||
FN_GLOBAL_STRING(lp_nt_drivers_file,&Globals.szNtDriverFile)
|
||||
|
||||
#ifdef WITH_LDAP
|
||||
FN_GLOBAL_STRING(lp_ldap_server,&Globals.szLdapServer);
|
||||
FN_GLOBAL_STRING(lp_ldap_suffix,&Globals.szLdapSuffix);
|
||||
|
@ -44,6 +44,7 @@ static char *known_nt_pipes[] = {
|
||||
"\\lsass",
|
||||
"\\lsarpc",
|
||||
"\\winreg",
|
||||
"\\spoolss",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -468,6 +468,9 @@ static void init_structs(void )
|
||||
/* for LSA handles */
|
||||
init_lsa_policy_hnd();
|
||||
|
||||
/* for SPOOLSS handles */
|
||||
init_printer_hnd();
|
||||
|
||||
init_dptrs();
|
||||
}
|
||||
|
||||
@ -707,8 +710,8 @@ static void usage(char *pname)
|
||||
DEBUG( 3, ( "Becoming a daemon.\n" ) );
|
||||
become_daemon();
|
||||
}
|
||||
|
||||
check_kernel_oplocks();
|
||||
|
||||
check_kernel_oplocks();
|
||||
|
||||
if (!directory_exist(lp_lockdir(), NULL)) {
|
||||
mkdir(lp_lockdir(), 0755);
|
||||
|
Loading…
x
Reference in New Issue
Block a user