1772
|
1 /* closeuucp.c Close uucp connection
|
|
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 static char *o6 = "OOOOOO",
|
|
29 *o7 = "OOOOOOO",
|
|
30 *o_o = "sending \"over and out\" to remote",
|
|
31 *no_oo = "timed out waiting for \"over and out\", closed anyway",
|
|
32 *got_oo = "got remote's \"over and out\"";
|
|
33
|
|
34
|
|
35 /* As the master, we send six O's and expect seven. We send them twice to
|
|
36 help the remote. We ignore any errors. */
|
|
37
|
|
38 int mcloseuucp()
|
|
39 {
|
|
40 char string[80];
|
|
41 register int i;
|
|
42
|
|
43 if (debuglvl > 0)
|
|
44 fprintf (log, "mcloseuucp: %s\n", o_o);
|
|
45
|
|
46 if (send0 (o6) && send0 (o6))
|
|
47 {
|
|
48 /* Look for remote's hangup string. We want to make sure our
|
|
49 modem sent our string. This is only necessary because some
|
|
50 versions of UUCP complain if they don't get the hangup string.
|
|
51 The remote should send us seven O's, but some versions of
|
|
52 UUCP only send 6. We look for the string several times because
|
|
53 some versions supposedly send garbage after the last packet but
|
|
54 before the hangup string. */
|
|
55
|
|
56 for (i = 0; i < 25; ++i)
|
|
57 {
|
|
58 if (recv0 (string) == TIMEDOUT)
|
|
59 {
|
|
60 if (debuglvl > 0)
|
|
61 fprintf (log, "mcloseuucp: %s\n", no_oo);
|
|
62
|
|
63 break;
|
|
64 }
|
|
65
|
|
66 if (strstr (string, o6) != NULL)
|
|
67 {
|
|
68 if (debuglvl > 0)
|
|
69 fprintf (log, "mcloseuucp: %s\n", got_oo);
|
|
70
|
|
71 break;
|
|
72 }
|
|
73 }
|
|
74 }
|
|
75 normal_end = TRUE;
|
|
76 return (ABORT);
|
|
77 }
|
|
78
|
|
79
|
|
80
|
|
81 /* As the slave, we send seven O' and expect six. Send them twice to help the
|
|
82 other side. We ignore any errors. */
|
|
83
|
|
84 int scloseuucp()
|
|
85 {
|
|
86 char string[80];
|
|
87 register int i;
|
|
88
|
|
89 if (debuglvl > 0)
|
|
90 fprintf (log, "scloseuucp: %s\n", o_o);
|
|
91
|
|
92 if (send0 (o7) && send0 (o7))
|
|
93 {
|
|
94 /* Look for remote's hangup string. We want to make sure our
|
|
95 modem sent our string. This is only necessary because some
|
|
96 version of UUCP complain if they don't get the hangup string.
|
|
97 We look for the string several times because some versions
|
|
98 supposedly send garbage after the last packet but before
|
|
99 the hangup string. */
|
|
100
|
|
101 for (i = 0; i < 25; ++i)
|
|
102 {
|
|
103 if (recv0 (string) == TIMEDOUT)
|
|
104 {
|
|
105 if (debuglvl > 0)
|
|
106 fprintf (log, "scloseuucp: %s\n", no_oo);
|
|
107
|
|
108 break;
|
|
109 }
|
|
110
|
|
111 if (strstr (string, o6) != NULL)
|
|
112 {
|
|
113 if (debuglvl > 0)
|
|
114 fprintf (log, "scloseuucp: %s\n", got_oo);
|
|
115
|
|
116 break;
|
|
117 }
|
|
118 }
|
|
119 }
|
|
120 normal_end = TRUE;
|
|
121 return (ABORT);
|
|
122 }
|