- column=MAX_COLUMN;
- writeCode(filename, options[kOptDestDir].value);
- }
- }
-
- return 0;
-}
-
-static void
-writeAssemblyCode(const char *filename, const char *destdir) {
- char entry[64];
- uint32_t buffer[1024];
- char *bufferStr = (char *)buffer;
- FileStream *in, *out;
- size_t i, length;
-
- in=T_FileStream_open(filename, "rb");
- if(in==NULL) {
- fprintf(stderr, "genccode: unable to open input file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- getOutFilename(filename, destdir, bufferStr, entry, ".s");
- out=T_FileStream_open(bufferStr, "w");
- if(out==NULL) {
- fprintf(stderr, "genccode: unable to open output file %s\n", bufferStr);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(options[kOptEntryPoint].doesOccur) {
- uprv_strcpy(entry, options[kOptEntryPoint].value);
- uprv_strcat(entry, "_dat");
- }
-
- /* turn dashes or dots in the entry name into underscores */
- length=uprv_strlen(entry);
- for(i=0; i<length; ++i) {
- if(entry[i]=='-' || entry[i]=='.') {
- entry[i]='_';
- }
- }
-
- sprintf(bufferStr, assemblyHeader[assemblyHeaderIndex].header,
- entry, entry, entry, entry,
- entry, entry, entry, entry);
- T_FileStream_writeLine(out, bufferStr);
- T_FileStream_writeLine(out, assemblyHeader[assemblyHeaderIndex].beginLine);
-
- for(;;) {
- length=T_FileStream_read(in, buffer, sizeof(buffer));
- if(length==0) {
- break;
- }
- if (length != sizeof(buffer)) {
- /* pad with extra 0's when at the end of the file */
- for(i=0; i < (length % sizeof(uint32_t)); ++i) {
- buffer[length+i] = 0;
- }
- }
- for(i=0; i<(length/sizeof(buffer[0])); i++) {
- write32(out, buffer[i]);
- }
- }
-
- T_FileStream_writeLine(out, "\n");
-
- if(T_FileStream_error(in)) {
- fprintf(stderr, "genccode: file read error while generating from file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(T_FileStream_error(out)) {
- fprintf(stderr, "genccode: file write error while generating from file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- T_FileStream_close(out);
- T_FileStream_close(in);
-}
-
-static void
-writeCCode(const char *filename, const char *destdir) {
- char buffer[4096], entry[64];
- FileStream *in, *out;
- size_t i, length;
-
- in=T_FileStream_open(filename, "rb");
- if(in==NULL) {
- fprintf(stderr, "genccode: unable to open input file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(options[kOptName].doesOccur) { /* prepend 'icudt28_' */
- strcpy(entry, options[kOptName].value);
- strcat(entry, "_");
- } else {
- entry[0] = 0;
- }
-
- getOutFilename(filename, destdir, buffer, entry+uprv_strlen(entry), ".c");
- out=T_FileStream_open(buffer, "w");
- if(out==NULL) {
- fprintf(stderr, "genccode: unable to open output file %s\n", buffer);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- /* turn dashes or dots in the entry name into underscores */
- length=uprv_strlen(entry);
- for(i=0; i<length; ++i) {
- if(entry[i]=='-' || entry[i]=='.') {
- entry[i]='_';
- }
- }
-
-#ifdef OS400
- /*
- TODO: Fix this once the compiler implements this feature. Keep in sync with udatamem.c
-
- This is here because this platform can't currently put
- const data into the read-only pages of an object or
- shared library (service program). Only strings are allowed in read-only
- pages, so we use char * strings to store the data.
-
- In order to prevent the beginning of the data from ever matching the
- magic numbers we must still use the initial double.
- [grhoten 4/24/2003]
- */
- sprintf(buffer,
- "#define U_DISABLE_RENAMING 1\n"
- "#include \"unicode/umachine.h\"\n"
- "U_CDECL_BEGIN\n"
- "const struct {\n"
- " double bogus;\n"
- " const char *bytes; \n"
- "} %s={ 0.0, \n",
- entry);
- T_FileStream_writeLine(out, buffer);
-
- for(;;) {
- length=T_FileStream_read(in, buffer, sizeof(buffer));
- if(length==0) {
- break;
- }
- for(i=0; i<length; ++i) {
- write8str(out, (uint8_t)buffer[i]);
- }
- }
-
- T_FileStream_writeLine(out, "\"\n};\nU_CDECL_END\n");
-#else
- /* Function renaming shouldn't be done in data */
- sprintf(buffer,
- "#define U_DISABLE_RENAMING 1\n"
- "#include \"unicode/umachine.h\"\n"
- "U_CDECL_BEGIN\n"
- "const struct {\n"
- " double bogus;\n"
- " uint8_t bytes[%ld]; \n"
- "} %s={ 0.0, {\n",
- (long)T_FileStream_size(in), entry);
- T_FileStream_writeLine(out, buffer);
-
- for(;;) {
- length=T_FileStream_read(in, buffer, sizeof(buffer));
- if(length==0) {
- break;
- }
- for(i=0; i<length; ++i) {
- write8(out, (uint8_t)buffer[i]);
- }
- }
-
- T_FileStream_writeLine(out, "\n}\n};\nU_CDECL_END\n");
-#endif
-
- if(T_FileStream_error(in)) {
- fprintf(stderr, "genccode: file read error while generating from file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- if(T_FileStream_error(out)) {
- fprintf(stderr, "genccode: file write error while generating from file %s\n", filename);
- exit(U_FILE_ACCESS_ERROR);
- }
-
- T_FileStream_close(out);
- T_FileStream_close(in);
-}