update doc server to ctorm 1.8.1

Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
ngn
2025-05-22 20:12:05 +03:00
parent a9d2633107
commit 912bf616b6
29 changed files with 178 additions and 122 deletions

View File

@ -3,13 +3,13 @@
#include <stdbool.h>
#include <dirent.h>
#include "util.h"
#include "file.h"
typedef struct {
DIR *dir;
util_file_t *file;
char name[NAME_MAX + 1];
char *lang;
DIR *dir;
file_t *file;
char name[NAME_MAX + 1];
char *lang;
} docs_t;
bool docs_init(docs_t *docs, char *dir);

10
doc/inc/file.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include <stdint.h>
typedef struct {
char *content;
int64_t size;
} file_t;
file_t *file_load(int dirfd, char *path);
void file_free(file_t *file);

View File

@ -4,16 +4,8 @@
#include <stdint.h>
#include <ctype.h>
typedef struct {
char *content;
uint64_t size;
} util_file_t;
#define util_toupper(str) \
for (char *c = str; *c != 0; c++) \
#define util_toupper(str) \
for (char *c = str; *c != 0; c++) \
*c = toupper(*c)
uint64_t util_endswith(char *str, char *suf);
void util_send(ctorm_res_t *res, uint16_t code, cJSON *json);
util_file_t *util_file_load(int dirfd, char *path);
void util_file_free(util_file_t *file);
bool util_parse_doc_name(char *name, char **lang, const char *ext);
uint64_t util_endswith(char *str, char *suf);
void util_send(ctorm_res_t *res, uint16_t code, cJSON *json);