@ -1,9 +1,15 @@ | |||
#ifndef IP4_H | |||
#define IP4_H | |||
extern unsigned int ip4_scan(const char *src,char *ip); | |||
extern unsigned int ip4_fmt(char *dest,const char *ip); | |||
extern unsigned int scan_ip4(const char *src,char *ip); | |||
extern unsigned int fmt_ip4(char *dest,const char *ip); | |||
/* for djb backwards compatibility */ | |||
#define ip4_scan scan_ip4 | |||
#define ip4_fmt fmt_ip4 | |||
#define IP4_FMT 20 | |||
extern const char ip4loopback[4]; /* = {127,0,0,1};*/ | |||
#endif |
@ -0,0 +1,27 @@ | |||
.TH fmt_ip4 3 | |||
.SH NAME | |||
fmt_ip4 \- write a formatted ASCII representation of an IPv4 number | |||
.SH SYNTAX | |||
.B #include <ip4.h> | |||
unsigned int \fBfmt_ip4\fP(char *\fIdest\fR,const char \fIip\fR[4]); | |||
.SH DESCRIPTION | |||
fmt_ip4 formats an IPv4 number in dotted-decimal ASCII representation | |||
from \fIip\fR and writes the result into \fIdest\fR. It returns the | |||
number of bytes written. | |||
If \fIdest\fR equals FMT_LEN (i.e. is zero), fmt_ip4 returns the number | |||
of bytes it would have written. | |||
fmt_ip4 does not append \\0. | |||
For convenience, ip4.h defines the integer IP4_FMT to be big enough to | |||
contain every possible fmt_ip4 output plus \\0. | |||
.SH EXAMPLE | |||
#include <ip4.h> | |||
char buf[IP4_FMT]; | |||
char ip[4]; | |||
buf[fmt_ip4(buf,ip)]=0; | |||
.SH "SEE ALSO" | |||
scan_ip4(3), ip6_fmt(3) |
@ -0,0 +1,32 @@ | |||
.TH fmt_ip6 3 | |||
.SH NAME | |||
fmt_ip6 \- write a formatted ASCII representation of an IPv6 number | |||
.SH SYNTAX | |||
.B #include <ip6.h> | |||
unsigned int \fBfmt_ip6\fP(char *\fIdest\fR,const char \fIip\fR[16]); | |||
.SH DESCRIPTION | |||
fmt_ip6 formats an IPv6 number in ASCII representation from \fIip\fR and | |||
writes the result into \fIdest\fR. It returns the number of bytes | |||
written. | |||
fmt_ip6 will apply "::" compression to the output. | |||
If \fIip\fR is an IPv4-mapped IPv6 address, fmt_ip6 will output the last | |||
4 bytes as IPv4 number in dotted-decimal notation. | |||
If \fIdest\fR equals FMT_LEN (i.e. is zero), fmt_ip6 returns the number | |||
of bytes it would have written. | |||
fmt_ip6 does not append \\0. | |||
For convenience, ip6.h defines the integer IP6_FMT to be big enough to | |||
contain every possible fmt_ip6 output plus \\0. | |||
.SH EXAMPLE | |||
#include <ip6.h> | |||
char buf[IP6_FMT]; | |||
char ip[16]; | |||
buf[fmt_ip6(buf,ip)]=0; | |||
.SH "SEE ALSO" | |||
scan_ip6(3), ip4_fmt(3) |
@ -1,27 +0,0 @@ | |||
.TH ip4_fmt 3 | |||
.SH NAME | |||
ip4_fmt \- write a formatted ASCII representation of an IPv4 number | |||
.SH SYNTAX | |||
.B #include <ip4.h> | |||
unsigned int \fBip4_fmt\fP(char *\fIdest\fR,const char \fIip\fR[4]); | |||
.SH DESCRIPTION | |||
ip4_fmt formats an IPv4 number in dotted-decimal ASCII representation | |||
from \fIip\fR and writes the result into \fIdest\fR. It returns the | |||
number of bytes written. | |||
If \fIdest\fR equals FMT_LEN (i.e. is zero), ip4_fmt returns the number | |||
of bytes it would have written. | |||
ip4_fmt does not append \\0. | |||
For convenience, ip4.h defines the integer IP4_FMT to be big enough to | |||
contain every possible ip4_fmt output plus \\0. | |||
.SH EXAMPLE | |||
#include <ip4.h> | |||
char buf[IP4_FMT]; | |||
char ip[4]; | |||
buf[ip4_fmt(buf,ip)]=0; | |||
.SH "SEE ALSO" | |||
ip4_scan(3), ip6_fmt(3) |
@ -1,32 +0,0 @@ | |||
.TH ip6_fmt 3 | |||
.SH NAME | |||
ip6_fmt \- write a formatted ASCII representation of an IPv6 number | |||
.SH SYNTAX | |||
.B #include <ip6.h> | |||
unsigned int \fBip6_fmt\fP(char *\fIdest\fR,const char \fIip\fR[16]); | |||
.SH DESCRIPTION | |||
ip6_fmt formats an IPv6 number in ASCII representation from \fIip\fR and | |||
writes the result into \fIdest\fR. It returns the number of bytes | |||
written. | |||
ip6_fmt will apply "::" compression to the output. | |||
If \fIip\fR is an IPv4-mapped IPv6 address, ip6_fmt will output the last | |||
4 bytes as IPv4 number in dotted-decimal notation. | |||
If \fIdest\fR equals FMT_LEN (i.e. is zero), ip6_fmt returns the number | |||
of bytes it would have written. | |||
ip6_fmt does not append \\0. | |||
For convenience, ip6.h defines the integer IP6_FMT to be big enough to | |||
contain every possible ip6_fmt output plus \\0. | |||
.SH EXAMPLE | |||
#include <ip6.h> | |||
char buf[IP6_FMT]; | |||
char ip[16]; | |||
buf[ip6_fmt(buf,ip)]=0; | |||
.SH "SEE ALSO" | |||
ip6_scan(3), ip4_fmt(3) |