Changeset 4646
- Timestamp:
- Jul 28, 2005, 11:55:52 AM (21 years ago)
- Location:
- trunk/Nebulous/nebclient
- Files:
-
- 3 edited
-
src/nebclient.c (modified) (4 diffs)
-
src/nebclient.h (modified) (3 diffs)
-
tests/tests.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/nebclient/src/nebclient.c
r4639 r4646 4 4 * Copyright (C) 2005 Joshua Hoblitt 5 5 * 6 * $Id: nebclient.c,v 1. 29 2005-07-28 04:13:32 jhoblitt Exp $6 * $Id: nebclient.c,v 1.30 2005-07-28 21:55:52 jhoblitt Exp $ 7 7 */ 8 8 … … 37 37 static size_t nebParseURI(nebServer *server, const char *URI, char **filename); 38 38 static bool nebNukeFile(nebServer *server, const char *filename); 39 static char *nullstrncpy(char *dest, const char *src, size_t n); 39 40 40 41 nebServer *nebServerAlloc(const char *endpoint) … … 457 458 } 458 459 459 int nebStat(nebServer *server, const char *key) 460 { 461 462 return 0; 460 nebObjectStat *nebStat(nebServer *server, const char *key) 461 { 462 struct ns1__stat_USCOREobjectResponse response; 463 nebObjectStat *stat; 464 int resultElements = 0; 465 char **resultArray = NULL; 466 467 stat = xmalloc(sizeof(nebObjectStat)); 468 469 // FIXME is this leaking memory when response goes out of scope? 470 if (soap_call_ns1__stat_USCOREobject(server->soap, server->endpoint, 471 NULL, (char *)key, &response) != SOAP_OK) { 472 nebSetServerErr(server); 473 return NULL; 474 } 475 476 resultElements = response.result->__size; 477 resultArray = response.result->__ptr; 478 479 if (resultElements != 8) { 480 nebSetErr(server, "server didn't return the proper number of stat elements"); 481 return NULL; 482 } 483 484 nullstrncpy(stat->so_id, resultArray[0], 256); 485 nullstrncpy(stat->ext_id, resultArray[1], 256); 486 nullstrncpy(stat->class_id, resultArray[2], 256); 487 nullstrncpy(stat->comment, resultArray[3], 256); 488 nullstrncpy(stat->read_lock, resultArray[4], 256); 489 nullstrncpy(stat->write_lock, resultArray[5], 256); 490 nullstrncpy(stat->epoch, resultArray[6], 256); 491 nullstrncpy(stat->mtime, resultArray[7], 256); 492 493 return stat; 463 494 } 464 495 … … 681 712 return true; 682 713 } 714 715 static char *nullstrncpy(char *dest, const char *src, size_t n) { 716 if (!src) { 717 dest = NULL; 718 return dest; 719 } 720 721 return strncpy(dest, src, n); 722 } -
trunk/Nebulous/nebclient/src/nebclient.h
r4635 r4646 4 4 * Copyright (C) 2005 Joshua Hoblitt 5 5 * 6 * $Id: nebclient.h,v 1.2 1 2005-07-28 02:07:13jhoblitt Exp $6 * $Id: nebclient.h,v 1.22 2005-07-28 21:55:52 jhoblitt Exp $ 7 7 */ 8 8 … … 21 21 char *endpoint; 22 22 } nebServer; 23 24 typedef struct { 25 char so_id[256]; 26 char ext_id[256]; 27 char class_id[256]; 28 char comment[256]; 29 char read_lock[256]; 30 char write_lock[256]; 31 char epoch[256]; 32 char mtime[256]; 33 } nebObjectStat; 23 34 24 35 nebServer *nebServerAlloc(const char *endpoint); … … 50 61 bool nebDeleteInstance(nebServer *server, const char *URI); 51 62 52 intnebStat(nebServer *server, const char *key);63 nebObjectStat *nebStat(nebServer *server, const char *key); 53 64 54 65 char *nebErr(nebServer *server); -
trunk/Nebulous/nebclient/tests/tests.c
r4640 r4646 1 1 #include <stdio.h> 2 #include <stdlib.h> 2 3 #include <unistd.h> 3 4 #include <stdbool.h> … … 21 22 char *key = "foobarbaz"; 22 23 23 TESTS( 19);24 TESTS(20); 24 25 25 26 if (getenv("NEBULOUS_SERVER")) { … … 50 51 51 52 OK(nebCull(server, key), "cull object"); 53 54 OK(nebStat(server, key), "stat object"); 52 55 53 56 OK(nebLock(server, key, NEB_WRITE), "lock object write");
Note:
See TracChangeset
for help on using the changeset viewer.
