- design improvements in scriptcontext (sct send) and ascon (AsconBaseHandler)
- bug fixes
This commit is contained in:
65
ascon.i
65
ascon.i
@ -51,25 +51,26 @@ typedef int (* AsconHandler)(Ascon *connection);
|
||||
* all members are public, allowing access by handler wrappers
|
||||
*/
|
||||
struct Ascon {
|
||||
AsconState state; /**< the current state */
|
||||
int fd; /**< socket */
|
||||
int readState; /**< default implementation: '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 *hostport; /**< host:port to connect */
|
||||
pDynString errmsg; /**< error message */
|
||||
double start; /**< unix time when read was started */
|
||||
void *private; /**< private data of protocol */
|
||||
AsconState state; /**< the current state */
|
||||
int fd; /**< socket */
|
||||
int readState; /**< default implementation: '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 *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 */
|
||||
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 */
|
||||
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 */
|
||||
};
|
||||
|
||||
#define ASCON_SELECT_ERROR -1
|
||||
@ -77,14 +78,25 @@ struct Ascon {
|
||||
#define ASCON_SEND_ERROR -3
|
||||
#define ASCON_DISCONNECTED -4
|
||||
|
||||
/** \brief the basic handler routine.
|
||||
* \param a the connection
|
||||
* \return when the state before the call was not AsconReading, the return
|
||||
* value should be 1
|
||||
* when the state was AsconReading, a 1 indicates that a character was read
|
||||
* and the character is stored in the lastChar field. A 0 indicates
|
||||
* that no charater was read.
|
||||
*
|
||||
*
|
||||
* In most cases a custom handler may be a wrapper around AsconBaseHandler
|
||||
* or around AsconStdHandler
|
||||
*/
|
||||
int AsconBaseHandler(Ascon *a);
|
||||
|
||||
/** \brief the standard handler routine.
|
||||
* \param a the connection
|
||||
* \return 0 when it makes sense to call the handler again immediately
|
||||
* (for example while reading, after a character was read, as
|
||||
* there may be more chars in the buffer)
|
||||
* 1 else
|
||||
* \return see AsconBaseHandler
|
||||
*
|
||||
* In most cases a custom handler may be a wrapper around AsconStdHandler
|
||||
* features: see description of AsconStdInit
|
||||
*/
|
||||
int AsconStdHandler(Ascon *a);
|
||||
|
||||
@ -94,12 +106,13 @@ int AsconStdHandler(Ascon *a);
|
||||
* \param argc number of arguments
|
||||
* \param argv arguments ("<host>:<port>" [sendTerminator] [timeout] [replyTerminators])
|
||||
* sendTerminator is a character or string sent at the end of a command
|
||||
* timoeut is in seconds
|
||||
* 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
|
||||
* terminators. In this case the terminator is removed from the result,
|
||||
* where in the case before, the terminator stays in the result.
|
||||
*
|
||||
* In most cases a custom init function may be a wrapper around AsconStdInit
|
||||
* In many cases a custom init function may be a wrapper around AsconStdInit
|
||||
*/
|
||||
int AsconStdInit(Ascon *a, SConnection *con, int argc, char *argv[]);
|
||||
|
||||
|
Reference in New Issue
Block a user