Skip to content

Commit 297c61e

Browse files
committed
net: add an isvalid function
(Also, mark all the declarations as extern.)
1 parent a194e17 commit 297c61e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/net.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ int git_net_url_parse(git_net_url *url, const char *given)
153153
return error;
154154
}
155155

156+
bool git_net_url_valid(git_net_url *url)
157+
{
158+
return (url->host && url->port && url->path);
159+
}
160+
156161
int git_net_url_is_default_port(git_net_url *url)
157162
{
158163
return (strcmp(url->port, default_port_for_scheme(url->scheme)) == 0);

src/net.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ typedef struct git_net_url {
2222
#define GIT_NET_URL_INIT { NULL }
2323

2424
/** Parses a string containing a URL into a structure. */
25-
int git_net_url_parse(git_net_url *url, const char *str);
25+
extern int git_net_url_parse(git_net_url *url, const char *str);
26+
27+
/** Ensures that a URL is minimally valid (contains a host, port and path) */
28+
extern bool git_net_url_valid(git_net_url *url);
2629

2730
/** Returns nonzero if the URL is on the default port. */
28-
int git_net_url_is_default_port(git_net_url *url);
31+
extern int git_net_url_is_default_port(git_net_url *url);
2932

3033
/** Swaps the contents of one URL for another. */
31-
void git_net_url_swap(git_net_url *a, git_net_url *b);
34+
extern void git_net_url_swap(git_net_url *a, git_net_url *b);
3235

3336
/** Disposes the contents of the structure. */
34-
void git_net_url_dispose(git_net_url *url);
37+
extern void git_net_url_dispose(git_net_url *url);
3538

3639
#endif

0 commit comments

Comments
 (0)