16
16
#ifndef _NDB_OPTS_H
17
17
#define _NDB_OPTS_H
18
18
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
19
22
#include <ndb_global.h>
20
23
#include <my_sys.h>
21
24
#include <my_getopt.h>
22
25
#include <mysql_version.h>
23
26
#include <ndb_version.h>
24
- #include <ndb_opt_defaults.h>
27
+ #include <ndbapi/ ndb_opt_defaults.h>
25
28
26
- #define NDB_STD_OPTS_VARS \
27
- my_bool opt_ndb_optimized_node_selection
29
+ #ifdef OPTEXPORT
30
+ #define OPT_EXTERN (T ,V ,I ) T V I
31
+ #else
32
+ #define OPT_EXTERN (T ,V ,I ) extern T V
33
+ #endif
28
34
29
- int opt_ndb_nodeid ;
30
- bool opt_endinfo = 0 ;
31
- my_bool opt_ndb_shm ;
32
- my_bool opt_core ;
33
- const char * opt_ndb_connectstring = 0 ;
34
- const char * opt_connect_str = 0 ;
35
- const char * opt_ndb_mgmd = 0 ;
36
- char opt_ndb_constrbuf [1024 ];
37
- unsigned opt_ndb_constrbuf_len = 0 ;
35
+ #define NONE
36
+ OPT_EXTERN (int ,opt_ndb_nodeid ,NONE );
37
+ OPT_EXTERN (my_bool ,opt_endinfo ,= 0 );
38
+ OPT_EXTERN (my_bool ,opt_ndb_shm ,NONE );
39
+ OPT_EXTERN (my_bool ,opt_core ,NONE );
40
+ OPT_EXTERN (my_bool ,opt_ndb_optimized_node_selection ,NONE );
41
+ OPT_EXTERN (char * ,opt_ndb_connectstring ,= 0 );
42
+ OPT_EXTERN (const char * ,opt_connect_str ,= 0 );
43
+ OPT_EXTERN (const char * ,opt_ndb_mgmd ,= 0 );
44
+ OPT_EXTERN (char ,opt_ndb_constrbuf [1024 ],NONE );
45
+ OPT_EXTERN (unsigned ,opt_ndb_constrbuf_len ,= 0 );
38
46
39
47
#ifndef DBUG_OFF
40
- const char * opt_debug = 0 ;
48
+ OPT_EXTERN ( const char * , opt_debug , = 0 ) ;
41
49
#endif
42
50
43
51
#define OPT_NDB_CONNECTSTRING 'c'
@@ -98,11 +106,7 @@ const char *opt_debug= 0;
98
106
#define NDB_STD_OPTS (prog_name ) NDB_STD_OPTS_COMMON
99
107
#endif
100
108
101
- static void ndb_std_print_version ()
102
- {
103
- printf ("MySQL distrib %s, for %s (%s)\n" ,
104
- NDB_VERSION_STRING ,SYSTEM_TYPE ,MACHINE_TYPE );
105
- }
109
+ void ndb_std_print_version ();
106
110
107
111
static void usage ();
108
112
@@ -117,59 +121,19 @@ enum ndb_std_options {
117
121
NDB_STD_OPTIONS_LAST /* should always be last in this enum */
118
122
};
119
123
120
- static my_bool
124
+ my_bool
121
125
ndb_std_get_one_option (int optid ,
122
126
const struct my_option * opt __attribute__((unused )),
123
- char * argument )
124
- {
125
- switch (optid ) {
126
- #ifndef DBUG_OFF
127
- case '#' :
128
- DBUG_SET_INITIAL (opt_debug ? opt_debug : "d:t" );
129
- opt_endinfo = 1 ;
130
- break ;
131
- #endif
132
- case 'V' :
133
- ndb_std_print_version ();
134
- exit (0 );
135
- case '?' :
136
- usage ();
137
- exit (0 );
138
- case OPT_NDB_SHM :
139
- if (opt_ndb_shm )
140
- {
141
- #ifndef NDB_SHM_TRANSPORTER
142
- printf ("Warning: binary not compiled with shared memory support,\n"
143
- "Tcp connections will now be used instead\n" );
144
- opt_ndb_shm = 0 ;
127
+ char * argument );
128
+
129
+ void ndb_usage ();
130
+ void ndb_short_usage_sub ();
131
+ #ifdef PROVIDE_USAGE
132
+ inline void usage (){ndb_usage ();}
133
+ inline void short_usage_sub (){ndb_short_usage_sub ();}
145
134
#endif
146
- }
147
- break ;
148
- case OPT_NDB_MGMD :
149
- case OPT_NDB_NODEID :
150
- {
151
- int len = my_snprintf (opt_ndb_constrbuf + opt_ndb_constrbuf_len ,
152
- sizeof (opt_ndb_constrbuf )- opt_ndb_constrbuf_len ,
153
- "%s%s%s" ,opt_ndb_constrbuf_len > 0 ? "," :"" ,
154
- optid == OPT_NDB_NODEID ? "nodeid=" : "" ,
155
- argument );
156
- opt_ndb_constrbuf_len += len ;
157
- }
158
- /* fall through to add the connectstring to the end
159
- * and set opt_ndbcluster_connectstring
160
- */
161
- case OPT_NDB_CONNECTSTRING :
162
- if (opt_ndb_connectstring && opt_ndb_connectstring [0 ])
163
- my_snprintf (opt_ndb_constrbuf + opt_ndb_constrbuf_len ,
164
- sizeof (opt_ndb_constrbuf )- opt_ndb_constrbuf_len ,
165
- "%s%s" , opt_ndb_constrbuf_len > 0 ? "," :"" ,
166
- opt_ndb_connectstring );
167
- else
168
- opt_ndb_constrbuf [opt_ndb_constrbuf_len ]= 0 ;
169
- opt_connect_str = opt_ndb_constrbuf ;
170
- break ;
171
- }
172
- return 0 ;
173
- }
174
135
136
+ #ifdef __cplusplus
137
+ }
138
+ #endif
175
139
#endif /*_NDB_OPTS_H */
0 commit comments