#include "includes.h"
#include "printing.h"
-#include "librpc/gen_ndr/messaging.h"
#include "../librpc/gen_ndr/spoolss.h"
#include "nt_printing.h"
+#include "printing/notify.h"
+#include "messages.h"
+#include "util_tdb.h"
static TALLOC_CTX *send_ctx;
memcpy( to, from, sizeof(SPOOLSS_NOTIFY_MSG) );
if ( from->len ) {
- to->notify.data = (char *)TALLOC_MEMDUP(send_ctx, from->notify.data, from->len );
+ to->notify.data = (char *)talloc_memdup(send_ctx, from->notify.data, from->len );
if ( !to->notify.data ) {
- DEBUG(0,("copy_notify2_msg: TALLOC_MEMDUP() of size [%d] failed!\n", from->len ));
+ DEBUG(0,("copy_notify2_msg: talloc_memdup() of size [%d] failed!\n", from->len ));
return False;
}
}
/* Store the message on the pending queue. */
- pnqueue = TALLOC_P(send_ctx, struct notify_queue);
+ pnqueue = talloc(send_ctx, struct notify_queue);
if (!pnqueue) {
DEBUG(0,("send_spoolss_notify2_msg: Out of memory.\n"));
return;
/* allocate a new msg structure and copy the fields */
- if ( !(pnqueue->msg = TALLOC_P(send_ctx, SPOOLSS_NOTIFY_MSG)) ) {
+ if ( !(pnqueue->msg = talloc(send_ctx, SPOOLSS_NOTIFY_MSG)) ) {
DEBUG(0,("send_spoolss_notify2_msg: talloc() of size [%lu] failed!\n",
(unsigned long)sizeof(SPOOLSS_NOTIFY_MSG)));
return;
if (!create_send_ctx())
return;
- msg = TALLOC_P(send_ctx, struct spoolss_notify_msg);
+ msg = talloc(send_ctx, struct spoolss_notify_msg);
if (!msg)
return;
if (!create_send_ctx())
return;
- msg = TALLOC_P(send_ctx, struct spoolss_notify_msg);
+ msg = talloc(send_ctx, struct spoolss_notify_msg);
if (!msg)
return;
msg->field = field;
msg->id = id;
msg->len = len;
- msg->notify.data = CONST_DISCARD(char *,buffer);
+ msg->notify.data = discard_const_p(char, buffer);
send_spoolss_notify2_msg(ev, msg_ctx, msg);
}
snum, strlen(driver_name) + 1, driver_name);
}
-void notify_printer_comment(int snum, const char *comment)
+void notify_printer_comment(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ int snum, const char *comment)
{
const char *sharename = lp_servicename(snum);
send_notify_field_buffer(
- server_event_context(), server_messaging_context(),
+ ev, msg_ctx,
sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_COMMENT,
snum, strlen(comment) + 1, comment);
}
-void notify_printer_sharename(int snum, const char *share_name)
+void notify_printer_sharename(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ int snum, const char *share_name)
{
const char *sharename = lp_servicename(snum);
send_notify_field_buffer(
- server_event_context(), server_messaging_context(),
+ ev, msg_ctx,
sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_SHARE_NAME,
snum, strlen(share_name) + 1, share_name);
}
-void notify_printer_printername(int snum, const char *printername)
+void notify_printer_printername(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ int snum, const char *printername)
{
const char *sharename = lp_servicename(snum);
send_notify_field_buffer(
- server_event_context(), server_messaging_context(),
+ ev, msg_ctx,
sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PRINTER_NAME,
snum, strlen(printername) + 1, printername);
}
-void notify_printer_port(int snum, const char *port_name)
+void notify_printer_port(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ int snum, const char *port_name)
{
const char *sharename = lp_servicename(snum);
send_notify_field_buffer(
- server_event_context(), server_messaging_context(),
+ ev, msg_ctx,
sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PORT_NAME,
snum, strlen(port_name) + 1, port_name);
}
-void notify_printer_location(int snum, const char *location)
+void notify_printer_location(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ int snum, const char *location)
{
const char *sharename = lp_servicename(snum);
send_notify_field_buffer(
- server_event_context(), server_messaging_context(),
+ ev, msg_ctx,
sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_LOCATION,
snum, strlen(location) + 1, location);
}
-void notify_printer_byname( const char *printername, uint32 change, const char *value )
+void notify_printer_sepfile(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ int snum, const char *sepfile)
+{
+ const char *sharename = lp_servicename(snum);
+
+ send_notify_field_buffer(
+ ev, msg_ctx,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_SEPFILE,
+ snum, strlen(sepfile) + 1, sepfile);
+}
+
+
+void notify_printer_byname(struct tevent_context *ev,
+ struct messaging_context *msg_ctx,
+ const char *printername, uint32 change,
+ const char *value)
{
int snum = print_queue_snum(printername);
int type = PRINTER_NOTIFY_TYPE;
return;
send_notify_field_buffer(
- server_event_context(), server_messaging_context(),
+ ev, msg_ctx,
printername, type, change, snum, strlen(value)+1, value );
}
return False;
tdb = pdb->tdb;
- if (tdb_read_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_read_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) != 0) {
DEBUG(0,("print_notify_pid_list: Failed to lock printer %s database\n",
printername));
if (pdb)
num_pids = data.dsize / 8;
if (num_pids) {
- if ((pid_list = TALLOC_ARRAY(mem_ctx, pid_t, num_pids)) == NULL) {
+ if ((pid_list = talloc_array(mem_ctx, pid_t, num_pids)) == NULL) {
ret = False;
goto done;
}