📄 settings.c
字号:
char *tempValue = NULL; XPTDEBUG((" getCapParms(%s)\n", szSettings)); parms = (awsp_Capabilities *) xppMalloc(sizeof(awsp_Capabilities)); /** * Initialize default values to take for missing Capabilities parameters. **/ if (parms == NULL) return NULL; xppMemset(parms, 0, sizeof(awsp_Capabilities)); /** * How to deal with retrieving the data for an array of values? The * settingsGetParm method assumes only one of each value. Also, it * is blank-delimitted, so any MSISDN numbers with embedded blanks need * to be quoted, and I need to strip the quotes... * * Not sure if/how awsp_Capabilities object can be constructed if the * number of elements in the array is not defined... **/ tempValue = getMetaInfoValue(szSettings, "capAlias"); if (tempValue != NULL) { parms->aliases = (char **) xppMalloc(10 * sizeof(char *)); parms->aliases[0] = tempValue; parms->aliasesSz = 1; hasCapSettings = AWSP_TRUE; } tempValue = getMetaInfoValue(szSettings, "capClientSDUSize"); if (tempValue != NULL) { parms->clientSDUsz = atoi(tempValue); hasCapSettings = AWSP_TRUE; } xppFree(tempValue); tempValue = getMetaInfoValue(szSettings, "capExtendedMethod"); if (tempValue != NULL) { parms->extendedMethods = (char **) xppMalloc(10 * sizeof(char *)); parms->extendedMethods[0] = tempValue; parms->extendedMethodsSz = 1; hasCapSettings = AWSP_TRUE; } tempValue = getMetaInfoValue(szSettings, "capHeaderCodePages"); if (tempValue != NULL) { parms->headerCodePages = (char **) xppMalloc(10 * sizeof(char *)); parms->headerCodePages[0] = tempValue; parms->headerCodePagesSz = 1; hasCapSettings = AWSP_TRUE; } tempValue = getMetaInfoValue(szSettings, "capMaxOutstandReq"); if (tempValue != NULL) { parms->maxOutstandingMethodRequests = atoi(tempValue); hasCapSettings = AWSP_TRUE; } xppFree(tempValue); tempValue = getMetaInfoValue(szSettings, "capMaxOutstPush"); if (tempValue != NULL) { parms->maxOutstandingPushRequests = atoi(tempValue); hasCapSettings = AWSP_TRUE; } xppFree(tempValue); tempValue = getMetaInfoValue(szSettings, "capProtocolOption"); if (tempValue != NULL) { parms->protocolOptions = (char **) xppMalloc(10 * sizeof(char *)); parms->protocolOptions[0] = tempValue; parms->protocolOptionsSz = 1; hasCapSettings = AWSP_TRUE; } tempValue = getMetaInfoValue(szSettings, "capServerSDUSize"); if (tempValue != NULL) { parms->serverSDUsz = atoi(tempValue); hasCapSettings = AWSP_TRUE; } xppFree(tempValue); if (hasCapSettings == AWSP_FALSE) { xppFree(parms); parms = NULL; } return parms;} /* End of getCapParms() *//** * releaseCapParms * - xppFrees the storage associate with the input awsp_Capabilities structure. * - nullifies the input pointer to the structure. * * IN: capParms Address of the pointer to the awsp_Capabilities structure * **/void releaseCapParms(awsp_Capabilities *capParms) { XPTDEBUG((" releaseCapParms(%lx)\n", (unsigned long) capParms)); if (capParms == NULL) return; /* Need to xppFree all elements of the arrays... */ if (!xppStrcmp(capParms->aliases[0], "")) { xppFree(capParms->aliases[0]); /* xppFree elements of array */ xppFree(capParms->aliases); /* xppFree array itself */ } if (!xppStrcmp(capParms->extendedMethods[0], "")) { xppFree(capParms->extendedMethods[0]); /* xppFree elements of array */ xppFree(capParms->extendedMethods); /* xppFree array itself */ } if (!xppStrcmp(capParms->headerCodePages[0], "")) { xppFree(capParms->headerCodePages[0]); /* xppFree elements of array */ xppFree(capParms->headerCodePages); /* xppFree array itself */ } if (!xppStrcmp(capParms->protocolOptions[0], "")) { xppFree(capParms->protocolOptions[0]); /* xppFree elements of array */ xppFree(capParms->protocolOptions); /* xppFree array itself */ } xppFree(capParms);} /* End of releaseCAPParms() */const char *getBearerString(awsp_BEARER_TYPE type) { const char *retValue = "DEFAULT"; switch(type) { case AWSP_USSD: retValue = "USSD"; break; case AWSP_CSD: retValue = "CSD"; break; case AWSP_CDPD: retValue = "CDPD"; break; case AWSP_SMS: retValue = "SMS"; break; case AWSP_PACKET: retValue = "PACKET"; break; case AWSP_FLEX_REFLEX: retValue = "FLEX, REFLEX"; break; case AWSP_GUTS_RDATA: retValue = "GUTS RDATA"; break; case AWSP_GPRS: retValue = "GPRS"; break; case AWSP_SDS: retValue = "SDS"; break; default: break; } /* End bearer switch */ return retValue;} /* End getBearerString() */const char *getAddressString(awsp_ADDRESS_TYPE type) { const char *retValue = "DEFAULT"; switch(type) { case AWSP_IPV4: retValue = "IP Version 4"; break; case AWSP_IPV6: retValue = "IP Version 6"; break; case AWSP_GSM_MSISDN: retValue = "GSM SMS"; break; case AWSP_IS_136_MSISDN: retValue = "IS-136"; break; case AWSP_IS_637_MSISDN: retValue = "IS-637"; break; case AWSP_IDEN_MSISDN: retValue = "iDen SMS"; break; case AWSP_FLEX_MSISDN: retValue = "FLEX"; break; case AWSP_PHS_MSISDN: retValue = "PHS"; break; case AWSP_GSM_SERVICE_CODE: retValue = "GSM USSD"; break; case AWSP_TETRA_ITSI: retValue = "TETRA SDS ITSI"; break; case AWSP_TETRA_MSISDN: retValue = "TETRA SDS MSISDN"; break; default: break; } /* End address switch */ return retValue;} /* End getAddressString() */#ifdef WSP_DEBUGvoid dumpSettings(WspSettings_t *settings) { if (settings == NULL) return; XPTDEBUG((" Meta Data Settings: \n")); XPTDEBUG((" createSession: %s\n", (settings->createSession) ? "true":"false")); XPTDEBUG((" host : %s\n", settings->host)); dumpSap(settings->servAccessPtParms); dumpCapabilities(settings->requestedCapabilities);} /* End dumpSettings() */void dumpCapabilities(awsp_Capabilities *capabilities) { if (capabilities == NULL) return; XPTDEBUG((" Requested Capabilities: \n")); XPTDEBUG((" Aliases :\n")); dumpCharArray(capabilities->aliases, capabilities->aliasesSz); XPTDEBUG((" Client SDU size : %u\n", capabilities->clientSDUsz)); XPTDEBUG((" Extended Methods :\n")); dumpCharArray(capabilities->extendedMethods, capabilities->extendedMethodsSz); XPTDEBUG((" Header Code Pages :\n")); dumpCharArray(capabilities->headerCodePages, capabilities->headerCodePagesSz); XPTDEBUG((" Protocol Options :\n")); dumpCharArray(capabilities->protocolOptions, capabilities->protocolOptionsSz); XPTDEBUG((" Server SDU size : %u\n", capabilities->serverSDUsz)); XPTDEBUG((" Max Outstanding Method Requests : %u\n", capabilities->maxOutstandingMethodRequests)); XPTDEBUG((" Max Outstanding Push Requests : %u\n", capabilities->maxOutstandingPushRequests));} /* End dumpCapabilities() */void dumpSap(SapParameters *sap) { if (sap == NULL) return; XPTDEBUG((" Service Access Point Parameters: \n")); XPTDEBUG((" Bearer Type : %s\n", getBearerString(sap->bearerType))); XPTDEBUG((" Address Type : %s\n", getAddressString(sap->addressType))); XPTDEBUG((" Server Address : %s\n", sap->serverAddress)); XPTDEBUG((" Server Port : %hu\n", sap->serverPort)); XPTDEBUG((" Client Address : %s\n", sap->clientAddress)); XPTDEBUG((" Client Port : %hu\n", sap->clientPort));} /* End dumpSap() */void dumpCharArray(char **arrayPtr, int arraySize) { int i = 0; for (; i < arraySize; i++) { if (i > 0) XPTDEBUG((", ")); XPTDEBUG(("%s", *(arrayPtr + i))); } /* End for */ XPTDEBUG(("\n"));} /* End dumpCharArray() */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -