File: uri.h

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (91 lines) | stat: -rw-r--r-- 3,025 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Copyright (c) 2012      Los Alamos National Security, LLC.
 *                         All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 *
 * @file
 */

/*
  Per RFC3986:
  The generic URI syntax consists of a hierarchical sequence of
   components referred to as the scheme, authority, path, query, and
   fragment.

      URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

      hier-part   = "//" authority path-abempty
                  / path-absolute
                  / path-rootless
                  / path-empty

   The scheme and path components are required, though the path may be
   empty (no characters).  When authority is present, the path must
   either be empty or begin with a slash ("/") character.  When
   authority is not present, the path cannot begin with two slash
   characters ("//").  These restrictions result in five different ABNF
   rules for a path (Section 3.3), only one of which will match any
   given URI reference.

   The following are two example URIs and their component parts:

         foo://example.com:8042/over/there?name=ferret#nose
         \_/   \______________/\_________/ \_________/ \__/
          |           |            |            |        |
       scheme     authority       path        query   fragment
          |   _____________________|__
         / \ /                        \
         urn:example:animal:ferret:nose

   Initially, this code supports only part of the first example - a scheme
   followed by an authority and a path. Queries and fragments are
   not supported. The APIs are modeled on the Gnome equivalent functions,
   though the code is NOT in any way based on thoat code.
*/

#ifndef OPAL_URI_H
#define OPAL_URI_H

#include "opal_config.h"

#ifdef HAVE_UNISTD_H
#    include <unistd.h>
#endif

BEGIN_C_DECLS

/**
 * Parse a uri to retrieve the scheme
 *
 * The caller is responsible for freeing the returned string.
 */
OPAL_DECLSPEC char *opal_uri_get_scheme(const char *uri)
    __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;

/**
 *  Create a uri from a hostname and filename
 *
 * The caller is responsible for freeing the returned string.
 */
OPAL_DECLSPEC char *opal_filename_to_uri(const char *filename, const char *hostname)
    __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
/**
 * Extract the filename (and hostname) from a uri
 *
 * @param uri : a uri describing a filename (escaped, encoded in ASCII).
 * @param hostname : Location to store hostname for the URI, or NULL.
 *                   If there is no hostname in the URI, NULL will be
 *                   stored in this location.
 * @retval a newly-allocated string holding the resulting filename, or NULL on an error.
 *
 * The caller is responsible for freeing the returned string.
 */
OPAL_DECLSPEC char *opal_filename_from_uri(const char *uri, char **hostname)
    __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;

END_C_DECLS
#endif /* OPAL_URI_H */