From fa810d4c8001c10bddce452b4ab1178eb80dee87 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 31 Aug 2000 19:04:51 +0000 Subject: Implemented DELETEFORM tested using Gerald's Win32 test code :-). Jeremy. (This used to be commit 596c21a2af0309ce43a5e52a343a671036d05ebf) --- source3/printing/nt_printing.c | 51 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'source3/printing') diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 1dfced705b..05ab71d178 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -155,7 +155,7 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count) update=False; - unistr2_to_ascii(form_name, &(form->name), sizeof(form_name)-1); + unistr2_to_ascii(form_name, &form->name, sizeof(form_name)-1); for (n=0; n<*count && update==False; n++) { if (!strncmp((*list)[n].name, form_name, strlen(form_name))) @@ -169,7 +169,7 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count) { if((*list=Realloc(*list, (n+1)*sizeof(nt_forms_struct))) == NULL) return False; - unistr2_to_ascii((*list)[n].name, &(form->name), sizeof((*list)[n].name)-1); + unistr2_to_ascii((*list)[n].name, &form->name, sizeof((*list)[n].name)-1); (*count)++; } @@ -184,6 +184,53 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count) return True; } +/**************************************************************************** + delete a named form struct +****************************************************************************/ +BOOL delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, uint32 *ret) +{ + pstring key; + TDB_DATA kbuf; + int n=0; + fstring form_name; + + *ret = 0; + + if (*count == 1) { + /* + * Don't delete the last form (no empty lists). + * CHECKME ! Is this correct ? JRA. + */ + *ret = ERROR_INVALID_PARAMETER; + return False; + } + + unistr2_to_ascii(form_name, del_name, sizeof(form_name)-1); + + for (n=0; n<*count; n++) { + if (!strncmp((*list)[n].name, form_name, strlen(form_name))) { + DEBUG(103, ("delete_a_form, [%s] in list\n", form_name)); + break; + } + } + + if (n == *count) { + DEBUG(10,("delete_a_form, [%s] not found\n", form_name)); + *ret = ERROR_INVALID_PARAMETER; + return False; + } + + slprintf(key, sizeof(key), "%s%s", FORMS_PREFIX, (*list)[n].name); + kbuf.dsize = strlen(key)+1; + kbuf.dptr = key; + if (tdb_delete(tdb, kbuf) != 0) { + *ret = ERROR_NOT_ENOUGH_MEMORY; + return False; + } + + return True; +} + /**************************************************************************** update a form struct ****************************************************************************/ -- cgit