Remove all trailing whitespace from source files
[gpgme.git] / src / getauditlog.c
1
2 /* getauditlog.c - Retrieve the audit log.
3    Copyright (C) 2007 g10 Code GmbH
4
5    This file is part of GPGME.
6
7    GPGME is free software; you can redistribute it and/or modify it
8    under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 2.1 of
10    the License, or (at your option) any later version.
11
12    GPGME is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #if HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include "gpgme.h"
26 #include "debug.h"
27 #include "context.h"
28 #include "ops.h"
29
30 \f
31 static gpgme_error_t
32 getauditlog_status_handler (void *priv, gpgme_status_code_t code, char *args)
33 {
34   return 0;
35 }
36
37
38 static gpgme_error_t
39 getauditlog_start (gpgme_ctx_t ctx, int synchronous,
40                    gpgme_data_t output, unsigned int flags)
41 {
42   gpgme_error_t err;
43
44   if (!output)
45     return gpg_error (GPG_ERR_INV_VALUE);
46
47   err = _gpgme_op_reset (ctx, ((synchronous&255) | 256) );
48   if (err)
49     return err;
50
51   _gpgme_engine_set_status_handler (ctx->engine,
52                                     getauditlog_status_handler, ctx);
53
54   return _gpgme_engine_op_getauditlog (ctx->engine, output, flags);
55 }
56
57
58
59 /* Return the auditlog for the current session.  This may be called
60    after a successful or failed operation.  If no audit log is
61    available GPG_ERR_NO_DATA is returned.  This is the asynchronous
62    variant. */
63 gpgme_error_t
64 gpgme_op_getauditlog_start (gpgme_ctx_t ctx,
65                             gpgme_data_t output, unsigned int flags)
66 {
67   gpg_error_t err;
68   TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog_start", ctx,
69               "output=%p, flags=0x%x", output, flags);
70
71   if (!ctx)
72     return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
73
74   err = getauditlog_start (ctx, 0, output, flags);
75   return TRACE_ERR (err);
76 }
77
78
79 /* Return the auditlog for the current session.  This may be called
80    after a successful or failed operation.  If no audit log is
81    available GPG_ERR_NO_DATA is returned.  This is the synchronous
82    variant. */
83 gpgme_error_t
84 gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags)
85 {
86   gpgme_error_t err;
87
88   TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog", ctx,
89               "output=%p, flags=0x%x", output, flags);
90
91   if (!ctx)
92     return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
93
94   err = getauditlog_start (ctx, 1, output, flags);
95   if (!err)
96     err = _gpgme_wait_one (ctx);
97   return TRACE_ERR (err);
98 }
99