|
|
@ -50,50 +50,30 @@ struct module {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
/***************************************
|
|
|
|
* Module "Methods"
|
|
|
|
* Public Static Inlines
|
|
|
|
***************************************/
|
|
|
|
***************************************/
|
|
|
|
|
|
|
|
|
|
|
|
struct module *module__new(char *mod_name, char *mod_path, i32 argument_count, u32 stack_sz, u32 max_heap, u32 timeout, int port, int req_sz, int resp_sz);
|
|
|
|
|
|
|
|
void module__free(struct module *module);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Sets the HTTP Request and Response Headers and Content type on a module
|
|
|
|
* Increment a modules reference count
|
|
|
|
* @param module
|
|
|
|
* @param module
|
|
|
|
* @param request_count
|
|
|
|
|
|
|
|
* @param request_headers
|
|
|
|
|
|
|
|
* @param request_content_type
|
|
|
|
|
|
|
|
* @param response_count
|
|
|
|
|
|
|
|
* @param response_headers
|
|
|
|
|
|
|
|
* @param response_content_type
|
|
|
|
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline void
|
|
|
|
static inline void
|
|
|
|
module__set_http_info(struct module *module, int request_count, char *request_headers, char request_content_type[],
|
|
|
|
module__acquire(struct module *module)
|
|
|
|
int response_count, char *response_headers, char response_content_type[])
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(module);
|
|
|
|
module->reference_count++;
|
|
|
|
module->request_header_count = request_count;
|
|
|
|
|
|
|
|
memcpy(module->request_headers, request_headers, HTTP_HEADER_MAXSZ * HTTP_HEADERS_MAX);
|
|
|
|
|
|
|
|
strcpy(module->request_content_type, request_content_type);
|
|
|
|
|
|
|
|
module->response_header_count = response_count;
|
|
|
|
|
|
|
|
memcpy(module->response_headers, response_headers, HTTP_HEADER_MAXSZ * HTTP_HEADERS_MAX);
|
|
|
|
|
|
|
|
strcpy(module->response_content_type, response_content_type);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Validate module, defined as having a non-NULL dynamical library handle and entry function pointer
|
|
|
|
* Get a module's argument count
|
|
|
|
* @param module
|
|
|
|
* @param module
|
|
|
|
* @return 1 if valid. 0 if invalid
|
|
|
|
* @returns the number of arguments
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline int
|
|
|
|
static inline i32
|
|
|
|
module__is_valid(struct module *module)
|
|
|
|
module__get_argument_count(struct module *module)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (module && module->dynamic_library_handle && module->main) return 1;
|
|
|
|
return module->argument_count;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: What is the point of these wrapper functions. They seem exceptionally silly
|
|
|
|
|
|
|
|
// We have the module, so why not just invoke the function pointer directly?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Invoke a module's initialize_globals
|
|
|
|
* Invoke a module's initialize_globals
|
|
|
|
* @param module
|
|
|
|
* @param module
|
|
|
@ -139,25 +119,27 @@ module__initialize_memory(struct module *module)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Invoke a module's entry function, forwarding on argc and argv
|
|
|
|
* Validate module, defined as having a non-NULL dynamical library handle and entry function pointer
|
|
|
|
* @param module
|
|
|
|
* @param module
|
|
|
|
* @param argc standard UNIX count of arguments
|
|
|
|
* @return 1 if valid. 0 if invalid
|
|
|
|
* @param argv standard UNIX vector of arguments
|
|
|
|
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline i32
|
|
|
|
static inline int
|
|
|
|
module__main(struct module *module, i32 argc, i32 argv)
|
|
|
|
module__is_valid(struct module *module)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return module->main(argc, argv);
|
|
|
|
if (module && module->dynamic_library_handle && module->main) return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Increment a modules reference count
|
|
|
|
* Invoke a module's entry function, forwarding on argc and argv
|
|
|
|
* @param module
|
|
|
|
* @param module
|
|
|
|
|
|
|
|
* @param argc standard UNIX count of arguments
|
|
|
|
|
|
|
|
* @param argv standard UNIX vector of arguments
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline void
|
|
|
|
static inline i32
|
|
|
|
module__acquire(struct module *module)
|
|
|
|
module__main(struct module *module, i32 argc, i32 argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
module->reference_count++;
|
|
|
|
return module->main(argc, argv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -171,14 +153,33 @@ module__release(struct module *module)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get a module's argument count
|
|
|
|
* Sets the HTTP Request and Response Headers and Content type on a module
|
|
|
|
* @param module
|
|
|
|
* @param module
|
|
|
|
* @returns the number of arguments
|
|
|
|
* @param request_count
|
|
|
|
|
|
|
|
* @param request_headers
|
|
|
|
|
|
|
|
* @param request_content_type
|
|
|
|
|
|
|
|
* @param response_count
|
|
|
|
|
|
|
|
* @param response_headers
|
|
|
|
|
|
|
|
* @param response_content_type
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline i32
|
|
|
|
static inline void
|
|
|
|
module__get_argument_count(struct module *module)
|
|
|
|
module__set_http_info(struct module *module, int request_count, char *request_headers, char request_content_type[],
|
|
|
|
|
|
|
|
int response_count, char *response_headers, char response_content_type[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return module->argument_count;
|
|
|
|
assert(module);
|
|
|
|
|
|
|
|
module->request_header_count = request_count;
|
|
|
|
|
|
|
|
memcpy(module->request_headers, request_headers, HTTP_HEADER_MAXSZ * HTTP_HEADERS_MAX);
|
|
|
|
|
|
|
|
strcpy(module->request_content_type, request_content_type);
|
|
|
|
|
|
|
|
module->response_header_count = response_count;
|
|
|
|
|
|
|
|
memcpy(module->response_headers, response_headers, HTTP_HEADER_MAXSZ * HTTP_HEADERS_MAX);
|
|
|
|
|
|
|
|
strcpy(module->response_content_type, response_content_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
|
|
|
|
* Public Methods from module.c
|
|
|
|
|
|
|
|
***************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct module *module__new(char *mod_name, char *mod_path, i32 argument_count, u32 stack_sz, u32 max_heap, u32 timeout, int port, int req_sz, int resp_sz);
|
|
|
|
|
|
|
|
void module__free(struct module *module);
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SFRT_MODULE_H */
|
|
|
|
#endif /* SFRT_MODULE_H */
|
|
|
|