CERN org.glite.Gfal  2.0.1
/builddir/build/BUILD/gfal2-2.0.0/src/common/srm/gfal_common_srm.h
Go to the documentation of this file.
00001 #pragma once
00002 /*
00003  * Copyright (c) Members of the EGEE Collaboration. 2004.
00004  * See http://www.eu-egee.org/partners/ for details on the copyright holders.
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  * 
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  * 
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00027 #include <string.h>
00028 #include <regex.h>
00029 
00030 #include <common/gfal_prototypes.h>
00031 #include <common/gfal_types.h>
00032 #include <common/gfal_constants.h>
00033 #include <externals/gsimplecache/gcachemain.h>
00034 
00035 
00036 
00037 #define GFAL_PREFIX_SRM "srm://"
00038 #define GFAL_ENDPOINT_DEFAULT_PREFIX "httpg://"
00039 
00040 #define SRM_XATTR_GETURL "user.replicas"
00041 
00042 #define GFAL_SRM_LSTAT_PREFIX "lstat_"
00043 
00044 //typedef struct srm_spacemd gfal_spacemd;
00045 enum status_type {DEFAULT_STATUS = 0, MD_STATUS, PIN_STATUS};
00046 
00047 enum se_type {TYPE_NONE = 0, TYPE_SRM, TYPE_SRMv2, TYPE_SE};
00048 enum gfal_srm_proto {PROTO_SRM=0, PROTO_SRMv2, PROTO_ERROR_UNKNOW};
00049 
00050 
00055 typedef struct _gfal_request_state{
00056         char *                                          srmv2_token;
00057         struct srmv2_filestatus *       srmv2_statuses;
00058         struct srmv2_pinfilestatus *srmv2_pinstatuses;
00059         enum gfal_srm_proto current_request_proto;
00060         char *                                          request_endpoint; 
00061         gboolean                                        finished;                       // finished or not
00062         int                                                     number;                         // number of files in request
00063  } gfal_request_state;
00064 
00065 
00066  
00071 typedef struct _gfal_srmv2_opt{
00072         enum gfal_srm_proto srm_proto_type;             // default protocol version
00073         int opt_srmv2_desiredpintime;                   //      optional desired default endpoint
00074         char** opt_srmv2_protocols;                             // optional protocols list for manual set
00075         char** opt_srmv2_tp3_protocols;
00076         char * opt_srmv2_spacetokendesc;                // optional spacetokens desc for srmv2   
00077         regex_t rexurl;
00078         regex_t rex_full;
00079         gfal_handle handle;
00080         gint64 filesizes;
00081         gfal_request_state* last_request_state;
00082         GSimpleCache* cache;
00083 } gfal_srmv2_opt;
00084 
00085 typedef gfal_srmv2_opt* gfal_srm_plugin_t;
00086 
00087 
00088 
00089 typedef struct _gfal_srm_result{
00090         char turl[GFAL_URL_MAX_LEN+1]; // turl associated with the request ( main result )
00091         char *reqtoken; // token of the request ( common to all result of a request )
00092         int err_code;           // errcode, !=0 if error
00093         char err_str[GFAL_ERRMSG_LEN+1];        // explanation about the error
00094 } gfal_srm_result;
00095 
00096 typedef struct _gfal_srm_params{
00097         char** protocols;                               // optional protocols list for manual set
00098         enum gfal_srm_proto proto_version;              // default protocol version
00099         char * spacetokendesc;          // optional spacetokens desc for srmv2   
00100         int desiredpintime;                     //      optional desired default endpoint
00101 }* gfal_srm_params_t;
00102 
00103 typedef void* srm_request_handle;
00104 
00105 const char* gfal_srm_getName();
00106 
00107 gfal_plugin_interface gfal_srm_initG(gfal_handle handle, GError** err);
00108 
00109 void gfal_srm_destroyG(plugin_handle ch);
00110 
00111 void gfal_srm_opt_initG(gfal_srmv2_opt* opts, gfal_handle handle);
00112 
00113 
00114 inline char* gfal_srm_construct_key(const char* url, const char* prefix, char* buff, const size_t s_buff);
00115 void gfal_set_default_storageG(gfal_srmv2_opt* opts, enum gfal_srm_proto proto);
00116 
00117 
00118 int gfal_srm_convert_filestatuses_to_GError(struct srmv2_filestatus* statuses, int n, GError** err);
00119 
00120 
00121                                         
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130