Sagui library v3.5.0
Cross-platform library which helps to develop web servers or frameworks.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
sagui.h File Reference
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  sg_expr_extension
 

Macros

#define SG_ERR_SIZE   256
 
#define sg_httpres_send(res, val, content_type, status)
 
#define sg_httpres_download(res, filename, status)    sg_httpres_sendfile2((res), 0, 0, 0, (filename), "attachment", (status))
 
#define sg_httpres_render(res, filename, status)    sg_httpres_sendfile2((res), 0, 0, 0, (filename), "inline", (status))
 
#define sg_httpres_zsend(res, val, content_type, status)
 
#define sg_httpres_zdownload(res, filename, status)    sg_httpres_zsendfile2((res), 1, 0, 0, 0, (filename), "attachment", (status))
 
#define sg_httpres_zrender(res, filename, status)    sg_httpres_zsendfile2((res), 1, 0, 0, 0, (filename), "inline", (status))
 

Typedefs

typedef void *(* sg_malloc_func) (size_t size)
 
typedef void *(* sg_realloc_func) (void *ptr, size_t size)
 
typedef void(* sg_free_func) (void *ptr)
 
typedef double(* sg_pow_func) (double x, double y)
 
typedef double(* sg_fmod_func) (double x, double y)
 
typedef void(* sg_err_cb) (void *cls, const char *err)
 
typedef ssize_t(* sg_write_cb) (void *handle, uint64_t offset, const char *buf, size_t size)
 
typedef ssize_t(* sg_read_cb) (void *handle, uint64_t offset, char *buf, size_t size)
 
typedef void(* sg_free_cb) (void *handle)
 
typedef int(* sg_save_cb) (void *handle, bool overwritten)
 
typedef int(* sg_save_as_cb) (void *handle, const char *path, bool overwritten)
 
typedef int(* sg_strmap_iter_cb) (void *cls, struct sg_strmap *pair)
 
typedef int(* sg_strmap_sort_cb) (void *cls, struct sg_strmap *pair_a, struct sg_strmap *pair_b)
 
typedef void(* sg_httpsrv_cli_cb) (void *cls, const void *client, bool *closed)
 
typedef bool(* sg_httpauth_cb) (void *cls, struct sg_httpauth *auth, struct sg_httpreq *req, struct sg_httpres *res)
 
typedef int(* sg_httpupld_cb) (void *cls, void **handle, const char *dir, const char *field, const char *name, const char *mime, const char *encoding)
 
typedef int(* sg_httpuplds_iter_cb) (void *cls, struct sg_httpupld *upld)
 
typedef void(* sg_httpreq_cb) (void *cls, struct sg_httpreq *req, struct sg_httpres *res)
 
typedef int(* sg_entrypoints_iter_cb) (void *cls, struct sg_entrypoint *entrypoint)
 
typedef int(* sg_segments_iter_cb) (void *cls, unsigned int index, const char *segment)
 
typedef int(* sg_vars_iter_cb) (void *cls, const char *name, const char *val)
 
typedef void(* sg_route_cb) (void *cls, struct sg_route *route)
 
typedef int(* sg_routes_iter_cb) (void *cls, struct sg_route *route)
 
typedef int(* sg_router_dispatch_cb) (void *cls, const char *path, struct sg_route *route)
 
typedef int(* sg_router_match_cb) (void *cls, struct sg_route *route)
 
typedef double(* sg_expr_func) (void *cls, struct sg_expr_argument *args, const char *identifier)
 

Enumerations

enum  sg_expr_err_type {
  SG_EXPR_ERR_UNKNOWN , SG_EXPR_ERR_UNEXPECTED_NUMBER , SG_EXPR_ERR_UNEXPECTED_WORD , SG_EXPR_ERR_UNEXPECTED_PARENS ,
  SG_EXPR_ERR_MISSING_OPERAND , SG_EXPR_ERR_UNKNOWN_OPERATOR , SG_EXPR_ERR_INVALID_FUNC_NAME , SG_EXPR_ERR_BAD_PARENS ,
  SG_EXPR_ERR_TOO_FEW_FUNC_ARGS , SG_EXPR_ERR_FIRST_ARG_IS_NOT_VAR , SG_EXPR_ERR_BAD_VARIABLE_NAME , SG_EXPR_ERR_BAD_ASSIGNMENT
}
 

Functions

unsigned int sg_version (void)
 
const char * sg_version_str (void)
 
int sg_mm_set (sg_malloc_func malloc_func, sg_realloc_func realloc_func, sg_free_func free_func)
 
void * sg_malloc (size_t size) __attribute__((malloc))
 
void * sg_alloc (size_t size) __attribute__((malloc))
 
void * sg_realloc (void *ptr, size_t size) __attribute__((malloc))
 
void sg_free (void *ptr)
 
int sg_math_set (sg_pow_func pow_func, sg_fmod_func fmod_func)
 
char * sg_strerror (int errnum, char *errmsg, size_t errlen)
 
bool sg_is_post (const char *method)
 
char * sg_extract_entrypoint (const char *path) __attribute__((malloc))
 
char * sg_tmpdir (void) __attribute__((malloc))
 
ssize_t sg_eor (bool err)
 
int sg_ip (const void *socket, char *buf, size_t size)
 
struct sg_strsg_str_new (void) __attribute__((malloc))
 
void sg_str_free (struct sg_str *str)
 
int sg_str_write (struct sg_str *str, const char *val, size_t len)
 
int sg_str_printf_va (struct sg_str *str, const char *fmt, va_list ap)
 
int sg_str_printf (struct sg_str *str, const char *fmt,...) __attribute__((format(printf
 
int const char * sg_str_content (struct sg_str *str)
 
size_t sg_str_length (struct sg_str *str)
 
int sg_str_clear (struct sg_str *str)
 
const char * sg_strmap_name (struct sg_strmap *pair)
 
const char * sg_strmap_val (struct sg_strmap *pair)
 
int sg_strmap_add (struct sg_strmap **map, const char *name, const char *val)
 
int sg_strmap_set (struct sg_strmap **map, const char *name, const char *val)
 
int sg_strmap_find (struct sg_strmap *map, const char *name, struct sg_strmap **pair)
 
const char * sg_strmap_get (struct sg_strmap *map, const char *name)
 
int sg_strmap_rm (struct sg_strmap **map, const char *name)
 
int sg_strmap_iter (struct sg_strmap *map, sg_strmap_iter_cb cb, void *cls)
 
int sg_strmap_sort (struct sg_strmap **map, sg_strmap_sort_cb cb, void *cls)
 
unsigned int sg_strmap_count (struct sg_strmap *map)
 
int sg_strmap_next (struct sg_strmap **next)
 
void sg_strmap_cleanup (struct sg_strmap **map)
 
int sg_httpauth_set_realm (struct sg_httpauth *auth, const char *realm)
 
const char * sg_httpauth_realm (struct sg_httpauth *auth)
 
int sg_httpauth_deny2 (struct sg_httpauth *auth, const char *reason, const char *content_type, unsigned int status)
 
int sg_httpauth_deny (struct sg_httpauth *auth, const char *reason, const char *content_type)
 
int sg_httpauth_cancel (struct sg_httpauth *auth)
 
const char * sg_httpauth_usr (struct sg_httpauth *auth)
 
const char * sg_httpauth_pwd (struct sg_httpauth *auth)
 
int sg_httpuplds_iter (struct sg_httpupld *uplds, sg_httpuplds_iter_cb cb, void *cls)
 
int sg_httpuplds_next (struct sg_httpupld **upld)
 
unsigned int sg_httpuplds_count (struct sg_httpupld *uplds)
 
void * sg_httpupld_handle (struct sg_httpupld *upld)
 
const char * sg_httpupld_dir (struct sg_httpupld *upld)
 
const char * sg_httpupld_field (struct sg_httpupld *upld)
 
const char * sg_httpupld_name (struct sg_httpupld *upld)
 
const char * sg_httpupld_mime (struct sg_httpupld *upld)
 
const char * sg_httpupld_encoding (struct sg_httpupld *upld)
 
uint64_t sg_httpupld_size (struct sg_httpupld *upld)
 
int sg_httpupld_save (struct sg_httpupld *upld, bool overwritten)
 
int sg_httpupld_save_as (struct sg_httpupld *upld, const char *path, bool overwritten)
 
struct sg_httpsrvsg_httpreq_srv (struct sg_httpreq *req)
 
struct sg_strmap ** sg_httpreq_headers (struct sg_httpreq *req)
 
struct sg_strmap ** sg_httpreq_cookies (struct sg_httpreq *req)
 
struct sg_strmap ** sg_httpreq_params (struct sg_httpreq *req)
 
struct sg_strmap ** sg_httpreq_fields (struct sg_httpreq *req)
 
const char * sg_httpreq_version (struct sg_httpreq *req)
 
const char * sg_httpreq_method (struct sg_httpreq *req)
 
const char * sg_httpreq_path (struct sg_httpreq *req)
 
struct sg_strsg_httpreq_payload (struct sg_httpreq *req)
 
bool sg_httpreq_is_uploading (struct sg_httpreq *req)
 
struct sg_httpupldsg_httpreq_uploads (struct sg_httpreq *req)
 
const void * sg_httpreq_client (struct sg_httpreq *req)
 
void * sg_httpreq_tls_session (struct sg_httpreq *req)
 
int sg_httpreq_isolate (struct sg_httpreq *req, sg_httpreq_cb cb, void *cls)
 
int sg_httpreq_set_user_data (struct sg_httpreq *req, void *data)
 
void * sg_httpreq_user_data (struct sg_httpreq *req)
 
struct sg_strmap ** sg_httpres_headers (struct sg_httpres *res)
 
int sg_httpres_set_cookie (struct sg_httpres *res, const char *name, const char *val)
 
int sg_httpres_sendbinary (struct sg_httpres *res, void *buf, size_t size, const char *content_type, unsigned int status)
 
int sg_httpres_sendfile2 (struct sg_httpres *res, uint64_t size, uint64_t max_size, uint64_t offset, const char *filename, const char *disposition, unsigned int status)
 
int sg_httpres_sendfile (struct sg_httpres *res, uint64_t size, uint64_t max_size, uint64_t offset, const char *filename, bool downloaded, unsigned int status)
 
int sg_httpres_sendstream (struct sg_httpres *res, uint64_t size, sg_read_cb read_cb, void *handle, sg_free_cb free_cb, unsigned int status)
 
int sg_httpres_zsendbinary2 (struct sg_httpres *res, int level, void *buf, size_t size, const char *content_type, unsigned int status)
 
int sg_httpres_zsendbinary (struct sg_httpres *res, void *buf, size_t size, const char *content_type, unsigned int status)
 
int sg_httpres_zsendstream2 (struct sg_httpres *res, int level, uint64_t size, sg_read_cb read_cb, void *handle, sg_free_cb free_cb, unsigned int status)
 
int sg_httpres_zsendstream (struct sg_httpres *res, sg_read_cb read_cb, void *handle, sg_free_cb free_cb, unsigned int status)
 
int sg_httpres_zsendfile2 (struct sg_httpres *res, int level, uint64_t size, uint64_t max_size, uint64_t offset, const char *filename, const char *disposition, unsigned int status)
 
int sg_httpres_zsendfile (struct sg_httpres *res, uint64_t size, uint64_t max_size, uint64_t offset, const char *filename, bool downloaded, unsigned int status)
 
int sg_httpres_reset (struct sg_httpres *res)
 
int sg_httpres_clear (struct sg_httpres *res)
 
bool sg_httpres_is_empty (struct sg_httpres *res)
 
struct sg_httpsrvsg_httpsrv_new2 (sg_httpauth_cb auth_cb, sg_httpreq_cb req_cb, sg_err_cb err_cb, void *cls) __attribute__((malloc))
 
struct sg_httpsrvsg_httpsrv_new (sg_httpreq_cb cb, void *cls) __attribute__((malloc))
 
void sg_httpsrv_free (struct sg_httpsrv *srv)
 
bool sg_httpsrv_tls_listen4 (struct sg_httpsrv *srv, const char *key, const char *pwd, const char *cert, const char *trust, const char *dhparams, const char *priorities, const char *hostname, uint16_t port, uint32_t backlog, bool threaded)
 
bool sg_httpsrv_tls_listen3 (struct sg_httpsrv *srv, const char *key, const char *pwd, const char *cert, const char *trust, const char *dhparams, const char *priorities, uint16_t port, bool threaded)
 
bool sg_httpsrv_tls_listen2 (struct sg_httpsrv *srv, const char *key, const char *pwd, const char *cert, const char *trust, const char *dhparams, uint16_t port, bool threaded)
 
bool sg_httpsrv_tls_listen (struct sg_httpsrv *srv, const char *key, const char *cert, uint16_t port, bool threaded)
 
bool sg_httpsrv_listen2 (struct sg_httpsrv *srv, const char *hostname, uint16_t port, uint32_t backlog, bool threaded)
 
bool sg_httpsrv_listen (struct sg_httpsrv *srv, uint16_t port, bool threaded)
 
int sg_httpsrv_shutdown (struct sg_httpsrv *srv)
 
uint16_t sg_httpsrv_port (struct sg_httpsrv *srv)
 
bool sg_httpsrv_is_threaded (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_cli_cb (struct sg_httpsrv *srv, sg_httpsrv_cli_cb cb, void *cls)
 
int sg_httpsrv_set_upld_cbs (struct sg_httpsrv *srv, sg_httpupld_cb cb, void *cls, sg_write_cb write_cb, sg_free_cb free_cb, sg_save_cb save_cb, sg_save_as_cb save_as_cb)
 
int sg_httpsrv_set_upld_dir (struct sg_httpsrv *srv, const char *dir)
 
const char * sg_httpsrv_upld_dir (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_post_buf_size (struct sg_httpsrv *srv, size_t size)
 
size_t sg_httpsrv_post_buf_size (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_payld_limit (struct sg_httpsrv *srv, size_t limit)
 
size_t sg_httpsrv_payld_limit (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_uplds_limit (struct sg_httpsrv *srv, uint64_t limit)
 
uint64_t sg_httpsrv_uplds_limit (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_thr_pool_size (struct sg_httpsrv *srv, unsigned int size)
 
unsigned int sg_httpsrv_thr_pool_size (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_con_timeout (struct sg_httpsrv *srv, unsigned int timeout)
 
unsigned int sg_httpsrv_con_timeout (struct sg_httpsrv *srv)
 
int sg_httpsrv_set_con_limit (struct sg_httpsrv *srv, unsigned int limit)
 
unsigned int sg_httpsrv_con_limit (struct sg_httpsrv *srv)
 
void * sg_httpsrv_handle (struct sg_httpsrv *srv)
 
const char * sg_entrypoint_name (struct sg_entrypoint *entrypoint)
 
int sg_entrypoint_set_user_data (struct sg_entrypoint *entrypoint, void *data)
 
void * sg_entrypoint_user_data (struct sg_entrypoint *entrypoint)
 
struct sg_entrypointssg_entrypoints_new (void) __attribute__((malloc))
 
void sg_entrypoints_free (struct sg_entrypoints *entrypoints)
 
int sg_entrypoints_add (struct sg_entrypoints *entrypoints, const char *path, void *user_data)
 
int sg_entrypoints_rm (struct sg_entrypoints *entrypoints, const char *path)
 
int sg_entrypoints_iter (struct sg_entrypoints *entrypoints, sg_entrypoints_iter_cb cb, void *cls)
 
int sg_entrypoints_clear (struct sg_entrypoints *entrypoints)
 
int sg_entrypoints_find (struct sg_entrypoints *entrypoints, struct sg_entrypoint **entrypoint, const char *path)
 
void * sg_route_handle (struct sg_route *route)
 
void * sg_route_match (struct sg_route *route)
 
const char * sg_route_rawpattern (struct sg_route *route)
 
char * sg_route_pattern (struct sg_route *route) __attribute__((malloc))
 
const char * sg_route_path (struct sg_route *route)
 
int sg_route_segments_iter (struct sg_route *route, sg_segments_iter_cb cb, void *cls)
 
int sg_route_vars_iter (struct sg_route *route, sg_vars_iter_cb cb, void *cls)
 
void * sg_route_user_data (struct sg_route *route)
 
int sg_routes_add2 (struct sg_route **routes, struct sg_route **route, const char *pattern, char *errmsg, size_t errlen, sg_route_cb cb, void *cls)
 
bool sg_routes_add (struct sg_route **routes, const char *pattern, sg_route_cb cb, void *cls)
 
int sg_routes_rm (struct sg_route **routes, const char *pattern)
 
int sg_routes_iter (struct sg_route *routes, sg_routes_iter_cb cb, void *cls)
 
int sg_routes_next (struct sg_route **route)
 
unsigned int sg_routes_count (struct sg_route *routes)
 
int sg_routes_cleanup (struct sg_route **routes)
 
struct sg_routersg_router_new (struct sg_route *routes) __attribute__((malloc))
 
void sg_router_free (struct sg_router *router)
 
int sg_router_dispatch2 (struct sg_router *router, const char *path, void *user_data, sg_router_dispatch_cb dispatch_cb, void *cls, sg_router_match_cb match_cb)
 
int sg_router_dispatch (struct sg_router *router, const char *path, void *user_data)
 
struct sg_exprsg_expr_new (void) __attribute__((malloc))
 
void sg_expr_free (struct sg_expr *expr)
 
int sg_expr_compile (struct sg_expr *expr, const char *str, size_t len, struct sg_expr_extension *extensions)
 
int sg_expr_clear (struct sg_expr *expr)
 
double sg_expr_eval (struct sg_expr *expr)
 
double sg_expr_var (struct sg_expr *expr, const char *name, size_t len)
 
int sg_expr_set_var (struct sg_expr *expr, const char *name, size_t len, double val)
 
double sg_expr_arg (struct sg_expr_argument *args, int index)
 
int sg_expr_near (struct sg_expr *expr)
 
enum sg_expr_err_type sg_expr_err (struct sg_expr *expr)
 
const char * sg_expr_strerror (struct sg_expr *expr)
 
double sg_expr_calc (const char *str, size_t len)
 

Macro Definition Documentation

◆ SG_ERR_SIZE

#define SG_ERR_SIZE   256