Remove DC_addWURemoteInput and DC_addWUInputAdvanced, merge into va_arg'ized

DC_addWUInput.


git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@2406 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
zfarkas 2010-09-29 13:36:40 +00:00 committed by Adam Visegradi
parent 1397ae1a2b
commit 2cb497ec58
7 changed files with 62 additions and 115 deletions

View File

@ -703,17 +703,13 @@ static int check_logical_name(DC_Workunit *wu, const char *logicalFileName)
}
int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode)
DC_FileMode fileMode, ...)
{
return DC_addWUInputAdvanced(wu, logicalFileName, URL, fileMode, NULL, NULL);
}
int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString)
{
DC_PhysicalFile *file;
char *workpath;
int ret;
va_list ap;
char *workpath;
DC_PhysicalFile *file;
DC_RemoteFile *rfile;
/* Sanity checks */
if (!wu || !logicalFileName)
@ -725,14 +721,38 @@ int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const ch
if (ret)
return ret;
/* XXX Check if the wu->num_inputs + wu->num_outputs + wu->subresults
* does not exceed the max. number of file slots */
/* Handle remote files */
if (DC_FILE_REMOTE == fileMode)
{
va_start(ap, fileMode);
char *md5 = va_arg(ap, char *);
int size = va_arg(ap, int);
va_end(ap);
rfile = _DC_createRemoteFile(logicalFileName, URL, md5, size);
if (!rfile)
return DC_ERR_INTERNAL;
wu->remote_input_files = g_list_append(wu->remote_input_files, rfile);
wu->num_remote_inputs++;
if (wu->serialized)
write_wudesc(wu);
return 0;
}
/* Now handle local files */
workpath = _DC_workDirPath(wu, logicalFileName, FILE_IN);
file = _DC_createPhysicalFile(logicalFileName, workpath);
g_free(workpath);
if (!file)
return DC_ERR_INTERNAL;
va_start(ap, fileMode);
char *physicalFileName = va_arg(ap, char *);
char *physicalFileHashString = va_arg(ap, char *);
va_end(ap);
if (physicalFileName)
{
file->physicalfilename = strdup(physicalFileName);
@ -799,36 +819,6 @@ int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const ch
return 0;
}
int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
const char *md5, const int size)
{
int ret;
DC_RemoteFile *file;
/* Sanity checks */
if (!wu || !logicalFileName || !URL || !md5 || !size)
{
DC_log(LOG_ERR, "%s: Missing arguments", __func__);
return DC_ERR_BADPARAM;
}
ret = check_logical_name(wu, logicalFileName);
if (ret)
return ret;
file = _DC_createRemoteFile(logicalFileName, URL, md5, size);
if (!file)
return DC_ERR_INTERNAL;
wu->remote_input_files = g_list_append(wu->remote_input_files, file);
wu->num_remote_inputs++;
if (wu->serialized)
write_wudesc(wu);
return 0;
}
int DC_addWUOutput(DC_Workunit *wu, const char *logicalFileName)
{
int ret;
@ -900,11 +890,11 @@ static int install_input_files(DC_Workunit *wu)
if (!f)
{
if (errno == EEXIST && file->physicalfilename)
{
DC_log(LOG_NOTICE, "File %s already exists under Boinc. Skipping...",hashFile->str);
}
else
{
{
DC_log(LOG_NOTICE, "File %s already exists under Boinc. Skipping...",hashFile->str);
}
else
{
DC_log(LOG_ERR, "Failed to create hash file %s: %s", hashFile->str,strerror(errno));
g_string_free(hashFile, TRUE);
g_free(dest);
@ -914,7 +904,7 @@ static int install_input_files(DC_Workunit *wu)
else
{
fprintf(f, "%s", file->physicalfilehash);
fclose(f);
fclose(f);
DC_log(LOG_DEBUG, "Hash file \"%s\" has been created with content \"%s\".", hashFile->str, file->physicalfilehash);
}
@ -1315,7 +1305,6 @@ int DC_submitWU(DC_Workunit *wu)
l = l->next, i++)
{
DC_RemoteFile *file = (DC_RemoteFile *)l->data;
//infiles[i] = get_input_download_name(wu, file->label, NULL);
infiles[i] = g_strdup_printf("%s_%s", file->label, md5_string(file->url));
}
if (wu->ckpt_name)

View File

@ -431,26 +431,12 @@ DC_destroyWU(DC_Workunit *wu)
}
int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString)
{
DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__);
return DC_ERR_INTERNAL;
}
int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
const char *md5, const int size)
{
DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__);
return DC_ERR_INTERNAL;
}
/* Sets an input file for the work unit. */
int
DC_addWUInput(DC_Workunit *wu,
const char *logicalFileName,
const char *URL,
DC_FileMode fileMode)
DC_FileMode fileMode, ...)
{
DC_PhysicalFile *file;
char *workpath;
@ -458,6 +444,15 @@ DC_addWUInput(DC_Workunit *wu,
if (!_DC_wu_check(wu))
return(DC_ERR_UNKNOWN_WU);
/* Remote file aren't supported */
if (DC_FILE_REMOTE == fileMode)
{
DC_log(LOG_ERR, "Unsupported file mode for input file %s",
logicalFileName);
return(DC_ERR_BADPARAM);
}
DC_log(LOG_DEBUG, "DC_addWUInput(%p-\"%s\", %s, %s, %d)",
wu, wu->data.name, logicalFileName, URL, fileMode);

View File

@ -269,23 +269,8 @@ units in state %DC_WU_READY (i.e., before the work unit is submitted).
@fileMode: usage mode of the file. Passing %DC_FILE_PERSISTENT or
%DC_FILE_VOLATILE allows DC-API to optimize the disk space
requirements of the application.
@Returns: 0 if successful or a #DC_ErrorCode.
<!-- ##### FUNCTION DC_addWURemoteInput ##### -->
<para>
Adds a remote input file to a work unit. This function may be called only for
work units in state %DC_WU_READY (i.e., before the work unit is submitted).
</para>
@wu: the work unit to add the input file to.
@logicalFileName: the logical file name the client will use to refer to this
input file. The client should call the DC_resolveFileName() function
with the %DC_FILE_IN file type and this name to get the real name of
the file on the local system.
@URL: remote URL of the input file.
@md5: the MD5 hash of the remote input file.
@size: the size of the remote input file in bytes.
@Varargs: in case using %DC_FILE_REMOTE file mode, the MD5 hash string (char *)
and file size information (int) have to be passed.
@Returns: 0 if successful or a #DC_ErrorCode.

View File

@ -59,6 +59,7 @@ Tells how should DC-API treat physical files passed to it.
lets DC-API use symbolic or hard links instead of copying to save space.
@DC_FILE_VOLATILE: the application does not want to use the file in any way in
the future. DC-API will remove the file when it is no longer needed.
@DC_FILE_REMOTE: the application uses a remote file not physically present.
<!-- ##### MACRO DC_CONFIG_FILE ##### -->
<para>
@ -99,16 +100,6 @@ Describes a physical file.
@physicalfilename:
@physicalfilehash:
<!-- ##### STRUCT DC_RemoteFile ##### -->
<para>
Describes a remote file.
</para>
@label: logical name of the file as used by the application.
@url: URL of the remote file.
@remotefilehash: MD5 hash of the remote file.
@remotefilesize: size of the remote file in bytes.
<!-- ##### FUNCTION DC_getCfgStr ##### -->
<para>
Returns the value belonging to the specified key @name in the configuration file.

View File

@ -147,15 +147,7 @@ DC_Workunit *DC_createWU(const char *clientName, const char *arguments[],
/* Sets an input file for the work unit. */
int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode);
/* Sets a remote input file for the work unit. */
int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
const char *md5, const int size);
/* Sets an input file for the work unit. */
int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString);
DC_FileMode fileMode, ...);
/* Defines an output file for the work unit. */
int DC_addWUOutput(DC_Workunit *wu, const char *logicalFileName);

View File

@ -63,7 +63,8 @@ typedef enum {
typedef enum {
DC_FILE_REGULAR, /* Not persistent, needs copy */
DC_FILE_PERSISTENT, /* Persistent, link is enough */
DC_FILE_VOLATILE /* DC-API should remove the original */
DC_FILE_VOLATILE, /* DC-API should remove the original */
DC_FILE_REMOTE /* HTTP files physically not present */
} DC_FileMode;
/* Default name of the configuration file */

View File

@ -502,22 +502,8 @@ static int copy_file(const char *src, const char *dst)
return 0;
}
int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString)
{
DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__);
return DC_ERR_INTERNAL;
}
int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
const char *md5, const int size)
{
DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__);
return DC_ERR_INTERNAL;
}
int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
DC_FileMode fileMode)
DC_FileMode fileMode, ...)
{
DC_PhysicalFile *file;
char *workpath;
@ -528,6 +514,14 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
if (ret)
return ret;
/* Remote files aren't supported */
if (DC_FILE_REMOTE == fileMode)
{
DC_log(LOG_ERR, "Unsupported file mode for input file %s",
logicalFileName);
return DC_ERR_BADPARAM;
}
workpath = get_workdir_path(wu, logicalFileName, FILE_IN);
file = _DC_createPhysicalFile(logicalFileName, workpath);
g_free(workpath);