version 1.44, 1999/04/13 20:17:48 |
version 1.45, 1999/06/18 23:26:40 |
Line 56 int network_up = 0; |
|
Line 56 int network_up = 0; |
|
/* URL encode unsafe characters. */ |
/* URL encode unsafe characters. */ |
|
|
static char *url_encode __P((char *dst, const char *src, size_t len, |
static char *url_encode __P((char *dst, const char *src, size_t len, |
const char *safe_chars)); |
const char *safe_chars, |
|
int encode_leading_slash)); |
|
|
/* Get the list of network interfaces. */ |
/* Get the list of network interfaces. */ |
|
|
Line 74 static void get_ifinterface_info __P((vo |
|
Line 75 static void get_ifinterface_info __P((vo |
|
* len is the length of the destination buffer. The result will be |
* len is the length of the destination buffer. The result will be |
* truncated if necessary to fit in the destination buffer. |
* truncated if necessary to fit in the destination buffer. |
* |
* |
* safe_chars is a string of characters that should not be encoded. Any |
* safe_chars is a string of characters that should not be encoded. If |
* characters in this string, as well as any alphanumeric characters, |
* safe_chars is non-NULL, any characters in safe_chars as well as any |
* will be copied from src to dst without encoding. Some potentially |
* alphanumeric characters will be copied from src to dst without |
* useful settings for this parameter are: |
* encoding. Some potentially useful settings for this parameter are: |
* |
* |
* NULL or "" Everything except alphanumerics are encoded |
* NULL Everything is encoded (even alphanumerics) |
|
* "" Everything except alphanumerics are encoded |
* "/" Alphanumerics and '/' remain unencoded |
* "/" Alphanumerics and '/' remain unencoded |
* "$-_.+!*'()," Consistent with a strict reading of RFC 1738 |
* "$-_.+!*'()," Consistent with a strict reading of RFC 1738 |
* "$-_.+!*'(),/" As above, except '/' is not encoded |
* "$-_.+!*'(),/" As above, except '/' is not encoded |
Line 109 static void get_ifinterface_info __P((vo |
|
Line 111 static void get_ifinterface_info __P((vo |
|
|
|
static char * |
static char * |
url_encode(char *dst, const char *src, size_t len, |
url_encode(char *dst, const char *src, size_t len, |
const char *safe_chars) |
const char *safe_chars, int encode_leading_slash) |
{ |
{ |
char *p = dst; |
char *p = dst; |
|
const char *initialsrc = src; |
|
|
if (safe_chars == NULL) |
|
safe_chars = ""; |
|
/* Remove any initial '/'s if present */ |
/* Remove any initial '/'s if present */ |
while (*src == '/') |
while (*src == '/') |
src++; |
src++; |
|
|
|
/* |
|
* If encoding of a leading slash was desired, and there was in |
|
* fact one or more leading shashes, encode one in the output string. |
|
*/ |
|
if (encode_leading_slash && (src != initialsrc)) { |
|
if (len < 3) |
|
goto done; |
|
sprintf(p, "%%%02X", '/'); |
|
p += 3; |
|
} |
|
|
while (--len > 0 && *src != '\0') { |
while (--len > 0 && *src != '\0') { |
if (isalnum(*src) || strchr(safe_chars, *src)) { |
if (safe_chars != NULL && |
|
(isalnum(*src) || strchr(safe_chars, *src))) { |
*p++ = *src++; |
*p++ = *src++; |
} else { |
} else { |
/* encode this char */ |
/* encode this char */ |
Line 130 url_encode(char *dst, const char *src, s |
|
Line 144 url_encode(char *dst, const char *src, s |
|
len -= 2; |
len -= 2; |
} |
} |
} |
} |
|
done: |
*p = '\0'; |
*p = '\0'; |
return dst; |
return dst; |
} |
} |
|
|
"/usr/bin/ftp -a ftp://%s/%s/%s", |
"/usr/bin/ftp -a ftp://%s/%s/%s", |
ftp_host, |
ftp_host, |
url_encode(ftp_dir_encoded, ftp_dir, STRSIZE, |
url_encode(ftp_dir_encoded, ftp_dir, STRSIZE, |
RFC1738_SAFE_LESS_SHELL_PLUS_SLASH), |
RFC1738_SAFE_LESS_SHELL_PLUS_SLASH, 1), |
filename); |
filename); |
else { |
else { |
ret = run_prog(0, 1, NULL, |
ret = run_prog(0, 1, NULL, |
"/usr/bin/ftp ftp://%s:%s@%s/%s/%s", |
"/usr/bin/ftp ftp://%s:%s@%s/%s/%s", |
url_encode(ftp_user_encoded, ftp_user, STRSIZE, |
url_encode(ftp_user_encoded, ftp_user, STRSIZE, |
RFC1738_SAFE_LESS_SHELL), |
RFC1738_SAFE_LESS_SHELL, 0), |
url_encode(ftp_pass_encoded, ftp_pass, STRSIZE, |
url_encode(ftp_pass_encoded, ftp_pass, STRSIZE, |
RFC1738_SAFE_LESS_SHELL), |
NULL, 0), |
ftp_host, |
ftp_host, |
url_encode(ftp_dir_encoded, ftp_dir, STRSIZE, |
url_encode(ftp_dir_encoded, ftp_dir, STRSIZE, |
RFC1738_SAFE_LESS_SHELL_PLUS_SLASH), |
RFC1738_SAFE_LESS_SHELL_PLUS_SLASH, 1), |
filename); |
filename); |
} |
} |
if (ret) { |
if (ret) { |