str->buffer = NULL;
return;
}
-
- len = strlen(buf) + 1;
- if (len) {
- str->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, len);
- if (str->buffer == NULL)
- smb_panic("init_unistr: malloc fail");
-
- rpcstr_push(str->buffer, buf, len*sizeof(uint16), STR_TERMINATE);
- } else {
+ len = rpcstr_push_talloc(talloc_tos(), &str->buffer, buf);
+ if (len == (size_t)-1) {
str->buffer = NULL;
}
}
Inits a UNISTR2 structure from a UNISTR
********************************************************************/
-void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from)
+void init_unistr2_from_unistr(TALLOC_CTX *ctx, UNISTR2 *to, const UNISTR *from)
{
uint32 i;
/* allocate the space and copy the string buffer */
if (i) {
- to->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, i);
+ to->buffer = TALLOC_ZERO_ARRAY(ctx, uint16, i);
if (to->buffer == NULL)
- smb_panic("init_unistr2_from_unistr: malloc fail");
+ smb_panic("init_unistr2_from_unistr: talloc fail");
memcpy(to->buffer, from->buffer, i*sizeof(uint16));
} else {
to->buffer = NULL;
create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
*******************************************************************/
-bool make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
+bool make_spoolss_printer_info_2(TALLOC_CTX *ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
PRINTER_INFO_2 *info)
{
SPOOL_PRINTER_INFO_LEVEL_2 *inf;
/* allocate the necessary memory */
- if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
+ if (!(inf=TALLOC_P(ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
return False;
}
-
+
inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
inf->untiltime = info->untiltime;
inf->cjobs = info->cjobs;
inf->averageppm = info->averageppm;
- init_unistr2_from_unistr(&inf->servername, &info->servername);
- init_unistr2_from_unistr(&inf->printername, &info->printername);
- init_unistr2_from_unistr(&inf->sharename, &info->sharename);
- init_unistr2_from_unistr(&inf->portname, &info->portname);
- init_unistr2_from_unistr(&inf->drivername, &info->drivername);
- init_unistr2_from_unistr(&inf->comment, &info->comment);
- init_unistr2_from_unistr(&inf->location, &info->location);
- init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
- init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
- init_unistr2_from_unistr(&inf->datatype, &info->datatype);
- init_unistr2_from_unistr(&inf->parameters, &info->parameters);
- init_unistr2_from_unistr(&inf->datatype, &info->datatype);
+ init_unistr2_from_unistr(inf, &inf->servername, &info->servername);
+ init_unistr2_from_unistr(inf, &inf->printername, &info->printername);
+ init_unistr2_from_unistr(inf, &inf->sharename, &info->sharename);
+ init_unistr2_from_unistr(inf, &inf->portname, &info->portname);
+ init_unistr2_from_unistr(inf, &inf->drivername, &info->drivername);
+ init_unistr2_from_unistr(inf, &inf->comment, &info->comment);
+ init_unistr2_from_unistr(inf, &inf->location, &info->location);
+ init_unistr2_from_unistr(inf, &inf->sepfile, &info->sepfile);
+ init_unistr2_from_unistr(inf, &inf->printprocessor, &info->printprocessor);
+ init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
+ init_unistr2_from_unistr(inf, &inf->parameters, &info->parameters);
+ init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
*spool_info2 = inf;
return False;
}
- inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
- inf->action = info->action;
- init_unistr2_from_unistr(&inf->guid, &info->guid);
+ inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
+ inf->action = info->action;
+ init_unistr2_from_unistr(inf, &inf->guid, &info->guid);
*spool_info7 = inf;
return True;
}
-bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
+bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
DRIVER_INFO_3 *info3)
{
if (!(inf=TALLOC_ZERO_P(mem_ctx, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)))
return False;
-
+
inf->cversion = info3->version;
inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
- init_unistr2_from_unistr(&inf->name, &info3->name);
- init_unistr2_from_unistr(&inf->environment, &info3->architecture);
- init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
- init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
- init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
- init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
- init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
- init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
+ init_unistr2_from_unistr(inf, &inf->name, &info3->name);
+ init_unistr2_from_unistr(inf, &inf->environment, &info3->architecture);
+ init_unistr2_from_unistr(inf, &inf->driverpath, &info3->driverpath);
+ init_unistr2_from_unistr(inf, &inf->datafile, &info3->datafile);
+ init_unistr2_from_unistr(inf, &inf->configfile, &info3->configfile);
+ init_unistr2_from_unistr(inf, &inf->helpfile, &info3->helpfile);
+ init_unistr2_from_unistr(inf, &inf->monitorname, &info3->monitorname);
+ init_unistr2_from_unistr(inf, &inf->defaultdatatype, &info3->defaultdatatype);
if (info3->dependentfiles) {
bool done = False;