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