Commit 5c173fdb authored by Andrew Price's avatar Andrew Price

Remove some unnecessary includes and externs, rejig some definitions into logical headers.

parent 87cfb7f4
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -11,7 +11,7 @@ JSLIB=$(shell if `echo "main(){}" | gcc -x c -ljs - 2> /dev/null`; then echo js;
CFLAGS+=-I/usr/include/mozjs
# cflags for standard 'cc' compiler
CFLAGS+= -Wall -Wshadow -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wcast-align -Wbad-function-cast -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -pedantic -fpie -std=gnu99 -D_GNU_SOURCE
CFLAGS+= -Werror -Wall -Wshadow -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wcast-align -Wbad-function-cast -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -pedantic -fpie -std=gnu99 -D_GNU_SOURCE
LDFLAGS+= -pie
LDLIBS+= -lreadline -ltermcap -lcrypt -l$(JSLIB) -lsqlite3 -lcurl -lpthread -lgnutls-openssl -ljansson
......
......@@ -6,18 +6,15 @@
#include "init.h"
#include "talker.h"
#include "strings.h"
#include "user.h"
#include "talker_privs.h"
extern unsigned long rights;
extern CommandList table[];
extern CommandList chattable[];
extern struct person *user;
extern long userposn;
#include "alias.h"
extern Alias alias_list;
extern Alias bind_list;
static void shuffle_up(char *bp)
{
......
......@@ -24,10 +24,12 @@
#include "intl.h"
#include "add.h"
#include "talker.h"
#include "bb.h"
extern int eof_caught;
extern int remote;
extern int busy;
extern int internet;
static void tidy_string(char *buff)
{
......
......@@ -22,7 +22,6 @@
#define MSGDIR "/var/run/mw"
#endif
#define COLOURDIR HOMEPATH"/colour"
#define LOGFILE LOGDIR"/log.bb"
#define LOGIN_BANNER "login.banner"
#define DEVEL_BANNER "login.banner.devel"
......@@ -35,22 +34,15 @@
#define SCRIPTHELP "scripthelp"
#define TALKHELP "talkhelp"
#define USERSQL STATEDIR"/users.db"
#define USERDB_PRIVATE "private"
#define USERDB_PUBLIC "public"
#define USERDB_ROOMS "rooms"
#define TEXT_END ".t"
#define INDEX_END ".i"
#define MOD_END ".m"
#define PATHSIZE 256
#define SETALLLONG 0xFFFFFFFF
#define CMD_BOARD_STR "!"
#define CMD_TALK_STR "."
#define CMD_SCRIPT_STR ","
#define SUBJECTSIZE 40 /* Subject field on messages */
#define LOGLINESIZE 2048 /* size of a line printed to log file */
#define MAXTEXTLENGTH 2048 /* text buffer size */
#define MAXPIPELENGTH 4096 /* maximum length of a pipe message */
......@@ -69,45 +61,6 @@ struct IgnoreList
struct IgnoreList *next;
};
#include "user.h"
struct Header
{
int32_t Ref;
int32_t date;
char from[NAMESIZE+1],to[SUBJECTSIZE+1];
char subject[SUBJECTSIZE+1];
int32_t datafield;
int32_t size;
char status;
int32_t replyto;
char spare[4]; /*adjust size as necessary */
};
/* Header.status
bit use
0 moderator approved
1 marked for deletion
2 has a reply
3 is a remote posting
4 -
5 -
6 -
7 -
*/
typedef struct gag_info
{
const char *name; /* gag filter name */
const char *text; /* gag realname */
const char *untext; /* ungag realname */
const char *gag; /* text on gag */
const char *ungag; /* text on ungag */
void (*Function)(char *); /* gag function to call */
} GagInfo;
extern int internet;
#define PACKAGE "mw"
#define LOCALEDIR HOMEPATH"/locale"
......
......@@ -11,9 +11,9 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "bb.h"
#include "frl.h"
#include "colour.h"
#include "user.h"
#define COLOUR_LIMIT 40
static char *colour_chart[COLOUR_LIMIT];
......
#ifndef COLOUR_H
#define COLOUR_H
#define COLOURDIR HOMEPATH"/colour"
void init_colour(void);
void destroy_colours(void);
void colour_load(char *file, int quiet);
......
......@@ -28,6 +28,7 @@
#include "init.h"
#include "read.h"
#include "intl.h"
#include "bb.h"
const char *partlist_user[]={
"edit", "status", "special", "groups", "passwd", "chatprivs", "chatmode",
......
......@@ -5,10 +5,11 @@
*********************************************************/
#include <stdio.h>
#include "bb.h"
#include "echo.h"
#include "getpass.h"
extern int internet;
char *get_pass(char *p)
{
static char buf[9];
......
......@@ -24,17 +24,15 @@
#include "echo.h"
#include "intl.h"
#include "socket.h"
#include "bb.h"
extern int script_terminate;
extern Alias rpc_list;
extern Alias event_list;
extern Alias onoff_list;
extern Alias ipc_list;
extern Alias force_list;
extern struct person *user;
extern long userposn;
extern struct room myroom;
extern int runautoexec;
extern int quietmode;
extern ipc_connection_t *ipcsock;
......
......@@ -10,13 +10,13 @@
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include "bb.h"
#include <curl/curl.h>
#include "intl.h"
#include "alias.h"
#include "js.h"
#include "sqlite.h"
#include "init.h"
#include <curl/curl.h>
#include "user.h"
extern Alias alias_list;
extern Alias bind_list;
......
......@@ -11,6 +11,7 @@
#include "files.h"
#include "socket.h"
#include "strings.h"
#include "bb.h"
/* client mode uses this as its connection */
ipc_connection_t * ipcsock = NULL;
......
......@@ -7,32 +7,16 @@
#include <sqlite3.h>
#include <gnutls/openssl.h>
#include <curl/curl.h>
#include <stdint.h>
#include "bb.h"
#include "strings.h"
#include "js.h"
#include "log.h"
#include "uri.h"
#include "sqlite.h"
extern int busy; /* if true dont display messages i.e. during new/write */
extern unsigned long rights;
#include "user.h"
extern struct person *user;
extern struct folder *fold;
extern int32_t userposn;
extern unsigned long loggedin;
extern int quietmode;
extern int runautoexec;
extern struct room myroom;
extern GagInfo gaglist[];
/* ignore list for current user */
extern struct IgnoreList *ignored;
/* local prototype */
static void *file_url(void * data);
static void *file_tag(void * data);
......
......@@ -45,8 +45,7 @@
#include "init.h"
#include "intl.h"
#include "ipc.h"
#include "bb.h"
extern struct room myroom;
......
......@@ -10,6 +10,7 @@
#include "files.h"
#include "intl.h"
#include "mesg.h"
#include "bb.h"
void send_mesg(char *from, const char *to, char *text, int wiz)
{
......
......@@ -2,7 +2,34 @@
#define MESG_H
#include "folders.h"
#include "bb.h"
#include "user.h"
#define SUBJECTSIZE 40
struct Header {
int32_t Ref;
int32_t date;
char from[NAMESIZE+1];
char to[SUBJECTSIZE+1];
char subject[SUBJECTSIZE+1];
int32_t datafield;
int32_t size;
char status;
int32_t replyto;
char spare[4]; /*adjust size as necessary */
};
/* Header.status
bit use
0 moderator approved
1 marked for deletion
2 has a reply
3 is a remote posting
4 -
5 -
6 -
7 -
*/
void broadcast(int state, const char *fmt, ...) __attribute__((format(printf,2,3)));
void inform_of_mail(char *to);
......
......@@ -14,6 +14,7 @@
#include "read.h"
#include "intl.h"
#include "mod.h"
#include "bb.h"
static void add_message(struct folder *fold, struct Header *head, char *text)
{
......
......@@ -21,6 +21,7 @@
#include "add.h"
#include "intl.h"
#include "new.h"
#include "bb.h"
extern int remote;
extern int busy;
......
......@@ -31,30 +31,21 @@
#include "log.h"
#include "intl.h"
#include "sort.h"
#include "bb.h"
#include "alias.h"
extern Alias alias_list;
extern int currentfolder,last_mesg;
extern int internet;
extern int idle_count;
extern int remote;
extern FILE *output;
extern int busy; /* if true dont display messages i.e. during new/write */
extern unsigned long rights;
extern struct person *user;
extern struct folder *fold;
extern long userposn;
extern unsigned long loggedin;
extern CommandList table[];
extern CommandList chattable[];
extern int autowho;
/* prototype */
void help_list(CommandList *cm, unsigned int hidestuff);
extern void help_list(CommandList *cm, unsigned int hidestuff);
static void help(const char *topic, int wiz)
{
......@@ -312,7 +303,7 @@ void c_colouroff(CommandList *cm, int argc, const char **argv, char *args)
c=strrchr(fn,'.');
if (c==NULL || strcmp(c,".col")) { free(fn); continue; }
*c=0;
snprintf(path, 1023, COLOURDIR"/%s", dd->d_name);
if ((ff=fopen(path,"r"))==NULL)
{
......
......@@ -17,6 +17,7 @@
#include "talker.h"
#include "echo.h"
#include "util.h"
#include "bb.h"
extern int remote;
extern FILE *output;
......
......@@ -2,7 +2,7 @@
#define READ_H
#include "folders.h"
#include "bb.h"
#include "mesg.h"
int get_mesg_header(struct folder *data, int msgnum, struct Header *head);
int get_data(int afile, struct Header *tmp);
......
......@@ -19,17 +19,13 @@
#include "main.h"
#include "frl.h"
#include "js.h"
#include "user.h"
extern Alias alias_list;
extern Alias bind_list;
extern unsigned long rights;
#define MAX_ARGC 128
extern CommandList chattable[];
extern CommandList table[];
extern struct person *user;
extern long userposn;
extern unsigned long rights;
extern int busy;
extern int current_rights;
......@@ -42,8 +38,6 @@ CompStack *comparison_stack=NULL;
/* very crude event driver, called on text recv */
char *event_body_text=NULL;
extern struct mstack *MesgStack;
extern int MesgStacked;
/* set runaway variable */
unsigned long run_away = RUNAWAY;
......
......@@ -6,7 +6,6 @@
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <inttypes.h>
#include <string.h>
#include "../socket.h"
#include "servsock.h"
......
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/param.h>
#include <time.h>
#include <sys/time.h>
#include "../socket.h"
......
......@@ -6,6 +6,8 @@
#include <sqlite3.h>
#include "bb.h"
#define USERSQL STATEDIR"/users.db"
static sqlite3* db_open(const char *dbname)
{
sqlite3 *db;
......
......@@ -23,6 +23,10 @@ struct js_db_result {
char *error_text;
};
#define USERDB_PRIVATE "private"
#define USERDB_PUBLIC "public"
#define USERDB_ROOMS "rooms"
struct db_result *db_query(const char *dbname, const char *query, int quiet);
struct js_db_result* js_db_query(char *dbname, char *query);
void db_free(struct db_result *result);
......
......@@ -10,12 +10,11 @@
#include "strings.h"
#include "main.h"
#define false 0
#define true !false
#define min(a,b) a<b?a:b
#define max(a,b) a>b?a:b
extern int internet;
int stringcmp(const char *a, const char *b, int n)
{
int length;
......@@ -33,17 +32,13 @@ int stringcmp(const char *a, const char *b, int n)
/* match by atleast n (or shortest string) */
else
{
if (strlen(a)<n) return(false);
if (strlen(a)<n) return 0;
length=strlen(a)>strlen(b)?strlen(a):strlen(b);
length=n<length?n:length;
}
if (length==0) return(false);
if (!strncasecmp(a,b,length))
return(true);
else
return(false);
if (length==0) return 0;
return (!strncasecmp(a,b,length));
}
struct stacked_str *cmd_stack = NULL;
......
......@@ -50,8 +50,6 @@ extern int runautoexec;
extern struct room myroom;
extern GagInfo gaglist[];
/* ignore list for current user */
extern struct IgnoreList *ignored;
......@@ -1619,17 +1617,6 @@ void chat_sayto(const char *to, char *text, int exclude)
talk_sayto(buff, to, user->room, exclude);
}
void apply_gag(char *text)
{
GagInfo *gi = gaglist;
while(gi->name)
{
if (flag_match(user->chatmode, gi->name)) gi->Function(text);
gi++;
}
}
struct IgnoreList *is_ignored(const char *name, struct IgnoreList **prev)
{
struct IgnoreList *tail;
......
......@@ -69,7 +69,6 @@ void talk_send_emote(char * text, int channel, int plural);
void talk_send_rawbcast(char * text);
void talk_send_raw(char * text, int channel);
void talk_send_shout(char * text);
void apply_gag(char *text);
unsigned long cp_flags(unsigned long cm, unsigned long flags, int mode);
void enter_talker(int logontype);
......
......@@ -7,17 +7,23 @@
#include "rooms.h"
#include "gags.h"
#include "main.h"
#define false 0
#define true !false
#include "user.h"
extern struct person *user;
extern long userposn;
extern int quietmode;
extern struct room myroom;
typedef struct {
const char *name; /* gag filter name */
const char *text; /* gag realname */
const char *untext; /* ungag realname */
const char *gag; /* text on gag */
const char *ungag; /* text on ungag */
void (*Function)(char *); /* gag function to call */
} GagInfo;
GagInfo gaglist[]={
static GagInfo gaglist[]={
{"","Gag", "Ungag",
"You have just been gagged!",
"You have been ungagged. You can now talk normally",
......@@ -117,6 +123,16 @@ GagInfo gaglist[]={
{NULL, NULL, NULL, NULL, NULL, NULL},
};
void apply_gag(char *text)
{
GagInfo *gi = gaglist;
while(gi->name)
{
if (flag_match(user->chatmode, gi->name)) gi->Function(text);
gi++;
}
}
/* chatmode flags, as in currently active modes */
unsigned long cm_flags(unsigned long cm, unsigned long flags, int mode)
......@@ -126,10 +142,10 @@ unsigned long cm_flags(unsigned long cm, unsigned long flags, int mode)
if (mode==CM_MODE_SET) return(cm | flags);
else
if (mode==CM_MODE_ANY) {
if ((cm&flags)>0) return(true); else return(false);
return ((cm & flags) > 0);
} else
if (mode==CM_MODE_ALL) {
if ((cm&flags)==flags) return(true); else return(false);
return ((cm & flags) == flags);
}
return(0);
}
......@@ -516,10 +532,10 @@ unsigned long cp_flags(unsigned long cm, unsigned long flags, int mode)
if (mode==CM_MODE_CLEAR) return( cm & (~flags) );
else
if (mode==CM_MODE_ANY) {
if ((cm&flags)>0) return(true); else return(false);
return ((cm & flags) > 0);
} else
if (mode==CM_MODE_ALL) {
if ((cm&flags)==flags) return(true); else return(false);
return ((cm & flags) == flags);
}
return(0);
}
......
......@@ -63,6 +63,7 @@ int gag_code(const char *str);
const char *gag_type(int type);
const char *ungag_name(unsigned long chatmode);
int flag_match(unsigned long val, const char *filter);
extern void apply_gag(char *text);
char *part_gag_filter(const char *text, int state);
unsigned long chatmode_describe(unsigned long old, unsigned long new, int ourapl, int theirapl, const char *from);
......
......@@ -11,6 +11,7 @@
#include "strings.h"
#include "mesg.h"
#include "perms.h"
#include "bb.h"
extern struct person *user;
......
......@@ -32,6 +32,7 @@ const char *partlist_search[]={
extern struct person *user;
extern struct folder *fold;
extern int internet;
char *getmylogin(void)
{
......
......@@ -15,7 +15,7 @@ struct person
char passwd[PASSWDSIZE+1];
int32_t lastlogout;
int32_t folders[2]; /* which folders are subscribed to */
#define SETALLLONG 0xFFFFFFFF
/* person.status
bit use
0 registered
......
......@@ -17,15 +17,12 @@
#include <talker_privs.h>
#include <special.h>
#include <ipc.h>
#include <perms.h>
#include <bb.h>
#include "import.h"
#include "comms.h"
#include "list.h"
#include "mwstring.h"
#include "../socket.h"
#include "../ipc.h"
int command_sock;
......
......@@ -2,12 +2,9 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <strings.h>
#include <stdbool.h>
#include <ctype.h>
......
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
#include <libpq-fe.h>
#include <bb.h>
#include <talker_privs.h>
#include <strings.h>
#include <files.h>
#include <who.h>
#include "import.h"
#include "comms.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment