?? config.c
字號:
{
//
// Parity options and settable bits from winbase.h
//
switch (dwParity) {
case NOPARITY: if (dwSettableParity & PARITY_NONE) return TRUE; break;
case ODDPARITY: if (dwSettableParity & PARITY_ODD) return TRUE; break;
case EVENPARITY: if (dwSettableParity & PARITY_EVEN) return TRUE; break;
case MARKPARITY: if (dwSettableParity & PARITY_MARK) return TRUE; break;
case SPACEPARITY: if (dwSettableParity & PARITY_SPACE)return TRUE; break;
}
return FALSE;
} // IsValidParity
BOOL
IsValidStopBits(
DWORD dwStopBits,
DWORD dwSettableStopBits
)
{
//
// Stop bit values and settable bits from winbase.h
//
switch (dwStopBits) {
case ONESTOPBIT: if (dwSettableStopBits & STOPBITS_10) return TRUE; break;
case ONE5STOPBITS: if (dwSettableStopBits & STOPBITS_15) return TRUE; break;
case TWOSTOPBITS: if (dwSettableStopBits & STOPBITS_20) return TRUE; break;
}
return FALSE;
} // IsValidStopBits
BOOL
IsBadStringPtr(
LPCWSTR lpStr,
DWORD dwMaxLen
)
{
DWORD len;
BOOL bRet;
bRet = FALSE;
try {
len = wcslen(lpStr);
} except (EXCEPTION_EXECUTE_HANDLER) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:IsBadStringPtr: Exception!\n")));
bRet = TRUE;
}
if (bRet) {
if (len > dwMaxLen) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:IsBadStringPtr: String too long %d > %d\n"), len, dwMaxLen));
bRet = TRUE;
}
}
return bRet;
} // IsBadStringPtr
//
// Function to edit the specific property of a PDEVMINICONFIG
//
LONG
DevSpecificLineConfigEdit(
PTLINEDEV pLineDev,
PUNIMDM_CHG_DEVCFG pChg
)
{
DWORD dwSettableBaud;
DWORD dwSettableData;
DWORD dwSettableStopParity;
DWORD rc;
PDEVMINICFG pDevMiniCfg;
LPVARSTRING lpDevConfig;
LPWSTR lpszDeviceClass;
LPWSTR lpszDialModifier;
DEBUGMSG(ZONE_FUNC, (TEXT("UNIMODEM:+DevSpecificLineConfigEdit\n")));
if (IsBadReadPtr(pChg, sizeof(UNIMDM_CHG_DEVCFG))) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Invalid PUNIMDM_CHG_DEVCFG\n")));
rc = LINEERR_INVALPOINTER;
goto exitPoint;
}
lpszDeviceClass = (LPWSTR)MapPtrToProcess((LPVOID)pChg->lpszDeviceClass, GetCallerProcess());
if (!ValidateDevCfgClass(lpszDeviceClass)) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: LINEERR_INVALDEVICECLASS\n")));
rc = LINEERR_INVALDEVICECLASS;
goto exitPoint;
}
//
// Validate the buffer pointers
//
if (pChg->lpDevConfig == NULL) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: LINEERR_INVALPOINTER\n")));
rc = LINEERR_INVALPOINTER;
goto exitPoint;
}
lpDevConfig = (LPVARSTRING)MapPtrToProcess((LPVOID)pChg->lpDevConfig, GetCallerProcess());
pDevMiniCfg = (PDEVMINICFG)(((LPBYTE)lpDevConfig) + sizeof(VARSTRING));
//
// Validate the buffer size
//
if (lpDevConfig->dwTotalSize < sizeof(VARSTRING) + sizeof(DEVMINICFG)) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: LINEERR_STRUCTURETOOSMALL\n")));
lpDevConfig->dwNeededSize = sizeof(VARSTRING) + sizeof(DEVMINICFG);
rc = LINEERR_STRUCTURETOOSMALL;
goto exitPoint;
}
lpDevConfig->dwUsedSize = sizeof(VARSTRING) + sizeof(DEVMINICFG);
//
// If they specify version 0, then they want the default devconfig.
//
if (pDevMiniCfg->wVersion == 0) {
getDefaultDevConfig( pLineDev, pDevMiniCfg );
}
rc = LINEERR_INVALPARAM;
if (pLineDev->DevMiniCfg.wVersion != (pDevMiniCfg->wVersion)) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Invalid DevConfig\n")));
goto exitPoint;
}
switch (pChg->dwOption) {
case UNIMDM_OPT_BAUDRATE:
case UNIMDM_OPT_BYTESIZE:
case UNIMDM_OPT_PARITY:
case UNIMDM_OPT_STOPBITS:
dwSettableData = dwSettableStopParity = 0;
GetSettableFields(
pLineDev,
&dwSettableBaud,
(WORD *)&dwSettableData,
(WORD *)&dwSettableStopParity
);
}
switch (pChg->dwOption) {
case UNIMDM_OPT_BAUDRATE:
if (IsValidBaudRate(pChg->dwValue, dwSettableBaud)) {
pDevMiniCfg->dwBaudRate = pChg->dwValue;
} else {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Unsupported baud rate\n")));
goto exitPoint;
}
break;
case UNIMDM_OPT_BYTESIZE:
if (IsValidByteSize(pChg->dwValue, dwSettableData)) {
pDevMiniCfg->ByteSize = (BYTE)pChg->dwValue;
} else {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Unsupported byte size\n")));
goto exitPoint;
}
break;
case UNIMDM_OPT_PARITY:
if (IsValidParity(pChg->dwValue, dwSettableStopParity)) {
pDevMiniCfg->Parity = (BYTE)pChg->dwValue;
} else {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Unsupported parity\n")));
goto exitPoint;
}
break;
case UNIMDM_OPT_STOPBITS:
if (IsValidStopBits(pChg->dwValue, dwSettableStopParity)) {
pDevMiniCfg->StopBits = (BYTE)pChg->dwValue;
} else {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Unsupported stop bits\n")));
goto exitPoint;
}
break;
case UNIMDM_OPT_WAITBONG:
pDevMiniCfg->wWaitBong = (WORD)pChg->dwValue;
break;
case UNIMDM_OPT_MDMOPTIONS: // MDM_* values from mcx.h
//
// Currently CE unimodem only looks at:
// MDM_BLIND_DIAL
// MDM_FLOWCONTROL_HARD
// MDM_FLOWCONTROL_SOFT
// MDM_SPEED_ADJUST (enables DCC client automatic baud rate detection)
//
if (pChg->dwValue > (MDM_V23_OVERRIDE * 2 - 1)) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Invalid modem option\n")));
goto exitPoint;
}
pDevMiniCfg->dwModemOptions = pChg->dwValue;
break;
case UNIMDM_OPT_TIMEOUT:
pDevMiniCfg->dwCallSetupFailTimer = pChg->dwValue;
break;
case UNIMDM_OPT_TERMOPTIONS: // NETUI_LCD_TRMOPT_* values from netui.h
if (pChg->dwValue == 0) {
pDevMiniCfg->fwOptions = TERMINAL_NONE;
} else {
pDevMiniCfg->fwOptions = 0;
if (pChg->dwValue & NETUI_LCD_TRMOPT_MANUAL_DIAL) {
pDevMiniCfg->fwOptions |= MANUAL_DIAL;
}
if (pChg->dwValue & NETUI_LCD_TRMOPT_PRE_DIAL) {
pDevMiniCfg->fwOptions |= TERMINAL_PRE;
}
if (pChg->dwValue & NETUI_LCD_TRMOPT_POST_DIAL) {
pDevMiniCfg->fwOptions |= TERMINAL_POST;
}
}
break;
case UNIMDM_OPT_DIALMOD:
lpszDialModifier = (LPWSTR)MapPtrToProcess((LPVOID)pChg->dwValue, GetCallerProcess());
if (IsBadStringPtr(lpszDialModifier, DIAL_MODIFIER_LEN)) {
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Invalid dial modifier\n")));
goto exitPoint;
}
wcscpy(pDevMiniCfg->szDialModifier, lpszDialModifier);
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("UNIMODEM:DevSpecificLineConfigEdit: Invalid dwOption\n")));
goto exitPoint;
}
rc = 0;
exitPoint:
DEBUGMSG(ZONE_FUNC, (TEXT("UNIMODEM:-DevSpecificLineConfigEdit: returning 0x%x\n"), rc));
return rc;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -