00001 #ifndef __STUB_PROBE
00002 #pragma once
00003 #ifndef _SEAP_COMMAND_H
00004 #define _SEAP_COMMAND_H
00005
00006 #include <stdint.h>
00007 #include <stddef.h>
00008 #if defined(SEAP_THREAD_SAFE)
00009 # include <pthread.h>
00010 #endif
00011
00012 #include "public/seap-command.h"
00013 #include "_sexp-types.h"
00014 #include "../../../common/util.h"
00015
00016 OSCAP_HIDDEN_START;
00017
00018 typedef uint8_t SEAP_cmdclass_t;
00019
00020 #define SEAP_CMDCLASS_INT 1
00021 #define SEAP_CMDCLASS_USR 2
00022
00023 #define SEAP_CMDFLAG_SYNC 0x01
00024 #define SEAP_CMDFLAG_ASYNC 0x00
00025 #define SEAP_CMDFLAG_REPLY 0x02
00026 #define SEAP_CMDFLAG_MASK 0xff
00027
00028 struct SEAP_cmd {
00029 SEAP_cmdid_t id;
00030 SEAP_cmdid_t rid;
00031 uint8_t flags;
00032 SEAP_cmdclass_t class;
00033 SEAP_cmdcode_t code;
00034 SEXP_t *args;
00035 };
00036
00037 struct SEAP_synchelper {
00038 SEXP_t *args;
00039 pthread_cond_t cond;
00040 pthread_mutex_t mtx;
00041 };
00042
00043 #define SEAP_CMDTBL_LARGE 0x01
00044 #define SEAP_CMDTBL_LARGE_TRESHOLD 32
00045
00046 typedef struct {
00047 uint8_t flags;
00048 void *table;
00049 size_t maxcnt;
00050 #if defined(SEAP_THREAD_SAFE)
00051 pthread_rwlock_t lock;
00052 #endif
00053 } SEAP_cmdtbl_t;
00054
00055 typedef struct {
00056 SEAP_cmdcode_t code;
00057 SEAP_cmdfn_t func;
00058 void *arg;
00059 } SEAP_cmdrec_t;
00060
00061 SEAP_cmdtbl_t *SEAP_cmdtbl_new (void);
00062 void SEAP_cmdtbl_free (SEAP_cmdtbl_t *t);
00063
00064 int SEAP_cmdtbl_setsize (SEAP_cmdtbl_t *t, size_t maxsz);
00065 int SEAP_cmdtbl_setfl (SEAP_cmdtbl_t *t, uint8_t f);
00066 int SEAP_cmdtbl_unsetfl (SEAP_cmdtbl_t *t, uint8_t f);
00067
00068
00069 int SEAP_cmdtbl_add (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
00070 int SEAP_cmdtbl_ins (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
00071 int SEAP_cmdtbl_del (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
00072 SEAP_cmdrec_t *SEAP_cmdtbl_get (SEAP_cmdtbl_t *t, SEAP_cmdcode_t c);
00073 int SEAP_cmdtbl_cmp (SEAP_cmdrec_t *a, SEAP_cmdrec_t *b);
00074
00075 #define SEAP_CMDTBL_ECOLL 1
00076
00077 SEAP_cmdrec_t *SEAP_cmdrec_new (void);
00078 void SEAP_cmdrec_free (SEAP_cmdrec_t *r);
00079
00080 #define SEAP_EXEC_LOCAL 0x01
00081 #define SEAP_EXEC_LONLY 0x02
00082 #define SEAP_EXEC_GFIRST 0x04
00083 #define SEAP_EXEC_THREAD 0x08
00084 #define SEAP_EXEC_WQUEUE 0x10
00085
00086 typedef uint8_t SEAP_cflags_t;
00087
00088 #define SEAP_CFLG_THREAD 0x01
00089 #define SEAP_CFLG_WATCH 0x02
00090
00091
00092 #include "seap-command-backendL.h"
00093 #include "seap-command-backendS.h"
00094
00095 typedef struct {
00096 SEAP_CTX_t *ctx;
00097 int sd;
00098 SEAP_cmd_t *cmd;
00099 } SEAP_cmdjob_t;
00100
00101 SEAP_cmdjob_t *SEAP_cmdjob_new (void);
00102 void SEAP_cmdjob_free (SEAP_cmdjob_t *j);
00103
00104 SEXP_t *SEAP_cmd2sexp (SEAP_cmd_t *cmd);
00105
00106 OSCAP_HIDDEN_END;
00107
00108 #endif
00109 #endif