mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-23 20:11:49 +00:00
Commonize mg_str
PUBLISHED_FROM=0e6a1c1a2356c1e12580e498c64ba7be367f601c
This commit is contained in:
1 parent
29b3950ee7
commit
c907e6c5fb
9 files changed
+82
-113
No files matched your search
+47
-28
@@ -841,6 +841,53 @@ double cs_time();
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* CS_COMMON_CS_TIME_H_ */
|
||||
/*
|
||||
* Copyright (c) 2014-2016 Cesanta Software Limited
|
||||
* All rights reserved
|
||||
*/
|
||||
|
||||
#ifndef CS_COMMON_MG_STR_H_
|
||||
#define CS_COMMON_MG_STR_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Describes chunk of memory */
|
||||
struct mg_str {
|
||||
const char *p; /* Memory chunk pointer */
|
||||
size_t len; /* Memory chunk length */
|
||||
};
|
||||
|
||||
/*
|
||||
* A helper function for creating mg_str struct from plain C string.
|
||||
* `NULL` is allowed and becomes `{NULL, 0}`.
|
||||
*/
|
||||
struct mg_str mg_mk_str(const char *s);
|
||||
|
||||
/* Macro for initializing mg_str. */
|
||||
#define MG_MK_STR(str_literal) \
|
||||
{ str_literal, sizeof(str_literal) - 1 }
|
||||
|
||||
/*
|
||||
* Cross-platform version of `strcmp()` where where first string is
|
||||
* specified by `struct mg_str`.
|
||||
*/
|
||||
int mg_vcmp(const struct mg_str *str2, const char *str1);
|
||||
|
||||
/*
|
||||
* Cross-platform version of `strncasecmp()` where first string is
|
||||
* specified by `struct mg_str`.
|
||||
*/
|
||||
int mg_vcasecmp(const struct mg_str *str2, const char *str1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* CS_COMMON_MG_STR_H_ */
|
||||
/*
|
||||
* Copyright (c) 2015 Cesanta Software Limited
|
||||
* All rights reserved
|
||||
@@ -1140,12 +1187,6 @@ union socket_address {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Describes chunk of memory */
|
||||
struct mg_str {
|
||||
const char *p; /* Memory chunk pointer */
|
||||
size_t len; /* Memory chunk length */
|
||||
};
|
||||
|
||||
struct mg_connection;
|
||||
|
||||
/*
|
||||
@@ -1793,18 +1834,6 @@ int mg_ncasecmp(const char *s1, const char *s2, size_t len);
|
||||
*/
|
||||
int mg_casecmp(const char *s1, const char *s2);
|
||||
|
||||
/*
|
||||
* Cross-platform version of `strcmp()` where where first string is
|
||||
* specified by `struct mg_str`.
|
||||
*/
|
||||
int mg_vcmp(const struct mg_str *str2, const char *str1);
|
||||
|
||||
/*
|
||||
* Cross-platform version of `strncasecmp()` where first string is
|
||||
* specified by `struct mg_str`.
|
||||
*/
|
||||
int mg_vcasecmp(const struct mg_str *str2, const char *str1);
|
||||
|
||||
/*
|
||||
* Decode base64-encoded string `s`, `len` into the destination `dst`.
|
||||
* Destination has to have enough space to hold decoded buffer.
|
||||
@@ -1963,16 +1992,6 @@ const char *mg_next_comma_list_entry(const char *list, struct mg_str *val,
|
||||
int mg_match_prefix(const char *pattern, int pattern_len, const char *str);
|
||||
int mg_match_prefix_n(const struct mg_str pattern, const struct mg_str str);
|
||||
|
||||
/*
|
||||
* A helper function for creating mg_str struct from plain C string.
|
||||
* `NULL` is allowed and becomes `{NULL, 0}`.
|
||||
*/
|
||||
struct mg_str mg_mk_str(const char *s);
|
||||
|
||||
/* Macro for initializing mg_str. */
|
||||
#define MG_MK_STR(str_literal) \
|
||||
{ str_literal, sizeof(str_literal) - 1 }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in new issue
Block a user