From 5e81facdf5baf68e33e3370bbc3aa6226dac5bc2 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 16 Jun 1999 11:55:24 +0000 Subject: [PATCH] Added APDU log to client. --- client/client.c | 29 ++++++++++++++++++++++------- comstack/xmosi.c | 11 +++++++---- include/tcpip.h | 8 +++++--- include/xmosi.h | 7 +++++-- include/yconfig.h | 8 -------- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/client/client.c b/client/client.c index c979041..5623f46 100644 --- a/client/client.c +++ b/client/client.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.84 1999-06-01 14:29:11 adam + * Revision 1.85 1999-06-16 11:55:24 adam + * Added APDU log to client. + * + * Revision 1.84 1999/06/01 14:29:11 adam * Work on Extended Services. * * Revision 1.83 1999/05/26 15:24:26 adam @@ -284,7 +287,6 @@ #include -#include #include #ifdef USE_XTIMOSI #include @@ -310,6 +312,7 @@ #define C_PROMPT "Z> " static ODR out, in, print; /* encoding and decoding streams */ +static FILE *apdu_file = 0; static COMSTACK conn = 0; /* our z-association */ static Z_IdAuthentication *auth = 0; /* our current auth definition */ static char *databaseNames[128]; @@ -353,6 +356,11 @@ static void send_apdu(Z_APDU *a) odr_perror(out, "Encoding APDU"); exit(1); } + if (apdu_file) + { + z_APDU(print, &a, 0, 0); + odr_reset(print); + } buf = odr_getbuf(out, &len, 0); if (cs_put(conn, buf, len) < 0) { @@ -1909,6 +1917,8 @@ static void initialize(void) exit(1); } setvbuf(stdout, 0, _IONBF, 0); + if (apdu_file) + odr_setprint(print, apdu_file); #if CCL2RPN bibset = ccl_qual_mk (); @@ -2061,14 +2071,12 @@ static int client(int wait) fprintf(stderr, "---------\n"); exit(1); } -#if 0 - if (!z_APDU(print, &apdu, 0)) + if (apdu_file && !z_APDU(print, &apdu, 0, 0)) { odr_perror(print, "Failed to print incoming APDU"); odr_reset(print); continue; } -#endif switch(apdu->which) { case Z_APDU_initResponse: @@ -2130,7 +2138,7 @@ int main(int argc, char **argv) int ret; int opened = 0; - while ((ret = options("m:v:", argv, argc, &arg)) != -2) + while ((ret = options("a:m:v:", argv, argc, &arg)) != -2) { switch (ret) { @@ -2149,11 +2157,18 @@ int main(int argc, char **argv) exit (1); } break; + case 'a': + if (!strcmp(arg, "-")) + apdu_file=stderr; + else + apdu_file=fopen(arg, "a"); + break; case 'v': log_init (log_mask_str(arg), "", NULL); break; default: - fprintf (stderr, "Usage: %s [-m ] []\n", + fprintf (stderr, "Usage: %s [-m ] [ -m ] " + "[]\n", prog); exit (1); } diff --git a/comstack/xmosi.c b/comstack/xmosi.c index 132de6c..4e56b12 100644 --- a/comstack/xmosi.c +++ b/comstack/xmosi.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: xmosi.c,v $ - * Revision 1.16 1997-09-17 12:10:30 adam + * Revision 1.17 1999-06-16 11:55:24 adam + * Added APDU log to client. + * + * Revision 1.16 1997/09/17 12:10:30 adam * YAZ version 1.4. * * Revision 1.15 1997/05/14 06:53:34 adam @@ -239,7 +242,7 @@ int hex2oct(char *hex, char *oct) * up in a t_mosiaddr in a netbuf (on a stick). */ -int MDF *mosi_strtoaddr_ex(const char *str, struct netbuf *ret) +int *mosi_strtoaddr_ex(const char *str, struct netbuf *ret) { struct sockaddr_in *add = xmalloc(sizeof(struct sockaddr_in)); struct t_mosiaddr *mosiaddr = xmalloc(sizeof(struct t_mosiaddr)); @@ -312,7 +315,7 @@ int MDF *mosi_strtoaddr_ex(const char *str, struct netbuf *ret) return 1; } -struct netbuf MDF *mosi_strtoaddr(const char *str) +struct netbuf *mosi_strtoaddr(const char *str) { struct netbuf *ret = xmalloc(sizeof(struct netbuf)); @@ -324,7 +327,7 @@ struct netbuf MDF *mosi_strtoaddr(const char *str) return ret; } -struct netbuf MDF *mosi_straddr(COMSTACK h, const char *str) +struct netbuf *mosi_straddr(COMSTACK h, const char *str) { mosi_state *st = h->cprivate; struct netbuf *ret = &st->netbuf; diff --git a/include/tcpip.h b/include/tcpip.h index c1bd7ef..a74c554 100644 --- a/include/tcpip.h +++ b/include/tcpip.h @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: tcpip.h,v $ - * Revision 1.12 1999-01-08 11:23:19 adam + * Revision 1.13 1999-06-16 11:55:24 adam + * Added APDU log to client. + * + * Revision 1.12 1999/01/08 11:23:19 adam * Added const modifier to some of the BER/ODR encoding routines. * * Revision 1.11 1998/06/22 11:32:38 adam @@ -78,8 +81,7 @@ #ifndef TCPIP_H #define TCPIP_H -#define YNETINCLUDE -#include +#include #include #ifdef __cplusplus diff --git a/include/xmosi.h b/include/xmosi.h index c359faa..8d522d3 100644 --- a/include/xmosi.h +++ b/include/xmosi.h @@ -24,7 +24,10 @@ * OF THIS SOFTWARE. * * $Log: xmosi.h,v $ - * Revision 1.6 1997-05-14 06:53:53 adam + * Revision 1.7 1999-06-16 11:55:24 adam + * Added APDU log to client. + * + * Revision 1.6 1997/05/14 06:53:53 adam * C++ support. * * Revision 1.5 1996/02/10 12:23:43 quinn @@ -57,7 +60,7 @@ #ifndef XMOSI_H #define XMOSI_H -#include +#include #include #include #include diff --git a/include/yconfig.h b/include/yconfig.h index 8546f31..394b7a0 100644 --- a/include/yconfig.h +++ b/include/yconfig.h @@ -42,12 +42,4 @@ #endif #endif -#ifdef WIN32 -#define MDF -#else -#ifndef MDF -#define MDF -#endif -#endif - #endif -- 1.7.10.4