Another MSV5.0 port. Changed projects to include proper
[yaz-moved-to-github.git] / ztest / ztest.c
index 8ce9c30..52ea666 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * Copyright (c) 1995-1997, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * NT Service interface by
+ *    Chas Woodfield, Fretwell Downing Datasystems.
+ *
+ * $Log: ztest.c,v $
+ * Revision 1.3  1997-09-09 10:10:20  adam
+ * Another MSV5.0 port. Changed projects to include proper
+ * library/include paths.
+ * Server starts server in test-mode when no options are given.
+ *
+ * Revision 1.2  1997/09/04 13:50:31  adam
+ * Bug fix in ztest.
+ *
+ */
 
-/* little dummy-server */
+/*
+ * Demonstration of simple server
+ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -33,6 +53,7 @@ bend_searchresult *bend_search(void *handle, bend_searchrequest *q, int *fd)
     r.errcode = 0;
     r.errstring = 0;
     r.hits = rand() % 22;
+
     return &r;
 }
 
@@ -129,10 +150,10 @@ bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *q, int *num)
     r.basename = "DUMMY";
     if (bbb)
     {
-    xfree(bbb);
+        xfree(bbb);
        bbb = 0;
     }
-    
+    r.format = q->format;  
     if (q->format == VAL_SUTRS)
     {
        char buf[100];
@@ -142,32 +163,6 @@ bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *q, int *num)
        strcpy(bbb, buf);
        r.len = strlen(buf);
     }
-#if 0
-    else if (q->format == VAL_GRS1)
-    {
-       Z_GenericRecord *rec = odr_malloc(q->stream, sizeof(*rec));
-       Z_TaggedElement *t1 = odr_malloc(q->stream, sizeof(*t1));
-       Z_StringOrNumeric *s1 = odr_malloc(q->stream, sizeof(*s1));
-       Z_ElementData *c1 = odr_malloc(q->stream, sizeof(*c1));
-
-       rec->elements = odr_malloc(q->stream, sizeof(Z_TaggedElement*)*10);
-       rec->num_elements = 1;
-       rec->elements[0] = t1 ;
-       t1->tagType = odr_malloc(q->stream, sizeof(int));
-       *t1->tagType = 3;
-       t1->tagValue = s1;
-       s1->which = Z_StringOrNumeric_string;
-       s1->u.string = "title";
-       t1->tagOccurrence = 0;
-       t1->content = c1;
-       c1->which = Z_ElementData_string;
-       c1->u.string = "The Bad Seed and The Ugly Duckling";
-       t1->metaData = 0;
-       t1->appliedVariant = 0;
-       r.record = (char*) rec;
-       r.len = -1;
-    }
-#endif
     else if (q->format == VAL_GRS1)
     {
        r.len = -1;
@@ -181,11 +176,11 @@ bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *q, int *num)
     else if (!(r.record = bbb = dummy_database_record(q->number)))
     {
        r.errcode = 13;
+       r.format = VAL_USMARC;
        return &r;
     }
     else
        r.len = strlen(r.record);
-    r.format = q->format;
     r.errcode = 0;
     return &r;
 }
@@ -338,7 +333,7 @@ int main(int argc, char **argv)
 
     /* The service controller does the following for us under windows */
     if (StartAppService(NULL, argc, argv))
-        RunAppService(NULL);
+        RunAppService(&ArgDetails);
 
     /* Ensure the service has been stopped */
     StopAppService(NULL);