summaryrefslogtreecommitdiffstats
path: root/source/printing/lpq_parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/printing/lpq_parse.c')
-rw-r--r--source/printing/lpq_parse.c108
1 files changed, 55 insertions, 53 deletions
diff --git a/source/printing/lpq_parse.c b/source/printing/lpq_parse.c
index 1307cdb3f8d..96484eaf583 100644
--- a/source/printing/lpq_parse.c
+++ b/source/printing/lpq_parse.c
@@ -1,7 +1,9 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 3.0
lpq parsing routines
Copyright (C) Andrew Tridgell 2000
+ Copyright (C) 2002 by Martin Pool
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,6 +22,7 @@
#include "includes.h"
+
static char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Err"};
@@ -126,7 +129,6 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
}
#endif /* OSF1 */
- /* FIXME: Use next_token rather than strtok! */
tok[0] = strtok(line2," \t");
count++;
@@ -145,18 +147,18 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
buf->size = atoi(tok[TOTALTOK]);
buf->status = strequal(tok[RANKTOK],"active")?LPQ_PRINTING:LPQ_QUEUED;
buf->time = time(NULL);
- StrnCpy(buf->fs_user,tok[USERTOK],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[FILETOK],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user,tok[USERTOK]);
+ fstrcpy(buf->fs_file,tok[FILETOK]);
if ((FILETOK + 1) != TOTALTOK) {
int i;
for (i = (FILETOK + 1); i < TOTALTOK; i++) {
- /* FIXME: Using fstrcat rather than other means is a bit
- * inefficient; this might be a problem for enormous queues with
- * many fields. */
- fstrcat(buf->fs_file, " ");
- fstrcat(buf->fs_file, tok[i]);
+ /* FIXME: Using fstrcat rather than other means is a bit
+ * inefficient; this might be a problem for enormous queues with
+ * many fields. */
+ fstrcat(buf->fs_file, " ");
+ fstrcat(buf->fs_file, tok[i]);
}
/* Ensure null termination. */
fstrterminate(buf->fs_file);
@@ -267,17 +269,17 @@ static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
buf->time = LPRng_time(tokarr[LPRNG_TIMETOK]);
- StrnCpy(buf->fs_user,tokarr[LPRNG_USERTOK],sizeof(buf->fs_user)-1);
+ fstrcpy(buf->fs_user,tokarr[LPRNG_USERTOK]);
/* The '@hostname' prevents windows from displaying the printing icon
* for the current user on the taskbar. Plop in a null.
*/
- if ((cptr = strchr_m(buf->fs_user,'@')) != NULL) {
+ if ((cptr = strchr(buf->fs_user,'@')) != NULL) {
*cptr = '\0';
}
- StrnCpy(buf->fs_file,tokarr[LPRNG_FILETOK],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_file,tokarr[LPRNG_FILETOK]);
if ((LPRNG_FILETOK + 1) != LPRNG_TOTALTOK) {
int i;
@@ -316,7 +318,7 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
int count=0;
/* handle the case of "(standard input)" as a filename */
- string_sub(line,"standard input","STDIN",0);
+ pstring_sub(line,"standard input","STDIN");
all_string_sub(line,"(","\"",0);
all_string_sub(line,")","\"",0);
@@ -334,13 +336,13 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4])) return(False);
buf->size = atoi(tok[4]) * 1024;
/* if the fname contains a space then use STDIN */
- if (strchr_m(tok[2],' '))
+ if (strchr(tok[2],' '))
fstrcpy(tok[2],"STDIN");
/* only take the last part of the filename */
{
fstring tmp;
- char *p = strrchr_m(tok[2],'/');
+ char *p = strrchr(tok[2],'/');
if (p)
{
fstrcpy(tmp,p+1);
@@ -353,8 +355,8 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[0],"HELD")?LPQ_PAUSED:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->fs_user,tok[3],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[2],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user, tok[3]);
+ fstrcpy(buf->fs_file, tok[2]);
}
else
{
@@ -368,13 +370,13 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
if (!isdigit((int)*tok[3]) || !isdigit((int)*tok[8])) return(False);
buf->size = atoi(tok[8]) * 1024;
/* if the fname contains a space then use STDIN */
- if (strchr_m(tok[4],' '))
+ if (strchr(tok[4],' '))
fstrcpy(tok[4],"STDIN");
/* only take the last part of the filename */
{
fstring tmp;
- char *p = strrchr_m(tok[4],'/');
+ char *p = strrchr(tok[4],'/');
if (p)
{
fstrcpy(tmp,p+1);
@@ -387,8 +389,8 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[2],"RUNNING")?LPQ_PRINTING:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->fs_user,tok[5],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[4],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user, tok[5]);
+ fstrcpy(buf->fs_file, tok[4]);
}
@@ -433,7 +435,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
}
if (!header_line_ok) return (False); /* incorrect header line */
/* handle the case of "(standard input)" as a filename */
- string_sub(line,"standard input","STDIN",0);
+ pstring_sub(line,"standard input","STDIN");
all_string_sub(line,"(","\"",0);
all_string_sub(line,")","\"",0);
@@ -445,18 +447,18 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
if (!isdigit((int)*tok[1])) return(False);
/* if the fname contains a space then use STDIN */
- if (strchr_m(tok[0],' '))
+ if (strchr(tok[0],' '))
fstrcpy(tok[0],"STDIN");
buf->size = atoi(tok[1]);
- StrnCpy(buf->fs_file,tok[0],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_file,tok[0]);
/* fill things from header line */
buf->time = jobtime;
buf->job = jobid;
buf->status = jobstat;
buf->priority = jobprio;
- StrnCpy(buf->fs_user,jobuser,sizeof(buf->fs_user)-1);
+ fstrcpy(buf->fs_user, jobuser);
return(True);
}
@@ -471,7 +473,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
else if (base_prio) base_prio_reset=False;
/* handle the dash in the job id */
- string_sub(line,"-"," ",0);
+ pstring_sub(line,"-"," ");
for (count=0; count<12 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
@@ -482,7 +484,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
/* the 2nd, 5th & 7th column must be integer */
if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4]) || !isdigit((int)*tok[6])) return(False);
jobid = atoi(tok[1]);
- StrnCpy(jobuser,tok[2],sizeof(buf->fs_user)-1);
+ fstrcpy(jobuser, tok[2]);
jobprio = atoi(tok[4]);
/* process time */
@@ -556,7 +558,7 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
return(False);
/* if the user contains a ! then trim the first part of it */
- if ((p=strchr_m(tok[2],'!'))) {
+ if ((p=strchr(tok[2],'!'))) {
fstring tmp;
fstrcpy(tmp,p+1);
fstrcpy(tok[2],tmp);
@@ -572,8 +574,8 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
buf->status = LPQ_QUEUED;
buf->priority = 0;
buf->time = EntryTime(tok, 4, count, 7);
- StrnCpy(buf->fs_user,tok[2],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[2],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user, tok[2]);
+ fstrcpy(buf->fs_file, tok[2]);
return(True);
}
@@ -595,14 +597,14 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
DEBUG(4,("antes [%s]\n", line));
/* handle the case of "-- standard input --" as a filename */
- string_sub(line,"standard input","STDIN",0);
+ pstring_sub(line,"standard input","STDIN");
DEBUG(4,("despues [%s]\n", line));
all_string_sub(line,"-- ","\"",0);
all_string_sub(line," --","\"",0);
DEBUG(4,("despues 1 [%s]\n", line));
- string_sub(line,"[job #","",0);
- string_sub(line,"]","",0);
+ pstring_sub(line,"[job #","");
+ pstring_sub(line,"]","");
DEBUG(4,("despues 2 [%s]\n", line));
@@ -619,7 +621,7 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
/* only take the last part of the filename */
{
fstring tmp;
- char *p = strrchr_m(tok[6],'/');
+ char *p = strrchr(tok[6],'/');
if (p)
{
fstrcpy(tmp,p+1);
@@ -633,8 +635,8 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->fs_user,tok[1],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[6],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user,tok[1]);
+ fstrcpy(buf->fs_file,tok[6]);
return(True);
}
@@ -658,7 +660,7 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
int count=0;
/* handle the case of "(standard input)" as a filename */
- string_sub(line,"stdin","STDIN",0);
+ pstring_sub(line,"stdin","STDIN");
all_string_sub(line,"(","\"",0);
all_string_sub(line,")","\"",0);
@@ -677,13 +679,13 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
return(False);
/* if the fname contains a space then use STDIN */
- if (strchr_m(tok[6],' '))
+ if (strchr(tok[6],' '))
fstrcpy(tok[6],"STDIN");
/* only take the last part of the filename */
{
fstring tmp;
- char *p = strrchr_m(tok[6],'/');
+ char *p = strrchr(tok[6],'/');
if (p)
{
fstrcpy(tmp,p+1);
@@ -695,16 +697,16 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
buf->job = atoi(tok[4]);
buf->size = atoi(tok[7]);
- if (strchr_m(tok[7],'K'))
+ if (strchr(tok[7],'K'))
buf->size *= 1024;
- if (strchr_m(tok[7],'M'))
+ 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->fs_user,tok[1],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[6],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user,tok[1]);
+ fstrcpy(buf->fs_file,tok[6]);
return(True);
}
@@ -728,7 +730,7 @@ static BOOL parse_lpq_softq(char *line,print_queue_struct *buf,BOOL first)
int count=0;
/* mung all the ":"s to spaces*/
- string_sub(line,":"," ",0);
+ pstring_sub(line,":"," ");
for (count=0; count<10 && next_token(&line,tok[count],NULL,sizeof(tok[count])); count++) ;
@@ -760,8 +762,8 @@ static BOOL parse_lpq_softq(char *line,print_queue_struct *buf,BOOL first)
buf->job = atoi(tok[0]);
buf->size = atoi(tok[count+6]);
buf->priority = atoi(tok[count+5]);
- StrnCpy(buf->fs_user,tok[count+7],sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file,tok[count+8],sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user,tok[count+7]);
+ fstrcpy(buf->fs_file,tok[count+8]);
buf->time = time(NULL); /* default case: take current time */
{
time_t jobtime;
@@ -833,8 +835,8 @@ static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
return(False);
/* Just want the first word in the owner field - the username */
- if (strchr_m(parse_line.owner, ' '))
- *(strchr_m(parse_line.owner, ' ')) = '\0';
+ if (strchr(parse_line.owner, ' '))
+ *(strchr(parse_line.owner, ' ')) = '\0';
else
parse_line.space1 = '\0';
@@ -857,8 +859,8 @@ static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
buf->priority = 0;
buf->size = atoi(parse_line.size);
buf->time = time(NULL);
- StrnCpy(buf->fs_user, parse_line.owner, sizeof(buf->fs_user)-1);
- StrnCpy(buf->fs_file, parse_line.jobname, sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_user, parse_line.owner);
+ fstrcpy(buf->fs_file, parse_line.jobname);
if (strequal(parse_line.status, LPRNT_PRINTING))
buf->status = LPQ_PRINTING;
else if (strequal(parse_line.status, LPRNT_PAUSED))
@@ -916,7 +918,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
/* Get the job name */
parse_line.space2[0] = '\0';
trim_string(parse_line.jobname, NULL, " ");
- StrnCpy(buf->fs_file, parse_line.jobname, sizeof(buf->fs_file)-1);
+ fstrcpy(buf->fs_file, parse_line.jobname);
buf->priority = 0;
buf->size = atoi(parse_line.size);
@@ -934,7 +936,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
!strequal(parse_line.status, LPROS2_WAITING))
return(False);
- StrnCpy(buf->fs_user, parse_line.owner, sizeof(buf->fs_user)-1);
+ fstrcpy(buf->fs_user, parse_line.owner);
if (strequal(parse_line.status, LPROS2_PRINTING))
buf->status = LPQ_PRINTING;
else if (strequal(parse_line.status, LPROS2_PAUSED))
@@ -1045,7 +1047,7 @@ BOOL parse_lpq_entry(int snum,char *line,
/* We don't want the newline in the status message. */
{
- char *p = strchr_m(line,'\n');
+ char *p = strchr(line,'\n');
if (p) *p = 0;
}