Haiku Support

Hope I didn't break things!
This commit is contained in:
Andrew Pamment 2018-10-18 11:36:02 +10:00
parent 93e08c0c3d
commit af8936c02e
18 changed files with 92 additions and 29 deletions

2
deps/jamlib/mbase.c vendored
View File

@ -85,7 +85,7 @@
#if defined( __LINUX__ ) #if defined( __LINUX__ )
#include <sys/file.h> #include <sys/file.h>
#include <unistd.h> #include <unistd.h>
#if defined(__sun) || defined(__MUSL__) #if defined(__sun) || defined(__MUSL__) || defined(__HAIKU__)
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#endif #endif

View File

@ -12,9 +12,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/time.h> #include <sys/time.h>
#ifndef __HAIKU__
#include <sys/syscall.h> #include <sys/syscall.h>
#endif
#include "randutils.h" #include "randutils.h"
#ifdef HAVE_TLS #ifdef HAVE_TLS

View File

@ -96,7 +96,7 @@
#define OD_DLL #define OD_DLL
#endif /* !OD_WIN32_STATIC */ #endif /* !OD_WIN32_STATIC */
#else /* !WIN32 */ #else /* !WIN32 */
#if defined(__unix__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__sun) #if defined(__unix__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__sun) || defined(__HAIKU__)
#define ODPLAT_NIX #define ODPLAT_NIX
#undef ODPLAT_DOS #undef ODPLAT_DOS
#undef DIRSEP #undef DIRSEP

11
src/GNUmakefile.haiku Normal file
View File

@ -0,0 +1,11 @@
CC:= cc
CFLAGS:= -std=gnu99 -I/boot/system/sources/haiku/headers/libs/iconv/ -I../deps/haiku/include -DDISABLE_MQTT=1 -DDISABLE_SSH=1
LIBS:= -lm -lssl -lcrypto -liconv -lsqlite3 -lnetwork -lbsd
EXTRAOBJS:= strlcpy/strlcpy.o strlcpy/strlcat.o
LIBTOOLIZE:= libtoolize
DEPS_LUA_TARGET:= linux
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
include GNUmakefile.common

View File

@ -6,7 +6,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __HAIKU__
#include <posix/fcntl.h>
#else
#include <sys/fcntl.h> #include <sys/fcntl.h>
#endif
#include <signal.h> #include <signal.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/time.h> #include <sys/time.h>
@ -15,7 +19,9 @@
#include <errno.h> #include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <iconv.h> #include <iconv.h>
#ifndef DISABLE_MQTT
#include <mosquitto.h> #include <mosquitto.h>
#endif
#include "bbs.h" #include "bbs.h"
#include "lua/lua.h" #include "lua/lua.h"
#include "lua/lualib.h" #include "lua/lualib.h"
@ -33,7 +39,9 @@ int usertimeout;
int timeoutpaused; int timeoutpaused;
time_t userlaston; time_t userlaston;
#ifndef DISABLE_MQTT
struct mosquitto *mosq = NULL; struct mosquitto *mosq = NULL;
#endif
char *ipaddress = NULL; char *ipaddress = NULL;
@ -49,6 +57,7 @@ void sigint_handler(int s) {
// do nothing... // do nothing...
} }
void broadcast(char *mess, ...) { void broadcast(char *mess, ...) {
#ifndef DISABLE_MQTT
char buffer[PATH_MAX]; char buffer[PATH_MAX];
if (conf.broadcast_enable && conf.broadcast_port != 0 && conf.broadcast_address != NULL) { if (conf.broadcast_enable && conf.broadcast_port != 0 && conf.broadcast_address != NULL) {
va_list ap; va_list ap;
@ -58,6 +67,7 @@ void broadcast(char *mess, ...) {
mosquitto_publish(mosq, NULL, (conf.broadcast_topic == NULL ? "MagickaBBS" : conf.broadcast_topic), strlen(buffer), buffer, 0, 0); mosquitto_publish(mosq, NULL, (conf.broadcast_topic == NULL ? "MagickaBBS" : conf.broadcast_topic), strlen(buffer), buffer, 0, 0);
} }
#endif
} }
void dolog_www(char *ipaddr, char *fmt, ...) { void dolog_www(char *ipaddr, char *fmt, ...) {
@ -643,12 +653,14 @@ void exit_bbs() {
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, mynode); snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, mynode);
remove(buffer); remove(buffer);
#ifndef DISABLE_MQTT
if (mosq != NULL) { if (mosq != NULL) {
mosquitto_disconnect(mosq); mosquitto_disconnect(mosq);
mosquitto_loop_stop(mosq, 0); mosquitto_loop_stop(mosq, 0);
mosquitto_destroy(mosq); mosquitto_destroy(mosq);
mosquitto_lib_cleanup(); mosquitto_lib_cleanup();
} }
#endif
} }
void disconnect(char *calledby) { void disconnect(char *calledby) {
@ -946,6 +958,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
} }
// initialize mqtt // initialize mqtt
#ifndef DISABLE_MQTT
if (conf.broadcast_enable && conf.broadcast_address != NULL && conf.broadcast_port != 0) { if (conf.broadcast_enable && conf.broadcast_address != NULL && conf.broadcast_port != 0) {
mosquitto_lib_init(); mosquitto_lib_init();
mosq = mosquitto_new(NULL, 1, NULL); mosq = mosquitto_new(NULL, 1, NULL);
@ -962,6 +975,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
} }
} }
} }
#endif
broadcast("USER: unknown; NODE:%d; STATUS: Logging in.", mynode); broadcast("USER: unknown; NODE:%d; STATUS: Logging in.", mynode);

View File

@ -7,7 +7,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#if defined(__OpenBSD__) #if defined(__OpenBSD__) || defined(__HAIKU__)
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#include "../deps/jsmn/jsmn.h" #include "../deps/jsmn/jsmn.h"

View File

@ -19,6 +19,9 @@
#elif defined(__sun) #elif defined(__sun)
#include "os/sunos.h" #include "os/sunos.h"
#endif #endif
#ifdef __HAIKU__
#include <sys/select.h>
#endif
#include "bbs.h" #include "bbs.h"
#include "lua/lua.h" #include "lua/lua.h"
#include "lua/lualib.h" #include "lua/lualib.h"

View File

@ -17,6 +17,9 @@
#include "lua/lua.h" #include "lua/lua.h"
#include "lua/lualib.h" #include "lua/lualib.h"
#include "lua/lauxlib.h" #include "lua/lauxlib.h"
#ifdef __HAIKU__
#include <sys/select.h>
#endif
extern struct bbs_config conf; extern struct bbs_config conf;
extern int gSocket; extern int gSocket;
@ -701,9 +704,9 @@ int do_upload(struct user_record *user, char *final_path) {
return 0; return 0;
} }
while ((dent = readdir(inb)) != NULL) { while ((dent = readdir(inb)) != NULL) {
#ifdef __sun #if defined(__sun) || defined(__HAIKU__)
snprintf(upload_command, 1024, "%s%s", upload_path, dent->d_name); snprintf(upload_command, 1024, "%s%s", upload_path, dent->d_name);
struct state s; struct stat s;
stat(upload_command, &s); stat(upload_command, &s);
if (S_ISREG(s.st_mode)) { if (S_ISREG(s.st_mode)) {
#else #else

View File

@ -11,9 +11,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#ifndef DISABLE_SSH
#include <libssh/libssh.h> #include <libssh/libssh.h>
#include <libssh/server.h> #include <libssh/server.h>
#include <libssh/callbacks.h> #include <libssh/callbacks.h>
#endif
#include <string.h> #include <string.h>
#include <poll.h> #include <poll.h>
#if defined(linux) #if defined(linux)
@ -479,6 +481,8 @@ static int handler(void *user, const char *section, const char *name,
return 1; return 1;
} }
#ifndef DISABLE_SSH
int ssh_authenticate(ssh_session p_ssh_session) { int ssh_authenticate(ssh_session p_ssh_session) {
ssh_message message; ssh_message message;
char *username; char *username;
@ -856,7 +860,7 @@ void serverssh(int port, int ipv6) {
} }
} }
} }
#endif
void server(int port, int ipv6) { void server(int port, int ipv6) {
struct sigaction sa; struct sigaction sa;
struct sigaction st; struct sigaction st;
@ -955,7 +959,7 @@ void server(int port, int ipv6) {
remove(conf.pid_file); remove(conf.pid_file);
exit(1); exit(1);
} }
#ifndef DISABLE_SSH
if (conf.ssh_server) { if (conf.ssh_server) {
if (!conf.fork) { if (!conf.fork) {
printf(" - SSH Starting on Port %d (IPv%d)\n", conf.ssh_port, (ipv6 ? 6 : 4)); printf(" - SSH Starting on Port %d (IPv%d)\n", conf.ssh_port, (ipv6 ? 6 : 4));
@ -974,7 +978,7 @@ void server(int port, int ipv6) {
fprintf(stderr, "Error forking ssh server."); fprintf(stderr, "Error forking ssh server.");
} }
} }
#endif
if (ipv6) { if (ipv6) {
server_socket = socket(AF_INET6, SOCK_STREAM, 0); server_socket = socket(AF_INET6, SOCK_STREAM, 0);
} else { } else {

View File

@ -35,6 +35,11 @@ ifeq ($(OS), SunOS)
CFLAGS= CFLAGS=
LDFLAGS=-lsocket LDFLAGS=-lsocket
endif endif
ifeq ($(OS), Haiku)
CC=gcc
CFLAGS=
LDFLAGS=-lnetwork
endif
DEPS = main.c DEPS = main.c

View File

@ -6,7 +6,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/types.h> #include <sys/types.h>
#if defined(__OpenBSD__) #if defined(__OpenBSD__) || defined(__HAIKU__)
# include <sys/select.h> # include <sys/select.h>
#endif #endif

View File

@ -39,7 +39,11 @@ ifeq ($(OS), SunOS)
CFLAGS= CFLAGS=
LDFLAGS=-lsqlite3 -lcurses LDFLAGS=-lsqlite3 -lcurses
endif endif
ifeq ($(OS), Haiku)
CC=gcc
CFLAGS=
LDFLAGS=-lsqlite3 -lncurses
endif
DEPS = main.c DEPS = main.c
OBJ = main.o OBJ = main.o

View File

@ -8,6 +8,10 @@ OS = $(shell uname -s)
ifeq ($(OS), SunOS) ifeq ($(OS), SunOS)
EXTRA_LIBS = -lsocket EXTRA_LIBS = -lsocket
endif endif
ifeq ($(OS), Haiku)
EXTRA_LIBS = -lnetwork
endif
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)

View File

@ -7,7 +7,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#if defined(__OpenBSD__) #if defined(__OpenBSD__) || defined(__HAIKU__)
# include <sys/select.h> # include <sys/select.h>
#endif #endif
#include "../../deps/jsmn/jsmn.h" #include "../../deps/jsmn/jsmn.h"

View File

@ -8,6 +8,10 @@ ifeq ($(OS), SunOS)
EXTRA_LIBS = -lsocket EXTRA_LIBS = -lsocket
endif endif
ifeq ($(OS), Haiku)
EXTRA_LIBS = -lnetwork
endif
OBJ = main.o OBJ = main.o
all: magiedit all: magiedit

View File

@ -35,6 +35,12 @@ ifeq ($(OS), SunOS)
CFLAGS= CFLAGS=
LDFLAGS=-lsqlite3 -lcrypto -lsocket -lnsl LDFLAGS=-lsqlite3 -lcrypto -lsocket -lnsl
endif endif
ifeq ($(OS), Haiku)
CC=gcc
CFLAGS=
LDFLAGS=-lsqlite3 -lcrypto -lnetwork
endif
DEPS = magiftpd.c DEPS = magiftpd.c

View File

@ -30,19 +30,20 @@ MBOBJS_MSG = obj/mb_msg.o
MBDEFS_JAM = -DMSGBASE_JAM MBDEFS_JAM = -DMSGBASE_JAM
MBOBJS_JAM = $(OBJDIR)/mb_jam.o $(JAMLIB) MBOBJS_JAM = $(OBJDIR)/mb_jam.o $(JAMLIB)
MBDEFS_SQ3 = -DMSGBASE_SQ3
MBOBJS_SQ3 = $(OBJDIR)/mb_sq3.o
# Sum them up. Only include the messagebases you want to use # Sum them up. Only include the messagebases you want to use
MBDEFS = $(MBDEFS_MSG) $(MBDEFS_JAM) $(MBDEFS_SQ3) MBDEFS = $(MBDEFS_MSG) $(MBDEFS_JAM)
MBOBJS = $(MBOBJS_MSG) $(MBOBJS_JAM) $(MBOBJS_SQ3) MBOBJS = $(MBOBJS_MSG) $(MBOBJS_JAM)
DEFS = $(PLATFORMDEF) $(MBDEFS) $(NLDEFS) DEFS = $(PLATFORMDEF) $(MBDEFS) $(NLDEFS)
ifeq ($(OS), SunOS) ifeq ($(OS), SunOS)
SLIBS = -lsocket -lnsl SLIBS = -lsocket -lnsl
else else
SLIBS = ifeq ($(OS), Haiku)
SLIBS = -lnetwork
else
SLIBS =
endif
endif endif
# Commands # Commands
@ -94,7 +95,7 @@ files : $(BINDIR)/magimail$(EXESUFFIX) \
$(BINDIR)/magilistout$(EXESUFFIX) $(BINDIR)/magilistout$(EXESUFFIX)
$(BINDIR)/magimail$(EXESUFFIX) : $(CMOBJS) $(SHOBJS) $(NLOBJS) $(MBOBJS) $(OSLIB) $(BINDIR)/magimail$(EXESUFFIX) : $(CMOBJS) $(SHOBJS) $(NLOBJS) $(MBOBJS) $(OSLIB)
$(CC) -o $(BINDIR)/magimail$(EXESUFFIX) $(CMOBJS) $(SHOBJS) $(NLOBJS) $(MBOBJS) $(OSLIB) -lsqlite3 $(SLIBS) $(CC) -o $(BINDIR)/magimail$(EXESUFFIX) $(CMOBJS) $(SHOBJS) $(NLOBJS) $(MBOBJS) $(OSLIB) $(SLIBS)
$(STRIP) $(BINDIR)/magimail$(EXESUFFIX) $(STRIP) $(BINDIR)/magimail$(EXESUFFIX)
$(BINDIR)/magistats$(EXESUFFIX) : tools/magistats.c $(SHOBJS) $(OSLIB) $(BINDIR)/magistats$(EXESUFFIX) : tools/magistats.c $(SHOBJS) $(OSLIB)

View File

@ -3,34 +3,38 @@ OS := $(shell uname -s)
ifeq ($(OS), FreeBSD) ifeq ($(OS), FreeBSD)
CC=cc CC=cc
CFLAGS=-I/usr/local/include CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib LDFLAGS=-L/usr/local/lib -lsqlite3
endif endif
ifeq ($(OS), DragonFly) ifeq ($(OS), DragonFly)
CC=cc CC=cc
CFLAGS=-I/usr/local/include CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib LDFLAGS=-L/usr/local/lib -lsqlite3
endif endif
ifeq ($(OS), NetBSD) ifeq ($(OS), NetBSD)
CC=cc CC=cc
CFLAGS=-I/usr/pkg/include CFLAGS=-I/usr/pkg/include
LDFLAGS=-R/usr/pkg/lib -L/usr/pkg/lib LDFLAGS=-R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3
endif endif
ifeq ($(OS), OpenBSD) ifeq ($(OS), OpenBSD)
CC=cc CC=cc
CFLAGS=-I/usr/local/include CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib LDFLAGS=-L/usr/local/lib -lsqlite3
endif endif
ifeq ($(OS), Linux) ifeq ($(OS), Linux)
CC=gcc CC=gcc
CFLAGS= CFLAGS=
LDFLAGS= LDFLAGS=-lsqlite3
endif endif
ifeq ($(OS), Darwin) ifeq ($(OS), Darwin)
CC=cc CC=cc
CFLAGS= CFLAGS=
LDFLAGS= LDFLAGS=-lsqlite3
endif
ifeq ($(OS), Haiku)
CC=gcc
CFLAGS=
LDFLAGS=-lsqlite3
endif endif
DEPS = ticproc.c DEPS = ticproc.c
@ -40,7 +44,7 @@ OBJ = ticproc.o ../../src/inih/ini.o crc32.o
ticproc: $(OBJ) ticproc: $(OBJ)
$(CC) -o ticproc $^ $(CFLAGS) $(LDFLAGS) -lsqlite3 $(CC) -o ticproc $^ $(CFLAGS) $(LDFLAGS)
.PHONY: clean .PHONY: clean