RAP queue status codes for LANMAN printing
Rainer Weikusat
rainer.weikusat at sncag.com
Fri Dec 16 15:41:06 GMT 2005
Jeremy Allison <jra at samba.org> writes:
> On Thu, Dec 15, 2005 at 09:26:25PM +0100, Rainer Weikusat wrote:
>
>> I've been flamed enough on various mailing lists to no longer send
>> patches to code someone else wrote without giving him a chance to
>> start flaming before I try to make a 'clean' patch ... :->.
>
> I'm *never* going to flame you for sending in a Samba patch.
> I may not use it "as-is" but I'm always grateful :-). If you
> do write a patch please send it to us.
It is somewhat larger than absolutely necessary, but the temptation
to simplify the control flow at least a little proved too great.
Index: eli-samba/source/include/smb.h
===================================================================
RCS file: /data/repo/eli-samba/source/include/smb.h,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.2 -r1.1.1.1.2.3
--- eli-samba/source/include/smb.h 16 Dec 2005 11:27:50 -0000 1.1.1.2
+++ eli-samba/source/include/smb.h 16 Dec 2005 15:27:35 -0000 1.1.1.1.2.3
@@ -598,7 +598,8 @@
fstring fs_file;
} print_queue_struct;
-enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
+/* the numerical values correspond with RAP queue status codes (LANMAN printing) */
+enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR, LPSTAT_BEING_DELETED};
typedef struct
{
Index: eli-samba/source/smbd/lanman.c
===================================================================
RCS file: /data/repo/eli-samba/source/smbd/lanman.c,v
retrieving revision 1.1.1.3
retrieving revision 1.1.1.2.2.2
diff -u -r1.1.1.3 -r1.1.1.2.2.2
--- eli-samba/source/smbd/lanman.c 16 Dec 2005 11:27:45 -0000 1.1.1.3
+++ eli-samba/source/smbd/lanman.c 16 Dec 2005 15:19:18 -0000 1.1.1.2.2.2
@@ -443,9 +443,6 @@
#define RAP_JOB_STATUS_PRINTING 3
#define RAP_JOB_STATUS_PRINTED 4
-#define RAP_QUEUE_STATUS_PAUSED 1
-#define RAP_QUEUE_STATUS_ERROR 2
-
/* turn a print job status into a on the wire status
*/
static int printj_status(int v)
@@ -463,18 +460,11 @@
return 0;
}
-/* turn a print queue status into a on the wire status
+/* turn a print queue status into a on the wire status
+
+ see LPSTAT comment in smb.h
*/
-static int printq_status(int v)
-{
- switch (v) {
- case LPQ_QUEUED:
- return 0;
- case LPQ_PAUSED:
- return RAP_QUEUE_STATUS_PAUSED;
- }
- return RAP_QUEUE_STATUS_ERROR;
-}
+#define printq_status(v) v
static void fill_printjob_info(connection_struct *conn, int snum, int uLevel,
struct pack_desc *desc,
@@ -638,6 +628,29 @@
free_a_printer_driver( driver, 3 );
}
+static void pack_printq_status(struct pack_desc *desc,
+ connection_struct *conn, int snum,
+ print_status_struct *status)
+{
+ char const *msg;
+ int code;
+
+ code = LPSTAT_ERROR;
+ msg = "UNKNOWN_PRINTER";
+
+ if (snum >= 0) {
+ if (status && *status->message) {
+ code = status->status;
+ msg = status->message;
+ } else {
+ code = LPSTAT_OK;
+ msg = Expand(conn, snum, lp_comment(snum));
+ }
+ }
+
+ PACKS(desc, "z", msg);
+ PACKI(desc, "W", printq_status(code));
+}
static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
struct pack_desc* desc,
@@ -668,17 +681,8 @@
PACKS(desc,"z","lpd"); /* pPrProc */
PACKS(desc,"z",SERVICE(snum)); /* pDestinations */
PACKS(desc,"z",""); /* pParms */
- if (snum < 0) {
- PACKS(desc,"z","UNKNOWN PRINTER");
- PACKI(desc,"W",LPSTAT_ERROR);
- }
- else if (!status || !status->message[0]) {
- PACKS(desc,"z",Expand(conn,snum,lp_comment(snum)));
- PACKI(desc,"W",LPSTAT_OK); /* status */
- } else {
- PACKS(desc,"z",status->message);
- PACKI(desc,"W",printq_status(status->status)); /* status */
- }
+
+ pack_printq_status(desc, conn, snum, status);
PACKI(desc,(uLevel == 1 ? "W" : "N"),count);
}
More information about the samba-technical
mailing list