Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ustdio.h

Go to the documentation of this file.
00001 /*
00002 ******************************************************************************
00003 *
00004 *   Copyright (C) 1998-2001, International Business Machines
00005 *   Corporation and others.  All Rights Reserved.
00006 *
00007 ******************************************************************************
00008 *
00009 * File ustdio.h
00010 *
00011 * Modification History:
00012 *
00013 *   Date        Name        Description
00014 *   10/16/98    stephen     Creation.
00015 *   11/06/98    stephen     Modified per code review.
00016 *   03/12/99    stephen     Modified for new C API.
00017 *   07/19/99    stephen     Minor doc update.
00018 *   02/01/01    george      Added sprintf & sscanf with all of its variants
00019 ******************************************************************************
00020 */
00021 
00022 #ifndef USTDIO_H
00023 #define USTDIO_H
00024 
00025 #include <stdio.h>
00026 #include <stdarg.h>
00027 
00028 #include "unicode/utypes.h"
00029 #include "unicode/ucnv.h"
00030 #include "unicode/utrans.h"
00031 
00032 /*
00033  The following is a small list as to what is currently wrong/suggestions for
00034  ustdio.
00035 
00036  * %D and %T printf uses the current timezone, but the scanf version uses GMT.
00037  * %p should be deprecated. Pointers are 2-16 bytes big and scanf should
00038     really read them.
00039  * The format specification should use int32_t and ICU type variants instead of
00040     the compiler dependent int.
00041  * We should consider using Microsoft's wprintf and wscanf format
00042     specification.
00043  * %C and %S are aliases of %lc and %ls, which are used for wchar_t.
00044     We should consider using this for UChar and replace %K and %U,
00045     or we should make them use wchar_t.
00046  * + in printf format specification is incomplete.
00047  * Make sure that #, blank and precision in the printf format specification
00048     works.
00049  * Make sure that * in the scanf format specification works.
00050  * Each UFILE takes up at least 2KB. This should be really reduced.
00051  * This library does buffering. The OS should do this for us already. Check on
00052     this, and remove it from this library, if this is the case. Double buffering
00053     wastes a lot of time and space.
00054  * Make sure that surrogates are supported.
00055  * The ustream header should also include operator<< and
00056     operator>> for UDate (not double). This may not work on some compilers
00057     that use these operators on a double.
00058  * Testing should be done for reading and writing multi-byte encodings,
00059     and make sure that a character that is contained across buffer boundries
00060     works even for incomplete characters.
00061  * Make sure that the last character is flushed when the file/string is closed.
00062  * snprintf should follow the C99 standard for the return value, which is
00063     return the number of characters (excluding the trailing '\0')
00064     which would have been written to the destination string regardless
00065     of available space. This is like pre-flighting.
00066  * Everything that uses %s should do what operator>> does for UnicodeString.
00067     It should convert one byte at a time, and once a character is
00068     converted then check to see if it's whitespace or in the scanset.
00069     If it's whitespace or in the scanset, put all the bytes back (do nothing
00070     for sprintf/sscanf).
00071  * If bad string data is encountered, make sure that the function fails
00072     without memory leaks and the unconvertable characters are valid
00073     substitution or are escaped characters.
00074  * u_fungetc() can't unget a character when it's at the beginning of the
00075     internal conversion buffer, and it shouldn't be writing new
00076     characters to this buffer because they might be different characters.
00077     This can be tested by writing a file, and reading it backwards by
00078     using u_fgetc and two u_fungetc() calls with incorrect data.
00079     FYI The behavior is undefined for ungetc() when an incorrect character
00080     is put back, when its called multiple times in a row, or when
00081     a its called without a read operation.
00082  * u_fflush() and u_fclose should return an int32_t like C99 functions.
00083    0 is returned if the operation was successful and EOF otherwise.
00084  * More testing is needed.
00085 */
00086 
00087 
00088 #define U_EOF 0xFFFF
00089 
00091 typedef struct UFILE UFILE;
00092 
00094 typedef enum { 
00095    U_READ = 1, U_WRITE = 2, 
00096    U_READWRITE =3  /* == (U_READ | U_WRITE) */ 
00097 } UFileDirection;
00098 
00117 U_CAPI UFILE* U_EXPORT2
00118 u_fopen(const char    *filename,
00119     const char    *perm,
00120     const char    *locale,
00121     const char    *codepage);
00122 
00136 U_CAPI UFILE* U_EXPORT2
00137 u_finit(FILE        *f,
00138     const char    *locale,
00139     const char    *codepage);
00140 
00146 U_CAPI void U_EXPORT2
00147 u_fclose(UFILE *file);
00148 
00157 U_CAPI void U_EXPORT2
00158 u_fflush(UFILE *file);
00159 
00166 U_CAPI FILE* U_EXPORT2
00167 u_fgetfile(UFILE *f);
00168 
00177 U_CAPI const char* U_EXPORT2
00178 u_fgetlocale(UFILE *file);
00179 
00188 U_CAPI int32_t U_EXPORT2
00189 u_fsetlocale(const char        *locale,
00190          UFILE        *file);
00191 
00201 U_CAPI const char* U_EXPORT2
00202 u_fgetcodepage(UFILE *file);
00203 
00216 U_CAPI int32_t U_EXPORT2
00217 u_fsetcodepage(const char    *codepage,
00218            UFILE        *file);
00219 
00220 
00227 U_CAPI UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
00228 
00229 /* Output functions */
00230 
00239 U_CAPI int32_t U_EXPORT2
00240 u_fprintf(    UFILE        *f,
00241         const char    *patternSpecification,
00242         ... );
00243 
00256 U_CAPI int32_t U_EXPORT2
00257 u_vfprintf(    UFILE        *f,
00258         const char    *patternSpecification,
00259         va_list        ap);
00260 
00269 U_CAPI int32_t U_EXPORT2
00270 u_fprintf_u(    UFILE        *f,
00271         const UChar    *patternSpecification,
00272         ... );
00273 
00286 U_CAPI int32_t U_EXPORT2
00287 u_vfprintf_u(    UFILE        *f,
00288         const UChar    *patternSpecification,
00289         va_list        ap);
00290 
00300 U_CAPI int32_t U_EXPORT2
00301 u_fputs(const UChar    *s,
00302     UFILE        *f);
00303 
00311 U_CAPI int32_t U_EXPORT2
00312 u_fputc(UChar        uc,
00313     UFILE        *f);
00314 
00325 U_CAPI int32_t U_EXPORT2
00326 u_file_write(const UChar     *chars, 
00327          int32_t        count, 
00328          UFILE         *f);
00329 
00330 
00331 /* Input functions */
00332 
00342 U_CAPI int32_t U_EXPORT2
00343 u_fscanf(    UFILE        *f,
00344         const char     *patternSpecification,
00345         ... );
00346 
00360 U_CAPI int32_t U_EXPORT2
00361 u_vfscanf(    UFILE        *f,
00362         const char     *patternSpecification,
00363         va_list        ap);
00364 
00374 U_CAPI int32_t U_EXPORT2
00375 u_fscanf_u(    UFILE        *f,
00376         const UChar     *patternSpecification,
00377         ... );
00378 
00392 U_CAPI int32_t U_EXPORT2
00393 u_vfscanf_u(    UFILE        *f,
00394         const UChar     *patternSpecification,
00395         va_list        ap);
00396 
00409 U_CAPI UChar* U_EXPORT2
00410 u_fgets(UFILE        *f,
00411     int32_t        n,
00412     UChar        *s);
00413 
00420 U_CAPI UChar U_EXPORT2
00421 u_fgetc(UFILE        *f);
00422 
00437 U_CAPI UChar32 U_EXPORT2
00438 u_fgetcx(UFILE        *f);
00439 
00449 U_CAPI UChar U_EXPORT2
00450 u_fungetc(UChar        c,
00451       UFILE        *f);
00452 
00463 U_CAPI int32_t U_EXPORT2
00464 u_file_read(UChar        *chars, 
00465         int32_t        count, 
00466         UFILE         *f);
00467 
00485 U_CAPI UTransliterator* U_EXPORT2
00486 u_fsettransliterator(UFILE *file, UFileDirection direction,
00487                      UTransliterator *adopt, UErrorCode *status);
00488 
00489 
00490 
00491 
00492 
00493 
00494 
00495 
00496 
00497 
00498 /* Output string functions */
00499 
00500 
00513 U_CAPI int32_t U_EXPORT2
00514 u_sprintf(UChar       *buffer,
00515         const char    *locale,
00516         const char    *patternSpecification,
00517         ... );
00518 
00537 U_CAPI int32_t U_EXPORT2
00538 u_snprintf(UChar      *buffer,
00539         int32_t       count,
00540         const char    *locale,
00541         const char    *patternSpecification,
00542         ... );
00543 
00559 U_CAPI int32_t U_EXPORT2
00560 u_vsprintf(UChar      *buffer,
00561         const char    *locale,
00562         const char    *patternSpecification,
00563         va_list        ap);
00564 
00586 U_CAPI int32_t U_EXPORT2
00587 u_vsnprintf(UChar     *buffer,
00588         int32_t       count,
00589         const char    *locale,
00590         const char    *patternSpecification,
00591         va_list        ap);
00592 
00604 U_CAPI int32_t U_EXPORT2
00605 u_sprintf_u(UChar      *buffer,
00606         const char     *locale,
00607         const UChar    *patternSpecification,
00608         ... );
00609 
00627 U_CAPI int32_t U_EXPORT2
00628 u_snprintf_u(UChar     *buffer,
00629         int32_t        count,
00630         const char     *locale,
00631         const UChar    *patternSpecification,
00632         ... );
00633 
00650 U_CAPI int32_t U_EXPORT2
00651 u_vsprintf_u(UChar     *buffer,
00652         const char    *locale,
00653         const UChar    *patternSpecification,
00654         va_list        ap);
00655 
00676 U_CAPI int32_t U_EXPORT2
00677 u_vsnprintf_u(UChar     *buffer,
00678         int32_t         count,
00679         const char     *locale,
00680         const UChar     *patternSpecification,
00681         va_list         ap);
00682 
00683 /* Input string functions */
00684 
00697 U_CAPI int32_t U_EXPORT2
00698 u_sscanf(UChar         *buffer,
00699         const char     *locale,
00700         const char     *patternSpecification,
00701         ... );
00702 
00719 U_CAPI int32_t U_EXPORT2
00720 u_vsscanf(UChar        *buffer,
00721         const char     *locale,
00722         const char     *patternSpecification,
00723         va_list        ap);
00724 
00737 U_CAPI int32_t U_EXPORT2
00738 u_sscanf_u(UChar        *buffer,
00739         const char      *locale,
00740         const UChar     *patternSpecification,
00741         ... );
00742 
00759 U_CAPI int32_t U_EXPORT2
00760 u_vsscanf_u(UChar       *buffer,
00761         const char      *locale,
00762         const UChar     *patternSpecification,
00763         va_list         ap);
00764 
00765 
00766 #endif
00767 
00768 
00769 

Generated on Tue Apr 9 11:30:12 2002 for ICU 2.1 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001