Add qemu 2.4.0
[kvmfornfv.git] / qemu / include / qemu / uri.h
1 /**
2  * Summary: library of generic URI related routines
3  * Description: library of generic URI related routines
4  *              Implements RFC 2396
5  *
6  * Copyright (C) 1998-2003 Daniel Veillard.  All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
21  * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  * Except as contained in this notice, the name of Daniel Veillard shall not
26  * be used in advertising or otherwise to promote the sale, use or other
27  * dealings in this Software without prior written authorization from him.
28  *
29  * Author: Daniel Veillard
30  **
31  * Copyright (C) 2007 Red Hat, Inc.
32  *
33  * This library is free software; you can redistribute it and/or
34  * modify it under the terms of the GNU Lesser General Public
35  * License as published by the Free Software Foundation; either
36  * version 2.1 of the License, or (at your option) any later version.
37  *
38  * This library is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
41  * Lesser General Public License for more details.
42  *
43  * You should have received a copy of the GNU Lesser General Public
44  * License along with this library; if not, write to the Free Software
45  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
46  *
47  * Authors:
48  *    Richard W.M. Jones <rjones@redhat.com>
49  *
50  * Utility functions to help parse and assemble query strings.
51  */
52
53 #ifndef QEMU_URI_H
54 #define QEMU_URI_H
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 /**
61  * URI:
62  *
63  * A parsed URI reference. This is a struct containing the various fields
64  * as described in RFC 2396 but separated for further processing.
65  */
66 typedef struct URI {
67     char *scheme;       /* the URI scheme */
68     char *opaque;       /* opaque part */
69     char *authority;    /* the authority part */
70     char *server;       /* the server part */
71     char *user;         /* the user part */
72     int port;           /* the port number */
73     char *path;         /* the path string */
74     char *fragment;     /* the fragment identifier */
75     int  cleanup;       /* parsing potentially unclean URI */
76     char *query;        /* the query string (as it appears in the URI) */
77 } URI;
78
79 URI *uri_new(void);
80 char *uri_resolve(const char *URI, const char *base);
81 char *uri_resolve_relative(const char *URI, const char *base);
82 URI *uri_parse(const char *str);
83 URI *uri_parse_raw(const char *str, int raw);
84 int uri_parse_into(URI *uri, const char *str);
85 char *uri_to_string(URI *uri);
86 char *uri_string_escape(const char *str, const char *list);
87 char *uri_string_unescape(const char *str, int len, char *target);
88 void uri_free(URI *uri);
89
90 /* Single web service query parameter 'name=value'. */
91 typedef struct QueryParam {
92   char *name;                   /* Name (unescaped). */
93   char *value;                  /* Value (unescaped). */
94   int ignore;                   /* Ignore this field in qparam_get_query */
95 } QueryParam;
96
97 /* Set of parameters. */
98 typedef struct QueryParams {
99   int n;                        /* number of parameters used */
100   int alloc;                    /* allocated space */
101   QueryParam *p;                /* array of parameters */
102 } QueryParams;
103
104 struct QueryParams *query_params_new (int init_alloc);
105 int query_param_append (QueryParams *ps, const char *name, const char *value);
106 extern char *query_param_to_string (const QueryParams *ps);
107 extern QueryParams *query_params_parse (const char *query);
108 extern void query_params_free (QueryParams *ps);
109
110 #ifdef __cplusplus
111 }
112 #endif
113 #endif /* QEMU_URI_H */