forked from g8bpq/OldLinBPQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BPQMail.h
1444 lines (1174 loc) · 45.3 KB
/
BPQMail.h
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
#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 _USE_32BIT_TIME_T
#define LIBCONFIG_STATIC
#include "libconfig.h"
#include "compatbits.h"
#ifndef LINBPQ
#include "bpq32.h"
#include "BPQMailrc.h"
#else
#include "CHeaders.h"
#endif
#include "asmstrucs.h"
#define NEWROUTING
// Standard __except handler for try/except
VOID CheckProgramErrors();
extern int ProgramErrors;
extern struct _EXCEPTION_POINTERS exinfox;
#ifdef WIN32
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();\
}
/*
#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(int 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 rtcflags; // p_linked or p_user.
int s; // Socket.
// char buf[ln_ibuf]; // Line of incoming text.
int Number; // Number of record - for Connections display
// SOCKET socket;
// SOCKADDR_IN sin;
BOOL Active;
int BPQStream;
int paclen;
UCHAR Callsign[11]; // Station call including SSID
BOOL GotHeader;
UCHAR InputMode; // Line by Line or Binary
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.
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
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
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
} 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
// 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
struct FBBRestartData
{
struct MsgInfo * TempMsg; // Header while message is being received
struct UserInfo * UserPointer;
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
};
// 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
};
#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;
int LLCount; // Number still to send in List Last N
};
#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*/
time_t 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.
char Call[10]; // Connected call without SSID
int Length; // To make subsequent format changes easier
int lastmsg; /* 4 Last L number */
time_t TimeLastConnected; //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)
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
char Filler[48]; // So we can add a few fields wirhout another resize
};
// flags equates
#define F_Excluded 0x0001
#define F_LOC 0x0002
#define F_Expert 0x0004
#define F_SYSOP 0x0008
#define F_BBS 0x0010
#define F_PAG 0x0020
#define F_GST 0x0040
#define F_MOD 0x0080
#define F_PRV 0x0100
#define F_UNP 0x0200
#define F_NEW 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 0x10000
#define F_NOWINLINK 0x20000 // Don't add Winlink.org
#define F_NOBULLS 0x40000
#define F_NTSMPS 0x80000
/* #define F_PWD 0x1000 */
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;
#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 FromRMS 8
#define FromRMSExpress 16
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 ;
time_t datereceived;
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;
#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 FromRMS 8
#define FromRMSExpress 16
time_t datecreated ;
time_t datechanged ;
char fbbs[NBMASK] ;
char forw[NBMASK] ;
char emailfrom[41];
char Locked; // Set if selected for sending (NTS Pickup)
char Defered; // FBB response '=' received
char Spare[62]; // 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;
/* Structures fichiers WP */
typedef struct WPREC { /* 108 bytes */
long last;
short local;
char source;
char callsign[7];
char homebbs[41];
char zip[9];
char name[13];
char qth[31];
} WPMsgRec, * WPMsgRecP;
typedef struct WPDBASE{ /* 194 bytes */
char callsign[7];
char name[13];
unsigned char Type;
unsigned char changed;
unsigned short seen;
long last_modif;
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 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
// 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
char RTFHeader[4000];
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
};
VOID __cdecl nprintf(CIRCUIT * conn, const char * format, ...);
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(int 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
} SocketConn;
#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, BOOL SendFullFrom);
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);
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);
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);