Omit yet more Debian crap ... it really is completely unacceptable the
[simpleserver-moved-to-github.git] / SimpleServer.xs
index dfa4bf9..b838b29 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: SimpleServer.xs,v 1.76 2007-08-20 21:27:50 mike Exp $ 
+ * $Id: SimpleServer.xs,v 1.83 2008-09-02 15:16:34 mike Exp $ 
  * ----------------------------------------------------------------------
  * 
  * Copyright (c) 2000-2004, Index Data.
@@ -424,9 +424,10 @@ static SV *apt2perl(Z_AttributesPlusTerm *at)
                setMember(hv2, "attributeValue",
                          newSViv(*elem->value.numeric));
            } else {
-               assert(elem->which == Z_AttributeValue_complex);
-               Z_ComplexAttribute *c = elem->value.complex;
+               Z_ComplexAttribute *c;
                Z_StringOrNumeric *son;
+               assert(elem->which == Z_AttributeValue_complex);
+               c = elem->value.complex;
                /* We ignore semantic actions and multiple values */
                assert(c->num_list > 0);
                son = c->list[0];
@@ -864,7 +865,7 @@ int bend_delete(void *handle, bend_delete_rr *rr)
            if (rr->num_setnames > 1) {
                rr->delete_status = 3; /* "System problem at target" */
                /* There's no way to sent delete-msg using the GFS */
-               return;
+               return 0;
            }
 
            for (i = 0; i < rr->num_setnames; i++) {
@@ -966,6 +967,8 @@ int bend_fetch(void *handle, bend_fetch_rr *rr)
                        else
                        {
                                rr->errcode = 26;
+                               rr->errstring = odr_strdup(rr->stream, "non-generic 'simple' composition");
+                               return 0;
                        }
                }
                else if (composition->which == Z_RecordComp_complex)
@@ -984,8 +987,8 @@ int bend_fetch(void *handle, bend_fetch_rr *rr)
                        else
                        {
 #if 0  /* For now ignore this error, which is ubiquitous in SRU */
-                               fprintf(stderr, "complex is weird\n");
                                rr->errcode = 26;
+                               rr->errstring = odr_strdup(rr->stream, "'complex' composition is not generic ESN");
                                return 0;
 #endif /*0*/
                        }
@@ -993,6 +996,7 @@ int bend_fetch(void *handle, bend_fetch_rr *rr)
                else
                {
                        rr->errcode = 26;
+                       rr->errstring = odr_strdup(rr->stream, "composition neither simple nor complex");
                        return 0;
                }
        }
@@ -1157,6 +1161,7 @@ int bend_present(void *handle, bend_present_rr *rr)
                        else
                        {
                                rr->errcode = 26;
+                               rr->errstring = odr_strdup(rr->stream, "non-generic 'simple' composition");
                                return 0;
                        }
                }
@@ -1176,12 +1181,14 @@ int bend_present(void *handle, bend_present_rr *rr)
                        else
                        {
                                rr->errcode = 26;
+                               rr->errstring = odr_strdup(rr->stream, "'complex' composition is not generic ESN");
                                return 0;
                        }
                }
                else
                {
                        rr->errcode = 26;
+                       rr->errstring = odr_strdup(rr->stream, "composition neither simple nor complex");
                        return 0;
                }
        }
@@ -1421,6 +1428,21 @@ int bend_explain(void *handle, bend_explain_rr *q)
         return 0;
 }
 
+
+/*
+ * You'll laugh when I tell you this ...  Astonishingly, it turns out
+ * that ActivePerl (which is widely used on Windows) has, in the
+ * header file Perl\lib\CORE\XSUB.h, the following heinous crime:
+ *         #    define open            PerlLIO_open
+ * This of course screws up the use of the "open" member of the
+ * Z_IdAuthentication structure below, so we have to undo this
+ * brain-damage.
+ */
+#ifdef open
+#undef open
+#endif
+
+
 bend_initresult *bend_init(bend_initrequest *q)
 {
        int dummy = simpleserver_clone();
@@ -1474,9 +1496,12 @@ bend_initresult *bend_init(bend_initrequest *q)
        }
 
                href = newHV(); 
+
+       /* ### These should be given initial values from the client */
        hv_store(href, "IMP_ID", 6, newSVpv("", 0), 0);
        hv_store(href, "IMP_NAME", 8, newSVpv("", 0), 0);
        hv_store(href, "IMP_VER", 7, newSVpv("", 0), 0);
+
        hv_store(href, "ERR_CODE", 8, newSViv(0), 0);
        hv_store(href, "ERR_STR", 7, newSViv(0), 0);
        hv_store(href, "PEER_NAME", 9, newSVpv(q->peer_name, 0), 0);