Haiku Support
Hope I didn't break things!
This commit is contained in:
11
src/GNUmakefile.haiku
Normal file
11
src/GNUmakefile.haiku
Normal 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
|
14
src/bbs.c
14
src/bbs.c
@@ -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);
|
||||
|
||||
|
@@ -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"
|
||||
|
@@ -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"
|
||||
|
@@ -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
|
||||
|
10
src/main.c
10
src/main.c
@@ -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 {
|
||||
|
Reference in New Issue
Block a user