comparison 3rdparty/packages/uucpbb/src/findmach.c @ 1772:5ba8e711a1a3

source added
author boisy
date Fri, 01 Apr 2005 22:04:25 +0000
parents
children
comparison
equal deleted inserted replaced
1771:7f2e75d5b62d 1772:5ba8e711a1a3
1 /* findmach.c This routine gets the information for a specific remote.
2 Copyright (C) 1990, 1993 Rick Adams and Bob Billson
3
4 This file is part of the OS-9 UUCP package, UUCPbb.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 The author of UUCPbb, Bob Billson, can be contacted at:
21 bob@kc2wz.bubble.org or uunet!kc2wz!bob or by snail mail:
22 21 Bates Way, Westfield, NJ 07090
23 */
24
25 #include "uucp.h"
26 #include "uucico.h"
27
28 #define WORDSIZE 30
29
30 /* Keep track of whether or not we've actually dialed */
31 static flag found_one = FALSE;
32
33
34 int findmach (entryline)
35 int *entryline;
36 {
37 char line[SYSLINE];
38 register char *words[WORDSIZE];
39 short i, n;
40
41 if (debuglvl > 0)
42 fprintf (log, "findmach: checking Systems for %s...", sysname);
43
44 do
45 {
46 /* find system entry */
47 if (findline (*entryline, sysname, SYSTEMS, line, sizeof (line))
48 == FALSE)
49 {
50 if (*entryline == 0)
51 {
52 char tmp[45];
53
54 if (debuglvl == 0)
55 {
56 sprintf (tmp, "'%s' not in Systems file", sysname);
57 logerror (tmp);
58 return (FATAL);
59 }
60 else
61 fputs ("NOT FOUND\n", log);
62
63 return (ABORT);
64 }
65 else if (found_one)
66 {
67 if (debuglvl > 0)
68 fputs ("no other entry\n", log);
69
70 return (NOANSWER);
71 }
72 else
73 {
74 char tmp[45];
75
76 fprintf (log, "Wrong time to call (%s)", sysname);
77 logerror (tmp);
78 return (ABORT);
79 }
80 }
81
82 if ((n = getargs (words, line, WORDSIZE)) < 5)
83 {
84 char tmp[65];
85
86 sprintf (tmp, "bad Systems entry for: %s", sysname);
87 logerror (tmp);
88 return (ABORT);
89 }
90 (*entryline)++; /* set up index for next entry */
91 }
92 while (!chksched (*(words+1))); /* check schedule to make sure we */
93 /* can use this entry now */
94 found_one = TRUE;
95
96 if (debuglvl > 0)
97 fprintf (log, "got it\n");
98
99 /* retrieve baud rate and phone number */
100 strcpy (baud, *(words+3));
101 strcpy (phone, *(words+4));
102
103 if (strucmp (phone, "none") == 0)
104 strcpy (phone, "-");
105
106 /* retrieve chat script for system */
107 for (*chatscript = '\0', i = 5; i < n; i++)
108 {
109 strcat (chatscript, words[i][0] != '\0' ? *(words+i) : "|");
110
111 if (i != (n - 1))
112 strcat (chatscript, " ");
113 }
114
115 /* Look in the Devices file for a matching "device" entry. This
116 "device" does not have to be an actual OS-9 device name (/t2, /t3,
117 etc.). It is merely a unique label to identify the entry in the
118 Devices file. */
119
120 if (findent (*(words+2), DEVICES, line, sizeof (line)) == FALSE)
121 {
122 char tmp[65];
123
124 sprintf (tmp, "entry not in Devices: %s", *(words+2));
125 logerror (tmp);
126 return (ABORT);
127 }
128
129 if ((n = getargs (words, line, WORDSIZE)) != 5)
130 {
131 char tmp[65];
132
133 sprintf (tmp, "bad Devices entry: %s", *words);
134 logerror (tmp);
135 return (ABORT);
136 }
137
138 /* Retrieve the actual OS-9 device we will use, e.g. /t2, /t3, etc. */
139 strcpy (device, *(words+1));
140
141 /* Find the entry in the Dialers file */
142 if (findent (*(words+4), DIALERS, line, sizeof (line)) == FALSE)
143 {
144 char tmp[65];
145
146 sprintf (tmp, "device not in Dialers: %s", *(words+4));
147 logerror (tmp);
148 return (ABORT);
149 }
150
151 if ((n = getargs (words, line, WORDSIZE)) < 2)
152 {
153 char tmp[65];
154
155 sprintf (tmp, "bad Dialers entry: %s", *words);
156 logerror (tmp);
157 return (ABORT);
158 }
159
160 /* get modem reset string */
161 strcat (strcpy (modemreset, *(words+2)), "\n");
162
163 /* retrieve dial script */
164 for (*dialscript = '\0', i = 1; i < n; i++)
165 {
166 if (words[i][0] == '-' || words[i][0] == '\0')
167 strcat (dialscript, "|");
168 else
169 strcat (dialscript, *(words+i));
170
171 if (i != (n - 1))
172 strcat (dialscript, " ");
173 }
174
175 return (OPENPORT);
176 }