build: make the "rpm" rule work once again
[iwhd.git] / state_defs.h
blob144323645bf6bc22793d469fa6c5983eba02265b
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(_STATE_DEFS_H)
17 #define _STATE_DEFS_H
19 #include <glib.h>
20 #include <microhttpd.h>
21 #include "mpipe.h"
22 #include "template.h"
24 #define MAX_FIELD_LEN 64
26 /* Avoid circular (my_state->provider->backend->my_state) include. */
27 struct _provider;
29 typedef enum {
30 MS_NEW,
31 MS_NORMAL,
32 } ms_state;
35 * This structure is used for pthread_create targets that take a void*
36 * argument, so that they can find the state_def and provider_t that they
37 * need regardless of whether they were invoked from main-line request
38 * code (using the thunk embedded here) or the replica code (using a thunk
39 * embedded in the repl_item).
41 typedef struct {
42 struct _my_state *parent;
43 struct _provider *prov;
44 } backend_thunk_t;
46 typedef struct _my_state {
47 volatile gint refcnt;
48 int cleanup;
49 /* for everyone */
50 MHD_AccessHandlerCallback handler;
51 ms_state state;
52 /* for proxy ops */
53 char *url;
54 char bucket[MAX_FIELD_LEN];
55 char key[MAX_FIELD_LEN];
56 char attr[MAX_FIELD_LEN];
57 /* for proxy gets */
58 long rc;
59 /* for proxy puts */
60 size_t size;
61 /* for proxy puts and queries */
62 struct MHD_Connection *conn;
63 /* for proxy queries */
64 struct MHD_PostProcessor *post;
65 void *query; /* object query */
66 void *aquery; /* attribute query */
67 /* for bucket-level puts */
68 GHashTable *dict;
69 /* for new producer/consumer model */
70 pipe_shared pipe;
71 int from_master;
72 pthread_t backend_th;
73 pthread_t cache_th;
74 /* for bucket/object/provider list generators */
75 tmpl_ctx_t *gen_ctx;
76 GHashTableIter prov_iter;
77 /* for back-end functions */
78 backend_thunk_t thunk;
79 int be_flags;
80 } my_state;
82 #define CLEANUP_CURL 0x01 /* no longer needed */
83 #define CLEANUP_BUF_PTR 0x02
84 #define CLEANUP_POST 0x04
85 #define CLEANUP_DICT 0x08
86 #define CLEANUP_QUERY 0x10
87 #define CLEANUP_TMPL 0x20
88 #define CLEANUP_URL 0x40
89 #define CLEANUP_AQUERY 0x80
91 #define BACKEND_GET_SIZE 0x01 /* used in put_child_func */
93 void free_ms (my_state *ms);
95 #endif