summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h783
-rwxr-xr-xsource3/include/rpc_spoolss.h98
-rw-r--r--source3/printing/nt_printing.c140
-rw-r--r--source3/rpc_parse/parse_prs.c19
-rw-r--r--source3/rpc_parse/parse_spoolss.c1665
-rw-r--r--source3/rpc_server/srv_pipe_srv.c2
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c526
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c1207
8 files changed, 2485 insertions, 1955 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d654af1fa4..7dc0d3e9e6 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -186,10 +186,208 @@ void CatchChildLeaveStatus(void);
int vslprintf(char *str, int n, char *format, va_list ap);
+/*The following definitions come from libsmb/clientgen.c */
+
+int cli_set_port(struct cli_state *cli, int port);
+char *cli_errstr(struct cli_state *cli);
+BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
+ uint16 *setup, uint32 setup_count, uint32 max_setup_count,
+ char *params, uint32 param_count, uint32 max_param_count,
+ char *data, uint32 data_count, uint32 max_data_count,
+ char **rparam, uint32 *rparam_count,
+ char **rdata, uint32 *rdata_count);
+BOOL cli_api(struct cli_state *cli,
+ char *param, int prcnt, int mprcnt,
+ char *data, int drcnt, int mdrcnt,
+ char **rparam, int *rprcnt,
+ char **rdata, int *rdrcnt);
+BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
+BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *));
+BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
+ void (*fn)(const char *, uint32, const char *));
+BOOL cli_session_setup(struct cli_state *cli,
+ char *user,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen,
+ char *workgroup);
+BOOL cli_ulogoff(struct cli_state *cli);
+BOOL cli_send_tconX(struct cli_state *cli,
+ char *share, char *dev, char *pass, int passlen);
+BOOL cli_tdis(struct cli_state *cli);
+BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
+BOOL cli_unlink(struct cli_state *cli, char *fname);
+BOOL cli_mkdir(struct cli_state *cli, char *dname);
+BOOL cli_rmdir(struct cli_state *cli, char *dname);
+int cli_nt_create(struct cli_state *cli, char *fname);
+int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode);
+BOOL cli_close(struct cli_state *cli, int fnum);
+BOOL cli_lock(struct cli_state *cli, int fnum,
+ uint32 offset, uint32 len, int timeout, enum brl_type lock_type);
+BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len);
+size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
+ssize_t cli_write(struct cli_state *cli,
+ int fnum, uint16 write_mode,
+ char *buf, off_t offset, size_t size);
+ssize_t cli_smbwrite(struct cli_state *cli,
+ int fnum, char *buf, off_t offset, size_t size1);
+BOOL cli_getattrE(struct cli_state *cli, int fd,
+ uint16 *attr, size_t *size,
+ time_t *c_time, time_t *a_time, time_t *m_time);
+BOOL cli_getatr(struct cli_state *cli, char *fname,
+ uint16 *attr, size_t *size, time_t *t);
+BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t);
+BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ size_t *size, uint16 *mode);
+BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ time_t *w_time, size_t *size, uint16 *mode,
+ SMB_INO_T *ino);
+BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
+ uint16 *mode, size_t *size,
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ time_t *w_time, SMB_INO_T *ino);
+int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+ void (*fn)(file_info *, const char *));
+BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
+ const char *old_password);
+BOOL cli_negprot(struct cli_state *cli);
+BOOL cli_session_request(struct cli_state *cli,
+ struct nmb_name *calling, struct nmb_name *called);
+BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
+struct cli_state *cli_initialise(struct cli_state *cli);
+void cli_shutdown(struct cli_state *cli);
+int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error);
+void cli_sockopt(struct cli_state *cli, char *options);
+uint16 cli_setpid(struct cli_state *cli, uint16 pid);
+BOOL cli_reestablish_connection(struct cli_state *cli);
+BOOL cli_establish_connection(struct cli_state *cli,
+ char *dest_host, struct in_addr *dest_ip,
+ struct nmb_name *calling, struct nmb_name *called,
+ char *service, char *service_type,
+ BOOL do_shutdown, BOOL do_tcon);
+int cli_printjob_del(struct cli_state *cli, int job);
+int cli_print_queue(struct cli_state *cli,
+ void (*fn)(struct print_job_info *));
+BOOL cli_chkpath(struct cli_state *cli, char *path);
+BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
+ int *grp);
+BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp);
+BOOL cli_message_end(struct cli_state *cli, int grp);
+BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
+ struct in_addr *pdest_ip);
+
+/*The following definitions come from libsmb/credentials.c */
+
+char *credstr(uchar *cred);
+void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass,
+ uchar session_key[8]);
+void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp,
+ DOM_CHAL *cred);
+int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred,
+ UTIME timestamp);
+BOOL clnt_deal_with_creds(uchar sess_key[8],
+ DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred);
+BOOL deal_with_creds(uchar sess_key[8],
+ DOM_CRED *sto_clnt_cred,
+ DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred);
+
+/*The following definitions come from libsmb/namequery.c */
+
+BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
+ struct in_addr to_ip,char *master,char *rname);
+struct in_addr *name_query(int fd,const char *name,int name_type,
+ BOOL bcast,BOOL recurse,
+ struct in_addr to_ip, int *count);
+FILE *startlmhosts(char *fname);
+BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
+void endlmhosts(FILE *fp);
+BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
+BOOL find_master_ip(char *group, struct in_addr *master_ip);
+BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name);
+BOOL get_dc_list(char *group, struct in_addr **ip_list, int *count);
+
+/*The following definitions come from libsmb/nmblib.c */
+
+void debug_nmb_packet(struct packet_struct *p);
+char *nmb_namestr(struct nmb_name *n);
+struct packet_struct *copy_packet(struct packet_struct *packet);
+void free_packet(struct packet_struct *packet);
+struct packet_struct *parse_packet(char *buf,int length,
+ enum packet_type packet_type);
+struct packet_struct *read_packet(int fd,enum packet_type packet_type);
+void make_nmb_name( struct nmb_name *n, const char *name, int type);
+BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
+int build_packet(char *buf, struct packet_struct *p);
+BOOL send_packet(struct packet_struct *p);
+struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
+struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id);
+struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name);
+BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name);
+void sort_query_replies(char *data, int n, struct in_addr ip);
+
+/*The following definitions come from libsmb/nterr.c */
+
+char *get_nt_error_msg(uint32 nt_code);
+
+/*The following definitions come from libsmb/passchange.c */
+
+BOOL remote_password_change(const char *remote_machine, const char *user_name,
+ const char *old_passwd, const char *new_passwd,
+ char *err_str, size_t err_str_len);
+
+/*The following definitions come from libsmb/pwd_cache.c */
+
+void pwd_init(struct pwd_info *pwd);
+void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key);
+BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2);
+void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt);
+void pwd_set_nullpwd(struct pwd_info *pwd);
+void pwd_set_cleartext(struct pwd_info *pwd, char *clr);
+void pwd_get_cleartext(struct pwd_info *pwd, char *clr);
+void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
+void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
+void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr);
+void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]);
+void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]);
+
/*The following definitions come from lib/smbrun.c */
int smbrun(char *cmd,char *outfile,BOOL shared);
+/*The following definitions come from libsmb/smbdes.c */
+
+void E_P16(unsigned char *p14,unsigned char *p16);
+void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
+void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
+void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out);
+void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key);
+void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key);
+void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
+void SamOEMhash( unsigned char *data, unsigned char *key, int val);
+
+/*The following definitions come from libsmb/smbencrypt.c */
+
+void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
+void E_md4hash(uchar *passwd, uchar *p16);
+void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]);
+void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
+void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
+void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
+BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode);
+
+/*The following definitions come from libsmb/smberr.c */
+
+char *smb_errstr(char *inbuf);
+
+/*The following definitions come from libsmb/unexpected.c */
+
+void unexpected_packet(struct packet_struct *p);
+void clear_unexpected(time_t t);
+struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
+ char *mailslot_name);
+
/*The following definitions come from lib/snprintf.c */
@@ -271,6 +469,23 @@ BOOL map_username(char *user);
struct passwd *Get_Pwnam(char *user,BOOL allow_change);
BOOL user_in_list(char *user,char *list);
+/*The following definitions come from lib/util_array.c */
+
+void free_void_array(uint32 num_entries, void **entries,
+ void(free_item)(void*));
+void* add_copy_to_array(uint32 *len, void ***array, const void *item,
+ void*(item_dup)(const void*), BOOL alloc_anyway);
+void* add_item_to_array(uint32 *len, void ***array, void *item);
+void free_use_info_array(uint32 num_entries, struct use_info **entries);
+struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array,
+ const struct use_info *name);
+void free_char_array(uint32 num_entries, char **entries);
+char* add_chars_to_array(uint32 *len, char ***array, const char *name);
+void free_uint32_array(uint32 num_entries, uint32 **entries);
+uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name);
+void free_sid_array(uint32 num_entries, DOM_SID **entries);
+DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid);
+
/*The following definitions come from lib/util.c */
char *tmpdir(void);
@@ -348,23 +563,6 @@ char *myhostname(void);
char *lock_path(char *name);
char *parent_dirname(const char *path);
-/*The following definitions come from lib/util_array.c */
-
-void free_void_array(uint32 num_entries, void **entries,
- void(free_item)(void*));
-void* add_copy_to_array(uint32 *len, void ***array, const void *item,
- void*(item_dup)(const void*), BOOL alloc_anyway);
-void* add_item_to_array(uint32 *len, void ***array, void *item);
-void free_use_info_array(uint32 num_entries, struct use_info **entries);
-struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array,
- const struct use_info *name);
-void free_char_array(uint32 num_entries, char **entries);
-char* add_chars_to_array(uint32 *len, char ***array, const char *name);
-void free_uint32_array(uint32 num_entries, uint32 **entries);
-uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name);
-void free_sid_array(uint32 num_entries, DOM_SID **entries);
-DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid);
-
/*The following definitions come from lib/util_file.c */
BOOL do_file_lock(int fd, int waitsecs, int type);
@@ -554,204 +752,6 @@ void split_at_last_component_w(smb_ucs2_t *path, smb_ucs2_t *front, smb_ucs2_t s
smb_ucs2_t *octal_string_w(int i);
smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length);
-/*The following definitions come from libsmb/clientgen.c */
-
-int cli_set_port(struct cli_state *cli, int port);
-char *cli_errstr(struct cli_state *cli);
-BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
- uint16 *setup, uint32 setup_count, uint32 max_setup_count,
- char *params, uint32 param_count, uint32 max_param_count,
- char *data, uint32 data_count, uint32 max_data_count,
- char **rparam, uint32 *rparam_count,
- char **rdata, uint32 *rdata_count);
-BOOL cli_api(struct cli_state *cli,
- char *param, int prcnt, int mprcnt,
- char *data, int drcnt, int mdrcnt,
- char **rparam, int *rprcnt,
- char **rdata, int *rdrcnt);
-BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
-BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *));
-BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
- void (*fn)(const char *, uint32, const char *));
-BOOL cli_session_setup(struct cli_state *cli,
- char *user,
- char *pass, int passlen,
- char *ntpass, int ntpasslen,
- char *workgroup);
-BOOL cli_ulogoff(struct cli_state *cli);
-BOOL cli_send_tconX(struct cli_state *cli,
- char *share, char *dev, char *pass, int passlen);
-BOOL cli_tdis(struct cli_state *cli);
-BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
-BOOL cli_unlink(struct cli_state *cli, char *fname);
-BOOL cli_mkdir(struct cli_state *cli, char *dname);
-BOOL cli_rmdir(struct cli_state *cli, char *dname);
-int cli_nt_create(struct cli_state *cli, char *fname);
-int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode);
-BOOL cli_close(struct cli_state *cli, int fnum);
-BOOL cli_lock(struct cli_state *cli, int fnum,
- uint32 offset, uint32 len, int timeout, enum brl_type lock_type);
-BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len);
-size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
-ssize_t cli_write(struct cli_state *cli,
- int fnum, uint16 write_mode,
- char *buf, off_t offset, size_t size);
-ssize_t cli_smbwrite(struct cli_state *cli,
- int fnum, char *buf, off_t offset, size_t size1);
-BOOL cli_getattrE(struct cli_state *cli, int fd,
- uint16 *attr, size_t *size,
- time_t *c_time, time_t *a_time, time_t *m_time);
-BOOL cli_getatr(struct cli_state *cli, char *fname,
- uint16 *attr, size_t *size, time_t *t);
-BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t);
-BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
- time_t *c_time, time_t *a_time, time_t *m_time,
- size_t *size, uint16 *mode);
-BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
- time_t *c_time, time_t *a_time, time_t *m_time,
- time_t *w_time, size_t *size, uint16 *mode,
- SMB_INO_T *ino);
-BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
- uint16 *mode, size_t *size,
- time_t *c_time, time_t *a_time, time_t *m_time,
- time_t *w_time, SMB_INO_T *ino);
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
- void (*fn)(file_info *, const char *));
-BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
- const char *old_password);
-BOOL cli_negprot(struct cli_state *cli);
-BOOL cli_session_request(struct cli_state *cli,
- struct nmb_name *calling, struct nmb_name *called);
-BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
-struct cli_state *cli_initialise(struct cli_state *cli);
-void cli_shutdown(struct cli_state *cli);
-int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error);
-void cli_sockopt(struct cli_state *cli, char *options);
-uint16 cli_setpid(struct cli_state *cli, uint16 pid);
-BOOL cli_reestablish_connection(struct cli_state *cli);
-BOOL cli_establish_connection(struct cli_state *cli,
- char *dest_host, struct in_addr *dest_ip,
- struct nmb_name *calling, struct nmb_name *called,
- char *service, char *service_type,
- BOOL do_shutdown, BOOL do_tcon);
-int cli_printjob_del(struct cli_state *cli, int job);
-int cli_print_queue(struct cli_state *cli,
- void (*fn)(struct print_job_info *));
-BOOL cli_chkpath(struct cli_state *cli, char *path);
-BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
- int *grp);
-BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp);
-BOOL cli_message_end(struct cli_state *cli, int grp);
-BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
-BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
- struct in_addr *pdest_ip);
-
-/*The following definitions come from libsmb/credentials.c */
-
-char *credstr(uchar *cred);
-void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass,
- uchar session_key[8]);
-void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp,
- DOM_CHAL *cred);
-int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred,
- UTIME timestamp);
-BOOL clnt_deal_with_creds(uchar sess_key[8],
- DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred);
-BOOL deal_with_creds(uchar sess_key[8],
- DOM_CRED *sto_clnt_cred,
- DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred);
-
-/*The following definitions come from libsmb/namequery.c */
-
-BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
- struct in_addr to_ip,char *master,char *rname);
-struct in_addr *name_query(int fd,const char *name,int name_type,
- BOOL bcast,BOOL recurse,
- struct in_addr to_ip, int *count);
-FILE *startlmhosts(char *fname);
-BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
-void endlmhosts(FILE *fp);
-BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
-BOOL find_master_ip(char *group, struct in_addr *master_ip);
-BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name);
-BOOL get_dc_list(char *group, struct in_addr **ip_list, int *count);
-
-/*The following definitions come from libsmb/nmblib.c */
-
-void debug_nmb_packet(struct packet_struct *p);
-char *nmb_namestr(struct nmb_name *n);
-struct packet_struct *copy_packet(struct packet_struct *packet);
-void free_packet(struct packet_struct *packet);
-struct packet_struct *parse_packet(char *buf,int length,
- enum packet_type packet_type);
-struct packet_struct *read_packet(int fd,enum packet_type packet_type);
-void make_nmb_name( struct nmb_name *n, const char *name, int type);
-BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
-int build_packet(char *buf, struct packet_struct *p);
-BOOL send_packet(struct packet_struct *p);
-struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
-struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id);
-struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name);
-BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name);
-void sort_query_replies(char *data, int n, struct in_addr ip);
-
-/*The following definitions come from libsmb/nterr.c */
-
-char *get_nt_error_msg(uint32 nt_code);
-
-/*The following definitions come from libsmb/passchange.c */
-
-BOOL remote_password_change(const char *remote_machine, const char *user_name,
- const char *old_passwd, const char *new_passwd,
- char *err_str, size_t err_str_len);
-
-/*The following definitions come from libsmb/pwd_cache.c */
-
-void pwd_init(struct pwd_info *pwd);
-void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key);
-BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2);
-void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt);
-void pwd_set_nullpwd(struct pwd_info *pwd);
-void pwd_set_cleartext(struct pwd_info *pwd, char *clr);
-void pwd_get_cleartext(struct pwd_info *pwd, char *clr);
-void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
-void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]);
-void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr);
-void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]);
-void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]);
-
-/*The following definitions come from libsmb/smbdes.c */
-
-void E_P16(unsigned char *p14,unsigned char *p16);
-void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
-void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
-void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out);
-void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key);
-void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key);
-void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
-void SamOEMhash( unsigned char *data, unsigned char *key, int val);
-
-/*The following definitions come from libsmb/smbencrypt.c */
-
-void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
-void E_md4hash(uchar *passwd, uchar *p16);
-void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]);
-void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
-void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
-void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
-BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode);
-
-/*The following definitions come from libsmb/smberr.c */
-
-char *smb_errstr(char *inbuf);
-
-/*The following definitions come from libsmb/unexpected.c */
-
-void unexpected_packet(struct packet_struct *p);
-void clear_unexpected(time_t t);
-struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
- char *mailslot_name);
-
/*The following definitions come from locking/brlock.c */
void brl_init(int read_only);
@@ -809,10 +809,6 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question,
struct name_record **n);
void kill_async_dns_child(void);
-/*The following definitions come from nmbd/nmbd.c */
-
-BOOL reload_services(BOOL test);
-
/*The following definitions come from nmbd/nmbd_become_dmb.c */
void add_domain_names(time_t t);
@@ -843,6 +839,10 @@ void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
void collect_all_workgroup_names_from_wins_server(time_t t);
void sync_all_dmbs(time_t t);
+/*The following definitions come from nmbd/nmbd.c */
+
+BOOL reload_services(BOOL test);
+
/*The following definitions come from nmbd/nmbd_elections.c */
void check_master_browser_exists(time_t t);
@@ -1515,11 +1515,6 @@ void pcap_printer_fn(void (*fn)(char *, char *));
void cups_printer_fn(void (*fn)(char *, char *));
int cups_printername_ok(char *name);
-/*The following definitions come from printing/print_svid.c */
-
-void sysv_printer_fn(void (*fn)(char *, char *));
-int sysv_printername_ok(char *name);
-
/*The following definitions come from printing/printing.c */
void lpq_reset(int snum);
@@ -1534,6 +1529,11 @@ void printjob_decode(int jobid, int *snum, int *job);
void status_printqueue(connection_struct *conn,int snum,int status);
void load_printers(void);
+/*The following definitions come from printing/print_svid.c */
+
+void sysv_printer_fn(void (*fn)(char *, char *));
+int sysv_printername_ok(char *name);
+
/*The following definitions come from profile/profile.c */
BOOL profile_setup(BOOL rdonly);
@@ -1699,6 +1699,109 @@ BOOL do_wks_query_info(struct cli_state *cli,
char *server_name, uint32 switch_value,
WKS_INFO_100 *wks100);
+/*The following definitions come from rpcclient/cmd_lsarpc.c */
+
+void cmd_lsa_query_info(struct client_info *info);
+void cmd_lsa_lookup_sids(struct client_info *info);
+
+/*The following definitions come from rpcclient/cmd_netlogon.c */
+
+void cmd_netlogon_login_test(struct client_info *info);
+
+/*The following definitions come from rpcclient/cmd_reg.c */
+
+void cmd_reg_enum(struct client_info *info);
+void cmd_reg_query_key(struct client_info *info);
+void cmd_reg_create_val(struct client_info *info);
+void cmd_reg_delete_val(struct client_info *info);
+void cmd_reg_delete_key(struct client_info *info);
+void cmd_reg_create_key(struct client_info *info);
+void cmd_reg_test_key_sec(struct client_info *info);
+void cmd_reg_get_key_sec(struct client_info *info);
+
+/*The following definitions come from rpcclient/cmd_samr.c */
+
+void cmd_sam_ntchange_pwd(struct client_info *info);
+void cmd_sam_test(struct client_info *info);
+void cmd_sam_enum_users(struct client_info *info);
+void cmd_sam_query_user(struct client_info *info);
+void cmd_sam_query_groups(struct client_info *info);
+void cmd_sam_enum_aliases(struct client_info *info);
+
+/*The following definitions come from rpcclient/cmd_srvsvc.c */
+
+void cmd_srv_query_info(struct client_info *info);
+void cmd_srv_enum_conn(struct client_info *info);
+void cmd_srv_enum_shares(struct client_info *info);
+void cmd_srv_enum_sess(struct client_info *info);
+void cmd_srv_enum_files(struct client_info *info);
+
+/*The following definitions come from rpcclient/cmd_wkssvc.c */
+
+void cmd_wks_query_info(struct client_info *info);
+
+/*The following definitions come from rpcclient/display.c */
+
+char *get_file_mode_str(uint32 share_mode);
+char *get_file_oplock_str(uint32 op_type);
+char *get_share_type_str(uint32 type);
+char *get_server_type_str(uint32 type);
+void display_srv_info_101(FILE *out_hnd, enum action_type action,
+ SRV_INFO_101 *sv101);
+void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *sv102);
+void display_srv_info_ctr(FILE *out_hnd, enum action_type action,SRV_INFO_CTR *ctr);
+void display_conn_info_0(FILE *out_hnd, enum action_type action,
+ CONN_INFO_0 *info0);
+void display_conn_info_1(FILE *out_hnd, enum action_type action,
+ CONN_INFO_1 *info1, CONN_INFO_1_STR *str1);
+void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_0 *ctr);
+void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_1 *ctr);
+void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_CTR *ctr);
+void display_share_info_1(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_1 *info1);
+void display_share_info_2(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_2 *info2);
+void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_CTR *ctr);
+void display_file_info_3(FILE *out_hnd, enum action_type action,
+ FILE_INFO_3 *info3, FILE_INFO_3_STR *str3);
+void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
+ SRV_FILE_INFO_3 *ctr);
+void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_FILE_INFO_CTR *ctr);
+void display_server(FILE *out_hnd, enum action_type action,
+ char *sname, uint32 type, char *comment);
+void display_share(FILE *out_hnd, enum action_type action,
+ char *sname, uint32 type, char *comment);
+void display_share2(FILE *out_hnd, enum action_type action,
+ char *sname, uint32 type, char *comment,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ char *path, char *passwd);
+void display_name(FILE *out_hnd, enum action_type action,
+ char *sname);
+void display_group_rid_info(FILE *out_hnd, enum action_type action,
+ uint32 num_gids, DOM_GID *gid);
+void display_alias_name_info(FILE *out_hnd, enum action_type action,
+ uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs);
+void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *usr);
+char *get_sec_mask_str(uint32 type);
+void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *info);
+void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *ace);
+void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *sec_acl);
+void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec);
+char *get_reg_val_type_str(uint32 type);
+void display_reg_value_info(FILE *out_hnd, enum action_type action,
+ char *val_name, uint32 val_type, BUFFER2 *value);
+void display_reg_key_info(FILE *out_hnd, enum action_type action,
+ char *key_name, time_t key_mod_time);
+
+/*The following definitions come from rpcclient/rpcclient.c */
+
+void rpcclient_init(void);
+
/*The following definitions come from rpc_parse/parse_creds.c */
BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name,
@@ -1940,7 +2043,7 @@ uint32 prs_data_size(prs_struct *ps);
uint32 prs_offset(prs_struct *ps);
BOOL prs_set_offset(prs_struct *ps, uint32 offset);
BOOL prs_append_prs_data(prs_struct *dst, prs_struct *src);
-BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, uint32 len);
+BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
BOOL prs_append_data(prs_struct *dst, char *src, uint32 len);
void prs_set_bigendian_data(prs_struct *ps);
BOOL prs_align(prs_struct *ps);
@@ -2332,12 +2435,36 @@ BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u,
BOOL spoolss_io_r_rfnpcnex(char *desc,
SPOOL_R_RFNPCNEX *r_u,
prs_struct *ps, int depth);
+BOOL new_smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth);
+BOOL new_smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth);
+BOOL new_smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth) ;
+BOOL new_smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth) ;
+BOOL new_smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth);
+BOOL new_smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth);
+BOOL new_smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth);
BOOL new_smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth);
void new_spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest);
void new_spoolss_allocate_buffer(NEW_BUFFER **buffer);
void new_spoolss_free_buffer(NEW_BUFFER *buffer);
uint32 new_get_buffer_size(NEW_BUFFER *buffer);
+BOOL new_smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth);
+BOOL new_smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth);
+BOOL smb_io_printprocessor_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth);
+BOOL smb_io_printmonitor_info_1(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth);
+BOOL smb_io_printmonitor_info_2(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth);
+uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info);
+uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info);
+uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info);
+uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info);
+uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info);
+uint32 spoolss_size_job_info_1(JOB_INFO_1 *info);
+uint32 spoolss_size_job_info_2(JOB_INFO_2 *info);
uint32 spoolss_size_form_1(FORM_1 *info);
+uint32 spoolss_size_port_info_1(PORT_INFO_1 *info);
+uint32 spoolss_size_port_info_2(PORT_INFO_2 *info);
+uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info);
+uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info);
+uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info);
BOOL spoolss_io_free_buffer(BUFFER *buffer);
BOOL spoolss_io_q_getprinterdriver2(char *desc,
SPOOL_Q_GETPRINTERDRIVER2 *q_u,
@@ -2351,10 +2478,7 @@ BOOL make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u,
uint32 size);
BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u,
prs_struct *ps, int depth);
-void free_r_enumprinters(SPOOL_R_ENUMPRINTERS *r_u);
-BOOL spoolss_io_r_enumprinters(char *desc,
- SPOOL_R_ENUMPRINTERS *r_u,
- prs_struct *ps, int depth);
+BOOL new_spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_getprinter(char *desc,
SPOOL_R_GETPRINTER *r_u,
prs_struct *ps, int depth);
@@ -2370,8 +2494,6 @@ BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth)
BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth);
-void free_job_info_ctr(JOB_INFO_CTR *ctr, uint32 level, uint32 numofjobs);
-void free_r_enumjobs(SPOOL_R_ENUMJOBS *r_u);
BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth);
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
uint32 firstjob,
@@ -2383,13 +2505,11 @@ BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *
BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth);
-BOOL spoolss_io_r_enumdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth);
-void free_spoolss_r_enumdrivers(SPOOL_R_ENUMPRINTERDRIVERS *r_u);
+BOOL new_spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth);
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_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth);
-void spoolss_free_r_enumports(SPOOL_R_ENUMPORTS *r_u);
+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_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 **q_u, prs_struct *ps, int depth);
BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth);
@@ -2410,8 +2530,8 @@ BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r
BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth);
-BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth);
+BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth);
@@ -2615,16 +2735,9 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle,
const SPOOL_NOTIFY_OPTION *option,
uint32 *count,
SPOOL_NOTIFY_INFO *info);
-uint32 _spoolss_enumprinters(
- uint32 flags,
- const UNISTR2 *servername,
- uint32 level,
- const BUFFER *buffer,
- uint32 buf_size,
- uint32 *offered,
- uint32 *needed,
- PRINTER_INFO_CTR *ctr,
- uint32 *returned);
+uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned);
uint32 _spoolss_getprinter( POLICY_HND *handle,
uint32 level,
PRINTER_INFO *ctr,
@@ -2656,38 +2769,24 @@ uint32 _spoolss_fcpn( const POLICY_HND *handle);
uint32 _spoolss_addjob( const POLICY_HND *handle, uint32 level,
const BUFFER *buffer,
uint32 buf_size);
-uint32 _spoolss_enumjobs( const POLICY_HND *handle,
- uint32 reqfirstjob,
- uint32 reqnumofjobs,
- uint32 level,
- JOB_INFO_CTR *ctr,
- uint32 *buf_size,
- uint32 *numofjobs);
+uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned);
uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid);
uint32 _spoolss_setjob( const POLICY_HND *handle,
uint32 jobid,
uint32 level,
JOB_INFO *ctr,
uint32 command);
-uint32 _spoolss_enumprinterdrivers( const UNISTR2 *name,
- const UNISTR2 *environment,
- uint32 level,
- DRIVER_INFO *ctr,
- uint32 *offered,
- uint32 *numofdrivers);
+uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned);
uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *numofforms);
-uint32 _spoolss_enumforms( const POLICY_HND *handle,
- uint32 level,
- FORM_1 **forms_1,
- uint32 *offered,
- uint32 *numofforms);
-uint32 _spoolss_enumports( const UNISTR2 *name,
- uint32 level,
- PORT_INFO_CTR *ctr,
- uint32 *offered,
- uint32 *numofports);
+uint32 _spoolss_enumports( UNISTR2 *name, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned);
uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name,
uint32 level,
const SPOOL_PRINTER_INFO_LEVEL *info,
@@ -2729,17 +2828,12 @@ uint32 _spoolss_setform( const POLICY_HND *handle,
const UNISTR2 *uni_name,
uint32 level,
const FORM *form);
-uint32 _spoolss_enumprintprocessors(const UNISTR2 *name,
- const UNISTR2 *environment,
- uint32 level,
- PRINTPROCESSOR_1 **info_1,
- uint32 *offered,
- uint32 *numofprintprocessors);
-uint32 _spoolss_enumprintmonitors( const UNISTR2 *name,
- uint32 level,
- PRINTMONITOR_1 **info_1,
- uint32 *offered,
- uint32 *numofprintmonitors);
+uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned);
+uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned);
uint32 _spoolss_getjob( const POLICY_HND *handle,
uint32 jobid,
uint32 level,
@@ -2765,109 +2859,6 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid);
BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data);
-/*The following definitions come from rpcclient/cmd_lsarpc.c */
-
-void cmd_lsa_query_info(struct client_info *info);
-void cmd_lsa_lookup_sids(struct client_info *info);
-
-/*The following definitions come from rpcclient/cmd_netlogon.c */
-
-void cmd_netlogon_login_test(struct client_info *info);
-
-/*The following definitions come from rpcclient/cmd_reg.c */
-
-void cmd_reg_enum(struct client_info *info);
-void cmd_reg_query_key(struct client_info *info);
-void cmd_reg_create_val(struct client_info *info);
-void cmd_reg_delete_val(struct client_info *info);
-void cmd_reg_delete_key(struct client_info *info);
-void cmd_reg_create_key(struct client_info *info);
-void cmd_reg_test_key_sec(struct client_info *info);
-void cmd_reg_get_key_sec(struct client_info *info);
-
-/*The following definitions come from rpcclient/cmd_samr.c */
-
-void cmd_sam_ntchange_pwd(struct client_info *info);
-void cmd_sam_test(struct client_info *info);
-void cmd_sam_enum_users(struct client_info *info);
-void cmd_sam_query_user(struct client_info *info);
-void cmd_sam_query_groups(struct client_info *info);
-void cmd_sam_enum_aliases(struct client_info *info);
-
-/*The following definitions come from rpcclient/cmd_srvsvc.c */
-
-void cmd_srv_query_info(struct client_info *info);
-void cmd_srv_enum_conn(struct client_info *info);
-void cmd_srv_enum_shares(struct client_info *info);
-void cmd_srv_enum_sess(struct client_info *info);
-void cmd_srv_enum_files(struct client_info *info);
-
-/*The following definitions come from rpcclient/cmd_wkssvc.c */
-
-void cmd_wks_query_info(struct client_info *info);
-
-/*The following definitions come from rpcclient/display.c */
-
-char *get_file_mode_str(uint32 share_mode);
-char *get_file_oplock_str(uint32 op_type);
-char *get_share_type_str(uint32 type);
-char *get_server_type_str(uint32 type);
-void display_srv_info_101(FILE *out_hnd, enum action_type action,
- SRV_INFO_101 *sv101);
-void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *sv102);
-void display_srv_info_ctr(FILE *out_hnd, enum action_type action,SRV_INFO_CTR *ctr);
-void display_conn_info_0(FILE *out_hnd, enum action_type action,
- CONN_INFO_0 *info0);
-void display_conn_info_1(FILE *out_hnd, enum action_type action,
- CONN_INFO_1 *info1, CONN_INFO_1_STR *str1);
-void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
- SRV_CONN_INFO_0 *ctr);
-void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
- SRV_CONN_INFO_1 *ctr);
-void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_CONN_INFO_CTR *ctr);
-void display_share_info_1(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_1 *info1);
-void display_share_info_2(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_2 *info2);
-void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_CTR *ctr);
-void display_file_info_3(FILE *out_hnd, enum action_type action,
- FILE_INFO_3 *info3, FILE_INFO_3_STR *str3);
-void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
- SRV_FILE_INFO_3 *ctr);
-void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_FILE_INFO_CTR *ctr);
-void display_server(FILE *out_hnd, enum action_type action,
- char *sname, uint32 type, char *comment);
-void display_share(FILE *out_hnd, enum action_type action,
- char *sname, uint32 type, char *comment);
-void display_share2(FILE *out_hnd, enum action_type action,
- char *sname, uint32 type, char *comment,
- uint32 perms, uint32 max_uses, uint32 num_uses,
- char *path, char *passwd);
-void display_name(FILE *out_hnd, enum action_type action,
- char *sname);
-void display_group_rid_info(FILE *out_hnd, enum action_type action,
- uint32 num_gids, DOM_GID *gid);
-void display_alias_name_info(FILE *out_hnd, enum action_type action,
- uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs);
-void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *usr);
-char *get_sec_mask_str(uint32 type);
-void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *info);
-void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *ace);
-void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *sec_acl);
-void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec);
-char *get_reg_val_type_str(uint32 type);
-void display_reg_value_info(FILE *out_hnd, enum action_type action,
- char *val_name, uint32 val_type, BUFFER2 *value);
-void display_reg_key_info(FILE *out_hnd, enum action_type action,
- char *key_name, time_t key_mod_time);
-
-/*The following definitions come from rpcclient/rpcclient.c */
-
-void rpcclient_init(void);
-
/*The following definitions come from smbd/blocking.c */
BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout, int lock_num);
@@ -3253,6 +3244,19 @@ BOOL unbecome_authenticated_pipe_user(pipes_struct *p);
void become_root(BOOL save_dir) ;
void unbecome_root(BOOL restore_dir);
+/*The following definitions come from smbd/vfs.c */
+
+int vfs_init_default(connection_struct *conn);
+BOOL vfs_init_custom(connection_struct *conn);
+BOOL vfs_directory_exist(connection_struct *conn, char *dname,
+ SMB_STRUCT_STAT *st);
+BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf);
+ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N);
+SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp,
+ int out_fd, files_struct *out_fsp,
+ SMB_OFF_T n, char *header, int headlen, int align);
+char *vfs_readdirname(connection_struct *conn, void *p);
+
/*The following definitions come from smbd/vfs-wrap.c */
int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
@@ -3280,19 +3284,6 @@ int vfswrap_unlink(char *path);
int vfswrap_chmod(char *path, mode_t mode);
int vfswrap_utime(char *path, struct utimbuf *times);
-/*The following definitions come from smbd/vfs.c */
-
-int vfs_init_default(connection_struct *conn);
-BOOL vfs_init_custom(connection_struct *conn);
-BOOL vfs_directory_exist(connection_struct *conn, char *dname,
- SMB_STRUCT_STAT *st);
-BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf);
-ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N);
-SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp,
- int out_fd, files_struct *out_fsp,
- SMB_OFF_T n, char *header, int headlen, int align);
-char *vfs_readdirname(connection_struct *conn, void *p);
-
/*The following definitions come from smbwrapper/realcalls.c */
int real_utime(const char *name, struct utimbuf *buf);
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 5aef2f3f63..fc8fd041d6 100755
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -270,6 +270,7 @@
#define MIN_PRIORITY 1
#define DEF_PRIORITY 1
+/* the flags of the query */
#define PRINTER_ENUM_DEFAULT 0x00000001
#define PRINTER_ENUM_LOCAL 0x00000002
#define PRINTER_ENUM_CONNECTIONS 0x00000004
@@ -279,9 +280,9 @@
#define PRINTER_ENUM_SHARED 0x00000020
#define PRINTER_ENUM_NETWORK 0x00000040
+/* the flags of each printers */
#define PRINTER_ENUM_EXPAND 0x00004000
#define PRINTER_ENUM_CONTAINER 0x00008000
-
#define PRINTER_ENUM_ICONMASK 0x00ff0000
#define PRINTER_ENUM_ICON1 0x00010000
#define PRINTER_ENUM_ICON2 0x00020000
@@ -685,10 +686,11 @@ typedef struct printer_info_2
typedef struct spool_q_enumprinters
{
uint32 flags;
+ uint32 servername_ptr;
UNISTR2 servername;
uint32 level;
- BUFFER buffer;
- uint32 buf_size;
+ NEW_BUFFER *buffer;
+ uint32 offered;
} SPOOL_Q_ENUMPRINTERS;
typedef struct printer_info_ctr_info
@@ -703,14 +705,10 @@ typedef struct printer_info_ctr_info
typedef struct spool_r_enumprinters
{
- uint32 offered; /* number of bytes offered */
+ NEW_BUFFER *buffer;
uint32 needed; /* bytes needed */
- uint32 level;
- UNISTR servername;
- PRINTER_INFO_CTR ctr;
uint32 returned; /* number of printers */
uint32 status;
-
} SPOOL_R_ENUMPRINTERS;
@@ -905,9 +903,8 @@ typedef struct spool_q_enumjobs
uint32 firstjob;
uint32 numofjobs;
uint32 level;
- BUFFER buffer;
- uint32 buf_size;
-
+ NEW_BUFFER *buffer;
+ uint32 offered;
} SPOOL_Q_ENUMJOBS;
typedef struct job_info_ctr_info
@@ -922,12 +919,10 @@ typedef struct job_info_ctr_info
typedef struct spool_r_enumjobs
{
- uint32 level;
- uint32 offered;
- JOB_INFO_CTR ctr;
- uint32 numofjobs;
+ NEW_BUFFER *buffer;
+ uint32 needed;
+ uint32 returned;
uint32 status;
-
} SPOOL_R_ENUMJOBS;
typedef struct spool_q_schedulejob
@@ -957,10 +952,11 @@ typedef struct s_port_info_2
typedef struct spool_q_enumports
{
+ uint32 name_ptr;
UNISTR2 name;
uint32 level;
- BUFFER buffer;
- uint32 buf_size;
+ NEW_BUFFER *buffer;
+ uint32 offered;
} SPOOL_Q_ENUMPORTS;
typedef struct port_info_ctr_info
@@ -974,12 +970,10 @@ typedef struct port_info_ctr_info
typedef struct spool_r_enumports
{
- uint32 level;
- PORT_INFO_CTR ctr;
- uint32 offered;
- uint32 numofports;
+ NEW_BUFFER *buffer;
+ uint32 needed; /* bytes needed */
+ uint32 returned; /* number of printers */
uint32 status;
-
} SPOOL_R_ENUMPORTS;
#define JOB_CONTROL_PAUSE 1
@@ -1015,22 +1009,21 @@ typedef struct spool_r_setjob
typedef struct spool_q_enumprinterdrivers
{
+ uint32 name_ptr;
UNISTR2 name;
+ uint32 environment_ptr;
UNISTR2 environment;
uint32 level;
- BUFFER buffer;
- uint32 buf_size;
-
+ NEW_BUFFER *buffer;
+ uint32 offered;
} SPOOL_Q_ENUMPRINTERDRIVERS;
typedef struct spool_r_enumprinterdrivers
{
- uint32 level;
- DRIVER_INFO ctr;
- uint32 offered;
- uint32 numofdrivers;
+ NEW_BUFFER *buffer;
+ uint32 needed;
+ uint32 returned;
uint32 status;
-
} SPOOL_R_ENUMPRINTERDRIVERS;
typedef struct spool_form_1
@@ -1264,11 +1257,13 @@ typedef struct spool_r_getprinterdriverdirectory
typedef struct spool_q_enumprintprocessors
{
+ uint32 name_ptr;
UNISTR2 name;
+ uint32 environment_ptr;
UNISTR2 environment;
uint32 level;
- BUFFER buffer;
- uint32 buf_size;
+ NEW_BUFFER *buffer;
+ uint32 offered;
} SPOOL_Q_ENUMPRINTPROCESSORS;
typedef struct printprocessor_1
@@ -1278,10 +1273,9 @@ typedef struct printprocessor_1
typedef struct spool_r_enumprintprocessors
{
- uint32 level;
- PRINTPROCESSOR_1 *info_1;
- uint32 offered;
- uint32 numofprintprocessors;
+ NEW_BUFFER *buffer;
+ uint32 needed;
+ uint32 returned;
uint32 status;
} SPOOL_R_ENUMPRINTPROCESSORS;
@@ -1308,28 +1302,36 @@ typedef struct spool_r_enumprintprocessordatatypes
uint32 status;
} SPOOL_R_ENUMPRINTPROCESSORDATATYPES;
-typedef struct spool_q_enumprintmonitors
-{
- UNISTR2 name;
- uint32 level;
- BUFFER buffer;
- uint32 buf_size;
-} SPOOL_Q_ENUMPRINTMONITORS;
-
typedef struct printmonitor_1
{
UNISTR name;
} PRINTMONITOR_1;
-typedef struct spool_r_enumprintmonitors
+typedef struct printmonitor_2
{
+ UNISTR name;
+ UNISTR environment;
+ UNISTR dll_name;
+} PRINTMONITOR_2;
+
+typedef struct spool_q_enumprintmonitors
+{
+ uint32 name_ptr;
+ UNISTR2 name;
uint32 level;
- PRINTMONITOR_1 *info_1;
+ NEW_BUFFER *buffer;
uint32 offered;
- uint32 numofprintmonitors;
+} SPOOL_Q_ENUMPRINTMONITORS;
+
+typedef struct spool_r_enumprintmonitors
+{
+ NEW_BUFFER *buffer;
+ uint32 needed;
+ uint32 returned;
uint32 status;
} SPOOL_R_ENUMPRINTMONITORS;
+
typedef struct spool_q_enumprinterdata
{
POLICY_HND handle;
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 00e052772e..a880184f3d 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -31,7 +31,7 @@ static BOOL parse_form_entry(char *line, nt_forms_struct *buf)
count++;
}
- DEBUG(6,("Found [%d] tokens\n", count));
+ DEBUG(106,("Found [%d] tokens\n", count));
StrnCpy(buf->name,tok[NAMETOK],sizeof(buf->name)-1);
buf->flag=atoi(tok[FLAGTOK]);
@@ -65,7 +65,7 @@ int get_ntforms(nt_forms_struct **list)
while ( fgets(line, sizeof(pstring), f) )
{
- DEBUG(5,("%s\n",line));
+ DEBUG(105,("%s\n",line));
*list = Realloc(*list, sizeof(nt_forms_struct)*(total+1));
if (! *list)
@@ -82,7 +82,7 @@ int get_ntforms(nt_forms_struct **list)
}
fclose(f);
- DEBUG(4,("%d info lines on %d\n",total, grandtotal));
+ DEBUG(104,("%d info lines on %d\n",total, grandtotal));
return(total);
}
@@ -100,7 +100,7 @@ int write_ntforms(nt_forms_struct **list, int number)
*line=0;
- DEBUG(6,("write_ntforms\n"));
+ DEBUG(106,("write_ntforms\n"));
if((f = sys_fopen(file, "w")) == NULL)
{
@@ -115,11 +115,11 @@ int write_ntforms(nt_forms_struct **list, int number)
(*list)[i].flag, (*list)[i].width, (*list)[i].length,
(*list)[i].left, (*list)[i].top, (*list)[i].right, (*list)[i].bottom);
- DEBUGADD(7,("adding entry [%s]\n", (*list)[i].name));
+ DEBUGADD(107,("adding entry [%s]\n", (*list)[i].name));
}
fclose(f);
- DEBUGADD(6,("closing file\n"));
+ DEBUGADD(106,("closing file\n"));
return(total);
}
@@ -145,7 +145,7 @@ void add_a_form(nt_forms_struct **list, const FORM *form, int *count)
{
if (!strncmp((*list)[n].name, form_name, strlen(form_name)))
{
- DEBUG(3, ("NT workaround, [%s] already exists\n", form_name));
+ DEBUG(103, ("NT workaround, [%s] already exists\n", form_name));
update=True;
}
}
@@ -175,10 +175,10 @@ void update_a_form(nt_forms_struct **list, const FORM *form, int count)
fstring form_name;
unistr2_to_ascii(form_name, &(form->name), sizeof(form_name)-1);
- DEBUG(6, ("[%s]\n", form_name));
+ DEBUG(106, ("[%s]\n", form_name));
for (n=0; n<count; n++)
{
- DEBUGADD(6, ("n [%d]:[%s]\n", n, (*list)[n].name));
+ DEBUGADD(106, ("n [%d]:[%s]\n", n, (*list)[n].name));
if (!strncmp((*list)[n].name, form_name, strlen(form_name)))
break;
}
@@ -209,7 +209,7 @@ int get_ntdrivers(fstring **list, char *architecture)
int match_len;
int total=0;
- DEBUG(5,("Getting the driver list from directory: [%s]\n", lp_nt_drivers_file()));
+ DEBUG(105,("Getting the driver list from directory: [%s]\n", lp_nt_drivers_file()));
*list=NULL;
dirp = opendir(lp_nt_drivers_file());
@@ -228,13 +228,13 @@ int get_ntdrivers(fstring **list, char *architecture)
{
if (strncmp(dpname, name_match, match_len)==0)
{
- DEBUGADD(7,("Found: [%s]\n", dpname));
+ DEBUGADD(107,("Found: [%s]\n", dpname));
fstrcpy(driver_name, dpname+match_len);
all_string_sub(driver_name, "#", "/", 0);
*list = Realloc(*list, sizeof(fstring)*(total+1));
StrnCpy((*list)[total], driver_name, strlen(driver_name));
- DEBUGADD(6,("Added: [%s]\n", driver_name));
+ DEBUGADD(106,("Added: [%s]\n", driver_name));
total++;
}
}
@@ -266,20 +266,20 @@ void get_short_archi(char *short_archi, char *long_archi)
int i=-1;
- DEBUG(7,("Getting architecture dependant directory\n"));
+ DEBUG(107,("Getting architecture dependant directory\n"));
do {
i++;
} while ( (archi_table[i].long_archi!=NULL ) && strncmp(long_archi, archi_table[i].long_archi, strlen(long_archi)) );
if (archi_table[i].long_archi==NULL)
{
- DEBUGADD(7,("Unknown architecture [%s] !\n", long_archi));
+ DEBUGADD(107,("Unknown architecture [%s] !\n", long_archi));
}
StrnCpy (short_archi, archi_table[i].short_archi, strlen(archi_table[i].short_archi));
- DEBUGADD(8,("index: [%d]\n", i));
- DEBUGADD(8,("long architecture: [%s]\n", long_archi));
- DEBUGADD(8,("short architecture: [%s]\n", short_archi));
+ DEBUGADD(108,("index: [%d]\n", i));
+ DEBUGADD(108,("long architecture: [%s]\n", long_archi));
+ DEBUGADD(108,("short architecture: [%s]\n", short_archi));
}
/****************************************************************************
@@ -471,7 +471,7 @@ static uint32 dump_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32
NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3;
char **dependentfiles;
- DEBUG(6,("Dumping printer driver at level [%d]\n", level));
+ DEBUG(106,("Dumping printer driver at level [%d]\n", level));
switch (level)
{
@@ -479,28 +479,28 @@ static uint32 dump_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32
{
if (driver.info_3 == NULL)
{
- DEBUGADD(3,("NULL pointer, memory not alloced ?\n"));
+ DEBUGADD(103,("NULL pointer, memory not alloced ?\n"));
success=5;
}
else
{
info3=driver.info_3;
- DEBUGADD(6,("version:[%d]\n", info3->cversion));
- DEBUGADD(6,("name:[%s]\n", info3->name));
- DEBUGADD(6,("environment:[%s]\n", info3->environment));
- DEBUGADD(6,("driverpath:[%s]\n", info3->driverpath));
- DEBUGADD(6,("datafile:[%s]\n", info3->datafile));
- DEBUGADD(6,("configfile:[%s]\n", info3->configfile));
- DEBUGADD(6,("helpfile:[%s]\n", info3->helpfile));
- DEBUGADD(6,("monitorname:[%s]\n", info3->monitorname));
- DEBUGADD(6,("defaultdatatype:[%s]\n", info3->defaultdatatype));
+ DEBUGADD(106,("version:[%d]\n", info3->cversion));
+ DEBUGADD(106,("name:[%s]\n", info3->name));
+ DEBUGADD(106,("environment:[%s]\n", info3->environment));
+ DEBUGADD(106,("driverpath:[%s]\n", info3->driverpath));
+ DEBUGADD(106,("datafile:[%s]\n", info3->datafile));
+ DEBUGADD(106,("configfile:[%s]\n", info3->configfile));
+ DEBUGADD(106,("helpfile:[%s]\n", info3->helpfile));
+ DEBUGADD(106,("monitorname:[%s]\n", info3->monitorname));
+ DEBUGADD(106,("defaultdatatype:[%s]\n", info3->defaultdatatype));
dependentfiles=info3->dependentfiles;
while ( **dependentfiles != '\0' )
{
- DEBUGADD(6,("dependentfile:[%s]\n", *dependentfiles));
+ DEBUGADD(106,("dependentfile:[%s]\n", *dependentfiles));
dependentfiles++;
}
success=0;
@@ -676,7 +676,7 @@ static void dissect_and_fill_a_param(NT_PRINTER_PARAM *param, char *v)
char *tok[5];
int count = 0;
- DEBUG(5,("dissect_and_fill_a_param\n"));
+ DEBUG(105,("dissect_and_fill_a_param\n"));
tok[count] = strtok(v,"#");
count++;
@@ -693,7 +693,7 @@ static void dissect_and_fill_a_param(NT_PRINTER_PARAM *param, char *v)
strhex_to_str(param->data, 2*(param->data_len), tok[3]);
param->next=NULL;
- DEBUGADD(5,("value:[%s], len:[%d]\n", param->value, param->data_len));
+ DEBUGADD(105,("value:[%s], len:[%d]\n", param->value, param->data_len));
}
/****************************************************************************
@@ -703,10 +703,10 @@ used when reading from disk.
****************************************************************************/
void dump_a_param(NT_PRINTER_PARAM *param)
{
- DEBUG(5,("dump_a_param\n"));
- DEBUGADD(6,("value [%s]\n", param->value));
- DEBUGADD(6,("type [%d]\n", param->type));
- DEBUGADD(6,("data len [%d]\n", param->data_len));
+ DEBUG(105,("dump_a_param\n"));
+ DEBUGADD(106,("value [%s]\n", param->value));
+ DEBUGADD(106,("type [%d]\n", param->type));
+ DEBUGADD(106,("data len [%d]\n", param->data_len));
}
/****************************************************************************
@@ -715,7 +715,7 @@ BOOL add_a_specific_param(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *par
{
NT_PRINTER_PARAM *current;
- DEBUG(8,("add_a_specific_param\n"));
+ DEBUG(108,("add_a_specific_param\n"));
param->next=NULL;
@@ -749,10 +749,10 @@ BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_
if ( !strcmp(current->value, param->value) &&
(strlen(current->value)==strlen(param->value)) )
{
- DEBUG(9,("deleting first value\n"));
+ DEBUG(109,("deleting first value\n"));
info_2->specific=current->next;
free(current);
- DEBUG(9,("deleted first value\n"));
+ DEBUG(109,("deleted first value\n"));
return (True);
}
@@ -763,10 +763,10 @@ BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_
if (!strcmp(current->value, param->value) &&
strlen(current->value)==strlen(param->value) )
{
- DEBUG(9,("deleting current value\n"));
+ DEBUG(109,("deleting current value\n"));
previous->next=current->next;
free(current);
- DEBUG(9,("deleted current value\n"));
+ DEBUG(109,("deleted current value\n"));
return(True);
}
@@ -835,7 +835,7 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
/* don't check if v==NULL as an empty arg is valid */
- DEBUGADD(15, ("[%s]:[%s]\n", p, v));
+ DEBUGADD(115, ("[%s]:[%s]\n", p, v));
/*
* The PRINTER_INFO_2 fields
@@ -1008,7 +1008,7 @@ static uint32 dump_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
uint32 success;
NT_PRINTER_INFO_LEVEL_2 *info2;
- DEBUG(6,("Dumping printer at level [%d]\n", level));
+ DEBUG(106,("Dumping printer at level [%d]\n", level));
switch (level)
{
@@ -1023,26 +1023,26 @@ static uint32 dump_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
info2=printer.info_2;
- DEBUGADD(6,("attributes:[%d]\n", info2->attributes));
- DEBUGADD(6,("priority:[%d]\n", info2->priority));
- DEBUGADD(6,("default_priority:[%d]\n", info2->default_priority));
- DEBUGADD(6,("starttime:[%d]\n", info2->starttime));
- DEBUGADD(6,("untiltime:[%d]\n", info2->untiltime));
- DEBUGADD(6,("status:[%d]\n", info2->status));
- DEBUGADD(6,("cjobs:[%d]\n", info2->cjobs));
- DEBUGADD(6,("averageppm:[%d]\n", info2->averageppm));
-
- DEBUGADD(6,("servername:[%s]\n", info2->servername));
- DEBUGADD(6,("printername:[%s]\n", info2->printername));
- DEBUGADD(6,("sharename:[%s]\n", info2->sharename));
- DEBUGADD(6,("portname:[%s]\n", info2->portname));
- DEBUGADD(6,("drivername:[%s]\n", info2->drivername));
- DEBUGADD(6,("comment:[%s]\n", info2->comment));
- DEBUGADD(6,("location:[%s]\n", info2->location));
- DEBUGADD(6,("sepfile:[%s]\n", info2->sepfile));
- DEBUGADD(6,("printprocessor:[%s]\n", info2->printprocessor));
- DEBUGADD(6,("datatype:[%s]\n", info2->datatype));
- DEBUGADD(6,("parameters:[%s]\n", info2->parameters));
+ DEBUGADD(106,("attributes:[%d]\n", info2->attributes));
+ DEBUGADD(106,("priority:[%d]\n", info2->priority));
+ DEBUGADD(106,("default_priority:[%d]\n", info2->default_priority));
+ DEBUGADD(106,("starttime:[%d]\n", info2->starttime));
+ DEBUGADD(106,("untiltime:[%d]\n", info2->untiltime));
+ DEBUGADD(106,("status:[%d]\n", info2->status));
+ DEBUGADD(106,("cjobs:[%d]\n", info2->cjobs));
+ DEBUGADD(106,("averageppm:[%d]\n", info2->averageppm));
+
+ DEBUGADD(106,("servername:[%s]\n", info2->servername));
+ DEBUGADD(106,("printername:[%s]\n", info2->printername));
+ DEBUGADD(106,("sharename:[%s]\n", info2->sharename));
+ DEBUGADD(106,("portname:[%s]\n", info2->portname));
+ DEBUGADD(106,("drivername:[%s]\n", info2->drivername));
+ DEBUGADD(106,("comment:[%s]\n", info2->comment));
+ DEBUGADD(106,("location:[%s]\n", info2->location));
+ DEBUGADD(106,("sepfile:[%s]\n", info2->sepfile));
+ DEBUGADD(106,("printprocessor:[%s]\n", info2->printprocessor));
+ DEBUGADD(106,("datatype:[%s]\n", info2->datatype));
+ DEBUGADD(106,("parameters:[%s]\n", info2->parameters));
success=0;
}
break;
@@ -1114,7 +1114,7 @@ uint32 get_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level, fstring share
uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
uint32 success;
- DEBUG(4,("freeing a printer at level [%d]\n", level));
+ DEBUG(104,("freeing a printer at level [%d]\n", level));
switch (level)
{
@@ -1124,7 +1124,7 @@ uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
if ((printer.info_2)->devmode != NULL)
{
- DEBUG(6,("deleting DEVMODE\n"));
+ DEBUG(106,("deleting DEVMODE\n"));
if ((printer.info_2)->devmode->private !=NULL )
free((printer.info_2)->devmode->private);
free((printer.info_2)->devmode);
@@ -1140,7 +1140,7 @@ uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
while ( param != NULL)
{
next_param=param->next;
- DEBUG(6,("deleting param [%s]\n", param->value));
+ DEBUG(106,("deleting param [%s]\n", param->value));
free(param->data);
free(param);
param=next_param;
@@ -1168,7 +1168,7 @@ uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
uint32 add_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level)
{
uint32 success;
- DEBUG(4,("adding a printer at level [%d]\n", level));
+ DEBUG(104,("adding a printer at level [%d]\n", level));
dump_a_printer_driver(driver, level);
switch (level)
@@ -1293,7 +1293,7 @@ BOOL get_specific_param(NT_PRINTER_INFO_LEVEL printer, uint32 level,
/* right now that's enough ! */
NT_PRINTER_PARAM *param;
- DEBUG(5, ("get_specific_param\n"));
+ DEBUG(105, ("get_specific_param\n"));
param=printer.info_2->specific;
@@ -1306,7 +1306,7 @@ BOOL get_specific_param(NT_PRINTER_INFO_LEVEL printer, uint32 level,
param=param->next;
}
- DEBUG(6, ("found one param\n"));
+ DEBUG(106, ("found one param\n"));
if (param != NULL)
{
/* exited because it exist */
@@ -1316,10 +1316,10 @@ BOOL get_specific_param(NT_PRINTER_INFO_LEVEL printer, uint32 level,
memcpy(*data, param->data, param->data_len);
*len=param->data_len;
- DEBUG(6, ("exit of get_specific_param:true\n"));
+ DEBUG(106, ("exit of get_specific_param:true\n"));
return (True);
}
- DEBUG(6, ("exit of get_specific_param:false\n"));
+ DEBUG(106, ("exit of get_specific_param:false\n"));
return (False);
}
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index 24eff1b779..5d0ea832c8 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -150,15 +150,13 @@ BOOL prs_grow(prs_struct *ps, uint32 extra_space)
(unsigned int)extra_space));
return False;
}
-
+
/*
* Decide how much extra space we really need.
*/
extra_space -= (ps->buffer_size - ps->data_offset);
-
if(ps->buffer_size == 0) {
-
/*
* Ensure we have at least a PDU's length, or extra_space, whichever
* is greater.
@@ -172,21 +170,18 @@ BOOL prs_grow(prs_struct *ps, uint32 extra_space)
}
memset(new_data, '\0', new_size );
} else {
-
/*
* If the current buffer size is bigger than the space needed, just
* double it, else add extra_space.
*/
+ new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space);
- new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space);
-
- if((new_data = Realloc(ps->data_p, new_size)) == NULL) {
+ if ((new_data = Realloc(ps->data_p, new_size)) == NULL) {
DEBUG(0,("prs_grow: Realloc failure for size %u.\n",
(unsigned int)new_size));
return False;
}
}
-
ps->buffer_size = new_size;
ps->data_p = new_data;
@@ -286,12 +281,12 @@ BOOL prs_append_prs_data(prs_struct *dst, prs_struct *src)
Append some data from one parse_struct into another.
********************************************************************/
-BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, uint32 len)
-{
+BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len)
+{
if(!prs_grow(dst, len))
return False;
-
- memcpy(&dst->data_p[dst->data_offset], prs_data_p(src), (size_t)len);
+
+ memcpy(&dst->data_p[dst->data_offset], prs_data_p(src)+start, (size_t)len);
dst->data_offset += len;
return True;
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index de998267b3..66fa2f1da5 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -825,9 +825,11 @@ BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct
prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter");
depth++;
- prs_align(ps);
+ if (!prs_align(ps))
+ return False;
- smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth);
+ if (!smb_io_prt_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
return True;
}
@@ -841,12 +843,15 @@ BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct
{
prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter");
depth++;
- prs_align(ps);
-
- smb_io_prt_hnd("printer handle",&(r_u->handle),ps,depth);
- prs_uint32("status", ps, depth, &(r_u->status));
+ if (!prs_align(ps))
+ return False;
+ if (!smb_io_prt_hnd("printer handle",&r_u->handle,ps,depth))
+ return False;
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
+
return True;
}
@@ -1240,8 +1245,7 @@ static BOOL new_smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR
{
prs_struct *ps=&(buffer->prs);
- if (MARSHALLING(ps))
- {
+ if (MARSHALLING(ps)) {
uint32 struct_offset = prs_offset(ps);
uint32 relative_offset;
@@ -1254,13 +1258,12 @@ static BOOL new_smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR
prs_set_offset(ps, struct_offset);
- relative_offset=buffer->string_at_end-buffer->struct_start;
+ relative_offset=buffer->string_at_end - buffer->struct_start;
/* write its offset */
if (!prs_uint32("offset", ps, depth, &relative_offset))
return False;
}
- else
- {
+ else {
uint32 old_offset;
/* read the offset */
@@ -1284,6 +1287,67 @@ static BOOL new_smb_io_relstr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR
* write a array UNICODE strings and its relative pointer.
* used by 2 RPC structs
********************************************************************/
+static BOOL new_smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, UNISTR ***string)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ if (MARSHALLING(ps)) {
+ uint32 struct_offset = prs_offset(ps);
+ uint32 relative_offset;
+ int i=0;
+
+ while ( (*string)[i]!=0x0000 )
+ i++;
+ i--;
+
+ /* count the ending NULL of the array */
+ buffer->string_at_end -= 2;
+
+ /* jfm: FIXME: write a (uint16) 0 for the ending NULL */
+
+ do
+ {
+ buffer->string_at_end -= 2*(str_len_uni((*string)[i])+1);
+ prs_set_offset(ps, buffer->string_at_end);
+
+ /* write the string */
+ if (!spoolss_smb_io_unistr(desc, (*string)[i], ps, depth))
+ return False;
+
+ i--;
+ }
+ while (i>=0);
+
+ prs_set_offset(ps, struct_offset);
+
+ relative_offset=buffer->string_at_end - buffer->struct_start;
+ /* write its offset */
+ if (!prs_uint32("offset", ps, depth, &relative_offset))
+ return False;
+ }
+ else {
+ uint32 old_offset;
+
+ /* read the offset */
+ if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end)))
+ return False;
+
+ old_offset = prs_offset(ps);
+ prs_set_offset(ps, buffer->string_at_end);
+
+ /* read the string */
+
+ /* jfm: FIXME: alloc memory and read all the strings until the string is NULL */
+
+/*
+ if (!spoolss_smb_io_unistr(desc, string, ps, depth))
+ return False;
+*/
+ prs_set_offset(ps, old_offset);
+ }
+ return True;
+}
+
static BOOL smb_io_relarraystr(char *desc, prs_struct *ps, int depth, UNISTR ***buffer,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1321,9 +1385,54 @@ static BOOL smb_io_relarraystr(char *desc, prs_struct *ps, int depth, UNISTR ***
}
/*******************************************************************
- * write a DEVMODE struct and its relative pointer.
- * used by all the RPC structs passing a buffer
- ********************************************************************/
+ Parse a DEVMODE structure and its relative pointer.
+********************************************************************/
+static BOOL new_smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE *devmode)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_reldevmode");
+ depth++;
+
+ if (MARSHALLING(ps)) {
+ uint32 struct_offset = prs_offset(ps);
+ uint32 relative_offset;
+
+ buffer->string_at_end -= (devmode->size+devmode->driverextra);
+
+ prs_set_offset(ps, buffer->string_at_end);
+
+ /* write the DEVMODE */
+ if (!spoolss_io_devmode(desc, ps, depth, devmode))
+ return False;
+
+ prs_set_offset(ps, struct_offset);
+
+ relative_offset=buffer->string_at_end - buffer->struct_start;
+ /* write its offset */
+ if (!prs_uint32("offset", ps, depth, &relative_offset))
+ return False;
+ }
+ else {
+ uint32 old_offset;
+
+ /* read the offset */
+ if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end)))
+ return False;
+
+ old_offset = prs_offset(ps);
+ prs_set_offset(ps, buffer->string_at_end + buffer->struct_start);
+
+ /* read the string */
+ if (!spoolss_io_devmode(desc, ps, depth, devmode))
+ return False;
+
+ prs_set_offset(ps, old_offset);
+ }
+ return True;
+}
+
+
static BOOL smb_io_reldevmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1392,76 +1501,112 @@ static BOOL smb_io_printer_info_0(char *desc, PRINTER_INFO_0 *info, prs_struct *
}
/*******************************************************************
+ Parse a PRINTER_INFO_1 structure.
********************************************************************/
-static BOOL smb_io_printer_info_1(char *desc, PRINTER_INFO_1 *info, prs_struct *ps, int depth,
- uint32 *start_offset, uint32 *end_offset)
+BOOL new_smb_io_printer_info_1(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
{
- prs_debug(ps, depth, desc, "smb_io_printer_info_1");
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_printer_info_1");
depth++;
- *start_offset=prs_offset(ps);
- prs_uint32("flags", ps, depth, &(info->flags));
- smb_io_relstr("description",ps, depth, &(info->description), start_offset, end_offset);
- smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset);
- smb_io_relstr("comment",ps, depth, &(info->comment), start_offset, end_offset);
+ buffer->struct_start=prs_offset(ps);
+
+ if (!prs_uint32("flags", ps, depth, &info->flags))
+ return False;
+ if (!new_smb_io_relstr("description", buffer, depth, &info->description))
+ return False;
+ if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
+ if (!new_smb_io_relstr("comment", buffer, depth, &info->comment))
+ return False;
return True;
}
/*******************************************************************
+ Parse a PRINTER_INFO_2 structure.
********************************************************************/
-static BOOL smb_io_printer_info_2(char *desc, PRINTER_INFO_2 *info, prs_struct *ps, int depth,
- uint32 *start_offset, uint32 *end_offset)
+BOOL new_smb_io_printer_info_2(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
{
+ /* hack for the SEC DESC */
uint32 pipo=0;
- uint32 devmode_offset;
- uint32 backup_offset;
- prs_debug(ps, depth, desc, "smb_io_printer_info_2");
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_printer_info_2");
depth++;
- *start_offset=prs_offset(ps);
- smb_io_relstr("servername", ps, depth, &(info->servername), start_offset, end_offset);
- smb_io_relstr("printername", ps, depth, &(info->printername), start_offset, end_offset);
- smb_io_relstr("sharename", ps, depth, &(info->sharename), start_offset, end_offset);
- smb_io_relstr("portname", ps, depth, &(info->portname), start_offset, end_offset);
- smb_io_relstr("drivername", ps, depth, &(info->drivername), start_offset, end_offset);
- smb_io_relstr("comment", ps, depth, &(info->comment), start_offset, end_offset);
- smb_io_relstr("location", ps, depth, &(info->location), start_offset, end_offset);
-
- devmode_offset=prs_offset(ps);
- prs_set_offset(ps, prs_offset(ps)+4);
+ buffer->struct_start=prs_offset(ps);
- smb_io_relstr("sepfile", ps, depth, &(info->sepfile), start_offset, end_offset);
- smb_io_relstr("printprocessor",ps, depth, &(info->printprocessor), start_offset, end_offset);
- smb_io_relstr("datatype", ps, depth, &(info->datatype), start_offset, end_offset);
- smb_io_relstr("parameters", ps, depth, &(info->parameters), start_offset, end_offset);
-
- prs_uint32("security descriptor", ps, depth, &(pipo));
-
- prs_uint32("attributes", ps, depth, &(info->attributes));
- prs_uint32("priority", ps, depth, &(info->priority));
- prs_uint32("defpriority", ps, depth, &(info->defaultpriority));
- prs_uint32("starttime", ps, depth, &(info->starttime));
- prs_uint32("untiltime", ps, depth, &(info->untiltime));
- prs_uint32("status", ps, depth, &(info->status));
- prs_uint32("jobs", ps, depth, &(info->cjobs));
- prs_uint32("averageppm", ps, depth, &(info->averageppm));
+ if (!new_smb_io_relstr("servername", buffer, depth, &info->servername))
+ return False;
+ if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ return False;
+ if (!new_smb_io_relstr("sharename", buffer, depth, &info->sharename))
+ return False;
+ if (!new_smb_io_relstr("portname", buffer, depth, &info->portname))
+ return False;
+ if (!new_smb_io_relstr("drivername", buffer, depth, &info->drivername))
+ return False;
+ if (!new_smb_io_relstr("comment", buffer, depth, &info->comment))
+ return False;
+ if (!new_smb_io_relstr("location", buffer, depth, &info->location))
+ return False;
- /*
- I'm not sure if putting the devmode at the end the struct is worth it
- but NT does it
- */
- backup_offset=prs_offset(ps);
- prs_set_offset(ps, devmode_offset);
- smb_io_reldevmode("devmode", ps, depth, info->devmode, start_offset, end_offset);
- prs_set_offset(ps, backup_offset);
+ /* NT parses the DEVMODE at the end of the struct */
+ if (!new_smb_io_reldevmode("devmode", buffer, depth, info->devmode))
+ return False;
+
+ if (!new_smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
+ return False;
+ if (!new_smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
+ return False;
+ if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ return False;
+ if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
+ return False;
+
+ if (!prs_uint32("security descriptor", ps, depth, &pipo))
+ return False;
+ if (!prs_uint32("attributes", ps, depth, &info->attributes))
+ return False;
+ if (!prs_uint32("priority", ps, depth, &info->priority))
+ return False;
+ if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
+ return False;
+ if (!prs_uint32("starttime", ps, depth, &info->starttime))
+ return False;
+ if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
+ return False;
+ if (!prs_uint32("status", ps, depth, &info->status))
+ return False;
+ if (!prs_uint32("jobs", ps, depth, &info->cjobs))
+ return False;
+ if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
+ return False;
return True;
}
/*******************************************************************
-********************************************************************/
+ Parse a DRIVER_INFO_1 structure.
+********************************************************************/
+BOOL new_smb_io_printer_driver_info_1(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_printer_driver_info_1");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
+
+ return True;
+}
+
static BOOL smb_io_printer_driver_info_1(char *desc, DRIVER_INFO_1 *info, prs_struct *ps, int depth,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1475,7 +1620,33 @@ static BOOL smb_io_printer_driver_info_1(char *desc, DRIVER_INFO_1 *info, prs_st
}
/*******************************************************************
-********************************************************************/
+ Parse a DRIVER_INFO_2 structure.
+********************************************************************/
+BOOL new_smb_io_printer_driver_info_2(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_printer_driver_info_2");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!prs_uint32("version", ps, depth, &info->version))
+ return False;
+ if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
+ if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
+ return False;
+ if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
+ return False;
+ if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
+ return False;
+ if (!new_smb_io_relstr("configfile", buffer, depth, &info->configfile))
+ return False;
+
+ return True;
+}
+
static BOOL smb_io_printer_driver_info_2(char *desc, DRIVER_INFO_2 *info,prs_struct *ps, int depth,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1494,7 +1665,43 @@ static BOOL smb_io_printer_driver_info_2(char *desc, DRIVER_INFO_2 *info,prs_str
}
/*******************************************************************
-********************************************************************/
+ Parse a DRIVER_INFO_3 structure.
+********************************************************************/
+BOOL new_smb_io_printer_driver_info_3(char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_printer_driver_info_3");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!prs_uint32("version", ps, depth, &info->version))
+ return False;
+ if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
+ if (!new_smb_io_relstr("architecture", buffer, depth, &info->architecture))
+ return False;
+ if (!new_smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
+ return False;
+ if (!new_smb_io_relstr("datafile", buffer, depth, &info->datafile))
+ return False;
+ if (!new_smb_io_relstr("configfile", buffer, depth, &info->configfile))
+ return False;
+ if (!new_smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
+ return False;
+
+ if (!new_smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
+ return False;
+
+ if (!new_smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
+ return False;
+ if (!new_smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
+ return False;
+
+ return True;
+}
+
static BOOL smb_io_printer_driver_info_3(char *desc, DRIVER_INFO_3 *info,prs_struct *ps, int depth,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1519,7 +1726,47 @@ static BOOL smb_io_printer_driver_info_3(char *desc, DRIVER_INFO_3 *info,prs_str
}
/*******************************************************************
+ Parse a JOB_INFO_1 structure.
********************************************************************/
+BOOL new_smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_job_info_1");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!prs_uint32("jobid", ps, depth, &info->jobid))
+ return False;
+ if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ return False;
+ if (!new_smb_io_relstr("machinename", buffer, depth, &info->machinename))
+ return False;
+ if (!new_smb_io_relstr("username", buffer, depth, &info->username))
+ return False;
+ if (!new_smb_io_relstr("document", buffer, depth, &info->document))
+ return False;
+ if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ return False;
+ if (!new_smb_io_relstr("text_status", buffer, depth, &info->text_status))
+ return False;
+ if (!prs_uint32("status", ps, depth, &info->status))
+ return False;
+ if (!prs_uint32("priority", ps, depth, &info->priority))
+ return False;
+ if (!prs_uint32("position", ps, depth, &info->position))
+ return False;
+ if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
+ return False;
+ if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
+ return False;
+ if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
+ return False;
+
+ return True;
+}
+
static BOOL smb_io_job_info_1(char *desc, JOB_INFO_1 *info, prs_struct *ps, int depth,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1545,7 +1792,71 @@ static BOOL smb_io_job_info_1(char *desc, JOB_INFO_1 *info, prs_struct *ps, int
}
/*******************************************************************
+ Parse a JOB_INFO_2 structure.
********************************************************************/
+BOOL new_smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth)
+{
+ int pipo=0;
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_job_info_2");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!prs_uint32("jobid",ps, depth, &info->jobid))
+ return False;
+ if (!new_smb_io_relstr("printername", buffer, depth, &info->printername))
+ return False;
+ if (!new_smb_io_relstr("machinename", buffer, depth, &info->machinename))
+ return False;
+ if (!new_smb_io_relstr("username", buffer, depth, &info->username))
+ return False;
+ if (!new_smb_io_relstr("document", buffer, depth, &info->document))
+ return False;
+ if (!new_smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
+ return False;
+ if (!new_smb_io_relstr("datatype", buffer, depth, &info->datatype))
+ return False;
+
+ if (!new_smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
+ return False;
+ if (!new_smb_io_relstr("parameters", buffer, depth, &info->parameters))
+ return False;
+ if (!new_smb_io_relstr("drivername", buffer, depth, &info->drivername))
+ return False;
+ if (!new_smb_io_reldevmode("devmode", buffer, depth, info->devmode))
+ return False;
+ if (!new_smb_io_relstr("text_status", buffer, depth, &info->text_status))
+ return False;
+
+/* SEC_DESC sec_desc;*/
+ if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
+ return False;
+
+ if (!prs_uint32("status",ps, depth, &info->status))
+ return False;
+ if (!prs_uint32("priority",ps, depth, &info->priority))
+ return False;
+ if (!prs_uint32("position",ps, depth, &info->position))
+ return False;
+ if (!prs_uint32("starttime",ps, depth, &info->starttime))
+ return False;
+ if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
+ return False;
+ if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
+ return False;
+ if (!prs_uint32("size",ps, depth, &info->size))
+ return False;
+ if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
+ return False;
+ if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
+ return False;
+ if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
+ return False;
+
+ return True;
+}
static BOOL smb_io_job_info_2(char *desc, JOB_INFO_2 *info, prs_struct *ps, int depth,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1643,18 +1954,20 @@ static BOOL new_spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUF
return True;
}
- if (!prs_uint32("size", ps, depth, &(buffer->size)))
+ if (!prs_uint32("size", ps, depth, &buffer->size))
return False;
if (!prs_init(&(buffer->prs), buffer->size, 4, UNMARSHALL))
return False;
- if (!prs_append_some_prs_data(&(buffer->prs), ps, buffer->size))
+ if (!prs_append_some_prs_data(&(buffer->prs), ps, prs_offset(ps), buffer->size))
return False;
- prs_set_offset(&(buffer->prs),0);
+ if (!prs_set_offset(&buffer->prs, 0))
+ return False;
- prs_set_offset(ps, buffer->size+prs_offset(ps));
+ if (!prs_set_offset(ps, buffer->size+prs_offset(ps)))
+ return False;
buffer->string_at_end=buffer->size;
@@ -1667,12 +1980,9 @@ static BOOL new_spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUF
if (!prs_uint32("size", ps, depth, &(buffer->size)))
return False;
-
- if (!prs_append_some_prs_data(ps, &(buffer->prs), buffer->size))
+ if (!prs_append_some_prs_data(ps, &(buffer->prs), 0, buffer->size))
return False;
- }
-
- return True;
+ }
}
/*******************************************************************
@@ -1746,9 +2056,50 @@ static BOOL smb_io_form_1(char *desc, FORM_1 *info, prs_struct *ps, int depth,
return True;
}
+/*******************************************************************
+ Parse a PORT_INFO_2 structure.
+********************************************************************/
+BOOL new_smb_io_port_1(char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_port_1");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if(!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
+ return False;
+
+ return True;
+}
/*******************************************************************
+ Parse a PORT_INFO_2 structure.
********************************************************************/
+BOOL new_smb_io_port_2(char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "new_smb_io_port_2");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if(!new_smb_io_relstr("port_name", buffer, depth, &info->port_name))
+ return False;
+ if(!new_smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name))
+ return False;
+ if(!new_smb_io_relstr("description", buffer, depth, &info->description))
+ return False;
+ if(!prs_uint32("port_type", ps, depth, &info->port_type))
+ return False;
+ if(!prs_uint32("reserved", ps, depth, &info->reserved))
+ return False;
+
+ return True;
+}
+
static BOOL smb_io_port_2(char *desc, PORT_INFO_2 *info, prs_struct *ps, int depth,
uint32 *start_offset, uint32 *end_offset)
{
@@ -1767,28 +2118,55 @@ static BOOL smb_io_port_2(char *desc, PORT_INFO_2 *info, prs_struct *ps, int dep
/*******************************************************************
********************************************************************/
-static BOOL smb_io_processor_info_1(char *desc, PRINTPROCESSOR_1 *info, prs_struct *ps, int depth,
- uint32 *start_offset, uint32 *end_offset)
+BOOL smb_io_printprocessor_info_1(char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth)
{
- prs_debug(ps, depth, desc, "smb_io_processor_info_1");
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1");
depth++;
- *start_offset=prs_offset(ps);
- smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset);
+ buffer->struct_start=prs_offset(ps);
+
+ if (new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
return True;
}
/*******************************************************************
********************************************************************/
-static BOOL smb_io_monitor_info_1(char *desc, PRINTMONITOR_1 *info, prs_struct *ps, int depth,
- uint32 *start_offset, uint32 *end_offset)
+BOOL smb_io_printmonitor_info_1(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth)
{
- prs_debug(ps, depth, desc, "smb_io_monitor_info_1");
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1");
depth++;
- *start_offset=prs_offset(ps);
- smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset);
+ buffer->struct_start=prs_offset(ps);
+
+ if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+********************************************************************/
+BOOL smb_io_printmonitor_info_2(char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth)
+{
+ prs_struct *ps=&(buffer->prs);
+
+ prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2");
+ depth++;
+
+ buffer->struct_start=prs_offset(ps);
+
+ if (!new_smb_io_relstr("name", buffer, depth, &info->name))
+ return False;
+ if (!new_smb_io_relstr("environment", buffer, depth, &info->environment))
+ return False;
+ if (!new_smb_io_relstr("dll_name", buffer, depth, &info->dll_name))
+ return False;
return True;
}
@@ -1811,7 +2189,7 @@ static uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
-static uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
+uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
{
int size=0;
@@ -1819,15 +2197,14 @@ static uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
size+=size_of_relative_string( &(info->description) );
size+=size_of_relative_string( &(info->name) );
size+=size_of_relative_string( &(info->comment) );
- return (size);
- return True;
+ return size;
}
/*******************************************************************
return the size required by a struct in the stream
-********************************************************************/
-static uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
+********************************************************************/
+uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
{
int size=0;
@@ -1856,15 +2233,13 @@ static uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
size+=size_of_uint32( &(info->status) );
size+=size_of_uint32( &(info->cjobs) );
size+=size_of_uint32( &(info->averageppm) );
- return (size);
-
- return True;
+ return size;
}
/*******************************************************************
return the size required by a struct in the stream
-********************************************************************/
-static uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
+********************************************************************/
+uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
{
int size=0;
DEBUG(9,("Sizing driver info_1\n"));
@@ -1878,8 +2253,8 @@ static uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
/*******************************************************************
return the size required by a struct in the stream
-********************************************************************/
-static uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
+********************************************************************/
+uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
{
int size=0;
DEBUG(9,("Sizing driver info_2\n"));
@@ -1898,8 +2273,8 @@ static uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
/*******************************************************************
return the size required by a struct in the stream
-********************************************************************/
-static uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
+********************************************************************/
+uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
{
int size=0;
UNISTR **string;
@@ -1934,7 +2309,7 @@ static uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
-static uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
+uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
{
int size=0;
size+=size_of_uint32( &(info->jobid) );
@@ -1950,15 +2325,14 @@ static uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
size+=size_of_uint32( &(info->totalpages) );
size+=size_of_uint32( &(info->pagesprinted) );
size+=size_of_systemtime( &(info->submitted) );
- return (size);
- return True;
+ return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
-static uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
+uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
{
int size=0;
@@ -2008,15 +2382,25 @@ uint32 spoolss_size_form_1(FORM_1 *info)
size+=size_of_uint32( &(info->right) );
size+=size_of_uint32( &(info->bottom) );
- return (size);
+ return size;
+}
- return True;
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+uint32 spoolss_size_port_info_1(PORT_INFO_1 *info)
+{
+ int size=0;
+
+ size+=size_of_relative_string( &(info->port_name) );
+
+ return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
-static uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
+uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
{
int size=0;
@@ -2027,40 +2411,49 @@ static uint32 spoolss_size_port_info_2(PORT_INFO_2 *info)
size+=size_of_uint32( &(info->port_type) );
size+=size_of_uint32( &(info->reserved) );
- return (size);
+ return size;
+}
- return True;
+/*******************************************************************
+return the size required by a struct in the stream
+********************************************************************/
+uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info)
+{
+ int size=0;
+ size+=size_of_relative_string( &info->name );
+
+ return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
-static uint32 spoolss_size_processor_info_1(PRINTPROCESSOR_1 *info)
+uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info)
{
int size=0;
- size+=size_of_relative_string( &(info->name) );
+ size+=size_of_relative_string( &info->name );
- return (size);
+ return size;
- return True;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
-static uint32 spoolss_size_monitor_info_1(PRINTMONITOR_1 *info)
+uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
{
int size=0;
- size+=size_of_relative_string( &(info->name) );
-
- return (size);
+ size+=size_of_relative_string( &info->name);
+ size+=size_of_relative_string( &info->environment);
+ size+=size_of_relative_string( &info->dll_name);
- return True;
+ return size;
}
/*******************************************************************
* make a structure.
********************************************************************/
+/*
static BOOL make_spoolss_buffer(BUFFER* buffer, uint32 size)
{
buffer->ptr = (size != 0) ? 1 : 0;
@@ -2069,6 +2462,7 @@ static BOOL make_spoolss_buffer(BUFFER* buffer, uint32 size)
return (buffer->data != NULL || size == 0);
}
+*/
/*******************************************************************
* read a uint8 buffer of size *size.
@@ -2358,8 +2752,8 @@ BOOL make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u,
init_unistr2(&q_u->servername, servername, len_name);
q_u->level = level;
- make_spoolss_buffer(&q_u->buffer, size);
- q_u->buf_size = size;
+ /*make_spoolss_buffer(&q_u->buffer, size);*/
+/* q_u->buf_size = size;*/
return True;
}
@@ -2371,195 +2765,63 @@ BOOL make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u,
BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u,
prs_struct *ps, int depth)
{
- uint32 useless_ptr = 0x01;
prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
depth++;
- prs_align(ps);
-
- prs_uint32("flags", ps, depth, &(q_u->flags));
- prs_uint32("useless ptr", ps, depth, &useless_ptr);
+ if (!prs_align(ps))
+ return False;
- smb_io_unistr2("", &q_u->servername,True,ps,depth);
- prs_align(ps);
+ if (!prs_uint32("flags", ps, depth, &q_u->flags))
+ return False;
+ if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
+ return False;
- prs_uint32("level", ps, depth, &(q_u->level));
+ if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("level", ps, depth, &q_u->level))
+ return False;
- spoolss_io_read_buffer("buffer", ps, depth, &(q_u->buffer));
+ if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ return False;
- prs_uint32("buf_size", ps, depth, &q_u->buf_size);
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("offered", ps, depth, &q_u->offered))
+ return False;
return True;
}
-/****************************************************************************
-****************************************************************************/
-void free_r_enumprinters(SPOOL_R_ENUMPRINTERS *r_u)
-{
- DEBUG(4,("free_enum_printers_info: [%d] structs to free at level [%d]\n", r_u->returned, r_u->level));
- switch (r_u->level)
- {
- case 1:
- {
- free_print1_array(r_u->returned, r_u->ctr.printer.printers_1);
- break;
- }
- case 2:
- {
- free_print2_array(r_u->returned, r_u->ctr.printer.printers_2);
- break;
- }
- }
-}
-
/*******************************************************************
- * write a structure.
- * called from spoolss_r_enum_printers (srv_spoolss.c)
- *
+ Parse a SPOOL_R_ENUMPRINTERS structure.
********************************************************************/
-BOOL spoolss_io_r_enumprinters(char *desc,
- SPOOL_R_ENUMPRINTERS *r_u,
- prs_struct *ps, int depth)
-{
- uint32 useless_ptr=0xADDE0FF0;
- int i;
- uint32 start_offset, end_offset, beginning;
- uint32 bufsize_required=0;
- uint32 tmp_ct = 0;
-
- PRINTER_INFO_1 *info1;
- PRINTER_INFO_2 *info2;
- fstring tmp;
-
- slprintf(tmp, sizeof(tmp)-1, "spoolss_io_r_enumprinters %d", r_u->level);
-
- prs_debug(ps, depth, desc, tmp);
+BOOL new_spoolss_io_r_enumprinters(char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "new_spoolss_io_r_enumprinters");
depth++;
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
- if (!ps->io)
- {
- /* writing */
- for(i=0;i<r_u->returned;i++)
- {
- switch (r_u->level)
- {
- case 1:
- info1 = r_u->ctr.printer.printers_1[i];
- bufsize_required += spoolss_size_printer_info_1(info1);
- break;
- case 2:
- info2 = r_u->ctr.printer.printers_2[i];
- bufsize_required += spoolss_size_printer_info_2(info2);
- break;
- }
- }
-
- DEBUG(4,("spoolss_io_r_enumprinters, size needed: %d\n",bufsize_required));
- DEBUG(4,("spoolss_io_r_enumprinters, size offered: %d\n",r_u->offered));
-
- if (r_u->offered<bufsize_required)
- {
- /*
- * so the buffer is too small to handle datas
- * reply the minimum size required in the status
- * make the buffer equal 0
- * and reply no printers in buffer
- */
- r_u->status=ERROR_INSUFFICIENT_BUFFER;
- r_u->offered=0;
- /*r_u->returned=0;*/
-
- DEBUG(4,("spoolss_io_r_enumprinters, buffer too small\n"));
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- prs_uint32("size of buffer needed", ps, depth, &(bufsize_required));
- prs_uint32("count", ps, depth, &(r_u->returned));
- prs_uint32("status", ps, depth, &(r_u->status));
- return False;
- }
+ if (!prs_align(ps))
+ return False;
- DEBUG(4,("spoolss_io_r_enumprinters, buffer large enough\n"));
- }
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
-
- /* have to skip to end of buffer when reading, and have to record
- * size of buffer when writing. *shudder*.
- */
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
- beginning = prs_offset(ps);
- start_offset = prs_offset(ps);
- end_offset = start_offset + r_u->offered;
+ if (!prs_align(ps))
+ return False;
- if (ps->io)
- {
- /* reading */
- prs_set_offset(ps, beginning + r_u->offered);
-
- prs_align(ps);
- prs_uint32("buffer size", ps, depth, &(bufsize_required));
- prs_uint32("count", ps, depth, &(r_u->returned));
-
- prs_set_offset(ps, beginning);
- }
-
- for(i=0;i<r_u->returned;i++)
- {
-
- switch (r_u->level)
- {
- case 1:
- {
- if (ps->io)
- {
- /* reading */
-/* r_u->ctr.printer.printers_1[i] = add_print1_to_array(&tmp_ct, &r_u->ctr.printer.printers_1, NULL);*/
- }
- info1 = r_u->ctr.printer.printers_1[i];
- if (info1 == NULL)
- {
- return False;
- }
- smb_io_printer_info_1(desc, info1, ps, depth,
- &start_offset, &end_offset);
- break;
- }
- case 2:
- {
- if (ps->io)
- {
- /* reading */
-/*
- r_u->ctr.printer.printers_2[i] = add_print2_to_array(&tmp_ct, &r_u->ctr.printer.printers_2, NULL);
-*/ }
- info2 = r_u->ctr.printer.printers_2[i];
- if (info2 == NULL)
- {
- return False;
- }
- smb_io_printer_info_2(desc, info2, ps, depth,
- &start_offset, &end_offset);
- break;
- }
- }
- }
-
- prs_set_offset(ps, beginning + r_u->offered);
- prs_align(ps);
-
- prs_uint32("buffer size", ps, depth, &(bufsize_required));
- prs_uint32("count", ps, depth, &(r_u->returned));
- prs_uint32("status", ps, depth, &(r_u->status));
-
- if (!ps->io)
- {
- /* writing */
- free_r_enumprinters(r_u);
- }
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if (!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
- return True;
+ return True;
}
/*******************************************************************
@@ -2663,12 +2925,14 @@ BOOL spoolss_io_r_getprinter(char *desc,
{
PRINTER_INFO_1 *info;
info = r_u->ctr.printer.info1;
+ /*
smb_io_printer_info_1(desc,
info,
ps,
depth,
&start_offset,
&end_offset);
+ */
if (!ps->io)
{
/* writing */
@@ -2680,12 +2944,14 @@ BOOL spoolss_io_r_getprinter(char *desc,
{
PRINTER_INFO_2 *info;
info = r_u->ctr.printer.info2;
+ /*
smb_io_printer_info_2(desc,
info,
ps,
depth,
&start_offset,
&end_offset);
+ */
if (!ps->io)
{
/* writing */
@@ -2901,191 +3167,35 @@ BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int de
return True;
}
-/****************************************************************************
-****************************************************************************/
-void free_job_info_ctr(JOB_INFO_CTR *ctr, uint32 level, uint32 numofjobs)
-{
- DEBUG(4,("free_enum_jobs_info: [%d] structs to free at level [%d]\n",
- numofjobs, level));
- switch (level)
- {
- case 1:
- {
- free_job1_array(numofjobs,
- ctr->job.job_info_1);
- break;
- }
- case 2:
- {
- free_job2_array(numofjobs,
- ctr->job.job_info_2);
- break;
- }
- }
-}
-
-/****************************************************************************
-****************************************************************************/
-void free_r_enumjobs(SPOOL_R_ENUMJOBS *r_u)
-{
- free_job_info_ctr(&r_u->ctr, r_u->level, r_u->numofjobs);
-}
-
/*******************************************************************
********************************************************************/
BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
{
- uint32 useless_ptr = 0;
- uint32 start_offset, end_offset, beginning;
- uint32 bufsize_required=0;
- uint32 tmp_ct = 0;
- int i;
-
prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
depth++;
- prs_align(ps);
-
- if (!ps->io)
- {
- /* writing */
- switch (r_u->level)
- {
- case 1:
- {
- for (i=0; i<r_u->numofjobs; i++)
- {
- JOB_INFO_1 *info;
- info=r_u->ctr.job.job_info_1[i];
- bufsize_required += spoolss_size_job_info_1(&(info[i]));
- }
- break;
- }
- case 2:
- {
- for (i=0; i<r_u->numofjobs; i++)
- {
- JOB_INFO_2 *info;
- info=r_u->ctr.job.job_info_2[i];
-
- bufsize_required += spoolss_size_job_info_2(&(info[i]));
- }
- break;
- }
- }
-
- DEBUG(4,("spoolss_io_r_enumjobs, size needed: %d\n",
- bufsize_required));
- DEBUG(4,("spoolss_io_r_enumjobs, size offered: %d\n",
- r_u->offered));
-
- /* check if the buffer is big enough for the datas */
- if (r_u->offered<bufsize_required)
- {
- /* it's too small */
- r_u->status = ERROR_INSUFFICIENT_BUFFER; /* say so */
- r_u->offered = bufsize_required;
- useless_ptr = 0;
-
- DEBUG(4,("spoolss_io_r_enumjobs, buffer too small\n"));
-
- }
- else
- {
- useless_ptr = 1;
- }
- }
-
- prs_uint32("pointer", ps, depth, &useless_ptr);
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
-
- if (useless_ptr != 0)
- {
- beginning=prs_offset(ps);
- start_offset=prs_offset(ps);
- end_offset=start_offset+r_u->offered;
+ if (!prs_align(ps))
+ return False;
- tmp_ct = 0;
-
- if (ps->io)
- {
- /* reading */
- prs_set_offset(ps, beginning + r_u->offered);
-
- prs_align(ps);
- prs_uint32("buffer size", ps, depth, &(bufsize_required));
- prs_uint32("numofjobs", ps, depth, &(r_u->numofjobs));
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
- prs_set_offset(ps, beginning);
- }
+ if (!prs_align(ps))
+ return False;
- switch (r_u->level)
- {
- case 1:
- {
- JOB_INFO_1 *info;
- for (i=0; i<r_u->numofjobs; i++)
- {
- if (ps->io)
- {
- /* reading */
-/* r_u->ctr.job.job_info_1[i] = add_job1_to_array(&tmp_ct, &r_u->ctr.job.job_info_1, NULL);*/
- }
- info = r_u->ctr.job.job_info_1[i];
- smb_io_job_info_1(desc,
- info,
- ps,
- depth,
- &start_offset,
- &end_offset);
- }
- break;
- }
- case 2:
- {
- JOB_INFO_2 *info;
- for (i=0; i<r_u->numofjobs; i++)
- {
- if (ps->io)
- {
- /* reading */
-/* r_u->ctr.job.job_info_2[i] = add_job2_to_array(&tmp_ct, &r_u->ctr.job.job_info_2, NULL);*/
- }
- info = r_u->ctr.job.job_info_2[i];
- smb_io_job_info_2(desc,
- info,
- ps,
- depth,
- &start_offset,
- &end_offset);
- }
- break;
- }
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
- }
- prs_set_offset(ps, beginning+r_u->offered);
- prs_align(ps);
+ if (!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
- /*
- * if the buffer was too small, send the minimum required size
- * if it was too large, send the real needed size
- */
-
- prs_uint32("buffer size", ps, depth, &(bufsize_required));
- }
-
- prs_uint32("numofjobs", ps, depth, &(r_u->numofjobs));
- prs_uint32("status", ps, depth, &(r_u->status));
-
- if (!ps->io)
- {
- /* writing */
- free_r_enumjobs(r_u);
- }
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
- return True;
+ return True;
}
+
/*******************************************************************
********************************************************************/
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
@@ -3102,13 +3212,13 @@ BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
q_u->firstjob = firstjob;
q_u->numofjobs = numofjobs;
q_u->level = level;
-
+/*
if (!make_spoolss_buffer(&q_u->buffer, buf_size))
{
return False;
}
q_u->buf_size = buf_size;
-
+*/
return True;
}
@@ -3119,16 +3229,24 @@ BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, in
prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
depth++;
- prs_align(ps);
+ if (!prs_align(ps))
+ return False;
- smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth);
- prs_uint32("firstjob", ps, depth, &(q_u->firstjob));
- prs_uint32("numofjobs", ps, depth, &(q_u->numofjobs));
- prs_uint32("level", ps, depth, &(q_u->level));
-
- spoolss_io_read_buffer("", ps, depth, &(q_u->buffer));
+ if (!smb_io_prt_hnd("printer handle",&q_u->handle, ps, depth))
+ return False;
+
+ if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
+ return False;
+ if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
+ return False;
+ if (!prs_uint32("level", ps, depth, &q_u->level))
+ return False;
- prs_uint32("buf_size", ps, depth, &(q_u->buf_size));
+ if (!new_spoolss_io_buffer("", ps, depth, q_u->buffer))
+ return False;
+
+ if (!prs_uint32("offered", ps, depth, &q_u->offered))
+ return False;
return True;
}
@@ -3198,199 +3316,72 @@ BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int de
}
/*******************************************************************
+ Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
********************************************************************/
-BOOL spoolss_io_r_enumdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
-{
- uint32 useless_ptr=0xADDE0FF0;
- uint32 start_offset, end_offset, beginning;
- uint32 bufsize_required=0;
- int i;
-
- prs_debug(ps, depth, desc, "spoolss_io_r_enumdrivers");
+BOOL new_spoolss_io_r_enumprinterdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "new_spoolss_io_r_enumprinterdrivers");
depth++;
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
-
- DEBUG(7,("Level [%d], number [%d]\n", r_u->level, r_u->numofdrivers));
- switch (r_u->level)
- {
- case 1:
- {
- DRIVER_INFO_1 *driver_info_1;
- driver_info_1=r_u->ctr.driver.info1;
-
- for (i=0; i<r_u->numofdrivers; i++)
- {
- bufsize_required += spoolss_size_printer_driver_info_1(&(driver_info_1[i]));
- }
- break;
- }
- case 2:
- {
- DRIVER_INFO_2 *driver_info_2;
- driver_info_2=r_u->ctr.driver.info2;
-
- for (i=0; i<r_u->numofdrivers; i++)
- {
- bufsize_required += spoolss_size_printer_driver_info_2(&(driver_info_2[i]));
- }
- break;
- }
- case 3:
- {
- DRIVER_INFO_3 *driver_info_3;
- driver_info_3=r_u->ctr.driver.info3;
-
- for (i=0; i<r_u->numofdrivers; i++)
- {
- bufsize_required += spoolss_size_printer_driver_info_3(&(driver_info_3[i]));
- }
- break;
- }
- }
-
- DEBUGADD(7,("size needed: %d\n",bufsize_required));
- DEBUGADD(7,("size offered: %d\n",r_u->offered));
-
- /* check if the buffer is big enough for the datas */
-
- if (r_u->offered<bufsize_required)
- {
-
- /* it's too small */
- r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */
- r_u->offered=0; /* don't send back the buffer */
- DEBUGADD(8,("buffer too small\n"));
+ if (!prs_align(ps))
+ return False;
+
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- }
- else
- {
- DEBUGADD(8,("buffer large enough\n"));
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- beginning=prs_offset(ps);
- start_offset=prs_offset(ps);
- end_offset=start_offset+r_u->offered;
+ if (!prs_align(ps))
+ return False;
- switch (r_u->level)
- {
- case 1:
- {
- DRIVER_INFO_1 *info;
- for (i=0; i<r_u->numofdrivers; i++)
- {
- info = &(r_u->ctr.driver.info1[i]);
- smb_io_printer_driver_info_1(desc, info, ps, depth, &start_offset, &end_offset);
- }
- break;
- }
- case 2:
- {
- DRIVER_INFO_2 *info;
- for (i=0; i<r_u->numofdrivers; i++)
- {
- info = &(r_u->ctr.driver.info2[i]);
- smb_io_printer_driver_info_2(desc, info, ps, depth, &start_offset, &end_offset);
- }
- break;
- }
- case 3:
- {
- DRIVER_INFO_3 *info;
- for (i=0; i<r_u->numofdrivers; i++)
- {
- info = &(r_u->ctr.driver.info3[i]);
- smb_io_printer_driver_info_3(desc, info, ps, depth, &start_offset, &end_offset);
- }
- break;
- }
- }
- prs_set_offset(ps, beginning+r_u->offered);
- prs_align(ps);
- }
-
- /*
- * if the buffer was too small, send the minimum required size
- * if it was too large, send the real needed size
- */
-
- prs_uint32("size of buffer needed", ps, depth, &(bufsize_required));
- prs_uint32("numofdrivers", ps, depth, &(r_u->numofdrivers));
- prs_uint32("status", ps, depth, &(r_u->status));
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if (!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
- return True;
+ return True;
}
-void free_spoolss_r_enumdrivers(SPOOL_R_ENUMPRINTERDRIVERS *r_u)
-{
- switch (r_u->level)
- {
- case 1:
- {
- DRIVER_INFO_1 *driver_info_1;
- driver_info_1=r_u->ctr.driver.info1;
-
- free(driver_info_1);
- break;
- }
- case 2:
- {
- DRIVER_INFO_2 *driver_info_2;
- driver_info_2=r_u->ctr.driver.info2;
-
- free(driver_info_2);
- break;
- }
- case 3:
- {
- DRIVER_INFO_3 *driver_info_3;
-
- UNISTR **dependentfiles;
- int i;
-
- driver_info_3=r_u->ctr.driver.info3;
-
- for (i=0; i<r_u->numofdrivers; i++)
- {
- int j=0;
- dependentfiles=(driver_info_3[i]).dependentfiles;
- while ( dependentfiles[j] != NULL )
- {
- free(dependentfiles[j]);
- j++;
- }
-
- free(dependentfiles);
- }
- free(driver_info_3);
- break;
- }
- }
-}
-
/*******************************************************************
+ Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
********************************************************************/
BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
{
- uint32 useless_ptr=0xADDE0FF0;
- prs_debug(ps, depth, desc, "");
+ prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
depth++;
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
- smb_io_unistr2("", &(q_u->name),True,ps,depth);
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
- smb_io_unistr2("", &(q_u->environment),True,ps,depth);
- prs_align(ps);
- prs_uint32("level", ps, depth, &(q_u->level));
- spoolss_io_read_buffer("", ps, depth, &(q_u->buffer));
- prs_align(ps);
- prs_uint32("buf_size", ps, depth, &(q_u->buf_size));
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
+ return False;
+ if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+ if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
+ return False;
+ if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, 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;
}
@@ -3451,114 +3442,61 @@ BOOL new_spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *
}
/*******************************************************************
+ Parse a SPOOL_R_ENUMPORTS structure.
********************************************************************/
-BOOL spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
-{
- uint32 useless_ptr=0xADDE0FF0;
- uint32 start_offset, end_offset, beginning;
- uint32 bufsize_required=0;
- int i;
-
- prs_debug(ps, depth, desc, "spoolss_io_r_enumports");
+BOOL new_spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "new_spoolss_io_r_enumports");
depth++;
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
- switch (r_u->level)
- {
- case 2:
- {
- PORT_INFO_2 *port_2;
- port_2=r_u->ctr.port.info_2;
-
- for (i=0; i<r_u->numofports; i++)
- {
- bufsize_required += spoolss_size_port_info_2(&(port_2[i]));
- }
- break;
- }
- }
-
- DEBUG(4,("size needed: %d\n",bufsize_required));
- DEBUG(4,("size offered: %d\n",r_u->offered));
-
- /* check if the buffer is big enough for the datas */
- if (r_u->offered<bufsize_required)
- {
-
- /* it's too small */
- r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */
- r_u->offered=0; /* don't send back the buffer */
+ if (!prs_align(ps))
+ return False;
- DEBUG(4,("buffer too small\n"));
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- }
- else
- {
- DEBUG(4,("buffer large enough\n"));
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- beginning=prs_offset(ps);
- start_offset=prs_offset(ps);
- end_offset=start_offset+r_u->offered;
+ if (!prs_align(ps))
+ return False;
- switch (r_u->level)
- {
- case 2:
- {
- PORT_INFO_2 *info;
- for (i=0; i<r_u->numofports; i++)
- {
- info = &(r_u->ctr.port.info_2[i]);
- smb_io_port_2(desc, info, ps, depth, &start_offset, &end_offset);
- }
- break;
- }
- }
- prs_set_offset(ps, beginning+r_u->offered);
- prs_align(ps);
- }
-
- /*
- * if the buffer was too small, send the minimum required size
- * if it was too large, send the real needed size
- */
-
- prs_uint32("size of buffer needed", ps, depth, &(bufsize_required));
- prs_uint32("numofports", ps, depth, &(r_u->numofports));
- prs_uint32("status", ps, depth, &(r_u->status));
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if (!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
- return True;
+ return True;
}
-void spoolss_free_r_enumports(SPOOL_R_ENUMPORTS *r_u)
-{
- switch (r_u->level)
- {
- case 2:
- {
- safe_free(r_u->ctr.port.info_2);
- break;
- }
- }
-}
/*******************************************************************
********************************************************************/
BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth)
{
- uint32 useless;
prs_debug(ps, depth, desc, "");
depth++;
- prs_align(ps);
- prs_uint32("useless", ps, depth, &useless);
- smb_io_unistr2("", &(q_u->name),True,ps,depth);
- prs_align(ps);
- prs_uint32("level", ps, depth, &(q_u->level));
- spoolss_io_read_buffer("", ps, depth, &(q_u->buffer));
- prs_align(ps);
- prs_uint32("buf_size", ps, depth, &(q_u->buf_size));
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("", ps, depth, &q_u->name_ptr))
+ return False;
+ if (!smb_io_unistr2("", &q_u->name,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;
}
@@ -4110,82 +4048,28 @@ BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q
********************************************************************/
BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
{
- uint32 useless_ptr=0xADDE0FF0;
- uint32 start_offset, end_offset, beginning;
- uint32 bufsize_required=0;
- int i;
-
prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors");
depth++;
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
- switch (r_u->level)
- {
- case 1:
- {
- PRINTPROCESSOR_1 *info_1;
- info_1=r_u->info_1;
-
- for (i=0; i<r_u->numofprintprocessors; i++)
- {
- bufsize_required += spoolss_size_processor_info_1(&(info_1[i]));
- }
- break;
- }
- }
-
- DEBUG(4,("size needed: %d\n",bufsize_required));
- DEBUG(4,("size offered: %d\n",r_u->offered));
-
- /* check if the buffer is big enough for the datas */
- if (r_u->offered<bufsize_required)
- {
-
- /* it's too small */
- r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */
- r_u->offered=0; /* don't send back the buffer */
+ if (!prs_align(ps))
+ return False;
- DEBUG(4,("buffer too small\n"));
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- }
- else
- {
- DEBUG(4,("buffer large enough\n"));
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- beginning=prs_offset(ps);
- start_offset=prs_offset(ps);
- end_offset=start_offset+r_u->offered;
+ if (!prs_align(ps))
+ return False;
- switch (r_u->level)
- {
- case 1:
- {
- PRINTPROCESSOR_1 *info_1;
- for (i=0; i<r_u->numofprintprocessors; i++)
- {
- info_1 = &(r_u->info_1[i]);
- smb_io_processor_info_1(desc, info_1, ps, depth, &start_offset, &end_offset);
- }
- break;
- }
- }
- prs_set_offset(ps, beginning+r_u->offered);
- prs_align(ps);
- }
-
- /*
- * if the buffer was too small, send the minimum required size
- * if it was too large, send the real needed size
- */
-
- prs_uint32("size of buffer needed", ps, depth, &(bufsize_required));
- prs_uint32("numofprintprocessors", ps, depth, &(r_u->numofprintprocessors));
- prs_uint32("status", ps, depth, &(r_u->status));
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if (!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
- return True;
+ return True;
}
/*******************************************************************
@@ -4196,121 +4080,100 @@ BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q
prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors");
depth++;
- prs_align(ps);
- prs_uint32("useless", ps, depth, &useless);
- smb_io_unistr2("", &(q_u->name),True,ps,depth);
- prs_align(ps);
- prs_uint32("useless", ps, depth, &useless);
- smb_io_unistr2("", &(q_u->environment),True,ps,depth);
- prs_align(ps);
- prs_uint32("level", ps, depth, &(q_u->level));
- spoolss_io_read_buffer("", ps, depth, &(q_u->buffer));
- prs_align(ps);
- prs_uint32("buf_size", ps, depth, &(q_u->buf_size));
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
+ return False;
+ if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
+ return False;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("", ps, depth, &q_u->environment_ptr))
+ return False;
+ if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, 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;
}
/*******************************************************************
+ Parse a SPOOL_Q_ENUMPRINTMONITORS structure.
********************************************************************/
-BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
-{
- uint32 useless_ptr=0xADDE0FF0;
- uint32 start_offset, end_offset, beginning;
- uint32 bufsize_required=0;
- int i;
-
- prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
+BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
depth++;
- prs_align(ps);
- prs_uint32("pointer", ps, depth, &useless_ptr);
- switch (r_u->level)
- {
- case 1:
- {
- PRINTMONITOR_1 *info_1;
- info_1=r_u->info_1;
-
- for (i=0; i<r_u->numofprintmonitors; i++)
- {
- bufsize_required += spoolss_size_monitor_info_1(&(info_1[i]));
- }
- break;
- }
- }
-
- DEBUG(4,("size needed: %d\n",bufsize_required));
- DEBUG(4,("size offered: %d\n",r_u->offered));
-
- /* check if the buffer is big enough for the datas */
- if (r_u->offered<bufsize_required)
- {
-
- /* it's too small */
- r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */
- r_u->offered=0; /* don't send back the buffer */
+ if (!prs_align(ps))
+ return False;
- DEBUG(4,("buffer too small\n"));
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- }
- else
- {
- DEBUG(4,("buffer large enough\n"));
-
- prs_uint32("size of buffer", ps, depth, &(r_u->offered));
- beginning=prs_offset(ps);
- start_offset=prs_offset(ps);
- end_offset=start_offset+r_u->offered;
+ if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
+ return False;
+ if (!smb_io_unistr2("name", &q_u->name, True, ps, depth))
+ return False;
- switch (r_u->level)
- {
- case 1:
- {
- PRINTMONITOR_1 *info_1;
- for (i=0; i<r_u->numofprintmonitors; i++)
- {
- info_1 = &(r_u->info_1[i]);
- smb_io_monitor_info_1(desc, info_1, ps, depth, &start_offset, &end_offset);
- }
- break;
- }
- }
- prs_set_offset(ps, beginning+r_u->offered);
- prs_align(ps);
- }
-
- /*
- * if the buffer was too small, send the minimum required size
- * if it was too large, send the real needed size
- */
-
- prs_uint32("size of buffer needed", ps, depth, &(bufsize_required));
- prs_uint32("numofprintmonitors", ps, depth, &(r_u->numofprintmonitors));
- prs_uint32("status", ps, depth, &(r_u->status));
+ 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 spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth)
-{
- uint32 useless;
- prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors");
+BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors");
depth++;
- prs_align(ps);
- prs_uint32("useless", ps, depth, &useless);
- smb_io_unistr2("", &(q_u->name),True,ps,depth);
- prs_align(ps);
- prs_uint32("level", ps, depth, &(q_u->level));
- spoolss_io_read_buffer("", ps, depth, &(q_u->buffer));
- prs_align(ps);
- prs_uint32("buf_size", ps, depth, &(q_u->buf_size));
+ if (!prs_align(ps))
+ return False;
+
+ if (!new_spoolss_io_buffer("", ps, depth, r_u->buffer))
+ return False;
- return True;
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("needed", ps, depth, &r_u->needed))
+ return False;
+
+ if (!prs_uint32("returned", ps, depth, &r_u->returned))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
}
/*******************************************************************
diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c
index 2cebc8148b..6e8b306760 100644
--- a/source3/rpc_server/srv_pipe_srv.c
+++ b/source3/rpc_server/srv_pipe_srv.c
@@ -796,7 +796,7 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_
* Create the header, now we know the length.
*/
- init_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST,
+ init_rpc_hdr(&p->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST,
p->hdr.call_id,
RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth),
auth_len);
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index 60333e1f3b..50b6dd3846 100755
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -107,10 +107,18 @@ static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct *
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_closeprinter("", &q_u, data, 0);
+ if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_closeprinter(&q_u.handle);
memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
- spoolss_io_r_closeprinter("",&r_u,rdata,0);
+
+ if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n"));
+ return False;
+ }
}
/********************************************************************
@@ -125,12 +133,19 @@ static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_rffpcnex("", &q_u, data, 0);
+ if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n"));
+ return False;
+ }
r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags,
q_u.options, &q_u.localmachine,
q_u.printerlocal, &q_u.option);
- spoolss_io_r_rffpcnex("",&r_u,rdata,0);
+
+ if (!spoolss_io_r_rffpcnex("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n"));
+ return False;
+ }
}
@@ -148,11 +163,18 @@ static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_rfnpcnex("", &q_u, data, 0);
+ if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n"));
+ return False;
+ }
r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change,
&q_u.option, &r_u.count, &r_u.info);
- spoolss_io_r_rfnpcnex("", &r_u, rdata, 0);
+
+ if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
+ return False;
+ }
}
@@ -169,32 +191,33 @@ static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct *
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_enumprinters("", &q_u, data, 0);
+ DEBUG(5,("api_spoolss_enumprinters\n"));
- /* lkclXXX DAMN DAMN DAMN! MICROSOFT @#$%S IT UP, AGAIN, AND WE
- HAVE TO DEAL WITH IT! AGH!
- */
- r_u.level = q_u.level;
- r_u.status = _spoolss_enumprinters(
- q_u.flags,
- &q_u.servername,
- q_u.level,
- &q_u.buffer,
- q_u.buf_size,
- &r_u.offered,
- &r_u.needed,
- &r_u.ctr,
- &r_u.returned);
+ new_spoolss_allocate_buffer(&q_u.buffer);
+
+ if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
+
+ r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level,
+ r_u.buffer, q_u.offered,
+ &r_u.needed, &r_u.returned);
- memcpy(r_u.servername.buffer,q_u.servername.buffer,
- 2*q_u.servername.uni_str_len);
- r_u.servername.buffer[q_u.servername.uni_str_len] = 0;
+ if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
+ DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
- spoolss_io_free_buffer(&(q_u.buffer));
- spoolss_io_r_enumprinters("",&r_u,rdata,0);
+ new_spoolss_free_buffer(q_u.buffer);
+
+ return True;
}
-
/********************************************************************
* api_spoolss_getprinter
* called from the spoolss dispatcher
@@ -208,7 +231,10 @@ static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rd
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_getprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
+ return False;
+ }
r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level,
&r_u.ctr, &q_u.offered, &r_u.needed);
@@ -218,7 +244,12 @@ static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rd
r_u.level = q_u.level;
safe_free(q_u.buffer);
- spoolss_io_r_getprinter("",&r_u,rdata,0);
+ if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
@@ -235,7 +266,10 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_getprinterdriver2("", &q_u, data, 0);
+ if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
+ return False;
+ }
r_u.status = _spoolss_getprinterdriver2(&q_u.handle,
&q_u.architecture, q_u.level,
@@ -246,7 +280,12 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str
r_u.level = q_u.level;
spoolss_io_free_buffer(&(q_u.buffer));
- spoolss_io_r_getprinterdriver2("",&r_u,rdata,0);
+ if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
+ return False;
+ }
+
+ return True;
}
/********************************************************************
@@ -262,9 +301,19 @@ static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_stru
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_startpageprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_startpageprinter(&q_u.handle);
- spoolss_io_r_startpageprinter("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
@@ -281,9 +330,19 @@ static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_endpageprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_endpageprinter(&q_u.handle);
- spoolss_io_r_endpageprinter("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
/********************************************************************
@@ -299,12 +358,22 @@ static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struc
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_startdocprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_startdocprinter(&q_u.handle,
q_u.doc_info_container.level,
&q_u.doc_info_container.docinfo,
&r_u.jobid);
- spoolss_io_r_startdocprinter("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
/********************************************************************
@@ -320,9 +389,19 @@ static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_enddocprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_enddocprinter(&q_u.handle);
- spoolss_io_r_enddocprinter("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
@@ -339,14 +418,24 @@ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct *
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_writeprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_writeprinter(&q_u.handle,
q_u.buffer_size,
q_u.buffer,
&q_u.buffer_size2);
r_u.buffer_written = q_u.buffer_size2;
safe_free(q_u.buffer);
- spoolss_io_r_writeprinter("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -359,7 +448,11 @@ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rd
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_setprinter("", &q_u, data, 0);
+ if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
+ return False;
+ }
+
DEBUG(0,("api_spoolss_setprinter: typecast sec_des to uint8*!\n"));
r_u.status = _spoolss_setprinter(&q_u.handle,
q_u.level, &q_u.info,
@@ -367,7 +460,13 @@ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rd
q_u.security.size_of_buffer,
(const uint8*)q_u.security.data,
q_u.command);
- spoolss_io_r_setprinter("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -380,9 +479,19 @@ static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata)
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_fcpn("", &q_u, data, 0);
+ if(!spoolss_io_q_fcpn("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_fcpn(&q_u.handle);
- spoolss_io_r_fcpn("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n"));
+ return False;
+ }
+
+ return True;
}
@@ -396,13 +505,22 @@ static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_addjob("", &q_u, data, 0);
+ if(!spoolss_io_q_addjob("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n"));
+ return False;
+ }
r_u.status = _spoolss_addjob(&q_u.handle, q_u.level,
&q_u.buffer, q_u.buf_size);
spoolss_io_free_buffer(&(q_u.buffer));
- spoolss_io_r_addjob("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_addjob("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n"));
+ return False;
+ }
+
+ return True;
}
@@ -415,15 +533,30 @@ static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdat
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
+
+ new_spoolss_allocate_buffer(&q_u.buffer);
+
+ if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
+
+ r_u.status = _spoolss_enumjobs(&q_u.handle, q_u.firstjob, q_u.numofjobs, q_u.level,
+ r_u.buffer, q_u.offered,
+ &r_u.needed, &r_u.returned);
+
+ if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
+
+ new_spoolss_free_buffer(q_u.buffer);
- spoolss_io_q_enumjobs("", &q_u, data, 0);
- r_u.offered = q_u.buf_size;
- r_u.level = q_u.level;
- r_u.status = _spoolss_enumjobs(&q_u.handle,
- q_u.firstjob, q_u.numofjobs, q_u.level,
- &r_u.ctr, &r_u.offered, &r_u.numofjobs);
- spoolss_io_free_buffer(&(q_u.buffer));
- spoolss_io_r_enumjobs("",&r_u,rdata,0);
+ return True;
}
@@ -437,9 +570,19 @@ static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *r
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_schedulejob("", &q_u, data, 0);
+ if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid);
- spoolss_io_r_schedulejob("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -452,10 +595,20 @@ static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_setjob("", &q_u, data, 0);
+ if(!spoolss_io_q_setjob("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid,
q_u.level, &q_u.ctr, q_u.command);
- spoolss_io_r_setjob("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_setjob("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -468,18 +621,30 @@ static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_st
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
-
- spoolss_io_q_enumprinterdrivers("", &q_u, data, 0);
- r_u.offered = q_u.buf_size;
- r_u.level = q_u.level;
- r_u.status = _spoolss_enumprinterdrivers(&q_u.name,
- &q_u.environment, q_u. level,
- &r_u.ctr, &r_u.offered, &r_u.numofdrivers);
+ new_spoolss_allocate_buffer(&q_u.buffer);
- spoolss_io_free_buffer(&q_u.buffer);
- spoolss_io_r_enumdrivers("",&r_u,rdata,0);
- free_spoolss_r_enumdrivers(&r_u);
+ if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
+
+ r_u.status = _spoolss_enumprinterdrivers(&q_u.name, &q_u.environment, q_u.level,
+ r_u.buffer, q_u.offered,
+ &r_u.needed, &r_u.returned);
+
+ if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
+ DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
+
+ new_spoolss_free_buffer(q_u.buffer);
+
+ return True;
}
@@ -493,12 +658,12 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- DEBUG(5,("spoolss_io_q_enumforms\n"));
-
new_spoolss_allocate_buffer(&q_u.buffer);
- if (!spoolss_io_q_enumforms("", &q_u, data, 0))
+ if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
return False;
+ }
/* that's an [in out] buffer */
new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
@@ -508,6 +673,7 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda
&r_u.needed, &r_u.numofforms);
if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) {
+ DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
new_spoolss_free_buffer(q_u.buffer);
return False;
}
@@ -527,20 +693,30 @@ static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rda
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
-
- spoolss_io_q_enumports("", &q_u, data, 0);
- r_u.offered = q_u.buf_size;
- r_u.level = q_u.level;
- r_u.status = _spoolss_enumports(&q_u.name,
- q_u.level,
- &r_u.ctr,
- &r_u.offered,
- &r_u.numofports);
+ new_spoolss_allocate_buffer(&q_u.buffer);
+
+ if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
- spoolss_io_free_buffer(&(q_u.buffer));
- spoolss_io_r_enumports("",&r_u,rdata,0);
- spoolss_free_r_enumports(&r_u);
+ r_u.status = _spoolss_enumports(&q_u.name, q_u.level,
+ r_u.buffer, q_u.offered,
+ &r_u.needed, &r_u.returned);
+
+ if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) {
+ DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
+
+ new_spoolss_free_buffer(q_u.buffer);
+
+ return True;
}
@@ -554,13 +730,23 @@ static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct *
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_addprinterex("", &q_u, data, 0);
+ if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_addprinterex(&q_u.server_name,
q_u.level, &q_u.info,
q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3,
q_u.user_level, &q_u.user,
&r_u.handle);
- spoolss_io_r_addprinterex("", &r_u, rdata, 0);
+
+ if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -573,10 +759,20 @@ static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_stru
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_addprinterdriver("", &q_u, data, 0);
+ if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_addprinterdriver(&q_u.server_name,
q_u.level, &q_u.info);
- spoolss_io_r_addprinterdriver("", &r_u, rdata, 0);
+
+ if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -586,7 +782,10 @@ static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data,
SPOOL_Q_GETPRINTERDRIVERDIR q_u;
SPOOL_R_GETPRINTERDRIVERDIR r_u;
- spoolss_io_q_getprinterdriverdir("", &q_u, data, 0);
+ if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
+ return False;
+ }
r_u.offered = q_u.buf_size;
r_u.level = q_u.level;
@@ -596,7 +795,13 @@ static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data,
&r_u.ctr,
&r_u.offered);
spoolss_io_free_buffer(&q_u.buffer);
- spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0);
+
+ if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -609,7 +814,11 @@ static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struc
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_enumprinterdata("", &q_u, data, 0);
+ if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n"));
+ return False;
+ }
+
r_u.valuesize = q_u.valuesize;
r_u.datasize = q_u.datasize;
@@ -622,8 +831,15 @@ static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struc
&r_u.datasize,/* in out */
&r_u.data,/* out */
&r_u.realdatasize);/* out */
- spoolss_io_r_enumprinterdata("", &r_u, rdata, 0);
+
+ if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n"));
+ return False;
+ }
+
safe_free(r_u.data);
+
+ return True;
}
/****************************************************************************
@@ -636,12 +852,21 @@ static BOOL api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, prs_struct
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_setprinterdata("", &q_u, data, 0);
+ if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_setprinterdata(&q_u.handle,
&q_u.value, q_u.type, q_u.max_len,
q_u.data, q_u.real_len, q_u.numeric_data);
- spoolss_io_r_setprinterdata("", &r_u, rdata, 0);
- safe_free(q_u.data);
+
+ if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -654,9 +879,19 @@ static BOOL api_spoolss_addform(uint16 vuid, prs_struct *data, prs_struct *rdata
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_addform("", &q_u, data, 0);
+ if(!spoolss_io_q_addform("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form);
- spoolss_io_r_addform("", &r_u, rdata, 0);
+
+ if(!spoolss_io_r_addform("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -669,10 +904,20 @@ static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_setform("", &q_u, data, 0);
+ if(!spoolss_io_q_setform("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n"));
+ return False;
+ }
+
r_u.status = _spoolss_setform(&q_u.handle,
&q_u.name, q_u.level, &q_u.form);
- spoolss_io_r_setform("", &r_u, rdata, 0);
+
+ if(!spoolss_io_r_setform("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n"));
+ return False;
+ }
+
+ return True;
}
/****************************************************************************
@@ -685,18 +930,29 @@ static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_s
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_enumprintprocessors("", &q_u, data, 0);
- r_u.offered = q_u.buf_size;
- r_u.level = q_u.level;
- r_u.status = _spoolss_enumprintprocessors(&q_u.name,
- &q_u.environment,
- q_u.level,
- &r_u.info_1,
- &r_u.offered,
- &r_u.numofprintprocessors);
- spoolss_io_free_buffer(&q_u.buffer);
- spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0);
- safe_free(r_u.info_1);
+ new_spoolss_allocate_buffer(&q_u.buffer);
+
+ if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
+
+ r_u.status = _spoolss_enumprintprocessors(&q_u.name, &q_u.environment, q_u.level,
+ r_u.buffer, q_u.offered,
+ &r_u.needed, &r_u.returned);
+
+ if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
+
+ new_spoolss_free_buffer(q_u.buffer);
+
+ return True;
}
/****************************************************************************
@@ -709,17 +965,29 @@ static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_str
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
- spoolss_io_q_enumprintmonitors("", &q_u, data, 0);
- r_u.offered = q_u.buf_size;
- r_u.level = q_u.level;
- r_u.status = _spoolss_enumprintmonitors(&q_u.name,
- q_u.level,
- &r_u.info_1,
- &r_u.offered,
- &r_u.numofprintmonitors);
- spoolss_io_free_buffer(&q_u.buffer);
- spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0);
- safe_free(r_u.info_1);
+ new_spoolss_allocate_buffer(&q_u.buffer);
+
+ if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
+ return False;
+ }
+
+ /* that's an [in out] buffer */
+ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer);
+
+ r_u.status = _spoolss_enumprintmonitors(&q_u.name, q_u.level,
+ r_u.buffer, q_u.offered,
+ &r_u.needed, &r_u.returned);
+
+ if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
+ DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
+ new_spoolss_free_buffer(q_u.buffer);
+ return False;
+ }
+
+ new_spoolss_free_buffer(q_u.buffer);
+
+ return True;
}
/****************************************************************************
@@ -729,7 +997,10 @@ static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
SPOOL_Q_GETJOB q_u;
SPOOL_R_GETJOB r_u;
- spoolss_io_q_getjob("", &q_u, data, 0);
+ if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
+ return False;
+ }
r_u.offered = q_u.buf_size;
r_u.level = q_u.level;
@@ -739,8 +1010,15 @@ static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata)
&r_u.ctr,
&r_u.offered);
spoolss_io_free_buffer(&(q_u.buffer));
- spoolss_io_r_getjob("",&r_u,rdata,0);
+
+ if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
+ return False;
+ }
+
free_spoolss_r_getjob(&r_u);
+
+ return True;
}
/*******************************************************************
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index d25281cea5..2e80cbdbf6 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -200,11 +200,8 @@ static BOOL open_printer_hnd(POLICY_HND *hnd)
{
if (!Printer[i].open)
{
- Printer[i].open = True;
- Printer[i].ok = True;
-
+ Printer[i].open = True;
memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd));
-
DEBUG(4,("Opened printer handle[%x] ", i));
dump_data(4, hnd->data, sizeof(hnd->data));
return True;
@@ -221,32 +218,14 @@ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required)
{
int pnum = find_printer_index_by_hnd(hnd);
- if (OPEN_HANDLE(pnum)) {
- DEBUG(4,("Setting printer access=%x (pnum=%x)\n", access_required, pnum));
- Printer[pnum].access = access_required;
- return True;
- }
- else {
+ if (!OPEN_HANDLE(pnum)) {
DEBUG(4,("Error setting printer type=%x (pnum=%x)", access_required, pnum));
return False;
}
- return False;
-}
-
-/****************************************************************************
- .
-****************************************************************************/
-static BOOL printer_entry_is_valid(POLICY_HND *hnd)
-{
- int pnum = find_printer_index_by_hnd(hnd);
- if (!OPEN_HANDLE(pnum))
- return False;
-
- if (Printer[pnum].ok == False)
- return False;
-
- return True;
+ DEBUG(4,("Setting printer access=%x (pnum=%x)\n", access_required, pnum));
+ Printer[pnum].access = access_required;
+ return True;
}
/****************************************************************************
@@ -266,23 +245,19 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername)
if ( strlen(printername) < 3 ) {
DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername));
- Printer[pnum].ok=False;
return False;
}
/* it's a print server */
if (!strchr(printername+2, '\\')) {
DEBUGADD(4,("Printer is a print server\n"));
- Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER;
- Printer[pnum].ok=True;
-
+ Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER;
return True;
}
/* it's a printer */
else {
DEBUGADD(4,("Printer is a printer\n"));
Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER;
- Printer[pnum].ok=True;
return True;
}
@@ -295,11 +270,11 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername)
static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
{
int pnum = find_printer_index_by_hnd(hnd);
- char *back;
NT_PRINTER_INFO_LEVEL printer;
int snum;
int n_services=lp_numservices();
- uint32 marche;
+ char *aprinter;
+ BOOL found=False;
if (!OPEN_HANDLE(pnum))
{
@@ -309,54 +284,66 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", printername, strlen(printername), pnum));
- switch (Printer[pnum].printer_type) {
- case PRINTER_HANDLE_IS_PRINTSERVER:
+ if (Printer[pnum].printer_type==PRINTER_HANDLE_IS_PRINTSERVER) {
ZERO_STRUCT(Printer[pnum].dev.printerservername);
strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername));
return True;
- break;
+ }
- case PRINTER_HANDLE_IS_PRINTER:
- back=strchr(printername+2, '\\');
- back=back+1;
- DEBUGADD(5,("searching for %s (len=%d)\n", back,strlen(back)));
- /*
- * store the Samba share name in it
- * in back we have the long printer name
- * need to iterate all the snum and do a
- * get_a_printer each time to find the printer
- * faster to do it here than later.
- */
- for (snum=0;snum<n_services; snum++) {
- if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
- DEBUGADD(5,("share:%s\n",lp_servicename(snum)));
-
- marche=get_a_printer(&printer, 2, lp_servicename(snum));
- DEBUGADD(6,("marche:%d\n",marche));
-
- if ( marche==0 && ( strlen(printer.info_2->printername) == strlen(back) )
- && ( !strncasecmp(printer.info_2->printername, back, strlen(back)))
- ) {
- DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum));
- ZERO_STRUCT(Printer[pnum].dev.printername);
- strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum)));
- free_a_printer(printer, 2);
- return True;
- break;
- }
- free_a_printer(printer, 2);
- }
- }
+ if (Printer[pnum].printer_type!=PRINTER_HANDLE_IS_PRINTER)
return False;
- break;
-
- default:
+
+ aprinter=strchr(printername+2, '\\');
+ aprinter++;
+
+ DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter)));
+ /*
+ * store the Samba share name in it
+ * in back we have the long printer name
+ * need to iterate all the snum and do a
+ * get_a_printer each time to find the printer
+ * faster to do it here than later.
+ */
+
+ for (snum=0;snum<n_services && found==False;snum++) {
+
+ if ( !(lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) )
+ continue;
+
+ DEBUGADD(5,("share:%s\n",lp_servicename(snum)));
+
+ if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
+ continue;
+
+ if ( strlen(printer.info_2->printername) != strlen(aprinter) ) {
+ free_a_printer(printer, 2);
+ continue;
+ }
+
+ if ( strncasecmp(printer.info_2->printername, aprinter, strlen(aprinter))) {
+ free_a_printer(printer, 2);
+ continue;
+ }
+
+ found=True;
+ }
+
+ if (found==False)
+ {
+ DEBUGADD(4,("Printer not found\n"));
return False;
- break;
- }
+ }
+
+ DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum));
+ ZERO_STRUCT(Printer[pnum].dev.printername);
+ strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum)));
+ free_a_printer(printer, 2);
+
+ return True;
}
/********************************************************************
+ Return True is the handle is a print server.
********************************************************************/
static BOOL handle_is_printserver(const POLICY_HND *handle)
{
@@ -371,6 +358,30 @@ static BOOL handle_is_printserver(const POLICY_HND *handle)
return True;
}
+/****************************************************************************
+ allocate more memory for a BUFFER.
+****************************************************************************/
+static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size)
+{
+ prs_struct *ps;
+ uint32 extra_space;
+
+ ps=&(buffer->prs);
+
+ /* damn, I'm doing the reverse operation of prs_grow() :) */
+ if (buffer_size < prs_data_size(ps))
+ extra_space=0;
+ else
+ extra_space = buffer_size - prs_data_size(ps);
+
+ if (!prs_grow(ps, extra_space))
+ return False;
+
+ buffer->string_at_end=prs_data_size(ps);
+
+ return True;
+}
+
/********************************************************************
* spoolss_open_printer
*
@@ -400,9 +411,15 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
open_printer_hnd(handle);
- set_printer_hnd_printertype(handle, name);
+ if (!set_printer_hnd_printertype(handle, name)) {
+ close_printer_handle(handle);
+ return NT_STATUS_ACCESS_DENIED;
+ }
- set_printer_hnd_printername(handle, name);
+ if (!set_printer_hnd_printername(handle, name)) {
+ close_printer_handle(handle);
+ return NT_STATUS_ACCESS_DENIED;
+ }
/*
if (printer_default->datatype_ptr != NULL)
@@ -414,14 +431,11 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
set_printer_hnd_datatype(handle, "");
*/
- set_printer_hnd_accesstype(handle, printer_default->access_required);
-
- if (!printer_entry_is_valid(handle))
- {
+ if (!set_printer_hnd_accesstype(handle, printer_default->access_required)) {
close_printer_handle(handle);
return NT_STATUS_ACCESS_DENIED;
}
-
+
return NT_STATUS_NO_PROBLEMO;
}
@@ -536,7 +550,8 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle)
}
/********************************************************************
- ********************************************************************/
+ GetPrinterData on a printer server Handle.
+********************************************************************/
static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size)
{
int i;
@@ -585,7 +600,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
*type = 0x1;
*needed = 2*(strlen(string)+1);
*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8));
- ZERO_STRUCTP(*data);
+ memset(*data, 0, (*needed > in_size) ? *needed:in_size);
/* it's done by hand ready to go on the wire */
for (i=0; i<strlen(string); i++)
@@ -602,7 +617,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
*type = 0x1;
*needed = 2*(strlen(string)+1);
*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8));
- ZERO_STRUCTP(*data);
+ memset(*data, 0, (*needed > in_size) ? *needed:in_size);
for (i=0; i<strlen(string); i++)
{
(*data)[2*i]=string[i];
@@ -615,7 +630,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
}
/********************************************************************
- ********************************************************************/
+ GetPrinterData on a printer Handle.
+********************************************************************/
static BOOL getprinterdata_printer(const POLICY_HND *handle,
fstring value, uint32 *type,
uint8 **data, uint32 *needed, uint32 in_size )
@@ -674,8 +690,8 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
*out_size=in_size;
/* in case of problem, return some default values */
- *needed=in_size;
- *type=4;
+ *needed=0;
+ *type=0;
DEBUG(4,("_spoolss_getprinterdata\n"));
@@ -694,6 +710,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
if (found==False) {
/* reply this param doesn't exist */
*data=(uint8 *)malloc(4*sizeof(uint8));
+ memset(*data, 0x0, 4);
return ERROR_INVALID_PARAMETER;
}
@@ -1495,9 +1512,10 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s
* construct_printer_info_1
* fill a printer_info_1 struct
********************************************************************/
-static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername)
+static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer, int snum, pstring servername)
{
pstring chaine;
+ pstring chaine2;
NT_PRINTER_INFO_LEVEL ntprinter;
if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0)
@@ -1505,21 +1523,23 @@ static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring s
return (False);
}
- printer->flags=PRINTER_ENUM_NAME;
+ printer->flags=PRINTER_ENUM_ICON8;
/* the description and the name are of the form \\server\share */
- slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername,
+
+ snprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername,
ntprinter.info_2->printername,
ntprinter.info_2->drivername,
lp_comment(snum));
init_unistr(&(printer->description), chaine);
- slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername);
- init_unistr(&(printer->name), chaine);
+ snprintf(chaine2,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername);
+ init_unistr(&(printer->name), chaine2);
init_unistr(&(printer->comment), lp_comment(snum));
free_a_printer(ntprinter, 2);
+
return (True);
}
@@ -1648,29 +1668,26 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring
* enum_printer_info_1
* glue between spoolss_enumprinters and construct_printer_info_1
********************************************************************/
-static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number)
+static BOOL get_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number)
{
pstring servername;
*printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1));
DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer));
pstrcpy(servername, global_myname);
- if (!construct_printer_info_1(*printer, snum, servername))
- {
+ if (!construct_printer_info_1(*printer, snum, servername)) {
free(*printer);
- return (False);
+ return False;
}
else
- {
- return (True);
- }
+ return True;
}
/********************************************************************
* enum_printer_info_2
* glue between spoolss_enumprinters and construct_printer_info_2
********************************************************************/
-static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number)
+static BOOL get_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number)
{
pstring servername;
@@ -1693,26 +1710,100 @@ static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number)
*
* called from api_spoolss_enumprinters (see this to understand)
********************************************************************/
-static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number)
+static BOOL enum_printer_info_1(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int snum;
+ int i;
int n_services=lp_numservices();
- *printers=NULL;
- *number=0;
+ PRINTER_INFO_1 *printer=NULL;
+DEBUG(1,("enum_printer_info_1\n"));
+ for (snum=0; snum<n_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+
+ /*
+ JFM: here we should check the name
+
+ */
+
+ if (get_printer_info_1(&printer , snum, *returned) )
+ (*returned)++;
+ }
+ }
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ (*needed) += spoolss_size_printer_info_1(printer);
- for (snum=0;snum<n_services; snum++)
- {
- if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
- {
- DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum));
- *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_1 *));
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers));
- if (enum_printer_info_1( &((*printers)[*number]), snum, *number) )
- {
- (*number)++;
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the structures */
+
+ for (i=0; i<*returned; i++)
+ new_smb_io_printer_info_1("", buffer, printer, 0);
+
+ /* clear memory */
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/********************************************************************
+ Spoolss_enumprinters.
+********************************************************************/
+static BOOL enum_all_printers_info_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ int snum;
+ int i;
+ int n_services=lp_numservices();
+ PRINTER_INFO_1 *printers=NULL;
+ PRINTER_INFO_1 current_prt;
+ pstring servername;
+
+ DEBUG(4,("enum_all_printers_info_1\n"));
+
+ pstrcpy(servername, global_myname);
+
+ for (snum=0; snum<n_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+
+ if (construct_printer_info_1(&current_prt, snum, servername))
+ {
+ printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1));
+ DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned));
+ memcpy(&(printers[*returned]), &current_prt, sizeof(PRINTER_INFO_1));
+ (*returned)++;
}
}
}
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ (*needed) += spoolss_size_printer_info_1(&(printers[i]));
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+
+ /* fill the buffer with the structures */
+
+ for (i=0; i<*returned; i++)
+ new_smb_io_printer_info_1("", buffer, &(printers[i]), 0);
+
+ /* clear memory */
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
}
/********************************************************************
@@ -1720,26 +1811,90 @@ static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number)
*
* called from api_spoolss_enumprinters (see this to understand)
********************************************************************/
-static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number)
+static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int snum;
+ int i;
int n_services=lp_numservices();
- *printers=NULL;
- *number=0;
+ PRINTER_INFO_2 **printers=NULL;
- for (snum=0;snum<n_services; snum++)
- {
- if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
- {
- DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum));
- *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_2 *));
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers at [%p]\n", *number+1, *printers));
- if (enum_printer_info_2( &((*printers)[*number]), snum, *number) )
- {
- (*number)++;
- }
+ for (snum=0; snum<n_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+
+ printers=Realloc(printers, ((*returned)+1)*sizeof(PRINTER_INFO_2 *));
+
+ DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers\n", (*returned)+1));
+
+ if (get_printer_info_2( &(printers[*returned]), snum, *returned) )
+ (*returned)++;
}
}
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ (*needed) += spoolss_size_printer_info_2(printers[i]);
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the structures */
+ for (i=0; i<*returned; i++)
+ new_smb_io_printer_info_2("", buffer, printers[i], 0);
+
+ /* clear memory */
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/********************************************************************
+ * handle enumeration of printers at level 1
+ ********************************************************************/
+static uint32 enumprinters_level1( uint32 flags, fstring name,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+ if (flags && PRINTER_ENUM_NETWORK)
+ return enum_all_printers_info_1(buffer, offered, needed, returned);
+
+ if (flags && PRINTER_ENUM_NAME) {
+ if (*name=='\0')
+ return enum_all_printers_info_1(buffer, offered, needed, returned);
+ else
+ return enum_printer_info_1(name, buffer, offered, needed, returned);
+ }
+
+ if (flags && PRINTER_ENUM_REMOTE)
+ return enum_all_printers_info_1(buffer, offered, needed, returned);
+
+
+}
+
+/********************************************************************
+ * handle enumeration of printers at level 2
+ ********************************************************************/
+static uint32 enumprinters_level2( uint32 flags, fstring servername,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+ return enum_all_printers_info_2(buffer, offered, needed, returned);
+}
+
+/********************************************************************
+ * handle enumeration of printers at level 5
+ ********************************************************************/
+static uint32 enumprinters_level5( uint32 flags, fstring servername,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+/* return enum_all_printers_info_5(buffer, offered, needed, returned);*/
+ return NT_STATUS_NO_PROBLEMO;
}
/********************************************************************
@@ -1747,55 +1902,48 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number)
*
* called from api_spoolss_enumprinters (see this to understand)
********************************************************************/
-uint32 _spoolss_enumprinters(
- uint32 flags,
- const UNISTR2 *servername,
- uint32 level,
- const BUFFER *buffer,
- uint32 buf_size,
- uint32 *offered,
- uint32 *needed,
- PRINTER_INFO_CTR *ctr,
- uint32 *returned)
+uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
{
- DEBUG(4,("Enumerating printers\n"));
+ fstring name;
+
+ DEBUG(4,("_spoolss_enumprinters\n"));
- (*returned)=0;
+ *needed=0;
+ *returned=0;
+
+ /*
+ * Level 1:
+ * flags==PRINTER_ENUM_NAME
+ * if name=="" then enumerates all printers
+ * if name!="" then enumerate the printer
+ * flags==PRINTER_ENUM_REMOTE
+ * name is NULL, enumerate printers
+ * Level 2: name!="" enumerates printers, name can't be NULL
+ * Level 3: doesn't exist
+ * Level 4: does a local registry lookup
+ * Level 5: same as Level 2
+ */
- switch (level)
- {
- case 1:
- if (flags == PRINTER_ENUM_NAME ||
- flags == PRINTER_ENUM_NETWORK )
- {
- /*if (is_a_printerserver(servername))*/
- enum_all_printers_info_1(&ctr->printer.printers_1, returned );
- /*else
- enum_one_printer_info_1(&r_u);*/
- break;
- }
- case 2:
- if (flags == PRINTER_ENUM_NAME ||
- flags == PRINTER_ENUM_NETWORK )
- {
- /*if (is_a_printerserver(servername))*/
- enum_all_printers_info_2(&ctr->printer.printers_2, returned );
- /*else
- enum_one_printer_info_2(&r_u);*/
- break;
- }
- case 3: /* doesn't exist */
- return NT_STATUS_INVALID_INFO_CLASS;
- case 4: /* can't, always on local machine */
- break;
- case 5:
- return NT_STATUS_INVALID_INFO_CLASS;
-
- }
- DEBUG(4,("%d printers enumerated\n", *returned));
- (*offered) = buffer->size;
+ unistr2_to_ascii(name, servername, sizeof(name)-1);
- return 0x0;
+ switch (level) {
+ case 1:
+ return enumprinters_level1(flags, name, buffer, offered, needed, returned);
+ break;
+ case 2:
+ return enumprinters_level2(flags, name, buffer, offered, needed, returned);
+ break;
+ case 5:
+ return enumprinters_level5(flags, name, buffer, offered, needed, returned);
+ break;
+ case 3:
+ case 4:
+ default:
+ return NT_STATUS_INVALID_LEVEL;
+ break;
+ }
}
/****************************************************************************
@@ -2562,76 +2710,125 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
}
/****************************************************************************
+ Enumjobs at level 1.
****************************************************************************/
-uint32 _spoolss_enumjobs( const POLICY_HND *handle,
- uint32 reqfirstjob,
- uint32 reqnumofjobs,
- uint32 level,
- JOB_INFO_CTR *ctr,
- uint32 *buf_size,
- uint32 *numofjobs)
+static uint32 enumjobs_level1(print_queue_struct *queue, int snum,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
{
- int snum;
- int count;
+ JOB_INFO_1 *info;
int i;
+
+ info=(JOB_INFO_1 *)malloc(*returned*sizeof(JOB_INFO_1));
+
+ for (i=0; i<*returned; i++)
+ {
+ fill_job_info_1(&(info[i]), &(queue[i]), i, snum);
+ }
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ (*needed) += spoolss_size_job_info_1(&(info[i]));
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the structures */
+ for (i=0; i<*returned; i++)
+ new_smb_io_job_info_1("", buffer, &(info[i]), 0);
+
+ /* clear memory */
+ safe_free(queue);
+ safe_free(info);
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+ Enumjobs at level 2.
+****************************************************************************/
+static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+ JOB_INFO_2 *info;
+ int i;
+
+ info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2));
+
+ for (i=0; i<*returned; i++)
+ {
+ fill_job_info_2(&(info[i]), &(queue[i]), i, snum);
+ }
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ (*needed) += spoolss_size_job_info_2(&(info[i]));
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the structures */
+ for (i=0; i<*returned; i++)
+ new_smb_io_job_info_2("", buffer, &(info[i]), 0);
+
+ /* clear memory */
+ safe_free(queue);
+ safe_free(info);
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+ Enumjobs.
+****************************************************************************/
+uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+ int snum;
print_queue_struct *queue=NULL;
print_status_struct prt_status;
- DEBUG(4,("spoolss_enumjobs\n"));
-
+ DEBUG(4,("_spoolss_enumjobs\n"));
+
ZERO_STRUCT(prt_status);
+ *needed=0;
+ *returned=0;
+
if (!get_printer_snum(handle, &snum))
{
return NT_STATUS_INVALID_HANDLE;
}
- count = get_printqueue(snum, NULL, &queue, &prt_status);
- (*numofjobs) = 0;
-
- DEBUG(4,("count:[%d], status:[%d], [%s]\n",
- count, prt_status.status, prt_status.message));
-
- switch (level)
- {
- case 1:
- {
- for (i=0; i<count; i++)
- {
- JOB_INFO_1 *job_info_1;
- job_info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1));
- add_job1_to_array(numofjobs,
- &ctr->job.job_info_1,
- job_info_1);
-
- fill_job_info_1(ctr->job.job_info_1[i],
- &(queue[i]), i, snum);
- }
- safe_free(queue);
- return 0x0;
- }
- case 2:
- {
- for (i=0; i<count; i++)
- {
- JOB_INFO_2 *job_info_2;
- job_info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2));
- add_job2_to_array(numofjobs,
- &ctr->job.job_info_2,
- job_info_2);
-
- fill_job_info_2(ctr->job.job_info_2[i],
- &(queue[i]), i, snum);
- }
- safe_free(queue);
- return 0x0;
- }
+ *returned = get_printqueue(snum, NULL, &queue, &prt_status);
+ DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message));
+
+ switch (level) {
+ case 1:
+ return enumjobs_level1(queue, snum, buffer, offered, needed, returned);
+ break;
+ case 2:
+ return enumjobs_level2(queue, snum, buffer, offered, needed, returned);
+ break;
+ default:
+ return NT_STATUS_INVALID_LEVEL;
+ break;
}
+}
- safe_free(queue);
- return NT_STATUS_INVALID_INFO_CLASS;
-}
/****************************************************************************
****************************************************************************/
@@ -2705,86 +2902,166 @@ uint32 _spoolss_setjob( const POLICY_HND *handle,
}
/****************************************************************************
+ Enumerates all printer drivers at level 1.
****************************************************************************/
-uint32 _spoolss_enumprinterdrivers( const UNISTR2 *name,
- const UNISTR2 *environment,
- uint32 level,
- DRIVER_INFO *ctr,
- uint32 *offered,
- uint32 *numofdrivers)
+static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
- int count;
int i;
- fstring *list;
- fstring servername;
- fstring architecture;
+ NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ DRIVER_INFO_1 *driver_info_1=NULL;
+ driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1));
- DEBUG(4,("spoolss_enumdrivers\n"));
- fstrcpy(servername, global_myname);
+ for (i=0; i<*returned; i++) {
+ get_a_printer_driver(&driver, 3, list[i], architecture);
+ fill_printer_driver_info_1(&(driver_info_1[i]), driver, servername, architecture );
+ free_a_printer_driver(driver, 3);
+ }
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding driver [%d]'s size\n",i));
+ *needed += spoolss_size_printer_driver_info_1(&(driver_info_1[i]));
+ }
- unistr2_to_ascii(architecture, environment, sizeof(architecture));
- count=get_ntdrivers(&list, architecture);
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
- DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture));
- for (i=0; i<count; i++)
+ /* fill the buffer with the form structures */
+ for (i=0; i<*returned; i++)
{
- DEBUGADD(5,("driver [%s]\n",list[i]));
+ DEBUGADD(6,("adding form [%d] to buffer\n",i));
+ new_smb_io_printer_driver_info_1("", buffer, &(driver_info_1[i]), 0);
+ }
+
+ safe_free(list);
+
+ if (*needed > offered)
+ return ERROR_INSUFFICIENT_BUFFER;
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+ Enumerates all printer drivers at level 2.
+****************************************************************************/
+static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ int i;
+ NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ DRIVER_INFO_2 *driver_info_2=NULL;
+ driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2));
+
+ for (i=0; i<*returned; i++) {
+ get_a_printer_driver(&driver, 3, list[i], architecture);
+ fill_printer_driver_info_2(&(driver_info_2[i]), driver, servername, architecture );
+ free_a_printer_driver(driver, 3);
}
- (*numofdrivers)=count;
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding driver [%d]'s size\n",i));
+ *needed += spoolss_size_printer_driver_info_2(&(driver_info_2[i]));
+ }
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the form structures */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding form [%d] to buffer\n",i));
+ new_smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0);
+ }
+
+ safe_free(list);
+
+ if (*needed > offered)
+ return ERROR_INSUFFICIENT_BUFFER;
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+ Enumerates all printer drivers at level 3.
+****************************************************************************/
+static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ int i;
+ NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ DRIVER_INFO_3 *driver_info_3=NULL;
+ driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3));
+
+ for (i=0; i<*returned; i++) {
+ get_a_printer_driver(&driver, 3, list[i], architecture);
+ fill_printer_driver_info_3(&(driver_info_3[i]), driver, servername, architecture );
+ free_a_printer_driver(driver, 3);
+ }
- switch (level)
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
{
- case 1:
- {
- DRIVER_INFO_1 *driver_info_1=NULL;
- driver_info_1=(DRIVER_INFO_1 *)malloc(count*sizeof(DRIVER_INFO_1));
+ DEBUGADD(6,("adding driver [%d]'s size\n",i));
+ *needed += spoolss_size_printer_driver_info_3(&(driver_info_3[i]));
+ }
- for (i=0; i<count; i++)
- {
- get_a_printer_driver(&driver, 3, list[i], architecture);
- fill_printer_driver_info_1(&(driver_info_1[i]), driver, servername, architecture );
- free_a_printer_driver(driver, 3);
- }
- ctr->driver.info1=driver_info_1;
- break;
- }
- case 2:
- {
- DRIVER_INFO_2 *driver_info_2=NULL;
- driver_info_2=(DRIVER_INFO_2 *)malloc(count*sizeof(DRIVER_INFO_2));
-
- for (i=0; i<count; i++)
- {
- get_a_printer_driver(&driver, 3, list[i], architecture);
- fill_printer_driver_info_2(&(driver_info_2[i]), driver, servername, architecture );
- free_a_printer_driver(driver, 3);
- }
- ctr->driver.info2=driver_info_2;
- break;
- }
- case 3:
- {
- DRIVER_INFO_3 *driver_info_3=NULL;
- driver_info_3=(DRIVER_INFO_3 *)malloc(count*sizeof(DRIVER_INFO_3));
-
- for (i=0; i<count; i++)
- {
- get_a_printer_driver(&driver, 3, list[i], architecture);
- fill_printer_driver_info_3(&(driver_info_3[i]), driver, servername, architecture );
- free_a_printer_driver(driver, 3);
- }
- ctr->driver.info3=driver_info_3;
- break;
- }
- default:
- {
- return NT_STATUS_INVALID_INFO_CLASS;
- }
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the form structures */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding form [%d] to buffer\n",i));
+ new_smb_io_printer_driver_info_3("", buffer, &(driver_info_3[i]), 0);
}
- return 0x0;
+ safe_free(list);
+
+ if (*needed > offered)
+ return ERROR_INSUFFICIENT_BUFFER;
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+ Enumerates all printer drivers.
+****************************************************************************/
+uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+ int i;
+ fstring *list;
+ fstring servername;
+ fstring architecture;
+
+ DEBUG(4,("_spoolss_enumprinterdrivers\n"));
+ fstrcpy(servername, global_myname);
+ *needed=0;
+ *returned=0;
+
+ unistr2_to_ascii(architecture, environment, sizeof(architecture)-1);
+ *returned=get_ntdrivers(&list, architecture);
+
+ DEBUGADD(4,("we have: [%d] drivers in environment [%s]\n", *returned, architecture));
+ for (i=0; i<*returned; i++)
+ DEBUGADD(5,("driver: [%s]\n", list[i]));
+
+ switch (level) {
+ case 1:
+ return enumprinterdrivers_level1(list, servername, architecture, buffer, offered, needed, returned);
+ break;
+ case 2:
+ return enumprinterdrivers_level2(list, servername, architecture, buffer, offered, needed, returned);
+ break;
+ case 3:
+ return enumprinterdrivers_level3(list, servername, architecture, buffer, offered, needed, returned);
+ break;
+ default:
+ return NT_STATUS_INVALID_INFO_CLASS;
+ break;
+ }
}
/****************************************************************************
@@ -2803,26 +3080,6 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position)
/****************************************************************************
****************************************************************************/
-static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size)
-{
- prs_struct *ps;
- uint32 extra_space;
-
- ps=&(buffer->prs);
-
- /* damn, I'm doing the reverse operation of prs_grow() :) */
- extra_space = buffer_size - prs_data_size(ps);
-
- if (!prs_grow(ps, extra_space))
- return False;
-
- buffer->string_at_end=buffer_size;
-
- return True;
-}
-
-/****************************************************************************
-****************************************************************************/
uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *numofforms)
@@ -2832,7 +3089,6 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
int buffer_size=0;
int i;
-
DEBUG(4,("_new_spoolss_enumforms\n"));
DEBUGADD(5,("Offered buffer size [%d]\n", offered));
DEBUGADD(5,("Info level [%d]\n", level));
@@ -2886,43 +3142,9 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
/****************************************************************************
****************************************************************************/
-uint32 _spoolss_enumforms( const POLICY_HND *handle,
- uint32 level,
- FORM_1 **forms_1,
- uint32 *offered,
- uint32 *numofforms)
+static void fill_port_1(PORT_INFO_1 *port, char *name)
{
- int count;
- int i;
- nt_forms_struct *list=NULL;
- (*forms_1)=NULL;
-
- DEBUG(4,("spoolss_enumforms\n"));
-
- count = get_ntforms(&list);
- (*numofforms) = count;
-
- DEBUGADD(5,("Offered buffer size [%d]\n", *offered));
- DEBUGADD(5,("Number of forms [%d]\n", *numofforms));
- DEBUGADD(5,("Info level [%d]\n", level));
-
- switch (level)
- {
- case 1:
- {
- (*forms_1)=(FORM_1 *)malloc(count*sizeof(FORM_1));
- for (i=0; i<count; i++)
- {
- DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&((*forms_1)[i]), &(list[i]), i);
- }
- safe_free(list);
- return 0x0;
- }
- }
-
- safe_free(list);
- return NT_STATUS_INVALID_INFO_CLASS;
+ init_unistr(&(port->port_name), name);
}
/****************************************************************************
@@ -2938,45 +3160,135 @@ static void fill_port_2(PORT_INFO_2 *port, char *name)
}
/****************************************************************************
+ enumports level 1.
****************************************************************************/
-uint32 _spoolss_enumports( const UNISTR2 *name,
- uint32 level,
- PORT_INFO_CTR *ctr,
- uint32 *offered,
- uint32 *numofports)
+static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int n_services=lp_numservices();
int snum;
+ int i=0;
+
+ PORT_INFO_1 *ports=NULL;
- DEBUG(4,("spoolss_enumports\n"));
+ for (snum=0; snum<n_services; snum++)
+ if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
+ (*returned)++;
+
+ ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) );
- (*numofports) = 0;
+ for (snum=0; snum<n_services; snum++)
+ {
+ if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ DEBUGADD(6,("Filling port number [%d]\n", i));
+ fill_port_1(&(ports[i]), lp_servicename(snum));
+ i++;
+ }
+ }
- switch (level)
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
{
- case 2:
- {
- PORT_INFO_2 *ports_2=NULL;
- ports_2=(PORT_INFO_2 *)malloc(n_services*sizeof(PORT_INFO_2));
- for (snum=0; snum<n_services; snum++)
- {
- if ( lp_browseable(snum) &&
- lp_snum_ok(snum) &&
- lp_print_ok(snum) )
- {
- DEBUGADD(6,("Filling port no [%d]\n",
- (*numofports)));
- fill_port_2(&(ports_2[(*numofports)]),
- lp_servicename(snum));
- (*numofports)++;
- }
- }
- ctr->port.info_2=ports_2;
- return 0x0;
- }
+ DEBUGADD(6,("adding port [%d]'s size\n", i));
+ *needed += spoolss_size_port_info_1(&(ports[i]));
}
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the ports structures */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding port [%d] to buffer\n", i));
+ new_smb_io_port_1("", buffer, &(ports[i]), 0);
+ }
+
+ safe_free(ports);
- return NT_STATUS_INVALID_INFO_CLASS;
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+
+/****************************************************************************
+ enumports level 2.
+****************************************************************************/
+static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ int n_services=lp_numservices();
+ int snum;
+ int i=0;
+
+ PORT_INFO_2 *ports=NULL;
+
+ for (snum=0; snum<n_services; snum++)
+ if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
+ (*returned)++;
+
+ ports=(PORT_INFO_2 *)malloc( (*returned+1) * sizeof(PORT_INFO_2) );
+
+ for (snum=0; snum<n_services; snum++)
+ {
+ if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ DEBUGADD(6,("Filling port number [%d]\n", i));
+ fill_port_2(&(ports[i]), lp_servicename(snum));
+ i++;
+ }
+ }
+
+ /* check the required size. */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding port [%d]'s size\n", i));
+ *needed += spoolss_size_port_info_2(&(ports[i]));
+ }
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /* fill the buffer with the ports structures */
+ for (i=0; i<*returned; i++)
+ {
+ DEBUGADD(6,("adding port [%d] to buffer\n", i));
+ new_smb_io_port_2("", buffer, &(ports[i]), 0);
+ }
+
+ safe_free(ports);
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+ enumports.
+****************************************************************************/
+uint32 _spoolss_enumports( UNISTR2 *name, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
+{
+ DEBUG(4,("spoolss_enumports\n"));
+
+ *returned=0;
+ *needed=0;
+
+ switch (level) {
+ case 1:
+ return enumports_level_1(buffer, offered, needed, returned);
+ break;
+ case 2:
+ return enumports_level_2(buffer, offered, needed, returned);
+ break;
+ default:
+ return NT_STATUS_INVALID_INFO_CLASS;
+ break;
+ }
}
/****************************************************************************
@@ -3293,13 +3605,39 @@ uint32 _spoolss_setform( const POLICY_HND *handle,
}
/****************************************************************************
+ enumprintprocessors level 1.
****************************************************************************/
-uint32 _spoolss_enumprintprocessors(const UNISTR2 *name,
- const UNISTR2 *environment,
- uint32 level,
- PRINTPROCESSOR_1 **info_1,
- uint32 *offered,
- uint32 *numofprintprocessors)
+static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ PRINTPROCESSOR_1 *info_1=NULL;
+
+ info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1));
+ (*returned) = 0x1;
+
+ init_unistr(&(info_1->name), "winprint");
+
+ *needed += spoolss_size_printprocessor_info_1(info_1);
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ smb_io_printprocessor_info_1("", buffer, info_1, 0);
+
+ safe_free(info_1);
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+****************************************************************************/
+uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
{
DEBUG(5,("spoolss_enumprintprocessors\n"));
@@ -3310,26 +3648,85 @@ uint32 _spoolss_enumprintprocessors(const UNISTR2 *name,
* and I can use my nice printer checker.
*/
- (*numofprintprocessors) = 0x1;
- (*info_1) = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1));
+ *returned=0;
+ *needed=0;
- if ((*info_1) == NULL)
- {
- return NT_STATUS_NO_MEMORY;
+ switch (level) {
+ case 1:
+ return enumprintprocessors_level_1(buffer, offered, needed, returned);
+ break;
+ default:
+ return NT_STATUS_INVALID_INFO_CLASS;
+ break;
}
- init_unistr(&((*info_1)->name), "winprint");
+}
- return 0x0;
+/****************************************************************************
+ enumprintmonitors level 1.
+****************************************************************************/
+static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ PRINTMONITOR_1 *info_1=NULL;
+
+ info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1));
+ (*returned) = 0x1;
+
+ init_unistr(&(info_1->name), "Local Port");
+
+ *needed += spoolss_size_printmonitor_info_1(info_1);
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ smb_io_printmonitor_info_1("", buffer, info_1, 0);
+
+ safe_free(info_1);
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
}
/****************************************************************************
+ enumprintmonitors level 2.
****************************************************************************/
-uint32 _spoolss_enumprintmonitors( const UNISTR2 *name,
- uint32 level,
- PRINTMONITOR_1 **info_1,
- uint32 *offered,
- uint32 *numofprintmonitors)
+static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+{
+ PRINTMONITOR_2 *info_2=NULL;
+
+ info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2));
+ (*returned) = 0x1;
+
+ init_unistr(&(info_2->name), "Local Port");
+ init_unistr(&(info_2->environment), "Windows NT X86");
+ init_unistr(&(info_2->dll_name), "localmon.dll");
+
+ *needed += spoolss_size_printmonitor_info_2(info_2);
+
+ if (!alloc_buffer_size(buffer, *needed))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ smb_io_printmonitor_info_2("", buffer, info_2, 0);
+
+ safe_free(info_2);
+
+ if (*needed > offered) {
+ *returned=0;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ else
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/****************************************************************************
+****************************************************************************/
+uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level,
+ NEW_BUFFER *buffer, uint32 offered,
+ uint32 *needed, uint32 *returned)
{
DEBUG(5,("spoolss_enumprintmonitors\n"));
@@ -3340,16 +3737,20 @@ uint32 _spoolss_enumprintmonitors( const UNISTR2 *name,
* and I can use my nice printer checker.
*/
- (*numofprintmonitors) = 0x1;
- (*info_1) = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1));
- if ((*info_1) == NULL)
- {
- return NT_STATUS_NO_MEMORY;
- }
+ *returned=0;
+ *needed=0;
- init_unistr(&((*info_1)->name), "Local Port");
-
- return 0x0;
+ switch (level) {
+ case 1:
+ return enumprintmonitors_level_1(buffer, offered, needed, returned);
+ break;
+ case 2:
+ return enumprintmonitors_level_2(buffer, offered, needed, returned);
+ break;
+ default:
+ return NT_STATUS_INVALID_INFO_CLASS;
+ break;
+ }
}
/****************************************************************************