Skip to content

Commit

Permalink
I have a test module now. I need to flesh out an actual api for the
Browse files Browse the repository at this point in the history
modules so we can write the actual program.
  • Loading branch information
Nikhil Samith Bysani committed Dec 24, 2008
1 parent 160936d commit 4fb7962
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Expand Up @@ -20,6 +20,8 @@ MODULESRC=src/base/bang-module.c

.PHONY: doc

all: $(EXENAME) test-module.so

$(EXENAME): $(OBJS)
$(CC) $(COPTS) $(GTKOPTS) $^ -o $(EXENAME)

Expand All @@ -44,12 +46,15 @@ bang-module.o: $(MODULESRC)
bang-net.o: $(NETWORKSRC)
$(CC) -c $(COPTS) $^

all: $(EXENAME) doc
test-module.so: src/modules/test-module.c
$(CC) --shared -Wl,-soname,testmodule.so $(COPTS) $^ -o test-module.so


doc:
cd doc && doxygen Doxygen

clean:
rm -f $(EXENAME)
rm -f *.o
rm -f *.so
rm -Rf doc/dox
1 change: 1 addition & 0 deletions src/app/main.c
Expand Up @@ -40,6 +40,7 @@
#include"../base/core.h"
#include"../base/bang-signals.h"
#include"../base/bang-types.h"
#include"../base/bang-module.h"
#include"server-preferences.h"
#include<stdio.h>
#include<stdlib.h>
Expand Down
5 changes: 5 additions & 0 deletions src/base/bang-module.c
Expand Up @@ -70,6 +70,7 @@ BANG_module* BANG_load_module(char *path) {
args.length = strlen(args.args);
BANG_send_signal(BANG_MODULE_ERROR,args);
free(args.args);
fprintf(stderr,"Could not find the module.\n");
return NULL;
}

Expand All @@ -84,6 +85,7 @@ BANG_module* BANG_load_module(char *path) {
args.length = strlen(args.args);
BANG_send_signal(BANG_MODULE_ERROR,args);
free(args.args);
fprintf(stderr,"Could not find the module name.\n");
return NULL;
}

Expand All @@ -96,6 +98,7 @@ BANG_module* BANG_load_module(char *path) {
args.length = strlen(args.args);
BANG_send_signal(BANG_MODULE_ERROR,args);
free(args.args);
fprintf(stderr,"Could not find the module version.\n");
return NULL;
}

Expand All @@ -108,6 +111,7 @@ BANG_module* BANG_load_module(char *path) {
args.length = strlen(args.args);
BANG_send_signal(BANG_MODULE_ERROR,args);
free(args.args);
fprintf(stderr,"Could not find the module init function.\n");
return NULL;
}

Expand All @@ -120,6 +124,7 @@ BANG_module* BANG_load_module(char *path) {
args.length = strlen(args.args);
BANG_send_signal(BANG_MODULE_ERROR,args);
free(args.args);
fprintf(stderr,"Could not find the module run function.\n");
return NULL;
}

Expand Down
28 changes: 28 additions & 0 deletions src/modules/test-module.c
@@ -0,0 +1,28 @@
/**
* \file test-module.c
* \author Nikhil Bysani
*/
#include<stdlib.h>
#include<stdio.h>

/**
* \page Test Modules
*
* A bang module should be a C share object file. Currently it must have
* the following symbol names defined:
* -BANG_module_name: the name of the module
* -BANG_module_version: version of the module
* -BANG_module_init: initialize the module
* -BANG_module_run: runs the module
*/

char BANG_module_name[5] = "test";
double BANG_module_version = .1;

int BANG_module_init() {
return 0;
}

void BANG_module_run() {
fprintf(stderr,"TEST with a module name %s.\n",BANG_module_name);
}

0 comments on commit 4fb7962

Please sign in to comment.