master 24.14
g8bpq 2 years ago
parent 27fd28f2e4
commit 318dbc55bf

Binary file not shown.

@ -5246,6 +5246,7 @@ int DecodeAPRSPayload(char * Payload, struct STATIONRECORD * Station)
DecodeLocationString(Payload + 18, Object);
Object->TimeLastUpdated = time(NULL);
Object->LastPort = Station->LastPort;
Station->Object = Object;
return 0;

@ -419,7 +419,7 @@ void ConvertTitletoUTF8(char * Title, char * UTF8Title, int Len)
iconv_t * icu = NULL;
if (icu == NULL)
icu = iconv_open("UTF-8", "CP1252");
icu = iconv_open("UTF-8//IGNORE", "CP1252");
iconv(icu, NULL, NULL, NULL, NULL); // Reset State Machine
iconv(icu, &Title, &len, (char ** __restrict__)&UTF8Title, &left);

@ -1191,6 +1191,9 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Fix sending UI frames on SCSPACTOR (11)
// Dont allow ports that can't set digi'ed bit in callsigns to digipeat. (11)
// Add SDRAngel rig control (11)
// Add option to specify config and data directories on linbpq (12)
// Allow zero resptime (send RR immediately) (13)
// Fix corruptions in Webmail, eg in displaying 7+ files (13)
#define CKernel
@ -1416,6 +1419,8 @@ extern char MAPCOMMENT[]; // Locator for Reporting - may be Maidenhead or LAT:L
extern char LOC[7]; // Maidenhead Locator for Reporting
extern char ReportDest[7];
extern UCHAR ConfigDirectory[260];
extern uint64_t timeLoadedMS;
VOID __cdecl Debugprintf(const char * format, ...);
@ -3282,6 +3287,8 @@ if (_winver < 0x0600)
RegCloseKey(hKey);
}
strcpy(ConfigDirectory, BPQDirectory);
if (LogDirectory[0] == 0)
strcpy(LogDirectory, BPQDirectory);

@ -3676,6 +3676,13 @@ VOID MHCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * CM
ptr = strtok_s(CmdTail, " ", &Context);
if (ptr == NULL || ptr[0] == 0)
{
Bufferptr = Cmdprintf(Session, Bufferptr, "Port Number needed eg MH 1\r");
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
return;
}
if (ptr)
Port = atoi(ptr);
@ -4137,7 +4144,7 @@ VOID ATTACHCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX
if (OtherTNC == TNC)
continue;
if (rxInterlock == OtherTNC->RXRadio || txInterlock == OtherTNC->TXRadio) // Same Group
if (rxInterlock && rxInterlock == OtherTNC->RXRadio || txInterlock && txInterlock == OtherTNC->TXRadio) // Same Group
{
int n;

@ -71,6 +71,7 @@ void WriteConnectLog(char * fromCall, char * toCall, UCHAR * Mode);
void SendDataToPktMap(char *Msg);
extern BOOL LogAllConnects;
extern BOOL M0LTEMap;
extern VOID * ENDBUFFERPOOL;
@ -2364,8 +2365,8 @@ BOOL WriteCOMBlock(HANDLE fd, char * Block, int BytesToWrite)
Err = GetCommModemStatus(fd, &Mask);
// if ((Mask & MS_CTS_ON) == 0) // trap com0com other end not open
// return TRUE;
if ((Mask & MS_CTS_ON) == 0) // trap com0com other end not open
return TRUE;
fWriteStat = WriteFile(fd, Block, BytesToWrite,
&BytesWritten, NULL );
@ -3331,7 +3332,10 @@ VOID SendLocation()
SendReportMsg((char *)&AXMSG.DEST, Len + 16);
SendDataToPktMap("");
printf("M0LTEMap %d\n", M0LTEMap);
if (M0LTEMap)
SendDataToPktMap("");
return;
@ -4877,20 +4881,21 @@ static char HeaderTemplate[] = "POST %s HTTP/1.1\r\n"
"Content-Length: %d\r\n"
//r\nUser-Agent: BPQ32(G8BPQ)\r\n"
// "Expect: 100-continue\r\n"
"\r\n{%s}";
"\r\n";
VOID SendWebRequest(SOCKET sock, char * Host, char * Request, char * Params, int Len, char * Return)
{
int InputLen = 0;
int inptr = 0;
char Buffer[2048];
char Header[2048];
char Buffer[4096];
char Header[256];
char * ptr, * ptr1;
int Sent;
sprintf(Header, HeaderTemplate, Request, Host, 80, Len + 2, Params);
sprintf(Header, HeaderTemplate, Request, Host, 80, Len, Params);
Sent = send(sock, Header, (int)strlen(Header), 0);
Sent = send(sock, Params, (int)strlen(Params), 0);
if (Sent == -1)
{
@ -4901,7 +4906,7 @@ VOID SendWebRequest(SOCKET sock, char * Host, char * Request, char * Params, int
while (InputLen != -1)
{
InputLen = recv(sock, &Buffer[inptr], 2048 - inptr, 0);
InputLen = recv(sock, &Buffer[inptr], 4096 - inptr, 0);
if (InputLen == -1 || InputLen == 0)
{
@ -4977,18 +4982,46 @@ VOID SendWebRequest(SOCKET sock, char * Host, char * Request, char * Params, int
//SendHTTPRequest(sock, "/account/exists", Message, Len, Response);
#include "kiss.h"
extern char MYALIASLOPPED[10];
extern int MasterPort[MAXBPQPORTS+1];
void SendDataToPktMap(char *Msg)
{
SOCKET sock;
char Return[256];
char Request[64];
char Params[16384];
char Params[50000];
struct PORTCONTROL * PORT = PORTTABLE;
struct PORTCONTROL * SAVEPORT;
struct ROUTE * Routes = NEIGHBOURS;
int MaxRoutes = MAXNEIGHBOURS;
int PortNo;
int Active;
uint64_t Freq;
int Baud;
int Bitrate;
char * Mode;
char * Use;
char * Type;
char * Modulation;
char locked[] = " ! ";
int Percent = 0;
int Port = 0;
char Normcall[10];
char Copy[20];
char * ptr = Params;
printf("Sending to new map\n");
sprintf(Request, "/api/NodeData/%s", MYNODECALL);
// https://packetnodes.spots.radio/swagger/index.html
// This builds the request and sends it
// Minimum header seems to be
@ -4997,25 +5030,307 @@ void SendDataToPktMap(char *Msg)
// "location": {"locator": "IO68VL"},
// "software": {"name": "BPQ32","version": "6.0.24.3"},
ptr += sprintf(ptr, "\"nodeAlias\": \"%s\",\r\n", MYALIASLOPPED);
ptr += sprintf(ptr, "\"locator\": \"%s\",\r\n", LOCATOR);
ptr += sprintf(ptr, "{\"nodeAlias\": \"%s\",\r\n", MYALIASLOPPED);
if (strlen(LOCATOR) == 6)
ptr += sprintf(ptr, "\"location\": {\"locator\": \"%s\"},\r\n", LOCATOR);
else
{
// Lat Lon
double myLat, myLon;
char LocCopy[80];
char * context;
strcpy(LocCopy, LOCATOR);
myLat = atof(strtok_s(LocCopy, ",:; ", &context));
myLon = atof(context);
ptr += sprintf(ptr, "\"location\": {\"coords\": {\"lat\": %f, \"lon\": %f}},\r\n",
myLat, myLon);
}
#ifdef LINBPQ
ptr += sprintf(ptr, "\"software\": \"LinBPQ\",\"version\": \"%s\",\r\n", VersionString);
ptr += sprintf(ptr, "\"software\": {\"name\": \"LINBPQ\",\"version\": \"%s\"},\r\n", VersionString);
#else
ptr += sprintf(ptr, "\"software\": \"BPQ32\",\"version\": \"%s\",\r\n", VersionString);
ptr += sprintf(ptr, "\"software\": {\"name\": \"BPQ32\",\"version\": \"%s\"},\r\n", VersionString);
#endif
ptr += sprintf(ptr, "\"source\": \"ReportedByNode\",\r\n");
//Ports
ptr += sprintf(ptr, "\"ports\": [");
// Get active ports
// "contact": "string",
// "neighbours": [{"node": "G7TAJ","port": "30"}]
while (PORT)
{
PortNo = PORT->PORTNUMBER;
return;
if (PORT->Hide)
{
PORT = PORT->PORTPOINTER;
continue;
}
if (PORT->SendtoM0LTEMap == 0)
{
PORT = PORT->PORTPOINTER;
continue;
}
// Try to get port status - may not be possible with some
if (PORT->PortStopped)
{
PORT = PORT->PORTPOINTER;
continue;
}
Active = 0;
Freq = 0;
Baud = 0;
Mode = "ax.25";
Use = "";
Type = "RF";
Bitrate = 0;
Modulation = "FSK";
if (PORT->PORTTYPE == 0)
{
struct KISSINFO * KISS = (struct KISSINFO *)PORT;
NPASYINFO Port;
SAVEPORT = PORT;
if (KISS->FIRSTPORT && KISS->FIRSTPORT != KISS)
{
// Not first port on device
PORT = (struct PORTCONTROL *)KISS->FIRSTPORT;
Port = KISSInfo[PortNo];
}
Port = KISSInfo[PORT->PORTNUMBER];
if (Port)
{
// KISS like - see if connected
if (PORT->PORTIPADDR.s_addr || PORT->KISSSLAVE)
{
// KISS over UDP or TCP
if (PORT->KISSTCP)
{
if (Port->Connected)
Active = 1;
}
else
Active = 1; // UDP - Cant tell
}
else
if (Port->idComDev) // Serial port Open
Active = 1;
PORT = SAVEPORT;
}
}
else if (PORT->PORTTYPE == 14) // Loopback
Active = 0;
else if (PORT->PORTTYPE == 16) // External
{
if (PORT->PROTOCOL == 10) // 'HF' Port
{
struct TNCINFO * TNC = TNCInfo[PortNo];
struct AGWINFO * AGW;
if (TNC == NULL)
{
PORT = PORT->PORTPOINTER;
continue;
}
if (TNC->RIG)
Freq = TNC->RIG->RigFreq * 1000000;
switch (TNC->Hardware) // Hardware Type
{
case H_KAM:
case H_AEA:
case H_HAL:
case H_SERIAL:
// Serial
if (TNC->hDevice)
Active = 1;
break;
case H_SCS:
case H_TRK:
case H_WINRPR:
if (TNC->HostMode)
Active = 1;
break;
case H_UZ7HO:
if (TNCInfo[MasterPort[PortNo]]->CONNECTED)
Active = 1;
// Try to get mode and frequency
AGW = TNC->AGWInfo;
if (AGW && AGW->isQTSM)
{
if (AGW->ModemName[0])
{
char * ptr1, * ptr2, *Context;
strcpy(Copy, AGW->ModemName);
ptr1 = strtok_s(Copy, " ", & Context);
ptr2 = strtok_s(NULL, " ", & Context);
if (Context)
{
Modulation = Copy;
if (strstr(ptr1, "BPSK") || strstr(ptr1, "AFSK"))
{
Baud = Bitrate = atoi(Context);
}
else if (strstr(ptr1, "QPSK"))
{
Modulation = "QPSK";
Bitrate = atoi(Context);
Baud = Bitrate /2;
}
}
}
}
break;
case H_WINMOR:
case H_V4:
case H_MPSK:
case H_FLDIGI:
case H_UIARQ:
case H_ARDOP:
case H_VARA:
case H_KISSHF:
case H_FREEDATA:
// TCP
Mode = Modenames[TNC->Hardware];
if (TNC->CONNECTED)
Active = 1;
break;
case H_TELNET:
Active = 1;
Type = "Internet";
Mode = "";
}
}
else
{
// External but not HF - AXIP, BPQETHER VKISS, ??
struct _EXTPORTDATA * EXTPORT = (struct _EXTPORTDATA *)PORT;
Type = "Internet";
Active = 1;
}
}
if (Active)
{
ptr += sprintf(ptr, "{\"id\": \"%d\",\"linkType\": \"%s\","
"\"freq\": \"%lld\",\"mode\": \"%s\",\"modulation\": \"%s\","
"\"baud\": \"%d\",\"bitrate\": \"%d\",\"usage\": \"%s\",\"comment\": \"%s\"},\r\n",
PortNo, Type,
Freq, Mode, Modulation,
Baud, Bitrate, "Access", PORT->PORTDESCRIPTION);
}
PORT = PORT->PORTPOINTER;
}
ptr -= 3;
ptr += sprintf(ptr, "],\r\n");
// Neighbours
ptr += sprintf(ptr, "\"neighbours\": [\r\n");
while (MaxRoutes--)
{
if (Routes->NEIGHBOUR_CALL[0] != 0)
if (Routes->NEIGHBOUR_LINK && Routes->NEIGHBOUR_LINK->L2STATE >= 5)
{
ConvFromAX25(Routes->NEIGHBOUR_CALL, Normcall);
strlop(Normcall, ' ');
ptr += sprintf(ptr,
"{\"node\": \"%s\", \"port\": \"%d\", \"quality\": \"%d\"},\r\n",
Normcall, Routes->NEIGHBOUR_PORT, Routes->NEIGHBOUR_QUAL);
}
Routes++;
}
ptr -= 3;
ptr += sprintf(ptr, "]}");
/*
{
"nodeAlias": "BPQ",
"location": {"locator": "IO92KX"},
"software": {"name": "BPQ32","version": "6.0.24.11 Debug Build "},
"contact": "G8BPQ",
"sysopComment": "Testing",
"source": "ReportedByNode"
}
"ports": [
{
"id": "string",
"linkType": "RF",
"freq": 0,
"mode": "string",
"modulation": "string",
"baud": 0,
"bitrate": 0,
"usage": "Access",
"comment": "string"
}
],
*/
// "contact": "string",
// "neighbours": [{"node": "G7TAJ","port": "30"}]
sock = OpenHTTPSock("packetnodes.spots.radio");
if (sock == 0)
return;
SendWebRequest(sock, "packetnodes.spots.radio", Request, Params, strlen(Params), Return);
closesocket(sock);
}

@ -99,6 +99,8 @@ extern UCHAR LogDirectory[];
extern struct RIGPORTINFO * PORTInfo[34];
extern int NumberofPorts;
extern UCHAR ConfigDirectory[260];
char * strlop(char * buf, char delim);
VOID sendandcheck(SOCKET sock, const char * Buffer, int Len);
int CompareNode(const void *a, const void *b);
@ -1475,13 +1477,13 @@ VOID SaveConfigFile(SOCKET sock , char * MsgPtr, char * Rest, int LOCAL)
MsgLen = (int)strlen(input + 8);
if (BPQDirectory[0] == 0)
if (ConfigDirectory[0] == 0)
{
strcpy(inputname, "bpq32.cfg");
}
else
{
strcpy(inputname,BPQDirectory);
strcpy(inputname,ConfigDirectory);
strcat(inputname,"/");
strcat(inputname, "bpq32.cfg");
}
@ -3024,13 +3026,13 @@ doHeader:
if (COOKIE ==FALSE)
Key = DummyKey;
if (BPQDirectory[0] == 0)
if (ConfigDirectory[0] == 0)
{
strcpy(inputname, "bpq32.cfg");
}
else
{
strcpy(inputname,BPQDirectory);
strcpy(inputname,ConfigDirectory);
strcat(inputname,"/");
strcat(inputname, "bpq32.cfg");
}

@ -607,10 +607,10 @@ VOID ProcessChatLine(ChatCIRCUIT * conn, struct UserInfo * user, char* OrigBuffe
{
if (icu->iconv_toUTF8 == NULL)
{
icu->iconv_toUTF8 = iconv_open("UTF-8", icu->Codepage);
icu->iconv_toUTF8 = iconv_open("UTF-8//IGNORE", icu->Codepage);
if (icu->iconv_toUTF8 == (iconv_t)-1)
icu->iconv_toUTF8 = iconv_open("UTF-8", "CP1252");
icu->iconv_toUTF8 = iconv_open("UTF-8//IGNORE", "CP1252");
}
iconv(icu->iconv_toUTF8, NULL, NULL, NULL, NULL); // Reset State Machine
@ -619,7 +619,7 @@ VOID ProcessChatLine(ChatCIRCUIT * conn, struct UserInfo * user, char* OrigBuffe
else
{
if (link_toUTF8 == NULL)
link_toUTF8 = iconv_open("UTF-8", "CP1252");
link_toUTF8 = iconv_open("UTF-8//IGNORE", "CP1252");
iconv(link_toUTF8, NULL, NULL, NULL, NULL); // Reset State Machine
iconv(link_toUTF8, &Buffer, &len, (char ** __restrict__)&BufferBP, &left);
@ -1123,12 +1123,12 @@ void rduser(USER *user)
// Open an iconv decriptor for each conversion
if (user->Codepage[0])
user->iconv_toUTF8 = iconv_open("UTF-8", user->Codepage);
user->iconv_toUTF8 = iconv_open("UTF-8//IGNORE", user->Codepage);
else
user->iconv_toUTF8 = (iconv_t)-1;
if (user->iconv_toUTF8 == (iconv_t)-1)
user->iconv_toUTF8 = iconv_open("UTF-8", "CP1252");
user->iconv_toUTF8 = iconv_open("UTF-8//IGNORE", "CP1252");
if (user->Codepage[0])
@ -1137,7 +1137,7 @@ void rduser(USER *user)
user->iconv_fromUTF8 = (iconv_t)-1;
if (user->iconv_fromUTF8 == (iconv_t)-1)
user->iconv_fromUTF8 = iconv_open("CP1252", "UTF-8");
user->iconv_fromUTF8 = iconv_open("CP1252//IGNORE", "UTF-8");
#endif
}
}
@ -1969,7 +1969,7 @@ void put_text(ChatCIRCUIT * circuit, USER * user, UCHAR * buf)
icu->iconv_fromUTF8 = iconv_open(icu->Codepage, "UTF-8");
if (icu->iconv_fromUTF8 == (iconv_t)-1)
icu->iconv_fromUTF8 = iconv_open("CP1252", "UTF-8");
icu->iconv_fromUTF8 = iconv_open("CP1252//IGNORE", "UTF-8");
}
iconv(icu->iconv_fromUTF8, NULL, NULL, NULL, NULL); // Reset State Machine

@ -2420,6 +2420,10 @@ CheckPF:
LINK->LAST_F_TIME = REALTIMETICKS;
}
else
if (LINK->L2ACKREQ == 0) // Resptime is zero so send RR now
SEND_RR_RESP(LINK, 0);
}

@ -28,6 +28,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
//#include "C:\Program Files (x86)\GnuWin32\include\iconv.h"
#else
#include <iconv.h>
#include <errno.h>
#ifndef MACBPQ
#ifndef FREEBSD
#include <sys/prctl.h>
@ -178,6 +179,13 @@ int _MYTIMEZONE = 0;
UCHAR BPQDirectory[260];
UCHAR LogDirectory[260];
UCHAR ConfigDirectory[260];
// overrides from params
UCHAR LogDir[260] = "";
UCHAR ConfigDir[260] = "";
UCHAR DataDir[260] = "";
BOOL GetConfig(char * ConfigName);
VOID DecryptPass(char * Encrypt, unsigned char * Pass, unsigned int len);
@ -706,8 +714,26 @@ void ConTermPoll()
return;
}
#include "getopt.h"
static struct option long_options[] =
{
{"logdir", required_argument, 0 , 'l'},
{"configdir", required_argument, 0 , 'c'},
{"datadir", required_argument, 0 , 'd'},
{"help", no_argument, 0 , 'h'},
{ NULL , no_argument , NULL , no_argument }
};
char HelpScreen[] =
"Usage:\n"
"Optional Paramters\n"
"-l path or --logdir path Path for log files\n"
"-c path or --configdir path Path to Config file bpq32.cfg\n"
"-d path or --datadir path Path to Data Files\n"
"-v Show version and exit\n";
int Redirected = 0;
int main(int argc, char * argv[])
@ -759,15 +785,61 @@ int main(int argc, char * argv[])
timeLoadedMS = GetTickCount();
printf("Loaded at %llu ms\r\n", timeLoadedMS);
#endif
printf("G8BPQ AX25 Packet Switch System Version %s %s\n", TextVerstring, Datestring);
printf("%s\n", VerCopyright);
printf("G8BPQ AX25 Packet Switch System Version %s %s\n", TextVerstring, Datestring);
printf("%s\n", VerCopyright);
if (argc > 1 && _stricmp(argv[1], "-v") == 0)
return 0;
// look for optarg format parameters
{
int val;
UCHAR * ptr1;
UCHAR * ptr2;
int c;
while (1)
{
int option_index = 0;
c = getopt_long(argc, argv, "l:c:d:hv", long_options, &option_index);
// Check for end of operation or error
if (c == -1)
break;
// Handle options
switch (c)
{
case 'h':
printf(HelpScreen);
exit (0);
case 'l':
strcpy(LogDir, optarg);
break;
case 'c':
strcpy(ConfigDir, optarg);
break;
case 'd':
strcpy(DataDir, optarg);
break;
case '?':
/* getopt_long already printed an error message. */
break;
case 'v':
return 0;
}
}
}
sprintf(RlineVer, "LinBPQ%d.%d.%d", Ver[0], Ver[1], Ver[2]);
@ -783,23 +855,40 @@ int main(int argc, char * argv[])
#ifdef WIN32
GetCurrentDirectory(256, BPQDirectory);
GetCurrentDirectory(256, LogDirectory);
#else
getcwd(BPQDirectory, 256);
getcwd(LogDirectory, 256);
#endif
Consoleprintf("Current Directory is %s\n", BPQDirectory);
for (i = 1; i < argc; i++)
strcpy(ConfigDirectory, BPQDirectory);
strcpy(LogDirectory, BPQDirectory);
Consoleprintf("Current Directory is %s", BPQDirectory);
if (LogDir[0])
{
strcpy(LogDirectory, LogDir);
Consoleprintf("Log Directory is %s", LogDirectory);
}
if (DataDir[0])
{
strcpy(BPQDirectory, DataDir);
Consoleprintf("Working Directory is %s", BPQDirectory);
}
if (ConfigDir[0])
{
strcpy(ConfigDirectory, ConfigDir);
Consoleprintf("Config Directory is %s", ConfigDirectory);
}
for (i = optind; i < argc; i++)
{
if (_memicmp(argv[i], "logdir=", 7) == 0)
{
strcpy(LogDirectory, &argv[i][7]);
Consoleprintf("Log Directory is %s\n", LogDirectory);
break;
}
}
// Make sure logs directory exists
sprintf(LogDir, "%s/logs", LogDirectory);
@ -807,7 +896,13 @@ int main(int argc, char * argv[])
#ifdef WIN32
CreateDirectory(LogDir, NULL);
#else
mkdir(LogDir, S_IRWXU | S_IRWXG | S_IRWXO);
printf("Making Directory %s\n", LogDir);
i = mkdir(LogDir, S_IRWXU | S_IRWXG | S_IRWXO);
if (i == -1 && errno != EEXIST)
{
perror("Couldn't create log directory\n");
return 0;
}
chmod(LogDir, S_IRWXU | S_IRWXG | S_IRWXO);
#endif
@ -891,7 +986,7 @@ int main(int argc, char * argv[])
#endif
for (i = 1; i < argc; i++)
for (i = optind; i < argc; i++)
{
if (_stricmp(argv[i], "chat") == 0)
IncludesChat = TRUE;
@ -942,7 +1037,7 @@ int main(int argc, char * argv[])
// Start Mail if requested by command line or config
for (i = 1; i < argc; i++)
for (i = optind; i < argc; i++)
{
if (_stricmp(argv[i], "mail") == 0)
IncludesMail = TRUE;
@ -1172,7 +1267,7 @@ int main(int argc, char * argv[])
DoHouseKeeping(FALSE);
}
}
for (i = 1; i < argc; i++)
for (i = optind; i < argc; i++)
{
if (_stricmp(argv[i], "tidymail") == 0)
DeleteRedundantMessages();

@ -336,6 +336,10 @@
RelativePath=".\FreeDATA.c"
>
</File>
<File
RelativePath=".\getopt.c"
>
</File>
<File
RelativePath="..\CommonSource\HALDriver.c"
>

@ -11,7 +11,7 @@
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory="C:\linbpq"
CommandArguments="mail"
CommandArguments="-h"
Attach="false"
DebuggerType="3"
Remote="1"

@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>LinBPQ</ProjectName>
@ -24,20 +32,37 @@
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>15.0.28307.799</_ProjectFileVersion>
@ -47,11 +72,17 @@
<IntDir>C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>C:\Dev\Msdev2005\$(SolutionName)\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>C:\Dev\Msdev2005\Intermed\$(SolutionName)\$(ProjectName)\$(Configuration)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
@ -76,6 +107,29 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\CKernel;..\CommonSource;..\CInclude;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;LINBPQ;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;WS2_32.Lib;..\lib\libconfigd.lib;DbgHelp.lib;setupapi.lib;miniupnpc.lib;zlibstat.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>c:\LINBPQ\$(ProjectName).exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>c:\linbpq\linmail.map</MapFileName>
<SubSystem>Console</SubSystem>
<StackReserveSize>4000000</StackReserveSize>
<StackCommitSize>0</StackCommitSize>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\CKernel;..\CommonSource;..\CInclude;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -97,6 +151,27 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\CKernel;..\CommonSource;..\CInclude;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LINBPQ;_USE_32BIT_TIME_T;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;WS2_32.Lib;..\lib\libconfig.lib;DbgHelp.lib;Setupapi.lib;miniupnpc.lib;zlibstat.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>c:\devprogs\bpq32\LinBPQ.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<HeapReserveSize>5000000</HeapReserveSize>
<StackReserveSize>10000000</StackReserveSize>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="adif.c" />
<ClCompile Include="AEAPactor.c" />
@ -113,8 +188,12 @@
<ClCompile Include="BBSUtilities.c">
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</AssemblerOutput>
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</AssemblerOutput>
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">All</AssemblerOutput>
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">All</AssemblerOutput>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)</ObjectFileName>
</ClCompile>
<ClCompile Include="bpqaxip.c" />
<ClCompile Include="bpqether.c" />

@ -3109,8 +3109,8 @@ BOOL RigWriteCommBlock(struct RIGPORTINFO * PORT)
Err = GetCommModemStatus(PORT->hDevice, &Mask);
// if ((Mask & MS_CTS_ON) == 0) // trap com0com other end not open
// return TRUE;
if (Mask == 0) // trap com0com other end not open
return TRUE;
fWriteStat = WriteFile(PORT->hDevice, PORT->TXBuffer, PORT->TXLen, &BytesWritten, NULL );
#endif
@ -9996,7 +9996,7 @@ void ProcessSDRANGELFrame(struct RIGPORTINFO * PORT)
{
pos += 17;
strncpy(cmd, pos, 20);
RIG->RigFreq += atof(cmd) / 1000000.0;
RIG->RigFreq += (atof(cmd) + RIG->rxOffset) / 1000000.0;;
}

@ -188,7 +188,7 @@ VOID SENDBTMSG()
if (Buffer)
{
memcpy(Buffer->DEST, PORT->PORTUNPROTO, 7);
Buffer->DEST[6] |= 0xC0; // Set COmmand bits
Buffer->DEST[6] |= 0xC0; // Set Command bits
// Send from BBSCALL unless PORTBCALL defined

@ -10,8 +10,8 @@
#endif
#define KVers 6,0,24,11
#define KVerstring "6.0.24.11\0"
#define KVers 6,0,24,13
#define KVerstring "6.0.24.13\0"
#ifdef CKernel

@ -906,7 +906,7 @@ int SendWebMailHeaderEx(char * Reply, char * Key, struct HTTPConnectionInfo * Se
if (Msg && CheckUserMsg(Msg, User->Call, User->flags & F_SYSOP))
{
char UTF8Title[256];
char UTF8Title[4096];
char * EncodedTitle;
// List if it is the right type and in the page range we want
@ -934,7 +934,8 @@ int SendWebMailHeaderEx(char * Reply, char * Key, struct HTTPConnectionInfo * Se
EncodedTitle = doXMLTransparency(Msg->title);
ConvertTitletoUTF8(EncodedTitle, UTF8Title, 256);
memset(UTF8Title, 0, 4096); // In case convert fails part way through
ConvertTitletoUTF8(EncodedTitle, UTF8Title, 4095);
free(EncodedTitle);
@ -971,7 +972,7 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
int msgLen;
char FullTo[100];
char UTF8Title[256];
char UTF8Title[4096];
int Index;
char * crcrptr;
char DownLoad[256] = "";
@ -1009,7 +1010,8 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
// make sure title is UTF 8 encoded
ConvertTitletoUTF8(Msg->title, UTF8Title, 256);
memset(UTF8Title, 0, 4096); // In case convert fails part way through
ConvertTitletoUTF8(Msg->title, UTF8Title, 4095);
// if a B2 message diplay B2 Header instead of a locally generated one
@ -1248,14 +1250,18 @@ int ViewWebMailMessage(struct HTTPConnectionInfo * Session, char * Reply, int Nu
#else
int left = 2 * msgLen;
int len = msgLen;
int ret;
UCHAR * BufferBP = BufferB;
char * orig = MsgBytes;
MsgBytes[msgLen] = 0;
iconv_t * icu = NULL;
if (icu == NULL)
icu = iconv_open("UTF-8", "CP1252");
icu = iconv_open("UTF-8//IGNORE", "CP1252");
iconv(icu, NULL, NULL, NULL, NULL); // Reset State Machine
iconv(icu, &MsgBytes, &len, (char ** __restrict__)&BufferBP, &left);
ret = iconv(icu, &MsgBytes, &len, (char ** __restrict__)&BufferBP, &left);
free(Save);
Save = MsgBytes = BufferB;
@ -6126,9 +6132,12 @@ int ProcessWebmailWebSock(char * MsgPtr, char * OutBuffer)
EncodedTitle = doXMLTransparency(Msg->title);
ConvertTitletoUTF8(EncodedTitle, UTF8Title, 4096);
memset(UTF8Title, 0, 4096); // In case convert fails part way through
ConvertTitletoUTF8(EncodedTitle, UTF8Title, 4095);
printf("%s %s\n", EncodedTitle, UTF8Title);
free(EncodedTitle);
ptr += sprintf(ptr, "<a href=/WebMail/WM?%s&%d>%6d</a> %s %c%c %5d %-8s%-8s%-8s%s\r\n",
Key, Msg->number, Msg->number,

@ -689,6 +689,7 @@ typedef struct PORTCONTROL
time_t LastSmartIDTime; // For SmartID - ID only if packets sent recently
time_t SmartIDNeeded; // Time to send next smart ID
time_t SmartIDInterval; // Smart ID Interval (Secs)
int SendtoM0LTEMap;
} PORTCONTROLX, *PPORTCONTROL;

@ -139,6 +139,7 @@ extern BOOL ADIFLogEnabled;
extern UCHAR LogDirectory[260];
extern BOOL EventsEnabled;
extern BOOL SaveAPRSMsgs;
BOOL M0LTEMap = FALSE;
//TNCTABLE DD 0
//NUMBEROFSTREAMS DD 0
@ -788,6 +789,8 @@ BOOL Start()
ADIFLogEnabled = cfg->C_ADIF;
EventsEnabled = cfg->C_EVENTS;
SaveAPRSMsgs = cfg->C_SaveAPRSMsgs;
M0LTEMap = cfg->C_M0LTEMap;
// Get pointers to PASSWORD and APPL1 commands
@ -1075,6 +1078,8 @@ BOOL Start()
KISS->KISSCMD = realloc(KISS->KISSCMD, KISS->KISSCMDLEN);
}
PORT->SendtoM0LTEMap = PortRec->SendtoM0LTEMap;
if (PortRec->BBSFLAG) // Appl 1 not permitted - BBSFLAG=NOBBS
PORT->PERMITTEDAPPLS &= 0xfffffffe; // Clear bottom bit

@ -300,7 +300,8 @@ static char *keywords[] =
"APPL1QUAL", "APPL2QUAL", "APPL3QUAL", "APPL4QUAL",
"APPL5QUAL", "APPL6QUAL", "APPL7QUAL", "APPL8QUAL",
"BTEXT:", "NETROMCALL", "C_IS_CHAT", "MAXRTT", "MAXHOPS", // IPGATEWAY= no longer allowed
"LogL4Connects", "LogAllConnects", "SAVEMH", "ENABLEADIFLOG", "ENABLEEVENTS", "SAVEAPRSMSGS"
"LogL4Connects", "LogAllConnects", "SAVEMH", "ENABLEADIFLOG", "ENABLEEVENTS", "SAVEAPRSMSGS",
"EnableM0LTEMap"
}; /* parameter keywords */
static void * offset[] =
@ -320,7 +321,8 @@ static void * offset[] =
&xxcfg.C_APPL[0].ApplQual, &xxcfg.C_APPL[1].ApplQual, &xxcfg.C_APPL[2].ApplQual, &xxcfg.C_APPL[3].ApplQual,
&xxcfg.C_APPL[4].ApplQual, &xxcfg.C_APPL[5].ApplQual, &xxcfg.C_APPL[6].ApplQual, &xxcfg.C_APPL[7].ApplQual,
&xxcfg.C_BTEXT, &xxcfg.C_NETROMCALL, &xxcfg.C_C, &xxcfg.C_MAXRTT, &xxcfg.C_MAXHOPS, // IPGATEWAY= no longer allowed
&xxcfg.C_LogL4Connects, &xxcfg.C_LogAllConnects, &xxcfg.C_SaveMH, &xxcfg.C_ADIF, &xxcfg.C_EVENTS, &xxcfg.C_SaveAPRSMsgs}; /* offset for corresponding data in config file */
&xxcfg.C_LogL4Connects, &xxcfg.C_LogAllConnects, &xxcfg.C_SaveMH, &xxcfg.C_ADIF, &xxcfg.C_EVENTS, &xxcfg.C_SaveAPRSMsgs,
&xxcfg.C_M0LTEMap}; /* offset for corresponding data in config file */
static int routine[] =
{
@ -339,7 +341,8 @@ static int routine[] =
14, 14, 14, 14,
14, 14 ,14, 14,
15, 0, 2, 9, 9,
2, 2, 2, 2, 2, 2} ; // Routine to process param
2, 2, 2, 2, 2, 2,
2} ; // Routine to process param
int PARAMLIM = sizeof(routine)/sizeof(int);
//int NUMBEROFKEYWORDS = sizeof(routine)/sizeof(int);
@ -361,7 +364,7 @@ static char *pkeywords[] =
"BCALL", "DIGIMASK", "NOKEEPALIVES", "COMPORT", "DRIVER", "WL2KREPORT", "UIONLY",
"UDPPORT", "IPADDR", "I2CBUS", "I2CDEVICE", "UDPTXPORT", "UDPRXPORT", "NONORMALIZE",
"IGNOREUNLOCKEDROUTES", "INP3ONLY", "TCPPORT", "RIGPORT", "PERMITTEDAPPLS", "HIDE",
"SMARTID", "KISSCOMMAND"}; /* parameter keywords */
"SMARTID", "KISSCOMMAND", "SendtoM0LTEMap"}; /* parameter keywords */
static void * poffset[] =
{
@ -375,7 +378,7 @@ static void * poffset[] =
&xxp.BCALL, &xxp.DIGIMASK, &xxp.DefaultNoKeepAlives, &xxp.IOADDR, &xxp.DLLNAME, &xxp.WL2K, &xxp.UIONLY,
&xxp.IOADDR, &xxp.IPADDR, &xxp.INTLEVEL, &xxp.IOADDR, &xxp.IOADDR, &xxp.ListenPort, &xxp.NoNormalize,
&xxp.IGNOREUNLOCKED, &xxp.INP3ONLY, &xxp.TCPPORT, &xxp.RIGPORT, &xxp.PERMITTEDAPPLS, &xxp.Hide,
&xxp.SmartID, &xxp.KissParams}; /* offset for corresponding data in config file */
&xxp.SmartID, &xxp.KissParams, &xxp.SendtoM0LTEMap}; /* offset for corresponding data in config file */
static int proutine[] =
{
@ -389,7 +392,7 @@ static int proutine[] =
0, 1, 2, 18, 15, 16, 2,
1, 17, 1, 1, 1, 1, 2,
2, 2, 1, 1, 19, 2,
1, 20}; /* routine to process parameter */
1, 20, 1}; /* routine to process parameter */
int PPARAMLIM = sizeof(proutine)/sizeof(int);
@ -427,6 +430,9 @@ char bbscall[11];
char bbsalias[11];
int bbsqual;
extern UCHAR ConfigDirectory[260];
BOOL LocSpecified = FALSE;
/************************************************************************/
@ -485,13 +491,13 @@ BOOL ProcessConfig()
Consoleprintf("Configuration file Preprocessor.");
if (BPQDirectory[0] == 0)
if (ConfigDirectory[0] == 0)
{
strcpy(inputname, "bpq32.cfg");
}
else
{
strcpy(inputname,BPQDirectory);
strcpy(inputname,ConfigDirectory);
strcat(inputname,"/");
strcat(inputname, "bpq32.cfg");
}
@ -597,6 +603,8 @@ BOOL ProcessConfig()
paramok[77]=1; // ENABLEADIFLOG optional
paramok[78]=1; // EnableEvents optional
paramok[79]=1; // SaveAPRSMsgs optional
paramok[79]=1; // SaveAPRSMsgs optional
paramok[80]=1; // EnableM0LTEMap optional
for (i=0; i < PARAMLIM; i++)
{
@ -1624,6 +1632,8 @@ int ports(int i)
heading = 1;
}
xxp.SendtoM0LTEMap = 1; // Default to enabled
while (endport == 0 && !feof(fp1))
{
GetNextLine(rec);

@ -73,10 +73,11 @@ struct PORTCONFIG
unsigned int PERMITTEDAPPLS; // Appls allowed on this port
int HavePermittedAppls; // Indicated PERMITTEDAPPLS uses
int Hide; // Don't show on Ports display or AGW Connect Menu
long long txOffset; // Transverter tx offset
long long rxOffset; // Transverter rx offset ppa
// long long txOffset; // Transverter tx offset
// long long rxOffset; // Transverter rx offset ppa
int SmartID;
unsigned char * KissParams;
int SendtoM0LTEMap;
};
struct ROUTECONFIG
@ -149,6 +150,7 @@ struct CONFIGTABLE
UCHAR C_EVENTS;
UCHAR C_LogAllConnects;
UCHAR C_SaveAPRSMsgs;
UCHAR C_M0LTEMap;
UCHAR C_VERSION; // CONFIG PROG VERSION
// Reuse C_APPLICATIONS - no longer used
char C_NETROMCALL[10];

@ -50,6 +50,7 @@ char LOC[7] = ""; // Must be in shared mem// Maidenhead Locator for Reporting
char ReportDest[7];
UCHAR BPQDirectory[260] = ".";
UCHAR ConfigDirectory[260] = ".";
UCHAR LogDirectory[260] = "";
UCHAR BPQProgramDirectory[260]="";

@ -0,0 +1,715 @@
/*
* getopt.c
*
* $Id: getopt.c,v 1.9 2009/02/08 18:02:17 keithmarshall Exp $
*
* Implementation of the `getopt', `getopt_long' and `getopt_long_only'
* APIs, for inclusion in the MinGW runtime library.
*
* This file is part of the MinGW32 package set.
*
* Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
*
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.9 $
* $Author: keithmarshall $
* $Date: 2009/02/08 18:02:17 $
*
*/
// Modified a little to compile as C code, John Wiseman 2018
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "getopt.h"
/* Identify how to get the calling program name, for use in messages...
*/
#ifdef __CYGWIN__
/*
* CYGWIN uses this DLL reference...
*/
# define PROGNAME __progname
extern char __declspec(dllimport) *__progname;
#else
/*
* ...while elsewhere, we simply use the first argument passed.
*/
# define PROGNAME *argv
#endif
/* Initialise the public variables. */
int optind = 1; /* index for first non-option arg */
int opterr = 1; /* enable built-in error messages */
char *optarg = NULL; /* pointer to current option argument */
#define CHAR char /* argument type selector */
#define getopt_switchar '-' /* option prefix character in argv */
#define getopt_pluschar '+' /* prefix for POSIX mode in optstring */
#define getopt_takes_argument ':' /* marker for optarg in optstring */
#define getopt_arg_assign '=' /* longopt argument field separator */
#define getopt_unknown '?' /* return code for unmatched option */
#define getopt_ordered 1 /* return code for ordered non-option */
#define getopt_all_done -1 /* return code to indicate completion */
enum
{ /* All `getopt' API functions are implemented via calls to the
* common static function `getopt_parse()'; these `mode' selectors
* determine the behaviour of `getopt_parse()', to deliver the
* appropriate result in each case.
*/
getopt_mode_standard = 0, /* getopt() */
getopt_mode_long, /* getopt_long() */
getopt_mode_long_only /* getopt_long_only() */
};
enum
{ /* When attempting to match a command line argument to a long form option,
* these indicate the status of the match.
*/
getopt_no_match = 0, /* no successful match */
getopt_abbreviated_match, /* argument is an abbreviation for an option */
getopt_exact_match /* argument matches the full option name */
};
int optopt = getopt_unknown; /* return value for option being evaluated */
/* Some BSD applications expect to be able to reinitialise `getopt' parsing
* by setting a global variable called `optreset'. We provide an obfuscated
* API, which allows applications to emulate this brain damage; however, any
* use of this is non-portable, and is strongly discouraged.
*/
#define optreset __mingw_optreset
int optreset = 0;
int getopt_missing_arg( const CHAR *optstring )
{
/* Helper function to determine the appropriate return value,
* for the case where a required option argument is missing.
*/
if( (*optstring == getopt_pluschar) || (*optstring == getopt_switchar) )
++optstring;
return (*optstring == getopt_takes_argument)
? getopt_takes_argument
: getopt_unknown;
}
/* `complain' macro facilitates the generation of simple built-in
* error messages, displayed on various fault conditions, provided
* `opterr' is non-zero.
*/
#define complain( MSG, ARG ) if( opterr ) \
fprintf( stderr, "%s: "MSG"\n", PROGNAME, ARG )
int getopt_argerror( int mode, char *fmt, CHAR *prog, struct option *opt, int retval )
{
/* Helper function, to generate more complex built-in error
* messages, for invalid arguments to long form options ...
*/
if( opterr )
{
/* ... but, displayed only if `opterr' is non-zero.
*/
char flag[] = "--";
if( mode != getopt_mode_long )
/*
* only display one hyphen, for implicit long form options,
* improperly resolved by `getopt_long_only()'.
*/
flag[1] = 0;
/*
* always preface the program name ...
*/
fprintf( stderr, "%s: ", prog );
/*
* to the appropriate, option specific message.
*/
fprintf( stderr, fmt, flag, opt->name );
}
/* Whether displaying the message, or not, always set `optopt'
* to identify the faulty option ...
*/
optopt = opt->val;
/*
* and return the `invalid option' indicator.
*/
return retval;
}
/* `getopt_conventions' establish behavioural options, to control
* the operation of `getopt_parse()', e.g. to select between POSIX
* and GNU style argument parsing behaviour.
*/
#define getopt_set_conventions 0x1000
#define getopt_posixly_correct 0x0010
int getopt_conventions( int flags )
{
static int conventions = 0;
if( (conventions == 0) && ((flags & getopt_set_conventions) == 0) )
{
/* default conventions have not yet been established;
* initialise them now!
*/
conventions = getopt_set_conventions;
}
else if( flags & getopt_set_conventions )
/*
* default conventions may have already been established,
* but this is a specific request to augment them.
*/
conventions |= flags;
/* in any event, return the currently established conventions.
*/
return conventions;
}
int is_switchar( CHAR flag )
{
/* A simple helper function, used to identify the switch character
* introducing an optional command line argument.
*/
return flag == getopt_switchar;
}
const CHAR *getopt_match( CHAR lookup, const CHAR *opt_string )
{
/* Helper function, used to identify short form options.
*/
if( (*opt_string == getopt_pluschar) || (*opt_string == getopt_switchar) )
++opt_string;
if( *opt_string == getopt_takes_argument )
++opt_string;
do if( lookup == *opt_string ) return opt_string;
while( *++opt_string );
return NULL;
}
int getopt_match_long( const CHAR *nextchar, const CHAR *optname )
{
/* Helper function, used to identify potential matches for
* long form options.
*/
CHAR matchchar;
while( (matchchar = *nextchar++) && (matchchar == *optname) )
/*
* skip over initial substring which DOES match.
*/
++optname;
if( matchchar )
{
/* did NOT match the entire argument to an initial substring
* of a defined option name ...
*/
if( matchchar != getopt_arg_assign )
/*
* ... and didn't stop at an `=' internal field separator,
* so this is NOT a possible match.
*/
return getopt_no_match;
/* DID stop at an `=' internal field separator,
* so this IS a possible match, and what follows is an
* argument to the possibly matched option.
*/
optarg = (char *)(nextchar);
}
return *optname
/*
* if we DIDN'T match the ENTIRE text of the option name,
* then it's a possible abbreviated match ...
*/
? getopt_abbreviated_match
/*
* but if we DID match the entire option name,
* then it's a DEFINITE EXACT match.
*/
: getopt_exact_match;
}
int getopt_resolved( int mode, int argc, CHAR *const *argv, int *argind,
struct option *opt, int index, int *retindex, const CHAR *optstring )
{
/* Helper function to establish appropriate return conditions,
* on resolution of a long form option.
*/
if( retindex != NULL )
*retindex = index;
/* On return, `optind' should normally refer to the argument, if any,
* which follows the current one; it is convenient to set this, before
* checking for the presence of any `optarg'.
*/
optind = *argind + 1;
if( optarg && (opt[index].has_arg == no_argument) )
/*
* it is an error for the user to specify an option specific argument
* with an option which doesn't expect one!
*/
return getopt_argerror( mode, "option `%s%s' doesn't accept an argument\n",
PROGNAME, opt + index, getopt_unknown );
else if( (optarg == NULL) && (opt[index].has_arg == required_argument) )
{
/* similarly, it is an error if no argument is specified
* with an option which requires one ...
*/
if( optind < argc )
/*
* ... except that the requirement may be satisfied from
* the following command line argument, if any ...
*/
optarg = argv[*argind = optind++];
else
/* so fail this case, only if no such argument exists!
*/
return getopt_argerror( mode, "option `%s%s' requires an argument\n",
PROGNAME, opt + index, getopt_missing_arg( optstring ) );
}
/* when the caller has provided a return buffer ...
*/
if( opt[index].flag != NULL )
{
/* ... then we place the proper return value there,
* and return a status code of zero ...
*/
*(opt[index].flag) = opt[index].val;
return 0;
}
/* ... otherwise, the return value becomes the status code.
*/
return opt[index].val;
}
static
#define getopt_std_args int argc, CHAR *const argv[], const CHAR *optstring
int getopt_parse( int mode, getopt_std_args, ... )
{
/* Common core implementation for ALL `getopt' functions.
*/
static int argind = 0;
static int optbase = 0;
static const CHAR *nextchar = NULL;
static int optmark = 0;
if( (optreset |= (optind < 1)) || (optind < optbase) )
{
/* POSIX does not prescribe any definitive mechanism for restarting
* a `getopt' scan, but some applications may require such capability.
* We will support it, by allowing the caller to adjust the value of
* `optind' downwards, (nominally setting it to zero). Since POSIX
* wants `optind' to have an initial value of one, but we want all
* of our internal place holders to be initialised to zero, when we
* are called for the first time, we will handle such a reset by
* adjusting all of the internal place holders to one less than
* the adjusted `optind' value, (but never to less than zero).
*/
if( optreset )
{
/* User has explicitly requested reinitialisation...
* We need to reset `optind' to it's normal initial value of 1,
* to avoid a potential infinitely recursive loop; by doing this
* up front, we also ensure that the remaining place holders
* will be correctly reinitialised to no less than zero.
*/
optind = 1;
/* We also need to clear the `optreset' request...
*/
optreset = 0;
}
/* Now, we may safely reinitialise the internal place holders, to
* one less than `optind', without fear of making them negative.
*/
optmark = optbase = argind = optind - 1;
nextchar = NULL;
}
/* From a POSIX perspective, the following is `undefined behaviour';
* we implement it thus, for compatibility with GNU and BSD getopt.
*/
else if( optind > (argind + 1) )
{
/* Some applications expect to be able to manipulate `optind',
* causing `getopt' to skip over one or more elements of `argv';
* POSIX doesn't require us to support this brain-damaged concept;
* (indeed, POSIX defines no particular behaviour, in the event of
* such usage, so it must be considered a bug for an application
* to rely on any particular outcome); nonetheless, Mac-OS-X and
* BSD actually provide *documented* support for this capability,
* so we ensure that our internal place holders keep track of
* external `optind' increments; (`argind' must lag by one).
*/
argind = optind - 1;
/* When `optind' is misused, in this fashion, we also abandon any
* residual text in the argument we had been parsing; this is done
* without any further processing of such abandoned text, assuming
* that the caller is equipped to handle it appropriately.
*/
nextchar = NULL;
}
if( nextchar && *nextchar )
{
/* we are parsing a standard, or short format, option argument ...
*/
const CHAR *optchar;
if( (optchar = getopt_match( optopt = *nextchar++, optstring )) != NULL )
{
/* we have identified it as valid ...
*/
if( optchar[1] == getopt_takes_argument )
{
/* and determined that it requires an associated argument ...
*/
if( ! *(optarg = (char *)(nextchar)) )
{
/* the argument is NOT attached ...
*/
if( optchar[2] == getopt_takes_argument )
/*
* but this GNU extension marks it as optional,
* so we don't provide one on this occasion.
*/
optarg = NULL;
/* otherwise this option takes a mandatory argument,
* so, provided there is one available ...
*/
else if( (argc - argind) > 1 )
/*
* we take the following command line argument,
* as the appropriate option argument.
*/
optarg = argv[++argind];
/* but if no further argument is available,
* then there is nothing we can do, except for
* issuing the requisite diagnostic message.
*/
else
{
complain( "option requires an argument -- %c", optopt );
return getopt_missing_arg( optstring );
}
}
optind = argind + 1;
nextchar = NULL;
}
else
optarg = NULL;
optind = (nextchar && *nextchar) ? argind : argind + 1;
return optopt;
}
/* if we didn't find a valid match for the specified option character,
* then we fall through to here, so take appropriate diagnostic action.
*/
if( mode == getopt_mode_long_only )
{
complain( "unrecognised option `-%s'", --nextchar );
nextchar = NULL;
optopt = 0;
}
else
complain( "invalid option -- %c", optopt );
optind = (nextchar && *nextchar) ? argind : argind + 1;
return getopt_unknown;
}
if( optmark > optbase )
{
/* This can happen, in GNU parsing mode ONLY, when we have
* skipped over non-option arguments, and found a subsequent
* option argument; in this case we permute the arguments.
*/
int index;
/*
* `optspan' specifies the number of contiguous arguments
* which are spanned by the current option, and so must be
* moved together during permutation.
*/
int optspan = argind - optmark + 1;
/*
* we use `this_arg' to store these temporarily.
*/
CHAR *this_arg[100];
/*
* we cannot manipulate `argv' directly, since the `getopt'
* API prototypes it as `read-only'; this cast to `arglist'
* allows us to work around that restriction.
*/
CHAR **arglist = (char **)(argv);
/* save temporary copies of the arguments which are associated
* with the current option ...
*/
for( index = 0; index < optspan; ++index )
this_arg[index] = arglist[optmark + index];
/* move all preceding non-option arguments to the right,
* overwriting these saved arguments, while making space
* to replace them in their permuted location.
*/
for( --optmark; optmark >= optbase; --optmark )
arglist[optmark + optspan] = arglist[optmark];
/* restore the temporarily saved option arguments to
* their permuted location.
*/
for( index = 0; index < optspan; ++index )
arglist[optbase + index] = this_arg[index];
/* adjust `optbase', to account for the relocated option.
*/
optbase += optspan;
}
else
/* no permutation occurred ...
* simply adjust `optbase' for all options parsed so far.
*/
optbase = argind + 1;
/* enter main parsing loop ...
*/
while( argc > ++argind )
{
/* inspect each argument in turn, identifying possible options ...
*/
if( is_switchar( *(nextchar = argv[optmark = argind]) ) && *++nextchar )
{
/* we've found a candidate option argument ... */
if( is_switchar( *nextchar ) )
{
/* it's a double hyphen argument ... */
const CHAR *refchar = nextchar;
if( *++refchar )
{
/* and it looks like a long format option ...
* `getopt_long' mode must be active to accept it as such,
* `getopt_long_only' also qualifies, but we must downgrade
* it to force explicit handling as a long format option.
*/
if( mode >= getopt_mode_long )
{
nextchar = refchar;
mode = getopt_mode_long;
}
}
else
{
/* this is an explicit `--' end of options marker, so wrap up now!
*/
if( optmark > optbase )
{
/* permuting the argument list as necessary ...
* (note use of `this_arg' and `arglist', as above).
*/
CHAR *this_arg = argv[optmark];
CHAR **arglist = (CHAR **)(argv);
/* move all preceding non-option arguments to the right ...
*/
do arglist[optmark] = arglist[optmark - 1];
while( optmark-- > optbase );
/* reinstate the `--' marker, in its permuted location.
*/
arglist[optbase] = this_arg;
}
/* ... before finally bumping `optbase' past the `--' marker,
* and returning the `all done' completion indicator.
*/
optind = ++optbase;
return getopt_all_done;
}
}
else if( mode < getopt_mode_long_only )
{
/* it's not an explicit long option, and `getopt_long_only' isn't active,
* so we must explicitly try to match it as a short option.
*/
mode = getopt_mode_standard;
}
if( mode >= getopt_mode_long )
{
/* the current argument is a long form option, (either explicitly,
* introduced by a double hyphen, or implicitly because we were called
* by `getopt_long_only'); this is where we parse it.
*/
int lookup;
int matched = -1;
struct option *longopts;
int *optindex;
/* we need to fetch the `extra' function arguments, which are
* specified for the `getopt_long' APIs.
*/
va_list refptr;
va_start( refptr, optstring );
longopts = va_arg( refptr, struct option * );
optindex = va_arg( refptr, int * );
va_end( refptr );
/* ensuring that `optarg' does not inherit any junk, from parsing
* preceding arguments ...
*/
optarg = NULL;
for( lookup = 0; longopts && longopts[lookup].name; ++lookup )
{
/* scan the list of defined long form options ...
*/
switch( getopt_match_long( nextchar, longopts[lookup].name ) )
{
/* looking for possible matches for the current argument.
*/
case getopt_exact_match:
/*
* when an exact match is found,
* return it immediately, setting `nextchar' to NULL,
* to ensure we don't mistakenly try to match any
* subsequent characters as short form options.
*/
nextchar = NULL;
return getopt_resolved( mode, argc, argv, &argind,
longopts, lookup, optindex, optstring );
case getopt_abbreviated_match:
/*
* but, for a partial (initial substring) match ...
*/
if( matched >= 0 )
{
/* if this is not the first, then we have an ambiguity ...
*/
optopt = 0;
nextchar = NULL;
optind = argind + 1;
complain( "option `%s' is ambiguous", argv[argind] );
return getopt_unknown;
}
/* otherwise just note that we've found a possible match ...
*/
matched = lookup;
}
}
if( matched >= 0 )
{
/* if we get to here, then we found exactly one partial match,
* so return it, as for an exact match.
*/
nextchar = NULL;
return getopt_resolved( mode, argc, argv, &argind,
longopts, matched, optindex, optstring );
}
if( mode < getopt_mode_long_only )
{
/* if here, then we had what SHOULD have been a long form option,
* but it is unmatched; (perversely, `mode == getopt_mode_long_only'
* allows us to still try to match it as a short form option).
*/
optopt = 0;
nextchar = NULL;
optind = argind + 1;
complain( "unrecognised option `%s'", argv[argind] );
return getopt_unknown;
}
}
/* fall through to handle standard short form options...
* when the option argument format is neither explictly identified
* as long, nor implicitly matched as such, and the argument isn't
* just a bare hyphen, (which isn't an option), then we make one
* recursive call to explicitly interpret it as short format.
*/
if( *nextchar )
return getopt_parse( mode, argc, argv, optstring );
}
/* if we get to here, then we've parsed a non-option argument ...
* in GNU compatibility mode, we step over it, so we can permute
* any subsequent option arguments, but ...
*/
if( *optstring == getopt_switchar )
{
/* if `optstring' begins with a `-' character, this special
* GNU specific behaviour requires us to return the non-option
* arguments in strict order, as pseudo-arguments to a special
* option, with return value defined as `getopt_ordered'.
*/
nextchar = NULL;
optind = argind + 1;
optarg = argv[argind];
return getopt_ordered;
}
if( getopt_conventions( *optstring ) & getopt_posixly_correct )
/*
* otherwise ...
* for POSIXLY_CORRECT behaviour, or if `optstring' begins with
* a `+' character, then we break out of the parsing loop, so that
* the scan ends at the current argument, with no permutation.
*/
break;
}
/* fall through when all arguments have been evaluated,
*/
optind = optbase;
return getopt_all_done;
}
/* All three public API entry points are trivially defined,
* in terms of the internal `getopt_parse' function.
*/
int getopt( getopt_std_args )
{
return getopt_parse( getopt_mode_standard, argc, argv, optstring );
}
int getopt_long( getopt_std_args, const struct option *opts, int *index )
{
return getopt_parse( getopt_mode_long, argc, argv, optstring, opts, index );
}
int getopt_long_only( getopt_std_args, const struct option *opts, int *index )
{
return getopt_parse( getopt_mode_long_only, argc, argv, optstring, opts, index );
}
#ifdef __weak_alias
/*
* These Microsnot style uglified aliases are provided for compatibility
* with the previous MinGW implementation of the getopt API.
*/
__weak_alias( getopt, _getopt )
__weak_alias( getopt_long, _getopt_long )
__weak_alias( getopt_long_only, _getopt_long_only )
#endif
/* $RCSfile: getopt.c,v $Revision: 1.9 $: end of file */

@ -0,0 +1,108 @@
#ifndef __GETOPT_H__
/*
* getopt.h
*
* $Id: getopt.h,v 1.4 2009/01/04 17:35:36 keithmarshall Exp $
*
* Defines constants and function prototypes required to implement
* the `getopt', `getopt_long' and `getopt_long_only' APIs.
*
* This file is part of the MinGW32 package set.
*
* Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
*
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.4 $
* $Author: keithmarshall $
* $Date: 2009/01/04 17:35:36 $
*
*/
#define __GETOPT_H__
#ifdef __cplusplus
extern "C" {
#endif
extern int optind; /* index of first non-option in argv */
extern int optopt; /* single option character, as parsed */
extern int opterr; /* flag to enable built-in diagnostics... */
/* (user may set to zero, to suppress) */
extern char *optarg; /* pointer to argument of current option */
extern int getopt( int, char * const [], const char * );
#ifdef _BSD_SOURCE
/*
* BSD adds the non-standard `optreset' feature, for reinitialisation
* of `getopt' parsing. We support this feature, for applications which
* proclaim their BSD heritage, before including this header; however,
* to maintain portability, developers are advised to avoid it.
*/
# define optreset __mingw_optreset
extern int optreset;
#endif
#ifdef __cplusplus
}
#endif
/*
* POSIX requires the `getopt' API to be specified in `unistd.h';
* thus, `unistd.h' includes this header. However, we do not want
* to expose the `getopt_long' or `getopt_long_only' APIs, when
* included in this manner. Thus, close the standard __GETOPT_H__
* declarations block, and open an additional __GETOPT_LONG_H__
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
#endif /* !defined(__GETOPT_H__) */
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__
#ifdef __cplusplus
extern "C" {
#endif
struct option /* specification for a long form option... */
{
const char *name; /* option name, without leading hyphens */
int has_arg; /* does it take an argument? */
int *flag; /* where to save its status, or NULL */
int val; /* its associated status value */
};
enum /* permitted values for its `has_arg' field... */
{
no_argument = 0, /* option never takes an argument */
required_argument, /* option always requires an argument */
optional_argument /* option may take an argument */
};
extern int getopt_long( int, char * const [], const char *, const struct option *, int * );
extern int getopt_long_only( int, char * const [], const char *, const struct option *, int * );
/*
* Previous MinGW implementation had...
*/
#ifndef HAVE_DECL_GETOPT
/*
* ...for the long form API only; keep this for compatibility.
*/
# define HAVE_DECL_GETOPT 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
/* $RCSfile: getopt.h,v $Revision: 1.4 $: end of file */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Debug|x64|C:\Users\John\OneDrive\Dev\Source\bpq32\CommonSource\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.