Skip to content

Commit

Permalink
Modified some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil Samith Bysani committed Jan 4, 2009
1 parent cf9be5f commit 851c9d5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/base/bang-module-api.h
Expand Up @@ -16,7 +16,13 @@
*/
void BANG_debug_on_all_peers(char *message);

/**
* The api for the modules to use.
*/
typedef struct {
/**
* Refrence to BANG_debug_on_all_peers.
*/
void (*BANG_debug_on_all_peers) (char *message);
} BANG_api;
#endif
29 changes: 18 additions & 11 deletions src/base/bang-module.c
Expand Up @@ -41,23 +41,28 @@ unsigned char* module_hash(char *path) {
int read = UPDATE_SIZE;

unsigned char *md = (unsigned char*) calloc(SHA_DIGEST_LENGTH,sizeof(unsigned char));
///This ctx creation should be done in an init
///function as it takes some time.
/*
* This ctx creation should be done in an init
* function as it takes some time.
*/
EVP_MD_CTX *ctx = EVP_MD_CTX_create();
EVP_MD_CTX_init(ctx);
///TODO: Error checking!
EVP_DigestInit_ex(ctx,EVP_sha1(),NULL);


///We don't really need to do this.
///(It'd be pretty interesting if we found a shared library bigger than memory.)
/*
* We don't really need to do this.
* It'd be pretty interesting if we found a shared library bigger than memory.)
*/
while (read < UPDATE_SIZE) {
read = fread(buf,sizeof(char),UPDATE_SIZE,fd);
EVP_DigestUpdate(ctx,buf,read);
}

EVP_DigestFinal_ex(ctx,md,NULL);

EVP_MD_CTX_destroy(ctx);
return md;
}

Expand All @@ -66,7 +71,7 @@ BANG_module* BANG_load_module(char *path) {
BANG_sigargs args;
args.args = dlerror();

///Make sure the dlopen worked.
/* Make sure the dlsym worked. */
if (args.args != NULL) {
args.length = strlen(args.args);
BANG_send_signal(BANG_MODULE_ERROR,args);
Expand All @@ -83,7 +88,7 @@ BANG_module* BANG_load_module(char *path) {

module->module_name = dlsym(handle,"BANG_module_name");

///Make sure the dlsym worked.
/* Make sure the dlsym worked. */
if ((args.args = dlerror()) != NULL) {
dlclose(handle);
free(module);
Expand All @@ -98,7 +103,7 @@ BANG_module* BANG_load_module(char *path) {

module->module_version = dlsym(handle,"BANG_module_version");

///Make sure the dlsym worked.
/* Make sure the dlsym worked. */
if ((args.args = dlerror()) != NULL) {
dlclose(handle);
free(module);
Expand All @@ -113,7 +118,7 @@ BANG_module* BANG_load_module(char *path) {

*(void **) (&(module->module_init)) = dlsym(handle,"BANG_module_init");

///Make sure the dlsym worked.
/* Make sure the dlsym worked. */
if ((args.args = dlerror()) != NULL) {
dlclose(handle);
free(module);
Expand All @@ -128,7 +133,7 @@ BANG_module* BANG_load_module(char *path) {

*(void **) (&(module->module_run)) = dlsym(handle,"BANG_module_run");

///Make sure the dlsym worked.
/* Make sure the dlsym worked. */
if ((args.args = dlerror()) != NULL) {
dlclose(handle);
free(module);
Expand All @@ -142,8 +147,10 @@ BANG_module* BANG_load_module(char *path) {
}

module->md = module_hash(path);
///The real question is, should I do a hash of the module handle?
///Then we need to know how long the module handle is.
/*
* The real question is, should I do a hash of the module handle?
* Then we need to know how long the module handle is.
*/
module->handle = handle;
module->path = path;

Expand Down
23 changes: 23 additions & 0 deletions src/base/bang-types.h
Expand Up @@ -29,8 +29,19 @@ typedef struct _BANG_module {
*/
void (*module_run)();

/**
* The hash of the module.
*/
unsigned char *md;

/**
* The actual handle of the module.
*/
void *handle;

/**
* The path to the module.
*/
char *path;
} BANG_module;

Expand Down Expand Up @@ -166,9 +177,21 @@ enum BANG_headers {
BANG_NUM_HEADERS
} BANG_header;

/**
* A request to be made to a write peer thread.
*/
typedef struct {
/**
* The type of request.
*/
char type;
/**
* Information part of the request.
*/
void *request;
/**
* Length of the information.
*/
unsigned int length;
} BANG_request;

Expand Down

0 comments on commit 851c9d5

Please sign in to comment.