8904b38616420cda5646400665c1246a188b07bd
[cascardo/atompub.git] / src / ctx.c
1 /*
2  *  Copyright (C) 2007  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20 #include <atompub/atom.h>
21
22 #include <glib.h>
23
24 struct _atom_ctx
25 {
26   GError *error;
27   gpointer config_data;
28   AtomBackend *backend;
29 };
30
31 AtomCtx *
32 atom_ctx_new ()
33 {
34   AtomCtx *ctx;
35   ctx = g_slice_new (AtomCtx);
36   ctx->error = NULL;
37   ctx->config_data = NULL;
38   return ctx;
39 }
40
41 void
42 atom_error_set (AtomCtx *ctx, GError *error)
43 {
44   if (ctx->error)
45     g_error_free (ctx->error);
46   ctx->error = error;
47 }
48
49 GError *
50 atom_error_get (AtomCtx *ctx)
51 {
52   return ctx->error;
53 }
54
55 void *
56 atom_config_data (AtomCtx *ctx)
57 {
58   return ctx->config_data;
59 }
60
61 void
62 atom_config_data_set (AtomCtx *ctx, void *data)
63 {
64   ctx->config_data = data;
65 }
66
67 AtomBackend *
68 atom_backend (AtomCtx *ctx)
69 {
70   return ctx->backend;
71 }
72
73 void
74 atom_backend_set (AtomCtx *ctx, AtomBackend *backend)
75 {
76   ctx->backend = backend;
77 }