gspool_joblist - get a list of jobs
int gspool_joblist(const int fd, const unsigned flags, int *numjobs, slotno_t **slots)
The gspool_joblist() function is used to obtain a list of jobs.
fd is a file descriptor previously returned by gspool_open
flags is zero, or a logical OR of one or more of the following values
Ignore remote printers/hosts, i.e. not local to the server, not the client.
Ignore other users jobs
numjobs is a pointer to an integer value which, on successful completion, will contain the number of job slots returned.
slots is a pointer to to an array of slot numbers. These slot numbers can be used to access individual jobs. The memory used by this vector is owned by the API, therefore no attempt should be made by the user to free it.
The function returns 0 if successful otherwise one of the error codes listed in Chapter 3.
The value assigned to *slots
is owned by the API, so the user
should not attempt to free it. This contrasts, for example, with X
library routines.
Also note that certain other calls to the API, notably gspool_ptrlist, may reuse the space, so the contents should be copied if required before other API calls are made.
An example to list all jobs:
int fd, ret, nj, i; slotno_t *slots;
fd = gspool_open("myhost", (char *) 0, 0);
if (fd < 0) { /* error handling */ ... }
ret = gspool_joblist(fd, 0, &nj, &slots);
if (ret < 0) { /* error handling */ ... }
for (i = 0; i < nj; i++) { slotno_t this_slot = slots[i];
/* process this_slot */
... }
gspool_close(fd);
gspool_jobread(3), gspool_jobdata(3), gspool_jobadd(3), gspool_jobdel(3), gspool_jobfind(3), gspool_jobfindslot(3), gspool_jobupd(3), gspool_jobmon(3), gspool_jobpbrk(3).
John M Collins, Xi Software Ltd.