{
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));