• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

/home/pvrabec/project/openscap/openscap-0.6.3/src/OVAL/probes/SEAP/_seap-command.h

00001 /*
00002  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
00003  * All Rights Reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  * Authors:
00020  *      "Daniel Kopecek" <dkopecek@redhat.com>
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         int signaled;
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 /* Generic operations */
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 typedef uint8_t SEAP_cflags_t;
00103 
00104 #define SEAP_CFLG_THREAD 0x01
00105 #define SEAP_CFLG_WATCH  0x02
00106 
00107 /* Backends */
00108 #include "seap-command-backendT.h"
00109 
00110 typedef struct {
00111         SEAP_CTX_t *ctx;
00112         int         sd;
00113         SEAP_cmd_t *cmd;
00114 } SEAP_cmdjob_t;
00115 
00116 SEAP_cmdjob_t *SEAP_cmdjob_new (void);
00117 void SEAP_cmdjob_free (SEAP_cmdjob_t *j);
00118 
00119 SEXP_t *SEAP_cmd2sexp (SEAP_cmd_t *cmd);
00120 
00121 OSCAP_HIDDEN_END;
00122 
00123 #endif /* _SEAP_COMMAND_H */

Generated on Tue Sep 14 2010 for Open SCAP Library by  doxygen 1.7.1