/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* misc.h: Misc. definitions which don't really belong anywhere,
* but have to go somewhere!
- *
+ *
* Known contributors to this file:
* Doug Hay, 1998
*/
#ifndef MISC_H
#define MISC_H
-#include <time.h>
-
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#ifdef _WIN32
-#ifndef __GNUC__
-
-typedef long ssize_t;
-
-/* integral mismatch, due to misuse of sector short */
-#pragma warning (disable : 4761 )
-
-#define strncasecmp(s1, s2, s3) _strnicmp((s1), (s2), (s3))
-
-typedef int pid_t;
-#define vsnprintf _vsnprintf
-#define snprintf _snprintf
-
-#endif /* !__GNUC__ */
-
-#define mkdir(dir,perm) _mkdir((dir))
-#define random rand
-#define srandom srand
-
+#include "w32misc.h"
#endif /* _WIN32 */
-/* This is the structure we use to keep track of the global mobility
- things, such as when the server is supposed to start/stop updating
- mobility and the timestamp of when the game was last up. These
- times are in seconds. */
-struct mob_acc_globals {
- time_t timestamp; /* Last timestamp of when the game was up */
- time_t starttime; /* When we should start updating mobility again. */
-};
+#ifndef S_IRWUG
+#define S_IRWUG S_IRGRP | S_IWGRP | S_IRUSR | S_IWUSR
+#endif
#ifdef __GNUC__
#define ATTRIBUTE(attrs) __attribute__ (attrs)
#define hours(x) (60*60*(x))
#define days(x) (60*60*24*(x))
-extern int debug;
-
/*
* If EXPR is true, an internal error occured.
* Return EXPR != 0.
#define CANT_REACH() (void)oops(NULL, __FILE__, __LINE__)
extern int oops(char *, char *, int);
+extern void (*oops_handler)(void);
+
+void exit_nomem(void) ATTRIBUTE((noreturn));
/* return codes from command routines */
#define RET_OK 0 /* command completed sucessfully */
#define RET_FAIL 1 /* command completed unsucessfully [?] */
#define RET_SYN 2 /* syntax error in command */
-#define RET_SYS 3 /* system error (missing file, etc) */
extern char *getstarg(char *input, char *prompt, char buf[]);
extern char *getstring(char *prompt, char buf[]);
extern char *ugetstring(char *prompt, char buf[]);
-
+
extern char *prbuf(char *format, ...)
ATTRIBUTE((format (printf, 1, 2)));