Skip to content

Commit ac3d75c

Browse files
author
ByteSizedFox
committed
add NO_FILESYSTEM flag into dictionary for embedded system support
1 parent 39c70db commit ac3d75c

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

src/loaddict.c

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
* Comments:
114114
*
115115
* *****************************************************************/
116+
#ifndef NO_FILESYSTEM
116117
void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_siz,
117118
unsigned int * dict_bytes, LPVOID *dicMapStartAddr, DT_HANDLE *dicMapObject,
118119
DT_HANDLE *dicFileHandle, MEMMAP_T dict_map
@@ -162,7 +163,14 @@ void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_
162163
return;
163164
}
164165
}
165-
166+
#else
167+
void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_siz,
168+
unsigned int * dict_bytes, LPVOID *dicMapStartAddr, DT_HANDLE *dicMapObject,
169+
DT_HANDLE *dicFileHandle, MEMMAP_T dict_map
170+
) {
171+
// dummy stub
172+
}
173+
#endif
166174
/* ******************************************************************
167175
* Function Name: load_dictionary()
168176
*
@@ -192,6 +200,8 @@ void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_
192200
* Comments:
193201
*
194202
* *****************************************************************/
203+
#ifndef NO_FILESYSTEM // if has a filesystem
204+
195205
#ifdef WIN32_OLD
196206
void TextToSpeechErrorHandler( LPTTS_HANDLE_T, UINT, MMRESULT );
197207

@@ -625,4 +635,67 @@ restart:if ( *dict_siz > 0 )
625635
#endif
626636
return( MMSYSERR_NOERROR );
627637
}
628-
/*********************************** end of loaddict.c ****************************/
638+
639+
#else // if has no filesystem
640+
641+
extern const unsigned char main_dict[];
642+
#define get_long_int(ptr) ((U32) ((((U8 *)(ptr))[3] << 24) | (((U8 *)(ptr))[2] << 16) | (((U8 *)(ptr))[1] << 8) | (((U8 *)(ptr))[0])))
643+
644+
int load_dictionary_raw( void **dict_index, void **dict_data, unsigned int *dict_siz,
645+
unsigned int *dict_bytes, char *dict_nam, int bRequired,
646+
DT_HANDLE *dicMapObject, // Handle for mapped object
647+
DT_HANDLE *dicFileHandle, // File Handle
648+
LPVOID *dicMapStartAddr, // Starting address of mapped view
649+
MEMMAP_T dict_map) {
650+
S32 *dict_index_buffer;
651+
unsigned char *dict_data_buffer;
652+
int entries, bytes, size, pointer_list_size;
653+
int status;
654+
655+
/*
656+
* set error return values
657+
*/
658+
if ( *dict_siz > 0 ) {
659+
return( MMSYSERR_ERROR );
660+
}
661+
662+
*dict_siz = 0;
663+
*dict_bytes = 0;
664+
dict_index_buffer = NULL;
665+
dict_data_buffer = NULL;
666+
667+
if ( !main_dict ) {
668+
if ( bRequired ) {
669+
fprintf(stderr,"Failed to open dictionary file %s\n",dict_nam);
670+
return ( MMSYSERR_INVALPARAM );
671+
}
672+
return( MMSYSERR_NOERROR );
673+
}
674+
675+
/* Read in file header */
676+
entries = get_long_int(main_dict);
677+
678+
/* tek 30jan97 bail with no error if the dictionary has no entries */
679+
if (entries == 0) {
680+
return (MMSYSERR_NOERROR);
681+
}
682+
683+
pointer_list_size = ( entries * sizeof(S32) );
684+
bytes = get_long_int(&main_dict[4]);
685+
686+
/* Compute & allocate required memory for both parts of dictionary */
687+
/* Allocated 4 (8 on alpha) extra bytes to store the size of the dictionary in bytes. JAW 7/7/98 */
688+
size = pointer_list_size + bytes;
689+
690+
dict_index_buffer = (int *) &main_dict[8]; // (int *)((((QWORD)*dicMapStartAddr) + 8)); //start the index buffer at start address + 8 bytes
691+
dict_data_buffer = (unsigned char *)(pointer_list_size + ((QWORD)dict_index_buffer)); //start
692+
693+
/* write output parameters */
694+
*dict_index = dict_index_buffer;
695+
*dict_data = dict_data_buffer;
696+
*dict_siz = entries;
697+
*dict_bytes = bytes;
698+
return( MMSYSERR_NOERROR );
699+
}
700+
701+
#endif

0 commit comments

Comments
 (0)