mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-24 11:54:49 +00:00
Make mongoose more bare-metal Keil friendly. Declare settings after arch. Introduce MG_ENABLE_FILE
This commit is contained in:
1 parent
9e0f04dc8b
commit
30bfb245f5
13 files changed
+141
-123
No files matched your search
@@ -17,11 +17,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#undef MG_PATH_MAX
|
||||
#undef MG_ENABLE_DIRLIST
|
||||
|
||||
#define MG_DIRSEP '/'
|
||||
#define MG_INT64_FMT "%lld"
|
||||
#define MG_PATH_MAX 128
|
||||
#define MG_ENABLE_DIRLIST 1
|
||||
|
||||
|
||||
@@ -21,11 +21,6 @@
|
||||
|
||||
#include <esp_system.h>
|
||||
|
||||
#undef MG_PATH_MAX
|
||||
#undef MG_ENABLE_DIRLIST
|
||||
|
||||
#define MG_DIRSEP '/'
|
||||
#define MG_INT64_FMT "%lld"
|
||||
#define MG_PATH_MAX 128
|
||||
#define MG_ENABLE_DIRLIST 1
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
#include <FreeRTOS_Sockets.h>
|
||||
#include <task.h>
|
||||
|
||||
#define MG_INT64_FMT "%lld"
|
||||
#define MG_DIRSEP '/'
|
||||
|
||||
// Why FreeRTOS-TCP did not implement a clean BSD API, but its own thing
|
||||
// with FreeRTOS_ prefix, is beyond me
|
||||
#define IPPROTO_TCP FREERTOS_IPPROTO_TCP
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MG_DIRSEP '/'
|
||||
#define MG_INT64_FMT "%" PRId64
|
||||
#undef MG_ENABLE_DIRLIST
|
||||
#define MG_ENABLE_DIRLIST 1
|
||||
|
||||
#endif
|
||||
@@ -68,9 +68,29 @@
|
||||
#endif
|
||||
|
||||
#ifndef MG_PATH_MAX
|
||||
#ifdef PATH_MAX
|
||||
#define MG_PATH_MAX PATH_MAX
|
||||
#else
|
||||
#define MG_PATH_MAX 128
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MG_SOCK_LISTEN_BACKLOG_SIZE
|
||||
#define MG_SOCK_LISTEN_BACKLOG_SIZE 128
|
||||
#endif
|
||||
|
||||
#ifndef MG_DIRSEP
|
||||
#define MG_DIRSEP '/'
|
||||
#endif
|
||||
|
||||
#ifndef MG_INT64_FMT
|
||||
#define MG_INT64_FMT "%lld"
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_FILE
|
||||
#if defined(FOPEN_MAX)
|
||||
#define MG_ENABLE_FILE 1
|
||||
#else
|
||||
#define MG_ENABLE_FILE 0
|
||||
#endif
|
||||
#endif
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
#include "fs.h"
|
||||
|
||||
#if defined(FOPEN_MAX)
|
||||
#if MG_ENABLE_FILE
|
||||
static int p_stat(const char *path, size_t *size, time_t *mtime) {
|
||||
#ifdef _WIN32
|
||||
struct _stati64 st;
|
||||
@@ -176,9 +176,9 @@ static size_t p_write(void *fp, const void *buf, size_t len) {
|
||||
}
|
||||
|
||||
static size_t p_seek(void *fp, size_t offset) {
|
||||
#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || \
|
||||
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
|
||||
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
|
||||
#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || \
|
||||
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
|
||||
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
|
||||
fseeko((FILE *) fp, (off_t) offset, SEEK_SET);
|
||||
#else
|
||||
fseek((FILE *) fp, (long) offset, SEEK_SET);
|
||||
|
||||
@@ -378,6 +378,7 @@ char *mg_http_etag(char *buf, size_t len, size_t size, time_t mtime) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
#if MG_ENABLE_FILE
|
||||
int mg_http_upload(struct mg_connection *c, struct mg_http_message *hm,
|
||||
const char *dir) {
|
||||
char offset[40] = "", name[200] = "", path[256];
|
||||
@@ -403,6 +404,7 @@ int mg_http_upload(struct mg_connection *c, struct mg_http_message *hm,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void static_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
void *fn_data) {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#if MG_ENABLE_LOG
|
||||
static void mg_log_stdout(const void *buf, size_t len, void *userdata) {
|
||||
(void) userdata;
|
||||
#if MG_ENABLE_FILE
|
||||
fwrite(buf, 1, len, stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char *s_spec = "2";
|
||||
|
||||
+4
-2
@@ -6,6 +6,7 @@
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
|
||||
#if MG_ENABLE_FILE
|
||||
char *mg_file_read(const char *path, size_t *sizep) {
|
||||
FILE *fp;
|
||||
char *data = NULL;
|
||||
@@ -47,6 +48,7 @@ bool mg_file_write(const char *path, const void *buf, size_t len) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool mg_file_printf(const char *path, const char *fmt, ...) {
|
||||
char tmp[256], *buf = tmp;
|
||||
@@ -355,8 +357,8 @@ unsigned long mg_millis(void) {
|
||||
uint64_t ticks = mach_absolute_time();
|
||||
static mach_timebase_info_data_t timebase;
|
||||
mach_timebase_info(&timebase);
|
||||
double ticks_to_nanos = (double)timebase.numer / timebase.denom;
|
||||
uint64_t uptime_nanos = (uint64_t)(ticks_to_nanos * ticks);
|
||||
double ticks_to_nanos = (double) timebase.numer / timebase.denom;
|
||||
uint64_t uptime_nanos = (uint64_t) (ticks_to_nanos * ticks);
|
||||
return (unsigned long) (uptime_nanos / 1000000);
|
||||
#else
|
||||
struct timespec ts;
|
||||
|
||||
Reference in new issue
Block a user