Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
6.2 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: phbk.h
  4. //
  5. // Module: CMPBK32.DLL
  6. //
  7. // Synopsis: Definitions for the CPhoneBook class
  8. //
  9. // Copyright (c) 1998 Microsoft Corporation
  10. //
  11. // Author: quintinb created header 08/17/99
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef _PHBK
  15. #define _PHBK
  16. #define DllExportH extern "C" HRESULT WINAPI __stdcall
  17. //#define DllExport extern "C" __stdcall __declspec(dllexport)
  18. //#define DllExport extern "C" __declspec(dllexport)
  19. #define cbAreaCode 11 // maximum number of characters in an area code, not including \0
  20. #define cbCity 31 // maximum number of chars in city name, not including \0
  21. #define cbAccessNumber 41 // maximum number of chars in phone number, not including \0
  22. #define cbStateName 31 // maximum number of chars in state name, not including \0
  23. #define cbBaudRate 6 // maximum number of chars in a baud rate, not including \0
  24. #define cbDataCenter (MAX_PATH+1) // max length of data center string
  25. // Our initial allocation of memory when loading the phone book
  26. #define PHONE_ENTRY_ALLOC_SIZE 500
  27. #define NO_AREA_CODE (-1)
  28. #define TEMP_BUFFER_LENGTH 1024
  29. typedef struct
  30. {
  31. DWORD dwIndex; // index number
  32. BYTE bFlipFactor; // for auto-pick
  33. DWORD fType; // phone number type
  34. WORD wStateID; // state ID
  35. DWORD dwCountryID; // TAPI country ID
  36. DWORD dwAreaCode; // area code or NO_AREA_CODE if none
  37. DWORD dwConnectSpeedMin; // minimum baud rate
  38. DWORD dwConnectSpeedMax; // maximum baud rate
  39. char szCity[cbCity + sizeof('\0')]; // city name
  40. char szAccessNumber[cbAccessNumber + sizeof('\0')]; // access number
  41. char szDataCenter[cbDataCenter + sizeof('\0')]; // data center access string
  42. char szAreaCode[cbAreaCode + sizeof('\0')]; //Keep the actual area code string around.
  43. } ACCESSENTRY, *PACCESSENTRY; // ae
  44. typedef struct {
  45. DWORD dwCountryID; // country ID that this state occurred in
  46. LONG_PTR iFirst; // index of first access entry for this state
  47. char szStateName[cbStateName + sizeof('\0')]; // state name
  48. } STATE, *PSTATE;
  49. typedef struct tagIDLOOKUPELEMENT {
  50. DWORD dwID;
  51. LPLINECOUNTRYENTRY pLCE;
  52. LONG_PTR iFirstAE;
  53. } IDLOOKUPELEMENT, *PIDLOOKUPELEMENT;
  54. typedef struct tagCNTRYNAMELOOKUPELEMENT {
  55. LPSTR psCountryName;
  56. DWORD dwNameSize;
  57. LPLINECOUNTRYENTRY pLCE;
  58. } CNTRYNAMELOOKUPELEMENT, *PCNTRYNAMELOOKUPELEMENT;
  59. typedef struct tagCNTRYNAMELOOKUPELEMENTW {
  60. LPWSTR psCountryName;
  61. DWORD dwNameSize;
  62. LPLINECOUNTRYENTRY pLCE;
  63. } CNTRYNAMELOOKUPELEMENTW, *PCNTRYNAMELOOKUPELEMENTW;
  64. typedef struct tagIDXLOOKUPELEMENT {
  65. DWORD dwIndex;
  66. LONG_PTR iAE;
  67. } IDXLOOKUPELEMENT,*PIDXLOOKUPELEMENT;
  68. typedef void (WINAPI *CB_PHONEBOOK)(unsigned int, DWORD_PTR);
  69. //
  70. // CPhoneBook
  71. //
  72. class CPhoneBook
  73. {
  74. public:
  75. CPhoneBook();
  76. ~CPhoneBook();
  77. HRESULT Init(LPCSTR pszISPCode);
  78. HRESULT Merge(LPCSTR pszChangeFilename);
  79. HRESULT GetCanonical(PACCESSENTRY pAE, char *psOut);
  80. HRESULT GetNonCanonical(PACCESSENTRY pAE, char *psOut);
  81. HRESULT GetCanonical(DWORD dwIdx, char *psOut) { return (GetCanonical(&m_rgPhoneBookEntry[dwIdx],psOut)); };
  82. HRESULT GetNonCanonical(DWORD dwIdx, char *psOut) { return (GetNonCanonical(&m_rgPhoneBookEntry[dwIdx],psOut)); };
  83. void EnumCountries(DWORD dwMask, DWORD fType, CB_PHONEBOOK pfnCountry, DWORD_PTR dwParam);
  84. void EnumCountries(PPBFS pFilter, CB_PHONEBOOK pfnCountry, DWORD_PTR dwParam);
  85. void EnumRegions(DWORD dwCountryID, DWORD dwMask, DWORD fType, CB_PHONEBOOK pfnCountry, DWORD_PTR dwParam);
  86. void EnumRegions(DWORD dwCountryID, PPBFS pFilter, CB_PHONEBOOK pfnCountry, DWORD_PTR dwParam);
  87. void EnumNumbersByCountry(DWORD dwCountryId, DWORD dwMask, DWORD fType, CB_PHONEBOOK pfnNumber, DWORD_PTR dwParam);
  88. void EnumNumbersByCountry(DWORD dwCountryId, PPBFS pFilter, CB_PHONEBOOK pfnNumber, DWORD_PTR dwParam);
  89. void EnumNumbersByRegion(unsigned int nRegion, DWORD dwCountryId, DWORD dwMask, DWORD fType, CB_PHONEBOOK pfnNumber, DWORD_PTR dwParam);
  90. void EnumNumbersByRegion(unsigned int nRegion, DWORD dwCountryId, PPBFS pFilter, CB_PHONEBOOK pfnNumber, DWORD_PTR dwParam);
  91. BOOL FHasPhoneType(PPBFS pFilter);
  92. BOOL FHasPhoneNumbers(DWORD dwCountryID, DWORD dwMask, DWORD fType);
  93. BOOL FHasPhoneNumbers(DWORD dwCountryID, PPBFS pFilter);
  94. LPCSTR GetCountryNameByIdx(DWORD dwIdx) { return (m_rgNameLookUp[dwIdx].psCountryName); };
  95. LPCWSTR GetCountryNameByIdxW(DWORD dwIdx) { return (((CNTRYNAMELOOKUPELEMENTW *)(&m_rgNameLookUp[dwIdx]))->psCountryName); };
  96. DWORD GetCountryIDByIdx(DWORD dwIdx) { return (m_rgNameLookUp[dwIdx].pLCE->dwCountryID); };
  97. LPCTSTR GetRegionNameByIdx(DWORD dwIdx) { return (m_rgState[dwIdx].szStateName); };
  98. LPCTSTR GetCityNameByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].szCity); };
  99. LPCTSTR GetAreaCodeByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].szAreaCode); };
  100. LPCTSTR GetAccessNumberByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].szAccessNumber); };
  101. LPCTSTR GetDataCenterByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].szDataCenter); };
  102. DWORD GetPhoneTypeByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].fType); };
  103. DWORD GetMinBaudByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].dwConnectSpeedMin); };
  104. DWORD GetMaxBaudByIdx(DWORD dwIdx) { return (m_rgPhoneBookEntry[dwIdx].dwConnectSpeedMax); };
  105. private:
  106. ACCESSENTRY *m_rgPhoneBookEntry;
  107. DWORD m_cPhoneBookEntries;
  108. LINECOUNTRYENTRY *m_rgLineCountryEntry;
  109. LINECOUNTRYLIST *m_pLineCountryList;
  110. IDLOOKUPELEMENT *m_rgIDLookUp;
  111. CNTRYNAMELOOKUPELEMENT *m_rgNameLookUp;
  112. PSTATE m_rgState;
  113. DWORD m_cStates;
  114. char m_szINFFile[MAX_PATH];
  115. char m_szPhoneBook[MAX_PATH];
  116. BOOL ReadPhoneBookDW(DWORD *pdw, CCSVFile *pcCSVFile);
  117. BOOL ReadPhoneBookW(WORD *pw, CCSVFile *pcCSVFile);
  118. BOOL ReadPhoneBookSZ(LPSTR psz, DWORD dwSize, CCSVFile *pcCSVFile);
  119. BOOL ReadPhoneBookB(BYTE *pb, CCSVFile *pcCSVFile);
  120. BOOL ReadPhoneBookNL(CCSVFile *pcCSVFile);
  121. HRESULT ReadOneLine(PACCESSENTRY pAccessEntry, CCSVFile *pcCSVFile);
  122. PACCESSENTRY IdxToPAE(LONG_PTR iIdx) { return ((iIdx==0)?NULL:(m_rgPhoneBookEntry+(iIdx-1))); };
  123. LONG_PTR PAEToIdx(PACCESSENTRY pAE) { return ((pAE==NULL)?0:((pAE-m_rgPhoneBookEntry)+1)); };
  124. };
  125. extern HINSTANCE g_hInst; // instance for this DLL
  126. #endif // _PHBK