Added bbs menu 221, display area rules

This commit is contained in:
Michiel Broek
2003-02-07 20:49:01 +00:00
parent c481073937
commit b968d11074
18 changed files with 258 additions and 134 deletions

View File

@@ -174,7 +174,7 @@ mbnewusr.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/str
input.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h input.h timeout.h language.h
whoson.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h input.h language.h exitinfo.h whoson.h
door.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h input.h timeout.h exitinfo.h whoson.h door.h
dispfile.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h funcs.h language.h oneline.h misc.h timeout.h timecheck.h exitinfo.h mail.h email.h dispfile.h
dispfile.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msgtext.h ../lib/msg.h ../lib/clcomm.h funcs.h language.h oneline.h misc.h timeout.h timecheck.h exitinfo.h mail.h email.h input.h dispfile.h
userlist.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h userlist.h language.h input.h timeout.h
timestats.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h timestats.h funcs.h language.h input.h exitinfo.h
logentry.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h logentry.h

View File

@@ -48,6 +48,7 @@
#include "exitinfo.h"
#include "mail.h"
#include "email.h"
#include "input.h"
#include "dispfile.h"
@@ -85,6 +86,129 @@ int TotalUsers(void)
/*
* Function will display a aras rulefile to the user.
* Searches in rules directory first for a file with
* the full name of the area, then the fule name of the
* area with a .rul suffix, and finally for the first
* 8 characters of the areaname with a .rul suffix.
* The search is case insensitive.
*
* Menu 221.
*/
void DisplayRules(void)
{
DIR *dp;
struct dirent *de;
int Found = FALSE;
char temp[128];
if ((dp = opendir(CFG.rulesdir)) == NULL) {
WriteError("$Can't open directory %s", CFG.rulesdir);
/* Can't open directory for listing: */
printf("\n%s\n\n", (char *) Language(290));
Pause();
return;
}
while ((de = readdir(dp))) {
if (de->d_name[0] != '.') {
strcpy(temp, msgs.Tag);
if (strcasecmp(de->d_name, temp) == 0) {
Found = TRUE;
sprintf(temp, "%s/%s", CFG.rulesdir, de->d_name);
break;
}
sprintf(temp, "%s.rul", temp);
if (strcasecmp(de->d_name, temp) == 0) {
Found = TRUE;
sprintf(temp, "%s/%s", CFG.rulesdir, de->d_name);
break;
}
memset(&temp, 0, sizeof(temp));
strncpy(temp, msgs.Tag, 8);
sprintf(temp, "%s.rul", temp);
if (strcasecmp(de->d_name, temp) == 0) {
Found = TRUE;
sprintf(temp, "%s/%s", CFG.rulesdir, de->d_name);
break;
}
}
}
closedir(dp);
if (Found) {
Syslog('+', "Display rules: %s", temp);
DisplayTextFile(temp);
} else {
Syslog('+', "Display rules for %s failed, not found", msgs.Tag);
Enter(1);
colour(LIGHTRED, BLACK);
/* No rules found for this area */
printf("\n%s\n\n", (char *) Language(13));
Pause();
}
}
/*
* Function will display a flat ascii textfile to the
* user without control codes. This is used to display
* area rules, but is also called from the menu function
* that will display a textfile or the contents of a archive.
*/
int DisplayTextFile(char *filename)
{
FILE *fp;
char *buf;
int i, x, c, lc = 0;
if ((fp = fopen(filename, "r")) == NULL) {
WriteError("$DisplayTextFile(%s) failed");
return FALSE;
}
buf = calloc(81, sizeof(char));
clear();
colour(CFG.TextColourF, CFG.TextColourB);
while (fgets(buf, 79, fp)) {
i = strlen(buf);
for (x = 0; x < i; x++) {
c = (*(buf + x));
if (isprint(c))
printf("%c", c);
}
printf("\n");
fflush(stdout);
lc++;
if (lc == exitinfo.iScreenLen) {
Pause();
lc = 0;
colour(CFG.TextColourF, CFG.TextColourB);
}
}
fclose(fp);
free(buf);
Enter(1);
/* Press ENTER to continue */
language(LIGHTMAGENTA, BLACK, 436);
fflush(stdout);
fflush(stdin);
alarm_on();
Getone();
return TRUE;
}
/*
* Function will display textfile in either ansi or ascii and
* display control codes if they exist.

View File

@@ -1,8 +1,11 @@
/* $Id$ */
#ifndef _DISPLAYFILE_H
#define _DISPLAYFILE_H
/* $Id$ */
void DisplayRules(void); /* Display area rules */
int DisplayTextFile(char *); /* Display a flat textfile */
int DisplayFile(char *); /* Display .ans/.asc textfile */
int DisplayFileEnter(char *); /* Display .ans/.asc wait for Enter */
void ControlCodeF(int); /* Check Control Codes in File */

View File

@@ -2213,7 +2213,7 @@ void EditTaglist()
/*
* View a file in the current area.
* View a file in the current area, menu 103.
*/
void ViewFile()
{

View File

@@ -79,13 +79,13 @@ int MenuError;
void InitMenu()
{
int i;
int i;
for (i = 0; i < 50; i++)
memset(Menus[i], 0, 51);
MenuLevel = 0;
MenuError = 0;
sprintf(Menus[0], "%s", CFG.default_menu);
for (i = 0; i < 50; i++)
memset(Menus[i], 0, 51);
MenuLevel = 0;
MenuError = 0;
sprintf(Menus[0], "%s", CFG.default_menu);
}
@@ -252,20 +252,16 @@ void menu()
void DoMenu(int Type)
{
int Strlen, i, x;
char *DisplayF;
char *sPrompt;
char *sPromptBak;
char *temp;
int Strlen, i, x;
char *sPrompt, *sPromptBak, *temp;
DisplayF = calloc(81, sizeof(char));
sPrompt = calloc(81, sizeof(char));
sPromptBak = calloc(81, sizeof(char));
temp = calloc(81, sizeof(char));
sPrompt = calloc(81, sizeof(char));
sPromptBak = calloc(81, sizeof(char));
temp = calloc(81, sizeof(char));
TimeCheck();
TimeCheck();
switch(Type) {
switch(Type) {
case 0: /* Display Prompt Line Only */
break;
@@ -277,16 +273,16 @@ void DoMenu(int Type)
case 2:
/* Gosub another menu */
if (MenuLevel < 49) {
MenuLevel++;
strncpy(Menus[MenuLevel], menus.OptionalData, 14);
MenuLevel++;
strncpy(Menus[MenuLevel], menus.OptionalData, 14);
} else
Syslog('?', "More than 50 menu levels");
Syslog('?', "More than 50 menu levels");
break;
case 3:
/* Return from gosub */
if (MenuLevel > 0)
MenuLevel--;
MenuLevel--;
break;
case 4:
@@ -302,36 +298,33 @@ void DoMenu(int Type)
case 6:
/* Show menu prompt */
Strlen = strlen(menus.OptionalData);
for(x = 0; x < Strlen; x++) {
if( menus.OptionalData[x] == '~') {
strcat(sPrompt, sUserTimeleft);
} else {
sprintf(temp, "%c", menus.OptionalData[x]);
strcat(sPrompt, temp);
}
for (x = 0; x < Strlen; x++) {
if (menus.OptionalData[x] == '~') {
strcat(sPrompt, sUserTimeleft);
} else {
sprintf(temp, "%c", menus.OptionalData[x]);
strcat(sPrompt, temp);
}
}
strcpy(sPromptBak, sPrompt);
strcpy(sPrompt, "");
Strlen = strlen(sPromptBak);
for(x = 0; x < Strlen; x++) {
if( *(sPromptBak + x) == '@')
strcat(sPrompt, sAreaDesc);
else
if ( *(sPromptBak + x) == '^')
strcat(sPrompt, sMsgAreaDesc);
else
if ( *(sPromptBak + x) == '#')
sprintf(sPrompt, "%s%s", sPrompt, (char *) GetLocalHM());
else {
sprintf(temp, "%c", *(sPromptBak + x));
strcat(sPrompt, temp);
}
for (x = 0; x < Strlen; x++) {
if (*(sPromptBak + x) == '@')
strcat(sPrompt, sAreaDesc);
else if (*(sPromptBak + x) == '^')
strcat(sPrompt, sMsgAreaDesc);
else if (*(sPromptBak + x) == '#')
sprintf(sPrompt, "%s%s", sPrompt, (char *) GetLocalHM());
else {
sprintf(temp, "%c", *(sPromptBak + x));
strcat(sPrompt, temp);
}
}
if (menus.ForeGnd || menus.BackGnd)
pout(menus.ForeGnd, menus.BackGnd, sPrompt);
else
pout(15, 0, sPrompt);
pout(WHITE, BLACK, sPrompt);
break;
case 7:
@@ -366,7 +359,6 @@ void DoMenu(int Type)
case 13:
/* terminate call */
free(DisplayF);
free(sPrompt);
free(sPromptBak);
free(temp);
@@ -381,10 +373,10 @@ void DoMenu(int Type)
case 15:
/* print text to screen */
if (exitinfo.Security.level >= menus.MenuSecurity.level) {
for(i = 0; i < strlen(menus.OptionalData); i++)
if(*(menus.OptionalData + i) == '@')
*(menus.OptionalData + i) = '\n';
printf("%s\n", menus.OptionalData);
for (i = 0; i < strlen(menus.OptionalData); i++)
if (*(menus.OptionalData + i) == '@')
*(menus.OptionalData + i) = '\n';
printf("%s\n", menus.OptionalData);
}
break;
@@ -576,6 +568,10 @@ void DoMenu(int Type)
QuickScan_Email();
break;
case 221:
DisplayRules();
break;
case 301:
Chg_Protocol();
break;
@@ -700,84 +696,79 @@ void DoMenu(int Type)
Pause();
}
free(DisplayF);
free(sPrompt);
free(sPromptBak);
free(temp);
}
void DisplayMenu ( void ) {
/*
* Display the Menu Display Text to the User,
* if the sysop puts a ';' (semicolon) at the end of the menu prompt,
* the CR/LR combination will not be sent
*/
/*
* Display the Menu Display Text to the User,
* if the sysop puts a ';' (semicolon) at the end of the menu prompt,
* the CR/LR combination will not be sent
*/
void DisplayMenu(void)
{
int maxdpos, dpos, escaped, skipCRLF, highlight;
int maxdpos;
int dpos;
int escaped ;
int skipCRLF ;
int highlight ;
/* Anything to process, if not; save CPU time, return */
if (( strlen( menus.Display ) == 0 ) && (menus.MenuType != 21)) {
return;
}
/* Anything to process, if not; save CPU time, return */
if (( strlen( menus.Display ) == 0 ) && (menus.MenuType != 21)) {
return;
}
/* Send Display string, formated with ANSI codes as required */
/* --- basically this with brains: printf("%s\n", menus.Display); */
maxdpos = strlen(menus.Display);
escaped = 0;
skipCRLF = 0;
highlight = 0;
colour( menus.ForeGnd, menus.BackGnd );
for ( dpos = 0; dpos < maxdpos ; dpos++ ){
switch ( menus.Display[ dpos ] ) {
case ';': /* Semicolon, if not escaped and last char, not CRLF at end of line */
if ( ( dpos + 1 ) == maxdpos ) {
skipCRLF=1;
} else {
printf("%c",menus.Display[ dpos ]);
}
break;
case '\\': if ( !escaped ) {
escaped = 1;
} else {
escaped = 0;
printf("%c",menus.Display[ dpos ]);
}
break;
case '^': /* Highlight Toggle */
if ( !escaped ) {
if ( highlight == 0 ) {
highlight = 1;
colour( menus.HiForeGnd, menus.HiBackGnd);
} else {
highlight = 0 ;
colour( menus.ForeGnd, menus.BackGnd );
}
} else {
escaped=0;
printf("%c",menus.Display[ dpos ]);
}
break;
default: /* all other characters */
printf("%c",menus.Display[ dpos ]);
}
}
if ( !skipCRLF ) {
printf("\n");
/* Send Display string, formated with ANSI codes as required */
/* --- basically this with brains: printf("%s\n", menus.Display); */
maxdpos = strlen(menus.Display);
escaped = 0;
skipCRLF = 0;
highlight = 0;
colour( menus.ForeGnd, menus.BackGnd );
for ( dpos = 0; dpos < maxdpos ; dpos++ ){
switch ( menus.Display[ dpos ] ) {
case ';': /* Semicolon, if not escaped and last char, not CRLF at end of line */
if ( ( dpos + 1 ) == maxdpos ) {
skipCRLF=1;
} else {
printf("%c",menus.Display[ dpos ]);
}
break;
case '\\': if ( !escaped ) {
escaped = 1;
} else {
escaped = 0;
printf("%c",menus.Display[ dpos ]);
}
break;
case '^': /* Highlight Toggle */
if ( !escaped ) {
if ( highlight == 0 ) {
highlight = 1;
colour( menus.HiForeGnd, menus.HiBackGnd);
} else {
highlight = 0 ;
colour( menus.ForeGnd, menus.BackGnd );
}
} else {
escaped=0;
printf("%c",menus.Display[ dpos ]);
}
break;
default: /* all other characters */
printf("%c",menus.Display[ dpos ]);
}
}
if ( !skipCRLF ) {
printf("\n");
}
}