diff options
author | Jeremy Allison <jra@samba.org> | 2000-08-31 19:04:51 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-08-31 19:04:51 +0000 |
commit | fa810d4c8001c10bddce452b4ab1178eb80dee87 (patch) | |
tree | 59edc49534184b4b766e65e416630a2a2763f16d | |
parent | 288ea15a564e0931f8002cfb2ca3b4064bb4c227 (diff) | |
download | samba-fa810d4c8001c10bddce452b4ab1178eb80dee87.tar.gz samba-fa810d4c8001c10bddce452b4ab1178eb80dee87.tar.bz2 samba-fa810d4c8001c10bddce452b4ab1178eb80dee87.zip |
Implemented DELETEFORM tested using Gerald's Win32 test code :-).
Jeremy.
(This used to be commit 596c21a2af0309ce43a5e52a343a671036d05ebf)
-rw-r--r-- | source3/include/proto.h | 4 | ||||
-rwxr-xr-x | source3/include/rpc_spoolss.h | 15 | ||||
-rw-r--r-- | source3/printing/nt_printing.c | 51 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 32 | ||||
-rwxr-xr-x | source3/rpc_server/srv_spoolss.c | 28 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 25 |
6 files changed, 152 insertions, 3 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 4fc65f8eda..38393e3de8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1682,6 +1682,7 @@ BOOL nt_printing_init(void); int get_ntforms(nt_forms_struct **list); int write_ntforms(nt_forms_struct **list, int number); BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count); +BOOL delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, uint32 *ret); void update_a_form(nt_forms_struct **list, const FORM *form, int count); int get_ntdrivers(fstring **list, char *architecture, uint32 version); BOOL get_short_archi(char *short_archi, char *long_archi); @@ -2886,6 +2887,8 @@ void free_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u); BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth); BOOL convert_specific_param(NT_PRINTER_PARAM **param, const UNISTR2 *value, uint32 type, const uint8 *data, uint32 len); +BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth); +BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth); BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth); BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth); BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth); @@ -3180,6 +3183,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, uint32 _spoolss_addform( POLICY_HND *handle, uint32 level, const FORM *form); +uint32 _spoolss_deleteform( POLICY_HND *handle, UNISTR2 *form_name); uint32 _spoolss_setform( POLICY_HND *handle, const UNISTR2 *uni_name, uint32 level, diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 7b3ee354ed..a77ce55063 100755 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -35,7 +35,6 @@ #define SPOOLSS_GETPRINTPROCESSORDIRECTORY 0x10 #define SPOOLSS_READPRINTER 0x16 #define SPOOLSS_WAITFORPRINTERCHANGE 0x1c -#define SPOOLSS_DELETEFORM 0x1f #define SPOOLSS_GETFORM 0x20 #define SPOOLSS_ADDPORT 0x25 #define SPOOLSS_CONFIGUREPORT 0x26 @@ -91,6 +90,7 @@ #define SPOOLSS_SETPRINTERDATA 0x1b #define SPOOLSS_CLOSEPRINTER 0x1d #define SPOOLSS_ADDFORM 0x1e +#define SPOOLSS_DELETEFORM 0x1f #define SPOOLSS_SETFORM 0x21 #define SPOOLSS_ENUMFORMS 0x22 #define SPOOLSS_ENUMPORTS 0x23 @@ -1686,6 +1686,19 @@ typedef struct spool_r_setform } SPOOL_R_SETFORM; +typedef struct spool_q_deleteform +{ + POLICY_HND handle; + UNISTR2 name; +} +SPOOL_Q_DELETEFORM; + +typedef struct spool_r_deleteform +{ + uint32 status; +} +SPOOL_R_DELETEFORM; + typedef struct spool_q_getjob { POLICY_HND handle; 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)++; } @@ -185,6 +185,53 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count) } /**************************************************************************** + 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 ****************************************************************************/ void update_a_form(nt_forms_struct **list, const FORM *form, int count) diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 60b6eed0c9..f123198fdb 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -5160,6 +5160,38 @@ static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, /******************************************************************* ********************************************************************/ +BOOL spoolss_io_q_deleteform(char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth) +{ + prs_debug(ps, depth, desc, "spoolss_io_q_deleteform"); + depth++; + + if(!prs_align(ps)) + return False; + if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) + return False; + if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ +BOOL spoolss_io_r_deleteform(char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth) +{ + prs_debug(ps, depth, desc, "spoolss_io_r_deleteform"); + depth++; + + if(!prs_align(ps)) + return False; + if(!prs_uint32("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth) { uint32 useless_ptr=0; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index e6a0f3ae6d..1e5ef1c673 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1057,6 +1057,33 @@ static BOOL api_spoolss_addform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ +static BOOL api_spoolss_deleteform(pipes_struct *p) +{ + SPOOL_Q_DELETEFORM q_u; + SPOOL_R_DELETEFORM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteform("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteform: unable to unmarshall SPOOL_Q_DELETEFORM.\n")); + return False; + } + + r_u.status = _spoolss_deleteform(&q_u.handle, &q_u.name); + + if(!spoolss_io_r_deleteform("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteform: unable to marshall SPOOL_R_DELETEFORM.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ static BOOL api_spoolss_setform(pipes_struct *p) { SPOOL_Q_SETFORM q_u; @@ -1265,6 +1292,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, + {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform }, {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8f58f72d73..0938b37ab3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4615,6 +4615,31 @@ uint32 _spoolss_addform( POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ +uint32 _spoolss_deleteform( POLICY_HND *handle, UNISTR2 *form_name) +{ + int count=0; + uint32 ret = 0; + nt_forms_struct *list=NULL; + Printer_entry *Printer = find_printer_index_by_hnd(handle); + + DEBUG(5,("spoolss_deleteform\n")); + + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_deleteform: Invalid handle (%s).\n", OUR_HANDLE(handle))); + return ERROR_INVALID_HANDLE; + } + + count = get_ntforms(&list); + if(!delete_a_form(&list, form_name, &count, &ret)) + return ERROR_INVALID_PARAMETER; + + safe_free(list); + + return ret; +} + +/**************************************************************************** +****************************************************************************/ uint32 _spoolss_setform( POLICY_HND *handle, const UNISTR2 *uni_name, uint32 level, |