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.

440 lines
16 KiB

  1. #include <t30ext.h>
  2. //
  3. // thread sync. timeouts
  4. //
  5. #define RX_WAIT_ACK_TERMINATE_TIMEOUT 60000
  6. #define RX_ACK_THRD_TIMEOUT 3000
  7. #define TX_WAIT_ACK_TERMINATE_TIMEOUT 60000
  8. #define T30_RX 1
  9. #define T30_TX 2
  10. //
  11. // Timeout for ATDT command
  12. //
  13. #define DIAL_TIMEOUT 70000L
  14. //
  15. // Custom StatusID's
  16. //
  17. #define FS_UNSUPPORTED_CHAR 0x40000800
  18. #define FS_RECV_NOT_FAX_CALL 0x40000801
  19. #define FS_NO_RESPONSE 0x40000802
  20. #define FS_SEND_BAD_TRAINING 0x40000803
  21. #define FS_RECV_BAD_TRAINING 0x40000804
  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. #define MAX_REG_KEY_NAME_SIZE (200)
  32. //identify.c
  33. typedef struct {
  34. DWORD_PTR hglb; // Tmp globall alloc "handle" for strings.
  35. // type HGLOBAL for non-ifax and LPVOID
  36. // for IFAX
  37. LPBYTE lpbBuf;
  38. LPBYTE szReset; // MAXCMDSIZE
  39. LPBYTE szResetGenerated; // MAXCMDSIZE
  40. LPBYTE szSetup; // MAXCMDSIZE
  41. LPBYTE szSetupGenerated; // MAXCMDSIZE
  42. LPBYTE szExit; // MAXCMDSIZE
  43. LPBYTE szPreDial; // MAXCMDSIZE
  44. LPBYTE szPreAnswer; // MAXCMDSIZE
  45. LPBYTE szIDCmd; // MAXCMDSIZE
  46. LPBYTE szID; // MAXIDSIZE
  47. LPBYTE szResponseBuf; // RESPONSEBUFSIZE
  48. LPBYTE szSmallTemp1; // SMALLTEMPSIZE
  49. LPBYTE szSmallTemp2; // SMALLTEMPSIZE
  50. LPMODEMCAPS lpMdmCaps;
  51. DWORD dwSerialSpeed;
  52. DWORD dwFlags; // dwFlags, as defined in the CMDTAB structure.
  53. DWORD dwGot;
  54. USHORT uDontPurge; // Profile entry says shouldn't delete the profile.
  55. // NOTE: We will ignore this and not delete the
  56. // profile if we don't get a response from the
  57. // modem, to avoid unnecessarily deleting the
  58. // profile simply because the modem is not
  59. // responding/off/disconnected.
  60. //
  61. // 0 = purge
  62. // 1 = don't purge
  63. // anything else = uninitialized.
  64. } S_TmpSettings;
  65. // This is how ResetCommand vs. ResetCommandGenerated work:
  66. // When first installing the modem, we copy ResetCommand from Unimodem/.inf. If there's
  67. // no ResetCommand, or ResetCommand is bad (produces ERROR), iModemFigureOutCmdsExt
  68. // generates a new command from scrach, and saves it in ResetCommandGenerated. When trying
  69. // to read from registry:
  70. // * If ResetCommand is different from Unimodem's ResetCommand, then there has been a
  71. // Unimodem inf upddate - install from scratch
  72. // * If ResetCommand is the same, and there's a non-null ResetCommandGenerated, use
  73. // ResetCommandGenerated - we've already tried the original ResetCommand once, and failed.
  74. // * If ResetCommand is the same, and there's no ResetCommandGenerate, use ResetCommand.
  75. //
  76. // Same goes for SetupCommand vs. SetupCommandGenerated
  77. typedef struct tagThreadGlobal {
  78. // t30.c
  79. int RecoveryIndex;
  80. ET30T30 T30; // same
  81. ET30ECHOPROTECT EchoProtect; // same
  82. // protapi.c
  83. PROT ProtInst; // protocol\protocol.h
  84. PROTPARAMS ProtParams; // headers\protparm.h
  85. // ddi.c
  86. CLASS1_MODEM Class1Modem; // class1\class1.h
  87. // 4. fcom.c
  88. FCOM_COMM Comm; // comm\fcomint.h
  89. // identify.c
  90. S_TmpSettings TmpSettings; // here
  91. // ncuparams.c
  92. NCUPARAMS NCUParams; // headers\ncuparm.h
  93. // modem.c
  94. FCOM_MODEM FComModem; // same
  95. FCOM_STATUS FComStatus; // same
  96. INSTDATA Inst; // fxrn\efaxrun.h
  97. HLINE LineHandle;
  98. HCALL CallHandle;
  99. DWORD DeviceId;
  100. HANDLE FaxHandle;
  101. HANDLE hComm;
  102. // memory management
  103. USHORT uCount;
  104. USHORT uUsed;
  105. BUFFER bfStaticBuf[STATICBUFCOUNT];
  106. BYTE bStaticBufData[STATICBUFSIZE];
  107. // additional mostly from gTAPI
  108. int fGotConnect;
  109. HANDLE hevAsync;
  110. int fWaitingForEvent;
  111. DWORD dwSignalledRID;
  112. DWORD dwSignalledParam2;
  113. DWORD_PTR dwSignalledParam3;
  114. DWORD dwPermanentLineID;
  115. char lpszPermanentLineID[16];
  116. char lpszUnimodemFaxKey[MAX_REG_KEY_NAME_SIZE];
  117. char lpszUnimodemKey[MAX_REG_KEY_NAME_SIZE];
  118. TIFF_INFO TiffInfo;
  119. LPBYTE TiffData;
  120. int TiffPageSizeAlloc;
  121. int TiffOffset;
  122. int fTiffOpenOrCreated;
  123. char lpszDialDestFax[MAXPHONESIZE];
  124. DWORD StatusId;
  125. DWORD StringId;
  126. DWORD PageCount;
  127. LPTSTR CSI;
  128. char CallerId[200];
  129. LPTSTR RoutingInfo;
  130. int fDeallocateCall;
  131. COMM_CACHE CommCache;
  132. BOOL fMegaHertzHack;
  133. FCOM_FILTER Filter;
  134. #define MAXFILTERBUFSIZE 2048
  135. BYTE bStaticFilterBuf[MAXFILTERBUFSIZE];
  136. #define CMDTABSIZE 100
  137. BYTE bModemCmds[CMDTABSIZE]; // store modem cmds read from INI/registry here
  138. #define SMALLTEMPSIZE 80
  139. char szSmallTemp1[SMALLTEMPSIZE];
  140. char szSmallTemp2[SMALLTEMPSIZE];
  141. PROTDUMP fsDump;
  142. #define TOTALRECVDFRAMESPACE 500
  143. BYTE bStaticRecvdFrameSpace[TOTALRECVDFRAMESPACE];
  144. RFS rfsSend;
  145. WORD PrevcbInQue;
  146. WORD PrevcbOutQue;
  147. BOOL PrevfXoffHold;
  148. BOOL PrevfXoffSent;
  149. LPWSTR lpwFileName;
  150. HANDLE CompletionPortHandle;
  151. ULONG_PTR CompletionKey;
  152. // helper thread interface
  153. BOOL fTiffThreadRunning;
  154. TX_THRD_PARAMS TiffConvertThreadParams;
  155. BOOL fTiffThreadCreated;
  156. HANDLE hThread;
  157. HANDLE ThrdSignal;
  158. HANDLE FirstPageReadyTxSignal;
  159. DWORD CurrentOut;
  160. DWORD FirstOut;
  161. DWORD LastOut;
  162. DWORD CurrentIn;
  163. BOOL ReqTerminate;
  164. BOOL AckTerminate;
  165. BOOL ReqStartNewPage;
  166. BOOL AckStartNewPage;
  167. char InFileName[_MAX_FNAME];
  168. HANDLE InFileHandle;
  169. BOOL InFileHandleNeedsBeClosed;
  170. BOOL fTxPageDone;
  171. BOOL fTiffPageDone;
  172. BOOL fTiffDocumentDone;
  173. // helper RX interface
  174. BOOL fPageIsBad; // Is the page bad (determined by rx_thrd)
  175. BOOL fPageIsBadOverride; // Was fPageIsBad overridden in ICommPutRecvBuf
  176. BOOL fLastReadBlock;
  177. HANDLE ThrdDoneSignal;
  178. HANDLE ThrdAckTerminateSignal;
  179. DWORD ThrdDoneRetCode;
  180. DWORD BytesIn;
  181. DWORD BytesInNotFlushed;
  182. DWORD BytesOut;
  183. DWORD BytesOutWillBe;
  184. char OutFileName[_MAX_FNAME];
  185. HANDLE OutFileHandle;
  186. BOOL SrcHiRes;
  187. // Need to have these as globals, so we can report them in PSS log
  188. DWORD Lines;
  189. DWORD BadFaxLines;
  190. DWORD ConsecBadLines;
  191. int iResScan;
  192. // error reporting
  193. BOOL fFatalErrorWasSignaled;
  194. BOOL fLineTooLongWasIgnored;
  195. // Set when we get CONNECT for AT+FRH=3. If this is not set when call ends,
  196. // it means the other side never sent any HDLC flags, and therefore is not
  197. // considered a fax machine.
  198. BOOL fReceivedHDLCflags;
  199. // Set when we send FTT, reset when we receive the next frame. If the next
  200. // frame is DCN, it means the other side has disconnected because of the FTT
  201. BOOL fSentFTT;
  202. // abort sync.
  203. HANDLE AbortReqEvent;
  204. HANDLE AbortAckEvent;
  205. // fUnblockIO:
  206. // Original documentation says: pending I/O should be aborted ONCE only
  207. //
  208. // This flag never initiated, but it's value is FALSE (0) at start.
  209. // The flag get the value TRUE on two conditions:
  210. // 1) Before wait on overlapped IO event or tapi event we check if there was an abort,
  211. // if so we turn this flag to TRUE.
  212. // 2) While waiting for multiple objects, the abort event has become signaled
  213. //
  214. // After this flag become TRUE, it stays so and never become FALSE again.
  215. BOOL fUnblockIO;
  216. BOOL fOkToResetAbortReqEvent;
  217. BOOL fAbortReqEventWasReset;
  218. BOOL fAbortRequested;
  219. // this is used to complete a whole IO operation (presumably a short one)
  220. // when this flag is set, the IO won't be disturbed by the abort event
  221. // this flag should NOT be set for long periods of time since abort
  222. // is disabled while it is set.
  223. BOOL fStallAbortRequest;
  224. // CSID, TSID local/remote
  225. char LocalID[MAXTOTALIDLEN + 2];
  226. LPWSTR RemoteID;
  227. BOOL fRemoteIdAvail;
  228. // Adaptive Answer
  229. BOOL AdaptiveAnswerEnable;
  230. // Unimodem setup
  231. DWORD dwSpeakerVolume;
  232. DWORD dwSpeakerMode;
  233. BOOL fBlindDial;
  234. // INF settings
  235. BOOL fEnableHardwareFlowControl;
  236. UWORD SerialSpeedInit;
  237. BOOL SerialSpeedInitSet;
  238. UWORD SerialSpeedConnect;
  239. BOOL SerialSpeedConnectSet;
  240. UWORD FixSerialSpeed;
  241. BOOL FixSerialSpeedSet;
  242. BOOL fCommInitialized;
  243. // derived from INF
  244. UWORD CurrentSerialSpeed;
  245. // Unimodem key info
  246. char ResponsesKeyName[300];
  247. DWORD AnswerCommandNum;
  248. #define MAX_ANSWER_COMMANDS 20
  249. char *AnswerCommand[MAX_ANSWER_COMMANDS];
  250. char *ModemResponseFaxDetect;
  251. char *ModemResponseDataDetect;
  252. UWORD SerialSpeedFaxDetect;
  253. UWORD SerialSpeedDataDetect;
  254. char *HostCommandFaxDetect;
  255. char *HostCommandDataDetect;
  256. char *ModemResponseFaxConnect;
  257. char *ModemResponseDataConnect;
  258. BOOL Operation;
  259. // Flags to indicate the source of INF info
  260. BOOL fAdaptiveRecordFound;
  261. BOOL fAdaptiveRecordUnique;
  262. DWORD AdaptiveCodeId;
  263. DWORD ModemKeyCreationId;
  264. // Class2
  265. DWORD ModemClass;
  266. CL2_COMM_ARRAY class2_commands;
  267. BYTE FPTSreport; // value from "+FPTS: X,..." or "+FPS: X,..."
  268. NCUPARAMS NCUParams2;
  269. LPCMDTAB lpCmdTab;
  270. PROTPARAMS ProtParams2;
  271. MFRSPEC CurrentMFRSpec;
  272. BYTE Class2bDLEETX[3];
  273. BYTE lpbResponseBuf2[RESPONSE_BUF_SIZE];
  274. BC bcSendCaps; // Used to generate DIS
  275. BC bcSendParams; // Used to generate DCS
  276. PCB DISPcb; // has default DIS values for this modem.
  277. TO toAnswer;
  278. TO toRecv;
  279. TO toDialog;
  280. TO toZero;
  281. BOOL fFoundFHNG; // Did we detect a "+FHNG" or "+FHS" from the modem?
  282. DWORD dwFHNGReason; // reason for the FHNG, as reported by the modem
  283. #define C2SZMAXLEN 50
  284. C2SZ cbszFDT[C2SZMAXLEN];
  285. C2SZ cbszFDR[C2SZMAXLEN];
  286. C2SZ cbszFPTS[C2SZMAXLEN];
  287. C2SZ cbszFCR[C2SZMAXLEN];
  288. C2SZ cbszFNR[C2SZMAXLEN];
  289. C2SZ cbszFCQ[C2SZMAXLEN];
  290. C2SZ cbszFBUG[C2SZMAXLEN];
  291. C2SZ cbszSET_FBOR[C2SZMAXLEN];
  292. // DCC - set High Res, Huffman, no ECM/BFT, default all others.
  293. C2SZ cbszFDCC_ALL[C2SZMAXLEN];
  294. C2SZ cbszFDCC_RECV_ALL[C2SZMAXLEN];
  295. C2SZ cbszFDIS_RECV_ALL[C2SZMAXLEN];
  296. C2SZ cbszFDCC_RES[C2SZMAXLEN];
  297. C2SZ cbszFDCC_RECV_RES[C2SZMAXLEN];
  298. C2SZ cbszFDCC_BAUD[C2SZMAXLEN];
  299. C2SZ cbszFDIS_BAUD[C2SZMAXLEN];
  300. C2SZ cbszFDIS_IS[C2SZMAXLEN];
  301. C2SZ cbszFDIS_NOQ_IS[C2SZMAXLEN];
  302. C2SZ cbszFDCC_IS[C2SZMAXLEN];
  303. C2SZ cbszFDIS_STRING[C2SZMAXLEN];
  304. C2SZ cbszFDIS[C2SZMAXLEN];
  305. C2SZ cbszONE[C2SZMAXLEN];
  306. C2SZ cbszCLASS2_FMFR[C2SZMAXLEN];
  307. C2SZ cbszCLASS2_FMDL[C2SZMAXLEN];
  308. C2SZ cbszFDT_CONNECT[C2SZMAXLEN];
  309. C2SZ cbszFCON[C2SZMAXLEN];
  310. C2SZ cbszFLID[C2SZMAXLEN];
  311. C2SZ cbszENDPAGE[C2SZMAXLEN];
  312. C2SZ cbszENDMESSAGE[C2SZMAXLEN];
  313. C2SZ cbszCLASS2_ATTEN[C2SZMAXLEN];
  314. C2SZ cbszATA[C2SZMAXLEN];
  315. // Bug1982: Racal modem, doesnt accept ATA. So we send it a PreAnswer
  316. // command of ATS0=1, i.r. turning ON autoanswer. And we ignore the
  317. // ERROR response it gives to the subsequent ATAs. It then answers
  318. // 'automatically' and gives us all the right responses. On hangup
  319. // however we need to send an ATS0=0 to turn auto-answer off. The
  320. // ExitCommand is not sent at all in Class2 and in Class1 it is only
  321. // sent on releasing the modem, not between calls. So just send an S0=0
  322. // after the ATH0. If the modem doesnt like it we ignore the response
  323. // anyway
  324. C2SZ cbszCLASS2_HANGUP[C2SZMAXLEN];
  325. C2SZ cbszCLASS2_CALLDONE[C2SZMAXLEN];
  326. C2SZ cbszCLASS2_ABORT[C2SZMAXLEN];
  327. C2SZ cbszCLASS2_DIAL[C2SZMAXLEN];
  328. C2SZ cbszCLASS2_NODIALTONE[C2SZMAXLEN];
  329. C2SZ cbszCLASS2_BUSY[C2SZMAXLEN];
  330. C2SZ cbszCLASS2_NOANSWER[C2SZMAXLEN];
  331. C2SZ cbszCLASS2_OK[C2SZMAXLEN];
  332. C2SZ cbszCLASS2_FHNG[C2SZMAXLEN];
  333. C2SZ cbszCLASS2_ERROR[C2SZMAXLEN];
  334. C2SZ cbszCLASS2_NOCARRIER[C2SZMAXLEN];
  335. BYTE Resolution;
  336. BYTE Encoding;
  337. // Dbg
  338. DWORD CommLogOffset;
  339. //
  340. // Extension Data
  341. //
  342. T30_EXTENSION_DATA ExtData;
  343. //
  344. // PSS log
  345. //
  346. // 0 - no logging, 1 - log all jobs, 2 - log failed jobs only
  347. DWORD dwLoggingEnabled;
  348. HANDLE hPSSLogFile; // Handle to the PSS log file
  349. TCHAR szLogFileName[MAX_PATH]; // temporary PSS log filename
  350. DWORD dwMaxLogFileSize; // Max allowed log file size
  351. DWORD dwCurrentFileSize; // Current log file size
  352. } ThrdGlbl, *PThrdGlbl;