summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@nuclecu.unam.mx>1997-08-06 19:14:48 +0000
committerMiguel de Icaza <miguel@nuclecu.unam.mx>1997-08-06 19:14:48 +0000
commite2819e52a162873ff5061de81bb749831bdb5de9 (patch)
tree6067ea700202750ba335a423696f2972700e5f76 /lib
parent17a005074429bbf143e40401f405ae4363e56828 (diff)
Merge to 2.1.38.
IMPORTANT NOTE: I could not figure out what information is the one that should be used for the following files (ie, those that were in our tree, or those that came from Linus' patch), please, check these: include/asm-mips/jazz.h include/asm-mips/jazzdma.h include/asm-mips/ioctls.h
Diffstat (limited to 'lib')
-rw-r--r--lib/vsprintf.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 8f813c655..b63f5469c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -131,6 +131,9 @@ static char * number(char * str, long num, int base, int size, int precision
return str;
}
+/* Forward decl. needed for IP address printing stuff... */
+int sprintf(char * buf, const char *fmt, ...);
+
int vsprintf(char *buf, const char *fmt, va_list args)
{
int len;
@@ -250,6 +253,41 @@ int vsprintf(char *buf, const char *fmt, va_list args)
}
continue;
+ case 'I': /* IPv4 / IPv6 printout */
+ {
+ __u8 *ip4;
+ char sbuf[6];
+ if (qualifier == 'l') {
+ __u16 *ip6 = va_arg(args, __u16 *);
+ i = 6;
+ for ( ; i > 0; --i, ++ip6)
+ if (*ip6 != 0)
+ break;
+ if (i < 6)
+ *str++ = ':';
+ for ( ; i > 0; --i, ++ip6) {
+ sprintf(sbuf,":%04x",(int)(*ip6));
+ s = sbuf;
+ while (*s)
+ *str++ = *s++;
+ }
+ *str++ = ':';
+ ip4 = (__u8*) ip6;
+ } else {
+ ip4 = va_arg(args, __u8 *);
+ }
+ for (i = 0; i < 4; ++i, ++ip4) {
+ if (i == 3)
+ sprintf(sbuf,"%d", 0xFF & (*ip4));
+ else
+ sprintf(sbuf,"%d.", 0xFF & (*ip4));
+ s = sbuf;
+ while (*s)
+ *str++ = *s++;
+ }
+ }
+ continue;
+
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;