Open SCAP Library: oval_fts.h Source File

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

oval_fts.h
1 /*
2 * Copyright 2010 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <dkopecek@redhat.com>
21 */
22 #ifndef OVAL_FTS_H
23 #define OVAL_FTS_H
24
25 #include <sexp.h>
26 #if defined(__SVR4) && defined(__sun)
27 #include "fts_sun.h"
28 #else
29 #include <fts.h>
30 #endif
31 #include <pcre.h>
32 #include "fsdev.h"
33
34 #define ENT_GET_AREF(ent, dst, attr_name, mandatory) \
35 do { \
36 if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
37 if (mandatory) { \
38 _F("Attribute `%s' is missing!\n", attr_name); \
39 return (NULL); \
40 } \
41 } \
42 } while(0)
43
44 #define ENT_GET_STRVAL(ent, dst, dstlen, zerolen_exp) \
45 do { \
46 SEXP_t *___r; \
47 \
48 if ((___r = probe_ent_getval(ent)) == NULL) { \
49 dW("entity has no value!\n"); \
50 return (NULL); \
51 } else { \
52 if (!SEXP_stringp(___r)) { \
53 _F("invalid type\n"); \
54 SEXP_free(___r); \
55 return (NULL); \
56 } \
57 if (SEXP_string_length(___r) == 0) { \
58 SEXP_free(___r); \
59 zerolen_exp; \
60 } else { \
61 SEXP_string_cstr_r(___r, dst, dstlen); \
62 SEXP_free(___r); \
63 } \
64 } \
65 } while (0)
66
67 typedef struct {
68 /* oval_fts_read_match_path() state */
69 FTS *ofts_match_path_fts;
70 FTSENT *ofts_match_path_fts_ent;
71 /* oval_fts_read_recurse_path() state */
72 FTS *ofts_recurse_path_fts;
73 int ofts_recurse_path_fts_opts;
74 int ofts_recurse_path_curdepth;
75 char *ofts_recurse_path_pthcpy;
76 char *ofts_recurse_path_curpth;
77 dev_t ofts_recurse_path_devid;
78
79 pcre *ofts_path_regex;
80 pcre_extra *ofts_path_regex_extra;
81 uint32_t ofts_path_op;
82
83 SEXP_t *ofts_spath;
84 SEXP_t *ofts_sfilename;
85 SEXP_t *ofts_sfilepath;
86
87 int max_depth;
88 int direction;
89 int recurse;
90 int filesystem;
91
92 fsdev_t *localdevs;
93 } OVAL_FTS;
94
95 #define OVAL_RECURSE_DIRECTION_NONE 0 /* default */
96 #define OVAL_RECURSE_DIRECTION_DOWN 1
97 #define OVAL_RECURSE_DIRECTION_UP 2
98
99 #define OVAL_RECURSE_FILES 0x01
100 #define OVAL_RECURSE_DIRS 0x02
101 #define OVAL_RECURSE_SYMLINKS 0x04
102
103 #define OVAL_RECURSE_SYMLINKS_AND_DIRS (OVAL_RECURSE_SYMLINKS|OVAL_RECURSE_DIRS) /* default */
104 #define OVAL_RECURSE_FILES_AND_DIRS (OVAL_RECURSE_FILES|OVAL_RECURSE_SYMLINKS)
105
106 #define OVAL_RECURSE_FS_LOCAL 0
107 #define OVAL_RECURSE_FS_DEFINED 1
108 #define OVAL_RECURSE_FS_ALL 2 /* default */
109
110 typedef struct {
111 char *file;
112 size_t file_len;
113 char *path;
114 size_t path_len;
115 unsigned int fts_info;
116 } OVAL_FTSENT;
117
118 /*
119 * OVAL FTS public API
120 */
121 OVAL_FTS *oval_fts_open(SEXP_t *path, SEXP_t *filename, SEXP_t *filepath, SEXP_t *behaviors);
122 OVAL_FTSENT *oval_fts_read(OVAL_FTS *ofts);
123 int oval_fts_close(OVAL_FTS *ofts);
124
125 void oval_ftsent_free(OVAL_FTSENT *ofts_ent);
126
127 #endif /* OVAL_FTS_H */
OVAL_FTSENT
Definition: oval_fts.h:110
fsdev.h
fsdev API public header file
OVAL_FTS
Definition: oval_fts.h:67
FTS
Definition: fts_sun.h:84
_ftsent
Definition: fts_sun.h:132
fsdev_t
Filesystem device structure.
Definition: fsdev.h:42
SEXP
Definition: sexp-types.h:82