diff options
Diffstat (limited to 'source/printing/printing.c')
-rw-r--r-- | source/printing/printing.c | 80 |
1 files changed, 77 insertions, 3 deletions
diff --git a/source/printing/printing.c b/source/printing/printing.c index 1dd8921800a..2eef0d303bc 100644 --- a/source/printing/printing.c +++ b/source/printing/printing.c @@ -20,7 +20,6 @@ */ #include "includes.h" -#include "loadparm.h" extern int DEBUGLEVEL; extern connection_struct Connections[]; extern files_struct Files[]; @@ -149,7 +148,7 @@ process time fields ********************************************************************/ static time_t EntryTime(string tok[], int ptr, int count, int minimum) { - time_t jobtime; + time_t jobtime,jobtime1; jobtime = time(NULL); /* default case: take current time */ if (count >= minimum) { @@ -181,7 +180,9 @@ static time_t EntryTime(string tok[], int ptr, int count, int minimum) t->tm_hour = hour; t->tm_min = min; t->tm_sec = sec; - jobtime = mktime(t); + jobtime1 = mktime(t); + if (jobtime1 != (time_t)-1) + jobtime = jobtime1; } } return jobtime; @@ -596,6 +597,76 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first) } +/**************************************************************************** + parse a lpq line for the plp printing system + Bertrand Wallrich <Bertrand.Wallrich@loria.fr> + +redone by tridge. Here is a sample queue: + +Local Printer 'lp2' (fjall): + Printing (started at Jun 15 13:33:58, attempt 1). + Rank Owner Pr Opt Job Host Files Size Date + active tridge X - 6 fjall /etc/hosts 739 Jun 15 13:33 + 3rd tridge X - 7 fjall /etc/hosts 739 Jun 15 13:33 + +****************************************************************************/ +static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first) +{ + string tok[11]; + int count=0; + + /* handle the case of "(standard input)" as a filename */ + string_sub(line,"stdin","STDIN"); + string_sub(line,"(","\""); + string_sub(line,")","\""); + + for (count=0; count<11 && next_token(&line,tok[count],NULL); count++) ; + + /* we must get 11 tokens */ + if (count < 11) + return(False); + + /* the first must be "active" or begin with an integer */ + if (strcmp(tok[0],"active") && !isdigit(tok[0][0])) + return(False); + + /* the 5th and 8th must be integer */ + if (!isdigit(*tok[4]) || !isdigit(*tok[7])) + return(False); + + /* if the fname contains a space then use STDIN */ + if (strchr(tok[6],' ')) + strcpy(tok[6],"STDIN"); + + /* only take the last part of the filename */ + { + string tmp; + char *p = strrchr(tok[6],'/'); + if (p) + { + strcpy(tmp,p+1); + strcpy(tok[6],tmp); + } + } + + + buf->job = atoi(tok[4]); + + buf->size = atoi(tok[7]); + if (strchr(tok[7],'K')) + buf->size *= 1024; + if (strchr(tok[7],'M')) + buf->size *= 1024*1024; + + buf->status = strequal(tok[0],"active")?LPQ_PRINTING:LPQ_QUEUED; + buf->priority = 0; + buf->time = time(NULL); + StrnCpy(buf->user,tok[1],sizeof(buf->user)-1); + StrnCpy(buf->file,tok[6],sizeof(buf->file)-1); + return(True); +} + + char *stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL }; char *stat1_strings[] = { "offline", "disabled", "down", "off", "waiting", "no daemon", NULL }; @@ -624,6 +695,9 @@ static BOOL parse_lpq_entry(int snum,char *line, case PRINT_QNX: ret = parse_lpq_qnx(line,buf,first); break; + case PRINT_PLP: + ret = parse_lpq_plp(line,buf,first); + break; default: ret = parse_lpq_bsd(line,buf,first); break; |