@ -3,10 +3,11 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct option {
|
||||
const char *name;
|
||||
char *value;
|
||||
bool required;
|
||||
typedef struct {
|
||||
#define OPT_NAME_MAX 20
|
||||
char name[20]; // option name
|
||||
char *value; // option value
|
||||
bool required; // is the option required (does it need to have a value)
|
||||
} option_t;
|
||||
|
||||
typedef struct config {
|
||||
@ -14,5 +15,5 @@ typedef struct config {
|
||||
int32_t count;
|
||||
} config_t;
|
||||
|
||||
int32_t config_load(config_t *conf);
|
||||
char *config_get(config_t *conf, const char *name);
|
||||
bool config_load(config_t *conf);
|
||||
char *config_get(config_t *conf, const char *name);
|
||||
|
@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
#include <ctorm/all.h>
|
||||
#include <ctorm/ctorm.h>
|
||||
|
||||
void GET_read(req_t *req, res_t *res);
|
||||
void route_cors(ctorm_req_t *req, ctorm_res_t *res);
|
||||
void route_list(ctorm_req_t *req, ctorm_res_t *res);
|
||||
void route_get(ctorm_req_t *req, ctorm_res_t *res);
|
||||
void route_notfound(ctorm_req_t *req, ctorm_res_t *res);
|
||||
|
23
doc/inc/util.h
Normal file
23
doc/inc/util.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include <ctorm/ctorm.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <ctype.h>
|
||||
|
||||
typedef struct {
|
||||
char *content;
|
||||
uint64_t size;
|
||||
} util_file_t;
|
||||
|
||||
#define util_compare_name(n1, n2) (strncmp(n1, n2, NAME_MAX) == 0)
|
||||
#define util_toupper(str) \
|
||||
for (char *c = str; *c != 0; c++) \
|
||||
*c = toupper(*c)
|
||||
#define util_tolower(str) \
|
||||
for (char *c = str; *c != 0; c++) \
|
||||
*c = tolower(*c)
|
||||
uint64_t util_endswith(char *str, char *suf);
|
||||
void util_send(ctorm_res_t *res, uint16_t code, cJSON *json);
|
||||
bool util_dir_contains(char *dir, const char *file);
|
||||
util_file_t *util_file_load(char *path);
|
||||
void util_file_free(util_file_t *file);
|
Reference in New Issue
Block a user