From 4b7a47b62b4411e59a8c1ade62b2017c4e7cc93c Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Wed, 23 Sep 2026 16:04:04 +0100 Subject: [PATCH] 6.0.25.41 --- .gitignore | 2 + BPQChat.rc | 2 +- BPQChat.vcxproj | 168 ++ BPQMail.c | 1 + BPQMail.rc | 2 +- BPQMail.vcxproj | 208 ++ BPQNRR.c | 1 + BPQTermTCP.h | 90 + BPQTermTCP.ini | 20 + BPQTermTCP.rc | 336 ++++ BPQTermTCP.vcproj | 192 ++ BPQTermTCP.vcxproj | 107 ++ BPQTerminal.c | 2413 ++++++++++++++++++++++++ BPQTerminal.h | 77 + BPQTerminal.rc | 164 ++ BPQTerminal.vcproj | 279 +++ BPQTerminal.vcxproj | 154 ++ BPQWinAPP.c | 111 +- BPQWinAPP.vcproj | 22 +- BPQWinAPP.vcxproj | 156 ++ BUILDING.md | 86 + Bpq32.c | 34 +- CBPQ32.sln | 29 + CBPQ32.vcproj | 2 +- CBPQ32.vcxproj | 84 +- CBPQ322026.sln | 84 + CMakeLists.txt | 24 + Cmd.c | 40 + CommonCode.c | 52 +- DragSize.cur | Bin 0 -> 326 bytes HTTPcode.c | 175 +- L4Code.c | 292 ++- LinBPQ.c | 76 +- MULTIPSK.c | 2 +- MailNode.vcproj | 4 +- MailNode.vcxproj | 221 +++ Moncode.c | 4 +- RTKnown.txt | 0 RigControl.c | 71 +- TelnetV6.c | 5 + UZ7HODrv.c | 2 +- Versions.h | 4 +- WebMail.c | 4 +- Win32bits/bpq32.dll | Bin 2957312 -> 0 bytes Win32bits/bpq32.exp | Bin 18558 -> 18680 bytes Win32bits/bpq32.lib | Bin 30672 -> 30870 bytes WinmorControl.rc | 2 +- WinmorControl.vcxproj | 150 ++ bpqether.c | 2 +- bpqtermTCP.c | 4170 +++++++++++++++++++++++++++++++++++++++++ cMain.c | 2 + chatconfig.cfg | 2 +- debug/bpq32.pdb | Bin 0 -> 1592320 bytes makefile | 2 +- tncinfo.h | 1 + 55 files changed, 9915 insertions(+), 216 deletions(-) create mode 100644 BPQChat.vcxproj create mode 100644 BPQMail.vcxproj create mode 100644 BPQTermTCP.h create mode 100644 BPQTermTCP.ini create mode 100644 BPQTermTCP.rc create mode 100644 BPQTermTCP.vcproj create mode 100644 BPQTermTCP.vcxproj create mode 100644 BPQTerminal.c create mode 100644 BPQTerminal.h create mode 100644 BPQTerminal.rc create mode 100644 BPQTerminal.vcproj create mode 100644 BPQTerminal.vcxproj create mode 100644 BPQWinAPP.vcxproj create mode 100644 BUILDING.md create mode 100644 CBPQ322026.sln create mode 100644 CMakeLists.txt create mode 100644 DragSize.cur create mode 100644 MailNode.vcxproj create mode 100644 RTKnown.txt delete mode 100644 Win32bits/bpq32.dll create mode 100644 WinmorControl.vcxproj create mode 100644 bpqtermTCP.c create mode 100644 debug/bpq32.pdb diff --git a/.gitignore b/.gitignore index 14065f4..06196a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.ncb *.suo +*.bsc *.user .svn/* +.vs/* \ No newline at end of file diff --git a/BPQChat.rc b/BPQChat.rc index dc873e2..e3b82f8 100644 --- a/BPQChat.rc +++ b/BPQChat.rc @@ -12,7 +12,7 @@ #undef APSTUDIO_HIDDEN_SYMBOLS #define CHAT #define IDC_STATIC -1 -#include "..\CommonSource\Versions.h" +#include "Versions.h" ///////////////////////////////////////////////////////////////////////////// diff --git a/BPQChat.vcxproj b/BPQChat.vcxproj new file mode 100644 index 0000000..c776b12 --- /dev/null +++ b/BPQChat.vcxproj @@ -0,0 +1,168 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + 18.0 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1} + BPQChat + Win32Proj + + + + Application + v145 + NotSet + true + + + Application + v145 + NotSet + + + + + + + + + + + + + <_ProjectFileVersion>18.0.12106.202 + + + C:\Dev\Msdev2005\$(SolutionName)\$(ProjectName)\$(Configuration)\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + true + + + C:\Dev\Msdev2005\$(SolutionName)\$(ProjectName)\$(Configuration)\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + false + + + + + + + Disabled + Win32bits;..\BPQSource;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + true + + Level3 + EditAndContinue + CompileAsC + + + Win32bits\bpq32.lib;wsock32.lib;comctl32.lib;winmm.lib;Win32bits\libconfig.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQChat.exe + true + $(IntDir)$(TargetName).pdb + true + $(IntDir)BBSListings\BPQChat.map + true + Windows + MachineX86 + + + + + + + + + + + MaxSpeed + false + Win32bits;..\BPQSource;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + MultiThreaded + + All + $(IntDir)BBSListings\ + Level3 + + CompileAsC + + + Win32bits\bpq32.lib;wsock32.lib;comctl32.lib;Win32bits\libconfig.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQChat.exe + false + $(IntDir)$(TargetName).pdb + true + $(IntDir)BBSListings\BPQChat.map + Windows + true + true + + MachineX86 + + + + + $(IntDir) + + + $(IntDir) + + + $(IntDir) + + + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir)%(Filename)1.xdc + + + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir)%(Filename)1.xdc + + + $(IntDir) + + + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + + + $(IntDir) + + + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + $(IntDir) + + + + + + + + + \ No newline at end of file diff --git a/BPQMail.c b/BPQMail.c index 62c2ff9..5300836 100644 --- a/BPQMail.c +++ b/BPQMail.c @@ -1168,6 +1168,7 @@ // Allow lower case SMTP/POP3 commands (39) // Fix Webmail Send Reply with SMTP server messages (39) // Fix paging in PG server (39) +// Fix crash in Webmail display message if message doesn't exist or isn't for you (41) #include "bpqmail.h" diff --git a/BPQMail.rc b/BPQMail.rc index 88d1116..26e48ab 100644 --- a/BPQMail.rc +++ b/BPQMail.rc @@ -16,7 +16,7 @@ #include "AFXRES.h" #undef APSTUDIO_HIDDEN_SYMBOLS #define MAILCHAT -#include "..\CommonSource\Versions.h" +#include "Versions.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS diff --git a/BPQMail.vcxproj b/BPQMail.vcxproj new file mode 100644 index 0000000..c3f3a7d --- /dev/null +++ b/BPQMail.vcxproj @@ -0,0 +1,208 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + 18.0 + {3766AA10-C777-4ED8-A83D-F1452DE9B665} + TelnetServer + Win32Proj + + + + Application + v145 + NotSet + true + + + Application + v145 + false + NotSet + + + + + + + + + + + + + <_ProjectFileVersion>18.0.12106.202 + + + C:\Dev\Msdev2005\$(SolutionName)\$(ProjectName)\$(Configuration)\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + true + + + C:\Dev\Msdev2005\$(SolutionName)\$(ProjectName)\$(Configuration)\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + false + + + + + + + Disabled + ..\BPQSource\Win32bits;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USE_32BIT_TIME_T;NOMQTT;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + true + + Level3 + EditAndContinue + CompileAsC + + + ..\Include;%(AdditionalIncludeDirectories) + + + Win32bits\bpq32.lib;wsock32.lib;comctl32.lib;winmm.lib;Win32bits\libconfig.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQMail.exe + false + LIBCMT;%(IgnoreSpecificDefaultLibraries) + true + $(IntDir)$(TargetName).pdb + true + $(IntDir)BBSListings\bpqmail.map + true + Windows + MachineX86 + + + + + + + + + + + MaxSpeed + false + Win32bits;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USE_32BIT_TIME_T;NOMQTT;%(PreprocessorDefinitions) + MultiThreaded + + Level3 + ProgramDatabase + CompileAsC + + + ..\Include;%(AdditionalIncludeDirectories) + + + Win32bits\bpq32.lib;wsock32.lib;comctl32.lib;winmm.lib;Win32bits\libconfig.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQMail.exe + true + c:\DevProgs\bpq32\BPQMail.pdb + true + c:\DevProgs\bpq32\BPQMail.map + Windows + true + true + + MachineX86 + + + + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + All + $(IntDir) + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + All + $(IntDir) + $(IntDir) + $(IntDir)%(Filename)1.xdc + + + + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + + + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + + + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + $(IntDir)%(Filename)1.obj + $(IntDir)%(Filename)1.xdc + + + + + + + + + + + + + \ No newline at end of file diff --git a/BPQNRR.c b/BPQNRR.c index 97e2b45..2bcab5c 100644 --- a/BPQNRR.c +++ b/BPQNRR.c @@ -214,3 +214,4 @@ VOID SendNRRecordRoute(struct DEST_LIST * DEST, TRANSPORTENTRY * Session) C_Q_ADD(&DEST->DEST_Q, Msg); } + diff --git a/BPQTermTCP.h b/BPQTermTCP.h new file mode 100644 index 0000000..d230864 --- /dev/null +++ b/BPQTermTCP.h @@ -0,0 +1,90 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by BPQTermTCP.rc +// +#define IDR_MENU1 101 +#define BPQMENU 101 +#define BPQDISCONNECT 103 +#define IDD_CONFIG 104 +#define IDD_FONT 105 +#define IDD_ALERTDLG 106 +#define IDD_LISTEN 107 + +#define MONITOR_ADDPORT 400 +#define IDC_HOST 1004 +#define IDC_PORT 1005 +#define IDC_USER 1006 +#define IDC_PASS 1007 +#define IDC_FONTWIDTH 1008 +#define IDC_FONTNAME 1009 +#define IDC_CODEPAGE 1010 +#define IDC_CHARSET 1011 +#define IDC_FONTSIZE 1012 +#define IDC_AUTO 1013 +#define IDC_1251 1014 +#define IDC_1252 1015 +#define IDC_437 1016 +#define IDC_UTF8 1017 +#define IDC_Send1251 1018 +#define IDC_Send1252 1019 +#define IDC_ALERTINTERVAL 1020 +#define IDC_RADIO1 1021 +#define IDC_RADIO2 1022 +#define IDC_ALERTFILENAME 1023 +#define IDC_PLAYFILENAME 1023 +#define IDC_FREQ 1024 +#define IDC_DURATION 1025 +#define IDC_USEKEYWORDS 1026 +#define IDC_ALERTKEYNAME 1027 +#define IDC_LISTENPORT 1028 + +#define BPQMTX 1164 +#define BPQMCOM 1165 +#define BPQCOPYMON 1166 +#define BPQCOPYOUT 1167 +#define BPQCLEARMON 1168 +#define BPQCLEAROUT 1169 +#define BPQBELLS 1170 +#define BPQCHAT 1171 +#define BPQHELP 1172 +#define BPQStripLF 1173 +#define BPQLogOutput 1174 +#define BPQLogMonitor 1175 +#define BPQSendDisconnected 1176 +#define BPQMNODES 1177 +#define MONCOLOUR 1178 +#define CHATTERM 1179 +#define MUIONLY 1180 +#define BPQPORT 1181 +#define BPQENABLE 1182 +#define YAPPSEND 1200 +#define YAPPDIR 1201 +#define BPQAUTOCONNECT 40001 +#define BPQAPPL1 40002 +#define BPQAPPL2 40003 +#define BPQAPPL3 40004 +#define BPQAPPL4 40005 +#define BPQAPPL6 40006 +#define BPQAPPL7 40007 +#define BPQAPPL8 40008 +#define BPQAPPL5 40009 +#define BPQFLAGS1 40010 +#define BPQFLAGS2 40011 +#define BPQFLAGS3 40012 +#define BPQFLAGS4 40013 +#define ID_SETUP_FONT 40025 +#define ID_SETUP_ALERTSETUP 40026 +#define BPQCONNECT1 40101 +#define IDC_HOST1 40201 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40027 +#define _APS_NEXT_CONTROL_VALUE 1027 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif diff --git a/BPQTermTCP.ini b/BPQTermTCP.ini new file mode 100644 index 0000000..3fe4d61 --- /dev/null +++ b/BPQTermTCP.ini @@ -0,0 +1,20 @@ +[Session 1] +PortMask=0 +Bells=0 +StripLF=0 +MTX=1 +MCOM=1 +MUIONLY=0 +Split=50 +MONColour=0 +MonNODES=1 +MonPorts=0 +ChatMode=0 +CurrentHost=0 +Size=34,650,47,669 +FontName=Courier New +CharSet=0 +CodePage=437 +FontSize=20 +FontWidth=8 +AlertInterval=3600 diff --git a/BPQTermTCP.rc b/BPQTermTCP.rc new file mode 100644 index 0000000..c44d16a --- /dev/null +++ b/BPQTermTCP.rc @@ -0,0 +1,336 @@ +//Microsoft Developer Studio generated resource script. +// +#define TermTCP +#include "bpqtermTCP.h" + + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "afxres.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "winver.h" +#define BPQBASE 1100 + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ALERTDLG DIALOG DISCARDABLE 0, 0, 250, 121 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Alert Settings" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,62,100,50,14 + PUSHBUTTON "Cancel",IDCANCEL,137,100,50,14 + LTEXT "Alert After Interval",IDC_STATIC,7,9,65,9, + SS_CENTERIMAGE + EDITTEXT IDC_ALERTINTERVAL,83,8,29,13,ES_AUTOHSCROLL + CONTROL "Beep",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,7,27,33,15 + CONTROL "Play File",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,7,50, + 52,14 + EDITTEXT IDC_ALERTFILENAME,83,49,151,15,ES_AUTOHSCROLL + LTEXT "Freq",IDC_STATIC,47,30,15,8 + LTEXT "Duration",IDC_STATIC,120,30,28,8 + EDITTEXT IDC_FREQ,83,28,29,13,ES_AUTOHSCROLL + EDITTEXT IDC_DURATION,154,28,29,13,ES_AUTOHSCROLL + CONTROL "Use Keyword File",IDC_USEKEYWORDS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,73,71,10 + EDITTEXT IDC_ALERTKEYNAME,83,72,151,15,ES_AUTOHSCROLL +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ALERTDLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 243 + TOPMARGIN, 7 + BOTTOMMARGIN, 114 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.K.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +BPQMAINWINDOW DIALOG DISCARDABLE 17, 25, 300, 300 +STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "BPQTerminal Version 1.0.0" +MENU MENU_1 +CLASS "BPQMAINWINDOW" +FONT 8, "FixedSys" +BEGIN + LISTBOX 116,5,6,290,134,LBS_MULTIPLESEL | LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_HSCROLL + EDITTEXT 118,5,280,440,15,ES_AUTOHSCROLL | ES_NOHIDESEL + CTEXT "",119,0,145,300,5,SS_NOTIFY +END + +IDD_CONFIG DIALOG DISCARDABLE 0, 0, 181, 129 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "TCP Host Config" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Host",IDC_STATIC,7,15,24,9 + EDITTEXT IDC_HOST,46,13,114,12,ES_AUTOHSCROLL + LTEXT "Port",IDC_STATIC,7,32,24,9 + EDITTEXT IDC_PORT,46,30,53,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "User",IDC_STATIC,7,49,24,9 + EDITTEXT IDC_USER,46,47,89,12,ES_AUTOHSCROLL + LTEXT "Password",IDC_STATIC,7,66,39,9 + EDITTEXT IDC_PASS,46,64,90,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "Save",IDOK,33,91,50,14 + PUSHBUTTON "Cancel",IDCANCEL,95,91,50,14 +END + +IDD_LISTEN DIALOG DISCARDABLE 0, 0, 181, 129 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "TCP Listen Config" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Port",IDC_STATIC,7,32,24,9 + EDITTEXT IDC_LISTENPORT,46,30,53,12,ES_AUTOHSCROLL | ES_NUMBER + DEFPUSHBUTTON "Save",IDOK,33,91,50,14 + PUSHBUTTON "Cancel",IDCANCEL,95,91,50,14 +END + + +IDD_FONT DIALOG DISCARDABLE 0, 0, 187, 206 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Font Setup" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Save",IDOK,39,182,50,14 + PUSHBUTTON "Cancel",IDCANCEL,92,182,50,14 + LTEXT "Font Width",IDC_STATIC,7,166,41,9 + EDITTEXT IDC_FONTWIDTH,53,164,39,12,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_FONTSIZE,53,149,38,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Font Size",IDC_STATIC,7,151,44,9 + LTEXT "Interpret non-UTF8 input as",IDC_STATIC,7,10,96,11 + CONTROL "Auto",IDC_AUTO,"Button",BS_AUTORADIOBUTTON,15,25,31,10 + CONTROL "CP1251 (Cyrillic)",IDC_1251,"Button",BS_AUTORADIOBUTTON, + 15,40,67,10 + CONTROL "CP1252 (Western Europe)",IDC_1252,"Button", + BS_AUTORADIOBUTTON,15,55,99,10 + CONTROL "CP437 (Windows Line Draw)",IDC_437,"Button", + BS_AUTORADIOBUTTON,15,70,107,10 + LTEXT "Send as",IDC_STATIC,7,85,27,8 + CONTROL "UTF8",IDC_UTF8,"Button",BS_AUTORADIOBUTTON | WS_GROUP, + 15,100,34,10 + CONTROL "CP1251",IDC_Send1251,"Button",BS_AUTORADIOBUTTON,15,115, + 41,10 + CONTROL "CP1252",IDC_Send1252,"Button",BS_AUTORADIOBUTTON,15,130, + 41,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_CONFIG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 174 + TOPMARGIN, 6 + BOTTOMMARGIN, 122 + END + + IDD_FONT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 180 + TOPMARGIN, 7 + BOTTOMMARGIN, 199 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "bpqtermTCP.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""..\\cinclude\\afxres.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""winver.h""\r\n" + "#define BPQBASE 1100\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""..\\CommonSource\\Versions.h""\r\n" + "#include ""..\\StdVer.inc""\r\n" + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Cursor +// + +IDC_DRAGSIZE CURSOR DISCARDABLE "DragSize.cur" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +MENU_1 MENU DISCARDABLE +BEGIN + POPUP "Connect" + BEGIN + MENUITEM "Host 1", BPQCONNECT1 + MENUITEM "Host 2", 40102 + MENUITEM "Host 3", 40103 + MENUITEM "Host 4", 40104 + MENUITEM "Host 5", 40105 + MENUITEM "Host 6", 40106 + MENUITEM "Host 7", 40107 + MENUITEM "Host 8", 40108 + MENUITEM "Host 9", 40109 + MENUITEM "Host 10", 40110 + MENUITEM "Host 11", 40111 + MENUITEM "Host 12", 40112 + MENUITEM "Host 13", 40113 + MENUITEM "Host 14", 40114 + MENUITEM "Host 15", 40115 + MENUITEM "Host 16", 40116 + END + MENUITEM "Disconnect", BPQDISCONNECT + + POPUP "Listen" + BEGIN + MENUITEM "Enable", BPQENABLE + MENUITEM "Port", BPQPORT + END + + POPUP "Setup" + BEGIN + POPUP "TCP Hosts" + BEGIN + MENUITEM "Host 1", IDC_HOST1 + MENUITEM "Host 2", 40202 + MENUITEM "Host 3", 40203 + MENUITEM "Host 4", 40204 + MENUITEM "Host 5", 40205 + MENUITEM "Host 6", 40206 + MENUITEM "Host 7", 40207 + MENUITEM "Host 8", 40208 + MENUITEM "Host 9", 40209 + MENUITEM "Host 10", 40210 + MENUITEM "Host 11", 40211 + MENUITEM "Host 12", 40212 + MENUITEM "Host 13", 40213 + MENUITEM "Host 14", 40214 + MENUITEM "Host 15", 40215 + MENUITEM "Host 16", 40216 + END + MENUITEM "Font Setup", ID_SETUP_FONT + MENUITEM "Enable Bells", BPQBELLS + MENUITEM "Strip Linefeeds", BPQStripLF + MENUITEM "Log Monitor", BPQLogMonitor + MENUITEM "Log Output", BPQLogOutput + MENUITEM "Chat Terminal Mode", CHATTERM + MENUITEM "Alert Setup", ID_SETUP_ALERTSETUP + END + POPUP "Monitor" + BEGIN + MENUITEM "Monitor TX", BPQMTX + MENUITEM "Monitor Supervisory", BPQMCOM + MENUITEM "Only monitor UI frames", MUIONLY + MENUITEM "Monitor NODES", BPQMNODES + MENUITEM "Enable Colour", MONCOLOUR + MENUITEM "Add Port", MONITOR_ADDPORT + END + POPUP "Edit" + BEGIN + MENUITEM "Copy Monitor Window", BPQCOPYMON + MENUITEM "Copy Output Window", BPQCOPYOUT + MENUITEM "Clear Monitor Window", BPQCLEARMON + MENUITEM "Clear Output Window", BPQCLEAROUT + END + POPUP "YAPP" + BEGIN + MENUITEM "Send File", YAPPSEND + MENUITEM "Set Receive Directory", YAPPDIR + END +END + +#endif // English (U.K.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#include "Versions.h" +#include "StdVer.inc" + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/BPQTermTCP.vcproj b/BPQTermTCP.vcproj new file mode 100644 index 0000000..2f8eed3 --- /dev/null +++ b/BPQTermTCP.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPQTermTCP.vcxproj b/BPQTermTCP.vcxproj new file mode 100644 index 0000000..a0fbe10 --- /dev/null +++ b/BPQTermTCP.vcxproj @@ -0,0 +1,107 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + 18.0 + {99625C77-CABA-469A-A5A7-ECB4EE354225} + BPQTermTCP + Win32Proj + 10.0 + + + + Application + v145 + Unicode + + + Application + v145 + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>18.0.12106.202 + + + c:\DevProgs\bpq32\ + C:\Dev\Msdev2005\Intermed\BPQTermTCP\Debug\ + true + + + Release\ + C:\Dev\Msdev2005\Intermed\BPQTermTCP\Release\ + false + + + + Disabled + ./;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + true + + true + Level3 + EditAndContinue + + + ws2_32.lib;winmm.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQTermTCP.exe + true + Windows + MachineX86 + false + + + + + Full + ./;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + + true + Level3 + ProgramDatabase + + + ws2_32.lib;winmm.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQTermTCP.exe + true + Windows + true + true + MachineX86 + + + + + + + + + + + + \ No newline at end of file diff --git a/BPQTerminal.c b/BPQTerminal.c new file mode 100644 index 0000000..2b4b3a0 --- /dev/null +++ b/BPQTerminal.c @@ -0,0 +1,2413 @@ + +// Version 2.0.1 November 2007 + +// Change resizing algorithm + + +// Version 2.0.2 January 2008 + +// Restore Checked state of Bells and AutoConnect Flags +// Call CheckTimer on startup (for new Initialisation Scheme for perl) + +// Version 2.0.3 July 2008 + +// Display lines received without a terminaing CR + + +// Version 2.0.4 November 2008 + +// Add option to remove a Line Feed following a CR +// Add Logging Option + +// Version 2.0.5 January 2009 + +// Add Start Minimized Option + +// Version 2.0.6 June 2009 + +// Add Option to send *** Disconnnected on disconnect +// Add line wrap code +// Add option not to monitor NODES broadcasts + +// Version 2.0.7 October 2009 + +// Add input buffer scrollback. +// Fix monitoring when PORTNUM specified + +// Version 2.0.8 December 2009 + +// Fix use of numeric keypad 2 and 8 (were treated as up and down) + +// Version 2.0.9 March 2010 + +// Add colour for monitor and BPQ Chat + +// Version 2.0.0 October 2010 + +// Add Chat Terminal Mode (sends keepalives) + +// Version 2.1.0 August 2011 + +// Add Copy/Paste capability to output window. +// Add Font Selection +// Get Registry Tree from BPQ32.dll +// Add Command to reset Monitor/Output window split + +// Version 2.1.1 October 2011 + +// Wrap overlong lines + +// Version 2.1.2 Jan 2012 + +// Call CloseBPQ32 on exit +// Fix ClearOutputWindow +// Save MonitorNodes flag + +// Version 2.2.1 June 2012 + +// Add UIOnly Monitor Option + +// Version 2.2.2.1 Nov 2014 +// Fix possible crash on processing part line + + +// Version 2.2.3.1 Dec 2014 +// Remove "Enable Chat" option + +// Version 2.2.4.1 Dec 2015 +// Add Port Names to Monitor Config Menu + + +// Add Chat Terminal Mode + +// Version 2.2.5.1 Sep 2019 + +// Recompile for change to Port Struct + +// Version 2.2.5.2 May 2023 +// Changes for compatibility with 63 port BPQ32 + +#define _USE_32BIT_TIME_T +#define _CRT_SECURE_NO_DEPRECATE + +#define pthread_t DWORD +#include "asmstrucs.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bpqterminal.h" + +#define BPQBASE WM_USER +// +// Port monitoring flags use BPQBASE -> BPQBASE+100 + +#include "bpq32.h" // BPQ32 API Defines +#define BPQTerm +#include "Versions.h" +#include "GetVersion.h" + +#define BGCOLOUR RGB(236,233,216) + +HBRUSH bgBrush; + +UINT BPQMsg; + +HKEY FAR WINAPI GetRegistryKey(); +char * FAR WINAPI GetRegistryKeyText(); + +HKEY REGTREE = HKEY_LOCAL_MACHINE; // Default + +HINSTANCE hInst; +char AppName[] = "BPQTerm 32"; +char ClassName[] = "BPQMAINWINDOW"; +char Title[80]; + +// Foward declarations of functions included in this code module: + +ATOM MyRegisterClass(CONST WNDCLASS*); +BOOL InitApplication(HINSTANCE); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); +int NewLine(); + +int ProcessBuff(char * readbuff,int len); + +int EnableConnectMenu(HWND hWnd); +int EnableDisconnectMenu(HWND hWnd); +int DisableConnectMenu(HWND hWnd); +int DisableDisconnectMenu(HWND hWnd); +int ToggleAutoConnect(HWND hWnd); +int DoReceivedData(HWND hWnd); +int DoStateChange(HWND hWnd); +int CopyScreentoBuffer(char * buff); +int DoMonData(HWND hWnd); +int TogglePort(HWND hWnd, int Item, uint64_t mask); +int ToggleMTX(HWND hWnd); +int ToggleMCOM(HWND hWnd); +int ToggleMUI(HWND hWnd); +int ToggleParam(HWND hWnd, BOOL * Param, int Item); +int ToggleChat(HWND hWnd); +void MoveWindows(); +void CopyListToClipboard(HWND hWnd); +void CopyRichTextToClipboard(HWND hWnd); +BOOL OpenMonitorLogfile(); +void WriteMonitorLine(char * Msg, int MsgLen); +VOID WritetoOutputWindow(struct RTFTerm * OPData, char * Msg, int len); +VOID DoRefresh(struct RTFTerm * OPData); +INT_PTR CALLBACK FontConfigWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + +COLORREF Colours[256] = {0, + RGB(0,0,0), RGB(0,0,128), RGB(0,0,192), RGB(0,0,255), // 1 - 4 + RGB(0,64,0), RGB(0,64,128), RGB(0,64,192), RGB(0,64,255), // 5 - 8 + RGB(0,128,0), RGB(0,128,128), RGB(0,128,192), RGB(0,128,255), // 9 - 12 + RGB(0,192,0), RGB(0,192,128), RGB(0,192,192), RGB(0,192,255), // 13 - 16 + RGB(0,255,0), RGB(0,255,128), RGB(0,255,192), RGB(0,255,255), // 17 - 20 + + RGB(64,0,0), RGB(64,0,128), RGB(64,0,192), RGB(0,0,255), // 21 + RGB(64,64,0), RGB(64,64,128), RGB(64,64,192), RGB(64,64,255), + RGB(64,128,0), RGB(64,128,128), RGB(64,128,192), RGB(64,128,255), + RGB(64,192,0), RGB(64,192,128), RGB(64,192,192), RGB(64,192,255), + RGB(64,255,0), RGB(64,255,128), RGB(64,255,192), RGB(64,255,255), + + RGB(128,0,0), RGB(128,0,128), RGB(128,0,192), RGB(128,0,255), // 41 + RGB(128,64,0), RGB(128,64,128), RGB(128,64,192), RGB(128,64,255), + RGB(128,128,0), RGB(128,128,128), RGB(128,128,192), RGB(128,128,255), + RGB(128,192,0), RGB(128,192,128), RGB(128,192,192), RGB(128,192,255), + RGB(128,255,0), RGB(128,255,128), RGB(128,255,192), RGB(128,255,255), + + RGB(192,0,0), RGB(192,0,128), RGB(192,0,192), RGB(192,0,255), // 61 + RGB(192,64,0), RGB(192,64,128), RGB(192,64,192), RGB(192,64,255), + RGB(192,128,0), RGB(192,128,128), RGB(192,128,192), RGB(192,128,255), + RGB(192,192,0), RGB(192,192,128), RGB(192,192,192), RGB(192,192,255), + RGB(192,255,0), RGB(192,255,128), RGB(192,255,192), RGB(192,2552,255), + + RGB(255,0,0), RGB(255,0,128), RGB(255,0,192), RGB(255,0,255), // 81 + RGB(255,64,0), RGB(255,64,128), RGB(255,64,192), RGB(255,64,255), + RGB(255,128,0), RGB(255,128,128), RGB(255,128,192), RGB(255,128,255), + RGB(255,192,0), RGB(255,192,128), RGB(255,192,192), RGB(255,192,255), + RGB(255,255,0), RGB(255,255,128), RGB(255,255,192), RGB(255,2552,255) +}; + + + +LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ; +LRESULT APIENTRY MonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ; +LRESULT APIENTRY SplitProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ; + + +WNDPROC wpOrigInputProc; +WNDPROC wpOrigMonProc; +WNDPROC wpOrigSplitProc; + +HWND hwndInput; +HWND hwndOutput; +HWND hwndMon; +HWND hwndSplit; + +HMENU trayMenu; + +int xsize,ysize; // Screen size at startup + +double Split=0.5; +int SplitPos=300; +#define SplitBarHeight 5 +#define InputBoxHeight 25 +RECT Rect; +RECT MonRect; +RECT OutputRect; +RECT SplitRect; + +int OutputBoxHeight; + +int Height, Width, LastY; + +int maxlinelen = 80; +int CharWidth = 8; + +int ClientHeight, ClientWidth; + + +#define MAXLINES 1000 +#define LINELEN 200 + +char RTFHeader[4000]; + +int RTFHddrLen; + +typedef struct RTFTerm +{ + 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 CharWidth; + int CurrentColour; + int Thumb; + int FirstTime; + int RTFHeight; // Height of RTF control in pixels + BOOL Scrolled; // Window is scrolled back + +}; + +char FontName[100] = "FixedSys"; +int FontSize = 20; +int FontWidth = 8; +int CodePage = 437; +int CharSet = 0; + + +struct RTFTerm OutputData; + +int CurrentHost = 0; +int CfgNo = 0; + +SOCKET sock; + +BOOL MonData = FALSE; + +char Key[80]; +uint64_t portmask=0; +int mtxparam=1; +int mcomparam=1; +int monUI = 0; + +char kbbuf[160]; +int kbptr=0; +char readbuff[100000]; // for stupid bbs programs + +int ptr=0; + +int Stream; +int len,count; + +char callsign[10]; +int state; +int change; +int applmask = 0; +int applflags = 2; // Message to Application +int Sessno = 0; + +int PartLinePtr=0; +int PartLineIndex=0; // Listbox index of (last) incomplete line + +BOOL Bells = FALSE; +BOOL StripLF = FALSE; +BOOL LogMonitor = FALSE; +BOOL LogOutput = FALSE; +BOOL SendDisconnected = TRUE; +BOOL MonitorNODES = TRUE; +BOOL MonitorColour = TRUE; +BOOL ChatMode = FALSE; + +HANDLE MonHandle=INVALID_HANDLE_VALUE; + +HCURSOR DragCursor; +HCURSOR Cursor; + +CONNECTED=FALSE; +AUTOCONNECT=TRUE; + +LOGFONT LFTTYFONT ; + +HFONT hFont ; + +BOOL MinimizetoTray=FALSE; +//BOOL StartMinimized = FALSE; + +HWND MainWnd, hWnd; + +VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime ); + +TIMERPROC lpTimerFunc = (TIMERPROC) TimerProc; + +int TimerHandle = 0; + +int SlowTimer; + +BOOL WINE; + +VOID __cdecl Debugprintf(const char * format, ...) +{ + char Mess[1000]; + va_list(arglist);int Len; + + va_start(arglist, format); + Len = vsprintf_s(Mess, sizeof(Mess), format, arglist); + strcat(Mess, "\r\n"); + OutputDebugString(Mess); + return; +} + + +VOID CALLBACK TimerProc( + + HWND hwnd, // handle of window for timer messages + UINT uMsg, // WM_TIMER message + UINT idEvent, // timer identifier + DWORD dwTime) // current system time +{ + // entered every 10 secs + + CheckTimer(); + + if (!CONNECTED) + return; + + if (!ChatMode) + return; + + SlowTimer++; + + if (SlowTimer > 50) // About 9 mins + { + SlowTimer = 0; + SendMsg(Stream, "\0", 1); + } +} + +// +// FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int) +// +// PURPOSE: Entry point for the application. +// +// COMMENTS: +// +// This function initializes the application and processes the +// message loop. +// +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + MSG msg; + int retCode, disp; + HKEY hKey=0; + char Size[80]; + +/* PCHAR p1, p2, p3; + + p1 = strtok(lpCmdLine, " ,\t\n\r"); + p2 = strtok(NULL, " ,\t\n\r"); + p3 = strtok(NULL, " ,\t\n\r"); + + if (nCmdShow == SW_SHOWMINIMIZED) + StartMinimized = TRUE; + + if (p1) + { + if (strlen(p1) > 5) + { + if (_stricmp(p1, "StartMinimized") == 0) + StartMinimized = TRUE; + + if (p2) Sessno = atoi(p2); + if (p3) sscanf(p3,"%x", &applflags); + } + else + { + if (p2) + { + if (strlen(p2) > 5) + { + if (_stricmp(p2, "StartMinimized") == 0) + StartMinimized = TRUE; + + if (p1) Sessno = atoi(p1); + if (p3) sscanf(p3,"%x", &applflags); + } + } + else + { + if (p3) + { + if (strlen(p3) > 5) + { + if (_stricmp(p3, "StartMinimized") == 0) + StartMinimized = TRUE; + + if (p1) Sessno = atoi(p1); + if (p2) sscanf(p2,"%x", &applflags); + } + } + } + } + } +*/ + sscanf(lpCmdLine,"%d %x",&Sessno, &applflags); + + if (!InitApplication(hInstance)) + return (FALSE); + + if (!InitInstance(hInstance, nCmdShow)) + return (FALSE); + + // Main message loop: + while (GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + // Save Config + + retCode = RegCreateKeyEx(REGTREE, + Key, + 0, // Reserved + 0, // Class + 0, // Options + KEY_ALL_ACCESS, + NULL, // Security Attrs + &hKey, + &disp); + + if (retCode == ERROR_SUCCESS) + { + retCode = RegSetValueEx(hKey,"AutoConnect",0,REG_DWORD,(BYTE *)&AUTOCONNECT,4); + retCode = RegSetValueEx(hKey,"PortMask",0,REG_BINARY,(BYTE *)&portmask, 8); + retCode = RegSetValueEx(hKey,"Bells",0,REG_DWORD,(BYTE *)&Bells,4); + retCode = RegSetValueEx(hKey,"StripLF",0,REG_DWORD,(BYTE *)&StripLF,4); + retCode = RegSetValueEx(hKey,"SendDisconnected",0,REG_DWORD,(BYTE *)&SendDisconnected,4); + retCode = RegSetValueEx(hKey,"MTX",0,REG_DWORD,(BYTE *)&mtxparam,4); + retCode = RegSetValueEx(hKey,"MCOM",0,REG_DWORD,(BYTE *)&mcomparam,4); + retCode = RegSetValueEx(hKey,"MUIONLY",0,REG_DWORD,(BYTE *)&monUI,4); + retCode = RegSetValueEx(hKey,"Split",0,REG_BINARY,(BYTE *)&Split,sizeof(Split)); + retCode = RegSetValueEx(hKey,"MONColour",0,REG_DWORD,(BYTE *)&MonitorColour,4); + retCode = RegSetValueEx(hKey,"MonitorNODES",0,REG_DWORD,(BYTE *)&MonitorNODES,4); + + wsprintf(Size,"%d,%d,%d,%d",Rect.left,Rect.right,Rect.top,Rect.bottom); + retCode = RegSetValueEx(hKey,"Size",0,REG_SZ,(BYTE *)&Size, strlen(Size)); + + RegCloseKey(hKey); + } + + KillTimer(NULL, TimerHandle); + + CloseBPQ32(); // Close Ext Drivers if last bpq32 process + + return (msg.wParam); +} + +// + +// +// FUNCTION: InitApplication(HANDLE) +// +// PURPOSE: Initializes window data and registers window class +// +// COMMENTS: +// +// In this function, we initialize a window class by filling out a data +// structure of type WNDCLASS and calling either RegisterClass or +// the internal MyRegisterClass. +// +BOOL InitApplication(HINSTANCE hInstance) +{ + WNDCLASS wc; + + bgBrush = CreateSolidBrush(BGCOLOUR); + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = WndProc; + + wc.cbClsExtra = 0; + wc.cbWndExtra = DLGWINDOWEXTRA; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( BPQICON ) ); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = bgBrush; + + wc.lpszMenuName = NULL; + wc.lpszClassName = ClassName; + + return (RegisterClass(&wc)); + +} + +HMENU hMenu, hPopMenu1, hPopMenu2, hPopMenu3; // handle of menu + +VOID SetupRTFHddr() +{ + int i, n; + char RTFColours[3000]; + char Temp[1000]; + + // Set up RTF Header, including Colours String; + + memcpy(RTFColours, "{\\colortbl ;", 12); + n = 12; + + for (i = 1; i < 100; i++) + { + COLORREF Colour = Colours[i]; + n += wsprintf(&RTFColours[n], "\\red%d\\green%d\\blue%d;", GetRValue(Colour), GetGValue(Colour),GetBValue(Colour)); + } + + RTFColours[n++] = '}'; + RTFColours[n] = 0; + +// strcpy(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset204 ;}}"); + wsprintf(RTFHeader, "{\\rtf1\\deff0{\\fonttbl{\\f0\\fprq1\\cpg%d\\fcharset%d %s;}}", CodePage, CharSet, FontName); + strcat(RTFHeader, RTFColours); + wsprintf(Temp, "\\viewkind4\\uc1\\pard\\f0\\fs%d", FontSize); + strcat(RTFHeader, Temp); + + RTFHddrLen = strlen(RTFHeader); +} + + +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + int i, n; + uint64_t tempmask=0x0; + char msg[50]; + int retCode,Type,Vallen; + HKEY hKey=0; + char Size[80]; + TEXTMETRIC tm; + HDC dc; + struct RTFTerm * OPData; + struct PORTCONTROL * PORT; + + hInst = hInstance; // Store instance handle in our global variable + + // See if running under WINE + + retCode = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine", 0, KEY_QUERY_VALUE, &hKey); + + if (retCode == ERROR_SUCCESS) + { + RegCloseKey(hKey); + WINE = TRUE; + Debugprintf("Running under WINE"); + } + + REGTREE = GetRegistryKey(); + + MinimizetoTray=GetMinimizetoTrayFlag(); + + // Create a dialog box as the main window + + hWnd=CreateDialog(hInst,ClassName,0,NULL); + + if (!hWnd) + return (FALSE); + + MainWnd=hWnd; + + // Retrieve the handlse to the edit controls. + + hwndInput = GetDlgItem(hWnd, 118); +// hwndOutput = GetDlgItem(hWnd, 117); + hwndSplit = GetDlgItem(hWnd, 119); + hwndMon = GetDlgItem(hWnd, 116); + + // Set our own WndProcs for the controls. + + wpOrigInputProc = (WNDPROC) SetWindowLong(hwndInput, GWL_WNDPROC, (LONG) InputProc); + wpOrigMonProc = (WNDPROC)SetWindowLong(hwndMon, GWL_WNDPROC, (LONG)MonProc); + wpOrigSplitProc = (WNDPROC)SetWindowLong(hwndSplit, GWL_WNDPROC, (LONG)SplitProc); + + // Get config from Registry + + wsprintf(Key,"SOFTWARE\\G8BPQ\\BPQ32\\BPQTerminal\\Session%d",Sessno); + + retCode = RegOpenKeyEx (REGTREE, + Key, + 0, + KEY_QUERY_VALUE, + &hKey); + + if (retCode == ERROR_SUCCESS) + { + Vallen=4; + retCode = RegQueryValueEx(hKey,"MTX",0, + (ULONG *)&Type,(UCHAR *)&mtxparam,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"MUIONLY",0, + (ULONG *)&Type,(UCHAR *)&monUI,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"MCOM",0, + (ULONG *)&Type,(UCHAR *)&mcomparam,(ULONG *)&Vallen); + + Vallen=8; + retCode = RegQueryValueEx(hKey,"PortMask",0, + (ULONG *)&Type,(UCHAR *)&tempmask,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"AutoConnect",0, + (ULONG *)&Type,(UCHAR *)&AUTOCONNECT,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"MONColour",0, + (ULONG *)&Type,(UCHAR *)&MonitorColour,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"MonitorNODES",0, + (ULONG *)&Type,(UCHAR *)&MonitorNODES,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"Bells",0, + (ULONG *)&Type,(UCHAR *)&Bells,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey,"StripLF",0, + (ULONG *)&Type,(UCHAR *)&StripLF,(ULONG *)&Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey, "SendDisconnected",0, + (ULONG *)&Type,(UCHAR *)&StripLF,(ULONG *)&Vallen); + + + + Vallen=8; + retCode = RegQueryValueEx(hKey,"Split",0, + (ULONG *)&Type,(UCHAR *)&Split,(ULONG *)&Vallen); + + Vallen=80; + retCode = RegQueryValueEx(hKey,"Size",0, + (ULONG *)&Type,(UCHAR *)&Size,(ULONG *)&Vallen); + + sscanf(Size,"%d,%d,%d,%d",&Rect.left,&Rect.right,&Rect.top,&Rect.bottom); + + Vallen=99; + retCode = RegQueryValueEx(hKey, "FontName", 0, &Type, FontName, &Vallen); + + if (FontName[0] == 0) + strcpy(FontName, "FixedSys"); + + Vallen=4; + retCode = RegQueryValueEx(hKey, "CharSet", 0, &Type, (UCHAR *)&CharSet, &Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey, "CodePage", 0, &Type, (UCHAR *)&CodePage, &Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey, "FontSize", 0, &Type, (UCHAR *)&FontSize, &Vallen); + + Vallen=4; + retCode = RegQueryValueEx(hKey, "FontWidth", 0, &Type, (UCHAR *)&FontWidth, &Vallen); + + RegCloseKey(hKey); + } + + OutputData.CharWidth = FontWidth; + + if (Rect.right < 100 || Rect.bottom < 100) + { + GetWindowRect(hWnd, &Rect); + } + + Height = Rect.bottom-Rect.top; + Width = Rect.right-Rect.left; + +#pragma warning(push) +#pragma warning(disable:4244) + SplitPos=Height*Split; +#pragma warning(pop) + + SetupRTFHddr(); + + // Create a Rich Text Control + + OPData = &OutputData; + + OPData->SendHeader = TRUE; + OPData->Finished = TRUE; + OPData->CurrentColour = 1; + + LoadLibrary("riched20.dll"); + + hwndOutput = CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, "", + WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_NOHIDESEL | WS_VSCROLL | ES_READONLY, + 6,145,290,130, MainWnd, NULL, hInstance, NULL); + + // Register for Mouse Events for Copy/Paste + + SendMessage(hwndOutput, EM_SETEVENTMASK, (WPARAM)0, (LPARAM)ENM_MOUSEEVENTS | ENM_SCROLLEVENTS | ENM_KEYEVENTS); + SendMessage(hwndOutput, EM_EXLIMITTEXT, 0, MAXLINES * LINELEN); + + trayMenu = CreatePopupMenu(); + + AppendMenu(trayMenu,MF_STRING,40000,"Copy"); + + MoveWindow(hWnd,Rect.left,Rect.top, Rect.right-Rect.left, Rect.bottom-Rect.top, TRUE); + + MoveWindows(); + + Stream=FindFreeStream(); + + if (Stream == 255) + { + MessageBox(NULL,"No free streams available",NULL,MB_OK); + return (FALSE); + } + + // + // Register message for posting by BPQDLL + // + + BPQMsg = RegisterWindowMessage(BPQWinMsg); + + // + // Enable Async notification + // + + BPQSetHandle(Stream, hWnd); + + GetVersionInfo(NULL); + + wsprintf(Title,"BPQTerminal Version %s - using stream %d", VersionString, Stream); + + SetWindowText(hWnd,Title); + + +// Sets Application Flags and Mask for stream. (BPQHOST function 1) +// AH = 1 Set application mask to value in DL (or even DX if 16 +// applications are ever to be supported). +// +// Set application flag(s) to value in CL (or CX). +// whether user gets connected/disconnected messages issued +// by the node etc. +// +// Top bit of flags controls monitoring + + hMenu=GetMenu(hWnd); + +// if (applmask & 0x01) CheckMenuItem(hMenu,BPQAPPL1,MF_CHECKED); +// if (applmask & 0x02) CheckMenuItem(hMenu,BPQCHAT,MF_CHECKED); +// if (applmask & 0x04) CheckMenuItem(hMenu,BPQAPPL3,MF_CHECKED); +// if (applmask & 0x08) CheckMenuItem(hMenu,BPQAPPL4,MF_CHECKED); +// if (applmask & 0x10) CheckMenuItem(hMenu,BPQAPPL5,MF_CHECKED); +// if (applmask & 0x20) CheckMenuItem(hMenu,BPQAPPL6,MF_CHECKED); +// if (applmask & 0x40) CheckMenuItem(hMenu,BPQAPPL7,MF_CHECKED); +// if (applmask & 0x80) CheckMenuItem(hMenu,BPQAPPL8,MF_CHECKED); + +// CMD_TO_APPL EQU 1B ; PASS COMMAND TO APPLICATION +// MSG_TO_USER EQU 10B ; SEND 'CONNECTED' TO USER +// MSG_TO_APPL EQU 100B ; SEND 'CONECTED' TO APPL +// 0x40 = Send Keepalives + +// if (applflags & 0x01) CheckMenuItem(hMenu,BPQFLAGS1,MF_CHECKED); +// if (applflags & 0x02) CheckMenuItem(hMenu,BPQFLAGS2,MF_CHECKED); +// if (applflags & 0x04) CheckMenuItem(hMenu,BPQFLAGS3,MF_CHECKED); +// if (applflags & 0x40) CheckMenuItem(hMenu,BPQFLAGS4,MF_CHECKED); + + + hPopMenu1=GetSubMenu(hMenu,1); + + for (n=1;n <= GetNumberofPorts();n++) + { + PORT = GetPortTableEntryFromSlot(n); + + i = PORT->PORTNUMBER; + + sprintf(msg,"Port %d %s ",i, PORT->PORTDESCRIPTION); + + if (tempmask & ((uint64_t)1<<(i-1))) + { + AppendMenu(hPopMenu1,MF_STRING | MF_CHECKED,BPQBASE + i,msg); + portmask |= ((uint64_t)1 <<( i-1)); + } + else + AppendMenu(hPopMenu1,MF_STRING | MF_UNCHECKED,BPQBASE + i,msg); + } + + if (mtxparam & 1) + CheckMenuItem(hMenu,BPQMTX,MF_CHECKED); + else + CheckMenuItem(hMenu,BPQMTX,MF_UNCHECKED); + + CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED); + + if (AUTOCONNECT) + CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_CHECKED); + else + CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_UNCHECKED); + + if (Bells & 1) + CheckMenuItem(hMenu,BPQBELLS, MF_CHECKED); + else + CheckMenuItem(hMenu,BPQBELLS, MF_UNCHECKED); + + if (SendDisconnected & 1) + CheckMenuItem(hMenu,BPQSendDisconnected, MF_CHECKED); + else + CheckMenuItem(hMenu,BPQSendDisconnected, MF_UNCHECKED); + + if (StripLF & 1) + CheckMenuItem(hMenu,BPQStripLF, MF_CHECKED); + else + CheckMenuItem(hMenu,BPQStripLF, MF_UNCHECKED); + + CheckMenuItem(hMenu,BPQMNODES, (MonitorNODES) ? MF_CHECKED : MF_UNCHECKED); + + CheckMenuItem(hMenu,MONCOLOUR, (MonitorColour) ? MF_CHECKED : MF_UNCHECKED); + + DrawMenuBar(hWnd); + + if (portmask) applflags |= 0x80; + + SetAppl(Stream, applflags, applmask); + + SetTraceOptions64(portmask, mtxparam, mcomparam, monUI); + + DragCursor = LoadCursor(hInstance, "IDC_DragSize"); + Cursor = LoadCursor(NULL, IDC_ARROW); + + GetCallsign(Stream, callsign); + + if (MinimizetoTray) + { + // Set up Tray ICON + + wsprintf(Title,"BPQTerminal Stream %d",Stream); + AddTrayMenuItem(hWnd, Title); + } + + if ((nCmdShow == SW_SHOWMINIMIZED) || (nCmdShow == SW_SHOWMINNOACTIVE)) + if (MinimizetoTray) + ShowWindow(hWnd, SW_HIDE); + else + ShowWindow(hWnd, nCmdShow); + else + ShowWindow(hWnd, nCmdShow); + + UpdateWindow(hWnd); + + CheckTimer(); + + TimerHandle = SetTimer(NULL, 0, 10000, lpTimerFunc); + + dc = GetDC(hwndOutput); + GetTextMetrics(dc, &tm); + + return (TRUE); +} + +// +// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) +// +// PURPOSE: Processes messages for the main window. +// + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + int wmId, wmEvent; + LPRECT lprc; + UCHAR Buffer[1000]; + UCHAR * buf = Buffer; + TEXTMETRIC tm; + int i, y; + LPMEASUREITEMSTRUCT lpmis; + LPDRAWITEMSTRUCT lpdis; + + + if (message == BPQMsg) + { + if (lParam & BPQDataAvail) + DoReceivedData(hWnd); + + if (lParam & BPQMonitorAvail) + DoMonData(hWnd); + + if (lParam & BPQStateChange) + DoStateChange(hWnd); + + return (0); + } + + switch (message) { + + case WM_CTLCOLOREDIT: + + if (OutputData.Scrolled) + { + HDC hdcStatic = (HDC)wParam; + SetBkMode(hdcStatic, TRANSPARENT); + + return (LONG)GetStockObject(LTGRAY_BRUSH); + } + return (DefWindowProc(hWnd, message, wParam, lParam)); + + case WM_NOTIFY: + { + const MSGFILTER * pF = (MSGFILTER *)lParam; + POINT pos; + CHARRANGE Range; + + if(pF->nmhdr.hwndFrom == hwndOutput) + { + if(pF->msg == WM_VSCROLL) + { +// OutputData.Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0); + DoRefresh(&OutputData); +// return TRUE; + } + + if(pF->msg == WM_KEYUP) + { + if (pF->wParam == VK_PRIOR || pF->wParam == VK_NEXT) + { +// OutputData.Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0); + DoRefresh(&OutputData); + } + } + + if(pF->msg == WM_RBUTTONDOWN) + { + // Only allow popup if something is selected + + SendMessage(hwndOutput, EM_EXGETSEL , 0, (WPARAM)&Range); + if (Range.cpMin == Range.cpMax) + return TRUE; + + GetCursorPos(&pos); + TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, hWnd, 0); + return TRUE; + } + } + break; + } + + + + case WM_MEASUREITEM: + + lpmis = (LPMEASUREITEMSTRUCT) lParam; + + // Set the height of the list box items. + + // lpmis->itemHeight = 15; + return TRUE; + + case WM_DRAWITEM: + + lpdis = (LPDRAWITEMSTRUCT) lParam; + + // If there are no list box items, skip this message. + + if (lpdis->itemID == -1) + { + return TRUE; + } + + switch (lpdis->itemAction) + { + case ODA_SELECT: + case ODA_DRAWENTIRE: + + // if Chat Console, and message has a colour eacape, action it + + SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM) Buffer); + + GetTextMetrics(lpdis->hDC, &tm); + + if (lpdis->hwndItem == hwndOutput) + { + CharWidth = tm.tmAveCharWidth; + maxlinelen = ClientWidth/CharWidth - 1; + } + + y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2; + + if (Buffer[0] == 0x1b) + { + SetTextColor(lpdis->hDC, Colours[Buffer[1] - 10]); + buf += 2; + } +// SetBkColor(lpdis->hDC, 0); + + TextOut(lpdis->hDC, + 6, + y, + buf, + strlen(buf)); + + // SetTextColor(lpdis->hDC, OldColour); + + break; + } + + return TRUE; + + case WM_ACTIVATE: + + //fActive = LOWORD(wParam); // activation flag + //fMinimized = (BOOL) HIWORD(wParam); // minimized flag + // hwnd = (HWND) lParam; // window handle + + SetFocus(hwndInput); + break; + + + + case WM_COMMAND: + + wmId = LOWORD(wParam); // Remember, these are... + wmEvent = HIWORD(wParam); // ...different for Win32! + + //Parse the menu selections: + + if (wmId > BPQBASE && wmId < BPQBASE + 64) + { + TogglePort(hWnd,wmId,(uint64_t)1 << (wmId - (BPQBASE + 1))); + break; + } + + switch (wmId) { + + case 40000: + { + int len=0; + HGLOBAL hMem; + char * ptr; + CHARRANGE Range; + + // Copy Rich Text Selection to Clipboard + + SendMessage(hwndOutput, EM_EXGETSEL , 0, (WPARAM)&Range); + + hMem=GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, Range.cpMax - Range.cpMin + 1); + + if (hMem != 0) + { + ptr=GlobalLock(hMem); + + if (OpenClipboard(MainWnd)) + { + len = SendMessage(hwndOutput, EM_GETSELTEXT , 0, (WPARAM)ptr); + + GlobalUnlock(hMem); + EmptyClipboard(); + SetClipboardData(CF_TEXT,hMem); + CloseClipboard(); + } + } + else + GlobalFree(hMem); + + SetFocus(hwndInput); + return TRUE; + } + + case ID_SETUP_FONT: + + DialogBox(hInst, MAKEINTRESOURCE(IDD_FONT), hWnd, FontConfigWndProc); + break; + + + case BPQMTX: + + ToggleMTX(hWnd); + break; + + case BPQMCOM: + + ToggleMCOM(hWnd); + break; + + case MUIONLY: + + ToggleMUI(hWnd); + break; + + case BPQCONNECT: + + SessionControl(Stream, 1, 0); + break; + + case BPQDISCONNECT: + + SessionControl(Stream, 2, 0); + break; + + + case ID_ACTION_RESETWINDOWSPLIT: + + Split = 0.5; + SplitPos=Height*Split; + MoveWindows(); + + break; + + case BPQAUTOCONNECT: + + ToggleAutoConnect(hWnd); + break; + + case BPQBELLS: + + ToggleParam(hWnd, &Bells, BPQBELLS); + break; + + case BPQStripLF: + + ToggleParam(hWnd, &StripLF, BPQStripLF); + break; + + case BPQLogOutput: + + ToggleParam(hWnd, &LogOutput, BPQLogOutput); + break; + + case CHATTERM: + + ToggleParam(hWnd, &ChatMode, CHATTERM); + break; + + + case BPQSendDisconnected: + + ToggleParam(hWnd, &SendDisconnected, BPQSendDisconnected); + break; + + case BPQMNODES: + + ToggleParam(hWnd, &MonitorNODES, BPQMNODES); + break; + + case MONCOLOUR: + + ToggleParam(hWnd, &MonitorColour, MONCOLOUR); + break; + + case BPQLogMonitor: + + ToggleParam(hWnd, &LogMonitor, BPQLogMonitor); + break; + + case BPQCLEARMON: + + SendMessage(hwndMon,LB_RESETCONTENT, 0, 0); + break; + + case BPQCLEAROUT: + + for (i = 0; i < MAXLINES; i++) + { + OutputData.OutputScreen[i][0] = 0; + } + + OutputData.CurrentLine = 0; + DoRefresh(&OutputData); + + break; + + case BPQCOPYMON: + + CopyListToClipboard(hwndMon); + break; + + case BPQCOPYOUT: + + CopyRichTextToClipboard(hwndOutput); + break; + + case BPQHELP: + + ShellExecute(hWnd,"open", + "http://www.cantab.net/users/john.wiseman/Documents/BPQTerminal.htm", + "", NULL, SW_SHOWNORMAL); + break; + + default: + + return 0; + + } + + case WM_SYSCOMMAND: + + wmId = LOWORD(wParam); // Remember, these are... + wmEvent = HIWORD(wParam); // ...different for Win32! + + switch (wmId) + { + case SC_MINIMIZE: + + if (MinimizetoTray) + return ShowWindow(hWnd, SW_HIDE); + + default: + + return (DefWindowProc(hWnd, message, wParam, lParam)); + } + + case WM_SIZING: + + lprc = (LPRECT) lParam; + + Height = lprc->bottom-lprc->top; + Width = lprc->right-lprc->left; + + SplitPos=Height*Split; + + MoveWindows(); + + return TRUE; + + case WM_SIZE: + + MoveWindows(); + return TRUE; + + case WM_DESTROY: + + // Remove the subclass from the edit control. + + GetWindowRect(hWnd, &Rect); // For save soutine + + SetWindowLong(hwndInput, GWL_WNDPROC, + (LONG) wpOrigInputProc); + + SessionControl(Stream, 2, 0); + DeallocateStream(Stream); + PostQuitMessage(0); + + if (MinimizetoTray) + DeleteTrayMenuItem(hWnd); + + break; + + default: + return (DefWindowProc(hWnd, message, wParam, lParam)); + + } + return (0); +} + +static char * KbdStack[20]; + +int StackIndex=0; + +LRESULT APIENTRY InputProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + char DisplayLine[200] = "\x1b\xb"; + + if (uMsg == WM_CTLCOLOREDIT) + { + HBRUSH Brush = CreateSolidBrush(RGB(0, 255, 0)); + HDC hdcStatic = (HDC)wParam; + SetTextColor(hdcStatic, RGB(0, 0, 0)); + SetBkMode(hdcStatic, TRANSPARENT); + + return (LONG)Brush; + } + + + if (uMsg == WM_KEYUP) + { + unsigned int i; + +// Debugprintf("5%x", LOBYTE(HIWORD(lParam))); + + if (LOBYTE(HIWORD(lParam)) == 0x48 && wParam == 0x26) + { + // Scroll up + + if (KbdStack[StackIndex] == NULL) + return TRUE; + + SendMessage(hwndInput, WM_SETTEXT,0,(LPARAM)(LPCSTR) KbdStack[StackIndex]); + + for (i = 0; i < strlen(KbdStack[StackIndex]); i++) + { + SendMessage(hwndInput, WM_KEYDOWN, VK_RIGHT, 0); + SendMessage(hwndInput, WM_KEYUP, VK_RIGHT, 0); + } + + StackIndex++; + if (StackIndex == 20) + StackIndex = 19; + + return TRUE; + } + + if (LOBYTE(HIWORD(lParam)) == 0x50 && wParam == 0x28) + { + // Scroll up + + StackIndex--; + if (StackIndex < 0) + StackIndex = 0; + + if (KbdStack[StackIndex] == NULL) + return TRUE; + + SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) KbdStack[StackIndex]); + + for (i = 0; i < strlen(KbdStack[StackIndex]); i++) + { + SendMessage(hwndInput, WM_KEYDOWN, VK_RIGHT, 0); + SendMessage(hwndInput, WM_KEYUP, VK_RIGHT, 0); + } + + return TRUE; + } + } + + + + if (uMsg == WM_CHAR) + { + if (wParam == 13) + { + int i; + + // + // if not connected, and autoconnect is + // enabled, connect now + + if (!CONNECTED && AUTOCONNECT) + SessionControl(Stream, 1, 0); + + kbptr=SendMessage(hwndInput,WM_GETTEXT,159,(LPARAM) (LPCSTR) kbbuf); + + // Stack it + + StackIndex = 0; + + if (KbdStack[19]) + free(KbdStack[19]); + + for (i = 18; i >= 0; i--) + { + KbdStack[i+1] = KbdStack[i]; + } + + KbdStack[0] = _strdup(kbbuf); + + kbbuf[kbptr]=13; + + SlowTimer = 0; + + // Echo, with set Black escape + + memcpy(&DisplayLine[2], kbbuf, kbptr+1); + + if (OutputData.Scrolled) + { + POINT Point; + Point.x = 0; + Point.y = 25000; // Should be plenty for any font + + SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point); + OutputData.Scrolled = FALSE; + } + + WritetoOutputWindow(&OutputData, DisplayLine, kbptr+3); + DoRefresh(&OutputData); + + + // Replace null with CR, and send to Node + + SendMsg(Stream, &kbbuf[0], kbptr+1); + + SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) ""); + + return 0; + } + if (wParam == 0x1a) // Ctrl/Z + { + // + // if not connected, and autoconnect is + // enabled, connect now + + if (!CONNECTED && AUTOCONNECT) + SessionControl(Stream, 1, 0); + + kbbuf[0]=0x1a; + kbbuf[1]=13; + + SendMsg(Stream, &kbbuf[0], 2); + + SendMessage(hwndInput,WM_SETTEXT,0,(LPARAM)(LPCSTR) ""); + + return 0; + } + + } + + return CallWindowProc(wpOrigInputProc, hwnd, uMsg, wParam, lParam); +} + +//int FirstItem=-1, LastItem=-1, SELECTING=FALSE, MOVED=FALSE, LastSelected=0; + +LRESULT APIENTRY MonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if (uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST) + return TRUE; + + return CallWindowProc(wpOrigMonProc, hwnd, uMsg, wParam, lParam); +} + +LRESULT APIENTRY SplitProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + int xPos, yPos; + + switch (uMsg) { + + case WM_LBUTTONDOWN: + + SetCapture(hwnd); + return 0; + + case WM_LBUTTONUP: + + xPos = LOWORD(lParam); // horizontal position of cursor + yPos = lParam >> 16; // vertical position of cursor + + SplitPos = SplitPos + yPos - 5; + + if (SplitPos < 0) SplitPos = 0; + + Split=SplitPos; + Split=Split/Height; + + ReleaseCapture(); + MoveWindows(); + DoRefresh(&OutputData); + return 0; + + case WM_MOUSEMOVE: + + // Used to size split between Monitor and Output Windows + + SetCursor(DragCursor); + break; + } + return CallWindowProc(wpOrigSplitProc, hwnd, uMsg, wParam, lParam); +} + + + + +DoStateChange(HWND hWnd) +{ + int port, sesstype, paclen, maxframe, l4window; + + // Get current Session State. Any state changed is ACK'ed + // automatically. See BPQHOST functions 4 and 5. + + SessionState(Stream, &state, &change); + + if (change == 1) + { + if (state == 1) + { + // Connected + + CONNECTED = TRUE; + SlowTimer = 0; + + // GetCallsign(Stream, callsign); + + GetConnectionInfo(Stream, callsign, + &port, &sesstype, &paclen, + &maxframe, &l4window); + + + wsprintf(Title,"BPQTerminal Version %s - using stream %d - Connected to %s",VersionString,Stream,callsign); + SetWindowText(hWnd,Title); + DisableConnectMenu(hWnd); + EnableDisconnectMenu(hWnd); + + } + else + { + CONNECTED=FALSE; + wsprintf(Title,"BPQTerminal Version %s - using stream %d - Disconnected",VersionString,Stream); + SetWindowText(hWnd,Title); + DisableDisconnectMenu(hWnd); + EnableConnectMenu(hWnd); + + if (SendDisconnected) + { + WritetoOutputWindow(&OutputData, "*** Disconnected\r", 17); + DoRefresh(&OutputData); + } + } + } + + return (0); + +} + +DoReceivedData(HWND hWnd) +{ + char Msg[300]; + + if (RXCount(Stream) > 0) + { + do { + + GetMsg(Stream, &Msg[0],&len,&count); + WritetoOutputWindow(&OutputData, Msg, len); + DoRefresh(&OutputData); + + SlowTimer = 0; + + } while (count > 0); + } + return (0); +} +DWORD CALLBACK EditStreamCallback(DWORD_PTR Cookie, LPBYTE lpBuff, LONG cb, PLONG pcb) +{ + struct RTFTerm * OPData = (struct RTFTerm *)Cookie; + int ReqLen = cb; + int i; + int Line; + +// if (cb != 4092) +// return 0; + + if (OPData->SendHeader) + { + // Return header + + memcpy(lpBuff, RTFHeader, RTFHddrLen); + *pcb = RTFHddrLen; + OPData->SendHeader = FALSE; + OPData->Finished = FALSE; + OPData->Index = 0; + return 0; + } + + if (OPData->Finished) + { + *pcb = 0; + return 0; + } + +/* + if (BufferLen > cb) + { + memcpy(lpBuff, &Buffer[Offset], cb); + BufferLen -= cb; + Offset += cb; + *pcb = cb; + return 0; + } + + memcpy(lpBuff, &Buffer[Offset], BufferLen); + + *pcb = BufferLen; +*/ + + // Return 10 line at a time + + for (i = 0; i < 10; i++); + { + Line = OPData->Index++ + OPData->CurrentLine - MAXLINES; + + if (Line <0) + Line = Line + MAXLINES; + + wsprintf(lpBuff, "\\cf%d ", OPData->Colourvalue[Line]); + strcat(lpBuff, OPData->OutputScreen[Line]); + strcat(lpBuff, "\\line"); + + if (OPData->Index == MAXLINES) + { + OPData->Finished = TRUE; + strcat(lpBuff, "}"); + i = 10; + } + } + *pcb = strlen(lpBuff); + return 0; +} + +VOID ForceRefresh(struct RTFTerm * OPData) +{ + OPData->Thumb = 25000; + DoRefresh(OPData); + OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0); +} + +VOID DoRefresh(struct RTFTerm * OPData) +{ + EDITSTREAM es = {0}; + int Min, Max, Pos; + POINT Point; + SCROLLINFO ScrollInfo; + int LoopTrap = 0; + + if(WINE) + OPData->Thumb = 30000; + else + OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0); + + Pos = OPData->Thumb + OutputBoxHeight; + + if (Pos > OPData->RTFHeight - 10) // Don't bother writing to screen if scrolled back + { + es.pfnCallback = EditStreamCallback; + es.dwCookie = (DWORD_PTR)OPData; + OPData->SendHeader = TRUE; + SendMessage(hwndOutput, EM_STREAMIN, SF_RTF, (LPARAM)&es); + } +// else +// Debugprintf("Pos %d RTFHeight %d - Not refreshing", Pos, OPData->RTFHeight); + + GetScrollRange(hwndOutput, SB_VERT, &Min, &Max); + ScrollInfo.cbSize = sizeof(ScrollInfo); + ScrollInfo.fMask = SIF_ALL; + + GetScrollInfo(hwndOutput, SB_VERT, &ScrollInfo); + +// Debugprintf("Thumb %d Pos %d Min %d Max %d nMax %d ClientH %d RTFHeight %d", +// OPData->Thumb, Pos, Min, Max, ScrollInfo.nMax, OutputBoxHeight, OPData->RTFHeight); + + if (OPData->FirstTime == FALSE) + { + // RTF Controls don't immediately scroll to end - don't know why. + + OPData->FirstTime = TRUE; + Point.x = 0; + Point.y = 25000; // Should be plenty for any font + + while (LoopTrap++ < 20) + { + SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point); + } + + GetScrollRange(hwndOutput, SB_VERT, &Min, &Max); // Get Actual Height + OPData->RTFHeight = Max; + Point.x = 0; + Point.y = OPData->RTFHeight - ScrollInfo.nPage; + SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point); + OPData->Thumb = SendMessage(hwndOutput, EM_GETTHUMB, 0, 0); + } + + Point.x = 0; + Point.y = OPData->RTFHeight - ScrollInfo.nPage; + + if (OPData->Thumb > (Point.y - 10)) // Don't Scroll if user has scrolled back + { +// Debugprintf("Scrolling to %d", Point.y); + SendMessage(hwndOutput, EM_SETSCROLLPOS, 0, (LPARAM) &Point); + if (OPData->Scrolled) + { + OPData->Scrolled = FALSE; + InvalidateRect(hwndInput, NULL, TRUE); + } + return; + } + +// Debugprintf("Thumb = %d Point.y = %d - Not Scrolling", OPData->Thumb, Point.y); + + if (!OPData->Scrolled) + { + OPData->Scrolled = TRUE; + InvalidateRect(hwndInput, NULL, TRUE); + } +} + +VOID AddLinetoWindow(struct RTFTerm * OPData, char * Line) +{ + int Len = strlen(Line); + char * ptr1 = Line; + char * ptr2; + int l, Index; + char LineCopy[LINELEN * 2]; + + if (Line[0] == 0x1b && Len > 1) + { + // Save Colour Char + + OPData->CurrentColour = Line[1] - 10; + ptr1 +=2; + Len -= 2; + } + + strcpy(OPData->OutputScreen[OPData->CurrentLine], ptr1); + + // Look for chars we need to escape (\ { }) + + ptr1 = OPData->OutputScreen[OPData->CurrentLine]; + Index = 0; + ptr2 = strchr(ptr1, '\\'); // Look for Backslash first, as we may add some later + + if (ptr2) + { + while (ptr2) + { + l = ++ptr2 - ptr1; + memcpy(&LineCopy[Index], ptr1, l); // Copy Including found char + Index += l; + LineCopy[Index++] = '\\'; + Len++; + ptr1 = ptr2; + ptr2 = strchr(ptr1, '\\'); + } + strcpy(&LineCopy[Index], ptr1); // Copy in rest + strcpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy); + } + + ptr1 = OPData->OutputScreen[OPData->CurrentLine]; + Index = 0; + ptr2 = strchr(ptr1, '{'); + + if (ptr2) + { + while (ptr2) + { + l = ptr2 - ptr1; + memcpy(&LineCopy[Index], ptr1, l); + Index += l; + LineCopy[Index++] = '\\'; + LineCopy[Index++] = '{'; + Len++; + ptr1 = ++ptr2; + ptr2 = strchr(ptr1, '{'); + } + strcpy(&LineCopy[Index], ptr1); // Copy in rest + strcpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy); + } + + ptr1 = OPData->OutputScreen[OPData->CurrentLine]; + Index = 0; + ptr2 = strchr(ptr1, '}'); // Look for Backslash first, as we may add some later + + if (ptr2) + { + while (ptr2) + { + l = ptr2 - ptr1; + memcpy(&LineCopy[Index], ptr1, l); // Copy + Index += l; + LineCopy[Index++] = '\\'; + LineCopy[Index++] = '}'; + Len++; + ptr1 = ++ptr2; + ptr2 = strchr(ptr1, '}'); + } + strcpy(&LineCopy[Index], ptr1); // Copy in rest + strcpy(OPData->OutputScreen[OPData->CurrentLine], LineCopy); + } + + + OPData->Colourvalue[OPData->CurrentLine] = OPData->CurrentColour; + OPData->LineLen[OPData->CurrentLine++] = Len; + if (OPData->CurrentLine >= MAXLINES) OPData->CurrentLine = 0; +} + +VOID WritetoOutputWindow(struct RTFTerm * OPData, char * Msg, int len) +{ + char * ptr1, * ptr2; + + if (PartLinePtr > LINELEN) + Msg[len++] = 13; // Force a newline + + if (PartLinePtr != 0) + { + OPData->CurrentLine--; // Overwrite part line in buffer + if (OPData->CurrentLine < 0) + OPData->CurrentLine = MAXLINES - 1; + + if (Msg[0] == 0x1b && len > 1) + { + Msg += 2; // Remove Colour Escape + len -= 2; + } + } + + memcpy(&readbuff[PartLinePtr], Msg, len); + + len += PartLinePtr; + + ptr1=&readbuff[0]; + readbuff[len]=0; + + if (Bells) + { + do { + ptr2=memchr(ptr1,7,len); + + if (ptr2) + { + *(ptr2)=32; + Beep(440,250); + } + } while (ptr2); + } + +lineloop: + + if (len > 0) + { + // copy text to buffer a line at a time + + ptr2=memchr(ptr1,13,len); + + if (ptr2 == 0) + { + // no newline. Move data to start of buffer and Save pointer + + PartLinePtr = len; + memmove(readbuff,ptr1,len); + AddLinetoWindow(OPData, ptr1); + return; + } + + *(ptr2++)=0; + + if (LogOutput) WriteMonitorLine(ptr1, ptr2 - ptr1); + + // If len is greater that screen with, fold + + if ((ptr2 - ptr1) > maxlinelen) + { + char * ptr3; + char * saveptr1 = ptr1; + int linelen = ptr2 - ptr1; + int foldlen; + char save; + + foldloop: + + ptr3 = ptr1 + maxlinelen; + + while(*ptr3!= 0x20 && ptr3 > ptr1) + { + ptr3--; + } + foldlen = ptr3 - ptr1 ; + + if (foldlen == 0) + { + // No space before, so split at width + + foldlen = maxlinelen; + ptr3 = ptr1 + maxlinelen; + + } + else + { + ptr3++ ; // Omit space + linelen--; + } + save = ptr1[foldlen]; + ptr1[foldlen] = 0; + + AddLinetoWindow(OPData, ptr1); + + ptr1[foldlen] = save; + linelen -= foldlen; + ptr1 = ptr3; + + if (linelen > maxlinelen) + goto foldloop; + + AddLinetoWindow(OPData, ptr1); + ptr1 = saveptr1; + + } + else + AddLinetoWindow(OPData, ptr1); + + + PartLinePtr=0; + + len-=(ptr2-ptr1); + + ptr1=ptr2; + + if ((len > 0) && StripLF) + { + if (*ptr1 == 0x0a) // Line Feed + { + ptr1++; + len--; + } + } + goto lineloop; + } +} + + +DoMonData(HWND hWnd) +{ + char * ptr1, * ptr2; + int index; + time_t stamp; + int len; + unsigned char buffer[1024] = "\x1b\xb", monbuff[512]; + + if (MONCount(Stream) > 0) + { + do { + + stamp=GetRaw(Stream, monbuff,&len,&count); + + if (MonitorColour) + { + if (monbuff[4] & 0x80) // TX + buffer[1] = 91; + else + buffer[1] = 17; + } + + // See if a NODES + + if (!MonitorNODES && monbuff[21] == 3 && monbuff[22] == 0xcf && monbuff[23] == 0xff) + len = 0; + else + { + len=DecodeFrame(monbuff,&buffer[2],stamp); + len +=2; + } + + ptr1=&buffer[0]; + + lineloop: + + if (len > 0) + { + // copy text to control a line at a time + + ptr2=memchr(ptr1,13,len); + + if (ptr2 == 0) + { + // no newline. Move data to start of buffer and Save pointer + + memmove(buffer,ptr1,len); + + return (0); + + } + else + { + *(ptr2++)=0; + + index=SendMessage(hwndMon,LB_ADDSTRING,0,(LPARAM)(LPCTSTR) ptr1 ); + + if (LogMonitor) WriteMonitorLine(ptr1, ptr2 - ptr1); + + if (index > 1200) + + do{ + + index=SendMessage(hwndMon,LB_DELETESTRING, 0, 0); + + } while (index > 1000); + + SendMessage(hwndMon,LB_SETCARETINDEX,(WPARAM) index, MAKELPARAM(FALSE, 0)); + + len-=(ptr2-ptr1); + + ptr1=ptr2; + + goto lineloop; + } + } + + } while (count > 0); + } + return (0); +} + + + + + +int DisableConnectMenu(HWND hWnd) +{ + HMENU hMenu; // handle of menu + + hMenu=GetMenu(hWnd); + + EnableMenuItem(hMenu,BPQCONNECT,MF_GRAYED); + + return (0); +} +int DisableDisconnectMenu(HWND hWnd) +{ + HMENU hMenu; // handle of menu + + hMenu=GetMenu(hWnd); + + EnableMenuItem(hMenu,BPQDISCONNECT,MF_GRAYED); + return (0); +} + +int EnableConnectMenu(HWND hWnd) +{ + HMENU hMenu; // handle of menu + + hMenu=GetMenu(hWnd); + + EnableMenuItem(hMenu,BPQCONNECT,MF_ENABLED); + return (0); +} + +int EnableDisconnectMenu(HWND hWnd) +{ + HMENU hMenu; // handle of menu + + hMenu=GetMenu(hWnd); + + EnableMenuItem(hMenu,BPQDISCONNECT,MF_ENABLED); + + return (0); +} + +int ToggleAutoConnect(HWND hWnd) +{ + HMENU hMenu; // handle of menu + + hMenu=GetMenu(hWnd); + + AUTOCONNECT = !AUTOCONNECT; + + if (AUTOCONNECT) + + CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_CHECKED); + + else + + CheckMenuItem(hMenu,BPQAUTOCONNECT,MF_UNCHECKED); + + return (0); + +} + +CopyScreentoBuffer(char * buff) +{ + + return (0); +} + +int TogglePort(HWND hWnd, int Item, uint64_t mask) +{ + portmask ^= mask; + + if (portmask & mask) + CheckMenuItem(hMenu,Item,MF_CHECKED); + else + CheckMenuItem(hMenu,Item,MF_UNCHECKED); + + if (portmask) + applflags |= 0x80; + else + applflags &= 0x7f; + + SetAppl(Stream,applflags,applmask); + + SetTraceOptions64(portmask, mtxparam, mcomparam, monUI); + + return (0); + +} +int ToggleMTX(HWND hWnd) +{ + mtxparam = mtxparam ^ 1; + + if (mtxparam & 1) + + CheckMenuItem(hMenu,BPQMTX,MF_CHECKED); + else + CheckMenuItem(hMenu,BPQMTX,MF_UNCHECKED); + + SetTraceOptions64(portmask, mtxparam, mcomparam, monUI); + + return (0); + +} +int ToggleMCOM(HWND hWnd) +{ + mcomparam = mcomparam ^ 1; + + CheckMenuItem(hMenu, BPQMCOM, (mcomparam) ? MF_CHECKED : MF_UNCHECKED); + SetTraceOptions64(portmask, mtxparam, mcomparam, monUI); + + return (0); + +} +int ToggleMUI(HWND hWnd) +{ + monUI = monUI ^ 1; + + CheckMenuItem(hMenu, MUIONLY, (monUI) ? MF_CHECKED : MF_UNCHECKED); + SetTraceOptions64(portmask, mtxparam, mcomparam, monUI); + + return (0); + +} +int ToggleParam(HWND hWnd, BOOL * Param, int Item) +{ + *Param = !(*Param); + + CheckMenuItem(hMenu,Item, (*Param) ? MF_CHECKED : MF_UNCHECKED); + + return (0); +} + +void MoveWindows() +{ + RECT rcMain, rcClient; + int ClientHeight, ClientWidth; + + if (hWnd == 0) + return; + + GetWindowRect(hWnd, &rcMain); + GetClientRect(hWnd, &rcClient); + + ClientHeight = rcClient.bottom; + ClientWidth = rcClient.right; + + if (ClientWidth == 0) // Minimized + return; + + OutputBoxHeight = ClientHeight - SplitPos - InputBoxHeight - SplitBarHeight - SplitBarHeight; + + MoveWindow(hwndMon,2, 0, ClientWidth-4, SplitPos, TRUE); + MoveWindow(hwndOutput,2, SplitPos+SplitBarHeight, ClientWidth-4, OutputBoxHeight, TRUE); + MoveWindow(hwndInput,2, ClientHeight-InputBoxHeight-2, ClientWidth-4, InputBoxHeight, TRUE); + MoveWindow(hwndSplit,0, SplitPos, ClientWidth, SplitBarHeight, TRUE); + + GetClientRect(hwndOutput, &rcClient); + + ClientHeight = rcClient.bottom; + ClientWidth = rcClient.right; + + if (ClientWidth > 16) + maxlinelen = ClientWidth/OutputData.CharWidth - 1; + + InvalidateRect(hWnd, NULL, TRUE); +} + +void CopyRichTextToClipboard(HWND hWnd) +{ + int len=0; + HGLOBAL hMem; + char * ptr; + + // Copy Rich Text to Clipboard + + len = SendMessage(hwndOutput, WM_GETTEXTLENGTH, 0, 0); + + hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, len + 1); + + if (hMem != 0) + { + ptr=GlobalLock(hMem); + + if (OpenClipboard(MainWnd)) + { + len = SendMessage(hwndOutput, WM_GETTEXT , len, (LPARAM)ptr); + + GlobalUnlock(hMem); + EmptyClipboard(); + SetClipboardData(CF_TEXT,hMem); + CloseClipboard(); + } + } + else + GlobalFree(hMem); +} + + +void CopyListToClipboard(HWND hWnd) +{ + int i,n, len=0; + HGLOBAL hMem; + char * ptr; + // + // Copy List Box to clipboard + // + + n = SendMessage(hWnd, LB_GETCOUNT, 0, 0); + + for (i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPQTerminal.vcxproj b/BPQTerminal.vcxproj new file mode 100644 index 0000000..865304b --- /dev/null +++ b/BPQTerminal.vcxproj @@ -0,0 +1,154 @@ + + + + + Debug + Win32 + + + Relase Static + Win32 + + + Release + Win32 + + + + 18.0 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8} + Win32Proj + + + + Application + v145 + + + Application + v145 + + + Application + v145 + + + + + + + + + + + + + + + + <_ProjectFileVersion>18.0.12106.202 + + + Debug\ + $(Configuration)\ + true + true + + + Release\ + Release\ + true + true + + + $(Configuration)\ + $(Configuration)\ + false + true + + + + Disabled + ./;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + true + Level3 + EditAndContinue + 4244;%(DisableSpecificWarnings) + + + S:\DEV\Source\BPQ32\cInclude;%(AdditionalIncludeDirectories) + + + Win32Bits\bpq32.lib;htmlhelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQTerminal.exe + c:\bpq32\BPQTerminal.exe.manifest + true + Windows + MachineX86 + + + + + ./;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + + Level3 + ProgramDatabase + 4244;%(DisableSpecificWarnings) + + + S:\DEV\Source\BPQ32\Include;%(AdditionalIncludeDirectories) + + + Win32Bits\bpq32.lib;htmlhelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQTerminal.exe + c:\bpq32\BPQTerminal.exe.manifest + false + Windows + + true + MachineX86 + + + + + ..\Commonsource;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + MultiThreaded + + Level3 + ProgramDatabase + 4244;%(DisableSpecificWarnings) + + + S:\DEV\Source\BPQ32\Include;%(AdditionalIncludeDirectories) + + + ..\lib\bpq32.lib;htmlhelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\BPQTerminal.exe + c:\bpq32\BPQTerminal.exe.manifest + false + true + c:\DevProgs\bpq32\BPQTerminal.map + Windows + + true + MachineX86 + + + + + + + + + + + + \ No newline at end of file diff --git a/BPQWinAPP.c b/BPQWinAPP.c index e3e8f1d..d70ef68 100644 --- a/BPQWinAPP.c +++ b/BPQWinAPP.c @@ -80,22 +80,26 @@ VOID WriteMiniDump() #endif } -SYMBOL_INFO * symbol; + HANDLE process; -void printStack(void) +void printStack() { -#ifdef WIN32 -//#ifdef _DEBUG // So we can use on 98/2K - - unsigned int i; - void * stack[ 100 ]; + unsigned int i, n; + void * stack[ 100 ]; unsigned short frames; DWORD dwDisplacement; IMAGEHLP_LINE64 line; char * fptr; - Debugprintf("Stack Backtrace"); + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; + + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + + Debugprintf("Stack Backtrace\r\n"); process = GetCurrentProcess(); @@ -106,42 +110,24 @@ void printStack(void) for( i = 0; i < frames; i++ ) { - SymGetLineFromAddr64(process, (DWORD64)stack[i], &dwDisplacement, &line); - SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol ); - - fptr = line.FileName + (int)strlen(line.FileName); // remove path - while (*fptr != '\\' && *fptr != '/') - fptr--; - - fptr++; - + n = SymGetLineFromAddr64(process, (DWORD64)stack[i], &dwDisplacement, &line); + n = SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol ); - Debugprintf( "%i: %s - %s Line %d Addr %p", frames - i - 1, symbol->Name, fptr, line.LineNumber, symbol->Address ); - } + if (line.FileName) + { + fptr = line.FileName + (int)strlen(line.FileName); // remove path + while (*fptr != '\\' && *fptr != '/') + fptr--; - free(symbol); + fptr++; -//#endif -#endif -} - -int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep) -{ - Debugprintf("in filter."); - printStack(); - if (code == EXCEPTION_ACCESS_VIOLATION) - { - Debugprintf("caught AV as expected."); - return EXCEPTION_EXECUTE_HANDLER; - } - else - { - Debugprintf("didn't catch AV, unexpected."); - return EXCEPTION_CONTINUE_SEARCH; - } + Debugprintf("%i: %s - %s Line %d Addr %p", frames - i - 1, symbol->Name, fptr, line.LineNumber, symbol->Address ); + } + } } +int inErrorhandling = 0; LONG WINAPI UnhandledExcepFilter(PEXCEPTION_POINTERS pExcepPointers) { @@ -149,27 +135,58 @@ LONG WINAPI UnhandledExcepFilter(PEXCEPTION_POINTERS pExcepPointers) IMAGEHLP_LINE64 line; char * fptr; + + time_t T; + struct tm * tm; + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; + + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + + + T = time(NULL); + tm = gmtime(&T); + + if (inErrorhandling) + { + MessageBox(NULL,"Program Error in error handler - program closing. See Debug Log for details","BPQ32",MB_ICONSTOP); + + exit(0); + } + + inErrorhandling = 1; + if(pExcepPointers->ExceptionRecord->ExceptionCode == DBG_PRINTEXCEPTION_C) return EXCEPTION_CONTINUE_EXECUTION; SymFromAddr( process, ((DWORD)pExcepPointers->ExceptionRecord->ExceptionAddress), 0, symbol ); - Debugprintf("Program error trapped\r\n"); + Debugprintf("\r\n\r\nProgram error trapped at %02d:%02d:%02d\r\n", tm->tm_hour, tm->tm_min, tm->tm_sec); SymGetLineFromAddr64(process, (DWORD)pExcepPointers->ExceptionRecord->ExceptionAddress, &dwDisplacement, &line); - fptr = line.FileName + (int)strlen(line.FileName); // remove path - while (*fptr != '\\' && *fptr != '/') - fptr--; + + if (line.FileName) + { + fptr = line.FileName + (int)strlen(line.FileName); // remove path + while (*fptr != '\\' && *fptr != '/') + fptr--; - fptr++; + fptr++; - Debugprintf("In Procedure %s - %s Line %d Addr %p\r\n", symbol->Name, fptr, line.LineNumber, symbol->Address ); + Debugprintf("In Procedure %s - %s Line %d Addr %p\r\n", symbol->Name, fptr, line.LineNumber, symbol->Address ); + } + printStack(); + CloseDebugLog(); + + MessageBox(NULL,"Program Error - program closing. See Debug Log for details","BPQ32",MB_ICONSTOP); RealCloseAllPrograms(); Sleep(1000); - CloseDebugLog(); + exit(0); } @@ -195,10 +212,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi SymSetOptions(SYMOPT_LOAD_LINES); SymInitialize( process, NULL, TRUE ); - symbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 ); - symbol->MaxNameLen = 255; - symbol->SizeOfStruct = sizeof( SYMBOL_INFO ); - AddVectoredExceptionHandler(1, UnhandledExcepFilter); if (_stricmp(lpCmdLine, "Wait") == 0) // If AutoRestart then Delay 5 Secs diff --git a/BPQWinAPP.vcproj b/BPQWinAPP.vcproj index 06a0744..6c69913 100644 --- a/BPQWinAPP.vcproj +++ b/BPQWinAPP.vcproj @@ -2,7 +2,7 @@ @@ -143,8 +143,8 @@ /> + + + + + + + Debug + Win32 + + + Release + Win32 + + + + 18.0 + BPQ32.EXE + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81} + BPQWinAPP + 10.0 + + + + Application + v145 + false + + + Application + v145 + false + + + + + + + + + + + + + + + <_ProjectFileVersion>18.0.12106.202 + + + c:\DevProgs\BPQ32VS2026\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + false + + + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ + true + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/BPQWinAPP.tlb + + + + Disabled + C:\Users\johnw\OneDrive\Dev\Source\bpq32\Commonsource;C:\Users\johnw\OneDrive\Dev\Source\bpq32\CInclude;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDebug + .\Debug/BPQWinAPP.pch + $(IntDir) + $(IntDir) + $(IntDir) + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0809 + + + Win32bits\bpq32.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\BPQ32VS2026\bpq32.exe + true + true + .\Debug/bpq32.pdb + true + Windows + 0 + 0 + MachineX86 + + + true + .\Debug/BPQWinAPP.bsc + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/BPQWinAPP.tlb + + + + MinSpace + Default + C:\Users\johnw\OneDrive\Dev\Source\bpq32\Commonsource;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + C:\msdev2005\Intermed\Release/BPQWinAPP.pch + $(IntDir) + $(IntDir) + $(IntDir) + Level3 + true + EditAndContinue + + + NDEBUG;%(PreprocessorDefinitions) + 0x0809 + + + Win32bits\bpq32.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\bpq32\bpq32.exe + true + true + c:\DevProgs\bpq32\bpq32app.pdb + true + c:\DevProgs\bpq32\bpq32app.map + Windows + MachineX86 + + + true + .\Release/BPQWinAPP.bsc + + + + + Disabled + + + + + + + + + \ No newline at end of file diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000..4c6b206 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,86 @@ + + + + + + +Building LinBPQ from source + + + +BPQ Home   BPQ32 Home + +

Building LinBPQ from source.

+ +

+I provide binaries for Linux on 32 and 64 bit ARM and Intel x86 processors but if you want to run on other Unix like operating systems you can build it from source. You will need to install some dependencies and download the source. The instructions below are for a Debian like system using apt as its package manager - you may need to alter the command for other systems. +

+To download dependencies run: +
+

sudo apt install build-essential git libminiupnpc-dev libconfig-dev libpcap-dev zlib1g-dev  libcap2-bin libjansson-dev libpaho-mqtt-dev libbacktrace-dev
+
+

+Some distributions may not include libpaho-mqtt-dev and/or libbacktrace-dev. The former is used for the MQTT reporting interface. If you don't need that you can build without MQTT support. If you do you can build libpaho-mqtt-dev from source: +

+sudo apt install cmake
+git clone https://github.com/eclipse/paho.mqtt.c.git
+cd paho.mqtt.c
+cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_STATIC=ON -DPAHO_WITH_SSL=OFF -DPAHO_HIGH_PERFORMANCE=ON -DCMAKE_INSTALL_PREFIX=../install
+cd build
+cmake --build . --target install
+
+You need to copy libpaho-mqtt3a.a to your lib directory.
+The commands below work on my ARM and Intel systems but you may need to change if your lib is in a different place.
+
+sudo cp src/libpaho-mqtt3a.a /usr/lib/arm-linux-gnueabihf 
+or
+sudo cp src/libpaho-mqtt3a.a /usr/lib/i386-linux-gnu/
+

+If libbacktrace isn't available you can build it: +

+git clone https://github.com/ianlancetaylor/libbacktrace.git
+cd libbacktrace 
+mkdir build 
+cd build 
+../configure 
+make
+sudo make install
+

+ +To download the LinBPQ source run: +

+git clone https://github.com/g8bpq/linbpq.git
+cd linbpq
+

+To build with MQTT support enter: +

+make
+
+

+To build without MQTT support enter: +

+make nomqtt
+

+This should create linbpq in the current directory. +

+

+ + +John Wiseman G8BPQ
+April 2025
+Updated September 2026
+ + + \ No newline at end of file diff --git a/Bpq32.c b/Bpq32.c index d7370c1..5652e1f 100644 --- a/Bpq32.c +++ b/Bpq32.c @@ -1340,6 +1340,11 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses // More fixes for timer problem introduced in v33 (38) // Changes to INP3 poison reverse and alias reporting (39) // L4 Connect Ack now sent via routing table (39) +// Debug info is now written to a log file rather than syslog (Linux) or Debugview (Windows) (40) +// Backtrace now includes source file info and is written to Debug log (40) +// Add Telnet Server config option "noWebSocks" to disable use of Websocks for Terminal and Driver windows (41) +// Log outpur from running disconnect script (41) +// Prevent Rigcontrol scan from changing frequency when PTT is active (41) #define CKernel @@ -1723,7 +1728,7 @@ int VECTORLENGTH = sizeof (struct _BPQVECSTRUC); int FirstEntry = 1; BOOL CloseLast = TRUE; // If the user started BPQ32.exe, don't close it when other programs close -BOOL Closing = FALSE; // Set if Close All called - prevents respawning bpq32.exe +extern BOOL Closing = FALSE; // Set if Close All called - prevents respawning bpq32.exe BOOL BPQ32_EXE; // Set if Process is running BPQ32.exe. Not initialised. // Used to Kill surplus BPQ32.exe processes @@ -1841,7 +1846,6 @@ void LoadToolHelperRoutines() { HINSTANCE ExtDriver=0; int err; - char msg[100]; ExtDriver=LoadLibrary("kernel32.dll"); @@ -2125,6 +2129,10 @@ VOID MonitorTimerThread(int x) VOID WritetoTraceSupport(struct TNCINFO * TNC, char * Msg, int Len); +VOID * _Q_REM_NP(VOID *PQ, char * File, int Line); + +#define Q_REM_NP(s) _Q_REM_NP(s, __FILE__, __LINE__) + void Semaphored100msCode() { // code that doesn't need to run every tick - run every 100 mS @@ -2156,9 +2164,9 @@ void Semaphored100msCode() while (WritetoConsoleQ) { - UINT * Buffer = Q_REM(&WritetoConsoleQ); + UINT * Buffer = Q_REM_NP(&WritetoConsoleQ); WritetoConsoleSupport((char *)&Buffer[2]); - RelBuff(Buffer); + free(Buffer); } @@ -2753,9 +2761,6 @@ Tell_Sessions() BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved) { - DWORD n; - char buf[350]; - int i; unsigned int ProcessID; @@ -3120,7 +3125,6 @@ SkipInit: { if (PIDArray[i] == ProcessID) { - char Log[80]; hWndArray[i] = 0; DeleteMenu(trayMenu,TRAYBASEID+i,MF_BYCOMMAND); } @@ -3567,8 +3571,6 @@ HANDLE OpenConfigFile(char *fn) UCHAR Value[MAX_PATH]; FILETIME LastWriteTime; SYSTEMTIME Time; - char Msg[256]; - // If no directory, use current if (BPQDirectory[0] == 0) @@ -5546,24 +5548,23 @@ DllExport int APIENTRY WritetoConsole(char * buff) DllExport VOID * APIENTRY GetBuff(); +int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF); + int WritetoConsoleLocal(char * buff) { int len=strlen(buff); UINT * buffptr; - if (Semaphore.Flag == 0) - return WritetoConsoleSupport(buff); - - buffptr = GetBuff(); + buffptr = (UINT *)zalloc(512); if (buffptr == 0) // No buffers, so send direct - return WritetoConsoleSupport(buff); + return 0; if (len > 300) len = 300; memcpy(&buffptr[2], buff, len + 1); - C_Q_ADD(&WritetoConsoleQ, buffptr); + C_Q_ADD_NP(&WritetoConsoleQ, buffptr); return 0; } @@ -6337,7 +6338,6 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile) { if (len > 76) { - len += sprintf(&RegLine[len], "\\\r\n", RegLine); strcat(RegLine, "\\\r\n"); WriteFile(hFile, RegLine, len, &written, NULL); strcpy(RegLine, " "); diff --git a/CBPQ32.sln b/CBPQ32.sln index eabbb30..d9b2153 100644 --- a/CBPQ32.sln +++ b/CBPQ32.sln @@ -13,36 +13,65 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CBPQ32", "CBPQ32.vcproj", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQChat", "BPQChat.vcproj", "{2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTerminal", "BPQTerminal.vcproj", "{04F2B9AD-4369-49EA-82EC-3C701C97C6D8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTermTCP", "BPQTermTCP.vcproj", "{99625C77-CABA-469A-A5A7-ECB4EE354225}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Relase Static|Win32 = Relase Static|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.ActiveCfg = Debug|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.Build.0 = Debug|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.ActiveCfg = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.Build.0 = Release|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.ActiveCfg = Release|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.Build.0 = Release|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.ActiveCfg = Debug|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.Build.0 = Debug|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.ActiveCfg = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.Build.0 = Release|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.ActiveCfg = Release|Win32 {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.Build.0 = Release|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.ActiveCfg = Debug|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.Build.0 = Debug|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.ActiveCfg = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.Build.0 = Release|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.ActiveCfg = Release|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.Build.0 = Release|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.ActiveCfg = Debug|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.Build.0 = Debug|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.ActiveCfg = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.Build.0 = Release|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.ActiveCfg = Release|Win32 {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.Build.0 = Release|Win32 {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.ActiveCfg = Debug|Win32 {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.Build.0 = Debug|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.ActiveCfg = Release|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.Build.0 = Release|Win32 {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.ActiveCfg = Release|Win32 {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.Build.0 = Release|Win32 {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.ActiveCfg = Debug|Win32 {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.Build.0 = Debug|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.ActiveCfg = Release|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.Build.0 = Release|Win32 {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.ActiveCfg = Release|Win32 {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.Build.0 = Release|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.ActiveCfg = Debug|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.Build.0 = Debug|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.ActiveCfg = Relase Static|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.Build.0 = Relase Static|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.ActiveCfg = Release|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.Build.0 = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.ActiveCfg = Debug|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.Build.0 = Debug|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.ActiveCfg = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.Build.0 = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.ActiveCfg = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CBPQ32.vcproj b/CBPQ32.vcproj index e211ac4..6a48af8 100644 --- a/CBPQ32.vcproj +++ b/CBPQ32.vcproj @@ -2,7 +2,7 @@ - + Debug @@ -11,22 +11,24 @@ + 18.0 + BPQ32.DLL {8EFA1E59-8654-4A23-8102-AA77A074D57C} CBPQ32 Win32Proj - 10.0.17763.0 + 10.0 DynamicLibrary - v141 + v145 NotSet false DynamicLibrary - v141 - MultiByte + v145 + NotSet @@ -40,16 +42,17 @@ - <_ProjectFileVersion>15.0.28127.55 + <_ProjectFileVersion>18.0.12106.202 - $(SolutionDir)$(Configuration)\ - C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(Configuration)\ + c:\DevProgs\BPQ32VS2026\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ true + bpq32 - $(SolutionDir)$(Configuration)\ - C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(Configuration)\ + Win32bits\ + C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\ false @@ -60,8 +63,8 @@ Disabled - ..\CInclude;..\CommonSource;..\CKernel;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;BPQ32_EXPORTS;MDIKERNEL;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + ..\BPQSource\Win32bits;..\BPQSource;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;BPQ32_EXPORTS;MDIKERNEL;_USE_32BIT_TIME_T;BPQ32;NOMQTT;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -74,11 +77,11 @@ /section:_BPQDATA,srw %(AdditionalOptions) - WS2_32.Lib;winmm.lib;DbgHelp.lib;comctl32.lib;Iphlpapi.lib;setupapi.lib;..\lib\libconfig.lib;miniupnpc.lib;zlibstat.lib;%(AdditionalDependencies) - c:\DevProgs\BPQ32\bpq32.dll + WS2_32.Lib;winmm.lib;DbgHelp.lib;comctl32.lib;Iphlpapi.lib;setupapi.lib;C:\OneDrive\Dev\Source\bpq32\libconfig\Release\libconfig.LIB;C:\Users\johnw\Downloads\upnpc-exe-win32-20220515\miniupnpc.lib;zlibstat.lib;%(AdditionalDependencies) + c:\DevProgs\BPQ32VS2026\bpq32.dll false LIBCMTD.lib;%(IgnoreSpecificDefaultLibraries) - ..\CommonSource\bpq32.def + ..\BPQSource\bpq32.def true true c:\DevProgs\BPQ32\bpqdev.map @@ -89,7 +92,7 @@ false 0x42000000 - ..\lib\bpq32.lib + Win32bits\bpq32.lib MachineX86 false @@ -114,8 +117,8 @@ /D "MDIKERNEL" %(AdditionalOptions) Disabled false - ..\CInclude;..\CommonSource;..\CKernel;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;BPQ32_EXPORTS;MDIKERNEL;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + ..\BPQSource\Win32bits;..\BPQSource;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;BPQ32_EXPORTS;MDIKERNEL;_USE_32BIT_TIME_T;NOMQTT;%(PreprocessorDefinitions) MultiThreaded All @@ -125,9 +128,9 @@ /section:_BPQDATA,srw %(AdditionalOptions) - WS2_32.Lib;winmm.lib;DbgHelp.lib;comctl32.lib;setupapi.lib;..\lib\libconfig.lib;miniupnpc.lib;zlibstat.lib;%(AdditionalDependencies) - C:\DevProgs\BPQ32\bpq32.dll - ..\CommonSource\bpq32.def + WS2_32.Lib;winmm.lib;comctl32.lib;setupapi.lib;Win32bits\libconfig.lib;miniupnpc.lib;zlibstat.lib;DbgHelp.lib;%(AdditionalDependencies) + c:\DevProgs\BPQ32\bpq32.dll + ..\BPQSource\bpq32.def true c:\DevProgs\BPQ32\bpq32.pdb true @@ -149,14 +152,17 @@ + + + @@ -167,14 +173,23 @@ - - + + + + + + + + + + + @@ -189,8 +204,29 @@ + + CompileAsC + + + + + + + + + + + + + + + + + + + @@ -214,7 +250,7 @@ - + diff --git a/CBPQ322026.sln b/CBPQ322026.sln new file mode 100644 index 0000000..ad64694 --- /dev/null +++ b/CBPQ322026.sln @@ -0,0 +1,84 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 18 +VisualStudioVersion = 18.10.12201.205 stable +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQ32.EXE", "BPQWinAPP.vcxproj", "{005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinmorControl", "WinmorControl.vcxproj", "{005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQMail", "BPQMail.vcxproj", "{3766AA10-C777-4ED8-A83D-F1452DE9B665}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LinBPQ", "MailNode.vcxproj", "{3766AA10-C777-4ED8-A83D-F1452DE9B666}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQ32.DLL", "CBPQ32.vcxproj", "{8EFA1E59-8654-4A23-8102-AA77A074D57C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQChat", "BPQChat.vcxproj", "{2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTerminal", "BPQTerminal.vcxproj", "{04F2B9AD-4369-49EA-82EC-3C701C97C6D8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BPQTermTCP", "BPQTermTCP.vcxproj", "{99625C77-CABA-469A-A5A7-ECB4EE354225}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Relase Static|Win32 = Relase Static|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.ActiveCfg = Debug|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Debug|Win32.Build.0 = Debug|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.ActiveCfg = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Relase Static|Win32.Build.0 = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.ActiveCfg = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B81}.Release|Win32.Build.0 = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.ActiveCfg = Debug|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Debug|Win32.Build.0 = Debug|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.ActiveCfg = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Relase Static|Win32.Build.0 = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.ActiveCfg = Release|Win32 + {005A91EA-3A00-4FB4-ADD9-EB78DBFA2B82}.Release|Win32.Build.0 = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.ActiveCfg = Debug|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Debug|Win32.Build.0 = Debug|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.ActiveCfg = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Relase Static|Win32.Build.0 = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.ActiveCfg = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B665}.Release|Win32.Build.0 = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.ActiveCfg = Debug|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Debug|Win32.Build.0 = Debug|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.ActiveCfg = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Relase Static|Win32.Build.0 = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.ActiveCfg = Release|Win32 + {3766AA10-C777-4ED8-A83D-F1452DE9B666}.Release|Win32.Build.0 = Release|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.ActiveCfg = Debug|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Debug|Win32.Build.0 = Debug|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.ActiveCfg = Release|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Relase Static|Win32.Build.0 = Release|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.ActiveCfg = Release|Win32 + {8EFA1E59-8654-4A23-8102-AA77A074D57C}.Release|Win32.Build.0 = Release|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.ActiveCfg = Debug|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Debug|Win32.Build.0 = Debug|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.ActiveCfg = Release|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Relase Static|Win32.Build.0 = Release|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.ActiveCfg = Release|Win32 + {2BDD2C8A-2B4A-496C-A2EA-6B49AA0670B1}.Release|Win32.Build.0 = Release|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.ActiveCfg = Debug|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Debug|Win32.Build.0 = Debug|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.ActiveCfg = Relase Static|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Relase Static|Win32.Build.0 = Relase Static|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.ActiveCfg = Release|Win32 + {04F2B9AD-4369-49EA-82EC-3C701C97C6D8}.Release|Win32.Build.0 = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.ActiveCfg = Debug|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Debug|Win32.Build.0 = Debug|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.ActiveCfg = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Relase Static|Win32.Build.0 = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.ActiveCfg = Release|Win32 + {99625C77-CABA-469A-A5A7-ECB4EE354225}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FB815A29-A2DD-470A-B0AF-7188AA0F4C7F} + EndGlobalSection +EndGlobal diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9dcfb88 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.18) + +project(LinBPQ) + +# Our Project + +set(CMAKE_C_FLAGS "-DLINBPQ -g -fcommon -fasynchronous-unwind-tables") + +set(SOURCE_FILES +pngwtran.c pngrtran.c pngset.c pngrio.c pngwio.c pngtrans.c pngrutil.c pngwutil.c + pngread.c pngwrite.c png.c pngerror.c pngget.c pngmem.c APRSIconData.c AISCommon.c + upnp.c APRSStdPages.c HSMODEM.c WinRPR.c KISSHF.c TNCEmulators.c bpqhdlc.c SerialPort.c + adif.c WebMail.c utf8Routines.c VARA.c LzFind.c Alloc.c LzmaDec.c LzmaEnc.c LzmaLib.c + Multicast.c ARDOP.c IPCode.c FLDigi.c linether.c CMSAuth.c APRSCode.c BPQtoAGW.c KAMPactor.c + AEAPactor.c HALDriver.c MULTIPSK.c BBSHTMLConfig.c ChatHTMLConfig.c BBSUtilities.c bpqaxip.c + BPQINP3.c BPQNRR.c cMain.c Cmd.c CommonCode.c HTMLCommonCode.c compatbits.c config.c datadefs.c + FBBRoutines.c HFCommon.c Housekeeping.c HTTPcode.c kiss.c L2Code.c L3Code.c L4Code.c lzhuf32.c + MailCommands.c MailDataDefs.c LinBPQ.c MailRouting.c MailTCP.c MBLRoutines.c md5.c Moncode.c + NNTPRoutines.c RigControl.c TelnetV6.c WINMOR.c TNCCode.c UZ7HODrv.c WPRoutines.c + SCSTrackeMulti.c SCSPactor.c SCSTracker.c HanksRT.c UIRoutines.c AGWAPI.c AGWMoncode.c + DRATS.c FreeDATA.c base64.c Events.c nodeapi.c mailapi.c mqtt.c RHP.c NETROMTCP.c) + +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) + diff --git a/Cmd.c b/Cmd.c index b7faab9..a4d8c02 100644 --- a/Cmd.c +++ b/Cmd.c @@ -4326,6 +4326,45 @@ VOID NRRCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct C return; } +VOID SendNRPing(struct DEST_LIST * DEST, TRANSPORTENTRY * Session); + +VOID NRPING(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, struct CMDX * UserCMD) +{ + // Send Paula's NCMP PING command = Netrom Ping + + char * ptr, *Context; + struct DEST_LIST * Dest = DESTS; + int count = MAXDESTS; + + ptr = strtok_s(CmdTail, " ", &Context); + + if (ptr) + { + UCHAR AXCall[8]; + int count; + + ConvToAX25(ptr, AXCall); + strcat(ptr, " "); + + for (count = 0; count < MAXDESTS; count++) + { + if (memcmp(Dest->DEST_ALIAS, ptr, 6) == 0 || CompareCalls(Dest->DEST_CALL, AXCall)) + { + SendNRPing(Dest, Session); + memcpy(Bufferptr, OKMSG, 3); + Bufferptr += 3; + SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); + + return; + } + Dest++; + } + } + Bufferptr = Cmdprintf(Session, Bufferptr, "Not found\r"); + SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); + return; +} + int CHECKINTERLOCK(struct PORTCONTROL * OURPORT) { // See if any Interlocked ports are Busy @@ -4884,6 +4923,7 @@ struct CMDX COMMANDS[] = "AXMHEARD ",3,AXMHEARD,0, "TELSTATUS ",3,SHOWTELNET,0, "NRR ",1,NRRCMD,0, + "NPING ",1,NRPING,0, "PING ",2,PING,0, "AGWSTATUS ",3,SHOWAGW,0, "ARP ",3,SHOWARP,0, diff --git a/CommonCode.c b/CommonCode.c index 2708e79..3559135 100644 --- a/CommonCode.c +++ b/CommonCode.c @@ -3829,6 +3829,7 @@ int __sync_lock_test_and_set(int * ptr, int val) #define GetSemaphore(Semaphore,ID) _GetSemaphore(Semaphore, ID, __FILE__, __LINE__) +BOOL Closing; void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line) { @@ -3843,7 +3844,7 @@ void _GetSemaphore(struct SEM * Semaphore, int ID, char * File, int Line) loop1: - while (Semaphore->Flag != 0) + while (Semaphore->Flag != 0 && Closing == 0) { Sleep(10); } @@ -3904,41 +3905,54 @@ USHORT WINAPI RtlCaptureStackBackTrace( */ #endif -void printStack(void) +void printStack() { -#ifdef WIN32 -#ifdef _DEBUG // So we can use on 98/2K - - unsigned int i; - void * stack[ 100 ]; +#ifdef BPQ32 + unsigned int i, n; + void * stack[ 100 ]; unsigned short frames; - SYMBOL_INFO * symbol; - HANDLE process; - Debugprintf("Stack Backtrace"); + DWORD dwDisplacement; + IMAGEHLP_LINE64 line; + char * fptr; + HANDLE process; + + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; + + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + + Debugprintf("Stack Backtrace\r\n"); process = GetCurrentProcess(); + SymSetOptions(SYMOPT_LOAD_LINES); SymInitialize( process, NULL, TRUE ); - frames = RtlCaptureStackBackTrace( 0, 60, stack, NULL ); - symbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 ); - symbol->MaxNameLen = 255; - symbol->SizeOfStruct = sizeof( SYMBOL_INFO ); + frames = RtlCaptureStackBackTrace(0, 60, stack, NULL ); for( i = 0; i < frames; i++ ) { - SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol ); + n = SymGetLineFromAddr64(process, (DWORD64)stack[i], &dwDisplacement, &line); + n = SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol ); - Debugprintf( "%i: %s - %p", frames - i - 1, symbol->Name, symbol->Address ); - } + if (line.FileName) + { + fptr = line.FileName + (int)strlen(line.FileName); // remove path + while (*fptr != '\\' && *fptr != '/') + fptr--; - free(symbol); + fptr++; -#endif + Debugprintf("%i: %s - %s Line %d Addr %p", frames - i - 1, symbol->Name, fptr, line.LineNumber, symbol->Address ); + } + } #endif } + pthread_t ResolveUpdateThreadId = 0; char NodeMapServer[80] = "update.g8bpq.net"; diff --git a/DragSize.cur b/DragSize.cur new file mode 100644 index 0000000000000000000000000000000000000000..a33158a70d263cd270caac4bcabe80a5f2bd732c GIT binary patch literal 326 zcma)$F%AMT3