Open SCAP Library: _seap-command.h Source File

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

_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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 #if defined(SEAP_THREAD_SAFE)
30 # include <pthread.h>
31 #endif
32
33 #include "public/seap-command.h"
34 #include "_sexp-types.h"
35 #include "../../../common/util.h"
36
37 OSCAP_HIDDEN_START;
38
39 typedef uint8_t SEAP_cmdclass_t;
40
41 #define SEAP_CMDCLASS_INT 1
42 #define SEAP_CMDCLASS_USR 2
43
44 #define SEAP_CMDFLAG_SYNC 0x01
45 #define SEAP_CMDFLAG_ASYNC 0x00
46 #define SEAP_CMDFLAG_REPLY 0x02
47 #define SEAP_CMDFLAG_MASK 0xff
48
49 struct SEAP_cmd {
50 SEAP_cmdid_t id;
51 SEAP_cmdid_t rid;
52 uint8_t flags;
53 SEAP_cmdclass_t class;
54 SEAP_cmdcode_t code;
55 SEXP_t *args;
56 };
57
58 struct SEAP_synchelper {
59 SEXP_t *args;
60 pthread_cond_t cond;
61 pthread_mutex_t mtx;
62 int signaled;
63 };
64
65 #define SEAP_CMDTBL_LARGE 0x01
66 #define SEAP_CMDTBL_LARGE_TRESHOLD 32
67
68 typedef struct {
69 uint8_t flags;
70 void *table;
71 size_t maxcnt;
72 #if defined(SEAP_THREAD_SAFE)
73 pthread_rwlock_t lock;
74 #endif
75 } SEAP_cmdtbl_t;
76
77 typedef struct {
78 SEAP_cmdcode_t code;
79 SEAP_cmdfn_t func;
80 void *arg;
81 } SEAP_cmdrec_t;
82
83 SEAP_cmdtbl_t *SEAP_cmdtbl_new (void);
84 void SEAP_cmdtbl_free (SEAP_cmdtbl_t *t);
85
86 int SEAP_cmdtbl_setsize (SEAP_cmdtbl_t *t, size_t maxsz);
87 int SEAP_cmdtbl_setfl (SEAP_cmdtbl_t *t, uint8_t f);
88 int SEAP_cmdtbl_unsetfl (SEAP_cmdtbl_t *t, uint8_t f);
89
90 /* Generic operations */
91 int SEAP_cmdtbl_add (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
92 int SEAP_cmdtbl_ins (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
93 int SEAP_cmdtbl_del (SEAP_cmdtbl_t *t, SEAP_cmdrec_t *r);
94 SEAP_cmdrec_t *SEAP_cmdtbl_get (SEAP_cmdtbl_t *t, SEAP_cmdcode_t c);
95 int SEAP_cmdtbl_cmp (SEAP_cmdrec_t *a, SEAP_cmdrec_t *b);
96
97 #define SEAP_CMDTBL_ECOLL 1
98
99 SEAP_cmdrec_t *SEAP_cmdrec_new (void);
100 void SEAP_cmdrec_free (SEAP_cmdrec_t *r);
101
102 typedef uint8_t SEAP_cflags_t;
103
104 #define SEAP_CFLG_THREAD 0x01
105 #define SEAP_CFLG_WATCH 0x02
106
107 /* Backends */
108 #include "seap-command-backendT.h"
109
110 typedef struct {
111 SEAP_CTX_t *ctx;
112 int sd;
113 SEAP_cmd_t *cmd;
114 } SEAP_cmdjob_t;
115
116 SEAP_cmdjob_t *SEAP_cmdjob_new (void);
117 void SEAP_cmdjob_free (SEAP_cmdjob_t *j);
118
119 SEXP_t *SEAP_cmd2sexp (SEAP_cmd_t *cmd);
120
121 OSCAP_HIDDEN_END;
122
123 #endif /* _SEAP_COMMAND_H */
SEAP_CTX
Definition: _seap-types.h:37
SEAP_synchelper
Definition: _seap-command.h:58
SEAP_cmd
Definition: _seap-command.h:49
SEAP_cmdjob_t
Definition: _seap-command.h:110
SEAP_cmdtbl_t
Definition: _seap-command.h:68
SEAP_cmdrec_t
Definition: _seap-command.h:77
SEXP
Definition: sexp-types.h:82