ICU-1828 These files don't seem to be used.

X-SVN-Rev: 8493
This commit is contained in:
George Rhoten 2002-04-19 01:25:47 +00:00
parent a600b010ec
commit c353ded34d
7 changed files with 0 additions and 1098 deletions

View file

@ -1,504 +0,0 @@
/*
*******************************************************************************
*
* Copyright (C) 1998-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
* File list.c
*
* Modification History:
*
* Date Name Description
* 06/01/99 stephen Creation.
*******************************************************************************
*/
#include "list.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/ustring.h"
/* Protos */
static void strlist_grow(struct SList *list, UErrorCode *status);
static void strlist2d_grow(struct SList *list, UErrorCode *status);
static void strlist2d_growRows(struct SList *list, UErrorCode *status);
static void taglist_grow(struct SList *list, UErrorCode *status);
/* String list */
struct SList*
strlist_open(UErrorCode *status)
{
struct SList *list;
if(U_FAILURE(*status)) return 0;
list = (struct SList*) uprv_malloc(sizeof(struct SList));
if(list == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
list->fType = eStringList;
list->u.fStringList.fData = 0;
list->u.fStringList.fCount = 0;
list->u.fStringList.fCapacity = 32;
strlist_grow(list, status);
return list;
}
void
strlist_close(struct SList *list,
UErrorCode *status)
{
int32_t i;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
/* deallocate each string */
for(i = 0; i < list->u.fStringList.fCount; ++i) {
uprv_free(list->u.fStringList.fData[i]);
}
uprv_free(list->u.fStringList.fData);
list->fType = eEmpty;
uprv_free(list);
}
void
strlist_add(struct SList *list,
const UChar *s,
UErrorCode *status)
{
int32_t index;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
index = list->u.fStringList.fCount;
if(list->u.fStringList.fCount == list->u.fStringList.fCapacity)
strlist_grow(list, status);
list->u.fStringList.fData[index] = (UChar*)
uprv_malloc(sizeof(UChar) * (u_strlen(s) + 1));
if(list->u.fStringList.fData[index] == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
u_strcpy(list->u.fStringList.fData[index], s);
++(list->u.fStringList.fCount);
}
static void
strlist_grow(struct SList *list,
UErrorCode *status)
{
int32_t i, j;
int32_t newCapacity;
UChar **newData;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
newCapacity = list->u.fStringList.fCapacity << 1;
/* allocate space for the array of strings */
newData = (UChar**) uprv_malloc(sizeof(UChar*) * newCapacity);
if(newData == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
/* allocate and copy each string */
for(i = 0; i < list->u.fStringList.fCount; ++i) {
newData[i] = (UChar*)
uprv_malloc(sizeof(UChar) * (u_strlen(list->u.fStringList.fData[i]) + 1));
if(newData[i] == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
for(j = 0; j < i; ++j)
uprv_free(newData[j]);
uprv_free(newData);
return;
}
u_strcpy(newData[i], list->u.fStringList.fData[i]);
}
uprv_free(list->u.fStringList.fData);
list->u.fStringList.fData = newData;
list->u.fStringList.fCapacity = newCapacity;
}
/* 2-d String list*/
struct SList*
strlist2d_open(UErrorCode *status)
{
struct SList *list;
if(U_FAILURE(*status)) return 0;
list = (struct SList*) uprv_malloc(sizeof(struct SList));
if(list == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
list->fType = eStringList2d;
list->u.fStringList2d.fData = 0;
list->u.fStringList2d.fCount = 0;
list->u.fStringList2d.fCapacity = 32;
list->u.fStringList2d.fRows = 0;
list->u.fStringList2d.fRowCount = 0;
list->u.fStringList2d.fRowCapacity = 32;
strlist2d_grow(list, status);
strlist2d_growRows(list, status);
if(U_SUCCESS(*status)) {
list->u.fStringList2d.fRows[0] = 0;
list->u.fStringList2d.fRowCount = 1;
}
return list;
}
void
strlist2d_close(struct SList *list,
UErrorCode *status)
{
int32_t i;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList2d) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
/* deallocate each string */
for(i = 0; i < list->u.fStringList2d.fCount; ++i) {
uprv_free(list->u.fStringList2d.fData[i]);
}
uprv_free(list->u.fStringList2d.fData);
uprv_free(list->u.fStringList2d.fRows);
list->fType = eEmpty;
uprv_free(list);
}
void
strlist2d_newRow(struct SList *list,
UErrorCode *status)
{
if(U_FAILURE(*status)) return;
if(list->fType != eStringList2d) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
if(list->u.fStringList2d.fRowCount == list->u.fStringList2d.fRowCapacity)
strlist2d_growRows(list, status);
if(U_FAILURE(*status)) return;
list->u.fStringList2d.fRows[(list->u.fStringList2d.fRowCount)++] =
list->u.fStringList2d.fCount;
}
void strlist2d_add(struct SList *list,
const UChar *s,
UErrorCode *status)
{
int32_t index;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList2d) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
index = list->u.fStringList2d.fCount;
if(list->u.fStringList2d.fCount == list->u.fStringList2d.fCapacity)
strlist2d_grow(list, status);
list->u.fStringList2d.fData[index] = (UChar*)
uprv_malloc(sizeof(UChar) * (u_strlen(s) + 1));
if(list->u.fStringList2d.fData[index] == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
u_strcpy(list->u.fStringList2d.fData[index], s);
++(list->u.fStringList2d.fCount);
}
static void
strlist2d_grow(struct SList *list,
UErrorCode *status)
{
int32_t i, j;
int32_t newCapacity;
UChar **newData;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList2d) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
newCapacity = list->u.fStringList2d.fCapacity << 1;
/* allocate space for the array of strings */
newData = (UChar**) uprv_malloc(sizeof(UChar*) * newCapacity);
if(newData == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
/* allocate and copy each string */
for(i = 0; i < list->u.fStringList2d.fCount; ++i) {
newData[i] = (UChar*)
uprv_malloc(sizeof(UChar) * (u_strlen(list->u.fStringList2d.fData[i]) + 1));
if(newData[i] == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
for(j = 0; j < i; ++j)
uprv_free(newData[j]);
uprv_free(newData);
return;
}
u_strcpy(newData[i], list->u.fStringList2d.fData[i]);
}
uprv_free(list->u.fStringList2d.fData);
list->u.fStringList2d.fData = newData;
list->u.fStringList2d.fCapacity = newCapacity;
}
static void
strlist2d_growRows(struct SList *list,
UErrorCode *status)
{
int32_t i;
int32_t newCapacity;
int32_t *newRows;
if(U_FAILURE(*status)) return;
if(list->fType != eStringList2d) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
newCapacity = list->u.fStringList2d.fRowCapacity << 1;
/* allocate space for the array of ints */
newRows = (int32_t*) uprv_malloc(sizeof(int32_t) * newCapacity);
if(newRows == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
}
/* copy each int */
for(i = 0; i < list->u.fStringList2d.fRowCount; ++i)
newRows[i] = list->u.fStringList2d.fRows[i];
/* clean up */
uprv_free(list->u.fStringList2d.fRows);
list->u.fStringList2d.fRows = newRows;
list->u.fStringList2d.fRowCapacity = newCapacity;
}
/* Tagged list */
struct SList*
taglist_open(UErrorCode *status)
{
struct SList *list;
if(U_FAILURE(*status)) return 0;
list = (struct SList*) uprv_malloc(sizeof(struct SList));
if(list == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
list->fType = eTaggedList;
/*list->u.fTaggedList.fData = 0;*/
list->u.fTaggedList.fFirst = NULL;
list->u.fTaggedList.fCount = 0;
/*list->u.fTaggedList.fCapacity = 32;*/
/*taglist_grow(list, status);*/
return list;
}
void
taglist_close(struct SList *list,
UErrorCode *status)
{
struct SStringPair *current;
struct SStringPair *prev;
if(U_FAILURE(*status)) return;
if(list->fType != eTaggedList) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
current = list->u.fTaggedList.fFirst;
while(current != NULL) {
prev = current;
current = current->fNext;
uprv_free(prev);
}
/*uprv_free(list->u.fTaggedList.fData);*/
list->fType = eEmpty;
uprv_free(list);
}
void
taglist_add(struct SList *list,
const UChar *tag,
const UChar *data,
UErrorCode *status)
{
/*int32_t index;*/
struct SStringPair *pair = NULL;
struct SStringPair *current = NULL;
struct SStringPair *prev = NULL;
if(U_FAILURE(*status)) return;
if(list->fType != eTaggedList) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
pair = (struct SStringPair *) uprv_malloc(sizeof(struct SStringPair));
if(pair->fKey == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
pair->fKey = (char*) uprv_malloc(sizeof(char) * (u_strlen(tag) + 1));
if(pair->fKey == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
uprv_free(pair);
return;
}
pair->fValue = (UChar*) uprv_malloc(sizeof(UChar) * (u_strlen(data) + 1));
if(pair->fValue == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
uprv_free(pair->fKey);
uprv_free(pair);
return;
}
++(list->u.fTaggedList.fCount);
/*u_strcpy(pair.fKey, tag);*/
u_UCharsToChars(tag, pair->fKey, u_strlen(tag)+1);
u_strcpy(pair->fValue, data);
/* is list still empty? */
if(list->u.fTaggedList.fFirst == NULL) {
list->u.fTaggedList.fFirst = pair;
pair->fNext = NULL;
return;
} else {
current = list->u.fTaggedList.fFirst;
}
while(current != NULL) {
if(uprv_strcmp(current->fKey, pair->fKey)<0) {
prev = current;
current = current->fNext;
} else { /*we're either in front of list, or in middle*/
if(prev == NULL) { /*front of the list*/
list->u.fTaggedList.fFirst = pair;
} else { /*middle of the list*/
prev->fNext = pair;
}
pair->fNext = current;
return;
}
}
/* end of list */
prev->fNext = pair;
pair->fNext = NULL;
/*index = list->u.fTaggedList.fCount;*/
/*if(list->u.fTaggedList.fCount == list->u.fTaggedList.fCapacity)*/
/*taglist_grow(list, status);*/
/*list->u.fTaggedList.fData[index] = pair;*/
}
const UChar*
taglist_get(const struct SList *list,
const char *tag,
UErrorCode *status)
{
/*int32_t i;*/
struct SStringPair *current;
if(U_FAILURE(*status)) return 0;
if(list->fType != eTaggedList) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
/* is list still empty? */
if(list->u.fTaggedList.fFirst == NULL) {
return NULL;
} else {
current = list->u.fTaggedList.fFirst;
}
while(current != NULL) {
if(uprv_strcmp(current->fKey, tag)!=0) {
current = current->fNext;
} else { /*we're either in front of list, or in middle*/
return current->fValue;
}
}
return NULL;
}

View file

@ -1,91 +0,0 @@
/*
*******************************************************************************
*
* Copyright (C) 1998-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
* File list.h
*
* Modification History:
*
* Date Name Description
* 06/01/99 stephen Creation.
*******************************************************************************
*/
#ifndef LIST_H
#define LIST_H 1
#include "unicode/utypes.h"
/* A string list */
struct SStringList {
UChar **fData;
int32_t fCount;
int32_t fCapacity;
};
struct SList* strlist_open(UErrorCode *status);
void strlist_close(struct SList *list, UErrorCode *status);
void strlist_add(struct SList *list, const UChar *s, UErrorCode *status);
/* A two-dimensional string list */
struct SStringList2d {
UChar **fData;
int32_t fCount;
int32_t fCapacity;
int32_t *fRows;
int32_t fRowCount;
int32_t fRowCapacity;
};
struct SList* strlist2d_open(UErrorCode *status);
void strlist2d_close(struct SList *list, UErrorCode *status);
void strlist2d_newRow(struct SList *list, UErrorCode *status);
void strlist2d_add(struct SList *list, const UChar *s, UErrorCode *status);
/* A name/value pair for a tagged list */
struct SStringPair {
char *fKey;
UChar *fValue;
struct SStringPair *fNext;
};
/* A tagged list */
struct STaggedList {
struct SStringPair *fFirst;
/*struct SStringPair *fData;*/
int32_t fCount;
/*int32_t fCapacity;*/
};
struct SList* taglist_open(UErrorCode *status);
void taglist_close(struct SList *list, UErrorCode *status);
void taglist_add(struct SList *list, const UChar *tag,
const UChar *data, UErrorCode *status);
const UChar* taglist_get(const struct SList *list, const char *tag,
UErrorCode *status);
/* Types of lists */
enum EListType {
eEmpty,
eStringList,
eStringList2d,
eTaggedList
};
/* A generic list container */
struct SList {
enum EListType fType; /* type of element in union */
union {
struct SStringList fStringList;
struct SStringList2d fStringList2d;
struct STaggedList fTaggedList;
} u;
};
#endif

View file

@ -20,7 +20,6 @@
#include "unicode/utypes.h"
#include "filestrm.h"
#include "rblist.h"
#include "ucbuf.h"
U_CDECL_BEGIN

View file

@ -1,190 +0,0 @@
/*
*******************************************************************************
*
* Copyright (C) 1998-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
* File rblist.c
*
* Modification History:
*
* Date Name Description
* 06/01/99 stephen Creation.
*******************************************************************************
*/
#include "rblist.h"
#include "ustr.h"
#include "unicode/ustring.h"
#include "cmemory.h"
#include "cstring.h"
struct SRBItem*
make_rbitem(const UChar *tag,
const struct SList *data,
UErrorCode *status)
{
struct SRBItem *item;
char *s;
if(U_FAILURE(*status)) return 0;
item = (struct SRBItem*) uprv_malloc(sizeof(struct SRBItem));
if(item == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
/* s = (UChar*) uprv_malloc(sizeof(UChar) * (u_strlen(tag) + 1)); */
s = (char*) uprv_malloc(sizeof(char) * (u_strlen(tag) + 1));
if(s == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
u_UCharsToChars(tag, s, u_strlen(tag)+1);
/* u_strcpy(s, tag); */
item->fTag = s;
item->fData = (struct SList*) data;
item->fNext = NULL;
return item;
}
struct SRBItemList*
rblist_open(UErrorCode *status)
{
struct SRBItemList *list;
if(U_FAILURE(*status)) return 0;
list = (struct SRBItemList*) uprv_malloc(sizeof(struct SRBItemList));
if(list == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
list->fLocale = 0;
list->fFirst = NULL;
/* list->fData = 0; */
list->fCount = 0;
list->fCapacity = 32;
list->fKeys = (char *) uprv_malloc(sizeof(char) * 65532);
list->fKeyPoint = 0;
return list;
}
void rblist_close(struct SRBItemList *list,
UErrorCode *status)
{
/* int32_t i; */
struct SRBItem *current;
struct SRBItem *prev = NULL;
if(U_FAILURE(*status)) return;
current = list->fFirst;
/* deallocate each list */
/* for(i = 0; i < list->fCount; ++i) { */
while(current != NULL) {
/* switch(list->fData[i]->fData->fType) { */
switch(current->fData->fType) {
case eStringList:
strlist_close(current->fData, status);
break;
case eStringList2d:
strlist2d_close(current->fData, status);
break;
case eTaggedList:
taglist_close(current->fData, status);
break;
case eEmpty:
break;
}
prev = current;
current=current->fNext;
uprv_free(prev);
}
/* uprv_free(list->fData); */
uprv_free(list->fLocale);
uprv_free(list->fKeys);
uprv_free(list);
}
void rblist_setlocale(struct SRBItemList *list,
const UChar *locale,
UErrorCode *status)
{
if(U_FAILURE(*status)) return;
/* Allocate enough space */
list->fLocale = (UChar*) uprv_realloc(list->fLocale,
sizeof(UChar) * (u_strlen(locale) + 1));
if(list->fLocale == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return;
}
u_strcpy(list->fLocale, locale);
}
void rblist_add(struct SRBItemList *list,
struct SRBItem *s,
UErrorCode *status)
{
/* int32_t index; */
struct SRBItem *current;
struct SRBItem *prev = NULL;
if(U_FAILURE(*status)) return;
/* here we need to traverse the list */
++(list->fCount);
s->fStrKey = list->fKeyPoint;
uprv_strcpy((list->fKeys)+list->fKeyPoint, s->fTag);
list->fKeyPoint += uprv_strlen(s->fTag)+1;
/* is list still empty? */
if(list->fFirst == NULL) {
list->fFirst = s;
s->fNext = NULL;
return;
} else {
current = list->fFirst;
}
while(current != NULL) {
if(uprv_strcmp(current->fTag, s->fTag)<0) {
prev = current;
current = current->fNext;
} else { /*we're either in front of list, or in middle*/
if(prev == NULL) { /*front of the list*/
list->fFirst = s;
} else { /*middle of the list*/
prev->fNext = s;
}
s->fNext = current;
return;
}
}
/* end of list */
prev->fNext = s;
s->fNext = NULL;
}

View file

@ -1,54 +0,0 @@
/*
*******************************************************************************
*
* Copyright (C) 1998-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
* File rblist.h
*
* Modification History:
*
* Date Name Description
* 06/01/99 stephen Creation.
*******************************************************************************
*/
#ifndef RBLIST_H
#define RBLIST_H 1
#include "unicode/utypes.h"
#include "list.h"
/* A resource bundle data item */
struct SRBItem {
char *fTag;
int16_t fStrKey;
struct SList *fData;
struct SRBItem *fNext;
};
/* A list of RBItems */
struct SRBItemList {
UChar *fLocale;
char *fKeys;
int16_t fKeyPoint;
int32_t fCount;
int32_t fCapacity;
struct SRBItem *fFirst;
};
struct SRBItemList* rblist_open(UErrorCode *status);
struct SRBItem* make_rbitem(const UChar *tag, const struct SList *data,
UErrorCode *status);
void rblist_close(struct SRBItemList *list, UErrorCode *status);
void rblist_setlocale(struct SRBItemList *list, const UChar *locale,
UErrorCode *status);
void rblist_add(struct SRBItemList *list, struct SRBItem *s,
UErrorCode *status);
#endif

View file

@ -1,230 +0,0 @@
/*
*******************************************************************************
*
* Copyright (C) 1998-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
* File write.c
*
* Modification History:
*
* Date Name Description
* 06/01/99 stephen Creation.
*******************************************************************************
*/
#include <stdio.h>
#include "write.h"
#include "cmemory.h"
#include "cstring.h"
#include "filestrm.h"
#include "unicode/ustring.h"
#include "error.h"
#include "list.h"
/* Protos */
static void write_ustring(FileStream *rb, const UChar *data);
static void write_string(FileStream *rb, const char *data);
static void write_strlist(FileStream *rb, const char *name,
const struct SStringList *list);
static void write_strlist2d(FileStream *rb, const char *name,
const struct SStringList2d *list);
static void write_taglist(FileStream *rb, const char *name,
const struct STaggedList *list);
/* Special values */
static const int32_t sBOM = 0x021C;
static const int32_t sEOF = -1;
static const int32_t sSTRINGLIST = 1;
static const int32_t sSTRINGLIST2D = 2;
static const int32_t sTAGGEDLIST = 3;
static const UChar gCollationElementsTag [] = {
/* "CollationElements" */
0x0043, 0x006f, 0x006c, 0x006c, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e,
0x0045, 0x006c, 0x0065, 0x006d, 0x0065, 0x006e, 0x0074, 0x0073, 0x0000
};
/* Write a null-terminated UChar array */
static void
write_ustring(FileStream *rb,
const UChar *data)
{
int32_t len;
len = u_strlen(data);
/* Write the string's length */
T_FileStream_write(rb, &len, sizeof(len));
/* Write the string's data */
T_FileStream_write(rb, data, sizeof(UChar) * len);
}
static void
write_string(FileStream *rb,
const char *data) {
int32_t len;
len = uprv_strlen(data);
T_FileStream_write(rb, &len, sizeof(len));
T_FileStream_write(rb, data, sizeof(char) * len);
}
/* Write a string list */
static void
write_strlist(FileStream *rb,
const char *name,
const struct SStringList *list)
{
int32_t i;
/* Write out the value indicating this is a string list */
T_FileStream_write(rb, &sSTRINGLIST, sizeof(sSTRINGLIST));
/* Write the name of this string list */
write_string(rb, name);
/* Write the item count */
T_FileStream_write(rb, &list->fCount, sizeof(list->fCount));
/* Write each string in the list */
for(i = 0; i < list->fCount; ++i) {
write_ustring(rb, list->fData[i]);
}
}
/* Write a 2-d string list */
static void
write_strlist2d(FileStream *rb,
const char *name,
const struct SStringList2d *list)
{
int32_t i, j;
int32_t itemcount;
/* Write out the value indicating this is a 2-d string list */
T_FileStream_write(rb, &sSTRINGLIST2D, sizeof(sSTRINGLIST2D));
/* Write the name of this 2-d string list */
write_string(rb, name);
/* Write the row count */
T_FileStream_write(rb, &list->fRowCount, sizeof(list->fRowCount));
/* Write out each row */
for(i = 0; i < list->fRowCount; ++i) {
itemcount = (i == list->fRowCount - 1 ? list->fCount: list->fRows[i+1])
- list->fRows[i];
/* Write out the count of strings in this row */
T_FileStream_write(rb, &itemcount, sizeof(itemcount));
/* Write out each string in the row */
for(j = 0; j < itemcount; ++j) {
write_ustring(rb, list->fData[list->fRows[i] + j]);
}
}
}
/* Write a tagged list */
static void
write_taglist(FileStream *rb,
const char *name,
const struct STaggedList *list)
{
/* int32_t i; */
struct SStringPair *current;
/* Write out the value indicating this is a tagged list */
T_FileStream_write(rb, &sTAGGEDLIST, sizeof(sTAGGEDLIST));
/* Write the name of this tagged list */
write_string(rb, name);
/* Write the item count */
T_FileStream_write(rb, &list->fCount, sizeof(list->fCount));
/* Write out each key/value pair */
current = list->fFirst;
while(current != NULL) {
write_string(rb, current->fKey);
write_ustring(rb, current->fValue);
current = current->fNext;
}
/* for(i = 0; i < list->fCount; ++i) {
// write_ustring(rb, list->fData[i].fKey);
// write_ustring(rb, list->fData[i].fValue);
// } */
}
/* Write a parsed SRBItemList to a file */
void
rb_write(FileStream *f,
struct SRBItemList *data,
UErrorCode *status)
{
/* int32_t i; */
struct SRBItem *item;
if(U_FAILURE(*status)) return;
/* Write the byte order mark to the file */
T_FileStream_write(f, &sBOM, sizeof(sBOM));
/* Write the locale name to the file */
write_ustring(f, data->fLocale);
item = data->fFirst;
/* Successively write each list item */
/* for(i = 0; i < data->fCount; ++i) { */
while(item != NULL) {
/* item = data->fData[i]; */
switch(item->fData->fType) {
case eStringList:
/*if(u_strcmp(item->fTag, gCollationElementsTag) == 0)
puts("got CollationElements");*/
write_strlist(f, item->fTag, &item->fData->u.fStringList);
break;
case eStringList2d:
write_strlist2d(f, item->fTag, &item->fData->u.fStringList2d);
break;
case eTaggedList:
write_taglist(f, item->fTag, &item->fData->u.fTaggedList);
break;
case eEmpty:
*status = U_INTERNAL_PROGRAM_ERROR;
setErrorText("Unexpected empty item found");
goto finish;
/*break;*/
}
item = item->fNext;
}
/* Indicate the end of the data */
T_FileStream_write(f, &sEOF, sizeof(sEOF));
/* Check if any errors occurred during writing */
if(T_FileStream_error(f) != 0) {
*status = U_FILE_ACCESS_ERROR;
}
finish:
;
/* clean up */
}

View file

@ -1,28 +0,0 @@
/*
*******************************************************************************
*
* Copyright (C) 1998-1999, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*
* File write.h
*
* Modification History:
*
* Date Name Description
* 06/01/99 stephen Creation.
*******************************************************************************
*/
#ifndef WRITE_H
#define WRITE_H 1
#include "unicode/utypes.h"
#include "rblist.h"
#include "filestrm.h"
/* Write a resource bundle item list to a file */
void rb_write(FileStream *f, struct SRBItemList *data, UErrorCode *status);
#endif