prout

smaller "lp" command
git clone git://git.2f30.org/prout
Log | Files | Refs | README | LICENSE

commit 09eea7b1235dd145579cf00ba17632c11b588257
parent f851bb0901d8084ae7eb2ef43af64b93d633c17c
Author: z3bra <willy@mailoo.org>
Date:   Mon, 10 Feb 2014 10:15:07 +0100

Made the program non-blocking

Diffstat:
Mprout.1.gz | 0
Mprout.c | 82+++++++++++++++++++++++++++++++++++++++----------------------------------------
2 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/prout.1.gz b/prout.1.gz Binary files differ. diff --git a/prout.c b/prout.c @@ -94,52 +94,50 @@ static void check_job (cups_dest_t *dest, int job_id) ipp_jstate_t state = IPP_JOB_PENDING; - while (state < IPP_JOB_STOPPED) { - /* GET ALL THE JOBS "\_(°D°)/ */ - num_jobs = cupsGetJobs(&jobs, dest->name, 1, CUPS_WHICHJOBS_ALL); - - /* Find MY job id */ - for (i = 0; i < num_jobs; i++) { - if (jobs[i].id == job_id) { - state = jobs[i].state; - break; - } + /* GET ALL THE JOBS "\_(°D°)/ */ + num_jobs = cupsGetJobs(&jobs, dest->name, 1, CUPS_WHICHJOBS_ALL); + + /* Find MY job id */ + for (i = 0; i < num_jobs; i++) { + if (jobs[i].id == job_id) { + state = jobs[i].state; + break; } + } - /* Free the job array */ - cupsFreeJobs(num_jobs, jobs); - - switch (state) { - case IPP_JOB_PENDING : - fprintf(stdout, "\rjob %d pending.", job_id); - break; - case IPP_JOB_HELD : - fprintf(stdout, "\rjob %d held.", job_id); - break; - case IPP_JOB_PROCESSING : - fprintf(stdout, "\rjob %d processing.", job_id); - break; - case IPP_JOB_STOPPED : - fprintf(stdout, "\rjob %d stopped.", job_id); - break; - case IPP_JOB_CANCELED : - fprintf(stdout, "\rjob %d canceled.", job_id); - break; - case IPP_JOB_ABORTED : - fprintf(stdout, "\rjob %d aborted.", job_id); - break; - case IPP_JOB_COMPLETED : - fprintf(stdout, "\rjob %d completed.\n", job_id); - break; - } + /* Free the job array */ + cupsFreeJobs(num_jobs, jobs); + + switch (state) { + case IPP_JOB_PENDING : + fprintf(stdout, "\rjob %d pending.", job_id); + break; + case IPP_JOB_HELD : + fprintf(stdout, "\rjob %d held.", job_id); + break; + case IPP_JOB_PROCESSING : + fprintf(stdout, "\rjob %d processing.", job_id); + break; + case IPP_JOB_STOPPED : + fprintf(stdout, "\rjob %d stopped.", job_id); + break; + case IPP_JOB_CANCELED : + fprintf(stdout, "\rjob %d canceled.", job_id); + break; + case IPP_JOB_ABORTED : + fprintf(stdout, "\rjob %d aborted.", job_id); + break; + case IPP_JOB_COMPLETED : + fprintf(stdout, "\rjob %d completed.\n", job_id); + break; + } - /* Actually print text to stdout */ - fflush(stdout); + /* Actually print text to stdout */ + fflush(stdout); - /* Wait just a second if the job is not finished */ - if (state < IPP_JOB_STOPPED) { - sleep(1); - } + /* Wait just a second if the job is not finished */ + if (state < IPP_JOB_STOPPED) { + sleep(1); } return;