mirror of
https://github.com/samba-team/samba.git
synced 2025-03-04 16:58:42 +03:00
lib/util_unistr.c: Removed ascii_to_unistr() as it does no codepage.
Removed unistr_to_ascii() as it was never used. printing/nt_printing.c: Removed "DUMMY.XX" files. rpc_server/srv_spoolss_nt.c: Use dos_PutUniCode() instead of ascii_to_unistr(). Attempted to fix the "return value" size code based on J.F's comments. This needs looking at. Jeremy.
This commit is contained in:
parent
5afc5f5031
commit
de99011bf3
source
File diff suppressed because it is too large
Load Diff
@ -48,13 +48,13 @@ static uint16 *ucs2_to_unixcp;
|
||||
|
||||
if null_terminate is True then null terminate the packet (adds 2 bytes)
|
||||
|
||||
the return value is the length consumed by the string, including the
|
||||
the return value is the length in bytes consumed by the string, including the
|
||||
null termination if applied
|
||||
********************************************************************/
|
||||
|
||||
int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate)
|
||||
size_t dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t ret = 0;
|
||||
while (*src && (len > 2)) {
|
||||
size_t skip = get_character_len(*src);
|
||||
smb_ucs2_t val = (*src & 0xff);
|
||||
@ -83,51 +83,6 @@ int dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Put an ASCII string into a UNICODE string.
|
||||
|
||||
Warning: doesn't do any codepage !!! BAD !!!
|
||||
|
||||
Help ! Fix Me ! Fix Me !
|
||||
********************************************************************/
|
||||
|
||||
void ascii_to_unistr(char *dest, const char *src, size_t maxlen)
|
||||
{
|
||||
char *destend = dest + maxlen;
|
||||
char c;
|
||||
|
||||
while (dest < destend) {
|
||||
c = *(src++);
|
||||
if (c == 0) break;
|
||||
|
||||
SSVAL(dest, 0, (uint16)c);
|
||||
dest += 2;
|
||||
}
|
||||
SSVAL(dest, 0, 0);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* HORRIBLE HACK!
|
||||
********************************************************************/
|
||||
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;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Pull a DOS codepage string out of a UNICODE array. len is in bytes.
|
||||
********************************************************************/
|
||||
|
@ -378,16 +378,16 @@ static uint32 get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **in
|
||||
fstrcpy(info.name, lp_printerdriver(snum));
|
||||
fstrcpy(info.defaultdatatype, "RAW");
|
||||
|
||||
fstrcpy(info.driverpath, "DUMMY.DLL");
|
||||
fstrcpy(info.datafile, "DUMMY.PPD");
|
||||
fstrcpy(info.configfile, "DUMMY.DLL");
|
||||
fstrcpy(info.helpfile, "DUMMY.HLP");
|
||||
fstrcpy(info.driverpath, "");
|
||||
fstrcpy(info.datafile, "");
|
||||
fstrcpy(info.configfile, "");
|
||||
fstrcpy(info.helpfile, "");
|
||||
|
||||
if ((info.dependentfiles=(fstring *)malloc(2*sizeof(fstring))) == NULL)
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
memset(info.dependentfiles, '\0', 2*sizeof(fstring));
|
||||
fstrcpy(info.dependentfiles[0], "DUMMY.PPD");
|
||||
fstrcpy(info.dependentfiles[0], "");
|
||||
|
||||
*info_ptr = memdup(&info, sizeof(info));
|
||||
|
||||
@ -734,8 +734,7 @@ BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_
|
||||
if (current==NULL) return (False);
|
||||
|
||||
if ( !strcmp(current->value, param->value) &&
|
||||
(strlen(current->value)==strlen(param->value)) )
|
||||
{
|
||||
(strlen(current->value)==strlen(param->value)) ) {
|
||||
DEBUG(109,("deleting first value\n"));
|
||||
info_2->specific=current->next;
|
||||
safe_free(current->data);
|
||||
@ -746,13 +745,12 @@ BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_
|
||||
|
||||
current=previous->next;
|
||||
|
||||
while ( current!=NULL )
|
||||
{
|
||||
while ( current!=NULL ) {
|
||||
if (!strcmp(current->value, param->value) &&
|
||||
strlen(current->value)==strlen(param->value) )
|
||||
{
|
||||
strlen(current->value)==strlen(param->value) ) {
|
||||
DEBUG(109,("deleting current value\n"));
|
||||
previous->next=current->next;
|
||||
safe_free(current->data);
|
||||
safe_free(current);
|
||||
DEBUG(109,("deleted current value\n"));
|
||||
return(True);
|
||||
|
@ -897,8 +897,8 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p
|
||||
|
||||
snprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname);
|
||||
|
||||
data->notify_data.data.length=strlen(temp_name);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length= (uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
temp_name, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -910,12 +910,10 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data,
|
||||
{
|
||||
/*
|
||||
data->notify_data.data.length=strlen(lp_servicename(snum));
|
||||
ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1);
|
||||
dos_PutUniCode(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string), True);
|
||||
*/
|
||||
data->notify_data.data.length=strlen(printer->info_2->printername);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->printername,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->printername, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -923,10 +921,8 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data,
|
||||
********************************************************************/
|
||||
static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(lp_servicename(snum));
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
lp_servicename(snum),
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
lp_servicename(snum), sizeof(data->notify_data.data.string),True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -936,10 +932,8 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri
|
||||
{
|
||||
/* even if it's strange, that's consistant in all the code */
|
||||
|
||||
data->notify_data.data.length=strlen(lp_servicename(snum));
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
lp_servicename(snum),
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
lp_servicename(snum), sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -949,10 +943,8 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri
|
||||
********************************************************************/
|
||||
static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(printer->info_2->drivername);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->drivername,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->drivername, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -960,10 +952,8 @@ static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p
|
||||
********************************************************************/
|
||||
static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(lp_comment(snum));
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
lp_comment(snum),
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
lp_comment(snum), sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -973,10 +963,8 @@ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print
|
||||
********************************************************************/
|
||||
static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(printer->info_2->location);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->location,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->location, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -994,10 +982,8 @@ static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print
|
||||
********************************************************************/
|
||||
static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(printer->info_2->sepfile);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->sepfile,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->sepfile, sizeof(data->notify_data.data.string)-1,True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1006,10 +992,8 @@ static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print
|
||||
********************************************************************/
|
||||
static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(printer->info_2->printprocessor);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->printprocessor,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->printprocessor, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1018,10 +1002,8 @@ static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *dat
|
||||
********************************************************************/
|
||||
static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(printer->info_2->parameters);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->parameters,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->parameters, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1030,10 +1012,8 @@ static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr
|
||||
********************************************************************/
|
||||
static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(printer->info_2->datatype);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string,
|
||||
printer->info_2->datatype,
|
||||
sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
printer->info_2->datatype, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1133,8 +1113,8 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p
|
||||
********************************************************************/
|
||||
static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(queue->user);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
queue->user, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1150,8 +1130,8 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr
|
||||
********************************************************************/
|
||||
static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
|
||||
{
|
||||
data->notify_data.data.length=strlen(queue->file);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
queue->file, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1174,8 +1154,8 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d
|
||||
p = "PRINTING";
|
||||
break;
|
||||
}
|
||||
data->notify_data.data.length=strlen(p);
|
||||
ascii_to_unistr((char *)data->notify_data.data.string, p, sizeof(data->notify_data.data.string)-1);
|
||||
data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
|
||||
p, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -2598,8 +2578,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe
|
||||
DEBUG(0,("init_unistr_array: Realloc error\n" ));
|
||||
return;
|
||||
}
|
||||
ascii_to_unistr((char *)(*uni_array+j), line , 2*strlen(line));
|
||||
j+=strlen(line)+1;
|
||||
j += (dos_PutUniCode((char *)(*uni_array+j), line , sizeof(uint16)*strlen(line), True) / sizeof(uint16) );
|
||||
i++;
|
||||
if (strlen(v) == 0) break;
|
||||
}
|
||||
@ -4145,13 +4124,12 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
|
||||
* take a pause *before* coding not *during* coding
|
||||
*/
|
||||
|
||||
*out_max_value_len=in_value_len;
|
||||
*out_max_value_len=(in_value_len/sizeof(uint16));
|
||||
if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) {
|
||||
safe_free(data);
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
ascii_to_unistr((char *)*out_value, value, *out_max_value_len);
|
||||
*out_value_len=2*(1+strlen(value));
|
||||
*out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True);
|
||||
|
||||
*out_type=type;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user