MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Using extensions.c in 1.8.0 to Add Packages



The new extensions.c, which is included in 1.8.0, is a great way of
adding to the server in a modular way!  However to make things even
more modular, the Makefile needs to be modified so that it "includes"
a file which contains macros and rules for the files in extensions.c.
Only one line needs to be added and the extensions.o rule needs to be
modified.  I have attached an abbreviated Makefile, extensions.mak,
and extensions.c file to show one way of doing this.

The extensions.mak and extensions.c file show how I have added 3
packages to the server.  I keep these files and all of the package
files in a separate directory, so when I get a new version of the
server, I'll just copy the files to the new server source directory
and recompile.  Odds are, files will still need to be edited, but with
this method, the changes could be localized to a few files and a few
lines.

Happy hacking,

Bruce Rafnel
_______________________________________________________________________________
EMail: rafnelb@mayfield.hp.com
The goal of Computer Science is to build something that will last at least
until we have finished building it.
_______________________________________________________________________________

========================================================================
# File: Makefile
.
.
.
OBJS = $(COBJS) $(YOBJS)

# Included after all macro definitions, so that changes or additions
# can be done to previous macros.
include extensions.mak

moo:	$(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(LIBRARIES) -static -o $@
.
.
.
execute.o : execute.c my-string.h config.h db.h program.h structures.h my-stdio.h \
  my-types.h my-stdarg.h version.h db_io.h decompile.h ast.h parser.h sym_table.h \
  eval_env.h eval_vm.h execute.h opcode.h parse_cmd.h exceptions.h functions.h \
  list.h log.h numbers.h options.h server.h network.h storage.h streams.h tasks.h \
  timers.h my-time.h utils.h 

extensions.o : $(EXTDEP)

functions.o : functions.c my-stdarg.h config.h bf_register.h functions.h my-stdio.h \
  my-types.h execute.h db.h program.h structures.h version.h opcode.h parse_cmd.h \
  list.h log.h server.h network.h options.h storage.h streams.h unparse.h utils.h 
.
.
.

========================================================================
# File: extensions.mak
# Include file for extensions.c (This is a brute force way of defining
# the dependencies, but it is clear which package uses which file.)

FUPDEP = \
 files.c \
 my-time.h \
 my-string.h \
 config.h \
 functions.h \
 log.h \
 random.h \
 storage.h \
 utils.h \
 unparse.h \
 list.h \
 regexpr.h \
 version.h

LISTDEP = \
 extlist.c \
 bf_register.h \
 config.h \
 exceptions.h \
 functions.h \
 list.h \
 log.h \
 md5.h \
 my-ctype.h \
 my-string.h \
 options.h \
 pattern.h \
 random.h \
 ref_count.h \
 storage.h \
 streams.h \
 structures.h \
 unparse.h \
 utils.h

DOCMDDEP = \
 extdocmd.c \
 config.h \
 db.h \
 execute.h \
 execute.h \
 functions.h \
 list.h \
 log.h \
 my-signal.h \
 my-stdio.h \
 my-stdlib.h \
 my-string.h \
 my-types.h \
 my-unistd.h \
 my-wait.h \
 network.h \
 options.h \
 parse_cmd.h \
 random.h \
 server.h \
 storage.h \
 streams.h \
 structures.h \
 tasks.h \
 timers.h \
 utils.h \
 version.h

PEMDEP = \
 extpem.c \
 config.h \
 db.h \
 execute.h \
 execute.h \
 functions.h \
 list.h \
 log.h \
 my-signal.h \
 my-stdio.h \
 my-stdlib.h \
 my-string.h \
 my-types.h \
 my-unistd.h \
 my-wait.h \
 network.h \
 options.h \
 parse_cmd.h \
 random.h \
 server.h \
 storage.h \
 streams.h \
 structures.h \
 tasks.h \
 timers.h \
 utils.h \
 version.h

EXTDEP = \
 extensions.c \
 bf_register.h \
 config.h \
 db.h \
 execute.h \
 functions.h \
 my-stdarg.h \
 my-stdio.h \
 my-types.h \
 opcode.h \
 parse_cmd.h \
 program.h \
 structures.h \
 version.h \
 $(FUPDEP) \
 $(LISTDEP) \
 $(DOCMDDEP) \
 $(PEMDEP)

========================================================================
/* File: extensions.c */
/* This is an example of one way that different packages can be added
to the extensions.c file.  The main advantage of include files, is the
files could be easily replaced with newer versions (probably without
changes to this file.  The #ifdef's are useful for quickly removing
"problem" packages.
*/
.
.
.

/*
 * Extensions to the MOO server 
 */

#define FUP 1
#define LIST 1
#define PEM 1

#include "bf_register.h"
#include "functions.h"

#if FUP
const char *FUP_version = "1.8";
#include "files.c"
#endif

#if LIST
#include "extlist.c"
#endif

#if PEM
#include "extpem.c"
#endif

void    register_extensions()
{
	oklog("Extensions:\n");

#if FUP
	register_files();
	oklog("        Using File Utilities Package version %s\n", FUP_version);
#endif

#if LIST
	(void) register_function("listiassoc", 2, 3, bf_listiassoc, TYPE_ANY,
				 TYPE_LIST, TYPE_INT);
	(void) register_function("listassoc", 2, 3, bf_listassoc, TYPE_ANY,
				 TYPE_LIST, TYPE_INT);
	oklog("        listutils.patch, Kenny Root, 3/5/95, 1.0\n");
#endif

#if PEM
	(void) register_function("pem_decode", 1, 1, bf_pem_decode, TYPE_STR);
	oklog("        PEM builtin, WOOM 1.0\n");
#endif
}

char    rcsid_extensions[] = "$Id: extensions.c,v 2.1 1996/02/08 07:03:47 pavel Exp $";



Home | Subject Index | Thread Index