summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Dickmeiss <dickmeiss@php.net>2003-05-13 11:05:59 +0000
committerAdam Dickmeiss <dickmeiss@php.net>2003-05-13 11:05:59 +0000
commit99af37d2c8d598aa825bbe71959e4f7e232aec9a (patch)
treed7aa01e9d80fb7e7bc915cf10b604220e4d09e4c
parent10f2defb0494f975b26063fb387d70d2cf543164 (diff)
downloadphp-git-99af37d2c8d598aa825bbe71959e4f7e232aec9a.tar.gz
Fix problem with yaz_record in array mode, when record is unavailable.
-rw-r--r--ext/yaz/php_yaz.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/ext/yaz/php_yaz.c b/ext/yaz/php_yaz.c
index af9dae494a..7c4962b302 100644
--- a/ext/yaz/php_yaz.c
+++ b/ext/yaz/php_yaz.c
@@ -944,44 +944,46 @@ PHP_FUNCTION(yaz_record)
if (!strcmp (type, "array"))
{
Z_External *ext = (Z_External *) ZOOM_record_get (r, "ext", 0);
- oident *ent = oid_getentbyoid(ext->direct_reference);
-
- if (ext->which == Z_External_grs1 && ent->value == VAL_GRS1)
- {
- retval_grs1 (return_value, ext->u.grs1);
- }
- else if (ext->which == Z_External_octet)
+ if (ext)
{
- char *buf = (char *) (ext->u.octet_aligned->buf);
- ODR odr = odr_createmem (ODR_DECODE);
- Z_GenericRecord *rec = 0;
-
- switch (ent->value)
+ oident *ent = oid_getentbyoid(ext->direct_reference);
+ if (ext->which == Z_External_grs1 && ent->value == VAL_GRS1)
{
- case VAL_SOIF:
- case VAL_HTML:
- break;
- case VAL_TEXT_XML:
- case VAL_APPLICATION_XML:
- /* text2grs1 (&buf, &len, t->odr_in, 0, 0); */
- break;
- default:
- rec = marc_to_grs1 (buf, odr);
+ retval_grs1 (return_value, ext->u.grs1);
+ }
+ else if (ext->which == Z_External_octet)
+ {
+ char *buf = (char *) (ext->u.octet_aligned->buf);
+ ODR odr = odr_createmem (ODR_DECODE);
+ Z_GenericRecord *rec = 0;
+
+ switch (ent->value)
+ {
+ case VAL_SOIF:
+ case VAL_HTML:
+ break;
+ case VAL_TEXT_XML:
+ case VAL_APPLICATION_XML:
+ /* text2grs1 (&buf, &len, t->odr_in, 0, 0); */
+ break;
+ default:
+ rec = marc_to_grs1 (buf, odr);
+ }
+ if (rec)
+ retval_grs1 (return_value, rec);
+ odr_destroy (odr);
}
- if (rec)
- retval_grs1 (return_value, rec);
- odr_destroy (odr);
}
}
- else
+ else
{
- int rlen;
+ int rlen;
const char *info = ZOOM_record_get (r, type, &rlen);
- return_value->value.str.len = (rlen > 0) ? rlen : 0;
- return_value->value.str.val =
- estrndup(info, return_value->value.str.len);
- return_value->type = IS_STRING;
+ return_value->value.str.len = (rlen > 0) ? rlen : 0;
+ return_value->value.str.val =
+ estrndup(info, return_value->value.str.len);
+ return_value->type = IS_STRING;
}
}
}