Issue #11: uint16_t instead of unsigned short for URI port number

This commit is contained in:
Andrew Bettison 2013-10-08 09:56:54 +10:30
parent 7a8d750a0e
commit 1c96164b62
3 changed files with 4 additions and 4 deletions

View File

@ -152,7 +152,7 @@ int cf_opt_rhizome_peer_from_uri(struct config_rhizome_peer *rpeer, const char *
}
const char *host;
size_t hostlen;
unsigned short port = RHIZOME_HTTP_PORT;
uint16_t port = RHIZOME_HTTP_PORT;
if (!str_uri_authority_hostname(auth, &host, &hostlen))
return CFINVALID;
str_uri_authority_port(auth, &port);

4
str.c
View File

@ -644,7 +644,7 @@ int str_uri_authority_hostname(const char *auth, const char **partp, size_t *len
return 1;
}
int str_uri_authority_port(const char *auth, unsigned short *portp)
int str_uri_authority_port(const char *auth, uint16_t *portp)
{
const char *p;
const char *q = auth;
@ -657,7 +657,7 @@ int str_uri_authority_port(const char *auth, unsigned short *portp)
if (r < p - 1 && *r == ':') {
for (++r; *r == '0'; ++r)
;
int n;
unsigned int n;
if (p - r <= 5 && (n = atoi(r)) <= USHRT_MAX) {
*portp = n;
return 1;

2
str.h
View File

@ -347,7 +347,7 @@ int str_uri_hierarchical_path(const char *hier, const char **partp, size_t *lenp
int str_uri_authority_username(const char *auth, const char **partp, size_t *lenp);
int str_uri_authority_password(const char *auth, const char **partp, size_t *lenp);
int str_uri_authority_hostname(const char *auth, const char **partp, size_t *lenp);
int str_uri_authority_port(const char *auth, unsigned short *portp);
int str_uri_authority_port(const char *auth, uint16_t *portp);
int parse_argv(char *cmdline, char delim, char **argv, int max_argv);