-/*
+/*
Unix SMB/Netbios implementation.
SMB client library implementation
Copyright (C) Andrew Tridgell 1998
Copyright (C) Richard Sharpe 2000, 2002
Copyright (C) John Terpstra 2000
- Copyright (C) Tom Jansen (Ninja ISD) 2002
+ Copyright (C) Tom Jansen (Ninja ISD) 2002
Copyright (C) Derrell Lipman 2003-2008
Copyright (C) Jeremy Allison 2007, 2008
/* Used by urldecode_talloc() */
-static int
+static int
hex2int( unsigned int _char )
{
if ( _char >= 'A' && _char <='F')
newlen++;
}
- dest = TALLOC_ARRAY(ctx, char, newlen);
+ dest = talloc_array(ctx, char, newlen);
if (!dest) {
return err_count;
}
*
*
* We accept:
- * smb://[[[domain;]user[:password]@]server[/share[/path[/file]]]][?options]
+ * smb://[[[domain;]user[:password]@]server[:port][/share[/path[/file]]]]
+ * [?options]
*
* Meaning of URLs:
*
const char *fname,
char **pp_workgroup,
char **pp_server,
+ uint16_t *p_port,
char **pp_share,
char **pp_path,
char **pp_user,
/* Ensure these returns are at least valid pointers. */
*pp_server = talloc_strdup(ctx, "");
+ *p_port = smbc_getPort(context);
*pp_share = talloc_strdup(ctx, "");
*pp_path = talloc_strdup(ctx, "");
*pp_user = talloc_strdup(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 ... */
}