diff --git a/Client/testclient.c b/Client/testclient.c index 0920f5f..e1b7ab5 100644 --- a/Client/testclient.c +++ b/Client/testclient.c @@ -51,7 +51,7 @@ structentry testdataentry[] = { { STR_PSTR, /* its a pointer to a string */ 0, /* pointers are unknown, have to use a callback */ - 0, /* for callbacks, no offset is required */ + offsetof(struct testdata, name), /* for callbacks, no offset is required */ readstr }, { @@ -68,6 +68,7 @@ structentry testdataentry[] = { } }; testdata *tmp; +testdata *tmp2; void *readstr(void *data, size_t *size) { @@ -90,6 +91,10 @@ int gotaction(int type, void *cbarg) { break; case PCK_SMP_MSGFROMQUEUE: sd = pck_get_msgfromqueue(conid); + tmp2 = malloc(sizeof(testdata)); + printf("%p %p %p %p\n", tmp2, tmp2->name, tmp2->size, tmp2->testdata); + pck_decode_message(sd, testdataentry,(sizeof(testdataentry)/sizeof(structentry)), tmp2); + printf("got %s %d %s\n", tmp2->name, tmp2->size, tmp2->testdata); printf("queue %s topic %s messid %d time %d from %s\n", sd->queue, sd->topic, sd->messid, sd->timestamp, sd->from); } diff --git a/Include/packet.h b/Include/packet.h index 31808d4..c681641 100644 --- a/Include/packet.h +++ b/Include/packet.h @@ -219,7 +219,7 @@ unsigned long pck_send_auth(mqp *mqplib, mqpacket *mqp, char *username, char *pa unsigned long pck_send_clntcap(mqp *mqplib, mqpacket *mqp); unsigned long pck_send_queueinfo(mqp *mqplib, mqpacket *mqpck, char *queue, char *info, int flags); unsigned long pck_send_queue_mes(mqp *mqplib, mqpacket *mqpck, char *queue, char *topic, void *data, size_t len, unsigned long messid, long timestamp, char *from); - +xds_t * pck_init_engines (mqp *mqplib, int type, int direction); /* this is the standalone un-threadsafe interface */ typedef int (actioncbfunc)(int, void *); diff --git a/Libs/packet.c b/Libs/packet.c index da48db0..23f1d81 100644 --- a/Libs/packet.c +++ b/Libs/packet.c @@ -122,10 +122,36 @@ void pck_set_data(mqpacket *mqp, void *data) { } +xds_t * +pck_init_engines (mqp *mqplib, int type, int direction) { + int i, rc = 0; + xds_t *xds; + if (xds_init (&xds, direction) != XDS_OK) { + if (mqplib->logger) + mqplib->logger ("xds init failed: %s", strerror (errno)); + return NULL; + } + i = 0; + while (i < NUMENGINES) { + if (mqplib->myengines[i].type == type) { + if (mqplib->myengines[i].dir == direction) { + rc = xds_register (xds, mqplib->myengines[i].myname, mqplib->myengines[i].ptr, NULL); + } + if (rc != XDS_OK) { + if (mqplib->logger) + mqplib->logger ("xds_register failed for %s", mqplib->myengines[i].myname); + xds_destroy (xds); + return NULL; + } + } + i++; + } + return xds; +} + mqpacket * pck_new_connection (mqp *mqplib, int fd, int type, int contype) { - int i, rc; mqpacket *mqpck; mqpck = malloc (sizeof (mqpacket)); @@ -133,7 +159,11 @@ pck_new_connection (mqp *mqplib, int fd, int type, int contype) mqpck->sock = fd; mqpck->outmsg.MID = -1; mqpck->nxtoutmid = 1; - + mqpck->xdsin = pck_init_engines(mqplib, type, XDS_DECODE); + mqpck->xdsout = pck_init_engines(mqplib, type, XDS_ENCODE); + + +#if 0 if (xds_init (&mqpck->xdsin, XDS_DECODE) != XDS_OK) { if (mqplib->logger) mqplib->logger ("xds init failed: %s", strerror (errno)); @@ -165,6 +195,7 @@ pck_new_connection (mqp *mqplib, int fd, int type, int contype) } i++; } +#endif mqpck->wiretype = type; switch (contype) { case PCK_IS_CLIENT: diff --git a/Libs/sock.c b/Libs/sock.c index 099de91..ea1a696 100644 --- a/Libs/sock.c +++ b/Libs/sock.c @@ -472,11 +472,57 @@ mq_data_senddata return NULL; } -void -*pck_decode_message(mq_data_senddata *sd, structentry *mystruct, int cols, void *target) { - /* XXX This needs some thinking about. Not tonight! */ - +int +pck_decode_message(mq_data_senddata *sd, structentry *mystruct, int cols, void *target) { + xds_t *xdstmp; + void *destptr; + char *string; + int i, rc, myint; + + xdstmp = pck_init_engines(sockconfig.mqplib, ENG_TYPE_XML, XDS_DECODE); + if (xdstmp == NULL) { + pck_logger("pck_decode_message xds init failed"); + return NS_FAILURE; + } + if (xds_setbuffer (xdstmp, XDS_LOAN, sd->data, sd->len) != XDS_OK) { + pck_logger("pck_decode_message XDS setbuffer Failed"); + return NS_FAILURE; + } + for (i = 0; i < cols; i++) { + switch (mystruct[i].type) { + case STR_PSTR: + rc = xds_decode(xdstmp, "string", &string); + if (rc == XDS_OK) { + destptr = (void *) target + mystruct[i].offset; + *(char **)destptr = strndup(string, strlen(string)); + } else { + pck_logger("pck_decode_message, STR_PSTR failed\n"); + } + break; + case STR_INT: + rc = xds_decode(xdstmp, "int32", &myint); + if (rc == XDS_OK) { + destptr = (void *) target + mystruct[i].offset; + *((int *)destptr) = myint; + } else { + pck_logger("pck_decode_message, STR_INT failed\n"); + } + break; + case STR_STR: + rc = xds_decode(xdstmp, "string", &string); + if (rc == XDS_OK) { + destptr = (void *) target + mystruct[i].offset; + strncpy((char *)destptr, string, mystruct[i].size); + } else { + pck_logger("pck_decode_message, STR_STR failed\n"); + } + break; + default: + pck_logger( "pck_decode_message, unknown type"); + } + } + return NS_SUCCESS; } \ No newline at end of file diff --git a/adns/Makefile b/adns/Makefile index c2f1c97..45b991e 100644 --- a/adns/Makefile +++ b/adns/Makefile @@ -1,5 +1,5 @@ -INCLUDES = -I.. +INCLUDES = -I.. -I../Include/ SRCS = check.c event.c general.c parse.c query.c reply.c setup.c transmit.c types.c OBJS = ${SRCS:.c=.o} @@ -35,12 +35,3 @@ dist: $(OBJS): Makefile -check.o: check.c internal.h config.h adns.h dlist.h -event.o: event.c internal.h config.h adns.h dlist.h tvarith.h -general.o: general.c internal.h config.h adns.h dlist.h -parse.o: parse.c internal.h config.h adns.h dlist.h -query.o: query.c internal.h config.h adns.h dlist.h -reply.o: reply.c internal.h config.h adns.h dlist.h -setup.o: setup.c internal.h config.h adns.h dlist.h -transmit.o: transmit.c internal.h config.h adns.h dlist.h tvarith.h -types.o: types.c internal.h config.h adns.h dlist.h \ No newline at end of file diff --git a/adns/config.h b/adns/config.h index 40aeffc..a22abe8 100644 --- a/adns/config.h +++ b/adns/config.h @@ -1,35 +1,34 @@ -/* adns/config.h. Generated by configure. */ /* src/config.h.in. Generated automatically from configure.in by autoheader. */ /* Define if inline functions a la GCC are available. */ -#define HAVE_INLINE 1 +#undef HAVE_INLINE /* Define if function attributes a la GCC 2.5 and higher are available. */ -#define HAVE_GNUC25_ATTRIB 1 +#undef HAVE_GNUC25_ATTRIB /* Define if constant functions a la GCC 2.5 and higher are available. */ -#define HAVE_GNUC25_CONST 1 +#undef HAVE_GNUC25_CONST /* Define if nonreturning functions a la GCC 2.5 and higher are available. */ -#define HAVE_GNUC25_NORETURN 1 +#undef HAVE_GNUC25_NORETURN /* Define if printf-format argument lists a la GCC are available. */ -#define HAVE_GNUC25_PRINTFFORMAT 1 +#undef HAVE_GNUC25_PRINTFFORMAT /* Define if we want to include rpc/types.h. Crap BSDs put INADDR_LOOPBACK there. */ -/* #undef HAVEUSE_RPCTYPES_H */ +#undef HAVEUSE_RPCTYPES_H /* Define if you have the poll function. */ -/* #undef HAVE_POLL */ +#undef HAVE_POLL /* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 +#undef HAVE_SYS_SELECT_H /* Define if you have the nsl library (-lnsl). */ -/* #undef HAVE_LIBNSL */ +#undef HAVE_LIBNSL /* Define if you have the socket library (-lsocket). */ -/* #undef HAVE_LIBSOCKET */ +#undef HAVE_LIBSOCKET /* Use the definitions: */ diff --git a/configure b/configure index 78f5ff4..1c61414 100755 --- a/configure +++ b/configure @@ -24437,7 +24437,7 @@ fi - ac_config_files="$ac_config_files Makefile Server/Makefile Libs/Makefile Include/xds.h Client/Makefile confuse/Makefile" + ac_config_files="$ac_config_files Makefile Server/Makefile Libs/Makefile Include/xds.h Client/Makefile confuse/Makefile adns/config.h" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -25021,6 +25021,7 @@ do "Include/xds.h" ) CONFIG_FILES="$CONFIG_FILES Include/xds.h" ;; "Client/Makefile" ) CONFIG_FILES="$CONFIG_FILES Client/Makefile" ;; "confuse/Makefile" ) CONFIG_FILES="$CONFIG_FILES confuse/Makefile" ;; + "adns/config.h" ) CONFIG_FILES="$CONFIG_FILES adns/config.h" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "Include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS Include/config.h" ;; diff --git a/configure.in b/configure.in index ec50bd9..0eba4c0 100644 --- a/configure.in +++ b/configure.in @@ -97,7 +97,7 @@ NEO_SUBDIR_CONFIG(libevent, [--disable-shared --enable-static]) dnl NEO_SUBDIR_CONFIG(sqlite, [--enable-static --disable-shared --enable-tempdb-in-ram --enable-incore-db]) AC_OUTPUT(Makefile Server/Makefile Libs/Makefile Include/xds.h -Client/Makefile confuse/Makefile) +Client/Makefile confuse/Makefile adns/config.h) echo "(*----------------------------------------------------------*)" echo "(| Important Instructions |)" echo "(*----------------------------------------------------------*)"