Magicka now builds and runs on SunOS
This commit is contained in:
76
src/Makefile.sunos
Normal file
76
src/Makefile.sunos
Normal file
@@ -0,0 +1,76 @@
|
||||
CC=gcc
|
||||
CFLAGS=-std=gnu99 -I/usr/local/include -I../deps/
|
||||
DEPS = bbs.h
|
||||
JAMLIB = ../deps/jamlib/jamlib.a
|
||||
ZMODEM = ../deps/Xmodem/libzmodem.a
|
||||
LUA = ../deps/lua/liblua.a
|
||||
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile solaris MAKEFLAGS=
|
||||
|
||||
${JAMLIB}:
|
||||
cd ../deps/jamlib && $(MAKE) -f Makefile.sunos MAKEFLAGS=
|
||||
|
||||
${ZMODEM}:
|
||||
cd ../deps/Xmodem && $(MAKE) MAKEFLAGS=
|
||||
|
||||
${ODOORS}:
|
||||
cd ../deps/odoors/ && $(MAKE)
|
||||
|
||||
$(JSMN):
|
||||
cd ../deps/jsmn/ && $(MAKE)
|
||||
|
||||
$(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && ./configure
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o os/sunos.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN}
|
||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh -lnsl -lsocket
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd ../utils/magimail && $(MAKE) freebsd
|
||||
|
||||
magiedit: $(ODOORS)
|
||||
cd ../utils/magiedit && $(MAKE) -f Makefile.sunos
|
||||
|
||||
ticproc:
|
||||
cd ../utils/ticproc && $(MAKE)
|
||||
|
||||
mgpost: $(JAMLIB)
|
||||
cd ../utils/mgpost && $(MAKE)
|
||||
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE) -f Makefile.sunos
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) ../magicka
|
||||
cd ../deps/lua && $(MAKE) clean
|
||||
cd ../deps/jamlib && $(MAKE) -f Makefile.linux clean
|
||||
cd ../deps/Xmodem && $(MAKE) clean
|
||||
cd ../utils/magimail && $(MAKE) cleanfreebsd
|
||||
cd ../utils/magiedit && $(MAKE) clean
|
||||
cd ../deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
|
||||
cd ../utils/ticproc && $(MAKE) clean
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
81
src/Makefile.sunos.WWW
Normal file
81
src/Makefile.sunos.WWW
Normal file
@@ -0,0 +1,81 @@
|
||||
CC=gcc
|
||||
CFLAGS=-std=gnu99 -I/usr/local/include -I../deps/ -I../deps/libb64-1.2/include -DENABLE_WWW=1
|
||||
DEPS = bbs.h
|
||||
JAMLIB = ../deps/jamlib/jamlib.a
|
||||
ZMODEM = ../deps/Xmodem/libzmodem.a
|
||||
LUA = ../deps/lua/liblua.a
|
||||
B64 = ../deps/libb64-1.2/src/libb64.a
|
||||
MICROHTTPD=-lmicrohttpd
|
||||
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile solaris MAKEFLAGS=
|
||||
|
||||
${JAMLIB}:
|
||||
cd ../deps/jamlib && $(MAKE) -f Makefile.sunos MAKEFLAGS=
|
||||
|
||||
${ZMODEM}:
|
||||
cd ../deps/Xmodem && $(MAKE) MAKEFLAGS=
|
||||
|
||||
${B64}:
|
||||
cd ../deps/libb64-1.2 && $(MAKE) MAKEFLAGS= CC=gcc
|
||||
|
||||
${ODOORS}:
|
||||
cd ../deps/odoors/ && $(MAKE)
|
||||
|
||||
$(JSMN):
|
||||
cd ../deps/jsmn/ && $(MAKE)
|
||||
|
||||
$(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && ./configure
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o hashmap/hashmap.o menus.o os/sunos.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN}
|
||||
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD) -lnsl -lsocket
|
||||
|
||||
magimail: $(JAMLIB)
|
||||
cd ../utils/magimail && $(MAKE) freebsd
|
||||
|
||||
magiedit: $(ODOORS)
|
||||
cd ../utils/magiedit && $(MAKE) -f Makefile.sunos
|
||||
|
||||
ticproc:
|
||||
cd ../utils/ticproc && $(MAKE)
|
||||
|
||||
mgpost: $(JAMLIB)
|
||||
cd ../utils/mgpost && $(MAKE)
|
||||
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE) -f Makefile.sunos
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) ../magicka
|
||||
cd ../deps/lua && $(MAKE) clean
|
||||
cd ../deps/jamlib && $(MAKE) -f Makefile.linux clean
|
||||
cd ../deps/Xmodem && $(MAKE) clean
|
||||
cd ../deps/libb64-1.2 && $(MAKE) clean
|
||||
cd ../utils/magimail && $(MAKE) cleanfreebsd
|
||||
cd ../utils/magiedit && $(MAKE) clean
|
||||
cd ../deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s`
|
||||
cd ../utils/ticproc && $(MAKE) clean
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
@@ -14,8 +14,10 @@
|
||||
# include <pty.h>
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
# include <util.h>
|
||||
#else
|
||||
#elif defined(__FreeBSD__)
|
||||
# include <libutil.h>
|
||||
#elif defined(__sun)
|
||||
# include "os/sunos.h"
|
||||
#endif
|
||||
#include "bbs.h"
|
||||
#include "lua/lua.h"
|
||||
|
@@ -576,7 +576,12 @@ int do_upload(struct user_record *user, char *final_path) {
|
||||
return 0;
|
||||
}
|
||||
while ((dent = readdir(inb)) != NULL) {
|
||||
#ifdef __sun
|
||||
stat(dent->d_name, &s);
|
||||
if (S_ISREG(s.st_mode)) {
|
||||
#else
|
||||
if (dent->d_type == DT_REG) {
|
||||
#endif
|
||||
snprintf(upload_command, 1024, "%s%s", upload_path, dent->d_name);
|
||||
snprintf(upload_filename, 1024, "%s/%s", final_path, dent->d_name);
|
||||
|
||||
|
@@ -13,7 +13,9 @@
|
||||
#include "lua/lua.h"
|
||||
#include "lua/lualib.h"
|
||||
#include "lua/lauxlib.h"
|
||||
|
||||
#ifdef __sun
|
||||
#include "os/sunos.h"
|
||||
#endif
|
||||
extern struct bbs_config conf;
|
||||
extern struct user_record *gUser;
|
||||
extern int mynode;
|
||||
@@ -24,8 +26,11 @@ time_t utc_to_local(time_t utc) {
|
||||
|
||||
localtime_r(&utc, &date_time);
|
||||
|
||||
#ifdef __sun
|
||||
local = utc + gmtoff(utc);
|
||||
#else
|
||||
local = utc + date_time.tm_gmtoff;
|
||||
|
||||
#endif
|
||||
return local;
|
||||
}
|
||||
|
||||
|
@@ -17,10 +17,12 @@
|
||||
#include <poll.h>
|
||||
#if defined(linux)
|
||||
# include <pty.h>
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||
# include <util.h>
|
||||
#else
|
||||
#elif defined(__FreeBSD__)
|
||||
# include <libutil.h>
|
||||
#elif defined(__sun)
|
||||
# include "os/sunos.h"
|
||||
#endif
|
||||
#if defined(ENABLE_WWW)
|
||||
# include <microhttpd.h>
|
||||
|
100
src/os/sunos.c
Normal file
100
src/os/sunos.c
Normal file
@@ -0,0 +1,100 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stropts.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#define TM_YEAR_ORIGIN 1900
|
||||
|
||||
int openpty(int *amaster, int *aslave, char *name, void *termp, void *winp) {
|
||||
int ptm;
|
||||
char *pname;
|
||||
int pts;
|
||||
|
||||
ptm = open("/dev/ptmx", O_RDWR);
|
||||
|
||||
grantpt(ptm);
|
||||
unlockpt(ptm);
|
||||
|
||||
pname = ptsname(ptm);
|
||||
|
||||
if (name != NULL) {
|
||||
strcpy(name, pname);
|
||||
}
|
||||
|
||||
pts = open(name, O_RDWR);
|
||||
ioctl(pts, I_PUSH, "ptem");
|
||||
ioctl(pts, I_PUSH, "ldterm");
|
||||
ioctl(pts, I_PUSH, "ttcompat");
|
||||
|
||||
if (termp != NULL) {
|
||||
tcsetattr(pts, TCSAFLUSH, termp);
|
||||
}
|
||||
if (winp != NULL) {
|
||||
ioctl(pts, TIOCSWINSZ, winp);
|
||||
}
|
||||
|
||||
|
||||
*amaster = ptm;
|
||||
*aslave = pts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int forkpty(int *amaster, char *name, void *termp, void *winp) {
|
||||
|
||||
int ptm;
|
||||
char *pname;
|
||||
int pts;
|
||||
pid_t pid;
|
||||
|
||||
ptm = open("/dev/ptmx", O_RDWR);
|
||||
|
||||
grantpt(ptm);
|
||||
unlockpt(ptm);
|
||||
|
||||
pname = ptsname(ptm);
|
||||
|
||||
if (name != NULL) {
|
||||
strcpy(name, pname);
|
||||
}
|
||||
pts = open(name, O_RDWR);
|
||||
ioctl(pts, I_PUSH, "ptem");
|
||||
ioctl(pts, I_PUSH, "ldterm");
|
||||
ioctl(pts, I_PUSH, "ttcompat");
|
||||
|
||||
if (termp != NULL) {
|
||||
tcsetattr(pts, TCSAFLUSH, termp);
|
||||
}
|
||||
if (winp != NULL) {
|
||||
ioctl(pts, TIOCSWINSZ, winp);
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
|
||||
if (!pid) {
|
||||
close(ptm);
|
||||
dup2(pts, 0);
|
||||
dup2(pts, 1);
|
||||
dup2(pts, 2);
|
||||
close(pts);
|
||||
} else {
|
||||
*amaster = ptm;
|
||||
}
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
||||
static long difftm(struct tm *a, struct tm *b) {
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
long days = (a->tm_yday - b->tm_yday + ((ay >> 2) - (by >> 2)) - (ay / 100 - by/100) + ((ay/100 >> 2) - (by / 100 >> 2)) + (long)(ay-by) * 365);
|
||||
|
||||
return (60 * (60 * (24 *days + (a->tm_hour - b->tm_hour)) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec));
|
||||
}
|
||||
|
||||
long gmtoff(time_t value) {
|
||||
struct tm gmt = *gmtime(&value);
|
||||
return difftm(localtime(&value), &gmt);
|
||||
}
|
8
src/os/sunos.h
Normal file
8
src/os/sunos.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __SUNOS_H
|
||||
#define __SUNOS_H
|
||||
|
||||
extern int openpty(int *amaster, int *aslave, char *name, void *termp, void *winp);
|
||||
extern int forkpty(int *amaster, char *name, void *termp, void *winp);
|
||||
extern long gmtoff(time_t value);
|
||||
#endif
|
||||
|
@@ -4,9 +4,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/utsname.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include "bbs.h"
|
||||
#include "jamlib/jam.h"
|
||||
|
||||
|
Reference in New Issue
Block a user