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.

140 lines
2.3 KiB

  1. /* ----------------------------------------------------------------------
  2. Copyright (c) 1996, Microsoft Corporation
  3. All rights reserved
  4. stiderc.c
  5. ---------------------------------------------------------------------- */
  6. #include "precomp.h"
  7. #include "global.h"
  8. #include "dirlist.h"
  9. UINT gfOprahMode = 0;
  10. VOID static _GetPsz(LPTSTR * ppsz, PTCHAR pszDest)
  11. {
  12. PTCHAR pch = *ppsz;
  13. while (_T('\0') != *pch)
  14. {
  15. *pszDest++ = (*pch++)-1;
  16. }
  17. *pszDest = _T('\0');
  18. *ppsz = pch+1;
  19. }
  20. PTCHAR static _NextWord(PTCHAR pch)
  21. {
  22. pch = (PTCHAR) _StrChr(pch, _T(','));
  23. if (NULL != pch)
  24. {
  25. *pch = _T('\0');
  26. pch++;
  27. }
  28. return pch;
  29. }
  30. HRESULT OprahDirectory(CDirListView* pdlv)
  31. {
  32. HRSRC hRes;
  33. PVOID pData;
  34. LPTSTR psz;
  35. PTCHAR pch;
  36. TCHAR szEmail[32];
  37. TCHAR szCity[32];
  38. TCHAR szCountry[128];
  39. TCHAR rgsz[4][32];
  40. if (NULL == (hRes = FindResource(GetInstanceHandle(), MAKEINTRESOURCE(IDC_STIDERC), "CDAT")) ||
  41. (NULL == (psz = (LPTSTR) LockResource(LoadResource(GetInstanceHandle(), hRes))) ) )
  42. {
  43. return E_FAIL;
  44. }
  45. _GetPsz(&psz, szEmail);
  46. _GetPsz(&psz, szCity);
  47. _GetPsz(&psz, rgsz[0]);
  48. _GetPsz(&psz, rgsz[1]);
  49. _GetPsz(&psz, rgsz[2]);
  50. _GetPsz(&psz, rgsz[3]);
  51. for ( ; ; )
  52. {
  53. TCHAR szRow[MAX_PATH];
  54. UINT bFlags;
  55. LPTSTR pszFirst;
  56. LPTSTR pszLast;
  57. LPTSTR pszComments;
  58. LPTSTR pszCity;
  59. LPTSTR pszCountry;
  60. _GetPsz(&psz, szRow);
  61. if (FEmptySz(szRow))
  62. break;
  63. pch = szRow;
  64. bFlags = (*pch) - _T('\0');
  65. pch++;
  66. pszFirst = pch;
  67. pch = _NextWord(pch);
  68. pszLast = pch;
  69. pch = _NextWord(pch);
  70. pszComments = pch;
  71. pch++;
  72. switch (*pch)
  73. {
  74. case _T(','):
  75. pch++;
  76. case _T('\0'):
  77. pszComments = rgsz[*pszComments-_T('1')];
  78. break;
  79. default:
  80. pch = _NextWord(pch);
  81. break;
  82. }
  83. if (FEmptySz(pch))
  84. {
  85. pszCity = szCity;
  86. pszCountry = TEXT("US");
  87. }
  88. else
  89. {
  90. pszCity = pch;
  91. pszCountry = _NextWord(pch);
  92. }
  93. if ((_T('\0') != pszCountry[0]) &&
  94. (_T('\0') != pszCountry[1]) &&
  95. (_T('\0') == pszCountry[2]))
  96. {
  97. if (pdlv->FFindCountry(szCountry, pszCountry))
  98. {
  99. pszCountry = szCountry;
  100. }
  101. }
  102. pdlv->Add(szEmail, pszFirst, pszLast, pszCity, pszCountry, pszComments,
  103. (bFlags & 0x04) ? II_IN_CALL : II_NOT_IN_CALL,
  104. (bFlags & 0x01) ? II_AUDIO_CAPABLE : 0,
  105. (bFlags & 0x02) ? II_VIDEO_CAPABLE : 0);
  106. }
  107. FreeResource(hRes);
  108. pdlv->CancelDirectory();
  109. return E_FAIL;
  110. }