clang-format
Fix a bunch of trivial formatting issues by running `clang-format`. Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
This commit is contained in:
parent
ff966a6b4d
commit
d6826137dd
32
src/bbs.c
32
src/bbs.c
@ -21,13 +21,11 @@
|
||||
#include "lua/lualib.h"
|
||||
#include "lua/lauxlib.h"
|
||||
|
||||
|
||||
int telnet_bin_mode = 0;
|
||||
|
||||
int mynode = 0;
|
||||
struct bbs_config conf;
|
||||
|
||||
|
||||
struct user_record *gUser;
|
||||
int gSocket;
|
||||
int sshBBS;
|
||||
@ -39,8 +37,7 @@ struct mosquitto *mosq = NULL;
|
||||
|
||||
char *ipaddress = NULL;
|
||||
|
||||
void sigterm_handler2(int s)
|
||||
{
|
||||
void sigterm_handler2(int s) {
|
||||
if (mynode != 0) {
|
||||
disconnect("Terminated.");
|
||||
}
|
||||
@ -48,8 +45,7 @@ void sigterm_handler2(int s)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void sigint_handler(int s)
|
||||
{
|
||||
void sigint_handler(int s) {
|
||||
// do nothing...
|
||||
}
|
||||
void broadcast(char *mess, ...) {
|
||||
@ -153,8 +149,7 @@ struct fido_addr *parse_fido_addr(const char *str) {
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
{
|
||||
case '9': {
|
||||
switch (state) {
|
||||
case 0:
|
||||
ret->zone = ret->zone * 10 + (str[c] - '0');
|
||||
@ -169,8 +164,7 @@ struct fido_addr *parse_fido_addr(const char *str) {
|
||||
ret->point = ret->point * 10 + (str[c] - '0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
default:
|
||||
free(ret);
|
||||
return NULL;
|
||||
@ -179,7 +173,6 @@ struct fido_addr *parse_fido_addr(const char *str) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void timer_handler(int signum) {
|
||||
if (signum == SIGALRM) {
|
||||
if (gUser != NULL) {
|
||||
@ -189,8 +182,6 @@ void timer_handler(int signum) {
|
||||
s_printf(get_string(0));
|
||||
disconnect("Out of Time");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (timeoutpaused == 0) {
|
||||
usertimeout--;
|
||||
@ -396,7 +387,6 @@ void s_displayansi_p(char *file) {
|
||||
s_displayansi_pause(file, 0);
|
||||
}
|
||||
|
||||
|
||||
void s_displayansi(char *file) {
|
||||
FILE *fptr;
|
||||
char c;
|
||||
@ -411,7 +401,6 @@ void s_displayansi(char *file) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char s_getchar() {
|
||||
unsigned char c;
|
||||
unsigned char d;
|
||||
@ -490,7 +479,6 @@ char s_getchar() {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -887,7 +875,6 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
||||
usertimeout = 10;
|
||||
timeoutpaused = 0;
|
||||
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = &timer_handler;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
@ -915,7 +902,6 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
||||
}
|
||||
gSocket = socket;
|
||||
|
||||
|
||||
if (!ssh) {
|
||||
gUser = NULL;
|
||||
sshBBS = 0;
|
||||
@ -1095,13 +1081,10 @@ tryagain:
|
||||
recursive_delete(buffer);
|
||||
}
|
||||
|
||||
|
||||
#if defined(ENABLE_WWW)
|
||||
www_expire_old_links();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// do post-login
|
||||
dolog("%s logged in, on node %d", user->loginname, mynode);
|
||||
broadcast("USER: %s; NODE:%d; STATUS: Logged in.", user->loginname, mynode);
|
||||
@ -1120,7 +1103,6 @@ tryagain:
|
||||
|
||||
user->timeson++;
|
||||
|
||||
|
||||
if (conf.script_path != NULL) {
|
||||
snprintf(buffer, PATH_MAX, "%s/login_stanza.lua", conf.script_path);
|
||||
if (stat(buffer, &s) == 0) {
|
||||
@ -1339,7 +1321,8 @@ char *str_replace(const char *str, const char *from, const char *to) {
|
||||
pos_cache_tmp = realloc(pos_cache, sizeof(*pos_cache) * cache_sz);
|
||||
if (pos_cache_tmp == NULL) {
|
||||
goto end_repl_str;
|
||||
} else pos_cache = pos_cache_tmp;
|
||||
} else
|
||||
pos_cache = pos_cache_tmp;
|
||||
cache_sz_inc *= cache_sz_inc_factor;
|
||||
if (cache_sz_inc > cache_sz_inc_max) {
|
||||
cache_sz_inc = cache_sz_inc_max;
|
||||
@ -1356,7 +1339,8 @@ char *str_replace(const char *str, const char *from, const char *to) {
|
||||
if (count > 0) {
|
||||
tolen = strlen(to);
|
||||
retlen = orglen + (tolen - fromlen) * count;
|
||||
} else retlen = orglen;
|
||||
} else
|
||||
retlen = orglen;
|
||||
ret = malloc(retlen + 1);
|
||||
if (ret == NULL) {
|
||||
goto end_repl_str;
|
||||
|
@ -90,7 +90,6 @@ int add_bbs(struct bbs_list_entry_t *new_entry) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
|
@ -175,7 +175,6 @@ void blog_display() {
|
||||
|
||||
s_printf(get_string(6));
|
||||
s_getchar();
|
||||
|
||||
}
|
||||
|
||||
void blog_write() {
|
||||
|
@ -175,7 +175,6 @@ int bwave_scan_area(int confr, int area, int areano, int totmsgs, FILE *fti_file
|
||||
} else if (jlr.LastReadMsg == 0 && jlr.HighReadMsg == 0) {
|
||||
all_unread = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (all_unread == 0) {
|
||||
@ -461,7 +460,6 @@ void bwave_create_packet() {
|
||||
if (totmsgs == conf.bwave_max_msgs) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (totmsgs == conf.bwave_max_msgs) {
|
||||
@ -588,7 +586,6 @@ void bwave_create_packet() {
|
||||
s_getc();
|
||||
}
|
||||
|
||||
|
||||
int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char *subject, struct fido_addr *destaddr, char *msg) {
|
||||
s_JamBase *jb;
|
||||
s_JamMsgHeader jmh;
|
||||
@ -613,7 +610,6 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
sprintf(buffer, "%s %s", gUser->firstname, gUser->lastname);
|
||||
}
|
||||
|
||||
|
||||
jsp = JAM_NewSubPacket();
|
||||
|
||||
jsf.LoID = JAMSFLD_SENDERNAME;
|
||||
@ -647,7 +643,6 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
if (conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_ECHOMAIL_AREA || conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_NEWSGROUP_AREA) {
|
||||
jmh.Attribute |= JAM_MSG_TYPEECHO;
|
||||
|
||||
|
||||
if (conf.mail_conferences[confr]->nettype == NETWORK_FIDO) {
|
||||
if (conf.mail_conferences[confr]->fidoaddr->point) {
|
||||
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[confr]->fidoaddr->zone,
|
||||
@ -685,7 +680,6 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
|
||||
uuid_generate(magi_msgid);
|
||||
uuid_unparse_lower(magi_msgid, buffer);
|
||||
|
||||
@ -1118,7 +1112,6 @@ void bwave_upload_reply() {
|
||||
}
|
||||
body[bpos] = '\0';
|
||||
|
||||
|
||||
if (bwave_add_message(confr, area, convertl(upl_rec.unix_date), upl_rec.to, upl_rec.subj, &addr, body) != 0) {
|
||||
// failed to add message
|
||||
s_printf(get_string(197));
|
||||
|
@ -22,12 +22,10 @@
|
||||
#ifndef __BLUEWAVE_H /* An extra safeguard to prevent this header from */
|
||||
#define __BLUEWAVE_H /* being included twice in the same source file */
|
||||
|
||||
|
||||
#define PACKET_LEVEL 3 /* The current mail packet revision level, */
|
||||
/* used in the "ver" field of the *.INF */
|
||||
/* file header. */
|
||||
|
||||
|
||||
/*
|
||||
** This header defines the data structures for the following files in the
|
||||
** official Blue Wave offline mail specification:
|
||||
@ -67,12 +65,10 @@
|
||||
** function. Example: "memset(&ftirec, 0, sizeof(FTI_REC))".)
|
||||
*/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* >>>>>>>>>>>>>>>>>>>>>>> DATA TYPE DEFINITIONS <<<<<<<<<<<<<<<<<<<<<<<<< */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
** The data type definitions below help make these structures a little more
|
||||
** universal between environments. The 8-bit, 16-bit, and 32-bit data types
|
||||
@ -96,9 +92,6 @@
|
||||
** they aren't, you're bound to get some *very* interesting results.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
typedef signed char tCHAR; /* 8 bit signed values */
|
||||
typedef unsigned char tBYTE; /* 8 bit unsigned values */
|
||||
typedef signed short tINT; /* 16 bit signed values */
|
||||
@ -106,12 +99,10 @@ typedef unsigned short tWORD; /* 16 bit unsigned values */
|
||||
typedef int tLONG; /* 32 bit signed values */
|
||||
typedef unsigned int tDWORD; /* 32 bit unsigned values */
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* >>>>>>>>>>>>>>>>>>>>> DOOR DATA FILE STRUCTURES <<<<<<<<<<<<<<<<<<<<<<< */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
** Name of file: *.INF
|
||||
**
|
||||
@ -534,12 +525,10 @@ FTI_REC;
|
||||
** File format: Unstructured
|
||||
*/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* >>>>>>>>>>>>>>>>> MISCELLANEOUS DATA FILE STRUCTURES <<<<<<<<<<<<<<<<<< */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
** Name of file: *.MSG
|
||||
**
|
||||
@ -667,12 +656,10 @@ typedef struct /* XTI_REC */
|
||||
} __attribute__((packed))
|
||||
XTI_REC;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* >>>>>>>>>>>>>>>>>>>> READER DATA FILE STRUCTURES <<<<<<<<<<<<<<<<<<<<<< */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
** Name of file: *.NET
|
||||
**
|
||||
@ -1149,4 +1136,3 @@ PDQ_REC;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* __BLUEWAVE_H */
|
||||
|
||||
|
@ -37,7 +37,6 @@ struct chat_msg {
|
||||
char msg[512];
|
||||
};
|
||||
|
||||
|
||||
static int jsoneq(const char *json, jsmntok_t *tok, const char *s) {
|
||||
if (tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
|
||||
strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
|
||||
@ -284,8 +283,6 @@ void chat_system(struct user_record *user) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
row_at = 0;
|
||||
line_at = 0;
|
||||
s_putstring("\e[2J\e[23;1H");
|
||||
@ -360,8 +357,6 @@ void chat_system(struct user_record *user) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
memset(buffer, 0, 513);
|
||||
|
||||
screenbuffer = (struct character_t ***)malloc(sizeof(struct character_t **) * 23);
|
||||
@ -493,11 +488,9 @@ void chat_system(struct user_record *user) {
|
||||
append_screenbuffer(outputbuffer);
|
||||
do_update = 1;
|
||||
|
||||
|
||||
memset(buffer, 0, 513);
|
||||
buffer_at = 0;
|
||||
}
|
||||
|
||||
}
|
||||
if (z < len) {
|
||||
memset(partmessage, 0, 1024);
|
||||
|
10
src/doors.c
10
src/doors.c
@ -36,10 +36,10 @@ int running_door = 0;
|
||||
extern int telnet_bin_mode;
|
||||
extern int timeoutpaused;
|
||||
|
||||
void doorchld_handler(int s)
|
||||
{
|
||||
void doorchld_handler(int s) {
|
||||
// waitpid() might overwrite errno, so we save and restore it:
|
||||
while(waitpid(-1, NULL, WNOHANG) > 0);
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||
;
|
||||
|
||||
running_door = 0;
|
||||
}
|
||||
@ -192,8 +192,6 @@ int write_door32sys(struct user_record *user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage) {
|
||||
char *arguments[4];
|
||||
int door_out;
|
||||
@ -276,8 +274,6 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
|
||||
door_out = gSocket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ws.ws_row = 24;
|
||||
ws.ws_col = 80;
|
||||
|
||||
|
@ -82,7 +82,6 @@ void send_email(struct user_record *user) {
|
||||
char *subject;
|
||||
char *msg;
|
||||
|
||||
|
||||
s_printf(get_string(54));
|
||||
s_readstring(buffer, 16);
|
||||
|
||||
@ -156,7 +155,6 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema
|
||||
lines = 0;
|
||||
chars = 0;
|
||||
|
||||
|
||||
msg_line_count = 0;
|
||||
start_line = 0;
|
||||
|
||||
@ -272,7 +270,6 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
|
||||
|
||||
if (tolower(c) == 'r') {
|
||||
if (emails[msgno]->subject != NULL) {
|
||||
if (strncasecmp(emails[msgno]->subject, "RE:", 3) != 0) {
|
||||
@ -620,7 +617,6 @@ void list_emails(struct user_record *user) {
|
||||
free(emails);
|
||||
}
|
||||
|
||||
|
||||
int mail_getemailcount(struct user_record *user) {
|
||||
char *sql = "SELECT COUNT(*) FROM email WHERE recipient LIKE ?";
|
||||
int count;
|
||||
|
14
src/files.c
14
src/files.c
@ -117,7 +117,6 @@ void ZFlowControl(int onoff, ZModem *info) {
|
||||
void ZStatus(int type, int value, char *status) {
|
||||
}
|
||||
|
||||
|
||||
char *upload_path;
|
||||
char upload_filename[1024];
|
||||
|
||||
@ -428,7 +427,6 @@ char *get_file_id_diz(char *filename) {
|
||||
continue;
|
||||
} else {
|
||||
description[bpos++] = description[i];
|
||||
|
||||
}
|
||||
}
|
||||
description[bpos] = '\0';
|
||||
@ -710,7 +708,6 @@ int do_upload(struct user_record *user, char *final_path) {
|
||||
recursive_delete(upload_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
closedir(inb);
|
||||
@ -856,7 +853,6 @@ void download_zmodem(struct user_record *user, char *filename) {
|
||||
|
||||
zm.packetsize = 1024;
|
||||
|
||||
|
||||
ZmodemTInit(&zm);
|
||||
done = doIO(&zm);
|
||||
if (done != ZmDone) {
|
||||
@ -899,7 +895,6 @@ void download_zmodem(struct user_record *user, char *filename) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void genurls() {
|
||||
#if defined(ENABLE_WWW)
|
||||
int i;
|
||||
@ -942,7 +937,6 @@ void genurls() {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void download(struct user_record *user) {
|
||||
int i;
|
||||
char *ssql = "select dlcount from files where filename like ?";
|
||||
@ -953,7 +947,6 @@ void download(struct user_record *user) {
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
|
||||
|
||||
for (i = 0; i < tagged_count; i++) {
|
||||
s_printf(get_string(254), basename(tagged_files[i]->filename));
|
||||
|
||||
@ -1005,8 +998,6 @@ void download(struct user_record *user) {
|
||||
sqlite3_close(db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < tagged_count; i++) {
|
||||
free(tagged_files[i]->filename);
|
||||
free(tagged_files[i]);
|
||||
@ -1329,8 +1320,6 @@ void file_search() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||
if (files_c == 0) {
|
||||
files_e = (struct file_entry **)malloc(sizeof(struct file_entry *));
|
||||
@ -1456,7 +1445,6 @@ void list_files(struct user_record *user) {
|
||||
default:
|
||||
sql = fsql;
|
||||
break;
|
||||
|
||||
}
|
||||
s_printf("\r\n");
|
||||
snprintf(buffer, PATH_MAX, "%s/%s.sq3", conf.bbs_path, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->database);
|
||||
@ -1479,8 +1467,6 @@ void list_files(struct user_record *user) {
|
||||
sqlite3_bind_int(res, 1, userlaston);
|
||||
}
|
||||
|
||||
|
||||
|
||||
files_c = 0;
|
||||
|
||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||
|
@ -141,19 +141,16 @@ static unsigned long crc32_tab[] = {
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
0x2d02ef8dL};
|
||||
|
||||
/* Return a 32-bit CRC of the contents of the buffer. */
|
||||
|
||||
unsigned long crc32(const unsigned char *s, unsigned int len)
|
||||
{
|
||||
unsigned long crc32(const unsigned char *s, unsigned int len) {
|
||||
unsigned int i;
|
||||
unsigned long crc32val;
|
||||
|
||||
crc32val = 0;
|
||||
for (i = 0; i < len; i ++)
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
crc32val =
|
||||
crc32_tab[(crc32val ^ s[i]) & 0xff] ^
|
||||
(crc32val >> 8);
|
||||
@ -392,6 +389,8 @@ void hashmap_free(map_t in){
|
||||
/* Return the length of the hashmap */
|
||||
int hashmap_length(map_t in) {
|
||||
hashmap_map *m = (hashmap_map *)in;
|
||||
if(m != NULL) return m->size;
|
||||
else return 0;
|
||||
if (m != NULL)
|
||||
return m->size;
|
||||
else
|
||||
return 0;
|
||||
}
|
@ -12,14 +12,12 @@
|
||||
#define KEY_PREFIX ("somekey")
|
||||
#define KEY_COUNT (1024 * 1024)
|
||||
|
||||
typedef struct data_struct_s
|
||||
{
|
||||
typedef struct data_struct_s {
|
||||
char key_string[KEY_MAX_LENGTH];
|
||||
int number;
|
||||
} data_struct_t;
|
||||
|
||||
int main(char* argv, int argc)
|
||||
{
|
||||
int main(char *argv, int argc) {
|
||||
int index;
|
||||
int error;
|
||||
map_t mymap;
|
||||
@ -29,8 +27,7 @@ int main(char* argv, int argc)
|
||||
mymap = hashmap_new();
|
||||
|
||||
/* First, populate the hash map with ascending values */
|
||||
for (index=0; index<KEY_COUNT; index+=1)
|
||||
{
|
||||
for (index = 0; index < KEY_COUNT; index += 1) {
|
||||
/* Store the key string along side the numerical value so we can free it later */
|
||||
value = malloc(sizeof(data_struct_t));
|
||||
snprintf(value->key_string, KEY_MAX_LENGTH, "%s%d", KEY_PREFIX, index);
|
||||
@ -41,8 +38,7 @@ int main(char* argv, int argc)
|
||||
}
|
||||
|
||||
/* Now, check all of the expected values are there */
|
||||
for (index=0; index<KEY_COUNT; index+=1)
|
||||
{
|
||||
for (index = 0; index < KEY_COUNT; index += 1) {
|
||||
snprintf(key_string, KEY_MAX_LENGTH, "%s%d", KEY_PREFIX, index);
|
||||
|
||||
error = hashmap_get(mymap, key_string, (void **)(&value));
|
||||
@ -61,8 +57,7 @@ int main(char* argv, int argc)
|
||||
assert(error == MAP_MISSING);
|
||||
|
||||
/* Free all of the values we allocated and remove them from the map */
|
||||
for (index=0; index<KEY_COUNT; index+=1)
|
||||
{
|
||||
for (index = 0; index < KEY_COUNT; index += 1) {
|
||||
snprintf(key_string, KEY_MAX_LENGTH, "%s%d", KEY_PREFIX, index);
|
||||
|
||||
error = hashmap_get(mymap, key_string, (void **)(&value));
|
||||
|
@ -25,8 +25,7 @@ https://github.com/benhoyt/inih
|
||||
#define MAX_NAME 50
|
||||
|
||||
/* Strip whitespace chars off end of given string, in place. Return s. */
|
||||
static char* rstrip(char* s)
|
||||
{
|
||||
static char *rstrip(char *s) {
|
||||
char *p = s + strlen(s);
|
||||
while (p > s && isspace((unsigned char)(*--p)))
|
||||
*p = '\0';
|
||||
@ -34,8 +33,7 @@ static char* rstrip(char* s)
|
||||
}
|
||||
|
||||
/* Return pointer to first non-whitespace char in given string. */
|
||||
static char* lskip(const char* s)
|
||||
{
|
||||
static char *lskip(const char *s) {
|
||||
while (*s && isspace((unsigned char)(*s)))
|
||||
s++;
|
||||
return (char *)s;
|
||||
@ -44,8 +42,7 @@ static char* lskip(const char* s)
|
||||
/* Return pointer to first char (of chars) or inline comment in given string,
|
||||
or pointer to null at end of string if neither found. Inline comment must
|
||||
be prefixed by a whitespace character to register as a comment. */
|
||||
static char* find_chars_or_comment(const char* s, const char* chars)
|
||||
{
|
||||
static char *find_chars_or_comment(const char *s, const char *chars) {
|
||||
#if INI_ALLOW_INLINE_COMMENTS
|
||||
int was_space = 0;
|
||||
while (*s && (!chars || !strchr(chars, *s)) &&
|
||||
@ -62,8 +59,7 @@ static char* find_chars_or_comment(const char* s, const char* chars)
|
||||
}
|
||||
|
||||
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
|
||||
static char* strncpy0(char* dest, const char* src, size_t size)
|
||||
{
|
||||
static char *strncpy0(char *dest, const char *src, size_t size) {
|
||||
strncpy(dest, src, size);
|
||||
dest[size - 1] = '\0';
|
||||
return dest;
|
||||
@ -71,8 +67,7 @@ static char* strncpy0(char* dest, const char* src, size_t size)
|
||||
|
||||
/* See documentation in header file. */
|
||||
int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
|
||||
void* user)
|
||||
{
|
||||
void *user) {
|
||||
/* Uses a fair bit of stack (use heap instead if you need to) */
|
||||
#if INI_USE_STACK
|
||||
char line[INI_MAX_LINE];
|
||||
@ -129,13 +124,11 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
*end = '\0';
|
||||
strncpy0(section, start + 1, sizeof(section));
|
||||
*prev_name = '\0';
|
||||
}
|
||||
else if (!error) {
|
||||
} else if (!error) {
|
||||
/* No ']' found on section line */
|
||||
error = lineno;
|
||||
}
|
||||
}
|
||||
else if (*start) {
|
||||
} else if (*start) {
|
||||
/* Not a comment, must be a name[=:]value pair */
|
||||
end = find_chars_or_comment(start, "=:");
|
||||
if (*end == '=' || *end == ':') {
|
||||
@ -153,8 +146,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
strncpy0(prev_name, name, sizeof(prev_name));
|
||||
if (!handler(user, section, name, value) && !error)
|
||||
error = lineno;
|
||||
}
|
||||
else if (!error) {
|
||||
} else if (!error) {
|
||||
/* No '=' or ':' found on name[=:]value line */
|
||||
error = lineno;
|
||||
}
|
||||
@ -174,14 +166,12 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
}
|
||||
|
||||
/* See documentation in header file. */
|
||||
int ini_parse_file(FILE* file, ini_handler handler, void* user)
|
||||
{
|
||||
int ini_parse_file(FILE *file, ini_handler handler, void *user) {
|
||||
return ini_parse_stream((ini_reader)fgets, file, handler, user);
|
||||
}
|
||||
|
||||
/* See documentation in header file. */
|
||||
int ini_parse(const char* filename, ini_handler handler, void* user)
|
||||
{
|
||||
int ini_parse(const char *filename, ini_handler handler, void *user) {
|
||||
FILE *file;
|
||||
int error;
|
||||
|
||||
|
@ -187,7 +187,6 @@ int l_getBBSInfo(lua_State *L) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
int l_getUserHandle(lua_State *L) {
|
||||
lua_pushstring(L, gUser->loginname);
|
||||
|
||||
@ -281,7 +280,6 @@ int l_readMessageHdr(lua_State *L) {
|
||||
memset(recipient, 0, jsp->Fields[z]->DatLen + 1);
|
||||
memcpy(recipient, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||
}
|
||||
|
||||
}
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
@ -307,7 +305,6 @@ int l_readMessageHdr(lua_State *L) {
|
||||
free(sender);
|
||||
free(recipient);
|
||||
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
@ -420,7 +417,6 @@ int l_postMessage(lua_State *L) {
|
||||
jmh.DateWritten = dwritten;
|
||||
jmh.Attribute |= JAM_MSG_LOCAL;
|
||||
|
||||
|
||||
jsp = JAM_NewSubPacket();
|
||||
|
||||
jsf.LoID = JAMSFLD_SENDERNAME;
|
||||
|
@ -36,7 +36,6 @@ time_t utc_to_local(time_t utc) {
|
||||
return local;
|
||||
}
|
||||
|
||||
|
||||
s_JamBase *open_jam_base(char *path) {
|
||||
int ret;
|
||||
s_JamBase *jb;
|
||||
@ -432,8 +431,6 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
|
||||
struct stat s;
|
||||
struct utsname name;
|
||||
|
||||
|
||||
|
||||
if (conf.external_editor_cmd != NULL && user->exteditor != 0) {
|
||||
if (user->exteditor == 2) {
|
||||
s_printf(get_string(85));
|
||||
@ -519,8 +516,6 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
|
||||
body = (char *)realloc(body, totlen + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
memcpy(&body[totlen - len], buffer, len);
|
||||
body[totlen] = '\0';
|
||||
|
||||
@ -1303,7 +1298,6 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
||||
bg = 0x07;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
state = 0;
|
||||
break;
|
||||
@ -1420,8 +1414,6 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
||||
case 0x07:
|
||||
buffer[buf_at++] = '7';
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
buffer[buf_at++] = '1';
|
||||
@ -1452,12 +1444,9 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
||||
case 0x0F:
|
||||
buffer[buf_at++] = '7';
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bg = fake_screen[i][j]->bg;
|
||||
buffer[buf_at++] = ';';
|
||||
buffer[buf_at++] = '4';
|
||||
@ -1486,15 +1475,12 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
||||
case 0x07:
|
||||
buffer[buf_at++] = '7';
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
buffer[buf_at++] = 'm';
|
||||
}
|
||||
buffer[buf_at++] = fake_screen[i][j]->c;
|
||||
}
|
||||
|
||||
|
||||
while (buf_at > 0 && buffer[buf_at - 1] == ' ') {
|
||||
buf_at--;
|
||||
}
|
||||
@ -1508,7 +1494,6 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
||||
|
||||
memcpy(&out[out_len], buffer, buf_at);
|
||||
out_len += buf_at;
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < line_count; i++) {
|
||||
@ -1523,14 +1508,10 @@ void unmangle_ansi(char *body, int len, char **body_out, int *body_len) {
|
||||
out_len--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
*body_out = out;
|
||||
*body_len = out_len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int read_message(struct user_record *user, struct msg_headers *msghs, int mailno, int newscan) {
|
||||
s_JamBase *jb;
|
||||
s_JamMsgHeader jmh;
|
||||
@ -1538,7 +1519,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
s_JamSubfield jsf;
|
||||
s_JamLastRead jlr;
|
||||
|
||||
|
||||
char buffer[256];
|
||||
int z, z2;
|
||||
struct tm msg_date;
|
||||
@ -1726,7 +1706,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tolower(c) == 'r') {
|
||||
@ -1813,8 +1792,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
jsf.Buffer = (char *)subject;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
|
||||
|
||||
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA || conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NEWSGROUP_AREA) {
|
||||
jmh.Attribute |= JAM_MSG_TYPEECHO;
|
||||
|
||||
@ -1835,7 +1812,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
|
||||
sprintf(buffer, "%d:%d/%d.%d %08lx", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
|
||||
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
|
||||
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
|
||||
@ -1858,7 +1834,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(buffer));
|
||||
}
|
||||
|
||||
|
||||
} else if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_MAGI) {
|
||||
sprintf(buffer, "%d", conf.mail_conferences[user->cur_mail_conf]->maginode);
|
||||
jsf.LoID = JAMSFLD_OADDRESS;
|
||||
@ -1932,7 +1907,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
free(from_addr);
|
||||
}
|
||||
|
||||
|
||||
sprintf(buffer, "%d:%d/%d.%d %08lx", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
|
||||
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
|
||||
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
|
||||
@ -2334,7 +2308,6 @@ void post_message(struct user_record *user) {
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
|
||||
uuid_generate(magi_msgid);
|
||||
uuid_unparse_lower(magi_msgid, buffer);
|
||||
|
||||
@ -2516,7 +2489,6 @@ void list_messages(struct user_record *user) {
|
||||
}
|
||||
closed = 0;
|
||||
|
||||
|
||||
redraw = 1;
|
||||
start = i - 1;
|
||||
while (!closed) {
|
||||
@ -2693,7 +2665,6 @@ void list_messages(struct user_record *user) {
|
||||
}
|
||||
}
|
||||
s_printf("\e[%d;5H", i - start + 1);
|
||||
|
||||
}
|
||||
} else if (c == 75) {
|
||||
// END KEY
|
||||
@ -2929,7 +2900,6 @@ void choose_area() {
|
||||
height = 13;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < conf.mail_conferences[gUser->cur_mail_conf]->mail_area_count; i++) {
|
||||
if (conf.mail_conferences[gUser->cur_mail_conf]->mail_areas[i]->read_sec_level <= gUser->sec_level) {
|
||||
if (list_tmp == 0) {
|
||||
@ -3084,7 +3054,6 @@ void choose_area() {
|
||||
free(area_tmp);
|
||||
}
|
||||
|
||||
|
||||
void next_mail_conf(struct user_record *user) {
|
||||
int i;
|
||||
|
||||
@ -3140,8 +3109,6 @@ void prev_mail_area(struct user_record *user) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void do_mail_scan(struct user_record *user, int oldscan, int personal) {
|
||||
s_JamBase *jb;
|
||||
s_JamBaseHeader jbh;
|
||||
@ -3284,8 +3251,6 @@ void do_mail_scan(struct user_record *user, int oldscan, int personal) {
|
||||
} else {
|
||||
if (jlr.HighReadMsg < jbh.ActiveMsgs) {
|
||||
|
||||
|
||||
|
||||
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
|
||||
msghs = read_message_headers(i, j, user, personal);
|
||||
if (msghs != NULL) {
|
||||
@ -3413,7 +3378,6 @@ void mail_scan(struct user_record *user) {
|
||||
do_mail_scan(user, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
void msg_conf_sub_bases() {
|
||||
int i;
|
||||
int lines = 0;
|
||||
|
47
src/main.c
47
src/main.c
@ -51,8 +51,7 @@ int bbs_stderr;
|
||||
struct MHD_Daemon *www_daemon;
|
||||
#endif
|
||||
|
||||
void sigterm_handler(int s)
|
||||
{
|
||||
void sigterm_handler(int s) {
|
||||
if (ssh_pid != -1) {
|
||||
kill(ssh_pid, SIGTERM);
|
||||
}
|
||||
@ -71,19 +70,18 @@ void sigterm_handler(int s)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void sigchld_handler(int s)
|
||||
{
|
||||
void sigchld_handler(int s) {
|
||||
// waitpid() might overwrite errno, so we save and restore it:
|
||||
int saved_errno = errno;
|
||||
|
||||
while(waitpid(-1, NULL, WNOHANG) > 0);
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||
;
|
||||
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
static int protocol_config_handler(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct bbs_config *conf = (struct bbs_config *)user;
|
||||
int i;
|
||||
|
||||
@ -159,8 +157,7 @@ static int protocol_config_handler(void* user, const char* section, const char*
|
||||
}
|
||||
|
||||
static int archiver_config_handler(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct bbs_config *conf = (struct bbs_config *)user;
|
||||
int i;
|
||||
|
||||
@ -201,8 +198,7 @@ static int archiver_config_handler(void* user, const char* section, const char*
|
||||
}
|
||||
|
||||
static int door_config_handler(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct bbs_config *conf = (struct bbs_config *)user;
|
||||
int i;
|
||||
|
||||
@ -252,8 +248,7 @@ static int door_config_handler(void* user, const char* section, const char* name
|
||||
}
|
||||
|
||||
static int file_sub_handler(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct file_directory *fd = (struct file_directory *)user;
|
||||
int i;
|
||||
|
||||
@ -306,10 +301,8 @@ static int file_sub_handler(void* user, const char* section, const char* name,
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int mail_area_handler(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct mail_conference *mc = (struct mail_conference *)user;
|
||||
int i;
|
||||
|
||||
@ -417,8 +410,7 @@ static int mail_area_handler(void* user, const char* section, const char* name,
|
||||
}
|
||||
|
||||
static int handler(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct bbs_config *conf = (struct bbs_config *)user;
|
||||
struct passwd *pwd;
|
||||
|
||||
@ -612,7 +604,6 @@ static int handler(void* user, const char* section, const char* name,
|
||||
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;
|
||||
@ -732,8 +723,7 @@ struct ssh_channel_callbacks_struct ssh_cb = {
|
||||
.channel_data_function = ssh_copy_chan_to_fd,
|
||||
.channel_eof_function = ssh_chan_close,
|
||||
.channel_close_function = ssh_chan_close,
|
||||
.userdata = NULL
|
||||
};
|
||||
.userdata = NULL};
|
||||
|
||||
void serverssh(int port, int ipv6) {
|
||||
ssh_session p_ssh_session;
|
||||
@ -789,7 +779,6 @@ void serverssh(int port, int ipv6) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
if (setsockopt(ssh_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) {
|
||||
fprintf(stderr, "setsockopt(SO_REUSEADDR) failed");
|
||||
exit(-1);
|
||||
@ -879,7 +868,6 @@ void serverssh(int port, int ipv6) {
|
||||
free(ip);
|
||||
ssh_disconnect(p_ssh_session);
|
||||
continue;
|
||||
|
||||
}
|
||||
} else {
|
||||
ip_guard->connection_count = 0;
|
||||
@ -945,10 +933,6 @@ void serverssh(int port, int ipv6) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bbs_pid = forkpty(&fd, NULL, NULL, NULL);
|
||||
if (bbs_pid == 0) {
|
||||
tcgetattr(STDIN_FILENO, &tios);
|
||||
@ -998,7 +982,6 @@ void serverssh(int port, int ipv6) {
|
||||
close(csock);
|
||||
free(ip);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1134,7 +1117,6 @@ void server(int port, int ipv6) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) {
|
||||
remove(conf.pid_file);
|
||||
fprintf(stderr, "setsockopt(SO_REUSEADDR) failed");
|
||||
@ -1145,7 +1127,6 @@ void server(int port, int ipv6) {
|
||||
printf(" - Telnet Starting on Port %d (IPv%d)\n", port, (ipv6 ? 6 : 4));
|
||||
}
|
||||
|
||||
|
||||
if (ipv6) {
|
||||
if (setsockopt(server_socket, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)) < 0) {
|
||||
fprintf(stderr, "setsockopt(IPV6_V6ONLY) failed");
|
||||
@ -1205,7 +1186,6 @@ void server(int port, int ipv6) {
|
||||
|
||||
listen(server_socket, 3);
|
||||
|
||||
|
||||
while ((client_sock = accept(server_socket, (struct sockaddr *)client_p, (socklen_t *)&c))) {
|
||||
if (ipv6) {
|
||||
ip = strdup(inet_ntop(AF_INET6, &((struct sockaddr_in6 *)client_p)->sin6_addr, str, sizeof(str)));
|
||||
@ -1249,7 +1229,6 @@ void server(int port, int ipv6) {
|
||||
free(ip);
|
||||
close(client_sock);
|
||||
continue;
|
||||
|
||||
}
|
||||
} else {
|
||||
ip_guard->connection_count = 0;
|
||||
@ -1375,7 +1354,6 @@ int main(int argc, char **argv) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
load_strings();
|
||||
|
||||
if (conf.fork) {
|
||||
@ -1389,8 +1367,7 @@ int main(int argc, char **argv) {
|
||||
if (main_pid < 0) {
|
||||
fprintf(stderr, "Error forking.\n");
|
||||
exit(-1);
|
||||
} else
|
||||
if (main_pid > 0) {
|
||||
} else if (main_pid > 0) {
|
||||
if (conf.uid != getuid()) {
|
||||
if (setgid(conf.gid) != 0 || setuid(conf.uid) != 0) {
|
||||
perror("Setuid Error: ");
|
||||
|
10
src/menus.c
10
src/menus.c
@ -97,7 +97,6 @@ int menu_system(char *menufile) {
|
||||
dolog("%s is loading menu: %s", gUser->loginname, menufile);
|
||||
broadcast("USER: %s; NODE:%d; STATUS: Browsing menu %s.", gUser->loginname, mynode, menufile);
|
||||
|
||||
|
||||
if (menufile[0] == '/') {
|
||||
snprintf(buffer, PATH_MAX, "%s.mnu", menufile);
|
||||
} else {
|
||||
@ -113,11 +112,9 @@ int menu_system(char *menufile) {
|
||||
lua_script = NULL;
|
||||
ansi_file = NULL;
|
||||
|
||||
|
||||
fgets(buffer, 256, fptr);
|
||||
while (!feof(fptr)) {
|
||||
|
||||
|
||||
chomp(buffer);
|
||||
|
||||
if (strncasecmp(buffer, "HOTKEY", 6) == 0) {
|
||||
@ -301,7 +298,6 @@ int menu_system(char *menufile) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (!doquit) {
|
||||
if (gUser->nodemsgs) {
|
||||
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
||||
@ -456,8 +452,7 @@ int menu_system(char *menufile) {
|
||||
case MENU_SETTINGS:
|
||||
settings_menu(gUser);
|
||||
break;
|
||||
case MENU_DOOR:
|
||||
{
|
||||
case MENU_DOOR: {
|
||||
for (m = 0; m < conf.door_count; m++) {
|
||||
if (strcasecmp(menu[i]->data[j], conf.doors[m]->name) == 0) {
|
||||
dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
||||
@ -467,8 +462,7 @@ int menu_system(char *menufile) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case MENU_MAILSCAN:
|
||||
broadcast("USER: %s; NODE:%d; STATUS: Performing Mail Scan.", gUser->loginname, mynode);
|
||||
mail_scan(gUser);
|
||||
|
@ -34,7 +34,6 @@ int openpty(int *amaster, int *aslave, char *name, void *termp, void *winp) {
|
||||
ioctl(pts, TIOCSWINSZ, winp);
|
||||
}
|
||||
|
||||
|
||||
*amaster = ptm;
|
||||
*aslave = pts;
|
||||
|
||||
@ -85,7 +84,6 @@ int forkpty(int *amaster, char *name, void *termp, void *winp) {
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
||||
static long difftm(struct tm *a, struct tm *b) {
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
|
@ -5,4 +5,3 @@ extern int openpty(int *amaster, int *aslave, char *name, void *termp, void *win
|
||||
extern int forkpty(int *amaster, char *name, void *termp, void *winp);
|
||||
extern long gmtoff(time_t value);
|
||||
#endif
|
||||
|
||||
|
@ -45,16 +45,13 @@ void settings_menu(struct user_record *user) {
|
||||
c = s_getc();
|
||||
|
||||
switch (tolower(c)) {
|
||||
case 27:
|
||||
{
|
||||
case 27: {
|
||||
c = s_getc();
|
||||
if (c == 91) {
|
||||
c = s_getc();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
{
|
||||
} break;
|
||||
case 'p': {
|
||||
s_printf(get_string(155));
|
||||
s_readpass(buffer, 16);
|
||||
hash = hash_sha256(buffer, user->salt);
|
||||
@ -76,20 +73,16 @@ void settings_menu(struct user_record *user) {
|
||||
} else {
|
||||
s_printf(get_string(159));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
{
|
||||
} break;
|
||||
case 'l': {
|
||||
s_printf(get_string(160));
|
||||
s_readstring(buffer, 32);
|
||||
free(user->location);
|
||||
user->location = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(user->location, buffer);
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
{
|
||||
} break;
|
||||
case 'a': {
|
||||
s_printf(get_string(206));
|
||||
|
||||
for (i = 0; i < conf.archiver_count; i++) {
|
||||
@ -106,11 +99,9 @@ void settings_menu(struct user_record *user) {
|
||||
user->defarchiver = new_arc;
|
||||
save_user(user);
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
||||
case 'o':
|
||||
{
|
||||
case 'o': {
|
||||
s_printf(get_string(212));
|
||||
|
||||
for (i = 0; i < conf.protocol_count; i++) {
|
||||
@ -127,38 +118,28 @@ void settings_menu(struct user_record *user) {
|
||||
user->defprotocol = new_arc;
|
||||
save_user(user);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
{
|
||||
} break;
|
||||
case 'm': {
|
||||
user->nodemsgs = !user->nodemsgs;
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
{
|
||||
} break;
|
||||
case 'c': {
|
||||
user->codepage = !user->codepage;
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
{
|
||||
} break;
|
||||
case 'e': {
|
||||
user->exteditor++;
|
||||
if (user->exteditor == 3) {
|
||||
user->exteditor = 0;
|
||||
}
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
{
|
||||
} break;
|
||||
case 'b': {
|
||||
user->bwavepktno = 0;
|
||||
user->bwavestyle = !user->bwavestyle;
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
} break;
|
||||
case 's': {
|
||||
// set signature
|
||||
if (user->signature != NULL) {
|
||||
free(user->signature);
|
||||
@ -168,14 +149,11 @@ void settings_menu(struct user_record *user) {
|
||||
user->signature = sig;
|
||||
save_user(user);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
{
|
||||
} break;
|
||||
case 't': {
|
||||
user->autosig = !user->autosig;
|
||||
save_user(user);
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case 'q':
|
||||
dosettings = 1;
|
||||
break;
|
||||
|
13
src/users.c
13
src/users.c
@ -29,7 +29,6 @@ char *hash_sha256(char *pass, char *salt) {
|
||||
|
||||
sprintf(buffer, "%s%s", pass, salt);
|
||||
|
||||
|
||||
EVP_MD_CTX *context = EVP_MD_CTX_new();
|
||||
|
||||
if (context != NULL) {
|
||||
@ -40,7 +39,6 @@ char *hash_sha256(char *pass, char *salt) {
|
||||
shash = (char *)malloc(length_of_hash * 2 + 1);
|
||||
for (i = 0; i < length_of_hash; i++) {
|
||||
sprintf(shash + (i * 2), "%02x", (int)hash[i]);
|
||||
|
||||
}
|
||||
EVP_MD_CTX_free(context);
|
||||
free(buffer);
|
||||
@ -82,8 +80,7 @@ void gen_salt(char **s) {
|
||||
}
|
||||
|
||||
static int secLevel(void *user, const char *section, const char *name,
|
||||
const char* value)
|
||||
{
|
||||
const char *value) {
|
||||
struct sec_level_t *conf = (struct sec_level_t *)user;
|
||||
|
||||
if (strcasecmp(section, "main") == 0) {
|
||||
@ -145,7 +142,6 @@ int save_user(struct user_record *user) {
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
}
|
||||
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
if (rc != SQLITE_DONE) {
|
||||
sqlite3_finalize(res);
|
||||
@ -156,7 +152,6 @@ int save_user(struct user_record *user) {
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
int msgbase_flag_unflag(struct user_record *user, int conference, int msgbase, int msgid) {
|
||||
@ -170,7 +165,6 @@ int msgbase_flag_unflag(struct user_record *user, int conference, int msgbase, i
|
||||
char *err_msg = 0;
|
||||
int flagunflag = 0;
|
||||
|
||||
|
||||
flagunflag = msgbase_is_flagged(user, conference, msgbase, msgid);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/users.sq3", conf.bbs_path);
|
||||
@ -266,7 +260,6 @@ int msgbase_sub_unsub(int conference, int msgbase) {
|
||||
char *err_msg = 0;
|
||||
int subunsub = 0;
|
||||
|
||||
|
||||
subunsub = msgbase_is_subscribed(conference, msgbase);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/users.sq3", conf.bbs_path);
|
||||
@ -316,8 +309,6 @@ int msgbase_is_subscribed(int conference, int msgbase) {
|
||||
|
||||
char *sql_buf = "SELECT * FROM msg_subs WHERE conference=? AND msgbase=? AND uid=?";
|
||||
|
||||
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/users.sq3", conf.bbs_path);
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
@ -442,7 +433,6 @@ int inst_user(struct user_record *user) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
@ -567,7 +557,6 @@ struct user_record *check_user_pass(char *loginname, char *password) {
|
||||
user->cur_file_sub = 0;
|
||||
}
|
||||
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,6 @@ static int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
|
||||
if (con_info != NULL) {
|
||||
if (con_info->connection_type == POST) {
|
||||
for (i = 0; i < con_info->count; i++) {
|
||||
@ -842,7 +841,6 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
page = www_msgs_messageview(con_inf->user, conference, area, msg);
|
||||
}
|
||||
|
||||
|
||||
if (page == NULL) {
|
||||
if (www_403(header, footer, connection) != 0) {
|
||||
free(header);
|
||||
@ -881,7 +879,6 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
mime = www_get_mime_type(NULL);
|
||||
}
|
||||
|
||||
|
||||
// load file
|
||||
|
||||
sprintf(buffer, "%s%s", conf.www_path, url);
|
||||
@ -982,7 +979,6 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
fno = open(filename, O_RDONLY);
|
||||
if (fno != -1) {
|
||||
|
||||
|
||||
response = MHD_create_response_from_fd(s.st_size, fno);
|
||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_TYPE, mime);
|
||||
sprintf(buffer, "%ld", s.st_size);
|
||||
@ -1209,7 +1205,6 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
|
||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
||||
|
||||
|
||||
} else {
|
||||
free(header);
|
||||
free(footer);
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "bbs.h"
|
||||
|
||||
|
||||
extern struct bbs_config conf;
|
||||
|
||||
char *www_blog() {
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <sys/utsname.h>
|
||||
#include "bbs.h"
|
||||
|
||||
|
||||
extern struct bbs_config conf;
|
||||
|
||||
int www_email_delete(struct user_record *user, int id) {
|
||||
@ -88,8 +87,6 @@ int www_send_email(struct user_record *user, char *recipient, char *subject, cha
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uname(&name);
|
||||
|
||||
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s \r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, conf.default_tagline);
|
||||
@ -139,8 +136,6 @@ int www_send_email(struct user_record *user, char *recipient, char *subject, cha
|
||||
}
|
||||
sqlite3_step(res);
|
||||
|
||||
|
||||
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return 1;
|
||||
@ -205,7 +200,6 @@ char *www_new_email() {
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
sprintf(buffer, "</form>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
@ -475,7 +469,6 @@ char *www_email_display(struct user_record *user, int email) {
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
sprintf(buffer, "</form>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
@ -552,7 +545,6 @@ char *www_email_summary(struct user_record *user) {
|
||||
"date INTEGER,"
|
||||
"seen INTEGER);";
|
||||
|
||||
|
||||
page = (char *)malloc(4096);
|
||||
max_len = 4096;
|
||||
len = 0;
|
||||
@ -642,7 +634,6 @@ sqlite3_busy_timeout(db, 5000);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "bbs.h"
|
||||
#include "../deps/hashids/hashids.h"
|
||||
|
||||
|
||||
extern struct bbs_config conf;
|
||||
extern struct user_record *gUser;
|
||||
extern char *aha(char *input);
|
||||
@ -405,7 +404,6 @@ char *www_files_display_listing(int dir, int sub) {
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
}
|
||||
|
||||
snprintf(buffer, 4096, "</tbody></table>\n");
|
||||
@ -539,7 +537,6 @@ char *www_files_get_from_area(int dir, int sub, char *clean_file) {
|
||||
rc = sqlite3_step(res);
|
||||
if (rc == SQLITE_ROW) {
|
||||
ret = strdup(sqlite3_column_text(res, 0));
|
||||
|
||||
}
|
||||
|
||||
free(filenamelike);
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "bbs.h"
|
||||
|
||||
|
||||
extern struct bbs_config conf;
|
||||
|
||||
char *www_last10() {
|
||||
|
@ -15,7 +15,6 @@
|
||||
extern char *aha(char *input);
|
||||
extern struct bbs_config conf;
|
||||
|
||||
|
||||
static char *www_wordwrap(char *content, int cutoff);
|
||||
char *www_sanitize(char *inp) {
|
||||
int i;
|
||||
@ -543,7 +542,6 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
aha_text = (char *)malloc(jmh.TxtLen + 1);
|
||||
|
||||
memcpy(aha_text, body, jmh.TxtLen);
|
||||
@ -567,8 +565,6 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
|
||||
sprintf(buffer, "<div class=\"msg-reply-form\">\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
@ -701,7 +697,6 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
sprintf(buffer, "<input type=\"submit\" name=\"submit\" value=\"Reply\" />\n<br />");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
@ -710,7 +705,6 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
sprintf(buffer, "</form>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
@ -787,7 +781,8 @@ static char *www_wordwrap(char *content, int cutoff) {
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
} else if (quote_line != 1) {
|
||||
for (z = i+1;content[z] != ' ' && z < len;z++);
|
||||
for (z = i + 1; content[z] != ' ' && z < len; z++)
|
||||
;
|
||||
if (at > 0 && content[at - 1] != '\r' && content[at - 1] != ' ' && cutoff - line_count < z - i) {
|
||||
content[at++] = ' ';
|
||||
line_count++;
|
||||
@ -815,7 +810,6 @@ static char *www_wordwrap(char *content, int cutoff) {
|
||||
content[at++] = content[i];
|
||||
content[at] = '\0';
|
||||
|
||||
|
||||
at = 0;
|
||||
|
||||
len = strlen(content);
|
||||
@ -1034,8 +1028,6 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (conf.mail_conferences[conference]->tagline != NULL) {
|
||||
tagline = conf.mail_conferences[conference]->tagline;
|
||||
} else {
|
||||
@ -1078,7 +1070,6 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
memset(body3, 0, strlen(body2) + 2 + strlen(buffer));
|
||||
pos = 0;
|
||||
sprintf(body3, "%s%s", body2, buffer);
|
||||
@ -1113,7 +1104,6 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(body2);
|
||||
|
||||
JAM_UnlockMB(jb);
|
||||
@ -1209,7 +1199,6 @@ char *www_new_msg(struct user_record *user, int conference, int area) {
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
|
||||
sprintf(buffer, "</form>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
|
Reference in New Issue
Block a user