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.

312 lines
11 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: srvr.h
  3. *
  4. * PURPOSE: Private definitions file for server code
  5. *
  6. * Created: 1990
  7. *
  8. * Copyright (c) 1990, 1991 Microsoft Corporation
  9. *
  10. * History:
  11. * Raor (../../90,91) Original
  12. * curts created portable version for WIN16/32
  13. *
  14. \***************************************************************************/
  15. #include "port1632.h"
  16. #define DEFSTD_ITEM_INDEX 0
  17. #define STDTARGETDEVICE 1
  18. #define STDDOCDIMENSIONS 2
  19. #define STDCOLORSCHEME 3
  20. #define STDHOSTNAMES 4
  21. #define PROTOCOL_EDIT ((LPSTR)"StdFileEditing")
  22. #define PROTOCOL_EXECUTE ((LPSTR)"StdExecute")
  23. #define SRVR_CLASS ((LPSTR)"SrvrWndClass")
  24. #define DOC_CLASS ((LPSTR)"DocWndClass")
  25. #define ITEM_CLASS ((LPSTR)"ItemWndClass")
  26. #define ISATOM(a) ((a >= 0xC000) && (a <= 0xFFFF))
  27. #define MAX_STR 124
  28. #define WW_LPTR 0 // ptr tosrvr/doc/item
  29. #define WW_HANDLE WW_LPTR + sizeof(PVOID) // instance handle
  30. #define WW_LE WW_HANDLE + sizeof(PVOID) // signature
  31. #define WC_LE 0x4c45 // LE chars
  32. // If we running under WLO, the HIGHWORD of version number will be >= 0x0A00
  33. #define VER_WLO 0x0A00
  34. extern WORD CheckPointer (LPVOID, int);
  35. #define READ_ACCESS 0
  36. #define WRITE_ACCESS 1
  37. #define PROBE_READ(lp){\
  38. if (!CheckPointer((LPVOID)(lp), READ_ACCESS))\
  39. return OLE_ERROR_ADDRESS; \
  40. }
  41. #define PROBE_WRITE(lp){\
  42. if (!CheckPointer((LPVOID)(lp), WRITE_ACCESS))\
  43. return OLE_ERROR_ADDRESS; \
  44. }
  45. #define OLE_COMMAND 1
  46. #define NON_OLE_COMMAND 2
  47. #define WT_SRVR 0 // server window
  48. #define WT_DOC 1 // document window
  49. #define PROBE_BLOCK(lpsrvr) { \
  50. if (lpsrvr->bBlock) \
  51. return OLE_ERROR_SERVER_BLOCKED; \
  52. }
  53. #define SET_MSG_STATUS(retval, status) { \
  54. if (retval == OLE_OK) \
  55. status |= 0x8000; \
  56. if (retval == OLE_BUSY) \
  57. status |= 0x4000; \
  58. }
  59. typedef LHSERVER LHSRVR;
  60. typedef LHSERVERDOC LHDOC;
  61. typedef struct _QUE { // nodes in Block/Unblock queue
  62. HWND hwnd; //***
  63. unsigned msg; // window
  64. WPARAM wParam; // procedure parameters
  65. LPARAM lParam; //***
  66. HANDLE hqNext; // handle to next node
  67. int wType; // WT_SRVR || WT_DOC
  68. } QUE;
  69. typedef QUE NEAR * PQUE;
  70. typedef QUE FAR * LPQUE;
  71. typedef struct _SRVR { /*srvr*/ // private data
  72. LPOLESERVER lpolesrvr; // corresponding server
  73. char sig[2]; // signature "SR"
  74. HANDLE hsrvr; // global handle
  75. ATOM aClass; // class atom
  76. ATOM aExe;
  77. HWND hwnd; // corresponding window
  78. BOOL bTerminate; // Set if we are terminating.
  79. int termNo; // termination count
  80. BOOL relLock; // ok to release the server.
  81. BOOL bnoRelease; // Block release. call
  82. OLE_SERVER_USE useFlags; // instance usage flags
  83. int cClients; // no of clients;
  84. BOOL bBlock; // blocked if TRUE
  85. BOOL bBlockedMsg; // msg from block queue if TRUE
  86. HANDLE hqHead; // Head and tail of the blocked
  87. HANDLE hqTail; // messages queue.
  88. HANDLE hqPostHead; // Head and tail of the blocked post msg
  89. HANDLE hqPostTail; // .
  90. BOOL fAckExit;
  91. HWND hwndExit;
  92. HANDLE hDataExit;
  93. } SRVR;
  94. typedef SRVR FAR *LPSRVR;
  95. LRESULT FAR PASCAL DocWndProc (HWND, UINT, WPARAM, LPARAM);
  96. LRESULT FAR PASCAL ItemWndProc (HWND, UINT, WPARAM, LPARAM);
  97. LRESULT FAR PASCAL SrvrWndProc (HWND, UINT, WPARAM, LPARAM);
  98. BOOL FAR PASCAL TerminateClients (HWND, LPSTR, HANDLE);
  99. void SendMsgToChildren (HWND, UINT, WPARAM, LPARAM);
  100. OLESTATUS INTERNAL RequestDataStd (LPARAM, HANDLE FAR *);
  101. BOOL INTERNAL ValidateSrvrClass (LPCSTR, ATOM FAR *);
  102. ATOM INTERNAL GetExeAtom (LPSTR);
  103. BOOL INTERNAL AddClient (HWND, HANDLE, HANDLE);
  104. BOOL INTERNAL DeleteClient (HWND, HANDLE);
  105. HANDLE INTERNAL FindClient (HWND, HANDLE);
  106. BOOL INTERNAL MakeSrvrStr(LPSTR, int, LPSTR, HANDLE);
  107. int INTERNAL RevokeAllDocs (LPSRVR);
  108. int INTERNAL ReleaseSrvr (LPSRVR);
  109. void INTERNAL WaitForTerminate (LPSRVR);
  110. OLESTATUS INTERNAL SrvrExecute (HWND, HANDLE, HWND);
  111. BOOL INTERNAL HandleInitMsg (LPSRVR, LPARAM);
  112. BOOL INTERNAL QueryRelease (LPSRVR);
  113. BOOL INTERNAL IsSingleServerInstance (void);
  114. // doc stuff
  115. typedef struct _DOC { /*doc*/ // private data
  116. LPOLESERVERDOC lpoledoc; // corresponding oledoc
  117. char sig[2]; // signature "SD"
  118. HANDLE hdoc; // global handle
  119. ATOM aDoc;
  120. HWND hwnd;
  121. BOOL bTerminate;
  122. int termNo;
  123. int cClients; // no of clients;
  124. BOOL fEmbed; // TRUE if embedded document
  125. BOOL fAckClose;
  126. HWND hwndClose;
  127. HANDLE hDataClose;
  128. } DOC;
  129. typedef DOC FAR *LPDOC;
  130. LPDOC INTERNAL FindDoc (LPSRVR, LPSTR);
  131. int INTERNAL ReleaseDoc (LPDOC);
  132. OLESTATUS INTERNAL DocExecute (HWND, HANDLE, HWND);
  133. BOOL FAR PASCAL TerminateDocClients (HWND, LPSTR, HANDLE);
  134. int INTERNAL DocShowItem (LPDOC, LPSTR, BOOL);
  135. int INTERNAL DocDoVerbItem (LPDOC, LPSTR, UINT, BOOL, BOOL);
  136. // client struct definitions.
  137. typedef struct _CLIENT { /*doc*/ // private data
  138. OLECLIENT oleClient; // oleclient structure
  139. LPOLEOBJECT lpoleobject; // corresponding oledoc
  140. HANDLE hclient; // global handle
  141. ATOM aItem; // item atom or index for some std items
  142. HWND hwnd; // item window
  143. HANDLE hdevInfo; // latest printer dev info sent
  144. } CLIENT;
  145. typedef CLIENT FAR *LPCLIENT;
  146. typedef struct _CLINFO { /*clInfo*/ // client transaction info
  147. HWND hwnd; // client window handle
  148. BOOL bnative; // doe sthis client require native
  149. OLECLIPFORMAT format; // dusplay format
  150. int options; // transaction advise time otipns
  151. BOOL bdata; // need wdat with advise?
  152. HANDLE hdevInfo; // device info handle
  153. BOOL bnewDevInfo; // new device info
  154. } CLINFO;
  155. typedef CLINFO *PCLINFO;
  156. BOOL FAR PASCAL FindItemWnd (HWND, LONG);
  157. BOOL FAR PASCAL SendRenameMsg (HWND, LPSTR, HANDLE);
  158. BOOL FAR PASCAL EnumForTerminate (HWND, LPSTR, HANDLE);
  159. BOOL FAR PASCAL SendDataMsg(HWND, LPSTR, HANDLE);
  160. BOOL FAR PASCAL DeleteClientInfo (HWND, LPSTR, HANDLE);
  161. int FAR PASCAL ItemCallBack (LPOLECLIENT, OLE_NOTIFICATION, LPOLEOBJECT);
  162. int INTERNAL RegisterItem (LHDOC, LPSTR, LPCLIENT FAR *, BOOL);
  163. int INTERNAL FindItem (LPDOC, LPSTR, LPCLIENT FAR *);
  164. HWND INTERNAL SearchItem (LPDOC, LPSTR);
  165. void INTERNAL DeleteFromItemsList (HWND, HWND);
  166. void INTERNAL DeleteAllItems (HWND);
  167. OLESTATUS INTERNAL PokeData (LPDOC, HWND, LPARAM);
  168. HANDLE INTERNAL MakeItemData (DDEPOKE FAR *, HANDLE, OLECLIPFORMAT);
  169. OLESTATUS INTERNAL AdviseData (LPDOC, HWND, LPARAM, BOOL FAR *);
  170. OLESTATUS INTERNAL AdviseStdItems (LPDOC, HWND, LPARAM, BOOL FAR *);
  171. OLESTATUS INTERNAL UnAdviseData (LPDOC, HWND, LPARAM);
  172. OLESTATUS INTERNAL RequestData (LPDOC, HWND, LPARAM, HANDLE FAR *);
  173. BOOL INTERNAL MakeDDEData (HANDLE, OLECLIPFORMAT, LPHANDLE, BOOL);
  174. HANDLE INTERNAL MakeGlobal (LPCSTR);
  175. OLESTATUS INTERNAL ScanItemOptions (LPSTR, int far *);
  176. OLESTATUS INTERNAL PokeStdItems (LPDOC, HWND, HANDLE, int);
  177. int INTERNAL GetStdItemIndex (ATOM);
  178. BOOL INTERNAL IsAdviseStdItems (ATOM);
  179. int INTERNAL SetStdInfo (LPDOC, HWND, LPSTR, HANDLE);
  180. void INTERNAL SendDevInfo (LPCLIENT, LPSTR);
  181. BOOL INTERNAL IsFormatAvailable (LPCLIENT, OLECLIPFORMAT);
  182. OLESTATUS INTERNAL RevokeObject (LPOLECLIENT, BOOL);
  183. BOOL INTERNAL AddMessage (HWND, UINT, WPARAM, LPARAM, int);
  184. #define ITEM_FIND 1 // find the item
  185. #define ITEM_DELETECLIENT 2 // delete the client from item clients
  186. #define ITEM_DELETE 3 // delete th item window itself
  187. #define ITEM_SAVED 4 // item saved
  188. // host names data structcure
  189. typedef struct _HOSTNAMES {
  190. WORD clientNameOffset;
  191. WORD documentNameOffset;
  192. BYTE data[];
  193. } HOSTNAMES;
  194. typedef HOSTNAMES FAR * LPHOSTNAMES;
  195. // routines in UTILS.C
  196. void INTERNAL MapToHexStr (LPSTR, HANDLE);
  197. void INTERNAL UtilMemCpy (LPSTR, LPCSTR, DWORD);
  198. HANDLE INTERNAL DuplicateData (HANDLE);
  199. LPSTR INTERNAL ScanArg(LPSTR);
  200. LPSTR INTERNAL ScanBoolArg (LPSTR, BOOL FAR *);
  201. WORD INTERNAL ScanCommand(LPSTR, UINT, LPSTR FAR *, ATOM FAR *);
  202. LPSTR INTERNAL ScanLastBoolArg (LPSTR);
  203. LPSTR INTERNAL ScanNumArg (LPSTR, LPINT);
  204. ATOM INTERNAL MakeDataAtom (ATOM, int);
  205. ATOM INTERNAL DuplicateAtom (ATOM);
  206. WORD INTERNAL StrToInt (LPSTR);
  207. BOOL INTERNAL CheckServer (LPSRVR);
  208. BOOL INTERNAL CheckServerDoc (LPDOC);
  209. BOOL INTERNAL PostMessageToClientWithBlock (HWND, UINT, WPARAM, LPARAM);
  210. BOOL INTERNAL PostMessageToClient (HWND, UINT, WPARAM, LPARAM);
  211. BOOL INTERNAL IsWindowValid (HWND);
  212. BOOL INTERNAL IsOleCommand (ATOM, UINT);
  213. BOOL INTERNAL UtilQueryProtocol (ATOM, LPSTR);
  214. // routines for queueing messages and posting them
  215. BOOL INTERNAL UnblockPostMsgs(HWND, BOOL);
  216. BOOL INTERNAL BlockPostMsg (HWND, UINT, WPARAM, LPARAM);
  217. BOOL INTERNAL IsBlockQueueEmpty (HWND);
  218. // routine in GIVE2GDI.ASM
  219. HANDLE FAR PASCAL GiveToGDI (HANDLE);
  220. // routine in item.c
  221. HBITMAP INTERNAL DuplicateBitmap (HBITMAP);
  222. HANDLE INTERNAL DuplicateMetaFile (HANDLE);
  223. // routines in doc.c
  224. void INTERNAL FreePokeData (HANDLE);
  225. BOOL INTERNAL FreeGDIdata (HANDLE, OLECLIPFORMAT);
  226. // props stuff
  227. #ifdef WIN16
  228. #define MAKE_DDE_LPARAM(x,y,z) MAKELONG(y,z)
  229. //#define ENUMPROPS EnumProps
  230. //#define REMOVEPROP RemoveProp
  231. //#define GETPROP GetProp
  232. //#define SETPROP SetProp
  233. #endif
  234. #ifdef WIN32
  235. #define MAKE_DDE_LPARAM(x,y,z) PackDDElParam((UINT)x,(UINT_PTR)y,(UINT_PTR)z)
  236. //#define ENUMPROPS OleEnumProps
  237. //#define REMOVEPROP OleRemoveProp
  238. //#define GETPROP OleGetProp
  239. //#define SETPROP OleSetProp
  240. #endif