probe-api.h
Go to the documentation of this file.
/*
* Copyright 2009 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors:
* Daniel Kopecek <dkopecek@redhat.com>
*/
#pragma once
#ifndef PROBE_API_H
#define PROBE_API_H
#include <seap.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <oval_definitions.h>
#include <oval_system_characteristics.h>
#include <oval_results.h>
#include <oval_types.h>
/*
* items
*/
SEXP_t *probe_item_build(const char *fmt, ...);
/* SEXP_t *probe_item_creat (const char *name, SEXP_t *attrs, ...); */
SEXP_t *probe_item_creat(const char *name, SEXP_t * attrs, ...);
SEXP_t *probe_item_new(const char *name, SEXP_t * attrs);
SEXP_t *probe_item_attr_add(SEXP_t * item, const char *name, SEXP_t * val);
SEXP_t *probe_item_ent_add(SEXP_t * item, const char *name, SEXP_t * attrs, SEXP_t * val);
int probe_item_setstatus(SEXP_t * obj, oval_syschar_status_t status);
int probe_itement_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
struct id_desc_t;
SEXP_t *probe_item_newid(struct id_desc_t *id_desc);
void probe_item_resetidctr(struct id_desc_t *id_desc);
#define probe_item_getent(item, name, n) probe_obj_getent (item, name, n)
/*
* attributes
*/
SEXP_t *probe_attr_creat(const char *name, const SEXP_t * val, ...);
/*
* objects
*/
SEXP_t *probe_obj_build(const char *fmt, ...);
SEXP_t *probe_obj_creat(const char *name, SEXP_t * attrs, ...);
SEXP_t *probe_obj_new(const char *name, SEXP_t * attrs);
SEXP_t *probe_obj_getent(const SEXP_t * obj, const char *name, uint32_t n);
SEXP_t *probe_obj_getentval(const SEXP_t * obj, const char *name, uint32_t n);
int probe_obj_getentvals(const SEXP_t * obj, const char *name, uint32_t n, SEXP_t ** res);
SEXP_t *probe_obj_getattrval(const SEXP_t * obj, const char *name);
bool probe_obj_attrexists(const SEXP_t * obj, const char *name);
int probe_obj_setstatus(SEXP_t * obj, oval_syschar_status_t status);
int probe_objent_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
char *probe_obj_getname(const SEXP_t * obj);
size_t probe_obj_getname_r(const SEXP_t * obj, char *buffer, size_t buflen);
/*
* collected objects
*/
SEXP_t *probe_cobj_new(oval_syschar_collection_flag_t flag, SEXP_t *msg_list, SEXP_t *item_list, SEXP_t *mask_list);
int probe_cobj_add_msg(SEXP_t *cobj, const SEXP_t *msg);
SEXP_t *probe_cobj_get_msgs(const SEXP_t *cobj);
SEXP_t *probe_cobj_get_mask(const SEXP_t *cobj);
int probe_cobj_add_item(SEXP_t *cobj, const SEXP_t *item);
SEXP_t *probe_cobj_get_items(const SEXP_t *cobj);
void probe_cobj_set_flag(SEXP_t *cobj, oval_syschar_collection_flag_t flag);
oval_syschar_collection_flag_t probe_cobj_get_flag(const SEXP_t *cobj);
oval_syschar_collection_flag_t probe_cobj_combine_flags(oval_syschar_collection_flag_t f1,
oval_syschar_collection_flag_t f2,
oval_setobject_operation_t op);
oval_syschar_collection_flag_t probe_cobj_compute_flag(SEXP_t *cobj);
/*
* messages
*/
SEXP_t *probe_msg_creat(oval_message_level_t level, char *message);
SEXP_t *probe_msg_creatf(oval_message_level_t level, const char *fmt, ...) __attribute__((format(printf, 2, 3), nonnull(2)));
/*
* entities
*/
SEXP_t *probe_ent_creat(const char *name, SEXP_t * attrs, SEXP_t * val, ...);
SEXP_t *probe_ent_creat1(const char *name, SEXP_t * attrs, SEXP_t * val);
SEXP_t *probe_ent_attr_add(SEXP_t * ent, const char *name, SEXP_t * val);
SEXP_t *probe_ent_getval(const SEXP_t * ent);
int probe_ent_getvals(const SEXP_t * ent, SEXP_t ** res);
SEXP_t *probe_ent_getattrval(const SEXP_t * ent, const char *name);
bool probe_ent_attrexists(const SEXP_t * ent, const char *name);
int probe_ent_setdatatype(SEXP_t * ent, oval_datatype_t type);
oval_datatype_t probe_ent_getdatatype(const SEXP_t * ent);
int probe_ent_setmask(SEXP_t * ent, bool mask);
bool probe_ent_getmask(const SEXP_t * ent);
int probe_ent_setstatus(SEXP_t * ent, oval_syschar_status_t status);
oval_syschar_status_t probe_ent_getstatus(const SEXP_t * ent);
char *probe_ent_getname(const SEXP_t * ent);
size_t probe_ent_getname_r(const SEXP_t * ent, char *buffer, size_t buflen);
void probe_free(SEXP_t * obj);
void probe_filebehaviors_canonicalize(SEXP_t **behaviors);
void probe_tfc54behaviors_canonicalize(SEXP_t **behaviors);
#define PROBE_EINVAL 1
#define PROBE_ENOELM 2
#define PROBE_ENOVAL 3
#define PROBE_ENOATTR 4
#define PROBE_EINIT 5
#define PROBE_ENOMEM 6
#define PROBE_EOPNOTSUPP 7
#define PROBE_ERANGE 8
#define PROBE_EDOM 9
#define PROBE_EFAULT 10
#define PROBE_EACCESS 11
#define PROBE_ESETEVAL 12
#define PROBE_ENOENT 13
#define PROBE_ENOOBJ 14
#define PROBE_ECONNABORTED 15
#define PROBE_ESYSTEM 253
#define PROBE_EFATAL 254
#define PROBE_EUNKNOWN 255
#define PROBECMD_STE_FETCH 1
#define PROBECMD_OBJ_EVAL 2
#define PROBECMD_RESET 3
void *probe_init(void) __attribute__ ((unused));
void probe_fini(void *) __attribute__ ((unused));
typedef struct probe_ctx probe_ctx;
int probe_main(probe_ctx *, void *) __attribute__ ((nonnull(1)));
bool probe_item_filtered(const SEXP_t *item, const SEXP_t *filters);
int probe_result_additem(SEXP_t *result, SEXP_t *item);
int probe_item_collect(probe_ctx *ctx, SEXP_t *item);
SEXP_t *probe_ctx_getobject(probe_ctx *ctx);
SEXP_t *probe_ctx_getresult(probe_ctx *ctx);
typedef struct {
oval_datatype_t type;
void *value;
} probe_elmatr_t;
SEXP_t *probe_item_create(oval_subtype_t item_subtype, probe_elmatr_t *item_attributes[], ...);
#define PROBE_ENT_AREF(ent, dst, attr_name, invalid_exp) \
do { \
if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
dE("Attribute `%s' is missing!\n", attr_name); \
invalid_exp \
} \
} while(0)
#define PROBE_ENT_STRVAL(ent, dst, dstlen, invalid_exp, zerolen_exp) \
do { \
SEXP_t *___r; \
\
if ((___r = probe_ent_getval(ent)) == NULL) { \
dW("Entity has no value!\n"); \
invalid_exp \
} else { \
if (!SEXP_stringp(___r)) { \
dE("Invalid type\n"); \
SEXP_free(___r); \
invalid_exp \
} \
else if (SEXP_string_length(___r) == 0) { \
SEXP_free(___r); \
zerolen_exp \
} else { \
SEXP_string_cstr_r(___r, dst, dstlen); \
SEXP_free(___r); \
} \
} \
} while (0)
#define PROBE_ENT_I32VAL(ent, dst, invalid_exp, nil_exp) \
do { \
SEXP_t *___r; \
\
if ((___r = probe_ent_getval(ent)) == NULL) { \
dW("Entity has no value!\n"); \
nil_exp; \
} else { \
if (!SEXP_numberp(___r)) { \
dE("Invalid type\n"); \
SEXP_free(___r); \
invalid_exp; \
} else { \
dst = SEXP_number_geti_32(___r); \
SEXP_free(___r); \
} \
} \
} while (0)
#endif /* PROBE_API_H */
oval_operation_t probe_ent_getoperation(SEXP_t *entity, oval_operation_t op);
int probe_item_add_msg(SEXP_t *item, oval_message_level_t msglvl, char *msgfmt, ...);
SEXP_t *probe_entval_from_cstr(oval_datatype_t type, const char *value, size_t vallen);
SEXP_t *probe_ent_from_cstr(const char *name, oval_datatype_t type, const char *value, size_t vallen);
oval_version_t probe_obj_get_schema_version(const SEXP_t *obj);
SEXP_t *probe_obj_getmask(SEXP_t *obj);