4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
36 GLOBAL
char _Protocol
[40] = ""; /* working protocol string */
37 static char _ProtoSys
[40] = ""; /* protocol string from Systems file entry */
38 static char _ProtoDev
[40] = ""; /* protocol string from Devices file entry */
39 EXTERN
char _ProtoCfg
[]; /* protocol string from Config file entry */
42 EXTERN
unsigned expecttime
;
46 /* Parity control during login procedure */
52 static char par_tab
[128];
54 EXTERN
void alarmtr();
55 static void addProto(), mergeProto(), removeProto();
56 static void bld_partab();
57 static char *nextProto();
58 EXTERN
char *findProto();
59 static void getProto();
60 EXTERN
int getto(); /* make this static when ct uses altconn() */
61 EXTERN
int chat(), rddev(), expect(), wrstr(), wrchr();
62 EXTERN
int processdev(), getdevline(), getsysline(), sysaccess();
63 EXTERN
int clear_hup();
64 EXTERN
char *currsys(), *currdev();
66 static int wait_for_hangup(), expect_str();
68 EXTERN
void sendthem(), nap();
69 static int notin(), ifdate(), checkdate(), checktime(), classmatch();
71 GLOBAL
char *Myline
= CNULL
; /* to force which line will be used */
72 GLOBAL
char *Mytype
= CNULL
; /* to force selection of specific device type */
73 GLOBAL
int Dologin
; /* to force login chat sequence */
76 * conn - place a telephone call to system and login, etc.
79 * FAIL - connection failed
80 * >0 - file no. - connect ok
81 * When a failure occurs, Uerror is set.
90 EXTERN
void sysreset();
92 CDEBUG(4, "conn(%s)\n", system
);
94 while ((nf
= finds(system
, flds
, F_MAX
)) > 0) {
96 CDEBUG(4, "getto ret %d\n", fn
);
103 int pgrp
= getpgrp();
105 int pgrp
= getpgrp(0);
107 ioctl(fn
, TIOCSPGRP
, &pgrp
);
110 if (Dologin
|| EQUALS(Progname
, "uucico")) {
111 if (chat(nf
- F_LOGIN
, flds
+ F_LOGIN
, fn
,"","") == SUCCESS
) {
113 return(fn
); /* successful return */
117 DEBUG(6, "close caller (%d)\n", fn
);
120 if (Dc
[0] != NULLCHAR
) {
121 DEBUG(6, "delock line (%s)\n", Dc
);
129 /* finds or getto failed */
131 CDEBUG(1, "Call Failed: %s\n", UERRORTEXT
);
136 * getto - connect to remote machine
139 * >0 - file number - ok
147 char *dev
[D_MAX
+2], devbuf
[BUFSIZ
];
151 int tries
= 0; /* count of call attempts - for limit purposes */
152 EXTERN
void devreset();
154 CDEBUG(1, "Device Type %s wanted\n", flds
[F_TYPE
]);
156 while (tries
< TRYCALLS
) {
157 if ((status
=rddev(flds
[F_TYPE
], dev
, devbuf
, D_MAX
)) == FAIL
) {
158 if (tries
== 0 || ++reread
>= TRYCALLS
)
163 /* check class, check (and possibly set) speed */
164 if (classmatch(flds
, dev
) != SUCCESS
) {
165 DEBUG(7, "Skipping entry in '%s'", currdev());
166 DEBUG(7, " - class (%s) not wanted.\n", dev
[D_CLASS
]);
169 DEBUG(5, "Trying device entry '%s' ", dev
[D_LINE
]);
170 DEBUG(5, "from '%s'.\n", currdev());
171 if ((dcf
= processdev(flds
, dev
)) >= 0)
175 case SS_CANT_ACCESS_DEVICE
:
176 case SS_DEVICE_FAILED
:
177 case SS_LOCKED_DEVICE
:
185 devreset(); /* reset devices file(s) */
186 if (status
== FAIL
&& !Uerror
) {
187 CDEBUG(1, "Requested Device Type Not Found\n%s", "");
188 Uerror
= SS_NO_DEVICE
;
194 * classmatch - process 'Any' in Devices and Systems and
195 * determine the correct speed, or match for ==
199 classmatch(flds
, dev
)
200 char *flds
[], *dev
[];
202 /* check class, check (and possibly set) speed */
203 if (EQUALS(flds
[F_CLASS
], "Any")
204 && EQUALS(dev
[D_CLASS
], "Any")) {
205 dev
[D_CLASS
] = DEFAULT_BAUDRATE
;
207 } else if (EQUALS(dev
[D_CLASS
], "Any")) {
208 dev
[D_CLASS
] = flds
[F_CLASS
];
210 } else if (EQUALS(flds
[F_CLASS
], "Any") ||
211 EQUALS(flds
[F_CLASS
], dev
[D_CLASS
]))
219 * rddev - find and unpack a line from device file for this caller type
220 * lines starting with whitespace of '#' are comments
223 * >0 - number of arguments in vector - succeeded
228 rddev(type
, dev
, buf
, devcount
)
233 char *commap
, d_type
[BUFSIZ
];
236 while (getdevline(buf
, BUFSIZ
)) {
237 if (buf
[0] == ' ' || buf
[0] == '\t'
238 || buf
[0] == '\n' || buf
[0] == '\0' || buf
[0] == '#')
240 na
= getargs(buf
, dev
, devcount
);
241 ASSERT(na
>= D_CALLER
, "BAD LINE", buf
, na
);
243 if ( strncmp(dev
[D_LINE
],"/dev/",5) == 0 ) {
244 /* since cu (altconn()) strips off leading */
245 /* "/dev/", do the same here. */
246 strcpy(dev
[D_LINE
], &(dev
[D_LINE
][5]) );
249 /* may have ",M" subfield in D_LINE */
251 if ( (commap
= strchr(dev
[D_LINE
], ',')) != (char *)NULL
) {
252 if ( strcmp( commap
, ",M") == SAME
)
258 * D_TYPE field may have protocol subfield, which
259 * must be pulled off before comparing to desired type.
261 (void)strcpy(d_type
, dev
[D_TYPE
]);
262 if ((commap
= strchr(d_type
, ',')) != (char *)NULL
)
265 /* to force the requested device type to be used. */
266 if ((Mytype
!= NULL
) && (!EQUALS(Mytype
, d_type
)) )
268 /* to force the requested line to be used */
269 if ((Myline
!= NULL
) && (!EQUALS(Myline
, dev
[D_LINE
])) )
272 bsfix(dev
); /* replace \X fields */
274 if (EQUALS(d_type
, type
)) {
275 getProto( _ProtoDev
, dev
[D_TYPE
] );
284 * finds - set system attribute vector
287 * fsys - open Systems file descriptor
288 * sysnam - system name to find
290 * flds - attibute vector from Systems file
291 * fldcount - number of fields in flds
293 * >0 - number of arguments in vector - succeeded
296 * 0 - found a line in Systems file
297 * SS_BADSYSTEM - no line found in Systems file
298 * SS_TIME_WRONG - wrong time to call
302 finds(sysnam
, flds
, fldcount
)
303 char *sysnam
, *flds
[];
305 static char info
[BUFSIZ
];
315 if (sysnam
== 0 || *sysnam
== 0 ) {
316 Uerror
= SS_BADSYSTEM
;
320 while (getsysline(info
, sizeof(info
))) {
321 na
= getargs(info
, flds
, fldcount
);
322 bsfix(flds
); /* replace \X fields */
323 if ( !EQUALSN(sysnam
, flds
[F_NAME
], MAXBASENAME
))
325 /* check if requested Mytype device type */
326 if ((Mytype
!= CNULL
) &&
328 !EQUALSN(flds
[F_TYPE
], Mytype
, strlen(Mytype
)))) {
329 DEBUG(7, "Skipping entry in '%s'", currsys());
330 DEBUG(7, " - type (%s) not wanted.\n", na
> F_TYPE
?
331 flds
[F_TYPE
] : "Missing type entry");
334 DEBUG(5, "Trying entry from '%s'", currsys());
335 DEBUG(5, " - device type %s.\n", na
> F_TYPE
?
336 flds
[F_TYPE
] : "<Missing type entry>");
338 /* OK if not uucico (ie. ct or cu) or the time is right */
339 if (!EQUALS(Progname
, "uucico") ||
340 (na
> F_TIME
&& ifdate(flds
[F_TIME
]))) {
341 /* found a good entry */
343 getProto(_ProtoSys
, flds
[F_TYPE
]);
345 return(na
); /* FOUND OK LINE */
347 DEBUG(5, "Trying entry from '%s'", currsys());
348 DEBUG(5, " - Missing type entry for <%s>.\n",
351 CDEBUG(1, "Wrong Time To Call: %s\n", na
> F_TIME
?
352 flds
[F_TIME
] : "<Missing time entry>");
354 Uerror
= SS_TIME_WRONG
;
358 Uerror
= SS_BADSYSTEM
;
363 * getProto - get the protocol letters from the input string.
365 * str - string from Systems/Devices/Config file,
366 * a ',' delimits the protocol string
369 * str - the , (if present) will be replaced with NULLCHAR
382 if ( (p
=strchr(str
, ',')) != NULL
) {
384 (void) strcpy(save
, p
+1);
385 DEBUG(7, "Protocol = %s\n", save
);
391 * check for a specified protocol selection string
393 * protocol string pointer
394 * NULL if none specified for LOGNAME
405 if ( _ProtoSys
[0] != '\0' )
406 addProto(_ProtoSys
, valid
);
407 if ( _ProtoDev
[0] != '\0' )
408 addProto(_ProtoDev
, valid
);
409 if ( _ProtoCfg
[0] != '\0' )
410 addProto(_ProtoCfg
, valid
);
412 if ( _Protocol
[0] == '\0' ) {
413 (void) strcpy(valid
, save
);
414 (void) strcpy(_Protocol
, save
);
417 return(_Protocol
[0] == NULLCHAR
? NULL
: _Protocol
);
423 * Verify that the desired protocols from the Systems and Devices file
424 * have been compiled into this application.
426 * desired - list of desired protocols
427 * valid - list of protocols that are compiled in.
431 addProto (desired
, valid
)
438 if ( *desired
== '\0' )
441 if ( *(protoPtr
= _Protocol
) != NULLCHAR
) {
442 while ( *(protoPtr
= nextProto(protoPtr
)) != NULLCHAR
) {
443 if ( *(wantPtr
= findProto(desired
, *protoPtr
)) == NULLCHAR
) {
444 removeProto(valid
, *protoPtr
);
445 removeProto(protoPtr
, *protoPtr
);
447 mergeProto(protoPtr
, wantPtr
);
453 while ( *(wantPtr
= nextProto(wantPtr
)) != NULLCHAR
) {
454 if ( *(findProto(valid
, *wantPtr
)) != NULLCHAR
) {
455 mergeProto(protoPtr
, wantPtr
);
460 if ( *(protoPtr
= _Protocol
) != NULLCHAR
) {
461 while ( *(protoPtr
= nextProto(protoPtr
)) != NULLCHAR
)
462 *(valid
++) = *(protoPtr
++);
472 * char *tostring, *fromstring;
475 mergeProto(tostring
, fromstring
)
476 char *tostring
, *fromstring
;
481 while ( *(tostring
= nextProto(tostring
)) != NULLCHAR
) {
482 if ( *tostring
== *fromstring
)
488 if ( *tostring
== NULLCHAR
) {
489 length
= nextProto(fromstring
+ 1) - fromstring
;
490 (void) strncpy(tostring
, fromstring
, length
);
491 *(tostring
+ length
) = NULLCHAR
;
495 if ( (*tostring
!= '(') && (*fromstring
== '(') ) {
496 (void) strcpy(buffer
, tostring
);
497 length
= nextProto(fromstring
) - fromstring
;
498 (void) strncpy(tostring
, fromstring
, length
);
499 (void) strcpy(tostring
+length
, buffer
);
515 removeProto(string
, letter
)
516 char *string
, letter
;
518 while ( *(string
= nextProto(string
)) != NULLCHAR
) {
519 if ( *string
== letter
)
520 (void) strcpy(string
, nextProto(string
+1));
530 * char * to next non-parameter letter
536 if ( *string
== '(' )
537 while ( *string
!= NULLCHAR
)
538 if ( *(string
++) == ')' )
548 * char *pointer to found or string terminating NULLCHAR
551 findProto(string
, letter
)
555 while ( *(string
= nextProto(string
)) != NULLCHAR
)
556 if ( *string
== letter
)
564 * chat - do conversation
566 * nf - number of fields in flds array
567 * flds - fields from Systems file
568 * fn - write file number
569 * phstr1 - phone number to replace \D
570 * phstr2 - phone number to replace \T
572 * return codes: 0 | FAIL
576 chat(nf
, flds
, fn
, phstr1
, phstr2
)
577 char *flds
[], *phstr1
, *phstr2
;
583 for (k
= 0; k
< nf
; k
+= 2) {
587 altern
= index(want
, '-');
589 *altern
++ = NULLCHAR
;
590 ok
= expect(want
, fn
);
593 if (altern
== NULL
) {
594 Uerror
= SS_LOGIN_FAILED
;
595 logent(UERRORTEXT
, "FAILED");
598 want
= index(altern
, '-');
601 sendthem(altern
, fn
, phstr1
, phstr2
);
605 sendthem(flds
[k
+1], fn
, phstr1
, phstr2
);
613 * expect(str, fn) look for expected string w/ possible special chars
617 * FAIL - too many characters read
618 * some character - timed out
631 for (sptr
= str
; *sptr
; sptr
++) {
636 if (expect_str(buf
, fn
) == FAIL
) {
639 if (wait_for_hangup(fn
) == FAIL
) {
656 if (expect_str(buf
, fn
) == FAIL
) {
663 * expect_str(str, fn) look for expected string, w/ no special chars
667 * FAIL - too many characters read
668 * some character - timed out
676 static char rdvec
[MR
];
683 CDEBUG(4, "expect: (%s", "");
684 for (c
=0; (kr
=str
[c
]) != 0 ; c
++)
686 CDEBUG(4, "^%c", kr
| 0100);
689 CDEBUG(4, ")\n%s", "");
691 if (EQUALS(str
, "\"\"")) {
692 CDEBUG(4, "got it\n%s", "");
701 (void) signal(SIGALRM
, alarmtr
);
703 while (notin(str
, rdvec
)) {
705 kr
= (*Read
)(fn
, &nextch
, 1);
708 CDEBUG(4, "lost line errno - %d\n", errno
);
709 logent("LOGIN", "LOST LINE");
713 CDEBUG(4, "%s", c
< 040 ? "^" : "");
714 CDEBUG(4, "%c", c
< 040 ? c
| 0100 : c
);
715 if ((*rp
= nextch
& 0177) != NULLCHAR
)
717 if (rp
>= rdvec
+ MR
) {
718 CDEBUG(4, "enough already\n%s", "");
725 CDEBUG(4, "got it\n%s", "");
729 * alarmtr() - catch alarm routine for "expect".
736 CDEBUG(6, "timed out\n%s", "");
741 * wait_for_hangup() - wait for a hangup to occur on the given device
750 CDEBUG(4, "Waiting for hangup\n%s", "");
751 while((rval
= read(dcf
, buff
, BUFSIZ
)) > 0);
756 CDEBUG(4, "Received hangup\n%s", "");
758 if (clear_hup(dcf
) != SUCCESS
) {
759 CDEBUG(4, "Unable to clear hup on device\n%s", "");
766 * sendthem(str, fn, phstr1, phstr2) send line of chat sequence
773 if ((bptr - buf) > 0)\
774 if (wrstr(fn, buf, bptr - buf, echocheck) != SUCCESS)\
780 sendthem(str
, fn
, phstr1
, phstr2
)
781 char *str
, *phstr1
, *phstr2
;
784 int sendcr
= 1, echocheck
= 0;
787 struct termio ttybuf
;
788 static int p_init
= 0;
795 /* should be EQUALS, but previous versions had BREAK n for integer n */
796 if (PREFIX("BREAK", str
)) {
798 CDEBUG(5, "BREAK\n%s", "");
803 if (PREFIX("STTY=", str
)) {
804 CDEBUG(5, "STTY %s\n", str
+5);
809 if (EQUALS(str
, "EOT")) {
810 CDEBUG(5, "EOT\n%s", "");
812 for (sptr
= EOTMSG
; *sptr
; sptr
++)
813 *bptr
++ = par_tab
[*sptr
&0177];
814 (void) (*Write
)(fn
, buf
, bptr
- buf
);
818 /* Set parity as needed */
819 if (EQUALS(str
, "P_ZERO")) {
823 if (EQUALS(str
, "P_ONE")) {
827 if (EQUALS(str
, "P_EVEN")) {
831 if (EQUALS(str
, "P_ODD")) {
836 if (EQUALS(str
, "\"\"")) {
837 CDEBUG(5, "\"\"\n%s", "");
842 CDEBUG(5, "sendthem (%s", "");
843 for (sptr
= str
; *sptr
; sptr
++) {
847 /* adjust switches */
848 case 'c': /* no CR after string */
850 if (sptr
[1] == NULLCHAR
) {
851 CDEBUG(5, "<NO CR>%s", "");
854 CDEBUG(5, "<NO CR IGNORED>\n%s", "");
857 /* stash in buf and continue */
858 case 'D': /* raw phnum */
859 strcpy(bptr
, phstr1
);
860 bptr
+= strlen(bptr
);
862 case 'T': /* translated phnum */
863 strcpy(bptr
, phstr2
);
864 bptr
+= strlen(bptr
);
869 case 's': /* space */
872 case '\\': /* backslash escapes itself */
875 default: /* send the backslash */
880 /* flush buf, perform action, and continue */
881 case 'E': /* echo check on */
883 CDEBUG(5, "ECHO CHECK ON\n%s", "");
886 case 'e': /* echo check off */
888 CDEBUG(5, "ECHO CHECK OFF\n%s", "");
891 case 'd': /* sleep briefly */
893 CDEBUG(5, "DELAY\n%s", "");
896 case 'p': /* pause momentarily */
898 CDEBUG(5, "PAUSE\n%s", "");
899 nap(HZ
/4); /* approximately 1/4 second */
901 case 'K': /* inline break */
903 CDEBUG(5, "BREAK\n%s", "");
906 case 'M': /* modem control - set CLOCAL */
907 case 'm': /* no modem control - clear CLOCAL */
909 CDEBUG(5, ")\n%s CLOCAL ",
910 (*sptr
== 'M' ? "set" : "clear"));
912 if ( (*Ioctl
)(fn
, TCGETA
, &ttybuf
) != 0 ) {
913 CDEBUG(5, "ignored. TCGETA failed, errno %d", errno
);
916 ttybuf
.c_cflag
|= CLOCAL
;
918 ttybuf
.c_cflag
&= ~CLOCAL
;
919 if ( (*Ioctl
)(fn
, TCSETAW
, &ttybuf
) != 0 )
920 CDEBUG(5, "failed. TCSETAW failed, errno %d", errno
);
923 CDEBUG(5, "\n%s", "");
931 if ( (bptr
- buf
) > 0 )
932 (void) wrstr(fn
, buf
, bptr
- buf
, echocheck
);
935 CDEBUG(5, ")\n%s", "");
940 * generate parity table for use by sendthem.
948 for (i
= 0; i
< 128; i
++) {
950 for (j
= i
&0177; j
; j
= (j
-1)&j
)
954 || (type
== P_EVEN
&& (n
&01) != 0)
955 || (type
== P_ODD
&& (n
&01) == 0))
963 wrstr(fn
, buf
, len
, echocheck
)
967 char dbuf
[BUFSIZ
], *dbptr
= dbuf
;
970 return(wrchr(fn
, buf
, len
));
973 if (sysaccess(ACCESS_SYSTEMS
) == 0) { /* Systems file access ok */
974 for (i
= 0; i
< len
; i
++) {
978 *dbptr
= buf
[i
] | 0100;
984 strcpy(dbuf
, "????????");
985 CDEBUG(5, "%s", dbuf
);
988 for (i
= 0; i
< len
; i
++)
989 *dbptr
++ = par_tab
[buf
[i
]&0177];
990 if ((*Write
)(fn
, dbuf
, len
) != len
)
1003 saccess
= (sysaccess(ACCESS_SYSTEMS
) == 0); /* protect Systems file */
1006 (void) signal(SIGALRM
, alarmtr
);
1008 for (i
= 0; i
< len
; i
++) {
1011 CDEBUG(5, "%s", cout
< 040 ? "^" : "");
1012 CDEBUG(5, "%c", cout
< 040 ? cout
| 0100 : cout
);
1014 CDEBUG(5, "?%s", "");
1015 if (((*Write
)(fn
, &par_tab
[cout
], 1)) != 1)
1018 (void) alarm(expecttime
);
1019 if ((*Read
)(fn
, &cin
, 1) != 1)
1024 CDEBUG(5, "%s", cin
< 040 ? "^" : "");
1025 CDEBUG(5, "%c", cin
< 040 ? cin
| 0100 : cin
);
1027 CDEBUG(5, "?%s", "");
1028 } while (cout
!= cin
);
1035 * notin(sh, lg) check for occurrence of substring "sh"
1039 * 0 - found the string
1040 * 1 - not in the string
1047 while (*lg
!= NULLCHAR
) {
1061 * ifdate - this routine will check a string (s)
1062 * like "MoTu0800-1730" to see if the present
1063 * time is within the given limits.
1065 * SIDE EFFECT - Retrytime is set to number following ";"
1066 * SIDE EFFECT - MaxGrade is set to character following "/"
1068 * if a grade is specified, iswrk() is consulted, so that we don't
1069 * place calls when there's only low priority work. this will appear
1070 * as a "wrong time to call" in the status file. sorry.
1072 * String alternatives:
1074 * zero or one time means all day
1078 * 0 - not within limits, or grade too low
1095 tp
= localtime(&clock
);
1096 t__now
= tp
->tm_hour
* 100 + tp
->tm_min
; /* "navy" time */
1099 * pick up retry time for failures and max grade
1100 * global variables Retrytime and MaxGrade are set here
1102 r
= strrchr(s
, ';');
1104 /* set retry time */
1106 if (isdigit(r
[1])) {
1107 if (sscanf(r
+1, "%ld", &Retrytime
) < 1)
1108 Retrytime
= 5; /* 5 minutes is error default */
1109 DEBUG(5, "Retry time set to %d minutes\n", Retrytime
);
1110 Retrytime
*= 60; /* convert to seconds */
1111 *r
= NULLCHAR
; /* blow away retry time field */
1114 Retrytime
= 0; /* use exponential backoff */
1118 MaxGrade
= NULLCHAR
; /* default */
1119 m
= strrchr(s
, '/');
1122 MaxGrade
= m
[1]; /* you asked for it! */
1123 *m
= NULLCHAR
; /* blow away max grade field */
1124 DEBUG(5, "Max Grade set to %c\n", MaxGrade
);
1128 if (MaxGrade
!= NULLCHAR
) {
1129 grade
= iswrk(CNULL
);
1130 if (grade
== NULLCHAR
|| MaxGrade
< grade
) {
1131 DEBUG(4, "No work of grade %c -- no call\n", MaxGrade
);
1135 #endif /* MAXGRADE */
1138 while (checkdate(s
, tp
, t__now
) == 0) {
1147 /* worker function for ifdate() */
1149 checkdate(s
, tp
, t__now
)
1154 static char *days
[] = {
1155 "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", 0
1163 while (isalpha(*s
)) {
1164 if (PREFIX("Any", s
))
1165 return(checktime(s
, t__now
));
1167 if (PREFIX("Wk", s
) && tp
->tm_wday
>= 1 && tp
->tm_wday
<= 5)
1168 return(checktime(s
, t__now
));
1170 for (i
= 0; days
[i
]; i
++)
1171 if (PREFIX(days
[i
], s
) && tp
->tm_wday
== i
)
1172 return(checktime(s
, t__now
));
1176 return(0); /* day match failed */
1179 /* day match ok -- check time */
1181 checktime(s
, t__now
)
1185 int t__low
, t__high
;
1187 while (isalpha(*s
)) /* flush day stuff */
1190 if ((sscanf(s
, "%d-%d", &t__low
, &t__high
) < 2))
1191 return(1); /* time match ok (default) */
1193 if (t__low
== t__high
)
1196 /* 0000 crossover? */
1197 if (t__low
< t__high
) {
1198 if (t__low
<= t__now
&& t__now
<= t__high
)
1201 if (t__low
<= t__now
|| t__now
<= t__high
)
1210 * fdig(cp) find first digit in string
1212 * return - pointer to first digit in string or end of string
1221 for (c
= cp
; *c
; c
++)
1222 if (*c
>= '0' && *c
<= '9')
1229 /* Sleep in increments of 60ths of second. */
1237 fd
= open (FASTTIMER
, 0);
1239 (void) (*Read
)(fd
, 0, time
);
1243 #endif /* FASTTIMER */
1245 #if defined(BSD4_2) || defined(ATTSVR4)
1247 /* nap(n) -- sleep for 'n' ticks of 1/60th sec each. */
1248 /* This version uses the select system call */
1260 tv
.tv_usec
= ((n
%60)*1000000L)/60;
1261 (void) select(32, 0, 0, 0, &tv
);
1265 #endif /* BSD4_2 || ATTSVR4 */
1269 /* nap(n) where n is ticks
1271 * loop using n/HZ part of a second
1272 * if n represents more than 1 second, then
1273 * use sleep(time) where time is the equivalent
1274 * seconds rounded off to full seconds
1275 * NOTE - this is a rough approximation and chews up
1276 * processor resource!
1288 /* > second, use sleep, rounding time */
1289 sleep( (int) (((n
)+HZ
/2)/HZ
) );
1293 /* use timing loop for < 1 second */
1294 endtime
= times(&tbuf
) + 3*n
/4; /* use 3/4 because of scheduler! */
1295 while (times(&tbuf
) < endtime
) {
1296 for (i
=0; i
<1000; i
++, (void) (i
*i
))
1306 * altconn - place a telephone call to system
1307 * from cu when telephone number or direct line used
1310 * FAIL - connection failed
1311 * >0 - file no. - connect ok
1312 * When a failure occurs, Uerror is set.
1320 EXTERN
char *Myline
;
1322 alt
[F_NAME
] = "dummy"; /* to replace the Systems file fields */
1323 alt
[F_TIME
] = "Any"; /* needed for getto(); [F_TYPE] and */
1324 alt
[F_TYPE
] = ""; /* [F_PHONE] assignment below */
1325 alt
[F_CLASS
] = call
->speed
;
1330 CDEBUG(4,"altconn called\r\n%s", "");
1333 /* if is "/dev/device", strip off "/dev/" because must */
1334 /* exactly match entries in Devices file, which usually */
1335 /* omit the "/dev/". if doesn't begin with "/dev/", */
1336 /* either they've omitted the "/dev/" or it's a non- */
1337 /* standard path name. in either case, leave it as is */
1339 if(call
->line
!= NULL
) {
1340 if ( strncmp(call
->line
, "/dev/", 5) == 0 ) {
1341 Myline
= (call
->line
+ 5);
1343 Myline
= call
->line
;
1348 if(call
->telno
!= NULL
) {
1349 alt
[F_PHONE
] = call
->telno
;
1350 alt
[F_TYPE
] = "ACU";
1352 /* cu direct line */
1353 alt
[F_TYPE
] = "Direct";
1355 if (call
->type
!= NULL
)
1356 alt
[F_TYPE
] = call
->type
;
1358 CDEBUG(4, "getto ret %d\n", fn
);