39 FILE *file = fopen(resp->
path,
"rb");
41 log_info(
"Failed to access requested file %s with errno %d", resp->
path, errno);
46 fseek(file, 0, SEEK_END);
47 unsigned int size = ftell(file);
48 fseek(file, 0, SEEK_SET);
50 log_warn(
"File larger (%d) than body buffer (%d). Truncating contents.",
56 resp->
body_len = fread(resp->
body,
sizeof(
char), size, file);
77 .
name =
"Webserver_fileio_msu",
int shortest_queue_route(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
Chooses the local MSU with the shortest queue.
struct msu_type WEBSERVER_FILEIO_MSU_TYPE
#define log_info(fmt,...)
Defines a type of MSU, including callback and accessor functions.
struct msu_type WEBSERVER_CACHE_MSU_TYPE
Logging of status messages to the terminal.
char * path_to_mimetype(char *path)
struct msu_type WEBSERVER_WRITE_MSU_TYPE
Declares the methods available for calling an MSU from another MSU.
#define log_error(fmt,...)
Declares the structures and functions applicable to MSUs on the local machine.
The structure that represents an MSU located on the local machine.
static int ws_fileio_load(struct local_msu *self, struct msu_msg *msg)
int call_msu_type(struct local_msu *sender, struct msu_type *dst_type, struct msu_msg_hdr *hdr, size_t data_size, void *data)
Sends an MSU message to a destination of the given type, utilizing the sending MSU's routing function...
int generate_header(char *dest, int code, int capacity, int body_len, char *mime_type)
A message that is to be delivered to an instance of an MSU.
#define WEBSERVER_FILEIO_MSU_TYPE_ID
char * name
Name for the msu type.
#define log_warn(fmt,...)
Declares strategies that MSUs can use for routing to endpoints.