Statistics
| Branch: | Revision:

root / include / qemu / uri.h @ 5a37532d

History | View | Annotate | Download (4.3 kB)

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