Use DC_getClientCfgStr to get client informations

git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@552 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
vida 2006-05-12 12:53:37 +00:00 committed by Adam Visegradi
parent e330ac5e6e
commit 5faea1e62c
1 changed files with 6 additions and 25 deletions

View File

@ -86,9 +86,6 @@ DC_Workunit *DC_createWU(const char *clientName, const char *arguments[],
{ {
char uuid_str[37]; char uuid_str[37];
DC_Workunit *wu; DC_Workunit *wu;
char *p;
char *clientStr;
const char *cfgval;
if (subresults > MAX_SUBRESULTS){ if (subresults > MAX_SUBRESULTS){
DC_log(LOG_ERR, "DC_createWU: The given subresult number: %d is too high. (max:%d)", DC_log(LOG_ERR, "DC_createWU: The given subresult number: %d is too high. (max:%d)",
@ -134,37 +131,21 @@ DC_Workunit *DC_createWU(const char *clientName, const char *arguments[],
return NULL; return NULL;
} }
clientStr = g_strdup_printf("client-%s-linux", clientName); wu->client_name = DC_getClientCfgStr(clientName, "name", FALSE);
cfgval = DC_getCfgStr(clientStr); wu->client_path = DC_getClientCfgStr(clientName, "path", FALSE);
if (!cfgval) if (!wu->client_name || !wu->client_path)
{ {
DC_log(LOG_ERR, "Failed to create WU. Unknown client name: %s", clientName); DC_log(LOG_ERR, "Failed to create WU. Cannot find client name\n"
DC_log(LOG_ERR, "Define client application in the config file: client-%s-linux", clientName); "Define client application in the config file:\n"
"[Client-%s]\nname = <client name>\npath = <client path>", clientName);
DC_destroyWU(wu); DC_destroyWU(wu);
g_free(clientStr);
return NULL; return NULL;
} }
p = strrchr(cfgval, '/');
if (p == NULL)
{
wu->client_name = g_strdup(cfgval);
wu->client_path = g_strdup(".");
}
else
{
wu->client_path = g_strdup(cfgval);
wu->client_path[strlen(wu->client_path)-strlen(p)] = 0;
p++;
wu->client_name = g_strdup(p);
}
DC_log(LOG_DEBUG, "client path: %s, client name: %s from client: %s", DC_log(LOG_DEBUG, "client path: %s, client name: %s from client: %s",
wu->client_path, wu->client_name, clientName); wu->client_path, wu->client_name, clientName);
g_free(clientStr);
if (!wu_table) if (!wu_table)
wu_table = g_hash_table_new_full(g_str_hash, g_str_equal, wu_table = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, NULL); NULL, NULL);