- implemented multi-line response in AsconStdHandler
This commit is contained in:
26
ascon.i
26
ascon.i
@ -48,29 +48,33 @@ typedef enum {
|
||||
typedef int (* AsconHandler)(Ascon *connection);
|
||||
|
||||
/** Ascon struct
|
||||
* all members are public, allowing access by handler wrappers
|
||||
* all fields are public, allowing access by handler wrappers
|
||||
* the fields marked with (std) are used by the standard handler
|
||||
* they may get other meanings in a custom handler
|
||||
*/
|
||||
struct Ascon {
|
||||
AsconState state; /**< the current state */
|
||||
int fd; /**< socket */
|
||||
int readState; /**< default implementation: 'was cr' */
|
||||
int readState; /**< (std) last char was CR */
|
||||
pDynString rdBuffer; /**< read buffer */
|
||||
pDynString wrBuffer; /**< write buffer */
|
||||
int wrPos; /**< write buffer position */
|
||||
double timeout; /**< read timeout (sec) */
|
||||
char *sendTerminator; /**< terminator for sending messages */
|
||||
char *replyTerminator; /**< terminator list for reply. NULL is the special case CR, LF or CR/LF */
|
||||
char *replyTerminator; /**< (std) terminator list for reply. NULL is the special case CR, LF or CR/LF */
|
||||
char *hostport; /**< host:port to connect */
|
||||
pDynString errmsg; /**< error message */
|
||||
double start; /**< unix time when read was started */
|
||||
void *private; /**< private data of protocol */
|
||||
void (*killPrivate)(void *); /** < kill function for private */
|
||||
void (*killPrivate)(void *); /**< kill function for private */
|
||||
int noResponse; /**< no response expected */
|
||||
int responseValid; /**< a valid response is ready */
|
||||
AsconHandler handler; /**< handler function */
|
||||
double reconnectInterval; /**< reconnect interval */
|
||||
double lastReconnect; /**< last reconnect try */
|
||||
char lastChar; /**< last char read */
|
||||
char *separator; /**< (std) separator for multiline responses */
|
||||
int lineCount; /**< number of lines expected (counting down) */
|
||||
};
|
||||
|
||||
#define ASCON_SELECT_ERROR -1
|
||||
@ -104,13 +108,17 @@ int AsconStdHandler(Ascon *a);
|
||||
* \param a the connection
|
||||
* \param con A connection to print errors too.
|
||||
* \param argc number of arguments
|
||||
* \param argv arguments ("<host>:<port>" [sendTerminator] [timeout] [replyTerminators])
|
||||
* \param argv arguments ("<host>:<port>" [sendTerminator] [timeout] [replyTerminators] [separator])
|
||||
* sendTerminator is a character or string sent at the end of a command
|
||||
* timeout is in seconds
|
||||
* replyTerminator is a string, meant as a list of terminator characters
|
||||
* if not replyTerminator is given, CR, LF or CR/LF all are detected as
|
||||
* terminators. In this case the terminator is removed from the result,
|
||||
* where in the case before, the terminator stays in the result.
|
||||
* replyTerminators is a string, meant as a list of terminator characters
|
||||
* if no replyTerminator is given, or if it is empty, CR, LF or CR/LF all are detected
|
||||
* as terminators. If the terminator is CR, LF or CR/LF, it is removed from the result,
|
||||
* all other terminators are kept in the result.
|
||||
* separator is used for multiline responses. If this parameter
|
||||
* is given (and not empty) a command may be followed by a line count in curly brackets,
|
||||
* indicating that a multiline response is expected. All the lines of the response are
|
||||
* then returned, separated with "separator"
|
||||
*
|
||||
* In many cases a custom init function may be a wrapper around AsconStdInit
|
||||
*/
|
||||
|
Reference in New Issue
Block a user