IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 25, 2007, 2:05:18 PM (19 years ago)
Author:
jhoblitt
Message:

add first pass nebclient support/linking
change pmConfigConvertFilename() to accept a boolean create [file] parameter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r11245 r11292  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-01-23 03:19:35 $
     6 *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-01-26 00:05:18 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2424#include <glob.h>
    2525#include <pslib.h>
     26
    2627#include "pmConfig.h"
     28#include "pmErrorCodes.h"
    2729#include "pmConfigRecipes.h"
    2830#include "pmConfigCamera.h"
     31
     32#ifdef HAVE_NEBCLIENT
     33#include <nebclient.h>
     34#endif // ifdef HAVE_NEBCLIENT
    2935
    3036#define PS_SITE "PS_SITE"         // Name of the environment variable containing the site config file
     
    10471053
    10481054// convert the supplied name, create a new output psString
    1049 psString pmConfigConvertFilename(const char *filename, const pmConfig *config)
     1055psString pmConfigConvertFilename(const char *filename, const pmConfig *config, bool create)
    10501056{
    10511057    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    10521058    PS_ASSERT_PTR_NON_NULL(config, NULL);
    10531059
    1054     psString newName = psStringCopy (filename);
    1055 
    10561060    // strip file:// from front of name
    1057     if (!strncasecmp (newName, "file:", strlen("file:"))) {
     1061    if (!strncasecmp(filename, "file:", strlen("file:"))) {
     1062        psString newName = psStringCopy(filename);
     1063
    10581064        char *point = newName + strlen("file:");
    10591065        while (*point == '/')
     
    10631069        psFree (newName);
    10641070        newName = tmpName;
     1071
     1072        return newName;
    10651073    }
    10661074
    10671075    // replace path://PATH with matched datapath
    1068     if (!strncasecmp (newName, "path://", strlen("path://"))) {
     1076    if (!strncasecmp(filename, "path://", strlen("path://"))) {
    10691077        PS_ASSERT_METADATA_NON_NULL(config->site, NULL);
     1078
     1079        psString newName = psStringCopy(filename);
    10701080
    10711081        // filename should be of the form: path://PATH/rest/of/file
     
    11021112        psFree(newName);
    11031113        newName = tmpName;
     1114
     1115        return newName;
    11041116    }
    11051117
    11061118    // substitute neb://name with matched nebulous name
    1107 
    1108     return newName;
    1109 }
     1119    if (!strncasecmp(filename, "neb://", strlen("neb://"))) {
     1120        #ifdef HAVE_NEBCLIENT
     1121
     1122        bool status = false;
     1123        psString nebulous_server = psMetadataLookupStr(&status, config->site, "NEBULOUS_SERVER");
     1124        if (!status) {
     1125            psError(PM_ERR_CONFIG, true, "failed to lookup config value for NEBULOUS_SERVER.");
     1126            return NULL;
     1127        }
     1128        if (!nebulous_server) {
     1129            psError(PM_ERR_CONFIG, true, "Could not determine nebulous server URI.");
     1130            return NULL;
     1131        }
     1132
     1133        nebServer *server = nebServerAlloc(nebulous_server);
     1134        if (!server) {
     1135            psError(PM_ERR_SYS, true, "failed to create a nebServer object.");
     1136            nebServerFree(server);
     1137            return NULL;
     1138        }
     1139
     1140        psString newName = psStringCopy(filename);
     1141
     1142        // for for the nebulous key
     1143        char *foo = nebFind(server, newName);
     1144        // if it doesn't exist, create it
     1145        if (!foo) {
     1146            foo = nebCreate(server, newName, 0, NULL, NULL, NULL);
     1147        }
     1148
     1149        psFree(newName);
     1150        psString newFoo = psStringCopy(foo);
     1151        psFree(foo);
     1152        nebServerFree(server);
     1153
     1154        return newFoo;
     1155
     1156        #else // ifdef HAVE_NEBCLIENT
     1157
     1158        psError(PM_ERR_PROG, true, "psModules was compiled without nebulous support.");
     1159        return NULL;
     1160        #endif // ifdef HAVE_NEBCLIENT
     1161
     1162    }
     1163
     1164    // if we go this far, do nothing
     1165    return psStringCopy(filename);
     1166}
Note: See TracChangeset for help on using the changeset viewer.