mirror of https://github.com/BOINC/boinc.git
initial checkin
git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@516 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
parent
e57e1a12ea
commit
6ce4254b41
|
@ -0,0 +1,67 @@
|
||||||
|
#include "dc_client.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Initializes the client API. */
|
||||||
|
int DC_init(void)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Resolves the local name of input/output files. */
|
||||||
|
char *DC_resolveFileName(DC_FileType type,
|
||||||
|
const char *logicalFileName)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Sends a sub-result back to the master. */
|
||||||
|
int DC_sendResult(const char *logicalFileName,
|
||||||
|
const char *path,
|
||||||
|
DC_FileMode fileMode)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Sends a message to the master. */
|
||||||
|
int DC_sendMessage(const char *message)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Checks for application control events. */
|
||||||
|
DC_Event *DC_checkEvent(void)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Destroys the event-specific data returned by DC_checkEvent(). */
|
||||||
|
void DC_destroyEvent(DC_Event *event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Indicates that an application-level checkpoint has completed. */
|
||||||
|
void DC_checkpointMade(const char *fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Informs the user interface about the fraction of work already done. */
|
||||||
|
void DC_fractionDone(double fraction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Finishes computation. */
|
||||||
|
void DC_finish(int exitcode)
|
||||||
|
{
|
||||||
|
for (;;) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of condor/client.c */
|
|
@ -0,0 +1,107 @@
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "dc_common.h"
|
||||||
|
|
||||||
|
#include "condor_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Determines the maximum allowed message length. */
|
||||||
|
int DC_getMaxMessageSize(void)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Determines the maximum number of sub-results. */
|
||||||
|
int DC_getMaxSubresults(void)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Determines the basic capabilities of the underlying grid infrastructure. */
|
||||||
|
DC_GridCapabilities DC_getGridCapabilities(void)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#define COPY_BUFSIZE 65536
|
||||||
|
int copy_file(const char *src, const char *dst)
|
||||||
|
{
|
||||||
|
int sfd, dfd;
|
||||||
|
ssize_t ret;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
buf= (char *)g_malloc(COPY_BUFSIZE);
|
||||||
|
sfd= open(src, O_RDONLY);
|
||||||
|
if (sfd == -1)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Failed to open %s for copying: %s", src,
|
||||||
|
strerror(errno));
|
||||||
|
g_free(buf);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
dfd= open(dst, O_WRONLY | O_CREAT | O_TRUNC);
|
||||||
|
if (dfd == -1)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Failed to create %s: %s", dst, strerror(errno));
|
||||||
|
g_free(buf);
|
||||||
|
close(sfd);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((ret= read(sfd, buf, COPY_BUFSIZE)) > 0)
|
||||||
|
{
|
||||||
|
char *ptr= buf;
|
||||||
|
while (ret)
|
||||||
|
{
|
||||||
|
ssize_t ret2= write(dfd, ptr, ret);
|
||||||
|
if (ret2 < 0)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Error writing to %s: %s", dst,
|
||||||
|
strerror(errno));
|
||||||
|
close(sfd);
|
||||||
|
close(dfd);
|
||||||
|
unlink(dst);
|
||||||
|
g_free(buf);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
ret -= ret2;
|
||||||
|
ptr += ret2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Error reading from %s: %s", src, strerror(errno));
|
||||||
|
close(sfd);
|
||||||
|
close(dfd);
|
||||||
|
g_free(buf);
|
||||||
|
unlink(dst);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(buf);
|
||||||
|
close(sfd);
|
||||||
|
if (close(dfd))
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Error writing to %s: %s", dst, strerror(errno));
|
||||||
|
unlink(dst);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of condor/common.c */
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _DC_API_CONDOR_COMMON_H_
|
||||||
|
#define _DC_API_CONDOR_COMMON_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
extern int copy_file(const char *src, const char *dst);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,57 @@
|
||||||
|
#ifndef __DC_API_CONDOR_DEFS_H_
|
||||||
|
#define __DC_API_CONDOR_DEFS_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <uuid/uuid.h>
|
||||||
|
|
||||||
|
#include "dc.h"
|
||||||
|
#include "dc_internal.h"
|
||||||
|
|
||||||
|
extern char project_uuid_str[37];
|
||||||
|
|
||||||
|
struct _DC_Workunit
|
||||||
|
{
|
||||||
|
char *client_name;
|
||||||
|
char **argv;
|
||||||
|
int argc;
|
||||||
|
char *tag;
|
||||||
|
int subresults;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
uuid_t uuid;
|
||||||
|
char *uuid_str;
|
||||||
|
DC_WUState state;
|
||||||
|
|
||||||
|
char *condor_id;
|
||||||
|
char *workdir;
|
||||||
|
|
||||||
|
GList *input_files;
|
||||||
|
GList *output_files;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _DC_Result
|
||||||
|
{
|
||||||
|
DC_Workunit *wu;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
FILE_IN,
|
||||||
|
FILE_OUT,
|
||||||
|
FILE_CKPT,
|
||||||
|
FILE_DCAPI
|
||||||
|
} WorkdirFile;
|
||||||
|
|
||||||
|
#define CFG_WORKDIR "WorkingDirectory"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* End of condor/condor_defs.h */
|
|
@ -0,0 +1,390 @@
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "dc.h"
|
||||||
|
|
||||||
|
#include "condor_server.h"
|
||||||
|
#include "condor_common.h"
|
||||||
|
#include "condor_defs.h"
|
||||||
|
#include "condor_wu.h"
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************* INIT */
|
||||||
|
|
||||||
|
static GHashTable *wu_table= NULL;
|
||||||
|
uuid_t project_uuid;
|
||||||
|
char project_uuid_str[37]= "";
|
||||||
|
|
||||||
|
/* Initializes the DC-API. */
|
||||||
|
int DC_init(const char *configFile)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
char *cfgval= NULL;
|
||||||
|
|
||||||
|
if (!wu_table)
|
||||||
|
wu_table= g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
|
||||||
|
|
||||||
|
ret= uuid_parse((char *)cfgval, project_uuid);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Invalid project UUID");
|
||||||
|
g_free(cfgval);
|
||||||
|
return(DC_ERR_CONFIG);
|
||||||
|
}
|
||||||
|
g_free(cfgval);
|
||||||
|
|
||||||
|
/* Enforce a canonical string representation of the UUID */
|
||||||
|
uuid_unparse_lower(project_uuid, project_uuid_str);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************** Manage WU structure */
|
||||||
|
|
||||||
|
/* Creates one work unit. */
|
||||||
|
DC_Workunit *DC_createWU(const char *clientName,
|
||||||
|
const char *arguments[],
|
||||||
|
int subresults,
|
||||||
|
const char *tag)
|
||||||
|
{
|
||||||
|
DC_Workunit *wu;
|
||||||
|
char uuid_str[37];
|
||||||
|
char *cfgval;
|
||||||
|
GString *str;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
wu= g_new0(DC_Workunit, 1);
|
||||||
|
|
||||||
|
wu->argv= g_strdupv((char **)arguments);
|
||||||
|
for (wu->argc= 0; arguments && arguments[wu->argc]; wu->argc++)
|
||||||
|
;
|
||||||
|
wu->subresults= subresults;
|
||||||
|
wu->tag= g_strdup(tag);
|
||||||
|
|
||||||
|
uuid_generate(wu->uuid);
|
||||||
|
uuid_unparse_lower(wu->uuid, uuid_str);
|
||||||
|
wu->uuid_str= g_strdup(uuid_str);
|
||||||
|
|
||||||
|
if (tag)
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Calculate & create the working directory. The working directory
|
||||||
|
* has the form:
|
||||||
|
* <project work dir>/.dcapi-<project uuid>/<hash>/<wu uuid>
|
||||||
|
* Where <hash> is the first 2 hex digits of the uuid
|
||||||
|
*/
|
||||||
|
cfgval= DC_getCfgStr(CFG_WORKDIR);
|
||||||
|
str= g_string_new(cfgval);
|
||||||
|
free(cfgval);
|
||||||
|
g_string_append_c(str, G_DIR_SEPARATOR);
|
||||||
|
g_string_append(str, ".dcapi-");
|
||||||
|
g_string_append(str, project_uuid_str);
|
||||||
|
g_string_append_c(str, G_DIR_SEPARATOR);
|
||||||
|
g_string_append_printf(str, "%02x", wu->uuid[0]);
|
||||||
|
g_string_append_c(str, G_DIR_SEPARATOR);
|
||||||
|
g_string_append(str, uuid_str);
|
||||||
|
|
||||||
|
ret= g_mkdir_with_parents(str->str, 0700);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Failed to create WU working directory %s: %s",
|
||||||
|
str->str, strerror(errno));
|
||||||
|
DC_destroyWU(wu);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wu->workdir= str->str;
|
||||||
|
g_string_free(str, FALSE);
|
||||||
|
|
||||||
|
if (!wu_table)
|
||||||
|
DC_init(NULL);
|
||||||
|
g_hash_table_insert(wu_table, wu->name, wu);
|
||||||
|
|
||||||
|
return(wu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Releases internal resources allocated to a work unit. */
|
||||||
|
void DC_destroyWU(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
if (!wu)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (wu_table)
|
||||||
|
g_hash_table_remove(wu_table, wu->name);
|
||||||
|
|
||||||
|
g_free(wu->client_name);
|
||||||
|
g_free(wu->uuid_str);
|
||||||
|
g_strfreev(wu->argv);
|
||||||
|
g_free(wu->tag);
|
||||||
|
g_free(wu->name);
|
||||||
|
|
||||||
|
g_free(wu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Sets an input file for the work unit. */
|
||||||
|
int DC_addWUInput(DC_Workunit *wu,
|
||||||
|
const char *logicalFileName,
|
||||||
|
const char *URL,
|
||||||
|
DC_FileMode fileMode)
|
||||||
|
{
|
||||||
|
DC_PhysicalFile *file;
|
||||||
|
char *workpath;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Sanity checks */
|
||||||
|
ret= check_logical_name(wu, logicalFileName);
|
||||||
|
if (ret)
|
||||||
|
return(ret);
|
||||||
|
|
||||||
|
workpath= get_workdir_path(wu, logicalFileName, FILE_IN);
|
||||||
|
file= _DC_createPhysicalFile(logicalFileName, workpath);
|
||||||
|
g_free(workpath);
|
||||||
|
if (!file)
|
||||||
|
return(DC_ERR_INTERNAL);
|
||||||
|
|
||||||
|
switch (fileMode)
|
||||||
|
{
|
||||||
|
case DC_FILE_REGULAR:
|
||||||
|
ret= copy_file(URL, file->path);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
_DC_destroyPhysicalFile(file);
|
||||||
|
return(DC_ERR_BADPARAM); /* XXX */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DC_FILE_PERSISTENT:
|
||||||
|
ret= link(URL, file->path);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Failed to link %s to %s: %s",
|
||||||
|
URL, file->path, strerror(errno));
|
||||||
|
_DC_destroyPhysicalFile(file);
|
||||||
|
return(DC_ERR_BADPARAM); /* XXX */
|
||||||
|
}
|
||||||
|
/* Remember the file mode */
|
||||||
|
file->mode= DC_FILE_PERSISTENT;
|
||||||
|
break;
|
||||||
|
case DC_FILE_VOLATILE:
|
||||||
|
ret= rename(URL, file->path);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Failed to rename %s to %s: %s",
|
||||||
|
URL, file->path, strerror(errno));
|
||||||
|
_DC_destroyPhysicalFile(file);
|
||||||
|
return(DC_ERR_BADPARAM);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wu->input_files= g_list_append(wu->input_files, file);
|
||||||
|
/*wu->num_inputs++;*/
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Defines an output file for the work unit. */
|
||||||
|
int DC_addWUOutput(DC_Workunit *wu,
|
||||||
|
const char *logicalFileName)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Sets the priority for the work unit. */
|
||||||
|
int DC_setWUPriority(DC_Workunit *wu,
|
||||||
|
int priority)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Sets the callback functions that will be called when a particular event. */
|
||||||
|
void DC_setcb(DC_ResultCallback resultcb,
|
||||||
|
DC_SubresultCallback subresultcb,
|
||||||
|
DC_MessageCallback msgcb)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Queries the state of a work unit. */
|
||||||
|
DC_WUState DC_getWUState(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(DC_WU_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Queries the low-level ID of the work unit. */
|
||||||
|
char *DC_getWUId(const DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Queries the tag of a work unit. */
|
||||||
|
char *DC_getWUTag(const DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Serializes a work unit description. */
|
||||||
|
char *DC_serializeWU(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Restores a serialized work unit. */
|
||||||
|
DC_Workunit *DC_deserializeWU(const char *buf)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Queries the number of WUs known to the API in the given state. */
|
||||||
|
int DC_getWUNumber(DC_WUState state)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************** Main cycles */
|
||||||
|
|
||||||
|
/* Waits for events and processes them. */
|
||||||
|
int DC_processEvents(int timeout)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Checks for events and return them. */
|
||||||
|
DC_Event *DC_waitEvent(const char *wuFilter,
|
||||||
|
int timeout)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Checks for events for a particular WU. */
|
||||||
|
DC_Event *DC_waitWUEvent(DC_Workunit *wu,
|
||||||
|
int timeout)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Destroys an event. */
|
||||||
|
void DC_destroyEvent(DC_Event *event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************** Manage WUs */
|
||||||
|
|
||||||
|
/* Submits a work unit. */
|
||||||
|
int DC_submitWU(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Cancels all computations for a given work unit. */
|
||||||
|
int DC_cancelWU(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Temporarily suspends the execution of a work unit. */
|
||||||
|
int DC_suspendWU(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Resumes computation of a previously suspended work unit. */
|
||||||
|
int DC_resumeWU(DC_Workunit *wu)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************** Messaging */
|
||||||
|
|
||||||
|
/* Sends a message to a running work unit. */
|
||||||
|
int DC_sendWUMessage(DC_Workunit *wu,
|
||||||
|
const char *message)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************** Result handling */
|
||||||
|
|
||||||
|
/* Queries what optional fields are present in the result. */
|
||||||
|
unsigned DC_getResultCapabilities(const DC_Result *result)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns the WU that generated this result. */
|
||||||
|
DC_Workunit *DC_getResultWU(DC_Result *result)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns the exit code of the client application. */
|
||||||
|
int DC_getResultExit(const DC_Result *result)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns the local name of an output file. */
|
||||||
|
char *DC_getResultOutput(const DC_Result *result,
|
||||||
|
const char *logicalFileName)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
DC_PhysicalFile *_DC_createPhysicalFile(const char *label,
|
||||||
|
const char *path)
|
||||||
|
{
|
||||||
|
DC_PhysicalFile *file;
|
||||||
|
|
||||||
|
file= g_new(DC_PhysicalFile, 1);
|
||||||
|
file->label= g_strdup(label);
|
||||||
|
file->path= g_strdup(path);
|
||||||
|
file->mode= DC_FILE_REGULAR;
|
||||||
|
|
||||||
|
return(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void _DC_destroyPhysicalFile(DC_PhysicalFile *file)
|
||||||
|
{
|
||||||
|
if (!file)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free(file->label);
|
||||||
|
g_free(file->path);
|
||||||
|
g_free(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of condor/server.c */
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef _DC_API_CONDOR_SERVER_H_
|
||||||
|
#define _DC_API_CONDOR_SERVER_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "dc.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern DC_PhysicalFile *_DC_createPhysicalFile(const char *label,
|
||||||
|
const char *path);
|
||||||
|
extern void _DC_destroyPhysicalFile(DC_PhysicalFile *file);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include <glib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "dc.h"
|
||||||
|
|
||||||
|
#include "condor_wu.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/* Check if the logical name is not already registered */
|
||||||
|
int check_logical_name(DC_Workunit *wu, const char *logicalFileName)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
if (strchr(logicalFileName, '/') || strchr(logicalFileName, '\\'))
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "Illegal characters in logical file name %s",
|
||||||
|
logicalFileName);
|
||||||
|
return(DC_ERR_BADPARAM);
|
||||||
|
}
|
||||||
|
for (l= wu->input_files; l; l= l->next)
|
||||||
|
{
|
||||||
|
DC_PhysicalFile *file= (DC_PhysicalFile *)l->data;
|
||||||
|
|
||||||
|
if (!strcmp(file->label, logicalFileName))
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "File %s is already registered as an "
|
||||||
|
"input file", logicalFileName);
|
||||||
|
return(DC_ERR_BADPARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (l= wu->output_files; l; l= l->next)
|
||||||
|
{
|
||||||
|
if (!strcmp((char *)l->data, logicalFileName))
|
||||||
|
{
|
||||||
|
DC_log(LOG_ERR, "File %s is already registered as an "
|
||||||
|
"output file", logicalFileName);
|
||||||
|
return(DC_ERR_BADPARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *get_workdir_path(DC_Workunit *wu,
|
||||||
|
const char *label,
|
||||||
|
WorkdirFile type)
|
||||||
|
{
|
||||||
|
return g_strdup_printf("%s%c%s", wu->workdir, G_DIR_SEPARATOR, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of condor/condor_wu.c */
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef _DC_API_CONDOR_WU_H_
|
||||||
|
#define _DC_API_CONDOR_WU_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "condor_defs.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern int check_logical_name(DC_Workunit *wu,
|
||||||
|
const char *logicalFileName);
|
||||||
|
extern char *get_workdir_path(DC_Workunit *wu,
|
||||||
|
const char *label,
|
||||||
|
WorkdirFile type);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* End of condor/condor_wu.h */
|
Loading…
Reference in New Issue