IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 28, 2005, 11:55:52 AM (21 years ago)
Author:
jhoblitt
Message:

add nebObjectStat
change nebStat() to return nebObjectStat
add nullstrncpy()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/nebclient/src/nebclient.c

    r4639 r4646  
    44 * Copyright (C) 2005  Joshua Hoblitt
    55 *
    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 $
    77 */
    88
     
    3737static size_t nebParseURI(nebServer *server, const char *URI, char **filename);
    3838static bool nebNukeFile(nebServer *server, const char *filename);
     39static char *nullstrncpy(char *dest, const char *src, size_t n);
    3940
    4041nebServer *nebServerAlloc(const char *endpoint)
     
    457458}
    458459
    459 int nebStat(nebServer *server, const char *key)
    460 {
    461 
    462     return 0;
     460nebObjectStat *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;
    463494}
    464495
     
    681712    return true;
    682713}
     714
     715static 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}
Note: See TracChangeset for help on using the changeset viewer.