{
ODR out = getODROutputStream();
char *dbname = odr_strdup (out, databaseNames[0]);
-
+
/* Type: 1=reindex, 2=truncate, 3=delete, 4=create, 5=import, 6=refresh, 7=commit */
Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
r->u.adminService->which = Z_Admin_esRequest;
r->u.adminService->u.esRequest = (Z_AdminEsRequest *)
odr_malloc(out, sizeof(*r->u.adminService->u.esRequest));
-
+
toKeep = r->u.adminService->u.esRequest->toKeep =
- (Z_ESAdminOriginPartToKeep *)
+ (Z_ESAdminOriginPartToKeep *)
odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->toKeep));
-
+
toKeep->which=type;
toKeep->databaseName = dbname;
switch ( type )
case Z_ESAdminOriginPartToKeep_reIndex:
toKeep->u.reIndex=odr_nullval();
break;
-
+
case Z_ESAdminOriginPartToKeep_truncate:
toKeep->u.truncate=odr_nullval();
break;
/* Unknown admin service */
break;
}
-
+
notToKeep = r->u.adminService->u.esRequest->notToKeep =
(Z_ESAdminOriginPartNotToKeep *)
odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->notToKeep));
notToKeep->which=Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
notToKeep->u.recordsWillFollow=odr_nullval();
-
+
send_apdu(apdu);
-
+
return 0;
}
}
/* cmd_adm_truncate
- Truncate the specified database, removing all records and index entries, but leaving
+ Truncate the specified database, removing all records and index entries, but leaving
the database & it's explain information intact ready for new records */
int cmd_adm_truncate(const char *arg)
{
dir = opendir(dir_str);
if (!dir)
return 0;
-
+
sendAdminES(Z_ESAdminOriginPartToKeep_import, type_str);
-
+
printf ("sent es request\n");
if ((cp=strrchr(dir_str, '/')) && cp[1] == 0)
sep="";
-
+
while ((ent = readdir(dir)))
{
if (fnmatch (pattern_str, ent->d_name, 0) == 0)
char fname[1024];
struct stat status;
FILE *inf;
-
+
sprintf (fname, "%s%s%s", dir_str, sep, ent->d_name);
stat (fname, &status);
rec->u.intermediateFragment->which =
Z_FragmentSyntax_notExternallyTagged;
rec->u.intermediateFragment->u.notExternallyTagged = oct;
-
+
oct->len = oct->size = status.st_size;
oct->buf = (unsigned char *) odr_malloc (out, oct->size);
if (fread(oct->buf, 1, oct->size, inf) != (size_t) oct->size)
{
printf("Close failed for file %s\n", fname);
}
-
+
segment->segmentRecords[segment->num_segmentRecords++] = rec;
if (segment->num_segmentRecords == chunk)
send_apdu (apdu);
apdu = 0;
}
- }
+ }
}
}
if (apdu)
#endif
-/* "Freshen" the specified database, by checking metadata records against the sources from which they were
+/* "Freshen" the specified database, by checking metadata records against the sources from which they were
generated, and creating a new record if the source has been touched since the last extraction */
int cmd_adm_refresh(const char *arg)
{
return 0;
}
-/* cmd_adm_commit
+/* cmd_adm_commit
Make imported records a permenant & visible to the live system */
int cmd_adm_commit(const char *arg)
{
printf("CCL ERROR: %s\n", ccl_err_msg(error));
return 0;
}
- }
+ }
else if (myQueryType == QueryType_CQL2RPN)
{
/* ### All this code should be wrapped in a utility function */
sprintf(setstring, "%d", setnumber);
else
*setstring = '\0';
-
+
token_len = check_token(arg_c, "format");
if (token_len)
{
apdu->u.triggerResourceControlRequest;
bool_t rfalse = 0;
char command[16];
-
+
*command = '\0';
sscanf(arg, "%15s", command);
-
+
if (only_z3950())
return 0;
if (session_initResponse &&
*req->requestedAction = Z_TriggerResourceControlRequest_cancel;
req->resultSetWanted = &rfalse;
req->referenceId = set_refid(out);
-
+
send_apdu(apdu);
printf("Sent cancel request\n");
if (!strcmp(command, "wait"))
scan_query = last_scan_query;
scan_term = last_scan_line;
}
- else
+ else
{
strcpy(last_scan_query, arg);
scan_query = arg;
printf("Error use on or off\n");
return 1;
}
-
+
if (auto_reconnect)
printf("Set auto reconnect enabled.\n");
else
fprintf(stderr, "failed to allocate ODR streams\n");
exit(1);
}
-
+
strcpy(scan_position, "1");
setvbuf(stdout, 0, _IONBF, 0);
{
int i;
int wait_for = atoi(arg);
- if (wait_for < 1)
+ if (wait_for < 1)
wait_for = 1;
for (i = 0 ; i < wait_for; ++i )
/* ***************************************************************************
*
- * generic completer
- *
+ * generic completer
+ *
* ***************************************************************************/
char *complete_from_list(const char** completions,
const char *text, int state)
-{
+{
#if HAVE_READLINE_READLINE_H
static int idx;
-
- if (!completions)
+
+ if (!completions)
return NULL;
- if (state==0)
+ if (state==0)
idx = 0;
for(; completions[idx]; ++ idx) {
if(!
_strnicmp
#else
strncasecmp
-#endif
+#endif
(completions[idx],text,strlen(text))) {
- ++idx; /* skip this entry on the next run */
+ ++idx; /* skip this entry on the next run */
return (char*)strdup(completions[idx-1]);
};
};
/* ***************************************************************************
- *
+ *
* code for getting a list of valid strings from the oid subsystem
- *
+ *
* ***************************************************************************/
-
+
typedef struct {
int oclass;
/*!
This is the call back function given to oid_trav... it updates the list
- of pointers into the oid owned data
+ of pointers into the oid owned data
*/
void oid_loader(const Odr_oid *oid,
oid_class oclass, const char *name, void* data_)
{
oid_callback_t* data=(oid_callback_t*) data_;
-
+
if ((oclass == CLASS_GENERAL) || (oclass == data->oclass))
{
- if (data->index==data->max)
+ if (data->index==data->max)
{
data->values=(const char**)
realloc(data->values,((data->max+1)*2)*sizeof(char*));
data->max=(data->max+1)*2 - 1;
}
data->values[data->index] = name;
- ++data->index;
+ ++data->index;
}
}
const char** build_list_for_oclass(oid_class oclass)
-{
- oid_callback_t data;
+{
+ oid_callback_t data;
data.values = (const char **) calloc(10,sizeof(char*));
data.index = 0;
data.max = 9;
yaz_oid_trav(yaz_oid_std(), oid_loader, &data);
data.values[data.index]=0;
- return data.values;
+ return data.values;
}
/* ***************************************************************************
- *
- * the completer functions
- *
+ *
+ * the completer functions
+ *
* ***************************************************************************/
char* complete_querytype(const char *text, int state)
{
static const char* querytypes[] = {"ccl2rpn","prefix","cclrpn","ccl","cql", "cql2rpn", 0};
- return complete_from_list(querytypes,text,state);
+ return complete_from_list(querytypes,text,state);
}
char* complete_auto_reconnect(const char *text, int state)
{
static const char* querytypes[] = {"on","off",0};
- return complete_from_list(querytypes,text,state);
+ return complete_from_list(querytypes,text,state);
}
char* complete_format(const char* text, int state)
{
const char** list = build_list_for_oclass(CLASS_RECSYN);
- char* res=complete_from_list(list,text,state);
-
- free(list);
+ char* res=complete_from_list(list,text,state);
+
+ free(list);
return res;
}
char* complete_schema(const char* text, int state)
{
const char** list = build_list_for_oclass(CLASS_SCHEMA);
- char* res = complete_from_list(list,text,state);
-
- free(list);
+ char* res = complete_from_list(list,text,state);
+
+ free(list);
return res;
}
char* complete_attributeset(const char* text, int state)
{
const char** list = build_list_for_oclass(CLASS_ATTSET);
- char* res = complete_from_list(list,text,state);
-
- free(list);
+ char* res = complete_from_list(list,text,state);
+
+ free(list);
return res;
}
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
+/*
This file contains the compleaters for the different commands.
*/
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
+/**
* \file backend.h
* \brief Header for GFS
*
#include <yaz/oid_db.h>
YAZ_BEGIN_CDECL
-
+
typedef struct association *bend_association;
/** \brief Information for Z39.50/SRU search handler
int delete_status; /**< status for the whole operation */
int *statuses; /**< status each set - indexed as setnames */
ODR stream;
- ODR print;
+ ODR print;
} bend_delete_rr;
/** \brief Information for Z39.50 sort handler */
{
int ItemNo;
Z_ExtendedServicesRequest *esr;
-
+
ODR stream; /* encoding stream */
ODR decode; /* decoding stream */
ODR print; /* printing stream */
This includes both request
information (to be read) and response information which should be
-set by the bend_init handler
+set by the bend_init handler
*/
typedef struct bend_initrequest
{
/** \brief user/name/password to be read */
- Z_IdAuthentication *auth;
+ Z_IdAuthentication *auth;
/** \brief encoding stream (for results) */
ODR stream;
/** \brief printing stream */
ODR print;
/** \brief decoding stream (use stream for results) */
- ODR decode;
+ ODR decode;
/** \brief reference ID */
Z_ReferenceId *referenceId;
/** \brief peer address of client */
- char *peer_name;
-
- /** \brief character set and language negotiation
+ char *peer_name;
- see include/yaz/z-charneg.h
+ /** \brief character set and language negotiation
+
+ see include/yaz/z-charneg.h
*/
Z_CharSetandLanguageNegotiation *charneg_request;
/** \brief character negotiation response */
Z_External *charneg_response;
- /** \brief character set (encoding) for query terms
-
+ /** \brief character set (encoding) for query terms
+
This is NULL by default. It should be set to the native character
set that the backend assumes for query terms */
- char *query_charset;
+ char *query_charset;
+
+ /** \brief whehter query_charset also applies to recors
- /** \brief whehter query_charset also applies to recors
-
Is 0 (No) by default. Set to 1 (yes) if records is in the same
character set as queries. If in doubt, use 0 (No).
*/
char apdufile[ODR_MAXNAME+1]; /**< file for pretty-printed PDUs */
char logfile[ODR_MAXNAME+1]; /**< file for diagnostic output */
char default_listen[1024]; /**< 0 == no default listen */
- enum oid_proto default_proto; /**< PROTO_SR or PROTO_Z3950 */
+ enum oid_proto default_proto; /**< PROTO_SR or PROTO_Z3950 */
int idle_timeout; /**< how many minutes to wait before closing */
int maxrecordsize; /**< maximum value for negotiation */
char configname[ODR_MAXNAME+1]; /**< given to the backend in bend_init */
#define YAZ_BASE64_H
#include <yaz/yconfig.h>
-
+
YAZ_BEGIN_CDECL
/** \brief encodes Base64 string
#include <yaz/wrbuf.h>
YAZ_BEGIN_CDECL
-
+
#define CCL_ERR_OK 0
#define CCL_ERR_TERM_EXPECTED 1
#define CCL_ERR_RP_EXPECTED 2
#define CCL_ERR_TRUNC_NOT_RIGHT 12
#define CCL_ERR_TRUNC_NOT_EMBED 13
#define CCL_ERR_TRUNC_NOT_SINGLE 14
-
+
/** \brief attribute node (type, value) pair as used in RPN */
struct ccl_rpn_attr {
/** \brief next attribute */
/** \brief CCL parser */
typedef struct ccl_parser *CCL_parser;
-
+
/**
\brief parse CCL find string using CCL profile return RPN tree
-
+
Parses a CCL Find command in a simple C string. Returns CCL parse
tree node describing RPN if parsing is successful. If parsing is
unsuccesful, NULL is returned and error and pos is set accordingly.
/**
\brief parse CCL find string with parser and return RPN tree
-
+
Parses a CCL Find command in a simple C string. Returns CCL parse
tree node describing RPN if parsing is successful. If parsing is
unsuccesful, NULL is returned and error and pos is set accordingly.
3 key
4 year
5 date (normalized)
- 6 word list
+ 6 word list
100 date (un-normalized)
101 name (normalized)
102 name (un-normalized)
- truncation (5)
+ truncation (5)
completeness (6)
*/
\param addinfo has error message if configuration could not be parsed
\retval 0 OK
\retval -1 errors. Inspect addinfo for error message
-
+
Configuration example:
\verbatim
<cclmap defaultattrset="bib-1">
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
+/**
* \file charneg.h
* \brief Header for Z39.50 Charset negotiation utilities
*
* client and server parts. At that moment the (*) is based on
* Z_PrivateCharacterSet_externallySpecified method.
*
- */
+ */
/*
* Get (*) record from request
int yaz_del_charneg_record(Z_OtherInformation **p);
/*
- * Client's part.
+ * Client's part.
*/
YAZ_EXPORT
Z_External *yaz_set_proposal_charneg(ODR odr,
/*
* Server's part
*/
-
+
YAZ_EXPORT
Z_External *yaz_set_response_charneg(ODR odr,
const char *charset, const char *lang,
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
+/**
* \file comstack.h
* \brief Header for COMSTACK
*/
#define cs_want_read(handle) ((handle)->io_pending & CS_WANT_READ)
#define cs_want_write(handle) ((handle)->io_pending & CS_WANT_WRITE)
#define cs_set_blocking(handle,blocking) ((handle)->f_set_blocking(handle, blocking))
-
+
#define CS_WANT_READ 1
#define CS_WANT_WRITE 2
YAZ_EXPORT int cs_look (COMSTACK);
YAZ_EXPORT const char *cs_strerror(COMSTACK h);
YAZ_EXPORT const char *cs_errmsg(int n);
-YAZ_EXPORT COMSTACK cs_create_host(const char *type_and_host,
+YAZ_EXPORT COMSTACK cs_create_host(const char *type_and_host,
int blocking, void **vp);
YAZ_EXPORT COMSTACK cs_create_host_proxy(const char *vhost,
/*
* error management.
*/
-
+
#define CSNONE 0
#define CSYSERR 1
#define CSOUTSTATE 2
/** \brief creates a CQL parser.
\returns CCL parser
-
+
Returns CQL parser or NULL if parser could not be created.
*/
-YAZ_EXPORT
+YAZ_EXPORT
CQL_parser cql_parser_create(void);
/** \brief destroys a CQL parser.
This function does nothing if NULL if received.
*/
-YAZ_EXPORT
+YAZ_EXPORT
void cql_parser_destroy(CQL_parser cp);
/** \brief parses a CQL query (string)
\retval 0 success
\retval !=0 failure
*/
-YAZ_EXPORT
+YAZ_EXPORT
int cql_parser_string(CQL_parser cp, const char *str);
/** \brief parses CQL query (query stream)
\param client_data data to be passed to stream functions
\retval 0 success
\retval !=0 failure
-
+
This function is similar to cql_parser_string but takes a
functions to read each query character from a stream.
-
+
The functions pointers getbytes, ungetbyte are similar to
that known from stdios getc, ungetc.
*/
-YAZ_EXPORT
+YAZ_EXPORT
int cql_parser_stream(CQL_parser cp,
int (*getbyte)(void *client_data),
void (*ungetbyte)(int b, void *client_data),
\param f file where query is read from
\retval 0 success
\retval !=0 failure
-
- This function is similar to cql_parser_string but reads from
+
+ This function is similar to cql_parser_string but reads from
stdio FILE handle instead.
*/
YAZ_EXPORT
char *value;
/** left operand */
struct cql_node *left;
- /** right operand */
+ /** right operand */
struct cql_node *right;
/** modifiers (NULL for no list) */
struct cql_node *modifiers;
\param client_data data to be passed to pr function
*/
YAZ_EXPORT
-void cql_to_xml(struct cql_node *cn,
+void cql_to_xml(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data);
/** \brief converts CQL tree to XCQL and writes to file
\param client_data data to be passed to pr function
*/
YAZ_EXPORT
-int cql_to_ccl(struct cql_node *cn,
+int cql_to_ccl(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data);
YAZ_EXPORT
int cql_transform_define_pattern(cql_transform_t ct, const char *pattern,
const char *value);
-
+
/** \brief destroys a CQL transform handle
\param cn CQL tree
\param pr print function
\param client_data data to be passed to pr function
-
+
This will take CQL_NODE_SORT entries and conver them to
path,schema,ascending,caseSensitive,missingValue
void (*pr)(const char *buf, void *client_data),
void *client_data);
-/** \brief converts CQL sortby to sortkeys ..
+/** \brief converts CQL sortby to sortkeys ..
\param cn CQL tree
\param out result buffer
\param max size of buffer (allocated)
Flag YAZ_DAEMON_DEBUG: Puts the service in debug mode (no fork at all).
- Flag YAZ_DAEMON_KEEPALIVE: Repeatedly calls work handler if it makes a
+ Flag YAZ_DAEMON_KEEPALIVE: Repeatedly calls work handler if it makes a
"fatal" error.
*/
YAZ_EXPORT
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/** \file
+/** \file
\brief wrapper for dirent.h or our own for Windows
*/
YAZ_BEGIN_CDECL
-/** \brief returns errno
- \returns errno value
+/** \brief returns errno
+ \returns errno value
*/
YAZ_EXPORT int yaz_errno(void);
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/** \file
+/** \file
\brief File globbing (ala POSIX glob, but simpler)
*/
/** \brief release glob result
\param res pointer to glob result
-
+
A value of *res == NULL is allowed. If *res != NULL, then
*res is set to NULL
*/
\retval 1 success
*/
YAZ_EXPORT int icu_chain_assign_cstr(yaz_icu_chain_t chain,
- const char * src8cstr,
+ const char * src8cstr,
UErrorCode *status);
/** \brief returns one token (if any)
/** \brief starts iteration over string
\param iter ICU tokenizer iterator
\param src8cstr input string (0-terminated)
-
+
Call icu_iter_next to iterate over each token.
*/
YAZ_EXPORT
UErrorCode *status);
void icu_sortkey8_from_utf16(UCollator *coll,
- struct icu_buf_utf8 * dest8,
+ struct icu_buf_utf8 * dest8,
struct icu_buf_utf16 * src16,
UErrorCode * status);
struct icu_tokenizer *icu_tokenizer_clone(struct icu_tokenizer *old);
void icu_tokenizer_destroy(struct icu_tokenizer * tokenizer);
-int icu_tokenizer_attach(struct icu_tokenizer * tokenizer,
+int icu_tokenizer_attach(struct icu_tokenizer * tokenizer,
struct icu_buf_utf16 * src16, UErrorCode *status);
-int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer,
- struct icu_buf_utf16 * tkn16,
+int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer,
+ struct icu_buf_utf16 * tkn16,
UErrorCode *status);
int32_t icu_tokenizer_token_count(struct icu_tokenizer * tokenizer);
void *clientData;
const char *(*f)(void *clientData, const char *element);
};
-
+
YAZ_EXPORT ILL_ItemRequest *ill_get_ItemRequest (
struct ill_get_ctl *gs, const char *name, const char *sub);
struct json_node {
enum json_node_type type;
union {
- char *string;
- double number;
+ char *string;
+ double number;
struct json_node *link[2];
} u;
};
/** \brief returns parser error
\param p JSON parser handle
- \returns parse error msg
+ \returns parse error msg
This function should be called if json_parser_parse returns NULL .
*/
/** \brief log level: append thread Id */
#define YLOG_TID 0x00000020
/** \brief log level: application */
-#define YLOG_APP 0x00000040
+#define YLOG_APP 0x00000040
/** \brief log level: malloc debug */
#define YLOG_MALLOC 0x00000080
/** \brief log level: do not output date and time */
#define YLOG_NOTIME 0x00000100
/** \brief log level: application 2 */
-#define YLOG_APP2 0x00000200
+#define YLOG_APP2 0x00000200
/** \brief log level: application 3 */
#define YLOG_APP3 0x00000400
/** \brief log level: flush */
*/
YAZ_EXPORT void yaz_log_init_level(int level);
-/** \brief sets log message prefix
+/** \brief sets log message prefix
\param prefix log message prefix
*/
YAZ_EXPORT void yaz_log_init_prefix(const char *prefix);
*/
YAZ_EXPORT void yaz_log_time_format(const char *fmt);
-/** \brief sets limit in bytes for size for log file
+/** \brief sets limit in bytes for size for log file
\param mx size in bytes
Sets the max size for a log file. Zero means no limit.
/** \brief Writes log message
\param level log level mask
\param fmt format string ala printf
-
+
Writes an entry in the log. Defaults to stderr if not initialized or
to a file with yaz_log_init_file(). The level must match the level set
via yaz_log_init_level(), optionally defined via yaz_log_mask_str().
/** \brief converts log level string to log level (integer)
\param str log level string
\return log level mask
-
+
yaz_log_mask_str() converts a comma-separated list of log levels to a
bit mask. Starts from default level, and adds bits as specified,
unless 'none' is specified, which clears the list. If a name matches
the name of a YLOG_BIT above, that one is set. Otherwise a new value is
- picked, and given to that name, to be found with yaz_log_module_level()
+ picked, and given to that name, to be found with yaz_log_module_level()
*/
YAZ_EXPORT int yaz_log_mask_str(const char *str);
/** \brief sets custom log handler
\param func custom log handler
\param info custom pointer to be passed to func handler
-
+
Allows log output to be captured to something else.. The
func parameter takes a log level, a message + custom pointer
*/
YAZ_EXPORT void log_rpn_query_level(int loglevel, Z_RPNQuery *rpn);
YAZ_EXPORT void log_scan_term(Z_AttributesPlusTerm *zapt, const Odr_oid *ast);
-YAZ_EXPORT void log_scan_term_level(int loglevel,
+YAZ_EXPORT void log_scan_term_level(int loglevel,
Z_AttributesPlusTerm *zapt,
const Odr_oid *ast);
YAZ_EXPORT void yaz_log_zquery(Z_Query *q);
/** \brief destroy yaz_marc_t handle */
YAZ_EXPORT void yaz_marc_destroy(yaz_marc_t mt);
-/** \brief set XML mode YAZ_MARC_LINE, YAZ_MARCXML, YAZ_MARC_ISO2709 ..
+/** \brief set XML mode YAZ_MARC_LINE, YAZ_MARCXML, YAZ_MARC_ISO2709 ..
\param mt MARC handle
\param xmlmode mode.
/** \brief supply iconv handle for character set conversion */
YAZ_EXPORT yaz_iconv_t yaz_marc_get_iconv(yaz_marc_t mt);
-/** \brief set debug level
+/** \brief set debug level
\param mt handle
- \param level level, where 0=lowest, 1 more debug, 2 even more
+ \param level level, where 0=lowest, 1 more debug, 2 even more
*/
YAZ_EXPORT void yaz_marc_debug(yaz_marc_t mt, int level);
\param rsize size of result (memory "owned" by yaz_marc_mt handle)
Decodes MARC in buf of size bsize.
- On success, result in *result with size *rsize.
+ On success, result in *result with size *rsize.
Returns -1 on error, or size of input record (>0) if OK
*/
YAZ_EXPORT int yaz_marc_decode_buf(yaz_marc_t mt, const char *buf, int bsize,
Parses MARC line record from stream
Returns > 0 for OK (same as length), -1=ERROR
*/
-YAZ_EXPORT
+YAZ_EXPORT
int yaz_marc_read_line(yaz_marc_t mt,
int (*getbyte)(void *client_data),
void (*ungetbyte)(int b, void *client_data),
void *client_data);
#if YAZ_HAVE_XML2
-/** \brief parses MARCXML/MarcXchange/TurboMARC record from xmlNode pointer
+/** \brief parses MARCXML/MarcXchange/TurboMARC record from xmlNode pointer
\param mt handle
- \param ptr is a pointer to root xml node
+ \param ptr is a pointer to root xml node
\retval 0 OK
\retval -1 ERROR
*/
\retval -1 ERROR
This function calls yaz_marc_write_iso2709, yaz_marc_write_marcxml,
- etc.. depending on mode given by yaz_marc_xml.
-*/
+ etc.. depending on mode given by yaz_marc_xml.
+*/
YAZ_EXPORT int yaz_marc_write_mode(yaz_marc_t mt, WRBUF wrbuf);
#if YAZ_HAVE_XML2
\param type MarcXchange format (NULL for none)
\retval 0 Creation successful and *root_ptr is "record" node
\retval -1 ERROR
-*/
+*/
YAZ_EXPORT
int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr,
- const char *ns,
+ const char *ns,
const char *format,
const char *type);
#endif
\param leader_spec
\retval 0 OK
\retval -1 ERROR
-
+
Spec takes form pos=val,pos=val,...
where value is either a number (decimal char value) or a
string in 'a', e.g. 9='a'
-
-*/
+
+*/
YAZ_EXPORT int yaz_marc_leader_spec(yaz_marc_t mt, const char *leader_spec);
\param identifier_length identifier length (returned value)
\param base_address base address (returned value)
\param length_data_entry length of data entry (returned value)
- \param length_starting length of starting
+ \param length_starting length of starting
\param length_implementation length of implementation defined data
*/
YAZ_EXPORT
/** \brief adds MARC comment string
\param mt handle
\param comment comment to be added)
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_comment(yaz_marc_t mt, char *comment);
/** \brief adds MARC annotation - printf interface
\param mt handle
\param fmt printf format string
-*/
+*/
YAZ_EXPORT
void yaz_marc_cprintf(yaz_marc_t mt, const char *fmt, ...);
\param mt handle
\param code_data code data buffer
\param code_data_len length of code data
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_subfield(yaz_marc_t mt,
const char *code_data, size_t code_data_len);
\param tag (e.g. "001"
\param data value for this tag
\param data_len length of data
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag,
const char *data, size_t data_len);
\param mt handle
\param ptr_tag value of tag (TEXT xmlNode)
\param ptr_data value of data (TEXT xmlNode)
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_controlfield_xml(yaz_marc_t mt, const xmlNode *ptr_tag,
const xmlNode *ptr_data);
\param mt handle
\param tag string tag
\param ptr_data value of data (TEXT xmlNode)
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_controlfield_xml2(yaz_marc_t mt, char *tag,
const xmlNode *ptr_data);
\param tag value of tag as string
\param indicator indicator string
\param indicator_len length of indicator string
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag,
const char *indicator, size_t indicator_len);
\param ptr_tag value of tag (TEXT xmlNode)
\param indicator indicator string
\param indicator_len length of indicator string
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_datafield_xml(yaz_marc_t mt, const xmlNode *ptr_tag,
const char *indicator, size_t indicator_len);
\param mt handle
\param tag_value string value (pointer copied verbatim, not strdupped)
\param indicators indicator string ; pointer copied verbatim; not strdupped
-*/
+*/
YAZ_EXPORT
void yaz_marc_add_datafield_xml2(yaz_marc_t mt, char *tag_value,
char *indicators);
/** \brief returns memory for MARC handle
\param mt handle
\retval NMEM handle for MARC system
-*/
+*/
YAZ_EXPORT
NMEM yaz_marc_get_nmem(yaz_marc_t mt);
/** \brief clears memory and MARC record
\param mt handle
-*/
+*/
YAZ_EXPORT
void yaz_marc_reset(yaz_marc_t mt);
/** \brief gets debug level for MARC system
\param mt handle
-*/
+*/
YAZ_EXPORT
int yaz_marc_get_debug(yaz_marc_t mt);
\param arg string
\retval -1 unknown format (bad arg)
\retval >= 0 OK (one of YAZ_MARC - values)
-*/
+*/
YAZ_EXPORT
int yaz_marc_decode_formatstr(const char *arg);
-/** \brief Enables or disables writing of MARC XML records using Libxml2
+/** \brief Enables or disables writing of MARC XML records using Libxml2
\param mt handle
\param enable 0=disable, 1=enable
-*/
+*/
YAZ_EXPORT
void yaz_marc_write_using_libxml2(yaz_marc_t mt, int enable);
\param mt handle
\param r OPAC record
\param wrbuf WRBUF for resulting display string
-
+
This function uses iconv_handle of yaz_marc_t for character set
conversion of both OPAC + ISO2709 part.
\*/
\param wr WRBUF for output
\retval 0 OK
\retval -1 ERROR
-*/
+*/
YAZ_EXPORT int yaz_marc_write_trailer(yaz_marc_t mt, WRBUF wr);
/** \brief enables record collection output
\param mt handle
-*/
+*/
YAZ_EXPORT void yaz_marc_enable_collection(yaz_marc_t mt);
YAZ_END_CDECL
/** \brief create MUTEX
\param mutexp is pointer to MUTEX handle (*mutexp must be NULL)
-
+
It is important that *mutexp is NULL. If not, yaz_mutex_create will
not modify the handle (assumes it is already created!)
*/
/** \brief creates condition variable
\param p reference to condition handle
-
+
Upon successful completion *p holds the condition handle; *p = 0
on error.
*/
/** \brief destroys condition variable
\param p reference to condition handle
-
+
Upon completion *p holds 0.
*/
YAZ_EXPORT
/** \brief BER/utility boolean */
typedef int nmem_bool_t;
-/** \brief releases memory associaged with an NMEM handle
+/** \brief releases memory associaged with an NMEM handle
\param n NMEM handle
*/
YAZ_EXPORT void nmem_reset(NMEM n);
*/
YAZ_EXPORT size_t nmem_total(NMEM n);
-/** \brief allocates string on NMEM handle (similar strdup)
+/** \brief allocates string on NMEM handle (similar strdup)
\param mem HNEM handle
\param src string
\returns duplicated string
/** \brief allocates sub strings out of string using certain delimitors
\param nmem NMEM handle
- \param delim delimitor chars (splits on each char in there)
+ \param delim delimitor chars (splits on each char in there)
\param dstr string to be split
\param darray result string array for each sub string
\param num number of result strings
/** \brief allocates sub strings out of string using certain delimitors
\param nmem NMEM handle
- \param delim delimitor chars (splits on each char in there)
+ \param delim delimitor chars (splits on each char in there)
\param dstr string to be split
\param darray result string array for each sub string
\param num number of result strings
/** \brief allocates sub strings out of string using certain delimitors
\param nmem NMEM handle
- \param delim delimitor chars (splits on each char in there)
+ \param delim delimitor chars (splits on each char in there)
\param dstr string to be split
\param darray result string array for each sub string
\param num number of result strings
/** \brief allocates sub strings out of string using certain delimitors
\param nmem NMEM handle
- \param delim delimitor chars (splits on each char in there)
+ \param delim delimitor chars (splits on each char in there)
\param dstr string to be split
\param darray result string array for each sub string
\param num number of result strings
*/
YAZ_EXPORT void nmem_transfer(NMEM dst, NMEM src);
-/** \brief returns new NMEM handle
+/** \brief returns new NMEM handle
\returns NMEM handle
*/
YAZ_EXPORT NMEM nmem_create(void);
union
{
Odr_any *single_ASN1_type;
- Odr_oct *octet_aligned;
+ Odr_oct *octet_aligned;
Odr_bitmask *arbitrary; /* we aren't really equipped for this*/
} u;
} Odr_external;
YAZ_EXPORT int odr_set_charset(ODR o, const char *to, const char *from);
YAZ_EXPORT void odr_set_stream(ODR o, void *handle,
- void (*stream_write)(ODR o,
+ void (*stream_write)(ODR o,
void *handle,
int type,
const char *buf,
CLASS_GENERAL,
CLASS_NEGOT
} oid_class;
-
-/** \brief returns standard OID database
+
+/** \brief returns standard OID database
\retval OID database handle
*/
YAZ_EXPORT
/** \brief maps named OID string to raw OID by database lookup
\param oid_db OID database
- \param oclass class of string (enum oid_class)
+ \param oclass class of string (enum oid_class)
\param name OID name
\returns raw OID or NULL if name is unknown (bad)
/** \brief creates NMEM malloc'ed OID from string
\param oid_db OID database
- \param oclass class of string (enum oid_class)
+ \param oclass class of string (enum oid_class)
\param name OID name
\param nmem memory for returned OID
\returns raw OID or NULL if name is unknown (bad)
/** \brief creates ODR malloc'ed OID from string
\param oid_db OID database
- \param oclass class of string (enum oid_class)
+ \param oclass class of string (enum oid_class)
\param name OID name
\param odr memory for returned OID
\returns raw OID or NULL if name is unknown (bad)
\param oid raw OID
\param oclass holds OID class if found (output parameter)
\param buf string buffer for result (must be of size OID_STR_MAX)
- \returns OID string (named or dot notatition)
+ \returns OID string (named or dot notatition)
*/
YAZ_EXPORT
const char *yaz_oid_to_string_buf(const Odr_oid *oid,
\retval -1 unknown option (error). arg is name of unknown option
\retval -2 no more options (end of options)
\retval c option char
-
+
This function is called repeatedly for each option. Both single
char options (-x) as well as GNU long options are supported (--long).
- The description is a sequence specs where each spec is if the form:
+ The description is a sequence specs where each spec is if the form:
[a-zA-Z0-9]({[a-zA-Z0-9]*})+:? . For example: h{help}f{filename}{fname}:
The first char is what is returned when met (single char option char).
YAZ_END_CDECL
#endif
-
+
/*
* Local variables:
* c-basic-offset: 4
void *client_data;
};
-/** \brief poll wrapper for poll or select
+/** \brief poll wrapper for poll or select
\param fds array of sockets to be polled
\param num_fds size of fds array (number of sockets)
\param sec number of seconds to wait (-1 for no timeout)
YAZ_EXPORT int yaz_pqf_error(YAZ_PQF_Parser p, const char **msg, size_t *off);
-YAZ_EXPORT
+YAZ_EXPORT
Z_Term *z_Term_create(ODR o, int term_type, const char *buf, size_t len);
#define Z_RES_INTERIM Z_SearchResponse_interim
#define Z_RES_NONE Z_SearchResponse_none
-#define Z_SortStatus_success Z_SortResponse_success
+#define Z_SortStatus_success Z_SortResponse_success
#define Z_SortStatus_partial_1 Z_SortResponse_partial_1
#define Z_SortStatus_failure Z_SortResponse_failure
-#define Z_SortRelation_ascending Z_SortKeySpec_ascending
+#define Z_SortRelation_ascending Z_SortKeySpec_ascending
#define Z_SortRelation_descending Z_SortKeySpec_descending
#define Z_SortRelation_ascendingByFreq Z_SortKeySpec_ascendingByFrequency
-#define Z_SortRelation_descendingByFreq Z_SortKeySpec_descendingByfrequency
+#define Z_SortRelation_descendingByFreq Z_SortKeySpec_descendingByfrequency
#define Z_SortCase_caseSensitive Z_SortKeySpec_caseSensitive
#define Z_SortCase_caseInsensitive Z_SortKeySpec_caseInsensitive
#include <yaz/yconfig.h>
YAZ_BEGIN_CDECL
-
+
YAZ_EXPORT int readconf(char *name, void *rprivate,
int (*fun)(char *name, void *rprivate,
int argc, char *argv[]));
YAZ_EXPORT int readconf_line(FILE *f, int *lineno,
char *line, int len, char *argv[], int num);
-
+
YAZ_END_CDECL
#endif
\retval -1 failure
On failure, use yaz_record_conv_get_error to get error string.
-
+
\verbatim
<backend syntax='xml'>
<xslt stylesheet="dc2marcxml.xsl"/>
/** returns error string (for last error)
\param p record conversion handle
\return error string
-*/
+*/
YAZ_EXPORT
const char *yaz_record_conv_get_error(yaz_record_conv_t p);
/** set path for opening stylesheets etc.
\param p record conversion handle
\param path file path (UNIX style with : / Windows with ;)
-*/
+*/
YAZ_EXPORT
void yaz_record_conv_set_path(yaz_record_conv_t p, const char *path);
/** adds a type to our conversion handler
\param p record conversion handle
\param type info
-*/
+*/
YAZ_END_CDECL
\retval -1 failure
On failure, call yaz_retrieval_get_error to get error string.
-
+
For retrieval:
\verbatim
<retrievalinfo>
/** returns error string (for last error)
\param p record conversion handle
\return error string
-*/
+*/
YAZ_EXPORT
const char *yaz_retrieval_get_error(yaz_retrieval_t p);
/** set path for opening stylesheets etc.
\param p record conversion handle
\param path file path (UNIX style with : / Windows with ;)
-*/
+*/
YAZ_EXPORT
void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path);
\returns pattern value or NULL if not found
*/
YAZ_EXPORT
-const char *cql_lookup_reverse(cql_transform_t ct,
+const char *cql_lookup_reverse(cql_transform_t ct,
const char *category,
Z_AttributeList *attributes);
/** \file sc.h
\brief Header for Windows Service Control utility
-
+
This is a simple wrapper for the Windows Service Control system. It
also operates on Unix in which case the user supplied main function
(sc_main) is is called immediately. See sc_test.c for an example.
/** \brief frees service control handle
\param s service control handle
-*/
+*/
YAZ_EXPORT void yaz_sc_destroy(yaz_sc_t *s);
YAZ_END_CDECL
YAZ_EXPORT void yaz_snprintf(char *buf, size_t size, const char *fmt, ...);
YAZ_EXPORT void yaz_vsnprintf(char *buf, size_t size, const char *fmt,
va_list ap);
-
+
YAZ_END_CDECL
#endif
Z_SOAP_fun f;
} Z_SOAP_Handler;
-YAZ_EXPORT int z_soap_codec(ODR o, Z_SOAP **pp,
+YAZ_EXPORT int z_soap_codec(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers);
-YAZ_EXPORT int z_soap_codec_enc(ODR o, Z_SOAP **pp,
+YAZ_EXPORT int z_soap_codec_enc(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers,
const char *encoding);
-YAZ_EXPORT int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
+YAZ_EXPORT int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers,
const char *encoding,
/** \brief creates a SOLR parser.
\returns CCL parser
-
+
Returns SOLR parser or NULL if parser could not be created.
*/
-YAZ_EXPORT
+YAZ_EXPORT
SOLR_parser solr_parser_create(void);
/** \brief destroys a SOLR parser.
This function does nothing if NULL if received.
*/
-YAZ_EXPORT
+YAZ_EXPORT
void solr_parser_destroy(SOLR_parser cp);
/** \brief parses a SOLR query (string)
\retval 0 success
\retval !=0 failure
*/
-YAZ_EXPORT
+YAZ_EXPORT
int solr_parser_string(SOLR_parser cp, const char *str);
/** \brief parses SOLR query (query stream)
\param client_data data to be passed to stream functions
\retval 0 success
\retval !=0 failure
-
+
This function is similar to solr_parser_string but takes a
functions to read each query character from a stream.
-
+
The functions pointers getbytes, ungetbyte are similar to
that known from stdios getc, ungetc.
*/
-YAZ_EXPORT
+YAZ_EXPORT
int solr_parser_stream(SOLR_parser cp,
int (*getbyte)(void *client_data),
void (*ungetbyte)(int b, void *client_data),
\param f file where query is read from
\retval 0 success
\retval !=0 failure
-
+
This function is similar to solr_parser_string but reads from
stdio FILE handle instead.
*/
char *value;
/** left operand */
struct solr_node *left;
- /** right operand */
+ /** right operand */
struct solr_node *right;
/** modifiers (NULL for no list) */
struct solr_node *modifiers;
YAZ_EXPORT
int solr_transform_define_pattern(solr_transform_t ct, const char *pattern,
const char *value);
-
+
/** \brief destroys a SOLR transform handle
\param odr memory for result
\param arg sort spec string
\returns Z39.50 SortKeySpecList or NULL on error
-
+
The sort spec list is of the form:
- (field flags)+
+ (field flags)+
where field is either a string or one or more attribute pairs
key=value (there must be no blanks in either field of flags).
flags is a character list:
sS : respectcase / case-sensitive
! : abort of key is omitted in result
=value : missing value
-
+
Examples:
title a
char *details;
char *message;
} Z_SRW_diagnostic;
-
+
typedef struct {
#define Z_SRW_query_type_cql 1
Odr_int *numberOfRecords;
char * resultSetId;
Odr_int *resultSetIdleTime;
-
+
Z_SRW_record *records;
int num_records;
int num_diagnostics;
Z_SRW_extra_record *extra_record;
} Z_SRW_explainResponse;
-
+
typedef struct {
int query_type;
union {
Z_SOAP **soap_package, ODR decode, char **charset);
YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
- Z_SOAP **soap_package, ODR decode,
+ Z_SOAP **soap_package, ODR decode,
char **charset,
Z_SRW_diagnostic **, int *num_diagnostic);
YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
int *num, int code,
const char *addinfo);
-
+
YAZ_EXPORT void yaz_add_sru_update_diagnostic(ODR o, Z_SRW_diagnostic **d,
int *num, int code,
const char *addinfo);
-YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
+YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
int code, const char *details);
YAZ_EXPORT void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
const char *message,
const char *details);
-YAZ_EXPORT void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
+YAZ_EXPORT void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
const char *uri, const char *message,
const char *details);
/** \brief encode SRU database for HTTP path
\param dst destination buffer (should be at least strlen(db) +2 in size)
\param db source database
-
+
The resulting database (dst) includes a leading /
*/
YAZ_EXPORT
} \
}
-/** \brief a test we know will fail at this time.
+/** \brief a test we know will fail at this time.
*
* Later, when the bug is fixed, this test will suddenly pass,
- * which will be reported as an error, to remind you to go and fix
+ * which will be reported as an error, to remind you to go and fix
* your tests.
*/
do_work();
yaz_timing_stop(my);
- printf("real=%g user=%g sys=%g\n",
+ printf("real=%g user=%g sys=%g\n",
yaz_timing_get_real(my),
yaz_timing_get_user(my),
yaz_timing_get_sys(my));
/** \brief stop timer
\param t timing handle
-
+
Use yaz_timing_get_real, yaz_timing_get_user and yaz_timing_get_sys
to fetch timing results.
*/
\param comp upon pointer to component (if component is found)
\retval 0 no component found (and no more componennts)
\retval >0 length of component (length of *comp)
-
+
A filepath has components separted by colon. For example
/usr/lib/modules:c:/my:/:lib
which has these components
YAZ_EXPORT size_t yaz_filepath_comp(const char **path_p, const char **comp);
-/** \brief resolve file on path
+/** \brief resolve file on path
\param fname "short" filename (without path)
\param path the path (dir1:dir2,..) - ala Unix
\param base can be added to relative paths (NULL for no append)
const char *base, char *fullpath);
-/** \brief opens first file in path in path
+/** \brief opens first file in path in path
\param fname "short" filename (without path)
\param mode mode as in fopen(3)
\param path the path (dir1:dir2,..) - ala Unix
YAZ_EXPORT FILE *yaz_fopen(const char *path, const char *fname,
const char *mode, const char *base);
-/** \brief opens first file in path in path
+/** \brief opens first file in path in path
\param fname "short" filename (without path)
\param mode mode as in fopen(3)
\param path the path (dir1:dir2,..) - ala Unix
/** \brief destroys a URL fetcher
\param p handle
-
+
Note: OK to pass NULL as p
*/
YAZ_EXPORT void yaz_url_destroy(yaz_url_t p);
/** \brief destroy WRBUF and its buffer
\param b WRBUF
-
+
For YAZ 4.0.2 WRBUF b may be NULL.
*/
YAZ_EXPORT void wrbuf_destroy(WRBUF b);
\param from character "from"
\param to charcter "to"
*/
-YAZ_EXPORT void wrbuf_puts_replace_char(WRBUF b, const char *buf,
+YAZ_EXPORT void wrbuf_puts_replace_char(WRBUF b, const char *buf,
const char from, const char to);
/** \brief writes C-string to WRBUF and escape non-ASCII characters
/** \brief iconv reset(flush) to WRBUF
\param b
\param cd iconv handle
-
+
This function calls iconv(cd, 0, 0, ..) to make it
flush any remaining content.
*/
*/
YAZ_EXPORT void wrbuf_cut_right(WRBUF b, size_t no_to_remove);
-/** \brief grow WRBUF larger
+/** \brief grow WRBUF larger
\param b WRBUF
\param minsize make WRBUF at least this size
#define xstrndup(s, n) xstrndup_f(s, n, __FILE__, __LINE__)
/** \brief utility macro which calls malloc_trav_f */
#define xmalloc_trav(s) xmalloc_trav_f(s, __FILE__, __LINE__)
-
+
/** \brief realloc
\param o buffer to be reallocated
\param size size of buffer to be allocated
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/** \file
+/** \file
\brief XML Include (not to be confused with W3C XInclude)
*/
size_t *no_read,
int *error);
-/** \brief encodes UTF-8 sequence
+/** \brief encodes UTF-8 sequence
\param x the UNICODE value
\param outbuf output buffer pointer, updated if conversion is successful
\param outbytesleft length of buffer, updated if conversino is successful
#include <yaz/yaz-version.h>
#include <yaz/xmalloc.h>
-#include <yaz/log.h>
+#include <yaz/log.h>
#include <yaz/tpath.h>
#include <yaz/options.h>
The following sections is just a summary of the most important
header files and where they belong.
-
+
\section utilities Utilies
Logging (syslog-like) utility \ref log.h .
Z39.50 sort: \ref sortspec.h .
\section ber BER handling
-
+
BER utilities (ODR): \ref odr.h .
\section z3950 Z39.50
Z39.50 common header: \ref proto.h .
-
+
Z39.50 core codecs: \ref z-core.h.
Z39.50 related formats:
- \ref z-accdes1.h , \ref z-core.h ,
+ \ref z-accdes1.h , \ref z-core.h ,
\ref z-estask.h , \ref z-oclcui.h , \ref z-sum.h
- \ref z-accform1.h , \ref z-date.h ,
+ \ref z-accform1.h , \ref z-date.h ,
\ref z-exp.h , \ref z-opac.h , \ref z-sutrs.h
- \ref z-acckrb1.h , \ref z-diag1.h ,
+ \ref z-acckrb1.h , \ref z-diag1.h ,
\ref z-grs.h , \ref z-rrf1.h , \ref z-uifr1.h
\ref z-charneg.h , \ref z-espec1.h
\ref z-mterm2.h , \ref z-rrf2.h , \ref z-univ.h .
Z39.50 extended services:
- \ref zes-admin.h , \ref zes-exps.h , \ref zes-pquery.h ,
+ \ref zes-admin.h , \ref zes-exps.h , \ref zes-pquery.h ,
\ref zes-pset.h , \ref zes-update.h ,
- \ref zes-expi.h , \ref zes-order.h , \ref zes-psched.h ,
+ \ref zes-expi.h , \ref zes-order.h , \ref zes-psched.h ,
\ref zes-update0.h .
Z39.50 diagnostics: \ref diagbib1.h .
Z39.50 externals: \ref prt-ext.h .
\section GDU Generic Data Unit (HTTP and BER)
-
+
Definitions for GDU and HTTP: \ref zgdu.h .
\section SRU SRU
SRU/SRW definitions: \ref srw.h .
SRW diagnostics: \ref diagsrw.h .
-
+
\section ILL ILL
Common header: \ref ill.h .
Codecs: \ref ill-core.h
\section ZOOM ZOOM
-
+
Common header: \ref zoom.h .
\section GFS Generic Frontend Server (GFS)
-
+
Header: \ref backend.h .
*/
#endif
-
+
/*
* Local variables:
* c-basic-offset: 4
# define YAZ_IMPORT __declspec(dllimport)
# else
# define YAZ_EXPORT
-# define YAZ_IMPORT
+# define YAZ_IMPORT
# endif
#endif
#define YAZ_BEGIN_CDECL extern "C" {
#define YAZ_END_CDECL }
#else
-#define YAZ_BEGIN_CDECL
-#define YAZ_END_CDECL
+#define YAZ_BEGIN_CDECL
+#define YAZ_END_CDECL
#endif
#endif
ZOOM_API(int)
ZOOM_record_error(ZOOM_record rec, const char **msg,
const char **addinfo, const char **diagset);
-
+
/* ----------------------------------------------------------- */
/* facets */
/* CCL translated client-side into RPN: `conn' is optional for diagnostics */
ZOOM_API(int)
ZOOM_query_ccl2rpn(ZOOM_query s, const char *query_str,
- const char *config,
+ const char *config,
int *ccl_error, const char **error_string, int *error_pos);
/* PQF */
ZOOM_API(int)
ZOOM_API(void)
ZOOM_options_set(ZOOM_options opt, const char *name, const char *v);
-
+
ZOOM_API(void)
ZOOM_options_setl(ZOOM_options opt, const char *name, const char *value,
int len);
\param cs connection array
\retval 0 no event was fired
\retval >0 event was fired for connection at (retval-1)
-
+
blocking poll for events on a number of connections. Returns positive
integer if event occurred ; zero if none occurred and no more
events are pending. The positive integer specifies the
\retval 0 no event was processed
\retval 1 event was processed for connection
- This function attemps to deal with outstandings events in
+ This function attemps to deal with outstandings events in
a non-blocking fashion. If no event was processed (return value of 0),
then the system should attempt to deal with sockets in blocking mode
using socket select/poll which means calling the following functions:
ZOOM_connection_get_socket(ZOOM_connection c);
-/** \brief get socket mask for connection
+/** \brief get socket mask for connection
\param c connection
\returns mask for connection (possibly 0)
inp++;
--inbytesleft;
(*no_read)++;
- }
+ }
if (inbytesleft == 0)
{
yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
}
switch (*inp) {
case 0x81:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x0386;
- else
+ else
x = 0x0391;
- else
- if (tonos)
+ else
+ if (tonos)
x = 0x03ac;
- else
+ else
x = 0x03b1;
break;
case 0x82:
- if (shift)
+ if (shift)
x = 0x0392;
- else
+ else
x = 0x03b2;
-
+
break;
case 0x83:
- if (shift)
+ if (shift)
x = 0x0393;
- else
+ else
x = 0x03b3;
break;
case 0x84:
- if (shift)
+ if (shift)
x = 0x0394;
- else
+ else
x = 0x03b4;
break;
case 0x85:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x0388;
- else
+ else
x = 0x0395;
- else
- if (tonos)
+ else
+ if (tonos)
x = 0x03ad;
- else
+ else
x = 0x03b5;
break;
case 0x86:
- if (shift)
+ if (shift)
x = 0x0396;
- else
+ else
x = 0x03b6;
break;
case 0x87:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x0389;
- else
+ else
x = 0x0397;
- else
- if (tonos)
+ else
+ if (tonos)
x = 0x03ae;
- else
+ else
x = 0x03b7;
break;
case 0x88:
- if (shift)
+ if (shift)
x = 0x0398;
- else
+ else
x = 0x03b8;
break;
case 0x89:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x038a;
- else
- if (dialitika)
+ else
+ if (dialitika)
x = 0x03aa;
- else
+ else
x = 0x0399;
- else
- if (tonos)
- if (dialitika)
+ else
+ if (tonos)
+ if (dialitika)
x = 0x0390;
- else
+ else
x = 0x03af;
-
- else
- if (dialitika)
+
+ else
+ if (dialitika)
x = 0x03ca;
- else
+ else
x = 0x03b9;
break;
case 0x8a:
- if (shift)
+ if (shift)
x = 0x039a;
- else
+ else
x = 0x03ba;
-
+
break;
case 0x8b:
- if (shift)
+ if (shift)
x = 0x039b;
- else
+ else
x = 0x03bb;
break;
case 0x8c:
- if (shift)
+ if (shift)
x = 0x039c;
- else
+ else
x = 0x03bc;
-
+
break;
case 0x8d:
- if (shift)
+ if (shift)
x = 0x039d;
- else
+ else
x = 0x03bd;
break;
case 0x8e:
- if (shift)
+ if (shift)
x = 0x039e;
- else
+ else
x = 0x03be;
break;
case 0x8f:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x038c;
- else
+ else
x = 0x039f;
- else
- if (tonos)
+ else
+ if (tonos)
x = 0x03cc;
- else
+ else
x = 0x03bf;
break;
case 0x90:
- if (shift)
+ if (shift)
x = 0x03a0;
- else
+ else
x = 0x03c0;
break;
case 0x91:
- if (shift)
+ if (shift)
x = 0x03a1;
- else
+ else
x = 0x03c1;
break;
case 0x92:
x = 0x03c2;
break;
case 0x93:
- if (shift)
+ if (shift)
x = 0x03a3;
- else
+ else
x = 0x03c3;
break;
case 0x94:
- if (shift)
+ if (shift)
x = 0x03a4;
- else
+ else
x = 0x03c4;
break;
case 0x95:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x038e;
- else
- if (dialitika)
+ else
+ if (dialitika)
x = 0x03ab;
- else
+ else
x = 0x03a5;
- else
- if (tonos)
- if (dialitika)
+ else
+ if (tonos)
+ if (dialitika)
x = 0x03b0;
- else
+ else
x = 0x03cd;
-
- else
- if (dialitika)
+
+ else
+ if (dialitika)
x = 0x03cb;
- else
+ else
x = 0x03c5;
break;
case 0x96:
- if (shift)
+ if (shift)
x = 0x03a6;
- else
+ else
x = 0x03c6;
break;
case 0x97:
- if (shift)
+ if (shift)
x = 0x03a7;
- else
+ else
x = 0x03c7;
break;
case 0x98:
- if (shift)
+ if (shift)
x = 0x03a8;
- else
+ else
x = 0x03c8;
-
+
break;
-
+
case 0x99:
- if (shift)
- if (tonos)
+ if (shift)
+ if (tonos)
x = 0x038f;
- else
+ else
x = 0x03a9;
- else
- if (tonos)
+ else
+ if (tonos)
x = 0x03ce;
- else
+ else
x = 0x03c9;
break;
default:
break;
}
(*no_read)++;
-
+
return x;
}
* See the file LICENSE for details.
*/
-/**
+/**
* \file atoin.c
* \brief Implements atoi_n function.
*/
while (len >= 4)
{
char i0, i1, i2, i3;
-
+
i0 = next_char(&in, &len);
if (i0 < 0)
return -1;
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_any.c
* \brief Implements BER ANY encoding and decoding.
*
int ber_any(ODR o, Odr_any **p)
{
int res;
-
+
switch (o->direction)
{
case ODR_DECODE:
{
int res, ll, zclass, tag, cons;
const unsigned char *b = buf;
-
+
if (level > 1000)
{
#if BER_ANY_DEBUG
#endif
return -1; /* error */
}
- if (res == -1)
+ if (res == -1)
{
#if BER_ANY_DEBUG
yaz_log(YLOG_LOG, "<<<<<<<<< return2 lev=%d res=%d", level, res);
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_bit.c
* \brief Implements BER BITSTRING encoding and decoding.
*
return 1;
case ODR_PRINT:
return 1;
- default:
+ default:
odr_seterror(o, OOTHER, 8);
return 0;
}
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_bool.c
* \brief Implements BER BOOLEAN encoding and decoding
*
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_int.c
* \brief Implements BER INTEGER encoding and decoding.
*
if ((res = ber_declen(b, &len, max)) < 0)
return -1;
if (len+res > max || len < 0) /* out of bounds or indefinite encoding */
- return -1;
+ return -1;
if (len > (int) sizeof(uval)) /* let's be reasonable, here */
return -1;
b += res;
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_len.c
* \brief Implements BER length octet encoding and decoding
*
/**
* ber_declen:
- * Decode BER length octets. Returns
- * > 0 : number of bytes read
+ * Decode BER length octets. Returns
+ * > 0 : number of bytes read
* -1 : not enough room to read bytes within max bytes
* -2 : other error
*
}
if (*b == 0XFF) /* reserved value */
return -2;
- /* indefinite long form */
+ /* indefinite long form */
n = *b & 0X7F;
if (n >= max)
return -1;
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_null.c
* \brief Implements ber_null
*
#include "odr-priv.h"
-/**
+/**
* ber_null: BER-en/decoder for NULL type.
*/
int ber_null(ODR o)
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_oct.c
* \brief Implements ber_octetstring
*
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_oid.c
* \brief Implements BER OID encoding and decoding
*
n = 0;
if (pos == 1)
id = p[0]*40 + p[1];
- else
+ else
id = p[pos];
do
{
}
odr_seek(o, ODR_S_END, 0);
return 1;
- default:
+ default:
odr_seterror(o, OOTHER, 22);
return 0;
}
* See the file LICENSE for details.
*/
-/**
+/**
* \file ber_tag.c
* \brief Implements BER tags encoding and decoding
*
}
}
-/**
+/**
* \brief Decodes BER identifier octets.
*
* Returns number of bytes read or -1 for error.
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file ccl_stop_words.c
* \brief Removes stop words from terms in RPN tree
*/
NMEM nmem; /* memory for removed items */
struct ccl_stop_info *removed_items;
};
-
+
static void append_removed_item(ccl_stop_words_t csw,
const char *qname,
const char *t, size_t len)
while (*csip)
csip = &(*csip)->next;
-
+
*csip = csi;
}
CCL_bibset bibset, struct ccl_rpn_node **t)
{
struct ccl_rpn_node *r;
-
+
/* remove list items */
nmem_reset(csw->nmem);
csw->removed_items = 0;
-
+
r = ccl_remove_stop_r(csw, bibset, *t);
*t = r;
if (csw->removed_items)
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file cclerrms.c
* \brief Implements CCL error code to error string map.
*
const char *ccl_err_msg(int ccl_errno)
{
- if (ccl_errno >= 0 &&
+ if (ccl_errno >= 0 &&
ccl_errno < sizeof(err_msg_array)/sizeof(*err_msg_array))
return err_msg_array[ccl_errno];
else
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file cclfind.c
* \brief Implements parsing of a CCL FIND query.
*
/**
* strxcat: concatenate strings.
- * n: Null-terminated Destination string
+ * n: Null-terminated Destination string
* src: Source string to be appended (not null-terminated)
* len: Length of source string.
*/
const char *set, int type)
{
struct ccl_rpn_attr *n;
-
+
n = (struct ccl_rpn_attr *)xmalloc(sizeof(*n));
ccl_assert(n);
if (set)
n->type = type;
n->next = p->u.t.attr_list;
p->u.t.attr_list = n;
-
+
return n;
}
*z3958_trunc = 2;
strcat(dst_term, "\\");
}
- strxcat(dst_term, src_str + j, 1);
+ strxcat(dst_term, src_str + j, 1);
}
}
return 0;
}
/**
- * search_term: Parse CCL search term.
+ * search_term: Parse CCL search term.
* cclp: CCL Parser
* qa: Qualifier attributes already applied.
* term_list: tokens we accept as terms in context
size_t max = 200;
if (and_list || or_list || !multi)
max = 1;
-
+
/* ignore commas when dealing with and-lists .. */
if (and_list && lookahead && lookahead->kind == CCL_TOK_COMMA)
{
if (len == 0)
break; /* no more terms . stop . */
-
+
/* create the term node, but wait a moment before adding the term */
p = ccl_rpn_node_create(CCL_RPN_TERM);
p->u.t.attr_list = NULL;
for (i=0; qa && qa[i]; i++)
{
struct ccl_rpn_attr *attr;
-
+
for (attr = ccl_qual_get_attr(qa[i]); attr; attr = attr->next)
switch(attr->kind)
{
}
attset = 0;
if (structure_value == -1 && (
- auto_group ||
+ auto_group ||
qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_WP, &attset))
)
{
static int list[] = {
CCL_TOK_TERM, CCL_TOK_COMMA,CCL_TOK_EQ,
CCL_TOK_REL, CCL_TOK_SET, -1};
-
+
return search_term_x(cclp, qa, list, 1);
}
}
if (cclp->look_token->name[i] == '-')
break;
}
-
+
if (cclp->look_token->len > 1 && i == 0)
{ /* -xx*/
struct ccl_token *ntoken = ccl_token_add(cclp->look_token);
cclp->look_token->next->kind == CCL_TOK_TERM &&
cclp->look_token->next->len > 1 &&
cclp->look_token->next->name[0] == '-')
-
+
{ /* xx -yy */
/* we _know_ that xx does not have - in it */
struct ccl_token *ntoken = ccl_token_add(cclp->look_token);
ntoken->len = 1;
(ntoken->next->name)++; /* adjust yy */
- (ntoken->next->len)--;
+ (ntoken->next->len)--;
}
}
}
-
+
if (rel == 3 &&
KIND == CCL_TOK_TERM &&
cclp->look_token->next && cclp->look_token->next->len == 1 &&
if (KIND == CCL_TOK_TERM) /* = term - term ? */
{
struct ccl_rpn_node *p2;
-
+
if (!(p2 = search_term(cclp, ap)))
{
ccl_rpn_delete(p1);
struct ccl_rpn_node *qualifier_relation(CCL_parser cclp, ccl_qualifier_t *ap)
{
char *attset;
-
+
if (qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_ORDER, &attset)
|| qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_PORDER, &attset))
return qualifiers_order(cclp, ap, attset);
}
/**
- * qualifier_list: Parse CCL qualifiers and search terms.
+ * qualifier_list: Parse CCL qualifiers and search terms.
* cclp: CCL Parser
* la: Token pointer to RELATION token.
* qa: Qualifier attributes already applied.
* return: pointer to node(s); NULL on error.
*/
-static struct ccl_rpn_node *qualifier_list(CCL_parser cclp,
+static struct ccl_rpn_node *qualifier_list(CCL_parser cclp,
struct ccl_token *la,
ccl_qualifier_t *qa)
{
{
struct ccl_rpn_node *node_sub;
cclp->look_token = la;
-
+
node_sub = qualifier_relation(cclp, ap);
if (!node_sub)
{
}
if (node)
{
- struct ccl_rpn_node *node_this =
+ struct ccl_rpn_node *node_this =
ccl_rpn_node_create(CCL_RPN_OR);
node_this->u.p[0] = node;
node_this->u.p[1] = node_sub;
if (qa)
{
ccl_qualifier_t *qa0 = qa;
-
+
while (*qa0)
ap[i++] = *qa0++;
}
ap[i] = NULL;
-
+
if (!found)
break;
-
+
cclp->look_token = lookahead;
-
+
node_sub = qualifier_relation(cclp, ap);
if (!node_sub)
{
}
if (node)
{
- struct ccl_rpn_node *node_this =
+ struct ccl_rpn_node *node_this =
ccl_rpn_node_create(CCL_RPN_OR);
node_this->u.p[0] = node;
node_this->u.p[1] = node_sub;
}
if (node)
{
- struct ccl_rpn_node *node_this =
+ struct ccl_rpn_node *node_this =
ccl_rpn_node_create(CCL_RPN_OR);
node_this->u.p[0] = node;
node_this->u.p[1] = node_sub;
return p;
}
-struct ccl_rpn_node *ccl_parser_find_token(CCL_parser cclp,
+struct ccl_rpn_node *ccl_parser_find_token(CCL_parser cclp,
struct ccl_token *list)
{
struct ccl_rpn_node *p;
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
- * \file cclp.h
- * \brief CCL header with private definitions
+/**
+ * \file cclp.h
+ * \brief CCL header with private definitions
*/
#include <yaz/ccl.h>
struct ccl_parser {
/** current lookahead token */
struct ccl_token *look_token;
-
+
/** holds error code if error occur */
int error_code;
/** start of CCL string buffer */
const char *start_pos;
/** if error occurs, this holds position (starting from 0). */
const char *error_pos;
-
+
/** current bibset */
CCL_bibset bibset;
YAZ_EXPORT
struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command);
-/**
+/**
* Deletes token list
*/
YAZ_EXPORT
YAZ_EXPORT
-ccl_qualifier_t ccl_qual_search(CCL_parser cclp, const char *name,
+ccl_qualifier_t ccl_qual_search(CCL_parser cclp, const char *name,
size_t name_len, int seq);
YAZ_EXPORT
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file cclptree.c
* \brief Implements CCL parse tree printing
*
const char *cp = p->u.p[2]->u.t.term;
/* exlusion distance ordered relation which-code unit-code */
if (*cp == '!')
- {
+ {
/* word order specified */
if (yaz_isdigit(cp[1]))
wrbuf_printf(w, "@prox 0 %s 1 2 k 2", cp+1);
else
wrbuf_printf(w, "@prox 0 1 1 2 k 2");
- }
+ }
else if (*cp == '%')
{
/* word order not specified */
WRBUF w = wrbuf_alloc();
ccl_pquery_indent(w, rpn, 0);
-
+
fputs(wrbuf_cstr(w), fd_out);
wrbuf_destroy(w);
}
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file cclqfile.c
* \brief Implements parsing of CCL qualifier specs in files
*/
yaz_tok_cfg_destroy(yt);
*addinfo = 0;
-
+
t = yaz_tok_move(tp);
while (t == YAZ_TOK_STRING)
{
goto out;
}
value_str = yaz_tok_parse_string(tp);
-
+
if (sscanf(type_str, "%d", &type) == 1)
;
else if (strlen(type_str) != 1)
value = CCL_BIB1_REL_ORDER;
else if (!ccl_stricmp (value_str, "r"))
value = CCL_BIB1_REL_PORDER;
- break;
+ break;
case 'p':
case 'P':
type = CCL_BIB1_POS;
value = CCL_BIB1_STR_OR_LIST;
if (!ccl_stricmp (value_str, "ag"))
value = CCL_BIB1_STR_AUTO_GROUP;
- break;
+ break;
case 't':
case 'T':
type = CCL_BIB1_TRU;
value = CCL_BIB1_TRU_CAN_REGEX;
else if (!ccl_stricmp (value_str, "z"))
value = CCL_BIB1_TRU_CAN_Z3958;
- break;
+ break;
case 'c':
case 'C':
type = CCL_BIB1_COM;
int no_scan = 0;
char qual_name[128];
char *cp1, *cp = line;
-
+
if (*cp == '#')
return; /* ignore lines starting with # */
if (sscanf (cp, "%100s%n", qual_name, &no_scan) < 1)
* Each line format is:
* <name> <t>=<v> <t>=<v> ....
* Where <name> is name of qualifier;
- * <t>=<v> is a attribute definition pair where <t> is one of:
- * u(use), r(relation), p(position), t(truncation), c(completeness)
+ * <t>=<v> is a attribute definition pair where <t> is one of:
+ * u(use), r(relation), p(position), t(truncation), c(completeness)
* or plain integer.
* <v> is an integer or special pseudo-value.
*/
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file cclqual.c
* \brief Implements CCL qualifier utilities
*/
yaz_tok_cfg_t yt = yaz_tok_cfg_create();
int t;
size_t i = 0;
-
+
yaz_tok_parse_t tp = yaz_tok_parse_buf(yt, cp);
-
+
yaz_tok_cfg_destroy(yt);
-
+
t = yaz_tok_move(tp);
while (t == YAZ_TOK_STRING)
{
if (i >= no-1)
vlist = (char **) xrealloc(vlist, (no = no * 2) * sizeof(*vlist));
vlist[i++] = xstrdup(yaz_tok_parse_string(tp));
- t = yaz_tok_move(tp);
+ t = yaz_tok_move(tp);
}
vlist[i] = 0;
ccl_qual_add_special_ar(bibset, n, (const char **) vlist);
-
+
yaz_tok_parse_destroy(tp);
}
/** \brief adds specifies qualifier aliases
-
+
\param b bibset
\param n qualifier name
\param names list of qualifier aliases
q->attr_list = 0;
q->next = b->list;
b->list = q;
-
+
for (i = 0; names[i]; i++)
;
q->no_sub = i;
}
/** \brief adds specifies attributes for qualifier
-
+
\param b bibset
\param name qualifier name
\param no number of attribute type+value pairs
{
q = (struct ccl_qualifier *)xmalloc(sizeof(*q));
ccl_assert(q);
-
+
q->next = b->list;
b->list = q;
-
+
q->name = xstrdup(name);
q->attr_list = 0;
{
CCL_bibset b = (CCL_bibset)xmalloc(sizeof(*b));
ccl_assert(b);
- b->list = NULL;
+ b->list = NULL;
b->special = NULL;
return b;
}
/** \brief destroys Bibset
\param b pointer to Bibset
-
+
*b will be set to NULL.
*/
void ccl_qual_rm(CCL_bibset *b)
(*qp)->next = 0;
(*qp)->attr_list = 0;
(*qp)->name = xstrdup(q->name);
-
+
attrp = &(*qp)->attr_list;
for (attr = q->attr_list; attr; attr = attr->next)
{
for (i = 0; i < q->no_sub; i++)
{
struct ccl_qualifier *q1, *q2;
-
+
/* sweep though original and match up the corresponding ent */
q2 = n->list;
for (q1 = b->list; q1 && q2; q1 = q1->next, q2 = q2->next)
return n;
}
-ccl_qualifier_t ccl_qual_search(CCL_parser cclp, const char *name,
+ccl_qualifier_t ccl_qual_search(CCL_parser cclp, const char *name,
size_t name_len, int seq)
{
struct ccl_qualifier *q = 0;
{
int i;
for (i = 0; slist[i]; i++)
- if (src_len == strlen(slist[i])
+ if (src_len == strlen(slist[i])
&& ccl_memicmp(slist[i], src_str, src_len) == 0)
return 1;
}
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file cclstr.c
* \brief Implements CCL string compare utilities
*/
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file ccltoken.c
* \brief Implements CCL lexical analyzer (scanner)
*/
default:
--cp;
--last->len;
-
+
last->kind = CCL_TOK_TERM;
last->name = (const char *) cp;
while (*cp && !strchr("(),%!><= \t\n\r", *cp))
else if (*cp == '"')
break;
}
- }
+ }
if (!*cp)
break;
cp++;
aliases = cclp->ccl_token_and;
if (token_cmp(cclp, aliases, last))
last->kind = CCL_TOK_AND;
-
+
aliases = ccl_qual_search_special(cclp->bibset, "or");
if (!aliases)
aliases = cclp->ccl_token_or;
if (token_cmp(cclp, aliases, last))
last->kind = CCL_TOK_OR;
-
+
aliases = ccl_qual_search_special(cclp->bibset, "not");
if (!aliases)
aliases = cclp->ccl_token_not;
if (token_cmp(cclp, aliases, last))
last->kind = CCL_TOK_NOT;
-
+
aliases = ccl_qual_search_special(cclp->bibset, "set");
if (!aliases)
aliases = cclp->ccl_token_set;
-
+
if (token_cmp(cclp, aliases, last))
last->kind = CCL_TOK_SET;
}
n->ws_prefix_len = 0;
return n;
}
-
+
/*
* ccl_token_del: delete CCL tokens
*/
{
struct ccl_token *list1;
- while (list)
+ while (list)
{
list1 = list->next;
xfree(list);
}
static int ccl_xml_config_qual(CCL_bibset bibset, const char *default_set,
- WRBUF wrbuf,
+ WRBUF wrbuf,
const xmlNode *ptr,
const char **addinfo)
{
int ccl_xml_config(CCL_bibset bibset, const xmlNode *ptr, const char **addinfo)
{
- if (ptr && ptr->type == XML_ELEMENT_NODE &&
+ if (ptr && ptr->type == XML_ELEMENT_NODE &&
!xmlStrcmp(ptr->name, BAD_CAST "cclmap"))
{
const xmlNode *c_ptr;
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file charneg.c
* \brief Implements Z39.50 Charset negotiation utilities
*
{
Z_External *p;
int len = strlen(buf);
-
+
if (!(p = (Z_External *)odr_malloc(o, sizeof(*p))))
return 0;
p->descriptor = 0;
p->indirect_reference = 0;
-
+
p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_id);
-
+
p->which = Z_External_octet;
if (!(p->u.octet_aligned = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct))))
return 0;
return 0;
p->u.octet_aligned->len = p->u.octet_aligned->size = len;
memcpy(p->u.octet_aligned->buf, buf, len);
-
+
return p;
}
(Z_PrivateCharacterSet *)odr_malloc(o, sizeof(*pc));
memset(pc, 0, sizeof(*pc));
-
+
p0->which = Z_OriginProposal_0_private;
p0->u.zprivate = pc;
-
+
pc->which = Z_PrivateCharacterSet_externallySpecified;
pc->u.externallySpecified = z_ext_record2(o, charset);
}
static Z_OriginProposal *z_get_OriginProposal(
ODR o, const char **charsets, int num_charsets,
const char **langs, int num_langs, int selected)
-{
+{
int i;
Z_OriginProposal *p = (Z_OriginProposal *) odr_malloc(o, sizeof(*p));
-
+
memset(p, 0, sizeof(*p));
p->recordsInSelectedCharSets = (bool_t *)odr_malloc(o, sizeof(bool_t));
if (charsets && num_charsets)
{
p->num_proposedCharSets = num_charsets;
- p->proposedCharSets =
+ p->proposedCharSets =
(Z_OriginProposal_0**)
odr_malloc(o, num_charsets*sizeof(Z_OriginProposal_0*));
if (langs && num_langs)
{
p->num_proposedlanguages = num_langs;
- p->proposedlanguages =
+ p->proposedlanguages =
(char **) odr_malloc(o, num_langs*sizeof(char *));
for (i = 0; i < num_langs; i++)
{
Z_CharSetandLanguageNegotiation *p =
(Z_CharSetandLanguageNegotiation *) odr_malloc(o, sizeof(*p));
-
+
memset(p, 0, sizeof(*p));
-
+
return p;
}
int selected)
{
Z_External *p = (Z_External *)odr_malloc(o, sizeof(*p));
-
+
p->descriptor = 0;
- p->indirect_reference = 0;
+ p->indirect_reference = 0;
p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_3);
char **langs_addresses = 0;
int charsets_count = 0;
int langs_count = 0;
-
+
if (charset_list)
nmem_strsplit(odr_getmem(o), delim, charset_list,
&charsets_addresses, &charsets_count);
if (lang_list)
nmem_strsplit(odr_getmem(o), delim, lang_list,
- &langs_addresses, &langs_count);
+ &langs_addresses, &langs_count);
return yaz_set_proposal_charneg(o,
(const char **) charsets_addresses,
charsets_count,
(const char **) langs_addresses,
- langs_count,
+ langs_count,
selected);
}
/* used by yaz_set_response_charneg */
static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
const char *lang, int selected)
-{
+{
Z_TargetResponse *p = (Z_TargetResponse *) odr_malloc(o, sizeof(*p));
int form = get_form(charset);
{
Z_PrivateCharacterSet *pc =
(Z_PrivateCharacterSet *)odr_malloc(o, sizeof(*pc));
-
+
memset(pc, 0, sizeof(*pc));
-
+
p->which = Z_TargetResponse_private;
p->u.zprivate = pc;
-
+
pc->which = Z_PrivateCharacterSet_externallySpecified;
pc->u.externallySpecified =
z_ext_record2(o, charset);
}
p->recordsInSelectedCharSets = (bool_t *)odr_malloc(o, sizeof(bool_t));
*p->recordsInSelectedCharSets = (selected) ? 1 : 0;
-
+
p->selectedLanguage = lang ? (char *) odr_strdup(o, lang) : 0;
return p;
}
const char *lang, int selected)
{
Z_External *p = (Z_External *)odr_malloc(o, sizeof(*p));
-
+
p->descriptor = 0;
- p->indirect_reference = 0;
+ p->indirect_reference = 0;
p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_3);
Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p)
{
int i;
-
+
if (!p)
return 0;
-
+
for (i = 0; i < p->num_elements; i++)
{
Z_External *pext;
int yaz_del_charneg_record(Z_OtherInformation **p)
{
int i;
-
+
if (!*p)
return 0;
-
+
for (i = 0; i < (*p)->num_elements; i++)
{
Z_External *pext;
{
int i;
Z_OriginProposal *pro = p->u.proposal;
-
+
if (num_charsets && charsets)
{
if (pro->num_proposedCharSets)
{
*num_charsets = pro->num_proposedCharSets;
-
+
(*charsets) = (char **)
nmem_malloc(mem, pro->num_proposedCharSets * sizeof(char *));
-
- for (i = 0; i < pro->num_proposedCharSets; i++)
+
+ for (i = 0; i < pro->num_proposedCharSets; i++)
{
(*charsets)[i] = 0;
-
+
if (pro->proposedCharSets[i]->which ==
Z_OriginProposal_0_private &&
pro->proposedCharSets[i]->u.zprivate->which ==
{
Z_External *pext =
pro->proposedCharSets[i]->u.zprivate->u.externallySpecified;
-
+
if (pext->which == Z_External_octet)
{
(*charsets)[i] = (char *)
nmem_malloc(mem, (1+pext->u.octet_aligned->len) *
sizeof(char));
-
+
memcpy((*charsets)[i], pext->u.octet_aligned->buf,
pext->u.octet_aligned->len);
(*charsets)[i][pext->u.octet_aligned->len] = 0;
else
*num_charsets = 0;
}
-
+
if (langs && num_langs)
{
if (pro->num_proposedlanguages)
{
*num_langs = pro->num_proposedlanguages;
-
+
(*langs) = (char **)
nmem_malloc(mem, pro->num_proposedlanguages * sizeof(char *));
-
+
for (i = 0; i < pro->num_proposedlanguages; i++)
(*langs)[i] = nmem_strdup(mem, pro->proposedlanguages[i]);
}
else
*num_langs = 0;
}
-
+
if (pro->recordsInSelectedCharSets && selected)
*selected = *pro->recordsInSelectedCharSets;
}
char **charset, char **lang, int *selected)
{
Z_TargetResponse *res = p->u.response;
-
+
if (charset && res->which == Z_TargetResponse_private &&
res->u.zprivate->which == Z_PrivateCharacterSet_externallySpecified)
{
Z_External *pext = res->u.zprivate->u.externallySpecified;
-
+
if (pext->which == Z_External_octet)
{
*charset = (char *)
memcpy(*charset, pext->u.octet_aligned->buf,
pext->u.octet_aligned->len);
(*charset)[pext->u.octet_aligned->len] = 0;
- }
+ }
}
if (charset && res->which == Z_TargetResponse_iso10646)
*charset = set_form(res->u.iso10646->encodingLevel);
* Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
-/**
+/**
* \file comstack.c
* \brief Implements Generic COMSTACK functions
*/
void cs_get_host_args(const char *type_and_host, const char **args)
{
-
+
*args = "";
if (*type_and_host && strncmp(type_and_host, "unix:", 5))
{
{
cs_close (cs);
cs = 0;
- }
+ }
}
xfree(connect_host);
return cs;
#endif
return 0;
} else if (yaz_isdigit(buf[i]))
- chunk_len = chunk_len * 16 +
+ chunk_len = chunk_len * 16 +
(buf[i++] - '0');
else if (yaz_isupper(buf[i]))
- chunk_len = chunk_len * 16 +
+ chunk_len = chunk_len * 16 +
(buf[i++] - ('A'-10));
else if (yaz_islower(buf[i]))
- chunk_len = chunk_len * 16 +
+ chunk_len = chunk_len * 16 +
(buf[i++] - ('a'-10));
else
break;
break;
if (chunk_len < 0)
return i;
-
+
while (1)
{
if (i >= len -1)
/* got CRLF */
#if CHUNK_DEBUG
printf ("chunk_len=%d\n", chunk_len);
-#endif
+#endif
i += chunk_len;
if (i >= len-2)
return 0;
/* if dealing with HTTP responses - then default
content length is unlimited (socket close) */
if (!head_only && !memcmp(buf, "HTTP/", 5))
- content_len = -1;
+ content_len = -1;
#if 0
printf("len = %d\n", len);
}
break;
}
- else if (i < len - 20 &&
+ else if (i < len - 20 &&
!strncasecmp((const char *) buf+i, "Transfer-Encoding:", 18))
{
i+=18;
#include <yaz/cql.h>
-static int cql_to_ccl_r(struct cql_node *cn,
+static int cql_to_ccl_r(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data);
for (cp = *cpp; *cp; cp++)
{
char x[4];
-
+
if (*cp == '\\' && cp[1])
{
if (!quote_mode)
*cpp = cp;
}
-static int node(struct cql_node *cn,
+static int node(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data)
{
}
-static int bool(struct cql_node *cn,
+static int bool(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data)
{
r = cql_to_ccl_r(cn->u.boolean.left, pr, client_data);
if (r)
return r;
-
+
pr(") ", client_data);
if (strcmp(value, "prox"))
return r;
}
-static int cql_to_ccl_r(struct cql_node *cn,
+static int cql_to_ccl_r(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data)
{
return -1;
}
-int cql_to_ccl(struct cql_node *cn,
+int cql_to_ccl(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data)
{
b.str = str;
b.off = 0;
-
+
return cql_parser_stream(cp, getbuf, ungetbuf, &b);
}
int ret = 0; /* 0=OK, != 0 FAIL */
int t;
t = yaz_tok_move(tp);
-
+
while (t == YAZ_TOK_STRING && ae_num < 20)
{
WRBUF type_str = wrbuf_alloc();
Z_AttributeElement *elem = 0;
const char *value_str = 0;
/* attset type=value OR type=value */
-
+
elem = (Z_AttributeElement *) nmem_malloc(ct->nmem, sizeof(*elem));
elem->attributeSet = 0;
ae[ae_num] = elem;
{
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
+ wrbuf_destroy(set_str);
break;
}
- if (t == YAZ_TOK_STRING)
- {
+ if (t == YAZ_TOK_STRING)
+ {
wrbuf_puts(ct->w, " ");
wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
set_str = type_str;
-
+
elem->attributeSet =
yaz_string_to_oid_nmem(yaz_oid_std(), CLASS_ATTSET,
wrbuf_cstr(set_str), ct->nmem);
-
+
type_str = wrbuf_alloc();
wrbuf_puts(type_str, yaz_tok_parse_string(tp));
t = yaz_tok_move(tp);
{
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
+ wrbuf_destroy(set_str);
yaz_log(YLOG_WARN, "Expected numeric attribute type");
ret = -1;
break;
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
-
+ wrbuf_destroy(set_str);
+
if (t != '=')
{
yaz_log(YLOG_WARN, "Expected = after after attribute type");
(*pp)->attr_list.attributes = (Z_AttributeElement **)
nmem_malloc(ct->nmem,
ae_num * sizeof(Z_AttributeElement *));
- memcpy((*pp)->attr_list.attributes, ae,
+ memcpy((*pp)->attr_list.attributes, ae,
ae_num * sizeof(Z_AttributeElement *));
}
(*pp)->next = 0;
yaz_tok_parse_destroy(tp);
return r;
}
-
+
cql_transform_t cql_transform_open_FILE(FILE *f)
{
cql_transform_t ct = cql_transform_create();
z_AttributeElement(odr_a, &a, 0, 0);
z_AttributeElement(odr_b, &b, 0, 0);
-
+
buf_a = odr_getbuf(odr_a, &len_a, 0);
buf_b = odr_getbuf(odr_b, &len_b, 0);
return ret;
}
-const char *cql_lookup_reverse(cql_transform_t ct,
+const char *cql_lookup_reverse(cql_transform_t ct,
const char *category,
Z_AttributeList *attributes)
{
}
if (j == attributes->num_attributes)
break; /* i was not found at all.. try next pattern */
-
+
}
if (i == e->attr_list.num_attributes)
return e->pattern + clen;
}
return 0;
}
-
+
static const char *cql_lookup_property(cql_transform_t ct,
const char *pat1, const char *pat2,
const char *pat3)
sprintf(pattern, "%.39s", pat1);
else
return 0;
-
+
for (e = ct->entry; e; e = e->next)
{
if (!cql_strcmp(e->pattern, pattern))
const char *res = 0;
const char *eval = val ? val : default_val;
const char *prefix = 0;
-
+
if (uri)
{
struct cql_prop_entry *e;
-
+
for (e = ct->entry; e; e = e->next)
if (!memcmp(e->pattern, "set.", 4) && e->value &&
!strcmp(e->value, uri))
proxrel = 5;
else if (!strcmp(relation, "<"))
proxrel = 1;
- else if (!strcmp(relation, ">="))
+ else if (!strcmp(relation, ">="))
proxrel = 4;
else if (!strcmp(relation, "<="))
proxrel = 2;
else if (!strcmp(relation, "<>"))
proxrel = 6;
- else
+ else
{
ct->error = YAZ_SRW_UNSUPP_PROX_RELATION;
ct->addinfo = xstrdup(relation);
return 0;
}
- }
+ }
else if (!strcmp(name, "ordered"))
ordered = 1;
else if (!strcmp(name, "unordered"))
unit = 4;
else if (!strcmp(term, "element"))
unit = 8;
- else
+ else
{
ct->error = YAZ_SRW_UNSUPP_PROX_UNIT;
ct->addinfo = xstrdup(term);
return 0;
}
- }
- else
+ }
+ else
{
ct->error = YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER;
ct->addinfo = xstrdup(name);
* there's no mapping for it, that's fine: we just use a
* general pattern-matching attribute.
*/
- if (first_wc == term && second_wc == term + length-1
- && *first_wc == '*' && *second_wc == '*'
- && cql_pr_attr(ct, "truncation", "both", 0, pr, client_data, 0))
+ if (first_wc == term && second_wc == term + length-1
+ && *first_wc == '*' && *second_wc == '*'
+ && cql_pr_attr(ct, "truncation", "both", 0, pr, client_data, 0))
{
term++;
length -= 2;
}
else if (first_wc == term + length-1 && second_wc == 0
&& *first_wc == '*'
- && cql_pr_attr(ct, "truncation", "right", 0,
+ && cql_pr_attr(ct, "truncation", "right", 0,
pr, client_data, 0))
{
length--;
(*pr)("@", client_data);
(*pr)(op, client_data);
(*pr)(" ", client_data);
- }
+ }
emit_term(ct, cn, ne->u.st.term, strlen(ne->u.st.term),
pr, client_data);
}
(*pr)(cn->u.boolean.value, client_data);
(*pr)(" ", client_data);
mods = cn->u.boolean.modifiers;
- if (!strcmp(cn->u.boolean.value, "prox"))
+ if (!strcmp(cn->u.boolean.value, "prox"))
{
if (!cql_pr_prox(ct, mods, pr, client_data))
return;
- }
+ }
else if (mods)
{
/* Boolean modifiers other than on proximity not supported */
cp->u.st.relation,
cp->u.st.term);
cn->u.st.modifiers = cql_node_dup(nmem, cp->u.st.modifiers);
- cn->u.st.index_uri = cp->u.st.index_uri ?
+ cn->u.st.index_uri = cp->u.st.index_uri ?
nmem_strdup(nmem, cp->u.st.index_uri) : 0;
cn->u.st.relation_uri = cp->u.st.relation_uri ?
nmem_strdup(nmem, cp->u.st.relation_uri) : 0;
if (!n->u.st.index_uri && n->u.st.index)
{ /* not yet resolved.. */
const char *cp = strchr(n->u.st.index, '.');
- if (prefix && cp &&
+ if (prefix && cp &&
strlen(prefix) == (size_t) (cp - n->u.st.index) &&
!cql_strncmp(n->u.st.index, prefix, strlen(prefix)))
{
void (*old_sigterm)(int);
void (*old_sigusr1)(int);
void (*old_sigusr2)(int);
-
+
keepalive_pid = getpid();
/* keep signals in their original state and make sure that some signals
signal(SIGTERM, old_sigterm);/* restore */
signal(SIGUSR1, old_sigusr1);/* restore */
signal(SIGUSR2, old_sigusr2);/* restore */
-
+
work(data);
exit(0);
}
-
+
/* enable signalling in kill_child_handler */
child_pid = p;
-
+
p1 = wait(&status);
-
+
/* disable signalling in kill_child_handler */
child_pid = 0;
-
+
if (p1 != p)
{
yaz_log(YLOG_FATAL, "p1=%d != p=%d", p1, p);
exit(1);
}
-
+
if (WIFSIGNALED(status))
{
/* keep the child alive in case of errors, but _log_ */
yaz_log(YLOG_WARN, "Received SIGSEGV from child %ld", (long) p);
cont = 1;
break;
- case SIGBUS:
+ case SIGBUS:
yaz_log(YLOG_WARN, "Received SIGBUS from child %ld", (long) p);
cont = 1;
break;
}
switch (fork())
{
- case 0:
+ case 0:
break;
case -1:
return 1;
close(hand[0]);
if (setsid() < 0)
return 1;
-
+
close(0);
close(1);
close(2);
17, 70,
18, 50,
19, 55,
- 20, 56,
+ 20, 56,
21, 52,
22, 50,
23, 3,
102, 3,
103, 3,
104, 3,
- 105, 3,
+ 105, 3,
106, 66,
107, 11,
108, 10,
108, 26,
108, 27,
108, 45,
-
+
109, 235,
110, 37,
111, 1,
123, 18,
124, 24,
125, 36,
- 126, 36,
+ 126, 36,
127, 36,
128, 51,
129, 39,
233, 1, /* bad map */
234, 1, /* bad map */
235, 235,
- 236, 236,
+ 236, 236,
237, 82,
238, 67,
239, 66,
1005, 1, /* bad map */
1006, 1, /* bad map */
1007, 100,
- 1008, 1,
+ 1008, 1,
1009, 1,
1010, 3,
1011, 3,
* See the file LICENSE for details.
*/
-/** \file
+/** \file
\brief Implement opendir/readdir/closedir on Windows
*/
dd->handle = FindFirstFile(fullName, &dd->find_data);
return dd;
}
-
+
struct dirent *readdir(DIR *dd)
{
if (dd->handle == INVALID_HANDLE_VALUE)
{
Z_RecordComposition *comp = (Z_RecordComposition *)
nmem_malloc(nmem, sizeof(*comp));
-
+
comp->which = Z_RecordComp_simple;
comp->u.simple = (Z_ElementSetNames *)
nmem_malloc(nmem, sizeof(*comp->u.simple));
int destroyed;
time_t last_event;
time_t max_idle;
-
+
struct iochan *next;
int chan_id; /* listening port (0 if none ) */
} *IOCHAN;
* See the file LICENSE for details.
*/
-/**
+/**
* \file facet.c
* \brief Facet utilities
*/
* See the file LICENSE for details.
*/
-/** \file
+/** \file
\brief File globbing (ala POSIX glob, but simpler)
*/
#if HAVE_CONFIG_H
is_pattern = 1;
i++;
}
-
+
if (!is_pattern && pattern[i]) /* no pattern and directory part */
{
i++; /* skip dir sep */
{
char oid_name_str[OID_STR_MAX];
oid_class oclass;
- const char *oid_name
+ const char *oid_name
= yaz_oid_to_string_buf(ip, &oclass, oid_name_str);
-
+
if (oid_name)
wrbuf_printf(w, "OID: %s\n", oid_name);
}
{
printf ("External\n");
/* we cannot print externals here. Srry */
- }
+ }
else
wrbuf_printf(w, "? type = %d\n",t->content->which);
if (t->appliedVariant)
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
-
+
static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
char **content_buf, int *content_len)
{
i++;
for (po = i; i < o->size-1 && !strchr("\r\n", o->buf[i]); i++)
;
-
+
(*headers)->value = (char*) odr_malloc(o, i - po + 1);
memcpy ((*headers)->value, o->buf + po, i - po);
(*headers)->value[i - po] = '\0';
-
+
if (!strcasecmp((*headers)->name, "Transfer-Encoding")
&&
!strcasecmp((*headers)->value, "chunked"))
if (chunked)
{
int off = 0;
-
+
/* we know buffer will be smaller than o->size - i*/
- *content_buf = (char*) odr_malloc(o, o->size - i);
-
+ *content_buf = (char*) odr_malloc(o, o->size - i);
+
while (1)
{
/* chunk length .. */
int chunk_len = 0;
for (; i < o->size-2; i++)
if (yaz_isdigit(o->buf[i]))
- chunk_len = chunk_len * 16 +
+ chunk_len = chunk_len * 16 +
(o->buf[i] - '0');
else if (yaz_isupper(o->buf[i]))
- chunk_len = chunk_len * 16 +
+ chunk_len = chunk_len * 16 +
(o->buf[i] - ('A'-10));
else if (yaz_islower(o->buf[i]))
- chunk_len = chunk_len * 16 +
+ chunk_len = chunk_len * 16 +
(o->buf[i] - ('a'-10));
else
break;
*content_buf = 0;
*content_len = 0;
}
- else
+ else
{
*content_len = o->size - i;
*content_buf = (char*) odr_malloc(o, *content_len + 1);
cp0 = cp0+3;
else
cp0 = uri;
-
+
cp1 = strchr(cp0, '/');
if (!cp1)
cp1 = cp0+strlen(cp0);
-
+
if (cp0 && cp1)
{
char *h = (char*) odr_malloc(odr, cp1 - cp0 + 1);
if (code != 200)
{
hres->content_buf = (char*) odr_malloc(o, 400);
- sprintf(hres->content_buf,
+ sprintf(hres->content_buf,
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""
" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
"<HTML>\n"
" <TITLE>YAZ " YAZ_VERSION "</TITLE>\n"
" </HEAD>\n"
" <BODY>\n"
- " <P><A HREF=\"http://www.indexdata.com/yaz/\">YAZ</A> "
+ " <P><A HREF=\"http://www.indexdata.com/yaz/\">YAZ</A> "
YAZ_VERSION "</P>\n"
" <P>Error: %d</P>\n"
" <P>Description: %.50s</P>\n"
{
int i, po;
Z_HTTP_Response *hr = (Z_HTTP_Response *) odr_malloc(o, sizeof(*hr));
-
+
*hr_p = hr;
hr->content_buf = 0;
hr->content_len = 0;
-
+
po = i = 5;
while (i < o->size-2 && !strchr(" \r\n", o->buf[i]))
i++;
while (i < o->size-1 && o->buf[i] != '\n')
i++;
return decode_headers_content(o, i, &hr->headers,
- &hr->content_buf, &hr->content_len);
+ &hr->content_buf, &hr->content_len);
}
int yaz_decode_http_request(ODR o, Z_HTTP_Request **hr_p)
{
int i, po;
Z_HTTP_Request *hr = (Z_HTTP_Request *) odr_malloc(o, sizeof(*hr));
-
+
*hr_p = hr;
-
+
/* method .. */
for (i = 0; o->buf[i] != ' '; i++)
if (i >= o->size-5 || i > 30)
}
odr_write(o, (unsigned char *) "\r\n", 2);
if (hr->content_buf)
- odr_write(o, (unsigned char *)
+ odr_write(o, (unsigned char *)
hr->content_buf,
hr->content_len);
if (o->direction == ODR_PRINT)
unsigned long x_back;
};
-static unsigned long read_danmarc(yaz_iconv_t cd,
+static unsigned long read_danmarc(yaz_iconv_t cd,
yaz_iconv_decoder_t d,
unsigned char *inp,
size_t inbytesleft, size_t *no_read)
yaz_iconv_decoder_t yaz_danmarc_decoder(const char *fromcode,
yaz_iconv_decoder_t d)
-
+
{
if (!yaz_matchstr(fromcode, "danmarc"))
{
*no_read = data->comb_no_read[data->comb_offset];
x = data->comb_x[data->comb_offset];
- /* special case for double-diacritic combining characters,
+ /* special case for double-diacritic combining characters,
INVERTED BREVE and DOUBLE TILDE.
We'll increment the no_read counter by 1, since we want to skip over
the processing of the closing ligature character
*no_read = data->comb_no_read[data->comb_offset];
x = data->comb_x[data->comb_offset];
- /* special case for double-diacritic combining characters,
+ /* special case for double-diacritic combining characters,
INVERTED BREVE and DOUBLE TILDE.
We'll increment the no_read counter by 1, since we want to skip over
the processing of the closing ligature character
{ 'y', 0x0301, 0xfd}, /* LATIN SMALL LETTER Y WITH ACUTE */
/* omitted: 0xfe LATIN SMALL LETTER THORN */
{ 'y', 0x0308, 0xff}, /* LATIN SMALL LETTER Y WITH DIAERESIS */
-
+
{ 0, 0, 0}
};
yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
return (size_t)(-1);
}
- if (!latin1_comb[i].x1)
+ if (!latin1_comb[i].x1)
{ /* not found. Just write compose_char */
*outp++ = (unsigned char) w->compose_char;
(*outbytesleft)--;
yaz_iconv_encoder_t yaz_iso_8859_1_encoder(const char *tocode,
yaz_iconv_encoder_t e)
-
+
{
if (!yaz_matchstr(tocode, "iso88591"))
{
return 0;
}
-static unsigned long read_ISO8859_1(yaz_iconv_t cd,
+static unsigned long read_ISO8859_1(yaz_iconv_t cd,
yaz_iconv_decoder_t d,
unsigned char *inp,
size_t inbytesleft, size_t *no_read)
yaz_iconv_decoder_t yaz_iso_8859_1_decoder(const char *fromcode,
yaz_iconv_decoder_t d)
-
+
{
if (!yaz_matchstr(fromcode, "iso88591"))
{
data->write_marc8_g1 = 0;
}
-static size_t yaz_write_marc8_page_chr(yaz_iconv_t cd,
+static size_t yaz_write_marc8_page_chr(yaz_iconv_t cd,
struct encoder_data *w,
char **outbuf, size_t *outbytesleft,
const char *page_chr);
size_t inbytesleft, no_read_sub = 0;
unsigned long x;
- *utf8_outbuf = '\0';
+ *utf8_outbuf = '\0';
inp = (unsigned char *) utf8_buf;
inbytesleft = strlen(utf8_buf);
{
*(*outbuf)++ = w->write_marc8_second_half_char;
(*outbytesleft)--;
- }
+ }
w->write_marc8_last = 0;
w->write_marc8_ncr = 0;
return 0;
}
-static size_t yaz_write_marc8_page_chr(yaz_iconv_t cd,
+static size_t yaz_write_marc8_page_chr(yaz_iconv_t cd,
struct encoder_data *w,
char **outbuf, size_t *outbytesleft,
const char *page_chr)
{
size_t plen = 0;
const char *page_out = page_chr;
-
+
if (*outbytesleft < 8)
{
yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG);
-
+
return (size_t) (-1);
}
if (*old_page_chr)
{
- if (!strcmp(*old_page_chr, ESC "p")
+ if (!strcmp(*old_page_chr, ESC "p")
|| !strcmp(*old_page_chr, ESC "g")
|| !strcmp(*old_page_chr, ESC "b"))
{
y = '|';
else
{
- y = x;
+ y = x;
enable_ncr = 1;
}
}
int ncr = w->write_marc8_ncr;
const char *lpage = w->write_marc8_lpage;
size_t r;
-
+
r = yaz_write_marc8_2(cd, w, x1,
outbuf, outbytesleft, loss_mode);
if (r)
yaz_iconv_encoder_t yaz_marc8_encoder(const char *tocode,
yaz_iconv_encoder_t e)
-
+
{
if (!yaz_matchstr(tocode, "MARC8"))
e->write_handle = write_marc8_normal;
yaz_iconv_encoder_t yaz_wchar_encoder(const char *tocode,
yaz_iconv_encoder_t e)
-
+
{
#if HAVE_WCHAR_H
if (!yaz_matchstr(tocode, "wchar_t"))
size_t inbytesleft, size_t *no_read)
{
unsigned long x = 0;
-
+
if (inbytesleft < sizeof(wchar_t))
{
yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
yaz_iconv_decoder_t yaz_wchar_decoder(const char *fromcode,
yaz_iconv_decoder_t d)
-
+
{
#if HAVE_WCHAR_H
if (!yaz_matchstr(fromcode, "wchar_t"))
};
struct icu_casemap * icu_casemap_create(char action, UErrorCode *status)
-{
+{
struct icu_casemap * casemap
= (struct icu_casemap *) xmalloc(sizeof(struct icu_casemap));
casemap->action = action;
switch (casemap->action)
{
- case 'l':
- case 'L':
- case 'u':
- case 'U':
- case 't':
- case 'T':
- case 'f':
- case 'F':
+ case 'l':
+ case 'L':
+ case 'u':
+ case 'U':
+ case 't':
+ case 'T':
+ case 'f':
+ case 'F':
break;
default:
icu_casemap_destroy(casemap);
{
if (!casemap)
return 0;
-
+
return icu_utf16_casemap(dest16, src16, locale,
casemap->action, status);
}
{
switch (action)
{
- case 'l':
- case 'L':
+ case 'l':
+ case 'L':
return u_strToLower(dest16->utf16, dest16->utf16_cap,
- src16->utf16, src16->utf16_len,
+ src16->utf16, src16->utf16_len,
locale, status);
- case 'u':
- case 'U':
+ case 'u':
+ case 'U':
return u_strToUpper(dest16->utf16, dest16->utf16_cap,
- src16->utf16, src16->utf16_len,
+ src16->utf16, src16->utf16_len,
locale, status);
break;
- case 't':
- case 'T':
+ case 't':
+ case 'T':
return u_strToTitle(dest16->utf16, dest16->utf16_cap,
src16->utf16, src16->utf16_len,
0, locale, status);
break;
- case 'f':
- case 'F':
+ case 'f':
+ case 'F':
return u_strFoldCase(dest16->utf16, dest16->utf16_cap,
src16->utf16, src16->utf16_len,
U_FOLD_CASE_DEFAULT, status);
dest16->utf16_len = 0;
return U_ZERO_ERROR;
}
-
+
dest16_len = icu_utf16_sub(dest16, src16, locale, action, status);
/* check for buffer overflow, resize and retry */
dest16->utf16[0] = (UChar) 0;
dest16->utf16_len = 0;
}
-
+
return *status;
}
union {
struct icu_casemap *casemap;
struct icu_transform *transform;
- struct icu_tokenizer *tokenizer;
+ struct icu_tokenizer *tokenizer;
yaz_stemmer_p stemmer;
} u;
struct icu_chain_step *previous;
int sort;
UCollator *coll;
-
+
/* linked list of chain steps */
struct icu_chain_step *csteps;
};
if (U_FAILURE(status))
{
yaz_log(YLOG_WARN, "ICU: %d %s\n", status, u_errorName(status));
- return 0;
+ return 0;
}
return 1;
}
const uint8_t *rule, UErrorCode *status)
{
struct icu_chain_step *step = 0;
-
+
if (!chain || !type || !rule)
return 0;
0, status);
break;
case ICU_chain_step_type_tokenize:
- step->u.tokenizer = icu_tokenizer_create(chain->locale,
+ step->u.tokenizer = icu_tokenizer_create(chain->locale,
(char) rule[0], status);
break;
case ICU_chain_step_type_transliterate:
{
*sp = (struct icu_chain_step *) xmalloc(sizeof(**sp));
(*sp)->type = old->type;
-
+
switch ((*sp)->type)
{
case ICU_chain_step_type_display:
}
}
-struct icu_chain *icu_chain_xml_config(const xmlNode *xml_node,
+struct icu_chain *icu_chain_xml_config(const xmlNode *xml_node,
int sort,
UErrorCode *status)
{
int no_errors = 0;
struct icu_chain *chain = 0;
NMEM nmem = 0;
-
+
*status = U_ZERO_ERROR;
if (xml_node && xml_node->type == XML_ELEMENT_NODE)
{
- xmlChar *xml_locale = xmlGetProp((xmlNode *) xml_node,
+ xmlChar *xml_locale = xmlGetProp((xmlNode *) xml_node,
(xmlChar *) "locale");
if (xml_locale)
{
}
if (!rule && node->children)
rule = nmem_text_node_cdata(node->children, nmem);
-
+
if (!strcmp((const char *) node->name, "casemap"))
- step = icu_chain_insert_step(chain, ICU_chain_step_type_casemap,
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_casemap,
(const uint8_t *) rule, status);
else if (!strcmp((const char *) node->name, "transform"))
- step = icu_chain_insert_step(chain, ICU_chain_step_type_transform,
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_transform,
(const uint8_t *) rule, status);
else if (!strcmp((const char *) node->name, "transliterate"))
- step = icu_chain_insert_step(chain, ICU_chain_step_type_transliterate,
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_transliterate,
(const uint8_t *) rule, status);
else if (!strcmp((const char *) node->name, "tokenize"))
- step = icu_chain_insert_step(chain, ICU_chain_step_type_tokenize,
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_tokenize,
(const uint8_t *) rule, status);
else if (!strcmp((const char *) node->name, "display"))
- step = icu_chain_insert_step(chain, ICU_chain_step_type_display,
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_display,
(const uint8_t *) "", status);
else if (!strcmp((const char *) node->name, "stemming"))
step = icu_chain_insert_step(chain, YAZ_chain_step_type_stemming,
{
yaz_log(YLOG_WARN, "Element %s is deprecated. "
"Use transform instead", node->name);
- step = icu_chain_insert_step(chain, ICU_chain_step_type_transform,
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_transform,
(const uint8_t *) rule, status);
}
else if (!strcmp((const char *) node->name, "index")
else
{
struct icu_buf_utf16 *dst = icu_iter_invoke(iter, step->previous, src);
-
+
switch (step->type)
{
case ICU_chain_step_type_casemap:
iter->steps : iter->chain->csteps,
iter->input);
iter->input = 0;
-
+
if (!iter->last)
return 0;
iter->token_count++;
if (iter->chain->sort)
- {
+ {
icu_sortkey8_from_utf16(iter->chain->coll,
iter->sort8, iter->last,
&iter->status);
}
const char *icu_iter_get_display(yaz_icu_iter_t iter)
-{
- return icu_buf_utf8_to_cstr(iter->display);
+{
+ return icu_buf_utf8_to_cstr(iter->display);
}
int icu_iter_get_token_number(yaz_icu_iter_t iter)
-{
+{
return iter->token_count;
}
-int icu_chain_assign_cstr(struct icu_chain *chain, const char *src8cstr,
+int icu_chain_assign_cstr(struct icu_chain *chain, const char *src8cstr,
UErrorCode *status)
{
if (chain->iter)
#include <unicode/uchar.h> /* char names */
void icu_sortkey8_from_utf16(UCollator *coll,
- struct icu_buf_utf8 * dest8,
+ struct icu_buf_utf8 * dest8,
struct icu_buf_utf16 * src16,
UErrorCode * status)
-{
+{
int32_t sortkey_len = 0;
/* we'll fake a capacity of one less, because it turns out
that ucol_getSortKey writes ONE character too much */
int32_t cap = dest8->utf8_cap ? dest8->utf8_cap - 1 : 0;
-
+
sortkey_len = ucol_getSortKey(coll, src16->utf16, src16->utf16_len,
dest8->utf8, cap);
if (U_SUCCESS(*status)
&& sortkey_len > 0)
dest8->utf8_len = sortkey_len;
- else
+ else
icu_buf_utf8_clear(dest8);
}
int32_t token_end;
/*
keep always invariant
- 0 <= token_start
- <= token_end
+ 0 <= token_start
+ <= token_end
<= buf16->utf16_len
and invariant
0 <= token_id <= token_count
icu_tokenizer_reset(tokenizer, action);
switch (tokenizer->action)
- {
+ {
case 'l':
case 'L':
tokenizer->bi = ubrk_open(UBRK_LINE, locale, 0, 0, status);
return 0;
break;
}
-
+
/* ICU error stuff is a very funny business */
if (U_SUCCESS(*status))
return tokenizer;
}
}
-int icu_tokenizer_attach(struct icu_tokenizer * tokenizer,
- struct icu_buf_utf16 * src16,
+int icu_tokenizer_attach(struct icu_tokenizer * tokenizer,
+ struct icu_buf_utf16 * src16,
UErrorCode *status)
{
if (!tokenizer || !tokenizer->bi || !src16)
ubrk_setText(tokenizer->bi,
tokenizer->buf16->utf16, tokenizer->buf16->utf16_len, status);
-
+
if (U_FAILURE(*status))
return 0;
return 1;
}
-int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer,
- struct icu_buf_utf16 * tkn16,
+int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer,
+ struct icu_buf_utf16 * tkn16,
UErrorCode *status)
{
int32_t tkn_start = 0;
return 0;
/*
never change tokenizer->buf16 and keep always invariant
- 0 <= tokenizer->token_start
- <= tokenizer->token_end
+ 0 <= tokenizer->token_start
+ <= tokenizer->token_end
<= tokenizer->buf16->utf16_len
returns length of token
*/
/* copy out if everything is well */
if (U_FAILURE(*status))
- return 0;
-
+ return 0;
+
/* everything OK, now update internal state */
tkn_len = tkn_end - tkn_start;
tokenizer->token_id++;
}
else
- tokenizer->token_id = 0;
+ tokenizer->token_id = 0;
tokenizer->token_start = tkn_start;
- tokenizer->token_end = tkn_end;
+ tokenizer->token_end = tkn_end;
/* copying into token buffer if it exists */
if (tkn16)
if (tkn16->utf16_cap < tkn_len)
icu_buf_utf16_resize(tkn16, (size_t) tkn_len * 2);
- u_strncpy(tkn16->utf16, &(tokenizer->buf16->utf16)[tkn_start],
+ u_strncpy(tkn16->utf16, &(tokenizer->buf16->utf16)[tkn_start],
tkn_len);
tkn16->utf16_len = tkn_len;
}
struct icu_transform * icu_transform_create(const char *id, char action,
- const char *rules,
+ const char *rules,
UErrorCode *status)
{
struct icu_buf_utf16 *id16 = icu_buf_utf16_create(0);
case 'f':
case 'F':
transform->trans
- = utrans_openU(id16->utf16,
+ = utrans_openU(id16->utf16,
id16->utf16_len,
UTRANS_FORWARD,
- rules16->utf16,
+ rules16->utf16,
rules16->utf16_len,
&transform->parse_error, status);
break;
= utrans_openU(id16->utf16,
id16->utf16_len,
UTRANS_REVERSE ,
- rules16->utf16,
+ rules16->utf16,
rules16->utf16_len,
&transform->parse_error, status);
break;
}
icu_buf_utf16_destroy(rules16);
icu_buf_utf16_destroy(id16);
-
+
if (U_SUCCESS(*status))
return transform;
const struct icu_buf_utf16 * src16,
UErrorCode *status)
{
- if (!transform || !transform->trans
+ if (!transform || !transform->trans
|| !src16 || !dest16)
return 0;
if (!icu_buf_utf16_copy(dest16, src16))
return 0;
- utrans_transUChars(transform->trans,
+ utrans_transUChars(transform->trans,
dest16->utf16, &(dest16->utf16_len),
dest16->utf16_cap,
0, &(dest16->utf16_len), status);
if (U_FAILURE(*status))
icu_buf_utf16_clear(dest16);
-
+
return dest16->utf16_len;
}
struct icu_buf_utf16 * icu_buf_utf16_create(size_t capacity)
{
- struct icu_buf_utf16 * buf16
+ struct icu_buf_utf16 * buf16
= (struct icu_buf_utf16 *) xmalloc(sizeof(struct icu_buf_utf16));
buf16->utf16 = 0;
{
if (!buf16)
return 0;
-
+
if (capacity > 0)
{
if (0 == buf16->utf16)
buf16->utf16 = (UChar *) xmalloc(sizeof(UChar) * capacity);
else
- buf16->utf16
+ buf16->utf16
= (UChar *) xrealloc(buf16->utf16, sizeof(UChar) * capacity);
icu_buf_utf16_clear(buf16);
buf16->utf16_cap = capacity;
- }
+ }
else
{
xfree(buf16->utf16);
struct icu_buf_utf8 *icu_buf_utf8_create(size_t capacity)
{
- struct icu_buf_utf8 * buf8
+ struct icu_buf_utf8 * buf8
= (struct icu_buf_utf8 *) xmalloc(sizeof(struct icu_buf_utf8));
buf8->utf8 = 0;
if (0 == buf8->utf8)
buf8->utf8 = (uint8_t *) xmalloc(sizeof(uint8_t) * capacity);
else
- buf8->utf8
+ buf8->utf8
= (uint8_t *) xrealloc(buf8->utf8, sizeof(uint8_t) * capacity);
-
+
buf8->utf8_cap = capacity;
- }
+ }
else
- {
+ {
xfree(buf8->utf8);
buf8->utf8 = 0;
buf8->utf8_len = 0;
buf8->utf8_cap = 0;
}
-
+
return buf8;
}
*status = U_ZERO_ERROR;
src8cstr_len = strlen(src8cstr);
-
+
u_strFromUTF8(dest16->utf16, dest16->utf16_cap,
&utf16_len,
src8cstr, src8cstr_len, status);
-
+
/* check for buffer overflow, resize and retry */
if (*status == U_BUFFER_OVERFLOW_ERROR)
{
if (U_SUCCESS(*status) && utf16_len <= dest16->utf16_cap)
dest16->utf16_len = utf16_len;
- else
+ else
icu_buf_utf16_clear(dest16);
-
+
return *status;
}
UErrorCode * status)
{
int32_t utf8_len = 0;
-
+
u_strToUTF8((char *) dest8->utf8, dest8->utf8_cap,
&utf8_len,
src16->utf16, src16->utf16_len, status);
-
+
/* check for buffer overflow, resize and retry */
if (*status == U_BUFFER_OVERFLOW_ERROR)
{
if (U_SUCCESS(*status) && utf8_len <= dest8->utf8_cap)
dest8->utf8_len = utf8_len;
- else
+ else
icu_buf_utf8_clear(dest8);
-
+
return *status;
}
char element[128];
const char *v;
bool_t *r = (bool_t *) odr_malloc(o, sizeof(*r));
-
+
strcpy(element, name);
if (sub)
{
strcat(element, ",");
strcat(element, sub);
- }
+ }
v = (gc->f)(gc->clientData, element);
if (v)
ODR o = gc->odr;
char element[128];
const char *v;
-
+
strcpy(element, name);
if (sub)
{
strcat(element, ",");
strcat(element, sub);
- }
+ }
v = (gc->f)(gc->clientData, element);
if (v)
val = atoi(v);
ODR o = gc->odr;
ILL_Person_Or_Institution_Symbol *p =
(ILL_Person_Or_Institution_Symbol *) odr_malloc(o, sizeof(*p));
-
+
strcpy(element, name);
if (sub)
{
ODR o = gc->odr;
ILL_Name_Of_Person_Or_Institution *p =
(ILL_Name_Of_Person_Or_Institution *) odr_malloc(o, sizeof(*p));
-
+
strcpy(element, name);
if (sub)
{
return p;
return 0;
}
-
+
ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
const char *name, const char *sub)
{
ODR o = gc->odr;
char element[128];
ILL_System_Id *p;
-
+
strcpy(element, name);
if (sub)
{
ODR o = gc->odr;
ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
strcat(element, ",");
strcat(element, sub);
- }
+ }
r->initial_requester_id =
ill_get_System_Id(gc, element, "initial-requester-id");
r->transaction_group_qualifier =
ILL_Service_Date_this *r =
(ILL_Service_Date_this *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
ILL_Service_Date_original *r =
(ILL_Service_Date_original *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
ILL_Service_Date_Time *r =
(ILL_Service_Date_Time *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
strcat(element, ",");
strcat(element, sub);
- }
+ }
r->date_time_of_this_service = ill_get_Service_Date_this(
gc, element, "this");
r->date_time_of_original_service = ill_get_Service_Date_original(
ILL_Requester_Optional_Messages_Type *r =
(ILL_Requester_Optional_Messages_Type *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
}
ILL_Item_Id *ill_get_Item_Id(
- struct ill_get_ctl *gc, const char *name, const char *sub)
+ struct ill_get_ctl *gc, const char *name, const char *sub)
{
ODR o = gc->odr;
ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
r->system_no = 0;
r->additional_no_letters =
ill_get_ILL_String(gc, element, "additional-no-letters");
- r->verification_reference_source =
+ r->verification_reference_source =
ill_get_ILL_String(gc, element, "verification-reference-source");
return r;
}
strcat(element, ",");
strcat(element, sub);
}
- r->name_of_person_or_institution =
+ r->name_of_person_or_institution =
ill_get_Name_Of_Person_Or_Institution(
gc, element, "name-of-person-or-institution");
r->extended_postal_delivery_address =
ILL_System_Address *r =
(ILL_System_Address *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
ILL_Delivery_Address *r =
(ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
ODR o = gc->odr;
ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
"need-before-date", 0);
r->expiry_date = ill_get_ILL_ISO_Date(gc, element, "expiry-date", 0);
r->expiry_flag = ill_get_enumerated(gc, element, "expiry-flag", 3);
-
+
return r;
}
ODR o = gc->odr;
ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
strcat(element, sub);
}
r->protocol_version_num =
- ill_get_enumerated(gc, element, "protocol-version-num",
+ ill_get_enumerated(gc, element, "protocol-version-num",
ILL_Request_version_2);
-
+
r->transaction_id = ill_get_Transaction_Id(gc, element, "transaction-id");
r->service_date_time =
ill_get_Service_Date_Time(gc, element, "service-date-time");
r->supply_medium_info_type = 0;
r->place_on_hold = ill_get_enumerated(
- gc, element, "place-on-hold",
+ gc, element, "place-on-hold",
ILL_Place_On_Hold_Type_according_to_responder_policy);
r->client_id = ill_get_Client_Id(gc, element, "client-id");
-
+
r->item_id = ill_get_Item_Id(gc, element, "item-id");
r->supplemental_item_description = 0;
r->cost_info_type = 0;
ODR o = gc->odr;
ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
strcat(element, sub);
}
r->protocol_version_num =
- ill_get_enumerated(gc, element, "protocol-version-num",
+ ill_get_enumerated(gc, element, "protocol-version-num",
ILL_Request_version_2);
-
+
r->transaction_id = ill_get_Transaction_Id(gc, element, "transaction-id");
r->service_date_time =
ill_get_Service_Date_Time(gc, element, "service-date-time");
r->supply_medium_info_type = 0;
r->place_on_hold = ill_get_enumerated(
- gc, element, "place-on-hold",
+ gc, element, "place-on-hold",
ILL_Place_On_Hold_Type_according_to_responder_policy);
r->client_id = ill_get_Client_Id(gc, element, "client-id");
-
+
r->item_id = ill_get_Item_Id(gc, element, "item-id");
r->supplemental_item_description = 0;
r->cost_info_type = 0;
ODR o = gc->odr;
ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r));
char element[128];
-
+
strcpy(element, name);
if (sub)
{
strcat(element, sub);
}
r->protocol_version_num =
- ill_get_enumerated(gc, element, "protocol-version-num",
+ ill_get_enumerated(gc, element, "protocol-version-num",
ILL_Request_version_2);
-
+
r->transaction_id = ill_get_Transaction_Id(gc, element, "transaction-id");
r->service_date_time =
ill_get_Service_Date_Time(gc, element, "service-date-time");
int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
{
const char *cp = opt_str;
-
+
ODR_MASK_ZERO(opt);
while (*cp)
{
inp++;
--inbytesleft;
(*no_read)++;
- }
+ }
if (inbytesleft == 0)
{
yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
}
switch (*inp) {
case 0xe1: /* alpha small */
- if (tonos)
+ if (tonos)
x = 0x03ac;
- else
+ else
x = 0x03b1;
break;
case 0xc1: /* alpha capital */
- if (tonos)
+ if (tonos)
x = 0x0386;
- else
+ else
x = 0x0391;
break;
x = 0x0394;
break;
case 0xe6: /* epsilon small */
- if (tonos)
+ if (tonos)
x = 0x03ad;
- else
+ else
x = 0x03b5;
break;
case 0xc6: /* epsilon capital */
- if (tonos)
+ if (tonos)
x = 0x0388;
- else
+ else
x = 0x0395;
break;
case 0xe9: /* Zeta small */
x = 0x0396;
break;
case 0xea: /* Eta small */
- if (tonos)
+ if (tonos)
x = 0x03ae;
- else
+ else
x = 0x03b7;
break;
case 0xca: /* Eta capital */
- if (tonos)
+ if (tonos)
x = 0x0389;
- else
+ else
x = 0x0397;
break;
case 0xeb: /* Theta small */
x = 0x0398;
break;
case 0xec: /* Iota small */
- if (tonos)
- if (dialitika)
+ if (tonos)
+ if (dialitika)
x = 0x0390;
- else
+ else
x = 0x03af;
- else
- if (dialitika)
+ else
+ if (dialitika)
x = 0x03ca;
- else
+ else
x = 0x03b9;
break;
case 0xcc: /* Iota capital */
- if (tonos)
+ if (tonos)
x = 0x038a;
- else
- if (dialitika)
+ else
+ if (dialitika)
x = 0x03aa;
- else
+ else
x = 0x0399;
break;
case 0xed: /* Kappa small */
x = 0x039e;
break;
case 0xf2: /* Omicron small */
- if (tonos)
+ if (tonos)
x = 0x03cc;
- else
+ else
x = 0x03bf;
break;
case 0xd2: /* Omicron capital */
- if (tonos)
+ if (tonos)
x = 0x038c;
- else
+ else
x = 0x039f;
break;
case 0xf3: /* Pi small */
x = 0x03a4;
break;
case 0xf9: /* Upsilon small */
- if (tonos)
- if (dialitika)
+ if (tonos)
+ if (dialitika)
x = 0x03b0;
- else
+ else
x = 0x03cd;
- else
- if (dialitika)
+ else
+ if (dialitika)
x = 0x03cb;
- else
+ else
x = 0x03c5;
break;
case 0xd9: /* Upsilon capital */
- if (tonos)
+ if (tonos)
x = 0x038e;
- else
- if (dialitika)
+ else
+ if (dialitika)
x = 0x03ab;
- else
+ else
x = 0x03a5;
break;
case 0xfa: /* Phi small */
x = 0x03a8;
break;
case 0xfd: /* Omega small */
- if (tonos)
+ if (tonos)
x = 0x03ce;
- else
+ else
x = 0x03c9;
break;
case 0xdd: /* Omega capital */
- if (tonos)
+ if (tonos)
x = 0x038f;
- else
+ else
x = 0x03a9;
break;
default:
break;
}
(*no_read)++;
-
+
return x;
}
json_parser_t json_parser_create(void)
{
json_parser_t p = (json_parser_t) xmalloc(sizeof(*p));
-
+
p->buf = 0;
p->cp = 0;
p->err_msg = 0;
}
n = json_new_node(p, json_node_string);
dst = n->u.string = (char *) xmalloc(l + 1);
-
+
cp = p->cp;
while (*cp && *cp != '"')
{
}
m2 = json_new_node(p, json_node_list);
m2->u.link[0] = n2;
-
+
m1->u.link[1] = m2;
m1 = m2;
}
}
m2 = json_new_node(p, json_node_list);
m2->u.link[0] = n2;
-
+
m1->u.link[1] = m2;
m1 = m2;
}
{ /* leave encoding as raw UTF-8 */
wrbuf_putc(b, cp[i]);
}
- }
-
+ }
+
}
void wrbuf_json_puts(WRBUF b, const char *str)
wrbuf_puts(result, "{");
if (indent >= 0)
{
- wrbuf_puts(result, "\n");
+ wrbuf_puts(result, "\n");
json_indent(result, sub_indent);
}
if (node->u.link[0])
struct json_node *json_get_object(struct json_node *n, const char *name)
{
struct json_node **np = json_get_objectp(n, name);
-
+
if (np)
return *np;
return 0;
struct json_node *json_detach_object(struct json_node *n, const char *name)
{
struct json_node **np = json_get_objectp(n, name);
-
+
if (np)
{
struct json_node *n = *np;
{ YLOG_TID, "tid" },
{ YLOG_APP, "app" },
{ YLOG_NOTIME, "notime" },
- { YLOG_APP2, "app2" },
+ { YLOG_APP2, "app2" },
{ YLOG_APP3, "app3" },
{ YLOG_ALL, "all" },
{ YLOG_FLUSH, "flush" },
- { YLOG_LOGLVL, "loglevel" },
+ { YLOG_LOGLVL, "loglevel" },
{ 0, "none" },
{ 0, NULL }
/* the rest will be filled in if the user defines dynamic modules*/
-};
+};
static unsigned int next_log_bit = YLOG_LAST_BIT<<1; /* first dynamic bit */
else
{
yaz_log_info.type = use_none; /* NULL name; use no file at all */
- yaz_log_info.l_fname[0] = '\0';
+ yaz_log_info.l_fname[0] = '\0';
}
yaz_log_reopen();
}
{
l_level = level;
yaz_log_reopen(); /* make sure we set buffering right */
- }
+ }
else
l_level = level;
{
strftime(dst, sz, fmt, tm);
}
-
+
static void yaz_log_to_file(int level, const char *log_message)
{
FILE *file;
#else
tm = localtime(&ti);
#endif
-
- yaz_log_open_check(tm, 0, "a");
+
+ yaz_log_open_check(tm, 0, "a");
file = yaz_log_file(); /* file may change in yaz_log_open_check */
if (file)
char tid[TID_LEN];
char flags[1024];
int i;
-
+
*flags = '\0';
for (i = 0; level && mask_names[i].name; i++)
if ( mask_names[i].mask & level)
{
- if (*mask_names[i].name && mask_names[i].mask &&
+ if (*mask_names[i].name && mask_names[i].mask &&
mask_names[i].mask != YLOG_ALL)
{
- if (strlen(flags) + strlen(mask_names[i].name)
+ if (strlen(flags) + strlen(mask_names[i].name)
< sizeof(flags) - 4)
{
strcat(flags, "[");
level &= ~mask_names[i].mask;
}
}
-
+
tbuf[0] = '\0';
if (!(l_level & YLOG_NOTIME))
{
void yaz_log_time_format(const char *fmt)
{
- if ( !fmt || !*fmt)
+ if ( !fmt || !*fmt)
{ /* no format, default to new */
l_actual_format = l_new_default_format;
- return;
+ return;
}
if (0==strcmp(fmt, "old"))
{ /* force the old format */
l_actual_format = l_old_default_format;
- return;
+ return;
}
/* else use custom format */
strncpy(l_custom_format, fmt, TIMEFORMAT_LEN-1);
char *p = namebuf;
char *start = namebuf;
if (buflen <= len)
- len = buflen-1;
+ len = buflen-1;
strncpy(namebuf, name, len);
namebuf[len] = '\0';
while ((p = strchr(start, '/')))
char clean[255];
char *n = clean_name(name, strlen(name), clean, sizeof(clean));
internal_log_init();
-
+
for (i = 0; mask_names[i].name; i++)
if (0==strcmp(n, mask_names[i].name))
{
yaz_log(YLOG_LOGLVL, "returning log bit 0x%x for '%s' %s",
- mask_names[i].mask, n,
+ mask_names[i].mask, n,
strcmp(n,name) ? name : "");
return mask_names[i].mask;
}
- yaz_log(YLOG_LOGLVL, "returning NO log bit for '%s' %s", n,
+ yaz_log(YLOG_LOGLVL, "returning NO log bit for '%s' %s", n,
strcmp(n, name) ? name : "" );
return 0;
}
{
level = atoi(str);
}
- else
+ else
{
char clean[509];
char *n = clean_name(str, (size_t) (p - str), clean, sizeof(clean));
int of, i;
char str[80];
int num_attributes = t->attributes->num_attributes;
-
+
for (of = 0; of < num_attributes; of++)
{
char attset_name_buf[OID_STR_MAX];
}
if (!attset_name)
attset_name = "";
- switch (element->which)
+ switch (element->which)
{
case Z_AttributeValue_numeric:
attrStr(*element->attributeType,
}
}
-static void zlog_structure(Z_RPNStructure *zs, int depth,
+static void zlog_structure(Z_RPNStructure *zs, int depth,
const Odr_oid *ast, int loglevel)
{
if (zs->which == Z_RPNStructure_complex)
" order=%s "
"rel=%s unit=%s",
depth, "", op->u.prox->exclusion ?
- (*op->u.prox->exclusion ? "T" : "F") : "N",
+ (*op->u.prox->exclusion ? "T" : "F") : "N",
*op->u.prox->distance,
*op->u.prox->ordered ? "T" : "F",
relToStr(*op->u.prox->relationType),
}
zlog_structure(zs->u.complex->s1, depth+2, ast, loglevel);
zlog_structure(zs->u.complex->s2, depth+2, ast, loglevel);
- }
+ }
else if (zs->which == Z_RPNStructure_simple)
{
if (zs->u.simple->which == Z_Operand_APT)
log_rpn_query_level(YLOG_LOG, rpn);
}
-void log_scan_term_level(int loglevel,
+void log_scan_term_level(int loglevel,
Z_AttributesPlusTerm *zapt, const Odr_oid *ast)
{
int depth = 0;
if (!loglevel)
return;
- if (zapt->term->which == Z_Term_general)
+ if (zapt->term->which == Z_Term_general)
{
yaz_log(loglevel, "%*.0s term '%.*s' (general)", depth, "",
zapt->term->u.general->len, zapt->term->u.general->buf);
void yaz_log_zquery_level(int loglevel, Z_Query *q)
{
if (!loglevel)
- return;
+ return;
switch (q->which)
{
case Z_Query_type_1: case Z_Query_type_101:
{
WRBUF hex = wrbuf_alloc();
/* Not all digits, so stop directory scan */
- wrbuf_write_escaped(hex, buf + entry_p,
+ wrbuf_write_escaped(hex, buf + entry_p,
length_data_entry + length_starting + 3);
yaz_marc_cprintf(mt, "Directory offset %d: Bad value for data"
" length and/or length starting (%s)", entry_p,
if (data_length <= 0 || data_offset < 0)
break;
-
+
if (yaz_marc_get_debug(mt))
{
yaz_marc_cprintf(mt, "Tag: %s. Directory offset %d: data-length %d,"
entry_p0, end_offset, record_length);
break;
}
-
+
if (memcmp (tag, "00", 2))
identifier_flag = 1; /* if not 00X assume subfields */
else if (indicator_length < 4 && indicator_length > 0)
{
/* controlfield */
int i0 = i;
- while (i < end_offset &&
+ while (i < end_offset &&
buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
i++;
yaz_marc_add_controlfield(mt, tag, buf+i0, i-i0);
return 1;
}
-
+
int yaz_marc_read_line(yaz_marc_t mt,
int (*getbyte)(void *client_data),
void (*ungetbyte)(int b, void *client_data),
{
const char *next;
size_t len;
-
+
assert(cp[0] == marker_ch);
cp++;
next = cp;
}
if (ptr_code->type == XML_TEXT_NODE)
{
- ctrl_data_len =
+ ctrl_data_len =
strlen((const char *)ptr_code->content);
}
else
/* note that indstr[0] is unused so we use indstr[1..] */
yaz_marc_add_datafield_xml(mt, ptr_tag,
indstr+1, strlen(indstr+1));
-
+
if (yaz_marc_read_xml_subfields(mt, ptr->children))
return -1;
}
{
int format = 0;
yaz_marc_reset(mt);
-
+
for(; ptr; ptr = ptr->next)
if (ptr->type == XML_ELEMENT_NODE)
{
ptr = ptr->children;
if (yaz_marc_read_xml_leader(mt, &ptr))
return -1;
-
+
switch (format)
{
case YAZ_MARC_MARCXML:
collection_first,
collection_second
};
-
+
/** \brief node types for yaz_marc_node */
enum YAZ_MARC_NODE_TYPE
-{
+{
YAZ_MARC_DATAFIELD,
YAZ_MARC_CONTROLFIELD,
YAZ_MARC_COMMENT,
size_t size);
#if YAZ_HAVE_XML2
static int yaz_marc_write_xml_turbo_xml(yaz_marc_t mt, xmlNode **root_ptr,
- const char *ns,
+ const char *ns,
const char *format,
const char *type);
#endif
}
/** \brief adds a attribute value to the element name if it is plain chars
-
+
If not, and if the attribute name is not null, it will append a
attribute element with the value if attribute name is null it will
return a non-zero value meaning it couldnt handle the value.
{
if (leader[offset] < ' ' || leader[offset] > 127)
{
- yaz_marc_cprintf(mt,
+ yaz_marc_cprintf(mt,
"Leader character at offset %d is non-ASCII. "
"Setting value to '%c'", offset, ch_default);
leader[offset] = ch_default;
check_ascii(mt, leader, 9, '#');
if (!atoi_n_check(leader+10, 1, indicator_length))
{
- yaz_marc_cprintf(mt,
+ yaz_marc_cprintf(mt,
"Indicator length at offset 10 should hold a digit."
" Assuming 2");
leader[10] = '2';
}
if (!atoi_n_check(leader+11, 1, identifier_length))
{
- yaz_marc_cprintf(mt,
+ yaz_marc_cprintf(mt,
"Identifier length at offset 11 should hold a digit."
" Assuming 2");
leader[11] = '2';
}
if (!atoi_n_check(leader+12, 5, base_address))
{
- yaz_marc_cprintf(mt,
+ yaz_marc_cprintf(mt,
"Base address at offsets 12..16 should hold a number."
" Assuming 0");
*base_address = 0;
check_ascii(mt, leader, 19, '#');
if (!atoi_n_check(leader+20, 1, length_data_entry))
{
- yaz_marc_cprintf(mt,
+ yaz_marc_cprintf(mt,
"Length data entry at offset 20 should hold a digit."
" Assuming 4");
*length_data_entry = 4;
}
if (!atoi_n_check(leader+22, 1, length_implementation))
{
- yaz_marc_cprintf(mt,
+ yaz_marc_cprintf(mt,
"Length implementation at offset 22 should hold a digit."
" Assuming 0");
*length_implementation = 0;
}
return 1; /* we don't know */
}
-
+
void yaz_marc_reset(yaz_marc_t mt)
{
nmem_reset(mt->nmem);
leader = n->u.leader;
break;
}
-
+
if (!leader)
return -1;
if (!atoi_n_check(leader+11, 1, &identifier_length))
switch(n->which)
{
case YAZ_MARC_COMMENT:
- wrbuf_iconv_write(wr, mt->iconv_cd,
+ wrbuf_iconv_write(wr, mt->iconv_cd,
n->u.comment, strlen(n->u.comment));
wrbuf_puts(wr, "\n");
break;
leader = n->u.leader;
break;
}
-
+
if (!leader)
return -1;
if (!atoi_n_check(leader+11, 1, &identifier_length))
{
size_t using_code_len = get_subfield_len(mt, s->code_data,
identifier_length);
-
- wrbuf_puts (wr, mt->subfield_str);
- wrbuf_iconv_write(wr, mt->iconv_cd, s->code_data,
+
+ wrbuf_puts (wr, mt->subfield_str);
+ wrbuf_iconv_write(wr, mt->iconv_cd, s->code_data,
using_code_len);
wrbuf_iconv_puts(wr, mt->iconv_cd, " ");
- wrbuf_iconv_puts(wr, mt->iconv_cd,
+ wrbuf_iconv_puts(wr, mt->iconv_cd,
s->code_data + using_code_len);
marc_iconv_reset(mt, wr);
}
break;
case YAZ_MARC_COMMENT:
wrbuf_puts(wr, "(");
- wrbuf_iconv_write(wr, mt->iconv_cd,
+ wrbuf_iconv_write(wr, mt->iconv_cd,
n->u.comment, strlen(n->u.comment));
marc_iconv_reset(mt, wr);
wrbuf_puts(wr, ")\n");
\retval -1 failure
*/
static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
- const char *ns,
+ const char *ns,
const char *format,
const char *type,
int turbo)
leader = n->u.leader;
break;
}
-
+
if (!leader)
return -1;
if (!atoi_n_check(leader+11, 1, &identifier_length))
return -1;
-
+
if (mt->enable_collection != no_collection)
{
if (mt->enable_collection == collection_first)
wrbuf_iconv_write_cdata(wr, mt->iconv_cd,
s->code_data, using_code_len);
wrbuf_iconv_puts(wr, mt->iconv_cd, "\">");
- }
+ }
else
{
element_name_append_attribute_value(mt, wr, "code", s->code_data, using_code_len);
}
static int yaz_marc_write_marcxml_ns(yaz_marc_t mt, WRBUF wr,
- const char *ns,
+ const char *ns,
const char *format,
const char *type,
int turbo)
{
char ind_str[6];
char ind_val[2];
-
+
ind_val[0] = n->u.datafield.indicator[i];
ind_val[1] = '\0';
sprintf(ind_str, "%s%d", indicator_name[1], i+1);
wrbuf_rewind(wr_cdata);
wrbuf_iconv_puts(wr_cdata, mt->iconv_cd, s->code_data + using_code_len);
marc_iconv_reset(mt, wr_cdata);
-
+
wrbuf_rewind(subfield_name);
wrbuf_puts(subfield_name, "s");
not_written = element_name_append_attribute_value(mt, subfield_name, 0, s->code_data, using_code_len) != 0;
}
static int yaz_marc_write_xml_turbo_xml(yaz_marc_t mt, xmlNode **root_ptr,
- const char *ns,
+ const char *ns,
const char *format,
const char *type)
{
leader = n->u.leader;
break;
}
-
+
if (!leader)
return -1;
if (!atoi_n_check(leader+11, 1, &identifier_length))
char field[10];
field[0] = 'c';
field[4] = '\0';
-
+
switch(n->which)
{
case YAZ_MARC_DATAFIELD:
wrbuf_rewind(wr_cdata);
wrbuf_iconv_puts(wr_cdata, mt->iconv_cd, n->u.controlfield.data);
marc_iconv_reset(mt, wr_cdata);
-
+
strncpy(field + 1, n->u.controlfield.tag, 3);
ptr = xmlNewTextChild(record_ptr, ns_record,
BAD_CAST field,
int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr,
- const char *ns,
+ const char *ns,
const char *format,
const char *type)
{
leader = n->u.leader;
break;
}
-
+
if (!leader)
return -1;
if (!atoi_n_check(leader+11, 1, &identifier_length))
wrbuf_rewind(wr_cdata);
wrbuf_iconv_puts(wr_cdata, mt->iconv_cd, n->u.controlfield.data);
marc_iconv_reset(mt, wr_cdata);
-
+
ptr = xmlNewTextChild(record_ptr, ns_record,
BAD_CAST "controlfield",
BAD_CAST wrbuf_cstr(wr_cdata));
-
+
xmlNewProp(ptr, BAD_CAST "tag", BAD_CAST n->u.controlfield.tag);
break;
case YAZ_MARC_COMMENT:
const char *leader = 0;
WRBUF wr_dir, wr_head, wr_data_tmp;
int base_address;
-
+
for (n = mt->nodes; n; n = n->next)
if (n->which == YAZ_MARC_LEADER)
leader = n->u.leader;
-
+
if (!leader)
return -1;
if (!atoi_n_check(leader+10, 1, &indicator_length))
wrbuf_printf(wr_dir, "%.3s", n->u.controlfield.tag);
wrbuf_rewind(wr_data_tmp);
- wrbuf_iconv_puts(wr_data_tmp, mt->iconv_cd,
+ wrbuf_iconv_puts(wr_data_tmp, mt->iconv_cd,
n->u.controlfield.data);
marc_iconv_reset(mt, wr_data_tmp);
wrbuf_iconv_putchar(wr_data_tmp, mt->iconv_cd, ' ');/* field sep */
wrbuf_printf(wr_head, "%05d", base_address);
/* from "original" leader */
wrbuf_write(wr_head, leader+17, 7);
-
+
wrbuf_write(wr, wrbuf_buf(wr_head), 24);
wrbuf_write(wr, wrbuf_buf(wr_dir), wrbuf_len(wr_dir));
wrbuf_destroy(wr_head);
{
const char *vp = strchr(val+1, '\'');
size_t len;
-
+
if (!vp)
return -1;
len = vp-val-1;
int yaz_marc_decode_formatstr(const char *arg)
{
- int mode = -1;
+ int mode = -1;
if (!strcmp(arg, "marc"))
mode = YAZ_MARC_ISO2709;
if (!strcmp(arg, "marcxml"))
return *text == '\0';
if (glob[0] == '*')
{
- do
+ do
{
if (yaz_match_glob(glob+1, text))
return 1;
EnterCriticalSection(&p->handle);
#elif YAZ_POSIX_THREADS
int r = 1; /* signal : not locked (yet) */
-
+
if (p->log_level)
{ /* debugging */
r = pthread_mutex_trylock(&p->handle);
static int log_level_initialized = 0;
static void free_block(struct nmem_block *p)
-{
+{
xfree(p->buf);
xfree(p);
if (log_level)
if (log_level)
yaz_log(log_level, "nmem get_block alloc new block size=%ld",
(long) get);
-
+
r = (struct nmem_block *) xmalloc(sizeof(*r));
r->buf = (char *)xmalloc(r->size = get);
r->top = 0;
void nmem_reset(NMEM n)
{
struct nmem_block *t;
-
+
yaz_log(log_level, "nmem_reset p=%p", n);
if (!n)
return;
log_level = yaz_log_module_level("nmem");
log_level_initialized = 1;
}
-
+
r = (struct nmem_control *)xmalloc(sizeof(*r));
r->blocks = 0;
{
if (!n)
return;
-
+
nmem_reset(n);
xfree(n);
}
fprintf(stderr, "%s: %s (code %d:%d)", message, odr_errlist[err], err, x);
if (e && *e)
fprintf(stderr, " element %s", e);
-
+
fprintf(stderr, "\n");
if (element_path)
{
void odr_set_stream(ODR o, void *handle,
- void (*stream_write)(ODR o,
+ void (*stream_write)(ODR o,
void *handle, int type,
const char *buf, int len),
void (*stream_close)(void *handle))
yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
yaz_log(log_level, "odr_reset o=%p", o);
}
-
+
void odr_destroy(ODR o)
{
nmem_destroy(o->mem);
(*p)->top = -1;
}
#if 0
- /* ignoring the cons helps with at least one target.
+ /* ignoring the cons helps with at least one target.
* http://bugzilla.indexdata.dk/cgi-bin/bugzilla/show_bug.cgi?id=24
*/
return ber_bitstring(o, *p, 0);
size_t outleft = 4 * inleft + 2;
char *outbuf = (char *) odr_malloc (o, outleft);
size_t ret;
-
+
t->buf = (unsigned char *) outbuf;
-
+
ret = yaz_iconv(o->op->iconv_handle, &inbuf, &inleft,
&outbuf, &outleft);
if (ret == (size_t)(-1))
size_t ret;
*p = outbuf;
-
+
ret = yaz_iconv (o->op->iconv_handle, &inbuf, &inleft,
&outbuf, &outleft);
if (ret == (size_t)(-1))
return 0;
}
inleft = outbuf - (char*) *p;
-
+
(*p)[inleft] = '\0'; /* null terminate it */
}
if (!*p)
int odr_sequence_end(ODR o)
{
- return odr_constructed_end(o);
+ return odr_constructed_end(o);
}
int odr_set_end(ODR o)
{
- return odr_constructed_end(o);
+ return odr_constructed_end(o);
}
static int odr_sequence_more(ODR o)
Odr_external *pp;
static Odr_arm arm[] =
{
- {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single,
+ {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single,
(Odr_fun)odr_any, "single"},
{ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet,
(Odr_fun)odr_octetstring, "octet"},
{
return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
ODR_VISIBLESTRING, opt, name);
-}
+}
/*
* a char may not be sufficient to hold a general string, but we'll deal
{
return odr_implicit_tag(o, odr_iconv_string, p, ODR_UNIVERSAL,
ODR_GENERALSTRING,opt, name);
-}
+}
int odr_graphicstring(ODR o, char **p, int opt, const char *name)
{
return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
ODR_GRAPHICSTRING, opt, name);
-}
+}
int odr_generalizedtime(ODR o, char **p, int opt, const char *name)
{
if (o->op->indent < 16)
odr_printf(o, "%*s", o->op->indent * 2, "");
else
- odr_printf(o, "level=%-7d%*s", o->op->indent,
+ odr_printf(o, "level=%-7d%*s", o->op->indent,
2 * (o->op->indent % 8) , "");
if (name)
odr_printf(o, "%s ", name);
int yaz_oid_is_iso2709(const Odr_oid *oid)
{
if (oid_oidlen(oid) == 6 && oid[0] == 1 && oid[1] == 2
- && oid[2] == 840 && oid[3] == 10003 && oid[4] == 5
+ && oid[2] == 840 && oid[3] == 10003 && oid[4] == 5
&& oid[5] <= 29 && oid[5] != 16)
return 1;
return 0;
for (; oid_db; oid_db = oid_db->next)
{
struct yaz_oid_entry *e = get_entries(oid_db);
-
+
for (; e->name; e++)
func(e->oid, e->oclass, e->name, client_data);
}
int i;
oidbuf[0] = '\0';
- for (i = 0; oid[i] != -1 && i < OID_SIZE; i++)
+ for (i = 0; oid[i] != -1 && i < OID_SIZE; i++)
{
yaz_snprintf(tmpbuf, sizeof(tmpbuf)-1, "%d", oid[i]);
if (i > 0)
wrbuf_puts(wrbuf, "<");
wrbuf_puts(wrbuf, elem);
wrbuf_puts(wrbuf, ">");
-
+
pos = wrbuf->pos; /* save position */
if (wrbuf_iconv_write_x(wrbuf, cd1, data, strlen(data), 1) && cd2)
{
if (r->bibliographicRecord)
{
Z_External *ext = r->bibliographicRecord;
-
+
wrbuf_puts(wrbuf, " <bibliographicRecord>\n");
if (ext->which == Z_External_octet)
yaz_marc_decode_wrbuf(mt, (const char *) ext->u.octet_aligned->buf,
else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
{
int j;
-
+
Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
-
+
opac_element_str(wrbuf, cd1, cd2, 2, "typeOfRecord",
d->typeOfRecord);
opac_element_str(wrbuf, cd1, cd2, 2, "encodingLevel",
const char *opt_buf = 0;
size_t i = 0;
int ch = 0;
-
+
if (arg_no >= argc)
return YAZ_OPTIONS_EOF;
if (arg_off == 0)
type = desc[i++];
}
if (desc_char == ch)
- {
+ {
if (type) /* option with argument */
{
if (argv[arg_no][arg_off])
}
}
return ch;
- }
+ }
}
*arg = argv[arg_no]+arg_off-1;
arg_no = arg_no + 1;
for (i = 0; i<otherInformation->num_elements; i++)
newlist[i] = otherInformation->list[i];
otherInformation->list = newlist;
-
+
otherInformation->list[i] = (Z_OtherInformationUnit*)
odr_malloc (odr, sizeof(Z_OtherInformationUnit));
if (oid)
odr_malloc (odr, sizeof(Z_InfoCategory));
otherInformation->list[i]->category->categoryTypeId = (Odr_oid*)
odr_oiddup (odr, oid);
- otherInformation->list[i]->category->categoryValue =
+ otherInformation->list[i]->category->categoryValue =
odr_intdup(odr, categoryValue);
}
else
otherInformation->list[i]->category = 0;
otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
otherInformation->list[i]->information.characterInfo = 0;
-
+
otherInformation->num_elements = i+1;
return otherInformation->list[i];
}
const Odr_oid *oid, int categoryValue, int delete_flag)
{
Z_OtherInformationUnit *oi;
-
+
if ((oi = yaz_oi_update(otherInformation, 0, oid, categoryValue,
delete_flag)) &&
oi->which == Z_OtherInfo_characterInfo)
* See the file LICENSE for details.
*/
/**
- * \file
+ * \file
* \brief Select, poll wrapper
*/
#if HAVE_CONFIG_H
}
tv.tv_sec = sec;
tv.tv_usec = nsec / 1000;
-
+
r = select(max_fd+1, &input, &output, &except, (sec == -1 ? 0 : &tv));
if (r >= 0)
{
};
static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
- int num_attr, int max_attr,
+ int num_attr, int max_attr,
Odr_int *attr_list, char **attr_clist,
Odr_oid **attr_set);
size_t off)
{
size_t len=strlen(src);
-
+
if (li->lex_len == len+off && !memcmp(li->lex_buf+off, src, len-off))
return 1;
return 0;
++(*qptr);
}
li->lex_buf = *qptr;
-
+
if (**qptr == li->escape_char && yaz_isdigit((*qptr)[1]))
{
++(li->lex_len);
char s[4];
int n = 0;
s[0] = *in;
- s[1] = *++in;
+ s[1] = *++in;
s[2] = *++in;
s[3] = '\0';
len = len - 2;
return 0;
}
}
- else
+ else
{
if (num_attr > 0)
attr_set[num_attr] = attr_set[num_attr-1];
memcpy(term_octet->buf, buf, len);
term_octet->size = term_octet->len = len;
term_octet->buf[term_octet->size] = 0; /* null terminate */
-
+
switch (term_type)
{
case Z_Term_general:
break;
case Z_Term_characterString:
term->which = Z_Term_characterString;
- term->u.characterString = (char*) term_octet->buf;
+ term->u.characterString = (char*) term_octet->buf;
/* null terminated above */
break;
case Z_Term_numeric:
li->error = YAZ_PQF_ERROR_PROXIMITY;
return NULL;
}
-
+
if (!lex (li))
{
li->error = YAZ_PQF_ERROR_MISSING;
}
static Z_Complex *rpn_complex(struct yaz_pqf_parser *li, ODR o,
- int num_attr, int max_attr,
+ int num_attr, int max_attr,
Odr_int *attr_list, char **attr_clist,
Odr_oid **attr_set)
{
#endif
lex(li);
}
-
+
static Z_RPNStructure *rpn_structure(struct yaz_pqf_parser *li, ODR o,
- int num_attr, int max_attr,
+ int num_attr, int max_attr,
Odr_int *attr_list,
char **attr_clist,
Odr_oid **attr_set)
facet_field->terms[facet_field->num_terms] =
(Z_FacetTerm *) odr_malloc(odr, sizeof(Z_FacetTerm));
facet_field->terms[facet_field->num_terms]->term = term;
- facet_field->terms[facet_field->num_terms]->count =
+ facet_field->terms[facet_field->num_terms]->count =
odr_intdup(odr, 0);
facet_field->num_terms++;
}
/*
* The table below should be moved to the ODR structure itself and
* be an image of the association context: To help
- * map indirect references when they show up.
+ * map indirect references when they show up.
*/
static Z_ext_typeent type_table[] =
{
encoding CHOICE {
single-ASN1-type [0] ABSTRACT_SYNTAX.&Type,
octet-aligned [1] IMPLICIT OCTET STRING,
- arbitrary [2] IMPLICIT BIT STRING
+ arbitrary [2] IMPLICIT BIT STRING
}
}
</pre>
return 0;
/* Save our decoding ODR members */
- o_bp = o->bp;
+ o_bp = o->bp;
o_buf = o->buf;
o_size = o->size;
r = (*type->fun)(o, &voidp, 0, 0);
(*p)->which = type->what;
(*p)->u.single_ASN1_type = (Odr_any*) voidp;
-
+
/* Restore our decoding ODR member */
- o->bp = o_bp;
+ o->bp = o_bp;
o->buf = o_buf;
o->size = o_size;
return r && odr_sequence_end(o);
}
if (zclass == ODR_CONTEXT && tag == 0 && cons == 1)
- {
+ {
/* It's single ASN.1 type, bias the CHOICE. */
odr_choice_bias(o, type->what);
}
else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs))
{ /* SUTRS is a single-ASN.1-type */
Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs));
-
+
thisext->which = Z_External_sutrs;
thisext->u.sutrs = sutrs;
sutrs->buf = (unsigned char *)odr_malloc(o, len);
if (element->attributeSet)
{
char oid_name_str[OID_STR_MAX];
- const char *setname = yaz_oid_to_string_buf(element->attributeSet,
+ const char *setname = yaz_oid_to_string_buf(element->attributeSet,
0, oid_name_str);
if (setname)
{
}
}
wrbuf_printf(b, ODR_INT_PRINTF "=", *element->attributeType);
- switch (element->which)
+ switch (element->which)
{
case Z_AttributeValue_numeric:
wrbuf_printf(b, ODR_INT_PRINTF, *element->value.numeric);
wrbuf_puts(b, element->value.complex->list[i]->u.string);
else if (element->value.complex->list[i]->which ==
Z_StringOrNumeric_numeric)
- wrbuf_printf(b, ODR_INT_PRINTF,
+ wrbuf_printf(b, ODR_INT_PRINTF,
*element->value.complex->list[i]->u.numeric);
}
break;
int i;
for (i = 0; i < num_attributes; i++)
yaz_attribute_element_to_wrbuf(b,zapt->attributes->attributes[i]);
-
+
switch (zapt->term->which)
{
case Z_Term_general:
else
wrbuf_putc(b, '0');
- wrbuf_printf(b, " " ODR_INT_PRINTF " %d "
+ wrbuf_printf(b, " " ODR_INT_PRINTF " %d "
ODR_INT_PRINTF " ", *op->u.prox->distance,
*op->u.prox->ordered,
*op->u.prox->relationType);
0, oid_name_str);
if (oid_name)
wrbuf_printf(b, "@attrset %s ", oid_name);
- }
+ }
yaz_rpnstructure_to_wrbuf(b, rpn->RPNStructure);
wrbuf_chop_right(b);
}
assert(b);
switch (q->which)
{
- case Z_Query_type_1:
+ case Z_Query_type_1:
case Z_Query_type_101:
wrbuf_puts(b,"RPN ");
yaz_rpnquery_to_wrbuf(b, q->u.type_1);
{
char *p;
int argc;
-
+
while ((p = fgets(line, len, f)))
{
(*lineno)++;
}
if (!p)
return 0;
-
+
for (argc = 0; *p && argc < num ; argc++)
{
if (*p == '#') /* trailing comment */
char line[512], *m_argv[50];
int m_argc;
int lineno = 0;
-
+
if (!(f = fopen(name, "r")))
{
yaz_log(YLOG_WARN|YLOG_ERRNO, "readconf: %s", name);
for (;;)
{
int res;
-
+
if (!(m_argc = readconf_line(f, &lineno, line, 512, m_argv, 50)))
{
fclose(f);
stylesheet, stylesheet);
if (path)
wrbuf_printf(wr_error, " with path '%s'", path);
-
+
return 0;
}
info->xsp_doc = xmlParseFile(fullpath);
wrbuf_printf(wr_error, " with path '%s'", path);
wrbuf_printf(wr_error, " ("
#if YAZ_HAVE_EXSLT
-
+
"EXSLT enabled"
#else
"EXSLT not supported"
{
xmlChar *out_buf = 0;
int out_len;
-
+
#if HAVE_XSLTSAVERESULTTOSTRING
xsltSaveResultToString(&out_buf, &out_len, res, xsp);
#else
{
wrbuf_rewind(record);
wrbuf_write(record, (const char *) out_buf, out_len);
-
+
xmlFree(out_buf);
}
xmlFreeDoc(res);
{
wrbuf_printf(wr_error, "Element <marc>: expected attributes"
"'inputformat', 'inputcharset', 'outputformat' or"
- " 'outputcharset', got attribute '%s'",
+ " 'outputcharset', got attribute '%s'",
attr->name);
nmem_destroy(info->nmem);
return 0;
{
info->input_format_mode = YAZ_MARC_MARCXML;
/** Libxml2 generates UTF-8 encoding by default .
- So we convert from UTF-8 to outputcharset (if defined)
+ So we convert from UTF-8 to outputcharset (if defined)
*/
if (!info->input_charset && info->output_charset)
info->input_charset = "utf-8";
{
wrbuf_printf(wr_error, "Element <marc inputformat='%s'>: "
" Unsupported input format"
- " defined by attribute value",
+ " defined by attribute value",
input_format);
nmem_destroy(info->nmem);
return 0;
}
-
+
if (!output_format)
{
- wrbuf_printf(wr_error,
+ wrbuf_printf(wr_error,
"Element <marc>: attribute 'outputformat' required");
nmem_destroy(info->nmem);
return 0;
{
wrbuf_printf(wr_error, "Element <marc outputformat='%s'>: "
" Unsupported output format"
- " defined by attribute value",
+ " defined by attribute value",
output_format);
nmem_destroy(info->nmem);
return 0;
info->input_charset);
if (!cd)
{
- wrbuf_printf(wr_error,
+ wrbuf_printf(wr_error,
"Element <marc inputcharset='%s' outputcharset='%s'>:"
" Unsupported character set mapping"
" defined by attribute values",
{
struct marc_info *mi = info;
int ret = 0;
-
+
yaz_iconv_t cd = yaz_iconv_open(mi->output_charset, mi->input_charset);
yaz_marc_t mt = yaz_marc_create();
-
+
yaz_marc_xml(mt, mi->output_format_mode);
if (mi->leader_spec)
yaz_marc_leader_spec(mt, mi->leader_spec);
-
+
if (cd)
yaz_marc_iconv(mt, cd);
if (mi->input_format_mode == YAZ_MARC_ISO2709)
static void destroy_marc(void *info)
{
struct marc_info *mi = info;
-
+
nmem_destroy(mi->nmem);
}
struct yaz_record_conv_type *types)
{
struct yaz_record_conv_type bt[2];
-
+
/* register marc */
bt[0].construct = construct_marc;
bt[0].convert = convert_marc;
#else
bt[0].next = types;
#endif
-
+
yaz_record_conv_reset(p);
/* parsing element children */
int ret = 0;
WRBUF record = output_record; /* pointer transfer */
wrbuf_rewind(p->wr_error);
-
+
wrbuf_write(record, input_record_buf, input_record_len);
for (; ret == 0 && r; r = r->next)
ret = r->type->convert(r->info, record, p->wr_error);
yaz_marc_t mt = yaz_marc_create();
yaz_iconv_t cd = yaz_iconv_open(mi->output_charset,
mi->input_charset);
-
+
wrbuf_rewind(p->wr_error);
yaz_marc_xml(mt, mi->output_format_mode);
-
+
yaz_marc_iconv(mt, cd);
-
+
yaz_opac_decode_wrbuf(mt, input_record, res);
if (ret != -1)
{
- ret = yaz_record_conv_record_rule(p,
+ ret = yaz_record_conv_record_rule(p,
r->next,
wrbuf_buf(res), wrbuf_len(res),
output_record);
p->rules = 0;
p->path = 0;
#if YAZ_HAVE_EXSLT
- exsltRegisterAll();
-#endif
+ exsltRegisterAll();
+#endif
return p;
}
if (record_charset && *record_charset)
{
char *cp = charset_buf;
-
+
strncpy(charset_buf, record_charset, sizeof(charset_buf)-1);
charset_buf[sizeof(charset_buf)-1] = '\0';
-
+
from_set1 = cp;
while (*cp && *cp != ',' && *cp != '/')
cp++;
cp++;
}
}
-
+
if (from_set1)
cd = yaz_iconv_open(to_set, from_set1);
if (cd2)
yaz_opac_decode_wrbuf2(mt, opac_rec, wrbuf, cd2);
else
yaz_opac_decode_wrbuf(mt, opac_rec, wrbuf);
-
+
yaz_marc_destroy(mt);
if (cd)
}
return 0;
}
-
+
static const char *get_record_format(WRBUF wrbuf, int *len,
Z_NamePlusRecord *npr,
int marctype, const char *charset,
xmlFreeDoc(doc);
res = wrbuf_cstr(wrbuf);
*len = wrbuf_len(wrbuf);
- }
+ }
}
#endif
return res;
}
else if (!strncmp(cp + i, "format=", 7))
{
- size_t j = 0;
+ size_t j = 0;
i = i + 7;
while (cp[i] == ' ')
i++;
format[j++] = cp[i];
}
format[j] = '\0';
- }
+ }
else if (!strncmp(cp + i, "base64=", 7))
{
size_t i0;
nmem = nmem_create();
base64_xpath = nmem_strdupn(nmem, cp + i0, i - i0);
- }
+ }
}
if (!strcmp(type, "database"))
{
}
else if (!strcmp(type, "syntax"))
{
- const char *desc = 0;
+ const char *desc = 0;
if (npr->which == Z_NamePlusRecord_databaseRecord)
{
Z_External *r = (Z_External *) npr->u.databaseRecord;
nmem_strdup(p->nmem, (const char *) attr->children->content);
else if (!xmlStrcmp(attr->name, BAD_CAST "name") &&
attr->children && attr->children->type == XML_TEXT_NODE)
- el->name =
+ el->name =
nmem_strdup(p->nmem, (const char *) attr->children->content);
else
{
/* parsing attributees */
for (attr = ptr->properties; attr; attr = attr->next)
{
- if (!xmlStrcmp(attr->name, BAD_CAST "name")
- && attr->children
+ if (!xmlStrcmp(attr->name, BAD_CAST "name")
+ && attr->children
&& attr->children->type == XML_TEXT_NODE)
- el->backend_name
- = nmem_strdup(p->nmem,
+ el->backend_name
+ = nmem_strdup(p->nmem,
(const char *) attr->children->content);
-
- else if (!xmlStrcmp(attr->name, BAD_CAST "syntax")
- && attr->children
+
+ else if (!xmlStrcmp(attr->name, BAD_CAST "syntax")
+ && attr->children
&& attr->children->type == XML_TEXT_NODE)
{
- el->backend_syntax
+ el->backend_syntax
= yaz_string_to_oid_odr(
yaz_oid_std(),
CLASS_RECSYN,
p->odr);
if (!el->backend_syntax)
{
- wrbuf_printf(p->wr_error,
+ wrbuf_printf(p->wr_error,
"Element <backend syntax='%s'>: "
"attribute 'syntax' has invalid "
- "value '%s'",
+ "value '%s'",
attr->children->content,
attr->children->content);
return -1;
- }
+ }
}
else
{
wrbuf_printf(p->wr_error, "Element <backend>: expected "
- "attributes 'syntax' or 'name, got '%s'",
+ "attributes 'syntax' or 'name, got '%s'",
attr->name);
return -1;
}
}
-
+
/* parsing internal of record conv */
el->record_conv = yaz_record_conv_create();
}
}
}
-
+
*p->list_p = el;
p->list_p = &el->next;
return 0;
else
{
wrbuf_printf(p->wr_error, "Element <retrievalinfo>: "
- "expected element <retrieval>, got <%s>",
+ "expected element <retrieval>, got <%s>",
ptr->name);
return -1;
}
if (!el->name && !el->identifier)
schema_ok = 1;
}
-
+
if (syntax && el->syntax && !oid_oidcmp(syntax, el->syntax))
syntax_ok = 1;
if (!syntax)
if (el->backend_name)
*backend_schema = el->backend_name;
else if (el->name)
- *backend_schema = el->name;
+ *backend_schema = el->name;
else
*backend_schema = schema;
}
switch (*relation)
{
/* Unsure on whether this is the relation attribute constants? */
- case Z_ProximityOperator_Prox_lessThan:
+ case Z_ProximityOperator_Prox_lessThan:
return "<";
- case Z_ProximityOperator_Prox_lessThanOrEqual:
- return "<=";
- case Z_ProximityOperator_Prox_equal:
- return "=";
- case Z_ProximityOperator_Prox_greaterThanOrEqual:
- return ">=";
- case Z_ProximityOperator_Prox_greaterThan:
- return ">";
- case Z_ProximityOperator_Prox_notEqual:
- return "<>";
- case 100:
+ case Z_ProximityOperator_Prox_lessThanOrEqual:
+ return "<=";
+ case Z_ProximityOperator_Prox_equal:
+ return "=";
+ case Z_ProximityOperator_Prox_greaterThanOrEqual:
+ return ">=";
+ case Z_ProximityOperator_Prox_greaterThan:
+ return ">";
+ case Z_ProximityOperator_Prox_notEqual:
+ return "<>";
+ case 100:
/* phonetic is not supported in CQL */
- return 0;
- case 101:
+ return 0;
+ case 101:
/* stem is not supported in CQL */
- return 0;
- case 102:
+ return 0;
+ case 102:
/* relevance is supported in CQL, but not implemented yet */
- return 0;
+ return 0;
default:
/* Invalid relation */
return 0;
index = lookup_index_from_string_attr(attributes);
/* Attempt to fix bug #2978: Look for a relation attribute */
- if (!relation)
+ if (!relation)
relation = lookup_relation_index_from_attr(attributes);
if (!index)
switch (*relation)
{
/* Unsure on whether this is the relation attribute constants? */
- case Z_ProximityOperator_Prox_lessThan:
+ case Z_ProximityOperator_Prox_lessThan:
return 0;
- case Z_ProximityOperator_Prox_lessThanOrEqual:
+ case Z_ProximityOperator_Prox_lessThanOrEqual:
return 0;
- case Z_ProximityOperator_Prox_equal:
+ case Z_ProximityOperator_Prox_equal:
return ":";
- case Z_ProximityOperator_Prox_greaterThanOrEqual:
+ case Z_ProximityOperator_Prox_greaterThanOrEqual:
return 0;
- case Z_ProximityOperator_Prox_greaterThan:
+ case Z_ProximityOperator_Prox_greaterThan:
return 0;
- case Z_ProximityOperator_Prox_notEqual:
+ case Z_ProximityOperator_Prox_notEqual:
return 0;
- case 100:
+ case 100:
/* phonetic is not implemented*/
- return 0;
- case 101:
+ return 0;
+ case 101:
/* stem is not not implemented */
- return 0;
- case 102:
+ return 0;
+ case 102:
/* relevance is supported in SOLR, but not implemented yet */
- return 0;
+ return 0;
default:
/* Invalid relation */
return 0;
index = lookup_index_from_string_attr(attributes);
/* Attempt to fix bug #2978: Look for a relation attribute */
- if (!relation)
+ if (!relation)
relation = lookup_relation_index_from_attr(attributes);
if (!index)
i++;
if (strchr(SOLR_SPECIAL, sterm[i]))
wrbuf_putc(w, '\\');
- wrbuf_putc(w, sterm[i]);
+ wrbuf_putc(w, sterm[i]);
}
else if (sterm[i] == '?' && trunc == 104)
{
}
}
-VOID sc_ReportSvcStatus(yaz_sc_t s,
+VOID sc_ReportSvcStatus(yaz_sc_t s,
DWORD dwCurrentState,
DWORD dwWin32ExitCode,
DWORD dwWaitHint)
if (dwCurrentState == SERVICE_START_PENDING)
s->gSvcStatus.dwControlsAccepted = 0;
- else
+ else
s->gSvcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
if ( (dwCurrentState == SERVICE_RUNNING) ||
(dwCurrentState == SERVICE_STOPPED) )
s->gSvcStatus.dwCheckPoint = 0;
- else
+ else
s->gSvcStatus.dwCheckPoint = dwCheckPoint++;
// Report the status of the service to the SCM.
static yaz_sc_t global_sc = 0;
-VOID WINAPI sc_SvcCtrlHandler(DWORD dwCtrl)
+VOID WINAPI sc_SvcCtrlHandler(DWORD dwCtrl)
{
- switch(dwCtrl)
- {
- case SERVICE_CONTROL_STOP:
+ switch(dwCtrl)
+ {
+ case SERVICE_CONTROL_STOP:
yaz_log(YLOG_LOG, "Service %s to stop", global_sc->service_name);
sc_ReportSvcStatus(global_sc, SERVICE_STOP_PENDING, NO_ERROR, 0);
global_sc->sc_stop(global_sc);
sc_ReportSvcStatus(global_sc, SERVICE_STOPPED, NO_ERROR, 0);
return;
- case SERVICE_CONTROL_INTERROGATE:
- break;
- default:
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+ default:
break;
}
}
yaz_log(YLOG_LOG, "Service %s starting", s->service_name);
- s->gSvcStatusHandle = RegisterServiceCtrlHandler(
+ s->gSvcStatusHandle = RegisterServiceCtrlHandler(
s->service_name, sc_SvcCtrlHandler);
if (!s->gSvcStatusHandle)
- {
+ {
yaz_log(YLOG_FATAL|YLOG_ERRNO, "RegisterServiceCtrlHandler");
- return;
- }
+ return;
+ }
- s->gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
- s->gSvcStatus.dwServiceSpecificExitCode = 0;
+ s->gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ s->gSvcStatus.dwServiceSpecificExitCode = 0;
sc_ReportSvcStatus(s, SERVICE_START_PENDING, NO_ERROR, 3000);
ret_code = s->sc_main(s, s->argc, s->argv);
-
+
sc_ReportSvcStatus(s, SERVICE_STOPPED,
ret_code ? ERROR_SERVICE_SPECIFIC_ERROR : NO_ERROR, ret_code);
}
wrbuf_puts(w, "\"");
yaz_log(YLOG_LOG, "path: %s", wrbuf_cstr(w));
- schService =
- CreateService(
+ schService =
+ CreateService(
manager, /* SCM database */
TEXT(s->service_name), /* name of service */
TEXT(s->display_name), /* service name to display */
NULL, /* no dependencies */
NULL, /* LocalSystem account */
NULL); /* no password */
- if (schService == NULL)
+ if (schService == NULL)
{
yaz_log(YLOG_FATAL|YLOG_ERRNO, "Service %s could not be installed",
s->service_name);
{
SC_HANDLE schService = 0;
SERVICE_STATUS serviceStatus;
-
+
schService = OpenService(manager, TEXT(s->service_name), SERVICE_ALL_ACCESS);
- if (schService == NULL)
+ if (schService == NULL)
{
yaz_log(YLOG_FATAL|YLOG_ERRNO, "Service %s could not be opened",
s->service_name);
if (!logbits_set)
{
logbits_set = 1;
- log_session = yaz_log_module_level("session");
+ log_session = yaz_log_module_level("session");
log_sessiondetail = yaz_log_module_level("sessiondetail");
log_request = yaz_log_module_level("request");
- log_requestdetail = yaz_log_module_level("requestdetail");
+ log_requestdetail = yaz_log_module_level("requestdetail");
}
}
wrbuf_puts(w, "+");
wrbuf_puts_replace_char(w, addinfo, ' ', '_');
}
- wrbuf_puts(w, " ");
+ wrbuf_puts(w, " ");
}
static int odr_int_to_int(Odr_int v)
if (*apdufile == '@')
{
odr_setprint(anew->print, yaz_log_file());
- }
+ }
else if (*apdufile != '-')
{
char filename[256];
{
Z_APDU *apdu = zget_APDU(a->encode, Z_APDU_close);
Z_Close *cls = apdu->u.close;
-
+
/* Purge request queue */
while (request_deq(&a->incoming));
while (request_deq(&a->outgoing));
association *assoc = (association *)iochan_getdata(h);
COMSTACK conn = assoc->client_link;
request *req;
-
+
if ((assoc->cs_put_mask & EVENT_INPUT) == 0 && (event & assoc->cs_get_mask))
{
/* We aren't speaking to this fellow */
yaz_log(log_session, "Connection error: %s res=%d",
cs_errmsg(cs_errno(conn)), res);
req = request_get(&assoc->incoming); /* get a new request */
- do_close_req(assoc, Z_Close_protocolError,
+ do_close_req(assoc, Z_Close_protocolError,
"Incoming package too large", req);
return 0;
}
return 0;
}
req->request_mem = odr_extract_mem(assoc->decode);
- if (assoc->print)
+ if (assoc->print)
{
if (!z_GDU(assoc->print, &req->gdu_request, 0, 0))
- yaz_log(YLOG_WARN, "ODR print error: %s",
+ yaz_log(YLOG_WARN, "ODR print error: %s",
odr_errmsg(odr_geterror(assoc->print)));
odr_reset(assoc->print);
}
* processing is initiated. Flow of control moves down through the
* various process_* functions below, until the encoded result comes back up
* to the output handler in here.
- *
+ *
* h : the I/O channel that has an outstanding event.
* event : the current outstanding event.
*/
return;
}
iochan_clearflag(h, EVENT_OUTPUT);
- if (conn->io_pending)
+ if (conn->io_pending)
{ /* cs_accept didn't complete */
- assoc->cs_accept_mask =
+ assoc->cs_accept_mask =
((conn->io_pending & CS_WANT_WRITE) ? EVENT_OUTPUT : 0) |
((conn->io_pending & CS_WANT_READ) ? EVENT_INPUT : 0);
assoc->init->charneg_response = NULL;
assoc->init->decode = assoc->decode;
- assoc->init->peer_name =
+ assoc->init->peer_name =
odr_strdup(assoc->encode, cs_addrstr(assoc->client_link));
yaz_log(log_requestdetail, "peer %s", assoc->init->peer_name);
yaz_log(log_requestdetail, "srw_bend_init config=%s", cb->configname);
assoc_init_reset(assoc);
-
+
if (sr->username)
{
Z_IdAuthentication *auth = (Z_IdAuthentication *)
size_t len;
len = strlen(sr->username) + 1;
- if (sr->password)
+ if (sr->password)
len += strlen(sr->password) + 2;
yaz_log(log_requestdetail, "username=%s password-len=%ld",
- sr->username, (long)
+ sr->username, (long)
(sr->password ? strlen(sr->password) : 0));
auth->which = Z_IdAuthentication_open;
auth->u.open = (char *) odr_malloc(assoc->decode, len);
int r;
const char *input_schema = yaz_get_esn(rr->comp);
Odr_oid *input_syntax_raw = rr->request_format;
-
+
const char *backend_schema = 0;
Odr_oid *backend_syntax = 0;
odr_malloc(assoc->decode, sizeof(Z_CompSpec));
rr.comp->u.complex->selectAlternativeSyntax = (bool_t *)
odr_malloc(assoc->encode, sizeof(bool_t));
- *rr.comp->u.complex->selectAlternativeSyntax = 0;
+ *rr.comp->u.complex->selectAlternativeSyntax = 0;
rr.comp->u.complex->num_dbSpecific = 0;
rr.comp->u.complex->dbSpecific = 0;
- rr.comp->u.complex->num_recordSyntax = 0;
+ rr.comp->u.complex->num_recordSyntax = 0;
rr.comp->u.complex->recordSyntax = 0;
- rr.comp->u.complex->generic = (Z_Specification *)
+ rr.comp->u.complex->generic = (Z_Specification *)
odr_malloc(assoc->decode, sizeof(Z_Specification));
/* schema uri = recordSchema (or NULL if recordSchema is not given) */
rr.comp->u.complex->generic->elementSpec = 0;
if (srw_req->recordSchema)
{
- rr.comp->u.complex->generic->elementSpec =
+ rr.comp->u.complex->generic->elementSpec =
(Z_ElementSpec *) odr_malloc(assoc->encode, sizeof(Z_ElementSpec));
- rr.comp->u.complex->generic->elementSpec->which =
+ rr.comp->u.complex->generic->elementSpec->which =
Z_ElementSpec_elementSetName;
rr.comp->u.complex->generic->elementSpec->u.elementSetName =
srw_req->recordSchema;
}
-
+
rr.stream = assoc->encode;
rr.print = assoc->print;
int srw_errcode = 0;
const char *add = 0;
WRBUF rpn_buf = wrbuf_alloc();
-
+
*sortkeys_p = 0;
r = cql_parser_string(cp, cql);
if (r)
{
char out[100];
int r = cql_sortby_to_sortkeys_buf(cn, out, sizeof(out)-1);
-
+
if (r == 0)
{
if (*out)
if (query.which != Z_Query_type_1 && query.which != Z_Query_type_101)
return YAZ_SRW_QUERY_SYNTAX_ERROR; /* bad query type */
rpn = query.u.type_1;
- if (!rpn->RPNStructure)
+ if (!rpn->RPNStructure)
return YAZ_SRW_QUERY_SYNTAX_ERROR; /* must be structure */
if (rpn->RPNStructure->which != Z_RPNStructure_simple)
return YAZ_SRW_QUERY_SYNTAX_ERROR; /* must be simple */
sizeof(*result));
return 0;
}
-
+
static int ccl2pqf(ODR odr, const Odr_oct *ccl, CCL_bibset bibset,
bend_search_rr *bsrr)
int srw_error = 0;
Z_External *ext;
Z_SRW_searchRetrieveRequest *srw_req = sr->u.request;
-
+
*http_code = 200;
yaz_log(log_requestdetail, "Got SRW SearchRetrieveRequest");
srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
rr.query->u.type_1 = 0;
rr.extra_args = sr->extra_args;
rr.extra_response_data = 0;
-
+
if (srw_req->query_type == Z_SRW_query_type_cql)
{
if (assoc->server && assoc->server->cql_transform)
{
/* CQL query to backend. Wrap it - Z39.50 style */
ext = (Z_External *) odr_malloc(assoc->decode, sizeof(*ext));
- ext->direct_reference = odr_getoidbystr(assoc->decode,
+ ext->direct_reference = odr_getoidbystr(assoc->decode,
"1.2.840.10003.16.2");
ext->indirect_reference = 0;
ext->descriptor = 0;
ext->which = Z_External_CQL;
ext->u.cql = srw_req->query.cql;
-
+
rr.query->which = Z_Query_type_104;
rr.query->u.type_104 = ext;
}
{
Z_RPNQuery *RPNquery;
YAZ_PQF_Parser pqf_parser;
-
+
pqf_parser = yaz_pqf_create();
-
+
RPNquery = yaz_pqf_parse(pqf_parser, assoc->decode,
srw_req->query.pqf);
if (!RPNquery)
code, pqf_msg, (long) off);
srw_error = YAZ_SRW_QUERY_SYNTAX_ERROR;
}
-
+
rr.query->which = Z_Query_type_1;
rr.query->u.type_1 = RPNquery;
-
+
yaz_pqf_destroy(pqf_parser);
}
else
rr.decode = assoc->decode;
rr.print = assoc->print;
if (srw_req->sort.sortKeys)
- rr.srw_sortKeys = odr_strdup(assoc->encode,
+ rr.srw_sortKeys = odr_strdup(assoc->encode,
srw_req->sort.sortKeys);
rr.association = assoc;
rr.hits = 0;
rr.search_info = 0;
rr.search_input = 0;
yaz_log_zquery_level(log_requestdetail,rr.query);
-
+
(assoc->init->bend_search)(assoc->backend, &rr);
if (rr.errcode)
{
odr_int_to_int(*srw_req->maximumRecords) : 0;
int start = srw_req->startRecord ?
odr_int_to_int(*srw_req->startRecord) : 1;
-
+
yaz_log(log_requestdetail, "Request to pack %d+%d out of "
ODR_INT_PRINTF,
start, number, rr.hits);
-
+
srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
if (rr.srw_setname)
{
srw_res->resultSetIdleTime =
odr_intdup(assoc->encode, *rr.srw_setnameIdleTime );
}
-
+
if (start > rr.hits || start < 1)
{
/* if hits<=0 and start=1 we don't return a diagnostic */
if (start != 1)
yaz_add_srw_diagnostic(
- assoc->encode,
+ assoc->encode,
&srw_res->diagnostics, &srw_res->num_diagnostics,
YAZ_SRW_FIRST_RECORD_POSITION_OUT_OF_RANGE, 0);
}
int ok = 1;
if (start + number > rr.hits)
number = odr_int_to_int(rr.hits) - start + 1;
-
+
/* Call bend_present if defined */
if (assoc->init->bend_present)
{
bprr->errcode = 0;
bprr->errstring = NULL;
(*assoc->init->bend_present)(assoc->backend, bprr);
-
+
if (bprr->errcode)
{
srw_error = yaz_diag_bib1_to_srw(bprr->errcode);
ok = 0;
}
}
-
+
if (ok)
{
int j = 0;
int packing = Z_SRW_recordPacking_string;
if (srw_req->recordPacking)
{
- packing =
+ packing =
yaz_srw_str_to_pack(srw_req->recordPacking);
if (packing == -1)
packing = Z_SRW_recordPacking_string;
srw_res->records = (Z_SRW_record *)
odr_malloc(assoc->encode,
number * sizeof(*srw_res->records));
-
+
srw_res->extra_records = (Z_SRW_extra_record **)
odr_malloc(assoc->encode,
number*sizeof(*srw_res->extra_records));
{
int errcode;
const char *addinfo = 0;
-
+
srw_res->records[j].recordPacking = packing;
srw_res->records[j].recordData_buf = 0;
srw_res->extra_records[j] = 0;
&srw_res->num_diagnostics,
yaz_diag_bib1_to_srw(errcode),
addinfo);
-
+
break;
}
if (srw_res->records[j].recordData_buf)
(srw_res->numberOfRecords ?
*srw_res->numberOfRecords : 0));
}
- wrbuf_printf(wr, " %s " ODR_INT_PRINTF "+%d",
+ wrbuf_printf(wr, " %s " ODR_INT_PRINTF "+%d",
(srw_res->resultSetId ?
srw_res->resultSetId : "-"),
- (srw_req->startRecord ? *srw_req->startRecord : 1),
+ (srw_req->startRecord ? *srw_req->startRecord : 1),
srw_res->num_records);
yaz_log(log_request, "%s %s: %s", wrbuf_cstr(wr), querytype, querystr);
wrbuf_destroy(wr);
char *content;
ptr = xmlCopyNode(ptr, 1);
-
+
xmlDocSetRootElement(doc, ptr);
-
+
xmlDocDumpMemory(doc, &buf_out, &len);
content = (char*) odr_malloc(rr->stream, 1+len);
memcpy(content, buf_out, len);
content[len] = '\0';
-
+
xmlFree(buf_out);
xmlFreeDoc(doc);
rr->explain_buf = content;
if (assoc->init)
{
bend_explain_rr rr;
-
+
rr.stream = assoc->encode;
rr.decode = assoc->decode;
rr.print = assoc->print;
int packing = Z_SRW_recordPacking_string;
if (srw_req->recordPacking)
{
- packing =
+ packing =
yaz_srw_str_to_pack(srw_req->recordPacking);
if (packing == -1)
packing = Z_SRW_recordPacking_string;
bsrr->entries = 0;
bsrr->setname = 0;
- if (bsrr->num_entries > 0)
+ if (bsrr->num_entries > 0)
{
int i;
- bsrr->entries = (struct scan_entry *)
+ bsrr->entries = (struct scan_entry *)
odr_malloc(assoc->decode, sizeof(*bsrr->entries) *
bsrr->num_entries);
for (i = 0; i<bsrr->num_entries; i++)
assoc->init->bend_scan)
{
YAZ_PQF_Parser pqf_parser = yaz_pqf_create();
-
+
bsrr->term = yaz_pqf_scan(pqf_parser, assoc->decode,
- &bsrr->attributeset,
- srw_req->scanClause.pqf);
+ &bsrr->attributeset,
+ srw_req->scanClause.pqf);
yaz_pqf_destroy(pqf_parser);
bsrr->scanClause = 0;
((int (*)(void *, bend_scan_rr *))
t->numberOfRecords =
odr_intdup(assoc->encode, bsrr->entries[i].occurrences);
t->displayTerm = 0;
- if (save_entries == bsrr->entries &&
+ if (save_entries == bsrr->entries &&
bsrr->entries[i].display_term)
{
/* the entries was _not_ set by the handler. So it's
safe to test for new member display_term. It is
NULL'ed by us.
*/
- t->displayTerm = odr_strdup(assoc->encode,
+ t->displayTerm = odr_strdup(assoc->encode,
bsrr->entries[i].display_term);
}
t->whereInList = 0;
wrbuf_printf(wr, "OK - - ");
wrbuf_printf(wr, ODR_INT_PRINTF "+" ODR_INT_PRINTF " ",
- (srw_req->responsePosition ?
+ (srw_req->responsePosition ?
*srw_req->responsePosition : 1),
(srw_req->maximumTerms ?
*srw_req->maximumTerms : 1));
{
bend_update_rr rr;
Z_SRW_extra_record *extra = srw_req->extra_record;
-
+
rr.stream = assoc->encode;
rr.print = assoc->print;
rr.num_bases = 1;
rr.uri = 0;
rr.message = 0;
rr.details = 0;
-
+
*http_code = 200;
if (rr.operation == 0)
{
if (srw_req->record)
{
rr.record_data = odr_strdupn(
- assoc->encode,
+ assoc->encode,
srw_req->record->recordData_buf,
srw_req->record->recordData_len );
}
if (extra && extra->extraRecordData_len)
{
rr.extra_record_data = odr_strdupn(
- assoc->encode,
+ assoc->encode,
extra->extraRecordData_buf,
extra->extraRecordData_len );
}
rr.record_id = srw_req->recordId;
else if (extra && extra->recordIdentifier)
rr.record_id = extra->recordIdentifier;
- else
+ else
{
yaz_add_sru_update_diagnostic(
assoc->encode, &srw_res->diagnostics,
YAZ_SRU_UPDATE_MISSING_MANDATORY_ELEMENT_RECORD_REJECTED,
"record");
}
- else
+ else
{
if (srw_req->record->recordSchema)
rr.record_schema = odr_strdup(
assoc->encode, srw_req->record->recordSchema);
if (srw_req->record->recordData_len )
{
- rr.record_data = odr_strdupn(assoc->encode,
+ rr.record_data = odr_strdupn(assoc->encode,
srw_req->record->recordData_buf,
srw_req->record->recordData_len );
}
- else
+ else
{
yaz_add_sru_update_diagnostic(
assoc->encode, &srw_res->diagnostics,
&srw_res->num_diagnostics,
- YAZ_SRU_UPDATE_MISSING_MANDATORY_ELEMENT_RECORD_REJECTED,
+ YAZ_SRU_UPDATE_MISSING_MANDATORY_ELEMENT_RECORD_REJECTED,
"recordData" );
}
}
if (extra && extra->extraRecordData_len)
{
rr.extra_record_data = odr_strdupn(
- assoc->encode,
+ assoc->encode,
extra->extraRecordData_buf,
extra->extraRecordData_len );
}
else if (!strcmp(rr.operation, "insert"))
{
if (srw_req->recordId)
- rr.record_id = srw_req->recordId;
+ rr.record_id = srw_req->recordId;
else if (extra)
rr.record_id = extra->recordIdentifier;
-
+
if (srw_req->record)
{
if (srw_req->record->recordSchema)
rr.record_schema = odr_strdup(
assoc->encode, srw_req->record->recordSchema);
-
+
if (srw_req->record->recordData_len)
rr.record_data = odr_strdupn(
- assoc->encode,
+ assoc->encode,
srw_req->record->recordData_buf,
srw_req->record->recordData_len );
}
if (extra && extra->extraRecordData_len)
{
rr.extra_record_data = odr_strdupn(
- assoc->encode,
+ assoc->encode,
extra->extraRecordData_buf,
extra->extraRecordData_len );
}
}
- else
+ else
yaz_add_sru_update_diagnostic(assoc->encode, &srw_res->diagnostics,
&srw_res->num_diagnostics,
YAZ_SRU_UPDATE_INVALID_ACTION,
if (srw_req->record)
{
- const char *pack_str =
+ const char *pack_str =
yaz_srw_pack_to_str(srw_req->record->recordPacking);
if (pack_str)
rr.record_packing = odr_strdup(assoc->encode, pack_str);
{
if ( assoc->init->bend_srw_update)
(*assoc->init->bend_srw_update)(assoc->backend, &rr);
- else
+ else
yaz_add_sru_update_diagnostic(
assoc->encode, &srw_res->diagnostics,
&srw_res->num_diagnostics,
yaz_add_srw_diagnostic_uri(assoc->encode,
&srw_res->diagnostics,
&srw_res->num_diagnostics,
- rr.uri,
+ rr.uri,
rr.message,
rr.details);
srw_res->recordId = rr.record_id;
srw_res->record->recordData_len = strlen(rr.record_data);
if (rr.extra_record_data)
{
- Z_SRW_extra_record *ex =
+ Z_SRW_extra_record *ex =
yaz_srw_get_extra_record(assoc->encode);
srw_res->extra_record = ex;
ex->extraRecordData_buf = rr.extra_record_data;
if (fread(buf, 1, *sz, inf) != *sz)
yaz_log(YLOG_WARN|YLOG_ERRNO, "short read %s", fname);
fclose(inf);
- return buf;
+ return buf;
}
static void process_http_request(association *assoc, request *req)
r = 1;
}
if (r == 2 && assoc->server && assoc->server->docpath
- && hreq->path[0] == '/'
- &&
+ && hreq->path[0] == '/'
+ &&
/* check if path is a proper prefix of documentroot */
strncmp(hreq->path+1, assoc->server->docpath,
strlen(assoc->server->docpath))
== 0)
- {
+ {
if (!check_path(hreq->path))
{
yaz_log(YLOG_LOG, "File %s access forbidden", hreq->path+1);
{
const char *ctype = 0;
yaz_mime_types types = yaz_mime_types_create();
-
+
yaz_mime_types_add(types, "xsl", "application/xml");
yaz_mime_types_add(types, "xml", "application/xml");
yaz_mime_types_add(types, "css", "text/css");
yaz_mime_types_add(types, "htm", "text/html");
yaz_mime_types_add(types, "txt", "text/plain");
yaz_mime_types_add(types, "js", "application/x-javascript");
-
+
yaz_mime_types_add(types, "gif", "image/gif");
yaz_mime_types_add(types, "png", "image/png");
yaz_mime_types_add(types, "jpg", "image/jpeg");
yaz_mime_types_add(types, "jpeg", "image/jpeg");
-
+
ctype = yaz_mime_lookup_fname(types, hreq->path);
if (!ctype)
{
sr->srw_version);
stylesheet = sr->u.explain_request->stylesheet;
if (num_diagnostic)
- {
+ {
res->u.explain_response->diagnostics = diagnostic;
res->u.explain_response->num_diagnostics = num_diagnostic;
}
sr->srw_version);
stylesheet = sr->u.scan_request->stylesheet;
if (num_diagnostic)
- {
+ {
res->u.scan_response->diagnostics = diagnostic;
res->u.scan_response->num_diagnostics = num_diagnostic;
}
sr->srw_version);
yaz_log(YLOG_DEBUG, "handling SRW UpdateRequest");
if (num_diagnostic)
- {
+ {
res->u.update_response->diagnostics = diagnostic;
res->u.update_response->num_diagnostics = num_diagnostic;
}
}
else
{
- yaz_log(log_request, "SOAP ERROR");
+ yaz_log(log_request, "SOAP ERROR");
/* FIXME - what error, what query */
http_code = 500;
z_soap_error(assoc->encode, soap_package,
- "SOAP-ENV:Client", "Bad method", 0);
+ "SOAP-ENV:Client", "Bad method", 0);
}
if (http_code == 200 || http_code == 500)
{
if (p == 0)
p = z_get_HTTP_Response(o, 500);
hres = p->u.HTTP_Response;
- if (!strcmp(hreq->version, "1.0"))
+ if (!strcmp(hreq->version, "1.0"))
{
const char *v = z_HTTP_header_lookup(hreq->headers, "Connection");
if (v && !strcmp(v, "Keep-Alive"))
{
Z_APDU *res;
int retval;
-
+
*msg = "Unknown Error";
assert(req && req->state == REQUEST_IDLE);
if (req->apdu_request->which != Z_APDU_initRequest && !assoc->init)
if (assoc->print)
{
if (!z_GDU(assoc->print, &res, 0, 0))
- yaz_log(YLOG_WARN, "ODR print error: %s",
+ yaz_log(YLOG_WARN, "ODR print error: %s",
odr_errmsg(odr_geterror(assoc->print)));
odr_reset(assoc->print);
}
if (req->implementationVersion)
yaz_log(log_requestdetail, "Version: %s",
req->implementationVersion);
-
+
assoc_init_reset(assoc);
assoc->init->auth = req->idAuthentication;
if (req->implementationVersion)
yaz_log(log_requestdetail, "Config: %s",
cb->configname);
-
+
iochan_settimeout(assoc->client_chan, cb->idle_timeout);
-
+
/* we have a backend control block, so call that init function */
if (!(binitres = (*cb->bend_init)(assoc->init)))
{
if ((assoc->init->bend_search))
yaz_log(YLOG_DEBUG, "Search handler installed");
if ((assoc->init->bend_present))
- yaz_log(YLOG_DEBUG, "Present handler installed");
+ yaz_log(YLOG_DEBUG, "Present handler installed");
if ((assoc->init->bend_esrequest))
- yaz_log(YLOG_DEBUG, "ESRequest handler installed");
+ yaz_log(YLOG_DEBUG, "ESRequest handler installed");
if ((assoc->init->bend_delete))
- yaz_log(YLOG_DEBUG, "Delete handler installed");
+ yaz_log(YLOG_DEBUG, "Delete handler installed");
if ((assoc->init->bend_scan))
- yaz_log(YLOG_DEBUG, "Scan handler installed");
+ yaz_log(YLOG_DEBUG, "Scan handler installed");
if ((assoc->init->bend_segment))
- yaz_log(YLOG_DEBUG, "Segment handler installed");
-
+ yaz_log(YLOG_DEBUG, "Segment handler installed");
+
resp->referenceId = req->referenceId;
*options = '\0';
/* let's tell the client what we can do */
ODR_MASK_SET(resp->options, Z_Options_sort);
strcat(options, " sort");
}
-
+
if (ODR_MASK_GET(req->options, Z_Options_negotiationModel))
{
Z_OtherInformationUnit *p0;
if (assoc->init->query_charset)
{
assoc->init->charneg_response = yaz_set_response_charneg(
- assoc->encode, assoc->init->query_charset, 0,
+ assoc->encode, assoc->init->query_charset, 0,
assoc->init->records_in_same_charset);
}
else
resp->preferredMessageSize =
odr_intdup(assoc->encode, assoc->preferredMessageSize);
- resp->maximumRecordSize =
+ resp->maximumRecordSize =
odr_intdup(assoc->encode, assoc->maximumRecordSize);
resp->implementationId = odr_prepend(assoc->encode,
}
else
assoc->state = ASSOC_UP;
-
+
if (log_request)
{
if (!req->idAuthentication)
yaz_log(log_request, "Auth idPass %s %s",
user ? user : "-", group ? group : "-");
}
- else if (req->idAuthentication->which
+ else if (req->idAuthentication->which
== Z_IdAuthentication_anonymous)
{
yaz_log(log_request, "Auth anonymous");
else
wrbuf_printf(wr, "OK -");
wrbuf_printf(wr, " ID:%s Name:%s Version:%s",
- (req->implementationId ? req->implementationId :"-"),
+ (req->implementationId ? req->implementationId :"-"),
(req->implementationName ?
req->implementationName : "-"),
(req->implementationVersion ?
/*
* surrogate diagnostic.
*/
-static Z_NamePlusRecord *surrogatediagrec(association *assoc,
+static Z_NamePlusRecord *surrogatediagrec(association *assoc,
const char *dbname,
int error, const char *addinfo)
{
*pres = Z_PresentStatus_failure;
/* for 'present request out of range',
set addinfo to record position if not set */
- if (freq.errcode == YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE &&
+ if (freq.errcode == YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE &&
freq.errstring == 0)
{
sprintf(s, "%d", recno);
static Z_APDU *process_searchRequest(association *assoc, request *reqb)
{
Z_SearchRequest *req = reqb->apdu_request->u.searchRequest;
- bend_search_rr *bsrr =
+ bend_search_rr *bsrr =
(bend_search_rr *)nmem_malloc(reqb->request_mem, sizeof(*bsrr));
-
+
yaz_log(log_requestdetail, "Got SearchRequest.");
bsrr->association = assoc;
bsrr->referenceId = req->referenceId;
bsrr->search_info = NULL;
bsrr->search_input = req->otherInfo;
- if (assoc->server && assoc->server->cql_transform
+ if (assoc->server && assoc->server->cql_transform
&& req->query->which == Z_Query_type_104
&& req->query->u.type_104->which == Z_External_CQL)
{
/* have a CQL query and a CQL to PQF transform .. */
- int srw_errcode =
+ int srw_errcode =
cql2pqf(bsrr->stream, req->query->u.type_104->u.cql,
assoc->server->cql_transform, bsrr->query,
&bsrr->srw_sortKeys);
bsrr->errcode = yaz_diag_srw_to_bib1(srw_errcode);
}
- if (assoc->server && assoc->server->ccl_transform
+ if (assoc->server && assoc->server->ccl_transform
&& req->query->which == Z_Query_type_2) /*CCL*/
{
/* have a CCL query and a CCL to PQF transform .. */
- int srw_errcode =
+ int srw_errcode =
ccl2pqf(bsrr->stream, req->query->u.type_2,
assoc->server->ccl_transform, bsrr);
if (srw_errcode)
(assoc->init->bend_search)(assoc->backend, bsrr);
}
else
- {
+ {
/* FIXME - make a diagnostic for it */
yaz_log(YLOG_WARN,"Search not supported ?!?!");
}
resp->resultSetStatus = 0;
if (bsrt->estimated_hit_count)
{
- resp->resultSetStatus = odr_intdup(assoc->encode,
+ resp->resultSetStatus = odr_intdup(assoc->encode,
Z_SearchResponse_estimate);
}
else if (bsrt->partial_resultset)
{
- resp->resultSetStatus = odr_intdup(assoc->encode,
+ resp->resultSetStatus = odr_intdup(assoc->encode,
Z_SearchResponse_subset);
}
}
wrbuf_puts(wr, req->databaseNames[i]);
}
wrbuf_printf(wr, " ");
-
+
if (bsrt->errcode)
wrbuf_printf(wr, "ERROR %d", bsrt->errcode);
else
wrbuf_printf(wr, " %s 1+" ODR_INT_PRINTF " ",
req->resultSetName, returnedrecs);
yaz_query_to_wrbuf(wr, req->query);
-
+
yaz_log(log_request, "Search %s", wrbuf_cstr(wr));
wrbuf_destroy(wr);
}
bprr->errcode = 0;
bprr->errstring = NULL;
(*assoc->init->bend_present)(assoc->backend, bprr);
-
+
if (bprr->errcode)
{
resp->records = diagrec(assoc, bprr->errcode, bprr->errstring);
apdu = (Z_APDU *)odr_malloc(assoc->encode, sizeof(*apdu));
next = odr_intdup(assoc->encode, 0);
num = odr_intdup(assoc->encode, 0);
-
+
apdu->which = Z_APDU_presentResponse;
apdu->u.presentResponse = resp;
resp->referenceId = req->referenceId;
resp->otherInfo = 0;
-
+
if (!resp->records)
{
*num = *req->numberOfRecordsRequested;
pack_records(assoc, req->resultSetId, *req->resultSetStartPoint,
num, req->recordComposition, next,
resp->presentStatus,
- req->referenceId, req->preferredRecordSyntax,
+ req->referenceId, req->preferredRecordSyntax,
&errcode);
}
if (log_request)
return 0;
resp->numberOfRecordsReturned = num;
resp->nextResultSetPosition = next;
-
+
return apdu;
}
bsrr->stream = assoc->encode;
bsrr->print = assoc->print;
bsrr->step_size = &step_size;
- bsrr->setname = yaz_oi_get_string_oid(&req->otherInfo,
+ bsrr->setname = yaz_oi_get_string_oid(&req->otherInfo,
yaz_oid_userinfo_scan_set, 1, 0);
bsrr->entries = 0;
/* For YAZ 2.0 and earlier it was the backend handler that
entries was modified - we assume that it is an old handler and
that 'display_term' is _not_ set.
*/
- if (bsrr->num_entries > 0)
+ if (bsrr->num_entries > 0)
{
int i;
bsrr->entries = (struct scan_entry *)
save_entries = bsrr->entries; /* save it so we can compare later */
bsrr->attributeset = req->attributeSet;
- log_scan_term_level(log_requestdetail, req->termListAndStartPoint,
+ log_scan_term_level(log_requestdetail, req->termListAndStartPoint,
bsrr->attributeset);
bsrr->term_position = req->preferredPositionInResponse ?
odr_int_to_int(*req->preferredPositionInResponse) : 1;
int i;
Z_Entry **tab = (Z_Entry **)
odr_malloc(assoc->encode, sizeof(*tab) * bsrr->num_entries);
-
+
if (bsrr->status == BEND_SCAN_PARTIAL)
*scanStatus = Z_Scan_partial_5;
else
res->stepSize = odr_intdup(assoc->encode, step_size);
ents->entries = tab;
ents->num_entries = bsrr->num_entries;
- res->numberOfEntriesReturned = odr_intdup(assoc->encode,
+ res->numberOfEntriesReturned = odr_intdup(assoc->encode,
ents->num_entries);
res->positionOfTerm = odr_intdup(assoc->encode, bsrr->term_position);
for (i = 0; i < bsrr->num_entries; i++)
Z_Entry *e;
Z_TermInfo *t;
Odr_oct *o;
-
+
tab[i] = e = (Z_Entry *)odr_malloc(assoc->encode, sizeof(*e));
if (bsrr->entries[i].occurrences >= 0)
{
odr_malloc(assoc->encode, sizeof(*t));
t->suggestedAttributes = 0;
t->displayTerm = 0;
- if (save_entries == bsrr->entries &&
+ if (save_entries == bsrr->entries &&
bsrr->entries[i].display_term)
{
/* the entries was _not_ set by the handler. So it's
}
wrbuf_printf(wr, " ");
-
+
if (bsrr->errcode)
wr_diag(wr, bsrr->errcode, bsrr->errstring);
else
- wrbuf_printf(wr, "OK");
+ wrbuf_printf(wr, "OK");
- wrbuf_printf(wr, " " ODR_INT_PRINTF " - " ODR_INT_PRINTF "+"
+ wrbuf_printf(wr, " " ODR_INT_PRINTF " - " ODR_INT_PRINTF "+"
ODR_INT_PRINTF "+" ODR_INT_PRINTF,
res->numberOfEntriesReturned ?
*res->numberOfEntriesReturned : 0,
*req->preferredPositionInResponse : 1),
*req->numberOfTermsRequested,
(res->stepSize ? *res->stepSize : 1));
-
+
if (bsrr->setname)
wrbuf_printf(wr, "+%s", bsrr->setname);
wrbuf_printf(wr, " ");
- yaz_scan_to_wrbuf(wr, req->termListAndStartPoint,
+ yaz_scan_to_wrbuf(wr, req->termListAndStartPoint,
bsrr->attributeset);
yaz_log(log_request, "%s", wrbuf_cstr(wr) );
wrbuf_destroy(wr);
bsrr->sort_status = Z_SortResponse_failure;
bsrr->errcode = 0;
bsrr->errstring = 0;
-
+
(*assoc->init->bend_sort)(assoc->backend, bsrr);
-
+
res->referenceId = bsrr->referenceId;
res->sortStatus = odr_intdup(assoc->encode, bsrr->sort_status);
res->resultSetStatus = 0;
bdrr->statuses = 0;
if (bdrr->num_setnames > 0)
{
- bdrr->statuses = (int*)
+ bdrr->statuses = (int*)
odr_malloc(assoc->encode, sizeof(*bdrr->statuses) *
bdrr->num_setnames);
for (i = 0; i < bdrr->num_setnames; i++)
bdrr->statuses[i] = 0;
}
(*assoc->init->bend_delete)(assoc->backend, bdrr);
-
+
res->referenceId = req->referenceId;
res->deleteOperationStatus = odr_intdup(assoc->encode,bdrr->delete_status);
res->deleteListStatuses->num = bdrr->num_setnames;
res->deleteListStatuses->elements =
(Z_ListStatus **)
- odr_malloc(assoc->encode,
+ odr_malloc(assoc->encode,
sizeof(*res->deleteListStatuses->elements) *
bdrr->num_setnames);
for (i = 0; i<bdrr->num_setnames; i++)
req.decode = assoc->decode;
req.print = assoc->print;
req.association = assoc;
-
+
(*assoc->init->bend_segment)(assoc->backend, &req);
return 0;
esrequest.association = assoc;
esrequest.taskPackage = 0;
esrequest.referenceId = req->referenceId;
-
+
if (esrequest.esr && esrequest.esr->taskSpecificParameters)
{
switch(esrequest.esr->taskSpecificParameters->which)
}
(*assoc->init->bend_esrequest)(assoc->backend, &esrequest);
-
+
resp->referenceId = req->referenceId;
if (esrequest.errcode == -1)
void *clientData;
struct request *next;
- struct request_q *q;
+ struct request_q *q;
} request;
typedef struct request_q
if (cd->init_flag)
{
cd->my_errno = YAZ_ICONV_UNKNOWN;
-
+
if (cd->encoder.init_handle)
(*cd->encoder.init_handle)(&cd->encoder);
-
+
cd->unget_x = 0;
cd->no_read_x = 0;
size_t r = (cd->decoder.init_handle)(
cd, &cd->decoder,
inbuf ? (unsigned char *) *inbuf : 0,
- inbytesleft ? *inbytesleft : 0,
+ inbytesleft ? *inbytesleft : 0,
&no_read);
if (r)
{
break;
}
x = (*cd->decoder.read_handle)(
- cd, &cd->decoder,
+ cd, &cd->decoder,
(unsigned char *) *inbuf, *inbytesleft, &no_read);
if (no_read == 0)
{
static const char *soap_v1_1 = "http://schemas.xmlsoap.org/soap/envelope/";
static const char *soap_v1_2 = "http://www.w3.org/2001/06/soap-envelope";
-int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
+int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers,
const char *encoding,
"No Envelope element", 0);
}
/* check for SRU root node match */
-
+
for (i = 0; handlers[i].ns; i++)
if (yaz_match_glob(handlers[i].ns, (const char *)ptr->ns->href))
break;
ret = (*handlers[i].f)(o, &p_top_tmp, &handler_data,
handlers[i].client_data,
(const char *)ptr->ns->href);
-
+
if (ret || !handler_data)
z_soap_error(o, p, "SOAP-ENV:Client",
"SOAP Handler returned error", 0);
ptr = ptr->next;
}
/* check that Body is present */
- if (!ptr || ptr->type != XML_ELEMENT_NODE ||
+ if (!ptr || ptr->type != XML_ELEMENT_NODE ||
xmlStrcmp(ptr->name, BAD_CAST "Body"))
{
xmlFreeDoc(doc);
}
else
{
- ret = z_soap_error(o, p, "SOAP-ENV:Client",
+ ret = z_soap_error(o, p, "SOAP-ENV:Client",
"No handler for NS", ns);
}
}
Z_SOAP_Fault *f = p->u.fault;
xmlNodePtr fault_ptr = xmlNewChild(body_ptr, ns_env,
BAD_CAST "Fault", 0);
- xmlNewChild(fault_ptr, ns_env, BAD_CAST "faultcode",
+ xmlNewChild(fault_ptr, ns_env, BAD_CAST "faultcode",
BAD_CAST f->fault_code);
xmlNewChild(fault_ptr, ns_env, BAD_CAST "faultstring",
BAD_CAST f->fault_string);
else if (p->which == Z_SOAP_generic)
{
int ret, no = p->u.generic->no;
-
+
ret = (*handlers[no].f)(o, body_ptr, &p->u.generic->p,
handlers[no].client_data,
handlers[no].ns);
if (stylesheet)
{
char *content = (char *) odr_malloc(o, strlen(stylesheet) + 40);
-
+
xmlNodePtr pi, ptr = xmlDocGetRootElement(doc);
sprintf(content, "type=\"text/xsl\" href=\"%s\"", stylesheet);
pi = xmlNewPI(BAD_CAST "xml-stylesheet",
return 0;
}
#else
-int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
+int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers, const char *encoding,
const char *stylesheet)
return -1;
}
#endif
-int z_soap_codec_enc(ODR o, Z_SOAP **pp,
+int z_soap_codec_enc(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers,
const char *encoding)
encoding, 0);
}
-int z_soap_codec(ODR o, Z_SOAP **pp,
+int z_soap_codec(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers)
{
const char *details)
{
p->which = Z_SOAP_error;
- p->u.soap_error = (Z_SOAP_Fault *)
+ p->u.soap_error = (Z_SOAP_Fault *)
odr_malloc(o, sizeof(*p->u.soap_error));
p->u.soap_error->fault_code = odr_strdup(o, fault_code);
p->u.soap_error->fault_string = odr_strdup(o, fault_string);
for (node = ptr->children; node; node = node->next)
if (node->type == XML_ELEMENT_NODE)
sr->num_records++;
-
+
if (sr->num_records)
sr->records = odr_malloc(o, sizeof(*sr->records) * sr->num_records);
{
sr->numberOfRecords = odr_intdup(o, odr_atoi(
(const char *) attr->children->content));
- }
+ }
else if (!strcmp((const char *) attr->name, "start"))
{
start = odr_atoi((const char *) attr->children->content);
facet_list->elements[index]);
if (r)
return -1;
-
+
}
return 0;
}
char *uri_args;
char *path;
int i = 0;
-
- z_HTTP_header_add_basic_auth(encode, &hreq->headers,
+
+ z_HTTP_header_add_basic_auth(encode, &hreq->headers,
srw_pdu->username, srw_pdu->password);
if (srw_pdu->which == Z_SRW_searchRetrieve_request)
{
name[i++] = 0;
yaz_array_to_uri(&uri_args, encode, name, value);
-
+
hreq->method = "GET";
-
+
path = (char *)
odr_malloc(encode, strlen(hreq->path) +
strlen(uri_args) + strlen(solr_op) + 4);
int ret = 0; /* 0=OK, != 0 FAIL */
int t;
t = yaz_tok_move(tp);
-
+
while (t == YAZ_TOK_STRING && ae_num < 20)
{
WRBUF type_str = wrbuf_alloc();
Z_AttributeElement *elem = 0;
const char *value_str = 0;
/* attset type=value OR type=value */
-
+
elem = (Z_AttributeElement *) nmem_malloc(ct->nmem, sizeof(*elem));
elem->attributeSet = 0;
ae[ae_num] = elem;
{
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
+ wrbuf_destroy(set_str);
break;
}
- if (t == YAZ_TOK_STRING)
- {
+ if (t == YAZ_TOK_STRING)
+ {
wrbuf_puts(ct->w, " ");
wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
set_str = type_str;
-
+
elem->attributeSet =
yaz_string_to_oid_nmem(yaz_oid_std(), CLASS_ATTSET,
wrbuf_cstr(set_str), ct->nmem);
-
+
type_str = wrbuf_alloc();
wrbuf_puts(type_str, yaz_tok_parse_string(tp));
t = yaz_tok_move(tp);
{
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
+ wrbuf_destroy(set_str);
yaz_log(YLOG_WARN, "Expected numeric attribute type");
ret = -1;
break;
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
-
+ wrbuf_destroy(set_str);
+
if (t != '=')
{
yaz_log(YLOG_WARN, "Expected = after after attribute type");
(*pp)->attr_list.attributes = (Z_AttributeElement **)
nmem_malloc(ct->nmem,
ae_num * sizeof(Z_AttributeElement *));
- memcpy((*pp)->attr_list.attributes, ae,
+ memcpy((*pp)->attr_list.attributes, ae,
ae_num * sizeof(Z_AttributeElement *));
}
(*pp)->next = 0;
yaz_tok_parse_destroy(tp);
return r;
}
-
+
solr_transform_t solr_transform_open_FILE(FILE *f)
{
solr_transform_t ct = solr_transform_create();
z_AttributeElement(odr_a, &a, 0, 0);
z_AttributeElement(odr_b, &b, 0, 0);
-
+
buf_a = odr_getbuf(odr_a, &len_a, 0);
buf_b = odr_getbuf(odr_b, &len_b, 0);
}
if (j == attributes->num_attributes)
break; /* i was not found at all.. try next pattern */
-
+
}
if (i == e->attr_list.num_attributes)
return e->pattern + clen;
}
return 0;
}
-
+
static const char *solr_lookup_property(solr_transform_t ct,
const char *pat1, const char *pat2,
const char *pat3)
sprintf(pattern, "%.39s", pat1);
else
return 0;
-
+
for (e = ct->entry; e; e = e->next)
{
if (!solr_strcmp(e->pattern, pattern))
const char *res = 0;
const char *eval = val ? val : default_val;
const char *prefix = 0;
-
+
if (uri)
{
struct solr_prop_entry *e;
-
+
for (e = ct->entry; e; e = e->next)
if (!memcmp(e->pattern, "set.", 4) && e->value &&
!strcmp(e->value, uri))
proxrel = 5;
else if (!strcmp(relation, "<"))
proxrel = 1;
- else if (!strcmp(relation, ">="))
+ else if (!strcmp(relation, ">="))
proxrel = 4;
else if (!strcmp(relation, "<="))
proxrel = 2;
else if (!strcmp(relation, "<>"))
proxrel = 6;
- else
+ else
{
ct->error = YAZ_SRW_UNSUPP_PROX_RELATION;
ct->addinfo = xstrdup(relation);
return 0;
}
- }
+ }
else if (!strcmp(name, "ordered"))
ordered = 1;
else if (!strcmp(name, "unordered"))
unit = 4;
else if (!strcmp(term, "element"))
unit = 8;
- else
+ else
{
ct->error = YAZ_SRW_UNSUPP_PROX_UNIT;
ct->addinfo = xstrdup(term);
return 0;
}
- }
- else
+ }
+ else
{
ct->error = YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER;
ct->addinfo = xstrdup(name);
* there's no mapping for it, that's fine: we just use a
* general pattern-matching attribute.
*/
- if (first_wc == term && second_wc == term + length-1
- && *first_wc == '*' && *second_wc == '*'
+ if (first_wc == term && second_wc == term + length-1
+ && *first_wc == '*' && *second_wc == '*'
&& solr_pr_attr(ct, "truncation", "both", 0, pr, client_data, 0))
{
term++;
(*pr)("@", client_data);
(*pr)(op, client_data);
(*pr)(" ", client_data);
- }
+ }
emit_term(ct, cn, ne->u.st.term, strlen(ne->u.st.term),
pr, client_data);
}
(*pr)(cn->u.boolean.value, client_data);
(*pr)(" ", client_data);
mods = cn->u.boolean.modifiers;
- if (!strcmp(cn->u.boolean.value, "prox"))
+ if (!strcmp(cn->u.boolean.value, "prox"))
{
if (!solr_pr_prox(ct, mods, pr, client_data))
return;
- }
+ }
else if (mods)
{
/* Boolean modifiers other than on proximity not supported */
Z_SortKeySpecList *sksl = (Z_SortKeySpecList *)
odr_malloc(out, sizeof(*sksl));
int off;
-
+
sksl->num_specs = 0;
sksl->specs = (Z_SortKeySpec **)odr_malloc(out, sizeof(sksl->specs) * 20);
-
+
while ((sscanf(arg, "%63s %63s%n", sort_string_buf,
sort_flags, &off)) == 2 && off > 1)
{
char *sort_string = sort_string_buf;
Z_SortKeySpec *sks = (Z_SortKeySpec *) odr_malloc(out, sizeof(*sks));
Z_SortKey *sk = (Z_SortKey *) odr_malloc(out, sizeof(*sk));
-
+
arg += off;
sksl->specs[sksl->num_specs++] = sks;
sks->sortElement = (Z_SortElement *)
odr_malloc(out, sizeof(*sks->sortElement));
sks->sortElement->which = Z_SortElement_generic;
sks->sortElement->u.generic = sk;
-
+
if ((sort_string_sep = strchr(sort_string, '=')))
{
int i = 0;
sk->u.sortAttributes->list = (Z_AttributeList *)
odr_malloc(out, sizeof(*sk->u.sortAttributes->list));
sk->u.sortAttributes->list->attributes = (Z_AttributeElement **)
- odr_malloc(out, 10 *
+ odr_malloc(out, 10 *
sizeof(*sk->u.sortAttributes->list->attributes));
while (i < 10 && sort_string && sort_string_sep)
{
sks->which = Z_SortKeySpec_null;
sks->u.null = odr_nullval ();
-
+
for (i = 0; sort_flags[i]; i++)
{
switch (sort_flags[i])
int num_sortspec = 0;
int i;
NMEM nmem = nmem_create();
-
+
if (srw_sortkeys)
nmem_strsplit_blank(nmem, srw_sortkeys, &sortspec, &num_sortspec);
if (num_sortspec > 0)
int case_sensitive = 0;
const char *missing = 0;
nmem_strsplitx(nmem, ",", sortspec[i], &arg, &num_arg, 0);
-
+
if (num_arg > 2 && arg[2][0])
ascending = atoi(arg[2]);
if (num_arg > 3 && arg[3][0])
#ifndef WIN32
{
unsigned long one = 1;
- if (setsockopt(p->m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)
+ if (setsockopt(p->m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)
&one, sizeof(one)))
{
if (err_msg)
add.sin_port = htons(port_to_use);
add.sin_addr.s_addr = INADDR_ANY;
addr = ( struct sockaddr *) &add;
-
+
if (bind(p->m_socket, addr, sizeof(struct sockaddr_in)))
{
if (err_msg)
yaz_spipe_destroy(p);
return 0;
}
-
+
if (listen(p->m_socket, 3) < 0)
{
if (err_msg)
yaz_spipe_destroy(p);
return 0;
}
-
+
memcpy(&add.sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
p->m_fd[1] = socket(AF_INET, SOCK_STREAM, 0);
if (p->m_fd[1] == YAZ_INVALID_SOCKET)
{
/* copy node to get NS right (bug #740). */
xmlNode *tmp = xmlCopyNode(ptr, 1);
-
+
xmlNodeDump(buf, tmp->doc, tmp, 0, 0);
-
+
xmlFreeNode(tmp);
no_root_nodes++;
}
for (ptr = pptr->children; ptr; ptr = ptr->next)
{
-
- if (match_xsd_string(ptr, "recordSchema", o,
+
+ if (match_xsd_string(ptr, "recordSchema", o,
&rec->recordSchema))
;
else if (match_xsd_string(ptr, "recordPacking", o, &spack))
; /* can't rely on it: in SRU 2.0 it's different semantics */
- else if (match_xsd_integer(ptr, "recordPosition", o,
+ else if (match_xsd_integer(ptr, "recordPosition", o,
&rec->recordPosition))
;
else if (match_element(ptr, "recordData"))
if (p)
{
match_xsd_XML_n2(
- ptr, "recordData", o,
+ ptr, "recordData", o,
&rec->recordData_buf, &rec->recordData_len, 1);
rec->recordPacking = Z_SRW_recordPacking_XML;
}
else
{
match_xsd_string_n(
- ptr, "recordData", o,
+ ptr, "recordData", o,
&rec->recordData_buf, &rec->recordData_len);
rec->recordPacking = Z_SRW_recordPacking_string;
}
}
- else if (match_xsd_XML_n(ptr, "extraRecordData", o,
+ else if (match_xsd_XML_n(ptr, "extraRecordData", o,
&ex.extraRecordData_buf,
&ex.extraRecordData_len) )
;
else
- match_xsd_string(ptr, "recordIdentifier", o,
+ match_xsd_string(ptr, "recordIdentifier", o,
&ex.recordIdentifier);
}
if (ex.extraRecordData_buf || ex.recordIdentifier)
rec->versionValue = 0;
for (ptr = pptr->children; ptr; ptr = ptr->next)
{
-
- if (match_xsd_string(ptr, "versionType", o,
+
+ if (match_xsd_string(ptr, "versionType", o,
&rec->versionType))
;
else
return 0;
}
-static int yaz_srw_versions(ODR o, xmlNodePtr pptr,
+static int yaz_srw_versions(ODR o, xmlNodePtr pptr,
Z_SRW_recordVersion **vers,
int *num, void *client_data, const char *ns)
{
(*recs)[i].uri = 0;
(*recs)[i].details = 0;
(*recs)[i].message = 0;
- }
+ }
for (i = 0, ptr = pptr; ptr; ptr = ptr->next)
{
if (ptr->type == XML_ELEMENT_NODE &&
(*recs)[i].message = 0;
for (rptr = ptr->children; rptr; rptr = rptr->next)
{
- if (match_xsd_string(rptr, "uri", o,
+ if (match_xsd_string(rptr, "uri", o,
&(*recs)[i].uri))
;
- else if (match_xsd_string(rptr, "details", o,
+ else if (match_xsd_string(rptr, "details", o,
&(*recs)[i].details))
;
else
xmlNodePtr ptr = xmlDocGetRootElement(doc);
while (ptr && ptr->type != XML_ELEMENT_NODE)
ptr = ptr->next;
- if (ptr && ptr->ns
+ if (ptr && ptr->ns
&& !xmlStrcmp(ptr->ns->href,
BAD_CAST "http://www.loc.gov/zing/srw/diagnostic/"))
{
{
if (match_xsd_string(ptr, "value", o, &term->value))
;
- else if (match_xsd_integer(ptr, "numberOfRecords", o,
+ else if (match_xsd_integer(ptr, "numberOfRecords", o,
&term->numberOfRecords))
;
- else if (match_xsd_string(ptr, "displayTerm", o,
+ else if (match_xsd_string(ptr, "displayTerm", o,
&term->displayTerm))
;
else
while (method && method->type == XML_TEXT_NODE)
method = method->next;
-
+
if (!method)
return -1;
if (method->type != XML_ELEMENT_NODE)
return -1;
*p = yaz_srw_get_core_v_1_1(o);
-
+
if (!xmlStrcmp(method->name, BAD_CAST "searchRetrieveRequest"))
{
xmlNodePtr ptr = method->children;
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_string(ptr, "query", o,
+ else if (match_xsd_string(ptr, "query", o,
&req->query.cql))
req->query_type = Z_SRW_query_type_cql;
- else if (match_xsd_string(ptr, "pQuery", o,
+ else if (match_xsd_string(ptr, "pQuery", o,
&req->query.pqf))
req->query_type = Z_SRW_query_type_pqf;
- else if (match_xsd_string(ptr, "xQuery", o,
+ else if (match_xsd_string(ptr, "xQuery", o,
&req->query.xcql))
req->query_type = Z_SRW_query_type_xcql;
else if (match_xsd_integer(ptr, "startRecord", o,
else if (match_xsd_string(ptr, "recordPacking", o,
&req->recordPacking))
;
- else if (match_xsd_string(ptr, "recordSchema", o,
+ else if (match_xsd_string(ptr, "recordSchema", o,
&req->recordSchema))
;
else if (match_xsd_string(ptr, "recordXPath", o,
else if (match_xsd_integer(ptr, "resultSetTTL", o,
&req->resultSetTTL))
;
- else if (match_xsd_string(ptr, "sortKeys", o,
+ else if (match_xsd_string(ptr, "sortKeys", o,
&req->sort.sortKeys))
req->sort_type = Z_SRW_sort_type_sort;
else if (match_xsd_string(ptr, "stylesheet", o,
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_XML_n(ptr, "extraResponseData", o,
+ else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&(*p)->extraResponseData_len))
;
- else if (match_xsd_integer(ptr, "numberOfRecords", o,
+ else if (match_xsd_integer(ptr, "numberOfRecords", o,
&res->numberOfRecords))
;
- else if (match_xsd_string(ptr, "resultSetId", o,
+ else if (match_xsd_string(ptr, "resultSetId", o,
&res->resultSetId))
;
- else if (match_xsd_integer(ptr, "resultSetIdleTime", o,
+ else if (match_xsd_integer(ptr, "resultSetIdleTime", o,
&res->resultSetIdleTime))
;
else if (match_element(ptr, "records"))
{
Z_SRW_explainRequest *req;
xmlNodePtr ptr = method->children;
-
+
(*p)->which = Z_SRW_explain_request;
req = (*p)->u.explain_request = (Z_SRW_explainRequest *)
odr_malloc(o, sizeof(*req));
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_XML_n(ptr, "extraResponseData", o,
+ else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&(*p)->extraResponseData_len))
;
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_XML_n(ptr, "extraResponseData", o,
+ else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&(*p)->extraResponseData_len))
;
req->maximumTerms = 0;
req->stylesheet = 0;
req->database = 0;
-
+
for (; ptr; ptr = ptr->next)
{
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_XML_n(ptr, "extraResponseData", o,
+ else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&(*p)->extraResponseData_len))
;
res->num_terms = 0;
res->diagnostics = 0;
res->num_diagnostics = 0;
-
+
for (; ptr; ptr = ptr->next)
{
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_XML_n(ptr, "extraResponseData", o,
+ else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&(*p)->extraResponseData_len))
;
Z_SRW_PDU **p = handler_data;
xmlNsPtr ns_srw;
xmlNodePtr ptr = 0;
-
+
if ((*p)->which == Z_SRW_searchRetrieve_request)
{
Z_SRW_searchRetrieveRequest *req = (*p)->u.request;
else
return -1;
if (ptr && (*p)->extraResponseData_len)
- add_XML_n(ptr, "extraResponseData",
- (*p)->extraResponseData_buf,
+ add_XML_n(ptr, "extraResponseData",
+ (*p)->extraResponseData_buf,
(*p)->extraResponseData_len, ns_srw);
-
+
}
return 0;
while (method && method->type == XML_TEXT_NODE)
method = method->next;
-
+
if (!method)
return -1;
if (method->type != XML_ELEMENT_NODE)
return -1;
*p = yaz_srw_get_core_v_1_1(o);
-
+
if (!xmlStrcmp(method->name, BAD_CAST "updateRequest"))
{
xmlNodePtr ptr = method->children;
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_string(ptr, "action", o,
+ else if (match_xsd_string(ptr, "action", o,
&oper)){
if (oper)
{
if (match_xsd_string(ptr, "version", o,
&(*p)->srw_version))
;
- else if (match_xsd_string(ptr, "operationStatus", o,
+ else if (match_xsd_string(ptr, "operationStatus", o,
&res->operationStatus ))
;
- else if (match_xsd_string(ptr, "recordIdentifier", o,
+ else if (match_xsd_string(ptr, "recordIdentifier", o,
&res->recordId))
;
- else if (match_element(ptr, "recordVersions" ))
+ else if (match_element(ptr, "recordVersions" ))
yaz_srw_versions(o, ptr, &res->recordVersions,
&res->num_recordVersions,
client_data, ns_ucp_str);
}
if (req->extraRequestData_len)
{
- add_XML_n(ptr, "extraRequestData",
- req->extraRequestData_buf,
+ add_XML_n(ptr, "extraRequestData",
+ req->extraRequestData_buf,
req->extraRequestData_len, ns_srw);
}
add_xsd_string(ptr, "stylesheet", req->stylesheet);
else if ((*p)->which == Z_SRW_update_response)
{
Z_SRW_updateResponse *res = (*p)->u.update_response;
- xmlNodePtr ptr = xmlNewChild(pptr, 0, (xmlChar *)
+ xmlNodePtr ptr = xmlNewChild(pptr, 0, (xmlChar *)
"updateResponse", 0);
ns_ucp = xmlNewNs(ptr, BAD_CAST ns_ucp_str, BAD_CAST "zu");
xmlSetNs(ptr, ns_ucp);
ns_srw = xmlNewNs(ptr, BAD_CAST ns_srw_str, BAD_CAST "zs");
-
+
add_xsd_string_ns(ptr, "version", (*p)->srw_version, ns_srw);
add_xsd_string(ptr, "operationStatus", res->operationStatus );
add_xsd_string(ptr, "recordIdentifier", res->recordId );
xmlNsPtr ns_diag =
xmlNewNs(pptr, BAD_CAST YAZ_XMLNS_DIAG_v1_1,
BAD_CAST "diag" );
-
+
xmlNodePtr rptr = xmlNewChild(ptr, ns_diag, BAD_CAST "diagnostics", 0);
yaz_srw_diagnostics(o, rptr, &res->diagnostics,
&res->num_diagnostics, client_data,
ns_ucp_str);
}
if (res->extraResponseData_len)
- add_XML_n(ptr, "extraResponseData",
- res->extraResponseData_buf,
+ add_XML_n(ptr, "extraResponseData",
+ res->extraResponseData_buf,
res->extraResponseData_len, ns_srw);
}
else
*intp = odr_intdup(o, atoi(v));
}
-void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
+void yaz_mk_srw_diagnostic(ODR o, Z_SRW_diagnostic *d,
const char *uri, const char *message,
const char *details)
{
d->details = 0;
}
-void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
+void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d,
int code, const char *details)
{
char uri[40];
-
+
sprintf(uri, "info:srw/diagnostic/1/%d", code);
yaz_mk_srw_diagnostic(o, d, uri, 0, details);
}
int *num, int code, const char *addinfo)
{
char uri[40];
-
+
sprintf(uri, "info:srw/diagnostic/1/%d", code);
yaz_add_srw_diagnostic_uri(o, d, num, uri, 0, addinfo);
}
int *num, int code, const char *addinfo)
{
char uri[40];
-
+
sprintf(uri, "info:srw/diagnostic/12/%d", code);
yaz_add_srw_diagnostic_uri(o, d, num, uri, 0, addinfo);
}
len += strlen(message);
if (details)
len += strlen(details);
-
+
record->recordData_buf = (char *) odr_malloc(o, len);
-
+
sprintf(record->recordData_buf, "<diagnostic "
"xmlns=\"http://www.loc.gov/zing/srw/diagnostic/\">\n"
" <uri>info:srw/diagnostic/1/%d</uri>\n", code);
static void grab_charset(ODR o, const char *content_type, char **charset)
{
if (charset)
- {
+ {
const char *charset_p = 0;
if (content_type && (charset_p = strstr(content_type, "; charset=")))
{
{
const char *content_type = z_HTTP_header_lookup(hreq->headers,
"Content-Type");
- if (content_type &&
+ if (content_type &&
(!yaz_strcmp_del("text/xml", content_type, "; ") ||
!yaz_strcmp_del("application/soap+xml", content_type, "; ") ||
!yaz_strcmp_del("text/plain", content_type, "; ")))
char *db = "Default";
const char *p0 = hreq->path, *p1;
int ret = -1;
-
+
static Z_SOAP_Handler soap_handlers[4] = {
#if YAZ_HAVE_XML2
{ YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec },
#endif
{0, 0, 0}
};
-
+
if (*p0 == '/')
p0++;
p1 = strchr(p0, '?');
db = yaz_decode_sru_dbpath_odr(decode, p0, p1 - p0);
grab_charset(decode, content_type, charset);
- ret = z_soap_codec(decode, soap_package,
+ ret = z_soap_codec(decode, soap_package,
&hreq->content_buf, &hreq->content_len,
soap_handlers);
if (ret == 0 && (*soap_package)->which == Z_SOAP_generic)
{
*srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
yaz_srw_decodeauth(*srw_pdu, hreq, 0, 0, decode);
-
+
if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
(*srw_pdu)->u.request->database == 0)
(*srw_pdu)->u.request->database = db;
}
#if YAZ_HAVE_XML2
-static int yaz_sru_decode_integer(ODR odr, const char *pname,
+static int yaz_sru_decode_integer(ODR odr, const char *pname,
const char *valstr, Odr_int **valp,
Z_SRW_diagnostic **diag, int *num_diag,
int min_value)
/**
http://www.loc.gov/z3950/agency/zing/srw/service.html
-*/
+*/
int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
Z_SOAP **soap_package, ODR decode, char **charset,
Z_SRW_diagnostic **diag, int *num_diag)
not "multipart/form-data" .
*/
if (!strcmp(hreq->method, "GET")
- ||
+ ||
(!strcmp(hreq->method, "POST") && content_type &&
!yaz_strcmp_del("application/x-www-form-urlencoded",
content_type, "; ")))
YAZ_SRW_UNSUPP_VERSION, "1.2");
version = "1.2";
}
-
+
if (!operation)
{
if (uri_name)
yaz_add_srw_diagnostic(
- decode, diag, num_diag,
+ decode, diag, num_diag,
YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "operation");
operation = "explain";
}
}
else
yaz_add_srw_diagnostic(
- decode, diag, num_diag,
+ decode, diag, num_diag,
YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "query");
if (sortKeys)
sr->u.request->recordPacking = recordPacking;
sr->u.request->stylesheet = stylesheet;
- yaz_sru_decode_integer(decode, "maximumRecords", maximumRecords,
- &sr->u.request->maximumRecords,
+ yaz_sru_decode_integer(decode, "maximumRecords", maximumRecords,
+ &sr->u.request->maximumRecords,
diag, num_diag, 0);
-
- yaz_sru_decode_integer(decode, "startRecord", startRecord,
+
+ yaz_sru_decode_integer(decode, "startRecord", startRecord,
&sr->u.request->startRecord,
diag, num_diag, 1);
(*soap_package) = (Z_SOAP *)
odr_malloc(decode, sizeof(**soap_package));
(*soap_package)->which = Z_SOAP_generic;
-
+
(*soap_package)->u.generic = (Z_SOAP_Generic *)
odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-
+
(*soap_package)->u.generic->p = sr;
(*soap_package)->u.generic->ns = soap_handlers[0].ns;
(*soap_package)->u.generic->no = 0;
-
+
(*soap_package)->ns = "SRU";
return 0;
(*soap_package) = (Z_SOAP *)
odr_malloc(decode, sizeof(**soap_package));
(*soap_package)->which = Z_SOAP_generic;
-
+
(*soap_package)->u.generic = (Z_SOAP_Generic *)
odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-
+
(*soap_package)->u.generic->p = sr;
(*soap_package)->u.generic->ns = soap_handlers[0].ns;
(*soap_package)->u.generic->no = 0;
-
+
(*soap_package)->ns = "SRU";
return 0;
}
else
yaz_add_srw_diagnostic(
- decode, diag, num_diag,
+ decode, diag, num_diag,
YAZ_SRW_MANDATORY_PARAMETER_NOT_SUPPLIED, "scanClause");
sr->u.scan_request->database = db;
-
+
yaz_sru_decode_integer(decode, "maximumTerms",
- maximumTerms,
+ maximumTerms,
&sr->u.scan_request->maximumTerms,
diag, num_diag, 0);
-
+
yaz_sru_decode_integer(decode, "responsePosition",
- responsePosition,
+ responsePosition,
&sr->u.scan_request->responsePosition,
diag, num_diag, 0);
(*soap_package) = (Z_SOAP *)
odr_malloc(decode, sizeof(**soap_package));
(*soap_package)->which = Z_SOAP_generic;
-
+
(*soap_package)->u.generic = (Z_SOAP_Generic *)
odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-
+
(*soap_package)->u.generic->p = sr;
(*soap_package)->u.generic->ns = soap_handlers[0].ns;
(*soap_package)->u.generic->no = 0;
-
+
(*soap_package)->ns = "SRU";
return 0;
(*soap_package) = (Z_SOAP *)
odr_malloc(decode, sizeof(**soap_package));
(*soap_package)->which = Z_SOAP_generic;
-
+
(*soap_package)->u.generic = (Z_SOAP_Generic *)
odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-
+
(*soap_package)->u.generic->p = sr;
(*soap_package)->u.generic->ns = soap_handlers[0].ns;
(*soap_package)->u.generic->no = 0;
-
+
(*soap_package)->ns = "SRU";
- yaz_add_srw_diagnostic(decode, diag, num_diag,
+ yaz_add_srw_diagnostic(decode, diag, num_diag,
YAZ_SRW_UNSUPP_OPERATION, operation);
return 0;
}
{
case Z_SRW_sort_type_none:
break;
- case Z_SRW_sort_type_sort:
+ case Z_SRW_sort_type_sort:
yaz_add_name_value_str(encode, name, value, &i, "sortKeys",
srw_pdu->u.request->sort.sortKeys);
break;
}
- yaz_add_name_value_int(encode, name, value, &i, "startRecord",
+ yaz_add_name_value_int(encode, name, value, &i, "startRecord",
srw_pdu->u.request->startRecord);
- yaz_add_name_value_int(encode, name, value, &i, "maximumRecords",
+ yaz_add_name_value_int(encode, name, value, &i, "maximumRecords",
srw_pdu->u.request->maximumRecords);
yaz_add_name_value_str(encode, name, value, &i, "recordSchema",
srw_pdu->u.request->recordSchema);
srw_pdu->u.request->recordXPath);
yaz_add_name_value_str(encode, name, value, &i, "stylesheet",
srw_pdu->u.request->stylesheet);
- yaz_add_name_value_int(encode, name, value, &i, "resultSetTTL",
+ yaz_add_name_value_int(encode, name, value, &i, "resultSetTTL",
srw_pdu->u.request->resultSetTTL);
break;
case Z_SRW_explain_request:
srw_pdu->u.scan_request->scanClause.xcql);
break;
}
- yaz_add_name_value_int(encode, name, value, &i, "responsePosition",
+ yaz_add_name_value_int(encode, name, value, &i, "responsePosition",
srw_pdu->u.scan_request->responsePosition);
- yaz_add_name_value_int(encode, name, value, &i, "maximumTerms",
+ yaz_add_name_value_int(encode, name, value, &i, "maximumTerms",
srw_pdu->u.scan_request->maximumTerms);
yaz_add_name_value_str(encode, name, value, &i, "stylesheet",
srw_pdu->u.scan_request->stylesheet);
char *uri_args;
char *path;
- z_HTTP_header_add_basic_auth(encode, &hreq->headers,
+ z_HTTP_header_add_basic_auth(encode, &hreq->headers,
srw_pdu->username, srw_pdu->password);
if (yaz_get_sru_parms(srw_pdu, encode, name, value, MAX_SRU_PARAMETERS))
return -1;
yaz_array_to_uri(&uri_args, encode, name, value);
hreq->method = "GET";
-
+
path = (char *)
odr_malloc(encode, strlen(hreq->path) + strlen(uri_args) + 4);
char *name[MAX_SRU_PARAMETERS], *value[MAX_SRU_PARAMETERS]; /* definite upper limit for SRU params */
char *uri_args;
- z_HTTP_header_add_basic_auth(encode, &hreq->headers,
+ z_HTTP_header_add_basic_auth(encode, &hreq->headers,
srw_pdu->username, srw_pdu->password);
if (yaz_get_sru_parms(srw_pdu, encode, name, value, MAX_SRU_PARAMETERS))
return -1;
yaz_array_to_uri(&uri_args, encode, name, value);
hreq->method = "POST";
-
+
hreq->content_buf = uri_args;
hreq->content_len = strlen(uri_args);
};
Z_SOAP *p = (Z_SOAP*) odr_malloc(odr, sizeof(*p));
- z_HTTP_header_add_basic_auth(odr, &hreq->headers,
+ z_HTTP_header_add_basic_auth(odr, &hreq->headers,
srw_pdu->username, srw_pdu->password);
z_HTTP_header_add_content_type(odr,
&hreq->headers,
"text/xml", charset);
-
+
z_HTTP_header_add(odr, &hreq->headers,
"SOAPAction", "\"\"");
p->which = Z_SOAP_generic;
Z_SRW_recordVersion *yaz_srw_get_record_versions(ODR odr, int num)
{
- Z_SRW_recordVersion *ver
+ Z_SRW_recordVersion *ver
= (Z_SRW_recordVersion *) odr_malloc(odr,num * sizeof(*ver));
int i;
for (i = 0; i < num; ++i)
yaz_log(YLOG_WARN, "Bad/missing root element for config %s",
control_block.xml_config);
return 0;
-
+
}
}
return ptr;
#endif
#if YAZ_HAVE_XML2
-static struct gfs_listen * gfs_listen_new(const char *id,
+static struct gfs_listen * gfs_listen_new(const char *id,
const char *address)
{
struct gfs_listen *n = (struct gfs_listen *)
assoc->server = gfs;
assoc->last_control = &gfs->cb;
statserv_setcontrol(&gfs->cb);
-
+
gfs_server_chdir(gfs);
break;
}
statserv_setcontrol(&control_block);
assoc->last_control = &control_block;
}
- yaz_log(YLOG_DEBUG, "server select: config=%s",
+ yaz_log(YLOG_DEBUG, "server select: config=%s",
assoc->last_control->configname);
assoc->maximumRecordSize = assoc->last_control->maxrecordsize;
struct gfs_server *gfs;
for ( ; attr; attr = attr->next)
- if (!xmlStrcmp(attr->name, BAD_CAST "listenref")
+ if (!xmlStrcmp(attr->name, BAD_CAST "listenref")
&& attr->children && attr->children->type == XML_TEXT_NODE)
listenref = nmem_dup_xml_content(gfs_nmem, attr->children);
else if (!xmlStrcmp(attr->name, BAD_CAST "id")
}
else if (!strcmp((const char *) ptr->name, "directory"))
{
- gfs->directory =
+ gfs->directory =
nmem_dup_xml_content(gfs_nmem, ptr->children);
}
else if (!strcmp((const char *) ptr->name, "docpath"))
{
- gfs->docpath =
+ gfs->docpath =
nmem_dup_xml_content(gfs_nmem, ptr->children);
}
else if (!strcmp((const char *) ptr->name, "maximumrecordsize"))
else if (!strcmp((const char *) ptr->name, "retrievalinfo"))
{
if (yaz_retrieval_configure(gfs->retrieval, ptr))
- {
+ {
yaz_log(YLOG_FATAL, "%s in config %s",
yaz_retrieval_get_error(gfs->retrieval),
control_block.xml_config);
init_control_tls = 1;
pthread_key_create(¤t_control_tls, 0);
#endif
-
+
gfs_nmem = nmem_create();
#if YAZ_HAVE_XML2
if (control_block.xml_config[0] == '\0')
/* Allocate the thread handle array */
pThreadHandles = (HANDLE *)malloc(sizeof(HANDLE) * iHandles);
- pCurrentHandle = pThreadHandles;
+ pCurrentHandle = pThreadHandles;
for (pCurrentThread = pFirstThread;
pCurrentThread != NULL;
}
/* WIN32 listener */
-static void listener(IOCHAN h, int event)
+static void listener(IOCHAN h, int event)
{
COMSTACK line = (COMSTACK) iochan_getdata(h);
IOCHAN parent_chan = line->user;
newHandle = (HANDLE) _beginthread(event_loop_thread, 0, new_chan);
if (newHandle == (HANDLE) -1)
{
-
+
yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create new thread.");
iochan_destroy(h);
return;
#else /* ! WIN32 */
/* To save having an #ifdef in event_loop we need to
- define this empty function
+ define this empty function
*/
void statserv_remove(IOCHAN pIOChannel)
{
COMSTACK new_line = (COMSTACK) vp;
IOCHAN parent_chan = (IOCHAN) new_line->user;
- unsigned cs_get_mask, cs_accept_mask, mask =
+ unsigned cs_get_mask, cs_accept_mask, mask =
((new_line->io_pending & CS_WANT_WRITE) ? EVENT_OUTPUT : 0) |
((new_line->io_pending & CS_WANT_READ) ? EVENT_INPUT : 0);
return 1;
xml_config_open();
-
+
xml_config_bend_start();
if (control_block.inetd)
int ret = 0, r;
char *arg;
- yaz_log_init_level(yaz_log_mask_str(STAT_DEFAULT_LOG_LEVEL));
+ yaz_log_init_level(yaz_log_mask_str(STAT_DEFAULT_LOG_LEVEL));
- get_logbits(1);
+ get_logbits(1);
while ((ret = options("1a:iszSTl:v:u:c:w:t:k:Kd:A:p:DC:f:m:r:",
argv, argc, &arg)) != -2)
if (add_listener(arg, 0))
return 1; /* failed to create listener */
break;
- case '1':
+ case '1':
control_block.one_shot = 1;
control_block.dynamic = 0;
break;
break;
case 'v':
yaz_log_init_level(yaz_log_mask_str(arg));
- get_logbits(1);
+ get_logbits(1);
break;
case 'a':
option_copy(control_block.apdufile, arg);
case 'w':
if (chdir(arg))
{
- perror(arg);
+ perror(arg);
return 1;
}
break;
* See the file LICENSE for details.
*/
-/**
+/**
* \file stemmer.c
* \brief Implements stemmer wrapper
*/
yaz_stemmer_p yaz_stemmer;
if (stemmer == 0) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
- yaz_log(YLOG_FATAL, "yaz_stemmer: Failed to create snowball stemmer from locale %srule %s. Showball: charenc %s algorithm %s ",
+ yaz_log(YLOG_FATAL, "yaz_stemmer: Failed to create snowball stemmer from locale %srule %s. Showball: charenc %s algorithm %s ",
locale, rule, charenc, algorithm);
return 0;
}
yaz_log(YLOG_DEBUG, "created snowball stemmer: algoritm %s charenc %s ", algorithm, charenc);
yaz_stemmer = xmalloc(sizeof(*yaz_stemmer));
yaz_stemmer->implementation = yaz_snowball;
-
+
yaz_stemmer->locale = xstrdup(locale);
yaz_stemmer->rule = xstrdup(rule);
yaz_stemmer->sb_stemmer = stemmer;
const char *cstr2 = (const char *) sb_symbol;
icu_utf16_from_utf8_cstr(dst, cstr2 , status);
-#if 0
+#if 0
yaz_log(YLOG_DEBUG, "stemming %s to %s ", cstr, cstr2);
#endif
}
}
}
-void yaz_stemmer_destroy(yaz_stemmer_p stemmer)
+void yaz_stemmer_destroy(yaz_stemmer_p stemmer)
{
/* Handle no stemmer correctly */
if (stemmer == 0)
struct hostent *host;
struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
-
+
if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
sizeof(addr_in->sin_addr),
AF_INET)))
return 0;
assert(ai);
h->iofile = s;
-
+
if (!tcpip_set_blocking(h, h->flags))
return 0;
}
int tcpip_more(COMSTACK h)
{
tcpip_state *sp = (tcpip_state *)h->cprivate;
-
+
return sp->altlen && (*sp->complete)(sp->altbuf, sp->altlen);
}
{
int res;
gnutls_global_init();
-
+
tcpip_create_cred(h);
gnutls_init(&sp->session, GNUTLS_CLIENT);
gnutls_set_default_priority(sp->session);
gnutls_credentials_set (sp->session, GNUTLS_CRD_CERTIFICATE,
sp->cred_ptr->xcred);
-
+
/* cast to intermediate size_t to avoid GCC warning. */
- gnutls_transport_set_ptr(sp->session,
- (gnutls_transport_ptr_t)
+ gnutls_transport_set_ptr(sp->session,
+ (gnutls_transport_ptr_t)
(size_t) h->iofile);
res = gnutls_handshake(sp->session);
if (res < 0)
{
int r;
tcpip_state *sp = (tcpip_state *)h->cprivate;
-#if HAVE_GETADDRINFO
- struct addrinfo *ai = (struct addrinfo *) address;
+#if HAVE_GETADDRINFO
+ struct addrinfo *ai = (struct addrinfo *) address;
#else
struct sockaddr *addr = (struct sockaddr *)address;
#endif
tcpip_create_cred(h);
- res = gnutls_certificate_set_x509_key_file(sp->cred_ptr->xcred,
+ res = gnutls_certificate_set_x509_key_file(sp->cred_ptr->xcred,
sp->cert_fname,
sp->cert_fname,
GNUTLS_X509_FMT_PEM);
TRC(fprintf(stderr, "tcpip_bind\n"));
#endif
#ifndef WIN32
- if (setsockopt(h->iofile, SOL_SOCKET, SO_REUSEADDR, (char*)
+ if (setsockopt(h->iofile, SOL_SOCKET, SO_REUSEADDR, (char*)
&one, sizeof(one)) < 0)
{
h->cerrno = CSYSERR;
#ifdef WIN32
WSAGetLastError() == WSAEWOULDBLOCK
#else
- yaz_errno() == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
|| yaz_errno() == EAGAIN
#endif
cnew->state = CS_ST_ACCEPT;
h->state = CS_ST_IDLE;
-
+
#if HAVE_GNUTLS_H
state->cred_ptr = st->cred_ptr;
state->session = 0;
return 0;
}
res = gnutls_credentials_set(state->session,
- GNUTLS_CRD_CERTIFICATE,
+ GNUTLS_CRD_CERTIFICATE,
st->cred_ptr->xcred);
if (res != GNUTLS_E_SUCCESS)
{
return 0;
}
/* cast to intermediate size_t to avoid GCC warning. */
- gnutls_transport_set_ptr(state->session,
+ gnutls_transport_set_ptr(state->session,
(gnutls_transport_ptr_t)
(size_t) cnew->iofile);
}
TRC(fprintf(stderr, " recv res=%d, hasread=%d\n", res, hasread));
if (res < 0)
{
- TRC(fprintf(stderr, " recv errno=%d, (%s)\n", yaz_errno(),
+ TRC(fprintf(stderr, " recv errno=%d, (%s)\n", yaz_errno(),
strerror(yaz_errno())));
#ifdef WIN32
if (WSAGetLastError() == WSAEWOULDBLOCK)
return -1;
}
#else
- if (yaz_errno() == EWOULDBLOCK
-#ifdef EAGAIN
+ if (yaz_errno() == EWOULDBLOCK
+#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
|| yaz_errno() == EAGAIN
#endif
{
if ((res =
send(h->iofile, buf + state->written, size -
- state->written,
+ state->written,
#ifdef MSG_NOSIGNAL
MSG_NOSIGNAL
#else
#ifdef WIN32
WSAGetLastError() == WSAEWOULDBLOCK
#else
- yaz_errno() == EWOULDBLOCK
+ yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
|| yaz_errno() == EAGAIN
while (state->towrite > state->written)
{
#if HAVE_GNUTLS_H
- res = gnutls_record_send(state->session, buf + state->written,
+ res = gnutls_record_send(state->session, buf + state->written,
size - state->written);
if (res <= 0)
{
return -1;
}
#else
- res = SSL_write(state->ssl, buf + state->written,
+ res = SSL_write(state->ssl, buf + state->written,
size - state->written);
if (res <= 0)
{
if (--(sp->cred_ptr->ref) == 0)
{
- TRC(fprintf(stderr, "Removed credentials %p pid=%d\n",
+ TRC(fprintf(stderr, "Removed credentials %p pid=%d\n",
sp->cred_ptr->xcred, getpid()));
gnutls_certificate_free_credentials(sp->cred_ptr->xcred);
xfree(sp->cred_ptr);
char host[120];
struct sockaddr_storage addr;
YAZ_SOCKLEN_T len = sizeof(addr);
-
+
if (getpeername(h->iofile, (struct sockaddr *)&addr, &len) < 0)
{
h->cerrno = CSYSERR;
return 0;
}
- if (getnameinfo((struct sockaddr *) &addr, len, host, sizeof(host)-1,
- 0, 0,
+ if (getnameinfo((struct sockaddr *) &addr, len, host, sizeof(host)-1,
+ 0, 0,
(h->flags & CS_FLAGS_NUMERICHOST) ? NI_NUMERICHOST : 0))
{
r = "unknown";
}
else
r = host;
-
+
#else
struct sockaddr_in addr;
YAZ_SOCKLEN_T len = sizeof(addr);
struct hostent *host;
-
+
if (getpeername(h->iofile, (struct sockaddr*) &addr, &len) < 0)
{
h->cerrno = CSYSERR;
r = (char*) host->h_name;
}
if (!r)
- r = inet_ntoa(addr.sin_addr);
+ r = inet_ntoa(addr.sin_addr);
#endif
if (h->protocol == PROTO_HTTP)
static int tcpip_set_blocking(COMSTACK p, int flags)
{
unsigned long flag;
-
+
#ifdef WIN32
flag = (flags & CS_FLAGS_BLOCKING) ? 0 : 1;
if (ioctlsocket(p->iofile, FIONBIO, &flag) < 0)
if (ssl)
{
X509 *server_cert = SSL_get_peer_certificate(ssl);
-
+
if (server_cert)
{
char *pem_buf;
if (cs && cs->type == ssl_type)
{
struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate;
- return sp->ssl;
+ return sp->ssl;
}
#endif
return 0;
struct tcpip_state *state = (struct tcpip_state *)h->cprivate;
int r;
- r = tcpip_get(h, &state->connect_response_buf,
+ r = tcpip_get(h, &state->connect_response_buf,
&state->connect_response_len);
if (r < 1)
return r;
static int test_todo = 0;
static int test_verbose = 1;
static const char *test_prog = 0;
-static int log_tests = 0;
+static int log_tests = 0;
static FILE *get_file(void)
{
}
else if (!strcmp(suf, "help"))
{
- fprintf(stderr,
+ fprintf(stderr,
"--test-help help\n"
"--test-file fname output to fname\n"
"--test-verbose level verbose level\n"
fprintf(stderr, "Use --test-help for more info\n");
exit(1);
}
-
+
}
break;
}
void yaz_check_init_log(const char *argv0)
{
char logfilename[2048];
- log_tests = 1;
+ log_tests = 1;
sprintf(logfilename,"%s.log", progname(argv0) );
yaz_log_init_file(logfilename);
yaz_log_trunc();
const char *left, const char *right, int lval, int rval)
{
char formstr[2048];
-
- if (type == YAZ_TEST_TYPE_OK)
+
+ if (type == YAZ_TEST_TYPE_OK)
sprintf(formstr, "%.500s == %.500s ", left, right);
else
sprintf(formstr, "%.500s != %.500s\n %d != %d", left, right, lval,rval);
yaz_check_print1(type, file, line, formstr);
}
-void yaz_check_print1(int type, const char *file, int line,
+void yaz_check_print1(int type, const char *file, int line,
const char *expr)
{
const char *msg = "unknown";
{
#if HAVE_SYS_TIMES_H
times(&t->tms2);
-
+
t->user_sec = (double) (t->tms2.tms_utime - t->tms1.tms_utime)/100;
t->sys_sec = (double) (t->tms2.tms_stime - t->tms1.tms_stime)/100;
#endif
gettimeofday(&t->end_time, 0);
t->real_sec = ((t->end_time.tv_sec - t->start_time.tv_sec) * 1000000.0 +
t->end_time.tv_usec - t->start_time.tv_usec) / 1000000;
-#else
+#else
#ifdef WIN32
get_date_as_largeinteger(&t->end_time);
t->real_sec = (t->end_time - t->start_time) / 10000000.0;
int unget_byte;
WRBUF wr_string;
int look;
-
+
yaz_tok_cfg_t cfg;
yaz_tok_get_byte_t get_byte_func;
void *get_byte_data;
tp->wr_string = wrbuf_alloc();
return tp;
}
-
+
void yaz_tok_parse_destroy(yaz_tok_parse_t tp)
{
/* skip white space */
while (ch && strchr(t->white_space, ch))
ch = get_byte(tp);
- if (!ch)
+ if (!ch)
ch = YAZ_TOK_EOF;
else if (strchr(t->comment, ch))
ch = YAZ_TOK_EOF;
path_sep = strchr(path+2, ':');
else
path_sep = 0;
-
+
if (path_sep)
{
len = path_sep - path;
{
struct stat stat_buf;
size_t slen = 0;
-
+
*fullpath = '\0';
if (path)
{
#ifdef WIN32
if (*p == '\\')
return 1;
- if (*p && p[1] == ':' &&
+ if (*p && p[1] == ':' &&
((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z')))
return 1;
#endif
size_t inbytesleft, size_t *no_read)
{
unsigned long x = 0;
-
+
if (inbytesleft < 4)
{
yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
size_t inbytesleft, size_t *no_read)
{
unsigned long x = 0;
-
+
if (inbytesleft < 4)
{
yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
yaz_iconv_encoder_t yaz_ucs4_encoder(const char *tocode,
yaz_iconv_encoder_t e)
-
+
{
if (!yaz_matchstr(tocode, "UCS4"))
e->write_handle = write_UCS4;
yaz_iconv_decoder_t yaz_ucs4_decoder(const char *tocode,
yaz_iconv_decoder_t d)
-
+
{
if (!yaz_matchstr(tocode, "UCS4"))
d->read_handle = read_UCS4;
{
char * end;
char * arg = s + 6;
-
+
sp->umask = strtol(arg, &end, 8);
if (errno == EINVAL ||
*end)
}
return 0;
}
- if (!(cnew->flags&CS_FLAGS_BLOCKING) &&
+ if (!(cnew->flags&CS_FLAGS_BLOCKING) &&
(fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
)
{
for(i = 0; name[i]; i++)
sz += strlen(name[i]) + 3 + strlen(value[i]) * 3;
*path = (char *) odr_malloc(o, sz);
-
+
for(i = 0; name[i]; i++)
{
size_t ilen;
{
size_t i = 0;
char *ret;
-
+
path = p1 + 1;
p1 = strchr(path, '&');
if (!p1)
if (cp1 && cp1 > uri)
{
cp1--;
-
+
if (!strncmp(cp1, "://", 3))
{
const char *cp3 = 0;
*uri_lean = nmem_malloc(nmem, strlen(uri) + 1);
memcpy(*uri_lean, uri, cp1 + 3 - uri);
strcpy(*uri_lean + (cp1 + 3 - uri), cp2 + 1);
-
+
*http_user = nmem_strdupn(nmem, cp1 + 3, cp3 - (cp1 + 3));
*http_pass = nmem_strdupn(nmem, cp3 + 1, cp2 - (cp3 + 1));
}
{
int len;
char *buf = odr_getbuf(p->odr_out, &len, 0);
-
+
if (cs_put(conn, buf, len) < 0)
yaz_log(YLOG_WARN, "cs_put failed URL: %s", uri);
else
}
else
*error = YAZ_ICONV_EILSEQ;
- }
+ }
else if (inp[0] <= 0xf7 && inbytesleft >= 4)
{
if ((inp[1] & 0xc0) == 0x80 && (inp[2] & 0xc0) == 0x80
{
*outp++ = (unsigned char) x;
(*outbytesleft)--;
- }
+ }
else if (x <= 0x7ff && *outbytesleft >= 2)
{
*outp++ = (unsigned char) ((x >> 6) | 0xc0);
*outp++ = (unsigned char) ((x & 0x3f) | 0x80);
(*outbytesleft) -= 6;
}
- else
+ else
{
*error = YAZ_ICONV_E2BIG; /* not room for output */
return (size_t)(-1);
yaz_iconv_encoder_t yaz_utf8_encoder(const char *tocode,
yaz_iconv_encoder_t e)
-
+
{
if (!yaz_matchstr(tocode, "UTF8"))
{
inbytesleft -= no_read;
}
return 1;
-}
+}
/*
* Local variables:
wrbuf_puts(b, buf);
}
-void wrbuf_puts_replace_char(WRBUF b, const char *buf,
+void wrbuf_puts_replace_char(WRBUF b, const char *buf,
const char from, const char to)
{
while(*buf)
#include <yaz/cql.h>
-static void pr_n(const char *buf,
+static void pr_n(const char *buf,
void (*pr)(const char *buf, void *client_data),
void *client_data, int n)
{
src++;
}
}
-
+
static void prefixes(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data, int level)
if (head)
pr_n("</prefixes>\n", pr, client_data, level);
}
-
+
static void cql_to_xml_mod(struct cql_node *m,
void (*pr)(const char *buf, void *client_data),
void *client_data, int level)
}
}
-static void cql_sort_to_xml(struct cql_node *cn,
+static void cql_sort_to_xml(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data, int level)
{
for (; cn; cn = cn->u.sort.next)
{
pr_n("<key>\n", pr, client_data, level+2);
-
+
if (cn->u.sort.index)
{
pr_n("<index>", pr, client_data, level+4);
}
}
-void cql_to_xml(struct cql_node *cn,
+void cql_to_xml(struct cql_node *cn,
void (*pr)(const char *buf, void *client_data),
void *client_data)
{
{
char *res;
struct dmalloc_info *dinfo;
-
+
if (!log_level_initialized)
{
log_level = yaz_log_module_level("malloc");
dinfo->file[sizeof(dinfo->file)-1] = '\0';
dinfo->line = line;
dinfo->len = nbytes;
-
+
dinfo->prev = 0;
dinfo->next = dmalloc_list;
if (dinfo->next)
dinfo->next->prev = dinfo;
dmalloc_list = dinfo;
-
+
memcpy(res + sizeof(*dinfo), head, 8*sizeof(char));
res += sizeof(*dinfo) + 8*sizeof(char);
memcpy(res + nbytes, tail, 8*sizeof(char));
struct dmalloc_info *dinfo;
char *ptr = (char*) p;
char *res;
-
+
if (!log_level_initialized)
{
log_level = yaz_log_module_level("malloc");
dmalloc_list = dinfo->next;
if (dinfo->next)
dinfo->next->prev = dinfo->prev;
-
+
if (!nbytes)
{
free(dinfo);
if (dmalloc_list)
dmalloc_list->prev = dinfo;
dmalloc_list = dinfo;
-
+
memcpy(res + sizeof(*dinfo), head, 8*sizeof(char));
res += sizeof(*dinfo) + 8*sizeof(char);
memcpy(res + nbytes, tail, 8*sizeof(char));
char *res;
struct dmalloc_info *dinfo;
size_t nbytes = nmemb * size;
-
+
if (!log_level_initialized)
{
log_level = yaz_log_module_level("malloc");
dinfo->file[sizeof(dinfo->file)-1] = '\0';
dinfo->line = line;
dinfo->len = nbytes;
-
+
dinfo->prev = 0;
dinfo->next = dmalloc_list;
if (dinfo->next)
dinfo->next->prev = dinfo;
dmalloc_list = dinfo;
-
+
memcpy(res + sizeof(*dinfo), head, 8*sizeof(char));
res += sizeof(*dinfo) + 8*sizeof(char);
memcpy(res + nbytes, tail, 8*sizeof(char));
{
size_t size = 0;
struct dmalloc_info *dinfo = dmalloc_list;
-
+
if (!log_level_initialized)
{
log_level = yaz_log_module_level("malloc");
#define xmalloc_d(x, f, l) malloc(x)
#define xcalloc_d(x,y, f, l) calloc(x,y)
#define xfree_d(x, f, l) free(x)
-#define xmalloc_trav_d(f, l)
+#define xmalloc_trav_d(f, l)
#endif
void xmalloc_trav_f(const char *s, const char *file, int line)
void *xmalloc_f(size_t size, const char *file, int line)
{
void *p = xmalloc_d(size, file, line);
-
+
if (!log_level_initialized)
{
log_level = yaz_log_module_level("malloc");
}
if (log_level)
- yaz_log(log_level, "%s:%d: xmalloc(s=%ld) %p", file, line,
+ yaz_log(log_level, "%s:%d: xmalloc(s=%ld) %p", file, line,
(long) size, p);
if (!p)
}
if (log_level)
- yaz_log(log_level, "%s:%d: xstrdup(s=%ld) %p", file, line,
+ yaz_log(log_level, "%s:%d: xstrdup(s=%ld) %p", file, line,
(long) strlen(s)+1, p);
strcpy(p, s);
memcpy(a, s, n);
a[n] = '\0';
return a;
- }
+ }
}
/*
* See the file LICENSE for details.
*/
-/** \file
+/** \file
\brief XML Include (not to be confused with W3C XInclude)
*/
#if HAVE_CONFIG_H
yaz_glob_res_t glob_res;
glob_ret = yaz_file_glob(wrbuf_cstr(w), &glob_res);
-
+
if (glob_ret == 0)
{
size_t i;
wrbuf_printf(w, " end include src=\"%s\" ", src);
c = xmlNewComment((const xmlChar *) wrbuf_cstr(w));
sib = xmlAddNextSibling(sib, c);
-
+
*np = sib;
wrbuf_destroy(w);
return ret;
xmlFree(src);
if (ret)
return ret;
-
+
}
}
else
void yaz_log_xml_errors(const char *prefix, int log_level)
{
xml_error_log_level = log_level;
-
+
#if YAZ_HAVE_XML2
xmlSetGenericErrorFunc((void *) (prefix ? prefix : "XML"),
xml_error_handler);
-#if YAZ_HAVE_XSLT
+#if YAZ_HAVE_XSLT
xsltSetGenericErrorFunc((void *) (prefix ? prefix : "XSLT"),
xml_error_handler);
#endif
char formstr[30];
const char *setname = 0;
char oid_name_str[OID_STR_MAX];
-
+
if (element->attributeSet)
{
setname = yaz_oid_to_string_buf(element->attributeSet,
for (i = 0; i<element->value.complex->num_list; i++)
{
xmlNodePtr node = xmlNewChild(parent, 0, BAD_CAST "attr", 0);
-
+
if (setname)
xmlNewProp(node, BAD_CAST "set", BAD_CAST setname);
-
+
sprintf(formstr, ODR_INT_PRINTF, *element->attributeType);
xmlNewProp(node, BAD_CAST "type", BAD_CAST formstr);
-
+
if (element->value.complex->list[i]->which ==
Z_StringOrNumeric_string)
{
- xmlNewProp(node, BAD_CAST "value", BAD_CAST
+ xmlNewProp(node, BAD_CAST "value", BAD_CAST
element->value.complex->list[i]->u.string);
}
else if (element->value.complex->list[i]->which ==
case Z_Term_numeric:
type = "numeric";
sprintf(formstr, ODR_INT_PRINTF, *term->u.numeric);
- t = xmlNewText(BAD_CAST formstr);
+ t = xmlNewText(BAD_CAST formstr);
break;
case Z_Term_characterString:
type = "string";
return;
}
xmlNewProp(node, BAD_CAST "type", BAD_CAST type);
-
+
if (op->which == Z_Operator_prox)
{
char formstr[30];
-
+
if (op->u.prox->exclusion)
{
if (*op->u.prox->exclusion)
if (*op->u.prox->ordered)
xmlNewProp(node, BAD_CAST "ordered", BAD_CAST "true");
- else
+ else
xmlNewProp(node, BAD_CAST "ordered", BAD_CAST "false");
-
+
sprintf(formstr, ODR_INT_PRINTF, *op->u.prox->relationType);
xmlNewProp(node, BAD_CAST "relationType", BAD_CAST formstr);
-
+
switch(op->u.prox->which)
{
case Z_ProximityOperator_known:
return yaz_query2xml_apt(zs->u.simple->u.attributesPlusTerm,
parent);
else if (zs->u.simple->which == Z_Operand_resultSetId)
- return xmlNewChild(parent, /* NS */ 0, BAD_CAST "rset",
+ return xmlNewChild(parent, /* NS */ 0, BAD_CAST "rset",
BAD_CAST zs->u.simple->u.resultSetId);
}
return 0;
switch (q->which)
{
- case Z_Query_type_1:
+ case Z_Query_type_1:
case Z_Query_type_101:
q_node = xmlNewChild(top_node, 0, BAD_CAST "rpn", 0);
child_node = yaz_query2xml_rpn(q->u.type_1, q_node);
xmlFree(type);
}
-static void yaz_xml2query_attribute_element(const xmlNode *ptr,
+static void yaz_xml2query_attribute_element(const xmlNode *ptr,
Z_AttributeElement **elem, ODR odr,
int *error_code,
const char **addinfo)
*addinfo = "missing value attribute for att content";
return;
}
-
+
*elem = (Z_AttributeElement *) odr_malloc(odr, sizeof(**elem));
if (set)
(*elem)->attributeSet = yaz_string_to_oid_odr(yaz_oid_std(),
}
}
(*elem)->value.complex->num_semanticAction = 0;
- (*elem)->value.complex->semanticAction = 0;
+ (*elem)->value.complex->semanticAction = 0;
}
else
{ /* good'ld numeric value */
(*zapt)->attributes->attributes = (Z_AttributeElement **)
odr_malloc(odr, sizeof(Z_AttributeElement*) * num_attr);
- i = 0;
+ i = 0;
ptr = ptr_apt->children;
for (; ptr; ptr = ptr->next)
if (ptr->type == XML_ELEMENT_NODE)
if (ptr && ptr->type == XML_ELEMENT_NODE)
{
if (!xmlStrcmp(ptr->name, BAD_CAST "term"))
- {
+ {
/* deal with term */
yaz_xml2query_term(ptr, &(*zapt)->term, odr, error_code, addinfo);
}
{
while (ptr && ptr->type != XML_ELEMENT_NODE)
ptr = ptr->next;
-
+
if (!ptr || ptr->type != XML_ELEMENT_NODE)
{
*error_code = 1;
if (!xmlStrcmp(ptr->name, BAD_CAST "operator"))
{
Z_Complex *zc = (Z_Complex *) odr_malloc(odr, sizeof(Z_Complex));
-
+
(*zs)->which = Z_RPNStructure_complex;
(*zs)->u.complex = zc;
-
+
yaz_xml2query_operator(ptr, &zc->roperator, odr, error_code, addinfo);
ptr = ptr->children;
ptr = ptr->next;
yaz_xml2query_rpnstructure(ptr, &zc->s2, odr, error_code, addinfo);
}
- else
+ else
{
Z_Operand *s = (Z_Operand *) odr_malloc(odr, sizeof(Z_Operand));
(*zs)->which = Z_RPNStructure_simple;
}
else if (!xmlStrcmp(ptr->name, BAD_CAST "rset"))
{
- s->which = Z_Operand_resultSetId;
+ s->which = Z_Operand_resultSetId;
yaz_xml2query_rset(ptr, &s->u.resultSetId,
odr, error_code, addinfo);
}
{
*error_code = 1;
*addinfo = "bad element: expected binary, apt or rset";
- }
+ }
}
}
{
if (check_diagnostic(ptr, odr, error_code, addinfo))
return;
- if (ptr && ptr->type == XML_ELEMENT_NODE &&
+ if (ptr && ptr->type == XML_ELEMENT_NODE &&
!xmlStrcmp(ptr->name, BAD_CAST "query"))
{
const char *type;
{
Z_DeleteResultSetResponse *r = (Z_DeleteResultSetResponse *)
odr_malloc(o, sizeof(*r));
-
+
r->referenceId = 0;
r->deleteOperationStatus = odr_intdup(o, Z_DeleteStatus_success);
r->deleteListStatuses = 0;
static Z_ScanRequest *zget_ScanRequest(ODR o)
{
Z_ScanRequest *r = (Z_ScanRequest *)odr_malloc(o, sizeof(*r));
-
+
r->referenceId = 0;
r->num_databaseNames = 0;
r->databaseNames = 0;
static Z_ScanResponse *zget_ScanResponse(ODR o)
{
Z_ScanResponse *r = (Z_ScanResponse *)odr_malloc(o, sizeof(*r));
-
+
r->referenceId = 0;
r->stepSize = 0;
r->scanStatus = odr_intdup(o, Z_Scan_success);
{
Z_TriggerResourceControlRequest *r = (Z_TriggerResourceControlRequest *)
odr_malloc(o, sizeof(*r));
-
+
r->referenceId = 0;
r->requestedAction = odr_intdup(o, Z_TriggerResourceControlRequest_resourceReport);
r->prefResourceReportFormat = 0;
{
Z_DuplicateDetectionRequest *r = (Z_DuplicateDetectionRequest *)
odr_malloc(o, sizeof(*r));
-
+
r->referenceId = 0;
r->num_inputResultSetIds = 0;
r->inputResultSetIds = 0;
{
Z_DuplicateDetectionResponse *r = (Z_DuplicateDetectionResponse *)
odr_malloc(o, sizeof(*r));
-
+
r->referenceId = 0;
r->status = odr_intdup(o, Z_DuplicateDetectionResponse_success);
r->resultSetCount = 0;
r->otherInfo = 0;
return r;
}
-
+
Z_APDU *zget_APDU(ODR o, int which)
{
Z_APDU *r = (Z_APDU *)odr_malloc(o, sizeof(*r));
-
+
switch (r->which = which)
{
case Z_APDU_initRequest:
Z_DefaultDiagFormat *zget_DefaultDiagFormat(ODR o, int error,
const char *addinfo)
{
- Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
+ Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
odr_malloc(o, sizeof(*dr));
-
+
dr->diagnosticSetId = odr_oiddup(o, yaz_oid_diagset_bib_1);
dr->condition = odr_intdup(o, error);
dr->which = Z_DefaultDiagFormat_v2Addinfo;
{
Z_NamePlusRecord *rec = (Z_NamePlusRecord *) odr_malloc(o, sizeof(*rec));
Z_DiagRec *drec = (Z_DiagRec *)odr_malloc(o, sizeof(*drec));
-
+
if (dbname)
rec->databaseName = odr_strdup(o, dbname);
else
x = (Z_External*) odr_malloc(odr, sizeof *x);
x->descriptor = 0;
- x->indirect_reference = 0;
+ x->indirect_reference = 0;
x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1);
x->which = Z_External_userInfo1;
x = (Z_External*) odr_malloc(odr, sizeof *x);
x->descriptor = 0;
- x->indirect_reference = 0;
+ x->indirect_reference = 0;
x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1);
x->which = Z_External_octet;
x->u.octet_aligned = (Odr_oct *) odr_malloc(odr, sizeof(Odr_oct));
int ZOOM_uri_to_code(const char *uri)
{
- int code = 0;
+ int code = 0;
const char *cp;
if ((cp = strrchr(uri, '/')))
code = atoi(cp+1);
c->host_port = 0;
c->proxy = 0;
c->tproxy = 0;
-
+
c->charset = c->lang = 0;
c->cookie_out = 0;
{
char **databaseNames;
const char *cp = ZOOM_options_get(options, "databaseName");
-
+
if ((!cp || !*cp) && con->host_port)
{
if (strncmp(con->host_port, "unix:", 5) == 0)
}
else
c->host_port = xstrdup(host);
- }
+ }
{
/*
c->cookie_out = 0;
val = ZOOM_options_get(c->options, "cookie");
if (val && *val)
- {
+ {
yaz_log(c->log_details, "%p ZOOM_connection_connect cookie=%s", c, val);
c->cookie_out = xstrdup(val);
}
if (val && *val)
c->password = xstrdup(val);
-
+
c->maximum_record_size =
ZOOM_options_get_int(c->options, "maximumRecordSize", 64*1024*1024);
c->preferred_message_size =
r->query = q;
r->options = ZOOM_options_create_with_parent(c->options);
-
+
start = ZOOM_options_get_int(r->options, "start", 0);
count = ZOOM_options_get_int(r->options, "count", 0);
{
r->databaseNames = ZOOM_connection_get_databases(c, c->options, &r->num_databaseNames,
r->odr);
-
+
r->connection = c;
#if ZOOM_RESULT_LISTS
task->u.search.count = count;
task->u.search.recv_search_fired = 0;
- syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
task->u.search.syntax = syntax ? xstrdup(syntax) : 0;
elementSetName = ZOOM_options_get(r->options, "elementSetName");
- task->u.search.elementSetName = elementSetName
+ task->u.search.elementSetName = elementSetName
? xstrdup(elementSetName) : 0;
-
+
ZOOM_resultset_addref(r);
ZOOM_query_addref(q);
c->reconnect_ok = 1;
}
}
-
+
ZOOM_resultset_cache_reset(r);
task = ZOOM_connection_add_task(c, ZOOM_TASK_SORT);
task->u.sort.resultset = r;
task->u.sort.q = newq;
- ZOOM_resultset_addref(r);
+ ZOOM_resultset_addref(r);
if (!c->async)
{
task->u.retrieve.start = start;
task->u.retrieve.count = count;
- syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
task->u.retrieve.syntax = syntax ? xstrdup(syntax) : 0;
elementSetName = ZOOM_options_get(r->options, "elementSetName");
- task->u.retrieve.elementSetName = elementSetName
+ task->u.retrieve.elementSetName = elementSetName
? xstrdup(elementSetName) : 0;
cp = ZOOM_options_get(r->options, "schema");
{
char *cert_buf;
int cert_len;
-
+
if (cs_get_peer_certificate_x509(c->cs, &cert_buf, &cert_len))
{
ZOOM_connection_option_setl(c, "sslPeerCert",
cs_close(c->cs);
c->cs = cs_create_host_proxy(logical_url, 0, &add,
c->tproxy ? c->tproxy : c->proxy);
-
+
if (c->cs && c->cs->protocol == PROTO_HTTP)
{
#if YAZ_HAVE_XML2
if (c->cs->io_pending & CS_WANT_READ)
mask += ZOOM_SELECT_READ;
ZOOM_connection_set_mask(c, mask);
- c->state = STATE_CONNECTING;
+ c->state = STATE_CONNECTING;
return zoom_pending;
}
}
}
/* returns 1 if PDU was sent OK (still pending )
- 0 if PDU was not sent OK (nothing to wait for)
+ 0 if PDU was not sent OK (nothing to wait for)
*/
ZOOM_API(ZOOM_record)
ZOOM_resultset_record_immediate(ZOOM_resultset s,size_t pos)
{
const char *syntax =
- ZOOM_options_get(s->options, "preferredRecordSyntax");
+ ZOOM_options_get(s->options, "preferredRecordSyntax");
const char *elementSetName =
ZOOM_options_get(s->options, "elementSetName");
{
ZOOM_task task = ZOOM_connection_add_task(c, ZOOM_TASK_SCAN);
task->u.scan.scan = scan;
-
+
(scan->refcount)++;
if (!c->async)
{
ZOOM_query_destroy(scan->query);
odr_destroy(scan->odr);
-
+
ZOOM_options_destroy(scan->options);
xfree(scan);
}
if (!c->tasks)
return zoom_complete;
assert (c->tasks->which == ZOOM_TASK_PACKAGE);
-
+
event = ZOOM_Event_create(ZOOM_EVENT_SEND_APDU);
ZOOM_connection_put_event(c, event);
-
+
c->buf_out = c->tasks->u.package->buf_out;
c->len_out = c->tasks->u.package->len_out;
const char **disp_term, size_t *disp_len)
{
size_t noent = ZOOM_scanset_size(scan);
-
+
*value_term = 0;
*value_len = 0;
if (res->entries->entries[pos]->which == Z_Entry_termInfo)
{
Z_TermInfo *t = res->entries->entries[pos]->u.termInfo;
-
+
*value_term = (const char *) t->term->u.general->buf;
*value_len = t->term->u.general->len;
if (t->displayTerm)
ZOOM_scanset_term_x(scan, pos, occ, &value_term, &value_len,
&disp_term, &disp_len);
-
+
*len = value_len;
return value_term;
}
ZOOM_scanset_term_x(scan, pos, occ, &value_term, &value_len,
&disp_term, &disp_len);
-
+
*len = disp_len;
return disp_term;
}
{
odr_destroy(p->odr_out);
xfree(p->buf_out);
-
+
ZOOM_options_destroy(p->options);
xfree(p);
}
ret = send_package(c);
break;
case ZOOM_TASK_SORT:
- c->tasks->u.sort.resultset->r_sort_spec =
+ c->tasks->u.sort.resultset->r_sort_spec =
ZOOM_query_get_sortspec(c->tasks->u.sort.q);
ret = send_Z3950_sort(c, c->tasks->u.sort.resultset);
break;
return;
}
}
- else
- {
+ else
+ {
ret = ZOOM_handle_sru(c, hres, &cret, &addinfo);
if (ret == 0)
{
{
int r, more;
ZOOM_Event event;
-
+
event = ZOOM_Event_create(ZOOM_EVENT_RECV_DATA);
ZOOM_connection_put_event(c, event);
-
+
r = cs_get(c->cs, &c->buf_in, &c->len_in);
more = cs_more(c->cs);
yaz_log(c->log_details, "%p do_read len=%d more=%d", c, r, more);
{
int r;
ZOOM_Event event;
-
+
event = ZOOM_Event_create(ZOOM_EVENT_SEND_DATA);
ZOOM_connection_put_event(c, event);
return zoom_complete;
}
else if (r == 1)
- {
+ {
int mask = ZOOM_SELECT_EXCEPT;
if (c->cs->io_pending & CS_WANT_WRITE)
mask += ZOOM_SELECT_WRITE;
int r = cs_look(c->cs);
yaz_log(c->log_details, "%p ZOOM_connection_do_io mask=%d cs_look=%d",
c, mask, r);
-
+
if (r == CS_NONE)
{
event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
int i;
yaz_log(log_details0, "ZOOM_process_event(no=%d,cs=%p)", no, cs);
-
+
for (i = 0; i<no; i++)
{
ZOOM_connection c = cs[i];
{
c->mask = mask;
if (!c->cs)
- return -1;
+ return -1;
return 0;
}
ZOOM_options dst = ZOOM_options_create();
struct ZOOM_options_entry *src_e = src->entries;
struct ZOOM_options_entry **dst_e = &dst->entries;
-
+
while(src_e)
{
append_entry(dst_e, src_e->name, src_e->value, src_e->len);
void *callback_handle)
{
ZOOM_options_callback callback_old;
-
+
assert(opt);
callback_old = opt->callback_func;
opt->callback_func = callback_func;
if (opt->refcount == 0)
{
struct ZOOM_options_entry *e;
-
+
ZOOM_options_destroy(opt->parent1);
ZOOM_options_destroy(opt->parent2);
e = opt->entries;
ZOOM_options_get_bool(ZOOM_options opt, const char *name, int defa)
{
const char *v = ZOOM_options_get(opt, name);
-
+
if (!v)
return defa;
if (!strcmp(v, "1") || !strcmp(v, "T"))
zoom_sru_post,
zoom_sru_solr
} zoom_sru_mode;
-
+
typedef struct ZOOM_task_p *ZOOM_task;
ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos,
const char *syntax,
const char *elementSetName);
-void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
+void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
int pos,
const char *syntax, const char *elementSetName,
const char *schema,
s->z_query = (Z_Query *) odr_malloc(s->odr_query,
sizeof(*s->z_query));
s->z_query->which = Z_Query_type_1;
- s->z_query->u.type_1 =
+ s->z_query->u.type_1 =
p_query_rpn(s->odr_query, wrbuf_cstr(s->full_query));
if (!s->z_query->u.type_1)
{
ext->descriptor = 0;
ext->which = Z_External_CQL;
ext->u.cql = odr_strdup(s->odr_query, wrbuf_cstr(s->full_query));
-
+
s->z_query = (Z_Query *) odr_malloc(s->odr_query, sizeof(*s->z_query));
s->z_query->which = Z_Query_type_104;
s->z_query->u.type_104 = ext;
-
+
break;
}
}
}
cqlfile = ZOOM_connection_option_get(c, "cqlfile");
- if (cqlfile == 0)
+ if (cqlfile == 0)
{
ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, "no CQL transform file");
}
- else if ((trans = cql_transform_open_fname(cqlfile)) == 0)
+ else if ((trans = cql_transform_open_fname(cqlfile)) == 0)
{
- char buf[512];
+ char buf[512];
sprintf(buf, "can't open CQL transform file '%.200s': %.200s",
cqlfile, strerror(errno));
ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, buf);
}
- else
+ else
{
WRBUF wrbuf_result = wrbuf_alloc();
error = cql_transform(trans, cql_parser_result(parser),
char buf[512];
const char *addinfo;
error = cql_transform_error(trans, &addinfo);
- sprintf(buf, "%.200s (addinfo=%.200s)",
+ sprintf(buf, "%.200s (addinfo=%.200s)",
cql_strerror(error), addinfo);
ZOOM_set_error(c, ZOOM_ERROR_CQL_TRANSFORM, buf);
}
return pos % RECORD_HASH_SIZE;
}
-void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
+void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
int pos,
const char *syntax, const char *elementSetName,
const char *schema,
Z_SRW_diagnostic *diag)
{
ZOOM_record_cache rc = 0;
-
+
ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_RECV_RECORD);
ZOOM_connection_put_event(r->connection, event);
for (rc = r->record_hash[record_hash(pos)]; rc; rc = rc->next)
{
- if (pos == rc->pos
+ if (pos == rc->pos
&& strcmp_null(r->schema, rc->schema) == 0
&& strcmp_null(elementSetName,rc->elementSetName) == 0
&& strcmp_null(syntax, rc->syntax) == 0)
rc->rec.wrbuf = 0;
#endif
rc->elementSetName = odr_strdup_null(r->odr, elementSetName);
-
+
rc->syntax = odr_strdup_null(r->odr, syntax);
-
+
rc->schema = odr_strdup_null(r->odr, r->schema);
rc->pos = pos;
*cp = '\0';
rc->rec.diag_uri = odr_strdup(r->odr, diag->uri);
}
- rc->rec.diag_message = odr_strdup_null(r->odr, diag->message);
+ rc->rec.diag_message = odr_strdup_null(r->odr, diag->message);
rc->rec.diag_details = odr_strdup_null(r->odr, diag->details);
}
}
const char *elementSetName)
{
ZOOM_record_cache rc;
-
+
for (rc = r->record_hash[record_hash(pos)]; rc; rc = rc->next)
{
if (pos == rc->pos)
if (!z_NamePlusRecord(odr_enc, &srec->npr, 0, 0))
return 0;
buf = odr_getbuf(odr_enc, &size, 0);
-
+
nrec = (ZOOM_record) xmalloc(sizeof(*nrec));
nrec->odr = odr_createmem(ODR_DECODE);
#if SHPTR
#endif
odr_setbuf(nrec->odr, buf, size, 0);
z_NamePlusRecord(nrec->odr, &nrec->npr, 0, 0);
-
+
nrec->schema = odr_strdup_null(nrec->odr, srec->schema);
nrec->diag_uri = odr_strdup_null(nrec->odr, srec->diag_uri);
nrec->diag_message = odr_strdup_null(nrec->odr, srec->diag_message);
ZOOM_record_get(ZOOM_record rec, const char *type_spec, int *len)
{
WRBUF wrbuf;
-
+
if (len)
*len = 0; /* default return */
-
+
if (!rec || !rec->npr)
return 0;
const char **addinfo, const char **diagset)
{
Z_NamePlusRecord *npr;
-
+
if (!rec)
return 0;
{
Z_DefaultDiagFormat *ddf = diag_rec->u.defaultFormat;
oid_class oclass;
-
+
error = *ddf->condition;
switch (ddf->which)
{
{
ZOOM_connection c = cs[i];
int fd, mask;
-
+
if (!c)
continue;
fd = ZOOM_connection_get_socket(c);
if (c->odr_save)
z_GDU(c->odr_save, &gdu, 0, 0);
c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
-
+
event = ZOOM_Event_create(ZOOM_EVENT_SEND_APDU);
ZOOM_connection_put_event(c, event);
odr_reset(c->odr_out);
return zoom_complete;
assert (c->tasks->which == ZOOM_TASK_SCAN);
scan = c->tasks->u.scan.scan;
-
+
sr = ZOOM_srw_get_pdu(c, Z_SRW_scan_request);
z_query = ZOOM_query_get_Z_Query(scan->query);
sr->u.scan_request->maximumTerms = odr_intdup(
c->odr_out, ZOOM_options_get_int(scan->options, "number", 10));
-
+
sr->u.scan_request->responsePosition = odr_intdup(
c->odr_out, ZOOM_options_get_int(scan->options, "position", 1));
-
+
option_val = ZOOM_options_get(scan->options, "extraArgs");
yaz_encode_sru_extra(sr, c->odr_out, option_val);
return send_srw(c, sr);
return zoom_complete;
}
assert(resultset->query);
-
+
sr = ZOOM_srw_get_pdu(c, Z_SRW_searchRetrieve_request);
z_query = ZOOM_query_get_Z_Query(resultset->query);
{
sr->u.request->query_type = Z_SRW_query_type_pqf;
sr->u.request->query.pqf =
- odr_strdup(c->odr_out,
+ odr_strdup(c->odr_out,
ZOOM_query_get_query_string(resultset->query));
}
else
ZOOM_set_error(c, ZOOM_ERROR_UNSUPPORTED_QUERY, 0);
return zoom_complete;
}
-
+
option_val = ZOOM_query_get_sru11(resultset->query);
if (option_val)
{
}
sr->u.request->startRecord = odr_intdup(c->odr_out, *start + 1);
sr->u.request->maximumRecords = odr_intdup(
- c->odr_out, (resultset->step > 0 && resultset->step < *count) ?
+ c->odr_out, (resultset->step > 0 && resultset->step < *count) ?
resultset->step : *count);
sr->u.request->recordSchema = resultset->schema;
sr->u.request->facetList = facet_list;
-
+
option_val = ZOOM_resultset_option_get(resultset, "recordPacking");
if (option_val)
sr->u.request->recordPacking = odr_strdup(c->odr_out, option_val);
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
syntax = c->tasks->u.search.syntax;
- elementSetName = c->tasks->u.search.elementSetName;
+ elementSetName = c->tasks->u.search.elementSetName;
/* Required not for reporting client hit count multiple times into session */
if (!c->tasks->u.search.recv_search_fired) {
Z_SRW_record *sru_rec;
Z_SRW_diagnostic *diag = 0;
int num_diag;
-
+
Z_NamePlusRecord *npr = (Z_NamePlusRecord *)
odr_malloc(c->odr_in, sizeof(Z_NamePlusRecord));
/* recordPosition is 1 based */
- if (res->records[i].recordPosition &&
+ if (res->records[i].recordPosition &&
*res->records[i].recordPosition > 0)
pos = *res->records[i].recordPosition - 1;
else
pos = *start + i;
sru_rec = &res->records[i];
-
+
npr->databaseName = 0;
npr->which = Z_NamePlusRecord_databaseRecord;
npr->u.databaseRecord = (Z_External *)
odr_oiddup(c->odr_in, yaz_oid_recsyn_xml);
npr->u.databaseRecord->indirect_reference = 0;
npr->u.databaseRecord->which = Z_External_octet;
-
+
npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
odr_malloc(c->odr_in, sizeof(Odr_oct));
npr->u.databaseRecord->u.octet_aligned->buf = (unsigned char*)
sru_rec->recordData_buf;
- npr->u.databaseRecord->u.octet_aligned->len =
- npr->u.databaseRecord->u.octet_aligned->size =
+ npr->u.databaseRecord->u.octet_aligned->len =
+ npr->u.databaseRecord->u.octet_aligned->size =
sru_rec->recordData_len;
-
- if (sru_rec->recordSchema
+
+ if (sru_rec->recordSchema
&& !strcmp(sru_rec->recordSchema,
"info:srw/schema/1/diagnostics-v1.1"))
{
if (!ret && soap_package->which == Z_SOAP_generic)
{
Z_SRW_PDU *sr = (Z_SRW_PDU*) soap_package->u.generic->p;
-
+
ZOOM_options_set(c->options, "sru_version", sr->srw_version);
ZOOM_options_setl(c->options, "sru_extra_response_data",
sr->extraResponseData_buf, sr->extraResponseData_len);
strcpy(*addinfo + sz, "");
ret = -1;
}
- }
+ }
return ret;
#else
return -1;
const char *str;
Z_APDU *apdu = zget_APDU(p->odr_out, Z_APDU_extendedServicesRequest);
Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
-
+
str = ZOOM_options_get(p->options, "package-name");
if (str && *str)
req->packageName = odr_strdup(p->odr_out, str);
-
+
str = ZOOM_options_get(p->options, "user-id");
if (str)
req->userId = odr_strdup_null(p->odr_out, str);
-
+
req->packageType = odr_oiddup(p->odr_out, oid);
str = ZOOM_options_get(p->options, "function");
ILL_Request *req;
Z_External *r = 0;
struct ill_get_ctl ctl;
-
+
ctl.odr = p->odr_out;
ctl.clientData = p;
ctl.f = ill_array_lookup;
-
+
req = ill_get_ILLRequest(&ctl, "ill", 0);
-
+
if (!ill_Request(out, &req, 0, 0))
{
int ill_request_size;
{
int illRequest_size = 0;
char *illRequest_buf = odr_getbuf(out, &illRequest_size, 0);
-
+
r = (Z_External *) odr_malloc(out, sizeof(*r));
r->direct_reference = odr_oiddup(out, yaz_oid_general_isoill_1);
r->indirect_reference = 0;
r->descriptor = 0;
r->which = Z_External_single;
-
+
r->u.single_ASN1_type =
odr_create_Odr_oct(out,
(unsigned char *)illRequest_buf,
Z_ItemOrder *req = (Z_ItemOrder *) odr_malloc(p->odr_out, sizeof(*req));
const char *str;
int len;
-
+
req->which = Z_IOItemOrder_esRequest;
- req->u.esRequest = (Z_IORequest *)
+ req->u.esRequest = (Z_IORequest *)
odr_malloc(p->odr_out,sizeof(Z_IORequest));
/* to keep part ... */
req->u.esRequest->toKeep->supplDescription = 0;
req->u.esRequest->toKeep->contact = (Z_IOContact *)
odr_malloc(p->odr_out, sizeof(*req->u.esRequest->toKeep->contact));
-
+
str = ZOOM_options_get(p->options, "contact-name");
req->u.esRequest->toKeep->contact->name =
odr_strdup_null(p->odr_out, str);
-
+
str = ZOOM_options_get(p->options, "contact-phone");
req->u.esRequest->toKeep->contact->phone =
odr_strdup_null(p->odr_out, str);
-
+
str = ZOOM_options_get(p->options, "contact-email");
req->u.esRequest->toKeep->contact->email =
odr_strdup_null(p->odr_out, str);
-
+
req->u.esRequest->toKeep->addlBilling = 0;
-
+
/* not to keep part ... */
req->u.esRequest->notToKeep = (Z_IOOriginPartNotToKeep *)
odr_malloc(p->odr_out,sizeof(Z_IOOriginPartNotToKeep));
-
+
str = ZOOM_options_get(p->options, "itemorder-setname");
if (!str)
str = "default";
- if (!*str)
+ if (!*str)
req->u.esRequest->notToKeep->resultSetItem = 0;
else
{
odr_strdup(p->odr_out, str);
req->u.esRequest->notToKeep->resultSetItem->item =
odr_intdup(p->odr_out, 0);
-
+
str = ZOOM_options_get(p->options, "itemorder-item");
*req->u.esRequest->notToKeep->resultSetItem->item =
(str ? atoi(str) : 1);
}
else
req->u.esRequest->notToKeep->itemRequest = encode_ill_request(p);
-
+
return req;
}
-Z_APDU *create_admin_package(ZOOM_package p, int type,
+Z_APDU *create_admin_package(ZOOM_package p, int type,
Z_ESAdminOriginPartToKeep **toKeepP,
Z_ESAdminOriginPartNotToKeep **notToKeepP)
{
p->odr_out);
if (num_db > 0)
first_db = db[0];
-
+
r->direct_reference = odr_oiddup(p->odr_out, yaz_oid_extserv_admin);
r->descriptor = 0;
r->indirect_reference = 0;
r->which = Z_External_ESAdmin;
-
+
r->u.adminService = (Z_Admin *)
odr_malloc(p->odr_out, sizeof(*r->u.adminService));
r->u.adminService->which = Z_Admin_esRequest;
r->u.adminService->u.esRequest = (Z_AdminEsRequest *)
odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest));
-
+
toKeep = r->u.adminService->u.esRequest->toKeep =
- (Z_ESAdminOriginPartToKeep *)
+ (Z_ESAdminOriginPartToKeep *)
odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest->toKeep));
toKeep->which = type;
toKeep->databaseName = odr_strdup(p->odr_out, first_db);
toKeep->u.create = odr_nullval();
apdu->u.extendedServicesRequest->taskSpecificParameters = r;
-
+
r->u.adminService->u.esRequest->notToKeep = notToKeep =
(Z_ESAdminOriginPartNotToKeep *)
odr_malloc(p->odr_out,
ext->direct_reference = req->packageType;
ext->descriptor = 0;
ext->indirect_reference = 0;
-
+
ext->which = Z_External_octet;
ext->u.single_ASN1_type =
odr_create_Odr_oct(p->odr_out, (const unsigned char *) doc, len);
p->odr_out);
}
if (!syntax_oid)
- {
+ {
ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_SYNTAX, syntax_str);
return 0;
}
if (num_db > 0)
first_db = db[0];
-
+
switch (*version)
{
case '1':
ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_VERSION, version);
return 0;
}
-
+
if (!strcmp(action, "recordInsert"))
action_no = Z_IUOriginPartToKeep_recordInsert;
else if (!strcmp(action, "recordReplace"))
odr_malloc(p->odr_out, sizeof(*r));
const char *elementSetName =
ZOOM_options_get(p->options, "elementSetName");
-
+
apdu->u.extendedServicesRequest->taskSpecificParameters = r;
-
+
r->direct_reference = odr_oiddup(p->odr_out, package_oid);
r->descriptor = 0;
r->which = Z_External_update;
r->indirect_reference = 0;
r->u.update = (Z_IUUpdate *)
odr_malloc(p->odr_out, sizeof(*r->u.update));
-
+
r->u.update->which = Z_IUUpdate_esRequest;
r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
odr_malloc(p->odr_out, sizeof(*r->u.update->u.esRequest));
- toKeep = r->u.update->u.esRequest->toKeep =
+ toKeep = r->u.update->u.esRequest->toKeep =
(Z_IUOriginPartToKeep *)
odr_malloc(p->odr_out, sizeof(*toKeep));
-
+
toKeep->databaseName = odr_strdup(p->odr_out, first_db);
toKeep->schema = 0;
-
+
toKeep->elementSetName = odr_strdup_null(p->odr_out, elementSetName);
-
+
toKeep->actionQualifier = 0;
toKeep->action = odr_intdup(p->odr_out, action_no);
-
- notToKeep = r->u.update->u.esRequest->notToKeep =
+
+ notToKeep = r->u.update->u.esRequest->notToKeep =
(Z_IUSuppliedRecords *)
odr_malloc(p->odr_out, sizeof(*notToKeep));
notToKeep->num = 1;
notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
if (recordIdOpaque)
{
- notToKeep->elements[0]->u.opaque =
+ notToKeep->elements[0]->u.opaque =
odr_create_Odr_oct(p->odr_out,
(const unsigned char *) recordIdOpaque,
recordIdOpaque_len);
else if (recordIdNumber)
{
notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_number;
-
+
notToKeep->elements[0]->u.number =
odr_intdup(p->odr_out, atoi(recordIdNumber));
}
len = sizeof(buf)-1;
memcpy(buf, val, len);
buf[len] = '\0';
-
+
oid = yaz_string_to_oid_odr(yaz_oid_std(), CLASS_USERINFO,
buf, out);
if (!oid)
continue;
-
+
yaz_oi_APDU(a, &oi);
yaz_oi_set_string_oid(oi, out, oid, 1, cp+1);
}
{
Z_OtherInformation **oi;
yaz_oi_APDU(a, &oi);
- yaz_oi_set_string_oid(oi, out, yaz_oid_userinfo_cookie,
+ yaz_oi_set_string_oid(oi, out, yaz_oid_userinfo_cookie,
1, c->cookie_out);
}
if (c->client_IP)
{
Z_OtherInformation **oi;
yaz_oi_APDU(a, &oi);
- yaz_oi_set_string_oid(oi, out, yaz_oid_userinfo_client_ip,
+ yaz_oi_set_string_oid(oi, out, yaz_oid_userinfo_client_ip,
1, c->client_IP);
}
otherInfo_attach(c, a, out);
ODR_MASK_SET(ireq->options, Z_Options_sort);
ODR_MASK_SET(ireq->options, Z_Options_extendedServices);
ODR_MASK_SET(ireq->options, Z_Options_namedResultSets);
-
+
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_1);
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2);
ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3);
-
+
ireq->implementationId =
odr_prepend(c->odr_out,
ZOOM_options_get(c->options, "implementationId"),
ireq->implementationId);
-
- ireq->implementationName =
+
+ ireq->implementationName =
odr_prepend(c->odr_out,
ZOOM_options_get(c->options, "implementationName"),
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
-
- ireq->implementationVersion =
+
+ ireq->implementationVersion =
odr_prepend(c->odr_out,
ZOOM_options_get(c->options, "implementationVersion"),
ireq->implementationVersion);
-
+
*ireq->maximumRecordSize = c->maximum_record_size;
*ireq->preferredMessageSize = c->preferred_message_size;
-
+
if (c->group || c->password)
{
Z_IdPass *pass = (Z_IdPass *) odr_malloc(c->odr_out, sizeof(*pass));
{
Z_OtherInformation **oi;
Z_OtherInformationUnit *oi_unit;
-
+
yaz_oi_APDU(apdu, &oi);
-
+
if ((oi_unit = yaz_oi_update(oi, c->odr_out, NULL, 0, 0)))
{
ODR_MASK_SET(ireq->options, Z_Options_negotiationModel);
ZOOM_set_error(c, ZOOM_ERROR_INVALID_QUERY, 0);
return zoom_complete;
}
- if (search_req->query->which == Z_Query_type_1 ||
+ if (search_req->query->which == Z_Query_type_1 ||
search_req->query->which == Z_Query_type_101)
{
const char *cp = ZOOM_options_get(r->options, "rpnCharset");
int r;
search_req->query = yaz_copy_Z_Query(search_req->query,
c->odr_out);
-
+
r = yaz_query_charset_convert_rpnquery_check(
search_req->query->u.type_1,
c->odr_out, cd);
/* Regular piggyback - do it unless we're going to do sort */
*search_req->largeSetLowerBound = 2000000000;
*search_req->smallSetUpperBound = 1;
- *search_req->mediumSetPresentNumber =
+ *search_req->mediumSetPresentNumber =
r->step>0 ? r->step : c->tasks->u.search.count;
}
else
{
Z_ElementSetNames *esn = (Z_ElementSetNames *)
odr_malloc(c->odr_out, sizeof(*esn));
-
+
esn->which = Z_ElementSetNames_generic;
esn->u.generic = odr_strdup(c->odr_out, smallSetElementSetName);
search_req->smallSetElementSetNames = esn;
{
Z_ElementSetNames *esn =(Z_ElementSetNames *)
odr_malloc(c->odr_out, sizeof(*esn));
-
+
esn->which = Z_ElementSetNames_generic;
esn->u.generic = odr_strdup(c->odr_out, mediumSetElementSetName);
search_req->mediumSetElementSetNames = esn;
if (syntax)
search_req->preferredRecordSyntax =
zoom_yaz_str_to_z3950oid(c, CLASS_RECSYN, syntax);
-
+
if (!r->setname)
{
if (c->support_named_resultsets)
req->stepSize =
odr_intdup(c->odr_out,
ZOOM_options_get_int(scan->options, "stepSize", 0));
-
+
req->databaseNames = scan->databaseNames;
req->num_databaseNames = scan->num_databaseNames;
if (apdu)
{
Z_External *r = (Z_External *) odr_malloc(p->odr_out, sizeof(*r));
-
- r->direct_reference =
+
+ r->direct_reference =
odr_oiddup(p->odr_out, yaz_oid_extserv_item_order);
r->descriptor = 0;
r->which = Z_External_itemOrder;
{
apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_create,
0, 0);
- }
+ }
else if (!strcmp(type, "drop")) /* drop database */
{
apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_drop,
buf = odr_getbuf(p->odr_out, &p->len_out, 0);
p->buf_out = (char *) xmalloc(p->len_out);
memcpy(p->buf_out, buf, p->len_out);
-
+
(p->refcount)++;
if (!c->async)
{
if (id)
ZOOM_options_setl(c->tasks->u.package->options,
"targetReference", (char*) id->buf, id->len);
-
+
switch ( *taskPackage->taskStatus ) {
case Z_TaskPackage_pending:
ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
Z_TaskPackage *taskPackage = res->taskPackage->u.extendedService;
es_response_taskpackage(c, taskPackage);
}
- if (res->taskPackage &&
+ if (res->taskPackage &&
res->taskPackage->which == Z_External_octet)
{
Odr_oct *doc = res->taskPackage->u.octet_aligned;
if (unit->which == Z_OtherInfo_externallyDefinedInfo &&
unit->information.externallyDefinedInfo &&
unit->information.externallyDefinedInfo->which ==
- Z_External_diag1)
+ Z_External_diag1)
{
interpret_init_diag(c, unit->information.externallyDefinedInfo->u.diag1);
- }
+ }
}
}
{
case Z_Term_general:
ZOOM_options_setl(opt, name,
- (const char *)(term->u.general->buf),
+ (const char *)(term->u.general->buf),
term->u.general->len);
break;
case Z_Term_characterString:
Z_QueryExpression *exp)
{
char opt_name[80];
-
+
switch (exp->which)
{
case Z_QueryExpression_term:
if (o->list[i]->which == Z_OtherInfo_externallyDefinedInfo)
{
Z_External *ext = o->list[i]->information.externallyDefinedInfo;
-
+
if (ext->which == Z_External_searchResult1)
{
int j;
Z_SearchInfoReport *sr = ext->u.searchResult1;
-
+
if (sr->num)
ZOOM_options_set_int(
resultset->options, "searchresult.size", sr->num);
Z_SearchInfoReport_s *ent =
ext->u.searchResult1->elements[j];
char pref[80];
-
+
sprintf(pref, "searchresult.%d", j);
if (ent->subqueryId)
sprintf(opt_name, "%s.count", pref);
ZOOM_options_set_int(resultset->options, opt_name,
*ent->subqueryCount);
- }
+ }
}
}
}
elementSetName = c->tasks->u.search.elementSetName;
break;
case ZOOM_TASK_RETRIEVE:
- resultset = c->tasks->u.retrieve.resultset;
+ resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
count = &c->tasks->u.retrieve.count;
syntax = c->tasks->u.retrieve.syntax;
else
ZOOM_set_error(c, ZOOM_ERROR_DECODE, 0);
}
- else
+ else
{
if (*count + *start > resultset->size)
*count = resultset->size - *start;
if (*count < 0)
*count = 0;
*start += i;
- yaz_log(c->log_details,
+ yaz_log(c->log_details,
"handle_records resultset=%p start=%d count=%d",
resultset, *start, *count);
if (present_phase && p->num_records == 0)
{
/* present response and we didn't get any records! */
- Z_NamePlusRecord *myrec =
+ Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(
- resultset->odr, 0,
+ resultset->odr, 0,
YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
"ZOOM C generated. Present phase and no records");
ZOOM_record_cache_add(resultset, myrec, *start,
else if (present_phase)
{
/* present response and we didn't get any records! */
- Z_NamePlusRecord *myrec =
+ Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(
resultset->odr, 0,
YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
{
Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_sortRequest);
Z_SortRequest *req = apdu->u.sortRequest;
-
+
req->num_inputResultSetNames = 1;
req->inputResultSetNames = (Z_InternationalString **)
odr_malloc(c->odr_out, sizeof(*req->inputResultSetNames));
yaz_log(c->log_details, "%p send_present no tasks", c);
return zoom_complete;
}
-
+
switch (c->tasks->which)
{
case ZOOM_TASK_SEARCH:
*req->numberOfRecordsRequested = resultset->step;
else
*req->numberOfRecordsRequested = *count;
-
+
if (*req->numberOfRecordsRequested + *start > resultset->size)
*req->numberOfRecordsRequested = resultset->size - *start;
assert(*req->numberOfRecordsRequested > 0);
compo->which = Z_RecordComp_complex;
compo->u.complex = (Z_CompSpec *)
odr_malloc(c->odr_out, sizeof(*compo->u.complex));
- compo->u.complex->selectAlternativeSyntax = (bool_t *)
+ compo->u.complex->selectAlternativeSyntax = (bool_t *)
odr_malloc(c->odr_out, sizeof(bool_t));
*compo->u.complex->selectAlternativeSyntax = 0;
odr_malloc(c->odr_out, sizeof(*esn));
Z_RecordComposition *compo = (Z_RecordComposition *)
odr_malloc(c->odr_out, sizeof(*compo));
-
+
esn->which = Z_ElementSetNames_generic;
esn->u.generic = odr_strdup(c->odr_out, elementSetName);
compo->which = Z_RecordComp_simple;
void ZOOM_handle_Z3950_apdu(ZOOM_connection c, Z_APDU *apdu)
{
Z_InitResponse *initrs;
-
+
ZOOM_connection_set_mask(c, 0);
yaz_log(c->log_details, "%p handle_Z3950_apdu apdu->which=%d",
c, apdu->which);
NMEM tmpmem = nmem_create();
Z_CharSetandLanguageNegotiation *p =
yaz_get_charneg_record(initrs->otherInfo);
-
+
if (p)
{
char *charset = NULL, *lang = NULL;
int sel;
-
+
yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel);
yaz_log(c->log_details, "%p handle_Z3950_apdu target accepted: "
"charset %s, language %s, select %d",
(sel != 0) ? "1" : "0");
nmem_destroy(tmpmem);
}
- }
+ }
break;
case Z_APDU_searchResponse:
yaz_log(c->log_api, "%p handle_Z3950_apdu Search response", c);
if (parser && bibset)
{
struct ccl_rpn_node *rpn;
-
+
rpn = ccl_parser_find_str(parser, query);
if (rpn)
{
/* parse ok. check that result is there and match */
WRBUF wrbuf = wrbuf_alloc();
ccl_pquery(wrbuf, rpn);
-
+
/* check expect a result and that it matches */
if (result && !strcmp(wrbuf_cstr(wrbuf), result))
ret = 1;
ccl_rpn_delete(rpn);
wrbuf_destroy(wrbuf);
}
- else
+ else
{
if (result)
{
"reg t=x\r\n"
"z t=z\r\n"
"dc.title 1=/my/title\n"
- "date r=r\n"
+ "date r=r\n"
"x r=o\n"
"title dc.title\n"
"comb term dc.title\n"
xmlDocPtr doc;
int r;
const char *addinfo = 0;
- const char *xml_str =
+ const char *xml_str =
"<cclmap>\n"
" <qual name=\"ti\">\n"
" <attr type=\"u\" value=\"4\"/>\n"
" <attr type=\"s\" value=\"ag\"/>\n"
" </qual>\n"
"</cclmap>\n";
-
+
doc = xmlParseMemory(xml_str, strlen(xml_str));
YAZ_CHECK(doc);
YAZ_CHECK(0);
return;
}
-
+
YAZ_CHECK(tst_ccl_query(bibset, "x1", "@attr 4=2 @attr 1=1016 x1 "));
YAZ_CHECK(tst_ccl_query(bibset, "k\xc3\xb8" "benhavn", "@attr 4=2 @attr 1=1016 k\xc3\xb8" "benhavn "));
YAZ_CHECK(tst_ccl_query(bibset, "x1 and", 0));
YAZ_CHECK(tst_ccl_query(bibset, "tix=x5", 0));
- YAZ_CHECK(tst_ccl_query(bibset, "a%b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a%b",
"@prox 0 1 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a%(b)",
+ YAZ_CHECK(tst_ccl_query(bibset, "a%(b)",
"@prox 0 1 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "(a)%(b)",
+ YAZ_CHECK(tst_ccl_query(bibset, "(a)%(b)",
"@prox 0 1 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a%1b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a%1b",
"@prox 0 1 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a%2b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a%2b",
"@prox 0 2 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "(a)%2(b)",
+ YAZ_CHECK(tst_ccl_query(bibset, "(a)%2(b)",
"@prox 0 2 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a%19b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a%19b",
"@prox 0 19 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "spid%æserne",
+ YAZ_CHECK(tst_ccl_query(bibset, "spid%æserne",
"@prox 0 1 0 2 k 2 "
"@attr 4=2 @attr 1=1016 spid "
"@attr 4=2 @attr 1=1016 æserne "));
- YAZ_CHECK(tst_ccl_query(bibset, "a!b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a!b",
"@prox 0 1 1 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a!2b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a!2b",
"@prox 0 2 1 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a% (b or dc.title=c)",
+ YAZ_CHECK(tst_ccl_query(bibset, "a% (b or dc.title=c)",
"@prox 0 1 0 2 k 2 "
"@attr 4=2 @attr 1=1016 a "
"@or @attr 4=2 @attr 1=1016 b "
"@attr 4=2 @attr 1=1016 @attr 1=/my/title c "));
- YAZ_CHECK(tst_ccl_query(bibset, "(a b) % (c)",
+ YAZ_CHECK(tst_ccl_query(bibset, "(a b) % (c)",
"@prox 0 1 0 2 k 2 @and "
"@attr 4=2 @attr 1=1016 a @attr 4=2 @attr 1=1016 b "
"@attr 4=2 @attr 1=1016 c " ));
YAZ_CHECK(tst_ccl_query(bibset, "a?",
"@attr 5=1 @attr 4=2 @attr 1=1016 a "));
- YAZ_CHECK(tst_ccl_query(bibset, "a b",
+ YAZ_CHECK(tst_ccl_query(bibset, "a b",
"@and @attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "a b?",
+ YAZ_CHECK(tst_ccl_query(bibset, "a b?",
"@and @attr 4=2 @attr 1=1016 a "
"@attr 5=1 @attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "title=a",
+ YAZ_CHECK(tst_ccl_query(bibset, "title=a",
"@attr 1=/my/title a "));
- YAZ_CHECK(tst_ccl_query(bibset, "reg=a?b#\"c?\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "reg=a?b#\"c?\"",
"@attr 5=102 a.*b.c\\\\? "));
- YAZ_CHECK(tst_ccl_query(bibset, "z=a?b#\"c?\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "z=a?b#\"c?\"",
"@attr 5=104 a?b#c\\\\? "));
- YAZ_CHECK(tst_ccl_query(bibset, "reg=\\(",
+ YAZ_CHECK(tst_ccl_query(bibset, "reg=\\(",
"@attr 5=102 \\\\( "));
- YAZ_CHECK(tst_ccl_query(bibset, "z=\\(",
+ YAZ_CHECK(tst_ccl_query(bibset, "z=\\(",
"( "));
- YAZ_CHECK(tst_ccl_query(bibset, "reg=\\\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "reg=\\\"",
"\"\\\"\" "));
- YAZ_CHECK(tst_ccl_query(bibset, "z=\\\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "z=\\\"",
"\"\\\"\" "));
YAZ_CHECK(tst_ccl_query(bibset, "reg=.",
YAZ_CHECK(tst_ccl_query(bibset, "z=.",
". "));
- YAZ_CHECK(tst_ccl_query(bibset, "reg=\".\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "reg=\".\"",
"@attr 5=102 \\\\. "));
- YAZ_CHECK(tst_ccl_query(bibset, "z=\".\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "z=\".\"",
". "));
YAZ_CHECK(tst_ccl_query(bibset, "reg=?\\?",
YAZ_CHECK(tst_ccl_query(bibset, "z=\\\\",
"@attr 5=104 \\\\\\\\ "));
- YAZ_CHECK(tst_ccl_query(bibset, "\\\\",
+ YAZ_CHECK(tst_ccl_query(bibset, "\\\\",
"@attr 4=2 @attr 1=1016 \\\\ "));
- YAZ_CHECK(tst_ccl_query(bibset, "comb=a",
+ YAZ_CHECK(tst_ccl_query(bibset, "comb=a",
"@or @attr 4=2 @attr 1=1016 a "
"@attr 1=/my/title a "));
- YAZ_CHECK(tst_ccl_query(bibset, "a? b?",
+ YAZ_CHECK(tst_ccl_query(bibset, "a? b?",
"@and @attr 5=1 @attr 4=2 @attr 1=1016 a "
"@attr 5=1 @attr 4=2 @attr 1=1016 b "));
- YAZ_CHECK(tst_ccl_query(bibset, "\"a\"? \"b?\"",
+ YAZ_CHECK(tst_ccl_query(bibset, "\"a\"? \"b?\"",
"@and @attr 5=1 @attr 4=2 @attr 1=1016 a "
"@attr 4=2 @attr 1=1016 b? "));
YAZ_CHECK(tst_ccl_query(bibset, "@and",
"@attr 4=2 @attr 1=1016 \\@and "));
-
+
YAZ_CHECK(tst_ccl_query(bibset, "a@and",
"@attr 4=2 @attr 1=1016 a@and "));
-
+
YAZ_CHECK(tst_ccl_query(bibset, "}",
"@attr 4=2 @attr 1=1016 } "));
-
+
YAZ_CHECK(tst_ccl_query(bibset, "{",
"@attr 4=2 @attr 1=1016 \"{\" "));
YAZ_CHECK(tst_ccl_query(bibset, "ag=\"a b c\"",
"@attr 4=1 \"a b c\" "));
-
+
YAZ_CHECK(tst_ccl_query(bibset, "ag=\"a b c\" \"d e\"",
"@and @attr 4=1 \"a b c\" @attr 4=1 \"d e\" "));
ccl_qual_rm(&bibset);
{
{
/* no content, no headers */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"GET / HTTP/1.1\r\n"
"\r\n"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 16), 0);
}
{
/* one header, no content */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"GET / HTTP/1.1\r\n"
"Content-Type: x\r\n"
"\r\n"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 34), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 35), 35);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 36), 35);
- }
+ }
{
/* one content-length header, length 0 */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"GET / HTTP/1.1\r\n"
"Content-Length: 0\r\n"
"\r\n"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 35), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 37), 37);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 38), 37);
- }
+ }
{
/* one content-length header, length 5 */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"GET / HTTP/1.1\r\n"
"Content-Length: 5\r\n"
"\r\n"
"ABCDE"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 41), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 42), 42);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 43), 42);
- }
+ }
{
/* LF only in GET, one content-length header, length 5 */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"GET / HTTP/1.1\n"
"Content-Length: 5\r\n"
"\r\n"
"ABCDE"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 40), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 41), 41);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 42), 41);
- }
+ }
{
/* LF only in all places, one content-length header, length 5 */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"GET / HTTP/1.1\n"
"Content-Length: 5\n"
"\n"
"ABCDE"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 38), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 39), 39);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 40), 39);
- }
+ }
{
/* one header, unknown transfer-encoding (no content) */
- const char *http_buf =
+ const char *http_buf =
/*12345678901234567890123456789 */
"GET / HTTP/1.1\r\n"
"Transfer-Encoding: chunke_\r\n"
"\r\n"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 45), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 46), 46);
- }
+ }
{
/* one header, one chunk */
- const char *http_buf =
+ const char *http_buf =
/*12345678901234567890123456789 */
"GET / HTTP/1.1\r\n"
"Transfer-Encoding: chunked\r\n"
"123\r\n"
"0\r\n\r\n"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 58), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 59), 59);
- }
+ }
{
/* one header, two chunks */
- const char *http_buf =
+ const char *http_buf =
/*12345678901234567890123456789 */
"GET / HTTP/1.1\r\n"
"Transfer-Encoding: chunked\r\n"
"12\n"
"0\r\n\r\n"
"GET / HTTP/1.0\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 64), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 65), 65);
- }
+ }
}
static void tst_http_response(void)
{
{
/* unlimited content, no headers */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"HTTP/1.1 200 OK\r\n"
"\r\n"
"HTTP/1.1 200 OK\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 24), 0);
}
{
/* response, content */
- const char *http_buf =
+ const char *http_buf =
/*123456789012345678 */
"HTTP/1.1 200 OK\r\n"
"Content-Length: 2\r\n"
"\r\n"
"12"
"HTTP/1.1 200 OK\r\n";
-
+
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0);
YAZ_CHECK_EQ(cs_complete_auto(http_buf, 39), 0);
/** \brief COMSTACK synopsis from manual, doc/comstack.xml */
static int comstack_example(const char *server_address_str)
-{
+{
COMSTACK stack;
char *buf = 0;
int size = 0, length_incoming;
perror("cs_create"); /* use perror() here since we have no stack yet */
return -1;
}
-
+
server_address_ip = cs_straddr(stack, server_address_str);
if (!server_address_ip)
{
fprintf(stderr, "cs_straddr: address could not be resolved\n");
return -1;
}
-
+
status = cs_connect(stack, server_address_ip);
if (status != 0) {
fprintf(stderr, "cs_connect: %s\n", cs_strerror(stack));
return -1;
}
-
+
status = cs_put(stack, protocol_package, protocol_package_length);
if (status) {
fprintf(stderr, "cs_put: %s\n", cs_strerror(stack));
return -1;
}
-
+
/* Now get a response */
-
+
length_incoming = cs_get(stack, &buf, &size);
if (!length_incoming) {
fprintf(stderr, "Connection closed\n");
fprintf(stderr, "cs_get: %s\n", cs_strerror(stack));
return -1;
}
-
+
/* Print result */
fwrite(buf, length_incoming, 1, stdout);
-
+
/* clean up */
cs_close(stack);
if (buf)
int ret = 1;
CQL_parser cp = cql_parser_create();
int r = cql_parser_string(cp, cql);
-
+
if (r)
{
yaz_log(YLOG_WARN, "cql: parse error: %s", cql);
yaz_log(YLOG_WARN, " got error");
}
wrbuf_rewind(w);
- r = cql_sortby_to_sortkeys(cql_parser_result(cp),
+ r = cql_sortby_to_sortkeys(cql_parser_result(cp),
wrbuf_vp_puts, w);
if (expected_keys && !r && !strcmp(wrbuf_cstr(w), expected_keys))
;
YAZ_CHECK(tst_query("dc.title=encyclopedia prox/distance<=3 dinosaurs",
"(dc.title=\"encyclopedia\") %3 (\"dinosaurs\")"));
YAZ_CHECK(tst_query("dc.title=encyclopedia prox/distance<=3/unit=word "
- "dinosaurs",
+ "dinosaurs",
"(dc.title=\"encyclopedia\") %3 (\"dinosaurs\")"));
YAZ_CHECK(tst_query("dc.title=encyclopedia prox/distance<=3/unit=phrase "
"dinosaurs", 0));
void test2(void)
{
- char base_enc[] =
+ char base_enc[] =
"MDA3NjZuYW0gIDIyMDAyNjU4YSA0NTAwMDAxMDAxMjAwMDAwMDAzMDAwNjAwMDEyMDA1MDAx"
"NzAwMDE4MDA4MDA0MTAwMDM1MDEwMDAxNzAwMDc2MDIwMDAxNTAwMDkzMDM1MDAxODAwMTA4"
"MDQwMDAxODAwMTI2MDQ5MDAwOTAwMTQ0MDUwMDAyNjAwMTUzMDgyMDAxNzAwMTc5MTAwMDAx"
"bmQgaW5kZXguHiAwH2FDT01NT04gTElTUCAoQ29tcHV0ZXIgcHJvZ3JhbSBsYW5ndWFnZSke"
"H2xVQUhJTEweHQ==";
- char bin_marc[] =
+ char bin_marc[] =
"00766nam 22002658a 4500001001200000003000600012005001700018008004100035010001700076020001500093035001800108040001800126049000900144050002600153082001700179100001800196245006700214260005200281263000900333300002700342500002700369504005100396650004400447999000900491\036ocm28339863\036OCoLC\03619940105074522.0\036930609s1994 cou b 001 0 eng \036 \037a 93009047 \036 \037a0130305529\036 \037a(ocm)28339863\036 \037aDLC\037cDLC\037dKKU\036 \037aKKUJ\03600\037aQA76.73.C28\037bG73 1994\03600\037a005.13/3\037220\0361 \037aGraham, Paul.\03610\037aOn Lisp :\037badvanced techniques for common Lisp /\037cPaul Graham.\036 \037aEnglewood Cliffs, N.J. :\037bPrentice Hall,\037c1994.\036 \037a9410\036 \037axiii, 413 p. ;\037c23 cm.\036 \037a\"An Alan R. Apt book.\"\036 \037aIncludes bibliographical references and index.\036 0\037aCOMMON LISP (Computer program language)\036\037lUAHILL\036\035";
int marc_size = strlen(bin_marc);
YAZ_CHECK(test_render("xml", 0, "<my/>", "<my/>"));
YAZ_CHECK(test_render(
- "xml", 1,
+ "xml", 1,
"\x30\x30\x31\x33\x38\x6E\x61\x6D\x20\x20\x32\x32\x30\x30\x30\x37"
"\x33\x38\x61\x20\x34\x35\x30\x30\x30\x30\x31\x30\x30\x31\x33\x30"
"\x30\x30\x30\x30\x30\x30\x33\x30\x30\x30\x34\x30\x30\x30\x31\x33"
int ret;
WRBUF tpath = wrbuf_alloc();
const char *srcdir = getenv("srcdir");
-
+
if (srcdir)
{
wrbuf_puts(tpath, srcdir);
if (expect_len == got_len
&& !memcmp(expect_buf, got_buf, expect_len))
return 1;
-
+
if (0) /* use 1 see how the buffers differ (for debug purposes) */
{
int i;
{
char got_char[10];
char expect_char[10];
-
+
if (i < got_len)
sprintf(got_char, "%02X", got_buf[i]);
else
sprintf(got_char, "? ");
-
+
if (i < expect_len)
sprintf(expect_char, "%02X", expect_buf[i]);
else
sprintf(expect_char, "? ");
-
+
printf("%02d %s %s %c\n",
i, got_char, expect_char, got_buf[i] == expect_buf[i] ?
' ' : '*');
-
+
}
}
return 0;
break;
}
}
- if (wrbuf_len(b) == strlen(cmpbuf)
+ if (wrbuf_len(b) == strlen(cmpbuf)
&& !memcmp(cmpbuf, wrbuf_buf(b), wrbuf_len(b)))
;
else
wrbuf_rewind(w);
wrbuf_write_escaped(w, wrbuf_buf(b), wrbuf_len(b));
yaz_log(YLOG_LOG, "got %s", wrbuf_cstr(w));
-
+
wrbuf_rewind(w);
wrbuf_puts_escaped(w, cmpbuf);
yaz_log(YLOG_LOG, "exp %s", wrbuf_cstr(w));
YAZ_CHECK(cd);
if (!cd)
return;
-
+
YAZ_CHECK(tst_convert_l(
cd,
0,
"\033$1" "\x21\x2B\x3B" /* FF1F */ "\033(B" "o",
- 8,
+ 8,
"\x00\x00\xFF\x1F" "\x00\x00\x00o"));
YAZ_CHECK(tst_convert_l(
cd,
"\x21\x33\x53" /* UCS 5206 */
"\x21\x44\x2B" /* UCS 6790 */
"\033(B",
- 24,
+ 24,
"\x00\x00\x7C\xFB"
"\x00\x00\x7D\x71"
"\x00\x00\x5B\x89"
cd,
0,
"\xB0\xB2", /* AYN and oSLASH */
- 8,
+ 8,
"\x00\x00\x02\xBB" "\x00\x00\x00\xF8"));
YAZ_CHECK(tst_convert_l(
cd,
0,
"\xF6\x61", /* a underscore */
- 8,
+ 8,
"\x00\x00\x00\x61" "\x00\x00\x03\x32"));
YAZ_CHECK(tst_convert_l(
cd,
0,
"\xe5\xe8\x41",
- 12,
+ 12,
"\x00\x00\x00\x41" "\x00\x00\x03\x04" "\x00\x00\x03\x08"));
/* bug #416 */
YAZ_CHECK(tst_convert_l(
cd,
0,
"\xFA\x74\xFB\x73",
- 12,
+ 12,
"\x00\x00\x00\x74" "\x00\x00\x03\x60" "\x00\x00\x00\x73"));
yaz_iconv_close(cd);
YAZ_CHECK(tst_convert_l(
cd,
- 8,
+ 8,
"\x00\x00\xAE\x0E\x00\x00\xC0\xF4",
6,
"\xEA\xB8\x8E\xEC\x83\xB4"));
yaz_iconv_close(cd);
if (r == (size_t) (-1))
return;
-
+
cd = yaz_iconv_open("ISO-8859-1", tmpcode);
YAZ_CHECK(cd || !mandatory);
if (!cd)
}
YAZ_CHECK(r != (size_t) (-1));
- if (r != (size_t)(-1))
+ if (r != (size_t)(-1))
{
ret = compare_buffers("dconvert", i,
strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
return 0;
for (i = 0; i<4; i++)
src[i] = c >> (i*8);
-
+
r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
yaz_iconv_close(cd);
}
return 1;
}
-
+
static void tst_marc8_to_utf8(void)
{
yaz_iconv_t cd = yaz_iconv_open("UTF-8", "MARC8");
if (!cd)
return;
- YAZ_CHECK(tst_convert(cd, "Cours de math",
+ YAZ_CHECK(tst_convert(cd, "Cours de math",
"Cours de math"));
/* COMBINING ACUTE ACCENT */
- YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
"Cours de mathe\xcc\x81"));
YAZ_CHECK(tst_convert(cd, "\xea" "a", "a\xcc\x8a"));
if (!cd)
return;
- YAZ_CHECK(tst_convert(cd, "Cours de math",
+ YAZ_CHECK(tst_convert(cd, "Cours de math",
"Cours de math"));
/* E9: LATIN SMALL LETTER E WITH ACUTE */
- YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
"Cours de math\xc3\xa9"));
yaz_iconv_close(cd);
YAZ_CHECK(tst_convert(cd, "\xea" "a" "\xea" "a", "\xe5" "\xe5"));
- YAZ_CHECK(tst_convert(cd, "Cours de math",
+ YAZ_CHECK(tst_convert(cd, "Cours de math",
"Cours de math"));
- YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
"Cours de mathé"));
- YAZ_CHECK(tst_convert(cd, "12345678âe",
+ YAZ_CHECK(tst_convert(cd, "12345678âe",
"12345678é"));
- YAZ_CHECK(tst_convert(cd, "123456789âe",
+ YAZ_CHECK(tst_convert(cd, "123456789âe",
"123456789é"));
- YAZ_CHECK(tst_convert(cd, "1234567890âe",
+ YAZ_CHECK(tst_convert(cd, "1234567890âe",
"1234567890é"));
- YAZ_CHECK(tst_convert(cd, "12345678901âe",
+ YAZ_CHECK(tst_convert(cd, "12345678901âe",
"12345678901é"));
- YAZ_CHECK(tst_convert(cd, "Cours de mathâem",
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâem",
"Cours de mathém"));
- YAZ_CHECK(tst_convert(cd, "Cours de mathâematiques",
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâematiques",
"Cours de mathématiques"));
yaz_iconv_close(cd);
/** A MACRON + UMLAUT, DIAERESIS */
YAZ_CHECK(tst_convert(cd, "A" "\xCC\x84" "\xCC\x88",
"\xE5\xE8\x41"));
-
+
/* Ligature spanning two characters */
YAZ_CHECK(tst_convert(cd,
"\x74" "\xCD\xA1" "\x73", /* UTF-8 */
YAZ_CHECK(tst_convert(cd,
"(\xe2\x81\xb0)", /* UTF-8 */
"(\033p0\x1bs)"));
-
-
+
+
/** bug #1778 */
YAZ_CHECK(tst_convert(cd,
/* offset 0x530 in UTF-8 rec marccol4.u8.marc */
- "\xE3\x83\xB3" "\xE3\x82\xBF"
+ "\xE3\x83\xB3" "\xE3\x82\xBF"
"\xCC\x84" "\xCC\x84" "\xE3\x83\xBC" /* UTF-8 */,
"\x1B\x24\x31" "\x69\x25\x73"
- "\x1B\x28\x42" "\xE5\xE5" "\x1B\x24\x31"
+ "\x1B\x28\x42" "\xE5\xE5" "\x1B\x24\x31"
"\x69\x25\x3F"
"\x69\x21\x3C" "\x1B\x28\x42"));
-
+
/** bug #2120 */
- YAZ_CHECK(tst_convert(cd,
+ YAZ_CHECK(tst_convert(cd,
"\xCE\x94\xCE\xB5\xCF\x84"
"\xCE\xBF\xCF\x81\xCE\xB1"
"\xCE\xBA\xCE\xB7\xCF\x82\x2C",
"\x61\x6D\x6A\x77"
"\x1B\x28\x42\x2C"
));
-
+
{
char *inbuf0 = "\xe2\x81\xb0";
char *inbuf = inbuf0;
YAZ_CHECK(tst_convert(cd, "@\xe5", "aa"));
YAZ_CHECK(tst_convert(cd, "@\xc5.", "Aa."));
-
+
yaz_iconv_close(cd);
}
*/
/* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
-
+
#if HAVE_CONFIG_H
#include "config.h"
struct icu_termmap *itmp2 = *(struct icu_termmap **) vp2;
int cmp = 0;
-
- cmp = strcmp((const char *)itmp1->sort_key,
+
+ cmp = strcmp((const char *)itmp1->sort_key,
(const char *)itmp2->sort_key);
return cmp;
}
/* perform case mapping */
icu_utf16_casemap(dest16, src16, locale, action, &status);
-
+
/* converting to UTF8 */
icu_utf16_to_utf8(dest8, dest16, &status);
/* determine success */
- if (dest8->utf8
+ if (dest8->utf8
&& (dest8->utf8_len == strlen(chk8cstr))
&& !strcmp(chk8cstr, (const char *) dest8->utf8))
success = 1;
yaz_log(YLOG_WARN, "test_icu_casemap failed");
yaz_log(YLOG_LOG, "Original string: '%s' (%d)",
src8cstr, src8cstr_len);
- yaz_log(YLOG_LOG, "icu_casemap '%s:%c' '%s' (%d)",
+ yaz_log(YLOG_LOG, "icu_casemap '%s:%c' '%s' (%d)",
locale, action, dest8->utf8, dest8->utf8_len);
yaz_log(YLOG_LOG, "expected string: '%s' (%d)",
chk8cstr, chk8cstr_len);
}
-
+
/* clean the buffers */
icu_buf_utf8_destroy(src8);
icu_buf_utf8_destroy(dest8);
icu_buf_utf16_destroy(src16);
icu_buf_utf16_destroy(dest16);
-
+
return success;
}
/* successful tests */
YAZ_CHECK(test_icu_casemap("en", 'l',
- "A ReD fOx hunTS sQUirriLs",
+ "A ReD fOx hunTS sQUirriLs",
"a red fox hunts squirrils"));
-
+
YAZ_CHECK(test_icu_casemap("en", 'u',
- "A ReD fOx hunTS sQUirriLs",
+ "A ReD fOx hunTS sQUirriLs",
"A RED FOX HUNTS SQUIRRILS"));
-
+
YAZ_CHECK(test_icu_casemap("en", 'f',
- "A ReD fOx hunTS sQUirriLs",
+ "A ReD fOx hunTS sQUirriLs",
"a red fox hunts squirrils"));
-
+
YAZ_CHECK(test_icu_casemap("en", 't',
- "A ReD fOx hunTS sQUirriLs",
+ "A ReD fOx hunTS sQUirriLs",
"A Red Fox Hunts Squirrils"));
-
+
/* Locale 'da' */
/* success expected */
YAZ_CHECK(test_icu_casemap("da", 'l',
- "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
+ "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
"åh æble, øs fløde i åen efter blåbærgrøden"));
YAZ_CHECK(test_icu_casemap("da", 'u',
- "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
+ "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
"ÅH ÆBLE, ØS FLØDE I ÅEN EFTER BLÅBÆRGRØDEN"));
YAZ_CHECK(test_icu_casemap("da", 'f',
- "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
+ "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
"åh æble, øs fløde i åen efter blåbærgrøden"));
YAZ_CHECK(test_icu_casemap("da", 't',
- "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
+ "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN",
"Åh Æble, Øs Fløde I Åen Efter Blåbærgrøden"));
/* Locale 'de' */
struct icu_termmap * list[src_list_len];
- UCollator *coll = ucol_open(locale, &status);
+ UCollator *coll = ucol_open(locale, &status);
icu_check_status(status);
if (U_FAILURE(status))
return 0;
/* assigning display terms and sort keys using buf 8 and buf16 */
- for (i = 0; i < src_list_len; i++)
+ for (i = 0; i < src_list_len; i++)
{
list[i] = (struct icu_termmap *) malloc(sizeof(struct icu_termmap));
/* copy display term */
- strcpy(list[i]->disp_term, src_list[i]);
+ strcpy(list[i]->disp_term, src_list[i]);
/* transforming to UTF16 */
icu_utf16_from_utf8_cstr(buf16, list[i]->disp_term, &status);
/* computing sortkeys */
icu_sortkey8_from_utf16(coll, buf8, buf16, &status);
icu_check_status(status);
-
+
/* assigning sortkeys */
- memcpy(list[i]->sort_key, buf8->utf8, buf8->utf8_len);
- }
+ memcpy(list[i]->sort_key, buf8->utf8, buf8->utf8_len);
+ }
/* do the sorting */
qsort(list, src_list_len, sizeof(struct icu_termmap *), icu_termmap_cmp);
if (!success)
{
- yaz_log(YLOG_LOG, "ERROR");
- yaz_log(YLOG_LOG, "Input str:'%s':", locale);
+ yaz_log(YLOG_LOG, "ERROR");
+ yaz_log(YLOG_LOG, "Input str:'%s':", locale);
for (i = 0; i < src_list_len; i++) {
- yaz_log(YLOG_LOG, " '%s'", list[i]->disp_term);
+ yaz_log(YLOG_LOG, " '%s'", list[i]->disp_term);
}
- yaz_log(YLOG_LOG, "ICU sort: '%s':", locale);
+ yaz_log(YLOG_LOG, "ICU sort: '%s':", locale);
for (i = 0; i < src_list_len; i++) {
- yaz_log(YLOG_LOG, " '%s'", list[i]->disp_term);
+ yaz_log(YLOG_LOG, " '%s'", list[i]->disp_term);
}
- yaz_log(YLOG_LOG, "Expected: '%s':", locale);
+ yaz_log(YLOG_LOG, "Expected: '%s':", locale);
for (i = 0; i < src_list_len; i++) {
- yaz_log(YLOG_LOG, " '%s'", chk_list[i]);
+ yaz_log(YLOG_LOG, " '%s'", chk_list[i]);
}
}
-
+
for (i = 0; i < src_list_len; i++)
free(list[i]);
-
+
ucol_close(coll);
icu_buf_utf8_destroy(buf8);
icu_buf_utf16_destroy(buf16);
- return success;
+ return success;
}
static void check_icu_sortmap(void)
YAZ_CHECK(test_icu_sortmap("en_CA", en_1_len, en_1_src, en_1_cck));
YAZ_CHECK(test_icu_sortmap("en_GB", en_1_len, en_1_src, en_1_cck));
YAZ_CHECK(test_icu_sortmap("en_US", en_1_len, en_1_src, en_1_cck));
-
+
/* successful tests */
{
size_t da_1_len = 6;
const char * chk8cstr)
{
int success = 0;
-
+
UErrorCode status = U_ZERO_ERROR;
struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0);
struct icu_transform * transform
= icu_transform_create(rules8cstr, 'f', 0, &status);
icu_check_status(status);
-
+
icu_utf16_from_utf8_cstr(src16, src8cstr, &status);
icu_check_status(status);
icu_check_status(status);
- if (!strcmp((const char *) dest8->utf8,
+ if (!strcmp((const char *) dest8->utf8,
(const char *) chk8cstr))
success = 1;
else
YAZ_CHECK(test_icu_normalizer("[:Punctuation:] Any-Remove",
"Don't shoot!",
"Dont shoot"));
-
+
YAZ_CHECK(test_icu_normalizer("[:Control:] Any-Remove",
"Don't\n shoot!",
"Don't shoot!"));
YAZ_CHECK(test_icu_normalizer("Lower; [:^Letter:] Remove",
"Don't shoot!",
"dontshoot"));
-
+
YAZ_CHECK(test_icu_normalizer("[:^Number:] Remove",
"Monday 15th of April",
"15"));
YAZ_CHECK(tokenizer);
/* attach text buffer to tokenizer */
- icu_tokenizer_attach(tokenizer, src16, &status);
+ icu_tokenizer_attach(tokenizer, src16, &status);
icu_check_status(status);
/* perform work on tokens */
icu_buf_utf16_destroy(src16);
icu_buf_utf16_destroy(tkn16);
icu_buf_utf8_destroy(tkn8);
-
+
return success;
}
static void check_icu_tokenizer(void)
{
- const char * en_str
+ const char * en_str
= "O Romeo, Romeo! wherefore art thou Romeo?";
-
+
YAZ_CHECK(test_icu_tokenizer("en", 's', en_str, 2));
YAZ_CHECK(test_icu_tokenizer("en", 'l', en_str, 7));
YAZ_CHECK(test_icu_tokenizer("en", 'w', en_str, 16));
YAZ_CHECK(test_icu_tokenizer("en", 'c', en_str, 41));
{
- const char * da_str
+ const char * da_str
= "Blåbærtærte. Denne kage stammer fra Finland. "
"Den er med blåbær, men alle sommerens forskellige bær kan bruges.";
-
+
YAZ_CHECK(test_icu_tokenizer("da", 's', da_str, 3));
YAZ_CHECK(test_icu_tokenizer("dar", 'l', da_str, 17));
YAZ_CHECK(test_icu_tokenizer("da", 'w', da_str, 37));
static void check_icu_chain(void)
{
- const char * en_str
+ const char * en_str
= "O Romeo, Romeo! wherefore art thou\t Romeo?";
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
-
+
const char * xml_str = "<icu locale=\"en\">"
"<transform rule=\"[:Control:] Any-Remove\"/>"
"<tokenize rule=\"l\"/>"
"<casemap rule=\"l\"/>"
"</icu>";
-
+
xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
{
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
-
+
const char * xml_str = "<icu locale=\"en\">"
/* if the first rule is normalize instead. Then it works */
"<casemap rule=\"l\"/>"
"</icu>";
-
+
xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
YAZ_CHECK(chain);
if (!chain)
return;
-
+
YAZ_CHECK(icu_chain_assign_cstr(
chain, "O Romeo, Romeo! wherefore art thou\t Romeo?",
&status));
icu_chain_token_norm(chain),
icu_chain_token_display(chain)); */
}
-
+
YAZ_CHECK_EQ(icu_chain_token_number(chain), 7);
"<tokenize rule=\"w\"/>"
"<transform rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
"</icu>";
-
+
xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
-
+
YAZ_CHECK(icu_chain_assign_cstr(
chain, "a string with 15 tokenss and 8 displays",
&status));
const char * xml_str = "<icu locale=\"en\">"
"</icu>";
-
+
const char * src8 = "some 5487 weired !¤%&(/& sTuFf";
char * dest8 = 0;
xmlFreeDoc(doc);
YAZ_CHECK(chain);
-
+
YAZ_CHECK(icu_chain_assign_cstr(
chain, src8,
&status));
dest8 = (char *) icu_chain_token_norm(chain);
YAZ_CHECK_EQ(strcmp(src8, dest8), 0);
-
+
icu_chain_destroy(chain);
}
"<tokenize rule=\"w\"/>"
"<transform rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
"</icu>";
-
+
xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
YAZ_CHECK(doc);
if (!doc)
xmlFreeDoc(doc);
YAZ_CHECK(chain);
-
+
iter = icu_iter_create(chain);
icu_iter_first(iter, "a string with 15 tokens and 8 displays");
YAZ_CHECK(iter);
{
struct icu_chain *chain = (struct icu_chain *) p;
int i;
-
+
for (i = 0; i < 1000; i++)
{
YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
YAZ_CHECK(chain);
if (!chain)
return;
-
+
YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
"[adobe][acrobat][reader][1991][][1999][]"));
struct icu_chain * chain = 0;
xmlNode *xml_node;
- const char * xml_str =
+ const char * xml_str =
"<icu_chain id=\"sort\" locale=\"el\">\n"
"<transform rule=\"[:Control:] Any-Remove\"/>\n"
"<transform rule=\"[[:Control:][:WhiteSpace:][:Punctuation:]] Remove\"/>\n"
YAZ_CHECK(chain);
if (!chain)
return;
-
+
YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
"[adobeacrobatreader19911999]"));
int main(int argc, char **argv)
{
- YAZ_CHECK_INIT(argc, argv);
+ YAZ_CHECK_INIT(argc, argv);
YAZ_CHECK_LOG();
#if YAZ_HAVE_ICU
check_icu_chain();
check_chain_empty_token();
check_chain_empty_chain();
- check_icu_iter1();
+ check_icu_iter1();
check_icu_iter2();
check_icu_iter3();
-
+
check_bug_1140();
u_cleanup();
YAZ_CHECK(0 == 0);
#endif /* YAZ_HAVE_ICU */
-
+
YAZ_CHECK_TERM;
}
* See the file LICENSE for details.
*/
/**
- * \file
+ * \file
* \brief JSON test
*/
#if HAVE_CONFIG_H
#include <string.h>
#include <yaz/log.h>
-static int expect(json_parser_t p, const char *input,
+static int expect(json_parser_t p, const char *input,
const char *output)
{
int ret = 0;
YAZ_CHECK(expect(p, "{} extra", 0));
YAZ_CHECK(expect(p, "{\"a\":[1,2,3}", 0));
-
+
YAZ_CHECK(expect(p, "{\"a\":[1,2,", 0));
YAZ_CHECK(expect(p, "{\"k\":\"wa\"}", "{\"k\":\"wa\"}"));
return;
YAZ_CHECK_EQ(json_count_children(n), 3);
-
+
n1 = json_get_object(n, "a");
YAZ_CHECK(n1 && n1->type == json_node_number && n1->u.number == 1.0);
YAZ_CHECK_EQ(json_count_children(n1), 0);
#if YAZ_HAVE_ICU
#include <yaz/stemmer.h>
-int test_stemmer_stem(yaz_stemmer_p stemmer, const char* to_stem, const char *expected)
+int test_stemmer_stem(yaz_stemmer_p stemmer, const char* to_stem, const char *expected)
{
struct icu_buf_utf16 *src = icu_buf_utf16_create(0);
struct icu_buf_utf16 *dst = icu_buf_utf16_create(0);
struct icu_buf_utf8 *dst8 = icu_buf_utf8_create(0);
int rc = 0;
- UErrorCode status;
+ UErrorCode status;
const char *result;
icu_utf16_from_utf8_cstr(src, to_stem, &status);
- yaz_stemmer_stem(stemmer, dst, src, &status);
+ yaz_stemmer_stem(stemmer, dst, src, &status);
if (status == U_ZERO_ERROR) {
icu_utf16_to_utf8(dst8, dst, &status);
result = icu_buf_utf8_to_cstr(dst8);
static void tst(void)
{
UErrorCode status;
- //== U_ZERO_ERROR;
+ //== U_ZERO_ERROR;
yaz_stemmer_p stemmer = yaz_stemmer_create("en", "porter", &status);
- YAZ_CHECK(stemmer);
+ YAZ_CHECK(stemmer);
/* fail */
- YAZ_CHECK(test_stemmer_stem(stemmer, "beer", "water") == 0 );
+ YAZ_CHECK(test_stemmer_stem(stemmer, "beer", "water") == 0 );
/* Same */
- YAZ_CHECK(test_stemmer_stem(stemmer, "adadwwr", "adadwwr"));
+ YAZ_CHECK(test_stemmer_stem(stemmer, "adadwwr", "adadwwr"));
/* Remove S */
- YAZ_CHECK(test_stemmer_stem(stemmer, "beers", "beer"));
- YAZ_CHECK(test_stemmer_stem(stemmer, "persons", "person"));
+ YAZ_CHECK(test_stemmer_stem(stemmer, "beers", "beer"));
+ YAZ_CHECK(test_stemmer_stem(stemmer, "persons", "person"));
/* Remove s and ing */
- YAZ_CHECK(test_stemmer_stem(stemmer, "runs", "run"));
- YAZ_CHECK(test_stemmer_stem(stemmer, "running", "run"));
+ YAZ_CHECK(test_stemmer_stem(stemmer, "runs", "run"));
+ YAZ_CHECK(test_stemmer_stem(stemmer, "running", "run"));
yaz_stemmer_destroy(stemmer);
}
case 'n':
number = atoi(arg);
break;
- case 'm':
+ case 'm':
level = yaz_log_module_level(arg);
break;
case 'w':
static void t_test(void)
{
pthread_t tids[4];
-
+
pthread_create(tids+0, 0, t_loop2, 0);
pthread_create(tids+1, 0, t_loop2, 0);
pthread_create(tids+2, 0, t_loop2, 0);
pthread_create(tids+3, 0, t_loop2, 0);
-
+
pthread_join(tids[0], 0);
pthread_join(tids[1], 0);
pthread_join(tids[2], 0);
{
r = yaz_gettimeofday(&abstime);
YAZ_CHECK_EQ(r, 0);
-
+
abstime.tv_sec += 1; /* wait 1 second */
-
+
r = yaz_cond_wait(c, p, &abstime);
YAZ_CHECK(r != 0);
YAZ_CHECK(t[0]);
t[1] = yaz_thread_create(my_handler, &mydata);
YAZ_CHECK(t[1]);
-
+
return_data = 0;
yaz_thread_join(&t[0], &return_data);
YAZ_CHECK(!t[0]);
yaz_thread_join(&t[1], &return_data);
YAZ_CHECK(!t[1]);
YAZ_CHECK(return_data == &mydata);
-
+
YAZ_CHECK_EQ(mydata, 44);
}
if ((int) sizeof(double) >= j)
*(double*) cp = 12.2;
}
-
+
for (j = 2000; j<20000; j+= 2000)
{
cp = (char *) nmem_malloc(n, j);
nmem_strsplitx(nmem, ",", "", &array, &num, 0);
YAZ_CHECK(num == 1);
YAZ_CHECK(num > 0 && !strcmp(array[0], ""));
-
+
nmem_strsplit(nmem, ",", ",,", &array, &num);
YAZ_CHECK(num == 0);
YAZ_CHECK(num > 0 && !strcmp(array[0], ""));
YAZ_CHECK(num > 1 && !strcmp(array[1], ""));
YAZ_CHECK(num > 2 && !strcmp(array[2], ""));
-
+
nmem_strsplit(nmem, ",", ",a,b,,cd", &array, &num);
YAZ_CHECK(num == 3);
YAZ_CHECK(num > 0 && !strcmp(array[0], "a"));
s->third = odr_booldup(encode, 1);
s->fourth = odr_nullval();
s->fifth = odr_intdup(encode, YC_MySequence_enum1);
-
+
s->myoid = odr_getoidbystr(decode, MYOID);
ret = yc_MySequence(encode, &s, 0, 0);
YAZ_CHECK(ret);
if (!ret)
return;
-
+
ber_buf = odr_getbuf(encode, &ber_len, 0);
odr_setbuf(decode, ber_buf, ber_len, 0);
Odr_int val;
Odr_int ret_val;
int r;
-
+
val = 0;
odr_reset(encode);
r = ber_integer(encode, &val);
Odr_int val;
Odr_int ret_val;
int r;
-
+
val = (Odr_int) 2 * 2147483648UL; /* 2^32 */
odr_reset(encode);
r = ber_integer(encode, &val);
Odr_int *valp, *resvalp;
char *bufferp;
int len;
-
+
/* allocate streams */
if (!(encode = odr_createmem(ODR_ENCODE)))
return;
int argc = sizeof(argv) / sizeof(*argv);
char *arg = 0;
const char *desc = "a{longa}b{longb}cdn:m{marmelade}:";
-
+
YAZ_CHECK_EQ(options(desc, argv, argc, &arg), 'a');
YAZ_CHECK_EQ(options(desc, argv, argc, &arg), 'b');
YAZ_CHECK_EQ(options(desc, argv, argc, &arg), 0);
else if (expect_error == YAZ_PQF_ERROR_NONE)
{
WRBUF wrbuf = wrbuf_alloc();
-
+
if (wrbuf)
{
yaz_rpnquery_to_wrbuf(wrbuf, rpn);
-
+
if (!strcmp(wrbuf_cstr(wrbuf), expect_pqf))
{
res = 1;
CONV_FAILED
};
-enum query_charset_status t(yaz_iconv_t cd,
+enum query_charset_status t(yaz_iconv_t cd,
const char *pqf, const char *expect_pqf)
{
YAZ_PQF_Parser parser = yaz_pqf_create();
int r = yaz_record_conv_configure(p, ptr);
-
+
if (r)
{
wrbuf_puts(w, yaz_record_conv_get_error(p));
}
xmlFreeDoc(doc);
return p;
- }
+ }
}
int conv_configure_test(const char *xmlstring, const char *expect_error,
"</backend>",
"xslt unsupported."
" YAZ compiled without XSLT support", 0));
-#endif
+#endif
}
static int conv_convert_test(yaz_record_conv_t p,
else if (strcmp(output_expect_record, wrbuf_cstr(output_record)))
{
ret = 0;
- printf("got-output_record len=%ld: %s\n",
+ printf("got-output_record len=%ld: %s\n",
(long) wrbuf_len(output_record),
wrbuf_cstr(output_record));
printf("output_expect_record len=%ld %s\n",
#if YAZ_HAVE_XML2
tst_configure();
#endif
-#if YAZ_HAVE_XSLT
+#if YAZ_HAVE_XSLT
tst_convert1();
tst_convert2();
#endif
else
{
int r = yaz_retrieval_configure(p, ptr);
-
+
if (r)
{
wrbuf_puts(w, yaz_retrieval_get_error(p));
}
xmlFreeDoc(doc);
return p;
- }
+ }
}
int conv_configure_test(const char *xmlstring, const char *expect_error,
static void tst_configure(void)
{
- YAZ_CHECK(conv_configure_test("<bad",
+ YAZ_CHECK(conv_configure_test("<bad",
"xmlParseMemory", 0));
- YAZ_CHECK(conv_configure_test("<bad/>",
+ YAZ_CHECK(conv_configure_test("<bad/>",
"Expected element <retrievalinfo>", 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo/>", 0, 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" unknown=\"unknown\""
">"
"</retrieval>"
"'unknown'", 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"unknown_synt\""
">"
"</retrieval>"
"value syntax='unknown_synt'", 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
"/>"
"</retrievalinfo>",
0, 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
" name=\"marcxml\"/>"
"</retrievalinfo>",
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
- " name=\"marcxml\""
+ " name=\"marcxml\""
" identifier=\"info:srw/schema/1/marcxml-v1.1\""
"/>"
"</retrievalinfo>",
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
" identifier=\"info:srw/schema/1/marcxml-v1.1\""
" name=\"marcxml\">"
"<convert/>"
- "</retrieval>"
+ "</retrieval>"
"</retrievalinfo>",
"Element <retrieval>: expected zero or one element "
"<backend>, got <convert>", 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
" identifier=\"info:srw/schema/1/marcxml-v1.1\""
" name=\"marcxml\">"
" got 'schema'", 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
" identifier=\"info:srw/schema/1/marcxml-v1.1\""
" name=\"marcxml\">"
0, 0));
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
" identifier=\"info:srw/schema/1/marcxml-v1.1\""
" name=\"marcxml\">"
YAZ_CHECK(conv_configure_test("<retrievalinfo>"
- "<retrieval"
+ "<retrieval"
" syntax=\"usmarc\""
" identifier=\"info:srw/schema/1/marcxml-v1.1\""
" name=\"marcxml\">"
ODR odr = odr_createmem(ODR_ENCODE);
WRBUF w = wrbuf_alloc();
Z_RPNQuery *q = p_query_rpn(odr, pqf);
-
+
if (q)
{
int r = cql_transform_rpn2cql_wrbuf(ct, w, q);
static void tst1(void)
{
- cql_transform_t ct = cql_transform_create();
+ cql_transform_t ct = cql_transform_create();
YAZ_CHECK(compare(ct, "abc", "\"abc\""));
YAZ_CHECK(compare(ct, "\"a b c\"", "\"a b c\""));
wrbuf_puts(w, "/");
}
wrbuf_puts(w, "../etc/pqf.properties");
-
+
ct = cql_transform_open_fname(wrbuf_cstr(w));
YAZ_CHECK(compare(ct, "@attr 1=4 abc", "dc.title=\"abc\""));
YAZ_CHECK(compare(ct, "@attr 1=4 @attr 4=108 abc", "dc.title=/exact \"abc\""));
wrbuf_puts(w, "/");
}
wrbuf_puts(w, "../etc/pqf.properties");
-
+
ct = solr_transform_open_fname(wrbuf_cstr(w));
YAZ_CHECK(compare(ct, "@attr 1=4 abc", "dc.title:abc"));
#if 0
WRBUF w = wrbuf_alloc();
WRBUF_shptr_t t = 0;
-
+
YAZ_SHPTR_INIT(t, w);
YAZ_CHECK(t);
top = xmlNewNode(0, BAD_CAST "top");
YAZ_CHECK(top);
-
+
xmlNewTextChild(top, 0, BAD_CAST "sub", BAD_CAST val);
xmlDocSetRootElement(doc, top);
-
+
xmlDocDumpMemory(doc, &buf_out, &len_out);
#if 0
printf("%*s", len_out, buf_out);
YAZ_CHECK(sr);
YAZ_CHECK(p);
#if 0
- sr->u.request->query.cql = "jordb" "\xe6" "r";
+ sr->u.request->query.cql = "jordb" "\xe6" "r";
#else
- sr->u.request->query.cql = "jordbaer";
+ sr->u.request->query.cql = "jordbaer";
#endif
p->which = Z_SOAP_generic;
{
YAZ_CHECK(names[0] && !strcmp(names[0], "a"));
YAZ_CHECK(values[0] && !strcmp(values[0], "AA"));
-
+
YAZ_CHECK(names[1] && !strcmp(names[1], "bb"));
YAZ_CHECK(values[1] && !strcmp(values[1], "BB"));
YAZ_CHECK(values[1] && !strcmp(values[1], ""));
YAZ_CHECK(names[2] && !strcmp(names[2], "x"));
- YAZ_CHECK(values[2] && !strcmp(values[2], ""));
+ YAZ_CHECK(values[2] && !strcmp(values[2], ""));
YAZ_CHECK(names[3] == 0);
YAZ_CHECK(values[3] == 0);
{
int len = 0;
char *buf = odr_getbuf(odr, &len, 0);
-
+
if (buf)
{
if (len == strlen(expect) && !memcmp(buf, expect, len))
{
Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request,
"1.2");
-
+
YAZ_CHECK(compare_solr_req(
odr, sr, 0,
"GET Default/select? HTTP/1.1\r\n"
{
Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request,
"1.2");
-
+
sr->u.request->query_type = Z_SRW_query_type_cql;
sr->u.request->query.cql = "title:solr";
sr->u.request->startRecord = odr_intdup(odr, 3);
{
Z_SRW_PDU *sr = yaz_srw_get_pdu(odr, Z_SRW_searchRetrieve_request,
"1.2");
-
+
sr->u.request->query_type = Z_SRW_query_type_cql;
sr->u.request->query.cql = "title:solr";
sr->u.request->startRecord = odr_intdup(odr, 3);
Z_SRW_PDU *sr_p;
char *http_response = odr_malloc(o, strlen(content) + 300);
- strcpy(http_response,
+ strcpy(http_response,
"HTTP/1.1 200 OK\r\n"
"Last-Modified: Wed, 13 Apr 2011 08:30:59 GMT\r\n"
"ETag: \"MjcyMWE5M2JiNDgwMDAwMFNvbHI=\"\r\n"
Z_SRW_searchRetrieveResponse *response;
YAZ_CHECK(check_response(
- odr,
+ odr,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<response>\n"
"<lst name=\"responseHeader\"><int name=\"status\">0</int>"
YAZ_CHECK(
check_response(
- odr,
+ odr,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<response><lst name=\"responseHeader\">"
"<int name=\"status\">0</int><int name=\"QTime\">2</int>"
"</doc>";
Z_SRW_record *record = response->records;
-
+
YAZ_CHECK(record->recordData_len == strlen(doc) &&
!memcmp(record->recordData_buf, doc, record->recordData_len));
}
user = yaz_timing_get_user(t);
YAZ_CHECK(user == -1.0 || user >= 0.0);
- sys = yaz_timing_get_sys(t);
+ sys = yaz_timing_get_sys(t);
YAZ_CHECK(sys == -1.0 || sys >= 0.0);
yaz_log(YLOG_LOG, "real=%f user=%f sys=%f", real, user, sys);
-
+
yaz_timing_destroy(&t);
YAZ_CHECK(!t);
}
buf[i] = '\0';
wrbuf_puts(wr, buf);
}
-
+
cp = wrbuf_buf(wr);
len = wrbuf_len(wr);
YAZ_CHECK(len == step * (step-1) / 2);
xmlDocPtr doc = 0;
yaz_rpnquery2xml(rpn, &doc);
-
+
if (!doc)
status = QUERY2XML_FAILED;
else
int len_out;
xmlDocDumpMemory(doc, (xmlChar **) &buf_out, &len_out);
-
+
if (len_out == (int) strlen(expect_xml)
&& memcmp(buf_out, expect_xml, len_out) == 0)
{
const char *addinfo = 0;
const xmlNode *root_element = xmlDocGetRootElement(doc);
ODR odr2 = odr_createmem(ODR_ENCODE);
-
+
yaz_xml2query(root_element, &query2, odr2,
&error_code, &addinfo);
if (error_code || !query2)
YAZ_CHECK_EQ(pqf2xml_text("@attr 1=4 bad query", "", 0), PQF_FAILED);
#if YAZ_HAVE_XML2
YAZ_CHECK_EQ(pqf2xml_text(
- "@attr 1=4 computer",
+ "@attr 1=4 computer",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<apt><attr type=\"1\" value=\"4\"/>"
"</rpn></query>\n",
"RPN @attrset Bib-1 @attr 1=4 computer"
), XML_MATCH);
-
+
YAZ_CHECK_EQ(pqf2xml_text(
"@attr 2=1 @attr 1=title computer",
"<?xml version=\"1.0\"?>\n"
"</rpn></query>\n",
"RPN @attrset Bib-1 @attr Exp-1 1=1 @attr 2=1 computer"
), XML_MATCH);
-
+
YAZ_CHECK_EQ(pqf2xml_text(
- "@and a b",
+ "@and a b",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<operator type=\"and\">"
"</operator></rpn></query>\n",
"RPN @attrset Bib-1 @and a b"
), XML_MATCH);
-
+
YAZ_CHECK_EQ(pqf2xml_text(
- "@or @and a b c",
+ "@or @and a b c",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<operator type=\"or\">"
), XML_MATCH);
YAZ_CHECK_EQ(pqf2xml_text(
- "@set abe",
+ "@set abe",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<rset>abe</rset></rpn></query>\n",
), XML_MATCH);
YAZ_CHECK_EQ(pqf2xml_text(
- /* exclusion, distance, ordered, relationtype,
+ /* exclusion, distance, ordered, relationtype,
knownunit, proxunit */
- "@prox 0 3 1 2 k 2 a b",
+ "@prox 0 3 1 2 k 2 a b",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<operator type=\"prox\" exclusion=\"false\" "
), XML_MATCH);
YAZ_CHECK_EQ(pqf2xml_text(
- "@term numeric 32",
+ "@term numeric 32",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<apt>"
"</rpn></query>\n",
"RPN @attrset Bib-1 @term numeric 32"
), XML_MATCH);
-
+
YAZ_CHECK_EQ(pqf2xml_text(
- "@term string computer",
+ "@term string computer",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<apt>"
"</rpn></query>\n",
"RPN @attrset Bib-1 @term string computer"
), XML_MATCH);
-
+
YAZ_CHECK_EQ(pqf2xml_text(
- "@term null void",
+ "@term null void",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"Bib-1\">"
"<apt>"
), XML_MATCH);
YAZ_CHECK_EQ(pqf2xml_text(
- "@attrset gils @attr 4=2 x",
+ "@attrset gils @attr 4=2 x",
"<?xml version=\"1.0\"?>\n"
"<query><rpn set=\"GILS\">"
"<apt>"
int ok;
int nok = 0;
char *arg;
-
+
while ((c = options("c:s:p:fbd:rv:", argv, argc, &arg)) != -2) {
switch (c) {
case 0:
#include <yaz/options.h>
#if HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
+#include <readline/readline.h>
#endif
#if HAVE_READLINE_HISTORY_H
#include <readline/history.h>
WRBUF q_wrbuf = 0;
prog = *argv;
- bibset = ccl_qual_mk();
-
+ bibset = ccl_qual_mk();
+
while ((ret = options("db:x:", argv, argc, &arg)) != -2)
{
switch(ret)
CCL_parser cclp = ccl_parser_create(bibset);
int error;
struct ccl_rpn_node *rpn;
-
+
rpn = ccl_parser_find_str(cclp, wrbuf_cstr(q_wrbuf));
-
+
error = ccl_parser_get_error(cclp, 0);
-
+
if (error)
{
printf("%s\n", ccl_err_msg(error));
}
strcpy(buf,line_in);
free(line_in);
-#else
+#else
printf("CCLSH>"); fflush(stdout);
if (!fgets(buf, 999, stdin))
break;
-#endif
+#endif
for (i = 0; i<1; i++)
{
CCL_parser cclp = ccl_parser_create(bibset);
int pos;
-
+
rpn = ccl_parser_find_str(cclp, buf);
-
+
error = ccl_parser_get_error(cclp, &pos);
if (error)
printf("Second:\n");
ccl_pr_tree(rpn, stdout);
printf("\n");
-
+
for (idx = 0; ; idx++)
{
const char *qname;
if (!ccl_stop_words_info(csw, idx,
&qname, &term))
break;
- printf("Removed from %s: %s\n",
+ printf("Removed from %s: %s\n",
qname ? qname : "none", term);
}
}
{
fprintf(stderr, "PQF syntax error\n");
}
- else
+ else
{
int ret = cql_transform_rpn2cql_stream(ct, cql_fputs,
stdout, rpn);
-
+
if (ret)
{
const char *addinfo;
{
CQL_parser cp = cql_parser_create();
int r = 0;
-
+
if (query)
{
if (verbose)
}
else
r = cql_parser_stdio(cp, stdin);
-
+
if (r)
fprintf(stderr, "Syntax error\n");
else
do_sortkeys = 1;
break;
default:
- usage(prog);
+ usage(prog);
}
}
if (do_sortkeys)
{
WRBUF w = wrbuf_alloc();
- r = cql_sortby_to_sortkeys(cql_parser_result(cp),
+ r = cql_sortby_to_sortkeys(cql_parser_result(cp),
wrbuf_vp_puts, w);
if (r == 0)
printf("sortkeys: %s\n", wrbuf_cstr(w));
"[-l pos=value] [-c cfile] [-s prefix] [-C size] [-n] "
"[-p] [-v] [-V] file...\n",
prog);
-}
+}
static void show_version(void)
{
prog, fname, strerror(errno));
exit(1);
}
-
+
while (yaz_marc_read_line(mt, getbyte_stream,
ungetbyte_stream, inf) == 0)
{
int type = xmlTextReaderNodeType(reader);
if (type == XML_READER_TYPE_ELEMENT)
{
- const char *name = (const char *)
+ const char *name = (const char *)
xmlTextReaderLocalName(reader);
if (!strcmp(name, "record") || !strcmp(name, "r"))
{
xmlNodePtr ptr = xmlTextReaderExpand(reader);
-
+
int r = yaz_marc_read_xml(mt, ptr);
if (r)
fprintf(stderr, "yaz_marc_read_xml failed\n");
int write_rc = yaz_marc_write_mode(mt, wrbuf);
if (write_rc)
yaz_log(YLOG_WARN, "yaz_marc_write_mode: write error: %d", write_rc);
-
+
fputs(wrbuf_cstr(wrbuf), stdout);
wrbuf_rewind(wrbuf);
}
else
{
yaz_marc_write_mode(mt, wrbuf);
-
+
fputs(wrbuf_cstr(wrbuf), stdout);
wrbuf_rewind(wrbuf);
}
size_t len_result;
size_t r;
char buf[100001];
-
+
r = fread(buf, 1, 5, inf);
if (r < 5)
{
long off = ftell(inf) - 5;
if (verbose || print_offset)
printf("<!-- Skipping bad byte %d (0x%02X) at offset "
- "%ld (0x%lx) -->\n",
+ "%ld (0x%lx) -->\n",
*buf & 0xff, *buf & 0xff,
off, off);
for (i = 0; i<4; i++)
if ((i & 15) == 0)
fprintf(cfile, " \"");
fprintf(cfile, "\\x%02X", p[i] & 255);
-
+
if (i < r - 1 && (i & 15) == 15)
fprintf(cfile, "\"\n");
-
+
}
fprintf(cfile, "\"\n");
}
}
#if YAZ_HAVE_XML2
#else
- if (input_format == YAZ_MARC_MARCXML
+ if (input_format == YAZ_MARC_MARCXML
|| input_format == YAZ_MARC_XCHANGE)
{
fprintf(stderr, "%s: Libxml2 support not enabled\n", prog);
case 'v':
verbose++;
break;
- case 'V':
+ case 'V':
show_version();
break;
default:
decode = odr_createmem(ODR_DECODE);
encode = odr_createmem(ODR_ENCODE);
content_len = no;
- z_soap_codec(decode, &soap_package,
+ z_soap_codec(decode, &soap_package,
&content_buf, &content_len, h);
if (!soap_package)
{
{
Z_SRW_PDU *sr = (Z_SRW_PDU *) soap_package->u.generic->p;
if (sr->which == Z_SRW_searchRetrieve_request)
- {
+ {
Z_SRW_searchRetrieveRequest *req = sr->u.request;
switch(req->query_type)
{
#include <unicode/ucnv.h>
#include <unicode/ustring.h>
-#include <unicode/ucol.h>
+#include <unicode/ucol.h>
#include <unicode/ubrk.h>
#include <unicode/utrans.h>
#include <unicode/uclean.h>
#include <yaz/wrbuf.h>
/* commando line and config parameters */
-struct config_t {
+struct config_t {
char conffile[1024];
char print[1024];
int xmloutput;
FILE * infile;
FILE * outfile;
};
-
+
void print_option_error(const struct config_t *p_config)
-{
+{
fprintf(stderr, "yaz-icu [options] [infile]\n"
"Options:\n"
" -c file XML configuration\n"
}
void read_params(int argc, char **argv, struct config_t *p_config)
-{
+{
char *arg;
int ret;
-
+
/* set default parameters */
p_config->conffile[0] = 0;
p_config->print[0] = 0;
p_config->chain = 0;
p_config->infile = 0;
p_config->outfile = stdout;
-
+
/* set up command line parameters */
-
+
while ((ret = options("c:p:xs", argv, argc, &arg)) != -2)
{
switch (ret)
fprintf(p_config->outfile, "<converters count=\"%d\" default=\"%s\">\n",
count, ucnv_getDefaultName());
else
- {
+ {
fprintf(p_config->outfile, "Available ICU converters: %d\n", count);
- fprintf(p_config->outfile, "Default ICU Converter is: '%s'\n",
+ fprintf(p_config->outfile, "Default ICU Converter is: '%s'\n",
ucnv_getDefaultName());
}
-
+
for (i = 0; i < count; i++)
{
if (p_config->xmloutput)
- fprintf(p_config->outfile, "<converter id=\"%s\"/>\n",
+ fprintf(p_config->outfile, "<converter id=\"%s\"/>\n",
ucnv_getAvailableName(i));
- else
+ else
fprintf(p_config->outfile, "%s\n", ucnv_getAvailableName(i));
}
-
+
if (p_config->xmloutput)
fprintf(p_config->outfile, "</converters>\n");
else
if (p_config->xmloutput)
fprintf(p_config->outfile, "<transliterators count=\"%d\">\n", count);
- else
+ else
fprintf(p_config->outfile, "Available ICU transliterators: %d\n", count);
while ((name = uenum_next(en, &length, &status)))
"see http://userguide.icu-project.org/transforms/general\n"
" http://www.unicode.org/reports/tr44/\n"
);
-
-
+
+
fprintf(p_config->outfile, "\n\n");
-
+
}
}
int32_t count;
int32_t i;
UErrorCode status = U_ZERO_ERROR;
-
+
UChar keyword[64];
int32_t keyword_len = 0;
char keyword_str[128];
if (p_config->xmloutput)
{
- fprintf(p_config->outfile, "<locales count=\"%d\" default=\"%s\" collations=\"%d\">\n",
+ fprintf(p_config->outfile, "<locales count=\"%d\" default=\"%s\" collations=\"%d\">\n",
count, uloc_getDefault(), ucol_countAvailable());
}
else
fprintf(p_config->outfile, "Available ICU locales: %d\n", count);
fprintf(p_config->outfile, "Default locale is: %s\n", uloc_getDefault());
}
-
- for (i = 0; i < count; i++)
+
+ for (i = 0; i < count; i++)
{
- keyword_len
- = uloc_getDisplayKeyword(uloc_getAvailable(i), "en",
- keyword, 64,
+ keyword_len
+ = uloc_getDisplayKeyword(uloc_getAvailable(i), "en",
+ keyword, 64,
&status);
u_strToUTF8(keyword_str, 128, &keyword_str_len,
keyword, keyword_len,
&status);
-
-
- language_len
- = uloc_getDisplayLanguage(uloc_getAvailable(i), "en",
- language, 64,
+
+
+ language_len
+ = uloc_getDisplayLanguage(uloc_getAvailable(i), "en",
+ language, 64,
&status);
u_strToUTF8(lang_str, 128, &lang_str_len,
&status);
- script_len
- = uloc_getDisplayScript(uloc_getAvailable(i), "en",
- script, 64,
+ script_len
+ = uloc_getDisplayScript(uloc_getAvailable(i), "en",
+ script, 64,
&status);
u_strToUTF8(script_str, 128, &script_str_len,
script, script_len,
&status);
- location_len
- = uloc_getDisplayCountry(uloc_getAvailable(i), "en",
- location, 64,
+ location_len
+ = uloc_getDisplayCountry(uloc_getAvailable(i), "en",
+ location, 64,
&status);
u_strToUTF8(location_str, 128, &location_str_len,
location, location_len,
&status);
- variant_len
- = uloc_getDisplayVariant(uloc_getAvailable(i), "en",
- variant, 64,
+ variant_len
+ = uloc_getDisplayVariant(uloc_getAvailable(i), "en",
+ variant, 64,
&status);
u_strToUTF8(variant_str, 128, &variant_str_len,
variant, variant_len,
&status);
- name_len
- = uloc_getDisplayName(uloc_getAvailable(i), "en",
- name, 64,
+ name_len
+ = uloc_getDisplayName(uloc_getAvailable(i), "en",
+ name, 64,
&status);
u_strToUTF8(name_str, 128, &name_str_len,
name, name_len,
&status);
- localname_len
- = uloc_getDisplayName(uloc_getAvailable(i), uloc_getAvailable(i),
- localname, 64,
+ localname_len
+ = uloc_getDisplayName(uloc_getAvailable(i), uloc_getAvailable(i),
+ localname, 64,
&status);
u_strToUTF8(localname_str, 128, &localname_str_len,
if (p_config->xmloutput)
{
- fprintf(p_config->outfile, "<locale id=\"%s\"", uloc_getAvailable(i));
+ fprintf(p_config->outfile, "<locale id=\"%s\"", uloc_getAvailable(i));
if (strlen(lang_str))
fprintf(p_config->outfile, " language=\"%s\"", lang_str);
if (strlen(script_str))
fprintf(p_config->outfile, ">");
if (strlen(localname_str))
fprintf(p_config->outfile, "%s", localname_str);
- fprintf(p_config->outfile, "</locale>\n");
+ fprintf(p_config->outfile, "</locale>\n");
}
else if (1 == p_config->xmloutput)
{
- fprintf(p_config->outfile, "%s", uloc_getAvailable(i));
+ fprintf(p_config->outfile, "%s", uloc_getAvailable(i));
fprintf(p_config->outfile, " | ");
if (strlen(name_str))
fprintf(p_config->outfile, "%s", name_str);
{
char *line = 0;
char linebuf[1024];
-
- xmlDoc *doc = xmlParseFile(p_config->conffile);
+
+ xmlDoc *doc = xmlParseFile(p_config->conffile);
xmlNode *xml_node = xmlDocGetRootElement(doc);
- long unsigned int token_count = 0;
- long unsigned int line_count = 0;
-
+ long unsigned int token_count = 0;
+ long unsigned int line_count = 0;
+
UErrorCode status = U_ZERO_ERROR;
-
+
if (!xml_node)
- {
+ {
printf("Could not parse XML config file '%s' \n",
p_config->conffile);
exit(1);
p_config->chain = icu_chain_xml_config(xml_node, 1, &status);
if (!p_config->chain || !U_SUCCESS(status))
- {
+ {
printf("Could not set up ICU chain from config file '%s' \n",
p_config->conffile);
if (!U_SUCCESS(status))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<icu>\n"
"<tokens>\n");
-
+
/* read input lines for processing */
while ((line=fgets(linebuf, sizeof(linebuf)-1, p_config->infile)))
{
wrbuf_rewind(sw);
wrbuf_puts_escaped(sw, sortkey);
token_count++;
- if (p_config->xmloutput)
+ if (p_config->xmloutput)
{
- fprintf(p_config->outfile,
+ fprintf(p_config->outfile,
"<token id=\"%lu\" line=\"%lu\"",
token_count, line_count);
wrbuf_xmlputs(cdata, icu_chain_token_display(p_config->chain));
fprintf(p_config->outfile, " display=\"%s\"",
wrbuf_cstr(cdata));
-
+
if (p_config->sortoutput)
{
wrbuf_rewind(cdata);
fprintf(p_config->outfile,
"</tokens>\n"
"</icu>\n");
-
+
icu_chain_destroy(p_config->chain);
xmlFreeDoc(doc);
if (line)
#endif /* YAZ_HAVE_ICU */
-int main(int argc, char **argv)
+int main(int argc, char **argv)
{
#if YAZ_HAVE_ICU
struct config_t config;
if (config.conffile && strlen(config.conffile))
process_text_file(&config);
-
+
if (config.print && strlen(config.print))
print_info(&config);
* and yaz already provides the APDUS for it.
*
* This is not an interactive client like yaz-client, but driven by command-
- * line arguments. Its output is a return code, and possibly some text on
+ * line arguments. Its output is a return code, and possibly some text on
* stdout.
*
* Exit codes (note, the program exits as soon as it finds a good reason)
struct nameval *nv = (struct nameval *) xmalloc(sizeof(*nv));
char *p=arg;
int len;
- if (!p || !*p)
+ if (!p || !*p)
return 0; /* yeah, leaks a bit of memory. so what */
- while ( *p && ( *p != '=' ) )
+ while ( *p && ( *p != '=' ) )
p++;
len = p - arg;
if (!len)
return;
if (args->namevals) {
nv->next=args->namevals->next; /* first */
- args->namevals->next=nv;
+ args->namevals->next=nv;
args->namevals=nv;
} else {
nv->next=nv;
/** \brief parse a parameter file */
void parse_paramfile(char *arg, struct prog_args *args) {
FILE *f=fopen(arg,"r");
-#define BUFSIZE 4096
+#define BUFSIZE 4096
char buf[BUFSIZE];
int len;
struct nameval *nv;
args->oclc_recno=0;
args->auth_userid = 0;
args->auth_passwd = 0;
-#if 0
+#if 0
/* Example 3 - directly from OCLC, supposed to work on their test server*/
args->auth_userid = "100-310-658" ; /* FIXME - get from cmd line */
args->auth_passwd = "apii2test" ; /* FIXME - get from cmd line */
hostaddr );
exit(2);
}
-
+
yaz_log(YLOG_DEBUG,"Created stack ok ");
status = cs_connect(stack, server_address_ip);
Z_PromptObject1 *makeprompt(struct prog_args *args, ODR odr) {
Z_PromptObject1 *p = (Z_PromptObject1 *) odr_malloc(odr, sizeof(*p) );
Z_ResponseUnit1 *ru = (Z_ResponseUnit1 *) odr_malloc(odr, sizeof(*ru) );
-
+
p->which=Z_PromptObject1_response;
p->u.response = (Z_Response1*) odr_malloc(odr, sizeof(*(p->u.response)) );
p->u.response->num=2;
- p->u.response->elements= (Z_ResponseUnit1 **) odr_malloc(odr,
+ p->u.response->elements= (Z_ResponseUnit1 **) odr_malloc(odr,
p->u.response->num*sizeof(*(p->u.response->elements)) );
/* user id, aka "oclc authorization number" */
p->u.response->elements[0] = ru;
ru->promptId->which = Z_PromptId_enumeratedPrompt;
ru->promptId->u.enumeratedPrompt = (Z_PromptIdEnumeratedPrompt *)
odr_malloc(odr, sizeof(*(ru->promptId->u.enumeratedPrompt) ));
- ru->promptId->u.enumeratedPrompt->type =
+ ru->promptId->u.enumeratedPrompt->type =
odr_intdup(odr,Z_PromptIdEnumeratedPrompt_userId);
ru->promptId->u.enumeratedPrompt->suggestedString = 0 ;
ru->which = Z_ResponseUnit1_string ;
ru->promptId->which = Z_PromptId_enumeratedPrompt;
ru->promptId->u.enumeratedPrompt = (Z_PromptIdEnumeratedPrompt *)
odr_malloc(odr, sizeof(*(ru->promptId->u.enumeratedPrompt) ));
- ru->promptId->u.enumeratedPrompt->type =
+ ru->promptId->u.enumeratedPrompt->type =
odr_intdup(odr,Z_PromptIdEnumeratedPrompt_password);
ru->promptId->u.enumeratedPrompt->suggestedString = 0 ;
ru->which = Z_ResponseUnit1_string ;
yaz_log(YLOG_FATAL,"Encoding of z_PromptObject1 failed ");
exit (6);
}
-
+
printf ("Prompt: \n"); /*!*/
z_PromptObject1(odr_prt, &p, 0,0 ); /*!*/
buf= odr_getbuf(odr_ext,&siz,0);
- ext->u.single_ASN1_type=(Odr_any *)
+ ext->u.single_ASN1_type=(Odr_any *)
odr_malloc(odr,sizeof(*ext->u.single_ASN1_type));
ext->u.single_ASN1_type->buf= (unsigned char *) odr_malloc(odr, siz);
memcpy(ext->u.single_ASN1_type->buf,buf, siz );
}
printf("External: \n");
z_External(odr_prt, &ext,0,0); /*!*/
- buf= odr_getbuf(odr_ext,&siz,0);
+ buf= odr_getbuf(odr_ext,&siz,0);
e->item->buf= (unsigned char *) odr_malloc(odr, siz);
memcpy(e->item->buf,buf, siz );
e->item->len = e->item->size = siz;
yaz_log(YLOG_FATAL,"Encoding of ill_OCLCILLRequestExtension failed ");
exit (6);
}
-
+
printf ("OCLC: \n"); /*!*/
ill_OCLCILLRequestExtension(odr_prt, &oc, 0,0 ); /*!*/
}
printf("External: \n");
z_External(odr_prt, &ext,0,0); /*!*/
- buf= odr_getbuf(odr_ext,&siz,0);
+ buf= odr_getbuf(odr_ext,&siz,0);
e->item->buf= (unsigned char *) odr_malloc(odr, siz);
memcpy(e->item->buf, buf, siz);
e->item->len = e->item->size = siz;
char *buf_out;
int len_out;
int res;
- if (!ill_APDU (odr, &apdu, 0, 0)) {
+ if (!ill_APDU (odr, &apdu, 0, 0)) {
yaz_log(YLOG_FATAL,"ill_Apdu failed");
exit(2);
}
yaz_log(YLOG_FATAL|YLOG_ERRNO, "write req.apdu failed");
}
}
-
+
} /* sendrequest */
/* * * * * * * * * * * * * * * */
yaz_log(YLOG_DEBUG,"Got a response of %d bytes at %p. res=%d", len_in,buf_in, res);
if (res<0) {
yaz_log(YLOG_FATAL,"Could not receive packet. code %d",res );
- yaz_log(YLOG_DEBUG,"%02x %02x %02x %02x %02x %02x %02x %02x ...",
+ yaz_log(YLOG_DEBUG,"%02x %02x %02x %02x %02x %02x %02x %02x ...",
buf_in[0], buf_in[1], buf_in[2], buf_in[3],
buf_in[4], buf_in[5], buf_in[6], buf_in[7] );
yaz_log(YLOG_DEBUG,"PDU Dump:");
sprintf(msg, "ODR code %d:%d element=%-20s",
err, x, element ? element : "<unknown>");
yaz_log(YLOG_FATAL,"Error decoding incoming packet: %s",msg);
- yaz_log(YLOG_DEBUG,"%02x %02x %02x %02x %02x %02x %02x %02x ...",
+ yaz_log(YLOG_DEBUG,"%02x %02x %02x %02x %02x %02x %02x %02x ...",
buf_in[0], buf_in[1], buf_in[2], buf_in[3],
buf_in[4], buf_in[5], buf_in[6], buf_in[7] );
yaz_log(YLOG_DEBUG,"PDU Dump:");
ILL_Status_Or_Error_Report *getstaterr( ILL_APDU *resp, ODR in_odr ) {
if (resp->which != ILL_APDU_Status_Or_Error_Report ) {
const char *element = odr_getelement(in_odr);
- if (!element)
+ if (!element)
element="unknown";
printf("Server returned wrong packet type: %d\n", resp->which);
yaz_log(YLOG_FATAL,"Server returned a (%d) and "
/** \brief Return a printable string from an ILL_String */
char *getillstring( ILL_String *s) {
- if (s->which == ILL_String_GeneralString )
+ if (s->which == ILL_String_GeneralString )
return s->u.GeneralString;
- else if (s->which == ILL_String_EDIFACTString )
+ else if (s->which == ILL_String_EDIFACTString )
return s->u.EDIFACTString;
else {
yaz_log(YLOG_FATAL,"Invalid ILL_String ");
printf("Already forwarded: \n");
break;
case ILL_User_Error_Report_intermediary_problem:
- printf("Intermediary problem: " ODR_INT_PRINTF "\n",
+ printf("Intermediary problem: " ODR_INT_PRINTF "\n",
*uerr->u.intermediary_problem);
break;
case ILL_User_Error_Report_security_problem:
- printf("Security problem: %s\n",
+ printf("Security problem: %s\n",
getillstring(uerr->u.security_problem));
break;
case ILL_User_Error_Report_unable_to_perform:
- printf("Unable to perform: " ODR_INT_PRINTF "\n",
+ printf("Unable to perform: " ODR_INT_PRINTF "\n",
*uerr->u.unable_to_perform);
break;
default:
ILL_Provider_Error_Report *perr= err->provider_error_report;
switch( perr->which ) {
case ILL_Provider_Error_Report_general_problem:
- printf("General Problem: " ODR_INT_PRINTF ":",
+ printf("General Problem: " ODR_INT_PRINTF ":",
*perr->u.general_problem);
break;
case ILL_Provider_Error_Report_transaction_id_problem:
- printf("Transaction Id Problem: " ODR_INT_PRINTF ":",
+ printf("Transaction Id Problem: " ODR_INT_PRINTF ":",
*perr->u.general_problem);
break;
case ILL_Provider_Error_Report_state_transition_prohibited:
break;
}
/*exit(7);*/
- }
+ }
/* fallbacks */
- if ( staterr->note )
+ if ( staterr->note )
printf("%s", getillstring(staterr->note));
- else
+ else
printf("Unknown error type");
printf("\n");
exit(7);
/* * * * * * * * * * * * * * * */
-/** \brief Main program
+/** \brief Main program
*
* Parse arguments
* Validate arguments
validateargs(&args);
stack = connect_to(args.host);
apdu = createrequest(&args, out_odr);
- if (1)
+ if (1)
dumpapdu(apdu);
- sendrequest(apdu, out_odr, stack );
+ sendrequest(apdu, out_odr, stack );
resp = getresponse(stack, in_odr );
- if (1)
+ if (1)
dumpapdu(resp);
staterr=getstaterr(resp, in_odr);
checkerr(staterr);
}
while ((c = getc(f)) != EOF)
wrbuf_putc(input_record, c);
-
- r = yaz_record_conv_record(p,
+
+ r = yaz_record_conv_record(p,
wrbuf_buf(input_record),
wrbuf_len(input_record),
output_record);
if (r)
{
fprintf(stderr, "%s: %s: Error %s\n",
- prog, arg,
+ prog, arg,
yaz_record_conv_get_error(p));
no_errors++;
}
else
{
xmlDocPtr doc = 0;
-
+
yaz_rpnquery2xml(rpn, &doc);
-
+
if (!doc)
{
fprintf(stderr, "%s: yaz_rpnquery2xml failed for query %s\n",
}
xmlFreeDoc(doc);
}
- }
+ }
odr_destroy(odr);
}
fprintf(stderr, "%s: close failed for file %s\n", prog, xmlfile);
exit(1);
}
-
+
xmlquerytopqf(xmlstr);
xfree(xmlstr);
}
return ;
}
else if (e == YAZ_ICONV_EINVAL) /* incomplete input */
- {
+ {
size_t i;
for (i = 0; i<inbytesleft; i++)
inbuf0[i] = inbuf[i];
static int zoom_progress[ZOOM_EVENT_MAX+1];
/* commando line parameters */
-static struct parameters_t {
+static struct parameters_t {
char host[1024];
char query[1024];
int progress[4096];
int gnuplot;
} parameters;
-struct event_line_t
+struct event_line_t
{
int connection;
long time_sec;
void print_event_line(struct event_line_t *pel)
{
printf ("%d\t%ld.%06ld\t%d\t%d\t%s\t%d\t%s\n",
- pel->connection, pel->time_sec, pel->time_usec,
+ pel->connection, pel->time_sec, pel->time_usec,
pel->progress,
- pel->event, pel->zoom_event,
+ pel->event, pel->zoom_event,
pel->error, pel->errmsg);
}
elc[ielc] += 1;
}
-void print_events(int *elc, struct event_line_t *els,
+void print_events(int *elc, struct event_line_t *els,
int connections){
int i;
int j;
for (i = 0; i < 4096; i++){
parameters.progress[i] = 0;
}
-
+
}
-
-struct time_type
+
+struct time_type
{
struct timeval now;
struct timeval then;
}
-void read_params(int argc, char **argv, struct parameters_t *p_parameters){
+void read_params(int argc, char **argv, struct parameters_t *p_parameters){
char *arg;
int ret;
while ((ret = options("h:q:c:t:p:bgn:", argv, argc, &arg)) != -2)
print_option_error();
}
}
-
+
if(0){
printf("zoom-benchmark\n");
printf(" host: %s \n", p_parameters->host);
ZOOM_options_set (o, "preferredRecordSyntax", "usmarc");
ZOOM_options_set (o, "elementSetName", "F");
}
-
+
time_init(&time);
/* repeat loop */
for (k = 0; k < parameters.repeat; k++){
/* create connection - pass options (they are the same for all) */
z[i] = ZOOM_connection_create(o);
-
+
/* connect and init */
ZOOM_connection_connect(z[i], parameters.host, 0);
}
r[i] = ZOOM_connection_search_pqf (z[i], parameters.query);
/* network I/O. pass number of connections and array of connections */
- while ((i = ZOOM_event (parameters.concurrent, z))){
+ while ((i = ZOOM_event (parameters.concurrent, z))){
int event = ZOOM_connection_last_event(z[i-1]);
const char *errmsg;
const char *addinfo;
int error = 0;
//int progress = zoom_progress[event];
-
+
if (event == ZOOM_EVENT_SEND_DATA || event == ZOOM_EVENT_RECV_DATA)
continue;
else
//parameters.progress[i] = zoom_progress[event];
parameters.progress[i] += 1;
-
+
update_events(elc, els,
- k, i-1,
- time_sec(&time), time_usec(&time),
+ k, i-1,
+ time_sec(&time), time_usec(&time),
parameters.progress[i],
- event, zoom_events[event],
+ event, zoom_events[event],
error, errmsg);
}
printf("\n");
printf("\n");
}
-
- print_table_header();
+
+ print_table_header();
print_events(elc, els, parameters.concurrent);
-
+
if (parameters.gnuplot){
printf("end\n");
printf("pause -1 \"Hit ENTER to return\"\n");
ZOOM_connection z;
ZOOM_options o = ZOOM_options_create ();
const char *errmsg, *addinfo;
-
+
if (argc != 4)
{
fprintf (stderr, "usage:\nzoom-ka sleepinterval target query\n");
ZOOM_resultset rset;
ZOOM_connection_connect (z, argv[2], 0);
rset = ZOOM_connection_search_pqf(z, argv[3]);
-
+
while ((i = ZOOM_event(1, &z)))
{
printf ("no = %d event = %d\n", i-1,
#include <yaz/options.h>
#if HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
+#include <readline/readline.h>
#endif
#if HAVE_READLINE_HISTORY_H
#include <readline/history.h>
const char *val;
if (!r[i])
continue;
-
+
val = ZOOM_resultset_option_get(r[i], wrbuf_cstr(key));
printf("%s = %s\n", wrbuf_cstr(key), val ? val : "<null>");
}
size_t pos = i + start;
ZOOM_record rec = ZOOM_resultset_record(r, pos);
const char *db = ZOOM_record_get(rec, "database", 0);
-
+
if (ZOOM_record_error(rec, 0, 0, 0))
{
const char *msg;
const char *addinfo;
const char *diagset;
int error = ZOOM_record_error(rec, &msg, &addinfo, &diagset);
-
+
printf("%lld %s: %s (%s:%d) %s\n", (long long) pos,
(db ? db : "unknown"),
msg, diagset, error, addinfo ? addinfo : "none");
int i;
int ret = 0;
WRBUF ext_type_str = next_token_new_wrbuf(args);
-
+
if (!ext_type_str)
{
printf("es: missing type "
const char *query_str = *args;
int i;
int ret = 0;
-
+
s = ZOOM_query_create();
while (*query_str == ' ')
query_str++;
printf("%s: %lld hits\n", ZOOM_connection_option_get(c[i], "host"),
(long long int) ZOOM_resultset_size(r[i]));
-
+
facet_num = ZOOM_resultset_facets_size(r[i]);
if (facet_num)
{
int i;
int ret = 0;
ZOOM_scanset s[MAX_CON];
-
+
while (*query_str == ' ')
query_str++;
const char *term = ZOOM_scanset_display_term(s[i], p,
&occ, &len);
printf("%.*s %lld\n", (int) len, term, (long long int) occ);
- }
+ }
ZOOM_scanset_destroy(s[i]);
}
}
const char *sort_spec = *args;
int i;
int ret = 0;
-
+
while (*sort_spec == ' ')
sort_spec++;
-
+
for (i = 0; i<MAX_CON; i++)
{
if (r[i])
}
c[i] = ZOOM_connection_create(options);
ZOOM_connection_connect(c[i], wrbuf_cstr(host), 0);
-
+
if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
{
printf("%s error: %s (%s:%d) %s\n",
\retval -1 EOF (no more commands or quit seen)
*/
static int cmd_parse(ZOOM_connection *c, ZOOM_resultset *r,
- ZOOM_options options,
+ ZOOM_options options,
const char **buf)
{
int cmd_len;
}
strcpy(buf,line_in);
free(line_in);
-#else
+#else
printf("ZOOM>"); fflush(stdout);
if (!fgets(buf, sizeof(buf)-1, stdin))
{
res = -1;
break;
}
-#endif
+#endif
if ((cp = strchr(buf, '\n')))
*cp = '\0';
res = cmd_parse(c, r, options, &bp);
exit (1);
}
z = ZOOM_connection_new (argv[1], 0);
-
+
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
{
fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
exit (1);
}
- if (ZOOM_query_ccl2rpn(q, argv[2],
+ if (ZOOM_query_ccl2rpn(q, argv[2],
"term t=l,r s=al\n" "ti u=4 s=pw\n",
&ccl_error_code, &ccl_error_string, &ccl_error_pos))
{
else
{
z = ZOOM_connection_new (argv[1], 0);
-
+
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
{
fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
exit (2);
}
-
+
r = ZOOM_connection_search (z, q);
ZOOM_query_destroy(q);
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
if (idle)
{
ZOOM_connection_connect(z, 0, 0); /* allow reconnect */
-
+
if (++use <= 10)
{
probe_search(z, use, use&1);
exit (2);
}
else /* OK print hit count */
- printf ("Result count: %ld\n", (long) ZOOM_resultset_size(r));
+ printf ("Result count: %ld\n", (long) ZOOM_resultset_size(r));
ZOOM_resultset_destroy (r);
ZOOM_connection_destroy (z);
exit (0);
event,
ZOOM_get_event_str(event));
}
-
+
/* no more to be done. Inspect results */
for (i = 0; i<no; i++)
{
/* set proxy */
ZOOM_options_set (o, "proxy", argv[1]);
-
+
/* create query */
q = ZOOM_query_create ();
if (ZOOM_query_prefix (q, argv[argc-1]))
/* if rec is non-null, we got a record for display */
if (str)
{
- printf("%d %s %s\n", pos+1, syntax,
+ printf("%d %s %s\n", pos+1, syntax,
(db ? db : "unknown"));
if (rec)
{
printf ("error - couldn't connect?\n");
exit (1);
}
-
+
ZOOM_connection_destroy (z);
for (block = 0; block < 3; block++)
sprintf (host, "localhost:9999/%d", i);
z = ZOOM_connection_create (o);
ZOOM_connection_connect (z, host, 0);
-
+
for (j = 0; j < 10; j++)
{
ZOOM_record recs[2];
char query[40];
ZOOM_query s = ZOOM_query_create ();
-
+
sprintf (query, "i%dr%d", i, j);
-
+
if (ZOOM_query_prefix (s, query))
{
printf ("bad PQF: %s\n", query);
}
ZOOM_options_set (o, "start", "0");
ZOOM_options_set (o, "count", "0");
-
+
r[j] = ZOOM_connection_search (z, s); /* non-piggy */
-
+
ZOOM_resultset_records (r[j], recs, 0, 2); /* first two */
-
+
ZOOM_resultset_records (r[j], recs, 1, 2); /* third */
ZOOM_resultset_records (r[j], recs, 0, 0); /* ignored */
exit (1);
}
}
-
+
ZOOM_query_destroy (s);
printf (".");
sprintf (host, "localhost:9999/%d", i);
z = ZOOM_connection_create (o);
ZOOM_connection_connect (z, host, 0);
-
+
for (j = 0; j < 10; j++)
{
char query[40];
-
+
sprintf (query, "i%dr%d", i, j);
-
+
ZOOM_options_set (o, "count", "0");
-
+
r[j] = ZOOM_connection_search_pqf (z, query);
printf (".");
}
ZOOM_connection_destroy (z);
-
+
for (j = 0; j < 10; j++)
{
ZOOM_resultset_records (r[j], 0, 0, 1);
term = ZOOM_scanset_term (scan, j, &occur, &len);
if (term)
printf ("%d %.*s %d\n", j, (int) len, term, (int) occur);
-
+
}
ZOOM_scanset_destroy (scan);
ZOOM_connection_destroy (z);
/* connect and init */
ZOOM_connection_connect (z[i], argv[1+i], 0);
-
+
}
/* scan all */
for (i = 0; i<no; i++)
ZOOM_options o = ZOOM_options_create ();
int error;
const char *errmsg, *addinfo;
-
+
if (argc < 3)
usage();
z = ZOOM_connection_create (o);
-
+
/* connect and init */
ZOOM_connection_connect (z, argv[1], 0);
-
+
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
{
fprintf(stderr, "%s error: %s (%d) %s\n",
odr_malloc(odr, sizeof(*hr));
Z_HoldingsAndCircData *hc = (Z_HoldingsAndCircData *)
odr_malloc(odr, sizeof(*hc));
-
+
rec->holdingsData[i] = hr;
hr->which = Z_HoldingsRecord_holdingsAndCirc;
hr->u.holdingsAndCirc = hc;
-
+
hc->typeOfRecord = "u";
hc->encodingLevel = "u";
hc->completeness = 0; /* OPT */
hc->dateOfReport = "000000";
hc->nucCode = "s-FM/GC";
- hc->localLocation =
+ hc->localLocation =
"Main or Science/Business Reading Rms - STORED OFFSITE";
hc->shelvingLocation = 0; /* OPT */
hc->callNumber = "MLCM 89/00602 (N)";
sh->result_sets = 0;
}
-/** \brief use term value as hit count
+/** \brief use term value as hit count
\param s RPN structure
\return >= 0: search term number or -1: not found
-
+
Traverse RPN tree 'in order' and use term value as hit count.
Only terms that looks a numeric is used.. Returns -1 if
no sub tree has a hit count term
/** \brief gets hit count for numeric terms in RPN queries
\param q RPN Query
\return number of hits (random or number for term)
-
+
This is just for testing.. A real database of course uses
the content of a database to establish a value.. In our case, we
have a way to trigger a certain hit count. Good for testing of
Z_FacetTerm *facet_term;
sprintf(key, "%s%d", facet_name, index);
yaz_log(YLOG_DEBUG, "facet add term %s %d %s", facet_name, index, key);
-
+
facet_term = facet_term_create_cstr(odr, key, freq);
freq = freq - 10 ;
facet_field_term_set(odr, facet_field, facet_term, index);
rr->errcode = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
return 0;
}
-
+
db = rr->basenames[0];
/* Allow Default, db.* and Slow */
return 0;
}
- new_set = get_set(sh, rr->setname);
+ new_set = get_set(sh, rr->setname);
if (new_set)
{
if (!rr->replace_set)
}
do_delay(&new_set->search_delay);
new_set->hits = rr->hits;
-
+
return 0;
}
Z_IOOriginPartToKeep *k = ir->toKeep;
Z_IOOriginPartNotToKeep *n = ir->notToKeep;
const char *xml_in_response = 0;
-
+
if (k && k->contact)
{
if (k->contact->name)
{
yaz_log(log_level, "Billing info (not shown)");
}
-
+
if (n->resultSetItem)
{
yaz_log(log_level, "resultsetItem");
{
char oid_name_str[OID_STR_MAX];
oid_class oclass;
- const char *oid_name =
+ const char *oid_name =
yaz_oid_to_string_buf(r->direct_reference,
&oclass, oid_name_str);
if (oid_name)
if (r->which == Z_External_octet)
yaz_log(log_level, "%.*s",
r->u.octet_aligned->len,
- r->u.octet_aligned->buf);
+ r->u.octet_aligned->buf);
xml_in_response = "<dummy>x</dummy>";
}
- if (!oid_oidcmp(r->direct_reference,
+ if (!oid_oidcmp(r->direct_reference,
yaz_oid_general_isoill_1))
{
yaz_log(log_level, "Decode ItemRequest begin");
odr_setbuf(rr->decode,
(char *) r->u.single_ASN1_type->buf,
r->u.single_ASN1_type->len, 0);
-
+
if (!ill_ItemRequest(rr->decode, &item_req, 0, 0))
{
yaz_log(log_level,
odr_setbuf(rr->decode,
(char*) r->u.single_ASN1_type->buf,
r->u.single_ASN1_type->len, 0);
-
+
if (!ill_APDU(rr->decode, &ill_apdu, 0, 0))
{
yaz_log(log_level,
strlen(xml_in_response));
else
targetPart->itemRequest = 0;
-
+
targetPart->statusOrErrorReport = 0;
targetPart->auxiliaryStatus = 0;
}
Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
-
+
yaz_log(log_level, "action");
if (toKeep->action)
{
targetPart->num_globalDiagnostics = 0;
targetPart->globalDiagnostics = (Z_DiagRec **) odr_nullval();
targetPart->num_taskPackageRecords = 1;
- targetPart->taskPackageRecords =
+ targetPart->taskPackageRecords =
(Z_IUTaskPackageRecordStructure **)
odr_malloc(rr->stream,
sizeof(Z_IUTaskPackageRecordStructure *));
(Z_IUTaskPackageRecordStructure *)
odr_malloc(rr->stream,
sizeof(Z_IUTaskPackageRecordStructure));
-
+
targetPart->taskPackageRecords[0]->which =
Z_IUTaskPackageRecordStructure_record;
- targetPart->taskPackageRecords[0]->u.record =
+ targetPart->taskPackageRecords[0]->u.record =
z_ext_record_sutrs(rr->stream, "test", 4);
- targetPart->taskPackageRecords[0]->correlationInfo = 0;
+ targetPart->taskPackageRecords[0]->correlationInfo = 0;
targetPart->taskPackageRecords[0]->recordStatus =
odr_intdup(rr->stream,
- Z_IUTaskPackageRecordStructure_success);
+ Z_IUTaskPackageRecordStructure_success);
targetPart->taskPackageRecords[0]->num_supplementalDiagnostics
= 0;
if (rec->direct_reference)
{
char oid_name_str[OID_STR_MAX];
- const char *oid_name
+ const char *oid_name
= oid_name = yaz_oid_to_string_buf(
rec->direct_reference, 0,
oid_name_str);
int ztest_present(void *handle, bend_present_rr *rr)
{
struct session_handle *sh = (struct session_handle*) handle;
- struct result_set *set = get_set(sh, rr->setname);
+ struct result_set *set = get_set(sh, rr->setname);
if (!set)
{
struct session_handle *sh = (struct session_handle*) handle;
char *cp;
const Odr_oid *oid = r->request_format;
- struct result_set *set = get_set(sh, r->setname);
+ struct result_set *set = get_set(sh, r->setname);
if (!set)
{
{
/* this section returns a small record */
char buf[100];
-
+
sprintf(buf, "This is dummy SUTRS record number %d\n", r->number);
r->len = strlen(buf);
r->len = strlen(cp);
r->record = cp;
}
- else
+ else
{
r->errcode = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
r->surrogate_flag = 1;