mirror of
https://github.com/samba-team/samba.git
synced 2025-11-13 08:23:49 +03:00
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>
This commit is contained in:
@@ -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 ... */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user