Open SCAP Library
seap.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_H
25 #define SEAP_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifndef SEAP_MSGID_BITS
32 # define SEAP_MSGID_BITS 32
33 #endif
34 
35 #include <stdint.h>
36 #include <sexp.h>
37 #include <seap-types.h>
38 #include <seap-message.h>
39 #include <seap-command.h>
40 #include <seap-error.h>
41 
42 #ifndef EOPNOTSUPP
43 # define EOPNOTSUPP 1001
44 #endif
45 
46 #ifndef ECANCELED
47 # define ECANCELED 1002
48 #endif
49 
50 SEAP_CTX_t *SEAP_CTX_new (void);
51 void SEAP_CTX_init (SEAP_CTX_t *ctx);
52 void SEAP_CTX_free (SEAP_CTX_t *ctx);
53 
54 int SEAP_connect (SEAP_CTX_t *ctx, const char *uri, uint32_t flags);
55 int SEAP_listen (SEAP_CTX_t *ctx, int sd, uint32_t maxcli);
56 int SEAP_accept (SEAP_CTX_t *ctx, int sd);
57 
58 int SEAP_open (SEAP_CTX_t *ctx, const char *path, uint32_t flags);
59 SEXP_t *SEAP_read (SEAP_CTX_t *ctx, int sd);
60 int SEAP_write (SEAP_CTX_t *ctx, int sd, SEXP_t *sexp);
61 int SEAP_close (SEAP_CTX_t *ctx, int sd);
62 
63 int SEAP_openfd (SEAP_CTX_t *ctx, int fd, uint32_t flags);
64 int SEAP_openfd2 (SEAP_CTX_t *ctx, int ifd, int ofd, uint32_t flags);
65 
66 SEAP_msg_t *SEAP_msg_new (void);
67 void SEAP_msg_free (SEAP_msg_t *msg);
68 int SEAP_msg_set (SEAP_msg_t *msg, SEXP_t *sexp);
69 SEXP_t *SEAP_msg_get (SEAP_msg_t *msg);
70 
71 int SEAP_msgattr_set (SEAP_msg_t *msg, const char *attr, SEXP_t *value);
72 SEXP_t *SEAP_msgattr_get (SEAP_msg_t *msg, const char *name);
73 
74 int SEAP_recvsexp (SEAP_CTX_t *ctx, int sd, SEXP_t **sexp);
75 int SEAP_recvmsg (SEAP_CTX_t *ctx, int sd, SEAP_msg_t **seap_msg);
76 
77 int SEAP_sendsexp (SEAP_CTX_t *ctx, int sd, SEXP_t *sexp);
78 int SEAP_sendmsg (SEAP_CTX_t *ctx, int sd, SEAP_msg_t *seap_msg);
79 
80 int SEAP_reply (SEAP_CTX_t *ctx, int sd, SEAP_msg_t *rep_msg, SEAP_msg_t *req_msg);
81 
82 int SEAP_senderr (SEAP_CTX_t *ctx, int sd, SEAP_err_t *err);
83 int SEAP_recverr (SEAP_CTX_t *ctx, int sd, SEAP_err_t **err);
84 int SEAP_recverr_byid (SEAP_CTX_t *ctx, int sd, SEAP_err_t **err, SEAP_msgid_t id);
85 
86 int SEAP_replyerr (SEAP_CTX_t *ctx, int sd, SEAP_msg_t *rep_msg, uint32_t e);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* SEAP_H */