Changeset 4121
- Timestamp:
- Jun 6, 2005, 11:21:05 AM (21 years ago)
- Location:
- trunk/Nebulous/nebclient/src
- Files:
-
- 2 edited
-
nebclient.c (modified) (6 diffs)
-
nebclient.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/nebclient/src/nebclient.c
r3045 r4121 4 4 * Copyright (C) 2005 Joshua Hoblitt 5 5 * 6 * $Id: nebclient.c,v 1. 2 2005-01-18 23:36:40jhoblitt Exp $6 * $Id: nebclient.c,v 1.3 2005-06-06 21:21:05 jhoblitt Exp $ 7 7 */ 8 8 … … 22 22 #define ERRBUF_SIZE 255 23 23 24 static off_t idataCopyFile(char *source, char *dest); 25 static off_t idataCopyFilehandle(int sourceFH, int destFH); 26 24 27 void idataServerInit(idataServer *server) 25 28 { … … 56 59 if (soap_call_ns1__create_USCOREobject(server, NULL, NULL, key, class, volume, comment, &response) == SOAP_OK) { 57 60 *URI = xmalloc(strlen(response.result)); 58 strcpy(*URI, response.result);61 strcpy(*URI, response.result); 59 62 60 63 if (!idataParseURI(*URI, &filename)) { … … 82 85 struct ns1__replicate_USCOREobjectResponse response; 83 86 char *filename; 84 int file;87 int sourceFH, destFH; 85 88 86 89 if (soap_call_ns1__replicate_USCOREobject(server, NULL, NULL, key, volume, &response) == SOAP_OK) { 87 90 *URI = xmalloc(strlen(response.result)); 88 strcpy(*URI, response.result);91 strcpy(*URI, response.result); 89 92 90 93 if (!idataParseURI(*URI, &filename)) { … … 94 97 } 95 98 96 //idataOpen(key, "read"); 97 //idataCopyFilehandle( 98 99 sourceFH = idataOpen(server, key, IDATA_READ); 100 if (sourceFH == -1) { 101 fprintf(stderr, "can not open key %s\n", key ); 102 103 return -1; 104 } 105 106 destFH = open(filename, O_RDWR|O_TRUNC, 0660); 107 if (destFH == -1) { 108 fprintf(stderr, "can not open %s: %s\n", filename, strerror(errno)); 109 110 return -1; 111 } 112 113 idataCopyFilehandle(sourceFH, destFH); 114 115 if (close(sourceFH) == -1) { 116 fprintf(stderr, "can not close file: %s", strerror(errno)); 117 118 return -1; 119 } 120 121 if (close(destFH) == -1) { 122 fprintf(stderr, "can not close %s: %s", filename, strerror(errno)); 123 124 return -1; 125 } 99 126 } 100 127 … … 121 148 } 122 149 123 int idataFindInstances(idataServer *server, char *key, char *volume ) 124 { 125 126 return 0; 150 int idataFindInstances(idataServer *server, char *key, char *volume, char ***locations) 151 { 152 struct ns1__find_USCOREinstancesResponse response; 153 int resultElements = 0; 154 int i; 155 char **resultArray; 156 char **loc; 157 158 // FIXME is this leaking memory when response goes out of scope? 159 if (soap_call_ns1__find_USCOREinstances(server, NULL, NULL, key, volume, &response) == SOAP_OK) { 160 161 resultElements = response.result->__size; 162 resultArray = response.result->__ptr; 163 164 loc = xmalloc(sizeof(char*) * resultElements); 165 166 for (i = 0; i < resultElements; i++) { 167 loc[i] = xmalloc(strlen(resultArray[i]) + 1); 168 169 strcpy(loc[i], resultArray[i]); 170 } 171 172 *locations = loc; 173 174 return resultElements; 175 } 176 177 // server error 178 return -1; 127 179 } 128 180 -
trunk/Nebulous/nebclient/src/nebclient.h
r3048 r4121 4 4 * Copyright (C) 2005 Joshua Hoblitt 5 5 * 6 * $Id: nebclient.h,v 1. 4 2005-01-19 00:18:08jhoblitt Exp $6 * $Id: nebclient.h,v 1.5 2005-06-06 21:21:05 jhoblitt Exp $ 7 7 */ 8 8 … … 31 31 int idataUnlock(idataServer *server, char *key, rw flag); 32 32 33 int idataFindInstances(idataServer *server, char *key, char *volume );33 int idataFindInstances(idataServer *server, char *key, char *volume, char ***locations); 34 34 35 35 int idataFind(idataServer *server, char *key); … … 53 53 void idataFree(void *ptr); 54 54 55 static off_t idataCopyFile(char *source, char *dest);56 57 static off_t idataCopyFilehandle(int sourceFH, int destFH);58 59 55 #endif // IDATACLIENT_H
Note:
See TracChangeset
for help on using the changeset viewer.
