Commit 3d2d50c1 authored by Dennis Waldron's avatar Dennis Waldron
Browse files

Added missing files from the conversion from CVS to SVN

parent 16456ee5
COMM
COMM Copyright (C) 2004 by CERN/IT/ADC/CA
COMM All rights reserved
COMM
COMM @(#)$RCSfile$ $Revision$ $Date$ CERN IT-ADC/CA Jean-Damien Durand
COMM Make job programs.
#include <Project.tmpl>
INCLUDES = FileName(..,h)
INCLUDES_CPP = FileName(..,/)
CPSHELL = /bin/sh
COMM
COMM Set this flag to -O for optimization, or -g for debug
COMM
#ifdef _WIN32
CCOPTIM =
#else
CCOPTIM = -g
#endif
JOBSPOOL = JobSpool
#ifdef StagerSuperUser
STAGERSUPERUSER0 = StagerSuperUser
#else
STAGERSUPERUSER0 = stage
#endif
#ifdef StagerSuperGroup
STAGERSUPERGROUP0 = StagerSuperGroup
#else
STAGERSUPERGROUP0 = st
#endif
STAGERSUPERUSER = -DSTAGERSUPERUSER=\"$(STAGERSUPERUSER0)\"
STAGERSUPERGROUP = -DSTAGERSUPERGROUP=\"$(STAGERSUPERGROUP0)\"
THREADFLAGS = $(MTCCFLAGS)
#if SOLARIS
LDLIBS = -lsocket -lnsl
#else
#if _AIX
#if defined(_IBMR2)
LDLIBS = -lodm
#endif
#else
#if linux
LDLIBS = $(ADNSLIB) -lnsl -Wl,-rpath-link,../shlib
#else
#if _WIN32
LDLIBS = wsock32.lib ws2_32.lib advapi32.lib
#endif
#endif
#endif
#endif
CFLAGS = -DBIN=\"$(BIN)\" $(CCOPTIM) -I$(INCLUDES) -I$(INCLUDES_CPP) $(SECURITYFLAG) $(THREADFLAGS) $(STAGERSUPERUSER) $(STAGERSUPERGROUP)
CPPFLAGS=$(CFLAGS) -I..
DEPLIB = DepSharedLibraryTargetName(shlib,shift)
GLOBLIB = -L../shlib -lshift -lcurl -ldl -lbat -llsf -llsbstream
PROGS_JOB = ProgramTargetName(stagerJob)
IPROGS_JOB = FileName($(BIN),ProgramTargetName(stagerJob))
EPROGS_JOB = FileName($(EXPORTBIN),stagerJob)
STAGERJOB_OBJS = stagerJob.Osuf RemoteJobSvc.Osuf \
stager_catalogInterface.Osuf stager_util.Osuf stager_messages.Osuf \
stager_extern_globals.Osuf stager_uuid.Osuf
#if BuildSecurity
GLOBLIB += -ldl
#endif
all: $(PROGS_JOB)
NormalProgramTarget(stagerJob, $(STAGERJOB_OBJS), $(DEPLIB), $(GLOBLIB) $(DBLIBS) $(LDLIBS))
MakeDepLibrary(lib,shift)
MakeDepSharedLibrary(shlib,shift)
install: $(BIN) $(IPROGS_JOB) $(JOBSPOOL)
MakeDir($(JOBSPOOL),stage,st,0755)
InstallProgram(stagerJob,$(BIN),$(STAGERSUPERUSER0),$(STAGERSUPERGROUP0),6755)
install.man:
export: $(EPROGS_JOB)
IEXPORT(stagerJob,$(EXPORTBIN),755)
exportman:
COMM###################### CLEANING RULES #######################
clean:
@echo cleaning in CurDir
-@RemoveFiles(FilesToClean)
clobber: clean
@echo clobbering in CurDir
-@RemoveFiles($(PROGS_JOB))
#if _WIN32
depend:
@echo Not supported on this platform
#else
depend:
makedepend -Y -- $(CFLAGS) -- *.c 2> /dev/null
#endif
Makefiles:
FORCE:
COMM DO NOT DELETE THIS LINE -- make depend depends on it.
/*
* $Id$
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <errno.h>
#include "serrno.h"
#include "stager_macros.h"
#include "RemoteJobSvc.h"
#include "Cglobals.h"
#include "stager_catalogInterface.h"
/* ----------------------------------------------------------------- */
/* stager_getRemJobAndDbSvc */
/* */
/* Purpose: Create/get the REMOTE JOB service inside a DB service */
/* */
/* Input: (struct Cstager_IJobSvc_t ***) jobSvc [JOB service] */
/* (struct C_Services_t ***) dbSvc [DB service] */
/* */
/* Output: Fills stgSvc */
/* ----------------------------------------------------------------- */
int DLL_DECL stager_getRemJobAndDbSvc(jobSvc,dbSvc)
struct Cstager_IJobSvc_t ***jobSvc;
struct C_Services_t ***dbSvc;
{
char *func = "stager_getRemJobAndDbSvc";
struct C_Services_t **svcs = NULL;
struct C_IService_t *iSvc = NULL;
struct Cstager_IJobSvc_t **svc;
static int SvcsKey = -1; /* Used by Cglobals_get */
int rc;
STAGER_LOG_ENTER();
if ((jobSvc == NULL) || (dbSvc == NULL)) {
serrno = EFAULT;
rc = -1;
goto stager_getStgSvcReturn;
}
svc = NULL;
rc = Cglobals_get(&SvcsKey,(void **)&svc,sizeof(struct Cstager_IJobSvc_t **));
if ((rc == -1) || (svc == NULL)) {
STAGER_LOG_ERROR(NULL,"Cglobals_get");
rc = -1;
goto stager_getStgSvcReturn;
}
if ( *svc == NULL ) {
if (stager_getDbSvc(&svcs) < 0) {
rc = -1;
goto stager_getStgSvcReturn;
}
rc = C_Services_service(*svcs,"RemoteJobSvc",SVC_REMOTEJOBSVC, &iSvc);
if ((rc == -1) || (iSvc == NULL)) {
serrno = SEINTERNAL;
STAGER_LOG_DB_ERROR(NULL,"C_Services_service",C_Services_errorMsg(*svcs));
rc = -1;
goto stager_getStgSvcReturn;
}
*svc = Cstager_IJobSvc_fromIService(iSvc);
} else {
if (stager_getDbSvc(&svcs) < 0) {
rc = -1;
goto stager_getStgSvcReturn;
}
}
*jobSvc = svc;
*dbSvc = svcs;
rc = 0;
stager_getStgSvcReturn:
STAGER_LOG_RETURN(rc);
}
/*
* $Id$
*/
#ifndef _RemoteJobSvc_h
#define _RemoteJobSvc_h
#include "castor/stager/IJobSvc.h"
#include "castor/Services.h"
#include "castor/Constants.h"
#include "castor/BaseAddress.h"
#include "castor/IObject.h"
#include "castor/IAddress.h"
EXTERN_C int DLL_DECL stager_getRemJobAndDbSvc _PROTO((struct Cstager_IJobSvc_t ***, struct C_Services_t ***));
#endif /* _RemoteJobSvc_h */
This diff is collapsed.
/*
* $Id: stager_catalogInterface.c,v 1.9 2007/02/21 09:46:22 sponcec3 Exp $
*/
/*
* Copyright (C) 2004 by CERN/IT/ADC/CA
* All rights reserved
*/
/*
* Credits go to Olof Barring - I cut/pasted his original well-done catalog interface */
/* ============== */
/* System headers */
/* ============== */
#include <errno.h>
/* ============= */
/* Local headers */
/* ============= */
#include "serrno.h"
#include "Cglobals.h"
#include "stager_macros.h"
#include "stager_catalogInterface.h"
/* ---------------------------------------------------- */
/* stager_getDbSvc */
/* */
/* Purpose: Create/get the DB service */
/* */
/* Input: (struct C_Services_t ***) dbSvc [DB service] */
/* */
/* Output: Fills dbSvc */
/* ---------------------------------------------------- */
int DLL_DECL stager_getDbSvc(dbSvc)
struct C_Services_t ***dbSvc;
{
char *func = "stager_getDbSvc";
struct C_Services_t **svc;
int rc;
static int svcsKey = -1; /* Used by Cglobals_get */
STAGER_LOG_ENTER();
if (dbSvc == NULL) {
serrno = EFAULT;
rc = -1;
goto stager_getDbSvcReturn;
}
svc = NULL;
rc = Cglobals_get(&svcsKey,(void **)&svc,sizeof(struct C_Services_t **));
if ((rc == -1) || (svc == NULL)) {
serrno = SEINTERNAL;
STAGER_LOG_ERROR(NULL,"Cglobals_get");
rc = -1;
goto stager_getDbSvcReturn;
}
if ( *svc == NULL ) {
if (C_Services_create(svc) < 0) {
STAGER_LOG_ERROR(NULL,"C_Services_create");
goto stager_getDbSvcReturn;
}
}
*dbSvc = svc;
rc = 0;
stager_getDbSvcReturn:
STAGER_LOG_RETURN(rc);
}
/* ----------------------------------------------------------------- */
/* stager_getStgAndDbSvc */
/* */
/* Purpose: Create/get the STAGER service inside a DB service */
/* */
/* Input: (struct Cstager_IStagerSvc_t ***) stgSvc [STAGER service] */
/* (struct C_Services_t ***) dbSvc [DB service] */
/* */
/* Output: Fills stgSvc */
/* ----------------------------------------------------------------- */
int DLL_DECL stager_getStgAndDbSvc(stgSvc,dbSvc)
struct Cstager_IStagerSvc_t ***stgSvc;
struct C_Services_t ***dbSvc;
{
char *func = "stager_getStgAndDbSvc";
struct C_Services_t **svcs = NULL;
struct C_IService_t *iSvc = NULL;
struct Cstager_IStagerSvc_t **svc;
static int SvcsKey = -1; /* Used by Cglobals_get */
int rc;
STAGER_LOG_ENTER();
if ((stgSvc == NULL) || (dbSvc == NULL)) {
serrno = EFAULT;
rc = -1;
goto stager_getStgSvcReturn;
}
svc = NULL;
rc = Cglobals_get(&SvcsKey,(void **)&svc,sizeof(struct Cstager_IStagerSvc_t **));
if ((rc == -1) || (svc == NULL)) {
STAGER_LOG_ERROR(NULL,"Cglobals_get");
rc = -1;
goto stager_getStgSvcReturn;
}
if ( *svc == NULL ) {
if (stager_getDbSvc(&svcs) < 0) {
rc = -1;
goto stager_getStgSvcReturn;
}
rc = C_Services_service(*svcs,"DbStagerSvc",SVC_DBSTAGERSVC, &iSvc);
if ((rc == -1) || (iSvc == NULL)) {
serrno = SEINTERNAL;
STAGER_LOG_DB_ERROR(NULL,"C_Services_service",C_Services_errorMsg(*svcs));
rc = -1;
goto stager_getStgSvcReturn;
}
*svc = Cstager_IStagerSvc_fromIService(iSvc);
} else {
if (stager_getDbSvc(&svcs) < 0) {
rc = -1;
goto stager_getStgSvcReturn;
}
}
*stgSvc = svc;
*dbSvc = svcs;
rc = 0;
stager_getStgSvcReturn:
STAGER_LOG_RETURN(rc);
}
/* ----------------------------------------------------------------- */
/* stager_getJobSvc */
/* */
/* Purpose: Create/get the JOB service */
/* */
/* Input: (struct Cstager_IJobSvc_t ***) jobSvc */
/* */
/* */
/* Output: Fills jobSvc */
/* ----------------------------------------------------------------- */
int DLL_DECL stager_getJobSvc(jobSvc)
struct Cstager_IJobSvc_t ***jobSvc;
{
char *func = "stager_getJobSvc";
struct C_Services_t **svcs = NULL;
struct C_IService_t *iSvc = NULL;
struct Cstager_IJobSvc_t **svc;
static int SvcsKey = -1; /* Used by Cglobals_get */
int rc;
STAGER_LOG_ENTER();
if ((jobSvc == NULL)) {
serrno = EFAULT;
rc = -1;
goto stager_getJobSvcReturn;
}
svc = NULL;
rc = Cglobals_get(&SvcsKey,(void **)&svc,sizeof(struct Cstager_IJobSvc_t **));
if ((rc == -1) || (svc == NULL)) {
STAGER_LOG_ERROR(NULL,"Cglobals_get");
rc = -1;
goto stager_getJobSvcReturn;
}
if ( *svc == NULL ) {
if (stager_getDbSvc(&svcs) < 0) {
rc = -1;
goto stager_getJobSvcReturn;
}
rc = C_Services_service(*svcs,"DbJobSvc",SVC_DBJOBSVC, &iSvc);
if ((rc == -1) || (iSvc == NULL)) {
serrno = SEINTERNAL;
STAGER_LOG_DB_ERROR(NULL,"C_Services_service",C_Services_errorMsg(*svcs));
rc = -1;
goto stager_getJobSvcReturn;
}
*svc = Cstager_IJobSvc_fromIService(iSvc);
} else {
if (stager_getDbSvc(&svcs) < 0) {
rc = -1;
goto stager_getJobSvcReturn;
}
}
*jobSvc = svc;
rc = 0;
stager_getJobSvcReturn:
STAGER_LOG_RETURN(rc);
}
/*
* $Id: stager_extern_globals.c,v 1.2 2007/02/21 09:46:22 sponcec3 Exp $
*/
/*
* Copyright (C) 2004 by CERN/IT/ADC/CA
* All rights reserved
*/
#include "stager_extern_globals.h"
int stagerNoDlf;
int stagerTrace;
int stagerDebug;
char *stagerLog;
Cuuid_t stagerUuid;
/*
* $Id: stager_messages.c,v 1.5 2007/08/27 16:00:00 sponcec3 Exp $
*/
/*
* Copyright (C) 2004 by CERN/IT/ADC/CA
* All rights reserved
*/
/* ============== */
/* System headers */
/* ============== */
#include <sys/types.h>
/* ============= */
/* Local headers */
/* ============= */
#include "stager_messages.h"
#include "stager_macros.h" /* For STAGER_NB_ELEMENTS */
#include "log.h"
struct stagerMessages stagerMessages[] = {
{ STAGER_MSG_EMERGENCY, DLF_LVL_EMERGENCY, LOG_EMERG, "EMERGENCY", "emergency"},
{ STAGER_MSG_ALERT , DLF_LVL_ALERT , LOG_ALERT, "ALERT" , "alert"},
{ STAGER_MSG_ERROR , DLF_LVL_ERROR , LOG_ERR, "ERROR" , "error"},
{ STAGER_MSG_SYSCALL , DLF_LVL_ERROR , LOG_ERR, "ERROR" , "system call error"},
{ STAGER_MSG_WARNING , DLF_LVL_WARNING , LOG_WARNING, "WARNING" , "warning"},
{ STAGER_MSG_AUTH , DLF_LVL_AUTH , LOG_ERR, "AUTH" , "authentication"},
{ STAGER_MSG_SECURITY , DLF_LVL_SECURITY, LOG_ERR, "SECURITY" , "security"},
{ STAGER_MSG_USAGE , DLF_LVL_USAGE , LOG_INFO, "USAGE" , "usage"},
{ STAGER_MSG_ENTER , DLF_LVL_USAGE , LOG_INFO, "USAGE" , "function enter"},
{ STAGER_MSG_LEAVE , DLF_LVL_USAGE , LOG_INFO, "USAGE" , "function leave"},
{ STAGER_MSG_RETURN , DLF_LVL_USAGE , LOG_INFO, "USAGE" , "function return"},
{ STAGER_MSG_SYSTEM , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "system"},
{ STAGER_MSG_STARTUP , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "stager server started"},
{ STAGER_MSG_IMPORTANT, DLF_LVL_IMPORTANT, LOG_CRIT, "IMPORTANT", "important"},
{ STAGER_MSG_DEBUG , DLF_LVL_DEBUG , LOG_DEBUG, "DEBUG" , "debug"},
{ STAGER_MSG_EXIT , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "stager server exiting"},
{ STAGER_MSG_RESTART , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "stager server restart"},
{ STAGER_MSG_FQUERY , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "Processing File Query by fileName"},
{ STAGER_MSG_RQUERY , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "Processing Request Query"},
{ STAGER_MSG_IQUERY , DLF_LVL_SYSTEM , LOG_INFO, "SYSTEM" , "Processing File Query by fileId"}
};
int DLL_DECL stager_messagesNbElements() {
return(STAGER_NB_ELEMENTS(stagerMessages));
}
/*
* $Id: stager_util.c,v 1.6 2007/12/07 11:40:54 sponcec3 Exp $
*/
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h> /* For INT_MIN and INT_MAX */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#ifndef _WIN32
#include <unistd.h>
#else
#include <winsock2.h>
#endif
#include <stdarg.h>
#include "osdep.h"
#include "stager_util.h"
#include "Cns_api.h"
#include "serrno.h"
#include "u64subr.h"
#include "stager_extern_globals.h"
#include "stager_messages.h"
#include "stager_uuid.h"
#include "dlf_api.h"
#include "log.h"
#ifdef SIXMONTHS
#undef SIXMONTHS
#endif
#define SIXMONTHS (6*30*24*60*60)
#if defined(_WIN32)
static char strftime_format_sixmonthsold[] = "%b %d %Y";
static char strftime_format[] = "%b %d %H:%M:%S";
#else /* _WIN32 */
static char strftime_format_sixmonthsold[] = "%b %e %Y";
static char strftime_format[] = "%b %e %H:%M:%S";
#endif /* _WIN32 */
void DLL_DECL stager_util_time(this,timestr)
time_t this;
char *timestr;
{
time_t this_time = time(NULL);
#if defined(_REENTRANT) || defined(_THREAD_SAFE)
struct tm tmstruc;
#endif /* _REENTRANT || _THREAD_SAFE */
struct tm *tp;
#if ((defined(_REENTRANT) || defined(_THREAD_SAFE)) && !defined(_WIN32))
localtime_r(&(this),&tmstruc);
tp = &tmstruc;
#else
tp = localtime(&(this));
#endif /* _REENTRANT || _THREAD_SAFE */
if ((this_time >= this) && ((this_time - this) > SIXMONTHS)) {
/* Too much in past */
strftime(timestr,64,strftime_format_sixmonthsold,tp);
} else if ((this_time < this) && ((this - this_time) > SIXMONTHS)) {
/* Too much in feature...! */
strftime(timestr,64,strftime_format_sixmonthsold,tp);
} else {
strftime(timestr,64,strftime_format,tp);
}
}
void DLL_DECL stager_log(const char *func, const char *file, int line, int what, struct Cns_fileid *fileid, ...)
{
va_list args;
char *message;
char *valueStr;
int valueInt;
void *valueVoid;
char *message2;
char *value2Str;
int value2Int;
/* Gcc does not like statement like: xxxx ? 1 : "" */
/* It will issue a warning about type mismatch... */
/* So I will convert the integers to string */
int _save_serrno = serrno;
va_start(args, fileid);
message = va_arg(args, char *);
if (message != NULL) {
if ((strcmp(message, "STRING") == 0) || (strcmp(message, "SIGNAL NAME") == 0)) {
valueStr = va_arg(args, char *);
} else {
valueInt = va_arg(args, int);
}
message2 = va_arg(args, char *);
if (message2 != NULL) {
if ((strcmp(message2, "STRING") == 0) || (strcmp(message2, "SIGNAL NAME") == 0)) {
value2Str = va_arg(args, char *);
} else {
value2Int = va_arg(args, int);
}
if (! stagerNoDlf) {
if ((strcmp(message, "STRING") == 0) || (strcmp(message, "SIGNAL NAME") == 0)) {
if ((strcmp(message2, "STRING") == 0) || (strcmp(message2, "SIGNAL NAME") == 0)) {
dlf_write(
stager_request_uuid,
stagerMessages[what].defaultSeverity,
what,
fileid,
STAGER_NB_PARAMS+3,
stagerMessages[what].what2Type,DLF_MSG_PARAM_STR,func,
message,DLF_MSG_PARAM_STR,valueStr,
message2,DLF_MSG_PARAM_STR,value2Str,
STAGER_LOG_WHERE(file,line)
);