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.

109 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. faxmodem.c
  5. Abstract:
  6. This module contains code to read the adaptive
  7. answer modem list from the faxsetup.inf file.
  8. Author:
  9. Wesley Witt (wesw) 22-Sep-1997
  10. Revision History:
  11. --*/
  12. #include <windows.h>
  13. #include <setupapi.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <tchar.h>
  17. #include "faxreg.h"
  18. #include "faxutil.h"
  19. LPVOID
  20. InitializeAdaptiveAnswerList(
  21. HINF hInf
  22. )
  23. {
  24. BOOL CloseInfHandle = FALSE;
  25. TCHAR Buffer[MAX_PATH];
  26. DWORD ErrorLine;
  27. INFCONTEXT InfLine;
  28. DWORD ModemCount = 0;
  29. LPTSTR ModemList = NULL;
  30. LPTSTR p;
  31. DWORD Size = 0;
  32. if (hInf == NULL) {
  33. ExpandEnvironmentStrings( TEXT("%windir%\\inf\\faxsetup.inf"), Buffer, sizeof(Buffer)/sizeof(TCHAR) );
  34. hInf = SetupOpenInfFile( Buffer, NULL, INF_STYLE_WIN4, &ErrorLine );
  35. if (hInf == INVALID_HANDLE_VALUE) {
  36. goto exit;
  37. }
  38. CloseInfHandle = TRUE;
  39. }
  40. if (SetupFindFirstLine( hInf, ADAPTIVE_ANSWER_SECTION, NULL, &InfLine )) {
  41. do {
  42. if (SetupGetStringField( &InfLine, 1, Buffer, sizeof(Buffer)/sizeof(TCHAR), &ErrorLine )) {
  43. Size += StringSize( Buffer );
  44. ModemCount += 1;
  45. }
  46. } while(SetupFindNextLine(&InfLine,&InfLine));
  47. }
  48. ModemList = MemAlloc( Size + 16 );
  49. if (ModemList == NULL) {
  50. goto exit;
  51. }
  52. p = ModemList;
  53. if (SetupFindFirstLine( hInf, ADAPTIVE_ANSWER_SECTION, NULL, &InfLine )) {
  54. do {
  55. if (SetupGetStringField( &InfLine, 1, Buffer, sizeof(Buffer)/sizeof(TCHAR), &ErrorLine )) {
  56. _tcscpy( p, Buffer );
  57. p += (_tcslen( Buffer ) + 1);
  58. }
  59. } while(SetupFindNextLine(&InfLine,&InfLine));
  60. }
  61. exit:
  62. if (CloseInfHandle) {
  63. SetupCloseInfFile( hInf );
  64. }
  65. return ModemList;
  66. }
  67. BOOL
  68. IsModemAdaptiveAnswer(
  69. LPVOID ModemList,
  70. LPCTSTR ModemId
  71. )
  72. {
  73. LPCTSTR p = ModemList;
  74. while (p && *p) {
  75. if (_tcsicmp( p, ModemId ) == 0) {
  76. return TRUE;
  77. }
  78. p += (_tcslen( p ) + 1);
  79. }
  80. return FALSE;
  81. }