Greenbone Vulnerability Manager  8.0.0~git
gmp_get.h
1 /* GVM
2  * $Id$
3  * Description: GVM GMP layer: Common GET command headers.
4  *
5  * Authors:
6  * Matthew Mundell <matthew.mundell@greenbone.net>
7  *
8  * Copyright:
9  * Copyright (C) 2018 Greenbone Networks GmbH
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef _GVMD_GMP_GET_H
27 #define _GVMD_GMP_GET_H
28 
29 #include "manage.h"
30 
31 void
33  const gchar *,
34  const gchar **,
35  const gchar **);
36 
37 int
38 init_get (gchar *, get_data_t *, const gchar *, int *);
39 
46 #define INIT_GET(type, capital) \
47  count = 0; \
48  ret = init_get ("get_" G_STRINGIFY (type) "s", \
49  &get_##type##s_data->get, \
50  G_STRINGIFY (capital) "s", \
51  &first); \
52  if (ret) \
53  { \
54  switch (ret) \
55  { \
56  case 99: \
57  SEND_TO_CLIENT_OR_FAIL (XML_ERROR_SYNTAX ( \
58  "get_" G_STRINGIFY (type) "s", "Permission denied")); \
59  break; \
60  default: \
61  internal_error_send_to_client (error); \
62  return; \
63  } \
64  get_##type##s_data_reset (get_##type##s_data); \
65  set_client_state (CLIENT_AUTHENTIC); \
66  return; \
67  }
68 
69 int
71  get_data_t *,
72  int *,
73  int *,
74  int (*) (iterator_t *, const get_data_t *));
75 
76 int
77 send_get_start (const char *, int (*) (const char *, void *), void *);
78 
85 #define SEND_GET_START(type) \
86  do \
87  { \
88  if (send_get_start ( \
89  type, gmp_parser->client_writer, gmp_parser->client_writer_data)) \
90  { \
91  error_send_to_client (error); \
92  return; \
93  } \
94  } \
95  while (0)
96 
97 int
98 send_get_common (const char *,
99  get_data_t *,
100  iterator_t *,
101  int (*) (const char *, void *),
102  void *,
103  int,
104  int);
105 
113 #define SEND_GET_COMMON(type, get, iterator) \
114  do \
115  { \
116  if (send_get_common ( \
117  G_STRINGIFY (type), \
118  get, \
119  iterator, \
120  gmp_parser->client_writer, \
121  gmp_parser->client_writer_data, \
122  (get)->trash \
123  ? trash_##type##_writable (get_iterator_resource (iterator)) \
124  : type##_writable (get_iterator_resource (iterator)), \
125  (get)->trash \
126  ? trash_##type##_in_use (get_iterator_resource (iterator)) \
127  : type##_in_use (get_iterator_resource (iterator)))) \
128  { \
129  error_send_to_client (error); \
130  return; \
131  } \
132  } \
133  while (0)
134 
135 int
136 buffer_get_filter_xml (GString *,
137  const char *,
138  const get_data_t *,
139  const char *,
140  const char *);
141 
142 int
143 send_get_end (const char *,
144  get_data_t *,
145  int,
146  int,
147  int,
148  int (*) (const char *, void *),
149  void *);
150 
151 int
152 send_get_end_no_counts (const char *,
153  get_data_t *,
154  int (*) (const char *, void *),
155  void *);
156 
163 #define SEND_GET_END(type, get, count, filtered) \
164  do \
165  { \
166  if (send_get_end (type, \
167  get, \
168  count, \
169  filtered, \
170  resource_count (type, get), \
171  gmp_parser->client_writer, \
172  gmp_parser->client_writer_data)) \
173  { \
174  error_send_to_client (error); \
175  return; \
176  } \
177  } \
178  while (0)
179 
180 #endif /* not _GVMD_GMP_GET_H */
int send_get_end_no_counts(const char *type, get_data_t *get, int(*write_to_client)(const char *, void *), void *write_to_client_data)
Send end of GET response, skipping result counts.
Definition: gmp_get.c:716
A generic SQL iterator structure.
Definition: iterator.h:50
int send_get_common(const char *type, get_data_t *get, iterator_t *iterator, int(*write_to_client)(const char *, void *), void *write_to_client_data, int writable, int in_use)
Send common part of GET response for a single resource.
Definition: gmp_get.c:320
void get_data_parse_attributes(get_data_t *data, const gchar *type, const gchar **attribute_names, const gchar **attribute_values)
Parse attributes for a GET command.
Definition: gmp_get.c:58
Command data for a get command.
Definition: manage.h:316
int buffer_get_filter_xml(GString *msg, const char *type, const get_data_t *get, const char *filter_term, const char *extra_xml)
Write data of a GET command filter to a string buffer as XML.
Definition: gmp_get.c:480
int send_get_end(const char *type, get_data_t *get, int count, int filtered, int full, int(*write_to_client)(const char *, void *), void *write_to_client_data)
Send end of GET response.
Definition: gmp_get.c:692
int init_get(gchar *command, get_data_t *get, const gchar *setting_name, int *first)
Init for a GET handler.
Definition: gmp_get.c:108
int send_get_start(const char *type, int(*write_to_client)(const char *, void *), void *write_to_client_data)
Send start of GET response.
Definition: gmp_get.c:280
int get_next(iterator_t *resources, get_data_t *get, int *first, int *count, int(*init)(iterator_t *, const get_data_t *))
Iterate a GET iterator.
Definition: gmp_get.c:233