CUBRID Engine  latest
databases_file.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * databases_file.h - Configuration file parser
22  *
23  */
24 
25 #ifndef _DATABASES_FILE_H_
26 #define _DATABASES_FILE_H_
27 
28 #ident "$Id$"
29 
30 #if !defined (DO_NOT_USE_CUBRIDENV)
31 /* Name of the environment variable pointing to database file */
32 #define DATABASES_ENVNAME "DATABASES"
33 #endif
34 
35 #if defined(WINDOWS)
36 #define SECTION_START_CHAR '['
37 #define SECTION_END_CHAR ']'
38 #endif /* WINDOWS */
39 
40 /* name of the database file */
41 #define DATABASES_FILENAME "databases.txt"
42 
43 /* max num of db-hosts */
44 #define MAX_NUM_DB_HOSTS 32
45 
46 /*
47  * DB_INFO
48  *
49  * Note: This is a descriptor structure for databases in the currently
50  * accessible directory file.
51  */
52 typedef struct database_info DB_INFO;
53 
55 {
56  char *name;
57  char *pathname;
58  char **hosts;
59  char *logpath;
60  char *lobpath;
62  int num_hosts;
63 };
64 
65 extern char *cfg_os_working_directory (void);
66 
67 extern char *cfg_maycreate_get_directory_filename (char *buffer);
68 extern int cfg_read_directory (DB_INFO ** info_p, bool write_flag);
69 extern void cfg_write_directory (const DB_INFO * databases);
70 
71 extern int cfg_read_directory_ex (int vdes, DB_INFO ** info_p, bool write_flag);
72 extern void cfg_write_directory_ex (int vdes, const DB_INFO * databases);
73 
74 extern void cfg_free_directory (DB_INFO * databases);
75 #if defined(CUBRID_DEBUG)
76 extern void cfg_dump_directory (const DB_INFO * databases);
77 #endif
78 extern void cfg_update_db (DB_INFO * db_info_p, const char *path, const char *logpath, const char *lobpath,
79  const char *host);
80 extern DB_INFO *cfg_new_db (const char *name, const char *path, const char *logpath, const char *lobpath,
81  const char **hosts);
82 extern DB_INFO *cfg_find_db_list (DB_INFO * dir, const char *name);
83 extern DB_INFO *cfg_add_db (DB_INFO ** dir, const char *name, const char *path, const char *logpath,
84  const char *lobpath, const char *host);
85 extern DB_INFO *cfg_find_db (const char *db_name);
86 extern bool cfg_delete_db (DB_INFO ** dir_info_p, const char *name);
87 
88 extern char **cfg_get_hosts (const char *prim_host, int *count, bool include_local_host);
89 extern void cfg_free_hosts (char **host_array);
90 extern char *cfg_create_host_list (const char *primary_host_name, bool append_local_host, int *cnt);
91 
92 #endif /* _DATABASES_FILE_H_ */
char * cfg_maycreate_get_directory_filename(char *buffer)
char * cfg_create_host_list(const char *primary_host_name, bool append_local_host, int *cnt)
void cfg_free_directory(DB_INFO *databases)
DB_INFO * cfg_add_db(DB_INFO **dir, const char *name, const char *path, const char *logpath, const char *lobpath, const char *host)
void cfg_free_hosts(char **host_array)
int cfg_read_directory_ex(int vdes, DB_INFO **info_p, bool write_flag)
DB_INFO * cfg_new_db(const char *name, const char *path, const char *logpath, const char *lobpath, const char **hosts)
DB_INFO * cfg_find_db(const char *db_name)
char * cfg_os_working_directory(void)
bool cfg_delete_db(DB_INFO **dir_info_p, const char *name)
void cfg_write_directory(const DB_INFO *databases)
DB_INFO * cfg_find_db_list(DB_INFO *dir, const char *name)
char * db_name
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
void cfg_write_directory_ex(int vdes, const DB_INFO *databases)
int cfg_read_directory(DB_INFO **info_p, bool write_flag)
char ** cfg_get_hosts(const char *prim_host, int *count, bool include_local_host)
DB_INFO * next
static char * host
void cfg_update_db(DB_INFO *db_info_p, const char *path, const char *logpath, const char *lobpath, const char *host)