Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
631769c3
Commit
631769c3
authored
10 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/cfg_array'
parents
53852b12
c019196d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cfg.cc
+36
-10
36 additions, 10 deletions
src/cfg.cc
src/cfg.h
+7
-0
7 additions, 0 deletions
src/cfg.h
with
43 additions
and
10 deletions
src/cfg.cc
+
36
−
10
View file @
631769c3
...
...
@@ -52,22 +52,27 @@ cfg_geti(const char *param)
return
val
;
}
const
char
*
cfg_
gets
(
const
char
*
param
)
static
const
char
*
cfg_
converts
(
struct
lua_State
*
L
)
{
/* Support simultaneous cfg_gets("str1") and cfg_gets("str2") */
static
char
__thread
values
[
MAX_STR_OPTS
][
MAX_OPT_VAL_LEN
];
static
int
__thread
i
=
0
;
struct
lua_State
*
L
=
tarantool_L
;
char
*
val
;
cfg_get
(
param
);
if
(
lua_isnil
(
L
,
-
1
))
val
=
NULL
;
return
NULL
;
else
{
val
=
values
[
i
++
%
MAX_STR_OPTS
];
snprintf
(
val
,
MAX_OPT_VAL_LEN
,
"%s"
,
lua_tostring
(
L
,
-
1
));
snprintf
(
values
[
i
%
MAX_STR_OPTS
],
MAX_OPT_VAL_LEN
,
"%s"
,
lua_tostring
(
L
,
-
1
));
return
values
[
i
++
%
MAX_STR_OPTS
];
}
lua_pop
(
L
,
1
);
}
const
char
*
cfg_gets
(
const
char
*
param
)
{
/* Support simultaneous cfg_gets("str1") and cfg_gets("str2") */
cfg_get
(
param
);
const
char
*
val
=
cfg_converts
(
tarantool_L
);
lua_pop
(
tarantool_L
,
1
);
return
val
;
}
...
...
@@ -80,3 +85,24 @@ cfg_getd(const char *param)
return
val
;
}
int
cfg_getarr_size
(
const
char
*
name
)
{
cfg_get
(
name
);
luaL_checktype
(
tarantool_L
,
-
1
,
LUA_TTABLE
);
int
result
=
luaL_getn
(
tarantool_L
,
-
1
);
lua_pop
(
tarantool_L
,
1
);
return
result
;
}
const
char
*
cfg_getarr_elem
(
const
char
*
name
,
int
i
)
{
cfg_get
(
name
);
luaL_checktype
(
tarantool_L
,
-
1
,
LUA_TTABLE
);
lua_rawgeti
(
tarantool_L
,
-
1
,
i
+
1
);
const
char
*
val
=
cfg_converts
(
tarantool_L
);
lua_pop
(
tarantool_L
,
2
);
return
val
;
}
This diff is collapsed.
Click to expand it.
src/cfg.h
+
7
−
0
View file @
631769c3
...
...
@@ -36,4 +36,11 @@ cfg_gets(const char *param);
double
cfg_getd
(
const
char
*
param
);
int
cfg_getarr_size
(
const
char
*
name
);
const
char
*
cfg_getarr_elem
(
const
char
*
name
,
int
i
);
#endif
/* INCLUDES_TARANTOOL_CFG_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment