Skip to content
Commits on Source (29)
image: debian:stable
stages:
- build
#- test
#- deploy
make deb!:
stage: build
before_script:
- apt update
- apt -y install make autoconf devscripts build-essential
- apt install -y debhelper libreadline-dev libcurl4-nss-dev libsqlite3-dev libjansson-dev libncurses5-dev libssl-dev libpq-dev
- apt install -y zlib1g-dev
script:
- make deb
artifacts:
expire_in: 1 week
paths:
- "*.deb"
......@@ -29,13 +29,6 @@ GCCMAJOR := $(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
GCCMINOR := $(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
GCCVER := $(shell printf "%02d%02d" $(GCCMAJOR) $(GCCMINOR))
JSDIR = $(DEPTH)mozjs/installroot
JSOBJ = $(JSDIR)/usr/lib/libmozjs-17.0.a
JSFLAGS = \
-include $(JSDIR)/usr/include/js-17.0/js/RequiredDefines.h \
-I/usr/include/nspr \
-I$(JSDIR)/usr/include/js-17.0
WARNINGS = \
-Wall \
-Wshadow \
......@@ -77,7 +70,7 @@ else
MWLDFLAGS += -O0
endif
MWCFLAGS = -std=gnu99 -pedantic -g $(DEFS) $(JSFLAGS) $(CCSEC) $(WARNINGS)
MWCFLAGS = -std=gnu99 -pedantic -g $(DEFS) $(CCSEC) $(WARNINGS)
ifneq ($(RELEASE_BUILD),0)
MWCFLAGS += -O2
# This requires optimisation so add it here instead of CCSEC
......
SRCROOT = $(CURDIR)/..
DEPTH=../
include $(DEPTH)Makefile.common
build: duktape.o
duktape.o: duktape.c duktape.h duk_config.h
$(CC) -std=c99 $(CCSEC) duktape.c -c
clean:
-rm -f *.o .*.d *.d
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,11 +2,35 @@ SRCROOT = $(CURDIR)/../..
DEPTH=../../
include ../../Makefile.common
# Build with `make JSENGINE=foo` to switch engines
JSENGINE ?= moz
JSDIR_moz = $(DEPTH)mozjs
JSOBJ_moz = $(JSDIR_moz)/installroot/usr/lib/libmozjs-17.0.a
JSFLAGS_moz = \
-include $(JSDIR_moz)/installroot/usr/include/js-17.0/js/RequiredDefines.h \
-I/usr/include/nspr \
-I$(JSDIR_moz)/installroot/usr/include/js-17.0
JSDIR_duk = $(DEPTH)duktape
JSOBJ_duk = $(JSDIR_duk)/duktape.o
JSFLAGS_duk = -I$(JSDIR_duk)
JSDIR = $(JSDIR_$(JSENGINE))
JSOBJ = $(JSOBJ_$(JSENGINE))
JSFLAGS = $(JSFLAGS_$(JSENGINE))
LDLIBS+= -lreadline -ltermcap -lcrypt -lsqlite3 -lcurl -lpthread -lcrypto -ljansson -lz -lm
CFLAGS+= -I..
CFLAGS+= -I.. $(JSFLAGS)
build: mw
$(JSOBJ):
$(MAKE) -C $(JSDIR)
# Ugly hack to only build the required js implementation
CODE := $(filter-out js-%.c, $(CODE)) js-$(JSENGINE).c
mw: $(CODE:.c=.o) ../libmw.a $(JSOBJ)
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
......
......@@ -291,7 +291,7 @@ int command_compare(const char *input, const char *comm)
return(c);
}
void help_list(CommandList *c, unsigned int hidestuff)
void help_list(CommandList *c, unsigned int hidestuff, const char * const prefix)
{
char buff[10];
int count;
......@@ -306,12 +306,12 @@ void help_list(CommandList *c, unsigned int hidestuff)
{
if (!hidestuff)
{
printf("%20s - %s\n",c->Command,c->Desc);
printf("%8s%-12s - %s\n", prefix, c->Command, c->Desc);
count++;
}
else if (c->Show == 1)
{
printf("%20s - %s\n",c->Command,c->Desc);
printf("%8s%-12s - %s\n", prefix, c->Command, c->Desc);
count++;
}
}
......
......@@ -90,7 +90,7 @@ extern void c_version(CommandList *cm, int argc, const char **argv, char *args);
extern void c_alias(CommandList *cm, int argc, const char **argv, char *args);
extern void c_unalias(CommandList *cm, int argc, const char **argv, char *args);
void help_list(CommandList *c, unsigned int hidestuff);
void help_list(CommandList *c, unsigned int hidestuff, const char * const prefix);
char *remove_first_word(char *args);
#endif
......@@ -189,7 +189,9 @@ int add_msg(int folnum, struct user *user, int replyto)
new->date=time(0);
if (!remote) printf(_("Message from %s\n"), user->record.name);
strncpy(new->from, user->record.name, 30);
strncpy(new->from, user->record.name, NAMESIZE);
new->from[NAMESIZE] = '\0';
if (replyto==0)
{
char t[NAMESIZE+1];
......
#include <stdio.h>
#include <duktape.h>
#include "js.h"
int js_isrunning(void)
{
return 0;
}
int js_exec(char *name, int argc, const char **argvc)
{
return 0;
}
int load_jsfile(FILE *f, const char *filename)
{
return 0;
}
int is_js(char *name)
{
return 0;
}
void js_stop_execution(void)
{
}
int stop_js(void)
{
return 0;
}
int setup_js(void)
{
return 0;
}
size_t urldata(void *ptr, size_t size, size_t nmemb, void *stream)
{
return 0;
}
size_t headlimit(void *ptr, size_t size, size_t nmemb, void *stream)
{
return 0;
}
......@@ -2,7 +2,6 @@
#define JS_H
#include <stdio.h>
#include <jsapi.h>
int js_isrunning(void);
int js_exec(char *name, int argc, const char **argvc);
......
......@@ -766,8 +766,10 @@ int idle(int fd, int millis)
int incoming_pipe = ipc_getfd();
FD_ZERO(&readfds);
FD_ZERO(&exceptfds);
FD_SET(incoming_pipe, &readfds);
FD_SET(incoming_pipe, &exceptfds);
if (incoming_pipe >= 0) {
FD_SET(incoming_pipe, &readfds);
FD_SET(incoming_pipe, &exceptfds);
}
if (fd >= 0)
{
FD_SET(fd, &readfds);
......@@ -786,7 +788,7 @@ int idle(int fd, int millis)
select_error = errno;
if (fd >= 0) fcntl(fd, F_SETFL, fl);
if (nfds > 0) {
if (FD_ISSET(incoming_pipe, &exceptfds)) {
if (incoming_pipe >= 0 && FD_ISSET(incoming_pipe, &exceptfds)) {
fprintf(stderr, _("\nError reading incoming message pipe. panic.\n"));
return -1;
}
......@@ -794,7 +796,7 @@ int idle(int fd, int millis)
fprintf(stderr, _("\nError on input terminal, argh.\n"));
return -1;
}
if (FD_ISSET(incoming_pipe, &readfds))
if (incoming_pipe >= 0 && FD_ISSET(incoming_pipe, &readfds))
handle_mesg();
}
in_idle--;
......@@ -931,7 +933,7 @@ void display_message(const char *text, int beeps, int newline)
/* escape sequence, skip next two chars */
if (s_colouroff(user))
{
continue;
goto eolprint;
}
hascolour++;
......@@ -1000,7 +1002,7 @@ void display_message(const char *text, int beeps, int newline)
printline_in_local(line, &convert_warnings, &not_in_local);
i=0;
}
eolprint:
if (s_nolinewrap(user))
endline = (ptr >= len);
else
......
......@@ -45,7 +45,6 @@ extern int busy; /* if true dont display messages i.e. during new/write */
extern unsigned long rights;
extern struct user * const user;
extern CommandList table[];
extern void help_list(CommandList *cm, unsigned int hidestuff);
static void help(const char *topic, int wiz)
{
......@@ -123,7 +122,7 @@ void c_help(CommandList *cm, int argc, const char **argv, char *args)
if (argc>1)
help(argv[1], u_god(user));
else
help_list(table, 1);
help_list(table, 1, CMD_BOARD_STR);
}
void c_cd(CommandList *cm, int argc, const char **argv, char *args)
......
......@@ -166,7 +166,6 @@ void ls(int folnum, struct user *user, int many)
int afile;
struct folder fold;
struct Header head;
char buff[SUBJECTSIZE+1];
int linecount=0;
int listpoint;
int screen_height = screen_h();
......@@ -198,17 +197,10 @@ void ls(int folnum, struct user *user, int many)
(is_private(&fold, user) && (stringcmp(head.from, user->record.name, -1)
|| stringcmp(head.to, user->record.name, -1))))) /*marked for deletion*/
{
strncpy(buff,head.to,NAMESIZE);
buff[NAMESIZE]=0;
printf("%4d %*s -> %*s ",
head.Ref,NAMESIZE,head.from,NAMESIZE,buff);
if (strlen(head.subject)>40)
{
strncpy(buff,head.subject,37);
strcat(buff,"...");
}else
strcpy(buff,head.subject);
printf("%s\n",buff);
printf("%4d %*s -> %*s ", head.Ref,
NAMESIZE, head.from,
NAMESIZE, head.to);
printf("%.*s\n", SUBJECTSIZE, head.subject);
linecount++;
if (linecount>=(screen_height-1))
{
......
......@@ -988,7 +988,7 @@ void t_help(CommandList *cm, int argc, const char **argv, char *args)
if (argc < 2)
{
help_list(chattable, 1);
help_list(chattable, 1, CMD_TALK_STR);
return;
}
......
......@@ -7,7 +7,7 @@ LDLIBS+= -ljansson -lsqlite3 -lcrypt
build: mwserv
mwserv: $(CODE:.c=.o) ../libmw.a $(JSOBJ)
mwserv: $(CODE:.c=.o) ../libmw.a
$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
clean:
......
......@@ -27,6 +27,7 @@ static void usage(char *name)
"[--foreground|-f]"
"[--port|-p <port>]"
"[--print-config|-P]"
"[--debug|-D]"
"\n", name);
}
......@@ -40,6 +41,7 @@ static const struct cfg_default_opt defcfgs[] = {
CFG_OPT(BOOL, "foreground", 0),
CFG_OPT(INT, "port", 9999),
CFG_OPT(STR, "user", MWUSER),
CFG_OPT(BOOL, "debug", 0),
CFG_END
};
......@@ -78,6 +80,7 @@ static int getconfig(int argc, char **argv)
static struct option loptspec[] = {
{"config", required_argument, 0, 'c'},
{"foreground", no_argument, 0, 'f'},
{"debug", no_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{"print-config", no_argument, 0, 'P'},
{"port", required_argument, 0, 'p'},
......@@ -89,7 +92,7 @@ static int getconfig(int argc, char **argv)
return ret;
while (1) {
c = getopt_long(argc, argv, "c:fhPp:", loptspec, &optidx);
c = getopt_long(argc, argv, "c:fDhPp:", loptspec, &optidx);
if (c == -1)
break;
......@@ -115,6 +118,9 @@ static int getconfig(int argc, char **argv)
case 'f':
cfg_set_bool("foreground", 1);
break;
case 'D':
cfg_set_bool("debug", 1);
break;
case 'h':
usage(argv[0]);
exit(0);
......@@ -176,6 +182,10 @@ int main(int argc, char **argv)
}
migrate_old_folders();
if (!cfg_get_bool("debug")) {
freopen("/dev/null", "w", stdout);
freopen("/dev/null", "w", stderr);
}
if (cfg_get_bool("foreground"))
setlinebuf(stdout);
else
......
......@@ -726,7 +726,7 @@ void migrate_old_folders(void)
int dfd;
DIR *dirp;
unsigned i;
struct dirent entry, *dp;
struct dirent *entry;
const char *bbdirs[] = {
FOL_IDX_DIR,
FOL_IDX_DIR"/"FOL_NEW,
......@@ -752,52 +752,50 @@ void migrate_old_folders(void)
return;
}
dfd = dirfd(dirp);
while (readdir_r(dirp, &entry, &dp) == 0) {
while ((entry = readdir(dirp)) != NULL) {
char *end, *path = NULL;
if (dp == NULL)
break;
if ((end = has_suffix(entry.d_name, ".t.t"))) {
if ((end = has_suffix(entry->d_name, ".t.t"))) {
*end = '\0';
asprintf(&path, FOL_TXT_DIR"/"FOL_NEW"/%s", entry.d_name);
asprintf(&path, FOL_TXT_DIR"/"FOL_NEW"/%s", entry->d_name);
*end = '.';
printf("Migrating folder '%s' to '%s'\n", entry.d_name, path);
renameat(dfd, entry.d_name, dfd, path);
printf("Migrating folder '%s' to '%s'\n", entry->d_name, path);
renameat(dfd, entry->d_name, dfd, path);
}
else if ((end = has_suffix(entry.d_name, ".i.t"))) {
else if ((end = has_suffix(entry->d_name, ".i.t"))) {
*end = '\0';
asprintf(&path, FOL_IDX_DIR"/"FOL_NEW"/%s", entry.d_name);
asprintf(&path, FOL_IDX_DIR"/"FOL_NEW"/%s", entry->d_name);
*end = '.';
printf("Migrating folder '%s' to '%s'\n", entry.d_name, path);
renameat(dfd, entry.d_name, dfd, path);
printf("Migrating folder '%s' to '%s'\n", entry->d_name, path);
renameat(dfd, entry->d_name, dfd, path);
}
else if ((end = has_suffix(entry.d_name, ".i.m"))) {
else if ((end = has_suffix(entry->d_name, ".i.m"))) {
*end = '\0';
asprintf(&path, FOL_IDX_DIR"/"FOL_MOD"/%s", entry.d_name);
asprintf(&path, FOL_IDX_DIR"/"FOL_MOD"/%s", entry->d_name);
*end = '.';
printf("Migrating folder '%s' to '%s'\n", entry.d_name, path);
renameat(dfd, entry.d_name, dfd, path);
printf("Migrating folder '%s' to '%s'\n", entry->d_name, path);
renameat(dfd, entry->d_name, dfd, path);
}
else if ((end = has_suffix(entry.d_name, ".t.m"))) {
else if ((end = has_suffix(entry->d_name, ".t.m"))) {
*end = '\0';
asprintf(&path, FOL_TXT_DIR"/"FOL_MOD"/%s", entry.d_name);
asprintf(&path, FOL_TXT_DIR"/"FOL_MOD"/%s", entry->d_name);
*end = '.';
printf("Migrating folder '%s' to '%s'\n", entry.d_name, path);
renameat(dfd, entry.d_name, dfd, path);
printf("Migrating folder '%s' to '%s'\n", entry->d_name, path);
renameat(dfd, entry->d_name, dfd, path);
}
else if ((end = has_suffix(entry.d_name, ".i"))) {
else if ((end = has_suffix(entry->d_name, ".i"))) {
*end = '\0';
asprintf(&path, FOL_IDX_DIR"/%s", entry.d_name);
asprintf(&path, FOL_IDX_DIR"/%s", entry->d_name);
*end = '.';
printf("Migrating folder '%s' to '%s'\n", entry.d_name, path);
renameat(dfd, entry.d_name, dfd, path);
printf("Migrating folder '%s' to '%s'\n", entry->d_name, path);
renameat(dfd, entry->d_name, dfd, path);
}
else if ((end = has_suffix(entry.d_name, ".t"))) {
else if ((end = has_suffix(entry->d_name, ".t"))) {
*end = '\0';
asprintf(&path, FOL_TXT_DIR"/%s", entry.d_name);
asprintf(&path, FOL_TXT_DIR"/%s", entry->d_name);
*end = '.';
printf("Migrating folder '%s' to '%s'\n", entry.d_name, path);
renameat(dfd, entry.d_name, dfd, path);
printf("Migrating folder '%s' to '%s'\n", entry->d_name, path);
renameat(dfd, entry->d_name, dfd, path);
}
if (path != NULL)
free(path);
......