#pragma once #include #include #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif struct PHYSFS_Stat; struct physfs_serve { int fd[16], nfds; const char* (*content_type)(struct physfs_serve *serve, const char *path); bool (*path_rewrite)(struct physfs_serve *serve, char buf[], const size_t bufsz, struct PHYSFS_Stat *st); }; bool physfs_serve_init(struct physfs_serve *serve, const unsigned int port, const char *addr); bool physfs_serve_event(struct physfs_serve *serve, const int index); void physfs_serve_free(struct physfs_serve *serve); const char* physfs_default_content_type(struct physfs_serve *serve, const char *path); bool physfs_default_path_rewrite(struct physfs_serve *serve, char buf[], const size_t bufsz, struct PHYSFS_Stat *st); bool physfs_ends_with(const char *str, const char *suf); inline void physfs_append(char buf[], const size_t bufsz, const char *str);