This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
magicka/main_menu.c

130 lines
3.0 KiB
C
Raw Normal View History

2016-03-22 01:48:59 +00:00
#include <stdio.h>
#include <string.h>
2016-03-27 00:33:43 +00:00
#include <stdlib.h>
2016-03-22 01:48:59 +00:00
#include <ctype.h>
2016-03-23 06:31:00 +00:00
#include <sys/stat.h>
2016-03-22 01:48:59 +00:00
#include "bbs.h"
extern struct bbs_config conf;
void main_menu(int socket, struct user_record *user) {
int doquit = 0;
char c;
char prompt[128];
2016-03-23 06:31:00 +00:00
char buffer[256];
int i;
struct stat s;
2016-03-22 01:48:59 +00:00
while (!doquit) {
s_displayansi(socket, "mainmenu");
sprintf(prompt, "\r\n\e[0mTL: %dm :> ", user->timeleft);
2016-03-22 01:48:59 +00:00
s_putstring(socket, prompt);
c = s_getc(socket);
switch(tolower(c)) {
2016-03-27 00:33:43 +00:00
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) {
2016-03-27 00:58:45 +00:00
s_putstring(socket, "\r\n");
2016-03-27 00:33:43 +00:00
s_displayansi_p(socket, conf.text_files[i]->path);
2016-03-27 00:58:45 +00:00
s_putstring(socket, "Press any key to continue...");
2016-03-27 00:33:43 +00:00
s_getc(socket);
2016-03-27 00:58:45 +00:00
s_putstring(socket, "\r\n");
2016-03-27 00:33:43 +00:00
}
} 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':
{
chat_system(socket, user);
}
break;
2016-03-25 10:21:28 +00:00
case 'l':
{
bbs_list(socket, user);
}
break;
2016-03-23 06:31:00 +00:00
case 'u':
{
list_users(socket, user);
}
break;
case 'b':
{
i = 0;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
while (stat(buffer, &s) == 0) {
sprintf(buffer, "bulletin%d", i);
s_displayansi(socket, buffer);
2016-04-10 04:10:18 +00:00
sprintf(buffer, "\e[0mPress any key to continue...\r\n");
2016-03-23 06:31:00 +00:00
s_putstring(socket, buffer);
s_getc(socket);
i++;
sprintf(buffer, "%s/bulletin%d.ans", conf.ansi_path, i);
}
}
break;
2016-03-23 05:21:53 +00:00
case '1':
{
display_last10_callers(socket, user, 0);
}
break;
case 'd':
{
doquit = door_menu(socket, user);
}
break;
2016-03-22 03:07:42 +00:00
case 'm':
{
doquit = mail_menu(socket, user);
}
break;
2016-03-22 01:48:59 +00:00
case 'g':
{
s_putstring(socket, "\r\nAre you sure you want to log off? (Y/N)");
c = s_getc(socket);
if (tolower(c) == 'y') {
doquit = 1;
}
}
break;
2016-04-02 23:26:17 +00:00
case 't':
{
doquit = file_menu(socket, user);
}
break;
2016-04-10 08:45:02 +00:00
case 's':
{
settings_menu(socket, user);
}
break;
2016-03-22 01:48:59 +00:00
}
}
}