00001 /* 00002 * Copyright 1999-2006 University of Chicago 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL 00018 00024 #ifndef GLOBUS_I_GASS_CACHE_CONFIG_H 00025 #define GLOBUS_I_GASS_CACHE_CONFIG_H 00026 00027 #include "globus_hashtable.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #define GLOBUS_L_ERROR_CONFIG_FILE_NOT_FOUND -200 00034 #define GLOBUS_L_ERROR_CONFIG_FILE_READ -201 00035 #define GLOBUS_L_ERROR_CONFIG_FILE_PARSE_ERROR -202 00036 00037 /* config structure definition */ 00038 typedef struct globus_l_gass_cache_config_s 00039 { 00040 char* buf; /* buffer that holds the config file */ 00041 globus_hashtable_t table; /* parsed config entries (hashtable) */ 00042 } globus_l_gass_cache_config_t; 00043 00044 /* 00045 * globus_l_gass_cache_config_init() 00046 * 00047 * Inits the config structure by reading from a file. 00048 * 00049 * Parameters: 00050 * - directory the GASS cache directory 00051 * - config the config structure 00052 * 00053 * Returns: 00054 * - GLOBUS_SUCCESS upon success 00055 */ 00056 int 00057 globus_l_gass_cache_config_init(char* file, 00058 globus_l_gass_cache_config_t *config); 00059 00060 00061 /* 00062 * globus_l_gass_cache_config_destroy() 00063 * 00064 * Destroys the config structure 00065 * 00066 * Parameters: 00067 * - config the config structure 00068 * 00069 * Returns: 00070 */ 00071 int 00072 globus_l_gass_cache_config_destroy(globus_l_gass_cache_config_t *config); 00073 00074 /* 00075 * globus_l_gass_cache_config_get() 00076 * 00077 * Retrieves a config entry 00078 * 00079 * Parameters: 00080 * - config the config structure 00081 * - key the config parameter 00082 * 00083 * Returns: 00084 * the value associated with 'key', or GLOBUS_NULL 00085 */ 00086 char* 00087 globus_l_gass_cache_config_get(globus_l_gass_cache_config_t *config, 00088 char* key); 00089 00090 00091 /* 00092 * globus_l_gass_cache_config_get() 00093 * 00094 * Defines a new config entry 00095 * 00096 * Parameters: 00097 * - config the config structure 00098 * - key the config parameter 00099 * - value the config parameter value 00100 * 00101 * Returns: 00102 */ 00103 int 00104 globus_l_gass_cache_config_set(globus_l_gass_cache_config_t *config, 00105 char *key, 00106 char *value); 00107 00108 00109 /* 00110 * globus_l_gass_cache_config_save() 00111 * 00112 * Saves the configuration to a file. NOTE: Any comments in the file 00113 * will be lost! 00114 * 00115 * Parameters: 00116 * - config the config structure 00117 * - file the file to write to 00118 * - overwrite if TRUE, will overwrite existing file 00119 * 00120 * Returns: 00121 */ 00122 int 00123 globus_l_gass_cache_config_save(globus_l_gass_cache_config_t *config, 00124 char *file, 00125 globus_bool_t *overwrite); 00126 00127 00128 #ifdef __cplusplus 00129 } 00130 #endif 00131 00132 #endif /* GLOBUS_I_GASS_CACHE_CONFIG_H */ 00133 00134 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */