1999-08-16 21:50:52 +00:00
|
|
|
/*
|
2007-07-27 03:12:12 +00:00
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998-2007, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* File ufile.h
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 12/01/98 stephen Creation.
|
|
|
|
* 03/12/99 stephen Modified for new C API.
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#ifndef UFILE_H
|
|
|
|
#define UFILE_H
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/ucnv.h"
|
2002-03-13 16:11:04 +00:00
|
|
|
#include "unicode/utrans.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "locbund.h"
|
|
|
|
|
|
|
|
/* The buffer size for fromUnicode calls */
|
|
|
|
#define UFILE_CHARBUFFER_SIZE 1024
|
|
|
|
|
|
|
|
/* The buffer size for toUnicode calls */
|
|
|
|
#define UFILE_UCHARBUFFER_SIZE 1024
|
|
|
|
|
|
|
|
/* A UFILE */
|
2002-03-13 16:11:04 +00:00
|
|
|
|
2002-10-01 01:26:49 +00:00
|
|
|
#if !UCONFIG_NO_TRANSLITERATION
|
|
|
|
|
2002-03-13 16:11:04 +00:00
|
|
|
typedef struct {
|
2004-04-16 01:08:35 +00:00
|
|
|
UChar *buffer; /* Beginning of buffer */
|
|
|
|
int32_t capacity; /* Capacity of buffer */
|
|
|
|
int32_t pos; /* Beginning of untranslitted data */
|
|
|
|
int32_t length; /* Length *from beginning of buffer* of untranslitted data */
|
|
|
|
UTransliterator *translit;
|
2002-03-13 16:11:04 +00:00
|
|
|
} UFILETranslitBuffer;
|
|
|
|
|
2002-10-01 01:26:49 +00:00
|
|
|
#endif
|
|
|
|
|
2004-04-16 01:08:35 +00:00
|
|
|
typedef struct u_localized_string {
|
|
|
|
UChar *fPos; /* current pos in fUCBuffer */
|
|
|
|
const UChar *fLimit; /* data limit in fUCBuffer */
|
2004-04-16 04:27:29 +00:00
|
|
|
UChar *fBuffer; /* Place to write the string */
|
2002-10-01 01:26:49 +00:00
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
2004-04-16 01:08:35 +00:00
|
|
|
ULocaleBundle fBundle; /* formatters */
|
2002-10-01 01:26:49 +00:00
|
|
|
#endif
|
2004-04-16 01:08:35 +00:00
|
|
|
} u_localized_string;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2004-04-16 01:08:35 +00:00
|
|
|
struct UFILE {
|
|
|
|
#if !UCONFIG_NO_TRANSLITERATION
|
|
|
|
UFILETranslitBuffer *fTranslit;
|
|
|
|
#endif
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2004-04-16 01:08:35 +00:00
|
|
|
FILE *fFile; /* the actual filesystem interface */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2004-04-16 01:08:35 +00:00
|
|
|
UConverter *fConverter; /* for codeset conversion */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2004-04-16 01:08:35 +00:00
|
|
|
u_localized_string str; /* struct to handle strings for number formatting */
|
2002-03-13 16:11:04 +00:00
|
|
|
|
2004-04-16 01:08:35 +00:00
|
|
|
UChar fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
|
|
|
|
|
|
|
|
UBool fOwnFile; /* TRUE if fFile should be closed */
|
2004-08-13 17:05:00 +00:00
|
|
|
|
|
|
|
int32_t fFileno; /* File number. Useful to determine if it's stdin. */
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
2002-03-13 16:11:04 +00:00
|
|
|
/**
|
|
|
|
* Like u_file_write but takes a flush parameter
|
|
|
|
*/
|
2007-06-10 20:11:28 +00:00
|
|
|
U_CFUNC int32_t U_EXPORT2
|
2005-06-23 07:10:52 +00:00
|
|
|
u_file_write_flush( const UChar *chars,
|
|
|
|
int32_t count,
|
|
|
|
UFILE *f,
|
|
|
|
UBool flushIO,
|
|
|
|
UBool flushTranslit);
|
2002-03-13 16:11:04 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Fill a UFILE's buffer with converted codepage data.
|
|
|
|
* @param f The UFILE containing the buffer to fill.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ufile_fill_uchar_buffer(UFILE *f);
|
|
|
|
|
2004-04-28 23:20:46 +00:00
|
|
|
/**
|
2004-05-03 05:21:24 +00:00
|
|
|
* Get one code unit and detect whether the end of file has been reached.
|
2004-04-28 23:20:46 +00:00
|
|
|
* @param f The UFILE containing the characters.
|
|
|
|
* @param ch The read in character
|
|
|
|
* @return TRUE if the character is valid, or FALSE when EOF has been detected
|
|
|
|
*/
|
|
|
|
U_CFUNC UBool U_EXPORT2
|
|
|
|
ufile_getch(UFILE *f, UChar *ch);
|
|
|
|
|
2004-05-03 05:21:24 +00:00
|
|
|
/**
|
|
|
|
* Get one character and detect whether the end of file has been reached.
|
|
|
|
* @param f The UFILE containing the characters.
|
|
|
|
* @param ch The read in character
|
|
|
|
* @return TRUE if the character is valid, or FALSE when EOF has been detected
|
|
|
|
*/
|
|
|
|
U_CFUNC UBool U_EXPORT2
|
2004-05-03 06:03:21 +00:00
|
|
|
ufile_getch32(UFILE *f, UChar32 *ch);
|
2004-05-03 05:21:24 +00:00
|
|
|
|
2002-03-13 16:11:04 +00:00
|
|
|
/**
|
|
|
|
* Close out the transliterator and flush any data therein.
|
|
|
|
* @param f flu
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ufile_close_translit(UFILE *f);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush the buffer in the transliterator
|
|
|
|
* @param f UFile to flush
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ufile_flush_translit(UFILE *f);
|
|
|
|
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
#endif
|