code beautifying

implementation of some wu info retrieving funcs

git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@642 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
drdani 2006-06-07 08:24:23 +00:00 committed by Adam Visegradi
parent fe6e0f0f4c
commit dbab02b4ef
2 changed files with 122 additions and 106 deletions

View File

@ -41,8 +41,7 @@ DC_initMaster (const char *configFile)
}
if (!wu_table)
wu_table =
g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
wu_table= g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
NULL);
cfgval= DC_getCfgStr(CFG_INSTANCEUUID);
@ -96,12 +95,11 @@ DC_createWU (const char *clientName,
wu->uuid_str= g_strdup(uuid_str);
if (tag)
wu->name =
g_strdup_printf ("%s_%s_%s", project_uuid_str,
wu->name= g_strdup_printf("%s_%s_%s", project_uuid_str,
uuid_str, tag);
else
wu->name =
g_strdup_printf ("%s_%s", project_uuid_str, uuid_str);
wu->name= g_strdup_printf("%s_%s", project_uuid_str,
uuid_str);
/* Calculate & create the working directory. The working directory
* has the form:
@ -168,7 +166,8 @@ DC_destroyWU (DC_Workunit * wu)
dir= g_dir_open(wu->workdir, 0, NULL);
/* The work directory should not contain any extra files, but
* just in case */
while (dir && (name= g_dir_read_name (dir)))
while (dir &&
(name= g_dir_read_name(dir)))
{
GString *str= g_string_new(wu->workdir);
g_string_append_c(str, G_DIR_SEPARATOR);
@ -296,7 +295,8 @@ DC_setWUPriority (DC_Workunit * wu, int priority)
/* Sets the callback functions that will be called when a particular event. */
void
DC_setMasterCb(DC_ResultCallback resultcb,
DC_SubresultCallback subresultcb, DC_MessageCallback msgcb)
DC_SubresultCallback subresultcb,
DC_MessageCallback msgcb)
{
}
@ -305,7 +305,9 @@ DC_setMasterCb (DC_ResultCallback resultcb,
DC_WUState
DC_getWUState(DC_Workunit *wu)
{
if (!wu)
return(DC_WU_UNKNOWN);
return(wu->state);
}
@ -321,7 +323,7 @@ DC_getWUId (const DC_Workunit * wu)
char *
DC_getWUTag(const DC_Workunit *wu)
{
return (0);
return(strdup(wu->tag));
}
@ -341,11 +343,25 @@ DC_deserializeWU (const char *buf)
}
/* iterator for DC_getWUNumber() */
static DC_WUState dd_look_for_state;
static void dd_check_state(void *key, void *value, void *ptr)
{
DC_Workunit *wu=(DC_Workunit *)value;
int *count= (int *)ptr;
if (wu->state == dd_look_for_state)
++(*count);
}
/* Queries the number of WUs known to the API in the given state. */
int
DC_getWUNumber(DC_WUState state)
{
return (0);
int val;
dd_look_for_state= state;
g_hash_table_foreach(wu_table, (GHFunc)dd_check_state, &val);
return(val);
}