Store certs in certs/. Add mg_unpacked()

This commit is contained in:
cpq committed 2023-08-20 23:43:04 +01:00
1 parent 1e0d57a832
commit b32d1c15f0
11 files changed
+2512 -2090

No files matched your search

+5
View File
@@ -40,3 +40,8 @@ void mg_fs_close(struct mg_fd *fd);
char *mg_file_read(struct mg_fs *fs, const char *path, size_t *size);
bool mg_file_write(struct mg_fs *fs, const char *path, const void *, size_t);
bool mg_file_printf(struct mg_fs *fs, const char *path, const char *fmt, ...);
// Packed API
const char *mg_unpack(const char *path, size_t *size, time_t *mtime);
const char *mg_unlist(size_t no); // Get no'th packed filename
struct mg_str mg_unpacked(const char *path); // Packed file as mg_str
+8 -4
View File
@@ -8,13 +8,11 @@ struct packed_file {
size_t pos;
};
const char *mg_unpack(const char *path, size_t *size, time_t *mtime);
const char *mg_unlist(size_t no);
#if MG_ENABLE_PACKED_FS
#else
const char *mg_unpack(const char *path, size_t *size, time_t *mtime) {
(void) path, (void) size, (void) mtime;
*size = 0, *mtime = 0;
(void) path;
return NULL;
}
const char *mg_unlist(size_t no) {
@@ -23,6 +21,12 @@ const char *mg_unlist(size_t no) {
}
#endif
struct mg_str mg_unpacked(const char *path) {
size_t len = 0;
const char *buf = mg_unpack(path, &len, NULL);
return mg_str_n(buf, len);
}
static int is_dir_prefix(const char *prefix, size_t n, const char *path) {
// MG_INFO(("[%.*s] [%s] %c", (int) n, prefix, path, path[n]));
return n < strlen(path) && strncmp(prefix, path, n) == 0 &&