Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
2c395a84
Commit
2c395a84
authored
Dec 18, 1998
by
Bob Halley
Browse files
undefine action support
parent
8dcce6f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/tests/sym_test.c
View file @
2c395a84
...
...
@@ -26,6 +26,26 @@
isc_mem_t
*
mctx
;
isc_symtab_t
*
st
;
static
char
*
mem_strdup
(
isc_mem_t
*
mctx
,
const
char
*
s
)
{
size_t
len
;
char
*
ns
;
len
=
strlen
(
s
);
ns
=
isc_mem_allocate
(
mctx
,
len
+
1
);
if
(
ns
==
NULL
)
return
(
NULL
);
strncpy
(
ns
,
s
,
len
+
1
);
return
(
ns
);
}
static
void
undefine_action
(
char
*
key
,
unsigned
int
type
,
isc_symvalue_t
value
)
{
INSIST
(
type
==
0
);
isc_mem_free
(
mctx
,
key
);
isc_mem_free
(
mctx
,
value
.
as_pointer
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
char
s
[
1000
],
*
cp
,
*
key
;
...
...
@@ -36,7 +56,8 @@ main(int argc, char *argv[]) {
int
c
;
INSIST
(
isc_mem_create
(
0
,
0
,
&
mctx
)
==
ISC_R_SUCCESS
);
INSIST
(
isc_symtab_create
(
mctx
,
691
,
&
st
)
==
ISC_R_SUCCESS
);
INSIST
(
isc_symtab_create
(
mctx
,
691
,
undefine_action
,
&
st
)
==
ISC_R_SUCCESS
);
while
((
c
=
getopt
(
argc
,
argv
,
"t"
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -74,8 +95,8 @@ main(int argc, char *argv[]) {
}
}
else
{
*
cp
++
=
'\0'
;
key
=
strdup
(
key
);
value
.
as_pointer
=
strdup
(
cp
);
key
=
mem_
strdup
(
mctx
,
key
);
value
.
as_pointer
=
mem_
strdup
(
mctx
,
cp
);
result
=
isc_symtab_define
(
st
,
key
,
0
,
value
);
if
(
trace
||
result
!=
ISC_R_SUCCESS
)
printf
(
"define('%s', '%s'): %s
\n
"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment