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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
|
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define _CRT_SECURE_NO_DEPRECATE
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#define LIBCONFIG_STATIC
#include <libconfig.h>
#ifndef WIN32
#include <iconv.h>
#endif
#include "compatbits.h"
#ifndef LINBPQ
#include "bpq32.h"
#include "BPQMailrc.h"
#include "dbghelp.h"
#else
#include "cheaders.h"
#endif
#include "asmstrucs.h"
#define MaxBPQPortNo 63 // Port 64 reserved for BBS Mon
#define MAXBPQPORTS 63
#define NEWROUTING
extern int FOURCHARCONT;
// Standard __except handler for try/except
VOID CheckProgramErrors();
VOID WriteMiniDump();
extern int ProgramErrors;
extern struct _EXCEPTION_POINTERS exinfox;
#ifdef WIN32
void Dump_Process_State(struct _EXCEPTION_POINTERS * exinfo, char * Msg);
#define My__except_Routine(Message) \
__except(memcpy(&exinfo, GetExceptionInformation(), sizeof(struct _EXCEPTION_POINTERS)), EXCEPTION_EXECUTE_HANDLER)\
{\
Debugprintf("MAILCHAT *** Program Error %x at %x in %s EAX %x EBX %x ECX %x EDX %x ESI %x EDI %x",\
exinfo.ExceptionRecord->ExceptionCode, exinfo.ExceptionRecord->ExceptionAddress, Message,\
exinfo.ContextRecord->Eax, exinfo.ContextRecord->Ebx, exinfo.ContextRecord->Ecx,\
exinfo.ContextRecord->Edx, exinfo.ContextRecord->Esi, exinfo.ContextRecord->Edi);\
CheckProgramErrors();\
WriteMiniDump();\
}
/*
#define My__except_Routine(Message) \
__except(memcpy(&exinfox, GetExceptionInformation(), sizeof(struct _EXCEPTION_POINTERS)), EXCEPTION_EXECUTE_HANDLER)\
{\
Dump_Process_State(&exinfox, Message);\
CheckProgramErrors();\
}
#define My__except_RoutineWithDisconnect(Message) \
__except(memcpy(&exinfo, GetExceptionInformation(), sizeof(struct _EXCEPTION_POINTERS)), EXCEPTION_EXECUTE_HANDLER)\
{\
Debugprintf("MAILCHAT *** Program Error %x at %x in %s EAX %x EBX %x ECX %x EDX %x ESI %x EDI %x",\
exinfo.ExceptionRecord->ExceptionCode, exinfo.ExceptionRecord->ExceptionAddress, Message,\
exinfo.ContextRecord->Eax, exinfo.ContextRecord->Ebx, exinfo.ContextRecord->Ecx,\
exinfo.ContextRecord->Edx, exinfo.ContextRecord->Esi, exinfo.ContextRecord->Edi);\
FreeSemaphore(&ChatSemaphore);\
if (conn->BPQStream < 0)\
CloseConsole(conn->BPQStream);\
else\
Disconnect(conn->BPQStream);\
}
*/
#define My_except_RoutineWithDiscBBS(Message) \
__except(memcpy(&exinfo, GetExceptionInformation(), sizeof(struct _EXCEPTION_POINTERS)), EXCEPTION_EXECUTE_HANDLER)\
{\
Debugprintf("MAILCHAT *** Program Error %x at %x in %s EAX %x EBX %x ECX %x EDX %x ESI %x EDI %x",\
exinfo.ExceptionRecord->ExceptionCode, exinfo.ExceptionRecord->ExceptionAddress, Message,\
exinfo.ContextRecord->Eax, exinfo.ContextRecord->Ebx, exinfo.ContextRecord->Ecx,\
exinfo.ContextRecord->Edx, exinfo.ContextRecord->Esi, exinfo.ContextRecord->Edi);\
if (conn->BPQStream < 0)\
CloseConsole(conn->BPQStream);\
else\
Disconnect(conn->BPQStream);\
CheckProgramErrors();\
}
#endif
#define MAXUSERNAMELEN 6
#define WSA_ACCEPT WM_USER + 1
#define WSA_CONNECT WM_USER + 2
#define WSA_DATA WM_USER + 3
#define NNTP_ACCEPT WM_USER + 4
#define NNTP_DATA WM_USER + 5
#ifdef _DEBUG
VOID * _malloc_dbg_trace(int len, int type, char * file, int line);
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define _recalloc(p, c, s) _recalloc_dbg(p, c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define free(p) _free_dbg(p, _NORMAL_BLOCK)
#define _strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define zalloc(s) _zalloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#else
#define zalloc(s) _zalloc(s)
#endif
#ifdef LINBPQ
#undef zalloc
#define zalloc _zalloc
#endif
VOID * _zalloc_dbg(size_t len, int type, char * file, int line);
#define LOG_BBS 0
#define LOG_CHAT 1
#define LOG_TCP 2
#define LOG_DEBUG_X 3
//Chat Duplicate suppression Code
#define MAXDUPS 10 // Number to keep
#define DUPSECONDS 5 // TIme to Keep
struct DUPINFO
{
time_t DupTime;
char DupUser[10];
char DupText[100];
};
struct UserRec
{
char * Callsign;
char * UserName;
char * Password;
};
typedef struct ConnectionInfo_S
{
struct ConnectionInfo_S *next;
PROC *proc;
UCHAR RadioOnlyMode; // T or R flag for Radio Only mode.
int Number; // Number of record - for Connections display
BOOL Active;
int BPQStream;
int paclen;
UCHAR Callsign[11]; // Station call including SSID
BOOL GotHeader;
UCHAR InputMode; // Line by Line or Binary or YAPP
UCHAR * InputBuffer;
int InputBufferLen;
int InputLen; // Data we have already = Offset of end of an incomplete packet;
struct UserInfo * UserPointer;
int Retries;
int LoginState; // 1 = user ok, 2 = password ok
int Flags;
// Data to the user is kept in a malloc'd buffer. This can be appended to,
// and data sucked out under both terminal and system flow control. PACLEN is
// enfored when sending to node.
UCHAR * OutputQueue; // Messages to user
int OutputQueueLength; // Total Malloc'ed size. Also Put Pointer for next Message
int OutputGetPointer; // Next byte to send. When Getpointer = Queue Length all is sent - free the buffer and start again.
int CloseAfterFlush; // Close session when all sent. Set to 100ms intervals to wait.
int ErrorCount; // Invalid Command count
BOOL Paging; // Set if user wants paging
int LinesSent; // Count when paging
int PageLen; // Lines per page
UCHAR * MailBuffer; // Mail Message being received
UCHAR * CopyBuffer; // Mail Message being forwarded
int MailBufferSize; // Total Malloc'ed size. Actual size in in Msg Struct
long lastmsg; // Last Listed. Stored here, updated in user record only on clean close
BOOL sysop; // Set if user is authenticated as a sysop
BOOL Secure_Session; // Set if Local Terminal, or Telnet connect with SYSOP status
UINT BBSFlags; // Set if defined as a bbs and SID received
struct MsgInfo * TempMsg; // Header while message is being received
struct MsgInfo * FwdMsg; // Header while message is being forwarded
char ** To; // May be several Recipients
int ToCount;
int BBSNumber; // The BBS number (offset into bitlist of BBSes to forward a message to
int NextMessagetoForward; // Next index to check in forward cycle
BOOL BPQBBS; // Set if SID indicates other end is BPQ
char MSGTYPES[20]; // Any MSGTYPEFLAGS
BOOL SendT; // Send T messages
BOOL SendP; // Send P messages
BOOL SendB; // Send Bulls
BOOL SendWL2KFW; // send ;FW:
int MaxBLen; // Max Size for this session
int MaxPLen; // Max Size for this session
int MaxTLen; // Max Size for this session
BOOL DoReverse; // Request Reverse Forward
char LastForwardType; // Last type of messages forwarded
struct FBBHeaderLine * FBBHeaders; // The Headers from an FFB forward block
char FBBReplyChars[36]; //The +-=!nnnn chars for the 5 proposals
int FBBReplyIndex; // current Reply Pointer
int FBBIndex; // current propopsal number
int RestartFrom; // Restart position
BOOL NeedRestartHeader; // Set if waiting for 6 byte restart header
BOOL DontSaveRestartData; // Set if corrupt data received
BOOL FBBMsgsSent; // Messages need to be maked as complete when next command received
UCHAR FBBChecksum; // Header Checksum
BOOL OpenBCM; // OpenBCM mode (escape -xFF chars)
BOOL InTelnetExcape; // Last Char was 0xff
BOOL LocalMsg; // Set if current Send command is for a local user
BOOL NewUser; // Set if first time user has accessed BBS
BOOL Paclink; // Set if receiving messages from Paclink
BOOL RMSExpress; // Set if receiving messages from RMS Express
BOOL WL2K; // Set if communicating with a CMS
BOOL PAT; // Set if communicating with PAT
char ** PacLinkCalls; // Calls we are getting messages for
BOOL SkipPrompt; // Set if a remote node sends a > at the end of his CTEXT
BOOL SkipConn; // Node sends "connected" in its CTEXT
int Watchdog; // Hung Circuit Detect.
int SessType; // BPQ32 sesstype bits
#define Sess_L2LINK 1
#define Sess_SESSION 2
#define Sess_UPLINK 4
#define Sess_DOWNLINK 8
#define Sess_BPQHOST 0x20
#define Sess_PACTOR 0x40
HANDLE DebugHandle; // File Handle for session-based debugging
char ARQFilename[256]; // Filename from ARQ:FILE:: Header
int ARQClearCount; // To make sure queues are flushed when sending
int SIDResponseTimer; // Used to detect incomplete handshake
char PQChallenge[20]; // Secure User logon challange
char SecureMsg[20]; // CMS Secure Signon Response
int MCastListenTime; // Time to run session for
int YAPPLen; // Bytes sent/received of YAPP Message
long YAPPDate; // Date for received file - if set enables YAPPC
int SyncCompressedLen;
int SyncXMLLen;
int SyncMsgLen;
char * SyncHost; // Saved so can send "request sync"
int SyncPort;
UCHAR * SyncMessage; // Compressed SYNC message to send
// These are used to detect CRLF split over a packet boundary
int usingCR; // Session is (normally) using CR as terminator
int lastLineEnd; // Terminator for current line
struct ConnectionInfo_S * SysopChatStream; // Stream sysop is chatting to
int bytesSent;
int bytesRxed;
} ConnectionInfo, CIRCUIT;
// Flags Equates
#define GETTINGUSER 1
#define GETTINGBBS 2
#define CHATMODE 4
#define GETTINGTITLE 8
#define GETTINGMESSAGE 16
#define CHATLINK 32 // Link to another Chat Node
#define SENDTITLE 64
#define SENDBODY 128
#define WAITPROMPT 256 // Waiting for prompt after message
#define PROPOSINGSYNCMSG 512 // Sent proposal to SYNC, waiting response
#define SENDINGSYNCMSG 1024 // Sent message to SYNC, waiting response
#define REQUESTINGSYNC 2048
#define GETTINGSYNCMESSAGE 4096 // Receiving body of a SYNC message
// BBSFlags Equates
#define BBS 1
#define FBBForwarding 2
#define FBBCompressed 4
#define FBBB1Mode 8
#define FBBB2Mode 16
#define RunningConnectScript 32
#define MBLFORWARDING 64 // MBL Style Frwarding- waiting for OK/NO or Prompt following message
#define TEXTFORWARDING 128 // Plain Text forwarding
#define OUTWARDCONNECT 256 // We connected to them
#define FLARQMODE 512 // Message from FLARQ
#define FLARQMAIL 1024 // Sending FLARQ Format Message
#define ARQMAILACK 2048 // Waiting for all data to be acked
#define NEEDLF 4096 // Add LF to forward script commands (fro Telnet
#define MCASTRX 8192 // Stream in Multicast RX Mode
#define DISCONNECTING 16384 // Disconnect sent to Node
#define YAPPTX 0x008000 // Sending YAPP file
#define SYSOPCHAT 0x010000 // Chatting to BBS console
#define WINLINKRO 0x020000 // WL2K RO (no J in SID)
#define SYNCMODE 0x040000 // RMS RELAY SYNC
#define MFJMODE 0x080000 // MFJ PMS
#define NEWPACCOM 0x100000 // PACCOM PMS 3.2
#define SETCALLTOSENDER 0x200000 // Set calling call to message sender
struct FBBRestartData
{
char Call[10];
char bid[13];
int length;
UCHAR * MailBuffer; // Mail Message being received
int MailBufferSize; // Total Malloc'ed size. Actual size in in Msg Struct
int Count; // Give up if too many restarts
time_t TimeCreated;
};
// We need to keep the B2Message file for B2 messages we are sending until the messages is acked, so
// we can restart it. Otherwise the file may change, resulting in a checksum error
struct B2RestartData
{
int CSize; // Compresses Size (B2 proto)
UCHAR * CompressedMsg; // Compressed Body fo B2
struct MsgInfo * FwdMsg;
struct UserInfo * UserPointer;
int Count; // Give up if too many restarts
};
//------ TAJ -----
typedef struct PGARGS
{
CIRCUIT * conn;
struct UserInfo * user;
char InputBuffer[80];
int Len;
}RUNPGARGS, *RUNPGARGS_PTR;
//---------------
#pragma pack(1)
struct TempUserInfo
{
int LastAuthCode; // Protect against playback attack
// Fields used to allow interrupting and resuming a paged listing
BOOL ListActive; // Doing a list
BOOL ListSuspended; // Paused doing a list
int LastListedInPagedMode;
char LastListCommand[80];
char LastListParams[80];
int LinesSent;
char SendFullFrom;
char ListType;
char ListDirn;
char ListStatus;
char ListSelector; // < > @ etc
int ListRangeStart;
int ListRangeEnd;
int LLCount; // Number still to send in List Last N
int UpdateLatest; // if set, save last listed as latest
BOOL IncludeKilled; // Show Killed Messages if SYSOP
//--- TAJ ---
int PG_INDEX; // current index of PG server
int PG_SERVER; // PG server to run
RUNPGARGS_PTR RUNPGPARAMS; // pointer to RUNPGARGS for dealloc
//-----------
};
#define PMSG 1
#define BMSG 2
#define TMSG 3
struct OldUserInfo
{
// Old format - without message type specific traffic counts
char Call[10]; // Connected call without SSID
// indicat relai[8]; /* 64 Digis path */
int lastmsg; /* 4 Last L number */
int ConnectsIn; /* 4 Number of connexions in*/
int TimeLastConnected; //Last connexion date */
// long lastyap __a2__ ; /* 4 Last YN date */
ULONG flags ; /* 4 Flags */
UCHAR PageLen; // Lines Per Page
UCHAR lang ; /* 1 Language */
int Xnewbanner; /* 4 Last Banner date */
short Xdownload ; /* 2 download size (KB) = 100 */
char POP3Locked ; // Nonzero if POP3 server has locked this user (stops other pop3 connections, or BBS user killing messages)
char BBSNumber; // BBS Bitmap Index Number
struct BBSForwardingInfo * ForwardingInfo;
struct UserInfo * BBSNext; // links BBS record
struct TempUserInfo * Temp; // Working Fields - not saved in user file
char xfree[6]; /* 6 Spare */
char Xtheme; /* 1 Current topic */
char Name[18]; /* 18 1st Name */
char Address[61]; /* 61 Address */
// Stats. Was City[31]; /* 31 City */
int MsgsReceived;
int MsgsSent;
int MsgsRejectedIn; // Messages we reject
int MsgsRejectedOut; // Messages Rejectd by other end
int BytesForwardedIn;
int BytesForwardedOut;
int ConnectsOut; // Forwarding Connects Out
USHORT RMSSSIDBits; // SSID's to poll in RMS
char Spare1;
char HomeBBS[41]; /* 41 home BBS */
char QRA[7]; /* 7 Qth Locator */
char pass[13]; /* 13 Password */
char ZIP[9]; /* 9 Zipcode */
BOOL spare;
} ; /* Total : 360 bytes */
struct MsgStats
{
int ConnectsIn; /* 4 Number of connexions in*/
int ConnectsOut; // Forwarding Connects Out
// Stats saveed by message type
int MsgsReceived[4];
int MsgsSent[4];
int MsgsRejectedIn[4]; // Messages we reject
int MsgsRejectedOut[4]; // Messages Rejectd by other end
int BytesForwardedIn[4];
int BytesForwardedOut[4];
};
struct UserInfo
{
// New Format - with stats maintained by message type and unused fields removed.
// This is no longer a fixed length record so can't be saved as a binarl
char Call[10]; // Connected call without SSID
int Length; // To make subsequent format changes easier
int lastmsg; /* 4 Last L number */
int xTimeLastConnected; //Last connexion date */
ULONG flags ; /* 4 Flags */
UCHAR PageLen; // Lines Per Page
char POP3Locked ; // Nonzero if POP3 server has locked this user (stops other pop3 connections, or BBS user killing messages)
unsigned char BBSNumber; // BBS Bitmap Index Number
struct BBSForwardingInfo * ForwardingInfo;
struct UserInfo * BBSNext; // links BBS record
struct TempUserInfo * Temp; // Working Fields - not saved in user file
char Name[18]; /* 18 1st Name */
char Address[61]; /* 61 Address */
USHORT RMSSSIDBits; // SSID's to poll in RMS
char HomeBBS[41]; /* 41 home BBS */
char QRA[7]; /* 7 Qth Locator */
char pass[13]; /* 13 Password */
char ZIP[9]; /* 9 Zipcode */
struct MsgStats Total;
struct MsgStats Last;
char CMSPass[16]; // For Secure Signon
int WebSeqNo;
long long TimeLastConnected; //Last connection date */
char Filler[44 - 8]; // So we can add a few fields wirhout another resize
};
// flags equates
#define F_Excluded 0x0001
#define F_GGG 0x0002
#define F_Expert 0x0004
#define F_SYSOP 0x0008
#define F_BBS 0x0010
#define F_RMSREDIRECT 0x0020
#define F_BBB 0x0040
#define F_CCC 0x0080
#define F_DDD 0x0100
#define F_EEE 0x0200
#define F_FFF 0x0400
#define F_PMS 0x0800
#define F_EMAIL 0x1000
#define F_HOLDMAIL 0x2000
#define F_POLLRMS 0x4000
#define F_SYSOP_IN_LM 0x8000
#define F_Temp_B2_BBS 0x00010000 // "Winlink Express User"
#define F_NOWINLINK 0x00020000 // Don't add Winlink.org
#define F_NOBULLS 0x00040000
#define F_NTSMPS 0x00080000
#define F_APRSMFOR 0x00100000 // Send APRS message for new mail
#define F_APRSSSID 0xF0000000 // (Top 4 Bits
struct Override
{
char * Call;
int Days;
};
struct ALIAS
{
char * Alias;
char * Dest;
};
typedef struct _MESSAGEX
{
// BASIC LINK LEVEL MESSAGE BUFFER LAYOUT
struct _MESSAGEX * CHAIN;
UCHAR PORT;
USHORT LENGTH;
UCHAR DEST[7];
UCHAR ORIGIN[7];
// MAY BE UP TO 56 BYTES OF DIGIS
UCHAR CTL;
UCHAR PID;
UCHAR DATA[256];
UCHAR DIGIS[56]; // Padding in case we have digis
}MESSAGEX, *PMESSAGEX;
#pragma pack()
// Message Database Entry. Designed to be compatible with FBB
#define NBBBS 160 // Max BBSes we can forward to. Must be Multiple of 8, and must be 80 for FBB compatibliliy
#define NBMASK NBBBS/8 // Number of bytes in Forward bitlists.
#pragma pack(1)
struct OldMsgInfo
{
char type ;
char status ;
int number ;
int length ;
int datereceived;
char bbsfrom[7] ; // ? BBS we got it from ?
char via[41] ;
char from[7] ;
char to[7] ;
char bid[13] ;
char title[61] ;
char bin;
int nntpnum; // Number within topic (ie Bull TO Addr) - used for nntp
UCHAR B2Flags;
char free[4];
unsigned short nblu;
int theme ;
time_t datecreated ;
time_t datechanged ;
char fbbs[10] ;
char forw[10] ;
char emailfrom[41];
} ;
struct MsgInfo
{
char type;
char status;
int number;
int length;
int xdatereceived;
char bbsfrom[7]; // ? BBS we got it from ?
char via[41];
char from[7];
char to[7];
char bid[13];
char title[61];
int nntpnum; // Number within topic (ie Bull TO Addr) - used for nntp
UCHAR B2Flags; // Not all flags specific to B2
#define B2Msg 1 // Set if Message File is a formatted B2 message
#define Attachments 2 // Set if B2 message has attachments
#define FromPaclink 4
#define FromCMS 8
#define FromRMSExpress 16
#define RadioOnlyMsg 32 // Received using call-T
#define RadioOnlyFwd 64 // Received using call-R
#define WarnNotForwardedSent 128
int xdatecreated;
int xdatechanged;
UCHAR fbbs[NBMASK];
UCHAR forw[NBMASK];
char emailfrom[41];
char Locked; // Set if selected for sending (NTS Pickup)
char Defered; // FBB response '=' received
UCHAR UTF8; // Set if Message is in UTF8 (ie from POP/SMTP)
// For 64 bit time_t compatibility define as long long
// (so struct is same with 32 or 64 bit time_t)
int64_t datereceived;
int64_t datecreated;
int64_t datechanged;
char Spare[61 - 24]; // For future use
} ;
#define MSGTYPE_B 0
#define MSGTYPE_P 1
#define MSGSTATUS_N 0
#define MSGSTATUS_Y 1
#define MSGSTATUS_F 2
#define MSGSTATUS_K 3
#define MSGSTATUS_H 4
#define MSGSTATUS_D 5
#define MSGSTATUS_$ 6
struct NNTPRec
{
// Used for NNTP access to Bulls
struct NNTPRec * Next; // Record held in chain, so can be held sorted
char NewsGroup[64]; // = Bull TO.at field
int FirstMsg; // Lowest Number
int LastMsg; // Highest Number
int Count; // Active Msgs
time_t DateCreated; // COntains Creation Date of First Bull in Group
};
typedef struct {
char mode;
char BID[13];
union
{ /* array named screen */
struct
{
unsigned short msgno;
unsigned short timestamp;
};
CIRCUIT * conn;
} u;
} BIDRec, *BIDRecP;
typedef struct WPDBASE{ /* 194 bytes */
char callsign[7];
char name[13];
unsigned char Type;
unsigned char changed;
unsigned short seen;
long long last_modif;
long long last_seen;
char first_homebbs[41];
char secnd_homebbs[41];
char first_zip[9];
char secnd_zip[9];
char first_qth[31];
char secnd_qth[31];
} WPRec, * WPRecP;
#pragma pack()
struct FWDBAND
{
time_t FWDStartBand;
time_t FWDEndBand;
};
struct BBSForwardingInfo
{
// Holds info for forwarding
BOOL Enabled; // Forwarding Enabled
char ** ConnectScript; // Main Connect Script
char ** TempConnectScript; // Used with FWD command.
int ScriptIndex; // Next line in script
BOOL MoreLines; // Set until script is finsihed
char ** TOCalls; // Calls in to field
char ** ATCalls; // Calls in ATBBS field
char ** HaddressesP; // Heirarchical Addresses for Personals to forward to (as stored)
char *** HADDRSP; // Heirarchical Addresses for Personals to forward to
char ** Haddresses; // Heirarchical Addresses to forward to (as stored)
char *** HADDRS; // Heirarchical Addresses to forward to
int * HADDROffet; // Elements added to complete the HR. At least n+1 must match to forward
char ** FWDTimes; // Time bands to forward
struct FWDBAND ** FWDBands;
int MsgCount; // Messages for this BBS
BOOL ReverseFlag; // Set if BBS wants to poll for reverse forwarding
BOOL Forwarding; // Forward in progress
int MaxFBBBlockSize;
BOOL AllowBlocked; // Allow FBB Blocked
BOOL AllowCompressed; // Allow FBB Compressed
BOOL AllowB1; // Enable B1
BOOL AllowB2; // Enable B2
BOOL SendCTRLZ; // Send Ctrl/z instead of /ex
BOOL PersonalOnly; // Only Forward Personals
BOOL SendNew; // Forward new messages immediately
int FwdInterval;
int RevFwdInterval;
int FwdTimer;
time_t LastReverseForward;
char *BBSHA; // HA of BBS
char ** BBSHAElements; // elements of HA of BBS
int ConTimeout;
// char UserCall[10]; // User we are forwarding on behalf of (Currently only for RMS)
// int UserIndex; // index of User we are forwarding on behalf of (Currently only for RMS)
};
struct FBBHeaderLine
{
// Holds the info from the (up to) 5 headers presented at the start of a Forward Block
char Format; // Ascii or Binary
char MsgType; // P B etc
char From[7]; // Sender
char ATBBS[41]; // BBS of recipient (@ Field)
char To[7]; // Recipient
char BID[13];
int Size;
int CSize; // Compresses Size (B2 proto)
BOOL B2Message; // Set if an FC type
UCHAR * CompressedMsg; // Compressed Body fo B2
struct MsgInfo * FwdMsg; // Header so we can mark as complete
};
#define MAXSTACK 20
//#define MAXLINE 10000
#define INPUTLEN 512
#define MAXLINES 1000
#define LINELEN 200
extern char RTFHeader[4000];
extern int RTFHddrLen;
struct ConsoleInfo
{
struct ConsoleInfo * next;
CIRCUIT * Console;
int BPQStream;
WNDPROC wpOrigInputProc;
HWND hConsole;
HWND hwndInput;
HWND hwndOutput;
HMENU hMenu; // handle of menu
RECT ConsoleRect;
RECT OutputRect;
int Height, Width, LastY;
int ClientHeight, ClientWidth;
char kbbuf[INPUTLEN];
int kbptr;
char * readbuff; // Malloc'ed
int readbufflen; // Current Length
char * KbdStack[MAXSTACK];
int StackIndex;
BOOL Bells;
BOOL FlashOnBell; // Flash instead of Beep
BOOL StripLF;
BOOL WarnWrap;
BOOL FlashOnConnect;
BOOL WrapInput;
BOOL CloseWindowOnBye;
unsigned int WrapLen;
int WarnLen;
int maxlinelen;
int PartLinePtr;
int PartLineIndex; // Listbox index of (last) incomplete line
DWORD dwCharX; // average width of characters
DWORD dwCharY; // height of characters
DWORD dwClientX; // width of client area
DWORD dwClientY; // height of client area
DWORD dwLineLen; // line length
int nCaretPosX; // horizontal position of caret
int nCaretPosY; // vertical position of caret
COLORREF FGColour; // Text Colour
COLORREF BGColour; // Background Colour
COLORREF DefaultColour; // Default Text Colour
int CurrentLine; // Line we are writing to in circular buffer.
int Index;
BOOL SendHeader;
BOOL Finished;
char OutputScreen[MAXLINES][LINELEN];
int Colourvalue[MAXLINES];
int LineLen[MAXLINES];
int CurrentColour;
int Thumb;
int FirstTime;
BOOL Scrolled; // Set if scrolled back
int RTFHeight; // Height of RTF control in pixels
};
struct MSESSION
{
struct MSESSION * Next;
unsigned int Key;
char * FileName;
char * OrigTimeStamp;
unsigned char * Message;
int MessageLen;
unsigned char * BlockList;
char * ID;
int BlockSize;
int BlockCount;
int BlocksReceived;
BOOL Completed;
time_t Created;
time_t LastUpdated;
int Index; // Line in Display
};
char * strlop(char * buf, char delim);
int rt_cmd(CIRCUIT *circuit, char * Buffer);
CIRCUIT *circuit_new(CIRCUIT *circuit, int flags);
VOID BBSputs(CIRCUIT * conn, char * buf);
VOID FBBputs(CIRCUIT * conn, char * buf);
void makelinks(void);
VOID * _zalloc(size_t len);
VOID FreeChatMemory();
VOID ChatTimer();
VOID nputs(CIRCUIT * conn, char * buf);
VOID node_close();
VOID removelinks();
VOID SetupChat();
VOID SendChatLinkStatus();
VOID ClearChatLinkStatus();
VOID Send_MON_Datagram(UCHAR * Msg, DWORD Len);
#define Connect(stream) SessionControl(stream,1,0)
#define Disconnect(stream) SessionControl(stream,2,0)
#define ReturntoNode(stream) SessionControl(stream,3,0)
#define ConnectUsingAppl(stream, appl) SessionControl(stream, 0, appl)
int EncryptPass(char * Pass, char * Encrypt);
VOID DecryptPass(char * Encrypt, unsigned char * Pass, unsigned int len);
// TCP Connections. FOr the moment SMTP or POP3
typedef struct SocketConnectionInfo
{
struct SocketConnectionInfo * Next;
int Number; // Number of record - for Connections display
SOCKET socket;
SOCKADDR_IN sin;
int Type; // SMTP or POP3
BOOL AMPR; // Set if sending to an AMPR.ORG server
char FromDomain[50]; // Domain we are sending from
struct UserInfo * bbs; // BBS dor forwarding to AMPR
int State; // Transaction State Machine
UCHAR CallSign[10];
UCHAR TCPBuffer[3000]; // For converting byte stream to messages
int InputLen; // Data we have alreasdy = Offset of end of an incomplete packet;
char * MailFrom; // Envelope Sender and Receiver
char ** RecpTo; // May be several Recipients
int Recipients;
UCHAR * MailBuffer; // Mail Message being received. malloc'ed as needed
int MailBufferSize; // Total Malloc'ed size. Actual size is in MailSize
int MailSize;
int Flags;
struct UserInfo * POP3User;
struct MsgInfo ** POP3Msgs; // Header List of messages for this uaer
int POP3MsgCount; // No of Messages
int POP3MsgNum; // Sequence number of message being received
struct MsgInfo * SMTPMsg; // message for this SMTP connection
UCHAR * SendBuffer; // Message being sent if socket is busy. malloc'ed as needed
int SendBufferSize; // Total Malloc'ed size. Actual size is in MailSize
int SendSize; // Bytes in buffer
int SendPtr; // next byte to send when ready
struct NNTPRec * NNTPGroup; // Currently Selected Group
int NNTPNum; // Currenrly Selected Msg Number
int Timeout; // Used to close a session that is open too long
} SocketConn;
// FBB reject.sys like filters
typedef struct FBBFILTER
{
struct FBBFILTER * Next;
char Action;
char Type;
char From[10];
char AT[10];
char TO[10];
char BID[16];
int MaxLen;
} FBBFilter;
extern FBBFilter * Filters;
typedef struct KEYVALUES
{
char * Key;
char * Value;
} KeyValues;
typedef struct WEBMAILINFO
{
// Info for HTML Forms Processing
struct HtmlFormDir * Dir; // HTML Directory
char * txtFileName; // Template Name for current message
char * InputHTMLName; // Template to input message
char * DisplayHTMLName; // Template to display message
char * ReplyHTMLName; // Template for replying to message
char * txtFile; // Template data
char * OrigTo; // To field when template loaded
char * OrigSubject; // Subject field when template loaded
char * OrigBody; // Msg text when template loaded
char * OrigBID;
char OrigType;
char * To;
char * CC;
char * Subject;
char * Body;
char * BID;
char Type;
struct MsgInfo * Msg; // Msg record if replying
KeyValues txtKeys[1000]; // Key/Value pairs for txt template. Used when creating or displaying
KeyValues XMLKeys[1000]; // Key/Value pairs from XML attachment
BOOL isReply;
char * XMLName;
char * XML; // XML attachment
int XMLLen;
int Files;
char * FileName[100]; // Attachments
char * FileBody[100];
int FileLen[100];
char * Header;
int HeaderLen;
char * Footer;
int FooterLen;
char * Reply; // put in here to save passing lots of parameters
int * RLen;
BOOL Winlink;
BOOL P2P;
BOOL Packet;
int CurrentMessageIndex; // Index of message currently displayed (for Prev and Next)
#ifdef WIN32
void * iconv_toUTF8; // Used on Linux for char set conversion
#else
iconv_t * iconv_toUTF8; // Used on Linux for char set conversion
#endif
}WebMailInfo;
#define SMTPServer 1
#define POP3SLAVE 2
#define SMTPClient 3
#define POP3Client 4
#define NNTPServer 5
// State Values
#define GettingUser 1
#define GettingPass 2
#define Authenticated 4
#define Connecting 8
// SMTP Master
#define WaitingForGreeting 16
#define WaitingForHELOResponse 32
#define WaitingForFROMResponse 64
#define WaitingForTOResponse 128
#define WaitingForDATAResponse 256
#define WaitingForBodyResponse 512
#define WaitingForAUTHResponse 1024
// POP3 Master
#define WaitingForUSERResponse 32
#define WaitingForPASSResponse 64
#define WaitingForSTATResponse 128
#define WaitingForUIDLResponse 256
#define WaitingForLISTResponse 512
#define WaitingForRETRResponse 512
#define WaitingForDELEResponse 1024
#define WaitingForQUITResponse 2048
#define SE 240 // End of subnegotiation parameters
#define NOP 241 //No operation
//#define DM 242 //Data mark Indicates the position of a Synch event within the data stream. This should always be accompanied by a TCP urgent notification.
#define BRK 243 //Break Indicates that the "break" or "attention" key was hi.
#define IP 244 //Suspend Interrupt or abort the process to which the NVT is connected.
#define AO 245 //Abort output Allows the current process to run to completion but does not send its output to the user.
#define AYT 246 //Are you there Send back to the NVT some visible evidence that the AYT was received.
#define EC 247 //Erase character The receiver should delete the last preceding undeleted character from the data stream.
#define EL 248 //Erase line Delete characters from the data stream back to but not including the previous CRLF.
#define GA 249 //Go ahead Under certain circumstances used to tell the other end that it can transmit.
#define SB 250 //Subnegotiation Subnegotiation of the indicated option follows.
#define WILL 251 //will Indicates the desire to begin performing, or confirmation that you are now performing, the indicated option.
#define WONT 252 //wont Indicates the refusal to perform, or continue performing, the indicated option.
#define DOx 253 //do Indicates the request that the other party perform, or confirmation that you are expecting the other party to perform, the indicated option.
#define DONT 254 //dont Indicates the demand that the other party stop performing, or confirmation that you are no longer expecting the other party to perform, the indicated option.
#define IAC 255
#define suppressgoahead 3 //858
//#define Status 5 //859
//#define echo 1 //857
#define timingmark 6 //860
#define terminaltype 24 //1091
#define windowsize 31 //1073
#define terminalspeed 32 //1079
#define remoteflowcontrol 33 //1372
#define linemode 34 //1184
#define environmentvariables 36 //1408
BOOL Initialise();
#ifdef WIN32
INT_PTR CALLBACK ConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
#endif
int DisplaySessions();
int DoStateChange(int Stream);
int DoReceivedData(int Stream);
int DoBBSMonitorData(int Stream);
int Connected(int Stream);
int Disconnected(int Stream);
//int Socket_Accept(int SocketId);
//int Socket_Data(int SocketId,int error, int eventcode);
int DataSocket_Read(SocketConn * sockptr, SOCKET sock);
int DataSocket_Write(SocketConn * sockptr, SOCKET sock);
int DataSocket_Disconnect(SocketConn * sockptr);
int RefreshMainWindow();
int Terminate();
int SendtoSocket(SOCKET sock,char * Msg);
int WriteLog(char * msg);
int ConnectState(int Stream);
UCHAR * EncodeCall(UCHAR * Call);
int ParseIniFile(char * fn);
struct UserInfo * AllocateUserRecord(char * Call);
struct MsgInfo * AllocateMsgRecord();
BIDRec * AllocateBIDRecord();
BIDRec * AllocateTempBIDRecord();
struct UserInfo * LookupCall(char * Call);
BIDRec * LookupBID(char * BID);
BIDRec * LookupTempBID(char * BID);
VOID RemoveTempBIDS(CIRCUIT * conn);
VOID SaveUserDatabase();
VOID GetUserDatabase();
VOID GetMessageDatabase();
VOID SaveMessageDatabase();
VOID GetBIDDatabase();
VOID SaveBIDDatabase();
VOID GetWPDatabase();
VOID CopyWPDatabase();
VOID SaveWPDatabase();
VOID GetBadWordFile();
WPRec * LookupWP(char * Call);
VOID SendWelcomeMsg(int Stream, ConnectionInfo * conn, struct UserInfo * user);
VOID ProcessLine(ConnectionInfo * conn, struct UserInfo * user, char* Buffer, int len);
VOID ProcessChatLine(ConnectionInfo * conn, struct UserInfo * user, char* Buffer, int len);
VOID SendPrompt(ConnectionInfo * conn, struct UserInfo * user);
int QueueMsg( ConnectionInfo * conn, char * msg, int len);
VOID SendUnbuffered(int stream, char * msg, int len);
//int GetFileList(char * Dir);
BOOL ListMessage(struct MsgInfo * Msg, ConnectionInfo * conn, struct TempUserInfo * Temp);
void DoDeliveredCommand(CIRCUIT * conn, struct UserInfo * user, char * Cmd, char * Arg1, char * Context);
void DoKillCommand(ConnectionInfo * conn, struct UserInfo * user, char * Cmd, char * Arg1, char * Context);
void DoListCommand(ConnectionInfo * conn, struct UserInfo * user, char * Cmd, char * Arg1, BOOL Resuming, char * Context);
void DoReadCommand(ConnectionInfo * conn, struct UserInfo * user, char * Cmd, char * Arg1, char * Context);
void KillMessage(ConnectionInfo * conn, struct UserInfo * user, int msgno);
int KillMessagesTo(ConnectionInfo * conn, struct UserInfo * user, char * Call);
int KillMessagesFrom(ConnectionInfo * conn, struct UserInfo * user, char * Call);
void DoUnholdCommand(CIRCUIT * conn, struct UserInfo * user, char * Cmd, char * Arg1, char * Context);
VOID FlagAsKilled(struct MsgInfo * Msg, BOOL SaveDB);
int ListMessagesFrom(ConnectionInfo * conn, struct UserInfo * user, char * Call, BOOL SendFullFrom, int Start);
int ListMessagesTo(ConnectionInfo * conn, struct UserInfo * user, char * Call, BOOL SendFullFrom, int Start);
int ListMessagesAT(ConnectionInfo * conn, struct UserInfo * user, char * Call, BOOL SendFullFrom, int Start);
void ListMessagesInRange(ConnectionInfo * conn, struct UserInfo * user, char * Call, int Start, int End, BOOL SendFullFrom );
void ListMessagesInRangeForwards(ConnectionInfo * conn, struct UserInfo * user, char * Call, int Start, int End, BOOL SendFullFrom );
int GetUserMsg(int m, char * Call, BOOL SYSOP);
void Flush(ConnectionInfo * conn);
VOID ClearQueue(ConnectionInfo * conn);
void TrytoSend();
void ReadMessage(ConnectionInfo * conn, struct UserInfo * user, int msgno);
struct MsgInfo * FindMessage(char * Call, int msgno, BOOL sysop);
char * ReadMessageFile(int msgno);
char * ReadInfoFile(char * File);
char * FormatDateAndTime(time_t Datim, BOOL DateOnly);
int CriticalErrorHandler(char * error);
BOOL DoSendCommand(ConnectionInfo * conn, struct UserInfo * user, char * Cmd, char * Arg1, char * Context);
BOOL CreateMessage(ConnectionInfo * conn, char * From, char * ToCall, char * ATBBS, char MsgType, char * BID, char * Title);
VOID ProcessMsgTitle(ConnectionInfo * conn, struct UserInfo * user, char* Buffer, int len);
VOID ProcessMsgLine(CIRCUIT * conn, struct UserInfo * user, char* Buffer, int len);
VOID CreateMessageFile(ConnectionInfo * conn, struct MsgInfo * Msg);
int ProcessConnecting(CIRCUIT * circuit, char * Buffer, int Len);
VOID SaveConfig(char * ConfigName);
BOOL GetConfig(char * ConfigName);
int GetIntValue(config_setting_t * group, char * name);
//BOOL GetStringValue(config_setting_t * group, char * name, char * value, int maxlen);
BOOL GetConfigFromRegistry();
VOID Parse_SID(CIRCUIT * conn, char * SID, int len);
VOID ProcessMBLLine(CIRCUIT * conn, struct UserInfo * user, UCHAR* Buffer, int len);
VOID ProcessFBBLine(ConnectionInfo * conn, struct UserInfo * user, UCHAR * Buffer, int len);
VOID SetupNextFBBMessage(CIRCUIT * conn);
BOOL DecodeSendParams(CIRCUIT * conn, char * Context, char ** From, char * To, char ** ATBBS, char ** BID);
int PrintMessages(HWND hDlg, int Count, int * Indexes);
int check_fwd_bit(char *mask, int bbsnumber);
void set_fwd_bit(char *mask, int bbsnumber);
void clear_fwd_bit (char *mask, int bbsnumber);
VOID SetupForwardingStruct(struct UserInfo * user);
BOOL Forward_Message(struct UserInfo * user, struct MsgInfo * Msg);
VOID StartForwarding (int BBSNumber, char ** TempScript);
BOOL Reverse_Forward();
int ProcessBBSConnectScript(CIRCUIT * conn, char * Buffer, int len);
BOOL FBBDoForward(CIRCUIT * conn);
BOOL FindMessagestoForward(CIRCUIT * conn);
BOOL SeeifMessagestoForward(int BBSNumber, CIRCUIT * Conn);
int CountMessagestoForward(struct UserInfo * user);
int CountBytestoForward(struct UserInfo * user);
VOID * GetMultiLineDialogParam(HWND hDialog, int DLGItem);
VOID * GetMultiStringValue(config_setting_t * hKey, char * ValueName);
VOID * RegGetMultiStringValue(HKEY hKey, char * ValueName);
int MultiLineDialogToREG_MULTI_SZ(HWND hWnd, int DLGItem, HKEY hKey, char * ValueName);
int Do_BBS_Sel_Changed(HWND hDlg);
VOID FreeForwardingStruct(struct UserInfo * user);
VOID FreeList(char ** Hddr);
int Do_User_Sel_Changed(HWND hDlg);
int Do_Msg_Sel_Changed(HWND hDlg);
VOID Do_Save_Msg();
VOID Do_Add_User(HWND hDlg);
VOID Do_Delete_User(HWND hDlg);
VOID FlagSentMessages(CIRCUIT * conn, struct UserInfo * user);
VOID HoldSentMessages(CIRCUIT * conn, struct UserInfo * user);
VOID Do_Save_User(HWND hDlg, BOOL ShowBox);
VOID DeleteBBS(struct UserInfo * user);
VOID SaveBBSConfig();
BOOL GetChatConfig(char * ConfigName);
VOID SaveChatConfig();
VOID SaveISPConfig();
VOID SaveFWDConfig();
VOID SaveMAINTConfig();
VOID SaveWelcomeMsgs();
VOID SavePrompts();
VOID ReinitializeFWDStruct(struct UserInfo * user);
VOID CopyBIDDatabase();
VOID CopyMessageDatabase();
VOID CopyUserDatabase();
VOID FWDTimerProc();
VOID CreateMessageFromBuffer(CIRCUIT * conn);
VOID __cdecl nodeprintf(ConnectionInfo * conn, const char * format, ...);
VOID __cdecl nodeprintfEx(ConnectionInfo * conn, const char * format, ...);
VOID FreeOverrides();
VOID SendMessageToSYSOP(char * Title, char * MailBuffer, int Length);
struct UserInfo * FindRMS();
VOID FindNextRMSUser(struct BBSForwardingInfo * FWDInfo);
BOOL ConnecttoBBS (struct UserInfo * user);
BOOL SetupNewBBS(struct UserInfo * user);
VOID CreateRegBackup();
VOID SaveFilters(HWND hDlg);
BOOL CheckRejFilters(char * From, char * To, char * ATBBS, char * BID, char Type, int Len);
BOOL CheckHoldFilters(struct MsgInfo * Msg, char * From, char * To, char * ATBBS, char * BID);
BOOL CheckifLocalRMSUser(char * FullTo);
VOID DoWPLookup(ConnectionInfo * conn, struct UserInfo * user, char Type, char *Context);
BOOL wildcardcompare(char * Target, char * Match);
VOID SendWarningToSYSOP(struct MsgInfo * Msg);
VOID DoEditUserCmd(CIRCUIT * conn, struct UserInfo * user, char * Arg1, char * Context);
VOID DoPollRMSCmd(CIRCUIT * conn, struct UserInfo * user, char * Arg1, char * Context);
VOID DoShowRMSCmd(CIRCUIT * conn, struct UserInfo * user, char * Arg1, char * Context);
VOID DoSetIdleTime(CIRCUIT * conn, struct UserInfo * user, char * Arg1, char * Context);
VOID DoFwdCmd(CIRCUIT * conn, struct UserInfo * user, char * Arg1, char * Context);
VOID SaveFwdParams(char * Call, struct BBSForwardingInfo * ForwardingInfo);
VOID DoAuthCmd(CIRCUIT * conn, struct UserInfo * user, char * Arg1, char * Context);
VOID ProcessSuspendedListCommand(CIRCUIT * conn, struct UserInfo * user, char* Buffer, int len);
VOID DoReroute(CIRCUIT * conn, struct UserInfo * user);
// FBB Routines
VOID SendCompressed(CIRCUIT * conn, struct MsgInfo * FwdMsg);
VOID SendCompressedB2(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader);
VOID UnpackFBBBinary(CIRCUIT * conn);
void Decode(CIRCUIT * conn, __int16 DecodeOnly);
//long Encode(char * in, char * out, long inlen, BOOL B1Protocol);
BOOL CreateB2Message(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader, char * Rline);
VOID SaveFBBBinary(CIRCUIT * conn);
BOOL LookupRestart(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader);
BOOL DoWeWantIt(CIRCUIT * conn, struct FBBHeaderLine * FBBHeader);
// Console Routines
BOOL CreateConsole(int Stream);
int WritetoConsoleWindow(int Stream, char * Msg, int len);
int ToggleParam(HMENU hMenu, HWND hWnd, BOOL * Param, int Item);
void CopyRichTextToClipboard(HWND hWnd);
void CopyToClipboard(HWND hWnd);
VOID CloseConsole(int Stream);
// Monitor Routines
BOOL CreateMonitor();
int WritetoMonitorWindow(char * Msg, int len);
BOOL CreateDebugWindow();
VOID WritetoDebugWindow(char * Msg, int len);
VOID ClearDebugWindow();
int RemoveLF(char * Message, int len);
// Utilities
BOOL isdigits(char * string);
void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line);
void FreeSemaphore(struct SEM * Semaphore);
VOID __cdecl Debugprintf(const char * format, ...);
VOID __cdecl Logprintf(int LogMode, CIRCUIT * conn, int InOut, const char * format, ...);
VOID SortBBSChain();
VOID ExpandAndSendMessage(CIRCUIT * conn, char * Msg, int LOG);
int ImportMessages(CIRCUIT * conn, char * FN, BOOL Nopopup);
// TCP Routines
BOOL InitialiseTCP();
VOID SetupListenSet();
VOID TCPTimer();
VOID TCPFastTimer();
int Socket_Data(int sock, int error, int eventcode);
static int Socket_Accept(SOCKET SocketId);
int Socket_Connect(SOCKET sock, int Error);
VOID ProcessSMTPServerMessage(SocketConn * sockptr, char * Buffer, int Len);
int CreateSMTPMessage(SocketConn * sockptr, int i, char * MsgTitle, time_t Date, char * MsgBody, int Msglen, BOOL B2Flag);
BOOL CreateSMTPMessageFile(char * Message, struct MsgInfo * Msg);
SOCKET CreateListeningSocket(int Port);
int TidyString(char * MailFrom);
VOID ProcessPOP3ServerMessage(SocketConn * sockptr, char * Buffer, int Len);
char *str_base64_encode(char *str);
int b64decode(char *str);
SocketConn * SMTPConnect(char * Host, int Port, BOOL AMPR, struct MsgInfo * Msg, char * MsgBody);
BOOL POP3Connect(char * Host, int Port);
VOID ProcessSMTPClientMessage(SocketConn * sockptr, char * Buffer, int Len);
VOID ProcessPOP3ClientMessage(SocketConn * sockptr, char * Buffer, int Len);
int CreatePOP3Message(char * From, char * To, char * MsgTitle, time_t Date, char * MsgBody, int MsgLen, BOOL B2Flag);
void WriteLogLine(CIRCUIT * conn, int Flag, char * Msg, int MsgLen, int Flags);
int SendSock(SocketConn * sockptr, char * msg);
VOID __cdecl sockprintf(SocketConn * sockptr, const char * format, ...);
VOID SendFromQueue(SocketConn * sockptr);
VOID SendMultiPartMessage(SocketConn * sockptr, struct MsgInfo * Msg, UCHAR * msgbytes);
int CountMessagesTo(struct UserInfo * user, int * Unread);
BOOL SendtoISP();
// NNTP ROutines
VOID InitialiseNNTP();
VOID BuildNNTPList(struct MsgInfo * Msg);
int NNTP_Data(int sock, int error, int eventcode);
int NNTP_Accept(SOCKET SocketId);
VOID * GetOverrides(config_setting_t * group, char * ValueName);
VOID * RegGetOverrides(HKEY hKey, char * ValueName);
VOID DoHouseKeeping(BOOL Mainual);
VOID ExpireMessages();
VOID KillMsg(struct MsgInfo * Msg);
BOOL RemoveKilledMessages();
VOID Renumber_Messages();
BOOL ExpireBIDs();
VOID MailHousekeepingResults();
VOID CreateBBSTrafficReport();
VOID CreateWPReport();
// WP Routines
VOID ProcessWPMsg(char * MailBuffer, int Size, char * FisrtRLine);
VOID GetWPInfoFromRLine(char * From, char * FirstRLine, time_t RLineTime);
VOID UpdateWPWithUserInfo(struct UserInfo * user);
VOID GetWPBBSInfo(char * Rline);
// UI Routines
VOID SetupUIInterface();
VOID Free_UI();
VOID SendLatestUI(int Port);
VOID SendMsgUI(struct MsgInfo * Msg);
static VOID Send_AX_Datagram(UCHAR * Msg, DWORD Len, UCHAR Port, UCHAR * HWADDR, BOOL Queue);
VOID SeeifBBSUIFrame(struct _MESSAGEX * buff, int len);
struct MsgInfo * FindMessageByNumber(int msgno);
int CountConnectionsOnPort(int CheckPort);
// Message Routing Routtines
VOID SetupHAElements(struct BBSForwardingInfo * ForwardingInfo);
VOID SetupHAddreses(struct BBSForwardingInfo * ForwardingInfo);
VOID SetupHAddresesP(struct BBSForwardingInfo * ForwardingInfo);
VOID SetupMyHA();
VOID SetupFwdAliases();
struct Continent * FindContinent(char * Name);
int MatchMessagetoBBSList(struct MsgInfo * Msg, CIRCUIT * conn);
BOOL CheckABBS(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS, char * HRoute);
BOOL CheckBBSToList(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSForwardingInfo * ForwardingInfo);
BOOL CheckBBSAtList(struct MsgInfo * Msg, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS);
BOOL CheckBBSHList(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS, char * HRoute);
BOOL CheckBBSHElements(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS, char ** HElements);
BOOL CheckBBSHElementsFlood(struct MsgInfo * Msg, struct UserInfo * bbs, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS, char ** HElements);
int CheckBBSToForNTS(struct MsgInfo * Msg, struct BBSForwardingInfo * ForwardingInfo);
int CheckBBSATListWildCarded(struct MsgInfo * Msg, struct BBSForwardingInfo * ForwardingInfo, char * ATBBS);
void SaveRestartData();
VOID ReRouteMessages();
VOID initUTF8();
int Is8Bit(unsigned char *cpt, int len);
int IsUTF8(unsigned char *ptr, int len);
int IsUTF8(unsigned char *ptr, int len);
int WebIsUTF8(unsigned char *ptr, int len);
int Convert437toUTF8(unsigned char * MsgPtr, int len, unsigned char * UTF);
int Convert1251toUTF8(unsigned char * MsgPtr, int len, unsigned char * UTF);
int Convert1252toUTF8(unsigned char * MsgPtr, int len, unsigned char * UTF);
int TrytoGuessCode(unsigned char * Char, int Len);
VOID FreeWebMailMallocs();
extern int _MYTIMEZONE;
extern HKEY REGTREE;
extern char * REGTREETEXT;
extern HBRUSH bgBrush;
extern BOOL cfgMinToTray;
extern CIRCUIT * Console;
extern ULONG ChatApplMask;
extern char Verstring[];
extern char SignoffMsg[];
extern char AbortedMsg[];
extern char InfoBoxText[]; // Text to display in Config Info Popup
extern int LastVer[4]; // In case we need to do somthing the first time a version is run
extern HWND MainWnd;
extern char BaseDir[];
extern char BaseDirRaw[];
extern char MailDir[];
extern char WPDatabasePath[];
extern char RlineVer[50];
extern BOOL LogBBS;
extern BOOL LogCHAT;
extern BOOL LogTCP;
extern BOOL ForwardToMe;
extern BOOL OnlyKnown;
extern BOOL AllowAnon;
extern BOOL UserCantKillT;
extern BOOL DontNeedHomeBBS;
extern int LatestMsg;
extern char BBSName[];
extern char SYSOPCall[];
extern char BBSSID[];
extern char NewUserPrompt[];
extern char * WelcomeMsg;
extern char * NewWelcomeMsg;
extern char * ChatWelcomeMsg;
extern char * NewChatWelcomeMsg;
extern char * ExpertWelcomeMsg;
extern char * Prompt;
extern char * NewPrompt;
extern char * ExpertPrompt;
// Filter Params
extern char ** RejFrom; // Reject on FROM Call
extern char ** RejTo; // Reject on TO Call
extern char ** RejAt; // Reject on AT Call
extern char ** RejBID;
extern char ** HoldFrom; // Hold on FROM Call
extern char ** HoldTo; // Hold on TO Call
extern char ** HoldAt; // Hold on AT Call
extern char ** HoldBID;
// Send WP Params
extern BOOL SendWP;
extern char SendWPVIA[81];
extern char SendWPTO[11];
extern int SendWPType;
extern int Ver[4];
extern struct MsgInfo ** MsgHddrPtr;
extern BIDRec ** BIDRecPtr;
extern int NumberofBIDs;
extern struct NNTPRec * FirstNNTPRec;
//extern int NumberofNNTPRecs;
extern int NumberofMessages;
extern int FirstMessageIndextoForward;
extern WPRec ** WPRecPtr;
extern int NumberofWPrecs;
extern struct SEM AllocSemaphore;
extern struct SEM ConSemaphore;
extern struct SEM MsgNoSemaphore;
extern struct MsgInfo * MsgnotoMsg[]; // Message Number to Message Slot List.
extern char hostname[];
extern char RtUsr[];
extern char RtUsrTemp[];
extern char RtKnown[];
extern int AXIPPort;
extern BOOL NeedStatus;
extern BOOL ISP_Gateway_Enabled;
extern BOOL SMTPAuthNeeded;
extern int MaxMsgno;
extern int BidLifetime;
extern int MaxAge;
extern int MaintInterval;
extern int MaintTime;
extern int UserLifetime;
extern int MaxRXSize;
extern int MaxTXSize;
extern char OurNode[];
extern char OurAlias[];
extern BOOL SMTPMsgCreated;
extern HINSTANCE hInst;
extern HWND hWnd;
extern RECT MainRect;
extern char BBSName[];
extern char HRoute[];
extern char AMPRDomain[];
extern BOOL SendAMPRDirect;
extern int BBSApplNum;
extern int SMTPInPort;
extern int POP3InPort;
extern int NNTPInPort;
extern BOOL RemoteEmail;
extern int MaxStreams;
extern UCHAR * OtherNodes;
extern struct UserInfo * BBSChain; // Chain of users that are BBSes
extern struct UserInfo ** UserRecPtr;
extern int NumberofUsers;
extern struct MsgInfo ** MsgHddrPtr;
extern int NumberofMessages;
extern int HighestBBSNumber;
extern HMENU hFWDMenu; // Forward Menu Handle
extern char zeros[]; // For forward bitmask tests
extern BOOL EnableUI;
extern BOOL RefuseBulls;
extern BOOL SendSYStoSYSOPCall;
extern BOOL SendBBStoSYSOPCall;
extern BOOL DontHoldNewUsers;
extern BOOL DefaultNoWINLINK;
extern BOOL UIEnabled[];
extern BOOL UINull[];
extern BOOL UIMF[];
extern BOOL UIHDDR[];
extern char * UIDigi[];
extern int MailForInterval;
extern char MailForText[];
extern BOOL ISP_Gateway_Enabled;
extern char MyDomain[]; // Mail domain for BBS<>Internet Mapping
extern char ISPSMTPName[];
extern char ISPEHLOName[];
extern int ISPSMTPPort;
extern char ISPPOP3Name[];
extern int ISPPOP3Port;
extern int ISPPOP3Interval;
extern char ISPAccountName[];
extern char ISPAccountPass[];
extern char EncryptedISPAccountPass[];
extern int EncryptedPassLen;
extern char *month[];
extern HWND hDebug;
extern RECT MonitorRect;
extern RECT DebugRect;
extern HWND hMonitor;
//extern HWND hConsole;
//extern RECT ConsoleRect;
extern int BBSLogAge;
extern BOOL DeletetoRecycleBin;
extern BOOL SuppressMaintEmail;
extern BOOL SaveRegDuringMaint;
extern BOOL SendWP;
extern BOOL OverrideUnsent;
extern BOOL SendNonDeliveryMsgs;
extern BOOL GenerateTrafficReport;
extern double PR;
extern double PUR;
extern double PF;
extern double PNF;
extern int BF;
extern int BNF;
extern int NTSD;
extern int NTSU;
extern int NTSF;
extern int AP;
extern int AB;
extern struct Override ** LTFROM;
extern struct Override ** LTTO;
extern struct Override ** LTAT;
extern time_t LastHouseKeepingTime;
extern time_t LastTrafficTime;
extern char * MyElements[];
extern char ** AliasText;
extern struct ALIAS ** Aliases;
extern BOOL ReaddressLocal;
extern BOOL ReaddressReceived;
extern BOOL WarnNoRoute;
extern BOOL SendPtoMultiple;
extern BOOL Localtime;
extern struct ConsoleInfo * ConsHeader[2];
extern BOOL NeedHomeBBS;
extern char ConfigName[250];
extern BOOL UsingingRegConfig;
extern BOOL MulticastRX;
extern BOOL FilterWPBulls;
extern BOOL NoWPGuesses;
extern char ** SendWPAddrs; // Replacers WP To and VIA
extern BOOL DontCheckFromCall;
extern time_t APIClock;;
// YAPP stuff
#define SOH 1
#define STX 2
#define ETX 3
#define EOT 4
#define ENQ 5
#define ACK 6
#define DLE 0x10
#define NAK 0x15
#define CAN 0x18
|