Leaked source code of windows server 2003
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.

161 lines
4.7 KiB

  1. /***************************************************************************
  2. Name : PROTHELP.C
  3. Comment : Protocol Initialization & helper functions
  4. Functions: (see Prototypes just below)
  5. Copyright (c) 1993 Microsoft Corp.
  6. Revision Log
  7. Date Name Description
  8. -------- ----- ---------------------------------------------------------
  9. ***************************************************************************/
  10. #define USE_DEBUG_CONTEXT DEBUG_CONTEXT_T30_MAIN
  11. #include "prep.h"
  12. #include "efaxcb.h"
  13. #include "protocol.h"
  14. #include "glbproto.h"
  15. // This function get the capabilities of the fax.
  16. // We are calling this function when we want to receive a fax, with type SEND_CAPS
  17. // (before we answer the call)
  18. // and with the information in pTG->ProtInst.SendCaps we make the DIS.
  19. BOOL ProtGetBC(PThrdGlbl pTG, BCTYPE bctype)
  20. {
  21. LPBC lpbc;
  22. USHORT uSpace;
  23. DEBUG_FUNCTION_NAME(_T("ProtGetBC"));
  24. DebugPrintEx(DEBUG_MSG,"In ProtGetBC: bctype=%d", bctype);
  25. lpbc = ICommGetBC(pTG, bctype);
  26. if(lpbc)
  27. {
  28. switch(bctype)
  29. {
  30. case SEND_CAPS:
  31. uSpace = sizeof(pTG->ProtInst.SendCaps);
  32. if(lpbc->wTotalSize > uSpace)
  33. goto nospace;
  34. // Here we actually take the send-caps and copy it
  35. // from pTG->Inst.SendCaps **to** pTG->ProtInst.SendCaps
  36. _fmemcpy(&pTG->ProtInst.SendCaps, lpbc, lpbc->wTotalSize);
  37. pTG->ProtInst.fSendCapsInited = TRUE;
  38. break;
  39. case SEND_PARAMS:
  40. if(lpbc->bctype == SEND_PARAMS)
  41. {
  42. uSpace = sizeof(pTG->ProtInst.SendParams);
  43. if(lpbc->wTotalSize > uSpace)
  44. goto nospace;
  45. // Here we actually take the send-caps and copy it
  46. // from pTG->Inst->SendParams **to** pTG->ProtInst.SendParams
  47. _fmemcpy(&pTG->ProtInst.SendParams, lpbc, lpbc->wTotalSize);
  48. pTG->ProtInst.fSendParamsInited = TRUE;
  49. }
  50. else
  51. {
  52. uSpace = sizeof(pTG->ProtInst.SendParams);
  53. if(lpbc->wTotalSize > uSpace)
  54. goto nospace;
  55. pTG->ProtInst.fSendParamsInited = TRUE;
  56. }
  57. break;
  58. default:
  59. goto error;
  60. break;
  61. }
  62. return TRUE;
  63. }
  64. else
  65. {
  66. DebugPrintEx(DEBUG_WRN,"Ex bctype=%d --> FAILED", bctype);
  67. return FALSE;
  68. }
  69. nospace:
  70. DebugPrintEx( DEBUG_ERR,
  71. "BC too big size=%d space=%d",
  72. lpbc->wTotalSize,
  73. uSpace);
  74. error:
  75. DebugPrintEx(DEBUG_WRN,"ATTENTION: pTG->ProtInst.fAbort = TRUE");
  76. pTG->ProtInst.fAbort = TRUE;
  77. return FALSE;
  78. }
  79. #define SetupLL(npll, B, M) \
  80. (((npll)->Baud=(BYTE)(B)), ((npll)->MinScan=(BYTE)(M)) )
  81. BOOL WINAPI ET30ProtSetProtParams
  82. (
  83. PThrdGlbl pTG,
  84. LPPROTPARAMS lp,
  85. USHORT uSendSpeeds,
  86. USHORT uRecvSpeeds
  87. )
  88. {
  89. DEBUG_FUNCTION_NAME(_T("ET30ProtSetProtParams"));
  90. _fmemcpy(&pTG->ProtParams, lp, min(sizeof(pTG->ProtParams), lp->uSize));
  91. // Hardware params
  92. SetupLL(&(pTG->ProtInst.llSendCaps), uRecvSpeeds, lp->uMinScan);
  93. pTG->ProtInst.fllSendCapsInited = TRUE;
  94. SetupLL(&(pTG->ProtInst.llSendParams), uSendSpeeds, MINSCAN_0_0_0);
  95. pTG->ProtInst.fllSendParamsInited = TRUE;
  96. if(lp->HighestSendSpeed && lp->HighestSendSpeed != 0xFFFF)
  97. {
  98. pTG->ProtInst.HighestSendSpeed = lp->HighestSendSpeed;
  99. }
  100. else
  101. {
  102. pTG->ProtInst.HighestSendSpeed = 0;
  103. }
  104. if(lp->LowestSendSpeed && lp->LowestSendSpeed != 0xFFFF)
  105. {
  106. pTG->ProtInst.LowestSendSpeed = lp->LowestSendSpeed;
  107. }
  108. else
  109. {
  110. pTG->ProtInst.LowestSendSpeed = 0;
  111. }
  112. DebugPrintEx(DEBUG_MSG,"Done with HW caps (recv, send)");
  113. // OK to print -- not online
  114. D_PrintBC("Recv HWCaps", &(pTG->ProtInst.llSendCaps));
  115. D_PrintBC("Send HWCaps", &(pTG->ProtInst.llSendParams));
  116. DebugPrintEx( DEBUG_MSG,
  117. "Highest=%d Lowest=%d",
  118. pTG->ProtInst.HighestSendSpeed,
  119. pTG->ProtInst.LowestSendSpeed);
  120. return TRUE;
  121. }
  122. void D_PrintBC(LPSTR szll, LPLLPARAMS lpll)
  123. {
  124. DEBUG_FUNCTION_NAME(_T("D_PrintBC"));
  125. if(lpll)
  126. {
  127. DebugPrintEx( DEBUG_MSG,
  128. "%s: Baud=%x MinScan=%x",
  129. (LPSTR)szll,
  130. lpll->Baud,
  131. lpll->MinScan);
  132. }
  133. }