printing/lpq_parse.c

ソースコードを見る。

関数

static time_t EntryTime (fstring tok[], int ptr, int count, int minimum)
static BOOL parse_lpq_bsd (char *line, print_queue_struct *buf, BOOL first)
static time_t LPRng_time (char *time_string)
static BOOL parse_lpq_lprng (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_aix (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_hpux (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_sysv (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_qnx (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_plp (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_nt (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_os2 (char *line, print_queue_struct *buf, BOOL first)
static BOOL parse_lpq_vlp (char *line, print_queue_struct *buf, BOOL first)
BOOL parse_lpq_entry (enum printing_types printing_type, char *line, print_queue_struct *buf, print_status_struct *status, BOOL first)

変数

static const char * Months [13]
static const char * stat0_strings [] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL }
static const char * stat1_strings [] = { "offline", "disabled", "down", "off", "waiting", "no daemon", NULL }
static const char * stat2_strings [] = { "jam", "paper", "error", "responding", "not accepting", "not running", "turned off", NULL }


関数

static time_t EntryTime ( fstring  tok[],
int  ptr,
int  count,
int  minimum 
) [static]

lpq_parse.c31 行で定義されています。

参照先 clocaltime()mktime()Monthst.

参照元 parse_lpq_hpux()parse_lpq_sysv().

00032 {
00033         time_t jobtime,jobtime1;
00034 
00035         jobtime = time(NULL);           /* default case: take current time */
00036         if (count >= minimum) {
00037                 struct tm *t;
00038                 int i, day, hour, min, sec;
00039                 char   *c;
00040 
00041                 for (i=0; i<13; i++) {
00042                         if (!strncmp(tok[ptr], Months[i],3)) {
00043                                 break; /* Find month */
00044                         }
00045                 }
00046 
00047                 if (i<12) {
00048                         t = localtime(&jobtime);
00049                         if (!t) {
00050                                 return (time_t)-1;
00051                         }
00052                         day = atoi(tok[ptr+1]);
00053                         c=(char *)(tok[ptr+2]);
00054                         *(c+2)=0;
00055                         hour = atoi(c);
00056                         *(c+5)=0;
00057                         min = atoi(c+3);
00058                         if(*(c+6) != 0) {
00059                                 sec = atoi(c+6);
00060                         } else {
00061                                 sec=0;
00062                         }
00063 
00064                         if ((t->tm_mon < i)|| ((t->tm_mon == i)&&
00065                                         ((t->tm_mday < day)||
00066                                         ((t->tm_mday == day)&&
00067                                         (t->tm_hour*60+t->tm_min < hour*60+min))))) {
00068                                 t->tm_year--;           /* last year's print job */
00069                         }
00070 
00071                         t->tm_mon = i;
00072                         t->tm_mday = day;
00073                         t->tm_hour = hour;
00074                         t->tm_min = min;
00075                         t->tm_sec = sec;
00076                         jobtime1 = mktime(t);
00077                         if (jobtime1 != (time_t)-1) {
00078                                 jobtime = jobtime1;
00079                         }
00080                 }
00081         }
00082         return jobtime;
00083 }

static BOOL parse_lpq_bsd ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c106 行で定義されています。

参照先 bufLPQ_PRINTINGLPQ_QUEUEDstrequal().

参照元 parse_lpq_entry().

00107 {
00108 #ifdef  OSF1
00109 #define RANKTOK 0
00110 #define PRIOTOK 1
00111 #define USERTOK 2
00112 #define JOBTOK  3
00113 #define FILETOK 4
00114 #define TOTALTOK (count - 2)
00115 #define NTOK    6
00116 #define MAXTOK  128
00117 #else   /* OSF1 */
00118 #define RANKTOK 0
00119 #define USERTOK 1
00120 #define JOBTOK  2
00121 #define FILETOK 3
00122 #define TOTALTOK (count - 2)
00123 #define NTOK    5
00124 #define MAXTOK  128
00125 #endif  /* OSF1 */
00126 
00127         char *tok[MAXTOK];
00128         int  count = 0;
00129         pstring line2;
00130 
00131         pstrcpy(line2,line);
00132 
00133 #ifdef  OSF1
00134         {
00135                 size_t length;
00136                 length = strlen(line2);
00137                 if (line2[length-3] == ':') {
00138                         return False;
00139                 }
00140         }
00141 #endif  /* OSF1 */
00142 
00143         /* FIXME: Use next_token rather than strtok! */
00144         tok[0] = strtok(line2," \t");
00145         count++;
00146 
00147         while ((count < MAXTOK) && ((tok[count] = strtok(NULL," \t")) != NULL)) {
00148                 count++;
00149         }
00150 
00151         /* we must get at least NTOK tokens */
00152         if (count < NTOK) {
00153                 return False;
00154         }
00155 
00156         /* the Job and Total columns must be integer */
00157         if (!isdigit((int)*tok[JOBTOK]) || !isdigit((int)*tok[TOTALTOK])) {
00158                 return False;
00159         }
00160 
00161         buf->job = atoi(tok[JOBTOK]);
00162         buf->size = atoi(tok[TOTALTOK]);
00163         buf->status = strequal(tok[RANKTOK],"active")?LPQ_PRINTING:LPQ_QUEUED;
00164         buf->time = time(NULL);
00165         fstrcpy(buf->fs_user,tok[USERTOK]);
00166         fstrcpy(buf->fs_file,tok[FILETOK]);
00167 
00168         if ((FILETOK + 1) != TOTALTOK) {
00169                 int i;
00170 
00171                 for (i = (FILETOK + 1); i < TOTALTOK; i++) {
00172                         /* FIXME: Using fstrcat rather than other means is a bit
00173                          * inefficient; this might be a problem for enormous queues with
00174                          * many fields. */
00175                         fstrcat(buf->fs_file, " ");
00176                         fstrcat(buf->fs_file, tok[i]);
00177                 }
00178                 /* Ensure null termination. */
00179                 fstrterminate(buf->fs_file);
00180         }
00181 
00182 #ifdef PRIOTOK
00183         buf->priority = atoi(tok[PRIOTOK]);
00184 #else
00185         buf->priority = 1;
00186 #endif
00187         return True;
00188 }

static time_t LPRng_time ( char *  time_string  )  [static]

lpq_parse.c207 行で定義されています。

参照先 localtime()mktime()t.

参照元 parse_lpq_lprng().

00208 {
00209         time_t jobtime;
00210         struct tm *t;
00211 
00212         jobtime = time(NULL);         /* default case: take current time */
00213         t = localtime(&jobtime);
00214         if (!t) {
00215                 return (time_t)-1;
00216         }
00217 
00218         if ( atoi(time_string) < 24 ){
00219                 t->tm_hour = atoi(time_string);
00220                 t->tm_min = atoi(time_string+3);
00221                 t->tm_sec = atoi(time_string+6);
00222         } else {
00223                 t->tm_year = atoi(time_string)-1900;
00224                 t->tm_mon = atoi(time_string+5)-1;
00225                 t->tm_mday = atoi(time_string+8);
00226                 t->tm_hour = atoi(time_string+11);
00227                 t->tm_min = atoi(time_string+14);
00228                 t->tm_sec = atoi(time_string+17);
00229         }    
00230         jobtime = mktime(t);
00231 
00232         return jobtime;
00233 }

static BOOL parse_lpq_lprng ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c243 行で定義されています。

参照先 bufLPQ_PAUSEDLPQ_PRINTEDLPQ_PRINTINGLPQ_QUEUEDLPRng_time()next_token()strchr_m()strequal().

参照元 parse_lpq_entry().

00244 {
00245 #define LPRNG_RANKTOK   0
00246 #define LPRNG_USERTOK   1
00247 #define LPRNG_PRIOTOK   2
00248 #define LPRNG_JOBTOK    3
00249 #define LPRNG_FILETOK   4
00250 #define LPRNG_TOTALTOK  (num_tok - 2)
00251 #define LPRNG_TIMETOK   (num_tok - 1)
00252 #define LPRNG_NTOK      7
00253 #define LPRNG_MAXTOK    128 /* PFMA just to keep us from running away. */
00254 
00255         fstring tokarr[LPRNG_MAXTOK];
00256         const char *cptr;
00257         char *ptr;
00258         int num_tok = 0;
00259 
00260         cptr = line;
00261         while((num_tok < LPRNG_MAXTOK) && next_token( &cptr, tokarr[num_tok], " \t", sizeof(fstring))) {
00262                 num_tok++;
00263         }
00264 
00265         /* We must get at least LPRNG_NTOK tokens. */
00266         if (num_tok < LPRNG_NTOK) {
00267                 return False;
00268         }
00269 
00270         if (!isdigit((int)*tokarr[LPRNG_JOBTOK]) || !isdigit((int)*tokarr[LPRNG_TOTALTOK])) {
00271                 return False;
00272         }
00273 
00274         buf->job  = atoi(tokarr[LPRNG_JOBTOK]);
00275         buf->size = atoi(tokarr[LPRNG_TOTALTOK]);
00276 
00277         if (strequal(tokarr[LPRNG_RANKTOK],"active")) {
00278                 buf->status = LPQ_PRINTING;
00279         } else if (strequal(tokarr[LPRNG_RANKTOK],"done")) {
00280                 buf->status = LPQ_PRINTED;
00281         } else if (isdigit((int)*tokarr[LPRNG_RANKTOK])) {
00282                 buf->status = LPQ_QUEUED;
00283         } else {
00284                 buf->status = LPQ_PAUSED;
00285         }
00286 
00287         buf->priority = *tokarr[LPRNG_PRIOTOK] -'A';
00288 
00289         buf->time = LPRng_time(tokarr[LPRNG_TIMETOK]);
00290 
00291         fstrcpy(buf->fs_user,tokarr[LPRNG_USERTOK]);
00292 
00293         /* The '@hostname' prevents windows from displaying the printing icon
00294          * for the current user on the taskbar.  Plop in a null.
00295          */
00296 
00297         if ((ptr = strchr_m(buf->fs_user,'@')) != NULL) {
00298                 *ptr = '\0';
00299         }
00300 
00301         fstrcpy(buf->fs_file,tokarr[LPRNG_FILETOK]);
00302 
00303         if ((LPRNG_FILETOK + 1) != LPRNG_TOTALTOK) {
00304                 int i;
00305 
00306                 for (i = (LPRNG_FILETOK + 1); i < LPRNG_TOTALTOK; i++) {
00307                         /* FIXME: Using fstrcat rather than other means is a bit
00308                          * inefficient; this might be a problem for enormous queues with
00309                          * many fields. */
00310                         fstrcat(buf->fs_file, " ");
00311                         fstrcat(buf->fs_file, tokarr[i]);
00312                 }
00313                 /* Ensure null termination. */
00314                 fstrterminate(buf->fs_file);
00315         }
00316 
00317         return True;
00318 }

static BOOL parse_lpq_aix ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c333 行で定義されています。

参照先 all_string_sub()bufLPQ_PAUSEDLPQ_PRINTINGLPQ_QUEUEDnext_token()strchr_m()strequal()string_sub()strrchr_m().

参照元 parse_lpq_entry().

00334 {
00335         fstring tok[11];
00336         int count=0;
00337         const char *cline = line;
00338 
00339         /* handle the case of "(standard input)" as a filename */
00340         string_sub(line,"standard input","STDIN",0);
00341         all_string_sub(line,"(","\"",0);
00342         all_string_sub(line,")","\"",0);
00343 
00344         for (count=0; count<10 && next_token(&cline,tok[count],NULL, sizeof(tok[count])); count++) {
00345                 ;
00346         }
00347 
00348         /* we must get 6 tokens */
00349         if (count < 10) {
00350                 if ((count == 7) && ((strcmp(tok[0],"QUEUED") == 0) || (strcmp(tok[0],"HELD") == 0))) {
00351                         /* the 2nd and 5th columns must be integer */
00352                         if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4])) {
00353                                 return False;
00354                         }
00355                         buf->size = atoi(tok[4]) * 1024;
00356                         /* if the fname contains a space then use STDIN */
00357                         if (strchr_m(tok[2],' ')) {
00358                                 fstrcpy(tok[2],"STDIN");
00359                         }
00360 
00361                         /* only take the last part of the filename */
00362                         {
00363                                 fstring tmp;
00364                                 char *p = strrchr_m(tok[2],'/');
00365                                 if (p) {
00366                                         fstrcpy(tmp,p+1);
00367                                         fstrcpy(tok[2],tmp);
00368                                 }
00369                         }
00370 
00371                         buf->job = atoi(tok[1]);
00372                         buf->status = strequal(tok[0],"HELD")?LPQ_PAUSED:LPQ_QUEUED;
00373                         buf->priority = 0;
00374                         buf->time = time(NULL);
00375                         fstrcpy(buf->fs_user,tok[3]);
00376                         fstrcpy(buf->fs_file,tok[2]);
00377                 } else {
00378                         DEBUG(6,("parse_lpq_aix count=%d\n", count));
00379                         return False;
00380                 }
00381         } else {
00382                 /* the 4th and 9th columns must be integer */
00383                 if (!isdigit((int)*tok[3]) || !isdigit((int)*tok[8])) {
00384                         return False;
00385                 }
00386 
00387                 buf->size = atoi(tok[8]) * 1024;
00388                 /* if the fname contains a space then use STDIN */
00389                 if (strchr_m(tok[4],' ')) {
00390                         fstrcpy(tok[4],"STDIN");
00391                 }
00392 
00393                 /* only take the last part of the filename */
00394                 {
00395                         fstring tmp;
00396                         char *p = strrchr_m(tok[4],'/');
00397                         if (p) {
00398                                 fstrcpy(tmp,p+1);
00399                                 fstrcpy(tok[4],tmp);
00400                         }
00401                 }
00402 
00403                 buf->job = atoi(tok[3]);
00404                 buf->status = strequal(tok[2],"RUNNING")?LPQ_PRINTING:LPQ_QUEUED;
00405                 buf->priority = 0;
00406                 buf->time = time(NULL);
00407                 fstrcpy(buf->fs_user,tok[5]);
00408                 fstrcpy(buf->fs_file,tok[4]);
00409         }
00410 
00411         return True;
00412 }

static BOOL parse_lpq_hpux ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c425 行で定義されています。

参照先 all_string_sub()bufEntryTime()LPQ_PAUSEDLPQ_PRINTINGLPQ_QUEUEDnext_token()strchr_m()strequal()string_sub().

参照元 parse_lpq_entry().

00426 {
00427         /* must read two lines to process, therefore keep some values static */
00428         static BOOL header_line_ok=False, base_prio_reset=False;
00429         static fstring jobuser;
00430         static int jobid;
00431         static int jobprio;
00432         static time_t jobtime;
00433         static int jobstat=LPQ_QUEUED;
00434         /* to store minimum priority to print, lpstat command should be invoked
00435                 with -p option first, to work */
00436         static int base_prio;
00437         int count;
00438         char htab = '\011';  
00439         const char *cline = line;
00440         fstring tok[12];
00441 
00442         /* If a line begins with a horizontal TAB, it is a subline type */
00443   
00444         if (line[0] == htab) { /* subline */
00445                 /* check if it contains the base priority */
00446                 if (!strncmp(line,"\tfence priority : ",18)) {
00447                         base_prio=atoi(&line[18]);
00448                         DEBUG(4, ("fence priority set at %d\n", base_prio));
00449                 }
00450 
00451                 if (!header_line_ok) {
00452                         return  False; /* incorrect header line */
00453                 }
00454 
00455                 /* handle the case of "(standard input)" as a filename */
00456                 string_sub(line,"standard input","STDIN",0);
00457                 all_string_sub(line,"(","\"",0);
00458                 all_string_sub(line,")","\"",0);
00459     
00460                 for (count=0; count<2 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
00461                         ;
00462                 }
00463                 /* we must get 2 tokens */
00464                 if (count < 2) {
00465                         return False;
00466                 }
00467     
00468                 /* the 2nd column must be integer */
00469                 if (!isdigit((int)*tok[1])) {
00470                         return False;
00471                 }
00472     
00473                 /* if the fname contains a space then use STDIN */
00474                 if (strchr_m(tok[0],' ')) {
00475                         fstrcpy(tok[0],"STDIN");
00476                 }
00477     
00478                 buf->size = atoi(tok[1]);
00479                 fstrcpy(buf->fs_file,tok[0]);
00480     
00481                 /* fill things from header line */
00482                 buf->time = jobtime;
00483                 buf->job = jobid;
00484                 buf->status = jobstat;
00485                 buf->priority = jobprio;
00486                 fstrcpy(buf->fs_user,jobuser);
00487     
00488                 return True;
00489         } else { /* header line */
00490                 header_line_ok=False; /* reset it */
00491                 if (first) {
00492                         if (!base_prio_reset) {
00493                                 base_prio=0; /* reset it */
00494                                 base_prio_reset=True;
00495                         }
00496                 } else if (base_prio) {
00497                         base_prio_reset=False;
00498                 }
00499     
00500                 /* handle the dash in the job id */
00501                 string_sub(line,"-"," ",0);
00502     
00503                 for (count=0; count<12 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
00504                         ;
00505                 }
00506       
00507                 /* we must get 8 tokens */
00508                 if (count < 8) {
00509                         return False;
00510                 }
00511     
00512                 /* first token must be printer name (cannot check ?) */
00513                 /* the 2nd, 5th & 7th column must be integer */
00514                 if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4]) || !isdigit((int)*tok[6])) {
00515                         return False;
00516                 }
00517                 jobid = atoi(tok[1]);
00518                 fstrcpy(jobuser,tok[2]);
00519                 jobprio = atoi(tok[4]);
00520     
00521                 /* process time */
00522                 jobtime=EntryTime(tok, 5, count, 8);
00523                 if (jobprio < base_prio) {
00524                         jobstat = LPQ_PAUSED;
00525                         DEBUG (4, ("job %d is paused: prio %d < %d; jobstat=%d\n",
00526                                 jobid, jobprio, base_prio, jobstat));
00527                 } else {
00528                         jobstat = LPQ_QUEUED;
00529                         if ((count >8) && (((strequal(tok[8],"on")) ||
00530                                         ((strequal(tok[8],"from")) && 
00531                                         ((count > 10)&&(strequal(tok[10],"on"))))))) {
00532                                 jobstat = LPQ_PRINTING;
00533                         }
00534                 }
00535     
00536                 header_line_ok=True; /* information is correct */
00537                 return False; /* need subline info to include into queuelist */
00538         }
00539 }

static BOOL parse_lpq_sysv ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c551 行で定義されています。

参照先 bufEntryTime()LPQ_PAUSEDLPQ_PRINTINGLPQ_QUEUEDnext_token()strchr_m()strequal().

参照元 parse_lpq_entry().

00552 {
00553         fstring tok[9];
00554         int count=0;
00555         char *p;
00556         const char *cline = line;
00557 
00558         /* 
00559          * Handle the dash in the job id, but make sure that we skip over
00560          * the printer name in case we have a dash in that.
00561          * Patch from Dom.Mitchell@palmerharvey.co.uk.
00562          */
00563 
00564         /*
00565          * Move to the first space.
00566          */
00567         for (p = line ; !isspace(*p) && *p; p++) {
00568                 ;
00569         }
00570 
00571         /*
00572          * Back up until the last '-' character or
00573          * start of line.
00574          */
00575         for (; (p >= line) && (*p != '-'); p--) {
00576                 ;
00577         }
00578 
00579         if((p >= line) && (*p == '-')) {
00580                 *p = ' ';
00581         }
00582 
00583         for (count=0; count<9 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
00584                 ;
00585         }
00586 
00587         /* we must get 7 tokens */
00588         if (count < 7) {
00589                 return False;
00590         }
00591 
00592         /* the 2nd and 4th, 6th columns must be integer */
00593         if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[3])) {
00594                 return False;
00595         }
00596         if (!isdigit((int)*tok[5])) {
00597                 return False;
00598         }
00599 
00600         /* if the user contains a ! then trim the first part of it */  
00601         if ((p=strchr_m(tok[2],'!'))) {
00602                 fstring tmp;
00603                 fstrcpy(tmp,p+1);
00604                 fstrcpy(tok[2],tmp);
00605         }
00606 
00607         buf->job = atoi(tok[1]);
00608         buf->size = atoi(tok[3]);
00609         if (count > 7 && strequal(tok[7],"on")) {
00610                 buf->status = LPQ_PRINTING;
00611         } else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held")) {
00612                 buf->status = LPQ_PAUSED;
00613         } else {
00614                 buf->status = LPQ_QUEUED;
00615         }
00616         buf->priority = 0;
00617         buf->time = EntryTime(tok, 4, count, 7);
00618         fstrcpy(buf->fs_user,tok[2]);
00619         fstrcpy(buf->fs_file,tok[2]);
00620         return True;
00621 }

static BOOL parse_lpq_qnx ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c634 行で定義されています。

参照先 all_string_sub()bufLPQ_PRINTINGLPQ_QUEUEDnext_token()strequal()string_sub()strrchr_m().

参照元 parse_lpq_entry().

00635 {
00636         fstring tok[7];
00637         int count=0;
00638         const char *cline = line;
00639 
00640         DEBUG(4,("antes [%s]\n", line));
00641 
00642         /* handle the case of "-- standard input --" as a filename */
00643         string_sub(line,"standard input","STDIN",0);
00644         DEBUG(4,("despues [%s]\n", line));
00645         all_string_sub(line,"-- ","\"",0);
00646         all_string_sub(line," --","\"",0);
00647         DEBUG(4,("despues 1 [%s]\n", line));
00648 
00649         string_sub(line,"[job #","",0);
00650         string_sub(line,"]","",0);
00651         DEBUG(4,("despues 2 [%s]\n", line));
00652 
00653         for (count=0; count<7 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
00654                 ;
00655         }
00656 
00657         /* we must get 7 tokens */
00658         if (count < 7) {
00659                 return False;
00660         }
00661 
00662         /* the 3rd and 5th columns must be integer */
00663         if (!isdigit((int)*tok[2]) || !isdigit((int)*tok[4])) {
00664                 return False;
00665         }
00666 
00667         /* only take the last part of the filename */
00668         {
00669                 fstring tmp;
00670                 char *p = strrchr_m(tok[6],'/');
00671                 if (p) {
00672                         fstrcpy(tmp,p+1);
00673                         fstrcpy(tok[6],tmp);
00674                 }
00675         }
00676         
00677         buf->job = atoi(tok[2]);
00678         buf->size = atoi(tok[4]);
00679         buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
00680         buf->priority = 0;
00681         buf->time = time(NULL);
00682         fstrcpy(buf->fs_user,tok[1]);
00683         fstrcpy(buf->fs_file,tok[6]);
00684         return True;
00685 }

static BOOL parse_lpq_plp ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c701 行で定義されています。

参照先 all_string_sub()bufLPQ_PRINTINGLPQ_QUEUEDnext_token()strchr_m()strequal()string_sub()strrchr_m().

参照元 parse_lpq_entry().

00702 {
00703         fstring tok[11];
00704         int count=0;
00705         const char *cline = line;
00706 
00707         /* handle the case of "(standard input)" as a filename */
00708         string_sub(line,"stdin","STDIN",0);
00709         all_string_sub(line,"(","\"",0);
00710         all_string_sub(line,")","\"",0);
00711   
00712         for (count=0; count<11 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
00713                 ;
00714         }
00715 
00716         /* we must get 11 tokens */
00717         if (count < 11) {
00718                 return False;
00719         }
00720 
00721         /* the first must be "active" or begin with an integer */
00722         if (strcmp(tok[0],"active") && !isdigit((int)tok[0][0])) {
00723                 return False;
00724         }
00725 
00726         /* the 5th and 8th must be integer */
00727         if (!isdigit((int)*tok[4]) || !isdigit((int)*tok[7])) {
00728                 return False;
00729         }
00730 
00731         /* if the fname contains a space then use STDIN */
00732         if (strchr_m(tok[6],' ')) {
00733                 fstrcpy(tok[6],"STDIN");
00734         }
00735 
00736         /* only take the last part of the filename */
00737         {
00738                 fstring tmp;
00739                 char *p = strrchr_m(tok[6],'/');
00740                 if (p) {
00741                         fstrcpy(tmp,p+1);
00742                         fstrcpy(tok[6],tmp);
00743                 }
00744         }
00745 
00746         buf->job = atoi(tok[4]);
00747 
00748         buf->size = atoi(tok[7]);
00749         if (strchr_m(tok[7],'K')) {
00750                 buf->size *= 1024;
00751         }
00752         if (strchr_m(tok[7],'M')) {
00753                 buf->size *= 1024*1024;
00754         }
00755 
00756         buf->status = strequal(tok[0],"active")?LPQ_PRINTING:LPQ_QUEUED;
00757         buf->priority = 0;
00758         buf->time = time(NULL);
00759         fstrcpy(buf->fs_user,tok[1]);
00760         fstrcpy(buf->fs_file,tok[6]);
00761         return True;
00762 }

static BOOL parse_lpq_nt ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c778 行で定義されています。

参照先 bufLPQ_PAUSEDLPQ_PRINTINGLPQ_QUEUEDsizestatusstrchr_m()strequal()trim_char().

参照元 parse_lpq_entry().

00779 {
00780 #define LPRNT_OWNSIZ 11
00781 #define LPRNT_STATSIZ 9
00782 #define LPRNT_JOBSIZ 19
00783 #define LPRNT_IDSIZ 6
00784 #define LPRNT_SIZSIZ 9
00785         typedef struct {
00786                 char owner[LPRNT_OWNSIZ];
00787                 char space1;
00788                 char status[LPRNT_STATSIZ];
00789                 char space2;
00790                 char jobname[LPRNT_JOBSIZ];
00791                 char space3;
00792                 char jobid[LPRNT_IDSIZ];
00793                 char space4;
00794                 char size[LPRNT_SIZSIZ];
00795                 char terminator;
00796         } nt_lpq_line;
00797 
00798         nt_lpq_line parse_line;
00799 #define LPRNT_PRINTING "Printing"
00800 #define LPRNT_WAITING "Waiting"
00801 #define LPRNT_PAUSED "Paused"
00802 
00803         memset(&parse_line, '\0', sizeof(parse_line));
00804         strncpy((char *) &parse_line, line, sizeof(parse_line) -1);
00805 
00806         if (strlen((char *) &parse_line) != sizeof(parse_line) - 1) {
00807                 return False;
00808         }
00809 
00810         /* Just want the first word in the owner field - the username */
00811         if (strchr_m(parse_line.owner, ' ')) {
00812                 *(strchr_m(parse_line.owner, ' ')) = '\0';
00813         } else {
00814                 parse_line.space1 = '\0';
00815         }
00816 
00817         /* Make sure we have an owner */
00818         if (!strlen(parse_line.owner)) {
00819                 return False;
00820         }
00821 
00822         /* Make sure the status is valid */
00823         parse_line.space2 = '\0';
00824         trim_char(parse_line.status, '\0', ' ');
00825         if (!strequal(parse_line.status, LPRNT_PRINTING) &&
00826                         !strequal(parse_line.status, LPRNT_PAUSED) &&
00827                         !strequal(parse_line.status, LPRNT_WAITING)) {
00828                 return False;
00829         }
00830   
00831         parse_line.space3 = '\0';
00832         trim_char(parse_line.jobname, '\0', ' ');
00833 
00834         buf->job = atoi(parse_line.jobid);
00835         buf->priority = 0;
00836         buf->size = atoi(parse_line.size);
00837         buf->time = time(NULL);
00838         fstrcpy(buf->fs_user, parse_line.owner);
00839         fstrcpy(buf->fs_file, parse_line.jobname);
00840         if (strequal(parse_line.status, LPRNT_PRINTING)) {
00841                 buf->status = LPQ_PRINTING;
00842         } else if (strequal(parse_line.status, LPRNT_PAUSED)) {
00843                 buf->status = LPQ_PAUSED;
00844         } else {
00845                 buf->status = LPQ_QUEUED;
00846         }
00847 
00848         return True;
00849 }

static BOOL parse_lpq_os2 ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c861 行で定義されています。

参照先 bufLPQ_PAUSEDLPQ_PRINTINGLPQ_QUEUEDsizestatusstrequal()trim_char().

参照元 parse_lpq_entry().

00862 {
00863 #define LPROS2_IDSIZ 5
00864 #define LPROS2_JOBSIZ 15
00865 #define LPROS2_SIZSIZ 8
00866 #define LPROS2_STATSIZ 12
00867 #define LPROS2_OWNSIZ 12
00868         typedef struct {
00869                 char jobid[LPROS2_IDSIZ];
00870                 char space1[2];
00871                 char jobname[LPROS2_JOBSIZ];
00872                 char space2[14];
00873                 char size[LPROS2_SIZSIZ];
00874                 char space3[4];
00875                 char status[LPROS2_STATSIZ];
00876                 char space4[4];
00877                 char owner[LPROS2_OWNSIZ];
00878                 char terminator;
00879         } os2_lpq_line;
00880 
00881         os2_lpq_line parse_line;
00882 #define LPROS2_PRINTING "Printing"
00883 #define LPROS2_WAITING "Queued"
00884 #define LPROS2_PAUSED "Paused"
00885 
00886         memset(&parse_line, '\0', sizeof(parse_line));
00887         strncpy((char *) &parse_line, line, sizeof(parse_line) -1);
00888 
00889         if (strlen((char *) &parse_line) != sizeof(parse_line) - 1) {
00890                 return False;
00891         }
00892 
00893         /* Get the jobid */
00894         buf->job = atoi(parse_line.jobid);
00895 
00896         /* Get the job name */
00897         parse_line.space2[0] = '\0';
00898         trim_char(parse_line.jobname, '\0', ' ');
00899         fstrcpy(buf->fs_file, parse_line.jobname);
00900 
00901         buf->priority = 0;
00902         buf->size = atoi(parse_line.size);
00903         buf->time = time(NULL);
00904 
00905         /* Make sure we have an owner */
00906         if (!strlen(parse_line.owner)) {
00907                 return False;
00908         }
00909 
00910         /* Make sure we have a valid status */
00911         parse_line.space4[0] = '\0';
00912         trim_char(parse_line.status, '\0', ' ');
00913         if (!strequal(parse_line.status, LPROS2_PRINTING) &&
00914                         !strequal(parse_line.status, LPROS2_PAUSED) &&
00915                         !strequal(parse_line.status, LPROS2_WAITING)) {
00916                 return False;
00917         }
00918 
00919         fstrcpy(buf->fs_user, parse_line.owner);
00920         if (strequal(parse_line.status, LPROS2_PRINTING)) {
00921                 buf->status = LPQ_PRINTING;
00922         } else if (strequal(parse_line.status, LPROS2_PAUSED)) {
00923                 buf->status = LPQ_PAUSED;
00924         } else {
00925                 buf->status = LPQ_QUEUED;
00926         }
00927 
00928         return True;
00929 }

static BOOL parse_lpq_vlp ( char *  line,
print_queue_struct buf,
BOOL  first 
) [static]

lpq_parse.c941 行で定義されています。

参照先 bufnext_token().

参照元 parse_lpq_entry().

00942 {
00943         int toknum = 0;
00944         fstring tok;
00945         const char *cline = line;
00946 
00947         /* First line is printer status */
00948 
00949         if (!isdigit(line[0])) return False;
00950 
00951         /* Parse a print job entry */
00952 
00953         while(next_token(&cline, tok, NULL, sizeof(fstring))) {
00954                 switch (toknum) {
00955                 case 0:
00956                         buf->job = atoi(tok);
00957                         break;
00958                 case 1:
00959                         buf->size = atoi(tok);
00960                         break;
00961                 case 2:
00962                         buf->status = atoi(tok);
00963                         break;
00964                 case 3:
00965                         buf->time = atoi(tok);
00966                         break;
00967                 case 4:
00968                         fstrcpy(buf->fs_user, tok);
00969                         break;
00970                 case 5:
00971                         fstrcpy(buf->fs_file, tok);
00972                         break;
00973                 }
00974                 toknum++;
00975         }
00976 
00977         return True;
00978 }

BOOL parse_lpq_entry ( enum printing_types  printing_type,
char *  line,
print_queue_struct buf,
print_status_struct status,
BOOL  first 
)

lpq_parse.c986 行で定義されています。

参照先 bufLPSTAT_ERRORLPSTAT_OKLPSTAT_STOPPEDparse_lpq_aix()parse_lpq_bsd()parse_lpq_hpux()parse_lpq_lprng()parse_lpq_nt()parse_lpq_os2()parse_lpq_plp()parse_lpq_qnx()parse_lpq_sysv()parse_lpq_vlp()PRINT_AIXPRINT_HPUXPRINT_LPRNGPRINT_LPRNTPRINT_LPROS2PRINT_PLPPRINT_QNXPRINT_SYSVPRINT_TESTstat0_stringsstat1_stringsstat2_stringsstatusstrchr_m()strlower_m()strstr_m().

参照元 generic_queue_get().

00989 {
00990         BOOL ret;
00991 
00992         switch (printing_type) {
00993                 case PRINT_SYSV:
00994                         ret = parse_lpq_sysv(line,buf,first);
00995                         break;
00996                 case PRINT_AIX:      
00997                         ret = parse_lpq_aix(line,buf,first);
00998                         break;
00999                 case PRINT_HPUX:
01000                         ret = parse_lpq_hpux(line,buf,first);
01001                         break;
01002                 case PRINT_QNX:
01003                         ret = parse_lpq_qnx(line,buf,first);
01004                         break;
01005                 case PRINT_LPRNG:
01006                         ret = parse_lpq_lprng(line,buf,first);
01007                         break;
01008                 case PRINT_PLP:
01009                         ret = parse_lpq_plp(line,buf,first);
01010                         break;
01011                 case PRINT_LPRNT:
01012                         ret = parse_lpq_nt(line,buf,first);
01013                         break;
01014                 case PRINT_LPROS2:
01015                         ret = parse_lpq_os2(line,buf,first);
01016                         break;
01017 #ifdef DEVELOPER
01018                 case PRINT_VLP:
01019                 case PRINT_TEST:
01020                         ret = parse_lpq_vlp(line,buf,first);
01021                         break;
01022 #endif /* DEVELOPER */
01023                 default:
01024                         ret = parse_lpq_bsd(line,buf,first);
01025                         break;
01026         }
01027 
01028         /* We don't want the newline in the status message. */
01029         {
01030                 char *p = strchr_m(line,'\n');
01031                 if (p) {
01032                         *p = 0;
01033                 }
01034         }
01035 
01036         /* in the LPRNG case, we skip lines starting by a space.*/
01037         if (!ret && (printing_type==PRINT_LPRNG) ) {
01038                 if (line[0]==' ') {
01039                         return ret;
01040                 }
01041         }
01042 
01043         if (status && !ret) {
01044                 /* a few simple checks to see if the line might be a
01045                         printer status line: 
01046                         handle them so that most severe condition is shown */
01047                 int i;
01048                 strlower_m(line);
01049       
01050                 switch (status->status) {
01051                         case LPSTAT_OK:
01052                                 for (i=0; stat0_strings[i]; i++) {
01053                                         if (strstr_m(line,stat0_strings[i])) {
01054                                                 fstrcpy(status->message,line);
01055                                                 status->status=LPSTAT_OK;
01056                                                 return ret;
01057                                         }
01058                                 }
01059                                 /* fallthrough */
01060                         case LPSTAT_STOPPED:
01061                                 for (i=0; stat1_strings[i]; i++) {
01062                                         if (strstr_m(line,stat1_strings[i])) {
01063                                                 fstrcpy(status->message,line);
01064                                                 status->status=LPSTAT_STOPPED;
01065                                                 return ret;
01066                                         }
01067                                 }
01068                                 /* fallthrough */
01069                         case LPSTAT_ERROR:
01070                                 for (i=0; stat2_strings[i]; i++) {
01071                                         if (strstr_m(line,stat2_strings[i])) {
01072                                                 fstrcpy(status->message,line);
01073                                                 status->status=LPSTAT_ERROR;
01074                                                 return ret;
01075                                         }
01076                                 }
01077                                 break;
01078                 }
01079         }
01080 
01081         return ret;
01082 }


変数

const char* Months[13] [static]

初期値:

 { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Err"}

lpq_parse.c23 行で定義されています。

参照元 EntryTime().

const char* stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL } [static]

lpq_parse.c931 行で定義されています。

参照元 parse_lpq_entry().

const char* stat1_strings[] = { "offline", "disabled", "down", "off", "waiting", "no daemon", NULL } [static]

lpq_parse.c932 行で定義されています。

参照元 parse_lpq_entry().

const char* stat2_strings[] = { "jam", "paper", "error", "responding", "not accepting", "not running", "turned off", NULL } [static]

lpq_parse.c933 行で定義されています。

参照元 parse_lpq_entry().


Sambaに対してSat Aug 29 21:24:02 2009に生成されました。  doxygen 1.4.7