19 #include <ndb_global.h>
20 #include <NdbConfig.h>
24 #include <basestring_vsnprintf.h>
26 static const char *datadir_path= 0;
29 NdbConfig_get_path(
int *_len)
31 const char *path= NdbEnv_GetEnv(
"NDB_HOME", 0, 0);
34 path_len= strlen(path);
35 if (path_len == 0 && datadir_path) {
37 path_len= strlen(path);
41 path_len= strlen(path);
49 NdbConfig_AllocHomePath(
int _len)
52 const char *path= NdbConfig_get_path(&path_len);
53 int len= _len+path_len;
54 char *
buf= NdbMem_Allocate(len);
55 basestring_snprintf(buf, len,
"%s%s", path, DIR_SEPARATOR);
60 NdbConfig_SetPath(
const char* path){
65 NdbConfig_NdbCfgName(
int with_ndb_home){
70 buf= NdbConfig_AllocHomePath(PATH_MAX);
73 buf= NdbMem_Allocate(PATH_MAX);
74 basestring_snprintf(buf+len, PATH_MAX,
"Ndb.cfg");
79 char *get_prefix_buf(
int len,
int node_id)
81 char tmp_buf[
sizeof(
"ndb_pid#############")+1];
84 basestring_snprintf(tmp_buf,
sizeof(tmp_buf),
"ndb_%u", node_id);
86 basestring_snprintf(tmp_buf,
sizeof(tmp_buf),
"ndb_pid%u",
87 NdbHost_GetProcessId());
88 tmp_buf[
sizeof(tmp_buf)-1]= 0;
90 buf= NdbConfig_AllocHomePath(len+strlen(tmp_buf));
96 NdbConfig_ErrorFileName(
int node_id){
97 char *buf= get_prefix_buf(PATH_MAX, node_id);
99 basestring_snprintf(buf+len, PATH_MAX,
"_error.log");
104 NdbConfig_ClusterLogFileName(
int node_id){
105 char *buf= get_prefix_buf(PATH_MAX, node_id);
106 int len= strlen(buf);
107 basestring_snprintf(buf+len, PATH_MAX,
"_cluster.log");
112 NdbConfig_SignalLogFileName(
int node_id){
113 char *buf= get_prefix_buf(PATH_MAX, node_id);
114 int len= strlen(buf);
115 basestring_snprintf(buf+len, PATH_MAX,
"_signal.log");
120 NdbConfig_TraceFileName(
int node_id,
int file_no){
121 char *buf= get_prefix_buf(PATH_MAX, node_id);
122 int len= strlen(buf);
123 basestring_snprintf(buf+len, PATH_MAX,
"_trace.log.%u", file_no);
128 NdbConfig_NextTraceFileName(
int node_id){
129 char *buf= get_prefix_buf(PATH_MAX, node_id);
130 int len= strlen(buf);
131 basestring_snprintf(buf+len, PATH_MAX,
"_trace.log.next");
136 NdbConfig_PidFileName(
int node_id){
137 char *buf= get_prefix_buf(PATH_MAX, node_id);
138 int len= strlen(buf);
139 basestring_snprintf(buf+len, PATH_MAX,
".pid");
144 NdbConfig_StdoutFileName(
int node_id){
145 char *buf= get_prefix_buf(PATH_MAX, node_id);
146 int len= strlen(buf);
147 basestring_snprintf(buf+len, PATH_MAX,
"_out.log");