X-Git-Url: http://git.indexdata.com/?p=yazpp-moved-to-github.git;a=blobdiff_plain;f=src%2Fyaz-my-client.cpp;h=f4879af23311b49e19720cf1830212a418c26c0d;hp=e359be36a4ef3f93f31ab56ee7c7d66e8add4439;hb=HEAD;hpb=d508100e993ab5c9a415bd1826b939875dcfe91c diff --git a/src/yaz-my-client.cpp b/src/yaz-my-client.cpp index e359be3..f4879af 100644 --- a/src/yaz-my-client.cpp +++ b/src/yaz-my-client.cpp @@ -1,10 +1,11 @@ -/* - * Copyright (c) 1998-2007, Index Data. +/* This file is part of the yazpp toolkit. + * Copyright (C) Index Data * See the file LICENSE for details. - * - * $Id: yaz-my-client.cpp,v 1.27 2007-04-12 15:00:33 adam Exp $ */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -90,7 +91,7 @@ void MyClient::failNotify() IPDU_Observer *MyClient::sessionNotify(IPDU_Observable *the_PDU_Observable, int fd) -{ +{ return new MyClient(the_PDU_Observable, m_socketManager); } @@ -113,14 +114,10 @@ void usage(char *prog) char *MyClient::get_cookie(Z_OtherInformation **otherInfo) { - Z_OtherInformationUnit *oi; - - const int *oid = - yaz_string_to_oid(yaz_oid_std(), CLASS_USERINFO, OID_STR_COOKIE); + Z_OtherInformationUnit *oi = + update_otherInformation(otherInfo, 0, yaz_oid_userinfo_cookie, 1, 1); - if (oid && - (oi = update_otherInformation(otherInfo, 0, oid, 1, 1)) && - oi->which == Z_OtherInfo_characterInfo) + if (oi && oi->which == Z_OtherInfo_characterInfo) return oi->information.characterInfo; return 0; } @@ -159,7 +156,7 @@ void MyClient::recv_diagrecs(Z_DiagRec **pp, int num) } else r = p->u.defaultFormat; - printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition)); + printf(" [" ODR_INT_PRINTF "] %s", *r->condition, diagbib1_str(*r->condition)); switch (r->which) { case Z_DefaultDiagFormat_v2Addinfo: @@ -196,7 +193,7 @@ void MyClient::recv_record(Z_DatabaseRecord *record, int offset, if (r->direct_reference) { char name_oid_str[OID_STR_MAX]; - const char *name_oid = yaz_oid_to_string_buf(r->direct_reference, 0, + const char *name_oid = yaz_oid_to_string_buf(r->direct_reference, 0, name_oid_str); printf("Record type: %s\n", name_oid ? name_oid : "unknown"); } @@ -226,7 +223,7 @@ void MyClient::recv_record(Z_DatabaseRecord *record, int offset, (size_t) r->u.sutrs->len); else if (r->which == Z_External_grs1) recv_genericRecord(r->u.grs1); - else + else { printf("Unknown record representation.\n"); if (!z_External(odr_print(), &r, 0, 0)) @@ -234,7 +231,7 @@ void MyClient::recv_record(Z_DatabaseRecord *record, int offset, odr_perror(odr_print(), "Printing external"); odr_reset(odr_print()); } - } + } } void MyClient::recv_namePlusRecord (Z_NamePlusRecord *zpr, int offset) @@ -283,7 +280,7 @@ void MyClient::recv_searchResponse(Z_SearchResponse *searchResponse) else { printf ("Ok\n"); - printf ("Hits: %d\n", *searchResponse->resultCount); + printf ("Hits: " ODR_INT_PRINTF "\n", *searchResponse->resultCount); } recv_records (searchResponse->records); } @@ -417,14 +414,14 @@ int MyClient::processCommand(const char *commandLine) {"proxy", &MyClient::cmd_proxy, ":[':']"}, {0,0,0} }; - + if (sscanf(commandLine, "%s %[^;]", cmdStr, cmdArgs) < 1) return 1; int i; for (i = 0; cmd[i].cmd; i++) if (!strncmp(cmd[i].cmd, cmdStr, strlen(cmdStr))) break; - + int res = 1; if (cmd[i].cmd) // Invoke command handler res = (this->*cmd[i].fun)(cmdArgs); @@ -453,7 +450,7 @@ const char *MyClient::getCommand() strncpy(m_thisCommand,line_in, 1023); m_thisCommand[1023] = '\0'; free (line_in); -#else +#else // Read using fgets(3) printf (C_PROMPT); fflush(stdout); @@ -558,6 +555,7 @@ int main(int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab