|
1 /** @file ../include/wchar.h |
|
2 @internalComponent |
|
3 */ |
|
4 |
|
5 /** @fn btowc(int c) |
|
6 @param c |
|
7 |
|
8 Note: This description also covers the following functions - |
|
9 wctob() |
|
10 |
|
11 @return The btowc function returns the wide character converted from the single |
|
12 byte c . If c is EOF or not a valid multibyte sequence of length 1 the function |
|
13 returns WEOF. |
|
14 |
|
15 The btowc function converts a single-byte character into a corresponding |
|
16 wide character. If the character is EOF , or not valid in the initial shift state, btowc returns WEOF. |
|
17 |
|
18 The wctob function converts a wide character into a corresponding single-byte |
|
19 character. If the wide character is WEOF , or not able to be represented as a single byte in the initial |
|
20 shift state, wctob returns WEOF. |
|
21 |
|
22 |
|
23 |
|
24 Examples: |
|
25 @code |
|
26 #include <wchar.h> |
|
27 // Illustrates how to use btowc API |
|
28 wint_t example_btowc(int c) |
|
29 { |
|
30 wint_t wc = L'a'; |
|
31 // converting single byte to wide-character |
|
32 wc = btowc(c); |
|
33 // return the character that was converted |
|
34 return (wc); |
|
35 } |
|
36 |
|
37 @endcode |
|
38 @code |
|
39 #include <wchar.h> |
|
40 /* Illustrates how to use wctob API */ |
|
41 int example_wctob(void) |
|
42 { |
|
43 wint_t wc = L'a'; |
|
44 int c; |
|
45 |
|
46 /* represent a wide-char in a single byte*/ |
|
47 c = wctob(wc); |
|
48 /* return the single byte */ |
|
49 return(c); |
|
50 } |
|
51 |
|
52 @endcode |
|
53 |
|
54 Limitations: |
|
55 |
|
56 The current implementation of btowc and wctob is not affected by the LC_CTYPE category of the current locale. |
|
57 It works only for UTF8 character set. |
|
58 |
|
59 @see mbrtowc() |
|
60 @see wcrtomb() |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 @publishedAll |
|
66 @externallyDefinedApi |
|
67 */ |
|
68 |
|
69 /** @fn fgetwc(FILE *stream) |
|
70 @param stream |
|
71 |
|
72 Note: This description also covers the following functions - |
|
73 getwc() getwchar() |
|
74 |
|
75 @return If successful these routines return the next wide character from the stream. If the stream is at end-of-file or a read error occurs the routines |
|
76 return WEOF. The routines feof and ferror must be used to distinguish between end-of-file |
|
77 and error. If an error occurs the global variable errno is set to indicate the error. The end-of-file condition is remembered, |
|
78 even on a terminal, and all subsequent attempts to read will return WEOF until the condition is cleared with clearerr . |
|
79 |
|
80 The fgetwc function |
|
81 obtains the next input wide character (if present) from the stream pointed at by stream, or the next character pushed back on the stream via ungetwc . |
|
82 |
|
83 The getwc function |
|
84 acts essentially identical to fgetwc. |
|
85 |
|
86 The getwchar function |
|
87 is equivalent to getwc with the argument stdin. |
|
88 |
|
89 Examples: |
|
90 @code |
|
91 /* Illustrates how to use fgetwc API */ |
|
92 #include <stdio.h> |
|
93 #include <wchar.h> |
|
94 wint_t example_fgetwc(void) |
|
95 { |
|
96 FILE *fp = NULL; |
|
97 wint_t retval; |
|
98 |
|
99 /* opening the input file */ |
|
100 fp = fopen("input.txt","r"); |
|
101 if(fp == NULL) |
|
102 { |
|
103 wprintf(L"Error: File open |
|
104 "); |
|
105 return (-1); |
|
106 } |
|
107 /* Read a character from the opened file */ |
|
108 retval = fgetwc(fp); |
|
109 /* Close the file open for reading */ |
|
110 fclose(fp); |
|
111 /* return the character read from the file */ |
|
112 return (retval); |
|
113 } |
|
114 |
|
115 @endcode |
|
116 @code |
|
117 /* Illustrates how to use getwc API */ |
|
118 #include <stdio.h> |
|
119 #include <wchar.h> |
|
120 wint_t example_getwc(void) |
|
121 { |
|
122 FILE *fp = NULL; |
|
123 wint_t retval; |
|
124 |
|
125 /* opening the input file */ |
|
126 fp = fopen("input.txt","r"); |
|
127 if(fp == NULL) |
|
128 { |
|
129 wprintf(L"Error: File open |
|
130 "); |
|
131 return (-1); |
|
132 } |
|
133 /* Read a character from the opened file */ |
|
134 retval = getwc(fp); |
|
135 /* Close the file open for reading */ |
|
136 fclose(fp); |
|
137 /* return the character read from the file */ |
|
138 return (retval); |
|
139 } |
|
140 |
|
141 @endcode |
|
142 @code |
|
143 /* Illustrates how to use getwchar API */ |
|
144 #include <stdio.h> |
|
145 #include <wchar.h> |
|
146 wint_t example_getwchar(void) |
|
147 { |
|
148 wint_t retval; |
|
149 |
|
150 /* Read a character from standard input */ |
|
151 retval = getwchar(); |
|
152 /* return the character read */ |
|
153 return (retval); |
|
154 } |
|
155 |
|
156 @endcode |
|
157 @see ferror() |
|
158 @see fopen() |
|
159 @see fread() |
|
160 @see getc() |
|
161 @see putwc() |
|
162 @see ungetwc() |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 @publishedAll |
|
168 @externallyDefinedApi |
|
169 */ |
|
170 |
|
171 |
|
172 /** @fn fgetws(wchar_t * ws, int n, FILE * fp) |
|
173 @param ws |
|
174 @param n |
|
175 @param fp |
|
176 @return Upon successful completion fgetws returns ws. If end-of-file occurs before any characters are read, fgetws returns NULL and the buffer contents remain unchanged. If an error occurs fgetws returns NULL and the buffer contents are indeterminate. The fgetws function does not distinguish between end-of-file and error, |
|
177 and callers must use feof and ferror to determine which occurred. |
|
178 |
|
179 The fgetws function reads at most one less than the number of characters |
|
180 specified by n from the given fp and stores them in the wide character string ws. Reading stops when a newline character is found, at end-of-file or |
|
181 error. The newline, if any, is retained. If any characters are read, and there |
|
182 is no error, a '\\0' character is appended to end the string. |
|
183 |
|
184 Examples: |
|
185 @code |
|
186 #include <stdio.h> |
|
187 #include <wchar.h> |
|
188 /* Illustrates how to use fgetws API */ |
|
189 wchar_t *example_fgetws(wchar_t *buf) |
|
190 { |
|
191 FILE *fp = NULL; |
|
192 wint_t retval; |
|
193 int n; |
|
194 /* for example, 10 characters to be read */ |
|
195 n = 10; |
|
196 /* opening the input file */ |
|
197 fp = fopen("input.txt","r"); |
|
198 if(fp == NULL) |
|
199 { |
|
200 wprintf(L"Error: File open |
|
201 "); |
|
202 return (-1); |
|
203 } |
|
204 /* Read characters from the opened file */ |
|
205 retval = fgetws(buf, n, fp); |
|
206 /* Close the file open for reading */ |
|
207 fclose(fp); |
|
208 /* return the character read from the file */ |
|
209 return (buf); |
|
210 } |
|
211 |
|
212 @endcode |
|
213 @see feof() |
|
214 @see ferror() |
|
215 @see fgets() |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 @publishedAll |
|
221 @externallyDefinedApi |
|
222 */ |
|
223 |
|
224 /** @fn fputwc(wchar_t wc, FILE *stream) |
|
225 @param wc |
|
226 @param stream |
|
227 |
|
228 Note: This description also covers the following functions - |
|
229 putwc() putwchar() |
|
230 |
|
231 @return The fputwc, putwc, and putwchar functions |
|
232 return the wide character written. |
|
233 If an error occurs, the value WEOF is returned. |
|
234 |
|
235 The fputwc function |
|
236 writes the wide character wc to the output stream pointed to by stream. |
|
237 |
|
238 The putwc function |
|
239 acts essentially identically to fputwc. |
|
240 |
|
241 The putwchar function |
|
242 is identical to putwc with an output stream of stdout. |
|
243 |
|
244 Examples: |
|
245 @code |
|
246 /* Illustrates how to use putwc API */ |
|
247 #include <stdio.h> |
|
248 #include <wchar.h> |
|
249 wint_t example_putwc(void) |
|
250 { |
|
251 FILE *fp = NULL; |
|
252 wchar_t wc = L'a'; |
|
253 wint_t rval; |
|
254 /* opening the file to write*/ |
|
255 fp = fopen("input.txt","w"); |
|
256 if(fp == NULL) |
|
257 { |
|
258 wprintf(L"Error: File open |
|
259 "); |
|
260 return (-1); |
|
261 } |
|
262 /* write a character into fp */ |
|
263 rval = putwc(wc, fp); |
|
264 /* Close the file opened for writing */ |
|
265 fclose(fp); |
|
266 /* return the value that was written */ |
|
267 return (rval); |
|
268 } |
|
269 |
|
270 @endcode |
|
271 @code |
|
272 /* Illustrates how to use fputwc API */ |
|
273 #include <stdio.h> |
|
274 #include <wchar.h> |
|
275 wint_t example_fputwc(void) |
|
276 { |
|
277 FILE *fp = NULL; |
|
278 wchar_t wc = L'a'; |
|
279 wint_t rval; |
|
280 /* opening the file to write*/ |
|
281 fp = fopen("input.txt","w"); |
|
282 if(fp == NULL) |
|
283 { |
|
284 wprintf(L"Error: File open |
|
285 "); |
|
286 return (-1); |
|
287 } |
|
288 /* write a character into fp */ |
|
289 rval = fputwc(wc, fp); |
|
290 /* Close the file opened for writing */ |
|
291 fclose(fp); |
|
292 /* return the value that was written */ |
|
293 return (rval); |
|
294 } |
|
295 |
|
296 @endcode |
|
297 @code |
|
298 /* Illustrates how to use putwchar API */ |
|
299 #include <stdio.h> |
|
300 #include <wchar.h> |
|
301 wint_t example_putwchar(void) |
|
302 { |
|
303 wint_t rval; |
|
304 wchar_t wc = L'q'; |
|
305 |
|
306 /* write a character onto the standard output */ |
|
307 rval = putwchar(wc); |
|
308 /* return the character that was written */ |
|
309 return (rval); |
|
310 } |
|
311 |
|
312 @endcode |
|
313 Output of putwchar |
|
314 @code |
|
315 q |
|
316 |
|
317 @endcode |
|
318 @see ferror() |
|
319 @see fopen() |
|
320 @see getwc() |
|
321 @see putc() |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 @publishedAll |
|
327 @externallyDefinedApi |
|
328 */ |
|
329 |
|
330 |
|
331 /** @fn fputws(const wchar_t * ws, FILE * fp) |
|
332 @param ws |
|
333 @param fp |
|
334 @return The fputws function |
|
335 returns 0 on success and -1 on error. |
|
336 |
|
337 The fputws function writes the wide character string pointed to by ws to the stream pointed to by fp. |
|
338 |
|
339 Examples: |
|
340 @code |
|
341 #include <stdio.h> |
|
342 #include <wchar.h> |
|
343 /* Illustrates how to use fputws API */ |
|
344 int example_fputws(wchar_t *buf) |
|
345 { |
|
346 FILE *fp = NULL; |
|
347 int retval; |
|
348 /* open the file for writing*/ |
|
349 fp = fopen("write.txt","r"); |
|
350 if(fp == NULL) |
|
351 { |
|
352 wprintf(L"Error: File open |
|
353 "); |
|
354 return (-1); |
|
355 } |
|
356 /* Write the characters into the file */ |
|
357 retval = fputws(buf, fp); |
|
358 /* Close the file open for writing */ |
|
359 fclose(fp); |
|
360 /* return the number of characters written */ |
|
361 /* into the file */ |
|
362 return (retval); |
|
363 } |
|
364 |
|
365 @endcode |
|
366 @see ferror() |
|
367 @see fputs() |
|
368 @see putwc() |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 @publishedAll |
|
374 @externallyDefinedApi |
|
375 */ |
|
376 |
|
377 |
|
378 /** @fn fwide(FILE *stream, int mode) |
|
379 @param stream |
|
380 @param mode |
|
381 @return The fwide function |
|
382 returns a value according to orientation after the call of fwide; a value less than zero if byte-oriented, a value greater than zero |
|
383 if wide-oriented, and zero if the stream has no orientation. |
|
384 |
|
385 The fwide function |
|
386 determines the orientation of the stream pointed at by stream. |
|
387 |
|
388 If the orientation of stream has already been determined fwide leaves it unchanged. Otherwise fwide sets the orientation of stream according to mode. |
|
389 |
|
390 If mode is less than zero stream is set to byte-oriented. If it is greater than zero stream is set to wide-oriented. Otherwise mode is zero and stream is unchanged. |
|
391 |
|
392 Examples: |
|
393 @code |
|
394 #include <stdio.h> |
|
395 #include <wchar.h> |
|
396 /* Illustrates how to use fwide API */ |
|
397 int example_fwide(void) |
|
398 { |
|
399 FILE *fp = NULL; |
|
400 int retval; |
|
401 int mode; |
|
402 /* open a file */ |
|
403 fp = fopen("input.txt","r"); |
|
404 if(fp == NULL) |
|
405 { |
|
406 wprintf(L"Error: File open |
|
407 "); |
|
408 return (-1); |
|
409 } |
|
410 /* set the mode to wide*/ |
|
411 mode = 1; |
|
412 /* set the orientation of the file */ |
|
413 retval = fwide(fp, mode); |
|
414 /* check the return value */ |
|
415 if(retval == 1) |
|
416 { |
|
417 wprintf(L"Mode set to WIDE |
|
418 "); |
|
419 } |
|
420 else |
|
421 { |
|
422 wprintf(L"Error setting the mode to wide!! |
|
423 "); |
|
424 } |
|
425 /* set the mode to determine the orientation */ |
|
426 mode = 0; |
|
427 /* Read back the orientation that was set */ |
|
428 retval = fwide(fp ,mode); |
|
429 if(retval == 1) |
|
430 { |
|
431 wprintf("Mode not changed |
|
432 "); |
|
433 } |
|
434 else |
|
435 { |
|
436 wprintf("Error, mode changed!! |
|
437 "); |
|
438 } |
|
439 /* Close the file open for writing */ |
|
440 fclose(fp); |
|
441 /* return the mode of fp */ |
|
442 return (retval); |
|
443 } |
|
444 |
|
445 @endcode |
|
446 @see ferror() |
|
447 @see fgetc() |
|
448 @see fgetwc() |
|
449 @see fopen() |
|
450 @see fputc() |
|
451 @see fputwc() |
|
452 @see freopen() |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 @publishedAll |
|
458 @externallyDefinedApi |
|
459 */ |
|
460 |
|
461 |
|
462 /** @fn fwprintf(FILE * stream, const wchar_t * format, ...) |
|
463 @param stream |
|
464 @param format |
|
465 @param ... |
|
466 |
|
467 Note: This description also covers the following functions - |
|
468 swprintf() snwprintf() vsnwprintf() wprintf() vfwprintf() vswprintf() vwprintf() |
|
469 |
|
470 @return The functions return the number of wide characters written, excluding the terminating null wide character in case of the functions swprintf , snwprintf , vswprintf and vsnwprintf . They return -1 when an error occurs. |
|
471 |
|
472 The wprintf family of functions produces output according to a format as described below. The wprintf and vwprintf functions write output to stdout, the standard output stream; fwprintf and vfwprintf write output to the given output stream; swprintf , snwprintf , vswprintf and vsnwprintf write to the wide character string ws. |
|
473 These functions write the output under the control of a format string that specifies how subsequent arguments (or arguments accessed via the variable-length argument facilities of stdarg) are converted for output. |
|
474 |
|
475 These functions return the number of characters printed (not including the trailing ‘\\0’ used to end output to strings). |
|
476 |
|
477 The swprintf , snwprintf , vswprintf and vsnwprintf functions will fail if n or more wide characters were requested to be written. |
|
478 |
|
479 @code |
|
480 |
|
481 Note : |
|
482 |
|
483 1. swprintf and snwprintf can be used interchangeably. |
|
484 |
|
485 2. vswprintf and vsnwprintf can be used interchangeably. |
|
486 |
|
487 |
|
488 The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced by the % character. The arguments must correspond properly (after type promotion) with the conversion specifier. After the %, the following appear in sequence: |
|
489 @endcode |
|
490 |
|
491 @code |
|
492 An optional field, consisting of a decimal digit string followed by a $, specifying the next argument to access. If this field is not provided, the argument following the last argument accessed will be used. Arguments are numbered starting at 1. If unaccessed arguments in the format string are interspersed with ones that are accessed the results will be indeterminate. |
|
493 Zero or more of the following flags: |
|
494 |
|
495 '#' The value should be converted to an "alternate form". For c, d, i, n, p, s, and u conversions, this option has no effect. For o conversions, the precision of the number is increased to force the first character of the output string to a zero (except if a zero value is printed with an explicit precision of zero). For x and X conversions, a non-zero result has the string ‘0x’ (or ‘0X’ for X conversions) prepended to it. For a, A, e, E, f, F, g, and G conversions, the result will always contain a decimal point, even if no digits follow it (normally, a decimal point appears in the results of those conversions only if a digit follows). For g and G conversions, trailing zeros are not removed from the result as they would otherwise be. |
|
496 |
|
497 '0(zero)' Zero padding. For all conversions except n, the converted value is padded on the left with zeros rather than blanks. If a precision is given with a numeric conversion ( d, i, o, u, i, x, and X), the 0 flag is ignored. |
|
498 |
|
499 '-' A negative field width flag; the converted value is to be left adjusted on the field boundary. Except for n conversions, the converted value is padded on the right with blanks, rather than on the left with blanks or zeros. A - overrides a 0 if both are given. |
|
500 |
|
501 ' (space)' A blank should be left before a positive number produced by a signed conversion ( a, A, d, e, E, f, F, g, G, or i). |
|
502 |
|
503 '+' A sign must always be placed before a number produced by a signed conversion. A + overrides a space if both are used. |
|
504 |
|
505 '’' Decimal conversions ( d, u, or i) or the integral portion of a floating point conversion ( f or F) should be grouped and separated by thousands using the non-monetary separator returned by localeconv. |
|
506 |
|
507 |
|
508 An optional decimal digit string specifying a minimum field width. If the converted value has fewer characters than the field width, it will be padded with spaces on the left (or right, if the left-adjustment flag has been given) to fill out the field width. |
|
509 |
|
510 An optional precision, in the form of a period . followed by an optional digit string. If the digit string is omitted, the precision is taken as zero. This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, the number of digits to appear after the decimal-point for a, A, e, E, f, and F conversions, the maximum number of significant digits for g and G conversions, or the maximum number of characters to be printed from a string for s conversions. |
|
511 |
|
512 An optional length modifier, that specifies the size of the argument. The following length modifiers are valid for the d, i, n, o, u, x, or X conversion: |
|
513 |
|
514 @endcode |
|
515 |
|
516 @code |
|
517 |
|
518 Modifier d, i o, u, x, X n |
|
519 |
|
520 hh signed char unsigned char signed char * |
|
521 h short unsigned short short * |
|
522 l (ell) long unsigned long long * |
|
523 ll (ell ell) long long unsigned long long long long * |
|
524 j intmax_t uintmax_t intmax_t * |
|
525 t ptrdiff_t (see note) ptrdiff_t * |
|
526 z (see note) size_t (see note) |
|
527 q (deprecated) quad_t u_quad_t quad_t * |
|
528 |
|
529 @endcode |
|
530 |
|
531 @code |
|
532 |
|
533 Note: the t modifier, when applied to a o, u, x, or X conversion, indicates that the argument is of an unsigned type equivalent in size to a ptrdiff_t . The z modifier, when applied to a d or i conversion, indicates that the argument is of a signed type equivalent in size to a size_t . Similarly, when applied to an n conversion, it indicates that the argument is a pointer to a signed type equivalent in size to a size_t . |
|
534 |
|
535 The following length modifier is valid for the a, A, e, E, f, F, g, or G conversion: |
|
536 |
|
537 @endcode |
|
538 |
|
539 @code |
|
540 |
|
541 Modifier a, A, e, E, f, F, g, G |
|
542 L long double |
|
543 |
|
544 @endcode |
|
545 |
|
546 @code |
|
547 |
|
548 The following length modifier is valid for the c or s conversion: |
|
549 |
|
550 Modifier c s |
|
551 l (ell) wint_t wchar_t * |
|
552 |
|
553 @endcode |
|
554 |
|
555 @code |
|
556 |
|
557 A character that specifies the type of conversion to be applied. |
|
558 |
|
559 A field width or precision, or both, may be indicated by an asterisk ‘*’ or an asterisk followed by one or more decimal digits and a ‘$’ instead of a digit string. In this case, an int argument supplies the field width or precision. A negative field width is treated as a left adjustment flag followed by a positive field width; a negative precision is treated as though it were missing. If a single format directive mixes positional (nn$) and non-positional arguments, the results are undefined. |
|
560 |
|
561 The conversion specifiers and their meanings are: |
|
562 |
|
563 |
|
564 diouxX |
|
565 The int (or appropriate variant) argument is converted to signed decimal ( d and i), unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal ( x and X) notation. The letters "abcdef" are used for x conversions; the letters "ABCDEF" are used for X conversions. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros. |
|
566 |
|
567 DOU |
|
568 The long int argument is converted to signed decimal, unsigned octal, or unsigned decimal, as if the format had been ld, lo, or lu respectively. These conversion characters are deprecated, and will eventually disappear. |
|
569 |
|
570 eE |
|
571 The double argument is rounded and converted in the style [-d . ddd e \*[Pm] dd] where there is one digit before the decimal-point character and the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6; if the precision is zero, no decimal-point character appears. An E conversion uses the letter ‘E’ (rather than ‘e’) to introduce the exponent. The exponent always contains at least two digits; if the value is zero, the exponent is 00. |
|
572 For a, A, e, E, f, F, g, and G conversions, positive and negative infinity are represented as inf and -inf respectively when using the lowercase conversion character, and INF and -INF respectively when using the uppercase conversion character. Similarly, NaN is represented as nan when using the lowercase conversion, and NAN when using the uppercase conversion. |
|
573 |
|
574 fF |
|
575 The double argument is rounded and converted to decimal notation in the style [-ddd . ddd], where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it. |
|
576 |
|
577 gG The double argument is converted in style f or e (or F or E for G conversions). The precision specifies the number of significant digits. If the precision is missing, 6 digits are given; if the precision is zero, it is treated as 1. Style e is used if the exponent from its conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit. |
|
578 |
|
579 aA The double argument is converted to hexadecimal notation in the style [-0x h . hhhp[\*[Pm]d]], where the number of digits after the hexadecimal-point character is equal to the precision specification. If the precision is missing, it is taken as enough to exactly represent the floating-point number; if the precision is explicitly zero, no hexadecimal-point character appears. This is an exact conversion of the mantissa+exponent internal floating point representation; the [-0x h . hhh] portion represents exactly the mantissa; only denormalized mantissas have a zero value to the left of the hexadecimal point. The p is a literal character ‘p’; the exponent is preceded by a positive or negative sign and is represented in decimal, using only enough characters to represent the exponent. The A conversion uses the prefix "0X" (rather than "0x"), the letters "ABCDEF" (rather than "abcdef") to represent the hex digits, and the letter ‘P’ (rather than ‘p’) to separate the mantissa and exponent. |
|
580 |
|
581 C Treated as c with the l (ell) modifier. |
|
582 |
|
583 c The int argument is converted to an unsigned char , then to a wchar_t as if by btowc, and the resulting character is written. |
|
584 |
|
585 If the l (ell) modifier is used, the wint_t argument is converted to a wchar_t and written. |
|
586 |
|
587 S Treated as s with the l (ell) modifier. |
|
588 |
|
589 s The char * argument is expected to be a pointer to an array of character type (pointer to a string) containing a multibyte sequence. Characters from the array are converted to wide characters and written up to (but not including) a terminating NUL character; if a precision is specified, no more than the number specified are written. If a precision is given, no null character need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating NUL character. |
|
590 |
|
591 If the l (ell) modifier is used, the wchar_t * argument is expected to be a pointer to an array of wide characters (pointer to a wide string). Each wide character in the string is written. Wide characters from the array are written up to (but not including) a terminating wide NUL character; if a precision is specified, no more than the number specified are written (including shift sequences). If a precision is given, no null character need be present; if the precision is not specified, or is greater than the number of characters in the string, the array must contain a terminating wide NUL character. |
|
592 |
|
593 p The void * pointer argument is printed in hexadecimal (as if by ‘%#x’ or ‘%#lx’). |
|
594 |
|
595 n The number of characters written so far is stored into the integer indicated by the int * (or variant) pointer argument. No argument is converted. |
|
596 |
|
597 % A ‘%’ is written. No argument is converted. The complete conversion specification is ‘%%’. |
|
598 |
|
599 @endcode |
|
600 |
|
601 The decimal point character is defined in the program’s locale (category LC_NUMERIC). |
|
602 |
|
603 In no case does a non-existent or small field width cause truncation of a numeric field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result. |
|
604 |
|
605 |
|
606 Examples: |
|
607 @code |
|
608 #include <stdio.h> |
|
609 #include <wchar.h> |
|
610 /* Illustrates how to use wprintf API */ |
|
611 int example_wprintf(void) |
|
612 { |
|
613 int input = 12345; |
|
614 int rval; |
|
615 /* prints the integers on the standard output */ |
|
616 rval = wprintf(L"%d", input); |
|
617 /* return the number of wide characters that were written */ |
|
618 return(rval); |
|
619 } |
|
620 |
|
621 @endcode |
|
622 Output |
|
623 @code |
|
624 12345 |
|
625 |
|
626 @endcode |
|
627 @code |
|
628 #include <stdio.h> |
|
629 #include <wchar.h> |
|
630 /* Illustrates how to use fwprintf API */ |
|
631 int example_fwprintf(void) |
|
632 { |
|
633 FILE *fp = NULL; |
|
634 int retval; |
|
635 wchar_t *wcs = L"abc"; |
|
636 /* open the file for writing*/ |
|
637 fp = fopen("write.txt","w"); |
|
638 if(fp == NULL) |
|
639 { |
|
640 wprintf(L"Error: File open |
|
641 "); |
|
642 return (-1); |
|
643 } |
|
644 /* print the characters into the file */ |
|
645 retval = fwprintf(fp, L"%s", wcs); |
|
646 /* Close the file opened for writing */ |
|
647 fclose(fp); |
|
648 /* return the number of wide characters that were written */ |
|
649 return (retval); |
|
650 } |
|
651 |
|
652 @endcode |
|
653 @code |
|
654 #include <stdio.h> |
|
655 #include <wchar.h> |
|
656 /* Illustrates how to use swprintf API */ |
|
657 int example_swprintf(wchar_t *buf, int maxlen) |
|
658 { |
|
659 wchar_t *wcs = L"abcdef"; |
|
660 int rval; |
|
661 /* prints the wide char string into the buffer buf */ |
|
662 rval = swprintf(buf, maxlen, L"%s", wcs); |
|
663 /* return the number of wide characters that were written */ |
|
664 return(rval); |
|
665 } |
|
666 |
|
667 @endcode |
|
668 @code |
|
669 #include <stdio.h> |
|
670 #include <wchar.h> |
|
671 /* Illustrates how to use vwprintf API */ |
|
672 int example_vwprintf(va_list input) |
|
673 { |
|
674 int rval; |
|
675 /* prints the integers on the standard output */ |
|
676 rval = vwprintf(L"%d", input); |
|
677 /* return the number of wide characters that were written */ |
|
678 return(rval); |
|
679 } |
|
680 |
|
681 @endcode |
|
682 @code |
|
683 #include <stdio.h> |
|
684 #include <wchar.h> |
|
685 /* Illustrates how to use vfwprintf API */ |
|
686 int example_vfwprintf(va_list input) |
|
687 { |
|
688 FILE *fp = NULL; |
|
689 int retval; |
|
690 |
|
691 /* open the file for writing*/ |
|
692 fp = fopen("write.txt","w"); |
|
693 if(fp == NULL) |
|
694 { |
|
695 wprintf(L"Error: File open |
|
696 "); |
|
697 return (-1); |
|
698 } |
|
699 /* print the characters into the file */ |
|
700 retval = vfwprintf(fp, L"%s", input); |
|
701 /* Close the file opened for writing */ |
|
702 fclose(fp); |
|
703 /* return the number of wide characters that were written */ |
|
704 return (retval); |
|
705 } |
|
706 |
|
707 @endcode |
|
708 @code |
|
709 #include <stdio.h> |
|
710 #include <wchar.h> |
|
711 /* Illustrates how to use vswprintf API */ |
|
712 int example_vswprintf(wchar_t *buf, int maxlen, va_list input) |
|
713 { |
|
714 int rval; |
|
715 /* prints the wide char string into the buffer buf */ |
|
716 rval = vswprintf(buf, maxlen, L"%s", input); |
|
717 /* return the number of wide characters that were written */ |
|
718 return(rval); |
|
719 } |
|
720 |
|
721 @endcode |
|
722 |
|
723 Security considerations: |
|
724 |
|
725 Refer to printf() . |
|
726 |
|
727 Limitations: |
|
728 |
|
729 Long double length modifiers are not supported. The maximum floating point |
|
730 precision is 15 digits. |
|
731 |
|
732 @see btowc() |
|
733 @see fputws() |
|
734 @see printf() |
|
735 @see putwc() |
|
736 @see setlocale() |
|
737 @see wcsrtombs() |
|
738 @see wscanf() |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 @publishedAll |
|
744 @externallyDefinedApi |
|
745 */ |
|
746 |
|
747 /** @fn fwscanf(FILE * stream, const wchar_t * format, ...) |
|
748 @param stream |
|
749 @param format |
|
750 @param ... |
|
751 |
|
752 Refer to wscanf() for the documentation |
|
753 |
|
754 @see fgetwc() |
|
755 @see scanf() |
|
756 @see wcrtomb() |
|
757 @see wcstod() |
|
758 @see wcstol() |
|
759 @see wcstoul() |
|
760 @see wprintf() |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 @publishedAll |
|
766 @externallyDefinedApi |
|
767 */ |
|
768 |
|
769 /** @fn getwc(FILE *stream) |
|
770 @param stream |
|
771 |
|
772 Refer to fgetwc() for the documentation |
|
773 |
|
774 @see ferror() |
|
775 @see fopen() |
|
776 @see fread() |
|
777 @see getc() |
|
778 @see putwc() |
|
779 @see ungetwc() |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 @publishedAll |
|
785 @externallyDefinedApi |
|
786 */ |
|
787 |
|
788 |
|
789 /** @fn getwchar(void) |
|
790 |
|
791 Refer to fgetwc() for the documentation |
|
792 |
|
793 @see ferror() |
|
794 @see fopen() |
|
795 @see fread() |
|
796 @see getc() |
|
797 @see putwc() |
|
798 @see ungetwc() |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 @publishedAll |
|
804 @externallyDefinedApi |
|
805 */ |
|
806 |
|
807 /** @fn mbrlen(const char * s, size_t n, mbstate_t * ps) |
|
808 @param s |
|
809 @param n |
|
810 @param ps |
|
811 |
|
812 @return The mbrlen functions returns: 0 The next n or fewer bytes |
|
813 represent the null wide character (L'\\0') \>0 The next n or fewer bytes |
|
814 represent a valid character, mbrlen returns the number of bytes used to complete the multibyte character. ( size_t-2) The next n contribute to, but do not complete, a valid multibyte character sequence, |
|
815 and all n bytes have been processed. ( size_t-1) An encoding error has occurred. |
|
816 The next n or fewer bytes do not contribute to a valid multibyte character. |
|
817 |
|
818 The mbrlen function inspects at most n bytes pointed to by s to determine the number of bytes needed to complete the next |
|
819 multibyte character. |
|
820 |
|
821 The mbstate_t |
|
822 argument, ps, is used to keep track of the shift state. |
|
823 If it is NULL, mbrlen uses an internal, static mbstate_t |
|
824 object, which is initialized to the initial conversion state |
|
825 at program startup. |
|
826 |
|
827 It is equivalent to: |
|
828 |
|
829 @code |
|
830 |
|
831 mbrtowc(NULL, s, n, ps); |
|
832 |
|
833 @endcode |
|
834 |
|
835 Except that when ps is a NULL pointer, mbrlen uses its own static, internal mbstate_t |
|
836 object to keep track of the shift state. The behavior of the mbrlen is affected by LC_CTYPE category of the current locale. |
|
837 |
|
838 Examples: |
|
839 A function that calculates the number of characters in a multibyte |
|
840 character string: |
|
841 @code |
|
842 size_t |
|
843 nchars(const char *s) |
|
844 { |
|
845 size_t charlen, chars; |
|
846 mbstate_t mbs; |
|
847 chars = 0; |
|
848 memset(&mbs;, 0, sizeof(mbs)); |
|
849 while ((charlen = mbrlen(s, MB_CUR_MAX, &mbs;)) != 0 && |
|
850 charlen != (size_t)-1 && charlen != (size_t)-2) { |
|
851 s += charlen; |
|
852 chars++; |
|
853 } |
|
854 return (chars); |
|
855 } |
|
856 |
|
857 @endcode |
|
858 |
|
859 Errors: |
|
860 |
|
861 The mbrlen function will fail if: |
|
862 [EILSEQ] An invalid multibyte sequence was detected. |
|
863 [EINVAL] The conversion state is invalid. |
|
864 |
|
865 Limitations: |
|
866 |
|
867 The current implementation of mbrlen is not affected by the LC_CTYPE category of the current locale. |
|
868 It works only for UTF8 character set. |
|
869 |
|
870 @see mblen() |
|
871 @see mbrtowc() |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 @publishedAll |
|
877 @externallyDefinedApi |
|
878 */ |
|
879 |
|
880 /** @fn mbrtowc(wchar_t * pwc, const char * s, size_t n, mbstate_t * ps) |
|
881 @param pwc |
|
882 @param s |
|
883 @param n |
|
884 @param ps |
|
885 |
|
886 @return The mbrtowc functions returns: 0 The next n or fewer bytes |
|
887 represent the null wide character (L'\\0') \>0 The next n or fewer bytes |
|
888 represent a valid character, mbrtowc returns the number of bytes used to complete the multibyte character. ( size_t-2) The next n contribute to, but do not complete, a valid multibyte character sequence, |
|
889 and all n bytes have been processed. ( size_t-1) An encoding error has occurred. |
|
890 The next n or fewer bytes do not contribute to a valid multibyte character. |
|
891 |
|
892 |
|
893 The mbrtowc function inspects at most n bytes pointed to by s to determine the number of bytes needed to complete the next multibyte |
|
894 character. |
|
895 If a character can be completed, and pwc is not NULL, the wide character which is represented by s is stored in the wchar_t |
|
896 it points to. |
|
897 |
|
898 If s is NULL, mbrtowc behaves as if pwc was NULL, s was an empty string ("") |
|
899 and n was 1. |
|
900 |
|
901 The mbstate_t |
|
902 argument, ps, is used to keep track of the shift state. |
|
903 If it is NULL, mbrtowc uses an internal, static mbstate_t |
|
904 object, which is initialized to the initial conversion state |
|
905 at program startup. |
|
906 |
|
907 The behavior of the mbrtowc is affected by LC_CTYPE category of the current locale. |
|
908 |
|
909 Examples: |
|
910 @code |
|
911 #include <stdio.h> |
|
912 #include <stdlib.h> |
|
913 #include <wchar.h> |
|
914 /* Illustrates how to use mbrtowc API */ |
|
915 size_t example_mbrtowc() |
|
916 { |
|
917 size_t len; |
|
918 wchar_t wc[100]; |
|
919 char *s = 'a'; |
|
920 size_t n = 1; |
|
921 mbstate_t ps; |
|
922 /* converting multibyte sequence to a wide-char sequence */ |
|
923 len = mbrtowc(wc,(const char *) s, n, &ps;); |
|
924 /* checking for error value */ |
|
925 if(len < 0) |
|
926 { |
|
927 wprintf(L"mbrtowc returned error!! |
|
928 "); |
|
929 } |
|
930 /* returning no of bytes consumed */ |
|
931 return (len); |
|
932 } |
|
933 |
|
934 @endcode |
|
935 |
|
936 Errors: |
|
937 |
|
938 The mbrtowc function will fail if: |
|
939 [EILSEQ] An invalid multibyte sequence was detected. |
|
940 [EINVAL]The conversion state is invalid. |
|
941 |
|
942 |
|
943 Limitations: |
|
944 |
|
945 The current implementation of mbrtowc is not affected by the LC_CTYPE category of the current locale. |
|
946 It works only for UTF8 character set. |
|
947 |
|
948 @see mbtowc() |
|
949 @see setlocale() |
|
950 @see wcrtomb() |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 @publishedAll |
|
956 @externallyDefinedApi |
|
957 */ |
|
958 |
|
959 /** @fn mbsinit(const mbstate_t *ps) |
|
960 @param ps |
|
961 |
|
962 @return The mbsinit function returns non-zero if ps is NULL or describes an initial conversion state, |
|
963 otherwise it returns zero. |
|
964 |
|
965 The mbsinit function determines whether the mbstate_t |
|
966 object pointed to by ps describes an initial conversion state. |
|
967 |
|
968 The behavior of the mbsinit is affected by LC_CTYPE category of the current locale. |
|
969 |
|
970 Examples: |
|
971 @code |
|
972 #include <stdlib.h> |
|
973 #include <wchar.h> |
|
974 /* Illustrates how to use mbsinit API */ |
|
975 int example_mbsinit(void) |
|
976 { |
|
977 mbstate_t mbs; |
|
978 int state; |
|
979 |
|
980 /* testing for the initial state */ |
|
981 state = mbsinit(&mbs;); |
|
982 /* return the state */ |
|
983 return(state); |
|
984 } |
|
985 |
|
986 @endcode |
|
987 |
|
988 Limitations: |
|
989 |
|
990 The current implementation of mbsinit is not affected by the LC_CTYPE category of the current locale. |
|
991 It works only for UTF8 character set. |
|
992 |
|
993 @see mbrlen() |
|
994 @see mbrtowc() |
|
995 @see mbsrtowcs() |
|
996 @see wcrtomb() |
|
997 @see wcsrtombs() |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 @publishedAll |
|
1003 @externallyDefinedApi |
|
1004 */ |
|
1005 |
|
1006 /** @fn mbsrtowcs(wchar_t * dst, const char ** src, size_t len, mbstate_t * ps) |
|
1007 @param dst |
|
1008 @param src |
|
1009 @param len |
|
1010 @param ps |
|
1011 |
|
1012 Note: This description also covers the following functions - |
|
1013 mbsnrtowcs() |
|
1014 |
|
1015 @return The mbsrtowcs and mbsnrtowcs functions return the number of wide characters stored in |
|
1016 the array pointed to by dst if successful, otherwise it returns ( size_t)(-1). |
|
1017 |
|
1018 The mbsrtowcs function converts a sequence of multibyte characters pointed to indirectly by src into a sequence of corresponding wide characters and stores at most len of them in the wchar_t |
|
1019 array pointed to by dst, until it encounters a terminating null character ('\\0'.) |
|
1020 |
|
1021 If dst is NULL no characters are stored. |
|
1022 |
|
1023 If dst is not NULL, the pointer pointed to by src is updated to point to the character after the one that conversion stopped at. |
|
1024 If conversion stops because a null character is encountered, *src is set to NULL. |
|
1025 |
|
1026 The mbstate_t |
|
1027 argument, ps, is used to keep track of the shift state. |
|
1028 If it is NULL, mbsrtowcs uses an internal, static mbstate_t |
|
1029 object, which is initialized to the initial conversion state |
|
1030 at program startup. |
|
1031 |
|
1032 The mbsnrtowcs function behaves identically to mbsrtowcs, except that conversion stops after reading at most nms bytes from the buffer pointed to by src. |
|
1033 |
|
1034 The behavior of the mbsrtowcs and mbsnrtowcs is affected by LC_CTYPE category of the current locale. |
|
1035 |
|
1036 Examples: |
|
1037 @code |
|
1038 /* Illustrates how to use mbsrtowcs API */ |
|
1039 #include <stdio.h> |
|
1040 #include <stdlib.h> |
|
1041 #include <wchar.h> |
|
1042 size_t example_mbsrtowcs(wchar_t *wc, char *s, size_t n) |
|
1043 { |
|
1044 size_t len; |
|
1045 mbstate_t mbs; |
|
1046 /* converting multibyte string to a wide-char string */ |
|
1047 len = mbsrtowcs(wc, &s;, n, &mbs;); |
|
1048 /* checking for error */ |
|
1049 if(len < 0) |
|
1050 { |
|
1051 wprintf(L"mbsrtowcs returned error!! |
|
1052 "); |
|
1053 } |
|
1054 /* returning no of bytes consumed */ |
|
1055 return (len); |
|
1056 } |
|
1057 |
|
1058 @endcode |
|
1059 @code |
|
1060 /* Illustrates how to use mbsrntowcs API */ |
|
1061 #include <stdio.h> |
|
1062 #include <stdlib.h> |
|
1063 #include <wchar.h> |
|
1064 size_t example_mbsnrtowcs(wchar_t *wc, char *s, size_t n, size_t nms) |
|
1065 { |
|
1066 size_t len; |
|
1067 mbstate_t mbs; |
|
1068 /* converting multibyte string to a wide-char string */ |
|
1069 len = mbsnrtowcs(wc, &s;, nms, n, &mbs;); |
|
1070 /* checking for error */ |
|
1071 if(len < 0) |
|
1072 { |
|
1073 wprintf(L"mbsnrtowcs returned error!! |
|
1074 "); |
|
1075 } |
|
1076 /* returning no of bytes consumed */ |
|
1077 return (len); |
|
1078 } |
|
1079 |
|
1080 @endcode |
|
1081 |
|
1082 Errors: |
|
1083 |
|
1084 The mbsrtowcs and mbsnrtowcs functions will fail if: |
|
1085 [EILSEQ]An invalid multibyte character sequence was encountered. |
|
1086 [EINVAL] The conversion state is invalid. |
|
1087 |
|
1088 |
|
1089 Limitations: |
|
1090 |
|
1091 The current implementation of mbsrtowcs and mbsnrtowcs is not affected by the LC_CTYPE category of the current locale. |
|
1092 It works only for UTF8 character set. |
|
1093 |
|
1094 @see mbrtowc() |
|
1095 @see mbstowcs() |
|
1096 @see wcsrtombs() |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 @publishedAll |
|
1102 @externallyDefinedApi |
|
1103 */ |
|
1104 |
|
1105 |
|
1106 /** @fn putwc(wchar_t wc, FILE *stream) |
|
1107 @param wc |
|
1108 @param stream |
|
1109 |
|
1110 Refer to fputwc() for the documentation |
|
1111 |
|
1112 @see ferror() |
|
1113 @see fopen() |
|
1114 @see getwc() |
|
1115 @see putc() |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 @publishedAll |
|
1121 @externallyDefinedApi |
|
1122 */ |
|
1123 |
|
1124 /** @fn putwchar(wchar_t wc) |
|
1125 @param wc |
|
1126 |
|
1127 Refer to fputwc() for the documentation |
|
1128 |
|
1129 @see ferror() |
|
1130 @see fopen() |
|
1131 @see getwc() |
|
1132 @see putc() |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 @publishedAll |
|
1138 @externallyDefinedApi |
|
1139 */ |
|
1140 |
|
1141 /** @fn swprintf(wchar_t * s, size_t n, const wchar_t * fmt, ...) |
|
1142 @param s |
|
1143 @param n |
|
1144 @param fmt |
|
1145 @param ... |
|
1146 |
|
1147 Refer to fwprintf() for the documentation |
|
1148 |
|
1149 @see btowc() |
|
1150 @see fputws() |
|
1151 @see printf() |
|
1152 @see putwc() |
|
1153 @see setlocale() |
|
1154 @see wcsrtombs() |
|
1155 @see wscanf() |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 @publishedAll |
|
1161 @externallyDefinedApi |
|
1162 */ |
|
1163 |
|
1164 /** @fn swscanf(const wchar_t * str, const wchar_t *fmt, ...) |
|
1165 @param str |
|
1166 @param fmt |
|
1167 @param ... |
|
1168 |
|
1169 Refer to wscanf() for the documentation |
|
1170 |
|
1171 @see fgetwc() |
|
1172 @see scanf() |
|
1173 @see wcrtomb() |
|
1174 @see wcstod() |
|
1175 @see wcstol() |
|
1176 @see wcstoul() |
|
1177 @see wprintf() |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 @publishedAll |
|
1183 @externallyDefinedApi |
|
1184 */ |
|
1185 |
|
1186 /** @fn ungetwc(wint_t wc, FILE *stream) |
|
1187 @param wc |
|
1188 @param stream |
|
1189 @return The ungetwc function |
|
1190 returns |
|
1191 the wide character pushed-back after the conversion, or WEOF if the operation fails. |
|
1192 If the value of the argument c character equals WEOF , |
|
1193 the operation will fail and the stream will remain unchanged. |
|
1194 |
|
1195 The ungetwc function pushes the wide character wc (converted to an wchar_t ) |
|
1196 back onto the input stream pointed to by stream . |
|
1197 The pushed-backed wide characters will be returned by subsequent reads on the |
|
1198 stream (in reverse order). |
|
1199 A successful intervening call, using the same stream, to one of the file |
|
1200 positioning functions fseek , fsetpos , |
|
1201 or rewind will discard the pushed back wide characters. |
|
1202 |
|
1203 One wide character of push-back is guaranteed, |
|
1204 but as long as there is |
|
1205 sufficient memory, an effectively infinite amount of pushback is allowed. |
|
1206 |
|
1207 If a character is successfully pushed-back, |
|
1208 the end-of-file indicator for the stream is cleared. |
|
1209 |
|
1210 Examples: |
|
1211 @code |
|
1212 #include <stdio.h> |
|
1213 #include <wchar.h> |
|
1214 /* Illustrates how to use ungetwc API */ |
|
1215 wint_t example_ungetwc(void) |
|
1216 { |
|
1217 FILE *fp = NULL; |
|
1218 wint_t wc1; |
|
1219 wint_t rval; |
|
1220 wint_t wc2; |
|
1221 /* opening the file to write*/ |
|
1222 fp = fopen("input.txt","w"); |
|
1223 if(fp == NULL) |
|
1224 { |
|
1225 wprintf(L"Error: File open |
|
1226 "); |
|
1227 return (-1); |
|
1228 } |
|
1229 /* character to written back to the fp */ |
|
1230 wc = (wint_t) L'e'; |
|
1231 /* write the character into the fp */ |
|
1232 rval = ungetwc(wc, fp); |
|
1233 /* check for error */ |
|
1234 if(rval == WEOF) |
|
1235 { |
|
1236 wprintf(L"ungetwc returned error!! |
|
1237 "); |
|
1238 } |
|
1239 /* Read the character from fp */ |
|
1240 /* this char should be the same as the char */ |
|
1241 /* that was written by ungetwc */ |
|
1242 wc2 = getwc(fp); |
|
1243 /* Close the file opened for writing */ |
|
1244 fclose(fp); |
|
1245 /* return the value that was written */ |
|
1246 return (rval); |
|
1247 } |
|
1248 |
|
1249 @endcode |
|
1250 @see fseek() |
|
1251 @see getwc() |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 @publishedAll |
|
1257 @externallyDefinedApi |
|
1258 */ |
|
1259 |
|
1260 /** @fn vfwprintf(FILE * stream, const wchar_t * , va_list ap) |
|
1261 @param stream |
|
1262 @param fmt0 |
|
1263 @param ap |
|
1264 |
|
1265 Refer to fwprintf() for the documentation |
|
1266 |
|
1267 @see btowc() |
|
1268 @see fputws() |
|
1269 @see printf() |
|
1270 @see putwc() |
|
1271 @see setlocale() |
|
1272 @see wcsrtombs() |
|
1273 @see wscanf() |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 @publishedAll |
|
1279 @externallyDefinedApi |
|
1280 */ |
|
1281 |
|
1282 /** @fn vswprintf(wchar_t *s, size_t n, const wchar_t *fmt, va_list ap) |
|
1283 @param s |
|
1284 @param n |
|
1285 @param fmt |
|
1286 @param ap |
|
1287 |
|
1288 Refer to fwprintf() for the documentation |
|
1289 |
|
1290 @see btowc() |
|
1291 @see fputws() |
|
1292 @see printf() |
|
1293 @see putwc() |
|
1294 @see setlocale() |
|
1295 @see wcsrtombs() |
|
1296 @see wscanf() |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 @publishedAll |
|
1302 @externallyDefinedApi |
|
1303 */ |
|
1304 |
|
1305 /** @fn vwprintf(const wchar_t * fmt, va_list ap) |
|
1306 @param fmt |
|
1307 @param ap |
|
1308 |
|
1309 Refer to fwprintf() for the documentation |
|
1310 |
|
1311 @see btowc() |
|
1312 @see fputws() |
|
1313 @see printf() |
|
1314 @see putwc() |
|
1315 @see setlocale() |
|
1316 @see wcsrtombs() |
|
1317 @see wscanf() |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 @publishedAll |
|
1323 @externallyDefinedApi |
|
1324 */ |
|
1325 |
|
1326 /** @fn wcrtomb(char * mbchar, wchar_t wc, mbstate_t * ps) |
|
1327 @param mbchar |
|
1328 @param wc |
|
1329 @param ps |
|
1330 @return The wcrtomb functions returns the length (in bytes) of the multibyte sequence |
|
1331 needed to represent wc , |
|
1332 or ( size_t-1) if wc is not a valid wide character code. |
|
1333 |
|
1334 The wcrtomb function stores a multibyte sequence representing the |
|
1335 wide character wc , |
|
1336 including any necessary shift sequences, to the |
|
1337 character array s , |
|
1338 storing a maximum of MB_CUR_MAX bytes. |
|
1339 |
|
1340 If s is NULL , wcrtomb behaves as if s pointed to an internal buffer and wc was a null wide character (L'\\0'). |
|
1341 |
|
1342 The mbstate_t argument, ps , |
|
1343 is used to keep track of the shift state. |
|
1344 If it is NULL , wcrtomb uses an internal, static mbstate_t |
|
1345 object, which is initialized to the initial conversion state |
|
1346 at program startup. |
|
1347 |
|
1348 The behavior of the wcrtomb is affected by LC_CTYPE category of the current locale. |
|
1349 |
|
1350 Examples: |
|
1351 @code |
|
1352 #include <stdio.h> |
|
1353 #include <stdlib.h> |
|
1354 #include <wchar.h> |
|
1355 /* Illustrates how to use wcrtomb API */ |
|
1356 int example_wcrtomb(wchar_t wc) |
|
1357 { |
|
1358 char s[MAX_CUR_MAX]; |
|
1359 size_t len; |
|
1360 mbstate_t mbs; |
|
1361 |
|
1362 /* represent a wide-char in a single byte*/ |
|
1363 len = wcrtomb(s, wc, &mbs;); |
|
1364 /* return the number of bytes */ |
|
1365 return(len); |
|
1366 } |
|
1367 |
|
1368 @endcode |
|
1369 |
|
1370 Errors: |
|
1371 |
|
1372 The wcrtomb function will fail if: |
|
1373 [EILSEQ] An invalid wide character code was specified. |
|
1374 [EINVAL] The conversion state is invalid. |
|
1375 |
|
1376 |
|
1377 Limitations: |
|
1378 |
|
1379 The current implementation of wcrtomb is not affected by the LC_CTYPE category of the current locale. |
|
1380 It works only for UTF8 character set. |
|
1381 |
|
1382 @see mbrtowc() |
|
1383 @see setlocale() |
|
1384 @see wctomb() |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 @publishedAll |
|
1390 @externallyDefinedApi |
|
1391 */ |
|
1392 |
|
1393 /** @fn wcscat(wchar_t * s1, const wchar_t * s2) |
|
1394 @param s1 |
|
1395 @param s2 |
|
1396 |
|
1397 Refer to wmemchr() for the documentation |
|
1398 |
|
1399 @see memchr() |
|
1400 @see memcmp() |
|
1401 @see memcpy() |
|
1402 @see memmove() |
|
1403 @see memset() |
|
1404 @see strcat() |
|
1405 @see strchr() |
|
1406 @see strcmp() |
|
1407 @see strcpy() |
|
1408 @see strcspn() |
|
1409 @see strlen() |
|
1410 @see strncat() |
|
1411 @see strncmp() |
|
1412 @see strncpy() |
|
1413 @see strpbrk() |
|
1414 @see strrchr() |
|
1415 @see strspn() |
|
1416 @see strstr() |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 @publishedAll |
|
1422 @externallyDefinedApi |
|
1423 */ |
|
1424 |
|
1425 /** @fn wcschr(const wchar_t *s, wchar_t c) |
|
1426 @param s |
|
1427 @param c |
|
1428 |
|
1429 Refer to wmemchr() for the documentation |
|
1430 |
|
1431 @see memchr() |
|
1432 @see memcmp() |
|
1433 @see memcpy() |
|
1434 @see memmove() |
|
1435 @see memset() |
|
1436 @see strcat() |
|
1437 @see strchr() |
|
1438 @see strcmp() |
|
1439 @see strcpy() |
|
1440 @see strcspn() |
|
1441 @see strlen() |
|
1442 @see strncat() |
|
1443 @see strncmp() |
|
1444 @see strncpy() |
|
1445 @see strpbrk() |
|
1446 @see strrchr() |
|
1447 @see strspn() |
|
1448 @see strstr() |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 @publishedAll |
|
1454 @externallyDefinedApi |
|
1455 */ |
|
1456 |
|
1457 /** @fn wcscmp(const wchar_t *s1, const wchar_t *s2) |
|
1458 @param s1 |
|
1459 @param s2 |
|
1460 |
|
1461 Refer to wmemchr() for the documentation |
|
1462 |
|
1463 @see memchr() |
|
1464 @see memcmp() |
|
1465 @see memcpy() |
|
1466 @see memmove() |
|
1467 @see memset() |
|
1468 @see strcat() |
|
1469 @see strchr() |
|
1470 @see strcmp() |
|
1471 @see strcpy() |
|
1472 @see strcspn() |
|
1473 @see strlen() |
|
1474 @see strncat() |
|
1475 @see strncmp() |
|
1476 @see strncpy() |
|
1477 @see strpbrk() |
|
1478 @see strrchr() |
|
1479 @see strspn() |
|
1480 @see strstr() |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 @publishedAll |
|
1486 @externallyDefinedApi |
|
1487 */ |
|
1488 |
|
1489 /** @fn wcscoll(const wchar_t *ws1, const wchar_t *ws2) |
|
1490 @param ws1 |
|
1491 @param ws2 |
|
1492 @return The wcscoll function |
|
1493 returns an integer greater than, equal to, or less than 0, |
|
1494 if ws1 is greater than, equal to, or less than ws2 . No return value is reserved to indicate errors; |
|
1495 callers should set errno to 0 before calling wcscoll . |
|
1496 If it is non-zero upon return from wcscoll , |
|
1497 an error has occurred. |
|
1498 |
|
1499 The wcscoll function compares the null-terminated strings ws1 and ws2 according to the current locale collation order. |
|
1500 In the "C" |
|
1501 locale, wcscoll is equivalent to wcscmp . |
|
1502 |
|
1503 Examples: |
|
1504 @code |
|
1505 #include <wchar.h> |
|
1506 /* Illustrates how to use wcscoll API */ |
|
1507 int example_wcscoll (void) |
|
1508 { |
|
1509 /* compares the two strings */ |
|
1510 if( wcscoll(L"abcdef",L"abcdeg") != L'f'-L'g') |
|
1511 return -1; |
|
1512 return 0; |
|
1513 } |
|
1514 |
|
1515 @endcode |
|
1516 |
|
1517 Errors: |
|
1518 |
|
1519 The wcscoll function will fail if: |
|
1520 [EILSEQ] An invalid wide character code was specified. |
|
1521 [ENOMEM] Cannot allocate enough memory for temporary buffers. |
|
1522 |
|
1523 |
|
1524 Limitations: |
|
1525 |
|
1526 The current implementation of wcscoll is not affected by the LC_CTYPE category of the current locale. It is equivalent to wcscmp in this implementation. |
|
1527 |
|
1528 @see setlocale() |
|
1529 @see strcoll() |
|
1530 @see wcscmp() |
|
1531 @see wcsxfrm() |
|
1532 |
|
1533 |
|
1534 Bugs: |
|
1535 |
|
1536 The current implementation of wcscoll only works in single-byte LC_CTYPE locales, and falls back to using wcscmp in locales with extended character sets. |
|
1537 |
|
1538 |
|
1539 |
|
1540 @publishedAll |
|
1541 @externallyDefinedApi |
|
1542 */ |
|
1543 |
|
1544 /** @fn wcscpy(wchar_t * s1, const wchar_t * s2) |
|
1545 @param s1 |
|
1546 @param s2 |
|
1547 |
|
1548 Refer to wmemchr() for the documentation |
|
1549 |
|
1550 @see memchr() |
|
1551 @see memcmp() |
|
1552 @see memcpy() |
|
1553 @see memmove() |
|
1554 @see memset() |
|
1555 @see strcat() |
|
1556 @see strchr() |
|
1557 @see strcmp() |
|
1558 @see strcpy() |
|
1559 @see strcspn() |
|
1560 @see strlen() |
|
1561 @see strncat() |
|
1562 @see strncmp() |
|
1563 @see strncpy() |
|
1564 @see strpbrk() |
|
1565 @see strrchr() |
|
1566 @see strspn() |
|
1567 @see strstr() |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 @publishedAll |
|
1573 @externallyDefinedApi |
|
1574 */ |
|
1575 |
|
1576 |
|
1577 /** @fn wcscspn(const wchar_t *s1, const wchar_t *s2) |
|
1578 @param s1 |
|
1579 @param s2 |
|
1580 |
|
1581 Refer to wmemchr() for the documentation |
|
1582 |
|
1583 @see memchr() |
|
1584 @see memcmp() |
|
1585 @see memcpy() |
|
1586 @see memmove() |
|
1587 @see memset() |
|
1588 @see strcat() |
|
1589 @see strchr() |
|
1590 @see strcmp() |
|
1591 @see strcpy() |
|
1592 @see strcspn() |
|
1593 @see strlen() |
|
1594 @see strncat() |
|
1595 @see strncmp() |
|
1596 @see strncpy() |
|
1597 @see strpbrk() |
|
1598 @see strrchr() |
|
1599 @see strspn() |
|
1600 @see strstr() |
|
1601 |
|
1602 |
|
1603 |
|
1604 |
|
1605 @publishedAll |
|
1606 @externallyDefinedApi |
|
1607 */ |
|
1608 |
|
1609 |
|
1610 /** @fn wcsftime(wchar_t * wcs, size_t maxsize, const wchar_t * format, const struct tm * timeptr) |
|
1611 @param wcs |
|
1612 @param maxsize |
|
1613 @param format |
|
1614 @param timeptr |
|
1615 @return wcsftime shall return the number of wide-character codes placed into the array pointed to by wcs , not including the terminating null wide-character code. Otherwise, zero is returned and the contents of the array are unspecified. |
|
1616 |
|
1617 The wcsftime function is equivalent to the strftime function except for the types of its arguments. |
|
1618 Refer to strftime() for a detailed description. |
|
1619 |
|
1620 Examples: |
|
1621 @code |
|
1622 #include <wchar.h> |
|
1623 #include <time.h> |
|
1624 /* Illustatrates how to use wcsftime API */ |
|
1625 int example_wcsftime() |
|
1626 { |
|
1627 wchar_t datestring[50]; |
|
1628 int retval; |
|
1629 struct tm *tm; |
|
1630 |
|
1631 /* get the current time */ |
|
1632 time_t t = time(NULL); |
|
1633 |
|
1634 /* get the local time from the current time */ |
|
1635 tm = localtime(&t;); |
|
1636 /* convert date and time to a wide-character string */ |
|
1637 retval = wcsftime(datestring,15,L"%A",tm); |
|
1638 |
|
1639 /* If the total number of resulting wide-character codes */ |
|
1640 /* including the terminating null wide-character code is */ |
|
1641 /* no more than maxsize, wcsftime() shall return the number */ |
|
1642 /* of wide-character codes placed into the array pointed to */ |
|
1643 /* by wcs, not including the terminating null wide-character */ |
|
1644 /* code. Otherwise, zero is returned and the contents of the */ |
|
1645 /* array are unspecified.*/ |
|
1646 return retval; |
|
1647 } |
|
1648 |
|
1649 @endcode |
|
1650 |
|
1651 |
|
1652 |
|
1653 @publishedAll |
|
1654 @externallyDefinedApi |
|
1655 */ |
|
1656 |
|
1657 |
|
1658 /** @fn wcslen(const wchar_t *s) |
|
1659 @param s |
|
1660 |
|
1661 Refer to wmemchr() for the documentation |
|
1662 |
|
1663 @see memchr() |
|
1664 @see memcmp() |
|
1665 @see memcpy() |
|
1666 @see memmove() |
|
1667 @see memset() |
|
1668 @see strcat() |
|
1669 @see strchr() |
|
1670 @see strcmp() |
|
1671 @see strcpy() |
|
1672 @see strcspn() |
|
1673 @see strlen() |
|
1674 @see strncat() |
|
1675 @see strncmp() |
|
1676 @see strncpy() |
|
1677 @see strpbrk() |
|
1678 @see strrchr() |
|
1679 @see strspn() |
|
1680 @see strstr() |
|
1681 |
|
1682 |
|
1683 |
|
1684 |
|
1685 @publishedAll |
|
1686 @externallyDefinedApi |
|
1687 */ |
|
1688 |
|
1689 |
|
1690 |
|
1691 /** @fn wcsncat(wchar_t * s1, const wchar_t * s2, size_t n) |
|
1692 @param s1 |
|
1693 @param s2 |
|
1694 @param n |
|
1695 |
|
1696 Refer to wmemchr() for the documentation |
|
1697 |
|
1698 @see memchr() |
|
1699 @see memcmp() |
|
1700 @see memcpy() |
|
1701 @see memmove() |
|
1702 @see memset() |
|
1703 @see strcat() |
|
1704 @see strchr() |
|
1705 @see strcmp() |
|
1706 @see strcpy() |
|
1707 @see strcspn() |
|
1708 @see strlen() |
|
1709 @see strncat() |
|
1710 @see strncmp() |
|
1711 @see strncpy() |
|
1712 @see strpbrk() |
|
1713 @see strrchr() |
|
1714 @see strspn() |
|
1715 @see strstr() |
|
1716 |
|
1717 |
|
1718 |
|
1719 |
|
1720 @publishedAll |
|
1721 @externallyDefinedApi |
|
1722 */ |
|
1723 |
|
1724 |
|
1725 |
|
1726 /** @fn wcsncmp(const wchar_t *s1, const wchar_t * s2, size_t n) |
|
1727 @param s1 |
|
1728 @param s2 |
|
1729 @param n |
|
1730 |
|
1731 Refer to wmemchr() for the documentation |
|
1732 |
|
1733 @see memchr() |
|
1734 @see memcmp() |
|
1735 @see memcpy() |
|
1736 @see memmove() |
|
1737 @see memset() |
|
1738 @see strcat() |
|
1739 @see strchr() |
|
1740 @see strcmp() |
|
1741 @see strcpy() |
|
1742 @see strcspn() |
|
1743 @see strlen() |
|
1744 @see strncat() |
|
1745 @see strncmp() |
|
1746 @see strncpy() |
|
1747 @see strpbrk() |
|
1748 @see strrchr() |
|
1749 @see strspn() |
|
1750 @see strstr() |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 @publishedAll |
|
1756 @externallyDefinedApi |
|
1757 */ |
|
1758 |
|
1759 |
|
1760 /** @fn wcsncpy(wchar_t * dst, const wchar_t * src, size_t n) |
|
1761 @param dst |
|
1762 @param src |
|
1763 @param n |
|
1764 |
|
1765 Refer to wmemchr() for the documentation |
|
1766 |
|
1767 @see memchr() |
|
1768 @see memcmp() |
|
1769 @see memcpy() |
|
1770 @see memmove() |
|
1771 @see memset() |
|
1772 @see strcat() |
|
1773 @see strchr() |
|
1774 @see strcmp() |
|
1775 @see strcpy() |
|
1776 @see strcspn() |
|
1777 @see strlen() |
|
1778 @see strncat() |
|
1779 @see strncmp() |
|
1780 @see strncpy() |
|
1781 @see strpbrk() |
|
1782 @see strrchr() |
|
1783 @see strspn() |
|
1784 @see strstr() |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 @publishedAll |
|
1790 @externallyDefinedApi |
|
1791 */ |
|
1792 |
|
1793 |
|
1794 /** @fn wcspbrk(const wchar_t *s1, const wchar_t *s2) |
|
1795 @param s1 |
|
1796 @param s2 |
|
1797 |
|
1798 Refer to wmemchr() for the documentation |
|
1799 |
|
1800 @see memchr() |
|
1801 @see memcmp() |
|
1802 @see memcpy() |
|
1803 @see memmove() |
|
1804 @see memset() |
|
1805 @see strcat() |
|
1806 @see strchr() |
|
1807 @see strcmp() |
|
1808 @see strcpy() |
|
1809 @see strcspn() |
|
1810 @see strlen() |
|
1811 @see strncat() |
|
1812 @see strncmp() |
|
1813 @see strncpy() |
|
1814 @see strpbrk() |
|
1815 @see strrchr() |
|
1816 @see strspn() |
|
1817 @see strstr() |
|
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 @publishedAll |
|
1823 @externallyDefinedApi |
|
1824 */ |
|
1825 |
|
1826 |
|
1827 /** @fn wcsrchr(const wchar_t *s, wchar_t c) |
|
1828 @param s |
|
1829 @param c |
|
1830 |
|
1831 Refer to wmemchr() for the documentation |
|
1832 |
|
1833 @see memchr() |
|
1834 @see memcmp() |
|
1835 @see memcpy() |
|
1836 @see memmove() |
|
1837 @see memset() |
|
1838 @see strcat() |
|
1839 @see strchr() |
|
1840 @see strcmp() |
|
1841 @see strcpy() |
|
1842 @see strcspn() |
|
1843 @see strlen() |
|
1844 @see strncat() |
|
1845 @see strncmp() |
|
1846 @see strncpy() |
|
1847 @see strpbrk() |
|
1848 @see strrchr() |
|
1849 @see strspn() |
|
1850 @see strstr() |
|
1851 |
|
1852 |
|
1853 |
|
1854 |
|
1855 @publishedAll |
|
1856 @externallyDefinedApi |
|
1857 */ |
|
1858 |
|
1859 |
|
1860 /** @fn wcsrtombs(char * dst, const wchar_t ** src, size_t len, mbstate_t * ps) |
|
1861 @param dst |
|
1862 @param src |
|
1863 @param len |
|
1864 @param ps |
|
1865 |
|
1866 Note: This description also covers the following functions - |
|
1867 wcsnrtombs() |
|
1868 |
|
1869 @return The wcsrtombs and wcsnrtombs functions return the number of bytes stored in |
|
1870 the array pointed to by dst (not including any terminating null), if successful, otherwise it returns ( size_t-1) . |
|
1871 |
|
1872 The wcsrtombs function converts a string of wide characters indirectly pointed to by src to a corresponding multibyte character string stored in the array |
|
1873 pointed to by dst . |
|
1874 No more than len bytes are written to dst . |
|
1875 |
|
1876 If dst is NULL , |
|
1877 no characters are stored. |
|
1878 |
|
1879 If dst is not NULL , |
|
1880 the pointer pointed to by src is updated to point to the character after the one that conversion stopped at. |
|
1881 If conversion stops because a null character is encountered, *src is set to NULL . |
|
1882 |
|
1883 The mbstate_t |
|
1884 argument, ps , |
|
1885 is used to keep track of the shift state. |
|
1886 If it is NULL , wcsrtombs uses an internal, static mbstate_t |
|
1887 object, which is initialized to the initial conversion state |
|
1888 at program startup. |
|
1889 |
|
1890 The wcsnrtombs function behaves identically to wcsrtombs , |
|
1891 except that conversion stops after reading at most nwc characters from the buffer pointed to by src . |
|
1892 The behavior of the wcsrtombs and wcsrntombs is affected by LC_CTYPE category of the current locale. |
|
1893 |
|
1894 Examples: |
|
1895 @code |
|
1896 #include <stdlib.h> |
|
1897 #include <wchar.h> |
|
1898 /* Illustrates how to use wcsrtombs API */ |
|
1899 size_t example_wcsrtombs(wchar_t *wcs, char *s, size_t n) |
|
1900 { |
|
1901 size_t len; |
|
1902 mstate_t mbs; |
|
1903 /* converting multibyte string to a wide-char string */ |
|
1904 len = wcsrtombs(s, &wcs;, n, &mbs;); |
|
1905 /* returning no of bytes that make up the multibyte sequence */ |
|
1906 return (len;); |
|
1907 } |
|
1908 |
|
1909 @endcode |
|
1910 @code |
|
1911 #include <stdlib.h> |
|
1912 #include <wchar.h> |
|
1913 /* Illustrates how to use wcsnrtombs API */ |
|
1914 size_t example_wcsnrtombs(wchar_t *wcs, char *s, size_t n, szie_t nmwc) |
|
1915 { |
|
1916 size_t len; |
|
1917 mstate_t mbs; |
|
1918 /* converting multibyte string to a wide-char string */ |
|
1919 len = wcsrtombs(s, &wcs;, nwc, n, &mbs;); |
|
1920 /* returning no of bytes that make up the multibyte sequence */ |
|
1921 return (len;); |
|
1922 } |
|
1923 |
|
1924 @endcode |
|
1925 |
|
1926 Limitations: |
|
1927 |
|
1928 The current implementation of wcsrtombs and wcsnrtombs is not affected by the LC_CTYPE category of the current locale. |
|
1929 It works only for UTF8 character set. |
|
1930 |
|
1931 @see mbsrtowcs() |
|
1932 @see wcrtomb() |
|
1933 @see wcstombs() |
|
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 @publishedAll |
|
1939 @externallyDefinedApi |
|
1940 */ |
|
1941 |
|
1942 |
|
1943 /** @fn wcsspn(const wchar_t *s1, const wchar_t *s2) |
|
1944 @param s1 |
|
1945 @param s2 |
|
1946 |
|
1947 Refer to wmemchr() for the documentation |
|
1948 |
|
1949 @see memchr() |
|
1950 @see memcmp() |
|
1951 @see memcpy() |
|
1952 @see memmove() |
|
1953 @see memset() |
|
1954 @see strcat() |
|
1955 @see strchr() |
|
1956 @see strcmp() |
|
1957 @see strcpy() |
|
1958 @see strcspn() |
|
1959 @see strlen() |
|
1960 @see strncat() |
|
1961 @see strncmp() |
|
1962 @see strncpy() |
|
1963 @see strpbrk() |
|
1964 @see strrchr() |
|
1965 @see strspn() |
|
1966 @see strstr() |
|
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 @publishedAll |
|
1972 @externallyDefinedApi |
|
1973 */ |
|
1974 |
|
1975 |
|
1976 |
|
1977 /** @fn wcsstr(const wchar_t * s, const wchar_t * find) |
|
1978 @param s |
|
1979 @param find |
|
1980 |
|
1981 Refer to wmemchr() for the documentation |
|
1982 |
|
1983 @see memchr() |
|
1984 @see memcmp() |
|
1985 @see memcpy() |
|
1986 @see memmove() |
|
1987 @see memset() |
|
1988 @see strcat() |
|
1989 @see strchr() |
|
1990 @see strcmp() |
|
1991 @see strcpy() |
|
1992 @see strcspn() |
|
1993 @see strlen() |
|
1994 @see strncat() |
|
1995 @see strncmp() |
|
1996 @see strncpy() |
|
1997 @see strpbrk() |
|
1998 @see strrchr() |
|
1999 @see strspn() |
|
2000 @see strstr() |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 @publishedAll |
|
2006 @externallyDefinedApi |
|
2007 */ |
|
2008 |
|
2009 |
|
2010 |
|
2011 /** @fn wcsxfrm(wchar_t * dest, const wchar_t * src, size_t len) |
|
2012 @param dest |
|
2013 @param src |
|
2014 @param len |
|
2015 @return Upon successful completion, wcsxfrm returns the length of the transformed string not including |
|
2016 the terminating null character. |
|
2017 If this value is len or more, the contents of dest are indeterminate. |
|
2018 |
|
2019 The wcsxfrm function transforms a null-terminated wide character string pointed to by src according to the current locale collation order |
|
2020 then copies the transformed string |
|
2021 into dest . |
|
2022 No more than len wide characters are copied into dest , |
|
2023 including the terminating null character added. |
|
2024 If len is set to 0 |
|
2025 (it helps to determine an actual size needed |
|
2026 for transformation), dest is permitted to be a NULL pointer. |
|
2027 |
|
2028 Comparing two strings using wcscmp after wcsxfrm is equivalent to comparing |
|
2029 two original strings with wcscoll . |
|
2030 |
|
2031 Examples: |
|
2032 @code |
|
2033 #include <stdlib.h> |
|
2034 #include <wchar.h> |
|
2035 /* Illustrates how to use wcpcpy API */ |
|
2036 int example_wcpcpy() |
|
2037 { |
|
2038 /* input string for which length to be found */ |
|
2039 wchar_t *src = L"testcase"; |
|
2040 wchar_t *dest = NULL; |
|
2041 int length; |
|
2042 |
|
2043 /* allocate memory for the destination string */ |
|
2044 dest = (wchar_t *)malloc((wcslen(src)+1)*sizeof(wchar_t)); |
|
2045 |
|
2046 /* perform the operation */ |
|
2047 if(dest != NULL) |
|
2048 length = wcsxfrm(dest,src,9); |
|
2049 else |
|
2050 { |
|
2051 wprintf(L"ERROR : Cannot allocate memory"); |
|
2052 return -1; |
|
2053 } |
|
2054 return length; |
|
2055 } |
|
2056 |
|
2057 @endcode |
|
2058 |
|
2059 Limitations: |
|
2060 |
|
2061 The current implementation of wcsxfrm works only for "C" locale. |
|
2062 |
|
2063 @see setlocale() |
|
2064 @see strxfrm() |
|
2065 @see wcscmp() |
|
2066 @see wcscoll() |
|
2067 |
|
2068 |
|
2069 Bugs: |
|
2070 |
|
2071 The current implementation of wcsxfrm only works in single-byte LC_CTYPE locales, and falls back to using wcsncpy in locales with extended character sets. Comparing two strings using wcscmp after wcsxfrm is not always equivalent to comparison with wcscoll ; wcsxfrm only stores information about primary collation weights into dst , |
|
2072 whereas wcscoll compares characters using both primary and secondary weights. |
|
2073 |
|
2074 |
|
2075 |
|
2076 @publishedAll |
|
2077 @externallyDefinedApi |
|
2078 */ |
|
2079 |
|
2080 |
|
2081 |
|
2082 /** @fn wctob(wint_t c) |
|
2083 @param c |
|
2084 |
|
2085 Refer to btowc() for the documentation |
|
2086 |
|
2087 @see mbrtowc() |
|
2088 @see wcrtomb() |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 @publishedAll |
|
2094 @externallyDefinedApi |
|
2095 */ |
|
2096 |
|
2097 |
|
2098 |
|
2099 /** @fn wcstod(const wchar_t * nptr, wchar_t ** endptr) |
|
2100 @param nptr |
|
2101 @param endptr |
|
2102 |
|
2103 Refer to wcstof() for the documentation |
|
2104 |
|
2105 @see strtod() |
|
2106 @see wcstol() |
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 @publishedAll |
|
2112 @externallyDefinedApi |
|
2113 */ |
|
2114 |
|
2115 |
|
2116 |
|
2117 /** @fn wcstok(wchar_t * s, const wchar_t * delim, wchar_t ** last) |
|
2118 @param s |
|
2119 @param delim |
|
2120 @param last |
|
2121 @return The wcstok function |
|
2122 returns a pointer to the beginning of each subsequent token in the string, |
|
2123 after replacing the token itself with a null wide character (L'//0'). |
|
2124 When no more tokens remain, a null pointer is returned. |
|
2125 |
|
2126 The wcstok function |
|
2127 is used to isolate sequential tokens in a null-terminated wide character |
|
2128 string, s. |
|
2129 These tokens are separated in the string by at least one of the |
|
2130 characters in delim . |
|
2131 The first time that wcstok is called, s should be specified; subsequent calls, wishing to obtain further tokens |
|
2132 from the same string, should pass a null pointer instead. |
|
2133 The separator string, delim , |
|
2134 must be supplied each time, and may change between calls. |
|
2135 The context pointer last must be provided on each call. |
|
2136 |
|
2137 The wcstok function is the wide character counterpart of the strtok_r function. |
|
2138 |
|
2139 |
|
2140 Examples: |
|
2141 |
|
2142 @code |
|
2143 #include <wchar.h> |
|
2144 /* Illustrates how to use wcstok API */ |
|
2145 int example_wcstok() |
|
2146 { |
|
2147 /* source wide character string */ |
|
2148 const wchar_t *seps = L"onetwhr"; |
|
2149 wchar_t *last, *tok, text[] = L"onetwothree"; |
|
2150 |
|
2151 tok = wcstok(text, seps, &last;); |
|
2152 if(tok == NULL) |
|
2153 return 0; |
|
2154 else |
|
2155 return 1; |
|
2156 } |
|
2157 |
|
2158 @endcode |
|
2159 |
|
2160 Examples: |
|
2161 |
|
2162 The following code fragment splits a wide character string on ASCII space, tab and newline characters and writes the tokens to |
|
2163 standard output: |
|
2164 |
|
2165 @code |
|
2166 const wchar_t *seps = L" |
|
2167 "; |
|
2168 wchar_t *last, *tok, text[] = L" |
|
2169 one two three |
|
2170 "; |
|
2171 for (tok = wcstok(text, seps, &last;); tok != NULL; |
|
2172 tok = wcstok(NULL, seps, &last;)) |
|
2173 wprintf(L"%ls |
|
2174 ", tok); |
|
2175 |
|
2176 @endcode |
|
2177 @see strtok() |
|
2178 @see wcschr() |
|
2179 @see wcscspn() |
|
2180 @see wcspbrk() |
|
2181 @see wcsrchr() |
|
2182 @see wcsspn() |
|
2183 |
|
2184 |
|
2185 Some early implementations of wcstok omit the context pointer argument, last, and maintain state across calls in a static variable like strtok does. |
|
2186 |
|
2187 |
|
2188 @publishedAll |
|
2189 @externallyDefinedApi |
|
2190 */ |
|
2191 |
|
2192 |
|
2193 |
|
2194 /** @fn wcstol(const wchar_t * nptr, wchar_t ** endptr, int base) |
|
2195 @param nptr |
|
2196 @param endptr |
|
2197 @param base |
|
2198 |
|
2199 Note: This description also covers the following functions - |
|
2200 wcstoul() wcstoll() wcstoull() wcstoq() wcstouq() wcstoimax() wcstoumax() |
|
2201 |
|
2202 @return errno may be set to indicate the error. If the correct value is outside |
|
2203 the range of representable values {LONG_MIN}, {LONG_MAX}, {LLONG_MIN}, or {LLONG_MAX} |
|
2204 is returned (according to the sign of the value) and errno set to [ERANGE]. |
|
2205 |
|
2206 The wcstol , wcstoul , wcstoll , wcstoull , wcstoimax and wcstoumax functions are wide-character versions of the strtol , strtoul , strtoll , strtoull , strtoimax and strtoumax functions, respectively. |
|
2207 Refer to their manual pages (for example strtol ) |
|
2208 for details. |
|
2209 The wcstoq and wcstouq are respectively equivalent to wcstoll and wcstoull. |
|
2210 |
|
2211 Examples: |
|
2212 @code |
|
2213 #include <wchar.h> |
|
2214 /* Illustrates how to use wcstoumax API */ |
|
2215 uintmax_t example_wcstoumax() |
|
2216 { |
|
2217 /* src string */ |
|
2218 wchar_t *src = L"478"; |
|
2219 uintmax_t longVal; |
|
2220 |
|
2221 /* convert the wide character string to uintmax_t */ |
|
2222 longVal = wcstoumax(src,NULL,10); |
|
2223 /* return the converted long value */ |
|
2224 return longVal; |
|
2225 } |
|
2226 |
|
2227 @endcode |
|
2228 @code |
|
2229 #include <wchar.h> |
|
2230 /* Illustrates how to use wcstoimax API */ |
|
2231 intmax_t example_wcstoimax() |
|
2232 { |
|
2233 /* src string */ |
|
2234 wchar_t *src = L"478"; |
|
2235 intmax_t longVal; |
|
2236 |
|
2237 /* convert the wide character string to intmax_t */ |
|
2238 longVal = wcstoimax(src,NULL,10); |
|
2239 /* return the converted long value */ |
|
2240 return longVal; |
|
2241 } |
|
2242 |
|
2243 @endcode |
|
2244 @code |
|
2245 #include <wchar.h> |
|
2246 /* Illustrates how to use wcstol API */ |
|
2247 long example_wcstol() |
|
2248 { |
|
2249 /* src string */ |
|
2250 wchar_t *src = L"478"; |
|
2251 long longVal; |
|
2252 |
|
2253 /* call the API to convert src string to long value */ |
|
2254 longVal = wcstol(src,NULL,10); |
|
2255 /* return the converted long value */ |
|
2256 return longVal; |
|
2257 } |
|
2258 |
|
2259 @endcode |
|
2260 @code |
|
2261 #include <wchar.h> |
|
2262 /* Illustrates how to use wcstoul API */ |
|
2263 unsigned long example_wcstoul() |
|
2264 { |
|
2265 /* src string */ |
|
2266 wchar_t *src = L"478"; |
|
2267 unsigned long longVal; |
|
2268 |
|
2269 /* call the API to convert src string to unsigned */ |
|
2270 /* long value */ |
|
2271 longVal = wcstoul(src,NULL,10); |
|
2272 /* return the converted long value */ |
|
2273 return longVal; |
|
2274 } |
|
2275 |
|
2276 @endcode |
|
2277 @code |
|
2278 #include <wchar.h> |
|
2279 /* Illustatrates how to use wcstoll API */ |
|
2280 long long example_wcstoll() |
|
2281 { |
|
2282 /* input string for which length to be found */ |
|
2283 wchar_t *src = L"478"; |
|
2284 long long longVal; |
|
2285 |
|
2286 /* perform the conversion operation from wide */ |
|
2287 /* char string to long long value */ |
|
2288 longVal = wcstoll(src,NULL,10); |
|
2289 |
|
2290 return longVal; |
|
2291 } |
|
2292 |
|
2293 @endcode |
|
2294 @code |
|
2295 #include <wchar.h> |
|
2296 /* Illustatrates how to use wcstoull API */ |
|
2297 unsigned long long example_wcstoull() |
|
2298 { |
|
2299 /* input string for which length to be found */ |
|
2300 wchar_t *src = L"478"; |
|
2301 unsigned long long longVal; |
|
2302 |
|
2303 /* perform the conversion operation from wide */ |
|
2304 /*char string to unsigned long long value */ |
|
2305 longVal = wcstoull(src,NULL,10); |
|
2306 |
|
2307 return longVal; |
|
2308 } |
|
2309 |
|
2310 @endcode |
|
2311 @code |
|
2312 #include <wchar.h> |
|
2313 /* Illustrates how to use wcstoq API */ |
|
2314 long long int example_wcstoq() |
|
2315 { |
|
2316 /* src string that contains decimal digits */ |
|
2317 wchar_t *src = L"478"; |
|
2318 long long int longVal; |
|
2319 /* convert the decimal wide char string to long long int value */ |
|
2320 longVal = wcstoq(src,NULL,10); |
|
2321 /* return longVal and its value should be 478 */ |
|
2322 return longVal; |
|
2323 } |
|
2324 |
|
2325 @endcode |
|
2326 @code |
|
2327 #include <wchar.h> |
|
2328 /* Illustrates how to use wcstouq API */ |
|
2329 unsigned long long int example_wcstouq() |
|
2330 { |
|
2331 /* src string that contains decimal digits */ |
|
2332 wchar_t *src = L"478"; |
|
2333 unsigned long long int longVal; |
|
2334 /* convert the decimal wide char string to unsigned long long int value */ |
|
2335 longVal = wcstouq(src,NULL,10); |
|
2336 /* return longVal, which should be 478 */ |
|
2337 return longVal; |
|
2338 } |
|
2339 |
|
2340 @endcode |
|
2341 @see strtol() |
|
2342 @see strtoul() |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 @publishedAll |
|
2348 @externallyDefinedApi |
|
2349 */ |
|
2350 |
|
2351 |
|
2352 |
|
2353 /** @fn wcstoul(const wchar_t * nptr, wchar_t ** endptr, int base) |
|
2354 @param nptr |
|
2355 @param endptr |
|
2356 @param base |
|
2357 |
|
2358 Refer to wcstol() for the documentation |
|
2359 |
|
2360 @see strtol() |
|
2361 @see strtoul() |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 @publishedAll |
|
2367 @externallyDefinedApi |
|
2368 */ |
|
2369 |
|
2370 |
|
2371 |
|
2372 /** @fn wmemchr(const wchar_t *s, wchar_t c, size_t n) |
|
2373 @param s |
|
2374 @param c |
|
2375 @param n |
|
2376 |
|
2377 Note: This description also covers the following functions - |
|
2378 wmemcmp() wmemcpy() wmemmove() wmemset() wcscat() wcschr() wcscmp() wcscpy() wcscspn() wcslcat() wcslcpy() wcslen() wcsncat() wcsncmp() wcsncpy() wcspbrk() wcsrchr() wcsspn() wcsstr() |
|
2379 |
|
2380 @return wmemchr function returns a pointer to the first occurrence of c among the n wide characters starting at s , or NULL if c does not occur among these. wcslcpy function returns wcslen(src); if retval \>= siz, truncation occurred wcslcat function returns wcslen(initial dst) + wcslen(src); if retval \>= sizet, |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 The function wcslcat() appends a copy of the wide-character string |
|
2387 pointed to by s2 (including the terminating null wide-character code) to the end |
|
2388 of the wide-character string pointed to by s1. The initial wide-character code |
|
2389 of string pointed to by s2 overwrites the null wide-character code at the end of s1. wcslcat() concatenates at most n-1 characters. |
|
2390 |
|
2391 |
|
2392 |
|
2393 The function wcslcpy() copies the wide-character string pointed to by s2 (including the terminating null wide-character code) into the array pointed to by s1. |
|
2394 It will copy at most n-1 characters. |
|
2395 |
|
2396 |
|
2397 |
|
2398 The functions implement string manipulation operations over wide character |
|
2399 strings. |
|
2400 For a detailed description, refer to documents for the respective single-byte |
|
2401 counterpart, such as memchr . |
|
2402 |
|
2403 Examples: |
|
2404 @code |
|
2405 #include <wchar.h> |
|
2406 /* Illustrates how to use wmemcmp API */ |
|
2407 int example_wmemcmp() |
|
2408 { |
|
2409 /* source wide character string */ |
|
2410 wchar_t *ws1 = L"test case",*ws2 = L"test case"; |
|
2411 int retval; |
|
2412 /* comparing the 2 wide-char strings */ |
|
2413 retval = wmemcmp(ws1,ws2,500); |
|
2414 /* checking for the return value */ |
|
2415 if(retval != 0) |
|
2416 return 1; |
|
2417 else |
|
2418 return 0; |
|
2419 } |
|
2420 |
|
2421 @endcode |
|
2422 @code |
|
2423 #include <wchar.h> |
|
2424 /* Illustrates how to use wmemcpy API */ |
|
2425 int example_wmemcpy() |
|
2426 { |
|
2427 /* source wide character string */ |
|
2428 wchar_t ws1[50]=L"abcdefghij",*retval,ws2[50]=L"test"; |
|
2429 /* compare the strings */ |
|
2430 retval = wmemcpy(ws1,ws2,6); |
|
2431 for(int i=0;i<6;i++) |
|
2432 { |
|
2433 if(retval[i] != ws2[i] || ws1[i] != ws2[i]) |
|
2434 return 1; |
|
2435 } |
|
2436 return 0; |
|
2437 } |
|
2438 |
|
2439 @endcode |
|
2440 @code |
|
2441 #include <wchar.h> |
|
2442 /* Illustrates how to use wmemmove API */ |
|
2443 int example_wmemmove() |
|
2444 { |
|
2445 /* source wide character string */ |
|
2446 wchar_t ws1[50]=L"abcdefghij",*retval,ws2[5] = L"abc"; |
|
2447 int i; |
|
2448 |
|
2449 /* move the contents of ws2 to ws1 */ |
|
2450 retval = wmemmove(ws1,ws2,3); |
|
2451 /* compare the contents */ |
|
2452 for(i=0;i<3;i++) |
|
2453 { |
|
2454 if(ws1[i] != ws2[i]) |
|
2455 return 1; |
|
2456 } |
|
2457 return 0; |
|
2458 } |
|
2459 |
|
2460 @endcode |
|
2461 @code |
|
2462 #include <wchar.h> |
|
2463 /* Illustrates how to use wmemset API */ |
|
2464 int example_wmemset() |
|
2465 { |
|
2466 /* source wide character string */ |
|
2467 wchar_t ws1[50]=L"abcdefghij", *retval; |
|
2468 int i; |
|
2469 /* setting the wide-string ws1 */ |
|
2470 retval = wmemset(ws1,L'a',7); |
|
2471 /* comparing the contents */ |
|
2472 for(i=0;i<7;i++) |
|
2473 { |
|
2474 if(ws1[i] != L'a') |
|
2475 return 1; |
|
2476 } |
|
2477 return 0; |
|
2478 } |
|
2479 |
|
2480 @endcode |
|
2481 @code |
|
2482 #include <wchar.h> |
|
2483 /* Illustrates how to use wmemchr API */ |
|
2484 wchar_t *example_wmemchr(void) |
|
2485 { |
|
2486 wchar_t *wcs = L"lmnopqr"; |
|
2487 size_t n; |
|
2488 wchar_t wc = L'p'; |
|
2489 wchar_t *res; |
|
2490 /* number of wide characters to be searched */ |
|
2491 n = wcslen(wcs); |
|
2492 /* search for the occurence of wchar wc in wide-char string wcs */ |
|
2493 res = wmemchr(wcs, wc, n); |
|
2494 /* return the pointer */ |
|
2495 return(res); |
|
2496 } |
|
2497 |
|
2498 @endcode |
|
2499 @code |
|
2500 #include <wchar.h> |
|
2501 /* Illustrates how to use wcslen API */ |
|
2502 size_t example_wcslen(void) |
|
2503 { |
|
2504 wchar_t *wcs = L"defqwert"; |
|
2505 size_t len; |
|
2506 /* compute the length of the wide-char string */ |
|
2507 len = wcslen(wcs); |
|
2508 /* return the length of the wide-char string */ |
|
2509 return (len); |
|
2510 } |
|
2511 |
|
2512 @endcode |
|
2513 @code |
|
2514 #include <wchar.h> |
|
2515 /* Illustrates how to use wcscat API */ |
|
2516 void example_wcscat(void) |
|
2517 { |
|
2518 wchar_t wcs[100] = L"abc"; |
|
2519 wchar_t *wcs1 = L"def"; |
|
2520 wchar *res; |
|
2521 /* concatenate the two strings */ |
|
2522 res = wcscat(wcs, wcs1); |
|
2523 /* print the string that resulted from concatenation */ |
|
2524 wprintf(L"Output wide-char string is : %ls |
|
2525 ",res); |
|
2526 } |
|
2527 |
|
2528 @endcode |
|
2529 Output |
|
2530 @code |
|
2531 abcdef |
|
2532 |
|
2533 @endcode |
|
2534 @code |
|
2535 #include <wchar.h> |
|
2536 /* Illustrates how to use wcschr API */ |
|
2537 int example_ wcschr () |
|
2538 { |
|
2539 /* source wide character string */ |
|
2540 wchar_t search_char[15] = L"&&&&$%%%%%TTU"; |
|
2541 wchar_t *wstr; |
|
2542 int i ; |
|
2543 for(i = 0 ; search_char[i]; i++) |
|
2544 { |
|
2545 wstr = wcschr(L"", search_char[i]); |
|
2546 if(wstr != NULL) |
|
2547 { |
|
2548 return -1; |
|
2549 } |
|
2550 } |
|
2551 return 0; |
|
2552 } |
|
2553 |
|
2554 @endcode |
|
2555 @code |
|
2556 int example_wcscmp() |
|
2557 { |
|
2558 /* source wide character string */ |
|
2559 wchar_t *wcs1 = "string1"; |
|
2560 wchar_t *wcs2 = "string2"; |
|
2561 int i ; |
|
2562 i = wcscmp(wcs1, wcs2); |
|
2563 if( i == 0) |
|
2564 return -1; |
|
2565 |
|
2566 i = wcscmp(wcs1, L"string1"); |
|
2567 if(i != 0) |
|
2568 return -1; |
|
2569 |
|
2570 return 0; |
|
2571 } |
|
2572 |
|
2573 @endcode |
|
2574 @code |
|
2575 #include <wchar.h> |
|
2576 /* Illustrates how to use wcscpy API */ |
|
2577 int example_wcscpy () |
|
2578 { |
|
2579 /* source wide character string */ |
|
2580 wchar_t wcs1[15]; |
|
2581 wchar_t *res; |
|
2582 |
|
2583 /* copy the wide-char string into wcs1*/ |
|
2584 res = wcscpy(wcs1, L"Hello world"); |
|
2585 |
|
2586 if(wcscmp(res, L"Hello world") != 0) |
|
2587 return -1; |
|
2588 |
|
2589 return 0; |
|
2590 } |
|
2591 |
|
2592 @endcode |
|
2593 @code |
|
2594 #include <wchar.h> |
|
2595 /* Illustrates how to use wcslcpy API */ |
|
2596 int example_wcslcpy () |
|
2597 { |
|
2598 /* source wide character string */ |
|
2599 wchar_t src[25] = L"Source"; |
|
2600 wchar_t dest[20]= L"Destination"; |
|
2601 |
|
2602 /* copy the wide-char string into dest*/ |
|
2603 |
|
2604 size_t t = wcslcpy(dest,src,4); |
|
2605 |
|
2606 if(wcscmp(dest,L"Sou")!=0) |
|
2607 return -1; |
|
2608 |
|
2609 return 0; |
|
2610 } |
|
2611 |
|
2612 @endcode |
|
2613 @code |
|
2614 #include <wchar.h> |
|
2615 /* Illustrates how to use wcslcat API */ |
|
2616 int example_wcslcat () |
|
2617 { |
|
2618 /* source wide character string */ |
|
2619 wchar_t src[25] = L"Source"; |
|
2620 wchar_t dest[20]= L"Destination"; |
|
2621 |
|
2622 /* concate the wide-char string into dest*/ |
|
2623 |
|
2624 size_t t = wcslcat(dest,src,14); |
|
2625 |
|
2626 if(wcscmp(dest,"DestinationSo")!=0) |
|
2627 return -1; |
|
2628 |
|
2629 return 0; |
|
2630 } |
|
2631 |
|
2632 @endcode |
|
2633 @code |
|
2634 #include <wchar.h> |
|
2635 /* Illustrates how to use wcscspnAPI */ |
|
2636 int example_wcscspn () |
|
2637 { |
|
2638 /* source wide character string */ |
|
2639 wchar_t wcs1[30] = L"1234567890ABCDE!@#$$"; |
|
2640 wchar_t *wcs2[20] = { L"abcdefghijkl", |
|
2641 L":::?>_)+(|{>", |
|
2642 L"~*(&IUIJJJ;", |
|
2643 L"1234567", |
|
2644 L":::?>", |
|
2645 L"1", |
|
2646 L"as1sd2ds3ds48f5fd" |
|
2647 }; |
|
2648 int i; |
|
2649 |
|
2650 for( i = 0; i < 3 ; i ++) |
|
2651 { |
|
2652 if( wcslen(wcs1) != wcscspn(wcs1,wcs2[i])) |
|
2653 return -1; |
|
2654 } |
|
2655 |
|
2656 return 0; |
|
2657 } |
|
2658 |
|
2659 @endcode |
|
2660 @code |
|
2661 #include <wchar.h> |
|
2662 /* Illustrates how to use wcsncat API */ |
|
2663 int example_wcsncat () |
|
2664 { |
|
2665 /* source wide character string */ |
|
2666 wchar_t *res; |
|
2667 wchar_t str[50]; |
|
2668 |
|
2669 wcscpy(str, L"Hello"); |
|
2670 res = wcsncat(str,L" world",12); |
|
2671 if(wcscmp(str, L"Hello world") != 0) |
|
2672 return -1; |
|
2673 else |
|
2674 return 0; |
|
2675 } |
|
2676 |
|
2677 @endcode |
|
2678 @code |
|
2679 #include <wchar.h> |
|
2680 /* Illustrates how to use wcsncmp API */ |
|
2681 int example_wcsncmp() |
|
2682 { |
|
2683 /* source wide character string */ |
|
2684 wchar_t *wcs1 = L"Hello world"; |
|
2685 if(wcsncmp(wcs1,wcs1,wcslen(wcs1))) |
|
2686 return -1; |
|
2687 else |
|
2688 return 0; |
|
2689 } |
|
2690 |
|
2691 @endcode |
|
2692 @code |
|
2693 #include <wchar.h> |
|
2694 /* Illustrates how to use wcsncpy API */ |
|
2695 int example_wcsncpy () |
|
2696 { |
|
2697 /* source wide character string */ |
|
2698 wchar_t wcs1[15] = L"Hello world"; |
|
2699 wchar_t *res; |
|
2700 res = wcsncpy(wcs1,wcs1,wcslen(wcs1)); |
|
2701 if(wcscmp(res,wcs1)) |
|
2702 return -1; |
|
2703 return 0; |
|
2704 } |
|
2705 |
|
2706 @endcode |
|
2707 @code |
|
2708 #include <wchar.h> |
|
2709 /* Illustrates how to use wcspbrk API */ |
|
2710 int example_wcspbrk () |
|
2711 { |
|
2712 /* source wide character string */ |
|
2713 wchar_t *wcs = L"abcdefghijkl"; |
|
2714 wchar_t *res1 = wcspbrk(wcs, L""); |
|
2715 if(res1 != NULL) |
|
2716 return -1; |
|
2717 |
|
2718 return 0; |
|
2719 } |
|
2720 |
|
2721 @endcode |
|
2722 @code |
|
2723 #include <wchar.h> |
|
2724 /* Illustrates how to use wcsrchr API */ |
|
2725 int example_wcsrchr () |
|
2726 { |
|
2727 /* source wide character string */ |
|
2728 wchar_t search_char[15] = L"&&&&$%%%%%TTU"; |
|
2729 wchar_t *wstr; |
|
2730 int i ; |
|
2731 |
|
2732 for(i = 0 ; search_char[i]; i++) |
|
2733 { |
|
2734 wstr = wcsrchr(L"", search_char[i]); |
|
2735 if(wstr != NULL) |
|
2736 { |
|
2737 return -1; |
|
2738 } |
|
2739 } |
|
2740 return 0; |
|
2741 } |
|
2742 |
|
2743 @endcode |
|
2744 @code |
|
2745 #include <wchar.h> |
|
2746 /* Illustrates how to use wcsspn API */ |
|
2747 int example_wcsspn() |
|
2748 { |
|
2749 /* source wide character string */ |
|
2750 wchar_t wcs1[30] = L"1234567890ABCDE!@#$$"; |
|
2751 if(wcslen(wcs1) != wcsspn(wcs1,wcs1)) |
|
2752 return -1; |
|
2753 return 0; |
|
2754 } |
|
2755 |
|
2756 @endcode |
|
2757 @code |
|
2758 #include <wchar.h> |
|
2759 /* Illustrates how to use wcsstr API */ |
|
2760 int example_wcsstr() |
|
2761 { |
|
2762 /* source wide character string */ |
|
2763 wchar_t *buf[20] = { L"fkhsdf%%38",L"rtti123123", }; |
|
2764 wchar_t *str = wcsstr(buf[0],L"\0"); |
|
2765 wchar_t *str1 = wcsstr(buf[1],L"\0"); |
|
2766 if(wcscmp(str,buf[0])) |
|
2767 return 1; |
|
2768 if(wcscmp(str1,buf[1])) |
|
2769 return 1 |
|
2770 return 0; |
|
2771 } |
|
2772 |
|
2773 @endcode |
|
2774 @see memchr() |
|
2775 @see memcmp() |
|
2776 @see memcpy() |
|
2777 @see memmove() |
|
2778 @see memset() |
|
2779 @see strcat() |
|
2780 @see strchr() |
|
2781 @see strcmp() |
|
2782 @see strcpy() |
|
2783 @see strcspn() |
|
2784 @see strlen() |
|
2785 @see strncat() |
|
2786 @see strncmp() |
|
2787 @see strncpy() |
|
2788 @see strpbrk() |
|
2789 @see strrchr() |
|
2790 @see strspn() |
|
2791 @see strstr() |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 @publishedAll |
|
2797 @externallyDefinedApi |
|
2798 */ |
|
2799 |
|
2800 |
|
2801 |
|
2802 /** @fn wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) |
|
2803 @param s1 |
|
2804 @param s2 |
|
2805 @param n |
|
2806 |
|
2807 Refer to wmemchr() for the documentation |
|
2808 |
|
2809 @see memchr() |
|
2810 @see memcmp() |
|
2811 @see memcpy() |
|
2812 @see memmove() |
|
2813 @see memset() |
|
2814 @see strcat() |
|
2815 @see strchr() |
|
2816 @see strcmp() |
|
2817 @see strcpy() |
|
2818 @see strcspn() |
|
2819 @see strlen() |
|
2820 @see strncat() |
|
2821 @see strncmp() |
|
2822 @see strncpy() |
|
2823 @see strpbrk() |
|
2824 @see strrchr() |
|
2825 @see strspn() |
|
2826 @see strstr() |
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 @publishedAll |
|
2832 @externallyDefinedApi |
|
2833 */ |
|
2834 |
|
2835 |
|
2836 |
|
2837 /** @fn wmemcpy(wchar_t * s1, const wchar_t * s2, size_t n) |
|
2838 @param s1 |
|
2839 @param s2 |
|
2840 @param n |
|
2841 |
|
2842 Refer to wmemchr() for the documentation |
|
2843 |
|
2844 @see memchr() |
|
2845 @see memcmp() |
|
2846 @see memcpy() |
|
2847 @see memmove() |
|
2848 @see memset() |
|
2849 @see strcat() |
|
2850 @see strchr() |
|
2851 @see strcmp() |
|
2852 @see strcpy() |
|
2853 @see strcspn() |
|
2854 @see strlen() |
|
2855 @see strncat() |
|
2856 @see strncmp() |
|
2857 @see strncpy() |
|
2858 @see strpbrk() |
|
2859 @see strrchr() |
|
2860 @see strspn() |
|
2861 @see strstr() |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 @publishedAll |
|
2867 @externallyDefinedApi |
|
2868 */ |
|
2869 |
|
2870 |
|
2871 |
|
2872 /** @fn wmemmove(wchar_t *s1, const wchar_t *s2, size_t n) |
|
2873 @param s1 |
|
2874 @param s2 |
|
2875 @param n |
|
2876 |
|
2877 Refer to wmemchr() for the documentation |
|
2878 |
|
2879 @see memchr() |
|
2880 @see memcmp() |
|
2881 @see memcpy() |
|
2882 @see memmove() |
|
2883 @see memset() |
|
2884 @see strcat() |
|
2885 @see strchr() |
|
2886 @see strcmp() |
|
2887 @see strcpy() |
|
2888 @see strcspn() |
|
2889 @see strlen() |
|
2890 @see strncat() |
|
2891 @see strncmp() |
|
2892 @see strncpy() |
|
2893 @see strpbrk() |
|
2894 @see strrchr() |
|
2895 @see strspn() |
|
2896 @see strstr() |
|
2897 |
|
2898 |
|
2899 |
|
2900 |
|
2901 @publishedAll |
|
2902 @externallyDefinedApi |
|
2903 */ |
|
2904 |
|
2905 |
|
2906 |
|
2907 /** @fn wmemset(wchar_t *s, wchar_t c, size_t n) |
|
2908 @param s |
|
2909 @param c |
|
2910 @param n |
|
2911 |
|
2912 Refer to wmemchr() for the documentation |
|
2913 |
|
2914 @see memchr() |
|
2915 @see memcmp() |
|
2916 @see memcpy() |
|
2917 @see memmove() |
|
2918 @see memset() |
|
2919 @see strcat() |
|
2920 @see strchr() |
|
2921 @see strcmp() |
|
2922 @see strcpy() |
|
2923 @see strcspn() |
|
2924 @see strlen() |
|
2925 @see strncat() |
|
2926 @see strncmp() |
|
2927 @see strncpy() |
|
2928 @see strpbrk() |
|
2929 @see strrchr() |
|
2930 @see strspn() |
|
2931 @see strstr() |
|
2932 |
|
2933 |
|
2934 |
|
2935 |
|
2936 @publishedAll |
|
2937 @externallyDefinedApi |
|
2938 */ |
|
2939 |
|
2940 |
|
2941 |
|
2942 /** @fn wprintf(const wchar_t *fmt, ...) |
|
2943 @param fmt |
|
2944 @param ... |
|
2945 |
|
2946 Refer to fwprintf() for the documentation |
|
2947 |
|
2948 @see btowc() |
|
2949 @see fputws() |
|
2950 @see printf() |
|
2951 @see putwc() |
|
2952 @see setlocale() |
|
2953 @see wcsrtombs() |
|
2954 @see wscanf() |
|
2955 |
|
2956 |
|
2957 |
|
2958 |
|
2959 @publishedAll |
|
2960 @externallyDefinedApi |
|
2961 */ |
|
2962 |
|
2963 |
|
2964 |
|
2965 /** @fn wscanf(const wchar_t *fmt, ...) |
|
2966 @param fmt |
|
2967 @param ... |
|
2968 |
|
2969 Note: This description also covers the following functions - |
|
2970 fwscanf() swscanf() vwscanf() vswscanf() vfwscanf() |
|
2971 |
|
2972 @return These |
|
2973 functions |
|
2974 return |
|
2975 the number of input items assigned, which can be fewer than provided |
|
2976 for, or even zero, in the event of a matching failure. |
|
2977 Zero |
|
2978 indicates that, while there was input available, |
|
2979 no conversions were assigned; |
|
2980 typically this is due to an invalid input character, |
|
2981 such as an alphabetic character for a '\%d' |
|
2982 conversion. |
|
2983 The value EOF is returned if an input failure occurs before any conversion such as an |
|
2984 end-of-file occurs. |
|
2985 If an error or end-of-file occurs after conversion |
|
2986 has begun, |
|
2987 the number of conversions which were successfully completed is returned. |
|
2988 |
|
2989 The wscanf family of functions scans input according to a format as described below. |
|
2990 This format may contain conversion specifiers ; |
|
2991 the results from such conversions, if any, |
|
2992 are stored through the pointer arguments. |
|
2993 The wscanf function |
|
2994 reads input from the standard input stream stdin , fwscanf reads input from the stream pointer stream , |
|
2995 and swscanf reads its input from the wide character string pointed to by str . |
|
2996 The vfwscanf function |
|
2997 is analogous to vfwprintf and reads input from the stream pointer stream using a variable argument list of pointers. |
|
2998 The vwscanf function scans a variable argument list from the standard input and |
|
2999 the vswscanf function scans it from a wide character string; |
|
3000 these are analogous to |
|
3001 the vwprintf and vswprintf functions respectively. |
|
3002 Each successive pointer argument must correspond properly with |
|
3003 each successive conversion specifier |
|
3004 (but see the * conversion below). |
|
3005 All conversions are introduced by the \% (percent sign) character. |
|
3006 The format string |
|
3007 may also contain other characters. |
|
3008 White space (such as blanks, tabs, or newlines) in the format string match any amount of white space, including none, in the input. |
|
3009 Everything else |
|
3010 matches only itself. |
|
3011 Scanning stops |
|
3012 when an input character does not match such a format character. |
|
3013 Scanning also stops |
|
3014 when an input conversion cannot be made (see below). |
|
3015 |
|
3016 |
|
3017 Conversions: |
|
3018 |
|
3019 @code |
|
3020 |
|
3021 Following the % character introducing a conversion there may be a number of flag characters, as follows: * Suppresses assignment. The conversion that follows occurs as usual, but no pointer is used; the result of the conversion is simply discarded. |
|
3022 hh Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a char (rather than int ) . |
|
3023 h Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a short int (rather than int ) . |
|
3024 l (ell) Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a long int (rather than int ) , that the conversion will be one of a, e, f, or g and the next pointer is a pointer to double (rather than float ) , or that the conversion will be one of c or s and the next pointer is a pointer to an array of wchar_t (rather than char ) . |
|
3025 ll (ell ell) |
|
3026 Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a long long int (rather than int ) . |
|
3027 L Indicates that the conversion will be one of a, e, f, or g and the next pointer is a pointer to long double . |
|
3028 j Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a intmax_t (rather than int ) . |
|
3029 t Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a ptrdiff_t (rather than int ) . |
|
3030 z Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a size_t (rather than int ) . |
|
3031 q (deprecated.) Indicates that the conversion will be one of dioux or n and the next pointer is a pointer to a long long int (rather than int ) . |
|
3032 |
|
3033 |
|
3034 In addition to these flags, there may be an optional maximum field width, expressed as a decimal integer, between the % and the conversion. If no width is given, a default of "infinity" is used (with one exception, below); otherwise at most this many characters are scanned in processing the conversion. Before conversion begins, most conversions skip white space; this white space is not counted against the field width. |
|
3035 |
|
3036 The following conversions are available: % Matches a literal ‘%’. That is, "%%" in the format string matches a single input ‘%’ character. No conversion is done, and assignment does not occur. |
|
3037 d Matches an optionally signed decimal integer; the next pointer must be a pointer to int . |
|
3038 i Matches an optionally signed integer; the next pointer must be a pointer to int . The integer is read in base 16 if it begins with ‘0x’ or ‘0X’, in base 8 if it begins with ‘0’, and in base 10 otherwise. Only characters that correspond to the base are used. |
|
3039 o Matches an octal integer; the next pointer must be a pointer to unsigned int . |
|
3040 u Matches an optionally signed decimal integer; the next pointer must be a pointer to unsigned int . |
|
3041 x, X Matches an optionally signed hexadecimal integer; the next pointer must be a pointer to unsigned int . |
|
3042 a, A, e, E, f, F, g, G |
|
3043 Matches a floating-point number in the style of wcstod. The next pointer must be a pointer to float (unless l or L is specified.) |
|
3044 s Matches a sequence of non-white-space wide characters; the next pointer must be a pointer to char , and the array must be large enough to accept the multibyte representation of all the sequence and the terminating NUL character. The input string stops at white space or at the maximum field width, whichever occurs first. |
|
3045 If an l qualifier is present, the next pointer must be a pointer to wchar_t , into which the input will be placed. |
|
3046 |
|
3047 S The same as ls. |
|
3048 c Matches a sequence of width count wide characters (default 1); the next pointer must be a pointer to char , and there must be enough room for the multibyte representation of all the characters (no terminating NUL is added). The usual skip of leading white space is suppressed. To skip white space first, use an explicit space in the format. |
|
3049 If an l qualifier is present, the next pointer must be a pointer to wchar_t , into which the input will be placed. |
|
3050 |
|
3051 C The same as lc. |
|
3052 [ Matches a nonempty sequence of characters from the specified set of accepted characters; the next pointer must be a pointer to char , and there must be enough room for the multibyte representation of all the characters in the string, plus a terminating NUL character. The usual skip of leading white space is suppressed. The string is to be made up of characters in (or not in) a particular set; the set is defined by the characters between the open bracket [ character and a close bracket ] character. The set excludes those characters if the first character after the open bracket is a circumflex ^. To include a close bracket in the set, make it the first character after the open bracket or the circumflex; any other position will end the set. To include a hyphen in the set, make it the last character before the final close bracket; some implementations of wscanf use "A-Z" to represent the range of characters between ‘A’ and ‘Z’. The string ends with the appearance of a character not in the (or, with a circumflex, in) set or when the field width runs out. |
|
3053 If an l qualifier is present, the next pointer must be a pointer to wchar_t , into which the input will be placed. |
|
3054 |
|
3055 p Matches a pointer value (as printed by ‘%p’ in wprintf); the next pointer must be a pointer to void . |
|
3056 n Nothing is expected; instead, the number of characters consumed thus far from the input is stored through the next pointer, which must be a pointer to int . This is not a conversion, although it can be suppressed with the * flag. |
|
3057 |
|
3058 |
|
3059 |
|
3060 The decimal point character is defined in the program’s locale (category LC_NUMERIC). |
|
3061 |
|
3062 For backwards compatibility, a "conversion" of ‘%\0’ causes an immediate return of EOF. |
|
3063 |
|
3064 @endcode |
|
3065 |
|
3066 Examples: |
|
3067 @code |
|
3068 #include <stdio.h> |
|
3069 #include <wchar.h> |
|
3070 /* Illustrates how to use wscanf API */ |
|
3071 int example_wscanf(void) |
|
3072 { |
|
3073 int rval; |
|
3074 int input; |
|
3075 /* Display a message to the user to input an integer */ |
|
3076 wprintf(L"Enter an integer : "); |
|
3077 /* Read an integer from the standard input */ |
|
3078 rval = wscanf(L"%d", &input;); |
|
3079 |
|
3080 /* return the number of inputs that were read */ |
|
3081 return(rval); |
|
3082 } |
|
3083 |
|
3084 @endcode |
|
3085 @code |
|
3086 #include <stdio.h> |
|
3087 #include <wchar.h> |
|
3088 /* Illustrates how to use swscanf API */ |
|
3089 int example_swscanf(void) |
|
3090 { |
|
3091 int rval; |
|
3092 wchar_t wcs[100]; |
|
3093 wchar_t *bufptr = L"abcdefg"; |
|
3094 /* Read a string from the buffer bufptr*/ |
|
3095 rval = swscanf(bufptr, L"%s", wcs); |
|
3096 |
|
3097 /* The string that was read into wcs is printed */ |
|
3098 wprintf(L"%s",wcs); |
|
3099 |
|
3100 /* return the number of inputs that were read */ |
|
3101 return(rval); |
|
3102 } |
|
3103 |
|
3104 @endcode |
|
3105 @code |
|
3106 #include <stdio.h> |
|
3107 #include <wchar.h> |
|
3108 /* Illustrates how to use fwscanf API */ |
|
3109 int example_fwscanf(void) |
|
3110 { |
|
3111 FILE *fp = NULL; |
|
3112 int retval; |
|
3113 wchar_t wcs[100]; |
|
3114 |
|
3115 /* open the file for writing*/ |
|
3116 fp = fopen("write.txt","w"); |
|
3117 if(fp == NULL) |
|
3118 { |
|
3119 wprintf(L"Error: File open |
|
3120 "); |
|
3121 return (-1); |
|
3122 } |
|
3123 /* Read a string from fp*/ |
|
3124 rval = fwscanf(fp, L"%s", wcs); |
|
3125 |
|
3126 /* Close the file that was opened */ |
|
3127 fclose(fp); |
|
3128 |
|
3129 /* return the number of inputs that were read */ |
|
3130 return(rval); |
|
3131 } |
|
3132 |
|
3133 @endcode |
|
3134 @code |
|
3135 #include <stdio.h> |
|
3136 #include <wchar.h> |
|
3137 /* Illustrates how to use vwscanf API */ |
|
3138 int example_vwscanf(va_list arg) |
|
3139 { |
|
3140 int retval; |
|
3141 |
|
3142 /* Read a string from standard input */ |
|
3143 rval = vwscanf(L"%s", arg); |
|
3144 |
|
3145 /* return the number of inputs that were read */ |
|
3146 return(rval); |
|
3147 } |
|
3148 |
|
3149 @endcode |
|
3150 @code |
|
3151 #include <stdio.h> |
|
3152 #include <wchar.h> |
|
3153 /* Illustrates how to use vswscanf API */ |
|
3154 int example_vswscanf(va_list arg) |
|
3155 { |
|
3156 int retval; |
|
3157 wchar_t bufptr = L"abc"; |
|
3158 |
|
3159 /* Read a string from bufptr */ |
|
3160 rval = vswscanf(bufptr, L"%s", arg); |
|
3161 |
|
3162 /* return the number of inputs that were read */ |
|
3163 return(rval); |
|
3164 } |
|
3165 |
|
3166 @endcode |
|
3167 @code |
|
3168 #include <stdio.h> |
|
3169 #include <wchar.h> |
|
3170 /* Illustrates how to use vfwscanf API */ |
|
3171 int example_vfwscanf(va_list arg) |
|
3172 { |
|
3173 FILE *fp = NULL; |
|
3174 int retval; |
|
3175 |
|
3176 /* open the file for writing*/ |
|
3177 fp = fopen("write.txt","w"); |
|
3178 if(fp == NULL) |
|
3179 { |
|
3180 wprintf(L"Error: File open |
|
3181 "); |
|
3182 return (-1); |
|
3183 } |
|
3184 /* Read a string */ |
|
3185 rval = vfwscanf(fp, L"%s", arg); |
|
3186 |
|
3187 /* Close the file that was opened */ |
|
3188 fclose(fp); |
|
3189 |
|
3190 /* return the number of inputs that were read */ |
|
3191 return(rval); |
|
3192 } |
|
3193 |
|
3194 @endcode |
|
3195 Examples: |
|
3196 @code |
|
3197 #include <stdio.h> |
|
3198 #include <wchar.h> |
|
3199 /* Illustrates how to use wscanf API */ |
|
3200 int example_wscanf(void) |
|
3201 { |
|
3202 int rval; |
|
3203 int input; |
|
3204 /* Display a message to the user to input an integer */ |
|
3205 wprintf(L"Enter an integer : "); |
|
3206 /* Read an integer from the standard input */ |
|
3207 rval = wscanf(L"%d", &input;); |
|
3208 |
|
3209 /* return the number of inputs that were read */ |
|
3210 return(rval); |
|
3211 } |
|
3212 |
|
3213 @endcode |
|
3214 @code |
|
3215 #include <stdio.h> |
|
3216 #include <wchar.h> |
|
3217 /* Illustrates how to use swscanf API */ |
|
3218 int example_swscanf(void) |
|
3219 { |
|
3220 int rval; |
|
3221 wchar_t wcs[100]; |
|
3222 wchar_t *bufptr = L"abcdefg"; |
|
3223 /* Read a string from the buffer bufptr*/ |
|
3224 rval = swscanf(bufptr, L"%s", wcs); |
|
3225 |
|
3226 /* The string that was read into wcs is printed */ |
|
3227 wprintf(L"%s",wcs); |
|
3228 |
|
3229 /* return the number of inputs that were read */ |
|
3230 return(rval); |
|
3231 } |
|
3232 |
|
3233 @endcode |
|
3234 @code |
|
3235 #include <stdio.h> |
|
3236 #include <wchar.h> |
|
3237 /* Illustrates how to use fwscanf API */ |
|
3238 int example_fwscanf(void) |
|
3239 { |
|
3240 FILE *fp = NULL; |
|
3241 int retval; |
|
3242 wchar_t wcs[100]; |
|
3243 |
|
3244 /* open the file for writing*/ |
|
3245 fp = fopen("write.txt","w"); |
|
3246 if(fp == NULL) |
|
3247 { |
|
3248 wprintf(L"Error: File open |
|
3249 "); |
|
3250 return (-1); |
|
3251 } |
|
3252 /* Read a string from fp*/ |
|
3253 rval = fwscanf(fp, L"%s", wcs); |
|
3254 |
|
3255 /* Close the file that was opened */ |
|
3256 fclose(fp); |
|
3257 |
|
3258 /* return the number of inputs that were read */ |
|
3259 return(rval); |
|
3260 } |
|
3261 |
|
3262 @endcode |
|
3263 @code |
|
3264 #include <stdio.h> |
|
3265 #include <wchar.h> |
|
3266 /* Illustrates how to use vwscanf API */ |
|
3267 int example_vwscanf(va_list arg) |
|
3268 { |
|
3269 int retval; |
|
3270 |
|
3271 /* Read a string from standard input */ |
|
3272 rval = vwscanf(L"%s", arg); |
|
3273 |
|
3274 /* return the number of inputs that were read */ |
|
3275 return(rval); |
|
3276 } |
|
3277 |
|
3278 @endcode |
|
3279 @code |
|
3280 #include <stdio.h> |
|
3281 #include <wchar.h> |
|
3282 /* Illustrates how to use vswscanf API */ |
|
3283 int example_vswscanf(va_list arg) |
|
3284 { |
|
3285 int retval; |
|
3286 wchar_t bufptr = L"abc"; |
|
3287 |
|
3288 /* Read a string from bufptr */ |
|
3289 rval = vswscanf(bufptr, L"%s", arg); |
|
3290 |
|
3291 /* return the number of inputs that were read */ |
|
3292 return(rval); |
|
3293 } |
|
3294 |
|
3295 @endcode |
|
3296 @code |
|
3297 #include <stdio.h> |
|
3298 #include <wchar.h> |
|
3299 /* Illustrates how to use vfwscanf API */ |
|
3300 int example_vfwscanf(va_list arg) |
|
3301 { |
|
3302 FILE *fp = NULL; |
|
3303 int retval; |
|
3304 |
|
3305 /* open the file for writing*/ |
|
3306 fp = fopen("write.txt","w"); |
|
3307 if(fp == NULL) |
|
3308 { |
|
3309 wprintf(L"Error: File open |
|
3310 "); |
|
3311 return (-1); |
|
3312 } |
|
3313 /* Read a string */ |
|
3314 rval = vfwscanf(fp, L"%s", arg); |
|
3315 |
|
3316 /* Close the file that was opened */ |
|
3317 fclose(fp); |
|
3318 |
|
3319 /* return the number of inputs that were read */ |
|
3320 return(rval); |
|
3321 } |
|
3322 |
|
3323 @endcode |
|
3324 |
|
3325 Limitations: |
|
3326 |
|
3327 Long double length modifiers are not supported. |
|
3328 |
|
3329 @see fgetwc() |
|
3330 @see scanf() |
|
3331 @see wcrtomb() |
|
3332 @see wcstod() |
|
3333 @see wcstol() |
|
3334 @see wcstoul() |
|
3335 @see wprintf() |
|
3336 |
|
3337 |
|
3338 Bugs: |
|
3339 |
|
3340 In addition to the bugs documented in scanf , wscanf does not support the "A-Z" |
|
3341 notation for specifying character ranges with the character |
|
3342 class conversion (' \%[ '). |
|
3343 |
|
3344 |
|
3345 |
|
3346 @publishedAll |
|
3347 @externallyDefinedApi |
|
3348 */ |
|
3349 |
|
3350 |
|
3351 |
|
3352 /** @fn wcstoq(const wchar_t * nptr, wchar_t ** endptr, int base) |
|
3353 @param nptr |
|
3354 @param endptr |
|
3355 @param base |
|
3356 |
|
3357 Refer to wcstol() for the documentation |
|
3358 |
|
3359 @see strtol() |
|
3360 @see strtoul() |
|
3361 |
|
3362 |
|
3363 |
|
3364 |
|
3365 @publishedAll |
|
3366 @externallyDefinedApi |
|
3367 */ |
|
3368 |
|
3369 |
|
3370 |
|
3371 /** @fn wcstouq(const wchar_t * nptr, wchar_t ** endptr, int base) |
|
3372 @param nptr |
|
3373 @param endptr |
|
3374 @param base |
|
3375 |
|
3376 Refer to wcstol() for the documentation |
|
3377 |
|
3378 @see strtol() |
|
3379 @see strtoul() |
|
3380 |
|
3381 |
|
3382 |
|
3383 |
|
3384 @publishedAll |
|
3385 @externallyDefinedApi |
|
3386 */ |
|
3387 |
|
3388 |
|
3389 |
|
3390 /** @fn wcswcs(const wchar_t *s, const wchar_t *find) |
|
3391 @param s |
|
3392 @param find |
|
3393 |
|
3394 The wcswcs() function locates the first occurrence of the wide-character |
|
3395 string pointed by s (excluding the terminating '\\0' character) in the wide-character |
|
3396 string pointed by find. |
|
3397 |
|
3398 Examples: |
|
3399 @code |
|
3400 #include <wchar.h> |
|
3401 /* Illustrates how to use wcswcs API */ |
|
3402 int example_wcswcs() |
|
3403 { |
|
3404 /* source wide character string */ |
|
3405 wchar_t *buf[20] = { L"fkhsdf%%38",L"rtti123123", }; |
|
3406 wchar_t *str = wcswcs(buf[0],L"\0"); |
|
3407 wchar_t *str1 = wcswcs(buf[1],L"\0"); |
|
3408 if(wcscmp(str,buf[0])) |
|
3409 return 1; |
|
3410 if(wcscmp(str1,buf[1])) |
|
3411 return 1 |
|
3412 return 0; |
|
3413 } |
|
3414 |
|
3415 @endcode |
|
3416 @return The wcswcs() on success returns a pointer to the located wide-character string and returns |
|
3417 a NULL pointer if the wide-charcter string was not found. If find is a wide-character string with length as zero, the function returns s. |
|
3418 |
|
3419 @see strstr() |
|
3420 |
|
3421 |
|
3422 |
|
3423 |
|
3424 @publishedAll |
|
3425 @externallyDefinedApi |
|
3426 */ |
|
3427 |
|
3428 |
|
3429 |
|
3430 /** @fn getwc(FILE *stream) |
|
3431 @param stream |
|
3432 |
|
3433 Refer to fgetwc() for the documentation |
|
3434 |
|
3435 @see ferror() |
|
3436 @see fopen() |
|
3437 @see fread() |
|
3438 @see getc() |
|
3439 @see putwc() |
|
3440 @see ungetwc() |
|
3441 |
|
3442 |
|
3443 |
|
3444 |
|
3445 @publishedAll |
|
3446 @externallyDefinedApi |
|
3447 */ |
|
3448 |
|
3449 |
|
3450 |
|
3451 /** @fn getwchar(void); |
|
3452 |
|
3453 |
|
3454 Refer to fgetwc() for the documentation |
|
3455 |
|
3456 @see ferror() |
|
3457 @see fopen() |
|
3458 @see fread() |
|
3459 @see getc() |
|
3460 @see putwc() |
|
3461 @see ungetwc() |
|
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 @publishedAll |
|
3467 @externallyDefinedApi |
|
3468 */ |
|
3469 |
|
3470 |
|
3471 |
|
3472 /** @fn putwc(wchar_t wc, FILE *stream) |
|
3473 @param wc |
|
3474 @param stream |
|
3475 |
|
3476 Refer to fputwc() for the documentation |
|
3477 |
|
3478 @see ferror() |
|
3479 @see fopen() |
|
3480 @see getwc() |
|
3481 @see putc() |
|
3482 |
|
3483 |
|
3484 |
|
3485 |
|
3486 @publishedAll |
|
3487 @externallyDefinedApi |
|
3488 */ |
|
3489 |
|
3490 |
|
3491 |
|
3492 /** @fn putwchar(wchar_t wc) |
|
3493 @param wc |
|
3494 |
|
3495 Refer to fputwc() for the documentation |
|
3496 |
|
3497 @see ferror() |
|
3498 @see fopen() |
|
3499 @see getwc() |
|
3500 @see putc() |
|
3501 |
|
3502 |
|
3503 |
|
3504 |
|
3505 @publishedAll |
|
3506 @externallyDefinedApi |
|
3507 */ |
|
3508 |
|
3509 |
|
3510 |
|
3511 /** @fn vfwscanf(FILE * stream, const wchar_t * format, va_list ap) |
|
3512 @param stream |
|
3513 @param format |
|
3514 @param ap |
|
3515 |
|
3516 Refer to wscanf() for the documentation |
|
3517 |
|
3518 @see fgetwc() |
|
3519 @see scanf() |
|
3520 @see wcrtomb() |
|
3521 @see wcstod() |
|
3522 @see wcstol() |
|
3523 @see wcstoul() |
|
3524 @see wprintf() |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 @publishedAll |
|
3530 @externallyDefinedApi |
|
3531 */ |
|
3532 |
|
3533 |
|
3534 |
|
3535 /** @fn vswscanf(const wchar_t * str, const wchar_t *fmt, va_list ap) |
|
3536 @param str |
|
3537 @param fmt |
|
3538 @param ap |
|
3539 |
|
3540 Refer to wscanf() for the documentation |
|
3541 |
|
3542 @see fgetwc() |
|
3543 @see scanf() |
|
3544 @see wcrtomb() |
|
3545 @see wcstod() |
|
3546 @see wcstol() |
|
3547 @see wcstoul() |
|
3548 @see wprintf() |
|
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 @publishedAll |
|
3554 @externallyDefinedApi |
|
3555 */ |
|
3556 |
|
3557 |
|
3558 |
|
3559 /** @fn vwscanf(const wchar_t *fmt, va_list ap) |
|
3560 @param fmt |
|
3561 @param ap |
|
3562 |
|
3563 Refer to wscanf() for the documentation |
|
3564 |
|
3565 @see fgetwc() |
|
3566 @see scanf() |
|
3567 @see wcrtomb() |
|
3568 @see wcstod() |
|
3569 @see wcstol() |
|
3570 @see wcstoul() |
|
3571 @see wprintf() |
|
3572 |
|
3573 |
|
3574 |
|
3575 |
|
3576 @publishedAll |
|
3577 @externallyDefinedApi |
|
3578 */ |
|
3579 |
|
3580 |
|
3581 |
|
3582 /** @fn wcstof(const wchar_t * nptr, wchar_t ** endptr) |
|
3583 @param nptr |
|
3584 @param endptr |
|
3585 |
|
3586 Note: This description also covers the following functions - |
|
3587 wcstold() wcstod() |
|
3588 |
|
3589 @return |
|
3590 |
|
3591 The wcstof , wcstod and wcstold functions are the wide-character versions of the strtof , strtod and strtold functions. |
|
3592 Refer to strtod() for details. |
|
3593 |
|
3594 Examples: |
|
3595 @code |
|
3596 #include <wchar.h> |
|
3597 /* Illustrates how to use wcstof API */ |
|
3598 int example_wcstof() |
|
3599 { |
|
3600 /* src string */ |
|
3601 wchar_t wcs1[21] = L" 1.23abcd"; |
|
3602 wchar_t wcs2[5]=L"abcd"; |
|
3603 wchar_t *eptr; |
|
3604 float d; |
|
3605 |
|
3606 /* convert wide-char string to float */ |
|
3607 d = wcstof(wcs1, &eptr;); |
|
3608 |
|
3609 /* compare the result */ |
|
3610 if((d == 1.23F) && !(wcscmp (eptr, wcs2))) |
|
3611 return 0; |
|
3612 else |
|
3613 return 1; |
|
3614 } |
|
3615 |
|
3616 @endcode |
|
3617 @code |
|
3618 #include <wchar.h> |
|
3619 /* Illustrates how to use wcstold API */ |
|
3620 int example_wcstold() |
|
3621 { |
|
3622 /* src string */ |
|
3623 wchar_t wcs1[21] = L" 1.23abcd"; |
|
3624 wchar_t wcs2[5]=L"abcd"; |
|
3625 wchar_t *eptr; |
|
3626 double d; |
|
3627 |
|
3628 /* convert wide-char string to double */ |
|
3629 d = wcstod(wcs1, &eptr;); |
|
3630 |
|
3631 /* compare the result */ |
|
3632 if((d == 1.23) && !(wcscmp (eptr, wcs2))) |
|
3633 return 0; |
|
3634 else |
|
3635 return 1; |
|
3636 } |
|
3637 |
|
3638 @endcode |
|
3639 @code |
|
3640 #include <wchar.h> |
|
3641 /* Illustrates how to use wcstold API */ |
|
3642 int example_wcstold() |
|
3643 { |
|
3644 /* src string */ |
|
3645 wchar_t wcs1[21] = L" 1.23abcd"; |
|
3646 wchar_t wcs2[5]=L"abcd"; |
|
3647 wchar_t *eptr; |
|
3648 long double d; |
|
3649 |
|
3650 /* convert wide-char string to long double */ |
|
3651 d = wcstold(wcs1, &eptr;); |
|
3652 |
|
3653 /* compare the result * |
|
3654 if((d == 1.23) && !(wcscmp (eptr, wcs2))) |
|
3655 return 0; |
|
3656 else |
|
3657 return 1; |
|
3658 } |
|
3659 |
|
3660 @endcode |
|
3661 @see strtod() |
|
3662 @see wcstol() |
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 @publishedAll |
|
3668 @externallyDefinedApi |
|
3669 */ |
|
3670 |
|
3671 |
|
3672 |
|
3673 /** @fn wcstold(const wchar_t * nptr, wchar_t ** endptr) |
|
3674 @param nptr |
|
3675 @param endptr |
|
3676 |
|
3677 Refer to wcstof() for the documentation |
|
3678 |
|
3679 @see strtod() |
|
3680 @see wcstol() |
|
3681 |
|
3682 |
|
3683 |
|
3684 |
|
3685 @publishedAll |
|
3686 @externallyDefinedApi |
|
3687 */ |
|
3688 |
|
3689 |
|
3690 |
|
3691 /** @fn wcstoll(const wchar_t * nptr, wchar_t ** endptr, int base) |
|
3692 @param nptr |
|
3693 @param endptr |
|
3694 @param base |
|
3695 |
|
3696 Refer to wcstol() for the documentation |
|
3697 |
|
3698 @see strtol() |
|
3699 @see strtoul() |
|
3700 |
|
3701 |
|
3702 |
|
3703 |
|
3704 @publishedAll |
|
3705 @externallyDefinedApi |
|
3706 */ |
|
3707 |
|
3708 |
|
3709 |
|
3710 /** @fn wcstoull(const wchar_t * nptr, wchar_t ** endptr, int base) |
|
3711 @param nptr |
|
3712 @param endptr |
|
3713 @param base |
|
3714 |
|
3715 Refer to wcstol() for the documentation |
|
3716 |
|
3717 @see strtol() |
|
3718 @see strtoul() |
|
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 @publishedAll |
|
3724 @externallyDefinedApi |
|
3725 */ |
|
3726 |
|
3727 |
|
3728 |
|
3729 /** @fn wcswidth(const wchar_t *pwcs, size_t n) |
|
3730 @param pwcs |
|
3731 @param n |
|
3732 @return The wcswidth function returns 0 if pwcs is an empty string (L""), -1 if a non-printing wide character is |
|
3733 encountered or the number of column positions occupied otherwise. |
|
3734 |
|
3735 The wcswidth function determines the number of column positions required for the first n characters of pwcs , |
|
3736 or until a null wide character (L'\\0') is encountered. |
|
3737 |
|
3738 The behavior of the wcswdith is affected by LC_CTYPE category of the current locale. |
|
3739 |
|
3740 Examples: |
|
3741 @code |
|
3742 #include <wchar.h> |
|
3743 /* Illustrates how to use wcswidth API */ |
|
3744 int example_wcswidth() |
|
3745 { |
|
3746 /* wide character string for which width has to */ |
|
3747 /* determined */ |
|
3748 wchar_t *ws1 = L"test case"; |
|
3749 int retval; |
|
3750 /* compute the width of the ws1 */ |
|
3751 retval = wcswidth(ws1,50); |
|
3752 /* return the result */ |
|
3753 return retval; |
|
3754 } |
|
3755 |
|
3756 @endcode |
|
3757 |
|
3758 Limitations: |
|
3759 |
|
3760 The current implementation of wcswidth is dependent upon locale support in Symbian OS. |
|
3761 |
|
3762 @see iswprint() |
|
3763 @see wcwidth() |
|
3764 |
|
3765 |
|
3766 |
|
3767 |
|
3768 @publishedAll |
|
3769 @externallyDefinedApi |
|
3770 */ |
|
3771 |
|
3772 |
|
3773 |
|
3774 /** @fn wcwidth(wchar_t wc) |
|
3775 @param wc |
|
3776 @return The wcwidth function returns 0 if the wc argument is a null wide character (L'\\0'), -1 if wc is not printable or the number of column positions the character occupies |
|
3777 otherwise. |
|
3778 |
|
3779 The wcwidth function determines the number of column positions required to |
|
3780 display the wide character wc . |
|
3781 |
|
3782 The behavior of the wcwdith is affected by LC_CTYPE category of the current locale. |
|
3783 |
|
3784 Examples: |
|
3785 @code |
|
3786 #include <wchar.h> |
|
3787 /* Illustrates how to use wcwidth API */ |
|
3788 int example_wcwidth() |
|
3789 { |
|
3790 /* wide character for which width has to be determined */ |
|
3791 wchar_t wc = L'a'; |
|
3792 int retval; |
|
3793 /* determine the width of wc */ |
|
3794 retval = wcwidth(wc); |
|
3795 /* return the determined width */ |
|
3796 return retval; |
|
3797 } |
|
3798 |
|
3799 @endcode |
|
3800 |
|
3801 Examples: |
|
3802 |
|
3803 This code fragment reads text from standard input and |
|
3804 breaks lines that are more than 20 column positions wide, |
|
3805 similar to the fold utility: |
|
3806 @code |
|
3807 wint_t ch; |
|
3808 int column, w; |
|
3809 column = 0; |
|
3810 while ((ch = getwchar()) != WEOF) { |
|
3811 w = wcwidth(ch); |
|
3812 if (w > 0 && column + w >= 20) { |
|
3813 putwchar(L' \en'); |
|
3814 column = 0; |
|
3815 } |
|
3816 putwchar(ch); |
|
3817 if (ch == L' \en') |
|
3818 column = 0; |
|
3819 else if (w > 0) |
|
3820 column += w; |
|
3821 } |
|
3822 |
|
3823 @endcode |
|
3824 |
|
3825 Limitations: |
|
3826 |
|
3827 The current implementation of wcwidth is dependent upon the locale support of Symbian OS. |
|
3828 |
|
3829 @see iswprint() |
|
3830 @see wcswidth() |
|
3831 |
|
3832 |
|
3833 |
|
3834 |
|
3835 @publishedAll |
|
3836 @externallyDefinedApi |
|
3837 */ |
|
3838 |
|
3839 |
|
3840 |
|
3841 /** @fn mbsnrtowcs(wchar_t * dst, const char ** src, size_t nms, size_t len, mbstate_t * ps) |
|
3842 @param dst |
|
3843 @param src |
|
3844 @param nms |
|
3845 @param len |
|
3846 @param ps |
|
3847 |
|
3848 Refer to mbsrtowcs() for the documentation |
|
3849 |
|
3850 @see mbrtowc() |
|
3851 @see mbstowcs() |
|
3852 @see wcsrtombs() |
|
3853 |
|
3854 |
|
3855 |
|
3856 |
|
3857 @publishedAll |
|
3858 @externallyDefinedApi |
|
3859 */ |
|
3860 |
|
3861 |
|
3862 |
|
3863 /** @fn wcsnrtombs(char * dst, const wchar_t ** src, size_t nwc, size_t len, mbstate_t * ps) |
|
3864 @param dst |
|
3865 @param src |
|
3866 @param nwc |
|
3867 @param len |
|
3868 @param ps |
|
3869 |
|
3870 Refer to wcsrtombs() for the documentation |
|
3871 |
|
3872 @see mbsrtowcs() |
|
3873 @see wcrtomb() |
|
3874 @see wcstombs() |
|
3875 |
|
3876 |
|
3877 |
|
3878 |
|
3879 @publishedAll |
|
3880 @externallyDefinedApi |
|
3881 */ |
|
3882 |
|
3883 |
|
3884 |
|
3885 /** @fn wcpcpy(wchar_t *dst , const wchar_t *src) |
|
3886 @param dst |
|
3887 @param src |
|
3888 @return The wcpcpy() function returns a pointer to the end of the wide-character |
|
3889 string dest , that is the return pointer points to the terminating '\\0'. |
|
3890 |
|
3891 |
|
3892 |
|
3893 The wcpcpy() function |
|
3894 copies the wide-character string src to dst (including the terminating '\\0' |
|
3895 character.) |
|
3896 |
|
3897 |
|
3898 |
|
3899 Examples: |
|
3900 @code |
|
3901 #include <stdlib.h> |
|
3902 #include <wchar.h> |
|
3903 /* Illustrates how to use wcpcpy API */ |
|
3904 int example_wcpcpy() |
|
3905 { |
|
3906 /* input string for which length to be found */ |
|
3907 wchar_t *src = L"testcase"; |
|
3908 wchar_t *dest = NULL; |
|
3909 wchar_t *destEndPtr = NULL; |
|
3910 |
|
3911 /* allocate memory for the destination string */ |
|
3912 dest = (wchar_t *)malloc((wcslen(src)+1)*sizeof(wchar_t)); |
|
3913 |
|
3914 /* perform the operation */ |
|
3915 if(dest != NULL) |
|
3916 destEndPtr = (wchar_t *)wcpcpy(dest,src); |
|
3917 else |
|
3918 return 1; |
|
3919 if(!wcscmp(dest,src)) |
|
3920 { |
|
3921 free(dest); |
|
3922 return 0; |
|
3923 } |
|
3924 else |
|
3925 { |
|
3926 free(dest); |
|
3927 return 1; |
|
3928 } |
|
3929 } |
|
3930 |
|
3931 @endcode |
|
3932 |
|
3933 |
|
3934 |
|
3935 @publishedAll |
|
3936 @externallyDefinedApi |
|
3937 */ |
|
3938 |
|
3939 |
|
3940 |
|
3941 /** @fn wcpncpy(wchar_t *dst , const wchar_t *src, size_t n) |
|
3942 @param dst |
|
3943 @param src |
|
3944 @param n |
|
3945 @return The wcpncpy() function returns a pointer to the wide character one past |
|
3946 the last non-null wide character written. |
|
3947 |
|
3948 The wcpncpy() function copies at most n wide characters from the wide-character string src , including the terminating L'\\0' character, to dst . Exactly n wide characters are written at dst . If the length wcslen(src) is less than n , the remaining wide characters in the array dst are filled with L'\\0' |
|
3949 characters. If the length wcslen(src) is greater than or equal to n , the string dst will not be L'\\0' terminated. |
|
3950 |
|
3951 Examples: |
|
3952 @code |
|
3953 #include <stdlib.h> |
|
3954 #include <wchar.h> |
|
3955 /* Illustrates how to use wcpncpy API */ |
|
3956 int example_wcpncpy(void) |
|
3957 { |
|
3958 /* input string for which length to be found */ |
|
3959 wchar_t *src = L"testcase"; |
|
3960 wchar_t *dest = NULL; |
|
3961 wchar_t *destEndPtr = NULL; |
|
3962 |
|
3963 /* allocate memory for the destination string */ |
|
3964 dest = (wchar_t *)malloc((wcslen(src)+1)*sizeof(wchar_t)); |
|
3965 |
|
3966 /* perform the operation */ |
|
3967 if(dest != NULL) |
|
3968 destEndPtr = (wchar_t *)wcpncpy(dest,src,wcslen(src)+1); |
|
3969 else |
|
3970 return -1; |
|
3971 /* checking for error */ |
|
3972 if(!wcscmp(dest,src)) |
|
3973 { |
|
3974 wprintf(L"wcpncpy succeeded |
|
3975 "); |
|
3976 free(dest); |
|
3977 return 0; |
|
3978 } |
|
3979 else |
|
3980 { |
|
3981 wprintf(L"wcpncpy failed!! |
|
3982 "); |
|
3983 free(dest); |
|
3984 return -1; |
|
3985 } |
|
3986 } |
|
3987 |
|
3988 @endcode |
|
3989 @see wcpcpy() |
|
3990 |
|
3991 |
|
3992 |
|
3993 |
|
3994 @publishedAll |
|
3995 @externallyDefinedApi |
|
3996 */ |
|
3997 |
|
3998 |
|
3999 |
|
4000 /** @fn wcscasecmp(const wchar_t *s1, const wchar_t *s2) |
|
4001 @param s1 |
|
4002 @param s2 |
|
4003 @return The wcscasecmp() returns an integer greater than, equal to, or less than |
|
4004 0, according as s1 is lexicographically greater than, equal to, or less than s2 after translation of each corresponding character to lower-case. The |
|
4005 strings themselves are not modified. |
|
4006 |
|
4007 The wcscasecmp() function |
|
4008 compares the null-terminated wide-character strings s1 and s2 . |
|
4009 |
|
4010 Examples: |
|
4011 @code |
|
4012 #include <wchar.h> |
|
4013 /* Illustrates how to use wcscasecmp API */ |
|
4014 int example_wcscasecmp(void) |
|
4015 { |
|
4016 /* input strings which needs to be compared */ |
|
4017 wchar_t *ws1=L"testcasecmp"; |
|
4018 wchar_t *ws2=L"TESTCASECMP"; |
|
4019 |
|
4020 /* function call to compare the two strings which */ |
|
4021 /* differ in case */ |
|
4022 int retval = wcscasecmp(ws1,ws2); |
|
4023 /* returns 0 if they are equal or > 1 */ |
|
4024 /* if first string is greater than second string else -1 */ |
|
4025 return retval; |
|
4026 } |
|
4027 |
|
4028 @endcode |
|
4029 @see strcasecmp() |
|
4030 |
|
4031 |
|
4032 |
|
4033 |
|
4034 @publishedAll |
|
4035 @externallyDefinedApi |
|
4036 */ |
|
4037 |
|
4038 |
|
4039 |
|
4040 /** @fn wcsdup(const wchar_t *srcwcs) |
|
4041 @param srcwcs |
|
4042 @return The wcsdup function returns a pointer to the new wide-character string, or NULL if sufficient memory was not available. |
|
4043 |
|
4044 The wcsdup() function allocates sufficient memory for a |
|
4045 copy of the wide-string srcwcs, does the copy, |
|
4046 and returns a pointer to it. The pointer may |
|
4047 subsequently be used as an argument to the function free . |
|
4048 |
|
4049 If insufficient memory is available, NULL is returned and errno is set to |
|
4050 ENOMEM. |
|
4051 |
|
4052 Examples: |
|
4053 @code |
|
4054 #include <wchar.h> |
|
4055 /* Illustrates how to use wcsdup API */ |
|
4056 int example_wcsdup(void) |
|
4057 { |
|
4058 /* input string for which length has to be found */ |
|
4059 wchar_t *srcws=L"testwcsdup"; |
|
4060 wchar_t *destws = NULL; |
|
4061 |
|
4062 /* invoke the API wcsdup to duplicate the string */ |
|
4063 destws = wcsdup(srcws); |
|
4064 /* return no error if src str and dest str are equal else return an error */ |
|
4065 if(!(wcscmp(srcws,destws))) |
|
4066 { |
|
4067 free(destws); |
|
4068 return 1; |
|
4069 } |
|
4070 else |
|
4071 { |
|
4072 free(destws); |
|
4073 return -1; |
|
4074 } |
|
4075 } |
|
4076 |
|
4077 @endcode |
|
4078 @see strdup() |
|
4079 |
|
4080 |
|
4081 |
|
4082 |
|
4083 @publishedAll |
|
4084 @externallyDefinedApi |
|
4085 */ |
|
4086 |
|
4087 |
|
4088 |
|
4089 /** @fn wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) |
|
4090 @param s1 |
|
4091 @param s2 |
|
4092 @param n |
|
4093 @return The wcsncasecmp() returns an integer greater than, equal to, or less than 0, |
|
4094 according as s1 is lexicographically greater than, equal to, or less than s2 after translation of each corresponding character to lower-case. |
|
4095 The strings themselves are not modified. |
|
4096 |
|
4097 The wcsncasecmp() function compares atmost n wide-characters from the null-terminated wide-character strings s1 and s2 . |
|
4098 |
|
4099 Examples: |
|
4100 @code |
|
4101 #include <wchar.h> |
|
4102 /* Illustrates how to use wcsncasecmp API */ |
|
4103 int example_wcsncasecmp() |
|
4104 { |
|
4105 /* input strings which need to be compared */ |
|
4106 wchar_t *ws1=L"testcasecmp"; |
|
4107 wchar_t *ws2=L"TESTCASECMP"; |
|
4108 |
|
4109 /* function call to compare the two strings which */ |
|
4110 /* differ in case */ |
|
4111 int retval = wcsncasecmp(ws1,ws2,11); |
|
4112 /* returns 0 if they are equal except the case or >1 */ |
|
4113 /* if first string is greater than second string else -1 */ |
|
4114 return retval; |
|
4115 } |
|
4116 |
|
4117 @endcode |
|
4118 @see strncasecmp() |
|
4119 |
|
4120 |
|
4121 |
|
4122 |
|
4123 @publishedAll |
|
4124 @externallyDefinedApi |
|
4125 */ |
|
4126 |
|
4127 |
|
4128 |
|
4129 /** @fn wcsnlen(const wchar_t *s, size_t maxlen) |
|
4130 @param s |
|
4131 @param maxlen |
|
4132 |
|
4133 The wcsnlen() function computes the length of the wide-character string s not including the terminating NUL character. It looks at only |
|
4134 first maxlen wide-characters in s and never beyond s+maxlen. |
|
4135 |
|
4136 Examples: |
|
4137 @code |
|
4138 #include <wchar.h> |
|
4139 /* Illustrates how to use wcsnlen API */ |
|
4140 size_t example_wcsnlen() |
|
4141 { |
|
4142 /* input string for which length to be found */ |
|
4143 wchar_t *ws=L"testwcsnlen"; |
|
4144 |
|
4145 /* find the length of the wide char string by */ |
|
4146 /* calling wcsnlen */ |
|
4147 size_t retval = wcsnlen(ws,14); |
|
4148 /* return the number of wide chars in the string */ |
|
4149 /* if retval is less than 14 Else return 14 as the */ |
|
4150 /* length of the string */ |
|
4151 return retval; |
|
4152 } |
|
4153 |
|
4154 @endcode |
|
4155 @return The wcsnlen() returns the number of wide-characters that precede the terminating |
|
4156 NUL character if it is less than maxlen or maxlen if there is a terminating NUL character among maxlen characters pointed by s. |
|
4157 |
|
4158 @see strnlen() |
|
4159 |
|
4160 |
|
4161 |
|
4162 |
|
4163 @publishedAll |
|
4164 @externallyDefinedApi |
|
4165 */ |
|
4166 |
|
4167 |
|
4168 |
|
4169 /** @fn wrealpath(const wchar_t *path, wchar_t *resolved) |
|
4170 @param path |
|
4171 @param resolved |
|
4172 @return The wrealpath function returns resolved path on success. |
|
4173 If an error occurs, wrealpath returns NULL, and resolved path contains the path which caused the problem. |
|
4174 |
|
4175 @code |
|
4176 The wrealpath function resolves all extra "/" |
|
4177 characters and references to /./ and /../ in path, and copies the resulting absolute path into |
|
4178 the memory referenced by resolved path. The resolved path argument must refer to a buffer capable of storing at least PATH_MAX characters. |
|
4179 |
|
4180 The wrealpath function will resolve both absolute and relative paths |
|
4181 and return the absolute path corresponding to path. All but the last component of path must exist when wrealpath is called. |
|
4182 @endcode |
|
4183 |
|
4184 |
|
4185 |
|
4186 Examples: |
|
4187 @code |
|
4188 #include<stdlib.h> |
|
4189 #include<stdio.h> //printf |
|
4190 #include<sys/stat.h> //S_IWUSR |
|
4191 #include<sys/syslimits.h> //PATH_MAX |
|
4192 #include<unistd.h> //chdir |
|
4193 #inlclude<wchar.h> |
|
4194 |
|
4195 int main() |
|
4196 { |
|
4197 wchar_t resolvepath[PATH_MAX]; |
|
4198 FILE *fp = NULL; |
|
4199 wchar_t *rpath = NULL; |
|
4200 |
|
4201 fp = wfopen(L"c:\xyz.txt", L"w"); |
|
4202 if(!fp) |
|
4203 { |
|
4204 printf("wfopen failed!!"); |
|
4205 return -1; |
|
4206 } |
|
4207 |
|
4208 wmkdir(L"c:\tmdir", S_IWUSR); |
|
4209 |
|
4210 int c = wchdir(L"c:\"); |
|
4211 if(c == -1) |
|
4212 { |
|
4213 printf("wchdir failed!!"); |
|
4214 return -1; |
|
4215 } |
|
4216 |
|
4217 rpath = wrealpath(L".\tmdir\..\xyz.txt", resolvepath); |
|
4218 printf("resolvepath: L%s |
|
4219 ", resolvepath); |
|
4220 if(rpath != NULL) |
|
4221 printf("rpath: L%s |
|
4222 |
|
4223 ", rpath); |
|
4224 |
|
4225 fclose(fp); |
|
4226 wrmdir(L"c:\tmdir"); |
|
4227 wunlink(L"c:\xyz.txt"); |
|
4228 return 0; |
|
4229 } |
|
4230 |
|
4231 @endcode |
|
4232 Output |
|
4233 @code |
|
4234 resolvepath: C:\xyz.txt |
|
4235 rpath: C:\xyz.txt |
|
4236 |
|
4237 @endcode |
|
4238 |
|
4239 |
|
4240 @publishedAll |
|
4241 @released |
|
4242 */ |
|
4243 |
|
4244 |
|
4245 |
|
4246 /** @fn wrmdir(const wchar_t *_path) |
|
4247 @param _path |
|
4248 @return The wrmdir() function returns the value 0 if successful; otherwise the |
|
4249 value -1 is returned and the global variable errno is set to indicate the |
|
4250 error. |
|
4251 |
|
4252 The wrmdir system call |
|
4253 removes a directory file |
|
4254 whose name is given by _path. The directory must not have any entries other |
|
4255 than '.' |
|
4256 and '..'. |
|
4257 |
|
4258 Examples: |
|
4259 @code |
|
4260 /* Detailed description: This test code demonstrates usage of wrmdir systemcall, it removes directory |
|
4261 * Example from the current working directory. |
|
4262 * |
|
4263 * Preconditions: Expects empty directoy "Example" in current working directory. |
|
4264 */ |
|
4265 #include <wchar.h> |
|
4266 int main() |
|
4267 { |
|
4268 if(wrmdir(L"Example") < 0 ) |
|
4269 { |
|
4270 printf("wrmdir failed |
|
4271 "); |
|
4272 return -1; |
|
4273 } |
|
4274 printf("Directory Example removed |
|
4275 "); |
|
4276 return 0; |
|
4277 } |
|
4278 |
|
4279 Output |
|
4280 Directory Example removed |
|
4281 |
|
4282 @endcode |
|
4283 |
|
4284 @code |
|
4285 |
|
4286 @endcode |
|
4287 |
|
4288 @capability Deferred @ref RFs::RmDir(const TDesC16&) |
|
4289 |
|
4290 @publishedAll |
|
4291 @released |
|
4292 */ |
|
4293 |
|
4294 |
|
4295 /** @fn wstat(const wchar_t *name, struct stat *st) |
|
4296 @param name |
|
4297 @param st |
|
4298 @return Upon successful completion, the value 0 is returned; otherwise the |
|
4299 value -1 is returned and the global variable errno is set to indicate the error. |
|
4300 |
|
4301 |
|
4302 The wstat system call obtains information about the file pointed to by name. Read, write or execute |
|
4303 permission of the named file is not required, but all directories |
|
4304 listed in the path name leading to the file must be searchable. |
|
4305 |
|
4306 The sb argument is a pointer to a stat structure as defined by \#include \<sys/stat.h\> and into which information is |
|
4307 placed concerning the file. |
|
4308 |
|
4309 The fields of struct stat |
|
4310 related to the file system are as follows: st_dev The numeric ID of the device containing the file. st_ino The file's inode number. st_nlink The number of hard links to the file. |
|
4311 |
|
4312 The st_dev and st_ino fields together identify the file uniquely within the system. |
|
4313 |
|
4314 The time-related fields of struct stat |
|
4315 are as follows: st_atime Time when file data last accessed. |
|
4316 Changed by the .Xr utimes 2, read and readv system calls. st_mtime Time when file data last modified. st_ctime Time when file status was last changed (inode data modification). st_birthtime Time when the inode was created. |
|
4317 |
|
4318 If _POSIX_SOURCE is not defined, the time-related fields are defined as: |
|
4319 @code |
|
4320 #ifndef _POSIX_SOURCE |
|
4321 #define st_atime st_atimespec.tv_sec |
|
4322 #define st_mtime st_mtimespec.tv_sec |
|
4323 #define st_ctime st_ctimespec.tv_sec |
|
4324 #endif |
|
4325 @endcode |
|
4326 |
|
4327 The size-related fields of the struct stat |
|
4328 are as follows: st_size The file size in bytes. st_blksize The optimal I/O block size for the file. st_blocks The actual number of blocks allocated for the file in 512-byte units. |
|
4329 As short symbolic links are stored in the inode, this number may |
|
4330 be zero. |
|
4331 |
|
4332 The access-related fields of struct stat |
|
4333 are as follows: st_uid The user ID of the file's owner. st_gid The group ID of the file. st_mode Status of the file (see below). |
|
4334 |
|
4335 The status information word st_mode has the following bits: |
|
4336 @code |
|
4337 #define S_IFMT 0170000 // type of file |
|
4338 #define S_IFIFO 0010000 // named pipe (fifo) |
|
4339 #define S_IFCHR 0020000 // character special |
|
4340 #define S_IFDIR 0040000 // directory |
|
4341 #define S_IFBLK 0060000 // block special |
|
4342 #define S_IFREG 0100000 // regular |
|
4343 #define S_IFLNK 0120000 // symbolic link |
|
4344 #define S_IFSOCK 0140000 // socket |
|
4345 #define S_IFWHT 0160000 // whiteout |
|
4346 #define S_ISUID 0004000 // set user id on execution |
|
4347 #define S_ISGID 0002000 // set group id on execution |
|
4348 #define S_ISVTX 0001000 // save swapped text even after use |
|
4349 #define S_IRUSR 0000400 // read permission, owner |
|
4350 #define S_IWUSR 0000200 // write permission, owner |
|
4351 #define S_IXUSR 0000100 // execute/search permission, owner |
|
4352 @endcode |
|
4353 |
|
4354 @code |
|
4355 For a list of access modes, see #include <sys/stat.h> The following macros are available |
|
4356 to test whether a st_mode value passed in the m argument corresponds to a file of the specified type: |
|
4357 S_ISBLK (m); Test for a block special file. |
|
4358 S_ISCHR (m); Test for a character special file. |
|
4359 S_ISDIR (m); Test for a directory. |
|
4360 S_ISFIFO (m); Test for a pipe or FIFO special file. |
|
4361 S_ISLNK (m); Test for a symbolic link. |
|
4362 |
|
4363 NOTE: Inode structure is not supported by Symbian OS and hence link count updation is not possible. |
|
4364 Check for symbolic link would always fail because of this reason. |
|
4365 |
|
4366 S_ISREG (m); Test for a regular file. |
|
4367 S_ISSOCK (m); Test for a socket. |
|
4368 S_ISWHT (m); Test for a whiteout. |
|
4369 @endcode |
|
4370 |
|
4371 The macros evaluate to a non-zero value if the test is true or to the value |
|
4372 0 if the test is false. |
|
4373 |
|
4374 @code |
|
4375 st_dev The numeric ID of the device containing the file. |
|
4376 st_ino The file's inode number. |
|
4377 st_nlink |
|
4378 The number of hard links to the file. |
|
4379 |
|
4380 @endcode |
|
4381 @code |
|
4382 st_atime Time when file data last accessed. |
|
4383 Changed by the .Xr utimes 2, read and readv system calls. |
|
4384 st_mtime Time when file data last modified. |
|
4385 st_ctime Time when file status was last changed (inode data modification). |
|
4386 st_birthtime |
|
4387 Time when the inode was created. |
|
4388 |
|
4389 @endcode |
|
4390 @code |
|
4391 st_size The file size in bytes. |
|
4392 st_blksize |
|
4393 The optimal I/O block size for the file. |
|
4394 st_blocks The actual number of blocks allocated for the file in 512-byte units. |
|
4395 As short symbolic links are stored in the inode, this number may |
|
4396 be zero. |
|
4397 |
|
4398 @endcode |
|
4399 @code |
|
4400 st_uid The user ID of the file's owner. |
|
4401 st_gid The group ID of the file. |
|
4402 st_mode |
|
4403 Status of the file (see below). |
|
4404 |
|
4405 @endcode |
|
4406 @code |
|
4407 Test for a block special file. |
|
4408 Test for a character special file. |
|
4409 Test for a directory. |
|
4410 Test for a pipe or FIFO special file. |
|
4411 Test for a symbolic link. NOTE: Inode structure is not supported by Symbian OS and hence link count updation is not possible. |
|
4412 Check for symbolic link would always fail because of this reason. |
|
4413 Test for a regular file. |
|
4414 Test for a socket. |
|
4415 Test for a whiteout. |
|
4416 |
|
4417 @endcode |
|
4418 |
|
4419 |
|
4420 Examples: |
|
4421 @code |
|
4422 /* Detailed description: Sample usage of wstat system call |
|
4423 * Preconditions: Example.txt file should be present in working directory |
|
4424 */ |
|
4425 #include <fcntl.h> |
|
4426 #include <unistd.h> |
|
4427 #include <sys/types.h> |
|
4428 #include <sys/stat.h> |
|
4429 #include <wchar.h> |
|
4430 int main() |
|
4431 { |
|
4432 struct stat buf; |
|
4433 if(wstat(L"Example.txt" , &buf;) < 0 ) |
|
4434 { |
|
4435 printf("Failed to wstat Example.txt |
|
4436 "); |
|
4437 return -1; |
|
4438 } |
|
4439 printf("wstat system call succeded |
|
4440 "); |
|
4441 return 0; |
|
4442 } |
|
4443 |
|
4444 @endcode |
|
4445 Output |
|
4446 @code |
|
4447 wstat system call succeded |
|
4448 |
|
4449 @endcode |
|
4450 @see access() |
|
4451 @see wchmod() |
|
4452 @see chown() |
|
4453 |
|
4454 |
|
4455 |
|
4456 @capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&) |
|
4457 |
|
4458 @publishedAll |
|
4459 @released |
|
4460 */ |
|
4461 |
|
4462 |
|
4463 /** @fn wstat64(const wchar_t *name, struct stat64 *st) |
|
4464 @param name |
|
4465 @param st |
|
4466 @return Upon successful completion, the value 0 is returned; otherwise the |
|
4467 value -1 is returned and the global variable errno is set to indicate the error. |
|
4468 |
|
4469 The wstat64() function is a 64-bit version of wstat. |
|
4470 |
|
4471 @see wstat() |
|
4472 |
|
4473 @publishedAll |
|
4474 @released |
|
4475 */ |
|
4476 |
|
4477 /** @fn wsystem(const wchar_t *cmd) |
|
4478 @param cmd |
|
4479 @return The wsystem function |
|
4480 returns the exit status of the child process as returned by |
|
4481 process' exit reason |
|
4482 or -1 if an error occurred when spawning a new process. |
|
4483 |
|
4484 The wsystem function |
|
4485 spawns another process with the argument cmd. The calling process waits for the child process |
|
4486 to finish executing. |
|
4487 |
|
4488 If cmd is a NULL pointer, wsystem will return non-zero to indicate that wsystem is suporrted |
|
4489 and zero if it is not supported. |
|
4490 |
|
4491 |
|
4492 |
|
4493 Examples: |
|
4494 @code |
|
4495 #include <stdlib.h> |
|
4496 #include <stdio.h> //printf |
|
4497 #include <wchar.h> |
|
4498 |
|
4499 int main( void ) |
|
4500 { |
|
4501 int retVal = -1; |
|
4502 |
|
4503 printf( "Calling wsystem()... |
|
4504 " ); |
|
4505 |
|
4506 /* helloworld.exe is an executable that just prints |
|
4507 * "Hello world!" and it should be created before |
|
4508 * executing this example code. |
|
4509 */ |
|
4510 retVal = wsystem(L"c:\sys\bin\helloworld.exe"); |
|
4511 |
|
4512 /* Print the return value of wsystem() */ |
|
4513 printf( "wsystem() returned: %d", retVal ); |
|
4514 |
|
4515 return 0; |
|
4516 } |
|
4517 |
|
4518 @endcode |
|
4519 Output |
|
4520 @code |
|
4521 Calling wsystem()... |
|
4522 wsystem() returned: -1 |
|
4523 |
|
4524 @endcode |
|
4525 @see wpopen() |
|
4526 |
|
4527 |
|
4528 |
|
4529 |
|
4530 @publishedAll |
|
4531 @released |
|
4532 */ |
|
4533 |
|
4534 |
|
4535 |
|
4536 /** @fn wunlink(const wchar_t *_path) |
|
4537 @param _path |
|
4538 @return Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno set to indicate the error. |
|
4539 |
|
4540 The wunlink system call removes the link named by _path from its file system. |
|
4541 |
|
4542 Symbian OS simulates links so there is no reference count and files are unaware |
|
4543 of links. Calling unlink on a file will always close the file, regardless of |
|
4544 whether there is another link. |
|
4545 |
|
4546 The _path argument may not be a directory. |
|
4547 |
|
4548 Examples: |
|
4549 @code |
|
4550 /* |
|
4551 * Detailed description: Example to wunlink a link file |
|
4552 * Precondition: A file by name "Link" should exist in |
|
4553 * c: drive. |
|
4554 */ |
|
4555 #include <wchar.h> |
|
4556 #include <stdio.h> |
|
4557 int main(void) |
|
4558 { |
|
4559 if(wunlink(L"C:\Link")) |
|
4560 { |
|
4561 printf("wunlink on link file failed"); |
|
4562 } |
|
4563 printf("wunlink on link file succeeded"); |
|
4564 } |
|
4565 |
|
4566 @endcode |
|
4567 Output |
|
4568 @code |
|
4569 wunlink on link file succeeded. |
|
4570 |
|
4571 @endcode |
|
4572 @see close() |
|
4573 @see rmdir() |
|
4574 |
|
4575 |
|
4576 |
|
4577 @capability Deferred @ref RFs::Att(const TDesC16&, unsigned&) |
|
4578 @capability Deferred @ref RFs::SetAtt(const TDesC16&, unsigned, unsigned) |
|
4579 @capability Deferred @ref RFs::Delete(const TDesC16&) |
|
4580 |
|
4581 @publishedAll |
|
4582 @released |
|
4583 */ |
|
4584 |
|
4585 |
|
4586 |
|
4587 /** @fn wpopen(const wchar_t* command, const wchar_t* wmode ) |
|
4588 @param command |
|
4589 @param wmode |
|
4590 @return The wpopen function returns NULL if the fork |
|
4591 or pipe calls fail, |
|
4592 or if it cannot allocate memory. And returns stream pointer on success. |
|
4593 |
|
4594 The wpopen function opens a process by creating a pipe and invoking the shell (creating a process). Since a pipe is by definition unidirectional, The wmode argument may specify only reading or writing, not both; the resulting stream is correspondingly read-only ("r") or write-only "w". If type is anything other than this, then the behavior is undefined. |
|
4595 |
|
4596 The command argument is a pointer to a null-terminated wide character string containing a shell command line. |
|
4597 This command is passed to /bin/sh using the - c flag; interpretation, if any, is performed by the shell. |
|
4598 |
|
4599 The return value from wpopen is a normal standard I/O stream in all respects |
|
4600 save that it must be closed with pclose rather than fclose. Writing to such a stream |
|
4601 writes to the standard input of the command; |
|
4602 the command's standard output is the same as that of the process that called wpopen, unless this is altered by the command itself. |
|
4603 Conversely, reading from a "wpopened" |
|
4604 stream reads the command's standard output, and |
|
4605 the command's standard input is the same as that of the process that called wpopen. |
|
4606 |
|
4607 Note that output wpopen streams are fully buffered by default. |
|
4608 |
|
4609 |
|
4610 |
|
4611 @see popen() |
|
4612 @see pclose() |
|
4613 @see pipe() |
|
4614 @see fclose() |
|
4615 @see fflush() |
|
4616 @see fopen() |
|
4617 @see system() |
|
4618 |
|
4619 |
|
4620 Bugs: |
|
4621 |
|
4622 Since the standard input of a command opened for reading |
|
4623 shares its seek offset with the process that called wpopen, if the original process has done a buffered read, |
|
4624 the command's input position may not be as expected. |
|
4625 Similarly, the output from a command opened for writing |
|
4626 may become intermingled with that of the original process. |
|
4627 The latter can be avoided by calling fflush before wpopen. Failure to execute the shell |
|
4628 is indistinguishable from the shell's failure to execute command, |
|
4629 or an immediate exit of the command. |
|
4630 The only hint is an exit status of 127. The wpopen function always calls sh, never calls csh. |
|
4631 |
|
4632 |
|
4633 @publishedAll |
|
4634 @released |
|
4635 */ |
|
4636 |
|
4637 |
|
4638 |
|
4639 /** @fn wopen(const wchar_t *file, int flags, ...) |
|
4640 @param file |
|
4641 @param flags |
|
4642 @param ... |
|
4643 @return If successful, wopen returns a non-negative integer, termed a file descriptor. |
|
4644 It returns -1 on failure, and sets errno to indicate the error. |
|
4645 |
|
4646 The wide character file-name specified by the wide character string file is opened |
|
4647 for reading and/or writing as specified by the |
|
4648 argument flags and the file descriptor returned to the calling process. |
|
4649 The flags argument may indicate the file is to be |
|
4650 created if it does not exist (by specifying the O_CREAT flag). |
|
4651 In this case wopen requires a third argument mode_t mode , |
|
4652 and the file is created with mode mode as described in chmod and modified by the process' umask value (see umask |
|
4653 |
|
4654 |
|
4655 |
|
4656 The flags specified are formed by or 'ing the following values |
|
4657 |
|
4658 @code |
|
4659 O_RDONLYopen for reading only |
|
4660 O_WRONLYopen for writing only |
|
4661 O_RDWRopen for reading and writing |
|
4662 O_APPENDappend on each write |
|
4663 O_CREATcreate file if it does not exist |
|
4664 O_TRUNCtruncate size to 0 |
|
4665 O_EXCLerror if create and file exists |
|
4666 @endcode |
|
4667 |
|
4668 Opening a file with O_APPEND set causes each write on the file |
|
4669 to be appended to the end. |
|
4670 If O_TRUNC is specified and the |
|
4671 file exists, the file is truncated to zero length. |
|
4672 If O_EXCL is set with O_CREAT and the file already |
|
4673 exists, wopen returns an error. |
|
4674 This may be used to |
|
4675 implement a simple exclusive access locking mechanism. |
|
4676 If O_EXCL is set and the last component of the path is |
|
4677 a symbolic link, wopen will fail even if the symbolic |
|
4678 link points to a non-existent name. |
|
4679 |
|
4680 |
|
4681 |
|
4682 If successful, wopen returns a non-negative integer, termed a file descriptor. |
|
4683 It returns -1 on failure. |
|
4684 The file pointer used to mark the current position within the |
|
4685 file is set to the beginning of the file. |
|
4686 |
|
4687 When a new file is created it is given the group of the directory |
|
4688 which contains it. |
|
4689 |
|
4690 The new descriptor is set to remain wopen across execve system calls; see close and fcntl . |
|
4691 |
|
4692 The system imposes a limit on the number of file descriptors |
|
4693 wopen simultaneously by one process. |
|
4694 The getdtablesize system call returns the current system limit. |
|
4695 |
|
4696 |
|
4697 |
|
4698 |
|
4699 |
|
4700 Notes: |
|
4701 |
|
4702 @code |
|
4703 1) Mode values for group and others are ignored |
|
4704 |
|
4705 2) Execute bit and setuid on exec bit are ignored. |
|
4706 |
|
4707 3) The default working directory of a process is initalized to C: \p rivate \U ID |
|
4708 (UID of the calling application) and any data written into this directory persists |
|
4709 between phone resets. |
|
4710 |
|
4711 4) If the specified file is a symbolic link and the file it is pointing to |
|
4712 is invalid, the symbolic link file will be automatically removed. |
|
4713 |
|
4714 5) A file in cannot be created with write-only permissions. Attempting to create |
|
4715 a file with write-only permissions will result in a file with read-write permission. |
|
4716 |
|
4717 6) Creating a new file with the O_CREAT flag does not alter the time stamp |
|
4718 of the parent directory. |
|
4719 |
|
4720 7) A file has only two time stamps: access and modification. Creation time |
|
4721 stamp of the file is not supported and access time stamp is initially set equal |
|
4722 to modification time stamp. |
|
4723 @endcode |
|
4724 |
|
4725 Examples: |
|
4726 @code |
|
4727 /*This example creates a file in the current working directory and |
|
4728 * opens it in read-write mode. |
|
4729 */ |
|
4730 #include <sys/types.h> |
|
4731 #include <sys/stat.h> |
|
4732 #include <wchar.h> |
|
4733 int main() |
|
4734 { |
|
4735 int fd = 0 ; |
|
4736 fd = wopen(L"Example.txt" , O_CREAT | O_EXCL , 0666) ; |
|
4737 if(fd < 0 ) |
|
4738 { |
|
4739 printf("Failed to create and wopen file in current working directory |
|
4740 ") ; |
|
4741 return -1 ; |
|
4742 } |
|
4743 printf("File created and opened in current working directory |
|
4744 " ) ; |
|
4745 return 0 ; |
|
4746 } |
|
4747 |
|
4748 @endcode |
|
4749 Output |
|
4750 @code |
|
4751 File created and opened in current working directory |
|
4752 |
|
4753 @endcode |
|
4754 @see chmod() |
|
4755 @see close() |
|
4756 @see dup() |
|
4757 @see getdtablesize() |
|
4758 @see lseek() |
|
4759 @see read() |
|
4760 @see umask() |
|
4761 @see write() |
|
4762 @see fopen() |
|
4763 @see open() |
|
4764 |
|
4765 |
|
4766 |
|
4767 @capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&) |
|
4768 |
|
4769 @publishedAll |
|
4770 @released |
|
4771 */ |
|
4772 |
|
4773 /** @fn wopen64(const wchar_t *file, int flags, ...) |
|
4774 @param file |
|
4775 @param flags |
|
4776 @param ... |
|
4777 @return If successful, wopen returns a non-negative integer, termed a file descriptor. |
|
4778 It returns -1 on failure, and sets errno to indicate the error. |
|
4779 |
|
4780 The wopen64() function is a 64-bit version of wopen. |
|
4781 |
|
4782 @see wopen() |
|
4783 |
|
4784 @publishedAll |
|
4785 @released |
|
4786 */ |
|
4787 |
|
4788 |
|
4789 /** @fn wfopen(const wchar_t *file, const wchar_t *mode) |
|
4790 @param file |
|
4791 @param mode |
|
4792 @return Upon successful completion wfopen returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error. |
|
4793 |
|
4794 @code |
|
4795 "r" Open text file for reading. |
|
4796 The stream is positioned at the beginning of the file. |
|
4797 "r+" Open for reading and writing. |
|
4798 The stream is positioned at the beginning of the file. |
|
4799 "w" Truncate to zero length or create text file for writing. |
|
4800 The stream is positioned at the beginning of the file. |
|
4801 "w+" Open for reading and writing. |
|
4802 The file is created if it does not exist, otherwise it is truncated. |
|
4803 The stream is positioned at the beginning of the file. |
|
4804 "a" Open for writing. |
|
4805 The file is created if it does not exist. |
|
4806 The stream is positioned at the end of the file. |
|
4807 Subsequent writes to the file will always end up at the then current |
|
4808 end of file, irrespective of any intervening fseek or similar. |
|
4809 "a+" Open for reading and writing. |
|
4810 The file is created if it does not exist. |
|
4811 The stream is positioned at the end of the file. |
|
4812 Subsequent writes to the file will always end up at the then current |
|
4813 end of file, irrespective of any intervening fseek or similar. |
|
4814 |
|
4815 @endcode |
|
4816 |
|
4817 |
|
4818 The mode string can also include the letter "b" either as a third character or |
|
4819 as a character between the characters in any of the two-character strings described above. |
|
4820 This is strictly for compatibility with -isoC and has no effect; the "b" is ignored. |
|
4821 |
|
4822 Reads and writes may be intermixed on read/write streams in any order, |
|
4823 and do not require an intermediate seek as in previous versions of stdio. This is not portable to other systems, however; ANSI C requires that |
|
4824 a file positioning function intervene between output and input, unless |
|
4825 an input operation encounters end-of-file. |
|
4826 |
|
4827 |
|
4828 |
|
4829 Examples: |
|
4830 @code |
|
4831 /* this program shows opening in write mode,write data and close */ |
|
4832 /* again open in append mode and write data */ |
|
4833 /* Check file c:\wfopen.txt */ |
|
4834 #include <stdio.h> |
|
4835 int main(void) |
|
4836 { |
|
4837 FILE *fp; |
|
4838 wchar_t* name = L"c:\wfopen.txt"; |
|
4839 if ((fp = wfopen (name, L"wb")) == NULL) |
|
4840 { |
|
4841 printf("Error creating file"); |
|
4842 return -1; |
|
4843 } |
|
4844 printf("Opened file |
|
4845 "); |
|
4846 fprintf(fp, "This is the first line |
|
4847 "); |
|
4848 printf("Wrote to file |
|
4849 "); |
|
4850 fclose (fp); |
|
4851 printf("Closed file |
|
4852 "); |
|
4853 if ((fp = wfopen (name, L"a")) == NULL) |
|
4854 { |
|
4855 printf("Error opening file"); |
|
4856 return -1; |
|
4857 } |
|
4858 printf("Opened file for appending |
|
4859 "); |
|
4860 fprintf(fp, "This is the second line |
|
4861 "); |
|
4862 fclose (fp); |
|
4863 printf("closed file, check output in c:\ wfopen.txt file |
|
4864 "); |
|
4865 wunlink(name); |
|
4866 return 0; |
|
4867 } |
|
4868 |
|
4869 @endcode |
|
4870 Output |
|
4871 @code |
|
4872 Opened file |
|
4873 Wrote to file |
|
4874 Closed file |
|
4875 Opened file for appending |
|
4876 closed file, check output in c:\ wfopen.txt file |
|
4877 |
|
4878 @endcode |
|
4879 |
|
4880 Errors: |
|
4881 |
|
4882 [EINVAL] The mode argument to wfopen, was invalid. |
|
4883 The wfopen, functions may also fail and set errno for any of the errors specified for the routine malloc. The wfopen function may also fail and set errno for any of the errors specified for the routine wopen. |
|
4884 |
|
4885 Note: |
|
4886 |
|
4887 @code |
|
4888 1) Mode values for group and others will be ignored for file creation,execute bit and setuid on exec bit on an file don't have any effect while file creation. |
|
4889 Default working directory of a process is initialized to C:\private\UID (UID of the calling application) and any data written into this directory persists between phone resets. |
|
4890 |
|
4891 2) If the specified file is a symbolic link and the file it is pointing to |
|
4892 is invalid the symbolic link file will be automatically removed. |
|
4893 @endcode |
|
4894 |
|
4895 Limitations: |
|
4896 |
|
4897 A file in cannot be created with write-only permission and attempting to |
|
4898 create one will result in a file with read-write permission. Creating a new file |
|
4899 with the O_CREAT flag does not alter the time stamp of its parent directory. The |
|
4900 newly created entry has only two time stamps: access and modification. Creation |
|
4901 time stamp is not supported and access time stamp is initially equal to modification |
|
4902 time stamp. open, fclose and fflush. |
|
4903 |
|
4904 @see open() |
|
4905 @see fclose() |
|
4906 @see fileno() |
|
4907 @see fseek() |
|
4908 @see fopen() |
|
4909 |
|
4910 |
|
4911 |
|
4912 @capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&) |
|
4913 |
|
4914 @publishedAll |
|
4915 @released |
|
4916 */ |
|
4917 |
|
4918 /** @fn wfopen64(const wchar_t *file, const wchar_t *mode) |
|
4919 @param file |
|
4920 @param mode |
|
4921 @return Upon successful completion wfopen returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error. |
|
4922 |
|
4923 The wfopen64() function is a 64-bit version of wfopen. |
|
4924 |
|
4925 @see wfopen() |
|
4926 |
|
4927 @publishedAll |
|
4928 @released |
|
4929 */ |
|
4930 |
|
4931 |
|
4932 |
|
4933 /** @fn wrename(const wchar_t *oldpath, const wchar_t *newpath) |
|
4934 @param oldpath |
|
4935 @param newpath |
|
4936 @return The wrename() function returns the value 0 if successful; otherwise it returns |
|
4937 -1 and sets the global variable errno to indicate the error. |
|
4938 |
|
4939 The wrename system call |
|
4940 causes the link with the wide character name oldpath to be renamed with the wide character name newpath. If newpath exists, it is first removed. |
|
4941 Both oldpath and newpath must be of the same type (that is, both directories or both |
|
4942 non-directories), and must reside on the same file system. |
|
4943 |
|
4944 If the final component of from is a symbolic link the symbolic link is renamed, not the file or |
|
4945 directory to which it points. |
|
4946 |
|
4947 If a file with a symbolic link pointing to it is renamed, then |
|
4948 a subsequent open call on the symbolic link file would automatically remove the link file, i.e |
|
4949 consider a symbolic file link.x pointing to a file abc.x. If the file abc.x is |
|
4950 renamed to abcd.x then, a subsequent open call on link.x file would automatically remove link.x file. |
|
4951 |
|
4952 Notes: |
|
4953 |
|
4954 wrename fails if from and to are files and are in use (i.e. if any either of the files is open). |
|
4955 |
|
4956 Parent directory time stamps are uneffected. |
|
4957 |
|
4958 The new entry has only two time stamps: modification and access. The access |
|
4959 time stamp is initially equal to modification time stamp. |
|
4960 |
|
4961 |
|
4962 |
|
4963 Examples: |
|
4964 @code |
|
4965 /* Detailed description : This sample code demonstrates usage of wrename system call. |
|
4966 * Preconditions : Example.cfg file should be present in the current working directory. |
|
4967 */ |
|
4968 #include <wchar.h> |
|
4969 #include <stdio.h> |
|
4970 int main() |
|
4971 { |
|
4972 if(wrename(L"Example.txt" , L"Example2.txt") < 0 ) { |
|
4973 printf("Failed to wrename Example.txt |
|
4974 "); |
|
4975 return -1; |
|
4976 } |
|
4977 printf("wrename successful |
|
4978 "); |
|
4979 return 0; |
|
4980 } |
|
4981 |
|
4982 @endcode |
|
4983 Output: |
|
4984 @code |
|
4985 wrename successful |
|
4986 |
|
4987 @endcode |
|
4988 |
|
4989 Errors: |
|
4990 |
|
4991 The wrename system call will fail and neither of the argument files will be affected if: |
|
4992 [EINVAL] Invalid argument. |
|
4993 [ENAMETOOLONG] A component of a path exceeded 255 characters. |
|
4994 [ENOENT] The named file does not exist. |
|
4995 [EACCES] Search permission is denied for a component of the path prefix. |
|
4996 [EACCES] The from argument is a parent directory of to, or an attempt is made to wrename ‘.’ or ‘..’. |
|
4997 |
|
4998 |
|
4999 @see open() |
|
5000 @see symlink() |
|
5001 @see rename() |
|
5002 |
|
5003 |
|
5004 |
|
5005 @capability Deferred @ref RFs::Rename(const TDesC& anOldName,const TDesC& aNewName) |
|
5006 @capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&) |
|
5007 @capability Deferred @ref RFs::RmDir(const TDesC16&) |
|
5008 @capability Deferred @ref RFs::SetAtt(const TDesC16&, unsigned, unsigned) |
|
5009 @capability Deferred @ref RFs::Delete(const TDesC16&) |
|
5010 |
|
5011 @publishedAll |
|
5012 @released |
|
5013 */ |
|
5014 |
|
5015 |
|
5016 |
|
5017 /** @fn wchdir(const wchar_t *_path) |
|
5018 @param _path |
|
5019 @return Upon successful completion, the value 0 is returned; otherwise the |
|
5020 value -1 is returned and the global variable errno is set to indicate the |
|
5021 error. |
|
5022 |
|
5023 The _path argument points to the pathname of a directory which is a wide character string. |
|
5024 The wchdir system call |
|
5025 causes the named directory |
|
5026 to become the current working directory, that is, |
|
5027 the starting point for _path searches of pathnames not beginning with |
|
5028 a slash, '/.' |
|
5029 |
|
5030 |
|
5031 |
|
5032 Examples: |
|
5033 @code |
|
5034 #include<wchar.h> /* wmkdir, wrmdir */ |
|
5035 #include <sys/stat.h> /* S_IRWXU */ |
|
5036 #include <stdio.h> /* printf */ |
|
5037 int main() |
|
5038 { |
|
5039 int ret_wmkdir = wmkdir(L"dirName", S_IRWXU); /* create directory */ |
|
5040 if(ret_wmkdir < 0) |
|
5041 { |
|
5042 printf("error creating directory"); |
|
5043 return -1; |
|
5044 } |
|
5045 else |
|
5046 { |
|
5047 int ret_wchdir = wchdir(L"dirName"); /* change directory */ |
|
5048 if(ret_wchdir < 0) |
|
5049 { |
|
5050 printf("error changing directory"); |
|
5051 return -1; |
|
5052 } |
|
5053 else |
|
5054 { |
|
5055 printf("working directory changed"); |
|
5056 } |
|
5057 wrmdir(L"dirname"); /* remove directory */ |
|
5058 } |
|
5059 return 0; |
|
5060 } |
|
5061 |
|
5062 @endcode |
|
5063 Output |
|
5064 @code |
|
5065 working directory changed |
|
5066 |
|
5067 @endcode |
|
5068 @see chdir() |
|
5069 |
|
5070 |
|
5071 |
|
5072 @capability Deferred @ref RFs::Att(const TDesC16&, unsigned&) |
|
5073 @capability Deferred @ref RFs::SetSessionPath(const TDesC16&) |
|
5074 |
|
5075 @publishedAll |
|
5076 @released |
|
5077 */ |
|
5078 |
|
5079 |
|
5080 |
|
5081 /** @fn wchmod(const wchar_t *_path, mode_t _mode) |
|
5082 @param _path |
|
5083 @param _mode |
|
5084 @return Upon successful completion, the value 0 is returned; otherwise the |
|
5085 value -1 is returned and the global variable errno is set to indicate the |
|
5086 error. |
|
5087 |
|
5088 The file permission bits of the wide character file-name specified by _path are changed to _mode. The wchmod system call verifies that the process owner (user) either owns the file specified by _path is the super-user. |
|
5089 A mode is created from or’d permission bit masks defined in \#include \<sys/stat.h\>: |
|
5090 |
|
5091 @code |
|
5092 #define S_IRWXU 0000700 // RWX mask for owner |
|
5093 #define S_IRUSR 0000400 // R for owner |
|
5094 #define S_IWUSR 0000200 // W for owner |
|
5095 #define S_IXUSR 0000100 // X for owner |
|
5096 #define S_IRWXG 0000070 // RWX mask for group |
|
5097 #define S_IRGRP 0000040 // R for group |
|
5098 #define S_IWGRP 0000020 // W for group |
|
5099 #define S_IXGRP 0000010 // X for group |
|
5100 #define S_IRWXO 0000007 // RWX mask for other |
|
5101 #define S_IROTH 0000004 // R for other |
|
5102 #define S_IWOTH 0000002 // W for other |
|
5103 #define S_IXOTH 0000001 // X for other |
|
5104 #define S_ISUID 0004000 // set user id on execution |
|
5105 #define S_ISGID 0002000 // set group id on execution |
|
5106 #ifndef __BSD_VISIBLE |
|
5107 #define S_ISTXT 0001000 // sticky bit |
|
5108 #endif |
|
5109 @endcode |
|
5110 |
|
5111 Note : sticky bit and setuid on exec bit are not supported, permission values for users is considered while premissions values for group and others are ignored(As there is no concept of group and others). An attempt to change file permission to write-only changes the file permission to read-write. Permissions for directory will be ignored. |
|
5112 |
|
5113 |
|
5114 Examples: |
|
5115 @code |
|
5116 #include <wchar.h> /* wchmode, wfopen */ |
|
5117 #include <sys/stat.h> /* S_IWUSR */ |
|
5118 #include <stdio.h> /* printf */ |
|
5119 int main() |
|
5120 { |
|
5121 FILE * wfp = wfopen(L"fileName.txt", L"wb"); /* create file */ |
|
5122 if(wfp) |
|
5123 { |
|
5124 fclose(wfp); /* close file */ |
|
5125 int ret = wchmod(L"fileName", S_IWUSR); /* change mode */ |
|
5126 if(ret < 0) |
|
5127 { |
|
5128 printf("error changing mode"); |
|
5129 return -1; |
|
5130 } |
|
5131 else |
|
5132 { |
|
5133 printf("mode changed"); |
|
5134 } |
|
5135 } |
|
5136 else |
|
5137 { |
|
5138 printf("error creating file"); |
|
5139 return -1; |
|
5140 } |
|
5141 return 0; |
|
5142 } |
|
5143 |
|
5144 @endcode |
|
5145 Output |
|
5146 @code |
|
5147 mode changed |
|
5148 |
|
5149 @endcode |
|
5150 @see chmod() |
|
5151 @see chown() |
|
5152 @see open() |
|
5153 @see stat() |
|
5154 |
|
5155 |
|
5156 |
|
5157 @capability Deferred @ref RFs::SetAtt(const TDesC16&, unsigned, unsigned) |
|
5158 |
|
5159 @publishedAll |
|
5160 @released |
|
5161 */ |
|
5162 |
|
5163 |
|
5164 |
|
5165 /** @fn wgetcwd(wchar_t *_buf, size_t _size) |
|
5166 @param _buf |
|
5167 @param _size |
|
5168 @return Upon successful completion, a pointer to the pathname is returned. |
|
5169 Otherwise a NULL pointer is returned and the global variable errno is set to indicate the error. |
|
5170 In addition, wgetcwd copies the error message associated with errno into the memory referenced by _buf. |
|
5171 |
|
5172 The wgetcwd function copies the absolute pathname of the current working directory |
|
5173 into the memory referenced by _buf which is a wchar_t pointer |
|
5174 and returns a pointer to _buf. The size argument is the _size, in bytes, of the array referenced by _buf. |
|
5175 |
|
5176 If _buf is NULL, space is allocated as indicated by size to store the pathname and the current working directory is |
|
5177 returned as long as the _size bytes are sufficient to hold the working directory name. |
|
5178 This space may later be free'd. |
|
5179 |
|
5180 This routine has traditionally been used by programs to save the |
|
5181 name of a working directory for the purpose of returning to it. |
|
5182 A much faster and less error-prone method of accomplishing this is to |
|
5183 open the current directory ('.') |
|
5184 and use the fchdir function to return. |
|
5185 |
|
5186 Examples: |
|
5187 @code |
|
5188 #include<wchar.h> |
|
5189 #include<stdio.h> |
|
5190 #include <stdlib.h> |
|
5191 #define BUF_SIZE 100 |
|
5192 |
|
5193 int main() |
|
5194 { |
|
5195 int c; |
|
5196 long size = BUF_SIZE; |
|
5197 wchar_t *buf = NULL; |
|
5198 wchar_t *ptr = NULL; |
|
5199 |
|
5200 c = wchdir("c:\"); /* change directory to c: */ |
|
5201 |
|
5202 buf = (wchar_t *)malloc((size_t)size); |
|
5203 |
|
5204 if (buf != NULL && c == 0) |
|
5205 { |
|
5206 ptr = wgetcwd(buf, (size_t)size); /* call wgetcwd to fetch the current directory */ |
|
5207 printf("wgetcwd returned: %s |
|
5208 ", ptr); |
|
5209 } |
|
5210 free(buf); |
|
5211 return 0; |
|
5212 } |
|
5213 |
|
5214 @endcode |
|
5215 Output |
|
5216 @code |
|
5217 wgetcwd returned: c:\ |
|
5218 |
|
5219 @endcode |
|
5220 |
|
5221 Notes: |
|
5222 |
|
5223 The wgetcwd function returns the default working directory as c:\\private\\XXXXXXXX (where XXXXXXXX is the UID of the process) as the |
|
5224 default session path is initialised to c:\\private\\current_process'_UID in Symbian OS. |
|
5225 |
|
5226 @see chdir() |
|
5227 @see malloc() |
|
5228 @see strerror() |
|
5229 @see wgetcwd() |
|
5230 |
|
5231 |
|
5232 |
|
5233 |
|
5234 @publishedAll |
|
5235 @released |
|
5236 */ |
|
5237 |
|
5238 |
|
5239 |
|
5240 /** @fn wmkdir(const wchar_t *_path, mode_t _mode) |
|
5241 @param _path |
|
5242 @param _mode |
|
5243 @return The wmkdir() function returns the value 0 if successful; otherwise the |
|
5244 value -1 is returned and the global variable errno is set to indicate the |
|
5245 error. |
|
5246 |
|
5247 The directory with the wide character name _path is created with the access permissions specified by _mode. |
|
5248 |
|
5249 Notes: |
|
5250 |
|
5251 mode is ignored. |
|
5252 |
|
5253 Parent directory time stamps are not updated. |
|
5254 |
|
5255 Examples: |
|
5256 @code |
|
5257 #include <sys/stat.h> |
|
5258 #include <wchar.h> |
|
5259 #include <stdio.h> |
|
5260 int main() |
|
5261 { |
|
5262 if(wmkdir(L"Example" , 0666) < 0 ) |
|
5263 { |
|
5264 printf("Directory creation failed |
|
5265 "); |
|
5266 return -1; |
|
5267 } |
|
5268 printf("Directory Example created |
|
5269 "); |
|
5270 return 0; |
|
5271 } |
|
5272 |
|
5273 @endcode |
|
5274 Output |
|
5275 @code |
|
5276 Directory Example created |
|
5277 |
|
5278 @endcode |
|
5279 @see chmod() |
|
5280 @see stat() |
|
5281 @see umask() |
|
5282 @see mkdir() |
|
5283 |
|
5284 |
|
5285 |
|
5286 @capability Deferred @ref RFs::MkDir(const TDesC16&) |
|
5287 |
|
5288 @publishedAll |
|
5289 @released |
|
5290 */ |
|
5291 |
|
5292 |
|
5293 |
|
5294 /** @fn wclosedir(WDIR *wdp) |
|
5295 @param wdp |
|
5296 @return The wclosedir function returns 0 on success and on failure -1 is returned and the global variable errno is set to indicate the error.. |
|
5297 |
|
5298 |
|
5299 |
|
5300 The wclosedir function closes the named directory stream and frees the structure associated with the dirp pointer. |
|
5301 |
|
5302 |
|
5303 |
|
5304 Examples: |
|
5305 @code |
|
5306 /* Detailed description: This test code demonstrates usage of wclose system call.* |
|
5307 * Preconditions: Expects Test directory to be present in current working directory. |
|
5308 */ |
|
5309 #include <wchar.h> |
|
5310 #include <dirent.h> |
|
5311 int main() |
|
5312 { |
|
5313 WDIR *DirHandle; |
|
5314 if(!(DirHandle = wopendir(L"Test") ) ) |
|
5315 { |
|
5316 printf("Failed to open directoy Test |
|
5317 "); |
|
5318 return -1; |
|
5319 } |
|
5320 if(wclosedir(DirHandle) < 0 ) |
|
5321 { |
|
5322 printf("Close dir failed |
|
5323 "); |
|
5324 return -1; |
|
5325 } |
|
5326 printf("Directory Test closed |
|
5327 "); |
|
5328 return 0; |
|
5329 } |
|
5330 |
|
5331 @endcode |
|
5332 Output |
|
5333 @code |
|
5334 Directory Test closed |
|
5335 |
|
5336 @endcode |
|
5337 @see wopendir() |
|
5338 @see wreaddir() |
|
5339 @see opendir() |
|
5340 @see readdir() |
|
5341 |
|
5342 |
|
5343 |
|
5344 |
|
5345 @publishedAll |
|
5346 @released |
|
5347 */ |
|
5348 |
|
5349 |
|
5350 |
|
5351 /** @fn wreaddir(WDIR *wdp) |
|
5352 @param wdp |
|
5353 @return The wreaddir function returns a pointer to a wdirent structure, |
|
5354 or NULL if an error occurs or end-of-file is reached. |
|
5355 |
|
5356 |
|
5357 |
|
5358 The wreaddir function |
|
5359 returns a wdirent pointer to the next directory entry. |
|
5360 It returns NULL upon reaching the end of the directory or detecting an invalid wreaddir operation on the directory stream. The new position reverts to the one associated with the directory stream when the wtelldir operation was performed. |
|
5361 |
|
5362 |
|
5363 |
|
5364 Note: wreaddir operates on a static directory structure created by wopendir . Asynchronous operations on the directory itself will not |
|
5365 be reflected in calls to wreaddir . |
|
5366 |
|
5367 |
|
5368 |
|
5369 Examples: |
|
5370 @code |
|
5371 /* Detailed description: Sample usage of wreaddir call |
|
5372 * Preconditions: Example Directory should be present in current working directory and should contain atleast one file/directory. |
|
5373 */ |
|
5374 #include <dirent.h> |
|
5375 #include <unistd.h> |
|
5376 #include <wchar.h> |
|
5377 int main() |
|
5378 { |
|
5379 WDIR *dirName; |
|
5380 struct wdirent *Dir; |
|
5381 dirName = wopendir(L"Example"); |
|
5382 if(dirName == NULL ) { |
|
5383 printf("Failed to open directory |
|
5384 "); |
|
5385 return -1; |
|
5386 } |
|
5387 if(!(Dir = wreaddir(dirName)) ) { |
|
5388 printf("Read dir failed |
|
5389 "); |
|
5390 return -1; |
|
5391 } |
|
5392 printf("Directory Example read |
|
5393 "); |
|
5394 wclosedir(dirName); |
|
5395 return 0; |
|
5396 } |
|
5397 |
|
5398 @endcode |
|
5399 Output |
|
5400 @code |
|
5401 Directory Example read |
|
5402 |
|
5403 @endcode |
|
5404 @see wopendir() |
|
5405 @see wreaddir() |
|
5406 @see wrewinddir() |
|
5407 @see wtelldir() |
|
5408 @see wseekdir() |
|
5409 @see wclosedir() |
|
5410 @see opendir() |
|
5411 @see readdir() |
|
5412 @see rewinddir() |
|
5413 @see telldir() |
|
5414 @see seekdir() |
|
5415 @see closedir() |
|
5416 @see close() |
|
5417 @see lseek() |
|
5418 @see open() |
|
5419 @see read() |
|
5420 |
|
5421 |
|
5422 |
|
5423 |
|
5424 @publishedAll |
|
5425 @released |
|
5426 */ |
|
5427 |
|
5428 |
|
5429 /** @fn wreaddir64(WDIR *wdp) |
|
5430 @param wdp |
|
5431 @return The wreaddir64 function returns a pointer to a wdirent64 structure, |
|
5432 or NULL if an error occurs or end-of-file is reached. |
|
5433 |
|
5434 The wreaddir64() function is a 64-bit version of wreaddir. |
|
5435 |
|
5436 @see wreaddir() |
|
5437 |
|
5438 @publishedAll |
|
5439 @released |
|
5440 */ |
|
5441 |
|
5442 /** @fn wrewinddir(WDIR *wdp) |
|
5443 @param wdp |
|
5444 @return The wrewinddir function returns no value. |
|
5445 |
|
5446 |
|
5447 |
|
5448 The wrewinddir function |
|
5449 function resets the position of the named directory stream pointed by 'dirp' to the beginning of the directory. |
|
5450 |
|
5451 |
|
5452 |
|
5453 Examples: |
|
5454 @code |
|
5455 /* Detailed description: Sample usage of wreaddir call |
|
5456 * Preconditions: Example Directory should be present in current working directory and should contain say 4 files/directories. |
|
5457 */ |
|
5458 #include <dirent.h> |
|
5459 #include <unistd.h> |
|
5460 #include <wchar.h> |
|
5461 int main() |
|
5462 { |
|
5463 WDIR *dirName; |
|
5464 off_t offset; |
|
5465 struct wdirent *Dir; |
|
5466 dirName = wopendir(L"Example"); |
|
5467 if(dirName == NULL ) { |
|
5468 printf("Failed to open directory |
|
5469 "); |
|
5470 return -1; |
|
5471 } |
|
5472 wseekdir(dirName, 3) |
|
5473 if((offset = wtelldir(dirName))!= 3) { |
|
5474 printf("failed |
|
5475 "); |
|
5476 return -1; |
|
5477 } |
|
5478 wrewindir(dirName); |
|
5479 if((offset = wtelldir(dirName))!= 0) { |
|
5480 printf("failed |
|
5481 "); |
|
5482 return -1; |
|
5483 } |
|
5484 printf("Successful |
|
5485 "); |
|
5486 wclosedir(dirName); |
|
5487 return 0; |
|
5488 } |
|
5489 |
|
5490 @endcode |
|
5491 Output |
|
5492 @code |
|
5493 Successful |
|
5494 |
|
5495 @endcode |
|
5496 @see wreaddir() |
|
5497 @see wtelldir() |
|
5498 @see wseekdir() |
|
5499 @see readdir() |
|
5500 @see rewinddir() |
|
5501 @see telldir() |
|
5502 @see seekdir() |
|
5503 |
|
5504 |
|
5505 |
|
5506 |
|
5507 @publishedAll |
|
5508 @released |
|
5509 */ |
|
5510 |
|
5511 |
|
5512 |
|
5513 /** @fn waccess(const wchar_t *fn, int flags) |
|
5514 @param fn |
|
5515 @param flags |
|
5516 @return Upon successful completion, the value 0 is returned; otherwise the |
|
5517 value -1 is returned and the global variable errno is set to indicate the |
|
5518 error. |
|
5519 |
|
5520 The waccess system call checks the accessibility of the |
|
5521 file named by the fn argument for the access permissions indicated by the flags argument. |
|
5522 The value of flags is either the bitwise-inclusive OR of the access permissions to be |
|
5523 checked (R_OK for read permission, W_OK for write permission, and X_OK for execute/search permission), |
|
5524 or the existence test ( F_OK. ) |
|
5525 |
|
5526 For additional information, see the File access Permission |
|
5527 section of intro . X_OK, the file may not actually have execute permission bits set. |
|
5528 Likewise for R_OK and W_OK. |
|
5529 |
|
5530 Note that as execute-bit for files is not supported waccess system call for X_OK is undefined. |
|
5531 |
|
5532 Examples: |
|
5533 @code |
|
5534 /* Detailed description: This sample code checks read-ok accessibility of file Example.c |
|
5535 * Precondtions: Example.txt file should be present in working directory. |
|
5536 */ |
|
5537 #include <unistd.h> |
|
5538 #include <wchar.h> |
|
5539 int main() |
|
5540 { |
|
5541 if(waccess("Example.c" ,R_OK) < 0) |
|
5542 { |
|
5543 printf("Read operation on the file is not permitted |
|
5544 ") ; |
|
5545 return -1 ; |
|
5546 } |
|
5547 printf("Read operation permitted on Example.c file |
|
5548 ") ; |
|
5549 return 0 ; |
|
5550 } |
|
5551 |
|
5552 @endcode |
|
5553 Output |
|
5554 @code |
|
5555 Read operation permitted on Example.c file |
|
5556 |
|
5557 @endcode |
|
5558 @see wchmod() |
|
5559 @see wstat() |
|
5560 |
|
5561 |
|
5562 |
|
5563 @capability Deferred @ref RFs::Entry(const TDesC16&, TEntry&) |
|
5564 |
|
5565 @publishedAll |
|
5566 @released |
|
5567 */ |
|
5568 |
|
5569 |
|
5570 |
|
5571 /** @fn wcreat(const wchar_t *file, mode_t mode) |
|
5572 @param file |
|
5573 @param mode |
|
5574 @return wopen and wcreat return the new file descriptor, or -1 if an error occurred |
|
5575 (in which case errno is set appropriately). |
|
5576 |
|
5577 This interface is made obsolete by: wopen |
|
5578 |
|
5579 The wcreat function |
|
5580 is the same as: wopen(path, O_CREAT | O_TRUNC | O_WRONLY, mode); |
|
5581 |
|
5582 Notes: |
|
5583 |
|
5584 Creating a new file doesn't alter the time stamp of the parent directory. |
|
5585 |
|
5586 The newly created entry has two time stamps: access and modification. Both |
|
5587 are initially the same. |
|
5588 |
|
5589 Symbian OS does not support a creation time stamp. |
|
5590 |
|
5591 |
|
5592 |
|
5593 Examples: |
|
5594 @code |
|
5595 /* |
|
5596 * Detailed description : This test code demonstrates wcreat api usage, it creates a |
|
5597 * in current working directory(if file exists then it is truncated. |
|
5598 *Preconditions : None |
|
5599 */ |
|
5600 #include <sys/types.h> |
|
5601 #include <sys/stat.h> |
|
5602 #include <fcntl.h> |
|
5603 #include <wchar.h> |
|
5604 int main() |
|
5605 { |
|
5606 int fd = 0; |
|
5607 fd = wcreat(L"Example.txt" , 0666); |
|
5608 if(fd < 0 ) |
|
5609 { |
|
5610 printf("File creation failed |
|
5611 "); |
|
5612 return -1; |
|
5613 } |
|
5614 printf("Example.txt file created |
|
5615 "); |
|
5616 return 0; |
|
5617 } |
|
5618 |
|
5619 @endcode |
|
5620 Output |
|
5621 @code |
|
5622 Example.txt file created |
|
5623 |
|
5624 @endcode |
|
5625 @see wopen() |
|
5626 |
|
5627 |
|
5628 |
|
5629 |
|
5630 @publishedAll |
|
5631 @released |
|
5632 */ |
|
5633 |
|
5634 /** @fn wcreat64(const wchar_t *file, mode_t mode) |
|
5635 @param file |
|
5636 @param mode |
|
5637 @return wcreat64() return the new file descriptor, or -1 if an error occurred |
|
5638 (in which case errno is set appropriately). |
|
5639 |
|
5640 The wcreat64() function is a 64-bit version of wcreat. |
|
5641 |
|
5642 @see wcreat() |
|
5643 |
|
5644 @publishedAll |
|
5645 @released |
|
5646 */ |
|
5647 |
|
5648 /** @fn wseekdir(WDIR *wdp, off_t index) |
|
5649 @param wdp |
|
5650 @param index |
|
5651 |
|
5652 Refer to wtelldir() for the documentation |
|
5653 |
|
5654 @see wclosedir() |
|
5655 @see wopendir() |
|
5656 @see wreaddir() |
|
5657 |
|
5658 |
|
5659 |
|
5660 |
|
5661 @publishedAll |
|
5662 @released |
|
5663 */ |
|
5664 |
|
5665 |
|
5666 /** @fn wcsupr(wchar_t *wcs) |
|
5667 @param wcs |
|
5668 |
|
5669 The wcsupr() function |
|
5670 converts each letter from the wide-character string wcs to upper-case. |
|
5671 The conversion is determined by the LC_CTYPE category setting of the locale. |
|
5672 Other characters are not affected. It returns a pointer to the altered string. |
|
5673 Because the modification is done in place, the pointer returned is the same as |
|
5674 the pointer passed as the input argument. |
|
5675 |
|
5676 @return The wcsupr() returns a pointer to the altered string, on successful conversion of wcs, else it returns NULL pointer. |
|
5677 |
|
5678 Examples: |
|
5679 @code |
|
5680 #include <wchar.h> |
|
5681 /* Illustrates how to use wcsupr API */ |
|
5682 int example_wcsupr(void) |
|
5683 { |
|
5684 /* input string which needs to be converted to upper-case */ |
|
5685 wchar_t src[9]=L"testcase"; |
|
5686 |
|
5687 /* expected result string */ |
|
5688 wchar_t *exp=L"TESTCASE"; |
|
5689 |
|
5690 wchar_t *res = NULL; |
|
5691 |
|
5692 /* function call to convert the src to upper-case */ |
|
5693 res = wcsupr(src); |
|
5694 /* compare res string with exp string, if they are equal then return 0, else return -1 */ |
|
5695 if( res != NULL && !wcscmp(res,exp)) |
|
5696 return 0; |
|
5697 else |
|
5698 return -1; |
|
5699 } |
|
5700 |
|
5701 @endcode |
|
5702 @see strupr() |
|
5703 @see towupper() |
|
5704 @see towlower() |
|
5705 @see wcslwr() |
|
5706 |
|
5707 |
|
5708 |
|
5709 |
|
5710 @publishedAll |
|
5711 @released |
|
5712 */ |
|
5713 |
|
5714 /** @fn wcslwr(wchar_t *wcs) |
|
5715 @param wcs |
|
5716 |
|
5717 The wcslwr() function |
|
5718 converts each letter from the wide-character string wcs to lower-case. |
|
5719 The conversion is determined by the LC_CTYPE category setting of the locale. |
|
5720 Other characters are not affected. It returns a pointer to the altered string. |
|
5721 Because the modification is done in place, the pointer returned is the same as |
|
5722 the pointer passed as the input argument. |
|
5723 |
|
5724 @return The wcslwr() returns a pointer to the altered string, on successful conversion of wcs, else it returns NULL pointer. |
|
5725 |
|
5726 Examples: |
|
5727 @code |
|
5728 #include <wchar.h> |
|
5729 /* Illustrates how to use wcslwr API */ |
|
5730 int example_wcslwr(void) |
|
5731 { |
|
5732 /* input string which needs to be converted to lower-case */ |
|
5733 wchar_t src[9]=L"TESTCASE"; |
|
5734 |
|
5735 /* expected result string */ |
|
5736 wchar_t *exp=L"testcase"; |
|
5737 |
|
5738 wchar_t *res = NULL; |
|
5739 |
|
5740 /* function call to convert the src to lower-case */ |
|
5741 res = wcslwr(src); |
|
5742 /* compare res string with exp string, if they are equal then return 0, else return -1 */ |
|
5743 if( res != NULL && !wcscmp(res,exp)) |
|
5744 return 0; |
|
5745 else |
|
5746 return -1; |
|
5747 } |
|
5748 |
|
5749 @endcode |
|
5750 @see strupr() |
|
5751 @see strlwr() |
|
5752 @see towupper() |
|
5753 @see towlower() |
|
5754 @see wcsupr() |
|
5755 |
|
5756 |
|
5757 |
|
5758 |
|
5759 @publishedAll |
|
5760 @released |
|
5761 */ |
|
5762 |
|
5763 /** @fn wcsset(wchar_t *wcs, wchar_t wc) |
|
5764 @param wcs |
|
5765 @param wc |
|
5766 |
|
5767 The wcsset() function sets all the characters of the wide-character string wcs to the wide-character specified by wc, except the terminating null character. It returns a pointer to the altered string, which is same |
|
5768 as the source string passed to wcsset as it is modified in place. |
|
5769 |
|
5770 @return The wcsset() returns a pointer to the altered string, on success, else it returns NULL pointer. |
|
5771 |
|
5772 Examples: |
|
5773 @code |
|
5774 #include <wchar.h> |
|
5775 /* Illustrates how to use wcsset API */ |
|
5776 int example_wcsset(void) |
|
5777 { |
|
5778 /* input string which needs to be set to the character specified by wc. */ |
|
5779 wchar_t wcs[9]=L"kohinoor"; |
|
5780 wcgar_t wc = L'K'; |
|
5781 |
|
5782 /* expected result string */ |
|
5783 wchar_t *exp=L"KKKKKKKK"; |
|
5784 |
|
5785 wchar_t *res = NULL; |
|
5786 |
|
5787 /* function call to set all the chars in wcs to wc*/ |
|
5788 res = wcsset(wcs, wc); |
|
5789 /* compare res string with exp string, if they are equal then return 0, else return -1 */ |
|
5790 if( res != NULL && !wcscmp(res,exp)) |
|
5791 return 0; |
|
5792 else |
|
5793 return -1; |
|
5794 } |
|
5795 |
|
5796 @endcode |
|
5797 @see strset() |
|
5798 @see wcsnset() |
|
5799 |
|
5800 |
|
5801 |
|
5802 |
|
5803 @publishedAll |
|
5804 @released |
|
5805 */ |
|
5806 |
|
5807 /** @fn wcsnset(wchar_t *wcs, wchar_t wc, size_t maxSize) |
|
5808 @param wcs |
|
5809 @param wc |
|
5810 @param maxSize |
|
5811 |
|
5812 The wcsnset() function sets first maxSize characters of the wide-character string wcs to the wide-character specified by wc. If maxSize is greater than the length of wcs, then length of wcs is used instead of maxSize. |
|
5813 It returns a pointer to the altered string, which is same |
|
5814 as the source string passed to wcsnset as it is modified in place. |
|
5815 |
|
5816 @return The wcsnset() returns a pointer to the altered string, on success, else it returns NULL pointer. |
|
5817 |
|
5818 Examples: |
|
5819 @code |
|
5820 #include <wchar.h> |
|
5821 /* Illustrates how to use wcsnset API */ |
|
5822 int example_wcsnset(void) |
|
5823 { |
|
5824 /* input string which needs to be set to the character specified by wc. */ |
|
5825 wchar_t wcs[9]=L"kohinoor"; |
|
5826 wcgar_t wc = L'K'; |
|
5827 int n = 3; |
|
5828 |
|
5829 /* expected result string */ |
|
5830 wchar_t *exp=L"KKKinoor"; |
|
5831 |
|
5832 wchar_t *res = NULL; |
|
5833 |
|
5834 /* function call to set first n chars in wcs to wc*/ |
|
5835 res = wcsnset(wcs, wc, n); |
|
5836 /* compare res string with exp string, if they are equal then return 0, else return -1 */ |
|
5837 if( res != NULL && !wcscmp(res,exp)) |
|
5838 return 0; |
|
5839 else |
|
5840 return -1; |
|
5841 } |
|
5842 |
|
5843 @endcode |
|
5844 @see strset() |
|
5845 @see wcsset() |
|
5846 |
|
5847 |
|
5848 |
|
5849 |
|
5850 @publishedAll |
|
5851 @released |
|
5852 */ |
|
5853 |
|
5854 /** @fn wcsrev(wchar_t *wcs) |
|
5855 @param wcs |
|
5856 |
|
5857 The wcsrev() function reverses the order of the characters in the wide-character string wcs. The terminating null character remains in place.The arguments and return value of wcsrev are wide-character strings; It returns a pointer to the altered string. |
|
5858 the pointer returned is the same as the pointer passed as the input argument. |
|
5859 |
|
5860 @return The wcsrev() returns a pointer to the reverted string, on success, else it returns NULL pointer. |
|
5861 |
|
5862 Examples: |
|
5863 @code |
|
5864 #include <wchar.h> |
|
5865 /* Illustrates how to use wcsrev API */ |
|
5866 int example_wcsrev(void) |
|
5867 { |
|
5868 /* input string which needs to be reverted. */ |
|
5869 wchar_t src[9]=L"kohinoor"; |
|
5870 |
|
5871 /* expected result string */ |
|
5872 wchar_t *exp=L"roonihok"; |
|
5873 |
|
5874 wchar_t *res = NULL; |
|
5875 |
|
5876 /* function call to revert the src */ |
|
5877 res = wcsrev(src); |
|
5878 /* compare res string with exp string, if they are equal then return 0, else return -1 */ |
|
5879 if( res != NULL && !wcscmp(res,exp)) |
|
5880 return 0; |
|
5881 else |
|
5882 return -1; |
|
5883 } |
|
5884 |
|
5885 @endcode |
|
5886 @see strrev() |
|
5887 |
|
5888 |
|
5889 |
|
5890 |
|
5891 @publishedAll |
|
5892 @released |
|
5893 */ |
|
5894 |
|
5895 /** @fn wcsicmp(const wchar_t *wcs1, const wchar_t *wcs2) |
|
5896 @param wcs1 |
|
5897 @param wcs2 |
|
5898 |
|
5899 The wcsicmp() function |
|
5900 compares the two null-terminated wide-character strings wcs1 and wcs2, by converting them into lower-case. |
|
5901 It returns an integer value indicating the status of |
|
5902 the comparision. |
|
5903 |
|
5904 @return The wcsicmp() returns an integer greater than, equal to, or less than 0, |
|
5905 according as wcs1 is lexicographically greater than, equal to, or less than wcs2 after translation of each corresponding character to lower-case. |
|
5906 The strings themselves are not modified. |
|
5907 |
|
5908 Examples: |
|
5909 @code |
|
5910 #include <wchar.h> |
|
5911 /* Illustrates how to use wcsicmp API */ |
|
5912 int example_wcsicmp(void) |
|
5913 { |
|
5914 /* input strings which needs to be compared */ |
|
5915 wchar_t *ws1=L"testcasecmp"; |
|
5916 wchar_t *ws2=L"TESTCASECMP"; |
|
5917 |
|
5918 /* function call to compare the two strings which */ |
|
5919 /* differ in case */ |
|
5920 int retval = wcsicmp(ws1,ws2); |
|
5921 /* returns 0 if they are equal or > 1 */ |
|
5922 /* if first string is greater than second string else -1 */ |
|
5923 return retval; |
|
5924 } |
|
5925 |
|
5926 @endcode |
|
5927 @see strcasecmp() |
|
5928 @see wcscasecmp() |
|
5929 |
|
5930 |
|
5931 |
|
5932 |
|
5933 @publishedAll |
|
5934 @released |
|
5935 */ |
|
5936 |
|
5937 /** @fn wstrdate(const wchar_t *datestr) |
|
5938 @param datestr |
|
5939 |
|
5940 The wstrdate() function gets the system date and converts it into wide-character |
|
5941 string. This copies the current system date into the string pointed by datestr in the format dd/mm/yyyy, the datestr buffer must be atleast 11 bytes long. It returns a pointer to |
|
5942 the datestr string. Because the modification is done in place, the pointer returned |
|
5943 is the same as the pointer passed as the input argument. |
|
5944 |
|
5945 @return The wstrdate() returns a pointer to the date string on succes, otherwise |
|
5946 it returns a NULL pointer and sets the errno accordingly. |
|
5947 |
|
5948 |
|
5949 Examples: |
|
5950 @code |
|
5951 #include <wchar.h> |
|
5952 /* Illustrates how to use wstrdate API */ |
|
5953 int example_wstrdate(void) |
|
5954 { |
|
5955 /* input string which is updated with the system date. */ |
|
5956 wchar_t datestr[20]; |
|
5957 |
|
5958 wchar_t *res = NULL; |
|
5959 |
|
5960 /* function call to get the system date in wide-char format */ |
|
5961 res = wstrdate(datestr); |
|
5962 if( !res && !datestr) |
|
5963 { |
|
5964 printf(" res - %s and datestr - %s",res, datestr); |
|
5965 return 0; |
|
5966 } |
|
5967 else |
|
5968 return -1; |
|
5969 } |
|
5970 |
|
5971 @endcode |
|
5972 |
|
5973 Output |
|
5974 |
|
5975 @code |
|
5976 |
|
5977 res - 21/11/2006 and datestr - 21/11/2006 |
|
5978 |
|
5979 @endcode |
|
5980 |
|
5981 Errors: |
|
5982 |
|
5983 The wstrdate function will fail if: |
|
5984 [EFAULT] The supplied argument datestr is invalid. |
|
5985 |
|
5986 @see strdate() |
|
5987 @see strftime() |
|
5988 @see strptime() |
|
5989 @see wstrtime() |
|
5990 |
|
5991 |
|
5992 |
|
5993 |
|
5994 @publishedAll |
|
5995 @released |
|
5996 */ |
|
5997 |
|
5998 /** @fn wstrtime(const wchar_t *timestr) |
|
5999 @param timestr |
|
6000 |
|
6001 The wstrtime() function gets the system time and converts it into wide-character |
|
6002 string. This copies the current system time into the string pointed by timestr in the format hh:mm:ss. The timestr buffer must be at least 9 bytes long. The function returns a pointer |
|
6003 to the timestr string. Because the modification is done in place, the pointer |
|
6004 returned is the same as the pointer passed as the input argument. |
|
6005 |
|
6006 @return The wstrtime() returns a pointer to the time string on success, otherwise |
|
6007 it returns a NULL pointer and sets the errno accordingly. |
|
6008 |
|
6009 Examples: |
|
6010 @code |
|
6011 #include <wchar.h> |
|
6012 /* Illustrates how to use wstrtime API */ |
|
6013 int example_wstrtime(void) |
|
6014 { |
|
6015 /* input string which is updated with the system time. */ |
|
6016 wchar_t timestr[20]; |
|
6017 |
|
6018 wchar_t *res = NULL; |
|
6019 |
|
6020 /* function call to get the system time in wide-char format */ |
|
6021 res = wstrtime(timestr); |
|
6022 if( !res && !timestr) |
|
6023 { |
|
6024 printf(" res - %s and timestr - %s",res, timestr); |
|
6025 return 0; |
|
6026 } |
|
6027 else |
|
6028 return -1; |
|
6029 } |
|
6030 |
|
6031 @endcode |
|
6032 |
|
6033 Output |
|
6034 |
|
6035 @code |
|
6036 |
|
6037 res - 15:46:36 and timestr - 15:46:36 |
|
6038 |
|
6039 @endcode |
|
6040 |
|
6041 |
|
6042 @see strtime() |
|
6043 @see strftime() |
|
6044 @see strptime() |
|
6045 |
|
6046 |
|
6047 |
|
6048 |
|
6049 @publishedAll |
|
6050 @released |
|
6051 */ |
|
6052 |
|
6053 /** @fn wfdopen(int fd ,const wchar_t * mode) |
|
6054 @param fd |
|
6055 @param mode |
|
6056 @return Upon successful completion wfdopen returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error. |
|
6057 |
|
6058 The wfdopen function |
|
6059 associates a stream with the existing file descriptor, fd. The mode argument is used just as in the function wfopen . |
|
6060 |
|
6061 The mode of the stream must be compatible with the mode of the file descriptor. |
|
6062 In other words the type specified by the stream must be allowed by the file access mode of the open file. |
|
6063 When the stream is closed via fclose, fd is also closed. |
|
6064 |
|
6065 |
|
6066 Errors: |
|
6067 |
|
6068 [EINVAL] The mode argument to wfdopen, was invalid. |
|
6069 The function wfdopen may also fail and set errno for any of the errors specified for the routine wopen. |
|
6070 |
|
6071 |
|
6072 |
|
6073 |
|
6074 Limitations: |
|
6075 |
|
6076 All the limitations that apply to wfopen apply to wfdopen also. |
|
6077 |
|
6078 @see wopen() |
|
6079 @see wfclose() |
|
6080 @see wfopen() |
|
6081 |
|
6082 |
|
6083 |
|
6084 |
|
6085 @publishedAll |
|
6086 @released |
|
6087 */ |
|
6088 |
|
6089 /** @fn wfreopen(const wchar_t * file, const wchar_t * mode,FILE *fp) |
|
6090 @param file |
|
6091 @param mode |
|
6092 @param fp |
|
6093 @return Upon successful completion wfreopen returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error. |
|
6094 |
|
6095 The wfreopen function |
|
6096 opens the file whose name is the string pointed to by file and associates the stream pointed to by fp with it. |
|
6097 The original stream (if it exists) is closed. |
|
6098 The mode argument is used just as in the wfopen function. |
|
6099 |
|
6100 If the file argument is NULL, wfreopen attempts to re-open the file associated with fp with a new mode. |
|
6101 The new mode must be compatible with the mode that the stream was originally |
|
6102 opened with: Streams originally opened with mode "r" |
|
6103 can only be reopened with that same mode. Streams originally opened with mode "a" |
|
6104 can be reopened with the same mode, or mode "w." Streams originally opened with mode "w" |
|
6105 can be reopened with the same mode, or mode "a." Streams originally opened with mode "r+," "w+," |
|
6106 or "a+" |
|
6107 can be reopened with any mode. |
|
6108 |
|
6109 The primary use of the wfreopen function |
|
6110 is to change the file associated with a |
|
6111 standard text stream (stderr, stdin, or stdout). |
|
6112 |
|
6113 |
|
6114 |
|
6115 |
|
6116 |
|
6117 Examples: |
|
6118 @code |
|
6119 /* wfreopen example: redirecting stdout */ |
|
6120 #include <stdio.h> |
|
6121 #include <wchar.h> |
|
6122 int main () |
|
6123 { |
|
6124 wfreopen (L"c:\myfile.txt",L"w",stdout); |
|
6125 printf ("This sentence is redirected to a file."); |
|
6126 fclose (stdout); |
|
6127 return 0; |
|
6128 } |
|
6129 |
|
6130 @endcode |
|
6131 Output: |
|
6132 @code |
|
6133 Contents of myfile.txt:This sentence is redirected to a file. |
|
6134 The output here is redirected from stdout to file myfile.txt |
|
6135 |
|
6136 @endcode |
|
6137 |
|
6138 Limitations: |
|
6139 |
|
6140 All the limitations that apply to wfopen apply to wfreopen also. |
|
6141 |
|
6142 @see wopen() |
|
6143 @see wfclose() |
|
6144 @see wfopen() |
|
6145 |
|
6146 |
|
6147 |
|
6148 |
|
6149 @publishedAll |
|
6150 @released |
|
6151 */ |
|
6152 |
|
6153 /** @fn wfreopen64(const wchar_t * file, const wchar_t * mode,FILE *fp) |
|
6154 @param file |
|
6155 @param mode |
|
6156 @param fp |
|
6157 @return Upon successful completion wfreopen64 returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error. |
|
6158 |
|
6159 The wfreopen64() function is a 64-bit version of wfreopen64. |
|
6160 |
|
6161 @publishedAll |
|
6162 @released |
|
6163 */ |
|
6164 |
|
6165 |
|
6166 /** @fn getws(wchar_t * str) |
|
6167 @param str |
|
6168 @return Upon successful completion, getws returns str. The getws function does not distinguish between end-of-file and error: Callers |
|
6169 must use feof and ferror to determine which occurred. |
|
6170 |
|
6171 |
|
6172 |
|
6173 The getws function |
|
6174 is equivalent to fgetws with an infinite size and a stream of stdin, except that the wide character newline(if any) is not stored in the string. |
|
6175 It is the caller's responsibility to ensure that the input line, |
|
6176 if any, is sufficiently short to fit in the string. |
|
6177 |
|
6178 |
|
6179 |
|
6180 Examples: |
|
6181 @code |
|
6182 #include <stdio.h> |
|
6183 #include <wchar.h> |
|
6184 /* Illustrates how to use getws API */ |
|
6185 int example_getws() |
|
6186 { |
|
6187 FILE* stdop = freopen("c:\stdop","w+",stdout); |
|
6188 FILE* stdip = freopen("c:\stdip","w+",stdin); |
|
6189 FILE* stder = freopen("c:\stder","w+",stderr); |
|
6190 wchar_t* buf = (wchar_t*)malloc(sizeof(wchar_t)*50); |
|
6191 wchar_t s[100]; |
|
6192 int ret = 0; |
|
6193 size_t size = fwrite("abdcef |
|
6194 ", 1, 6, stdip); //write to stdin |
|
6195 fclose(stdip); |
|
6196 stdip = freopen("c:\stdip","r", stdin); |
|
6197 getws(s); // read a line (from stdin) |
|
6198 putws(s); //write to stdout |
|
6199 fclose(stdop); |
|
6200 stdop = freopen("c:\stdop","r", stdout); |
|
6201 fgetws(buf,7,stdop); //read from stdout |
|
6202 if(wcsncmp(s, buf,6)) |
|
6203 { |
|
6204 ret = -1; |
|
6205 } |
|
6206 fclose(stdin); |
|
6207 fclose(stder); |
|
6208 fclose(stdop); |
|
6209 remove("c:\stdop"); |
|
6210 remove("c:\stdip"); |
|
6211 remove("c:\stder"); |
|
6212 return ret; |
|
6213 } |
|
6214 |
|
6215 @endcode |
|
6216 Output |
|
6217 @code |
|
6218 abcdef |
|
6219 abcdef |
|
6220 |
|
6221 @endcode |
|
6222 |
|
6223 Security considerations: |
|
6224 |
|
6225 The getws function cannot be used securely. Because of its lack of bounds |
|
6226 checking, and the inability for the calling program to determine reliably the |
|
6227 length of the next incoming line, the use of this function enables malicious users |
|
6228 to arbitrarily change a running program's functionality through a buffer |
|
6229 overflow attack. It is strongly suggested that the fgetws function be used in all cases. |
|
6230 |
|
6231 @see feof() |
|
6232 @see ferror() |
|
6233 @see fgets() |
|
6234 @see fgetws() |
|
6235 @see gets() |
|
6236 |
|
6237 |
|
6238 |
|
6239 |
|
6240 @publishedAll |
|
6241 @released |
|
6242 */ |
|
6243 |
|
6244 /** @fn wremove(const wchar_t *file) |
|
6245 @param file |
|
6246 @return Upon successful completion, wremove returns 0. Otherwise, it returns -1 is and sets the global |
|
6247 variable errno to indicate the error. |
|
6248 |
|
6249 The wremove function removes the file or directory specified by the wide character name referred by file. |
|
6250 |
|
6251 If file specifies a directory, wremove (file); is the equivalent of wrmdir (file); Otherwise, it is the equivalent of wunlink (file); |
|
6252 |
|
6253 Examples: |
|
6254 @code |
|
6255 /* this program shows deleting a file using wremove */ |
|
6256 #include <stdio.h> |
|
6257 int main() |
|
6258 { |
|
6259 wchar_t* name = L"C:\input.txt"; |
|
6260 FILE *fp = wfopen(name, L"w+"); |
|
6261 if (fp == NULL) |
|
6262 { |
|
6263 printf ("fopen failed |
|
6264 "); |
|
6265 return -1; |
|
6266 } |
|
6267 fprintf(fp,"hello world"); |
|
6268 fclose(fp); |
|
6269 |
|
6270 wremove(name); |
|
6271 fp=wfopen(name,L"r"); |
|
6272 if (fp == NULL) |
|
6273 { |
|
6274 printf ("file has been deleted already |
|
6275 "); |
|
6276 } |
|
6277 else |
|
6278 { |
|
6279 printf("wremove failed |
|
6280 "); |
|
6281 return -1; |
|
6282 } |
|
6283 return 0; |
|
6284 } |
|
6285 |
|
6286 @endcode |
|
6287 Output |
|
6288 @code |
|
6289 file has been deleted already |
|
6290 |
|
6291 @endcode |
|
6292 @see wrmdir() |
|
6293 @see wunlink() |
|
6294 |
|
6295 |
|
6296 |
|
6297 |
|
6298 @publishedAll |
|
6299 @released |
|
6300 */ |
|
6301 |
|
6302 /** @fn putws(wchar_t * str) |
|
6303 @param str |
|
6304 @return The putws function |
|
6305 returns 0 on success and -1 on error. |
|
6306 |
|
6307 The putws function writes the wide character string pointed to by str to the stdout stream. |
|
6308 |
|
6309 |
|
6310 |
|
6311 Examples: |
|
6312 @code |
|
6313 #include <stdio.h> |
|
6314 #include <wchar.h> |
|
6315 /* Illustrates how to use putws API */ |
|
6316 int example_putws() |
|
6317 { |
|
6318 wchar_t buf[12]; |
|
6319 FILE* op; |
|
6320 FILE* stdop = freopen("c:\stdop","w+",stdout); |
|
6321 |
|
6322 putws(L"Hello World"); //write to stdout |
|
6323 |
|
6324 fclose(stdop); |
|
6325 |
|
6326 op = freopen("c:\stdop","r",stdout); |
|
6327 |
|
6328 fgetws(buf, 12, op); //read from stdout |
|
6329 |
|
6330 fclose(stdop); |
|
6331 |
|
6332 remove("c:\stdop"); |
|
6333 |
|
6334 if(!(wcsncmp(L"Hello World", buf, 11))) |
|
6335 { |
|
6336 return 0; |
|
6337 } |
|
6338 return -1; |
|
6339 } |
|
6340 } |
|
6341 |
|
6342 @endcode |
|
6343 @see ferror() |
|
6344 @see fputws() |
|
6345 @see fputs() |
|
6346 @see putwc() |
|
6347 |
|
6348 |
|
6349 |
|
6350 |
|
6351 @publishedAll |
|
6352 @released |
|
6353 */ |
|
6354 |
|
6355 /** @fn wtelldir(const WDIR *wdp) |
|
6356 @param wdp |
|
6357 |
|
6358 Note: This description also covers the following functions - |
|
6359 wseekdir() |
|
6360 |
|
6361 @return wtelldir function returns current location associated with the named directory stream on success or -1 on failure. |
|
6362 |
|
6363 The wtelldir function |
|
6364 returns the current location associated with the named directory stream . |
|
6365 Values returned by wtelldir are good only for the lifetime of the DIR pointer, dirp , |
|
6366 from which they are derived. |
|
6367 If the directory is closed and then |
|
6368 reopened, prior values returned by wtelldir will no longer be valid. |
|
6369 |
|
6370 The wseekdir function |
|
6371 sets the position of the next wreaddir operation on the directory stream . |
|
6372 The new position reverts to the one associated with the directory stream when the wtelldir operation was performed. |
|
6373 |
|
6374 |
|
6375 |
|
6376 Examples: |
|
6377 @code |
|
6378 #include <dirent.h> |
|
6379 #include<wchar.h> |
|
6380 #include<stdio.h> |
|
6381 #include<unistd.h> |
|
6382 #include<sys/types.h> |
|
6383 void wTest() |
|
6384 { |
|
6385 //declare the variables for dir pointer and dir position. |
|
6386 wchar_t *dirName =L"c: est_wseekdir"; |
|
6387 off_t dirpos; |
|
6388 // Open the directory |
|
6389 WDIR *dirp = wopendir (dirName); |
|
6390 |
|
6391 if(dirp != NULL) |
|
6392 { |
|
6393 //read the directory. |
|
6394 wreaddir(dirp); |
|
6395 wreaddir(dirp); |
|
6396 //get the dirp pointer position by calling telldir API. |
|
6397 dirpos = wtelldir(dirp); |
|
6398 //print the position of the dirp pointer. |
|
6399 printf("dirp is pointing at position %ld.",dirpos); |
|
6400 |
|
6401 wseekdir(dirp , 0) ; |
|
6402 wreaddir(dirp); |
|
6403 dirpos = wtelldir(dirp); |
|
6404 //print the position of the dirp pointer. |
|
6405 printf("dirp is pointing at position %ld.",dirpos); |
|
6406 } |
|
6407 } |
|
6408 |
|
6409 @endcode |
|
6410 |
|
6411 Output |
|
6412 |
|
6413 @code |
|
6414 Dirp is pointing at position 2. |
|
6415 Dirp is pointing at position 1. |
|
6416 |
|
6417 @endcode |
|
6418 @see wclosedir() |
|
6419 @see wopendir() |
|
6420 @see wreaddir() |
|
6421 |
|
6422 |
|
6423 |
|
6424 |
|
6425 @publishedAll |
|
6426 @released |
|
6427 */ |
|
6428 |
|
6429 |
|
6430 /** @fn wopendir(const wchar_t *_wpath) |
|
6431 @param _wpath |
|
6432 @return The wopendir function returns a pointer to the directory stream or NULL if an error occurred. |
|
6433 |
|
6434 The wopendir function |
|
6435 opens the directory given by the wide-character name _wpath, associates a directory stream with it and positions it at the first entry |
|
6436 and |
|
6437 returns a pointer to be used to identify the directory stream in subsequent operations. |
|
6438 The pointer NULL is returned if _wpath cannot be accessed, or if it cannot malloc enough memory to hold the whole thing. |
|
6439 |
|
6440 |
|
6441 |
|
6442 Examples: |
|
6443 @code |
|
6444 /* Detailed description: This test code demonstrates usage of wopendir system call, open directory wide name "test". |
|
6445 * Preconditions: Expects "test" directory to be present in the current working directory. |
|
6446 */ |
|
6447 #include <wchar.h> |
|
6448 #include <stdio.h> |
|
6449 #include <dirent.h> |
|
6450 int main() |
|
6451 { |
|
6452 WDIR *WDirHandle; |
|
6453 if(!(WDirHandle = wopendir(L"test") ) ) |
|
6454 { |
|
6455 printf("Failed to open directory test |
|
6456 "); |
|
6457 return -1; |
|
6458 } |
|
6459 printf("Directory test opened |
|
6460 "); |
|
6461 wclosedir(WDirHandle); |
|
6462 return 0; |
|
6463 } |
|
6464 |
|
6465 @endcode |
|
6466 Output |
|
6467 @code |
|
6468 Directory test opened |
|
6469 |
|
6470 @endcode |
|
6471 @see opendir() |
|
6472 @see close() |
|
6473 @see lseek() |
|
6474 @see open() |
|
6475 @see read() |
|
6476 |
|
6477 |
|
6478 |
|
6479 |
|
6480 @publishedAll |
|
6481 @externallyDefinedApi |
|
6482 */ |
|
6483 |
|
6484 |
|
6485 /** @fn wcslcat(wchar_t *s1, const wchar_t *s2, size_t n) |
|
6486 @param s1 |
|
6487 @param s2 |
|
6488 @param n |
|
6489 |
|
6490 Refer to wmemchr() for the documentation |
|
6491 |
|
6492 @see memchr() |
|
6493 @see memcmp() |
|
6494 @see memcpy() |
|
6495 @see memmove() |
|
6496 @see memset() |
|
6497 @see strcat() |
|
6498 @see strchr() |
|
6499 @see strcmp() |
|
6500 @see strcpy() |
|
6501 @see strcspn() |
|
6502 @see strlen() |
|
6503 @see strncat() |
|
6504 @see strncmp() |
|
6505 @see strncpy() |
|
6506 @see strpbrk() |
|
6507 @see strrchr() |
|
6508 @see strspn() |
|
6509 @see strstr() |
|
6510 |
|
6511 |
|
6512 |
|
6513 |
|
6514 @publishedAll |
|
6515 @released |
|
6516 */ |
|
6517 |
|
6518 /** @fn wcslcpy(wchar_t *s1, const wchar_t *s2, size_t n) |
|
6519 @param s1 |
|
6520 @param s2 |
|
6521 @param n |
|
6522 |
|
6523 Refer to wmemchr() for the documentation |
|
6524 |
|
6525 @see memchr() |
|
6526 @see memcmp() |
|
6527 @see memcpy() |
|
6528 @see memmove() |
|
6529 @see memset() |
|
6530 @see strcat() |
|
6531 @see strchr() |
|
6532 @see strcmp() |
|
6533 @see strcpy() |
|
6534 @see strcspn() |
|
6535 @see strlen() |
|
6536 @see strncat() |
|
6537 @see strncmp() |
|
6538 @see strncpy() |
|
6539 @see strpbrk() |
|
6540 @see strrchr() |
|
6541 @see strspn() |
|
6542 @see strstr() |
|
6543 |
|
6544 |
|
6545 |
|
6546 |
|
6547 @publishedAll |
|
6548 @released |
|
6549 */ |
|
6550 |
|
6551 /** @fn wasctime(const struct tm *tm) |
|
6552 @param tm |
|
6553 |
|
6554 Refer to wctime() for the documentation |
|
6555 |
|
6556 @see asctime() |
|
6557 @see ctime() |
|
6558 |
|
6559 |
|
6560 |
|
6561 |
|
6562 @publishedAll |
|
6563 @released |
|
6564 */ |
|
6565 |
|
6566 /** @fn wctime(const time_t *clock) |
|
6567 @param clock |
|
6568 |
|
6569 Note: This description also covers the following functions - |
|
6570 wasctime() |
|
6571 |
|
6572 @return The functions wasctime and wctime return a pointer to the resulting wide-character string. |
|
6573 |
|
6574 The function wctime takes a time value representing the time in seconds since the |
|
6575 Epoch (00:00:00 UTC, January 1, 1970) as an argument. See time |
|
6576 |
|
6577 The function wctime adjusts the time value for the current time zone in the same |
|
6578 manner as localtime and returns a pointer to a 26-wide character string of the |
|
6579 form: Thu Nov 24 18:22:48 1986 |
|
6580 \\0 All the fields have constant width. |
|
6581 |
|
6582 The function wasctime converts the broken down time in the structure tm , pointed at by *tm , to the form shown in the example above. |
|
6583 |
|
6584 @code |
|
6585 External declarations as well as the tm structure definition are in the #include <time.h> include file. The tm structure includes |
|
6586 at least the following fields: |
|
6587 |
|
6588 int tm_sec;/* seconds (0 - 60) */ |
|
6589 int tm_min;/* minutes (0 - 59) */ |
|
6590 int tm_hour;/* hours (0 - 23) */ |
|
6591 int tm_mday;/* day of month (1 - 31) */ |
|
6592 int tm_mon;/* month of year (0 - 11) */ |
|
6593 int tm_year;/* year - 1900 */ |
|
6594 int tm_wday;/* day of week (Sunday = 0) */ |
|
6595 int tm_yday;/* day of year (0 - 365) */ |
|
6596 int tm_isdst;/* is summer time in effect? */ |
|
6597 char *tm_zone;/* abbreviation of timezone name */ |
|
6598 long tm_gmtoff;/* offset from UTC in seconds */ |
|
6599 @endcode |
|
6600 |
|
6601 The |
|
6602 field tm_isdst is non-zero if summer time is in effect. |
|
6603 |
|
6604 The field tm_gmtoff is the offset (in seconds) of the time represented from UTC, with positive |
|
6605 values indicating east of the Prime Meridian. |
|
6606 |
|
6607 |
|
6608 |
|
6609 Examples: |
|
6610 @code |
|
6611 //Example usage of wasctime and wctime: |
|
6612 #include <time.h> |
|
6613 #include <stdio.h> |
|
6614 int main(){ |
|
6615 time_t t; |
|
6616 struct tm *timeptr; |
|
6617 wchar_t* wasc_time; |
|
6618 t = time (NULL); //Get current time in seconds from Epoc |
|
6619 //Fill tm struct w.r.t localtime using localtime |
|
6620 timeptr = localtime (&t;); |
|
6621 //Use this to convert it to a string indicating time w.r.t localtime |
|
6622 wasc_time = wasctime (timeptr); |
|
6623 wprintf (L"Time from wasctime w.r.t localtime : %s", wasc_time); |
|
6624 wprintf(L"Time from wctime w.r.t localtime : %s0, wctime(&t;) ); |
|
6625 return 0; |
|
6626 } |
|
6627 |
|
6628 @endcode |
|
6629 Output |
|
6630 @code |
|
6631 Time from wasctime w.r.t localtime : Thu Jun 22 10:42:27 2006 |
|
6632 Time from wctime w.r.t localtime : Thu Jun 22 10:42:27 2006 |
|
6633 |
|
6634 @endcode |
|
6635 @code |
|
6636 |
|
6637 @endcode |
|
6638 @see asctime() |
|
6639 @see ctime() |
|
6640 |
|
6641 |
|
6642 Bugs: |
|
6643 |
|
6644 These functions leave their result in an internal static object and return |
|
6645 a pointer to that object. |
|
6646 Subsequent calls to these |
|
6647 functions will modify the same object. The C Standard provides no mechanism for a program to modify its current local |
|
6648 timezone setting and the POSIX -standard method is not reentrant. (However, thread-safe implementations |
|
6649 are provided in the POSIX threaded environment.) The tm_zone field of a returned tm structure points to a static array of characters which will also be overwritten |
|
6650 by any subsequent calls (as well as by subsequent call to tzset ) |
|
6651 |
|
6652 |
|
6653 |
|
6654 @publishedAll |
|
6655 @released |
|
6656 */ |
|
6657 |
|
6658 /** @fn wsetlocale(int category, const wchar_t *locale) |
|
6659 @param category |
|
6660 @param locale |
|
6661 @return Upon successful completion, wsetlocale returns the wide char string associated with the specified category for the requested locale. The wsetlocale function returns NULL and fails to change the locale |
|
6662 if the given combination of category and locale make no sense. |
|
6663 |
|
6664 |
|
6665 The wsetlocale function sets the C library's notion |
|
6666 of natural language formatting style |
|
6667 for particular sets of routines. |
|
6668 Each such style is called a 'locale' |
|
6669 and is invoked using an appropriate name passed as a wide char string. |
|
6670 |
|
6671 The wsetlocale function can recognise several categories of routines. |
|
6672 The categories and the sets of routines recognised by wsetlocale are listed below: |
|
6673 |
|
6674 @code |
|
6675 LC_ALL Set the entire locale generically. |
|
6676 LC_COLLATE Set a locale for string collation routines. Currently locale setting does not have effect on |
|
6677 this category. |
|
6678 LC_CTYPE This controls recognition of upper and lower case, |
|
6679 alphabetic or non-alphabetic characters, |
|
6680 and so on. Currently locale setting does not have effect on this category. |
|
6681 LC_MESSAGES |
|
6682 Set a locale for message catalogs. Currently this category is not supported. |
|
6683 LC_MONETARY |
|
6684 Set a locale for formatting monetary values; |
|
6685 this affects the localeconv function. |
|
6686 LC_NUMERIC Set a locale for formatting numbers. |
|
6687 This controls the formatting of decimal points |
|
6688 in input and output of floating point numbers |
|
6689 in functions such as printf and scanf, as well as values returned by localeconv. |
|
6690 LC_TIME Set a locale for formatting dates and times using the strftime function. |
|
6691 |
|
6692 @endcode |
|
6693 |
|
6694 Only three locales are defined by default, |
|
6695 the empty string which denotes the native environment, the C |
|
6696 and the POSIX |
|
6697 locales, which denote the C language environment. |
|
6698 A locale argument of NULL causes wsetlocale to return the current locale. |
|
6699 By default, C programs start in the C |
|
6700 locale. |
|
6701 The only functions in the library that set the locale are wsetlocale and setlocale; the locale is never changed as a side effect of some other routine. |
|
6702 |
|
6703 Examples: |
|
6704 @code |
|
6705 #include<stdio.h> |
|
6706 #include<wchar.h> |
|
6707 int main() |
|
6708 { |
|
6709 //Set the locale to UK English |
|
6710 wchar_t* locale = wsetlocale(LC_ALL,L"en_GB.ISO-8859-1"); |
|
6711 //Check whether locale setting is succesful or not |
|
6712 if(NULL != locale) |
|
6713 { |
|
6714 wprintf(L"Locale setting is successful |
|
6715 "); |
|
6716 wprintf(L"Locale is set to %s |
|
6717 ", locale); |
|
6718 } |
|
6719 else |
|
6720 { |
|
6721 wprintf(L"Locale setting failed |
|
6722 "); |
|
6723 } |
|
6724 return 0; |
|
6725 } |
|
6726 |
|
6727 @endcode |
|
6728 Output |
|
6729 @code |
|
6730 Locale setting is successful |
|
6731 Locale is set to en_GB.ISO-8859-1 |
|
6732 |
|
6733 @endcode |
|
6734 @see setlocale() |
|
6735 @see localeconv() |
|
6736 @see nl_langinfo() |
|
6737 |
|
6738 |
|
6739 |
|
6740 |
|
6741 @publishedAll |
|
6742 @released |
|
6743 */ |
|
6744 |
|
6745 /** @fn wperror(const wchar_t *s) |
|
6746 @param s |
|
6747 |
|
6748 Note: This description also covers the following functions - |
|
6749 wcserror() |
|
6750 |
|
6751 @return The function wcserror returns the appropriate error description wide char string, or an unknown error message if the error code is unknown. The value of errno is not changed for a successful call, and is set to a nonzero value upon error. |
|
6752 |
|
6753 The functions wcserror and wperror look up the error message string corresponding to an |
|
6754 error number. |
|
6755 |
|
6756 The function wcserror function accepts an error number argument errnum (error number) and returns a pointer to the corresponding |
|
6757 message string. |
|
6758 |
|
6759 The function wperror finds the error message corresponding to the current |
|
6760 value of the global variable errno and writes it, followed by a newline, to the |
|
6761 standard error file descriptor. |
|
6762 If the argument s is non- NULL and does not point to the null character, |
|
6763 this wide char string is prepended to the message |
|
6764 string and separated from it by |
|
6765 a colon and space (": "); |
|
6766 otherwise, only the error message string is printed. |
|
6767 |
|
6768 If the error number is not recognized, these functions return an error message |
|
6769 string containing "Unknown error: " |
|
6770 followed by the error number in decimal. |
|
6771 The wcserror function returns EINVAL as a warning. |
|
6772 Error numbers recognized by this implementation fall in |
|
6773 the range 0 \<errnum \<sys_nerr . |
|
6774 |
|
6775 If insufficient storage is provided in strerrbuf (as specified in buflen ) |
|
6776 to contain the error string, wcserror returns ERANGE and strerrbuf will contain an error message that has been truncated and NUL terminated to fit the length specified by buflen . |
|
6777 |
|
6778 |
|
6779 |
|
6780 Examples: |
|
6781 @code |
|
6782 #include <string.h> |
|
6783 #include <stdio.h> |
|
6784 #include <errno.h> |
|
6785 #include <wchar.h> |
|
6786 int main() |
|
6787 { |
|
6788 wchar_t *ptr = wcserror(ERANGE); |
|
6789 wprintf(L"wcserror(ERANGE) = %s |
|
6790 ",ptr); |
|
6791 return 0; |
|
6792 } |
|
6793 |
|
6794 @endcode |
|
6795 Output |
|
6796 @code |
|
6797 wcserror(ERANGE) = Numerical result out of range |
|
6798 |
|
6799 @endcode |
|
6800 @see perror() |
|
6801 @see strerror() |
|
6802 |
|
6803 |
|
6804 Bugs: |
|
6805 |
|
6806 For unknown error numbers, the function wcserror will return its result in a static buffer which |
|
6807 may be overwritten by subsequent calls. The return type for wcserror is missing a type-qualifier. The type-qualifier must be const wchar_t * . |
|
6808 |
|
6809 |
|
6810 |
|
6811 @publishedAll |
|
6812 @released |
|
6813 */ |
|
6814 |
|
6815 /** @fn wcserror(int num) |
|
6816 @param num |
|
6817 |
|
6818 Refer to wperror() for the documentation |
|
6819 |
|
6820 @see perror() |
|
6821 @see strerror() |
|
6822 |
|
6823 |
|
6824 |
|
6825 |
|
6826 @publishedAll |
|
6827 @released |
|
6828 */ |
|
6829 |
|
6830 /** @fn wfindnext(intptr_t handle, struct _wfinddata_t * fileinfo) |
|
6831 @param handle |
|
6832 @param fileinfo |
|
6833 |
|
6834 Refer to wfindfirst() for the documentation |
|
6835 |
|
6836 |
|
6837 |
|
6838 |
|
6839 @publishedAll |
|
6840 @released |
|
6841 */ |
|
6842 |
|
6843 /** @fn wfindfirst(const wchar_t* filespec, struct _wfinddata_t* fileinfo) |
|
6844 @param filespec |
|
6845 @param fileinfo |
|
6846 |
|
6847 Note: This description also covers the following functions - |
|
6848 wfindnext() findclose() |
|
6849 |
|
6850 @return If successful, wfindfirst return a unique search handle identifying the file or group |
|
6851 of files matching the filespec specification. The handle can be used in a subsequent |
|
6852 call to wfindnext or to findclose. Otherwise, wfindfirst returns -1 and sets |
|
6853 errno accordingly. If successful, wfindnext returns 0. Otherwise, returns -1 and sets errno to a value indicating the nature of the failure. If successful, findclose returns 0. Otherwise, it returns -1 and sets errno to ENOENT |
|
6854 |
|
6855 Errors: |
|
6856 |
|
6857 [EINVAL] Invalid parameter: filespec or fileinfo was NULL. Or, the operating system returned an unexpected error. |
|
6858 [ENOENT] File specification that could not be matched. |
|
6859 |
|
6860 The wfindfirst function provides information about the first instance of a file name that matches the file specified in the filespec argument. Any wildcard combination supported by the host operating system can be used in filespec. File information is returned in a _wfinddata_t structure, defined in wchar.h. The _wfinddata_t structure includes the following elements. |
|
6861 |
|
6862 @code |
|
6863 unsigned attrib File attribute |
|
6864 @endcode |
|
6865 |
|
6866 time_t time_create Time of file creation (-1L for Symbian OS) |
|
6867 |
|
6868 time_t time_access Time of the last file access (-1L for Symbian OS) |
|
6869 |
|
6870 time_t time_write Time of the last write to file |
|
6871 |
|
6872 size_t size Length of the file in bytes |
|
6873 |
|
6874 wchar_t name[260] Null-terminated name of matched file/directory, without the path |
|
6875 |
|
6876 |
|
6877 |
|
6878 This attribute is returned in the attrib field of the _wfinddata_t structure and can have the following values (defined in wchar.h). |
|
6879 |
|
6880 @code |
|
6881 _A_ARCH Archive. |
|
6882 _A_HIDDEN |
|
6883 Hidden file. |
|
6884 _A_NORMAL |
|
6885 Normal. |
|
6886 _A_RDONLY |
|
6887 Read-only. |
|
6888 _A_SYSTEM |
|
6889 System file. |
|
6890 |
|
6891 @endcode |
|
6892 |
|
6893 The wfindnext finds the next name, if any, that matches the filespec argument in a previous call to wfindfirst and then alters the fileinfo structure contents accordingly. |
|
6894 |
|
6895 The findclose closes the specified search handle and releases the associated resources. |
|
6896 |
|
6897 |
|
6898 |
|
6899 |
|
6900 |
|
6901 Examples: |
|
6902 @code |
|
6903 #include <wchar.h> |
|
6904 int main( void ) |
|
6905 { |
|
6906 struct _wfinddata_t c_file; |
|
6907 intptr_t hFile; |
|
6908 // Find .txt file in current directory |
|
6909 if( (hFile = wfindfirst( L"*.txt", &c;_file )) == -1L ) |
|
6910 printf( "No *.txt files in current directory" ); |
|
6911 else |
|
6912 { |
|
6913 int i = 1; |
|
6914 do { |
|
6915 wprintf( L" File %d = %s ",i,c_file.name); |
|
6916 i++; |
|
6917 } while( wfindnext( hFile, &c;_file ) == 0 ); |
|
6918 findclose( hFile ); |
|
6919 } |
|
6920 return 0 ; |
|
6921 } |
|
6922 |
|
6923 @endcode |
|
6924 Output |
|
6925 @code |
|
6926 File 1 = test1.txt |
|
6927 File 2 = test2.txt |
|
6928 |
|
6929 @endcode |
|
6930 |
|
6931 Bugs: |
|
6932 |
|
6933 Does not support any attribute to find out the sub-directories |
|
6934 (i.e., attribute _A_SUBDIR not supported). |
|
6935 |
|
6936 |
|
6937 @publishedAll |
|
6938 @released |
|
6939 */ |
|
6940 |
|
6941 /** @fn findclose(intptr_t handle) |
|
6942 @param handle |
|
6943 |
|
6944 Refer to wfindfirst() for the documentation |
|
6945 |
|
6946 |
|
6947 |
|
6948 |
|
6949 @publishedAll |
|
6950 @released |
|
6951 */ |
|
6952 |
|
6953 /** @fn wcsnicmp(const wchar_t *wcs1, const wchar_t *wcs2, size_t n) |
|
6954 @param wcs1 |
|
6955 @param wcs2 |
|
6956 @param n |
|
6957 |
|
6958 The wcsnicmp() function |
|
6959 compares the first n characters from two null-terminated wide-character strings wcs1 and wcs2, by converting them into lower-case. |
|
6960 It returns an integer value indicating the status of |
|
6961 the comparision. |
|
6962 |
|
6963 @return The wcsnicmp() returns an integer greater than, equal to, or less than 0, |
|
6964 according as wcs1 is lexicographically greater than, equal to, or less than wcs2 after translation of each corresponding character to lower-case. |
|
6965 The strings themselves are not modified. |
|
6966 |
|
6967 Examples: |
|
6968 @code |
|
6969 #include <wchar.h> |
|
6970 /* Illustrates how to use wcsnicmp API */ |
|
6971 int example_wcsnicmp(void) |
|
6972 { |
|
6973 /* input strings which needs to be compared */ |
|
6974 wchar_t *ws1=L"testcasecmp"; |
|
6975 wchar_t *ws2=L"TESTCASECMP"; |
|
6976 |
|
6977 /* function call to compare the two strings which */ |
|
6978 /* differ in case */ |
|
6979 int retval = wcsnicmp(ws1,ws2,12); |
|
6980 /* returns 0 if they are equal or > 1 */ |
|
6981 /* if first string is greater than second string else -1 */ |
|
6982 return retval; |
|
6983 } |
|
6984 |
|
6985 @endcode |
|
6986 @see strcasecmp() |
|
6987 @see wcscasecmp() |
|
6988 @see wcsncasecmp() |
|
6989 |
|
6990 |
|
6991 |
|
6992 |
|
6993 @publishedAll |
|
6994 @released |
|
6995 */ |
|
6996 |
|
6997 /** @fn wcsicoll(const wchar_t *wcs1, const wchar_t *wcs2) |
|
6998 @param wcs1 |
|
6999 @param wcs2 |
|
7000 @return The wcsicoll function |
|
7001 returns an integer greater than, equal to, or less than 0, |
|
7002 if wcs1 is greater than, equal to, or less than wcs2. No return value is reserved to indicate errors; |
|
7003 callers should set errno to 0 before calling wcsicoll . |
|
7004 If it is non-zero upon return from wcsicoll , |
|
7005 an error has occurred. |
|
7006 |
|
7007 The wcsicoll function compares the null-terminated strings wcs1 and wcs2 according to the current locale collation order, by ignoring the case. |
|
7008 In the "C" |
|
7009 locale, wcsicoll is equivalent to wcsicmp . |
|
7010 |
|
7011 Examples: |
|
7012 @code |
|
7013 #include <wchar.h> |
|
7014 /* Illustrates how to use wcsicoll API */ |
|
7015 int example_wcsicoll (void) |
|
7016 { |
|
7017 /* compares the two strings */ |
|
7018 if( wcsicoll(L"abcdef",L"abcdeg") != L'f'-L'g') |
|
7019 return -1; |
|
7020 return 0; |
|
7021 } |
|
7022 |
|
7023 @endcode |
|
7024 |
|
7025 Limitations: |
|
7026 |
|
7027 The current implementation of wcsicoll is not affected by the LC_CTYPE category of the current locale. It is equivalent to wcsicmp in this implementation. |
|
7028 |
|
7029 @see setlocale() |
|
7030 @see strcoll() |
|
7031 @see wcsicmp() |
|
7032 @see wcsxfrm() |
|
7033 |
|
7034 |
|
7035 Bugs: |
|
7036 |
|
7037 The current implementation of wcsicoll only works in single-byte LC_CTYPE locales, and falls back to using wcsicmp in locales with extended character sets. |
|
7038 |
|
7039 |
|
7040 |
|
7041 @publishedAll |
|
7042 @released |
|
7043 */ |
|
7044 |
|
7045 /** @fn wcsncoll(const wchar_t *wcs1, const wchar_t *wcs2, size_t n) |
|
7046 @param wcs1 |
|
7047 @param wcs2 |
|
7048 @param n |
|
7049 @return The wcsncoll function |
|
7050 returns an integer greater than, equal to, or less than 0, |
|
7051 if wcs1 is greater than, equal to, or less than wcs2 . No return value is reserved to indicate errors; |
|
7052 callers should set errno to 0 before calling wcsncoll . |
|
7053 If it is non-zero upon return from wcsncoll , |
|
7054 an error has occurred. |
|
7055 |
|
7056 The wcsncoll function compares the first n chars from the two null-terminated strings wcs1 and wcs2 according to the current locale collation order. |
|
7057 In the "C" |
|
7058 locale, wcsncoll is equivalent to wcscmp . |
|
7059 |
|
7060 Examples: |
|
7061 @code |
|
7062 #include <wchar.h> |
|
7063 /* Illustrates how to use wcsncoll API */ |
|
7064 int example_wcsncoll (void) |
|
7065 { |
|
7066 /* compares the two strings */ |
|
7067 if( wcsncoll(L"abcdef",L"abcdeg",7) != L'f'-L'g') |
|
7068 return -1; |
|
7069 return 0; |
|
7070 } |
|
7071 |
|
7072 @endcode |
|
7073 |
|
7074 Limitations: |
|
7075 |
|
7076 The current implementation of wcsncoll is not affected by the LC_CTYPE category of the current locale. It is equivalent to wcscoll in this implementation. |
|
7077 |
|
7078 @see setlocale() |
|
7079 @see strcoll() |
|
7080 @see wcscoll() |
|
7081 @see wcsncmp() |
|
7082 @see wcsxfrm() |
|
7083 |
|
7084 |
|
7085 |
|
7086 Bugs: |
|
7087 |
|
7088 The current implementation of wcsncoll only works in single-byte LC_CTYPE locales, and falls back to using wcscoll in locales with extended character sets. |
|
7089 |
|
7090 |
|
7091 |
|
7092 @publishedAll |
|
7093 @released |
|
7094 */ |
|
7095 |
|
7096 |
|
7097 /** @fn wcsnicoll(const wchar_t *wcs1, const wchar_t *wcs2, size_t n) |
|
7098 @param wcs1 |
|
7099 @param wcs2 |
|
7100 @param n |
|
7101 @return The wcsnicoll function |
|
7102 returns an integer greater than, equal to, or less than 0, |
|
7103 if wcs1 is greater than, equal to, or less than wcs2 . No return value is reserved to indicate errors; |
|
7104 callers should set errno to 0 before calling wcsnicoll . |
|
7105 If it is non-zero upon return from wcsnicoll , |
|
7106 an error has occurred. |
|
7107 |
|
7108 The wcsnicoll function compares the null-terminated strings wcs1 and wcs2 according to the current locale collation order. |
|
7109 In the "C" |
|
7110 locale, wcsnicoll is equivalent to wcsncasecmp . |
|
7111 |
|
7112 Examples: |
|
7113 @code |
|
7114 #include <wchar.h> |
|
7115 /* Illustrates how to use wcsnicoll API */ |
|
7116 int example_wcsnicoll (void) |
|
7117 { |
|
7118 /* compares the two strings */ |
|
7119 if( wcsnicoll(L"abcdef",L"abcdeg",7) != L'f'-L'g') |
|
7120 return -1; |
|
7121 return 0; |
|
7122 } |
|
7123 |
|
7124 @endcode |
|
7125 |
|
7126 Limitations: |
|
7127 |
|
7128 The current implementation of wcsnicoll is not affected by the LC_CTYPE category of the current locale. It is equivalent to wcsncasecmp in this implementation. |
|
7129 |
|
7130 @see setlocale() |
|
7131 @see strcoll() |
|
7132 @see wcscmp() |
|
7133 @see wcsxfrm() |
|
7134 @see wcsncasecmp() |
|
7135 |
|
7136 |
|
7137 Bugs: |
|
7138 |
|
7139 The current implementation of wcsnicoll only works in single-byte LC_CTYPE locales, and falls back to using wcsncoll in locales with extended character sets. |
|
7140 |
|
7141 |
|
7142 @publishedAll |
|
7143 @released |
|
7144 */ |
|
7145 |
|
7146 |
|
7147 /** @fn wtmpnam(wchar_t *s) |
|
7148 @param s |
|
7149 @return The wtmpnam function returns a pointer to a file name on success and a NULL pointer on error. |
|
7150 |
|
7151 The wtmpnam function returns a pointer to a file name in the P_tmpdir directory which did not reference an existing file at some |
|
7152 indeterminate point in the past. P_tmpdir is defined in the include file stdio.h . If the argument s is non-NULL, the file name is copied to the buffer it references. Otherwise, the |
|
7153 file name is copied to a static buffer. In either case, wtmpnam returns a pointer to the file name. |
|
7154 |
|
7155 The buffer referenced by s is expected to be at least L_tmpnam bytes in length. L_tmpnam is defined in the include file stdio.h . |
|
7156 |
|
7157 The environment variable TMPDIR (if set), the argument tmpdir (if non-NULL), the directory P_tmpdir , and the directory /tmp are tried in that order as directories in which to store the |
|
7158 temporary file. |
|
7159 |
|
7160 |
|
7161 |
|
7162 Examples: |
|
7163 @code |
|
7164 #include<stdio.h> //wtmpnam |
|
7165 #include<sys/stat.h> //S_IWUSR |
|
7166 #include<errno.h> //errno |
|
7167 |
|
7168 int main() |
|
7169 { |
|
7170 //create a directory c:\system emp |
|
7171 wmkdir(L"c:\system\temp", S_IWUSR); |
|
7172 |
|
7173 wchar_t wbuf[L_tmpnam]; |
|
7174 wchar_t rbuf[10]; |
|
7175 |
|
7176 //call wtmpnam() to create a file |
|
7177 wchar_t *rval = wtmpnam(wbuf); |
|
7178 |
|
7179 errno = 0; |
|
7180 //open the file with the name returned by wtmpnam() |
|
7181 FILE *fp = wfopen(buf, L"w"); |
|
7182 |
|
7183 if (fp == NULL) |
|
7184 { |
|
7185 printf("fopen of file returned by wtmpnam() failed - errno %d ", errno); |
|
7186 return -1; |
|
7187 } |
|
7188 |
|
7189 if(fp) |
|
7190 { |
|
7191 fwprintf(fp, L"%ls", L"check"); |
|
7192 fclose(fp); |
|
7193 } |
|
7194 |
|
7195 fp = wfopen(buf, L"r"); |
|
7196 |
|
7197 if(fp) |
|
7198 { |
|
7199 fwscanf(fp, L"%ls", rbuf); |
|
7200 fclose(fp); |
|
7201 } |
|
7202 |
|
7203 printf("read from file: %ls |
|
7204 ", rbuf); |
|
7205 printf("argument buf: %ls |
|
7206 ", buf); |
|
7207 printf("return value: %ls |
|
7208 ", rval); |
|
7209 |
|
7210 return 0; |
|
7211 } |
|
7212 |
|
7213 @endcode |
|
7214 Output |
|
7215 @code |
|
7216 read from file: check |
|
7217 argument buf: /System/temp/tmp.0.U9UPTx |
|
7218 return value: /System/temp/tmp.0.U9UPTx |
|
7219 |
|
7220 @endcode |
|
7221 @see mktemp() |
|
7222 @see tmpnam() |
|
7223 |
|
7224 |
|
7225 |
|
7226 |
|
7227 @publishedAll |
|
7228 @released |
|
7229 */ |
|
7230 |
|
7231 |
|
7232 |
|
7233 /** @typedef typedef __mbstate_t mbstate_t |
|
7234 |
|
7235 An object type other than an array type that can hold the conversion state information necessary to convert between sequences of (possibly multibyte) characters and wide-characters. |
|
7236 If a codeset is being used such that an mbstate_t needs to preserve more than 2 levels of reserved state, the results are unspecified. |
|
7237 |
|
7238 @publishedAll |
|
7239 @externallyDefinedApi |
|
7240 */ |
|
7241 |
|
7242 |
|
7243 /** @typedef typedef __wint_t wint_t |
|
7244 |
|
7245 An integral type capable of storing any valid value of wchar_t, or WEOF. |
|
7246 |
|
7247 @publishedAll |
|
7248 @externallyDefinedApi |
|
7249 */ |
|
7250 |
|
7251 |
|
7252 /** @def WCHAR_MIN |
|
7253 |
|
7254 The minimum value representable by an object of type wchar_t. |
|
7255 |
|
7256 @publishedAll |
|
7257 @externallyDefinedApi |
|
7258 */ |
|
7259 |
|
7260 /** @def WCHAR_MAX |
|
7261 |
|
7262 The maximum value representable by an object of type wchar_t. |
|
7263 |
|
7264 @publishedAll |
|
7265 @externallyDefinedApi |
|
7266 */ |
|
7267 |
|
7268 /** @def WEOF |
|
7269 |
|
7270 Constant expression of type wint_t that is returned by several WP functions to indicate end-of-file. |
|
7271 |
|
7272 @publishedAll |
|
7273 @externallyDefinedApi |
|
7274 */ |
|
7275 |
|
7276 /** @fn wpopen3 (const wchar_t* file, const wchar_t* cmd, wchar_t** env, int fids[3]) |
|
7277 @param file |
|
7278 @param cmd |
|
7279 @param env |
|
7280 @param fids |
|
7281 |
|
7282 Note:wpopen3 is a wide-character version of popen3() |
|
7283 |
|
7284 @return Upon successful completion, it returns pid of the child. |
|
7285 |
|
7286 Examples: |
|
7287 |
|
7288 @code |
|
7289 |
|
7290 /* Illustrates how to use wpopen3 API */ |
|
7291 #include <wchar.h> |
|
7292 int main() |
|
7293 { |
|
7294 int fds[3]; |
|
7295 int childid= wpopen3( NULL,NULL, NULL, fds); |
|
7296 if (childid == -1 && errno == ENOENT) |
|
7297 { |
|
7298 printf("wpopen success"); |
|
7299 return 0; |
|
7300 } |
|
7301 return -1; |
|
7302 } |
|
7303 @endcode |
|
7304 @code |
|
7305 Output: |
|
7306 wpopen success |
|
7307 @endcode |
|
7308 |
|
7309 @publishedAll |
|
7310 @released |
|
7311 */ |