IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 5, 2008, 5:07:36 PM (18 years ago)
Author:
Paul Price
Message:

Switching over to new system, using pmConfigUserSite.

File:
1 edited

Legend:

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

    r18908 r18937  
    1313    PS_ASSERT_PTR_NON_NULL(command, false);
    1414    PS_ASSERT_PTR_NON_NULL(config, false);
    15     PS_ASSERT_PTR_NON_NULL(config->user, false);
    1615
    17     bool mdok;                          // Status of MD lookup
    18     const char *dbserver = psMetadataLookupStr(&mdok, config->user, "DBSERVER"); // Database server
    19     if (!mdok || strlen(dbserver) == 0) {
    20         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBSERVER in site configuration.\n");
    21         return false;
    22     }
    23     const char *dbname = psMetadataLookupStr(&mdok, config->user, "DBNAME"); // Database name
    24     if (!mdok || strlen(dbname) == 0) {
    25         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBNAME in site configuration.\n");
    26         return false;
    27     }
    28     const char *dbuser = psMetadataLookupStr(&mdok, config->user, "DBUSER"); // Database user
    29     if (!mdok || strlen(dbuser) == 0) {
    30         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBUSER in site configuration.\n");
    31         return false;
    32     }
    33     const char *dbpassword = psMetadataLookupStr(&mdok, config->user, "DBPASSWORD"); // Database password
    34     if (!mdok || strlen(dbpassword) == 0) {
    35         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBPASSWORD in site configuration.\n");
    36         return false;
     16    // Connection details
     17    psMetadataItem *server = pmConfigUserSite(config, "DBSERVER",   PS_DATA_STRING);
     18    psMetadataItem *user   = pmConfigUserSite(config, "DBUSER",     PS_DATA_STRING);
     19    psMetadataItem *pass   = pmConfigUserSite(config, "DBPASSWORD", PS_DATA_STRING);
     20    psMetadataItem *name   = pmConfigUserSite(config, "DBNAME",     PS_DATA_STRING);
     21
     22    if (!server || !user || !pass || !name) {
     23        psWarning("Cannot find DBSERVER/DBUSER/DBPASSWORD/DBNAME in user or site configuration: "
     24                  "unable to connect to database.");
     25        psErrorClear();
     26        return NULL;
    3727    }
    3828
    3929    psStringAppend(command, " -dbserver %s -dbname %s -dbuser %s -dbpassword %s",
    40                    dbserver, dbname, dbuser, dbpassword);
     30                   server->data.str, name->data.str, user->data.str, pass->data.str);
    4131
    4232    return true;
Note: See TracChangeset for help on using the changeset viewer.