22 const int n = sscanf(buf,
"%d,%d,%d,%d,%d,%d",
23 &h1, &h2, &h3, &h4, &p1, &p2);
25 if (n != 6 || p1 < 0 || p2 < 0 || p1 > 255 || p2 > 255)
31 static char ipBuf[1024];
32 snprintf(ipBuf,
sizeof(ipBuf),
"%d.%d.%d.%d", h1, h2, h3, h4);
39 const int port = ((p1 << 8) + p2);
55 const char delim = *buf;
56 const char *s = buf + 1;
58 const int proto = strtol(s,
const_cast<char**
>(&e), 10);
59 if ((proto != 1 && proto != 2) || *e != delim)
68 if (
static_cast<size_t>(e - s) >=
sizeof(ip))
70 strncpy(ip, s, e - s);
77 if ((proto == 2) != addr.
isIPv6())
81 const int port = strtol(s,
const_cast<char**
>(&e), 10);
82 if (
port < 0 || *e !=
'|')
97 const char *s = quotedPath;
100 bool parseDone =
false;
102 if (
const char *e = strchr(s,
'"')) {
unsigned short port() const
void append(const char *c, int sz) override
char * content()
start of the added data
struct SquidConfig::@92 Ftp
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
const char * UnescapeDoubleQuoted(const char *quotedPath)
parses an FTP-quoted quote-escaped path
bool ParseProtoIpPort(const char *buf, Ip::Address &addr)
bool ParseIpPort(const char *buf, const char *forceIp, Ip::Address &addr)
parses and validates "A1,A2,A3,A4,P1,P2" IP,port sequence