Release 980913
[wine/multimedia.git] / ipc / dde_proc_test.c
blob541172ac06f0ae26dbbcbdb22c2c07f261a3d9ce
1 /***************************************************************************
2 * Copyright 1995, Technion, Israel Institute of Technology
3 * Electrical Eng, Software Lab.
4 * Author: Michael Veksler.
5 ***************************************************************************
6 * File: dde_proc.c
7 * Purpose : test DDE signals and processes functionality for DDE
8 * Usage: run two independant processes, one with an argument another
9 * without (with the argument is the server).
10 ***************************************************************************
12 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
13 #include <sys/syscall.h>
14 #include <sys/param.h>
15 #else
16 #include <syscall.h>
17 #endif
18 #include <stdio.h>
19 #include <unistd.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <signal.h>
23 #include <win.h>
24 #include "dde.h"
25 #include "dde_proc.h"
26 #include "shm_main_blk.h"
28 #if !defined(BSD4_4) || defined(linux) || defined(__FreeBSD__)
29 char * cstack[4096];
30 #endif
31 #ifdef linux
32 extern void ___sig_restore();
33 extern void ___masksig_restore();
35 /* Similar to the sigaction function in libc, except it leaves alone the
36 restorer field */
38 static int
39 wine_sigaction(int sig,struct sigaction * new, struct sigaction * old)
41 __asm__("int $0x80":"=a" (sig)
42 :"0" (SYS_sigaction),"b" (sig),"c" (new),"d" (old));
43 if (sig>=0)
44 return 0;
45 errno = -sig;
46 return -1;
48 #endif
50 struct sigaction usr2_act;
53 void init_signals()
55 #ifdef linux
56 usr2_act.sa_handler = (__sighandler_t) stop_wait;
57 usr2_act.sa_flags = 0;
58 usr2_act.sa_restorer =
59 (void (*)()) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3);
60 wine_sigaction(SIGUSR2,&usr2_act,NULL);
61 #endif
62 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
63 usr2_act.sa_hadnler = (void (*)) stop_wait;
64 usr2_act.sa_flags = SA_ONSTACK;
65 usr2_act.sa_mask = sig_mask;
66 usr2_act.sa_restorer =
67 (void (*)()) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3);
68 if (sigaction(SIGUSR2,&usr2_act,NULL) <0) {
69 perror("sigaction: SIGUSR2");
70 exit(1);
72 #endif
74 void ATOM_GlobalInit()
76 printf("ATOM_GlobalInit\n");
80 void idle_loop()
82 int timeout;
83 for(timeout=500; timeout ; timeout--) {
84 if (DDE_GetRemoteMessage())
85 exit(0); ;
86 usleep(1000);
88 exit(-1);
91 void client()
93 MSG msg;
94 msg.hwnd=(HWND)-1;
95 msg.message= WM_DDE_INITIATE;
96 msg.wParam= 3;
97 msg.lParam= 4;
98 if (!DDE_SendMessage(&msg))
99 exit(-1);
100 idle_loop();
102 void server()
104 DDE_IPC_init();
105 idle_loop();
108 int main(int argc, char *argv[])
110 printf("Kill when done one message\n");
111 init_signals();
112 if (argc>1)
113 server();
114 else
115 client();
116 return 0;