]>
git.saurik.com Git - apple/icu.git/blob - icuSources/io/sscanf.c
2 ******************************************************************************
4 * Copyright (C) 2000-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 02/08/00 george Creation. Copied from uscanf.c
15 ******************************************************************************
18 #include "unicode/utypes.h"
20 #if !UCONFIG_NO_FORMATTING
22 #include "unicode/putil.h"
23 #include "unicode/ustdio.h"
24 #include "unicode/ustring.h"
33 U_CAPI
int32_t U_EXPORT2
34 u_sscanf(const UChar
*buffer
,
35 const char *patternSpecification
,
41 va_start(ap
, patternSpecification
);
42 converted
= u_vsscanf(buffer
, patternSpecification
, ap
);
48 U_CAPI
int32_t U_EXPORT2
49 u_sscanf_u(const UChar
*buffer
,
50 const UChar
*patternSpecification
,
56 va_start(ap
, patternSpecification
);
57 converted
= u_vsscanf_u(buffer
, patternSpecification
, ap
);
63 U_CAPI
int32_t U_EXPORT2
/* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
64 u_vsscanf(const UChar
*buffer
,
65 const char *patternSpecification
,
70 UChar patBuffer
[UFMT_DEFAULT_BUFFER_SIZE
];
71 int32_t size
= (int32_t)uprv_strlen(patternSpecification
) + 1;
73 /* convert from the default codepage to Unicode */
74 if (size
>= MAX_UCHAR_BUFFER_SIZE(patBuffer
)) {
75 pattern
= (UChar
*)uprv_malloc(size
* sizeof(UChar
));
83 u_charsToUChars(patternSpecification
, pattern
, size
);
86 converted
= u_vsscanf_u(buffer
, pattern
, ap
);
89 if (pattern
!= patBuffer
) {
96 U_CAPI
int32_t U_EXPORT2
/* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
97 u_vsscanf_u(const UChar
*buffer
,
98 const UChar
*patternSpecification
,
104 inStr
.fConverter
= NULL
;
106 inStr
.fOwnFile
= FALSE
;
107 #if !UCONFIG_NO_TRANSLITERATION
108 inStr
.fTranslit
= NULL
;
110 inStr
.fUCBuffer
[0] = 0;
111 inStr
.str
.fBuffer
= (UChar
*)buffer
;
112 inStr
.str
.fPos
= (UChar
*)buffer
;
113 inStr
.str
.fLimit
= buffer
+ u_strlen(buffer
);
115 if(u_locbund_init(&inStr
.str
.fBundle
, "en_US_POSIX") == 0) {
119 converted
= u_scanf_parse(&inStr
, patternSpecification
, ap
);
121 u_locbund_close(&inStr
.str
.fBundle
);
123 /* return # of items converted */
127 #endif /* #if !UCONFIG_NO_FORMATTING */