plug leaks-after-OOM-failure
[iwhd.git] / template.h
blob96c89d2be4ef0ea7eed24efbd486ca8beda71a95
1 /* Copyright (C) 2010 Red Hat, Inc.
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 #if !defined(_TEMPLATE_H)
17 #define _TEMPLATE_H
19 #define TMPL_BUF_SIZE 1024
21 typedef struct {
22 const char *root_header;
23 const char *root_entry;
24 const char *root_footer;
25 const char *prov_header;
26 const char *prov_entry;
27 const char *prov_footer;
28 const char *list_header;
29 const char *list_entry;
30 const char *list_footer;
31 const char *obj_header;
32 const char *obj_entry;
33 const char *obj_footer;
34 int z_offset; /* offset to use when index is zero */
35 } tmpl_format_t;
37 typedef struct {
38 const tmpl_format_t *format;
39 const char *base;
40 unsigned int index;
41 char raw_buf[TMPL_BUF_SIZE];
42 const char *buf;
43 } tmpl_ctx_t;
45 #define TMPL_CTX_DONE ((tmpl_ctx_t *)(-1))
47 tmpl_ctx_t *tmpl_get_ctx (const char *type);
48 size_t tmpl_root_header (tmpl_ctx_t *ctx,
49 const char *name, const char *version);
50 size_t tmpl_root_entry (tmpl_ctx_t *ctx,
51 const char *rel, const char *link);
52 size_t tmpl_root_footer (tmpl_ctx_t *ctx);
53 size_t tmpl_prov_header (tmpl_ctx_t *ctx);
54 size_t tmpl_prov_entry (tmpl_ctx_t *ctx,
55 const char *name, const char *type,
56 const char *host, int port,
57 const char *user, const char *pass);
58 size_t tmpl_prov_footer (tmpl_ctx_t *ctx);
59 size_t tmpl_list_header (tmpl_ctx_t *ctx);
60 size_t tmpl_list_entry (tmpl_ctx_t *ctx,
61 const char *bucket, const char *key);
62 size_t tmpl_list_footer (tmpl_ctx_t *ctx);
63 size_t tmpl_obj_header (tmpl_ctx_t *ctx,
64 const char *bucket, const char *key);
65 size_t tmpl_obj_entry (tmpl_ctx_t *ctx, const char *bucket,
66 const char *key, const char *attr);
67 size_t tmpl_obj_footer (tmpl_ctx_t *ctx);
70 #endif