Added Ansi/textfile collections

This commit is contained in:
Andrew Pamment 2016-03-27 10:33:43 +10:00
parent 2373391b2e
commit 7c344319ea
5 changed files with 87 additions and 13 deletions

View File

@ -1,15 +1,14 @@
[?7h 
ワワワワワワワワワワワ ワワワワワワ ワワ ワワワワワワ ワワワワワワワワワワワ ワワワワワワワ ワワワワワワ ワワ ワ ワワ ワワワワワワワワワワワ ワワワワワワ ワワ ワワワワワワ ワワワワワワワワワワワ ワワワワワワワ ワワワワワワ ワワ ワ ワワ
イ゚ーワ イ゚ーワ イロイ゚ー イロロロイ゚ーワ イロイ゚ーワ イ゚ーワ イロイ゚ワワ ゚゚ イ゚ーワ イロイ゚ロ ロイ イ゚ーワ イ゚ーワ イロ イ゚ー イロ ロロ イ゚ーワ イロ イ゚ーワ イ゚ーワ イロ イ゚ワワ ゚゚ イ゚ーワ イロ イ゚ ロ ロイ
ーイ イ ーイ イ ア゚ーイ゚゚゚ア゚イイ ーイ イ ア゚ーイ イ ーイ イ ア゚アイワー イ゚ーイ イ ア゚ーイワ゚ イ  ーイ イ ーイ イ ア゚ ーイ゚゚゚ア゚ イイ ーイ イ ア゚ ーイ イ ーイ イ ア゚ アイワー イ゚ ーイ イ ア゚ ーイワ゚ イ 
゚゚ ゚ ゚゚ ゚ ーロ ゚゚ ゚ ーロ ゚゚ ゚゚ ゚ ーロ ゚゚ ゚ ゚゚ ゚ ーロ ゚゚゚゚゚゚ ゚゚ ゚ ーロ ゚゚゚゚゚゚ ゚゚ ゚ ゚゚ ゚ ーロ ゚゚ ゚ ーロ ゚゚ ゚゚ ゚ ーロ ゚゚ ゚ ゚゚ ゚ ーロ ゚゚゚゚゚゚ ゚゚ ゚ ーロ ゚゚゚゚゚゚
トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト
M. Message Areasウ L. BBS Listウ M. Message Areasウ L. BBS Listウ
ウ T. File Areasウ C. Chat Systemウ ウ T. File AreasC. Chat System
B. Bulletinsウ U. User Listウ B. Bulletinsウ U. User Listウ
D. Online Gamesウ 1. Last 10 Callersウ D. Door Games & Utilitesウ 1. Last 10 Callersウ
ウ  A. Text/ANSI File Collection ウ
ウウ 
ウ G. Goodbye (Log Off)ウ G. Goodbye (Log Off)ウ
トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト トトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトトト


30
bbs.c
View File

@ -326,6 +326,18 @@ static int handler(void* user, const char* section, const char* name,
conf->file_directories[conf->file_directory_count]->path = strdup(value); conf->file_directories[conf->file_directory_count]->path = strdup(value);
conf->file_directories[conf->file_directory_count]->file_sub_count = 0; conf->file_directories[conf->file_directory_count]->file_sub_count = 0;
conf->file_directory_count++; conf->file_directory_count++;
} else if (strcasecmp(section, "text files") == 0) {
if (conf->text_file_count == 0) {
conf->text_files = (struct text_file **)malloc(sizeof(struct text_file *));
} else {
conf->text_files = (struct text_file **)realloc(conf->text_files, sizeof(struct text_file *) * (conf->text_file_count + 1));
}
conf->text_files[conf->text_file_count] = (struct text_file *)malloc(sizeof(struct text_file));
conf->text_files[conf->text_file_count]->name = strdup(name);
conf->text_files[conf->text_file_count]->path = strdup(value);
conf->text_file_count++;
} }
return 1; return 1;
@ -339,6 +351,23 @@ void s_putstring(int socket, char *c) {
write(socket, c, strlen(c)); write(socket, c, strlen(c));
} }
void s_displayansi_p(int socket, char *file) {
FILE *fptr;
char c;
fptr = fopen(file, "r");
if (!fptr) {
return;
}
c = fgetc(fptr);
while (!feof(fptr)) {
s_putchar(socket, c);
c = fgetc(fptr);
}
fclose(fptr);
}
void s_displayansi(int socket, char *file) { void s_displayansi(int socket, char *file) {
FILE *fptr; FILE *fptr;
char c; char c;
@ -577,6 +606,7 @@ void runbbs(int socket, char *config_path) {
conf.file_directory_count = 0; conf.file_directory_count = 0;
conf.irc_server = NULL; conf.irc_server = NULL;
conf.irc_port = 6667; conf.irc_port = 6667;
conf.text_file_count = 0;
// Load BBS data // Load BBS data
if (ini_parse(config_path, handler, &conf) <0) { if (ini_parse(config_path, handler, &conf) <0) {

8
bbs.h
View File

@ -26,6 +26,11 @@ struct last10_callers {
time_t time; time_t time;
}__attribute__((packed)); }__attribute__((packed));
struct text_file {
char *name;
char *path;
};
struct door_config { struct door_config {
char *name; char *name;
char key; char key;
@ -88,6 +93,8 @@ struct bbs_config {
struct door_config **doors; struct door_config **doors;
int file_directory_count; int file_directory_count;
struct file_directory **file_directories; struct file_directory **file_directories;
int text_file_count;
struct text_file **text_files;
}; };
struct sec_level_t { struct sec_level_t {
@ -118,6 +125,7 @@ extern void runbbs(int sock, char *config);
extern struct fido_addr *parse_fido_addr(const char *str); extern struct fido_addr *parse_fido_addr(const char *str);
extern void s_putchar(int socket, char c); extern void s_putchar(int socket, char c);
extern void s_putstring(int socket, char *c); extern void s_putstring(int socket, char *c);
extern void s_displayansi_p(int socket, char *file);
extern void s_displayansi(int socket, char *file); extern void s_displayansi(int socket, char *file);
extern char s_getchar(int socket); extern char s_getchar(int socket);
extern void s_readstring(int socket, char *buffer, int max); extern void s_readstring(int socket, char *buffer, int max);

View File

@ -18,3 +18,6 @@ IllusionNet = config/illusionnet.ini
[file directories] [file directories]
General Files = config/filesgen.ini General Files = config/filesgen.ini
[text files]
Warning = ansis/bulletin0.ans

View File

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "bbs.h" #include "bbs.h"
@ -23,6 +24,39 @@ void main_menu(int socket, struct user_record *user) {
c = s_getc(socket); c = s_getc(socket);
switch(tolower(c)) { switch(tolower(c)) {
case 'a':
{
if (conf.text_file_count > 0) {
while(1) {
s_putstring(socket, "\r\n\e[1;32mText Files Collection\r\n");
s_putstring(socket, "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n");
for (i=0;i<conf.text_file_count;i++) {
sprintf(buffer, "\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%s\r\n", i, conf.text_files[i]->name);
s_putstring(socket, buffer);
}
s_putstring(socket, "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n");
s_putstring(socket, "Enter the number of a text file to display or Q to quit: ");
s_readstring(socket, buffer, 4);
if (tolower(buffer[0]) != 'q') {
i = atoi(buffer);
if (i >= 0 && i < conf.text_file_count) {
s_displayansi_p(socket, conf.text_files[i]->path);
s_putstring(socket, "Press any key to continue...\r\n");
s_getc(socket);
}
} else {
break;
}
}
} else {
s_putstring(socket, "\r\nSorry, there are no text files to display\r\n");
s_putstring(socket, "Press any key to continue...\r\n");
s_getc(socket);
}
}
break;
case 'c': case 'c':
{ {
chat_system(socket, user); chat_system(socket, user);