cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
mturk 2002/11/20 09:29:11 Modified:jk/native2/common jk_msg_ajp.c Log: Use the logger for dump method instead of using stderr. Revision ChangesPath 1.20 +2 -1 jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- jk_msg_ajp.c 24 Sep 2002 22:39:21 - 1.19 +++ jk_msg_ajp.c 20 Nov 2002 17:29:11 - 1.20 @@ -130,7 +130,8 @@ } *current++='\n'; *current++='\0'; -fprintf( stderr, %.4x%s, i, line ); +env-l-jkLog(env, env-l, JK_LOG_INFO, + %.4x%s, i, line); } } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
hgomez 2002/09/24 15:39:21 Modified:jk/native2/common jk_msg_ajp.c Log: AS/400 / BS2000 back port from 1.2.0. Revision ChangesPath 1.19 +22 -3 jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- jk_msg_ajp.c 23 Jun 2002 15:54:13 - 1.18 +++ jk_msg_ajp.c 24 Sep 2002 22:39:21 - 1.19 @@ -253,8 +253,8 @@ } -static int jk2_msg_ajp_appendString(jk_env_t *env, jk_msg_t *msg, -const char *param) +static int jk2_msg_ajp_appendAString(jk_env_t *env, jk_msg_t *msg, + const char *param, int convert) { int len; @@ -273,13 +273,31 @@ /* We checked for space !! */ strncpy((char *)msg-buf + msg-len , param, len+1);/* including \0 */ -jk_xlate_to_ascii((char *)msg-buf + msg-len, len+1); /* convert from EBCDIC if needed */ +#if defined(AS400) || defined(_OSD_POSIX) +if (convert) + jk_xlate_to_ascii((char *)msg-buf + msg-len, len+1); /* convert from EBCDIC if needed */ +#endif msg-len += len + 1; return JK_OK; } + +static int jk2_msg_ajp_appendString(jk_env_t *env, jk_msg_t *msg, +const char *param) +{ +return jk2_msg_ajp_appendAString(env, msg, param, 1); +} + + +static int jk2_msg_ajp_appendAsciiString(jk_env_t *env, jk_msg_t *msg, + const char *param) +{ +return jk2_msg_ajp_appendAString(env, msg, param, 0); +} + + static int jk2_msg_ajp_appendBytes(jk_env_t *env, jk_msg_t *msg, const unsigned char *param, const int len) @@ -516,6 +534,7 @@ msg-appendInt=jk2_msg_ajp_appendInt; msg-appendLong=jk2_msg_ajp_appendLong; msg-appendString=jk2_msg_ajp_appendString; +msg-appendAsciiString=jk2_msg_ajp_appendAsciiString; msg-appendMap=jk2_msg_ajp_appendMap; msg-appendFromServer=jk2_msg_ajp_appendFromServer; -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
jfclere 2002/06/23 08:54:13 Modified:jk/native2/common jk_msg_ajp.c Log: Replace the 4's by AJP_HEADER_LEN (Where they were header length). Revision ChangesPath 1.18 +7 -7 jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- jk_msg_ajp.c 10 Jun 2002 21:55:06 - 1.17 +++ jk_msg_ajp.c 23 Jun 2002 15:54:13 - 1.18 @@ -137,13 +137,13 @@ static void jk2_msg_ajp_reset(jk_env_t *env, jk_msg_t *_this) { -_this-len = 4; -_this-pos = 4; +_this-len = AJP_HEADER_LEN; +_this-pos = AJP_HEADER_LEN; } static void jk2_msg_ajp_end(jk_env_t *env, jk_msg_t *msg) { -unsigned short len=msg-len - 4; +unsigned short len=msg-len - AJP_HEADER_LEN; if(msg-serverSide ) { @@ -165,7 +165,7 @@ { int len=msg-len; -if(len + 4 msg-maxlen) { +if(len + AJP_HEADER_LEN msg-maxlen) { return JK_ERR; } @@ -442,8 +442,8 @@ return -2; } -msg-len=msglen+4; -msg-pos=4; +msg-len=msglen+AJP_HEADER_LEN; +msg-pos=AJP_HEADER_LEN; return msglen; } @@ -505,7 +505,7 @@ msg-maxlen=buffSize; msg-len=0; -msg-headerLength=4; +msg-headerLength=AJP_HEADER_LEN; msg-reset=jk2_msg_ajp_reset; msg-end=jk2_msg_ajp_end; -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
costin 02/05/14 10:15:27 Modified:jk/native2/common jk_msg_ajp.c Log: Long due - 'decent' dump of the buffer. Lots of pointers, it'll probably disqualify me as a java programmer. Revision ChangesPath 1.13 +57 -22jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- jk_msg_ajp.c 8 May 2002 23:55:11 - 1.12 +++ jk_msg_ajp.c 14 May 2002 17:15:27 - 1.13 @@ -55,13 +55,16 @@ * * * = */ -/*** - * Description: Data marshaling. XDR like * - * Author: Costin Manolache - * Author: Gal Shachor [EMAIL PROTECTED] * - * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.12 $ * - ***/ +/** + * Data marshaling. Originally based on Jserv's ajp12 and other similar + * formats. Implements the jk_msg interface. + * + * Will be eventually replaced with XDR or CDR. + * + * @author: Gal Shachor [EMAIL PROTECTED] + * @author: Henri Gomez [EMAIL PROTECTED] + * @author: Costin Manolache + */ #include jk_pool.h #include jk_msg.h @@ -70,33 +73,65 @@ #include jk_channel.h #include jk_requtil.h +/* Signature for the messages sent from Apache to tomcat + */ #define AJP13_WS_HEADER 0x1234 +/* Size of the header ( signature + len ) + */ #define AJP_HEADER_LEN(4) #define AJP_HEADER_SZ_LEN (2) +char *jk_HEX=0123456789ABCDEFX; + /* - * Simple marshaling code. + * Debugging - display the buffer. */ static void jk2_msg_ajp_dump(jk_env_t *env, struct jk_msg *_this, char *err) { -int i=0; +unsigned int i=0; +char line[80]; +char *current; +unsigned int j; +unsigned int len=_this-len; + +if( len 1024 ) len=1024; + env-l-jkLog( env, env-l, JK_LOG_INFO, %s pos=%d len=%d max=%d \n, err, _this-pos, _this-len, _this-maxlen ); - -env-l-jkLog( env, env-l, JK_LOG_INFO, -%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x \n, -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++]); -env-l-jkLog( env, env-l, JK_LOG_INFO, -%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x \n, -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++]); + +for( i=0; i len; i+=16) { +current=line; +/* I can't believe I did this ! That's the %.4x :-) + *current++= jk_HEX[ ( i 0xf000 ) 12 ]; */ +/* *current++= jk_HEX[ ( i 0x0f00 ) 8 ]; */ +/* *current++= jk_HEX[ ( i 0xf0 ) 4 ]; */ +/* *current++= jk_HEX[ ( i 0x0f ) ]; */ + +for( j=0; j16; j++ ) { +unsigned char x=(_this-buf[i+j]); + +*current++ = jk_HEX[x 4 ]; +*current++ = jk_HEX[x 0x0f ]; +*current++ =' '; +} +*current++=' '; +*current++='-'; +*current++=' '; +for( j=0; j16; j++ ) { +unsigned char x=_this-buf[i+j]; + +if( x 0x20 x 0x7F ) { +*current++=x; +} else { +*current++='.'; +} +} +*current++='\n'; +*current++='\0'; +fprintf( stderr, %.4x%s, i, line ); +} } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
costin 02/05/03 10:41:52 Modified:jk/native2/common jk_msg_ajp.c Log: Add encoding/decoding for map. That'll be used very frequently to pass properties back and forth ( either via shm or a different channel ) Revision ChangesPath 1.9 +26 -4 jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- jk_msg_ajp.c 2 May 2002 03:13:05 - 1.8 +++ jk_msg_ajp.c 3 May 2002 17:41:52 - 1.9 @@ -60,7 +60,7 @@ * Author: Costin Manolache * Author: Gal Shachor [EMAIL PROTECTED] * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.8 $ * + * Version: $Revision: 1.9 $ * ***/ #include jk_pool.h @@ -172,14 +172,36 @@ static int jk2_msg_ajp_appendMap(jk_env_t *env, jk_msg_t *msg, jk_map_t *map) { +int rc; +int i; +int size=map-size(env, map); -return JK_OK; +rc=msg-appendInt( env, msg, size ); + +for( i=0; i size; i++ ) { +char *name=map-nameAt( env, map, i ); +char *val=map-valueAt( env, map, i ); +if( rc== JK_OK ) +rc=msg-appendString( env, msg, name ); +if( rc== JK_OK ) +msg-appendString( env, msg, val ); +} + +return rc; } static int jk2_msg_ajp_getMap(jk_env_t *env, jk_msg_t *msg, jk_map_t *map) { +int size=msg-getInt( env, msg ); +int i; + +for( i=0; isize; i++ ) { +char *name= msg-getString( env, msg ); +char *val=msg-getString( env, msg ); +map-add( env, map, name, val ); +} return JK_OK; } @@ -189,8 +211,8 @@ { int len; -if(!param) { - msg-appendInt( env, msg, 0x ); +if(param==NULL) { +msg-appendInt( env, msg, 0x ); return JK_OK; } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
costin 02/04/25 12:17:22 Modified:jk/native2/common jk_msg_ajp.c Log: Update rc. Dump the message on error, clean up the dump. Revision ChangesPath 1.7 +22 -30jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- jk_msg_ajp.c 21 Feb 2002 11:11:15 - 1.6 +++ jk_msg_ajp.c 25 Apr 2002 19:17:22 - 1.7 @@ -60,7 +60,7 @@ * Author: Costin Manolache * Author: Gal Shachor [EMAIL PROTECTED] * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.6 $ * + * Version: $Revision: 1.7 $ * ***/ #include jk_pool.h @@ -82,31 +82,17 @@ { int i=0; env-l-jkLog( env, env-l, JK_LOG_INFO, - %s pos=%d len=%d max=%d , + %s pos=%d len=%d max=%d \n, err, _this-pos, _this-len, _this-maxlen ); env-l-jkLog( env, env-l, JK_LOG_INFO, -%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x\n, +%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x \n, _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++]); -i-=16; env-l-jkLog( env, env-l, JK_LOG_INFO, -%c %c %c %c: %c %c %c %c: %c %c %c %c: %c %c %c %c\n, -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++]); -env-l-jkLog( env, env-l, JK_LOG_INFO, -%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x\n, -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], -_this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++]); -i-=16; -env-l-jkLog( env, env-l, JK_LOG_INFO, -%c %c %c %c: %c %c %c %c: %c %c %c %c: %c %c %c %c\n, +%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x \n, _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], _this-buf[i++],_this-buf[i++],_this-buf[i++],_this-buf[i++], @@ -139,7 +125,7 @@ int len=msg-len; if(len + 4 msg-maxlen) { -return -1; +return JK_ERR; } msg-buf[len] = (unsigned char)((val 24) 0xFF); @@ -149,7 +135,7 @@ msg-len += 4; -return 0; +return JK_OK; } @@ -158,7 +144,7 @@ { int len=msg-len; if(len + 2 msg-maxlen) { -return -1; +return JK_ERR; } msg-buf[len] = (unsigned char)((val 8) 0xFF); @@ -166,7 +152,7 @@ msg-len += 2; -return 0; +return JK_OK; } static int jk2_msg_ajp_appendByte(jk_env_t *env, jk_msg_t *msg, @@ -174,13 +160,13 @@ { int len=msg-len; if(len + 1 msg-maxlen) { - return -1; + return JK_ERR; } msg-buf[len]= val; msg-len += 1; -return 0; +return JK_OK; } static int jk2_msg_ajp_appendString(jk_env_t *env, jk_msg_t *msg, @@ -190,12 +176,12 @@ if(!param) { msg-appendInt( env, msg, 0x ); -return 0; +return JK_OK; } len = strlen(param); if(msg-len + len + 2 msg-maxlen) { - return -1; + return JK_ERR; } /* ignore error - we checked once */ @@ -206,7 +192,7 @@ jk_xlate_to_ascii((char *)msg-buf + msg-len, len+1); /* convert from EBCDIC if needed */ msg-len += len + 1; -return 0; +return JK_OK; } @@ -215,18 +201,18 @@ int len) { if (! len) { -return 0; +return JK_OK; }
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c
costin 02/01/25 23:07:13 Modified:jk/native2/common jk_msg_ajp.c Log: Removed the send/receive ( now in channel ). A small change - the msg is just a byte chunk for the channel. It has a header, and a body. We now store both in the same buffer. That's because it may be more efficient to receive both at the same time. Revision ChangesPath 1.5 +32 -73jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c Index: jk_msg_ajp.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- jk_msg_ajp.c 17 Dec 2001 07:17:08 - 1.4 +++ jk_msg_ajp.c 26 Jan 2002 07:07:13 - 1.5 @@ -60,7 +60,7 @@ * Author: Costin Manolache * Author: Gal Shachor [EMAIL PROTECTED] * * Author: Henri Gomez [EMAIL PROTECTED] * - * Version: $Revision: 1.4 $ * + * Version: $Revision: 1.5 $ * ***/ #include jk_pool.h @@ -235,7 +235,8 @@ if(msg-pos + 3 msg-len) { env-l-jkLog( env, env-l, JK_LOG_ERROR, - Error: try to get data past end of the buffer\n); + msg_ajp.getLong(): BufferOverflowException %d %d\n, + msg-pos, msg-len); return -1; } i = ((msg-buf[(msg-pos++)] 0xFF)24); @@ -250,7 +251,8 @@ int i; if(msg-pos + 1 msg-len) { env-l-jkLog( env, env-l, JK_LOG_ERROR, - Error: try to get data past end of the buffer\n); + msg_ajp.geInt(): BufferOverflowException %d %d\n, + msg-pos, msg-len); return -1; } i = ((msg-buf[(msg-pos++)] 0xFF)8); @@ -263,7 +265,8 @@ int i; if(msg-pos + 1 msg-len) { env-l-jkLog( env, env-l, JK_LOG_ERROR, - Error: try to get data past end of the buffer\n); + msg_ajp.peekInt(): BufferOverflowException %d %d\n, + msg-pos, msg-len); return -1; } i = ((msg-buf[(msg-pos)] 0xFF)8); @@ -276,7 +279,8 @@ unsigned char rc; if(msg-pos msg-len) { env-l-jkLog( env, env-l, JK_LOG_ERROR, - Error: try to get data past end of the buffer\n); + msg_ajp.getByte(): BufferOverflowException %d %d\n, + msg-pos, msg-len); return -1; } rc = msg-buf[msg-pos++]; @@ -291,7 +295,8 @@ if((size 0 ) || (size + start msg-maxlen)) { env-l-jkLog( env, env-l, JK_LOG_ERROR, - Error: try to get data past end of the buffer\n); + msg_ajp.getString(): BufferOverflowException %d %d\n, + msg-pos, msg-len); return (unsigned char *)ERROR; /* XXX */ } @@ -310,7 +315,8 @@ if((size 0 ) || (size + start msg-maxlen)) { env-l-jkLog( env, env-l, JK_LOG_ERROR, - Error: try to get data past end of the buffer\n); + msg_ajp.getBytes(): BufferOverflowException %d %d\n, + msg-pos, msg-len); return (unsigned char *)ERROR; /* XXX */ } @@ -330,57 +336,21 @@ *dst= *src; } - -/* - * Send a message to endpoint, using corresponding PROTO HEADER - */ -static int jk_msg_ajp_send(jk_env_t *env, jk_msg_t *msg, - jk_endpoint_t *ae ) -{ -int err; -jk_channel_t *channel=ae-worker-channel; - -jk_msg_ajp_end(env, msg); - -/* jk_msg_ajp_dump(l, JK_LOG_DEBUG, sending to ajp13, msg); */ -env-l-jkLog( env, env-l, JK_LOG_INFO, - msgAjp.send() %d\n, msg-len ); - -err=channel-send( env, channel, ae, - msg-buf, msg-len ); - -if( err!=JK_TRUE ) { -return err; -} - -return JK_TRUE; -} - - -/* - * Receive a message from endpoint - */ -static int jk_msg_ajp_receive(jk_env_t *env, jk_msg_t *msg, - jk_endpoint_t *ae ) +/** Process the request header. At least the header must be +available - the channel may get more data it it can, to +avoid multiple system calls. +*/ +static int jk_msg_ajp_checkHeader(jk_env_t *env, jk_msg_t *msg, + jk_endpoint_t *ae ) { -unsigned char head[4]; -int rc; -int msglen; -jk_channel_t *channel=ae-worker-channel; -
cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_msg_ajp.c jk_msg_buff.c jk_msg_buff.h
costin 01/12/12 13:23:57 Modified:jk/native2/include jk_msg.h Added: jk/native2/common jk_msg_ajp.c Removed: jk/native2/common jk_msg_buff.c jk_msg_buff.h Log: Better abstraction for message serializing/deserializing, protecting the internal data ( the buf is no longer used/useable outside ). This is supposed to allow other encodings/protocols to be added with minimal effort and without changes in mod_jk. In addition, this is supposed to work with JNI as well - each 'appendFoo' can be translated to converting to java and saving it in a jobject[], with send() implemented as a jni call. It also cleans up a lot of code that used 'dirty' tricks. Revision ChangesPath 1.2 +75 -24jakarta-tomcat-connectors/jk/native2/include/jk_msg.h Index: jk_msg.h === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_msg.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- jk_msg.h 2001/12/01 22:30:57 1.1 +++ jk_msg.h 2001/12/12 21:23:57 1.2 @@ -61,14 +61,25 @@ #include jk_global.h #include jk_logger.h #include jk_pool.h -#include jk_msg_buff.h +#include jk_endpoint.h +#include jk_service.h #ifdef __cplusplus extern C { #endif /* __cplusplus */ +struct jk_msg; +typedef struct jk_msg jk_msg_t; + +struct jk_endpoint; +struct jk_ws_service; +struct jk_logger; + +#define DEF_BUFFER_SZ (8 * 1024) +#define AJP13_MAX_SEND_BODY_SZ (DEF_BUFFER_SZ - 6) + /** - * Abstract interface to jk marshalling. Different encodings and + * Abstract interface to marshalling. Different encodings and * communication mechanisms can be supported. * * This object is recyclable, but is not thread safe - it can @@ -94,14 +105,6 @@ */ int id; -/** List of properties. The handler can be configured. - * ( password for login, etc ). - */ -/* - char **supportedProperties; - jk_map_t *properties; -*/ - /* * Prepare the buffer for a new invocation */ @@ -116,37 +119,85 @@ * Dump the buffer header * @param err Message text */ -void (*dump)(struct jk_msg *_this, char *err); +void (*dump)(struct jk_msg *_this, struct jk_logger *log, char *err); -void (*appendByte)(struct jk_msg *_this, unsigned char val); +int (*appendByte)(struct jk_msg *_this, unsigned char val); -void (*appendBytes)(struct jk_msg *_this, - const unsigned char * param, - const int len); +int (*appendBytes)(struct jk_msg *_this, +const unsigned char * param, +const int len); -void (*appendInt)(struct jk_msg *_this, - const unsigned short val); +int (*appendInt)(struct jk_msg *_this, + const unsigned short val); -void (*appendLong)(struct jk_msg *_this, +int (*appendLong)(struct jk_msg *_this, const unsigned long val); -void (*appendString)(struct jk_msg *_this, +int (*appendString)(struct jk_msg *_this, const char *param); unsigned char (*getByte)(struct jk_msg *_this); unsigned short (*getInt)(struct jk_msg *_this); +/** Look at the next int, without reading it + */ +unsigned short (*peekInt)(struct jk_msg *_this); + unsigned long (*getLong)(struct jk_msg *_this); + +/** Return a string. +The buffer is internal to the message, you must save +or make sure the message lives long enough. + */ +unsigned char *(*getString)(struct jk_msg *_this); + +/** Return a byte[] and it's length. +The buffer is internal to the message, you must save +or make sure the message lives long enough. + */ +unsigned char *(*getBytes)(struct jk_msg *_this, int *len); + + +/* + * Receive a message from endpoint + */ +int (*receive)(jk_msg_t *_this, struct jk_endpoint *ae ); + +/* + * Send a message to endpoint + */ +int (*send)(jk_msg_t *_this, struct jk_endpoint *ae ); -char * (*getString)(struct jk_msg *_this); - +/** + * Special method. Will read data from the server and add them as + * bytes. It is equivalent with jk_requtil_readFully() in a buffer + * and then jk_msg_appendBytes(), except that we use directly the + * internal buffer. + * + * Returns -1 on error, else number of bytes read + */ +int (*appendFromServer)(struct jk_msg *_this, +struct jk_ws_service *r, +struct