]>
Commit | Line | Data |
---|---|---|
22a2d3d5 UG |
1 | /* |
2 | * Copyright (C) the libgit2 contributors. All rights reserved. | |
3 | * | |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with | |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
6 | */ | |
7 | #ifndef INCLUDE_net_h__ | |
8 | #define INCLUDE_net_h__ | |
9 | ||
10 | #include "common.h" | |
11 | ||
12 | typedef struct git_net_url { | |
13 | char *scheme; | |
14 | char *host; | |
15 | char *port; | |
16 | char *path; | |
17 | char *query; | |
18 | char *username; | |
19 | char *password; | |
20 | } git_net_url; | |
21 | ||
22 | #define GIT_NET_URL_INIT { NULL } | |
23 | ||
e579e0f7 MB |
24 | /** Is a given string a url? */ |
25 | extern bool git_net_str_is_url(const char *str); | |
26 | ||
c25aa7cd PP |
27 | /** Duplicate a URL */ |
28 | extern int git_net_url_dup(git_net_url *out, git_net_url *in); | |
29 | ||
e579e0f7 | 30 | /** Parses a string containing a URL into a structure. */ |
22a2d3d5 UG |
31 | extern int git_net_url_parse(git_net_url *url, const char *str); |
32 | ||
e579e0f7 MB |
33 | /** Parses a string containing an SCP style path into a URL structure. */ |
34 | extern int git_net_url_parse_scp(git_net_url *url, const char *str); | |
35 | ||
22a2d3d5 UG |
36 | /** Appends a path and/or query string to the given URL */ |
37 | extern int git_net_url_joinpath( | |
38 | git_net_url *out, | |
39 | git_net_url *in, | |
40 | const char *path); | |
41 | ||
42 | /** Ensures that a URL is minimally valid (contains a host, port and path) */ | |
43 | extern bool git_net_url_valid(git_net_url *url); | |
44 | ||
c25aa7cd PP |
45 | /** Returns true if the URL is on the default port. */ |
46 | extern bool git_net_url_is_default_port(git_net_url *url); | |
47 | ||
48 | /** Returns true if the host portion of the URL is an ipv6 address. */ | |
49 | extern bool git_net_url_is_ipv6(git_net_url *url); | |
22a2d3d5 UG |
50 | |
51 | /* Applies a redirect to the URL with a git-aware service suffix. */ | |
52 | extern int git_net_url_apply_redirect( | |
53 | git_net_url *url, | |
54 | const char *redirect_location, | |
e579e0f7 | 55 | bool allow_offsite, |
22a2d3d5 UG |
56 | const char *service_suffix); |
57 | ||
58 | /** Swaps the contents of one URL for another. */ | |
59 | extern void git_net_url_swap(git_net_url *a, git_net_url *b); | |
60 | ||
61 | /** Places the URL into the given buffer. */ | |
e579e0f7 | 62 | extern int git_net_url_fmt(git_str *out, git_net_url *url); |
22a2d3d5 UG |
63 | |
64 | /** Place the path and query string into the given buffer. */ | |
e579e0f7 | 65 | extern int git_net_url_fmt_path(git_str *buf, git_net_url *url); |
22a2d3d5 | 66 | |
c25aa7cd PP |
67 | /** Determines if the url matches given pattern or pattern list */ |
68 | extern bool git_net_url_matches_pattern( | |
69 | git_net_url *url, | |
70 | const char *pattern); | |
71 | extern bool git_net_url_matches_pattern_list( | |
72 | git_net_url *url, | |
73 | const char *pattern_list); | |
74 | ||
22a2d3d5 UG |
75 | /** Disposes the contents of the structure. */ |
76 | extern void git_net_url_dispose(git_net_url *url); | |
77 | ||
78 | #endif |