intl/icu/source/io/ufile.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  *******************************************************************************
     3  *
     4  *   Copyright (C) 1998-2010, International Business Machines
     5  *   Corporation and others.  All Rights Reserved.
     6  *
     7  *******************************************************************************
     8  *
     9  * File ufile.h
    10  *
    11  * Modification History:
    12  *
    13  *   Date        Name        Description
    14  *   12/01/98    stephen        Creation.
    15  *   03/12/99    stephen     Modified for new C API.
    16  *******************************************************************************
    17  */
    19 #ifndef UFILE_H
    20 #define UFILE_H
    22 #include "unicode/utypes.h"
    23 #include "unicode/ucnv.h"
    24 #include "unicode/utrans.h"
    25 #include "locbund.h"
    27 /* The buffer size for fromUnicode calls */
    28 #define UFILE_CHARBUFFER_SIZE 1024
    30 /* The buffer size for toUnicode calls */
    31 #define UFILE_UCHARBUFFER_SIZE 1024
    33 /* A UFILE */
    35 #if !UCONFIG_NO_TRANSLITERATION
    37 typedef struct {
    38     UChar  *buffer;             /* Beginning of buffer */
    39     int32_t capacity;           /* Capacity of buffer */
    40     int32_t pos;                /* Beginning of untranslitted data */
    41     int32_t length;             /* Length *from beginning of buffer* of untranslitted data */
    42     UTransliterator *translit;
    43 } UFILETranslitBuffer;
    45 #endif
    47 typedef struct u_localized_string {
    48     UChar       *fPos;          /* current pos in fUCBuffer */
    49     const UChar *fLimit;        /* data limit in fUCBuffer */
    50     UChar       *fBuffer;       /* Place to write the string */
    52 #if !UCONFIG_NO_FORMATTING
    53     ULocaleBundle  fBundle; /* formatters */
    54 #endif
    55 } u_localized_string;
    57 struct UFILE {
    58 #if !UCONFIG_NO_TRANSLITERATION
    59     UFILETranslitBuffer *fTranslit;
    60 #endif
    62     FILE        *fFile;         /* the actual filesystem interface */
    64     UConverter  *fConverter;    /* for codeset conversion */
    66     u_localized_string str;     /* struct to handle strings for number formatting */
    68     UChar       fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
    70     UBool       fOwnFile;       /* TRUE if fFile should be closed */
    72     int32_t     fFileno;        /* File number. Useful to determine if it's stdin. */
    73 };
    75 /**
    76  * Like u_file_write but takes a flush parameter
    77  */
    78 U_CFUNC int32_t U_EXPORT2
    79 u_file_write_flush( const UChar     *chars, 
    80         int32_t     count, 
    81         UFILE       *f,
    82         UBool       flushIO,
    83         UBool       flushTranslit);
    85 /**
    86  * Fill a UFILE's buffer with converted codepage data.
    87  * @param f The UFILE containing the buffer to fill.
    88  */
    89 void
    90 ufile_fill_uchar_buffer(UFILE *f);
    92 /**
    93  * Get one code unit and detect whether the end of file has been reached.
    94  * @param f The UFILE containing the characters.
    95  * @param ch The read in character
    96  * @return TRUE if the character is valid, or FALSE when EOF has been detected
    97  */
    98 U_CFUNC UBool U_EXPORT2
    99 ufile_getch(UFILE *f, UChar *ch);
   101 /**
   102  * Get one character and detect whether the end of file has been reached.
   103  * @param f The UFILE containing the characters.
   104  * @param ch The read in character
   105  * @return TRUE if the character is valid, or FALSE when EOF has been detected
   106  */
   107 U_CFUNC UBool U_EXPORT2
   108 ufile_getch32(UFILE *f, UChar32 *ch);
   110 /**
   111  * Close out the transliterator and flush any data therein.
   112  * @param f flu
   113  */
   114 void 
   115 ufile_close_translit(UFILE *f);
   117 /**
   118  * Flush the buffer in the transliterator 
   119  * @param f UFile to flush
   120  */
   121 void 
   122 ufile_flush_translit(UFILE *f);
   124 /**
   125  * Flush the IO buffer
   126  * @param f UFile to flush
   127  */
   128 void 
   129 ufile_flush_io(UFILE *f);
   132 #endif

mercurial