mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
+
This commit is contained in:
commit
71dc5a7dad
1 changed files with 38 additions and 17 deletions
|
@ -1,14 +1,15 @@
|
|||
/**
|
||||
* @file psyc/parser.h
|
||||
* @brief Interface for various psyc parser functions
|
||||
* @brief Interface for various psyc parser functions.
|
||||
*
|
||||
* All parsing functions and the definitions they use are
|
||||
* defined in this file.
|
||||
*/
|
||||
|
||||
/** @defgroup parsing Parsing Functions
|
||||
/**
|
||||
* @defgroup parsing Parsing Functions
|
||||
*
|
||||
* This module contains all parsing functions
|
||||
* This module contains all parsing functions.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -18,7 +19,8 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/** Different types that a variable can have
|
||||
/**
|
||||
* Different types that a variable can have.
|
||||
*
|
||||
* This enum lists PSYC variable types that
|
||||
* this library is capable of checking for
|
||||
|
@ -45,7 +47,8 @@ enum PSYC_Flags
|
|||
PSYC_HEADER_ONLY = 1,
|
||||
};
|
||||
|
||||
/** The return value definitions for packet parsing function
|
||||
/**
|
||||
* The return value definitions for the packet parsing function.
|
||||
* @see PSYC_parse()
|
||||
*/
|
||||
enum PSYC_ReturnCodes
|
||||
|
@ -69,6 +72,10 @@ enum PSYC_ReturnCodes
|
|||
PSYC_INCOMPLETE = 9,
|
||||
};
|
||||
|
||||
/**
|
||||
* The return value definitions for the list parsing function.
|
||||
* @see PSYC_parseList()
|
||||
*/
|
||||
enum PSYC_ListReturnCodes
|
||||
{
|
||||
PSYC_ERROR_LIST_DELIM = -5,
|
||||
|
@ -81,6 +88,9 @@ enum PSYC_ListReturnCodes
|
|||
PSYC_LIST_INCOMPLETE = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* PSYC packet parts.
|
||||
*/
|
||||
enum PSYC_Parts
|
||||
{
|
||||
PSYC_PART_RESET = -1,
|
||||
|
@ -92,6 +102,10 @@ enum PSYC_Parts
|
|||
PSYC_PART_END,
|
||||
};
|
||||
|
||||
/**
|
||||
* List types.
|
||||
* Possible types are text and binary.
|
||||
*/
|
||||
enum PSYC_ListTypes
|
||||
{
|
||||
PSYC_LIST_TEXT = 1,
|
||||
|
@ -104,7 +118,9 @@ typedef struct
|
|||
const uint8_t * ptr;
|
||||
} PSYC_Array;
|
||||
|
||||
|
||||
/**
|
||||
* Struct for keeping parser state.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t cursor; ///< current position in buffer
|
||||
|
@ -120,6 +136,9 @@ typedef struct
|
|||
size_t valueLength; ///< expected length of the value
|
||||
} PSYC_State;
|
||||
|
||||
/**
|
||||
* Struct for keeping list parser state.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t cursor; ///< current position in buffer
|
||||
|
@ -197,7 +216,8 @@ inline size_t PSYC_getContentLength (PSYC_State* s)
|
|||
|
||||
#endif
|
||||
|
||||
/** Parse PSYC packets.
|
||||
/**
|
||||
* Parse PSYC packets.
|
||||
*
|
||||
* Generalized line-based packet parser.
|
||||
*
|
||||
|
@ -214,11 +234,12 @@ inline size_t PSYC_getContentLength (PSYC_State* s)
|
|||
* @see PSYC_State
|
||||
* @see PSYC_Array
|
||||
*/
|
||||
PSYC_ReturnCodes PSYC_parse(PSYC_State* state, uint8_t* modifier, PSYC_Array* name, PSYC_Array* value);
|
||||
int PSYC_parse(PSYC_State* state, uint8_t* modifier, PSYC_Array* name, PSYC_Array* value);
|
||||
|
||||
/**
|
||||
* List value parser.
|
||||
* @return see PSYC_ListReturnCodes.
|
||||
* @return one of PSYC_ReturnCodes
|
||||
* @see PSYC_ListReturnCodes
|
||||
*/
|
||||
int PSYC_parseList(PSYC_ListState* state, PSYC_Array *name, PSYC_Array* value, PSYC_Array* elem);
|
||||
|
||||
|
|
Loading…
Reference in a new issue