00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef OVAL_FTS_H
00023 #define OVAL_FTS_H
00024
00025 #include <sexp.h>
00026 #if (defined(__SVR4) && defined(__sun)) || defined(_AIX)
00027 #include "fts_sun.h"
00028 #else
00029 #include <fts.h>
00030 #endif
00031 #include <pcre.h>
00032 #include "fsdev.h"
00033
00034 #define ENT_GET_AREF(ent, dst, attr_name, mandatory) \
00035 do { \
00036 if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
00037 if (mandatory) { \
00038 _F("Attribute `%s' is missing!\n", attr_name); \
00039 return (NULL); \
00040 } \
00041 } \
00042 } while(0)
00043
00044 #define ENT_GET_STRVAL(ent, dst, dstlen, zerolen_exp) \
00045 do { \
00046 SEXP_t *___r; \
00047 \
00048 if ((___r = probe_ent_getval(ent)) == NULL) { \
00049 dW("entity has no value!"); \
00050 return (NULL); \
00051 } else { \
00052 if (!SEXP_stringp(___r)) { \
00053 _F("invalid type\n"); \
00054 SEXP_free(___r); \
00055 return (NULL); \
00056 } \
00057 if (SEXP_string_length(___r) == 0) { \
00058 SEXP_free(___r); \
00059 zerolen_exp; \
00060 } else { \
00061 SEXP_string_cstr_r(___r, dst, dstlen); \
00062 SEXP_free(___r); \
00063 } \
00064 } \
00065 } while (0)
00066
00067 typedef struct {
00068
00069 FTS *ofts_match_path_fts;
00070 FTSENT *ofts_match_path_fts_ent;
00071
00072 FTS *ofts_recurse_path_fts;
00073 int ofts_recurse_path_fts_opts;
00074 int ofts_recurse_path_curdepth;
00075 char *ofts_recurse_path_pthcpy;
00076 char *ofts_recurse_path_curpth;
00077 dev_t ofts_recurse_path_devid;
00078
00079 pcre *ofts_path_regex;
00080 pcre_extra *ofts_path_regex_extra;
00081 uint32_t ofts_path_op;
00082
00083 SEXP_t *ofts_spath;
00084 SEXP_t *ofts_sfilename;
00085 SEXP_t *ofts_sfilepath;
00086 SEXP_t *result;
00087
00088 int max_depth;
00089 int direction;
00090 int recurse;
00091 int filesystem;
00092
00093 fsdev_t *localdevs;
00094 } OVAL_FTS;
00095
00096 #define OVAL_RECURSE_DIRECTION_NONE 0
00097 #define OVAL_RECURSE_DIRECTION_DOWN 1
00098 #define OVAL_RECURSE_DIRECTION_UP 2
00099
00100 #define OVAL_RECURSE_FILES 0x01
00101 #define OVAL_RECURSE_DIRS 0x02
00102 #define OVAL_RECURSE_SYMLINKS 0x04
00103
00104 #define OVAL_RECURSE_SYMLINKS_AND_DIRS (OVAL_RECURSE_SYMLINKS|OVAL_RECURSE_DIRS)
00105 #define OVAL_RECURSE_FILES_AND_DIRS (OVAL_RECURSE_FILES|OVAL_RECURSE_SYMLINKS)
00106
00107 #define OVAL_RECURSE_FS_LOCAL 0
00108 #define OVAL_RECURSE_FS_DEFINED 1
00109 #define OVAL_RECURSE_FS_ALL 2
00110
00111 typedef struct {
00112 char *file;
00113 size_t file_len;
00114 char *path;
00115 size_t path_len;
00116 unsigned int fts_info;
00117 } OVAL_FTSENT;
00118
00119
00120
00121
00122 OVAL_FTS *oval_fts_open(SEXP_t *path, SEXP_t *filename, SEXP_t *filepath, SEXP_t *behaviors, SEXP_t* result);
00123 OVAL_FTSENT *oval_fts_read(OVAL_FTS *ofts);
00124 int oval_fts_close(OVAL_FTS *ofts);
00125
00126 void oval_ftsent_free(OVAL_FTSENT *ofts_ent);
00127
00128 #endif