Added Configurations for File areas
This commit is contained in:
parent
fb8056e084
commit
f9575b92a0
69
bbs.c
69
bbs.c
@ -88,6 +88,53 @@ static int door_config_handler(void* user, const char* section, const char* name
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int file_sub_handler(void* user, const char* section, const char* name,
|
||||||
|
const char* value)
|
||||||
|
{
|
||||||
|
struct file_directory *fd = (struct file_directory *)user;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (strcasecmp(section, "main") == 0) {
|
||||||
|
if (strcasecmp(name, "visible sec level")) {
|
||||||
|
fd->sec_level = atoi(value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// check if it's partially filled in
|
||||||
|
for (i=0;i<fd->file_sub_count;i++) {
|
||||||
|
if (strcasecmp(fd->file_subs[i]->name, section) == 0) {
|
||||||
|
if (strcasecmp(name, "upload sec level") == 0) {
|
||||||
|
fd->file_subs[i]->upload_sec_level = atoi(value);
|
||||||
|
} else if (strcasecmp(name, "download sec level") == 0) {
|
||||||
|
fd->file_subs[i]->download_sec_level = atoi(value);
|
||||||
|
} else if (strcasecmp(name, "database") == 0) {
|
||||||
|
fd->file_subs[i]->database = strdup(value);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fd->file_sub_count == 0) {
|
||||||
|
fd->file_subs = (struct file_sub **)malloc(sizeof(struct file_sub *));
|
||||||
|
} else {
|
||||||
|
fd->file_subs = (struct file_sub **)realloc(fd->file_subs, sizeof(struct file_sub *) * (fd->file_sub_count + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
fd->file_subs[fd->file_sub_count] = (struct file_sub *)malloc(sizeof(struct file_sub));
|
||||||
|
|
||||||
|
fd->file_subs[fd->file_sub_count]->name = strdup(section);
|
||||||
|
if (strcasecmp(name, "upload sec level") == 0) {
|
||||||
|
fd->file_subs[fd->file_sub_count]->upload_sec_level = atoi(value);
|
||||||
|
} else if (strcasecmp(name, "download sec level") == 0) {
|
||||||
|
fd->file_subs[fd->file_sub_count]->download_sec_level = atoi(value);
|
||||||
|
} else if (strcasecmp(name, "database") == 0) {
|
||||||
|
fd->file_subs[fd->file_sub_count]->database = strdup(value);
|
||||||
|
}
|
||||||
|
fd->file_sub_count++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int mail_area_handler(void* user, const char* section, const char* name,
|
static int mail_area_handler(void* user, const char* section, const char* name,
|
||||||
const char* value)
|
const char* value)
|
||||||
{
|
{
|
||||||
@ -180,6 +227,18 @@ static int handler(void* user, const char* section, const char* name,
|
|||||||
conf->mail_conferences[conf->mail_conference_count]->path = strdup(value);
|
conf->mail_conferences[conf->mail_conference_count]->path = strdup(value);
|
||||||
conf->mail_conferences[conf->mail_conference_count]->mail_area_count = 0;
|
conf->mail_conferences[conf->mail_conference_count]->mail_area_count = 0;
|
||||||
conf->mail_conference_count++;
|
conf->mail_conference_count++;
|
||||||
|
} else if (strcasecmp(section, "file directories") == 0) {
|
||||||
|
if (conf->file_directory_count == 0) {
|
||||||
|
conf->file_directories = (struct file_directory **)malloc(sizeof(struct file_directory *));
|
||||||
|
} else {
|
||||||
|
conf->file_directories = (struct file_directory **)realloc(conf->file_directories, sizeof(struct file_directory *) * (conf->file_directory_count + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
conf->file_directories[conf->file_directory_count] = (struct file_directory *)malloc(sizeof(struct file_directory));
|
||||||
|
conf->file_directories[conf->file_directory_count]->name = strdup(name);
|
||||||
|
conf->file_directories[conf->file_directory_count]->path = strdup(value);
|
||||||
|
conf->file_directories[conf->file_directory_count]->file_sub_count = 0;
|
||||||
|
conf->file_directory_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -430,6 +489,7 @@ void runbbs(int socket, char *config_path) {
|
|||||||
|
|
||||||
conf.mail_conference_count = 0;
|
conf.mail_conference_count = 0;
|
||||||
conf.door_count = 0;
|
conf.door_count = 0;
|
||||||
|
conf.file_directory_count = 0;
|
||||||
|
|
||||||
// Load BBS data
|
// Load BBS data
|
||||||
if (ini_parse(config_path, handler, &conf) <0) {
|
if (ini_parse(config_path, handler, &conf) <0) {
|
||||||
@ -443,7 +503,14 @@ void runbbs(int socket, char *config_path) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Load file Subs
|
||||||
|
for (i=0;i<conf.file_directory_count;i++) {
|
||||||
|
if (ini_parse(conf.file_directories[i]->path, file_sub_handler, conf.file_directories[i]) <0) {
|
||||||
|
printf("Unable to load configuration ini (%s)!\n", conf.file_directories[i]->path);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ini_parse("config/doors.ini", door_config_handler, &conf) <0) {
|
if (ini_parse("config/doors.ini", door_config_handler, &conf) <0) {
|
||||||
printf("Unable to load configuration ini (doors.ini)!\n");
|
printf("Unable to load configuration ini (doors.ini)!\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
17
bbs.h
17
bbs.h
@ -37,6 +37,21 @@ struct mail_conference {
|
|||||||
struct mail_area **mail_areas;
|
struct mail_area **mail_areas;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct file_sub {
|
||||||
|
char *name;
|
||||||
|
char *database;
|
||||||
|
int upload_sec_level;
|
||||||
|
int download_sec_level;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct file_directory {
|
||||||
|
char *name;
|
||||||
|
char *path;
|
||||||
|
int sec_level;
|
||||||
|
int file_sub_count;
|
||||||
|
struct file_sub **file_subs;
|
||||||
|
};
|
||||||
|
|
||||||
struct bbs_config {
|
struct bbs_config {
|
||||||
char *bbs_name;
|
char *bbs_name;
|
||||||
char *sysop_name;
|
char *sysop_name;
|
||||||
@ -51,6 +66,8 @@ struct bbs_config {
|
|||||||
struct mail_conference **mail_conferences;
|
struct mail_conference **mail_conferences;
|
||||||
int door_count;
|
int door_count;
|
||||||
struct door_config **doors;
|
struct door_config **doors;
|
||||||
|
int file_directory_count;
|
||||||
|
struct file_directory **file_directories;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sec_level_t {
|
struct sec_level_t {
|
||||||
|
@ -11,3 +11,6 @@ Email Path = /home/andrew/MagickaBBS/msgs/email
|
|||||||
|
|
||||||
[mail conferences]
|
[mail conferences]
|
||||||
Local Mail = config/localmail.ini
|
Local Mail = config/localmail.ini
|
||||||
|
|
||||||
|
[file directories]
|
||||||
|
General Files = config/filesgen.ini
|
||||||
|
7
config_default/filesgen.ini
Normal file
7
config_default/filesgen.ini
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[main]
|
||||||
|
Visible Sec Level = 10
|
||||||
|
|
||||||
|
[Misc]
|
||||||
|
Database = files_misc
|
||||||
|
Download Sec Level = 10
|
||||||
|
Upload Sec Level = 10
|
Reference in New Issue
Block a user