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__ )
#include <sys/file.h>
#include <unistd.h>
#if defined(__sun) || defined(__MUSL__)
#if defined(__sun) || defined(__MUSL__) || defined(__HAIKU__)
#include <fcntl.h>
#endif
#endif

View File

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

View File

@ -96,7 +96,7 @@
#define OD_DLL
#endif /* !OD_WIN32_STATIC */
#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
#undef ODPLAT_DOS
#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 <unistd.h>
#include <sys/stat.h>
#ifdef __HAIKU__
#include <posix/fcntl.h>
#else
#include <sys/fcntl.h>
#endif
#include <signal.h>
#include <sys/utsname.h>
#include <sys/time.h>
@ -15,7 +19,9 @@
#include <errno.h>
#include <sys/socket.h>
#include <iconv.h>
#ifndef DISABLE_MQTT
#include <mosquitto.h>
#endif
#include "bbs.h"
#include "lua/lua.h"
#include "lua/lualib.h"
@ -33,7 +39,9 @@ int usertimeout;
int timeoutpaused;
time_t userlaston;
#ifndef DISABLE_MQTT
struct mosquitto *mosq = NULL;
#endif
char *ipaddress = NULL;
@ -49,6 +57,7 @@ void sigint_handler(int s) {
// do nothing...
}
void broadcast(char *mess, ...) {
#ifndef DISABLE_MQTT
char buffer[PATH_MAX];
if (conf.broadcast_enable && conf.broadcast_port != 0 && conf.broadcast_address != NULL) {
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);
}
#endif
}
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);
remove(buffer);
#ifndef DISABLE_MQTT
if (mosq != NULL) {
mosquitto_disconnect(mosq);
mosquitto_loop_stop(mosq, 0);
mosquitto_destroy(mosq);
mosquitto_lib_cleanup();
}
#endif
}
void disconnect(char *calledby) {
@ -946,6 +958,7 @@ void runbbs_real(int socket, char *ip, int ssh) {
}
// initialize mqtt
#ifndef DISABLE_MQTT
if (conf.broadcast_enable && conf.broadcast_address != NULL && conf.broadcast_port != 0) {
mosquitto_lib_init();
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);

View File

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

View File

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

View File

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

View File

@ -11,9 +11,11 @@
#include <stdlib.h>
#include <errno.h>
#include <arpa/inet.h>
#ifndef DISABLE_SSH
#include <libssh/libssh.h>
#include <libssh/server.h>
#include <libssh/callbacks.h>
#endif
#include <string.h>
#include <poll.h>
#if defined(linux)
@ -479,6 +481,8 @@ static int handler(void *user, const char *section, const char *name,
return 1;
}
#ifndef DISABLE_SSH
int ssh_authenticate(ssh_session p_ssh_session) {
ssh_message message;
char *username;
@ -856,7 +860,7 @@ void serverssh(int port, int ipv6) {
}
}
}
#endif
void server(int port, int ipv6) {
struct sigaction sa;
struct sigaction st;
@ -955,7 +959,7 @@ void server(int port, int ipv6) {
remove(conf.pid_file);
exit(1);
}
#ifndef DISABLE_SSH
if (conf.ssh_server) {
if (!conf.fork) {
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.");
}
}
#endif
if (ipv6) {
server_socket = socket(AF_INET6, SOCK_STREAM, 0);
} else {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,19 +30,20 @@ MBOBJS_MSG = obj/mb_msg.o
MBDEFS_JAM = -DMSGBASE_JAM
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
MBDEFS = $(MBDEFS_MSG) $(MBDEFS_JAM) $(MBDEFS_SQ3)
MBOBJS = $(MBOBJS_MSG) $(MBOBJS_JAM) $(MBOBJS_SQ3)
MBDEFS = $(MBDEFS_MSG) $(MBDEFS_JAM)
MBOBJS = $(MBOBJS_MSG) $(MBOBJS_JAM)
DEFS = $(PLATFORMDEF) $(MBDEFS) $(NLDEFS)
ifeq ($(OS), SunOS)
SLIBS = -lsocket -lnsl
else
ifeq ($(OS), Haiku)
SLIBS = -lnetwork
else
SLIBS =
endif
endif
# Commands
@ -94,7 +95,7 @@ files : $(BINDIR)/magimail$(EXESUFFIX) \
$(BINDIR)/magilistout$(EXESUFFIX)
$(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)
$(BINDIR)/magistats$(EXESUFFIX) : tools/magistats.c $(SHOBJS) $(OSLIB)

View File

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