Changeset 578


Ignore:
Timestamp:
08/21/05 06:37:53 (7 years ago)
Author:
wd
Message:

Expand tabs ('\t') to eight spaces.

Location:
trunk/ithildin
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/ithildin/Makefile.in

    r576 r578  
    4040 
    4141base_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" 
    4646 
    4747modules_build: 
    48         @(cd modules && $(MAKE) all) 
     48        @(cd modules && $(MAKE) all) 
    4949 
    5050base_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) 
    5454 
    5555conf_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         fi 
    63          
     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         
    6464data_install: 
    65         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 
     65        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 
    7474 
    7575include_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) 
    7979 
    8080modules_install: modules_build 
    81         @cd modules; $(MAKE) install 
     81        @cd modules; $(MAKE) install 
    8282 
    8383install: 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!" 
    8585 
    8686clean: 
    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" 
     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" 
    9292 
    9393distclean: clean 
    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'` 
     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'` 
    9898 
    9999update: clean 
    100         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 
     100        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 
    111111 
    112112reconf: reconfigure 
    113113reconfig: reconfigure 
    114114reconfigure: 
    115         @cfgline=`grep -E '^  \\$$' config.log | head -1 | sed 's/^  \\$$ //'`;\ 
    116         echo ">>> re-running configure as:"                             ;\ 
    117         echo "    $$cfgline"                                            ;\ 
    118         $$cfgline 
     115        @cfgline=`grep -E '^  \\$$' config.log | head -1 | sed 's/^  \\$$ //'`;\ 
     116        echo ">>> re-running configure as:"                                ;\ 
     117        echo "    $$cfgline"                                                ;\ 
     118        $$cfgline 
    119119 
    120 DISTFILES = .svn COPYING DEVELOPERS Makefile.in README TODO autoconf    \ 
    121             configure doc include source tools 
     120DISTFILES = .svn COPYING DEVELOPERS Makefile.in README TODO autoconf        \ 
     121            configure doc include source tools 
    122122MDISTFILES = modules/.svn modules/Makefile.in 
    123123 
    124124release: 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" 
    140140 
    141141# vi:set ts=8 sts=4 sw=4 tw=76 et: 
  • trunk/ithildin/autoconf/config.guess

    r490 r578  
    7474    -- )     # Stop option processing 
    7575       shift; break ;; 
    76     - ) # Use stdin as input. 
     76    - )        # Use stdin as input. 
    7777       break ;; 
    7878    -* ) 
     
    9999set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in 
    100100 ,,)    echo "int dummy(){}" > $dummy.c ; 
    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         ;; 
     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        ;; 
    112112 ,,*)   CC_FOR_BUILD=$CC ;; 
    113113 ,*,*)  CC_FOR_BUILD=$HOST_CC ;; 
     
    117117# (ghazi@noc.rutgers.edu 1994-08-24) 
    118118if (test -f /.attbin/uname) >/dev/null 2>&1 ; then 
    119         PATH=$PATH:/.attbin ; export PATH 
     119        PATH=$PATH:/.attbin ; export PATH 
    120120fi 
    121121 
     
    129129case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 
    130130    *:NetBSD:*:*) 
    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 ;; 
     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 ;; 
    176176    amiga:OpenBSD:*:*) 
    177         echo m68k-unknown-openbsd${UNAME_RELEASE} 
    178         exit 0 ;; 
     177        echo m68k-unknown-openbsd${UNAME_RELEASE} 
     178        exit 0 ;; 
    179179    arc:OpenBSD:*:*) 
    180         echo mipsel-unknown-openbsd${UNAME_RELEASE} 
    181         exit 0 ;; 
     180        echo mipsel-unknown-openbsd${UNAME_RELEASE} 
     181        exit 0 ;; 
    182182    hp300:OpenBSD:*:*) 
    183         echo m68k-unknown-openbsd${UNAME_RELEASE} 
    184         exit 0 ;; 
     183        echo m68k-unknown-openbsd${UNAME_RELEASE} 
     184        exit 0 ;; 
    185185    mac68k:OpenBSD:*:*) 
    186         echo m68k-unknown-openbsd${UNAME_RELEASE} 
    187         exit 0 ;; 
     186        echo m68k-unknown-openbsd${UNAME_RELEASE} 
     187        exit 0 ;; 
    188188    macppc:OpenBSD:*:*) 
    189         echo powerpc-unknown-openbsd${UNAME_RELEASE} 
    190         exit 0 ;; 
     189        echo powerpc-unknown-openbsd${UNAME_RELEASE} 
     190        exit 0 ;; 
    191191    mvme68k:OpenBSD:*:*) 
    192         echo m68k-unknown-openbsd${UNAME_RELEASE} 
    193         exit 0 ;; 
     192        echo m68k-unknown-openbsd${UNAME_RELEASE} 
     193        exit 0 ;; 
    194194    mvme88k:OpenBSD:*:*) 
    195         echo m88k-unknown-openbsd${UNAME_RELEASE} 
    196         exit 0 ;; 
     195        echo m88k-unknown-openbsd${UNAME_RELEASE} 
     196        exit 0 ;; 
    197197    mvmeppc:OpenBSD:*:*) 
    198         echo powerpc-unknown-openbsd${UNAME_RELEASE} 
    199         exit 0 ;; 
     198        echo powerpc-unknown-openbsd${UNAME_RELEASE} 
     199        exit 0 ;; 
    200200    pmax:OpenBSD:*:*) 
    201         echo mipsel-unknown-openbsd${UNAME_RELEASE} 
    202         exit 0 ;; 
     201        echo mipsel-unknown-openbsd${UNAME_RELEASE} 
     202        exit 0 ;; 
    203203    sgi:OpenBSD:*:*) 
    204         echo mipseb-unknown-openbsd${UNAME_RELEASE} 
    205         exit 0 ;; 
     204        echo mipseb-unknown-openbsd${UNAME_RELEASE} 
     205        exit 0 ;; 
    206206    sun3:OpenBSD:*:*) 
    207         echo m68k-unknown-openbsd${UNAME_RELEASE} 
    208         exit 0 ;; 
     207        echo m68k-unknown-openbsd${UNAME_RELEASE} 
     208        exit 0 ;; 
    209209    wgrisc:OpenBSD:*:*) 
    210         echo mipsel-unknown-openbsd${UNAME_RELEASE} 
    211         exit 0 ;; 
     210        echo mipsel-unknown-openbsd${UNAME_RELEASE} 
     211        exit 0 ;; 
    212212    *:OpenBSD:*:*) 
    213         echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} 
    214         exit 0 ;; 
     213        echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} 
     214        exit 0 ;; 
    215215    alpha:OSF1:*:*) 
    216         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 
     216        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 
    225225\$Lformat: 
    226         .byte 37,100,45,37,120,10,0     # "%d-%x\n" 
    227  
    228         .text 
    229         .globl main 
    230         .align 4 
    231         .ent main 
     226        .byte 37,100,45,37,120,10,0        # "%d-%x\n" 
     227 
     228        .text 
     229        .globl main 
     230        .align 4 
     231        .ent main 
    232232main: 
    233         .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 
     233        .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 
    247247EOF 
    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 ;; 
     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 ;; 
    278278    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 instead 
    281         # of the specific Alpha model? 
    282         echo alpha-pc-interix 
    283         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 ;; 
    284284    21064:Windows_NT:50:3) 
    285         echo alpha-dec-winnt3.5 
    286         exit 0 ;; 
     285        echo alpha-dec-winnt3.5 
     286        exit 0 ;; 
    287287    Amiga*:UNIX_System_V:4.0:*) 
    288         echo m68k-unknown-sysv4 
    289         exit 0;; 
     288        echo m68k-unknown-sysv4 
     289        exit 0;; 
    290290    *:[Aa]miga[Oo][Ss]:*:*) 
    291         echo ${UNAME_MACHINE}-unknown-amigaos 
    292         exit 0 ;; 
     291        echo ${UNAME_MACHINE}-unknown-amigaos 
     292        exit 0 ;; 
    293293    *:[Mm]orph[Oo][Ss]:*:*) 
    294         echo ${UNAME_MACHINE}-unknown-morphos 
    295         exit 0 ;; 
     294        echo ${UNAME_MACHINE}-unknown-morphos 
     295        exit 0 ;; 
    296296    *:OS/390:*:*) 
    297         echo i370-ibm-openedition 
    298         exit 0 ;; 
     297        echo i370-ibm-openedition 
     298        exit 0 ;; 
    299299    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;; 
    302302    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) 
    303         echo hppa1.1-hitachi-hiuxmpp 
    304         exit 0;; 
     303        echo hppa1.1-hitachi-hiuxmpp 
     304        exit 0;; 
    305305    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 ; then 
    308                 echo pyramid-pyramid-sysv3 
    309         else 
    310                 echo pyramid-pyramid-bsd 
    311         fi 
    312         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 ;; 
    313313    NILE*:*:*:dcosx) 
    314         echo pyramid-pyramid-svr4 
    315         exit 0 ;; 
     314        echo pyramid-pyramid-svr4 
     315        exit 0 ;; 
    316316    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 ;; 
    319319    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 ;; 
    322322    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 ;; 
    325325    sun4*:SunOS:6*:*) 
    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 ;; 
     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 ;; 
    331331    sun4*:SunOS:*:*) 
    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 ;; 
     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 ;; 
    340340    sun3*:SunOS:*:*) 
    341         echo m68k-sun-sunos${UNAME_RELEASE} 
    342         exit 0 ;; 
     341        echo m68k-sun-sunos${UNAME_RELEASE} 
     342        exit 0 ;; 
    343343    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=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 ;; 
     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 ;; 
    355355    aushp:SunOS:*:*) 
    356         echo sparc-auspex-sunos${UNAME_RELEASE} 
    357         exit 0 ;; 
     356        echo sparc-auspex-sunos${UNAME_RELEASE} 
     357        exit 0 ;; 
    358358    # The situation for MiNT is a little confusing.  The machine name 
    359359    # can be virtually everything (everything which is not 
     
    366366    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 
    367367        echo m68k-atari-mint${UNAME_RELEASE} 
    368         exit 0 ;; 
     368        exit 0 ;; 
    369369    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 
    370         echo m68k-atari-mint${UNAME_RELEASE} 
     370        echo m68k-atari-mint${UNAME_RELEASE} 
    371371        exit 0 ;; 
    372372    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 
    373373        echo m68k-atari-mint${UNAME_RELEASE} 
    374         exit 0 ;; 
     374        exit 0 ;; 
    375375    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 
    376376        echo m68k-milan-mint${UNAME_RELEASE} 
     
    383383        exit 0 ;; 
    384384    powerpc:machten:*:*) 
    385         echo powerpc-apple-machten${UNAME_RELEASE} 
    386         exit 0 ;; 
     385        echo powerpc-apple-machten${UNAME_RELEASE} 
     386        exit 0 ;; 
    387387    RISC*:Mach:*:*) 
    388         echo mips-dec-mach_bsd4.3 
    389         exit 0 ;; 
     388        echo mips-dec-mach_bsd4.3 
     389        exit 0 ;; 
    390390    RISC*:ULTRIX:*:*) 
    391         echo mips-dec-ultrix${UNAME_RELEASE} 
    392         exit 0 ;; 
     391        echo mips-dec-ultrix${UNAME_RELEASE} 
     392        exit 0 ;; 
    393393    VAX*:ULTRIX*:*:*) 
    394         echo vax-dec-ultrix${UNAME_RELEASE} 
    395         exit 0 ;; 
     394        echo vax-dec-ultrix${UNAME_RELEASE} 
     395        exit 0 ;; 
    396396    2020:CLIX:*:* | 2430:CLIX:*:*) 
    397         echo clipper-intergraph-clix${UNAME_RELEASE} 
    398         exit 0 ;; 
     397        echo clipper-intergraph-clix${UNAME_RELEASE} 
     398        exit 0 ;; 
    399399    mips:*:*:UMIPS | mips:*:*:RISCos) 
    400         eval $set_cc_for_build 
    401         sed 's/^        //' << EOF >$dummy.c 
     400        eval $set_cc_for_build 
     401        sed 's/^        //' << EOF >$dummy.c 
    402402#ifdef __cplusplus 
    403403#include <stdio.h>  /* for printf() prototype */ 
    404         int main (int argc, char *argv[]) { 
     404        int main (int argc, char *argv[]) { 
    405405#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         #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         } 
     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        } 
    421421EOF 
    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 ;; 
     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 ;; 
    428428    Motorola:PowerMAX_OS:*:*) 
    429         echo powerpc-motorola-powermax 
    430         exit 0 ;; 
     429        echo powerpc-motorola-powermax 
     430        exit 0 ;; 
    431431    Night_Hawk:Power_UNIX:*:*) 
    432         echo powerpc-harris-powerunix 
    433         exit 0 ;; 
     432        echo powerpc-harris-powerunix 
     433        exit 0 ;; 
    434434    m88k:CX/UX:7*:*) 
    435         echo m88k-harris-cxux7 
    436         exit 0 ;; 
     435        echo m88k-harris-cxux7 
     436        exit 0 ;; 
    437437    m88k:*:4*:R4*) 
    438         echo m88k-motorola-sysv4 
    439         exit 0 ;; 
     438        echo m88k-motorola-sysv4 
     439        exit 0 ;; 
    440440    m88k:*:3*:R3*) 
    441         echo m88k-motorola-sysv3 
    442         exit 0 ;; 
     441        echo m88k-motorola-sysv3 
     442        exit 0 ;; 
    443443    AViiON:dgux:*:*) 
    444444        # DG/UX returns AViiON for all architectures 
    445445        UNAME_PROCESSOR=`/usr/bin/uname -p` 
    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 ;; 
     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 ;; 
    462462    M88*:*:R3*:*) 
    463         # Delta 88k system running SVR3 
    464         echo m88k-motorola-sysv3 
    465         exit 0 ;; 
     463        # Delta 88k system running SVR3 
     464        echo m88k-motorola-sysv3 
     465        exit 0 ;; 
    466466    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) 
    467         echo m88k-tektronix-sysv3 
    468         exit 0 ;; 
     467        echo m88k-tektronix-sysv3 
     468        exit 0 ;; 
    469469    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) 
    470         echo m68k-tektronix-bsd 
    471         exit 0 ;; 
     470        echo m68k-tektronix-bsd 
     471        exit 0 ;; 
    472472    *: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 ;; 
    475475    ????????: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 id 
    477         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 ' 
    478478    i*86:AIX:*:*) 
    479         echo i386-ibm-aix 
    480         exit 0 ;; 
     479        echo i386-ibm-aix 
     480        exit 0 ;; 
    481481    ia64:AIX:*:*) 
    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 ;; 
     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 ;; 
    489489    *:AIX:2:3) 
    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                         } 
     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                        } 
    502502EOF 
    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 ;; 
     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 ;; 
    512512    *: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; 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 ;; 
     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 ;; 
    526526    *:AIX:*:*) 
    527         echo rs6000-ibm-aix 
    528         exit 0 ;; 
     527        echo rs6000-ibm-aix 
     528        exit 0 ;; 
    529529    ibmrt:4.4BSD:*|romp-ibm:BSD:*) 
    530         echo romp-ibm-bsd4.4 
    531         exit 0 ;; 
     530        echo romp-ibm-bsd4.4 
     531        exit 0 ;; 
    532532    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and 
    533         echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to 
    534         exit 0 ;;                           # report: romp-ibm BSD 4.3 
     533        echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to 
     534        exit 0 ;;                           # report: romp-ibm BSD 4.3 
    535535    *:BOSX:*:*) 
    536         echo rs6000-bull-bosx 
    537         exit 0 ;; 
     536        echo rs6000-bull-bosx 
     537        exit 0 ;; 
    538538    DPX/2?00:B.O.S.:*:*) 
    539         echo m68k-bull-sysv3 
    540         exit 0 ;; 
     539        echo m68k-bull-sysv3 
     540        exit 0 ;; 
    541541    9000/[34]??:4.3bsd:1.*:*) 
    542         echo m68k-hp-bsd 
    543         exit 0 ;; 
     542        echo m68k-hp-bsd 
     543        exit 0 ;; 
    544544    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) 
    545         echo m68k-hp-bsd4.4 
    546         exit 0 ;; 
     545        echo m68k-hp-bsd4.4 
     546        exit 0 ;; 
    547547    9000/[34678]??:HP-UX:*:*) 
    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` 
     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` 
    555555                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 
    556556                    case "${sc_cpu_version}" in 
     
    561561                          32) HP_ARCH="hppa2.0n" ;; 
    562562                          64) HP_ARCH="hppa2.0w" ;; 
    563                           '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20 
     563                          '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20 
    564564                        esac ;; 
    565565                    esac 
    566                 fi 
    567                 if [ "${HP_ARCH}" = "" ]; then 
    568                     eval $set_cc_for_build 
    569                     sed 's/^              //' << EOF >$dummy.c 
     566                fi 
     567                if [ "${HP_ARCH}" = "" ]; then 
     568                    eval $set_cc_for_build 
     569                    sed 's/^              //' << EOF >$dummy.c 
    570570 
    571571              #define _HPUX_SOURCE 
     
    581581 
    582582                  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: 
    587587              #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; 
    594594              #else  /* !defined(_SC_KERNEL_BITS) */ 
    595                     puts ("hppa2.0"); break; 
     595                          puts ("hppa2.0"); break; 
    596596              #endif 
    597                 default: puts ("hppa1.0"); break; 
    598                 } 
     597                      default: puts ("hppa1.0"); break; 
     598                      } 
    599599                  exit (0); 
    600600              } 
    601601EOF 
    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 ;; 
     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 ;; 
    609609    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 ;; 
    613613    3050*:HI-UX:*:*) 
    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         } 
     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        } 
    639639EOF 
    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 ;; 
     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 ;; 
    644644    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 
    645         echo hppa1.1-hp-bsd 
    646         exit 0 ;; 
     645        echo hppa1.1-hp-bsd 
     646        exit 0 ;; 
    647647    9000/8??:4.3bsd:*:*) 
    648         echo hppa1.0-hp-bsd 
    649         exit 0 ;; 
     648        echo hppa1.0-hp-bsd 
     649        exit 0 ;; 
    650650    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) 
    651         echo hppa1.0-hp-mpeix 
    652         exit 0 ;; 
     651        echo hppa1.0-hp-mpeix 
     652        exit 0 ;; 
    653653    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) 
    654         echo hppa1.1-hp-osf 
    655         exit 0 ;; 
     654        echo hppa1.1-hp-osf 
     655        exit 0 ;; 
    656656    hp8??:OSF1:*:*) 
    657         echo hppa1.0-hp-osf 
    658         exit 0 ;; 
     657        echo hppa1.0-hp-osf 
     658        exit 0 ;; 
    659659    i*86:OSF1:*:*) 
    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 ;; 
     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 ;; 
    666666    parisc*:Lites*:*:*) 
    667         echo hppa1.1-hp-lites 
    668         exit 0 ;; 
     667        echo hppa1.1-hp-lites 
     668        exit 0 ;; 
    669669    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 
    670         echo c1-convex-bsd 
     670        echo c1-convex-bsd 
    671671        exit 0 ;; 
    672672    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 
    673         if getsysinfo -f scalar_acc 
    674         then echo c32-convex-bsd 
    675         else echo c2-convex-bsd 
    676         fi 
     673        if getsysinfo -f scalar_acc 
     674        then echo c32-convex-bsd 
     675        else echo c2-convex-bsd 
     676        fi 
    677677        exit 0 ;; 
    678678    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 
    679         echo c34-convex-bsd 
     679        echo c34-convex-bsd 
    680680        exit 0 ;; 
    681681    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 
    682         echo c38-convex-bsd 
     682        echo c38-convex-bsd 
    683683        exit 0 ;; 
    684684    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 
    685         echo c4-convex-bsd 
     685        echo c4-convex-bsd 
    686686        exit 0 ;; 
    687687    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 ;; 
    690690    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 ;; 
    696696    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 ;; 
    699699    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 ;; 
    702702    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 ;; 
    705705    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 ;; 
    708708    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'` 
    710710        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 
    711711        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` 
     
    713713        exit 0 ;; 
    714714    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 ;; 
    717717    sparc*:BSD/OS:*:*) 
    718         echo sparc-unknown-bsdi${UNAME_RELEASE} 
    719         exit 0 ;; 
     718        echo sparc-unknown-bsdi${UNAME_RELEASE} 
     719        exit 0 ;; 
    720720    *:BSD/OS:*:*) 
    721         echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 
    722         exit 0 ;; 
     721        echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 
     722        exit 0 ;; 
    723723    *: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 ;; 
    726726    i*:CYGWIN*:*) 
    727         echo ${UNAME_MACHINE}-pc-cygwin 
    728         exit 0 ;; 
     727        echo ${UNAME_MACHINE}-pc-cygwin 
     728        exit 0 ;; 
    729729    i*:MINGW*:*) 
    730         echo ${UNAME_MACHINE}-pc-mingw32 
    731         exit 0 ;; 
     730        echo ${UNAME_MACHINE}-pc-mingw32 
     731        exit 0 ;; 
    732732    i*:PW*:*) 
    733         echo ${UNAME_MACHINE}-pc-pw32 
    734         exit 0 ;; 
     733        echo ${UNAME_MACHINE}-pc-pw32 
     734        exit 0 ;; 
    735735    x86:Interix*:3*) 
    736         echo i386-pc-interix3 
    737         exit 0 ;; 
     736        echo i386-pc-interix3 
     737        exit 0 ;; 
    738738    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 we 
    741         # UNAME_MACHINE based on the output of uname instead of i386? 
    742         echo i386-pc-interix 
    743         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 ;; 
    744744    i*:UWIN*:*) 
    745         echo ${UNAME_MACHINE}-pc-uwin 
    746         exit 0 ;; 
     745        echo ${UNAME_MACHINE}-pc-uwin 
     746        exit 0 ;; 
    747747    p*:CYGWIN*:*) 
    748         echo powerpcle-unknown-cygwin 
    749         exit 0 ;; 
     748        echo powerpcle-unknown-cygwin 
     749        exit 0 ;; 
    750750    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 ;; 
    753753    *: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 ;; 
    756756    i*86:Minix:*:*) 
    757         echo ${UNAME_MACHINE}-pc-minix 
    758         exit 0 ;; 
     757        echo ${UNAME_MACHINE}-pc-minix 
     758        exit 0 ;; 
    759759    arm*:Linux:*:*) 
    760         echo ${UNAME_MACHINE}-unknown-linux-gnu 
    761         exit 0 ;; 
     760        echo ${UNAME_MACHINE}-unknown-linux-gnu 
     761        exit 0 ;; 
    762762    ia64:Linux:*:*) 
    763         echo ${UNAME_MACHINE}-unknown-linux 
    764         exit 0 ;; 
     763        echo ${UNAME_MACHINE}-unknown-linux 
     764        exit 0 ;; 
    765765    m68*:Linux:*:*) 
    766         echo ${UNAME_MACHINE}-unknown-linux-gnu 
    767         exit 0 ;; 
     766        echo ${UNAME_MACHINE}-unknown-linux-gnu 
     767        exit 0 ;; 
    768768    mips:Linux:*:*) 
    769         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  
     769        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  
    783783EOF 
    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         ;; 
     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        ;; 
    788788    ppc:Linux:*:*) 
    789         echo powerpc-unknown-linux-gnu 
    790         exit 0 ;; 
     789        echo powerpc-unknown-linux-gnu 
     790        exit 0 ;; 
    791791    ppc64:Linux:*:*) 
    792         echo powerpc64-unknown-linux-gnu 
    793         exit 0 ;; 
     792        echo powerpc64-unknown-linux-gnu 
     793        exit 0 ;; 
    794794    alpha:Linux:*:*) 
    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 ;; 
     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 ;; 
    803803        esac 
    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 ;; 
     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 ;; 
    808808    parisc:Linux:*:* | hppa:Linux:*:*) 
    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 ;; 
     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 ;; 
    816816    parisc64:Linux:*:* | hppa64:Linux:*:*) 
    817         echo hppa64-unknown-linux-gnu 
    818         exit 0 ;; 
     817        echo hppa64-unknown-linux-gnu 
     818        exit 0 ;; 
    819819    s390:Linux:*:* | s390x:Linux:*:*) 
    820         echo ${UNAME_MACHINE}-ibm-linux 
    821         exit 0 ;; 
     820        echo ${UNAME_MACHINE}-ibm-linux 
     821        exit 0 ;; 
    822822    sh*:Linux:*:*) 
    823         echo ${UNAME_MACHINE}-unknown-linux-gnu 
    824         exit 0 ;; 
     823        echo ${UNAME_MACHINE}-unknown-linux-gnu 
     824        exit 0 ;; 
    825825    sparc:Linux:*:* | sparc64:Linux:*:*) 
    826         echo ${UNAME_MACHINE}-unknown-linux-gnu 
    827         exit 0 ;; 
     826        echo ${UNAME_MACHINE}-unknown-linux-gnu 
     827        exit 0 ;; 
    828828    x86_64:Linux:*:*) 
    829         echo x86_64-unknown-linux-gnu 
    830         exit 0 ;; 
     829        echo x86_64-unknown-linux-gnu 
     830        exit 0 ;; 
    831831    i*86:Linux:*:*) 
    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'` 
     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'` 
    842842        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) 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 
     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) 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 
    879879EOF 
    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         ;; 
     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        ;; 
    885885    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 both 
    888         # sysname and nodename. 
    889         echo i386-sequent-sysv4 
    890         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 ;; 
    891891    i*86:UNIX_SV:4.2MP:2.*) 
    892892        # Unixware is an offshoot of SVR4, but it has its own version 
    893893        # number series starting with 2... 
    894894        # 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. 
    896896        # 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 ;; 
    899899    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; then 
    902                 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} 
    903         else 
    904                 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} 
    905         fi 
    906         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 ;; 
    907907    i*86:*:5:[78]*) 
    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 ;; 
     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 ;; 
    915915    i*86:*:3.2:*) 
    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 ;; 
     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 ;; 
    933933    i*86:*DOS:*:*) 
    934         echo ${UNAME_MACHINE}-pc-msdosdjgpp 
    935         exit 0 ;; 
     934        echo ${UNAME_MACHINE}-pc-msdosdjgpp 
     935        exit 0 ;; 
    936936    pc:*:*:*) 
    937         # Left here for compatibility: 
     937        # Left here for compatibility: 
    938938        # uname -m prints for DJGPP always 'pc', but it prints nothing about 
    939939        # the processor, so we play safe by assuming i386. 
    940         echo i386-pc-msdosdjgpp 
     940        echo i386-pc-msdosdjgpp 
    941941        exit 0 ;; 
    942942    Intel:Mach:3*:*) 
    943         echo i386-pc-mach3 
    944         exit 0 ;; 
     943        echo i386-pc-mach3 
     944        exit 0 ;; 
    945945    paragon:*:*:*) 
    946         echo i860-intel-osf1 
    947         exit 0 ;; 
     946        echo i860-intel-osf1 
     947        exit 0 ;; 
    948948    i860:*:4.*:*) # i860-SVR4 
    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 ;; 
     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 ;; 
    955955    mini*:CTIX:SYS*5:*) 
    956         # "miniframe" 
    957         echo m68010-convergent-sysv 
    958         exit 0 ;; 
     956        # "miniframe" 
     957        echo m68010-convergent-sysv 
     958        exit 0 ;; 
    959959    M68*:*:R3V[567]*:*) 
    960         test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 
     960        test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 
    961961    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 0 
    967         /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 ;; 
    969969    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 
    970970        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 
    971971          && echo i486-ncr-sysv4 && exit 0 ;; 
    972972    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 ;; 
    975975    mc68030:UNIX_System_V:4.*:*) 
    976         echo m68k-atari-sysv4 
    977         exit 0 ;; 
     976        echo m68k-atari-sysv4 
     977        exit 0 ;; 
    978978    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 ;; 
    981981    TSUNAMI:LynxOS:2.*:*) 
    982         echo sparc-unknown-lynxos${UNAME_RELEASE} 
    983         exit 0 ;; 
     982        echo sparc-unknown-lynxos${UNAME_RELEASE} 
     983        exit 0 ;; 
    984984    rs6000:LynxOS:2.*:*) 
    985         echo rs6000-unknown-lynxos${UNAME_RELEASE} 
    986         exit 0 ;; 
     985        echo rs6000-unknown-lynxos${UNAME_RELEASE} 
     986        exit 0 ;; 
    987987    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 ;; 
    990990    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 ;; 
    993993    RM*:ReliantUNIX-*:*:*) 
    994         echo mips-sni-sysv4 
    995         exit 0 ;; 
     994        echo mips-sni-sysv4 
     995        exit 0 ;; 
    996996    RM*:SINIX-*:*:*) 
    997         echo mips-sni-sysv4 
    998         exit 0 ;; 
     997        echo mips-sni-sysv4 
     998        exit 0 ;; 
    999999    *:SINIX-*:*:*) 
    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 ;; 
     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 ;; 
    10071007    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 
    10081008                      # says <Richard.M.Bartel@ccMail.Census.GOV> 
     
    10101010        exit 0 ;; 
    10111011    *:UNIX_System_V:4*:FTX*) 
    1012         # From Gerald Hewes <hewes@openmarket.com>. 
    1013         # How about differentiating between stratus architectures? -djm 
    1014         echo hppa1.1-stratus-sysv4 
    1015         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 ;; 
    10161016    *:*:*:FTX*) 
    1017         # From seanf@swdc.stratus.com. 
    1018         echo i860-stratus-sysv4 
    1019         exit 0 ;; 
     1017        # From seanf@swdc.stratus.com. 
     1018        echo i860-stratus-sysv4 
     1019        exit 0 ;; 
    10201020    *:VOS:*:*) 
    1021         # From Paul.Green@stratus.com. 
    1022         echo hppa1.1-stratus-vos 
    1023         exit 0 ;; 
     1021        # From Paul.Green@stratus.com. 
     1022        echo hppa1.1-stratus-vos 
     1023        exit 0 ;; 
    10241024    mc68*:A/UX:*:*) 
    1025         echo m68k-apple-aux${UNAME_RELEASE} 
    1026         exit 0 ;; 
     1025        echo m68k-apple-aux${UNAME_RELEASE} 
     1026        exit 0 ;; 
    10271027    news*:NEWS-OS:6*:*) 
    1028         echo mips-sony-newsos6 
    1029         exit 0 ;; 
     1028        echo mips-sony-newsos6 
     1029        exit 0 ;; 
    10301030    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 
    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 ;; 
     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 ;; 
    10461046    SX-4:SUPER-UX:*:*) 
    1047         echo sx4-nec-superux${UNAME_RELEASE} 
    1048         exit 0 ;; 
     1047        echo sx4-nec-superux${UNAME_RELEASE} 
     1048        exit 0 ;; 
    10491049    SX-5:SUPER-UX:*:*) 
    1050         echo sx5-nec-superux${UNAME_RELEASE} 
    1051         exit 0 ;; 
     1050        echo sx5-nec-superux${UNAME_RELEASE} 
     1051        exit 0 ;; 
    10521052    Power*:Rhapsody:*:*) 
    1053         echo powerpc-apple-rhapsody${UNAME_RELEASE} 
    1054         exit 0 ;; 
     1053        echo powerpc-apple-rhapsody${UNAME_RELEASE} 
     1054        exit 0 ;; 
    10551055    *:Rhapsody:*:*) 
    1056         echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 
    1057         exit 0 ;; 
     1056        echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 
     1057        exit 0 ;; 
    10581058    *:Darwin:*:*) 
    1059         echo `uname -p`-apple-darwin${UNAME_RELEASE} 
    1060         exit 0 ;; 
     1059        echo `uname -p`-apple-darwin${UNAME_RELEASE} 
     1060        exit 0 ;; 
    10611061    *:procnto*:*:* | *:QNX:[0123456789]*:*) 
    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 ;; 
     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 ;; 
    10691069    *:QNX:*:4*) 
    1070         echo i386-pc-qnx 
    1071         exit 0 ;; 
     1070        echo i386-pc-qnx 
     1071        exit 0 ;; 
    10721072    NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) 
    1073         echo nsr-tandem-nsk${UNAME_RELEASE} 
    1074         exit 0 ;; 
     1073        echo nsr-tandem-nsk${UNAME_RELEASE} 
     1074        exit 0 ;; 
    10751075    *:NonStop-UX:*:*) 
    1076         echo mips-compaq-nonstopux 
    1077         exit 0 ;; 
     1076        echo mips-compaq-nonstopux 
     1077        exit 0 ;; 
    10781078    BS2000:POSIX*:*:*) 
    1079         echo bs2000-siemens-sysv 
    1080         exit 0 ;; 
     1079        echo bs2000-siemens-sysv 
     1080        exit 0 ;; 
    10811081    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 ;; 
    10841084    *:Plan9:*:*) 
    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 ;; 
     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 ;; 
    10951095    i*86:OS/2:*:*) 
    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 ;; 
     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 ;; 
    11001100    *:TOPS-10:*:*) 
    1101         echo pdp10-unknown-tops10 
    1102         exit 0 ;; 
     1101        echo pdp10-unknown-tops10 
     1102        exit 0 ;; 
    11031103    *:TENEX:*:*) 
    1104         echo pdp10-unknown-tenex 
    1105         exit 0 ;; 
     1104        echo pdp10-unknown-tenex 
     1105        exit 0 ;; 
    11061106    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) 
    1107         echo pdp10-dec-tops20 
    1108         exit 0 ;; 
     1107        echo pdp10-dec-tops20 
     1108        exit 0 ;; 
    11091109    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) 
    1110         echo pdp10-xkl-tops20 
    1111         exit 0 ;; 
     1110        echo pdp10-xkl-tops20 
     1111        exit 0 ;; 
    11121112    *:TOPS-20:*:*) 
    1113         echo pdp10-unknown-tops20 
    1114         exit 0 ;; 
     1113        echo pdp10-unknown-tops20 
     1114        exit 0 ;; 
    11151115    *:ITS:*:*) 
    1116         echo pdp10-unknown-its 
    1117         exit 0 ;; 
     1116        echo pdp10-unknown-its 
     1117        exit 0 ;; 
    11181118    i*86:XTS-300:*:STOP) 
    1119         echo ${UNAME_MACHINE}-unknown-stop 
    1120         exit 0 ;; 
     1119        echo ${UNAME_MACHINE}-unknown-stop 
     1120        exit 0 ;; 
    11211121    i*86:atheos:*:*) 
    1122         echo ${UNAME_MACHINE}-unknown-atheos 
    1123         exit 0 ;; 
     1122        echo ${UNAME_MACHINE}-unknown-atheos 
     1123        exit 0 ;; 
    11241124esac 
    11251125 
     
    11461146          "4" 
    11471147#else 
    1148           "" 
     1148          "" 
    11491149#endif 
    11501150         ); exit (0); 
     
    12041204 
    12051205    if (strncmp(un.version, "V2", 2) == 0) { 
    1206         printf ("i386-sequent-ptx2\n"); exit (0); 
     1206        printf ("i386-sequent-ptx2\n"); exit (0); 
    12071207    } 
    12081208    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); 
    12101210    } 
    12111211    printf ("i386-sequent-ptx\n"); exit (0); 
     
    12551255    case `getsysinfo -f cpu_type` in 
    12561256    c1*) 
    1257         echo c1-convex-bsd 
    1258         exit 0 ;; 
     1257        echo c1-convex-bsd 
     1258        exit 0 ;; 
    12591259    c2*) 
    1260         if getsysinfo -f scalar_acc 
    1261         then echo c32-convex-bsd 
    1262         else echo c2-convex-bsd 
    1263         fi 
    1264         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 ;; 
    12651265    c34*) 
    1266         echo c34-convex-bsd 
    1267         exit 0 ;; 
     1266        echo c34-convex-bsd 
     1267        exit 0 ;; 
    12681268    c38*) 
    1269         echo c38-convex-bsd 
    1270         exit 0 ;; 
     1269        echo c38-convex-bsd 
     1270        exit 0 ;; 
    12711271    c4*) 
    1272         echo c4-convex-bsd 
    1273         exit 0 ;; 
     1272        echo c4-convex-bsd 
     1273        exit 0 ;; 
    12741274    esac 
    12751275fi 
  • trunk/ithildin/autoconf/config.sub

    r490 r578  
    4848# The goal of this file is to map all the various variations of a given 
    4949# machine specification into a single specification in the form: 
    50 #       CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 
     50#        CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 
    5151# or in some cases, the newer four-part form: 
    52 #       CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 
     52#        CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 
    5353# It is wrong to echo any other type of specification. 
    5454 
     
    9191    -- )     # Stop option processing 
    9292       shift; break ;; 
    93     - ) # Use stdin as input. 
     93    - )        # Use stdin as input. 
    9494       break ;; 
    9595    -* ) 
     
    136136### can provide default operating systems below. 
    137137case $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=$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                 ;; 
     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                ;; 
    221221esac 
    222222 
    223223# Decode aliases for certain CPU-COMPANY combinations. 
    224224case $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-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                 ;; 
     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                ;; 
    547547# 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=-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                 ;; 
     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                ;; 
    731731        pc532 | pc532-*) 
    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                 ;; 
     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                ;; 
    869869        sv1) 
    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-*) 
     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-*) 
    927927               basic_machine=f301-fujitsu 
    928928               ;; 
    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                 ;; 
     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                ;; 
    953953        xps | xps100) 
    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                 ;; 
     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                ;; 
    968968 
    969969# Here we handle the default manufacturer of certain CPU types.  It is in 
    970970# some cases the only manufacturer, in others, it is the most popular. 
    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                 ;; 
     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                ;; 
    10081008        cydra) 
    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                 ;; 
     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                ;; 
    10341034esac 
    10351035 
    10361036# Here we canonicalize certain aliases for manufacturers. 
    10371037case $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                ;; 
    10461046esac 
    10471047 
     
    10531053        # First match some system type aliases 
    10541054        # 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=-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                 ;; 
     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                ;; 
    11971197        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 
    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                 ;; 
     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                ;; 
    12081208esac 
    12091209else 
     
    12201220 
    12211221case $basic_machine in 
    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                 ;; 
     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                ;; 
    12351235        pdp11-*) 
    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                 ;; 
     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                ;; 
    13281328        *-gould) 
    1329                 os=-sysv 
    1330                 ;; 
     1329                os=-sysv 
     1330                ;; 
    13311331        *-highlevel) 
    1332                 os=-bsd 
    1333                 ;; 
    1334         *-encore) 
    1335                 os=-bsd 
    1336                 ;; 
     1332                os=-bsd 
     1333                ;; 
     1334        *-encore) 
     1335                os=-bsd 
     1336                ;; 
    13371337        *-sgi) 
    1338                 os=-irix 
    1339                 ;; 
     1338                os=-irix 
     1339                ;; 
    13401340        *-siemens) 
    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                 ;; 
     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                ;; 
    13641364esac 
    13651365fi 
     
    13691369vendor=unknown 
    13701370case $basic_machine in 
    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                 ;; 
     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                ;; 
    14331433esac 
    14341434 
  • trunk/ithildin/autoconf/configure.ac

    r539 r578  
    3838case `$CC -V 2>&1` in 
    3939    *Intel*) 
    40         AC_MSG_RESULT([yes]) 
    41         ICC=yes 
     40        AC_MSG_RESULT([yes]) 
     41        ICC=yes 
    4242    ;; 
    4343    *) 
    44         AC_MSG_RESULT([no]) 
     44        AC_MSG_RESULT([no]) 
    4545    ;; 
    4646esac 
     
    8888else 
    8989    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!]) 
    9494    fi 
    9595fi 
     
    9999else 
    100100    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!]) 
    105105    fi 
    106106fi 
     
    110110else 
    111111    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!]) 
    116116    fi 
    117117fi 
     
    178178 
    179179    if (fp != NULL) { 
    180         fprintf(fp, "%d\n", getpagesize()); 
    181         fclose(fp); 
     180        fprintf(fp, "%d\n", getpagesize()); 
     181        fclose(fp); 
    182182    } else 
    183         exit(1); 
     183        exit(1); 
    184184    exit(0); 
    185185}],[ 
     
    192192else 
    193193    if test "$ac_cv_sizeof_int" = "4" ; then 
    194         pagesize=4096 
    195     else 
    196         pagesize=8192 
     194        pagesize=4096 
     195    else 
     196        pagesize=8192 
    197197    fi 
    198198    AC_MSG_RESULT([$pagesize (guessing)]) 
     
    218218    malloc(42); 
    219219    if (okay) 
    220         exit(0); 
     220        exit(0); 
    221221    exit(1); 
    222222}],[malloc_override="yes"]) 
     
    252252    CFLAGSDLL="${CFLAGSDLL} -fPIC -DPIC -shared" 
    253253    else if test -n "$ICC" ; then 
    254         CFLAGSDLL="${CFLAGSDLL} -KPIC -DPIC -shared" 
     254        CFLAGSDLL="${CFLAGSDLL} -KPIC -DPIC -shared" 
    255255    fi 
    256256fi 
     
    281281AC_ARG_WITH(poller, 
    282282    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)]), 
    284284    POLLER="$with_poller" 
    285285    ithildin_cv_poller="$POLLER" 
     
    291291if test "x$POLLER" = "x" ; then 
    292292    case "$host_os" in 
    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         ;; 
     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        ;; 
    303303    esac 
    304304 
    305305    if test -z "$POLLER" ; then 
    306         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 
     306        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 
    318318    fi 
    319319fi 
     
    324324case "$POLLER" in 
    325325    select) 
    326         AC_DEFINE(POLLER_SELECT, 1, [The select() system call]) 
     326        AC_DEFINE(POLLER_SELECT, 1, [The select() system call]) 
    327327    ;; 
    328328    poll) 
    329         AC_DEFINE(POLLER_POLL, 1, [The poll() system call]) 
     329        AC_DEFINE(POLLER_POLL, 1, [The poll() system call]) 
    330330    ;; 
    331331    kqueue) 
    332         AC_DEFINE(POLLER_KQUEUE, 1, [The kqueue() system call]) 
     332        AC_DEFINE(POLLER_KQUEUE, 1, [The kqueue() system call]) 
    333333    ;; 
    334334    devpoll) 
    335         AC_DEFINE(POLLER_DEVPOLL, 1, [The /dev/poll device]) 
     335        AC_DEFINE(POLLER_DEVPOLL, 1, [The /dev/poll device]) 
    336336    ;; 
    337337    *) 
    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, 
    339339try again?]) 
    340340    ;; 
     
    347347ith_feature_append () { 
    348348    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}, $*" 
    352352    fi 
    353353} 
     
    364364AC_ARG_WITH(ipv6, 
    365365    AC_HELP_STRING([--with-ipv6], 
    366         [enable IPv6 support]), 
     366        [enable IPv6 support]), 
    367367    [if test -z "$withval" ; then 
    368         with_ipv6="yes" 
     368        with_ipv6="yes" 
    369369    fi] 
    370370) 
     
    373373    AC_MSG_CHECKING([whether to support IPv6]) 
    374374    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 support 
     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 support 
    380380    fi 
    381381else 
     
    388388AC_ARG_WITH(openssl, 
    389389    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)]), 
    391391    [if test -z "$withval" ; then 
    392         with_openssl="yes" 
     392        with_openssl="yes" 
    393393    fi] 
    394394) 
     
    396396if test "x$with_openssl" != "xno" ; then 
    397397    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]) 
    402402    fi 
    403403 
     
    406406    LIBS="$LIBS -lssl -lcrypto" 
    407407    AC_TRY_LINK([#include <openssl/ssl.h>],[SSL_accept(NULL);], 
    408         have_openssl="yes") 
     408        have_openssl="yes") 
    409409 
    410410    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 ; 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 
     411        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 
    425425    fi 
    426426 
    427427    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 support 
    431     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) 
    435435    fi 
    436436fi 
     
    442442AC_ARG_WITH(modules, 
    443443    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/)]), 
    445445    if test -n "$withval " ; then 
    446         if test "$withval" != "yes" -a "$withval" != "no" ; then 
    447             MODULES="$withval" 
    448         fi 
     446        if test "$withval" != "yes" -a "$withval" != "no" ; then 
     447            MODULES="$withval" 
     448        fi 
    449449    fi 
    450450) 
     
    452452AC_ARG_WITH(dmalloc, 
    453453    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)]), 
    455455    if test "x$withval" != "no" ; then 
    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]) 
     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]) 
    466466    fi 
    467467) 
    468468AC_ARG_ENABLE(debug, 
    469469    AC_HELP_STRING([--enable-debug], 
    470         [enable debugging in code (changes CFLAGS, adds code)]), 
     470        [enable debugging in code (changes CFLAGS, adds code)]), 
    471471    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" 
    473473    fi 
    474474    AC_DEFINE(DEBUG_CODE, 1, [Extra debugging instructions]) 
     
    476476AC_ARG_ENABLE(custom-libc, 
    477477    AC_HELP_STRING([--disable-custom-libc], 
    478         [disable custom libc functions (slower!)]), 
     478        [disable custom libc functions (slower!)]), 
    479479    AC_DEFINE(NO_INTERNAL_LIBC, 1, [No internal libc functions]), 
    480480    ith_feature_append internal libc functions 
     
    482482AC_ARG_ENABLE(fd-setsize, 
    483483    AC_HELP_STRING([--enable-fd-setsize], 
    484         [set FD_SETSIZE to the specified value (useful only if your system is 
     484        [set FD_SETSIZE to the specified value (useful only if your system is 
    485485using select() and you you want more file descriptors to work)]), 
    486486    AC_DEFINE_UNQUOTED(FD_SETSIZE, $enable_fd_setsize, 
    487         [the size of FD_SETSIZE]), 
     487        [the size of FD_SETSIZE]), 
    488488) 
    489489 
     
    491491AC_ARG_ENABLE(dir-suffix, 
    492492    AC_HELP_STRING([--disable-dir-suffix], 
    493         [keep 'make install' from appending the package name to target 
     493        [keep 'make install' from appending the package name to target 
    494494installation directories]), 
    495495    DIRSUFFIX="" 
  • trunk/ithildin/autoconf/install-sh

    r490 r578  
    4545while [ x"$1" != x ]; do 
    4646    case $1 in 
    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;; 
     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;; 
    9292    esac 
    9393done 
     
    9595if [ x"$src" = x ] 
    9696then 
    97         echo "install:  no input file specified" 
    98         exit 1 
     97        echo "install:        no input file specified" 
     98        exit 1 
    9999else 
    100         true 
     100        true 
    101101fi 
    102102 
    103103if [ x"$dir_arg" != x ]; then 
    104         dst=$src 
    105         src="" 
    106          
    107         if [ -d $dst ]; then 
    108                 instcmd=: 
    109         else 
    110                 instcmd=mkdir 
    111         fi 
     104        dst=$src 
     105        src="" 
     106         
     107        if [ -d $dst ]; then 
     108                instcmd=: 
     109        else 
     110                instcmd=mkdir 
     111        fi 
    112112else 
    113113 
     
    116116# if $src (and thus $dsttmp) contains '*'. 
    117117 
    118         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 
     118        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 
    133133 
    134134# If destination is a directory, append the input filename; if your system 
    135135# does not like double slashes in filenames, you may need to add some logic 
    136136 
    137         if [ -d $dst ] 
    138         then 
    139                 dst="$dst"/`basename $src` 
    140         else 
    141                 true 
    142         fi 
     137        if [ -d $dst ] 
     138        then 
     139                dst="$dst"/`basename $src` 
     140        else 
     141                true 
     142        fi 
    143143fi 
    144144 
     
    151151# Skip lots of stat calls in the usual case. 
    152152if [ ! -d "$dstdir" ]; then 
    153 defaultIFS='     
     153defaultIFS='         
    154154' 
    155155IFS="${IFS-${defaultIFS}}" 
     
    164164 
    165165while [ $# -ne 0 ] ; do 
    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}/" 
     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}/" 
    177177done 
    178178fi 
     
    180180if [ x"$dir_arg" != x ] 
    181181then 
    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 ; fi 
     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 ; fi 
    188188else 
    189189 
    190190# If we're going to rename the final executable, determine the name now. 
    191191 
    192         if [ x"$transformarg" = x ]  
    193         then 
    194                 dstfile=`basename $dst` 
    195         else 
    196                 dstfile=`basename $dst $transformbasename |  
    197                         sed $transformarg`$transformbasename 
    198         fi 
     192        if [ x"$transformarg" = x ]  
     193        then 
     194                dstfile=`basename $dst` 
     195        else 
     196                dstfile=`basename $dst $transformbasename |  
     197                        sed $transformarg`$transformbasename 
     198        fi 
    199199 
    200200# don't allow the sed command to completely eliminate the filename 
    201201 
    202         if [ x"$dstfile" = x ]  
    203         then 
    204                 dstfile=`basename $dst` 
    205         else 
    206                 true 
    207         fi 
     202        if [ x"$dstfile" = x ]  
     203        then 
     204                dstfile=`basename $dst` 
     205        else 
     206                true 
     207        fi 
    208208 
    209209# Make a temp file name in the proper directory. 
    210210 
    211         dsttmp=$dstdir/#inst.$$# 
     211        dsttmp=$dstdir/#inst.$$# 
    212212 
    213213# Move or copy the file name to the temp name 
    214214 
    215         $doit $instcmd $src $dsttmp && 
    216  
    217         trap "rm -f ${dsttmp}" 0 && 
     215        $doit $instcmd $src $dsttmp && 
     216 
     217        trap "rm -f ${dsttmp}" 0 && 
    218218 
    219219# and set any options; do chmod last to preserve setuid bits 
     
    223223# errors from the above "$doit $instcmd $src $dsttmp" command. 
    224224 
    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 && 
    229229 
    230230# Now rename the file to the real destination. 
    231231 
    232         $doit $rmcmd -f $dstdir/$dstfile && 
    233         $doit $mvcmd $dsttmp $dstdir/$dstfile  
     232        $doit $rmcmd -f $dstdir/$dstfile && 
     233        $doit $mvcmd $dsttmp $dstdir/$dstfile  
    234234 
    235235fi && 
  • trunk/ithildin/doc/conf/ithildin.conf

    r490 r578  
    4545 
    4646    module log { // define a module's information 
    47         file "log.so"; // this is our module 
    48         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) 
    4949    }; 
    5050 
    5151    module dns { 
    52         file "dns.so"; // non-blocking dns module 
    53         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        }; 
    5757    }; 
    5858    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        }; 
    6565    }; 
    6666 
  • trunk/ithildin/doc/conf/proxyscan.conf

    r490 r578  
    66** 
    77*/ 
    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-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 
     8bind        "0.0.0.0";        // address to bind to (default is inaddr_any) 
     9timeout        20;                // time in seconds to wait for sockets to time-out 
     10expire        3600;                // time in seconds to keep cached scan results 
     11cache        32768;                // number of cache results to keep at most. 
     12data        "/path/to/save/data"; // file in which saved statistical data lives 
    1313 
    1414/* 
     
    4848 
    4949skip { 
    50     0.0.0.0/32;     // inaddr_any 
     50    0.0.0.0/32;            // inaddr_any 
    5151    127.0.0.0/8;    // localhost 
    52     10.0.0.0/8;     // internal networks 
     52    10.0.0.0/8;            // internal networks 
    5353    172.16.0.0/12; 
    5454    192.168.0.0/16; 
  • trunk/ithildin/doc/style.txt

    r495 r578  
    8585 * aligned whenever possible. */ 
    8686struct 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. 
    9090 
    9191    LIST_ENTRY(foo) lp; /* a list entry.  lists should be rolled with the 
    92                            macros in queue.h unless there is a pressing reason 
    93                            not to do so. */ 
     92                           macros in queue.h unless there is a pressing reason 
     93                           not to do so. */ 
    9494}; 
    9595 
  • trunk/ithildin/include/ithildin/conf.h

    r576 r578  
    3030 * sub-tree, or an actual single entry of data which is terminating. */ 
    3131struct conf_entry { 
    32     char    *name;      /* the name of the entry */ 
     32    char    *name;        /* the name of the entry */ 
    3333    char    *string;    /* string (if this is a single data entry) */ 
    3434    conf_list_t *list;  /* list of stuff (if this is a list entry) string 
    35                            may also be filled out if this list has a 
    36                            name */ 
     35                           may also be filled out if this list has a 
     36                           name */ 
    3737    conf_list_t *parent;/* parent of this entry, this should never be 
    38                            null! */ 
     38                           null! */ 
    3939 
    4040#define CONF_TYPE_LIST 0x1 
    4141#define CONF_TYPE_DATA 0x2 
    42     int type; 
     42    int        type; 
    4343 
    4444    LIST_ENTRY(conf_entry) lp; 
    4545 
    46 };       
     46};         
    4747 
    4848/* general conf handling calls */ 
     
    5454conf_entry_t *conf_find(const char *, const char *, int, conf_list_t *, int); 
    5555conf_entry_t *conf_find_next(const char *, const char *, int, conf_entry_t *, 
    56         conf_list_t *, int); 
     56        conf_list_t *, int); 
    5757conf_list_t *conf_find_list(const char *, conf_list_t *, int); 
    5858conf_list_t *conf_find_list_next(const char *, conf_list_t *, conf_list_t *, 
    59         int); 
     59        int); 
    6060char *conf_find_entry(const char *, conf_list_t *, int); 
    6161char *conf_find_entry_next(const char *, char *, conf_list_t *, int); 
  • trunk/ithildin/include/ithildin/event.h

    r576 r578  
    1616/* The event structure.  Intentionally pretty small. */ 
    1717struct 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 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 */ 
     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 */ 
    3232}; 
    3333 
     
    5959 * indicate some measure of success or failure.  The above values *SHOULD NOT* 
    6060 * 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 */ 
    6666 
    6767/* the simple hook structure.  holds a 'hook_function' and a list pointer 
     
    7070    hook_function_t function; 
    7171    int flags; 
    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. */ 
     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. */ 
    7979 
    8080    SLIST_ENTRY(hook) lp; 
  • trunk/ithildin/include/ithildin/global.h

    r576 r578  
    2222extern struct me_t { 
    2323    char    conf_path[PATH_MAX];/* path where data (conf files, 
    24                                    motd, etc) live */ 
     24                                   motd, etc) live */ 
    2525    char    conf_file[PATH_MAX];/* explicit name of conf file */ 
    2626    char    lib_path[PATH_MAX]; 
    2727    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 is 
    32                                    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) */ 
    3333 
    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 */ 
    3636 
    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? */ 
     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? */ 
    4444     
    4545#ifdef HAVE_OPENSSL 
    4646    /* various ssl configuration items. */ 
    4747    struct { 
    48         bool enabled;           /* set if SSL support is enabled. */ 
     48        bool enabled;                /* set if SSL support is enabled. */ 
    4949 
    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. */ 
     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. */ 
    6363    } ssl; 
    6464#endif 
    6565 
    66     conf_list_t *confhead;      /* head of configuration data */ 
     66    conf_list_t *confhead;        /* head of configuration data */ 
    6767 
    6868    LIST_HEAD(, module) modules; 
     
    7171    /* static events */ 
    7272    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 */ 
    7878 
    79         event_t *read_conf;     /* hooked when the conf is read */ 
     79        event_t *read_conf;        /* hooked when the conf is read */ 
    8080 
    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 */ 
    8383 
    84         event_t *afterpoll;     /* called after each polling run */ 
     84        event_t *afterpoll;        /* called after each polling run */ 
    8585 
    86         event_t *shutdown;      /* called just prior to shutdown */ 
     86        event_t *shutdown;        /* called just prior to shutdown */ 
    8787 
    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 */ 
    9393    } events; 
    9494} me; 
  • trunk/ithildin/include/ithildin/hash.h

    r576 r578  
    1616struct hashent { 
    1717    void    *ent; 
    18     unsigned int hv;        /* full hash value (i.e. no modulus).  makes for 
    19                                quick compares. */ 
     18    unsigned int hv;            /* full hash value (i.e. no modulus).  makes for 
     19                               quick compares. */ 
    2020    SLIST_ENTRY(hashent) lp; 
    2121}; 
    2222 
    2323struct hashtable { 
    24     int     size;           /* thte size of the hash table */ 
     24    int            size;            /* thte size of the hash table */ 
    2525#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 */ 
    2727#define hashtable_count(x) ((x)->entries) 
    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. */ 
     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. */ 
    3434 
    3535    /* these are useful for debugging the state of the hash system */ 
    3636#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 */ 
    3939#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 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; 
     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; 
    4747    /* the symbol for our comparison function, used in hash_find_ent().  This 
    4848     * behaves much like the compare function used in qsort().  This means that 
  • trunk/ithildin/include/ithildin/log.h

    r576 r578  
    4242#if defined(__GNUC__) || __STDC_VERSION__ >= 199901L 
    4343# 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__) 
    4646# else 
    4747#  define log_debug(msg, ...) ((void)0) 
    4848# 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__) 
    5353# define log_error(msg, ...) log_msg(LOGTYPE_ERROR, LOG_MODULENAME, msg,\ 
    54         ## __VA_ARGS__) 
     54        ## __VA_ARGS__) 
    5555#else 
    5656# define NEED_INDIVIDUAL_LOG_FUNCTIONS 
  • trunk/ithildin/include/ithildin/malloc.h

    r576 r578  
    1111#define MALLOC_H 
    1212 
    13 #if !defined(NO_INTERNAL_LIBC) && !defined(USE_DMALLOC) &&              \ 
     13#if !defined(NO_INTERNAL_LIBC) && !defined(USE_DMALLOC) &&                \ 
    1414    defined(MALLOC_LOWLEVEL) 
    1515# define USE_INTERNAL_MALLOC 
  • trunk/ithildin/include/ithildin/md5.h

    r576 r578  
    2929/* MD5 context. */ 
    3030typedef 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 */ 
    3434} ith_md5_ctx; 
    3535 
  • trunk/ithildin/include/ithildin/module.h

    r576 r578  
    1515struct module_header { 
    1616    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; 
    2121    } baseversion; 
    2222 
    23     const char  *version; 
     23    const char        *version; 
    2424}; 
    2525 
    2626SLIST_HEAD(module_savedata_list, module_savedata); 
    2727struct 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 */ 
    3131 
    3232    SLIST_ENTRY(module_savedata) lp; 
     
    3939 
    4040typedef int (*module_load_function)(int, struct module_savedata_list *, 
    41         conf_list_t **, module_t *); 
     41        conf_list_t **, module_t *); 
    4242typedef void (*module_unload_function)(int, struct module_savedata_list *); 
    4343struct module { 
    4444    struct module_header *header; 
    4545 
    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 */ 
     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 */ 
    5151    conf_list_t *confdata; 
    5252    module_load_function load_function; 
     
    5959    LIST_HEAD(, module_dependency) deps; 
    6060 
    61     int flags; 
     61    int        flags; 
    6262#define MODULE_FL_LOADED 0x1 
    6363#define MODULE_FL_DEPENDLOAD 0x2 
     
    7878    /* this one sets an internal reload state */ 
    7979#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 */ 
    8181 
    8282    LIST_ENTRY(module) lp; 
     
    100100 * reload is occuring, the module may have data it wishes to resurrect that it 
    101101 * 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)                                                \ 
     103int x##_loader(int, struct module_savedata_list *, conf_list_t **,        \ 
     104        module_t *);                                                        \ 
     105int x##_loader(int reload, struct module_savedata_list *savelist,        \ 
     106        conf_list_t **confdata, module_t *module) 
     107 
     108#define MODULE_UNLOADER(x)                                                \ 
     109void x##_unloader(int, struct module_savedata_list *);                        \ 
    110110void x##_unloader(int reload, struct module_savedata_list *savelist) 
    111111 
     
    134134 
    135135void add_module_savedata(struct module_savedata_list *, const char *, size_t, 
    136         const void *); 
     136        const void *); 
    137137size_t get_module_savedata(struct module_savedata_list *, const char *, 
    138         void *); 
     138        void *); 
    139139 
    140140/* msymbol definitions */ 
    141141typedef struct msymbol msymbol_t; 
    142142struct msymbol { 
    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 */ 
     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 */ 
    147147 
    148148    LIST_ENTRY(msymbol) lp; 
     
    155155((sym->module != NULL && sym->module->handle == NULL) ?                       \ 
    156156 (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) 
    158158#else 
    159159# define getsym(sym) (sym->val) 
     
    164164 
    165165struct mdext_item { 
    166     int     offset; /* offset into the data */ 
     166    int            offset; /* offset into the data */ 
    167167    size_t  size;   /* size of the data at the offset */ 
    168168 
     
    171171 
    172172struct 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 */ 
    176176    SLIST_HEAD(, mdext_item) items; /* items defining this data */ 
    177177 
  • trunk/ithildin/include/ithildin/queue.h

    r490 r578  
    99 
    1010#ifndef QUEUE_H 
    11 #define QUEUE_H 
     11#define        QUEUE_H 
    1212 
    1313/* a shim struct for the *_ALLOC calls. */ 
     
    1717 
    1818#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));                                                \ 
    2222} while (0) 
    2323#undef SLIST_FREE 
    24 #define SLIST_FREE(head) do {                                           \ 
    25         free((head));                                                   \ 
     24#define SLIST_FREE(head) do {                                                \ 
     25        free((head));                                                        \ 
    2626} while (0) 
    2727 
    2828#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));                                                \ 
    3232} while (0) 
    3333#undef STAILQ_FREE 
    34 #define STAILQ_FREE(head) do {                                          \ 
    35         free((head));                                                   \ 
     34#define STAILQ_FREE(head) do {                                                \ 
     35        free((head));                                                        \ 
    3636} while (0) 
    3737 
    3838#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));                                                \ 
    4242} while (0) 
    4343#undef LIST_FREE 
    44 #define LIST_FREE(head) do {                                            \ 
    45         free((head));                                                   \ 
     44#define LIST_FREE(head) do {                                                \ 
     45        free((head));                                                        \ 
    4646} while (0) 
    4747 
    4848#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));                                                \ 
    5252} while (0) 
    5353#undef TAILQ_FREE 
    54 #define TAILQ_FREE(head) do {                                           \ 
    55         free((head));                                                   \ 
     54#define TAILQ_FREE(head) do {                                                \ 
     55        free((head));                                                        \ 
    5656} while (0) 
    5757 
     
    135135/* 
    136136 * 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. 
    138138 * 
    139139 * Redistribution and use in source and binary forms, with or without 
     
    161161 * SUCH DAMAGE. 
    162162 * 
    163  *      @(#)queue.h     8.5 (Berkeley) 8/20/94 
     163 *        @(#)queue.h        8.5 (Berkeley) 8/20/94 
    164164 * $FreeBSD: src/sys/sys/queue.h,v 1.54 2002/08/05 05:18:43 alfred Exp $ 
    165165 */ 
     
    207207 * 
    208208 * 
    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              +       +       +       + 
     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                +        +        +        + 
    228228 * 
    229229 */ 
     
    231231/* Store the last 2 places the queue element or head was altered */ 
    232232struct 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; 
    237237}; 
    238238 
    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__;                                \ 
    254254} while (0) 
    255255 
     
    259259#define TRACEBUF 
    260260#define TRASHIT(x) 
    261 #endif  /* QUEUE_MACRO_DEBUG */ 
     261#endif        /* QUEUE_MACRO_DEBUG */ 
    262262 
    263263/* 
    264264 * Singly-linked List declarations. 
    265265 */ 
    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)                                                \ 
     267struct name {                                                                \ 
     268        struct type *slh_first;        /* first element */                        \ 
     269} 
     270 
     271#define        SLIST_HEAD_INITIALIZER(head)                                        \ 
     272        { NULL } 
    273273  
    274 #define SLIST_ENTRY(type)                                               \ 
    275 struct {                                                                \ 
    276         struct type *sle_next;  /* next element */                      \ 
     274#define        SLIST_ENTRY(type)                                                \ 
     275struct {                                                                \ 
     276        struct type *sle_next;        /* next element */                        \ 
    277277} 
    278278  
     
    280280 * Singly-linked List functions. 
    281281 */ 
    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);        \ 
    327327} while (0) 
    328328 
     
    330330 * Singly-linked Tail queue declarations. 
    331331 */ 
    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)                                                \ 
     333struct 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)                                                \ 
     342struct {                                                                \ 
     343        struct type *stqe_next;        /* next element */                        \ 
    344344} 
    345345 
     
    347347 * Singly-linked Tail queue functions. 
    348348 */ 
    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));                \ 
    420420} while (0) 
    421421 
     
    423423 * List declarations. 
    424424 */ 
    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)                                                \ 
     426struct name {                                                                \ 
     427        struct type *lh_first;        /* first element */                        \ 
     428} 
     429 
     430#define        LIST_HEAD_INITIALIZER(head)                                        \ 
     431        { NULL } 
     432 
     433#define        LIST_ENTRY(type)                                                \ 
     434struct {                                                                \ 
     435        struct type *le_next;        /* next element */                        \ 
     436        struct type **le_prev;        /* address of previous next element */        \ 
    437437} 
    438438 
     
    441441 */ 
    442442 
    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);                \ 
    485485} while (0) 
    486486 
     
    488488 * Tail queue declarations. 
    489489 */ 
    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)                                                \ 
     491struct 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)                                                \ 
     501struct {                                                                \ 
     502        struct type *tqe_next;        /* next element */                        \ 
     503        struct type **tqe_prev;        /* address of previous next element */        \ 
     504        TRACEBUF                                                        \ 
    505505} 
    506506 
     
    508508 * Tail queue functions. 
    509509 */ 
    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);                                        \ 
    605605} while (0) 
    606606 
  • trunk/ithildin/include/ithildin/socket.h

    r576 r578  
    1212 
    1313/* these are some defined maximums for lengths. */ 
    14 #define HOSTNAME_MAXLEN 63 
    15 #define FQDN_MAXLEN     255 
     14#define HOSTNAME_MAXLEN        63 
     15#define FQDN_MAXLEN        255 
    1616 
    1717#ifdef INET6 
    18 #define IPADDR_MAXLEN   39 
    19 #define IPADDR_SIZE     16 
     18#define IPADDR_MAXLEN        39 
     19#define IPADDR_SIZE        16 
    2020#else 
    21 #define IPADDR_MAXLEN   15 
    22 #define IPADDR_SIZE     4 
     21#define IPADDR_MAXLEN        15 
     22#define IPADDR_SIZE        4 
    2323#endif 
    2424 
     
    2828struct isock_address { 
    2929    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 */ 
    3434}; 
    35              
     35             
    3636LIST_HEAD(isocket_list, isocket); 
    3737 
    3838struct isocket { 
    39     int     fd;             /* file descriptor */ 
     39    int            fd;                    /* file descriptor */ 
    4040#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 */ 
    4343#endif 
    4444 
     
    4949 
    5050    struct event *datahook; 
    51     void    *udata;         /* user data...useful for when sockets are 
    52                                hooked */ 
     51    void    *udata;            /* user data...useful for when sockets are 
     52                               hooked */ 
    5353 
    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          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 
     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                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 
    6767 
    6868#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) 
    7272#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) 
    7575#endif 
    7676 
    77 #define SOCKET_FL_DEAD          (0x8000 << 16) 
     77#define SOCKET_FL_DEAD                (0x8000 << 16) 
    7878 
    7979#define SOCKET_FL_READ SOCKET_FL_READ_PENDING 
    8080#define SOCKET_FL_WRITE SOCKET_FL_WRITE_PENDING 
    8181#define SOCKET_FL_PENDING (SOCKET_FL_READ_PENDING | SOCKET_FL_WRITE_PENDING | \ 
    82         SOCKET_FL_ERROR_PENDING) 
     82        SOCKET_FL_ERROR_PENDING) 
    8383 
    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) 
    8989 
    9090    LIST_ENTRY(isocket) intlp; /* only for use in the 'allsockets' list! */ 
     
    151151#define getaddrinfo getaddrinfo__compat 
    152152int getaddrinfo__compat(const char *hostname, const char *servname, 
    153         const struct addrinfo *hints, struct addrinfo **res); 
     153        const struct addrinfo *hints, struct addrinfo **res); 
    154154#define getnameinfo getnameinfo__compat 
    155155int 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); 
    157157#define gai_strerror gai_strerror__compat 
    158158const char *gai_strerror__compat(int ecode); 
     
    163163#define inet_pton inet_pton__compat 
    164164const char *inet_ntop__compat(int af, const void *addr, char *numaddr, 
    165         size_t numaddr_len); 
     165        size_t numaddr_len); 
    166166#endif 
    167167#ifndef HAVE_INET_NTOP 
  • trunk/ithildin/include/ithildin/string.h

    r576 r578  
    106106/* baseX encoding/decoding/conversion functions.  please note that, in the case 
    107107 * of base64, it is *NOT* compatible with RFC1521! */ 
    108 #define BASE2_ENCODING  1 
    109 #define BASE4_ENCODING  2 
    110 #define BASE8_ENCODING  3 
    111 #define BASE16_ENCODING 4 
     108#define BASE2_ENCODING        1 
     109#define BASE4_ENCODING        2 
     110#define BASE8_ENCODING        3 
     111#define BASE16_ENCODING        4 
    112112#define BASE32_ENCODING 5 
    113 #define BASE64_ENCODING 6 
     113#define BASE64_ENCODING        6 
    114114size_t str_base_encode(char, char *, char *, size_t); 
    115115size_t str_base_decode(char, char *, char *, size_t); 
  • trunk/ithildin/include/ithildin/timer.h

    r576 r578  
    1818 * data values pertaining to execution time. */ 
    1919struct timer_event { 
    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 */ 
     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 */ 
    2929 
    3030    LIST_ENTRY(timer_event) lp; 
  • trunk/ithildin/source/Makefile.in

    r576 r578  
    3030 
    3131# 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.c 
     32SOURCES = 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 
    3434OBJECTS = $(SOURCES:.c=.o) 
    3535 
     
    3737 
    3838all: $(OBJECTS) md5sum 
    39         $(CC) $(LDFLAGS) -o $(PACKAGE) $(OBJECTS) $(LIBS) 
    40         ls -l $(PACKAGE) 
     39        $(CC) $(LDFLAGS) -o $(PACKAGE) $(OBJECTS) $(LIBS) 
     40        ls -l $(PACKAGE) 
    4141 
    4242# generic compile ruleset 
    4343.c.o:  
    44         $(CC) $(CFLAGS) $(INCLUDES) -c $< 
     44        $(CC) $(CFLAGS) $(INCLUDES) -c $< 
    4545# special stuff: 
    4646main.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.c 
     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.c 
    4848 
    4949md5sum: md5sum.o 
    50         $(CC) $(LDFLAGS) -o md5sum md5sum.o md5.o $(LIBS) 
     50        $(CC) $(LDFLAGS) -o md5sum md5sum.o md5.o $(LIBS) 
    5151 
    5252# file dependencies 
    5353%.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 $@ 
    5757-include $(SOURCES:.c=.d) 
    5858 
  • trunk/ithildin/source/conf.c

    r576 r578  
    1818static conf_list_t *conf_parse(char *, int, char *); 
    1919static conf_entry_t *merge_into_conf(conf_list_t *, conf_entry_t *, 
    20         conf_list_t *); 
     20        conf_list_t *); 
    2121static char *conf_expand_text(char *); 
    2222 
     
    3232    /* mmap the data in */ 
    3333    if ((stuff = mmap_file(file)) == NULL) 
    34         return NULL; 
     34        return NULL; 
    3535 
    3636    /* weed out comments, and bad strings */ 
    3737    if ((stuff = conf_preparse(file, stuff)) == NULL) 
    38         return NULL; 
     38        return NULL; 
    3939     
    4040    /* now parse */ 
     
    4444 
    4545    if (list == NULL) 
    46         return NULL; 
     46        return NULL; 
    4747 
    4848    /* display_tree(0, list);*/ 
     
    5757    ep1 = LIST_FIRST(list); 
    5858    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; 
    6767    } 
    6868} 
     
    7676#define print_branches(x) for (i = x;i;i--) printf("| "); 
    7777    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        } 
    8686    } 
    8787#undef print_branches 
     
    9797 
    9898    if (maxdepth < 1 || list == NULL) 
    99         return NULL; 
     99        return NULL; 
    100100 
    101101    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        } 
    113113    } 
    114114 
     
    120120 * the list. */ 
    121121conf_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) { 
    123123    conf_entry_t *cep = NULL, *tmpcep; 
    124124 
    125125    if (maxdepth < 1 || list == NULL) 
    126         return NULL; 
     126        return NULL; 
    127127 
    128128    /* with a conf entry, we get the list data too, so we know where 
    129129     * to start from! */ 
    130130    if (last == NULL) 
    131         cep = LIST_FIRST(list); 
     131        cep = LIST_FIRST(list); 
    132132    else 
    133         cep = LIST_NEXT(last, lp); 
     133        cep = LIST_NEXT(last, lp); 
    134134 
    135135    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); 
    149149    } 
    150150    return NULL; 
     
    153153/* this is shorthand to find a list-type conf, it uses conf_find() above. */ 
    154154conf_list_t *conf_find_list(const char *name, conf_list_t *list, 
    155         int maxdepth) { 
     155        int maxdepth) { 
    156156    conf_entry_t *cep; 
    157157    
    158158    if ((cep = conf_find(name, NULL, CONF_TYPE_LIST, list, maxdepth)) != NULL) 
    159         return cep->list; 
     159        return cep->list; 
    160160 
    161161    return NULL; 
     
    167167    
    168168    if ((cep = conf_find(name, NULL, CONF_TYPE_DATA, list, maxdepth)) != NULL) 
    169         return cep->string; 
     169        return cep->string; 
    170170 
    171171    return NULL; 
     
    176176 * possible, it is recommended you use conf_find_next() instead. */ 
    177177conf_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) { 
    179179    conf_entry_t *cep = NULL; 
    180180    conf_list_t *clp = NULL; 
     
    182182 
    183183    if (maxdepth < 1 || list == NULL) 
    184         return NULL; 
     184        return NULL; 
    185185 
    186186    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 */ 
    188188 
    189189    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        } 
    202202    } 
    203203 
     
    205205} 
    206206char *conf_find_entry_next(const char *name, char *last, 
    207         conf_list_t *list, int maxdepth) { 
     207        conf_list_t *list, int maxdepth) { 
    208208    conf_entry_t *cep = NULL; 
    209209    char *s = NULL; 
     
    211211 
    212212    if (maxdepth < 1 || list == NULL) 
    213         return NULL; 
     213        return NULL; 
    214214 
    215215    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 */ 
    217217 
    218218    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        } 
    231231    } 
    232232 
     
    246246 
    247247    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 next 
    260                           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') { 
    267267#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; 
    272272#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                 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++; 
     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++; 
    306306#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                } 
    313313#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                     } else 
    324                         s++; 
    325                 } else 
    326                     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        } 
    329329    } 
    330330 
     
    333333 
    334334    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; 
    339339    } 
    340340     
     
    351351    int startline = 0; 
    352352 
    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    }                                                                        \ 
    362362} while (0) 
    363363 
     
    365365 
    366366    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 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         } 
     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        } 
    410410     
    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         } 
     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        } 
    570570    } 
    571571 
     
    576576 * place entries starting after the 'after' point */ 
    577577static conf_entry_t *merge_into_conf(conf_list_t *big, conf_entry_t *after, 
    578         conf_list_t *little) { 
     578        conf_list_t *little) { 
    579579    conf_entry_t *last = after; 
    580580    conf_entry_t *ep; 
    581581 
    582582    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         else 
    588             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; 
    591591    } 
    592592 
     
    605605     
    606606    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 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++; 
     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++; 
    657657    } 
    658658     
  • trunk/ithildin/source/contrib/fmtcheck.c

    r576 r578  
    3737 
    3838enum __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_UNKNOWN 
     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_UNKNOWN 
    5555}; 
    5656typedef enum __e_fmtcheck_types EFT; 
    5757 
    5858#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) 
    6262 
    6363static EFT 
    6464get_next_format_from_precision(const char **pf) 
    6565{ 
    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*/ 
     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*/ 
    148148} 
    149149 
     
    151151get_next_format_from_width(const char **pf) 
    152152{ 
    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*/ 
    167167} 
    168168 
     
    170170get_next_format(const char **pf, EFT eft) 
    171171{ 
    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*/ 
     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*/ 
    213213} 
    214214 
     
    216216fmtcheck(const char *f1, const char *f2) 
    217217{ 
    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; 
     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; 
    235235} 
    236236/* vi:set ts=8 sts=4 sw=4 tw=76 et: */ 
  • trunk/ithildin/source/contrib/gailib.c

    r576 r578  
    6767 * Error return codes from getaddrinfo() 
    6868 */ 
    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    12 
    81 #define EAI_PROTOCOL    13 
    82 #define EAI_MAX         14 
     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        12 
     81#define EAI_PROTOCOL        13 
     82#define EAI_MAX                14 
    8383 
    8484/* 
    8585 * Flag values for getaddrinfo() 
    8686 */ 
    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 */ 
     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 */ 
    9090/* valid flags for addrinfo */ 
    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 */ 
     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 */ 
    9797/* special recommended flags for getipnodebyname */ 
    98 #define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 
     98#define        AI_DEFAULT        (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 
    9999 
    100100/* 
    101101 * Constants for getnameinfo() 
    102102 */ 
    103 #define NI_MAXHOST      1025 
    104 #define NI_MAXSERV      32 
     103#define        NI_MAXHOST        1025 
     104#define        NI_MAXSERV        32 
    105105 
    106106/* 
    107107 * Flag values for getnameinfo() 
    108108 */ 
    109 #define NI_NOFQDN       0x00000001 
    110 #define NI_NUMERICHOST  0x00000002 
    111 #define NI_NAMEREQD     0x00000004 
    112 #define NI_NUMERICSERV  0x00000008 
    113 #define NI_DGRAM        0x00000010 
     109#define        NI_NOFQDN        0x00000001 
     110#define        NI_NUMERICHOST        0x00000002 
     111#define        NI_NAMEREQD        0x00000004 
     112#define        NI_NUMERICSERV        0x00000008 
     113#define        NI_DGRAM        0x00000010 
    114114 
    115115struct 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 */ 
    124124}; 
    125125 
    126126int getaddrinfo__compat(const char *hostname, const char *servname, 
    127         const struct addrinfo *hints, struct addrinfo **res); 
     127        const struct addrinfo *hints, struct addrinfo **res); 
    128128 
    129129int 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); 
    131131 
    132132const char *gai_strerror__compat(int ecode); 
    133133void freeaddrinfo__compat(struct addrinfo *ai); 
    134134const char *inet_ntop__compat(int af, const void *addr, char *numaddr, 
    135         size_t numaddr_len); 
     135        size_t numaddr_len); 
    136136int inet_pton__compat(int af, const char *hostname, void *pton); 
    137137 
     
    152152#  ifdef INET6 
    153153#   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)) 
    156156#  else 
    157157    /* 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)) 
    159159#  endif 
    160160# endif 
     
    176176 
    177177#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) 
    180180#endif 
    181181 
     
    218218static const char in_addrany[] = { 0, 0, 0, 0 }; 
    219219static const char in6_addrany[] = { 
    220         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
     220        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
    221221}; 
    222222static const char in_loopback[] = { 127, 0, 0, 1 };  
    223223static const char in6_loopback[] = { 
    224         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 
     224        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 
    225225}; 
    226226 
    227227struct sockinet { 
    228         unsigned char   si_len; 
    229         unsigned char   si_family; 
    230         unsigned short  si_port; 
     228        unsigned char        si_len; 
     229        unsigned char        si_family; 
     230        unsigned short        si_port; 
    231231}; 
    232232 
    233233static 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;         
    240240} afdl [] = { 
    241241#ifdef INET6 
    242242#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}, 
    247247#define N_INET  1 
    248248#else 
    249249#define N_INET  0 
    250250#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}, 
    256256}; 
    257257 
    258258#ifdef INET6 
    259 #define PTON_MAX        16 
    260 #else 
    261 #define PTON_MAX        4 
     259#define PTON_MAX        16 
     260#else 
     261#define PTON_MAX        4 
    262262#endif 
    263263 
    264264static int get_name (const char *, struct afd *, 
    265                           struct addrinfo **, char *, struct addrinfo *, 
    266                           int); 
     265                          struct addrinfo **, char *, struct addrinfo *, 
     266                          int); 
    267267static int get_addr (const char *, int, struct addrinfo **, 
    268                         struct addrinfo *, int); 
     268                        struct addrinfo *, int); 
    269269static int str_isnumber (const char *); 
    270          
     270         
    271271static 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        */ 
    287287}; 
    288288 
    289289#define GET_CANONNAME(ai, str) \ 
    290290if (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        }\ 
    297297} 
    298298 
    299299#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);\ 
    315315} 
    316316 
     
    319319const char *gai_strerror__compat(int ecode) 
    320320{ 
    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]; 
    324324} 
    325325 
    326326void freeaddrinfo__compat(struct addrinfo *ai) 
    327327{ 
    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); 
    337337} 
    338338 
    339339static int str_isnumber(const char *p) 
    340340{ 
    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; 
    348348} 
    349349 
    350350int inet_pton__compat(int af, const char *hostname, void *pton) 
    351351{ 
    352         struct in_addr in; 
     352        struct in_addr in; 
    353353 
    354354#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; 
    374374} 
    375375 
    376376int getaddrinfo__compat(const char *hostname, const char *servname, 
    377         const struct addrinfo *hints, struct addrinfo **res) 
     377        const struct addrinfo *hints, struct addrinfo **res) 
    378378{ 
    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: 
    434434#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; 
    440440#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 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; 
     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; 
    530530#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                 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) { 
     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) { 
    612612 good: 
    613                         *res = top; 
    614                         return SUCCESS; 
    615                 } else 
    616                         error = EAI_FAIL; 
    617         } 
     613                        *res = top; 
     614                        return SUCCESS; 
     615                } else 
     616                        error = EAI_FAIL; 
     617        } 
    618618 free: 
    619         if (top) 
    620                 freeaddrinfo(top); 
     619        if (top) 
     620                freeaddrinfo(top); 
    621621 bad: 
    622         *res = NULL; 
    623         return error; 
     622        *res = NULL; 
     623        return error; 
    624624} 
    625625 
    626626static 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) 
    628628{ 
    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; 
     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; 
    654654 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); 
    660660#endif 
    661661 /* bad: */ 
    662         *res = NULL; 
    663         return error; 
     662        *res = NULL; 
     663        return error; 
    664664} 
    665665 
    666666static int get_addr(const char *hostname, int af, struct addrinfo **res, 
    667         struct addrinfo *pai, int port0) 
     667        struct addrinfo *pai, int port0) 
    668668{ 
    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; 
     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; 
    717717#endif 
    718718#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                         } 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; 
     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; 
    747747 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); 
    753753#endif 
    754754 bad: 
    755         *res = NULL; 
    756         return error; 
     755        *res = NULL; 
     756        return error; 
    757757} 
    758758 
     
    767767 */ 
    768768 
    769 #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 
     769#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 
    776776 
    777777const char *inet_ntop__compat(int af, const void *addr, char *numaddr, 
    778         size_t numaddr_len) 
     778        size_t numaddr_len) 
    779779{ 
    780780#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; 
    791791} 
    792792 
    793793int 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) 
    795795{ 
    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         
    824824 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 { 
    838838#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                 } 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; 
     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; 
    912912} 
    913913/* vi:set ts=8 sts=4 sw=4 tw=76 et: */ 
  • trunk/ithildin/source/contrib/strlcat.c

    r490 r578  
    4343    /* Find the end of dst and adjust bytes left but don't go past end */ 
    4444    while (n-- != 0 && *d != '\0') 
    45         d++; 
     45        d++; 
    4646    dlen = d - dst; 
    4747    n = siz - dlen; 
    4848 
    4949    if (n == 0) 
    50         return(dlen + strlen(s)); 
     50        return(dlen + strlen(s)); 
    5151    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++; 
    5757    } 
    5858    *d = '\0'; 
    5959 
    60     return(dlen + (s - src));   /* count does not include NUL */ 
     60    return(dlen + (s - src));        /* count does not include NUL */ 
    6161} 
  • 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 $        */ 
    22 
    33/* 
     
    4242    /* Copy as many bytes as will fit */ 
    4343    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); 
    4848    } 
    4949 
    5050    /* Not enough room in dst, add NUL and traverse rest of src */ 
    5151    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++); 
    5555    } 
    5656 
    57     return(s - src - 1);        /* count does not include NUL */ 
     57    return(s - src - 1);        /* count does not include NUL */ 
    5858} 
  • trunk/ithildin/source/event.c

    r576 r578  
    3232event_t *create_event(int flags) { 
    3333    event_t *ep = NULL; 
    34          
     34         
    3535    ep = malloc(sizeof(event_t)); 
    3636    ep->numhooks = 0; 
     
    5959 
    6060    if (ep->flags & EVENT_FL_NORETURN) 
    61         returned = NULL; 
     61        returned = NULL; 
    6262    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 */ 
    6464    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; 
    9191    } 
    9292 
    9393    if (ep->flags & EVENT_FL_CONDITIONAL) { 
    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; 
     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; 
    9898    } else 
    99         hook_num_returns = i; 
     99        hook_num_returns = i; 
    100100 
    101101    /* trash the hooks which are deferred (will be all of them if this is a 
    102102     * 'hookonce' event. */ 
    103103    ep->flags &= ~EVENT_FL_CALLING; 
    104             hp = SLIST_FIRST(&ep->hooks); 
     104            hp = SLIST_FIRST(&ep->hooks); 
    105105    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; 
    114114    } 
    115115 
    116116    return returned; 
    117117} 
    118                  
     118                 
    119119void destroy_event(event_t *ep) { 
    120120    struct hook *hp; 
    121121 
    122122    if (ep == NULL) 
    123         return; 
     123        return; 
    124124 
    125125    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); 
    129129    } 
    130130    free(ep); 
     
    135135 * last hook on the event. */ 
    136136int add_hook_after(event_t *ep, hook_function_t func, 
    137         hook_function_t after) { 
     137        hook_function_t after) { 
    138138    struct hook *hp = NULL; 
    139139 
    140140    if (ep == NULL || func == NULL) 
    141         return 0; 
     141        return 0; 
    142142 
    143143    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; 
    146146    } 
    147147 
     
    150150     * add it on to the end. */ 
    151151    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        } 
    156156    } 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        } 
    163163    } 
    164164 
     
    168168 
    169169int add_hook_before(event_t *ep, hook_function_t func, 
    170         hook_function_t before) { 
     170        hook_function_t before) { 
    171171    struct hook *hp = NULL; 
    172172    struct hook *hp2 = NULL; 
    173173 
    174174    if (ep == NULL || func == NULL) 
    175         return 0; 
     175        return 0; 
    176176 
    177177    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; 
    180180    } 
    181181 
     
    185185     * the head of the list. */ 
    186186    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; 
    189189    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        } 
    197197    } 
    198198 
     
    207207    hp->function = func; 
    208208    if (ep->flags & EVENT_FL_CALLING) 
    209         hp->flags = HOOK_FL_NEW; 
     209        hp->flags = HOOK_FL_NEW; 
    210210    else 
    211         hp->flags = 0; 
     211        hp->flags = 0; 
    212212    if (at == NULL) 
    213         SLIST_INSERT_HEAD(&ep->hooks, hp, lp); 
     213        SLIST_INSERT_HEAD(&ep->hooks, hp, lp); 
    214214    else 
    215         SLIST_INSERT_AFTER(at, hp, lp); 
     215        SLIST_INSERT_AFTER(at, hp, lp); 
    216216    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); 
    219219    } 
    220220} 
     
    224224 
    225225    SLIST_FOREACH(hp, &ep->hooks, lp) { 
    226         if (hp->function == func) 
    227             return hp; 
     226        if (hp->function == func) 
     227            return hp; 
    228228    } 
    229229 
     
    235235 
    236236    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; 
    246246    } 
    247247 
  • trunk/ithildin/source/hash.c

    r576 r578  
    2121 * comparison when calling 'hash_find' */ 
    2222hashtable_t *create_hash_table(int elems, size_t offset, size_t len, 
    23         int flags, char *cmpname) { 
     23        int flags, char *cmpname) { 
    2424    hashtable_t *htp = malloc(sizeof(hashtable_t)); 
    2525 
     
    3434    htp->flags = flags; 
    3535    if (cmpname != NULL) 
    36         htp->cmpsym = import_symbol(cmpname); 
     36        htp->cmpsym = import_symbol(cmpname); 
    3737    else 
    38         htp->cmpsym = import_symbol("memcmp"); 
     38        htp->cmpsym = import_symbol("memcmp"); 
    3939 
    4040    htp->table = malloc(sizeof(struct hashbucket) * htp->size); 
     
    5151 
    5252    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        } 
    5858    } 
    5959    free(table->table); 
     
    8585     * and re-adding them to the table as we go */ 
    8686    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        } 
    9393    } 
    9494    free(oldtable); 
     
    100100 * you adequately. */ 
    101101unsigned int hash_get_key_hash(hashtable_t *table, void *key, 
    102         size_t offset) { 
     102        size_t offset) { 
    103103    char *rkey = (char *)key + offset; 
    104104    int len = table->keylen; 
     
    106106 
    107107    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; 
    111111    } 
    112112    /* I borrowed this algorithm from perl5.  Kudos to Larry Wall & co. */ 
    113113    if (table->flags & HASH_FL_NOCASE) 
    114         while (len--) 
    115             hash = hash * 33 + tolower(*rkey++); 
     114        while (len--) 
     115            hash = hash * 33 + tolower(*rkey++); 
    116116    else 
    117         while (len--) 
    118             hash = hash * 33 + *rkey++; 
     117        while (len--) 
     118            hash = hash * 33 + *rkey++; 
    119119 
    120120    return hash + (hash >> 5); 
     
    130130#ifdef DEBUG_CODE 
    131131    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 */ 
    133133    else { 
    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; 
     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; 
    143143    } 
    144144#endif 
     
    147147    hep->ent = ent; 
    148148    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 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); 
     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); 
    165165    } else 
    166         SLIST_INSERT_HEAD(&table->table[hash], hep, lp); 
     166        SLIST_INSERT_HEAD(&table->table[hash], hep, lp); 
    167167 
    168168    /* if the table has 1.2x as many entries as there are buckets, resize it so 
    169169     * that there ar twice as many buckets. :) */ 
    170170    if (((table->size * 6) / 5)  <= table->entries) 
    171         resize_hash_table(table, table->size * 2); 
     171        resize_hash_table(table, table->size * 2); 
    172172 
    173173    return 1; 
     
    177177int hash_delete(hashtable_t *table, void *ent) { 
    178178    unsigned int hash = hash_get_key_hash(table, ent, table->keyoffset) % 
    179         table->size; 
     179        table->size; 
    180180    struct hashent *hep; 
    181181 
    182182    SLIST_FOREACH(hep, &table->table[hash], lp) { 
    183         if (hep->ent == ent) 
    184             break; 
     183        if (hep->ent == ent) 
     184            break; 
    185185    } 
    186186    if (hep == NULL) 
    187         return 0; 
     187        return 0; 
    188188 
    189189    table->entries--; 
     
    193193#ifdef DEBUG_CODE 
    194194    if (SLIST_EMPTY(&table->table[hash])) 
    195         table->empty_buckets++; /* this bucket is empty again. */ 
     195        table->empty_buckets++; /* this bucket is empty again. */ 
    196196#endif 
    197197