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.

1087 lines
28 KiB

  1. //
  2. // Copyright (c) Microsoft Corporation 1993-1995
  3. //
  4. // rovcomm.h
  5. //
  6. // Declares common and useful data structures, macros and functions.
  7. // These items are broken down into the following sections. Defining
  8. // the associated flags will inhibit definition of the indicated
  9. // items.
  10. //
  11. // NORTL - run-time library functions
  12. // NOBASICS - basic macros
  13. // NOMEM - memory management, dynamic array functions
  14. // NODA - dynamic array functions
  15. // NOSHAREDHEAP - shared heap functions
  16. // NOFILEINFO - FileInfo functions
  17. // NOCOLORHELP - helper macros to derive COLOR_ values from state
  18. // NODRAWTEXT - enhanced version of DrawText
  19. // NODIALOGHELPER - dialog helper functions
  20. // NOMESSAGESTRING - construct message string functions
  21. // NOSTRING - string functions
  22. // NOPATH - path whacking functions
  23. // NODEBUGHELP - debug routines
  24. // NOSYNC - synchronization (critical sections, etc.)
  25. // NOPROFILE - profile (.ini) support functions
  26. // NODI - setup API Device Installer wrappers
  27. //
  28. // Optional defines are:
  29. //
  30. // WANT_SHELL_SUPPORT - include SH* function support
  31. // SZ_MODULEA - debug string prepended to debug spew
  32. // SZ_MODULEW - (wide-char) debug string prepended to debug spew
  33. // SHARED_DLL - DLL is in shared memory (may require
  34. // per-instance data)
  35. // SZ_DEBUGSECTION - .ini section name for debug options
  36. // SZ_DEBUGINI - .ini name for debug options
  37. //
  38. // This is the "master" header. The associated files are:
  39. //
  40. // rovcomm.c
  41. // rovpath.c
  42. // rovmem.c, rovmem.h
  43. // rovini.c
  44. //
  45. // If you want debug macros, be sure to include rovdbg.h in one (and
  46. // only one) of your project source files. This contains the three function
  47. // helpers.
  48. //
  49. // History:
  50. // 04-26-95 ScottH Transferred from Briefcase code
  51. // Added controlling defines
  52. //
  53. #ifndef __ROVCOMM_H__
  54. #define __ROVCOMM_H__
  55. #ifdef RC_INVOKED
  56. // Turn off a bunch of stuff to ensure that RC files compile OK
  57. #define NOMEM
  58. #define NODA
  59. #define NOSHAREDHEAP
  60. #define NOFILEINFO
  61. #define NOCOLORHELP
  62. #define NODRAWTEXT
  63. #define NODIALOGHELPER
  64. #define NOMESSAGESTRING
  65. #define NOSTRING
  66. #define NOPATH
  67. #define NODEBUGHELP
  68. #define NOSYNC
  69. #define NOPROFILE
  70. #define NODI
  71. #endif // RC_INVOKED
  72. #ifdef JUSTDEBUGSTUFF
  73. #define NORTL
  74. #define NOMEM
  75. #define NODA
  76. #define NOSHAREDHEAP
  77. #define NOFILEINFO
  78. #define NOCOLORHELP
  79. #define NODRAWTEXT
  80. #define NODIALOGHELPER
  81. #define NOMESSAGESTRING
  82. #define NOPROFILE
  83. #define NOSTRING
  84. #define NOPATH
  85. #define NOSYNC
  86. #define NODI
  87. #endif // JUSTDEBUGSTUFF
  88. #ifdef _INC_OLE
  89. #define WANT_OLE_SUPPORT
  90. #endif
  91. // Check for any conflicting defines...
  92. #if !defined(WANT_SHELL_SUPPORT) && !defined(NOFILEINFO)
  93. #pragma message("FileInfo routines need WANT_SHELL_SUPPORT. Not providing FileInfo routines.")
  94. #define NOFILEINFO
  95. #endif
  96. #if !defined(NOFILEINFO) && defined(NOMEM)
  97. #pragma message("FileInfo routines need NOMEM undefined. Overriding.")
  98. #undef NOMEM
  99. #endif
  100. #if !defined(NOFILEINFO) && defined(NOMESSAGESTRING)
  101. #pragma message("FileInfo routines need NOMESSAGESTRING undefined. Overriding.")
  102. #undef NOMESSAGESTRING
  103. #endif
  104. #if !defined(NOFILEINFO) && defined(NOSTRING)
  105. #pragma message("FileInfo routines need NOSTRING undefined. Overriding.")
  106. #undef NOSTRING
  107. #endif
  108. #if !defined(NOMESSAGESTRING) && defined(NOMEM)
  109. #pragma message("ConstructMessage routines need NOMEM undefined. Overriding.")
  110. #undef NOMEM
  111. #endif
  112. #if !defined(NOPATH) && defined(NOSTRING)
  113. #pragma message("Path routines need NOSTRING undefined. Overriding.")
  114. #undef NOSTRING
  115. #endif
  116. #if !defined(NODA) && defined(NOMEM)
  117. #pragma message("Dynamic Array routines need NOMEM undefined. Overriding.")
  118. #undef NOMEM
  119. #endif
  120. #if !defined(NOSHAREDHEAP) && defined(NOMEM)
  121. #pragma message("Shared memory routines need NOMEM undefined. Overriding.")
  122. #undef NOMEM
  123. #endif
  124. #if !defined(NOPROFILE) && defined(NODEBUGHELP)
  125. #pragma message("Debug profiling routines need NODEBUGHELP undefined. Overriding.")
  126. #undef NODEBUGHELP
  127. #endif
  128. #if !defined(NOPROFILE) && defined(NOSTRING)
  129. #pragma message("Private profile needs NOSTRING undefined. Overriding.")
  130. #undef NOSTRING
  131. #endif
  132. #if DBG > 0 && !defined(DEBUG)
  133. #define DEBUG
  134. #endif
  135. #if DBG > 0 && !defined(FULL_DEBUG)
  136. #define FULL_DEBUG
  137. #endif
  138. // Other include files...
  139. #if !defined(NOFILEINFO) && !defined(_SHLOBJ_H_)
  140. #include <shlobj.h>
  141. #endif
  142. #if !defined(NODEBUGHELP) && !defined(_VA_LIST_DEFINED)
  143. #include <stdarg.h>
  144. #endif
  145. #if !defined(WINNT)
  146. #define WIN95
  147. #else
  148. #undef WIN95
  149. #endif
  150. //
  151. // Basics
  152. //
  153. #ifndef NOBASICS
  154. #define Unref(x) x
  155. #ifdef DEBUG
  156. #define INLINE
  157. #define DEBUG_CODE(x) x
  158. #else
  159. #define INLINE __inline
  160. #define DEBUG_CODE(x)
  161. #endif
  162. #ifdef UNICODE
  163. #define SZ_MODULE SZ_MODULEW
  164. #else
  165. #define SZ_MODULE SZ_MODULEA
  166. #endif // UNICODE
  167. #ifndef OPTIONAL
  168. #define OPTIONAL
  169. #endif
  170. #ifndef IN
  171. #define IN
  172. #endif
  173. #ifndef OUT
  174. #define OUT
  175. #endif
  176. // General flag macros
  177. //
  178. #define SetFlag(obj, f) do {obj |= (f);} while (0)
  179. #define ToggleFlag(obj, f) do {obj ^= (f);} while (0)
  180. #define ClearFlag(obj, f) do {obj &= ~(f);} while (0)
  181. #define IsFlagSet(obj, f) (BOOL)(((obj) & (f)) == (f))
  182. #define IsFlagClear(obj, f) (BOOL)(((obj) & (f)) != (f))
  183. #define InRange(id, idFirst, idLast) ((UINT)(id-idFirst) <= (UINT)(idLast-idFirst))
  184. // Standard buffer lengths
  185. //
  186. #define MAX_BUF 260
  187. #define MAX_BUF_MSG 520
  188. #define MAX_BUF_MED 64
  189. #define MAX_BUF_SHORT 32
  190. #define MAX_BUF_REG 128 // Should be same as MAX_REG_KEY_LEN
  191. #define MAX_BUF_ID 128
  192. #define NULL_CHAR '\0'
  193. #define ARRAYSIZE(rg) (sizeof(rg) / sizeof((rg)[0]))
  194. #define ARRAY_ELEMENTS(rg) ARRAYSIZE(rg)
  195. #define SIZECHARS(rg) ARRAYSIZE(rg)
  196. // Comparison return values
  197. //
  198. #define CMP_GREATER 1
  199. #define CMP_LESSER (-1)
  200. #define CMP_EQUAL 0
  201. // Count of characters to count of bytes
  202. //
  203. #define CbFromCchW(cch) ((cch)*sizeof(WCHAR))
  204. #define CbFromCchA(cch) ((cch)*sizeof(CHAR))
  205. #ifdef UNICODE
  206. #define CbFromCch CbFromCchW
  207. #else // UNICODE
  208. #define CbFromCch CbFromCchA
  209. #endif // UNICODE
  210. // 64-bit macros
  211. //
  212. #define HIDWORD(_qw) (DWORD)((_qw)>>32)
  213. #define LODWORD(_qw) (DWORD)(_qw)
  214. // Calling declarations
  215. //
  216. #define PUBLIC FAR PASCAL
  217. #define CPUBLIC FAR CDECL
  218. #define PRIVATE NEAR PASCAL
  219. // Range of resource ID indexes are 0x000 - 0x7ff
  220. #define IDS_BASE 0x1000
  221. #define IDS_ERR_BASE (IDS_BASE + 0x0000)
  222. #define IDS_OOM_BASE (IDS_BASE + 0x0800)
  223. #define IDS_MSG_BASE (IDS_BASE + 0x1000)
  224. #define IDS_RANDO_BASE (IDS_BASE + 0x1800)
  225. #define IDS_COMMON_BASE (IDS_BASE + 0x2000)
  226. // Resource string IDs for FileInfo
  227. #define IDS_BYTES (IDS_COMMON_BASE + 0x000)
  228. #define IDS_ORDERKB (IDS_COMMON_BASE + 0x001)
  229. #define IDS_ORDERMB (IDS_COMMON_BASE + 0x002)
  230. #define IDS_ORDERGB (IDS_COMMON_BASE + 0x003)
  231. #define IDS_ORDERTB (IDS_COMMON_BASE + 0x004)
  232. #define IDS_DATESIZELINE (IDS_COMMON_BASE + 0x005)
  233. #ifndef DECLARE_STANDARD_TYPES
  234. // For a type "FOO", define the standard derived types PFOO, CFOO, and PCFOO.
  235. //
  236. #define DECLARE_STANDARD_TYPES(type) typedef type FAR *P##type; \
  237. typedef const type C##type; \
  238. typedef const type FAR *PC##type;
  239. #endif
  240. // Zero-initialize data-item
  241. //
  242. #define ZeroInitSize(pobj, cb) MyZeroMemory(pobj, cb)
  243. #define ZeroInit(pobj) MyZeroMemory(pobj, sizeof(*(pobj)))
  244. // Copy chunk of memory
  245. //
  246. #define BltByte(pdest, psrc, cb) MyMoveMemory(pdest, psrc, cb)
  247. // Porting macros
  248. //
  249. #ifdef WIN32
  250. #define ISVALIDHINSTANCE(hinst) ((BOOL)(hinst != NULL))
  251. #define LOCALOF(lp) (lp)
  252. #define OFFSETOF(lp) (lp)
  253. #define DATASEG_READONLY ".text"
  254. #define DATASEG_PERINSTANCE ".instanc"
  255. #define DATASEG_SHARED ".data"
  256. #else // WIN32
  257. #define ISVALIDHINSTANCE(hinst) ((UINT)hinst >= (UINT)HINSTANCE_ERROR)
  258. #define LOCALOF(lp) ((HLOCAL)OFFSETOF(lp))
  259. #define DATASEG_READONLY "_TEXT"
  260. #define DATASEG_PERINSTANCE
  261. #define DATASEG_SHARED
  262. typedef LPCSTR LPCTSTR;
  263. typedef LPSTR LPTSTR;
  264. typedef char TCHAR;
  265. #endif // WIN32
  266. #define LocalFreePtr(p) LocalFree((HLOCAL)OFFSETOF(p))
  267. typedef UINT FAR *LPUINT;
  268. #endif // NOBASICS
  269. //
  270. // Run-time library replacements
  271. //
  272. #ifdef NORTL
  273. // (implemented privately)
  274. LPWSTR
  275. PUBLIC
  276. lmemmoveW(
  277. LPWSTR dst,
  278. LPCWSTR src,
  279. DWORD count);
  280. LPSTR
  281. PUBLIC
  282. lmemmoveA(
  283. LPSTR dst,
  284. LPCSTR src,
  285. DWORD count);
  286. #ifdef UNICODE
  287. #define lmemmove lmemmoveW
  288. #else
  289. #define lmemmove lmemmoveA
  290. #endif // UNICODE
  291. LPWSTR
  292. PUBLIC
  293. lmemsetW(
  294. LPWSTR dst,
  295. WCHAR val,
  296. DWORD count);
  297. LPSTR
  298. PUBLIC
  299. lmemsetA(
  300. LPSTR dst,
  301. CHAR val,
  302. DWORD count);
  303. #ifdef UNICODE
  304. #define lmemset lmemsetW
  305. #else
  306. #define lmemset lmemsetA
  307. #endif // UNICODE
  308. #define MyZeroMemory(p, cb) lmemset((LPTSTR)(p), 0, cb)
  309. #define MyMoveMemory(pdest, psrc, cb) lmemmove((LPTSTR)(pdest), (LPCTSTR)(psrc), cb)
  310. #else // NORTL
  311. #define MyZeroMemory ZeroMemory
  312. #define MyMoveMemory MoveMemory
  313. #endif // NORTL
  314. //
  315. // Memory and dynamic array functions
  316. //
  317. #ifndef NOMEM
  318. #include "rovmem.h"
  319. #endif // NOMEM
  320. //
  321. // Message string helpers
  322. //
  323. #ifndef NOMESSAGESTRING
  324. #if !defined(WIN32) && !defined(LANG_NEUTRAL)
  325. #define LANG_NEUTRAL 0x00
  326. #endif
  327. LPWSTR
  328. PUBLIC
  329. ConstructVMessageStringW(
  330. HINSTANCE hinst,
  331. LPCWSTR pwszMsg,
  332. va_list FAR * ArgList);
  333. LPSTR
  334. PUBLIC
  335. ConstructVMessageStringA(
  336. HINSTANCE hinst,
  337. LPCSTR pszMsg,
  338. va_list FAR * ArgList);
  339. #ifdef UNICODE
  340. #define ConstructVMessageString ConstructVMessageStringW
  341. #else // UNICODE
  342. #define ConstructVMessageString ConstructVMessageStringA
  343. #endif // UNICODE
  344. BOOL
  345. CPUBLIC
  346. ConstructMessageW(
  347. LPWSTR FAR * ppwsz,
  348. HINSTANCE hinst,
  349. LPCWSTR pwszMsg, ...);
  350. BOOL
  351. CPUBLIC
  352. ConstructMessageA(
  353. LPSTR FAR * ppsz,
  354. HINSTANCE hinst,
  355. LPCSTR pszMsg, ...);
  356. #ifdef UNICODE
  357. #define ConstructMessage ConstructMessageW
  358. #else // UNICODE
  359. #define ConstructMessage ConstructMessageA
  360. #endif // UNICODE
  361. #define SzFromIDSW(hinst, ids, pwszBuf, cchBuf) (LoadStringW(hinst, ids, pwszBuf, cchBuf), pwszBuf)
  362. #define SzFromIDSA(hinst, ids, pszBuf, cchBuf) (LoadStringA(hinst, ids, pszBuf, cchBuf), pszBuf)
  363. #ifdef UNICODE
  364. #define SzFromIDS SzFromIDSW
  365. #else // UNICODE
  366. #define SzFromIDS SzFromIDSA
  367. #endif // UNICODE
  368. int
  369. CPUBLIC
  370. MsgBoxW(
  371. HINSTANCE hinst,
  372. HWND hwndOwner,
  373. LPCWSTR pwszText,
  374. LPCWSTR pwszCaption,
  375. HICON hicon,
  376. DWORD dwStyle, ...);
  377. int
  378. CPUBLIC
  379. MsgBoxA(
  380. HINSTANCE hinst,
  381. HWND hwndOwner,
  382. LPCSTR pszText,
  383. LPCSTR pszCaption,
  384. HICON hicon,
  385. DWORD dwStyle, ...);
  386. #ifdef UNICODE
  387. #define MsgBox MsgBoxW
  388. #else // UNICODE
  389. #define MsgBox MsgBoxA
  390. #endif // UNICODE
  391. // Additional MB_ flags
  392. #define MB_WARNING (MB_OK | MB_ICONWARNING)
  393. #define MB_INFO (MB_OK | MB_ICONINFORMATION)
  394. #define MB_ERROR (MB_OK | MB_ICONERROR)
  395. #define MB_QUESTION (MB_YESNO | MB_ICONQUESTION)
  396. #endif // NOMESSAGESTRING
  397. //
  398. // String functions
  399. //
  400. #ifndef NOSTRING
  401. BOOL
  402. PUBLIC
  403. AnsiToIntW(
  404. LPCWSTR pszString,
  405. int FAR * piRet);
  406. BOOL
  407. PUBLIC
  408. AnsiToIntA(
  409. LPCSTR pszString,
  410. int FAR * piRet);
  411. #ifdef UNICODE
  412. #define AnsiToInt AnsiToIntW
  413. #else
  414. #define AnsiToInt AnsiToIntA
  415. #endif // UNICODE
  416. LPWSTR
  417. PUBLIC
  418. AnsiChrW(
  419. LPCWSTR psz,
  420. WORD wMatch);
  421. LPSTR
  422. PUBLIC
  423. AnsiChrA(
  424. LPCSTR psz,
  425. WORD wMatch);
  426. #ifdef UNICODE
  427. #define AnsiChr AnsiChrW
  428. #else
  429. #define AnsiChr AnsiChrA
  430. #endif // UNICODE
  431. LPWSTR
  432. PUBLIC
  433. AnsiRChrW(
  434. LPCWSTR psz,
  435. WORD wMatch);
  436. #ifdef UNICODE
  437. #define AnsiRChr AnsiRChrW
  438. #else
  439. #define AnsiRChr
  440. #endif // UNICODE
  441. #define IsSzEqual(sz1, sz2) (BOOL)(lstrcmpi(sz1, sz2) == 0)
  442. #define IsSzEqualC(sz1, sz2) (BOOL)(lstrcmp(sz1, sz2) == 0)
  443. #ifdef WIN32
  444. #define lstrnicmp(sz1, sz2, cch) (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, sz1, cch, sz2, cch) - 2)
  445. #define lstrncmp(sz1, sz2, cch) (CompareString(LOCALE_USER_DEFAULT, 0, sz1, cch, sz2, cch) - 2)
  446. #else
  447. int PUBLIC lstrnicmp(LPCSTR psz1, LPCSTR psz2, UINT count);
  448. int PUBLIC lstrncmp(LPCSTR psz1, LPCSTR psz2, UINT count);
  449. #endif // WIN32
  450. #define IsSzEqualN(sz1, sz2, cch) (BOOL)(0 == lstrnicmp(sz1, sz2, cch))
  451. #define IsSzEqualNC(sz1, sz2, cch) (BOOL)(0 == lstrncmp(sz1, sz2, cch))
  452. #endif // NOSTRING
  453. //
  454. // FileInfo functions
  455. //
  456. #if !defined(NOFILEINFO) && defined(WIN95)
  457. // FileInfo struct that contains file time/size info
  458. //
  459. typedef struct _FileInfo
  460. {
  461. HICON hicon;
  462. FILETIME ftMod;
  463. DWORD dwSize; // size of the file
  464. DWORD dwAttributes; // attributes
  465. LPARAM lParam;
  466. LPSTR pszDisplayName; // points to the display name
  467. CHAR szPath[1];
  468. } FileInfo;
  469. #define FIGetSize(pfi) ((pfi)->dwSize)
  470. #define FIGetPath(pfi) ((pfi)->szPath)
  471. #define FIGetDisplayName(pfi) ((pfi)->pszDisplayName)
  472. #define FIGetAttributes(pfi) ((pfi)->dwAttributes)
  473. #define FIIsFolder(pfi) (IsFlagSet((pfi)->dwAttributes, SFGAO_FOLDER))
  474. // Flags for FICreate
  475. #define FIF_DEFAULT 0x0000
  476. #define FIF_ICON 0x0001
  477. #define FIF_DONTTOUCH 0x0002
  478. #define FIF_FOLDER 0x0004
  479. HRESULT PUBLIC FICreate(LPCSTR pszPath, FileInfo ** ppfi, UINT uFlags);
  480. BOOL PUBLIC FISetPath(FileInfo ** ppfi, LPCSTR pszPathNew, UINT uFlags);
  481. BOOL PUBLIC FIGetInfoString(FileInfo * pfi, LPSTR pszBuf, int cchBuf);
  482. void PUBLIC FIFree(FileInfo * pfi);
  483. void PUBLIC FileTimeToDateTimeString(LPFILETIME pft, LPSTR pszBuf, int cchBuf);
  484. #endif // NOFILEINFO
  485. //
  486. // Color-from-owner-draw-state macros
  487. //
  488. #ifndef NOCOLORHELP
  489. #define ColorText(nState) (((nState) & ODS_SELECTED) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT)
  490. #define ColorBk(nState) (((nState) & ODS_SELECTED) ? COLOR_HIGHLIGHT : COLOR_WINDOW)
  491. #define ColorMenuText(nState) (((nState) & ODS_SELECTED) ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)
  492. #define ColorMenuBk(nState) (((nState) & ODS_SELECTED) ? COLOR_HIGHLIGHT : COLOR_MENU)
  493. #define GetImageDrawStyle(nState) (((nState) & ODS_SELECTED) ? ILD_SELECTED : ILD_NORMAL)
  494. #endif // NOCOLORHELP
  495. //
  496. // Dialog helper functions
  497. //
  498. #ifndef NODIALOGHELPER
  499. // Sets the dialog handle in the given data struct on first
  500. // message that the dialog gets (WM_SETFONT).
  501. //
  502. #define SetDlgHandle(hwnd, msg, lp) if((msg)==WM_SETFONT) (lp)->hdlg=(hwnd);
  503. #define DoModal DialogBoxParam
  504. VOID
  505. PUBLIC
  506. SetRectFromExtentW(
  507. HDC hdc,
  508. LPRECT lprc,
  509. LPCWSTR lpcwsz);
  510. VOID
  511. PUBLIC
  512. SetRectFromExtentA(
  513. HDC hdc,
  514. LPRECT lprc,
  515. LPCSTR lpcsz);
  516. #ifdef UNICODE
  517. #define SetRectFromExtent SetRectFromExtentW
  518. #else
  519. #define SetRectFromExtent SetRectFromExtentA
  520. #endif // UNICODE
  521. #endif // NODIALOGHELPER
  522. //
  523. // Enhanced form of DrawText()
  524. //
  525. #ifndef NODRAWTEXT
  526. // Flags for MyDrawText()
  527. #define MDT_DRAWTEXT 0x00000001
  528. #define MDT_ELLIPSES 0x00000002
  529. #define MDT_LINK 0x00000004
  530. #define MDT_SELECTED 0x00000008
  531. #define MDT_DESELECTED 0x00000010
  532. #define MDT_DEPRESSED 0x00000020
  533. #define MDT_EXTRAMARGIN 0x00000040
  534. #define MDT_TRANSPARENT 0x00000080
  535. #define MDT_LEFT 0x00000100
  536. #define MDT_RIGHT 0x00000200
  537. #define MDT_CENTER 0x00000400
  538. #define MDT_VCENTER 0x00000800
  539. #define MDT_CLIPPED 0x00001000
  540. #ifndef CLR_DEFAULT // (usually defined in commctrl.h)
  541. #define CLR_DEFAULT 0xFF000000L
  542. #endif
  543. void
  544. PUBLIC
  545. MyDrawTextW(
  546. HDC hdc,
  547. LPCWSTR pwszText,
  548. RECT FAR* prc,
  549. UINT flags,
  550. int cyChar,
  551. int cxEllipses,
  552. COLORREF clrText,
  553. COLORREF clrTextBk);
  554. void
  555. PUBLIC
  556. MyDrawTextA(
  557. HDC hdc,
  558. LPCSTR pszText,
  559. RECT FAR* prc,
  560. UINT flags,
  561. int cyChar,
  562. int cxEllipses,
  563. COLORREF clrText,
  564. COLORREF clrTextBk);
  565. #ifdef UNICODE
  566. #define MyDrawText MyDrawTextW
  567. #else
  568. #define MyDrawText MyDrawTextA
  569. #endif // UNICODE
  570. void PUBLIC GetCommonMetrics(WPARAM wParam);
  571. extern int g_cxLabelMargin;
  572. extern int g_cxBorder;
  573. extern int g_cyBorder;
  574. extern COLORREF g_clrHighlightText;
  575. extern COLORREF g_clrHighlight;
  576. extern COLORREF g_clrWindowText;
  577. extern COLORREF g_clrWindow;
  578. extern HBRUSH g_hbrHighlight;
  579. extern HBRUSH g_hbrWindow;
  580. #endif // NODRAWTEXT
  581. //
  582. // Synchronization
  583. //
  584. #ifndef NOSYNC
  585. // Safe version of MsgWaitMultipleObjects()
  586. //
  587. DWORD PUBLIC MsgWaitObjectsSendMessage(DWORD cObjects, LPHANDLE phObjects, DWORD dwTimeout);
  588. #else // NOSYNC
  589. #endif // NOSYNC
  590. //
  591. // Path whacking functions
  592. //
  593. #if !defined(NOPATH) && defined(WIN95)
  594. BOOL PUBLIC WPPathIsRoot(LPCSTR pszPath);
  595. BOOL PUBLIC WPPathIsUNC(LPCSTR pszPath);
  596. LPSTR PUBLIC WPRemoveBackslash(LPSTR lpszPath);
  597. LPSTR PUBLIC WPRemoveExt(LPCSTR pszPath, LPSTR pszBuf);
  598. LPSTR PUBLIC WPFindNextComponentI(LPCSTR lpszPath);
  599. void PUBLIC WPMakePresentable(LPSTR pszPath);
  600. BOOL PUBLIC WPPathsTooLong(LPCSTR pszFolder, LPCSTR pszName);
  601. void PUBLIC WPCanonicalize(LPCSTR pszPath, LPSTR pszBuf);
  602. LPSTR PUBLIC WPFindFileName(LPCSTR pPath);
  603. BOOL PUBLIC WPPathExists(LPCSTR pszPath);
  604. LPCSTR PUBLIC WPFindEndOfRoot(LPCSTR pszPath);
  605. BOOL PUBLIC WPPathIsPrefix(LPCSTR lpcszPath1, LPCSTR lpcszPath2);
  606. #ifdef WANT_SHELL_SUPPORT
  607. LPSTR PUBLIC WPGetDisplayName(LPCSTR pszPath, LPSTR pszBuf);
  608. // Events for WPNotifyShell
  609. typedef enum _notifyshellevent
  610. {
  611. NSE_CREATE = 0,
  612. NSE_MKDIR,
  613. NSE_UPDATEITEM,
  614. NSE_UPDATEDIR
  615. } NOTIFYSHELLEVENT;
  616. void PUBLIC WPNotifyShell(LPCSTR pszPath, NOTIFYSHELLEVENT nse, BOOL bDoNow);
  617. #endif // WANT_SHELL_SUPPORT
  618. #endif // !defined(NOPATH) && defined(WIN95)
  619. //
  620. // Profile (.ini) support functions
  621. //
  622. // (Currently all profile functions are for DEBUG use only
  623. #ifndef DEBUG
  624. #define NOPROFILE
  625. #endif
  626. #ifndef NOPROFILE
  627. #ifndef SZ_DEBUGINI
  628. #pragma message("SZ_DEBUGINI is not #defined. Assuming \"rover.ini\".")
  629. #define SZ_DEBUGINI "rover.ini"
  630. #endif
  631. #ifndef SZ_DEBUGSECTION
  632. #pragma message("SZ_DEBUGSECTION is not #defined. Assuming [Debug].")
  633. #define SZ_DEBUGSECTION "Debug"
  634. #endif
  635. BOOL PUBLIC RovComm_ProcessIniFile(void);
  636. #else // NOPROFILE
  637. #define RovComm_ProcessIniFile() TRUE
  638. #endif // NOPROFILE
  639. //
  640. // Debug helper functions
  641. //
  642. // Break flags
  643. #define BF_ONVALIDATE 0x00000001
  644. #define BF_ONOPEN 0x00000002
  645. #define BF_ONCLOSE 0x00000004
  646. #define BF_ONRUNONCE 0x00000008
  647. #define BF_ONTHREADATT 0x00000010
  648. #define BF_ONTHREADDET 0x00000020
  649. #define BF_ONPROCESSATT 0x00000040
  650. #define BF_ONPROCESSDET 0x00000080
  651. #define BF_ONAPIENTER 0x00000100
  652. // Trace flags
  653. #define TF_ALWAYS 0x00000000
  654. #define TF_WARNING 0x00000001
  655. #define TF_ERROR 0x00000002
  656. #define TF_GENERAL 0x00000004 // Standard messages
  657. #define TF_FUNC 0x00000008 // Trace function calls
  658. // (Upper 16 bits reserved for user)
  659. #if defined(NODEBUGHELP) || !defined(DEBUG)
  660. #define DEBUG_BREAK (void)0
  661. #define ASSERT(f)
  662. #define EVAL(f) (f)
  663. #define ASSERT_MSG {}
  664. #define DEBUG_MSG {}
  665. #define TRACE_MSGA {}
  666. #define TRACE_MSGW {}
  667. #ifdef UNICODE
  668. #define TRACE_MSG TRACE_MSGW
  669. #else
  670. #define TRACE_MSG TRACE_MSGA
  671. #endif
  672. #define VERIFY_SZ(f, szFmt, x) (f)
  673. #define VERIFY_SZ2(f, szFmt, x1, x2) (f)
  674. #define DBG_ENTER(fn)
  675. #define DBG_ENTER_SZ(fn, sz)
  676. #define DBG_ENTER_DTOBJ(fn, pdtobj, sz)
  677. #define DBG_ENTER_RIID(fn, riid)
  678. #define DBG_ENTER_UL(fn, ul)
  679. #define DBG_EXIT(fn)
  680. #define DBG_EXIT_TYPE(fn, dw, pfnStrFromType)
  681. #define DBG_EXIT_INT(fn, n)
  682. #define DBG_EXIT_BOOL(fn, b)
  683. #define DBG_EXIT_US(fn, us)
  684. #define DBG_EXIT_UL(fn, ul)
  685. #define DBG_EXIT_DWORD DBG_EXIT_UL
  686. #define DBG_EXIT_PTR(fn, ptr)
  687. #define DBG_EXIT_HRES(fn, hres)
  688. #else // defined(NODEBUGHELP) || !defined(DEBUG)
  689. extern DWORD g_dwDumpFlags;
  690. extern DWORD g_dwBreakFlags;
  691. extern DWORD g_dwTraceFlags;
  692. extern LONG g_dwIndent;
  693. // Debugging macros
  694. //
  695. #ifndef SZ_MODULEA
  696. #error SZ_MODULEA is not #defined
  697. #endif
  698. #if defined(UNICODE) && !defined(SZ_MODULEW)
  699. #error SZ_MODULEW is not #defined
  700. #endif
  701. #define DEBUG_CASE_STRING(x) case x: return #x
  702. #define DEBUG_STRING_MAPW(x) { x, TEXT(#x) }
  703. #define DEBUG_STRING_MAPA(x) { x, #x }
  704. #ifdef UNICODE
  705. #define DEBUG_STRING_MAP DEBUG_STRING_MAPW
  706. #else // UNICODE
  707. #define DEBUG_STRING_MAP DEBUG_STRING_MAPA
  708. #endif // UNICODE
  709. #define ASSERTSEG
  710. // Use this macro to declare message text that will be placed
  711. // in the CODE segment (useful if DS is getting full)
  712. //
  713. // Ex: DEBUGTEXT(szMsg, "Invalid whatever: %d");
  714. //
  715. #define DEBUGTEXT(sz, msg) \
  716. static const CHAR ASSERTSEG sz[] = msg;
  717. void PUBLIC CommonDebugBreak(DWORD flag);
  718. void PUBLIC CommonAssertFailed(LPCSTR szFile, int line);
  719. void
  720. CPUBLIC
  721. CommonAssertMsgW(
  722. BOOL f,
  723. LPCWSTR pwszMsg, ...);
  724. void
  725. CPUBLIC
  726. CommonAssertMsgA(
  727. BOOL f,
  728. LPCSTR pszMsg, ...);
  729. #ifdef UNICODE
  730. #define CommonAssertMsg CommonAssertMsgW
  731. #else
  732. #define CommonAssertMsg CommonAssertMsgA
  733. #endif // UNICODE
  734. BOOL WINAPI
  735. DisplayDebug(
  736. DWORD flag
  737. );
  738. void
  739. CPUBLIC
  740. CommonDebugMsgW(
  741. DWORD mask,
  742. LPCSTR pszMsg, ...);
  743. void
  744. CPUBLIC
  745. CommonDebugMsgA(
  746. DWORD mask,
  747. LPCSTR pszMsg, ...);
  748. #ifdef UNICODE
  749. #define CommonDebugMsg CommonDebugMsgW
  750. #else
  751. #define CommonDebugMsg CommonDebugMsgA
  752. #endif // UNICODE
  753. LPCWSTR
  754. PUBLIC
  755. Dbg_SafeStrW(
  756. LPCWSTR pwsz);
  757. LPCSTR
  758. PUBLIC
  759. Dbg_SafeStrA(
  760. LPCSTR psz);
  761. #ifdef UNICODE
  762. #define Dbg_SafeStr Dbg_SafeStrW
  763. #else
  764. #define Dbg_SafeStr Dbg_SafeStrA
  765. #endif // UNICODE
  766. #define DEBUG_BREAK CommonDebugBreak
  767. // ASSERT(f) -- Generate "assertion failed in line x of file.c"
  768. // message if f is NOT true.
  769. //
  770. #define ASSERT(f) \
  771. { \
  772. DEBUGTEXT(szFile, __FILE__); \
  773. if (!(f)) \
  774. CommonAssertFailed(szFile, __LINE__); \
  775. }
  776. #define EVAL ASSERT
  777. // ASSERT_MSG(f, msg, args...) -- Generate wsprintf-formatted
  778. // messsage w/params if f is NOT true.
  779. //
  780. #define ASSERT_MSG CommonAssertMsg
  781. // TRACE_MSG(mask, msg, args...) - Generate wsprintf-formatted msg using
  782. // specified debug mask. System debug mask
  783. // governs whether message is output.
  784. //
  785. #define TRACE_MSGW CommonDebugMsgW
  786. #define TRACE_MSGA CommonDebugMsgA
  787. #define TRACE_MSG CommonDebugMsg
  788. // VERIFY_SZ(f, msg, arg) -- Generate wsprintf-formatted msg w/ 1 param
  789. // if f is NOT true
  790. //
  791. #define VERIFY_SZ(f, szFmt, x) ASSERT_MSG(f, szFmt, x)
  792. // VERIFY_SZ2(f, msg, arg1, arg2) -- Generate wsprintf-formatted msg w/ 2
  793. // param if f is NOT true
  794. //
  795. #define VERIFY_SZ2(f, szFmt, x1, x2) ASSERT_MSG(f, szFmt, x1, x2)
  796. // DBG_ENTER(fn) -- Generates a function entry debug spew for
  797. // a function
  798. //
  799. #define DBG_ENTER(fn) \
  800. TRACE_MSG(TF_FUNC, "> " #fn "()");\
  801. g_dwIndent+=2
  802. // DBG_ENTER_SZ(fn, sz) -- Generates a function entry debug spew for
  803. // a function that accepts a string as one of its
  804. // parameters.
  805. //
  806. #define DBG_ENTER_SZ(fn, sz) \
  807. TRACE_MSG(TF_FUNC, "> " #fn "(..., \"%s\",...)", Dbg_SafeStr(sz)); \
  808. g_dwIndent+=2
  809. // DBG_ENTER_UL(fn, ul) -- Generates a function entry debug spew for
  810. // a function that accepts a DWORD as one of its
  811. // parameters.
  812. //
  813. #define DBG_ENTER_UL(fn, ul) \
  814. TRACE_MSG(TF_FUNC, "> " #fn "(..., %#08lx,...)", (ULONG)(ul)); \
  815. g_dwIndent+=2
  816. #ifdef WANT_OLE_SUPPORT
  817. // DBG_ENTER_RIID(fn, riid) -- Generates a function entry debug spew for
  818. // a function that accepts an riid as one of its
  819. // parameters.
  820. //
  821. #define DBG_ENTER_RIID(fn, riid) \
  822. TRACE_MSG(TF_FUNC, "> " #fn "(..., %s,...)", Dbg_GetRiidName(riid)); \
  823. g_dwIndent+=2
  824. #endif
  825. // DBG_EXIT(fn) -- Generates a function exit debug spew
  826. //
  827. #define DBG_EXIT(fn) \
  828. g_dwIndent-=2; \
  829. TRACE_MSG(TF_FUNC, "< " #fn "()")
  830. // DBG_EXIT_TYPE(fn, dw, pfnStrFromType) -- Generates a function exit debug
  831. // spew for functions that return <type>.
  832. //
  833. #define DBG_EXIT_TYPE(fn, dw, pfnStrFromType) \
  834. g_dwIndent-=2; \
  835. TRACE_MSG(TF_FUNC, "< " #fn "() with %s", (LPCTSTR)pfnStrFromType(dw))
  836. // DBG_EXIT_INT(fn, us) -- Generates a function exit debug spew for
  837. // functions that return an INT.
  838. //
  839. #define DBG_EXIT_INT(fn, n) \
  840. g_dwIndent-=2; \
  841. TRACE_MSG(TF_FUNC, "< " #fn "() with %d", (int)(n))
  842. // DBG_EXIT_BOOL(fn, b) -- Generates a function exit debug spew for
  843. // functions that return a boolean.
  844. //
  845. #define DBG_EXIT_BOOL(fn, b) \
  846. g_dwIndent-=2; \
  847. TRACE_MSG(TF_FUNC, "< " #fn "() with %s", (b) ? (LPTSTR)TEXT("TRUE") : (LPTSTR)TEXT("FALSE"))
  848. // DBG_EXIT_US(fn, us) -- Generates a function exit debug spew for
  849. // functions that return a USHORT.
  850. //
  851. #define DBG_EXIT_US(fn, us) \
  852. g_dwIndent-=2; \
  853. TRACE_MSG(TF_FUNC, "< " #fn "() with %#x", (USHORT)(us))
  854. // DBG_EXIT_UL(fn, ul) -- Generates a function exit debug spew for
  855. // functions that return a ULONG.
  856. //
  857. #define DBG_EXIT_UL(fn, ul) \
  858. g_dwIndent-=2; \
  859. TRACE_MSG(TF_FUNC, "< " #fn "() with %#08lx", (ULONG)(ul))
  860. #define DBG_EXIT_DWORD DBG_EXIT_UL
  861. // DBG_EXIT_PTR(fn, pv) -- Generates a function exit debug spew for
  862. // functions that return a pointer.
  863. //
  864. #define DBG_EXIT_PTR(fn, pv) \
  865. g_dwIndent-=2; \
  866. TRACE_MSG(TF_FUNC, "< " #fn "() with %#lx", (LPVOID)(pv))
  867. // DBG_EXIT_HRES(fn, hres) -- Generates a function exit debug spew for
  868. // functions that return an HRESULT.
  869. //
  870. #define DBG_EXIT_HRES(fn, hres) DBG_EXIT_TYPE(fn, hres, Dbg_GetScode)
  871. #endif // defined(NODEBUGHELP) || !defined(DEBUG)
  872. //
  873. // Standard functions
  874. //
  875. BOOL PUBLIC RovComm_Init(HINSTANCE hinst);
  876. BOOL PUBLIC RovComm_Terminate(HINSTANCE hinst);
  877. // Admin related
  878. BOOL PUBLIC IsAdminUser(void);
  879. //
  880. // Device Installer wrappers and helper functions
  881. //
  882. #ifndef NODI
  883. #include <rovdi.h>
  884. #endif // NODI
  885. LONG
  886. QueryModemForCountrySettings(
  887. HKEY ModemRegKey,
  888. BOOL ForceRequery
  889. );
  890. typedef LONG (*lpQueryModemForCountrySettings)(
  891. HKEY ModemRegKey,
  892. BOOL ForceRequery
  893. );
  894. #endif // __ROVCOMM_H__