2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
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.
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.
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.
20 #include <atompub/atom.h>
28 void (*map_entries) (AtomCtx *, char **, AtomEntry **, size_t);
29 int (*is_feed) (AtomCtx *, char *);
30 AtomRequest * (*get_request) (AtomCtx *);
36 AtomFrontend *frontend;
37 frontend = g_slice_new (AtomFrontend);
38 frontend->map_entries = NULL;
39 frontend->is_feed = NULL;
40 frontend->get_request = NULL;
45 atom_frontend_delete (AtomFrontend *frontend)
47 g_slice_free (AtomFrontend, frontend);
51 atom_frontend_map_entries_set (AtomFrontend *frontend,
52 void map_entries (AtomCtx *,
57 frontend->map_entries = map_entries;
61 atom_frontend_is_feed_set (AtomFrontend *frontend,
62 int is_feed (AtomCtx *, char *))
64 frontend->is_feed = is_feed;
68 atom_frontend_get_request_set (AtomFrontend *frontend,
69 AtomRequest * get_request (AtomCtx *))
71 frontend->get_request = get_request;
75 atom_frontend_map_entries (AtomCtx *ctx, char ** reqs,
76 AtomEntry ** entries, size_t len)
78 AtomFrontend *frontend;
79 frontend = atom_frontend (ctx);
80 if (frontend && frontend->map_entries)
82 frontend->map_entries (ctx, reqs, entries, len);
87 atom_is_feed (AtomCtx *ctx, char *req)
89 AtomFrontend *frontend;
91 frontend = atom_frontend (ctx);
92 if (frontend && frontend->is_feed)
94 return frontend->is_feed (ctx, req);
96 /* If frontend cannot decide if a request is a feed, let's tell it's
97 * not. If the request mapping cannot be done, it will return a "Not
98 * Found" error anyway.
104 atom_get_request (AtomCtx *ctx)
106 AtomFrontend *frontend;
107 frontend = atom_frontend (ctx);
108 if (frontend && frontend->get_request)
110 return frontend->get_request (ctx);