Skip to content
This repository
Newer
Older
100644 93 lines (73 sloc) 2.08 kb
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20bc »
2011-01-14 Happy new year!
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
2c390923 »
2009-01-02 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2660 5dc97367-9…
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
23 */
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
24
25 #include "common-internal.h"
26 #include "admin_request.h"
27 #include "list_ext.h"
28 #include "pickle.h"
29
30
31 struct cherokee_admin_request {
32 cherokee_buffer_t req;
33 int num;
34 struct list_head list;
35 };
36
37
38 ret_t cherokee_admin_request_new (cherokee_admin_request_t **req)
39 {
40 CHEROKEE_NEW_STRUCT (n, admin_request);
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
41
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
42 INIT_LIST_HEAD(&n->list);
43 cherokee_buffer_init (&n->req);
44 n->num = 0;
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
45
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
46 *req = n;
47 return ret_ok;
48 }
49
50
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
51 ret_t
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
52 cherokee_admin_request_free (cherokee_admin_request_t *req)
53 {
1c17f18f »
2006-09-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@383 5dc97367-97…
54 cherokee_list_content_free (&req->list, free);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
55 cherokee_buffer_mrproper (&req->req);
56
57 free (req);
58 return ret_ok;
59 }
60
61
62 ret_t
63 cherokee_admin_request_add (cherokee_admin_request_t *req, char *key)
64 {
1c17f18f »
2006-09-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@383 5dc97367-97…
65 cherokee_list_add_tail_content (&req->list, strdup(key));
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
66 req->num++;
67 return ret_ok;
68 }
69
70
71 ret_t
72 cherokee_admin_request_serialize (cherokee_admin_request_t *req)
73 {
74 list_t *i;
75
76 /* Add the number of elements
77 */
78 cherokee_pickle_add_uint (&req->req, req->num);
79
80 /* Add each string
81 */
82 list_for_each (i, &req->list) {
83 char *str = (char *)LIST_ITEM_INFO(i);
84 cherokee_pickle_add_string (&req->req, str, strlen(str));
85 }
86
87 /* Clean the list
88 */
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
89 cherokee_list_content_free (&req->list, free);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
90 return ret_ok;
91 }
92
Something went wrong with that request. Please try again.