summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-09-05 20:56:09 +0000
committerJeremy Allison <jra@samba.org>2000-09-05 20:56:09 +0000
commitd644d4438cfef54733118cbd09f89518ffb318ca (patch)
treeb1512128d82728bb2ace5708fa7749a8800224c9 /source3
parenta3a28675fafbbc5a5a378b3a7235253d772ef63e (diff)
downloadsamba-d644d4438cfef54733118cbd09f89518ffb318ca.tar.gz
samba-d644d4438cfef54733118cbd09f89518ffb318ca.tar.bz2
samba-d644d4438cfef54733118cbd09f89518ffb318ca.zip
Implemented GETFORM tested and working using Gerald's Win32 test progs....
Jeremy. (This used to be commit 55ed0a9b0c91159c0fc4282c2171d9ced74a302a)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h3
-rwxr-xr-xsource3/include/rpc_spoolss.h19
-rw-r--r--source3/rpc_parse/parse_spoolss.c57
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c38
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c67
5 files changed, 180 insertions, 4 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9d239d38fd..393c417f60 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2834,6 +2834,8 @@ BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth);
BOOL new_spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth);
+BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth);
+BOOL new_spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth);
BOOL new_spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth);
BOOL spool_io_printer_info_level_1(char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth);
@@ -3158,6 +3160,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32
uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level,
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *numofforms);
+uint32 _spoolss_getform( POLICY_HND *handle, uint32 level, UNISTR2 *formname, NEW_BUFFER *buffer, uint32 offered, uint32 *needed);
uint32 _spoolss_enumports( UNISTR2 *name, uint32 level,
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *returned);
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index eb521a5b94..f581c381f9 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_GETFORM 0x20
#define SPOOLSS_ADDPORT 0x25
#define SPOOLSS_CONFIGUREPORT 0x26
#define SPOOLSS_DELETEPORT 0x27
@@ -91,6 +90,7 @@
#define SPOOLSS_CLOSEPRINTER 0x1d
#define SPOOLSS_ADDFORM 0x1e
#define SPOOLSS_DELETEFORM 0x1f
+#define SPOOLSS_GETFORM 0x20
#define SPOOLSS_SETFORM 0x21
#define SPOOLSS_ENUMFORMS 0x22
#define SPOOLSS_ENUMPORTS 0x23
@@ -1214,6 +1214,23 @@ typedef struct spool_r_enumforms
}
SPOOL_R_ENUMFORMS;
+typedef struct spool_q_getform
+{
+ POLICY_HND handle;
+ UNISTR2 formname;
+ uint32 level;
+ NEW_BUFFER *buffer;
+ uint32 offered;
+}
+SPOOL_Q_GETFORM;
+
+typedef struct spool_r_getform
+{
+ NEW_BUFFER *buffer;
+ uint32 needed;
+ uint32 status;
+}
+SPOOL_R_GETFORM;
typedef struct spool_printer_info_level_1
{
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index f123198fdb..3b0ddaac9f 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -3665,10 +3665,65 @@ BOOL new_spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *
return False;
return True;
-
}
/*******************************************************************
+********************************************************************/
+BOOL spoolss_io_q_getform(char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth)
+{
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_getform");
+ 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("", &q_u->formname,True,ps,depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("level", ps, depth, &q_u->level))
+ return False;
+
+ if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("offered", ps, depth, &q_u->offered))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+BOOL new_spoolss_io_r_getform(char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "new_spoolss_io_r_getform");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+/*******************************************************************
Parse a SPOOL_R_ENUMPORTS structure.
********************************************************************/
BOOL new_spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index 1e5ef1c673..fd6cf11746 100755
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -775,6 +775,43 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p)
/****************************************************************************
****************************************************************************/
+static BOOL api_spoolss_getform(pipes_struct *p)
+{
+ SPOOL_Q_GETFORM q_u;
+ SPOOL_R_GETFORM 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(!new_spoolss_allocate_buffer(&q_u.buffer))
+ return False;
+
+ if (!spoolss_io_q_getform("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_getform: unable to unmarshall SPOOL_Q_GETFORM.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
+
+ r_u.status = _spoolss_getform(&q_u.handle, q_u.level,
+ &q_u.formname, r_u.buffer, q_u.offered, &r_u.needed);
+
+ if (!new_spoolss_io_r_getform("",&r_u,rdata,0)) {
+ DEBUG(0,("new_spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
+
+ new_spoolss_free_buffer(q_u.buffer);
+
+ return True;
+}
+
+/****************************************************************************
+****************************************************************************/
static BOOL api_spoolss_enumforms(pipes_struct *p)
{
SPOOL_Q_ENUMFORMS q_u;
@@ -1293,6 +1330,7 @@ struct api_struct api_spoolss_cmds[] =
{"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata },
{"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform },
{"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform },
+ {"SPOOLSS_GETFORM", SPOOLSS_GETFORM, api_spoolss_getform },
{"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 1f19be1188..a31858a3e0 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -3888,7 +3888,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32
/****************************************************************************
****************************************************************************/
-static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position)
+static void fill_form_1(FORM_1 *form, nt_forms_struct *list)
{
form->flag=list->flag;
init_unistr(&form->name, list->name);
@@ -3930,7 +3930,7 @@ uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level,
/* construct the list of form structures */
for (i=0; i<*numofforms; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &list[i], i);
+ fill_form_1(&forms_1[i], &list[i]);
}
safe_free(list);
@@ -3972,6 +3972,69 @@ uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level,
/****************************************************************************
****************************************************************************/
+uint32 _spoolss_getform( POLICY_HND *handle, uint32 level, UNISTR2 *uni_formname, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
+{
+ nt_forms_struct *list=NULL;
+ FORM_1 form_1;
+ fstring form_name;
+ int buffer_size=0;
+ int numofforms, i;
+
+ unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1);
+
+ DEBUG(4,("_spoolss_getform\n"));
+ DEBUGADD(5,("Offered buffer size [%d]\n", offered));
+ DEBUGADD(5,("Info level [%d]\n", level));
+
+ numofforms = get_ntforms(&list);
+ DEBUGADD(5,("Number of forms [%d]\n", numofforms));
+
+ if (numofforms == 0)
+ return ERROR_NO_MORE_ITEMS;
+
+ switch (level) {
+ case 1:
+
+ /* Check if the requested name is in the list of form structures */
+ for (i=0; i<numofforms; i++) {
+
+ DEBUG(4,("_spoolss_getform: checking form %s (want %s)\n", list[i].name, form_name));
+
+ if (strequal(form_name, list[i].name)) {
+ DEBUGADD(6,("Found form %s number [%d]\n", form_name, i));
+ fill_form_1(&form_1, &list[i]);
+ break;
+ }
+ }
+
+ safe_free(list);
+
+ /* check the required size. */
+
+ *needed=spoolss_size_form_1(&form_1);
+
+ if (!alloc_buffer_size(buffer, buffer_size)){
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+
+ if (*needed > offered) {
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+
+ /* fill the buffer with the form structures */
+ DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i));
+ new_smb_io_form_1("", buffer, &form_1, 0);
+
+ return NT_STATUS_NO_PROBLEMO;
+
+ default:
+ safe_free(list);
+ return ERROR_INVALID_LEVEL;
+ }
+}
+
+/****************************************************************************
+****************************************************************************/
static void fill_port_1(PORT_INFO_1 *port, char *name)
{
init_unistr(&port->port_name, name);