home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / ddeml / ddemlp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  18.8 KB  |  566 lines

  1. /****************************** Module Header ******************************\
  2. * Module Name: DMGP.H
  3. *
  4. * Private header for DDE manager DLL.
  5. *
  6. * Created:      12/16/88    by Sanford Staab
  7. * 6/12/90 sanfords  Added definitions so it can compile on SLOOP environment.
  8. *                   Added ST_BOTHDLLCLIENTS
  9. *                   Added Dynamic DDE initiate APIs
  10. *                   Reconciled PQUEUEITEM and QST structures
  11. *
  12. * Copyright (c) 1988, 1989  Microsoft Corporation
  13. \***************************************************************************/
  14.  
  15. #define INCL_DOSPROCESS
  16. #define INCL_DOSMEMMGR
  17. #define INCL_DOSSEMAPHORES
  18. #define INCL_WIN
  19. #define INCL_WINDDE
  20. #define INCL_WINATOM
  21. #define INCL_WINHEAP
  22. #define INCL_DOSNLS
  23. #include "os2.h"
  24. #include "ddeml.h"
  25.  
  26. typedef HATOMTBL FAR *PHATOMTBL;
  27. typedef ULONG LATOM;
  28.  
  29. /***** structures *****/
  30.  
  31.  
  32.  
  33. /*
  34.  * generic list structures
  35.  */
  36. typedef struct _LITEM {         /* 4 */
  37.     struct _LITEM FAR *next;    /* 0 */
  38. } LITEM;
  39. typedef LITEM FAR *PLITEM;
  40.  
  41. typedef struct _LST {           /* A */
  42.     PLITEM pItemFirst;          /* 0 */
  43.     HHEAP hheap;                /* 4 */
  44.     USHORT cbItem;              /* 8 */
  45. } LST;
  46. typedef LST FAR *PLST;
  47.  
  48. #define ILST_LAST       0x0000
  49. #define ILST_FIRST      0x0001
  50. #define ILST_NOLINK     0x0002
  51.  
  52.  
  53. /*
  54.  * Specific list item structures
  55.  */
  56. typedef struct _CBLI {      /* 20 callback list item */
  57.     PLITEM next;            /* 0 */
  58.     HCONV hConv;            /* 4 perameters for callback */
  59.     HSZ hszTopic;           /* 8 */
  60.     HSZ hszItem;            /* C */
  61.     USHORT usFmt;           /* 10 */
  62.     USHORT usType;          /* 12 */
  63.     HDMGDATA hDmgData;      /* 14 */
  64.     USHORT msg;             /* 18 DDE message received that created this item */
  65.     USHORT fsStatus;        /* 1A Status from DDE msg */
  66.     HCONV hConvPartner;     /* 1C source window */
  67. } CBLI;
  68. typedef CBLI FAR *PCBLI;
  69.  
  70. typedef struct _HSZLI {     /* 8 */
  71.     PLITEM next;            /* 0 */
  72.     HSZ hsz;                /* 4 */
  73. } HSZLI;
  74. typedef HSZLI FAR *PHSZLI;
  75.  
  76. typedef struct _HWNDLI {    /* 8 */
  77.     PLITEM next;            /* 0 */
  78.     HWND   hwnd;            /* 4 */
  79. } HWNDLI;
  80. typedef HWNDLI FAR *PHWNDLI;
  81.  
  82. typedef struct _ACKHWNDLI { /* 10 */
  83.     PLITEM next;            /* 0 */
  84.     HWND   hwnd;            /* 4 same as HWNDLI to here */
  85.     HSZ    hszApp;          /* 8 */
  86.     HSZ    hszTopic;        /* C */
  87. } ACKHWNDLI;
  88. typedef ACKHWNDLI FAR *PACKHWNDLI;
  89.  
  90. typedef struct _HWNDHSZLI { /* C */
  91.     PLITEM next;            /* 0 */
  92.     HSZ    hsz;             /* 4 should be same as HSZLI to here */
  93.     HWND   hwnd;            /* 8 */
  94. } HWNDHSZLI;
  95. typedef HWNDHSZLI FAR *PHWNDHSZLI;
  96.  
  97. typedef struct _ADVLI {     /* C */
  98.     PLITEM  next;           /* 0 */
  99.     HSZ     hszItem;        /* 4 should be same as HSZLI to here */
  100.     USHORT  usFmt;          /* 8 */
  101.     USHORT  fsStatus;       /* A used to remember NODATA and FACKREQ state */
  102. } ADVLI;
  103. typedef ADVLI FAR *PADVLI;
  104.  
  105.  
  106. /*
  107.  * generic pile structures - a pile is an unordered list with no key
  108.  * duplicates.
  109.  */
  110. typedef struct _PILEB {         /* E */
  111.     struct _PILEB FAR *next;    /* 0 same as LITEM structure */
  112.     USHORT cItems;              /* 4 pile item additions */
  113.     USHORT reserved;            /* 6 */
  114. } PILEB;
  115. typedef PILEB FAR *PPILEB;
  116.  
  117. typedef struct PILE {           /*  */
  118.     PPILEB pBlockFirst;         /* 0 same as LST structure */
  119.     HHEAP hheap;                /* 4 */
  120.     USHORT cbBlock;             /* 8 */
  121.     
  122.     USHORT cSubItemsMax;        /* A additions for piles */
  123.     USHORT cbSubItem;           /* C */
  124. } PILE;
  125. typedef PILE FAR *PPILE;
  126. typedef BOOL (*NPFNCMP)(PBYTE, PBYTE);
  127.  
  128. #define PTOPPILEITEM(p) ((PBYTE)p->pBlockFirst + sizeof(PILEB))
  129.  
  130. #define FPI_DELETE 0x1
  131. #define FPI_COUNT  0x2
  132.  
  133. /*
  134.  * These bits are used to keep track of advise loop states.
  135.  */
  136. #define ADVST_POSTED    0x0100  /* Appstatus bit - set if callback Q has ADVREQ */
  137. #define ADVST_WAITING   0x0080  /* fReserved bit - set if still waiting for FACK */
  138. #define ADVST_CHANGED   0x0040  /* fReserved bit - set if data changed while waiting */
  139.  
  140. /*
  141.  * These may need to change if either the list items change or any of
  142.  * their component parts change size.
  143.  */
  144. #define CmpHwnd CmpULONG
  145.  
  146.  
  147. /* queue structures */
  148.  
  149. typedef struct _QUEUEITEM {         /* A */
  150.     struct _QUEUEITEM FAR *next;    /* 0 */
  151.     struct _QUEUEITEM FAR *prev;    /* 4 */
  152.     USHORT   inst;                  /* 8 */
  153. } QUEUEITEM;
  154. typedef QUEUEITEM FAR *PQUEUEITEM;
  155.                     
  156. typedef struct _QST {               /* C */
  157.     USHORT cItems;                  /* 0 */
  158.     USHORT instLast;                /* 2 */
  159.     USHORT cbItem;                  /* 4 */
  160.     USHORT usRes;                   /* 6 */
  161.     HHEAP hheap;                    /* 8 */
  162.     PQUEUEITEM pqiHead;
  163. } QST;
  164. typedef QST FAR *PQST;
  165.  
  166. #define MAKEID(pqd) ((ULONG)(USHORT)(pqd) + ((ULONG)(((PQUEUEITEM)pqd)->inst) << 16))
  167. #define PFROMID(pQ, id) ((PQUEUEITEM)MAKEP(HIUSHORT(pQ), LOUSHORT(id)))
  168.  
  169. typedef struct _XFERINFO { /* 1C */
  170.     PULONG pidXfer;        /* 0 if of queued transaction on QID_SYNC */
  171.     ULONG  ulTimeout;      /* 4 timeout allowed if QID_SYNC */
  172.     USHORT usType;         /* 8 transaction type */
  173.     USHORT usFmt;          /* A */
  174.     HSZ    hszItem;        /* C */
  175.     HCONV  hConv;          /* 10 client conversation handle */
  176.     ULONG  cb;             /* 14 count of data to get from client */
  177.     PBYTE  pData;          /* 18 location of data in client app */
  178. } XFERINFO;
  179. typedef XFERINFO FAR *PXFERINFO;
  180.  
  181. typedef struct _APPINFO {           /* 46 */
  182.     struct  _APPINFO FAR *next;     /* 0 */
  183.     struct  _APPINFO FAR *nextThread; /* 4 */ 
  184.     PPILE   pAppNamePile;           /* 8 */ 
  185.     PLST    plstCBExceptions;       /* C */ 
  186.     ULONG   afCmd;                  /* 10 */
  187.     HWND    hwndFrame;              /* 14 */
  188.     HWND    hwndMonitor;            /* 18 */
  189.     HWND    hwndDmg;                /* 1C */
  190.     HWND    hwndTimer;              /* 20 */
  191.     PID     pid;                    /* 24 */
  192.     TID     tid;                    /* 28 */
  193.     PFNCALLBACK pfnCallback;        /* 2C */
  194.     PPILE   pHDataPile;             /* 30 */
  195.     PLST    pSvrTopicList;          /* 34 */
  196.     PLST    plstCB;                 /* 38 */
  197.     HHEAP   hheapApp;               /* 3C */
  198.     USHORT  cInCallback;            /* 40 */
  199.     USHORT  LastError;              /* 42 */
  200.     BOOL    fEnableCB;              /* 44 */
  201. } APPINFO;
  202. typedef APPINFO FAR *PAPPINFO;
  203. typedef PAPPINFO FAR *PPAPPINFO;
  204.  
  205. typedef struct _MYDDES {    /* 20 */
  206.     ULONG   cbData;         /* 0 same as DDESTRUCT */
  207.     USHORT  fsStatus;       /* 4 */
  208.     USHORT  usFormat;       /* 6 */
  209.     USHORT  offszItemName;  /* 8 */
  210.     USHORT  offabData;      /* A */
  211.     ULONG   ulRes1;         /* C    handle control info */
  212.     USHORT  magic;          /* 14 */
  213.     USHORT  fs;             /* 16   HDATA_ flags */
  214.     HSZ     hszItem;        /* 18 */
  215.     PAPPINFO pai;           /* 1C */
  216. } MYDDES;
  217. typedef MYDDES FAR *PMYDDES;
  218.  
  219. #define MYDDESMAGIC     0x5353
  220.  
  221. /*
  222.  * private afCmd values
  223.  */
  224. #define     DMGCMD_32BIT    0x8000L
  225.  
  226. typedef struct _XADATA {    /* C */
  227.     USHORT     state;       /* 0  state of this transaction (CONVST_) */     
  228.     USHORT     LastError;   /* 2  last error logged in this transaction */
  229.     PXFERINFO  pXferInfo;   /* 4  transaction info */
  230.     PDDESTRUCT pddes;       /* 8  data for the client from the server */
  231. } XADATA;
  232. typedef XADATA FAR *PXADATA;    
  233.  
  234. typedef struct _COMMONINFO {  /* 38 */
  235.     PAPPINFO   pai;           /* 0 */ 
  236.     HSZ        hszServerApp;  /* 4 */  
  237.     HSZ        hszTopic;      /* 8 */ 
  238.     ULONG      hAgent;        /* C  agent handle, 0 for local conversations */
  239.     HWND       hwndPartner;   /* 10 */
  240.     PLST       pAdviseList;   /* 14 */
  241.     XADATA     xad;           /* 18 */
  242.     CONVCONTEXT cc;           /* 24 */
  243.     SHORT      fs;            /* 30 */
  244.     USHORT     reserverd;     /* 32 for DWORD alignment */  
  245.     HWND       hwndFrame;     /* 34 */
  246. } COMMONINFO;
  247.  
  248. typedef struct _CLIENTINFO {        /* 3C */
  249.     COMMONINFO ci;                  /* 0 */
  250.     PQST       pQ;                  /* 38 */
  251. } CLIENTINFO;
  252. typedef CLIENTINFO FAR *PCLIENTINFO;
  253.  
  254. typedef struct _SERVERINFO {
  255.     COMMONINFO ci;
  256. } SERVERINFO;
  257. typedef SERVERINFO FAR *PSERVERINFO;
  258.  
  259. typedef struct _INITINFO {          /* 18 */
  260.     HSZ        hszTopic;            /* 0 */
  261.     HSZ        hszAppName;          /* 4 */
  262.     HWND       hwndSend;            /* C */
  263.     HWND       hwndFrame;           /* 10 */
  264.     PCONVCONTEXT pCC;               /* 14 */
  265. } INITINFO;
  266. typedef INITINFO FAR *PINITINFO;
  267.  
  268. /* specific queue structures */
  269.  
  270. typedef struct _CQDATA {            /* 32 */
  271.     PQUEUEITEM FAR *next;           /* 0 */
  272.     PQUEUEITEM FAR *prev;           /* 4 */
  273.     USHORT   inst;                  /* 8 */ /* same as QUEUEITEM */
  274.     XADATA   xad;                   /* a */
  275.     XFERINFO XferInfo;              /* 14 */
  276. } CQDATA;
  277. typedef CQDATA FAR *PCQDATA;
  278.  
  279.  
  280.  
  281. /****** strings ******/
  282. #define SZDMGSEM "\\sem\\ddeml.lck"
  283. #define SZDMGCLASS "DMGClass"
  284. #define SZCLIENTCLASS "DMGClientClass"
  285. #define SZSERVERCLASS "DMGServerClass"
  286. #define SZMONITORCLASS "DMGMonitorClass"
  287. #define SZDEFCLASS "DMGHoldingClass"
  288. #define SZERRCAPTION "DDE Manager DLL error:"
  289. #define SZSYSTEMTOPIC "System"
  290. #define SZSYSTOPICS "Topics"
  291.  
  292. /***** private window messages and constants ******/
  293.  
  294. #define     HDATA_READONLY          0x8000
  295. #define     HDATA_APPFREEABLE       0x4000
  296. #define     HDATA_PSZITEMSET        0x2000
  297.  
  298. #define     UMCL_INITIATE           WM_USER
  299. #define     UMCL_TERMINATE          (WM_USER + 2)
  300.  
  301. #define     UMCL_XFER               (WM_USER + 4)
  302.  
  303. #define     UMSR_INITIATE           (WM_USER + 100)
  304. #define     UMSR_TERMINATE          (WM_USER + 102)
  305. #define     UMSR_RESET              (WM_USER + 103)
  306. #define     UMSR_POSTADVISE         (WM_USER + 104)
  307. #define     UMSR_QREPLY             (WM_USER + 105)
  308.  
  309. #define     UM_REGISTER             (WM_USER + 200)
  310. #define     UM_UNREGISTER           (WM_USER + 201)
  311. #define     UM_MONITOR              (WM_USER + 202)
  312. #define     UM_QUERY                (WM_USER + 203)
  313. #define         Q_APPNAME             1
  314. #define         Q_STATUS              2
  315. #define         Q_CLIENT              3
  316. #define         Q_APPINFO             4
  317. #define         Q_TOPIC               5
  318. #define         Q_ALL                10
  319. #define     UM_CHECKCBQ             (WM_USER + 204)
  320.  
  321. #define     AI_TIMEOUT          0x0001
  322.  
  323. #define     DMGHAB                  0
  324. #define     MAX_MONITORS            8
  325. #define     MAX_RECURSE             3
  326.  
  327.  
  328. /* these constants help identify windows during debugging. */
  329.  
  330. #define     WID_APPROOT         0x100
  331. #define     WID_CLROOT          0x300
  332. #define     WID_SVRTOPIC        0x201
  333. #define     WID_SERVER          0x202
  334. #define     WID_CLIENT          0x302
  335. #define     WID_DMGROOT         0x400
  336. #define     WID_MONITORROOT     0x500
  337. #define     WID_MONITOR         0x502
  338.  
  339.  
  340. /***** Queue control constants *****/
  341.  
  342. #define QST_OVERFLOW    0x1
  343. #define QST_CREATED     0x2
  344.  
  345. #define MDPM_FREEHDATA  1
  346.  
  347. /****** private procedures ******/
  348.  
  349. /* from dmgstrt.asm */
  350.  
  351. void LoadProc(void);
  352. void FillBlock(PBYTE pDst, USHORT cb, USHORT b);
  353. BOOL CopyBlock(PBYTE pSrc, PBYTE pDst, USHORT cb);
  354. PBYTE HugeOffset(PBYTE pSrc, ULONG cb);
  355.  
  356.  
  357. /* dmg.c entrypoints are exported by ddeml.h */
  358.  
  359. /* from ddeml.c */
  360.  
  361. void SpawnExtraAckClients(HCONV hConv, HCONVLIST hConvList, PCONVCONTEXT pCC);
  362. USHORT EXPENTRY Register(PFNCALLBACK pfnCallback, ULONG afCmd, ULONG ulRes,
  363.         BOOL f32bit);
  364.  
  365. /* from dmgwndp.c */
  366.  
  367. MRESULT EXPENTRY DmgWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  368. MRESULT EXPENTRY ClientWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  369. MRESULT EXPENTRY ServerWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  370. HWND CreateServerWindow(PAPPINFO pai, HSZ hszTopic);
  371. HWND FindFrame(HWND hwnd);
  372. void QReply(PCBLI pcbi, PDDESTRUCT pddes);
  373. MRESULT EXPENTRY subframeWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  374. HDMGDATA DoCallback(PAPPINFO pai, HCONV hConv, HSZ hszTopic, HSZ hszItem,
  375.     USHORT usFmt, USHORT usType, HDMGDATA hDmgData);
  376.  
  377. /* from dmgdde.c */
  378.  
  379. BOOL    timeout(PAPPINFO pai, ULONG ulTimeout, HWND hwndTimeout);
  380. BOOL    ClientInitiate(HWND hwnd, PINITINFO pinitInfo, PCLIENTINFO pci);
  381. BOOL    SendDDEInit(HWND hwndFrom, HWND hwndTo, PCLIENTINFO pci);
  382. PDDESTRUCT AllocDDESel(USHORT fsStatus, USHORT usFmt, HSZ hszItem,
  383.         ULONG cbData, PAPPINFO pai);
  384. PDDESTRUCT getServerData(HCONV hConv, HSZ hszTopic, HSZ hszItem,
  385.         USHORT usFmt, USHORT usType, PFNCALLBACK pfnDataFromApp,
  386.         PAPPINFO pai);
  387. HCONV   GetDDEClientWindow(HCONVLIST hConvList, HWND hwndFrame, HWND hwndSend,
  388.         HSZ hszApp, HSZ hszTopic, PCONVCONTEXT pCC);
  389. BOOL    MakeCallback(PAPPINFO pai, HCONV hConv, HSZ hszTopic, HSZ hszItem,
  390.         USHORT usFmt, USHORT usType, HDMGDATA hDmgData, USHORT msg,
  391.         USHORT fsStatus, HCONV hConvClient);
  392. BOOL MyDdePostMsg(HWND hwndTo, HWND hwndFrom, USHORT msg, PMYDDES pmyddes,
  393.         PAPPINFO paiFrom, USHORT afCmd);
  394.         
  395. /* from dmgmon.c */
  396.  
  397. BOOL EXPENTRY DdePostHookProc(HAB hab, PQMSG pqmsg, USHORT msgf);
  398. BOOL EXPENTRY DdeSendHookProc(HAB hab, PSMHSTRUCT psmh, BOOL fInterTask);
  399. void    MonitorBroadcast(PSZ psz);
  400. BOOL    allocMonStr(PSZ FAR *ppsz, PSZ FAR *ppszLast);
  401. MRESULT EXPENTRY MonitorWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  402.  
  403. /* from dmghsz.c */
  404.  
  405. PSZ pszFromHsz(HSZ hsz, USHORT FAR *pcch);
  406. HSZ GetHsz(PSZ psz, USHORT cc, USHORT cp, BOOL fAdd);
  407. BOOL FreeHsz(HSZ hsz);
  408. BOOL IncHszCount(HSZ hsz);
  409. BOOL AddAtomTable(BOOL fInit);
  410. USHORT QueryHszLength(HSZ hsz);
  411. USHORT QueryHszName(HSZ hsz, PSZ psz, USHORT cchMax);
  412. SHORT CmpHsz(HSZ hsz1, HSZ hsz2);
  413. USHORT QuerylatomLength(LATOM latom);
  414. BOOL Freelatom(LATOM latom);
  415. BOOL InclatomCount(LATOM latom);
  416. LATOM Decode(PBYTE pb);
  417. PBYTE Encode(ULONG latom, PBYTE pb);
  418. USHORT QuerylatomName(LATOM latom, PSZ psz, USHORT cchMax);
  419. LATOM FindAddlatom(PSZ psz, BOOL fAdd);
  420. LATOM FindAddlatomHelper(PSZ psz, BOOL fAdd);
  421. HSZ GetHszItem(PMYDDES pmyddes, PCONVCONTEXT pCC, BOOL fAdd);
  422.  
  423. /* from dmgstrt.asm */
  424. BOOL CheckSel(SEL sel);
  425.  
  426. /* from dmgdb.c */
  427.  
  428. PAPPINFO GetCurrentAppInfo(BOOL fChkCallback);
  429. void UnlinkAppInfo(PAPPINFO pai);
  430. BOOL CmpAdv(PBYTE pb1, PBYTE pb2);
  431.  
  432. PLST CreateLst(HHEAP hheap, USHORT cbItem);
  433. void FlushLst(PLST pLst);
  434. void DestroyLst(PLST pLst);
  435. PLITEM FindLstItem(PLST pLst, NPFNCMP npfnCmp, PLITEM piSearch);
  436. BOOL CmpULONG(PBYTE pb1, PBYTE pb2);
  437. BOOL CmppHsz(PBYTE pb1, PBYTE pb2);
  438. PLITEM NewLstItem(PLST pLst, USHORT afCmd);
  439. BOOL RemoveLstItem(PLST pLst, PLITEM pi);
  440. BOOL InsertLstItem(PLST pLst, PLITEM pi, USHORT afCmd);
  441.  
  442. PPILE CreatePile(HHEAP hheap, USHORT cbItem, USHORT cItemsPerBlock);
  443. PPILE DestroyPile(PPILE pPile);
  444. void FlushPile(PPILE pPile);
  445. USHORT QPileItemCount(PPILE pPile);
  446. BOOL CopyPileItems(PPILE pPile, PBYTE pDst);
  447. PBYTE FindPileItem(PPILE pPile, NPFNCMP npfnCmp, PBYTE pbSearch, USHORT afCmd);
  448. BOOL AddPileItem(PPILE pPile, PBYTE pb, NPFNCMP npfncmp);
  449. BOOL PopPileSubitem(PPILE pPile, PBYTE pb);
  450.  
  451. BOOL fSearchHwndList(PLST pLst, HWND hwnd);
  452. void AddHwndList(HWND hwnd, PLST pLst);
  453. void AddAckHwndList(HWND hwnd, HSZ hszApp, HSZ hszTopic, PLST pLst);
  454.          
  455. void AddHwndHszList(HSZ hsz, HWND hwnd, PLST pLst);
  456. void DestroyHwndHszList(PLST pLst);
  457. HWND HwndFromHsz(HSZ hsz, PLST pLst);
  458. BOOL AddAdvList(PLST pLst, HSZ hszItem, USHORT fsStatus, USHORT usFormat);
  459. BOOL DeleteAdvList(PLST pLst, HSZ hszItem, USHORT usFmt);
  460. PADVLI FindAdvList(PLST pLst, HSZ hszItem, USHORT usFmt);
  461. PADVLI FindNextAdv(PADVLI padvli, HSZ hszItem);
  462.  
  463. void SemInit(void);
  464. void SemCheckIn(void);
  465. void SemCheckOut(void);
  466. void SemEnter(void);
  467. void SemLeave(void);
  468.  
  469. void EXPENTRY ExlstAbort(USHORT usTermCode);
  470. BOOL CopyHugeBlock(PBYTE pSrc, PBYTE pDst, ULONG cb);
  471. BOOL DestroyWindow(HWND hwnd);
  472. HCONV IsDdeWindow(HWND hwnd); 
  473. void FreeData(PMYDDES pmyddes, PAPPINFO pai);
  474. HDMGDATA PutData(PBYTE pSrc, ULONG cb, ULONG cbOff, HSZ hszItem, USHORT usFmt,
  475.         USHORT afCmd, PAPPINFO pai);
  476. ULONG QueryAppNames(PAPPINFO pai, HDMGDATA hDataAdd, HSZ hszApp, ULONG offAdd);
  477.  
  478. /* from mem.c */
  479.  
  480. PBYTE  FarAllocMem(HHEAP hheap, USHORT cb);
  481. NPBYTE DbgAllocMem(HHEAP hheap, USHORT cb);
  482. HHEAP DbgCreateHeap(USHORT sel, USHORT cb, USHORT cbGrow, USHORT cbMinDed,
  483.     USHORT cbMaxDed, USHORT fs);
  484. HHEAP DbgDestroyHeap(HHEAP hheap);
  485. NPBYTE DbgFreeMem(HHEAP hheap, NPBYTE pb, USHORT cb);
  486.  
  487.  
  488. /* from dmgstr.c */
  489.  
  490. int lstrlen(PSZ psz);
  491. PSZ lstrcat(PSZ psz1, PSZ psz2, PSZ pszLast);
  492. PSZ hwndToPsz(HWND hwnd, PSZ psz, PSZ pszLast);
  493. PSZ pddesToPsz(USHORT msg, PDDESTRUCT pddes, PSZ psz, PSZ pszLast);
  494. PSZ Status(USHORT fs, PSZ psz, PSZ pszLast);
  495. PSZ Format(USHORT fmt, PSZ psz, PSZ pszLast);
  496. PSZ ddeMsgToPsz(USHORT msg, PSZ psz, PSZ pszLast);
  497. PSZ itoa(USHORT us, PSZ psz, PSZ pszLast);
  498. PSZ ltoa(ULONG ul, PSZ psz, PSZ pszLast);
  499. PSZ stoa(PSZ psz, USHORT us);
  500. PSZ dtoa(PSZ psz, USHORT us, BOOL fRecurse);
  501. PSZ timestamp(PSZ psz, PSZ pszLast);
  502.  
  503. /* from dmgq.c */
  504.  
  505. PQST CreateQ(USHORT cbItem);
  506. BOOL DestroyQ(PQST pQ);
  507. PQUEUEITEM Addqi(PQST pQ);
  508. void Deleteqi(PQST pQ, ULONG id);
  509. PQUEUEITEM Findqi(PQST pQ, ULONG id);
  510.  
  511. /* from bakthnk.asm */
  512. HDMGDATA NEAR PASCAL ThkCallback(HCONV hConv, HSZ hszTopic, HSZ hszItem,
  513.     USHORT usFmt, USHORT usType, HDMGDATA hDmgData, PFNCALLBACK pfn);
  514.  
  515. /* macros */
  516.  
  517. #define UNUSED
  518. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  519. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  520. #define PSZAPP(p) (PSZ)(((ULONG)p & 0xFFFF0000L) + (USHORT)(((PDDEINIT)(p))->pszAppName))
  521. #define PSZTOPIC(p) (PSZ)(((ULONG)p & 0xFFFF0000L) + (USHORT)(((PDDEINIT)(p))->pszTopic))
  522.  
  523. #ifdef DEBUG
  524.  
  525. #define HEAPFLAGS (HM_MOVEABLE | HM_VALIDSIZE)
  526. #define MyAllocMem DbgAllocMem
  527. #define MyFreeMem DbgFreeMem
  528. #define MyCreateHeap DbgCreateHeap
  529. #define MyDestroyHeap DbgDestroyHeap
  530. void fAssert(BOOL f, PSZ psz, USHORT line, PSZ szFile);
  531. #define AssertF(f, psz)    fAssert(f, psz, __LINE__, __FILE__);
  532. #define DebugBreak() DdeDebugBreak()
  533.  
  534. #else
  535.  
  536. #define HEAPFLAGS 0
  537. #define MyAllocMem WinAllocMem
  538. #define MyFreeMem WinFreeMem
  539. #define MyCreateHeap WinCreateHeap
  540. #define MyDestroyHeap WinDestroyHeap
  541. #define AssertF(f, psz)
  542. #define DebugBreak()
  543. #define SemCheckIn()
  544. #define SemCheckOut()
  545. #endif /* DEBUG */
  546.  
  547. #define FarFreeMem(hheap, pb, cb) (MyFreeMem(hheap, (NPBYTE)(SHORT)pb, cb))
  548.  
  549. /******* globals ******/
  550. extern HMODULE hmodDmg;
  551. extern HWND hwndDmgMonitor;
  552. extern PFNWP lpfnFrameWndProc;
  553. extern HHEAP hheapDmg;
  554. extern USHORT cMonitor;
  555. extern USHORT cAtoms;
  556. extern HATOMTBL hatomtblDmg;
  557. extern DOSFSRSEM FSRSemDmg;
  558. extern PAPPINFO pAppInfoList;
  559. extern USHORT usHugeShift;
  560. extern USHORT usHugeAdd;
  561. extern COUNTRYCODE syscc;
  562. extern PHATOMTBL aAtbls;
  563. extern USHORT cAtbls;
  564. extern USHORT iAtblCurrent;
  565. extern char szT[];
  566.