Replace printf / fprintf(stderr... with dolog
This commit is contained in:
parent
7a12fb716f
commit
6b78526669
12
bbs.c
12
bbs.c
@ -41,7 +41,7 @@ void dolog(char *fmt, ...) {
|
||||
snprintf(buffer, 512, "%s/%04d%02d%02d.log", conf.log_path, time_now.tm_year + 1900, time_now.tm_mon + 1, time_now.tm_mday);
|
||||
logfptr = fopen(buffer, "a");
|
||||
if (!logfptr) {
|
||||
printf("Error opening log file!\n");
|
||||
dolog("Error opening log file!");
|
||||
return;
|
||||
}
|
||||
va_list ap;
|
||||
@ -422,7 +422,7 @@ void automessage_write(int socket, struct user_record *user) {
|
||||
fwrite(automsg, strlen(automsg), 1, fptr);
|
||||
fclose(fptr);
|
||||
} else {
|
||||
printf("Unable to open automessage.txt for writing\n");
|
||||
dolog("Unable to open automessage.txt for writing");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -446,7 +446,7 @@ void automessage_display(int socket) {
|
||||
}
|
||||
fclose(fptr);
|
||||
} else {
|
||||
printf("Error opening automessage.txt\n");
|
||||
dolog("Error opening automessage.txt");
|
||||
}
|
||||
} else {
|
||||
s_putstring(socket, "No automessage!\r\n");
|
||||
@ -491,7 +491,7 @@ void runbbs(int socket, char *ip) {
|
||||
mynode = i;
|
||||
nodefile = fopen(buffer, "w");
|
||||
if (!nodefile) {
|
||||
printf("Error opening nodefile!\n");
|
||||
dolog("Error opening nodefile!");
|
||||
close(socket);
|
||||
exit(1);
|
||||
}
|
||||
@ -548,7 +548,7 @@ void runbbs(int socket, char *ip) {
|
||||
if (stat(buffer, &s) == 0) {
|
||||
nodefile = fopen(buffer, "r");
|
||||
if (!nodefile) {
|
||||
printf("Error opening nodefile!\n");
|
||||
dolog("Error opening nodefile!");
|
||||
disconnect(socket, "Error opening nodefile!");
|
||||
}
|
||||
fgets(buffer, 256, nodefile);
|
||||
@ -566,7 +566,7 @@ void runbbs(int socket, char *ip) {
|
||||
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, mynode);
|
||||
nodefile = fopen(buffer, "w");
|
||||
if (!nodefile) {
|
||||
printf("Error opening nodefile!\n");
|
||||
dolog("Error opening nodefile!");
|
||||
close(socket);
|
||||
exit(1);
|
||||
}
|
||||
|
10
bbs_list.c
10
bbs_list.c
@ -55,7 +55,7 @@ void add_bbs(int socket, struct user_record *user) {
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -64,7 +64,7 @@ void add_bbs(int socket, struct user_record *user) {
|
||||
rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg);
|
||||
if (rc != SQLITE_OK ) {
|
||||
|
||||
fprintf(stderr, "SQL error: %s\n", err_msg);
|
||||
dolog("SQL error: %s", err_msg);
|
||||
|
||||
sqlite3_free(err_msg);
|
||||
sqlite3_close(db);
|
||||
@ -82,7 +82,7 @@ void add_bbs(int socket, struct user_record *user) {
|
||||
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ void add_bbs(int socket, struct user_record *user) {
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
|
||||
printf("execution failed: %s", sqlite3_errmsg(db));
|
||||
dolog("execution failed: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
@ -170,7 +170,7 @@ void list_bbses(int socket) {
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
|
8
doors.c
8
doors.c
@ -54,7 +54,7 @@ int write_door32sys(int socket, struct user_record *user) {
|
||||
fptr = fopen(buffer, "w");
|
||||
|
||||
if (!fptr) {
|
||||
printf("Unable to open %s for writing!\n", buffer);
|
||||
dolog("Unable to open %s for writing!", buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ int write_door32sys(int socket, struct user_record *user) {
|
||||
fptr = fopen(buffer, "w");
|
||||
|
||||
if (!fptr) {
|
||||
printf("Unable to open %s for writing!\n", buffer);
|
||||
dolog("Unable to open %s for writing!", buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ int door_menu(int socket, struct user_record *user) {
|
||||
do_internal_menu = 0;
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
}
|
||||
} else {
|
||||
@ -278,7 +278,7 @@ int door_menu(int socket, struct user_record *user) {
|
||||
lua_getglobal(L, "menu");
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
lua_close(L);
|
||||
continue;
|
||||
|
26
email.c
26
email.c
@ -57,7 +57,7 @@ void send_email(int socket, struct user_record *user) {
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -67,7 +67,7 @@ void send_email(int socket, struct user_record *user) {
|
||||
rc = sqlite3_exec(db, csql, 0, 0, &err_msg);
|
||||
if (rc != SQLITE_OK ) {
|
||||
|
||||
fprintf(stderr, "SQL error: %s\n", err_msg);
|
||||
dolog("SQL error: %s", err_msg);
|
||||
|
||||
sqlite3_free(err_msg);
|
||||
sqlite3_close(db);
|
||||
@ -84,7 +84,7 @@ void send_email(int socket, struct user_record *user) {
|
||||
sqlite3_bind_text(res, 4, msg, -1, 0);
|
||||
sqlite3_bind_int(res, 5, time(NULL));
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
s_putstring(socket, "\r\nNo such email\r\n");
|
||||
@ -125,7 +125,7 @@ void show_email(int socket, struct user_record *user, int msgno) {
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -136,7 +136,7 @@ void show_email(int socket, struct user_record *user, int msgno) {
|
||||
sqlite3_bind_text(res, 1, user->loginname, -1, 0);
|
||||
sqlite3_bind_int(res, 2, msgno);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
s_putstring(socket, "\r\nNo such email\r\n");
|
||||
@ -188,7 +188,7 @@ void show_email(int socket, struct user_record *user, int msgno) {
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_int(res, 1, id);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return;
|
||||
@ -221,7 +221,7 @@ void show_email(int socket, struct user_record *user, int msgno) {
|
||||
sqlite3_bind_text(res, 4, replybody, -1, 0);
|
||||
sqlite3_bind_int(res, 5, time(NULL));
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
s_putstring(socket, "\r\nNo such email\r\n");
|
||||
@ -246,7 +246,7 @@ void show_email(int socket, struct user_record *user, int msgno) {
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_int(res, 1, id);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
s_putstring(socket, "\r\nNo such email\r\n");
|
||||
@ -259,7 +259,7 @@ void show_email(int socket, struct user_record *user, int msgno) {
|
||||
}
|
||||
|
||||
} else {
|
||||
printf("Failed\n");
|
||||
dolog("Failed");
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
}
|
||||
@ -285,7 +285,7 @@ void list_emails(int socket, struct user_record *user) {
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -295,7 +295,7 @@ void list_emails(int socket, struct user_record *user) {
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_text(res, 1, user->loginname, -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
s_putstring(socket, "\r\nYou have no email\r\n");
|
||||
@ -373,7 +373,7 @@ int mail_getemailcount(struct user_record *user) {
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -383,7 +383,7 @@ int mail_getemailcount(struct user_record *user) {
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_text(res, 1, user->loginname, -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return 0;
|
||||
|
31
files.c
31
files.c
@ -83,7 +83,6 @@ FILE *ZOpenFile(char *name, u_long crc, ZModem *info) {
|
||||
struct stat s;
|
||||
|
||||
snprintf(upload_filename, 1023, "%s/%s", upload_path, basename(name));
|
||||
fprintf(stderr, "%s\n", upload_filename);
|
||||
if (stat(upload_filename, &s) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
@ -153,7 +152,7 @@ int doIO(ZModem *zm) {
|
||||
} else {
|
||||
// SIG INT catch
|
||||
if (errno != EINTR) {
|
||||
printf("SELECT ERROR %s\n", strerror(errno));
|
||||
dolog("SELECT ERROR %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,14 +222,14 @@ void upload(int socket, struct user_record *user) {
|
||||
rc = sqlite3_open(buffer3, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg);
|
||||
if (rc != SQLITE_OK ) {
|
||||
fprintf(stderr, "SQL error: %s\n", err_msg);
|
||||
dolog("SQL error: %s", err_msg);
|
||||
sqlite3_free(err_msg);
|
||||
sqlite3_close(db);
|
||||
return;
|
||||
@ -244,7 +243,7 @@ void upload(int socket, struct user_record *user) {
|
||||
sqlite3_bind_text(res, 2, buffer, -1, 0);
|
||||
sqlite3_bind_int(res, 3, s.st_size);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return;
|
||||
@ -253,7 +252,7 @@ void upload(int socket, struct user_record *user) {
|
||||
rc = sqlite3_step(res);
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
printf("execution failed: %s", sqlite3_errmsg(db));
|
||||
dolog("execution failed: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return;
|
||||
@ -275,7 +274,7 @@ void download_zmodem(int socket, struct user_record *user, char *filename) {
|
||||
u_char buffer[2048];
|
||||
u_char buffer2[1024];
|
||||
|
||||
printf("Attempting to upload %s\n", filename);
|
||||
dolog("Attempting to upload %s", filename);
|
||||
|
||||
zm.attn = NULL;
|
||||
zm.windowsize = 0;
|
||||
@ -303,11 +302,11 @@ void download_zmodem(int socket, struct user_record *user, char *filename) {
|
||||
break ;
|
||||
|
||||
case ZmErrCantOpen:
|
||||
fprintf(stderr, "cannot open file \"%s\": %s\n", filename, strerror(errno)) ;
|
||||
dolog("cannot open file \"%s\": %s\n", filename, strerror(errno)) ;
|
||||
return;
|
||||
|
||||
case ZmFileTooLong:
|
||||
fprintf(stderr, "filename \"%s\" too long, skipping...\n", filename) ;
|
||||
dolog("filename \"%s\" too long, skipping...\n", filename) ;
|
||||
return;
|
||||
|
||||
case ZmDone:
|
||||
@ -351,7 +350,7 @@ void download(int socket, struct user_record *user) {
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
@ -360,13 +359,13 @@ void download(int socket, struct user_record *user) {
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_text(res, 1, tagged_files[i], -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
|
||||
if (rc != SQLITE_ROW) {
|
||||
fprintf(stderr, "Downloaded a file not in database!!!!!");
|
||||
dolog("Downloaded a file not in database!!!!!");
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
@ -382,7 +381,7 @@ void download(int socket, struct user_record *user) {
|
||||
sqlite3_bind_int(res, 1, dloads);
|
||||
sqlite3_bind_text(res, 2, tagged_files[i], -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
@ -421,7 +420,7 @@ void list_files(int socket, struct user_record *user) {
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -603,7 +602,7 @@ int file_menu(int socket, struct user_record *user) {
|
||||
do_internal_menu = 0;
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
}
|
||||
} else {
|
||||
@ -625,7 +624,7 @@ int file_menu(int socket, struct user_record *user) {
|
||||
lua_getglobal(L, "menu");
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
lua_close(L);
|
||||
continue;
|
||||
|
30
mail_menu.c
30
mail_menu.c
@ -48,7 +48,7 @@ s_JamBase *open_jam_base(char *path) {
|
||||
}
|
||||
} else {
|
||||
free(jb);
|
||||
printf("Got %d\n", ret);
|
||||
dolog("Got %d", ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
||||
|
||||
jb = open_jam_base(conf.mail_conferences[msgconf]->mail_areas[msgarea]->path);
|
||||
if (!jb) {
|
||||
printf("Error opening JAM base.. %s\n", conf.mail_conferences[msgconf]->mail_areas[msgarea]->path);
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[msgconf]->mail_areas[msgarea]->path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
||||
memset(&jmh, 0, sizeof(s_JamMsgHeader));
|
||||
z = JAM_ReadMsgHeader(jb, i, &jmh, &jsp);
|
||||
if (z != 0) {
|
||||
printf("Failed to read msg header: %d Erro %d\n", z, JAM_Errno(jb));
|
||||
dolog("Failed to read msg header: %d Erro %d", z, JAM_Errno(jb));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -730,7 +730,7 @@ void read_message(int socket, struct user_record *user, struct msg_headers *msgh
|
||||
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -961,7 +961,7 @@ void read_message(int socket, struct user_record *user, struct msg_headers *msgh
|
||||
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
free(replybody);
|
||||
free(body);
|
||||
free(subject);
|
||||
@ -1135,12 +1135,12 @@ void read_message(int socket, struct user_record *user, struct msg_headers *msgh
|
||||
free(subject);
|
||||
free(to);
|
||||
free(from);
|
||||
printf("Failed to lock msg base!\n");
|
||||
dolog("Failed to lock msg base!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (JAM_AddMessage(jb, &jmh, jsp, (char *)replybody, strlen(replybody))) {
|
||||
printf("Failed to add message\n");
|
||||
dolog("Failed to add message");
|
||||
} else {
|
||||
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) {
|
||||
if (conf.netmail_sem != NULL) {
|
||||
@ -1252,7 +1252,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
do_internal_menu = 0;
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
}
|
||||
} else {
|
||||
@ -1275,7 +1275,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
lua_getglobal(L, "menu");
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
lua_close(L);
|
||||
continue;
|
||||
@ -1293,7 +1293,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
if (msghs != NULL && msghs->msg_count > 0) {
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
break;
|
||||
} else {
|
||||
all_unread = 0;
|
||||
@ -1402,7 +1402,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
if (msg != NULL) {
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
free(msg);
|
||||
free(to);
|
||||
free(subject);
|
||||
@ -1557,7 +1557,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
free(msg);
|
||||
free(to);
|
||||
free(subject);
|
||||
printf("Failed to lock msg base!\n");
|
||||
dolog("Failed to lock msg base!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1567,7 +1567,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
}
|
||||
|
||||
if (JAM_AddMessage(jb, &jmh, jsp, (char *)msg, strlen(msg))) {
|
||||
printf("Failed to add message\n");
|
||||
dolog("Failed to add message");
|
||||
} else {
|
||||
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) {
|
||||
if (conf.netmail_sem != NULL) {
|
||||
@ -1600,7 +1600,7 @@ int mail_menu(int socket, struct user_record *user) {
|
||||
if (msghs != NULL && msghs->msg_count > 0) {
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
printf("Error opening JAM base.. %s\n", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
break;
|
||||
} else {
|
||||
all_unread = 0;
|
||||
@ -1854,7 +1854,7 @@ void mail_scan(int socket, struct user_record *user) {
|
||||
}
|
||||
jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path);
|
||||
if (!jb) {
|
||||
printf("Unable to open message base\n");
|
||||
dolog("Unable to open message base");
|
||||
continue;
|
||||
}
|
||||
if (JAM_ReadMBHeader(jb, &jbh) != 0) {
|
||||
|
12
main.c
12
main.c
@ -341,7 +341,7 @@ void server(int port) {
|
||||
|
||||
socket_desc = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (socket_desc == -1) {
|
||||
printf("Couldn't create socket..\n");
|
||||
fprintf(stderr, "Couldn't create socket..\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ int main(int argc, char **argv) {
|
||||
FILE *fptr;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("Usage ./magicka config/bbs.ini port\n");
|
||||
fprintf(stderr, "Usage ./magicka config/bbs.ini port\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -412,26 +412,26 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Load BBS data
|
||||
if (ini_parse(argv[1], handler, &conf) <0) {
|
||||
printf("Unable to load configuration ini (%s)!\n", argv[1]);
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", argv[1]);
|
||||
exit(-1);
|
||||
}
|
||||
// Load mail Areas
|
||||
for (i=0;i<conf.mail_conference_count;i++) {
|
||||
if (ini_parse(conf.mail_conferences[i]->path, mail_area_handler, conf.mail_conferences[i]) <0) {
|
||||
printf("Unable to load configuration ini (%s)!\n", conf.mail_conferences[i]->path);
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", conf.mail_conferences[i]->path);
|
||||
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);
|
||||
fprintf(stderr, "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) {
|
||||
printf("Unable to load configuration ini (doors.ini)!\n");
|
||||
fprintf(stderr, "Unable to load configuration ini (doors.ini)!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ void main_menu(int socket, struct user_record *user) {
|
||||
do_internal_menu = 0;
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
}
|
||||
} else {
|
||||
@ -56,7 +56,7 @@ void main_menu(int socket, struct user_record *user) {
|
||||
lua_getglobal(L, "menu");
|
||||
result = lua_pcall(L, 0, 1, 0);
|
||||
if (result) {
|
||||
fprintf(stderr, "Failed to run script: %s\n", lua_tostring(L, -1));
|
||||
dolog("Failed to run script: %s", lua_tostring(L, -1));
|
||||
do_internal_menu = 1;
|
||||
lua_close(L);
|
||||
continue;
|
||||
|
30
users.c
30
users.c
@ -36,7 +36,7 @@ int save_user(struct user_record *user) {
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -60,7 +60,7 @@ int save_user(struct user_record *user) {
|
||||
sqlite3_bind_int(res, 13, user->timeson);
|
||||
sqlite3_bind_text(res, 14, user->loginname, -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ int save_user(struct user_record *user) {
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
|
||||
printf("execution failed: %s", sqlite3_errmsg(db));
|
||||
dolog("execution failed: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
@ -108,7 +108,7 @@ int inst_user(struct user_record *user) {
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -117,7 +117,7 @@ int inst_user(struct user_record *user) {
|
||||
rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg);
|
||||
if (rc != SQLITE_OK ) {
|
||||
|
||||
fprintf(stderr, "SQL error: %s\n", err_msg);
|
||||
dolog("SQL error: %s", err_msg);
|
||||
|
||||
sqlite3_free(err_msg);
|
||||
sqlite3_close(db);
|
||||
@ -144,7 +144,7 @@ int inst_user(struct user_record *user) {
|
||||
sqlite3_bind_int(res, 14, user->timeson);
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ int inst_user(struct user_record *user) {
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
|
||||
printf("execution failed: %s", sqlite3_errmsg(db));
|
||||
dolog("execution failed: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
@ -176,7 +176,7 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password)
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -186,7 +186,7 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password)
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_text(res, 1, loginname, -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return NULL;
|
||||
@ -236,7 +236,7 @@ struct user_record *check_user_pass(int socket, char *loginname, char *password)
|
||||
|
||||
sprintf(buffer, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
||||
if (ini_parse(buffer, secLevel, user->sec_info) <0) {
|
||||
printf("Unable to load sec Level ini (%s)!\n", buffer);
|
||||
dolog("Unable to load sec Level ini (%s)!", buffer);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -273,13 +273,13 @@ void list_users(int socket, struct user_record *user) {
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
rc = sqlite3_prepare_v2(db, sql, -1, &res, 0);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot prepare statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot prepare statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
@ -320,7 +320,7 @@ int check_user(char *loginname) {
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
|
||||
exit(1);
|
||||
@ -330,7 +330,7 @@ int check_user(char *loginname) {
|
||||
if (rc == SQLITE_OK) {
|
||||
sqlite3_bind_text(res, 1, loginname, -1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to execute statement: %s\n", sqlite3_errmsg(db));
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
int step = sqlite3_step(res);
|
||||
@ -471,7 +471,7 @@ struct user_record *new_user(int socket) {
|
||||
sprintf(buffer, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
||||
|
||||
if (ini_parse(buffer, secLevel, user->sec_info) <0) {
|
||||
printf("Unable to load sec Level ini (%s)!\n", buffer);
|
||||
dolog("Unable to load sec Level ini (%s)!", buffer);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user