Open SCAP Library
Loading...
Searching...
No Matches
_seap-command.h
1/*
2 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * "Daniel Kopecek" <dkopecek@redhat.com>
21 */
22
23#pragma once
24#ifndef _SEAP_COMMAND_H
25#define _SEAP_COMMAND_H
26
27#include <stdint.h>
28#include <stddef.h>
29#include <pthread.h>
30
31#include "_sexp-types.h"
32#include "_seap-types.h"
33#include "../../../common/util.h"
34
35
36#define SEAP_CMDCLASS_INT 1
37#define SEAP_CMDCLASS_USR 2
38
39#define SEAP_CMDFLAG_SYNC 0x01
40#define SEAP_CMDFLAG_ASYNC 0x00
41#define SEAP_CMDFLAG_REPLY 0x02
42#define SEAP_CMDFLAG_MASK 0xff
43
44#define SEAP_CMDTYPE_SYNC 1
45#define SEAP_CMDTYPE_ASYNC 2
46
47#define SEAP_CMDREG_LOCAL 0x00000001
48#define SEAP_CMDREG_USEARG 0x00000002
49#define SEAP_CMDREG_THREAD 0x00000004
50
51#define SEAP_EXEC_LOCAL 0x01
52#define SEAP_EXEC_LONLY 0x02
53#define SEAP_EXEC_GFIRST 0x04
54#define SEAP_EXEC_THREAD 0x08
55#define SEAP_EXEC_WQUEUE 0x10
56#define SEAP_EXEC_RECV 0x20
57
58
59struct SEAP_cmd {
60 SEAP_cmdid_t id;
61 SEAP_cmdid_t rid;
62 uint8_t flags;
63 SEAP_cmdclass_t class;
64 SEAP_cmdcode_t code;
65 SEXP_t *args;
66};
67typedef struct SEAP_cmd SEAP_cmd_t;
68
70 SEXP_t *args;
71 pthread_cond_t cond;
72 pthread_mutex_t mtx;
73 int signaled;
74};
75
76#define SEAP_CMDTBL_LARGE 0x01
77#define SEAP_CMDTBL_LARGE_TRESHOLD 32
78
79typedef struct {
80 SEAP_cmdcode_t code;
81 SEAP_cmdfn_t func;
82 void *arg;
84
85SEAP_cmdtbl_t *SEAP_cmdtbl_new (void);
86void SEAP_cmdtbl_free (SEAP_cmdtbl_t *t);
87
88int SEAP_cmdtbl_setsize (SEAP_cmdtbl_t *t, size_t maxsz);
89int SEAP_cmdtbl_setfl (SEAP_cmdtbl_t *t, uint8_t f);
90int SEAP_cmdtbl_unsetfl (SEAP_cmdtbl_t *t, uint8_t f);
91
92/* Generic operations */
93int SEAP_cmdtbl_add (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
94int SEAP_cmdtbl_ins (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
95int SEAP_cmdtbl_del (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
96SEAP_cmdrec_t *SEAP_cmdtbl_get (SEAP_cmdtbl_t *t, SEAP_cmdcode_t c);
97int SEAP_cmdtbl_cmp (SEAP_cmdrec_t *a, SEAP_cmdrec_t *b);
98
99#define SEAP_CMDTBL_ECOLL 1
100
101SEAP_cmdrec_t *SEAP_cmdrec_new (void);
102void SEAP_cmdrec_free (SEAP_cmdrec_t *r);
103
104#define SEAP_CFLG_THREAD 0x01
105#define SEAP_CFLG_WATCH 0x02
106
107/* Backends */
108#include "seap-command-backendT.h"
109
110typedef struct {
111 SEAP_CTX_t *ctx;
112 int sd;
113 SEAP_cmd_t *cmd;
115
116SEAP_cmdjob_t *SEAP_cmdjob_new (void);
117void SEAP_cmdjob_free (SEAP_cmdjob_t *j);
118
119SEXP_t *SEAP_cmd2sexp (SEAP_cmd_t *cmd);
120
121int SEAP_cmd_register(SEAP_CTX_t *ctx, SEAP_cmdcode_t code, uint32_t flags, SEAP_cmdfn_t func, ...);
122
123SEXP_t *SEAP_cmd_exec(SEAP_CTX_t *ctx,
124 int sd,
125 uint32_t flags,
126 SEAP_cmdcode_t code,
127 SEXP_t *args,
128 SEAP_cmdtype_t type,
129 SEAP_cmdfn_t func,
130 void *funcarg);
131
132#endif /* _SEAP_COMMAND_H */
Definition _seap-types.h:51
Definition _seap-command.h:59
Definition _seap-command.h:110
Definition _seap-command.h:79
Definition _seap-types.h:41
Definition _seap-command.h:69
Definition sexp-types.h:82