mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
Merging rust bindings from lurchi, thxaloz!
This commit is contained in:
commit
8b2d725514
24 changed files with 1406 additions and 54 deletions
|
@ -77,7 +77,7 @@ psyc_map_lookup (const PsycMap *map, size_t size,
|
|||
* Look up value associated with a key in a map with integer values.
|
||||
* @see psyc_map_lookup
|
||||
*/
|
||||
static inline intptr_t
|
||||
inline intptr_t
|
||||
psyc_map_lookup_int (const PsycMapInt *map, size_t size,
|
||||
const char *key, size_t keylen, PsycBool inherit)
|
||||
{
|
||||
|
|
|
@ -253,7 +253,7 @@ typedef struct {
|
|||
/**
|
||||
* Return the number of digits a number has in its base 10 representation.
|
||||
*/
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_num_length (size_t n)
|
||||
{
|
||||
return n < 10 ? 1 : log10(n) + 1;
|
||||
|
@ -263,7 +263,7 @@ psyc_num_length (size_t n)
|
|||
* \internal
|
||||
* Check if a modifier needs length.
|
||||
*/
|
||||
static inline PsycModifierFlag
|
||||
inline PsycModifierFlag
|
||||
psyc_modifier_length_check (PsycModifier *m)
|
||||
{
|
||||
if (m->value.length > 0
|
||||
|
@ -275,7 +275,7 @@ psyc_modifier_length_check (PsycModifier *m)
|
|||
}
|
||||
|
||||
/** Initialize modifier */
|
||||
static inline void
|
||||
inline void
|
||||
psyc_modifier_init (PsycModifier *m, PsycOperator oper,
|
||||
char *name, size_t namelen,
|
||||
char *value, size_t valuelen, PsycModifierFlag flag)
|
||||
|
|
|
@ -510,7 +510,7 @@ typedef struct {
|
|||
* @param flags Flags to be set for the parser, see PsycParseFlag.
|
||||
* @see PsycParseFlag
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_state_init (PsycParseState *state, uint8_t flags)
|
||||
{
|
||||
memset(state, 0, sizeof(PsycParseState));
|
||||
|
@ -531,7 +531,7 @@ psyc_parse_state_init (PsycParseState *state, uint8_t flags)
|
|||
* @param length length of the data in bytes
|
||||
* @see PsycString
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_buffer_set (PsycParseState *state, const char *buffer, size_t length)
|
||||
{
|
||||
state->buffer = (PsycString) {length, (char*)buffer};
|
||||
|
@ -546,7 +546,7 @@ psyc_parse_buffer_set (PsycParseState *state, const char *buffer, size_t length)
|
|||
/**
|
||||
* Initializes the list parser state.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_list_state_init (PsycParseListState *state)
|
||||
{
|
||||
memset(state, 0, sizeof(PsycParseListState));
|
||||
|
@ -555,7 +555,7 @@ psyc_parse_list_state_init (PsycParseListState *state)
|
|||
/**
|
||||
* Sets a new buffer in the list parser state struct with data to be parsed.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_list_buffer_set (PsycParseListState *state,
|
||||
const char *buffer, size_t length)
|
||||
{
|
||||
|
@ -566,7 +566,7 @@ psyc_parse_list_buffer_set (PsycParseListState *state,
|
|||
/**
|
||||
* Initializes the dict parser state.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_dict_state_init (PsycParseDictState *state)
|
||||
{
|
||||
memset(state, 0, sizeof(PsycParseDictState));
|
||||
|
@ -575,7 +575,7 @@ psyc_parse_dict_state_init (PsycParseDictState *state)
|
|||
/**
|
||||
* Sets a new buffer in the dict parser state struct with data to be parsed.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_dict_buffer_set (PsycParseDictState *state,
|
||||
const char *buffer, size_t length)
|
||||
{
|
||||
|
@ -586,7 +586,7 @@ psyc_parse_dict_buffer_set (PsycParseDictState *state,
|
|||
/**
|
||||
* Initializes the index parser state.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_index_state_init (PsycParseIndexState *state)
|
||||
{
|
||||
memset(state, 0, sizeof(PsycParseIndexState));
|
||||
|
@ -595,7 +595,7 @@ psyc_parse_index_state_init (PsycParseIndexState *state)
|
|||
/**
|
||||
* Sets a new buffer in the index parser state struct with data to be parsed.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_index_buffer_set (PsycParseIndexState *state,
|
||||
const char *buffer, size_t length)
|
||||
{
|
||||
|
@ -606,7 +606,7 @@ psyc_parse_index_buffer_set (PsycParseIndexState *state,
|
|||
/**
|
||||
* Initializes the update modifier parser state.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_update_state_init (PsycParseUpdateState *state)
|
||||
{
|
||||
memset(state, 0, sizeof(PsycParseUpdateState));
|
||||
|
@ -615,7 +615,7 @@ psyc_parse_update_state_init (PsycParseUpdateState *state)
|
|||
/**
|
||||
* Sets a new buffer in the update modifier parser state struct with data to be parsed.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_parse_update_buffer_set (PsycParseUpdateState *state,
|
||||
const char *buffer, size_t length)
|
||||
{
|
||||
|
@ -623,49 +623,49 @@ psyc_parse_update_buffer_set (PsycParseUpdateState *state,
|
|||
state->cursor = 0;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_content_length (PsycParseState *state)
|
||||
{
|
||||
return state->contentlen;
|
||||
}
|
||||
|
||||
static inline PsycBool
|
||||
inline PsycBool
|
||||
psyc_parse_content_length_found (PsycParseState *state)
|
||||
{
|
||||
return (PsycBool) state->contentlen_found;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_value_length (PsycParseState *state)
|
||||
{
|
||||
return state->valuelen;
|
||||
}
|
||||
|
||||
static inline PsycBool
|
||||
inline PsycBool
|
||||
psyc_parse_value_length_found (PsycParseState *state)
|
||||
{
|
||||
return (PsycBool) state->valuelen_found;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_cursor (PsycParseState *state)
|
||||
{
|
||||
return state->cursor;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_buffer_length (PsycParseState *state)
|
||||
{
|
||||
return state->buffer.length;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_remaining_length (PsycParseState *state)
|
||||
{
|
||||
return state->buffer.length - state->cursor;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
inline const char *
|
||||
psyc_parse_remaining_buffer (PsycParseState *state)
|
||||
{
|
||||
return state->buffer.data + state->cursor;
|
||||
|
@ -688,7 +688,7 @@ psyc_parse_remaining_buffer (PsycParseState *state)
|
|||
* in case of the body it will point to the data.
|
||||
*/
|
||||
#ifdef __INLINE_PSYC_PARSE
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycParseRC
|
||||
psyc_parse (PsycParseState *state, char *oper,
|
||||
|
@ -706,30 +706,30 @@ psyc_parse (PsycParseState *state, char *oper,
|
|||
* @param elem It will point to the next element in the list.
|
||||
*/
|
||||
#ifdef __INLINE_PSYC_PARSE
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycParseListRC
|
||||
psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem);
|
||||
|
||||
#ifdef __INLINE_PSYC_PARSE
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycParseDictRC
|
||||
psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem);
|
||||
|
||||
#ifdef __INLINE_PSYC_PARSE
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycParseIndexRC
|
||||
psyc_parse_index (PsycParseIndexState *state, PsycString *idx);
|
||||
|
||||
#ifdef __INLINE_PSYC_PARSE
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycParseUpdateRC
|
||||
psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value);
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_int (const char *value, size_t len, int64_t *n)
|
||||
{
|
||||
size_t c = 0;
|
||||
|
@ -754,7 +754,7 @@ psyc_parse_int (const char *value, size_t len, int64_t *n)
|
|||
return c;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_uint (const char *value, size_t len, uint64_t *n)
|
||||
{
|
||||
size_t c = 0;
|
||||
|
@ -768,7 +768,7 @@ psyc_parse_uint (const char *value, size_t len, uint64_t *n)
|
|||
return c;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_list_index (const char *value, size_t len, int64_t *n)
|
||||
{
|
||||
if (!value || len == 0 || value[0] != '#')
|
||||
|
@ -780,7 +780,7 @@ psyc_parse_list_index (const char *value, size_t len, int64_t *n)
|
|||
* Determines if the argument is a glyph.
|
||||
* Glyphs are: : = + - ? !
|
||||
*/
|
||||
static inline PsycBool
|
||||
inline PsycBool
|
||||
psyc_is_oper (char g)
|
||||
{
|
||||
switch (g) {
|
||||
|
@ -800,7 +800,7 @@ psyc_is_oper (char g)
|
|||
/**
|
||||
* Determines if the argument is numeric.
|
||||
*/
|
||||
static inline char
|
||||
inline char
|
||||
psyc_is_numeric (char c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
|
@ -809,7 +809,7 @@ psyc_is_numeric (char c)
|
|||
/**
|
||||
* Determines if the argument is alphabetic.
|
||||
*/
|
||||
static inline char
|
||||
inline char
|
||||
psyc_is_alpha (char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
|
@ -818,7 +818,7 @@ psyc_is_alpha (char c)
|
|||
/**
|
||||
* Determines if the argument is alphanumeric.
|
||||
*/
|
||||
static inline char
|
||||
inline char
|
||||
psyc_is_alpha_numeric (char c)
|
||||
{
|
||||
return psyc_is_alpha(c) || psyc_is_numeric(c);
|
||||
|
@ -828,7 +828,7 @@ psyc_is_alpha_numeric (char c)
|
|||
* Determines if the argument is a keyword character.
|
||||
* Keyword characters are: alphanumeric and _
|
||||
*/
|
||||
static inline char
|
||||
inline char
|
||||
psyc_is_kw_char (char c)
|
||||
{
|
||||
return psyc_is_alpha_numeric(c) || c == '_';
|
||||
|
@ -838,7 +838,7 @@ psyc_is_kw_char (char c)
|
|||
* Determines if the argument is a name character.
|
||||
* Name characters are: see opaque_part in RFC 2396
|
||||
*/
|
||||
static inline char
|
||||
inline char
|
||||
psyc_is_name_char (char c)
|
||||
{
|
||||
return psyc_is_alpha(c) || (c >= '$' && c <= ';')
|
||||
|
@ -849,7 +849,7 @@ psyc_is_name_char (char c)
|
|||
* Determines if the argument is a hostname character.
|
||||
* Hostname characters are: alphanumeric and -
|
||||
*/
|
||||
static inline char
|
||||
inline char
|
||||
psyc_is_host_char (char c)
|
||||
{
|
||||
return psyc_is_alpha_numeric(c) || c == '.' || c == '-';
|
||||
|
@ -860,7 +860,7 @@ psyc_is_host_char (char c)
|
|||
* It should contain one or more keyword characters.
|
||||
* @return Number of characters parsed.
|
||||
*/
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_parse_keyword (const char *data, size_t len)
|
||||
{
|
||||
size_t c = 0;
|
||||
|
|
|
@ -66,7 +66,7 @@ typedef enum {
|
|||
* @see psyc_packet_length_set()
|
||||
*/
|
||||
#ifdef __INLINE_PSYC_RENDER
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycRenderRC
|
||||
psyc_render (PsycPacket *packet, char *buffer, size_t buflen);
|
||||
|
@ -84,7 +84,7 @@ psyc_render_dict_key (PsycDictKey *elem, char *buffer, size_t buflen);
|
|||
* Render a PSYC list into a buffer.
|
||||
*/
|
||||
#ifdef __INLINE_PSYC_RENDER
|
||||
static inline
|
||||
inline
|
||||
#endif
|
||||
PsycRenderRC
|
||||
psyc_render_list (PsycList *list, char *buffer, size_t buflen);
|
||||
|
|
|
@ -94,7 +94,7 @@ typedef PsycTextValueRC (*PsycTextCB) (void *cls, const char *name, size_t namel
|
|||
* @param buffer Output buffer where the rendered text is going to be written.
|
||||
* @param buflen Length of output buffer.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_text_state_init (PsycTextState *state,
|
||||
char *tmpl, size_t tmplen,
|
||||
char *buffer, size_t buflen)
|
||||
|
@ -120,7 +120,7 @@ psyc_text_state_init (PsycTextState *state,
|
|||
* @param clo Closing brace.
|
||||
* @param clolen Length of closing brace.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_text_state_init_custom (PsycTextState *state,
|
||||
char *tmpl, size_t tmplen,
|
||||
char *buffer, size_t buflen,
|
||||
|
@ -138,7 +138,7 @@ psyc_text_state_init_custom (PsycTextState *state,
|
|||
/**
|
||||
* Sets a new output buffer in the PSYC text state struct.
|
||||
*/
|
||||
static inline void
|
||||
inline void
|
||||
psyc_text_buffer_set (PsycTextState *state, char *buffer, size_t length)
|
||||
{
|
||||
state->buffer = (PsycString) {
|
||||
|
@ -146,7 +146,7 @@ psyc_text_buffer_set (PsycTextState *state, char *buffer, size_t length)
|
|||
state->written = 0;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
inline size_t
|
||||
psyc_text_bytes_written (PsycTextState *state)
|
||||
{
|
||||
return state->written;
|
||||
|
|
|
@ -117,7 +117,7 @@ psyc_uniform_parse (PsycUniform *uni, const char *buffer, size_t length);
|
|||
*
|
||||
* @return PsycEntityType on success, PSYC_ERROR on error.
|
||||
*/
|
||||
static inline int
|
||||
inline int
|
||||
psyc_entity_type (char entity)
|
||||
{
|
||||
switch (entity) {
|
||||
|
|
|
@ -88,7 +88,7 @@ typedef enum {
|
|||
/**
|
||||
* Look up routing variable.
|
||||
*/
|
||||
static inline PsycRoutingVar
|
||||
inline PsycRoutingVar
|
||||
psyc_var_routing (const char *name, size_t len)
|
||||
{
|
||||
return (PsycRoutingVar)
|
||||
|
@ -99,7 +99,7 @@ psyc_var_routing (const char *name, size_t len)
|
|||
/**
|
||||
* Get the type of variable name.
|
||||
*/
|
||||
static inline PsycType
|
||||
inline PsycType
|
||||
psyc_var_type (const char *name, size_t len)
|
||||
{
|
||||
return (PsycType)
|
||||
|
@ -110,7 +110,7 @@ psyc_var_type (const char *name, size_t len)
|
|||
/**
|
||||
* Is this a list variable name?
|
||||
*/
|
||||
static inline PsycBool
|
||||
inline PsycBool
|
||||
psyc_var_is_list (const char *name, size_t len)
|
||||
{
|
||||
return len < 5 || memcmp(name, "_list", 5) != 0 || (len > 5 && name[5] != '_')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue