added zebra_insert_record call, function in perl api, documentation and tests
[idzebra-moved-to-github.git] / index / zebraapi.c
index ab5cf26..01c6433 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.91 2003-03-06 11:58:08 adam Exp $
+/* $Id: zebraapi.c,v 1.93 2003-03-13 04:25:17 pop Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
    Index Data Aps
 
@@ -1776,11 +1776,38 @@ void api_records_retrieve (ZebraHandle zh, ODR stream,
   If not, and a record is provided, then sysno is got from there
 */
 
+int zebra_insert_record (ZebraHandle zh, 
+                        struct recordGroup *rGroup,
+                        const char *recordType,
+                        int sysno, const char *match, const char *fname,
+                        const char *buf, int buf_size,
+                        int force_update) // This one is ignored
+{
+    int res;
+
+    if (buf_size < 1) buf_size = strlen(buf);
+
+    zebra_begin_trans(zh, 1);
+    res=bufferExtractRecord (zh, buf, buf_size, rGroup, 
+                            0, // delete_flag 
+                            0, // test_mode,
+                            recordType,
+                            &sysno,   
+                            match, fname,
+                            force_update, 
+                            0); // allow_update     
+    zebra_end_trans(zh); 
+    if (res < 0) return (res);
+    return sysno; 
+}
+
 int zebra_update_record (ZebraHandle zh, 
                         struct recordGroup *rGroup,
                         const char *recordType,
                         int sysno, const char *match, const char *fname,
-                        const char *buf, int buf_size)
+                        const char *buf, int buf_size,
+                        int force_update)
 
 {
     int res;
@@ -1793,16 +1820,21 @@ int zebra_update_record (ZebraHandle zh,
                             0, // test_mode,
                             recordType,
                             &sysno,   
-                            match, fname);     
+                            match, fname,
+                            force_update, 
+                            1); // allow_update    
     zebra_end_trans(zh); 
     return sysno; 
 }
 
+
+
 int zebra_delete_record (ZebraHandle zh, 
                         struct recordGroup *rGroup, 
                         const char *recordType,
                         int sysno, const char *match, const char *fname,
-                        const char *buf, int buf_size)
+                        const char *buf, int buf_size,
+                        int force_update) 
 {
     int res;
 
@@ -1814,7 +1846,9 @@ int zebra_delete_record (ZebraHandle zh,
                             0, // test_mode, 
                             recordType,
                             &sysno,
-                            match,fname);    
+                            match,fname,
+                            force_update,
+                            1); // allow_update    
     zebra_end_trans(zh);
     return sysno;   
 }