home *** CD-ROM | disk | FTP | other *** search
- /*
- ** j o b . c
- **
- ** functions for retrieving job information
- **
- ** Arthur W. Neilson III
- ** art@bohtsg.pegasus.com
- ** Feb 7, 1991
- **
- */
-
- #include "main.h"
- #include "node.h"
-
- #define MAXLINE 133
-
- VOID
- jobinfo(name, job)
- char *name;
- Job *job;
- {
- FILE *fp;
- char *getfield(), *ptr;
- char buf[MAXLINE];
- int i;
-
- /* open print file */
- if ((fp = fopen(name, "r")) == NULL)
- return;
-
- /* retrieve first banner line */
- if (fread(buf, sizeof(buf), 1, fp) < 1) {
- fclose(fp);
- return;
- }
- fclose(fp);
-
- /* skip fields 1 thru 4 */
- if ((ptr = strtok(buf, " ")) == NULL)
- return;
- for (i = 2; i <= 4 && strtok(NULL, " ") != NULL; i++)
- ;
-
- /* and get jobname from field 5 */
- strcpy(job->name, strtok(NULL, " "));
-
- /* search for time field */
- while ((ptr = strtok(NULL, " ")) != NULL)
- if (strchr(ptr, '.') != NULL)
- break;
-
- /* get time */
- if (at(ptr, '.') == 2)
- sprintf(job->time, "0%7s", ptr);
- else
- strcpy(job->time, ptr);
- strcpy(job->ampm, strtok(NULL, " "));
-
- /* and date */
- strcpy(job->day, strtok(NULL, " "));
- strcpy(job->month, strtok(NULL, " "));
- strcpy(job->year, strtok(NULL, " "));
- }
-