This overrides pz:nativesyntax and used for non-binary data retrievals.
For binary data, this overrides the "raw" string which was passed
previously (and still is by default).
int binary;
char *syntax;
char *esn;
int binary;
char *syntax;
char *esn;
void (*error_handler)(void *data, const char *addinfo);
void (*record_handler)(void *data, const char *buf, size_t sz);
void *data;
void (*error_handler)(void *data, const char *addinfo);
void (*record_handler)(void *data, const char *buf, size_t sz);
void *data;
}
static void client_send_raw_present(struct client *cl);
}
static void client_send_raw_present(struct client *cl);
-static int nativesyntax_to_type(struct session_database *sdb, char *type,
- ZOOM_record rec);
+static int nativesyntax_to_type(const char *s, char *type, ZOOM_record rec);
static void client_show_immediate(
ZOOM_resultset resultset, struct session_database *sdb, int position,
void *data,
void (*error_handler)(void *data, const char *addinfo),
void (*record_handler)(void *data, const char *buf, size_t sz),
static void client_show_immediate(
ZOOM_resultset resultset, struct session_database *sdb, int position,
void *data,
void (*error_handler)(void *data, const char *addinfo),
void (*record_handler)(void *data, const char *buf, size_t sz),
+ int binary,
+ const char *nativesyntax)
{
ZOOM_record rec = 0;
char type[80];
{
ZOOM_record rec = 0;
char type[80];
error_handler(data, "no record");
return;
}
error_handler(data, "no record");
return;
}
- if (binary)
- strcpy(type, "raw");
- else
- nativesyntax_to_type(sdb, type, rec);
+ nativesyntax_to_type(nativesyntax, type, rec);
buf = ZOOM_record_get(rec, type, &len);
if (!buf)
{
buf = ZOOM_record_get(rec, type, &len);
if (!buf)
{
void (*error_handler)(void *data, const char *addinfo),
void (*record_handler)(void *data, const char *buf,
size_t sz),
void (*error_handler)(void *data, const char *addinfo),
void (*record_handler)(void *data, const char *buf,
size_t sz),
+ int binary,
+ const char *nativesyntax)
+ if (!nativesyntax)
+ {
+ if (binary)
+ nativesyntax = "raw";
+ else
+ {
+ struct session_database *sdb = client_get_database(cl);
+ nativesyntax = session_setting_oneval(sdb, PZ_NATIVESYNTAX);
+ }
+ }
+
if (syntax == 0 && esn == 0)
client_show_immediate(cl->resultset, client_get_database(cl),
position, data,
error_handler, record_handler,
if (syntax == 0 && esn == 0)
client_show_immediate(cl->resultset, client_get_database(cl),
position, data,
error_handler, record_handler,
else
{
struct show_raw *rr, **rrp;
else
{
struct show_raw *rr, **rrp;
rr->esn = xstrdup(esn);
else
rr->esn = 0;
rr->esn = xstrdup(esn);
else
rr->esn = 0;
+
+ assert(nativesyntax);
+ rr->nativesyntax = xstrdup(nativesyntax);
+
rr->next = 0;
for (rrp = &cl->show_raw; *rrp; rrp = &(*rrp)->next)
rr->next = 0;
for (rrp = &cl->show_raw; *rrp; rrp = &(*rrp)->next)
{
xfree(r->syntax);
xfree(r->esn);
{
xfree(r->syntax);
xfree(r->esn);
+ xfree(r->nativesyntax);
connection_continue(co);
}
connection_continue(co);
}
-static int nativesyntax_to_type(struct session_database *sdb, char *type,
+static int nativesyntax_to_type(const char *s, char *type,
- const char *s = session_setting_oneval(sdb, PZ_NATIVESYNTAX);
-
if (s && *s)
{
if (!strncmp(s, "iso2709", 7))
if (s && *s)
{
if (!strncmp(s, "iso2709", 7))
yaz_snprintf(type, 80, "txml; charset=%s", cp ? cp+1 : "marc-8s");
}
else
yaz_snprintf(type, 80, "txml; charset=%s", cp ? cp+1 : "marc-8s");
}
else
return 0;
}
else /* attempt to deduce structure */
return 0;
}
else /* attempt to deduce structure */
- if (cl->show_raw->binary)
- strcpy(type, "raw");
- else
- {
- struct session_database *sdb = client_get_database(cl);
- nativesyntax_to_type(sdb, type, rec);
- }
-
+ nativesyntax_to_type(cl->show_raw->nativesyntax, type, rec);
buf = ZOOM_record_get(rec, type, &len);
cl->show_raw->record_handler(cl->show_raw->data, buf, len);
client_show_raw_dequeue(cl);
buf = ZOOM_record_get(rec, type, &len);
cl->show_raw->record_handler(cl->show_raw->data, buf, len);
client_show_raw_dequeue(cl);
const char *xmlrec;
char type[80];
const char *xmlrec;
char type[80];
- if (nativesyntax_to_type(sdb, type, rec))
+ 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");
xmlrec = ZOOM_record_get(rec, type, NULL);
if (!xmlrec)
yaz_log(YLOG_WARN, "Failed to determine record type");
xmlrec = ZOOM_record_get(rec, type, NULL);
if (!xmlrec)
void (*error_handler)(void *data, const char *addinfo),
void (*record_handler)(void *data, const char *buf,
size_t sz),
void (*error_handler)(void *data, const char *addinfo),
void (*record_handler)(void *data, const char *buf,
size_t sz),
+ int binary,
+ const char *nativesyntax);
void client_show_raw_remove(struct client *cl, void *rr);
void client_show_raw_remove(struct client *cl, void *rr);
int i;
struct record*r = rec->records;
int binary = 0;
int i;
struct record*r = rec->records;
int binary = 0;
+ const char *nativesyntax = http_argbyname(rq, "nativesyntax");
+
if (binarystr && *binarystr != '0')
binary = 1;
if (binarystr && *binarystr != '0')
binary = 1;
http_channel_observer_t obs =
http_add_observer(c, r->client, show_raw_reset);
int ret = client_show_raw_begin(r->client, r->position,
http_channel_observer_t obs =
http_add_observer(c, r->client, show_raw_reset);
int ret = client_show_raw_begin(r->client, r->position,
- syntax, esn,
- obs /* data */,
- show_raw_record_error,
- (binary ?
- show_raw_record_ok_binary :
- show_raw_record_ok),
- (binary ? 1 : 0));
+ syntax, esn,
+ obs /* data */,
+ show_raw_record_error,
+ (binary ?
+ show_raw_record_ok_binary :
+ show_raw_record_ok),
+ (binary ? 1 : 0),
+ nativesyntax);
if (ret == -1)
{
http_remove_observer(obs);
if (ret == -1)
{
http_remove_observer(obs);