header

md_api.h

Go to the documentation of this file.
00001 /*
00002   Copyright (c) Members of the EGEE Collaboration. 2004. 
00003   See http://www.eu-egee.org/partners/ for details on the copyright
00004   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 
00019 
00020 #ifndef MD_API_H
00021 #define MD_API_H
00022 
00023 // Compatibility with FUSE
00024 #define _FILE_OFFSET_BITS 64
00025 
00026 #include <string>
00027 #include <list>
00028 #include <vector>
00029 
00030 #include <sys/types.h>
00031 #include <dirent.h>
00032 
00033 #define MD_ERR_OK 0
00034 #define MD_ERR_NOENT 1
00035 #define MD_ERR_ILCMD 3
00036 #define MD_ERR_PERM 4
00037 #define MD_ERR_INTERNAL 9
00038 #define MD_ERR_NOKEY 7
00039 
00040 
00041 class MDClient;
00042 
00043 class AttributeList{
00044  public:
00045   friend int getAttr(const std::string &pattern,
00046                      const std::list <std::string > &keys,
00047                      AttributeList &attributes);
00048   AttributeList(int columns);
00049   ~AttributeList();
00050 
00051   int getRow(std::string &file, 
00052              std::vector < std::string >  &attributes);
00053   bool lastRow();
00054 
00055  private:
00056   void connect(MDClient *c); 
00057   MDClient *client;
00058   unsigned int columns;
00059 };
00060 
00061 
00062 class EntryList{
00063  public:
00064   friend int findEntries(const std::string &pattern,
00065                          const std::string &query,
00066                          EntryList &entries);
00067   EntryList();
00068   ~EntryList();
00069 
00070   int getEntry(std::string &file);
00071   int cancel();
00072   bool lastEntry();
00073 
00074  private:
00075   void connect(MDClient *c);
00076   MDClient *client;
00077 };
00078 
00079 
00080 class UploadHandle{
00081  public:
00082   friend int upload(const std::string &dir,
00083                     const std::vector<std::string > &keys,
00084                     UploadHandle &handle);
00085   UploadHandle();
00086   ~UploadHandle();
00087 
00088   int put(const std::string &entry,
00089           const std::vector<std::string > &values);
00090 
00091   int abort();
00092   int commit();
00093 
00094  private:
00095   void connect(MDClient *c);
00096   MDClient *client;
00097 };
00098 
00099 int translateError(int amga);
00100 
00101 int addAttr(const std::string &dir, const std::string &key,
00102             const std::string &type="varchar(256)");
00103 
00104 int getAttr(const std::string &file, const std::string &key,
00105             std::string &attr);
00106 
00107 int getAttr(MDClient &client, const std::string &file,
00108             const std::string &key, std::string &attr);
00109 
00110 int amgaStat(MDClient &client, const std::string &file,
00111              struct stat *stbuf);
00112 
00113 int amgaReadlink(MDClient &client,
00114                  const char *path, char *buf, size_t size);
00115 
00116 int setAttr(const std::string &file, const std::vector<std::string> &keys,
00117             const std::vector<std::string> &values);
00118 
00119 int setAttr(MDClient &client, const std::string &file,
00120             const std::vector<std::string> &keys,
00121             const std::vector<std::string> &values);
00122 
00123 int listAttr(MDClient &client,const std::string &file,
00124              std::list<std::string> &attrList, 
00125              std::list<std::string> &types);
00126 
00127 int listAttr(const std::string &file, std::list<std::string> &attrList,
00128              std::list<std::string> &types);
00129 
00130 int removeAttr(const std::string &file, const std::string &key);
00131 
00132 int clearAttr(const std::string &file, const std::string &key);
00133 
00134 int createDir(const std::string &dir);
00135 
00136 int getAttr(const std::string &pattern,
00137             const std::list <std::string > &keys,
00138             AttributeList &attributes);
00139 
00140 int findEntries(const std::string &pattern,
00141                 const std::string &query,
00142                 EntryList &entries);
00143 
00144 int link(const std::string &file, const std::string &URL);
00145 
00146 
00147 int upload(const std::string &dir,
00148            const std::vector<std::string > &keys,
00149            UploadHandle &handle);
00150 
00151 DIR *amgaOpendir(MDClient &client, const char *name);
00152 
00153 struct dirent *amgaReaddir(MDClient &client, DIR *dir);
00154 
00155 int amgaClosedir(MDClient &client, DIR *dir);
00156 
00157 #endif // MD_API_H

Generated on Mon Apr 16 13:59:17 2012 for AMGA by  doxygen 1.4.7