]>
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 | ||
c25aa7cd PP |
24 | /** Duplicate a URL */ |
25 | extern int git_net_url_dup(git_net_url *out, git_net_url *in); | |
26 | ||
22a2d3d5 UG |
27 | /** Parses a string containing a URL into a structure. */ |
28 | extern int git_net_url_parse(git_net_url *url, const char *str); | |
29 | ||
30 | /** Appends a path and/or query string to the given URL */ | |
31 | extern int git_net_url_joinpath( | |
32 | git_net_url *out, | |
33 | git_net_url *in, | |
34 | const char *path); | |
35 | ||
36 | /** Ensures that a URL is minimally valid (contains a host, port and path) */ | |
37 | extern bool git_net_url_valid(git_net_url *url); | |
38 | ||
c25aa7cd PP |
39 | /** Returns true if the URL is on the default port. */ |
40 | extern bool git_net_url_is_default_port(git_net_url *url); | |
41 | ||
42 | /** Returns true if the host portion of the URL is an ipv6 address. */ | |
43 | extern bool git_net_url_is_ipv6(git_net_url *url); | |
22a2d3d5 UG |
44 | |
45 | /* Applies a redirect to the URL with a git-aware service suffix. */ | |
46 | extern int git_net_url_apply_redirect( | |
47 | git_net_url *url, | |
48 | const char *redirect_location, | |
49 | const char *service_suffix); | |
50 | ||
51 | /** Swaps the contents of one URL for another. */ | |
52 | extern void git_net_url_swap(git_net_url *a, git_net_url *b); | |
53 | ||
54 | /** Places the URL into the given buffer. */ | |
55 | extern int git_net_url_fmt(git_buf *out, git_net_url *url); | |
56 | ||
57 | /** Place the path and query string into the given buffer. */ | |
58 | extern int git_net_url_fmt_path(git_buf *buf, git_net_url *url); | |
59 | ||
c25aa7cd PP |
60 | /** Determines if the url matches given pattern or pattern list */ |
61 | extern bool git_net_url_matches_pattern( | |
62 | git_net_url *url, | |
63 | const char *pattern); | |
64 | extern bool git_net_url_matches_pattern_list( | |
65 | git_net_url *url, | |
66 | const char *pattern_list); | |
67 | ||
22a2d3d5 UG |
68 | /** Disposes the contents of the structure. */ |
69 | extern void git_net_url_dispose(git_net_url *url); | |
70 | ||
71 | #endif |