diff options
author | Jeremy Allison <jra@samba.org> | 2013-04-16 12:09:41 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-06-11 10:50:41 -0700 |
commit | 534cf516ed17d90bbd851fd8e190811a055aa5f0 (patch) | |
tree | 2af489bbf6e38ea2a0a9e9322d87085c92dd0d2b /source3/libsmb/libsmb_path.c | |
parent | c0cbf5936f0385ab93315cc366a0aa16c0ebd237 (diff) | |
download | samba-534cf516ed17d90bbd851fd8e190811a055aa5f0.tar.gz samba-534cf516ed17d90bbd851fd8e190811a055aa5f0.tar.bz2 samba-534cf516ed17d90bbd851fd8e190811a055aa5f0.zip |
Add the ability to parse out the port to SMBC_parse_path().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Diffstat (limited to 'source3/libsmb/libsmb_path.c')
-rw-r--r-- | source3/libsmb/libsmb_path.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c index 1dcf2dd516..b286691a21 100644 --- a/source3/libsmb/libsmb_path.c +++ b/source3/libsmb/libsmb_path.c @@ -224,6 +224,7 @@ SMBC_parse_path(TALLOC_CTX *ctx, const char *fname, char **pp_workgroup, char **pp_server, + uint16_t *p_port, char **pp_share, char **pp_path, char **pp_user, @@ -238,6 +239,7 @@ SMBC_parse_path(TALLOC_CTX *ctx, /* Ensure these returns are at least valid pointers. */ *pp_server = talloc_strdup(ctx, ""); + *p_port = 0; *pp_share = talloc_strdup(ctx, ""); *pp_path = talloc_strdup(ctx, ""); *pp_user = talloc_strdup(ctx, ""); @@ -363,6 +365,28 @@ SMBC_parse_path(TALLOC_CTX *ctx, return -1; } + /* + * Does *pp_server contain a ':' ? If so + * this denotes the port. + */ + q = strchr_m(*pp_server, ':'); + if (q != NULL) { + long int port; + char *endptr = NULL; + *q = '\0'; + q++; + if (*q == '\0') { + /* Bad port. */ + return -1; + } + port = strtol(q, &endptr, 10); + if (*endptr != '\0') { + /* Bad port. */ + return -1; + } + *p_port = (uint16_t)port; + } + if (*p == (char)0) { goto decoding; /* That's it ... */ } |