int gspool_jobupd(const intfd, const unsignedflags, const slotno_tslot, struct apispq *jobd)
DESCRIPTION
The gspool_jobupd() function is used to update the details of a job.
fd is a file descriptor previously returned by gspool_open
flags is zero, or "GSPOOL_FLAG_IGNORESEQ" to ignore changes since the list was last read.
slot is the slot number corresponding to the job as previously
returned by gspool_joblist or gspool_jobfindslot.
jobd is a descriptor containing the job descriptor as defined in
gspool.h.
The fields in struct apispq are defined in the documentation for
gspool_jobread(3).
Note that we recommend that the whole structure be first read in with
gspool_jobread or gspool_jobfind and then required fields updaated; this
approach will cover any future extensions with additional fields.
RETURN VALUES
The function gspool_jobupd() returns 0 if successful, otherwise one
of the following codes:
GSPOOL_BAD_PRIORITY
The job's priority is outside the range for the user, or it cannot be
changed by the user.
GSPOOL_INVALID_FD
Invalid File descriptor
GSPOOL_BADWRITE
failure writing to the network
GSPOOL_BADREAD
failure reading from the network
GSPOOL_NOPERM
The user does not have permission
GSPOOL_ZERO_CLASS
A class code of zero is illegal
GSPOOL_BAD_COPIES
The copies field is outside the limit for the user
GSPOOL_BAD_FORM
The form type filed has been left empty
GSPOOL_SEQUENCE
Sequence error, slot may be out of date
GSPOOL_UNKNOWN_JOB
Job not found
GSPOOL_INVALIDSLOT
Invalid slot number
EXAMPLE
An example to change the name of job ``readme.txt'' to ``myfile''
int fd, ret, nj, i;
struct apispq job;
slotno_t *slots;
fd = gspool_open("myhost", (char *) 0, 0);
if (fd < 0) { /* error handling */
...
}
/* make a list of jobs */
ret = gspool_joblist(fd, 0, &nj, &slots);
if (ret < 0) { /* error handling */
...
}
for (i = 0; i < nj; i++) {
ret = gspool_jobread(fd, 0, list[i], &job);
if (ret < 0)
continue;
if (strcmp(job.apispq_file, "readme.txt"))
continue;
strcpy(job.apispq_file, "myfile");
ret = gspool_jobupd(fd, 0, list[i], &job);
if (ret < 0) { /* error handling */
...
}
break;
}
gspool_close(fd);
Copyright (c) 2009 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the
terms of the GNU General Public License
<http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.