More work on ccenter

This commit is contained in:
Andrew Pamment 2017-03-27 21:41:23 +10:00
parent 5ed4566eda
commit b03e16405b
6 changed files with 635 additions and 2 deletions

View File

@ -26,7 +26,7 @@ CC=cc
CFLAGS=-I/usr/local/include CFLAGS=-I/usr/local/include
DEPS = main.c DEPS = main.c
OBJ = main.o load_ini.o systemconfig.o ../../inih/ini.o OBJ = main.o load_ini.o systemconfig.o systempaths.o mailconfs.o mailareas.o ../../inih/ini.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) -I../../deps/cdk-5.0-20161210/include/ $(CC) -c -o $@ $< $(CFLAGS) -I../../deps/cdk-5.0-20161210/include/

View File

@ -168,8 +168,12 @@ struct user_record {
int defarchiver; int defarchiver;
int defprotocol; int defprotocol;
}; };
extern void choose_sec_level(int *result, int x, int y, int selected);
extern int get_valid_seclevels(int **levels, int *count); extern int get_valid_seclevels(int **levels, int *count);
extern struct fido_addr *parse_fido_addr(const char *str); extern struct fido_addr *parse_fido_addr(const char *str);
extern int load_ini_file(char *ini_file); extern int load_ini_file(char *ini_file);
extern void system_config(void); extern void system_config(void);
extern void system_paths();
extern void mail_conferences();
extern void edit_mail_areas(int confer);
#endif #endif

46
utils/ccenter/mailareas.c Normal file
View File

@ -0,0 +1,46 @@
#include <curses.h>
#include <cdk.h>
#include "ccenter.h"
extern struct bbs_config conf;
extern CDKSCREEN *cdkscreen;
void edit_mail_areas(int confer) {
char **itemlist;
int selection;
int i;
while (1) {
itemlist = (char **)malloc(sizeof(char *) * (conf.mail_conferences[confer]->mail_area_count + 1));
itemlist[0] = strdup("Add Area");
for (i=0;i<conf.mail_conferences[confer]->mail_area_count;i++) {
itemlist[i+1] = strdup(conf.mail_conferences[confer]->mail_areas[i]->name);
}
CDKSCROLL *mailAreaList = newCDKScroll(cdkscreen, 7, 7, RIGHT, 12, 30, "</B/32>Mail Areas<!32>", itemlist, conf.mail_conferences[confer]->mail_area_count + 1, FALSE, A_STANDOUT, TRUE, FALSE);
selection = activateCDKScroll(mailAreaList, 0);
if (mailAreaList->exitType == vESCAPE_HIT) {
destroyCDKScroll(mailAreaList);
for (i=0;i<conf.mail_conferences[confer]->mail_area_count+1;i++) {
free(itemlist[i]);
}
free(itemlist);
break;
}
if (selection == 0) {
// add new
} else {
// edit existing
//edit_mail_conference(selection - 1);
}
destroyCDKScroll(mailAreaList);
for (i=0;i<conf.mail_conferences[confer]->mail_area_count+1;i++) {
free(itemlist[i]);
}
free(itemlist);
}
}

294
utils/ccenter/mailconfs.c Normal file
View File

@ -0,0 +1,294 @@
#include <curses.h>
#include <cdk.h>
#include "ccenter.h"
extern struct bbs_config conf;
extern CDKSCREEN *cdkscreen;
void edit_mail_conference_name(int confer) {
char *entrytext;
CDKENTRY *confName = newCDKEntry(cdkscreen, 7, 7, "</B/32>Conference Name<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 64, TRUE, FALSE);
setCDKEntry(confName, conf.mail_conferences[confer]->name, 1, 64, TRUE);
entrytext = activateCDKEntry(confName, 0);
if (confName->exitType == vNORMAL) {
if (conf.mail_conferences[confer]->name != NULL) {
free(conf.mail_conferences[confer]->name);
}
conf.mail_conferences[confer]->name = strdup(entrytext);
}
destroyCDKEntry(confName);
}
void edit_mail_conference_file(int confer) {
char *entrytext;
CDKENTRY *confFile = newCDKEntry(cdkscreen, 7, 7, "</B/32>Conference Path & Filename<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(confFile, conf.mail_conferences[confer]->path, 1, 1024, TRUE);
entrytext = activateCDKEntry(confFile, 0);
if (confFile->exitType == vNORMAL) {
if (conf.mail_conferences[confer]->path != NULL) {
free(conf.mail_conferences[confer]->path);
}
conf.mail_conferences[confer]->path = strdup(entrytext);
}
destroyCDKEntry(confFile);
}
void edit_mail_conference_networked_enable(int confer) {
char *itemList[] = {"True",
"False"};
int selection;
int doexit = 0;
CDKSCROLL *mailConfNet = newCDKScroll(cdkscreen, 9, 9, RIGHT, 5, 30, "</B/32>Conference is Networked<!32>", itemList, 2,FALSE, A_STANDOUT, TRUE, FALSE);
if (conf.mail_conferences[confer]->networked == 1) {
setCDKScrollCurrent(mailConfNet, 0);
} else {
setCDKScrollCurrent(mailConfNet, 1);
}
while(!doexit) {
selection = activateCDKScroll(mailConfNet, 0);
if (mailConfNet->exitType == vESCAPE_HIT) {
break;
}
switch(selection) {
case 0:
conf.mail_conferences[confer]->networked = 1;
doexit = 1;
break;
case 1:
conf.mail_conferences[confer]->networked = 0;
doexit = 1;
break;
default:
break;
}
}
destroyCDKScroll(mailConfNet);
}
void edit_mail_conference_networked_type(int confer) {
char *itemList[] = {"FTN Style"};
int selection;
int doexit = 0;
CDKSCROLL *mailConfNet = newCDKScroll(cdkscreen, 9, 9, RIGHT, 4, 30, "</B/32>Network Type<!32>", itemList,1,FALSE, A_STANDOUT, TRUE, FALSE);
while(!doexit) {
selection = activateCDKScroll(mailConfNet, 0);
if (mailConfNet->exitType == vESCAPE_HIT) {
break;
}
switch(selection) {
case 0:
conf.mail_conferences[confer]->nettype = NETWORK_FIDO;
doexit = 1;
break;
default:
break;
}
}
destroyCDKScroll(mailConfNet);
}
void edit_mail_conference_networked_address(int confer) {
char *entrytext;
char buffer[128];
struct fido_addr *new_addr;
CDKENTRY *mailConfAddr = newCDKEntry(cdkscreen, 9, 9, "</B/32>Network Address<!32>", NULL, A_NORMAL, ' ', vMIXED, 32, 1, 32, TRUE, FALSE);
if (conf.mail_conferences[confer]->fidoaddr != NULL) {
snprintf(buffer, 128, "%d:%d/%d.%d", conf.mail_conferences[confer]->fidoaddr->zone, conf.mail_conferences[confer]->fidoaddr->net, conf.mail_conferences[confer]->fidoaddr->node, conf.mail_conferences[confer]->fidoaddr->point);
setCDKEntry(mailConfAddr, buffer, 1, 32, TRUE);
}
entrytext = activateCDKEntry(mailConfAddr, 0);
if (mailConfAddr->exitType == vNORMAL) {
new_addr = parse_fido_addr(entrytext);
if (new_addr != NULL) {
if (conf.mail_conferences[confer]->fidoaddr != NULL) {
free(conf.mail_conferences[confer]->fidoaddr);
}
conf.mail_conferences[confer]->fidoaddr = new_addr;
}
}
destroyCDKEntry(mailConfAddr);
}
void edit_mail_conference_networked(int confer) {
char *itemList[] = {"Networked",
"Network Type",
"Network Address"
};
int selection;
CDKSCROLL *editConfNetList = newCDKScroll(cdkscreen, 7, 7, RIGHT, 6, 30, "</B/32>Network Options<!32>", itemList, 3, FALSE, A_STANDOUT, TRUE, FALSE);
while (1) {
selection = activateCDKScroll(editConfNetList, 0);
if (editConfNetList->exitType == vESCAPE_HIT) {
break;
}
switch(selection) {
case 0:
edit_mail_conference_networked_enable(confer);
break;
case 1:
edit_mail_conference_networked_type(confer);
break;
case 2:
edit_mail_conference_networked_address(confer);
break;
default:
break;
}
}
}
void edit_mail_conference_tagline(int confer) {
char *entrytext;
CDKENTRY *confTagLine = newCDKEntry(cdkscreen, 9, 9, "</B/32>Conference Tagline<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 80, TRUE, FALSE);
setCDKEntry(confTagLine, conf.mail_conferences[confer]->tagline, 1, 80, TRUE);
entrytext = activateCDKEntry(confTagLine, 0);
if (confTagLine->exitType == vNORMAL) {
if (conf.mail_conferences[confer]->tagline != NULL) {
free(conf.mail_conferences[confer]->tagline);
}
conf.mail_conferences[confer]->tagline = strdup(entrytext);
}
destroyCDKEntry(confTagLine);
}
void edit_mail_conference_realnames(int confer) {
char *itemList[] = {"True",
"False"};
int selection;
int doexit = 0;
CDKSCROLL *mailConfRN = newCDKScroll(cdkscreen, 9, 9, RIGHT, 5, 30, "</B/32>Conference is Networked<!32>", itemList, 2,FALSE, A_STANDOUT, TRUE, FALSE);
if (conf.mail_conferences[confer]->realnames == 1) {
setCDKScrollCurrent(mailConfRN, 0);
} else {
setCDKScrollCurrent(mailConfRN, 1);
}
while(!doexit) {
selection = activateCDKScroll(mailConfRN, 0);
if (mailConfRN->exitType == vESCAPE_HIT) {
break;
}
switch(selection) {
case 0:
conf.mail_conferences[confer]->realnames = 1;
doexit = 1;
break;
case 1:
conf.mail_conferences[confer]->realnames = 0;
doexit = 1;
break;
default:
break;
}
}
destroyCDKScroll(mailConfRN);
}
void edit_mail_conference(int confer) {
char *itemList[] = {"Name",
"Path & Filename",
"Visible Sec. Level",
"Networked",
"Tag Line",
"Use Real Names",
"Edit Areas",
"Delete Conference"};
char buffer[1024];
int selection;
snprintf(buffer, 1024, "</B/32>%s<!32>", conf.mail_conferences[confer]->name);
CDKSCROLL *editConfList = newCDKScroll(cdkscreen, 5, 5, RIGHT, 10, 30, buffer, itemList, 7, FALSE, A_STANDOUT, TRUE, FALSE);
while (1) {
selection = activateCDKScroll(editConfList, 0);
if (editConfList->exitType == vESCAPE_HIT) {
break;
}
switch(selection) {
case 0:
edit_mail_conference_name(confer);
break;
case 1:
edit_mail_conference_file(confer);
break;
case 2:
choose_sec_level(&conf.mail_conferences[confer]->sec_level, 7, 7, conf.mail_conferences[confer]->sec_level);
break;
case 3:
edit_mail_conference_networked(confer);
break;
case 4:
edit_mail_conference_tagline(confer);
break;
case 5:
edit_mail_conference_realnames(confer);
break;
case 6:
edit_mail_areas(confer);
break;
default:
break;
}
}
destroyCDKScroll(editConfList);
}
void mail_conferences() {
char **itemlist;
int selection;
int i;
while (1) {
itemlist = (char **)malloc(sizeof(char *) * (conf.mail_conference_count + 1));
itemlist[0] = strdup("Add Conference");
for (i=0;i<conf.mail_conference_count;i++) {
itemlist[i+1] = strdup(conf.mail_conferences[i]->name);
}
CDKSCROLL *mailConfList = newCDKScroll(cdkscreen, 3, 3, RIGHT, 12, 30, "</B/32>Mail Conferences<!32>", itemlist, conf.mail_conference_count + 1, FALSE, A_STANDOUT, TRUE, FALSE);
selection = activateCDKScroll(mailConfList, 0);
if (mailConfList->exitType == vESCAPE_HIT) {
destroyCDKScroll(mailConfList);
for (i=0;i<conf.mail_conference_count+1;i++) {
free(itemlist[i]);
}
free(itemlist);
break;
}
if (selection == 0) {
// add new
} else {
// edit existing
edit_mail_conference(selection - 1);
}
destroyCDKScroll(mailConfList);
for (i=0;i<conf.mail_conference_count+1;i++) {
free(itemlist[i]);
}
free(itemlist);
}
}

View File

@ -56,7 +56,7 @@ int main(int argc, char **argv) {
menuItems[0][6] = strdup("Exit"); menuItems[0][6] = strdup("Exit");
menuItems[1][0] = strdup("Misc"); menuItems[1][0] = strdup("Misc");
menuItems[1][1] = strdup("About"); menuItems[1][1] = strdup("About");
int locations[1] = {LEFT, RIGHT}; int locations[2] = {LEFT, RIGHT};
CDKparseParams(argc, argv, &params, "c:" CDK_CLI_PARAMS); CDKparseParams(argc, argv, &params, "c:" CDK_CLI_PARAMS);
if (!load_ini_file(CDKparamString (&params, 'c'))) { if (!load_ini_file(CDKparamString (&params, 'c'))) {
fprintf(stderr, "Error opening ini file: %s\n", CDKparamString (&params, 'c')); fprintf(stderr, "Error opening ini file: %s\n", CDKparamString (&params, 'c'));
@ -84,6 +84,12 @@ int main(int argc, char **argv) {
case 0: case 0:
system_config(); system_config();
break; break;
case 1:
system_paths();
break;
case 2:
mail_conferences();
break;
case 5: case 5:
doexit = 1; doexit = 1;
break; break;

283
utils/ccenter/systempaths.c Normal file
View File

@ -0,0 +1,283 @@
#include <curses.h>
#include <cdk.h>
#include "ccenter.h"
extern struct bbs_config conf;
extern CDKSCREEN *cdkscreen;
void set_bbs_path(void) {
char *entrytext;
char *old_path = strdup(conf.bbs_path);
char *new_path;
CDKENTRY *bbsPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>BBS Path<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(bbsPath, conf.bbs_path, 1, 1024, TRUE);
entrytext = activateCDKEntry(bbsPath, 0);
if (bbsPath->exitType == vNORMAL) {
if (conf.bbs_path != NULL) {
free(conf.bbs_path);
}
conf.bbs_path = strdup(entrytext);
}
destroyCDKEntry(bbsPath);
char *message[] = {"Do you want to apply this path to all other paths?"};
char *buttons[] = {" Yes ", " No "};
CDKDIALOG *dialog = newCDKDialog(cdkscreen, 7, 7, message, 1, buttons, 2, A_STANDOUT, FALSE, TRUE, FALSE);
int selection = activateCDKDialog(dialog, 0);
if (dialog->exitType == vESCAPE_HIT || (dialog->exitType == vNORMAL && selection == 1)) {
// do nothing
} else {
if (strncmp(conf.www_path, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.www_path[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.www_path[strlen(old_path)]);
free(conf.www_path);
conf.www_path = new_path;
}
if (strncmp(conf.config_path, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.config_path[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.config_path[strlen(old_path)]);
free(conf.config_path);
conf.config_path = new_path;
}
if (strncmp(conf.string_file, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.string_file[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.string_file[strlen(old_path)]);
free(conf.string_file);
conf.string_file = new_path;
}
if (strncmp(conf.pid_file, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.pid_file[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.pid_file[strlen(old_path)]);
free(conf.pid_file);
conf.pid_file = new_path;
}
if (strncmp(conf.ansi_path, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.ansi_path[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.ansi_path[strlen(old_path)]);
free(conf.ansi_path);
conf.ansi_path = new_path;
}
if (strncmp(conf.log_path, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.log_path[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.log_path[strlen(old_path)]);
free(conf.log_path);
conf.log_path = new_path;
}
if (strncmp(conf.script_path, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.script_path[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.script_path[strlen(old_path)]);
free(conf.script_path);
conf.script_path = new_path;
}
if (strncmp(conf.echomail_sem, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.echomail_sem[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.echomail_sem[strlen(old_path)]);
free(conf.echomail_sem);
conf.echomail_sem = new_path;
}
if (strncmp(conf.netmail_sem, old_path, strlen(old_path)) == 0) {
new_path = (char *)malloc(strlen(conf.bbs_path) + strlen(&conf.netmail_sem[strlen(old_path)]) + 1);
sprintf(new_path, "%s%s", conf.bbs_path, &conf.netmail_sem[strlen(old_path)]);
free(conf.netmail_sem);
conf.netmail_sem = new_path;
}
}
free(old_path);
destroyCDKDialog(dialog);
}
void set_config_path(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>Config Path<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.config_path, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.config_path != NULL) {
free(conf.config_path);
}
conf.config_path = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_ansi_path(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>ANSI Path<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.ansi_path, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.ansi_path != NULL) {
free(conf.ansi_path);
}
conf.ansi_path = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_script_path(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>Script Path<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.script_path, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.script_path != NULL) {
free(conf.script_path);
}
conf.script_path = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_log_path(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>Log Path<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.log_path, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.log_path != NULL) {
free(conf.log_path);
}
conf.log_path = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_string_file(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>String File<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.string_file, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.string_file != NULL) {
free(conf.string_file);
}
conf.string_file = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_pid_file(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>PID File<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.pid_file, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.pid_file != NULL) {
free(conf.pid_file);
}
conf.pid_file = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_echomail_sem(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>Echomail Semaphore<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.echomail_sem, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.echomail_sem != NULL) {
free(conf.echomail_sem);
}
conf.echomail_sem = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void set_netmail_sem(void) {
char *entrytext;
CDKENTRY *configPath = newCDKEntry(cdkscreen, 5, 5, "</B/32>Netmail Semaphore<!32>", NULL, A_NORMAL, ' ', vMIXED, 48, 1, 1024, TRUE, FALSE);
setCDKEntry(configPath, conf.netmail_sem, 1, 1024, TRUE);
entrytext = activateCDKEntry(configPath, 0);
if (configPath->exitType == vNORMAL) {
if (conf.netmail_sem != NULL) {
free(conf.netmail_sem);
}
conf.netmail_sem = strdup(entrytext);
}
destroyCDKEntry(configPath);
}
void system_paths() {
char *itemList[] = {"BBS Path",
"Config Path",
"ANSI Path",
"Script Path",
"Log Path",
"String File",
"PID File",
"Echomail Semaphore",
"Netmail Semaphore"};
int selection;
CDKSCROLL *sysPathItemList = newCDKScroll(cdkscreen, 3, 3, RIGHT, 12, 30, "</B/32>System Paths<!32>", itemList, 9, FALSE, A_STANDOUT, TRUE, FALSE);
while (1) {
selection = activateCDKScroll(sysPathItemList, 0);
if (sysPathItemList->exitType == vESCAPE_HIT) {
break;
}
switch(selection) {
case 0:
set_bbs_path();
break;
case 1:
set_config_path();
break;
case 2:
set_ansi_path();
break;
case 3:
set_script_path();
break;
case 4:
set_log_path();
break;
case 5:
set_string_file();
break;
case 6:
set_pid_file();
break;
case 7:
set_echomail_sem();
break;
case 8:
set_netmail_sem();
break;
default:
break;
}
}
destroyCDKScroll(sysPathItemList);
}