mirror of
https://github.com/samba-team/samba.git
synced 2025-06-03 17:05:54 +03:00
Implemented DELETEFORM tested using Gerald's Win32 test code :-).
Jeremy.
This commit is contained in:
parent
155c7c3739
commit
596c21a2af
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
****************************************************************************/
|
||||
|
@ -5158,6 +5158,38 @@ static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps,
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
********************************************************************/
|
||||
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)
|
||||
|
@ -1055,6 +1055,33 @@ static BOOL api_spoolss_addform(pipes_struct *p)
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
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)
|
||||
@ -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 },
|
||||
|
@ -4613,6 +4613,31 @@ uint32 _spoolss_addform( POLICY_HND *handle,
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user