Skip to content

Commit

Permalink
version 0.7.0 : plugin support is removed
Browse files Browse the repository at this point in the history
remove plugin support for logging.
moved logging related macros and definitions to log/logging.h
created macro for b_log() to avoid changing a lot of files.
removed dll low-level routines and plugin support.
  • Loading branch information
OrangeTide committed Apr 28, 2020
1 parent 10edf97 commit 6c01765
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 500 deletions.
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ CPPFLAGS+=-DNTEST
# project configurations
MODULES:=\
boris \
logging \
# do not remove this comment.

# hack around makedep rules not seeing our CPPFLAGS_modules
CPPFLAGS+=-Iinclude/ -Ichannel -Icharacter/ -Icrypt/ -Ifdb/ -Iroom/ -Itask/ -Iutil/ -Iworldclock/
CPPFLAGS+=-Iinclude/ -Ichannel -Icharacter/ -Icrypt/ -Ifdb/ -Iroom/ -Itask/ -Iutil/ -Iworldclock/ -Ilog/

# boris
EXEC_boris:=boris
Expand All @@ -45,6 +44,7 @@ SRCS_boris:=\
crypt/sha1crypt.c \
fdb/fdbfile.c \
log/eventlog.c \
log/logging.c \
room/room.c \
server/common.c \
task/command.c \
Expand All @@ -54,11 +54,6 @@ SRCS_boris:=\
# do not remove this comment.
OBJS_boris:=$(SRCS_boris:.c=.o)

# logging.so plugin
EXEC_logging:=logging.$(SOEXT)
SRCS_logging:=logging.c
OBJS_logging:=$(SRCS_logging:.c=.o)

##############################################################################
# Dec 24 2009
#
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Boris MUD is a text-based virtual reality that allows multiple people to engage

## Features

- plugin based design. easily extend, test, and customize your own server.
- file-based database. Like NoSQL, but inferior in every way.

## Building
Expand All @@ -44,7 +43,7 @@ cd boris
make
```

Build output is an executable (`boris`) and several plugins (`channel.so character.so example.so fdbfile.so logging.so room.so`).
Build output is an executable (`boris`).

## Usage

Expand Down
19 changes: 11 additions & 8 deletions boris.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file common.c
*
* A plugin oriented MUD.
* 20th Century MUD.
*
* @author Jon Mayo <jon.mayo@gmail.com>
* @version 0.6
* @date 2020 Apr 26
* @version 0.7
* @date 2020 Apr 27
*
* Copyright (c) 2008-2020, Jon Mayo
*
Expand Down Expand Up @@ -39,6 +39,7 @@
#include "eventlog.h"
#include "fdb.h"
#include "room.h"
#include "logging.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -236,6 +237,13 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}

if (logging_initialize()) {
ERROR_MSG("could not initialize logging");
return EXIT_FAILURE;
}

atexit(logging_shutdown);

if (fdb_initialize()) {
ERROR_MSG("could not load database");
return EXIT_FAILURE;
Expand Down Expand Up @@ -264,11 +272,6 @@ int main(int argc, char **argv)

atexit(character_shutdown);

if (!plugin_load_list(mud_config.plugins)) {
ERROR_MSG("could not load one or more plugins");
return EXIT_FAILURE;
}

if (!eventlog_init()) {
return EXIT_FAILURE;
}
Expand Down
1 change: 0 additions & 1 deletion boris.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
server.name = MUD
server.port = 4444
server.plugins = logging
prompt.menu = Choose:
prompt.form = Pick:
msg.unsupported = Not supported!
Expand Down
26 changes: 11 additions & 15 deletions channel/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
#include "channel.h"
#include "boris.h"
#include "logging.h"

#include <assert.h>
#include <stdarg.h>
Expand Down Expand Up @@ -67,11 +68,6 @@ struct channel_public {

LIST_HEAD(struct channel_public_list, struct channel_public);

/******************************************************************************
* Prototypes
******************************************************************************/
extern const struct plugin_channel_class plugin_class;

/******************************************************************************
* Globals
******************************************************************************/
Expand All @@ -94,18 +90,18 @@ static struct channel_member **channel_find_member(struct channel *ch, struct ch
{
unsigned i;

DEBUG("looking for channel member %p(p=%p)", cm, cm ? cm->p : NULL);
DEBUG("looking for channel member %p(p=%p)", (void*)cm, cm ? cm->p : NULL);

if (!ch) return NULL;

for (i = 0; i < ch->nr_member; i++) {
DEBUG("looking at %p...", ch->member[i]);
DEBUG("looking at %p...", (void*)ch->member[i]);

if (ch->member[i] == cm) return &ch->member[i];

}

DEBUG("not found %p(p=%p)", cm, cm ? cm->p : NULL);
DEBUG("not found %p(p=%p)", (void*)cm, cm ? cm->p : NULL);
return NULL;
}

Expand Down Expand Up @@ -151,7 +147,7 @@ static int channel_delete_member(struct channel *ch, struct channel_member *cm)

if (!d) return 0; /* not a member */

DEBUG("found channel member %p at %p", cm, d);
DEBUG("found channel member %p at %p", (void*)cm, (void*)d);

assert(ch->nr_member > 0);

Expand Down Expand Up @@ -238,24 +234,24 @@ struct channel *channel_public(const char *name)
}

/**
* Initialize the plugin.
* Initialize the sub-system.
*/
int channel_initialize(void)
{
b_log(B_LOG_INFO, "channel", "channel plugin loaded (" __FILE__ " compiled " __TIME__ " " __DATE__ ")");
b_log(B_LOG_INFO, "channel", "channel sub-system loaded (" __FILE__ " compiled " __TIME__ " " __DATE__ ")");
channel_public_add("Wiz");
channel_public_add("OOC");
channel_public_add(NULL); /* system channel. */
return 0;
}

/**
* Shutdown the plugin.
* Shutdown the sub-system.
*/
void channel_shutdown(void)
{
b_log(B_LOG_INFO, "channel", "channel plugin shutting down...");
b_log(B_LOG_INFO, "channel", "channel plugin ended.");
b_log(B_LOG_INFO, "channel", "channel sub-system shutting down...");
b_log(B_LOG_INFO, "channel", "channel sub-system ended.");
}

/**
Expand Down Expand Up @@ -308,7 +304,7 @@ int channel_broadcast(struct channel *ch, struct channel_member **exclude_list,

for (i = 0; i < ch->nr_member; i++) {
struct channel_member *cm = ch->member[i];
DEBUG("cm=%p p=%p\n", cm, cm ? cm->p : NULL);
DEBUG("cm=%p p=%p\n", (void*)cm, cm ? cm->p : NULL);

if (cm && cm->send && !is_on_list(cm, exclude_list, exclude_list_len)) {
cm->send(cm, ch, buf);
Expand Down
7 changes: 4 additions & 3 deletions character/character.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "character.h"
#include "boris.h"
#include "fdb.h"
#include "logging.h"

#include <assert.h>
#include <stddef.h>
Expand Down Expand Up @@ -420,7 +421,7 @@ static int character_preflight(void)
*/
int character_initialize(void)
{
b_log(B_LOG_INFO, "character", "Character plugin loaded (" __FILE__ " compiled " __TIME__ " " __DATE__ ")");
b_log(B_LOG_INFO, "character", "Character sub-system loaded (" __FILE__ " compiled " __TIME__ " " __DATE__ ")");
freelist_init(&character_id_freelist);
freelist_pool(&character_id_freelist, 1, ID_MAX);

Expand All @@ -443,6 +444,6 @@ int character_initialize(void)
*/
void character_shutdown(void)
{
b_log(B_LOG_INFO, "character", "Character plugin shutting down...");
b_log(B_LOG_INFO, "character", "Character plugin ended.");
b_log(B_LOG_INFO, "character", "Character sub-system shutting down...");
b_log(B_LOG_INFO, "character", "Character sub-system ended.");
}
1 change: 1 addition & 0 deletions fdb/fdbfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
#include "fdb.h"
#include "boris.h"
#include "logging.h"

#include <assert.h>
#include <ctype.h>
Expand Down
23 changes: 4 additions & 19 deletions include/boris.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @file boris.h
*
* A plugin oriented MUD.
* 20th Century MUD.
*
* @author Jon Mayo <jon.mayo@gmail.com>
* @date 2019 Dec 25
* @date 2020 Apr 27
*
* Copyright (c) 2009-2019 Jon Mayo
* Copyright (c) 2009-2020 Jon Mayo
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -35,7 +35,7 @@

/* major, minor and patch level for version. */
#define BORIS_VERSION_MAJ 0
#define BORIS_VERSION_MIN 6
#define BORIS_VERSION_MIN 7
#define BORIS_VERSION_PAT 0

/******************************************************************************
Expand All @@ -57,7 +57,6 @@ struct form_state;
#include <sys/socket.h>

#include "mudconfig.h"
#include "plugin.h"
#include "list.h"
#include "terminal.h"

Expand Down Expand Up @@ -260,15 +259,6 @@ struct socketio_handle;
/** round down on a boundry. */
#define ROUNDDOWN(a,n) ((a)-((a)%(n)))

#define B_LOG_ASSERT 0 /**< unexpected condition forcing shutdown. */
#define B_LOG_CRIT 1 /**< critial message - system needs to shutdown. */
#define B_LOG_ERROR 2 /**< error occured - maybe fatal. */
#define B_LOG_WARN 3 /**< warning - something unexpected. */
#define B_LOG_INFO 4 /**< interesting information */
#define B_LOG_TODO 5 /**< messages for incomplete implementation. */
#define B_LOG_DEBUG 6 /**< debug messages. */
#define B_LOG_TRACE 7 /**< trace logging */

/* names of various domains */
#define DOMAIN_USER "users"
#define DOMAIN_ROOM "rooms"
Expand Down Expand Up @@ -346,11 +336,6 @@ struct channel_member {
* Protos
******************************************************************************/

extern void (*b_log)(int priority, const char *domain, const char *fmt, ...);

int plugin_load(const char *name);
int plugin_load_list(const char *list);

int service_detach_log(void (*log)(int priority, const char *domain, const char *fmt, ...));
void service_attach_log(void (*log)(int priority, const char *domain, const char *fmt, ...));

Expand Down
1 change: 0 additions & 1 deletion include/mudconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extern struct mud_config {
char *default_channels;
unsigned webserver_port;
char *form_newuser_filename;
char *plugins;
int default_family; /* IPv4 or IPv6 */
} mud_config;
#endif
75 changes: 0 additions & 75 deletions include/plugin.h

This file was deleted.

Loading

0 comments on commit 6c01765

Please sign in to comment.