|
113 | 113 | * Comments: |
114 | 114 | * |
115 | 115 | * *****************************************************************/ |
| 116 | +#ifndef NO_FILESYSTEM |
116 | 117 | void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_siz, |
117 | 118 | unsigned int * dict_bytes, LPVOID *dicMapStartAddr, DT_HANDLE *dicMapObject, |
118 | 119 | DT_HANDLE *dicFileHandle, MEMMAP_T dict_map |
@@ -162,7 +163,14 @@ void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_ |
162 | 163 | return; |
163 | 164 | } |
164 | 165 | } |
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 |
166 | 174 | /* ****************************************************************** |
167 | 175 | * Function Name: load_dictionary() |
168 | 176 | * |
@@ -192,6 +200,8 @@ void unload_dictionary( void **dict_index, void **dict_data, unsigned int *dict_ |
192 | 200 | * Comments: |
193 | 201 | * |
194 | 202 | * *****************************************************************/ |
| 203 | +#ifndef NO_FILESYSTEM // if has a filesystem |
| 204 | + |
195 | 205 | #ifdef WIN32_OLD |
196 | 206 | void TextToSpeechErrorHandler( LPTTS_HANDLE_T, UINT, MMRESULT ); |
197 | 207 |
|
@@ -625,4 +635,67 @@ restart:if ( *dict_siz > 0 ) |
625 | 635 | #endif |
626 | 636 | return( MMSYSERR_NOERROR ); |
627 | 637 | } |
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