utils.h

Go to the documentation of this file.
00001 /** @file   include/dmlite/c/utils.h
00002  *  @brief  C wrapper for DMLite utils.
00003  *  @author Alejandro Álvarez Ayllon <aalvarez@cern.ch>
00004  */
00005 #ifndef DMLITE_UTILS_H
00006 #define DMLITE_UTILS_H
00007 
00008 #include <limits.h>
00009 #include <stdint.h>
00010 
00011 #define ACL_ENTRIES_MAX 300
00012 #define ACL_SIZE         13
00013 #define CSUMTYPE_MAX      3
00014 #define CSUMVALUE_MAX    33
00015 #define GUID_MAX         36
00016 #ifndef HOST_NAME_MAX
00017 # define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
00018 #endif
00019 #define QUERY_MAX      1024
00020 #define SCHEME_MAX        7
00021 #define URL_MAX        8192
00022 
00023 #define ACL_USER_OBJ  1
00024 #define ACL_USER      2
00025 #define ACL_GROUP_OBJ 3
00026 #define ACL_GROUP     4
00027 #define ACL_MASK      5
00028 #define ACL_OTHER     6
00029 #define ACL_DEFAULT   0x20
00030 
00031 #ifdef  __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 /** @brief Handles URL */
00036 typedef struct dmlite_url {
00037   char     scheme[SCHEME_MAX];
00038   char     domain[HOST_NAME_MAX];
00039   unsigned port;
00040   char     path  [PATH_MAX];
00041   char     query [QUERY_MAX];
00042 } dmlite_url;
00043 
00044 /** @brief Handles ACL entries */
00045 typedef struct dmlite_aclentry {
00046   uint8_t  type;
00047   uint8_t  perm;
00048   uint32_t id;
00049 } dmlite_aclentry;
00050 
00051 
00052 /**
00053  * @brief        Parses a URL.
00054  * @param source Original URL.
00055  * @param dest   Parsed URL.
00056  */
00057 void dmlite_parse_url(const char* source, dmlite_url* dest);
00058 
00059 /**
00060  * @brief          Serializes into a string a set of ACL entries
00061  * @param nEntries The number of ACL entries in the array.
00062  * @param acl      The ACL.
00063  * @param buffer   Where to put the resulting string.
00064  * @param bsize    The buffer size.
00065  */
00066 void dmlite_serialize_acls(unsigned nEntries, dmlite_aclentry* acl,
00067                            char* buffer, size_t bsize);
00068 
00069 /**
00070  * @brief          Deserializes a string into an array of ACL entries.
00071  * @param buffer   The string.
00072  * @param nEntries The resulting number of ACL entries.
00073  * @param acl      The resulting ACL.
00074  */
00075 void dmlite_deserialize_acl(const char* buffer, unsigned* nEntries,
00076                              dmlite_aclentry** acl);
00077 
00078 /**
00079  * @brief          Frees an array of ACL entries as returned by dm_deserialize_acls
00080  * @param nEntries The number of entries in the array.
00081  * @param acl      The ACL.
00082  */
00083 void dmlite_acl_free(unsigned nEntries, dmlite_aclentry* acl);
00084 
00085 #ifdef  __cplusplus
00086 }
00087 #endif
00088 
00089 #endif /* DMLITE_UTILS_H */

Generated on 3 Mar 2013 for dmlite by  doxygen 1.4.7