Debian Codegraph @

src/common/public/oscap.h

raw symbols SCIP
1 /*
2 * Copyright 2009,2010,2011 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Lukas Kuklinek <[email protected]>
21 * Peter Vrabec <[email protected]>
22 */
23
24 /**
25 * @file
26 * General OpenScap functions and types.
27 * @author Lukas Kuklinek <[email protected]>
28 *
29 * @addtogroup COMMON
30 * @{
31 */
32
33 #ifndef OSCAP_H_
34 #define OSCAP_H_
35 #include <stdbool.h>
36
37 #include "oscap_text.h"
38 #include "oscap_reference.h"
39 #include "oscap_export.h"
40
41 /**
42 * This macro will warn, when a deprecated function is used.
43 */
44 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
45 # define OSCAP_DEPRECATED(func) func __attribute__ ((deprecated))
46 #elif defined(_MSC_VER)
47 # define OSCAP_DEPRECATED(func) __declspec(deprecated) func
48 #else
49 # pragma message("WARNING: You need to implement OSCAP_DEPRECATED for this compiler---in order to get deprecation warnings.")
50 # define OSCAP_DEPRECATED(func) func
51 #endif
52
53 /**
54 * Initialize OpenSCAP library.
55 *
56 * This is currently needed only in multithreaded applications
57 * (needs to be called before any child threads are spawned)
58 * or applications using the XSLT facility w/ EXSLT extensions.
59 * However, it is a good practice to call this function
60 * always at the beginning of the program execution.
61 */
62 OSCAP_API void oscap_init(void);
63
64 /**
65 * Release library internal caches.
66 *
67 * This function should be called once you finish working with
68 * any of the libraries included in OpenScap framework.
69 * It frees internally allocated memory, e.g. cache of the XML parser.
70 */
71 OSCAP_API void oscap_cleanup(void);
72
73 /// Get version of the OpenSCAP library
74 OSCAP_API const char *oscap_get_version(void);
75
76
77 /**
78 * @addtogroup VALID
79 * @{
80 * XML schema based validation of XML representations of SCAP documents.
81 */
82
83 /// SCAP document type identifiers
84 typedef enum oscap_document_type {
85 OSCAP_DOCUMENT_UNKNOWN = 0, ///< The type is unknown
86 OSCAP_DOCUMENT_OVAL_DEFINITIONS, ///< OVAL Definitions file
87 OSCAP_DOCUMENT_OVAL_VARIABLES, ///< OVAL Variables
88 OSCAP_DOCUMENT_OVAL_SYSCHAR, ///< OVAL system characteristics file
89 OSCAP_DOCUMENT_OVAL_RESULTS, ///< OVAL results file
90 OSCAP_DOCUMENT_OVAL_DIRECTIVES, ///< OVAL directives file
91 OSCAP_DOCUMENT_XCCDF, ///< XCCDF benchmark file
92 OSCAP_DOCUMENT_CPE_LANGUAGE, ///< CPE language file
93 OSCAP_DOCUMENT_CPE_DICTIONARY, ///< CPE dictionary file
94 OSCAP_DOCUMENT_SCE_RESULT, ///< SCE result file
95 OSCAP_DOCUMENT_SDS, ///< Source Data Stream file
96 OSCAP_DOCUMENT_ARF, ///< Result Data Stream file
97 OSCAP_DOCUMENT_XCCDF_TAILORING, ///< XCCDF tailoring file
98 OSCAP_DOCUMENT_OCIL, ///< OCIL Definitions file
99 // If you are adding a new enum here, make sure you add support for it
100 // to utils/oscap-info.c!
101 } oscap_document_type_t;
102
103 /**
104 * Convert @ref oscap_document_type_t constant to human readable (english)
105 * representation.
106 * @param type OpenSCAP Document Type
107 * @returns English string describing document type.
108 * @retval Returned value might be pointer to static memory and must not be modified.
109 * @retval NULL in case of unrecognized document type
110 */
111 OSCAP_API const char *oscap_document_type_to_string(oscap_document_type_t type);
112
113 typedef int (*xml_reporter)(const char *file, int line, const char *msg, void *arg);
114
115 /**
116 * Apply a XSLT stylesheet to a XML file.
117 *
118 * If xsltfile is not an absolute path, the file will be searched relatively to a path specified by the OSCAP_XSLT_PATH environment variable.
119 * If the variable does not exist a default path is used (usually something like $PREFIX/share/openscap/schemas).
120 *
121 * @param xmlfile File to be transformed.
122 * @param xsltfile XSLT file
123 * @param outfile Result file shall be written here (NULL for stdout).
124 * @param params list of key-value pairs to pass to the stylesheet.
125 * @return the number of bytes written or -1 in case of failure
126 */
127 OSCAP_API int oscap_apply_xslt(const char *xmlfile, const char *xsltfile, const char *outfile, const char **params);
128
129 /**
130 * Function returns path used to locate OpenSCAP XML schemas
131 */
132 OSCAP_API const char * oscap_path_to_schemas(void);
133
134 /**
135 * Function returns path used to locate OpenSCAP Default CPE files
136 */
137 OSCAP_API const char * oscap_path_to_cpe(void);
138
139 /************************************************************/
140 /** @} validation group end */
141
142 /** @} */
143
144 #endif