+1998-10-07 Nathan Bryant <bryant@cs.usm.maine.edu>
+ * snprintf.c, snprintf.h: new files
+ * Makefile.in, configure.in, dynloader.c, sysdep.c: support for the
+ above; citserver now builds and runs on Digital Unix 4.0d with the
+ GNU-style configure script. there is a bug with the hostname display
+ in the wholist.
+ * netproc.c: sillyness fix
+ * room_ops.h: prototype delete_room()
+
Mon Oct 5 17:01:32 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Began fixing the stuff I broke
LDFLAGS=@LDFLAGS@
SERVER_LDFLAGS=@SERVER_LDFLAGS@
CURSES=@CURSES@
+SNPRINTF=@SNPRINTF@
PTHREAD_DEFS=-D_REENTRANT
client: $(CLIENT_TARGETS)
citserver: citserver.o user_ops.o support.o room_ops.o file_ops.o \
msgbase.o config.o sysdep.o locate_host.o \
housekeeping.o database.o control.o logging.o \
- dynloader.o
+ dynloader.o $(SNPRINTF)
$(CC) \
citserver.o user_ops.o room_ops.o file_ops.o support.o \
msgbase.o config.o sysdep.o locate_host.o \
housekeeping.o database.o control.o logging.o \
- dynloader.o \
+ dynloader.o $(SNPRINTF)\
$(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) -o citserver
citserver.o: citserver.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c citserver.c
+snprintf.o: snprintf.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c snprintf.c
+
user_ops.o: user_ops.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c user_ops.c
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(mkdir mktime rmdir select socket strerror)
+AC_CHECK_FUNCS(snprintf mkdir mktime rmdir select socket strerror)
+
+if test "$ac_cv_func_snprintf" = no; then
+ SNPRINTF=snprintf.o
+fi
AC_SUBST(CURSES)
AC_SUBST(TARGETS)
AC_SUBST(SERVER_LDFLAGS)
+AC_SUBST(SNPRINTF)
AC_CONFIG_HEADER(sysdep.h)
AC_OUTPUT(Makefile)
#include "server.h"
#include "sysdep_decls.h"
+#ifndef HAVE_SNPRINTF
+#include <stdarg.h>
+#include "snprintf.h"
+#endif
+
struct CleanupFunctionHook *CleanupHookTable = NULL;
struct SessionFunctionHook *SessionHookTable = NULL;
struct UserFunctionHook *UserHookTable = NULL;
/*
* Change directories if specified
*/
- if (argv > 0) for (a=1; a<argc; ++a) {
+ for (a=1; a<argc; ++a) {
if (!strncmp(argv[a], "-h", 2)) {
strcpy(bbs_home_directory, argv[a]);
strcpy(bbs_home_directory, &bbs_home_directory[2]);
void cmd_eflr (char *argbuf);
void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom));
void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix);
+void delete_room(struct quickroom *qrbuf);
--- /dev/null
+/*
+ * modified from Sten Gunterberg's BUGTRAQ post of 22 Jul 1997
+ * --nathan bryant <bryant@cs.usm.maine.edu>
+ */
+
+/*
+ * Replacements for snprintf() and vsnprintf()
+ *
+ * Use it only if you have the "spare" cycles needed to effectively
+ * do every snprintf operation twice! Why is that? Because everything
+ * is first vfprintf()'d to /dev/null to determine the number of bytes.
+ * Perhaps a bit slow for demanding applications on slow machines,
+ * no problem for a fast machine with some spare cycles.
+ *
+ * You don't have a /dev/null? Every Linux contains one for free!
+ *
+ * Because the format string is never even looked at, all current and
+ * possible future printf-conversions should be handled just fine.
+ *
+ * Written July 1997 by Sten Gunterberg (gunterberg@ergon.ch)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+static int
+needed (const char *fmt, va_list argp)
+{
+ static FILE *sink = NULL;
+
+ /* ok, there's a small race here that could result in the sink being
+ * opened more than once if we're threaded, but I'd rather ignore it than
+ * spend cycles synchronizing :-) */
+
+ if (sink == NULL)
+ {
+ if ((sink = fopen("/dev/null", "w")) == NULL)
+ {
+ perror("/dev/null");
+ exit(1);
+ }
+ }
+
+ return vfprintf(sink, fmt, argp);
+}
+
+int
+snprintf (char *buf, size_t max, const char *fmt, ...)
+{
+ va_list argp;
+ int bytes;
+
+ va_start(argp, fmt);
+ bytes = vsnprintf(buf, max, fmt, argp);
+ va_end(argp);
+
+ return bytes;
+}
+
+int
+vsnprintf (char *buf, size_t max, const char *fmt, va_list argp)
+{
+ char *p;
+ int size;
+
+ if ((p = malloc(needed(fmt, argp) + 1)) == NULL)
+ {
+ fprintf(stderr, "vsnprintf: malloc failed, aborting\n");
+ abort();
+ }
+
+ if ((size = vsprintf(p, fmt, argp)) >= max)
+ size = -1;
+
+ strncpy(buf, p, max);
+ buf[max - 1] = 0;
+ free(p);
+ return size;
+}
--- /dev/null
+int snprintf (char *buf, size_t max, const char *fmt, ...);
+int vsnprintf (char *buf, size_t max, const char *fmt, va_list argp);
#include <sys/select.h>
#endif
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
pthread_mutex_t Critters[MAX_SEMAPHORES]; /* Things needing locking */
pthread_key_t MyConKey; /* TSD key for MyContext() */