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