OpenDNSSEC-enforcer
2.1.6
src
policy
policy_list_cmd.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Surfnet
3
* Copyright (c) 2011 .SE (The Internet Infrastructure Foundation).
4
* Copyright (c) 2011 OpenDNSSEC AB (svb)
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*
28
*/
29
30
#include "config.h"
31
32
#include "cmdhandler.h"
33
#include "
daemon/enforcercommands.h
"
34
#include "log.h"
35
#include "str.h"
36
#include "
daemon/engine.h
"
37
#include "clientpipe.h"
38
#include "
db/policy.h
"
39
40
#include "
policy/policy_list_cmd.h
"
41
42
/* static const char *module_str = "policy_list_cmd"; */
43
44
static
void
45
usage(
int
sockfd)
46
{
47
client_printf(sockfd,
48
"policy list\n"
);
49
}
50
51
static
void
52
help(
int
sockfd)
53
{
54
client_printf(sockfd,
55
"List all policies in the database.\n\n"
56
);
57
}
58
59
static
int
60
run(
int
sockfd, cmdhandler_ctx_type* context,
const
char
*cmd)
61
{
62
const
char
*fmt =
"%-31s %-48s\n"
;
63
policy_list_t
*pol_list;
64
const
policy_t
*
policy
;
65
db_connection_t
* dbconn =
getconnectioncontext
(context);;
66
engine_type
* engine =
getglobalcontext
(context);
67
(void)cmd;
68
69
if
(!(pol_list =
policy_list_new_get
(dbconn)))
70
return
1;
71
72
/* May want to keep this for compatibility?
73
* client_printf(sockfd, "Database set to: %s\nPolicies:\n",
74
engine->config->datastore);*/
75
client_printf(sockfd, fmt,
"Policy:"
,
"Description:"
);
76
77
policy
=
policy_list_next
(pol_list);
78
while
(
policy
) {
79
client_printf(sockfd, fmt,
policy_name
(
policy
),
80
policy_description
(
policy
));
81
policy
=
policy_list_next
(pol_list);
82
}
83
policy_list_free
(pol_list);
84
return
0;
85
}
86
87
struct
cmd_func_block
policy_list_funcblock
= {
88
"policy list"
, &usage, &help, NULL, &run
89
};
policy.h
policy_list_free
void policy_list_free(policy_list_t *policy_list)
Definition:
policy.c:2664
policy_name
const char * policy_name(const policy_t *policy)
Definition:
policy.c:813
enforcercommands.h
policy_list_cmd.h
policy_list_next
const policy_t * policy_list_next(policy_list_t *policy_list)
Definition:
policy.c:3214
policy_list_new_get
policy_list_t * policy_list_new_get(const db_connection_t *connection)
Definition:
policy.c:3079
getconnectioncontext
db_connection_t * getconnectioncontext(cmdhandler_ctx_type *context)
Definition:
enforcercommands.c:110
policy_description
const char * policy_description(const policy_t *policy)
Definition:
policy.c:821
engine_struct
Definition:
engine.h:47
policy
Definition:
policy.h:60
policy_list
Definition:
policy.h:733
engine.h
policy_list_funcblock
struct cmd_func_block policy_list_funcblock
Definition:
policy_list_cmd.c:87
db_connection
Definition:
db_connection.h:46
getglobalcontext
engine_type * getglobalcontext(cmdhandler_ctx_type *context)
Definition:
enforcercommands.c:104
Generated by
1.8.18