/Home/aooliver/work/stagersvc/org.glite.data.lcg_gfal/src/lrc_ifce.c File Reference

#include <errno.h>
#include <string.h>
#include "stdsoap2.h"
#include "lrcH.h"
#include "edg_local_replica_catalogSoapBinding+.nsmap"
#include "lrcC.c"
#include "lrcClient.c"
#include "gfal_api.h"

Go to the source code of this file.

Defines

#define SOAP_FMAC3   static
#define SOAP_FMAC5   static

Functions

static int lrc_init (struct soap *soap, char *errbuf, int errbufsz)
char * lrc_get_catalog_endpoint (char *errbuf, int errbufsz)
int lrc_replica_exists (const char *guid, char *errbuf, int errbufsz)
char * lrc_guidforpfn (const char *pfn, char *errbuf, int errbufsz)
 lrc_guid_exists (const char *guid, char *errbuf, int errbufsz)
 lrc_register_pfn (const char *guid, const char *pfn, char *errbuf, int errbufsz)
 lrc_setfilesize (const char *pfn, GFAL_LONG64 filesize, char *errbuf, int errbufsz)
char * lrc_surlfromguid (const char *guid, char *errbuf, int errbufsz)
char ** lrc_surlsfromguid (const char *guid, char *errbuf, int errbufsz)
 lrc_unregister_pfn (const char *guid, const char *pfn, char *errbuf, int errbufsz)

Variables

char * lrc_endpoint
char * rmc_endpoint


Define Documentation

#define SOAP_FMAC3   static
 

Definition at line 13 of file lrc_ifce.c.

#define SOAP_FMAC5   static
 

Definition at line 15 of file lrc_ifce.c.


Function Documentation

char* lrc_get_catalog_endpoint char *  errbuf,
int  errbufsz
 

Definition at line 54 of file lrc_ifce.c.

References lrc_endpoint, and lrc_init().

Referenced by get_catalog_endpoint().

00054                                                      {
00055         struct soap soap;
00056         if(lrc_init(&soap, errbuf, errbufsz) < 0)
00057                 return (NULL);
00058         return lrc_endpoint;
00059 }

lrc_guid_exists const char *  guid,
char *  errbuf,
int  errbufsz
 

Definition at line 136 of file lrc_ifce.c.

References gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by guid_exists().

00137 {
00138         struct ns3__guidExistsResponse out;
00139         int ret;
00140         struct soap soap;
00141 
00142         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00143                 return (-1);
00144 
00145         if (ret = soap_call_ns3__guidExists (&soap, lrc_endpoint, "",
00146             (char *) guid, &out)) {
00147                 gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00148                 soap_end (&soap);
00149                 soap_done (&soap);      
00150                 errno = ECOMM;
00151                 return (-1);
00152         }
00153         ret = out._guidExistsReturn ? 1 : 0;
00154         soap_end (&soap);
00155         soap_done (&soap);
00156         return (ret);
00157 }

char* lrc_guidforpfn const char *  pfn,
char *  errbuf,
int  errbufsz
 

Definition at line 101 of file lrc_ifce.c.

References gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by guidforpfn().

00102 {
00103         struct ns3__guidForPfnResponse out;
00104         char *p;
00105         int ret;
00106         int sav_errno;
00107         struct soap soap;
00108 
00109         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00110                 return (NULL);
00111 
00112         if (ret = soap_call_ns3__guidForPfn (&soap, lrc_endpoint, "",
00113             (char *) pfn, &out)) {
00114                 if (ret == SOAP_FAULT) {
00115                         if (strstr (soap.fault->faultcode, "NOSUCHPFN"))
00116                                 sav_errno = ENOENT;
00117                         else {
00118                           gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00119                                 sav_errno = ECOMM;
00120                         }
00121                 } else {
00122                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00123                         sav_errno = ECOMM;
00124                 }
00125                 soap_end (&soap);
00126                 soap_done (&soap);
00127                 errno = sav_errno;
00128                 return (NULL);
00129         }
00130         p = strdup (out._guidForPfnReturn);
00131         soap_end (&soap);
00132         soap_done (&soap);
00133         return (p);
00134 }

static int lrc_init struct soap *  soap,
char *  errbuf,
int  errbufsz
[static]
 

Definition at line 29 of file lrc_ifce.c.

References get_rls_endpointsx(), lrc_endpoint, and rmc_endpoint.

Referenced by lrc_get_catalog_endpoint(), lrc_guid_exists(), lrc_guidforpfn(), lrc_register_pfn(), lrc_replica_exists(), lrc_setfilesize(), lrc_surlfromguid(), lrc_surlsfromguid(), and lrc_unregister_pfn().

00030 {
00031         int flags;
00032 
00033         soap_init (soap);
00034         soap->namespaces = namespaces_lrc;
00035 
00036         if (lrc_endpoint == NULL &&
00037             (lrc_endpoint = getenv ("LRC_ENDPOINT")) == NULL &&
00038             get_rls_endpointsx (&lrc_endpoint, &rmc_endpoint, errbuf, errbufsz)) {
00039                 errno = EINVAL;
00040                 return (-1);
00041         }
00042 
00043 #ifdef GFAL_SECURE
00044         if (strncmp (lrc_endpoint, "https", 5) == 0) {
00045                 flags = CGSI_OPT_SSL_COMPATIBLE;
00046                 soap_register_plugin_arg (soap, client_cgsi_plugin, &flags);
00047         }
00048 #endif
00049         return (0);
00050 }

lrc_register_pfn const char *  guid,
const char *  pfn,
char *  errbuf,
int  errbufsz
 

Definition at line 159 of file lrc_ifce.c.

References gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by register_pfn().

00160 {
00161         struct ns3__addMappingResponse out;
00162         int ret;
00163         int sav_errno;
00164         struct soap soap;
00165 
00166         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00167                 return (-1);
00168 
00169         if (ret = soap_call_ns3__addMapping (&soap, lrc_endpoint, "",
00170             (char *) guid, (char *) pfn, &out)) {
00171                 if (ret == SOAP_FAULT) {
00172                         if (strstr (soap.fault->faultcode, "PFNEXISTS"))
00173                                 sav_errno = EEXIST;
00174                         else if (strstr (soap.fault->faultcode, "VALUETOOLONG"))
00175                                 sav_errno = ENAMETOOLONG;
00176                         else {
00177                           gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00178                                 sav_errno = ECOMM;
00179                         }
00180                 } else {
00181                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00182                         sav_errno = ECOMM;
00183                 }
00184                 soap_end (&soap);
00185                 soap_done (&soap);
00186                 errno = sav_errno;
00187                 return (-1);
00188         }
00189         soap_end (&soap);
00190         soap_done (&soap);
00191         return (0);
00192 }

int lrc_replica_exists const char *  guid,
char *  errbuf,
int  errbufsz
 

Definition at line 62 of file lrc_ifce.c.

References gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by replica_exists().

00063 {
00064         struct ns3__getPfnsResponse out;
00065         int ret;
00066         int sav_errno;
00067         struct soap soap;
00068         char **surlarray;
00069 
00070         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00071                 return (-1);
00072 
00073         if (ret = soap_call_ns3__getPfns (&soap, lrc_endpoint, "",
00074             (char *) guid, &out)) {
00075                 if (ret == SOAP_FAULT) {
00076                   if (strstr (soap.fault->faultcode, "NOSUCHGUID"))
00077                                 sav_errno = 0;
00078                   else {
00079                 gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00080                                 sav_errno = ECOMM;
00081                   }
00082                 } else {
00083                   gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00084                         sav_errno = ECOMM;
00085                 }
00086                 soap_end (&soap);
00087                 soap_done (&soap);
00088                 // return 'false' if guid does not exist in LRC
00089                 if(sav_errno == 0)
00090                   return (0);
00091                 
00092                 errno = sav_errno;
00093                 return (-1);
00094         }
00095         soap_end (&soap);
00096         soap_done (&soap);
00097         return (out._getPfnsReturn->__size==0?0:1);
00098 }

lrc_setfilesize const char *  pfn,
GFAL_LONG64  filesize,
char *  errbuf,
int  errbufsz
 

Definition at line 194 of file lrc_ifce.c.

References gfal_errmsg(), GFAL_LONG64_FORMAT, lrc_endpoint, and lrc_init().

Referenced by setfilesize().

00195 {
00196         struct ns3__setStringPfnAttributeResponse out;
00197         int ret;
00198         int sav_errno;
00199         struct soap soap;
00200         char tmpbuf[21];
00201 
00202         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00203                 return (-1);
00204 
00205         sprintf (tmpbuf, GFAL_LONG64_FORMAT, filesize);
00206         if (ret = soap_call_ns3__setStringPfnAttribute (&soap, lrc_endpoint,
00207             "", (char *) pfn, "size", tmpbuf, &out)) {
00208                 if (ret == SOAP_FAULT) {
00209                         if (strstr (soap.fault->faultcode, "NOSUCHPFN"))
00210                                 sav_errno = ENOENT;
00211                         else {
00212                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00213                                 sav_errno = ECOMM;
00214                         }
00215                 } else {
00216                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00217                         sav_errno = ECOMM;
00218                 }
00219                 soap_end (&soap);
00220                 soap_done (&soap);
00221                 errno = sav_errno;
00222                 return (-1);
00223         }
00224         soap_end (&soap);
00225         soap_done (&soap);
00226         return (0);
00227 }

char* lrc_surlfromguid const char *  guid,
char *  errbuf,
int  errbufsz
 

Definition at line 230 of file lrc_ifce.c.

References getbestfile(), gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by surlfromguid().

00231 {
00232         struct ns3__getPfnsResponse out;
00233         char *p, *result;
00234         int ret;
00235         int sav_errno;
00236         struct soap soap;
00237         char **surls;
00238 
00239         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00240                 return (NULL);
00241 
00242         if (ret = soap_call_ns3__getPfns (&soap, lrc_endpoint, "",
00243             (char *) guid, &out)) {
00244                 if (ret == SOAP_FAULT) {
00245                         if (strstr (soap.fault->faultcode, "NOSUCHGUID"))
00246                                 sav_errno = ENOENT;
00247                         else {
00248                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00249                                 sav_errno = ECOMM;
00250                         }
00251                 } else {
00252                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00253                         sav_errno = ECOMM;
00254                 }
00255                 soap_end (&soap);
00256                 soap_done (&soap);
00257                 errno = sav_errno;
00258                 return (NULL);
00259         } else {
00260           result = getbestfile (out._getPfnsReturn->__ptr, 
00261                                 out._getPfnsReturn->__size, errbuf, errbufsz);
00262           if(result == NULL) {
00263             soap_end (&soap);
00264             soap_done (&soap);
00265             errno = EPROTONOSUPPORT;
00266             return (NULL);
00267           }
00268           p = strdup (result);
00269           soap_end (&soap);
00270           soap_done (&soap);
00271           return (p);
00272         }
00273           
00274 }

char** lrc_surlsfromguid const char *  guid,
char *  errbuf,
int  errbufsz
 

Definition at line 277 of file lrc_ifce.c.

References gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by surlsfromguid().

00278 {
00279         int i;
00280         int j;
00281         struct ns3__getPfnsResponse out;
00282         int ret;
00283         int sav_errno;
00284         struct soap soap;
00285         char **surlarray;
00286 
00287         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00288                 return (NULL);
00289 
00290         if (ret = soap_call_ns3__getPfns (&soap, lrc_endpoint, "",
00291             (char *) guid, &out)) {
00292                 if (ret == SOAP_FAULT) {
00293                         if (strstr (soap.fault->faultcode, "NOSUCHGUID"))
00294                                 sav_errno = ENOENT;
00295                         else {
00296                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00297                                 sav_errno = ECOMM;
00298                         }
00299                 } else {
00300                         gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00301                         sav_errno = ECOMM;
00302                 }
00303                 soap_end (&soap);
00304                 soap_done (&soap);
00305                 errno = sav_errno;
00306                 return (NULL);
00307         }
00308         if ((surlarray = calloc (out._getPfnsReturn->__size + 1, sizeof(char *))) == NULL) {
00309                 soap_end (&soap);
00310                 soap_done (&soap);
00311                 errno = ENOMEM;
00312                 return (NULL);
00313         }
00314         for (i = 0; i < out._getPfnsReturn->__size; i++) {
00315                 if ((surlarray[i] = strdup (out._getPfnsReturn->__ptr[i])) == NULL) {
00316                         for (j = 0; j < i; j++)
00317                                 free (surlarray[j]);
00318                         free (surlarray);
00319                         soap_end (&soap);
00320                         soap_done (&soap);
00321                         errno = ENOMEM;
00322                         return (NULL);
00323                 }
00324         }
00325         soap_end (&soap);
00326         soap_done (&soap);
00327         return (surlarray);
00328 }

lrc_unregister_pfn const char *  guid,
const char *  pfn,
char *  errbuf,
int  errbufsz
 

Definition at line 330 of file lrc_ifce.c.

References gfal_errmsg(), lrc_endpoint, and lrc_init().

Referenced by unregister_pfn().

00331 {
00332         struct ns3__removeMappingResponse out;
00333         int ret;
00334         struct soap soap;
00335 
00336         if (lrc_init (&soap, errbuf, errbufsz) < 0)
00337                 return (-1);
00338 
00339         if (ret = soap_call_ns3__removeMapping (&soap, lrc_endpoint, "",
00340             (char *) guid, (char *) pfn, &out)) {
00341                 gfal_errmsg(errbuf, errbufsz, soap.fault->faultstring);
00342                 soap_end (&soap);
00343                 soap_done (&soap);
00344                 errno = ECOMM;
00345                 return (-1);
00346         }
00347         soap_end (&soap);
00348         soap_done (&soap);
00349         return (0);
00350 }


Variable Documentation

char* lrc_endpoint
 

Definition at line 23 of file lrc_ifce.c.

Referenced by lrc_get_catalog_endpoint(), lrc_guid_exists(), lrc_guidforpfn(), lrc_init(), lrc_register_pfn(), lrc_replica_exists(), lrc_setfilesize(), lrc_surlfromguid(), lrc_surlsfromguid(), lrc_unregister_pfn(), and rmc_init().

char* rmc_endpoint
 

Definition at line 25 of file rmc_ifce.c.

Referenced by lrc_init(), rmc_guidfromlfn(), rmc_init(), rmc_lfnsforguid(), rmc_register_alias(), and rmc_unregister_alias().


Generated on Fri Sep 8 20:20:48 2006 for GFAL by  doxygen 1.4.6