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