0
|
1 #ifndef POP
|
|
2 /* qu2bb_send.c - manager for qu --> bb */
|
|
3 #else POP
|
|
4 /* qu2po_send.c - manager for qu --> po */
|
|
5 #endif POP
|
|
6
|
|
7
|
|
8 #include "util.h"
|
|
9 #include "mmdf.h"
|
|
10 #include "phs.h"
|
|
11 #include "ch.h"
|
|
12
|
|
13 /* */
|
|
14
|
|
15 extern LLog *logptr;
|
|
16 extern char *supportaddr;
|
|
17
|
|
18 struct rp_construct rp_hend = { /* end of host list */
|
|
19 RP_NOOP,
|
|
20 'e', 'n', 'd', ' ', 'o', 'f', ' ', 'h', 'o', 's', 't', ' ',
|
|
21 'i', 'g', 'n', 'o', 'r', 'e', 'd',
|
|
22 NULL
|
|
23 };
|
|
24
|
|
25 struct rp_construct rp_aend = { /* end of address list */
|
|
26 RP_OK,
|
|
27 #ifndef POP
|
|
28 'b', 'b', 'o', 'a', 'r', 'd', 's', ' ', 'e', 'n', 'd', ' ',
|
|
29 #else POP
|
|
30 'p', 'o', 'p', ' ', 'e', 'n', 'd', ' ',
|
|
31 #endif POP
|
|
32 'o', 'f', ' ', 'a', 'd', 'd', 'r', ' ', 'l', 'i', 's', 't',
|
|
33 NULL
|
|
34 };
|
|
35
|
|
36 struct rp_construct rp_badr = { /* no such bboard */
|
|
37 RP_USER,
|
|
38 'u', 'n', 'k', 'n', 'o', 'w', 'n', ' ',
|
|
39 #ifndef POP
|
|
40 'b', 'b', 'o', 'a', 'r', 'd',
|
|
41 #else POP
|
|
42 'p', 'o', 'p', ' ', 's', 'u', 'b', 's', 'c', 'r', 'i', 'b', 'e', 'r',
|
|
43 #endif POP
|
|
44 NULL
|
|
45 };
|
|
46
|
|
47 struct rp_construct rp_err = { /* error, retry later */
|
|
48 RP_AGN,
|
|
49 'u', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r',
|
|
50 NULL
|
|
51 };
|
|
52
|
|
53 /* */
|
|
54
|
|
55 qu2bb_send (chanptr)
|
|
56 Chan *chanptr;
|
|
57 {
|
|
58 short result;
|
|
59 char info[LINESIZE],
|
|
60 sender[LINESIZE];
|
|
61
|
|
62 #ifdef DEBUG
|
|
63 ll_log (logptr, LLOGBTR, "qu2bb_send()");
|
|
64 #endif
|
|
65
|
|
66 if (rp_isbad (result = qu_pkinit ()))
|
|
67 return result;
|
|
68 if (rp_isbad (result = bb_sbinit ()))
|
|
69 return result;
|
|
70
|
|
71 while (rp_gval ((result =
|
|
72 qu_rinit (info, sender, chanptr -> ch_apout))) == RP_OK) {
|
|
73 #ifdef DEBUG
|
|
74 ll_log (logptr, LLOGGEN, "info=%s sender=%s", info, sender);
|
|
75 #endif
|
|
76 if (rp_isbad (result = bb_winit (info, sender)))
|
|
77 return result;
|
|
78 if (rp_isbad (result = qu2bb_each (sender)))
|
|
79 return result;
|
|
80 qu_rend();
|
|
81 }
|
|
82 qu_rend();
|
|
83
|
|
84 if (rp_gval (result) != RP_DONE) {
|
|
85 ll_log (logptr, LLOGTMP, "not DONE [%s]", rp_valstr (result));
|
|
86 return RP_RPLY;
|
|
87 }
|
|
88
|
|
89 qu_pkend ();
|
|
90 bb_sbend ();
|
|
91
|
|
92 return result;
|
|
93 }
|
|
94
|
|
95 /* */
|
|
96 LOCFUN
|
|
97 qu2bb_each (sender)
|
|
98 char *sender;
|
|
99 {
|
|
100 short result;
|
|
101 char adr[LINESIZE],
|
|
102 host[LINESIZE];
|
|
103 RP_Buf replyval;
|
|
104
|
|
105 #ifdef DEBUG
|
|
106 ll_log (logptr, LLOGBTR, "qu2bb_each(sender='%s')", sender);
|
|
107 #endif
|
|
108
|
|
109 FOREVER { /* loop through the addresses */
|
|
110 if (rp_isbad (result = qu_radr (host, adr)))
|
|
111 return result;
|
|
112 #ifdef RP_HOK
|
|
113 if (rp_gval (result) == RP_HOK) {/* no-op the sub-list indication */
|
|
114 qu_wrply ((struct rp_bufstruct *) &rp_hend, rp_conlen (rp_hend));
|
|
115 continue;
|
|
116 }
|
|
117 #endif RP_HOK
|
|
118 if (rp_gval (result) == RP_DONE) {
|
|
119 qu_wrply ((RP_Buf *) &rp_aend, rp_conlen (rp_aend));
|
|
120 return RP_OK;
|
|
121 }
|
|
122
|
|
123 switch (replyval.rp_val = bb_wtadr (host, adr)) {
|
|
124 case RP_AOK:
|
|
125 case RP_OK:
|
|
126 switch (replyval.rp_val = bb_txtcpy ()) {
|
|
127 case RP_MOK:
|
|
128 replyval.rp_line[0] = NULL;
|
|
129 break;
|
|
130 default:
|
|
131 ll_log (logptr, LLOGFAT, "unknown error [%s]",
|
|
132 rp_valstr (replyval.rp_val));
|
|
133 blt (&rp_err, (char *) &replyval, sizeof rp_err);
|
|
134 break;
|
|
135 }
|
|
136 break;
|
|
137
|
|
138 case RP_USER:
|
|
139 #ifndef POP
|
|
140 ll_log (logptr, LLOGFAT, "unknown bboard '%s'", adr);
|
|
141 #else POP
|
|
142 ll_log (logptr, LLOGFAT, "unknown pop subscriber '%s'", adr);
|
|
143 #endif POP
|
|
144 blt (&rp_badr, (char *) &replyval, sizeof rp_badr);
|
|
145 break;
|
|
146
|
|
147 default:
|
|
148 ll_log (logptr, LLOGFAT, "unknown error [%s]",
|
|
149 rp_valstr (replyval.rp_val));
|
|
150 blt (&rp_err, (char *) &replyval, sizeof rp_err);
|
|
151 break;
|
|
152 }
|
|
153
|
|
154 qu_wrply (&replyval,
|
|
155 (sizeof replyval.rp_val) + strlen (replyval.rp_line));
|
|
156 }
|
|
157 }
|