From a08d4448964641150cad0e6b3fb0055602ef79be Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Aug 2000 20:14:29 +0000 Subject: More work on AddPrinterDriver() and AddPrinterEx() client RPC's Also fixed init_unistr() to deal with a NULL source character string. -jerry (This used to be commit 8ecd5dd52a6bd867f5d117352048ee43ce7254d9) --- source3/rpcclient/cmd_spoolss.c | 84 ++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 44 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 5751c1e227..2844df8dd8 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -778,6 +778,30 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch) return; } +/************************************************************************** + wrapper for strtok to get the next parameter from a delimited list. + Needed to handle the empty parameter string denoted by "NULL" + *************************************************************************/ +static char* get_driver_3_param (char* str, char* delim, UNISTR* dest) +{ + char *ptr; + + /* get the next token */ + ptr = strtok(str, delim); + + /* a string of 'NULL' is used to represent an empty + parameter because two consecutive delimiters + will not return an empty string. See man strtok(3) + for details */ + if (StrCaseCmp(ptr, "NULL") == 0) + ptr = NULL; + + if (dest != NULL) + init_unistr(dest, ptr); + + return ptr; +} + /******************************************************************************** fill in the members of a DRIVER_INFO_3 struct using a character string in the form of @@ -790,52 +814,21 @@ BOOL init_drv_info_3_members (DRIVER_INFO_3 *info, char *args) char *str, *str2; uint32 len, i; - /* */ - if ((str = strtok(args, ":")) == NULL) - return False; - else - init_unistr(&info->name, str); - - /* */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->driverpath, str); - - /* */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->datafile, str); - - /* */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->configfile, str); - - /* */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->helpfile, str); - - /* */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->monitorname, str); - - /* */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->defaultdatatype, str); + /* fill in the UNISTR fields */ + str = get_driver_3_param (args, ":", &info->name); + str = get_driver_3_param (NULL, ":", &info->driverpath); + str = get_driver_3_param (NULL, ":", &info->datafile); + str = get_driver_3_param (NULL, ":", &info->configfile); + str = get_driver_3_param (NULL, ":", &info->helpfile); + str = get_driver_3_param (NULL, ":", &info->monitorname); + str = get_driver_3_param (NULL, ":", &info->defaultdatatype); /* */ - str = strtok(NULL, ":"); /* get the list of dependent files */ - str2 = str; /* save the beginning of the string */ - str = strtok(str, ","); /* begin to strip out each filename */ + str2 = get_driver_3_param (NULL, ":", NULL); /* save the beginning of the string */ + str = str2; + + /* begin to strip out each filename */ + str = strtok(str, ","); len = 0; while (str != NULL) { @@ -874,3 +867,6 @@ void free_drv_info_3 (DRIVER_INFO_3 *info) return; } + + + -- cgit