Added Magiedit to makefile

This commit is contained in:
Andrew Pamment
2017-03-19 07:49:46 +10:00
parent 981eb3a4c9
commit ec69297cd8
111 changed files with 110 additions and 17 deletions

25
deps/odoors/historic/odtips3/BPFIND.H vendored Normal file
View File

@@ -0,0 +1,25 @@
/* MSC / BC compatible findfirst()/findnext() definitions. */
#ifdef __TURBOC__
#include <dir.h>
#include <dos.h>
#else
#include <dos.h>
struct ffblk
{
char ff_reserved[21];
char ff_attrib;
unsigned ff_ftime;
unsigned ff_fdate;
long ff_fsize;
char ff_name[13];
}
#define findfirst(p, f, a) _dos_findfirst(p, (struct _find_t *)f, a)
#define findnext(f) _dos_findnext((struct _find_t *)f)
#define FA_RDONLY _A_RDONLY
#define FA_HIDDEN _A_HIDDEN
#define FA_SYSTEM _A_SYSTEM
#define FA_LABEL _A_VOLID
#define FA_DIREC _A_SUBDIR
#define FA_ARCH _A_ARCH
#endif

342
deps/odoors/historic/odtips3/CMDLINE.C vendored Normal file
View File

@@ -0,0 +1,342 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "opendoor.h"
#include "cmdline.h"
#ifndef BOOL
typedef int BOOL;
#endif
typedef enum
{
kParamLocal,
kParamBPS,
kParamPort,
kParamNode,
kParamHelp,
kParamPersonality,
kParamMaxTime,
kParamAddress,
kParamIRQ,
kParamNoFOSSIL,
kParamNoFIFO,
kParamDropFile,
kParamUserName,
kParamTimeLeft,
kParamSecurity,
kParamLocation,
kParamUnknown
} tCommandLineParameter;
static void AdvanceToNextArg(int *pnCurrentArg, int nArgCount,
char *pszOption);
static void GetNextArgName(int *pnCurrentArg, int nArgCount,
char *papszArguments[], char *pszString,
int nStringSize);
static tCommandLineParameter GetCommandLineParameter(char *pszArgument);
void ParseStandardCommandLine(int nArgCount, char *papszArguments[])
{
char *pszCurrentArg;
int nCurrentArg;
for(nCurrentArg = 1; nCurrentArg < nArgCount; ++nCurrentArg)
{
pszCurrentArg = papszArguments[nCurrentArg];
switch(GetCommandLineParameter(pszCurrentArg))
{
case kParamLocal:
od_control.od_force_local = TRUE;
break;
case kParamBPS:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.baud = atol(papszArguments[nCurrentArg]);
break;
case kParamPort:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.port = atoi(papszArguments[nCurrentArg]);
break;
case kParamHelp:
printf("AVALIABLE COMMAND LINE PARAMETERS:\n");
printf(" -L or -LOCAL - Causes door to operate in local mode, without requiring a\n");
printf(" door information (drop) file.\n");
printf(" -DROPFILE x - Door information file directory or directory+filename.\n");
printf(" -N x or -NODE x - Sets the node number to use.\n");
printf(" -B x or -BPS x - Sets the serial port <---> modem bps (baud) rate to use.\n");
printf(" -P x or -PORT x - Sets the serial port to use, were 0=COM1, 1=COM2, etc.\n");
printf(" -ADDRESS x - Sets serial port address in decimal NOT hexidecimal\n");
printf(" (only has effect if FOSSIL driver is not being used).\n");
printf(" -IRQ x - Sets the serial port IRQ line (only has effect if FOSSIL\n");
printf(" driver is not being used).\n");
printf(" -NOFOSSIL - Disables use of FOSSIL driver, even if available.\n");
printf(" -NOFIFO - Disables use of 16550 FIFO buffers (only if FOSSIL driver\n");
printf(" is not being used).\n");
printf(" -PERSONALITY x - Sets the sysop status line / function key personality to\n");
printf(" use - one of Standard, PCBoard, RemoteAccess or Wildcat.\n");
printf(" -MAXTIME x - Sets the maximum number of minutes that any user will be\n");
printf(" permitted to access the door.\n");
printf(" -USERNAME x - Name of user who is currently online.\n");
printf(" -TIMELEFT x - User's time remaining online.\n");
printf(" -SECURITY x - User's security level.\n");
printf(" -LOCATION x - Location from which user is calling.\n");
printf(" -?, -H or -HELP - Displays command-line help and exits.\n");
exit(1);
break;
case kParamNode:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.od_node = atoi(papszArguments[nCurrentArg]);
break;
case kParamPersonality:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
if(stricmp(papszArguments[nCurrentArg], "Standard") == 0)
{
od_control.od_default_personality = PER_OPENDOORS;
}
else if(stricmp(papszArguments[nCurrentArg], "PCBoard") == 0)
{
od_control.od_default_personality = PER_PCBOARD;
}
else if(stricmp(papszArguments[nCurrentArg], "RemoteAccess") == 0)
{
od_control.od_default_personality = PER_RA;
}
else if(stricmp(papszArguments[nCurrentArg], "Wildcat") == 0)
{
od_control.od_default_personality = PER_WILDCAT;
}
else
{
printf("Unknown personality: %s\n", papszArguments[nCurrentArg]);
exit(1);
}
break;
case kParamMaxTime:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.od_maxtime = atoi(papszArguments[nCurrentArg]);
break;
case kParamAddress:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.od_com_address = atoi(papszArguments[nCurrentArg]);
break;
case kParamIRQ:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.od_com_irq = atoi(papszArguments[nCurrentArg]);
break;
case kParamNoFOSSIL:
od_control.od_no_fossil = TRUE;
break;
case kParamNoFIFO:
od_control.od_com_no_fifo = TRUE;
break;
case kParamDropFile:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
strncpy(od_control.info_path, papszArguments[nCurrentArg],
sizeof(od_control.info_path) - 1);
od_control.info_path[sizeof(od_control.info_path) - 1] = '\0';
break;
case kParamUserName:
GetNextArgName(&nCurrentArg, nArgCount, papszArguments,
od_control.user_name, sizeof(od_control.user_name));
break;
case kParamTimeLeft:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.user_timelimit = atoi(papszArguments[nCurrentArg]);
break;
case kParamSecurity:
AdvanceToNextArg(&nCurrentArg, nArgCount, pszCurrentArg);
od_control.user_security = atoi(papszArguments[nCurrentArg]);
break;
case kParamLocation:
GetNextArgName(&nCurrentArg, nArgCount, papszArguments,
od_control.user_location, sizeof(od_control.user_location));
break;
default:
printf("Unrecognized command line option: %s\n", pszCurrentArg);
exit(1);
break;
}
}
}
static void AdvanceToNextArg(int *pnCurrentArg, int nArgCount, char *pszOption)
{
if(++*pnCurrentArg >= nArgCount)
{
printf("Missing parameter for option: %s\n", pszOption);
exit(1);
}
}
static void GetNextArgName(int *pnCurrentArg, int nArgCount,
char *papszArguments[], char *pszString,
int nStringSize)
{
BOOL bFirst = TRUE;
if((*pnCurrentArg) + 1 >= nArgCount)
{
printf("Missing parameter for option: %s\n",
papszArguments[(*pnCurrentArg) - 1]);
exit(1);
}
pszString[0] = '\0';
while(++*pnCurrentArg < nArgCount)
{
if(GetCommandLineParameter(papszArguments[*pnCurrentArg])
!= kParamUnknown)
{
--*pnCurrentArg;
break;
}
if(strlen(pszString) >= nStringSize - 1)
{
break;
}
if(!bFirst)
{
strcat(pszString, " ");
}
strncat(pszString, papszArguments[*pnCurrentArg],
strlen(pszString) - nStringSize - 1);
pszString[nStringSize - 1] = '\0';
bFirst = FALSE;
}
}
static tCommandLineParameter GetCommandLineParameter(char *pszArgument)
{
if(*pszArgument == '-' || *pszArgument == '/')
{
++pszArgument;
}
if(stricmp(pszArgument, "L") == 0
|| stricmp(pszArgument, "LOCAL") == 0)
{
return(kParamLocal);
}
else if(stricmp(pszArgument, "B") == 0
|| stricmp(pszArgument, "BPS") == 0
|| stricmp(pszArgument, "BAUD") == 0)
{
return(kParamBPS);
}
else if(stricmp(pszArgument, "P") == 0
|| stricmp(pszArgument, "PORT") == 0)
{
return(kParamPort);
}
else if(stricmp(pszArgument, "N") == 0
|| stricmp(pszArgument, "NODE") == 0)
{
return(kParamNode);
}
else if(stricmp(pszArgument, "?") == 0
|| stricmp(pszArgument, "H") == 0
|| stricmp(pszArgument, "HELP") == 0)
{
return(kParamHelp);
}
else if(stricmp(pszArgument, "PERSONALITY") == 0)
{
return(kParamPersonality);
}
else if(stricmp(pszArgument, "MAXTIME") == 0)
{
return(kParamMaxTime);
}
else if(stricmp(pszArgument, "ADDRESS") == 0)
{
return(kParamAddress);
}
else if(stricmp(pszArgument, "IRQ") == 0)
{
return(kParamIRQ);
}
else if(stricmp(pszArgument, "NOFOSSIL") == 0)
{
return(kParamNoFOSSIL);
}
else if(stricmp(pszArgument, "NOFIFO") == 0)
{
return(kParamNoFIFO);
}
else if(stricmp(pszArgument, "DROPFILE") == 0)
{
return(kParamDropFile);
}
else if(stricmp(pszArgument, "USERNAME") == 0)
{
return(kParamUserName);
}
else if(stricmp(pszArgument, "TIMELEFT") == 0)
{
return(kParamTimeLeft);
}
else if(stricmp(pszArgument, "SECURITY") == 0)
{
return(kParamSecurity);
}
else if(stricmp(pszArgument, "LOCATION") == 0)
{
return(kParamLocation);
}
else
{
return(kParamUnknown);
}
}
void NoDoorFileHandler(void)
{
/* Alter OpenDoors behaviour, so that we proceed with defaults if */
/* no door information file is available, rather than exiting with */
/* an error. Set od_no_file_func to point to this function. */
if(strlen(od_control.user_name) == 0)
{
strcpy(od_control.user_name, "Unknown User");
}
if(strlen(od_control.user_location) == 0)
{
strcpy(od_control.user_location, "Unknown Location");
}
if(od_control.user_timelimit == 0)
{
od_control.user_timelimit = 30;
}
od_control.od_info_type = CUSTOM;
}

View File

@@ -0,0 +1,5 @@
#ifndef INC_CMDLINE
#define INC_CMDLINE
void ParseStandardCommandLine(int nArgCount, char *papszArguments[]);
void NoDoorFileHandler(void);
#endif

352
deps/odoors/historic/odtips3/FILEVIEW.C vendored Normal file
View File

@@ -0,0 +1,352 @@
/* fileview.c - File viewing door that demonstrates the use of the */
/* PagedViewer() function. This door can be setup to */
/* to display a single text file, or any file from an */
/* entire directory of text files. The program accepts */
/* a single command-line argument, which if present, */
/* specifies the filename or wildcard of the files to */
/* display. If this argument is not present, all files */
/* in the current directory will be available for */
/* viewing. If there is more than one possible file to */
/* be displayed, this program will display a list of */
/* files that the user can choose from to display. If */
/* there is only one possible file, that file is */
/* is displayed. This program uses PagedViewer() for two */
/* seperate uses - the list of available files, and for */
/* viewing the file itself. */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "bpfind.h"
#include "opendoor.h"
#include "pageview.h"
/* Configurable constants. */
#define FILENAME_SIZE 75
#define PATH_CHARS (FILENAME_SIZE - 13)
#define LINE_SIZE 80
#define ARRAY_GROW_SIZE 20
/* Global variables. */
int nTotalFiles = 0;
int nFileArraySize = 0;
char *paszFileArray = NULL;
FILE *pfCurrentFile;
int nTotalLines = 0;
int nLineArraySize = 0;
long *palLineOffset = NULL;
/* Function prototypes. */
void AddFilesMatching(char *pszFileSpec);
char *GetFilename(int nIndex);
int AddFilename(char *pszFilename);
void GetDirOnly(char *pszOutDirName, const char *pszInPathName);
int DirExists(const char *pszDirName);
void BuildPath(char *pszOut, char *pszPath, char *pszFilename);
void FreeFileList(void);
void DisplayFileName(int nLine, void *pCallbackData);
void DisplayFile(char *pszFilename);
void DisplayFileLine(int nLine, void *pCallbackData);
int AddOffsetToArray(long lOffset);
void FreeLineArray(void);
/* Program execution begins here. */
int main(int nArgCount, char *papszArgument[])
{
int nArg;
int nChoice;
od_init();
/* Get file specifiction from command-line, if any. */
if(nArgCount >= 2)
{
for(nArg = 1; nArg < nArgCount; ++nArg)
{
AddFilesMatching(papszArgument[nArg]);
}
}
/* If there are no command-line parameters, use *.* */
else
{
AddFilesMatching("*.*");
}
/* If there are no matching files, display error. */
if(nTotalFiles == 0)
{
od_printf("No files were found.\n\r\n\r");
od_printf("Press [Enter] to continue.\n\r");
od_get_answer("\n\r");
return(0);
}
/* If only one file was found, then display it. */
else if(nTotalFiles == 1)
{
DisplayFile(GetFilename(0));
}
/* If more than one file was found, allow user to choose file */
/* to display. */
else
{
/* Loop until user chooses to quit. */
nChoice = 0;
for(;;)
{
/* Get user's selection. */
nChoice = PagedViewer(nChoice, nTotalFiles, DisplayFileName,
NULL, TRUE, "Choose A File To Display", 19);
/* If user chose to quit, then exit door. */
if(nChoice == NO_LINE) break;
/* Otherwise, display the file that the user chose. */
DisplayFile(GetFilename(nChoice));
}
}
FreeFileList();
return(0);
}
void AddFilesMatching(char *pszFileSpec)
{
struct ffblk DirEntry;
int bNoMoreFiles;
char szDirName[PATH_CHARS + 1];
char szFileName[FILENAME_SIZE];
/* Check that file specification is not too long. */
if(strlen(pszFileSpec) > PATH_CHARS)
{
return;
}
/* Get directory name from path. */
GetDirOnly(szDirName, pszFileSpec);
bNoMoreFiles = findfirst(pszFileSpec, &DirEntry, FA_RDONLY);
while(!bNoMoreFiles)
{
BuildPath(szFileName, szDirName, DirEntry.ff_name);
AddFilename(szFileName);
bNoMoreFiles = findnext(&DirEntry);
}
}
void GetDirOnly(char *pszOutDirName, const char *pszInPathName)
{
char *pchBackslashChar;
/* Default dir name is entire path. */
strcpy(pszOutDirName, pszInPathName);
/* If there is a backslash in the string. */
pchBackslashChar = strrchr(pszOutDirName, '\\');
if(pchBackslashChar != NULL)
{
/* Remove all character beginning at last backslash from path. */
*pchBackslashChar = '\0';
}
else
{
/* If there is no backslash in the filename, then the dir name */
/* is empty. */
pszOutDirName[0] = '\0';
}
}
void BuildPath(char *pszOut, char *pszPath, char *pszFilename)
{
/* Copy path to output filename. */
strcpy(pszOut, pszPath);
/* Ensure there is a trailing backslash. */
if(strlen(pszOut) > 0 && pszOut[strlen(pszOut) - 1] != '\\')
{
strcat(pszOut, "\\");
}
/* Append base filename. */
strcat(pszOut, pszFilename);
}
char *GetFilename(int nIndex)
{
return(paszFileArray + (nIndex * FILENAME_SIZE));
}
int AddFilename(char *pszFilename)
{
int nNewArraySize;
char *paszNewArray;
char *pszNewString;
/* If array is full, then try to grow it. */
if(nTotalFiles == nFileArraySize)
{
nNewArraySize = nFileArraySize + ARRAY_GROW_SIZE;
if((paszNewArray =
realloc(paszFileArray, nNewArraySize * FILENAME_SIZE)) == NULL)
{
return(FALSE);
}
nFileArraySize = nNewArraySize;
paszFileArray = paszNewArray;
}
/* Get address to place new string at, while incrementing total number */
/* of filenames. */
pszNewString = GetFilename(nTotalFiles++);
/* Copy up to the maximum number of filename characters to the string. */
strncpy(pszNewString, pszFilename, FILENAME_SIZE - 1);
pszNewString[FILENAME_SIZE - 1] = '\0';
return(TRUE);
}
void FreeFileList(void)
{
if(nFileArraySize > 0)
{
free(paszFileArray);
nFileArraySize = 0;
nTotalFiles = 0;
paszFileArray = NULL;
}
}
void DisplayFileName(int nLine, void *pCallbackData)
{
(void)pCallbackData;
od_printf(GetFilename(nLine));
}
void DisplayFile(char *pszFilename)
{
char szLine[LINE_SIZE];
long lnOffset;
/* Clear the screen. */
od_clr_scr();
/* Attempt to open the file. */
pfCurrentFile = fopen(pszFilename, "r");
if(pfCurrentFile == NULL)
{
od_printf("Unable to open file.\n\r\n\r");
od_printf("Press [Enter] to continue.\n\r");
od_get_answer("\n\r");
return;
}
/* Get file offsets of each line and total line count from file. */
for(;;)
{
lnOffset = fTell(pfCurrentFile);
if(fgets(szLine, LINE_SIZE, pfCurrentFile) == NULL) break;
AddOffsetToArray(lnOffset);
}
/* Use PagedViewer() to view the file. */
PagedViewer(0, nTotalLines, DisplayFileLine, NULL, FALSE, NULL, 21);
/* Deallocate array of line offsets. */
FreeLineArray();
/* Close the file. */
fclose(pfCurrentFile);
}
void DisplayFileLine(int nLine, void *pCallbackData)
{
char szLine[LINE_SIZE];
long lnTargetOffset = palLineOffset[nLine];
int nLineLen;
(void)pCallbackData;
/* Move to proper offset in file. */
if(lnTargetOffset != ftell(pfCurrentFile))
{
fseek(pfCurrentFile, lnTargetOffset, SEEK_SET);
}
/* Get line from line. */
if(fgets(szLine, LINE_SIZE, pfCurrentFile) != NULL)
{
/* Remote any trailing CR/LF sequence from line. */
nLineLen = strlen(szLine);
while(nLineLen > 0
&& (szLine[nLineLen - 1] == '\r' || szLine[nLineLen - 1] == '\n'))
{
szLine[--nLineLen] = '\0';
}
/* Display the line on the screen. */
od_disp_str(szLine);
}
}
int AddOffsetToArray(long lOffset)
{
long *palNewArray;
int nNewArraySize;
/* If array is full, then grow it. */
if(nTotalLines == nLineArraySize)
{
nNewArraySize = nLineArraySize + ARRAY_GROW_SIZE;
if((palNewArray =
realloc(palLineOffset, nNewArraySize * sizeof(long))) == NULL)
{
return(FALSE);
}
nLineArraySize = nNewArraySize;
palLineOffset = palNewArray;
}
palLineOffset[nTotalLines++] = lOffset;
return(TRUE);
}
void FreeLineArray(void)
{
if(nLineArraySize > 0)
{
nTotalLines = 0;
nLineArraySize = 0;
free(palLineOffset);
palLineOffset = NULL;
}
}

177
deps/odoors/historic/odtips3/PAGEVIEW.C vendored Normal file
View File

@@ -0,0 +1,177 @@
/* pageview.c - Implementation of the PagedViewer() system. */
#include <string.h>
#include "opendoor.h"
#include "pageview.h"
char bTitleColor = 0x0c;
char bTitleLineColor = 0x04;
char bNumberColor = 0x0a;
char bTextColor = 0x02;
char bPromptColor = 0x0f;
int PagedViewer(
int nInitialLine, /* Zero-based initial line number. */
int nTotalLines, /* Total line count. */
void (*pDisplayCallback)(int nLine, void *pData),
void *pCallbackData, /* Data to pass to callback func. */
BOOL bAllowSelection, /* TRUE if selection is permitted. */
char *pszTitle, /* Title string, or NULL. */
int nPageSize) /* # of lines to display per page. */
{
int nCurrentPage = 0;
int nScreenLine;
int nAbsoluteLine;
char chPressed;
char bCanPageDown;
char bCanPageUp;
/* Determine current page from initial line number, if specified. */
if(nInitialLine != NO_LINE)
{
nCurrentPage = nInitialLine / nPageSize;
}
/* Loop until user makes a selection, or chooses to quit. */
for(;;)
{
/* Display the current page. */
/* Clear the screen */
od_printf("\n\r");
od_clr_scr();
/* If a title has been specified, then display it. */
if(pszTitle != NULL)
{
od_set_attrib(bTitleColor);
od_repeat(' ', (80 - strlen(pszTitle)) / 2);
od_disp_str(pszTitle);
od_printf("\n\r");
od_set_attrib(bTitleLineColor);
if(od_control.user_ansi || od_control.user_avatar)
{
od_repeat(196, 79);
}
else
{
od_repeat('-', 79);
}
od_printf("\n\r");
}
/* Display the lines on this page. */
nAbsoluteLine = nCurrentPage * nPageSize;
nScreenLine = 0;
while(nScreenLine < nPageSize && nAbsoluteLine < nTotalLines)
{
/* If selection is permitted, display an identifier for each line. */
if(bAllowSelection)
{
od_set_attrib(bNumberColor);
if(nScreenLine < 9)
{
od_printf("%d. ", nScreenLine + 1);
}
else
{
od_printf("%c. ", 'A' + (nScreenLine - 9));
}
}
/* Display the line itself. */
od_set_attrib(bTextColor);
(*pDisplayCallback)(nAbsoluteLine, pCallbackData);
od_printf("\n\r");
/* Move to next line. */
nScreenLine++;
nAbsoluteLine++;
}
/* Determine whether user can page up or down from this page. */
bCanPageDown = nCurrentPage < (nTotalLines - 1) / nPageSize;
bCanPageUp = nCurrentPage > 0;
/* Display prompt at bottom of screen. */
od_set_attrib(bPromptColor);
od_printf("\n\r[Page %d of %d] ", nCurrentPage + 1,
((nTotalLines - 1) / nPageSize) + 1);
if(bAllowSelection)
{
od_printf("Choose an option or");
}
else
{
od_printf("Available options:");
}
if(bCanPageDown)
{
od_printf(" [N]ext page,");
}
if(bCanPageUp)
{
od_printf(" [P]revious page,");
}
od_printf(" [Q]uit.");
/* Loop until the user makes a valid choice. */
for(;;)
{
/* Get key from user */
chPressed = toupper(od_get_key(TRUE));
if(chPressed == 'Q')
{
/* If user chooses to quit, then return without a selection. */
od_printf("\n\r");
return(NO_LINE);
}
else if(chPressed == 'P' && bCanPageUp)
{
/* Move to previous page and redraw screen. */
--nCurrentPage;
break;
}
else if(chPressed == 'N' && bCanPageDown)
{
/* Move to next page and redraw screen. */
++nCurrentPage;
break;
}
else if(bAllowSelection
&& (
(chPressed >= '1' && chPressed <= '9')
|| (chPressed >= 'A' && chPressed <= 'M')
)
)
{
/* If user pressed a possible line key, and selection is */
/* enabled, try translating character to a line number. */
if(chPressed >= '1' && chPressed <= '9')
{
nScreenLine = chPressed - '1';
}
else
{
nScreenLine = 9 + (chPressed - 'A');
}
/* Calculate absolute line number. */
nAbsoluteLine = nScreenLine + (nCurrentPage * nPageSize);
/* If selected line is within range, then return selected line */
/* number. */
if(nScreenLine < nPageSize && nAbsoluteLine < nTotalLines)
{
od_printf("\n\r");
return(nAbsoluteLine);
}
}
}
}
}

19
deps/odoors/historic/odtips3/PAGEVIEW.H vendored Normal file
View File

@@ -0,0 +1,19 @@
/* pageview.h - Include file for PagedViewer() function. */
/* Manifest constant. */
#define NO_LINE -1
/* Boolean definitions. */
#ifndef BOOL
typedef int BOOL;
#endif
/* Prototype for the function. */
int PagedViewer(
int nInitialLine,
int nTotalLines,
void (*pDisplayCallback)(int nLine, void *pCallbackData),
void *pCallbackData,
BOOL bAllowSelection,
char *pszTitle,
int nPageSize);

View File

@@ -0,0 +1,46 @@
OpenDoors tips package #3
---
(C) Copyright 1994, Brian Pirie. All Rights Reserved.
This package includes a collection of tips and utility functions to help
those using the OpenDoors door programming toolkit. You are free to use
these tips and included source code as you wish, without any fee or
royalty.
This package includes the following tip files:
Tip #1. Drawing horizontal bar graphs using od_repeat().
Files: tip1.txt, tip1.c
Tip #2. Transferring files using DSZ.
Files: tip2.txt, tip2.c
Tip #3. A generic paged viewing / selection routine, and text file
viewing door that uses the paged viewing routine.
Files: tip3.txt, pageview.c, pageview.h, fileview.c, bpfind.h
Tip #4. Command-line processing for many standard door-related command
line options.
Files: tip4.txt,tip4.c, cmdline.c, cmdline.h
How to contact the author
-------------------------
I can be reached by any of the following means:
Internet email : brianp@bpecomm.ocunix.on.ca
Fidonet Crashmail : 1:243/8 (you must poll for a response)
Modem (24hrs/day) : +1 613 526 4466
Conventional mail : Brian Pirie
#1416 - 2201 Riverside Drive
Ottawa, Ontario
K1H 8K9
Canada

88
deps/odoors/historic/odtips3/TIP1.C vendored Normal file
View File

@@ -0,0 +1,88 @@
/* Includes */
#include "opendoor.h"
/* Function prototypes. */
void DrawHorizontalBar(int nValue, int nMinValue, int nMaxValue,
int nMaxChars);
void DrawGraphOfPercentages(int nItems, int *panPercentages,
char **papszTitles, char bTitleColor, char bGraphColor,
int nTitleWidth, int nGraphWidth);
/* Main function - program execution begins here. */
main()
{
char *apszTitles[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
int anValues[7] = {50, 75, 100, 25, 83, 0, 43};
od_printf("`bright green`Test graph:\n\r");
DrawGraphOfPercentages(7, anValues, apszTitles, 0x02, 0x0f, 20, 50);
od_get_key(TRUE);
return(0);
}
/* Function to draw horizontal graph of percentages with titles, to */
/* demonstrate the use of the DrawHorizontalBar() function. */
/* No titles should have more than nTitleWidth characters. */
void DrawGraphOfPercentages(int nItems, int *panPercentages,
char **papszTitles, char bTitleColor, char bGraphColor,
int nTitleWidth, int nGraphWidth)
{
int nCurrentItem;
/* Loop for each item (line) in the graph. */
for(nCurrentItem = 0; nCurrentItem < nItems; ++nCurrentItem)
{
/* Set display color for title text. */
od_set_attrib(bTitleColor);
/* Add spaces to right-align all titles. */
od_repeat(' ', nTitleWidth - strlen(papszTitles[nCurrentItem]));
/* Display the title. */
od_disp_str(papszTitles[nCurrentItem]);
/* Add space between title and graph. */
od_printf(" ");
/* Set display color for graph. */
od_set_attrib(bGraphColor);
/* Draw bar graph for this line. */
DrawHorizontalBar(panPercentages[nCurrentItem], 0, 100, nGraphWidth);
/* Move to the next line. */
od_printf("\n\r");
}
}
/* Function to draw a horizontal bar, given a value, the minimum and maximum */
/* possible values, and the number of characters the horizontal bar should */
/* extended for the maximum value. */
void DrawHorizontalBar(int nValue, int nMinValue, int nMaxValue,
int nMaxChars)
{
/* Determine lenght of bar */
int nBarChars = ((nValue - nMinValue) * nMaxChars) / nMaxValue;
if(od_control.user_ansi || od_control.user_avatar)
{
/* If ANSI or AVATAR graphics are available, assume that IBM extended */
/* ASCII is also available. This function uses character 220 to form */
/* bars that are 1/2 the height of the line. You might also want to */
/* try character 119, which will form bars that are the entire height */
/* of the line. */
od_repeat(220, nBarChars);
}
else
{
/* In ASCII mode, the bar is formed by the '=' character. */
od_repeat('=', nBarChars);
}
}

55
deps/odoors/historic/odtips3/TIP1.TXT vendored Normal file
View File

@@ -0,0 +1,55 @@
Many different types of programs can be enhanced by the use of graphical
information. Often, this graphical information can take the form of
horizontal bar graphs.
An easy way to draw horizontal bars in door programs written with
OpenDoors, is to use the od_repeat() function. Not only does od_repeat()
allow you to easily form a bar by repeating a particular character the
specified number of times, but it is also a very efficient way to do so.
od_repeat() will take advantage of terminal emulation optimizations,
when available. For instance, a character can be repeated any number of
times with AVATAR by sending a short 3-byte sequence that specifies the
character and number of times to repeat.
How do you calculate the number of character to use to form a bar in
your graph? The DrawHorizontalBar() function, which is provided below,
will do this calculation for you. Simply provide the value to be
represented by this bar, the minimum and maximum possible values, and
the maximum number of character to use to draw the bar. For example, if
you are graphing percentages (which could range from 0% to 100%), and
wanted the graph to fit in a space of 40 columns, you would use:
DrawHorizontalBar(nPercent, 0, 100, 40);
The included tip1.c is a complete program which demonstrates the
DrawHorizontalBar() function as called from another function that will
create complete horizontal bar graphs. This second function,
DrawGraphOfPercentages(), takes an array of titles, and array of values
corresponding to each title, and draws a complete bar graph from this
information.
/* Function to draw a horizontal bar, given a value, the minimum and maximum */
/* possible values, and the number of characters the horizontal bar should */
/* extended for the maximum value. */
void DrawHorizontalBar(int nValue, int nMinValue, int nMaxValue,
int nMaxChars)
{
/* Determine lenght of bar */
int nBarChars = ((nValue - nMinValue) * nMaxChars) / nMaxValue;
if(od_control.user_ansi || od_control.user_avatar)
{
/* If ANSI or AVATAR graphics are available, assume that IBM extended */
/* ASCII is also available. This function uses character 220 to form */
/* bars that are 1/2 the height of the line. You might also want to */
/* try character 119, which will form bars that are the entire height */
/* of the line. */
od_repeat(220, nBarChars);
}
else
{
/* In ASCII mode, the bar is formed by the '=' character. */
od_repeat('=', nBarChars);
}
}

245
deps/odoors/historic/odtips3/TIP2.C vendored Normal file
View File

@@ -0,0 +1,245 @@
/* tip2.c - Example program to demonstrate how to send or receive files */
/* using DSZ, from within an OpenDoors program. */
/* Include required header files. */
#include <stdio.h>
#include <assert.h>
#include "opendoor.h"
/* File transfer protocol enumeration. */
typedef enum
{
XModem,
XModemCRC,
XModem1K,
YModem,
YModemG,
ZModem
} eProtocol;
/* Function prototypes. */
int TransferFile(char *pszFilename, eProtocol Protocol, char bReceive);
eProtocol ChooseProtocol(void);
void AddParameter(char **papszArguments, int *pnCount, char *pszNewArgument);
/* Manifest constants. */
#define ARGS_ARRAY_SIZE 10
/* Global variable with DSZ filename. */
char szDSZFilename[80] = "DSZ";
/* Program's execution begins here. */
main()
{
char chAnswer;
char bReceive;
eProtocol Protocol;
char szFilename[73];
int bSuccess;
od_printf("OpenDoors file transfer demo.\n\r\n\r");
/* Get file transfer direction from user. */
od_printf("Do you wish to [U]pload or [D]ownload? ");
chAnswer = od_get_answer("UD");
if(chAnswer == 'U')
{
od_printf("Upload\n\r\n\r");
bReceive = TRUE;
}
else
{
od_printf("Download\n\r\n\r");
bReceive = FALSE;
}
/* Get file transfer protocol from user. */
Protocol = ChooseProtocol();
/* Get filename. */
od_printf("\n\rEnter filename(s) : ");
od_input_str(szFilename, 72, ' ', 255);
od_printf("\n\r");
/* Perform file transfer. */
bSuccess = TransferFile(szFilename, Protocol, bReceive);
/* Display result of file transfer to user. */
od_clr_scr();
if(bSuccess)
{
od_printf("File transfer successful.\n\r");
}
else
{
od_printf("File transfer not completed.\n\r");
}
/* Prompt user to exit program. */
od_printf("Press [Enter] to return to BBS.\n\r");
od_get_answer("\n\r");
/* Return control to calling BBS software. */
od_exit(0, FALSE);
return(0);
}
/* Function to allow user to choose a file transfer protocol. */
eProtocol ChooseProtocol(void)
{
eProtocol Protocol;
char chAnswer;
od_printf("Available file transfer protocols:\n\r");
od_printf(" [X] XModem\n\r");
od_printf(" [C] XModem/CRC\n\r");
od_printf(" [1] XModem/1K\n\r");
od_printf(" [Y] YModem\n\r");
od_printf(" [G] YModem-G\n\r");
od_printf(" [Z] ZModem\n\r\n\r");
od_printf("Please select a protocol: ");
chAnswer = od_get_answer("XC1YGZ");
switch(chAnswer)
{
case 'X':
od_printf("XModem\n\r");
Protocol = XModem;
break;
case 'C':
od_printf("XModem/CRC\n\r");
Protocol = XModemCRC;
break;
case '1':
od_printf("XModem/1K\n\r");
Protocol = XModem1K;
break;
case 'Y':
od_printf("YModem\n\r");
Protocol = YModem;
break;
case 'G':
od_printf("YModem-G\n\r");
Protocol = YModemG;
break;
case 'Z':
default:
od_printf("ZModem\n\r");
Protocol = ZModem;
break;
}
return(Protocol);
}
/* Function to send or receive a file to/from remote system. */
int TransferFile(char *pszFilename, eProtocol Protocol, char bReceive)
{
char szPort[7];
char *apszArguments[ARGS_ARRAY_SIZE];
int nArgCount = 0;
/* Filename cannot be NULL. */
assert(pszFilename != NULL);
/* Ensure that we are not operating in local mode. */
if(od_control.baud == 0)
{
od_printf("Operating in local mode; file transfer not possible.\n\r");
return(FALSE);
}
/* Generate DSZ command line */
/* Begin with executable filename. */
AddParameter(apszArguments, &nArgCount, szDSZFilename);
/* Add port parameter. */
AddParameter(apszArguments, &nArgCount, "port");
sprintf(szPort, "%d", od_control.port + 1);
AddParameter(apszArguments, &nArgCount, szPort);
/* Restrict inbound files to current drive and directory. */
AddParameter(apszArguments, &nArgCount, "restrict");
/* Generate DSZ protocol parameters from specified protocol and direction. */
if(bReceive)
{
switch(Protocol)
{
case XModem:
case XModem1K:
AddParameter(apszArguments, &nArgCount, "rx");
break;
case XModemCRC:
AddParameter(apszArguments, &nArgCount, "rc");
break;
case YModem:
AddParameter(apszArguments, &nArgCount, "rb");
break;
case YModemG:
AddParameter(apszArguments, &nArgCount, "rb");
AddParameter(apszArguments, &nArgCount, "-g");
break;
case ZModem:
AddParameter(apszArguments, &nArgCount, "rz");
break;
default:
assert(FALSE);
}
}
else
{
switch(Protocol)
{
case XModem:
case XModemCRC:
AddParameter(apszArguments, &nArgCount, "sx");
break;
case XModem1K:
AddParameter(apszArguments, &nArgCount, "sx");
AddParameter(apszArguments, &nArgCount, "-k");
break;
case YModem:
case YModemG:
AddParameter(apszArguments, &nArgCount, "sb");
break;
case ZModem:
AddParameter(apszArguments, &nArgCount, "sz");
break;
default:
assert(FALSE);
}
}
/* Add filename parameter to command line. */
AddParameter(apszArguments, &nArgCount, pszFilename);
/* Display prompt to user providing */
od_printf("Begin your transfer now, or press [Ctrl]-[X] several times to abort.\n\r");
/* Execute command using the OpenDoors od_spawn() function. */
return(od_spawnvpe(P_WAIT, apszArguments[0], apszArguments, NULL) == 0);
}
/* Function to add next parameter to array of parameters to pass to */
/* od_spawnvpe(). */
void AddParameter(char **papszArguments, int *pnCount, char *pszNewArgument)
{
assert(*pnCount < ARGS_ARRAY_SIZE - 1);
assert(papszArguments != NULL);
assert(pnCount != NULL);
assert(pszNewArgument != NULL);
/* Add next argument to array. */
papszArguments[(*pnCount)++] = pszNewArgument;
/* Ensure that the array is always NULL-terminated. */
papszArguments[*pnCount] = NULL;
}

45
deps/odoors/historic/odtips3/TIP2.TXT vendored Normal file
View File

@@ -0,0 +1,45 @@
Often, it can be useful or necessary to send and receive files between
a program using OpenDoors, and the remote user's system. To allow file
uploading and downloadeding, you can either implement the common file
transfer protocols as part of your program, or you can call an external
file transfer program, such as DSZ. This tip demonstrates how you can
call DSZ using OpenDoors.
In order to see this program in action, you should run a terminal
program on one machine, and connect to second machine that will run this
example program. (You could also do this in two different windows on one
machine.) The demonstration program will ask whether you want to upload
or download files, and will then prompt you for the file transfer protocol
to use and the filename to transfer. Once this is done, DSZ is invoked
to perform the file transfer. As such, DSZ will need to be installed on
the machine that will run the example program.
The tip2.c source file provides a function that you can use to perform
file transfers. This function is defined as follows:
int TransferFile(char *pszFilename, eProtocol Protocol, char bReceive)
The first parameter should contain the name of the file or files to be
transfered. The second parameter should specify the file transfer
protocol to use, and should be one of the following enumerated
constants:
XModem
XModemCRC
XModem1K
YModem
YModemG
ZModem
The third parameter specifies whether the file is being send (FALSE) or
received (TRUE). From the user's perspective, sending the file means
downloading, and receiving the file means uploading.
The TransferFile() function returns TRUE if the file transfer was
completed, and FALSE if it was not.
If the DSZ program is not present in the system's PATH or the current
directory, then the global variable szDSZFilename must be set to the
full path and filename of the DSZ program. This could be done by adding
a custom OpenDoors configuration file line with a keyword such as
"DSZPath".

82
deps/odoors/historic/odtips3/TIP3.TXT vendored Normal file
View File

@@ -0,0 +1,82 @@
Many people have admired the paged question selection facility in the
OpenDoors 5.00 EZVote example door. EZVote allows the user to choose
questions from a list of up to 200 questions, by displaying one page
of questions at a time. The user is able to page up or down in the list
of quesitons, select a question from the list, or return to the main
menu. A prompt at the bottom of the screen shows the current page
number, and a list of options that are currently available. For
instance, when displaying the first of two pages, this prompt indicates
that the user can move to the next page, but not the previous page.
This OpenDoors Tip shows a generic function that provides the same sorts
of capabilities that are seen in the EZVote example door, in a form that
can be re-used in many different programs. This function, named
PagedViewer(), can be used for displaying multi-paged messages, text
files, or for permitting selection from a potentially very long list of
items. To use the PagedViewer() in a program, you should add the
pageview.c file to your project file / makefile, and #include the
pageview.h file in any source file that calls PagedViewer().
The prototype for the PagedViewer() function is as follows:
int PagedViewer(
int nInitialLine,
int nTotalLines,
void (*pDisplayCallback)(int nLine, void *pCallbackData),
void *pCallbackData,
BOOL bAllowSelection,
char *pszTitle,
int nPageSize);
The nInitialLine parameter specifies the line to begin viewing at.
Normally this would be 0, but you may wish to pass a different value to
this function to force the viewer to begin on a page other than the
first. Using this parameter, you can have the user return to
the page they were previously viewing, rather than returning to the
first page and having to again find their original location.
The nTotalLines parameter specifies the total number of lines that can
be viewed, and can be any value greater than or equal to 0.
The pDisplayCallback parameter must be a pointer to a function that the
PagedViewer will call to display a particular line of the file at the
current location. When PagedViewer() calls your function, it will pass
the line number to be displayed, along with the value originally passed
to PagedViewer() in pCallbackData. The provided function should simply
display the text for the specified line number, without a trailing CR/LF
sequence, and then return.
The pCallbackData can point to any data that you wish PagedViewer() to
pass to your callback function, or may be NULL if you do not wish to use
this feature.
The bAllowSelection parameter should be TRUE if the user should be able
to make a selection from the list, and FALSE if they should not. If
bAllowSelection is TRUE, PagedViewer() will display a letter beside each
line, and allow the user to select a line by pressing the corresponding
letter. If you are using PagedViewer() to display a text file or
message, you will want to set bAllowSelection to FALSE. If you are using
PagedViewer() to display a list of items from which the user can select,
you will want to set bAllowSelection to TRUE.
The pszTitle parameter can point to a title to be displayed at the top
of each page, and could be something like ("Select a message"). If you
do not wish to have a title displayed, set this parameter to NULL.
The nPageSize parameter specifies the number of lines that should be
displayed on each page. If you do not wish to have the local screen
(with a two line status line) to be scrolled while displaying the list,
the maximum page size you should use is 21 if no title is being
displayed, and 19 if a title is being displayed.
The included fileview.c text file viewing program demonstrates the use
of PagedViewer(). The fileview.c door can be setup to allow the user to
view one or more files. If setup to view multiple files, the program
first displays a list of files that the user can select to view.
The fileview.c program uses PagedViewer() in two places - for providing
the list of files and for displaying the file itself. As such, the user
can page up or down in the list of files, select a file to view, and
then page up or down in the file. When the user selects quit while
viewing the file, they are returned to the list of files to possibly
select another file. When the user selects quit from the list of files,
the door returns control to the calling BBS software.

19
deps/odoors/historic/odtips3/TIP4.C vendored Normal file
View File

@@ -0,0 +1,19 @@
#include "opendoor.h"
#include "cmdline.h"
int main(int argc, char *argv[])
{
/* Set function to be called if no door information file is found. */
od_control.od_no_file_func = NoDoorFileHandler;
/* Call command-line processing function before first call to any */
/* OpenDoors function! */
ParseStandardCommandLine(argc, argv);
/* Proceed with door normally. */
od_printf("Hello World!\n\r\n\r");
od_printf("Press [Enter] to return to BBS.\n\r");
od_get_answer("\n\r");
return(0);
}

50
deps/odoors/historic/odtips3/TIP4.TXT vendored Normal file
View File

@@ -0,0 +1,50 @@
It is common for BBS door programs to accept command line parameters
that permit various door-related settings, such as the serial port, baud
rate, and node number. This tip demonstrates how you can do this when
working with OpenDoors. This tip is presented in the following files:
cmdline.h - Header file for command line processing function.
cmdline.c - Implementation of command line processing function.
tip4.c - Example of a program that uses the command line
processing function.
The cmdline.c module implements the ParseStandardCommandLine() function,
which takes as its parameters the same argc and argv parameters that are
passed to the main() function of any C program. The
ParseStandardCommandLine() function then sets the appropriate OpenDoors
settings based on the following optional command-line parameters:
-L or -LOCAL - Causes door to operate in local mode, without
requiring a door information (drop) file.
-B x or -BPS x - Sets the bps (baud) rate to use.
-P x or -PORT x - Sets the serial port to use, were 0=COM1, 1=COM2,
etc.
-N x or -NODE x - Sets the node number to use.
-?, -H or -HELP - Displays command-line help and exits
-PERSONALITY x - Sets the sysop status line / function key
personality to use.
-MAXTIME x - Sets the maximum number of minutes that any
user will be permitted to access the door.
-ADDRESS x - Sets serial port address, to be used if FOSSIL
driver is not being used.
-IRQ x - Sets the serial port IRQ line, to be used if
FOSSIL driver is not being used.
-NOFOSSIL - Disables use of FOSSIL driver, even if it is
present.
-NOFIFO - Disables use of 16550 FIFO buffers (only if
FOSSIL driver is not being used).
-DROPFILE x - Door information file directory or
directory+filename.
-USERNAME x - Name of user who is currently online.
-TIMELEFT x - User's time remaining online.
-SECURITY x - User's security level.
-LOCATION x - Location from which user is calling.
Note that any information that is available from the door information
file overrides information provided on the command-line. If sufficient
parameters are provided on the command-line, the door can be operated
without a door information file. In order to do this, cmdline.c provides
a callback function that you can hook into od_control.od_no_file_func,
as demonstrated in tip4.c.
Case is not sensitive in the names of command line arguments.