zip.c splitting/rewriting begun

--HG--
branch : HEAD
diff --git a/lib/zip_replace.c b/lib/zip_replace.c
new file mode 100644
index 0000000..9adf5b7
--- /dev/null
+++ b/lib/zip_replace.c
@@ -0,0 +1,32 @@
+#include "zip.h"
+#include "zipint.h"
+
+
+
+int
+zip_replace(struct zip *zf, int idx, char *name,
+	    zip_read_func *fn, void *state, int comp)
+{
+    if (idx == -1)
+	zip_add(zf, name, fn, state, comp);
+    
+    if (idx < 0 || idx >= zf->nentry) {
+	zip_err = ZERR_NOENT;
+	return -1;
+    }
+
+    if (_zip_unchange_data(zf, idx) != 0)
+	return -1;
+
+    if (_zip_set_name(zf, idx, name) != 0)
+	return -1;
+    
+    zf->changes = 1;
+    zf->entry[idx].state = Z_REPLACED;
+
+    zf->entry[idx].ch_func = fn;
+    zf->entry[idx].ch_data = state;
+    zf->entry[idx].ch_comp = comp;
+
+    return 0;
+}