Changeset 578
- Timestamp:
- 08/21/05 06:37:53 (7 years ago)
- Location:
- trunk/ithildin
- Files:
-
- 43 edited
-
Makefile.in (modified) (1 diff)
-
autoconf/config.guess (modified) (13 diffs)
-
autoconf/config.sub (modified) (6 diffs)
-
autoconf/configure.ac (modified) (22 diffs)
-
autoconf/install-sh (modified) (7 diffs)
-
doc/conf/ithildin.conf (modified) (1 diff)
-
doc/conf/proxyscan.conf (modified) (2 diffs)
-
doc/style.txt (modified) (1 diff)
-
include/ithildin/conf.h (modified) (2 diffs)
-
include/ithildin/event.h (modified) (3 diffs)
-
include/ithildin/global.h (modified) (2 diffs)
-
include/ithildin/hash.h (modified) (1 diff)
-
include/ithildin/log.h (modified) (1 diff)
-
include/ithildin/malloc.h (modified) (1 diff)
-
include/ithildin/md5.h (modified) (1 diff)
-
include/ithildin/module.h (modified) (9 diffs)
-
include/ithildin/queue.h (modified) (14 diffs)
-
include/ithildin/socket.h (modified) (5 diffs)
-
include/ithildin/string.h (modified) (1 diff)
-
include/ithildin/timer.h (modified) (1 diff)
-
source/Makefile.in (modified) (2 diffs)
-
source/conf.c (modified) (19 diffs)
-
source/contrib/fmtcheck.c (modified) (4 diffs)
-
source/contrib/gailib.c (modified) (6 diffs)
-
source/contrib/strlcat.c (modified) (1 diff)
-
source/contrib/strlcpy.c (modified) (2 diffs)
-
source/event.c (modified) (9 diffs)
-
source/hash.c (modified) (13 diffs)
-
source/log.c (modified) (4 diffs)
-
source/main.c (modified) (25 diffs)
-
source/malloc.c (modified) (31 diffs)
-
source/md5.c (modified) (9 diffs)
-
source/md5sum.c (modified) (1 diff)
-
source/module.c (modified) (35 diffs)
-
source/poller_kqueue.c (modified) (2 diffs)
-
source/poller_poll.c (modified) (1 diff)
-
source/poller_select.c (modified) (1 diff)
-
source/socket.c (modified) (33 diffs)
-
source/string.c (modified) (29 diffs)
-
source/timer.c (modified) (7 diffs)
-
source/util.c (modified) (9 diffs)
-
tools/modver.sh (modified) (1 diff)
-
tools/repover.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ithildin/Makefile.in
r576 r578 40 40 41 41 base_build: 42 @echo ">>> building base system ..."43 @repover=`sh tools/repover.sh` ;\44 (cd source && $(MAKE) REPOVER=$$repover all)45 @echo "<<< finished building base system"42 @echo ">>> building base system ..." 43 @repover=`sh tools/repover.sh` ; \ 44 (cd source && $(MAKE) REPOVER=$$repover all) 45 @echo "<<< finished building base system" 46 46 47 47 modules_build: 48 @(cd modules && $(MAKE) all)48 @(cd modules && $(MAKE) all) 49 49 50 50 base_install: base_build 51 mkdir -p $(BINDIR)52 $(INSTALL) -b source/$(PACKAGE) $(BINDIR)53 $(INSTALL) source/md5sum $(BINDIR)51 mkdir -p $(BINDIR) 52 $(INSTALL) -b source/$(PACKAGE) $(BINDIR) 53 $(INSTALL) source/md5sum $(BINDIR) 54 54 55 55 conf_install: 56 @if test -e $(CONFDIR)/$(PACKAGE).conf; then\57 echo ">>> not overwriting conf files";\58 else\59 echo ">>> installing configuration files";\60 mkdir -p $(CONFDIR);\61 $(INSTALL) -b -m 644 doc/conf/*.conf $(CONFDIR);\62 fi63 56 @if test -e $(CONFDIR)/$(PACKAGE).conf; then\ 57 echo ">>> not overwriting conf files";\ 58 else\ 59 echo ">>> installing configuration files";\ 60 mkdir -p $(CONFDIR);\ 61 $(INSTALL) -b -m 644 doc/conf/*.conf $(CONFDIR);\ 62 fi 63 64 64 data_install: 65 mkdir -p $(DATADIR)/doc66 @echo ">>> installing data files in $(DATADIR)"67 @$(INSTALL) -m 644 COPYING DEVELOPERS README TODO $(DATADIR)68 @echo ">>> installing documentation in $(DATADIR)/doc"69 @cd doc && for f in `find . \! -path '*/.svn*' -type f` ; do\70 df=`dirname $$f`;\71 mkdir -p $(DATADIR)/doc/$$df;\72 $(INSTALL) -m 644 $$f $(DATADIR)/doc/$$df;\73 done65 mkdir -p $(DATADIR)/doc 66 @echo ">>> installing data files in $(DATADIR)" 67 @$(INSTALL) -m 644 COPYING DEVELOPERS README TODO $(DATADIR) 68 @echo ">>> installing documentation in $(DATADIR)/doc" 69 @cd doc && for f in `find . \! -path '*/.svn*' -type f` ; do \ 70 df=`dirname $$f` ;\ 71 mkdir -p $(DATADIR)/doc/$$df ;\ 72 $(INSTALL) -m 644 $$f $(DATADIR)/doc/$$df ;\ 73 done 74 74 75 75 include_install: 76 mkdir -p $(INCDIR)77 @echo ">>> installing include files in $(INCDIR)"78 $(INSTALL) -m 644 include/*.h $(INCDIR)76 mkdir -p $(INCDIR) 77 @echo ">>> installing include files in $(INCDIR)" 78 $(INSTALL) -m 644 include/*.h $(INCDIR) 79 79 80 80 modules_install: modules_build 81 @cd modules; $(MAKE) install81 @cd modules; $(MAKE) install 82 82 83 83 install: base_install modules_install conf_install data_install include_install 84 @echo ">>> well, there you have it. everything installed. enjoy!"84 @echo ">>> well, there you have it. everything installed. enjoy!" 85 85 86 86 clean: 87 @echo ">>> cleaning base"88 rm -f *~ doc/*~ include/*~ source/*~ *.core source/*.core89 rm -f source/*.[do] source/$(PACKAGE) source/md5sum90 @cd modules; $(MAKE) clean91 @echo "<<< finished cleaning"87 @echo ">>> cleaning base" 88 rm -f *~ doc/*~ include/*~ source/*~ *.core source/*.core 89 rm -f source/*.[do] source/$(PACKAGE) source/md5sum 90 @cd modules; $(MAKE) clean 91 @echo "<<< finished cleaning" 92 92 93 93 distclean: clean 94 rm -rf autom4te.cache config.log config.status configure.lineno95 rm -f tags source/tags include/config.h96 rm -f Makefile source/Makefile modules/Makefile doc/conf/Makefile97 rm -f `find . -name '*.d'`94 rm -rf autom4te.cache config.log config.status configure.lineno 95 rm -f tags source/tags include/config.h 96 rm -f Makefile source/Makefile modules/Makefile doc/conf/Makefile 97 rm -f `find . -name '*.d'` 98 98 99 99 update: clean 100 svn update101 @cfgline=`grep -E '^ \\$$' config.log | head -1 |\102 sed 's/^ \\$$ //' | sed 's/--quiet//'`;\103 if test autoconf/configure.ac -nt configure ; then\104 echo ">>> updating configure and include/config.h.in";\105 autoconf -o configure autoconf/configure.ac;\106 autoheader autoconf/configure.ac;\107 echo ">>> re-running configure as:";\108 echo " $$cfgline";\109 $$cfgline;\110 fi100 svn update 101 @cfgline=`grep -E '^ \\$$' config.log | head -1 | \ 102 sed 's/^ \\$$ //' | sed 's/--quiet//'` ;\ 103 if test autoconf/configure.ac -nt configure ; then \ 104 echo ">>> updating configure and include/config.h.in" ;\ 105 autoconf -o configure autoconf/configure.ac ;\ 106 autoheader autoconf/configure.ac ;\ 107 echo ">>> re-running configure as:" ;\ 108 echo " $$cfgline" ;\ 109 $$cfgline ;\ 110 fi 111 111 112 112 reconf: reconfigure 113 113 reconfig: reconfigure 114 114 reconfigure: 115 @cfgline=`grep -E '^ \\$$' config.log | head -1 | sed 's/^ \\$$ //'`;\116 echo ">>> re-running configure as:";\117 echo " $$cfgline";\118 $$cfgline115 @cfgline=`grep -E '^ \\$$' config.log | head -1 | sed 's/^ \\$$ //'`;\ 116 echo ">>> re-running configure as:" ;\ 117 echo " $$cfgline" ;\ 118 $$cfgline 119 119 120 DISTFILES = .svn COPYING DEVELOPERS Makefile.in README TODO autoconf \121 configure doc include source tools120 DISTFILES = .svn COPYING DEVELOPERS Makefile.in README TODO autoconf \ 121 configure doc include source tools 122 122 MDISTFILES = modules/.svn modules/Makefile.in 123 123 124 124 release: clean 125 @repover=`sh tools/repover.sh` ;\126 echo ">>> building release for revision $$repover ..." ;\127 autoconf -o configure autoconf/configure.ac ;\128 autoheader autoconf/configure.ac ;\129 rm -rf dist ;\130 mkdir -p dist/$$repover ;\131 echo ">>> building release for base system in $(VERSION).tar.gz";\132 mkdir dist/$$repover/$(VERSION) ;\133 cp -R $(DISTFILES) dist/$$repover/$(VERSION) ;\134 mkdir -p dist/$$repover/$(VERSION)/modules ;\135 cp -R $(MDISTFILES) dist/$$repover/$(VERSION)/modules ;\136 (cd dist/$$repover && tar -zcf $(VERSION).tar.gz $(VERSION)) ;\137 rm -rf dist/$$repover/$(VERSION) ;\138 (cd modules && $(MAKE) REPOVER=$$repover release) ;\139 echo "<<< finished building release in dist/$$repover"125 @repover=`sh tools/repover.sh` ; \ 126 echo ">>> building release for revision $$repover ..." ; \ 127 autoconf -o configure autoconf/configure.ac ; \ 128 autoheader autoconf/configure.ac ; \ 129 rm -rf dist ; \ 130 mkdir -p dist/$$repover ; \ 131 echo ">>> building release for base system in $(VERSION).tar.gz";\ 132 mkdir dist/$$repover/$(VERSION) ; \ 133 cp -R $(DISTFILES) dist/$$repover/$(VERSION) ; \ 134 mkdir -p dist/$$repover/$(VERSION)/modules ; \ 135 cp -R $(MDISTFILES) dist/$$repover/$(VERSION)/modules ; \ 136 (cd dist/$$repover && tar -zcf $(VERSION).tar.gz $(VERSION)) ; \ 137 rm -rf dist/$$repover/$(VERSION) ; \ 138 (cd modules && $(MAKE) REPOVER=$$repover release) ; \ 139 echo "<<< finished building release in dist/$$repover" 140 140 141 141 # vi:set ts=8 sts=4 sw=4 tw=76 et: -
trunk/ithildin/autoconf/config.guess
r490 r578 74 74 -- ) # Stop option processing 75 75 shift; break ;; 76 - ) # Use stdin as input.76 - ) # Use stdin as input. 77 77 break ;; 78 78 -* ) … … 99 99 set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in 100 100 ,,) echo "int dummy(){}" > $dummy.c ; 101 for c in cc gcc c89 ; do102 ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;103 if test $? = 0 ; then104 CC_FOR_BUILD="$c"; break ;105 fi ;106 done ;107 rm -f $dummy.c $dummy.o $dummy.rel ;108 if test x"$CC_FOR_BUILD" = x ; then109 CC_FOR_BUILD=no_compiler_found ;110 fi111 ;;101 for c in cc gcc c89 ; do 102 ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; 103 if test $? = 0 ; then 104 CC_FOR_BUILD="$c"; break ; 105 fi ; 106 done ; 107 rm -f $dummy.c $dummy.o $dummy.rel ; 108 if test x"$CC_FOR_BUILD" = x ; then 109 CC_FOR_BUILD=no_compiler_found ; 110 fi 111 ;; 112 112 ,,*) CC_FOR_BUILD=$CC ;; 113 113 ,*,*) CC_FOR_BUILD=$HOST_CC ;; … … 117 117 # (ghazi@noc.rutgers.edu 1994-08-24) 118 118 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then 119 PATH=$PATH:/.attbin ; export PATH119 PATH=$PATH:/.attbin ; export PATH 120 120 fi 121 121 … … 129 129 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 130 130 *:NetBSD:*:*) 131 # NetBSD (nbsd) targets should (where applicable) match one or132 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,133 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently134 # switched to ELF, *-*-netbsd* would select the old135 # object file format. This provides both forward136 # compatibility and a consistent mechanism for selecting the137 # object file format.138 #139 # Note: NetBSD doesn't particularly care about the vendor140 # portion of the name. We always set it to "unknown".141 sysctl="sysctl -n hw.machine_arch"142 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \143 /usr/sbin/$sysctl 2>/dev/null || echo unknown)`144 case "${UNAME_MACHINE_ARCH}" in145 arm*) machine=arm-unknown ;;146 sh3el) machine=shl-unknown ;;147 sh3eb) machine=sh-unknown ;;148 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;149 esac150 # The Operating System including object format, if it has switched151 # to ELF recently, or will in the future.152 case "${UNAME_MACHINE_ARCH}" in153 arm*|i386|m68k|ns32k|sh3*|sparc|vax)154 eval $set_cc_for_build155 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \156 | grep __ELF__ >/dev/null157 then158 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).159 # Return netbsd for either. FIX?160 os=netbsd161 else162 os=netbsdelf163 fi164 ;;165 *)166 os=netbsd167 ;;168 esac169 # The OS release170 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`171 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:172 # contains redundant information, the shorter form:173 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.174 echo "${machine}-${os}${release}"175 exit 0 ;;131 # NetBSD (nbsd) targets should (where applicable) match one or 132 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, 133 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently 134 # switched to ELF, *-*-netbsd* would select the old 135 # object file format. This provides both forward 136 # compatibility and a consistent mechanism for selecting the 137 # object file format. 138 # 139 # Note: NetBSD doesn't particularly care about the vendor 140 # portion of the name. We always set it to "unknown". 141 sysctl="sysctl -n hw.machine_arch" 142 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ 143 /usr/sbin/$sysctl 2>/dev/null || echo unknown)` 144 case "${UNAME_MACHINE_ARCH}" in 145 arm*) machine=arm-unknown ;; 146 sh3el) machine=shl-unknown ;; 147 sh3eb) machine=sh-unknown ;; 148 *) machine=${UNAME_MACHINE_ARCH}-unknown ;; 149 esac 150 # The Operating System including object format, if it has switched 151 # to ELF recently, or will in the future. 152 case "${UNAME_MACHINE_ARCH}" in 153 arm*|i386|m68k|ns32k|sh3*|sparc|vax) 154 eval $set_cc_for_build 155 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ 156 | grep __ELF__ >/dev/null 157 then 158 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). 159 # Return netbsd for either. FIX? 160 os=netbsd 161 else 162 os=netbsdelf 163 fi 164 ;; 165 *) 166 os=netbsd 167 ;; 168 esac 169 # The OS release 170 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` 171 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: 172 # contains redundant information, the shorter form: 173 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. 174 echo "${machine}-${os}${release}" 175 exit 0 ;; 176 176 amiga:OpenBSD:*:*) 177 echo m68k-unknown-openbsd${UNAME_RELEASE}178 exit 0 ;;177 echo m68k-unknown-openbsd${UNAME_RELEASE} 178 exit 0 ;; 179 179 arc:OpenBSD:*:*) 180 echo mipsel-unknown-openbsd${UNAME_RELEASE}181 exit 0 ;;180 echo mipsel-unknown-openbsd${UNAME_RELEASE} 181 exit 0 ;; 182 182 hp300:OpenBSD:*:*) 183 echo m68k-unknown-openbsd${UNAME_RELEASE}184 exit 0 ;;183 echo m68k-unknown-openbsd${UNAME_RELEASE} 184 exit 0 ;; 185 185 mac68k:OpenBSD:*:*) 186 echo m68k-unknown-openbsd${UNAME_RELEASE}187 exit 0 ;;186 echo m68k-unknown-openbsd${UNAME_RELEASE} 187 exit 0 ;; 188 188 macppc:OpenBSD:*:*) 189 echo powerpc-unknown-openbsd${UNAME_RELEASE}190 exit 0 ;;189 echo powerpc-unknown-openbsd${UNAME_RELEASE} 190 exit 0 ;; 191 191 mvme68k:OpenBSD:*:*) 192 echo m68k-unknown-openbsd${UNAME_RELEASE}193 exit 0 ;;192 echo m68k-unknown-openbsd${UNAME_RELEASE} 193 exit 0 ;; 194 194 mvme88k:OpenBSD:*:*) 195 echo m88k-unknown-openbsd${UNAME_RELEASE}196 exit 0 ;;195 echo m88k-unknown-openbsd${UNAME_RELEASE} 196 exit 0 ;; 197 197 mvmeppc:OpenBSD:*:*) 198 echo powerpc-unknown-openbsd${UNAME_RELEASE}199 exit 0 ;;198 echo powerpc-unknown-openbsd${UNAME_RELEASE} 199 exit 0 ;; 200 200 pmax:OpenBSD:*:*) 201 echo mipsel-unknown-openbsd${UNAME_RELEASE}202 exit 0 ;;201 echo mipsel-unknown-openbsd${UNAME_RELEASE} 202 exit 0 ;; 203 203 sgi:OpenBSD:*:*) 204 echo mipseb-unknown-openbsd${UNAME_RELEASE}205 exit 0 ;;204 echo mipseb-unknown-openbsd${UNAME_RELEASE} 205 exit 0 ;; 206 206 sun3:OpenBSD:*:*) 207 echo m68k-unknown-openbsd${UNAME_RELEASE}208 exit 0 ;;207 echo m68k-unknown-openbsd${UNAME_RELEASE} 208 exit 0 ;; 209 209 wgrisc:OpenBSD:*:*) 210 echo mipsel-unknown-openbsd${UNAME_RELEASE}211 exit 0 ;;210 echo mipsel-unknown-openbsd${UNAME_RELEASE} 211 exit 0 ;; 212 212 *:OpenBSD:*:*) 213 echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}214 exit 0 ;;213 echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} 214 exit 0 ;; 215 215 alpha:OSF1:*:*) 216 if test $UNAME_RELEASE = "V4.0"; then217 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`218 fi219 # A Vn.n version is a released version.220 # A Tn.n version is a released field test version.221 # A Xn.n version is an unreleased experimental baselevel.222 # 1.2 uses "1.2" for uname -r.223 cat <<EOF >$dummy.s224 .data216 if test $UNAME_RELEASE = "V4.0"; then 217 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` 218 fi 219 # A Vn.n version is a released version. 220 # A Tn.n version is a released field test version. 221 # A Xn.n version is an unreleased experimental baselevel. 222 # 1.2 uses "1.2" for uname -r. 223 cat <<EOF >$dummy.s 224 .data 225 225 \$Lformat: 226 .byte 37,100,45,37,120,10,0# "%d-%x\n"227 228 .text229 .globl main230 .align 4231 .ent main226 .byte 37,100,45,37,120,10,0 # "%d-%x\n" 227 228 .text 229 .globl main 230 .align 4 231 .ent main 232 232 main: 233 .frame \$30,16,\$26,0234 ldgp \$29,0(\$27)235 .prologue 1236 .long 0x47e03d80 # implver \$0237 lda \$2,-1238 .long 0x47e20c21 # amask \$2,\$1239 lda \$16,\$Lformat240 mov \$0,\$17241 not \$1,\$18242 jsr \$26,printf243 ldgp \$29,0(\$26)244 mov 0,\$16245 jsr \$26,exit246 .end main233 .frame \$30,16,\$26,0 234 ldgp \$29,0(\$27) 235 .prologue 1 236 .long 0x47e03d80 # implver \$0 237 lda \$2,-1 238 .long 0x47e20c21 # amask \$2,\$1 239 lda \$16,\$Lformat 240 mov \$0,\$17 241 not \$1,\$18 242 jsr \$26,printf 243 ldgp \$29,0(\$26) 244 mov 0,\$16 245 jsr \$26,exit 246 .end main 247 247 EOF 248 eval $set_cc_for_build249 $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null250 if test "$?" = 0 ; then251 case `./$dummy` in252 0-0)253 UNAME_MACHINE="alpha"254 ;;255 1-0)256 UNAME_MACHINE="alphaev5"257 ;;258 1-1)259 UNAME_MACHINE="alphaev56"260 ;;261 1-101)262 UNAME_MACHINE="alphapca56"263 ;;264 2-303)265 UNAME_MACHINE="alphaev6"266 ;;267 2-307)268 UNAME_MACHINE="alphaev67"269 ;;270 2-1307)271 UNAME_MACHINE="alphaev68"272 ;;273 esac274 fi275 rm -f $dummy.s $dummy276 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`277 exit 0 ;;248 eval $set_cc_for_build 249 $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null 250 if test "$?" = 0 ; then 251 case `./$dummy` in 252 0-0) 253 UNAME_MACHINE="alpha" 254 ;; 255 1-0) 256 UNAME_MACHINE="alphaev5" 257 ;; 258 1-1) 259 UNAME_MACHINE="alphaev56" 260 ;; 261 1-101) 262 UNAME_MACHINE="alphapca56" 263 ;; 264 2-303) 265 UNAME_MACHINE="alphaev6" 266 ;; 267 2-307) 268 UNAME_MACHINE="alphaev67" 269 ;; 270 2-1307) 271 UNAME_MACHINE="alphaev68" 272 ;; 273 esac 274 fi 275 rm -f $dummy.s $dummy 276 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 277 exit 0 ;; 278 278 Alpha\ *:Windows_NT*:*) 279 # How do we know it's Interix rather than the generic POSIX subsystem?280 # Should we change UNAME_MACHINE based on the output of uname instead281 # of the specific Alpha model?282 echo alpha-pc-interix283 exit 0 ;;279 # How do we know it's Interix rather than the generic POSIX subsystem? 280 # Should we change UNAME_MACHINE based on the output of uname instead 281 # of the specific Alpha model? 282 echo alpha-pc-interix 283 exit 0 ;; 284 284 21064:Windows_NT:50:3) 285 echo alpha-dec-winnt3.5286 exit 0 ;;285 echo alpha-dec-winnt3.5 286 exit 0 ;; 287 287 Amiga*:UNIX_System_V:4.0:*) 288 echo m68k-unknown-sysv4289 exit 0;;288 echo m68k-unknown-sysv4 289 exit 0;; 290 290 *:[Aa]miga[Oo][Ss]:*:*) 291 echo ${UNAME_MACHINE}-unknown-amigaos292 exit 0 ;;291 echo ${UNAME_MACHINE}-unknown-amigaos 292 exit 0 ;; 293 293 *:[Mm]orph[Oo][Ss]:*:*) 294 echo ${UNAME_MACHINE}-unknown-morphos295 exit 0 ;;294 echo ${UNAME_MACHINE}-unknown-morphos 295 exit 0 ;; 296 296 *:OS/390:*:*) 297 echo i370-ibm-openedition298 exit 0 ;;297 echo i370-ibm-openedition 298 exit 0 ;; 299 299 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 300 echo arm-acorn-riscix${UNAME_RELEASE}301 exit 0;;300 echo arm-acorn-riscix${UNAME_RELEASE} 301 exit 0;; 302 302 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) 303 echo hppa1.1-hitachi-hiuxmpp304 exit 0;;303 echo hppa1.1-hitachi-hiuxmpp 304 exit 0;; 305 305 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) 306 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.307 if test "`(/bin/universe) 2>/dev/null`" = att ; then308 echo pyramid-pyramid-sysv3309 else310 echo pyramid-pyramid-bsd311 fi312 exit 0 ;;306 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. 307 if test "`(/bin/universe) 2>/dev/null`" = att ; then 308 echo pyramid-pyramid-sysv3 309 else 310 echo pyramid-pyramid-bsd 311 fi 312 exit 0 ;; 313 313 NILE*:*:*:dcosx) 314 echo pyramid-pyramid-svr4315 exit 0 ;;314 echo pyramid-pyramid-svr4 315 exit 0 ;; 316 316 sun4H:SunOS:5.*:*) 317 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`318 exit 0 ;;317 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 318 exit 0 ;; 319 319 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) 320 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`321 exit 0 ;;320 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 321 exit 0 ;; 322 322 i86pc:SunOS:5.*:*) 323 echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`324 exit 0 ;;323 echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 324 exit 0 ;; 325 325 sun4*:SunOS:6*:*) 326 # According to config.sub, this is the proper way to canonicalize327 # SunOS6. Hard to guess exactly what SunOS6 will be like, but328 # it's likely to be more like Solaris than SunOS4.329 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`330 exit 0 ;;326 # According to config.sub, this is the proper way to canonicalize 327 # SunOS6. Hard to guess exactly what SunOS6 will be like, but 328 # it's likely to be more like Solaris than SunOS4. 329 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 330 exit 0 ;; 331 331 sun4*:SunOS:*:*) 332 case "`/usr/bin/arch -k`" in333 Series*|S4*)334 UNAME_RELEASE=`uname -v`335 ;;336 esac337 # Japanese Language versions have a version number like `4.1.3-JL'.338 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`339 exit 0 ;;332 case "`/usr/bin/arch -k`" in 333 Series*|S4*) 334 UNAME_RELEASE=`uname -v` 335 ;; 336 esac 337 # Japanese Language versions have a version number like `4.1.3-JL'. 338 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` 339 exit 0 ;; 340 340 sun3*:SunOS:*:*) 341 echo m68k-sun-sunos${UNAME_RELEASE}342 exit 0 ;;341 echo m68k-sun-sunos${UNAME_RELEASE} 342 exit 0 ;; 343 343 sun*:*:4.2BSD:*) 344 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`345 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3346 case "`/bin/arch`" in347 sun3)348 echo m68k-sun-sunos${UNAME_RELEASE}349 ;;350 sun4)351 echo sparc-sun-sunos${UNAME_RELEASE}352 ;;353 esac354 exit 0 ;;344 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` 345 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 346 case "`/bin/arch`" in 347 sun3) 348 echo m68k-sun-sunos${UNAME_RELEASE} 349 ;; 350 sun4) 351 echo sparc-sun-sunos${UNAME_RELEASE} 352 ;; 353 esac 354 exit 0 ;; 355 355 aushp:SunOS:*:*) 356 echo sparc-auspex-sunos${UNAME_RELEASE}357 exit 0 ;;356 echo sparc-auspex-sunos${UNAME_RELEASE} 357 exit 0 ;; 358 358 # The situation for MiNT is a little confusing. The machine name 359 359 # can be virtually everything (everything which is not … … 366 366 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 367 367 echo m68k-atari-mint${UNAME_RELEASE} 368 exit 0 ;;368 exit 0 ;; 369 369 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 370 echo m68k-atari-mint${UNAME_RELEASE}370 echo m68k-atari-mint${UNAME_RELEASE} 371 371 exit 0 ;; 372 372 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 373 373 echo m68k-atari-mint${UNAME_RELEASE} 374 exit 0 ;;374 exit 0 ;; 375 375 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 376 376 echo m68k-milan-mint${UNAME_RELEASE} … … 383 383 exit 0 ;; 384 384 powerpc:machten:*:*) 385 echo powerpc-apple-machten${UNAME_RELEASE}386 exit 0 ;;385 echo powerpc-apple-machten${UNAME_RELEASE} 386 exit 0 ;; 387 387 RISC*:Mach:*:*) 388 echo mips-dec-mach_bsd4.3389 exit 0 ;;388 echo mips-dec-mach_bsd4.3 389 exit 0 ;; 390 390 RISC*:ULTRIX:*:*) 391 echo mips-dec-ultrix${UNAME_RELEASE}392 exit 0 ;;391 echo mips-dec-ultrix${UNAME_RELEASE} 392 exit 0 ;; 393 393 VAX*:ULTRIX*:*:*) 394 echo vax-dec-ultrix${UNAME_RELEASE}395 exit 0 ;;394 echo vax-dec-ultrix${UNAME_RELEASE} 395 exit 0 ;; 396 396 2020:CLIX:*:* | 2430:CLIX:*:*) 397 echo clipper-intergraph-clix${UNAME_RELEASE}398 exit 0 ;;397 echo clipper-intergraph-clix${UNAME_RELEASE} 398 exit 0 ;; 399 399 mips:*:*:UMIPS | mips:*:*:RISCos) 400 eval $set_cc_for_build401 sed 's/^//' << EOF >$dummy.c400 eval $set_cc_for_build 401 sed 's/^ //' << EOF >$dummy.c 402 402 #ifdef __cplusplus 403 403 #include <stdio.h> /* for printf() prototype */ 404 int main (int argc, char *argv[]) {404 int main (int argc, char *argv[]) { 405 405 #else 406 int main (argc, argv) int argc; char *argv[]; {407 #endif 408 #if defined (host_mips) && defined (MIPSEB)409 #if defined (SYSTYPE_SYSV)410 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);411 #endif412 #if defined (SYSTYPE_SVR4)413 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);414 #endif415 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)416 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);417 #endif418 #endif419 exit (-1);420 }406 int main (argc, argv) int argc; char *argv[]; { 407 #endif 408 #if defined (host_mips) && defined (MIPSEB) 409 #if defined (SYSTYPE_SYSV) 410 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); 411 #endif 412 #if defined (SYSTYPE_SVR4) 413 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); 414 #endif 415 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) 416 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); 417 #endif 418 #endif 419 exit (-1); 420 } 421 421 EOF 422 $CC_FOR_BUILD $dummy.c -o $dummy \423 && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \424 && rm -f $dummy.c $dummy && exit 0425 rm -f $dummy.c $dummy426 echo mips-mips-riscos${UNAME_RELEASE}427 exit 0 ;;422 $CC_FOR_BUILD $dummy.c -o $dummy \ 423 && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ 424 && rm -f $dummy.c $dummy && exit 0 425 rm -f $dummy.c $dummy 426 echo mips-mips-riscos${UNAME_RELEASE} 427 exit 0 ;; 428 428 Motorola:PowerMAX_OS:*:*) 429 echo powerpc-motorola-powermax430 exit 0 ;;429 echo powerpc-motorola-powermax 430 exit 0 ;; 431 431 Night_Hawk:Power_UNIX:*:*) 432 echo powerpc-harris-powerunix433 exit 0 ;;432 echo powerpc-harris-powerunix 433 exit 0 ;; 434 434 m88k:CX/UX:7*:*) 435 echo m88k-harris-cxux7436 exit 0 ;;435 echo m88k-harris-cxux7 436 exit 0 ;; 437 437 m88k:*:4*:R4*) 438 echo m88k-motorola-sysv4439 exit 0 ;;438 echo m88k-motorola-sysv4 439 exit 0 ;; 440 440 m88k:*:3*:R3*) 441 echo m88k-motorola-sysv3442 exit 0 ;;441 echo m88k-motorola-sysv3 442 exit 0 ;; 443 443 AViiON:dgux:*:*) 444 444 # DG/UX returns AViiON for all architectures 445 445 UNAME_PROCESSOR=`/usr/bin/uname -p` 446 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]447 then448 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \449 [ ${TARGET_BINARY_INTERFACE}x = x ]450 then451 echo m88k-dg-dgux${UNAME_RELEASE}452 else453 echo m88k-dg-dguxbcs${UNAME_RELEASE}454 fi455 else456 echo i586-dg-dgux${UNAME_RELEASE}457 fi458 exit 0 ;;459 M88*:DolphinOS:*:*) # DolphinOS (SVR3)460 echo m88k-dolphin-sysv3461 exit 0 ;;446 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] 447 then 448 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ 449 [ ${TARGET_BINARY_INTERFACE}x = x ] 450 then 451 echo m88k-dg-dgux${UNAME_RELEASE} 452 else 453 echo m88k-dg-dguxbcs${UNAME_RELEASE} 454 fi 455 else 456 echo i586-dg-dgux${UNAME_RELEASE} 457 fi 458 exit 0 ;; 459 M88*:DolphinOS:*:*) # DolphinOS (SVR3) 460 echo m88k-dolphin-sysv3 461 exit 0 ;; 462 462 M88*:*:R3*:*) 463 # Delta 88k system running SVR3464 echo m88k-motorola-sysv3465 exit 0 ;;463 # Delta 88k system running SVR3 464 echo m88k-motorola-sysv3 465 exit 0 ;; 466 466 XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) 467 echo m88k-tektronix-sysv3468 exit 0 ;;467 echo m88k-tektronix-sysv3 468 exit 0 ;; 469 469 Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) 470 echo m68k-tektronix-bsd471 exit 0 ;;470 echo m68k-tektronix-bsd 471 exit 0 ;; 472 472 *:IRIX*:*:*) 473 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`474 exit 0 ;;473 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` 474 exit 0 ;; 475 475 ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. 476 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id477 exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '476 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id 477 exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' 478 478 i*86:AIX:*:*) 479 echo i386-ibm-aix480 exit 0 ;;479 echo i386-ibm-aix 480 exit 0 ;; 481 481 ia64:AIX:*:*) 482 if [ -x /usr/bin/oslevel ] ; then483 IBM_REV=`/usr/bin/oslevel`484 else485 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}486 fi487 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}488 exit 0 ;;482 if [ -x /usr/bin/oslevel ] ; then 483 IBM_REV=`/usr/bin/oslevel` 484 else 485 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 486 fi 487 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} 488 exit 0 ;; 489 489 *:AIX:2:3) 490 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then491 eval $set_cc_for_build492 sed 's/^//' << EOF >$dummy.c493 #include <sys/systemcfg.h>494 495 main()496 {497 if (!__power_pc())498 exit(1);499 puts("powerpc-ibm-aix3.2.5");500 exit(0);501 }490 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then 491 eval $set_cc_for_build 492 sed 's/^ //' << EOF >$dummy.c 493 #include <sys/systemcfg.h> 494 495 main() 496 { 497 if (!__power_pc()) 498 exit(1); 499 puts("powerpc-ibm-aix3.2.5"); 500 exit(0); 501 } 502 502 EOF 503 $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0504 rm -f $dummy.c $dummy505 echo rs6000-ibm-aix3.2.5506 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then507 echo rs6000-ibm-aix3.2.4508 else509 echo rs6000-ibm-aix3.2510 fi511 exit 0 ;;503 $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 504 rm -f $dummy.c $dummy 505 echo rs6000-ibm-aix3.2.5 506 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then 507 echo rs6000-ibm-aix3.2.4 508 else 509 echo rs6000-ibm-aix3.2 510 fi 511 exit 0 ;; 512 512 *:AIX:*:[45]) 513 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`514 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then515 IBM_ARCH=rs6000516 else517 IBM_ARCH=powerpc518 fi519 if [ -x /usr/bin/oslevel ] ; then520 IBM_REV=`/usr/bin/oslevel`521 else522 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}523 fi524 echo ${IBM_ARCH}-ibm-aix${IBM_REV}525 exit 0 ;;513 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 514 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then 515 IBM_ARCH=rs6000 516 else 517 IBM_ARCH=powerpc 518 fi 519 if [ -x /usr/bin/oslevel ] ; then 520 IBM_REV=`/usr/bin/oslevel` 521 else 522 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 523 fi 524 echo ${IBM_ARCH}-ibm-aix${IBM_REV} 525 exit 0 ;; 526 526 *:AIX:*:*) 527 echo rs6000-ibm-aix528 exit 0 ;;527 echo rs6000-ibm-aix 528 exit 0 ;; 529 529 ibmrt:4.4BSD:*|romp-ibm:BSD:*) 530 echo romp-ibm-bsd4.4531 exit 0 ;;530 echo romp-ibm-bsd4.4 531 exit 0 ;; 532 532 ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and 533 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to534 exit 0 ;; # report: romp-ibm BSD 4.3533 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to 534 exit 0 ;; # report: romp-ibm BSD 4.3 535 535 *:BOSX:*:*) 536 echo rs6000-bull-bosx537 exit 0 ;;536 echo rs6000-bull-bosx 537 exit 0 ;; 538 538 DPX/2?00:B.O.S.:*:*) 539 echo m68k-bull-sysv3540 exit 0 ;;539 echo m68k-bull-sysv3 540 exit 0 ;; 541 541 9000/[34]??:4.3bsd:1.*:*) 542 echo m68k-hp-bsd543 exit 0 ;;542 echo m68k-hp-bsd 543 exit 0 ;; 544 544 hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) 545 echo m68k-hp-bsd4.4546 exit 0 ;;545 echo m68k-hp-bsd4.4 546 exit 0 ;; 547 547 9000/[34678]??:HP-UX:*:*) 548 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`549 case "${UNAME_MACHINE}" in550 9000/31? ) HP_ARCH=m68000 ;;551 9000/[34]?? ) HP_ARCH=m68k ;;552 9000/[678][0-9][0-9])553 if [ -x /usr/bin/getconf ]; then554 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`548 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 549 case "${UNAME_MACHINE}" in 550 9000/31? ) HP_ARCH=m68000 ;; 551 9000/[34]?? ) HP_ARCH=m68k ;; 552 9000/[678][0-9][0-9]) 553 if [ -x /usr/bin/getconf ]; then 554 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 555 555 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 556 556 case "${sc_cpu_version}" in … … 561 561 32) HP_ARCH="hppa2.0n" ;; 562 562 64) HP_ARCH="hppa2.0w" ;; 563 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20563 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 564 564 esac ;; 565 565 esac 566 fi567 if [ "${HP_ARCH}" = "" ]; then568 eval $set_cc_for_build569 sed 's/^ //' << EOF >$dummy.c566 fi 567 if [ "${HP_ARCH}" = "" ]; then 568 eval $set_cc_for_build 569 sed 's/^ //' << EOF >$dummy.c 570 570 571 571 #define _HPUX_SOURCE … … 581 581 582 582 switch (cpu) 583 {584 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;585 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;586 case CPU_PA_RISC2_0:583 { 584 case CPU_PA_RISC1_0: puts ("hppa1.0"); break; 585 case CPU_PA_RISC1_1: puts ("hppa1.1"); break; 586 case CPU_PA_RISC2_0: 587 587 #if defined(_SC_KERNEL_BITS) 588 switch (bits)589 {590 case 64: puts ("hppa2.0w"); break;591 case 32: puts ("hppa2.0n"); break;592 default: puts ("hppa2.0"); break;593 } break;588 switch (bits) 589 { 590 case 64: puts ("hppa2.0w"); break; 591 case 32: puts ("hppa2.0n"); break; 592 default: puts ("hppa2.0"); break; 593 } break; 594 594 #else /* !defined(_SC_KERNEL_BITS) */ 595 puts ("hppa2.0"); break;595 puts ("hppa2.0"); break; 596 596 #endif 597 default: puts ("hppa1.0"); break;598 }597 default: puts ("hppa1.0"); break; 598 } 599 599 exit (0); 600 600 } 601 601 EOF 602 (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`603 if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi604 rm -f $dummy.c $dummy605 fi ;;606 esac607 echo ${HP_ARCH}-hp-hpux${HPUX_REV}608 exit 0 ;;602 (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` 603 if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi 604 rm -f $dummy.c $dummy 605 fi ;; 606 esac 607 echo ${HP_ARCH}-hp-hpux${HPUX_REV} 608 exit 0 ;; 609 609 ia64:HP-UX:*:*) 610 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`611 echo ia64-hp-hpux${HPUX_REV}612 exit 0 ;;610 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 611 echo ia64-hp-hpux${HPUX_REV} 612 exit 0 ;; 613 613 3050*:HI-UX:*:*) 614 eval $set_cc_for_build615 sed 's/^//' << EOF >$dummy.c616 #include <unistd.h>617 int618 main ()619 {620 long cpu = sysconf (_SC_CPU_VERSION);621 /* The order matters, because CPU_IS_HP_MC68K erroneously returns622 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct623 results, however. */624 if (CPU_IS_PA_RISC (cpu))625 {626 switch (cpu)627 {628 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;629 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;630 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;631 default: puts ("hppa-hitachi-hiuxwe2"); break;632 }633 }634 else if (CPU_IS_HP_MC68K (cpu))635 puts ("m68k-hitachi-hiuxwe2");636 else puts ("unknown-hitachi-hiuxwe2");637 exit (0);638 }614 eval $set_cc_for_build 615 sed 's/^ //' << EOF >$dummy.c 616 #include <unistd.h> 617 int 618 main () 619 { 620 long cpu = sysconf (_SC_CPU_VERSION); 621 /* The order matters, because CPU_IS_HP_MC68K erroneously returns 622 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct 623 results, however. */ 624 if (CPU_IS_PA_RISC (cpu)) 625 { 626 switch (cpu) 627 { 628 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; 629 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; 630 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; 631 default: puts ("hppa-hitachi-hiuxwe2"); break; 632 } 633 } 634 else if (CPU_IS_HP_MC68K (cpu)) 635 puts ("m68k-hitachi-hiuxwe2"); 636 else puts ("unknown-hitachi-hiuxwe2"); 637 exit (0); 638 } 639 639 EOF 640 $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0641 rm -f $dummy.c $dummy642 echo unknown-hitachi-hiuxwe2643 exit 0 ;;640 $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 641 rm -f $dummy.c $dummy 642 echo unknown-hitachi-hiuxwe2 643 exit 0 ;; 644 644 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 645 echo hppa1.1-hp-bsd646 exit 0 ;;645 echo hppa1.1-hp-bsd 646 exit 0 ;; 647 647 9000/8??:4.3bsd:*:*) 648 echo hppa1.0-hp-bsd649 exit 0 ;;648 echo hppa1.0-hp-bsd 649 exit 0 ;; 650 650 *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) 651 echo hppa1.0-hp-mpeix652 exit 0 ;;651 echo hppa1.0-hp-mpeix 652 exit 0 ;; 653 653 hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) 654 echo hppa1.1-hp-osf655 exit 0 ;;654 echo hppa1.1-hp-osf 655 exit 0 ;; 656 656 hp8??:OSF1:*:*) 657 echo hppa1.0-hp-osf658 exit 0 ;;657 echo hppa1.0-hp-osf 658 exit 0 ;; 659 659 i*86:OSF1:*:*) 660 if [ -x /usr/sbin/sysversion ] ; then661 echo ${UNAME_MACHINE}-unknown-osf1mk662 else663 echo ${UNAME_MACHINE}-unknown-osf1664 fi665 exit 0 ;;660 if [ -x /usr/sbin/sysversion ] ; then 661 echo ${UNAME_MACHINE}-unknown-osf1mk 662 else 663 echo ${UNAME_MACHINE}-unknown-osf1 664 fi 665 exit 0 ;; 666 666 parisc*:Lites*:*:*) 667 echo hppa1.1-hp-lites668 exit 0 ;;667 echo hppa1.1-hp-lites 668 exit 0 ;; 669 669 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 670 echo c1-convex-bsd670 echo c1-convex-bsd 671 671 exit 0 ;; 672 672 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 673 if getsysinfo -f scalar_acc674 then echo c32-convex-bsd675 else echo c2-convex-bsd676 fi673 if getsysinfo -f scalar_acc 674 then echo c32-convex-bsd 675 else echo c2-convex-bsd 676 fi 677 677 exit 0 ;; 678 678 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 679 echo c34-convex-bsd679 echo c34-convex-bsd 680 680 exit 0 ;; 681 681 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 682 echo c38-convex-bsd682 echo c38-convex-bsd 683 683 exit 0 ;; 684 684 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 685 echo c4-convex-bsd685 echo c4-convex-bsd 686 686 exit 0 ;; 687 687 CRAY*Y-MP:*:*:*) 688 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'689 exit 0 ;;688 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 689 exit 0 ;; 690 690 CRAY*[A-Z]90:*:*:*) 691 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \692 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \693 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \694 -e 's/\.[^.]*$/.X/'695 exit 0 ;;691 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ 692 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ 693 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ 694 -e 's/\.[^.]*$/.X/' 695 exit 0 ;; 696 696 CRAY*TS:*:*:*) 697 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'698 exit 0 ;;697 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 698 exit 0 ;; 699 699 CRAY*T3D:*:*:*) 700 echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'701 exit 0 ;;700 echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 701 exit 0 ;; 702 702 CRAY*T3E:*:*:*) 703 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'704 exit 0 ;;703 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 704 exit 0 ;; 705 705 CRAY*SV1:*:*:*) 706 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'707 exit 0 ;;706 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 707 exit 0 ;; 708 708 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) 709 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`709 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 710 710 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 711 711 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` … … 713 713 exit 0 ;; 714 714 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) 715 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}716 exit 0 ;;715 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} 716 exit 0 ;; 717 717 sparc*:BSD/OS:*:*) 718 echo sparc-unknown-bsdi${UNAME_RELEASE}719 exit 0 ;;718 echo sparc-unknown-bsdi${UNAME_RELEASE} 719 exit 0 ;; 720 720 *:BSD/OS:*:*) 721 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}722 exit 0 ;;721 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 722 exit 0 ;; 723 723 *:FreeBSD:*:*) 724 echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`725 exit 0 ;;724 echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` 725 exit 0 ;; 726 726 i*:CYGWIN*:*) 727 echo ${UNAME_MACHINE}-pc-cygwin728 exit 0 ;;727 echo ${UNAME_MACHINE}-pc-cygwin 728 exit 0 ;; 729 729 i*:MINGW*:*) 730 echo ${UNAME_MACHINE}-pc-mingw32731 exit 0 ;;730 echo ${UNAME_MACHINE}-pc-mingw32 731 exit 0 ;; 732 732 i*:PW*:*) 733 echo ${UNAME_MACHINE}-pc-pw32734 exit 0 ;;733 echo ${UNAME_MACHINE}-pc-pw32 734 exit 0 ;; 735 735 x86:Interix*:3*) 736 echo i386-pc-interix3737 exit 0 ;;736 echo i386-pc-interix3 737 exit 0 ;; 738 738 i*:Windows_NT*:* | Pentium*:Windows_NT*:*) 739 # How do we know it's Interix rather than the generic POSIX subsystem?740 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we741 # UNAME_MACHINE based on the output of uname instead of i386?742 echo i386-pc-interix743 exit 0 ;;739 # How do we know it's Interix rather than the generic POSIX subsystem? 740 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we 741 # UNAME_MACHINE based on the output of uname instead of i386? 742 echo i386-pc-interix 743 exit 0 ;; 744 744 i*:UWIN*:*) 745 echo ${UNAME_MACHINE}-pc-uwin746 exit 0 ;;745 echo ${UNAME_MACHINE}-pc-uwin 746 exit 0 ;; 747 747 p*:CYGWIN*:*) 748 echo powerpcle-unknown-cygwin749 exit 0 ;;748 echo powerpcle-unknown-cygwin 749 exit 0 ;; 750 750 prep*:SunOS:5.*:*) 751 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`752 exit 0 ;;751 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 752 exit 0 ;; 753 753 *:GNU:*:*) 754 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`755 exit 0 ;;754 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` 755 exit 0 ;; 756 756 i*86:Minix:*:*) 757 echo ${UNAME_MACHINE}-pc-minix758 exit 0 ;;757 echo ${UNAME_MACHINE}-pc-minix 758 exit 0 ;; 759 759 arm*:Linux:*:*) 760 echo ${UNAME_MACHINE}-unknown-linux-gnu761 exit 0 ;;760 echo ${UNAME_MACHINE}-unknown-linux-gnu 761 exit 0 ;; 762 762 ia64:Linux:*:*) 763 echo ${UNAME_MACHINE}-unknown-linux764 exit 0 ;;763 echo ${UNAME_MACHINE}-unknown-linux 764 exit 0 ;; 765 765 m68*:Linux:*:*) 766 echo ${UNAME_MACHINE}-unknown-linux-gnu767 exit 0 ;;766 echo ${UNAME_MACHINE}-unknown-linux-gnu 767 exit 0 ;; 768 768 mips:Linux:*:*) 769 eval $set_cc_for_build770 sed 's/^//' << EOF >$dummy.c771 #undef CPU772 #undef mips773 #undef mipsel774 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)775 CPU=mipsel776 #else777 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)778 CPU=mips779 #else780 CPU=781 #endif782 #endif769 eval $set_cc_for_build 770 sed 's/^ //' << EOF >$dummy.c 771 #undef CPU 772 #undef mips 773 #undef mipsel 774 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) 775 CPU=mipsel 776 #else 777 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 778 CPU=mips 779 #else 780 CPU= 781 #endif 782 #endif 783 783 EOF 784 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`785 rm -f $dummy.c786 test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0787 ;;784 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` 785 rm -f $dummy.c 786 test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 787 ;; 788 788 ppc:Linux:*:*) 789 echo powerpc-unknown-linux-gnu790 exit 0 ;;789 echo powerpc-unknown-linux-gnu 790 exit 0 ;; 791 791 ppc64:Linux:*:*) 792 echo powerpc64-unknown-linux-gnu793 exit 0 ;;792 echo powerpc64-unknown-linux-gnu 793 exit 0 ;; 794 794 alpha:Linux:*:*) 795 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in796 EV5) UNAME_MACHINE=alphaev5 ;;797 EV56) UNAME_MACHINE=alphaev56 ;;798 PCA56) UNAME_MACHINE=alphapca56 ;;799 PCA57) UNAME_MACHINE=alphapca56 ;;800 EV6) UNAME_MACHINE=alphaev6 ;;801 EV67) UNAME_MACHINE=alphaev67 ;;802 EV68*) UNAME_MACHINE=alphaev68 ;;795 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in 796 EV5) UNAME_MACHINE=alphaev5 ;; 797 EV56) UNAME_MACHINE=alphaev56 ;; 798 PCA56) UNAME_MACHINE=alphapca56 ;; 799 PCA57) UNAME_MACHINE=alphapca56 ;; 800 EV6) UNAME_MACHINE=alphaev6 ;; 801 EV67) UNAME_MACHINE=alphaev67 ;; 802 EV68*) UNAME_MACHINE=alphaev68 ;; 803 803 esac 804 objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null805 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi806 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}807 exit 0 ;;804 objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null 805 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi 806 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} 807 exit 0 ;; 808 808 parisc:Linux:*:* | hppa:Linux:*:*) 809 # Look for CPU level810 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in811 PA7*) echo hppa1.1-unknown-linux-gnu ;;812 PA8*) echo hppa2.0-unknown-linux-gnu ;;813 *) echo hppa-unknown-linux-gnu ;;814 esac815 exit 0 ;;809 # Look for CPU level 810 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in 811 PA7*) echo hppa1.1-unknown-linux-gnu ;; 812 PA8*) echo hppa2.0-unknown-linux-gnu ;; 813 *) echo hppa-unknown-linux-gnu ;; 814 esac 815 exit 0 ;; 816 816 parisc64:Linux:*:* | hppa64:Linux:*:*) 817 echo hppa64-unknown-linux-gnu818 exit 0 ;;817 echo hppa64-unknown-linux-gnu 818 exit 0 ;; 819 819 s390:Linux:*:* | s390x:Linux:*:*) 820 echo ${UNAME_MACHINE}-ibm-linux821 exit 0 ;;820 echo ${UNAME_MACHINE}-ibm-linux 821 exit 0 ;; 822 822 sh*:Linux:*:*) 823 echo ${UNAME_MACHINE}-unknown-linux-gnu824 exit 0 ;;823 echo ${UNAME_MACHINE}-unknown-linux-gnu 824 exit 0 ;; 825 825 sparc:Linux:*:* | sparc64:Linux:*:*) 826 echo ${UNAME_MACHINE}-unknown-linux-gnu827 exit 0 ;;826 echo ${UNAME_MACHINE}-unknown-linux-gnu 827 exit 0 ;; 828 828 x86_64:Linux:*:*) 829 echo x86_64-unknown-linux-gnu830 exit 0 ;;829 echo x86_64-unknown-linux-gnu 830 exit 0 ;; 831 831 i*86:Linux:*:*) 832 # The BFD linker knows what the default object file format is, so833 # first see if it will tell us. cd to the root directory to prevent834 # problems with other programs or directories called `ld' in the path.835 # Set LC_ALL=C to ensure ld outputs messages in English.836 ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \837 | sed -ne '/supported targets:/!d838 s/[ ][]*/ /g839 s/.*supported targets: *//840 s/ .*//841 p'`832 # The BFD linker knows what the default object file format is, so 833 # first see if it will tell us. cd to the root directory to prevent 834 # problems with other programs or directories called `ld' in the path. 835 # Set LC_ALL=C to ensure ld outputs messages in English. 836 ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ 837 | sed -ne '/supported targets:/!d 838 s/[ ][ ]*/ /g 839 s/.*supported targets: *// 840 s/ .*// 841 p'` 842 842 case "$ld_supported_targets" in 843 elf32-i386)844 TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"845 ;;846 a.out-i386-linux)847 echo "${UNAME_MACHINE}-pc-linux-gnuaout"848 exit 0 ;; 849 coff-i386)850 echo "${UNAME_MACHINE}-pc-linux-gnucoff"851 exit 0 ;;852 "")853 # Either a pre-BFD a.out linker (linux-gnuoldld) or854 # one that does not give us useful --help.855 echo "${UNAME_MACHINE}-pc-linux-gnuoldld"856 exit 0 ;;857 esac858 # Determine whether the default compiler is a.out or elf859 eval $set_cc_for_build860 sed 's/^//' << EOF >$dummy.c861 #include <features.h>862 #ifdef __ELF__863 # ifdef __GLIBC__864 # if __GLIBC__ >= 2865 LIBC=gnu866 # else867 LIBC=gnulibc1868 # endif869 # else870 LIBC=gnulibc1871 # endif872 #else873 #ifdef __INTEL_COMPILER874 LIBC=gnu875 #else876 LIBC=gnuaout877 #endif878 #endif843 elf32-i386) 844 TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" 845 ;; 846 a.out-i386-linux) 847 echo "${UNAME_MACHINE}-pc-linux-gnuaout" 848 exit 0 ;; 849 coff-i386) 850 echo "${UNAME_MACHINE}-pc-linux-gnucoff" 851 exit 0 ;; 852 "") 853 # Either a pre-BFD a.out linker (linux-gnuoldld) or 854 # one that does not give us useful --help. 855 echo "${UNAME_MACHINE}-pc-linux-gnuoldld" 856 exit 0 ;; 857 esac 858 # Determine whether the default compiler is a.out or elf 859 eval $set_cc_for_build 860 sed 's/^ //' << EOF >$dummy.c 861 #include <features.h> 862 #ifdef __ELF__ 863 # ifdef __GLIBC__ 864 # if __GLIBC__ >= 2 865 LIBC=gnu 866 # else 867 LIBC=gnulibc1 868 # endif 869 # else 870 LIBC=gnulibc1 871 # endif 872 #else 873 #ifdef __INTEL_COMPILER 874 LIBC=gnu 875 #else 876 LIBC=gnuaout 877 #endif 878 #endif 879 879 EOF 880 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`881 rm -f $dummy.c882 test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0883 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0884 ;;880 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` 881 rm -f $dummy.c 882 test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 883 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 884 ;; 885 885 i*86:DYNIX/ptx:4*:*) 886 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.887 # earlier versions are messed up and put the nodename in both888 # sysname and nodename.889 echo i386-sequent-sysv4890 exit 0 ;;886 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. 887 # earlier versions are messed up and put the nodename in both 888 # sysname and nodename. 889 echo i386-sequent-sysv4 890 exit 0 ;; 891 891 i*86:UNIX_SV:4.2MP:2.*) 892 892 # Unixware is an offshoot of SVR4, but it has its own version 893 893 # number series starting with 2... 894 894 # I am not positive that other SVR4 systems won't match this, 895 # I just have to hope. -- rms.895 # I just have to hope. -- rms. 896 896 # Use sysv4.2uw... so that sysv4* matches it. 897 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}898 exit 0 ;;897 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} 898 exit 0 ;; 899 899 i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) 900 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`901 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then902 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}903 else904 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}905 fi906 exit 0 ;;900 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` 901 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then 902 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} 903 else 904 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} 905 fi 906 exit 0 ;; 907 907 i*86:*:5:[78]*) 908 case `/bin/uname -X | grep "^Machine"` in909 *486*)UNAME_MACHINE=i486 ;;910 *Pentium)UNAME_MACHINE=i586 ;;911 *Pent*|*Celeron) UNAME_MACHINE=i686 ;;912 esac913 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}914 exit 0 ;;908 case `/bin/uname -X | grep "^Machine"` in 909 *486*) UNAME_MACHINE=i486 ;; 910 *Pentium) UNAME_MACHINE=i586 ;; 911 *Pent*|*Celeron) UNAME_MACHINE=i686 ;; 912 esac 913 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} 914 exit 0 ;; 915 915 i*86:*:3.2:*) 916 if test -f /usr/options/cb.name; then917 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`918 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL919 elif /bin/uname -X 2>/dev/null >/dev/null ; then920 UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`921 (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486922 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \923 && UNAME_MACHINE=i586924 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \925 && UNAME_MACHINE=i686926 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \927 && UNAME_MACHINE=i686928 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL929 else930 echo ${UNAME_MACHINE}-pc-sysv32931 fi932 exit 0 ;;916 if test -f /usr/options/cb.name; then 917 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` 918 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL 919 elif /bin/uname -X 2>/dev/null >/dev/null ; then 920 UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` 921 (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 922 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ 923 && UNAME_MACHINE=i586 924 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ 925 && UNAME_MACHINE=i686 926 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ 927 && UNAME_MACHINE=i686 928 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL 929 else 930 echo ${UNAME_MACHINE}-pc-sysv32 931 fi 932 exit 0 ;; 933 933 i*86:*DOS:*:*) 934 echo ${UNAME_MACHINE}-pc-msdosdjgpp935 exit 0 ;;934 echo ${UNAME_MACHINE}-pc-msdosdjgpp 935 exit 0 ;; 936 936 pc:*:*:*) 937 # Left here for compatibility:937 # Left here for compatibility: 938 938 # uname -m prints for DJGPP always 'pc', but it prints nothing about 939 939 # the processor, so we play safe by assuming i386. 940 echo i386-pc-msdosdjgpp940 echo i386-pc-msdosdjgpp 941 941 exit 0 ;; 942 942 Intel:Mach:3*:*) 943 echo i386-pc-mach3944 exit 0 ;;943 echo i386-pc-mach3 944 exit 0 ;; 945 945 paragon:*:*:*) 946 echo i860-intel-osf1947 exit 0 ;;946 echo i860-intel-osf1 947 exit 0 ;; 948 948 i860:*:4.*:*) # i860-SVR4 949 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then950 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4951 else # Add other i860-SVR4 vendors below as they are discovered.952 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4953 fi954 exit 0 ;;949 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then 950 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 951 else # Add other i860-SVR4 vendors below as they are discovered. 952 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 953 fi 954 exit 0 ;; 955 955 mini*:CTIX:SYS*5:*) 956 # "miniframe"957 echo m68010-convergent-sysv958 exit 0 ;;956 # "miniframe" 957 echo m68010-convergent-sysv 958 exit 0 ;; 959 959 M68*:*:R3V[567]*:*) 960 test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;960 test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 961 961 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) 962 OS_REL=''963 test -r /etc/.relid \964 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`965 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \966 && echo i486-ncr-sysv4.3${OS_REL} && exit 0967 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \968 && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;962 OS_REL='' 963 test -r /etc/.relid \ 964 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 965 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 966 && echo i486-ncr-sysv4.3${OS_REL} && exit 0 967 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 968 && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 969 969 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 970 970 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 971 971 && echo i486-ncr-sysv4 && exit 0 ;; 972 972 m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) 973 echo m68k-unknown-lynxos${UNAME_RELEASE}974 exit 0 ;;973 echo m68k-unknown-lynxos${UNAME_RELEASE} 974 exit 0 ;; 975 975 mc68030:UNIX_System_V:4.*:*) 976 echo m68k-atari-sysv4977 exit 0 ;;976 echo m68k-atari-sysv4 977 exit 0 ;; 978 978 i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) 979 echo i386-unknown-lynxos${UNAME_RELEASE}980 exit 0 ;;979 echo i386-unknown-lynxos${UNAME_RELEASE} 980 exit 0 ;; 981 981 TSUNAMI:LynxOS:2.*:*) 982 echo sparc-unknown-lynxos${UNAME_RELEASE}983 exit 0 ;;982 echo sparc-unknown-lynxos${UNAME_RELEASE} 983 exit 0 ;; 984 984 rs6000:LynxOS:2.*:*) 985 echo rs6000-unknown-lynxos${UNAME_RELEASE}986 exit 0 ;;985 echo rs6000-unknown-lynxos${UNAME_RELEASE} 986 exit 0 ;; 987 987 PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) 988 echo powerpc-unknown-lynxos${UNAME_RELEASE}989 exit 0 ;;988 echo powerpc-unknown-lynxos${UNAME_RELEASE} 989 exit 0 ;; 990 990 SM[BE]S:UNIX_SV:*:*) 991 echo mips-dde-sysv${UNAME_RELEASE}992 exit 0 ;;991 echo mips-dde-sysv${UNAME_RELEASE} 992 exit 0 ;; 993 993 RM*:ReliantUNIX-*:*:*) 994 echo mips-sni-sysv4995 exit 0 ;;994 echo mips-sni-sysv4 995 exit 0 ;; 996 996 RM*:SINIX-*:*:*) 997 echo mips-sni-sysv4998 exit 0 ;;997 echo mips-sni-sysv4 998 exit 0 ;; 999 999 *:SINIX-*:*:*) 1000 if uname -p 2>/dev/null >/dev/null ; then1001 UNAME_MACHINE=`(uname -p) 2>/dev/null`1002 echo ${UNAME_MACHINE}-sni-sysv41003 else1004 echo ns32k-sni-sysv1005 fi1006 exit 0 ;;1000 if uname -p 2>/dev/null >/dev/null ; then 1001 UNAME_MACHINE=`(uname -p) 2>/dev/null` 1002 echo ${UNAME_MACHINE}-sni-sysv4 1003 else 1004 echo ns32k-sni-sysv 1005 fi 1006 exit 0 ;; 1007 1007 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 1008 1008 # says <Richard.M.Bartel@ccMail.Census.GOV> … … 1010 1010 exit 0 ;; 1011 1011 *:UNIX_System_V:4*:FTX*) 1012 # From Gerald Hewes <hewes@openmarket.com>.1013 # How about differentiating between stratus architectures? -djm1014 echo hppa1.1-stratus-sysv41015 exit 0 ;;1012 # From Gerald Hewes <hewes@openmarket.com>. 1013 # How about differentiating between stratus architectures? -djm 1014 echo hppa1.1-stratus-sysv4 1015 exit 0 ;; 1016 1016 *:*:*:FTX*) 1017 # From seanf@swdc.stratus.com.1018 echo i860-stratus-sysv41019 exit 0 ;;1017 # From seanf@swdc.stratus.com. 1018 echo i860-stratus-sysv4 1019 exit 0 ;; 1020 1020 *:VOS:*:*) 1021 # From Paul.Green@stratus.com.1022 echo hppa1.1-stratus-vos1023 exit 0 ;;1021 # From Paul.Green@stratus.com. 1022 echo hppa1.1-stratus-vos 1023 exit 0 ;; 1024 1024 mc68*:A/UX:*:*) 1025 echo m68k-apple-aux${UNAME_RELEASE}1026 exit 0 ;;1025 echo m68k-apple-aux${UNAME_RELEASE} 1026 exit 0 ;; 1027 1027 news*:NEWS-OS:6*:*) 1028 echo mips-sony-newsos61029 exit 0 ;;1028 echo mips-sony-newsos6 1029 exit 0 ;; 1030 1030 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 1031 if [ -d /usr/nec ]; then1032 echo mips-nec-sysv${UNAME_RELEASE}1033 else1034 echo mips-unknown-sysv${UNAME_RELEASE}1035 fi1036 exit 0 ;; 1037 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.1038 echo powerpc-be-beos1039 exit 0 ;;1040 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.1041 echo powerpc-apple-beos1042 exit 0 ;;1043 BePC:BeOS:*:*) # BeOS running on Intel PC compatible.1044 echo i586-pc-beos1045 exit 0 ;;1031 if [ -d /usr/nec ]; then 1032 echo mips-nec-sysv${UNAME_RELEASE} 1033 else 1034 echo mips-unknown-sysv${UNAME_RELEASE} 1035 fi 1036 exit 0 ;; 1037 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. 1038 echo powerpc-be-beos 1039 exit 0 ;; 1040 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. 1041 echo powerpc-apple-beos 1042 exit 0 ;; 1043 BePC:BeOS:*:*) # BeOS running on Intel PC compatible. 1044 echo i586-pc-beos 1045 exit 0 ;; 1046 1046 SX-4:SUPER-UX:*:*) 1047 echo sx4-nec-superux${UNAME_RELEASE}1048 exit 0 ;;1047 echo sx4-nec-superux${UNAME_RELEASE} 1048 exit 0 ;; 1049 1049 SX-5:SUPER-UX:*:*) 1050 echo sx5-nec-superux${UNAME_RELEASE}1051 exit 0 ;;1050 echo sx5-nec-superux${UNAME_RELEASE} 1051 exit 0 ;; 1052 1052 Power*:Rhapsody:*:*) 1053 echo powerpc-apple-rhapsody${UNAME_RELEASE}1054 exit 0 ;;1053 echo powerpc-apple-rhapsody${UNAME_RELEASE} 1054 exit 0 ;; 1055 1055 *:Rhapsody:*:*) 1056 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}1057 exit 0 ;;1056 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 1057 exit 0 ;; 1058 1058 *:Darwin:*:*) 1059 echo `uname -p`-apple-darwin${UNAME_RELEASE}1060 exit 0 ;;1059 echo `uname -p`-apple-darwin${UNAME_RELEASE} 1060 exit 0 ;; 1061 1061 *:procnto*:*:* | *:QNX:[0123456789]*:*) 1062 if test "${UNAME_MACHINE}" = "x86pc"; then1063 UNAME_MACHINE=pc1064 echo i386-${UNAME_MACHINE}-nto-qnx1065 else1066 echo `uname -p`-${UNAME_MACHINE}-nto-qnx1067 fi1068 exit 0 ;;1062 if test "${UNAME_MACHINE}" = "x86pc"; then 1063 UNAME_MACHINE=pc 1064 echo i386-${UNAME_MACHINE}-nto-qnx 1065 else 1066 echo `uname -p`-${UNAME_MACHINE}-nto-qnx 1067 fi 1068 exit 0 ;; 1069 1069 *:QNX:*:4*) 1070 echo i386-pc-qnx1071 exit 0 ;;1070 echo i386-pc-qnx 1071 exit 0 ;; 1072 1072 NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) 1073 echo nsr-tandem-nsk${UNAME_RELEASE}1074 exit 0 ;;1073 echo nsr-tandem-nsk${UNAME_RELEASE} 1074 exit 0 ;; 1075 1075 *:NonStop-UX:*:*) 1076 echo mips-compaq-nonstopux1077 exit 0 ;;1076 echo mips-compaq-nonstopux 1077 exit 0 ;; 1078 1078 BS2000:POSIX*:*:*) 1079 echo bs2000-siemens-sysv1080 exit 0 ;;1079 echo bs2000-siemens-sysv 1080 exit 0 ;; 1081 1081 DS/*:UNIX_System_V:*:*) 1082 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}1083 exit 0 ;;1082 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} 1083 exit 0 ;; 1084 1084 *:Plan9:*:*) 1085 # "uname -m" is not consistent, so use $cputype instead. 3861086 # is converted to i386 for consistency with other x861087 # operating systems.1088 if test "$cputype" = "386"; then1089 UNAME_MACHINE=i3861090 else1091 UNAME_MACHINE="$cputype"1092 fi1093 echo ${UNAME_MACHINE}-unknown-plan91094 exit 0 ;;1085 # "uname -m" is not consistent, so use $cputype instead. 386 1086 # is converted to i386 for consistency with other x86 1087 # operating systems. 1088 if test "$cputype" = "386"; then 1089 UNAME_MACHINE=i386 1090 else 1091 UNAME_MACHINE="$cputype" 1092 fi 1093 echo ${UNAME_MACHINE}-unknown-plan9 1094 exit 0 ;; 1095 1095 i*86:OS/2:*:*) 1096 # If we were able to find `uname', then EMX Unix compatibility1097 # is probably installed.1098 echo ${UNAME_MACHINE}-pc-os2-emx1099 exit 0 ;;1096 # If we were able to find `uname', then EMX Unix compatibility 1097 # is probably installed. 1098 echo ${UNAME_MACHINE}-pc-os2-emx 1099 exit 0 ;; 1100 1100 *:TOPS-10:*:*) 1101 echo pdp10-unknown-tops101102 exit 0 ;;1101 echo pdp10-unknown-tops10 1102 exit 0 ;; 1103 1103 *:TENEX:*:*) 1104 echo pdp10-unknown-tenex1105 exit 0 ;;1104 echo pdp10-unknown-tenex 1105 exit 0 ;; 1106 1106 KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) 1107 echo pdp10-dec-tops201108 exit 0 ;;1107 echo pdp10-dec-tops20 1108 exit 0 ;; 1109 1109 XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) 1110 echo pdp10-xkl-tops201111 exit 0 ;;1110 echo pdp10-xkl-tops20 1111 exit 0 ;; 1112 1112 *:TOPS-20:*:*) 1113 echo pdp10-unknown-tops201114 exit 0 ;;1113 echo pdp10-unknown-tops20 1114 exit 0 ;; 1115 1115 *:ITS:*:*) 1116 echo pdp10-unknown-its1117 exit 0 ;;1116 echo pdp10-unknown-its 1117 exit 0 ;; 1118 1118 i*86:XTS-300:*:STOP) 1119 echo ${UNAME_MACHINE}-unknown-stop1120 exit 0 ;;1119 echo ${UNAME_MACHINE}-unknown-stop 1120 exit 0 ;; 1121 1121 i*86:atheos:*:*) 1122 echo ${UNAME_MACHINE}-unknown-atheos1123 exit 0 ;;1122 echo ${UNAME_MACHINE}-unknown-atheos 1123 exit 0 ;; 1124 1124 esac 1125 1125 … … 1146 1146 "4" 1147 1147 #else 1148 ""1148 "" 1149 1149 #endif 1150 1150 ); exit (0); … … 1204 1204 1205 1205 if (strncmp(un.version, "V2", 2) == 0) { 1206 printf ("i386-sequent-ptx2\n"); exit (0);1206 printf ("i386-sequent-ptx2\n"); exit (0); 1207 1207 } 1208 1208 if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ 1209 printf ("i386-sequent-ptx1\n"); exit (0);1209 printf ("i386-sequent-ptx1\n"); exit (0); 1210 1210 } 1211 1211 printf ("i386-sequent-ptx\n"); exit (0); … … 1255 1255 case `getsysinfo -f cpu_type` in 1256 1256 c1*) 1257 echo c1-convex-bsd1258 exit 0 ;;1257 echo c1-convex-bsd 1258 exit 0 ;; 1259 1259 c2*) 1260 if getsysinfo -f scalar_acc1261 then echo c32-convex-bsd1262 else echo c2-convex-bsd1263 fi1264 exit 0 ;;1260 if getsysinfo -f scalar_acc 1261 then echo c32-convex-bsd 1262 else echo c2-convex-bsd 1263 fi 1264 exit 0 ;; 1265 1265 c34*) 1266 echo c34-convex-bsd1267 exit 0 ;;1266 echo c34-convex-bsd 1267 exit 0 ;; 1268 1268 c38*) 1269 echo c38-convex-bsd1270 exit 0 ;;1269 echo c38-convex-bsd 1270 exit 0 ;; 1271 1271 c4*) 1272 echo c4-convex-bsd1273 exit 0 ;;1272 echo c4-convex-bsd 1273 exit 0 ;; 1274 1274 esac 1275 1275 fi -
trunk/ithildin/autoconf/config.sub
r490 r578 48 48 # The goal of this file is to map all the various variations of a given 49 49 # machine specification into a single specification in the form: 50 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM50 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 51 51 # or in some cases, the newer four-part form: 52 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM52 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 53 53 # It is wrong to echo any other type of specification. 54 54 … … 91 91 -- ) # Stop option processing 92 92 shift; break ;; 93 - ) # Use stdin as input.93 - ) # Use stdin as input. 94 94 break ;; 95 95 -* ) … … 136 136 ### can provide default operating systems below. 137 137 case $os in 138 -sun*os*)139 # Prevent following clause from handling this invalid input.140 ;;141 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \142 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \143 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \144 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\145 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \146 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \147 -apple | -axis)148 os=149 basic_machine=$1150 ;;151 -sim | -cisco | -oki | -wec | -winbond)152 os=153 basic_machine=$1154 ;;155 -scout)156 ;;157 -wrs)158 os=-vxworks159 basic_machine=$1160 ;;161 -chorusos*)162 os=-chorusos163 basic_machine=$1164 ;;165 -chorusrdb)166 os=-chorusrdb167 basic_machine=$1168 ;;169 -hiux*)170 os=-hiuxwe2171 ;;172 -sco5)173 os=-sco3.2v5174 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`175 ;;176 -sco4)177 os=-sco3.2v4178 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`179 ;;180 -sco3.2.[4-9]*)181 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`182 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`183 ;;184 -sco3.2v[4-9]*)185 # Don't forget version if it is 3.2v4 or newer.186 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`187 ;;188 -sco*)189 os=-sco3.2v2190 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`191 ;;192 -udk*)193 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`194 ;;195 -isc)196 os=-isc2.2197 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`198 ;;199 -clix*)200 basic_machine=clipper-intergraph201 ;;202 -isc*)203 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`204 ;;205 -lynx*)206 os=-lynxos207 ;;208 -ptx*)209 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`210 ;;211 -windowsnt*)212 os=`echo $os | sed -e 's/windowsnt/winnt/'`213 ;;214 -psos*)215 os=-psos216 ;;217 -mint | -mint[0-9]*)218 basic_machine=m68k-atari219 os=-mint220 ;;138 -sun*os*) 139 # Prevent following clause from handling this invalid input. 140 ;; 141 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ 142 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ 143 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ 144 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ 145 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ 146 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ 147 -apple | -axis) 148 os= 149 basic_machine=$1 150 ;; 151 -sim | -cisco | -oki | -wec | -winbond) 152 os= 153 basic_machine=$1 154 ;; 155 -scout) 156 ;; 157 -wrs) 158 os=-vxworks 159 basic_machine=$1 160 ;; 161 -chorusos*) 162 os=-chorusos 163 basic_machine=$1 164 ;; 165 -chorusrdb) 166 os=-chorusrdb 167 basic_machine=$1 168 ;; 169 -hiux*) 170 os=-hiuxwe2 171 ;; 172 -sco5) 173 os=-sco3.2v5 174 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 175 ;; 176 -sco4) 177 os=-sco3.2v4 178 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 179 ;; 180 -sco3.2.[4-9]*) 181 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` 182 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 183 ;; 184 -sco3.2v[4-9]*) 185 # Don't forget version if it is 3.2v4 or newer. 186 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 187 ;; 188 -sco*) 189 os=-sco3.2v2 190 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 191 ;; 192 -udk*) 193 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 194 ;; 195 -isc) 196 os=-isc2.2 197 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 198 ;; 199 -clix*) 200 basic_machine=clipper-intergraph 201 ;; 202 -isc*) 203 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 204 ;; 205 -lynx*) 206 os=-lynxos 207 ;; 208 -ptx*) 209 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` 210 ;; 211 -windowsnt*) 212 os=`echo $os | sed -e 's/windowsnt/winnt/'` 213 ;; 214 -psos*) 215 os=-psos 216 ;; 217 -mint | -mint[0-9]*) 218 basic_machine=m68k-atari 219 os=-mint 220 ;; 221 221 esac 222 222 223 223 # Decode aliases for certain CPU-COMPANY combinations. 224 224 case $basic_machine in 225 # Recognize the basic CPU types without company name.226 # Some are omitted here because they have special meanings below.227 1750a | 580 \228 | a29k \229 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \230 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \231 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \232 | c4x | clipper \233 | d10v | d30v | dsp16xx \234 | fr30 \235 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \236 | i370 | i860 | i960 | ia64 \237 | m32r | m68000 | m68k | m88k | mcore \238 | mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \239 | mips64vr4100 | mips64vr4100el | mips64vr4300 \240 | mips64vr4300el | mips64vr5000 | mips64vr5000el \241 | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \242 | mipsisa32 | mipsisa64 \243 | mn10200 | mn10300 \244 | ns16k | ns32k \245 | openrisc | or32 \246 | pdp10 | pdp11 | pj | pjl \247 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \248 | pyramid \249 | sh | sh[34] | sh[34]eb | shbe | shle | sh64 \250 | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \251 | strongarm \252 | tahoe | thumb | tic80 | tron \253 | v850 | v850e \254 | we32k \255 | x86 | xscale | xstormy16 | xtensa \256 | z8k)257 basic_machine=$basic_machine-unknown258 ;;259 m6811 | m68hc11 | m6812 | m68hc12)260 # Motorola 68HC11/12.261 basic_machine=$basic_machine-unknown262 os=-none263 ;;264 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)265 ;;266 267 # We use `pc' rather than `unknown'268 # because (1) that's what they normally are, and269 # (2) the word "unknown" tends to confuse beginning users.270 i*86 | x86_64)271 basic_machine=$basic_machine-pc272 ;;273 # Object if more than one company name word.274 *-*-*)275 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2276 exit 1277 ;;278 # Recognize the basic CPU types with company name.279 580-* \280 | a29k-* \281 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \282 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \283 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \284 | arm-* | armbe-* | armle-* | armv*-* \285 | avr-* \286 | bs2000-* \287 | c[123]* | c30-* | [cjt]90-* | c54x-* \288 | clipper-* | cydra-* \289 | d10v-* | d30v-* \290 | elxsi-* \291 | f30[01]-* | f700-* | fr30-* | fx80-* \292 | h8300-* | h8500-* \293 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \294 | i*86-* | i860-* | i960-* | ia64-* \295 | m32r-* \296 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \297 | m88110-* | m88k-* | mcore-* \298 | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \299 | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \300 | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \301 | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \302 | none-* | np1-* | ns16k-* | ns32k-* \303 | orion-* \304 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \305 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \306 | pyramid-* \307 | romp-* | rs6000-* \308 | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \309 | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \310 | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \311 | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \312 | v850-* | v850e-* | vax-* \313 | we32k-* \314 | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \315 | xtensa-* \316 | ymp-* \317 | z8k-*)318 ;;319 # Recognize the various machine names and aliases which stand320 # for a CPU type and a company and sometimes even an OS.321 386bsd)322 basic_machine=i386-unknown323 os=-bsd324 ;;325 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)326 basic_machine=m68000-att327 ;;328 3b*)329 basic_machine=we32k-att330 ;;331 a29khif)332 basic_machine=a29k-amd333 os=-udi334 ;;335 adobe68k)336 basic_machine=m68010-adobe337 os=-scout338 ;;339 alliant | fx80)340 basic_machine=fx80-alliant341 ;;342 altos | altos3068)343 basic_machine=m68k-altos344 ;;345 am29k)346 basic_machine=a29k-none347 os=-bsd348 ;;349 amdahl)350 basic_machine=580-amdahl351 os=-sysv352 ;;353 amiga | amiga-*)354 basic_machine=m68k-unknown355 ;;356 amigaos | amigados)357 basic_machine=m68k-unknown358 os=-amigaos359 ;;360 amigaunix | amix)361 basic_machine=m68k-unknown362 os=-sysv4363 ;;364 apollo68)365 basic_machine=m68k-apollo366 os=-sysv367 ;;368 apollo68bsd)369 basic_machine=m68k-apollo370 os=-bsd371 ;;372 aux)373 basic_machine=m68k-apple374 os=-aux375 ;;376 balance)377 basic_machine=ns32k-sequent378 os=-dynix379 ;;380 c90)381 basic_machine=c90-cray382 os=-unicos383 ;;384 convex-c1)385 basic_machine=c1-convex386 os=-bsd387 ;;388 convex-c2)389 basic_machine=c2-convex390 os=-bsd391 ;;392 convex-c32)393 basic_machine=c32-convex394 os=-bsd395 ;;396 convex-c34)397 basic_machine=c34-convex398 os=-bsd399 ;;400 convex-c38)401 basic_machine=c38-convex402 os=-bsd403 ;;404 cray | j90)405 basic_machine=j90-cray406 os=-unicos407 ;;408 crds | unos)409 basic_machine=m68k-crds410 ;;411 cris | cris-* | etrax*)412 basic_machine=cris-axis413 ;;414 da30 | da30-*)415 basic_machine=m68k-da30416 ;;417 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)418 basic_machine=mips-dec419 ;;420 decsystem10* | dec10*)421 basic_machine=pdp10-dec422 os=-tops10423 ;;424 decsystem20* | dec20*)425 basic_machine=pdp10-dec426 os=-tops20427 ;;428 delta | 3300 | motorola-3300 | motorola-delta \429 | 3300-motorola | delta-motorola)430 basic_machine=m68k-motorola431 ;;432 delta88)433 basic_machine=m88k-motorola434 os=-sysv3435 ;;436 dpx20 | dpx20-*)437 basic_machine=rs6000-bull438 os=-bosx439 ;;440 dpx2* | dpx2*-bull)441 basic_machine=m68k-bull442 os=-sysv3443 ;;444 ebmon29k)445 basic_machine=a29k-amd446 os=-ebmon447 ;;448 elxsi)449 basic_machine=elxsi-elxsi450 os=-bsd451 ;;452 encore | umax | mmax)453 basic_machine=ns32k-encore454 ;;455 es1800 | OSE68k | ose68k | ose | OSE)456 basic_machine=m68k-ericsson457 os=-ose458 ;;459 fx2800)460 basic_machine=i860-alliant461 ;;462 genix)463 basic_machine=ns32k-ns464 ;;465 gmicro)466 basic_machine=tron-gmicro467 os=-sysv468 ;;469 go32)470 basic_machine=i386-pc471 os=-go32472 ;;473 h3050r* | hiux*)474 basic_machine=hppa1.1-hitachi475 os=-hiuxwe2476 ;;477 h8300hms)478 basic_machine=h8300-hitachi479 os=-hms480 ;;481 h8300xray)482 basic_machine=h8300-hitachi483 os=-xray484 ;;485 h8500hms)486 basic_machine=h8500-hitachi487 os=-hms488 ;;489 harris)490 basic_machine=m88k-harris491 os=-sysv3492 ;;493 hp300-*)494 basic_machine=m68k-hp495 ;;496 hp300bsd)497 basic_machine=m68k-hp498 os=-bsd499 ;;500 hp300hpux)501 basic_machine=m68k-hp502 os=-hpux503 ;;504 hp3k9[0-9][0-9] | hp9[0-9][0-9])505 basic_machine=hppa1.0-hp506 ;;507 hp9k2[0-9][0-9] | hp9k31[0-9])508 basic_machine=m68000-hp509 ;;510 hp9k3[2-9][0-9])511 basic_machine=m68k-hp512 ;;513 hp9k6[0-9][0-9] | hp6[0-9][0-9])514 basic_machine=hppa1.0-hp515 ;;516 hp9k7[0-79][0-9] | hp7[0-79][0-9])517 basic_machine=hppa1.1-hp518 ;;519 hp9k78[0-9] | hp78[0-9])520 # FIXME: really hppa2.0-hp521 basic_machine=hppa1.1-hp522 ;;523 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)524 # FIXME: really hppa2.0-hp525 basic_machine=hppa1.1-hp526 ;;527 hp9k8[0-9][13679] | hp8[0-9][13679])528 basic_machine=hppa1.1-hp529 ;;530 hp9k8[0-9][0-9] | hp8[0-9][0-9])531 basic_machine=hppa1.0-hp532 ;;533 hppa-next)534 os=-nextstep3535 ;;536 hppaosf)537 basic_machine=hppa1.1-hp538 os=-osf539 ;;540 hppro)541 basic_machine=hppa1.1-hp542 os=-proelf543 ;;544 i370-ibm* | ibm*)545 basic_machine=i370-ibm546 ;;225 # Recognize the basic CPU types without company name. 226 # Some are omitted here because they have special meanings below. 227 1750a | 580 \ 228 | a29k \ 229 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ 230 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ 231 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ 232 | c4x | clipper \ 233 | d10v | d30v | dsp16xx \ 234 | fr30 \ 235 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ 236 | i370 | i860 | i960 | ia64 \ 237 | m32r | m68000 | m68k | m88k | mcore \ 238 | mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ 239 | mips64vr4100 | mips64vr4100el | mips64vr4300 \ 240 | mips64vr4300el | mips64vr5000 | mips64vr5000el \ 241 | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ 242 | mipsisa32 | mipsisa64 \ 243 | mn10200 | mn10300 \ 244 | ns16k | ns32k \ 245 | openrisc | or32 \ 246 | pdp10 | pdp11 | pj | pjl \ 247 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ 248 | pyramid \ 249 | sh | sh[34] | sh[34]eb | shbe | shle | sh64 \ 250 | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ 251 | strongarm \ 252 | tahoe | thumb | tic80 | tron \ 253 | v850 | v850e \ 254 | we32k \ 255 | x86 | xscale | xstormy16 | xtensa \ 256 | z8k) 257 basic_machine=$basic_machine-unknown 258 ;; 259 m6811 | m68hc11 | m6812 | m68hc12) 260 # Motorola 68HC11/12. 261 basic_machine=$basic_machine-unknown 262 os=-none 263 ;; 264 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) 265 ;; 266 267 # We use `pc' rather than `unknown' 268 # because (1) that's what they normally are, and 269 # (2) the word "unknown" tends to confuse beginning users. 270 i*86 | x86_64) 271 basic_machine=$basic_machine-pc 272 ;; 273 # Object if more than one company name word. 274 *-*-*) 275 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 276 exit 1 277 ;; 278 # Recognize the basic CPU types with company name. 279 580-* \ 280 | a29k-* \ 281 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ 282 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ 283 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ 284 | arm-* | armbe-* | armle-* | armv*-* \ 285 | avr-* \ 286 | bs2000-* \ 287 | c[123]* | c30-* | [cjt]90-* | c54x-* \ 288 | clipper-* | cydra-* \ 289 | d10v-* | d30v-* \ 290 | elxsi-* \ 291 | f30[01]-* | f700-* | fr30-* | fx80-* \ 292 | h8300-* | h8500-* \ 293 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ 294 | i*86-* | i860-* | i960-* | ia64-* \ 295 | m32r-* \ 296 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ 297 | m88110-* | m88k-* | mcore-* \ 298 | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ 299 | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ 300 | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ 301 | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ 302 | none-* | np1-* | ns16k-* | ns32k-* \ 303 | orion-* \ 304 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 305 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ 306 | pyramid-* \ 307 | romp-* | rs6000-* \ 308 | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \ 309 | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ 310 | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ 311 | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ 312 | v850-* | v850e-* | vax-* \ 313 | we32k-* \ 314 | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ 315 | xtensa-* \ 316 | ymp-* \ 317 | z8k-*) 318 ;; 319 # Recognize the various machine names and aliases which stand 320 # for a CPU type and a company and sometimes even an OS. 321 386bsd) 322 basic_machine=i386-unknown 323 os=-bsd 324 ;; 325 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) 326 basic_machine=m68000-att 327 ;; 328 3b*) 329 basic_machine=we32k-att 330 ;; 331 a29khif) 332 basic_machine=a29k-amd 333 os=-udi 334 ;; 335 adobe68k) 336 basic_machine=m68010-adobe 337 os=-scout 338 ;; 339 alliant | fx80) 340 basic_machine=fx80-alliant 341 ;; 342 altos | altos3068) 343 basic_machine=m68k-altos 344 ;; 345 am29k) 346 basic_machine=a29k-none 347 os=-bsd 348 ;; 349 amdahl) 350 basic_machine=580-amdahl 351 os=-sysv 352 ;; 353 amiga | amiga-*) 354 basic_machine=m68k-unknown 355 ;; 356 amigaos | amigados) 357 basic_machine=m68k-unknown 358 os=-amigaos 359 ;; 360 amigaunix | amix) 361 basic_machine=m68k-unknown 362 os=-sysv4 363 ;; 364 apollo68) 365 basic_machine=m68k-apollo 366 os=-sysv 367 ;; 368 apollo68bsd) 369 basic_machine=m68k-apollo 370 os=-bsd 371 ;; 372 aux) 373 basic_machine=m68k-apple 374 os=-aux 375 ;; 376 balance) 377 basic_machine=ns32k-sequent 378 os=-dynix 379 ;; 380 c90) 381 basic_machine=c90-cray 382 os=-unicos 383 ;; 384 convex-c1) 385 basic_machine=c1-convex 386 os=-bsd 387 ;; 388 convex-c2) 389 basic_machine=c2-convex 390 os=-bsd 391 ;; 392 convex-c32) 393 basic_machine=c32-convex 394 os=-bsd 395 ;; 396 convex-c34) 397 basic_machine=c34-convex 398 os=-bsd 399 ;; 400 convex-c38) 401 basic_machine=c38-convex 402 os=-bsd 403 ;; 404 cray | j90) 405 basic_machine=j90-cray 406 os=-unicos 407 ;; 408 crds | unos) 409 basic_machine=m68k-crds 410 ;; 411 cris | cris-* | etrax*) 412 basic_machine=cris-axis 413 ;; 414 da30 | da30-*) 415 basic_machine=m68k-da30 416 ;; 417 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) 418 basic_machine=mips-dec 419 ;; 420 decsystem10* | dec10*) 421 basic_machine=pdp10-dec 422 os=-tops10 423 ;; 424 decsystem20* | dec20*) 425 basic_machine=pdp10-dec 426 os=-tops20 427 ;; 428 delta | 3300 | motorola-3300 | motorola-delta \ 429 | 3300-motorola | delta-motorola) 430 basic_machine=m68k-motorola 431 ;; 432 delta88) 433 basic_machine=m88k-motorola 434 os=-sysv3 435 ;; 436 dpx20 | dpx20-*) 437 basic_machine=rs6000-bull 438 os=-bosx 439 ;; 440 dpx2* | dpx2*-bull) 441 basic_machine=m68k-bull 442 os=-sysv3 443 ;; 444 ebmon29k) 445 basic_machine=a29k-amd 446 os=-ebmon 447 ;; 448 elxsi) 449 basic_machine=elxsi-elxsi 450 os=-bsd 451 ;; 452 encore | umax | mmax) 453 basic_machine=ns32k-encore 454 ;; 455 es1800 | OSE68k | ose68k | ose | OSE) 456 basic_machine=m68k-ericsson 457 os=-ose 458 ;; 459 fx2800) 460 basic_machine=i860-alliant 461 ;; 462 genix) 463 basic_machine=ns32k-ns 464 ;; 465 gmicro) 466 basic_machine=tron-gmicro 467 os=-sysv 468 ;; 469 go32) 470 basic_machine=i386-pc 471 os=-go32 472 ;; 473 h3050r* | hiux*) 474 basic_machine=hppa1.1-hitachi 475 os=-hiuxwe2 476 ;; 477 h8300hms) 478 basic_machine=h8300-hitachi 479 os=-hms 480 ;; 481 h8300xray) 482 basic_machine=h8300-hitachi 483 os=-xray 484 ;; 485 h8500hms) 486 basic_machine=h8500-hitachi 487 os=-hms 488 ;; 489 harris) 490 basic_machine=m88k-harris 491 os=-sysv3 492 ;; 493 hp300-*) 494 basic_machine=m68k-hp 495 ;; 496 hp300bsd) 497 basic_machine=m68k-hp 498 os=-bsd 499 ;; 500 hp300hpux) 501 basic_machine=m68k-hp 502 os=-hpux 503 ;; 504 hp3k9[0-9][0-9] | hp9[0-9][0-9]) 505 basic_machine=hppa1.0-hp 506 ;; 507 hp9k2[0-9][0-9] | hp9k31[0-9]) 508 basic_machine=m68000-hp 509 ;; 510 hp9k3[2-9][0-9]) 511 basic_machine=m68k-hp 512 ;; 513 hp9k6[0-9][0-9] | hp6[0-9][0-9]) 514 basic_machine=hppa1.0-hp 515 ;; 516 hp9k7[0-79][0-9] | hp7[0-79][0-9]) 517 basic_machine=hppa1.1-hp 518 ;; 519 hp9k78[0-9] | hp78[0-9]) 520 # FIXME: really hppa2.0-hp 521 basic_machine=hppa1.1-hp 522 ;; 523 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) 524 # FIXME: really hppa2.0-hp 525 basic_machine=hppa1.1-hp 526 ;; 527 hp9k8[0-9][13679] | hp8[0-9][13679]) 528 basic_machine=hppa1.1-hp 529 ;; 530 hp9k8[0-9][0-9] | hp8[0-9][0-9]) 531 basic_machine=hppa1.0-hp 532 ;; 533 hppa-next) 534 os=-nextstep3 535 ;; 536 hppaosf) 537 basic_machine=hppa1.1-hp 538 os=-osf 539 ;; 540 hppro) 541 basic_machine=hppa1.1-hp 542 os=-proelf 543 ;; 544 i370-ibm* | ibm*) 545 basic_machine=i370-ibm 546 ;; 547 547 # I'm not sure what "Sysv32" means. Should this be sysv3.2? 548 i*86v32)549 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`550 os=-sysv32551 ;;552 i*86v4*)553 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`554 os=-sysv4555 ;;556 i*86v)557 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`558 os=-sysv559 ;;560 i*86sol2)561 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`562 os=-solaris2563 ;;564 i386mach)565 basic_machine=i386-mach566 os=-mach567 ;;568 i386-vsta | vsta)569 basic_machine=i386-unknown570 os=-vsta571 ;;572 iris | iris4d)573 basic_machine=mips-sgi574 case $os in575 -irix*)576 ;;577 *)578 os=-irix4579 ;;580 esac581 ;;582 isi68 | isi)583 basic_machine=m68k-isi584 os=-sysv585 ;;586 m88k-omron*)587 basic_machine=m88k-omron588 ;;589 magnum | m3230)590 basic_machine=mips-mips591 os=-sysv592 ;;593 merlin)594 basic_machine=ns32k-utek595 os=-sysv596 ;;597 mingw32)598 basic_machine=i386-pc599 os=-mingw32600 ;;601 miniframe)602 basic_machine=m68000-convergent603 ;;604 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)605 basic_machine=m68k-atari606 os=-mint607 ;;608 mips3*-*)609 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`610 ;;611 mips3*)612 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown613 ;;614 mmix*)615 basic_machine=mmix-knuth616 os=-mmixware617 ;;618 monitor)619 basic_machine=m68k-rom68k620 os=-coff621 ;;622 morphos)623 basic_machine=powerpc-unknown624 os=-morphos625 ;;626 msdos)627 basic_machine=i386-pc628 os=-msdos629 ;;630 mvs)631 basic_machine=i370-ibm632 os=-mvs633 ;;634 ncr3000)635 basic_machine=i486-ncr636 os=-sysv4637 ;;638 netbsd386)639 basic_machine=i386-unknown640 os=-netbsd641 ;;642 netwinder)643 basic_machine=armv4l-rebel644 os=-linux645 ;;646 news | news700 | news800 | news900)647 basic_machine=m68k-sony648 os=-newsos649 ;;650 news1000)651 basic_machine=m68030-sony652 os=-newsos653 ;;654 news-3600 | risc-news)655 basic_machine=mips-sony656 os=-newsos657 ;;658 necv70)659 basic_machine=v70-nec660 os=-sysv661 ;;662 next | m*-next )663 basic_machine=m68k-next664 case $os in665 -nextstep* )666 ;;667 -ns2*)668 os=-nextstep2669 ;;670 *)671 os=-nextstep3672 ;;673 esac674 ;;675 nh3000)676 basic_machine=m68k-harris677 os=-cxux678 ;;679 nh[45]000)680 basic_machine=m88k-harris681 os=-cxux682 ;;683 nindy960)684 basic_machine=i960-intel685 os=-nindy686 ;;687 mon960)688 basic_machine=i960-intel689 os=-mon960690 ;;691 nonstopux)692 basic_machine=mips-compaq693 os=-nonstopux694 ;;695 np1)696 basic_machine=np1-gould697 ;;698 nsr-tandem)699 basic_machine=nsr-tandem700 ;;701 op50n-* | op60c-*)702 basic_machine=hppa1.1-oki703 os=-proelf704 ;;705 or32 | or32-*)706 basic_machine=or32-unknown707 os=-coff708 ;;709 OSE68000 | ose68000)710 basic_machine=m68000-ericsson711 os=-ose712 ;;713 os68k)714 basic_machine=m68k-none715 os=-os68k716 ;;717 pa-hitachi)718 basic_machine=hppa1.1-hitachi719 os=-hiuxwe2720 ;;721 paragon)722 basic_machine=i860-intel723 os=-osf724 ;;725 pbd)726 basic_machine=sparc-tti727 ;;728 pbb)729 basic_machine=m68k-tti730 ;;548 i*86v32) 549 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 550 os=-sysv32 551 ;; 552 i*86v4*) 553 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 554 os=-sysv4 555 ;; 556 i*86v) 557 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 558 os=-sysv 559 ;; 560 i*86sol2) 561 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 562 os=-solaris2 563 ;; 564 i386mach) 565 basic_machine=i386-mach 566 os=-mach 567 ;; 568 i386-vsta | vsta) 569 basic_machine=i386-unknown 570 os=-vsta 571 ;; 572 iris | iris4d) 573 basic_machine=mips-sgi 574 case $os in 575 -irix*) 576 ;; 577 *) 578 os=-irix4 579 ;; 580 esac 581 ;; 582 isi68 | isi) 583 basic_machine=m68k-isi 584 os=-sysv 585 ;; 586 m88k-omron*) 587 basic_machine=m88k-omron 588 ;; 589 magnum | m3230) 590 basic_machine=mips-mips 591 os=-sysv 592 ;; 593 merlin) 594 basic_machine=ns32k-utek 595 os=-sysv 596 ;; 597 mingw32) 598 basic_machine=i386-pc 599 os=-mingw32 600 ;; 601 miniframe) 602 basic_machine=m68000-convergent 603 ;; 604 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) 605 basic_machine=m68k-atari 606 os=-mint 607 ;; 608 mips3*-*) 609 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` 610 ;; 611 mips3*) 612 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown 613 ;; 614 mmix*) 615 basic_machine=mmix-knuth 616 os=-mmixware 617 ;; 618 monitor) 619 basic_machine=m68k-rom68k 620 os=-coff 621 ;; 622 morphos) 623 basic_machine=powerpc-unknown 624 os=-morphos 625 ;; 626 msdos) 627 basic_machine=i386-pc 628 os=-msdos 629 ;; 630 mvs) 631 basic_machine=i370-ibm 632 os=-mvs 633 ;; 634 ncr3000) 635 basic_machine=i486-ncr 636 os=-sysv4 637 ;; 638 netbsd386) 639 basic_machine=i386-unknown 640 os=-netbsd 641 ;; 642 netwinder) 643 basic_machine=armv4l-rebel 644 os=-linux 645 ;; 646 news | news700 | news800 | news900) 647 basic_machine=m68k-sony 648 os=-newsos 649 ;; 650 news1000) 651 basic_machine=m68030-sony 652 os=-newsos 653 ;; 654 news-3600 | risc-news) 655 basic_machine=mips-sony 656 os=-newsos 657 ;; 658 necv70) 659 basic_machine=v70-nec 660 os=-sysv 661 ;; 662 next | m*-next ) 663 basic_machine=m68k-next 664 case $os in 665 -nextstep* ) 666 ;; 667 -ns2*) 668 os=-nextstep2 669 ;; 670 *) 671 os=-nextstep3 672 ;; 673 esac 674 ;; 675 nh3000) 676 basic_machine=m68k-harris 677 os=-cxux 678 ;; 679 nh[45]000) 680 basic_machine=m88k-harris 681 os=-cxux 682 ;; 683 nindy960) 684 basic_machine=i960-intel 685 os=-nindy 686 ;; 687 mon960) 688 basic_machine=i960-intel 689 os=-mon960 690 ;; 691 nonstopux) 692 basic_machine=mips-compaq 693 os=-nonstopux 694 ;; 695 np1) 696 basic_machine=np1-gould 697 ;; 698 nsr-tandem) 699 basic_machine=nsr-tandem 700 ;; 701 op50n-* | op60c-*) 702 basic_machine=hppa1.1-oki 703 os=-proelf 704 ;; 705 or32 | or32-*) 706 basic_machine=or32-unknown 707 os=-coff 708 ;; 709 OSE68000 | ose68000) 710 basic_machine=m68000-ericsson 711 os=-ose 712 ;; 713 os68k) 714 basic_machine=m68k-none 715 os=-os68k 716 ;; 717 pa-hitachi) 718 basic_machine=hppa1.1-hitachi 719 os=-hiuxwe2 720 ;; 721 paragon) 722 basic_machine=i860-intel 723 os=-osf 724 ;; 725 pbd) 726 basic_machine=sparc-tti 727 ;; 728 pbb) 729 basic_machine=m68k-tti 730 ;; 731 731 pc532 | pc532-*) 732 basic_machine=ns32k-pc532733 ;;734 pentium | p5 | k5 | k6 | nexgen | viac3)735 basic_machine=i586-pc736 ;;737 pentiumpro | p6 | 6x86 | athlon)738 basic_machine=i686-pc739 ;;740 pentiumii | pentium2)741 basic_machine=i686-pc742 ;;743 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)744 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`745 ;;746 pentiumpro-* | p6-* | 6x86-* | athlon-*)747 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`748 ;;749 pentiumii-* | pentium2-*)750 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`751 ;;752 pn)753 basic_machine=pn-gould754 ;;755 power)basic_machine=power-ibm756 ;;757 ppc)basic_machine=powerpc-unknown758 ;;759 ppc-*)basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`760 ;;761 ppcle | powerpclittle | ppc-le | powerpc-little)762 basic_machine=powerpcle-unknown763 ;;764 ppcle-* | powerpclittle-*)765 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`766 ;;767 ppc64)basic_machine=powerpc64-unknown768 ;;769 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`770 ;;771 ppc64le | powerpc64little | ppc64-le | powerpc64-little)772 basic_machine=powerpc64le-unknown773 ;;774 ppc64le-* | powerpc64little-*)775 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`776 ;;777 ps2)778 basic_machine=i386-ibm779 ;;780 pw32)781 basic_machine=i586-unknown782 os=-pw32783 ;;784 rom68k)785 basic_machine=m68k-rom68k786 os=-coff787 ;;788 rm[46]00)789 basic_machine=mips-siemens790 ;;791 rtpc | rtpc-*)792 basic_machine=romp-ibm793 ;;794 s390 | s390-*)795 basic_machine=s390-ibm796 ;;797 s390x | s390x-*)798 basic_machine=s390x-ibm799 ;;800 sa29200)801 basic_machine=a29k-amd802 os=-udi803 ;;804 sequent)805 basic_machine=i386-sequent806 ;;807 sh)808 basic_machine=sh-hitachi809 os=-hms810 ;;811 sparclite-wrs | simso-wrs)812 basic_machine=sparclite-wrs813 os=-vxworks814 ;;815 sps7)816 basic_machine=m68k-bull817 os=-sysv2818 ;;819 spur)820 basic_machine=spur-unknown821 ;;822 st2000)823 basic_machine=m68k-tandem824 ;;825 stratus)826 basic_machine=i860-stratus827 os=-sysv4828 ;;829 sun2)830 basic_machine=m68000-sun831 ;;832 sun2os3)833 basic_machine=m68000-sun834 os=-sunos3835 ;;836 sun2os4)837 basic_machine=m68000-sun838 os=-sunos4839 ;;840 sun3os3)841 basic_machine=m68k-sun842 os=-sunos3843 ;;844 sun3os4)845 basic_machine=m68k-sun846 os=-sunos4847 ;;848 sun4os3)849 basic_machine=sparc-sun850 os=-sunos3851 ;;852 sun4os4)853 basic_machine=sparc-sun854 os=-sunos4855 ;;856 sun4sol2)857 basic_machine=sparc-sun858 os=-solaris2859 ;;860 sun3 | sun3-*)861 basic_machine=m68k-sun862 ;;863 sun4)864 basic_machine=sparc-sun865 ;;866 sun386 | sun386i | roadrunner)867 basic_machine=i386-sun868 ;;732 basic_machine=ns32k-pc532 733 ;; 734 pentium | p5 | k5 | k6 | nexgen | viac3) 735 basic_machine=i586-pc 736 ;; 737 pentiumpro | p6 | 6x86 | athlon) 738 basic_machine=i686-pc 739 ;; 740 pentiumii | pentium2) 741 basic_machine=i686-pc 742 ;; 743 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) 744 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` 745 ;; 746 pentiumpro-* | p6-* | 6x86-* | athlon-*) 747 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 748 ;; 749 pentiumii-* | pentium2-*) 750 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 751 ;; 752 pn) 753 basic_machine=pn-gould 754 ;; 755 power) basic_machine=power-ibm 756 ;; 757 ppc) basic_machine=powerpc-unknown 758 ;; 759 ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 760 ;; 761 ppcle | powerpclittle | ppc-le | powerpc-little) 762 basic_machine=powerpcle-unknown 763 ;; 764 ppcle-* | powerpclittle-*) 765 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` 766 ;; 767 ppc64) basic_machine=powerpc64-unknown 768 ;; 769 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` 770 ;; 771 ppc64le | powerpc64little | ppc64-le | powerpc64-little) 772 basic_machine=powerpc64le-unknown 773 ;; 774 ppc64le-* | powerpc64little-*) 775 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` 776 ;; 777 ps2) 778 basic_machine=i386-ibm 779 ;; 780 pw32) 781 basic_machine=i586-unknown 782 os=-pw32 783 ;; 784 rom68k) 785 basic_machine=m68k-rom68k 786 os=-coff 787 ;; 788 rm[46]00) 789 basic_machine=mips-siemens 790 ;; 791 rtpc | rtpc-*) 792 basic_machine=romp-ibm 793 ;; 794 s390 | s390-*) 795 basic_machine=s390-ibm 796 ;; 797 s390x | s390x-*) 798 basic_machine=s390x-ibm 799 ;; 800 sa29200) 801 basic_machine=a29k-amd 802 os=-udi 803 ;; 804 sequent) 805 basic_machine=i386-sequent 806 ;; 807 sh) 808 basic_machine=sh-hitachi 809 os=-hms 810 ;; 811 sparclite-wrs | simso-wrs) 812 basic_machine=sparclite-wrs 813 os=-vxworks 814 ;; 815 sps7) 816 basic_machine=m68k-bull 817 os=-sysv2 818 ;; 819 spur) 820 basic_machine=spur-unknown 821 ;; 822 st2000) 823 basic_machine=m68k-tandem 824 ;; 825 stratus) 826 basic_machine=i860-stratus 827 os=-sysv4 828 ;; 829 sun2) 830 basic_machine=m68000-sun 831 ;; 832 sun2os3) 833 basic_machine=m68000-sun 834 os=-sunos3 835 ;; 836 sun2os4) 837 basic_machine=m68000-sun 838 os=-sunos4 839 ;; 840 sun3os3) 841 basic_machine=m68k-sun 842 os=-sunos3 843 ;; 844 sun3os4) 845 basic_machine=m68k-sun 846 os=-sunos4 847 ;; 848 sun4os3) 849 basic_machine=sparc-sun 850 os=-sunos3 851 ;; 852 sun4os4) 853 basic_machine=sparc-sun 854 os=-sunos4 855 ;; 856 sun4sol2) 857 basic_machine=sparc-sun 858 os=-solaris2 859 ;; 860 sun3 | sun3-*) 861 basic_machine=m68k-sun 862 ;; 863 sun4) 864 basic_machine=sparc-sun 865 ;; 866 sun386 | sun386i | roadrunner) 867 basic_machine=i386-sun 868 ;; 869 869 sv1) 870 basic_machine=sv1-cray871 os=-unicos872 ;;873 symmetry)874 basic_machine=i386-sequent875 os=-dynix876 ;;877 t3d)878 basic_machine=alpha-cray879 os=-unicos880 ;;881 t3e)882 basic_machine=alphaev5-cray883 os=-unicos884 ;;885 t90)886 basic_machine=t90-cray887 os=-unicos888 ;;889 tic54x | c54x*)890 basic_machine=tic54x-unknown891 os=-coff892 ;;893 tx39)894 basic_machine=mipstx39-unknown895 ;;896 tx39el)897 basic_machine=mipstx39el-unknown898 ;;899 toad1)900 basic_machine=pdp10-xkl901 os=-tops20902 ;;903 tower | tower-32)904 basic_machine=m68k-ncr905 ;;906 udi29k)907 basic_machine=a29k-amd908 os=-udi909 ;;910 ultra3)911 basic_machine=a29k-nyu912 os=-sym1913 ;;914 v810 | necv810)915 basic_machine=v810-nec916 os=-none917 ;;918 vaxv)919 basic_machine=vax-dec920 os=-sysv921 ;;922 vms)923 basic_machine=vax-dec924 os=-vms925 ;;926 vpp*|vx|vx-*)870 basic_machine=sv1-cray 871 os=-unicos 872 ;; 873 symmetry) 874 basic_machine=i386-sequent 875 os=-dynix 876 ;; 877 t3d) 878 basic_machine=alpha-cray 879 os=-unicos 880 ;; 881 t3e) 882 basic_machine=alphaev5-cray 883 os=-unicos 884 ;; 885 t90) 886 basic_machine=t90-cray 887 os=-unicos 888 ;; 889 tic54x | c54x*) 890 basic_machine=tic54x-unknown 891 os=-coff 892 ;; 893 tx39) 894 basic_machine=mipstx39-unknown 895 ;; 896 tx39el) 897 basic_machine=mipstx39el-unknown 898 ;; 899 toad1) 900 basic_machine=pdp10-xkl 901 os=-tops20 902 ;; 903 tower | tower-32) 904 basic_machine=m68k-ncr 905 ;; 906 udi29k) 907 basic_machine=a29k-amd 908 os=-udi 909 ;; 910 ultra3) 911 basic_machine=a29k-nyu 912 os=-sym1 913 ;; 914 v810 | necv810) 915 basic_machine=v810-nec 916 os=-none 917 ;; 918 vaxv) 919 basic_machine=vax-dec 920 os=-sysv 921 ;; 922 vms) 923 basic_machine=vax-dec 924 os=-vms 925 ;; 926 vpp*|vx|vx-*) 927 927 basic_machine=f301-fujitsu 928 928 ;; 929 vxworks960)930 basic_machine=i960-wrs931 os=-vxworks932 ;;933 vxworks68)934 basic_machine=m68k-wrs935 os=-vxworks936 ;;937 vxworks29k)938 basic_machine=a29k-wrs939 os=-vxworks940 ;;941 w65*)942 basic_machine=w65-wdc943 os=-none944 ;;945 w89k-*)946 basic_machine=hppa1.1-winbond947 os=-proelf948 ;;949 windows32)950 basic_machine=i386-pc951 os=-windows32-msvcrt952 ;;929 vxworks960) 930 basic_machine=i960-wrs 931 os=-vxworks 932 ;; 933 vxworks68) 934 basic_machine=m68k-wrs 935 os=-vxworks 936 ;; 937 vxworks29k) 938 basic_machine=a29k-wrs 939 os=-vxworks 940 ;; 941 w65*) 942 basic_machine=w65-wdc 943 os=-none 944 ;; 945 w89k-*) 946 basic_machine=hppa1.1-winbond 947 os=-proelf 948 ;; 949 windows32) 950 basic_machine=i386-pc 951 os=-windows32-msvcrt 952 ;; 953 953 xps | xps100) 954 basic_machine=xps100-honeywell955 ;;956 ymp)957 basic_machine=ymp-cray958 os=-unicos959 ;;960 z8k-*-coff)961 basic_machine=z8k-unknown962 os=-sim963 ;;964 none)965 basic_machine=none-none966 os=-none967 ;;954 basic_machine=xps100-honeywell 955 ;; 956 ymp) 957 basic_machine=ymp-cray 958 os=-unicos 959 ;; 960 z8k-*-coff) 961 basic_machine=z8k-unknown 962 os=-sim 963 ;; 964 none) 965 basic_machine=none-none 966 os=-none 967 ;; 968 968 969 969 # Here we handle the default manufacturer of certain CPU types. It is in 970 970 # some cases the only manufacturer, in others, it is the most popular. 971 w89k)972 basic_machine=hppa1.1-winbond973 ;;974 op50n)975 basic_machine=hppa1.1-oki976 ;;977 op60c)978 basic_machine=hppa1.1-oki979 ;;980 romp)981 basic_machine=romp-ibm982 ;;983 rs6000)984 basic_machine=rs6000-ibm985 ;;986 vax)987 basic_machine=vax-dec988 ;;989 pdp10)990 # there are many clones, so DEC is not a safe bet991 basic_machine=pdp10-unknown992 ;;993 pdp11)994 basic_machine=pdp11-dec995 ;;996 we32k)997 basic_machine=we32k-att998 ;;999 sh3 | sh4 | sh3eb | sh4eb)1000 basic_machine=sh-unknown1001 ;;1002 sh64)1003 basic_machine=sh64-unknown1004 ;;1005 sparc | sparcv9 | sparcv9b)1006 basic_machine=sparc-sun1007 ;;971 w89k) 972 basic_machine=hppa1.1-winbond 973 ;; 974 op50n) 975 basic_machine=hppa1.1-oki 976 ;; 977 op60c) 978 basic_machine=hppa1.1-oki 979 ;; 980 romp) 981 basic_machine=romp-ibm 982 ;; 983 rs6000) 984 basic_machine=rs6000-ibm 985 ;; 986 vax) 987 basic_machine=vax-dec 988 ;; 989 pdp10) 990 # there are many clones, so DEC is not a safe bet 991 basic_machine=pdp10-unknown 992 ;; 993 pdp11) 994 basic_machine=pdp11-dec 995 ;; 996 we32k) 997 basic_machine=we32k-att 998 ;; 999 sh3 | sh4 | sh3eb | sh4eb) 1000 basic_machine=sh-unknown 1001 ;; 1002 sh64) 1003 basic_machine=sh64-unknown 1004 ;; 1005 sparc | sparcv9 | sparcv9b) 1006 basic_machine=sparc-sun 1007 ;; 1008 1008 cydra) 1009 basic_machine=cydra-cydrome1010 ;;1011 orion)1012 basic_machine=orion-highlevel1013 ;;1014 orion105)1015 basic_machine=clipper-highlevel1016 ;;1017 mac | mpw | mac-mpw)1018 basic_machine=m68k-apple1019 ;;1020 pmac | pmac-mpw)1021 basic_machine=powerpc-apple1022 ;;1023 c4x*)1024 basic_machine=c4x-none1025 os=-coff1026 ;;1027 *-unknown)1028 # Make sure to match an already-canonicalized machine name.1029 ;;1030 *)1031 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&21032 exit 11033 ;;1009 basic_machine=cydra-cydrome 1010 ;; 1011 orion) 1012 basic_machine=orion-highlevel 1013 ;; 1014 orion105) 1015 basic_machine=clipper-highlevel 1016 ;; 1017 mac | mpw | mac-mpw) 1018 basic_machine=m68k-apple 1019 ;; 1020 pmac | pmac-mpw) 1021 basic_machine=powerpc-apple 1022 ;; 1023 c4x*) 1024 basic_machine=c4x-none 1025 os=-coff 1026 ;; 1027 *-unknown) 1028 # Make sure to match an already-canonicalized machine name. 1029 ;; 1030 *) 1031 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 1032 exit 1 1033 ;; 1034 1034 esac 1035 1035 1036 1036 # Here we canonicalize certain aliases for manufacturers. 1037 1037 case $basic_machine in 1038 *-digital*)1039 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`1040 ;;1041 *-commodore*)1042 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`1043 ;;1044 *)1045 ;;1038 *-digital*) 1039 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` 1040 ;; 1041 *-commodore*) 1042 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` 1043 ;; 1044 *) 1045 ;; 1046 1046 esac 1047 1047 … … 1053 1053 # First match some system type aliases 1054 1054 # that might get confused with valid system types. 1055 # -solaris* is a basic system type, with this one exception.1056 -solaris1 | -solaris1.*)1057 os=`echo $os | sed -e 's|solaris1|sunos4|'`1058 ;;1059 -solaris)1060 os=-solaris21061 ;;1062 -svr4*)1063 os=-sysv41064 ;;1065 -unixware*)1066 os=-sysv4.2uw1067 ;;1068 -gnu/linux*)1069 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`1070 ;;1071 # First accept the basic system types.1072 # The portable systems comes first.1073 # Each alternative MUST END IN A *, to match a version number.1074 # -sysv* is not here because it comes later, after sysvr4.1075 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \1076 | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\1077 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \1078 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \1079 | -aos* \1080 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \1081 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \1082 | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \1083 | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \1084 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \1085 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \1086 | -chorusos* | -chorusrdb* \1087 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \1088 | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \1089 | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \1090 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \1091 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \1092 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \1093 | -morphos* | -superux* | -rtmk* | -rtmk-nova*)1094 # Remember, each alternative MUST END IN *, to match a version number.1095 ;;1096 -qnx*)1097 case $basic_machine in1098 x86-* | i*86-*)1099 ;;1100 *)1101 os=-nto$os1102 ;;1103 esac1104 ;;1105 -nto*)1106 os=-nto-qnx1107 ;;1108 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \1109 | -windows* | -osx | -abug | -netware* | -os9* | -beos* \1110 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)1111 ;;1112 -mac*)1113 os=`echo $os | sed -e 's|mac|macos|'`1114 ;;1115 -linux*)1116 os=`echo $os | sed -e 's|linux|linux-gnu|'`1117 ;;1118 -sunos5*)1119 os=`echo $os | sed -e 's|sunos5|solaris2|'`1120 ;;1121 -sunos6*)1122 os=`echo $os | sed -e 's|sunos6|solaris3|'`1123 ;;1124 -opened*)1125 os=-openedition1126 ;;1127 -wince*)1128 os=-wince1129 ;;1130 -osfrose*)1131 os=-osfrose1132 ;;1133 -osf*)1134 os=-osf1135 ;;1136 -utek*)1137 os=-bsd1138 ;;1139 -dynix*)1140 os=-bsd1141 ;;1142 -acis*)1143 os=-aos1144 ;;1145 -atheos*)1146 os=-atheos1147 ;;1148 -386bsd)1149 os=-bsd1150 ;;1151 -ctix* | -uts*)1152 os=-sysv1153 ;;1154 -nova*)1155 os=-rtmk-nova1156 ;;1157 -ns2 )1158 os=-nextstep21159 ;;1160 -nsk*)1161 os=-nsk1162 ;;1163 # Preserve the version number of sinix5.1164 -sinix5.*)1165 os=`echo $os | sed -e 's|sinix|sysv|'`1166 ;;1167 -sinix*)1168 os=-sysv41169 ;;1170 -triton*)1171 os=-sysv31172 ;;1173 -oss*)1174 os=-sysv31175 ;;1176 -svr4)1177 os=-sysv41178 ;;1179 -svr3)1180 os=-sysv31181 ;;1182 -sysvr4)1183 os=-sysv41184 ;;1185 # This must come after -sysvr4.1186 -sysv*)1187 ;;1188 -ose*)1189 os=-ose1190 ;;1191 -es1800*)1192 os=-ose1193 ;;1194 -xenix)1195 os=-xenix1196 ;;1055 # -solaris* is a basic system type, with this one exception. 1056 -solaris1 | -solaris1.*) 1057 os=`echo $os | sed -e 's|solaris1|sunos4|'` 1058 ;; 1059 -solaris) 1060 os=-solaris2 1061 ;; 1062 -svr4*) 1063 os=-sysv4 1064 ;; 1065 -unixware*) 1066 os=-sysv4.2uw 1067 ;; 1068 -gnu/linux*) 1069 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` 1070 ;; 1071 # First accept the basic system types. 1072 # The portable systems comes first. 1073 # Each alternative MUST END IN A *, to match a version number. 1074 # -sysv* is not here because it comes later, after sysvr4. 1075 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ 1076 | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ 1077 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ 1078 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 1079 | -aos* \ 1080 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ 1081 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 1082 | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ 1083 | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ 1084 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ 1085 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ 1086 | -chorusos* | -chorusrdb* \ 1087 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1088 | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ 1089 | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ 1090 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ 1091 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ 1092 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ 1093 | -morphos* | -superux* | -rtmk* | -rtmk-nova*) 1094 # Remember, each alternative MUST END IN *, to match a version number. 1095 ;; 1096 -qnx*) 1097 case $basic_machine in 1098 x86-* | i*86-*) 1099 ;; 1100 *) 1101 os=-nto$os 1102 ;; 1103 esac 1104 ;; 1105 -nto*) 1106 os=-nto-qnx 1107 ;; 1108 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ 1109 | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ 1110 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) 1111 ;; 1112 -mac*) 1113 os=`echo $os | sed -e 's|mac|macos|'` 1114 ;; 1115 -linux*) 1116 os=`echo $os | sed -e 's|linux|linux-gnu|'` 1117 ;; 1118 -sunos5*) 1119 os=`echo $os | sed -e 's|sunos5|solaris2|'` 1120 ;; 1121 -sunos6*) 1122 os=`echo $os | sed -e 's|sunos6|solaris3|'` 1123 ;; 1124 -opened*) 1125 os=-openedition 1126 ;; 1127 -wince*) 1128 os=-wince 1129 ;; 1130 -osfrose*) 1131 os=-osfrose 1132 ;; 1133 -osf*) 1134 os=-osf 1135 ;; 1136 -utek*) 1137 os=-bsd 1138 ;; 1139 -dynix*) 1140 os=-bsd 1141 ;; 1142 -acis*) 1143 os=-aos 1144 ;; 1145 -atheos*) 1146 os=-atheos 1147 ;; 1148 -386bsd) 1149 os=-bsd 1150 ;; 1151 -ctix* | -uts*) 1152 os=-sysv 1153 ;; 1154 -nova*) 1155 os=-rtmk-nova 1156 ;; 1157 -ns2 ) 1158 os=-nextstep2 1159 ;; 1160 -nsk*) 1161 os=-nsk 1162 ;; 1163 # Preserve the version number of sinix5. 1164 -sinix5.*) 1165 os=`echo $os | sed -e 's|sinix|sysv|'` 1166 ;; 1167 -sinix*) 1168 os=-sysv4 1169 ;; 1170 -triton*) 1171 os=-sysv3 1172 ;; 1173 -oss*) 1174 os=-sysv3 1175 ;; 1176 -svr4) 1177 os=-sysv4 1178 ;; 1179 -svr3) 1180 os=-sysv3 1181 ;; 1182 -sysvr4) 1183 os=-sysv4 1184 ;; 1185 # This must come after -sysvr4. 1186 -sysv*) 1187 ;; 1188 -ose*) 1189 os=-ose 1190 ;; 1191 -es1800*) 1192 os=-ose 1193 ;; 1194 -xenix) 1195 os=-xenix 1196 ;; 1197 1197 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1198 os=-mint1199 ;;1200 -none)1201 ;;1202 *)1203 # Get rid of the `-' at the beginning of $os.1204 os=`echo $os | sed 's/[^-]*-//'`1205 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&21206 exit 11207 ;;1198 os=-mint 1199 ;; 1200 -none) 1201 ;; 1202 *) 1203 # Get rid of the `-' at the beginning of $os. 1204 os=`echo $os | sed 's/[^-]*-//'` 1205 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 1206 exit 1 1207 ;; 1208 1208 esac 1209 1209 else … … 1220 1220 1221 1221 case $basic_machine in 1222 *-acorn)1223 os=-riscix1.21224 ;;1225 arm*-rebel)1226 os=-linux1227 ;;1228 arm*-semi)1229 os=-aout1230 ;;1231 # This must come before the *-dec entry.1232 pdp10-*)1233 os=-tops201234 ;;1222 *-acorn) 1223 os=-riscix1.2 1224 ;; 1225 arm*-rebel) 1226 os=-linux 1227 ;; 1228 arm*-semi) 1229 os=-aout 1230 ;; 1231 # This must come before the *-dec entry. 1232 pdp10-*) 1233 os=-tops20 1234 ;; 1235 1235 pdp11-*) 1236 os=-none1237 ;;1238 *-dec | vax-*)1239 os=-ultrix4.21240 ;;1241 m68*-apollo)1242 os=-domain1243 ;;1244 i386-sun)1245 os=-sunos4.0.21246 ;;1247 m68000-sun)1248 os=-sunos31249 # This also exists in the configure program, but was not the1250 # default.1251 # os=-sunos41252 ;;1253 m68*-cisco)1254 os=-aout1255 ;;1256 mips*-cisco)1257 os=-elf1258 ;;1259 mips*-*)1260 os=-elf1261 ;;1262 or32-*)1263 os=-coff1264 ;;1265 *-tti)# must be before sparc entry or we get the wrong os.1266 os=-sysv31267 ;;1268 sparc-* | *-sun)1269 os=-sunos4.1.11270 ;;1271 *-be)1272 os=-beos1273 ;;1274 *-ibm)1275 os=-aix1276 ;;1277 *-wec)1278 os=-proelf1279 ;;1280 *-winbond)1281 os=-proelf1282 ;;1283 *-oki)1284 os=-proelf1285 ;;1286 *-hp)1287 os=-hpux1288 ;;1289 *-hitachi)1290 os=-hiux1291 ;;1292 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)1293 os=-sysv1294 ;;1295 *-cbm)1296 os=-amigaos1297 ;;1298 *-dg)1299 os=-dgux1300 ;;1301 *-dolphin)1302 os=-sysv31303 ;;1304 m68k-ccur)1305 os=-rtu1306 ;;1307 m88k-omron*)1308 os=-luna1309 ;;1310 *-next )1311 os=-nextstep1312 ;;1313 *-sequent)1314 os=-ptx1315 ;;1316 *-crds)1317 os=-unos1318 ;;1319 *-ns)1320 os=-genix1321 ;;1322 i370-*)1323 os=-mvs1324 ;;1325 *-next)1326 os=-nextstep31327 ;;1236 os=-none 1237 ;; 1238 *-dec | vax-*) 1239 os=-ultrix4.2 1240 ;; 1241 m68*-apollo) 1242 os=-domain 1243 ;; 1244 i386-sun) 1245 os=-sunos4.0.2 1246 ;; 1247 m68000-sun) 1248 os=-sunos3 1249 # This also exists in the configure program, but was not the 1250 # default. 1251 # os=-sunos4 1252 ;; 1253 m68*-cisco) 1254 os=-aout 1255 ;; 1256 mips*-cisco) 1257 os=-elf 1258 ;; 1259 mips*-*) 1260 os=-elf 1261 ;; 1262 or32-*) 1263 os=-coff 1264 ;; 1265 *-tti) # must be before sparc entry or we get the wrong os. 1266 os=-sysv3 1267 ;; 1268 sparc-* | *-sun) 1269 os=-sunos4.1.1 1270 ;; 1271 *-be) 1272 os=-beos 1273 ;; 1274 *-ibm) 1275 os=-aix 1276 ;; 1277 *-wec) 1278 os=-proelf 1279 ;; 1280 *-winbond) 1281 os=-proelf 1282 ;; 1283 *-oki) 1284 os=-proelf 1285 ;; 1286 *-hp) 1287 os=-hpux 1288 ;; 1289 *-hitachi) 1290 os=-hiux 1291 ;; 1292 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) 1293 os=-sysv 1294 ;; 1295 *-cbm) 1296 os=-amigaos 1297 ;; 1298 *-dg) 1299 os=-dgux 1300 ;; 1301 *-dolphin) 1302 os=-sysv3 1303 ;; 1304 m68k-ccur) 1305 os=-rtu 1306 ;; 1307 m88k-omron*) 1308 os=-luna 1309 ;; 1310 *-next ) 1311 os=-nextstep 1312 ;; 1313 *-sequent) 1314 os=-ptx 1315 ;; 1316 *-crds) 1317 os=-unos 1318 ;; 1319 *-ns) 1320 os=-genix 1321 ;; 1322 i370-*) 1323 os=-mvs 1324 ;; 1325 *-next) 1326 os=-nextstep3 1327 ;; 1328 1328 *-gould) 1329 os=-sysv1330 ;;1329 os=-sysv 1330 ;; 1331 1331 *-highlevel) 1332 os=-bsd1333 ;;1334 *-encore)1335 os=-bsd1336 ;;1332 os=-bsd 1333 ;; 1334 *-encore) 1335 os=-bsd 1336 ;; 1337 1337 *-sgi) 1338 os=-irix1339 ;;1338 os=-irix 1339 ;; 1340 1340 *-siemens) 1341 os=-sysv41342 ;;1343 *-masscomp)1344 os=-rtu1345 ;;1346 f30[01]-fujitsu | f700-fujitsu)1347 os=-uxpv1348 ;;1349 *-rom68k)1350 os=-coff1351 ;;1352 *-*bug)1353 os=-coff1354 ;;1355 *-apple)1356 os=-macos1357 ;;1358 *-atari*)1359 os=-mint1360 ;;1361 *)1362 os=-none1363 ;;1341 os=-sysv4 1342 ;; 1343 *-masscomp) 1344 os=-rtu 1345 ;; 1346 f30[01]-fujitsu | f700-fujitsu) 1347 os=-uxpv 1348 ;; 1349 *-rom68k) 1350 os=-coff 1351 ;; 1352 *-*bug) 1353 os=-coff 1354 ;; 1355 *-apple) 1356 os=-macos 1357 ;; 1358 *-atari*) 1359 os=-mint 1360 ;; 1361 *) 1362 os=-none 1363 ;; 1364 1364 esac 1365 1365 fi … … 1369 1369 vendor=unknown 1370 1370 case $basic_machine in 1371 *-unknown)1372 case $os in1373 -riscix*)1374 vendor=acorn1375 ;;1376 -sunos*)1377 vendor=sun1378 ;;1379 -aix*)1380 vendor=ibm1381 ;;1382 -beos*)1383 vendor=be1384 ;;1385 -hpux*)1386 vendor=hp1387 ;;1388 -mpeix*)1389 vendor=hp1390 ;;1391 -hiux*)1392 vendor=hitachi1393 ;;1394 -unos*)1395 vendor=crds1396 ;;1397 -dgux*)1398 vendor=dg1399 ;;1400 -luna*)1401 vendor=omron1402 ;;1403 -genix*)1404 vendor=ns1405 ;;1406 -mvs* | -opened*)1407 vendor=ibm1408 ;;1409 -ptx*)1410 vendor=sequent1411 ;;1412 -vxsim* | -vxworks*)1413 vendor=wrs1414 ;;1415 -aux*)1416 vendor=apple1417 ;;1418 -hms*)1419 vendor=hitachi1420 ;;1421 -mpw* | -macos*)1422 vendor=apple1423 ;;1424 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)1425 vendor=atari1426 ;;1427 -vos*)1428 vendor=stratus1429 ;;1430 esac1431 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`1432 ;;1371 *-unknown) 1372 case $os in 1373 -riscix*) 1374 vendor=acorn 1375 ;; 1376 -sunos*) 1377 vendor=sun 1378 ;; 1379 -aix*) 1380 vendor=ibm 1381 ;; 1382 -beos*) 1383 vendor=be 1384 ;; 1385 -hpux*) 1386 vendor=hp 1387 ;; 1388 -mpeix*) 1389 vendor=hp 1390 ;; 1391 -hiux*) 1392 vendor=hitachi 1393 ;; 1394 -unos*) 1395 vendor=crds 1396 ;; 1397 -dgux*) 1398 vendor=dg 1399 ;; 1400 -luna*) 1401 vendor=omron 1402 ;; 1403 -genix*) 1404 vendor=ns 1405 ;; 1406 -mvs* | -opened*) 1407 vendor=ibm 1408 ;; 1409 -ptx*) 1410 vendor=sequent 1411 ;; 1412 -vxsim* | -vxworks*) 1413 vendor=wrs 1414 ;; 1415 -aux*) 1416 vendor=apple 1417 ;; 1418 -hms*) 1419 vendor=hitachi 1420 ;; 1421 -mpw* | -macos*) 1422 vendor=apple 1423 ;; 1424 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1425 vendor=atari 1426 ;; 1427 -vos*) 1428 vendor=stratus 1429 ;; 1430 esac 1431 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` 1432 ;; 1433 1433 esac 1434 1434 -
trunk/ithildin/autoconf/configure.ac
r539 r578 38 38 case `$CC -V 2>&1` in 39 39 *Intel*) 40 AC_MSG_RESULT([yes])41 ICC=yes40 AC_MSG_RESULT([yes]) 41 ICC=yes 42 42 ;; 43 43 *) 44 AC_MSG_RESULT([no])44 AC_MSG_RESULT([no]) 45 45 ;; 46 46 esac … … 88 88 else 89 89 if test "$ac_cv_sizeof_int" = "2" ; then 90 AC_CHECK_TYPE(int16_t, int)91 AC_CHECK_TYPE(uint16_t, unsigned int)92 else 93 AC_MSG_ERROR([I can't seem to find a 2 byte integer on your system!])90 AC_CHECK_TYPE(int16_t, int) 91 AC_CHECK_TYPE(uint16_t, unsigned int) 92 else 93 AC_MSG_ERROR([I can't seem to find a 2 byte integer on your system!]) 94 94 fi 95 95 fi … … 99 99 else 100 100 if test "$ac_cv_sizeof_long" = "4" ; then 101 AC_CHECK_TYPE(int32_t, long)102 AC_CHECK_TYPE(uint32_t, unsigned long)103 else 104 AC_MSG_ERROR([I can't seem to find a 4 byte integer on your system!])101 AC_CHECK_TYPE(int32_t, long) 102 AC_CHECK_TYPE(uint32_t, unsigned long) 103 else 104 AC_MSG_ERROR([I can't seem to find a 4 byte integer on your system!]) 105 105 fi 106 106 fi … … 110 110 else 111 111 if test "$ac_cv_sizeof_long" = "8" ; then 112 AC_CHECK_TYPE(int64_t, long long)113 AC_CHECK_TYPE(uint64_t, unsigned long)114 else 115 AC_MSG_ERROR([I can't seem to find an 8 byte integer on your system!])112 AC_CHECK_TYPE(int64_t, long long) 113 AC_CHECK_TYPE(uint64_t, unsigned long) 114 else 115 AC_MSG_ERROR([I can't seem to find an 8 byte integer on your system!]) 116 116 fi 117 117 fi … … 178 178 179 179 if (fp != NULL) { 180 fprintf(fp, "%d\n", getpagesize());181 fclose(fp);180 fprintf(fp, "%d\n", getpagesize()); 181 fclose(fp); 182 182 } else 183 exit(1);183 exit(1); 184 184 exit(0); 185 185 }],[ … … 192 192 else 193 193 if test "$ac_cv_sizeof_int" = "4" ; then 194 pagesize=4096195 else 196 pagesize=8192194 pagesize=4096 195 else 196 pagesize=8192 197 197 fi 198 198 AC_MSG_RESULT([$pagesize (guessing)]) … … 218 218 malloc(42); 219 219 if (okay) 220 exit(0);220 exit(0); 221 221 exit(1); 222 222 }],[malloc_override="yes"]) … … 252 252 CFLAGSDLL="${CFLAGSDLL} -fPIC -DPIC -shared" 253 253 else if test -n "$ICC" ; then 254 CFLAGSDLL="${CFLAGSDLL} -KPIC -DPIC -shared"254 CFLAGSDLL="${CFLAGSDLL} -KPIC -DPIC -shared" 255 255 fi 256 256 fi … … 281 281 AC_ARG_WITH(poller, 282 282 AC_HELP_STRING([--with-poller=x], 283 [set the poller to x (one of select, poll, kqueue, devpoll)]),283 [set the poller to x (one of select, poll, kqueue, devpoll)]), 284 284 POLLER="$with_poller" 285 285 ithildin_cv_poller="$POLLER" … … 291 291 if test "x$POLLER" = "x" ; then 292 292 case "$host_os" in 293 freebsd*|netbsd*|openbsd*)294 if test "$ac_cv_func_kqueue" = "yes" ; then295 POLLER=kqueue296 fi297 ;;298 solaris*|sunos*|linux*)299 if test -e /dev/poll ; then300 POLLER=/dev/poll301 fi302 ;;293 freebsd*|netbsd*|openbsd*) 294 if test "$ac_cv_func_kqueue" = "yes" ; then 295 POLLER=kqueue 296 fi 297 ;; 298 solaris*|sunos*|linux*) 299 if test -e /dev/poll ; then 300 POLLER=/dev/poll 301 fi 302 ;; 303 303 esac 304 304 305 305 if test -z "$POLLER" ; then 306 if test "$ac_cv_func_select" = "yes" ; then307 POLLER=select308 else309 if test "$ac_cv_func_poll" = "yes" ; then310 POLLER=poll311 else312 AC_MSG_ERROR(313 [your system doesn't seem to have select or poll, or any other314 method by which to check socket activity. this daemon will not315 function, sorry.])316 fi317 fi306 if test "$ac_cv_func_select" = "yes" ; then 307 POLLER=select 308 else 309 if test "$ac_cv_func_poll" = "yes" ; then 310 POLLER=poll 311 else 312 AC_MSG_ERROR( 313 [your system doesn't seem to have select or poll, or any other 314 method by which to check socket activity. this daemon will not 315 function, sorry.]) 316 fi 317 fi 318 318 fi 319 319 fi … … 324 324 case "$POLLER" in 325 325 select) 326 AC_DEFINE(POLLER_SELECT, 1, [The select() system call])326 AC_DEFINE(POLLER_SELECT, 1, [The select() system call]) 327 327 ;; 328 328 poll) 329 AC_DEFINE(POLLER_POLL, 1, [The poll() system call])329 AC_DEFINE(POLLER_POLL, 1, [The poll() system call]) 330 330 ;; 331 331 kqueue) 332 AC_DEFINE(POLLER_KQUEUE, 1, [The kqueue() system call])332 AC_DEFINE(POLLER_KQUEUE, 1, [The kqueue() system call]) 333 333 ;; 334 334 devpoll) 335 AC_DEFINE(POLLER_DEVPOLL, 1, [The /dev/poll device])335 AC_DEFINE(POLLER_DEVPOLL, 1, [The /dev/poll device]) 336 336 ;; 337 337 *) 338 AC_MSG_ERROR([The poller "$POLLER" is not supported by this system,338 AC_MSG_ERROR([The poller "$POLLER" is not supported by this system, 339 339 try again?]) 340 340 ;; … … 347 347 ith_feature_append () { 348 348 if test -z "$extra_features" ; then 349 extra_features="$*"350 else 351 extra_features="${extra_features}, $*"349 extra_features="$*" 350 else 351 extra_features="${extra_features}, $*" 352 352 fi 353 353 } … … 364 364 AC_ARG_WITH(ipv6, 365 365 AC_HELP_STRING([--with-ipv6], 366 [enable IPv6 support]),366 [enable IPv6 support]), 367 367 [if test -z "$withval" ; then 368 with_ipv6="yes"368 with_ipv6="yes" 369 369 fi] 370 370 ) … … 373 373 AC_MSG_CHECKING([whether to support IPv6]) 374 374 if test "$ac_cv_func_getaddrinfo" = "no" ; then 375 AC_MSG_RESULT([no])376 else 377 AC_DEFINE(INET6, 1, [IPv6 network protocol support])378 AC_MSG_RESULT([yes])379 ith_feature_append IPv6 support375 AC_MSG_RESULT([no]) 376 else 377 AC_DEFINE(INET6, 1, [IPv6 network protocol support]) 378 AC_MSG_RESULT([yes]) 379 ith_feature_append IPv6 support 380 380 fi 381 381 else … … 388 388 AC_ARG_WITH(openssl, 389 389 AC_HELP_STRING([--with-openssl=PATH], 390 [use the OpenSSL library (PATH is OpenSSL's install prefix)]),390 [use the OpenSSL library (PATH is OpenSSL's install prefix)]), 391 391 [if test -z "$withval" ; then 392 with_openssl="yes"392 with_openssl="yes" 393 393 fi] 394 394 ) … … 396 396 if test "x$with_openssl" != "xno" ; then 397 397 if test "x$with_openssl" = "xyes" -o -z "$with_openssl" ; then 398 AC_MSG_CHECKING([for an OpenSSL installation])399 else 400 openssl_dirs="$with_openssl"401 AC_MSG_CHECKING([for an OpenSSL installation in $with_openssl])398 AC_MSG_CHECKING([for an OpenSSL installation]) 399 else 400 openssl_dirs="$with_openssl" 401 AC_MSG_CHECKING([for an OpenSSL installation in $with_openssl]) 402 402 fi 403 403 … … 406 406 LIBS="$LIBS -lssl -lcrypto" 407 407 AC_TRY_LINK([#include <openssl/ssl.h>],[SSL_accept(NULL);], 408 have_openssl="yes")408 have_openssl="yes") 409 409 410 410 if test -z "$have_openssl" ; then 411 for dir in "$openssl_dirs" /usr/local /usr/ssl /usr/openssl \412 /usr/local/ssl /usr/local/openssl ; do413 if test -n "$have_openssl" -o -z "$dir"; then414 break;415 fi416 417 if test -f "$dir/include/openssl/ssl.h" -a -f \418 "$ssldir/lib/libssl.a" ; then419 CFLAGS="$CFLAGS -I$dir/include"420 LIBS="$old_LIBS -L$dir/lib -lssl -lcrypto"421 AC_TRY_LINK([#include <openssl/ssl.h>],[SSL_accept(NULL);],422 have_openssl="yes")423 fi424 done411 for dir in "$openssl_dirs" /usr/local /usr/ssl /usr/openssl \ 412 /usr/local/ssl /usr/local/openssl ; do 413 if test -n "$have_openssl" -o -z "$dir"; then 414 break; 415 fi 416 417 if test -f "$dir/include/openssl/ssl.h" -a -f \ 418 "$ssldir/lib/libssl.a" ; then 419 CFLAGS="$CFLAGS -I$dir/include" 420 LIBS="$old_LIBS -L$dir/lib -lssl -lcrypto" 421 AC_TRY_LINK([#include <openssl/ssl.h>],[SSL_accept(NULL);], 422 have_openssl="yes") 423 fi 424 done 425 425 fi 426 426 427 427 if test -n "$have_openssl" ; then 428 AC_DEFINE(HAVE_OPENSSL, 1, [OpenSSL Library Support])429 AC_MSG_RESULT(found)430 ith_feature_append SSL support431 else 432 CLFAGS="$old_CFLAGS"433 LIBS="$old_LIBS"434 AC_MSG_RESULT(not found)428 AC_DEFINE(HAVE_OPENSSL, 1, [OpenSSL Library Support]) 429 AC_MSG_RESULT(found) 430 ith_feature_append SSL support 431 else 432 CLFAGS="$old_CFLAGS" 433 LIBS="$old_LIBS" 434 AC_MSG_RESULT(not found) 435 435 fi 436 436 fi … … 442 442 AC_ARG_WITH(modules, 443 443 AC_HELP_STRING([--with-modules="list"], 444 [list of modules to build and install (defaults to * in modules/)]),444 [list of modules to build and install (defaults to * in modules/)]), 445 445 if test -n "$withval " ; then 446 if test "$withval" != "yes" -a "$withval" != "no" ; then447 MODULES="$withval"448 fi446 if test "$withval" != "yes" -a "$withval" != "no" ; then 447 MODULES="$withval" 448 fi 449 449 fi 450 450 ) … … 452 452 AC_ARG_WITH(dmalloc, 453 453 AC_HELP_STRING([--with-dmalloc=PATH], 454 [use the debug malloc library (PATH is dmalloc's install prefix)]),454 [use the debug malloc library (PATH is dmalloc's install prefix)]), 455 455 if test "x$withval" != "no" ; then 456 if test -z "$withval" -o "x$withval" = "xyes" ; then457 dmallocdir="/usr/local"458 else459 dmallocdir="$withval"460 fi461 LDFLAGS="$LDFLAGS -L$dmallocdir/lib"462 CFLAGS="$CFLAGS -I$dmallocdir/include"463 AC_CHECK_LIB(dmalloc, dmalloc_verify,,464 AC_MSG_ERROR([I cannot find the dmalloc library on your system]))465 AC_DEFINE(USE_DMALLOC, 1, [dmalloc library support])456 if test -z "$withval" -o "x$withval" = "xyes" ; then 457 dmallocdir="/usr/local" 458 else 459 dmallocdir="$withval" 460 fi 461 LDFLAGS="$LDFLAGS -L$dmallocdir/lib" 462 CFLAGS="$CFLAGS -I$dmallocdir/include" 463 AC_CHECK_LIB(dmalloc, dmalloc_verify,, 464 AC_MSG_ERROR([I cannot find the dmalloc library on your system])) 465 AC_DEFINE(USE_DMALLOC, 1, [dmalloc library support]) 466 466 fi 467 467 ) 468 468 AC_ARG_ENABLE(debug, 469 469 AC_HELP_STRING([--enable-debug], 470 [enable debugging in code (changes CFLAGS, adds code)]),470 [enable debugging in code (changes CFLAGS, adds code)]), 471 471 if test -n "$GCC" ; then 472 CFLAGS="$CFLAGS -O0 -g3 -Wall -Wshadow -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Winline"472 CFLAGS="$CFLAGS -O0 -g3 -Wall -Wshadow -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Winline" 473 473 fi 474 474 AC_DEFINE(DEBUG_CODE, 1, [Extra debugging instructions]) … … 476 476 AC_ARG_ENABLE(custom-libc, 477 477 AC_HELP_STRING([--disable-custom-libc], 478 [disable custom libc functions (slower!)]),478 [disable custom libc functions (slower!)]), 479 479 AC_DEFINE(NO_INTERNAL_LIBC, 1, [No internal libc functions]), 480 480 ith_feature_append internal libc functions … … 482 482 AC_ARG_ENABLE(fd-setsize, 483 483 AC_HELP_STRING([--enable-fd-setsize], 484 [set FD_SETSIZE to the specified value (useful only if your system is484 [set FD_SETSIZE to the specified value (useful only if your system is 485 485 using select() and you you want more file descriptors to work)]), 486 486 AC_DEFINE_UNQUOTED(FD_SETSIZE, $enable_fd_setsize, 487 [the size of FD_SETSIZE]),487 [the size of FD_SETSIZE]), 488 488 ) 489 489 … … 491 491 AC_ARG_ENABLE(dir-suffix, 492 492 AC_HELP_STRING([--disable-dir-suffix], 493 [keep 'make install' from appending the package name to target493 [keep 'make install' from appending the package name to target 494 494 installation directories]), 495 495 DIRSUFFIX="" -
trunk/ithildin/autoconf/install-sh
r490 r578 45 45 while [ x"$1" != x ]; do 46 46 case $1 in 47 -c) instcmd="$cpprog"48 shift49 continue;;50 51 -d) dir_arg=true52 shift53 continue;;54 55 -m) chmodcmd="$chmodprog $2"56 shift57 shift58 continue;;59 60 -o) chowncmd="$chownprog $2"61 shift62 shift63 continue;;64 65 -g) chgrpcmd="$chgrpprog $2"66 shift67 shift68 continue;;69 70 -s) stripcmd="$stripprog"71 shift72 continue;;73 74 -t=*) transformarg=`echo $1 | sed 's/-t=//'`75 shift76 continue;;77 78 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`79 shift80 continue;;81 82 *) if [ x"$src" = x ]83 then84 src=$185 else86 # this colon is to work around a 386BSD /bin/sh bug87 :88 dst=$189 fi90 shift91 continue;;47 -c) instcmd="$cpprog" 48 shift 49 continue;; 50 51 -d) dir_arg=true 52 shift 53 continue;; 54 55 -m) chmodcmd="$chmodprog $2" 56 shift 57 shift 58 continue;; 59 60 -o) chowncmd="$chownprog $2" 61 shift 62 shift 63 continue;; 64 65 -g) chgrpcmd="$chgrpprog $2" 66 shift 67 shift 68 continue;; 69 70 -s) stripcmd="$stripprog" 71 shift 72 continue;; 73 74 -t=*) transformarg=`echo $1 | sed 's/-t=//'` 75 shift 76 continue;; 77 78 -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 79 shift 80 continue;; 81 82 *) if [ x"$src" = x ] 83 then 84 src=$1 85 else 86 # this colon is to work around a 386BSD /bin/sh bug 87 : 88 dst=$1 89 fi 90 shift 91 continue;; 92 92 esac 93 93 done … … 95 95 if [ x"$src" = x ] 96 96 then 97 echo "install:no input file specified"98 exit 197 echo "install: no input file specified" 98 exit 1 99 99 else 100 true100 true 101 101 fi 102 102 103 103 if [ x"$dir_arg" != x ]; then 104 dst=$src105 src=""106 107 if [ -d $dst ]; then108 instcmd=:109 else110 instcmd=mkdir111 fi104 dst=$src 105 src="" 106 107 if [ -d $dst ]; then 108 instcmd=: 109 else 110 instcmd=mkdir 111 fi 112 112 else 113 113 … … 116 116 # if $src (and thus $dsttmp) contains '*'. 117 117 118 if [ -f $src -o -d $src ]119 then120 true121 else122 echo "install: $src does not exist"123 exit 1124 fi125 126 if [ x"$dst" = x ]127 then128 echo "install:no destination specified"129 exit 1130 else131 true132 fi118 if [ -f $src -o -d $src ] 119 then 120 true 121 else 122 echo "install: $src does not exist" 123 exit 1 124 fi 125 126 if [ x"$dst" = x ] 127 then 128 echo "install: no destination specified" 129 exit 1 130 else 131 true 132 fi 133 133 134 134 # If destination is a directory, append the input filename; if your system 135 135 # does not like double slashes in filenames, you may need to add some logic 136 136 137 if [ -d $dst ]138 then139 dst="$dst"/`basename $src`140 else141 true142 fi137 if [ -d $dst ] 138 then 139 dst="$dst"/`basename $src` 140 else 141 true 142 fi 143 143 fi 144 144 … … 151 151 # Skip lots of stat calls in the usual case. 152 152 if [ ! -d "$dstdir" ]; then 153 defaultIFS=' 153 defaultIFS=' 154 154 ' 155 155 IFS="${IFS-${defaultIFS}}" … … 164 164 165 165 while [ $# -ne 0 ] ; do 166 pathcomp="${pathcomp}${1}"167 shift168 169 if [ ! -d "${pathcomp}" ] ;170 then 171 $mkdirprog "${pathcomp}"172 else173 true174 fi175 176 pathcomp="${pathcomp}/"166 pathcomp="${pathcomp}${1}" 167 shift 168 169 if [ ! -d "${pathcomp}" ] ; 170 then 171 $mkdirprog "${pathcomp}" 172 else 173 true 174 fi 175 176 pathcomp="${pathcomp}/" 177 177 done 178 178 fi … … 180 180 if [ x"$dir_arg" != x ] 181 181 then 182 $doit $instcmd $dst &&183 184 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&185 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&186 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&187 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi182 $doit $instcmd $dst && 183 184 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 185 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 186 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 187 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 188 188 else 189 189 190 190 # If we're going to rename the final executable, determine the name now. 191 191 192 if [ x"$transformarg" = x ]193 then194 dstfile=`basename $dst`195 else196 dstfile=`basename $dst $transformbasename |197 sed $transformarg`$transformbasename198 fi192 if [ x"$transformarg" = x ] 193 then 194 dstfile=`basename $dst` 195 else 196 dstfile=`basename $dst $transformbasename | 197 sed $transformarg`$transformbasename 198 fi 199 199 200 200 # don't allow the sed command to completely eliminate the filename 201 201 202 if [ x"$dstfile" = x ]203 then204 dstfile=`basename $dst`205 else206 true207 fi202 if [ x"$dstfile" = x ] 203 then 204 dstfile=`basename $dst` 205 else 206 true 207 fi 208 208 209 209 # Make a temp file name in the proper directory. 210 210 211 dsttmp=$dstdir/#inst.$$#211 dsttmp=$dstdir/#inst.$$# 212 212 213 213 # Move or copy the file name to the temp name 214 214 215 $doit $instcmd $src $dsttmp &&216 217 trap "rm -f ${dsttmp}" 0 &&215 $doit $instcmd $src $dsttmp && 216 217 trap "rm -f ${dsttmp}" 0 && 218 218 219 219 # and set any options; do chmod last to preserve setuid bits … … 223 223 # errors from the above "$doit $instcmd $src $dsttmp" command. 224 224 225 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&226 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&227 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&228 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&225 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 226 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 227 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 228 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 229 229 230 230 # Now rename the file to the real destination. 231 231 232 $doit $rmcmd -f $dstdir/$dstfile &&233 $doit $mvcmd $dsttmp $dstdir/$dstfile232 $doit $rmcmd -f $dstdir/$dstfile && 233 $doit $mvcmd $dsttmp $dstdir/$dstfile 234 234 235 235 fi && -
trunk/ithildin/doc/conf/ithildin.conf
r490 r578 45 45 46 46 module log { // define a module's information 47 file "log.so"; // this is our module48 load "yes"; // load at boot-time (yes/no)47 file "log.so"; // this is our module 48 load "yes"; // load at boot-time (yes/no) 49 49 }; 50 50 51 51 module dns { 52 file "dns.so"; // non-blocking dns module53 load "no"; // will be loaded if necessary.54 data {55 $INCLUDE "dns.conf";56 };52 file "dns.so"; // non-blocking dns module 53 load "no"; // will be loaded if necessary. 54 data { 55 $INCLUDE "dns.conf"; 56 }; 57 57 }; 58 58 module ircd { 59 file "ircd.so";60 load "yes";61 export "yes"; // force symbol export.62 data {63 $INCLUDE "ircd/ircd.conf";64 };59 file "ircd.so"; 60 load "yes"; 61 export "yes"; // force symbol export. 62 data { 63 $INCLUDE "ircd/ircd.conf"; 64 }; 65 65 }; 66 66 -
trunk/ithildin/doc/conf/proxyscan.conf
r490 r578 6 6 ** 7 7 */ 8 bind "0.0.0.0";// address to bind to (default is inaddr_any)9 timeout 20;// time in seconds to wait for sockets to time-out10 expire 3600;// time in seconds to keep cached scan results11 cache 32768;// number of cache results to keep at most.12 data "/path/to/save/data"; // file in which saved statistical data lives8 bind "0.0.0.0"; // address to bind to (default is inaddr_any) 9 timeout 20; // time in seconds to wait for sockets to time-out 10 expire 3600; // time in seconds to keep cached scan results 11 cache 32768; // number of cache results to keep at most. 12 data "/path/to/save/data"; // file in which saved statistical data lives 13 13 14 14 /* … … 48 48 49 49 skip { 50 0.0.0.0/32; // inaddr_any50 0.0.0.0/32; // inaddr_any 51 51 127.0.0.0/8; // localhost 52 10.0.0.0/8; // internal networks52 10.0.0.0/8; // internal networks 53 53 172.16.0.0/12; 54 54 192.168.0.0/16; -
trunk/ithildin/doc/style.txt
r495 r578 85 85 * aligned whenever possible. */ 86 86 struct foo { 87 int bar;/* brief description of variable */88 struct baz abaz; /* a baz structure */89 longtypename avar; /* another variable.87 int bar; /* brief description of variable */ 88 struct baz abaz; /* a baz structure */ 89 longtypename avar; /* another variable. 90 90 91 91 LIST_ENTRY(foo) lp; /* a list entry. lists should be rolled with the 92 macros in queue.h unless there is a pressing reason93 not to do so. */92 macros in queue.h unless there is a pressing reason 93 not to do so. */ 94 94 }; 95 95 -
trunk/ithildin/include/ithildin/conf.h
r576 r578 30 30 * sub-tree, or an actual single entry of data which is terminating. */ 31 31 struct conf_entry { 32 char *name; /* the name of the entry */32 char *name; /* the name of the entry */ 33 33 char *string; /* string (if this is a single data entry) */ 34 34 conf_list_t *list; /* list of stuff (if this is a list entry) string 35 may also be filled out if this list has a36 name */35 may also be filled out if this list has a 36 name */ 37 37 conf_list_t *parent;/* parent of this entry, this should never be 38 null! */38 null! */ 39 39 40 40 #define CONF_TYPE_LIST 0x1 41 41 #define CONF_TYPE_DATA 0x2 42 int type;42 int type; 43 43 44 44 LIST_ENTRY(conf_entry) lp; 45 45 46 }; 46 }; 47 47 48 48 /* general conf handling calls */ … … 54 54 conf_entry_t *conf_find(const char *, const char *, int, conf_list_t *, int); 55 55 conf_entry_t *conf_find_next(const char *, const char *, int, conf_entry_t *, 56 conf_list_t *, int);56 conf_list_t *, int); 57 57 conf_list_t *conf_find_list(const char *, conf_list_t *, int); 58 58 conf_list_t *conf_find_list_next(const char *, conf_list_t *, conf_list_t *, 59 int);59 int); 60 60 char *conf_find_entry(const char *, conf_list_t *, int); 61 61 char *conf_find_entry_next(const char *, char *, conf_list_t *, int); -
trunk/ithildin/include/ithildin/event.h
r576 r578 16 16 /* The event structure. Intentionally pretty small. */ 17 17 struct event { 18 int numhooks;/* the number of hooks in the event */19 int flags;20 #define EVENT_FL_ONEHOOK 0x1 /* allow only one hook at a time */21 #define EVENT_FL_NORETURN 0x2/* return values from hooks are22 ignored */23 #define EVENT_FL_HOOKONCE 0x4/* automatically pop each hook off the24 stack when it is called */25 #define EVENT_FL_CONDITIONAL 0x8/* do short-circuit conditional26 handling using the values below. */27 #define EVENT_FL_CALLING 0x10/* set if we are in the process of28 calling this event's hooks.29 this defers removal until we are30 done with the list. */31 SLIST_HEAD(, hook) hooks; /* the hooks */18 int numhooks; /* the number of hooks in the event */ 19 int flags; 20 #define EVENT_FL_ONEHOOK 0x1 /* allow only one hook at a time */ 21 #define EVENT_FL_NORETURN 0x2 /* return values from hooks are 22 ignored */ 23 #define EVENT_FL_HOOKONCE 0x4 /* automatically pop each hook off the 24 stack when it is called */ 25 #define EVENT_FL_CONDITIONAL 0x8 /* do short-circuit conditional 26 handling using the values below. */ 27 #define EVENT_FL_CALLING 0x10 /* set if we are in the process of 28 calling this event's hooks. 29 this defers removal until we are 30 done with the list. */ 31 SLIST_HEAD(, hook) hooks; /* the hooks */ 32 32 }; 33 33 … … 59 59 * indicate some measure of success or failure. The above values *SHOULD NOT* 60 60 * be used as returns in individual hooks! */ 61 #define HOOK_COND_ALWAYSOK -4 /* short-circuit truth condition */62 #define HOOK_COND_OK -3/* truth condition */63 #define HOOK_COND_NEVEROK -2 /* short-circuit failure condition */64 #define HOOK_COND_NOTOK -2/* failure condition */65 #define HOOK_COND_NEUTRAL 0 /* neutral (ignored) condition */61 #define HOOK_COND_ALWAYSOK -4 /* short-circuit truth condition */ 62 #define HOOK_COND_OK -3 /* truth condition */ 63 #define HOOK_COND_NEVEROK -2 /* short-circuit failure condition */ 64 #define HOOK_COND_NOTOK -2 /* failure condition */ 65 #define HOOK_COND_NEUTRAL 0 /* neutral (ignored) condition */ 66 66 67 67 /* the simple hook structure. holds a 'hook_function' and a list pointer … … 70 70 hook_function_t function; 71 71 int flags; 72 #define HOOK_FL_DEFERRED 0x1/* 'deferred' for deletion. set when a73 hook would be deleted but its owner74 event is being walked */75 #define HOOK_FL_NEW 0x2/* set when a new hook is inserted into76 an event being called. this hook77 will not be called on the first pass78 through. */72 #define HOOK_FL_DEFERRED 0x1 /* 'deferred' for deletion. set when a 73 hook would be deleted but its owner 74 event is being walked */ 75 #define HOOK_FL_NEW 0x2 /* set when a new hook is inserted into 76 an event being called. this hook 77 will not be called on the first pass 78 through. */ 79 79 80 80 SLIST_ENTRY(hook) lp; -
trunk/ithildin/include/ithildin/global.h
r576 r578 22 22 extern struct me_t { 23 23 char conf_path[PATH_MAX];/* path where data (conf files, 24 motd, etc) live */24 motd, etc) live */ 25 25 char conf_file[PATH_MAX];/* explicit name of conf file */ 26 26 char lib_path[PATH_MAX]; 27 27 char data_path[PATH_MAX]; 28 29 char version[128]; /* a pre-allocated version string */30 int revision;/* revision number in the scm repo. */31 char *execname; /* the name of the executable (path data is32 stripped out) */28 29 char version[128]; /* a pre-allocated version string */ 30 int revision; /* revision number in the scm repo. */ 31 char *execname; /* the name of the executable (path data is 32 stripped out) */ 33 33 34 time_t started; /* time of creation for the daemon */35 time_t now; /* the time now */34 time_t started; /* time of creation for the daemon */ 35 time_t now; /* the time now */ 36 36 37 int debug; /* are we in debugmode (logging extra38 data, etc) */39 bool fork; /* are we going to/have we forked */40 bool shutdown; /* are we going to shutdown? */41 bool reloads; /* do we have reloads pending? */42 bool have_ssl; /* is ssl available (compiled in) and43 configured? */37 int debug; /* are we in debugmode (logging extra 38 data, etc) */ 39 bool fork; /* are we going to/have we forked */ 40 bool shutdown; /* are we going to shutdown? */ 41 bool reloads; /* do we have reloads pending? */ 42 bool have_ssl; /* is ssl available (compiled in) and 43 configured? */ 44 44 45 45 #ifdef HAVE_OPENSSL 46 46 /* various ssl configuration items. */ 47 47 struct { 48 bool enabled;/* set if SSL support is enabled. */48 bool enabled; /* set if SSL support is enabled. */ 49 49 50 char certfile[PATH_MAX];/* certificate file */51 char keyfile[PATH_MAX];/* key file */52 char cafile[PATH_MAX];/* certificate authority file */53 /* This is the default SSL context object. It contains liberal (in54 * terms of security) settings. Callers which wish for more55 * restrictive settings should use their own SSL_CTX objects instead.56 * This object is suitable for making outbound SSL connections, and57 * also for accepting connections where key verification will not be58 * important. */59 struct ssl_ctx_st *ctx;60 bool verify;/* set if we want to verify certificates61 (the default) */62 time_t hs_timeout;/* the timeout for SSL handshakes. */50 char certfile[PATH_MAX];/* certificate file */ 51 char keyfile[PATH_MAX]; /* key file */ 52 char cafile[PATH_MAX]; /* certificate authority file */ 53 /* This is the default SSL context object. It contains liberal (in 54 * terms of security) settings. Callers which wish for more 55 * restrictive settings should use their own SSL_CTX objects instead. 56 * This object is suitable for making outbound SSL connections, and 57 * also for accepting connections where key verification will not be 58 * important. */ 59 struct ssl_ctx_st *ctx; 60 bool verify; /* set if we want to verify certificates 61 (the default) */ 62 time_t hs_timeout; /* the timeout for SSL handshakes. */ 63 63 } ssl; 64 64 #endif 65 65 66 conf_list_t *confhead; /* head of configuration data */66 conf_list_t *confhead; /* head of configuration data */ 67 67 68 68 LIST_HEAD(, module) modules; … … 71 71 /* static events */ 72 72 struct { 73 event_t *log_debug;/* hooked for debug messages */74 event_t *log_notice;/* notices */75 event_t *log_warn;/* warnings */76 event_t *log_error;/* errors */77 event_t *log_unknown;/* and any other type */73 event_t *log_debug; /* hooked for debug messages */ 74 event_t *log_notice; /* notices */ 75 event_t *log_warn; /* warnings */ 76 event_t *log_error; /* errors */ 77 event_t *log_unknown; /* and any other type */ 78 78 79 event_t *read_conf;/* hooked when the conf is read */79 event_t *read_conf; /* hooked when the conf is read */ 80 80 81 event_t *load_module;/* hooked when a module is laoded */82 event_t *unload_module;/* ... or unloaded */81 event_t *load_module; /* hooked when a module is laoded */ 82 event_t *unload_module; /* ... or unloaded */ 83 83 84 event_t *afterpoll;/* called after each polling run */84 event_t *afterpoll; /* called after each polling run */ 85 85 86 event_t *shutdown;/* called just prior to shutdown */86 event_t *shutdown; /* called just prior to shutdown */ 87 87 88 event_t *sighup;/* called for SIGHUP .. */89 event_t *sigint;/* ... SIGINT */90 event_t *sigterm;/* ... SIGTERM */91 event_t *sigusr1;/* ... SIGUSR1 */92 event_t *sigusr2;/* ... SIGUSR2 */88 event_t *sighup; /* called for SIGHUP .. */ 89 event_t *sigint; /* ... SIGINT */ 90 event_t *sigterm; /* ... SIGTERM */ 91 event_t *sigusr1; /* ... SIGUSR1 */ 92 event_t *sigusr2; /* ... SIGUSR2 */ 93 93 } events; 94 94 } me; -
trunk/ithildin/include/ithildin/hash.h
r576 r578 16 16 struct hashent { 17 17 void *ent; 18 unsigned int hv; /* full hash value (i.e. no modulus). makes for19 quick compares. */18 unsigned int hv; /* full hash value (i.e. no modulus). makes for 19 quick compares. */ 20 20 SLIST_ENTRY(hashent) lp; 21 21 }; 22 22 23 23 struct hashtable { 24 int size;/* thte size of the hash table */24 int size; /* thte size of the hash table */ 25 25 #define hashtable_size(x) ((x)->size) 26 int entries;/* number of entries in the hash table */26 int entries; /* number of entries in the hash table */ 27 27 #define hashtable_count(x) ((x)->entries) 28 struct hashbucket *table; /* our table */29 size_t keyoffset; /* this stores the offset of the key from the30 given structure */31 size_t keylen; /* the length of the key. this CANNOT be 0. If32 you want to use variable length strings use the33 flag below. */28 struct hashbucket *table; /* our table */ 29 size_t keyoffset; /* this stores the offset of the key from the 30 given structure */ 31 size_t keylen; /* the length of the key. this CANNOT be 0. If 32 you want to use variable length strings use the 33 flag below. */ 34 34 35 35 /* these are useful for debugging the state of the hash system */ 36 36 #ifdef DEBUG_CODE 37 int max_per_bucket; /* most entries in a single bucket */38 int empty_buckets; /* number of empty buckets */37 int max_per_bucket; /* most entries in a single bucket */ 38 int empty_buckets; /* number of empty buckets */ 39 39 #endif 40 #define HASH_FL_NOCASE 0x1 /* ignore case (tolower before hash) */41 #define HASH_FL_STRING 0x2 /* key is a nul-terminated string, treat len42 as a maximum length to hash */43 #define HASH_FL_INSERTHEAD 0x4 /* insert values at the head of their44 respective buckets (default) */45 #define HASH_FL_INSERTTAIL 0x8 /* insert values at the tail of their bucket */46 int flags;40 #define HASH_FL_NOCASE 0x1 /* ignore case (tolower before hash) */ 41 #define HASH_FL_STRING 0x2 /* key is a nul-terminated string, treat len 42 as a maximum length to hash */ 43 #define HASH_FL_INSERTHEAD 0x4 /* insert values at the head of their 44 respective buckets (default) */ 45 #define HASH_FL_INSERTTAIL 0x8 /* insert values at the tail of their bucket */ 46 int flags; 47 47 /* the symbol for our comparison function, used in hash_find_ent(). This 48 48 * behaves much like the compare function used in qsort(). This means that -
trunk/ithildin/include/ithildin/log.h
r576 r578 42 42 #if defined(__GNUC__) || __STDC_VERSION__ >= 199901L 43 43 # if defined(DEBUG_CODE) 44 # define log_debug(msg, ...) log_msg(LOGTYPE_DEBUG, LOG_MODULENAME, \45 msg, ## __VA_ARGS__)44 # define log_debug(msg, ...) log_msg(LOGTYPE_DEBUG, LOG_MODULENAME, \ 45 msg, ## __VA_ARGS__) 46 46 # else 47 47 # define log_debug(msg, ...) ((void)0) 48 48 # endif 49 # define log_notice(msg, ...) log_msg(LOGTYPE_NOTICE, LOG_MODULENAME, \50 msg, ## __VA_ARGS__)51 # define log_warn(msg, ...) log_msg(LOGTYPE_WARN, LOG_MODULENAME, msg, \52 ## __VA_ARGS__)49 # define log_notice(msg, ...) log_msg(LOGTYPE_NOTICE, LOG_MODULENAME, \ 50 msg, ## __VA_ARGS__) 51 # define log_warn(msg, ...) log_msg(LOGTYPE_WARN, LOG_MODULENAME, msg, \ 52 ## __VA_ARGS__) 53 53 # define log_error(msg, ...) log_msg(LOGTYPE_ERROR, LOG_MODULENAME, msg,\ 54 ## __VA_ARGS__)54 ## __VA_ARGS__) 55 55 #else 56 56 # define NEED_INDIVIDUAL_LOG_FUNCTIONS -
trunk/ithildin/include/ithildin/malloc.h
r576 r578 11 11 #define MALLOC_H 12 12 13 #if !defined(NO_INTERNAL_LIBC) && !defined(USE_DMALLOC) && \13 #if !defined(NO_INTERNAL_LIBC) && !defined(USE_DMALLOC) && \ 14 14 defined(MALLOC_LOWLEVEL) 15 15 # define USE_INTERNAL_MALLOC -
trunk/ithildin/include/ithildin/md5.h
r576 r578 29 29 /* MD5 context. */ 30 30 typedef struct ith_md5context { 31 uint32_t state[4]; /* state (ABCD) */32 uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */33 unsigned char buffer[64]; /* input buffer */31 uint32_t state[4]; /* state (ABCD) */ 32 uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ 33 unsigned char buffer[64]; /* input buffer */ 34 34 } ith_md5_ctx; 35 35 -
trunk/ithildin/include/ithildin/module.h
r576 r578 15 15 struct module_header { 16 16 struct { 17 char major;18 char minor;19 char patch;20 char pad;17 char major; 18 char minor; 19 char patch; 20 char pad; 21 21 } baseversion; 22 22 23 const char *version;23 const char *version; 24 24 }; 25 25 26 26 SLIST_HEAD(module_savedata_list, module_savedata); 27 27 struct module_savedata { 28 char *name; /* the symbol name */29 size_t size; /* the size of the data */30 char *data; /* and the actual data */28 char *name; /* the symbol name */ 29 size_t size; /* the size of the data */ 30 char *data; /* and the actual data */ 31 31 32 32 SLIST_ENTRY(module_savedata) lp; … … 39 39 40 40 typedef int (*module_load_function)(int, struct module_savedata_list *, 41 conf_list_t **, module_t *);41 conf_list_t **, module_t *); 42 42 typedef void (*module_unload_function)(int, struct module_savedata_list *); 43 43 struct module { 44 44 struct module_header *header; 45 45 46 char *fullpath; /* full path to file's module */47 char *depfile; /* full path to the file's dependency file, or NULL48 if no file exists. */49 char *name; /* name of module */50 void *handle; /* dlopen() handle */46 char *fullpath; /* full path to file's module */ 47 char *depfile; /* full path to the file's dependency file, or NULL 48 if no file exists. */ 49 char *name; /* name of module */ 50 void *handle; /* dlopen() handle */ 51 51 conf_list_t *confdata; 52 52 module_load_function load_function; … … 59 59 LIST_HEAD(, module_dependency) deps; 60 60 61 int flags;61 int flags; 62 62 #define MODULE_FL_LOADED 0x1 63 63 #define MODULE_FL_DEPENDLOAD 0x2 … … 78 78 /* this one sets an internal reload state */ 79 79 #define MODULE_FL_RELOADING 0x1000 80 int opencalls; /* needed to track how many times to call dlclose */80 int opencalls; /* needed to track how many times to call dlclose */ 81 81 82 82 LIST_ENTRY(module) lp; … … 100 100 * reload is occuring, the module may have data it wishes to resurrect that it 101 101 * saved in the unload call. */ 102 #define MODULE_LOADER(x) \103 int x##_loader(int, struct module_savedata_list *, conf_list_t **, \104 module_t *);\105 int x##_loader(int reload, struct module_savedata_list *savelist, \106 conf_list_t **confdata, module_t *module)107 108 #define MODULE_UNLOADER(x) \109 void x##_unloader(int, struct module_savedata_list *); \102 #define MODULE_LOADER(x) \ 103 int x##_loader(int, struct module_savedata_list *, conf_list_t **, \ 104 module_t *); \ 105 int x##_loader(int reload, struct module_savedata_list *savelist, \ 106 conf_list_t **confdata, module_t *module) 107 108 #define MODULE_UNLOADER(x) \ 109 void x##_unloader(int, struct module_savedata_list *); \ 110 110 void x##_unloader(int reload, struct module_savedata_list *savelist) 111 111 … … 134 134 135 135 void add_module_savedata(struct module_savedata_list *, const char *, size_t, 136 const void *);136 const void *); 137 137 size_t get_module_savedata(struct module_savedata_list *, const char *, 138 void *);138 void *); 139 139 140 140 /* msymbol definitions */ 141 141 typedef struct msymbol msymbol_t; 142 142 struct msymbol { 143 char name[32]; /* 31 characters worth of significant name info. if144 this isn't enough it can be changed later.. */145 void *val; /* the value of the symbol */146 module_t *module; /* the module which owns this symbol */143 char name[32]; /* 31 characters worth of significant name info. if 144 this isn't enough it can be changed later.. */ 145 void *val; /* the value of the symbol */ 146 module_t *module; /* the module which owns this symbol */ 147 147 148 148 LIST_ENTRY(msymbol) lp; … … 155 155 ((sym->module != NULL && sym->module->handle == NULL) ? \ 156 156 (log_error("referenced unavailable symbol %s from module %s", sym->name, \ 157 sym->module->name)), (void *)NULL : sym->val)157 sym->module->name)), (void *)NULL : sym->val) 158 158 #else 159 159 # define getsym(sym) (sym->val) … … 164 164 165 165 struct mdext_item { 166 int offset; /* offset into the data */166 int offset; /* offset into the data */ 167 167 size_t size; /* size of the data at the offset */ 168 168 … … 171 171 172 172 struct mdext_header { 173 size_t size; /* size required for mdext */174 event_t *create; /* object creation event */175 event_t *destroy; /* and destruction event */173 size_t size; /* size required for mdext */ 174 event_t *create; /* object creation event */ 175 event_t *destroy; /* and destruction event */ 176 176 SLIST_HEAD(, mdext_item) items; /* items defining this data */ 177 177 -
trunk/ithildin/include/ithildin/queue.h
r490 r578 9 9 10 10 #ifndef QUEUE_H 11 #define QUEUE_H11 #define QUEUE_H 12 12 13 13 /* a shim struct for the *_ALLOC calls. */ … … 17 17 18 18 #undef SLIST_ALLOC 19 #define SLIST_ALLOC(head) do { \20 (head) = malloc(sizeof(SLIST_HEAD(, queue__shim__struct__)));\21 SLIST_INIT((head));\19 #define SLIST_ALLOC(head) do { \ 20 (head) = malloc(sizeof(SLIST_HEAD(, queue__shim__struct__))); \ 21 SLIST_INIT((head)); \ 22 22 } while (0) 23 23 #undef SLIST_FREE 24 #define SLIST_FREE(head) do { \25 free((head));\24 #define SLIST_FREE(head) do { \ 25 free((head)); \ 26 26 } while (0) 27 27 28 28 #undef STAILQ_ALLOC 29 #define STAILQ_ALLOC(head) do { \30 (head) = malloc(sizeof(STAILQ_HEAD(, queue__shim__struct__)));\31 STAILQ_INIT((head));\29 #define STAILQ_ALLOC(head) do { \ 30 (head) = malloc(sizeof(STAILQ_HEAD(, queue__shim__struct__))); \ 31 STAILQ_INIT((head)); \ 32 32 } while (0) 33 33 #undef STAILQ_FREE 34 #define STAILQ_FREE(head) do { \35 free((head));\34 #define STAILQ_FREE(head) do { \ 35 free((head)); \ 36 36 } while (0) 37 37 38 38 #undef LIST_ALLOC 39 #define LIST_ALLOC(head) do { \40 (head) = malloc(sizeof(LIST_HEAD(, queue__shim__struct__)));\41 LIST_INIT((head));\39 #define LIST_ALLOC(head) do { \ 40 (head) = malloc(sizeof(LIST_HEAD(, queue__shim__struct__))); \ 41 LIST_INIT((head)); \ 42 42 } while (0) 43 43 #undef LIST_FREE 44 #define LIST_FREE(head) do { \45 free((head));\44 #define LIST_FREE(head) do { \ 45 free((head)); \ 46 46 } while (0) 47 47 48 48 #undef TAILQ_ALLOC 49 #define TAILQ_ALLOC(head) do { \50 (head) = malloc(sizeof(TAILQ_HEAD(, queue__shim__struct__)));\51 TAILQ_INIT((head));\49 #define TAILQ_ALLOC(head) do { \ 50 (head) = malloc(sizeof(TAILQ_HEAD(, queue__shim__struct__))); \ 51 TAILQ_INIT((head)); \ 52 52 } while (0) 53 53 #undef TAILQ_FREE 54 #define TAILQ_FREE(head) do { \55 free((head));\54 #define TAILQ_FREE(head) do { \ 55 free((head)); \ 56 56 } while (0) 57 57 … … 135 135 /* 136 136 * Copyright (c) 1991, 1993 137 * The Regents of the University of California. All rights reserved.137 * The Regents of the University of California. All rights reserved. 138 138 * 139 139 * Redistribution and use in source and binary forms, with or without … … 161 161 * SUCH DAMAGE. 162 162 * 163 * @(#)queue.h8.5 (Berkeley) 8/20/94163 * @(#)queue.h 8.5 (Berkeley) 8/20/94 164 164 * $FreeBSD: src/sys/sys/queue.h,v 1.54 2002/08/05 05:18:43 alfred Exp $ 165 165 */ … … 207 207 * 208 208 * 209 * SLIST LIST STAILQTAILQ210 * _HEAD + + ++211 * _HEAD_INITIALIZER + + ++212 * _ENTRY + + ++213 * _INIT + + ++214 * _EMPTY + + ++215 * _FIRST + + ++216 * _NEXT + + ++217 * _PREV - - -+218 * _LAST - - ++219 * _FOREACH + + ++220 * _FOREACH_REVERSE - - -+221 * _INSERT_HEAD + + ++222 * _INSERT_BEFORE - + -+223 * _INSERT_AFTER + + ++224 * _INSERT_TAIL - - ++225 * _CONCAT - - ++226 * _REMOVE_HEAD + - +-227 * _REMOVE + + ++209 * SLIST LIST STAILQ TAILQ 210 * _HEAD + + + + 211 * _HEAD_INITIALIZER + + + + 212 * _ENTRY + + + + 213 * _INIT + + + + 214 * _EMPTY + + + + 215 * _FIRST + + + + 216 * _NEXT + + + + 217 * _PREV - - - + 218 * _LAST - - + + 219 * _FOREACH + + + + 220 * _FOREACH_REVERSE - - - + 221 * _INSERT_HEAD + + + + 222 * _INSERT_BEFORE - + - + 223 * _INSERT_AFTER + + + + 224 * _INSERT_TAIL - - + + 225 * _CONCAT - - + + 226 * _REMOVE_HEAD + - + - 227 * _REMOVE + + + + 228 228 * 229 229 */ … … 231 231 /* Store the last 2 places the queue element or head was altered */ 232 232 struct qm_trace { 233 char * lastfile;234 int lastline;235 char * prevfile;236 int prevline;233 char * lastfile; 234 int lastline; 235 char * prevfile; 236 int prevline; 237 237 }; 238 238 239 #define TRACEBUF struct qm_trace trace;240 #define TRASHIT(x) do {(x) = (void *)-1;} while (0)241 242 #define QMD_TRACE_HEAD(head) do { \243 (head)->trace.prevline = (head)->trace.lastline;\244 (head)->trace.prevfile = (head)->trace.lastfile;\245 (head)->trace.lastline = __LINE__;\246 (head)->trace.lastfile = __FILE__;\247 } while (0) 248 249 #define QMD_TRACE_ELEM(elem) do { \250 (elem)->trace.prevline = (elem)->trace.lastline;\251 (elem)->trace.prevfile = (elem)->trace.lastfile;\252 (elem)->trace.lastline = __LINE__;\253 (elem)->trace.lastfile = __FILE__;\239 #define TRACEBUF struct qm_trace trace; 240 #define TRASHIT(x) do {(x) = (void *)-1;} while (0) 241 242 #define QMD_TRACE_HEAD(head) do { \ 243 (head)->trace.prevline = (head)->trace.lastline; \ 244 (head)->trace.prevfile = (head)->trace.lastfile; \ 245 (head)->trace.lastline = __LINE__; \ 246 (head)->trace.lastfile = __FILE__; \ 247 } while (0) 248 249 #define QMD_TRACE_ELEM(elem) do { \ 250 (elem)->trace.prevline = (elem)->trace.lastline; \ 251 (elem)->trace.prevfile = (elem)->trace.lastfile; \ 252 (elem)->trace.lastline = __LINE__; \ 253 (elem)->trace.lastfile = __FILE__; \ 254 254 } while (0) 255 255 … … 259 259 #define TRACEBUF 260 260 #define TRASHIT(x) 261 #endif /* QUEUE_MACRO_DEBUG */261 #endif /* QUEUE_MACRO_DEBUG */ 262 262 263 263 /* 264 264 * Singly-linked List declarations. 265 265 */ 266 #define SLIST_HEAD(name, type)\267 struct name { \268 struct type *slh_first; /* first element */\269 } 270 271 #define SLIST_HEAD_INITIALIZER(head)\272 { NULL }266 #define SLIST_HEAD(name, type) \ 267 struct name { \ 268 struct type *slh_first; /* first element */ \ 269 } 270 271 #define SLIST_HEAD_INITIALIZER(head) \ 272 { NULL } 273 273 274 #define SLIST_ENTRY(type)\275 struct { \276 struct type *sle_next; /* next element */\274 #define SLIST_ENTRY(type) \ 275 struct { \ 276 struct type *sle_next; /* next element */ \ 277 277 } 278 278 … … 280 280 * Singly-linked List functions. 281 281 */ 282 #define SLIST_EMPTY(head)((head)->slh_first == NULL)283 284 #define SLIST_FIRST(head)((head)->slh_first)285 286 #define SLIST_FOREACH(var, head, field)\287 for ((var) = SLIST_FIRST((head));\288 (var);\289 (var) = SLIST_NEXT((var), field))290 291 #define SLIST_FOREACH_PREVPTR(var, varp, head, field) \292 for ((varp) = &SLIST_FIRST((head));\293 ((var) = *(varp)) != NULL;\294 (varp) = &SLIST_NEXT((var), field))295 296 #define SLIST_INIT(head) do {\297 SLIST_FIRST((head)) = NULL;\298 } while (0) 299 300 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {\301 SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);\302 SLIST_NEXT((slistelm), field) = (elm);\303 } while (0) 304 305 #define SLIST_INSERT_HEAD(head, elm, field) do {\306 SLIST_NEXT((elm), field) = SLIST_FIRST((head));\307 SLIST_FIRST((head)) = (elm);\308 } while (0) 309 310 #define SLIST_NEXT(elm, field)((elm)->field.sle_next)311 312 #define SLIST_REMOVE(head, elm, type, field) do {\313 if (SLIST_FIRST((head)) == (elm)) {\314 SLIST_REMOVE_HEAD((head), field);\315 }\316 else {\317 struct type *curelm = SLIST_FIRST((head));\318 while (SLIST_NEXT(curelm, field) != (elm))\319 curelm = SLIST_NEXT(curelm, field);\320 SLIST_NEXT(curelm, field) =\321 SLIST_NEXT(SLIST_NEXT(curelm, field), field);\322 }\323 } while (0) 324 325 #define SLIST_REMOVE_HEAD(head, field) do {\326 SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);\282 #define SLIST_EMPTY(head) ((head)->slh_first == NULL) 283 284 #define SLIST_FIRST(head) ((head)->slh_first) 285 286 #define SLIST_FOREACH(var, head, field) \ 287 for ((var) = SLIST_FIRST((head)); \ 288 (var); \ 289 (var) = SLIST_NEXT((var), field)) 290 291 #define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ 292 for ((varp) = &SLIST_FIRST((head)); \ 293 ((var) = *(varp)) != NULL; \ 294 (varp) = &SLIST_NEXT((var), field)) 295 296 #define SLIST_INIT(head) do { \ 297 SLIST_FIRST((head)) = NULL; \ 298 } while (0) 299 300 #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ 301 SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ 302 SLIST_NEXT((slistelm), field) = (elm); \ 303 } while (0) 304 305 #define SLIST_INSERT_HEAD(head, elm, field) do { \ 306 SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ 307 SLIST_FIRST((head)) = (elm); \ 308 } while (0) 309 310 #define SLIST_NEXT(elm, field) ((elm)->field.sle_next) 311 312 #define SLIST_REMOVE(head, elm, type, field) do { \ 313 if (SLIST_FIRST((head)) == (elm)) { \ 314 SLIST_REMOVE_HEAD((head), field); \ 315 } \ 316 else { \ 317 struct type *curelm = SLIST_FIRST((head)); \ 318 while (SLIST_NEXT(curelm, field) != (elm)) \ 319 curelm = SLIST_NEXT(curelm, field); \ 320 SLIST_NEXT(curelm, field) = \ 321 SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ 322 } \ 323 } while (0) 324 325 #define SLIST_REMOVE_HEAD(head, field) do { \ 326 SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ 327 327 } while (0) 328 328 … … 330 330 * Singly-linked Tail queue declarations. 331 331 */ 332 #define STAILQ_HEAD(name, type)\333 struct name { \334 struct type *stqh_first;/* first element */\335 struct type **stqh_last;/* addr of last next element */\336 } 337 338 #define STAILQ_HEAD_INITIALIZER(head)\339 { NULL, &(head).stqh_first }340 341 #define STAILQ_ENTRY(type)\342 struct { \343 struct type *stqe_next; /* next element */\332 #define STAILQ_HEAD(name, type) \ 333 struct name { \ 334 struct type *stqh_first;/* first element */ \ 335 struct type **stqh_last;/* addr of last next element */ \ 336 } 337 338 #define STAILQ_HEAD_INITIALIZER(head) \ 339 { NULL, &(head).stqh_first } 340 341 #define STAILQ_ENTRY(type) \ 342 struct { \ 343 struct type *stqe_next; /* next element */ \ 344 344 } 345 345 … … 347 347 * Singly-linked Tail queue functions. 348 348 */ 349 #define STAILQ_CONCAT(head1, head2) do {\350 if (!STAILQ_EMPTY((head2))) {\351 *(head1)->stqh_last = (head2)->stqh_first;\352 (head1)->stqh_last = (head2)->stqh_last;\353 STAILQ_INIT((head2));\354 }\355 } while (0) 356 357 #define STAILQ_EMPTY(head)((head)->stqh_first == NULL)358 359 #define STAILQ_FIRST(head)((head)->stqh_first)360 361 #define STAILQ_FOREACH(var, head, field)\362 for((var) = STAILQ_FIRST((head));\363 (var);\364 (var) = STAILQ_NEXT((var), field))365 366 #define STAILQ_INIT(head) do {\367 STAILQ_FIRST((head)) = NULL;\368 (head)->stqh_last = &STAILQ_FIRST((head));\369 } while (0) 370 371 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {\372 if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\373 (head)->stqh_last = &STAILQ_NEXT((elm), field);\374 STAILQ_NEXT((tqelm), field) = (elm);\375 } while (0) 376 377 #define STAILQ_INSERT_HEAD(head, elm, field) do {\378 if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL)\379 (head)->stqh_last = &STAILQ_NEXT((elm), field);\380 STAILQ_FIRST((head)) = (elm);\381 } while (0) 382 383 #define STAILQ_INSERT_TAIL(head, elm, field) do {\384 STAILQ_NEXT((elm), field) = NULL;\385 *(head)->stqh_last = (elm);\386 (head)->stqh_last = &STAILQ_NEXT((elm), field);\387 } while (0) 388 389 #define STAILQ_LAST(head, type, field)\390 (STAILQ_EMPTY((head)) ?\391 NULL :\392 ((struct type *)\393 ((char *)((head)->stqh_last) - __offsetof(struct type, field))))394 395 #define STAILQ_NEXT(elm, field)((elm)->field.stqe_next)396 397 #define STAILQ_REMOVE(head, elm, type, field) do {\398 if (STAILQ_FIRST((head)) == (elm)) {\399 STAILQ_REMOVE_HEAD((head), field);\400 }\401 else {\402 struct type *curelm = STAILQ_FIRST((head));\403 while (STAILQ_NEXT(curelm, field) != (elm))\404 curelm = STAILQ_NEXT(curelm, field);\405 if ((STAILQ_NEXT(curelm, field) =\406 STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\407 (head)->stqh_last = &STAILQ_NEXT((curelm), field);\408 }\409 } while (0) 410 411 #define STAILQ_REMOVE_HEAD(head, field) do {\412 if ((STAILQ_FIRST((head)) =\413 STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)\414 (head)->stqh_last = &STAILQ_FIRST((head));\415 } while (0) 416 417 #define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {\418 if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL)\419 (head)->stqh_last = &STAILQ_FIRST((head));\349 #define STAILQ_CONCAT(head1, head2) do { \ 350 if (!STAILQ_EMPTY((head2))) { \ 351 *(head1)->stqh_last = (head2)->stqh_first; \ 352 (head1)->stqh_last = (head2)->stqh_last; \ 353 STAILQ_INIT((head2)); \ 354 } \ 355 } while (0) 356 357 #define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) 358 359 #define STAILQ_FIRST(head) ((head)->stqh_first) 360 361 #define STAILQ_FOREACH(var, head, field) \ 362 for((var) = STAILQ_FIRST((head)); \ 363 (var); \ 364 (var) = STAILQ_NEXT((var), field)) 365 366 #define STAILQ_INIT(head) do { \ 367 STAILQ_FIRST((head)) = NULL; \ 368 (head)->stqh_last = &STAILQ_FIRST((head)); \ 369 } while (0) 370 371 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ 372 if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ 373 (head)->stqh_last = &STAILQ_NEXT((elm), field); \ 374 STAILQ_NEXT((tqelm), field) = (elm); \ 375 } while (0) 376 377 #define STAILQ_INSERT_HEAD(head, elm, field) do { \ 378 if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ 379 (head)->stqh_last = &STAILQ_NEXT((elm), field); \ 380 STAILQ_FIRST((head)) = (elm); \ 381 } while (0) 382 383 #define STAILQ_INSERT_TAIL(head, elm, field) do { \ 384 STAILQ_NEXT((elm), field) = NULL; \ 385 *(head)->stqh_last = (elm); \ 386 (head)->stqh_last = &STAILQ_NEXT((elm), field); \ 387 } while (0) 388 389 #define STAILQ_LAST(head, type, field) \ 390 (STAILQ_EMPTY((head)) ? \ 391 NULL : \ 392 ((struct type *) \ 393 ((char *)((head)->stqh_last) - __offsetof(struct type, field)))) 394 395 #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) 396 397 #define STAILQ_REMOVE(head, elm, type, field) do { \ 398 if (STAILQ_FIRST((head)) == (elm)) { \ 399 STAILQ_REMOVE_HEAD((head), field); \ 400 } \ 401 else { \ 402 struct type *curelm = STAILQ_FIRST((head)); \ 403 while (STAILQ_NEXT(curelm, field) != (elm)) \ 404 curelm = STAILQ_NEXT(curelm, field); \ 405 if ((STAILQ_NEXT(curelm, field) = \ 406 STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ 407 (head)->stqh_last = &STAILQ_NEXT((curelm), field);\ 408 } \ 409 } while (0) 410 411 #define STAILQ_REMOVE_HEAD(head, field) do { \ 412 if ((STAILQ_FIRST((head)) = \ 413 STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ 414 (head)->stqh_last = &STAILQ_FIRST((head)); \ 415 } while (0) 416 417 #define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ 418 if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ 419 (head)->stqh_last = &STAILQ_FIRST((head)); \ 420 420 } while (0) 421 421 … … 423 423 * List declarations. 424 424 */ 425 #define LIST_HEAD(name, type)\426 struct name { \427 struct type *lh_first; /* first element */\428 } 429 430 #define LIST_HEAD_INITIALIZER(head)\431 { NULL }432 433 #define LIST_ENTRY(type)\434 struct { \435 struct type *le_next; /* next element */\436 struct type **le_prev; /* address of previous next element */\425 #define LIST_HEAD(name, type) \ 426 struct name { \ 427 struct type *lh_first; /* first element */ \ 428 } 429 430 #define LIST_HEAD_INITIALIZER(head) \ 431 { NULL } 432 433 #define LIST_ENTRY(type) \ 434 struct { \ 435 struct type *le_next; /* next element */ \ 436 struct type **le_prev; /* address of previous next element */ \ 437 437 } 438 438 … … 441 441 */ 442 442 443 #define LIST_EMPTY(head)((head)->lh_first == NULL)444 445 #define LIST_FIRST(head)((head)->lh_first)446 447 #define LIST_FOREACH(var, head, field)\448 for ((var) = LIST_FIRST((head));\449 (var);\450 (var) = LIST_NEXT((var), field))451 452 #define LIST_INIT(head) do {\453 LIST_FIRST((head)) = NULL;\454 } while (0) 455 456 #define LIST_INSERT_AFTER(listelm, elm, field) do {\457 if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\458 LIST_NEXT((listelm), field)->field.le_prev =\459 &LIST_NEXT((elm), field);\460 LIST_NEXT((listelm), field) = (elm);\461 (elm)->field.le_prev = &LIST_NEXT((listelm), field);\462 } while (0) 463 464 #define LIST_INSERT_BEFORE(listelm, elm, field) do {\465 (elm)->field.le_prev = (listelm)->field.le_prev;\466 LIST_NEXT((elm), field) = (listelm);\467 *(listelm)->field.le_prev = (elm);\468 (listelm)->field.le_prev = &LIST_NEXT((elm), field);\469 } while (0) 470 471 #define LIST_INSERT_HEAD(head, elm, field) do {\472 if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)\473 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\474 LIST_FIRST((head)) = (elm);\475 (elm)->field.le_prev = &LIST_FIRST((head));\476 } while (0) 477 478 #define LIST_NEXT(elm, field)((elm)->field.le_next)479 480 #define LIST_REMOVE(elm, field) do {\481 if (LIST_NEXT((elm), field) != NULL)\482 LIST_NEXT((elm), field)->field.le_prev =\483 (elm)->field.le_prev;\484 *(elm)->field.le_prev = LIST_NEXT((elm), field);\443 #define LIST_EMPTY(head) ((head)->lh_first == NULL) 444 445 #define LIST_FIRST(head) ((head)->lh_first) 446 447 #define LIST_FOREACH(var, head, field) \ 448 for ((var) = LIST_FIRST((head)); \ 449 (var); \ 450 (var) = LIST_NEXT((var), field)) 451 452 #define LIST_INIT(head) do { \ 453 LIST_FIRST((head)) = NULL; \ 454 } while (0) 455 456 #define LIST_INSERT_AFTER(listelm, elm, field) do { \ 457 if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ 458 LIST_NEXT((listelm), field)->field.le_prev = \ 459 &LIST_NEXT((elm), field); \ 460 LIST_NEXT((listelm), field) = (elm); \ 461 (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ 462 } while (0) 463 464 #define LIST_INSERT_BEFORE(listelm, elm, field) do { \ 465 (elm)->field.le_prev = (listelm)->field.le_prev; \ 466 LIST_NEXT((elm), field) = (listelm); \ 467 *(listelm)->field.le_prev = (elm); \ 468 (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ 469 } while (0) 470 471 #define LIST_INSERT_HEAD(head, elm, field) do { \ 472 if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ 473 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ 474 LIST_FIRST((head)) = (elm); \ 475 (elm)->field.le_prev = &LIST_FIRST((head)); \ 476 } while (0) 477 478 #define LIST_NEXT(elm, field) ((elm)->field.le_next) 479 480 #define LIST_REMOVE(elm, field) do { \ 481 if (LIST_NEXT((elm), field) != NULL) \ 482 LIST_NEXT((elm), field)->field.le_prev = \ 483 (elm)->field.le_prev; \ 484 *(elm)->field.le_prev = LIST_NEXT((elm), field); \ 485 485 } while (0) 486 486 … … 488 488 * Tail queue declarations. 489 489 */ 490 #define TAILQ_HEAD(name, type)\491 struct name { \492 struct type *tqh_first; /* first element */\493 struct type **tqh_last; /* addr of last next element */\494 TRACEBUF\495 } 496 497 #define TAILQ_HEAD_INITIALIZER(head)\498 { NULL, &(head).tqh_first }499 500 #define TAILQ_ENTRY(type)\501 struct { \502 struct type *tqe_next; /* next element */\503 struct type **tqe_prev; /* address of previous next element */\504 TRACEBUF\490 #define TAILQ_HEAD(name, type) \ 491 struct name { \ 492 struct type *tqh_first; /* first element */ \ 493 struct type **tqh_last; /* addr of last next element */ \ 494 TRACEBUF \ 495 } 496 497 #define TAILQ_HEAD_INITIALIZER(head) \ 498 { NULL, &(head).tqh_first } 499 500 #define TAILQ_ENTRY(type) \ 501 struct { \ 502 struct type *tqe_next; /* next element */ \ 503 struct type **tqe_prev; /* address of previous next element */ \ 504 TRACEBUF \ 505 505 } 506 506 … … 508 508 * Tail queue functions. 509 509 */ 510 #define TAILQ_CONCAT(head1, head2, field) do {\511 if (!TAILQ_EMPTY(head2)) {\512 *(head1)->tqh_last = (head2)->tqh_first;\513 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;\514 (head1)->tqh_last = (head2)->tqh_last;\515 TAILQ_INIT((head2));\516 QMD_TRACE_HEAD(head);\517 QMD_TRACE_HEAD(head2);\518 }\519 } while (0) 520 521 #define TAILQ_EMPTY(head)((head)->tqh_first == NULL)522 523 #define TAILQ_FIRST(head)((head)->tqh_first)524 525 #define TAILQ_FOREACH(var, head, field)\526 for ((var) = TAILQ_FIRST((head));\527 (var);\528 (var) = TAILQ_NEXT((var), field))529 530 #define TAILQ_FOREACH_REVERSE(var, head, headname, field)\531 for ((var) = TAILQ_LAST((head), headname);\532 (var);\533 (var) = TAILQ_PREV((var), headname, field))534 535 #define TAILQ_INIT(head) do {\536 TAILQ_FIRST((head)) = NULL;\537 (head)->tqh_last = &TAILQ_FIRST((head));\538 QMD_TRACE_HEAD(head);\539 } while (0) 540 541 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {\542 if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\543 TAILQ_NEXT((elm), field)->field.tqe_prev =\544 &TAILQ_NEXT((elm), field);\545 else {\546 (head)->tqh_last = &TAILQ_NEXT((elm), field);\547 QMD_TRACE_HEAD(head);\548 }\549 TAILQ_NEXT((listelm), field) = (elm);\550 (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);\551 QMD_TRACE_ELEM(&(elm)->field);\552 QMD_TRACE_ELEM(&listelm->field);\553 } while (0) 554 555 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do {\556 (elm)->field.tqe_prev = (listelm)->field.tqe_prev;\557 TAILQ_NEXT((elm), field) = (listelm);\558 *(listelm)->field.tqe_prev = (elm);\559 (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);\560 QMD_TRACE_ELEM(&(elm)->field);\561 QMD_TRACE_ELEM(&listelm->field);\562 } while (0) 563 564 #define TAILQ_INSERT_HEAD(head, elm, field) do {\565 if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)\566 TAILQ_FIRST((head))->field.tqe_prev =\567 &TAILQ_NEXT((elm), field);\568 else\569 (head)->tqh_last = &TAILQ_NEXT((elm), field);\570 TAILQ_FIRST((head)) = (elm);\571 (elm)->field.tqe_prev = &TAILQ_FIRST((head));\572 QMD_TRACE_HEAD(head);\573 QMD_TRACE_ELEM(&(elm)->field);\574 } while (0) 575 576 #define TAILQ_INSERT_TAIL(head, elm, field) do {\577 TAILQ_NEXT((elm), field) = NULL;\578 (elm)->field.tqe_prev = (head)->tqh_last;\579 *(head)->tqh_last = (elm);\580 (head)->tqh_last = &TAILQ_NEXT((elm), field);\581 QMD_TRACE_HEAD(head);\582 QMD_TRACE_ELEM(&(elm)->field);\583 } while (0) 584 585 #define TAILQ_LAST(head, headname)\586 (*(((struct headname *)((head)->tqh_last))->tqh_last))587 588 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)589 590 #define TAILQ_PREV(elm, headname, field)\591 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))592 593 #define TAILQ_REMOVE(head, elm, field) do {\594 if ((TAILQ_NEXT((elm), field)) != NULL)\595 TAILQ_NEXT((elm), field)->field.tqe_prev =\596 (elm)->field.tqe_prev;\597 else {\598 (head)->tqh_last = (elm)->field.tqe_prev;\599 QMD_TRACE_HEAD(head);\600 }\601 *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);\602 TRASHIT((elm)->field.tqe_next);\603 TRASHIT((elm)->field.tqe_prev);\604 QMD_TRACE_ELEM(&(elm)->field);\510 #define TAILQ_CONCAT(head1, head2, field) do { \ 511 if (!TAILQ_EMPTY(head2)) { \ 512 *(head1)->tqh_last = (head2)->tqh_first; \ 513 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ 514 (head1)->tqh_last = (head2)->tqh_last; \ 515 TAILQ_INIT((head2)); \ 516 QMD_TRACE_HEAD(head); \ 517 QMD_TRACE_HEAD(head2); \ 518 } \ 519 } while (0) 520 521 #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) 522 523 #define TAILQ_FIRST(head) ((head)->tqh_first) 524 525 #define TAILQ_FOREACH(var, head, field) \ 526 for ((var) = TAILQ_FIRST((head)); \ 527 (var); \ 528 (var) = TAILQ_NEXT((var), field)) 529 530 #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ 531 for ((var) = TAILQ_LAST((head), headname); \ 532 (var); \ 533 (var) = TAILQ_PREV((var), headname, field)) 534 535 #define TAILQ_INIT(head) do { \ 536 TAILQ_FIRST((head)) = NULL; \ 537 (head)->tqh_last = &TAILQ_FIRST((head)); \ 538 QMD_TRACE_HEAD(head); \ 539 } while (0) 540 541 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ 542 if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ 543 TAILQ_NEXT((elm), field)->field.tqe_prev = \ 544 &TAILQ_NEXT((elm), field); \ 545 else { \ 546 (head)->tqh_last = &TAILQ_NEXT((elm), field); \ 547 QMD_TRACE_HEAD(head); \ 548 } \ 549 TAILQ_NEXT((listelm), field) = (elm); \ 550 (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ 551 QMD_TRACE_ELEM(&(elm)->field); \ 552 QMD_TRACE_ELEM(&listelm->field); \ 553 } while (0) 554 555 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ 556 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ 557 TAILQ_NEXT((elm), field) = (listelm); \ 558 *(listelm)->field.tqe_prev = (elm); \ 559 (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ 560 QMD_TRACE_ELEM(&(elm)->field); \ 561 QMD_TRACE_ELEM(&listelm->field); \ 562 } while (0) 563 564 #define TAILQ_INSERT_HEAD(head, elm, field) do { \ 565 if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ 566 TAILQ_FIRST((head))->field.tqe_prev = \ 567 &TAILQ_NEXT((elm), field); \ 568 else \ 569 (head)->tqh_last = &TAILQ_NEXT((elm), field); \ 570 TAILQ_FIRST((head)) = (elm); \ 571 (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ 572 QMD_TRACE_HEAD(head); \ 573 QMD_TRACE_ELEM(&(elm)->field); \ 574 } while (0) 575 576 #define TAILQ_INSERT_TAIL(head, elm, field) do { \ 577 TAILQ_NEXT((elm), field) = NULL; \ 578 (elm)->field.tqe_prev = (head)->tqh_last; \ 579 *(head)->tqh_last = (elm); \ 580 (head)->tqh_last = &TAILQ_NEXT((elm), field); \ 581 QMD_TRACE_HEAD(head); \ 582 QMD_TRACE_ELEM(&(elm)->field); \ 583 } while (0) 584 585 #define TAILQ_LAST(head, headname) \ 586 (*(((struct headname *)((head)->tqh_last))->tqh_last)) 587 588 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) 589 590 #define TAILQ_PREV(elm, headname, field) \ 591 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) 592 593 #define TAILQ_REMOVE(head, elm, field) do { \ 594 if ((TAILQ_NEXT((elm), field)) != NULL) \ 595 TAILQ_NEXT((elm), field)->field.tqe_prev = \ 596 (elm)->field.tqe_prev; \ 597 else { \ 598 (head)->tqh_last = (elm)->field.tqe_prev; \ 599 QMD_TRACE_HEAD(head); \ 600 } \ 601 *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ 602 TRASHIT((elm)->field.tqe_next); \ 603 TRASHIT((elm)->field.tqe_prev); \ 604 QMD_TRACE_ELEM(&(elm)->field); \ 605 605 } while (0) 606 606 -
trunk/ithildin/include/ithildin/socket.h
r576 r578 12 12 13 13 /* these are some defined maximums for lengths. */ 14 #define HOSTNAME_MAXLEN 6315 #define FQDN_MAXLEN 25514 #define HOSTNAME_MAXLEN 63 15 #define FQDN_MAXLEN 255 16 16 17 17 #ifdef INET6 18 #define IPADDR_MAXLEN 3919 #define IPADDR_SIZE 1618 #define IPADDR_MAXLEN 39 19 #define IPADDR_SIZE 16 20 20 #else 21 #define IPADDR_MAXLEN 1522 #define IPADDR_SIZE 421 #define IPADDR_MAXLEN 15 22 #define IPADDR_SIZE 4 23 23 #endif 24 24 … … 28 28 struct isock_address { 29 29 struct sockaddr *addr; /* sockaddr * to one of a few types. */ 30 size_t addrlen; /* length of addr */31 int family; /* PF_xxx family. */32 int type; /* SOCK_xxx type. */33 int protocol; /* IPPORTO_xxx protocol, or 0 */30 size_t addrlen; /* length of addr */ 31 int family; /* PF_xxx family. */ 32 int type; /* SOCK_xxx type. */ 33 int protocol; /* IPPORTO_xxx protocol, or 0 */ 34 34 }; 35 35 36 36 LIST_HEAD(isocket_list, isocket); 37 37 38 38 struct isocket { 39 int fd;/* file descriptor */39 int fd; /* file descriptor */ 40 40 #ifdef HAVE_OPENSSL 41 struct ssl_st *ssl; /* SSL descriptor */42 time_t ssl_start; /* when handshaking started */41 struct ssl_st *ssl; /* SSL descriptor */ 42 time_t ssl_start; /* when handshaking started */ 43 43 #endif 44 44 … … 49 49 50 50 struct event *datahook; 51 void *udata; /* user data...useful for when sockets are52 hooked */51 void *udata; /* user data...useful for when sockets are 52 hooked */ 53 53 54 int err;/* last errno on this socket. */55 uint32_t state; /* state is set from one of the below */56 #define SOCKET_FL_OPEN 0x000157 #define SOCKET_FL_LISTENING 0x000258 #define SOCKET_LISTENING(x) ((x)->state & SOCKET_FL_LISTENING)59 #define SOCKET_FL_CONNECTED 0x000460 #define SOCKET_FL_READ_PENDING 0x000861 #define SOCKET_FL_WRITE_PENDING 0x001062 #define SOCKET_FL_ERROR_PENDING 0x002063 #define SOCKET_FL_WANT_READ 0x004064 #define SOCKET_FL_WANT_WRITE 0x008065 #define SOCKET_FL_INTERNAL 0x010066 #define SOCKET_FL_EOF 0x020054 int err; /* last errno on this socket. */ 55 uint32_t state; /* state is set from one of the below */ 56 #define SOCKET_FL_OPEN 0x0001 57 #define SOCKET_FL_LISTENING 0x0002 58 #define SOCKET_LISTENING(x) ((x)->state & SOCKET_FL_LISTENING) 59 #define SOCKET_FL_CONNECTED 0x0004 60 #define SOCKET_FL_READ_PENDING 0x0008 61 #define SOCKET_FL_WRITE_PENDING 0x0010 62 #define SOCKET_FL_ERROR_PENDING 0x0020 63 #define SOCKET_FL_WANT_READ 0x0040 64 #define SOCKET_FL_WANT_WRITE 0x0080 65 #define SOCKET_FL_INTERNAL 0x0100 66 #define SOCKET_FL_EOF 0x0200 67 67 68 68 #ifdef HAVE_OPENSSL 69 #define SOCKET_FL_SSL (0x0001 << 16)70 #define SOCKET_SSL(x) ((x)->state & SOCKET_FL_SSL)71 #define SOCKET_FL_SSL_HANDSHAKE (0x0002 << 16)69 #define SOCKET_FL_SSL (0x0001 << 16) 70 #define SOCKET_SSL(x) ((x)->state & SOCKET_FL_SSL) 71 #define SOCKET_FL_SSL_HANDSHAKE (0x0002 << 16) 72 72 #define SOCKET_SSL_HANDSHAKING(x) ((x)->state & SOCKET_FL_SSL_HANDSHAKE) 73 #define SOCKET_FL_SSLWANT_READ (0x0004 << 16)74 #define SOCKET_FL_SSLWANT_WRITE (0x0008 << 16)73 #define SOCKET_FL_SSLWANT_READ (0x0004 << 16) 74 #define SOCKET_FL_SSLWANT_WRITE (0x0008 << 16) 75 75 #endif 76 76 77 #define SOCKET_FL_DEAD (0x8000 << 16)77 #define SOCKET_FL_DEAD (0x8000 << 16) 78 78 79 79 #define SOCKET_FL_READ SOCKET_FL_READ_PENDING 80 80 #define SOCKET_FL_WRITE SOCKET_FL_WRITE_PENDING 81 81 #define SOCKET_FL_PENDING (SOCKET_FL_READ_PENDING | SOCKET_FL_WRITE_PENDING | \ 82 SOCKET_FL_ERROR_PENDING)82 SOCKET_FL_ERROR_PENDING) 83 83 84 #define SOCKET_READ(x) ((x)->state & SOCKET_FL_READ_PENDING)85 #define SOCKET_WRITE(x) ((x)->state & SOCKET_FL_WRITE_PENDING)86 #define SOCKET_ERROR(x) ((x)->state & SOCKET_FL_ERROR_PENDING)87 #define SOCKET_ANY(x) ((x)->state & SOCKET_FL_PENDING)88 #define SOCKET_DEAD(x) ((x)->state & SOCKET_FL_DEAD)84 #define SOCKET_READ(x) ((x)->state & SOCKET_FL_READ_PENDING) 85 #define SOCKET_WRITE(x) ((x)->state & SOCKET_FL_WRITE_PENDING) 86 #define SOCKET_ERROR(x) ((x)->state & SOCKET_FL_ERROR_PENDING) 87 #define SOCKET_ANY(x) ((x)->state & SOCKET_FL_PENDING) 88 #define SOCKET_DEAD(x) ((x)->state & SOCKET_FL_DEAD) 89 89 90 90 LIST_ENTRY(isocket) intlp; /* only for use in the 'allsockets' list! */ … … 151 151 #define getaddrinfo getaddrinfo__compat 152 152 int getaddrinfo__compat(const char *hostname, const char *servname, 153 const struct addrinfo *hints, struct addrinfo **res);153 const struct addrinfo *hints, struct addrinfo **res); 154 154 #define getnameinfo getnameinfo__compat 155 155 int getnameinfo__compat(const struct sockaddr *sa, size_t salen, 156 char *host, size_t hostlen, char *serv, size_t servlen, int flags);156 char *host, size_t hostlen, char *serv, size_t servlen, int flags); 157 157 #define gai_strerror gai_strerror__compat 158 158 const char *gai_strerror__compat(int ecode); … … 163 163 #define inet_pton inet_pton__compat 164 164 const char *inet_ntop__compat(int af, const void *addr, char *numaddr, 165 size_t numaddr_len);165 size_t numaddr_len); 166 166 #endif 167 167 #ifndef HAVE_INET_NTOP -
trunk/ithildin/include/ithildin/string.h
r576 r578 106 106 /* baseX encoding/decoding/conversion functions. please note that, in the case 107 107 * of base64, it is *NOT* compatible with RFC1521! */ 108 #define BASE2_ENCODING 1109 #define BASE4_ENCODING 2110 #define BASE8_ENCODING 3111 #define BASE16_ENCODING 4108 #define BASE2_ENCODING 1 109 #define BASE4_ENCODING 2 110 #define BASE8_ENCODING 3 111 #define BASE16_ENCODING 4 112 112 #define BASE32_ENCODING 5 113 #define BASE64_ENCODING 6113 #define BASE64_ENCODING 6 114 114 size_t str_base_encode(char, char *, char *, size_t); 115 115 size_t str_base_decode(char, char *, char *, size_t); -
trunk/ithildin/include/ithildin/timer.h
r576 r578 18 18 * data values pertaining to execution time. */ 19 19 struct timer_event { 20 timer_ref_t ref; /* timer reference number */21 int reps;/* number of times to repeat this call. a22 negative value indicates indefinite23 repetition. */24 time_t interval; /* interval between calls. */25 time_t next; /* the (absolute) next time this call should be26 made. */27 void *udata; /* data value passed with the callback */28 hook_function_t callback; /* the callback function */20 timer_ref_t ref; /* timer reference number */ 21 int reps; /* number of times to repeat this call. a 22 negative value indicates indefinite 23 repetition. */ 24 time_t interval; /* interval between calls. */ 25 time_t next; /* the (absolute) next time this call should be 26 made. */ 27 void *udata; /* data value passed with the callback */ 28 hook_function_t callback; /* the callback function */ 29 29 30 30 LIST_ENTRY(timer_event) lp; -
trunk/ithildin/source/Makefile.in
r576 r578 30 30 31 31 # the source files 32 SOURCES = conf.c event.c hash.c log.c main.c malloc.c md5.c module.c \33 socket.c string.c timer.c util.c32 SOURCES = conf.c event.c hash.c log.c main.c malloc.c md5.c module.c \ 33 socket.c string.c timer.c util.c 34 34 OBJECTS = $(SOURCES:.c=.o) 35 35 … … 37 37 38 38 all: $(OBJECTS) md5sum 39 $(CC) $(LDFLAGS) -o $(PACKAGE) $(OBJECTS) $(LIBS)40 ls -l $(PACKAGE)39 $(CC) $(LDFLAGS) -o $(PACKAGE) $(OBJECTS) $(LIBS) 40 ls -l $(PACKAGE) 41 41 42 42 # generic compile ruleset 43 43 .c.o: 44 $(CC) $(CFLAGS) $(INCLUDES) -c $<44 $(CC) $(CFLAGS) $(INCLUDES) -c $< 45 45 # special stuff: 46 46 main.o: 47 $(CC) $(CFLAGS) $(INCLUDES) -DCONF_PATH="\"$(CONFPATH)\"" -DLIB_PATH="\"$(LIBPATH)\"" -DDATA_PATH="\"$(DATAPATH)\"" -DCOMP_FLAGS="\"$(CFLAGS)\"" -DCOMP_FLAGS_MOD="\"$(CFLAGSDLL)\"" -DCOMP_LDFLAGS="\"$(LDFLAGS)\"" -DCOMP_LDFLAGS_MOD="\"$(LDFLAGSDLL)\"" -DREPOVER=$(REPOVER) -c main.c47 $(CC) $(CFLAGS) $(INCLUDES) -DCONF_PATH="\"$(CONFPATH)\"" -DLIB_PATH="\"$(LIBPATH)\"" -DDATA_PATH="\"$(DATAPATH)\"" -DCOMP_FLAGS="\"$(CFLAGS)\"" -DCOMP_FLAGS_MOD="\"$(CFLAGSDLL)\"" -DCOMP_LDFLAGS="\"$(LDFLAGS)\"" -DCOMP_LDFLAGS_MOD="\"$(LDFLAGSDLL)\"" -DREPOVER=$(REPOVER) -c main.c 48 48 49 49 md5sum: md5sum.o 50 $(CC) $(LDFLAGS) -o md5sum md5sum.o md5.o $(LIBS)50 $(CC) $(LDFLAGS) -o md5sum md5sum.o md5.o $(LIBS) 51 51 52 52 # file dependencies 53 53 %.d: %.c 54 @set -e; $(CC) -M $(CFLAGS) $(INCLUDES) $< \55 | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \56 test -s $@ || rm -f $@54 @set -e; $(CC) -M $(CFLAGS) $(INCLUDES) $< \ 55 | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ 56 test -s $@ || rm -f $@ 57 57 -include $(SOURCES:.c=.d) 58 58 -
trunk/ithildin/source/conf.c
r576 r578 18 18 static conf_list_t *conf_parse(char *, int, char *); 19 19 static conf_entry_t *merge_into_conf(conf_list_t *, conf_entry_t *, 20 conf_list_t *);20 conf_list_t *); 21 21 static char *conf_expand_text(char *); 22 22 … … 32 32 /* mmap the data in */ 33 33 if ((stuff = mmap_file(file)) == NULL) 34 return NULL;34 return NULL; 35 35 36 36 /* weed out comments, and bad strings */ 37 37 if ((stuff = conf_preparse(file, stuff)) == NULL) 38 return NULL;38 return NULL; 39 39 40 40 /* now parse */ … … 44 44 45 45 if (list == NULL) 46 return NULL;46 return NULL; 47 47 48 48 /* display_tree(0, list);*/ … … 57 57 ep1 = LIST_FIRST(list); 58 58 while (ep1 != NULL) { 59 ep2 = LIST_NEXT(ep1, lp);60 if (ep1->type == CONF_TYPE_LIST)61 destroy_conf_branch(ep1->list);62 if (ep1->string != NULL)63 free(ep1->string);64 free(ep1->name);65 free(ep1);66 ep1 = ep2;59 ep2 = LIST_NEXT(ep1, lp); 60 if (ep1->type == CONF_TYPE_LIST) 61 destroy_conf_branch(ep1->list); 62 if (ep1->string != NULL) 63 free(ep1->string); 64 free(ep1->name); 65 free(ep1); 66 ep1 = ep2; 67 67 } 68 68 } … … 76 76 #define print_branches(x) for (i = x;i;i--) printf("| "); 77 77 LIST_FOREACH(ep, list, lp) { 78 print_branches(depth);79 if (ep->type == CONF_TYPE_DATA)80 printf("%s-> %s = '%s'\n", (depth ? "\b" : ""), ep->name,81 ep->string);82 else {83 printf("%s->[%s]\n", (depth ? "\b" : ""), ep->name);84 conf_display_tree(depth + 1, ep->list);85 }78 print_branches(depth); 79 if (ep->type == CONF_TYPE_DATA) 80 printf("%s-> %s = '%s'\n", (depth ? "\b" : ""), ep->name, 81 ep->string); 82 else { 83 printf("%s->[%s]\n", (depth ? "\b" : ""), ep->name); 84 conf_display_tree(depth + 1, ep->list); 85 } 86 86 } 87 87 #undef print_branches … … 97 97 98 98 if (maxdepth < 1 || list == NULL) 99 return NULL;99 return NULL; 100 100 101 101 LIST_FOREACH(cep, list, lp) { 102 if (!strcasecmp(cep->name, name) && (cep->type == type || type == 0)) {103 /* return the entry if the strings match, or if data is NULL */104 if (data == NULL)105 return cep;106 else if (!strcasecmp(cep->string, data))107 return cep;108 } else if (cep->type == CONF_TYPE_LIST) {109 if ((tmpcep = conf_find(name, data, type, cep->list, maxdepth - 1))110 != NULL)111 return tmpcep;112 }102 if (!strcasecmp(cep->name, name) && (cep->type == type || type == 0)) { 103 /* return the entry if the strings match, or if data is NULL */ 104 if (data == NULL) 105 return cep; 106 else if (!strcasecmp(cep->string, data)) 107 return cep; 108 } else if (cep->type == CONF_TYPE_LIST) { 109 if ((tmpcep = conf_find(name, data, type, cep->list, maxdepth - 1)) 110 != NULL) 111 return tmpcep; 112 } 113 113 } 114 114 … … 120 120 * the list. */ 121 121 conf_entry_t *conf_find_next(const char *name, const char *data, int type, 122 conf_entry_t *last, conf_list_t *list, int maxdepth) {122 conf_entry_t *last, conf_list_t *list, int maxdepth) { 123 123 conf_entry_t *cep = NULL, *tmpcep; 124 124 125 125 if (maxdepth < 1 || list == NULL) 126 return NULL;126 return NULL; 127 127 128 128 /* with a conf entry, we get the list data too, so we know where 129 129 * to start from! */ 130 130 if (last == NULL) 131 cep = LIST_FIRST(list);131 cep = LIST_FIRST(list); 132 132 else 133 cep = LIST_NEXT(last, lp);133 cep = LIST_NEXT(last, lp); 134 134 135 135 while (cep != NULL) { 136 if (!strcasecmp(cep->name, name) &&137 (cep->type == type || type == 0)) {138 /* return the entry if the strings match, or if data is NULL */139 if (data == NULL)140 return cep;141 else if (!strcasecmp(cep->string, data))142 return cep;143 } else if (cep->type == CONF_TYPE_LIST) {144 if ((tmpcep = conf_find(name, data, type, cep->list, maxdepth - 1))145 != NULL)146 return tmpcep;147 }148 cep = LIST_NEXT(cep, lp);136 if (!strcasecmp(cep->name, name) && 137 (cep->type == type || type == 0)) { 138 /* return the entry if the strings match, or if data is NULL */ 139 if (data == NULL) 140 return cep; 141 else if (!strcasecmp(cep->string, data)) 142 return cep; 143 } else if (cep->type == CONF_TYPE_LIST) { 144 if ((tmpcep = conf_find(name, data, type, cep->list, maxdepth - 1)) 145 != NULL) 146 return tmpcep; 147 } 148 cep = LIST_NEXT(cep, lp); 149 149 } 150 150 return NULL; … … 153 153 /* this is shorthand to find a list-type conf, it uses conf_find() above. */ 154 154 conf_list_t *conf_find_list(const char *name, conf_list_t *list, 155 int maxdepth) {155 int maxdepth) { 156 156 conf_entry_t *cep; 157 157 158 158 if ((cep = conf_find(name, NULL, CONF_TYPE_LIST, list, maxdepth)) != NULL) 159 return cep->list;159 return cep->list; 160 160 161 161 return NULL; … … 167 167 168 168 if ((cep = conf_find(name, NULL, CONF_TYPE_DATA, list, maxdepth)) != NULL) 169 return cep->string;169 return cep->string; 170 170 171 171 return NULL; … … 176 176 * possible, it is recommended you use conf_find_next() instead. */ 177 177 conf_list_t *conf_find_list_next(const char *name, conf_list_t *last, 178 conf_list_t *list, int maxdepth) {178 conf_list_t *list, int maxdepth) { 179 179 conf_entry_t *cep = NULL; 180 180 conf_list_t *clp = NULL; … … 182 182 183 183 if (maxdepth < 1 || list == NULL) 184 return NULL;184 return NULL; 185 185 186 186 if (last == NULL) 187 found = 1; /* if last is NULL, start at the beginning */187 found = 1; /* if last is NULL, start at the beginning */ 188 188 189 189 LIST_FOREACH(cep, list, lp) { 190 if (!found) {191 if (cep->list == last)192 found++; /* this is the matching entry */193 continue;194 }195 196 if (cep->type == CONF_TYPE_LIST && !strcasecmp(cep->name, name))197 return cep->list;198 else if (cep->type == CONF_TYPE_LIST) {199 if ((clp = conf_find_list(name, cep->list, maxdepth - 1)) != NULL)200 return clp;201 }190 if (!found) { 191 if (cep->list == last) 192 found++; /* this is the matching entry */ 193 continue; 194 } 195 196 if (cep->type == CONF_TYPE_LIST && !strcasecmp(cep->name, name)) 197 return cep->list; 198 else if (cep->type == CONF_TYPE_LIST) { 199 if ((clp = conf_find_list(name, cep->list, maxdepth - 1)) != NULL) 200 return clp; 201 } 202 202 } 203 203 … … 205 205 } 206 206 char *conf_find_entry_next(const char *name, char *last, 207 conf_list_t *list, int maxdepth) {207 conf_list_t *list, int maxdepth) { 208 208 conf_entry_t *cep = NULL; 209 209 char *s = NULL; … … 211 211 212 212 if (maxdepth < 1 || list == NULL) 213 return NULL;213 return NULL; 214 214 215 215 if (last == NULL) 216 found = 1; /* if last is NULL, start at the beginning */216 found = 1; /* if last is NULL, start at the beginning */ 217 217 218 218 LIST_FOREACH(cep, list, lp) { 219 if (!found) {220 if (cep->string == last)221 found++; /* this is the matching entry */222 continue;223 }224 225 if (cep->type == CONF_TYPE_DATA && !strcasecmp(cep->name, name))226 return cep->string;227 else if (cep->type == CONF_TYPE_LIST) {228 if ((s = conf_find_entry(name, cep->list, maxdepth - 1)) != NULL)229 return s;230 }219 if (!found) { 220 if (cep->string == last) 221 found++; /* this is the matching entry */ 222 continue; 223 } 224 225 if (cep->type == CONF_TYPE_DATA && !strcasecmp(cep->name, name)) 226 return cep->string; 227 else if (cep->type == CONF_TYPE_LIST) { 228 if ((s = conf_find_entry(name, cep->list, maxdepth - 1)) != NULL) 229 return s; 230 } 231 231 } 232 232 … … 246 246 247 247 while (*s) { 248 switch (*s) {249 case '"':250 if (incomment) {251 s++;252 break;253 }254 if (!instring)255 begline=line;256 instring ^= 1;257 *str++ = *s++;258 break;259 case '\\': /* the \ just negates us from checking the next260 character, shrug. */261 if (incomment) {262 s++;263 break;264 }265 *str++ = *s++;266 if (*s == '\n') {248 switch (*s) { 249 case '"': 250 if (incomment) { 251 s++; 252 break; 253 } 254 if (!instring) 255 begline=line; 256 instring ^= 1; 257 *str++ = *s++; 258 break; 259 case '\\': /* the \ just negates us from checking the next 260 character, shrug. */ 261 if (incomment) { 262 s++; 263 break; 264 } 265 *str++ = *s++; 266 if (*s == '\n') { 267 267 #if 0 268 parse_err("cannot backquote literal newline.");269 free(newstr);270 free(oldstr);271 return NULL;268 parse_err("cannot backquote literal newline."); 269 free(newstr); 270 free(oldstr); 271 return NULL; 272 272 #endif 273 line++;274 }275 *str++ = *s++;276 break;277 case '#':278 if (incomment) {279 s++;280 break;281 } else if (instring)282 *str++ = *s++;283 else284 while (*s && *s != '\n')285 s++; /* a #-style comment. whee. */286 break;287 case '/':288 if (incomment) {289 s++;290 break;291 }292 if (*(s + 1) == '/' && !instring) {293 /* this being a comment of the C++ neature, eat until294 EOL */295 while (*s && *s != '\n')296 s++;297 } else if (*(s + 1) == '*' && !instring) {298 s += 2;299 incomment = 1;300 begline=line;301 } else302 *str++ = *s++;303 break; 304 case '\n':305 line++;273 line++; 274 } 275 *str++ = *s++; 276 break; 277 case '#': 278 if (incomment) { 279 s++; 280 break; 281 } else if (instring) 282 *str++ = *s++; 283 else 284 while (*s && *s != '\n') 285 s++; /* a #-style comment. whee. */ 286 break; 287 case '/': 288 if (incomment) { 289 s++; 290 break; 291 } 292 if (*(s + 1) == '/' && !instring) { 293 /* this being a comment of the C++ neature, eat until 294 EOL */ 295 while (*s && *s != '\n') 296 s++; 297 } else if (*(s + 1) == '*' && !instring) { 298 s += 2; 299 incomment = 1; 300 begline=line; 301 } else 302 *str++ = *s++; 303 break; 304 case '\n': 305 line++; 306 306 #if 0 307 if (instring) {308 parse_err("unterminated string on previous line");309 free(newstr);310 free(oldstr);311 return NULL;312 }307 if (instring) { 308 parse_err("unterminated string on previous line"); 309 free(newstr); 310 free(oldstr); 311 return NULL; 312 } 313 313 #endif 314 *str++ = *s++;315 break;316 default:317 if (!incomment)318 *str++ = *s++;319 else if (incomment && *s == '*') {320 if (*(s + 1) == '/') { /* the comment is over */321 s += 2;322 incomment=0;323 } else324 s++;325 } else326 s++;327 break;328 }314 *str++ = *s++; 315 break; 316 default: 317 if (!incomment) 318 *str++ = *s++; 319 else if (incomment && *s == '*') { 320 if (*(s + 1) == '/') { /* the comment is over */ 321 s += 2; 322 incomment=0; 323 } else 324 s++; 325 } else 326 s++; 327 break; 328 } 329 329 } 330 330 … … 333 333 334 334 if (instring || incomment) { 335 line = begline;336 parse_err("unterminated string or comment beginning here");337 free(newstr);338 return NULL;335 line = begline; 336 parse_err("unterminated string or comment beginning here"); 337 free(newstr); 338 return NULL; 339 339 } 340 340 … … 351 351 int startline = 0; 352 352 353 #define swallow_whitespace() do { \354 while (*str) { \355 if (*str == '\n')\356 line++;\357 if (isspace(*str))\358 str++;\359 else\360 break;\361 } \353 #define swallow_whitespace() do { \ 354 while (*str) { \ 355 if (*str == '\n') \ 356 line++; \ 357 if (isspace(*str)) \ 358 str++; \ 359 else \ 360 break; \ 361 } \ 362 362 } while (0) 363 363 … … 365 365 366 366 while (*str) { 367 swallow_whitespace();368 if (!*str)369 return list; /* that's it, we're done! */370 371 ent = malloc(sizeof(conf_entry_t));372 memset(ent, 0, sizeof(conf_entry_t));373 ent->parent = list;374 375 /* here's some cute syntactic sugar. we allow nameless entries if376 * they are lists (start with/end with {/}) or if the are quoted (""),377 * we set the name field to "" */378 if (*str != '"' && *str != '{') {379 i = 0;380 s = str;381 while (*str && !isspace(*str) && *str != '{' && *str != ';') {382 str++;383 i++;384 }385 386 if (!*str) {387 destroy_conf_branch(list);388 parse_err("file terminated prematurely");389 return NULL; /* this is obviously eroneous */390 }391 392 /* silly hack for nameless entries here, too. We swallow393 * whitespace, and if our next character is a ';', we craftily push394 * our pointer back to where it was before and let the parser395 * continue. */396 swallow_whitespace();397 if (*str == ';') {398 str = s;399 ent->name = malloc(1);400 strcpy(ent->name, "");401 } else {402 ent->name = malloc((size_t)i + 1);403 strncpy(ent->name, s, (size_t)i);404 ent->name[i]=0;405 }406 } else {407 ent->name = malloc(1);408 strcpy(ent->name, "");409 }367 swallow_whitespace(); 368 if (!*str) 369 return list; /* that's it, we're done! */ 370 371 ent = malloc(sizeof(conf_entry_t)); 372 memset(ent, 0, sizeof(conf_entry_t)); 373 ent->parent = list; 374 375 /* here's some cute syntactic sugar. we allow nameless entries if 376 * they are lists (start with/end with {/}) or if the are quoted (""), 377 * we set the name field to "" */ 378 if (*str != '"' && *str != '{') { 379 i = 0; 380 s = str; 381 while (*str && !isspace(*str) && *str != '{' && *str != ';') { 382 str++; 383 i++; 384 } 385 386 if (!*str) { 387 destroy_conf_branch(list); 388 parse_err("file terminated prematurely"); 389 return NULL; /* this is obviously eroneous */ 390 } 391 392 /* silly hack for nameless entries here, too. We swallow 393 * whitespace, and if our next character is a ';', we craftily push 394 * our pointer back to where it was before and let the parser 395 * continue. */ 396 swallow_whitespace(); 397 if (*str == ';') { 398 str = s; 399 ent->name = malloc(1); 400 strcpy(ent->name, ""); 401 } else { 402 ent->name = malloc((size_t)i + 1); 403 strncpy(ent->name, s, (size_t)i); 404 ent->name[i]=0; 405 } 406 } else { 407 ent->name = malloc(1); 408 strcpy(ent->name, ""); 409 } 410 410 411 swallow_whitespace();412 413 s = str;414 while (*str && *str != ';' && *str != '{') {415 if (*str == '"') {416 while (*str) {417 if (*str == '\\')418 str += 2;419 else if (*str == '"') {420 str++;421 break;422 } else423 str++;424 }425 426 if (!*str) {427 free(ent->name);428 free(ent);429 destroy_conf_branch(list);430 parse_err("syntax error");431 return NULL;432 }433 } else434 str++;435 }436 437 if (!*str) {438 free(ent->name);439 free(ent);440 destroy_conf_branch(list);441 parse_err("syntax error");442 return NULL;443 }444 445 /* copy in the string, if any. if the string evaluates to empty, free446 * the memory and set string to NULL. */447 save = *str;448 *str = 0;449 ent->string = conf_expand_text(s);450 if (*ent->string == '\0') {451 free(ent->string);452 ent->string = NULL;453 }454 *str = save;455 456 /* if this really was a data-type entry, check to see if it was an457 * include statement, and do the including. also check to see if it458 * boiled down to an empty string and complain if it did. */459 if (*str == ';') {460 ent->type = CONF_TYPE_DATA;461 if (ent->string == NULL) {462 /* actually.. let's try this.. if string came out NULL, make it463 * a nameless entry. */464 ent->string = ent->name;465 ent->name = strdup("");466 }467 468 if (!strcmp(ent->name, "$INCLUDE")) {469 conf_list_t *inclist;470 471 if ((inclist = read_conf(ent->string)) == NULL) {472 parse_err("error in included file:");473 parse_err(ent->string);474 destroy_conf_branch(list);475 return NULL;476 } else {477 free(ent->string);478 free(ent);479 last = merge_into_conf(list, last, inclist);480 }481 } else {482 if (last == NULL)483 LIST_INSERT_HEAD(list, ent, lp);484 else485 LIST_INSERT_AFTER(last, ent, lp);486 last = ent;487 }488 str++; /* skip the semicolon */489 } else if (*str == '{') {490 /* otherwise, it's a section, keep going .. */491 int depth = 1;492 startline = line;493 s = ++str;494 ent->type = CONF_TYPE_LIST;495 496 while (*str) {497 if (*str == '"') {498 str++;499 while (*str) {500 if (*str == '\\')501 str += 2;502 else if (*str == '"')503 break;504 else505 str++;506 }507 } else if (*str == '{')508 depth++;509 else if (*str == '}') {510 depth--;511 512 if (depth == 0)513 break;514 }515 if (*str == '\n')516 line++;517 str++;518 }519 520 if (!*str) {521 free(ent->name);522 free(ent);523 destroy_conf_branch(list);524 parse_err("syntax error (unclosed braces)");525 return NULL; /* some kind of syntax error */526 }527 528 *str++ = 0;529 ent->list = conf_parse(file, startline, s);530 if (ent->list == NULL) {531 free(ent->name);532 free(ent);533 destroy_conf_branch(list);534 return NULL;535 }536 537 if (last == NULL)538 LIST_INSERT_HEAD(list, ent, lp);539 else540 LIST_INSERT_AFTER(last, ent, lp);541 last = ent;542 543 swallow_whitespace();544 545 if (!*str) {546 free(ent->name);547 free(ent);548 destroy_conf_branch(list);549 parse_err("missing semicolon (';')");550 return NULL; /* missing semi-colon */551 } else552 s = NULL;553 554 if (*str != ';') {555 free(ent->name);556 destroy_conf_branch(ent->list);557 free(ent);558 parse_err("garbage between closing brace ('}') and "559 "semicolon (';')");560 return NULL;561 }562 563 *str++ = '\0';;564 continue;565 } else {566 destroy_conf_branch(list);567 parse_err("conf parser barfed!");568 return NULL; /* some kind of syntax error */569 }411 swallow_whitespace(); 412 413 s = str; 414 while (*str && *str != ';' && *str != '{') { 415 if (*str == '"') { 416 while (*str) { 417 if (*str == '\\') 418 str += 2; 419 else if (*str == '"') { 420 str++; 421 break; 422 } else 423 str++; 424 } 425 426 if (!*str) { 427 free(ent->name); 428 free(ent); 429 destroy_conf_branch(list); 430 parse_err("syntax error"); 431 return NULL; 432 } 433 } else 434 str++; 435 } 436 437 if (!*str) { 438 free(ent->name); 439 free(ent); 440 destroy_conf_branch(list); 441 parse_err("syntax error"); 442 return NULL; 443 } 444 445 /* copy in the string, if any. if the string evaluates to empty, free 446 * the memory and set string to NULL. */ 447 save = *str; 448 *str = 0; 449 ent->string = conf_expand_text(s); 450 if (*ent->string == '\0') { 451 free(ent->string); 452 ent->string = NULL; 453 } 454 *str = save; 455 456 /* if this really was a data-type entry, check to see if it was an 457 * include statement, and do the including. also check to see if it 458 * boiled down to an empty string and complain if it did. */ 459 if (*str == ';') { 460 ent->type = CONF_TYPE_DATA; 461 if (ent->string == NULL) { 462 /* actually.. let's try this.. if string came out NULL, make it 463 * a nameless entry. */ 464 ent->string = ent->name; 465 ent->name = strdup(""); 466 } 467 468 if (!strcmp(ent->name, "$INCLUDE")) { 469 conf_list_t *inclist; 470 471 if ((inclist = read_conf(ent->string)) == NULL) { 472 parse_err("error in included file:"); 473 parse_err(ent->string); 474 destroy_conf_branch(list); 475 return NULL; 476 } else { 477 free(ent->string); 478 free(ent); 479 last = merge_into_conf(list, last, inclist); 480 } 481 } else { 482 if (last == NULL) 483 LIST_INSERT_HEAD(list, ent, lp); 484 else 485 LIST_INSERT_AFTER(last, ent, lp); 486 last = ent; 487 } 488 str++; /* skip the semicolon */ 489 } else if (*str == '{') { 490 /* otherwise, it's a section, keep going .. */ 491 int depth = 1; 492 startline = line; 493 s = ++str; 494 ent->type = CONF_TYPE_LIST; 495 496 while (*str) { 497 if (*str == '"') { 498 str++; 499 while (*str) { 500 if (*str == '\\') 501 str += 2; 502 else if (*str == '"') 503 break; 504 else 505 str++; 506 } 507 } else if (*str == '{') 508 depth++; 509 else if (*str == '}') { 510 depth--; 511 512 if (depth == 0) 513 break; 514 } 515 if (*str == '\n') 516 line++; 517 str++; 518 } 519 520 if (!*str) { 521 free(ent->name); 522 free(ent); 523 destroy_conf_branch(list); 524 parse_err("syntax error (unclosed braces)"); 525 return NULL; /* some kind of syntax error */ 526 } 527 528 *str++ = 0; 529 ent->list = conf_parse(file, startline, s); 530 if (ent->list == NULL) { 531 free(ent->name); 532 free(ent); 533 destroy_conf_branch(list); 534 return NULL; 535 } 536 537 if (last == NULL) 538 LIST_INSERT_HEAD(list, ent, lp); 539 else 540 LIST_INSERT_AFTER(last, ent, lp); 541 last = ent; 542 543 swallow_whitespace(); 544 545 if (!*str) { 546 free(ent->name); 547 free(ent); 548 destroy_conf_branch(list); 549 parse_err("missing semicolon (';')"); 550 return NULL; /* missing semi-colon */ 551 } else 552 s = NULL; 553 554 if (*str != ';') { 555 free(ent->name); 556 destroy_conf_branch(ent->list); 557 free(ent); 558 parse_err("garbage between closing brace ('}') and " 559 "semicolon (';')"); 560 return NULL; 561 } 562 563 *str++ = '\0';; 564 continue; 565 } else { 566 destroy_conf_branch(list); 567 parse_err("conf parser barfed!"); 568 return NULL; /* some kind of syntax error */ 569 } 570 570 } 571 571 … … 576 576 * place entries starting after the 'after' point */ 577 577 static conf_entry_t *merge_into_conf(conf_list_t *big, conf_entry_t *after, 578 conf_list_t *little) {578 conf_list_t *little) { 579 579 conf_entry_t *last = after; 580 580 conf_entry_t *ep; 581 581 582 582 while (!LIST_EMPTY(little)) { 583 ep = LIST_FIRST(little);584 LIST_REMOVE(ep, lp);585 if (last == NULL)586 LIST_INSERT_HEAD(big, ep, lp);587 else588 LIST_INSERT_AFTER(last, ep, lp);589 ep->parent = big;590 last = ep;583 ep = LIST_FIRST(little); 584 LIST_REMOVE(ep, lp); 585 if (last == NULL) 586 LIST_INSERT_HEAD(big, ep, lp); 587 else 588 LIST_INSERT_AFTER(last, ep, lp); 589 ep->parent = big; 590 last = ep; 591 591 } 592 592 … … 605 605 606 606 while (*str) { 607 if (*str == '"') {608 str++;609 while (*str) {610 if (*str == '\\') {611 str++;612 if (*str == '\0') {613 *s++ = '\\';614 break;615 }616 switch (*str) {617 case 'a':618 *s++ = '\007'; /* BEL character (^G) */619 break;620 case 'b':621 *s++ = '\010'; /* Backspace character (^H) */622 break;623 case 'f':624 *s++ = '\014'; /* Form-feed character (^L) */625 break;626 case 'n':627 *s++ = '\012'; /* Newline character (^J) */628 break;629 case 'r':630 *s++ = '\015'; /* Carriage return character (^M) */631 break;632 case 't':633 *s++ = '\011'; /* Tab character (^I) */634 break;635 case 'v':636 *s++ = '\013'; /* Vertical tab character (^K) */637 break;638 default:639 *s++ = *str;640 }641 str++;642 } else if (*str == '"') {643 str++;644 break; /* break out of the inner loop, the outer one will645 pick up the slack. */646 } else647 *s++ = *str++;648 }649 } else if (isspace(*str)) {650 *s++ = ' ';651 while (isspace(*str))652 str++;653 if (!*str)654 s--; /* let that last space get trimmed down below. */655 } else656 *s++ = *str++;607 if (*str == '"') { 608 str++; 609 while (*str) { 610 if (*str == '\\') { 611 str++; 612 if (*str == '\0') { 613 *s++ = '\\'; 614 break; 615 } 616 switch (*str) { 617 case 'a': 618 *s++ = '\007'; /* BEL character (^G) */ 619 break; 620 case 'b': 621 *s++ = '\010'; /* Backspace character (^H) */ 622 break; 623 case 'f': 624 *s++ = '\014'; /* Form-feed character (^L) */ 625 break; 626 case 'n': 627 *s++ = '\012'; /* Newline character (^J) */ 628 break; 629 case 'r': 630 *s++ = '\015'; /* Carriage return character (^M) */ 631 break; 632 case 't': 633 *s++ = '\011'; /* Tab character (^I) */ 634 break; 635 case 'v': 636 *s++ = '\013'; /* Vertical tab character (^K) */ 637 break; 638 default: 639 *s++ = *str; 640 } 641 str++; 642 } else if (*str == '"') { 643 str++; 644 break; /* break out of the inner loop, the outer one will 645 pick up the slack. */ 646 } else 647 *s++ = *str++; 648 } 649 } else if (isspace(*str)) { 650 *s++ = ' '; 651 while (isspace(*str)) 652 str++; 653 if (!*str) 654 s--; /* let that last space get trimmed down below. */ 655 } else 656 *s++ = *str++; 657 657 } 658 658 -
trunk/ithildin/source/contrib/fmtcheck.c
r576 r578 37 37 38 38 enum __e_fmtcheck_types { 39 FMTCHECK_START,40 FMTCHECK_SHORT,41 FMTCHECK_INT,42 FMTCHECK_LONG,43 FMTCHECK_QUAD,44 FMTCHECK_SHORTPOINTER,45 FMTCHECK_INTPOINTER,46 FMTCHECK_LONGPOINTER,47 FMTCHECK_QUADPOINTER,48 FMTCHECK_DOUBLE,49 FMTCHECK_LONGDOUBLE,50 FMTCHECK_STRING,51 FMTCHECK_WIDTH,52 FMTCHECK_PRECISION,53 FMTCHECK_DONE,54 FMTCHECK_UNKNOWN39 FMTCHECK_START, 40 FMTCHECK_SHORT, 41 FMTCHECK_INT, 42 FMTCHECK_LONG, 43 FMTCHECK_QUAD, 44 FMTCHECK_SHORTPOINTER, 45 FMTCHECK_INTPOINTER, 46 FMTCHECK_LONGPOINTER, 47 FMTCHECK_QUADPOINTER, 48 FMTCHECK_DOUBLE, 49 FMTCHECK_LONGDOUBLE, 50 FMTCHECK_STRING, 51 FMTCHECK_WIDTH, 52 FMTCHECK_PRECISION, 53 FMTCHECK_DONE, 54 FMTCHECK_UNKNOWN 55 55 }; 56 56 typedef enum __e_fmtcheck_types EFT; 57 57 58 58 #define RETURN(pf,f,r) do { \ 59 *(pf) = (f); \60 return r; \61 } /*NOTREACHED*/ /*CONSTCOND*/ while (0)59 *(pf) = (f); \ 60 return r; \ 61 } /*NOTREACHED*/ /*CONSTCOND*/ while (0) 62 62 63 63 static EFT 64 64 get_next_format_from_precision(const char **pf) 65 65 { 66 intsh, lg, quad, longdouble;67 const char*f;68 69 sh = lg = quad = longdouble = 0;70 71 f = *pf;72 switch (*f) {73 case 'h':74 f++;75 sh = 1;76 break;77 case 'l':78 f++;79 if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);80 if (*f == 'l') {81 f++;82 quad = 1;83 } else {84 lg = 1;85 }86 break;87 case 'q':88 f++;89 quad = 1;90 break;91 case 'L':92 f++;93 longdouble = 1;94 break;95 default:96 break;97 }98 if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);99 if (strchr("diouxX", *f)) {100 if (longdouble)101 RETURN(pf,f,FMTCHECK_UNKNOWN);102 if (lg)103 RETURN(pf,f,FMTCHECK_LONG);104 if (quad)105 RETURN(pf,f,FMTCHECK_QUAD);106 RETURN(pf,f,FMTCHECK_INT);107 }108 if (*f == 'n') {109 if (longdouble)110 RETURN(pf,f,FMTCHECK_UNKNOWN);111 if (sh)112 RETURN(pf,f,FMTCHECK_SHORTPOINTER);113 if (lg)114 RETURN(pf,f,FMTCHECK_LONGPOINTER);115 if (quad)116 RETURN(pf,f,FMTCHECK_QUADPOINTER);117 RETURN(pf,f,FMTCHECK_INTPOINTER);118 }119 if (strchr("DOU", *f)) {120 if (sh + lg + quad + longdouble)121 RETURN(pf,f,FMTCHECK_UNKNOWN);122 RETURN(pf,f,FMTCHECK_LONG);123 }124 if (strchr("eEfg", *f)) {125 if (longdouble)126 RETURN(pf,f,FMTCHECK_LONGDOUBLE);127 if (sh + lg + quad)128 RETURN(pf,f,FMTCHECK_UNKNOWN);129 RETURN(pf,f,FMTCHECK_DOUBLE);130 }131 if (*f == 'c') {132 if (sh + lg + quad + longdouble)133 RETURN(pf,f,FMTCHECK_UNKNOWN);134 RETURN(pf,f,FMTCHECK_INT);135 }136 if (*f == 's') {137 if (sh + lg + quad + longdouble)138 RETURN(pf,f,FMTCHECK_UNKNOWN);139 RETURN(pf,f,FMTCHECK_STRING);140 }141 if (*f == 'p') {142 if (sh + lg + quad + longdouble)143 RETURN(pf,f,FMTCHECK_UNKNOWN);144 RETURN(pf,f,FMTCHECK_LONG);145 }146 RETURN(pf,f,FMTCHECK_UNKNOWN);147 /*NOTREACHED*/66 int sh, lg, quad, longdouble; 67 const char *f; 68 69 sh = lg = quad = longdouble = 0; 70 71 f = *pf; 72 switch (*f) { 73 case 'h': 74 f++; 75 sh = 1; 76 break; 77 case 'l': 78 f++; 79 if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); 80 if (*f == 'l') { 81 f++; 82 quad = 1; 83 } else { 84 lg = 1; 85 } 86 break; 87 case 'q': 88 f++; 89 quad = 1; 90 break; 91 case 'L': 92 f++; 93 longdouble = 1; 94 break; 95 default: 96 break; 97 } 98 if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); 99 if (strchr("diouxX", *f)) { 100 if (longdouble) 101 RETURN(pf,f,FMTCHECK_UNKNOWN); 102 if (lg) 103 RETURN(pf,f,FMTCHECK_LONG); 104 if (quad) 105 RETURN(pf,f,FMTCHECK_QUAD); 106 RETURN(pf,f,FMTCHECK_INT); 107 } 108 if (*f == 'n') { 109 if (longdouble) 110 RETURN(pf,f,FMTCHECK_UNKNOWN); 111 if (sh) 112 RETURN(pf,f,FMTCHECK_SHORTPOINTER); 113 if (lg) 114 RETURN(pf,f,FMTCHECK_LONGPOINTER); 115 if (quad) 116 RETURN(pf,f,FMTCHECK_QUADPOINTER); 117 RETURN(pf,f,FMTCHECK_INTPOINTER); 118 } 119 if (strchr("DOU", *f)) { 120 if (sh + lg + quad + longdouble) 121 RETURN(pf,f,FMTCHECK_UNKNOWN); 122 RETURN(pf,f,FMTCHECK_LONG); 123 } 124 if (strchr("eEfg", *f)) { 125 if (longdouble) 126 RETURN(pf,f,FMTCHECK_LONGDOUBLE); 127 if (sh + lg + quad) 128 RETURN(pf,f,FMTCHECK_UNKNOWN); 129 RETURN(pf,f,FMTCHECK_DOUBLE); 130 } 131 if (*f == 'c') { 132 if (sh + lg + quad + longdouble) 133 RETURN(pf,f,FMTCHECK_UNKNOWN); 134 RETURN(pf,f,FMTCHECK_INT); 135 } 136 if (*f == 's') { 137 if (sh + lg + quad + longdouble) 138 RETURN(pf,f,FMTCHECK_UNKNOWN); 139 RETURN(pf,f,FMTCHECK_STRING); 140 } 141 if (*f == 'p') { 142 if (sh + lg + quad + longdouble) 143 RETURN(pf,f,FMTCHECK_UNKNOWN); 144 RETURN(pf,f,FMTCHECK_LONG); 145 } 146 RETURN(pf,f,FMTCHECK_UNKNOWN); 147 /*NOTREACHED*/ 148 148 } 149 149 … … 151 151 get_next_format_from_width(const char **pf) 152 152 { 153 const char*f;154 155 f = *pf;156 if (*f == '.') {157 f++;158 if (*f == '*') {159 RETURN(pf,f,FMTCHECK_PRECISION);160 }161 /* eat any precision (empty is allowed) */162 while (isdigit(*f)) f++;163 if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);164 }165 RETURN(pf,f,get_next_format_from_precision(pf));166 /*NOTREACHED*/153 const char *f; 154 155 f = *pf; 156 if (*f == '.') { 157 f++; 158 if (*f == '*') { 159 RETURN(pf,f,FMTCHECK_PRECISION); 160 } 161 /* eat any precision (empty is allowed) */ 162 while (isdigit(*f)) f++; 163 if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); 164 } 165 RETURN(pf,f,get_next_format_from_precision(pf)); 166 /*NOTREACHED*/ 167 167 } 168 168 … … 170 170 get_next_format(const char **pf, EFT eft) 171 171 { 172 intinfmt;173 const char*f;174 175 if (eft == FMTCHECK_WIDTH) {176 (*pf)++;177 return get_next_format_from_width(pf);178 } else if (eft == FMTCHECK_PRECISION) {179 (*pf)++;180 return get_next_format_from_precision(pf);181 }182 183 f = *pf;184 infmt = 0;185 while (!infmt) {186 f = strchr(f, '%');187 if (f == NULL)188 RETURN(pf,f,FMTCHECK_DONE);189 f++;190 if (!*f)191 RETURN(pf,f,FMTCHECK_UNKNOWN);192 if (*f != '%')193 infmt = 1;194 else195 f++;196 }197 198 /* Eat any of the flags */199 while (*f && (strchr("#0- +", *f)))200 f++;201 202 if (*f == '*') {203 RETURN(pf,f,FMTCHECK_WIDTH);204 }205 /* eat any width */206 while (isdigit(*f)) f++;207 if (!*f) {208 RETURN(pf,f,FMTCHECK_UNKNOWN);209 }210 211 RETURN(pf,f,get_next_format_from_width(pf));212 /*NOTREACHED*/172 int infmt; 173 const char *f; 174 175 if (eft == FMTCHECK_WIDTH) { 176 (*pf)++; 177 return get_next_format_from_width(pf); 178 } else if (eft == FMTCHECK_PRECISION) { 179 (*pf)++; 180 return get_next_format_from_precision(pf); 181 } 182 183 f = *pf; 184 infmt = 0; 185 while (!infmt) { 186 f = strchr(f, '%'); 187 if (f == NULL) 188 RETURN(pf,f,FMTCHECK_DONE); 189 f++; 190 if (!*f) 191 RETURN(pf,f,FMTCHECK_UNKNOWN); 192 if (*f != '%') 193 infmt = 1; 194 else 195 f++; 196 } 197 198 /* Eat any of the flags */ 199 while (*f && (strchr("#0- +", *f))) 200 f++; 201 202 if (*f == '*') { 203 RETURN(pf,f,FMTCHECK_WIDTH); 204 } 205 /* eat any width */ 206 while (isdigit(*f)) f++; 207 if (!*f) { 208 RETURN(pf,f,FMTCHECK_UNKNOWN); 209 } 210 211 RETURN(pf,f,get_next_format_from_width(pf)); 212 /*NOTREACHED*/ 213 213 } 214 214 … … 216 216 fmtcheck(const char *f1, const char *f2) 217 217 { 218 const char*f1p, *f2p;219 EFTf1t, f2t;220 221 if (!f1) return f2;222 223 f1p = f1;224 f1t = FMTCHECK_START;225 f2p = f2;226 f2t = FMTCHECK_START;227 while ((f1t = get_next_format(&f1p, f1t)) != FMTCHECK_DONE) {228 if (f1t == FMTCHECK_UNKNOWN)229 return f2;230 f2t = get_next_format(&f2p, f2t);231 if (f1t != f2t)232 return f2;233 }234 return f1;218 const char *f1p, *f2p; 219 EFT f1t, f2t; 220 221 if (!f1) return f2; 222 223 f1p = f1; 224 f1t = FMTCHECK_START; 225 f2p = f2; 226 f2t = FMTCHECK_START; 227 while ((f1t = get_next_format(&f1p, f1t)) != FMTCHECK_DONE) { 228 if (f1t == FMTCHECK_UNKNOWN) 229 return f2; 230 f2t = get_next_format(&f2p, f2t); 231 if (f1t != f2t) 232 return f2; 233 } 234 return f1; 235 235 } 236 236 /* vi:set ts=8 sts=4 sw=4 tw=76 et: */ -
trunk/ithildin/source/contrib/gailib.c
r576 r578 67 67 * Error return codes from getaddrinfo() 68 68 */ 69 #define EAI_ADDRFAMILY 1/* address family for hostname not supported */70 #define EAI_AGAIN 2/* temporary failure in name resolution */71 #define EAI_BADFLAGS 3/* invalid value for ai_flags */72 #define EAI_FAIL 4/* non-recoverable failure in name resolution */73 #define EAI_FAMILY 5/* ai_family not supported */74 #define EAI_MEMORY 6/* memory allocation failure */75 #define EAI_NODATA 7/* no address associated with hostname */76 #define EAI_NONAME 8/* hostname nor servname provided, or not known */77 #define EAI_SERVICE 9/* servname not supported for ai_socktype */78 #define EAI_SOCKTYPE 10/* ai_socktype not supported */79 #define EAI_SYSTEM 11/* system error returned in errno */80 #define EAI_BADHINTS 1281 #define EAI_PROTOCOL 1382 #define EAI_MAX 1469 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 70 #define EAI_AGAIN 2 /* temporary failure in name resolution */ 71 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 72 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 73 #define EAI_FAMILY 5 /* ai_family not supported */ 74 #define EAI_MEMORY 6 /* memory allocation failure */ 75 #define EAI_NODATA 7 /* no address associated with hostname */ 76 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 77 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 78 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 79 #define EAI_SYSTEM 11 /* system error returned in errno */ 80 #define EAI_BADHINTS 12 81 #define EAI_PROTOCOL 13 82 #define EAI_MAX 14 83 83 84 84 /* 85 85 * Flag values for getaddrinfo() 86 86 */ 87 #define AI_PASSIVE0x00000001 /* get address to use bind() */88 #define AI_CANONNAME0x00000002 /* fill ai_canonname */89 #define AI_NUMERICHOST0x00000004 /* prevent name resolution */87 #define AI_PASSIVE 0x00000001 /* get address to use bind() */ 88 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ 89 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ 90 90 /* valid flags for addrinfo */ 91 #define AI_MASK(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)92 93 #define AI_ALL0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */94 #define AI_V4MAPPED_CFG0x00000200 /* accept IPv4-mapped if kernel supports */95 #define AI_ADDRCONFIG0x00000400 /* only if any address is assigned */96 #define AI_V4MAPPED0x00000800 /* accept IPv4-mapped IPv6 address */91 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) 92 93 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ 94 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ 95 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ 96 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ 97 97 /* special recommended flags for getipnodebyname */ 98 #define AI_DEFAULT(AI_V4MAPPED_CFG | AI_ADDRCONFIG)98 #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 99 99 100 100 /* 101 101 * Constants for getnameinfo() 102 102 */ 103 #define NI_MAXHOST1025104 #define NI_MAXSERV32103 #define NI_MAXHOST 1025 104 #define NI_MAXSERV 32 105 105 106 106 /* 107 107 * Flag values for getnameinfo() 108 108 */ 109 #define NI_NOFQDN0x00000001110 #define NI_NUMERICHOST0x00000002111 #define NI_NAMEREQD0x00000004112 #define NI_NUMERICSERV0x00000008113 #define NI_DGRAM0x00000010109 #define NI_NOFQDN 0x00000001 110 #define NI_NUMERICHOST 0x00000002 111 #define NI_NAMEREQD 0x00000004 112 #define NI_NUMERICSERV 0x00000008 113 #define NI_DGRAM 0x00000010 114 114 115 115 struct addrinfo__compat { 116 int ai_flags;/* AI_PASSIVE, AI_CANONNAME */117 int ai_family;/* PF_xxx */118 int ai_socktype;/* SOCK_xxx */119 int ai_protocol;/* 0 or IPPROTO_xxx for IPv4 and IPv6 */120 size_t ai_addrlen;/* length of ai_addr */121 char *ai_canonname;/* canonical name for hostname */122 struct sockaddr *ai_addr;/* binary address */123 struct addrinfo *ai_next;/* next structure in linked list */116 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 117 int ai_family; /* PF_xxx */ 118 int ai_socktype; /* SOCK_xxx */ 119 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 120 size_t ai_addrlen; /* length of ai_addr */ 121 char *ai_canonname; /* canonical name for hostname */ 122 struct sockaddr *ai_addr; /* binary address */ 123 struct addrinfo *ai_next; /* next structure in linked list */ 124 124 }; 125 125 126 126 int getaddrinfo__compat(const char *hostname, const char *servname, 127 const struct addrinfo *hints, struct addrinfo **res);127 const struct addrinfo *hints, struct addrinfo **res); 128 128 129 129 int getnameinfo__compat(const struct sockaddr *sa, size_t salen, 130 char *host, size_t hostlen, char *serv, size_t servlen, int flags);130 char *host, size_t hostlen, char *serv, size_t servlen, int flags); 131 131 132 132 const char *gai_strerror__compat(int ecode); 133 133 void freeaddrinfo__compat(struct addrinfo *ai); 134 134 const char *inet_ntop__compat(int af, const void *addr, char *numaddr, 135 size_t numaddr_len);135 size_t numaddr_len); 136 136 int inet_pton__compat(int af, const char *hostname, void *pton); 137 137 … … 152 152 # ifdef INET6 153 153 # define SA_LEN(sa) \ 154 (((sa)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \155 : sizeof(struct sockaddr))154 (((sa)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ 155 : sizeof(struct sockaddr)) 156 156 # else 157 157 /* by tradition, sizeof(struct sockaddr) covers most of the sockaddrs */ 158 # define SA_LEN(sa) (sizeof(struct sockaddr))158 # define SA_LEN(sa) (sizeof(struct sockaddr)) 159 159 # endif 160 160 # endif … … 176 176 177 177 #ifndef IN_MULTICAST 178 # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)179 # define IN_MULTICAST(i) IN_CLASSD(i)178 # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) 179 # define IN_MULTICAST(i) IN_CLASSD(i) 180 180 #endif 181 181 … … 218 218 static const char in_addrany[] = { 0, 0, 0, 0 }; 219 219 static const char in6_addrany[] = { 220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 221 221 }; 222 222 static const char in_loopback[] = { 127, 0, 0, 1 }; 223 223 static const char in6_loopback[] = { 224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 225 225 }; 226 226 227 227 struct sockinet { 228 unsigned charsi_len;229 unsigned charsi_family;230 unsigned shortsi_port;228 unsigned char si_len; 229 unsigned char si_family; 230 unsigned short si_port; 231 231 }; 232 232 233 233 static struct afd { 234 int a_af;235 int a_addrlen;236 int a_socklen;237 int a_off;238 const char *a_addrany;239 const char *a_loopback; 234 int a_af; 235 int a_addrlen; 236 int a_socklen; 237 int a_off; 238 const char *a_addrany; 239 const char *a_loopback; 240 240 } afdl [] = { 241 241 #ifdef INET6 242 242 #define N_INET6 0 243 {PF_INET6, sizeof(struct in6_addr),244 sizeof(struct sockaddr_in6),245 offsetof(struct sockaddr_in6, sin6_addr),246 in6_addrany, in6_loopback},243 {PF_INET6, sizeof(struct in6_addr), 244 sizeof(struct sockaddr_in6), 245 offsetof(struct sockaddr_in6, sin6_addr), 246 in6_addrany, in6_loopback}, 247 247 #define N_INET 1 248 248 #else 249 249 #define N_INET 0 250 250 #endif 251 {PF_INET, sizeof(struct in_addr),252 sizeof(struct sockaddr_in),253 offsetof(struct sockaddr_in, sin_addr),254 in_addrany, in_loopback},255 {0, 0, 0, 0, NULL, NULL},251 {PF_INET, sizeof(struct in_addr), 252 sizeof(struct sockaddr_in), 253 offsetof(struct sockaddr_in, sin_addr), 254 in_addrany, in_loopback}, 255 {0, 0, 0, 0, NULL, NULL}, 256 256 }; 257 257 258 258 #ifdef INET6 259 #define PTON_MAX 16260 #else 261 #define PTON_MAX 4259 #define PTON_MAX 16 260 #else 261 #define PTON_MAX 4 262 262 #endif 263 263 264 264 static int get_name (const char *, struct afd *, 265 struct addrinfo **, char *, struct addrinfo *,266 int);265 struct addrinfo **, char *, struct addrinfo *, 266 int); 267 267 static int get_addr (const char *, int, struct addrinfo **, 268 struct addrinfo *, int);268 struct addrinfo *, int); 269 269 static int str_isnumber (const char *); 270 270 271 271 static char *ai_errlist[] = { 272 "success.",273 "address family for hostname not supported.",/* EAI_ADDRFAMILY */274 "temporary failure in name resolution.",/* EAI_AGAIN */275 "invalid value for ai_flags.",/* EAI_BADFLAGS */276 "non-recoverable failure in name resolution.",/* EAI_FAIL */277 "ai_family not supported.",/* EAI_FAMILY */278 "memory allocation failure.",/* EAI_MEMORY */279 "no address associated with hostname.",/* EAI_NODATA */280 "hostname nor servname provided, or not known.",/* EAI_NONAME */281 "servname not supported for ai_socktype.",/* EAI_SERVICE */282 "ai_socktype not supported.",/* EAI_SOCKTYPE */283 "system error returned in errno.",/* EAI_SYSTEM */284 "invalid value for hints.", /* EAI_BADHINTS*/285 "resolved protocol is unknown.",/* EAI_PROTOCOL */286 "unknown error.",/* EAI_MAX */272 "success.", 273 "address family for hostname not supported.", /* EAI_ADDRFAMILY */ 274 "temporary failure in name resolution.", /* EAI_AGAIN */ 275 "invalid value for ai_flags.", /* EAI_BADFLAGS */ 276 "non-recoverable failure in name resolution.", /* EAI_FAIL */ 277 "ai_family not supported.", /* EAI_FAMILY */ 278 "memory allocation failure.", /* EAI_MEMORY */ 279 "no address associated with hostname.", /* EAI_NODATA */ 280 "hostname nor servname provided, or not known.",/* EAI_NONAME */ 281 "servname not supported for ai_socktype.", /* EAI_SERVICE */ 282 "ai_socktype not supported.", /* EAI_SOCKTYPE */ 283 "system error returned in errno.", /* EAI_SYSTEM */ 284 "invalid value for hints.", /* EAI_BADHINTS */ 285 "resolved protocol is unknown.", /* EAI_PROTOCOL */ 286 "unknown error.", /* EAI_MAX */ 287 287 }; 288 288 289 289 #define GET_CANONNAME(ai, str) \ 290 290 if (pai->ai_flags & AI_CANONNAME) {\ 291 if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\292 strcpy((ai)->ai_canonname, (str));\293 } else {\294 error = EAI_MEMORY;\295 goto free;\296 }\291 if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\ 292 strcpy((ai)->ai_canonname, (str));\ 293 } else {\ 294 error = EAI_MEMORY;\ 295 goto free;\ 296 }\ 297 297 } 298 298 299 299 #define GET_AI(ai, afd, addr, port) {\ 300 char *p;\301 if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\302 ((afd)->a_socklen)))\303 == NULL) {\304 error = EAI_MEMORY;\305 goto free;\306 }\307 memcpy(ai, pai, sizeof(struct addrinfo));\308 (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\309 memset((ai)->ai_addr, 0, (afd)->a_socklen);\310 SET_SA_LEN((ai)->ai_addr, (ai)->ai_addrlen = (afd)->a_socklen);\311 (ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\312 ((struct sockinet *)(ai)->ai_addr)->si_port = port;\313 p = (char *)((ai)->ai_addr);\314 memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\300 char *p;\ 301 if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ 302 ((afd)->a_socklen)))\ 303 == NULL) {\ 304 error = EAI_MEMORY;\ 305 goto free;\ 306 }\ 307 memcpy(ai, pai, sizeof(struct addrinfo));\ 308 (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ 309 memset((ai)->ai_addr, 0, (afd)->a_socklen);\ 310 SET_SA_LEN((ai)->ai_addr, (ai)->ai_addrlen = (afd)->a_socklen);\ 311 (ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\ 312 ((struct sockinet *)(ai)->ai_addr)->si_port = port;\ 313 p = (char *)((ai)->ai_addr);\ 314 memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\ 315 315 } 316 316 … … 319 319 const char *gai_strerror__compat(int ecode) 320 320 { 321 if (ecode < 0 || ecode > EAI_MAX)322 ecode = EAI_MAX;323 return ai_errlist[ecode];321 if (ecode < 0 || ecode > EAI_MAX) 322 ecode = EAI_MAX; 323 return ai_errlist[ecode]; 324 324 } 325 325 326 326 void freeaddrinfo__compat(struct addrinfo *ai) 327 327 { 328 struct addrinfo *next;329 330 do {331 next = ai->ai_next;332 if (ai->ai_canonname)333 free(ai->ai_canonname);334 /* no need to free(ai->ai_addr) */335 free(ai);336 } while ((ai = next) != NULL);328 struct addrinfo *next; 329 330 do { 331 next = ai->ai_next; 332 if (ai->ai_canonname) 333 free(ai->ai_canonname); 334 /* no need to free(ai->ai_addr) */ 335 free(ai); 336 } while ((ai = next) != NULL); 337 337 } 338 338 339 339 static int str_isnumber(const char *p) 340 340 { 341 char *q = (char *)p;342 while (*q) {343 if (! isdigit(*q))344 return NO;345 q++;346 }347 return YES;341 char *q = (char *)p; 342 while (*q) { 343 if (! isdigit(*q)) 344 return NO; 345 q++; 346 } 347 return YES; 348 348 } 349 349 350 350 int inet_pton__compat(int af, const char *hostname, void *pton) 351 351 { 352 struct in_addr in;352 struct in_addr in; 353 353 354 354 #ifdef HAVE_INET_ATON 355 if (!inet_aton(hostname, &in))356 return 0;357 #else 358 int d1, d2, d3, d4;359 char ch;360 361 if (sscanf(hostname, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 &&362 0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 &&363 0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) {364 in.s_addr = htonl(365 ((long) d1 << 24) | ((long) d2 << 16) |366 ((long) d3 << 8) | ((long) d4 << 0));367 }368 else {369 return 0;370 }371 #endif 372 memcpy(pton, &in, sizeof(in));373 return 1;355 if (!inet_aton(hostname, &in)) 356 return 0; 357 #else 358 int d1, d2, d3, d4; 359 char ch; 360 361 if (sscanf(hostname, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 && 362 0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 && 363 0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) { 364 in.s_addr = htonl( 365 ((long) d1 << 24) | ((long) d2 << 16) | 366 ((long) d3 << 8) | ((long) d4 << 0)); 367 } 368 else { 369 return 0; 370 } 371 #endif 372 memcpy(pton, &in, sizeof(in)); 373 return 1; 374 374 } 375 375 376 376 int getaddrinfo__compat(const char *hostname, const char *servname, 377 const struct addrinfo *hints, struct addrinfo **res)377 const struct addrinfo *hints, struct addrinfo **res) 378 378 { 379 struct addrinfo sentinel;380 struct addrinfo *top = NULL;381 struct addrinfo *cur;382 int i, error = 0;383 char pton[PTON_MAX];384 struct addrinfo ai;385 struct addrinfo *pai;386 unsigned short port;387 388 /* initialize file static vars */389 sentinel.ai_next = NULL;390 cur = &sentinel;391 pai = &ai;392 pai->ai_flags = 0;393 pai->ai_family = PF_UNSPEC;394 pai->ai_socktype = ANY;395 pai->ai_protocol = ANY;396 pai->ai_addrlen = 0;397 pai->ai_canonname = NULL;398 pai->ai_addr = NULL;399 pai->ai_next = NULL;400 port = ANY;401 402 if (hostname == NULL && servname == NULL)403 return EAI_NONAME;404 if (hints) {405 /* error check for hints */406 if (hints->ai_addrlen || hints->ai_canonname ||407 hints->ai_addr || hints->ai_next)408 ERR(EAI_BADHINTS); /* xxx */409 if (hints->ai_flags & ~AI_MASK)410 ERR(EAI_BADFLAGS);411 switch (hints->ai_family) {412 case PF_UNSPEC:413 case PF_INET:414 #ifdef INET6 415 case PF_INET6:416 #endif 417 break;418 default:419 ERR(EAI_FAMILY);420 }421 memcpy(pai, hints, sizeof(*pai));422 switch (pai->ai_socktype) {423 case ANY:424 switch (pai->ai_protocol) {425 case ANY:426 break;427 case IPPROTO_UDP:428 pai->ai_socktype = SOCK_DGRAM;429 break;430 case IPPROTO_TCP:431 pai->ai_socktype = SOCK_STREAM;432 break;433 default:379 struct addrinfo sentinel; 380 struct addrinfo *top = NULL; 381 struct addrinfo *cur; 382 int i, error = 0; 383 char pton[PTON_MAX]; 384 struct addrinfo ai; 385 struct addrinfo *pai; 386 unsigned short port; 387 388 /* initialize file static vars */ 389 sentinel.ai_next = NULL; 390 cur = &sentinel; 391 pai = &ai; 392 pai->ai_flags = 0; 393 pai->ai_family = PF_UNSPEC; 394 pai->ai_socktype = ANY; 395 pai->ai_protocol = ANY; 396 pai->ai_addrlen = 0; 397 pai->ai_canonname = NULL; 398 pai->ai_addr = NULL; 399 pai->ai_next = NULL; 400 port = ANY; 401 402 if (hostname == NULL && servname == NULL) 403 return EAI_NONAME; 404 if (hints) { 405 /* error check for hints */ 406 if (hints->ai_addrlen || hints->ai_canonname || 407 hints->ai_addr || hints->ai_next) 408 ERR(EAI_BADHINTS); /* xxx */ 409 if (hints->ai_flags & ~AI_MASK) 410 ERR(EAI_BADFLAGS); 411 switch (hints->ai_family) { 412 case PF_UNSPEC: 413 case PF_INET: 414 #ifdef INET6 415 case PF_INET6: 416 #endif 417 break; 418 default: 419 ERR(EAI_FAMILY); 420 } 421 memcpy(pai, hints, sizeof(*pai)); 422 switch (pai->ai_socktype) { 423 case ANY: 424 switch (pai->ai_protocol) { 425 case ANY: 426 break; 427 case IPPROTO_UDP: 428 pai->ai_socktype = SOCK_DGRAM; 429 break; 430 case IPPROTO_TCP: 431 pai->ai_socktype = SOCK_STREAM; 432 break; 433 default: 434 434 #if defined(SOCK_RAW) 435 pai->ai_socktype = SOCK_RAW;436 #endif 437 break;438 }439 break;435 pai->ai_socktype = SOCK_RAW; 436 #endif 437 break; 438 } 439 break; 440 440 #if defined(SOCK_RAW) 441 case SOCK_RAW:442 break;443 #endif 444 case SOCK_DGRAM:445 if (pai->ai_protocol != IPPROTO_UDP &&446 pai->ai_protocol != ANY)447 ERR(EAI_BADHINTS);/*xxx*/448 pai->ai_protocol = IPPROTO_UDP;449 break;450 case SOCK_STREAM:451 if (pai->ai_protocol != IPPROTO_TCP &&452 pai->ai_protocol != ANY)453 ERR(EAI_BADHINTS);/*xxx*/454 pai->ai_protocol = IPPROTO_TCP;455 break;456 default:457 ERR(EAI_SOCKTYPE);458 break;459 }460 }461 462 /*463 * service port464 */465 if (servname) {466 if (str_isnumber(servname)) {467 if (pai->ai_socktype == ANY) {468 /* caller accept *ANY* socktype */469 pai->ai_socktype = SOCK_DGRAM;470 pai->ai_protocol = IPPROTO_UDP;471 }472 port = htons((unsigned short)atoi(servname));473 } else {474 struct servent *sp;475 char *proto;476 477 proto = NULL;478 switch (pai->ai_socktype) {479 case ANY:480 proto = NULL;481 break;482 case SOCK_DGRAM:483 proto = "udp";484 break;485 case SOCK_STREAM:486 proto = "tcp";487 break;488 default:489 fprintf(stderr, "panic!\n");490 break;491 }492 if ((sp = getservbyname(servname, proto)) == NULL)493 ERR(EAI_SERVICE);494 port = sp->s_port;495 if (pai->ai_socktype == ANY) {496 if (strcmp(sp->s_proto, "udp") == 0) {497 pai->ai_socktype = SOCK_DGRAM;498 pai->ai_protocol = IPPROTO_UDP;499 } else if (strcmp(sp->s_proto, "tcp") == 0) {500 pai->ai_socktype = SOCK_STREAM;501 pai->ai_protocol = IPPROTO_TCP;502 } else503 ERR(EAI_PROTOCOL);/*xxx*/504 }505 }506 }507 508 /*509 * hostname == NULL.510 * passive socket -> anyaddr (0.0.0.0 or ::)511 * non-passive socket -> localhost (127.0.0.1 or ::1)512 */513 if (hostname == NULL) {514 struct afd *afd;515 int s;516 517 for (afd = &afdl[0]; afd->a_af; afd++) {518 if (!(pai->ai_family == PF_UNSPEC519 || pai->ai_family == afd->a_af)) {520 continue;521 }522 523 /*524 * filter out AFs that are not supported by the kernel525 * XXX errno?526 */527 s = socket(afd->a_af, SOCK_DGRAM, 0);528 if (s < 0)529 continue;441 case SOCK_RAW: 442 break; 443 #endif 444 case SOCK_DGRAM: 445 if (pai->ai_protocol != IPPROTO_UDP && 446 pai->ai_protocol != ANY) 447 ERR(EAI_BADHINTS); /*xxx*/ 448 pai->ai_protocol = IPPROTO_UDP; 449 break; 450 case SOCK_STREAM: 451 if (pai->ai_protocol != IPPROTO_TCP && 452 pai->ai_protocol != ANY) 453 ERR(EAI_BADHINTS); /*xxx*/ 454 pai->ai_protocol = IPPROTO_TCP; 455 break; 456 default: 457 ERR(EAI_SOCKTYPE); 458 break; 459 } 460 } 461 462 /* 463 * service port 464 */ 465 if (servname) { 466 if (str_isnumber(servname)) { 467 if (pai->ai_socktype == ANY) { 468 /* caller accept *ANY* socktype */ 469 pai->ai_socktype = SOCK_DGRAM; 470 pai->ai_protocol = IPPROTO_UDP; 471 } 472 port = htons((unsigned short)atoi(servname)); 473 } else { 474 struct servent *sp; 475 char *proto; 476 477 proto = NULL; 478 switch (pai->ai_socktype) { 479 case ANY: 480 proto = NULL; 481 break; 482 case SOCK_DGRAM: 483 proto = "udp"; 484 break; 485 case SOCK_STREAM: 486 proto = "tcp"; 487 break; 488 default: 489 fprintf(stderr, "panic!\n"); 490 break; 491 } 492 if ((sp = getservbyname(servname, proto)) == NULL) 493 ERR(EAI_SERVICE); 494 port = sp->s_port; 495 if (pai->ai_socktype == ANY) { 496 if (strcmp(sp->s_proto, "udp") == 0) { 497 pai->ai_socktype = SOCK_DGRAM; 498 pai->ai_protocol = IPPROTO_UDP; 499 } else if (strcmp(sp->s_proto, "tcp") == 0) { 500 pai->ai_socktype = SOCK_STREAM; 501 pai->ai_protocol = IPPROTO_TCP; 502 } else 503 ERR(EAI_PROTOCOL); /*xxx*/ 504 } 505 } 506 } 507 508 /* 509 * hostname == NULL. 510 * passive socket -> anyaddr (0.0.0.0 or ::) 511 * non-passive socket -> localhost (127.0.0.1 or ::1) 512 */ 513 if (hostname == NULL) { 514 struct afd *afd; 515 int s; 516 517 for (afd = &afdl[0]; afd->a_af; afd++) { 518 if (!(pai->ai_family == PF_UNSPEC 519 || pai->ai_family == afd->a_af)) { 520 continue; 521 } 522 523 /* 524 * filter out AFs that are not supported by the kernel 525 * XXX errno? 526 */ 527 s = socket(afd->a_af, SOCK_DGRAM, 0); 528 if (s < 0) 529 continue; 530 530 #if defined(HAVE_CLOSESOCKET) 531 closesocket(s);532 #else 533 close(s);534 #endif 535 536 if (pai->ai_flags & AI_PASSIVE) {537 GET_AI(cur->ai_next, afd, afd->a_addrany, port);538 /* xxx meaningless?539 * GET_CANONNAME(cur->ai_next, "anyaddr");540 */541 } else {542 GET_AI(cur->ai_next, afd, afd->a_loopback,543 port);544 /* xxx meaningless?545 * GET_CANONNAME(cur->ai_next, "localhost");546 */547 }548 cur = cur->ai_next;549 }550 top = sentinel.ai_next;551 if (top)552 goto good;553 else554 ERR(EAI_FAMILY);555 }556 557 /* hostname as numeric name */558 for (i = 0; afdl[i].a_af; i++) {559 if (inet_pton(afdl[i].a_af, hostname, pton)) {560 unsigned long v4a;561 #ifdef INET6 562 unsigned char pfx;563 #endif 564 565 switch (afdl[i].a_af) {566 case AF_INET:567 v4a = ((struct in_addr *)pton)->s_addr;568 if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))569 pai->ai_flags &= ~AI_CANONNAME;570 v4a >>= IN_CLASSA_NSHIFT;571 if (v4a == 0 || v4a == IN_LOOPBACKNET)572 pai->ai_flags &= ~AI_CANONNAME;573 break;574 #ifdef INET6 575 case AF_INET6:576 pfx = ((struct in6_addr *)pton)->s6_addr8[0];577 if (pfx == 0 || pfx == 0xfe || pfx == 0xff)578 pai->ai_flags &= ~AI_CANONNAME;579 break;580 #endif 581 }582 583 if (pai->ai_family == afdl[i].a_af ||584 pai->ai_family == PF_UNSPEC) {585 if (! (pai->ai_flags & AI_CANONNAME)) {586 GET_AI(top, &afdl[i], pton, port);587 goto good;588 }589 /*590 * if AI_CANONNAME and if reverse lookup591 * fail, return ai anyway to pacify592 * calling application.593 *594 * XXX getaddrinfo() is a name->address595 * translation function, and it looks strange596 * that we do addr->name translation here.597 */598 get_name(pton, &afdl[i], &top, pton, pai, port);599 goto good;600 } else601 ERR(EAI_FAMILY);/*xxx*/602 }603 }604 605 if (pai->ai_flags & AI_NUMERICHOST)606 ERR(EAI_NONAME);607 608 /* hostname as alphabetical name */609 error = get_addr(hostname, pai->ai_family, &top, pai, port);610 if (error == 0) {611 if (top) {531 closesocket(s); 532 #else 533 close(s); 534 #endif 535 536 if (pai->ai_flags & AI_PASSIVE) { 537 GET_AI(cur->ai_next, afd, afd->a_addrany, port); 538 /* xxx meaningless? 539 * GET_CANONNAME(cur->ai_next, "anyaddr"); 540 */ 541 } else { 542 GET_AI(cur->ai_next, afd, afd->a_loopback, 543 port); 544 /* xxx meaningless? 545 * GET_CANONNAME(cur->ai_next, "localhost"); 546 */ 547 } 548 cur = cur->ai_next; 549 } 550 top = sentinel.ai_next; 551 if (top) 552 goto good; 553 else 554 ERR(EAI_FAMILY); 555 } 556 557 /* hostname as numeric name */ 558 for (i = 0; afdl[i].a_af; i++) { 559 if (inet_pton(afdl[i].a_af, hostname, pton)) { 560 unsigned long v4a; 561 #ifdef INET6 562 unsigned char pfx; 563 #endif 564 565 switch (afdl[i].a_af) { 566 case AF_INET: 567 v4a = ((struct in_addr *)pton)->s_addr; 568 if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) 569 pai->ai_flags &= ~AI_CANONNAME; 570 v4a >>= IN_CLASSA_NSHIFT; 571 if (v4a == 0 || v4a == IN_LOOPBACKNET) 572 pai->ai_flags &= ~AI_CANONNAME; 573 break; 574 #ifdef INET6 575 case AF_INET6: 576 pfx = ((struct in6_addr *)pton)->s6_addr8[0]; 577 if (pfx == 0 || pfx == 0xfe || pfx == 0xff) 578 pai->ai_flags &= ~AI_CANONNAME; 579 break; 580 #endif 581 } 582 583 if (pai->ai_family == afdl[i].a_af || 584 pai->ai_family == PF_UNSPEC) { 585 if (! (pai->ai_flags & AI_CANONNAME)) { 586 GET_AI(top, &afdl[i], pton, port); 587 goto good; 588 } 589 /* 590 * if AI_CANONNAME and if reverse lookup 591 * fail, return ai anyway to pacify 592 * calling application. 593 * 594 * XXX getaddrinfo() is a name->address 595 * translation function, and it looks strange 596 * that we do addr->name translation here. 597 */ 598 get_name(pton, &afdl[i], &top, pton, pai, port); 599 goto good; 600 } else 601 ERR(EAI_FAMILY); /*xxx*/ 602 } 603 } 604 605 if (pai->ai_flags & AI_NUMERICHOST) 606 ERR(EAI_NONAME); 607 608 /* hostname as alphabetical name */ 609 error = get_addr(hostname, pai->ai_family, &top, pai, port); 610 if (error == 0) { 611 if (top) { 612 612 good: 613 *res = top;614 return SUCCESS;615 } else616 error = EAI_FAIL;617 }613 *res = top; 614 return SUCCESS; 615 } else 616 error = EAI_FAIL; 617 } 618 618 free: 619 if (top)620 freeaddrinfo(top);619 if (top) 620 freeaddrinfo(top); 621 621 bad: 622 *res = NULL;623 return error;622 *res = NULL; 623 return error; 624 624 } 625 625 626 626 static int get_name(const char *addr, struct afd *afd, struct addrinfo **res, 627 char *numaddr, struct addrinfo *pai, int port0)627 char *numaddr, struct addrinfo *pai, int port0) 628 628 { 629 unsigned short port = port0 & 0xffff;630 struct hostent *hp;631 struct addrinfo *cur;632 int error = 0;633 #ifdef INET6 634 int h_error;635 #endif 636 637 #ifdef INET6 638 hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);639 #else 640 hp = gethostbyaddr(addr, afd->a_addrlen, AF_INET);641 #endif 642 if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {643 GET_AI(cur, afd, hp->h_addr_list[0], port);644 GET_CANONNAME(cur, hp->h_name);645 } else646 GET_AI(cur, afd, numaddr, port);647 648 #ifdef INET6 649 if (hp)650 freehostent(hp);651 #endif 652 *res = cur;653 return SUCCESS;629 unsigned short port = port0 & 0xffff; 630 struct hostent *hp; 631 struct addrinfo *cur; 632 int error = 0; 633 #ifdef INET6 634 int h_error; 635 #endif 636 637 #ifdef INET6 638 hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); 639 #else 640 hp = gethostbyaddr(addr, afd->a_addrlen, AF_INET); 641 #endif 642 if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { 643 GET_AI(cur, afd, hp->h_addr_list[0], port); 644 GET_CANONNAME(cur, hp->h_name); 645 } else 646 GET_AI(cur, afd, numaddr, port); 647 648 #ifdef INET6 649 if (hp) 650 freehostent(hp); 651 #endif 652 *res = cur; 653 return SUCCESS; 654 654 free: 655 if (cur)656 freeaddrinfo(cur);657 #ifdef INET6 658 if (hp)659 freehostent(hp);655 if (cur) 656 freeaddrinfo(cur); 657 #ifdef INET6 658 if (hp) 659 freehostent(hp); 660 660 #endif 661 661 /* bad: */ 662 *res = NULL;663 return error;662 *res = NULL; 663 return error; 664 664 } 665 665 666 666 static int get_addr(const char *hostname, int af, struct addrinfo **res, 667 struct addrinfo *pai, int port0)667 struct addrinfo *pai, int port0) 668 668 { 669 unsigned short port = port0 & 0xffff;670 struct addrinfo sentinel;671 struct hostent *hp;672 struct addrinfo *top, *cur;673 struct afd *afd;674 int i, error = 0, h_error;675 char *ap;676 677 top = NULL;678 sentinel.ai_next = NULL;679 cur = &sentinel;680 #ifdef INET6 681 if (af == AF_UNSPEC) {682 hp = getipnodebyname(hostname, AF_INET6,683 AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error);684 } else685 hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);686 #else 687 hp = gethostbyname(hostname);688 h_error = h_errno;689 #endif 690 if (hp == NULL) {691 switch (h_error) {692 case HOST_NOT_FOUND:693 case NO_DATA:694 error = EAI_NODATA;695 break;696 case TRY_AGAIN:697 error = EAI_AGAIN;698 break;699 case NO_RECOVERY:700 default:701 error = EAI_FAIL;702 break;703 }704 goto bad;705 }706 707 if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||708 (hp->h_addr_list[0] == NULL))709 ERR(EAI_FAIL);710 711 for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {712 switch (af) {713 #ifdef INET6 714 case AF_INET6:715 afd = &afdl[N_INET6];716 break;669 unsigned short port = port0 & 0xffff; 670 struct addrinfo sentinel; 671 struct hostent *hp; 672 struct addrinfo *top, *cur; 673 struct afd *afd; 674 int i, error = 0, h_error; 675 char *ap; 676 677 top = NULL; 678 sentinel.ai_next = NULL; 679 cur = &sentinel; 680 #ifdef INET6 681 if (af == AF_UNSPEC) { 682 hp = getipnodebyname(hostname, AF_INET6, 683 AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error); 684 } else 685 hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error); 686 #else 687 hp = gethostbyname(hostname); 688 h_error = h_errno; 689 #endif 690 if (hp == NULL) { 691 switch (h_error) { 692 case HOST_NOT_FOUND: 693 case NO_DATA: 694 error = EAI_NODATA; 695 break; 696 case TRY_AGAIN: 697 error = EAI_AGAIN; 698 break; 699 case NO_RECOVERY: 700 default: 701 error = EAI_FAIL; 702 break; 703 } 704 goto bad; 705 } 706 707 if ((hp->h_name == NULL) || (hp->h_name[0] == 0) || 708 (hp->h_addr_list[0] == NULL)) 709 ERR(EAI_FAIL); 710 711 for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) { 712 switch (af) { 713 #ifdef INET6 714 case AF_INET6: 715 afd = &afdl[N_INET6]; 716 break; 717 717 #endif 718 718 #ifndef INET6 719 default:/* AF_UNSPEC */720 #endif 721 case AF_INET:722 afd = &afdl[N_INET];723 break;724 #ifdef INET6 725 default:/* AF_UNSPEC */726 if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {727 ap += sizeof(struct in6_addr) -728 sizeof(struct in_addr);729 afd = &afdl[N_INET];730 } else731 afd = &afdl[N_INET6];732 break;733 #endif 734 }735 GET_AI(cur->ai_next, afd, ap, port);736 if (cur == &sentinel) {737 top = cur->ai_next;738 GET_CANONNAME(top, hp->h_name);739 }740 cur = cur->ai_next;741 }742 #ifdef INET6 743 freehostent(hp);744 #endif 745 *res = top;746 return SUCCESS;719 default: /* AF_UNSPEC */ 720 #endif 721 case AF_INET: 722 afd = &afdl[N_INET]; 723 break; 724 #ifdef INET6 725 default: /* AF_UNSPEC */ 726 if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) { 727 ap += sizeof(struct in6_addr) - 728 sizeof(struct in_addr); 729 afd = &afdl[N_INET]; 730 } else 731 afd = &afdl[N_INET6]; 732 break; 733 #endif 734 } 735 GET_AI(cur->ai_next, afd, ap, port); 736 if (cur == &sentinel) { 737 top = cur->ai_next; 738 GET_CANONNAME(top, hp->h_name); 739 } 740 cur = cur->ai_next; 741 } 742 #ifdef INET6 743 freehostent(hp); 744 #endif 745 *res = top; 746 return SUCCESS; 747 747 free: 748 if (top)749 freeaddrinfo(top);750 #ifdef INET6 751 if (hp)752 freehostent(hp);748 if (top) 749 freeaddrinfo(top); 750 #ifdef INET6 751 if (hp) 752 freehostent(hp); 753 753 #endif 754 754 bad: 755 *res = NULL;756 return error;755 *res = NULL; 756 return error; 757 757 } 758 758 … … 767 767 */ 768 768 769 #define ENI_NOSOCKET 0770 #define ENI_NOSERVNAME 1771 #define ENI_NOHOSTNAME 2772 #define ENI_MEMORY 3773 #define ENI_SYSTEM 4774 #define ENI_FAMILY 5775 #define ENI_SALEN 6769 #define ENI_NOSOCKET 0 770 #define ENI_NOSERVNAME 1 771 #define ENI_NOHOSTNAME 2 772 #define ENI_MEMORY 3 773 #define ENI_SYSTEM 4 774 #define ENI_FAMILY 5 775 #define ENI_SALEN 6 776 776 777 777 const char *inet_ntop__compat(int af, const void *addr, char *numaddr, 778 size_t numaddr_len)778 size_t numaddr_len) 779 779 { 780 780 #ifdef HAVE_INET_NTOA 781 struct in_addr in;782 memcpy(&in.s_addr, addr, sizeof(in.s_addr));783 snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));784 #else 785 unsigned long x = ntohl(*(unsigned long*)addr);786 snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",787 (int) (x>>24) & 0xff, (int) (x>>16) & 0xff,788 (int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);789 #endif 790 return numaddr;781 struct in_addr in; 782 memcpy(&in.s_addr, addr, sizeof(in.s_addr)); 783 snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in)); 784 #else 785 unsigned long x = ntohl(*(unsigned long*)addr); 786 snprintf(numaddr, numaddr_len, "%d.%d.%d.%d", 787 (int) (x>>24) & 0xff, (int) (x>>16) & 0xff, 788 (int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff); 789 #endif 790 return numaddr; 791 791 } 792 792 793 793 int getnameinfo__compat(const struct sockaddr *sa, size_t salen, 794 char *host, size_t hostlen, char *serv, size_t servlen, int flags)794 char *host, size_t hostlen, char *serv, size_t servlen, int flags) 795 795 { 796 struct afd *afd;797 struct servent *sp;798 struct hostent *hp;799 unsigned short port;800 int family, len, i;801 char *addr, *p;802 unsigned long v4a;803 #ifdef INET6 804 unsigned char pfx;805 #endif 806 int h_error;807 char numserv[512];808 char numaddr[512];809 810 if (sa == NULL)811 return ENI_NOSOCKET;812 813 len = SA_LEN(sa);814 if (len != salen) return ENI_SALEN;815 816 family = sa->sa_family;817 for (i = 0; afdl[i].a_af; i++)818 if (afdl[i].a_af == family) {819 afd = &afdl[i];820 goto found;821 }822 return ENI_FAMILY;823 796 struct afd *afd; 797 struct servent *sp; 798 struct hostent *hp; 799 unsigned short port; 800 int family, len, i; 801 char *addr, *p; 802 unsigned long v4a; 803 #ifdef INET6 804 unsigned char pfx; 805 #endif 806 int h_error; 807 char numserv[512]; 808 char numaddr[512]; 809 810 if (sa == NULL) 811 return ENI_NOSOCKET; 812 813 len = SA_LEN(sa); 814 if (len != salen) return ENI_SALEN; 815 816 family = sa->sa_family; 817 for (i = 0; afdl[i].a_af; i++) 818 if (afdl[i].a_af == family) { 819 afd = &afdl[i]; 820 goto found; 821 } 822 return ENI_FAMILY; 823 824 824 found: 825 if (len != afd->a_socklen) return ENI_SALEN;826 827 port = ((struct sockinet *)sa)->si_port; /* network byte order */828 addr = (char *)sa + afd->a_off;829 830 if (serv == NULL || servlen == 0) {831 /* what we should do? */832 } else if (flags & NI_NUMERICSERV) {833 snprintf(numserv, sizeof(numserv), "%d", ntohs(port));834 if (strlen(numserv) > servlen)835 return ENI_MEMORY;836 strcpy(serv, numserv);837 } else {825 if (len != afd->a_socklen) return ENI_SALEN; 826 827 port = ((struct sockinet *)sa)->si_port; /* network byte order */ 828 addr = (char *)sa + afd->a_off; 829 830 if (serv == NULL || servlen == 0) { 831 /* what we should do? */ 832 } else if (flags & NI_NUMERICSERV) { 833 snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); 834 if (strlen(numserv) > servlen) 835 return ENI_MEMORY; 836 strcpy(serv, numserv); 837 } else { 838 838 #if defined(HAVE_GETSERVBYPORT) 839 sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");840 if (sp) {841 if (strlen(sp->s_name) > servlen)842 return ENI_MEMORY;843 strcpy(serv, sp->s_name);844 } else845 return ENI_NOSERVNAME;846 #else 847 return ENI_NOSERVNAME;848 #endif 849 }850 851 switch (sa->sa_family) {852 case AF_INET:853 v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr;854 if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))855 flags |= NI_NUMERICHOST;856 v4a >>= IN_CLASSA_NSHIFT;857 if (v4a == 0 || v4a == IN_LOOPBACKNET)858 flags |= NI_NUMERICHOST; 859 break;860 #ifdef INET6 861 case AF_INET6:862 pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0];863 if (pfx == 0 || pfx == 0xfe || pfx == 0xff)864 flags |= NI_NUMERICHOST;865 break;866 #endif 867 }868 if (host == NULL || hostlen == 0) {869 /* what should we do? */870 } else if (flags & NI_NUMERICHOST) {871 if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))872 == NULL)873 return ENI_SYSTEM;874 if (strlen(numaddr) > hostlen)875 return ENI_MEMORY;876 strcpy(host, numaddr);877 } else {878 #ifdef INET6 879 hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);880 #else 881 hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);882 h_error = h_errno;883 #endif 884 885 if (hp) {886 if (flags & NI_NOFQDN) {887 p = strchr(hp->h_name, '.');888 if (p) *p = '\0';889 }890 if (strlen(hp->h_name) > hostlen) {891 #ifdef INET6 892 freehostent(hp);893 #endif 894 return ENI_MEMORY;895 }896 strcpy(host, hp->h_name);897 #ifdef INET6 898 freehostent(hp);899 #endif 900 } else {901 if (flags & NI_NAMEREQD)902 return ENI_NOHOSTNAME;903 if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))904 == NULL)905 return ENI_NOHOSTNAME;906 if (strlen(numaddr) > hostlen)907 return ENI_MEMORY;908 strcpy(host, numaddr);909 }910 }911 return SUCCESS;839 sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp"); 840 if (sp) { 841 if (strlen(sp->s_name) > servlen) 842 return ENI_MEMORY; 843 strcpy(serv, sp->s_name); 844 } else 845 return ENI_NOSERVNAME; 846 #else 847 return ENI_NOSERVNAME; 848 #endif 849 } 850 851 switch (sa->sa_family) { 852 case AF_INET: 853 v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr; 854 if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) 855 flags |= NI_NUMERICHOST; 856 v4a >>= IN_CLASSA_NSHIFT; 857 if (v4a == 0 || v4a == IN_LOOPBACKNET) 858 flags |= NI_NUMERICHOST; 859 break; 860 #ifdef INET6 861 case AF_INET6: 862 pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0]; 863 if (pfx == 0 || pfx == 0xfe || pfx == 0xff) 864 flags |= NI_NUMERICHOST; 865 break; 866 #endif 867 } 868 if (host == NULL || hostlen == 0) { 869 /* what should we do? */ 870 } else if (flags & NI_NUMERICHOST) { 871 if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) 872 == NULL) 873 return ENI_SYSTEM; 874 if (strlen(numaddr) > hostlen) 875 return ENI_MEMORY; 876 strcpy(host, numaddr); 877 } else { 878 #ifdef INET6 879 hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); 880 #else 881 hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); 882 h_error = h_errno; 883 #endif 884 885 if (hp) { 886 if (flags & NI_NOFQDN) { 887 p = strchr(hp->h_name, '.'); 888 if (p) *p = '\0'; 889 } 890 if (strlen(hp->h_name) > hostlen) { 891 #ifdef INET6 892 freehostent(hp); 893 #endif 894 return ENI_MEMORY; 895 } 896 strcpy(host, hp->h_name); 897 #ifdef INET6 898 freehostent(hp); 899 #endif 900 } else { 901 if (flags & NI_NAMEREQD) 902 return ENI_NOHOSTNAME; 903 if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) 904 == NULL) 905 return ENI_NOHOSTNAME; 906 if (strlen(numaddr) > hostlen) 907 return ENI_MEMORY; 908 strcpy(host, numaddr); 909 } 910 } 911 return SUCCESS; 912 912 } 913 913 /* vi:set ts=8 sts=4 sw=4 tw=76 et: */ -
trunk/ithildin/source/contrib/strlcat.c
r490 r578 43 43 /* Find the end of dst and adjust bytes left but don't go past end */ 44 44 while (n-- != 0 && *d != '\0') 45 d++;45 d++; 46 46 dlen = d - dst; 47 47 n = siz - dlen; 48 48 49 49 if (n == 0) 50 return(dlen + strlen(s));50 return(dlen + strlen(s)); 51 51 while (*s != '\0') { 52 if (n != 1) {53 *d++ = *s;54 n--;55 }56 s++;52 if (n != 1) { 53 *d++ = *s; 54 n--; 55 } 56 s++; 57 57 } 58 58 *d = '\0'; 59 59 60 return(dlen + (s - src)); /* count does not include NUL */60 return(dlen + (s - src)); /* count does not include NUL */ 61 61 } -
trunk/ithildin/source/contrib/strlcpy.c
r490 r578 1 /* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $*/1 /* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */ 2 2 3 3 /* … … 42 42 /* Copy as many bytes as will fit */ 43 43 if (n != 0 && --n != 0) { 44 do {45 if ((*d++ = *s++) == 0)46 break;47 } while (--n != 0);44 do { 45 if ((*d++ = *s++) == 0) 46 break; 47 } while (--n != 0); 48 48 } 49 49 50 50 /* Not enough room in dst, add NUL and traverse rest of src */ 51 51 if (n == 0) { 52 if (siz != 0)53 *d = '\0';/* NUL-terminate dst */54 while (*s++);52 if (siz != 0) 53 *d = '\0'; /* NUL-terminate dst */ 54 while (*s++); 55 55 } 56 56 57 return(s - src - 1); /* count does not include NUL */57 return(s - src - 1); /* count does not include NUL */ 58 58 } -
trunk/ithildin/source/event.c
r576 r578 32 32 event_t *create_event(int flags) { 33 33 event_t *ep = NULL; 34 34 35 35 ep = malloc(sizeof(event_t)); 36 36 ep->numhooks = 0; … … 59 59 60 60 if (ep->flags & EVENT_FL_NORETURN) 61 returned = NULL;61 returned = NULL; 62 62 else if (ep->flags & EVENT_FL_CONDITIONAL) 63 returned = (void **)HOOK_COND_PASS; /* success is the default */63 returned = (void **)HOOK_COND_PASS; /* success is the default */ 64 64 else 65 returned = hookreturns;66 SLIST_FOREACH(hp, &ep->hooks, lp) {67 if (hp->flags & (HOOK_FL_DEFERRED | HOOK_FL_NEW))68 continue; /* either deferred for deletion or newly added */69 70 ret = hookreturns[i++] = hp->function(ep, data);71 if (ep->flags & EVENT_FL_CONDITIONAL) {72 if (ret == (void *)HOOK_COND_ALWAYSOK) {73 /* short-circuit success value. stop here */74 returned = (void **)HOOK_COND_SPASS;75 break;76 } else if (ret == (void *)HOOK_COND_NEVEROK) {77 /* short-circuit failure value. stop here */78 returned = (void **)HOOK_COND_FAIL;79 break;80 } else if (ret == (void *)HOOK_COND_NOTOK)81 returned = (void **)HOOK_COND_FAIL;82 else if (ret != (void *)HOOK_COND_OK &&83 ret != (void *)HOOK_COND_NEUTRAL) {84 returned = (void **)HOOK_COND_FAIL;85 econd = ret;86 }87 }88 89 if (ep->flags & EVENT_FL_HOOKONCE)90 hp->flags |= HOOK_FL_DEFERRED;65 returned = hookreturns; 66 SLIST_FOREACH(hp, &ep->hooks, lp) { 67 if (hp->flags & (HOOK_FL_DEFERRED | HOOK_FL_NEW)) 68 continue; /* either deferred for deletion or newly added */ 69 70 ret = hookreturns[i++] = hp->function(ep, data); 71 if (ep->flags & EVENT_FL_CONDITIONAL) { 72 if (ret == (void *)HOOK_COND_ALWAYSOK) { 73 /* short-circuit success value. stop here */ 74 returned = (void **)HOOK_COND_SPASS; 75 break; 76 } else if (ret == (void *)HOOK_COND_NEVEROK) { 77 /* short-circuit failure value. stop here */ 78 returned = (void **)HOOK_COND_FAIL; 79 break; 80 } else if (ret == (void *)HOOK_COND_NOTOK) 81 returned = (void **)HOOK_COND_FAIL; 82 else if (ret != (void *)HOOK_COND_OK && 83 ret != (void *)HOOK_COND_NEUTRAL) { 84 returned = (void **)HOOK_COND_FAIL; 85 econd = ret; 86 } 87 } 88 89 if (ep->flags & EVENT_FL_HOOKONCE) 90 hp->flags |= HOOK_FL_DEFERRED; 91 91 } 92 92 93 93 if (ep->flags & EVENT_FL_CONDITIONAL) { 94 /* if we got a positive return (econd is set) then set returned95 * properly. */96 if (returned == (void **)HOOK_COND_FAIL && econd != NULL)97 returned = (void **)econd;94 /* if we got a positive return (econd is set) then set returned 95 * properly. */ 96 if (returned == (void **)HOOK_COND_FAIL && econd != NULL) 97 returned = (void **)econd; 98 98 } else 99 hook_num_returns = i;99 hook_num_returns = i; 100 100 101 101 /* trash the hooks which are deferred (will be all of them if this is a 102 102 * 'hookonce' event. */ 103 103 ep->flags &= ~EVENT_FL_CALLING; 104 hp = SLIST_FIRST(&ep->hooks);104 hp = SLIST_FIRST(&ep->hooks); 105 105 while (hp != NULL) { 106 hp2 = SLIST_NEXT(hp, lp);107 108 if (hp->flags & HOOK_FL_DEFERRED) {109 SLIST_REMOVE(&ep->hooks, hp, hook, lp);110 free(hp);111 } else if (hp->flags & HOOK_FL_NEW)112 hp->flags &= ~HOOK_FL_NEW;113 hp = hp2;106 hp2 = SLIST_NEXT(hp, lp); 107 108 if (hp->flags & HOOK_FL_DEFERRED) { 109 SLIST_REMOVE(&ep->hooks, hp, hook, lp); 110 free(hp); 111 } else if (hp->flags & HOOK_FL_NEW) 112 hp->flags &= ~HOOK_FL_NEW; 113 hp = hp2; 114 114 } 115 115 116 116 return returned; 117 117 } 118 118 119 119 void destroy_event(event_t *ep) { 120 120 struct hook *hp; 121 121 122 122 if (ep == NULL) 123 return;123 return; 124 124 125 125 while (!SLIST_EMPTY(&ep->hooks)) { 126 hp = SLIST_FIRST(&ep->hooks);127 SLIST_REMOVE_HEAD(&ep->hooks, lp);128 free(hp);126 hp = SLIST_FIRST(&ep->hooks); 127 SLIST_REMOVE_HEAD(&ep->hooks, lp); 128 free(hp); 129 129 } 130 130 free(ep); … … 135 135 * last hook on the event. */ 136 136 int add_hook_after(event_t *ep, hook_function_t func, 137 hook_function_t after) {137 hook_function_t after) { 138 138 struct hook *hp = NULL; 139 139 140 140 if (ep == NULL || func == NULL) 141 return 0;141 return 0; 142 142 143 143 if (ep->numhooks && ep->flags & EVENT_FL_ONEHOOK) { 144 log_debug("tried to add another hook to a one-hook event");145 return 0;144 log_debug("tried to add another hook to a one-hook event"); 145 return 0; 146 146 } 147 147 … … 150 150 * add it on to the end. */ 151 151 if (after == NULL) { 152 SLIST_FOREACH(hp, &ep->hooks, lp) {153 if (SLIST_NEXT(hp, lp) == NULL)154 break;155 }152 SLIST_FOREACH(hp, &ep->hooks, lp) { 153 if (SLIST_NEXT(hp, lp) == NULL) 154 break; 155 } 156 156 } else { 157 SLIST_FOREACH(hp, &ep->hooks, lp) {158 if (hp->function == after)159 break; /* found it */160 if (SLIST_NEXT(hp, lp) == NULL)161 break; /* if the list ends here, be sure to preserve this */162 }157 SLIST_FOREACH(hp, &ep->hooks, lp) { 158 if (hp->function == after) 159 break; /* found it */ 160 if (SLIST_NEXT(hp, lp) == NULL) 161 break; /* if the list ends here, be sure to preserve this */ 162 } 163 163 } 164 164 … … 168 168 169 169 int add_hook_before(event_t *ep, hook_function_t func, 170 hook_function_t before) {170 hook_function_t before) { 171 171 struct hook *hp = NULL; 172 172 struct hook *hp2 = NULL; 173 173 174 174 if (ep == NULL || func == NULL) 175 return 0;175 return 0; 176 176 177 177 if (ep->numhooks && ep->flags & EVENT_FL_ONEHOOK) { 178 log_debug("tried to add another hook to a one-hook event");179 return 0;178 log_debug("tried to add another hook to a one-hook event"); 179 return 0; 180 180 } 181 181 … … 185 185 * the head of the list. */ 186 186 if (before == NULL || SLIST_EMPTY(&ep->hooks) || 187 ((SLIST_FIRST(&ep->hooks))->function == before))188 hp = NULL;187 ((SLIST_FIRST(&ep->hooks))->function == before)) 188 hp = NULL; 189 189 else { 190 SLIST_FOREACH(hp, &ep->hooks, lp) {191 hp2 = SLIST_NEXT(hp, lp);192 if (hp2 == NULL)193 break; /* add it on to the end */194 else if (hp2->function == before)195 break; /* hp is the one before 'function'. tada */196 }190 SLIST_FOREACH(hp, &ep->hooks, lp) { 191 hp2 = SLIST_NEXT(hp, lp); 192 if (hp2 == NULL) 193 break; /* add it on to the end */ 194 else if (hp2->function == before) 195 break; /* hp is the one before 'function'. tada */ 196 } 197 197 } 198 198 … … 207 207 hp->function = func; 208 208 if (ep->flags & EVENT_FL_CALLING) 209 hp->flags = HOOK_FL_NEW;209 hp->flags = HOOK_FL_NEW; 210 210 else 211 hp->flags = 0;211 hp->flags = 0; 212 212 if (at == NULL) 213 SLIST_INSERT_HEAD(&ep->hooks, hp, lp);213 SLIST_INSERT_HEAD(&ep->hooks, hp, lp); 214 214 else 215 SLIST_INSERT_AFTER(at, hp, lp);215 SLIST_INSERT_AFTER(at, hp, lp); 216 216 if (maxhooks <= ++ep->numhooks) { 217 maxhooks *= 2;218 hookreturns = (void **)realloc(hookreturns, sizeof(void *) * maxhooks);217 maxhooks *= 2; 218 hookreturns = (void **)realloc(hookreturns, sizeof(void *) * maxhooks); 219 219 } 220 220 } … … 224 224 225 225 SLIST_FOREACH(hp, &ep->hooks, lp) { 226 if (hp->function == func)227 return hp;226 if (hp->function == func) 227 return hp; 228 228 } 229 229 … … 235 235 236 236 if (hp != NULL) { 237 ep->numhooks--;238 239 if (ep->flags & EVENT_FL_CALLING)240 hp->flags |= HOOK_FL_DEFERRED; /* just defer this for deletion */241 else {242 SLIST_REMOVE(&ep->hooks, hp, hook, lp);243 free(hp);244 }245 return 1;237 ep->numhooks--; 238 239 if (ep->flags & EVENT_FL_CALLING) 240 hp->flags |= HOOK_FL_DEFERRED; /* just defer this for deletion */ 241 else { 242 SLIST_REMOVE(&ep->hooks, hp, hook, lp); 243 free(hp); 244 } 245 return 1; 246 246 } 247 247 -
trunk/ithildin/source/hash.c
r576 r578 21 21 * comparison when calling 'hash_find' */ 22 22 hashtable_t *create_hash_table(int elems, size_t offset, size_t len, 23 int flags, char *cmpname) {23 int flags, char *cmpname) { 24 24 hashtable_t *htp = malloc(sizeof(hashtable_t)); 25 25 … … 34 34 htp->flags = flags; 35 35 if (cmpname != NULL) 36 htp->cmpsym = import_symbol(cmpname);36 htp->cmpsym = import_symbol(cmpname); 37 37 else 38 htp->cmpsym = import_symbol("memcmp");38 htp->cmpsym = import_symbol("memcmp"); 39 39 40 40 htp->table = malloc(sizeof(struct hashbucket) * htp->size); … … 51 51 52 52 for (i = 0;i < table->size;i++) { 53 while (!SLIST_EMPTY(&table->table[i])) {54 hep = SLIST_FIRST(&table->table[i]);55 SLIST_REMOVE_HEAD(&table->table[i], lp);56 free(hep);57 }53 while (!SLIST_EMPTY(&table->table[i])) { 54 hep = SLIST_FIRST(&table->table[i]); 55 SLIST_REMOVE_HEAD(&table->table[i], lp); 56 free(hep); 57 } 58 58 } 59 59 free(table->table); … … 85 85 * and re-adding them to the table as we go */ 86 86 for (i = 0;i < oldsize;i++) { 87 while (!SLIST_EMPTY(&oldtable[i])) {88 hep = SLIST_FIRST(&oldtable[i]);89 hash_insert(table, hep->ent);90 SLIST_REMOVE_HEAD(&oldtable[i], lp);91 free(hep);92 }87 while (!SLIST_EMPTY(&oldtable[i])) { 88 hep = SLIST_FIRST(&oldtable[i]); 89 hash_insert(table, hep->ent); 90 SLIST_REMOVE_HEAD(&oldtable[i], lp); 91 free(hep); 92 } 93 93 } 94 94 free(oldtable); … … 100 100 * you adequately. */ 101 101 unsigned int hash_get_key_hash(hashtable_t *table, void *key, 102 size_t offset) {102 size_t offset) { 103 103 char *rkey = (char *)key + offset; 104 104 int len = table->keylen; … … 106 106 107 107 if (table->flags & HASH_FL_STRING) { 108 len = strlen(rkey);109 if (len > table->keylen)110 len = table->keylen;108 len = strlen(rkey); 109 if (len > table->keylen) 110 len = table->keylen; 111 111 } 112 112 /* I borrowed this algorithm from perl5. Kudos to Larry Wall & co. */ 113 113 if (table->flags & HASH_FL_NOCASE) 114 while (len--)115 hash = hash * 33 + tolower(*rkey++);114 while (len--) 115 hash = hash * 33 + tolower(*rkey++); 116 116 else 117 while (len--)118 hash = hash * 33 + *rkey++;117 while (len--) 118 hash = hash * 33 + *rkey++; 119 119 120 120 return hash + (hash >> 5); … … 130 130 #ifdef DEBUG_CODE 131 131 if (SLIST_EMPTY(&table->table[hash])) 132 table->empty_buckets--; /* this bucket isn't empty now */132 table->empty_buckets--; /* this bucket isn't empty now */ 133 133 else { 134 /* count the items in the bucket. of course this is expensive, that's135 * why you don't debug code in production. :) */136 struct hashent *hep2;137 int cnt = 0;138 SLIST_FOREACH(hep2, &table->table[hash], lp) {139 cnt++;140 }141 if (cnt > table->max_per_bucket)142 table->max_per_bucket = cnt;134 /* count the items in the bucket. of course this is expensive, that's 135 * why you don't debug code in production. :) */ 136 struct hashent *hep2; 137 int cnt = 0; 138 SLIST_FOREACH(hep2, &table->table[hash], lp) { 139 cnt++; 140 } 141 if (cnt > table->max_per_bucket) 142 table->max_per_bucket = cnt; 143 143 } 144 144 #endif … … 147 147 hep->ent = ent; 148 148 if (table->flags & HASH_FL_INSERTTAIL) { 149 /* find the end of the list and insert data there. this is costly,150 * and probably not something you want to do unless you're really sure151 * that it's what you're after. */152 struct hashent *hep2;153 154 hep2 = SLIST_FIRST(&table->table[hash]);155 while (hep2 != NULL)156 if (SLIST_NEXT(hep2, lp) == NULL)157 break;158 else159 hep2 = SLIST_NEXT(hep2, lp);160 161 if (hep2 == NULL)162 SLIST_INSERT_HEAD(&table->table[hash], hep, lp);163 else164 SLIST_INSERT_AFTER(hep2, hep, lp);149 /* find the end of the list and insert data there. this is costly, 150 * and probably not something you want to do unless you're really sure 151 * that it's what you're after. */ 152 struct hashent *hep2; 153 154 hep2 = SLIST_FIRST(&table->table[hash]); 155 while (hep2 != NULL) 156 if (SLIST_NEXT(hep2, lp) == NULL) 157 break; 158 else 159 hep2 = SLIST_NEXT(hep2, lp); 160 161 if (hep2 == NULL) 162 SLIST_INSERT_HEAD(&table->table[hash], hep, lp); 163 else 164 SLIST_INSERT_AFTER(hep2, hep, lp); 165 165 } else 166 SLIST_INSERT_HEAD(&table->table[hash], hep, lp);166 SLIST_INSERT_HEAD(&table->table[hash], hep, lp); 167 167 168 168 /* if the table has 1.2x as many entries as there are buckets, resize it so 169 169 * that there ar twice as many buckets. :) */ 170 170 if (((table->size * 6) / 5) <= table->entries) 171 resize_hash_table(table, table->size * 2);171 resize_hash_table(table, table->size * 2); 172 172 173 173 return 1; … … 177 177 int hash_delete(hashtable_t *table, void *ent) { 178 178 unsigned int hash = hash_get_key_hash(table, ent, table->keyoffset) % 179 table->size;179 table->size; 180 180 struct hashent *hep; 181 181 182 182 SLIST_FOREACH(hep, &table->table[hash], lp) { 183 if (hep->ent == ent)184 break;183 if (hep->ent == ent) 184 break; 185 185 } 186 186 if (hep == NULL) 187 return 0;187 return 0; 188 188 189 189 table->entries--; … … 193 193 #ifdef DEBUG_CODE 194 194 if (SLIST_EMPTY(&table->table[hash])) 195 table->empty_buckets++; /* this bucket is empty again. */195 table->empty_buckets++; /* this bucket is empty again. */ 196 196 #endif 197 197 … …
