From: Adam Dickmeiss Date: Tue, 18 Sep 2012 12:54:07 +0000 (+0200) Subject: Remove trailing whitespace X-Git-Tag: v1.6.19~1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=8961ed761e348e972f00d015284ce75c16b1648c;p=pazpar2-moved-to-github.git Remove trailing whitespace --- diff --git a/src/charsets.c b/src/charsets.c index fc14257..5fa6c39 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -201,7 +201,7 @@ pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node) //xmlChar *xmlstr = 0; //int size = 0; //xmlDocDumpMemory(icu_doc, size); - + yaz_log(YLOG_FATAL, "Could not parse ICU chain config:\n" "<%s>\n ... \n", xml_node->name, xml_node->name); @@ -212,7 +212,7 @@ pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node) yaz_log(YLOG_FATAL, "Error: ICU support requested with element:\n" "<%s>\n ... \n", xml_node->name, xml_node->name); - yaz_log(YLOG_FATAL, + yaz_log(YLOG_FATAL, "But no ICU support is compiled into the YAZ library."); return 0; #endif // YAZ_HAVE_ICU @@ -286,14 +286,14 @@ pp2_charset_token_t pp2_charset_tokenize(pp2_charset_t pct) void pp2_charset_token_first(pp2_charset_token_t prt, const char *buf, int skip_article) -{ +{ if (skip_article) { const char *p = buf; char firstword[64]; char *pout = firstword; char articles[] = "the den der die des an a "; // must end in space - + for (; *p && *p != ' ' && pout - firstword < (sizeof(firstword)-2); p++) *pout++ = tolower(*(unsigned char *)p); *pout++ = ' '; @@ -322,9 +322,9 @@ void pp2_charset_token_destroy(pp2_charset_token_t prt) if (prt->iter) icu_iter_destroy(prt->iter); #endif - if(prt->norm_str) + if(prt->norm_str) wrbuf_destroy(prt->norm_str); - if(prt->sort_str) + if(prt->sort_str) wrbuf_destroy(prt->sort_str); xfree(prt); } @@ -385,7 +385,7 @@ static const char *pp2_get_sort_ascii(pp2_charset_token_t prt) char *tmp = xstrdup(prt->last_cp); char *result = 0; result = normalize7bit_mergekey(tmp); - + wrbuf_rewind(prt->sort_str); wrbuf_puts(prt->sort_str, result); xfree(tmp); diff --git a/src/client.c b/src/client.c index 9f86ce6..5a9f6fb 100644 --- a/src/client.c +++ b/src/client.c @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file client.c - \brief Z39.50 client + \brief Z39.50 client */ #if HAVE_CONFIG_H @@ -286,7 +286,7 @@ int client_show_raw_begin(struct client *cl, int position, if (!cl->connection) return -1; - + rr = xmalloc(sizeof(*rr)); rr->position = position; @@ -306,13 +306,13 @@ int client_show_raw_begin(struct client *cl, int position, assert(nativesyntax); rr->nativesyntax = xstrdup(nativesyntax); - + rr->next = 0; - + for (rrp = &cl->show_raw; *rrp; rrp = &(*rrp)->next) ; *rrp = rr; - + if (cl->state == Client_Failed) { client_show_raw_error(cl, "client failed"); @@ -533,7 +533,7 @@ void client_search_response(struct client *cl) ZOOM_resultset resultset = cl->resultset; const char *error, *addinfo = 0; - + if (ZOOM_connection_error(link, &error, &addinfo)) { cl->hits = 0; @@ -593,7 +593,7 @@ static void client_record_ingest(struct client *cl) NMEM nmem = nmem_create(); const char *xmlrec; char type[80]; - + const char *s = session_setting_oneval(sdb, PZ_NATIVESYNTAX); if (nativesyntax_to_type(s, type, rec)) yaz_log(YLOG_WARN, "Failed to determine record type"); @@ -673,7 +673,7 @@ static void client_set_facets_request(struct client *cl, ZOOM_connection link) struct session_database *sdb = client_get_database(cl); WRBUF w = wrbuf_alloc(); - + struct setting *s; for (s = sdb->settings[PZ_FACETMAP]; s; s = s->next) @@ -717,7 +717,7 @@ static const char *get_strategy_plus_sort(struct client *l, const char *field) struct setting *s; const char *strategy_plus_sort = 0; - + for (s = sdb->settings[PZ_SORTMAP]; s; s = s->next) { char *p = strchr(s->name + 3, ':'); @@ -825,7 +825,7 @@ void client_start_search(struct client *cl) else { yaz_log(YLOG_LOG, "Client %s: Search PQF: %s", client_get_id(cl), cl->pquery); - + ZOOM_query_prefix(q, cl->pquery); } if (se->sorted_results) @@ -902,7 +902,7 @@ struct client *client_create(const char *id) assert(id); cl->id = xstrdup(id); client_use(1); - + return cl; } @@ -1022,7 +1022,7 @@ static char *make_cqlquery(struct client *cl, Z_RPNQuery *zquery) else { r = xstrdup(wrbuf_cstr(wrb)); - } + } wrbuf_destroy(wrb); cql_transform_close(cqlt); return r; @@ -1036,7 +1036,7 @@ static char *make_solrquery(struct client *cl, Z_RPNQuery *zquery) char *r = 0; WRBUF wrb = wrbuf_alloc(); int status; - + if ((status = solr_transform_rpn2solr_wrbuf(sqlt, wrb, zquery))) { yaz_log(YLOG_WARN, "Failed to generate SOLR query, code=%d", status); @@ -1060,7 +1060,7 @@ const char *client_get_facet_limit_local(struct client *cl, for (; (name = facet_limits_get(cl->facet_limits, *l, &value)); (*l)++) { struct setting *s = 0; - + for (s = sdb->settings[PZ_LIMITMAP]; s; s = s->next) { const char *p = strchr(s->name + 3, ':'); @@ -1070,7 +1070,7 @@ const char *client_get_facet_limit_local(struct client *cl, const char *cp = s->value + 6; while (*cp == ' ') cp++; - + nmem_strsplit_escape2(nmem, "|", value, values, num, 1, '\\', 1); (*l)++; @@ -1135,7 +1135,7 @@ static int apply_limit(struct session_database *sdb, wrbuf_puts(ccl_w, values[i]); wrbuf_puts(ccl_w, "\""); - cn = ccl_find_str(ccl_map, wrbuf_cstr(ccl_w), + cn = ccl_find_str(ccl_map, wrbuf_cstr(ccl_w), &cerror, &cpos); if (cn) { @@ -1173,7 +1173,7 @@ static int apply_limit(struct session_database *sdb, nmem_destroy(nmem_tmp); return ret; } - + // Parse the query given the settings specific to this client // return 0 if query is OK but different from before // return 1 if query is OK but same as before @@ -1275,11 +1275,11 @@ int client_parse_query(struct client *cl, const char *query, ret_value = 0; } wrbuf_destroy(w_pqf); - + xfree(cl->cqlquery); cl->cqlquery = 0; - odr_out = odr_createmem(ODR_ENCODE); + odr_out = odr_createmem(ODR_ENCODE); zquery = p_query_rpn(odr_out, cl->pquery); if (!zquery) { @@ -1292,7 +1292,7 @@ int client_parse_query(struct client *cl, const char *query, { session_log(se, YLOG_LOG, "PQF for Client %s: %s", client_get_id(cl), cl->pquery); - + /* Support for PQF on SRU targets. */ if (strcmp(query_syntax, "pqf") != 0 && *sru) { diff --git a/src/client.h b/src/client.h index e5861b3..300caa7 100644 --- a/src/client.h +++ b/src/client.h @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file client.h - \brief Z39.50 client + \brief Z39.50 client */ #ifndef CLIENT_H diff --git a/src/connection.c b/src/connection.c index e441514..b456f0d 100644 --- a/src/connection.c +++ b/src/connection.c @@ -162,7 +162,7 @@ static void connection_destroy(struct connection *co) connection_use(-1); } -// Creates a new connection for client, associated with the host of +// Creates a new connection for client, associated with the host of // client's database static struct connection *connection_create(struct client *cl, struct host *host, @@ -182,7 +182,7 @@ static struct connection *connection_create(struct client *cl, co->state = Conn_Closed; co->operation_timeout = operation_timeout; co->session_timeout = session_timeout; - + if (host->ipport) connection_connect(co, iochan_man); @@ -210,11 +210,11 @@ static void non_block_events(struct connection *co) if (!cl) continue; ev = ZOOM_connection_last_event(link); - + #if 1 yaz_log(YLOG_DEBUG, "%p Connection ZOOM_EVENT_%s", co, ZOOM_get_event_str(ev)); #endif - switch (ev) + switch (ev) { case ZOOM_EVENT_END: { @@ -308,7 +308,7 @@ static void connection_handler(IOCHAN iochan, int event) yaz_mutex_enter(host->mutex); cl = co->client; - if (!cl) + if (!cl) { /* no client associated with it.. We are probably getting a closed connection from the target.. Or, perhaps, an unexpected @@ -345,7 +345,7 @@ static void connection_handler(IOCHAN iochan, int event) non_block_events(co); ZOOM_connection_fire_event_socket(co->link, event); - + non_block_events(co); client_unlock(cl); @@ -435,10 +435,10 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) ZOOM_options_set(zoptions, "async", "1"); ZOOM_options_set(zoptions, "implementationName", PACKAGE_NAME); ZOOM_options_set(zoptions, "implementationVersion", VERSION); - + if ((charset = session_setting_oneval(sdb, PZ_NEGOTIATION_CHARSET))) ZOOM_options_set(zoptions, "charset", charset); - + assert(host->ipport); if (host->proxy) { @@ -450,7 +450,7 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) assert(host->tproxy); yaz_log(YLOG_LOG, "tproxy=%s", host->ipport); ZOOM_options_set(zoptions, "tproxy", host->ipport); - } + } if (apdulog && *apdulog) ZOOM_options_set(zoptions, "apdulog", apdulog); @@ -459,7 +459,7 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) ZOOM_options_set(zoptions, "user", auth); if ((sru = session_setting_oneval(sdb, PZ_SRU)) && *sru) ZOOM_options_set(zoptions, "sru", sru); - if ((sru_version = session_setting_oneval(sdb, PZ_SRU_VERSION)) + if ((sru_version = session_setting_oneval(sdb, PZ_SRU_VERSION)) && *sru_version) ZOOM_options_set(zoptions, "sru_version", sru_version); if (!(con->link = ZOOM_connection_create(zoptions))) @@ -541,7 +541,7 @@ int client_prep_connection(struct client *cl, PZ_MAX_CONNECTIONS); if (v && *v) max_connections = atoi(v); - + v = session_setting_oneval(client_get_database(cl), PZ_REUSE_CONNECTIONS); if (v && *v) diff --git a/src/database.c b/src/database.c index 2940c25..a29fc06 100644 --- a/src/database.c +++ b/src/database.c @@ -99,7 +99,7 @@ struct database *create_database_for_service(const char *id, for (p = service->databases; p; p = p->next) if (!strcmp(p->id, id)) return p; - + yaz_log(YLOG_DEBUG, "new database %s under service %s", id, service->id ? service->id : "null"); p = new_database_inherit_settings(id, service->nmem, service->settings); @@ -142,7 +142,7 @@ int match_zurl(const char *zurl, const char *pattern) // This will be generalized at some point static int match_criterion(struct setting **settings, - struct conf_service *service, + struct conf_service *service, struct database_criterion *c) { int offset = settings_lookup_offset(service, c->name); @@ -164,12 +164,12 @@ static int match_criterion(struct setting **settings, if (match_zurl(settings[offset]->value, v->value)) break; } - else + else { if (!strcmp(settings[offset]->value, v->value)) break; } - } + } else if (c->type == PAZPAR2_SUBSTRING_MATCH) { if (strstr(settings[offset]->value, v->value)) diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index 6a31e61..6dca551 100644 --- a/src/getaddrinfo.c +++ b/src/getaddrinfo.c @@ -99,7 +99,7 @@ void perform_getaddrinfo(struct work *w) // returns AF_INET address. if ((res = getaddrinfo(hostport, port, &hints, &addrinfo))) { - yaz_log(YLOG_WARN, "Failed to resolve %s %s", + yaz_log(YLOG_WARN, "Failed to resolve %s %s", w->hostport, gai_strerror(res)); } else @@ -107,7 +107,7 @@ void perform_getaddrinfo(struct work *w) char ipport[128]; unsigned char addrbuf[4]; assert(addrinfo->ai_family == PF_INET); - memcpy(addrbuf, + memcpy(addrbuf, &((struct sockaddr_in*)addrinfo->ai_addr)->sin_addr.s_addr, 4); sprintf(ipport, "%u.%u.%u.%u:%s", addrbuf[0], addrbuf[1], addrbuf[2], addrbuf[3], port); @@ -170,7 +170,7 @@ static sel_thread_t resolver_thread = 0; static void getaddrinfo_start(iochan_man_t iochan_man) { int fd; - sel_thread_t p = resolver_thread = + sel_thread_t p = resolver_thread = sel_thread_create(work_handler, 0 /* work_destroy */, &fd, 3 /* no of resolver threads */); if (!p) diff --git a/src/host.c b/src/host.c index 7af0c07..9daabc2 100644 --- a/src/host.c +++ b/src/host.c @@ -55,7 +55,7 @@ static struct host *create_host(const char *url, const char *proxy, else { char *cp; - + host->tproxy = xmalloc (strlen(url) + 10); /* so we can add :port */ strcpy(host->tproxy, url); for (cp = host->tproxy; *cp; cp++) diff --git a/src/http.c b/src/http.c index c0f9596..05b2119 100644 --- a/src/http.c +++ b/src/http.c @@ -696,12 +696,12 @@ static int http_weshouldproxy(struct http_request *rq) } -struct http_header * http_header_append(struct http_channel *ch, - struct http_header * hp, - const char *name, +struct http_header * http_header_append(struct http_channel *ch, + struct http_header * hp, + const char *name, const char *value) { - struct http_header *hpnew = 0; + struct http_header *hpnew = 0; if (!hp | !ch) return 0; @@ -713,18 +713,18 @@ struct http_header * http_header_append(struct http_channel *ch, hpnew = nmem_malloc(ch->nmem, sizeof *hpnew); hpnew->name = nmem_strdup(ch->nmem, name); hpnew->value = nmem_strdup(ch->nmem, value); - + hpnew->next = 0; hp->next = hpnew; hp = hp->next; - + return hpnew; } return hp; } - + static int is_inprogress(void) { #ifdef WIN32 @@ -735,7 +735,7 @@ static int is_inprogress(void) return 1; #endif return 0; -} +} static void enable_nonblock(int sock) { @@ -745,7 +745,7 @@ static void enable_nonblock(int sock) if (ioctlsocket(sock, FIONBIO, &flags) < 0) yaz_log(YLOG_FATAL|YLOG_ERRNO, "ioctlsocket"); #else - if ((flags = fcntl(sock, F_GETFL, 0)) < 0) + if ((flags = fcntl(sock, F_GETFL, 0)) < 0) yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl"); if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) yaz_log(YLOG_FATAL|YLOG_ERRNO, "fcntl2"); @@ -780,10 +780,10 @@ static int http_proxy(struct http_request *rq) abort(); enable_nonblock(sock); if (connect(sock, (struct sockaddr *) - c->server->http_server->proxy_addr, + c->server->http_server->proxy_addr, sizeof(*c->server->http_server->proxy_addr)) < 0) { - if (!is_inprogress()) + if (!is_inprogress()) { yaz_log(YLOG_WARN|YLOG_ERRNO, "Proxy connect"); return -1; @@ -808,27 +808,27 @@ static int http_proxy(struct http_request *rq) yaz_log(YLOG_WARN, "Failed to find Host header in proxy"); return -1; } - + // Add new header about paraz2 version, host, remote client address, etc. { char server_via[128]; hp = rq->headers; - hp = http_header_append(c, hp, + hp = http_header_append(c, hp, "X-Pazpar2-Version", PACKAGE_VERSION); - hp = http_header_append(c, hp, + hp = http_header_append(c, hp, "X-Pazpar2-Server-Host", ser->host); sprintf(server_port, "%d", ser->port); - hp = http_header_append(c, hp, + hp = http_header_append(c, hp, "X-Pazpar2-Server-Port", server_port); - yaz_snprintf(server_via, sizeof(server_via), - "1.1 %s:%s (%s/%s)", + yaz_snprintf(server_via, sizeof(server_via), + "1.1 %s:%s (%s/%s)", ser->host ? ser->host : "@", server_port, PACKAGE_NAME, PACKAGE_VERSION); hp = http_header_append(c, hp, "Via" , server_via); hp = http_header_append(c, hp, "X-Forwarded-For", c->addr); } - + requestbuf = http_serialize_request(rq); http_buf_enqueue(&p->oqueue, requestbuf); @@ -881,7 +881,7 @@ static void http_io(IOCHAN i, int event) { int res, reqlen; struct http_buf *htbuf; - + htbuf = http_buf_create(hc->http_server); res = recv(iochan_getfd(i), htbuf->buf, HTTP_BUF_SIZE -1, 0); if (res == -1 && errno == EAGAIN) @@ -1014,7 +1014,7 @@ static void http_io(IOCHAN i, int event) } } } - if (!hc->oqueue && hc->proxy && !hc->proxy->iochan) + if (!hc->oqueue && hc->proxy && !hc->proxy->iochan) http_channel_destroy(i); // Server closed; we're done } else @@ -1086,7 +1086,7 @@ static void proxy_io(IOCHAN pi, int event) return; } if (res == htbuf->len) - { + { struct http_buf *np = htbuf->next; http_buf_destroy(hc->http_server, htbuf); pc->oqueue = np; @@ -1205,7 +1205,7 @@ static void http_accept(IOCHAN i, int event) yaz_log(YLOG_DEBUG, "New command connection"); c = iochan_create(s, http_io, EVENT_INPUT | EVENT_EXCEPT, "http_session_socket"); - + ch = http_channel_create(server->http_server, inet_ntoa(addr.sin_addr), server); ch->iochan = c; @@ -1277,12 +1277,12 @@ int http_init(const char *addr, struct conf_server *server, &one, sizeof(one)) < 0) return 1; - if (bind(l, (struct sockaddr *) &myaddr, sizeof myaddr) < 0) + if (bind(l, (struct sockaddr *) &myaddr, sizeof myaddr) < 0) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "bind"); return 1; } - if (listen(l, SOMAXCONN) < 0) + if (listen(l, SOMAXCONN) < 0) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "listen"); return 1; diff --git a/src/http.h b/src/http.h index 06ccf76..1670766 100644 --- a/src/http.h +++ b/src/http.h @@ -107,13 +107,13 @@ void http_set_proxyaddr(const char *url, struct conf_server *ser); int http_init(const char *addr, struct conf_server *ser, const char *record_fname); void http_close_server(struct conf_server *ser); -void http_addheader(struct http_response *r, +void http_addheader(struct http_response *r, const char *name, const char *value); const char *http_lookup_header(struct http_header *header, const char *name); -struct http_header * http_header_append(struct http_channel *ch, - struct http_header * hp, - const char *name, +struct http_header * http_header_append(struct http_channel *ch, + struct http_header * hp, + const char *name, const char *value); const char *http_argbyname(struct http_request *r, const char *name); const char *http_headerbyname(struct http_header *r, const char *name); diff --git a/src/http_command.c b/src/http_command.c index 7676eef..a75538f 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -49,16 +49,16 @@ void print_meminfo(WRBUF wrbuf) struct mallinfo minfo; minfo = mallinfo(); wrbuf_printf(wrbuf, " \n" - " %d\n" + " %d\n" " %d\n" " %d\n" " %d\n" " %d\n" - " %d\n" + " %d\n" " %d\n" " %d\n" " %d\n" - " \n", + " \n", minfo.arena, minfo.uordblks, minfo.fordblks,minfo.ordblks, minfo.keepcost, minfo.hblks, minfo.hblkhd, minfo.arena + minfo.hblkhd, minfo.uordblks + minfo.hblkhd); } @@ -253,7 +253,7 @@ static const char *get_msg(enum pazpar2_error_code code) return "No error"; } -static void error(struct http_response *rs, +static void error(struct http_response *rs, enum pazpar2_error_code code, const char *addinfo) { @@ -261,7 +261,7 @@ static void error(struct http_response *rs, WRBUF text = wrbuf_alloc(); const char *http_status = "417"; const char *msg = get_msg(code); - + rs->msg = nmem_strdup(c->nmem, msg); strcpy(rs->code, http_status); @@ -320,7 +320,7 @@ unsigned int make_sessionid(void) yaz_log(YLOG_WARN|YLOG_ERRNO, "gettimeofday"); exit(1); } - /* at most 256 sessions per second .. + /* at most 256 sessions per second .. (long long would be more appropriate)*/ res = t.tv_sec; res = ((res << 8) | (seq & 0xff)) & ((1U << 31) - 1); @@ -417,8 +417,8 @@ static void cmd_init(struct http_channel *c) struct http_session *s; struct http_response *rs = c->response; struct conf_service *service = 0; /* no service (yet) */ - - if (r->content_len && content_type && + + if (r->content_len && content_type && !yaz_strcmp_del("text/xml", content_type, "; ")) { xmlDoc *doc = xmlParseMemory(r->content_buf, r->content_len); @@ -437,7 +437,7 @@ static void cmd_init(struct http_channel *c) return; } } - + if (!service) { const char *service_name = http_argbyname(c->request, "service"); @@ -450,13 +450,13 @@ static void cmd_init(struct http_channel *c) } sesid = make_sessionid(); s = http_session_create(service, c->http_sessions, sesid); - + yaz_log(c->http_sessions->log_level, "Session init %u ", sesid); if (!clear || *clear == '0') session_init_databases(s->psession); else yaz_log(YLOG_LOG, "Session %u init: No databases preloaded", sesid); - + if (process_settings(s->psession, c->request, c->response) < 0) return; @@ -469,7 +469,7 @@ static void cmd_init(struct http_channel *c) } wrbuf_puts(c->wrbuf, "" "" PAZPAR2_PROTOCOL_VERSION ""); - + wrbuf_printf(c->wrbuf, "%d\n", 1000 * ((s->psession->service->session_timeout >= 20) ? (s->psession->service->session_timeout - 10) : 50)); response_close(c, "init"); @@ -495,7 +495,7 @@ static void cmd_settings(struct http_channel *c) if (!s) return; - if (rq->content_len && content_type && + if (rq->content_len && content_type && !yaz_strcmp_del("text/xml", content_type, "; ")) { xmlDoc *doc = xmlParseMemory(rq->content_buf, rq->content_len); @@ -515,7 +515,7 @@ static void cmd_settings(struct http_channel *c) error(rs, PAZPAR2_MALFORMED_SETTING, 0); release_session(c,s); return; - } + } } if (process_settings(s->psession, rq, rs) < 0) { @@ -715,7 +715,7 @@ static void bytarget_response(struct http_channel *c, struct http_session *s, co wrbuf_xmlputs(c->wrbuf, ht[i].id); wrbuf_puts(c->wrbuf, "\n"); - if (ht[i].name && ht[i].name[0]) + if (ht[i].name && ht[i].name[0]) { wrbuf_puts(c->wrbuf, ""); wrbuf_xmlputs(c->wrbuf, ht[i].name); @@ -948,7 +948,7 @@ static void show_record(struct http_channel *c, struct http_session *s) const char *offsetstr = http_argbyname(rq, "offset"); const char *binarystr = http_argbyname(rq, "binary"); const char *checksumstr = http_argbyname(rq, "checksum"); - + if (!s) return; service = s->psession->service; @@ -979,7 +979,7 @@ static void show_record(struct http_channel *c, struct http_session *s) struct record*r = rec->records; int binary = 0; const char *nativesyntax = http_argbyname(rq, "nativesyntax"); - + if (binarystr && *binarystr != '0') binary = 1; @@ -1008,8 +1008,8 @@ static void show_record(struct http_channel *c, struct http_session *s) syntax, esn, obs /* data */, show_raw_record_error, - (binary ? - show_raw_record_ok_binary : + (binary ? + show_raw_record_ok_binary : show_raw_record_ok), (binary ? 1 : 0), nativesyntax); @@ -1039,7 +1039,7 @@ static void show_record(struct http_channel *c, struct http_session *s) wrbuf_xmlputs(c->wrbuf, next_r->recid); wrbuf_puts(c->wrbuf, "\n"); } - wrbuf_printf(c->wrbuf, "%d\n", + wrbuf_printf(c->wrbuf, "%d\n", session_active_clients(s->psession)); write_metadata(c->wrbuf, service, rec->metadata, 1); for (r = rec->records; r; r = r->next) @@ -1107,7 +1107,7 @@ static void show_records(struct http_channel *c, struct http_session *s, int act return; } - + rl = show_range_start(s->psession, sp, startn, &numn, &total, &total_hits, &approx_hits); response_open(c, "show"); @@ -1175,13 +1175,13 @@ static void cmd_show(struct http_channel *c) int report_error = 0; if (block_error && !strcmp("1", block_error)) { report_error = 1; - } + } if (!s) return; if (!sort) sort = "relevance"; - + if (!(sp = reclist_parse_sortparms(c->nmem, sort, s->psession->service))) { error(c->response, PAZPAR2_MALFORMED_PARAMETER_VALUE, "sort"); @@ -1209,7 +1209,7 @@ static void cmd_show(struct http_channel *c) } else { - yaz_log(YLOG_WARN, "Session %u: Attempt to block multiple times on show (preferred targets) block. Not supported!", + yaz_log(YLOG_WARN, "Session %u: Attempt to block multiple times on show (preferred targets) block. Not supported!", s->session_id); if (report_error) { error(rs, PAZPAR2_ALREADY_BLOCKED, "show (preferred targets)"); @@ -1358,7 +1358,7 @@ static void cmd_info(struct http_channel *c) wrbuf_puts(c->wrbuf, "\n"); wrbuf_puts(c->wrbuf, " \n"); - + info_services(c->server, c->wrbuf); response_close(c, "info"); diff --git a/src/jenkins_hash.c b/src/jenkins_hash.c index b2b330d..ecfa6f3 100644 --- a/src/jenkins_hash.c +++ b/src/jenkins_hash.c @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** \file +/** \file \brief Jenkins hash function */ diff --git a/src/marchash.c b/src/marchash.c index 3ca63d1..5771929 100644 --- a/src/marchash.c +++ b/src/marchash.c @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** \file +/** \file \brief MARC MAP utilities (hash lookup etc) */ @@ -116,7 +116,7 @@ void marchash_ingest_marcxml(struct marchash *marchash, xmlNodePtr rec_node) if (field) { sub_node = field_node->children; - while (sub_node) + while (sub_node) { if ((sub_node->type == XML_ELEMENT_NODE) && !strcmp((const char *) sub_node->name, "subfield")) @@ -131,7 +131,7 @@ void marchash_ingest_marcxml(struct marchash *marchash, xmlNodePtr rec_node) xmlFree(code); } sub_node = sub_node->next; - } + } } } field_node = field_node->next; @@ -144,15 +144,15 @@ struct marcfield *marchash_add_field(struct marchash *marchash, int slot; struct marcfield *new; struct marcfield *last; - + slot = jenkins_hash((const unsigned char *) key) & MARCHASH_MASK; new = marchash->table[slot]; last = NULL; - - while (new) + + while (new) { - last = new; - new = new->next; + last = new; + new = new->next; } new = nmem_malloc(marchash->nmem, sizeof (struct marcfield)); @@ -165,8 +165,8 @@ struct marcfield *marchash_add_field(struct marchash *marchash, new->next = NULL; new->subfields = NULL; strncpy(new->key, key, 4); - - // only 3 char in a marc field name + + // only 3 char in a marc field name if (new->key[3] != '\0') return 0; @@ -211,7 +211,7 @@ struct marcfield *marchash_get_field (struct marchash *marchash, struct marcfield *cur; if (last) cur = last->next; - else + else cur = marchash->table[jenkins_hash((const unsigned char *)key) & MARCHASH_MASK]; while (cur) { @@ -253,9 +253,9 @@ char *marchash_catenate_subfields(struct marcfield *field, { outsize += strlen(cur->val) + delimsize; cur = cur->next; - } + } if (outsize > 0) - output = nmem_malloc(nmem, outsize); + output = nmem_malloc(nmem, outsize); else return NULL; *output = '\0'; @@ -264,9 +264,9 @@ char *marchash_catenate_subfields(struct marcfield *field, { strtrimcat(output, cur->val); if (cur->next) - strcat(output, delim); + strcat(output, delim); cur = cur->next; - } + } return output; } /* diff --git a/src/marcmap.c b/src/marcmap.c index 5c4a3f2..b10b464 100644 --- a/src/marcmap.c +++ b/src/marcmap.c @@ -55,18 +55,18 @@ struct marcmap *marcmap_load(const char *filename, NMEM nmem) mmhead = NULL; fp = fopen(filename, "r"); - while ((c = getc(fp) ) != EOF) + while ((c = getc(fp) ) != EOF) { // allocate some space if (newrec) { - if (mm != NULL) + if (mm != NULL) { mm->next = nmem_malloc(nmem, sizeof(struct marcmap)); mm = mm->next; } // first one! - else + else { mm = nmem_malloc(nmem, sizeof(struct marcmap)); mmhead = mm; } @@ -93,8 +93,8 @@ struct marcmap *marcmap_load(const char *filename, NMEM nmem) mm->subfield = buf[len-2]; } // third, pz fieldname - else if (field == 2) - { + else if (field == 2) + { mm->pz = nmem_malloc(nmem, len * sizeof(char)); strncpy(mm->pz, buf, len); } @@ -131,17 +131,17 @@ xmlDoc *marcmap_apply(struct marcmap *marcmap, xmlDoc *xml_in) xmlDocPtr xml_out; xmlNodePtr xml_out_root; xmlNodePtr rec_node; - xmlNodePtr meta_node; + xmlNodePtr meta_node; struct marchash *marchash; struct marcfield *field; struct marcsubfield *subfield; struct marcmap *mmcur; - + xml_out = xmlNewDoc(BAD_CAST "1.0"); xml_out->encoding = xmlCharStrdup("UTF-8"); xml_out_root = xmlNewNode(NULL, BAD_CAST "record"); xmlDocSetRootElement(xml_out, xml_out_root); - ns_pz = xmlNewNs(xml_out_root, BAD_CAST "http://www.indexdata.com/pazpar2/1.0", BAD_CAST "pz"); + ns_pz = xmlNewNs(xml_out_root, BAD_CAST "http://www.indexdata.com/pazpar2/1.0", BAD_CAST "pz"); xmlSetNs(xml_out_root, ns_pz); nmem = nmem_create(); rec_node = xmlDocGetRootElement(xml_in); @@ -158,7 +158,7 @@ xmlDoc *marcmap_apply(struct marcmap *marcmap, xmlDoc *xml_in) if ((mmcur->subfield == '$') && (s = field->val)) { meta_node = xmlNewChild(xml_out_root, ns_pz, BAD_CAST "metadata", BAD_CAST s); - xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST mmcur->pz); + xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST mmcur->pz); } // catenate all subfields else if ((mmcur->subfield == '*') && (s = marchash_catenate_subfields(field, " ", nmem))) @@ -167,10 +167,10 @@ xmlDoc *marcmap_apply(struct marcmap *marcmap, xmlDoc *xml_in) xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST mmcur->pz); } // subfield value - else if (mmcur->subfield) + else if (mmcur->subfield) { subfield = 0; - while ((subfield = + while ((subfield = marchash_get_subfield(mmcur->subfield, field, subfield)) != 0) { @@ -181,7 +181,7 @@ xmlDoc *marcmap_apply(struct marcmap *marcmap, xmlDoc *xml_in) } } } - + } mmcur = mmcur->next; } diff --git a/src/normalize7bit.c b/src/normalize7bit.c index a45b816..3087182 100644 --- a/src/normalize7bit.c +++ b/src/normalize7bit.c @@ -63,7 +63,7 @@ char *normalize7bit_mergekey(char *buf) *(pout--) = '\0'; } while (pout > buf && *pout == ' '); - + return buf; } diff --git a/src/normalize_record.c b/src/normalize_record.c index 90876e5..9a81fb3 100644 --- a/src/normalize_record.c +++ b/src/normalize_record.c @@ -71,8 +71,8 @@ normalize_record_t normalize_record_create(struct conf_service *service, (*m)->marcmap = NULL; (*m)->stylesheet = NULL; (*m)->stylesheet2 = NULL; - - + + (*m)->stylesheet = xsltParseStylesheetDoc(xsp_doc); if (!(*m)->stylesheet) no_errors++; @@ -89,16 +89,16 @@ normalize_record_t normalize_record_create(struct conf_service *service, for (i = 0; i < num; i++) { WRBUF fname = conf_get_fname(conf, stylesheets[i]); - + *m = nmem_malloc(nt->nmem, sizeof(**m)); (*m)->marcmap = NULL; (*m)->stylesheet = NULL; - + (*m)->stylesheet2 = service_xslt_get(service, stylesheets[i]); if ((*m)->stylesheet2) ; - else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl")) - { + else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl")) + { if (!((*m)->stylesheet = xsltParseStylesheetFile((xmlChar *) wrbuf_cstr(fname)))) { @@ -121,7 +121,7 @@ normalize_record_t normalize_record_create(struct conf_service *service, yaz_log(YLOG_FATAL, "Cannot handle stylesheet: %s", stylesheets[i]); no_errors++; } - + wrbuf_destroy(fname); m = &(*m)->next; } @@ -170,7 +170,7 @@ int normalize_record_transform(normalize_record_t nt, xmlDoc **doc, ndoc = 0; xmlFreeDoc(*doc); *doc = 0; - + if (ndoc) root = xmlDocGetRootElement(ndoc); diff --git a/src/pazpar2.c b/src/pazpar2.c index f1a24bc..6afccf1 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -58,7 +58,7 @@ void child_handler(void *data) static void show_version(void) { char yaz_version_str[80]; - printf("Pazpar2 " PACKAGE_VERSION + printf("Pazpar2 " PACKAGE_VERSION #ifdef PAZPAR2_VERSION_SHA1 " " PAZPAR2_VERSION_SHA1 @@ -76,7 +76,7 @@ static void show_version(void) printf(" yaz:%s", yaz_version_str); printf("\n"); exit(0); -} +} #ifdef WIN32 static int tcpip_init (void) @@ -93,7 +93,7 @@ static int tcpip_init (void) static int sc_main( - yaz_sc_t s, + yaz_sc_t s, int argc, char **argv) { int daemon = 0; @@ -164,7 +164,7 @@ static int sc_main( #else chdir #endif - (arg)) + (arg)) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "chdir %s", arg); return 1; @@ -203,7 +203,7 @@ static int sc_main( return 1; } pazpar2_mutex_init(); - + config = config_create(config_fname, global_parameters.dump_records); if (!config) return 1; @@ -231,9 +231,9 @@ static int sc_main( ret = config_start_listeners(config, listener_override, record_fname); if (ret) return ret; /* error starting http listener */ - + yaz_sc_running(s); - + yaz_daemon("pazpar2", (global_parameters.debug_mode ? YAZ_DAEMON_DEBUG : 0) + (daemon ? YAZ_DAEMON_FORK : 0) + YAZ_DAEMON_KEEPALIVE, @@ -253,7 +253,7 @@ int main(int argc, char **argv) { int ret; yaz_sc_t s = yaz_sc_create("pazpar2", "Pazpar2"); - + #ifdef MTRACE mtrace(); #endif diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index b45d8ec..6e7652c 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -50,7 +50,7 @@ struct conf_config { NMEM nmem; /* for conf_config and servers memory */ struct conf_server *servers; - + int no_threads; WRBUF confdir; iochan_man_t iochan_man; @@ -63,8 +63,8 @@ struct service_xslt xsltStylesheetPtr xsp; struct service_xslt *next; }; - -static void conf_metadata_assign(NMEM nmem, + +static void conf_metadata_assign(NMEM nmem, struct conf_metadata * metadata, const char *name, enum conf_metadata_type type, @@ -79,7 +79,7 @@ static void conf_metadata_assign(NMEM nmem, const char *limitmap) { assert(nmem && metadata && name); - + metadata->name = nmem_strdup(nmem, name); metadata->type = type; @@ -88,10 +88,10 @@ static void conf_metadata_assign(NMEM nmem, if (metadata->type == Metadata_type_year) metadata->merge = Metadata_merge_range; else - metadata->merge = merge; + metadata->merge = merge; metadata->setting = setting; - metadata->brief = brief; + metadata->brief = brief; metadata->termlist = termlist; metadata->rank = nmem_strdup_null(nmem, rank); metadata->sortkey_offset = sortkey_offset; @@ -101,13 +101,13 @@ static void conf_metadata_assign(NMEM nmem, } -static void conf_sortkey_assign(NMEM nmem, +static void conf_sortkey_assign(NMEM nmem, struct conf_sortkey * sortkey, const char *name, enum conf_sortkey_type type) { assert(nmem && sortkey && name); - + sortkey->name = nmem_strdup(nmem, name); sortkey->type = type; } @@ -152,18 +152,18 @@ struct conf_service *service_init(struct conf_server *server, service->metadata = 0; if (service->num_metadata) - service->metadata - = nmem_malloc(nmem, + service->metadata + = nmem_malloc(nmem, sizeof(struct conf_metadata) * service->num_metadata); service->num_sortkeys = num_sortkeys; service->sortkeys = 0; if (service->num_sortkeys) - service->sortkeys - = nmem_malloc(nmem, + service->sortkeys + = nmem_malloc(nmem, sizeof(struct conf_sortkey) * service->num_sortkeys); - return service; + return service; } static struct conf_metadata* conf_service_add_metadata( @@ -221,7 +221,7 @@ int conf_service_metadata_field_id(struct conf_service *service, if (!service || !service->metadata || !service->num_metadata) return -1; - + for (i = 0; i < service->num_metadata; i++) if (!strcmp(name, (service->metadata[i]).name)) return i; @@ -339,7 +339,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, return -1; } } - + // now do the parsing logic if (!xml_name) { @@ -356,7 +356,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, return -1; } } - + if (xml_termlist) { if (!strcmp((const char *) xml_termlist, "yes")) @@ -367,7 +367,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, return -1; } } - + if (xml_type) { if (!strcmp((const char *) xml_type, "generic")) @@ -378,12 +378,12 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, type = Metadata_type_date; else { - yaz_log(YLOG_FATAL, + yaz_log(YLOG_FATAL, "Unknown value for metadata/type: %s", xml_type); return -1; } } - + if (xml_merge) { if (!strcmp((const char *) xml_merge, "no")) @@ -398,12 +398,12 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, merge = Metadata_merge_all; else { - yaz_log(YLOG_FATAL, + yaz_log(YLOG_FATAL, "Unknown value for metadata/merge: %s", xml_merge); return -1; } } - + if (xml_setting) { if (!strcmp((const char *) xml_setting, "no")) @@ -419,14 +419,14 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, return -1; } } - + // add a sortkey if so specified if (xml_sortkey && strcmp((const char *) xml_sortkey, "no")) { enum conf_sortkey_type sk_type; if (merge == Metadata_merge_no) { - yaz_log(YLOG_FATAL, + yaz_log(YLOG_FATAL, "Can't specify sortkey on a non-merged field"); return -1; } @@ -437,19 +437,19 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, else { yaz_log(YLOG_FATAL, - "Unknown sortkey in metadata element: %s", + "Unknown sortkey in metadata element: %s", xml_sortkey); return -1; } sortkey_offset = *sk_node; - + conf_service_add_sortkey(service, *sk_node, - (const char *) xml_name, sk_type); + (const char *) xml_name, sk_type); (*sk_node)++; } else sortkey_offset = -1; - + if (xml_mergekey) { if (!strcmp((const char *) xml_mergekey, "required")) @@ -490,7 +490,7 @@ static struct conf_service *service_create_static(struct conf_server *server, int num_metadata = 0; int num_sortkeys = 0; int got_settings = 0; - + // count num_metadata and num_sortkeys for (n = node->children; n; n = n->next) if (n->type == XML_ELEMENT_NODE && !strcmp((const char *) @@ -559,7 +559,7 @@ static struct conf_service *service_create_static(struct conf_server *server, } value = (char *) xmlGetProp(n, (xmlChar *) "value"); if (!value) - { + { xmlFree(name); yaz_log(YLOG_FATAL, "ccldirective: missing @value"); return 0; @@ -692,7 +692,7 @@ static int inherit_server_settings(struct conf_service *s) init_settings(s); } } - + /* use relevance/sort/mergekey/facet from server if not defined for this service.. */ if (!s->charsets) @@ -824,8 +824,8 @@ static struct conf_server *server_create(struct conf_config *config, { yaz_log(YLOG_FATAL, "ICU chain definition error"); return 0; - } - } + } + } else if (!strcmp((const char *) n->name, "service")) { char *service_id = (char *) @@ -982,7 +982,7 @@ struct conf_config *config_create(const char *fname, int verbose) config->database_hosts = database_hosts_create(); config->confdir = wrbuf_alloc(); - if ((p = strrchr(fname, + if ((p = strrchr(fname, #ifdef WIN32 '\\' #else @@ -994,7 +994,7 @@ struct conf_config *config_create(const char *fname, int verbose) wrbuf_write(config->confdir, fname, len); } wrbuf_puts(config->confdir, ""); - + n = xmlDocGetRootElement(doc); r = yaz_xml_include_simple(n, wrbuf_cstr(config->confdir)); if (r == 0) /* OK */ @@ -1040,7 +1040,7 @@ void config_destroy(struct conf_config *config) if (config) { struct conf_server *server = config->servers; - iochan_man_destroy(&config->iochan_man); + iochan_man_destroy(&config->iochan_man); while (server) { struct conf_server *s_next = server->next; @@ -1063,7 +1063,7 @@ void config_stop_listeners(struct conf_config *conf) void config_process_events(struct conf_config *conf) { struct conf_server *ser; - + for (ser = conf->servers; ser; ser = ser->next) { struct conf_service *s = ser->service; diff --git a/src/pazpar2_config.h b/src/pazpar2_config.h index 42e7c03..f3960b2 100644 --- a/src/pazpar2_config.h +++ b/src/pazpar2_config.h @@ -69,7 +69,7 @@ enum conf_metadata_mergekey { // An array of these structure provides a 'map' against which // discovered metadata elements are matched. It also governs storage, // to minimize number of cycles needed at various tages of processing -struct conf_metadata +struct conf_metadata { char *name; // The field name. Output by normalization stylesheet int brief; // Is this element to be returned in the brief format? diff --git a/src/pazpar2_play.c b/src/pazpar2_play.c index d5455dd..2669ed6 100644 --- a/src/pazpar2_play.c +++ b/src/pazpar2_play.c @@ -86,7 +86,7 @@ static int run(FILE *inf, struct addrinfo *res) } else spec.tv_usec = tv_usec1 - tv_usec0; - + select(0, 0, 0, 0, &spec); } tv_sec0 = tv_sec1; @@ -213,7 +213,7 @@ int main(int argc, char **argv) hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; - + cp = strchr(host, ':'); if (*cp) { diff --git a/src/reclists.c b/src/reclists.c index 201dab6..60df921 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -72,7 +72,7 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, if (!(cpp = strchr(parms, ','))) cpp = parms + strlen(parms); - strncpy(parm, parms, cpp - parms); + strncpy(parm, parms, cpp - parms); parm[cpp-parms] = '\0'; if ((pp = strchr(parm, ':'))) @@ -86,7 +86,7 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, yaz_log(YLOG_FATAL, "Bad sortkey modifier: %s", parm); return 0; } - + if (pp[2]) { if (pp[2] == 'p') @@ -101,7 +101,7 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, if (!strcmp(parm, "relevance")) { type = Metadata_sortkey_relevance; - } + } else if (!strcmp(parm, "position")) { type = Metadata_sortkey_position; @@ -143,7 +143,7 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, static int reclist_cmp(const void *p1, const void *p2) { - struct reclist_sortparms *sortparms = + struct reclist_sortparms *sortparms = (*(struct reclist_bucket **) p1)->sort_parms; struct record_cluster *r1 = (*(struct reclist_bucket**) p1)->record; struct record_cluster *r2 = (*(struct reclist_bucket**) p2)->record; @@ -276,7 +276,7 @@ struct reclist *reclist_create(NMEM nmem) { struct reclist *res = nmem_malloc(nmem, sizeof(struct reclist)); res->hash_size = 399; - res->hashtable + res->hashtable = nmem_malloc(nmem, res->hash_size * sizeof(struct reclist_bucket*)); memset(res->hashtable, 0, res->hash_size * sizeof(struct reclist_bucket*)); res->nmem = nmem; @@ -306,14 +306,14 @@ int reclist_get_num_records(struct reclist *l) // Insert a record. Return record cluster (newly formed or pre-existing) struct record_cluster *reclist_insert(struct reclist *l, - struct conf_service *service, + struct conf_service *service, struct record *record, const char *merge_key, int *total) { unsigned int bucket; struct reclist_bucket **p; struct record_cluster *cluster = 0; - + assert(service); assert(l); assert(record); @@ -335,7 +335,7 @@ struct record_cluster *reclist_insert(struct reclist *l, { if (re->client == record->client && record_compare(record, re, service)) - { + { yaz_mutex_leave(l->mutex); return 0; } @@ -352,7 +352,7 @@ struct record_cluster *reclist_insert(struct reclist *l, nmem_malloc(l->nmem, sizeof(*new)); cluster = nmem_malloc(l->nmem, sizeof(*cluster)); - + record->next = 0; new->record = cluster; new->hnext = 0; @@ -365,15 +365,15 @@ struct record_cluster *reclist_insert(struct reclist *l, cluster->metadata = nmem_malloc(l->nmem, sizeof(struct record_metadata*) * service->num_metadata); - memset(cluster->metadata, 0, + memset(cluster->metadata, 0, sizeof(struct record_metadata*) * service->num_metadata); - cluster->sortkeys = + cluster->sortkeys = nmem_malloc(l->nmem, sizeof(struct record_metadata*) * service->num_sortkeys); memset(cluster->sortkeys, 0, sizeof(union data_types*) * service->num_sortkeys); - + /* attach to hash list */ - *p = new; + *p = new; /* append to sorted_list */ *l->last = new; diff --git a/src/record.c b/src/record.c index 7db84e3..53cb34e 100644 --- a/src/record.c +++ b/src/record.c @@ -30,8 +30,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" #include "record.h" -union data_types * data_types_assign(NMEM nmem, - union data_types ** data1, +union data_types * data_types_assign(NMEM nmem, + union data_types ** data1, union data_types data2) { // assert(nmem); @@ -45,7 +45,7 @@ union data_types * data_types_assign(NMEM nmem, else *data1 = nmem_malloc(nmem, sizeof(union data_types)); } - + **data1 = data2; return *data1; } @@ -58,7 +58,7 @@ struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys, int i = 0; const char *name = client_get_id(client); unsigned h = position; - + // assert(nmem); record = nmem_malloc(nmem, sizeof(struct record)); @@ -66,14 +66,14 @@ struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys, record->next = 0; record->client = client; - record->metadata - = nmem_malloc(nmem, + record->metadata + = nmem_malloc(nmem, sizeof(struct record_metadata*) * num_metadata); for (i = 0; i < num_metadata; i++) record->metadata[i] = 0; - - record->sortkeys - = nmem_malloc(nmem, + + record->sortkeys + = nmem_malloc(nmem, sizeof(union data_types*) * num_sortkeys); for (i = 0; i < num_sortkeys; i++) record->sortkeys[i] = 0; @@ -84,13 +84,13 @@ struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys, h = h * 65509 + ((unsigned char *) name)[i]; record->checksum = h; - + return record; } struct record_metadata * record_metadata_create(NMEM nmem) { - struct record_metadata * rec_md + struct record_metadata * rec_md = nmem_malloc(nmem, sizeof(struct record_metadata)); rec_md->next = 0; rec_md->attributes = 0; @@ -106,7 +106,7 @@ int record_compare(struct record *r1, struct record *r2, { struct conf_metadata *ser_md = &service->metadata[i]; enum conf_metadata_type type = ser_md->type; - + struct record_metadata *m1 = r1->metadata[i]; struct record_metadata *m2 = r2->metadata[i]; while (m1 && m2) diff --git a/src/sel_thread.c b/src/sel_thread.c index 1aca81a..fe8ef82 100644 --- a/src/sel_thread.c +++ b/src/sel_thread.c @@ -108,7 +108,7 @@ static void *sel_thread_handler(void *vp) /* work on this item */ p->work_handler(work_this->data); - + /* put it back into output queue */ yaz_mutex_enter(p->mutex); work_this->next = p->output_queue; @@ -121,7 +121,7 @@ static void *sel_thread_handler(void *vp) #else (void) write(p->write_fd, "", 1); #endif - } + } yaz_mutex_leave(p->mutex); return 0; } @@ -151,7 +151,7 @@ sel_thread_t sel_thread_create(void (*work_handler)(void *work_data), { nmem_destroy(nmem); return 0; - } + } *read_fd = p->read_fd = yaz_spipe_get_read_fd(p->spipe); p->write_fd = yaz_spipe_get_write_fd(p->spipe); @@ -186,7 +186,7 @@ void sel_thread_destroy(sel_thread_t p) p->stop_flag = 1; yaz_cond_broadcast(p->input_data); yaz_mutex_leave(p->mutex); - + for (i = 0; i< p->no_threads; i++) yaz_thread_join(&p->thread_id[i], 0); @@ -242,7 +242,7 @@ void *sel_thread_result(sel_thread_t p) /* put freed item in free list */ work_this->next = p->free_queue; p->free_queue = work_this; - + data = work_this->data; #ifdef WIN32 (void) recv(p->read_fd, read_buf, 1, 0); diff --git a/src/service_xslt.c b/src/service_xslt.c index 3ef5b55..938a0ff 100644 --- a/src/service_xslt.c +++ b/src/service_xslt.c @@ -42,7 +42,7 @@ struct service_xslt xsltStylesheetPtr xsp; struct service_xslt *next; }; - + xsltStylesheetPtr service_xslt_get(struct conf_service *service, const char *id) { @@ -94,12 +94,12 @@ int service_xslt_config(struct conf_service *service, xmlNode *n) yaz_log(YLOG_FATAL, "Multiple xslt with id=%s", id); return -1; } - + sx = nmem_malloc(service->nmem, sizeof(*sx)); sx->id = nmem_strdup(service->nmem, id); sx->next = service->xslt_list; service->xslt_list = sx; - + xsp_doc = xmlNewDoc(BAD_CAST "1.0"); xmlDocSetRootElement(xsp_doc, xmlCopyNode(root, 1)); sx->xsp = xsltParseStylesheetDoc(xsp_doc); diff --git a/src/session.c b/src/session.c index e391b82..4a817a2 100644 --- a/src/session.c +++ b/src/session.c @@ -83,7 +83,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX(a,b) ((a)>(b)?(a):(b)) // Note: Some things in this structure will eventually move to configuration -struct parameters global_parameters = +struct parameters global_parameters = { 0, // dump_records 0, // debug_mode @@ -211,7 +211,7 @@ void add_facet(struct session *s, const char *type, const char *value, int count WRBUF display_wrbuf = wrbuf_alloc(); session_normalize_facet(s, type, value, display_wrbuf, facet_wrbuf); - + if (wrbuf_len(facet_wrbuf)) { int i; @@ -227,12 +227,12 @@ void add_facet(struct session *s, const char *type, const char *value, int count wrbuf_destroy(display_wrbuf); return; } - + s->termlists[i].name = nmem_strdup(s->nmem, type); s->termlists[i].termlist = termlist_create(s->nmem); s->num_termlists = i + 1; } - + #if 0 session_log(s, YLOG_LOG, "Facets for %s: %s norm:%s (%d)", type, value, wrbuf_cstr(facet_wrbuf), count); #endif @@ -342,9 +342,9 @@ static xmlDoc *normalize_record(struct session *se, if (rdoc) { char *parms[MAX_XSLT_ARGS*2+1]; - + insert_settings_parameters(sdb, service, parms, nmem); - + if (normalize_record_transform(sdb->map, &rdoc, (const char **)parms)) { session_log(se, YLOG_WARN, "Normalize failed from %s", @@ -353,10 +353,10 @@ static xmlDoc *normalize_record(struct session *se, else { insert_settings_values(sdb, rdoc, service); - + if (global_parameters.dump_records) { - session_log(se, YLOG_LOG, "Normalized record from %s", + session_log(se, YLOG_LOG, "Normalized record from %s", sdb->database->id); log_xml_doc(rdoc); } @@ -410,10 +410,10 @@ static int prepare_map(struct session *se, struct session_database *sdb) const char *s; if (sdb->settings[PZ_XSLT] && - (s = session_setting_oneval(sdb, PZ_XSLT))) + (s = session_setting_oneval(sdb, PZ_XSLT))) { char auto_stylesheet[256]; - + if (!strcmp(s, "auto")) { const char *request_syntax = session_setting_oneval( @@ -458,7 +458,7 @@ static void session_watch_cancel(void *data, struct http_channel *c, } // set watch. Returns 0=OK, -1 if watch is already set -int session_set_watch(struct session *s, int what, +int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *chan) { @@ -468,7 +468,7 @@ int session_set_watch(struct session *s, int what, ret = -1; else { - + s->watchlist[what].fun = fun; s->watchlist[what].data = data; s->watchlist[what].obs = http_add_observer(chan, &s->watchlist[what], @@ -554,7 +554,7 @@ static void session_reset_active_clients(struct session *se, { struct client_list *l_next = l->next; - client_lock(l->client); + client_lock(l->client); client_set_session(l->client, 0); /* mark client inactive */ client_unlock(l->client); @@ -588,7 +588,7 @@ static void session_remove_cached_clients(struct session *se) } // Associates a set of clients with a session; -// Note: Session-databases represent databases with per-session +// Note: Session-databases represent databases with per-session // setting overrides static int select_targets(struct session *se, const char *filter) { @@ -630,14 +630,14 @@ static void session_clear_set(struct session *se, nmem_reset(se->nmem); se->total_records = se->total_merged = 0; se->num_termlists = 0; - + /* reset list of sorted results and clear to relevance search */ se->sorted_results = nmem_malloc(se->nmem, sizeof(*se->sorted_results)); se->sorted_results->field = nmem_strdup(se->nmem, sort_field); se->sorted_results->increasing = increasing; se->sorted_results->position = position; se->sorted_results->next = 0; - + se->reclist = reclist_create(se->nmem); } @@ -680,7 +680,7 @@ void session_sort(struct session *se, const char *field, int increasing, se->sorted_results = sr; } yaz_log(YLOG_DEBUG, "Restarting search for clients due to change in sort order"); - + for (l = se->clients_active; l; l = l->next) { struct client *cl = l->client; @@ -720,7 +720,7 @@ enum pazpar2_error_code session_search(struct session *se, session_remove_cached_clients(se); else session_reset_active_clients(se, 0); - + session_enter(se); se->settings_modified = 0; session_clear_set(se, sort_field, increasing, 0); /* hardcoded position */ @@ -734,7 +734,7 @@ enum pazpar2_error_code session_search(struct session *se, } yaz_gettimeofday(&tval); - + tval.tv_sec += 5; facet_limits = facet_limits_create(limit); @@ -813,7 +813,7 @@ static void session_init_databases_fun(void *context, struct database *db) int i; new->database = db; - + new->map = 0; assert(db->settings); new->settings = nmem_malloc(se->session_nmem, @@ -844,7 +844,7 @@ void session_init_databases(struct session *se) // Probably session_init_databases_fun should be refactored instead of // called here. -static struct session_database *load_session_database(struct session *se, +static struct session_database *load_session_database(struct session *se, char *id) { struct database *db = new_database_inherit_settings(id, se->session_nmem, se->service->settings); @@ -855,7 +855,7 @@ static struct session_database *load_session_database(struct session *se, } // Find an existing session database. If not found, load it -static struct session_database *find_session_database(struct session *se, +static struct session_database *find_session_database(struct session *se, char *id) { struct session_database *sdb; @@ -1050,20 +1050,20 @@ static int targets_termlist_nb(WRBUF wrbuf, struct session *se, int num, { // do only print terms which have display names - + wrbuf_puts(wrbuf, "\n"); wrbuf_puts(wrbuf, ""); wrbuf_xmlputs(wrbuf, ht[i].id); wrbuf_puts(wrbuf, "\n"); - + wrbuf_puts(wrbuf, ""); if (!ht[i].name || !ht[i].name[0]) wrbuf_xmlputs(wrbuf, "NO TARGET NAME"); else wrbuf_xmlputs(wrbuf, ht[i].name); wrbuf_puts(wrbuf, "\n"); - + wrbuf_printf(wrbuf, "" ODR_INT_PRINTF "\n", ht[i].hits); @@ -1077,8 +1077,8 @@ static int targets_termlist_nb(WRBUF wrbuf, struct session *se, int num, wrbuf_puts(wrbuf, ""); wrbuf_xmlputs(wrbuf, ht[i].state); wrbuf_puts(wrbuf, "\n"); - - wrbuf_printf(wrbuf, "%d\n", + + wrbuf_printf(wrbuf, "%d\n", ht[i].diagnostic); wrbuf_puts(wrbuf, "\n"); } @@ -1128,14 +1128,14 @@ void perform_termlist(struct http_channel *c, struct session *se, // prevent sending empty term elements if (!p[i]->display_term || !p[i]->display_term[0]) continue; - + wrbuf_puts(c->wrbuf, ""); wrbuf_puts(c->wrbuf, ""); wrbuf_xmlputs(c->wrbuf, p[i]->display_term); wrbuf_puts(c->wrbuf, ""); - - wrbuf_printf(c->wrbuf, - "%d", + + wrbuf_printf(c->wrbuf, + "%d", p[i]->frequency); wrbuf_puts(c->wrbuf, "\n"); } @@ -1173,7 +1173,7 @@ void report_nmem_stats(void) nmem_get_memory_in_use(&in_use); nmem_get_memory_free(&is_free); - yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld", + yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld", (long) in_use, (long) is_free); } #endif @@ -1212,13 +1212,13 @@ void show_single_stop(struct session *se, struct record_cluster *rec) } struct record_cluster **show_range_start(struct session *se, - struct reclist_sortparms *sp, + struct reclist_sortparms *sp, int start, int *num, int *total, Odr_int *sumhits, Odr_int *approx_hits) { struct record_cluster **recs; struct reclist_sortparms *spp; int i; -#if USE_TIMING +#if USE_TIMING yaz_timing_t t = yaz_timing_create(); #endif session_enter(se); @@ -1227,14 +1227,14 @@ struct record_cluster **show_range_start(struct session *se, { *num = 0; *total = 0; - *sumhits = 0; + *sumhits = 0; *approx_hits = 0; recs = 0; } else { struct client_list *l; - + for (spp = sp; spp; spp = spp->next) if (spp->type == Metadata_sortkey_relevance) { @@ -1242,7 +1242,7 @@ struct record_cluster **show_range_start(struct session *se, break; } reclist_sort(se->reclist, sp); - + reclist_enter(se->reclist); *total = reclist_get_num_records(se->reclist); @@ -1259,7 +1259,7 @@ struct record_cluster **show_range_start(struct session *se, recs = 0; break; } - + for (i = 0; i < *num; i++) { struct record_cluster *r = reclist_read_record(se->reclist); @@ -1274,7 +1274,7 @@ struct record_cluster **show_range_start(struct session *se, } #if USE_TIMING yaz_timing_stop(t); - yaz_log(YLOG_LOG, "show %6.5f %3.2f %3.2f", + yaz_log(YLOG_LOG, "show %6.5f %3.2f %3.2f", yaz_timing_get_real(t), yaz_timing_get_user(t), yaz_timing_get_sys(t)); yaz_timing_destroy(&t); @@ -1322,7 +1322,7 @@ static struct record_metadata *record_metadata_init( { struct record_metadata *rec_md = record_metadata_create(nmem); struct record_metadata_attr **attrp = &rec_md->attributes; - + for (; attr; attr = attr->next) { if (attr->children && attr->children->content) @@ -1347,7 +1347,7 @@ static struct record_metadata *record_metadata_init( char *p = nmem_strdup(nmem, value); p = normalize7bit_generic(p, " ,/.:(["); - + rec_md->data.text.disp = p; rec_md->data.text.sort = 0; } @@ -1392,7 +1392,7 @@ static int get_mergekey_from_doc(xmlDoc *doc, xmlNode *root, const char *name, const char *norm_str; pp2_charset_token_t prt = pp2_charset_token_create(service->charsets, "mergekey"); - + pp2_charset_token_first(prt, (const char *) value, 0); if (wrbuf_len(norm_wr) > 0) wrbuf_puts(norm_wr, " "); @@ -1458,7 +1458,7 @@ static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, service, norm_wr); if (r == 0 && ser_md->mergekey == Metadata_mergekey_required) { - /* no mergekey on this one and it is required.. + /* no mergekey on this one and it is required.. Generate unique key instead */ wrbuf_rewind(norm_wr); break; @@ -1484,7 +1484,7 @@ static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, return mergekey_norm; } -/** \brief see if metadata for pz:recordfilter exists +/** \brief see if metadata for pz:recordfilter exists \param root xml root element of normalized record \param sdb session database for client \retval 0 if there is no metadata for pz:recordfilter @@ -1493,7 +1493,7 @@ static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, If there is no pz:recordfilter defined, this function returns 1 as well. */ - + static int check_record_filter(xmlNode *root, struct session_database *sdb) { int match = 0; @@ -1571,19 +1571,19 @@ int ingest_record(struct client *cl, const char *rec, xmlDoc *xdoc = normalize_record(se, sdb, service, rec, nmem); xmlNode *root; const char *mergekey_norm; - + if (!xdoc) return -1; - + root = xmlDocGetRootElement(xdoc); - + if (!check_record_filter(root, sdb)) { session_log(se, YLOG_LOG, "Filtered out record no %d from %s", record_no, sdb->database->id); xmlFreeDoc(xdoc); return -2; } - + mergekey_norm = get_mergekey(xdoc, cl, record_no, service, nmem); if (!mergekey_norm) { @@ -1595,7 +1595,7 @@ int ingest_record(struct client *cl, const char *rec, if (client_get_session(cl) == se) ret = ingest_to_cluster(cl, xdoc, root, record_no, mergekey_norm); session_leave(se); - + xmlFreeDoc(xdoc); return ret; } @@ -1618,11 +1618,11 @@ static int check_limit_local(struct client *cl, int md_field_id; char **values = 0; int i, num_v = 0; - + const char *name = client_get_facet_limit_local(cl, sdb, &l, nmem_tmp, &num_v, &values); if (!name) break; - + md_field_id = conf_service_metadata_field_id(service, name); if (md_field_id < 0) { @@ -1636,11 +1636,11 @@ static int check_limit_local(struct client *cl, { if (rec_md) { - if (ser_md->type == Metadata_type_year + if (ser_md->type == Metadata_type_year || ser_md->type == Metadata_type_date) { int y = atoi(values[i]); - if (y >= rec_md->data.number.min + if (y >= rec_md->data.number.min && y <= rec_md->data.number.max) break; } @@ -1671,7 +1671,7 @@ static int check_limit_local(struct client *cl, nmem_destroy(nmem_tmp); return skip_record; } - + static int ingest_to_cluster(struct client *cl, xmlDoc *xdoc, xmlNode *root, @@ -1686,7 +1686,7 @@ static int ingest_to_cluster(struct client *cl, int term_factor = 1; struct record_cluster *cluster; struct session_database *sdb = client_get_database(cl); - struct record *record = record_create(se->nmem, + struct record *record = record_create(se->nmem, service->num_metadata, service->num_sortkeys, cl, record_no); @@ -1698,7 +1698,7 @@ static int ingest_to_cluster(struct client *cl, if (value) xmlFree(value); type = value = 0; - + if (n->type != XML_ELEMENT_NODE) continue; if (!strcmp((const char *) n->name, "metadata")) @@ -1707,26 +1707,26 @@ static int ingest_to_cluster(struct client *cl, struct record_metadata **wheretoput = 0; struct record_metadata *rec_md = 0; int md_field_id = -1; - + type = xmlGetProp(n, (xmlChar *) "type"); value = xmlNodeListGetString(xdoc, n->children, 1); - + if (!type || !value || !*value) continue; - - md_field_id + + md_field_id = conf_service_metadata_field_id(service, (const char *) type); if (md_field_id < 0) { if (se->number_of_warnings_unknown_metadata == 0) { - session_log(se, YLOG_WARN, + session_log(se, YLOG_WARN, "Ignoring unknown metadata element: %s", type); } se->number_of_warnings_unknown_metadata++; continue; } - + ser_md = &service->metadata[md_field_id]; // non-merged metadata @@ -1779,7 +1779,7 @@ static int ingest_to_cluster(struct client *cl, relevance_newrec(se->relevance, cluster); - + // now parsing XML record and adding data to cluster or record metadata for (n = root->children; n; n = n->next) { @@ -1789,7 +1789,7 @@ static int ingest_to_cluster(struct client *cl, if (value) xmlFree(value); type = value = 0; - + if (n->type != XML_ELEMENT_NODE) continue; if (!strcmp((const char *) n->name, "metadata")) @@ -1802,18 +1802,18 @@ static int ingest_to_cluster(struct client *cl, int sk_field_id = -1; const char *rank; xmlChar *xml_rank; - + type = xmlGetProp(n, (xmlChar *) "type"); value = xmlNodeListGetString(xdoc, n->children, 1); - + if (!type || !value || !*value) continue; - - md_field_id + + md_field_id = conf_service_metadata_field_id(service, (const char *) type); if (md_field_id < 0) continue; - + ser_md = &service->metadata[md_field_id]; if (ser_md->sortkey_offset >= 0) @@ -1839,7 +1839,7 @@ static int ingest_to_cluster(struct client *cl, { while (*wheretoput) { - if (!strcmp((const char *) (*wheretoput)->data.text.disp, + if (!strcmp((const char *) (*wheretoput)->data.text.disp, rec_md->data.text.disp)) break; wheretoput = &(*wheretoput)->next; @@ -1849,22 +1849,22 @@ static int ingest_to_cluster(struct client *cl, } else if (ser_md->merge == Metadata_merge_longest) { - if (!*wheretoput - || strlen(rec_md->data.text.disp) + if (!*wheretoput + || strlen(rec_md->data.text.disp) > strlen((*wheretoput)->data.text.disp)) { *wheretoput = rec_md; if (ser_sk) { const char *sort_str = 0; - int skip_article = + int skip_article = ser_sk->type == Metadata_sortkey_skiparticle; if (!cluster->sortkeys[sk_field_id]) - cluster->sortkeys[sk_field_id] = - nmem_malloc(se->nmem, + cluster->sortkeys[sk_field_id] = + nmem_malloc(se->nmem, sizeof(union data_types)); - + prt = pp2_charset_token_create(service->charsets, "sort"); @@ -1872,18 +1872,18 @@ static int ingest_to_cluster(struct client *cl, skip_article); pp2_charset_token_next(prt); - + sort_str = pp2_get_sort(prt); - - cluster->sortkeys[sk_field_id]->text.disp = + + cluster->sortkeys[sk_field_id]->text.disp = rec_md->data.text.disp; if (!sort_str) { sort_str = rec_md->data.text.disp; - session_log(se, YLOG_WARN, + session_log(se, YLOG_WARN, "Could not make sortkey. Bug #1858"); } - cluster->sortkeys[sk_field_id]->text.sort = + cluster->sortkeys[sk_field_id]->text.sort = nmem_strdup(se->nmem, sort_str); pp2_charset_token_destroy(prt); } @@ -1901,7 +1901,7 @@ static int ingest_to_cluster(struct client *cl, { *wheretoput = rec_md; if (ser_sk) - cluster->sortkeys[sk_field_id] + cluster->sortkeys[sk_field_id] = &rec_md->data; } else @@ -1915,10 +1915,10 @@ static int ingest_to_cluster(struct client *cl, } } - // ranking of _all_ fields enabled ... + // ranking of _all_ fields enabled ... if (rank) { - relevance_countwords(se->relevance, cluster, + relevance_countwords(se->relevance, cluster, (char *) value, rank, ser_md->name); } diff --git a/src/settings.c b/src/settings.c index 491ad08..de04cc1 100644 --- a/src/settings.c +++ b/src/settings.c @@ -108,7 +108,7 @@ static int settings_index_lookup(struct setting_dictionary *dictionary, const ch size_t maxlen; int i; const char *p; - + assert(name); if (!strncmp("pz:", name, 3) && (p = strchr(name + 3, ':'))) @@ -241,7 +241,7 @@ int settings_read_node_x(xmlNode *n, xmlDocSetRootElement(doc, xmlCopyNode(root, 1)); xmlDocDumpMemory(doc, &buf_out, &len_out); /* xmlDocDumpMemory 0-terminates */ - set.value = (char *) buf_out; + set.value = (char *) buf_out; xmlFreeDoc(doc); } } @@ -266,7 +266,7 @@ int settings_read_node_x(xmlNode *n, } else { - yaz_log(YLOG_WARN, "Unknown element %s in settings file", + yaz_log(YLOG_WARN, "Unknown element %s in settings file", (char*) n->name); ret_val = -1; } @@ -278,7 +278,7 @@ int settings_read_node_x(xmlNode *n, xmlFree(targeta); return ret_val; } - + static int read_settings_file(const char *path, void *client_data, void (*fun)(void *client_data, @@ -301,7 +301,7 @@ static int read_settings_file(const char *path, } -// Recursively read files or directories, invoking a +// Recursively read files or directories, invoking a // callback for each one static int read_settings(const char *path, void *client_data, @@ -444,7 +444,7 @@ static void update_database_fun(void *context, struct database *db) { struct setting *set = ((struct update_database_context *) context)->set; - struct conf_service *service = ((struct update_database_context *) + struct conf_service *service = ((struct update_database_context *) context)->service; struct setting **sp; int offset; @@ -535,7 +535,7 @@ void initialize_soft_settings(struct conf_service *service) // Also create setting for some metadata attributes. if (md->limitmap) { - int index; + int index; WRBUF wrbuf = wrbuf_alloc(); yaz_log(YLOG_DEBUG, "Metadata %s has limitmap: %s ",md->name, md->limitmap); wrbuf_printf(wrbuf, "pz:limitmap:%s", md->name); @@ -571,9 +571,9 @@ static void prepare_target_dictionary(void *client_data, struct setting *set) void init_settings(struct conf_service *service) { struct setting_dictionary *new; - + assert(service->nmem); - + new = nmem_malloc(service->nmem, sizeof(*new)); memset(new, 0, sizeof(*new)); service->dictionary = new; diff --git a/src/termlists.c b/src/termlists.c index 6808a68..64f397a 100644 --- a/src/termlists.c +++ b/src/termlists.c @@ -110,7 +110,7 @@ struct termlist_score **termlist_highscore(struct termlist *tl, int *len, struct termlist_score **highscore = (struct termlist_score **) nmem_malloc(nmem, tl->no_entries * sizeof(*highscore)); - + int no = 0; unsigned bucket; for (bucket = 0; bucket < tl->hash_size; bucket++) diff --git a/src/test_normalize.c b/src/test_normalize.c index 0f1147f..d41b9c1 100644 --- a/src/test_normalize.c +++ b/src/test_normalize.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "normalize7bit.h" -int test_normalize7bit_generic(const char *rm_chars, const char *input, +int test_normalize7bit_generic(const char *rm_chars, const char *input, const char *expect_output) { int ret = 0; @@ -54,17 +54,17 @@ int test_normalize7bit_mergekey(const char *input, int main(int argc, char **argv) { - YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_INIT(argc, argv); YAZ_CHECK_LOG(); YAZ_CHECK(test_normalize7bit_generic("/; ", " how are you; ", "how are you")); YAZ_CHECK(!test_normalize7bit_generic("/; ", " how are you; ", "how are youx")); - + YAZ_CHECK(test_normalize7bit_generic("/; "," ", "")); YAZ_CHECK(test_normalize7bit_mergekey("the art of computer", "the art of computer")); YAZ_CHECK(test_normalize7bit_mergekey("The Art Of Computer", "the art of computer")); - + YAZ_CHECK_TERM; } diff --git a/src/test_sel_thread.c b/src/test_sel_thread.c index d0b1c90..fea51c5 100644 --- a/src/test_sel_thread.c +++ b/src/test_sel_thread.c @@ -102,7 +102,7 @@ void iochan_handler(struct iochan *i, int event) static void test_for_real_work(int no_threads) { int thread_fd; - sel_thread_t p = sel_thread_create(work_handler, work_destroy, + sel_thread_t p = sel_thread_create(work_handler, work_destroy, &thread_fd, no_threads); YAZ_CHECK(p); if (p) @@ -122,8 +122,8 @@ static void test_for_real_work(int no_threads) int main(int argc, char **argv) { - YAZ_CHECK_INIT(argc, argv); - YAZ_CHECK_LOG(); + YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); test_create_destroy(); test_for_real_work(1);