home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum4.lzh
/
SPRACHEN
/
C
/
LP
/
prjob.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-02-09
|
2KB
|
90 lines
/* Druckt einen Job aus */
/* Uebergabe der Jobnummer als Parameter */
/* Uwe Simon Januar 1988 */
#include <module.h>
#include <stdio.h>
#include "lp.h"
int ev;
kopf(s,id) /* gibt Jobheader aus !!! */
char *s;
int id;
{
/* kann noch beliebig erweitert werden (z.B. mit uid in Grosschrift */
}
int pr(t,s,d,id,co) /* returns -1 wenn job gekillt */
char *t,*s,*d;
int co,id;
{
char h[300];
FILE *f,*g;
g=fopen(d,"a");
kopf(t,id);
while(co--) {
if((f=fopen(s,"r"))!=NULL) {
while(fgets(h,255,f)) {
if(_ev_read(ev)==STOP) { /* ein Job muss getstoppt werden */
if(queue->parameter==id) { /* ich bin gemeint */
_ev_set(ev,1,0);
fputs("\n<<<<< CANCEL >>>>>\n\f",g);
fclose(g);
unlink(s);
return(-1);
}
}
fputs(h,g);
}
fputs("\n\f",g);
}
fclose(f);
}
fclose(g);
unlink(s);
return(0);
}
main(argc,argv)
int argc;
char **argv;
{
int jo,job,id,copy;
char s[100],t[100],d[100];
mod_exec *module;
jo=atoi(argv[1]);
module=(mod_exec *)modlink("spoolqueue",0x400);
if((int)module==-1) { exit(_errmsg(1,"Spooler not installed\n")); }
queue=(struct spoolqueue *)((long)module+module->_mexec);
if(!queue->active) fprintf(stderr,"WARNING: Spooler not active\n");
ev=_ev_link("spoolqueue");
_ev_wait(ev,0,0);
queue->command=NICHTS;
if((job=find_job(jo))>=0) {
queue->jobs[job].status=BUSY;
strcpy(s,queue->jobs[job].filename);
strcpy(t,queue->jobs[job].titel);
strcpy(d,queue->printer[queue->jobs[job].dev]);
id=queue->jobs[job].spoolid;
copy=queue->jobs[job].copy;
_ev_set(ev,0,0); /* gibt queue wieder frei ohne lpsched zu informieren */
pr(t,s,d,id,copy);
_ev_wait(ev,0,0);
}
queue->parameter=jo;
queue->command=READY;
_ev_signal(ev,0);
_ev_unlink(ev);
munlink(module);
}