Index: /trunk/Nebulous/nebclient/src/nebclient.c
===================================================================
--- /trunk/Nebulous/nebclient/src/nebclient.c	(revision 4460)
+++ /trunk/Nebulous/nebclient/src/nebclient.c	(revision 4461)
@@ -4,5 +4,5 @@
  * Copyright (C) 2005  Joshua Hoblitt
  *
- * $Id: nebclient.c,v 1.5 2005-07-06 02:44:12 jhoblitt Exp $
+ * $Id: nebclient.c,v 1.6 2005-07-06 04:14:41 jhoblitt Exp $
  */
 
@@ -15,4 +15,6 @@
 #include <string.h>
 #include <regex.h>
+#include <unistd.h>
+#include <stdbool.h>
 #include "xmalloc.h"
 #include "soapH.h"
@@ -25,4 +27,5 @@
 static off_t nebCopyFilehandle(int sourceFH, int destFH);
 static int nebParseURI(const char *URI, char **filename);
+static bool nebNukeFile(const char *filename);
 
 void nebServerInit(nebServer *server)
@@ -58,7 +61,7 @@
     int             file;
 
-    if (soap_call_ns1__create_USCOREobject(server, NULL, NULL, key, class, volume, comment, &response) == SOAP_OK) {
-        *URI = xmalloc(strlen(response.result));
-        strcpy(*URI, response.result);
+    if (soap_call_ns1__create_USCOREobject(server, NULL, NULL, key, class, volume, comment, (char **)&response) == SOAP_OK) {
+        *URI = xmalloc(strlen((char *)response.result));
+        strcpy(*URI, (char *)response.result);
 
         if (!nebParseURI(*URI, &filename)) {
@@ -88,7 +91,7 @@
     int             sourceFH, destFH;
 
-    if (soap_call_ns1__replicate_USCOREobject(server, NULL, NULL, key, volume, &response) == SOAP_OK) {
-        *URI = xmalloc(strlen(response.result));
-        strcpy(*URI, response.result);
+    if (soap_call_ns1__replicate_USCOREobject(server, NULL, NULL, key, volume, (char **)&response) == SOAP_OK) {
+        *URI = xmalloc(strlen((char *)response.result));
+        strcpy(*URI, (char *)response.result);
 
         if (!nebParseURI(*URI, &filename)) {
@@ -131,8 +134,20 @@
 }
 
-int nebCull( nebServer *server,char *key )
-{
-
-    return 0;
+int nebCull(nebServer *server, char *key)
+{
+    char            **locations;
+    int             n;
+
+    n = nebFindInstances(server, key, NULL, &locations);
+
+    printf( "found %d instances\n", n );
+
+    if (n < 2 ) {
+        fprintf(stderr, "can not cull - not enough instances");
+        //free locations
+        return -1;
+    }
+
+    return nebDeleteInstance(server, locations[0]);
 }
 
@@ -210,8 +225,31 @@
 }
 
-int nebDelete_instance(nebServer *server, char *URI )
-{
-
-    return 0;
+bool nebDeleteInstance(nebServer *server, const char *URI)
+{
+    int             *response;
+    char            *filename;
+    bool            status;
+
+    if (!nebParseURI(URI, &filename)) {
+        fprintf(stderr, "can not parse URI\n");
+
+        return false;
+    }
+
+    if (soap_call_ns1__delete_USCOREinstance(server, NULL, NULL, (char *)URI, response) != SOAP_OK) {
+        nebFree(filename);
+
+        return false;
+    }
+
+    if (*response > 0) {
+        status = nebNukeFile(filename);
+    } else {
+        status = false;
+    }
+
+    nebFree(filename);
+
+    return status;
 }
 
@@ -364,2 +402,13 @@
     return bytesTotal;
 }
+
+static bool nebNukeFile(const char *filename)
+{
+    if (unlink(filename) < 0) {
+        perror("unlink");
+
+        return false;
+    }
+             
+    return true;
+}
