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.

552 lines
15 KiB

  1. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  3. //from headers\timeouts.h
  4. /****************** begin prototypes from timeouts.c *****************/
  5. extern void startTimeOut( PThrdGlbl pTG, TO *lpto, ULONG ulTimeOut);
  6. extern BOOL checkTimeOut( PThrdGlbl pTG, TO *lpto);
  7. extern ULONG leftTimeOut( PThrdGlbl pTG, TO *lpto);
  8. /****************** begin prototypes from timeouts.c *****************/
  9. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  10. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  11. USHORT MinScanToBytesPerLine(PThrdGlbl pTG, BYTE Minscan, BYTE Baud);
  12. /****************** begin prototypes from protapi.c *****************/
  13. BOOL ProtGetBC(PThrdGlbl pTG, BCTYPE bctype);
  14. BOOL WINAPI ET30ProtSetProtParams(PThrdGlbl pTG, LPPROTPARAMS lp, USHORT uRecvSpeeds, USHORT uSendSpeeds);
  15. /***************** end of prototypes from protapi.c *****************/
  16. //from headers\comapi.h
  17. #define FComFilterAsyncWrite(pTG, lpb,cb,fl) (FComFilterWrite(pTG, lpb, cb, fl) == cb)
  18. #define FComDirectAsyncWrite(pTG, lpb,cb) ((FComDirectWrite(pTG, lpb, cb)==cb) ? 1 : 0)
  19. #define FComDirectSyncWriteFast(pTG, lpb,cb) ((FComDirectWrite(pTG, lpb, cb)==cb) && FComDrain(pTG, FALSE,TRUE))
  20. #define FComFlush(pTG) { FComFlushQueue(pTG, 0); FComFlushQueue(pTG, 1); }
  21. #define FComFlushInput(pTG) { FComFlushQueue(pTG, 1); }
  22. #define FComFlushOutput(pTG) { FComFlushQueue(pTG, 0); }
  23. extern BOOL FComInit(PThrdGlbl pTG, DWORD dwLineID, DWORD dwLineIDType);
  24. extern BOOL FComClose(PThrdGlbl pTG);
  25. extern BOOL FComSetBaudRate(PThrdGlbl pTG, UWORD uwBaudRate);
  26. extern void FComFlushQueue(PThrdGlbl pTG, int queue);
  27. extern BOOL FComXon(PThrdGlbl pTG, BOOL fEnable);
  28. extern BOOL FComDTR(PThrdGlbl pTG, BOOL fEnable);
  29. extern UWORD FComDirectWrite(PThrdGlbl pTG, LPB lpb, UWORD cb);
  30. extern UWORD FComFilterWrite(PThrdGlbl pTG, LPB lpb, UWORD cb, USHORT flags);
  31. extern BOOL FComDrain(PThrdGlbl pTG, BOOL fLongTimeout, BOOL fDrainComm);
  32. extern UWORD FComFilterReadBuf(PThrdGlbl pTG, LPB lpb, UWORD cbSize, LPTO lpto, BOOL fClass2, LPSWORD lpswEOF);
  33. // *lpswEOF is 1 on Class1 EOF, 0 on non-EOF, -1 on Class2 EOF, -2 on error -3 on timeout
  34. extern SWORD FComFilterReadLine(PThrdGlbl pTG, LPB lpb, UWORD cbSize, LPTO lptoRead);
  35. extern void FComInFilterInit(PThrdGlbl pTG);
  36. extern void FComOutFilterInit(PThrdGlbl pTG);
  37. extern void FComOutFilterClose(PThrdGlbl pTG);
  38. extern void FComAbort(PThrdGlbl pTG, BOOL f);
  39. extern void FComSetStuffZERO(PThrdGlbl pTG, USHORT cbLineMin);
  40. BOOL FComGetOneChar(PThrdGlbl pTG, UWORD ch);
  41. extern void WINAPI FComOverlappedIO(PThrdGlbl pTG, BOOL fStart);
  42. /****************** begin DEBUG prototypes *****************/
  43. extern void far D_HexPrint(LPB b1, UWORD incnt);
  44. /***************** end of prototypes *****************/
  45. /****************** begin prototypes from modem.c *****************/
  46. extern USHORT iModemInit( PThrdGlbl pTG,
  47. DWORD dwLineID,
  48. DWORD dwLineIDType,
  49. DWORD dwProfileID,
  50. LPSTR lpszKey,
  51. BOOL fInstall);
  52. extern BOOL iModemClose(PThrdGlbl pTG);
  53. void LogDialCommand(PThrdGlbl pTG, LPSTR lpszFormat, char chMod, int iLen);
  54. extern BOOL iModemSetNCUParams(PThrdGlbl pTG, int comma, int speaker, int volume, int fBlind, int fRingAloud);
  55. extern BOOL iModemHangup(PThrdGlbl pTG);
  56. extern USHORT iModemDial(PThrdGlbl pTG, LPSTR lpszDial);
  57. extern USHORT iModemAnswer(PThrdGlbl pTG);
  58. extern LPCMDTAB iModemGetCmdTabPtr(PThrdGlbl pTG);
  59. // 6 fixed args, then variable number of CBPSTRs, but there
  60. // must be at leat 2. One real one and one NULL terminator
  61. extern UWORD far iiModemDialog(PThrdGlbl pTG, LPSTR szSend, UWORD uwLen, ULONG ulTimeout,
  62. BOOL fMultiLine, UWORD uwRepeatCount, BOOL fPause,
  63. CBPSTR w1, CBPSTR w2, ...);
  64. /***************** end of prototypes from modem.c *****************/
  65. /****************** begin prototypes from whatnext.c *****************/
  66. ET30ACTION
  67. __cdecl
  68. FAR
  69. WhatNext
  70. (
  71. PThrdGlbl pTG,
  72. ET30EVENT event,
  73. WORD wArg1,
  74. DWORD_PTR lArg2,
  75. DWORD_PTR lArg3
  76. );
  77. /***************** end of prototypes from whatnext.c *****************/
  78. //from headers\filet30.h
  79. ULONG_PTR ProfileOpen(DWORD dwProfileID, LPSTR lpszSection, DWORD dwFlags);
  80. // dwProfileID should be one of DEF_BASEKEY or OEM_BASEKEY.
  81. // lpszSection should be (for example) "COM2" or "TAPI02345a04"
  82. // If dwProfileID == DEF_BASEKEY, the value is set to be a
  83. // sub key of:
  84. // HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\At Work Fax\
  85. // Local Modems\<lpszSection>.
  86. // Else if it is DEF_OEMKEY, it is assumed to be a fully-
  87. // qualified Key name, like "SOFTWARE\MICROSOFT.."
  88. //
  89. // Currently both are based of HKEY_LOCAL_MACHINE.
  90. //
  91. // When you're finished with this key, call ProfileClose.
  92. //
  93. // dwFlags is a combination of one of the fREG keys above..
  94. //
  95. // WIN32 ONLY: if lpszSection is NULL, it will open the base key,
  96. // and return its handle, which can be used in the Reg* functions.
  97. // Following are emulations of Get/WritePrivateProfileInt/String...
  98. BOOL
  99. ProfileWriteString(
  100. ULONG_PTR dwKey,
  101. LPSTR lpszValueName,
  102. LPSTR lpszBuf,
  103. BOOL fRemoveCR
  104. );
  105. DWORD ProfileGetString(ULONG_PTR dwKey, LPSTR lpszValueName, LPSTR lpszDefault, LPSTR lpszBuf , DWORD dwcbMax);
  106. UINT ProfileGetInt(ULONG_PTR dwKey, LPSTR szValueName, UINT uDefault, BOOL *fExist);
  107. UINT
  108. ProfileListGetInt(
  109. ULONG_PTR KeyList[10],
  110. LPSTR lpszValueName,
  111. UINT uDefault
  112. );
  113. // Following read/write binary data (type REG_BINARY). Available
  114. // on Win32 only....
  115. void ProfileClose(ULONG_PTR dwKey);
  116. BOOL ProfileDeleteSection(DWORD dwProfileID, LPSTR lpszSection);
  117. BOOL
  118. ProfileCopySection(
  119. DWORD dwProfileIDTo,
  120. LPSTR lpszSectionTo,
  121. DWORD dwProfileIDFr,
  122. LPSTR lpszSectionFr,
  123. BOOL fCreateAlways
  124. );
  125. BOOL ProfileCopyTree(DWORD dwProfileIDTo,
  126. LPSTR lpszSectionTo, DWORD dwProfileIDFrom, LPSTR lpszSectionFrom);
  127. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  128. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  129. // from headers\modemddi.h
  130. /****************** begin prototypes from ddi.c *****************/
  131. USHORT NCULink(PThrdGlbl pTG, USHORT uFlags);
  132. USHORT NCUDial(PThrdGlbl pTG, LPSTR szPhoneNum);
  133. // dwFlags -- one of...
  134. # define fMDMSYNC_DCN 0x1L
  135. BOOL ModemSendMode(PThrdGlbl pTG, USHORT uMod);
  136. BOOL ModemSendMem(PThrdGlbl pTG, LPBYTE lpb, USHORT uCount, USHORT uParams);
  137. BOOL iModemSyncEx(PThrdGlbl pTG, ULONG ulTimeout, DWORD dwFlags);
  138. BOOL ModemRecvSilence(PThrdGlbl pTG, USHORT uMillisecs, ULONG ulTimeout);
  139. USHORT ModemRecvMode(PThrdGlbl pTG, USHORT uMod, ULONG ulTimeout, BOOL fRetryOnFCERROR);
  140. USHORT ModemRecvMem(PThrdGlbl pTG, LPBYTE lpb, USHORT cbMax, ULONG ulTimeout, USHORT far* lpcbRecv);
  141. /***************** end of prototypes from ddi.c *****************/
  142. LPBUFFER MyAllocBuf(PThrdGlbl pTG, LONG sSize);
  143. BOOL MyFreeBuf(PThrdGlbl pTG, LPBUFFER);
  144. void MyAllocInit(PThrdGlbl pTG);
  145. //negot.c
  146. BOOL NegotiateCaps(PThrdGlbl pTG);
  147. VOID
  148. T30LineCallBackFunction(
  149. HANDLE hFax,
  150. DWORD hDevice,
  151. DWORD dwMessage,
  152. DWORD_PTR dwInstance,
  153. DWORD_PTR dwParam1,
  154. DWORD_PTR dwParam2,
  155. DWORD_PTR dwParam3
  156. );
  157. BOOL T30ComInit( PThrdGlbl pTG);
  158. PVOID T30AllocThreadGlobalData(VOID);
  159. BOOL T30Cl1Rx (PThrdGlbl pTG);
  160. BOOL T30Cl1Tx (PThrdGlbl pTG,LPSTR szPhone);
  161. USHORT
  162. T30ModemInit(PThrdGlbl pTG);
  163. BOOL itapi_async_setup(PThrdGlbl pTG);
  164. BOOL itapi_async_wait(PThrdGlbl pTG,DWORD dwRequestID,PDWORD lpdwParam2,PDWORD_PTR lpdwParam3,DWORD dwTimeout);
  165. BOOL itapi_async_signal(PThrdGlbl pTG, DWORD dwRequestID, DWORD dwParam2, DWORD_PTR dwParam3);
  166. LPLINECALLPARAMS itapi_create_linecallparams(void);
  167. void
  168. GetCommErrorNT(
  169. PThrdGlbl pTG
  170. );
  171. void
  172. ClearCommCache(
  173. PThrdGlbl pTG
  174. );
  175. UWORD FComStripBuf(PThrdGlbl pTG, LPB lpbOut, LPB lpbIn, UWORD cb, BOOL fClass2, LPSWORD lpswEOF, LPUWORD lpcbUsed);
  176. void InitCapsBC(PThrdGlbl pTG, LPBC lpbc, USHORT uSize, BCTYPE bctype);
  177. BOOL
  178. SignalStatusChange(
  179. PThrdGlbl pTG,
  180. DWORD StatusId
  181. );
  182. BOOL
  183. SignalStatusChangeWithStringId(
  184. PThrdGlbl pTG,
  185. DWORD StatusId,
  186. DWORD StringId
  187. );
  188. ////////////////////////////////////////////////////////////////////
  189. // Ansi prototypes
  190. ////////////////////////////////////////////////////////////////////
  191. VOID CALLBACK
  192. T30LineCallBackFunctionA(
  193. HANDLE hFax,
  194. DWORD hDevice,
  195. DWORD dwMessage,
  196. DWORD_PTR dwInstance,
  197. DWORD_PTR dwParam1,
  198. DWORD_PTR dwParam2,
  199. DWORD_PTR dwParam3
  200. );
  201. BOOL WINAPI
  202. FaxDevInitializeA(
  203. IN HLINEAPP LineAppHandle,
  204. IN HANDLE HeapHandle,
  205. OUT PFAX_LINECALLBACK *LineCallbackFunction,
  206. IN PFAX_SERVICE_CALLBACK FaxServiceCallback
  207. );
  208. BOOL WINAPI
  209. FaxDevStartJobA(
  210. HLINE LineHandle,
  211. DWORD DeviceId,
  212. PHANDLE pFaxHandle,
  213. HANDLE CompletionPortHandle,
  214. ULONG_PTR CompletionKey
  215. );
  216. BOOL WINAPI
  217. FaxDevEndJobA(
  218. HANDLE FaxHandle
  219. );
  220. BOOL WINAPI
  221. FaxDevSendA(
  222. IN HANDLE FaxHandle,
  223. IN PFAX_SEND_A FaxSend,
  224. IN PFAX_SEND_CALLBACK FaxSendCallback
  225. );
  226. BOOL WINAPI
  227. FaxDevReceiveA(
  228. HANDLE FaxHandle,
  229. HCALL CallHandle,
  230. PFAX_RECEIVE_A FaxReceive
  231. );
  232. BOOL WINAPI
  233. FaxDevReportStatusA(
  234. IN HANDLE FaxHandle OPTIONAL,
  235. OUT PFAX_DEV_STATUS FaxStatus,
  236. IN DWORD FaxStatusSize,
  237. OUT LPDWORD FaxStatusSizeRequired
  238. );
  239. BOOL WINAPI
  240. FaxDevAbortOperationA(
  241. HANDLE FaxHandle
  242. );
  243. HRESULT WINAPI
  244. FaxDevShutdownA();
  245. HANDLE
  246. TiffCreateW(
  247. LPWSTR FileName,
  248. DWORD CompressionType,
  249. DWORD ImageWidth,
  250. DWORD FillOrder,
  251. DWORD HiRes
  252. );
  253. HANDLE
  254. TiffOpenW(
  255. LPWSTR FileName,
  256. PTIFF_INFO TiffInfo,
  257. BOOL ReadOnly
  258. );
  259. // fast tiff
  260. DWORD
  261. TiffConvertThread(
  262. PThrdGlbl pTG
  263. );
  264. DWORD
  265. PageAckThread(
  266. PThrdGlbl pTG
  267. );
  268. DWORD
  269. ComputeCheckSum(
  270. LPDWORD BaseAddr,
  271. DWORD NumDwords
  272. );
  273. BOOL
  274. SignalRecoveryStatusChange(
  275. T30_RECOVERY_GLOB *Recovery
  276. );
  277. int
  278. SearchNewInfFile(
  279. PThrdGlbl pTG,
  280. char *Key1,
  281. char *Key2,
  282. BOOL fRead
  283. );
  284. int
  285. my_strcmp(
  286. LPSTR sz1,
  287. LPSTR sz2
  288. );
  289. void
  290. TalkToModem (
  291. PThrdGlbl pTG,
  292. BOOL fGetClass
  293. );
  294. BOOL
  295. SaveInf2Registry (
  296. PThrdGlbl pTG
  297. );
  298. BOOL
  299. SaveModemClass2Registry (
  300. PThrdGlbl pTG
  301. );
  302. BOOL
  303. ReadModemClassFromRegistry (
  304. PThrdGlbl pTG
  305. );
  306. VOID
  307. CleanModemInfStrings (
  308. PThrdGlbl pTG
  309. );
  310. BOOL
  311. RemoveCR (
  312. LPSTR sz
  313. );
  314. /*** BEGIN PROTOTYPES FROM CLASS2.c ***/
  315. BOOL
  316. T30Cl2Rx(
  317. PThrdGlbl pTG
  318. );
  319. BOOL
  320. T30Cl2Tx(
  321. PThrdGlbl pTG,
  322. LPSTR szPhone
  323. );
  324. BOOL Class2Send(PThrdGlbl pTG);
  325. BOOL Class2Receive(PThrdGlbl pTG);
  326. USHORT Class2Dial(PThrdGlbl pTG, LPSTR lpszDial);
  327. USHORT Class2Answer(PThrdGlbl pTG);
  328. SWORD Class2ModemSync(PThrdGlbl pTG);
  329. UWORD Class2iModemDialog(PThrdGlbl pTG, LPSTR szSend, UWORD uwLen, ULONG ulTimeout,
  330. UWORD uwRepeatCount, BOOL fLogSend, ...);
  331. BOOL Class2ModemHangup(PThrdGlbl pTG);
  332. BOOL Class2ModemAbort(PThrdGlbl pTG);
  333. SWORD Class2HayesSyncSpeed(PThrdGlbl pTG, C2PSTR cbszCommand, UWORD uwLen);
  334. USHORT Class2ModemRecvData(PThrdGlbl pTG, LPB lpb, USHORT cbMax, USHORT uTimeout,
  335. USHORT far* lpcbRecv);
  336. BOOL Class2ModemSendMem(PThrdGlbl pTG, LPBYTE lpb, USHORT uCount);
  337. DWORD Class2ModemDrain(PThrdGlbl pTG);
  338. USHORT Class2MinScanToBytesPerLine(PThrdGlbl pTG, BYTE Minscan, BYTE Baud, BYTE Resolution);
  339. BOOL Class2ResponseAction(PThrdGlbl pTG, LPPCB lpPcb);
  340. USHORT Class2ModemRecvBuf(PThrdGlbl pTG, LPBUFFER far* lplpbf, USHORT uTimeout);
  341. USHORT Class2EndPageResponseAction(PThrdGlbl pTG);
  342. BOOL Class2GetModemMaker(PThrdGlbl pTG);
  343. void Class2SetMFRSpecific(PThrdGlbl pTG);
  344. BOOL Class2Parse( PThrdGlbl pTG, CL2_COMM_ARRAY *, BYTE responsebuf[] );
  345. BOOL Class2UpdateTiffInfo(PThrdGlbl pTG, LPPCB lpPcb);
  346. BOOL Class2IsValidDCS(LPPCB lpPcb);
  347. void Class2InitBC(PThrdGlbl pTG, LPBC lpbc, USHORT uSize, BCTYPE bctype);
  348. void Class2PCBtoBC(PThrdGlbl pTG, LPBC lpbc, USHORT uMaxSize, LPPCB lppcb);
  349. void
  350. Class2SetDIS_DCSParams
  351. (
  352. PThrdGlbl pTG,
  353. BCTYPE bctype,
  354. OUT LPUWORD Encoding,
  355. OUT LPUWORD Resolution,
  356. OUT LPUWORD PageWidth,
  357. OUT LPUWORD PageLength,
  358. OUT LPSTR szID,
  359. UINT cch
  360. );
  361. void Class2BCHack(PThrdGlbl pTG);
  362. BOOL Class2GetBC(PThrdGlbl pTG, BCTYPE bctype);
  363. void cl2_flip_bytes( LPB lpb, DWORD dw);
  364. void Class2SignalFatalError(PThrdGlbl pTG);
  365. BOOL iModemGoClass(PThrdGlbl pTG, USHORT uClass);
  366. void
  367. Class2Init(
  368. PThrdGlbl pTG
  369. );
  370. BOOL
  371. Class2SetProtParams(
  372. PThrdGlbl pTG,
  373. LPPROTPARAMS lp
  374. );
  375. /*** BEGIN PROTOTYPES FROM CLASS2_0.c ***/
  376. BOOL
  377. T30Cl20Rx (
  378. PThrdGlbl pTG
  379. );
  380. BOOL
  381. T30Cl20Tx(
  382. PThrdGlbl pTG,
  383. LPSTR szPhone
  384. );
  385. BOOL Class20Send(PThrdGlbl pTG);
  386. BOOL Class20Receive(PThrdGlbl pTG);
  387. void
  388. Class20Init(
  389. PThrdGlbl pTG
  390. );
  391. BOOL Class20Parse( PThrdGlbl pTG, CL2_COMM_ARRAY *, BYTE responsebuf[] );