1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/utils/x11_parse_ip.c
Simon Tatham 1b851758bd Add some missing #includes.
My experimental build with clang-cl at -Wall did show up a few things
that are safe enough to fix right now. One was this list of missing
includes, which was causing a lot of -Wmissing-prototype warnings, and
is a real risk because it means the declarations in headers weren't
being type-checked against the actual function definitions.

Happily, no actual mismatches.
2022-09-03 11:59:12 +01:00

22 lines
455 B
C

/*
* Try to make sense of a string as an IPv4 address, for
* XDM-AUTHORIZATION-1 purposes.
*/
#include <stdio.h>
#include "putty.h"
#include "ssh.h"
bool x11_parse_ip(const char *addr_string, unsigned long *ip)
{
int i[4];
if (addr_string &&
4 == sscanf(addr_string, "%d.%d.%d.%d", i+0, i+1, i+2, i+3)) {
*ip = (i[0] << 24) | (i[1] << 16) | (i[2] << 8) | i[3];
return true;
} else {
return false;
}
}