Release 960414
[wine.git] / misc / toolhelp.c
blobcd34e208911e15efaecfd6c700578c41aae2a0e0
1 /*
2 * Misc Toolhelp functions
4 * Copyright 1996 Marcus Meissner
5 */
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <ctype.h>
12 #include "windows.h"
13 #include "win.h"
14 #include "toolhelp.h"
15 #include "stddebug.h"
16 #include "debug.h"
17 #include "xmalloc.h"
19 /* FIXME: to make this working, we have to callback all these registered
20 * functions from all over the WINE code. Someone with more knowledge than
21 * me please do that. -Marcus
23 static struct notify
25 HTASK htask;
26 FARPROC lpfnCallback;
27 WORD wFlags;
28 } *notifys = NULL;
30 static int nrofnotifys = 0;
32 BOOL
33 NotifyRegister(HTASK htask,FARPROC lpfnCallback,WORD wFlags)
35 int i;
37 dprintf_toolhelp( stddeb, "NotifyRegister(%x,%lx,%x) called.\n",
38 htask, (DWORD)lpfnCallback, wFlags );
39 for (i=0;i<nrofnotifys;i++)
40 if (notifys[i].htask==htask)
41 break;
42 if (i==nrofnotifys) {
43 if (notifys==NULL)
44 notifys=(struct notify*)xmalloc(sizeof(struct notify));
45 else
46 notifys=(struct notify*)xrealloc(notifys,sizeof(struct notify)*(nrofnotifys+1));
47 nrofnotifys++;
49 notifys[i].htask=htask;
50 notifys[i].lpfnCallback=lpfnCallback;
51 notifys[i].wFlags=wFlags;
52 return TRUE;
55 BOOL
56 NotifyUnregister(HTASK htask)
58 int i;
60 dprintf_toolhelp( stddeb, "NotifyUnregister(%x) called.\n", htask );
61 for (i=nrofnotifys;i--;)
62 if (notifys[i].htask==htask)
63 break;
64 if (i==-1)
65 return FALSE;
66 memcpy(notifys+i,notifys+(i+1),sizeof(struct notify)*(nrofnotifys-i-1));
67 notifys=(struct notify*)xrealloc(notifys,(nrofnotifys-1)*sizeof(struct notify));
68 nrofnotifys--;
69 return TRUE;