#define STRICT #include #include #include "location.h" #if DBG #define DBGOUT(arg) DbgPrt arg void DbgPrt( DWORD dwDbgLevel, PSTR DbgMessage, ... ); #else #define DBGOUT(_x_) #endif const TCHAR gszName[] = "Name"; const TCHAR gszID[] = "ID"; const TCHAR gszAreaCode[] = "AreaCode"; const TCHAR gszCountry[] = "Country"; const TCHAR gszOutsideAccess[] = "OutsideAccess"; const TCHAR gszLongDistanceAccess[] = "LongDistanceAccess"; const TCHAR gszFlags[] = "Flags"; const TCHAR gszCallingCard[] = "CallingCard"; const TCHAR gszDisableCallWaiting[] = "DisableCallWaiting"; const TCHAR gszTollList[] = "TollList"; //const TCHAR gszNumLocations[] = "NumLocations"; //const TCHAR gszCurrLocation[] = "CurrLocation"; //const TCHAR gszNextLocationID[] = "NextLocationID"; const TCHAR gszCard[] = "Card"; const TCHAR gszPin[] = "Pin"; const TCHAR gszCards[] = "Cards"; //const TCHAR gszNumCards[] = "NumCards"; //const TCHAR gszCurrCard[] = "CurrCard"; const TCHAR gszLocalRule[] = "LocalRule"; const TCHAR gszLDRule[] = "LDRule"; const TCHAR gszInternationalRule[] = "InternationalRule"; const TCHAR gszNumEntries[] = "NumEntries"; const TCHAR gszCurrentID[] = "CurrentID"; const TCHAR gszNextID[] = "NextID"; const TCHAR gszEmpty[] = ""; const TCHAR gszLocations[] = "Locations"; const TCHAR gszLocation[] = "Location"; const TCHAR gszCurrentLocation[] = "CurrentLocation"; const TCHAR gszHandoffPriorities[] = "HandoffPriorities"; const TCHAR gszProviders[] = "Providers"; const TCHAR gszProvider[] = "Provider%d"; const TCHAR gszTelephonIni[] = "Telephon.ini"; const TCHAR gszTelephony[] = "Software\\Microsoft\\Windows\\" "CurrentVersion\\Telephony"; const CHAR *gaszMediaModes[] = { "", "unknown", "interactivevoice", "automatedvoice", "datamodem", "g3fax", "tdd", "g4fax", "digitaldata", "teletex", "videotex", "telex", "mixed", "adsi", "voiceview", NULL }; const CHAR *gszRequestMakeCallW = "RequestMakeCall"; const CHAR *gszRequestMediaCallW = "RequestMediaCall"; const CHAR *gszRegKeyHandoffPriorities = "Software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\HandoffPriorities"; const CHAR *gszRegKeyHandoffPrioritiesMediaModes = "MediaModes"; void FixPriorityList(HKEY hKeyHandoffPriorities, LPCSTR pszListName); void FixMediaModesPriorityLists(); #pragma check_stack ( off ) //*************************************************************************** //*************************************************************************** //*************************************************************************** BOOL ParseSomething( LPCSTR pFormat, LPCSTR pInputString, LPVOID pOutputPtr ) { BYTE c; LPBYTE pOutput = (LPBYTE)pOutputPtr; LPBYTE pInput = (LPBYTE)pInputString; while ( (c = *pFormat) && *pInput ) { #if DBG DBGOUT((11, "Inputstring[%s]\r\n Format[%s]\r\n", pInput, pFormat)); #endif switch ( c ) { case 'n': { DWORD dwValue = 0; BYTE bDigit; // // Parse value from the string // while ( ((bDigit = *pInput) != '\0') && bDigit != ',' ) { dwValue = (dwValue * 10) + ( bDigit - '0' ); #if DBG DBGOUT((11, "val of bDigit=%d dwValue=%ld\r\n", (int)bDigit, dwValue)); #endif bDigit = *(++pInput); } *(LPDWORD)pOutput = dwValue; pOutput += sizeof(DWORD); } break; case 's': { // // If the caller is looking for a string, the first char // MUST be a quotes. So, just step past it. // pInput++; // // Ok, _now_ we're into the meat of the string (if there _is_ // any...) // while ( *pInput != '\0' && *pInput != '"' ) { *pOutput = *pInput; pOutput++; pInput++; } // // Don't forget to put a cap on that thing. // *pOutput = '\0'; pOutput++; // The input should now be at a ->"<- if it's not, the ini // file was hosed, and I'm not fixing it. // So, we step past it, and we're done // if ( *pInput == '"' ) { pInput++; } } break; } // // Step past the comma... // // if ( *pInput == ',' ) { pInput++; } pFormat++; } return TRUE; } //*************************************************************************** //*************************************************************************** //*************************************************************************** //VOID __cdecl main( void ) void __cdecl main( void ) { DWORD dw; DWORD dwNumEntries; DWORD dwCurrentID; DWORD dwNextID; DWORD dwSize; DWORD dwType; DWORD dwValue; DWORD dwArray[10]; BYTE *bBigArray; BYTE *Buffer; LPBYTE pSource; HKEY hKey3; HKEY hKey2; HKEY hKey; DWORD dwDisposition; #define BUFFER_SIZE (5120) bBigArray = LocalAlloc( LPTR, BUFFER_SIZE ); if ( !bBigArray ) { return; } Buffer = LocalAlloc( LPTR, BUFFER_SIZE ); //Might needs tons of room for tolllist if ( !Buffer ) { return; } dw = GetPrivateProfileString( gszCards, gszCards, gszEmpty, Buffer, BUFFER_SIZE, gszTelephonIni ); // // Is there an existing AND valid TELEPHON.INI file? // There would HAVE TO be at least one card. The SYSTEM cards cannot // be deleted, only hidden. // if ( 0 != dw ) { //[Cards] //Cards=23,23 //Card0=0,"None (Direct Dial)","","","","",1 //Card1=1,"AT&T Direct Dial via 10ATT1","","G","102881FG","10288011EFG",1 #define CARD_INI_ID (0) #define CARD_INI_NAME (1) #define CARD_INI_SNUMBER (2) #define CARD_INI_SARULE (3) #define CARD_INI_LDRULE (4) #define CARD_INI_INTNLRULE (5) #define CARD_INI_HIDDEN (6) #define PC_INI_ID (0) #define PC_INI_NEXTID (1) #define PC_INI_NAME (2) #define PC_INI_SARULE (3) #define PC_INI_LDRULE (4) #define PC_INI_INTNLRULE (5) // // Move CARDS entries to registry // ParseSomething( "nn", Buffer, &dwArray); dwNumEntries = dwArray[0]; dwNextID = dwArray[1]; RegCreateKeyEx( HKEY_CURRENT_USER, gszTelephony, 0, "", //Class? What class? REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey3, &dwDisposition ); RegCreateKeyEx( hKey3, gszCards, 0, "", //Class? What class? REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey2, &dwDisposition ); // // Don't wipe out an existing card section // dwSize = sizeof(dwValue); dw = RegQueryValueEx( hKey2, gszNumEntries, 0, &dwType, (LPBYTE)&dwValue, &dwSize ); if ( 0 != dw ) { RegSetValueEx( hKey2, gszNumEntries, 0, REG_DWORD, (LPBYTE)&dwNumEntries, sizeof(DWORD) ); RegSetValueEx( hKey2, gszNextID, 0, REG_DWORD, (LPBYTE)&dwNextID, sizeof(DWORD) ); for ( dw=0; dw