diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-11-13 02:44:40 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-11-13 02:44:40 +0000 |
commit | ec256792a5ad61489b3d850adcb9eeb66227dcc7 (patch) | |
tree | f3d03ce3689adc220a6e9f1e0c2a9cf2caa0f036 | |
parent | 8d37599c4eca0400eb35bf811817a5fe6ff6159a (diff) | |
parent | f3986ebb5fa156b34b51584d78a10d0d906dbcd6 (diff) | |
download | perl-ec256792a5ad61489b3d850adcb9eeb66227dcc7.tar.gz |
Integrate Win32 branch
p4raw-id: //depot/ansiperl@246
38 files changed, 654 insertions, 6966 deletions
@@ -880,8 +880,6 @@ win32/runperl.c Win32 port win32/splittree.pl Win32 port win32/win32.c Win32 port win32/win32.h Win32 port -win32/win32io.c Win32 port -win32/win32io.h Win32 port win32/win32iop.h Win32 port win32/win32sck.c Win32 port win32/win32thread.h Win32 port mapping to threads diff --git a/configure b/configure deleted file mode 100755 index e101147948..0000000000 --- a/configure +++ /dev/null @@ -1,124 +0,0 @@ -#! /bin/sh -# -# $Id: configure,v 3.0.1.1 1995/07/25 14:16:21 ram Exp $ -# -# GNU configure-like front end to metaconfig's Configure. -# -# Written by Andy Dougherty <doughera@lafcol.lafayette.edu> -# and Matthew Green <mrg@mame.mu.oz.au>. -# -# Reformatted and modified for inclusion in the dist-3.0 package by -# Raphael Manfredi <ram@hptnos02.grenoble.hp.com>. -# -# This script belongs to the public domain and may be freely redistributed. -# -# The remaining of this leading shell comment may be removed if you -# include this script in your own package. -# -# $Log: configure,v $ -# Revision 3.0.1.1 1995/07/25 14:16:21 ram -# patch56: created -# - -(exit $?0) || exec sh $0 $argv:q - -case "$0" in -*configure) - if cmp $0 `echo $0 | sed -e s/configure/Configure/` >/dev/null; then - echo "Your configure and Configure scripts seem to be identical." - echo "This can happen on filesystems that aren't fully case sensitive." - echo "You'll have to explicitly extract Configure and run that." - exit 1 - fi - ;; -esac - -opts='' -verbose='' -create='-e' -while test $# -gt 0; do - case $1 in - --help) - cat <<EOM -Usage: configure [options] -This is GNU configure-like front end for a metaconfig-generated Configure. -It emulates the following GNU configure options (must be fully spelled out): - --help - --no-create - --prefix=PREFIX - --cache-file (ignored) - --quiet - --silent - --verbose - --version - -And it honours these environment variables: CC, CFLAGS and DEFS. -EOM - exit 0 - ;; - --no-create) - create='-E' - shift - ;; - --prefix=*) - arg=`echo $1 | sed 's/--prefix=/-Dprefix=/'` - opts="$opts $arg" - shift - ;; - --cache-file=*) - shift # Just ignore it. - ;; - --quiet|--silent) - exec >/dev/null 2>&1 - shift - ;; - --verbose) - verbose=true - shift - ;; - --version) - copt="$copt -V" - shift - ;; - --*) - opt=`echo $1 | sed 's/=.*//'` - echo "This GNU configure front end does not understand $opt" - exit 1 - ;; - *) - opts="$opts $1" - shift - ;; - esac -done - -case "$CC" in -'') ;; -*) opts="$opts -Dcc='$CC'";; -esac - -# Join DEFS and CFLAGS together. -ccflags='' -case "$DEFS" in -'') ;; -*) ccflags=$DEFS;; -esac -case "$CFLAGS" in -'') ;; -*) ccflags="$ccflags $CFLAGS";; -esac -case "$ccflags" in -'') ;; -*) opts="$opts -Dccflags='$ccflags'";; -esac - -# Don't use -s if they want verbose mode -case "$verbose" in -'') copt="$copt -ds";; -*) copt="$copt -d";; -esac - -set X sh Configure $copt $create $opts -shift -echo "$@" -exec "$@" @@ -94,12 +94,9 @@ void Perl_DJGPP_init(); #ifndef WIN32 # define Stat(fname,bufptr) stat((fname),(bufptr)) #else -# define Stat(fname,bufptr) win32_stat((fname),(bufptr)) -# define my_getenv(var) getenv(var) /* - * the following are standard library calls (stdio in particular) - * that is being redirected to the perl DLL. This is needed for - * Dynaloading any modules that called stdio functions + * This provides a layer of functions and macros to ensure extensions will + * get to use the same RTL functions as the core. */ # include <win32iop.h> #endif /* WIN32 */ @@ -1277,6 +1277,7 @@ #define formfeed (curinterp->Iformfeed) #define formtarget (curinterp->Iformtarget) #define gensym (curinterp->Igensym) +#define globalstash (curinterp->Iglobalstash) #define in_eval (curinterp->Iin_eval) #define incgv (curinterp->Iincgv) #define initav (curinterp->Iinitav) @@ -1330,7 +1331,6 @@ #define restartop (curinterp->Irestartop) #define rightgv (curinterp->Irightgv) #define rs (curinterp->Irs) -#define runlevel (curinterp->Irunlevel) #define sawampersand (curinterp->Isawampersand) #define sawstudy (curinterp->Isawstudy) #define sawvec (curinterp->Isawvec) @@ -1429,6 +1429,7 @@ #define Iformfeed formfeed #define Iformtarget formtarget #define Igensym gensym +#define Iglobalstash globalstash #define Iin_eval in_eval #define Iincgv incgv #define Iinitav initav @@ -1482,7 +1483,6 @@ #define Irestartop restartop #define Irightgv rightgv #define Irs rs -#define Irunlevel runlevel #define Isawampersand sawampersand #define Isawstudy sawstudy #define Isawvec sawvec @@ -1590,6 +1590,7 @@ #define formfeed Perl_formfeed #define formtarget Perl_formtarget #define gensym Perl_gensym +#define globalstash Perl_globalstash #define in_eval Perl_in_eval #define incgv Perl_incgv #define initav Perl_initav @@ -1643,7 +1644,6 @@ #define restartop Perl_restartop #define rightgv Perl_rightgv #define rs Perl_rs -#define runlevel Perl_runlevel #define sawampersand Perl_sawampersand #define sawstudy Perl_sawstudy #define sawvec Perl_sawvec diff --git a/ext/util/extliblist b/ext/util/extliblist deleted file mode 100755 index 2351ddfd0e..0000000000 --- a/ext/util/extliblist +++ /dev/null @@ -1,155 +0,0 @@ -case $CONFIG in -'') - if test -f config.sh; then TOP=.; - elif test -f ../config.sh; then TOP=..; - elif test -f ../../config.sh; then TOP=../..; - elif test -f ../../../config.sh; then TOP=../../..; - elif test -f ../../../../config.sh; then TOP=../../../..; - else - echo "Can't find config.sh."; exit 1 - fi - . $TOP/config.sh - ;; -esac -: extliblist -: -: Author: Andy Dougherty doughera@lafcol.lafayette.edu -: -: This utility was only used by the old Makefile.SH extension -: mechanism. It is now obsolete and may be removed in a future -: release. -: -: This utility takes a list of libraries in the form -: -llib1 -llib2 -llib3 -: and prints out lines suitable for inclusion in an extension -: Makefile. -: Extra library paths may be included with the form -L/another/path -: this will affect the searches for all subsequent libraries. -: -: It is intended to be "dotted" from within an extension Makefile.SH. -: see ext/POSIX/Makefile.SH for an example. -: Prior to calling this, the variable potential_libs should be set -: to the potential list of libraries -: -: It sets the following -: extralibs = full list of libraries needed for static linking. -: Only those libraries that actually exist are included. -: dynaloadlibs = full path names of those libraries that are needed -: but can be linked in dynamically on this platform. On -: SunOS, for example, this would be .so* libraries, -: but not archive libraries. -: Eventually, this list can be used to write a bootstrap file. -: statloadlibs = list of those libraries which must be statically -: linked into the shared library. On SunOS 4.1.3, -: for example, I have only an archive version of -: -lm, and it must be linked in statically. -: -: This script uses config.sh variables libs, libpth, and so. It is mostly -: taken from the metaconfig libs.U unit. -extralibs='' -dynaloadlibs='' -statloadlibs='' -Llibpth='' -for thislib in `echo "XXX $potential_libs " | $sed 's/ -l/ /g'` ; do - case "$thislib" in - XXX) - : Handle case where potential_libs is empty. - ;; - -L*) - : Handle possible linker path arguments. - newpath=`echo $thislib | $sed 's/^-L//'` - if $test -d $newpath; then - Llibpth="$Llibpth $newpath" - extralibs="$extralibs $thislib" - statloadlibs="$statloadlibs $thislib" - fi - ;; - *) - : Handle possible library arguments. - for thispth in $Llibpth $libpth; do - : Loop over possible wildcards and take the last one. - for fullname in $thispth/lib$thislib.$so.[0-9]* ; do - : - done - if $test -f $fullname; then - break - elif fullname=$thispth/lib$thislib.$so && $test -f $fullname; then - break - elif fullname=$thispth/lib${thislib}_s.a && $test -f $fullname; then - thislib=${thislib}_s - break - elif fullname=$thispth/lib${thislib}.a && $test -f $fullname; then - break - elif fullname=$thispth/Slib${thislib}.a && $test -f $fullname; then - break - else - fullname='' - fi - done - : Now update library lists - case "$fullname" in - '') - : Skip nonexistent files - ;; - *) - : Do not add it into the extralibs if it is already linked in - : with the main perl executable. - case " $libs " in - *" -l$thislib "*|*" -l${thislib}_s "*) ;; - *) extralibs="$extralibs -l$thislib" ;; - esac - : - : For NeXT and DLD, put files into DYNALOADLIBS to be - : converted into a boostrap file. For other systems, - : we will use ld with what I have misnamed STATLOADLIBS - : to assemble the shared object. - case "$dlsrc" in - dl_dld*|dl_next*) - dynaloadlibs="$dynaloadlibs $fullname" ;; - *) - case "$fullname" in - *.a) - statloadlibs="$statloadlibs -l$thislib" - ;; - *) - : For SunOS4, do not add in this shared library - : if it is already linked in the main - : perl executable - case "$osname" in - sunos) - case " $libs " in - *" -l$thislib "*) ;; - *) statloadlibs="$statloadlibs -l$thislib" ;; - esac - ;; - *) - statloadlibs="$statloadlibs -l$thislib" - ;; - esac - ;; - esac - ;; - esac - ;; - esac - ;; - esac -done - -case "$dlsrc" in -dl_next*) - extralibs=`echo " $extralibs "| $sed -e 's/ -lm / /'` ;; -esac - -set X $extralibs -shift -extralibs="$*" - -set X $dynaloadlibs -shift -dynaloadlibs="$*" - -set X $statloadlibs -shift -statloadlibs="$*" - diff --git a/global.sym b/global.sym index 178fa29f70..d32b9807d1 100644 --- a/global.sym +++ b/global.sym @@ -986,6 +986,7 @@ pp_system pp_syswrite pp_tell pp_telldir +pp_threadsv pp_tie pp_tied pp_time diff --git a/interp.sym b/interp.sym index 1583ea217e..f50711b802 100644 --- a/interp.sym +++ b/interp.sym @@ -57,6 +57,7 @@ forkprocess formfeed formtarget gensym +globalstash in_eval incgv initav @@ -110,7 +111,6 @@ preprocess restartop rightgv rs -runlevel sawampersand sawstudy sawvec diff --git a/miniperlmain.c b/miniperlmain.c index 7522ae28cf..27ad541fb4 100644 --- a/miniperlmain.c +++ b/miniperlmain.c @@ -10,13 +10,6 @@ #include "EXTERN.h" #include "perl.h" -#undef EXTERN_C -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C extern -#endif - static void xs_init _((void)); static PerlInterpreter *my_perl; @@ -1798,6 +1798,7 @@ init_main_stash(void) curstash = defstash; compiling.cop_stash = defstash; debstash = GvHV(gv_fetchpv("DB::", GV_ADDMULTI, SVt_PVHV)); + globalstash = GvHV(gv_fetchpv("CORE::GLOBAL::", GV_ADDMULTI, SVt_PVHV)); /* We must init $/ before switches are processed. */ sv_setpvn(GvSV(gv_fetchpv("/", TRUE, SVt_PV)), "\n", 1); } @@ -2849,7 +2850,7 @@ init_main_thread() SET_THREAD_SELF(thr); #else thr->self = pthread_self(); -#endif /* HAVE_THREAD_INTERN */ +#endif /* SET_THREAD_SELF */ SET_THR(thr); /* @@ -29,6 +29,9 @@ #include "embed.h" +#undef START_EXTERN_C +#undef END_EXTERN_C +#undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } @@ -1894,6 +1897,7 @@ IEXT AV * Idbargs; /* args to call listed by caller function */ IEXT HV * Idefstash; /* main symbol table */ IEXT HV * Icurstash; /* symbol table for current package */ IEXT HV * Idebstash; /* symbol table for perldb package */ +IEXT HV * Iglobalstash; /* global keyword overrides imported here */ IEXT SV * Icurstname; /* name of current package */ IEXT AV * Ibeginav; /* names of BEGIN subroutines */ IEXT AV * Iendav; /* names of END subroutines */ @@ -1950,7 +1954,6 @@ IEXT I32 Icxstack_ix IINIT(-1); IEXT I32 Icxstack_max IINIT(128); IEXT JMPENV Istart_env; /* empty startup sigjmp() environment */ IEXT JMPENV * Itop_env; /* ptr. to current sigjmp() environment */ -IEXT I32 Irunlevel; /* stack stuff */ IEXT AV * Icurstack; /* THE STACK */ @@ -2055,20 +2055,18 @@ docatch(OP *o) { dTHR; int ret; - I32 oldrunlevel = runlevel; OP *oldop = op; dJMPENV; op = o; #ifdef DEBUGGING assert(CATCH_GET == TRUE); - DEBUG_l(deb("(Setting up local jumplevel, runlevel = %ld)\n", (long)runlevel+1)); + DEBUG_l(deb("Setting up local jumplevel %p, was %p\n", &cur_env, top_env)); #endif JMPENV_PUSH(ret); switch (ret) { default: /* topmost level handles it */ JMPENV_POP; - runlevel = oldrunlevel; op = oldop; JMPENV_JUMP(ret); /* NOTREACHED */ @@ -2085,7 +2083,6 @@ docatch(OP *o) break; } JMPENV_POP; - runlevel = oldrunlevel; op = oldop; return Nullop; } @@ -22,8 +22,6 @@ dEXT char *watchok; int runops_standard(void) { dTHR; - SAVEI32(runlevel); - runlevel++; while ( op = (*op->op_ppaddr)(ARGS) ) ; @@ -42,9 +40,6 @@ runops_debug(void) { return 0; } - SAVEI32(runlevel); - runlevel++; - do { if (debug) { if (watchaddr != 0 && *watchaddr != watchok) @@ -211,7 +211,6 @@ struct thread { AV * Tcurstack; AV * Tmainstack; JMPENV * Ttop_env; - I32 Trunlevel; /* XXX Sort stuff, firstgv, secongv and so on? */ @@ -312,7 +311,6 @@ typedef struct condpair { #undef start_env #undef toptarget #undef top_env -#undef runlevel #undef in_eval #undef restartop #undef delaymagic @@ -384,7 +382,6 @@ typedef struct condpair { #define localizing (thr->Tlocalizing) #define top_env (thr->Ttop_env) -#define runlevel (thr->Trunlevel) #define start_env (thr->Tstart_env) #else @@ -2520,7 +2520,10 @@ yylex(void) case 'y': case 'Y': case 'z': case 'Z': - keylookup: + keylookup: { + GV *gv = Nullgv; + GV **gvp = 0; + bufptr = s; s = scan_word(s, tokenbuf, sizeof tokenbuf, FALSE, &len); @@ -2562,16 +2565,24 @@ yylex(void) } if (tmp < 0) { /* second-class keyword? */ - GV* gv; - if (expect != XOPERATOR && - (*s != ':' || s[1] != ':') && - (gv = gv_fetchpv(tokenbuf, FALSE, SVt_PVCV)) && - GvIMPORTED_CV(gv)) + if (expect != XOPERATOR && (*s != ':' || s[1] != ':') && + (((gv = gv_fetchpv(tokenbuf, FALSE, SVt_PVCV)) && + GvCVu(gv) && GvIMPORTED_CV(gv)) || + ((gvp = (GV**)hv_fetch(globalstash,tokenbuf,len,FALSE)) && + (gv = *gvp) != (GV*)&sv_undef && + GvCVu(gv) && GvIMPORTED_CV(gv)))) { - tmp = 0; + tmp = 0; /* overridden by importation */ + } + else if (gv && !gvp + && -tmp==KEY_lock /* XXX generalizable kludge */ + && !hv_fetch(GvHVn(incgv), "Thread.pm", 9, FALSE)) + { + tmp = 0; /* any sub overrides "weak" keyword */ + } + else { + tmp = -tmp; gv = Nullgv; gvp = 0; } - else - tmp = -tmp; } reserved_word: @@ -2579,7 +2590,6 @@ yylex(void) default: /* not a keyword */ just_a_word: { - GV *gv; SV *sv; char lastchar = (bufptr == oldoldbufptr ? 0 : bufptr[-1]); @@ -2604,12 +2614,19 @@ yylex(void) /* Look for a subroutine with this name in current package. */ - gv = gv_fetchpv(tokenbuf,FALSE, SVt_PVCV); + if (gvp) { + sv = newSVpv("CORE::GLOBAL::",14); + sv_catpv(sv,tokenbuf); + } + else + sv = newSVpv(tokenbuf,0); + if (!gv) + gv = gv_fetchpv(tokenbuf,FALSE, SVt_PVCV); /* Presume this is going to be a bareword of some sort. */ CLINE; - yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(tokenbuf,0)); + yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv); yylval.opval->op_private = OPpCONST_BARE; /* See if it's the indirect object for a list operator. */ @@ -3745,7 +3762,7 @@ yylex(void) s = scan_trans(s); TERM(sublex_start()); } - } + }} } I32 @@ -1120,7 +1120,6 @@ die(pat, va_alist) dTHR; va_list args; char *message; - I32 oldrunlevel = runlevel; int was_in_eval = in_eval; HV *stash; GV *gv; @@ -1181,10 +1180,10 @@ die(pat, va_alist) restartop = die_where(message); #ifdef USE_THREADS DEBUG_L(PerlIO_printf(PerlIO_stderr(), - "%p: die: restartop = %p, was_in_eval = %d, oldrunlevel = %d\n", - thr, restartop, was_in_eval, oldrunlevel)); + "%p: die: restartop = %p, was_in_eval = %d, top_env = %p\n", + thr, restartop, was_in_eval, top_env)); #endif /* USE_THREADS */ - if ((!restartop && was_in_eval) || oldrunlevel > 1) + if ((!restartop && was_in_eval) || top_env->je_prev) JMPENV_JUMP(3); return restartop; } @@ -2418,8 +2417,6 @@ new_struct_thread(struct thread *t) SvGROW(sv, sizeof(struct thread) + 1); SvCUR_set(sv, sizeof(struct thread)); thr = (Thread) SvPVX(sv); - /* Zero(thr, 1, struct thread); */ - /* debug */ memset(thr, 0xab, sizeof(struct thread)); markstack = 0; @@ -2431,7 +2428,7 @@ new_struct_thread(struct thread *t) /* end debug */ thr->oursv = sv; - init_stacks(thr); + init_stacks(ARGS); curcop = &compiling; thr->cvcache = newHV(); @@ -2445,9 +2442,21 @@ new_struct_thread(struct thread *t) curcop = t->Tcurcop; /* XXX As good a guess as any? */ defstash = t->Tdefstash; /* XXX maybe these should */ curstash = t->Tcurstash; /* always be set to main? */ - /* top_env needs to be non-zero. The particular value doesn't matter */ - top_env = t->Ttop_env; - runlevel = 1; /* XXX should be safe ? */ + + + /* top_env needs to be non-zero. It points to an area + in which longjmp() stuff is stored, as C callstack + info there at least is thread specific this has to + be per-thread. Otherwise a 'die' in a thread gives + that thread the C stack of last thread to do an eval {}! + See comments in scope.h + Initialize top entry (as in perl.c for main thread) + */ + start_env.je_prev = NULL; + start_env.je_ret = -1; + start_env.je_mustcatch = TRUE; + top_env = &start_env; + in_eval = FALSE; restartop = 0; @@ -2472,7 +2481,8 @@ new_struct_thread(struct thread *t) av_store(thr->magicals, i, sv); sv_magic(sv, 0, 0, &per_thread_magicals[i], 1); DEBUG_L(PerlIO_printf(PerlIO_stderr(), - "new_struct_thread: copied magical %d\n",i)); + "new_struct_thread: copied magical %d %p->%p\n",i, + t, thr)); } } diff --git a/win32/Makefile b/win32/Makefile index f6b9a99b45..5d241300c0 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -11,7 +11,7 @@ # newly built perl. INST_DRV=c: INST_TOP=$(INST_DRV)\perl -BUILDOPT=-DUSE_THREADS -TP +BUILDOPT=-DUSE_THREADS CORECCOPT= # @@ -60,7 +60,7 @@ LIBC = msvcrt.lib WINIOMAYBE = !ELSE LIBC = libcmt.lib -WINIOMAYBE = win32io.obj +WINIOMAYBE = !ENDIF !IF "$(CFG)" == "Debug" @@ -197,18 +197,15 @@ CORE_OBJ= ..\av.obj \ WIN32_C = perllib.c \ win32.c \ - win32io.c \ win32sck.c \ win32thread.c WIN32_OBJ = win32.obj \ - win32io.obj \ win32sck.obj \ win32thread.obj PERL95_OBJ = perl95.obj \ win32mt.obj \ - win32iomt.obj \ win32sckmt.obj DLL_OBJ = perllib.obj $(DYNALOADER).obj @@ -236,6 +233,7 @@ CORE_H = ..\av.h \ ..\regexp.h \ ..\scope.h \ ..\sv.h \ + ..\thread.h \ ..\unixish.h \ ..\util.h \ ..\XSUB.h \ @@ -313,6 +311,7 @@ config.w32 : $(CFGSH_TMPL) "INST_TOP=$(INST_TOP)" "cc=$(CC)" "ccflags=$(OPTIMIZE) $(DEFINES)" \ "cf_email=$(EMAIL)" "libs=$(LIBFILES)" "incpath=$(CCINCDIR)" \ "libpth=$(CCLIBDIR)" "libc=$(LIBC)" \ + "LINK_FLAGS=$(LINK_FLAGS)" \ config.w32 > ..\config.sh $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl @@ -361,8 +360,6 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) perlmain.obj del perl.exe copy splittree.pl .. $(MINIPERL) -I..\lib ..\splittree.pl "../LIB" "../LIB/auto" -# attrib -r ..\t\*.* -# copy test ..\t perl95.c : runperl.c copy runperl.c perl95.c @@ -370,9 +367,6 @@ perl95.c : runperl.c perl95.obj : perl95.c $(CC) $(CFLAGS) -MT -UPERLDLL -c perl95.c -win32iomt.obj : win32io.c - $(CC) $(CFLAGS) -MT -c $(OBJOUT_FLAG)win32iomt.obj win32io.c - win32sckmt.obj : win32sck.c $(CC) $(CFLAGS) -MT -c $(OBJOUT_FLAG)win32sckmt.obj win32sck.c @@ -386,7 +380,7 @@ $(PERL95EXE): $(PERLDLL) $(CONFIGPM) $(PERL95_OBJ) del perl95.exe $(DYNALOADER).c: $(MINIPERL) $(EXTDIR)\DynaLoader\dl_win32.xs $(CONFIGPM) - if not exist ..\lib\auto md ..\lib\auto + if not exist ..\lib\auto mkdir ..\lib\auto $(XCOPY) $(EXTDIR)\$(*B)\$(*B).pm $(LIBDIR)\$(NULL) cd $(EXTDIR)\$(*B) $(XSUBPP) dl_win32.xs > $(*B).c diff --git a/win32/bin/pl2bat.bat b/win32/bin/pl2bat.bat deleted file mode 100644 index 7f5f39aa95..0000000000 --- a/win32/bin/pl2bat.bat +++ /dev/null @@ -1,54 +0,0 @@ -@rem = '--*-Perl-*-- -@echo off -perl -x -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto endofperl -@rem '; -#!perl -w -#line 8 -(my $head = <<'--end--') =~ s/^\t//gm; - @rem = '--*-Perl-*-- - @echo off - perl -x -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 - goto endofperl - @rem '; ---end-- -my $headlines = 2 + ($head =~ tr/\n/\n/); -my $tail = "__END__\n:endofperl\n"; - -@ARGV = ('-') unless @ARGV; - -process(@ARGV); - -sub process { - LOOP: - foreach ( @_ ) { - my $myhead = $head; - my $linedone = 0; - my $linenum = $headlines; - my $line; - open( FILE, $_ ) or die "Can't open $_: $!"; - @file = <FILE>; - foreach $line ( @file ) { - $linenum++; - if ( $line =~ /^:endofperl/) { - warn "$_ has already been converted to a batch file!\n"; - next LOOP; - } - if ( not $linedone and $line =~ /^#!.*perl/ ) { - $line .= "#line $linenum\n"; - $linedone++; - } - } - close( FILE ); - s/\.pl$//; - $_ .= '.bat' unless /\.bat$/ or /^-$/; - open( FILE, ">$_" ) or die "Can't open $_: $!"; - $myhead =~ s/perl -x/perl/ unless $linedone; - print FILE $myhead; - print FILE "#line $headlines\n" unless $linedone; - print FILE @file, $tail; - close( FILE ); - } -} -__END__ -:endofperl diff --git a/win32/bin/search.bat b/win32/bin/search.bat deleted file mode 100644 index 88e83e5040..0000000000 --- a/win32/bin/search.bat +++ /dev/null @@ -1,1873 +0,0 @@ -@rem = '--*-Perl-*--'; -@rem = ' -@echo off -perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto endofperl -@rem '; -#!/usr/local/bin/perl -w -'di'; -'ig00'; -############################################################################## -## -## search -## -## Jeffrey Friedl (jfriedl@omron.co.jp), Dec 1994. -## Copyright 19.... ah hell, just take it. -## -## BLURB: -## A combo of find and grep -- more or less do a 'grep' on a whole -## directory tree. Fast, with lots of options. Much more powerful than -## the simple "find ... | xargs grep ....". Has a full man page. -## Powerfully customizable. -## -## This file is big, but mostly comments and man page. -## -## See man page for usage info. -## Return value: 2=error, 1=nothing found, 0=something found. -## - -$version = "950918.5"; -## -## "950918.5"; -## Changed all 'sysread' to 'read' because Linux perl's don't seem -## to like sysread() -## -## "941227.4"; -## Added -n, -u -## -## "941222.3" -## Added -nice (due to Lionel Cons <Lionel.Cons@cern.ch>) -## Removed any leading "./" from name. -## Added default flags for ~/.search, including TTY, -nice, -list, etc. -## Program name now has path removed when printed in diagnostics. -## Added simple tilde-expansion to -dir arg. -## Added -dskip, etc. Fixed -iregex bug. -## Changed -dir to be additive, adding -ddir. -## Now screen out devices, pipes, and sockets. -## More tidying and lots of expanding of the man page -## -## -## "941217.2"; -## initial release. - -$stripped=0; - -&init; -$rc_file = join('/', $ENV{'HOME'}, ".search"); - -&check_args; - -## Make sure we've got a regex. -## Don't need one if -find or -showrc was specified. -$!=2, die "expecting regex arguments.\n" - if $FIND_ONLY == 0 && $showrc == 0 && @ARGV == 0; - -&prepare_to_search($rc_file); - -&import_program if !defined &dodir; ## BIG key to speed. - -## do search while there are directories to be done. -&dodir(shift(@todo)) while @todo; - -&clear_message if $VERBOSE && $STDERR_IS_TTY; -exit($retval); -############################################################################### - -sub init -{ - ## initialize variables that might be reset by command-line args - $DOREP=0; ## set true by -dorep (redo multi-hardlink files) - $DO_SORT=0; ## set by -sort (sort files in a dir before checking) - $FIND_ONLY=0; ## set by -find (don't search files) - $LIST_ONLY=0; ## set true by -l (list filenames only) - $NEWER=0; ## set by -newer, "-mtime -###" - $NICE=0; ## set by -nice (print human-readable output) - $NOLINKS=0; ## set true by -nolinks (don't follow symlinks) - $OLDER=0; ## set by -older, "-mtime ###" - $PREPEND_FILENAME=1; ## set false by -h (don't prefix lines with filename) - $REPORT_LINENUM=0; ## set true by -n (show line numbers) - $VERBOSE=0; ## set to a value by -v, -vv, etc. (verbose messages) - $WHY=0; ## set true by -why, -vvv+ (report why skipped) - $XDEV=0; ## set true by -xdev (stay on one filesystem) - $all=0; ## set true by -all (don't skip many kinds of files) - $iflag = ''; ## set to 'i' by -i (ignore case); - $norc=0; ## set by -norc (don't load rc file) - $showrc=0; ## set by -showrc (show what happens with rc file) - $underlineOK=0; ## set true by -u (watch for underline stuff) - $words=0; ## set true by -w (match whole-words only) - $DELAY=0; ## inter-file delay (seconds) - $retval=1; ## will set to 0 if we find anything. - - ## various elements of stat() that we might access - $STAT_DEV = 1; - $STAT_INODE = 2; - $STAT_MTIME = 9; - - $VV_PRINT_COUNT = 50; ## with -vv, print every VV_PRINT_COUNT files, or... - $VV_SIZE = 1024*1024; ## ...every VV_SIZE bytes searched - $vv_print = $vv_size = 0; ## running totals. - - ## set default options, in case the rc file wants them - $opt{'TTY'}= 1 if -t STDOUT; - - ## want to know this for debugging message stuff - $STDERR_IS_TTY = -t STDERR ? 1 : 0; - $STDERR_SCREWS_STDOUT = ($STDERR_IS_TTY && -t STDOUT) ? 1 : 0; - - $0 =~ s,.*/,,; ## clean up $0 for any diagnostics we'll be printing. -} - -## -## Check arguments. -## -sub check_args -{ - while (@ARGV && $ARGV[0] =~ m/^-/) - { - $arg = shift(@ARGV); - - if ($arg eq '-version' || ($VERBOSE && $arg eq '-help')) { - print qq/Jeffrey's file search, version "$version".\n/; - exit(0) unless $arg eq '-help'; - } - if ($arg eq '-help') { - print <<INLINE_LITERAL_TEXT; -usage: $0 [options] [-e] [PerlRegex ....] -OPTIONS TELLING *WHERE* TO SEARCH: - -dir DIR start search at the named directory (default is current dir). - -xdev stay on starting file system. - -sort sort the files in each directory before processing. - -nolinks don't follow symbolic links. -OPTIONS TELLING WHICH FILES TO EVEN CONSIDER: - -mtime # consider files modified > # days ago (-# for < # days old) - -newer FILE consider files modified more recently than FILE (also -older) - -name GLOB consider files whose name matches pattern (also -regex). - -skip GLOB opposite of -name: identifies files to not consider. - -path GLOB like -name, but for files whose whole path is described. - -dpath/-dregex/-dskip versions for selecting or pruning directories. - -all don't skip any files marked to be skipped by the startup file. - -x<SPECIAL> (see manual, and/or try -showrc). - -why report why a file isn't checked (also implied by -vvvv). -OPTIONS TELLING WHAT TO DO WITH FILES THAT WILL BE CONSIDERED: - -f | -find just list files (PerlRegex ignored). Default is to grep them. - -ff | -ffind Does a faster -find (implies -find -all -dorep) -OPTIONS CONTROLLING HOW THE SEARCH IS DONE (AND WHAT IS PRINTED): - -l | -list only list files with matches, not the lines themselves. - -nice | -nnice print more "human readable" output. - -n prefix each output line with its line number in the file. - -h don't prefix output lines with file name. - -u also look "inside" manpage-style underlined text - -i do case-insensitive searching. - -w match words only (as defined by perl's \\b). -OTHER OPTIONS: - -v, -vv, -vvv various levels of message verbosity. - -e end of options (in case a regex looks like an option). - -showrc show what the rc file sets, then exit. - -norc don't load the rc file. - -dorep check files with multiple hard links multiple times. -INLINE_LITERAL_TEXT - print "Use -v -help for more verbose help.\n" unless $VERBOSE; - print "This script file is also a man page.\n" unless $stripped; - print <<INLINE_LITERAL_TEXT if $VERBOSE; - -If -f (or -find) given, PerlRegex is optional and ignored. -Otherwise, will search for files with lines matching any of the given regexes. - -Combining things like -name and -mtime implies boolean AND. -However, duplicating things (such as -name '*.c' -name '*.txt') implies OR. - --mtime may be given floating point (i.e. 1.5 is a day and a half). --iskip/-idskip/-ipath/... etc are case-insensitive versions. - -If any letter in -newer/-older is upper case, "or equal" is -inserted into the test. - -You can always find the latest version on the World Wide Web in - http://www.wg.omron.co.jp/~jfriedl/perl/ -INLINE_LITERAL_TEXT - exit(0); - } - $DOREP=1, next if $arg eq '-dorep'; ## do repeats - $DO_SORT=1, next if $arg eq '-sort'; ## sort files - $NOLINKS=1, next if $arg eq '-nolinks'; ## no sym. links - $PREPEND_FILENAME=0, next if $arg eq '-h'; ## no filename prefix - $REPORT_LINENUM=1, next if $arg eq '-n'; ## show line numbers - $WHY=1, next if $arg eq '-why'; ## tell why skipped - $XDEV=1, next if $arg eq '-xdev'; ## don't leave F.S. - $all=1,$opt{'-all'}=1,next if $arg eq '-all'; ## don't skip *.Z, etc - $iflag='i', next if $arg eq '-i'; ## ignore case - $norc=1, next if $arg eq '-norc'; ## don't load rc file - $showrc=1, next if $arg eq '-showrc'; ## show rc file - $underlineOK=1, next if $arg eq '-u'; ## look throuh underln. - $words=1, next if $arg eq '-w'; ## match "words" only - &strip if $arg eq '-strip'; ## dump this program - last if $arg eq '-e'; - $DELAY=$1, next if $arg =~ m/-delay(\d+)/; - - $FIND_ONLY=1, next if $arg =~/^-f(ind)?$/;## do "find" only - - $FIND_ONLY=1, $DOREP=1, $all=1, - next if $arg =~/^-ff(ind)?$/;## fast -find - $LIST_ONLY=1,$opt{'-list'}=1, - next if $arg =~/^-l(ist)?$/;## only list files - - if ($arg =~ m/^-(v+)$/) { ## verbosity - $VERBOSE =length($1); - foreach $len (1..$VERBOSE) { $opt{'-'.('v' x $len)}=1 } - next; - } - if ($arg =~ m/^-(n+)ice$/) { ## "nice" output - $NICE =length($1); - foreach $len (1..$NICE) { $opt{'-'.('n' x $len).'ice'}=1 } - next; - } - - if ($arg =~ m/^-(i?)(d?)skip$/) { - local($i) = $1 eq 'i'; - local($d) = $2 eq 'd'; - $! = 2, die qq/$0: expecting glob arg to -$arg\n/ unless @ARGV; - foreach (split(/\s+/, shift @ARGV)) { - if ($d) { - $idskip{$_}=1 if $i; - $dskip{$_}=1; - } else { - $iskip{$_}=1 if $i; - $skip{$_}=1; - } - } - next; - } - - - if ($arg =~ m/^-(i?)(d?)(regex|path|name)$/) { - local($i) = $1 eq 'i'; - $! = 2, die qq/$0: expecting arg to -$arg\n/ unless @ARGV; - foreach (split(/\s+/, shift @ARGV)) { - $iname{join(',', $arg, $_)}=1 if $i; - $name{join(',', $arg, $_)}=1; - } - next; - } - - if ($arg =~ m/^-d?dir$/) { - $opt{'-dir'}=1; - $! = 2, die qq/$0: expecting filename arg to -$arg\n/ unless @ARGV; - $start = shift(@ARGV); - $start =~ s#^~(/+|$)#$ENV{'HOME'}$1# if defined $ENV{'HOME'}; - $! = 2, die qq/$0: can't find ${arg}'s "$start"\n/ unless -e $start; - $! = 2, die qq/$0: ${arg}'s "$start" not a directory.\n/ unless -d _; - undef(@todo), $opt{'-ddir'}=1 if $arg eq '-ddir'; - push(@todo, $start); - next; - } - - if ($arg =~ m/^-(new|old)er$/i) { - $! = 2, die "$0: expecting filename arg to -$arg\n" unless @ARGV; - local($file, $time) = shift(@ARGV); - $! = 2, die qq/$0: can't stat -${arg}'s "$file"./ - unless $time = (stat($file))[$STAT_MTIME]; - local($upper) = $arg =~ tr/A-Z//; - if ($arg =~ m/new/i) { - $time++ unless $upper; - $NEWER = $time if $NEWER < $time; - } else { - $time-- unless $upper; - $OLDER = $time if $OLDER == 0 || $OLDER > $time; - } - next; - } - - if ($arg =~ m/-mtime/) { - $! = 2, die "$0: expecting numerical arg to -$arg\n" unless @ARGV; - local($days) = shift(@ARGV); - $! = 2, die qq/$0: inappropriate arg ($days) to $arg\n/ if $days==0; - $days *= 3600 * 24; - if ($days < 0) { - local($time) = $^T + $days; - $NEWER = $time if $NEWER < $time; - } else { - local($time) = $^T - $days; - $OLDER = $time if $OLDER == 0 || $OLDER > $time; - } - next; - } - - ## special user options - if ($arg =~ m/^-x(.+)/) { - foreach (split(/[\s,]+/, $1)) { $user_opt{$_} = $opt{$_}= 1; } - next; - } - - $! = 2, die "$0: unknown arg [$arg]\n"; - } -} - -## -## Given a filename glob, return a regex. -## If the glob has no globbing chars (no * ? or [..]), then -## prepend an effective '*' to it. -## -sub glob_to_regex -{ - local($glob) = @_; - local(@parts) = $glob =~ m/\\.|[*?]|\[]?[^]]*]|[^[\\*?]+/g; - local($trueglob)=0; - foreach (@parts) { - if ($_ eq '*' || $_ eq '?') { - $_ = ".$_"; - $trueglob=1; ## * and ? are a real glob - } elsif (substr($_, 0, 1) eq '[') { - $trueglob=1; ## [..] is a real glob - } else { - s/^\\//; ## remove any leading backslash; - s/\W/\\$&/g; ## now quote anything dangerous; - } - } - unshift(@parts, '.*') unless $trueglob; - join('', '^', @parts, '$'); -} - -sub prepare_to_search -{ - local($rc_file) = @_; - - $HEADER_BYTES=0; ## Might be set nonzero in &read_rc; - $last_message_length = 0; ## For &message and &clear_message. - - &read_rc($rc_file, $showrc) unless $norc; - exit(0) if $showrc; - - $NEXT_DIR_ENTRY = $DO_SORT ? 'shift @files' : 'readdir(DIR)'; - $WHY = 1 if $VERBOSE > 3; ## Arg -vvvv or above implies -why. - @todo = ('.') if @todo == 0; ## Where we'll start looking - - ## see if any user options were specified that weren't accounted for - foreach $opt (keys %user_opt) { - next if defined $seen_opt{$opt}; - warn "warning: -x$opt never considered.\n"; - } - - die "$0: multiple time constraints exclude all possible files.\n" - if ($NEWER && $OLDER) && ($NEWER > $OLDER); - - ## - ## Process any -skip/-iskip args that had been given - ## - local(@skip_test); - foreach $glob (keys %skip) { - $i = defined($iskip{$glob}) ? 'i': ''; - push(@skip_test, '$name =~ m/'. &glob_to_regex($glob). "/$i"); - } - if (@skip_test) { - $SKIP_TEST = join('||',@skip_test); - $DO_SKIP_TEST = 1; - } else { - $DO_SKIP_TEST = $SKIP_TEST = 0; - } - - ## - ## Process any -dskip/-idskip args that had been given - ## - local(@dskip_test); - foreach $glob (keys %dskip) { - $i = defined($idskip{$glob}) ? 'i': ''; - push(@dskip_test, '$name =~ m/'. &glob_to_regex($glob). "/$i"); - } - if (@dskip_test) { - $DSKIP_TEST = join('||',@dskip_test); - $DO_DSKIP_TEST = 1; - } else { - $DO_DSKIP_TEST = $DSKIP_TEST = 0; - } - - - ## - ## Process any -name, -path, -regex, etc. args that had been given. - ## - undef @name_test; - undef @dname_test; - foreach $key (keys %name) { - local($type, $pat) = split(/,/, $key, 2); - local($i) = defined($iname{$key}) ? 'i' : ''; - if ($type =~ /regex/) { - $pat =~ s/!/\\!/g; - $test = "\$name =~ m!^$pat\$!$i"; - } else { - local($var) = $type eq 'name' ? '$name' : '$file'; - $test = "$var =~ m/". &glob_to_regex($pat). "/$i"; - } - if ($type =~ m/^-i?d/) { - push(@dname_test, $test); - } else { - push(@name_test, $test); - } - } - if (@name_test) { - $GLOB_TESTS = join('||', @name_test); - - $DO_GLOB_TESTS = 1; - } else { - $GLOB_TESTS = $DO_GLOB_TESTS = 0; - } - if (@dname_test) { - $DGLOB_TESTS = join('||', @dname_test); - $DO_DGLOB_TESTS = 1; - } else { - $DGLOB_TESTS = $DO_DGLOB_TESTS = 0; - } - - - ## - ## Process any 'magic' things from the startup file. - ## - if (@magic_tests && $HEADER_BYTES) { - ## the $magic' one is for when &dodir is not inlined - $tests = join('||',@magic_tests); - $MAGIC_TESTS = " { package magic; \$val = ($tests) }"; - $DO_MAGIC_TESTS = 1; - } else { - $MAGIC_TESTS = 1; - $DO_MAGIC_TESTS = 0; - } - - ## - ## Prepare regular expressions. - ## - { - local(@regex_tests); - - if ($LIST_ONLY) { - $mflag = ''; - ## need to have $* set, but perl5 just won''t shut up about it. - if ($] >= 5) { - $mflag = 'm'; - } else { - eval ' $* = 1 '; - } - } - - ## - ## Until I figure out a better way to deal with it, - ## We have to worry about a regex like [^xyz] when doing $LIST_ONLY. - ## Such a regex *will* match \n, and if I'm pulling in multiple - ## lines, it can allow lines to match that would otherwise not match. - ## - ## Therefore, if there is a '[^' in a regex, we can NOT take a chance - ## an use the fast listonly. - ## - $CAN_USE_FAST_LISTONLY = $LIST_ONLY; - - local(@extra); - local($underline_glue) = ($] >= 5) ? '(:?_\cH)?' : '(_\cH)?'; - while (@ARGV) { - $regex = shift(@ARGV); - ## - ## If watching for underlined things too, add another regex. - ## - if ($underlineOK) { - if ($regex =~ m/[?*+{}()\\.|^\$[]/) { - warn "$0: warning, can't underline-safe ``$regex''.\n"; - } else { - $regex = join($underline_glue, split(//, $regex)); - } - } - - ## If nothing special in the regex, just use index... - ## is quite a bit faster. - if (($iflag eq '') && ($words == 0) && - $regex !~ m/[?*+{}()\\.|^\$[]/) - { - push(@regex_tests, "(index(\$_, q+$regex+)>=0)"); - - } else { - $regex =~ s#[\$\@\/]\w#\\$&#; - if ($words) { - if ($regex =~ m/\|/) { - ## could be dangerous -- see if we can wrap in parens. - if ($regex =~ m/\\\d/) { - warn "warning: -w and a | in a regex is dangerous.\n" - } else { - $regex = join($regex, '(', ')'); - } - } - $regex = join($regex, '\b', '\b'); - } - $CAN_USE_FAST_LISTONLY = 0 if substr($regex, "[^") >= 0; - push(@regex_tests, "m/$regex/$iflag$mflag"); - } - - ## If we're done, but still have @extra to do, get set for that. - if (@ARGV == 0 && @extra) { - @ARGV = @extra; ## now deal with the extra stuff. - $underlineOK = 0; ## but no more of this. - undef @extra; ## or this. - } - } - if (@regex_tests) { - $REGEX_TEST = join('||', @regex_tests); - ## print STDERR $REGEX_TEST, "\n"; exit; - } else { - ## must be doing -find -- just give something syntactically correct. - $REGEX_TEST = 1; - } - } - - ## - ## Make sure we can read the first item(s). - ## - foreach $start (@todo) { - $! = 2, die qq/$0: can't stat "$start"\n/ - unless ($dev,$inode) = (stat($start))[$STAT_DEV,$STAT_INODE]; - - if (defined $dir_done{"$dev,$inode"}) { - ## ignore the repeat. - warn(qq/ignoring "$start" (same as "$dir_done{"$dev,$inode"}").\n/) - if $VERBOSE; - next; - } - - ## if -xdev was given, remember the device. - $xdev{$dev} = 1 if $XDEV; - - ## Note that we won't want to do it again - $dir_done{"$dev,$inode"} = $start; - } -} - - -## -## See the comment above the __END__ above the 'sub dodir' below. -## -sub import_program -{ - sub bad { - print STDERR "$0: internal error (@_)\n"; - exit 2; - } - - ## Read from data, up to next __END__. This will be &dodir. - local($/) = "\n__END__"; - $prog = <DATA>; - close(DATA); - - $prog =~ s/\beval\b//g; ## remove any 'eval' - - ## Inline uppercase $-variables by their current values. - if ($] >= 5) { - $prog =~ s/\$([A-Z][A-Z0-9_]{2,}\b)/ - &bad($1) if !defined ${$main::{$1}}; ${$main::{$1}};/eg; - } else { - $prog =~ s/\$([A-Z][A-Z0-9_]{2,}\b)/local(*VAR) = $_main{$1}; - &bad($1) if !defined $VAR; $VAR;/eg; - } - - eval $prog; ## now do it. This will define &dodir; - $!=2, die "$0 internal error: $@\n" if $@; -} - -########################################################################### - -## -## Read the .search file: -## Blank lines and lines that are only #-comments ignored. -## Newlines may be escaped to create long lines -## Other lines are directives. -## -## A directive may begin with an optional tag in the form <...> -## Things inside the <...> are evaluated as with: -## <(this || that) && must> -## will be true if -## -xmust -xthis or -xmust -xthat -## were specified on the command line (order doesn't matter, though) -## A directive is not done if there is a tag and it's false. -## Any characters but whitespace and &|()>,! may appear after an -x -## (although "-xdev" is special). -xmust,this is the same as -xmust -xthis. -## Something like -x~ would make <~> true, and <!~> false. -## -## Directives are in the form: -## option: STRING -## magic : NUMBYTES : EXPR -## -## With option: -## The STRING is parsed like a Bourne shell command line, and the -## options are used as if given on the command line. -## No comments are allowed on 'option' lines. -## Examples: -## # skip objects and libraries -## option: -skip '.o .a' -## # skip emacs *~ and *# files, unless -x~ given: -## <!~> option: -skip '~ #' -## -## With magic: -## EXPR can be pretty much any perl (comments allowed!). -## If it evaluates to true for any particular file, it is skipped. -## The only info you'll have about a file is the variable $H, which -## will have at least the first NUMBYTES of the file (less if the file -## is shorter than that, of course, and maybe more). You'll also have -## any variables you set in previous 'magic' lines. -## Examples: -## magic: 6 : ($x6 = substr($H, 0, 6)) eq 'GIF87a' -## magic: 6 : $x6 eq 'GIF89a' -## -## magic: 6 : (($x6 = substr($H, 0, 6)) eq 'GIF87a' ## old gif \ -## || $x6 eq 'GIF89a' ## new gif -## (the above two sets are the same) -## ## Check the first 32 bytes for "binarish" looking bytes. -## ## Don't blindly dump on any high-bit set, as non-ASCII text -## ## often has them set. \x80 and \xff seem to be special, though. -## ## Require two in a row to not get things like perl's $^T. -## ## This is known to get *.Z, *.gz, pkzip, *.elc and about any -## ## executable you'll find. -## magic: 32 : $H =~ m/[\x00-\x06\x10-\x1a\x1c-\x1f\x80\xff]{2}/ -## -sub read_rc -{ - local($file, $show) = @_; - local($line_num, $ln, $tag) = 0; - local($use_default, @default) = 0; - - { package magic; $ = 0; } ## turn off warnings for when we run EXPR's - - unless (open(RC, "$file")) { - $use_default=1; - $file = "<internal default startup file>"; - ## no RC file -- use this default. - @default = split(/\n/,<<'--------INLINE_LITERAL_TEXT'); - magic: 32 : $H =~ m/[\x00-\x06\x10-\x1a\x1c-\x1f\x80\xff]{2}/ - option: -skip '.a .COM .elc .EXE .gz .o .pbm .xbm .dvi' - option: -iskip '.tarz .zip .z .lzh .jpg .jpeg .gif .uu' - <!~> option: -skip '~ #' ---------INLINE_LITERAL_TEXT - } - - ## - ## Make an eval error pretty. - ## - sub clean_eval_error { - local($_) = @_; - s/ in file \(eval\) at line \d+,//g; ## perl4-style error - s/ at \(eval \d+\) line \d+,//g; ## perl5-style error - $_ = $` if m/\n/; ## remove all but first line - "$_\n"; - } - - print "reading RC file: $file\n" if $show; - - while (defined($_ = ($use_default ? shift(@default) : <RC>))) { - $ln = ++$line_num; ## note starting line num. - $_ .= <RC>, $line_num++ while s/\\\n?$/\n/; ## allow continuations - next if /^\s*(#.*)?$/; ## skip blank or comment-only lines. - $do = ''; - - ## look for an initial <...> tag. - if (s/^\s*<([^>]*)>//) { - ## This simple s// will make the tag ready to eval. - ($tag = $msg = $1) =~ - s/[^\s&|(!)]+/ - $seen_opt{$&}=1; ## note seen option - "defined(\$opt{q>$&>})" ## (q>> is safe quoting here) - /eg; - - ## see if the tag is true or not, abort this line if not. - $dothis = (eval $tag); - $!=2, die "$file $ln <$msg>: $_".&clean_eval_error($@) if $@; - - if ($show) { - $msg =~ s/[^\s&|(!)]+/-x$&/; - $msg =~ s/\s*!\s*/ no /g; - $msg =~ s/\s*&&\s*/ and /g; - $msg =~ s/\s*\|\|\s*/ or /g; - $msg =~ s/^\s+//; $msg =~ s/\s+$//; - $do = $dothis ? "(doing because $msg)" : - "(do if $msg)"; - } elsif (!$dothis) { - next; - } - } - - if (m/^\s*option\s*:\s*/) { - next if $all && !$show; ## -all turns off these checks; - local($_) = $'; - s/\n$//; - local($orig) = $_; - print " $do option: $_\n" if $show; - local($0) = "$0 ($file)"; ## for any error message. - local(@ARGV); - local($this); - ## - ## Parse $_ as a Bourne shell line -- fill @ARGV - ## - while (length) { - if (s/^\s+//) { - push(@ARGV, $this) if defined $this; - undef $this; - next; - } - $this = '' if !defined $this; - $this .= $1 while s/^'([^']*)'// || - s/^"([^"]*)"// || - s/^([^'"\s\\]+)//|| - s/^(\\[\D\d])//; - die "$file $ln: error parsing $orig at $_\n" if m/^\S/; - } - push(@ARGV, $this) if defined $this; - &check_args; - die qq/$file $ln: unused arg "@ARGV".\n/ if @ARGV; - next; - } - - if (m/^\s*magic\s*:\s*(\d+)\s*:\s*/) { - next if $all && !$show; ## -all turns off these checks; - local($bytes, $check) = ($1, $'); - - if ($show) { - $check =~ s/\n?$/\n/; - print " $do contents: $check"; - } - ## Check to make sure the thing at least compiles. - eval "package magic; (\$H = '1'x \$main'bytes) && (\n$check\n)\n"; - $! = 2, die "$file $ln: ".&clean_eval_error($@) if $@; - - $HEADER_BYTES = $bytes if $bytes > $HEADER_BYTES; - push(@magic_tests, "(\n$check\n)"); - next; - } - $! = 2, die "$file $ln: unknown command\n"; - } - close(RC); -} - -sub message -{ - if (!$STDERR_IS_TTY) { - print STDERR $_[0], "\n"; - } else { - local($text) = @_; - $thislength = length($text); - if ($thislength >= $last_message_length) { - print STDERR $text, "\r"; - } else { - print STDERR $text, ' 'x ($last_message_length-$thislength),"\r"; - } - $last_message_length = $thislength; - } -} - -sub clear_message -{ - print STDERR ' ' x $last_message_length, "\r" if $last_message_length; - $vv_print = $vv_size = $last_message_length = 0; -} - -## -## Output a copy of this program with comments, extra whitespace, and -## the trailing man page removed. On an ultra slow machine, such a copy -## might load faster (but I can't tell any difference on my machine). -## -sub strip { - seek(DATA, 0, 0) || die "$0: can't reset internal pointer.\n"; - while(<DATA>) { - print, next if /INLINE_LITERAL_TEXT/.../INLINE_LITERAL_TEXT/; - ## must mention INLINE_LITERAL_TEXT on this line! - s/\#\#.*|^\s+|\s+$//; ## remove cruft - last if $_ eq '.00;'; - next if ($_ eq '') || ($_ eq "'di'") || ($_ eq "'ig00'"); - s/\$stripped=0;/\$stripped=1;/; - s/\s\s+/ /; ## squish multiple whitespaces down to one. - print $_, "\n"; - } - exit(0); -} - -## -## Just to shut up -w. Never executed. -## -sub dummy { - - 1 || &dummy || &dir_done || &bad || &message || $NEXT_DIR_ENTRY || - $DELAY || $VV_SIZE || $VV_PRINT_COUNT || $STDERR_SCREWS_STDOUT || - @files || @files || $magic'H || $magic'H || $xdev{''} || &clear_message; - -} - -## -## If the following __END__ is in place, what follows will be -## inlined when the program first starts up. Any $ variable name -## all in upper case, specifically, any string matching -## \$([A-Z][A-Z0-9_]{2,}\b -## will have the true value for that variable inlined. Also, any 'eval' is -## removed -## -## The idea is that when the whole thing is then eval'ed to define &dodir, -## the perl optimizer will make all the decisions that are based upon -## command-line options (such as $VERBOSE), since they'll be inlined as -## constants -## -## Also, and here's the big win, the tests for matching the regex, and a -## few others, are all inlined. Should be blinding speed here. -## -## See the read from <DATA> above for where all this takes place. -## But all-in-all, you *want* the __END__ here. Comment it out only for -## debugging.... -## - -__END__ - -## -## Given a directory, check all "appropriate" files in it. -## Shove any subdirectories into the global @todo, so they'll be done -## later. -## -## Be careful about adding any upper-case variables, as they are subject -## to being inlined. See comments above the __END__ above. -## -sub dodir -{ - local($dir) = @_; - $dir =~ s,/+$,,; ## remove any trailing slash. - unless (opendir(DIR, "$dir/.")) { - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - warn qq($0: can't opendir "$dir/".\n); - return; - } - - if ($VERBOSE) { - &message($dir); - $vv_print = $vv_size = 0; - } - - @files = sort readdir(DIR) if $DO_SORT; - - while (defined($name = eval $NEXT_DIR_ENTRY)) - { - next if $name eq '.' || $name eq '..'; ## never follow these. - - ## create full relative pathname. - $file = $dir eq '.' ? $name : "$dir/$name"; - - ## if link and skipping them, do so. - if ($NOLINKS && -l $file) { - warn qq/skip (symlink): $file\n/ if $WHY; - next; - } - - ## skip things unless files or directories - unless (-f $file || -d _) { - if ($WHY) { - $why = (-S _ && "socket") || - (-p _ && "pipe") || - (-b _ && "block special")|| - (-c _ && "char special") || "somekinda special"; - warn qq/skip ($why): $file\n/; - } - next; - } - - ## skip things we can't read - unless (-r _) { - if ($WHY) { - $why = (-l $file) ? "follow" : "read"; - warn qq/skip (can't $why): $file\n/; - } - next; - } - - ## skip things that are empty - unless (-s _) { - warn qq/skip (empty): $file\n/ if $WHY; - next; - } - - ## Note file device & inode. If -xdev, skip if appropriate. - ($dev, $inode) = (stat(_))[$STAT_DEV, $STAT_INODE]; - if ($XDEV && defined $xdev{$dev}) { - warn qq/skip (other device): $file\n/ if $WHY; - next; - } - $id = "$dev,$inode"; - - ## special work for a directory - if (-d _) { - ## Do checks for directory file endings. - if ($DO_DSKIP_TEST && (eval $DSKIP_TEST)) { - warn qq/skip (-dskip): $file\n/ if $WHY; - next; - } - ## do checks for -name/-regex/-path tests - if ($DO_DGLOB_TESTS && !(eval $DGLOB_TESTS)) { - warn qq/skip (dirname): $file\n/ if $WHY; - next; - } - - ## _never_ redo a directory - if (defined $dir_done{$id}) { - warn qq/skip (did as "$dir_done{$id}"): $file\n/ if $WHY; - next; - } - $dir_done{$id} = $file; ## mark it done. - unshift(@todo, $file); ## add to the list to do. - next; - } - if ($WHY == 0 && $VERBOSE > 1) { - if ($VERBOSE>2||$vv_print++>$VV_PRINT_COUNT||($vv_size+=-s _)>$VV_SIZE){ - &message($file); - $vv_print = $vv_size = 0; - } - } - - ## do time-related tests - if ($NEWER || $OLDER) { - $_ = (stat(_))[$STAT_MTIME]; - if ($NEWER && $_ < $NEWER) { - warn qq/skip (too old): $file\n/ if $WHY; - next; - } - if ($OLDER && $_ > $OLDER) { - warn qq/skip (too new): $file\n/ if $WHY; - next; - } - } - - ## do checks for file endings - if ($DO_SKIP_TEST && (eval $SKIP_TEST)) { - warn qq/skip (-skip): $file\n/ if $WHY; - next; - } - - ## do checks for -name/-regex/-path tests - if ($DO_GLOB_TESTS && !(eval $GLOB_TESTS)) { - warn qq/skip (filename): $file\n/ if $WHY; - next; - } - - - ## If we're not repeating files, - ## skip this one if we've done it, or note we're doing it. - unless ($DOREP) { - if (defined $file_done{$id}) { - warn qq/skip (did as "$file_done{$id}"): $file\n/ if $WHY; - next; - } - $file_done{$id} = $file; - } - - if ($DO_MAGIC_TESTS) { - if (!open(FILE_IN, $file)) { - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - warn qq/$0: can't open: $file\n/; - next; - } - unless (read(FILE_IN, $magic'H, $HEADER_BYTES)) { - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - warn qq/$0: can't read from "$file"\n"/; - close(FILE_IN); - next; - } - - eval $MAGIC_TESTS; - if ($magic'val) { - close(FILE_IN); - warn qq/skip (magic): $file\n/ if $WHY; - next; - } - seek(FILE_IN, 0, 0); ## reset for later <FILE_IN> - } - - if ($WHY != 0 && $VERBOSE > 1) { - if ($VERBOSE>2||$vv_print++>$VV_PRINT_COUNT||($vv_size+=-s _)>$VV_SIZE){ - &message($file); - $vv_print = $vv_size = 0; - } - } - - if ($DELAY) { - sleep($DELAY); - } - - if ($FIND_ONLY) { - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - print $file, "\n"; - $retval=0; ## we've found something - close(FILE_IN) if $DO_MAGIC_TESTS; - next; - } else { - ## if we weren't doing magic tests, file won't be open yet... - if (!$DO_MAGIC_TESTS && !open(FILE_IN, $file)) { - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - warn qq/$0: can't open: $file\n/; - next; - } - if ($LIST_ONLY && $CAN_USE_FAST_LISTONLY) { - ## - ## This is rather complex, but buys us a LOT when we're just - ## listing files and not the individual internal lines. - ## - local($size) = 4096; ## block-size in which to do reads - local($nl); ## will point to $_'s ending newline. - local($read); ## will be how many bytes read. - local($_) = ''; ## Starts out empty - local($hold); ## (see below) - - while (($read = read(FILE_IN,$_,$size,length($_)))||length($_)) - { - undef @parts; - ## if read a full block, but no newline, need to read more. - while ($read == $size && ($nl = rindex($_, "\n")) < 0) { - push(@parts, $_); ## save that part - $read = read(FILE_IN, $_, $size); ## keep trying - } - - ## - ## If we had to save parts, must now combine them together. - ## adjusting $nl to reflect the now-larger $_. This should - ## be a lot more efficient than using any kind of .= in the - ## loop above. - ## - if (@parts) { - local($lastlen) = length($_); #only need if $nl >= 0 - $_ = join('', @parts, $_); - $nl = length($_) - ($lastlen - $nl) if $nl >= 0; - } - - ## - ## If we're at the end of the file, then we can use $_ as - ## is. Otherwise, we need to remove the final partial-line - ## and save it so that it'll be at the beginning of the - ## next read (where the rest of the line will be layed in - ## right after it). $hold will be what we should save - ## until next time. - ## - if ($read != $size || $nl < 0) { - $hold = ''; - } else { - $hold = substr($_, $nl + 1); - substr($_, $nl + 1) = ''; - } - - ## - ## Now have a bunch of full lines in $_. Use it. - ## - if (eval $REGEX_TEST) { - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - print $file, "\n"; - $retval=0; ## we've found something - - last; - } - - ## Prepare for next read.... - $_ = $hold; - } - - } else { ## else not using faster block scanning..... - - $lines_printed = 0 if $NICE; - while (<FILE_IN>) { - study; - next unless (eval $REGEX_TEST); - - ## - ## We found a matching line. - ## - $retval=0; - &clear_message if $VERBOSE && $STDERR_SCREWS_STDOUT; - if ($LIST_ONLY) { - print $file, "\n"; - last; - } else { - ## prepare to print line. - if ($NICE && $lines_printed++ == 0) { - print '-' x 70, "\n" if $NICE > 1; - print $file, ":\n"; - } - - ## - ## Print all the prelim stuff. This looks less efficient - ## than it needs to be, but that's so that when the eval - ## is compiled (and the tests are optimized away), the - ## result will be less actual PRINTs than the more natural - ## way of doing these tests.... - ## - if ($NICE) { - if ($REPORT_LINENUM) { - print " line $.: "; - } else { - print " "; - } - } elsif ($REPORT_LINENUM && $PREPEND_FILENAME) { - print "$file,:$.: "; - } elsif ($PREPEND_FILENAME) { - print "$file: "; - } elsif ($REPORT_LINENUM) { - print "$.: "; - } - print $_; - print "\n" unless m/\n$/; - } - } - print "\n" if ($NICE > 1) && $lines_printed; - } - close(FILE_IN); - } - } - closedir(DIR); -} - -__END__ -.00; ## finish .ig - -'di \" finish diversion--previous line must be blank -.nr nl 0-1 \" fake up transition to first page again -.nr % 0 \" start at page 1 -.\"__________________NORMAL_MAN_PAGE_BELOW_________________ -.ll+10n -.TH search 1 "Dec 17, 1994" -.SH SEARCH -search \- search files (a'la grep) in a whole directory tree. -.SH SYNOPSIS -search [ grep-like and find-like options] [regex ....] -.SH DESCRIPTION -.I Search -is more or less a combo of 'find' and 'grep' (although the regular -expression flavor is that of the perl being used, which is closer to -egrep's than grep's). - -.I Search -does generally the same kind of thing that -.nf - find <blah blah> | xargs egrep <blah blah> -.fi -does, but is -.I much -more powerful and efficient (and intuitive, I think). - -This manual describes -.I search -as of version "941227.4". You can always find the latest version at -.nf - http://www.wg.omron.co.jp/~jfriedl/perl/index.html -.fi - -.SH "QUICK EXAMPLE" -Basic use is simple: -.nf - % search jeff -.fi -will search files in the current directory, and all sub directories, for -files that have "jeff" in them. The lines will be listed with the -containing file's name prepended. -.PP -If you list more than one regex, such as with -.nf - % search jeff Larry Randal+ 'Stoc?k' 'C.*son' -.fi -then a line containing any of the regexes will be listed. -This makes it effectively the same as -.nf - % search 'jeff|Larry|Randal+|Stoc?k|C.*son' -.fi -However, listing them separately is much more efficient (and is easier -to type). -.PP -Note that in the case of these examples, the -.B \-w -(list whole-words only) option would be useful. -.PP -Normally, various kinds of files are automatically removed from consideration. -If it has has a certain ending (such as ".tar", ".Z", ".o", .etc), or if -the beginning of the file looks like a binary, it'll be excluded. -You can control exactly how this works -- see below. One quick way to -override this is to use the -.B \-all -option, which means to consider all the files that would normally be -automatically excluded. -Or, if you're curious, you can use -.B \-why -to have notes about what files are skipped (and why) printed to stderr. - -.SH "BASIC OVERVIEW" -Normally, the search starts in the current directory, considering files in -all subdirectories. - -You can use the -.I ~/.search -file to control ways to automatically exclude files. -If you don't have this file, a default one will kick in, which automatically -add -.nf - -skip .o .Z .gif -.fi -(among others) to exclude those kinds of files (which you probably want to -skip when searching for text, as is normal). -Files that look to be be binary will also be excluded. - -Files ending with "#" and "~" will also be excluded unless the -.B -x~ -option is given. - -You can use -.B -showrc -to show what kinds of files will normally be skipped. -See the section on the startup file -for more info. - -You can use the -.B -all -option to indicate you want to consider all files that would otherwise be -skipped by the startup file. - -Based upon various other flags (see "WHICH FILES TO CONSIDER" below), -more files might be removed from consideration. For example -.nf - -mtime 3 -.fi -will exclude files that aren't at least three days old (change the 3 to -3 -to exclude files that are more than three days old), while -.nf - -skip .* -.fi -would exclude any file beginning with a dot (of course, '.' and '..' are -special and always excluded). - -If you'd like to see what files are being excluded, and why, you can get the -list via the -.B \-why -option. - -If a file makes it past all the checks, it is then "considered". -This usually means it is greped for the regular expressions you gave -on the command line. - -If any of the regexes match a line, the line is printed. -However, if -.B -list -is given, just the filename is printed. Or, if -.B -nice -is given, a somewhat more (human-)readable output is generated. - -If you're searching a huge tree and want to keep informed about how -the search is progressing, -.B -v -will print (to stderr) the current directory being searched. -Using -.B -vv -will also print the current file "every so often", which could be useful -if a directory is huge. Using -.B -vvv -will print the update with every file. - -Below is the full listing of options. - -.SH "OPTIONS TELLING *WHERE* TO SEARCH" -.TP -.BI -dir " DIR" -Start searching at the named directory instead of the current directory. -If multiple -.B -dir -arguments are given, multiple trees will be searched. -.TP -.BI -ddir " DIR" -Like -.B -dir -except it flushes any previous -.B -dir -directories (i.e. "-dir A -dir B -dir C" will search A, B, and C, while -"-dir A -ddir B -dir C" will search only B and C. This might be of use -in the startup file (see that section below). -.TP -.B -xdev -Stay on the same filesystem as the starting directory/directories. -.TP -.B -sort -Sort the items in a directory before processing them. -Normally they are processed in whatever order they happen to be read from -the directory. -.TP -.B -nolinks -Don't follow symbolic links. Normally they're followed. - -.SH "OPTIONS CONTROLLING WHICH FILES TO CONSIDER AND EXCLUDE" -.TP -.BI -mtime " NUM" -Only consider files that were last changed more than -.I NUM -days ago -(less than -.I NUM -days if -.I NUM -has '-' prepended, i.e. "-mtime -2.5" means to consider files that -have been changed in the last two and a half days). -.TP -.B -older FILE -Only consider files that have not changed since -.I FILE -was last changed. -If there is any upper case in the "-older", "or equal" is added to the sense -of the test. Therefore, "search -older ./file regex" will never consider -"./file", while "search -Older ./file regex" will. - -If a file is a symbolic link, the time used is that of the file and not the -link. -.TP -.BI -newer " FILE" -Opposite of -.BR -older . -.TP -.BI -name " GLOB" -Only consider files that match the shell filename pattern -.IR GLOB . -The check is only done on a file's name (use -.B -path -to check the whole path, and use -.B -dname -to check directory names). - -Multiple specifications can be given by separating them with spaces, a'la -.nf - -name '*.c *.h' -.fi -to consider C source and header files. -If -.I GLOB -doesn't contain any special pattern characters, a '*' is prepended. -This last example could have been given as -.nf - -name '.c .h' -.fi -It could also be given as -.nf - -name .c -name .h -.fi -or -.nf - -name '*.c' -name '*.h' -.fi -or -.nf - -name '*.[ch]' -.fi -(among others) -but in this last case, you have to be sure to supply the leading '*'. -.TP -.BI -path " GLOB" -Like -.B -name -except the entire path is checked against the pattern. -.TP -.B -regex " REGEX" -Considers files whose names (not paths) match the given perl regex -exactly. -.TP -.BI -iname " GLOB" -Case-insensitive version of -.BR -name . -.TP -.BI -ipath " GLOB" -Case-insensitive version of -.BR -path . -.TP -.BI -iregex " REGEX" -Case-insensitive version of -.BR -regex . - -.TP -.BI -dpath " GLOB" -Only search down directories whose path matches the given pattern (this -doesn't apply to the initial directory given by -.BI -dir , -of course). -Something like -.nf - -dir /usr/man -dpath /usr/man/man* -.fi -would completely skip -"/usr/man/cat1", "/usr/man/cat2", etc. -.TP -.BI -dskip " GLOB" -Skips directories whose name (not path) matches the given pattern. -Something like -.nf - -dir /usr/man -dskip cat* -.fi -would completely skip any directory in the tree whose name begins with "cat" -(including "/usr/man/cat1", "/usr/man/cat2", etc.). -.TP -.BI -dregex " REGEX" -Like -.BI -dpath , -but the pattern is a full perl regex. Note that this quite different -from -.B -regex -which considers only file names (not paths). This option considers -full directory paths (not just names). It's much more useful this way. -Sorry if it's confusing. -.TP -.BI -dpath " GLOB" -This option exists, but is probably not very useful. It probably wants to -be like the '-below' or something I mention in the "TODO" section. -.TP -.BI -idpath " GLOB" -Case-insensitive version of -.BR -dpath . -.TP -.BI -idskip " GLOB" -Case-insensitive version of -.BR -dskip . -.TP -.BI -idregex " REGEX" -Case-insensitive version of -.BR -dregex . -.TP -.B -all -Ignore any 'magic' or 'option' lines in the startup file. -The effect is that all files that would otherwise be automatically -excluded are considered. -.TP -.BI -x SPECIAL -Arguments starting with -.B -x -(except -.BR -xdev , -explained elsewhere) do special interaction with the -.I ~/.search -startup file. Something like -.nf - -xflag1 -xflag2 -.fi -will turn on "flag1" and "flag2" in the startup file (and is -the same as "-xflag1,flag2"). You can use this to write your own -rules for what kinds of files are to be considered. - -For example, the internal-default startup file contains the line -.nf - <!~> option: -skip '~ #' -.fi -This means that if the -.B -x~ -flag is -.I not -seen, the option -.nf - -skip '~ #' -.fi -should be done. -The effect is that emacs temp and backup files are not normally -considered, but you can included them with the -x~ flag. - -You can write your own rules to customize -.I search -in powerful ways. See the STARTUP FILE section below. -.TP -.B -why -Print a message (to stderr) when and why a file is not considered. - -.SH "OPTIONS TELLING WHAT TO DO WITH FILES THAT WILL BE CONSIDERED" -.TP -.B -find -(you can use -.B -f -as well). -This option changes the basic action of -.IR search . - -Normally, if a file is considered, it is searched -for the regular expressions as described earlier. However, if this option -is given, the filename is printed and no searching takes place. This turns -.I search -into a 'find' of some sorts. - -In this case, no regular expressions are needed on the command line -(any that are there are silently ignored). - -This is not intended to be a replacement for the 'find' program, -but to aid -you in understanding just what files are getting past the exclusion checks. -If you really want to use it as a sort of replacement for the 'find' program, -you might want to use -.B -all -so that it doesn't waste time checking to see if the file is binary, etc -(unless you really want that, of course). - -If you use -.BR -find , -none of the "GREP-LIKE OPTIONS" (below) matter. - -As a replacement for 'find', -.I search -is probably a bit slower (or in the case of GNU find, a lot slower -- -GNU find is -.I unbelievably -fast). -However, "search -ffind" -might be more useful than 'find' when options such as -.B -skip -are used (at least until 'find' gets such functionality). -.TP -.B -ffind -(or -.BR -ff ) -A faster more 'find'-like find. Does -.nf - -find -all -dorep -.fi -.SH "GREP-LIKE OPTIONS" -These options control how a searched file is accessed, -and how things are printed. -.TP -.B -i -Ignore letter case when matching. -.TP -.B -w -Consider only whole-word matches ("whole word" as defined by perl's "\\b" -regex). -.TP -.B -u -If the regex(es) is/are simple, try to modify them so that they'll work -in manpage-like underlined text (i.e. like _^Ht_^Hh_^Hi_^Hs). -This is very rudimentary at the moment. -.TP -.B -list -(you can use -.B -l -too). -Don't print matching lines, but the names of files that contain matching -lines. This will likely be *much* faster, as special optimizations are -made -- particularly with large files. -.TP -.B -n -Pepfix each line by its line number. -.TP -.B -nice -Not a grep-like option, but similar to -.BR -list , -so included here. -.B -nice -will have the output be a bit more human-readable, with matching lines printed -slightly indented after the filename, a'la -.nf - - % search foo - somedir/somefile: line with foo in it - somedir/somefile: some food for thought - anotherdir/x: don't be a buffoon! - % - -.fi -will become -.nf - - % search -nice foo - somedir/somefile: - line with foo in it - some food for thought - anotherdir/x: - don't be a buffoon! - % - -.fi -This option due to Lionel Cons. -.TP -.B -nnice -Be a bit nicer than -.BR -nice . -Prefix each file's output by a rule line, and follow with an extra blank line. -.TP -.B -h -Don't prepend each output line with the name of the file -(meaningless when -.B -find -or -.B -l -are given). - -.SH "OTHER OPTIONS" -.TP -.B -help -Print the usage information. -.TP -.B -version -Print the version information and quit. -.TP -.B -v -Set the level of message verbosity. -.B -v -will print a note whenever a new directory is entered. -.B -vv -will also print a note "every so often". This can be useful to see -what's happening when searching huge directories. -.B -vvv -will print a new with every file. -.B -vvvv -is --vvv -plus -.BR -why . -.TP -.B -e -This ends the options, and can be useful if the regex begins with '-'. -.TP -.B -showrc -Shows what is being considered in the startup file, then exits. -.TP -.B -dorep -Normally, an identical file won't be checked twice (even with multiple -hard or symbolic links). If you're just trying to do a fast -.BR -find , -the bookkeeping to remember which files have been seen is not desirable, -so you can eliminate the bookkeeping with this flag. - -.SH "STARTUP FILE" -When -.I search -starts up, it processes the directives in -.IR ~/.search . -If no such file exists, a default -internal version is used. - -The internal version looks like: -.nf - - magic: 32 : $H =~ m/[\ex00-\ex06\ex10-\ex1a\ex1c-\ex1f\ex80\exff]{2}/ - option: -skip '.a .COM .elc .EXE .gz .o .pbm .xbm .dvi' - option: -iskip '.tarz .zip .z .lzh .jpg .jpeg .gif .uu' - <!~> option: -skip '~ #' - -.fi -If you wish to create your own "~/.search", -you might consider copying the above, and then working from there. - -There are two kinds of directives in a startup file: "magic" and "option". -.RS 0n -.TP -OPTION -Option lines will automatically do the command-line options given. -For example, the line -.nf - option: -v -.fi -in you startup file will turn on -v every time, without needing to type it -on the command line. - -The text on the line after the "option:" directive is processed -like the Bourne shell, so make sure to pay attention to quoting. -.nf - option: -skip .exe .com -.fi -will give an error (".com" by itself isn't a valid option), while -.nf - option: -skip ".exe .com" -.fi -will properly include it as part of -skip's argument. - -.TP -MAGIC -Magic lines are used to determine if a file should be considered a binary -or not (the term "magic" refers to checking a file's magic number). These -are described in more detail below. -.RE - -Blank lines and comments (lines beginning with '#') are allowed. - -If a line begins with <...>, then it's a check to see if the -directive on the line should be done or not. The stuff inside the <...> -can contain perl's && (and), || (or), ! (not), and parens for grouping, -along with "flags" that might be indicated by the user with -.BI -x flag -options. - -For example, using "-xfoo" will cause "foo" to be true inside the <...> -blocks. Therefore, a line beginning with "<foo>" would be done only when -"-xfoo" had been specified, while a line beginning with "<!foo>" would be -done only when "-xfoo" is not specified (of course, a line without any <...> -is done in either case). - -A realistic example might be -.nf - <!v> -vv -.fi -This will cause -vv messages to be the default, but allow "-xv" to override. - -There are a few flags that are set automatically: -.RS -.TP -.B TTY -true if the output is to the screen (as opposed to being redirected to a file). -You can force this (as with all the other automatic flags) with -xTTY. -.TP -.B -v -True if -v was specified. If -vv was specified, both -.B -v -and -.B -vv -flags are true (and so on). -.TP -.B -nice -True if -nice was specified. Same thing about -nnice as for -vv. -.PP -.TP -.B -list -true if -list (or -l) was given. -.TP -.B -dir -true if -dir was given. -.RE - -Using this info, you might change the last example to -.nf - - <!v && !-v> option: -vv - -.fi -The added "&& !-v" means "and if the '-v' option not given". -This will allow you to use "-v" alone on the command line, and not -have this directive add the more verbose "-vv" automatically. - -.RS 0 -Some other examples: -.TP -<!-dir && !here> option: -dir ~/ -Effectively make the default directory your home directory (instead of the -current directory). Using -dir or -xhere will undo this. -.TP -<tex> option: -name .tex -dir ~/pub -Create '-xtex' to search only "*.tex" files in your ~/pub directory tree. -Actually, this could be made a bit better. If you combine '-xtex' and '-dir' -on the command line, this directive will add ~/pub to the list, when you -probably want to use the -dir directory only. You could do -.nf - - <tex> option: -name .tex - <tex && !-dir> option: -dir ~/pub -.fi - -to will allow '-xtex' to work as before, but allow a command-line "-dir" -to take precedence with respect to ~/pub. -.TP -<fluff> option: -nnice -sort -i -vvv -Combine a few user-friendly options into one '-xfluff' option. -.TP -<man> option: -ddir /usr/man -v -w -When the '-xman' option is given, search "/usr/man" for whole-words -(of whatever regex or regexes are given on the command line), with -v. -.RE - -The lines in the startup file are executed from top to bottom, so something -like -.nf - - <both> option: -xflag1 -xflag2 - <flag1> option: ...whatever... - <flag2> option: ...whatever... - -.fi -will allow '-xboth' to be the same as '-xflag1 -xflag2' (or '-xflag1,flag2' -for that matter). However, if you put the "<both>" line below the others, -they will not be true when encountered, so the result would be different -(and probably undesired). - -The "magic" directives are used to determine if a file looks to be binary -or not. The form of a magic line is -.nf - magic: \fISIZE\fP : \fIPERLCODE\fP -.fi -where -.I SIZE -is the number of bytes of the file you need to check, and -.I PERLCODE -is the code to do the check. Within -.IR PERLCODE , -the variable $H will hold at least the first -.I SIZE -bytes of the file (unless the file is shorter than that, of course). -It might hold more bytes. The perl should evaluate to true if the file -should be considered a binary. - -An example might be -.nf - magic: 6 : substr($H, 0, 6) eq 'GIF87a' -.fi -to test for a GIF ("-iskip .gif" is better, but this might be useful -if you have images in files without the ".gif" extension). - -Since the startup file is checked from top to bottom, you can be a bit -efficient: -.nf - magic: 6 : ($x6 = substr($H, 0, 6)) eq 'GIF87a' - magic: 6 : $x6 eq 'GIF89a' -.fi -You could also write the same thing as -.nf - magic: 6 : (($x6 = substr($H, 0, 6)) eq 'GIF87a') || ## an old gif, or.. \e - $x6 eq 'GIF89a' ## .. a new one. -.fi -since newlines may be escaped. - -The default internal startup file includes -.nf - magic: 32 : $H =~ m/[\ex00-\ex06\ex10-\ex1a\ex1c-\ex1f\ex80\exff]{2}/ -.fi -which checks for certain non-printable characters, and catches a large -number of binary files, including most system's executables, linkable -objects, compressed, tarred, and otherwise folded, spindled, and mutilated -files. - -Another example might be -.nf - ## an archive library - magic: 17 : substr($H, 0, 17) eq "!<arch>\en__.SYMDEF" -.fi - -.SH "RETURN VALUE" -.I Search -returns zero if lines (or files, if appropriate) were found, -or if no work was requested (such as with -.BR -help ). -Returns 1 if no lines (or files) were found. -Returns 2 on error. - -.SH TODO -Things I'd like to add some day: -.nf - + show surrounding lines (context). - + highlight matched portions of lines. - + add '-and', which can go between regexes to override - the default logical or of the regexes. - + add something like - -below GLOB - which will examine a tree and only consider files that - lie in a directory deeper than one named by the pattern. - + add 'warning' and 'error' directives. - + add 'help' directive. -.fi -.SH BUGS -If -xdev and multiple -dir arguments are given, any file in any of the -target filesystems are allowed. It would be better to allow each filesystem -for each separate tree. - -Multiple -dir args might also cause some confusing effects. Doing -.nf - -dir some/dir -dir other -.fi -will search "some/dir" completely, then search "other" completely. This -is good. However, something like -.nf - -dir some/dir -dir some/dir/more/specific -.fi -will search "some/dir" completely *except for* "some/dir/more/specific", -after which it will return and be searched. Not really a bug, but just sort -of odd. - -File times (for -newer, etc.) of symbolic links are for the file, not the -link. This could cause some misunderstandings. - -Probably more. Please let me know. -.SH AUTHOR -Jeffrey Friedl, Omron Corp (jfriedl@omron.co.jp) -.br -http://www.wg.omron.co.jp/cgi-bin/j-e/jfriedl.html - -.SH "LATEST SOURCE" -See http://www.wg.omron.co.jp/~jfriedl/perl/index.html -__END__ -:endofperl diff --git a/win32/bin/test.bat b/win32/bin/test.bat deleted file mode 100644 index e6b7b38160..0000000000 --- a/win32/bin/test.bat +++ /dev/null @@ -1,143 +0,0 @@ -@rem = ' -@echo off -if exist perl.exe goto perlhere -echo Cannot run without perl.exe in current directory!! Did you build it? -pause -goto endofperl -:perlhere -if exist perlglob.exe goto perlglobhere -echo Cannot run without perlglob.exe in current directory!! Did you build it? -pause -goto endofperl -:perlglobhere -perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto endofperl -@rem '; - -#Portions (C) 1995 Microsoft Corporation. All rights reserved. -# Developed by hip communications inc., http://info.hip.com/info/ - - -# This is written in a peculiar style, since we're trying to avoid -# most of the constructs we'll be testing for. - -$| = 1; - -if ($ARGV[0] eq '-v') { - $verbose = 1; - shift; -} - - -# WYT 1995-05-02 -chdir 't' if -f 't/TESTNT'; - - -if ($ARGV[0] eq '') { -# @ARGV = split(/[ \n]/, -# `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`); -# `ls base/*.t comp/*.t cmd/*.t io/*.t op/*.t lib/*.t`); - -# WYT 1995-05-02 wildcard expansion, -# `perl -e "print( join( ' ', \@ARGV ) )" base/*.t comp/*.t cmd/*.t io/*.t op/*.t lib/*.t nt/*.t`); - -# WYT 1995-06-01 removed all dependency on perlglob -# WYT 1995-11-28 hacked up to cope with braindead Win95 console. - push( @ARGV, `dir/s/b base` ); - push( @ARGV, `dir/s/b comp` ); - push( @ARGV, `dir/s/b cmd` ); - push( @ARGV, `dir/s/b io` ); - push( @ARGV, `dir/s/b op` ); - push( @ARGV, `dir/s/b lib` ); - push( @ARGV, `dir/s/b nt` ); - - grep( chomp, @ARGV ); - @ARGV = grep( /\.t$/, @ARGV ); - grep( s/.*t\\//, @ARGV ); -} - -$sharpbang = 0; - -$bad = 0; -$good = 0; -$total = @ARGV; -while ($test = shift) { - if ($test =~ /^$/) { - next; - } - $te = $test; -# chop off 't' extension - chop($te); - print "$te" . '.' x (15 - length($te)); - if ($sharpbang) { - open(results,"./$test |") || (print "can't run.\n"); - } else { - $switch = ''; -# open(results,"./perl$switch $test |") || (print "can't run.\n"); - open(results,"perl$switch $test |") || (print "can't run.\n"); - } - $ok = 0; - $next = 0; - while (<results>) { - if ($verbose) { - print $_; - } - unless (/^#/||/^$/) { - if (/^1\.\.([0-9]+)/) { - $max = $1; - $totmax += $max; - $files += 1; - $next = 1; - $ok = 1; - } else { - $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; - if (/^ok (.*)/ && $1 == $next) { - $next = $next + 1; - } else { - $ok = 0; - } - } - } - } - $next = $next - 1; - if ($ok && $next == $max) { - print "ok\n"; - $good = $good + 1; - } else { - $next += 1; - print "FAILED on test $next\n"; - $bad = $bad + 1; - $_ = $test; - if (/^base/) { - die "Failed a basic test--cannot continue.\n"; - } - } -} - -if ($bad == 0) { - if ($ok) { - print "All tests successful.\n"; - } else { - die "FAILED--no tests were run for some reason.\n"; - } -} else { - $pct = sprintf("%.2f", $good / $total * 100); - if ($bad == 1) { - warn "Failed 1 test, $pct% okay.\n"; - } else { - die "Failed $bad/$total tests, $pct% okay.\n"; - } -} - - -# WYT 1995-05-03 times not implemented. -#($user,$sys,$cuser,$csys) = times; -#print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n", -# $user,$sys,$cuser,$csys,$files,$totmax); - -#`del /f Cmd_while.tmp Comp.try null 2>NULL`; - -unlink 'Cmd_while.tmp', 'Comp.try', 'null'; - -__END__ -:endofperl diff --git a/win32/bin/webget.bat b/win32/bin/webget.bat deleted file mode 100644 index e77bb88ced..0000000000 --- a/win32/bin/webget.bat +++ /dev/null @@ -1,1099 +0,0 @@ -@rem = '--*-Perl-*--'; -@rem = ' -@echo off -perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto endofperl -@rem '; -#!/usr/local/bin/perl -w - -#- -#!/usr/local/bin/perl -w -$version = "951121.18"; -$comments = 'jfriedl@omron.co.jp'; - -## -## This is "webget" -## -## Jeffrey Friedl (jfriedl@omron.co.jp), July 1994. -## Copyright 19.... ah hell, just take it. -## Should work with either perl4 or perl5 -## -## BLURB: -## Given a URL on the command line (HTTP and FTP supported at the moment), -## webget fetches the named object (HTML text, images, audio, whatever the -## object happens to be). Will automatically use a proxy if one is defined -## in the environment, follow "this URL has moved" responses, and retry -## "can't find host" responses from a proxy in case host lookup was slow). -## Supports users & passwords (FTP), Basic Authorization (HTTP), update-if- -## modified (HTTP), and much more. Works with perl4 or perl5. - -## -## More-detailed instructions in the comment block below the history list. -## - -## -## To-do: -## Add gopher support. -## Fix up how error messages are passed among this and the libraries. -## - -## 951219.19 -## Lost ftp connections now die with a bit more grace. -## -## 951121.18 -## Add -nnab. -## Brought the "usage" string in line with reality. -## -## 951114.17 -## Added -head. -## Added -update/-refresh/-IfNewerThan. If any URL was not pulled -## because it was not out of date, an exit value of 2 is returned. -## -## 951031.16 -## Added -timeout. Cleaned up (a bit) the exit value. Now exits -## with 1 if all URLs had some error (timeout exits immediately with -## code 3, though. This is subject to change). Exits with 0 if any -## URL was brought over safely. -## -## 951017.15 -## Neat -pf, -postfile idea from Lorrie Cranor -## (http://www.ccrc.wustl.edu/~lorracks/) -## -## 950912.14 -## Sigh, fixed a typo. -## -## 950911.13 -## Added Basic Authorization support for http. See "PASSWORDS AND STUFF" -## in the documentation. -## -## 950911.12 -## Implemented a most-excellent suggestion by Anthony D'Atri -## (aad@nwnet.net), to be able to automatically grab to a local file of -## the same name as the URL. See the '-nab' flag. -## -## 950706.11 -## Quelled small -w warning (thanks: Lars Rasmussen <gnort@daimi.aau.dk>) -## -## 950630.10 -## Steve Campbell to the rescue again. FTP now works when supplied -## with a userid & password (eg ftp://user:pass@foo.bar.com/index.txt). -## -## 950623.9 -## Incorporated changes from Steve Campbell (steven_campbell@uk.ibm.com) -## so that the ftp will work when no password is required of a user. -## -## 950530.8 -## Minor changes: -## Eliminate read-size warning message when size unknown. -## Pseudo-debug/warning messages at the end of debug_read now go to -## stderr. Some better error handling when trying to contact systems -## that aren't really set up for ftp. Fixed a bug concerning FTP access -## to a root directory. Added proxy documentation at head of file. -## -## 950426.6,7 -## Complete Overhaul: -## Renamed from httpget. Added ftp support (very sketchy at the moment). -## Redid to work with new 'www.pl' library; chucked 'Www.pl' library. -## More or less new and/or improved in many ways, but probably introduced -## a few bugs along the way. -## -## 941227.5 -## Added follow stuff (with -nofollow, etc.) -## Added -updateme. Cool! -## Some general tidying up. -## -## 941107.4 -## Allowed for ^M ending a header line... PCs give those kind of headers. -## -## 940820.3 -## First sorta'clean net release. -## -## - -## -##> -## -## Fetch http and/or ftp URL(s) given on the command line and spit to -## STDOUT. -## -## Options include: -## -V, -version -## Print version information; exit. -## -## -p, -post -## If the URL looks like a reply to a form (i.e. has a '?' in it), -## the request is POST'ed instead of GET'ed. -## -## -head -## Gets the header only (for HTTP). This might include such useful -## things as 'Last-modified' and 'Content-length' fields -## (a lack of a 'Last-modified' might be a good indication that it's -## a CGI). -## -## The "-head" option implies "-nostrip", but does *not* imply, -## for example "-nofollow". -## -## -## -pf, -postfile -## The item after the '?' is taken as a local filename, and the contents -## are POST'ed as with -post -## -## -nab, -f, -file -## Rather than spit the URL(s) to standard output, unconditionally -## dump to a file (or files) whose name is that as used in the URL, -## sans path. I like '-nab', but supply '-file' as well since that's -## what was originally suggested. Also see '-update' below for the -## only-if-changed version. -## -## -nnab -## Like -nab, but in addtion to dumping to a file, dump to stdout as well. -## Sort of like the 'tee' command. -## -## -update, -refresh -## Do the same thing as -nab, etc., but does not bother pulling the -## URL if it older than the localfile. Only applies to HTTP. -## Uses the HTTP "If-Modified-Since" field. If the URL was not modified -## (and hence not changed), the return value is '2'. -## -## -IfNewerThan FILE -## -int FILE -## Only pulls URLs if they are newer than the date the local FILE was -## last written. -## -## -q, -quiet -## Suppresses all non-essential informational messages. -## -## -nf, -nofollow -## Normally, a "this URL has moved" HTTP response is automatically -## followed. Not done with -nofollow. -## -## -nr, -noretry -## Normally, an HTTP proxy response of "can't find host" is retried -## up to three times, to give the remote hostname lookup time to -## come back with an answer. This suppresses the retries. This is the -## same as '-retry 0'. -## -## -r#, -retry#, -r #, -retry # -## Sets the number of times to retry. Default 3. -## -## -ns, -nostrip -## For HTTP items (including other items going through an HTTP proxy), -## the HTTP response header is printed rather than stripped as default. -## -## -np, -noproxy -## A proxy is not used, even if defined for the protocol. -## -## -h, -help -## Show a usage message and exit. -## -## -d, -debug -## Show some debugging messages. -## -## -updateme -## The special and rather cool flag "-updateme" will see if webget has -## been updated since you got your version, and prepare a local -## version of the new version for you to use. Keep updated! (although -## you can always ask to be put on the ping list to be notified when -## there's a new version -- see the author's perl web page). -## -## -timeout TIMESPAN -## -to TIMESPAN -## Time out if a connection can not be made within the specified time -## period. TIMESPAN is normally in seconds, although a 'm' or 'h' may -## be appended to indicate minutes and hours. "-to 1.5m" would timeout -## after 90 seconds. -## -## (At least for now), a timeout causes immediate program death (with -## exit value 3). For some reason, the alarm doesn't always cause a -## waiting read or connect to abort, so I just die immediately.. /-: -## -## I might consider adding an "entire fetch" timeout, if someone -## wants it. -## -## PASSWORDS AND SUCH -## -## You can use webget to do FTP fetches from non-Anonymous systems and -## accounts. Just put the required username and password into the URL, -## as with -## webget 'ftp:/user:password@ftp.somesite.com/pub/pix/babe.gif -## ^^^^^^^^^^^^^ -## Note the user:password is separated from the hostname by a '@'. -## -## You can use the same kind of thing with HTTP, and if so it will provide -## what's know as Basic Authorization. This is >weak< authorization. It -## also provides >zero< security -- I wouldn't be sending any credit-card -## numbers this way (unless you send them 'round my way :-). It seems to -## be used most by providers of free stuff where they want to make some -## attempt to limit access to "known users". -## -## PROXY STUFF -## -## If you need to go through a gateway to get out to the whole internet, -## you can use a proxy if one's been set up on the gateway. This is done -## by setting the "http_proxy" environmental variable to point to the -## proxy server. Other variables are used for other target protocols.... -## "gopher_proxy", "ftp_proxy", "wais_proxy", etc. -## -## For example, I have the following in my ".login" file (for use with csh): -## -## setenv http_proxy http://local.gateway.machine:8080/ -## -## This is to indicate that any http URL should go to local.gateway.machine -## (port 8080) via HTTP. Additionally, I have -## -## setenv gopher_proxy "$http_proxy" -## setenv wais_proxy "$http_proxy" -## setenv ftp_proxy "$http_proxy" -## -## This means that any gopher, wais, or ftp URL should also go to the -## same place, also via HTTP. This allows webget to get, for example, -## GOPHER URLs even though it doesn't support GOPHER itself. It uses HTTP -## to talk to the proxy, which then uses GOPHER to talk to the destination. -## -## Finally, if there are sites inside your gateway that you would like to -## connect to, you can list them in the "no_proxy" variable. This will allow -## you to connect to them directly and skip going through the proxy: -## -## setenv no_proxy "www.this,www.that,www.other" -## -## I (jfriedl@omron.co.jp) have little personal experience with proxies -## except what I deal with here at Omron, so if this is not representative -## of your situation, please let me know. -## -## RETURN VALUE -## The value returned to the system by webget is rather screwed up because -## I didn't think about dealing with it until things were already -## complicated. Since there can be more than one URL on the command line, -## it's hard to decide what to return when one times out, another is fetched, -## another doesn't need to be fetched, and a fourth isn't found. -## -## So, here's the current status: -## -## Upon any timeout (via the -timeout arg), webget immediately -## returns 3. End of story. Otherwise.... -## -## If any URL was fetched with a date limit (i.e. via -## '-update/-refresh/-IfNewerThan' and was found to not have changed, -## 2 is returned. Otherwise.... -## -## If any URL was successfully fetched, 0 is returned. Otherwise... -## -## If there were any errors, 1 is returned. Otherwise... -## -## Must have been an info-only or do-nothing instance. 0 is returned. -## -## Phew. Hopefully useful to someone. -##< -## - -## Where latest version should be. -$WEB_normal = 'http://www.wg.omron.co.jp/~jfriedl/perl/webget'; -$WEB_inlined = 'http://www.wg.omron.co.jp/~jfriedl/perl/inlined/webget'; - - -require 'network.pl'; ## inline if possible (directive to a tool of mine) -require 'www.pl'; ## inline if possible (directive to a tool of mine) -$inlined=0; ## this might be changed by a the inline thing. - -## -## Exit values. All screwed up. -## -$EXIT_ok = 0; -$EXIT_error = 1; -$EXIT_notmodified = 2; -$EXIT_timeout = 3; - -## -## - -warn qq/WARNING:\n$0: need a newer version of "network.pl"\n/ if - !defined($network'version) || $network'version < "950311.5"; -warn qq/WARNING:\n$0: need a newer version of "www.pl"\n/ if - !defined($www'version) || $www'version < "951114.8"; - -$WEB = $inlined ? $WEB_inlined : $WEB_normal; - -$debug = 0; -$strip = 1; ## default is to strip -$quiet = 0; ## also normally off. -$follow = 1; ## normally, we follow "Found (302)" links -$retry = 3; ## normally, retry proxy hostname lookups up to 3 times. -$nab = 0; ## If true, grab to a local file of the same name. -$refresh = 0; ## If true, use 'If-Modified-Since' with -nab get. -$postfile = 0; ## If true, filename is given after the '?' -$defaultdelta2print = 2048; -$TimeoutSpan = 0; ## seconds after which we should time out. - -while (@ARGV && $ARGV[0] =~ m/^-/) -{ - $arg = shift(@ARGV); - - $nab = 1, next if $arg =~ m/^-f(ile)?$/; - $nab = 1, next if $arg =~ m/^-nab$/; - $nab = 2, next if $arg =~ m/^-nnab$/; - $post = 1, next if $arg =~ m/^-p(ost)?$/i; - $post = $postfile = 1, next if $arg =~ m/^-p(ost)?f(ile)?$/i; - $quiet=1, next if $arg =~ m/^-q(uiet)?$/; - $follow = 0, next if $arg =~ m/^-no?f(ollow)?$/; - $strip = 0, next if $arg =~ m/^-no?s(trip)?$/; - $debug=1, next if $arg =~ m/^-d(ebug)?$/; - $noproxy=1, next if $arg =~ m/^-no?p(roxy)?$/; - $retry=0, next if $arg =~ m/^-no?r(etry)?$/; - $retry=$2, next if $arg =~ m/^-r(etry)?(\d+)$/; - &updateme if $arg eq '-updateme'; - $strip = 0, $head = 1, next if $arg =~ m/^-head(er)?/; - $nab = $refresh = 1, next if $arg =~ m/^-(refresh|update)/; - - &usage($EXIT_ok) if $arg =~ m/^-h(elp)?$/; - &show_version, exit($EXIT_ok) if $arg eq '-version' || $arg eq '-V'; - - if ($arg =~ m/^-t(ime)?o(ut)?$/i) { - local($num) = shift(@ARGV); - &usage($EXIT_error, "expecting timespan argument to $arg\n") unless - $num =~ m/^\d+(\d*)?[hms]?$/; - &timeout_arg($num); - next; - } - - if ($arg =~ m/^-if?n(ewer)?t(han)?$/i) { - $reference_file = shift(@ARGV); - &usage($EXIT_error, "expecting filename arg to $arg") - if !defined $reference_file; - if (!-f $reference_file) { - warn qq/$0: ${arg}'s "$reference_file" not found.\n/; - exit($EXIT_error); - } - next; - } - - if ($arg eq '-r' || $arg eq '-retry') { - local($num) = shift(@ARGV); - &usage($EXIT_error, "expecting numerical arg to $arg\n") unless - defined($num) && $num =~ m/^\d+$/; - $retry = $num; - next; - } - &usage($EXIT_error, qq/$0: unknown option "$arg"\n/); -} - -if ($head && $post) { - warn "$0: combining -head and -post makes no sense, ignoring -post.\n"; - $post = 0; - undef $postfile; -} - -if ($refresh && defined($reference_file)) { - warn "$0: combining -update and -IfNewerThan make no sense, ignoring -IfNewerThan.\n"; - undef $reference_file; -} - -if (@ARGV == 0) { - warn "$0: nothing to do. Use -help for info.\n"; - exit($EXIT_ok); -} - - -## -## Now run through the remaining arguments (mostly URLs) and do a quick -## check to see if they look well-formed. We won't *do* anything -- just -## want to catch quick errors before really starting the work. -## -@tmp = @ARGV; -$errors = 0; -while (@tmp) { - $arg = shift(@tmp); - if ($arg =~ m/^-t(ime)?o(ut)?$/) { - local($num) = shift(@tmp); - if ($num !~ m/^\d+(\d*)?[hms]?$/) { - &warn("expecting timespan argument to $arg\n"); - $errors++; - } - } else { - local($protocol) = &www'grok_URL($arg, $noproxy); - - if (!defined $protocol) { - warn qq/can't grok "$arg"/; - $errors++; - } elsif (!$quiet && ($protocol eq 'ftp')) { - warn qq/warning: -head ignored for ftp URLs\n/ if $head; - warn qq/warning: -refresh ignored for ftp URLs\n/if $refresh; - warn qq/warning: -IfNewerThan ignored for ftp URLs\n/if defined($reference_file); - - } - } -} - -exit($EXIT_error) if $errors; - - -$SuccessfulCount = 0; -$NotModifiedCount = 0; - -## -## Now do the real thing. -## -while (@ARGV) { - $arg = shift(@ARGV); - if ($arg =~ m/^-t(ime)?o(ut)?$/) { - &timeout_arg(shift(@ARGV)); - } else { - &fetch_url($arg); - } -} - -if ($NotModifiedCount) { - exit($EXIT_notmodified); -} elsif ($SuccessfulCount) { - exit($EXIT_ok); -} else { - exit($EXIT_error); -} - -########################################################################### -########################################################################### - -sub timeout_arg -{ - ($TimeoutSpan) = @_; - $TimeoutSpan =~ s/s//; - $TimeoutSpan *= 60 if $TimeoutSpan =~ m/m/; - $TimeoutSpan *= 3600 if $TimeoutSpan =~ m/h/; - -} - -## -## As a byproduct, returns the basename of $0. -## -sub show_version -{ - local($base) = $0; - $base =~ s,.*/,,; - print STDERR "This is $base version $version\n"; - $base; -} - -## -## &usage(exitval, message); -## -## Prints a usage message to STDERR. -## If MESSAGE is defined, prints that first. -## If exitval is defined, exits with that value. Otherwise, returns. -## -sub usage -{ - local($exit, $message) = @_; - - print STDERR $message if defined $message; - local($base) = &show_version; - print STDERR <<INLINE_LITERAL_TEXT; -usage: $0 [options] URL ... - Fetches and displays the named URL(s). Supports http and ftp. - (if no protocol is given, a leading "http://" is normally used). - -Options are from among: - -V, -version Print version information; exit. - -p, -post If URL looks like a form reply, does POST instead of GET. - -pf, -postfile Like -post, but takes everything after ? to be a filename. - -q, -quiet All non-essential informational messages are suppressed. - -nf, -nofollow Don't follow "this document has moved" replies. - -nr, -noretry Doesn't retry a failed hostname lookup (same as -retry 0) - -r #, -retry # Sets failed-hostname-lookup-retry to # (default $retry) - -np, -noproxy Uses no proxy, even if one defined for the protocol. - -ns, -nostrip The HTTP header, normally elided, is printed. - -head gets item header only (implies -ns) - -nab, -file Dumps output to file whose name taken from URL, minus path - -nnab Like -nab, but *also* dumps to stdout. - -update HTTP only. Like -nab, but only if the page has been modified. - -h, -help Prints this message. - -IfNewerThan F HTTP only. Only brings page if it is newer than named file. - -timeout T Fail if a connection can't be made in the specified time. - - -updateme Pull the latest version of $base from - $WEB - and reports if it is newer than your current version. - -Comments to $comments. -INLINE_LITERAL_TEXT - - exit($exit) if defined $exit; -} - -## -## Pull the latest version of this program to a local file. -## Clip the first couple lines from this executing file so that we -## preserve the local invocation style. -## -sub updateme -{ - ## - ## Open a temp file to hold the new version, - ## redirecting STDOUT to it. - ## - open(STDOUT, '>'.($tempFile="/tmp/webget.new")) || - open(STDOUT, '>'.($tempFile="/usr/tmp/webget.new")) || - open(STDOUT, '>'.($tempFile="/webget.new")) || - open(STDOUT, '>'.($tempFile="webget.new")) || - die "$0: can't open a temp file.\n"; - - ## - ## See if we can figure out how we were called. - ## The seek will rewind not to the start of the data, but to the - ## start of the whole program script. - ## - ## Keep the first line if it begins with #!, and the next two if they - ## look like the trick mentioned in the perl man page for getting - ## around the lack of #!-support. - ## - if (seek(DATA, 0, 0)) { ## - $_ = <DATA>; if (m/^#!/) { print STDOUT; - $_ = <DATA>; if (m/^\s*eval/) { print STDOUT; - $_ = <DATA>; if (m/^\s*if/) { print STDOUT; } - } - } - print STDOUT "\n#-\n"; - } - - ## Go get the latest one... - local(@options); - push(@options, 'head') if $head; - push(@options, 'nofollow') unless $follow; - push(@options, ('retry') x $retry) if $retry; - push(@options, 'quiet') if $quiet; - push(@options, 'debug') if $debug; - local($status, $memo, %info) = &www'open_http_url(*IN, $WEB, @options); - die "fetching $WEB:\n $memo\n" unless $status eq 'ok'; - - $size = $info{'content-length'}; - while (<IN>) - { - $size -= length; - print STDOUT; - if (!defined $fetched_version && m/version\s*=\s*"([^"]+)"/) { - $fetched_version = $1; - &general_read(*IN, $size); - last; - } - } - - $fetched_version = "<unknown>" unless defined $fetched_version; - - ## - ## Try to update the mode of the temp file with the mode of this file. - ## Don't worry if it fails. - ## - chmod($mode, $tempFile) if $mode = (stat($0))[2]; - - $as_well = ''; - if ($fetched_version eq $version) - { - print STDERR "You already have the most-recent version ($version).\n", - qq/FWIW, the newly fetched one has been left in "$tempFile".\n/; - } - elsif ($fetched_version <= $version) - { - print STDERR - "Mmm, your current version seems newer (?!):\n", - qq/ your version: "$version"\n/, - qq/ new version: "$fetched_version"\n/, - qq/FWIW, fetched one left in "$tempFile".\n/; - } - else - { - print STDERR - "Indeed, your current version was old:\n", - qq/ your version: "$version"\n/, - qq/ new version: "$fetched_version"\n/, - qq/The file "$tempFile" is ready to replace the old one.\n/; - print STDERR qq/Just do:\n % mv $tempFile $0\n/ if -f $0; - $as_well = ' as well'; - } - print STDERR "Note that the libraries it uses may (or may not) need updating$as_well.\n" - unless $inlined; - exit($EXIT_ok); -} - -## -## Given a list of URLs, fetch'em. -## Parses the URL and calls the routine for the appropriate protocol -## -sub fetch_url -{ - local(@todo) = @_; - local(%circref, %hold_circref); - - URL_LOOP: while (@todo) - { - $URL = shift(@todo); - %hold_circref = %circref; undef %circref; - - local($protocol, @args) = &www'grok_URL($URL, $noproxy); - - if (!defined $protocol) { - &www'message(1, qq/can't grok "$URL"/); - next URL_LOOP; - } - - ## call protocol-specific handler - $func = "fetch_via_" . $protocol; - $error = &$func(@args, $TimeoutSpan); - if (defined $error) { - &www'message(1, "$URL: $error"); - } else { - $SuccessfulCount++; - } - } -} - -sub filedate -{ - local($filename) = @_; - local($filetime) = (stat($filename))[9]; - return 0 if !defined $filetime; - local($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($filetime); - return 0 if !defined $wday; - sprintf(qq/"%s, %02d-%s-%02d %02d:%02d:%02d GMT"/, - ("Sunday", "Monday", "Tuesdsy", "Wednesday", - "Thursday", "Friday", "Saturday")[$wday], - $mday, - ("Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$mon], - $year, - $hour, - $min, - $sec); -} - -sub local_filename -{ - local($filename) = @_; - $filename =~ s,/+$,,; ## remove any trailing slashes - $filename =~ s,.*/,,; ## remove any leading path - if ($filename eq '') { - ## empty -- pick a random name - $filename = "file0000"; - ## look for a free random name. - $filename++ while -f $filename; - } - $filename; -} - -sub set_output_file -{ - local($filename) = @_; - if (!open(OUT, ">$filename")) { - &www'message(1, "$0: can't open [$filename] for output"); - } else { - open(SAVEOUT, ">>&STDOUT") || die "$!";; - open(STDOUT, ">>&OUT"); - } -} - -sub close_output_file -{ - local($filename) = @_; - unless ($quiet) - { - local($note) = qq/"$filename" written/; - if (defined $error) { - $note .= " (possibly corrupt due to error above)"; - } - &www'message(1, "$note."); - } - close(STDOUT); - open(STDOUT, ">&SAVEOUT"); -} - -sub http_alarm -{ - &www'message(1, "ERROR: $AlarmNote."); - exit($EXIT_timeout); ## the alarm doesn't seem to cause a waiting syscall to break? -# $HaveAlarm = 1; -} - -## -## Given the host, port, and path, and (for info only) real target, -## fetch via HTTP. -## -## If there is a user and/or password, use that for Basic Authorization. -## -## If $timeout is nonzero, time out after that many seconds. -## -sub fetch_via_http -{ - local($host, $port, $path, $target, $user, $password, $timeout) = @_; - local(@options); - local($local_filename); - - ## - ## If we're posting, but -postfile was given, we need to interpret - ## the item in $path after '?' as a filename, and replace it with - ## the contents of the file. - ## - if ($postfile && $path =~ s/\?([\d\D]*)//) { - local($filename) = $1; - return("can't open [$filename] to POST") if !open(IN, "<$filename"); - local($/) = ''; ## want to suck up the whole file. - $path .= '?' . <IN>; - close(IN); - } - - $local_filename = &local_filename($path) - if $refresh || $nab || defined($reference_file); - $refresh = &filedate($local_filename) if $refresh; - $refresh = &filedate($reference_file) if defined($reference_file); - - push(@options, 'head') if $head; - push(@options, 'post') if $post; - push(@options, 'nofollow') unless $follow; - push(@options, ('retry') x 3); - push(@options, 'quiet') if $quiet; - push(@options, 'debug') if $debug; - push(@options, "ifmodifiedsince=$refresh") if $refresh; - - if (defined $password || defined $user) { - local($auth) = join(':', ($user || ''), ($password || '')); - push(@options, "authorization=$auth"); - } - - local($old_alarm); - if ($timeout) { - $old_alarm = $SIG{'ALRM'} || 'DEFAULT'; - $SIG{'ALRM'} = "main'http_alarm"; -# $HaveAlarm = 0; - $AlarmNote = "host $host"; - $AlarmNote .= ":$port" if $port != $www'default_port{'http'}; - $AlarmNote .= " timed out after $timeout second"; - $AlarmNote .= 's' if $timeout > 1; - alarm($timeout); - } - local($result, $memo, %info) = - &www'open_http_connection(*HTTP, $host,$port,$path,$target,@options); - - if ($timeout) { - alarm(0); - $SIG{'ALRM'} = $old_alarm; - } - -# if ($HaveAlarm) { -# close(HTTP); -# $error = "timeout after $timeout second"; -# $error .= "s" if $timeout > 1; -# return $error; -# } - - if ($follow && ($result eq 'follow')) { - %circref = %hold_circref; - $circref{$memo} = 1; - unshift(@todo, $memo); - return undef; - } - - - return $memo if $result eq 'error'; - if (!$quiet && $result eq 'status' && ! -t STDOUT) { - #&www'message(1, "Warning: $memo"); - $error = "Warning: $memo"; - } - - if ($info{'CODE'} == 304) { ## 304 is magic for "Not Modified" - close(HTTP); - &www'message(1, "$URL: Not Modified") unless $quiet; - $NotModifiedCount++; - return undef; ## no error - } - - - &set_output_file($local_filename) if $nab; - - unless($strip) { - print $info{'STATUS'}, "\n", $info{'HEADER'}, "\n"; - - print SAVEOUT $info{'STATUS'}, "\n", $info{'HEADER'}, "\n" if $nab==2; - } - - if (defined $info{'BODY'}) { - print $info{'BODY'}; - print SAVEOUT $info{'BODY'} if $nab==2; - } - - if (!$head) { - &general_read(*HTTP, $info{'content-length'}); - } - close(HTTP); - &close_output_file($local_filename) if $nab; - - $error; ## will be 'undef' if no error; -} - -sub fetch_via_ftp -{ - local($host, $port, $path, $target, $user, $password, $timeout) = @_; - local($local_filename) = &local_filename($path); - local($ftp_debug) = $debug; - local(@password) = ($password); - $path =~ s,^/,,; ## remove a leading / from the path. - $path = '.' if $path eq ''; ## make sure we have something - - if (!defined $user) { - $user = 'anonymous'; - $password = $ENV{'USER'} || 'WWWuser'; - @password = ($password.'@'. &network'addr_to_ascii(&network'my_addr), - $password.'@'); - } elsif (!defined $password) { - @password = (""); - } - - local($_last_ftp_reply, $_passive_host, $_passive_port); - local($size); - - sub _ftp_get_reply - { - local($text) = scalar(<FTP_CONTROL>); - die "lost connection to $host\n" if !defined $text; - local($_, $tmp); - print STDERR "READ: $text" if $ftp_debug; - die "internal error: expected reply code in response from ". - "ftp server [$text]" unless $text =~ s/^(\d+)([- ])//; - local($code) = $1; - if ($2 eq '-') { - while (<FTP_CONTROL>) { - ($tmp = $_) =~ s/^\d+[- ]//; - $text .= $tmp; - last if m/^$code /; - } - } - $text =~ s/^\d+ ?/<foo>/g; - ($code, $text); - } - - sub _ftp_expect - { - local($code, $text) = &_ftp_get_reply; - $_last_ftp_reply = $text; - foreach $expect (@_) { - return ($code, $text) if $code == $expect; - } - die "internal error: expected return code ". - join('|',@_).", got [$text]"; - } - - sub _ftp_send - { - print STDERR "SEND: ", @_ if $ftp_debug; - print FTP_CONTROL @_; - } - - sub _ftp_do_passive - { - local(@commands) = @_; - - &_ftp_send("PASV\r\n"); - local($code) = &_ftp_expect(227, 125); - - if ($code == 227) - { - die "internal error: can't grok passive reply [$_last_ftp_reply]" - unless $_last_ftp_reply =~ m/\(([\d,]+)\)/; - local($a,$b,$c,$d, $p1, $p2) = split(/,/, $1); - ($_passive_host, $_passive_port) = - ("$a.$b.$c.$d", $p1*256 + $p2); - } - - foreach(@commands) { - &_ftp_send($_); - } - - local($error)= - &network'connect_to(*PASSIVE, $_passive_host, $_passive_port); - die "internal error: passive ftp connect [$error]" if $error; - } - - ## make the connection to the host - &www'message($debug, "connecting to $host...") unless $quiet; - - local($old_alarm); - if ($timeout) { - $old_alarm = $SIG{'ALRM'} || 'DEFAULT'; - $SIG{'ALRM'} = "main'http_alarm"; ## can use this for now -# $HaveAlarm = 0; - $AlarmNote = "host $host"; - $AlarmNote .= ":$port" if $port != $www'default_port{'ftp'}; - $AlarmNote .= " timed out after $timeout second"; - $AlarmNote .= 's' if $timeout > 1; - alarm($timeout); - } - - local($error) = &network'connect_to(*FTP_CONTROL, $host, $port); - - if ($timeout) { - alarm(0); - $SIG{'ALRM'} = $old_alarm; - } - - return $error if $error; - - local ($code, $text) = &_ftp_get_reply(*FTP_CONTROL); - close(FTP_CONTROL), return "internal ftp error: [$text]" unless $code==220; - - ## log in - &www'message($debug, "logging in as $user...") unless $quiet; - foreach $password (@password) - { - &_ftp_send("USER $user\r\n"); - ($code, $text) = &_ftp_expect(230,331,530); - close(FTP_CONTROL), return $text if ($code == 530); - last if $code == 230; ## hey, already logged in, cool. - - &_ftp_send("PASS $password\r\n"); - ($code, $text) = &_ftp_expect(220,230,530,550,332); - last if $code != 550; - last if $text =~ m/can't change directory/; - } - - if ($code == 550) - { - $text =~ s/\n+$//; - &www'message(1, "Can't log in $host: $text") unless $quiet; - exit($EXIT_error); - } - - if ($code == 332) - { - &_ftp_send("ACCT noaccount\r\n"); - ($code, $text) = &_ftp_expect(230, 202, 530, 500,501,503, 421) - } - close(FTP_CONTROL), return $text if $code >= 300; - - &_ftp_send("TYPE I\r\n"); - &_ftp_expect(200); - - unless ($quiet) { - local($name) = $path; - $name =~ s,.*/([^/]),$1,; - &www'message($debug, "requesting $name..."); - } - ## get file - &_ftp_do_passive("RETR $path\r\n"); - ($code,$text) = &_ftp_expect(125, 150, 550, 530); - close(FTP_CONTROL), return $text if $code == 530; - - if ($code == 550) - { - close(PASSIVE); - if ($text =~ /directory/i) { - ## probably from "no such file or directory", so just return now. - close(FTP_CONTROL); - return $text; - } - - ## do like Mosaic and try getting a directory listing. - &_ftp_send("CWD $path\r\n"); - ($code) = &_ftp_expect(250,550); - if ($code == 550) { - close(FTP_CONTROL); - return $text; - } - &_ftp_do_passive("LIST\r\n"); - &_ftp_expect(125, 150); - } - - $size = $1 if $text =~ m/(\d+)\s+bytes/; - binmode(PASSIVE); ## just in case. - &www'message($debug, "waiting for data...") unless $quiet; - &set_output_file($local_filename) if $nab; - &general_read(*PASSIVE, $size); - &close_output_file($local_filename) if $nab; - - close(PASSIVE); - close(FTP_CONTROL); - undef; -} - -sub general_read -{ - local(*INPUT, $size) = @_; - local($lastcount, $bytes) = (0,0); - local($need_to_clear) = 0; - local($start_time) = time; - local($last_time, $time) = $start_time; - ## Figure out how often to print the "bytes read" message - local($delta2print) = - (defined $size) ? int($size/50) : $defaultdelta2print; - - &www'message(0, "read 0 bytes") unless $quiet; - - ## so $! below is set only if a real error happens from now - eval 'local($^W) = 0; undef $!'; - - - while (defined($_ = <INPUT>)) - { - ## shove it out. - &www'clear_message if $need_to_clear; - print; - print SAVEOUT if $nab==2; - - ## if we know the content-size, keep track of what we're reading. - $bytes += length; - - last if eof || (defined $size && $bytes >= $size); - - if (!$quiet && $bytes > ($lastcount + $delta2print)) - { - if ($time = time, $last_time == $time) { - $delta2print *= 1.5; - } else { - $last_time = $time; - $lastcount = $bytes; - local($time_delta) = $time - $start_time; - local($text); - - $delta2print /= $time_delta; - if (defined $size) { - $text = sprintf("read $bytes bytes (%.0f%%)", - $bytes*100/$size); - } else { - $text = "read $bytes bytes"; - } - - if ($time_delta > 5 || ($time_delta && $bytes > 10240)) - { - local($rate) = int($bytes / $time_delta); - if ($rate < 5000) { - $text .= " ($rate bytes/sec)"; - } elsif ($rate < 1024 * 10) { - $text .= sprintf(" (%.1f k/sec)", $rate/1024); - } else { - $text .= sprintf(" (%.0f k/sec)", $rate/1024); - } - } - &www'message(0, "$text..."); - $need_to_clear = -t STDOUT; - } - } - } - - if (!$quiet) - { - if ($size && ($size != $bytes)) { - &www'message("WARNING: Expected $size bytes, read $bytes bytes.\n"); - } -# if ($!) { -# print STDERR "\$! is [$!]\n"; -# } -# if ($@) { -# print STDERR "\$\@ is [$@]\n"; -# } - } - &www'clear_message($text) unless $quiet; -} - -sub dummy { - 1 || &dummy || &fetch_via_ftp || &fetch_via_http || &http_alarm; - 1 || close(OUT); - 1 || close(SAVEOUT); -} - -__END__ -__END__ -:endofperl diff --git a/win32/config.H b/win32/config.H deleted file mode 100644 index 2018198084..0000000000 --- a/win32/config.H +++ /dev/null @@ -1,1781 +0,0 @@ -/* - * This file was produced by running the config_h.SH script, which - * gets its values from config.sh, which is generally produced by - * running Configure. - * - * Feel free to modify any of this as the need arises. Note, however, - * that running config_h.SH again will wipe out any changes you've made. - * For a more permanent change edit config.sh and rerun config_h.SH. - * - * $Id: Config_h.U,v 3.0.1.4 1995/09/25 09:10:49 ram Exp $ - */ - -/* Configuration time: Thu Apr 11 06:20:49 PDT 1996 - * Configured by: garyng - * Target system: - */ - -#ifndef _config_h_ -#define _config_h_ - -/* MEM_ALIGNBYTES: - * This symbol contains the number of bytes required to align a - * double. Usual values are 2, 4 and 8. - */ -#define MEM_ALIGNBYTES 8 /**/ - -/* ARCHNAME: - * This symbol holds a string representing the architecture name. - * It may be used to construct an architecture-dependant pathname - * where library files may be held under a private library, for - * instance. - */ -#define ARCHNAME "MSWin32" /**/ - -/* BIN: - * This symbol holds the path of the bin directory where the package will - * be installed. Program must be prepared to deal with ~name substitution. - */ -/* BIN_EXP: - * This symbol is the filename expanded version of the BIN symbol, for - * programs that do not want to deal with that at run-time. - */ -#define BIN "c:\\perl\\bin" /**/ -#define BIN_EXP "c:\\perl\\bin" /**/ - -/* CAT2: - * This macro catenates 2 tokens together. - */ -/* STRINGIFY: - * This macro surrounds its token with double quotes. - */ -#if 42 == 1 -#define CAT2(a,b)a/**/b -#define CAT3(a,b,c)a/**/b/**/c -#define CAT4(a,b,c,d)a/**/b/**/c/**/d -#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e -#define STRINGIFY(a)"a" - /* If you can get stringification with catify, tell me how! */ -#endif -#if 42 == 42 -#define CAT2(a,b)a ## b -#define CAT3(a,b,c)a ## b ## c -#define CAT4(a,b,c,d)a ## b ## c ## d -#define CAT5(a,b,c,d,e)a ## b ## c ## d ## e -#define StGiFy(a)# a -#define STRINGIFY(a)StGiFy(a) -#define SCAT2(a,b)StGiFy(a) StGiFy(b) -#define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c) -#define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) -#define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e) -#endif -#ifndef CAT2 -#include "Bletch: How does this C preprocessor catenate tokens?" -#endif - -/* CPPSTDIN: - * This symbol contains the first part of the string which will invoke - * the C preprocessor on the standard input and produce to standard - * output. Typical value of "cc -E" or "/lib/cpp", but it can also - * call a wrapper. See CPPRUN. - */ -/* CPPMINUS: - * This symbol contains the second part of the string which will invoke - * the C preprocessor on the standard input and produce to standard - * output. This symbol will have the value "-" if CPPSTDIN needs a minus - * to specify standard input, otherwise the value is "". - */ -#define CPPSTDIN "cl -E" -#define CPPMINUS "" - -/* HAS_ALARM: - * This symbol, if defined, indicates that the alarm routine is - * available. - */ -/*#define HAS_ALARM /**/ - -/* HASATTRIBUTE: - * This symbol indicates the C compiler can check for function attributes, - * such as printf formats. This is normally only supported by GNU cc. - */ -/*#define HASATTRIBUTE /**/ -#ifndef HASATTRIBUTE -#define __attribute__(_arg_) -#endif - -/* HAS_BCMP: - * This symbol is defined if the bcmp() routine is available to - * compare blocks of memory. - */ -/*#define HAS_BCMP /**/ - -/* HAS_BCOPY: - * This symbol is defined if the bcopy() routine is available to - * copy blocks of memory. - */ -/*#define HAS_BCOPY /**/ - -/* HAS_BZERO: - * This symbol is defined if the bzero() routine is available to - * set a memory block to 0. - */ -/*#define HAS_BZERO /**/ - -/* CASTI32: - * This symbol is defined if the C compiler can cast negative - * or large floating point numbers to 32-bit ints. - */ -#define CASTI32 /**/ - -/* CASTNEGFLOAT: - * This symbol is defined if the C compiler can cast negative - * numbers to unsigned longs, ints and shorts. - */ -/* CASTFLAGS: - * This symbol contains flags that say what difficulties the compiler - * has casting odd floating values to unsigned long: - * 0 = ok - * 1 = couldn't cast < 0 - * 2 = couldn't cast >= 0x80000000 - * 4 = couldn't cast in argument expression list - */ -#define CASTNEGFLOAT /**/ -#define CASTFLAGS 0 /**/ - -/* HAS_CHOWN: - * This symbol, if defined, indicates that the chown routine is - * available. - */ -/*#define HAS_CHOWN /**/ - -/* HAS_CHROOT: - * This symbol, if defined, indicates that the chroot routine is - * available. - */ -/*#define HAS_CHROOT /**/ - -/* HAS_CHSIZE: - * This symbol, if defined, indicates that the chsize routine is available - * to truncate files. You might need a -lx to get this routine. - */ -#define HAS_CHSIZE /**/ - -/* VOID_CLOSEDIR: - * This symbol, if defined, indicates that the closedir() routine - * does not return a value. - */ -/*#define VOID_CLOSEDIR /**/ - -/* HASCONST: - * This symbol, if defined, indicates that this C compiler knows about - * the const type. There is no need to actually test for that symbol - * within your programs. The mere use of the "const" keyword will - * trigger the necessary tests. - */ -#define HASCONST /**/ -#ifndef HASCONST -#define const -#endif - -/* HAS_CRYPT: - * This symbol, if defined, indicates that the crypt routine is available - * to encrypt passwords and the like. - */ -/*#define HAS_CRYPT /**/ - -/* HAS_CUSERID: - * This symbol, if defined, indicates that the cuserid routine is - * available to get character login names. - */ -/*#define HAS_CUSERID /**/ - -/* HAS_DBL_DIG: - * This symbol, if defined, indicates that this system's <float.h> - * or <limits.h> defines the symbol DBL_DIG, which is the number - * of significant digits in a double precision number. If this - * symbol is not defined, a guess of 15 is usually pretty good. - */ -#define HAS_DBL_DIG /**/ - -/* HAS_DIFFTIME: - * This symbol, if defined, indicates that the difftime routine is - * available. - */ -#define HAS_DIFFTIME /**/ - -/* HAS_DLERROR: - * This symbol, if defined, indicates that the dlerror routine is - * available to return a string describing the last error that - * occurred from a call to dlopen(), dlclose() or dlsym(). - */ -#define HAS_DLERROR /**/ - -/* HAS_DUP2: - * This symbol, if defined, indicates that the dup2 routine is - * available to duplicate file descriptors. - */ -#define HAS_DUP2 /**/ - -/* HAS_FCHMOD: - * This symbol, if defined, indicates that the fchmod routine is available - * to change mode of opened files. If unavailable, use chmod(). - */ -/*#define HAS_FCHMOD /**/ - -/* HAS_FCHOWN: - * This symbol, if defined, indicates that the fchown routine is available - * to change ownership of opened files. If unavailable, use chown(). - */ -/*#define HAS_FCHOWN /**/ - -/* HAS_FCNTL: - * This symbol, if defined, indicates to the C program that - * the fcntl() function exists. - */ -/*#define HAS_FCNTL /**/ - -/* HAS_FGETPOS: - * This symbol, if defined, indicates that the fgetpos routine is - * available to get the file position indicator, similar to ftell(). - */ -#define HAS_FGETPOS /**/ - -/* FLEXFILENAMES: - * This symbol, if defined, indicates that the system supports filenames - * longer than 14 characters. - */ -#define FLEXFILENAMES /**/ - -/* HAS_FLOCK: - * This symbol, if defined, indicates that the flock routine is - * available to do file locking. - */ -#define HAS_FLOCK /**/ - -/* HAS_FORK: - * This symbol, if defined, indicates that the fork routine is - * available. - */ -/*#define HAS_FORK /**/ - -/* HAS_FSETPOS: - * This symbol, if defined, indicates that the fsetpos routine is - * available to set the file position indicator, similar to fseek(). - */ -#define HAS_FSETPOS /**/ - -/* HAS_GETTIMEOFDAY: - * This symbol, if defined, indicates that the gettimeofday() system - * call is available for a sub-second accuracy clock. Usually, the file - * <sys/resource.h> needs to be included (see I_SYS_RESOURCE). - * The type "Timeval" should be used to refer to "struct timeval". - */ -/*#define HAS_GETTIMEOFDAY /**/ -#ifdef HAS_GETTIMEOFDAY -#define Timeval struct timeval /* Structure used by gettimeofday() */ -#endif - -/* HAS_GETGROUPS: - * This symbol, if defined, indicates that the getgroups() routine is - * available to get the list of process groups. If unavailable, multiple - * groups are probably not supported. - */ -/* HAS_SETGROUPS: - * This symbol, if defined, indicates that the setgroups() routine is - * available to set the list of process groups. If unavailable, multiple - * groups are probably not supported. - */ -/*#define HAS_GETGROUPS /**/ -/*#define HAS_SETGROUPS /**/ - -/* HAS_GETHOSTENT: - * This symbol, if defined, indicates that the gethostent routine is - * available to lookup host names in some data base or other. - */ -/*#define HAS_GETHOSTENT /**/ - -/* HAS_UNAME: - * This symbol, if defined, indicates that the C program may use the - * uname() routine to derive the host name. See also HAS_GETHOSTNAME - * and PHOSTNAME. - */ -/*#define HAS_UNAME /**/ - -/* HAS_GETLOGIN: - * This symbol, if defined, indicates that the getlogin routine is - * available to get the login name. - */ -/*#define HAS_GETLOGIN /**/ - -/* HAS_GETPGRP2: - * This symbol, if defined, indicates that the getpgrp2() (as in DG/UX) - * routine is available to get the current process group. - */ -/*#define HAS_GETPGRP2 /**/ - -/* HAS_GETPPID: - * This symbol, if defined, indicates that the getppid routine is - * available to get the parent process ID. - */ -/*#define HAS_GETPPID /**/ - -/* HAS_GETPRIORITY: - * This symbol, if defined, indicates that the getpriority routine is - * available to get a process's priority. - */ -/*#define HAS_GETPRIORITY /**/ - -/* HAS_HTONL: - * This symbol, if defined, indicates that the htonl() routine (and - * friends htons() ntohl() ntohs()) are available to do network - * order byte swapping. - */ -/* HAS_HTONS: - * This symbol, if defined, indicates that the htons() routine (and - * friends htonl() ntohl() ntohs()) are available to do network - * order byte swapping. - */ -/* HAS_NTOHL: - * This symbol, if defined, indicates that the ntohl() routine (and - * friends htonl() htons() ntohs()) are available to do network - * order byte swapping. - */ -/* HAS_NTOHS: - * This symbol, if defined, indicates that the ntohs() routine (and - * friends htonl() htons() ntohl()) are available to do network - * order byte swapping. - */ -#define HAS_HTONL /**/ -#define HAS_HTONS /**/ -#define HAS_NTOHL /**/ -#define HAS_NTOHS /**/ - -/* HAS_ISASCII: - * This manifest constant lets the C program know that isascii - * is available. - */ -#define HAS_ISASCII /**/ - -/* HAS_KILLPG: - * This symbol, if defined, indicates that the killpg routine is available - * to kill process groups. If unavailable, you probably should use kill - * with a negative process number. - */ -/*#define HAS_KILLPG /**/ - -/* HAS_LINK: - * This symbol, if defined, indicates that the link routine is - * available to create hard links. - */ -/*#define HAS_LINK /**/ - -/* HAS_LOCALECONV: - * This symbol, if defined, indicates that the localeconv routine is - * available for numeric and monetary formatting conventions. - */ -#define HAS_LOCALECONV /**/ - -/* HAS_LOCKF: - * This symbol, if defined, indicates that the lockf routine is - * available to do file locking. - */ -/*#define HAS_LOCKF /**/ - -/* HAS_LSTAT: - * This symbol, if defined, indicates that the lstat routine is - * available to do file stats on symbolic links. - */ -/*#define HAS_LSTAT /**/ - -/* HAS_MBLEN: - * This symbol, if defined, indicates that the mblen routine is available - * to find the number of bytes in a multibye character. - */ -#define HAS_MBLEN /**/ - -/* HAS_MBSTOWCS: - * This symbol, if defined, indicates that the mbstowcs routine is - * available to covert a multibyte string into a wide character string. - */ -#define HAS_MBSTOWCS /**/ - -/* HAS_MBTOWC: - * This symbol, if defined, indicates that the mbtowc routine is available - * to covert a multibyte to a wide character. - */ -#define HAS_MBTOWC /**/ - -/* HAS_MEMCMP: - * This symbol, if defined, indicates that the memcmp routine is available - * to compare blocks of memory. - */ -#define HAS_MEMCMP /**/ - -/* HAS_MEMCPY: - * This symbol, if defined, indicates that the memcpy routine is available - * to copy blocks of memory. - */ -#define HAS_MEMCPY /**/ - -/* HAS_MEMMOVE: - * This symbol, if defined, indicates that the memmove routine is available - * to copy potentially overlapping blocks of memory. This should be used - * only when HAS_SAFE_BCOPY is not defined. If neither is there, roll your - * own version. - */ -#define HAS_MEMMOVE /**/ - -/* HAS_MEMSET: - * This symbol, if defined, indicates that the memset routine is available - * to set blocks of memory. - */ -#define HAS_MEMSET /**/ - -/* HAS_MKDIR: - * This symbol, if defined, indicates that the mkdir routine is available - * to create directories. Otherwise you should fork off a new process to - * exec /bin/mkdir. - */ -#define HAS_MKDIR /**/ - -/* HAS_MKFIFO: - * This symbol, if defined, indicates that the mkfifo routine is - * available to create FIFOs. Otherwise, mknod should be able to - * do it for you. However, if mkfifo is there, mknod might require - * super-user privileges which mkfifo will not. - */ -/*#define HAS_MKFIFO /**/ - -/* HAS_MKTIME: - * This symbol, if defined, indicates that the mktime routine is - * available. - */ -#define HAS_MKTIME /**/ - -/* HAS_MSG: - * This symbol, if defined, indicates that the entire msg*(2) library is - * supported (IPC mechanism based on message queues). - */ -/*#define HAS_MSG /**/ - -/* HAS_NICE: - * This symbol, if defined, indicates that the nice routine is - * available. - */ -/*#define HAS_NICE /**/ - -/* HAS_OPEN3: - * This manifest constant lets the C program know that the three - * argument form of open(2) is available. - */ -/*#define HAS_OPEN3 /**/ - -/* HAS_PATHCONF: - * This symbol, if defined, indicates that pathconf() is available - * to determine file-system related limits and options associated - * with a given filename. - */ -/* HAS_FPATHCONF: - * This symbol, if defined, indicates that pathconf() is available - * to determine file-system related limits and options associated - * with a given open file descriptor. - */ -/*#define HAS_PATHCONF /**/ -/*#define HAS_FPATHCONF /**/ - -/* HAS_PAUSE: - * This symbol, if defined, indicates that the pause routine is - * available to suspend a process until a signal is received. - */ -#define HAS_PAUSE /**/ - -/* HAS_PIPE: - * This symbol, if defined, indicates that the pipe routine is - * available to create an inter-process channel. - */ -#define HAS_PIPE /**/ - -/* HAS_POLL: - * This symbol, if defined, indicates that the poll routine is - * available to poll active file descriptors. - */ -/*#define HAS_POLL /**/ - -/* HAS_READDIR: - * This symbol, if defined, indicates that the readdir routine is - * available to read directory entries. You may have to include - * <dirent.h>. See I_DIRENT. - */ -#define HAS_READDIR /**/ - -/* HAS_SEEKDIR: - * This symbol, if defined, indicates that the seekdir routine is - * available. You may have to include <dirent.h>. See I_DIRENT. - */ -#define HAS_SEEKDIR /**/ - -/* HAS_TELLDIR: - * This symbol, if defined, indicates that the telldir routine is - * available. You may have to include <dirent.h>. See I_DIRENT. - */ -#define HAS_TELLDIR /**/ - -/* HAS_REWINDDIR: - * This symbol, if defined, indicates that the rewinddir routine is - * available. You may have to include <dirent.h>. See I_DIRENT. - */ -#define HAS_REWINDDIR /**/ - -/* HAS_READLINK: - * This symbol, if defined, indicates that the readlink routine is - * available to read the value of a symbolic link. - */ -/*#define HAS_READLINK /**/ - -/* HAS_RENAME: - * This symbol, if defined, indicates that the rename routine is available - * to rename files. Otherwise you should do the unlink(), link(), unlink() - * trick. - */ -#define HAS_RENAME /**/ - -/* HAS_RMDIR: - * This symbol, if defined, indicates that the rmdir routine is - * available to remove directories. Otherwise you should fork off a - * new process to exec /bin/rmdir. - */ -#define HAS_RMDIR /**/ - -/* HAS_SAFE_BCOPY: - * This symbol, if defined, indicates that the bcopy routine is available - * to copy potentially overlapping memory blocks. Otherwise you should - * probably use memmove() or memcpy(). If neither is defined, roll your - * own version. - */ -/*#define HAS_SAFE_BCOPY /**/ - -/* HAS_SAFE_MEMCPY: - * This symbol, if defined, indicates that the memcpy routine is available - * to copy potentially overlapping memory blocks. Otherwise you should - * probably use memmove() or memcpy(). If neither is defined, roll your - * own version. - */ -/*#define HAS_SAFE_MEMCPY /**/ - -/* HAS_SANE_MEMCMP: - * This symbol, if defined, indicates that the memcmp routine is available - * and can be used to compare relative magnitudes of chars with their high - * bits set. If it is not defined, roll your own version. - */ -#define HAS_SANE_MEMCMP /**/ - -/* HAS_SELECT: - * This symbol, if defined, indicates that the select routine is - * available to select active file descriptors. If the timeout field - * is used, <sys/time.h> may need to be included. - */ -#define HAS_SELECT /**/ - -/* HAS_SEM: - * This symbol, if defined, indicates that the entire sem*(2) library is - * supported. - */ -/*#define HAS_SEM /**/ - -/* HAS_SETEGID: - * This symbol, if defined, indicates that the setegid routine is available - * to change the effective gid of the current program. - */ -/*#define HAS_SETEGID /**/ - -/* HAS_SETEUID: - * This symbol, if defined, indicates that the seteuid routine is available - * to change the effective uid of the current program. - */ -/*#define HAS_SETEUID /**/ - -/* HAS_SETLINEBUF: - * This symbol, if defined, indicates that the setlinebuf routine is - * available to change stderr or stdout from block-buffered or unbuffered - * to a line-buffered mode. - */ -/*#define HAS_SETLINEBUF /**/ - -/* HAS_SETLOCALE: - * This symbol, if defined, indicates that the setlocale routine is - * available to handle locale-specific ctype implementations. - */ -#define HAS_SETLOCALE /**/ - -/* HAS_SETPGRP2: - * This symbol, if defined, indicates that the setpgrp2() (as in DG/UX) - * routine is available to set the current process group. - */ -/*#define HAS_SETPGRP2 /**/ - -/* HAS_SETPRIORITY: - * This symbol, if defined, indicates that the setpriority routine is - * available to set a process's priority. - */ -/*#define HAS_SETPRIORITY /**/ - -/* HAS_SETREGID: - * This symbol, if defined, indicates that the setregid routine is - * available to change the real and effective gid of the current - * process. - */ -/* HAS_SETRESGID: - * This symbol, if defined, indicates that the setresgid routine is - * available to change the real, effective and saved gid of the current - * process. - */ -/*#define HAS_SETREGID /**/ -/*#define HAS_SETRESGID /**/ - -/* HAS_SETREUID: - * This symbol, if defined, indicates that the setreuid routine is - * available to change the real and effective uid of the current - * process. - */ -/* HAS_SETRESUID: - * This symbol, if defined, indicates that the setresuid routine is - * available to change the real, effective and saved uid of the current - * process. - */ -/*#define HAS_SETREUID /**/ -/*#define HAS_SETRESUID /**/ - -/* HAS_SETRGID: - * This symbol, if defined, indicates that the setrgid routine is available - * to change the real gid of the current program. - */ -/*#define HAS_SETRGID /**/ - -/* HAS_SETRUID: - * This symbol, if defined, indicates that the setruid routine is available - * to change the real uid of the current program. - */ -/*#define HAS_SETRUID /**/ - -/* HAS_SETSID: - * This symbol, if defined, indicates that the setsid routine is - * available to set the process group ID. - */ -/*#define HAS_SETSID /**/ - -/* HAS_SHM: - * This symbol, if defined, indicates that the entire shm*(2) library is - * supported. - */ -/*#define HAS_SHM /**/ - -/* Shmat_t: - * This symbol holds the return type of the shmat() system call. - * Usually set to 'void *' or 'char *'. - */ -/* HAS_SHMAT_PROTOTYPE: - * This symbol, if defined, indicates that the sys/shm.h includes - * a prototype for shmat(). Otherwise, it is up to the program to - * guess one. Shmat_t shmat _((int, Shmat_t, int)) is a good guess, - * but not always right so it should be emitted by the program only - * when HAS_SHMAT_PROTOTYPE is not defined to avoid conflicting defs. - */ -#define Shmat_t void * /**/ -/*#define HAS_SHMAT_PROTOTYPE /**/ - -/* HAS_SIGACTION: - * This symbol, if defined, indicates that Vr4's sigaction() routine - * is available. - */ -/*#define HAS_SIGACTION /**/ - -/* HAS_SOCKET: - * This symbol, if defined, indicates that the BSD socket interface is - * supported. - */ -/* HAS_SOCKETPAIR: - * This symbol, if defined, indicates that the BSD socketpair() call is - * supported. - */ -#define HAS_SOCKET /**/ -/*#define HAS_SOCKETPAIR /**/ - -/* USE_STAT_BLOCKS: - * This symbol is defined if this system has a stat structure declaring - * st_blksize and st_blocks. - */ -/*#define USE_STAT_BLOCKS /**/ - -/* USE_STDIO_PTR: - * This symbol is defined if the _ptr and _cnt fields (or similar) - * of the stdio FILE structure can be used to access the stdio buffer - * for a file handle. If this is defined, then the FILE_ptr(fp) - * and FILE_cnt(fp) macros will also be defined and should be used - * to access these fields. - */ -/* FILE_ptr: - * This macro is used to access the _ptr field (or equivalent) of the - * FILE structure pointed to by its argument. This macro will always be - * defined if USE_STDIO_PTR is defined. - */ -/* STDIO_PTR_LVALUE: - * This symbol is defined if the FILE_ptr macro can be used as an - * lvalue. - */ -/* FILE_cnt: - * This macro is used to access the _cnt field (or equivalent) of the - * FILE structure pointed to by its argument. This macro will always be - * defined if USE_STDIO_PTR is defined. - */ -/* STDIO_CNT_LVALUE: - * This symbol is defined if the FILE_cnt macro can be used as an - * lvalue. - */ -#define USE_STDIO_PTR /**/ -#ifdef USE_STDIO_PTR -#define FILE_ptr(fp) ((fp)->_ptr) -#define STDIO_PTR_LVALUE /**/ -#define FILE_cnt(fp) ((fp)->_cnt) -#define STDIO_CNT_LVALUE /**/ -#endif - -/* USE_STDIO_BASE: - * This symbol is defined if the _base field (or similar) of the - * stdio FILE structure can be used to access the stdio buffer for - * a file handle. If this is defined, then the FILE_base(fp) macro - * will also be defined and should be used to access this field. - * Also, the FILE_bufsiz(fp) macro will be defined and should be used - * to determine the number of bytes in the buffer. USE_STDIO_BASE - * will never be defined unless USE_STDIO_PTR is. - */ -/* FILE_base: - * This macro is used to access the _base field (or equivalent) of the - * FILE structure pointed to by its argument. This macro will always be - * defined if USE_STDIO_BASE is defined. - */ -/* FILE_bufsiz: - * This macro is used to determine the number of bytes in the I/O - * buffer pointed to by _base field (or equivalent) of the FILE - * structure pointed to its argument. This macro will always be defined - * if USE_STDIO_BASE is defined. - */ -#define USE_STDIO_BASE /**/ -#ifdef USE_STDIO_BASE -#define FILE_base(fp) ((fp)->_base) -#define FILE_bufsiz(fp) ((fp)->_cnt + (fp)->_ptr - (fp)->_base) -#endif - -/* HAS_STRCHR: - * This symbol is defined to indicate that the strchr()/strrchr() - * functions are available for string searching. If not, try the - * index()/rindex() pair. - */ -/* HAS_INDEX: - * This symbol is defined to indicate that the index()/rindex() - * functions are available for string searching. - */ -#define HAS_STRCHR /**/ -/*#define HAS_INDEX /**/ - -/* HAS_STRCOLL: - * This symbol, if defined, indicates that the strcoll routine is - * available to compare strings using collating information. - */ -#define HAS_STRCOLL /**/ - -/* USE_STRUCT_COPY: - * This symbol, if defined, indicates that this C compiler knows how - * to copy structures. If undefined, you'll need to use a block copy - * routine of some sort instead. - */ -#define USE_STRUCT_COPY /**/ - -/* HAS_STRERROR: - * This symbol, if defined, indicates that the strerror routine is - * available to translate error numbers to strings. See the writeup - * of Strerror() in this file before you try to define your own. - */ -/* HAS_SYS_ERRLIST: - * This symbol, if defined, indicates that the sys_errlist array is - * available to translate error numbers to strings. The extern int - * sys_nerr gives the size of that table. - */ -/* Strerror: - * This preprocessor symbol is defined as a macro if strerror() is - * not available to translate error numbers to strings but sys_errlist[] - * array is there. - */ -#define HAS_STRERROR /**/ -#define HAS_SYS_ERRLIST /**/ -#define Strerror(e) strerror(e) - -/* HAS_STRTOD: - * This symbol, if defined, indicates that the strtod routine is - * available to provide better numeric string conversion than atof(). - */ -#define HAS_STRTOD /**/ - -/* HAS_STRTOL: - * This symbol, if defined, indicates that the strtol routine is available - * to provide better numeric string conversion than atoi() and friends. - */ -#define HAS_STRTOL /**/ - -/* HAS_STRTOUL: - * This symbol, if defined, indicates that the strtoul routine is - * available to provide conversion of strings to unsigned long. - */ -#define HAS_STRTOUL /**/ - -/* HAS_STRXFRM: - * This symbol, if defined, indicates that the strxfrm() routine is - * available to transform strings. - */ -#define HAS_STRXFRM /**/ - -/* HAS_SYMLINK: - * This symbol, if defined, indicates that the symlink routine is available - * to create symbolic links. - */ -/*#define HAS_SYMLINK /**/ - -/* HAS_SYSCALL: - * This symbol, if defined, indicates that the syscall routine is - * available to call arbitrary system calls. If undefined, that's tough. - */ -/*#define HAS_SYSCALL /**/ - -/* HAS_SYSCONF: - * This symbol, if defined, indicates that sysconf() is available - * to determine system related limits and options. - */ -/*#define HAS_SYSCONF /**/ - -/* HAS_SYSTEM: - * This symbol, if defined, indicates that the system routine is - * available to issue a shell command. - */ -#define HAS_SYSTEM /**/ - -/* HAS_TCGETPGRP: - * This symbol, if defined, indicates that the tcgetpgrp routine is - * available to get foreground process group ID. - */ -/*#define HAS_TCGETPGRP /**/ - -/* HAS_TCSETPGRP: - * This symbol, if defined, indicates that the tcsetpgrp routine is - * available to set foreground process group ID. - */ -/*#define HAS_TCSETPGRP /**/ - -/* Time_t: - * This symbol holds the type returned by time(). It can be long, - * or time_t on BSD sites (in which case <sys/types.h> should be - * included). - */ -#define Time_t time_t /* Time type */ - -/* HAS_TIMES: - * This symbol, if defined, indicates that the times() routine exists. - * Note that this became obsolete on some systems (SUNOS), which now - * use getrusage(). It may be necessary to include <sys/times.h>. - */ -#define HAS_TIMES /**/ - -/* HAS_TRUNCATE: - * This symbol, if defined, indicates that the truncate routine is - * available to truncate files. - */ -/*#define HAS_TRUNCATE /**/ - -/* HAS_TZNAME: - * This symbol, if defined, indicates that the tzname[] array is - * available to access timezone names. - */ -#define HAS_TZNAME /**/ - -/* HAS_UMASK: - * This symbol, if defined, indicates that the umask routine is - * available to set and get the value of the file creation mask. - */ -#define HAS_UMASK /**/ - -/* HAS_VFORK: - * This symbol, if defined, indicates that vfork() exists. - */ -/*#define HAS_VFORK /**/ - -/* Signal_t: - * This symbol's value is either "void" or "int", corresponding to the - * appropriate return type of a signal handler. Thus, you can declare - * a signal handler using "Signal_t (*handler)()", and define the - * handler using "Signal_t handler(sig)". - */ -#define Signal_t void /* Signal handler's return type */ - -/* HASVOLATILE: - * This symbol, if defined, indicates that this C compiler knows about - * the volatile declaration. - */ -#define HASVOLATILE /**/ -#ifndef HASVOLATILE -#define volatile -#endif - -/* HAS_VPRINTF: - * This symbol, if defined, indicates that the vprintf routine is available - * to printf with a pointer to an argument list. If unavailable, you - * may need to write your own, probably in terms of _doprnt(). - */ -/* USE_CHAR_VSPRINTF: - * This symbol is defined if this system has vsprintf() returning type - * (char*). The trend seems to be to declare it as "int vsprintf()". It - * is up to the package author to declare vsprintf correctly based on the - * symbol. - */ -#define HAS_VPRINTF /**/ -/*#define USE_CHAR_VSPRINTF /**/ - -/* HAS_WAIT4: - * This symbol, if defined, indicates that wait4() exists. - */ -/*#define HAS_WAIT4 /**/ - -/* HAS_WAITPID: - * This symbol, if defined, indicates that the waitpid routine is - * available to wait for child process. - */ -/*#define HAS_WAITPID /**/ - -/* HAS_WCSTOMBS: - * This symbol, if defined, indicates that the wcstombs routine is - * available to convert wide character strings to multibyte strings. - */ -#define HAS_WCSTOMBS /**/ - -/* HAS_WCTOMB: - * This symbol, if defined, indicates that the wctomb routine is available - * to covert a wide character to a multibyte. - */ -#define HAS_WCTOMB /**/ - -/* Fpos_t: - * This symbol holds the type used to declare file positions in libc. - * It can be fpos_t, long, uint, etc... It may be necessary to include - * <sys/types.h> to get any typedef'ed information. - */ -#define Fpos_t fpos_t /* File position type */ - -/* Gid_t: - * This symbol holds the return type of getgid() and the type of - * argument to setrgid() and related functions. Typically, - * it is the type of group ids in the kernel. It can be int, ushort, - * uid_t, etc... It may be necessary to include <sys/types.h> to get - * any typedef'ed information. - */ -#define Gid_t gid_t /* Type for getgid(), etc... */ - -/* Groups_t: - * This symbol holds the type used for the second argument to - * [gs]etgroups(). Usually, this is the same of gidtype, but - * sometimes it isn't. It can be int, ushort, uid_t, etc... - * It may be necessary to include <sys/types.h> to get any - * typedef'ed information. This is only required if you have - * getgroups() or setgroups(). - */ -#if defined(HAS_GETGROUPS) || defined(HAS_SETGROUPS) -#define Groups_t gid_t /* Type for 2nd arg to [gs]etgroups() */ -#endif - -/* DB_Prefix_t: - * This symbol contains the type of the prefix structure element - * in the <db.h> header file. In older versions of DB, it was - * int, while in newer ones it is u_int32_t. - */ -/* DB_Hash_t: - * This symbol contains the type of the prefix structure element - * in the <db.h> header file. In older versions of DB, it was - * int, while in newer ones it is size_t. - */ -#define DB_Hash_t int /**/ -#define DB_Prefix_t int /**/ - -/* I_DIRENT: - * This symbol, if defined, indicates to the C program that it should - * include <dirent.h>. Using this symbol also triggers the definition - * of the Direntry_t define which ends up being 'struct dirent' or - * 'struct direct' depending on the availability of <dirent.h>. - */ -/* DIRNAMLEN: - * This symbol, if defined, indicates to the C program that the length - * of directory entry names is provided by a d_namlen field. Otherwise - * you need to do strlen() on the d_name field. - */ -/* Direntry_t: - * This symbol is set to 'struct direct' or 'struct dirent' depending on - * whether dirent is available or not. You should use this pseudo type to - * portably declare your directory entries. - */ -#define I_DIRENT /**/ -#define DIRNAMLEN /**/ -#define Direntry_t struct direct - -/* I_DLFCN: - * This symbol, if defined, indicates that <dlfcn.h> exists and should - * be included. - */ -#define I_DLFCN /**/ - -/* I_FCNTL: - * This manifest constant tells the C program to include <fcntl.h>. - */ -#define I_FCNTL /**/ - -/* I_FLOAT: - * This symbol, if defined, indicates to the C program that it should - * include <float.h> to get definition of symbols like DBL_MAX or - * DBL_MIN, i.e. machine dependent floating point values. - */ -#define I_FLOAT /**/ - -/* I_GRP: - * This symbol, if defined, indicates to the C program that it should - * include <grp.h>. - */ -#define I_GRP /**/ - -/* I_LIMITS: - * This symbol, if defined, indicates to the C program that it should - * include <limits.h> to get definition of symbols like WORD_BIT or - * LONG_MAX, i.e. machine dependant limitations. - */ -#define I_LIMITS /**/ - -/* I_MATH: - * This symbol, if defined, indicates to the C program that it should - * include <math.h>. - */ -#define I_MATH /**/ - -/* I_MEMORY: - * This symbol, if defined, indicates to the C program that it should - * include <memory.h>. - */ -/*#define I_MEMORY /**/ - -/* I_NDBM: - * This symbol, if defined, indicates that <ndbm.h> exists and should - * be included. - */ -/*#define I_NDBM /**/ - -/* I_NET_ERRNO: - * This symbol, if defined, indicates that <net/errno.h> exists and - * should be included. - */ -/*#define I_NET_ERRNO /**/ - -/* I_NETINET_IN: - * This symbol, if defined, indicates to the C program that it should - * include <netinet/in.h>. Otherwise, you may try <sys/in.h>. - */ -/*#define I_NETINET_IN /**/ - -/* I_PWD: - * This symbol, if defined, indicates to the C program that it should - * include <pwd.h>. - */ -/* PWQUOTA: - * This symbol, if defined, indicates to the C program that struct passwd - * contains pw_quota. - */ -/* PWAGE: - * This symbol, if defined, indicates to the C program that struct passwd - * contains pw_age. - */ -/* PWCHANGE: - * This symbol, if defined, indicates to the C program that struct passwd - * contains pw_change. - */ -/* PWCLASS: - * This symbol, if defined, indicates to the C program that struct passwd - * contains pw_class. - */ -/* PWEXPIRE: - * This symbol, if defined, indicates to the C program that struct passwd - * contains pw_expire. - */ -/* PWCOMMENT: - * This symbol, if defined, indicates to the C program that struct passwd - * contains pw_comment. - */ -/*#define I_PWD /**/ -/*#define PWQUOTA /**/ -/*#define PWAGE /**/ -/*#define PWCHANGE /**/ -/*#define PWCLASS /**/ -/*#define PWEXPIRE /**/ -/*#define PWCOMMENT /**/ - -/* I_STDDEF: - * This symbol, if defined, indicates that <stddef.h> exists and should - * be included. - */ -#define I_STDDEF /**/ - -/* I_STDLIB: - * This symbol, if defined, indicates that <stdlib.h> exists and should - * be included. - */ -#define I_STDLIB /**/ - -/* I_STRING: - * This symbol, if defined, indicates to the C program that it should - * include <string.h> (USG systems) instead of <strings.h> (BSD systems). - */ -#define I_STRING /**/ - -/* I_SYS_DIR: - * This symbol, if defined, indicates to the C program that it should - * include <sys/dir.h>. - */ -/*#define I_SYS_DIR /**/ - -/* I_SYS_FILE: - * This symbol, if defined, indicates to the C program that it should - * include <sys/file.h> to get definition of R_OK and friends. - */ -/*#define I_SYS_FILE /**/ - -/* I_SYS_IOCTL: - * This symbol, if defined, indicates that <sys/ioctl.h> exists and should - * be included. Otherwise, include <sgtty.h> or <termio.h>. - */ -/*#define I_SYS_IOCTL /**/ - -/* I_SYS_NDIR: - * This symbol, if defined, indicates to the C program that it should - * include <sys/ndir.h>. - */ -/*#define I_SYS_NDIR /**/ - -/* I_SYS_PARAM: - * This symbol, if defined, indicates to the C program that it should - * include <sys/param.h>. - */ -/*#define I_SYS_PARAM /**/ - -/* I_SYS_RESOURCE: - * This symbol, if defined, indicates to the C program that it should - * include <sys/resource.h>. - */ -/*#define I_SYS_RESOURCE /**/ - -/* I_SYS_SELECT: - * This symbol, if defined, indicates to the C program that it should - * include <sys/select.h> in order to get definition of struct timeval. - */ -/*#define I_SYS_SELECT /**/ - -/* I_SYS_TIMES: - * This symbol, if defined, indicates to the C program that it should - * include <sys/times.h>. - */ -/*#define I_SYS_TIMES /**/ - -/* I_SYS_TYPES: - * This symbol, if defined, indicates to the C program that it should - * include <sys/types.h>. - */ -#define I_SYS_TYPES /**/ - -/* I_SYS_UN: - * This symbol, if defined, indicates to the C program that it should - * include <sys/un.h> to get UNIX domain socket definitions. - */ -/*#define I_SYS_UN /**/ - -/* I_SYS_WAIT: - * This symbol, if defined, indicates to the C program that it should - * include <sys/wait.h>. - */ -/*#define I_SYS_WAIT /**/ - -/* I_TERMIO: - * This symbol, if defined, indicates that the program should include - * <termio.h> rather than <sgtty.h>. There are also differences in - * the ioctl() calls that depend on the value of this symbol. - */ -/* I_TERMIOS: - * This symbol, if defined, indicates that the program should include - * the POSIX termios.h rather than sgtty.h or termio.h. - * There are also differences in the ioctl() calls that depend on the - * value of this symbol. - */ -/* I_SGTTY: - * This symbol, if defined, indicates that the program should include - * <sgtty.h> rather than <termio.h>. There are also differences in - * the ioctl() calls that depend on the value of this symbol. - */ -/*#define I_TERMIO /**/ -/*#define I_TERMIOS /**/ -/*#define I_SGTTY /**/ - -/* I_TIME: - * This symbol, if defined, indicates to the C program that it should - * include <time.h>. - */ -/* I_SYS_TIME: - * This symbol, if defined, indicates to the C program that it should - * include <sys/time.h>. - */ -/* I_SYS_TIME_KERNEL: - * This symbol, if defined, indicates to the C program that it should - * include <sys/time.h> with KERNEL defined. - */ -#define I_TIME /**/ -/*#define I_SYS_TIME /**/ -/*#define I_SYS_TIME_KERNEL /**/ - -/* I_UNISTD: - * This symbol, if defined, indicates to the C program that it should - * include <unistd.h>. - */ -/*#define I_UNISTD /**/ - -/* I_UTIME: - * This symbol, if defined, indicates to the C program that it should - * include <utime.h>. - */ -#define I_UTIME /**/ - -/* I_STDARG: - * This symbol, if defined, indicates that <stdarg.h> exists and should - * be included. - */ -/* I_VARARGS: - * This symbol, if defined, indicates to the C program that it should - * include <varargs.h>. - */ -#define I_STDARG /**/ -/*#define I_VARARGS /**/ - -/* I_VFORK: - * This symbol, if defined, indicates to the C program that it should - * include vfork.h. - */ -/*#define I_VFORK /**/ - -/* INTSIZE: - * This symbol contains the value of sizeof(int) so that the C - * preprocessor can make decisions based on it. - */ -/* LONGSIZE: - * This symbol contains the value of sizeof(long) so that the C - * preprocessor can make decisions based on it. - */ -/* SHORTSIZE: - * This symbol contains the value of sizeof(short) so that the C - * preprocessor can make decisions based on it. - */ -#define INTSIZE 4 /**/ -#define LONGSIZE 4 /**/ -#define SHORTSIZE 2 /**/ - -/* Off_t: - * This symbol holds the type used to declare offsets in the kernel. - * It can be int, long, off_t, etc... It may be necessary to include - * <sys/types.h> to get any typedef'ed information. - */ -#define Off_t off_t /* <offset> type */ - -/* Mode_t: - * This symbol holds the type used to declare file modes - * for systems calls. It is usually mode_t, but may be - * int or unsigned short. It may be necessary to include <sys/types.h> - * to get any typedef'ed information. - */ -#define Mode_t mode_t /* file mode parameter for system calls */ - -/* VAL_O_NONBLOCK: - * This symbol is to be used during open() or fcntl(F_SETFL) to turn on - * non-blocking I/O for the file descriptor. Note that there is no way - * back, i.e. you cannot turn it blocking again this way. If you wish to - * alternatively switch between blocking and non-blocking, use the - * ioctl(FIOSNBIO) call instead, but that is not supported by all devices. - */ -/* VAL_EAGAIN: - * This symbol holds the errno error code set by read() when no data was - * present on the non-blocking file descriptor. - */ -/* RD_NODATA: - * This symbol holds the return code from read() when no data is present - * on the non-blocking file descriptor. Be careful! If EOF_NONBLOCK is - * not defined, then you can't distinguish between no data and EOF by - * issuing a read(). You'll have to find another way to tell for sure! - */ -/* EOF_NONBLOCK: - * This symbol, if defined, indicates to the C program that a read() on - * a non-blocking file descriptor will return 0 on EOF, and not the value - * held in RD_NODATA (-1 usually, in that case!). - */ -#define VAL_O_NONBLOCK O_NONBLOCK -#define VAL_EAGAIN EAGAIN -#define RD_NODATA -1 -#define EOF_NONBLOCK - -/* CAN_PROTOTYPE: - * If defined, this macro indicates that the C compiler can handle - * function prototypes. - */ -/* _: - * This macro is used to declare function parameters for folks who want - * to make declarations with prototypes using a different style than - * the above macros. Use double parentheses. For example: - * - * int main _((int argc, char *argv[])); - */ -#define CAN_PROTOTYPE /**/ -#ifdef CAN_PROTOTYPE -#define _(args) args -#else -#define _(args) () -#endif - -/* RANDBITS: - * This symbol contains the number of bits of random number the rand() - * function produces. Usual values are 15, 16, and 31. - */ -#define RANDBITS 15 /**/ - -/* Select_fd_set_t: - * This symbol holds the type used for the 2nd, 3rd, and 4th - * arguments to select. Usually, this is 'fd_set *', if HAS_FD_SET - * is defined, and 'int *' otherwise. This is only useful if you - * have select(), of course. - */ -#define Select_fd_set_t int * /**/ - -/* Size_t: - * This symbol holds the type used to declare length parameters - * for string functions. It is usually size_t, but may be - * unsigned long, int, etc. It may be necessary to include - * <sys/types.h> to get any typedef'ed information. - */ -#define Size_t size_t /* length paramater for string functions */ - -/* SSize_t: - * This symbol holds the type used by functions that return - * a count of bytes or an error condition. It must be a signed type. - * It is usually ssize_t, but may be long or int, etc. - * It may be necessary to include <sys/types.h> or <unistd.h> - * to get any typedef'ed information. - * We will pick a type such that sizeof(SSize_t) == sizeof(Size_t). - */ -#define SSize_t int /* signed count of bytes */ - -/* STDCHAR: - * This symbol is defined to be the type of char used in stdio.h. - * It has the values "unsigned char" or "char". - */ -#define STDCHAR unsigned char /**/ - -/* Uid_t: - * This symbol holds the type used to declare user ids in the kernel. - * It can be int, ushort, uid_t, etc... It may be necessary to include - * <sys/types.h> to get any typedef'ed information. - */ -#define Uid_t uid_t /* UID type */ - -/* LOC_SED: - * This symbol holds the complete pathname to the sed program. - */ -#define LOC_SED "" /**/ - -/* OSNAME: - * This symbol contains the name of the operating system, as determined - * by Configure. You shouldn't rely on it too much; the specific - * feature tests from Configure are generally more reliable. - */ -#define OSNAME "MSWin32" /**/ - -/* ARCHLIB: - * This variable, if defined, holds the name of the directory in - * which the user wants to put architecture-dependent public - * library files for perl5. It is most often a local directory - * such as /usr/local/lib. Programs using this variable must be - * prepared to deal with filename expansion. If ARCHLIB is the - * same as PRIVLIB, it is not defined, since presumably the - * program already searches PRIVLIB. - */ -/* ARCHLIB_EXP: - * This symbol contains the ~name expanded version of ARCHLIB, to be used - * in programs that are not prepared to deal with ~ expansion at run-time. - */ -#define ARCHLIB "c:\\perl\\lib" /**/ -#define ARCHLIB_EXP (win32PerlLibPath()) /**/ - -/* BINCOMPAT3: - * This symbol, if defined, indicates that Perl 5.004 should be - * binary-compatible with Perl 5.003. - */ -/*#define BINCOMPAT3 /**/ - -/* BYTEORDER: - * This symbol holds the hexadecimal constant defined in byteorder, - * i.e. 0x1234 or 0x4321, etc... - * On NeXT 4 (and greater), you can build "Fat" Multiple Architecture - * Binaries (MAB) on either big endian or little endian machines. - * The endian-ness is available at compile-time. This only matters - * for perl, where the config.h can be generated and installed on - * one system, and used by a different architecture to build an - * extension. Older versions of NeXT that might not have - * defined either *_ENDIAN__ were all on Motorola 680x0 series, - * so the default case (for NeXT) is big endian to catch them. - * This might matter for NeXT 3.0. - */ -#ifndef NeXT -#define BYTEORDER 0x1234 /* large digits for MSB */ -#else /* NeXT */ -#ifdef __LITTLE_ENDIAN__ -#define BYTEORDER 0x1234 -#else /* __BIG_ENDIAN__ */ -#define BYTEORDER 0x4321 -#endif /* ENDIAN CHECK */ -#endif /* NeXT */ - -/* CSH: - * This symbol, if defined, indicates that the C-shell exists. - * If defined, contains the full pathname of csh. - */ -/*#define CSH "" /**/ - -/* DLSYM_NEEDS_UNDERSCORE: - * This symbol, if defined, indicates that we need to prepend an - * underscore to the symbol name before calling dlsym(). This only - * makes sense if you *have* dlsym, which we will presume is the - * case if you're using dl_dlopen.xs. - */ -/*#define DLSYM_NEEDS_UNDERSCORE /**/ - -/* SETUID_SCRIPTS_ARE_SECURE_NOW: - * This symbol, if defined, indicates that the bug that prevents - * setuid scripts from being secure is not present in this kernel. - */ -/* DOSUID: - * This symbol, if defined, indicates that the C program should - * check the script that it is executing for setuid/setgid bits, and - * attempt to emulate setuid/setgid on systems that have disabled - * setuid #! scripts because the kernel can't do it securely. - * It is up to the package designer to make sure that this emulation - * is done securely. Among other things, it should do an fstat on - * the script it just opened to make sure it really is a setuid/setgid - * script, it should make sure the arguments passed correspond exactly - * to the argument on the #! line, and it should not trust any - * subprocesses to which it must pass the filename rather than the - * file descriptor of the script to be executed. - */ -/*#define SETUID_SCRIPTS_ARE_SECURE_NOW /**/ -/*#define DOSUID /**/ - -/* Gconvert: - * This preprocessor macro is defined to convert a floating point - * number to a string without a trailing decimal point. This - * emulates the behavior of sprintf("%g"), but is sometimes much more - * efficient. If gconvert() is not available, but gcvt() drops the - * trailing decimal point, then gcvt() is used. If all else fails, - * a macro using sprintf("%g") is used. Arguments for the Gconvert - * macro are: value, number of digits, whether trailing zeros should - * be retained, and the output buffer. - * Possible values are: - * d_Gconvert='gconvert((x),(n),(t),(b))' - * d_Gconvert='gcvt((x),(n),(b))' - * d_Gconvert='sprintf((b),"%.*g",(n),(x))' - * The last two assume trailing zeros should not be kept. - */ -#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x)) - -/* HAS_GETPGID: - * This symbol, if defined, indicates to the C program that - * the getpgid(pid) function is available to get the - * process group id. - */ -/*#define HAS_GETPGID /**/ - -/* HAS_GETPGRP: - * This symbol, if defined, indicates that the getpgrp routine is - * available to get the current process group. - */ -/* USE_BSD_GETPGRP: - * This symbol, if defined, indicates that getpgrp needs one - * arguments whereas USG one needs none. - */ -/*#define HAS_GETPGRP /**/ -/*#define USE_BSD_GETPGRP /**/ - -/* HAS_INET_ATON: - * This symbol, if defined, indicates to the C program that the - * inet_aton() function is available to parse IP address "dotted-quad" - * strings. - */ -/*#define HAS_INET_ATON /**/ - -/* HAS_SETPGID: - * This symbol, if defined, indicates to the C program that - * the setpgid(pid, gpid) function is available to set the - * process group id. - */ -/*#define HAS_SETPGID /**/ - -/* HAS_SETPGRP: - * This symbol, if defined, indicates that the setpgrp routine is - * available to set the current process group. - */ -/* USE_BSD_SETPGRP: - * This symbol, if defined, indicates that setpgrp needs two - * arguments whereas USG one needs none. See also HAS_SETPGID - * for a POSIX interface. - */ -/* USE_BSDPGRP: - * This symbol, if defined, indicates that the BSD notion of process - * group is to be used. For instance, you have to say setpgrp(pid, pgrp) - * instead of the USG setpgrp(). This should be obsolete since - * there are systems which have BSD-ish setpgrp but USG-ish getpgrp. - */ -/*#define HAS_SETPGRP /**/ -/*#define USE_BSD_SETPGRP /**/ -/*#define USE_BSDPGRP /**/ - -/* USE_SFIO: - * This symbol, if defined, indicates that sfio should - * be used. - */ -/*#define USE_SFIO /**/ - -/* Sigjmp_buf: - * This is the buffer type to be used with Sigsetjmp and Siglongjmp. - */ -/* Sigsetjmp: - * This macro is used in the same way as sigsetjmp(), but will invoke - * traditional setjmp() if sigsetjmp isn't available. - * See HAS_SIGSETJMP. - */ -/* Siglongjmp: - * This macro is used in the same way as siglongjmp(), but will invoke - * traditional longjmp() if siglongjmp isn't available. - * See HAS_SIGSETJMP. - */ -/*#define HAS_SIGSETJMP /**/ -#ifdef HAS_SIGSETJMP -#define Sigjmp_buf sigjmp_buf -#define Sigsetjmp(buf,save_mask) sigsetjmp((buf),(save_mask)) -#define Siglongjmp(buf,retval) siglongjmp((buf),(retval)) -#else -#define Sigjmp_buf jmp_buf -#define Sigsetjmp(buf,save_mask) setjmp((buf)) -#define Siglongjmp(buf,retval) longjmp((buf),(retval)) -#endif - -/* USE_DYNAMIC_LOADING: - * This symbol, if defined, indicates that dynamic loading of - * some sort is available. - */ -#define USE_DYNAMIC_LOADING /**/ - -/* I_DBM: - * This symbol, if defined, indicates that <dbm.h> exists and should - * be included. - */ -/* I_RPCSVC_DBM: - * This symbol, if defined, indicates that <rpcsvc/dbm.h> exists and - * should be included. - */ -/*#define I_DBM /**/ -#define I_RPCSVC_DBM /**/ - -/* I_LOCALE: - * This symbol, if defined, indicates to the C program that it should - * include <locale.h>. - */ -#define I_LOCALE /**/ - -/* I_SFIO: - * This symbol, if defined, indicates to the C program that it should - * include <sfio.h>. - */ -/*#define I_SFIO /**/ - -/* I_SYS_STAT: - * This symbol, if defined, indicates to the C program that it should - * include <sys/stat.h>. - */ -#define I_SYS_STAT /**/ - -/* I_VALUES: - * This symbol, if defined, indicates to the C program that it should - * include <values.h> to get definition of symbols like MINFLOAT or - * MAXLONG, i.e. machine dependant limitations. Probably, you - * should use <limits.h> instead, if it is available. - */ -/*#define I_VALUES /**/ - -/* Free_t: - * This variable contains the return type of free(). It is usually - * void, but occasionally int. - */ -/* Malloc_t: - * This symbol is the type of pointer returned by malloc and realloc. - */ -#define Malloc_t void * /**/ -#define Free_t void /**/ - -/* MYMALLOC: - * This symbol, if defined, indicates that we're using our own malloc. - */ -/*#define MYMALLOC /**/ - -/* OLDARCHLIB: - * This variable, if defined, holds the name of the directory in - * which the user has perl5.000 or perl5.001 architecture-dependent - * public library files for perl5. For the most part, these - * files will work with 5.002 (and later), but that is not - * guaranteed. - */ -/* OLDARCHLIB_EXP: - * This symbol contains the ~name expanded version of OLDARCHLIB, to be - * used in programs that are not prepared to deal with ~ expansion at - * run-time. - */ -/*#define OLDARCHLIB "" /**/ -/*#define OLDARCHLIB_EXP "" /**/ - -/* PRIVLIB: - * This symbol contains the name of the private library for this package. - * The library is private in the sense that it needn't be in anyone's - * execution path, but it should be accessible by the world. The program - * should be prepared to do ~ expansion. - */ -/* PRIVLIB_EXP: - * This symbol contains the ~name expanded version of PRIVLIB, to be used - * in programs that are not prepared to deal with ~ expansion at run-time. - */ -#define PRIVLIB "c:\\perl\\lib" /**/ -#define PRIVLIB_EXP "c:\\perl\\lib" /**/ - -/* SH_PATH: - * This symbol contains the full pathname to the shell used on this - * on this system to execute Bourne shell scripts. Usually, this will be - * /bin/sh, though it's possible that some systems will have /bin/ksh, - * /bin/pdksh, /bin/ash, /bin/bash, or even something such as - * D:/bin/sh.exe. - */ -#define SH_PATH "cmd /x /c" /**/ - -/* SIG_NAME: - * This symbol contains a list of signal names in order of - * signal number. This is intended - * to be used as a static array initialization, like this: - * char *sig_name[] = { SIG_NAME }; - * The signals in the list are separated with commas, and each signal - * is surrounded by double quotes. There is no leading SIG in the signal - * name, i.e. SIGQUIT is known as "QUIT". - * Gaps in the signal numbers (up to NSIG) are filled in with NUMnn, - * etc., where nn is the actual signal number (e.g. NUM37). - * The signal number for sig_name[i] is stored in sig_num[i]. - * The last element is 0 to terminate the list with a NULL. This - * corresponds to the 0 at the end of the sig_num list. - */ -/* SIG_NUM: - * This symbol contains a list of signal numbers, in the same order as the - * SIG_NAME list. It is suitable for static array initialization, as in: - * int sig_num[] = { SIG_NUM }; - * The signals in the list are separated with commas, and the indices - * within that list and the SIG_NAME list match, so it's easy to compute - * the signal name from a number or vice versa at the price of a small - * dynamic linear lookup. - * Duplicates are allowed, but are moved to the end of the list. - * The signal number corresponding to sig_name[i] is sig_number[i]. - * if (i < NSIG) then sig_number[i] == i. - * The last element is 0, corresponding to the 0 at the end of - * the sig_name list. - */ -#define SIG_NAME "ZERO","HUP","INT","QUIT","ILL","TRAP","ABRT","EMT","FPE","KILL","BUS","SEGV","SYS","PIPE","ALRM","TERM","USR1","USR2","CHLD","PWR","WINCH","URG","IO","STOP","TSTP","CONT","TTIN","TTOU","VTALRM","PROF","XCPU","XFSZ","WAITING","LWP","FREEZE","THAW","RTMIN","NUM37","NUM38","NUM39","NUM40","NUM41","NUM42","RTMAX","IOT","CLD","POLL",0 /**/ -#define SIG_NUM 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,6,18,22,0 /**/ - -/* SITEARCH: - * This symbol contains the name of the private library for this package. - * The library is private in the sense that it needn't be in anyone's - * execution path, but it should be accessible by the world. The program - * should be prepared to do ~ expansion. - * The standard distribution will put nothing in this directory. - * Individual sites may place their own extensions and modules in - * this directory. - */ -/* SITEARCH_EXP: - * This symbol contains the ~name expanded version of SITEARCH, to be used - * in programs that are not prepared to deal with ~ expansion at run-time. - */ -#define SITEARCH "c:\\perl\\lib\\site" /**/ -#define SITEARCH_EXP "c:\\perl\\lib\\site" /**/ - -/* SITELIB: - * This symbol contains the name of the private library for this package. - * The library is private in the sense that it needn't be in anyone's - * execution path, but it should be accessible by the world. The program - * should be prepared to do ~ expansion. - * The standard distribution will put nothing in this directory. - * Individual sites may place their own extensions and modules in - * this directory. - */ -/* SITELIB_EXP: - * This symbol contains the ~name expanded version of SITELIB, to be used - * in programs that are not prepared to deal with ~ expansion at run-time. - */ -#define SITELIB "c:\\perl\\lib\\site" /**/ -#define SITELIB_EXP "c:\\perl\\lib\\site" /**/ - -/* STARTPERL: - * This variable contains the string to put in front of a perl - * script to make sure (one hopes) that it runs with perl and not - * some shell. - */ -#define STARTPERL "#perl" /**/ - -/* USE_PERLIO: - * This symbol, if defined, indicates that the PerlIO abstraction should - * be used throughout. If not defined, stdio should be - * used in a fully backward compatible manner. - */ -/*#define USE_PERLIO /**/ - -/* VOIDFLAGS: - * This symbol indicates how much support of the void type is given by this - * compiler. What various bits mean: - * - * 1 = supports declaration of void - * 2 = supports arrays of pointers to functions returning void - * 4 = supports comparisons between pointers to void functions and - * addresses of void functions - * 8 = suports declaration of generic void pointers - * - * The package designer should define VOIDUSED to indicate the requirements - * of the package. This can be done either by #defining VOIDUSED before - * including config.h, or by defining defvoidused in Myinit.U. If the - * latter approach is taken, only those flags will be tested. If the - * level of void support necessary is not present, defines void to int. - */ -#ifndef VOIDUSED -#define VOIDUSED 15 -#endif -#define VOIDFLAGS 15 -#if (VOIDFLAGS & VOIDUSED) != VOIDUSED -#define void int /* is void to be avoided? */ -#define M_VOID /* Xenix strikes again */ -#endif - -#endif -#include <win32.h> -#ifndef DEBUGGING -#define DEBUGGING -#endif diff --git a/win32/config.bc b/win32/config.bc index 3933c2789c..60e9b47e62 100644 --- a/win32/config.bc +++ b/win32/config.bc @@ -83,7 +83,7 @@ cryptlib='' csh='undef' d_Gconvert='gcvt((x),(n),(b))' d_access='define' -d_alarm='define' +d_alarm='undef' d_archlib='define' d_attribut='undef' d_bcmp='undef' diff --git a/win32/config.vc b/win32/config.vc index 188317478c..2bce3b230e 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -21,7 +21,6 @@ osname='MSWin32' osvers='4.0' prefix='~INST_DRV~' privlibexp='~INST_TOP~\lib' -ranlib='' sharpbang='#!' shsharp='true' sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM USR1 USR2 CHLD PWR WINCH URG IO STOP TSTP CONT TTIN TTOU VTALRM PROF XCPU XFSZ WAITING LWP FREEZE THAW RTMIN NUM37 NUM38 NUM39 NUM40 NUM41 NUM42 RTMAX IOT CLD POLL' diff --git a/win32/config.w32 b/win32/config.w32 deleted file mode 100644 index e977b17e07..0000000000 --- a/win32/config.w32 +++ /dev/null @@ -1,498 +0,0 @@ -# -## This file was hand coded and a lot of information is invalid -# -## Configured by: garyng -## Target system: WIN32 -# - -archlibexp='~INST_TOP~\lib' -archname='MSWin32' -cc='cl' -ccflags='-MD -DWIN32' -cppflags='-DWIN32' -dlsrc='dl_win32.xs' -dynamic_ext='Fcntl IO Opcode SDBM_File Socket' -extensions='Fcntl IO Opcode SDBM_File Socket' -installarchlib='~INST_TOP~\lib' -installprivlib='~INST_TOP~\lib' -libpth='' -libs='' -osname='MSWin32' -osvers='4.0' -prefix='~INST_DRV~' -privlibexp='~INST_TOP~\lib' -sharpbang='#!' -shsharp='true' -sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM USR1 USR2 CHLD PWR WINCH URG IO STOP TSTP CONT TTIN TTOU VTALRM PROF XCPU XFSZ WAITING LWP FREEZE THAW RTMIN NUM37 NUM38 NUM39 NUM40 NUM41 NUM42 RTMAX IOT CLD POLL' -so='dll' -startsh='#!/bin/sh' -static_ext=' ' -Author='' -CONFIG='true' -Date='$Date' -Header='' -Id='$Id' -Locker='' -Log='$Log' -Mcc='Mcc' -PATCHLEVEL='~PATCHLEVEL~' -POSIX_cflags='ccflags="$ccflags -DSTRUCT_TM_HASZONE"' -RCSfile='$RCSfile' -Revision='$Revision' -SUBVERSION='~SUBVERSION~' -Source='' -State='' -afs='false' -alignbytes='8' -aphostname='' -ar='ar' -archlib='~INST_TOP~\lib' -archobjs='' -awk='awk' -baserev='5.0' -bash='' -bin='~INST_TOP~\bin' -binexp='~INST_TOP~\bin' -bison='' -byacc='byacc' -byteorder='1234' -c='' -castflags='0' -cat='cat' -cccdlflags='' -ccdlflags=' ' -cf_by='garyng' -cf_email='71564.1743@compuserve.com' -cf_time='Thu Apr 11 06:20:49 PDT 1996' -chgrp='' -chmod='' -chown='' -clocktype='clock_t' -comm='comm' -compress='' -contains='grep' -cp='cp' -cpio='' -cpp='cpp' -cpp_stuff='42' -cpplast='' -cppminus='' -cpprun='cl -E' -cppstdin='cl -E' -cryptlib='' -csh='undef' -d_Gconvert='sprintf((b),"%.*g",(n),(x))' -d_access='define' -d_alarm='undef' -d_archlib='define' -d_attribut='undef' -d_bcmp='undef' -d_bcopy='undef' -d_bincompat3='undef' -d_bsd='define' -d_bsdgetpgrp='undef' -d_bsdpgrp='undef' -d_bsdsetpgrp='undef' -d_bzero='undef' -d_casti32='define' -d_castneg='define' -d_charvspr='undef' -d_chown='undef' -d_chroot='undef' -d_chsize='define' -d_closedir='define' -d_const='define' -d_crypt='undef' -d_csh='undef' -d_cuserid='undef' -d_dbl_dig='define' -d_difftime='define' -d_dirnamlen='define' -d_dlerror='define' -d_dlopen='define' -d_dlsymun='undef' -d_dosuid='undef' -d_dup2='define' -d_eofnblk='define' -d_eunice='undef' -d_fchmod='undef' -d_fchown='undef' -d_fcntl='undef' -d_fd_macros='define' -d_fd_set='define' -d_fds_bits='define' -d_fgetpos='define' -d_flexfnam='define' -d_flock='define' -d_fork='undef' -d_fpathconf='undef' -d_fsetpos='define' -d_getgrps='undef' -d_setgrps='undef' -d_gethent='undef' -d_gethname='undef' -d_getlogin='undef' -d_getpgrp2='undef' -d_getpgrp='undef' -d_getpgid='undef' -d_getppid='undef' -d_getprior='undef' -d_gettimeod='undef' -d_htonl='define' -d_index='undef' -d_inetaton='undef' -d_isascii='define' -d_killpg='undef' -d_link='undef' -d_locconv='define' -d_lockf='undef' -d_lstat='undef' -d_mblen='define' -d_mbstowcs='define' -d_mbtowc='define' -d_memcmp='define' -d_memcpy='define' -d_memmove='define' -d_memset='define' -d_mkdir='define' -d_mkfifo='undef' -d_mktime='define' -d_msg='undef' -d_msgctl='define' -d_msgget='define' -d_msgrcv='define' -d_msgsnd='define' -d_mymalloc='undef' -d_nice='undef' -d_oldarchlib='undef' -d_oldsock='undef' -d_open3='undef' -d_pathconf='undef' -d_pause='define' -d_phostname='undef' -d_pipe='define' -d_poll='undef' -d_portable='define' -d_pwage='undef' -d_pwchange='undef' -d_pwclass='undef' -d_pwcomment='undef' -d_pwexpire='undef' -d_pwquota='undef' -d_readdir='define' -d_readlink='undef' -d_rename='define' -d_rewinddir='define' -d_rmdir='define' -d_safebcpy='undef' -d_safemcpy='undef' -d_sanemcmp='define' -d_seekdir='define' -d_select='define' -d_sem='undef' -d_semctl='define' -d_semget='define' -d_semop='define' -d_setegid='undef' -d_seteuid='undef' -d_setlinebuf='undef' -d_setlocale='define' -d_setpgid='undef' -d_setpgrp2='undef' -d_setpgrp='undef' -d_setprior='undef' -d_setregid='undef' -d_setresgid='undef' -d_setresuid='undef' -d_setreuid='undef' -d_setrgid='undef' -d_setruid='undef' -d_setsid='undef' -d_sfio='undef' -d_shm='undef' -d_shmat='undef' -d_shmatprototype='undef' -d_shmctl='define' -d_shmdt='define' -d_shmget='define' -d_shrplib='undef' -d_sigaction='undef' -d_sigintrp='' -d_sigsetjmp='undef' -d_sigvec='define' -d_sigvectr='undef' -d_socket='define' -d_sockpair='undef' -d_statblks='undef' -d_stdio_cnt_lval='define' -d_stdio_ptr_lval='define' -d_stdiobase='define' -d_stdstdio='define' -d_strchr='define' -d_strcoll='define' -d_strctcpy='define' -d_strerrm='strerror(e)' -d_strerror='define' -d_strtod='define' -d_strtol='define' -d_strtoul='define' -d_strxfrm='define' -d_suidsafe='undef' -d_symlink='undef' -d_syscall='undef' -d_sysconf='undef' -d_sysernlst='' -d_syserrlst='define' -d_system='define' -d_tcgetpgrp='undef' -d_tcsetpgrp='undef' -d_telldir='define' -d_time='define' -d_times='define' -d_truncate='undef' -d_tzname='define' -d_umask='define' -d_uname='undef' -d_vfork='undef' -d_void_closedir='undef' -d_voidsig='define' -d_voidtty='' -d_volatile='define' -d_vprintf='define' -d_wait4='undef' -d_waitpid='undef' -d_wcstombs='define' -d_wctomb='define' -d_xenix='undef' -date='date' -db_hashtype='int' -db_prefixtype='int' -defvoidused='15' -direntrytype='struct direct' -dlext='dll' -eagain='EAGAIN' -echo='echo' -egrep='egrep' -emacs='' -eunicefix=':' -exe_ext='.exe' -expr='expr' -find='find' -firstmakefile='makefile' -flex='' -fpostype='fpos_t' -freetype='void' -full_csh='' -full_sed='' -gcc='' -gccversion='' -gidtype='gid_t' -glibpth='/usr/shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/shlib ' -grep='grep' -groupcat='' -groupstype='gid_t' -h_fcntl='false' -h_sysfile='true' -hint='recommended' -hostcat='ypcat hosts' -huge='' -i_bsdioctl='' -i_db='undef' -i_dbm='undef' -i_dirent='define' -i_dld='undef' -i_dlfcn='define' -i_fcntl='define' -i_float='define' -i_gdbm='define' -i_grp='define' -i_limits='define' -i_locale='define' -i_malloc='define' -i_math='define' -i_memory='undef' -i_ndbm='undef' -i_neterrno='undef' -i_niin='undef' -i_pwd='undef' -i_rpcsvcdbm='define' -i_sfio='undef' -i_sgtty='undef' -i_stdarg='define' -i_stddef='define' -i_stdlib='define' -i_string='define' -i_sysdir='undef' -i_sysfile='undef' -i_sysfilio='define' -i_sysin='undef' -i_sysioctl='undef' -i_sysndir='undef' -i_sysparam='undef' -i_sysresrc='undef' -i_sysselct='undef' -i_syssockio='' -i_sysstat='define' -i_systime='undef' -i_systimek='undef' -i_systimes='undef' -i_systypes='define' -i_sysun='undef' -i_syswait='undef' -i_termio='undef' -i_termios='undef' -i_time='define' -i_unistd='undef' -i_utime='define' -i_values='undef' -i_varargs='undef' -i_varhdr='varargs.h' -i_vfork='undef' -incpath='' -inews='' -installbin='~INST_TOP~\bin' -installman1dir='~INST_TOP~\man\man1' -installman3dir='~INST_TOP~\man\man3' -installscript='~INST_TOP~\bin' -installsitearch='~INST_TOP~\lib\site' -installsitelib='~INST_TOP~\lib\site' -intsize='4' -known_extensions='DB_File Fcntl GDBM_File NDBM_File ODBM_File Opcode POSIX SDBM_File Socket' -ksh='' -large='' -ld='link' -lddlflags='-dll' -ldflags='-nologo -subsystem:windows' -less='less' -lib_ext='.lib' -libc='msvcrt.lib' -libswanted='net socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x' -line='line' -lint='' -lkflags='' -ln='' -lns='' -locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt/gnu/include /usr/GNU/include /opt/GNU/include' -loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib' -longsize='4' -lp='' -lpr='' -ls='ls' -lseektype='off_t' -mail='' -mailx='' -make='nmake' -mallocobj='malloc.o' -mallocsrc='malloc.c' -malloctype='void *' -man1dir='~INST_TOP~\man\man1' -man1direxp='~INST_TOP~\man\man1' -man1ext='1' -man3dir='~INST_TOP~\man\man3' -man3direxp='~INST_TOP~\man\man3' -man3ext='3' -medium='' -mips='' -mips_type='' -mkdir='mkdir' -models='none' -modetype='mode_t' -more='more /e' -mv='' -myarchname='MSWin32' -mydomain='' -myhostname='' -myuname='' -n='-n' -nm_opt='' -nm_so_opt='' -nroff='' -o_nonblock='O_NONBLOCK' -obj_ext='.obj' -oldarchlib='' -oldarchlibexp='' -optimize='-O' -orderlib='false' -package='perl5' -pager='more /e' -passcat='' -patchlevel='2' -path_sep=';' -perl='perl' -perladmin='' -perlpath='~INST_TOP~\bin\perl.exe' -pg='pg' -phostname='hostname' -plibpth='' -pmake='' -pr='' -prefixexp='~INST_DRV~' -privlib='~INST_TOP~\lib' -prototype='define' -randbits='15' -ranlib='' -rd_nodata='-1' -rm='rm' -rmail='' -runnm='true' -scriptdir='~INST_TOP~\bin' -scriptdirexp='~INST_TOP~\bin' -sed='sed' -selecttype='int *' -sendmail='blat' -sh='cmd /x /c' -shar='' -shmattype='void *' -shortsize='2' -shrpdir='none' -sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 6 18 22' -signal_t='void' -sitearch='~INST_TOP~\lib\site' -sitearchexp='~INST_TOP~\lib\site' -sitelib='~INST_TOP~\lib\site' -sitelibexp='~INST_TOP~\lib\site' -sizetype='size_t' -sleep='' -smail='' -small='' -sockethdr='' -socketlib='' -sort='sort' -spackage='Perl5' -spitshell='cat' -split='' -ssizetype='int' -startperl='#perl' -stdchar='unsigned char' -stdio_base='((fp)->_base)' -stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)' -stdio_cnt='((fp)->_cnt)' -stdio_ptr='((fp)->_ptr)' -strings='/usr/include/string.h' -submit='' -sysman='/usr/man/man1' -tail='' -tar='' -tbl='' -test='test' -timeincl='/usr/include/sys/time.h ' -timetype='time_t' -touch='touch' -tr='tr' -troff='' -uidtype='uid_t' -uname='uname' -uniq='uniq' -usedl='define' -usemymalloc='n' -usenm='false' -useperlio='undef' -useposix='true' -usesafe='true' -usevfork='false' -usrinc='/usr/include' -uuname='' -vi='' -voidflags='15' -xlibpth='/usr/lib/386 /lib/386' -zcat='' diff --git a/win32/config_H.bc b/win32/config_H.bc index 460b58577c..61fb5a3241 100644 --- a/win32/config_H.bc +++ b/win32/config_H.bc @@ -113,7 +113,7 @@ * This symbol, if defined, indicates that the alarm routine is * available. */ -#define HAS_ALARM /**/ +/*#define HAS_ALARM /**/ /* HASATTRIBUTE: * This symbol indicates the C compiler can check for function attributes, diff --git a/win32/include/sys/socket.h b/win32/include/sys/socket.h index 9e5259b254..487f9d5877 100644 --- a/win32/include/sys/socket.h +++ b/win32/include/sys/socket.h @@ -115,6 +115,7 @@ void win32_endservent(void); #define recv win32_recv #define recvfrom win32_recvfrom #define shutdown win32_shutdown +#define closesocket win32_closesocket #define ioctlsocket win32_ioctlsocket #define setsockopt win32_setsockopt #define getsockopt win32_getsockopt diff --git a/win32/makedef.pl b/win32/makedef.pl index 8bc7a8a46a..abc89d848a 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -154,7 +154,11 @@ Perl_eval_mutex Perl_eval_cond Perl_eval_owner Perl_threads_mutex +Perl_new_struct_thread +Perl_nthreads Perl_nthreads_cond +Perl_per_thread_magicals +Perl_thrsv Perl_unlock_condpair Perl_vtbl_mutex Perl_magic_mutexfree @@ -347,6 +351,7 @@ win32_sendto win32_recv win32_recvfrom win32_shutdown +win32_closesocket win32_ioctlsocket win32_setsockopt win32_getsockopt @@ -390,8 +395,11 @@ win32_malloc win32_calloc win32_realloc win32_free -win32stdio +win32_sleep +win32_times +win32_alarm +win32_open_osfhandle +win32_get_osfhandle Perl_win32_init +Perl_init_os_extras RunPerl -SetIOSubSystem -GetIOSubSystem diff --git a/win32/makefile.mk b/win32/makefile.mk index 655efb7395..35baed5c5d 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -10,8 +10,8 @@ # Set these to wherever you want "nmake install" to put your # newly built perl. INST_DRV=c: -INST_TOP=$(INST_DRV)\perl\perl5004.5X -BUILDOPT=-DUSE_THREADS +INST_TOP=$(INST_DRV)\perl +BUILDOPT=-DUSE_THREADS # -DUSE_PERLIO -D__STDC__=1 -DUSE_SFIO -DI_SFIO -I\sfio97\include @@ -96,7 +96,7 @@ RUNTIME = -MD .ENDIF INCLUDES = -I.\include -I. -I.. #PCHFLAGS = -Fp$(INTDIR)\vcmoduls.pch -YX -DEFINES = -DWIN32 $(BUILDOPT) -D_CONSOLE -D_WIN32_WINNT=0x400 +DEFINES = -DWIN32 -D_CONSOLE $(BUILDOPT) LOCDEFS = -DPERLDLL SUBSYS = console @@ -105,7 +105,7 @@ LIBC = msvcrt.lib WINIOMAYBE = .ELSE LIBC = libcmt.lib -WINIOMAYBE = win32io.obj +WINIOMAYBE = .ENDIF .IF "$(CFG)" == "Debug" @@ -131,7 +131,7 @@ LIBFILES = oldnames.lib kernel32.lib user32.lib gdi32.lib \ version.lib odbc32.lib odbccp32.lib CFLAGS = -nologo -W3 $(INCLUDES) $(DEFINES) $(LOCDEFS) $(PCHFLAGS) $(OPTIMIZE) -LINK_FLAGS = -nologo $(LIBFILES) $(LINK_DBG) -machine:I386 +LINK_FLAGS = -nologo $(LIBFILES) $(LINK_DBG) -machine:$(PROCESSOR_ARCHITECTURE) OBJOUT_FLAG = -Fo .ENDIF @@ -265,18 +265,15 @@ CORE_OBJ= ..\av.obj \ WIN32_C = perllib.c \ win32.c \ - win32io.c \ win32sck.c \ win32thread.c WIN32_OBJ = win32.obj \ - win32io.obj \ win32sck.obj \ win32thread.obj PERL95_OBJ = perl95.obj \ win32mt.obj \ - win32iomt.obj \ win32sckmt.obj DLL_OBJ = perllib.obj $(DYNALOADER).obj @@ -315,7 +312,6 @@ CORE_H = ..\av.h \ .\include\sys\socket.h \ .\win32.h - EXTENSIONS=DynaLoader Socket IO Fcntl Opcode SDBM_File attrs Thread DYNALOADER=$(EXTDIR)\DynaLoader\DynaLoader @@ -461,8 +457,6 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) perlmain.obj .ENDIF copy splittree.pl .. $(MINIPERL) -I..\lib ..\splittree.pl "../LIB" "../LIB/auto" -# attrib -r ..\t\*.* -# copy test ..\t .IF "$(CCTYPE)" != "BORLAND" @@ -472,9 +466,6 @@ perl95.c : runperl.c perl95.obj : perl95.c $(CC) $(CFLAGS) -MT -UPERLDLL -c perl95.c -win32iomt.obj : win32io.c - $(CC) $(CFLAGS) -MT -c $(OBJOUT_FLAG)win32iomt.obj win32io.c - win32sckmt.obj : win32sck.c $(CC) $(CFLAGS) -MT -c $(OBJOUT_FLAG)win32sckmt.obj win32sck.c @@ -601,7 +592,7 @@ minitest : $(MINIPERL) $(GLOBEXE) $(CONFIGPM) cd ..\t && \ $(MINIPERL) -I..\lib test base/*.t comp/*.t cmd/*.t io/*.t op/*.t pragma/*.t -test : all +test-prep : all $(XCOPY) $(PERLEXE) ..\t\$(NULL) $(XCOPY) $(PERLDLL) ..\t\$(NULL) .IF "$(CCTYPE)" == "BORLAND" @@ -609,8 +600,14 @@ test : all .ELSE $(XCOPY) $(GLOBEXE) ..\t\$(NULL) .ENDIF + +test : test-prep cd ..\t && $(PERLEXE) -I..\lib harness +test-notty : test-prep + set PERL_SKIP_TTY_TEST=1 && \ + cd ..\t && $(PERLEXE) -I.\lib harness + clean : -@erase miniperlmain.obj -@erase $(MINIPERL) diff --git a/win32/perllib.c b/win32/perllib.c index 317c88ac05..848360698b 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -7,12 +7,6 @@ #include "perl.h" #include "XSUB.h" -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C extern -#endif - static void xs_init _((void)); __declspec(dllexport) int @@ -20,9 +14,6 @@ RunPerl(int argc, char **argv, char **env, void *iosubsystem) { int exitstatus; PerlInterpreter *my_perl; - void *pOldIOSubsystem; - - pOldIOSubsystem = SetIOSubSystem(iosubsystem); PERL_SYS_INIT(&argc,&argv); @@ -43,8 +34,6 @@ RunPerl(int argc, char **argv, char **env, void *iosubsystem) PERL_SYS_TERM(); - SetIOSubSystem(pOldIOSubsystem); - return (exitstatus); } diff --git a/win32/runperl.c b/win32/runperl.c index 07e2bd6f83..6f84c601ea 100644 --- a/win32/runperl.c +++ b/win32/runperl.c @@ -1,18 +1,9 @@ -#include <stdio.h> -#include <win32io.h> +/* Say NO to CPP! Hallelujah! */ -#ifndef _DLL -extern WIN32_IOSUBSYSTEM win32stdio; -#endif - -extern int RunPerl(int argc, char **argv, char **env, void *iosubsystem); +__declspec(dllimport) int RunPerl(int argc, char **argv, char **env, void *ios); int main(int argc, char **argv, char **env) { -#ifdef _DLL - return (RunPerl(argc, argv, env, NULL)); -#else - return (RunPerl(argc, argv, env, &win32stdio)); -#endif + return RunPerl(argc, argv, env, (void*)0); } diff --git a/win32/win32.c b/win32/win32.c index e10bf2b463..4551679f58 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -30,18 +30,12 @@ #include <stdarg.h> #include <float.h> -#define CROAK croak -#define WARN warn - #define EXECF_EXEC 1 #define EXECF_SPAWN 2 #define EXECF_SPAWN_NOWAIT 3 static DWORD IdOS(void); -extern WIN32_IOSUBSYSTEM win32stdio; -static PWIN32_IOSUBSYSTEM pIOSubSystem = &win32stdio; - BOOL ProbeEnv = FALSE; DWORD Win32System = (DWORD)-1; char szShellPath[MAX_PATH+1]; @@ -60,29 +54,6 @@ IsWinNT(void) { return (IdOS() == VER_PLATFORM_WIN32_NT); } -DllExport PWIN32_IOSUBSYSTEM -SetIOSubSystem(void *p) -{ - PWIN32_IOSUBSYSTEM old = pIOSubSystem; - if (p) { - PWIN32_IOSUBSYSTEM pio = (PWIN32_IOSUBSYSTEM)p; - if (pio->signature_begin == 12345678L - && pio->signature_end == 87654321L) { - pIOSubSystem = pio; - } - } - else { - pIOSubSystem = &win32stdio; - } - return old; -} - -DllExport PWIN32_IOSUBSYSTEM -GetIOSubSystem(void) -{ - return pIOSubSystem; -} - char * win32PerlLibPath(void) { @@ -168,156 +139,12 @@ my_popen(char *cmd, char *mode) #else #define fixcmd(x) #endif - -#if 1 -/* was #ifndef PERLDLL, but the #else stuff doesn't work on NT - * GSAR 97/03/13 - */ fixcmd(cmd); #ifdef __BORLANDC__ /* workaround a Borland stdio bug */ win32_fflush(stdout); win32_fflush(stderr); #endif return win32_popen(cmd, mode); -#else -/* - * There seems to be some problems for the _popen call in a DLL - * this trick at the moment seems to work but it is never test - * on NT yet - * - */ -# ifdef __cplusplus -#define EXT_C_FUNC extern "C" -# else -#define EXT_C_FUNC extern -# endif - - EXT_C_FUNC int __cdecl _set_osfhnd(int fh, long value); - EXT_C_FUNC void __cdecl _lock_fhandle(int); - EXT_C_FUNC void __cdecl _unlock_fhandle(int); - - BOOL fSuccess; - PerlIO *pf; /* to store the _popen return value */ - int tm = 0; /* flag indicating tDllExport or binary mode */ - int fhNeeded, fhInherited, fhDup; - int ineeded, iinherited; - DWORD dwDup; - int phdls[2]; /* I/O handles for pipe */ - HANDLE hPIn, hPOut, hPErr, - hSaveStdin, hSaveStdout, hSaveStderr, - hPNeeded, hPInherited, hPDuped; - - /* first check for errors in the arguments */ - if ( (cmd == NULL) || (mode == NULL) - || ((*mode != 'w') && (*mode != _T('r'))) ) - goto error1; - - if ( *(mode + 1) == _T('t') ) - tm = O_TEXT; - else if ( *(mode + 1) == _T('b') ) - tm = O_BINARY; - else - tm = (*mode == 'w' ? O_BINARY : O_TEXT); - - - fixcmd(cmd); - if (&win32stdio != pIOSubSystem) - return win32_popen(cmd, mode); - -#ifdef EFG - if ( _pipe( phdls, 1024, tm ) == -1 ) -#else - if ( win32_pipe( phdls, 1024, tm ) == -1 ) -#endif - goto error1; - - /* save the current situation */ - hSaveStdin = GetStdHandle(STD_INPUT_HANDLE); - hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE); - hSaveStderr = GetStdHandle(STD_ERROR_HANDLE); - - if (*mode == _T('w')) { - ineeded = 1; - dwDup = STD_INPUT_HANDLE; - iinherited = 0; - } - else { - ineeded = 0; - dwDup = STD_OUTPUT_HANDLE; - iinherited = 1; - } - - fhNeeded = phdls[ineeded]; - fhInherited = phdls[iinherited]; - - fSuccess = DuplicateHandle(GetCurrentProcess(), - (HANDLE) stolen_get_osfhandle(fhNeeded), - GetCurrentProcess(), - &hPNeeded, - 0, - FALSE, /* not inherited */ - DUPLICATE_SAME_ACCESS); - - if (!fSuccess) - goto error2; - - fhDup = stolen_open_osfhandle((long) hPNeeded, tm); - win32_dup2(fhDup, fhNeeded); - win32_close(fhDup); - -#ifdef AAA - /* Close the Out pipe, child won't need it */ - hPDuped = (HANDLE) stolen_get_osfhandle(fhNeeded); - - _lock_fhandle(fhNeeded); - _set_osfhnd(fhNeeded, (long)hPNeeded); /* put in ours duplicated one */ - _unlock_fhandle(fhNeeded); - - CloseHandle(hPDuped); /* close the handle first */ -#endif - - if (!SetStdHandle(dwDup, (HANDLE) stolen_get_osfhandle(fhInherited))) - goto error2; - - /* - * make sure the child see the same stderr as the calling program - */ - if (!SetStdHandle(STD_ERROR_HANDLE, - (HANDLE)stolen_get_osfhandle(win32_fileno(win32_stderr())))) - goto error2; - - pf = win32_popen(cmd, mode); /* ask _popen to do the job */ - - /* restore to where we were */ - SetStdHandle(STD_INPUT_HANDLE, hSaveStdin); - SetStdHandle(STD_OUTPUT_HANDLE, hSaveStdout); - SetStdHandle(STD_ERROR_HANDLE, hSaveStderr); - - /* we don't need it any more, that's for the child */ - win32_close(fhInherited); - - if (NULL == pf) { - /* something wrong */ - win32_close(fhNeeded); - goto error1; - } - else { - /* - * here we steal the file handle in pf and stuff ours in - */ - win32_dup2(fhNeeded, win32_fileno(pf)); - win32_close(fhNeeded); - } - return (pf); - -error2: - win32_close(fhNeeded); - win32_close(fhInherited); - -error1: - return (NULL); - -#endif } long @@ -566,7 +393,7 @@ opendir(char *filename) idx = strlen(FindData.cFileName)+1; New(1304, p->start, idx, char); if(p->start == NULL) { - CROAK("opendir: malloc failed!\n"); + croak("opendir: malloc failed!\n"); } strcpy(p->start, FindData.cFileName); /* if(downcase) @@ -586,7 +413,7 @@ opendir(char *filename) */ Renew(p->start, idx+len+1, char); if(p->start == NULL) { - CROAK("opendir: malloc failed!\n"); + croak("opendir: malloc failed!\n"); } strcpy(&p->start[idx], FindData.cFileName); /* if (downcase) @@ -725,11 +552,11 @@ kill(int pid, int sig) HANDLE hProcess= OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid); if (hProcess == NULL) { - CROAK("kill process failed!\n"); + croak("kill process failed!\n"); } else { if (!TerminateProcess(hProcess, sig)) - CROAK("kill process failed!\n"); + croak("kill process failed!\n"); CloseHandle(hProcess); } return 0; @@ -743,31 +570,18 @@ kill(int pid, int sig) int ioctl(int i, unsigned int u, char *data) { - CROAK("ioctl not implemented!\n"); + croak("ioctl not implemented!\n"); return -1; } #endif -unsigned int -sleep(unsigned int t) +DllExport unsigned int +win32_sleep(unsigned int t) { Sleep(t*1000); return 0; } - -#undef rename - -int -myrename(char *OldFileName, char *newname) -{ - if(_access(newname, 0) != -1) { /* file exists */ - _unlink(newname); - } - return rename(OldFileName, newname); -} - - DllExport int win32_stat(const char *path, struct stat *buffer) { @@ -787,7 +601,7 @@ win32_stat(const char *path, struct stat *buffer) }; } } - res = pIOSubSystem->pfnstat(p,buffer); + res = stat(p,buffer); #ifdef __BORLANDC__ if (res == 0) { if (S_ISDIR(buffer->st_mode)) @@ -843,9 +657,8 @@ FileTimeToClock(PFILETIME ft) return (long) qw; } -#undef times -int -mytimes(struct tms *timebuf) +DllExport int +win32_times(struct tms *timebuf) { FILETIME user; FILETIME kernel; @@ -878,9 +691,8 @@ static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time) sighandler(14); } -#undef alarm -unsigned int -myalarm(unsigned int sec) +DllExport unsigned int +win32_alarm(unsigned int sec) { /* * the 'obvious' implentation is SetTimer() with a callback @@ -908,6 +720,154 @@ myalarm(unsigned int sec) return 0; } +#ifdef USE_FIXED_OSFHANDLE + +EXTERN_C int __cdecl _alloc_osfhnd(void); +EXTERN_C int __cdecl _set_osfhnd(int fh, long value); +EXTERN_C void __cdecl _lock_fhandle(int); +EXTERN_C void __cdecl _unlock_fhandle(int); +EXTERN_C void __cdecl _unlock(int); + +#if (_MSC_VER >= 1000) +typedef struct { + long osfhnd; /* underlying OS file HANDLE */ + char osfile; /* attributes of file (e.g., open in text mode?) */ + char pipech; /* one char buffer for handles opened on pipes */ +#if defined (_MT) && !defined (DLL_FOR_WIN32S) + int lockinitflag; + CRITICAL_SECTION lock; +#endif /* defined (_MT) && !defined (DLL_FOR_WIN32S) */ +} ioinfo; + +EXTERN_C ioinfo * __pioinfo[]; + +#define IOINFO_L2E 5 +#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) +#define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1))) +#define _osfile(i) (_pioinfo(i)->osfile) + +#else /* (_MSC_VER >= 1000) */ +extern char _osfile[]; +#endif /* (_MSC_VER >= 1000) */ + +#define FOPEN 0x01 /* file handle open */ +#define FAPPEND 0x20 /* file handle opened O_APPEND */ +#define FDEV 0x40 /* file handle refers to device */ +#define FTEXT 0x80 /* file handle is in text mode */ + +#define _STREAM_LOCKS 26 /* Table of stream locks */ +#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_NSTREAM_-1) /* Last stream lock */ +#define _FH_LOCKS (_LAST_STREAM_LOCK+1) /* Table of fh locks */ + +/*** +*int my_open_osfhandle(long osfhandle, int flags) - open C Runtime file handle +* +*Purpose: +* This function allocates a free C Runtime file handle and associates +* it with the Win32 HANDLE specified by the first parameter. This is a +* temperary fix for WIN95's brain damage GetFileType() error on socket +* we just bypass that call for socket +* +*Entry: +* long osfhandle - Win32 HANDLE to associate with C Runtime file handle. +* int flags - flags to associate with C Runtime file handle. +* +*Exit: +* returns index of entry in fh, if successful +* return -1, if no free entry is found +* +*Exceptions: +* +*******************************************************************************/ + +static int +my_open_osfhandle(long osfhandle, int flags) +{ + int fh; + char fileflags; /* _osfile flags */ + + /* copy relevant flags from second parameter */ + fileflags = FDEV; + + if(flags & O_APPEND) + fileflags |= FAPPEND; + + if(flags & O_TEXT) + fileflags |= FTEXT; + + /* attempt to allocate a C Runtime file handle */ + if((fh = _alloc_osfhnd()) == -1) { + errno = EMFILE; /* too many open files */ + _doserrno = 0L; /* not an OS error */ + return -1; /* return error to caller */ + } + + /* the file is open. now, set the info in _osfhnd array */ + _set_osfhnd(fh, osfhandle); + + fileflags |= FOPEN; /* mark as open */ + +#if (_MSC_VER >= 1000) + _osfile(fh) = fileflags; /* set osfile entry */ + _unlock_fhandle(fh); +#else + _osfile[fh] = fileflags; /* set osfile entry */ + _unlock(fh+_FH_LOCKS); /* unlock handle */ +#endif + + return fh; /* return handle */ +} + +#define _open_osfhandle my_open_osfhandle +#endif /* USE_FIXED_OSFHANDLE */ + +/* simulate flock by locking a range on the file */ + +#define LK_ERR(f,i) ((f) ? (i = 0) : (errno = GetLastError())) +#define LK_LEN 0xffff0000 + +DllExport int +win32_flock(int fd, int oper) +{ + OVERLAPPED o; + int i = -1; + HANDLE fh; + + if (!IsWinNT()) { + croak("flock() unimplemented on this platform"); + return -1; + } + fh = (HANDLE)_get_osfhandle(fd); + memset(&o, 0, sizeof(o)); + + switch(oper) { + case LOCK_SH: /* shared lock */ + LK_ERR(LockFileEx(fh, 0, 0, LK_LEN, 0, &o),i); + break; + case LOCK_EX: /* exclusive lock */ + LK_ERR(LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0, LK_LEN, 0, &o),i); + break; + case LOCK_SH|LOCK_NB: /* non-blocking shared lock */ + LK_ERR(LockFileEx(fh, LOCKFILE_FAIL_IMMEDIATELY, 0, LK_LEN, 0, &o),i); + break; + case LOCK_EX|LOCK_NB: /* non-blocking exclusive lock */ + LK_ERR(LockFileEx(fh, + LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, + 0, LK_LEN, 0, &o),i); + break; + case LOCK_UN: /* unlock lock */ + LK_ERR(UnlockFileEx(fh, 0, LK_LEN, 0, &o),i); + break; + default: /* unknown */ + errno = EINVAL; + break; + } + return i; +} + +#undef LK_ERR +#undef LK_LEN + /* * redirected io subsystem for all XS modules * @@ -916,45 +876,45 @@ myalarm(unsigned int sec) DllExport int * win32_errno(void) { - return (pIOSubSystem->pfnerrno()); + return (&errno); } DllExport char *** win32_environ(void) { - return (pIOSubSystem->pfnenviron()); + return (&(_environ)); } /* the rest are the remapped stdio routines */ DllExport FILE * win32_stderr(void) { - return (pIOSubSystem->pfnstderr()); + return (stderr); } DllExport FILE * win32_stdin(void) { - return (pIOSubSystem->pfnstdin()); + return (stdin); } DllExport FILE * win32_stdout() { - return (pIOSubSystem->pfnstdout()); + return (stdout); } DllExport int win32_ferror(FILE *fp) { - return (pIOSubSystem->pfnferror(fp)); + return (ferror(fp)); } DllExport int win32_feof(FILE *fp) { - return (pIOSubSystem->pfnfeof(fp)); + return (feof(fp)); } /* @@ -983,7 +943,7 @@ win32_strerror(int e) return strerror_buffer; } - return pIOSubSystem->pfnstrerror(e); + return strerror(e); } DllExport int @@ -992,7 +952,7 @@ win32_fprintf(FILE *fp, const char *format, ...) va_list marker; va_start(marker, format); /* Initialize variable arguments. */ - return (pIOSubSystem->pfnvfprintf(fp, format, marker)); + return (vfprintf(fp, format, marker)); } DllExport int @@ -1001,188 +961,193 @@ win32_printf(const char *format, ...) va_list marker; va_start(marker, format); /* Initialize variable arguments. */ - return (pIOSubSystem->pfnvprintf(format, marker)); + return (vprintf(format, marker)); } DllExport int win32_vfprintf(FILE *fp, const char *format, va_list args) { - return (pIOSubSystem->pfnvfprintf(fp, format, args)); + return (vfprintf(fp, format, args)); } DllExport int win32_vprintf(const char *format, va_list args) { - return (pIOSubSystem->pfnvprintf(format, args)); + return (vprintf(format, args)); } DllExport size_t win32_fread(void *buf, size_t size, size_t count, FILE *fp) { - return pIOSubSystem->pfnfread(buf, size, count, fp); + return fread(buf, size, count, fp); } DllExport size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *fp) { - return pIOSubSystem->pfnfwrite(buf, size, count, fp); + return fwrite(buf, size, count, fp); } DllExport FILE * win32_fopen(const char *filename, const char *mode) { if (stricmp(filename, "/dev/null")==0) - return pIOSubSystem->pfnfopen("NUL", mode); - return pIOSubSystem->pfnfopen(filename, mode); + return fopen("NUL", mode); + return fopen(filename, mode); } +#ifndef USE_SOCKETS_AS_HANDLES +#undef fdopen +#define fdopen my_fdopen +#endif + DllExport FILE * win32_fdopen( int handle, const char *mode) { - return pIOSubSystem->pfnfdopen(handle, (char *) mode); + return fdopen(handle, (char *) mode); } DllExport FILE * win32_freopen( const char *path, const char *mode, FILE *stream) { if (stricmp(path, "/dev/null")==0) - return pIOSubSystem->pfnfreopen("NUL", mode, stream); - return pIOSubSystem->pfnfreopen(path, mode, stream); + return freopen("NUL", mode, stream); + return freopen(path, mode, stream); } DllExport int win32_fclose(FILE *pf) { - return pIOSubSystem->pfnfclose(pf); + return my_fclose(pf); /* defined in win32sck.c */ } DllExport int win32_fputs(const char *s,FILE *pf) { - return pIOSubSystem->pfnfputs(s, pf); + return fputs(s, pf); } DllExport int win32_fputc(int c,FILE *pf) { - return pIOSubSystem->pfnfputc(c,pf); + return fputc(c,pf); } DllExport int win32_ungetc(int c,FILE *pf) { - return pIOSubSystem->pfnungetc(c,pf); + return ungetc(c,pf); } DllExport int win32_getc(FILE *pf) { - return pIOSubSystem->pfngetc(pf); + return getc(pf); } DllExport int win32_fileno(FILE *pf) { - return pIOSubSystem->pfnfileno(pf); + return fileno(pf); } DllExport void win32_clearerr(FILE *pf) { - pIOSubSystem->pfnclearerr(pf); + clearerr(pf); return; } DllExport int win32_fflush(FILE *pf) { - return pIOSubSystem->pfnfflush(pf); + return fflush(pf); } DllExport long win32_ftell(FILE *pf) { - return pIOSubSystem->pfnftell(pf); + return ftell(pf); } DllExport int win32_fseek(FILE *pf,long offset,int origin) { - return pIOSubSystem->pfnfseek(pf, offset, origin); + return fseek(pf, offset, origin); } DllExport int win32_fgetpos(FILE *pf,fpos_t *p) { - return pIOSubSystem->pfnfgetpos(pf, p); + return fgetpos(pf, p); } DllExport int win32_fsetpos(FILE *pf,const fpos_t *p) { - return pIOSubSystem->pfnfsetpos(pf, p); + return fsetpos(pf, p); } DllExport void win32_rewind(FILE *pf) { - pIOSubSystem->pfnrewind(pf); + rewind(pf); return; } DllExport FILE* win32_tmpfile(void) { - return pIOSubSystem->pfntmpfile(); + return tmpfile(); } DllExport void win32_abort(void) { - pIOSubSystem->pfnabort(); + abort(); return; } DllExport int win32_fstat(int fd,struct stat *bufptr) { - return pIOSubSystem->pfnfstat(fd,bufptr); + return fstat(fd,bufptr); } DllExport int win32_pipe(int *pfd, unsigned int size, int mode) { - return pIOSubSystem->pfnpipe(pfd, size, mode); + return _pipe(pfd, size, mode); } DllExport FILE* win32_popen(const char *command, const char *mode) { - return pIOSubSystem->pfnpopen(command, mode); + return _popen(command, mode); } DllExport int win32_pclose(FILE *pf) { - return pIOSubSystem->pfnpclose(pf); + return _pclose(pf); } DllExport int win32_setmode(int fd, int mode) { - return pIOSubSystem->pfnsetmode(fd, mode); + return setmode(fd, mode); } DllExport long win32_lseek(int fd, long offset, int origin) { - return pIOSubSystem->pfnlseek(fd, offset, origin); + return lseek(fd, offset, origin); } DllExport long win32_tell(int fd) { - return pIOSubSystem->pfntell(fd); + return tell(fd); } DllExport int @@ -1196,198 +1161,188 @@ win32_open(const char *path, int flag, ...) va_end(ap); if (stricmp(path, "/dev/null")==0) - return pIOSubSystem->pfnopen("NUL", flag, pmode); - return pIOSubSystem->pfnopen(path,flag,pmode); + return open("NUL", flag, pmode); + return open(path,flag,pmode); } DllExport int win32_close(int fd) { - return pIOSubSystem->pfnclose(fd); + return close(fd); } DllExport int win32_eof(int fd) { - return pIOSubSystem->pfneof(fd); + return eof(fd); } DllExport int win32_dup(int fd) { - return pIOSubSystem->pfndup(fd); + return dup(fd); } DllExport int win32_dup2(int fd1,int fd2) { - return pIOSubSystem->pfndup2(fd1,fd2); + return dup2(fd1,fd2); } DllExport int win32_read(int fd, void *buf, unsigned int cnt) { - return pIOSubSystem->pfnread(fd, buf, cnt); + return read(fd, buf, cnt); } DllExport int win32_write(int fd, const void *buf, unsigned int cnt) { - return pIOSubSystem->pfnwrite(fd, buf, cnt); + return write(fd, buf, cnt); } DllExport int win32_mkdir(const char *dir, int mode) { - return pIOSubSystem->pfnmkdir(dir); /* just ignore mode */ + return mkdir(dir); /* just ignore mode */ } DllExport int win32_rmdir(const char *dir) { - return pIOSubSystem->pfnrmdir(dir); + return rmdir(dir); } DllExport int win32_chdir(const char *dir) { - return pIOSubSystem->pfnchdir(dir); + return chdir(dir); } DllExport int win32_spawnvp(int mode, const char *cmdname, const char *const *argv) { - return pIOSubSystem->pfnspawnvp(mode, cmdname, (char * const *) argv); + return spawnvp(mode, cmdname, (char * const *) argv); } DllExport int win32_execvp(const char *cmdname, const char *const *argv) { - return pIOSubSystem->pfnexecvp(cmdname, (char *const *)argv); + return execvp(cmdname, (char *const *)argv); } DllExport void win32_perror(const char *str) { - pIOSubSystem->pfnperror(str); + perror(str); } DllExport void win32_setbuf(FILE *pf, char *buf) { - pIOSubSystem->pfnsetbuf(pf, buf); + setbuf(pf, buf); } DllExport int win32_setvbuf(FILE *pf, char *buf, int type, size_t size) { - return pIOSubSystem->pfnsetvbuf(pf, buf, type, size); + return setvbuf(pf, buf, type, size); } DllExport int win32_flushall(void) { - return pIOSubSystem->pfnflushall(); + return flushall(); } DllExport int win32_fcloseall(void) { - return pIOSubSystem->pfnfcloseall(); + return fcloseall(); } DllExport char* win32_fgets(char *s, int n, FILE *pf) { - return pIOSubSystem->pfnfgets(s, n, pf); + return fgets(s, n, pf); } DllExport char* win32_gets(char *s) { - return pIOSubSystem->pfngets(s); + return gets(s); } DllExport int win32_fgetc(FILE *pf) { - return pIOSubSystem->pfnfgetc(pf); + return fgetc(pf); } DllExport int win32_putc(int c, FILE *pf) { - return pIOSubSystem->pfnputc(c,pf); + return putc(c,pf); } DllExport int win32_puts(const char *s) { - return pIOSubSystem->pfnputs(s); + return puts(s); } DllExport int win32_getchar(void) { - return pIOSubSystem->pfngetchar(); + return getchar(); } DllExport int win32_putchar(int c) { - return pIOSubSystem->pfnputchar(c); + return putchar(c); } DllExport void* win32_malloc(size_t size) { - return pIOSubSystem->pfnmalloc(size); + return malloc(size); } DllExport void* win32_calloc(size_t numitems, size_t size) { - return pIOSubSystem->pfncalloc(numitems,size); + return calloc(numitems,size); } DllExport void* win32_realloc(void *block, size_t size) { - return pIOSubSystem->pfnrealloc(block,size); + return realloc(block,size); } DllExport void win32_free(void *block) { - pIOSubSystem->pfnfree(block); + free(block); } int -stolen_open_osfhandle(long handle, int flags) +win32_open_osfhandle(long handle, int flags) { - return pIOSubSystem->pfn_open_osfhandle(handle, flags); + return _open_osfhandle(handle, flags); } long -stolen_get_osfhandle(int fd) +win32_get_osfhandle(int fd) { - return pIOSubSystem->pfn_get_osfhandle(fd); + return _get_osfhandle(fd); } /* * Extras. */ -DllExport int -win32_flock(int fd, int oper) -{ - if (!IsWinNT()) { - croak("flock() unimplemented on this platform"); - return -1; - } - return pIOSubSystem->pfnflock(fd, oper); -} - static XS(w32_GetCwd) { @@ -1639,7 +1594,7 @@ XS(w32_GetShortPathName) } void -init_os_extras() +Perl_init_os_extras() { char *file = __FILE__; dXSUB_SYS; diff --git a/win32/win32.h b/win32/win32.h index 525ef0f6cc..18bf8a2e96 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -22,10 +22,51 @@ #include <process.h> #include <stdio.h> #include <direct.h> +#include <stdlib.h> +#ifndef EXT +#include "EXTERN.h" +#endif -/* For UNIX compatibility. */ +#ifndef START_EXTERN_C +#ifdef __cplusplus +# define START_EXTERN_C extern "C" { +# define END_EXTERN_C } +# define EXTERN_C extern "C" +#else +# define START_EXTERN_C +# define END_EXTERN_C +# define EXTERN_C +#endif +#endif + +#define STANDARD_C 1 +#define DOSISH 1 /* no escaping our roots */ +#define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */ +#define DllExport __declspec(dllexport) +#define DllImport __declspec(dllimport) + +/* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as + * real filehandles. XXX Should always be defined (the other version is untested) */ +#define USE_SOCKETS_AS_HANDLES + +/* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls + * to read the environment, bypassing the runtime's (usually broken) + * facilities for accessing the same. See note in util.c/my_setenv(). */ +/*#define USE_WIN32_RTL_ENV */ + +/* Define USE_FIXED_OSFHANDLE to fix VC's _open_osfhandle() on W95. + * Can only enable it if not using the DLL CRT (it doesn't expose internals) */ +#if defined(_MSC_VER) && !defined(_DLL) && defined(_M_IX86) +#define USE_FIXED_OSFHANDLE +#endif + +#ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers dont have this */ +#define VER_PLATFORM_WIN32_WINDOWS 1 +#endif + +/* Compiler-specific stuff. */ -#ifdef __BORLANDC__ +#ifdef __BORLANDC__ /* Microsoft Visual C++ */ #define _access access #define _chdir chdir @@ -47,136 +88,61 @@ #else +#ifdef _MSC_VER /* Microsoft Visual C++ */ + typedef long uid_t; typedef long gid_t; +#pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761) -#endif +#endif /* _MSC_VER */ + +/* compatibility stuff for other compilers goes here */ -#ifdef __cplusplus -extern "C" { #endif +START_EXTERN_C + +/* For UNIX compatibility. */ + extern uid_t getuid(void); extern gid_t getgid(void); extern uid_t geteuid(void); extern gid_t getegid(void); extern int setuid(uid_t uid); extern int setgid(gid_t gid); - extern int kill(int pid, int sig); -#ifdef __cplusplus -} -#endif - - -extern char *staticlinkmodules[]; - -/* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls - * to read the environment, bypassing the runtime's (usually broken) - * facilities for accessing the same. See note in util.c/my_setenv(). - */ -/*#define USE_WIN32_RTL_ENV */ - -#ifndef USE_WIN32_RTL_ENV -#include <stdlib.h> -#ifndef EXT -#include "EXTERN.h" -#endif -#undef getenv -#define getenv win32_getenv -EXT char *win32_getenv(const char *name); -#endif - -#ifdef __cplusplus -extern "C" { -#endif +#undef Stat +#define Stat win32_stat +#undef init_os_extras +#define init_os_extras Perl_init_os_extras -EXT void Perl_win32_init(int *argcp, char ***argvp); +EXT void Perl_win32_init(int *argcp, char ***argvp); +EXT void Perl_init_os_extras(void); -#define USE_SOCKETS_AS_HANDLES #ifndef USE_SOCKETS_AS_HANDLES - -extern FILE *myfdopen(int, char *); - -#undef fdopen -#define fdopen myfdopen -#endif /* USE_SOCKETS_AS_HANDLES */ - -#define STANDARD_C 1 /* Perl5 likes standard C. */ -#define DOSISH 1 /* Take advantage of DOSish code in Perl5. */ - -#define OP_BINARY O_BINARY /* Mistake in in pp_sys.c. */ - -#undef pipe -#define pipe(fd) win32_pipe((fd), 512, O_BINARY) /* the pipe call is a bit different */ - -#undef pause -#define pause() sleep((32767L << 16) + 32767) - - -#undef times -#define times mytimes - -#undef alarm -#define alarm myalarm - -struct tms { - long tms_utime; - long tms_stime; - long tms_cutime; - long tms_cstime; -}; - -unsigned int sleep(unsigned int); -char *win32PerlLibPath(void); -char *win32SiteLibPath(void); -int mytimes(struct tms *timebuf); -unsigned int myalarm(unsigned int sec); -int do_aspawn(void* really, void ** mark, void ** arglast); -int do_spawn(char *cmd); -char do_exec(char *cmd); -void init_os_extras(void); - -#ifdef __cplusplus -} +extern FILE * my_fdopen(int, char *); #endif +extern int my_fclose(FILE *); +extern int do_aspawn(void* really, void ** mark, void ** arglast); +extern int do_spawn(char *cmd); +extern char do_exec(char *cmd); +extern char * win32PerlLibPath(void); +extern char * win32SiteLibPath(void); +extern int IsWin95(void); +extern int IsWinNT(void); -typedef char * caddr_t; /* In malloc.c (core address). */ +extern char * staticlinkmodules[]; -/* - * Extension Library, only good for VC - */ +END_EXTERN_C -#define DllExport __declspec(dllexport) -#define DllImport __declspec(dllimport) +typedef char * caddr_t; /* In malloc.c (core address). */ /* * handle socket stuff, assuming socket is always available */ - #include <sys/socket.h> #include <netdb.h> -#ifdef _MSC_VER -#pragma warning(disable: 4018 4035 4101 4102 4244 4245 4761) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -int IsWin95(void); -int IsWinNT(void); - -#ifdef __cplusplus -} -#endif - - -#ifndef VER_PLATFORM_WIN32_WINDOWS /* VC-2.0 headers dont have this */ -#define VER_PLATFORM_WIN32_WINDOWS 1 -#endif - #endif /* _INC_WIN32_PERL5 */ diff --git a/win32/win32io.c b/win32/win32io.c deleted file mode 100644 index 0e2e649059..0000000000 --- a/win32/win32io.c +++ /dev/null @@ -1,333 +0,0 @@ - - -#define WIN32_LEAN_AND_MEAN -#include <stdio.h> -extern int my_fclose(FILE *pf); -#include "EXTERN.h" -#define WIN32IO_IS_STDIO -#include <windows.h> -#include <stdlib.h> -#include <io.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <fcntl.h> -#include <assert.h> -#include <errno.h> -#include <process.h> -#include <direct.h> - - -#ifdef __cplusplus -#define START_EXTERN_C extern "C" { -#define END_EXTERN_C } -#else -#define START_EXTERN_C -#define END_EXTERN_C -#endif - -#include "win32iop.h" - -/* - * The following is just a basic wrapping of the stdio - * - * redirected io subsystem for all XS modules - */ - -static int * -dummy_errno(void) -{ - return (&(errno)); -} - -static char *** -dummy_environ(void) -{ - return (&(_environ)); -} - -/* the rest are the remapped stdio routines */ -static FILE * -dummy_stderr(void) -{ - return stderr; -} - -static FILE * -dummy_stdin(void) -{ - return stdin; -} - -static FILE * -dummy_stdout(void) -{ - return stdout; -} - -static int -dummy_globalmode(int mode) -{ - int o = _fmode; - _fmode = mode; - - return o; -} - -#if defined(_DLL) || defined(__BORLANDC__) -/* It may or may not be fixed (ok on NT), but DLL runtime - does not export the functions used in the workround -*/ -#define WIN95_OSFHANDLE_FIXED -#endif - -#if defined(_WIN32) && !defined(WIN95_OSFHANDLE_FIXED) && defined(_M_IX86) - -# ifdef __cplusplus -#define EXT_C_FUNC extern "C" -# else -#define EXT_C_FUNC extern -# endif - -EXT_C_FUNC int __cdecl _alloc_osfhnd(void); -EXT_C_FUNC int __cdecl _set_osfhnd(int fh, long value); -EXT_C_FUNC void __cdecl _lock_fhandle(int); -EXT_C_FUNC void __cdecl _unlock_fhandle(int); -EXT_C_FUNC void __cdecl _unlock(int); - -#if (_MSC_VER >= 1000) -typedef struct { - long osfhnd; /* underlying OS file HANDLE */ - char osfile; /* attributes of file (e.g., open in text mode?) */ - char pipech; /* one char buffer for handles opened on pipes */ -#if defined (_MT) && !defined (DLL_FOR_WIN32S) - int lockinitflag; - CRITICAL_SECTION lock; -#endif /* defined (_MT) && !defined (DLL_FOR_WIN32S) */ -} ioinfo; - -EXT_C_FUNC ioinfo * __pioinfo[]; - -#define IOINFO_L2E 5 -#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) -#define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1))) -#define _osfile(i) (_pioinfo(i)->osfile) - -#else /* (_MSC_VER >= 1000) */ -extern char _osfile[]; -#endif /* (_MSC_VER >= 1000) */ - -#define FOPEN 0x01 /* file handle open */ -#define FAPPEND 0x20 /* file handle opened O_APPEND */ -#define FDEV 0x40 /* file handle refers to device */ -#define FTEXT 0x80 /* file handle is in text mode */ - -#define _STREAM_LOCKS 26 /* Table of stream locks */ -#define _LAST_STREAM_LOCK (_STREAM_LOCKS+_NSTREAM_-1) /* Last stream lock */ -#define _FH_LOCKS (_LAST_STREAM_LOCK+1) /* Table of fh locks */ - -/*** -*int _patch_open_osfhandle(long osfhandle, int flags) - open C Runtime file handle -* -*Purpose: -* This function allocates a free C Runtime file handle and associates -* it with the Win32 HANDLE specified by the first parameter. This is a -* temperary fix for WIN95's brain damage GetFileType() error on socket -* we just bypass that call for socket -* -*Entry: -* long osfhandle - Win32 HANDLE to associate with C Runtime file handle. -* int flags - flags to associate with C Runtime file handle. -* -*Exit: -* returns index of entry in fh, if successful -* return -1, if no free entry is found -* -*Exceptions: -* -*******************************************************************************/ - -int -my_open_osfhandle(long osfhandle, int flags) -{ - int fh; - char fileflags; /* _osfile flags */ - - /* copy relevant flags from second parameter */ - fileflags = FDEV; - - if(flags & O_APPEND) - fileflags |= FAPPEND; - - if(flags & O_TEXT) - fileflags |= FTEXT; - - /* attempt to allocate a C Runtime file handle */ - if((fh = _alloc_osfhnd()) == -1) { - errno = EMFILE; /* too many open files */ - _doserrno = 0L; /* not an OS error */ - return -1; /* return error to caller */ - } - - /* the file is open. now, set the info in _osfhnd array */ - _set_osfhnd(fh, osfhandle); - - fileflags |= FOPEN; /* mark as open */ - -#if (_MSC_VER >= 1000) - _osfile(fh) = fileflags; /* set osfile entry */ - _unlock_fhandle(fh); -#else - _osfile[fh] = fileflags; /* set osfile entry */ - _unlock(fh+_FH_LOCKS); /* unlock handle */ -#endif - - return fh; /* return handle */ -} -#else - -int __cdecl -my_open_osfhandle(long osfhandle, int flags) -{ - return _open_osfhandle(osfhandle, flags); -} -#endif /* _M_IX86 */ - -long -my_get_osfhandle( int filehandle ) -{ - return _get_osfhandle(filehandle); -} - -#ifdef __BORLANDC__ -#define _chdir chdir -#endif - -/* simulate flock by locking a range on the file */ - - -#define LK_ERR(f,i) ((f) ? (i = 0) : (errno = GetLastError())) -#define LK_LEN 0xffff0000 - -int -my_flock(int fd, int oper) -{ - OVERLAPPED o; - int i = -1; - HANDLE fh; - - fh = (HANDLE)my_get_osfhandle(fd); - memset(&o, 0, sizeof(o)); - - switch(oper) { - case LOCK_SH: /* shared lock */ - LK_ERR(LockFileEx(fh, 0, 0, LK_LEN, 0, &o),i); - break; - case LOCK_EX: /* exclusive lock */ - LK_ERR(LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0, LK_LEN, 0, &o),i); - break; - case LOCK_SH|LOCK_NB: /* non-blocking shared lock */ - LK_ERR(LockFileEx(fh, LOCKFILE_FAIL_IMMEDIATELY, 0, LK_LEN, 0, &o),i); - break; - case LOCK_EX|LOCK_NB: /* non-blocking exclusive lock */ - LK_ERR(LockFileEx(fh, - LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, - 0, LK_LEN, 0, &o),i); - break; - case LOCK_UN: /* unlock lock */ - LK_ERR(UnlockFileEx(fh, 0, LK_LEN, 0, &o),i); - break; - default: /* unknown */ - errno = EINVAL; - break; - } - return i; -} - -#undef LK_ERR -#undef LK_LEN - - -#ifdef PERLDLL -__declspec(dllexport) -#endif -WIN32_IOSUBSYSTEM win32stdio = { - 12345678L, /* begin of structure; */ - dummy_errno, /* (*pfunc_errno)(void); */ - dummy_environ, /* (*pfunc_environ)(void); */ - dummy_stdin, /* (*pfunc_stdin)(void); */ - dummy_stdout, /* (*pfunc_stdout)(void); */ - dummy_stderr, /* (*pfunc_stderr)(void); */ - ferror, /* (*pfunc_ferror)(FILE *fp); */ - feof, /* (*pfunc_feof)(FILE *fp); */ - strerror, /* (*strerror)(int e); */ - vfprintf, /* (*pfunc_vfprintf)(FILE *pf, const char *format, va_list arg); */ - vprintf, /* (*pfunc_vprintf)(const char *format, va_list arg); */ - fread, /* (*pfunc_fread)(void *buf, size_t size, size_t count, FILE *pf); */ - fwrite, /* (*pfunc_fwrite)(void *buf, size_t size, size_t count, FILE *pf); */ - fopen, /* (*pfunc_fopen)(const char *path, const char *mode); */ - fdopen, /* (*pfunc_fdopen)(int fh, const char *mode); */ - freopen, /* (*pfunc_freopen)(const char *path, const char *mode, FILE *pf); */ - my_fclose, /* (*pfunc_fclose)(FILE *pf); */ - fputs, /* (*pfunc_fputs)(const char *s,FILE *pf); */ - fputc, /* (*pfunc_fputc)(int c,FILE *pf); */ - ungetc, /* (*pfunc_ungetc)(int c,FILE *pf); */ - getc, /* (*pfunc_getc)(FILE *pf); */ - fileno, /* (*pfunc_fileno)(FILE *pf); */ - clearerr, /* (*pfunc_clearerr)(FILE *pf); */ - fflush, /* (*pfunc_fflush)(FILE *pf); */ - ftell, /* (*pfunc_ftell)(FILE *pf); */ - fseek, /* (*pfunc_fseek)(FILE *pf,long offset,int origin); */ - fgetpos, /* (*pfunc_fgetpos)(FILE *pf,fpos_t *p); */ - fsetpos, /* (*pfunc_fsetpos)(FILE *pf,fpos_t *p); */ - rewind, /* (*pfunc_rewind)(FILE *pf); */ - tmpfile, /* (*pfunc_tmpfile)(void); */ - abort, /* (*pfunc_abort)(void); */ - fstat, /* (*pfunc_fstat)(int fd,struct stat *bufptr); */ - stat, /* (*pfunc_stat)(const char *name,struct stat *bufptr); */ - _pipe, /* (*pfunc_pipe)( int *phandles, unsigned int psize, int textmode ); */ - _popen, /* (*pfunc_popen)( const char *command, const char *mode ); */ - _pclose, /* (*pfunc_pclose)( FILE *pf); */ - setmode, /* (*pfunc_setmode)( int fd, int mode); */ - lseek, /* (*pfunc_lseek)( int fd, long offset, int origin); */ - tell, /* (*pfunc_tell)( int fd); */ - dup, /* (*pfunc_dup)( int fd); */ - dup2, /* (*pfunc_dup2)(int h1, int h2); */ - open, /* (*pfunc_open)(const char *path, int oflag,...); */ - close, /* (*pfunc_close)(int fd); */ - eof, /* (*pfunc_eof)(int fd); */ - read, /* (*pfunc_read)(int fd, void *buf, unsigned int cnt); */ - write, /* (*pfunc_write)(int fd, const void *buf, unsigned int cnt); */ - dummy_globalmode, /* (*pfunc_globalmode)(int mode) */ - my_open_osfhandle, - my_get_osfhandle, - spawnvp, - mkdir, - rmdir, - chdir, - my_flock, /* (*pfunc_flock)(int fd, int oper) */ - execvp, - perror, - setbuf, - setvbuf, - flushall, - fcloseall, - fgets, - gets, - fgetc, - putc, - puts, - getchar, - putchar, - fscanf, - scanf, - malloc, - calloc, - realloc, - free, - 87654321L, /* end of structure */ -}; - - - - - diff --git a/win32/win32io.h b/win32/win32io.h deleted file mode 100644 index 0e849cf783..0000000000 --- a/win32/win32io.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef WIN32IO_H -#define WIN32IO_H - -#ifdef __BORLANDC__ -#include <stdarg.h> -#define MSconst -#else -#define MSconst const -#endif - -typedef struct { -int signature_begin; -int * (*pfnerrno)(void); -char ***(*pfnenviron)(void); -FILE* (*pfnstdin)(void); -FILE* (*pfnstdout)(void); -FILE* (*pfnstderr)(void); -int (*pfnferror)(FILE *fp); -int (*pfnfeof)(FILE *fp); -char* (*pfnstrerror)(int e); -int (*pfnvfprintf)(FILE *pf, const char *format, va_list arg); -int (*pfnvprintf)(const char *format, va_list arg); -size_t (*pfnfread)(void *buf, size_t size, size_t count, FILE *pf); -size_t (*pfnfwrite)(const void *buf, size_t size, size_t count, FILE *pf); -FILE* (*pfnfopen)(const char *path, const char *mode); -FILE* (*pfnfdopen)(int fh, MSconst char *mode); -FILE* (*pfnfreopen)(const char *path, const char *mode, FILE *pf); -int (*pfnfclose)(FILE *pf); -int (*pfnfputs)(const char *s,FILE *pf); -int (*pfnfputc)(int c,FILE *pf); -int (*pfnungetc)(int c,FILE *pf); -int (*pfngetc)(FILE *pf); -int (*pfnfileno)(FILE *pf); -void (*pfnclearerr)(FILE *pf); -int (*pfnfflush)(FILE *pf); -long (*pfnftell)(FILE *pf); -int (*pfnfseek)(FILE *pf,long offset,int origin); -int (*pfnfgetpos)(FILE *pf,fpos_t *p); -int (*pfnfsetpos)(FILE *pf,const fpos_t *p); -void (*pfnrewind)(FILE *pf); -FILE* (*pfntmpfile)(void); -void (*pfnabort)(void); -int (*pfnfstat)(int fd,struct stat *bufptr); -int (*pfnstat)(const char *name,struct stat *bufptr); -int (*pfnpipe)( int *phandles, unsigned int psize, int textmode ); -FILE* (*pfnpopen)( const char *command, const char *mode ); -int (*pfnpclose)( FILE *pf); -int (*pfnsetmode)( int fd, int mode); -long (*pfnlseek)( int fd, long offset, int origin); -long (*pfntell)( int fd); -int (*pfndup)( int fd); -int (*pfndup2)(int h1, int h2); -int (*pfnopen)(const char *path, int oflag,...); -int (*pfnclose)(int fd); -int (*pfneof)(int fd); -int (*pfnread)(int fd, void *buf, unsigned int cnt); -int (*pfnwrite)(int fd, const void *buf, unsigned int cnt); -int (*pfnopenmode)(int mode); -int (*pfn_open_osfhandle)(long handle, int flags); -long (*pfn_get_osfhandle)(int fd); -int (*pfnspawnvp)(int mode, const char *cmdname, MSconst char * const *argv); -int (*pfnmkdir)(const char *path); -int (*pfnrmdir)(const char *path); -int (*pfnchdir)(const char *path); -int (*pfnflock)(int fd, int oper); -int (*pfnexecvp)(const char *cmdname, MSconst char *const *argv); -void (*pfnperror)(const char *str); -void (*pfnsetbuf)(FILE *pf, char *buf); -int (*pfnsetvbuf)(FILE *pf, char *buf, int type, size_t size); -int (*pfnflushall)(void); -int (*pfnfcloseall)(void); -char* (*pfnfgets)(char *s, int n, FILE *pf); -char* (*pfngets)(char *s); -int (*pfnfgetc)(FILE *pf); -int (*pfnputc)(int c, FILE *pf); -int (*pfnputs)(const char *s); -int (*pfngetchar)(void); -int (*pfnputchar)(int c); -int (*pfnfscanf)(FILE *pf, const char *format, ...); -int (*pfnscanf)(const char *format, ...); -void* (*pfnmalloc)(size_t size); -void* (*pfncalloc)(size_t numitems, size_t size); -void* (*pfnrealloc)(void *block, size_t size); -void (*pfnfree)(void *block); -int signature_end; -} WIN32_IOSUBSYSTEM; - -typedef WIN32_IOSUBSYSTEM *PWIN32_IOSUBSYSTEM; - -#endif /* WIN32IO_H */ - diff --git a/win32/win32iop.h b/win32/win32iop.h index 52acce1a9b..a60194d0f0 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -1,6 +1,18 @@ #ifndef WIN32IOP_H #define WIN32IOP_H +#ifndef START_EXTERN_C +#ifdef __cplusplus +# define START_EXTERN_C extern "C" { +# define END_EXTERN_C } +# define EXTERN_C extern "C" +#else +# define START_EXTERN_C +# define END_EXTERN_C +# define EXTERN_C +#endif +#endif + /* * defines for flock emulation */ @@ -9,8 +21,6 @@ #define LOCK_NB 4 #define LOCK_UN 8 -#include <win32io.h> /* pull in the io sub system structure */ - /* * Make this as close to original stdio as possible. */ @@ -20,6 +30,13 @@ */ START_EXTERN_C +struct tms { + long tms_utime; + long tms_stime; + long tms_cutime; + long tms_cstime; +}; + EXT int * win32_errno(void); EXT char *** win32_environ(void); EXT FILE* win32_stdin(void); @@ -92,17 +109,18 @@ EXT void* win32_calloc(size_t numitems, size_t size); EXT void* win32_realloc(void *block, size_t size); EXT void win32_free(void *block); +EXT int win32_open_osfhandle(long handle, int flags); +EXT long win32_get_osfhandle(int fd); +#ifndef USE_WIN32_RTL_ENV +EXT char* win32_getenv(const char *name); +#endif -/* - * these two are win32 specific but still io related - */ -int stolen_open_osfhandle(long handle, int flags); -long stolen_get_osfhandle(int fd); - - -EXT PWIN32_IOSUBSYSTEM SetIOSubSystem(void *piosubsystem); -EXT PWIN32_IOSUBSYSTEM GetIOSubSystem(void); +EXT unsigned int win32_sleep(unsigned int); +EXT int win32_times(struct tms *timebuf); +EXT unsigned int win32_alarm(unsigned int sec); +EXT int win32_flock(int fd, int oper); +EXT int win32_stat(const char *path, struct stat *buf); END_EXTERN_C @@ -117,6 +135,12 @@ END_EXTERN_C #undef stdout #undef ferror #undef feof +#undef fclose +#undef pipe +#undef pause +#undef sleep +#undef times +#undef alarm #ifdef __BORLANDC__ #undef ungetc @@ -175,8 +199,8 @@ END_EXTERN_C #define eof(fd) win32_eof(fd) #define read(fd,b,s) win32_read(fd,b,s) #define write(fd,b,s) win32_write(fd,b,s) -#define _open_osfhandle stolen_open_osfhandle -#define _get_osfhandle stolen_get_osfhandle +#define _open_osfhandle win32_open_osfhandle +#define _get_osfhandle win32_get_osfhandle #define spawnvp win32_spawnvp #define mkdir win32_mkdir #define rmdir win32_rmdir @@ -195,12 +219,21 @@ END_EXTERN_C #define puts win32_puts #define getchar win32_getchar #define putchar win32_putchar -#define fscanf (GetIOSubSystem()->pfnfscanf) -#define scanf (GetIOSubSystem()->pfnscanf) #define malloc win32_malloc #define calloc win32_calloc #define realloc win32_realloc #define free win32_free -#endif /* WIN32IO_IS_STDIO */ +#define pipe(fd) win32_pipe((fd), 512, O_BINARY) +#define pause() win32_sleep((32767L << 16) + 32767) +#define sleep win32_sleep +#define times win32_times +#define alarm win32_alarm + +#ifndef USE_WIN32_RTL_ENV +#undef getenv +#define getenv win32_getenv +#endif + +#endif /* WIN32IO_IS_STDIO */ #endif /* WIN32IOP_H */ diff --git a/win32/win32sck.c b/win32/win32sck.c index b4ad4f4cfb..b4f40f0de1 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -1,4 +1,4 @@ -/* NTSock.C +/* win32sck.c * * (c) 1995 Microsoft Corporation. All rights reserved. * Developed by hip communications inc., http://info.hip.com/info/ @@ -8,202 +8,115 @@ * License or the Artistic License, as specified in the README file. */ -#include <windows.h> +#define WIN32IO_IS_STDIO #define WIN32_LEAN_AND_MEAN +#include <windows.h> #include "EXTERN.h" #include "perl.h" #include <sys/socket.h> #include <fcntl.h> #include <sys/stat.h> #include <assert.h> +#include <io.h> -#define CROAK croak +#undef htonl +#undef htons +#undef ntohl +#undef ntohs +#undef inet_addr +#undef inet_ntoa +#undef socket +#undef bind +#undef listen +#undef accept +#undef connect +#undef send +#undef sendto +#undef recv +#undef recvfrom +#undef shutdown +#undef closesocket +#undef ioctlsocket +#undef setsockopt +#undef getsockopt +#undef getpeername +#undef getsockname +#undef gethostname +#undef gethostbyname +#undef gethostbyaddr +#undef getprotobyname +#undef getprotobynumber +#undef getservbyname +#undef getservbyport +#undef select +#undef endhostent +#undef endnetent +#undef endprotoent +#undef endservent +#undef getnetent +#undef getnetbyname +#undef getnetbyaddr +#undef getprotoent +#undef getservent +#undef sethostent +#undef setnetent +#undef setprotoent +#undef setservent -#ifdef USE_SOCKETS_AS_HANDLES /* thanks to Beverly Brown (beverly@datacube.com) */ - -#define OPEN_SOCKET(x) _open_osfhandle(x,O_RDWR|O_BINARY) -#define TO_SOCKET(x) _get_osfhandle(x) - +#ifdef USE_SOCKETS_AS_HANDLES +# define OPEN_SOCKET(x) _open_osfhandle(x,O_RDWR|O_BINARY) +# define TO_SOCKET(x) _get_osfhandle(x) #else - # define OPEN_SOCKET(x) (x) # define TO_SOCKET(x) (x) - #endif /* USE_SOCKETS_AS_HANDLES */ +#define StartSockets() \ + STMT_START { \ + if (!wsock_started) \ + start_sockets(); \ + } STMT_END + +#define EndSockets() \ + STMT_START { \ + if (wsock_started) \ + WSACleanup(); \ + } STMT_END + +#define SOCKET_TEST(x, y) \ + STMT_START { \ + StartSockets(); \ + if((x) == (y)) \ + errno = WSAGetLastError(); \ + } STMT_END + +#define SOCKET_TEST_ERROR(x) SOCKET_TEST(x, SOCKET_ERROR) + static struct servent* win32_savecopyservent(struct servent*d, struct servent*s, const char *proto); -#define SOCKETAPI PASCAL - -typedef SOCKET (SOCKETAPI *LPSOCKACCEPT)(SOCKET, struct sockaddr *, int *); -typedef int (SOCKETAPI *LPSOCKBIND)(SOCKET, const struct sockaddr *, int); -typedef int (SOCKETAPI *LPSOCKCLOSESOCKET)(SOCKET); -typedef int (SOCKETAPI *LPSOCKCONNECT)(SOCKET, const struct sockaddr *, int); -typedef int (SOCKETAPI *LPSOCKIOCTLSOCKET)(SOCKET, long, u_long *); -typedef int (SOCKETAPI *LPSOCKGETPEERNAME)(SOCKET, struct sockaddr *, int *); -typedef int (SOCKETAPI *LPSOCKGETSOCKNAME)(SOCKET, struct sockaddr *, int *); -typedef int (SOCKETAPI *LPSOCKGETSOCKOPT)(SOCKET, int, int, char *, int *); -typedef u_long (SOCKETAPI *LPSOCKHTONL)(u_long); -typedef u_short (SOCKETAPI *LPSOCKHTONS)(u_short); -typedef int (SOCKETAPI *LPSOCKLISTEN)(SOCKET, int); -typedef u_long (SOCKETAPI *LPSOCKNTOHL)(u_long); -typedef u_short (SOCKETAPI *LPSOCKNTOHS)(u_short); -typedef int (SOCKETAPI *LPSOCKRECV)(SOCKET, char *, int, int); -typedef int (SOCKETAPI *LPSOCKRECVFROM)(SOCKET, char *, int, int, struct sockaddr *, int *); -typedef int (SOCKETAPI *LPSOCKSELECT)(int, fd_set *, fd_set *, fd_set *, const struct timeval *); -typedef int (SOCKETAPI *LPSOCKSEND)(SOCKET, const char *, int, int); -typedef int (SOCKETAPI *LPSOCKSENDTO)(SOCKET, const char *, int, int, const struct sockaddr *, int); -typedef int (SOCKETAPI *LPSOCKSETSOCKOPT)(SOCKET, int, int, const char *, int); -typedef int (SOCKETAPI *LPSOCKSHUTDOWN)(SOCKET, int); -typedef SOCKET (SOCKETAPI *LPSOCKSOCKET)(int, int, int); -typedef char FAR *(SOCKETAPI *LPSOCKINETNTOA)(struct in_addr in); -typedef unsigned long (SOCKETAPI *LPSOCKINETADDR)(const char FAR * cp); - - -/* Database function prototypes */ -typedef struct hostent *(SOCKETAPI *LPSOCKGETHOSTBYADDR)(const char *, int, int); -typedef struct hostent *(SOCKETAPI *LPSOCKGETHOSTBYNAME)(const char *); -typedef int (SOCKETAPI *LPSOCKGETHOSTNAME)(char *, int); -typedef struct servent *(SOCKETAPI *LPSOCKGETSERVBYPORT)(int, const char *); -typedef struct servent *(SOCKETAPI *LPSOCKGETSERVBYNAME)(const char *, const char *); -typedef struct protoent *(SOCKETAPI *LPSOCKGETPROTOBYNUMBER)(int); -typedef struct protoent *(SOCKETAPI *LPSOCKGETPROTOBYNAME)(const char *); - -/* Microsoft Windows Extension function prototypes */ -typedef int (SOCKETAPI *LPSOCKWSASTARTUP)(unsigned short, LPWSADATA); -typedef int (SOCKETAPI *LPSOCKWSACLEANUP)(void); -typedef int (SOCKETAPI *LPSOCKWSAGETLASTERROR)(void); -typedef int (SOCKETAPI *LPWSAFDIsSet)(SOCKET, fd_set *); - -static HINSTANCE hWinSockDll = 0; -/* extern CRITICAL_SECTION csSock; */ - -static LPSOCKACCEPT paccept = 0; -static LPSOCKBIND pbind = 0; -static LPSOCKCLOSESOCKET pclosesocket = 0; -static LPSOCKCONNECT pconnect = 0; -static LPSOCKIOCTLSOCKET pioctlsocket = 0; -static LPSOCKGETPEERNAME pgetpeername = 0; -static LPSOCKGETSOCKNAME pgetsockname = 0; -static LPSOCKGETSOCKOPT pgetsockopt = 0; -static LPSOCKHTONL phtonl = 0; -static LPSOCKHTONS phtons = 0; -static LPSOCKLISTEN plisten = 0; -static LPSOCKNTOHL pntohl = 0; -static LPSOCKNTOHS pntohs = 0; -static LPSOCKRECV precv = 0; -static LPSOCKRECVFROM precvfrom = 0; -static LPSOCKSELECT pselect = 0; -static LPSOCKSEND psend = 0; -static LPSOCKSENDTO psendto = 0; -static LPSOCKSETSOCKOPT psetsockopt = 0; -static LPSOCKSHUTDOWN pshutdown = 0; -static LPSOCKSOCKET psocket = 0; -static LPSOCKGETHOSTBYADDR pgethostbyaddr = 0; -static LPSOCKGETHOSTBYNAME pgethostbyname = 0; -static LPSOCKGETHOSTNAME pgethostname = 0; -static LPSOCKGETSERVBYPORT pgetservbyport = 0; -static LPSOCKGETSERVBYNAME pgetservbyname = 0; -static LPSOCKGETPROTOBYNUMBER pgetprotobynumber = 0; -static LPSOCKGETPROTOBYNAME pgetprotobyname = 0; -static LPSOCKWSASTARTUP pWSAStartup = 0; -static LPSOCKWSACLEANUP pWSACleanup = 0; -static LPSOCKWSAGETLASTERROR pWSAGetLastError = 0; -static LPWSAFDIsSet pWSAFDIsSet = 0; -static LPSOCKINETNTOA pinet_ntoa = 0; -static LPSOCKINETADDR pinet_addr = 0; __declspec(thread) struct servent myservent; - - -void * -GetAddress(HINSTANCE hInstance, char *lpFunctionName) -{ - FARPROC proc = GetProcAddress(hInstance, lpFunctionName); - if(proc == 0) - CROAK("Unable to get address of %s in WSock32.dll", lpFunctionName); - return proc; -} - -void -LoadWinSock(void) -{ -/* EnterCriticalSection(&csSock); */ - if(hWinSockDll == NULL) { - HINSTANCE hLib = LoadLibrary("WSock32.DLL"); - if(hLib == NULL) - CROAK("Could not load WSock32.dll\n"); - - paccept = (LPSOCKACCEPT)GetAddress(hLib, "accept"); - pbind = (LPSOCKBIND)GetAddress(hLib, "bind"); - pclosesocket = (LPSOCKCLOSESOCKET)GetAddress(hLib, "closesocket"); - pconnect = (LPSOCKCONNECT)GetAddress(hLib, "connect"); - pioctlsocket = (LPSOCKIOCTLSOCKET)GetAddress(hLib, "ioctlsocket"); - pgetpeername = (LPSOCKGETPEERNAME)GetAddress(hLib, "getpeername"); - pgetsockname = (LPSOCKGETSOCKNAME)GetAddress(hLib, "getsockname"); - pgetsockopt = (LPSOCKGETSOCKOPT)GetAddress(hLib, "getsockopt"); - phtonl = (LPSOCKHTONL)GetAddress(hLib, "htonl"); - phtons = (LPSOCKHTONS)GetAddress(hLib, "htons"); - plisten = (LPSOCKLISTEN)GetAddress(hLib, "listen"); - pntohl = (LPSOCKNTOHL)GetAddress(hLib, "ntohl"); - pntohs = (LPSOCKNTOHS)GetAddress(hLib, "ntohs"); - precv = (LPSOCKRECV)GetAddress(hLib, "recv"); - precvfrom = (LPSOCKRECVFROM)GetAddress(hLib, "recvfrom"); - pselect = (LPSOCKSELECT)GetAddress(hLib, "select"); - psend = (LPSOCKSEND)GetAddress(hLib, "send"); - psendto = (LPSOCKSENDTO)GetAddress(hLib, "sendto"); - psetsockopt = (LPSOCKSETSOCKOPT)GetAddress(hLib, "setsockopt"); - pshutdown = (LPSOCKSHUTDOWN)GetAddress(hLib, "shutdown"); - psocket = (LPSOCKSOCKET)GetAddress(hLib, "socket"); - pgethostbyaddr = (LPSOCKGETHOSTBYADDR)GetAddress(hLib, "gethostbyaddr"); - pgethostbyname = (LPSOCKGETHOSTBYNAME)GetAddress(hLib, "gethostbyname"); - pgethostname = (LPSOCKGETHOSTNAME)GetAddress(hLib, "gethostname"); - pgetservbyport = (LPSOCKGETSERVBYPORT)GetAddress(hLib, "getservbyport"); - pgetservbyname = (LPSOCKGETSERVBYNAME)GetAddress(hLib, "getservbyname"); - pgetprotobynumber = (LPSOCKGETPROTOBYNUMBER)GetAddress(hLib, "getprotobynumber"); - pgetprotobyname = (LPSOCKGETPROTOBYNAME)GetAddress(hLib, "getprotobyname"); - pWSAStartup = (LPSOCKWSASTARTUP)GetAddress(hLib, "WSAStartup"); - pWSACleanup = (LPSOCKWSACLEANUP)GetAddress(hLib, "WSACleanup"); - pWSAGetLastError = (LPSOCKWSAGETLASTERROR)GetAddress(hLib, "WSAGetLastError"); - pWSAFDIsSet = (LPWSAFDIsSet)GetAddress(hLib, "__WSAFDIsSet"); - pinet_addr = (LPSOCKINETADDR)GetAddress(hLib,"inet_addr"); - pinet_ntoa = (LPSOCKINETNTOA)GetAddress(hLib,"inet_ntoa"); - - hWinSockDll = hLib; - } -/* LeaveCriticalSection(&csSock); */ -} - -void -EndSockets(void) -{ - if(hWinSockDll != NULL) { - pWSACleanup(); - FreeLibrary(hWinSockDll); - } - hWinSockDll = NULL; -} +static int wsock_started = 0; void -StartSockets(void) +start_sockets(void) { unsigned short version; WSADATA retdata; int ret; int iSockOpt = SO_SYNCHRONOUS_NONALERT; - LoadWinSock(); /* * initalize the winsock interface and insure that it is * cleaned up at exit. */ version = 0x101; - if(ret = pWSAStartup(version, &retdata)) - CROAK("Unable to locate winsock library!\n"); + if(ret = WSAStartup(version, &retdata)) + croak("Unable to locate winsock library!\n"); if(retdata.wVersion != version) - CROAK("Could not find version 1.1 of winsock dll\n"); + croak("Could not find version 1.1 of winsock dll\n"); /* atexit((void (*)(void)) EndSockets); */ @@ -211,26 +124,28 @@ StartSockets(void) /* * Enable the use of sockets as filehandles */ - psetsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&iSockOpt, sizeof(iSockOpt)); #endif /* USE_SOCKETS_AS_HANDLES */ + wsock_started = 1; } #ifndef USE_SOCKETS_AS_HANDLES +#undef fdopen FILE * -myfdopen(int fd, char *mode) +my_fdopen(int fd, char *mode) { FILE *fp; char sockbuf[256]; int optlen = sizeof(sockbuf); int retval; - if (hWinSockDll == 0) + if (!wsock_started) return(fdopen(fd, mode)); - retval = pgetsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, sockbuf, &optlen); - if(retval == SOCKET_ERROR && pWSAGetLastError() == WSAENOTSOCK) { + retval = getsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, sockbuf, &optlen); + if(retval == SOCKET_ERROR && WSAGetLastError() == WSAENOTSOCK) { return(fdopen(fd, mode)); } @@ -257,51 +172,39 @@ myfdopen(int fd, char *mode) u_long win32_htonl(u_long hostlong) { - if(hWinSockDll == 0) - StartSockets(); - - return phtonl(hostlong); + StartSockets(); + return htonl(hostlong); } u_short win32_htons(u_short hostshort) { - if(hWinSockDll == 0) - StartSockets(); - - return phtons(hostshort); + StartSockets(); + return htons(hostshort); } u_long win32_ntohl(u_long netlong) { - if(hWinSockDll == 0) - StartSockets(); - - return pntohl(netlong); + StartSockets(); + return ntohl(netlong); } u_short win32_ntohs(u_short netshort) { - if(hWinSockDll == 0) - StartSockets(); - - return pntohs(netshort); + StartSockets(); + return ntohs(netshort); } -#define SOCKET_TEST(x, y) if(hWinSockDll == 0) StartSockets();\ - if((x) == (y)) errno = pWSAGetLastError() - -#define SOCKET_TEST_ERROR(x) SOCKET_TEST(x, SOCKET_ERROR) SOCKET win32_accept(SOCKET s, struct sockaddr *addr, int *addrlen) { SOCKET r; - SOCKET_TEST((r = paccept(TO_SOCKET(s), addr, addrlen)), INVALID_SOCKET); + SOCKET_TEST((r = accept(TO_SOCKET(s), addr, addrlen)), INVALID_SOCKET); return OPEN_SOCKET(r); } @@ -310,7 +213,7 @@ win32_bind(SOCKET s, const struct sockaddr *addr, int addrlen) { int r; - SOCKET_TEST_ERROR(r = pbind(TO_SOCKET(s), addr, addrlen)); + SOCKET_TEST_ERROR(r = bind(TO_SOCKET(s), addr, addrlen)); return r; } @@ -319,7 +222,7 @@ win32_connect(SOCKET s, const struct sockaddr *addr, int addrlen) { int r; - SOCKET_TEST_ERROR(r = pconnect(TO_SOCKET(s), addr, addrlen)); + SOCKET_TEST_ERROR(r = connect(TO_SOCKET(s), addr, addrlen)); return r; } @@ -329,7 +232,7 @@ win32_getpeername(SOCKET s, struct sockaddr *addr, int *addrlen) { int r; - SOCKET_TEST_ERROR(r = pgetpeername(TO_SOCKET(s), addr, addrlen)); + SOCKET_TEST_ERROR(r = getpeername(TO_SOCKET(s), addr, addrlen)); return r; } @@ -338,7 +241,7 @@ win32_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen) { int r; - SOCKET_TEST_ERROR(r = pgetsockname(TO_SOCKET(s), addr, addrlen)); + SOCKET_TEST_ERROR(r = getsockname(TO_SOCKET(s), addr, addrlen)); return r; } @@ -347,7 +250,7 @@ win32_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen) { int r; - SOCKET_TEST_ERROR(r = pgetsockopt(TO_SOCKET(s), level, optname, optval, optlen)); + SOCKET_TEST_ERROR(r = getsockopt(TO_SOCKET(s), level, optname, optval, optlen)); return r; } @@ -356,7 +259,7 @@ win32_ioctlsocket(SOCKET s, long cmd, u_long *argp) { int r; - SOCKET_TEST_ERROR(r = pioctlsocket(TO_SOCKET(s), cmd, argp)); + SOCKET_TEST_ERROR(r = ioctlsocket(TO_SOCKET(s), cmd, argp)); return r; } @@ -365,7 +268,7 @@ win32_listen(SOCKET s, int backlog) { int r; - SOCKET_TEST_ERROR(r = plisten(TO_SOCKET(s), backlog)); + SOCKET_TEST_ERROR(r = listen(TO_SOCKET(s), backlog)); return r; } @@ -374,7 +277,7 @@ win32_recv(SOCKET s, char *buf, int len, int flags) { int r; - SOCKET_TEST_ERROR(r = precv(TO_SOCKET(s), buf, len, flags)); + SOCKET_TEST_ERROR(r = recv(TO_SOCKET(s), buf, len, flags)); return r; } @@ -383,7 +286,7 @@ win32_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, i { int r; - SOCKET_TEST_ERROR(r = precvfrom(TO_SOCKET(s), buf, len, flags, from, fromlen)); + SOCKET_TEST_ERROR(r = recvfrom(TO_SOCKET(s), buf, len, flags, from, fromlen)); return r; } @@ -424,22 +327,22 @@ win32_select(int nfds, int* rd, int* wr, int* ex, const struct timeval* timeout) FD_SET(fd, &nex); } - SOCKET_TEST_ERROR(r = pselect(nfds, prd, pwr, pex, timeout)); + SOCKET_TEST_ERROR(r = select(nfds, prd, pwr, pex, timeout)); for (i = 0; i < nfds; i++) { fd = TO_SOCKET(i); bit = 1L<<(i % (sizeof(int)*8)); offset = i / (sizeof(int)*8); if (rd[offset] & bit) { - if (!pWSAFDIsSet(fd, &nrd)) + if (!__WSAFDIsSet(fd, &nrd)) rd[offset] &= ~bit; } if (wr[offset] & bit) { - if (!pWSAFDIsSet(fd, &nwr)) + if (!__WSAFDIsSet(fd, &nwr)) wr[offset] &= ~bit; } if (ex[offset] & bit) { - if (!pWSAFDIsSet(fd, &nex)) + if (!__WSAFDIsSet(fd, &nex)) ex[offset] &= ~bit; } } @@ -451,7 +354,7 @@ win32_send(SOCKET s, const char *buf, int len, int flags) { int r; - SOCKET_TEST_ERROR(r = psend(TO_SOCKET(s), buf, len, flags)); + SOCKET_TEST_ERROR(r = send(TO_SOCKET(s), buf, len, flags)); return r; } @@ -461,7 +364,7 @@ win32_sendto(SOCKET s, const char *buf, int len, int flags, { int r; - SOCKET_TEST_ERROR(r = psendto(TO_SOCKET(s), buf, len, flags, to, tolen)); + SOCKET_TEST_ERROR(r = sendto(TO_SOCKET(s), buf, len, flags, to, tolen)); return r; } @@ -470,7 +373,7 @@ win32_setsockopt(SOCKET s, int level, int optname, const char *optval, int optle { int r; - SOCKET_TEST_ERROR(r = psetsockopt(TO_SOCKET(s), level, optname, optval, optlen)); + SOCKET_TEST_ERROR(r = setsockopt(TO_SOCKET(s), level, optname, optval, optlen)); return r; } @@ -479,7 +382,16 @@ win32_shutdown(SOCKET s, int how) { int r; - SOCKET_TEST_ERROR(r = pshutdown(TO_SOCKET(s), how)); + SOCKET_TEST_ERROR(r = shutdown(TO_SOCKET(s), how)); + return r; +} + +int +win32_closesocket(SOCKET s) +{ + int r; + + SOCKET_TEST_ERROR(r = closesocket(TO_SOCKET(s))); return r; } @@ -489,13 +401,11 @@ win32_socket(int af, int type, int protocol) SOCKET s; #ifndef USE_SOCKETS_AS_HANDLES - SOCKET_TEST(s = psocket(af, type, protocol), INVALID_SOCKET); + SOCKET_TEST(s = socket(af, type, protocol), INVALID_SOCKET); #else - if(hWinSockDll == 0) - StartSockets(); - - if((s = psocket(af, type, protocol)) == INVALID_SOCKET) - errno = pWSAGetLastError(); + StartSockets(); + if((s = socket(af, type, protocol)) == INVALID_SOCKET) + errno = WSAGetLastError(); else s = OPEN_SOCKET(s); #endif /* USE_SOCKETS_AS_HANDLES */ @@ -507,16 +417,18 @@ win32_socket(int af, int type, int protocol) int my_fclose (FILE *pf) { - int osf, retval; - if (hWinSockDll == 0) /* No WinSockDLL? */ - return(fclose(pf)); /* Then not a socket. */ - osf = TO_SOCKET(fileno(pf)); /* Get it now before it's gone! */ - retval = fclose(pf); /* Must fclose() before closesocket() */ - if (osf != -1 - && pclosesocket(osf) == SOCKET_ERROR - && WSAGetLastError() != WSAENOTSOCK) - retval = EOF; - return retval; + int osf, retval; + if (!wsock_started) /* No WinSock? */ + return(fclose(pf)); /* Then not a socket. */ + osf = TO_SOCKET(fileno(pf));/* Get it now before it's gone! */ + retval = fclose(pf); /* Must fclose() before closesocket() */ + if (osf != -1 + && closesocket(osf) == SOCKET_ERROR + && WSAGetLastError() != WSAENOTSOCK) + { + return EOF; + } + return retval; } struct hostent * @@ -524,7 +436,7 @@ win32_gethostbyaddr(const char *addr, int len, int type) { struct hostent *r; - SOCKET_TEST(r = pgethostbyaddr(addr, len, type), NULL); + SOCKET_TEST(r = gethostbyaddr(addr, len, type), NULL); return r; } @@ -533,7 +445,7 @@ win32_gethostbyname(const char *name) { struct hostent *r; - SOCKET_TEST(r = pgethostbyname(name), NULL); + SOCKET_TEST(r = gethostbyname(name), NULL); return r; } @@ -542,7 +454,7 @@ win32_gethostname(char *name, int len) { int r; - SOCKET_TEST_ERROR(r = pgethostname(name, len)); + SOCKET_TEST_ERROR(r = gethostname(name, len)); return r; } @@ -551,7 +463,7 @@ win32_getprotobyname(const char *name) { struct protoent *r; - SOCKET_TEST(r = pgetprotobyname(name), NULL); + SOCKET_TEST(r = getprotobyname(name), NULL); return r; } @@ -560,7 +472,7 @@ win32_getprotobynumber(int num) { struct protoent *r; - SOCKET_TEST(r = pgetprotobynumber(num), NULL); + SOCKET_TEST(r = getprotobynumber(num), NULL); return r; } @@ -569,7 +481,7 @@ win32_getservbyname(const char *name, const char *proto) { struct servent *r; - SOCKET_TEST(r = pgetservbyname(name, proto), NULL); + SOCKET_TEST(r = getservbyname(name, proto), NULL); if (r) { r = win32_savecopyservent(&myservent, r, proto); } @@ -581,7 +493,7 @@ win32_getservbyport(int port, const char *proto) { struct servent *r; - SOCKET_TEST(r = pgetservbyport(port, proto), NULL); + SOCKET_TEST(r = getservbyport(port, proto), NULL); if (r) { r = win32_savecopyservent(&myservent, r, proto); } @@ -591,125 +503,107 @@ win32_getservbyport(int port, const char *proto) char FAR * win32_inet_ntoa(struct in_addr in) { - if(hWinSockDll == 0) - StartSockets(); - - return pinet_ntoa(in); + StartSockets(); + return inet_ntoa(in); } unsigned long win32_inet_addr(const char FAR *cp) { - if(hWinSockDll == 0) - StartSockets(); - - return pinet_addr(cp); - + StartSockets(); + return inet_addr(cp); } /* * Networking stubs */ -#undef CROAK -#define CROAK croak void win32_endhostent() { - CROAK("endhostent not implemented!\n"); + croak("endhostent not implemented!\n"); } void win32_endnetent() { - CROAK("endnetent not implemented!\n"); + croak("endnetent not implemented!\n"); } void win32_endprotoent() { - CROAK("endprotoent not implemented!\n"); + croak("endprotoent not implemented!\n"); } void win32_endservent() { - CROAK("endservent not implemented!\n"); + croak("endservent not implemented!\n"); } struct netent * win32_getnetent(void) { - CROAK("getnetent not implemented!\n"); + croak("getnetent not implemented!\n"); return (struct netent *) NULL; } struct netent * win32_getnetbyname(char *name) { - CROAK("getnetbyname not implemented!\n"); + croak("getnetbyname not implemented!\n"); return (struct netent *)NULL; } struct netent * win32_getnetbyaddr(long net, int type) { - CROAK("getnetbyaddr not implemented!\n"); + croak("getnetbyaddr not implemented!\n"); return (struct netent *)NULL; } struct protoent * win32_getprotoent(void) { - CROAK("getprotoent not implemented!\n"); + croak("getprotoent not implemented!\n"); return (struct protoent *) NULL; } struct servent * win32_getservent(void) { - CROAK("getservent not implemented!\n"); + croak("getservent not implemented!\n"); return (struct servent *) NULL; } void win32_sethostent(int stayopen) { - CROAK("sethostent not implemented!\n"); + croak("sethostent not implemented!\n"); } void win32_setnetent(int stayopen) { - CROAK("setnetent not implemented!\n"); + croak("setnetent not implemented!\n"); } void win32_setprotoent(int stayopen) { - CROAK("setprotoent not implemented!\n"); + croak("setprotoent not implemented!\n"); } void win32_setservent(int stayopen) { - CROAK("setservent not implemented!\n"); -} - -#define WIN32IO_IS_STDIO -#include <io.h> - -#ifdef __cplusplus -extern "C" { -#endif -#include "win32iop.h" -#ifdef __cplusplus + croak("setservent not implemented!\n"); } -#endif static struct servent* win32_savecopyservent(struct servent*d, struct servent*s, const char *proto) diff --git a/win32/win32thread.c b/win32/win32thread.c index 92199678e2..4dbc750b05 100644 --- a/win32/win32thread.c +++ b/win32/win32thread.c @@ -18,8 +18,8 @@ void Perl_set_thread_self(struct thread *thr) { #ifdef USE_THREADS - /* GetCurrentThread() retrurns a pseudo handle, need - this to convert it into a handle another thread can use + /* Set thr->self. GetCurrentThread() retrurns a pseudo handle, need + this to convert it into a handle another thread can use. */ DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), diff --git a/win32/win32thread.h b/win32/win32thread.h index 03b0807b72..0c6bb55b69 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -4,20 +4,21 @@ typedef struct win32_cond { LONG waiters; HANDLE sem; } perl_cond; typedef DWORD perl_key; typedef HANDLE perl_thread; -/* XXX Critical Sections used instead of mutexes: lightweight, +#ifndef DONT_USE_CRITICAL_SECTION + +/* Critical Sections used instead of mutexes: lightweight, * but can't be communicated to child processes, and can't get - * HANDLE to it for use elsewhere + * HANDLE to it for use elsewhere. */ - -#ifndef DONT_USE_CRITICAL_SECTION typedef CRITICAL_SECTION perl_mutex; #define MUTEX_INIT(m) InitializeCriticalSection(m) #define MUTEX_LOCK(m) EnterCriticalSection(m) #define MUTEX_UNLOCK(m) LeaveCriticalSection(m) #define MUTEX_DESTROY(m) DeleteCriticalSection(m) + #else -typedef HANDLE perl_mutex; +typedef HANDLE perl_mutex; #define MUTEX_INIT(m) \ STMT_START { \ if ((*(m) = CreateMutex(NULL,FALSE,NULL)) == NULL) \ @@ -46,44 +47,46 @@ typedef HANDLE perl_mutex; * so there's no separate mutex protecting access to (c)->waiters */ #define COND_INIT(c) \ - STMT_START { \ - (c)->waiters = 0; \ - (c)->sem = CreateSemaphore(NULL,0,LONG_MAX,NULL); \ - if ((c)->sem == NULL) \ - croak("panic: COND_INIT (%ld)",GetLastError()); \ + STMT_START { \ + (c)->waiters = 0; \ + (c)->sem = CreateSemaphore(NULL,0,LONG_MAX,NULL); \ + if ((c)->sem == NULL) \ + croak("panic: COND_INIT (%ld)",GetLastError()); \ } STMT_END #define COND_SIGNAL(c) \ - STMT_START { \ - if (ReleaseSemaphore((c)->sem,1,NULL) == 0) \ - croak("panic: COND_SIGNAL (%ld)",GetLastError()); \ + STMT_START { \ + if ((c)->waiters > 0 && \ + ReleaseSemaphore((c)->sem,1,NULL) == 0) \ + croak("panic: COND_SIGNAL (%ld)",GetLastError()); \ } STMT_END #define COND_BROADCAST(c) \ - STMT_START { \ - if ((c)->waiters > 0 && \ - ReleaseSemaphore((c)->sem,(c)->waiters,NULL) == 0) \ - croak("panic: COND_BROADCAST (%ld)",GetLastError());\ + STMT_START { \ + if ((c)->waiters > 0 && \ + ReleaseSemaphore((c)->sem,(c)->waiters,NULL) == 0) \ + croak("panic: COND_BROADCAST (%ld)",GetLastError());\ } STMT_END #define COND_WAIT(c, m) \ - STMT_START { \ - (c)->waiters++; \ - MUTEX_UNLOCK(m); \ - /* Note that there's no race here, since a \ - * COND_BROADCAST() on another thread will have seen the\ - * right number of waiters (i.e. including this one) */ \ - if (WaitForSingleObject((c)->sem,INFINITE)==WAIT_FAILED)\ - croak("panic: COND_WAIT (%ld)",GetLastError()); \ - MUTEX_LOCK(m); \ - (c)->waiters--; \ + STMT_START { \ + (c)->waiters++; \ + MUTEX_UNLOCK(m); \ + /* Note that there's no race here, since a \ + * COND_BROADCAST() on another thread will have seen the\ + * right number of waiters (i.e. including this one) */ \ + if (WaitForSingleObject((c)->sem,INFINITE)==WAIT_FAILED)\ + croak("panic: COND_WAIT (%ld)",GetLastError()); \ + /* XXX there may be an inconsequential race here */ \ + MUTEX_LOCK(m); \ + (c)->waiters--; \ } STMT_END #define COND_DESTROY(c) \ - STMT_START { \ - (c)->waiters = 0; \ - if (CloseHandle((c)->sem) == 0) \ - croak("panic: COND_DESTROY (%ld)",GetLastError()); \ + STMT_START { \ + (c)->waiters = 0; \ + if (CloseHandle((c)->sem) == 0) \ + croak("panic: COND_DESTROY (%ld)",GetLastError()); \ } STMT_END #define DETACH(t) \ @@ -115,7 +118,7 @@ END_EXTERN_C #define JOIN(t, avp) \ STMT_START { \ if ((WaitForSingleObject((t)->self,INFINITE) == WAIT_FAILED) \ - || (GetExitCodeThread((t)->self,(LPDWORD)(avp)) == 0)) \ + || (GetExitCodeThread((t)->self,(LPDWORD)(avp)) == 0)) \ croak("panic: JOIN"); \ } STMT_END |