qemu/include/qemu/uri.h
<<
>>
Prefs
   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, see <https://www.gnu.org/licenses/>.
  45 *
  46 * Authors:
  47 *    Richard W.M. Jones <rjones@redhat.com>
  48 *
  49 * Utility functions to help parse and assemble query strings.
  50 */
  51
  52#ifndef QEMU_URI_H
  53#define QEMU_URI_H
  54
  55/**
  56 * URI:
  57 *
  58 * A parsed URI reference. This is a struct containing the various fields
  59 * as described in RFC 2396 but separated for further processing.
  60 */
  61typedef struct URI {
  62    char *scheme;      /* the URI scheme */
  63    char *opaque;      /* opaque part */
  64    char *authority;   /* the authority part */
  65    char *server;      /* the server part */
  66    char *user;        /* the user part */
  67    int port;          /* the port number */
  68    char *path;        /* the path string */
  69    char *fragment;    /* the fragment identifier */
  70    int cleanup;       /* parsing potentially unclean URI */
  71    char *query;       /* the query string (as it appears in the URI) */
  72} URI;
  73
  74URI *uri_new(void);
  75char *uri_resolve(const char *URI, const char *base);
  76char *uri_resolve_relative(const char *URI, const char *base);
  77URI *uri_parse(const char *str);
  78URI *uri_parse_raw(const char *str, int raw);
  79int uri_parse_into(URI *uri, const char *str);
  80char *uri_to_string(URI *uri);
  81char *uri_string_escape(const char *str, const char *list);
  82char *uri_string_unescape(const char *str, int len, char *target);
  83void uri_free(URI *uri);
  84
  85/* Single web service query parameter 'name=value'. */
  86typedef struct QueryParam {
  87  char *name;          /* Name (unescaped). */
  88  char *value;         /* Value (unescaped). */
  89  int ignore;          /* Ignore this field in qparam_get_query */
  90} QueryParam;
  91
  92/* Set of parameters. */
  93typedef struct QueryParams {
  94  int n;               /* number of parameters used */
  95  int alloc;           /* allocated space */
  96  QueryParam *p;       /* array of parameters */
  97} QueryParams;
  98
  99struct QueryParams *query_params_new (int init_alloc);
 100extern QueryParams *query_params_parse (const char *query);
 101extern void query_params_free (QueryParams *ps);
 102
 103#endif /* QEMU_URI_H */
 104