YAZ 5.35.1
query-charset.c
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
4 */
8#if HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12#include <stdio.h>
13#include <assert.h>
14
15#include <yaz/query-charset.h>
16#include <yaz/wrbuf.h>
17
18static int yaz_query_charset_convert_buf(char *buf_in, int len_in,
19 char **buf_out, int *len_out,
21{
22 int r = 0;
24 wrbuf_iconv_write(wrbuf, cd, buf_in, len_in);
26
27 *len_out = wrbuf_len(wrbuf);
28 if (*len_out == 0)
29 { /* we assume conversion failed */
30 *buf_out = buf_in;
31 *len_out = len_in;
32 r = -1;
33 }
34 else
35 {
36 /* conversion OK */
37 *buf_out = (char*) odr_malloc(o, *len_out);
38 memcpy(*buf_out, wrbuf_buf(wrbuf), *len_out);
39 }
40 return r;
41}
42
45{
46 int r = 0;
47 switch(q->which)
48 {
49 case Z_Term_general:
51 (char *) q->u.general->buf, q->u.general->len,
52 (char **) &q->u.general->buf, &q->u.general->len, o, wrbuf, cd);
53 break;
54 }
55 return r;
56}
57
60{
61 int r = 0;
62 switch(q->which)
63 {
64 case Z_Operand_APT:
66 o, wrbuf, cd);
67 break;
69 break;
71 break;
72 }
73 return r;
74}
75
77 ODR o, WRBUF wrbuf,
78 yaz_iconv_t cd)
79{
80 int r = 0;
81 switch(q->which)
82 {
85 break;
88 if (r == 0)
90 q->u.complex->s2, o, wrbuf, cd);
91 break;
92 }
93 return r;
94}
95
105
113
121
122/*
123 * Local variables:
124 * c-basic-offset: 4
125 * c-file-style: "Stroustrup"
126 * indent-tabs-mode: nil
127 * End:
128 * vim: shiftwidth=4 tabstop=8 expandtab
129 */
130
void * odr_malloc(ODR o, size_t size)
Definition odr_mem.c:31
void yaz_query_charset_convert_apt(Z_AttributesPlusTerm *apt, ODR o, yaz_iconv_t cd)
static int yaz_query_charset_convert_term(Z_Term *q, ODR o, WRBUF wrbuf, yaz_iconv_t cd)
int yaz_query_charset_convert_rpnquery_check(Z_RPNQuery *q, ODR o, yaz_iconv_t cd)
static int yaz_query_charset_convert_buf(char *buf_in, int len_in, char **buf_out, int *len_out, ODR o, WRBUF wrbuf, yaz_iconv_t cd)
static int yaz_query_charset_convert_structure(Z_RPNStructure *q, ODR o, WRBUF wrbuf, yaz_iconv_t cd)
static int yaz_query_charset_convert_operand(Z_Operand *q, ODR o, WRBUF wrbuf, yaz_iconv_t cd)
void yaz_query_charset_convert_rpnquery(Z_RPNQuery *q, ODR o, yaz_iconv_t cd)
Query to WRBUF (to strings)
Z_RPNStructure * s2
Definition z-core.h:495
Z_RPNStructure * s1
Definition z-core.h:494
union Z_Operand::@47 u
int which
Definition z-core.h:510
Z_AttributesPlusTerm * attributesPlusTerm
Definition z-core.h:512
Z_RPNStructure * RPNStructure
Definition z-core.h:490
Z_Complex * complex
Definition z-core.h:503
union Z_RPNStructure::@46 u
Z_Operand * simple
Definition z-core.h:502
Odr_oct * general
Definition z-core.h:539
union Z_Term::@48 u
int which
Definition z-core.h:537
int len
Definition odr.h:102
char * buf
Definition odr.h:101
Definition odr.h:125
string buffer
Definition wrbuf.h:43
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
Definition wrbuf.c:38
void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd)
iconv reset(flush) to WRBUF
Definition wrbuf.c:286
void wrbuf_rewind(WRBUF b)
empty WRBUF content (length of buffer set to 0)
Definition wrbuf.c:47
WRBUF wrbuf_alloc(void)
construct WRBUF
Definition wrbuf.c:25
void wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf, size_t size)
Converts buffer using iconv and appends to WRBUF.
Definition wrbuf.c:248
Header for WRBUF (growing buffer)
#define wrbuf_buf(b)
Definition wrbuf.h:270
#define wrbuf_len(b)
Definition wrbuf.h:269
#define Z_Operand_resultAttr
Definition z-core.h:517
#define Z_Operand_APT
Definition z-core.h:515
#define Z_Term_general
Definition z-core.h:547
#define Z_Operand_resultSetId
Definition z-core.h:516
#define Z_RPNStructure_complex
Definition z-core.h:505
#define Z_RPNStructure_simple
Definition z-core.h:504