Changeset 4461
- Timestamp:
- Jul 5, 2005, 6:14:41 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous/nebclient/src/nebclient.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/nebclient/src/nebclient.c
r4456 r4461 4 4 * Copyright (C) 2005 Joshua Hoblitt 5 5 * 6 * $Id: nebclient.c,v 1. 5 2005-07-06 02:44:12jhoblitt Exp $6 * $Id: nebclient.c,v 1.6 2005-07-06 04:14:41 jhoblitt Exp $ 7 7 */ 8 8 … … 15 15 #include <string.h> 16 16 #include <regex.h> 17 #include <unistd.h> 18 #include <stdbool.h> 17 19 #include "xmalloc.h" 18 20 #include "soapH.h" … … 25 27 static off_t nebCopyFilehandle(int sourceFH, int destFH); 26 28 static int nebParseURI(const char *URI, char **filename); 29 static bool nebNukeFile(const char *filename); 27 30 28 31 void nebServerInit(nebServer *server) … … 58 61 int file; 59 62 60 if (soap_call_ns1__create_USCOREobject(server, NULL, NULL, key, class, volume, comment, &response) == SOAP_OK) {61 *URI = xmalloc(strlen( response.result));62 strcpy(*URI, response.result);63 if (soap_call_ns1__create_USCOREobject(server, NULL, NULL, key, class, volume, comment, (char **)&response) == SOAP_OK) { 64 *URI = xmalloc(strlen((char *)response.result)); 65 strcpy(*URI, (char *)response.result); 63 66 64 67 if (!nebParseURI(*URI, &filename)) { … … 88 91 int sourceFH, destFH; 89 92 90 if (soap_call_ns1__replicate_USCOREobject(server, NULL, NULL, key, volume, &response) == SOAP_OK) {91 *URI = xmalloc(strlen( response.result));92 strcpy(*URI, response.result);93 if (soap_call_ns1__replicate_USCOREobject(server, NULL, NULL, key, volume, (char **)&response) == SOAP_OK) { 94 *URI = xmalloc(strlen((char *)response.result)); 95 strcpy(*URI, (char *)response.result); 93 96 94 97 if (!nebParseURI(*URI, &filename)) { … … 131 134 } 132 135 133 int nebCull( nebServer *server,char *key ) 134 { 135 136 return 0; 136 int nebCull(nebServer *server, char *key) 137 { 138 char **locations; 139 int n; 140 141 n = nebFindInstances(server, key, NULL, &locations); 142 143 printf( "found %d instances\n", n ); 144 145 if (n < 2 ) { 146 fprintf(stderr, "can not cull - not enough instances"); 147 //free locations 148 return -1; 149 } 150 151 return nebDeleteInstance(server, locations[0]); 137 152 } 138 153 … … 210 225 } 211 226 212 int nebDelete_instance(nebServer *server, char *URI ) 213 { 214 215 return 0; 227 bool nebDeleteInstance(nebServer *server, const char *URI) 228 { 229 int *response; 230 char *filename; 231 bool status; 232 233 if (!nebParseURI(URI, &filename)) { 234 fprintf(stderr, "can not parse URI\n"); 235 236 return false; 237 } 238 239 if (soap_call_ns1__delete_USCOREinstance(server, NULL, NULL, (char *)URI, response) != SOAP_OK) { 240 nebFree(filename); 241 242 return false; 243 } 244 245 if (*response > 0) { 246 status = nebNukeFile(filename); 247 } else { 248 status = false; 249 } 250 251 nebFree(filename); 252 253 return status; 216 254 } 217 255 … … 364 402 return bytesTotal; 365 403 } 404 405 static bool nebNukeFile(const char *filename) 406 { 407 if (unlink(filename) < 0) { 408 perror("unlink"); 409 410 return false; 411 } 412 413 return true; 414 }
Note:
See TracChangeset
for help on using the changeset viewer.
