static char *sccsid
="@(#)dnd.c 4.4 (Berkeley) %G%";
* batch queue manager. by Greg Chesson. Modified to be
* a daemon managing requests to a multiple autodialers, by
int dndebug
= 1; /* we actually run debug = 1 */
int nactive
; /* number running */
int max
; /* max allowable */
} pdevs
[] = {{"/dev/cua0",'4','8'}, /*{"/dev/cua1",'4','1'},*/ {0}};
/* the second line here is commented out because,
our 1200 baud dialer is being repaired, and if one attempts
to dial with a modem that is not capable, the dialer gets
hung and must be pulled out of the machine */
#define INDEX(x) ((x&0xff00)>>4)
max = atoi(argv[1]);*/ max
= 1;
strcpy(argv
[0], "dnd-child");
while( (cc
=read(xd
, buf
, 512)) >= 0) {
register struct chan
*cp
;
wctl(x
,(char *)&noioctl
,sizeof(noioctl
));
cb
+= sizeof(struct sgttyb
);
printf("starting to dial on behalf of uid %d\n",xx
.uid
);
printf("channel %d aborted\n", INDEX(x
));
printf("channel %d finished\n", INDEX(x
));
* make mpx node, open accounting file, and initialize queue.
register struct mx_leaves
*lp
;
freopen(stdout
,"/dev/null","w");
if((actfile
= fopen("/usr/adm/dnacct","a"))==NULL
)
quit("Can't make accouting file");
for(t
=QSIZE
; --t
>=0;) runq
[t
].uid
= -1;
if(xd
< 0) quit("Can't open master mpx node");
for(lp
= pdevs
; lp
->name
; lp
++) {
if(t
< 0) quit("Can't make minor mpx node");
if((t
= join(t
,xd
)) == -1) quit("Can't attach to tree");
printf("pseudo-device %s assigned channel %x\n",lp
->name
,t
);
* unpack an mpx buffer at
bp
+= sizeof (struct rh
);
control(rp
->index
, bp
, rp
->ccount
);
/* transfer numbers to the unique dialer */
char *mdata
, *tmpt
, *ctime();
struct passwd
*getpwuid();
printf("phase error: Writing data from chan %x on behalf of chan %x\n",rp
->index
,xx
.index
);
while(mdata
< lim
&& dp
< dialbuf
+DSIZE
) {
time(&clock
); tmpt
= ctime(&clock
); tmpt
[20] = 0;
if((c
= dialit(dialbuf
))=='A')
fprintf(actfile
, "%s dialed %s at %s\n",
getpwuid(xx
.uid
)->pw_name
,dialbuf
,tmpt
);
else printf("Dialer returns %c\n",c
);
for(j
=i
+1; j
<QSIZE
;j
++) {
write(xd
,&msg
,sizeof msg
);
write(xd
,&msg
,sizeof msg
);
#define pc(x) (c = x, write(fd,&c,1))
#define unlike(a,b) (((a)^(b))&0xf)
static struct sgttyb cntrl
;
register int fd
= open(DN
,2);
register struct mx_leaves
*lp
= pdevs
;
/*if(linebusy()) return('X');*/
gtty(fd
,&cntrl
); /* set raw, -echo, 2400 Baud */
cntrl
.sg_ispeed
= cntrl
.sg_ospeed
= B2400
;
cntrl
.sg_flags
= RAW
| EVENP
| ODDP
;
string
= sanitize(string
);
if(*string
=='<' && string
[1]==0) {
while(test
= unlike(lp
->chan
,xx
.index
))
printf("Unable to locate dialer, chan = %x\n",xx
.index
);
pc(STX
); pc(lp
->rack
); pc(lp
->modem
);
for(;*string
&& *string
!='<'; string
++) pc(*string
);
/*for(;*string; string++) pc(*string);*/
if(read(fd
,&c
,1)!=1) c
= 'M';
for(;*string
; string
++) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '<':
/* Band-aid for hardware glitch - access forbidded to
dialer while line in use */
/* if we are there the open did not hang, so
we problem got the line was busy */
printf("open succeeded did not hang\n");
return(1); /* line busy */
/* came in on interrupt */
return(0); /* line is free, we did hang waiting for Carrier */