]> granicus.if.org Git - php/commitdiff
Fix problem with yaz_record in array mode, when record is unavailable.
authorAdam Dickmeiss <dickmeiss@php.net>
Tue, 13 May 2003 11:05:59 +0000 (11:05 +0000)
committerAdam Dickmeiss <dickmeiss@php.net>
Tue, 13 May 2003 11:05:59 +0000 (11:05 +0000)
ext/yaz/php_yaz.c

index af9dae494a1af386311d8455fb6fd797b4e4bc6a..7c4962b302ab1f5623ec62f1164f46e64d94d9df 100644 (file)
@@ -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;
                        }
                }
        }