Changeset 18937 for trunk/psModules/src/config/pmConfigCommand.c
- Timestamp:
- Aug 5, 2008, 5:07:36 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfigCommand.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfigCommand.c
r18908 r18937 13 13 PS_ASSERT_PTR_NON_NULL(command, false); 14 14 PS_ASSERT_PTR_NON_NULL(config, false); 15 PS_ASSERT_PTR_NON_NULL(config->user, false);16 15 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; 37 27 } 38 28 39 29 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); 41 31 42 32 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
