added the bin directory and moves files for binary commands into it
This commit is contained in:
@ -120,22 +120,6 @@ libmoo_la_DEPENDENCIES += $(abs_builddir)/../mod/libmoo-x11.la
|
||||
endif
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = moo
|
||||
moo_SOURCES = main.c
|
||||
if WIN32
|
||||
moo_SOURCES += poll-msw.c poll-msw.h
|
||||
endif
|
||||
moo_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
moo_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
moo_LDADD = $(LIBADD_LIB_COMMON) -lmoo $(PTHREAD_LIBS)
|
||||
if WIN32
|
||||
moo_LDADD += $(SOCKET_LIBS)
|
||||
endif
|
||||
if ENABLE_STATIC_MODULE
|
||||
moo_DEPENDENCIES = libmoo.la
|
||||
endif
|
||||
|
||||
|
||||
install-data-hook:
|
||||
@echo "#ifndef _MOO_CFG_H_" > "$(DESTDIR)$(pkgincludedir)/moo-cfg.h"
|
||||
@echo "#define _MOO_CFG_H_" >> "$(DESTDIR)$(pkgincludedir)/moo-cfg.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
@ -109,12 +108,6 @@ host_triplet = @host@
|
||||
@ENABLE_MOD_SCK_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_12 = $(abs_builddir)/../mod/libmoo-sck.la
|
||||
@ENABLE_MOD_X11_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_13 = -lmoo-x11
|
||||
@ENABLE_MOD_X11_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_14 = $(abs_builddir)/../mod/libmoo-x11.la
|
||||
bin_PROGRAMS = moo$(EXEEXT)
|
||||
@WIN32_TRUE@am__append_15 = poll-msw.c poll-msw.h
|
||||
@WIN32_TRUE@am__append_16 = $(SOCKET_LIBS)
|
||||
@ENABLE_STATIC_MODULE_FALSE@moo_DEPENDENCIES = $(am__DEPENDENCIES_5) \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1) \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_6)
|
||||
subdir = lib
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||
@ -158,7 +151,7 @@ am__uninstall_files_from_dir = { \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(bindir)" \
|
||||
am__installdirs = "$(DESTDIR)$(pkglibdir)" \
|
||||
"$(DESTDIR)$(pkgincludedir)"
|
||||
LTLIBRARIES = $(pkglib_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 =
|
||||
@ -184,15 +177,6 @@ am__v_lt_1 =
|
||||
libmoo_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libmoo_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am__moo_SOURCES_DIST = main.c poll-msw.c poll-msw.h
|
||||
@WIN32_TRUE@am__objects_1 = moo-poll-msw.$(OBJEXT)
|
||||
am_moo_OBJECTS = moo-main.$(OBJEXT) $(am__objects_1)
|
||||
moo_OBJECTS = $(am_moo_OBJECTS)
|
||||
@WIN32_TRUE@am__DEPENDENCIES_6 = $(am__DEPENDENCIES_1)
|
||||
moo_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(moo_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
@ -227,8 +211,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(libmoo_la_SOURCES) $(moo_SOURCES)
|
||||
DIST_SOURCES = $(libmoo_la_SOURCES) $(am__moo_SOURCES_DIST)
|
||||
SOURCES = $(libmoo_la_SOURCES)
|
||||
DIST_SOURCES = $(libmoo_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -495,12 +479,6 @@ libmoo_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_6) \
|
||||
@ENABLE_STATIC_MODULE_TRUE@libmoo_la_DEPENDENCIES = $(abs_builddir)/../mod/libmoo-stdio.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ $(am__append_8) $(am__append_10) \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ $(am__append_12) $(am__append_14)
|
||||
moo_SOURCES = main.c $(am__append_15)
|
||||
moo_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
moo_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
moo_LDADD = $(LIBADD_LIB_COMMON) -lmoo $(PTHREAD_LIBS) \
|
||||
$(am__append_16)
|
||||
@ENABLE_STATIC_MODULE_TRUE@moo_DEPENDENCIES = libmoo.la
|
||||
all: moo-cfg.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
@ -588,59 +566,6 @@ clean-pkglibLTLIBRARIES:
|
||||
|
||||
libmoo.la: $(libmoo_la_OBJECTS) $(libmoo_la_DEPENDENCIES) $(EXTRA_libmoo_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libmoo_la_LINK) -rpath $(pkglibdir) $(libmoo_la_OBJECTS) $(libmoo_la_LIBADD) $(LIBS)
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed 's/$(EXEEXT)$$//' | \
|
||||
while read p p1; do if test -f $$p \
|
||||
|| test -f $$p1 \
|
||||
; then echo "$$p"; echo "$$p"; else :; fi; \
|
||||
done | \
|
||||
sed -e 'p;s,.*/,,;n;h' \
|
||||
-e 's|.*|.|' \
|
||||
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
|
||||
sed 'N;N;N;s,\n, ,g' | \
|
||||
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
|
||||
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
|
||||
if ($$2 == $$4) files[d] = files[d] " " $$1; \
|
||||
else { print "f", $$3 "/" $$4, $$1; } } \
|
||||
END { for (d in files) print "f", d, files[d] }' | \
|
||||
while read type dir files; do \
|
||||
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
|
||||
} \
|
||||
; done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
files=`for p in $$list; do echo "$$p"; done | \
|
||||
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
|
||||
-e 's/$$/$(EXEEXT)/' \
|
||||
`; \
|
||||
test -n "$$list" || exit 0; \
|
||||
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(bindir)" && rm -f $$files
|
||||
|
||||
clean-binPROGRAMS:
|
||||
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list || exit $$?; \
|
||||
test -n "$(EXEEXT)" || exit 0; \
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
|
||||
moo$(EXEEXT): $(moo_OBJECTS) $(moo_DEPENDENCIES) $(EXTRA_moo_DEPENDENCIES)
|
||||
@rm -f moo$(EXEEXT)
|
||||
$(AM_V_CCLD)$(moo_LINK) $(moo_OBJECTS) $(moo_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
@ -672,8 +597,6 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-utf16.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-utf8.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-utl.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/moo-main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/moo-poll-msw.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||
@ -867,34 +790,6 @@ libmoo_la-std.lo: std.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-std.lo `test -f 'std.c' || echo '$(srcdir)/'`std.c
|
||||
|
||||
moo-main.o: main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT moo-main.o -MD -MP -MF $(DEPDIR)/moo-main.Tpo -c -o moo-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/moo-main.Tpo $(DEPDIR)/moo-main.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='moo-main.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o moo-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
|
||||
|
||||
moo-main.obj: main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT moo-main.obj -MD -MP -MF $(DEPDIR)/moo-main.Tpo -c -o moo-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/moo-main.Tpo $(DEPDIR)/moo-main.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='moo-main.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o moo-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
|
||||
moo-poll-msw.o: poll-msw.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT moo-poll-msw.o -MD -MP -MF $(DEPDIR)/moo-poll-msw.Tpo -c -o moo-poll-msw.o `test -f 'poll-msw.c' || echo '$(srcdir)/'`poll-msw.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/moo-poll-msw.Tpo $(DEPDIR)/moo-poll-msw.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='poll-msw.c' object='moo-poll-msw.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o moo-poll-msw.o `test -f 'poll-msw.c' || echo '$(srcdir)/'`poll-msw.c
|
||||
|
||||
moo-poll-msw.obj: poll-msw.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT moo-poll-msw.obj -MD -MP -MF $(DEPDIR)/moo-poll-msw.Tpo -c -o moo-poll-msw.obj `if test -f 'poll-msw.c'; then $(CYGPATH_W) 'poll-msw.c'; else $(CYGPATH_W) '$(srcdir)/poll-msw.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/moo-poll-msw.Tpo $(DEPDIR)/moo-poll-msw.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='poll-msw.c' object='moo-poll-msw.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(moo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o moo-poll-msw.obj `if test -f 'poll-msw.c'; then $(CYGPATH_W) 'poll-msw.c'; else $(CYGPATH_W) '$(srcdir)/poll-msw.c'; fi`
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
@ -1006,9 +901,9 @@ distdir: $(DISTFILES)
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) moo-cfg.h
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS) moo-cfg.h
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgincludedir)"; do \
|
||||
for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(pkgincludedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
@ -1043,8 +938,8 @@ maintainer-clean-generic:
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-generic clean-libtool \
|
||||
clean-pkglibLTLIBRARIES mostlyclean-am
|
||||
clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
@ -1071,7 +966,7 @@ install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-binPROGRAMS install-pkglibLTLIBRARIES
|
||||
install-exec-am: install-pkglibLTLIBRARIES
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
@ -1111,18 +1006,16 @@ ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-binPROGRAMS uninstall-pkgincludeHEADERS \
|
||||
uninstall-pkglibLTLIBRARIES
|
||||
uninstall-am: uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
|
||||
@$(NORMAL_INSTALL)
|
||||
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
|
||||
.MAKE: all install-am install-data-am install-strip uninstall-am
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
|
||||
clean-binPROGRAMS clean-generic clean-libtool \
|
||||
clean-pkglibLTLIBRARIES cscopelist-am ctags ctags-am distclean \
|
||||
distclean-compile distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-tags distdir dvi dvi-am html \
|
||||
html-am info info-am install install-am install-binPROGRAMS \
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \
|
||||
ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-data-hook install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
@ -1132,8 +1025,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-pkgincludeHEADERS \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
|
||||
uninstall-binPROGRAMS uninstall-hook \
|
||||
uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
|
||||
uninstall-hook uninstall-pkgincludeHEADERS \
|
||||
uninstall-pkglibLTLIBRARIES
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
#include <Types.h>
|
||||
#include <Memory.h>
|
||||
#include <QuickDraw.h>
|
||||
#include <Fonts.h>
|
||||
#include <Events.h>
|
||||
#include <Menus.h>
|
||||
#include <TextEdit.h>
|
||||
#include <MacWindows.h>
|
||||
#include <OSUtils.h>
|
||||
#include <ToolUtils.h>
|
||||
|
||||
|
||||
static void InitToolBox (void)
|
||||
{
|
||||
GrafPtr wmgrPort;
|
||||
|
||||
#if defined(TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON > 0)
|
||||
/* no init required for the managers below in Carbon */
|
||||
#else
|
||||
InitGraf (&qd.thePort);
|
||||
InitFonts ();
|
||||
InitWindows ();
|
||||
InitMenus ();
|
||||
TEInit ();
|
||||
InitDialogs (0L);
|
||||
MaxApplZone ();
|
||||
#endif
|
||||
|
||||
InitCursor ();
|
||||
|
||||
#if defined(TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON > 0)
|
||||
wmgrPort = CreateNewPort();
|
||||
#else
|
||||
GetWMgrPort (&wmgrPort);
|
||||
#endif
|
||||
|
||||
SetPort (wmgrPort);
|
||||
}
|
||||
|
||||
|
||||
static void EventLoop (void)
|
||||
{
|
||||
|
||||
}
|
292
moo/lib/main.c
292
moo/lib/main.c
@ -1,292 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <moo-std.h>
|
||||
#include <moo-utl.h>
|
||||
#include <moo-opt.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if (defined(__unix) || defined(__linux) || defined(__ultrix) || defined(_AIX) || defined(__hpux) || defined(__sgi)) && defined(HAVE_SIGNAL_H)
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
static void print_syntax_error (moo_t* moo, const char* main_src_file)
|
||||
{
|
||||
moo_synerr_t synerr;
|
||||
|
||||
moo_getsynerr (moo, &synerr);
|
||||
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: ");
|
||||
if (synerr.loc.file)
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "%js", synerr.loc.file);
|
||||
}
|
||||
else
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "%s", main_src_file);
|
||||
}
|
||||
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "[%zu,%zu] %js",
|
||||
synerr.loc.line, synerr.loc.colm,
|
||||
(moo_geterrmsg(moo) != moo_geterrstr(moo)? moo_geterrmsg(moo): moo_geterrstr(moo))
|
||||
);
|
||||
|
||||
if (synerr.tgt.len > 0)
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, " - %.*js", synerr.tgt.len, synerr.tgt.ptr);
|
||||
}
|
||||
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "\n");
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#define MIN_MEMSIZE 2048000ul
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
static moo_ooch_t str_my_object[] = { 'M', 'y', 'O', 'b','j','e','c','t' }; /*TODO: make this an argument */
|
||||
static moo_ooch_t str_main[] = { 'm', 'a', 'i', 'n' };
|
||||
|
||||
moo_t* moo;
|
||||
moo_cfgstd_t cfg;
|
||||
moo_errinf_t errinf;
|
||||
|
||||
moo_oocs_t objname;
|
||||
moo_oocs_t mthname;
|
||||
moo_oow_t memsize;
|
||||
int i, xret;
|
||||
|
||||
moo_bci_t c;
|
||||
static moo_bopt_lng_t lopt[] =
|
||||
{
|
||||
{ ":log", 'l' },
|
||||
{ ":memsize", 'm' },
|
||||
{ "large-pages", '\0' },
|
||||
{ "utf8", '\0' },
|
||||
{ "utf16", '\0' },
|
||||
#if defined(MOO_BUILD_DEBUG)
|
||||
{ ":debug", '\0' }, /* NOTE: there is no short option for --debug */
|
||||
#endif
|
||||
{ MOO_NULL, '\0' }
|
||||
};
|
||||
static moo_bopt_t opt =
|
||||
{
|
||||
"l:m:",
|
||||
lopt
|
||||
};
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
#if !defined(macintosh)
|
||||
if (argc < 2)
|
||||
{
|
||||
print_usage:
|
||||
fprintf (stderr, "Usage: %s [options] filename ...\n", argv[0]);
|
||||
fprintf (stderr, " --log filename[,logopts]\n");
|
||||
fprintf (stderr, " --memsize number\n");
|
||||
fprintf (stderr, " --large-pages\n");
|
||||
fprintf (stderr, " --utf16\n");
|
||||
fprintf (stderr, " --utf8\n");
|
||||
#if defined(MOO_BUILD_DEBUG)
|
||||
fprintf (stderr, " --debug dbgopts\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset (&cfg, 0, MOO_SIZEOF(cfg));
|
||||
cfg.type = MOO_CFGSTD_OPTB;
|
||||
cfg.cmgr = moo_get_utf8_cmgr();
|
||||
|
||||
memsize = MIN_MEMSIZE;
|
||||
|
||||
while ((c = moo_getbopt(argc, argv, &opt)) != MOO_BCI_EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'l':
|
||||
cfg.u.optb.log = opt.arg;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
memsize = strtoul(opt.arg, MOO_NULL, 0);
|
||||
if (memsize <= MIN_MEMSIZE) memsize = MIN_MEMSIZE;
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
if (moo_comp_bcstr(opt.lngopt, "large-pages") == 0)
|
||||
{
|
||||
cfg.large_pages = 1;
|
||||
break;
|
||||
}
|
||||
else if (moo_comp_bcstr(opt.lngopt, "utf8") == 0)
|
||||
{
|
||||
cfg.cmgr = moo_get_utf8_cmgr();
|
||||
break;
|
||||
}
|
||||
else if (moo_comp_bcstr(opt.lngopt, "utf16") == 0)
|
||||
{
|
||||
cfg.cmgr = moo_get_utf16_cmgr();
|
||||
break;
|
||||
}
|
||||
#if defined(MOO_BUILD_DEBUG)
|
||||
else if (moo_comp_bcstr(opt.lngopt, "debug") == 0)
|
||||
{
|
||||
cfg.u.optb.dbg = opt.arg;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
goto print_usage;
|
||||
|
||||
case ':':
|
||||
if (opt.lngopt)
|
||||
fprintf (stderr, "bad argument for '%s'\n", opt.lngopt);
|
||||
else
|
||||
fprintf (stderr, "bad argument for '%c'\n", opt.opt);
|
||||
|
||||
return -1;
|
||||
|
||||
default:
|
||||
goto print_usage;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt.ind >= argc) goto print_usage;
|
||||
#endif
|
||||
|
||||
moo = moo_openstd(0, &cfg, &errinf);
|
||||
if (!moo)
|
||||
{
|
||||
#if defined(MOO_OOCH_IS_BCH)
|
||||
fprintf (stderr, "ERROR: cannot open moo - [%d] %s\n", (int)errinf.num, errinf.msg);
|
||||
#elif (MOO_SIZEOF_UCH_T == MOO_SIZEOF_WCHAR_T)
|
||||
fprintf (stderr, "ERROR: cannot open moo - [%d] %ls\n", (int)errinf.num, errinf.msg);
|
||||
#else
|
||||
moo_bch_t bcsmsg[MOO_COUNTOF(errinf.msg) * 2]; /* error messages may get truncated */
|
||||
moo_oow_t wcslen, bcslen;
|
||||
bcslen = MOO_COUNTOF(bcsmsg);
|
||||
moo_conv_ucstr_to_utf8 (errinf.msg, &wcslen, bcsmsg, &bcslen);
|
||||
fprintf (stderr, "ERROR: cannot open moo - [%d] %s\n", (int)errinf.num, bcsmsg);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
moo_oow_t tab_size;
|
||||
|
||||
tab_size = 5000;
|
||||
moo_setoption (moo, MOO_SYMTAB_SIZE, &tab_size);
|
||||
tab_size = 5000;
|
||||
moo_setoption (moo, MOO_SYSDIC_SIZE, &tab_size);
|
||||
tab_size = 600;
|
||||
moo_setoption (moo, MOO_PROCSTK_SIZE, &tab_size);
|
||||
}
|
||||
|
||||
if (moo_ignite(moo, memsize) <= -1)
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot ignite moo - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo));
|
||||
moo_close (moo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
#if defined(macintosh)
|
||||
i = 20;
|
||||
xtn->source_path = "test.moo";
|
||||
goto compile;
|
||||
#endif
|
||||
*/
|
||||
for (i = opt.ind; i < argc; i++)
|
||||
{
|
||||
moo_iostd_t in;
|
||||
|
||||
#if 1
|
||||
in.type = MOO_IOSTD_FILEB;
|
||||
in.u.fileb.path = argv[i];
|
||||
#else
|
||||
moo_uch_t tmp[1000];
|
||||
moo_oow_t bcslen, ucslen;
|
||||
ucslen = MOO_COUNTOF(tmp);
|
||||
moo_conv_utf8_to_ucstr(argv[i], &bcslen, tmp, &ucslen);
|
||||
in.type = MOO_IOSTD_FILEU;
|
||||
in.u.fileu.path = tmp;
|
||||
#endif
|
||||
|
||||
/*compile:*/
|
||||
if (moo_compilestd(moo, &in, 1) <= -1)
|
||||
{
|
||||
if (moo->errnum == MOO_ESYNERR)
|
||||
{
|
||||
print_syntax_error (moo, argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot compile code - [%d] %js\n", moo_geterrnum(moo), moo_geterrmsg(moo));
|
||||
}
|
||||
|
||||
moo_close (moo);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
MOO_DEBUG0 (moo, "COMPILE OK. STARTING EXECUTION...\n");
|
||||
xret = 0;
|
||||
|
||||
#if defined(SIGINT) && defined(HAVE_SIGNAL)
|
||||
/* i'd like the program to ignore the interrupt signal
|
||||
* before moo_catch_termreq() and after moo_uncatch_termreq() */
|
||||
signal (SIGINT, SIG_IGN);
|
||||
signal (SIGTERM, SIG_IGN);
|
||||
#endif
|
||||
|
||||
moo_catch_termreq ();
|
||||
moo_start_ticker ();
|
||||
|
||||
moo_rcvtickstd (moo, 1);
|
||||
|
||||
objname.ptr = str_my_object;
|
||||
objname.len = 8;
|
||||
mthname.ptr = str_main;
|
||||
mthname.len = 4;
|
||||
if (moo_invoke(moo, &objname, &mthname) <= -1)
|
||||
{
|
||||
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot execute code - [%d] %js\n", moo_geterrnum(moo), moo_geterrmsg(moo));
|
||||
xret = -1;
|
||||
}
|
||||
|
||||
moo_stop_ticker ();
|
||||
moo_uncatch_termreq ();
|
||||
|
||||
/*moo_dumpsymtab(moo);
|
||||
moo_dumpdic(moo, moo->sysdic, "System dictionary");*/
|
||||
|
||||
moo_close (moo);
|
||||
return xret;
|
||||
}
|
@ -1,411 +0,0 @@
|
||||
/* Emulation for poll(2)
|
||||
Contributed by Paolo Bonzini.
|
||||
|
||||
Copyright 2001-2003, 2006-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of gnulib.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Tell gcc not to warn about the (nfd < 0) tests, below. */
|
||||
#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
#endif
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "poll-msw.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
# include <malloc.h>
|
||||
# define _alloca alloca
|
||||
#endif
|
||||
|
||||
#ifndef INFTIM
|
||||
# define INFTIM (-1)
|
||||
#endif
|
||||
|
||||
/* BeOS does not have MSG_PEEK. */
|
||||
#ifndef MSG_PEEK
|
||||
# define MSG_PEEK 0
|
||||
#endif
|
||||
|
||||
#ifndef POLLRDNORM
|
||||
# define POLLRDNORM 0
|
||||
# define POLLRDBAND 0
|
||||
# define POLLWRNORM 0
|
||||
# define POLLWRBAND 0
|
||||
#endif
|
||||
|
||||
static BOOL IsConsoleHandle (HANDLE h)
|
||||
{
|
||||
DWORD mode;
|
||||
return GetConsoleMode (h, &mode) != 0;
|
||||
}
|
||||
|
||||
static BOOL IsSocketHandle (HANDLE h)
|
||||
{
|
||||
WSANETWORKEVENTS ev;
|
||||
|
||||
if (IsConsoleHandle (h)) return FALSE;
|
||||
|
||||
/* Under Wine, it seems that getsockopt returns 0 for pipes too.
|
||||
WSAEnumNetworkEvents instead distinguishes the two correctly. */
|
||||
ev.lNetworkEvents = 0xDEADBEEF;
|
||||
WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
|
||||
return ev.lNetworkEvents != 0xDEADBEEF;
|
||||
}
|
||||
|
||||
/* Declare data structures for ntdll functions. */
|
||||
typedef struct _FILE_PIPE_LOCAL_INFORMATION
|
||||
{
|
||||
ULONG NamedPipeType;
|
||||
ULONG NamedPipeConfiguration;
|
||||
ULONG MaximumInstances;
|
||||
ULONG CurrentInstances;
|
||||
ULONG InboundQuota;
|
||||
ULONG ReadDataAvailable;
|
||||
ULONG OutboundQuota;
|
||||
ULONG WriteQuotaAvailable;
|
||||
ULONG NamedPipeState;
|
||||
ULONG NamedPipeEnd;
|
||||
} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
|
||||
|
||||
typedef struct _IO_STATUS_BLOCK
|
||||
{
|
||||
union
|
||||
{
|
||||
DWORD Status;
|
||||
PVOID Pointer;
|
||||
} u;
|
||||
/*ULONG_PTR Information;*/
|
||||
ULONG* Information;
|
||||
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
|
||||
|
||||
typedef enum _FILE_INFORMATION_CLASS
|
||||
{
|
||||
FilePipeLocalInformation = 24
|
||||
} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
|
||||
|
||||
typedef DWORD (WINAPI *PNtQueryInformationFile) (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
|
||||
|
||||
# ifndef PIPE_BUF
|
||||
# define PIPE_BUF 512
|
||||
# endif
|
||||
|
||||
/* Compute revents values for file handle H. If some events cannot happen
|
||||
for the handle, eliminate them from *P_SOUGHT. */
|
||||
|
||||
static int windows_compute_revents (HANDLE h, int *p_sought)
|
||||
{
|
||||
int i, ret, happened;
|
||||
INPUT_RECORD *irbuffer;
|
||||
DWORD avail, nbuffer;
|
||||
BOOL bRet;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
FILE_PIPE_LOCAL_INFORMATION fpli;
|
||||
static PNtQueryInformationFile NtQueryInformationFile;
|
||||
static BOOL once_only;
|
||||
|
||||
switch (GetFileType (h))
|
||||
{
|
||||
case FILE_TYPE_PIPE:
|
||||
if (!once_only)
|
||||
{
|
||||
NtQueryInformationFile = (PNtQueryInformationFile)
|
||||
GetProcAddress (GetModuleHandle(TEXT("ntdll.dll")), "NtQueryInformationFile");
|
||||
once_only = TRUE;
|
||||
}
|
||||
|
||||
happened = 0;
|
||||
if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
|
||||
{
|
||||
if (avail)
|
||||
happened |= *p_sought & (POLLIN | POLLRDNORM);
|
||||
}
|
||||
else if (GetLastError () == ERROR_BROKEN_PIPE)
|
||||
happened |= POLLHUP;
|
||||
|
||||
else
|
||||
{
|
||||
/* It was the write-end of the pipe. Check if it is writable.
|
||||
If NtQueryInformationFile fails, optimistically assume the pipe is
|
||||
writable. This could happen on Windows 9x, where
|
||||
NtQueryInformationFile is not available, or if we inherit a pipe
|
||||
that doesn't permit FILE_READ_ATTRIBUTES access on the write end
|
||||
(I think this should not happen since Windows XP SP2; WINE seems
|
||||
fine too). Otherwise, ensure that enough space is available for
|
||||
atomic writes. */
|
||||
memset (&iosb, 0, sizeof (iosb));
|
||||
memset (&fpli, 0, sizeof (fpli));
|
||||
|
||||
if (!NtQueryInformationFile
|
||||
|| NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), FilePipeLocalInformation)
|
||||
|| fpli.WriteQuotaAvailable >= PIPE_BUF
|
||||
|| (fpli.OutboundQuota < PIPE_BUF && fpli.WriteQuotaAvailable == fpli.OutboundQuota))
|
||||
{
|
||||
happened |= *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
|
||||
}
|
||||
}
|
||||
return happened;
|
||||
|
||||
case FILE_TYPE_CHAR:
|
||||
ret = WaitForSingleObject (h, 0);
|
||||
if (!IsConsoleHandle (h))
|
||||
return ret == WAIT_OBJECT_0 ? *p_sought & ~(POLLPRI | POLLRDBAND) : 0;
|
||||
|
||||
nbuffer = avail = 0;
|
||||
bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
|
||||
if (bRet)
|
||||
{
|
||||
/* Input buffer. */
|
||||
*p_sought &= POLLIN | POLLRDNORM;
|
||||
if (nbuffer == 0)
|
||||
return POLLHUP;
|
||||
if (!*p_sought)
|
||||
return 0;
|
||||
|
||||
irbuffer = (INPUT_RECORD *)_alloca(nbuffer * sizeof (INPUT_RECORD));
|
||||
bRet = PeekConsoleInput(h, irbuffer, nbuffer, &avail);
|
||||
if (!bRet || avail == 0)
|
||||
return POLLHUP;
|
||||
|
||||
for (i = 0; i < avail; i++)
|
||||
if (irbuffer[i].EventType == KEY_EVENT)
|
||||
return *p_sought;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Screen buffer. */
|
||||
*p_sought &= POLLOUT | POLLWRNORM | POLLWRBAND;
|
||||
return *p_sought;
|
||||
}
|
||||
|
||||
default:
|
||||
ret = WaitForSingleObject (h, 0);
|
||||
if (ret == WAIT_OBJECT_0)
|
||||
return *p_sought & ~(POLLPRI | POLLRDBAND);
|
||||
|
||||
return *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert fd_sets returned by select into revents values. */
|
||||
|
||||
static int windows_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
|
||||
{
|
||||
int happened = 0;
|
||||
|
||||
if ((lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) == FD_ACCEPT)
|
||||
happened |= (POLLIN | POLLRDNORM) & sought;
|
||||
|
||||
else if (lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
|
||||
{
|
||||
int r, error;
|
||||
|
||||
char data[64];
|
||||
WSASetLastError (0);
|
||||
r = recv (h, data, sizeof (data), MSG_PEEK);
|
||||
error = WSAGetLastError ();
|
||||
WSASetLastError (0);
|
||||
|
||||
if (r > 0 || error == WSAENOTCONN)
|
||||
happened |= (POLLIN | POLLRDNORM) & sought;
|
||||
|
||||
/* Distinguish hung-up sockets from other errors. */
|
||||
else if (r == 0 || error == WSAESHUTDOWN || error == WSAECONNRESET
|
||||
|| error == WSAECONNABORTED || error == WSAENETRESET)
|
||||
happened |= POLLHUP;
|
||||
|
||||
else
|
||||
happened |= POLLERR;
|
||||
}
|
||||
|
||||
if (lNetworkEvents & (FD_WRITE | FD_CONNECT))
|
||||
happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
|
||||
|
||||
if (lNetworkEvents & FD_OOB)
|
||||
happened |= (POLLPRI | POLLRDBAND) & sought;
|
||||
|
||||
return happened;
|
||||
}
|
||||
|
||||
|
||||
int poll (struct pollfd *pfd, nfds_t nfd, int timeout)
|
||||
{
|
||||
static struct timeval tv0;
|
||||
static HANDLE hEvent;
|
||||
WSANETWORKEVENTS ev;
|
||||
HANDLE h, handle_array[FD_SETSIZE + 2];
|
||||
DWORD ret, wait_timeout, nhandles;
|
||||
fd_set rfds, wfds, xfds;
|
||||
BOOL poll_again;
|
||||
MSG msg;
|
||||
int rc = 0;
|
||||
nfds_t i;
|
||||
|
||||
if (nfd < 0 || timeout < -1)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!hEvent)
|
||||
hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
|
||||
|
||||
restart:
|
||||
handle_array[0] = hEvent;
|
||||
nhandles = 1;
|
||||
FD_ZERO (&rfds);
|
||||
FD_ZERO (&wfds);
|
||||
FD_ZERO (&xfds);
|
||||
|
||||
/* Classify socket handles and create fd sets. */
|
||||
for (i = 0; i < nfd; i++)
|
||||
{
|
||||
int sought = pfd[i].events;
|
||||
pfd[i].revents = 0;
|
||||
if (pfd[i].fd < 0) continue;
|
||||
if (!(sought & (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLWRBAND | POLLPRI | POLLRDBAND))) continue;
|
||||
|
||||
h = (HANDLE)_get_osfhandle(pfd[i].fd);
|
||||
if (IsSocketHandle (h))
|
||||
{
|
||||
int requested = FD_CLOSE;
|
||||
|
||||
/* see above; socket handles are mapped onto select. */
|
||||
if (sought & (POLLIN | POLLRDNORM))
|
||||
{
|
||||
requested |= FD_READ | FD_ACCEPT;
|
||||
FD_SET ((SOCKET) h, &rfds);
|
||||
}
|
||||
if (sought & (POLLOUT | POLLWRNORM | POLLWRBAND))
|
||||
{
|
||||
requested |= FD_WRITE | FD_CONNECT;
|
||||
FD_SET ((SOCKET) h, &wfds);
|
||||
}
|
||||
if (sought & (POLLPRI | POLLRDBAND))
|
||||
{
|
||||
requested |= FD_OOB;
|
||||
FD_SET ((SOCKET) h, &xfds);
|
||||
}
|
||||
|
||||
if (requested)
|
||||
WSAEventSelect ((SOCKET) h, hEvent, requested);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Poll now. If we get an event, do not poll again. Also,
|
||||
screen buffer handles are waitable, and they'll block until
|
||||
a character is available. windows_compute_revents eliminates
|
||||
bits for the "wrong" direction. */
|
||||
pfd[i].revents = windows_compute_revents (h, &sought);
|
||||
if (sought) handle_array[nhandles++] = h;
|
||||
if (pfd[i].revents) timeout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (select(0, &rfds, &wfds, &xfds, &tv0) > 0)
|
||||
{
|
||||
/* Do MsgWaitForMultipleObjects anyway to dispatch messages, but
|
||||
no need to call select again. */
|
||||
poll_again = FALSE;
|
||||
wait_timeout = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
poll_again = TRUE;
|
||||
if (timeout == INFTIM)
|
||||
wait_timeout = INFINITE;
|
||||
else
|
||||
wait_timeout = timeout;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ret = MsgWaitForMultipleObjects(nhandles, handle_array, FALSE, wait_timeout, QS_ALLINPUT);
|
||||
|
||||
if (ret == WAIT_OBJECT_0 + nhandles)
|
||||
{
|
||||
/* new input of some other kind */
|
||||
BOOL bRet;
|
||||
while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0)
|
||||
{
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (poll_again)
|
||||
select (0, &rfds, &wfds, &xfds, &tv0);
|
||||
|
||||
/* Place a sentinel at the end of the array. */
|
||||
handle_array[nhandles] = NULL;
|
||||
nhandles = 1;
|
||||
for (i = 0; i < nfd; i++)
|
||||
{
|
||||
int happened;
|
||||
|
||||
if (pfd[i].fd < 0)
|
||||
continue;
|
||||
if (!(pfd[i].events & (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLWRBAND)))
|
||||
continue;
|
||||
|
||||
h = (HANDLE) _get_osfhandle (pfd[i].fd);
|
||||
if (h != handle_array[nhandles])
|
||||
{
|
||||
/* It's a socket. */
|
||||
WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
|
||||
WSAEventSelect ((SOCKET) h, 0, 0);
|
||||
|
||||
/* If we're lucky, WSAEnumNetworkEvents already provided a way
|
||||
to distinguish FD_READ and FD_ACCEPT; this saves a recv later. */
|
||||
if (FD_ISSET ((SOCKET) h, &rfds) && !(ev.lNetworkEvents & (FD_READ | FD_ACCEPT)))
|
||||
ev.lNetworkEvents |= FD_READ | FD_ACCEPT;
|
||||
if (FD_ISSET ((SOCKET) h, &wfds))
|
||||
ev.lNetworkEvents |= FD_WRITE | FD_CONNECT;
|
||||
if (FD_ISSET ((SOCKET) h, &xfds))
|
||||
ev.lNetworkEvents |= FD_OOB;
|
||||
|
||||
happened = windows_compute_revents_socket ((SOCKET) h, pfd[i].events, ev.lNetworkEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not a socket. */
|
||||
int sought = pfd[i].events;
|
||||
happened = windows_compute_revents (h, &sought);
|
||||
nhandles++;
|
||||
}
|
||||
|
||||
if ((pfd[i].revents |= happened) != 0) rc++;
|
||||
}
|
||||
|
||||
if (!rc && timeout == INFTIM)
|
||||
{
|
||||
SleepEx (1, TRUE);
|
||||
goto restart;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#ifndef _POLL_MSW_H_
|
||||
#define _POLL_MSW_H_
|
||||
|
||||
#include "moo.h"
|
||||
|
||||
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0600)
|
||||
/* Event types that can be polled for. These bits may be set in `events'
|
||||
to indicate the interesting event types; they will appear in `revents'
|
||||
to indicate the status of the file descriptor. */
|
||||
#define POLLIN 0x001 /* There is data to read. */
|
||||
#define POLLPRI 0x002 /* There is urgent data to read. */
|
||||
#define POLLOUT 0x004 /* Writing now will not block. */
|
||||
|
||||
/* Event types always implicitly polled for. These bits need not be set in
|
||||
`events', but they will appear in `revents' to indicate the status of
|
||||
the file descriptor. */
|
||||
#define POLLERR 0x008 /* Error condition. */
|
||||
#define POLLHUP 0x010 /* Hung up. */
|
||||
#define POLLNVAL 0x020 /* Invalid polling request. */
|
||||
|
||||
/* Data structure describing a polling request. */
|
||||
struct pollfd
|
||||
{
|
||||
int fd; /* File descriptor to poll. */
|
||||
short int events; /* Types of events poller cares about. */
|
||||
short int revents; /* Types of events that actually occurred. */
|
||||
};
|
||||
|
||||
/* Poll the file descriptors described by the NFDS structures starting at
|
||||
FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
|
||||
an event to occur; if TIMEOUT is -1, block until an event occurs.
|
||||
Returns the number of file descriptors with events, zero if timed out,
|
||||
or -1 for errors. */
|
||||
#endif
|
||||
|
||||
typedef unsigned long nfds_t;
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int poll (struct pollfd *pfd, nfds_t nfd, int timeout);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user