From 57a4650104210f5e0bd9b6e0dbde0690000c1dc1 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 23 Jan 2002 22:40:36 +0000 Subject: [PATCH] Retrieval of post script files. -k option for client. --- client/client.c | 21 +++++++++++++++++---- server/seshigh.c | 8 ++++---- ztest/ztest.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/client/client.c b/client/client.c index 12b8239..e27a246 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.135 2002-01-21 12:54:06 adam Exp $ + * $Id: client.c,v 1.136 2002-01-23 22:40:36 adam Exp $ */ #include @@ -67,6 +67,7 @@ static char last_scan_query[512] = "0"; static char ccl_fields[512] = "default.bib"; static char* esPackageName = 0; static char* yazProxy = 0; +static int kilobytes = 1024; static char last_cmd[32] = "?"; static FILE *marcdump = 0; @@ -172,8 +173,8 @@ static void send_initRequest(const char* type_and_host) ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3); - *req->maximumRecordSize = 1024*1024; - *req->preferredMessageSize = 1024*1024; + *req->maximumRecordSize = 1024*kilobytes; + *req->preferredMessageSize = 1024*kilobytes; req->idAuthentication = auth; @@ -508,8 +509,17 @@ static void display_record(Z_External *r) const char *octet_buf = (char*)r->u.octet_aligned->buf; if (ent->value == VAL_TEXT_XML || ent->value == VAL_APPLICATION_XML || ent->value == VAL_HTML) + { print_record((const unsigned char *) octet_buf, r->u.octet_aligned->len); + } + else if (ent->value == VAL_POSTSCRIPT) + { + int size = r->u.octet_aligned->len; + if (size > 100) + size = 100; + print_record((const unsigned char *) octet_buf, size); + } else { if ( @@ -2273,7 +2283,7 @@ int main(int argc, char **argv) char *arg; int ret; - while ((ret = options("c:a:m:v:p:u:", argv, argc, &arg)) != -2) + while ((ret = options("k:c:a:m:v:p:u:", argv, argc, &arg)) != -2) { switch (ret) { @@ -2285,6 +2295,9 @@ int main(int argc, char **argv) strcat (open_command, arg); } break; + case 'k': + kilobytes = atoi(arg); + break; case 'm': if (!(marcdump = fopen (arg, "a"))) { diff --git a/server/seshigh.c b/server/seshigh.c index d7e34a0..936cd80 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.125 2002-01-23 21:13:30 adam Exp $ + * $Id: seshigh.c,v 1.126 2002-01-23 22:40:36 adam Exp $ */ /* @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -759,7 +760,7 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) odr_malloc (assoc->encode, sizeof(*dr)); yaz_log(LOG_LOG, "[%d] %s %s%s", error, diagbib1_str(error), - addinfo ? " -- " : "", addinfo ? addinfo : "", error); + addinfo ? " -- " : "", addinfo ? addinfo : ""); rec->which = Z_Records_NSD; rec->u.nonSurrogateDiagnostic = dr; dr->diagnosticSetId = @@ -936,7 +937,7 @@ static Z_Records *pack_records(association *a, char *setname, int start, } else /* too big entirely */ { - yaz_log(LOG_DEBUG, "Record > maxrcdsz"); + yaz_log(LOG_LOG, "Record > maxrcdsz this=%d max=%d", this_length, a->maximumRecordSize); reclist->records[reclist->num_records] = surrogatediagrec(a, freq.basename, 17, 0); reclist->num_records++; @@ -1225,7 +1226,6 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) Z_ListEntries *ents = (Z_ListEntries *) odr_malloc (assoc->encode, sizeof(*ents)); Z_DiagRecs *diagrecs_p = NULL; - oident *attent; oident *attset; bend_scan_rr *bsrr = (bend_scan_rr *) odr_malloc (assoc->encode, sizeof(*bsrr)); diff --git a/ztest/ztest.c b/ztest/ztest.c index e886866..645ebd8 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data. * See the file LICENSE for details. * - * $Id: ztest.c,v 1.49 2002-01-21 12:54:06 adam Exp $ + * $Id: ztest.c,v 1.50 2002-01-23 22:40:36 adam Exp $ */ /* @@ -504,7 +504,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) char *cp; r->errstring = 0; r->last_in_set = 0; - r->basename = "DUMMY"; + r->basename = "Default"; r->output_format = r->request_format; if (r->request_format == VAL_SUTRS) { @@ -534,6 +534,33 @@ int ztest_fetch(void *handle, bend_fetch_rr *r) return 0; } } + else if (r->request_format == VAL_POSTSCRIPT) + { + char fname[20]; + FILE *f; + long size; + + sprintf (fname, "part.%d.ps", r->number); + f = fopen(fname, "rb"); + if (!f) + { + r->errcode = 13; + return 0; + } + fseek (f, 0L, SEEK_END); + size = ftell (f); + if (size <= 0 || size >= 5000000) + { + r->errcode = 14; + return 0; + } + fseek (f, 0L, SEEK_SET); + r->record = odr_malloc (r->stream, size); + r->len = size; + r->output_format = VAL_POSTSCRIPT; + fread (r->record, size, 1, f); + fclose (f); + } else if ((cp = dummy_database_record(r->number, r->stream))) { r->len = strlen(cp); -- 1.7.10.4