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.

1901 lines
66 KiB

  1. #ifndef _INC_IFAXOS
  2. #define _INC_IFAXOS
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. // add SHIP_BUILD from Win95fax retail builds
  7. #ifndef DEBUG
  8. #ifdef WIN32
  9. #define SHIP_BUILD
  10. #endif
  11. #endif
  12. // -------------------------- Include Files ------------------------------------
  13. #ifdef IFBGPROC
  14. // Remove appropriate parts of windows.h
  15. // #define NOKERNEL
  16. #ifndef WANTGDI
  17. #define NOGDI
  18. #endif
  19. // #define NOUSER
  20. #define NOSOUND
  21. // #define NOCOMM
  22. // #define NODRIVERS
  23. // #define NOMINMAX
  24. // #define NOLOGERROR
  25. // #define NOPROFILER
  26. // #define NOMEMMGR
  27. // #define NOLFILEIO
  28. // #define NOOPENFILE
  29. // #define NORESOURCE
  30. // #define NOATOM
  31. // #define NOLANGUAGE
  32. // #define NOLSTRING
  33. // #define NODBCS
  34. #define NOKEYBOARDINFO
  35. #define NOGDICAPMASKS
  36. #define NOCOLOR
  37. #ifndef WANTGDI
  38. #define NOGDIOBJ
  39. #define NOBITMAP
  40. #endif
  41. #define NODRAWTEXT
  42. #define NOTEXTMETRIC
  43. #define NOSCALABLEFONT
  44. #define NORASTEROPS
  45. #define NOMETAFILE
  46. #define NOSYSMETRICS
  47. #define NOSYSTEMPARAMSINFO
  48. // #define NOMSG
  49. #define NOWINSTYLES
  50. #define NOWINOFFSETS
  51. // #define NOSHOWWINDOW
  52. #define NODEFERWINDOWPOS
  53. #define NOVIRTUALKEYCODES
  54. #define NOKEYSTATES
  55. #define NOWH
  56. #define NOMENUS
  57. #define NOSCROLL
  58. #define NOCLIPBOARD
  59. #define NOICONS
  60. #define NOMB
  61. #define NOSYSCOMMANDS
  62. #define NOMDI
  63. #define NOCTLMGR
  64. #define NOWINMESSAGES
  65. #define NOHELP
  66. #endif
  67. // put strict type checking on ... and get rid of multiple define warnings
  68. #ifndef STRICT
  69. #define STRICT
  70. #endif
  71. #ifndef WINDRV
  72. # ifdef WIN32
  73. # define _INC_OLE
  74. # endif
  75. # include <windows.h>
  76. # ifdef WIN32
  77. # include <windowsx.h>
  78. # endif
  79. #endif
  80. #ifdef WIN32
  81. #define DECLSPEC_IMPORT __declspec(dllimport)
  82. #endif
  83. #ifndef WIN32
  84. // Define WINBASE to avoid mapi including some duplicate definitions
  85. #define _WINBASE_
  86. #endif
  87. //-------------------------- General Defines ---------------------
  88. #ifndef WIN32
  89. #define STATIC static
  90. #define CONST const
  91. #define CHAR char
  92. #define UCHAR BYTE
  93. #define INT int
  94. typedef short SHORT;
  95. typedef unsigned long ULONG;
  96. typedef unsigned short USHORT;
  97. typedef CHAR *PCHAR;
  98. typedef VOID *PVOID;
  99. #endif
  100. typedef CHAR FAR *LPCHAR;
  101. typedef CHAR NEAR *NPCHAR;
  102. #define CARRAIGE_RETURN 0x0D
  103. #define LINEFEED 0x0A
  104. #define BACKSPACE 0x08
  105. #define CNULL 0x00
  106. #ifndef WIN32
  107. #ifndef MAKEWORD
  108. # define MAKEWORD(low, high) ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << 8)))
  109. #endif
  110. # define EXPORT_DLL
  111. # define IMPORT_DLL
  112. #else
  113. # ifndef HTASK
  114. # define HTASK HANDLE
  115. # endif
  116. # define __export __declspec( dllexport )
  117. # define _export __declspec( dllexport )
  118. # define IMPORT_DLL __declspec( dllimport )
  119. # define EXPORT_DLL __declspec( dllexport )
  120. #endif
  121. // --------------- RESOURCE management -------------------------------
  122. // Always define this for now ...
  123. #ifndef SHIP_BUILD
  124. // #if defined(VALIDATE) || defined(DEBUGAPI) || defined(DEBUG)
  125. /********
  126. @doc EXTERNAL RESOURCE IFAXOS
  127. @type VOID | RESOURCE_ALLOC_FLAGS | Lists the resource management options
  128. for OS resource accounting.
  129. @emem RES_ALLOC_TASK | This flag indicates that the resource in question
  130. is being allocated on behalf of the current process. The resource
  131. should not be directly passed on to any other process context. It
  132. should be freed by this process before termination - else the kernel
  133. will free it when the process dies (if running in debug).
  134. Ownership automatically gets transferred between tasks when standard
  135. IPC methods like pipes are used to transfer resources like Buffers.
  136. @emem RES_ALLOC_NONE | This flag is used to allocate resources which should
  137. not be accounted to any system module. The calling party essentially
  138. undertakes full responsibility for freeing this object. This is mainly
  139. to be used for resource allocated on behalf of messages in the store
  140. since their ownership is transferred to the current process which has
  141. the message open.
  142. @emem HINSTANCE_DLL | If the allocated resource is to be assigned to the
  143. calling DLL, the hinstance of the DLL should be passed in as the value
  144. of the ResourceFlags Word. These resources will be freed (in the debug
  145. version) when the DLL terminates. They will not be assigned to any
  146. particular process context.
  147. @xref <f IFBufAlloc> <f IFMemAlloc> <f CreateMutex> <f CreateEvent>
  148. <f IFPipeCreate> <f IFProcSetResFlags>
  149. ********/
  150. #define RES_ALLOC_TASK 0x0000
  151. #define RES_ALLOC_NONE 0x0001
  152. #define RES_ALLOC_INTERNAL 0x0002
  153. #define RES_ALLOC_CRITSEC 0x0003
  154. #if defined(WFW) || defined(WIN32)
  155. #define IFProcSetResFlags(wResFlags) (0)
  156. #else
  157. extern EXPORT_DLL VOID WINAPI IFProcSetResFlags(WORD wResFlags);
  158. #endif
  159. #else
  160. #define IFProcSetResFlags(p1) (0)
  161. #endif
  162. // --------------- ERROR Handling ------------------------------------
  163. #include <errormod.h>
  164. /********
  165. @doc EXTERNAL ERROR IFAXOS
  166. @api DWORD | IFErrAssemble | Forms an IFAX Error dword out of its components.
  167. @parm BYTE | bProcessID | Identifies the process in whose context the error
  168. occured. Must be one of the predefined system process ID's - see <t SYSTEM_PROCESSES>
  169. for the list. This field does not need to be filled in until an error is
  170. propagated across a process boundary. If not being set to a valid PROCID, this
  171. should be initilialized to one of the following values:
  172. @flag PROCID_WIN32 | if <p bModuleID> is set to MODID_WIN32.
  173. @flag PROCID_NONE | for all other cases.
  174. @parm BYTE | bModuleID | Identifies the module reporting the error. MUST be
  175. one of the predefined system module ID's - see <t SYSTEM_MODULES> for the
  176. list.
  177. @parm WORD | wApiCode | Identifies the API code for the error in the module indicated
  178. by <p bModuleID>. All Api codes should be defined in the file errormod.h. Api codes should
  179. be defined so that the low 6 bits are zero. This allows both the <p wApiCode> and the
  180. <p wErrorCode> to be logical OR'ed together and stored as a single word.
  181. @parm WORD | wErrorCode | Identifies the error code. The format
  182. of this is module dependent. For uniformity however, it is highly
  183. encouraged that all IFAX modules use a standard format for this error word.
  184. This standard format reserves the first 6 bits for an error code,
  185. and the high 10 bits for an API identifier.
  186. If the IFAX format is being used, the <p wApiCode>
  187. parameter should be used to pass in the high 10 bits, and the <p wErrorCode> (This
  188. parameter!) should be used to pass in the 6 bit error code. Values upto ERR_FUNCTION_START
  189. are reserved for standard system errors - see <t SYSTEM_ERROR_VALUES> for the list.
  190. Error values should be positive and less than 64.
  191. Other modules like the filesystem conform completely to the Win32 Error space. These
  192. should set <p wErrorCode> to standard Win32 errors (use all 16 bits) and leave
  193. the <p wApiCode> as API_WIN32.
  194. Still others need to use all 16 bits in a custom manner - like the Printer Drivers.
  195. These *must* set the <p bModuleID> correctly so that the error can be interpreted
  196. appropriately. Standard processes like the UI have to understand these error codes,
  197. so only inbuilt system modules which they have knowledge about can use custom codes.
  198. These should set the wApiCode to API_NONE.
  199. @rdesc Returns the DWORD representation for this error. This allows this to be directly
  200. passed in as input to <f SetLastError>.
  201. @ex Example usage |
  202. SetLastError(IFErrAssemble(PROCID_NONE,MODID_IFKERNEL,API_IFK_POSTMESSAGE,ERR_INVALID_PARAM));
  203. @xref <f IFErrGetModule> <f IFErrGetProcess> <f GetIFErrorErrcode> <f SetLastError>
  204. <f GetIFErrorApicode> <t SYSTEM_MODULES> <t SYSTEM_PROCESSES> <t SYSTEM_ERROR_VALUES>
  205. <f GetLastError> <f IFNVRamSetError> <f GetIFErrorCustomErrcode>
  206. ********/
  207. #define IFErrAssemble(process,module,call,error) \
  208. MAKELONG((WORD)call|(WORD)error, MAKEWORD((BYTE)module, (BYTE)process))
  209. /*********
  210. @doc EXTERNAL ERROR IFAXOS
  211. @api BYTE | IFErrGetModule | Retrieves the module ID from an IFAX Error.
  212. @parm DWORD | errvar | The error value.
  213. @rdesc Returns the module ID. This will be from the list specified in <t SYSTEM_MODULES>.
  214. @xref <f IFErrAssemble> <t SYSTEM_MODULES> <f IFErrSetModule>
  215. @api BYTE | IFErrGetProcess | Retrieves the process ID from an IFAX Error.
  216. @parm DWORD | errvar | The error value.
  217. @rdesc Returns the process ID. This will be from the list specified in <t SYSTEM_PROCESSES>.
  218. @xref <f IFErrAssemble> <t SYSTEM_PROCESSES> <f IFErrSetProcess>
  219. @api WORD | GetIFErrorErrcode | Retrieves the error code from an IFAX Error.
  220. @parm DWORD | errvar | The error value.
  221. @rdesc Returns the error code. If less than ERR_FUNCTION_START, this is from the list
  222. in <t SYSTEM_ERROR_VALUES>.
  223. @xref <f IFErrAssemble> <t SYSTEM_ERROR_VALUES>
  224. @api WORD | GetIFErrorCustomErrcode | Retrieves a custom 16 bit error code from an IFAX Error.
  225. @parm DWORD | errvar | The error value.
  226. @rdesc Returns the error code. This might be a Win32 error code if the module ID was
  227. MODID_WIN32, or a custom error code.
  228. @xref <f IFErrAssemble> <t SYSTEM_ERROR_VALUES>
  229. @api WORD | GetIFErrorApicode | Retrieves the API code from an IFAX Error.
  230. @parm DWORD | errvar | The error value.
  231. @rdesc Returns the API code. API codes for all the system modules are documented in
  232. the file errormod.h
  233. @xref <f IFErrAssemble> <t SYSTEM_MODULES>
  234. @api DWORD | IFErrSetModule | Sets the module ID in an IFAX Error.
  235. @parm DWORD | errvar | The error value. It's value is not changed by the call.
  236. @parm BYTE | bModule | The module ID to be set from the list in <t SYSTEM_MODULES>.
  237. @rdesc Returns the DWORD representation of the new error code.
  238. @xref <f IFErrAssemble> <t SYSTEM_MODULES> <f IFErrGetModule>
  239. @api DWORD | IFErrSetProcess | Sets the Process ID in an IFAX Error.
  240. @parm DWORD | errvar | The error value. Its value is not changed by the call.
  241. @parm BYTE | bProcess | The Process ID to be set from the list in <t SYSTEM_PROCESSES>.
  242. @rdesc Returns the DWORD representation of the new error code.
  243. @xref <f IFErrAssemble> <t SYSTEM_PROCESSES> <f IFErrGetProcess>
  244. ********/
  245. #define IFErrSetModule(errvar,module) \
  246. MAKELONG(LOWORD((DWORD)errvar),MAKEWORD((BYTE)module, HIBYTE(HIWORD((DWORD)errvar))))
  247. #define IFErrSetProcess(errvar,process) \
  248. MAKELONG(LOWORD((DWORD)errvar),MAKEWORD(LOBYTE(HIWORD((DWORD)errvar)), (BYTE)process))
  249. #define IFErrGetModule(errvar) LOBYTE(HIWORD((DWORD)errvar))
  250. #define IFErrGetProcess(errvar) HIBYTE(HIWORD((DWORD)errvar))
  251. #define GetIFErrorErrcode(errvar) (LOWORD((DWORD)errvar) & 0x003F)
  252. #define GetIFErrorApicode(errvar) (LOWORD((DWORD)errvar) & 0xFFC0)
  253. #define GetIFErrorCustomErrcode(errvar) LOWORD((DWORD)errvar)
  254. /********
  255. @doc EXTERNAL DEFINES ERROR IFAXOS
  256. @type VOID | SYSTEM_MODULES | Identifiers for all the standard system modules.
  257. @emem MODID_NONE | Use this if you are not setting the module ID. DONT USE ZERO !!
  258. @emem MODID_WIN32 | Set for modules returning standard Win32 system error codes
  259. @emem MODID_BOSS | ID = 1 Error in BOSS
  260. @emem MODID_WINMODULE | ID = 2 All windows modules including UER/GDI/KERNEL
  261. @emem MODID_IFKERNEL | ID = 3
  262. @emem MODID_IFFILESYS | ID = 4
  263. @emem MODID_MSGSTORE | ID = 5
  264. @emem MODID_LINEARIZER | ID = 6
  265. @emem MODID_SECURITY | ID = 7
  266. @emem MODID_IFPRINT | ID = 8 High level Printer Driver
  267. @emem MODID_IFSCAN | ID = 9 High level Scanner Driver
  268. @emem MODID_IFSIPX | ID = 10 SPX/IPX Stack
  269. @emem MODID_REND_SERVER | ID = 11 Rendering Server
  270. @emem MODID_FORMAT_RES | ID = 12 Format Resolution
  271. @emem MODID_IFFILE | ID = 13 IFFiles
  272. @emem MODID_TEXTRENDERER | ID = 14 Ascii Renderer
  273. @emem MODID_DIGCOVPAGE | ID = 15 Digital Coverpage
  274. @emem MODID_AWBRANDER | ID = 16 Fax Brander
  275. @emem MODID_MSGSVR | ID = 17 Message Server
  276. @emem MODID_MSGHNDLR | ID = 18 Per-Connection message handler
  277. @emem MODID_MODEMDRV | ID = 19 Modem driver
  278. @emem MODID_PSIFAX | ID = 20 PSI Fax protocol
  279. @emem MODID_AWT30 | ID = 21
  280. @emem MODID_PSIFAXBG | ID = 22
  281. @emem MODID_AWNSF | ID = 23
  282. @emem MODID_FAXCODEC | ID = 24
  283. @emem MODID_MSGPUMP | ID = 25
  284. @emem MODID_AWREPORT | ID = 26
  285. @emem MODID_MSGSVRD | ID = 27
  286. @emem MODID_CUSTOM | ID = 160 Beyond this are custom/installable modules
  287. @xref <f IFErrAssemble> <f IFErrGetModule>
  288. ********/
  289. // System Module IDs
  290. #define MODID_WIN32 0
  291. #define MODID_BOSS 1
  292. #define MODID_WINMODULE 2
  293. #define MODID_IFKERNEL 3
  294. #define MODID_IFFILESYS 4
  295. #define MODID_MSGSTORE 5
  296. #define MODID_LINEARIZER 6
  297. #define MODID_SECURITY 7
  298. #define MODID_IFPRINT 8
  299. #define MODID_IFSCAN 9
  300. #define MODID_IFSIPX 10
  301. #define MODID_REND_SERVER 11
  302. #define MODID_FORMAT_RES 12
  303. #define MODID_IFFILE 13
  304. #define MODID_TEXTRENDERER 14
  305. #define MODID_DIGCOVPAGE 15
  306. #define MODID_AWBRANDER 16
  307. #define MODID_MSGSVR 17
  308. #define MODID_MSGHNDLR 18
  309. #define MODID_MODEMDRV 19
  310. #define MODID_PSIFAX 20
  311. #define MODID_AWT30 21
  312. #define MODID_PSIFAXBG 22
  313. #define MODID_AWNSF 23
  314. #define MODID_FAXCODEC 24
  315. #define MODID_MSGPUMP 25
  316. #define MODID_AWREPORT 26
  317. #define MODID_MSGSVRD 27
  318. #define MAXMODID 26
  319. #define MODID_NONE 159
  320. // Special module ID's
  321. #define MODID_CUSTOM 160
  322. // Strings used in debug version for friendly display
  323. #define SYSMODULESTRINGS \
  324. { "Win32", "Boss", "Windows", "IFKernel", "FileSystem", "Msg Store", "Linearizer", \
  325. "Security", "HLPrintDriver", "HLScanDriver", "IPX/SPX", "RendServer", \
  326. "Format Res", "IFFile", "AsciiRenderer","DigCovPage","AWBrander", \
  327. "Msg Server", "Msg Handler", "Modem Driver", "PSIFAX", "AWT30", \
  328. "PSIFAXBG", "AWNSF", "Fax Codec", "Msg Pump" , "Awreport" \
  329. }
  330. /********
  331. @doc EXTERNAL DEFINES ERROR IFAXOS
  332. @type VOID | SYSTEM_PROCESSES | Identifiers for all the standard system processes.
  333. @emem PROCID_WIN32 | Used to initialize for Win32 modules.
  334. @emem PROCID_NONE | Used when process context does not need to be set.
  335. @emem PROCID_MSGSCHED | ID = 0x21
  336. @emem PROCID_JOBPROCESS | ID = 0x22
  337. @emem PROCID_UI | ID = 0x23
  338. @emem PROCID_PRINTER | ID = 0x24
  339. @emem PROCID_SCANNER | ID = 0x25
  340. @emem PROCID_MSGSVR | ID = 0x26
  341. @emem PROCID_GRRENDER | ID = 0x27
  342. @emem PROCID_MSGHNDLR | ID = 0x28
  343. @emem PROCID_PARADEV | ID = 0x29
  344. @emem PROCID_UIBGPROC | ID = 0x30
  345. @comm All Process ID's need to have the 6th bit set to be compatible with the
  346. standard Win32 error definitions.
  347. @xref <f IFErrAssemble> <f IFErrGetProcess>
  348. ********/
  349. // System Process IDs
  350. #define PROCID_WIN32 0x00
  351. #define PROCID_NONE 0x20
  352. #define PROCID_MSGSCHED 0x21
  353. #define PROCID_JOBPROCESS 0x22
  354. #define PROCID_UI 0x23
  355. #define PROCID_PRINTER 0x24
  356. #define PROCID_SCANNER 0x25
  357. #define PROCID_MSGSVR 0x26
  358. #define PROCID_GRRENDER 0x27
  359. #define PROCID_MSGHNDLR 0x28
  360. #define PROCID_PARADEV 0x29
  361. #define PROCID_UIBGPROC 0x30
  362. // Strings used in debug version for friendly display
  363. #define MAXPROCID 11
  364. #define SYSPROCESSSTRINGS \
  365. {"None", "Msg Scheduler", "Job Process", "UI Process", "Printer", "Scanner", \
  366. "Msg Transport", "GR Renderer", "Msg Handler", "Para Dev", "UIBGProc" }
  367. /********
  368. @doc EXTERNAL DEFINES ERROR IFAXOS
  369. @type VOID | SYSTEM_ERROR_VALUES | This defines all the standard
  370. system error values.
  371. @emem ERR_NOT_ENOUGH_MEM | Value = 0x0001 : Indicates an out of memory
  372. condition.
  373. @emem ERR_INVALID_PARAM | Value = 0x0002 : Indicates that any one of
  374. the parameters passed to the function was invalid.
  375. @emem ERR_FUNCTION_START | Value = 0x0010 : Any error value above this
  376. had been custom defined by the called function. If you need
  377. a custom error value, you can define it starting from this
  378. value.
  379. @xref <f IFErrAssemble>
  380. ********/
  381. // System Error values
  382. #define ERR_NOT_ENOUGH_MEM 0x0001
  383. #define ERR_INVALID_PARAM 0x0002
  384. #define ERR_FUNCTION_START 0x0010
  385. // Strings used in debug version for friendly display
  386. #define SYSERRORSTRINGS \
  387. {"None", "Out Of Memory", "Invalid Param", "Unused", "Unused", "Unused", \
  388. "Unused", "Unused", "Unused", "Unused", "Unused", "Unused", \
  389. "Unused", "Unused", "Unused", "Unused" }
  390. // Functions
  391. #if !defined(SHIP_BUILD) && !defined(WIN32)
  392. VOID WINAPI RestoreLastError (DWORD dwErrVal);
  393. #else
  394. #define RestoreLastError(dw) SetLastError(dw)
  395. #endif
  396. #ifndef WIN32
  397. VOID WINAPI SetLastError (DWORD dwErrVal);
  398. DWORD WINAPI GetLastError (VOID);
  399. #endif
  400. //----------------------------- MESSAGING -------------------------
  401. // Message type definitions - below 0x0400 is reserved by windows,
  402. // between 0x0400 and 0x0800 is reserved by the IFAX OS
  403. #define IF_START WM_USER+0x0300
  404. #define IF_TASK_START IF_START+0x0001
  405. #define IF_TASK_END IF_START+0x0020
  406. #define IF_DEBUG_START IF_START+0x0021
  407. #define IF_DEBUG_END IF_START+0x0040
  408. #define IF_PIPES_START IF_START+0x0041
  409. #define IF_PIPES_END IF_START+0x0060
  410. #define IF_TIMER_START IF_START+0x0081
  411. #define IF_TIMER_END IF_START+0x0090
  412. #define IF_USER IF_START+0x0400
  413. //messages for printer and scanner
  414. #define IF_SCANNER_START IF_START+0x0200
  415. #define IF_SCANNER_END IF_START+0x0220
  416. //messages for the graphics renderer
  417. #define IF_GRRENDER_START IF_START+0x0221
  418. #define IF_GRRENDER_END IF_START+0x0230
  419. //messages for the faxcodec renderer
  420. #define IF_FAXREND_START IF_START+0x0231
  421. #define IF_FAXREND_END IF_START+0x0235
  422. //messages for the message pump
  423. #define IF_MSGPUMP_START (IF_START+0x0250)
  424. #define IF_MSGPUMP_END (IF_START+0x029F)
  425. //messages for devices
  426. #define IF_DEVICE_START (IF_START+0x02B0)
  427. #define IF_DEVICE_END (IF_START+0x02CF)
  428. // Message for UI Init
  429. #define IF_UI_START (IF_START+0x2F0)
  430. #define IF_UI_END (IF_START+0x300)
  431. // Status
  432. #define IF_STATUS_START (IF_START+0x301)
  433. #define IF_STATUS_END (IF_START+0x310)
  434. // Config
  435. #define IF_CONFIG_START (IF_START+0x311)
  436. #define IF_CONFIG_END (IF_START+0x320)
  437. // Modem
  438. #define IF_MODEM_START (IF_START+0x321)
  439. #define IF_MODEM_END (IF_START+0x325)
  440. // PSIBG
  441. #define IF_PSIBG_START (IF_START+0x330)
  442. #define IF_PSIBG_END (IF_START+0x339)
  443. // PSIFAX
  444. #define IF_PSIFAX_START (IF_START+0x340)
  445. #define IF_PSIFAX_END (IF_START+0x349)
  446. // MSGSVR
  447. #define IF_MSGSVR_START (IF_START+0x350)
  448. #define IF_MSGSVR_END (IF_START+0x369)
  449. // OEM
  450. #define IF_OEM_START (IF_START+0x370)
  451. #define IF_OEM_END (IF_START+0x379)
  452. // SOS
  453. #define IF_SOS_START (IF_START+0x380)
  454. #define IF_SOS_END (IF_START+0x38F)
  455. // uiutil
  456. #define IF_UU_START (IF_START+0x390)
  457. #define IF_UU_END (IF_START+0x39F)
  458. // parallel device
  459. #define IF_PD_START (IF_START+0x3A0)
  460. #define IF_PD_END (IF_START+0x3BF)
  461. // RPC layer
  462. #define IF_RPC_START (IF_START+0x3C0)
  463. #define IF_RPC_END (IF_START+0x3CF)
  464. //UIBGProc
  465. #define IF_UIBGPROC_START (IF_START+0x3D0)
  466. #define IF_UIBGPROC_END (IF_START+0x3DF)
  467. // services
  468. #define IF_SERVICE_START (IF_START+0x3E0)
  469. #define IF_SERVICE_END (IF_START+0x3EF)
  470. /********
  471. @doc EXTERNAL MESSAGES PROCESS IFAXOS
  472. @msg IF_INIT_STATUS | This message should be posted by all devices
  473. after initialization is complete to indicate success/failure.
  474. Typically, the device process will send an IF_INIT_STATUS
  475. message for every device it initializes and one for its own
  476. initilization. This message should be posted to the UISHELL
  477. process. Use <f IFProcGetInfo> to obtain the appropriate window handle.
  478. @parm WPARAM | wParam | 16 bit device error.
  479. @parm LPARAM | lParam | Is formed as MAKELPARAM(MAKEWORD
  480. (ucInitStatus,ucMinorDevId),MAKEWORD(ucMajorDevId,ucProcId))
  481. @flag INIT_NO_ERROR | There was no error.
  482. @flag INIT_FATAL_ERROR| There was a fatal error. System should reboot.
  483. @flag INIT_WARNING_ERROR | There were some errors, but the system doesnt need
  484. to reboot.
  485. @parm LPARAM | lParam | Contains a standard IFAX Error code. See
  486. <f IFErrAssemble> for details.
  487. @xref <f IFProcGetInfo> <f IFErrAssemble>
  488. ********/
  489. #define INIT_NO_ERROR 0x00
  490. #define INIT_FATAL_ERROR 0x01
  491. #define INIT_WARNING_ERROR 0x02
  492. #define IF_INIT_STATUS IF_UI_START
  493. /********
  494. @doc EXTERNAL MESSAGES PROCESS IFAXOS
  495. @msg IF_DEVREINIT | This message will be posted by the uishell to
  496. device process that handle user errors if the initialization
  497. fails due to user errors.
  498. @parm WPARAM | wParam | MAKEWORD(ucMinorDevId,ucMajorDevId)
  499. @xref <f IFProcGetInfo> <f IFErrAssemble>
  500. ********/
  501. #define IF_DEVREINIT IF_UI_START+1
  502. // Functions --------
  503. BOOL WINAPI BroadcastMessage (UINT uMsg, WPARAM wParam, LPARAM lParam);
  504. BOOL WINAPI BroadcastMessageEx (UINT uMsg, WPARAM wParam, LPARAM lParam);
  505. // Dispatch message for BG Procs
  506. /********
  507. @doc EXTERNAL MESSAGE MACROS IFAXOS
  508. @api VOID | DispatchMessage | Dispatches a message to your
  509. windows procedure.
  510. @parm LPMSG | lpMsg | Ptr to a message struct which is to be
  511. dispatched. This parameter *must* be &msg for all IFAX
  512. background processes - i.e you must have a declared variable
  513. called "msg" into which you have previsouly retrieved the
  514. message using <f GetMessage>.
  515. @comm This function dispatches a message to your windows procedure.
  516. For foreground processes this works exactly the way the standard
  517. Windows DispatchMessage works. For background processes
  518. (which dont have any explicit windows) the message is sent to
  519. a procedure called BGWindowProc. You *must* have a callback
  520. defined as this - see BGWindowProc for details.
  521. @cb LRESULT BGCALLBACK | BGWindowProc | This is the window procedure
  522. for all IFAX background processes. The functions *must* be called
  523. by this exact name. This callback is not relevant for foreground
  524. processes.
  525. @parm HWND | hwnd | contains the handle of the window to which the
  526. message is being dispatched. For Background processes this will always
  527. be the same as that returned from <f IFProcGetInfo>.
  528. @parm UINT | message | the message id
  529. @parm WPARAM | wParam | the first parameter associated with the message
  530. @parm LPARAM | lParam | The second parameter associated with the message
  531. @rdesc The return value depends on the message being processed.
  532. @comm A protoype for this is already declared in ifaxos.h. You should
  533. process all your messages inside this window procedure. Your
  534. main application loop should thus look like
  535. while (GetMessage(&msg,NULL,0,0))
  536. {
  537. DispatchMessage(&msg);
  538. }
  539. return;
  540. You should *not* export this procedure in your .def file.
  541. @xref <f GetMessage>
  542. ********/
  543. #ifdef IFBGPROC
  544. #define DispatchMessage(pmsg) BGWindowProc((pmsg)->hwnd,(pmsg)->message,(pmsg)->wParam,(pmsg)->lParam)
  545. #define BGCALLBACK PASCAL
  546. LRESULT BGCALLBACK BGWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  547. #endif
  548. //----------------------------- TASK MANAGEMENT--------------------
  549. /********
  550. @doc EXTERNAL PROCESS MACROS IFAXOS
  551. @api VOID | ENTER_INT_CRIT_SECTION | Macro to enter
  552. an interrupt critical section.
  553. @comm This is an inline assembly macro which turns interrupts
  554. off. Needless to say, this must be used with extreme
  555. caution. There must be a matching call to
  556. <f EXIT_INT_CRIT_SECTION>. Nested pairs of calls
  557. to these are permitted as long as they are not within the
  558. same invocation of the function. The function relies on
  559. being able to save the previous state of the flags in a
  560. unique local variable called __wIntFlags.
  561. This might affect some optimization options in your
  562. function due to being inline assembly. You might want to
  563. declare a local function which calls this macro internally.
  564. This way you can get global optimzations in the calling
  565. functions.
  566. @xref <f EXIT_INT_CRIT_SECTION> <f IFProcEnterCritSec>
  567. <f IFProcExitCritSec>
  568. ********/
  569. // Macros --------
  570. #define ENTER_INT_CRIT_SECTION \
  571. { \
  572. _asm pushf \
  573. _asm cli \
  574. _asm pop __wIntFlags \
  575. }
  576. /********
  577. @doc EXTERNAL PROCESS MACROS IFAXOS
  578. @api VOID | EXIT_INT_CRIT_SECTION | Macro to exit
  579. an interrupt critical section.
  580. @comm This is an inline assembly macro which sets the interrupt
  581. flag state back to its state before the last call to
  582. <f ENTER_INT_CRIT_SECTION>. This function relies on the
  583. appropriate flags to have been saved in a local variable
  584. with the name __wIntFlags.
  585. @xref <f ENTER_INT_CRIT_SECTION> <f IFProcEnterCritSec>
  586. <f IFProcExitCritSec>
  587. ********/
  588. // defined this way so that it works with windows enhanced mode
  589. // refer guide to programming pg 14-15
  590. #define EXIT_INT_CRIT_SECTION \
  591. { \
  592. _asm mov ax, __wIntFlags \
  593. _asm test ah,2 \
  594. _asm jz $+3 \
  595. _asm sti \
  596. _asm NOP \
  597. }
  598. /********
  599. @doc EXTERNAL DEFINES ERROR IFAXOS
  600. @type VOID | PRIORITY DEFINES | System defined priority levels
  601. @emem PROC_PRIORITY_CRITICALRT | This should be used very sparingly
  602. for tasks which have very critical real time constraints (less
  603. than 200ms). These processes should typically be very low bandwidth
  604. since they can easily starve other processes.
  605. @emem PROC_PRIORITY_HIGHRT | Tasks with latency requirements of less than
  606. a second. Should not be high bandwidth to avoid starvation of processes.
  607. @emem PROC_PRIORITY_MEDRT | Tasks with latency requirements of 1-3 secs.
  608. Should not be high bandwidth to avoid starvation of processes.
  609. @emem PROC_PRIORITY_LOWRT | Tasks with latencies of 3-30secs. Should not
  610. be high bandwidth.
  611. @emem PROC_PRIORITY_DEFAULT | The default priority tasks start out at. These
  612. processes have none or very low real time requirements. They should
  613. in general not have high bandwidth.
  614. @emem PROC_PRIORITY_NONRT_USERVISIBLE | Non real time tasks which have visibility
  615. at the user level. Can be high bandwidth. An example on a fax machine is
  616. a copy job.
  617. @emem PROC_PRIORITY_NONRT_USERHIDDEN | Non real time tasks which have very little
  618. visibility at the user level. Examples on a fax machine are local jobs
  619. not involving devices. Can be high bandwidth.
  620. @comm Processes should be VERY careful in setting their priorities. The way the
  621. current scheduling works it is very easy to cause starvation of low
  622. priority processes. In particular, processes which are "high bandwidth" - ie
  623. those which can consume huge amounts of CPU time if given, should be very
  624. careful - and should in general be at a priority level lower than the default.
  625. Processes higher than the default should have some sontrols on how much cpu
  626. time they can use up. On the fax machine, such controls are mostly in the form
  627. of device througputs - like the phone line.
  628. @xref <f IFProcSetPriority> <f IFProcGetPriority>
  629. ********/
  630. #define PROC_PRIORITY_MIN 31
  631. #define PROC_PRIORITY_MAX 1
  632. #define PROC_PRIORITY_CRITICALRT 3
  633. #define PROC_PRIORITY_HIGHRT 6
  634. #define PROC_PRIORITY_MEDRT 9
  635. #define PROC_PRIORITY_LOWRT 12
  636. #define PROC_PRIORITY_DEFAULT 15
  637. #define PROC_PRIORITY_NONRT_USERVISIBLE 18
  638. #define PROC_PRIORITY_NONRT_USERHIDDEN 21
  639. #define UAE_BOX 0
  640. #define NO_UAE_BOX 1
  641. ///// Specific priorities used by standard processes ////
  642. //
  643. // We want the following relations to hold
  644. // PSIFAXBG > everything else, cause it's low-latency, low-bandwidth
  645. // ModemJob related (med bandwidth) > all other high/med bandwith jobs
  646. // DeviceJob related (high bandwidth, NO latency reqs) < all other jobs except Spool jobs
  647. // SpoolJobs (high bandwidth NO latency reqs, not user-visible) < everything
  648. // MSCHED is as high as ModemJob prio when it is on critical path, otherwise
  649. // it stays at default. Higher than Dev & Spool jobs, lower than all else
  650. // COMMSRV (pretty low latency reqs, high bandwidth) is slightly higher than
  651. // default (Higher than MSCHED & Dev/Spool jobs, lower than modem jobs)
  652. // RPCHNDLR (pretty lax latency reqs, high bandwidth) dynamic
  653. // Same prio as MSCHED while working, same as COMMSRV during accept
  654. // MSGSVR & RPCSRV (lowish latency reqs, very low bandwidth) roundrobin
  655. // with ModemJob, higher than all else
  656. // REPORT bg proc slightly lower than default.
  657. // PSIFAXBG prio is highest
  658. #define PRIO_PSIFAXBG_ACTIVE PROC_PRIORITY_CRITICALRT
  659. #define PRIO_PSIFAXBG_IDLE PROC_PRIORITY_DEFAULT
  660. // ModemJob is 2nd highest
  661. #define PRIO_MODEMJOB PROC_PRIORITY_MEDRT
  662. // Spooljob is LOWEST, Device jobs are second lowest
  663. #define PRIO_SPOOLJOB PROC_PRIORITY_NONRT_USERHIDDEN
  664. #define PRIO_DEVICEJOB PROC_PRIORITY_NONRT_USERVISIBLE
  665. // PSINET jobs are same prio as SPOOL jobs
  666. #define PRIO_PSINETJOB PRIO_SPOOLJOB
  667. // MSCHED's prio when it is NOT on a MODEMJOB critical path
  668. #define PRIO_MSCHED PROC_PRIORITY_DEFAULT
  669. // COMMSRV is between MODEMJOB & MSCHED
  670. #define PRIO_COMMSRV PROC_PRIORITY_LOWRT
  671. // RPCHNDLR is same as MSCHED while working
  672. #define PRIO_RPCHNDLR_ACCEPT PROC_PRIORITY_LOWRT
  673. #define PRIO_RPCHNDLR_WORKING PROC_PRIORITY_DEFAULT
  674. // RPCSRV is same as MODEMJOB. It should NOT consume much CPU at this level!
  675. #define PRIO_RPCSRV PROC_PRIORITY_MEDRT
  676. // MSGSVR is same as MODEMJOB, except when processing recovery msgs
  677. #define PRIO_MSGSVR_WAITMSG PROC_PRIORITY_MEDRT
  678. #define PRIO_MSGSVR_RECOVERY PROC_PRIORITY_NONRT_USERVISIBLE
  679. // Report process is real low prio when doing background info assimilation
  680. // slightly higher when doing work on user request.
  681. #define PRIO_UIBGPROC PROC_PRIORITY_NONRT_USERHIDDEN
  682. #define PRIO_UIBGPROC_USERREQUEST PROC_PRIORITY_NONRT_USERVISIBLE
  683. /********
  684. @doc EXTERNAL MESSAGES PROCESS IFAXOS
  685. @msg IF_QUIT | This is the message which forces <f GetMessage>
  686. to return FALSE causing the process to exit its main message
  687. processing loop and terminate. Typically a process should
  688. post itself this message in response to a <m IF_EXIT> message.
  689. @parm WPARAM | wParam | NULL
  690. @parm LPARAM | lParam | NULL
  691. @rdesc none
  692. @xref <m IF_EXIT>
  693. @msg IF_EXIT | This message is sent to a process to request it
  694. to terminate. An application should clean up any resources
  695. it has allocated and then post itself a <m IF_QUIT> message
  696. directly.
  697. @parm WPARAM | wParam | NULL
  698. @parm LPARAM | lParam | NULL
  699. @rdesc none
  700. @xref <m IF_QUIT>
  701. ********/
  702. // Messages
  703. #define IF_QUIT IF_TASK_START
  704. #define IF_EXIT IF_TASK_START+1
  705. // Functions -----------
  706. #ifndef WIN32
  707. HTASK WINAPI GetWindowTask(HWND hwnd);
  708. #ifndef SHIP_BUILD
  709. DWORD WINAPI IFProcProfile(HTASK hTask, BOOL fStart);
  710. #else
  711. #define IFProcProfile(HTASK,FSTART) (0)
  712. #endif
  713. #else
  714. // Remove calls to Profile ..
  715. #define IFProcProfile(x,y) (DWORD)(0)
  716. #endif
  717. HTASK WINAPI IFProcCreate (LPSTR lpszAppName, UINT fuCmdShow);
  718. VOID WINAPI IFProcTerminate (HTASK hTask, WORD wFlags);
  719. VOID WINAPI IFProcEnterCritSec(VOID);
  720. VOID WINAPI IFProcExitCritSec(VOID);
  721. BOOL WINAPI IFProcChangeToFG(VOID);
  722. BOOL WINAPI IFProcChangeToBG(VOID);
  723. HWND WINAPI IFProcGetInfo (HTASK FAR *lphTask, LPSTR lpszModule, HINSTANCE FAR *lphInst);
  724. BOOL WINAPI IFProcRegisterWindow (HWND hwnd);
  725. WORD WINAPI IFProcGetPriority (HTASK hTask);
  726. BOOL WINAPI IFProcSetPriority (HTASK hTask, WORD wPriority);
  727. #ifndef NOBUFFERS
  728. //----------------------------- BUFFERS -------------------------
  729. // Moved BUFFER typedef and standard meta-data values to buffers.h! -RajeevD
  730. #include <buffers.h>
  731. #ifdef VALIDATE
  732. #define BUF_SENTINELPOS 30
  733. #endif
  734. // Error values
  735. #define ERR_DATA_SMALL ERR_FUNCTION_START
  736. // Functions
  737. extern LPBUFFER IFBufAlloc (LONG lBufSize);
  738. extern BOOL IFBufFree (LPBUFFER lpbf);
  739. extern EXPORT_DLL LPBUFFER WINAPI IFBufMakeWritable (LPBUFFER lpbf);
  740. extern EXPORT_DLL LPBUFFER WINAPI IFBufShare (LPBUFFER lpbf);
  741. extern EXPORT_DLL LPBUFFER WINAPI IFBufSplit (LPBUFFER lpbf, LPBYTE lpb);
  742. //----------------------------- PIPES ----------------------------
  743. #ifndef WIN32
  744. // types
  745. typedef struct _PIPE NEAR *HPIPE;
  746. // Parameter
  747. #define IFPIPE_READ_MODE 0x0001
  748. #define IFPIPE_WRITE_MODE 0x0002
  749. #define REQREAD_REMOVE_DATA 0x0003
  750. #define REQREAD_NOREMOVE_DATA 0x0004
  751. // Error values
  752. #define ERR_TOO_MANY_OPENS ERR_FUNCTION_START
  753. #define ERR_TOO_MANY_PENDING_WRITES ERR_FUNCTION_START+1
  754. #define ERR_PIPE_STILL_OPEN ERR_FUNCTION_START+2
  755. /********
  756. @doc EXTERNAL MESSAGES IFPIPES IFAXOS
  757. @msg IF_PIPE_DATA_WRITTEN | This message is sent to notify a process
  758. that a previous write request using <f IFPipeReqWrite> has
  759. been successfully concluded. On reciept of this message the
  760. process can issue another write request on the same pipe.
  761. @parm WPARAM | wParam | The <p wContext> parameter passed to the
  762. <f IFPipeOpen> call.
  763. @parm LPARAM | lParam | NULL
  764. @rdesc none
  765. @xref <f IFPipeReqWrite>
  766. @msg IF_PIPE_DATA_ARRIVED | This message is sent to a process which
  767. previsouly issued a read request to a pipe, intimating it that
  768. the buffer it requested is now available.
  769. @parm WPARAM | wParam | The <p wContext> parameter passed to the
  770. <f IFPipeOpen> call.
  771. @parm LPARAM | lParam | Contains a far ptr to a <t BUFFER> structure
  772. which has the requested data. On receipt of this message the process
  773. can issue another read request on the same pipe.
  774. @rdesc none
  775. @xref <f IFPipeReqRead>
  776. ********/
  777. // Messages
  778. #define IF_PIPE_DATA_WRITTEN IF_PIPES_START
  779. #define IF_PIPE_DATA_ARRIVED IF_PIPES_START+1
  780. // Functions
  781. HPIPE WINAPI IFPipeCreate (WORD wSize);
  782. BOOL WINAPI IFPipeDelete (HPIPE hpipe);
  783. BOOL WINAPI IFPipeOpen (HPIPE hPipe, HWND hwnd, WORD wMode, WPARAM wContext);
  784. BOOL WINAPI IFPipeClose (HPIPE hPipe, WORD wMode);
  785. BOOL WINAPI IFPipeReqRead (HPIPE hPipe, WORD fwRemove);
  786. BOOL WINAPI IFPipeReqWrite (HPIPE hPipe, LPBUFFER lpbf);
  787. BOOL WINAPI IFPipeGetInfo (HPIPE hPipe, LPWORD lpwSize, LPWORD lpwcBufs);
  788. #else // !WIN32
  789. DECLARE_HANDLE32(HPIPE);
  790. #endif // !WIN32
  791. #endif // NOBUFFERS
  792. //----------------------------- DEBUG SERVICES -------------------------
  793. // Debug typedefs. These dont do any harm to anyone. Define them if there is
  794. // anyone who might need them.
  795. #if defined(DEBUG) || defined(IFKINTERNAL)
  796. /********
  797. @doc EXTERNAL DATATYPES DEBUG IFAXOS
  798. @types DBGPARAM | Structure containing the debug
  799. settings for any module in the system.
  800. @field CHAR[32] | lpszName | Specifies the name of the module.
  801. This is how your module will appear in the IFAX controller. Must
  802. be less than 32 characters long, and NULL terminated.
  803. @field HWND | hwnd | Specifies the primary window handle associated with
  804. this module IF the module is a process. For DLL's this value should
  805. always be NULL. Background processes should set it to their own ID using
  806. <f IFProcGetInfo> and <f GetCurrentTask> at initialization time.
  807. Foreground processes should set it to the window handle of their client
  808. window.
  809. @field CHAR[16][32] | rglpszZones | Stores a list of 16 strings
  810. which describe the zones associated with the lower 16 bits of
  811. zone mask. The module must decide and define its own zones for these
  812. bits - any bits not used should be left as "Not Used". These strings
  813. will be displayed by the IFAX controller to assist users in choosing
  814. the zones to be set for your module. Each string should not be more
  815. than 32 characters long, and should be NULL terminated.
  816. @field ULONG | ulZoneMask | This is the mask which stores the
  817. current zone settings for the module. The IFAX controller will
  818. set this field according to what the user specifies. This field
  819. should be initialized to something which makes sense for your module
  820. - as that will be the default till the user changes it.
  821. @comm This structure should be passed to <f IFDbgSetParams> at
  822. intialization time to enable the user to control the trace options.
  823. **VERY IMPORTANT NOTE** This structure MUST be declared with a
  824. variable name of dpCurSettings to allow the system zones to
  825. function correctly.
  826. @tagname _DBGPARAM
  827. @xref <f IFDbgSetParams>
  828. ********/
  829. typedef struct _DBGPARAM {
  830. CHAR lpszName[32]; // name of module
  831. HWND hwnd; // Primary window Handle if task, NULL otherwise
  832. CHAR rglpszZones[16][32]; // names of zones for first 16 bits
  833. ULONG ulZoneMask; // Zone Mask
  834. } DBGPARAM, FAR *LPDBGPARAM;
  835. // Debug functions
  836. BOOL WINAPI IFDbgOut (LPSTR lpszStatus);
  837. WORD WINAPI IFDbgIn (LPSTR lpszPrompt, LPSTR lpszReply, WORD wBufSize);
  838. extern EXPORT_DLL VOID WINAPI IFDbgSetParams (LPDBGPARAM lpdpParam, BOOL fEntry);
  839. extern VOID FAR IFDbgPrintf(LPSTR lpszFmt, ...);
  840. extern EXPORT_DLL BOOL WINAPI IFDbgCheck(VOID);
  841. // Encourage people to use the correct variable
  842. extern DBGPARAM dpCurSettings;
  843. // Special UI communication stuff
  844. // Functions
  845. DWORD WINAPI DebugUIMessage (UINT wMsg, WPARAM wParam, DWORD lParam);
  846. // Messages to the UI proc
  847. #define IF_DISP_STRING IF_DEBUG_START
  848. #define IF_INP_REQUEST IF_DEBUG_START+1
  849. #define IF_NEW_SETTING IF_DEBUG_START+2
  850. #define IF_DEL_SETTING IF_DEBUG_START+3
  851. #define IF_NEW_TASK IF_DEBUG_START+4
  852. #define IF_DEL_TASK IF_DEBUG_START+5
  853. #define IF_FILELOG_POLL IF_DEBUG_START+6
  854. // Messages from the UI proc
  855. #define REGISTER_UI_TASK 1
  856. #define SET_LOG_MODE 2
  857. #define DEBUG_OUT_DONE 3
  858. #define DEBUG_IN_DONE 4
  859. #define DEREGISTER_UI_TASK 5
  860. #endif
  861. // Debug Macros. These should be defined only if the module is being compiled
  862. // in debug
  863. #ifdef DEBUG
  864. /********
  865. @doc EXTERNAL IFAXOS DEBUG MACROS
  866. @api BOOL | DEBUGMSG | Prints a trace message on the debug
  867. console depending on enable flags set by the user.
  868. @parm <lt>c_expression<gt> | cond | Boolean condition which is
  869. evaluated to decide whether or not to print the message.
  870. @parm <lt>printfexp<gt> | printf_exp | Printf parameters for the
  871. message to be displayed. Must be enclosed in a single pair of
  872. parentheses.
  873. @rdesc TRUE if the message is printed, and FALSE if it is not.
  874. @comm The condition should consist of a boolean expression testing whether
  875. the relevant zones are on or off. Each module has a current zone
  876. mask which identifies which of the possible 32 zones is currently on.
  877. The top 16 bits of these are reserved for use for system defined
  878. zones - like ZONE_FUNC_ENTRY which is defined as
  879. #define ZONE_FUNC_ENTRY (0x00010000&dpCurSettings.ulZoneMask)
  880. Modules should take care to see
  881. that they print out trace messages which are meaningful and conform
  882. to some pattern - remember that other people than you have to see
  883. and make sense of your messages. The general format I have been
  884. following is :
  885. <lt>Task ID<gt> :
  886. <lt>ModuleName<gt>:<lt>SubModule<gt>:<lt>Function<gt>:<lt>msg<gt>
  887. The task ID is useful to sort out the output of multiple tasks
  888. running in the system. The example call above yields this kind of
  889. output.
  890. The various predefined system zones are:
  891. ZONE_FUNC_ENTRY : To be used for all function entry and exit
  892. messages. By convention, the parameters should be printed
  893. on entry, and the return value should be printed on exit.
  894. Any values printed in hexadecimal should be preceded by a 0x
  895. ZONE_INT_FUNC : To be used for any other traces at interesting
  896. points within a function.
  897. All trace messages are disabled in a non debug build.
  898. @ex Example Definition & Use |
  899. #define ZONE_CUSTOM (0x00000001&dpCurSettings.ulZoneMask)
  900. DEBUGMSG (ZONE_FUNC_ENTRY && ZONE_CUSTOM,
  901. ("0x%04X:IFK:Buffers:GenericFunction:Entry\r\n",
  902. GetCurrentTask()));
  903. This will print a trace message only if the user has turned the
  904. function entry zone and the custom zone on.
  905. @xref <f IFDbgPrintf>
  906. ********/
  907. #if 0
  908. #define DEBUGMSG(cond,printf_exp) \
  909. ((cond)?(IFDbgPrintf printf_exp),1:0)
  910. #endif
  911. #define DEBUGMSG(cond, printf_exp) \
  912. (IFDbgPrintf printf_exp)
  913. // Standard Debug zones
  914. #define ZONE_FUNC_ENTRY (0x00010000&dpCurSettings.ulZoneMask)
  915. #define ZONE_INT_FUNC (0x00020000&dpCurSettings.ulZoneMask)
  916. /********
  917. @doc EXTERNAL IFAXOS DEBUG MACROS
  918. @api BOOL | ERRORMSG | Prints an error message on the debug
  919. console.
  920. @parm <lt>printfexp<gt> | printf_exp | Printf parameters for the
  921. message to be displayed. Must be enclosed in a single pair of
  922. parentheses.
  923. @comm Should be used to display Error messages.
  924. @ex Example Definition & Use |
  925. ERRORMSG (("0x%04X:JOB Failed !!\r\n", GetCurrentTask()));
  926. This will print a trace message like:
  927. ERROR: Job Process: 0x2346: JOB Failed !!
  928. @xref <f IFDbgPrintf>
  929. ********/
  930. #ifndef WIN32
  931. #define ERRORMSG(printf_exp) \
  932. (IFProcEnterCritSec(), \
  933. IFDbgPrintf("ERROR:(0x%04X):%s:",GetCurrentTask(),(LPSTR)(dpCurSettings.lpszName)), \
  934. IFDbgPrintf printf_exp ,\
  935. IFProcExitCritSec(), \
  936. 1)
  937. #else
  938. #define ERRORMSG(printf_exp) \
  939. (IFDbgPrintf("ERROR:(0x%08lX):%s:",GetCurrentProcessId(),(LPSTR)(dpCurSettings.lpszName)), \
  940. IFDbgPrintf printf_exp ,\
  941. 1)
  942. #endif
  943. /********
  944. @doc EXTERNAL IFAXOS DEBUG MACROS
  945. @api BOOL | RETAILMSG | Prints a message on the debug
  946. console even for retail builds.
  947. @parm <lt>printfexp<gt> | printf_exp | Printf parameters for the
  948. message to be displayed. Must be enclosed in a single pair of
  949. parentheses.
  950. @comm Should be used to display debugging messages which are desired
  951. in the retail build. For obvious reasons this should be used
  952. sparingly. The benefit is that all such messages can be turned off
  953. for the shipping build by simply changing the macro in ifaxos.h
  954. @ex Example Definition & Use |
  955. RETAILMSG (("0x%04X:Scanner Opened !!\r\n", GetCurrentTask()));
  956. This will print a trace message like:
  957. 0x4567:Scanner Opened !!
  958. @xref <f IFDbgPrintf>
  959. ********/
  960. #define RETAILMSG(printf_exp) (IFDbgPrintf printf_exp)
  961. /********
  962. @doc EXTERNAL IFAXOS DEBUG MACROS
  963. @api BOOL | WARNINGMSG | Prints a warning message on the debug
  964. console even for retail builds.
  965. @parm <lt>printfexp<gt> | printf_exp | Printf parameters for the
  966. message to be displayed. Must be enclosed in a single pair of
  967. parentheses.
  968. @comm Should be used to display debugging messages which are desired
  969. in the retail build. For obvious reasons this should be used
  970. sparingly. The benefit is that all such messages can be turned off
  971. for the shipping build by simply changing the macro in ifaxos.h
  972. @ex Example Definition & Use |
  973. WARNINGMSG (("0x%04X:Scanner Opened !!\r\n", GetCurrentTask()));
  974. This will print a trace message like:
  975. WARNING: 0x4567:Scanner Opened !!
  976. @xref <f IFDbgPrintf> <f ERRORMSG>
  977. ********/
  978. #ifndef WIN32
  979. #define WARNINGMSG(printf_exp) \
  980. (IFProcEnterCritSec(), \
  981. IFDbgPrintf("WARNING:(0x%04X):%s:",GetCurrentTask(),(LPSTR)(dpCurSettings.lpszName)), \
  982. IFDbgPrintf printf_exp ,\
  983. IFProcExitCritSec(), \
  984. 1)
  985. #else
  986. #define WARNINGMSG(printf_exp) \
  987. (IFDbgPrintf("WARNING:(0x%08lX):%s:",GetCurrentProcessId(),(LPSTR)(dpCurSettings.lpszName)), \
  988. IFDbgPrintf printf_exp ,\
  989. 1)
  990. #endif
  991. /********
  992. @doc EXTERNAL IFAXOS DEBUG MACROS
  993. @api BOOL | DEBUGCHK | Macro implementing an assert.
  994. @parm <lt>c_exp<gt> | exp | Expression to be checked.
  995. @rdesc Returns TRUE if the expression was non zero, and FALSE if not.
  996. @comm This is a macro which implements functionality similar to the assert
  997. statement in C. The expression argument is evaluated, and no action
  998. is taken if it evaluates to true. If false, a debug message is
  999. printed out giving the File name and line number where the check
  1000. failed, along with the module name which was registered
  1001. in the <t DBGPARAM> structure. Because of this, you *must* register
  1002. your debug settings using <f IFDbgSetParams> before you can use the
  1003. DEBUGCHK macro. After this the function <f IFDbgCheck> is called
  1004. to generate an assert.
  1005. This statement disappears when the DEBUG option is turned off.
  1006. @xref <f IFDbgCheck>
  1007. ********/
  1008. #define BG_CHK(exp) \
  1009. ((exp)?1:( \
  1010. IFDbgPrintf ("DEBUGCHK failed in file %s at line %d \r\n", \
  1011. (LPSTR) __FILE__ , __LINE__ ), 1 \
  1012. ))
  1013. #ifndef DEBUGCHK_UNSAFE_IN_WFWBG
  1014. #define DBGCHK(module,exp) \
  1015. ((exp)?1:( \
  1016. IFDbgPrintf ("%s: DEBUGCHK failed in file %s at line %d \r\n", \
  1017. (LPSTR) module, (LPSTR) __FILE__ , __LINE__ ), \
  1018. IFDbgCheck() \
  1019. ))
  1020. #define DEBUGCHK(exp) DBGCHK(dpCurSettings.lpszName, exp)
  1021. #endif
  1022. /********
  1023. @doc EXTERNAL IFAXOS DEBUG MACROS
  1024. @api BOOL | DEBUGSTMT | Evaluates the expression in debug mode.
  1025. @parm <lt>c_exp<gt> | exp | Expression to be evaluated.
  1026. @rdesc Returns the value returned by the expression.
  1027. @comm This macro is provided for convenience and code readability purposes
  1028. to replace a construct of the form
  1029. #ifdef DEBUG
  1030. exp;
  1031. #endif
  1032. It evaluates to zero in a non debug build.
  1033. ********/
  1034. #define DEBUGSTMT(exp) exp
  1035. #else // NOT DEBUG
  1036. // Let debugmsg's through currently
  1037. #ifndef SHIP_BUILD
  1038. //#ifndef FOOBAR
  1039. // Non DEBUG MODE
  1040. extern EXPORT_DLL VOID FAR CDECL IFDbgPrintf(LPSTR lpszFmt, ...);
  1041. extern EXPORT_DLL BOOL WINAPI IFDbgCheck(VOID);
  1042. #ifndef WIN32
  1043. #define ERRORMSG(printf_exp) \
  1044. (IFProcEnterCritSec(), \
  1045. IFDbgPrintf("ERROR:(0x%04X):",GetCurrentTask()), \
  1046. IFDbgPrintf printf_exp ,\
  1047. IFProcExitCritSec(), \
  1048. 1)
  1049. #define WARNINGMSG(printf_exp) \
  1050. (IFProcEnterCritSec(), \
  1051. IFDbgPrintf("WARNING:(0x%04X):",GetCurrentTask()), \
  1052. IFDbgPrintf printf_exp ,\
  1053. IFProcExitCritSec(), \
  1054. 1)
  1055. #define RETAILMSG(printf_exp) (IFDbgPrintf printf_exp)
  1056. #else //Win32 -- NO MESSAGES OF ANY SORT IN NON-DEBUG WIN32
  1057. #define RETAILMSG(printf_exp) (0)
  1058. #define ERRORMSG(printf_exp) (0)
  1059. #define WARNINGMSG(printf_exp) (0)
  1060. #endif
  1061. #else
  1062. #define RETAILMSG(printf_exp) (0)
  1063. #define ERRORMSG(printf_exp) (0)
  1064. #define WARNINGMSG(printf_exp) (0)
  1065. #endif
  1066. // These are to macro out all debug stuff in retail/ship builds
  1067. #define DEBUGMSG(cond,expr) (0)
  1068. #define DBGCHK(module,exp) (0)
  1069. #define DEBUGCHK(exp) (0)
  1070. #define BG_CHK(exp) (0)
  1071. #define DEBUGSTMT(exp) (0)
  1072. // Macros for direct function calls made ..
  1073. #ifndef IFKINTERNAL
  1074. #define IFDbgOut(lpszStatus) (0)
  1075. #define IFDbgIn(lpszPrompt,lpszReply,wBufSize) (0)
  1076. #define IFDbgSetParams(lpdpParam,fEntry) (0)
  1077. #define DebugUIMessage(wMsg,wParam,lParam) (0)
  1078. #endif
  1079. #endif
  1080. /********
  1081. @doc EXTERNAL IFAXOS MACROS
  1082. @api BOOL | UIEVENT | Prints a status string in the UI
  1083. @parm LPSTR | string | String to be printed.
  1084. @comm This macro is provided in both the retail & debug builds to
  1085. allow some limited set of status strings to be printed in
  1086. the UI. You must format a string yourself - you can
  1087. use wsprintf() to create a complex one if desired. The
  1088. maximum string length allowed is 64 bytes.
  1089. ********/
  1090. #define IF_SYS_EVENT IF_UI_START+1
  1091. // UI Event messages
  1092. #define UIEVENT(string) \
  1093. { \
  1094. CHAR szUIShell[] = "UISHELL"; \
  1095. DEBUGCHK(lstrlen(string) < 64); \
  1096. PostMessage (IFProcGetInfo(NULL, szUIShell, NULL), IF_SYS_EVENT, \
  1097. NULL, MAKELPARAM(GlobalAddAtom(string),0)); \
  1098. }
  1099. // --------------- Synchronization services --------------------------------------
  1100. // Dont provide any for win32.
  1101. #ifndef WIN32
  1102. typedef struct _SYNC NEAR *HSYNC;
  1103. // Error returns
  1104. #define ERR_MUTEX_NOT_FREE ERR_FUNCTION_START
  1105. #define ERR_EVENT_NOT_FREE ERR_FUNCTION_START+1
  1106. #define ERR_TOO_MANY_EVENTWAITS ERR_FUNCTION_START+2
  1107. // generic functions
  1108. DWORD WINAPI WaitForSingleObject (HSYNC hsc, DWORD dwTime);
  1109. // Mutex functions
  1110. HSYNC WINAPI CreateMutex (LPVOID lpvAttribs, BOOL fInitial,LPSTR lpszName);
  1111. BOOL WINAPI ReleaseMutex (HSYNC hsc);
  1112. // Event Functions
  1113. HSYNC WINAPI CreateEvent (LPVOID lpvAttribs, BOOL bManualReset,
  1114. BOOL bInitialState, LPSTR lpszName);
  1115. BOOL WINAPI SetEvent (HSYNC hsc);
  1116. BOOL WINAPI ResetEvent (HSYNC hsc);
  1117. BOOL WINAPI FreeSyncObject (HSYNC hsc);
  1118. BOOL WINAPI GetSetEventParam (HSYNC hsc, BOOL fSetParam, LPDWORD lpdwParam);
  1119. #else // !WIN32
  1120. DECLARE_HANDLE32(HSYNC);
  1121. #endif // !WIN32
  1122. /********
  1123. @doc EXTERNAL DEFINES ERROR IFAXOS
  1124. @type VOID | SYSTEM_MODULE_NAMES | Strings to be passed to IFProcGetInfo to get handles to standard IFAX modules
  1125. @emem MODNAME_UISHELL | UI Shell
  1126. @emem MODNAME_MSCHED | Message Scheduler
  1127. @emem MODNAME_MSGSVR | Message Server a.k.a. Message Transport
  1128. @xref <f IFProcGetInfo>
  1129. ********/
  1130. // IFAX Module names
  1131. #define MODNAME_UISHELL "UISHELL"
  1132. #define MODNAME_MSCHED "MSCHED"
  1133. #define MODNAME_MSGSVR "MSGSVR"
  1134. // --------------- Timer Services -----------------------------------------
  1135. #ifndef WIN32
  1136. /********
  1137. @doc EXTERNAL IFAXOS MESSAGES TIMER
  1138. @msg IF_TIMER | This message is sent to notify a process
  1139. of the expiration of a timer set using <f IFTimerSet>.
  1140. @parm WPARAM | wParam | Contains the timer id set int he
  1141. <f IFTimerSet> call.
  1142. @parm LPARAM | lParam | Contains the lParam passed into
  1143. the IFTimerSet call.
  1144. @rdesc none
  1145. @xref <f IFTimerSet>
  1146. ********/
  1147. // messages
  1148. #define IF_TIMER IF_TIMER_START
  1149. // flags
  1150. #define TIME_ONESHOT 0
  1151. #define TIME_PERIODIC 1
  1152. // functions
  1153. VOID WINAPI IFProcSleep (WORD wSleepPeriod);
  1154. WORD WINAPI IFTimerSet (HWND hwnd, WORD idTimer, WORD wTimeout,
  1155. TIMERPROC tmprc, WORD wFlags, LPARAM lContext);
  1156. BOOL WINAPI IFTimerKill (HWND hwnd, UINT idTimer);
  1157. #endif
  1158. // --------------- Global Pool Management ----------------------------------
  1159. /********
  1160. @doc EXTERNAL IFAXOS DEFINES GLOBMEM
  1161. @type VOID | STANDARD_BLOCK_SIZES | This defines all the standard global
  1162. memory block sizes. As far as possible all memory allocations
  1163. should be for one of these sizes. Any other size will be much
  1164. more inefficient and couls cause fragmentation of system
  1165. memory.
  1166. @emem ONLY_HEADER_SIZE| This will allocate a buffer with no data
  1167. associated with it. This can be used to pass metadata between
  1168. processes - eg an END_OF_JOB buffer marker.
  1169. @emem SMALL_HEADER_SIZE| This currently defines a 32 byte memory
  1170. block. It is used for all buffer headers, and can be used
  1171. for things like protocol headers, structure headers etc.
  1172. @emem COMPRESS_DATA_SIZE | This defines a 1Kb memory block which
  1173. should be used to store any compressed data form. This is
  1174. the general purpose data storage size. Any buffer which
  1175. could be around for a long time should contain compressed
  1176. data in this size of buffer.
  1177. @emem RAW_DATA_SIZE | This defines a large buffer size (currently
  1178. 8Kb) for use by renderers as frame buffers. They should be
  1179. used only to store raw bitmap data which is being sent
  1180. directly to a consumer device like the printer. There are
  1181. very few of these - so they should be used only for this
  1182. short lived purpose.
  1183. @emem BAND_BUFFER_SIZE| This defines a jumbo buffer of 64K for use
  1184. by the resource-based renderer. There may be only one such
  1185. buffer in the global pool. (NOT IMPLEMENTED YET)
  1186. @xref <f IFMemAlloc> <f IFBufAlloc>
  1187. ********/
  1188. // Std block sizes
  1189. #define ONLY_HEADER_SIZE 0 // No data
  1190. #define SMALL_HEADER_SIZE -1 // 32b
  1191. #define COMPRESS_DATA_SIZE -2 // 1Kb
  1192. //
  1193. #define RAW_DATA_SIZE -3 // 8Kb
  1194. // Special size for modem ECM frame
  1195. #define BYTE_265_SIZE -4 // 265 bytes
  1196. #define BYTE_265_ACTUALSIZE 265
  1197. // Number of sizes
  1198. #define MAX_POOL_INDEX -4 // For parameter validation
  1199. // Not available yet!
  1200. #define BAND_BUFFER_SIZE 30720 // 64Kb
  1201. // Flag to force global alloc. Uses a windows flag which is ignored/defunct in
  1202. // the 3.1 kernel (and the boss kernel)
  1203. #define IFMEM_USEGLOBALALLOC GMEM_NOT_BANKED
  1204. // Functions
  1205. extern LPVOID IFMemAlloc (UINT fuAlloc, LONG lAllocSize,
  1206. LPWORD lpwActualSize);
  1207. extern BOOL IFMemFree (LPVOID lpvMem);
  1208. /********
  1209. @doc EXTERNAL IFAXOS
  1210. @api HIPCMEM | IFMemGetIPCHandle | Returns an opaque 32 bit handle
  1211. which is portable across process contexts.
  1212. @parm LPVOID | lpvMem | A ptr to global memory allocated using
  1213. <f IFMemAlloc>.
  1214. @rdesc Opaque 32 bit none zero handle if succesfull. 0 if the memory
  1215. ptr passed in is invalid.
  1216. @comm This function should be used by any DLL or process before trying
  1217. to pass this memory to another process context. Only handles
  1218. returned by this API should cross context boundaries, and the
  1219. receiving context should call <f IFMemMapIPCHandle> to get back
  1220. a valid memory ptr in its new context.
  1221. This applies even for DLL's which might allocate a piece of
  1222. global memory and access it in different process contexts. They
  1223. should use these functions to map them so that they are portable.
  1224. For Win16/IFAX implementations, this is essentially a NOP.
  1225. @xref <f IFMemAlloc> <f IFMemMapIPCHandle>
  1226. @type DWORD | HIPCMEM | Opaque 32 bit handle to global memory block.
  1227. @xref <f IFMemMapIPCHandle> <f IFMemGetIPCHandle>
  1228. *********/
  1229. typedef DWORD HIPCMEM;
  1230. #define IFMemGetIPCHandle(par1) ((HIPCMEM)par1)
  1231. /********
  1232. @doc EXTERNAL IFAXOS
  1233. @api DWORD | IFMemMapIPCHandle | Maps a piece of memory into the
  1234. current tasks address space.
  1235. @parm HIPCMEM | hMemHandle | A memory handle returned from a call
  1236. to <f IFMemGetIPCHandle> previously.
  1237. @rdesc Valid ptr to memory in the context of the calling process if
  1238. succesful. NULL if it fails.
  1239. @comm See comments in <f IFMemMapIPCHandle>.
  1240. @xref <f IFMemAlloc> <f IFMemMapIPCHandle>
  1241. *********/
  1242. #define IFMemMapIPCHandle(par1) ((LPVOID)par1)
  1243. // --------------- Time API's ----------------------------------------------
  1244. /********
  1245. @doc EXTERNAL IFAXOS SRVRDLL
  1246. @types SYSTEMTIME | Structure describing the time in terms of roman
  1247. calendar.
  1248. @field WORD | wYear | The year
  1249. @field WORD | wMonth | The month from 1-12
  1250. @field WORD | wDayOfWeek | Day of week with Sunday = 0
  1251. @field WORD | wDay | The day of the month, from 1-31
  1252. @field WORD | wHour | The hour from 0-23
  1253. @field WORD | wMinute | Minutes from 0-59
  1254. @field WORD | wSecond | Seconds from 0-50
  1255. @field WORD | wMilliseconds | Milliseconds from 0-99
  1256. @comm This is the format used for dislaying time to the user etc.
  1257. @xref <f SystemTimeToFileTime> <t FILETIME> <f FileTimeToSystemTime>
  1258. ********/
  1259. #ifndef WIN32
  1260. typedef struct _SYSTEMTIME {
  1261. WORD wYear;
  1262. WORD wMonth;
  1263. WORD wDayOfWeek;
  1264. WORD wDay;
  1265. WORD wHour;
  1266. WORD wMinute;
  1267. WORD wSecond;
  1268. WORD wMilliseconds;
  1269. } SYSTEMTIME, FAR *LPSYSTEMTIME;
  1270. #endif
  1271. /********
  1272. @doc EXTERNAL IFAXOS
  1273. @types FILETIME | Structure used to store time internally and for
  1274. mathematical operations.
  1275. @field DWORD | dwLowDateTime | Low 32 bits of the time.
  1276. @field DWORD | dwHighDateTime | High 32 bits of the time.
  1277. @comm Absolute time in IFAX is represented by a 64-bit large integer accurate
  1278. to 100ns resolution. The smallest time resolution used by this package
  1279. is One millisecond. The basis for this time is the start of 1601 which
  1280. was chosen because it is the start of a new quadricentury. Some facts
  1281. to note are:
  1282. o At 100ns resolution 32 bits is good for about 429 seconds (or 7 minutes)
  1283. o At 100ns resolution a large integer (i.e., 63 bits) is good for
  1284. about 29,247 years, or around 10,682,247 days.
  1285. o At 1 second resolution 31 bits is good for about 68 years
  1286. o At 1 second resolution 32 bits is good for about 136 years
  1287. o 100ns Time (ignoring time less than a millisecond) can be expressed
  1288. as two values, Days and Milliseconds. Where Days is the number of
  1289. whole days and Milliseconds is the number of milliseconds for the
  1290. partial day. Both of these values are ULONG.
  1291. @xref <f SystemTimeToFileTime> <t SYSTEMTIME> <f FileTimeToSystemTime>
  1292. ********/
  1293. #ifndef WIN32
  1294. // If sos property.h has been included this will cause a redefinition
  1295. #ifndef PROPERTY_H
  1296. #ifndef _FILETIME_
  1297. #define _FILETIME_
  1298. typedef struct _FILETIME {
  1299. DWORD dwLowDateTime;
  1300. DWORD dwHighDateTime;
  1301. } FILETIME, FAR *LPFILETIME;
  1302. #endif // _FILETIME_
  1303. #endif // Property_H
  1304. BOOL WINAPI FileTimeToSystemTime(LPFILETIME lpTime,LPSYSTEMTIME lpTimeFields);
  1305. BOOL WINAPI SystemTimeToFileTime(LPSYSTEMTIME lpTimeFields,LPFILETIME lpTime);
  1306. BOOL WINAPI FileTimeToLocalFileTime(LPFILETIME lpft, LPFILETIME lpftLocal);
  1307. BOOL WINAPI LocalFileTimeToFileTime(LPFILETIME lpftLocal, LPFILETIME lpft);
  1308. BOOL WINAPI SetLocalTime(LPSYSTEMTIME lpstLocal);
  1309. VOID WINAPI GetLocalTime(LPSYSTEMTIME lpstLocal);
  1310. #endif // Win32
  1311. // --------------- NVRAM API's ----------------------------------------------
  1312. typedef struct ERRORLOGPOINTER {
  1313. WORD wNextEntryPtr ;
  1314. WORD wNumEntries ;
  1315. } ERRORLOGPOINTER , FAR * LPERRORLOGPOINTER ;
  1316. #define MAX_ERRORLOG_ENTRIES 30
  1317. #define MAX_OEMERRBUF_SIZE 16
  1318. /********
  1319. @doc EXTERNAL IFAXOS
  1320. @types ERRORLOGENTRY | Used to store Log Entries.
  1321. @field DWORD | dwErrorCode | This is the IFAX error code
  1322. corresponding to the error being retrieved. See <f IFErrAssemble>
  1323. for details of the format of this dword.
  1324. @field DWORD | dwTimeStamp | The time at which this error was
  1325. logged into NVRam. The various fields are:
  1326. @flag Bits 0-4 | Second divided by 2
  1327. @flag Bits 5-10| Minute (0-59)
  1328. @flag Bits 11-15 | Hour (0-23 on a 24 hour clock)
  1329. @flag Bits 16-20 | Day of the month (1-31)
  1330. @flag Bits 21-24 | Month (1 = January, 2 = February, etc.)
  1331. @flag Bits 25-31 | Year offset from COUNTER_YEAR_OFFSET (add COUNTER_YEAR_OFFSET to get actual year)
  1332. @field CHAR | oemErrBuf | The buffer in which the application
  1333. specific custom data/extended error corresponding to this
  1334. error is retrieved.
  1335. @comm Used as a parameter to IFNvramGetError. This will typically be
  1336. used for diagnostic functions.
  1337. @xref <f IFNvramGetError>
  1338. ********/
  1339. #define COUNTER_YEAR_OFFSET (1970)
  1340. typedef struct tagERRORLOGENTRY {
  1341. DWORD dwErrorCode;
  1342. DWORD dwTimeStamp;
  1343. char oemErrBuf[MAX_OEMERRBUF_SIZE];
  1344. } ERRORLOGENTRY, FAR *LPERRORLOGENTRY;
  1345. typedef DWORD ERRORLOGSENTINEL , FAR * LPERRORLOGSENTINEL ;
  1346. // Set to the current version number (12.19)
  1347. #define SENTINEL_SET 0x00000C13UL
  1348. #define MAX_COUNTERS 30
  1349. #define OEM_NVRAM_COUNTER_START 12
  1350. // Special system counter which indicates the # of times the machine has rebooted
  1351. // It is a 4 byte counter with a timestamp
  1352. // If this value is 1 then this is the first time the machine has ever been rebooted.
  1353. // - This value cannot be set by any user application!
  1354. #define BOOT_COUNTER 0
  1355. // specific counter numbers assigned for various logical counters
  1356. #define TXCALL_COUNTER 1
  1357. #define RXCALL_COUNTER 2
  1358. // ****************************************************************************
  1359. //
  1360. // An HHSOS owned counter.
  1361. // This is the number of bad boots we have suffered (meaning the HHSOS could not
  1362. // successfully init). When this number gets too big, we stop trying to init.
  1363. // This will cause AWCHKSOS to alert the user of the problem.
  1364. //
  1365. #define BAD_BOOTS_COUNTER 3
  1366. //
  1367. // ****************************************************************************
  1368. // These values for wFlags (in IFSetCounterValue) - some are mutually exclusive
  1369. // If CLEARSET is set the value is cleared before being added - otherwise it is just added
  1370. // Currently you cannot request a double long and a timestamp
  1371. // For now the interrupt has no context but in the future it might be useful
  1372. #define COUNTER_CLEARSET 0x0001
  1373. #define COUNTER_DOUBLE_LONG 0x0002
  1374. #define COUNTER_UPDATE_TIMESTAMP 0x0004
  1375. #define COUNTER_INTERRUPT_CONTEXT 0x1000
  1376. // Only here temporarily until everything gets moved to new values
  1377. #define COUNTER_VALUESET (COUNTER_CLEARSET | COUNTER_UPDATE_TIMESTAMP)
  1378. #define COUNTER_ADDVALUE 0x0100
  1379. #define COUNTER_TIMESTAMP 0x0200
  1380. #define COUNTER_NOTIMESTAMP COUNTER_DOUBLE_LONG
  1381. #define PROCESS_CONTEXT 0x0300
  1382. #define INTERRUPT_CONTEXT COUNTER_INTERRUPT_CONTEXT
  1383. /********
  1384. @doc EXTERNAL IFAXOS
  1385. @types COUNTERENTRY | Used to store 4 and 8 byte Counters.
  1386. @field DWORD | dwCounterVal1 | For a 4 byte counter, the value of the
  1387. counter. For an 8 byte counter, the low order
  1388. 4 bytes of the value of the counter.
  1389. @field DWORD | dwTimeStamp | For a 4 byte counter, the time at
  1390. which the counter was last reset. The fields in the timestamp are:
  1391. @flag Bits 0-4 | Second divided by 2
  1392. @flag Bits 5-10| Minute (0-59)
  1393. @flag Bits 11-15 | Hour (0-23 on a 24 hour clock)
  1394. @flag Bits 16-20 | Day of the month (1-31)
  1395. @flag Bits 21-24 | Month (1 = January, 2 = February, etc.)
  1396. @flag Bits 25-31 | Year offset from 1980 (add 1980 to get actual year)
  1397. For an 8 byte counter, dwTimeStamp is the high order 4 bytes of the
  1398. counter value.
  1399. @comm Used by the IFNvramGetCounterValue function.
  1400. @xref <f IFNvramGetCounterValue>
  1401. ********/
  1402. typedef struct tagCOUNTERENTRY {
  1403. DWORD dwCounterVal1;
  1404. DWORD dwTimeStamp;
  1405. } COUNTERENTRY, FAR *LPCOUNTERENTRY;
  1406. //-------------------------- Prototypes ----------------------------------
  1407. #if defined(WFW) || defined(WIN32)
  1408. #define IFNvramSetError(dw,lpb,w) (0)
  1409. #define IFNvramSetErrorInterrupt(dw,lpb,w) (0)
  1410. #define IFNvramGetError(lperrlog,lpwMaxEntries) (0)
  1411. #define IFNvramSetCounterValue(p1,p2,p3,p4) (0)
  1412. #define IFNvramGetCounterValue(w1,lpentry) (0)
  1413. #define IFNvramAllocScratchBuf(wSize) (NULL)
  1414. #else
  1415. BOOL WINAPI IFNvramSetError(DWORD, LPBYTE, WORD);
  1416. BOOL WINAPI IFNvramSetErrorInterrupt(DWORD, LPBYTE, WORD);
  1417. BOOL FAR CDECL IFNvramvSetError(DWORD dwError,WORD nErrs,...) ;
  1418. BOOL WINAPI IFNvramGetError(LPERRORLOGENTRY lperrlog,LPWORD lpwMaxEntries) ;
  1419. BOOL WINAPI IFNvramSetCounterValue(WORD, DWORD, DWORD, WORD);
  1420. BOOL WINAPI IFNvramGetCounterValue(WORD, LPCOUNTERENTRY);
  1421. BOOL WINAPI IFNvramFlushToFileLog(VOID) ;
  1422. BOOL WINAPI IFNvramInitFileLog(VOID) ;
  1423. LPBYTE WINAPI IFNvramAllocScratchBuf(WORD wSize);
  1424. #endif
  1425. /********
  1426. @doc EXTERNAL IFAXOS
  1427. @api BOOL | _lflush | Flushes all pending writes to a file handle.
  1428. @parm HFILE | hf | A file handle obtained from _lopen or OpenFile
  1429. @rdesc Returns TRUE for success, FALSE for failure.
  1430. @comm This function will flush all pending writes to disk.
  1431. For Win16 implementations, this currently always fails.
  1432. *********/
  1433. BOOL WINAPI _lflush(HFILE hf);
  1434. // the following is for service messages
  1435. #define IF_ST_END_SOSBK (IF_SERVICE_START+0)
  1436. #define IF_ST_END_SOSRST (IF_SERVICE_START+1)
  1437. #ifdef __cplusplus
  1438. } // extern "C" {
  1439. #endif
  1440. #endif // _INC_IFAXOS