Merge from fixincl-branch

From-SVN: r25558
This commit is contained in:
Bruce Korb 1999-03-03 07:41:52 +00:00
parent 9a9f6326f2
commit 1f414ac48f
14 changed files with 1402 additions and 992 deletions

View File

@ -1,5 +1,5 @@
# Makefile for GNU C++ compiler.
# Copyright (C) 1987, 88, 90-5, 1998 Free Software Foundation, Inc.
# Makefile for GNU compilers.
# Copyright (C) 1998, 1999 Free Software Foundation, Inc.
#This file is part of GNU CC.
@ -22,6 +22,7 @@
# Its purpose is to build the any-platforms fixinc.sh script.
CFLAGS = -g
FIXINC_DEFS = @fixinc_defs@
CC = @CC@
SHELL = /bin/sh
@ -39,11 +40,11 @@ default : gen
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order.
INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config
INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)/../../include
# Always use -I$(srcdir)/config when compiling.
.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCLUDES) $<
$(CC) -c $(CFLAGS) $(FIXINC_DEFS) $(CPPFLAGS) $(INCLUDES) $<
# The only suffixes we want for implicit rules are .c and .o.
.SUFFIXES:
@ -55,12 +56,11 @@ INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config
##
## Makefile for constructing the "best" include fixer we can
##
## $Id: Makefile.in,v 1.2 1998/12/16 21:18:54 law Exp $
##
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
OBJ = fixincl.o server.o regex.o
HDR = server.h regex.h
LIBERTY = ../../libiberty/libiberty.a
SH_TARGET = inclhack.sh fixincl.sh
BIN_TARGET = fixincl
@ -75,13 +75,13 @@ gen : $(SH_TARGET) fixincl.x
$(OBJ): $(HDR)
fixincl: $(OBJ)
@echo $(CC) -o $@ $(OBJ) $(LIB) ; \
if $(CC) -o $@ $(OBJ) $(LIB) ; then : ; else \
@echo $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; \
if $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; then : ; else \
rm -f $@ ; (echo "#! /bin/sh" ; echo exit 1 ) > $@ ; \
chmod 777 $@ ; fi
regex.o: regex.c
-$(CC) $(CFLAGS) -DSTDC_HEADERS=1 -c regex.c
-$(CC) $(CFLAGS) $(FIXINC_DEFS) -DSTDC_HEADERS=1 -c $(srcdir)/regex.c
fixincl.o : fixincl.x fixincl.c
server.o : server.c server.h
@ -92,21 +92,28 @@ fixincl.x: fixincl.tpl inclhack.def
autogen -T $(srcdir)/fixincl.tpl -b fixincl \
$(srcdir)/inclhack.def ; \
else echo You need to install autogen ; \
$(CP) $(srcdir)/$@ . ; fi
if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
$(CP) $(srcdir)/$@ . ; \
else touch $@ ; fi ; fi
inclhack.sh: inclhack.def inclhack.tpl hackshell.tpl
@if ( autogen --help > /dev/null 2>&1 ) ; then \
echo autogen inclhack.def ; \
autogen inclhack.def ; \
autogen -L$(srcdir) $(srcdir)/inclhack.def ; \
else echo You need to install autogen ; \
$(CP) $(srcdir)/$@ . ; fi
if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
$(CP) $(srcdir)/$@ . ; \
else touch $@ ; fi ; fi
fixincl.sh: inclhack.def inclhack.tpl
@if ( autogen --help > /dev/null 2>&1 ) ; then \
echo autogen -DPROGRAM=1 -b fixincl inclhack.def ; \
autogen -DPROGRAM=1 -b fixincl inclhack.def ; touch $@ ; \
autogen -DPROGRAM=1 -b fixincl -L$(srcdir) \
$(srcdir)/inclhack.def ; touch $@ ; \
else echo You need to install autogen ; \
$(CP) $(srcdir)/$@ . ; fi
if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \
$(CP) $(srcdir)/$@ . ; \
else touch $@ ; fi ; fi
clean:
rm -f *.o $(TARGETS) fixincl.x
@ -120,13 +127,19 @@ install: $(TARGETS)
@rm -f ../fixinc.sh ; \
if ( ./fixincl -v > /dev/null 2>&1 ) ; then \
echo cp fixincl.sh ../fixinc.sh ; \
cp fixincl.sh ../fixinc.sh ; \
if [ -f ./fixincl.sh ] ; \
then cp fixincl.sh ../fixinc.sh ; \
else cp $(srcdir)/fixincl.sh ../fixinc.sh ; fi ; \
chmod 555 ../fixinc.sh ; \
rm -f ../fixincl ; \
echo cp fixincl .. ; \
cp fixincl .. ; \
chmod 555 ../fixincl ; \
else \
echo Could not install binary fixincludes. ; \
echo Installing shell script instead. ; \
echo cp inclhack.sh ../fixinc.sh ; \
cp inclhack.sh ../fixinc.sh ; \
if [ -f ./inclhack.sh ] ; \
then cp inclhack.sh ../fixinc.sh ; \
else cp $(srcdir)/inclhack.sh ../fixinc.sh ; fi ; \
fi

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
#
# DO NOT EDIT THIS FILE (fixincl.sh)
#
# It has been autogen-ed Friday October 16, 1998 at 07:29:49 AM PDT
# It has been autogen-ed Wednesday January 27, 1999 at 09:03:56 AM PST
# From the definitions inclhack.def
# and the template file inclhack.tpl
#
@ -10,7 +10,7 @@
# files which are fixed to work correctly with ANSI C and placed in a
# directory that GNU C will search.
#
# This script contains 104 fixup scripts.
# This script contains 105 fixup scripts.
#
# See README-fixinc for more information.
#
@ -127,10 +127,7 @@ for INPUT in ${INPUTLIST} ; do
cd ${ORIGDIR}
cd ${INPUT} || {
echo 'fixincludes: input dir `'$INPUT"' is an invalid directory"
exit 1
}
cd ${INPUT} || continue
#
# # # # # # # # # # # # # # # # # # # # #
@ -344,18 +341,20 @@ while [ $# != 0 ]; do
#
cd ${INPUT}
cd $1
if [ -r $2 ] && [ ! -r $3 ]; then
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null
echo Copied $2
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
if [ -f $2 ] ; then
if [ -r $2 ] && [ ! -r $3 ]; then
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null
echo Copied $2
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
do
dir=`echo $2 | sed -e s'|/[^/]*$||'`
dir2=`echo $3 | sed -e s'|/[^/]*$||'`
newreq="$newreq $1 $dir/$include $dir2/$include"
done
do
dir=`echo $2 | sed -e s'|/[^/]*$||'`
dir2=`echo $3 | sed -e s'|/[^/]*$||'`
newreq="$newreq $1 $dir/$include $dir2/$include"
done
fi
fi
shift; shift; shift
done
@ -384,6 +383,6 @@ done
cd $ORIGDIR
rm -f include/assert.h
cp ${EGCS_SRCDIR}/assert.h include/assert.h
cp ${srcdir}/assert.h include/assert.h || exit 1
chmod a+r include/assert.h

View File

@ -1,7 +1,7 @@
/*
* DO NOT EDIT THIS FILE (fixincl.x)
*
* It has been autogen-ed Friday October 16, 1998 at 07:29:50 AM PDT
* It has been autogen-ed Tuesday January 5, 1999 at 09:20:37 AM PST
* From the definitions inclhack.def
* and the template file fixincl.tpl
*
@ -9,7 +9,7 @@
* files which are fixed to work correctly with ANSI C and placed in a
* directory that GNU C will search.
*
* This script contains 104 fixup scripts.
* This script contains 105 fixup scripts.
*
* See README-fixinc for more information.
*
@ -3005,7 +3005,41 @@ const char* apzUltrix_Ansi_CompatPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 84 - Ultrix_Atof_Param fix
* Description 84 - Ultrix_Fix_Fixproto fix
*/
tSCC zUltrix_Fix_FixprotoName[] =
"Ultrix_Fix_Fixproto";
/*
* File name selection pattern
*/
tSCC zUltrix_Fix_FixprotoList[] =
"|" "sys/utsname.h" "|";
/*
* Machine/OS name selection pattern
*/
#define apzUltrix_Fix_FixprotoMachs (const char**)NULL
/*
* content selection pattern
*/
tSCC zUltrix_Fix_FixprotoSelect0[] =
"ULTRIX";
#define ULTRIX_FIX_FIXPROTO_TEST_CT 1
tTestDesc aUltrix_Fix_FixprotoTests[] = {
{ TT_EGREP, zUltrix_Fix_FixprotoSelect0, (regex_t*)NULL } };
/*
* Fix Command Arguments for Ultrix_Fix_Fixproto
*/
const char* apzUltrix_Fix_FixprotoPatch[] = { "sed",
"-e" "/^[ \t]*extern[ \t]*int[ \t]*uname();$/i\\\n"
"struct utsname;\n",
(char*)NULL };
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 85 - Ultrix_Atof_Param fix
*/
tSCC zUltrix_Atof_ParamName[] =
"Ultrix_Atof_Param";
@ -3034,7 +3068,7 @@ const char* apzUltrix_Atof_ParamPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 85 - Ultrix_Const fix
* Description 86 - Ultrix_Const fix
*/
tSCC zUltrix_ConstName[] =
"Ultrix_Const";
@ -3067,7 +3101,7 @@ const char* apzUltrix_ConstPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 86 - Ultrix_Ifdef fix
* Description 87 - Ultrix_Ifdef fix
*/
tSCC zUltrix_IfdefName[] =
"Ultrix_Ifdef";
@ -3100,7 +3134,7 @@ const char* apzUltrix_IfdefPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 87 - Ultrix_Nested_Cmnt fix
* Description 88 - Ultrix_Nested_Cmnt fix
*/
tSCC zUltrix_Nested_CmntName[] =
"Ultrix_Nested_Cmnt";
@ -3125,7 +3159,7 @@ const char* apzUltrix_Nested_CmntPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 88 - Ultrix_Static fix
* Description 89 - Ultrix_Static fix
*/
tSCC zUltrix_StaticName[] =
"Ultrix_Static";
@ -3160,7 +3194,7 @@ const char* apzUltrix_StaticPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 89 - Undefine_Null fix
* Description 90 - Undefine_Null fix
*/
tSCC zUndefine_NullName[] =
"Undefine_Null";
@ -3200,7 +3234,7 @@ const char* apzUndefine_NullPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 90 - Va_I960_Macro fix
* Description 91 - Va_I960_Macro fix
*/
tSCC zVa_I960_MacroName[] =
"Va_I960_Macro";
@ -3236,7 +3270,7 @@ const char* apzVa_I960_MacroPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 91 - Void_Null fix
* Description 92 - Void_Null fix
*/
tSCC zVoid_NullName[] =
"Void_Null";
@ -3279,7 +3313,7 @@ const char* apzVoid_NullPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 92 - Vxworks_Gcc_Problem fix
* Description 93 - Vxworks_Gcc_Problem fix
*/
tSCC zVxworks_Gcc_ProblemName[] =
"Vxworks_Gcc_Problem";
@ -3327,7 +3361,7 @@ const char* apzVxworks_Gcc_ProblemPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 93 - Vxworks_Needs_Vxtypes fix
* Description 94 - Vxworks_Needs_Vxtypes fix
*/
tSCC zVxworks_Needs_VxtypesName[] =
"Vxworks_Needs_Vxtypes";
@ -3360,7 +3394,7 @@ const char* apzVxworks_Needs_VxtypesPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 94 - Vxworks_Needs_Vxworks fix
* Description 95 - Vxworks_Needs_Vxworks fix
*/
tSCC zVxworks_Needs_VxworksName[] =
"Vxworks_Needs_Vxworks";
@ -3407,7 +3441,7 @@ const char* apzVxworks_Needs_VxworksPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 95 - Vxworks_Time fix
* Description 96 - Vxworks_Time fix
*/
tSCC zVxworks_TimeName[] =
"Vxworks_Time";
@ -3456,7 +3490,7 @@ const char* apzVxworks_TimePatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 96 - X11_Class fix
* Description 97 - X11_Class fix
*/
tSCC zX11_ClassName[] =
"X11_Class";
@ -3494,7 +3528,7 @@ const char* apzX11_ClassPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 97 - X11_Class_Usage fix
* Description 98 - X11_Class_Usage fix
*/
tSCC zX11_Class_UsageName[] =
"X11_Class_Usage";
@ -3527,7 +3561,7 @@ const char* apzX11_Class_UsagePatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 98 - X11_New fix
* Description 99 - X11_New fix
*/
tSCC zX11_NewName[] =
"X11_New";
@ -3566,7 +3600,7 @@ const char* apzX11_NewPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 99 - X11_Sprintf fix
* Description 100 - X11_Sprintf fix
*/
tSCC zX11_SprintfName[] =
"X11_Sprintf";
@ -3593,7 +3627,7 @@ const char* apzX11_SprintfPatch[] = { "sed",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 100 - Zzz_Ki_Iface fix
* Description 101 - Zzz_Ki_Iface fix
*/
tSCC zZzz_Ki_IfaceName[] =
"Zzz_Ki_Iface";
@ -3628,7 +3662,7 @@ const char* apzZzz_Ki_IfacePatch[] = { "sh", "-c",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 101 - Zzz_Ki fix
* Description 102 - Zzz_Ki fix
*/
tSCC zZzz_KiName[] =
"Zzz_Ki";
@ -3663,7 +3697,7 @@ const char* apzZzz_KiPatch[] = { "sh", "-c",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 102 - Zzz_Ki_Calls fix
* Description 103 - Zzz_Ki_Calls fix
*/
tSCC zZzz_Ki_CallsName[] =
"Zzz_Ki_Calls";
@ -3698,7 +3732,7 @@ const char* apzZzz_Ki_CallsPatch[] = { "sh", "-c",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 103 - Zzz_Ki_Defs fix
* Description 104 - Zzz_Ki_Defs fix
*/
tSCC zZzz_Ki_DefsName[] =
"Zzz_Ki_Defs";
@ -3733,7 +3767,7 @@ const char* apzZzz_Ki_DefsPatch[] = { "sh", "-c",
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description 104 - Zzz_Time fix
* Description 105 - Zzz_Time fix
*/
tSCC zZzz_TimeName[] =
"Zzz_Time";
@ -3770,9 +3804,9 @@ const char* apzZzz_TimePatch[] = { "sh", "-c",
*
* List of all fixes
*/
#define REGEX_COUNT 75
#define FIX_COUNT 104
tFixDesc fixDescList[ 104 ] = {
#define REGEX_COUNT 76
#define FIX_COUNT 105
tFixDesc fixDescList[ 105 ] = {
{ zAix_SyswaitName, zAix_SyswaitList,
apzAix_SyswaitMachs, (regex_t*)NULL,
AIX_SYSWAIT_TEST_CT, FD_MACH_ONLY,
@ -4188,6 +4222,11 @@ tFixDesc fixDescList[ 104 ] = {
ULTRIX_ANSI_COMPAT_TEST_CT, FD_MACH_ONLY,
aUltrix_Ansi_CompatTests, apzUltrix_Ansi_CompatPatch },
{ zUltrix_Fix_FixprotoName, zUltrix_Fix_FixprotoList,
apzUltrix_Fix_FixprotoMachs, (regex_t*)NULL,
ULTRIX_FIX_FIXPROTO_TEST_CT, FD_MACH_ONLY,
aUltrix_Fix_FixprotoTests, apzUltrix_Fix_FixprotoPatch },
{ zUltrix_Atof_ParamName, zUltrix_Atof_ParamList,
apzUltrix_Atof_ParamMachs, (regex_t*)NULL,
ULTRIX_ATOF_PARAM_TEST_CT, FD_MACH_ONLY,

View File

@ -1,6 +1,5 @@
[= autogen template include =]
[=
# $Id: hackshell.tpl,v 1.2 1998/12/16 21:19:08 law Exp $
#
# This file contanes the shell template replacement for the
# fixincl program. It is the repetitive guts of the fixincludes logic.

View File

@ -1,4 +1,4 @@
/* -*- Mode: C -*- $Id: inclhack.def,v 1.2 1998/12/16 21:19:09 law Exp $ */
/* -*- Mode: C -*- */
autogen definitions inclhack;
@ -2006,6 +2006,19 @@ fix = {
};
/*
* Ultrix V4.[35] puts the declaration of uname before the definition
* of struct utsname, so the prototype (added by fixproto) causes havoc.
*/
fix = {
hackname = ultrix_fix_fixproto;
files = sys/utsname.h;
select = ULTRIX;
sed = "/^[ \t]*extern[ \t]*int[ \t]*uname();$/i\\\n"
"struct utsname;\n";
};
/*
* parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
* also get rid of bogus inline definitions in HP-UX 8.0

View File

@ -2,7 +2,7 @@
#
# DO NOT EDIT THIS FILE (inclhack.sh)
#
# It has been autogen-ed Friday October 16, 1998 at 07:29:49 AM PDT
# It has been autogen-ed Wednesday January 27, 1999 at 09:03:36 AM PST
# From the definitions inclhack.def
# and the template file inclhack.tpl
#
@ -10,7 +10,7 @@
# files which are fixed to work correctly with ANSI C and placed in a
# directory that GNU C will search.
#
# This script contains 104 fixup scripts.
# This script contains 105 fixup scripts.
#
# See README-fixinc for more information.
#
@ -125,10 +125,7 @@ for INPUT in ${INPUTLIST} ; do
cd ${ORIGDIR}
cd ${INPUT} || {
echo 'fixincludes: input dir `'$INPUT"' is an invalid directory"
exit 1
}
cd ${INPUT} || continue
#
# # # # # # # # # # # # # # # # # # # # #
@ -2464,7 +2461,30 @@ extern unsigned int\
#
# Fix 84: Ultrix_Atof_Param
# Fix 84: Ultrix_Fix_Fixproto
#
case "$file" in ./sys/utsname.h )
if ( test -n "`egrep 'ULTRIX' $file`"
) > /dev/null 2>&1 ; then
fixlist="${fixlist}
ultrix_fix_fixproto"
if [ ! -r ${DESTDIR}/$file ]
then infile=$file
else infile=${DESTDIR}/$file ; fi
sed -e '/^[ ]*extern[ ]*int[ ]*uname();$/i\
struct utsname;
' \
< $infile > ${DESTDIR}/$file.
mv -f ${DESTDIR}/$file. ${DESTDIR}/$file
fi # end of selection 'if'
;; # case end for file name test
esac
#
# Fix 85: Ultrix_Atof_Param
#
case "$file" in ./math.h )
fixlist="${fixlist}
@ -2486,7 +2506,7 @@ extern unsigned int\
#
# Fix 85: Ultrix_Const
# Fix 86: Ultrix_Const
#
case "$file" in ./stdio.h )
fixlist="${fixlist}
@ -2512,7 +2532,7 @@ extern unsigned int\
#
# Fix 86: Ultrix_Ifdef
# Fix 87: Ultrix_Ifdef
#
case "$file" in ./sys/file.h )
if ( test -n "`egrep '#ifdef KERNEL' $file`"
@ -2533,7 +2553,7 @@ extern unsigned int\
#
# Fix 87: Ultrix_Nested_Cmnt
# Fix 88: Ultrix_Nested_Cmnt
#
case "$file" in ./rpc/svc.h )
fixlist="${fixlist}
@ -2551,7 +2571,7 @@ extern unsigned int\
#
# Fix 88: Ultrix_Static
# Fix 89: Ultrix_Static
#
case "$file" in ./machine/cpu.h )
if ( test -n "`egrep '#include \"r[34]_cpu' $file`"
@ -2574,7 +2594,7 @@ extern unsigned int\
#
# Fix 89: Undefine_Null
# Fix 90: Undefine_Null
#
if ( test -n "`egrep '^#[ ]*define[ ]*[ ]NULL[ ]' $file`" -a \
-z "`egrep '#[ ]*(ifn|un)def[ ]*[ ]NULL($|[ ])' $file`"
@ -2595,7 +2615,7 @@ extern unsigned int\
#
# Fix 90: Va_I960_Macro
# Fix 91: Va_I960_Macro
#
case "$file" in ./arch/i960/archI960.h )
if ( test -n "`egrep '__(vsiz|vali|vpad|alignof__)' $file`"
@ -2619,7 +2639,7 @@ extern unsigned int\
#
# Fix 91: Void_Null
# Fix 92: Void_Null
#
case "$file" in ./curses.h | \
./dbm.h | \
@ -2650,7 +2670,7 @@ extern unsigned int\
#
# Fix 92: Vxworks_Gcc_Problem
# Fix 93: Vxworks_Gcc_Problem
#
case "$file" in ./types/vxTypesBase.h )
if ( test -n "`egrep '__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__' $file`"
@ -2692,7 +2712,7 @@ extern unsigned int\
#
# Fix 93: Vxworks_Needs_Vxtypes
# Fix 94: Vxworks_Needs_Vxtypes
#
case "$file" in ./time.h )
if ( test -n "`egrep 'uint_t[ ][ ]*_clocks_per_sec' $file`"
@ -2713,7 +2733,7 @@ extern unsigned int\
#
# Fix 94: Vxworks_Needs_Vxworks
# Fix 95: Vxworks_Needs_Vxworks
#
case "$file" in ./sys/stat.h )
if ( test -n "`egrep '#[ ]define[ ][ ]*__INCstath' $file`" -a \
@ -2739,7 +2759,7 @@ extern unsigned int\
#
# Fix 95: Vxworks_Time
# Fix 96: Vxworks_Time
#
case "$file" in ./time.h )
if ( test -n "`egrep 'VOIDFUNCPTR' $file`" -a \
@ -2771,7 +2791,7 @@ typedef void (*__gcc_VOIDFUNCPTR) ();\
#
# Fix 96: X11_Class
# Fix 97: X11_Class
#
case "$file" in ./X11/ShellP.h )
if ( test -z "`egrep '__cplusplus' $file`"
@ -2799,7 +2819,7 @@ typedef void (*__gcc_VOIDFUNCPTR) ();\
#
# Fix 97: X11_Class_Usage
# Fix 98: X11_Class_Usage
#
case "$file" in ./Xm/BaseClassI.h )
if ( test -z "`egrep '__cplusplus' $file`"
@ -2820,7 +2840,7 @@ typedef void (*__gcc_VOIDFUNCPTR) ();\
#
# Fix 98: X11_New
# Fix 99: X11_New
#
case "$file" in ./Xm/Traversal.h )
if ( test -z "`egrep '__cplusplus' $file`"
@ -2849,7 +2869,7 @@ typedef void (*__gcc_VOIDFUNCPTR) ();\
#
# Fix 99: X11_Sprintf
# Fix 100: X11_Sprintf
#
case "$file" in ./X11*/Xmu.h )
fixlist="${fixlist}
@ -2869,7 +2889,7 @@ extern char * sprintf();\
#
# Fix 100: Zzz_Ki_Iface
# Fix 101: Zzz_Ki_Iface
#
case "$file" in ./sys/ki_iface.h )
if ( test -n "`egrep 'These definitions are for HP Internal developers' $file`"
@ -2896,7 +2916,7 @@ cat > /dev/null ) < $infile > ${DESTDIR}/$file.
#
# Fix 101: Zzz_Ki
# Fix 102: Zzz_Ki
#
case "$file" in ./sys/ki.h )
if ( test -n "`egrep '11.00 HP-UX LP64' $file`"
@ -2923,7 +2943,7 @@ cat > /dev/null ) < $infile > ${DESTDIR}/$file.
#
# Fix 102: Zzz_Ki_Calls
# Fix 103: Zzz_Ki_Calls
#
case "$file" in ./sys/ki_calls.h )
if ( test -n "`egrep 'KI_MAX_PROCS is an arbitrary number' $file`"
@ -2950,7 +2970,7 @@ cat > /dev/null ) < $infile > ${DESTDIR}/$file.
#
# Fix 103: Zzz_Ki_Defs
# Fix 104: Zzz_Ki_Defs
#
case "$file" in ./sys/ki_defs.h )
if ( test -n "`egrep 'Kernel Instrumentation Definitions' $file`"
@ -2977,7 +2997,7 @@ cat > /dev/null ) < $infile > ${DESTDIR}/$file.
#
# Fix 104: Zzz_Time
# Fix 105: Zzz_Time
#
case "$file" in ./sys/time.h )
if ( test -n "`egrep 'For CASPEC, look in' $file`"
@ -3041,18 +3061,20 @@ while [ $# != 0 ]; do
#
cd ${INPUT}
cd $1
if [ -r $2 ] && [ ! -r $3 ]; then
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null
echo Copied $2
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
if [ -f $2 ] ; then
if [ -r $2 ] && [ ! -r $3 ]; then
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null
echo Copied $2
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
do
dir=`echo $2 | sed -e s'|/[^/]*$||'`
dir2=`echo $3 | sed -e s'|/[^/]*$||'`
newreq="$newreq $1 $dir/$include $dir2/$include"
done
do
dir=`echo $2 | sed -e s'|/[^/]*$||'`
dir2=`echo $3 | sed -e s'|/[^/]*$||'`
newreq="$newreq $1 $dir/$include $dir2/$include"
done
fi
fi
shift; shift; shift
done
@ -3081,6 +3103,6 @@ done
cd $ORIGDIR
rm -f include/assert.h
cp ${EGCS_SRCDIR}/assert.h include/assert.h
cp ${srcdir}/assert.h include/assert.h || exit 1
chmod a+r include/assert.h

View File

@ -1,7 +1,6 @@
[= autogen template -*- Mode: ksh -*-
sh
#
# $Id: inclhack.tpl,v 1.2 1998/12/16 21:19:11 law Exp $
#
=]
#!/bin/sh
@ -116,10 +115,7 @@ for INPUT in ${INPUTLIST} ; do
cd ${ORIGDIR}
cd ${INPUT} || {
echo 'fixincludes: input dir `'$INPUT"' is an invalid directory"
exit 1
}
cd ${INPUT} || continue
#
# # # # # # # # # # # # # # # # # # # # #
@ -342,18 +338,20 @@ while [ $# != 0 ]; do
#
cd ${INPUT}
cd $1
if [ -r $2 ] && [ ! -r $3 ]; then
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null
echo Copied $2
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
if [ -f $2 ] ; then
if [ -r $2 ] && [ ! -r $3 ]; then
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null
echo Copied $2
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
do
dir=`echo $2 | sed -e s'|/[^/]*$||'`
dir2=`echo $3 | sed -e s'|/[^/]*$||'`
newreq="$newreq $1 $dir/$include $dir2/$include"
done
do
dir=`echo $2 | sed -e s'|/[^/]*$||'`
dir2=`echo $3 | sed -e s'|/[^/]*$||'`
newreq="$newreq $1 $dir/$include $dir2/$include"
done
fi
fi
shift; shift; shift
done
@ -382,7 +380,7 @@ done
cd $ORIGDIR
rm -f include/assert.h
cp ${EGCS_SRCDIR}/assert.h include/assert.h
cp ${srcdir}/assert.h include/assert.h || exit 1
chmod a+r include/assert.h
[=

View File

@ -7,8 +7,10 @@ then
exit 1
fi
echo constructing fixinc.sh for $machine
fixincludes="../fixinc.sh"
target=../fixinc.sh
echo constructing ${target} for $machine
fixincludes="${target}"
case $machine in
*-*-gnu*)
@ -103,21 +105,47 @@ case $machine in
;;
esac
# IF there is no include fixing,
# THEN create a no-op fixer and exit
#
if test -z "$fixincludes"
then
cat > ../fixinc.sh <<- _EOF_
cat > ${target} <<- _EOF_
#! /bin/sh
exit 0
_EOF_
exit 0
fi
if test -f "$fixincludes"
# IF the fixer is supplied in our source directory,
# THEN copy that into place
#
if test -f ${srcdir}/"${fixincludes}"
then
echo copying $fixincludes to ../fixinc.sh
cp $fixincludes ../fixinc.sh
echo copying ${srcdir}/$fixincludes to ${target}
cp ${srcdir}/$fixincludes ${target}
exit 0
fi
echo $MAKE install
$MAKE install || cp inclhack.sh ..
# OK. We gotta make the thing.
#
echo $MAKE SHELL=\"$SHELL\" install
# make and install either the binary or the default script
#
$MAKE SHELL="$SHELL" install && exit 0
# Where is our inclhack script? That is the backup
# in case we are unable to make a working binary.
#
if test -f ./inclhack.sh
then
INCLHACK=./inclhack.sh
else
INCLHACK=${srcdir}/inclhack.sh
fi
echo Could not install binary fixincludes.
echo Installing shell script instead.
cp ${INCLHACK} ${target}

260
gcc/fixinc/procopen.c Normal file
View File

@ -0,0 +1,260 @@
/*
* server.c Set up and handle communications with a server process.
*
* Server Handling copyright 1992-1999 The Free Software Foundation
*
* Server Handling is free software.
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2, or (at your option) any later version.
*
* Server Handling is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Server Handling. See the file "COPYING". If not,
* write to: The Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* As a special exception, The Free Software Foundation gives
* permission for additional uses of the text contained in his release
* of ServerHandler.
*
* The exception is that, if you link the ServerHandler library with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the ServerHandler library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by The Free
* Software Foundation under the name ServerHandler. If you copy code
* from other sources under the General Public License into a copy of
* ServerHandler, as the General Public License permits, the exception
* does not apply to the code that you add in this way. To avoid
* misleading anyone as to the status of such modified files, you must
* delete this exception notice from them.
*
* If you write modifications of your own for ServerHandler, it is your
* choice whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
#include "config.h"
#include <sys/types.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/param.h>
#include "server.h"
/* If this particular system's header files define the macro `MAXPATHLEN',
we happily take advantage of it; otherwise we use a value which ought
to be large enough. */
#ifndef MAXPATHLEN
# define MAXPATHLEN 4096
#endif
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
# define STDOUT_FILENO 1
#endif
#ifdef DEBUG
#define STATIC
#else
#define STATIC static
#endif
#ifndef tSCC
#define tSCC static const char
#endif
#ifndef NUL
#define NUL '\0'
#endif
STATIC t_pchar def_args[] =
{ (char *) NULL, (char *) NULL };
/*
* chain_open
*
* Given an FD for an inferior process to use as stdin,
* start that process and return a NEW FD that that process
* will use for its stdout. Requires the argument vector
* for the new process and, optionally, a pointer to a place
* to store the child's process id.
*/
int
chain_open (stdin_fd, pp_args, p_child)
int stdin_fd;
t_pchar *pp_args;
pid_t *p_child;
{
t_fd_pair stdout_pair = {-1, -1};
pid_t ch_id;
char *pz_cmd;
/*
* Create a pipe it will be the child process' stdout,
* and the parent will read from it.
*/
if (pipe ((int *) &stdout_pair) < 0)
{
if (p_child != (pid_t *) NULL)
*p_child = NOPROCESS;
return -1;
}
/*
* If we did not get an arg list, use the default
*/
if (pp_args == (t_pchar *) NULL)
pp_args = def_args;
/*
* If the arg list does not have a program,
* assume the "SHELL" from the environment, or, failing
* that, then sh. Set argv[0] to whatever we decided on.
*/
if (pz_cmd = *pp_args,
(pz_cmd == (char *) NULL) || (*pz_cmd == '\0'))
{
pz_cmd = getenv ("SHELL");
if (pz_cmd == (char *) NULL)
pz_cmd = "sh";
}
#ifdef DEBUG_PRINT
printf ("START: %s\n", pz_cmd);
{
int idx = 0;
while (pp_args[++idx] != (char *) NULL)
printf (" ARG %2d: %s\n", idx, pp_args[idx]);
}
#endif
/*
* Call fork() and see which process we become
*/
ch_id = fork ();
switch (ch_id)
{
case NOPROCESS: /* parent - error in call */
close (stdout_pair.read_fd);
close (stdout_pair.write_fd);
if (p_child != (pid_t *) NULL)
*p_child = NOPROCESS;
return -1;
default: /* parent - return opposite FD's */
if (p_child != (pid_t *) NULL)
*p_child = ch_id;
#ifdef DEBUG_PRINT
printf ("for pid %d: stdin from %d, stdout to %d\n"
"for parent: read from %d\n",
ch_id, stdin_fd, stdout_pair.write_fd, stdout_pair.read_fd);
#endif
close (stdin_fd);
close (stdout_pair.write_fd);
return stdout_pair.read_fd;
case NULLPROCESS: /* child - continue processing */
break;
}
/*
* Close the pipe end handed back to the parent process
*/
close (stdout_pair.read_fd);
/*
* Close our current stdin and stdout
*/
close (STDIN_FILENO);
close (STDOUT_FILENO);
/*
* Make the fd passed in the stdin, and the write end of
* the new pipe become the stdout.
*/
fcntl (stdout_pair.write_fd, F_DUPFD, STDOUT_FILENO);
fcntl (stdin_fd, F_DUPFD, STDIN_FILENO);
if (*pp_args == (char *) NULL)
*pp_args = pz_cmd;
execvp (pz_cmd, pp_args);
fprintf (stderr, "Error %d: Could not execvp( '%s', ... ): %s\n",
errno, pz_cmd, strerror (errno));
exit (EXIT_PANIC);
}
/*
* proc2_open
*
* Given a pointer to an argument vector, start a process and
* place its stdin and stdout file descriptors into an fd pair
* structure. The "write_fd" connects to the inferior process
* stdin, and the "read_fd" connects to its stdout. The calling
* process should write to "write_fd" and read from "read_fd".
* The return value is the process id of the created process.
*/
pid_t
proc2_open (p_pair, pp_args)
t_fd_pair *p_pair;
t_pchar *pp_args;
{
pid_t ch_id;
/* Create a bi-directional pipe. Writes on 0 arrive on 1 and vice
versa, so the parent and child processes will read and write to
opposite FD's. */
if (pipe ((int *) p_pair) < 0)
return NOPROCESS;
p_pair->read_fd = chain_open (p_pair->read_fd, pp_args, &ch_id);
if (ch_id == NOPROCESS)
close (p_pair->write_fd);
return ch_id;
}
/*
* proc2_fopen
*
* Identical to "proc2_open()", except that the "fd"'s are
* "fdopen(3)"-ed into file pointers instead.
*/
pid_t
proc2_fopen (pf_pair, pp_args)
t_pf_pair *pf_pair;
t_pchar *pp_args;
{
t_fd_pair fd_pair;
pid_t ch_id = proc2_open (&fd_pair, pp_args);
if (ch_id == NOPROCESS)
return ch_id;
pf_pair->pf_read = fdopen (fd_pair.read_fd, "r");
pf_pair->pf_write = fdopen (fd_pair.write_fd, "w");
return ch_id;
}

View File

@ -25,8 +25,6 @@
#pragma alloca
#endif
/* $Id: regex.c,v 1.3 1999/01/11 13:34:23 law Exp $ */
#define _GNU_SOURCE
/* We need this for `regex.h', and perhaps for the Emacs include files. */

View File

@ -18,8 +18,6 @@
Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* $Id: regex.h,v 1.3 1999/01/11 13:34:25 law Exp $ */
#ifndef __REGEXP_LIBRARY_H__
#define __REGEXP_LIBRARY_H__

View File

@ -1,8 +1,8 @@
/*
* $Id: server.c,v 1.2 1998/12/16 21:19:16 law Exp $
* server.c Set up and handle communications with a server process.
*
* Server Handling copyright 1992-1998 Bruce Korb
* Server Handling copyright 1992-1999 The Free Software Foundation
*
* Server Handling is free software.
* You may redistribute it and/or modify it under the terms of the
@ -20,8 +20,9 @@
* 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* As a special exception, Bruce Korb gives permission for additional
* uses of the text contained in his release of ServerHandler.
* As a special exception, The Free Software Foundation gives
* permission for additional uses of the text contained in his release
* of ServerHandler.
*
* The exception is that, if you link the ServerHandler library with other
* files to produce an executable, this does not by itself cause the
@ -32,19 +33,24 @@
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by Bruce Korb under
* the name ServerHandler. If you copy code from other sources under the
* General Public License into a copy of ServerHandler, as the General Public
* License permits, the exception does not apply to the code that you add
* in this way. To avoid misleading anyone as to the status of such
* modified files, you must delete this exception notice from them.
* This exception applies only to the code released by The Free
* Software Foundation under the name ServerHandler. If you copy code
* from other sources under the General Public License into a copy of
* ServerHandler, as the General Public License permits, the exception
* does not apply to the code that you add in this way. To avoid
* misleading anyone as to the status of such modified files, you must
* delete this exception notice from them.
*
* If you write modifications of your own for ServerHandler, it is your
* choice whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
#include "config.h"
#include <sys/types.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
@ -54,6 +60,20 @@
#include "server.h"
/* If this particular system's header files define the macro `MAXPATHLEN',
we happily take advantage of it; otherwise we use a value which ought
to be large enough. */
#ifndef MAXPATHLEN
# define MAXPATHLEN 4096
#endif
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
# define STDOUT_FILENO 1
#endif
#ifdef DEBUG
#define STATIC
#else
@ -66,398 +86,218 @@
#define NUL '\0'
#endif
STATIC bool readPipeTimeout;
STATIC bool read_pipe_timeout;
STATIC tpChar defArgs[] =
{(char *) NULL, "-p", (char *) NULL};
STATIC tpfPair serverPair =
{(FILE *) NULL, (FILE *) NULL};
STATIC pid_t serverId = NULLPROCESS;
STATIC t_pchar def_args[] =
{ (char *) NULL, (char *) NULL };
STATIC t_pf_pair server_pair =
{ (FILE *) NULL, (FILE *) NULL };
STATIC pid_t server_id = NULLPROCESS;
/*
* Arbitrary text that should not be found in the shell output.
* It must be a single line and appear verbatim at the start of
* the terminating output line.
*/
tSCC zDone[] = "ShElL-OuTpUt-HaS-bEeN-cOmPlEtEd";
STATIC tpChar pCurDir = (char *) NULL;
tSCC z_done[] = "ShElL-OuTpUt-HaS-bEeN-cOmPlEtEd";
STATIC t_pchar p_cur_dir = (char *) NULL;
/*
* chainOpen
*
* Given an FD for an inferior process to use as stdin,
* start that process and return a NEW FD that that process
* will use for its stdout. Requires the argument vector
* for the new process and, optionally, a pointer to a place
* to store the child's process id.
*/
int
chainOpen (stdinFd, ppArgs, pChild)
int stdinFd;
tpChar *ppArgs;
pid_t *pChild;
{
tFdPair stdoutPair =
{-1, -1};
pid_t chId;
char *pzCmd;
/*
* Create a pipe it will be the child process' stdout,
* and the parent will read from it.
*/
if ((pipe ((int *) &stdoutPair) < 0))
{
if (pChild != (pid_t *) NULL)
*pChild = NOPROCESS;
return -1;
}
/*
* If we did not get an arg list, use the default
*/
if (ppArgs == (tpChar *) NULL)
ppArgs = defArgs;
/*
* If the arg list does not have a program,
* assume the "SHELL" from the environment, or, failing
* that, then sh. Set argv[0] to whatever we decided on.
*/
if (pzCmd = *ppArgs,
(pzCmd == (char *) NULL) || (*pzCmd == '\0'))
{
pzCmd = getenv ("SHELL");
if (pzCmd == (char *) NULL)
pzCmd = "sh";
}
#ifdef DEBUG_PRINT
printf ("START: %s\n", pzCmd);
{
int idx = 0;
while (ppArgs[++idx] != (char *) NULL)
printf (" ARG %2d: %s\n", idx, ppArgs[idx]);
}
#endif
/*
* Call fork() and see which process we become
*/
chId = fork ();
switch (chId)
{
case NOPROCESS: /* parent - error in call */
close (stdoutPair.readFd);
close (stdoutPair.writeFd);
if (pChild != (pid_t *) NULL)
*pChild = NOPROCESS;
return -1;
default: /* parent - return opposite FD's */
if (pChild != (pid_t *) NULL)
*pChild = chId;
#ifdef DEBUG_PRINT
printf ("for pid %d: stdin from %d, stdout to %d\n"
"for parent: read from %d\n",
chId, stdinFd, stdoutPair.writeFd, stdoutPair.readFd);
#endif
close (stdinFd);
close (stdoutPair.writeFd);
return stdoutPair.readFd;
case NULLPROCESS: /* child - continue processing */
break;
}
/*
* Close the pipe end handed back to the parent process
*/
close (stdoutPair.readFd);
/*
* Close our current stdin and stdout
*/
close (STDIN_FILENO);
close (STDOUT_FILENO);
/*
* Make the fd passed in the stdin, and the write end of
* the new pipe become the stdout.
*/
fcntl (stdoutPair.writeFd, F_DUPFD, STDOUT_FILENO);
fcntl (stdinFd, F_DUPFD, STDIN_FILENO);
if (*ppArgs == (char *) NULL)
*ppArgs = pzCmd;
execvp (pzCmd, ppArgs);
fprintf (stderr, "Error %d: Could not execvp( '%s', ... ): %s\n",
errno, pzCmd, strerror (errno));
exit (EXIT_PANIC);
}
/*
* p2open
*
* Given a pointer to an argument vector, start a process and
* place its stdin and stdout file descriptors into an fd pair
* structure. The "writeFd" connects to the inferior process
* stdin, and the "readFd" connects to its stdout. The calling
* process should write to "writeFd" and read from "readFd".
* The return value is the process id of the created process.
*/
pid_t
p2open (pPair, ppArgs)
tFdPair *pPair;
tpChar *ppArgs;
{
pid_t chId;
/*
* Create a bi-directional pipe. Writes on 0 arrive on 1
* and vice versa, so the parent and child processes will
* read and write to opposite FD's.
*/
if (pipe ((int *) pPair) < 0)
return NOPROCESS;
pPair->readFd = chainOpen (pPair->readFd, ppArgs, &chId);
if (chId == NOPROCESS)
close (pPair->writeFd);
return chId;
}
/*
* p2fopen
*
* Identical to "p2open()", except that the "fd"'s are "fdopen(3)"-ed
* into file pointers instead.
*/
pid_t
p2fopen (pfPair, ppArgs)
tpfPair *pfPair;
tpChar *ppArgs;
{
tFdPair fdPair;
pid_t chId = p2open (&fdPair, ppArgs);
if (chId == NOPROCESS)
return chId;
pfPair->pfRead = fdopen (fdPair.readFd, "r");
pfPair->pfWrite = fdopen (fdPair.writeFd, "w");
return chId;
}
/*
* loadData
* load_data
*
* Read data from a file pointer (a pipe to a process in this context)
* until we either get EOF or we get a marker line back.
* The read data are stored in a malloc-ed string that is truncated
* to size at the end. Input is assumed to be an ASCII string.
*/
STATIC char *
loadData (fp)
static char *
load_data (fp)
FILE *fp;
{
char *pzText;
size_t textSize;
char *pzScan;
char zLine[1024];
char *pz_text;
size_t text_size;
char *pz_scan;
char z_line[1024];
textSize = sizeof (zLine) * 2;
pzScan = \
pzText = malloc (textSize);
text_size = sizeof (z_line) * 2;
pz_scan = pz_text = malloc (text_size);
if (pzText == (char *) NULL)
return pzText;
if (pz_text == (char *) NULL)
return (char *) NULL;
for (;;)
{
size_t usedCt;
size_t used_ct;
alarm (10);
readPipeTimeout = BOOL_FALSE;
if (fgets (zLine, sizeof (zLine), fp) == (char *) NULL)
break;
read_pipe_timeout = BOOL_FALSE;
if (fgets (z_line, sizeof (z_line), fp) == (char *) NULL)
break;
if (strncmp (zLine, zDone, sizeof (zDone) - 1) == 0)
break;
if (strncmp (z_line, z_done, sizeof (z_done) - 1) == 0)
break;
strcpy (pzScan, zLine);
pzScan += strlen (zLine);
usedCt = (size_t) (pzScan - pzText);
strcpy (pz_scan, z_line);
pz_scan += strlen (z_line);
used_ct = (size_t) (pz_scan - pz_text);
if (textSize - usedCt < sizeof (zLine))
{
size_t off = (size_t) (pzScan - pzText);
void *p;
textSize += 4096;
p = realloc ((void *) pzText, textSize);
if (p == (void *) NULL)
{
fprintf (stderr, "Failed to get 0x%08X bytes\n", textSize);
free ((void *) pzText);
return (char *) NULL;
}
pzText = (char *) p;
pzScan = pzText + off;
}
if (text_size - used_ct < sizeof (z_line))
{
size_t off = (size_t) (pz_scan - pz_text);
void *p;
text_size += 4096;
p = realloc ((void *) pz_text, text_size);
if (p == (void *) NULL)
{
fprintf (stderr, "Failed to get 0x%08X bytes\n", text_size);
free ((void *) pz_text);
return (char *) NULL;
}
pz_text = (char *) p;
pz_scan = pz_text + off;
}
}
alarm (0);
if (readPipeTimeout)
if (read_pipe_timeout)
{
free ((void *) pzText);
free ((void *) pz_text);
return (char *) NULL;
}
while ((pzScan > pzText) && isspace (pzScan[-1]))
pzScan--;
*pzScan = NUL;
return realloc ((void *) pzText, strlen (pzText) + 1);
while ((pz_scan > pz_text) && isspace (pz_scan[-1]))
pz_scan--;
*pz_scan = NUL;
return realloc ((void *) pz_text, strlen (pz_text) + 1);
}
/*
* SHELL SERVER PROCESS CODE
* close_server
*
* Make certain the server process is dead, close the
* pipes to it and from it, finally NULL out the file pointers
*/
#ifdef DONT_HAVE_SIGSEND
typedef enum
static void
close_server ()
{
P_ALL, P_PID, P_GID, P_UID, P_PGID, P_SID, P_CID
}
idtype_t;
typedef long id_t;
STATIC int
sigsend (idtype, id, sig)
idtype_t idtype;
id_t id;
int sig;
{
switch (idtype)
{
case P_PID:
kill ((pid_t) id, sig);
break;
case P_ALL:
case P_GID:
case P_UID:
case P_PGID:
case P_SID:
case P_CID:
errno = EINVAL;
return -1;
/*NOTREACHED */
}
return 0;
}
#endif /* HAVE_SIGSEND */
STATIC void
closeServer ()
{
kill( (pid_t) serverId, SIGKILL);
serverId = NULLPROCESS;
fclose (serverPair.pfRead);
fclose (serverPair.pfWrite);
serverPair.pfRead = serverPair.pfWrite = (FILE *) NULL;
kill ((pid_t) server_id, SIGKILL);
server_id = NULLPROCESS;
fclose (server_pair.pf_read);
fclose (server_pair.pf_write);
server_pair.pf_read = server_pair.pf_write = (FILE *) NULL;
}
struct sigaction savePipeAction;
struct sigaction saveAlrmAction;
struct sigaction currentAction;
STATIC void
sigHandler (signo)
/*
* sig_handler really only handles the timeout and pipe signals.
* This ensures that we do not wait forever on a request
* to our server, and also that if the server dies, we do not
* die from a sigpipe problem.
*/
static void
sig_handler (signo)
int signo;
{
closeServer ();
readPipeTimeout = BOOL_TRUE;
close_server ();
read_pipe_timeout = BOOL_TRUE;
}
STATIC void
serverSetup ()
/*
* server_setup Establish the signal handler for PIPE and ALARM.
* Also establishes the current directory to give to the
* server process at the start of every server command.
*/
static void
server_setup ()
{
#ifndef SA_SIGINFO
# define SA_SIGINFO 0
#else
currentAction.sa_sigaction =
#endif
currentAction.sa_handler = sigHandler;
currentAction.sa_flags = SA_SIGINFO;
sigemptyset( &currentAction.sa_mask );
static int atexit_done = 0;
if (atexit_done++ == 0)
atexit (&close_server);
sigaction( SIGPIPE, &currentAction, &savePipeAction );
sigaction( SIGALRM, &currentAction, &saveAlrmAction );
atexit( &closeServer );
signal (SIGPIPE, sig_handler);
signal (SIGALRM, sig_handler);
fputs ("trap : INT\n", serverPair.pfWrite);
fflush (serverPair.pfWrite);
pCurDir = getcwd ((char *) NULL, MAXPATHLEN + 1);
fputs ("trap : 1\n", server_pair.pf_write);
fflush (server_pair.pf_write);
p_cur_dir = getcwd ((char *) NULL, MAXPATHLEN + 1);
}
/*
* run_shell
*
* Run a shell command on the server. The command string
* passed in is wrapped inside the sequence:
*
* cd <original directory>
* <command string>
* echo
* echo <end-of-command-marker>
*
* This ensures that all commands start at a known place in
* the directory structure, that any incomplete output lines
* are completed and that our special marker sequence appears on
* a line by itself. We have chosen a marker that is
* excessively unlikely to be reproduced in normal output:
*
* "ShElL-OuTpUt-HaS-bEeN-cOmPlEtEd"
*/
char *
runShell (pzCmd)
const char *pzCmd;
run_shell (pz_cmd)
const char *pz_cmd;
{
tSCC zNil[] = "";
/*
* IF the shell server process is not running yet,
* THEN try to start it.
*/
if (serverId == NULLPROCESS)
/* IF the shell server process is not running yet,
THEN try to start it. */
if (server_id == NULLPROCESS)
{
serverId = p2fopen (&serverPair, defArgs);
if (serverId > 0)
serverSetup ();
server_id = proc2_fopen (&server_pair, def_args);
if (server_id > 0)
server_setup ();
}
/*
* IF it is still not running,
* THEN return the nil string.
*/
if (serverId <= 0)
return (char *) zNil;
/* IF it is still not running, THEN return the nil string. */
if (server_id <= 0)
{
char *pz = (char *) malloc (1);
if (pz != (char *) NULL)
*pz = '\0';
return pz;
}
/*
* Make sure the process will pay attention to us,
* send the supplied command, and then
* have it output a special marker that we can find.
*/
fprintf (serverPair.pfWrite, "\\cd %s\n%s\n\necho\necho %s\n",
pCurDir, pzCmd, zDone);
fflush (serverPair.pfWrite);
if (serverId == NULLPROCESS)
return (char *) NULL;
/* Make sure the process will pay attention to us, send the
supplied command, and then have it output a special marker that
we can find. */
fprintf (server_pair.pf_write, "\\cd %s\n%s\n\necho\necho %s\n",
p_cur_dir, pz_cmd, z_done);
fflush (server_pair.pf_write);
/*
* Now try to read back all the data. If we fail due to either
* a sigpipe or sigalrm (timeout), we will return the nil string.
*/
/* IF the server died and we received a SIGPIPE,
THEN return an empty string. */
if (server_id == NULLPROCESS)
{
char *pz = (char *) malloc (1);
if (pz != (char *) NULL)
*pz = '\0';
return pz;
}
/* Now try to read back all the data. If we fail due to either a
sigpipe or sigalrm (timeout), we will return the nil string. */
{
char *pz = loadData (serverPair.pfRead);
char *pz = load_data (server_pair.pf_read);
if (pz == (char *) NULL)
{
fprintf (stderr, "CLOSING SHELL SERVER - command failure:\n\t%s\n",
pzCmd);
closeServer ();
pz = (char *) zNil;
fprintf (stderr, "CLOSING SHELL SERVER - command failure:\n\t%s\n",
pz_cmd);
close_server ();
pz = (char *) malloc (1);
if (pz != (char *) NULL)
*pz = '\0';
}
return pz;
}

View File

@ -1,8 +1,8 @@
/*
* $Id: server.h,v 1.2 1998/12/16 21:19:17 law Exp $
* server.c Set up and handle communications with a server process.
*
* Server Handling copyright 1992-1998 Bruce Korb
* Server Handling copyright 1992-1999 The Free Software Foundation
*
* Server Handling is free software.
* You may redistribute it and/or modify it under the terms of the
@ -20,8 +20,9 @@
* 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* As a special exception, Bruce Korb gives permission for additional
* uses of the text contained in his release of ServerHandler.
* As a special exception, The Free Software Foundation gives
* permission for additional uses of the text contained in his release
* of ServerHandler.
*
* The exception is that, if you link the ServerHandler library with other
* files to produce an executable, this does not by itself cause the
@ -32,12 +33,13 @@
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by Bruce Korb under
* the name ServerHandler. If you copy code from other sources under the
* General Public License into a copy of ServerHandler, as the General Public
* License permits, the exception does not apply to the code that you add
* in this way. To avoid misleading anyone as to the status of such
* modified files, you must delete this exception notice from them.
* This exception applies only to the code released by The Free
* Software Foundation under the name ServerHandler. If you copy code
* from other sources under the General Public License into a copy of
* ServerHandler, as the General Public License permits, the exception
* does not apply to the code that you add in this way. To avoid
* misleading anyone as to the status of such modified files, you must
* delete this exception notice from them.
*
* If you write modifications of your own for ServerHandler, it is your
* choice whether to permit this exception to apply to your modifications.
@ -48,47 +50,45 @@
#define FIXINC_SERVER_H
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/*
* Dual pipe opening of a child process
*/
typedef struct
{
int readFd;
int writeFd;
}
tFdPair;
{
int read_fd;
int write_fd;
} t_fd_pair;
typedef struct
{
FILE *pfRead; /* parent read fp */
FILE *pfWrite; /* parent write fp */
}
tpfPair;
{
FILE *pf_read; /* parent read fp */
FILE *pf_write; /* parent write fp */
} t_pf_pair;
typedef char *tpChar;
typedef char *t_pchar;
#define NOPROCESS ((pid_t)-1)
#define NULLPROCESS ((pid_t)0)
#define NOPROCESS ((pid_t) -1)
#define NULLPROCESS ((pid_t)0)
#define EXIT_PANIC 99
#define EXIT_PANIC 99
typedef enum
{
BOOL_FALSE, BOOL_TRUE
}
bool;
{
BOOL_FALSE, BOOL_TRUE
} bool;
#define _P_(p) ()
#define _P_(p) ()
char *runShell _P_ ((const char *pzCmd));
pid_t p2fopen _P_ ((tpfPair * pfPair, tpChar * ppArgs));
pid_t p2open _P_ ((tFdPair * pPair, tpChar * ppArgs));
int
chainOpen _P_ ((int stdinFd,
tpChar * ppArgs,
pid_t * pChild));
char *run_shell _P_ (( const char *pzCmd));
pid_t proc2_fopen _P_ (( t_pf_pair * p_pair, t_pchar * pp_args));
pid_t proc2_open _P_ (( t_fd_pair * p_pair, t_pchar * pp_args));
int chain_open _P_ (( int in_fd,
t_pchar * pp_args,
pid_t * p_child));
#endif /* FIXINC_SERVER_H */