]>
Commit | Line | Data |
---|---|---|
0c9c969a 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 | ||
24 | /** Parses a string containing a URL into a structure. */ | |
25 | extern int git_net_url_parse(git_net_url *url, const char *str); | |
26 | ||
27 | /** Appends a path and/or query string to the given URL */ | |
28 | extern int git_net_url_joinpath( | |
29 | git_net_url *out, | |
30 | git_net_url *in, | |
31 | const char *path); | |
32 | ||
33 | /** Ensures that a URL is minimally valid (contains a host, port and path) */ | |
34 | extern bool git_net_url_valid(git_net_url *url); | |
35 | ||
36 | /** Returns nonzero if the URL is on the default port. */ | |
37 | extern int git_net_url_is_default_port(git_net_url *url); | |
38 | ||
39 | /* Applies a redirect to the URL with a git-aware service suffix. */ | |
40 | extern int git_net_url_apply_redirect( | |
41 | git_net_url *url, | |
42 | const char *redirect_location, | |
43 | const char *service_suffix); | |
44 | ||
45 | /** Swaps the contents of one URL for another. */ | |
46 | extern void git_net_url_swap(git_net_url *a, git_net_url *b); | |
47 | ||
48 | /** Places the URL into the given buffer. */ | |
49 | extern int git_net_url_fmt(git_buf *out, git_net_url *url); | |
50 | ||
51 | /** Place the path and query string into the given buffer. */ | |
52 | extern int git_net_url_fmt_path(git_buf *buf, git_net_url *url); | |
53 | ||
54 | /** Disposes the contents of the structure. */ | |
55 | extern void git_net_url_dispose(git_net_url *url); | |
56 | ||
57 | #endif |