List* GlobalFactory::getComponentsByType(char* type) { List* list = (List*)hashTableLookup(&typePool, hash32(type, (int)strlen(type))); if (list == NULL) { char* message = (char*)"No component typed "; message = stringInsert(message, type, (int)strlen(message)); message = stringInsert(message, "exists for now", (int)strlen(message)); throw message; } return list; }
Component* GlobalFactory::getComponentById(char* id) { Component* component = (Component*)hashTableLookup(&idPool, hash32(id, (int)strlen(id))); if (component == NULL) { char* message = (char*)"The component "; message = stringInsert(message, id, (int)strlen(message)); message = stringInsert(message, " doesn't exist", (int)strlen(message)); throw message; } return component; }
/* * Taken from CUCM/CUP code as they have done this already. */ cc_string_t CCAPI_ApplyTranslationMask (const char *ext, const char *mask) { char translationMask[100] = {'\0'}; char dn[100] = {'\0'}; char translatedString[100] = {'\0'}; cc_string_t result; unsigned int maskLen, dnLen, i, j = 0; if ((ext == NULL) || (mask == NULL)) { return NULL; } maskLen = strlen(mask); dnLen = strlen(ext); if ((dnLen == 0) || (maskLen == 0)) { CCAPP_DEBUG(DEB_F_PREFIX"CCAPI_ApplyTranslationMask DN or mask has len=0\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI_ApplyTranslationMask")); return NULL; } /* make sure there's enough space in the buffer to * hold the translated string. */ if (dnLen + maskLen > 99) { CCAPP_DEBUG(DEB_F_PREFIX"CCAPI_ApplyTranslationMask length overflow\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI_ApplyTranslationMask")); return NULL; } sstrncpy(translationMask, mask, 100); sstrncpy(dn, ext, 100); /* make sure DN is numeric only */ for (i=0; i< dnLen; i++) { if (isalpha(dn[i])) { return 0; } } if (maskLen > dnLen) { stringInsert(dn, maskLen - dnLen, '?'); } /* if the digit string is longer than the translation mask * prepad the translation mask with '%'. */ if (dnLen > maskLen) { stringInsert(translationMask, dnLen - maskLen, '%'); } dnLen = strlen(dn); for (i=0; i < dnLen; i++) { if (translationMask[i] == '%') continue; else if (translationMask[i] == 'X') translatedString[j++] = dn[i]; else translatedString[j++] = translationMask[i]; } translatedString[j] = 0; result = strlib_malloc(translatedString, strlen(translatedString)); return result; }