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.

449 lines
15 KiB

  1. //
  2. // thread sync. timeouts
  3. //
  4. #define RX_WAIT_ACK_TERMINATE_TIMEOUT 60000
  5. #define RX_ACK_THRD_TIMEOUT 3000
  6. #define TX_WAIT_ACK_TERMINATE_TIMEOUT 60000
  7. //
  8. // TIFF encoder/decoder defs.
  9. //
  10. #define LINE_LENGTH 1728
  11. #define FAX_SUCCESS 0
  12. #define FAX_FAILURE 1
  13. #define RET_FAIL 0
  14. #define RET_SUCCESS 1
  15. #define RET_TIMEOUT 2
  16. #define RET_CANCELED 3
  17. #define LOG_ALL 256
  18. #define LOG_ERR 1
  19. #define LOG_NOTHING 0
  20. #define T30_RX 1
  21. #define T30_TX 2
  22. typedef struct {
  23. DWORD tiffCompression;
  24. BOOL HiRes;
  25. char lpszLineID[16]; // to be used for a temp. TIFF page data file
  26. } TX_THRD_PARAMS;
  27. #define DECODE_BUFFER_SIZE 44000
  28. #define MODEMKEY_FROM_UNIMODEM 1
  29. #define MODEMKEY_FROM_ADAPTIVE 2
  30. #define MODEMKEY_FROM_NOTHING 3
  31. //identify.c
  32. typedef struct {
  33. DWORD_PTR hglb; // Tmp globall alloc "handle" for strings.
  34. // type HGLOBAL for non-ifax and LPVOID
  35. // for IFAX
  36. LPBYTE lpbBuf;
  37. LPSTR szReset; // MAXCMDSIZE
  38. LPBYTE szSetup; // MAXCMDSIZE
  39. LPBYTE szExit; // MAXCMDSIZE
  40. LPBYTE szPreDial; // MAXCMDSIZE
  41. LPBYTE szPreAnswer; // MAXCMDSIZE
  42. LPBYTE szIDCmd; // MAXCMDSIZE
  43. LPBYTE szID; // MAXIDSIZE
  44. LPBYTE szResponseBuf; // RESPONSEBUFSIZE
  45. LPBYTE szSmallTemp1; // SMALLTEMPSIZE
  46. LPBYTE szSmallTemp2; // SMALLTEMPSIZE
  47. LPMODEMCAPS lpMdmCaps;
  48. LPMODEMEXTCAPS lpMdmExtCaps;
  49. DWORD dwSerialSpeed;
  50. DWORD dwFlags; // dwFlags, as defined in the CMDTAB structure.
  51. DWORD dwGot;
  52. USHORT uDontPurge; // Profile entry says shouldn't delete the profile.
  53. // NOTE: We will ignore this and not delete the
  54. // profile if we don't get a response from the
  55. // modem, to avoid unnecessarily deleting the
  56. // profile simply because the modem is not
  57. // responding/off/disconnected.
  58. //
  59. // 0 = purge
  60. // 1 = don't purge
  61. // anything else = uninitialized.
  62. } S_TmpSettings;
  63. typedef struct tagThreadGlobal {
  64. // t30.c
  65. int RecoveryIndex;
  66. ET30PARAMS Params; // protocol\t30.h
  67. ET30T30 T30; // same
  68. ET30ECM ECM; // same
  69. ET30ECHOPROTECT EchoProtect; // same
  70. // protapi.c
  71. PROT ProtInst; // protocol\protocol.h
  72. PROTPARAMS ProtParams; // headers\protparm.h
  73. // ddi.c
  74. MODEMPARAMS ModemParams; // headers\modemddi.h
  75. CLASS1_MODEM Class1Modem; // class1\class1.h
  76. CLASS1_STATUS Class1Status;// same
  77. // ifddi.c
  78. CLASS1_DDI DDI; // same
  79. // 4. fcom.c
  80. FCOM_COMM Comm; // comm\fcomint.h
  81. BOOL fNCUAbort;// same, 0=None 2=abort FCOM 1=abort higher level only
  82. // identify.c
  83. S_TmpSettings TmpSettings; // here
  84. // ncuparams.c
  85. NCUPARAMS NCUParams; // headers\ncuparm.h
  86. BOOL fNCUParamsChanged; //comm\modemint.h, to indicate the we need to reset params on next dial/answer...
  87. // modem.c
  88. FCOM_MODEM FComModem; // same
  89. FCOM_STATUS FComStatus; // same
  90. INSTDATA Inst; // fxrn\efaxrun.h
  91. HLINE LineHandle;
  92. HCALL CallHandle;
  93. DWORD DeviceId;
  94. HANDLE FaxHandle;
  95. HANDLE hComm;
  96. // memory management
  97. USHORT uCount;
  98. USHORT uUsed;
  99. BUFFER bfStaticBuf[STATICBUFCOUNT];
  100. BYTE bStaticBufData[STATICBUFSIZE];
  101. // additional mostly from gTAPI
  102. int fGotConnect;
  103. HANDLE hevAsync;
  104. int fWaitingForEvent;
  105. DWORD dwSignalledRID;
  106. DWORD dwSignalledParam2;
  107. DWORD_PTR dwSignalledParam3;
  108. DWORD dwPermanentLineID;
  109. char lpszPermanentLineID[16];
  110. char lpszUnimodemFaxKey[200];
  111. char lpszUnimodemKey[200];
  112. TIFF_INFO TiffInfo;
  113. LPBYTE TiffData;
  114. int TiffPageSizeAlloc;
  115. int TiffOffset;
  116. int fTiffOpenOrCreated;
  117. char lpszDialDestFax[sizeof(LINETRANSLATEOUTPUT)+64];
  118. DWORD StatusId;
  119. DWORD StringId;
  120. DWORD PageCount;
  121. LPTSTR CSI;
  122. LPTSTR CallerId;
  123. LPTSTR RoutingInfo;
  124. int fDeallocateCall;
  125. int CurrentCommSpeed;
  126. HANDLE CtrlEvent;
  127. COMM_CACHE CommCache;
  128. BOOL fMegaHertzHack;
  129. MONINFO gMonInfo;
  130. FCOM_FILTER Filter;
  131. #ifdef SMM
  132. #define MAXFILTERBUFSIZE 2048
  133. BYTE bStaticFilterBuf[MAXFILTERBUFSIZE];
  134. #endif
  135. #define CMDTABSIZE 100
  136. BYTE bModemCmds[CMDTABSIZE]; // store modem cmds read from INI/registry here
  137. #define SMALLTEMPSIZE 80
  138. char szSmallTemp1[SMALLTEMPSIZE];
  139. char szSmallTemp2[SMALLTEMPSIZE];
  140. COMMODEM_FRAMING Framing;
  141. #ifdef SMM
  142. #define FRAMEBUFINITIALSIZE ((USHORT)(((4 + 256 + 2) * 1.2) + 10)) // extra for flags
  143. BYTE bStaticFramingBuf[FRAMEBUFINITIALSIZE];
  144. #endif
  145. BYTE bRem[MAXNSFFRAMESIZE];
  146. BYTE bOut[MAXNSFFRAMESIZE];
  147. PROTDUMP fsDump;
  148. #ifndef NOCHALL
  149. BYTE bSavedChallenge[POLL_CHALLENGE_LEN];
  150. USHORT uSavedChallengeLen;
  151. #endif
  152. #define TOTALRECVDFRAMESPACE 500
  153. #ifdef SMM
  154. BYTE bStaticRecvdFrameSpace[TOTALRECVDFRAMESPACE];
  155. #endif
  156. DWORD lEarliestDialTime;
  157. RFS rfsSend;
  158. WORD PrevcbInQue;
  159. WORD PrevcbOutQue;
  160. BOOL PrevfXoffHold;
  161. BOOL PrevfXoffSent;
  162. LPWSTR lpwFileName;
  163. HANDLE CompletionPortHandle;
  164. ULONG_PTR CompletionKey;
  165. // helper thread interface
  166. BOOL fTiffThreadRunning;
  167. TX_THRD_PARAMS TiffConvertThreadParams;
  168. BOOL fTiffThreadCreated;
  169. HANDLE hThread;
  170. HANDLE ThrdSignal;
  171. HANDLE FirstPageReadyTxSignal;
  172. DWORD CurrentOut;
  173. DWORD FirstOut;
  174. DWORD LastOut;
  175. DWORD CurrentIn;
  176. BOOL ThrdRuns;
  177. BOOL ReqTerminate;
  178. BOOL AckTerminate;
  179. BOOL ReqStartNewPage;
  180. BOOL AckStartNewPage;
  181. BOOL ThreadFatalError;
  182. char InFileName[_MAX_FNAME];
  183. HANDLE InFileHandle;
  184. BOOL InFileHandleNeedsBeClosed;
  185. BOOL fTxPageDone;
  186. BOOL fTiffPageDone;
  187. BOOL fTiffDocumentDone;
  188. // helper RX interface
  189. BOOL fPageIsBad;
  190. BOOL fLastReadBlock;
  191. HANDLE ThrdDoneSignal;
  192. HANDLE ThrdAckTerminateSignal;
  193. DWORD ThrdDoneRetCode;
  194. DWORD BytesIn;
  195. DWORD BytesInNotFlushed;
  196. DWORD BytesOut;
  197. DWORD BytesOutWillBe;
  198. char OutFileName[_MAX_FNAME];
  199. HANDLE OutFileHandle;
  200. BOOL SrcHiRes;
  201. // error reporting
  202. BOOL fFatalErrorWasSignaled;
  203. // abort sync.
  204. HANDLE AbortReqEvent;
  205. HANDLE AbortAckEvent;
  206. BOOL fUnblockIO; // pending I/O should be aborted ONCE only
  207. BOOL fOkToResetAbortReqEvent;
  208. BOOL fAbortReqEventWasReset;
  209. BOOL fAbortRequested;
  210. // CSID, TSID local/remote
  211. char LocalID[MAXTOTALIDLEN + 2];
  212. LPWSTR RemoteID;
  213. BOOL fRemoteIdAvail;
  214. // Adaptive Answer
  215. BOOL AdaptiveAnswerEnable;
  216. // Unimodem setup
  217. DWORD dwSpeakerVolume;
  218. DWORD dwSpeakerMode;
  219. BOOL fBlindDial;
  220. // INF settings
  221. BOOL fEnableHardwareFlowControl;
  222. UWORD SerialSpeedInit;
  223. BOOL SerialSpeedInitSet;
  224. UWORD SerialSpeedConnect;
  225. BOOL SerialSpeedConnectSet;
  226. UWORD FixSerialSpeed;
  227. BOOL FixSerialSpeedSet;
  228. BOOL fCommInitialized;
  229. // derived from INF
  230. UWORD CurrentSerialSpeed;
  231. // Unimodem key info
  232. char ResponsesKeyName[300];
  233. // new ADAPTIVE.INF
  234. DWORD FaxClass;
  235. char *ResetCommand;
  236. char *SetupCommand;
  237. DWORD AnswerCommandNum;
  238. char *AnswerCommand[20];
  239. char *ModemResponseFaxDetect;
  240. char *ModemResponseDataDetect;
  241. UWORD SerialSpeedFaxDetect;
  242. UWORD SerialSpeedDataDetect;
  243. char *HostCommandFaxDetect;
  244. char *HostCommandDataDetect;
  245. char *ModemResponseFaxConnect;
  246. char *ModemResponseDataConnect;
  247. BOOL Operation;
  248. // Flags to indicate the source of INF info
  249. BOOL fAdaptiveRecordFound;
  250. BOOL fAdaptiveRecordUnique;
  251. BOOL fUnimodemFaxDefined;
  252. DWORD AdaptiveCodeId;
  253. DWORD ModemKeyCreationId;
  254. // Class2
  255. DWORD ModemClass;
  256. USHORT cbResponseSize;
  257. BYTE lpbResponseBuf[RESPONSE_BUF_SIZE];
  258. CL2_COMM_ARRAY class2_commands;
  259. BOOL fRecvPageOK; // flag set when Class2GetRecvPageAck is called
  260. NCUPARAMS NCUParams2;
  261. LPCMDTAB lpCmdTab;
  262. PROTPARAMS ProtParams2;
  263. BYTE bLastReply2[REPLYBUFSIZE+1];
  264. BYTE bFoundReply[REPLYBUFSIZE+1];
  265. MFRSPEC CurrentMFRSpec;
  266. BYTE Class2bDLEETX[3];
  267. BYTE lpbResponseBuf2[RESPONSE_BUF_SIZE];
  268. BCwithTEXT bcSendCaps; // Used to generate DIS
  269. BCwithTEXT bcSendParams; // Used to generate DCS
  270. PCB DISPcb; // has default DIS values for this modem.
  271. BOOL fAbort; // flag set when Class2Abort is called
  272. TO toAnswer;
  273. TO toRecv;
  274. TO toDialog;
  275. TO toZero;
  276. #define C2SZMAXLEN 50
  277. C2SZ cbszFDT[C2SZMAXLEN];
  278. C2SZ cbszINITIAL_FDT[C2SZMAXLEN];
  279. C2SZ cbszFDR[C2SZMAXLEN];
  280. C2SZ cbszFPTS[C2SZMAXLEN];
  281. C2SZ cbszFCR[C2SZMAXLEN];
  282. C2SZ cbszFNR[C2SZMAXLEN];
  283. C2SZ cbszFCQ[C2SZMAXLEN];
  284. C2SZ cbszFLO[C2SZMAXLEN];
  285. C2SZ cbszFBUG[C2SZMAXLEN];
  286. C2SZ cbszSET_FBOR[C2SZMAXLEN];
  287. // DCC - set High Res, Huffman, no ECM/BFT, default all others.
  288. C2SZ cbszFDCC_ALL[C2SZMAXLEN];
  289. C2SZ cbszFDCC_RECV_ALL[C2SZMAXLEN];
  290. C2SZ cbszFDIS_RECV_ALL[C2SZMAXLEN];
  291. C2SZ cbszFDCC_RES[C2SZMAXLEN];
  292. C2SZ cbszFDCC_BAUD[C2SZMAXLEN];
  293. C2SZ cbszFDIS_BAUD[C2SZMAXLEN];
  294. C2SZ cbszFDIS_IS[C2SZMAXLEN];
  295. C2SZ cbszFDIS_NOQ_IS[C2SZMAXLEN];
  296. C2SZ cbszFDCC_IS[C2SZMAXLEN];
  297. C2SZ cbszFDIS_STRING[C2SZMAXLEN];
  298. C2SZ cbszFDIS[C2SZMAXLEN];
  299. C2SZ cbszZERO[C2SZMAXLEN];
  300. C2SZ cbszONE[C2SZMAXLEN];
  301. C2SZ cbszQUERY_S1[C2SZMAXLEN];
  302. C2SZ cbszRING[C2SZMAXLEN];
  303. C2SZ cbszCLASS2_ATI[C2SZMAXLEN];
  304. C2SZ cbszCLASS2_FMFR[C2SZMAXLEN];
  305. C2SZ cbszCLASS2_FMDL[C2SZMAXLEN];
  306. C2SZ cbszCLASS2_FREV[C2SZMAXLEN];
  307. C2SZ cbszFDT_CONNECT[C2SZMAXLEN];
  308. C2SZ cbszFDT_CNTL_Q[C2SZMAXLEN];
  309. C2SZ cbszFCON[C2SZMAXLEN];
  310. C2SZ cbszGO_CLASS2[C2SZMAXLEN];
  311. C2SZ cbszFLID[C2SZMAXLEN];
  312. C2SZ cbszENDPAGE[C2SZMAXLEN];
  313. C2SZ cbszENDMESSAGE[C2SZMAXLEN];
  314. C2SZ cbszCLASS2_QUERY_CLASS[C2SZMAXLEN];
  315. C2SZ cbszCLASS2_GO_CLASS0[C2SZMAXLEN];
  316. C2SZ cbszCLASS2_ATTEN[C2SZMAXLEN];
  317. C2SZ cbszATA[C2SZMAXLEN];
  318. // Bug1982: Racal modem, doesnt accept ATA. So we send it a PreAnswer
  319. // command of ATS0=1, i.r. turning ON autoanswer. And we ignore the
  320. // ERROR response it gives to the subsequent ATAs. It then answers
  321. // 'automatically' and gives us all the right responses. On hangup
  322. // however we need to send an ATS0=0 to turn auto-answer off. The
  323. // ExitCommand is not sent at all in Class2 and in Class1 it is only
  324. // sent on releasing the modem, not between calls. So just send an S0=0
  325. // after the ATH0. If the modem doesnt like it we ignore the response
  326. // anyway
  327. C2SZ cbszCLASS2_HANGUP[C2SZMAXLEN];
  328. C2SZ cbszCLASS2_CALLDONE[C2SZMAXLEN];
  329. C2SZ cbszCLASS2_ABORT[C2SZMAXLEN];
  330. C2SZ cbszCLASS2_DIAL[C2SZMAXLEN];
  331. C2SZ cbszCLASS2_NODIALTONE[C2SZMAXLEN];
  332. C2SZ cbszCLASS2_BUSY[C2SZMAXLEN];
  333. C2SZ cbszCLASS2_NOANSWER[C2SZMAXLEN];
  334. C2SZ cbszCLASS2_OK[C2SZMAXLEN];
  335. C2SZ cbszCLASS2_FHNG[C2SZMAXLEN];
  336. C2SZ cbszCLASS2_ERROR[C2SZMAXLEN];
  337. C2SZ cbszCLASS2_RESET[C2SZMAXLEN];
  338. C2SZ cbszCLASS2_ATE0[C2SZMAXLEN];
  339. BYTE Resolution;
  340. BYTE Encoding;
  341. // Dbg
  342. DWORD CommLogOffset;
  343. DWORD dbg1;
  344. DWORD dbg2;
  345. DWORD dbg3;
  346. DWORD dbg4;
  347. DWORD dbg5;
  348. } ThrdGlbl, *PThrdGlbl;