1999-08-16 21:50:52 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
2000-01-13 23:54:23 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1998-1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
1999-08-16 21:50:52 +00:00
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* File ufile.h
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 12/01/98 stephen Creation.
|
|
|
|
* 03/12/99 stephen Modified for new C API.
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UTransliterator *fTranslit;
|
|
|
|
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;
|
|
|
|
} UFILETranslitBuffer;
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
struct UFILE {
|
|
|
|
FILE *fFile; /* the actual fs interface */
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool fOwnFile; /* TRUE if fFile should be closed */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
ULocaleBundle *fBundle; /* formatters */
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool fOwnBundle; /* TRUE if fBundle should be deleted */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
UConverter *fConverter; /* for codeset conversion */
|
|
|
|
|
|
|
|
/* buffer used for fromUnicode */
|
|
|
|
char fCharBuffer [UFILE_CHARBUFFER_SIZE];
|
|
|
|
|
|
|
|
/* buffer used for toUnicode */
|
|
|
|
UChar fUCBuffer [UFILE_UCHARBUFFER_SIZE];
|
|
|
|
|
|
|
|
UChar *fUCLimit; /* data limit in fUCBuffer */
|
|
|
|
UChar *fUCPos; /* current pos in fUCBuffer */
|
2002-03-13 16:11:04 +00:00
|
|
|
|
|
|
|
UFILETranslitBuffer *fTranslit;
|
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
|
|
|
|
*/
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
u_file_write_flush( const UChar *chars,
|
|
|
|
int32_t count,
|
|
|
|
UFILE *f,
|
2002-04-02 01:17:28 +00:00
|
|
|
UBool flush);
|
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);
|
|
|
|
|
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
|