forked from oe5hpm/openBCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convers.cpp
215 lines (197 loc) · 6.24 KB
/
convers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/***************************************************************
BayCom(R) Packet-Radio fuer IBM PC
OpenBCM-Mailbox
--------------------------
Convers-Modus fuer Mailbox
--------------------------
Copyright (C) Florian Radlherr
Taubenbergstr. 32
83627 Warngau
Alle Rechte vorbehalten / All Rights Reserved
***************************************************************/
//19981001 OE3DZW removed obsolete parts of convers-code
// added putflush
//19991118 DF3VI no talk to user that is not logged in
//19991118 DF3VI change talk adress permanent or temporary
//19991118 DF3VI give little help
//19991119 DF3VI execute bbs-comand with !cmd
// mailbef() needs change: don't convers and logouts if convers
//19991127 DF3VI finished convers
//20000111 OE3DZW remove "!" command under DOS, needs too much stack
// dynamic allocation of buffer
#include "baycom.h"
/*---------------------------------------------------------------------------*/
int conversout (int prompt)
//*************************************************************************
//
//*************************************************************************
{
char s[LINELEN+1];
unsigned num;
int ok = 0;
conv_t *cp;
while (b->conv)
{
cp = b->conv;
b->conv = cp->next;
if (prompt) putv(LF);
if (cp->line[1] == 1)
{
if (sscanf(cp->line + 5, "%s %d", s, &num) == 2)
{
putf("*SYSTEM*: ");
putf(ms(m_msgarrived), s, num);
strcpy(b->prompt, b->logincall);
putv(LF);
sprintf(s, "%d", num);
b->optgroup = o_id;
mbdir(s, 0);
}
}
else
putf("%s\n", cp->line);
t_free(cp);
ok = 1;
prompt = 0;
}
return ok;
}
/*---------------------------------------------------------------------------*/
void convers_msg (int pending, char *befname)
//*************************************************************************
//
//*************************************************************************
{
strupr(befname);
if (! pending)
putf(ms(m_conv_notloggedon), befname);
else if (pending == 10 || pending == 15)
putf(ms(m_conv_linespending), befname, pending);
else if (pending > 19)
putf(ms(m_conv_toomanypending), befname);
return;
}
/*---------------------------------------------------------------------------*/
void convers (char *befbuf, char *befname)
//*************************************************************************
//
//*************************************************************************
{
char *s = (char *) t_malloc(BUFLEN, "conv"); //save stack
int conversaktiv = 1;
int pending;
char *msg;
msg = strchr(befbuf, ' ');
if (msg) *msg++ = 0;
strupr(befbuf);
b->job = j_convers;
if (eingelogt(befbuf, 0, 0) || ! strcmp(befbuf, "ALL"))
{
if (! msg)
{
putf(ms(m_conversto), befname, befbuf);
while (conversaktiv)
{
conversout(0);
if (getvalid())
{
getline(s, BUFLEN - 1, 1);
if (*s == '!')
{
mailbef(s + 1, 0);
putf(ms(m_conversto), befname, befbuf);
strcpy(s, befname);
strcat(s, " ");
strcat(s, befbuf);
lastcmd(s);
b->job = j_convers;
}
else
if (*s == '/')
{
switch (toupper(s[1]))
{
case 'Q':
case 'B':
putf(ms(m_conversend), befname);
conversaktiv = 0;
break;
case 'U':
case 'W': listusers(1); break;
case 'T': //Talk-Befehl
case 'M':
case 'C':
case 'S':
if (strchr(s, ' ')) // mit Argument
{
msg = strchr(s, ' ');
while (*msg == ' ') msg++;
if (! strchr(msg, ' ')) // EIN Arg: Neues Ziel
{
strupr(msg);
if ((eingelogt(msg, 0, 0) || (! stricmp(msg, "ALL"))))
{
strcpy(befbuf, msg); // Wenn eingeloggt, umschalten
strupr(befbuf);
putf(ms(m_conversto), befname, befbuf);
strcpy(s, befname);
strcat(s, " ");
strcat(s, befbuf);
lastcmd(s);
}
else
convers_msg(0, msg); // Sonst Fehlermeldung
}
else // Zwei o. mehr Argumente
{
char newcall[CALLEN+1];
msg = nextword(msg, newcall, CALLEN);
newcall[CALLEN] = 0;
strupr(newcall);
// subst1(newcall, ' ', 0);
if (eingelogt(newcall, 0, 0) || ! stricmp(newcall, "ALL"))
{
// while (*msg!=' ') msg++; // Call ueberlesen
pending = mbtalk(b->logincall, newcall, msg); // Text raus
convers_msg(pending, befname);
}
else
{
// subst1(msg, ' ', 0);
convers_msg(0, newcall); // Sonst Fehlermeldung
}
}
}
else // Kein Arg: Zielcall anzeigen
putf(ms(m_conversto), befname, befbuf);
break;
default: // Fehlermeldung
putf("/Quit /Bye /User /Who /Talk /Msg /Chat /Send !<cmd>\n");
}
}
else if (*s)
{
if (conversaktiv)
{
pending = mbtalk(b->logincall, befbuf, s);
convers_msg(pending, befname);
}
}
}
putflush();
timeout(m.usrtimeout);
wdelay(152);
}
}
else
{
pending = mbtalk(b->logincall, befbuf, msg);
convers_msg(pending, befname);
}
}
else
if (mbcallok(befbuf)) convers_msg(0, befbuf);
else putf(ms(m_syntaxconvers), befname);
t_free(s);
}
/*---------------------------------------------------------------------------*/