-# $Id: GNUmakefile,v 1.1 2006/12/31 08:32:39 mmondor Exp $
+# $Id: GNUmakefile,v 1.2 2014/06/19 18:22:03 mmondor Exp $
CC := cc
RM := rm
$(OBJDUMP) -t $(TMPDIR)/obj.o | \
$(GREP) 'file format' | $(AWK) '{print $$4}' \
&& $(RM) $(TMPDIR)/obj.o $(TMPDIR)/obj.c)
-OBJARCH := $(shell echo $(OBJTARGET) | $(AWK) -F '-' '{print $$2}')
+#OBJARCH := $(shell echo $(OBJTARGET) | $(AWK) -F '-' '{print $$2}')
+OBJARCH := i386
SEED := $(shell date +%s)
# Architecture independent settings follow
-/* $Id: conf.h,v 1.1 2006/12/31 08:32:39 mmondor Exp $ */
+/* $Id: conf.h,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
* Various hardcoded configuration parameters.
*/
-#define SERVER_HOST "hal.xisop"
+#define SERVER_HOST "192.168.1.15"
/*#define SERVER_HOST "tms-play.pulsar-zone.net"*/
#define SERVER_PORT 7777
-/* $Id: recvq.c,v 1.1 2006/12/31 08:32:39 mmondor Exp $ */
+/* $Id: recvq.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
* packets.
*/
if ((s = SDLNet_TCP_Recv(q->sock, rbuffer, RBUFFER_SIZE)) == -1 ||
- s == 0)
+ s == 0) {
+ (void) fprintf(stderr,
+ "SDLNet_TCP_Recv() == %d - %d - %s\n",
+ s, errno, SDLNet_GetError());
return -1;
+ }
#ifdef USE_ENCRYPTION
/* Decrypt incomming data */
q->zin.next_out = (Bytef *)ibuffer;
q->zin.avail_out = IBUFFER_SIZE;
if ((ret = inflate(&q->zin, Z_SYNC_FLUSH)) != Z_OK &&
- ret != Z_STREAM_END)
+ ret != Z_STREAM_END) {
+ (void) fprintf(stderr,
+ "inflate() error\n");
return -1;
+ }
buf = (int8_t *)ibuffer;
s = IBUFFER_SIZE - q->zin.avail_out;
#else
-/* $Id: thread_msg.c,v 1.2 2007/12/29 19:13:37 mmondor Exp $ */
+/* $Id: thread_msg.c,v 1.3 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (C) 2006, Matthew Mondor
{
ASSERT(msg != NULL);
+
msg->callback = callback;
msg->callback_arg = callback_arg;
}
-/* $Id: packets_common.h,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: packets_common.h,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
* Client to server packets
*/
-enum cpacket_tyoes {
+enum cpacket_types {
CPACKET_AUTH = 0,
CPACKET_PING,
CPACKET_PONG,
-# $Id: GNUmakefile,v 1.1 2006/12/31 08:32:40 mmondor Exp $
+# $Id: GNUmakefile,v 1.2 2014/06/19 18:22:03 mmondor Exp $
-MMLIB_PATH := ../../../mmlib
+MMLIB_PATH := ../../mmlib
-MMLIBS := $(addprefix $(MMLIB_PATH)/,mmpool.o mmstring.o mmarch.o)
+MMLIBS := $(addprefix $(MMLIB_PATH)/,mmpool.o mmarch.o)
LIBS := -lc -lm -lz
OBJS := $(addprefix src/,main.o trigonometry.o net.o kqueue.o sendq.o recvq.o \
packets.o daemon.o client.o ships.o torp.o enc.o) \
-/* $Id: client.c,v 1.2 2007/12/05 23:47:57 mmondor Exp $ */
+/* $Id: client.c,v 1.3 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
if (sendq_write(&c->sendq, buf, size, client_enable_write_polling, c,
buffer) == -1) {
- syslog(LOG_NOTICE, "sendq_write(%u) - %s", size,
- strerror(errno));
+ syslog(LOG_NOTICE, "sendq_write(%u) - %s",
+ (unsigned int)size, strerror(errno));
return -1;
}
* We can safely use DLIST_FOREACH() since client_destroy_mark()
* doesn't yet destroy the node, and we're single-threaded.
*/
- DLIST_FOREACH(&clients_list, (client_t *)c) {
+ DLIST_FOREACH(&clients_list, c) {
if (current_time - c->created >= TIMEOUT_SECONDS &&
c->recvq.recvpackets == 0)
client_destroy_mark(c);
-/* $Id: daemon.c,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: daemon.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
#include <syslog.h>
#include <unistd.h>
-#include <mmstring.h>
-
#include <conf.h>
if ((fd = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600)) != -1) {
(void) snprintf(str, 15, "%d\n", getpid());
- (void) write(fd, str, mm_strlen(str));
+ (void) write(fd, str, strlen(str));
(void) close(fd);
} else
syslog(LOG_NOTICE, "pidfile_write() - open(%s) - %s",
-/* $Id: kqueue.c,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: kqueue.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
EV_SET(sev, id, EVFILT_TIMER, EV_ADD | EV_ENABLE, 0, ms,
(intptr_t)NULL);
if (kevent(kqid, sev, 1, NULL, 0, NULL) == -1) {
- syslog(LOG_NOTICE, "kevent_addtimer(%d) - kevent(%lld) - %s",
- id, ms, strerror(errno));
+ syslog(LOG_NOTICE, "kevent_addtimer(%d) - kevent(%" PRId64
+ ") - %s", id, ms, strerror(errno));
exit(EXIT_FAILURE);
}
}
/* Report errors if any */
if ((kev->flags & EV_ERROR) != 0) {
syslog(LOG_NOTICE,
- "EV_ERROR: ident=%d filter=%d flags=%d "
- "fflags=%d data=%lld udata=%p",
+ "EV_ERROR: ident=%" PRIuPTR " filter=%"
+ PRIu32 " flags=%" PRIu32 " fflags=%"
+ PRIu32 " data=%" PRId64 " udata=%p",
kev->ident, kev->filter, kev->flags,
kev->fflags, kev->data,
(void *)kev->udata);
-/* $Id: net.c,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: net.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <mmstring.h>
-
#include <net.h>
#include <conf.h>
fd = -1;
- mm_memclr(&server, sizeof(struct sockaddr_in));
+ memset(&server, 0, sizeof(struct sockaddr_in));
server.sin_family = AF_INET;
if (inet_pton(AF_INET, addr, &server.sin_addr) != 1) {
syslog(LOG_NOTICE, "inet_pton(%s) - %s", addr,
-/* $Id: packets.c,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: packets.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
#include <syslog.h>
#include <string.h>
-#include <mmstring.h>
#include <mmarch.h>
+#include <mmlist.h>
#include <mmlog.h>
#include <packets_common.h>
torps_update();
/* XXX Send all ships and all torps to all clients for now */
- DLIST_FOREACH(&clients_list, (node_t *)c) {
+ DLIST_FOREACH(&clients_list, c) {
client_t *c2;
torp_t *t;
c->slowcnt = c->slowlevel;
}
- DLIST_FOREACH(&clients_list, (node_t *)c2) {
+ DLIST_FOREACH(&clients_list, c2) {
if (!c2->authenticated)
continue;
}
}
- DLIST_FOREACH(&torps_list, (node_t *)t) {
+ DLIST_FOREACH(&torps_list, t) {
if (spacket_torp_send(c, t) == -1)
break;
}
*/
validuser = 0;
(void) memset(plogin, '\0', 16);
- (void) strncpy(plogin, SERVER_LOGIN, 15);
+ (void) strncpy((char *)plogin, SERVER_LOGIN, 15);
if (memcmp(p->login, plogin, 16) == 0)
validuser = 1;
else
*/
/* XXX If !validuser we should use a dummy password */
(void) memset(ppasswd, '\0', 32);
- (void) strncpy(ppasswd, SERVER_PASSWD, 31);
+ (void) strncpy((char *)ppasswd, SERVER_PASSWD, 31);
hmac_sha1((uint8_t *)c->noncerand1, 32, ppasswd, 32, hmac1);
hmac_rmd160((uint8_t *)c->noncerand1, 32, ppasswd, 32, &hmac1[20]);
-/* $Id: recvq.c,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: recvq.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
#include <string.h>
#include <syslog.h>
-#include <mmstring.h>
-
#include <recvq.h>
#include <conf.h>
-static int8_t rbuffer[RBUFFER_SIZE];
+static uint8_t rbuffer[RBUFFER_SIZE];
#ifdef USE_COMPRESSION
-static char ibuffer[IBUFFER_SIZE];
+static unsigned char ibuffer[IBUFFER_SIZE];
#endif
recvq_read(recvq_t *q)
{
ssize_t s;
- int8_t *ptr, *tptr, *buf;
+ uint8_t *ptr, *tptr, *buf;
client_t *c = (client_t *)q->client;
/*
syslog(LOG_NOTICE,
"recvq_read(%d) - "
"Invalid packet size %d",
- q->fd, q->length);
+ q->fd, (int)q->length);
q->variable = -1;
q->length = -1;
return -1;
register size_t s;
s = q->tail - q->ptail;
- (void) mm_memcpy(q->buffer, &q->buffer[q->ptail], s);
+ (void) memcpy(q->buffer, &q->buffer[q->ptail], s);
q->tail = s;
} else
q->tail = 0;
-/* $Id: sendq.c,v 1.1 2006/12/31 08:32:40 mmondor Exp $ */
+/* $Id: sendq.c,v 1.2 2014/06/19 18:22:03 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
#include <unistd.h>
#include <mmlist.h>
-#include <mmstring.h>
#include <sendq.h>
#include <client.h>
#ifdef USE_COMPRESSION
-static char dbuffer[DBUFFER_SIZE];
+static unsigned char dbuffer[DBUFFER_SIZE];
#endif
if (q->tail + size > q->size)
return -1;
- (void) mm_memcpy(&q->buffer[q->tail], buf, size);
+ (void) memcpy(&q->buffer[q->tail], buf, size);
q->tail += size;
if (bfunc != NULL && buffer)
bfunc(bfuncarg);
#endif
#ifdef USE_COMPRESSION
- char ch;
- size_t size;
+ unsigned char ch;
+ size_t size;
q->zout.next_in = &ch;
q->zout.avail_in = 0;
mmenc_encrypt(&q->enc_out, dbuffer, size);
#endif
- (void) mm_memcpy(&q->buffer[q->tail], dbuffer, size);
+ (void) memcpy(&q->buffer[q->tail], dbuffer, size);
q->tail += size;
if (bfunc != NULL)
bfunc(bfuncarg);