4 * Copyright (C) 1991, 1992 Linus Torvalds
7 /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
9 * Wirzenius wrote this portably, Torvalds fucked it up :-)
13 * Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
14 * - changed to provide snprintf and vsnprintf functions
15 * So Feb 1 16:51:32 CET 2004 Juergen Quade <quade@hsnr.de>
16 * - scnprintf and vscnprintf
20 #include <linux/module.h>
21 #include <linux/types.h>
22 #include <linux/string.h>
23 #include <linux/ctype.h>
24 #include <linux/kernel.h>
25 #include <linux/kallsyms.h>
26 #include <linux/uaccess.h>
28 #include <asm/page.h> /* for PAGE_SIZE */
29 #include <asm/div64.h>
30 #include <asm/sections.h> /* for dereference_function_descriptor() */
32 /* Works only for digits and letters, but small and fast */
33 #define TOLOWER(x) ((x) | 0x20)
36 * simple_strtoul - convert a string to an unsigned long
37 * @cp: The start of the string
38 * @endp: A pointer to the end of the parsed string will be placed here
39 * @base: The number base to use
41 unsigned long simple_strtoul(const char *cp
,char **endp
,unsigned int base
)
43 unsigned long result
= 0,value
;
50 if ((TOLOWER(*cp
) == 'x') && isxdigit(cp
[1])) {
55 } else if (base
== 16) {
56 if (cp
[0] == '0' && TOLOWER(cp
[1]) == 'x')
59 while (isxdigit(*cp
) &&
60 (value
= isdigit(*cp
) ? *cp
-'0' : TOLOWER(*cp
)-'a'+10) < base
) {
61 result
= result
*base
+ value
;
69 EXPORT_SYMBOL(simple_strtoul
);
72 * simple_strtol - convert a string to a signed long
73 * @cp: The start of the string
74 * @endp: A pointer to the end of the parsed string will be placed here
75 * @base: The number base to use
77 long simple_strtol(const char *cp
,char **endp
,unsigned int base
)
80 return -simple_strtoul(cp
+1,endp
,base
);
81 return simple_strtoul(cp
,endp
,base
);
84 EXPORT_SYMBOL(simple_strtol
);
87 * simple_strtoull - convert a string to an unsigned long long
88 * @cp: The start of the string
89 * @endp: A pointer to the end of the parsed string will be placed here
90 * @base: The number base to use
92 unsigned long long simple_strtoull(const char *cp
,char **endp
,unsigned int base
)
94 unsigned long long result
= 0,value
;
101 if ((TOLOWER(*cp
) == 'x') && isxdigit(cp
[1])) {
106 } else if (base
== 16) {
107 if (cp
[0] == '0' && TOLOWER(cp
[1]) == 'x')
111 && (value
= isdigit(*cp
) ? *cp
-'0' : TOLOWER(*cp
)-'a'+10) < base
) {
112 result
= result
*base
+ value
;
120 EXPORT_SYMBOL(simple_strtoull
);
123 * simple_strtoll - convert a string to a signed long long
124 * @cp: The start of the string
125 * @endp: A pointer to the end of the parsed string will be placed here
126 * @base: The number base to use
128 long long simple_strtoll(const char *cp
,char **endp
,unsigned int base
)
131 return -simple_strtoull(cp
+1,endp
,base
);
132 return simple_strtoull(cp
,endp
,base
);
137 * strict_strtoul - convert a string to an unsigned long strictly
138 * @cp: The string to be converted
139 * @base: The number base to use
140 * @res: The converted result value
142 * strict_strtoul converts a string to an unsigned long only if the
143 * string is really an unsigned long string, any string containing
144 * any invalid char at the tail will be rejected and -EINVAL is returned,
145 * only a newline char at the tail is acceptible because people generally
146 * change a module parameter in the following way:
148 * echo 1024 > /sys/module/e1000/parameters/copybreak
150 * echo will append a newline to the tail.
152 * It returns 0 if conversion is successful and *res is set to the converted
153 * value, otherwise it returns -EINVAL and *res is set to 0.
155 * simple_strtoul just ignores the successive invalid characters and
156 * return the converted value of prefix part of the string.
158 int strict_strtoul(const char *cp
, unsigned int base
, unsigned long *res
);
161 * strict_strtol - convert a string to a long strictly
162 * @cp: The string to be converted
163 * @base: The number base to use
164 * @res: The converted result value
166 * strict_strtol is similiar to strict_strtoul, but it allows the first
167 * character of a string is '-'.
169 * It returns 0 if conversion is successful and *res is set to the converted
170 * value, otherwise it returns -EINVAL and *res is set to 0.
172 int strict_strtol(const char *cp
, unsigned int base
, long *res
);
175 * strict_strtoull - convert a string to an unsigned long long strictly
176 * @cp: The string to be converted
177 * @base: The number base to use
178 * @res: The converted result value
180 * strict_strtoull converts a string to an unsigned long long only if the
181 * string is really an unsigned long long string, any string containing
182 * any invalid char at the tail will be rejected and -EINVAL is returned,
183 * only a newline char at the tail is acceptible because people generally
184 * change a module parameter in the following way:
186 * echo 1024 > /sys/module/e1000/parameters/copybreak
188 * echo will append a newline to the tail of the string.
190 * It returns 0 if conversion is successful and *res is set to the converted
191 * value, otherwise it returns -EINVAL and *res is set to 0.
193 * simple_strtoull just ignores the successive invalid characters and
194 * return the converted value of prefix part of the string.
196 int strict_strtoull(const char *cp
, unsigned int base
, unsigned long long *res
);
199 * strict_strtoll - convert a string to a long long strictly
200 * @cp: The string to be converted
201 * @base: The number base to use
202 * @res: The converted result value
204 * strict_strtoll is similiar to strict_strtoull, but it allows the first
205 * character of a string is '-'.
207 * It returns 0 if conversion is successful and *res is set to the converted
208 * value, otherwise it returns -EINVAL and *res is set to 0.
210 int strict_strtoll(const char *cp
, unsigned int base
, long long *res
);
212 #define define_strict_strtoux(type, valtype) \
213 int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\
224 val = simple_strtou##type(cp, &tail, base); \
225 if ((*tail == '\0') || \
226 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\
234 #define define_strict_strtox(type, valtype) \
235 int strict_strto##type(const char *cp, unsigned int base, valtype *res) \
239 ret = strict_strtou##type(cp+1, base, res); \
243 ret = strict_strtou##type(cp, base, res); \
248 define_strict_strtoux(l, unsigned long)
249 define_strict_strtox(l
, long)
250 define_strict_strtoux(ll
, unsigned long long)
251 define_strict_strtox(ll
, long long)
253 EXPORT_SYMBOL(strict_strtoul
);
254 EXPORT_SYMBOL(strict_strtol
);
255 EXPORT_SYMBOL(strict_strtoll
);
256 EXPORT_SYMBOL(strict_strtoull
);
258 static int skip_atoi(const char **s
)
263 i
= i
*10 + *((*s
)++) - '0';
267 /* Decimal conversion is by far the most typical, and is used
268 * for /proc and /sys data. This directly impacts e.g. top performance
269 * with many processes running. We optimize it for speed
271 * http://www.cs.uiowa.edu/~jones/bcd/decimal.html
272 * (with permission from the author, Douglas W. Jones). */
274 /* Formats correctly any integer in [0,99999].
275 * Outputs from one to five digits depending on input.
276 * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */
277 static char* put_dec_trunc(char *buf
, unsigned q
)
279 unsigned d3
, d2
, d1
, d0
;
284 d0
= 6*(d3
+ d2
+ d1
) + (q
& 0xf);
285 q
= (d0
* 0xcd) >> 11;
287 *buf
++ = d0
+ '0'; /* least significant digit */
288 d1
= q
+ 9*d3
+ 5*d2
+ d1
;
290 q
= (d1
* 0xcd) >> 11;
292 *buf
++ = d1
+ '0'; /* next digit */
295 if ((d2
!= 0) || (d3
!= 0)) {
298 *buf
++ = d2
+ '0'; /* next digit */
302 q
= (d3
* 0xcd) >> 11;
304 *buf
++ = d3
+ '0'; /* next digit */
306 *buf
++ = q
+ '0'; /* most sign. digit */
312 /* Same with if's removed. Always emits five digits */
313 static char* put_dec_full(char *buf
, unsigned q
)
315 /* BTW, if q is in [0,9999], 8-bit ints will be enough, */
316 /* but anyway, gcc produces better code with full-sized ints */
317 unsigned d3
, d2
, d1
, d0
;
322 /* Possible ways to approx. divide by 10 */
323 /* gcc -O2 replaces multiply with shifts and adds */
324 // (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386)
325 // (x * 0x67) >> 10: 1100111
326 // (x * 0x34) >> 9: 110100 - same
327 // (x * 0x1a) >> 8: 11010 - same
328 // (x * 0x0d) >> 7: 1101 - same, shortest code (on i386)
330 d0
= 6*(d3
+ d2
+ d1
) + (q
& 0xf);
331 q
= (d0
* 0xcd) >> 11;
334 d1
= q
+ 9*d3
+ 5*d2
+ d1
;
335 q
= (d1
* 0xcd) >> 11;
345 q
= (d3
* 0xcd) >> 11; /* - shorter code */
346 /* q = (d3 * 0x67) >> 10; - would also work */
352 /* No inlining helps gcc to use registers better */
353 static noinline
char* put_dec(char *buf
, unsigned long long num
)
358 return put_dec_trunc(buf
, num
);
359 rem
= do_div(num
, 100000);
360 buf
= put_dec_full(buf
, rem
);
364 #define ZEROPAD 1 /* pad with zero */
365 #define SIGN 2 /* unsigned/signed long */
366 #define PLUS 4 /* show plus */
367 #define SPACE 8 /* space if plus */
368 #define LEFT 16 /* left justified */
369 #define SMALL 32 /* Must be 32 == 0x20 */
370 #define SPECIAL 64 /* 0x */
372 static char *number(char *buf
, char *end
, unsigned long long num
, int base
, int size
, int precision
, int type
)
374 /* we are called with base 8, 10 or 16, only, thus don't need "G..." */
375 static const char digits
[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
380 int need_pfx
= ((type
& SPECIAL
) && base
!= 10);
383 /* locase = 0 or 0x20. ORing digits or letters with 'locase'
384 * produces same digits or (maybe lowercased) letters */
385 locase
= (type
& SMALL
);
390 if ((signed long long) num
< 0) {
392 num
= - (signed long long) num
;
394 } else if (type
& PLUS
) {
397 } else if (type
& SPACE
) {
408 /* generate full string in tmp[], in reverse order */
412 /* Generic code, for any base:
414 tmp[i++] = (digits[do_div(num,base)] | locase);
417 else if (base
!= 10) { /* 8 or 16 */
420 if (base
== 16) shift
= 4;
422 tmp
[i
++] = (digits
[((unsigned char)num
) & mask
] | locase
);
425 } else { /* base 10 */
426 i
= put_dec(tmp
, num
) - tmp
;
429 /* printing 100 using %2d gives "100", not "00" */
432 /* leading space padding */
434 if (!(type
& (ZEROPAD
+LEFT
))) {
447 /* "0x" / "0" prefix */
454 *buf
= ('X' | locase
);
458 /* zero or space padding */
459 if (!(type
& LEFT
)) {
460 char c
= (type
& ZEROPAD
) ? '0' : ' ';
461 while (--size
>= 0) {
467 /* hmm even more zero padding? */
468 while (i
<= --precision
) {
473 /* actual digits of result */
479 /* trailing space padding */
480 while (--size
>= 0) {
488 static char *string(char *buf
, char *end
, char *s
, int field_width
, int precision
, int flags
)
492 if ((unsigned long)s
< PAGE_SIZE
)
495 len
= strnlen(s
, precision
);
497 if (!(flags
& LEFT
)) {
498 while (len
< field_width
--) {
504 for (i
= 0; i
< len
; ++i
) {
509 while (len
< field_width
--) {
517 static char *symbol_string(char *buf
, char *end
, void *ptr
, int field_width
, int precision
, int flags
)
519 unsigned long value
= (unsigned long) ptr
;
520 #ifdef CONFIG_KALLSYMS
521 char sym
[KSYM_SYMBOL_LEN
];
522 sprint_symbol(sym
, value
);
523 return string(buf
, end
, sym
, field_width
, precision
, flags
);
525 field_width
= 2*sizeof(void *);
526 flags
|= SPECIAL
| SMALL
| ZEROPAD
;
527 return number(buf
, end
, value
, 16, field_width
, precision
, flags
);
532 * Show a '%p' thing. A kernel extension is that the '%p' is followed
533 * by an extra set of alphanumeric characters that are extended format
536 * Right now we just handle 'F' (for symbolic Function descriptor pointers)
537 * and 'S' (for Symbolic direct pointers), but this can easily be
538 * extended in the future (network address types etc).
540 * The difference between 'S' and 'F' is that on ia64 and ppc64 function
541 * pointers are really function descriptors, which contain a pointer the
544 static char *pointer(const char *fmt
, char *buf
, char *end
, void *ptr
, int field_width
, int precision
, int flags
)
548 ptr
= dereference_function_descriptor(ptr
);
551 return symbol_string(buf
, end
, ptr
, field_width
, precision
, flags
);
554 if (field_width
== -1) {
555 field_width
= 2*sizeof(void *);
558 return number(buf
, end
, (unsigned long) ptr
, 16, field_width
, precision
, flags
);
562 * vsnprintf - Format a string and place it in a buffer
563 * @buf: The buffer to place the result into
564 * @size: The size of the buffer, including the trailing null space
565 * @fmt: The format string to use
566 * @args: Arguments for the format string
568 * This function follows C99 vsnprintf, but has some extensions:
569 * %pS output the name of a text symbol
570 * %pF output the name of a function pointer
572 * The return value is the number of characters which would
573 * be generated for the given input, excluding the trailing
574 * '\0', as per ISO C99. If you want to have the exact
575 * number of characters written into @buf as return value
576 * (not including the trailing '\0'), use vscnprintf(). If the
577 * return is greater than or equal to @size, the resulting
578 * string is truncated.
580 * Call this function if you are already dealing with a va_list.
581 * You probably want snprintf() instead.
583 int vsnprintf(char *buf
, size_t size
, const char *fmt
, va_list args
)
585 unsigned long long num
;
589 int flags
; /* flags to number() */
591 int field_width
; /* width of output field */
592 int precision
; /* min. # of digits for integers; max
593 number of chars for from string */
594 int qualifier
; /* 'h', 'l', or 'L' for integer fields */
595 /* 'z' support added 23/7/1999 S.H. */
596 /* 'z' changed to 'Z' --davidm 1/25/99 */
597 /* 't' added for ptrdiff_t */
599 /* Reject out-of-range values early. Large positive sizes are
600 used for unknown buffer sizes. */
601 if (unlikely((int) size
< 0)) {
602 /* There can be only one.. */
603 static char warn
= 1;
612 /* Make sure end is always >= buf */
618 for (; *fmt
; ++fmt
) {
629 ++fmt
; /* this also skips first '%' */
631 case '-': flags
|= LEFT
; goto repeat
;
632 case '+': flags
|= PLUS
; goto repeat
;
633 case ' ': flags
|= SPACE
; goto repeat
;
634 case '#': flags
|= SPECIAL
; goto repeat
;
635 case '0': flags
|= ZEROPAD
; goto repeat
;
638 /* get field width */
641 field_width
= skip_atoi(&fmt
);
642 else if (*fmt
== '*') {
644 /* it's the next argument */
645 field_width
= va_arg(args
, int);
646 if (field_width
< 0) {
647 field_width
= -field_width
;
652 /* get the precision */
657 precision
= skip_atoi(&fmt
);
658 else if (*fmt
== '*') {
660 /* it's the next argument */
661 precision
= va_arg(args
, int);
667 /* get the conversion qualifier */
669 if (*fmt
== 'h' || *fmt
== 'l' || *fmt
== 'L' ||
670 *fmt
=='Z' || *fmt
== 'z' || *fmt
== 't') {
673 if (qualifier
== 'l' && *fmt
== 'l') {
684 if (!(flags
& LEFT
)) {
685 while (--field_width
> 0) {
691 c
= (unsigned char) va_arg(args
, int);
695 while (--field_width
> 0) {
703 str
= string(str
, end
, va_arg(args
, char *), field_width
, precision
, flags
);
707 str
= pointer(fmt
+1, str
, end
,
708 va_arg(args
, void *),
709 field_width
, precision
, flags
);
710 /* Skip all alphanumeric pointer suffixes */
711 while (isalnum(fmt
[1]))
717 * What does C99 say about the overflow case here? */
718 if (qualifier
== 'l') {
719 long * ip
= va_arg(args
, long *);
721 } else if (qualifier
== 'Z' || qualifier
== 'z') {
722 size_t * ip
= va_arg(args
, size_t *);
725 int * ip
= va_arg(args
, int *);
736 /* integer number formats - set up the flags and "break" */
766 if (qualifier
== 'L')
767 num
= va_arg(args
, long long);
768 else if (qualifier
== 'l') {
769 num
= va_arg(args
, unsigned long);
771 num
= (signed long) num
;
772 } else if (qualifier
== 'Z' || qualifier
== 'z') {
773 num
= va_arg(args
, size_t);
774 } else if (qualifier
== 't') {
775 num
= va_arg(args
, ptrdiff_t);
776 } else if (qualifier
== 'h') {
777 num
= (unsigned short) va_arg(args
, int);
779 num
= (signed short) num
;
781 num
= va_arg(args
, unsigned int);
783 num
= (signed int) num
;
785 str
= number(str
, end
, num
, base
,
786 field_width
, precision
, flags
);
794 /* the trailing null byte doesn't count towards the total */
798 EXPORT_SYMBOL(vsnprintf
);
801 * vscnprintf - Format a string and place it in a buffer
802 * @buf: The buffer to place the result into
803 * @size: The size of the buffer, including the trailing null space
804 * @fmt: The format string to use
805 * @args: Arguments for the format string
807 * The return value is the number of characters which have been written into
808 * the @buf not including the trailing '\0'. If @size is <= 0 the function
811 * Call this function if you are already dealing with a va_list.
812 * You probably want scnprintf() instead.
814 * See the vsnprintf() documentation for format string extensions over C99.
816 int vscnprintf(char *buf
, size_t size
, const char *fmt
, va_list args
)
820 i
=vsnprintf(buf
,size
,fmt
,args
);
821 return (i
>= size
) ? (size
- 1) : i
;
824 EXPORT_SYMBOL(vscnprintf
);
827 * snprintf - Format a string and place it in a buffer
828 * @buf: The buffer to place the result into
829 * @size: The size of the buffer, including the trailing null space
830 * @fmt: The format string to use
831 * @...: Arguments for the format string
833 * The return value is the number of characters which would be
834 * generated for the given input, excluding the trailing null,
835 * as per ISO C99. If the return is greater than or equal to
836 * @size, the resulting string is truncated.
838 * See the vsnprintf() documentation for format string extensions over C99.
840 int snprintf(char * buf
, size_t size
, const char *fmt
, ...)
846 i
=vsnprintf(buf
,size
,fmt
,args
);
851 EXPORT_SYMBOL(snprintf
);
854 * scnprintf - Format a string and place it in a buffer
855 * @buf: The buffer to place the result into
856 * @size: The size of the buffer, including the trailing null space
857 * @fmt: The format string to use
858 * @...: Arguments for the format string
860 * The return value is the number of characters written into @buf not including
861 * the trailing '\0'. If @size is <= 0 the function returns 0.
864 int scnprintf(char * buf
, size_t size
, const char *fmt
, ...)
870 i
= vsnprintf(buf
, size
, fmt
, args
);
872 return (i
>= size
) ? (size
- 1) : i
;
874 EXPORT_SYMBOL(scnprintf
);
877 * vsprintf - Format a string and place it in a buffer
878 * @buf: The buffer to place the result into
879 * @fmt: The format string to use
880 * @args: Arguments for the format string
882 * The function returns the number of characters written
883 * into @buf. Use vsnprintf() or vscnprintf() in order to avoid
886 * Call this function if you are already dealing with a va_list.
887 * You probably want sprintf() instead.
889 * See the vsnprintf() documentation for format string extensions over C99.
891 int vsprintf(char *buf
, const char *fmt
, va_list args
)
893 return vsnprintf(buf
, INT_MAX
, fmt
, args
);
896 EXPORT_SYMBOL(vsprintf
);
899 * sprintf - Format a string and place it in a buffer
900 * @buf: The buffer to place the result into
901 * @fmt: The format string to use
902 * @...: Arguments for the format string
904 * The function returns the number of characters written
905 * into @buf. Use snprintf() or scnprintf() in order to avoid
908 * See the vsnprintf() documentation for format string extensions over C99.
910 int sprintf(char * buf
, const char *fmt
, ...)
916 i
=vsnprintf(buf
, INT_MAX
, fmt
, args
);
921 EXPORT_SYMBOL(sprintf
);
924 * vsscanf - Unformat a buffer into a list of arguments
926 * @fmt: format of buffer
929 int vsscanf(const char * buf
, const char * fmt
, va_list args
)
931 const char *str
= buf
;
940 while(*fmt
&& *str
) {
941 /* skip any white space in format */
942 /* white space in format matchs any amount of
943 * white space, including none, in the input.
946 while (isspace(*fmt
))
948 while (isspace(*str
))
952 /* anything that is not a conversion must match exactly */
953 if (*fmt
!= '%' && *fmt
) {
954 if (*fmt
++ != *str
++)
963 /* skip this conversion.
964 * advance both strings to next white space
967 while (!isspace(*fmt
) && *fmt
)
969 while (!isspace(*str
) && *str
)
974 /* get field width */
977 field_width
= skip_atoi(&fmt
);
979 /* get conversion qualifier */
981 if (*fmt
== 'h' || *fmt
== 'l' || *fmt
== 'L' ||
982 *fmt
== 'Z' || *fmt
== 'z') {
984 if (unlikely(qualifier
== *fmt
)) {
985 if (qualifier
== 'h') {
988 } else if (qualifier
== 'l') {
1003 char *s
= (char *) va_arg(args
,char*);
1004 if (field_width
== -1)
1008 } while (--field_width
> 0 && *str
);
1014 char *s
= (char *) va_arg(args
, char *);
1015 if(field_width
== -1)
1016 field_width
= INT_MAX
;
1017 /* first, skip leading white space in buffer */
1018 while (isspace(*str
))
1021 /* now copy until next white space */
1022 while (*str
&& !isspace(*str
) && field_width
--) {
1030 /* return number of characters read so far */
1032 int *i
= (int *)va_arg(args
,int*);
1050 /* looking for '%' in str */
1055 /* invalid format; stop here */
1059 /* have some sort of integer conversion.
1060 * first, skip white space in buffer.
1062 while (isspace(*str
))
1066 if (is_sign
&& digit
== '-')
1070 || (base
== 16 && !isxdigit(digit
))
1071 || (base
== 10 && !isdigit(digit
))
1072 || (base
== 8 && (!isdigit(digit
) || digit
> '7'))
1073 || (base
== 0 && !isdigit(digit
)))
1077 case 'H': /* that's 'hh' in format */
1079 signed char *s
= (signed char *) va_arg(args
,signed char *);
1080 *s
= (signed char) simple_strtol(str
,&next
,base
);
1082 unsigned char *s
= (unsigned char *) va_arg(args
, unsigned char *);
1083 *s
= (unsigned char) simple_strtoul(str
, &next
, base
);
1088 short *s
= (short *) va_arg(args
,short *);
1089 *s
= (short) simple_strtol(str
,&next
,base
);
1091 unsigned short *s
= (unsigned short *) va_arg(args
, unsigned short *);
1092 *s
= (unsigned short) simple_strtoul(str
, &next
, base
);
1097 long *l
= (long *) va_arg(args
,long *);
1098 *l
= simple_strtol(str
,&next
,base
);
1100 unsigned long *l
= (unsigned long*) va_arg(args
,unsigned long*);
1101 *l
= simple_strtoul(str
,&next
,base
);
1106 long long *l
= (long long*) va_arg(args
,long long *);
1107 *l
= simple_strtoll(str
,&next
,base
);
1109 unsigned long long *l
= (unsigned long long*) va_arg(args
,unsigned long long*);
1110 *l
= simple_strtoull(str
,&next
,base
);
1116 size_t *s
= (size_t*) va_arg(args
,size_t*);
1117 *s
= (size_t) simple_strtoul(str
,&next
,base
);
1122 int *i
= (int *) va_arg(args
, int*);
1123 *i
= (int) simple_strtol(str
,&next
,base
);
1125 unsigned int *i
= (unsigned int*) va_arg(args
, unsigned int*);
1126 *i
= (unsigned int) simple_strtoul(str
,&next
,base
);
1138 * Now we've come all the way through so either the input string or the
1139 * format ended. In the former case, there can be a %n at the current
1140 * position in the format that needs to be filled.
1142 if (*fmt
== '%' && *(fmt
+ 1) == 'n') {
1143 int *p
= (int *)va_arg(args
, int *);
1150 EXPORT_SYMBOL(vsscanf
);
1153 * sscanf - Unformat a buffer into a list of arguments
1154 * @buf: input buffer
1155 * @fmt: formatting of buffer
1156 * @...: resulting arguments
1158 int sscanf(const char * buf
, const char * fmt
, ...)
1164 i
= vsscanf(buf
,fmt
,args
);
1169 EXPORT_SYMBOL(sscanf
);