Lines Matching refs:this
88 picoos_int16 picoctrl_isValidResourceHandle(picorsrc_Resource this) in picoctrl_isValidResourceHandle() argument
90 return (this != NULL) && CHECK_MAGIC_NUMBER(this); in picoctrl_isValidResourceHandle()
96 picorsrc_Resource this = picoos_allocate(mm, sizeof(*this)); in picorsrc_newResource() local
97 if (NULL != this) { in picorsrc_newResource()
98 SET_MAGIC_NUMBER(this); in picorsrc_newResource()
100 this->name[0] = NULLC; in picorsrc_newResource()
102 this->next = NULL; in picorsrc_newResource()
103 this->type = PICORSRC_TYPE_NULL; in picorsrc_newResource()
104 this->lockCount = 0; in picorsrc_newResource()
105 this->file = NULL; in picorsrc_newResource()
106 this->raw_mem = NULL; in picorsrc_newResource()
107 this->start = NULL; in picorsrc_newResource()
108 this->kbList = NULL; in picorsrc_newResource()
111 return this; in picorsrc_newResource()
114 static void picorsrc_disposeResource(picoos_MemoryManager mm, picorsrc_Resource * this) in picorsrc_disposeResource() argument
116 if (NULL != (*this)) { in picorsrc_disposeResource()
117 (*this)->magic ^= 0xFFFEFDFC; in picorsrc_disposeResource()
121 if ((*this)->raw_mem != NULL) { in picorsrc_disposeResource()
122 picoos_deallocProtMem(mm, (void *) &(*this)->raw_mem); in picorsrc_disposeResource()
124 picoos_deallocate(mm,(void * *)this); in picorsrc_disposeResource()
131 static void picorsrc_initializeVoice(picorsrc_Voice this) in picorsrc_initializeVoice() argument
134 if (NULL != this) { in picorsrc_initializeVoice()
137 this->kbArray[i] = NULL; in picorsrc_initializeVoice()
139 this->numResources = 0; in picorsrc_initializeVoice()
140 this->next = NULL; in picorsrc_initializeVoice()
146 picorsrc_Voice this = (picorsrc_Voice) picoos_allocate(mm,sizeof(*this)); in picorsrc_newVoice() local
147 picorsrc_initializeVoice(this); in picorsrc_newVoice()
148 return this; in picorsrc_newVoice()
180 picorsrc_VoiceDefinition this = (picorsrc_VoiceDefinition) picoos_allocate(mm,sizeof(*this)); in picorsrc_newVoiceDefinition() local
181 if (NULL != this) { in picorsrc_newVoiceDefinition()
183 this->voiceName[0] = NULLC; in picorsrc_newVoiceDefinition()
184 this->numResources = 0; in picorsrc_newVoiceDefinition()
190 this->next = NULL; in picorsrc_newVoiceDefinition()
192 return this; in picorsrc_newVoiceDefinition()
224 pico_status_t picorsrc_createDefaultResource(picorsrc_ResourceManager this /*,
230 picorsrc_ResourceManager this = picoos_allocate(mm,sizeof(*this)); in picorsrc_newResourceManager() local
231 if (NULL != this) { in picorsrc_newResourceManager()
233 this->common = common; in picorsrc_newResourceManager()
234 this->numResources = 0; in picorsrc_newResourceManager()
235 this->resources = NULL; in picorsrc_newResourceManager()
236 this->freeResources = NULL; in picorsrc_newResourceManager()
237 this->numVoices = 0; in picorsrc_newResourceManager()
238 this->voices = NULL; in picorsrc_newResourceManager()
239 this->freeVoices = NULL; in picorsrc_newResourceManager()
240 this->numVdefs = 0; in picorsrc_newResourceManager()
241 this->vdefs = NULL; in picorsrc_newResourceManager()
242 this->freeVdefs = NULL; in picorsrc_newResourceManager()
244 return this; in picorsrc_newResourceManager()
247 void picorsrc_disposeResourceManager(picoos_MemoryManager mm, picorsrc_ResourceManager * this) in picorsrc_disposeResourceManager() argument
249 if (NULL != (*this)) { in picorsrc_disposeResourceManager()
251 picoos_deallocate(mm,(void *)this); in picorsrc_disposeResourceManager()
259 static pico_status_t findResource(picorsrc_ResourceManager this, picoos_char * resourceName, picors… in findResource() argument
261 if (NULL == this) { in findResource()
264 r = this->resources; in findResource()
272 static picoos_uint8 isResourceLoaded(picorsrc_ResourceManager this, picoos_char * resourceName) { in isResourceLoaded() argument
275 if (PICO_OK == findResource(this, resourceName,&res)){ in isResourceLoaded()
295 static pico_status_t readHeader(picorsrc_ResourceManager this, in readHeader() argument
309 …return picoos_emRaiseException(this->common->em,status,NULL,(picoos_char *)"problem reading file h… in readHeader()
320 if (picoos_ReadBytes(file, (picoos_uint8 *) this->tmpHeader, &n) && hdrlen1 == n) { in readHeader()
321 this->tmpHeader[hdrlen1] = NULLC; in readHeader()
323 PICODBG_DEBUG(("got header <%s>",this->tmpHeader)); in readHeader()
331 status = picoos_hdrParseHeader(header, this->tmpHeader); in readHeader()
338 picorsrc_ResourceManager this, in picorsrc_createKnowledgeBase() argument
344 (*kb) = picoknow_newKnowledgeBase(this->common->mm); in picorsrc_createKnowledgeBase()
355 return picokpr_specializePreprocKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
358 return picoktab_specializeGraphsKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
361 return picoktab_specializePhonesKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
364 return picoktab_specializePosKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
367 return picoktab_specializeIdsKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
372 return picoklex_specializeLexKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
375 return picokdt_specializeDtKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
379 return picokdt_specializeDtKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
383 return picokdt_specializeDtKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
387 return picokdt_specializeDtKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
391 return picokdt_specializeDtKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
413 return picokfst_specializeFSTKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
427 return picokdt_specializeDtKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
431 return picokpdf_specializePdfKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
436 return picokpdf_specializePdfKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
440 return picokpdf_specializePdfKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
444 return picokpdf_specializePdfKnowledgeBase(*kb, this->common, in picorsrc_createKnowledgeBase()
452 return picokdbg_specializeDbgKnowledgeBase(*kb, this->common); in picorsrc_createKnowledgeBase()
464 picorsrc_ResourceManager this, in picorsrc_releaseKnowledgeBase() argument
471 static pico_status_t picorsrc_getKbList(picorsrc_ResourceManager this, in picorsrc_getKbList() argument
511 … status = picorsrc_createKnowledgeBase(this, NULL, size, (picoknow_kb_id_t)kbid, &kb); in picorsrc_getKbList()
513 … status = picorsrc_createKnowledgeBase(this, data+offset, size, (picoknow_kb_id_t)kbid, &kb); in picorsrc_getKbList()
525 picorsrc_releaseKnowledgeBase(this,&kb); in picorsrc_getKbList()
536 pico_status_t picorsrc_loadResource(picorsrc_ResourceManager this, in picorsrc_loadResource() argument
551 res = picorsrc_newResource(this->common->mm); in picorsrc_loadResource()
554 return picoos_emRaiseException(this->common->em,PICO_EXC_OUT_OF_MEM,NULL,NULL); in picorsrc_loadResource()
557 if (PICO_MAX_NUM_RESOURCES <= this->numResources) { in picorsrc_loadResource()
558 picoos_deallocate(this->common->mm, (void *) &res); in picorsrc_loadResource()
559 …return picoos_emRaiseException(this->common->em,PICO_EXC_MAX_NUM_EXCEED,NULL,(picoos_char *)"no mo… in picorsrc_loadResource()
565 picoos_deallocate(this->common->mm, (void *) &res); in picorsrc_loadResource()
573 if (!picoos_OpenBinary(this->common, &res->file, fileName)) { in picorsrc_loadResource()
577 picoos_emRaiseException(this->common->em, PICO_EXC_CANT_OPEN_FILE, in picorsrc_loadResource()
581 status = readHeader(this, &header, &headerlen, res->file); in picorsrc_loadResource()
586 if (PICO_OK == status && isResourceLoaded(this, header.field[PICOOS_HEADER_NAME].value)) { in picorsrc_loadResource()
589 …picoos_emRaiseWarning(this->common->em,PICO_WARN_RESOURCE_DOUBLE_LOAD,NULL,(picoos_char *)"%s",hea… in picorsrc_loadResource()
601 res->raw_mem = picoos_allocProtMem(this->common->mm, maxlen); in picorsrc_loadResource()
618 picoos_protectMem(this->common->mm, res->start, len, /*enable*/TRUE); in picorsrc_loadResource()
629 picoos_emRaiseException(this->common->em, in picorsrc_loadResource()
652 status = picorsrc_getKbList(this, res->start, len, &res->kbList); in picorsrc_loadResource()
658 res->next = this->resources; in picorsrc_loadResource()
659 this->resources = res; in picorsrc_loadResource()
660 this->numResources++; in picorsrc_loadResource()
664 picorsrc_disposeResource(this->common->mm, &res); in picorsrc_loadResource()
675 static pico_status_t picorsrc_releaseKbList(picorsrc_ResourceManager this, picoknow_KnowledgeBase *… in picorsrc_releaseKbList() argument
682 picoknow_disposeKnowledgeBase(this->common->mm,&kbprev); in picorsrc_releaseKbList()
689 pico_status_t picorsrc_unloadResource(picorsrc_ResourceManager this, picorsrc_Resource * resource) { in picorsrc_unloadResource() argument
704 picoos_CloseBinary(this->common, &rsrc->file); in picorsrc_unloadResource()
707 picoos_deallocProtMem(this->common->mm, (void *) &rsrc->raw_mem); in picorsrc_unloadResource()
712 r2 = this->resources; in picorsrc_unloadResource()
718 this->resources = rsrc->next; in picorsrc_unloadResource()
727 picorsrc_releaseKbList(this, &rsrc->kbList); in picorsrc_unloadResource()
730 picoos_deallocate(this->common->mm,(void **)resource); in picorsrc_unloadResource()
731 this->numResources--; in picorsrc_unloadResource()
737 pico_status_t picorsrc_createDefaultResource(picorsrc_ResourceManager this in picorsrc_createDefaultResource() argument
746 if (PICO_MAX_NUM_RESOURCES <= this->numResources) { in picorsrc_createDefaultResource()
747 …return picoos_emRaiseException(this->common->em,PICO_EXC_MAX_NUM_EXCEED,NULL,(picoos_char *)"no mo… in picorsrc_createDefaultResource()
750 res = picorsrc_newResource(this->common->mm); in picorsrc_createDefaultResource()
753 return picoos_emRaiseException(this->common->em,PICO_EXC_OUT_OF_MEM,NULL,NULL); in picorsrc_createDefaultResource()
763 …status = picorsrc_createKnowledgeBase(this, NULL, 0, (picoknow_kb_id_t)PICOKNOW_KBID_FIXED_IDS, &r… in picorsrc_createDefaultResource()
766 res->next = this->resources; in picorsrc_createDefaultResource()
767 this->resources = res; in picorsrc_createDefaultResource()
768 this->numResources++; in picorsrc_createDefaultResource()
778 pico_status_t picorsrc_rsrcGetName(picorsrc_Resource this, in picorsrc_rsrcGetName() argument
780 if (!picoctrl_isValidResourceHandle(this)) { in picorsrc_rsrcGetName()
783 picoos_strlcpy(name, this->name,maxlen); in picorsrc_rsrcGetName()
791 static pico_status_t findVoiceDefinition(picorsrc_ResourceManager this, in findVoiceDefinition() argument
796 if (NULL == this) { in findVoiceDefinition()
799 v = this->vdefs; in findVoiceDefinition()
814 pico_status_t picorsrc_addResourceToVoiceDefinition(picorsrc_ResourceManager this, in picorsrc_addResourceToVoiceDefinition() argument
819 if (NULL == this) { in picorsrc_addResourceToVoiceDefinition()
823 if ((PICO_OK == findVoiceDefinition(this,voiceName,&vdef)) && (NULL != vdef)) { in picorsrc_addResourceToVoiceDefinition()
825 …return picoos_emRaiseException(this->common->em,PICO_EXC_MAX_NUM_EXCEED,NULL,(picoos_char *)"no mo… in picorsrc_addResourceToVoiceDefinition()
833 …return picoos_emRaiseException(this->common->em,PICO_EXC_NAME_ILLEGAL,NULL,(picoos_char *)"%s",res… in picorsrc_addResourceToVoiceDefinition()
837 …return picoos_emRaiseException(this->common->em,PICO_EXC_NAME_UNDEFINED,NULL,(picoos_char *)"%s",v… in picorsrc_addResourceToVoiceDefinition()
842 pico_status_t picorsrc_createVoiceDefinition(picorsrc_ResourceManager this, in picorsrc_createVoiceDefinition() argument
847 if (NULL == this) { in picorsrc_createVoiceDefinition()
851 if ((PICO_OK == findVoiceDefinition(this,voiceName,&vdef)) && (NULL != vdef)) { in picorsrc_createVoiceDefinition()
853 return picoos_emRaiseException(this->common->em,PICO_EXC_NAME_CONFLICT,NULL,NULL); in picorsrc_createVoiceDefinition()
855 if (PICO_MAX_NUM_VOICE_DEFINITIONS <= this->numVdefs) { in picorsrc_createVoiceDefinition()
856 PICODBG_ERROR(("max number of vdefs exceeded (%i)",this->numVdefs)); in picorsrc_createVoiceDefinition()
857 …return picoos_emRaiseException(this->common->em,PICO_EXC_MAX_NUM_EXCEED,NULL,(picoos_char *)"no mo… in picorsrc_createVoiceDefinition()
859 if (NULL == this->freeVdefs) { in picorsrc_createVoiceDefinition()
860 vdef = picorsrc_newVoiceDefinition(this->common->mm); in picorsrc_createVoiceDefinition()
862 vdef = this->freeVdefs; in picorsrc_createVoiceDefinition()
863 this->freeVdefs = vdef->next; in picorsrc_createVoiceDefinition()
869 return picoos_emRaiseException(this->common->em,PICO_EXC_OUT_OF_MEM,NULL,NULL); in picorsrc_createVoiceDefinition()
873 vdef->next = this->vdefs; in picorsrc_createVoiceDefinition()
874 this->vdefs = vdef; in picorsrc_createVoiceDefinition()
875 this->numVdefs++; in picorsrc_createVoiceDefinition()
876 …if (PICO_OK != picorsrc_addResourceToVoiceDefinition(this,voiceName,PICOKNOW_DEFAULT_RESOURCE_NAME… in picorsrc_createVoiceDefinition()
877 …return picoos_emRaiseException(this->common->em,PICO_ERR_OTHER,NULL,(picoos_char *)"problem loadin… in picorsrc_createVoiceDefinition()
883 …return picoos_emRaiseException(this->common->em,PICO_EXC_NAME_ILLEGAL,NULL,(picoos_char *)"%s",voi… in picorsrc_createVoiceDefinition()
888 pico_status_t picorsrc_releaseVoiceDefinition(picorsrc_ResourceManager this, in picorsrc_releaseVoiceDefinition() argument
893 if (this == NULL) { in picorsrc_releaseVoiceDefinition()
898 v = this->vdefs; in picorsrc_releaseVoiceDefinition()
908 this->vdefs = v->next; in picorsrc_releaseVoiceDefinition()
911 v->next = this->freeVdefs; in picorsrc_releaseVoiceDefinition()
912 this->freeVdefs = v; in picorsrc_releaseVoiceDefinition()
913 this->numVdefs--; in picorsrc_releaseVoiceDefinition()
929 pico_status_t picorsrc_createVoice(picorsrc_ResourceManager this, const picoos_char * voiceName, pi… in picorsrc_createVoice() argument
939 if (NULL == this) { in picorsrc_createVoice()
945 if (PICORSRC_MAX_NUM_VOICES <= this->numVoices) { in picorsrc_createVoice()
947 …return picoos_emRaiseException(this->common->em,PICO_EXC_MAX_NUM_EXCEED,NULL,(picoos_char *)"no mo… in picorsrc_createVoice()
951 if (!(PICO_OK == findVoiceDefinition(this,voiceName,&vdef)) || (NULL == vdef)) { in picorsrc_createVoice()
953 …return picoos_emRaiseException(this->common->em,PICO_EXC_NAME_UNDEFINED,NULL,(picoos_char *)"voice… in picorsrc_createVoice()
961 if (required && !isResourceLoaded(this,vdef->resourceName[i])) { in picorsrc_createVoice()
963 …return picoos_emRaiseException(this->common->em,PICO_EXC_RESOURCE_MISSING,NULL,(picoos_char *)"res… in picorsrc_createVoice()
968 if (NULL == this->freeVoices) { in picorsrc_createVoice()
969 *voice = picorsrc_newVoice(this->common->mm); in picorsrc_createVoice()
971 *voice = this->freeVoices; in picorsrc_createVoice()
972 this->freeVoices = (*voice)->next; in picorsrc_createVoice()
976 return picoos_emRaiseException(this->common->em, PICO_EXC_OUT_OF_MEM, NULL, NULL); in picorsrc_createVoice()
978 this->numVoices++; in picorsrc_createVoice()
984 findResource(this,vdef->resourceName[i],&rsrc); in picorsrc_createVoice()
990 … picoos_emRaiseWarning(this->common->em,PICO_WARN_KB_OVERWRITE,NULL, (picoos_char *)"%i", kb->id); in picorsrc_createVoice()
1007 pico_status_t picorsrc_releaseVoice(picorsrc_ResourceManager this, picorsrc_Voice * voice) in picorsrc_releaseVoice() argument
1011 if (NULL == this || NULL == v) { in picorsrc_releaseVoice()
1017 v->next = this->freeVoices; in picorsrc_releaseVoice()
1018 this->freeVoices = v; in picorsrc_releaseVoice()
1019 this->numVoices--; in picorsrc_releaseVoice()