Ulfius
HTTP Framework for REST Applications in C
Macros | Functions
ulfius.c File Reference
#include <u_private.h>
#include <ulfius.h>
#include <curl/curl.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for ulfius.c:

Macros

#define MHD_CREATE_RESPONSE_FROM_BUFFER_PIMPED(len, buf, flag)   MHD_create_response_from_buffer((len), (buf), (flag))
 

Functions

void * ulfius_uri_logger (void *cls, const char *uri)
 
void mhd_redirect_log (void *arg, const char *fmt, va_list ap)
 
void mhd_request_completed (void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
 
int ulfius_start_framework (struct _u_instance *u_instance)
 
int ulfius_start_secure_framework (struct _u_instance *u_instance, const char *key_pem, const char *cert_pem)
 
int ulfius_start_secure_ca_trust_framework (struct _u_instance *u_instance, const char *key_pem, const char *cert_pem, const char *root_ca_pem)
 
int ulfius_start_framework_with_mhd_options (struct _u_instance *u_instance, unsigned int mhd_flags, struct MHD_OptionItem *mhd_ops)
 
int ulfius_stop_framework (struct _u_instance *u_instance)
 
int ulfius_copy_endpoint (struct _u_endpoint *dest, const struct _u_endpoint *source)
 
struct _u_endpointulfius_duplicate_endpoint_list (const struct _u_endpoint *endpoint_list)
 
void ulfius_clean_endpoint (struct _u_endpoint *endpoint)
 
void ulfius_clean_endpoint_list (struct _u_endpoint *endpoint_list)
 
int ulfius_add_endpoint (struct _u_instance *u_instance, const struct _u_endpoint *u_endpoint)
 
int ulfius_add_endpoint_list (struct _u_instance *u_instance, const struct _u_endpoint **u_endpoint_list)
 
int ulfius_remove_endpoint (struct _u_instance *u_instance, const struct _u_endpoint *u_endpoint)
 
const struct _u_endpointulfius_empty_endpoint (void)
 
int ulfius_equals_endpoints (const struct _u_endpoint *endpoint1, const struct _u_endpoint *endpoint2)
 
int ulfius_add_endpoint_by_val (struct _u_instance *u_instance, const char *http_method, const char *url_prefix, const char *url_format, unsigned int priority, int(*callback_function)(const struct _u_request *request, struct _u_response *response, void *user_data), void *user_data)
 
int ulfius_remove_endpoint_by_val (struct _u_instance *u_instance, const char *http_method, const char *url_prefix, const char *url_format)
 
int ulfius_set_default_endpoint (struct _u_instance *u_instance, int(*callback_function)(const struct _u_request *request, struct _u_response *response, void *user_data), void *user_data)
 
int ulfius_set_upload_file_callback_function (struct _u_instance *u_instance, int(*file_upload_callback)(const struct _u_request *request, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size, void *cls), void *cls)
 
void ulfius_clean_instance (struct _u_instance *u_instance)
 
int ulfius_init_instance (struct _u_instance *u_instance, unsigned int port, struct sockaddr_in *bind_address, const char *default_auth_realm)
 
void u_free (void *data)
 
const unsigned char * utf8_check (const char *s_orig, size_t len)
 
char * ulfius_url_encode (const char *str)
 
char * ulfius_url_decode (const char *str)
 
int ulfius_global_init (void)
 
void ulfius_global_close (void)
 

Macro Definition Documentation

◆ MHD_CREATE_RESPONSE_FROM_BUFFER_PIMPED

#define MHD_CREATE_RESPONSE_FROM_BUFFER_PIMPED (   len,
  buf,
  flag 
)    MHD_create_response_from_buffer((len), (buf), (flag))

Function Documentation

◆ mhd_redirect_log()

void mhd_redirect_log ( void *  arg,
const char *  fmt,
va_list  ap 
)

◆ utf8_check()

const unsigned char* utf8_check ( const char *  s_orig,
size_t  len 
)

The utf8_check() function scans the string starting at s. It returns a pointer to the first byte of the first malformed or overlong UTF-8 sequence found, or NULL if the string contains only correct UTF-8. It also spots UTF-8 sequences that could cause trouble if converted to UTF-16, namely surrogate characters (U+D800..U+DFFF) and non-Unicode positions (U+FFFE..U+FFFF). This routine is very likely to find a malformed sequence if the input uses any other encoding than UTF-8. It therefore can be used as a very effective heuristic for distinguishing between UTF-8 and other encodings.

I wrote this code mainly as a specification of functionality; there are no doubt performance optimizations possible for certain CPUs.

Markus Kuhn http://www.cl.cam.ac.uk/~mgk25/ – 2005-03-30 Nicolas Mora mail@.nosp@m.babe.nosp@m.loues.nosp@m.t.or.nosp@m.g License: http://www.cl.cam.ac.uk/~mgk25/short-license.html