1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2025-10-22 13:11:25 +02:00
Files
debian
docs
glib
gmodule
gobject
gthread
m4macros
po
tests
gobject
markups
.cvsignore
Makefile.am
array-test.c
casefold.txt
casemap.txt
cxx-test.C
date-test.c
dirname-test.c
gen-casefold-txt.pl
gen-casemap-txt.pl
gio-test.c
hash-test.c
iochannel-test-infile
iochannel-test.c
libmoduletestplugin_a.c
libmoduletestplugin_b.c
list-test.c
mainloop-test.c
makefile.mingw.in
makefile.msc.in
markup-test.c
module-test.c
node-test.c
patterntest.c
qsort-test.c
queue-test.c
rand-test.c
relation-test.c
run-markup-tests.sh
shell-test.c
slist-test.c
spawn-test-win32-gui.c
spawn-test.c
strfunc-test.c
string-test.c
strtod-test.c
testgdate.c
testgdateparser.c
testglib.c
thread-test.c
threadpool-test.c
timeloop-basic.c
timeloop-closure.c
timeloop.c
tree-test.c
type-test.c
unicode-caseconv.c
unicode-collate.c
unicode-encoding.c
unicode-normalize.c
uri-test.c
utf8.txt
.cvsignore
AUTHORS
COPYING
ChangeLog
ChangeLog.pre-1-2
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
HACKING
INSTALL
INSTALL.in
Makefile.am
NEWS
NEWS.pre-1-3
README
README.in
README.win32
TODO.xml
acglib.m4
acinclude.m4
autogen.sh
config.h.win32.in
configure.in
glib-2.0-uninstalled.pc.in
glib-2.0.pc.in
glib-gettextize.in
glib-zip.in
glib.spec.in
glibconfig.h.win32.in
gmodule-2.0-uninstalled.pc.in
gmodule-2.0.pc.in
gobject-2.0-uninstalled.pc.in
gobject-2.0.pc.in
gthread-2.0-uninstalled.pc.in
gthread-2.0.pc.in
makefile.mingw
makefile.msc
msvc_recommended_pragmas.h
sanity_check
win32-fixup.pl
glib/tests/spawn-test-win32-gui.c

100 lines
2.8 KiB
C
Raw Normal View History

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
int _stdcall
WinMain (struct HINSTANCE__ *hInstance,
struct HINSTANCE__ *hPrevInstance,
char *lpszCmdLine,
int nCmdShow)
{
if (__argc <= 2)
{
MessageBox (NULL, "spawn-test-win32-gui: Will write to stdout",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
printf ("This is stdout\n");
fflush (stdout);
MessageBox (NULL, "spawn-test-win32-gui: Will write to stderr",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
fprintf (stderr, "This is stderr\n");
fflush (stderr);
}
else if (__argc == 4 && strcmp (__argv[1], "pipes") == 0)
{
int infd = atoi (__argv[2]);
int outfd = atoi (__argv[3]);
int k, n;
char buf[100];
if (infd < 0 || outfd < 0)
{
MessageBox (NULL, "spawn-test-win32-gui: illegal fds on command line",
lpszCmdLine, MB_ICONERROR|MB_SYSTEMMODAL);
exit (1);
}
MessageBox (NULL, "spawn-test-win32-gui: Will write to parent",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
n = strlen ("Hello there");
if (write (outfd, &n, sizeof (n)) == -1 ||
write (outfd, "Hello there", n) == -1)
{
sprintf (buf, "spawn-test-win32-gui: Write: %s", strerror (errno));
MessageBox (NULL, buf, lpszCmdLine, MB_ICONERROR|MB_SYSTEMMODAL);
exit (1);
}
MessageBox (NULL, "spawn-test-win32-gui: Will read from parent",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
if ((k = read (infd, &n, sizeof (n))) != sizeof (n))
{
sprintf (buf, "spawn-test-win32-gui: Got only %d bytes, wanted %d",
k, sizeof (n));
MessageBox (NULL, buf, lpszCmdLine, MB_ICONERROR|MB_SYSTEMMODAL);
exit (1);
}
sprintf (buf, "spawn-test-win32-gui: Parent says %d bytes to read", n);
MessageBox (NULL, buf, lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
if ((k = read (infd, buf, n)) != n)
{
if (k == -1)
sprintf (buf, "spawn-test-win32-gui: Read: %s", strerror (errno));
else
sprintf (buf, "spawn-test-win32-gui: Got only %d bytes", k);
MessageBox (NULL, buf, lpszCmdLine, MB_ICONERROR|MB_SYSTEMMODAL);
exit (1);
}
MessageBox (NULL, "spawn-test-win32-gui: Will write more to parent",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
n = strlen ("See ya");
if (write (outfd, &n, sizeof (n)) == -1 ||
write (outfd, "See ya", n) == -1)
{
sprintf (buf, "spawn-test-win32-gui: Write: %s", strerror (errno));
MessageBox (NULL, buf, lpszCmdLine, MB_ICONERROR|MB_SYSTEMMODAL);
exit (1);
}
}
MessageBox (NULL, "spawn-test-win32-gui: Sleeping a bit.",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
Sleep (2000);
MessageBox (NULL, "spawn-test-win32-gui: Done, exiting.",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
return 0;
}