summaryrefslogtreecommitdiffstats
ModeNameSize
-rw-r--r--.cvsignore80logstatsplain
-rw-r--r--Makefile5454logstatsplain
d---------docs791logstatsplain
-rw-r--r--live_update2414logstatsplain
-rwxr-xr-xmake_boot_img15504logstatsplain
-rwxr-xr-xmake_ks_from_floppy306logstatsplain
d---------mdk-stage12469logstatsplain
d---------perl-install3560logstatsplain
d---------rescue710logstatsplain
d---------tools1163logstatsplain
-rwxr-xr-xupdate_kernel4613logstatsplain
mode'>-rw-r--r--docs/BUGS10
-rw-r--r--docs/COPYING340
-rw-r--r--docs/HACKING137
-rw-r--r--docs/Partition-ends-after-end-of-disk.txt66
-rw-r--r--docs/README300
-rw-r--r--docs/README.devel252
-rw-r--r--docs/README.pxe133
-rw-r--r--docs/SHORTCUTS51
-rw-r--r--docs/TODO515
-rw-r--r--docs/advocacy87
-rw-r--r--docs/advocacy-interactive60
-rw-r--r--docs/comparisons288
-rw-r--r--docs/diskdrake.TODO23
-rw-r--r--docs/drakfont/Makefile57
-rw-r--r--docs/drakfont/dia_srcs/drakfont.diabin4599 -> 0 bytes-rw-r--r--docs/drakfont/dia_srcs/drakfont_install.diabin3662 -> 0 bytes-rw-r--r--docs/drakfont/dia_srcs/drakfont_uninstall.diabin1908 -> 0 bytes-rw-r--r--docs/drakfont/drakfont.jpgbin134044 -> 0 bytes-rw-r--r--docs/drakfont/drakfont.tex152
-rw-r--r--docs/drakfont/drakfont_install.jpgbin86455 -> 0 bytes-rw-r--r--docs/drakfont/drakfont_uninstall.jpgbin42291 -> 0 bytes-rw-r--r--docs/drakfont/mandrake.ps534
-rw-r--r--docs/draknet_advanced_doc.txt165
-rwxr-xr-xdocs/interactive/ask_from29
-rwxr-xr-xdocs/interactive/ask_from_list27
-rwxr-xr-xdocs/interactive/ask_from_listf27
-rwxr-xr-xdocs/interactive/ask_from_treelist27
-rwxr-xr-xdocs/interactive/wait_message13
-rw-r--r--docs/mdk-9.2129
-rw-r--r--docs/mdk-vs-redhat43
-rw-r--r--docs/net_object_class.fig73
-rw-r--r--docs/object_class.fig32
-rwxr-xr-xdocs/porting-ugtk48
-rw-r--r--docs/spec-DrakX-8.0.html405
-rw-r--r--docs/wizard.doc31
-rw-r--r--globetrotter/.perl_checker8
-rw-r--r--globetrotter/ChangeLog276
-rw-r--r--globetrotter/Makefile97
-rw-r--r--globetrotter/README64
-rw-r--r--globetrotter/doc/BUGS6
-rw-r--r--globetrotter/doc/BUILD28
-rw-r--r--globetrotter/doc/NOTES17
-rw-r--r--globetrotter/fix-broken-hd.diff127
-rw-r--r--globetrotter/hwprofile44
-rwxr-xr-xglobetrotter/make_live538
-rw-r--r--globetrotter/mandrake-globetrotter.spec45
-rw-r--r--globetrotter/move.pm177
-rwxr-xr-xglobetrotter/runstage230
-rw-r--r--help.msg.xml21
-rw-r--r--isolinux-graphic-simple.bmpbin480566 -> 0 bytes-rw-r--r--isolinux-graphic-simple.bmp.parameters10
-rw-r--r--isolinux-graphic.bmpbin480566 -> 0 bytes-rw-r--r--isolinux-graphic.bmp.parameters10
-rw-r--r--kernel/.cvsignore3
-rw-r--r--kernel/Makefile16
-rw-r--r--kernel/list_modules.pm316
-rw-r--r--kernel/modules.pl280
-rwxr-xr-xkernel/strip_modules129
-rwxr-xr-xkernel/update_kernel118
-rwxr-xr-xmake_boot_img843
-rw-r--r--mdk-stage1/.cvsignore15
-rw-r--r--mdk-stage1/Makefile263
-rw-r--r--mdk-stage1/Makefile.common54
-rw-r--r--mdk-stage1/Makefile.mkinitrd_helper30
-rw-r--r--mdk-stage1/adsl.c183
-rw-r--r--mdk-stage1/adsl.h34
-rw-r--r--mdk-stage1/automatic.c165
-rw-r--r--mdk-stage1/automatic.h33
-rw-r--r--mdk-stage1/bootsplash.c70
-rw-r--r--mdk-stage1/bootsplash.h25
-rw-r--r--mdk-stage1/bzlib/Makefile42
-rw-r--r--mdk-stage1/bzlib/blocksort.c1138
-rw-r--r--mdk-stage1/bzlib/bzlib.c1567
-rw-r--r--mdk-stage1/bzlib/bzlib.h319
-rw-r--r--mdk-stage1/bzlib/bzlib_private.h530
-rw-r--r--mdk-stage1/bzlib/compress.c720
-rw-r--r--mdk-stage1/bzlib/crctable.c148
-rw-r--r--mdk-stage1/bzlib/decompress.c664
-rw-r--r--mdk-stage1/bzlib/huffman.c232
-rw-r--r--mdk-stage1/bzlib/randtable.c128
-rw-r--r--mdk-stage1/cdrom.c215
-rw-r--r--mdk-stage1/cdrom.h29
-rw-r--r--mdk-stage1/config-stage1.h105
-rw-r--r--mdk-stage1/dhcp.c676
-rw-r--r--mdk-stage1/dhcp.h37
-rw-r--r--mdk-stage1/directory.c180
-rw-r--r--mdk-stage1/directory.h29
-rw-r--r--mdk-stage1/disk.c163
-rw-r--r--mdk-stage1/disk.h27
-rw-r--r--mdk-stage1/dns.c224
-rw-r--r--mdk-stage1/dns.h30
-rw-r--r--mdk-stage1/doc/HACKING31
-rw-r--r--mdk-stage1/doc/README185
-rw-r--r--mdk-stage1/doc/TECH-INFOS101
-rw-r--r--mdk-stage1/doc/UPDATEMODULES95
-rw-r--r--mdk-stage1/doc/WHY-DIETLIBC50
-rw-r--r--mdk-stage1/doc/documented..frontend.h69
-rw-r--r--mdk-stage1/frontend-common.c45
-rw-r--r--mdk-stage1/frontend.h67
-rw-r--r--mdk-stage1/init-libc-headers.h45
-rw-r--r--mdk-stage1/init.c584
-rw-r--r--mdk-stage1/insmod-busybox/.cvsignore2
-rw-r--r--mdk-stage1/insmod-busybox/Config.h133
-rw-r--r--mdk-stage1/insmod-busybox/Makefile43
-rw-r--r--mdk-stage1/insmod-busybox/README8
-rw-r--r--mdk-stage1/insmod-busybox/busybox.h477
-rw-r--r--mdk-stage1/insmod-busybox/insmod-frontend.c24
-rw-r--r--mdk-stage1/insmod-busybox/insmod.c3758
-rw-r--r--mdk-stage1/insmod-busybox/loop.h5
-rw-r--r--mdk-stage1/insmod-busybox/messages.c90
-rw-r--r--mdk-stage1/insmod-busybox/utility.c1759
-rw-r--r--mdk-stage1/insmod-modutils/Makefile59
-rw-r--r--mdk-stage1/insmod-modutils/include/config.h108
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_alpha.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_arm.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_hppa.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_hppa64.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_i386.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_ia64.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_m68k.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_mips.h23
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_ppc.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_s390.h11
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_sparc.h9
-rw-r--r--mdk-stage1/insmod-modutils/include/elf_sparc64.h26
-rw-r--r--mdk-stage1/insmod-modutils/include/kallsyms.h129
-rw-r--r--mdk-stage1/insmod-modutils/include/kerneld.h44
-rw-r--r--mdk-stage1/insmod-modutils/include/modstat.h55
-rw-r--r--mdk-stage1/insmod-modutils/include/module.h217
-rw-r--r--mdk-stage1/insmod-modutils/include/obj.h298
-rw-r--r--mdk-stage1/insmod-modutils/include/util.h99
-rw-r--r--mdk-stage1/insmod-modutils/include/version.h1
-rw-r--r--mdk-stage1/insmod-modutils/insmod-frontend.c24
-rw-r--r--mdk-stage1/insmod-modutils/insmod.c2141
-rw-r--r--mdk-stage1/insmod-modutils/obj/Makefile38
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_alpha.c328
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_arm.c310
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_common.c416
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_hppa.c638
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_hppa64.c682
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_i386.c237
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_ia64.c1022
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_kallsyms.c290
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_load.c343
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_m68k.c145
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_mips.c254
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_ppc.c266
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_reloc.c413
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_s390.c332
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_sparc.c224
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_sparc64.c350
-rw-r--r--mdk-stage1/insmod-modutils/util/Makefile42
-rw-r--r--mdk-stage1/insmod-modutils/util/alias.h310
-rw-r--r--mdk-stage1/insmod-modutils/util/arch64.c43
-rw-r--r--mdk-stage1/insmod-modutils/util/config.c1614
-rw-r--r--mdk-stage1/insmod-modutils/util/gzfiles.c74
-rw-r--r--mdk-stage1/insmod-modutils/util/logger.c160
-rw-r--r--mdk-stage1/insmod-modutils/util/meta_expand.c339
-rw-r--r--mdk-stage1/insmod-modutils/util/modstat.c419
-rw-r--r--mdk-stage1/insmod-modutils/util/snap_shot.c154
-rw-r--r--mdk-stage1/insmod-modutils/util/sys_cm.c86
-rw-r--r--mdk-stage1/insmod-modutils/util/sys_dm.c35
-rw-r--r--mdk-stage1/insmod-modutils/util/sys_gks.c35
-rw-r--r--mdk-stage1/insmod-modutils/util/sys_nim.c51
-rw-r--r--mdk-stage1/insmod-modutils/util/sys_oim.c38
-rw-r--r--mdk-stage1/insmod-modutils/util/sys_qm.c54
-rw-r--r--mdk-stage1/insmod-modutils/util/xftw.c422
-rw-r--r--mdk-stage1/insmod-modutils/util/xmalloc.c37
-rw-r--r--mdk-stage1/insmod-modutils/util/xrealloc.c37
-rw-r--r--mdk-stage1/insmod-modutils/util/xstrcat.c38
-rw-r--r--mdk-stage1/insmod-modutils/util/xstrdup.c39
-rw-r--r--mdk-stage1/insmod-modutils/util/xsystem.c49
-rw-r--r--mdk-stage1/insmod.h20
-rw-r--r--mdk-stage1/linux-2.2/nfs.h226
-rw-r--r--mdk-stage1/linux-2.2/nfs_mount.h53
-rw-r--r--mdk-stage1/log.c94
-rw-r--r--mdk-stage1/log.h34
-rw-r--r--mdk-stage1/lomount.c197
-rw-r--r--mdk-stage1/lomount.h21
-rw-r--r--mdk-stage1/mar/.cvsignore1
-rw-r--r--mdk-stage1/mar/Makefile49
-rw-r--r--mdk-stage1/mar/mar-extract-only.c214
-rw-r--r--mdk-stage1/mar/mar-extract-only.h32
-rw-r--r--mdk-stage1/mar/mar-frontend.c199
-rw-r--r--mdk-stage1/mar/mar.h70
-rw-r--r--mdk-stage1/minilibc.c317
-rw-r--r--mdk-stage1/minilibc.h159
-rw-r--r--mdk-stage1/mkinitrd_helper/Makefile46
-rw-r--r--mdk-stage1/mkinitrd_helper/mkinitrd_helper.c308
-rw-r--r--mdk-stage1/modules.c558
-rw-r--r--mdk-stage1/modules.h37
-rw-r--r--mdk-stage1/modules_descr.h66
-rw-r--r--mdk-stage1/mount.c227
-rw-r--r--mdk-stage1/mount.h32
-rw-r--r--mdk-stage1/mount_rpcgen.h208
-rw-r--r--mdk-stage1/network.c1161
-rw-r--r--mdk-stage1/network.h64
-rw-r--r--mdk-stage1/newt-frontend.c400
-rw-r--r--mdk-stage1/newt/Makefile42
-rw-r--r--mdk-stage1/newt/button.c192
-rw-r--r--mdk-stage1/newt/buttonbar.c46
-rw-r--r--mdk-stage1/newt/checkbox.c292
-rw-r--r--mdk-stage1/newt/checkboxtree.c714
-rw-r--r--mdk-stage1/newt/entry.c378
-rw-r--r--mdk-stage1/newt/form.c713
-rw-r--r--mdk-stage1/newt/grid.c389
-rw-r--r--mdk-stage1/newt/label.c81
-rw-r--r--mdk-stage1/newt/listbox.c752
-rw-r--r--mdk-stage1/newt/newt.c672
-rw-r--r--mdk-stage1/newt/newt.h362
-rw-r--r--mdk-stage1/newt/newt_pr.h82
-rw-r--r--mdk-stage1/newt/scale.c72
-rw-r--r--mdk-stage1/newt/scrollbar.c124
-rw-r--r--mdk-stage1/newt/textbox.c409
-rw-r--r--mdk-stage1/newt/windows.c275
-rw-r--r--mdk-stage1/nfs_mount4.h54
-rw-r--r--mdk-stage1/nfsmount.c740
-rw-r--r--mdk-stage1/nfsmount.h331
-rw-r--r--mdk-stage1/partition.c171
-rw-r--r--mdk-stage1/partition.h28
-rw-r--r--mdk-stage1/pci-resource/.cvsignore1
-rw-r--r--mdk-stage1/pci-resource/Makefile25
-rwxr-xr-xmdk-stage1/pci-resource/update-pci-ids.pl72
-rw-r--r--mdk-stage1/pcmcia_/Makefile37
-rw-r--r--mdk-stage1/pcmcia_/bulkmem.h195
-rw-r--r--mdk-stage1/pcmcia_/cardmgr.c1652
-rw-r--r--mdk-stage1/pcmcia_/cardmgr.h112
-rw-r--r--mdk-stage1/pcmcia_/cirrus.h157
-rw-r--r--mdk-stage1/pcmcia_/cistpl.h604
-rw-r--r--mdk-stage1/pcmcia_/cs.h433
-rw-r--r--mdk-stage1/pcmcia_/cs_types.h70
-rw-r--r--mdk-stage1/pcmcia_/driver_ops.h73
-rw-r--r--mdk-stage1/pcmcia_/ds.h148
-rw-r--r--mdk-stage1/pcmcia_/i82365.h135
-rw-r--r--mdk-stage1/pcmcia_/lex_config.c2053
-rwxr-xr-xmdk-stage1/pcmcia_/merge_from_pcitable47
-rw-r--r--mdk-stage1/pcmcia_/pcmcia.h21
-rw-r--r--mdk-stage1/pcmcia_/probe.c524
-rw-r--r--mdk-stage1/pcmcia_/tcic.h266
-rw-r--r--mdk-stage1/pcmcia_/version.h4
-rw-r--r--mdk-stage1/pcmcia_/vg468.h106
-rw-r--r--mdk-stage1/pcmcia_/yacc_config.c1015
-rw-r--r--mdk-stage1/pcmcia_/yacc_config.h37
-rw-r--r--mdk-stage1/ppp/.cvsignore1
-rw-r--r--mdk-stage1/ppp/Changes-2.3441
-rw-r--r--mdk-stage1/ppp/FAQ634
-rw-r--r--mdk-stage1/ppp/PLUGINS131
-rw-r--r--mdk-stage1/ppp/README168
-rw-r--r--mdk-stage1/ppp/README.MSCHAP80284
-rw-r--r--mdk-stage1/ppp/README.cbcp97
-rw-r--r--mdk-stage1/ppp/README.linux297
-rw-r--r--mdk-stage1/ppp/README.sol2220
-rw-r--r--mdk-stage1/ppp/README.sunos462
-rw-r--r--mdk-stage1/ppp/SETUP111
-rw-r--r--mdk-stage1/ppp/chat/Makefile.linux27
-rw-r--r--mdk-stage1/ppp/chat/Makefile.linux.makeopt27
-rw-r--r--mdk-stage1/ppp/chat/Makefile.sol219
-rw-r--r--mdk-stage1/ppp/chat/Makefile.sunos419
-rw-r--r--mdk-stage1/ppp/chat/chat.8515
-rw-r--r--mdk-stage1/ppp/chat/chat.c1756
-rw-r--r--mdk-stage1/ppp/common/zlib.c5376
-rw-r--r--mdk-stage1/ppp/common/zlib.h1010
-rwxr-xr-xmdk-stage1/ppp/configure141
-rw-r--r--mdk-stage1/ppp/contrib/pppgetpass/Makefile.linux16
-rw-r--r--mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.818
-rw-r--r--mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.gtk.c92
-rw-r--r--mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.sh7
-rw-r--r--mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.vt.c218
-rw-r--r--mdk-stage1/ppp/etc.ppp/chap-secrets2
-rw-r--r--mdk-stage1/ppp/etc.ppp/options5
-rw-r--r--mdk-stage1/ppp/etc.ppp/options.options1
-rw-r--r--mdk-stage1/ppp/etc.ppp/pap-secrets2
-rw-r--r--mdk-stage1/ppp/include/linux/if_ppp.h155
-rw-r--r--mdk-stage1/ppp/include/linux/if_pppvar.h138
-rw-r--r--mdk-stage1/ppp/include/linux/ppp-comp.h203
-rw-r--r--mdk-stage1/ppp/include/linux/ppp_defs.h185
-rw-r--r--mdk-stage1/ppp/include/net/if_ppp.h133
-rw-r--r--mdk-stage1/ppp/include/net/ppp-comp.h165
-rw-r--r--mdk-stage1/ppp/include/net/ppp_defs.h184
-rw-r--r--mdk-stage1/ppp/include/net/pppio.h99
-rw-r--r--mdk-stage1/ppp/include/net/slcompress.h148
-rw-r--r--mdk-stage1/ppp/include/net/vjcompress.h144
-rw-r--r--mdk-stage1/ppp/include/pcap-int.h117
-rw-r--r--mdk-stage1/ppp/linux/Makefile.top55
-rw-r--r--mdk-stage1/ppp/modules/bsd-comp.c1116
-rw-r--r--mdk-stage1/ppp/modules/deflate.c760
-rw-r--r--mdk-stage1/ppp/modules/if_ppp.c865
-rw-r--r--mdk-stage1/ppp/modules/ppp.c2486
-rw-r--r--mdk-stage1/ppp/modules/ppp_ahdlc.c878
-rw-r--r--mdk-stage1/ppp/modules/ppp_comp.c1126
-rw-r--r--mdk-stage1/ppp/modules/ppp_mod.h190
-rw-r--r--mdk-stage1/ppp/modules/vjcompress.c587
-rw-r--r--mdk-stage1/ppp/pppd/.cvsignore2
-rw-r--r--mdk-stage1/ppp/pppd/Makefile49
-rw-r--r--mdk-stage1/ppp/pppd/Makefile.linux129
-rw-r--r--mdk-stage1/ppp/pppd/Makefile.linux.make131
-rw-r--r--mdk-stage1/ppp/pppd/Makefile.linux.makeopt129
-rw-r--r--mdk-stage1/ppp/pppd/Makefile.sol248
-rw-r--r--mdk-stage1/ppp/pppd/Makefile.sunos426
-rw-r--r--mdk-stage1/ppp/pppd/auth.c1939
-rw-r--r--mdk-stage1/ppp/pppd/cbcp.c456
-rw-r--r--mdk-stage1/ppp/pppd/cbcp.h26
-rw-r--r--mdk-stage1/ppp/pppd/ccp.c1257
-rw-r--r--mdk-stage1/ppp/pppd/ccp.h48
-rw-r--r--mdk-stage1/ppp/pppd/chap.c860
-rw-r--r--mdk-stage1/ppp/pppd/chap.h124
-rw-r--r--mdk-stage1/ppp/pppd/chap_ms.c338
-rw-r--r--mdk-stage1/ppp/pppd/chap_ms.h33
-rw-r--r--mdk-stage1/ppp/pppd/demand.c351
-rw-r--r--mdk-stage1/ppp/pppd/eui64.c40
-rw-r--r--mdk-stage1/ppp/pppd/eui64.h97
-rw-r--r--mdk-stage1/ppp/pppd/fsm.c762
-rw-r--r--mdk-stage1/ppp/pppd/fsm.h144
-rw-r--r--mdk-stage1/ppp/pppd/ipcp.c2054
-rw-r--r--mdk-stage1/ppp/pppd/ipcp.h73
-rw-r--r--mdk-stage1/ppp/pppd/ipv6cp.c1512
-rw-r--r--mdk-stage1/ppp/pppd/ipv6cp.h126
-rw-r--r--mdk-stage1/ppp/pppd/ipxcp.c1570
-rw-r--r--mdk-stage1/ppp/pppd/ipxcp.h71
-rw-r--r--mdk-stage1/ppp/pppd/lcp.c2224
-rw-r--r--mdk-stage1/ppp/pppd/lcp.h95
-rw-r--r--mdk-stage1/ppp/pppd/magic.c88
-rw-r--r--mdk-stage1/ppp/pppd/magic.h23
-rw-r--r--mdk-stage1/ppp/pppd/main.c1846
-rw-r--r--mdk-stage1/ppp/pppd/md4.c298
-rw-r--r--mdk-stage1/ppp/pppd/md4.h64
-rw-r--r--mdk-stage1/ppp/pppd/md5.c309
-rw-r--r--mdk-stage1/ppp/pppd/md5.h58
-rw-r--r--mdk-stage1/ppp/pppd/multilink.c397
-rw-r--r--mdk-stage1/ppp/pppd/options.c1513
-rw-r--r--mdk-stage1/ppp/pppd/patchlevel.h4
-rw-r--r--mdk-stage1/ppp/pppd/pathnames.h25
-rw-r--r--mdk-stage1/ppp/pppd/plugins/Makefile.linux19
-rw-r--r--mdk-stage1/ppp/pppd/plugins/Makefile.sol227
-rw-r--r--mdk-stage1/ppp/pppd/plugins/minconn.c46
-rw-r--r--mdk-stage1/ppp/pppd/plugins/passprompt.c108
-rw-r--r--mdk-stage1/ppp/pppd/ppp.pam6
-rw-r--r--mdk-stage1/ppp/pppd/pppd.81591
-rw-r--r--mdk-stage1/ppp/pppd/pppd.h787
-rw-r--r--mdk-stage1/ppp/pppd/pppd.h.wtmp789
-rw-r--r--mdk-stage1/ppp/pppd/sys-linux.c2672
-rw-r--r--mdk-stage1/ppp/pppd/sys-linux.c.wtmp2750
-rw-r--r--mdk-stage1/ppp/pppd/sys-solaris.c2737
-rw-r--r--mdk-stage1/ppp/pppd/sys-sunos4.c1559
-rw-r--r--mdk-stage1/ppp/pppd/tdb.c1282
-rw-r--r--mdk-stage1/ppp/pppd/tdb.h77
-rw-r--r--mdk-stage1/ppp/pppd/tty.c1164
-rw-r--r--mdk-stage1/ppp/pppd/upap.c640
-rw-r--r--mdk-stage1/ppp/pppd/upap.h87
-rw-r--r--mdk-stage1/ppp/pppd/utils.c949
-rw-r--r--mdk-stage1/ppp/pppdump/Makefile.linux17
-rw-r--r--mdk-stage1/ppp/pppdump/Makefile.linux.makeopt17
-rw-r--r--mdk-stage1/ppp/pppdump/Makefile.linux.pppdump-Makefile17
-rw-r--r--mdk-stage1/ppp/pppdump/Makefile.sol221
-rw-r--r--mdk-stage1/ppp/pppdump/Makefile.sunos421
-rw-r--r--mdk-stage1/ppp/pppdump/bsd-comp.c750
-rw-r--r--mdk-stage1/ppp/pppdump/deflate.c344
-rw-r--r--mdk-stage1/ppp/pppdump/ppp-comp.h150
-rw-r--r--mdk-stage1/ppp/pppdump/pppdump.862
-rw-r--r--mdk-stage1/ppp/pppdump/pppdump.c502
-rw-r--r--mdk-stage1/ppp/pppdump/zlib.c4614
-rw-r--r--mdk-stage1/ppp/pppdump/zlib.h631
-rw-r--r--mdk-stage1/ppp/pppstats/Makefile.linux32
-rw-r--r--mdk-stage1/ppp/pppstats/Makefile.sol220
-rw-r--r--mdk-stage1/ppp/pppstats/Makefile.sunos430
-rw-r--r--mdk-stage1/ppp/pppstats/pppstats.8217
-rw-r--r--mdk-stage1/ppp/pppstats/pppstats.c557
-rw-r--r--mdk-stage1/ppp/sample/auth-down17
-rw-r--r--mdk-stage1/ppp/sample/auth-up17
-rw-r--r--mdk-stage1/ppp/sample/ip-down22
-rw-r--r--mdk-stage1/ppp/sample/ip-up23
-rw-r--r--mdk-stage1/ppp/sample/options153
-rw-r--r--mdk-stage1/ppp/sample/options.ttyXX14
-rw-r--r--mdk-stage1/ppp/sample/pap-secrets28
-rw-r--r--mdk-stage1/ppp/scripts/README143
-rwxr-xr-xmdk-stage1/ppp/scripts/callback77
-rw-r--r--mdk-stage1/ppp/scripts/chat-callback98
-rw-r--r--mdk-stage1/ppp/scripts/chatchat/README134
-rw-r--r--mdk-stage1/ppp/scripts/chatchat/chatchat.c409
-rw-r--r--mdk-stage1/ppp/scripts/ip-down.local.add20
-rw-r--r--mdk-stage1/ppp/scripts/ip-up.local.add24
-rw-r--r--mdk-stage1/ppp/scripts/options-rsh-loc1
-rw-r--r--mdk-stage1/ppp/scripts/options-rsh-rem1
-rw-r--r--mdk-stage1/ppp/scripts/options-ssh-loc1
-rw-r--r--mdk-stage1/ppp/scripts/options-ssh-rem1
-rwxr-xr-xmdk-stage1/ppp/scripts/ppp-off34
-rwxr-xr-xmdk-stage1/ppp/scripts/ppp-on36
-rwxr-xr-xmdk-stage1/ppp/scripts/ppp-on-dialer17
-rwxr-xr-xmdk-stage1/ppp/scripts/ppp-on-rsh72
-rwxr-xr-xmdk-stage1/ppp/scripts/ppp-on-ssh76
-rwxr-xr-xmdk-stage1/ppp/scripts/redialer96
-rw-r--r--mdk-stage1/ppp/scripts/secure-card111
-rw-r--r--mdk-stage1/ppp/solaris/Makedefs16
-rw-r--r--mdk-stage1/ppp/solaris/Makedefs.sol259
-rw-r--r--mdk-stage1/ppp/solaris/Makefile.sol266
-rw-r--r--mdk-stage1/ppp/solaris/Makefile.sol2-6485
-rw-r--r--mdk-stage1/ppp/solaris/Makefile.top50
-rw-r--r--mdk-stage1/ppp/solaris/ppp.c2486
-rw-r--r--mdk-stage1/ppp/solaris/ppp.conf1
-rw-r--r--mdk-stage1/ppp/solaris/ppp_ahdlc.c878
-rw-r--r--mdk-stage1/ppp/solaris/ppp_ahdlc_mod.c49
-rw-r--r--mdk-stage1/ppp/solaris/ppp_comp.c1126
-rw-r--r--mdk-stage1/ppp/solaris/ppp_comp_mod.c81
-rw-r--r--mdk-stage1/ppp/solaris/ppp_mod.c174
-rw-r--r--mdk-stage1/ppp/solaris/ppp_mod.h190
-rw-r--r--mdk-stage1/ppp/sunos4/Makedefs13
-rw-r--r--mdk-stage1/ppp/sunos4/Makefile57
-rw-r--r--mdk-stage1/ppp/sunos4/Makefile.top46
-rw-r--r--mdk-stage1/ppp/sunos4/if_ppp_vdcmd.c57
-rwxr-xr-xmdk-stage1/ppp/sunos4/ppp.INSTALL104
-rw-r--r--mdk-stage1/ppp/sunos4/ppp_ahdlc_vdcmd.c57
-rw-r--r--mdk-stage1/ppp/sunos4/ppp_comp_vdcmd.c57
-rw-r--r--mdk-stage1/ppp/sunos4/ppp_vdcmd.c81
-rw-r--r--mdk-stage1/ppp/svr4/Makedefs16
-rw-r--r--mdk-stage1/ppp/svr4/Makedefs.sol259
-rw-r--r--mdk-stage1/ppp/svr4/Makefile.sol266
-rw-r--r--mdk-stage1/ppp/svr4/Makefile.sol2-6485
-rw-r--r--mdk-stage1/ppp/svr4/Makefile.svr460
-rw-r--r--mdk-stage1/ppp/svr4/Makefile.top50
-rw-r--r--mdk-stage1/ppp/svr4/ppp.Master1
-rw-r--r--mdk-stage1/ppp/svr4/ppp.Node1
-rw-r--r--mdk-stage1/ppp/svr4/ppp.System1
-rw-r--r--mdk-stage1/ppp/svr4/ppp.conf1
-rw-r--r--mdk-stage1/ppp/svr4/ppp_ahdl.Master1
-rw-r--r--mdk-stage1/ppp/svr4/ppp_ahdl.System1
-rw-r--r--mdk-stage1/ppp/svr4/ppp_ahdlc_mod.c49
-rw-r--r--mdk-stage1/ppp/svr4/ppp_comp.Master1
-rw-r--r--mdk-stage1/ppp/svr4/ppp_comp.System1
-rw-r--r--mdk-stage1/ppp/svr4/ppp_comp_mod.c81
-rw-r--r--mdk-stage1/ppp/svr4/ppp_mod.c174
-rw-r--r--mdk-stage1/probing.c899
-rw-r--r--mdk-stage1/probing.h51
-rw-r--r--mdk-stage1/rescue-gui.c243
-rw-r--r--mdk-stage1/rp-pppoe/.cvsignore1
-rw-r--r--mdk-stage1/rp-pppoe/README87
-rw-r--r--mdk-stage1/rp-pppoe/configs/firewall-masq35
-rw-r--r--mdk-stage1/rp-pppoe/configs/firewall-standalone32
-rw-r--r--mdk-stage1/rp-pppoe/configs/pap-secrets9
-rw-r--r--mdk-stage1/rp-pppoe/configs/pppoe-server-options5
-rw-r--r--mdk-stage1/rp-pppoe/configs/pppoe.conf126
-rw-r--r--mdk-stage1/rp-pppoe/doc/CHANGES177
-rw-r--r--mdk-stage1/rp-pppoe/doc/HOW-TO-CONNECT295
-rw-r--r--mdk-stage1/rp-pppoe/doc/KERNEL-MODE-PPPOE39
-rw-r--r--mdk-stage1/rp-pppoe/doc/LICENSE339
-rw-r--r--mdk-stage1/rp-pppoe/doc/PROBLEMS3
-rwxr-xr-xmdk-stage1/rp-pppoe/go43
-rwxr-xr-xmdk-stage1/rp-pppoe/go-gui92
-rw-r--r--mdk-stage1/rp-pppoe/gui/Makefile.in64
-rw-r--r--mdk-stage1/rp-pppoe/gui/html/tkpppoe.html181
-rw-r--r--mdk-stage1/rp-pppoe/gui/pppoe-wrapper.145
-rw-r--r--mdk-stage1/rp-pppoe/gui/tkpppoe.136
-rwxr-xr-xmdk-stage1/rp-pppoe/gui/tkpppoe.in2891
-rw-r--r--mdk-stage1/rp-pppoe/gui/wrapper.c234
-rw-r--r--mdk-stage1/rp-pppoe/man/adsl-connect.866
-rw-r--r--mdk-stage1/rp-pppoe/man/adsl-setup.823
-rw-r--r--mdk-stage1/rp-pppoe/man/adsl-start.827
-rw-r--r--mdk-stage1/rp-pppoe/man/adsl-status.825
-rw-r--r--mdk-stage1/rp-pppoe/man/adsl-stop.821
-rw-r--r--mdk-stage1/rp-pppoe/man/pppoe-relay.8124
-rw-r--r--mdk-stage1/rp-pppoe/man/pppoe-server.8123
-rw-r--r--mdk-stage1/rp-pppoe/man/pppoe-sniff.877
-rw-r--r--mdk-stage1/rp-pppoe/man/pppoe.8236
-rw-r--r--mdk-stage1/rp-pppoe/man/pppoe.conf.5168
-rw-r--r--mdk-stage1/rp-pppoe/rp-pppoe-gui.spec98
-rw-r--r--mdk-stage1/rp-pppoe/rp-pppoe.spec71
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-connect.in278
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-init-suse.in62
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-init-turbolinux.in62
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-init.in64
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-setup.in346
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-start.in186
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-status82
-rwxr-xr-xmdk-stage1/rp-pppoe/scripts/adsl-stop.in84
-rw-r--r--mdk-stage1/rp-pppoe/src/.cvsignore2
-rw-r--r--mdk-stage1/rp-pppoe/src/Makefile45
-rw-r--r--mdk-stage1/rp-pppoe/src/Makefile.in257
-rw-r--r--mdk-stage1/rp-pppoe/src/common.c485
-rw-r--r--mdk-stage1/rp-pppoe/src/config.h135
-rw-r--r--mdk-stage1/rp-pppoe/src/config.h.in134
-rwxr-xr-xmdk-stage1/rp-pppoe/src/configure2356
-rw-r--r--mdk-stage1/rp-pppoe/src/configure.in231
-rw-r--r--mdk-stage1/rp-pppoe/src/debug.c143
-rw-r--r--mdk-stage1/rp-pppoe/src/discovery.c629
-rw-r--r--mdk-stage1/rp-pppoe/src/if.c1092
-rwxr-xr-xmdk-stage1/rp-pppoe/src/install-sh238
-rw-r--r--mdk-stage1/rp-pppoe/src/md5.c246
-rw-r--r--mdk-stage1/rp-pppoe/src/md5.h27
-rw-r--r--mdk-stage1/rp-pppoe/src/plugin.c397
-rw-r--r--mdk-stage1/rp-pppoe/src/ppp.c258
-rw-r--r--mdk-stage1/rp-pppoe/src/pppoe-server.c1247
-rw-r--r--mdk-stage1/rp-pppoe/src/pppoe-sniff.c258
-rw-r--r--mdk-stage1/rp-pppoe/src/pppoe.c834
-rw-r--r--mdk-stage1/rp-pppoe/src/pppoe.h331
-rw-r--r--mdk-stage1/rp-pppoe/src/relay.c1541
-rw-r--r--mdk-stage1/rp-pppoe/src/relay.h97
-rw-r--r--mdk-stage1/slang/Makefile42
-rw-r--r--mdk-stage1/slang/_slang.h743
-rw-r--r--mdk-stage1/slang/config.h163
-rw-r--r--mdk-stage1/slang/jdmacros.h53
-rw-r--r--mdk-stage1/slang/keywhash.c190
-rw-r--r--mdk-stage1/slang/sl-feat.h60
-rw-r--r--mdk-stage1/slang/slang.c5547
-rw-r--r--mdk-stage1/slang/slang.h1930
-rw-r--r--mdk-stage1/slang/slarith.c1656
-rw-r--r--mdk-stage1/slang/slarith.inc783
-rw-r--r--mdk-stage1/slang/slarray.c3139
-rw-r--r--mdk-stage1/slang/slarrfun.c464
-rw-r--r--mdk-stage1/slang/slarrfun.inc257
-rw-r--r--mdk-stage1/slang/slarrmis.c38
-rw-r--r--mdk-stage1/slang/slassoc.c713
-rw-r--r--mdk-stage1/slang/slbstr.c615
-rw-r--r--mdk-stage1/slang/slclass.c1391
-rw-r--r--mdk-stage1/slang/slcmd.c351
-rw-r--r--mdk-stage1/slang/slcmplex.c1142
-rw-r--r--mdk-stage1/slang/slcompat.c34
-rw-r--r--mdk-stage1/slang/slcurses.c972
-rw-r--r--mdk-stage1/slang/slcurses.h353
-rw-r--r--mdk-stage1/slang/sldisply.c2596
-rw-r--r--mdk-stage1/slang/slerr.c181
-rw-r--r--mdk-stage1/slang/slerrno.c219
-rw-r--r--mdk-stage1/slang/slgetkey.c306
-rw-r--r--mdk-stage1/slang/slimport.c281
-rw-r--r--mdk-stage1/slang/slinclud.h26
-rw-r--r--mdk-stage1/slang/slintall.c27
-rw-r--r--mdk-stage1/slang/slistruc.c218
-rw-r--r--mdk-stage1/slang/slkeymap.c596
-rw-r--r--mdk-stage1/slang/slkeypad.c163
-rw-r--r--mdk-stage1/slang/sllimits.h64
-rw-r--r--mdk-stage1/slang/slmalloc.c165
-rw-r--r--mdk-stage1/slang/slmath.c565
-rw-r--r--mdk-stage1/slang/slmemchr.c47
-rw-r--r--mdk-stage1/slang/slmemcmp.c76
-rw-r--r--mdk-stage1/slang/slmemcpy.c49
-rw-r--r--mdk-stage1/slang/slmemset.c39
-rw-r--r--mdk-stage1/slang/slmisc.c330
-rw-r--r--mdk-stage1/slang/slnspace.c242
-rw-r--r--mdk-stage1/slang/slospath.c73
-rw-r--r--mdk-stage1/slang/slpack.c785
-rw-r--r--mdk-stage1/slang/slparse.c1970
-rw-r--r--mdk-stage1/slang/slpath.c344
-rw-r--r--mdk-stage1/slang/slposdir.c1057
-rw-r--r--mdk-stage1/slang/slposio.c568
-rw-r--r--mdk-stage1/slang/slprepr.c427
-rw-r--r--mdk-stage1/slang/slproc.c155
-rw-r--r--mdk-stage1/slang/slregexp.c935
-rw-r--r--mdk-stage1/slang/slrline.c836
-rw-r--r--mdk-stage1/slang/slscanf.c718
-rw-r--r--mdk-stage1/slang/slscroll.c450
-rw-r--r--mdk-stage1/slang/slsearch.c239
-rw-r--r--mdk-stage1/slang/slsignal.c336
-rw-r--r--mdk-stage1/slang/slsmg.c1584
-rw-r--r--mdk-stage1/slang/slstd.c724
-rw-r--r--mdk-stage1/slang/slstdio.c1050
-rw-r--r--mdk-stage1/slang/slstring.c546
-rw-r--r--mdk-stage1/slang/slstrops.c1686
-rw-r--r--mdk-stage1/slang/slstruct.c932
-rw-r--r--mdk-stage1/slang/sltermin.c1155
-rw-r--r--mdk-stage1/slang/sltime.c310
-rw-r--r--mdk-stage1/slang/sltoken.c1702
-rw-r--r--mdk-stage1/slang/sltypes.c966
-rw-r--r--mdk-stage1/slang/slutty.c596
-rw-r--r--mdk-stage1/slang/slxstrng.c43
-rw-r--r--mdk-stage1/stage1-data/stage1-with-busybox.tar.bz2bin92142 -> 0 bytes-rw-r--r--mdk-stage1/stage1-data/stage1-with-sash.tar.bz2bin345030 -> 0 bytes-rw-r--r--mdk-stage1/stage1-data/stage1.tar.bz2bin1957 -> 0 bytes-rw-r--r--mdk-stage1/stage1.c638
-rw-r--r--mdk-stage1/stage1.h61
-rw-r--r--mdk-stage1/stdio-frontend.c369
-rw-r--r--mdk-stage1/thirdparty.c407
-rw-r--r--mdk-stage1/thirdparty.h32
-rw-r--r--mdk-stage1/tools.c561
-rw-r--r--mdk-stage1/tools.h72
-rw-r--r--mdk-stage1/url.c524
-rw-r--r--mdk-stage1/url.h46
-rw-r--r--mdk-stage1/usb-resource/.cvsignore1
-rw-r--r--mdk-stage1/usb-resource/Makefile25
-rwxr-xr-xmdk-stage1/usb-resource/update-usb-ids.pl53
-rw-r--r--mdk-stage1/wireless.c160
-rw-r--r--mdk-stage1/wireless.h22
-rw-r--r--move/.cvsignore4
-rw-r--r--move/Makefile159
-rwxr-xr-xmove/collect-directories-to-create.pl15
-rw-r--r--move/data/.cvsignore4
-rw-r--r--move/data/BOOT-1024-MOVE.jpgbin165129 -> 0 bytes-rw-r--r--move/data/BOOT-1280-MOVE.jpgbin248565 -> 0 bytes-rw-r--r--move/data/BOOT-1600-MOVE.jpgbin346222 -> 0 bytes-rw-r--r--move/data/BOOT-800-MOVE.jpgbin88325 -> 0 bytes-rw-r--r--move/data/always.dirs0
-rw-r--r--move/data/always.list143
-rw-r--r--move/data/always_i18n.list33
-rw-r--r--move/data/boot.dirs39
-rw-r--r--move/data/boot.list879
-rw-r--r--move/data/devices4
-rw-r--r--move/data/etcfiles36
-rw-r--r--move/data/etcfiles-report151
-rw-r--r--move/data/isolinux-graphic.bmpbin481078 -> 0 bytes-rwxr-xr-xmove/data/isolinux-graphic.bmp.parameters10
-rw-r--r--move/data/keyfiles24
-rwxr-xr-xmove/data/make_i18n_list47
-rw-r--r--move/data/nvidia.list5
-rw-r--r--move/data/symlinks4
-rw-r--r--move/data/totem.dirs2
-rw-r--r--move/data/totem.list68
-rw-r--r--move/doc/README95
-rw-r--r--move/doc/errata.144
-rwxr-xr-xmove/etc-monitorer.pl32
-rw-r--r--move/img/FE92-1024-MOVE1.jpgbin134082 -> 0 bytes-rw-r--r--move/img/FE92-1024-MOVE2.jpgbin110160 -> 0 bytes-rw-r--r--move/img/FE92-1024-MOVE3.jpgbin114463 -> 0 bytes-rw-r--r--move/img/FE92-1024-MOVE4.jpgbin42557 -> 0 bytes-rw-r--r--move/img/FE92-1024-MOVE5.jpgbin38483 -> 0 bytes-rw-r--r--move/img/FE92-1280-MOVE1.jpgbin195812 -> 0 bytes-rw-r--r--move/img/FE92-1280-MOVE2.jpgbin167724 -> 0 bytes-rw-r--r--move/img/FE92-1280-MOVE3.jpgbin165527 -> 0 bytes-rw-r--r--move/img/FE92-1280-MOVE4.jpgbin64707 -> 0 bytes-rw-r--r--move/img/FE92-1280-MOVE5.jpgbin58419 -> 0 bytes-rw-r--r--move/img/Mandrake.pngbin164099 -> 0 bytes-rw-r--r--move/isolinux/.cvsignore4
-rw-r--r--move/isolinux/help.msgbin1361 -> 0 bytes-rw-r--r--move/isolinux/isolinux.cfg14
-rw-r--r--move/isolinux/make.pl29
-rwxr-xr-xmove/make_live268
-rwxr-xr-xmove/make_live_tree_boot177
-rw-r--r--move/move.pm809
-rw-r--r--move/pkgs.pm32
-rw-r--r--move/runlevel_set.c25
-rwxr-xr-xmove/runstage225
-rw-r--r--move/todo39
-rwxr-xr-xmove/tools/busy-files25
-rw-r--r--move/tools/busy-files-accesses34
-rw-r--r--move/tools/check-fc-cache.pl27
-rwxr-xr-xmove/tools/fix-fc-cache.pl21
-rw-r--r--move/tools/kernel-nfsd.patch61
-rwxr-xr-xmove/tools/nfs-accesses67
-rwxr-xr-xmove/tools/scan-etc.pl41
-rwxr-xr-xmove/tree/X_move16
-rwxr-xr-xmove/tree/alsa_default.pl19
-rwxr-xr-xmove/tree/halt5
-rw-r--r--move/tree/kdedrc7
-rw-r--r--move/tree/konsolerc19
-rwxr-xr-xmove/tree/mdk_behind_totem106
-rw-r--r--move/tree/mdk_move_boot_loop.desktop8
-rwxr-xr-xmove/tree/mdk_move_loop56
-rwxr-xr-xmove/tree/mdk_totem125
-rw-r--r--move/tree/mdk_totem.desktop12
-rwxr-xr-xmove/tree/netscape3
-rwxr-xr-xmove/tree/reboot5
-rwxr-xr-xmove/tree/sound.initscript116
-rwxr-xr-xmove/tree/startkde_move17
-rw-r--r--move/tree/sudoers1
-rwxr-xr-xmove/tree/wait4x21
-rw-r--r--move/xwait.c19
-rw-r--r--rescue/.cvsignore1
-rw-r--r--rescue/Makefile12
-rw-r--r--rescue/aliases6
-rw-r--r--rescue/devices.pl54
-rw-r--r--rescue/dirs6
-rwxr-xr-xrescue/drvinst47
-rwxr-xr-xrescue/guessmounts82
-rwxr-xr-xrescue/install_bootloader63
-rw-r--r--rescue/list.xml233
-rwxr-xr-xrescue/lsparts45
-rwxr-xr-xrescue/make_partimage_save_rest_all65
-rwxr-xr-xrescue/make_rescue_img115
-rwxr-xr-xrescue/partimage_whole_disk191
-rwxr-xr-xrescue/rescue-doc60
-rwxr-xr-xrescue/restore_ms_boot73
-rwxr-xr-xrescue/tree/bin/insmod2
-rwxr-xr-xrescue/tree/bin/login2
-rw-r--r--rescue/tree/etc/fstab4
-rw-r--r--rescue/tree/etc/group1
-rw-r--r--rescue/tree/etc/host.conf2
-rw-r--r--rescue/tree/etc/hosts1
-rw-r--r--rescue/tree/etc/inittab14
-rw-r--r--rescue/tree/etc/issue28
-rw-r--r--rescue/tree/etc/passwd3
-rw-r--r--rescue/tree/etc/profile24
-rwxr-xr-xrescue/tree/etc/rc.reboot8
-rwxr-xr-xrescue/tree/etc/rc.sysinit62
-rw-r--r--rescue/tree/etc/resolv.conf2
-rwxr-xr-xrescue/tree/sbin/fakeshutdown39
-rwxr-xr-xrescue/tree/sbin/modprobe56
-rw-r--r--rescue/tree/usr/lib/CVS.0
-rw-r--r--rescue/tree/usr/share/symlinks11
-rw-r--r--tools/.cvsignore4
-rw-r--r--tools/2adsldb.pm17
-rw-r--r--tools/2isdndb.pm25
-rw-r--r--tools/Makefile39
-rwxr-xr-xtools/addchangelog.pl18
-rw-r--r--tools/alpha/cd/Makefile8
-rw-r--r--tools/alpha/cd/README40
-rw-r--r--tools/alpha/cd/README.milo13
-rw-r--r--tools/alpha/cd/aboot.cnf3
-rw-r--r--tools/alpha/cd/up1000/5100440A.txt25
-rw-r--r--tools/alpha/cd/up1000/README.txt16
-rwxr-xr-xtools/alpha/cd/up1000/apb.cfg2
-rwxr-xr-xtools/alpha/cd/up1000/apb.exebin120832 -> 0 bytes-rw-r--r--tools/alpha/cd/up1000/install.txt356
-rw-r--r--tools/alpha/cd/up1000/up1000.palbin30464 -> 0 bytes-rwxr-xr-xtools/alpha/e2fsck.sharedbin111080 -> 0 bytes-rwxr-xr-xtools/checkusedmodules22
-rwxr-xr-xtools/closurepkgs108
-rwxr-xr-xtools/cvslog2changelog.pl139
-rw-r--r--tools/dmidecode/.cvsignore1
-rw-r--r--tools/dmidecode/Makefile17
-rw-r--r--tools/dmidecode/dmidecode.c856
-rw-r--r--tools/drakx-in-chroot121
-rw-r--r--tools/extractchangelog2
-rwxr-xr-xtools/gencompss14
-rwxr-xr-xtools/gencryptofiles115
-rwxr-xr-xtools/genmodparm145
-rwxr-xr-xtools/get-needed-drakx-modules19
-rwxr-xr-xtools/hd_grub.cgi102
-rwxr-xr-xtools/i386/busyboxbin55508 -> 0 bytes-rwxr-xr-xtools/i386/e2fsck.sharedbin80308 -> 0 bytes-rwxr-xr-xtools/i386/mkreiserfsbin15868 -> 0 bytes-rw-r--r--tools/i386/netboot/.cvsignore4
-rw-r--r--tools/i386/netboot/3c503/nbgrubbin112066 -> 0 bytes-rw-r--r--tools/i386/netboot/3c503/pxegrubbin113090 -> 0 bytes-rwxr-xr-xtools/i386/netboot/3c503/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/3c503/stage2bin112130 -> 0 bytes-rw-r--r--tools/i386/netboot/3c507/nbgrubbin111616 -> 0 bytes-rw-r--r--tools/i386/netboot/3c507/pxegrubbin112640 -> 0 bytes-rwxr-xr-xtools/i386/netboot/3c507/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/3c507/stage2bin111680 -> 0 bytes-rw-r--r--tools/i386/netboot/3c509/nbgrubbin112020 -> 0 bytes-rw-r--r--tools/i386/netboot/3c509/pxegrubbin113044 -> 0 bytes-rwxr-xr-xtools/i386/netboot/3c509/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/3c509/stage2bin112084 -> 0 bytes-rw-r--r--tools/i386/netboot/3c529/nbgrubbin112724 -> 0 bytes-rw-r--r--tools/i386/netboot/3c529/pxegrubbin113748 -> 0 bytes-rwxr-xr-xtools/i386/netboot/3c529/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/3c529/stage2bin112788 -> 0 bytes-rw-r--r--tools/i386/netboot/3c595/nbgrubbin114408 -> 0 bytes-rw-r--r--tools/i386/netboot/3c595/pxegrubbin115432 -> 0 bytes-rwxr-xr-xtools/i386/netboot/3c595/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/3c595/stage2bin114472 -> 0 bytes-rw-r--r--tools/i386/netboot/3c90x/nbgrubbin115520 -> 0 bytes-rw-r--r--tools/i386/netboot/3c90x/pxegrubbin116544 -> 0 bytes-rwxr-xr-xtools/i386/netboot/3c90x/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/3c90x/stage2bin115552 -> 0 bytes-rw-r--r--tools/i386/netboot/cs89x0/nbgrubbin113762 -> 0 bytes-rw-r--r--tools/i386/netboot/cs89x0/pxegrubbin114786 -> 0 bytes-rwxr-xr-xtools/i386/netboot/cs89x0/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/cs89x0/stage2bin113826 -> 0 bytes-rw-r--r--tools/i386/netboot/davicom/nbgrubbin114160 -> 0 bytes-rw-r--r--tools/i386/netboot/davicom/pxegrubbin115184 -> 0 bytes-rwxr-xr-xtools/i386/netboot/davicom/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/davicom/stage2bin114192 -> 0 bytes-rw-r--r--tools/i386/netboot/depca/nbgrubbin111698 -> 0 bytes-rw-r--r--tools/i386/netboot/depca/pxegrubbin112722 -> 0 bytes-rwxr-xr-xtools/i386/netboot/depca/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/depca/stage2bin111762 -> 0 bytes-rw-r--r--tools/i386/netboot/device.map1
-rw-r--r--tools/i386/netboot/eepro/nbgrubbin111836 -> 0 bytes-rw-r--r--tools/i386/netboot/eepro/pxegrubbin112860 -> 0 bytes-rwxr-xr-xtools/i386/netboot/eepro/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/eepro/stage2bin111900 -> 0 bytes-rw-r--r--tools/i386/netboot/eepro100/nbgrubbin114112 -> 0 bytes-rw-r--r--tools/i386/netboot/eepro100/pxegrubbin115136 -> 0 bytes-rwxr-xr-xtools/i386/netboot/eepro100/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/eepro100/stage2bin114144 -> 0 bytes-rw-r--r--tools/i386/netboot/epic100/nbgrubbin113184 -> 0 bytes-rw-r--r--tools/i386/netboot/epic100/pxegrubbin114208 -> 0 bytes-rwxr-xr-xtools/i386/netboot/epic100/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/epic100/stage2bin113248 -> 0 bytes-rw-r--r--tools/i386/netboot/exos205/nbgrubbin111524 -> 0 bytes-rw-r--r--tools/i386/netboot/exos205/pxegrubbin112548 -> 0 bytes-rwxr-xr-xtools/i386/netboot/exos205/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/exos205/stage2bin111588 -> 0 bytes-rwxr-xr-xtools/i386/netboot/grubbin329223 -> 0 bytes-rw-r--r--tools/i386/netboot/lance/nbgrubbin113680 -> 0 bytes-rw-r--r--tools/i386/netboot/lance/pxegrubbin114704 -> 0 bytes-rwxr-xr-xtools/i386/netboot/lance/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/lance/stage2bin113744 -> 0 bytes-rwxr-xr-xtools/i386/netboot/makeImages31
-rwxr-xr-xtools/i386/netboot/make_boot_network24
-rw-r--r--tools/i386/netboot/menu.lst.example21
-rw-r--r--tools/i386/netboot/natsemi/nbgrubbin114564 -> 0 bytes-rw-r--r--tools/i386/netboot/natsemi/pxegrubbin115588 -> 0 bytes-rwxr-xr-xtools/i386/netboot/natsemi/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/natsemi/stage2bin114628 -> 0 bytes-rw-r--r--tools/i386/netboot/ne/nbgrubbin111752 -> 0 bytes-rw-r--r--tools/i386/netboot/ne/pxegrubbin112776 -> 0 bytes-rwxr-xr-xtools/i386/netboot/ne/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/ne/stage2bin111784 -> 0 bytes-rw-r--r--tools/i386/netboot/ne2100/nbgrubbin111962 -> 0 bytes-rw-r--r--tools/i386/netboot/ne2100/pxegrubbin112986 -> 0 bytes-rwxr-xr-xtools/i386/netboot/ne2100/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/ne2100/stage2bin112026 -> 0 bytes-rw-r--r--tools/i386/netboot/ni5010/nbgrubbin111006 -> 0 bytes-rw-r--r--tools/i386/netboot/ni5010/pxegrubbin112030 -> 0 bytes-rwxr-xr-xtools/i386/netboot/ni5010/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/ni5010/stage2bin111070 -> 0 bytes-rw-r--r--tools/i386/netboot/ni5210/nbgrubbin111796 -> 0 bytes-rw-r--r--tools/i386/netboot/ni5210/pxegrubbin112820 -> 0 bytes-rwxr-xr-xtools/i386/netboot/ni5210/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/ni5210/stage2bin111828 -> 0 bytes-rw-r--r--tools/i386/netboot/ni6510/nbgrubbin111930 -> 0 bytes-rw-r--r--tools/i386/netboot/ni6510/pxegrubbin112954 -> 0 bytes-rwxr-xr-xtools/i386/netboot/ni6510/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/ni6510/stage2bin111994 -> 0 bytes-rw-r--r--tools/i386/netboot/ns8390/nbgrubbin113896 -> 0 bytes-rw-r--r--tools/i386/netboot/ns8390/pxegrubbin114920 -> 0 bytes-rwxr-xr-xtools/i386/netboot/ns8390/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/ns8390/stage2bin113960 -> 0 bytes-rw-r--r--tools/i386/netboot/otulip/nbgrubbin113680 -> 0 bytes-rw-r--r--tools/i386/netboot/otulip/pxegrubbin114704 -> 0 bytes-rwxr-xr-xtools/i386/netboot/otulip/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/otulip/stage2bin113744 -> 0 bytes-rw-r--r--tools/i386/netboot/rtl8139/nbgrubbin113152 -> 0 bytes-rw-r--r--tools/i386/netboot/rtl8139/pxegrubbin114176 -> 0 bytes-rwxr-xr-xtools/i386/netboot/rtl8139/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/rtl8139/stage2bin113216 -> 0 bytes-rw-r--r--tools/i386/netboot/sis900/nbgrubbin116416 -> 0 bytes-rw-r--r--tools/i386/netboot/sis900/pxegrubbin117440 -> 0 bytes-rwxr-xr-xtools/i386/netboot/sis900/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/sis900/stage2bin116480 -> 0 bytes-rw-r--r--tools/i386/netboot/sk_g16/nbgrubbin111618 -> 0 bytes-rw-r--r--tools/i386/netboot/sk_g16/pxegrubbin112642 -> 0 bytes-rwxr-xr-xtools/i386/netboot/sk_g16/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/sk_g16/stage2bin111650 -> 0 bytes-rw-r--r--tools/i386/netboot/smc9000/nbgrubbin112162 -> 0 bytes-rw-r--r--tools/i386/netboot/smc9000/pxegrubbin113186 -> 0 bytes-rwxr-xr-xtools/i386/netboot/smc9000/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/smc9000/stage2bin112226 -> 0 bytes-rw-r--r--tools/i386/netboot/tiara/nbgrubbin110673 -> 0 bytes-rw-r--r--tools/i386/netboot/tiara/pxegrubbin111697 -> 0 bytes-rwxr-xr-xtools/i386/netboot/tiara/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/tiara/stage2bin110737 -> 0 bytes-rw-r--r--tools/i386/netboot/tulip/nbgrubbin123886 -> 0 bytes-rw-r--r--tools/i386/netboot/tulip/pxegrubbin124910 -> 0 bytes-rwxr-xr-xtools/i386/netboot/tulip/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/tulip/stage2bin123918 -> 0 bytes-rw-r--r--tools/i386/netboot/via_rhine/nbgrubbin113768 -> 0 bytes-rw-r--r--tools/i386/netboot/via_rhine/pxegrubbin114792 -> 0 bytes-rwxr-xr-xtools/i386/netboot/via_rhine/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/via_rhine/stage2bin113800 -> 0 bytes-rw-r--r--tools/i386/netboot/w89c840/nbgrubbin114140 -> 0 bytes-rw-r--r--tools/i386/netboot/w89c840/pxegrubbin115164 -> 0 bytes-rwxr-xr-xtools/i386/netboot/w89c840/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/w89c840/stage2bin114172 -> 0 bytes-rw-r--r--tools/i386/netboot/wd/nbgrubbin112088 -> 0 bytes-rw-r--r--tools/i386/netboot/wd/pxegrubbin113112 -> 0 bytes-rwxr-xr-xtools/i386/netboot/wd/stage1bin512 -> 0 bytes-rw-r--r--tools/i386/netboot/wd/stage2bin112120 -> 0 bytes-rwxr-xr-xtools/i386/shbin153752 -> 0 bytes-rwxr-xr-xtools/ia64/e2fsck.sharedbin1060504 -> 0 bytes-rwxr-xr-xtools/ia64/elilo.efibin315800 -> 0 bytes-rwxr-xr-xtools/install-xml-file-list353
-rwxr-xr-xtools/mailchangelog.pl14
-rw-r--r--tools/make_lang_png_transparent.c167
-rwxr-xr-xtools/mdkinst_stage2_tool44
-rw-r--r--tools/ntp_servers.pl303
-rwxr-xr-xtools/patch_pcmcia_config.pl28
-rw-r--r--tools/ppc/README39
-rwxr-xr-xtools/ppc/Xpmacbin3762427 -> 0 bytes-rwxr-xr-xtools/ppc/convert5
-rw-r--r--tools/ppc/e2fsck.sharedbin101469 -> 0 bytes-rwxr-xr-xtools/ppc/magic89
-rwxr-xr-xtools/ppc/mapping29
-rwxr-xr-xtools/ppc/mkINSTALLCD71
-rwxr-xr-xtools/ppc/mkhybrid-1.12b5.4bin488623 -> 0 bytes-rwxr-xr-xtools/ppc/mkhybrid-1.12b5.4-x86bin194471 -> 0 bytes-rw-r--r--tools/ppc/yabootbin58556 -> 0 bytes-rw-r--r--tools/shift_all.pl113
-rw-r--r--tools/shift_img.c165
-rwxr-xr-xtools/simplify-drakx-modules5
-rwxr-xr-xtools/sparc/e2fsck.sharedbin125624 -> 0 bytes-rwxr-xr-xtools/specific_arch9
-rwxr-xr-xtools/syncrpms267
-rwxr-xr-xtools/update_images52
-rwxr-xr-xtools/x86_64/busyboxbin74064 -> 0 bytes-rw-r--r--tools/xhost+.c11
882 files changed, 0 insertions, 209083 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index 2a8035f11..000000000
--- a/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-docs
-images
-unused
-drakxtools.tar.bz2
-isolinux
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 1885a64dc..000000000
--- a/Makefile
+++ /dev/null
@@ -1,96 +0,0 @@
-include Makefile.config
-
-DIRS = tools kernel mdk-stage1 perl-install rescue
-
-.PHONY: dirs install isolinux-graphic.bmp.parameters isolinux-graphic-simple.bmp.parameters images
-
-install: dirs images rescue install_only
-
-dirs:
- @for n in $(DIRS); do $(MAKE) -C $$n all || exit 1 ; done
-
-images:
- DISTRIB_DESCR=$(DISTRIB_DESCR) ./make_boot_img
-
-tar: clean
- rpm -qa > needed_rpms.lst
- cd .. ; tar cfj gi.tar.bz2 gi
- rm needed_rpms.lst
-
-install_only:
- install -d $(MISC_DEST) $(EXTRA_INSTALL_DEST) $(IMAGES_DEST) $(MEDIA_INFO_DEST)
- ifneq (ppc,$(ARCH))
- cp -f images/* $(IMAGES_DEST)
- rm -rf $(IMAGES_DEST)/alternatives
- if [ `ls $(IMAGES_DEST)/*.img-* 2>/dev/null | wc -l` -gt 0 ]; then \
- cd $(IMAGES_DEST); mkdir alternatives; cd alternatives; mv ../*.img-* .; md5sum *.img-* > MD5SUM; \
- fi
- cd $(IMAGES_DEST); md5sum *.{img,iso}* > MD5SUM
- endif
- ifeq (alpha,$(ARCH))
- cp -f images/* $(ROOTDEST)/boot
- cp -f vmlinux.gz $(ROOTDEST)/boot/instboot.gz
- make -C tools/$(ARCH)/cd install ROOTDEST=$(ROOTDEST)
- endif
-
- ifeq (i386,$(ARCH))
- rm -rf $(ROOTDEST)/isolinux
- cp -af isolinux $(ROOTDEST)
- endif
-
- ifeq (x86_64,$(ARCH))
- rm -rf $(ROOTDEST)/isolinux
- cp -af isolinux $(ROOTDEST)
- endif
-
- make -C perl-install full_stage2
- make -C perl-install/share/advertising install
- make -C rescue install
-
-clean:
- rm -rf images
-# force taking new rpms from repository
- rm -rf kernel/RPMS
- for i in $(DIRS); do make -C $$i clean; done
- find . -name "*~" -o -name ".#*" | xargs rm -f
-
-check:
- @badrights=`find $(STAGE2_LIVE) | perl -lne 'print if !((stat)[2] & 4)'`; [ -z "$$badrights" ] || { echo "bad rights for files vvvvvvvvvvvvvvvvvvvvvvvvvv" ; echo "$$badrights" ; echo "bad rights for files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" ; exit 1; }
- @missing_kb=`find -name "Entries" | xargs perl -F/ -alne 'print $$ARGV =~ m|(.*)/CVS|, "/$$F[1]" if $$F[1] =~ /\.(png|gif|bmp|xcf|gz|bz2|tar|rdz|so|a|o|mar|img|exe)$$/ && $$F[4] ne "-kb"'` ; [ -z "$$missing_kb" ] || { echo "missing -kb in CVS for files vvvvvvvvvvvvvvvvvvvvvvvvvv" ; echo "$$missing_kb" ; echo "missing -kb in CVS for files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" ; exit 1; }
- $(MAKE) -C perl-install check
-
-upload:
- $(MAKE) clean
-
-# # done before make install to increment ChangeLog version
- tools/addchangelog.pl tools/cvslog2changelog.pl | tools/mailchangelog.pl &
-
- $(MAKE) install
- $(MAKE) check
- $(MAKE) upload_only
-
-upload_only:
- function upload() { rel=`echo $$1 | sed 's!$(ROOTDEST)/!!'`; rsync -qSavz --verbose --exclude '*~' -e ssh --delete $$1/$$2 mandrake@ken:/c/cooker/$$rel; } ;\
- upload $(MEDIA_INFO_DEST) 'compssUsers.pl*' ;\
- upload $(MEDIA_INFO_DEST) rpmsrate ;\
- upload $(STAGE2_DEST) '*.clp' ;\
- upload $(STAGE2_DEST) mdkinst.kernels ;\
- upload $(STAGE2_DEST) VERSION ;\
- upload $(EXTRA_INSTALL_DEST)/advertising '' ;\
- upload $(MISC_DEST) gendistrib ;\
- upload $(MISC_DEST) mdkinst_stage2_tool ;\
- upload $(MISC_DEST) packdrake ;\
- upload $(MISC_DEST) packdrake.pm ;\
- upload $(MISC_DEST) auto ;\
- upload $(IMAGES_DEST) MD5SUM ;\
- upload $(IMAGES_DEST) '*.img*' ;\
- upload $(IMAGES_DEST) '*.iso*' ;\
- upload $(IMAGES_DEST)/alternatives '' ;\
- upload $(ROOTDEST)/isolinux '' ;\
- echo
-
-isolinux-graphic.bmp.parameters: isolinux-graphic.bmp isolinux
- perl -I perl-install perl-install/standalone/draksplash2 --isolinux --kernel isolinux/alt0/vmlinuz --initrd isolinux/alt0/all.rdz $<
-
-isolinux-graphic-simple.bmp.parameters: isolinux-graphic-simple.bmp isolinux
- perl -I perl-install perl-install/standalone/draksplash2 --isolinux --size 1400 $<
diff --git a/Makefile.common b/Makefile.common
deleted file mode 100644
index ec7066a06..000000000
--- a/Makefile.common
+++ /dev/null
@@ -1,64 +0,0 @@
- # -*- makefile -*-
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-ARCH := $(patsubst i%86,i386,$(shell uname -m))
-ARCH := $(patsubst sparc%,sparc,$(ARCH))
-
- #- default lib is dietlibc (honoured by main Makefile whenever possible)
-L = DIETLIBC
-#L = GLIBC
-
- #- default frontend is newt (honoured by main Makefile whenever possible)
-F = NEWT
-# F = STDIO
-
- #- override in some situations
-ifeq (ia64, $(ARCH))
-L = GLIBC
-endif
-ifeq (ppc, $(ARCH))
-L = GLIBC
-endif
-ifeq (x86_64, $(ARCH))
-#L = GLIBC
-endif
-
-ifeq (DIETLIBC, $(L))
-DIET = $(top_dir)/dietlibc/bin-$(ARCH)/diet
-endif
-
-
- #- flags used by all stuff
-ifeq (ppc, $(ARCH))
-CFLAGS = -Os -pipe -Wall -fomit-frame-pointer -fno-strict-aliasing
-else
-CFLAGS = -Os -pipe -Wall -Werror -fomit-frame-pointer -fno-strict-aliasing
-endif
-
-DIETLIBC_INCLUDES = -I$(top_dir)/dietlibc/include -I. -I$(top_dir)/bzlib
-GLIBC_INCLUDES = -I. -I$(top_dir)/bzlib
-INCLUDES = $($(L)_INCLUDES)
-
-GLIBC_LDFLAGS_STAGE1 = -static
-DIETLIBC_LDFLAGS_STAGE1 = -nostdlib
-LDFLAGS_STAGE1 = $($(L)_LDFLAGS_STAGE1)
-
-GLIBC_LIBC =
-DIETLIBC_LIBC =
-STAGE1_LIBC = $($(L)_LIBC)
-
-STRIPCMD = strip -R .note -R .comment
-
diff --git a/Makefile.config b/Makefile.config
deleted file mode 100644
index d798ff255..000000000
--- a/Makefile.config
+++ /dev/null
@@ -1,25 +0,0 @@
-ROOTDEST = /export
-MISC_DEST = $(ROOTDEST)/misc
-GENERIC_INSTALL_DEST = $(ROOTDEST)/install
-EXTRA_INSTALL_DEST = $(GENERIC_INSTALL_DEST)/extra
-IMAGES_DEST = $(GENERIC_INSTALL_DEST)/images
-STAGE2_DEST = $(GENERIC_INSTALL_DEST)/stage2
-STAGE2_LIVE = $(STAGE2_DEST)/live
-
-MAIN_RPMS_DIR = $(ROOTDEST)/media/main
-MEDIA_INFO_DEST = $(ROOTDEST)/media/media_info
-
-DISTRIB_NAME = Mandrakelinux
-DISTRIB_VERSION = 10.2
-DISTRIB_DESCR = "$(DISTRIB_NAME) release $(DISTRIB_VERSION) (Limited Edition 2005)"
-
-
-# not config, but useful everywhere :)
-ARCH := $(patsubst i%86,i386,$(shell uname -m))
-ARCH := $(patsubst sparc%,sparc,$(ARCH))
-
-ifeq (x86_64, $(ARCH))
-LIB = lib64
-else
-LIB = lib
-endif
diff --git a/advanced.msg.xml b/advanced.msg.xml
deleted file mode 100644
index 01c2b575a..000000000
--- a/advanced.msg.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<document>
-The following install types may be used instead of previously notified :
- o <white>vgahi</white> for high resolution graphical installation.
- o <white>vga16</white> for 640x480 in 16 colors graphical installation.
-
-The following options may be added on the command line :
- o <white>readonly=1</white> to disable editing disk partitions.
- o <white>display=ackbar:0</white> to export display to <blue>ackbar</blue> machine screen 0 during
- installation.
- o <white>noauto</white> to disable automatic detection.
- o <white>security=n</white> to set security level to value <blue>n</blue>.
- o <white>updatemodules</white> to use the special update floppy containing modules updates.
- o <white>patch</white> to use a patch from the floppy (file named <blue>patch.pl</blue>).
- o <white>auto_install=floppy</white> to enable auto_install using <blue>auto_inst.cfg</blue> file on the
- floppy.
- o <white>memtest</white> to test your computer RAM for faulty memory modules.
-</document>
diff --git a/docs/.cvsignore b/docs/.cvsignore
deleted file mode 100644
index a0593a470..000000000
--- a/docs/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-pictures
diff --git a/docs/9.0_errata.txt b/docs/9.0_errata.txt
deleted file mode 100644
index 4fec8885c..000000000
--- a/docs/9.0_errata.txt
+++ /dev/null
@@ -1,108 +0,0 @@
-# This file contains all the bugs/glitches/inconsistencies shipped in
-# 9.0 (Dolphin) Mandrake Linux Release.
-
-# Feel free to add your entry and if possible the fixes and status of
-# the errata.
-
- o Drakxtools:
- ==========
-
- widget libraries:
-
- In both XFdrake and printerdrake pop up small, empty, gray windows when
- clicking in the main menu. STATUS: Not fixed.
-
- Scroll bars and widget sizes often not correct (visible primarily in the
- printer options step of the "Add printer" wizard of printerdrake. STATUS:
- Not fixed.
-
- harddrake:
-
- logdrake:
- IS: Send the alert mail when service is stopped but the mail
- is empty.
- SHOULD BE: incorporate a text on which service is stopped.
- Status: not fixed.
-
- o Drakconf:
- =========
- IS: locale nl_NL, sl and zh_CN prevent drakconf from starting with
- a "cannot call set_active on undefined values" error.
-
- SHOULD BE: work well in all locales.
-
- a workaround has been comitted
-
- o Drakfont:
- =========
-
- drakfont get stopped in stat64("/mnt/nt/winnt/fonts/8514oem.fon",
- ...) on ntfs partitions.
- there's a bug in ntfs.o fs module of the kernel
-
- o Install:
- ========
-
- o urpmi:
- ======
-
- "urpmi mplayer" shows a list of libraries it needs and asks whether
- to install all this, after saying "y", it says that all these
- packages are missing and fails (I have shown it to François and he
- says that is a bug with the "contribs". He had to regenerate the
- hdlists somehow. STATUS: Not fixed.
-
- o XFree 4.2.x:
- ============
-
- Touchpad mouse on my Asus S8600 notebook. Worked out-of-the-box
- with Mandrake 8.2, but in 9.0 I cannot do any dragging operation
- with the PS/2-"Standard" mouse setting. I switched to "Glidepoint"
- with mousedrake and then dragging works, but the emulation of the
- third button by pressing both buttons not. Adding the lines
-
- Option "Emulate3Buttons"
- Option "Emulate3Timeout" "50"
-
- to the mouse section of /etc/X11/XF86Config-4 manually fixes the
- middle-button problem. STATUS: Not fixed.
-
-
-
- Sometimes, XFree86 can cause sound glitches because of intensive
- pci bus usage.
- Adding the line
-
- Option "PciRetry" "true"
-
- to the "Device" section /etc/X11/XF86Config-4 fixes these boxes.
-
-
- I810 driver is bogus: when Xrender extension is in use (antialiased
- fonts), X11 may crash upon vt switch.
- is fixed in devel branch of cvs
-
-
- o Printer drivers:
- ================
-
- "Best Grayscale" mode of HP DeskJet 6xx and Apollo printers does
- not work. STATUS: Fixed on linuxprinting.org, needs to be packaged
- in "printer-drivers".
-
-o kernel:
- =======
-
- Sometimes reboot stops on "illegal seek" message (having /usr on /
- fs fix it)
-
- Sometimes process get blocked in D-state on ntfs partitions (see
- drakfont)
-
- i810_audio mistakely say to modules.pm through modules.*map it
- handles nforces whereas it lacks some workaround nvidia and alsa
- uses.
- workaround: perl-install/patch/patch-nforce.pl
-
- snd-via686 is said to produce background noise since alsa-0.9.0rc3
- workaround: switch to via82cxxx_audio (oss driver) through draksound
diff --git a/docs/9.1_errata.txt b/docs/9.1_errata.txt
deleted file mode 100644
index fa73c200e..000000000
--- a/docs/9.1_errata.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-# This file contains all the bugs/glitches/inconsistencies shipped in
-# 9.1 (Bamboo) Mandrake Linux Release.
-
-# Feel free to add your entry and if possible the fixes and status of
-# the errata.
-
-
- o DrakConf:
- =========
-
- - #2439: menudrake failled to run for users other than root and
- xserver owner
-
- - #3415: do not kill "explicitely non embeddable" processes when
- killing embedded tools
-
- both fixed in 9.1-12mdk
-
-
-
- o DrakxTools:
- ===========
- - drakconnect:
- o ltmodem support is missing from mdk9.1 [added in hp release]
- o various other fixes came into mdk4hp release
-
- - explanations: most common ones are not logged because of a
- standalone.pm vs common.pm methods overloading bug [not yet
- fixed]
-
- - harddrake-ui:
- o menu entry starts logdrake instead of harddrake's gui [fixed in
- cvs]
- o status bar is not cleared on config tool exit [fixed in cvs]
- o title bar miss some spaces in french locale [fixed in cvs]
-
- - harddrake service: 5 second timeout was too short so it was
- increased up to 25 seconds [in hp release]
-
- - localedrake/drakx: legal problem with rpc vs hong-kong||taiwan
- [fixed in hp release]
-
-
-
- o Kernel:
- =======
-
- - ntfs driver has a hang, additionally also causing 100% cpu usage
- if either the size of the ntfs filesystem or the number of MFT
- entries fell to a certain range and statfs() system call was
- invoked by an application (e.g. df, gnome system monitor, etc).
- see #3353
-
- it got fixed quickly but unfortunately too late for us
-
- the probability one hits this bug is 0.2% or every 512th users.
-
- updated ntfs driver (2.1.2a) is at the usual place,
-
- http://linux-ntfs.sourceforge.net/
-
- or more precisely,
-
- http://sourceforge.net/project/showfiles.php?group_id=13956
-
diff --git a/docs/BUGS b/docs/BUGS
deleted file mode 100644
index 1d154fcf1..000000000
--- a/docs/BUGS
+++ /dev/null
@@ -1,10 +0,0 @@
-doInstallStep: if there's not enough room, error, but packages are marked installed :(
-
-when you click directly on setupFilesystems and you have scsi, you're fucked.
-Even if you go to setupSCSI, you won't be able to have partitions again.
-
-bug non reproductible:
-- /etc/passwd is empty after `root passwd' stage :(
-- reboot at the end of package installation with a lot of error messages from
-gtk about the progressbar
-
diff --git a/docs/COPYING b/docs/COPYING
deleted file mode 100644
index 60549be51..000000000
--- a/docs/COPYING
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/docs/HACKING b/docs/HACKING
deleted file mode 100644
index 5b16ed18f..000000000
--- a/docs/HACKING
+++ /dev/null
@@ -1,137 +0,0 @@
--=-=--
-DrakX is a very big project, and it needs special setups to work.
-The purpose of this file is to explain how you can setup your box to make it
-compile and run.
--=-=--
-
-Beware, don't try this on a production machine with important data.
-
-
---------------------------------------------------------------------------
-Sources installation:
-
-First grab the gi.tar.bz2 archive and untar it in your home directory, for
-example from DrakX-*.src.rpm on your Mandrakelinux distribution.
-
-Fix a few things:
-% find gi -name "*/CVS/root/*" | xargs perl -pi -e 's/prigaux/anoncvs/'
-
-Then, log yourself into the cvs:
-% export CVS_RSH=ssh
-% export CVSROOT=:ext:anoncvs@cvs.mandrakesoft.com:/cooker
-% cvs checkout gi
-        (the passwd is: 'cvs')
-
-And update the gi package:
-% cvs update -P -d gi
-
-
---------------------------------------------------------------------------
-Preparing the compilation process:
-
-(1) target directory
-
-Create a top level directory called /export and give write permissions to
-the user/group that will be compiling DrakX.  It is also suggested that you
-copy a recent Mandrakelinux CD in there. (You don't have to put have all
-the RPMS...) ; you'll need roughly 1.5 Gbytes for a full install. (It is
-possible to not have a copy of Mandrakelinux there, if all you desire is to
-compile gi)
-
-
-(2) support directories
-
-You will need to create a top level /RPMS directory.  This directory needs
-to be populated with the following RPMS:
-locales-ja locales-ko locales-zh
-
-GI needs to be informed about which kernel(s) is/are to be used.
-Most of the time, no manual install is needed. Just be sure to
-have the BOOT kernel(s) in /RPMS, and typing make later on will
-extract the package(s) and build stuff from it.
-
-FYI, for each kernel, directories will be populated as follows:
-
-gi/kernel/all.kernels/2.6.0
- special files containing
- - vmlinuz, modules.dep
- - modules for stage1 (*.mar, *.tar)
- - modules for stage2 (modules.cz)
-
-
-(3) required rpm packages
-
-You need quite a number of rpm packages installed on your system
-to build gi properly. Roughly:
-
-emacs gcc make glibc-devel glibc-static-devel perl-devel XFree86
-XFree86-FBDev XFree86-VGA16 XFree86-devel libglib-devel
-libgtk+-devel ldetect ldetect-devel ldetect-lst
-ldetect-lst-devel libslang-devel libnewt-devel e2fsprogs
-libext2fs2-devel dosfstools rpm-devel rpmtools libbzip2_1
-libbzip2_1-devel libncurses5 libncurses5-devel setserial telnet
-parted raidtools pciutils mt-st gpart reiserfsprogs jfsprogs
-xfsprogs extipl pcmcia-cs gettext perl-Gtk2 perl-Glib perl-XML-Parser ash imlib
-fb2png ntfsprogs lm_sensors galaxy-gnome perl-PerlIO-gzip brltty
-lvm2 mkcd perl-URPM glibc-i18ndata cloop-utils partimage syslinux
-memtest86+ dmraid dietlibc-devel
-
-You may need a few others I forgot to mention. If the compilation fails, try
-to understand the message and install any necessary remaining package.
-
-
-(4)
-
-NEVER build or run Drakx as root.  Install sudo and setup the following
-permissions in /etc/sudoers:
-
-user ALL=(root)
-NOPASSWD:/usr/bin/patch,NOPASSWD:/bin/rpm,NOPASSWD:/bin/mount,NOPASSWD:/bin/cp,NOPASSWD:/bin/umount,NOPASSWD:/usr/bin/install,NOPASSWD:/bin/rm,NOPASSWD:/bin/mv,NOPASSWD:/bin/tar,NOPASSWD:/bin/cpio,NOPASSWD:/bin/chown,NOPASSWD:/bin/mkdir,NOPASSWD:/usr/bin/strip,NOPASSWD:/bin/mknod
-
-
-(5)
-
-pray
-
-[gc@obiwan ~/cvs/gi] make
-
-
----------------------------------------------------------------------------
-The comments written with #- are automatically stripped out at install.
-
-
----------------------------------------------------------------------------
-testing all:
-
-  go to the perl-install directory and execute ./install2 --testing
-
-  NEVER execute DrakX as root! You might need to allow all users
-  to read the block devices of your hard-disks, though (chmod a+w
-  /dev/hda* for example).
-
-
-
-Here is how I (dams) made it work on my computer.
--------------------------------------------------
-
-- get the sources
-- install the librairies needed included newt-devel gtk+-devel popt-devel popt gtk-engines
-- cd path/to/gi
-- make
-- mkdir /usr/share/gtk
-- ln -s path/to/gi/perl-install/share/themes /usr/share/gtk
-- ln -s path/to/gi/perl-install/share/step-* /usr/share
-- ln -s path/to/gi/perl-install/share/help.xpm /usr/share
-- ln -s path/to/gi/perl-install/share/isdn* /etc/sysconfdir/network-scripts
-- have a cd architecture linked on /export
-- ln -s /export /tmp/rhimage
-- export PERL_INSTALL_TEST=1
-- cd path/to/gi/perl-install
-- gendistrib --noclean --distrib /export
-- ./install2 in root (dangerous) or chmod a+r /dev/hd* and ./install2 in user
-
-
-
-address all bugreports to dave@null.com
-
-info has been added by sunny@opencurve.org
diff --git a/docs/Partition-ends-after-end-of-disk.txt b/docs/Partition-ends-after-end-of-disk.txt
deleted file mode 100644
index 3da57d561..000000000
--- a/docs/Partition-ends-after-end-of-disk.txt
+++ /dev/null
@@ -1,66 +0,0 @@
- Cylinder/Head/Size Hell Is Not Over
-
- pixel@mandrakesoft.com
- $Date$
-
-
-Nowadays, you can boot Linux without ever relying on CHS
-(Cylinder/Head/Size):
-
-- CHS information on partition table is obsolete and not used anymore.
-It was causing the 1024th cylinder limitation:
- - disallowing partitions above 8GiG. Problem overcome using 28bits Linear
- Block Addressing (LBA) in partition table.
- - disallowing to boot on partition above 8GiG (due to int13 limitation used
- in bootloaders). Problem overcome using int13 extensions (EDD)
-
-Logical CHS (Cylinder/Head/Size) and physical CHS are not related anymore.
-Especially the size of a hard drive is not a multiple of the number of
-Cylinders.
-
-
-The problem is that many tools still rely somewhat heavily on CHS information.
-- most tools adjust partitions on cylinder boundary
-- some tools compute the size of the disk based on CHS (eg: fdisk)
-
-
-Resulting problems in various tools:
-
-- last partition not cylinder boundary adjusted, and overrun CHS computed size
- - fdisk
- > Total allocated sectors %d greater than the maximum %d
- - cfdisk (need confirmation)
- > FATAL ERROR: Bad primary partition %d: Partition ends after end-of-disk
- or
- > FATAL ERROR: Bad logical partition %d: Partition ends after end-of-disk
- - Partition Magic (version?)
- > Error #109: Partition ends after end of disk
- - Windows <= 98se, Windows Me
- (doesn't like it, what error message?)
-
- Tools handling it correctly:
- - parted and so diskdruid in RedHat >= 7.2 (or is it 7.x?)
- - diskdrake >= Mandrake 8.2
- - Windows XP (need confirmation)
-
- Tools using the full size of the disk, and so causing pbs with fdisk/cfdisk/...:
- - diskdrake == Mandrake 8.2
-
-- disagreement between CHS and linear address
- - parted
- > "Warning: Unable to align partition properly. This probably means that
- > another partitioning tool generated an
- > incorrect partition table, because it didn't have the correct BIOS
- > geometry. It is safe to ignore,but
- > ignoring may cause (fixable) problems with some boot loaders.
- > Ignore Cancel ? C
- - lilo
- > Warning: Kernel & BIOS return differing head/sector geometries for device 0x80
- > Kernel: 38792 cylinders, 16 heads, 63 sectors
- > BIOS: 1023 cylinders, 255 heads, 63 sectors
- > Device 0x2100: Inconsistent partition table, 2nd entry
- > CHS address in PT: 48:0:1 --> LBA (771120)
- > LBA address in PT: 48384 --> CHS (3:3:1)
- > The partition table is *NOT* being adjusted.
-
-
diff --git a/docs/README b/docs/README
deleted file mode 100644
index 7f7c6b552..000000000
--- a/docs/README
+++ /dev/null
@@ -1,300 +0,0 @@
-Well here is a little description of what DrakX needs to work in comparison
-to the RH newt install.
-
-********************************************************************************
-* CVS **************************************************************************
-********************************************************************************
-Like all good free software, DrakX is in CVS :)
-
-You can access it at http://www.mandrakelinux.com/cgi-bin/cvsweb.cgi/gi
-
-or via
-
-export CVS_RSH=ssh
-export CVSROOT=:ext:anoncvs@cvs.mandrakesoft.com:/cooker
-cvs checkout gi
- (enter password 'cvs')
-
-
-This is only read-only access. If you want more, tell me (pixel@mandrakesoft.com)
-
-Alas, all is not in CVS, a lot of things come from rpm packages which you must
-install.
-
-Please note that redoing *all* the stuff is not for the faint of heart. I myself
-sometimes wonder what the whole make does :-%
-Instead, changing some .pm files is quite easy (nice interpreted language)
-
-********************************************************************************
-* Making your custom install ***************************************************
-********************************************************************************
-If you have your own rpms you want to add, or make your own updated cdrom, you
-just have to issue:
-
-% gendistrib --noclean --distrib <DIRS>
-
-Where <DIRS> is the root of all the media that the install will see, this first
-one is the main one :
-
-(1) network or 1-cdrom installs
- DIRS == the root directory of the Distribution
-
-(2) multi-cdrom install
- DIRS == the root directories of all the media that the install will see
-
-``gendistrib'' will scan the file media/media_info/hdlists in the main root
-directory (the first one in DIRS) to search for all media used. Typically you
-use media/main for RPM packages repository.
-For multi-cd, please use media/main or media/foo, etc.
-For one CD or a network/hd volume, please use media/main.
-
-Optionnally, you can modify ``media/media_info/rpmsrate''; this file manages
-the relative importance of the files, and thus their installation or not.
-
-To modify the code of stage2, use "misc/mdkinst_stage2_tool install/stage2" to generate "install/stage2/live".
-When you are done use "misc/mdkinst_stage2_tool install/stage2" again, the "rm -rf install/stage/live".
-See below for information about these files.
-
-********************************************************************************
-* FILES ************************************************************************
-********************************************************************************
-First here are the different things needed :
-
-media/media_info/hdlists
- description of the available install media.
- format is one line for one medium as
- <hdlist_name> <rpms_directory> <description>
- <hdlist_name> should be match regexp /hdlist\S*.cz2?/
- for example (two cd install) you get
- hdlist1.cz Mandrake/RPMS1 Boot CD
- hdlist2.cz Mandrake/RPMS2 Extension CD
-
-media/media_info/hdlist*.cz
- table of rpm's headers, referred by ``hdlists''
- their contents can be listed using ``packdrake -l <hdlist_file>'' or
- or ``parsehdlist <hdlist_file>''.
- ! Need to be remade when media/main changes (with ``gendistrib'') !
-
-media/media_info/depslist.ordered
- for each packages, tell which package it depends on. Also contains the
- size for some (obscure) bloody reasons.
- ! Need to be remade when media/main changes !
- (with ``gendistrib --noclean --distrib .'')
-
-media/media_info/compssUsers
-
-media/media_info/rpmsrate
- ranks and classify packages, so that the installer will know which
- ones to install. format is :
- <intern_group>
- <level> <packages>
- where <intern_group> is a symbolic name used in media/media_info/compssUsers* files,
- and <level> defines importance level as described below :
- 5 must have
- 4 important
- 3 very nice
- 2 nice
- 1 maybe
- by default (for non expert), group selects packages for level 4 (important)
- and 5 (must have). export mode add 3 (very nice) level. other level (below 2)
- can only be selected using individual package selection.
-
-install/stage2/live
- live system used on certain installs. See ``Ramdisk or not'' below for
- more.
-
-install/stage2/mdkinst.clp
- for the compressed loopback of install.
- generated from install/stage2/live tree using misc/mdkinst_stage2_tool
-
-install/stage2/rescue.clp
- rescue ramdisk. create_compressed_fs iso file
- this is the ramdisk loaded when typing rescue on boot prompt.
-
-install/images/*.img
- floppy boot images to use with DrakX. Use:
- - cdrom.img for cdrom install
- - network.img + network_drivers.img for ftp/nfs install (non-pcmcia devices)
- - hd_grub.img for hard-disk install (see http://qa.mandrakesoft.com/hd_grub.cgi)
- - pcmcia.img for pcmcia install (see ``PCMCIA install'' below for more)
-
-install/images/boot.iso
- iso image to burn enabling any install (cdrom/hd/nfs/ftp)
-
- Boot from cdrom:
- - boot.iso : iso image to burn
-
- Boot from hd (esp. usb key):
- - all.img : fat16 image to dd on a partition (hint: sda1)
- - it seems some bioses don't use the code on MBR (sda),
- or at least skip it when it's blanked
- (eg: "dd if=/dev/zero of=/dev/sda bs=1 count=446")
- - some bioses need it. I had some luck using
- dd if=/usr/lib/extipl/aldebaran.bin of=/dev/sda
- (install package extipl first)
-
- Boot from network:
- - all.rdz + vmlinuz via pxe
-
- Boot from floppy:
- - cdrom.img : to install from a cdrom (but not a usb drive)
- - network.img + network_drivers.img : to install from network
- - hd_grub.img : to install from hd
-
- dd for windows: http://uranus.it.swin.edu.au/~jn/linux/rawwrite/dd.htm
-
-********************************************************************************
-* logs *************************************************************************
-********************************************************************************
-During install, a lot of interesting stuff can be found in different places:
-in consoles and in files. To switch to console 2 for example, do Ctrl-Alt-F2
-from the X install.
-- alt-F1: the stdout of the install. Not very interesting stuff
-- alt-F2: simple shell. Quite a lot of commands are available but as they are
-written in perl (for space), they do not handle the very same options as normal.
-After install, you can do ``chroot /mnt'' to see your system just like after
-rebooting. ``rpm -qa'' works for example.
-- alt-F3: a lot of interesting things. Be carefull, some ``ERROR'' messages are
-not interesting.
-- alt-F4: kernel's place. aka the output of dmesg.
-- alt-F7: the graphical install lives there
-
-- command "bug" puts on floppy lots of interesting stuff.
-- /tmp/stage1.log: same as alt-F3 part when stage1 run (e.g. actions
- before graphical install really begins)
-- /tmp/ddebug.log: (nearly the) same as latter alt-F3 part
-- /tmp/syslog: same as alt-F4
-- /mnt/root/drakx/ddebug.log: at the end of each step, DrakX tries to backup
- /tmp/ddebug.log to /mnt/root/drakx. Available only after mounting of /.
-- /mnt/root/drakx/install.log: the log of the installation (or upgrade) of the rpms
-(just like rpm's /mnt/tmp/(install|upgrade).log)
-- /mnt/root/drakx/auto_inst.cfg.pl: a kickstart file generated at the end of each
-step. Can be used in 2 ways: kickstart install or ``defcfg'' install. Hopefully
-you know about kickstart. ``defcfg'' is a way to customize the default values in
-install. For example, French can be the default language with a qwerty keyboard,
-the auto-partitionning partitions can be changed, the default user class can be
-set to developer (!)...
-
-********************************************************************************
-* po translation files *********************************************************
-********************************************************************************
-DrakX uses .po files for its translation. A script takes the different
-strings out of the .pm files. It generates the DrakX.pot file which contains
-all the english strings to translate.
-
-********************************************************************************
-* PCMCIA install ***************************************************************
-********************************************************************************
-If the media you use to install is a pcmcia device, use the pcmcia boot disk.
-
-********************************************************************************
-* modules **********************************************************************
-********************************************************************************
-Modules can be found in at least 2 places:
-- in /modules/modules.mar
-- in /lib/modules.cz<KERNEL_VERSION_RELEASE>
-
-/modules/modules.mar is used in mdk-stage1. It contains only modules
-interesting for one kind of install. For example in an hd install, it
-contains scsi modules. For a network install, it contains network card
-modules. (To create, extract or view files in a ``mar'' archive, please
-use gi/mdk-stage1/mar/mar; this is basically an archive format meant to
-be minimalistic)
-
-/lib/modules.cz<KERNEL_VERSION_RELEASE> contains all modules, it is used
-in stage2.
-
-
-To manually install a module during install, switch to console #2
-and type "modprobe <modulename>". The modprobe program is a perl
-wrapper around /usr/bin/insmod. It uses the dependencies found in
-/modules/modules.dep (stage1).
-
-/usr/bin/insmod is a wrapper around /usr/bin/insmod_. It just extracts the
-module out of /lib/modules.cz in /tmp. Then it calls insmod_.
-
-/usr/bin/insmod_ is the real prog (which you usually find in /sbin/). You need
-to give it the complete path.
-
-********************************************************************************
-* Making screenshots ***********************************************************
-********************************************************************************
-1. easy solution: press "F2"!
-
-2. On a test machine, make a network install, switch to console (ctrl-alt-F2), enter:
-% xhost+
-then, on another computer:
-% DISPLAY=test_machine:0 xwd -root | convert - screenshot.png
-
-********************************************************************************
-* Auto install *****************************************************************
-********************************************************************************
-A powerful auto-install system is available. It allows performing
-an install without any human interaction.
-
-To feed automatic parameters to the stage1 part (the textmode
-part - might not be necessary for you if you plan to do
-cdrom-based auto-installs, but mostly highly needed when doing
-network installs), please refer to ../mdk-stage1/doc/TECH-INFOS.
-
-About the stage2 part (the actual installer, at the time you're
-(usually) running in graphical mode), please refer to the nice
-documentation written by David Eastcott. Either install the
-package "drakx-autoinstall-doc" from contrib, or browse:
-
-http://members.shaw.ca/mandrake/drakx/9.0/HTML/
-
-The previous document will explain you how to setup the contents
-of the auto_inst.cfg file. Note that you have 3 alternatives for
-providing this file:
-- from a floppy disk; use "kickstart=floppy" as kernel parameter,
- as explained in the document
-- from the installation volume itself; put the file in the
- "install" directory of the installation volume; use
- "kickstart" only, or "kickstart=filename" to specify another
- filename than auto_inst.cfg
-- specified by the network; setup your DHCP server to provide the
- "bootfile" parameter, this file will be used as the
- "auto_inst.cfg" file; in this case you also need to provide the
- "netauto" boot parameter
-
-In any case, if the specified file ends with -IP or -IP.pl, IP
-will be substituted by the IP address of the machine, when doing
-a network install. Might be useful so that you can control all
-your auto installs from your server.
-
-********************************************************************************
-* Miscellaneous ****************************************************************
-********************************************************************************
-> o Media access methods: nfs, ftp, http, hd, cdrom
-> o Stages: init, stage1, stage2
-> - What exactly each stage does
-
-init loads stage1
-stage1 loads stage2, from various medium type
-
-stage2 is too big to fit on a floppy, that's why stage1 exists
-
-> - How each stage relates to the various media access methods
-
-stage1 knows only how to access to the media is compiled for. It
-contains only the kernel modules needed for that media. For eg,
-the nfs/ftp/http stage1 (network.img floppy) doesn't contain scsi
-modules nor ide.
-
-> - How one stage terminates and another begins. i.e., How does
-> stage1 find, mount, and launch stage2?
-
- /sbin/init just starts /sbin/stage1, and monitors its
-execution; it's here to cleanly umount the partitions when stage1
-or stage2 dies/finished
-
- /sbin/stage1 takes care of mounting stage2 (in ramdisk if
-necessary) then it execs /usr/bin/runinstall2 (thus, stage2
-replaces stage1, and init then monitors stage2)
-
-> o Text and Graphic mode installers
-> - Architectural overview of each
-
-have a look at gi/docs/object_class.fig
-
diff --git a/docs/README.devel b/docs/README.devel
deleted file mode 100644
index 989946de9..000000000
--- a/docs/README.devel
+++ /dev/null
@@ -1,252 +0,0 @@
-Well here is a little description of how DrakX can be modified or extended.
-Please refer to README file for getting DrakX code source and to known more
-exactly how it works and what it can do.
-
-
-********************************************************************************
-* Execution of DrakX ***********************************************************
-********************************************************************************
-DrakX has originally be written by pixel in perl and C.
-entry point for stage2 is /usr/bin/runinstall2 which is typically a link to
-/usr/bin/install2 which simply load module install2.pm and execute
-install2::main with @ARGV.
-
-install2::main parse command line arguments, prepare installation, find the right
-install_interactive class (take a look at gi/docs/object_class.fig) according to
-command line, memory available and if the interactive chosen is initializing
-correctly, else it will try a less-demanding interactive object.
-Once done, $::o is set to this install & interactive object and main runs the
-various step of install2 defined in $o->{steps}, starting with $o->{steps}{first}
-and iterating with method install_any::getNextStep().
-while running step, it trap any errors that may arise and use perl exception to
-change step.
-
-********************************************************************************
-* DrakX modules descriptions ***************************************************
-********************************************************************************
-Here is a brief description of what each modules of DrakX is doing.
-
-install2: main module of DrakX as described above, main loop execution of DrakX.
-
-install_steps: generic installation module containing steps definition, all steps
- should always be defined here as some methods may be used on automatic mode.
- there is no interactivity available. typically are defined base operation for
- configuring each step according to $o.
-
-install_steps_interactive: generic installation module with generic interative
- methods. typically are found all interactive code of DrakX for each steps.
-
-install_steps_auto_install: implementation installation module without interactive
- methods to match auto_install mode. this is the simplest as almost no method are
- redefined (inherit module install_steps only, compared to other implementation
- modules described below).
-
-install_steps_stdio: implementation installation module with interactive stdio
- methods to match stdio mode. inherit modules install_steps_interactive and
- interactive_stdio.
-
-install_steps_newt: implementation installation module with interactive newt
- methods to match newt mode. inherit modules install_steps_interactive and
- interactive_newt.
-
-install_steps_gtk: implementation installation module with interactive gtk
- methods to match gtk mode. inherit modules install_steps_interactive and
- interactive_gtk.
-
-install_any: contains various methods using generic interactive interface but
- not used by standalone tools.
-
-install_gtk: contains various methods using gtk interface but not used by
- standalone tools.
-
-interactive_stdio: implementation methods for interactivity in stdio mode.
- inherit module interactive.
-
-interactive_newt: implementation methods for interactivity in newt mode.
- inherit module interactive.
-
-interactive_gtk: implementation methods for interactivity in gtk mode.
- inherit module interactive.
-
-my_gtk: basic gtk access methods.
-
-any: contains various methods using generic interactive interface. to compare
- against install_any module as this one is available for standalone tools.
-
-class_discard: simple module that implement every methods undefined to return
- nothing. this trick is used to ensure no undefined method can arise when using
- code that reference interactive method which are not defined.
-
-common: contains very simple and very usefull (common) methods to do various task.
- some methods inspired by functionnal language.
-
-c: contains wrapper to C definition of methods used by DrakX, use of C is necessary
- for C extern libraries interface (rpmlib, ldetect), kernel interface, XFree
- interface.
-
-commands: implement some un*x commands, conflicting name with perl contains
- trailing underscore (_). this module is used by commands perl script that
- determine which command to run according to $0 (this is used this way when DrakX
- is running).
-
-run_program: allow running a program with redirection but without using a shell.
- allow rooted execution.
-
-help: contains all help message displayed by DrakX.
-
-log: log facility methods.
-
-lang: language manipulation methods, get and set sysconfig file, load po.
-
-keyboard: keyboard manipulation methods, get and set sysconfig file, set console
- keyboard mapping.
-
-mouse: mouse manipulation methods, get and set sysconfig file, change mouse.
-
-timezone: time zone manipulation methods, get and set timezone.
-
-services: services manipulation methods, activate or delete services (see
- /etc/rc.d/init.d directories).
-
-detect_devices: manage detection of various class of hardware.
-
-devices: manage device file, create device special according device name.
-
-partition_table: base partition table management methods, it manages
- appriopriate partition_table_XXX object according to what has been read
- as XXX partition table type.
-
-partition_table::bsd: matches a BSD partition table.
-
-partition_table::dos: matches a DOS partition table.
-
-partition_table::emtpy: matches an empty partition table.
-
-partition_table::mac: matches an Apple partition table.
-
-partition_table::raw: generic class for the following partition_table::XXX.
-
-partition_table::sun: matches a Sun Label partition table.
-
-fs: read and write /etc/fstab file, mount and umount, format.
-
-fsedit: manage (modyfy, edit) mount point associated to partition (like editing
- /etc/fstab).
-
-swap: swap management methods, format and mount (activation).
-
-raid: raid (software only) management methods.
-
-lvm: lvm (Logical Volume Manager) management methods.
-
-loopback: loopback management methods, used for lnx4win type installation or using
- a file as a partition.
-
-diskdrake: diskdrake itself, disk graphical (using gtk) manipulation tools.
-
-ftp: ftp mangement methods, used when using ftp install.
-
-http: http management methods, used when using http install.
-
-modparm: kernel modules options management, allow building nice dialog with each
- module parameter available.
-
-modules: kernel modules management, allow loading or unloading (ala modprobe or
- insmod).
-
-printer: printer management methods, read and write both LPR or CUPS configuration.
-
-printerdrake: interactive printer management methods.
-
-network: network management methods, get and set sysconfig file.
-
-netconnect: network configuration wizard.
-
-netconnect_const: network configuration wirard data.
-
-Xconfig: X configuration (monitor + already existing config file) management.
-
-Xconfigurator: X configuration wizard.
-
-Xconfigurator_const: X configuration wizard data.
-
-booloader: bootloader (LILO, GRUB, LOADLIN, SILO) configuration management methods.
-
-pkgs: rpm package and hdlist, depslist management methods, allow selecting or
- unselecting packages, manage rpmsrate file and select group, installation and
- removal methods of rpm file.
-
-crypto: *obsoleted* module to manage crypto site and rpm file.
-
-standalone: standalone only, allow defining a standalone tools.
-
-bootlook: standalone only, interface with DrakConf to configure bootloader options.
-
-drakfirewall: standalone only, interface with DrakConf to configure a tiny firewall.
-
-********************************************************************************
-* DrakX FAT resizer module description *****************************************
-********************************************************************************
-here is a fat resizer written in perl and C used by DrakX (diskdrake) to resize
-FAT16/FAT32 partition. it moves clusters to make sure a shrink can be done on the
-limit of the partition itself, if no cluster need to be moved, only boot sector
-partition limit are modified.
-
-any: various methods to flag cluster, compute min size.
-
-boot_sector: boot sector management methods.
-
-c_rewritten: originally resize_fat was only perl, this contains code section that
- are the most sensible to speed or memory contraints and have been rewritten to C
- using perl extension.
-
-dir_entry: manage directory structure.
-
-directory: traverse directory recursively, needed to move correctly cluster.
-
-fat: manage fat structure.
-
-info_sector: manage info sector.
-
-io: manage I/O on disk (need to take care of big file as partition size may be
- larger than 2GB).
-
-main: main resizer algortihm. if needed allocate new clusters, copy files, copy
- directories. update boot sector info.
-
-********************************************************************************
-* Adding a new step to DrakX ***************************************************
-********************************************************************************
-Say we want to add a question for setting "alawindows" option.
-We put it pretty early in the install, let's say after "Select Installation
-Class".
-
-1. in install2.pm
-
-add
-
- selectAlawindows => [ __("A la windows or not"), 0, 1, '' ],
-
-after
-
- selectInstallClass => [ __("Select installation class"), 1, 1, '' ],
-
-the 0, 1, '' means not "redoable", "skip on error", "don't hide"
-
-2. add your function selectAlawindows in install2.pm
-
-sub selectAlawindows { $o->selectAlawindows }
-
-3. add your function selectAlawindows in install_steps_interactive.pm
-
-sub selectAlawindows {
- my ($o) = @_;
- $o->{alawindows} = $o->ask_yesorno('', _("Throw everything away as windobe does?"), 1);
-}
-
-4. add your function selectAlawindows in install_steps.pm (not needed in that
-case, except for auto_install)
-
-sub selectAlawindows {}
-
-
diff --git a/docs/README.pxe b/docs/README.pxe
deleted file mode 100644
index 2ddd205fe..000000000
--- a/docs/README.pxe
+++ /dev/null
@@ -1,133 +0,0 @@
-Here is a short description to configure a PXE server using dhcpd and tftpd.
-This allows a network boot for your ethernet card conforming to the Interl
-PXE specification.
-
-********************************************************************************
-********** General overview ************
-********************************************************************************
-
-You need a dhcp server and a tftp server on one or two machines to allow the
-network boot. We are not using a PXE server to achieve this as it is not
-mandatory.
-You can install tftp-server and dhcp-server package from the Mandrake
-distribution for example.
-
-On the server machine at 192.168.2.1, you will find a "/etc/dhcpd.conf" sample
-file written by Florin Grad <florin@mandrakesoft.com>, where "mydomain.com" is
-assumed to be your domain name, and 192.168.1.1 a name server. All install are
-done on subnet 192.168.2.0.
-
-All the files that will be downloaded by the tftp daemon are located under
-"/tftpboot" :
- "/tftpboot/pxelinux.0" is a program that is loaded directly by the machine
- where a network boot will be done, this program comes
- from the SYSLINUX package by H. Peter Anvin. (look at
- http://syslinux.zytor.com/pxe.php for more information)
- "/tftpboot/pxelinux.cfg/" is a directory where all configuration file for
- pxelinux.0 will be found, pxelinux.0 will download
- these file by itself. It searches first for a file
- named accordind to the machine IP address in
- hexadecimal, for example for 192.168.2.20, it
- looks for "C0A80214" first, then "C0A8021" and so
- on down to "C0", "C" and "default".
- "/tftpboot/network.rdz" is the standard network initrd for Mandrake installation.
- "/tftpboot/vmlinuz" is the boot kernel for installation.
- "/tftpboot/help.msg" is the message displayed by pxelinux.0, note that currently
- graphical message (as for install using SYSLINUX 1.48 with
- graphic patch by Mandrake) is not supported.
-
-All file "network.rdz", "vmlinuz", "help.msg" can be found by mounting "network.img",
-or the network floppy disk used for install, "pxelinux.cfg" is just an adaptation
-of the file found on the "network.img" called "syslinux.cfg" but without the reference
-to boot.msg (as it is not currently supported).
-
-Update network configuration for your needs and start dhcp server on the machine and
-tftp server and this should work.
-
-********************************************************************************
-* /etc/dhcpd.conf **************************************************************
-********************************************************************************
-ddns-update-style ad-hoc;
-
-authoritative;
-
-option space PXE;
-option PXE.mtftp-ip code 1 = ip-address;
-option PXE.mtftp-cport code 2 = unsigned integer 16;
-option PXE.mtftp-sport code 3 = unsigned integer 16;
-option PXE.mtftp-tmout code 4 = unsigned integer 8;
-option PXE.mtftp-delay code 5 = unsigned integer 8;
-option PXE.discovery-control code 6 = unsigned integer 8;
-option PXE.discovery-mcast-addr code 7 = ip-address;
-
-default-lease-time 28800;
-max-lease-time 86400;
-
-option domain-name "mydomain.com";
-option domain-name-servers 192.168.1.1;
-
-class "PXE" {
- match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
- option vendor-class-identifier "PXEClient";
-
- vendor-option-space PXE;
- option PXE.mtftp-ip 0.0.0.0;
- next-server 192.168.2.1; #tftp server location
-
- filename "pxelinux.0"; # standard TFTP
-
-}
-
-shared-network "mynetwork" {
- subnet 192.168.2.0 netmask 255.255.255.0 {
- option subnet-mask 255.255.255.0;
- option routers 192.168.2.1;
-
- ddns-domainname = "mydomain.com";
-
- pool {
- range 192.168.2.10 192.168.2.20;
- allow members of "PXE";
- }
- }
-}
-********************************************************************************
-* /tftpboot/pxelinux.cfg/default ***********************************************
-********************************************************************************
-default linux
-prompt 1
-timeout 72
-display help.msg
-label linux
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 vga=788
-label vgalo
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 vga=785
-label vgahi
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 vga=791
-label vga16
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 vga16
-label text
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 text
-label patch
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 patch vga=788
-label expert
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 expert vga=788
-label rescue
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz root=/dev/ram3 rescue rw
-label oem
- kernel vmlinuz
- append ramdisk_size=32000 initrd=network.rdz automatic=method:cdrom root=/dev/ram3 rescue oem rw
-********************************************************************************
-* Usefull linkst ***************************************************************
-********************************************************************************
-
-http://syslinux.zytor.com/pxe.php
-http://www.kano.org.uk/projects/pxe/
diff --git a/docs/SHORTCUTS b/docs/SHORTCUTS
deleted file mode 100644
index 93a7133db..000000000
--- a/docs/SHORTCUTS
+++ /dev/null
@@ -1,51 +0,0 @@
-********************************************************************************
-main shortcuts
-
-F1 -> help
-F2 -> take a screenshot
-F11 -> previous step
-F12 -> next (reachable) step
-
-********************************************************************************
-diskdrake
-
-taken directly from diskdrake.pm:
-
- "a" => \&Active,
- "b" => \&Move,
- "c" => \&Create,
- "d" => \&Delete,
- "f" => \&Format,
- "m" => \&Mount_point,
- "M" => \&Mount,
- "n" => \&Create,
- "o" => \&ReadFromFile,
- "s" => \&SaveInFile,
- "q" => \&Exit,
- "r" => \&Resize,
- "t" => \&Type,
- "u" => \&Unmount,
- "w" => \&WritePartitions,
- "W" => \&WriteFstab,
-
-hopefully it is explicit enough :)
-
-********************************************************************************
-list choice
-
-- acceleration a la windows (default): enter a letter and the selection will move to the
-first entry beginning with that letter. If you enter another letter it will try
-to find the entry beginning with the 2 letters you have given. In case it fails
-the starting_word is reset.
-- incremental search a la emacs: searches trough the list
-
-Use control-s to use incremental search and then to search next occurence
-
-********************************************************************************
-in case of complete mouse sh**t
-
-XFree86 provides a way of moving the mouse pointer:
-- first, press Ctrl-Shift-NumLock
-- then move the pointer with the keypad arrows
-- press button is ``0'' (aka Inser)
-- release button is ``.'' (aka Suppr)
diff --git a/docs/TODO b/docs/TODO
deleted file mode 100644
index cb9399f82..000000000
--- a/docs/TODO
+++ /dev/null
@@ -1,515 +0,0 @@
--URGENT---------------------------------------------------------------------------------
-check for fpons/pixel BOTH that resize_fat is clean for current version
-relative to 7.0-2.
-
-heavy testing of diskdrake to avoid corrupting partition table, current version
-should be available to fix bogus partition table, writing enabled only when
-partition is Ok (fixme? allow primary partition inside extended one, but with
-warning on diskdrake startup, made them as warning ?).
-
--features-------------------------------------------------------------------------------
-add rpmdrake in menu
-
-(7.1 or later) clean SCSI CDROM autoboot.
-(done,gc,8.0) stage1 & cdrom: add ability in expert to choose the scsi cdrom drive to use
-
-(7.1)better help for partitioning in newbie
-
-(7.1)Improved network configuration (PPP and/or Ethernet)
-PPPoE install and configuration (SuSE includes it, DHCP-like)
-(7.1)standalone applications for configuration (netdrake, timetool, authentificationconf, soundcard)
-
-----
-(7.2) replace normal with standard (in the installClass's)
-
-(7.2 or later)horizontal sub-steps
-
-(7.2 or later)diskdrake in text mode
-
-ask "do you have SCSI?" before asking "probe PCI or not"
-
-(?) paride in stage1
-(done,gc,8.0) stage1 & network: add ability to choose the network interface to use
-
-(?) msec custom
-
-(?)firewall configuration (instant firewalling?)
-
-(?)widget for displaying fdisk (dindinx)
-add fdisk using the zvt widget (taken in gnome-libs)
-
-(?)help in some configuration files.
-
-ability to add nfs/weird_fs entries in fstab
-
-size of packages in crypto
-
--to test--------------------------------------------------------------------------------
-what's lseek64?
-
-ensure installClass is set to something in auto install.
-
-for axp, swriteboot -f1 if swriteboot failed.
-axp with swap part sigsegv
-
-tree for choosing monitors (buggy?)
-
-what happens if a module fails to insmod (scsi step), in beginner/normal/expert
-
-fstab must be sorted (/usr/local after /usr)
-
-RAID upgrades
-
-add choice clean /tmp or not in expert
-
-kernel chosen by default must be the one according to supermount/secure
-
-bug if ide-scsi, no more hdX, but scd0 (aka sr0)
- (and add alias block-major-11 ide-scsi ?)
-
-check on update for conf.modules and modules.conf !
-
-with /usr, /usr/local and /usr/local/e mount points i get an error at step mounting local filesystems
-
--easy fixes-----------------------------------------------------------------------------
-rpmdrake proposition for cdrom labels
-
-use option nocheck to mount for upgrades
-
--fixes needing thinking-----------------------------------------------------------------
-bug: changing mem= in miscellaneous doesn't modify lilo conf if you backtrack
-
-ask network configuration only if NIC found?
-
-configure DHCP for newbies if ethernet & DHCP card available
-
-xvidtune like screen configuration (see SuSE's yast)
-
-live cdrom for alpha (sparc?)
-
-network boot
-
-get the error when getting/reading .rpm files fail
-better timeout handling for network installs
-
-handle not enough room for update
-(fpons)verify the free space is big enough.
-
-the XFdrake test does not handle the fontset
-
-> Here I go into the printer configuration select 'HP Deskjet 722C Colour',
-> print a test ASCII page, pressing 'No' when prompted to indicate the page did
-> not print OK and then hitting cancel when prompted to choose a printer type
-> again.
-> ask_from_list cancel at /usr/lib/libDrakX/my_gtk.pm line 504.
-
-diskdrake: take from parted mklabel, hide(?)
-
-bug in kde desktop if keeps home but not an upgrade
-
-bug in users: mandrake user is added twice in strange installs
-(mixed of security 0 + ???)
-
-bugs rpmdrake:
-- just after installing a package, switch to `Installed', the package has wrong name
-- refresh the kde desktop after package installation in rpmdrake
-(restart kpanel)
-- rpmdrake and same name packages
-
-urpmi: pb if XXX-devel requires XXX = 1.2.3 and we updgrade XXX-1.2.3
-
-bug in defcfg in with lang=fr_FR, display is buggy
-
-bug keyboard focus: after switch in console at Xconfig step
-
-
-
--to look at--------------------------------------------------------------------------
-adduserdrake to remove/update users
-
-(???)free provider auto configuration facility (to be discussed).
-auto ppp-configure with free provider
-
-(?)on laptop, configure the MMU to use swap not very often
-
-(?)checkboxes in groups based on compssList (and availableSpace?)
-
-(?)see what can be done with nvram (50 bytes to save information)
-
-better wacom support
-
-(fpons)bug: CANON BJC 4X00 do not work with current rhs-printfilters
- (work with magicfilters (debian))
- (should be handled by ghostscript BJC600's driver)
-
-(pix)install text on mem=8M, mem=16M?
-
-(pix)kickstart
-partitioning? raid?
-X configuration and bootloader in kickstart
-
-XFdrake chooseResolutions with ask_from_list do not permit ``Show all''
-
-(?) options in mkfs, progress bar when formatting
-
-(?) when some error occurs, partition must be unset isFormatted
-
--hardware-------------------------------------------------------------------------------
-- with no floppy drive, mkbootdisk step fails badly
-- with bad floppy or write protected, mkbootdisk doesn't say anything
-- try detect_devices::floppies (and how are scsi floppies handled?)
-maybe: do a iotcl FDGETPRM to detect fd1, fd0.
-
-need a simple solution to precise mouse type (syslinux option?)
-
-ELSA Gloria has bad ddc info
-
-token ring is tr0 not eth0
-
-I have Mandrake 6.1 installed and working on a ThinkPad 770.
-To enable the PCMCIA Token ring I have to append the following line to
-/etc/pcmcia/config.opts
-module "ibmtr_cs" opts "mmiobase=0xd2000 srambase=0xd4000"
-
-smp not detected (mhoward@memphisonline.com on cooker, bios=BP6PW)
-
-UDMA66 (ultra66.o for promise)
-
-aha152x needs "insmod aha152x.o aha152x=0x140,11,7"
-
-(obsolete) usb module not removed if no mouse found
-
-(fpons)handle dat drives
-
-hibernation on laptop -> clock not restored
-
-# in 2.3.15 "Silicon Integrated Systems [SiS]|SiS900 10/100 Ethernet" is handled
-
-(?)enable the testing of the mouse type (under X) (wheel)
-possibility to specify the mouse
-
--(?)---------------------------------------------------------------------------------
-(?) handle NT (add entry for it in lilo, put it in fstab)
-
-(?) lilo-0.22-19mdk is buggy with boot=/dev/hde & root=/dev/sda13, it needs
-disk=/dev/hde bios=0x80 & disk=/dev/sda bios=0x81
-
-(?)using setxkb, enable the testing of the keyboard
-
-(?)XFdrake does not handle fbdev
-
-(?) Je viens de faire une installation sur une machine où seul Be était
-installé. Je l'ai supprimé et installé (mode recommandé) Oxygen. Au
-redémarrage, le boot manager de Be apparaît et il est impossible de
-démarrer Linux.
-Pourquoi ne pas installer LILO si on supprime toutes les partitions ?
-
-(?)initrd in bzip2
-
-(?)smaller zsh (or ash in initrd)
-
-(?)is configureNetworkNet needed with dhcp/bootp?
-
-(?)bug in upgrade: install from hda1:/usr/local/blah with hda1:/
-
-(?)mandrake_desk was not installed while kdebase it there on upgrade
-
-(?)when clicking on X configuration, installation of packages is not displayed
-
-(?)maybe remove commented lines in /usr/lib/perl5/... files
-
-(?)timezone using a picture (pb: how to delimit zones)
-when asking GMT or not, display the time for each possibility
-the list is too big for USA
-
-(?)ability to select the type of install when booting of cdrom
-(?)use the ability of el torito to handle 2.88MB or more
-
-(obsolete)lilo-deinstallation in case of lilo auto-installation for beginners
-
-(?)loadFont sucks
-
-(obsolete)trash on the screen when X first starts
-
-(?)remove the gray line surrounding the logo
-
-(?)cleanup /etc/services & /etc/protocols
-
-(?)strange: no scsi of type 'fd', only 'tape'
-
-(?)remount ro before X test.
-
-(?)remove every << and >> (doesn't handle > 32bits)
-
-
--done---------------------------------------------------------------------------------
-(7.1,done,fpons) improve printerdrake to at least have the same functionalities as printtool.
-
-(done,fpons)diskdrake can olverlap partitions (resize lower, resize original typically
-after clear all and auto allocate, try maximal size available).
-
-(done,fpons)rewrite mouseconfig in perl?
-
-(done,pix)kudzu or not in miscellaneous
-
-(done,pix)warn the user if not enough ram to fulfill install
-
-(done,fpons)test after printer config
-
-(done,pix)ask for more than the memory size detected
-
-(done,fpons)modem config
-
-(done,pix)call kudzu in batch to initialize its list
-
-(done,pix)standalone generator of mdkinst_stage2.gz
-
-(done,pix)text install
-
-(done,pix) if u choose mouse usb != found mouse, it fails at X config
-
-(done,pix) diskdrake bug: saved information on floppy contains isMounted.
-
-(done,pix) update devices.c from modules.pm
-
-(done,pix) in lilo.conf, put
-disk=/dev/hdb
- bios=0x80
-
-(done,pix) diskdrake
-auto_partitions
-suggested partition tables must be better foreach installClass
-
-(done,pix) update the list of modules (in update_kernel)
-
-(done,pix) language support: only choose the right locales and upmark the packages requiring it
-
-(done,pix) move security question before isntallation of packages
-
-(done,pix) install ssh
-
-(done,fpons,pix) change the boot message of syslinux (have something different from RedHat)
-
-(done,pix) install_steps.pm: 569 (128M + 3)
-
-(done,pix) bug: mouse freeze just before network configuration (mouse primax)
- (was kudzu)
-
-(done,pix) signal 11 in stage1 nfs kickstart mount failed
-
-(done,pix) ask supermount or not, no supermount with kernel-secure
-
-(done,pix) fix bug in g_auto_install (can't go through all)
-
-(done,pix) bug: install from ciril.fr fails
-
-(done,pix)wizard for partitioning in case of one full vfat
-
-(done,dindinx)app for choosing drakxtools (drakxconf)
-(done,pix)verify being root
-(done,pix)log::l -> initlog
-
-(done,pix)install apmd for laptops (maybe not start apmd though)
-(done,pix)icewm apm (sh icewm_apm)
-(done,pix)kde apm (put Kapm.kdelnk in ~/Desktop/Autostart)
-
-(done,pix)bug in adduserdrake: missing pwconv in md5
-(done,pix)correct the default value of draksec (cp draksec)
-(done,pix)in draksec, (and maybe others) have --expert as default if /etc/sysconfig/system has TYPE=expert
-
-(done,pix)bug in XFdrake in install, cancel in choose Card do not close the window
-
-(done,pix)in XFdrake, testing should not overwrite /etc/X11/XF86Config
-
-(done,pix) hwiz and supermount and eject :(
-
-(done(replaced by msec's),pix) bug: usermod -G urpmi a not done (full install)
-
-(done,pix)perl and .ph's
-
-(done,pix) BUG bootp in network install sigsegv
-
-(done,pix) move the last done stuff before Xconfiguration if possible
-
-(done,pix)draksec is buggy, don't try security >= 4
-
-(done,pix)install apmd on laptops?? (maybe ask emcweb@btinernet.com (see alix))
-
-(done,pix)missing alias ll for root
-
-(done,pix)urpmi.addmedia: |gzip instead of doing it afterwards
-
-(done,pix)locale (and fonts?) buggy in case ramdisk is used
-
-(done,pix)rpmdrake: Installed packages not in hdlist should be there
-
-(done)in ftp install, locale not installed properly
-
-(done,pix)pcmcia.img does not handle hd/cdrom
-
-(done,pix)cyrillic font buggy in DrakX
-
-(done,fred)remove xfs user from kdm
-
-(done,pix)bug with 2 cdrom drives (.kdelnk to there for 1st drive)
-
-(done,pix(works))test ramdisk stage2 and romanian
-
-(done,pix)kfmrc
-
-(done,pix)on laptop, default to 1024x768
-
-(done,pix)mkinitrd and deps
-
-(done,fred(removed the call))XFdrake and mousedrake freeze if lothar launches them
-
-(done,pix)crypto message
-
-(done,pix)test bug with lilo and windows (if not on mbr)
-
-(done,pix)removed icons come back later (kde desktop)
-
-(done,pix(was bug in upgrade reading old config))
- segfault in linuxconf (adapter 1 empty)
- (test with the sysconfig sent)
-
-(done,fpons)bug: Lrosqu'on effectue une mise à jour et que /etc/lilo.conf
-contient la variable « default » positionnée sur autre chose que
-« linux » ou « windows », DrakX est incapable de générer LILO.
-
-(done,fpons)bug: GeForce and hd.img?
-
-(done,fpons)for upgrade in expert, give choice of packages to install
- choosing packages available in upgrade?
-
-(done,pix)rpmdrake: pb uninstalling package with dependencies (rpmdrake is killed?!) (as root too)
-
-(done,pix)noatime option for ext2 fs on laptops (do not wake up the hd)
- Do not update inode access times on this
- file system (e.g, for faster access on the
- news spool to speed up news servers).
-
-(done,pix)kde's icons: 28 horiz and 25 vert grid for big icons
-
-(done,pix)bug: DrakConf don't follow the charset -> add setlocale(LC_ALL, "")
-(done,pix)for ko|ja|zh, gnome-terminal should point to rxvt (-CLE)
-(done,pix)group cdrom in /etc/group (gid=22)
-(done,pix)drakxtools should require urpmi
-(done,pix)bug: gdm unset LANG
-(done,pix) zip with automount -> ppa not autoloaded
-(done,pix)when you set the kde icons to Large, maybe it'd be good to chown the .kderc
-(done,pix)lilo in russian/japaneese is horrible
-(ok,pix)test ide burners
-(ok)test check bad blocks optional for mke2fs
-(done,pix)hd install: no umount is done at the end of install :(
-
-just before release:
-(done,pix)- mandrake_doc-xx, the symlink is no good in /usr/doc/mandrake as
-(done,pix)- crypto dependencies to update
-(done,pix)- update kudzu's pcitable
-(done,pix)- update pcitable for 86C368 if 3.3.6 (and other S3 3D's)
- ("ATI|3D Rage P/M Mobility AGP 2x" -> changed to Server:Mach64)
-
-(done,pix)with 2MB of video ram, chooses 8bpp instead of 16bpp
-
-(done,pix) replace
- { device => "loop7", type => 0x83, size => ((cat_('/dos/lnx4win/size.txt'))[0]*2048), mntpoint => "/", isFormatted => 1, isMounted => 1 },
-by
- { device => "loop7", type => 0x83, size => cat_('/dos/lnx4win/size.txt') * 2048, mntpoint => "/", isFormatted => 1, isMounted => 1 },
-
-(done,fpons)in ftp install, bug with X server install with wu-ftpd 2.6 (see http://www.wu-ftpd.org/broken-clients.html)
-
-(done,pix)ask package installation languages (must be put in RPM_INSTALL_LANG)
-
-(done,pix)bug (by dadou): Si la partition racine est trop petite pour installer le système, un
-message d'erreur apparaît pour signaler le problème (bien) mais on ne
-peut en sortir. La seule solution est de redémarrer.
-
-(obsolete)bug when selecting compssUsers, do not deselect after (if u deselect)
-
-(done,pix)detect ide burners and then add hdX=ide-scsi to kernel cmdline
-
-(done,pix)urpmi: handle many args on cmd-line
-
-(done,pix)fix any // in path to ftp server otherwise windobe server bug :(
-
-(done,pix)diskdrake and auto partitioning, may have the last creation of partition rejected,
-try to figure why?
-
-(done,pix)in chooseResolutions: display the graphic card found
-
-(done,pix)with pcmcia, need ONBOOT=no
-
-(fpons,done) XFree: handle by card options
-eg: SIS6326 needs "no_bitblt" "no_bltimage" and 24bpp instead of 32bpp
-
-(done,pix) Xconfiguration: if "can't open fixed font", relaunch xfs.
-
-(obsolete) pb with dependencies ``missing'': icewm do not require XFree86 and so you can have icewm but no X server
-
-(obsolete) bug in ext2resizing (no sparse superbloc, don't finish properly)
-
-(done,pix,7.1)manage a lot of language (ergonomic issue as it already exists)
-
-(done,pix,7.1)tree for choosing things like timezone, monitors, graphic cards, modules, mice, keyboard? ...
-
-(done,pix,7.1)sound config, although very simple, no dedicated steps and only PCI (or maybe ISA-PNP if time left ?)
-
-(done,pix,7.1)partitioning, keyboard shortcut.
-
-(done,fpons,7.1)index/compress hdlist? (for multi-cd)
-! for multi-cd live is mandatory, small transaction are mandatory too.
-
-(done,pix,7.1?)loopback partitions (even root one)
-
-(done,pix)in ok_cancel, focus has 3 states, should be 2 (ask dindinx)
-
-(done,pix,7.1)Generally improved package selection /ergonmic issue.
-Tree -> CTree, ``all'' branch with all packages
-show the value associated (100->a must, 90->great, 80->nice, ... 10->useless, 0->do not install)
-
-(done,pix)let diskdrake have dos/win partition automatically set up with mount point,
-this will help loopback too.
-
-(done,pix,7.1)grub
-
-(done,pix,7.1)feature missing: cancel installation
-
-(obsolete) bug in diskdrake: can in strange cases create a primary partition at sector #0
-
-(done,pix(partly, protection against bugging))bug in diskdrake:
-in expert: blank, create hda5 at beginning, create hda6 at the end, create hda7
-in the middle, remove the first one. Result hda5 at the end and bug.
-
-(obsolete) have a better time estimation of the remaining time in install packages
-
-(done,dindinx+pix)ask_many_from_list can't keyboard scroll
-
-(done,pix,7.1)individual package selection: double click is tiring...
-
-(done,fpons,7.1) sparc ehancement, avoid V7+ machine target (div and mul not in v7 standard)
-
-(done,fpons,7.1)syslinux in graphical mode to be improved for heavily bogus BIOSes.
-
-(done,pix)missing feature in lilo configuration: can't give hda2 with /boot/vmlinuz if
-already hda1 with /boot/vmlinuz
-
-(done,pix)in 640x480 install box is to small (cuz of 'Cancel' button beeing added)
-
-(done,pix)chooseGroup with individual alone
-
-(done)(7.1) rewrite crypto stuff
-(done)crypto: add a cancel & progress bar while downloading
-(done)error handling (like reading hdlist)
-(done)(7.1)progression bar on crypto.
-
-(done, daouda&pix,7.1, other persons)rescue:
-- small modification for stage1 to get the rescue stage2
-- create a stage2 with many tools (fdisk, bash...)
-the rescue could be on another cd (if multi-cd)
-! care must be taken about modules (if ide is in module...)
-
-(done,7.1)install in 800x600
-- need handling of both 640x480 (mostly for VGA16) and 800x600
-
-(done,NEED 7.1) auto-install for corporate, very important (need consolidation).
diff --git a/docs/advocacy b/docs/advocacy
deleted file mode 100644
index 9e7f00b6b..000000000
--- a/docs/advocacy
+++ /dev/null
@@ -1,87 +0,0 @@
-a little DrakX history:
-
-june 1999:
- i start rewriting redhat's install in perl, partly for the fun of it. I'm
- still working for the army
-
-5 july 1999:
- i start full time job at mandrakesoft. But we don't have many computers and i
- must share the accounting computer with Merieme who is working half-time. No
- test machine (i test on others box, and destroyed Jacques partitions once),
- guess how it slows things down?
-
-august 1999:
- at last computers, even test one
- first DrakX version which can install things, very very rough
-
-september 1999:
- a friend of mine help me 2 weeks on DrakX relayed by Francois
-
-november 1999:
- first released version of DrakX (goldpack). Not really stable yet.
-
-january 2000:
- 7.0 is out, with a DrakX quite stable
-
-july 2000:
- dams starts working on draknet
-
-mid-october -> mid-january 2000:
- gc rewrites the stage1 to win every kb we can
- -> size divided by 7 (!) for cdrom
-
-
-The DrakX team is also doing a lot of other things:
-- drakxtools
-- urpmi, early MandrakeUpdate, early rpmdrake...
-- Mandrake Control Center (new DrakConf)
-- packages maintenance/enhancing (esp. ghostscript, 3D-wrappers, lilo)
-- fixing core packages to make them installable
-- scoring packages, sorting them, flagging them... (compssList, rpmsrate)
-- reading/answering cooker and other MLs
-- helping non-perl gurus :)
-
-That doesn't give much. Me being the one more working on plain DrakX. It gives 2
-people working for 1.5 years. IMO it isn't ``spending an enormous amount of
-resources''.
-And what do you mean by ``compared to the code base size''??? DrakX is currently
-around 28K lines, which is big IMO. You can compare it with linuxconf which is
-170K lines. I think the achievement of DrakX is comparable (a 6 times code size
-win from dumb C++ to expressive perl is normal imo).
-
-
-Also it seems like we don't have the same understanding of the word
-"maintenance".
-DrakX functionalities have evolved *a lot* since the beginning:
-
-- hardware detection, configuration, debugging, work-arounding (multi-kernel installs...)
-- making things prettier
- - more bitmaps
- - "advanced" button
- - syslinux graphical boot
-- making it work with latest versions of software (eg: switching to rpm4)
-- finding out the best way to use rpmlib
-- multi-cd
-- draknet: configuring every piece of stupid protocols
-- diskdrake: raid, loopback, LVM, resizing, checking stupid users entry
-- XFdrake: multi-mice, multi-heads, 3D-accel
-- porting to axp/sparc/ppc (with Stew's help)
-- always more i18n
-- keeping things small
- - .cz format
- - moving to .png
- - getFile on demand from mdkinst for ramdisk installs
-
-[...]
-
-> You don't believe the books ? Count yourself; see the man/months spent
-> in 'pure' developoment in drakX, and the resources put in mantainance
-> of the code base; as far as i know, your count should confirm what the
-> books says; more probabily, you will discover that our numbers are
-> even worse.
-
-if you count enhancements, adding features... in maintenance, i confirm the
-numbers, and find them quite normal.
-
-if you only count bug fixing, the time would be much shorter (around 30%).
-
diff --git a/docs/advocacy-interactive b/docs/advocacy-interactive
deleted file mode 100644
index 99036008e..000000000
--- a/docs/advocacy-interactive
+++ /dev/null
@@ -1,60 +0,0 @@
-
-> > We already have some functional backends, frontends, that works great, and has
-> > not been thrown away since 1 year. We use it during install, post install, mcc
-> > and so.
->
-> But aren't generic enough.
-
-DrakX handles:
-- buttons
-- bool values (checkboxes)
-- ranges
-- entries
-- combo boxes (editable or not)
-- lists / radio boxes
-- tree lists
-- iconlist
-- wait messages
-
-Features:
-- all the entries above can be mixed
-- nice separation between data and displayed data (eg: choose in list of
-objects representing hda/hdb/... but displayed nicely with size...)
-- keyboard handled nicely in GTK frontend
-- callback on events:
- ok pressed => check before the dialog is hidden
- focus changed =>
- * enables pre-setting things based on other entries
- * value checking on the fly
-- simple/advance toggle
-- shadowing of entries
-- tooltips
-- size of windows computed the best possible
-- perl-based
-
-Misfeatures:
-- display not flexible (though i don't know any of the tools we're talking
-about that is flexible => nice)
-- quite a few features are gtk only (simple/advance toggle, shadowing of
-entries, certain events, tooltips).
-- a stdio front-end exist but handle only certain entries. It would need a
-week-work to finish it
-- a http front-end could be done (mod-perl needed)
-- perl-based
-
-The DrakX frontend (called "interactive") could be moved out of DrakX.
-
-eg of use:
-
-<#part type="text/plain" filename="~/bin/perl/imessage" disposition=attachment>
-<#/part>
-
-[...]
-
-> > -provides a lot of frontends
->
-> And you ideally have to provide a frontend by widget set.
-
-nope. The interface is completly standardised, even if it include some
-gtk-like niceties. The *complete* newt (and not just entries and radioboxes
-like bus) binding takes 241 lines.
diff --git a/docs/comparisons b/docs/comparisons
deleted file mode 100644
index f399a9e84..000000000
--- a/docs/comparisons
+++ /dev/null
@@ -1,288 +0,0 @@
-redhat 6.1 (fr?), install 766MB, df 900MB, 35min (asked for all groups except "everything")
-
-upgrade to redhat 6.2, sum 757MB, df 936MB, 20min
-
-mandrake 7.1, install 755MB, df 1091MB, 17min (asked install size 910MB), 515 packages
-
-upgrade to cooker, sum 1000MB, df 1404MB, 35min
-
-
-redhat 7.0b, install 815MB, df 960MB, 18min
-redhat 7.0, install 995MB, df MB, 26min
-
-7.2b, 3.3GB 2h26
-
-
-7.2b: (lang fr)
-compssLevel df rpm time fs df/time
-
-100 64 59 0:59 ext2 500M 1.08
- 90 132 127 1:50 ext2 500M 1.20
- 80 226 218 3:26 ext2 500M 1.10
- 70 449 387 5:52 ext2 1G 1.28
- 60 614 541 8:36 ext2 1G 1.19
- 50 1113 943 17:40 ext2 2G 1.05
- 40 1193 1013 20:39 ext2 2G 0.96
- 30 1262 1072 22:28 ext2 2G 0.94
- 20 1445 1219 27:34 ext2 2G 0.87
- 10 1649 1394 36:58 ext2 2G 0.74
- 0 1943 1638 48:02 ext2 2G 0.67
--10 2957 2519 101:49 ext2 4G 0.48
-
-7.2b: (lang all)
-compssLevel df rpm time fs df/time
-
-100 70 59 1:04 ext2 500M 1.09
- 90 289 281 4:20 ext2 500M 1.11
- 80 373 361 5:41 ext2 500M 1.09
- 70 890 794 13:28 ext2 1G 1.10
-
-
-mem used 7.2cooker
-gtk: runinstall2 13608(data 9572) + FBDev 2984(data 1544)
-newt: runinstall2 9516(data 7528)
-stdio: runinstall2 9160(data 7372)
-
-8.0rc1: (lang fr)
-
-rpmsrate
-
-4 () 175 139 3:25 reiserfs 2G 0.85
-4 all 831 786 18:08 reiserfs 2G 0.76
-
-8.1b
-
-5 () 77 66 1:24 ext2 300M
-
-8.1pre_rc1 rpm df time/rpm rpm/df
-
-6 () 82 66 1:26 ext2 500M 1.05 1.24
-5 () 89 71 1:38 ext2 500M 1.10 1.25
-3 () 94 77 1:46 ext2 500M 1.13 1.22
-5 X 145 127 2:09 ext2 500M 0.89 1.14
-3 X 231 217 3:26 ext2 500M 0.89 1.06
-4 kde 393 316 4:31 ext2 2G 0.69 1.24
-4 kde 393 316 4:41 ext2 2G 0.72 1.24
-4 kde 393 316 4:43 ext2 4G 0.72 1.24
-5 all 367 337 5:02 ext2 500M 0.82 1.09
-4 kde+gnome 454 370 5:50 ext2 4G 0.77 1.23
-4 kde+gnome 454 370 6:10 ext2 4G 0.81 1.23
-4 kde+gnome 454 370 6:24 ext2 4G 0.85 1.23
-5 all 489 406 5:55 ext2 4G 0.73 1.20
-5 all 490 406 5:18 ext2 1G 0.65 1.21
-4 kd+gn+dsk 594 494 7:31 ext2 4G 0.76 1.20
-4 prev+dev 827 696 10:27 ext2 4G 0.76 1.19
-4 all 1100 988 19:34 ext2 1G 1.07 1.11
-3 all 1640 1331 31:33 ext2 2G 1.15 1.23
-3 all 1740 1434 39:38 ext2 4G 1.37 1.21
-2 all 2252 1843 54:40 ext2 4G 1.46 1.22
--1 all 2490 2048 61:02 ext2 4G 1.47 1.22
-
-# perl -alpe '$F[4] =~ /(.*):(.*)/; $r = ($1 * 60 + $2) / $F[2]; s|\S+(\s+\S+)\s*$|sprintf("%.2f", $r) . "$1"|e;'
-# perl -ape '$r = $F[2] / $F[3]; s|\S+\s*$|sprintf "%.2f\n", $r|e;'
-
-9.0beta1
-
-5 () 89 71 1:35 ext2 500M
-3 X 240 231 3:41 ext2 500M
-5 all 306 293 3:36 ext2 500M
-4 all 808 731 6:48 ext2 1G
-4 all 1433 1331 21:44 ext2 2G
-4 X+kde 822 749 6:05 ext2 2G
-4 X+gnome 369 319 5:58 ext2 2G
-
-
-redhat 7.3:
-- do not halt the box when "halt" is used
-- no sysreq
-- kdm has gnome entry whereas gnome is not installed
- => choosing gnome gives a flashing black screen and kdm reruns
-
-- repartition of packages on various CDs is crap
-
-- bootloader: handling of multiple disks is more powerful in redhat, but more
-dangerous (proposed to everyone, but not proposed especially to people having
-a dangerous combinaison)
-- why still asking about lba32!!
-
-* anaconda 7.3 vs 7.3.92
- - skipddc option (locks some machines) ??
- maybe because it's done at the beginning of their install?
-
- - LVM
- - lvm_dialog_gui.py
- - Physical Extent 1MB 2MB 4MB ... 16GB
- (vgcreate -s ${PhysicalExtentSize}k)
- - see lvm_sanity_checks.txt, take them
- - lvm on / (mkinitrd)
- - handle upgrade when lvm on /
- - vgcreate -An (ie --autobackup no) ??
- (also for lvcreate vgchange lvremove
- - see clampPVSize in lvm.py
-
- - RAID
- - Number of spares ??
- - mkraid --dangerous-no-resync ??
-
- - progress bar in ext2 formatting
-
- - ctrl-alt-suppr during install => reboots
-
- - user names: the regexp is [a-zA-Z][^\0-\x20:,\n]* or [A-Za-z][A-Za-z0-9]{0,7} (depending on wether you're in text mode or graphic mode :)
- - check the user name created is not a system one (see systemUsers)
-
- - SMB authentification
- - cloneDrive ?
-
- - edd dropped (was to detect lba32 capability, which was dumb)
-
- - reconfig type of installed removed (was something between install & upgrade)
-
- - ddcprobe code removed -> moved to kudzu
- changes: sigprocmask and movl added around lrmi_vm86
-
- - $ENV{GDK_USE_XFT} = 0
-
-* kudzu 0.99.52 vs 0.99.55
- - blacklisting modules.pcimap e100 and bcm5700
-
-* hwdata 0.14 vs 0.32
- - dropped XFree86 3.3.6 support
-
- - upgradelist: list of (old_module => new_module) for upgrades
- (a simpler way would be to drop entries in modules.conf that concern
- obsolete (and not available anymore) modules, relying on auto-detection to
- add the new one)
-
- - CardMonitorCombos (for laptops)
-
-redhat 8.0:
-
- (legend: + pros - cons / notice)
-
- Install steps difference
- + firewall wizard
- + md5sum check when booting install
- - no upgrade packages installation during install
- - no services configuration (chkconfig)
- - no printer configuration
- - no autologin
- - no real small installation
- - no small packages (groff-for-man, perl-base...)
- / still propose non-MD5 or non-shadow passwords
- / post install tool (firstconfig)
-
- General install behaviour, eye-candiness
- + package selection a la Windows
- + in language selection languages displayed in native language
- + candy timezone selection
- + help uses bold/italic/big-font
- - no one CD install
- / not using fb at install
- / python + gtk2 vs perl + gtk
- / ask many things before doing anything (esp. delayed partitioning, swap not available when selecting packages!(?))
- - more width-hard-coded dialog boxes (harder for translations)
- / use a loopback file from the CD then copied on system
-
- Partitioning
- - no diskdruid after install
- - no partitioning wizard
- - no devfs
- - no xfs (but now has reiserfs/jfs)
- - no loopback crypted fs
- - no file swap (?)
- - no supermount
- + LABELed entries in fstab
- + progress bar while formatting
-
- Bootloader
- + bootloader configuration less awkward
- - no automatic handling of bios ordering with many harddrives
- - propose to manually change bios ordering even with one harddrive
- - LBA32 checkbox
- / defaults to grub
-
- Network
- - awkward question apropos hostname when using DHCP
- - no default choice for netmask/gateway/DNS based on IP
-
- XFree
- - no wacom configuration
- - no graphic card multi-head configuration
- - no ATI tvout configuration
- - no prompt for logout after changing X config
- - VideoRam prompted for everybody
- / no XFree3
- / no Utah GLX
- / load module "fbdevhw" "record", but not "v4l"
- / always load module "glx" and "dri"
-
- Keyboard
- - many non useful keyboard entries (eg: latin0)
- - no way to choose the toggle key to choose between latin/non-latin keyboard
- - no loadkeys done during install for console
-
- Mouse
- - no way to test mouse choice
- - mouse choices include many non-useful choices, badly sorted
- (Intellimouse must be sought in Microsoft whereas it's used by many others)
-
- Multimedia
- - no bttv configuration (including webcams)
- - missing audio modules (alsa, audigy...)
-
-* anaconda 8.0 (rel. 4) vs 8.0.92
- - use vte instead of gnome.zvt
- - add alpha (axp) partitioning code
- - remove label "nofb" and options "devfs=nomount ramdisk_size=9216" from syslinux.cfg
- - edd (ddc probe) moved to kudzu
- - add "-Odir_index" option to ext3 tunefs
- - screenshoting in directory /root/anaconda-screenshots/ instead of using exported display
- - assembler code change in cpuid, smp.c
- - there is some code to read the "raid superblock" (see doGetRaidSuperblock in isys/isys.c)
- - new code for choosing to upgrade or not
- - hack to remove /var/lib/rpm/__db.00[123] (with comment "make sure that the rpmdb doesn't have stale locks :/")
-
-* anaconda 8.0.92 vs 8.0.93 (rel. 0.20030108205243)
- - drop xmode (bring up text mode in a remote xterm)
- - code available to check the ability to do a mkbootdisk
- (check size of vmlinuz + initrd, check size of floppy)
- - drop "-Odir_index" option to ext3 tunefs
- (with comment "add back -Odir_index when htree is safe")
- - waitForLink added to loader2/net.c using added ethtool thingy (get_ethtool_link_status, get_link_status)
- - OS390 fdasd & z/IPL changes
- - for kickstart, new option "--ignoremissing", (there were --ignoredeps and --resolvedeps)
- - /usr/kerberos/lib in LD_LIBRARY_PATH
- - these are symlinks so you cant make them mount points
- otherexcept = ['/var/mail', '/usr/bin/X11', '/usr/lib/X11', '/usr/tmp']
-
- elif self.mountpoint in otherexcept:
- return _("The mount point %s cannot be used. It must "
- "be a symbolic link for proper system "
- "operation. Please select a different "
- "mount point.") % (self.mountpoint,)
-
-
-* hwdata 0.47 (redhat 8.0) vs 0.62 (redhat 8.1 beta1 phoebe)
- - pcitable & upgradelist
- - replace eepro100 with e100
- - switch 0x1106 0x3059 "via82cxxx_audio" to "unknown"
- - Cards
- - remove most swcursor with comment:
- # mharris - Nov 23, 2002 - Commented out the swcursor option, if it is still
- # needed, then lets disable it right in the driver completely, or possibly
- # fix it.
- - using driver "nv" for GeForce4 and Quadro4 with comment:
- # mharris - Nov 23, 2002 - enabling "nv" driver for GeForce 4 and Quadro 4 as
- # CVS XFree86 support them now in 4.2.99.2
- - special options "externDisp" and "internDisp" for NeoMagic cards
- together with CHIPSET
-
-* kudzu 0.99.69 (redhat 8.0) vs 0.99.83 (redhat 8.1 beta1 phoebe)
- - don't read eepro100 entries from the pcitable
- - handle compressed modules
- - many changes in PS/2 mouse detection, and handle "intellips/2" mouse
- - changes in PnP serial modem detection
- - use "udf,iso9660" option for cdrom entry in fstab
- (note that comma separated choice of filesystems *is* allowed, though not
- documented in fstab(5))
diff --git a/docs/diskdrake.TODO b/docs/diskdrake.TODO
deleted file mode 100644
index e6f2da038..000000000
--- a/docs/diskdrake.TODO
+++ /dev/null
@@ -1,23 +0,0 @@
-- test what windows can handle (the number of partitions)
-- better keyboard focus handling
-- end sector in Create
-- add warnings for scsi drives if you create more than sdx15
-- the information put in save/restore partitions must be cleaned
-(remove mounted/formatted/..., also remove the Data::Dumper dependency)
-- test, test, test
-- do not allow swap partitions above 2Gigs
-- wanting the first partition to be extended is not used
-- maybe warn if a mounted partition change of dev number
-- text version
-- better error handling (what to do if we find a bad partition table?)
-- display the information about the correspondance color2type
-- handle the partition labels (missing information here)
-- add comments in the code
-- add documentation
-- handle the `luke' case (main extended partition must be extended)
-- ability to batch actions (like chained moves)
-- add a verification after fdiskReadPartitionTable that the start_cyl,
-end_cyl... do correspond to start and start+size. For the moment, this
-information is just discarded :(
-This verif can't be done in fdiskReadPartitionTable as start is relative in
-extended partitions
diff --git a/docs/drakfont/Makefile b/docs/drakfont/Makefile
deleted file mode 100644
index b70b4a0c8..000000000
--- a/docs/drakfont/Makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-#
-# Project : Projet Libre
-# file : pki.tex
-# Date : Thu Jun 21 19:26:19 CEST 2001
-# (o- Id : DUPONT Sebastien
-# /\ mail : <dupont_s@epita.fr>
-# Y_/___________________________________________
-#
-
-RM = @rm -f
-
-CD = @cd
-
-ECHO = @echo
-
-PRINTF = @echo -n
-
-FILE = drakfont
-
-DVI = @dvips -j0 -Pcmz -Pamz -o
-
-PS = @ps2pdf
-
-LATEX = @latex
-
-normal :
- $(ECHO) '/*--LATEX--*/'
- $(LATEX) $(FILE).tex
-
-all :
- $(ECHO) '/*----------latex -> dvi -> ps -> pdf------------'
- $(ECHO) '/*--LATEX--*/'
- $(LATEX) $(FILE).tex
- $(ECHO) '/*--DVI -> PS--*/'
- $(DVI) $(FILE).ps $(FILE).dvi
- $(ECHO) '/*--PS -> PDF--*/'
- $(PS) $(FILE).ps
- $(ECHO) '/*--That s all--*/'
-
-
-ps : normal
- $(ECHO) '/*--DVI -> PS--*/'
- $(DVI) $(FILE).ps $(FILE).dvi
- $(ECHO) '/*--That s all--*/'
-
-pdf : ps
- $(ECHO) '/*--PS -> PDF--*/'
- $(PS) $(FILE).ps
- $(ECHO) '/*--That s all--*/'
-
-clean :
- $(RM) $(FILE).toc $(FILE).log $(FILE).aux *~
-
-fclean :
- make clean
- $(RM) $(FILE).ps $(FILE).pdf $(FILE).dvi
diff --git a/docs/drakfont/dia_srcs/drakfont.dia b/docs/drakfont/dia_srcs/drakfont.dia
deleted file mode 100644
index c4502a12e..000000000
--- a/docs/drakfont/dia_srcs/drakfont.dia
+++ /dev/null
Binary files differ
diff --git a/docs/drakfont/dia_srcs/drakfont_install.dia b/docs/drakfont/dia_srcs/drakfont_install.dia
deleted file mode 100644
index 737c19b9f..000000000
--- a/docs/drakfont/dia_srcs/drakfont_install.dia
+++ /dev/null
Binary files differ
diff --git a/docs/drakfont/dia_srcs/drakfont_uninstall.dia b/docs/drakfont/dia_srcs/drakfont_uninstall.dia
deleted file mode 100644
index c06f92dd6..000000000
--- a/docs/drakfont/dia_srcs/drakfont_uninstall.dia
+++ /dev/null
Binary files differ
diff --git a/docs/drakfont/drakfont.jpg b/docs/drakfont/drakfont.jpg
deleted file mode 100644
index 898dfe440..000000000
--- a/docs/drakfont/drakfont.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/drakfont/drakfont.tex b/docs/drakfont/drakfont.tex
deleted file mode 100644
index bbc936e5b..000000000
--- a/docs/drakfont/drakfont.tex
+++ /dev/null
@@ -1,152 +0,0 @@
-%\documentclass[pdftex]{article} \usepackage{hyperref} .
-%\documentclass[pdftex,onecolumn,11pt,oneside]{article}
-\documentclass[onecolumn,11pt,oneside]{article}%seminar}
-%\usepackage[pdftex]{hyperref}
-\usepackage{isolatin1}
-%\ifx\pdfoutput\undefined
-
-\usepackage[dvips]{graphicx}
-%\else
-%\usepackage[pdftex]{graphicx}
-%\usepackage[pdftex]{hyperref}
-%\usepackage{type1cm}
-%\fi
-%\pdfoutput=1
-\usepackage{color,graphicx,shortvrb,epsfig,verbatim,tabularx}
-\usepackage{url}
-\usepackage{hyperref}
-\urlstyle{sf}
-\usepackage{fancyheadings}
-\usepackage{program}
-\usepackage{ulem}
-\usepackage{amsfonts}
-\usepackage{xspace}
-\usepackage[english,francais]{babel}
-\pagestyle{fancy}
-\newcommand{\trtitle}{Drakfont\\ fonts importation for mandrake linux}
-\DeclareGraphicsRule{.ps}{eps}{.ps}{}
-\DeclareGraphicsExtensions{.ps}
-\renewcommand\star{{\ttfamily*}}
-\let\package\textsf
-\newlength{\gxlen}
-\settowidth{\gxlen}{\package{graphicx}: }
-\newcommand\gs{\makebox[\gxlen][l]{\package{graphics}:}}
-\newcommand\gx{\makebox[\gxlen][l]{\package{graphicx}:}}
-\MakeShortVerb{\|}
-\begin{document}
-\title{$Drakfont$ fonts importation for mandrake linux}
-
-\begin{figure}%[ht]
-\begin{center}
-%\caption{Exemple d'image}
-\mbox{\epsfig{file=mandrake.ps}}\\ %,height=1in,width=2in}}\\
-%\mbox{\epsfig{file=carte_.ps,height=1in,width=2in}}
-\end{center}
-\end{figure}
-%\begin{figure}
-%\begin{center}
-
-%\end{center}
-%\end{figure}
-\author{Dupont Sebastien \\ sdupont@mandrakesoft.com}
-\date{05/10/2001}
-\pagestyle{myheadings}
-\markright{\scriptsize \trtitle}
-\title{\bf \trtitle}
-\maketitle
-\section{drakfont Future Overview}
-
-\paragraph{Fonts import :\\}
-\begin{itemize}
-\item pfb ( Adobe Type 1 binary )
-\item pfa ( Adobe Type 1 ASCII )
-\item ttf ( True-Type )
-\item pcf.gz
-\item Speedo
-\item pfa ( Adobe Type 1 ASCII )
-\item ttf ( True-Type )
-\item and Bitmap (PCF, BDF, and SNF)
-\end{itemize}
-
-
-\paragraph{Features}
-\begin{itemize}
-\item Install fonts from any directory
-\item Get windows fonts on any vfat partitions
-\item UN-installation of any fonts (even if not installed through drakfont)
-\end{itemize}
-
-
-\paragraph{Support}
-\begin{itemize}
-\item Xfs
-\item ghostscript \& printer
-\item Staroffice \& printer
-\item abiword
-\item Koffice, Gnumeric, ... studying
-\item all fonts supported by printer
-\item ( aliases by RENDER in Xfree86 .... -> later )
-\end{itemize}
-
-
-\section{Window interface:}
-\begin{itemize}
-\item
-\item Fontselectiondialog widget
-\item Command buttons under Fontselectiondialog (like the actual frontend).
-\item Commands buttons:
-\item import from windows partition.
-\item import from all fat32 partitions and look for winnt/windows/font
-\item and import all (delete doublon) but don't import if already exist.
-\item import from directory
-\item look for if it exist before for each font and not delete the original.
-\item (replace all, no, none)
-\item expert options:
-\item ask the directory, and look for if it exist before
-\item if it exist ask: (replace all, no, none)
-\item uninstall with list per font type
-\item Expert additional switch
-\item option support: ghostscript, Staroffice, etc...
-\item check-button. (by default all check)
-\item Printer Application Fonts Support...
-\item check-button. (by default all check)
-\end{itemize}
-
-\section{Command line}
-\paragraph{Font Importation and monitoring application\\}
-\-\-windows\_import : import from all available windows partitions. \\
-\-\-strong : strong verification of font.\\
-\-\-install : accept any font file and any directory.\\
-\-\-uninstall : uninstall any font or any directory of font.\\
-\-\-replace : replace all font if already exist\\
-\-\-application : 0 none application.\\
- : 1 all application available supported.\\
- : name\_of\_application" like staroffice for only this one.\\
-
-\section{Graphics}
-
-to visualize the conceptual graphics please see:\\
-drakfont.jpg\\
-drakfont\_install\.jpg\\
-\& drakfont\_uninstall.jpg\\
-
-
-
-%\begin{figure}%[ht]
-%\begin{center}
-%\caption{Exemple d'image}
-%\mbox{\epsfig{file=drakfont_install.ps}}\\ %,height=1in,width=2in}}\\
-%\mbox{\epsfig{file=carte_.ps,height=1in,width=2in}}
-%\end{center}
-%\end{figure}
-
-
-%\begin{figure}%[ht]
-%\begin{center}
-%\caption{Exemple d'image}
-%\mbox{\epsfig{file=drakfont_uninstall.eps}}\\ %,height=1in,width=2in}}\\
-%\mbox{\epsfig{file=carte_.ps,height=1in,width=2in}}
-%\end{center}
-%\end{figure}
-
-\end{document}
diff --git a/docs/drakfont/drakfont_install.jpg b/docs/drakfont/drakfont_install.jpg
deleted file mode 100644
index 795a5a711..000000000
--- a/docs/drakfont/drakfont_install.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/drakfont/drakfont_uninstall.jpg b/docs/drakfont/drakfont_uninstall.jpg
deleted file mode 100644
index 711f28e77..000000000
--- a/docs/drakfont/drakfont_uninstall.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/drakfont/mandrake.ps b/docs/drakfont/mandrake.ps
deleted file mode 100644
index 1af9d5bb4..000000000
--- a/docs/drakfont/mandrake.ps
+++ /dev/null
@@ -1,534 +0,0 @@
-%!PS-Adobe-3.0
-%%Creator: GIMP PostScript file plugin V 1.12 by Peter Kirchgessner
-%%Title: /home/seb/drakfont/mandrake.ps
-%%CreationDate: Fri Oct 5 18:28:29 2001
-%%DocumentData: Clean7Bit
-%%LanguageLevel: 2
-%%Pages: 1
-%%BoundingBox: 14 14 424 84
-%%EndComments
-%%BeginProlog
-% Use own dictionary to avoid conflicts
-10 dict begin
-%%EndProlog
-%%Page: 1 1
-% Translate for offset
-14.173228 14.173228 translate
-% Translate to begin of first scanline
-0.000000 69.000000 translate
-409.000000 -69.000000 scale
-% Image geometry
-409 69 8
-% Transformation matrix
-[ 409 0 0 69 0 0 ]
-% Strings to hold RGB-samples per scanline
-/rstr 409 string def
-/gstr 409 string def
-/bstr 409 string def
-{currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}
-{currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}
-{currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}
-true 3
-%%BeginData: 29637 ASCII Bytes
-colorimage
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-bl7e@q"4E6s+13Ds*t~>
-bl7e@m,@els+13Ds*t~>
-bl7e@T5=@Ts+13Ds*t~>
-c2RqDnG2D<JcC<$U&TW~>
-c2RqDl/9_PJcC<$U&TW~>
-c2RqD]71%QJcC<$U&TW~>
-cMn+JnG;n/i;S<-JcDJEJ,~>
-cMn+JmbuTmh#;m)JcDJEJ,~>
-cMn+Jie^A<a8UYiJcDJEJ,~>
-cMn+DnbMk)f)($uJcDJEJ,~>
-cMn+DjkIhQchi:nJcDJEJ,~>
-cMn+DST5n_V>GiDJcDJEJ,~>
-ci47Jn+l_KeBdl?s+13Es*t~>
-ci47Jkhjh)WP\C\s+13Es*t~>
-ci47J^4K&h%!hSus+13Es*t~>
-d/OCNnbW%Rn_2+VJcC<$UAo`~>
-d/OCNn);p@^TP0>JcC<$UAo`~>
-d/OCNj+q1n%LcV6JcC<$UAo`~>
-d/OCHnG2eMo&%LUJcC<$UAo`~>
-d/OCHjkS+u^p135JcC<$UAo`~>
-d/OCHTl`:/%Lk8_JcC<$UAo`~>
-lMgqbp\sLY$2s;fp\"1NjN$P:s+13Es*t~>
-lMgqbp\sLY$2s,He&K8A[BAeGs+13Es*t~>
-lMgqbq>T^[$2r)%;B-/V%3+S`s+13Es*t~>
-li.(dk/mMerri>mqY9a_oE+4!k(3P`s.]OD~>
-li.(dk/mMersJbqin;Gk_SWgdk(3P`s.]OD~>
-li.(dmFhC'rsJbkMeO[R%M'!Pk(3P`s.]OD~>
-m/I4fjeV8=m/I1an+l\UoE4C(gAQU&JcDMFJ,~>
-m/I4fje_>>m/I4bjk\5#rk\cKUso9ns+13Fs*t~>
-m/I4flbMl_m/IIiWH^N?%Ls!Y%&s2Vs+13Fs*t~>
-mJd@ggl^4WrU'UfrU9RVp&4Lbm*a;WJcC<$U]5i~>
-mJd@gglg:XrU'UfrTiCk`r3aV];N^FJcC<$U]5i~>
-mJd@gjg<_0rU'UfrR6L%+8lZO%1J$fJcC<$U]5i~>
-mf*Iik)["5qX+:crq-'^p&+Famb#_TJcC<$U]5i~>
-mf*Iik)d(6qX+:drq#.'b/=1p"21eLoR[$ns.fUE~>
-mf*IilEnChqX+:drp>Y\/e\'l!Xrf8JcC<$U]5i~>
-n,F"!nYD2sp&>!hp%nOYp@\.TrV6BpqX41Qqt(!\hT52;s+13Fs*t~>
-n,F"!nYM8tp&>!hm-F!$l0Rm2rV6BqqW?VZ`;IIS^p(69JcC<$U]5i~>
-n,F"!o>7BVp&>!h[uQH0T!cSkrV6BqqQkK3(&JIB%70K7s+13Fs*t~>
-n,FI)^NR3SrVuomhY$U:q"X[\qY0^VpA+[ds82B`p\"CT!oq>fJcC<$U]5i~>
-n,FI)^j!BUrVuomg;hIdf%Jg6kNM-qn+?PWs82-AeAqF&!jo2uJcC<$U]5i~>
-n,FI)d@e5>rVuom_BM'9>A8)$G_hZm`nC%as80]m<Zq5K!Y$ODJcC<$U]5i~>
-nG`[jf8YC8q>UBuqVJd?m.L&NpAajeq#1!kp%eIZp%e4]kKW1@s+13Fs*t~>
-nG`[jf8YC8q>UC0qVJQ`]>_n8c-Xnhg"Y?>kiqElf#bi+_?.6OkCNYas.fUE~>
-nG`[jhm8^'q>UC0qVI;C%2gQM4%)eE@rZaAKVFlk?7QZc%Kd4N"m:I:JcDMFJ,~>
-nc&gmm]UN9m/I"a#6+8C]\r,HrUg-_rq??c!VZ3]oE4O8iVnE.JcDPGJ,~>
-nc&gmm]UQ:m/I"a(&mjRYd1mV_SX4/`lQ?JcdC7lcH*p!_?7KSh>W!*JcDPGJ,~>
-nc&gmnApp+m/I"a(&mjRCCL^_%M'-d*@NX&6:t6X5:%$?%Km:P%*&9ts+13Gs*t~>
-nc&dibD(8oq>C6srp\(Nj6cI(oE4^PjnOE,JcDPGJ,~>
-nc&dibD(;pq>C6srp\(:[(O6N_?7]o`5D>d"2VXrpjrHrs.o[F~>
-nc&dif<14fq>C6qrp\&r%J^M6%g3L](D78P%KT)pJcC<$V#Pr~>
-o)Apnm'1H"lMg\\#6!f&dH0iglLY2OnG*"XrsA\uq"XjgqtB^[JcC<$\c70~>
-o)ApnmBLT$lMg\\#6!f&\@0,fm(rqD`5^X+rqQL"rpo1Err;l[jSON.JcE:\J,~>
-o)Apnm`LrrlMg\\"T@T$+q<fI"VDOmC#f3frsA\WEU3W(qji66JcC<$\c70~>
-o)Amjb*?Map%eUlqr>9CjmVg,oEY'_p\"4Rr;QWo$2s&VmeZnNp>>Uqs+13\s*t~>
-o)Amjb*?Pbp%eUlqr>2i[_BTE_?e'"cIM%Anb`=`rsAYegtV](lHe5ZJcC<$\c70~>
-o)Amjf"$U`p%eUjqr=df%I4K1%hp3M>Ci]roD\[f$2s$mBDVSN(rc6#s+13\s*t~>
-o)Am`[;pHKrV6BrptE13kO@d/(%q:pq"X[Yp%\Lcs8M65p?qSEe(skOs+13\s*t~>
-o)Am`[W6TMrV6BrptE!V\A.@H(;n2:dFR%+k3DR:s8W)^b0fDEf>-5=JcC<$\c70~>
-o)Am`bFssSrV6BqptC`;%I4K?%hp-C8mQ7RKs0)+s8W)^Q8?5H>YX&NJcC<$\c70~>
-oD]!me>?o:lhCD`rq+[OhWjXqo`+Uap(-omq"aUUq=E"uo]5Yem/DS9JcE:\J,~>
-oD]!meYd,>lhCD`rq+[DZ+@a9_A'o,aNMlWf%T6KmIg(uccXqbaR&nWs+13\s*t~>
-oD]!mgr,DGlhCD_rq+ZT%1VS4'b:op,r7b[?>XPE\DZu+?7Vct]^5WKs+13\s*t~>
-oD]!f^6W?3nb2terp\+KipH=!o`+Uap($ilq"O+(guI)Go(DbUrdk*#s1JA^~>
-oD]!f^6`H5nb2terp\+:Zb4-;_@si+aNVuZf\>QHa2#=.eDfTZqu20HJcEC_J,~>
-oD]!fcFJk?nb2tcrp\*'%H\-7%h]a,2F:;PDg@Us1*L+oT;9Krrdk*#s1JA^~>
-oD]!]YCC#np\"OjrThAHk3qp%o_nFnp@?/4i8NJDeEQYKc-"5QrlP;YVY^&e!rCEmrQ58a`3ciI
-d/OCNp#k&U\;/o>h#@ZZp#k&V\rFr4iVs>cn`8KObf\)MdFe!gir92]puU2Tbl5cb^&\&$s*t~>
-oD]!]YCC#np\"OjrThA1\%]]>_A'o-aN2ZXdCHg.]=keag\&b7bKS30b6#MWqY1!kqUNslb6?&0
-`3ciId/OCNp#k&U\VT)@h#@ZZp#k&V]8k/7iVs>cn`8KObfe/NdFn'hir9DcpuU2Tbfe2P^V9T9
-s*t~>
-oD]!]aJt!3p\"OhrTh?P%H@p+%hp!3-mB]:J%7BArWNL]p"S9UgY;_]!n>*`p\t<kinaRe"PMAM
-b59Qc#laScjPJ7fjo4'8#laScjPS@lgAU"1%0#nbjk\\Fg=b?Co`!kM"oe>aj5&JhgAfS$qjmb;~>
-o`#-pfr/arg&(FA"oIDohWO@goFpf^hTE^[d+I+3\@B)hioYiBMk'a<!fM0fq#:d$hS6+`T:M*e
-C1Mkcdf0[Qg;:S9ZD;SVjSds8$N8Ym]Xb>FH>(\%jSoMbptsB7]<eK2rgs@hW2mGdrT4%`rTDG@
-ZDXGrT)saenX]]1~>
-o`#-pfr/asg&(FA"oIDmZ+.O/_@s_sYb@bpYJAE'\@B)hioYlDMk'a<!fM3gq#:d$hS?1aT:M*e
-C1Mnddf0[Qg;:V:ZD;SWjSds8$N8Ym]XkDGH>1b&jSoMbptsE9]<eK2rgs@hW3!MerT4%`rTDG@
-ZDXGrT)safnX]]1~>
-o`#-phSl(>g&(FA"T.;a%1V;,rs]MI#nAC@F#gb?\]3XkXJrM=rP&E>SaH4P%/o8;a1oC'[\K.H
-S+>#-$N9&:eC)RXUQ4F6hZ!r]j3uH'bep?>eGA8+#laY_hUg0!`PMPg"iA7"cKP5grs&Ggh:9`f
-_>_1NY+"mOs*t~>
-o`#-k`1LULi;W?J"o6r`jR)O$oH!MhhT2q%V6%_Zamms?io]goWKMCCDf9T7A7i^Wq>Uls_PM^#
-EG/W[H],6!df0[K[s3%5GACN#iVq^6$MV#aF)?#9>[lFajo6"lim#-6Ob7puCMe$3G'nq%P-t2M
-rseqc_lA`EF(f,p@pNR+qYpZso@s5Bs*t~>
-o`#-k`1U[Ni;W?J"o6r[[Cj?=_B$G(Yb-l2RA-dea2uK^io]goWfhOEDf9T7A7i^Wq>Uls_PM^#
-EG/W[H]5<"df0[K[s<.7GACN$iVq^6$MV&bFDc2;>[uLbjo6"lim#-6Ob7puCMe$3G'nq%PICAO
-rseqd_lA`EF(f,p@pNU,qYpZso@s5Bs*t~>
-o`#-kd(bp"i;W?J"8U`5%HJ$!%2'$U$Vu+1*4lc6i8Wnik-LYHT`1PdTU(S\rV?I%p=$pYT:h[3
-H]"0#n'_4CpW&ntT;8$8L>i-grsJMAUn"!NSr/*QqrRhkr9<%c`3ueET:MRGTqnTfZa\-TkPl"i
-kL[_[W1f]IQ'I8]k5,)[rq>LQW;hA~>
-o`#*d[?tH4iq!*Orq+U^kO]kem,#gfX.uc3c/-+Vg@4Y3s8V`JaII`jBOk^aA?5P&rseqYZA*4-
-An"tc][5[4df0XJgUa)+DIZpqkM?.FpYNZaKQL^.E9$r[rtYF__PW-/@pN2?>?b?@A7fLoF`b+j
-kl1kZ]qg0nA7#49!`N1[rVm*#m+]aaPkD!TJ,~>
-o`#*d[?tH5iq!*Qrq+UM_o(`U+2GLmT8\SmWkcK^ZHL,*n,E@eo\RZZIq35'An#;Pq>1+#rR\?0
-D.R<g>][R)iqLn$$2<2cTmU`f>^5GfrsJMW^Sup0@p<p4roX4qqq/c_LiHp1=B\p5>[_/TBQ/*:
-\,>Ii%J7B1J8/V$='/O*;cr&Xrs&Gggrugaor.n@~>
-o`#*daL[Uhiq!*Qrq+T=&eX=;rs]qU$49S'^m5IRb>Su4rr<#jhT2duQC+#+P`30KqYq$'hor9p
-R$j.jL:kmmpX9'JpY39ST:_@%Np#6u$MWDlWLorNKS\[fk5Q1nimu&PTTkChKS>2>Od;B(T;/.&
-r94.io[1OUS<f1eIXHKcG2iK##6"&QgW-\oW;hA~>
-o`#*_Y**4%ipm$Orp7u)p$;5no'G5SYcFP#`80S<da$mpg!]Zqs8DcYY`!(2BkCmdRIp@U%J7;r
-C2Rg"@9\fPp%n[9rsAYqkKfKE@U+lYh>[f[o]t&"L1=JFlK8*_qpN'DH"C;]<*!I??<^cDA7fIh
-AT[29lMhb#f;aXCARA><Dg6PQL$&F8rp%YE[[qAdm&9r7~>
-o`#*_Y**4&ipm$Orp7_N`p:Jb^q6hCN/3h#`80S%YKl1M]Wh22s8DcYY`!(3BkCmdRIp@U%J7;r
-C2Rg"@9eoRp%n[9rsAYqkKfNF@U+lYh>[f[o]t&#L1=JFlK8*_qpW-EH"C;]<**RB?X-rFA7fIh
-AT[29lMh1hf;aXCARA><DuP"jL?AO9rp%YE[[qAem&9r7~>
-o`#*__mY_]ipm$Orp619+6j@9%3>la$;[D7h<&&XcK!"r-M[W@rV>`pZBLK>R$E]4o_SRso[(%8
-R%0S,JXtfnqYnqC$2sJYcaTp<K:M;arsAYrld`SMP_,=gk5Q7phU/s3R#QQ;FaJO^I"dTHR$jJ2
-Rd9t<rsAY\`iu#$O*Z#%reLuJk5YJ\mb?C>^7Lk]W;hA~>
-o`#*ZUkW8cipcsMp"fB8mIV+`m,#gfX.uc7h=(70ftQD>j2T+,rVm5nY_6SBEG/onK^em=$iSSQ
-AoDX/BO>#Io$.1>roKu.@9o]!gA_B@WJ4hdV"!RI)#`C(R!*(K;HJLGZF-p8L1t./AnPUc]DUso
-)>M+?H=pbn?DG-N`Pp?ss8VuHXd"9O@X..9s*t~>
-o`#*ZV1rAeipcsMp"%[8mD9RQ]<IodLmP-[h=(70^o$&bj1r.lrVm5nZ%Q\DEG/onK^em=$iSSQ
-AoDX/BO>&Jo$.1>roKu.@:#c"gA_B@WeOqfV"!RI)#`C)R!*(K;HJLGZF-p8LM:70AnPUd]_q'p
-)>M+@H=pbn?DG-N`Pp?ss8VuHXd"9O@X74:s*t~>
-o`#*Z_lo/TipcsMorV=Eljj%)&ISpQ:SPe`n,)Q69AoU*Sm:^^rsJ57Xc8[=R[9,,nGE4nrS5>X
-Od;]1Ne"S/c2S%Jjhn-]K!+Xtrs%],YE=C=nE9fgrT2G=UmR0gG)iE)[BQToO-H$"R?WcQr9F;"
-ps6[OR?rbYV7X[b`ROGXs81Tm\#Gs[PNf%GJ,~>
-o`#*USpk'WipcsMo^2GHmdq7aj3"U,UTDDin,*+anBoYPs7bI*nbrIpl)/<.WHrAm@s759rsSJ2
-I:ACfH"^Ghc1oQ`#Q</JHsU*ip"TKOrR.Hg?!Y;?kPlCl^8$'h@ola#aP>qAk2+1GFD,9!@UY`"
-lMhao^RTFYA7Bc1lgXH7o_\[gps#U\B4YY(l)=W4~>
-o`#*UT710YipcsMo\e<Am_T^R[@rP8Q`A![n,*+anBoYPs7bI*nbrIpl)8B/WI&Gn@s@;:rsSJ2
-I:JIhH"^Ghc1oQ`#Q</JHsU-jp"TKOrR7Qi?!Y>@kPlCl^8$'h@ola$aP>qAk2+1HF_GB"@UYc#
-lMhao^moOZA7Bf2lgXH7o_\[gps#U\B4YY)l)=W4~>
-o`#*U^T!9KipcsMoS[$&m1'g>$OR5:U;YmVqu6WbdF%F_pYacqrVm5h`LVjeVOa*;PjJ;I$hVcD
-Ln(08RYu[Aps&gDrS#,eNe"q<g]%NWg;9eIJ&_3FrttFU_PirgJp*g.gudh_hT2LdS!f\/M6-I:
-ru(IQ]q_!^O-@uWnF?&@qu?]ke&%uMR$+!(W;hA~>
-o`#-TSpXpVgA^[C"T@]_p\""I$M!,kX.uc7h=(7?rr39#nF?DUrqQ0`rr3B*gRr(l_2W\Q@;"d$
-rs\kUW+'bVOa^kHB&<L2rs/AEVfl9Mg%sJ'#Pc0+F'E),qrn%trnXZ6D.[6aLXGVgrr<#sm`B`\
->$>!/P4JSO$NB_ai7ci8j6?C=rVn,AnE]E#]pj(TASZtFkNV-or9Wb8k/F0@AnGb*cfjZYk3)`H
-s*t~>
-o`#-TT6t$XgA^[C"T@N>dDbRk$Ga!9LmP-[h=(7?rr39#nF?DUrqQ0`rr3B*gS&.n_2`bR@;+j%
-rs\kUW+'eWP($tIBAWU3rs/AEVfl9Ng%sJ'#Pc0,F'E,-qrn%trnX]7D.[6bLXGVgrr<#sm`Bc]
->$>!/P4JSO$NB_ai7cl:j6?C=rVn,AnE]E#]ps.UASd(HkN_3pr9`h9k/F3AAnGb*cfjZZk3)`H
-s*t~>
-o`#-T^Sd0Lh#?mE"T?Pj8f@%,#n77L:SPe`n,*+`rs8Jjnb`@cq"=O`rsSh_^m'YkXJMAJMs($<%
-/o#$Nf(?RWL/KohYk_!#PlogUksTSqV2#Tps-RHLk+4Vkl2P"ilJBrR?NDkdI@&4s8W&caeauPL
-OslIo)8RqrqGmFjQ#7bn,!%^s!.O8nF5Vd]qLj]S#+d)n*KQAnaQ&6d_hlKR@9u)mdKW2mf'BhJ
-,~>
-p&>9rfUI1qAAA*6rr_uaq"=(I#jTO4W5RN\qu6*b%/\5;@X67aIVN;&b5VD?%K>h.I9iVgS:>$Q
-E97)srseu&j4W#8g[4q*f#-ePrVm?+nD;IBrVulhiRu`LrqQL&rp\gma3WGQSnqYIiVrfU$iTGD
-a6`g)o\S-WrVQU'rTr7if@K0ao\.C>rVlg-o=(-$>B&X%s8W)nimu]Zq>V-,le:"AlMgh`q8/\K
-BP(dkW9sT^rr`5OC0CL:32Q3Grq"sk`4`U`XfSb5[(FcZrr;`7_S!FWKl(F7COr.a[$dWS`50!q
-Y)I=3B52a`ZFI90PP;6[J,~>
-p&>9rfUI1qA\\37rri&Tfuh5$_?d`GLo&&Gn,*+Rrs\eJS76chQ@<RWB$1,Prsetr]7!t[aII`i
->B/d(r;R6*puL,ZfA#]jm+92@rr)j+rp\difDYaKo\nKRn,E+^%K>kSdE'\f^7T4HCZ59krsSel
-f>m7Wrq,'tir/cS!r_K>rmqA<rUegbg&:pM&+d8uBNoH9rr<#tpu9oVrV?I,rTi4kf'<87s7sR(
-H>$o$D5ck$r;Qltf5"Rg=?*/Js8MWGcG[H+YcY"3['dNop&>!cb/:m&VhJu"B5<*mZa?0pm)?fO
-]!%'3AnPk)S[,f5R[!QLs*t~>
-p&>9rgq9PJM9,Ydrri%ZC+^+e%L<LO$BrEan,*+Rrs\eS]T/*!ZDj@WMUDG&rsetsc_uAqb.Xg>
-KSegir;R6*q<I#!ioT_.nD`!err)j+rq#=.ir/oVp?CVroD\Ob%K>t_hUpZCcbH$,L#N%0rsSeq
-in3f#rq>O6lM^V[!r_WLro+.MrV#=)jSf)X&+dlSRtQUXrr<#tq<Hu!rV?I,rUAn.iU?dGs7t$U
-Vja$?QaH/Zr;QltfoULXFuZ\rs8M]Rh:U3%b/hWGc-=Vmp\t3eg"4[!`N>`"R@UCobg!f8m+Bn9
-dE/\dR@0SC^<FsK]X.@8s*t~>
-p&>9qe<bGiA\.^/rri;fq=jRMoEO?eX3pA4rpKdpp:Z]!N7jqXD.7%`qYpL'qp)$GD:$7nHsp9;
-li$i-rqG-bVh9;XWO9ORQuhZnrpJ^ob/:HB[J'1A`k&CNP0Nt&ruh:,e%:laFG6?XK4J52kPk5<
-g!RmUUOqY(gr[+(Ls#\qrsnq`b-[7VNMEen_5D=oqYpL+m]_pd>`%bGs8D-*^8cn'rVca4rqG*\
-UR%RPTs=LpoX0j'AnG[iJ'@WcrVlruke@"p3O[W8qqfH+UlpI\G'/(ZK85MVUXoD3Z^lo'H#IA.
-B52C3Jph<eeu=peJpMEMAnPdpG_(KqBRfHQs*t~>
-p&>9qeX1VkB"Rm1rri;ahU9C2_?RE4UXAN,rpKdpp:Z]!N7jqXD.7(aqYpL'qp)$GD:$7oHsp9;
-li$i-rqG-bVh9>YWO9RTQuq`orpJ^ob/:HB[J'1Aa1ALOPKj('ruh:,e@_)dFbQHYK4J53kPk5<
-g!RmVUP%_)grd1)M9Gksrsnqab-[7VNMEen_5D@qqYpL+m]i!e>`%bGs8D-*^T*"(rVca4rqG*\
-Um@[QU9XUqoX0j'AnG[iJ'@WcrVlruke@"p3O[W8qqfK,UlpI\G'/(ZK85MWUt5M4[%3#(H#IA.
-B52C3Jph<feuG!fJpMEMAnPdpG_(KqBRfHQs*t~>
-p&>9qft+#DNPkS`rri;GI7tRI%L*@LG1#aTrpKdpp<0q%SCt?PSs,,KqYpL'qq8lGL!\,[W02b$
-li$i-rqPR,`2olF`Qm#^\sr*crpo:3gXjTRanGAcg!Rs[\(^fXruh:0i6o0.Trl)DXHnR#kPk;D
-j58S@_Q2qsjkJ/#Yh8pRrsnqigWd+&Zbjr8e\n',qYpL+m_u]%Jskp(s8D<?eAeW;rVca,rqPO'
-_R[J$_9)TSoYn85rg<nYWS.(GrVlruke@"p3O[W8qrZY\_R?YIUnaccXKT%E_;Y@\aM+mZV4X3E
-R@BhGX/VG]f#G5%X/DV[R@0P9V5p_tQ^[?Fs*t~>
-p&>9qh3`IuAXiDbrr_rbq"=%H"QI&9o)A"U*:U4g@'&CoM/d$8Re?^\rp@4;=eXcaRs8=HV""B`
-,Q6oOY@q-TL6-A%LjW]Uk5P%GR[TP$I!M[1Y`jQ^I!fUSo_e_Fqq]5`?s\8GL2:U?@9ecXrRd?u
-QBI#DJ()9=P_4-kL%YKFp!UC%?<qlDE-@"k@q49irr3PoWJFtfV""E_i5)4IFCTpprr4)=jN*g$
-D1d%QHuQ7cnZ7LaAnG^mH'tnN`mNB$me,iCi[s?cpsm0RKlLX0=^#'8?=RSaG_1XmkFcNo?"%;V
-An>FX>?Y-1Gg1_G>$PKHralFG?X-c<=BBS.Y5a"~>
-p&>9qh3iP!AXrJcrri#Ufuh5#_?@3>b4>PuruCO6LL@4DZANX3A"3/ks8MDqFBYBr\XRhO?DR)i
-s!.L-bcb\bCPIpiI#*/[G38esTUVC9N-orM`j(_WH$k!QI.[@:1]-"IT3tuSP_O!hCLLJ,m/>S$
-PEqAeEe)WUY`sc`AqfpXrq4^MJR2W/QuR;)L1=cKqYpL+l)KPJ?)6uirSYPgMf`H\o`"k4rT)%i
-AT!0GEdVi/qsgbCDe<TpCjDGQ^W+[PkjJ-.rSfElo_?tPTnRJs?<LH:>[CoPD0UYebNGR5>[:cL
-AnGU`?<^T8=*`&@?s6fDAH$0H@p`JE>$+jJl)t&:~>
-p&>9qh7BGJO0/-Irri"VC+^+d%Km4Eb4>PuruCOJYD'@D^TaArN32dQs8MH3UO9'!ah4I3K!+VB
-s!.L1grc+;Js;grVm*+\O66H7^q@=jZ`'b5eB>>$V5L5[Sb2j[1]-:d^Q<o(S=,b7SW\Vqm/>nQ
-\%/rNTr-Gkb.+RLPbIdMrq>6rX,)+]TUDUZYEajsqYpL+l,KrjJZeMBrTDbLZ(mDOo`"k4rT`+M
-OGT3hTr=U#qshD(T:)+9SYj!@e(<I8mIKr7rSfj#o_@Cq_6'AqNJ3%>LlR^eSu&Kjg#oo6Mi<gc
-R@0G,NerOFIZr$VOGJgWQC+)-Q&gfYLP:29l)t&:~>
-p&>9ri0S\"A;0RGrri;fq=jRLoE4*fhYld?6gCXi@*J&VNH8W?MXg`Hqok^>C=;@PQZHJ=](Q+'
-rp%Lt?rMQ_`P77JBOP/&l2U+CMfW]JAS$."@r6'lA7f4[l2CX3qprKA=]_$-c+SaGB4,#@nb_+7
-M/R3CCN#8KEbJrj>'B93oZXOW<,AJK_jGIX@p<^+rVuosf;*h$?,H=6hQhEB?sHc`mJm4bi5(4Q
-EjE?WHZ!A@o('&0AS#IdBP_jEO-ucBZ*q3U`p!F%s81?YR<W=O<Duq-Am\kN&Rf6aDJsd;KO7ef
-@q'%^@p2q3<t'#lAm/8?A79%]AR/=6<rm7(Y5a"~>
-p&>9ri0\b#A;9XHrri;`hU0=0_?70AhYld?6gCXi@*J&VNcS`AMt-iIqok^>CXVIQQucS?](Q+'
-rp%Lt?rVZa`P77JBOP/&l2U+CN,rfKAS$."A8Z6nA7f4\l2CX3qprKA=]_$-c+SdHB4,&Anb_+7
-MK!BECN,AMEbJrj>'K?4oZaUX<,AJK_jPRZ@p<a,rVuosf;3n%?GcF7hm.NC?sHfbmJm4bi5(4R
-F0`HXHu<JBo(')2AS#IdBP_jEO-ucBZ*q3U`p!F%s81BZR<W=O<Dut/B4,%P&Rf6aDJsg<Kj\"j
-@q'%^@p2q3=:B/nB3SJCART.^AR/=6=93C*Y5a"~>
-p&>9ri4>bPOe;19rri;8HV,1C%Kd.DhYld?6gDU_K$Nf-Z_<_HU%/0_qq&W>K$ro&\tP+6_"Ia-
-rpACTOEHPj`P8(;RZ`8jl2U+TT9u1=Q^+/*LkgkKQ'm\hl2CX$qr-#2L3B3*c+Td@R?3$'nb_4I
-SX,h7S=?^MQBIJoJro?up"[`^H\&04_kiuoQ%k"NrVuosh8?4OJB%<]jijTgOG\IOmJm4bkLHeg
-KsJ@mVk0*@o('PkR$a;0R[p7U[(F2obKeJ^fC&Y<ruh3rdCZ6COFVLsH[U3kM34-nStDk)UOdT>
-N0K]tQ%s\aFps/NMgBPoMisHqQ]-:hFodB_Y5a"~>
-o`#-UP]^SJEpNAts7??ep$D;Pj2'a@s$ZkAU1IrnpXt[MAn6;Vs8MDpDHa4-l`?4a>@#qYs8MT-
-Uh!JR`T-LO]o6r=>bplho%(RBIqiCm<HOn>XaY%t?!u^ls"s]2]Tc]&S^Zrtj/n,S?<t/8rU&.L
-P(%.V@TRN?IUlARM<ju\Z$BA\]%ZT=bE7$Y?%_A?s!RZ_T6+:JgA'O+AS-3k;,aC]s8ColO^)V7
-i9Sg_H!=\@pX=Lu@:]@L6"akGDfpAVKo(nYS%ALrl+*7-B44b;GbVLOYFBWC@qB:fBnaC,WMYDh
-BP(^[H)@R?YKGP5WMueYFD>Du?YQ>8W<09Gn#l\@~>
-o`#-UP]^SJF6iJu"SCd-ai!M_!jnlbli0BPgnSFnhY5]cF(Ss2mJm1Q[r,BQl0GF5CKk,uqZ$Qc
-`2$pDIDt7:kIupq?sTSts74aUQ[`aY<`X@9ZE8UlAmJj*rr4hRhS#.Z=.Rh,o]**2D-gP[p&4:.
-^6="\A7AY\T7:BM:l=T7bcuFoA\-U`m)tQ:@U4WMrr4AB`h.?WA_Qq9XCZ!i>#A4rn,N@F^l_l9
-^>S>*T6XXLl1`YT@:<^GAjL'CC2\6@J;&iAR%1bbropt^G\:Ga;L,"B[BH'B@Uit^C2&C<YGnCS
-E+iim??rEIWNXIt^T"31P'(MOA7')Iri#t&b3uM5J,~>
-o`#-U[\T=SPO%l@"S@FZ.M;%X!Y#=mli0BPhnbV3hY5^3U6q+2mJm1Rc(B?gl0H9rSV_jLqZ$Qd
-f>Eo"N5aiIkJ4BrO+FJ's74aUW2c>LJ9QgEZE9[fR#H[Xrr4hRjO:SrG,*OQo]*EbSrJ99p&4:.
-^8S$$QAg6HTotC_ELH.gg<6=BICe/#m)uW0PD,:crr4DCdD)H4L"c=`a-)"2J9>q:n,N@Le[C3_
-^>S>*];CF;l1`YtO-,crrg?$?S=cRSWi`M5]"H>crp.qDV4!KrEJUEr[BH3^Ng,p!S!g%fYGnCg
-T:;74KnuV*WNXIt^T"31S>)L@QAU6hri#t&b3uM5J,~>
-o`#0XQ?d.RC=`CXrr`5dq=a^X#P.6Ah:prSnbMeYji6<Gs*X^eS76L"rSWl_B4,B:s81'6??Olp
-kbj/H>\i<ts8'mAH<=RmlhpeYbaWf_?,?77r:T0RP&"9(NPF*,fq*h.>@QXms8MN%Tk.;IdI[A;
-oXpN1>@#qYrqlBKViGOu<-5k$Z=$^Xbja>pN*KGaiVEKOiLka1>F"XUs"!`PRr)P[i7t\PD5jp_
-B:%6Erp[^p@9KJfqu,0MEE[;BrTCV-?<UZD@qGOL3bN,AF*`26p!9XhC1LLJLVhd-kiC=+Iq`J+
-BObeoj5S[aL2U[5?]*IpioKLtl/L^YZ\rm:A7'B*ro+"?mJ=!cJ,~>
-o`#0XQ?d.RC=`CXrri;^h9a+<_?[lg['-X=]"n-Y!k,,gli2A0bFN*_jo+,%G%Y2rl2UY*TO2lo
-punZ2AR'$0rr;i<YBj;Z_s@7#q95@Q?=(MBs8;QOY**R)=H1)Ijk68YAm8d*s8W)f^7f+?Fj]g[
-s7EsjEEcc&qYpBbj/@uR>uc!\d'@(]H-Gd3[u=QoWo<dQrSaH$@9f)crr4M@\XRGDI,NeeB5X`W
-EbLilp\sZtSmbg"j88f-YAm`bjo+ANE*c^S@:NmGAiaR<CNFfKX7af>JSJ_!<JSHFk31mW\pnF*
-AnY[i_W0Y-Tn[Jt@UG#Eio9%do',/nh6`,^An57idf/5-jR)fHs*t~>
-o`#0XZDF%TOkTg.rri;6GXNAF%fQn=$k3[@%K[(Cip6Vlqp`<?MWOfp[%s+OMs:9=fYE<!fD+RK
-YEt#uiVrlRfZL+DHc,1Is7t*VUlBoEpAb'`jhS?rLj56#fB(\kXI4lrj8]/Yo$Y@AI>H;Brr;W3
-\Y+e/g%t^Fp#EcnSVqcK^<j<AFc+E4iQnfeGcp$$rr(fjX-/%/mf*5;oZ=b;N0iJ`c'<p^[>9=)
-fD#:7e\@5mXQ03Vh8u@BLZSKt\W)?!NKKHlR/<:3R[p1NVo/2[a/b\qLj#!!g?.V[f".<;R$jD.
-P0)bDf<h]QR?NDqfAbfNmIKN$in_;RTp_4(MphUa!p&bFY5a"~>
-o`#0\SpbBcC8q('s8V]lq"=XY%.`iKfuLG"XLZ^>n+6GK"6[b[rp9Y=p:Z`"MX1<)Q?m4QA^gVB
-[r,BTm/>M0IUZQ1kl:YD[?G'&OQ-0;s7sX)F';l'qu6UAn$/*h>B%aLq>TigP@e$<jo>AXd]\:.
-=gIAms8V`'Rr2JHiVriV+7#tfA63'HjRh6#W5n/m\tE_>E7O^_s8LoOJ6uQaoD\bEn#qskCQ?fU
-NHDegi5i[anbr@/Y'aSseG&t.`0FV+L["j6hQqZ;=^"s4>$P?@@V#IM->.(*HI]WtFCnucBufQ:
-rr;umj0s>IAnPXcTDANWY`Ed9@UPDiq>U`q`g(a[A70WGW;hA~>
-o`#0\T7(KdC9%.(rr_oSfZF-0%)KWdXe(W3Q'8&Q^;9]`"1Y&Urp9Y=p:Z`"MX1<)Q[3=RB%-_C
-\8GNVm/>M1IUZT3kl:YD[?G'&OQ-0;s7sX)F';o(qu6UAn$/*h>B%aLq>TigP@e$=jo>AXe$"C/
-=gIAms8V`'Rr2JHiVriV+7#tfA63*IjRh6$W5n/m\tE_>E7O^_s8LoPJ6uQaoD\bEn$&$lCQHlV
-NHMkhi5i[anbr@0Y'aSteG&t.`0FV+M!=s7hQqZ<=^"s4>$P?@@V#IM->.(*He#`uFCnucC<,Z;
-rr;umj0sAJAnPXcT_\WXY`Ed9@UPDiq>U`q`g1g\A70ZHW;hA~>
-o`#0\[&KU_Q+HhcrrhtK@jhld%L<LP$OR1D$4IC>%Kd.J\,Pao0_W]"MONl2k-LqSP)Iuklcu,M
-[d<tJ_5WZQP3DrFkg$Z$I@K6ns8VoA^7pF4gACmL-1Aj`R"U19l1t>I_7,hcM<4d;qqK5oML)_s
-rr<#jah44$L#N%1ru^RG[$H5f\`ED<WN+#'n^"t>JVDYKs8W)W_Q&ZH[e'Lu1@N2lSX6>,e$G.J
-h;HAhf(&_9fZC(LMq%M#maeq,FI27lptiE>I=$HqL51YFO->otrg>(&RAS]_]q_!ZJq:u.qu6Wp
-puAo]R@'D.NjAK\n\MT+R?WN'nbN1jps-FGR?ieol)=W4~>
-o`#0bY^gP%AUF"BrtYM!q=aIQn`o#X]W8'.Uo1&mdH'cfr:C*SaOC%Qs!@0?Lg[%Js6HG3Cgq%n
-ouW_1FkQTeb+Eug>E%qKqSoF\>[52<rr35r]:3S@DrUcqru1.$M.9eIk5G>[n#qsd>`%bGs7Edj
-C0PN+q>UBun?A-h>^,B1ruh="Vh8A[No'X3o&/HpqV830@9]8err<#sd%GYh?IeiMs$GtLMJI3l
-WL\$Lh"gg9me6VZn[4^#D4p%Yf"HrE;.[o@s8McQa0:YNB4=qD<`r[6@:a%_B4Z"YTnR;p@9eiS
-rVZ[/q:UdLB4b[`MXpf;Y`Ed9@UPDiq>U`q`g(a[A70WGW;hA~>
-o`#0bY^pV&AUO(CrtYLoh9a*W^Ug\GQ&(ZkTr4WYVR=.Sr5&QGT?[9"s!@0?Lgd+Ks6HG3Cgq(o
-ouWb3G1l]fb+O&h>E/"LqT#L]>[52<rr35r]:3S@E8plrru1.%M.9eIk5G>[n$&$e>`%bGs7Egk
-C0PQ,q>UBun?A-h>^5H2ruh="W.SJ\O5Ba4o&/HpqV861@9f>frr<#sd%P_i?e+rNs$GtLMJI3l
-WL\$Lh"gg9me6VZn[=d$D4p%Yf"HrE;.[o@s8McQa0:\OB4G%F='8d7@:a%_B4Z"YTnR;p@9noT
-rVZ[/q:UdLB4b[aMt6o<Y`Ed9@UPDiq>U`q`g1g\A70ZHW;hA~>
-o`#0b]W7TkQC[U@rtG@EGXN>X%LijU$ORA5O/J%.$k<%C!t>X6qs=>/nA_\eY42JW[]>s`O3@4I
-]n_Htq>/RTVNHG#m/Qq2`2AK?`Uj*/#PH6PSV;mZrr2p9l,KrlJskd"s8VQ,\<_`7lMpnVbe9O"
-K\-&!rs%u3\=&&2kPkK(ro:quO+!JRqYp'Di:$O$aKUeVVX"0\s8CQbV2BfRq#::Ll,9itTWQ2I
-TTe1,qXEqHrVuE4\t5=nk4.H[Z&!FLb4>T3pZ';uR#$3<G'/"VK8PhYrg=.\T"De@SXGUlSE9_I
-rtG4]XJ2,NQB%[0s7*q4Tp_.$V"+9\#l)]UUm[O-Om/hEJ,~>
-o`#3jbCF>>ASnsUq#CBd'DV7gjOV8SX/2Yr_q3baZ*MsCnGMn\kK)$Fm/JBsWH)@^pAaWdLi?m?
-V;AUk=gIDnot?l=?X0]'s7*C\C0YK.qu6U"n?A-g>_D;?rs/PTUjlcWV"+Ha&F-<R@9]Mrs8M,[
-M.9eHkl1S]#4&4H@pFuZrr3`3dA)"m>f6.3s8DinrqXF(H<spup&=t,pq`M@>@ugls8W)RV1E2e
-Dfg)5C;'TDs!%ElW.SVlHC1@VA6;lY^#f.ks8Mocj4)&ZZE0a]K6:j;@fBsHA8HgPF(f/o@'0"s
-rtGCrV1reuA70`Ns7*=SEFrZfPO\JK#l)E)G@kAnGNl(+J,~>
-o`#3jbCOD?AT#$Vq#;*$jOhPe[Ao^TLm4C4_q3baZ)=V2^\kqN\=^n<m/JBsWH)@_pAaWdLi?m@
-V;AUk=gIDnot?l=?X9c(s7*F]C0YN/qu6U"n?A-g>_MA@rs/PTV12lYV"+Ha&F-?S@9fVts8M,\
-M.9eHkl1S]#4&7I@pFuZrr3`3dA2(n>f6.3s8DinrqXF(H<st!p&=t,pq`PA>A)mms8W)RVL`;f
-Dfg)5CVKcFs!%EmWIn_mHC:IYAQW#[^#f.ks8Mocj4)&ZZE0a]KQV!=@fBsHA8HjQF(f/o@BK+t
-rtGCrV1reuA70cOs7*=SEFrZfPO\JK#l)E*G@kAnGj21,J,~>
-o`#3jcDmA%R$u+pq#;'#L1;M>%1EUO$8Q4s_q3bg[V$!Xq[N];$_d@^s!?sKU4UDYs7!b+T9bhU
-iQdg:[d="dbIs^4J@+nIn]AA4LP4I[rr32l`OM7fQ0J;J#QEPsWfVe7nc&P"lGg)kJ?JDAro_;*
-P_,:drr2p%lbg&oK:M<-rtYLb_PW3<`Ua$.rVQQmq9ZpSNI].Drr3c/cG#s,KAc_.s8LonX-f*A
-U8+-@b5M8<0`BeGXI#0H]>1J/H?G(Xjno)Xrql6GeA]#)XJ;/DLPLnSR$jA-RA@$\R[K:l[IX4p
-'E77+Y+:uHN0N`0n\MT+R?WN'nbN1jps-FGR?ieol)=W4~>
-o`#6qhi2JbBP;n\rqcX2rTs@QiQJ^2WMHN)cJe6bqt/mh\(g-:rU^3Ub0]qNs!Ia#U1@`equ?<%
-MfWKKPI?KVHeJ5pn?A-r?!bbLs66G:A6jWHrr2p%l`,nQ?(CB_ru1aRT6O[J_=mp/rn!uq?!YVI
-s8C?>I:6K`nbrIlk,*c>?)7#irs/;5So@qLh#%!K#P"s\DHgE%r;Q^#o!Oiu>B]0.rs\eJTm:$G
-@q]FcB8?0Xs"O5]RWMk;>[1HHEJ1:2jQkXVf\"]ol1a`6kMtCKbe^K:DeN`p@V0q-C1_'eA@D7/
-rt=e+P]:;G?Ztc8nZ\'oAn#/3nbN1jpr8SCAn5:nl)=W4~>
-o`#6qhi;SdBP;n\rqcX2rT2eVZ_ES<PaA5XcJe6bqt/mhXKK+KrPAZITum)ss!Ia#UL[lgqu?<&
-N,rTLPdc]YI+e>qn?A-r?!khMs66J;A6s`Jrr2p%l`,nQ?(CB_ru1aRT6O[K_Y4$0rn+)s?!b\J
-s8C?>I:6NanbrIlk,3i??DR,jrs/;5So@qMh#%!K#P"s\DHgH&r;Q^#o!Oiu>Bf6/rs\eJU3U-H
-@qfLdB8?0Xs"O5]RWMk;?!UZLEJ1:2jQkXVg"Fosl1a`6kMtCKbe^K;DeN`p@V0q-C1_'eA[_@0
-rt=e,P]:;G?[(i9nZ\'oAn#/3nbN1jpr8VDAn5:ol)=W4~>
-o`#6qhl337R[Kr<rqcX1rOd/&%1ERN(Jp@-cJe6cqt/mhBabIK%Kd.JT_RpS-N;o=Q%@Zds7F@;
-TpVIXag?_[g%k[;`jhY!JBmohl,BilL6Ca!rr32g_m>PYW:0`c)Z%jrV2^#FpAb0lh8?4MJ'@Ze
-rRercObC(2rVm)a`3#/RY4;Mk#PZKWT883VqtpBun\qu/Lk"4Xrr32na1@^nNTU6?%/\PiV2p+[
-Ng,rtV=jcd0_il(UQ'_NI<pEsOK-@^n)i]kj5ASXp[RS4j5&80_69B$S!f\.OI;f4R@07s^A%L(
-'(<]HTp_1&OmE&;_6fo(P_c.*q>U`qcFKa=Q].'kW;hA~>
-o`#6sm&bA@AnZ4XqYL4/o^_[uY,e@pZGkP^oAlm+n,)qIb.c]qnc&._lHdfNmJeL0bFE$\j8T)R
-d>r?]DM3^N?+fV)s6HVBB3Sj$rVkNCIUccGm/I"iro']*?X'c,rr3o/\XRSB?/#2Us8'd/F'N>5
-r;ZQ,R<N(I[.aM!#Q<)DHsU*ip&=srn["Qp>^,?0qu6oeV28knEo[/urs%npP@RmUli-nnp:Zu8
->$@)HDJ!EsdJj+E(\4npDI@4VWi`_GcJS-cftXqsXe:!`qu6U*rr)WambP(/EFrcg@#Aq&AclRU
-U\FWb'(</mEFrZbHKtP#Y`Ed9@UPDiq>U`q`g(a[AR]oKW;hA~>
-o`#6sm&bDAAnZ7YqYL4/o\[]`MhmXjZGkP^oAlp-n,)qIb-/"Z^])(P\u!F@mJeL0bFN*]j8T)R
-d?&E^DM3aO?+fV)s6HYCB3Sm%rVkNDIUccHm/I"iro'`+?X0i-rr3o/\sm\C?J>;Vs8'd/F'N>5
-r;ZQ,R<N(J[.aM!#Q<)EHsU-jp&=srn[+Wq>^5E1qu6oeVMStoF6!9!rs%npP@RmUli-nnp:Zu8
->$@)HDJ!EtdJj+E(\4qqDI@7WWi`_GcJS-cftXqsXe:$aqu6U*rr)WambP+1EFrcg@#Aq&AclRV
-U\FWb'(</mEFrZbHKtP#Y`Ed9@UPDiq>U`q`g1g\AR]rLW;hA~>
-o`#6sm'rdWR@Bk\qYL4.oOf9T$48nBZGkP^oBO;snb`.Kb#AfZr=/o=%$LAPs!@Ql]oS!0rr;cB
-[%`t\XKIS0^@)"#lbg&sLk4C\rnbDhP_bsurr36&j27pYJ%5.Mru1OP]V((0gACpMqU30RLP"@[
-s7jjNUlgAEpAY'srRnubNe"q<rr35na1@[mNop?<rs.l(Z'pW1j8T&X#4BF=Q%>Fjrr3H$bIsO&
-H'jtfR?j2mrr)j5o#.u.N.\"-XgZ'khsgC!eBZ.V^S]QYrr3`4rV6$Qh7C%fR@&tgR[ok6R?iuB
-p\On&n&Mu4R?N>dlMpCj[%WnPLnsS:rs8DF\YPX[Ng&_+s*t~>
-oD]-ke:VIHBQ8U'qu$I:rTWITVkg?,e)^&okeDar]C5b!rThG=gZ\2"o^'uIp$Mc*p:Z`#M<b-@
-rS<QWAnZ$h=G#B*s8V5ZK4J5,jSo&"Q[*(NPOSSO#Q<&EH<ab,q>UC4n$&$i?#\g&s8V`&S8)8O
-jo5;PZ]K6:A%;=5rs/A=T64CFg%t^J#4&=M@pFuZqYpcaU5*JnGNf#*#3i+C@9ou)rr3GsYa/m*
-FiV=FB4bkDq#14/nZ\'nA9QD\jQZ+*qu6<(TS@c=F)SS`q>Ufm^R]IY@olp:Ir>6t!b[5Xqu7?/
-k-U(`Amef#m/QU[O)\c@@$C-Vrs8D=Q$-bOA9[::s*t~>
-oD]-ke:_OIBQA^*qu$I:rSk;MPaSMbe)^&okeMjt]C5b!rThG+Y.;<a_Rl\Wp$Mc*p:Z`#MX(6A
-rS<TXAnZ$h=G#B*s8V5[K4J5,jSo&"R!E1OPjn\P#Q<&FH<ae-q>UC4n$/*j?#em's8V`&S8)8P
-jo5;PZ]K6:A%;=5rs/A>T64CGg%t^J#4&=M@pFuZqYpcaUPESoGj,,+#3i+C@:$&*rr3GsZ'K!,
-G/qFHB4bnEq#14/nZ\'nA9QD\jQZ+*qu6<(TS@c=F)\Yaq>Ufm^R]IY@ols;J8Y?u!b[8Yqu7?/
-k-^.aAmef$m/QU[O)\c@@$C-Vrs8D>Q$-bOA9d@;s*t~>
-oD]-ke>&FuR\?e"qu$I3rNm"@+BkGPe)^&omF&)'_XIL(rThEe$k<1G!t>ZQp$Mc*p<0t'Rd0qQ
-rS=fSR@Bb/I$*7]s8V6#Xd+TsjSo&*\tt[NV==Ka#Q<;kVM]lSq>UC4n&Dl+LPb$is8V`6]pj_8
-jo5;P`3c8%M88ocrs/AH^S?[:g%t^J#4'78Q%PUnqYpca]W[fdP3DlE#3j.3P(C"1rr3Gs`jqIi
-M9!H.R@0DFq#14/n\DN(Oc\#NjQZ+*qu6<6^TXQ5Tps$rq>Ufmcb?0BP_4CfTUu.N!g]SOqu7?/
-kKU<'R?2ogm/QUl[%WnPLnsS:rs8DF\>5O[PEtI3s*t~>
-oD]3skbrH1ASZOGVsOE^ruh3s_Psrbh<an5ikpgsNPF3?rr<#qkeY$ekje<3d)>MBs!@0?M.*4L
-s8W)ZQ?m4V@TQdJnG`Idd\;/!>_MAAq9"eAAS-kirr35u`hIN\CuG9krs%_dLh'b>l2L\om]Vgb
->`7qJs73CMEFWXdp\t1)oYR8@?>SU"s8W)WVh8D`V"+<]#3hh8Cgq>Hrr36&goH!5?c2X;rsn@p
-N+6(Lk2;MDBOu/=rr2p%nZ@^h@Vk9*rri>h\rUh0Acl_$li-e]')U1eNc&E6<-H<EEFrfrAoc)n
-r;RH,bc6,*A6N-Ao)J6aO)\c@@$C-VrsAJ=OEG/JA9?`.WW.J~>
-oD]3skbrK2ASZOHW9jN_ruh3o[%t+Oh<an5il$q!Nka<@rr<#qkeXC'\\H"nVRQ-`s!@0?M.3:M
-s8W)ZQ[3=W@TQdJnG`Idd\D5">_VGBq9"hBAS6tkrr35u`hRT]D;bBlrs%_dLh'e@l2L\om]Vgb
->`A"Ks73CNEFW[fp\t1)oYR8@?>\[#s8W)WW.SMbV"+<]#3hk9CgqAIrr36&goQ'6?c2X;rsn@p
-N+6(Lk2;MDBOu2>rr2p%nZIdi@Vt?+rri>h\rUh0Acl_$li-e]')U4fNc&E6<HlKGEFrfrAol/o
-r;RH,c)Z;,A6N0Bo)J6aO)\c@@$C-VrsAJ=O`b8KA9Hf/WW.J~>
-oD]3skd-eER%:(W_XRR(ruh3V>_of0h<an5l.*2,SA3eNrr<#qkeTIl%1WjW$tf(ts!@0SZ%oLO
-s8W)ZZDO(YP_"%onG`IdftjYOKU:s'q9cUFR$496rr35udD;Q7LuA72rs%`,Ya'p*l2L\om`)`%
-Jt20,s73t0TTtVPp\t1)oZk7FMMU6js8W)Y`3#2SY4;Ag#3i_%SWf6#rr36&hoMjZK#m]crsnA4
-Z]p$0k2<83R[9K&rr2p%n\;?&PEP/,rri>ja0_K<R0/nXmf*+`')US3Z_!MAH&BY@TUD4:R%Dn-
-r;RH,fZ0t[Q\^!uo)J6r[%WnPLnsS:rsAJF[A0.XQ_!.8WW.J~>
-o)Bg*dtqgLAnlF@S]^I$s82'2fB2Z"kL6u'D0r;*jnJcQrsJYc_8"[ena+Z@na6>[lE,>?]Cl1'
--L%4TCLpdPK&6D)s7jL(H!t'Mn,N:<N,WB>GO5A0rpIXpE+4(Trr36&gSB=->`J.Mru1+#LLXkt
-nc/X]]7k-6BpJ>js8M,mP\afRkPkJdrR%Bf?<t/8qYqf)RXT$_DT;YTs8(!>H=1:<qu?]qiMM68
->cdMc]Qe%$C6\Mmrs/(sK5P7<\,H:*55jQB]74L*AnZ")S^HX!rqc!<cF9']AR88;ZerB<A7]Cg
-DMZI5s8W)mf!pl_ARAAEfD5I:Y`Ed9@UPDiq>Us#c&-IPB4u1McIg^bb5JLCJ,~>
-o)Bg*du%mMAnlFAT$$R%s82'2fB2Z"kL@&)DLAJ,jnJcQrsJYc_6'iM^UpANna6>[lE,>@]Cl1'
--L%7UCLpdPK&6D)s7jL(H!t'Nn,N:<NGrK?GjPJ1rpIXpE+4(Trr36&gSB=->`S4Nru1+#LLXkt
-nc/X]]7k-6C6nMls8M,mP\afRkPkJdrR%Eg?=(59qYqf)Rso-`DT;YTs8(!>H=1==qu?]qiMV<9
-?**Vd]Qn+%C6\Mmrs/(sK5P7<\,H:*55jQB]7=R+AnZ")T$lg#rqc!<cFB-^AR88;ZerB=A7]Cg
-DMZI5s8W)mf!pl_ARAAFfD5I:Y`Ed9@UPDiq>Us#c&6OQB4u1NcIgacbPeUDJ,~>
-o)Bg*e"E%mR%0kP^=i/Xs82'2fB2Z"mGQ<uP`W&jjnJcQrsJYc_*8>;%LihXna6>[lGocU_=dg-
--L%t?SX5:\Ol$!8s7jpTV36P3n,N:<Z_*YOSF$:Urp\=LT9#/urr36&hSQ:UJtDB/ru1+@YEb!S
-nc/X]`NGf"R'-)]s8M92\=J\DkPkJdrReucNe"q<qYqf)[],gaR*bg3s8(?dViZ_hqu?]qj2A$\
-J@+n:_5*KeR^)Yers/)/XIbfI`r5l955jcd_Q'&lR@9\C^#&/Trql3IgsER+R#ZK:\)4upQC+)0
-T<HoFs8W)niR#$+R#ZK?fD5I:_6fo(P_c.*q>Us#d^#L4R@BhYgZ%2BgAS2SJ,~>
-o)Ba/m(IUQ@qB=nJ![1Jce7C<f@J6]Vg;umQbhDFr;-F"qrY`0g$%bO`:<9q#6*J_F)'D)rr4>5
-W.f+u<a*6,rr<#i^n5aYBXIF3ro&]MAnPt[p&*jhVh8bsIHgb2-2YoZH='sZo)Jagd@G\sD6rp8
-s7k,rBP(q$_Ya,_]:+%ZAprqCrs/;6Soe1Bg%tRFEU03?BP2(>lM^"mYDdF1DqY-is8CB@HsL(&
-p\NU&D.[I&_>XE6oYc)fAncbIrVui^c'`OhJ7iA'B4u::SZ]T?_S<LQLiHp0:fES5o@f+9@:a(g
-H'PYSbKe,8P]gVF;H'1Mrr;MmO)\c@@$C-Vrsnq]JnS_-BPrBkWhXj:p9+FG~>
-o)Ba/m(IXR@qB=nJ![4Ld+[R>f[e?_W-W)oR).MGr;-F"qrY_sXgu'C\+/nd#6*J`F)0J*rr4>5
-W.f+u<a*6,rr<#i^n5aYBXIF3ro&`NAnQ"\p&*jiVh8bsId-k3-2YoZH='sZo)Jagd@PbtDR9$9
-s7k,sBP(q%_Ya,_]UF.[Aq'"Drs/;6Soe1Cg%tRFEU06@BP2(?lM^"mYDdF1E7t6js8CBAHsL+'
-p\NU&DJ!R'_YsN7oYl2hAnceKrVui^cC/akJS/J(B4u::T!,fC_nWURLiHp0:fES5o@f.:@:a(g
-H'Y_Tbg4;:P]gVF;H'1Mrr;MmO)\c@@$C-Vrsnq]K4nh.BPrBkWhXj:p9+FG~>
-o)Ba/m(f'QPaIr5Wk-3th;mk`iSiSA`MSQHT>B7Nr;-F"qrY^Z$k3XSAb#3g#6*T(U6+()rr4>5
-]<.ZgJ9Sfurr<#ic+g$<OM1;dro'oKR$jP^p\a=.`N>\rT'?7S-2Z3-VN6;8o)JagfY4>OR)&Cp
-s7k-ER[BS?dJNb#d_)KIQ(I7>rs/;D^8$O7g%tRFEU0s,R[KYMmeuV/ag.P'QJDK>s8CWfVi6/O
-p\NUASXGq?dJa+FoZ="uR%()6rVuicgq/okT9bb0R@BkN^<+gRf@8*^Yb78=GB9;0o@fq'P*_T.
-VRXe#gYLQ.\"oCPHul1Jrr;N)[%WnPLnsS:rsnq]W0s!?R\$Rn`knUap9+FG~>
-nc'R)iM^Kt?t<kbFFfLGWNrn2QuunCBp6-WlhUPTrs8Ma_8"[bf>[7Ks(;9#lH6&KFN!>@s8VZ#
-MJQNsK&6D(o^(GHP&OuPU>PtMl(Ds(AT*="XcddEAS,Ll[+3%=oXpK)>?o)?s8Vr8NH&QBIE]p?
-q;R?H@V9bCWMY2mBP(geDm\'3d-e,uA6Na,rqcY7o"B-RA8?UbXdaBWB4YXiRa]EmoY-W)=^g.b
-rp-Y+@qKV2^>dMmfnj<LAp9TQaMOii?&[14CgCFYAS>n&J;9&@Km[`H>uXU'PgK""m_s9V?".A\
-G(l6RSs"Y@@Tu]-MUV7us7*1@@piSIP4AAJ%fYUXB3\hR@qB=iA7:epY5a"~>
-nc'R)iM^Kt?t<kbFFfLGWj9"4R<E(FC6Q6XlhUPTrs8Ma_6'iJX0hBcs(;9#lH6)LFN!>@s8VZ$
-MelWtK&6D(o^(JIP&OuPU>PtMl(Ds(AT*@$Y**pHAS,Ll[+<.@oXpK)>?o)?s8Vr8NH&QBIEg!A
-q;RBJ@V9bDWMb8oBkCpfDm\*5d-e0!A6Nd-rqcY7o"B0SA8?UcY+0QZB4YXiS(#QpoY-W)=^p4c
-rp-\,@qKV2^>dMmfnsENAp9WRaMXrk?B!:5CgCFYAS>n&J;9&@Km[`H>uXX(Q-f+#m_s<W?".A\
-G(l6RSs"Y@@Tu]-MUV7us7*1@@piSIP4AAJ%fYUXBO"qS@qB=iA7:epY5a"~>
-nc'R)iNJ<#OHu<*UT:f<`lu]J];(@6JXa7"lhUPTrs8Ma_*8>;$r-6\s(;9'maoFRT$Qg's8VZ-
-Z(6brOl$!7p@74k\"B%Y\E<ejl*-V?R%LS"agRq4QC+&1a5PS)oZOe8LjmD=s8VrAZ_<bSVqKhH
-q;S9;PF8/P`l+mNQ'[l*S]B^>h<r7hQ\C.PrqcX&o#%)_QCY"hah=C>rg7/a\DQ#goZXk7Kn/"X
-rp.%bQ'n5Fd-9EIfqXaoRAILAf[[p/JXOolOc#3bR$sS@Wir\4Y,IqVMgf_kSC$j*m_tEKN0BX"
-Uoq8B^:()5P_j[*Q.,F+s7*h'Q&poVU[e0[%fYUjOc,9aQ'[r1Q&;L1Y5a"~>
-nc'L+p",mS?!CTA?t!MS@pr\J=&s:,]$fg9rUp0qqrY`/eBP_pnc)Gai3TGCAR/\cG-UrEpW.Sa
-:gh?5rqO73TQadJ>$Z,lPPXprG@4QW>$G08OFL_B=^#BOBs$TcB3S;>h#%-Oq9*kc=]o$FBP6f&
-^2mU`r`Tq;CS5cU=]np>C2'g1M.KgeFQ`K"55O#m@p3&?>$>'WQ=jB(=^c&ZNT?L@>>]7urr;`B
-JRDVb>\S1mVWGI1?<^]DBP:jZBq*B3fqN.d>?bE@rEq6b?!C?/;-%Y9dd[58qr>,4?<^T=?X[DR
-@UNJD<)HhTbjYN1s7)^m>$"^$O7E#F"nKol?WgM1=Thf*;NL@Ns*t~>
-nc'L+p",pU?!CTA?t!MS@pr\J=''C.]$fg9rUp0qqrY_rWM?N]nc)GaiO#VEAR/\dGI%,GpW7\c
-:gqE6rqO:5TQadJ>$Z,mPPXprG[OZX>$G08OFLbC=^#BOBs$TcB3S;?h#%-Oq9*nd=]o$FBP?l'
-^2mXar`Tq;CnPoW=]np>C2'g1MIfpfFm&T#55O#nA6N/@>$G-YQ=sH)=^c&[NoZXB>>];!rr;`B
-Jmhed>\S4oVrbR3?<^]DBP:m[C7EK4fqN1e>?bE@rEq6b?!C?/;HIk<dd[58qr>,5?X-c??X[DR
-@UNJD<)HhUbjYN1s7)an>$"^$OR`,G"nKol?WpS2=Thf*;NUFOs*t~>
-nc'L+p"-."K85AFOHG`kQ'.)ZH$+e2]$fg9rUp0qqrY^Z$k+u[nc*5"kKV#QQ].!!UW332pW]Ol
-GC.C"rqOsb^nm-KLl@n"ZMO4<QAC6NLk^D*R$!;]L51hRO1shcQA'R/h#%-Oq9YalL4tJJP)Sku
-^lsS.Lkp_3Jte9^L5(JEPE3H<Y*4EZMWag855O$,MhHkAL4OW0S;i;YL5_=YW8t@QKQVt/rr;`B
-S;W,XMjBou]&gYfKnbMJR@&t_J>(6Pfr9aYKo(eMrK&XlN/3%2F*3/;dd[58qr>2JJqSo;O-,Wj
-PE:]UHZF=pbjYN1s7*LXJ9uQ_TCM^V"nKp)Jpr4KJHUIKF.`!*s*t~>
-nGa:'o@UL#@Tc`5=&r:!<*O-jVSC^HpAOR^#5dQ!\[\s2nc&ag`,8sbrDsP4R.UFUgM'bkOQ-0;
-mYPO[qc>FQG45Cl\:.[a='g0Qa1$"i='KBoY1hojD.[F1jo5;[qr!`H='&mRNP4]TiO!b,<tf%s
-]Zd<l='&U?LT]@gI;<G.R-aYK+TCiPO^M6l>Ap1P`IV;r=(lrVd,:%)An[7ks8W&_]Qa?V)J"5b
-dI?,&I:$&S='K[-]%6?Io@LF+AQW&8r`9J.<)cdtAq$SmhXpdGrtP7f_j,4H='&F(=&r:!<F0sM
-cL(T0rrVc"K`65uJ$AM=rrr>daJ+0"rFQ.II^&CGs*t~>
-nG`^lo@UL#@p8k5$s$>+<Ej6lVSC^HpAOR^#5dQ!Vim_=nc&ag`,B'erE'V6R.UFUgM0knOQ-0;
-mYPR]qcGLSGOPLm\:.^c=C6BTa1$"j=BoTrYM/#lDJ*X5jo5;[qr!`I=BK*VNP4]TiO!e-=;,2!
-]Zd<m=BJgCLTfFhIV`Y2R-aYK+TCiPO^V?o>]?@R`IV>t=D</Yd,:(*B5*Ins8W&_]QjEX)J+;d
-dI?,&IUH8V=Boj/]%6?Io@LF+Am&5:r`9J.<)lk!B7HbohXpdGrtP7f_j,7J='&F(=&r:"<F:'P
-cL(T0rrVc"K`65uJ$AM=rrr>daJ+3$rFZ4JJ$ALHs*t~>
-nG`[ko@UL4J,Xa'H[9mXFEi=sW5$pJpAOR^#5dQ!57013nc&agc]s*,rH8`sWV$5fgQ-Q%S)X>F
-m\bqiqfXW:O73&0\rV,[G']"Ia1@.PG'JS&ZJ+?3LOO]6jo5;[qr"5uG'87gR(r"aiO4XCFq]7c
-]ZdR7G'8+]Pd9$#RY6-?V!RpW:&aV(S:#L'G_;d/`KY^mG(5INd,:gXIXdpSs8W&_^5[>[G(,FI
-eF;G+NdGqjG'J\/]%6?Io@LF7IsH<cH@(!bGBItMIZ12@hXpdGrtP7f_juO.G^4U^H[9jVFaAnF
-cL(T0rrVc+Q2ZR@Nk"ZTrrr>daJY#JrI+j!Nk"Y_s*t~>
-n,EUkpZ'?$Q[esZ#_\MH]Zo="q#9a^"oIH!ZG#VprrW&S\bi?:[++aJroh(qZdSLGs6n+6qPbL=
-b4#B*j2\I*X0fq*n)M6dWirtTh!j[V]"#B!nG`G6rpe@BWiWSBcJnTtpYiumWN<VTkOIBBXfAS8
-akZCObIG'sg%G.?)>idI[]?F4_:e8@bH\(L[`-kamF/_X^=MrUruh-t`36/A[DLGZqY0$k[&K4e
-YeS]Op\t3lp>sQ-SrS-pGmK4fX16=.meZq]rs/Q"m+&kSOb<RW#)SnWa5?IdrVlroim%JA!mTa"
-p\tBnn(c("rO;sCb2W3!s*t~>
-n,EUkpZ'?$Q[esZ#_\MH]Zo="q#9a^"oIH!VmYm]rrW&S\bi?:[++aJroh(qZdSLGs6n+6qPbL=
-b4#B*j2\I*X0fq*n)M6dWirtTh!j[V]"#B!nG`G6rpe@BWiWSBcJnTtpYiumWN<VTkOIBBXfAS8
-akZCObIG'sg%G.?)>idI[]?F4_:e8@bH\(L[`-kamF/_X^=MrUruh-t`36/A[DLGZqY0$k[&K4e
-YeS]Op\t3lp>sQ-Sr\3rGmSeROK5n6h<t.=rVm-%qWubIYE=M:GmAYPS[6Aoo)8Oe!r1d"rl"r`
-iqW9J"T.ZCb.dha"22k:poaXI~>
-n,EUkpZ'?$SW*N'#`tOY]Zo="q#9a^"oIH!@u'F@rrW&S\bi?:[++aJroh(qZdSLGs6n+6qPbL=
-b4#B*j2\I*X0fq*n)M6dWirtTh!j[V]"#B!nG`G6rpe@BWiWSBcJnTtpYiumWN<VTkOIBBXfAS8
-akZCObIG'sg%G.?)>idI[]?F4_:e8@bH\(L[`-kamF/_X^=MrUruh-t`36/A[DLGZqY0$k[&KLm
-YeS]Op\t3lp>sQ-U6^Z7L^Ap$R&da>h<t.=rVm-%qWubIYF1IML^/d#TsMeso)8Oe!r1d"rl"r`
-iqW9J"T.ZCb.dha"22k:poaXI~>
-mJd^oo&\KIa2Q$<cIh1Do_\XSrri5`f&$)irrW/kkkj?Mk4/?Ks7kj<kOSTOs8)-DqViOVmJ?k^
-qsik0j66%1rqYpAj5oUtqYp?\lKRX*qu-O?rU]75j65q(qu6WpqX3J)j6?47rqGd?j5oUtqYp?[
-l07R,rV-=/rUf@7j6#e*rql3Ij5fIoq#:0]lfmd.r;Q^2rqc'EioB7kpAFphqsin.gY_/]p\k$i
-"o\)WgsX=C`<XK0fAPrcqu6Ek#6";aimuAprl#)_d+d^Qqu6Nn!r_obrp^'\q#0pd$i^"om-<j"
-lKn'9rN?0N~>
-mJd^oo&\KIa2Q$<cIh1Do_\XSrri5`f&$)irrW/kkkj?Mk4/?Ks7kj<kOSTOs8)-DqViOVmJ?k^
-qsik0j66%1rqYpAj5oUtqYp?\lKRX*qu-O?rU]75j65q(qu6WpqX3J)j6?47rqGd?j5oUtqYp?[
-l07R,rV-=/rUf@7j6#e*rql3Ij5fIoq#:0]lfmd.r;Q^2rqc'EioB7kpAFphqsin.gY_/]p\k$i
-"o\)WgsX=C`<XK0fAPrcqu6Ek#6";aimuAprl#)_d+d^Qqu6Nn!r_obrp^'\q#0pd$i^"om-<j"
-lKn'9rN?0N~>
-mJd^oo&\KIa2Q$<cIh1Do_\XSrri5`f&$)irrW/kkkj?Mk4/?Ks7kj<kOSTOs8)-DqViOVmJ?k^
-qsik0j66%1rqYpAj5oUtqYp?\lKRX*qu-O?rU]75j65q(qu6WpqX3J)j6?47rqGd?j5oUtqYp?[
-l07R,rV-=/rUf@7j6#e*rql3Ij5fIoq#:0]lfmd.r;Q^2rqc'EioB7kpAFphqsin.gY_/]p\k$i
-"o\)WgsX=C`<XK0fAPrcqu6Ek#6";aimuAprl#)_d+d^Qqu6Nn!r_obrp^'\q#0pd$i^"om-<j"
-lKn'9rN?0N~>
-li.%cq=O[V"7l-]roa:`r:fsaJcF:#!r`#ppAY6oqtK[[nH8@Tq>Kma"9&&fo)A.]o(Mt[LAuc~>
-li.%cq=O[V"7l-]roa:`r:fsaJcF:#!r`#ppAY6oqtK[[nH8@Tq>Kma"9&&fo)A.]o(Mt[LAuc~>
-li.%cq=O[V"7l-]roa:`r:fsaJcF:#!r`#ppAY6oqtK[[nH8@Tq>Kma"9&&fo)A.]o(Mt[LAuc~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-JcC<$JcFs6J,~>
-%%EndData
-showpage
-%%Trailer
-end
-%%EOF
diff --git a/docs/draknet_advanced_doc.txt b/docs/draknet_advanced_doc.txt
deleted file mode 100644
index a0c0c63e0..000000000
--- a/docs/draknet_advanced_doc.txt
+++ /dev/null
@@ -1,165 +0,0 @@
-This document details the entry points you can call without the DrakX graohical
-toolkit. First, the general variables you will encounter further. If you don't
-know wht a variable is, look here. Any additional locally variables are
-commented 'in place'
-
-------------------------------
-Special types (in upper cases)
-------------------------------
- DB_FILE : file storing the ISDN ISP database. see share/isdndb.txt : file of lines in 'Unlisted - edit manually' or /^(.*)\|(.*)\|(.*)=>([0-9]*)=>(.*)=>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})=>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/ where $1=Land $2=City $3=ISP_name $4=phone_number $5=hostname $6=dns1 $7=dns2
-
----------------------------------------------------------------------------------------
-Summary of common variables used (local variables are described in the function itself)
----------------------------------------------------------------------------------------
-notation : keys : description : type : format (regexp or enumeration. `...' means it's not exhaustive
- $prefix : prefix path (empty in post-install) : string : path
- $isLaptop : flag for laptop : boolean or int : guess
- $isdn : hash table containing isdn infos
- $isdn->{login} : cnx login : string
- $isdn->{passwd} : cnx passwd : string
- $isdn->{phone_in} : user phone : /^[0-9]*$/
- $isdn->{phone_out} : ISP phone : /^[0-9]*$/
- $isdn->{dialing_mode} : dialing mode : "auto" or "manual"
- $isdn->{driver} : driver used for the card : "hisax" or "b1pci" or ...
- $isdn->{type} : type of card, used for the driver, see netconnect_consts : integer : /^[1-22]|[24-37]$/
- $isdn->{irq} : irq of the ISA card : integer |
- $isdn->{mem} : mem of the ISA card : string |
- $isdn->{io} : io of the ISA card : string | see netconnect_consts for examples.
- $isdn->{io0} : io0 of the ISA card : string |
- $isdn->{io1} : i01 of the ISA card : string |
- $isdn->{idl} : amount of time after the cnx times out in secs : int
- $isdn->{user_name} : not used anymore. Not explicit. It represented the name of the connexion.
- $isdn->{card_type} : card type : string : "isa" or "pci" or "pcmcia"
- $isdn->{protocol} : cnx protocol : int : 1|2|3 : 1 for old german specific (not used anymore), 2 for europe, 3 for rest of the world
- $isdn->{id} : card id. Associated with vendor, identify strictly the card. see pcitable : integer
- $isdn->{description} : card description from pcitable : string
- $isdn->{vendor} : card vendor : integer
- $isdn->{passwd2} : passwd verification : string
- $modem : hash table containing modem infos
- $modem->{device} : device of the modem : string : /ttyS[0-9]/
- $adsl : hash table containing modem infos
- $adsl->{login} : cnx login : string
- $adsl->{passwd} : cnx passwd : string
- $adsl->{atboot} :
- $netc : hash table containing system-wide networking infos (maybe not true, correct this) :
- $netc->{NET_DEVICE}
- $netc->{dnsServer2}
- $netc->{dnsServer3}
- $netc->{DOMAINNAME2}
- $netc->{NET_INTERFACE} is set to "ppp0"
- $in : interactive object
-
-------------
-Entry points
-------------
-
-isdn_write_config_backend : write isdn info, only for ippp0 -> ask_connect_now
-input :
- $prefix
- $isdn
-$isdn input:
- $isdn->{login} $isdn->{passwd} $isdn->{phone_in} $isdn->{phone_out} $isdn->{dialing_mode}
- $isdn->{driver} $isdn->{type} $isdn->{irq} $isdn->{mem} $isdn->{io} $isdn->{io0} $isdn->{io1}
-
-write_secret_backend : write login and passwd into /etc/ppp/{chap, pap}-secrets. Replace old passwd only if same login
-input :
- $a : login : string : /^.*$/
- $b : passwd : string : /^.*$/
-
-connect_backend : launch the cnx script
-input : $prefix
-
-connect_backend : launch the cnx script
-input : $prefix
-
-read_providers_backend : build the tree of isdn ISP
-input :
- $file : 1st location of the file : ISDN_DB_FILE
- $file2 : 2nd location of the file : ISDN_DB_FILE
-output : the list of ISP : array of strings : array of /^(.*)\|(.*)\|(.*)$/ where $1=Land $2=City $3=ISP_name
-
-get_info_isdn_backend : fills the infos from the line of the tree returned into $isdn and $netc
-input :
- $isdn
- $netc
- $name : the line choosen in the tree of ISP : string : /^(.*)\|(.*)\|(.*)$/ with $1=Land $2=City $3=ISP_name
- $file : 1st location of the file : ISDN_DB_FILE
- $file2 : 2nd location of the file : ISDN_DB_FILE
-$isdn ouput
- $isdn->{user_name}, $isdn->{phone_out}, $netc->{DOMAINNAME2}, $netc->{dnsServer2}, $netc->{dnsServer3},
-$netc output
- $netc->{DOMAINNAME2}, $netc->{dnsServer2}, $netc->{dnsServer3}
-
-isdn_detect_backend : detects isdn pci card and fills the infos in $isdn : only detects one card
-input
- $isdn
-$isdn output:
- $isdn->{description} $isdn->{vendor} $isdn->{id} $isdn->{driver} $isdn->{card_type} $isdn->{type}
-
-isdn_get_list : return isdn cards descriptions list. This function is not use internally.
-output : descriptions : list of strings
-
-isdn_get_info : return isdn card infos. This function is not use internally.
-input : the description of the card (see isdn_get_list)
-output : a reference on the decription of the card. : ref on a hash(description,type,irq,mem,io,io0,io1card,)
-
-conf_network_card_backend : configure the network cards and return the list of them, or configure one specified interface : WARNING, you have to setup the ethernet cards, by calling setup_thiskind($in, 'net', !$::expert, 1) or setup_thiskind_backend before calling this function. Basically, you call this function in 2 times.
-input
- $prefix
- $netc
- $intf
- $type : type of interface, must be given if $interface is : string : "static" or "dhcp"
- $interface : facultative, if given, set this interface and return it in a proper form. If not, return @all_cards
- $ipadr : facultative, ip address of the interface : string
- $netadr : facultative, netaddress of the interface : string
-when $interface is given, informations are written in $intf and $netc. If not, @all_cards is returned.
-$intf output: $device is the result of
- $intf->{$device}->{DEVICE} : which device is concerned : $device is the result of $interface =~ /(eth[0-9]+)/; my $device = $1;;
- $intf->{$device}->{BOOTPROTO} : $type
- $intf->{$device}->{NETMASK} : '255.255.255.0'
- $intf->{$device}->{NETWORK} : $netadr
- $intf->{$device}->{ONBOOT} : "yes"
-$netc output:
- $netc->{nb_cards} : nb of ethernet cards
- $netc->{NET_DEVICE} : this is used to indicate that this eth card is used to connect to internet : $device
-output:
- $all_cards : a list of a list ( (eth1, module1), ... , (ethn, modulen)). Pass the ethx as $interface in further call.
- $device : only returned in case $interface was given it's $interface, but filtered by /eth[0-9+]/ : string : /eth[0-9+]/
-
-adsl_conf_backend : write adsl configuration
-input :
- $prefix
- $adsl
- $netc
- $adsl_type : type of cnx : string : "pptp" or "pppoe"
-$adsl input:
- $adsl->{login}, $adsl->{passwd}, $adsl->{atboot}
-$netc input:
- $netc->{NET_DEVICE}
- $netc->{dnsServer2}
- $netc->{dnsServer3}
- $netc->{DOMAINNAME2}
-$netc output:
- $netc->{NET_INTERFACE} is set to "ppp0"
-
-modem_detect_backend : detects modem on serial ports and fills the infos in $modem : detects only one card
-input
- $modem
- $mouse : facultative, hash containing device to exclude not to test mouse port : ( device => /ttyS[0-9]/ )
-output:
- $modem->{device} : device where the modem were detected
-
-get_net_device : return the device choosen for the net cnx
-no input
-output : name of the internet device.
-
-read_net_conf : read the information stored in $prefix/etc/sysconfig/draknet and $prefix/etc/sysconfig/draknet.`type`
-input:
- $prefix
- $netcnx
- $netc
-
-set_net_conf : set the information from netcnx in $prefix/etc/sysconfig/draknet and $prefix/etc/sysconfig/draknet.`type`
- $prefix
- $netcnx
- $netc : useless! REMOVE ME
diff --git a/docs/interactive/ask_from b/docs/interactive/ask_from
deleted file mode 100755
index dad69247e..000000000
--- a/docs/interactive/ask_from
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/perl
-# Yves Duret <yduret at mandrakesoft.com>
-# license: GPL
-
-use lib qw(/usr/lib/libDrakX);
-use interactive;
-
-my $irq=1;
-my $login;
-my $login2="editable";
-my $check;
-my $range=57;
-
-my $in = 'interactive'->vnew(undef, 'default');
-
-$in->ask_from("window title - ask_from",
- "message\nexamples of utilisation of ask_from",
- [
- { label => "enter scalar", val => \$irq },
- { label => "combo (type=>combo optionnal)", val => \$login, list => ['Netherlands', 'France', 'Belgium', 'Italy', 'UK'], type => 'combo'},
- { label => "choose from list editable and sorted", val => \$login2, list => ['Netherlands', 'France', 'Belgium', 'Italy', 'UK'], not_edit => 0, sort => 1},
- { label => "check box", val => \$check, type => "bool", text => "text" },
- { label => "range", val => \$range, type => 'range', min => 0, max => 100 },
- ],
- complete => sub { print "complete\n";print "$irq\n$login\n$range\n"; },
-# focus_out => sub { print "focus_out\n"},
-# changed => sub { print "changed\n"; },
- ) or $in->exit(0);
-$in->exit(0);
diff --git a/docs/interactive/ask_from_list b/docs/interactive/ask_from_list
deleted file mode 100755
index 63c0ee996..000000000
--- a/docs/interactive/ask_from_list
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/perl
-# Yves Duret <yduret at mandrakesoft.com>
-# license: GPL
-
-use lib qw(/usr/lib/libDrakX);
-use common;
-use interactive;
-
-my %l = (
- 0 => "Welcome To Crackers",
- 1 => "Poor",
- 2 => "Low",
- 3 => "Medium",
- 4 => "High",
- 5 => "Paranoid",
- );
-
-my $in = 'interactive'->vnew(undef, 'default');
-
-my $level = $in->ask_from_list("window title - ask_from_list",
- "radio button\nexamples of utilisation of ask_from_list",
- [ values %l ], $l{2}
- ) or $in->exit(0);
-
-print "$level\n";
-$in->exit(0);
-
diff --git a/docs/interactive/ask_from_listf b/docs/interactive/ask_from_listf
deleted file mode 100755
index 077540b49..000000000
--- a/docs/interactive/ask_from_listf
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/perl
-# Yves Duret <yduret at mandrakesoft.com>
-# license: GPL
-
-use lib qw(/usr/lib/libDrakX);
-use interactive;
-use Data::Dumper;
-
-my $in = 'interactive'->vnew(undef, 'default');
-
-my @m=(
- { description => "dhcpcd",
- c => 1},
- { description => "dhcpxd",
- c => 3},
- { description => "dhcp-client",
- c => 4},
- );
-my $f = $in->ask_from_listf(_("ask_from_listf"),
- _("Which dhcp client do you want to use?\nDefault is dhcpcd"),
- sub { $_[0]{description} },
- \@m );
-
-print Data::Dumper->Dump([$f],['f']) . "\n";
-
-$in->exit(0);
-
diff --git a/docs/interactive/ask_from_treelist b/docs/interactive/ask_from_treelist
deleted file mode 100755
index ade7141d4..000000000
--- a/docs/interactive/ask_from_treelist
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/perl
-# Yves Duret <yduret at mandrakesoft.com>
-# license: GPL
-
-use lib qw(/usr/lib/libDrakX);
-use common;
-use interactive;
-
-my $in = 'interactive'->vnew(undef, 'default');
-my $foo = $in->ask_from_treelist("window title - ask_from_treelist",
- "message\nexamples of utilisation of ask_from_treelist",
- '|',
- ['Custom',
- 'Other|Unlisted',
- 'Matrox|Millennium II=>Matrox Millennium II',
- 'Matrox|Millennium G200=>Matrox Millennium G200',
- 'Matrox|Millennium G400=>Matrox Millennium G400',
- 'Matrox|Millennium G450=>Matrox Millennium G450',
- 'Matrox|Millennium G550=>Matrox Millennium G550',
- 'Sun|FFB 67MHz Creator=>Sun FFB 67MHz Creator',
- 'Sun|FFB 67MHz Creator 3D=>Sun FFB 67MHz Creator 3D',
- 'Sun|FFB 75MHz Creator 3D=>Sun FFB 75MHz Creator 3D',
- ],
- 'Custom'
- ) or $in->exit(0);
-print "$foo\n";
-$in->exit(0);
diff --git a/docs/interactive/wait_message b/docs/interactive/wait_message
deleted file mode 100755
index 0caec4471..000000000
--- a/docs/interactive/wait_message
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/perl
-# Yves Duret <yduret at mandrakesoft.com>
-# license: GPL
-
-use lib qw(/usr/lib/libDrakX);
-use interactive;
-
-my $in = 'interactive'->vnew(undef, 'default');
-my $wait = $in->wait_message('wainting title', _("Moving files to the new partition"));
-sleep(3);
-$wait->set(_("Removing"));
-sleep(3);
-$in->exit(0);
diff --git a/docs/mdk-9.2 b/docs/mdk-9.2
deleted file mode 100644
index 1d5a06494..000000000
--- a/docs/mdk-9.2
+++ /dev/null
@@ -1,129 +0,0 @@
--*- outline -*-
-
- todo list for mdk9.2
- (mainly gtk+ oriented for now)
-
-* erratas
-** put them in gi/perl-install/patch/mdk_9.1
-** move mdk9.1 ones from gi/perl-install/patch into gi/perl-install/patch/mdk_9.0
-
-
-* libDrakX
-** document internals through docbook like kernel-2.5.x does
-
-* mcc vs tools communication
-** faster tools embedding in mcc (gc idea)
- move gui into gui/<sg>.pm so that mcc can just do require on them
- instead of doing slow fork+perl startup (same idea as fast_cgi,
- perl_mod and the like)
-** told apps to ask user whether to save their changes or to discard them on cancel (#1437)
-** to let diskdrake fit better when embedded, we should write "formated - mounted" rather than "formated\nmounted"
-** "testing mode" option in options menu so that we pass --testing to our tools ?
-
-* ugtk2 & tools guies:
-** cleanups:
-*** $o->flush() should be sub { $_[0]->window->process_updates(1) }
- see logdrake::parse_file()'s progress bar as an example
-** saner/cleaner usage of gtk+-2.2 widgets:
-*** use MessageDialog for modal windows (cleaner)
- especially for wait/error messages so that one uses std gtk+ icons for info/error/warning and the like events
-*** use button boxes everywhere when we have several buttons for saner gui (as per gnome specs/recommendations)
-*** gtk::combo => gtk::optionMenu (as per gtk+-2 doc)
-*** use size::group to let things be smoother in some places (eg: clock.pl from mcc)
-
-* tools
-** all:
-*** provide menu entries for more gui tools (?): for now, only harddrake2 and logdrake have one
-*** explanations of std standalone.pm functions are broken due to common.pm overloading
-*** have a button or a menu to access help (was already part of mdk9.1 specs)
- only harddrake2, mcc and rpmdrake have one for now
- policy might be: "most users access tools via the mcc, so let handle help, bug reports and co only in mcc"
-*** rename and provide compatibility links:
-**** adduserdrake => drakeuseradd
-**** diskdrake => drakdisk
-**** harddrake => drakhw
-**** keyboarddrake => drakkeyboard
-**** localedrake => draklocale
-**** logdrake => draklog
-**** menudrake => drakmenu [fredc]
-**** mousedrake => drakmouse
-**** printerdrake => drakprinter
-**** userdrake => drakuser [deush]
-**** XFdrake => drakx11
-** drakboot:
-*** should prevent the user to insert a space in a kernel label (#2826)
-*** fix "Display theme under console" setting from current theme config file (#2662)
-** drakconnect
-*** does not show up zeroconf as a valid mode in "configuring lan" window in embedded mode
-** drakedm:
-*** restart dm service ?
-** harddrake:
-*** colorize the internal help
-*** add raw description (or join('|', vendor, descr)) for mass medias (see drakx bug #3???)
-*** use pure gtk+ instead of interactive for "fields description" or alter interactive so that it creates modal windows
-** logdrake:
-*** search field does not get focus when embedded
-*** we may disable the search button when one deselect all explanation files
-** mcc:
-*** make tool names be black or blue (like in rpmdrake & harddrake2 guies) (#2695)
-*** hide non executable programs instead of warning at runtime if program isn't executable
-*** make more program being options rather than depandancies (ie like rpmdrake and drakwizard)
-*** add scrollbars if root window is below 800x600 (#2961)
-*** add scrollbars for too big translated messages (but how to detect it)
-*** move drakedm from hardware to system section
-*** enhance mcc descriptions (#3265)
-** rpmdrake
-*** save mode (sort by group, mdk choice, ...)
-**** sa serait cool que tu sauve la position (aka choix mdk, tri/alpha, par
- groupe, par taille, ...) et que tu la restaure
-*** m-q accelerator to quit
-*** if package is unselectable, explain why
-*** si conflit, proposer de deselectionner le package en question +tot que de
- devoir se taper l'arborescence pour le deselectionner (a - que la
- recherche e perde pas la selection de package en cours)
-*** some windows are still non modal, like:
- o tout ce qui se rapporte aux dependances "des paquetages
- supplementaires sont necessaires", ... tu oublie de passer "{
- transient => $w->{rwindow} }"
- o toutes les fenetres grpmi. faudrait voir si on peut foutre le
- core de grpmi dans un package pour faire "use grpmi" et seter
- le nouveau $::main_window pour corriger ca.
-*** we need access to urpmi options like "no gpg signature check"
-*** bug 1
-1) selectionner des packages a installer
-
-2) rpmdrake dit que X doit etres vier
-
-3) rpmdrake le vire
-
-4) rpmdrake passe a l'update/isntall proprement dite
-
-5) rpmdrake failled
-
-rpmdrake re-tentera d'enlever le package X du 1 en cas de reessai
-alors qu'il n'est + la
-
-** scannerdrake/sane-find-scanner
-*** do not detect every usb devices as scanner
-** urpmi
-*** --repair-system: add missing dependancies for currently installed packages
-
-
-* packages
-** main package updates:
-*** rpm-4.2
-*** kernel-2.6 (if availlable and stabilized: not probable) ?
- at least, keep kernel-2.4.x
-** add new packages:
-*** kernel-mosix
-*** dvb related packages: vcr, vdr, ...
-** icewm/windowmaker/other wm
-*** export BROWSER like gnome/kde (look at /etc/gnome/gnomerc)
-
-* hardware support
-** kernel: update alsa, bttv, dvb & saa7134 drivers for better hardware support (the laters from http://bytesex.org)
-*** add "REGISTER ^dvb/adapter[0-9]+/[^/]+$ PERMISSIONS root.video 0660" to devfsd
-*** update oss audigy driver from pserver:anonymous@cvs.sourceforge.net:/cvsroot/emu10k1 cvs
-** add cx88 sound driver from http://bytesex.org/snapshot
-** isa detection/probing in ldetect ? (#118, #497) => need some old hw in order to test
- probably not
diff --git a/docs/mdk-vs-redhat b/docs/mdk-vs-redhat
deleted file mode 100644
index 4d0de8223..000000000
--- a/docs/mdk-vs-redhat
+++ /dev/null
@@ -1,43 +0,0 @@
-+ Open Development (at least DrakX)
-+ UDMA66 (HPT366)
-+ gamerz
-+ number of packages
-+ better packages(?)
-+ no automatic handling of ide burners
-+ urpmi/rpmdrake
-+ XFdrake
-+ no newbie install
-+ reiserfs
-+ fat resizing
-+ 3D handling (eg: Voodoo3)
-+ diskdrake (vs diskdruid)
-+ usb storage (?)
-+ KDE2
-+ faces in kdm/gdm
-+ menu
-+ alternatives
-+ /etc/emacs/site-start.d
-+ default config
-+ i18n (bootloader keyboard)
-
-+ More user-friendliness in general:
- + you can choose between multiple net devices when more than one are
- detected
- + you are presented with the media descriptions (disks, cdrom's)
- when you must choose between multiple media, and not only "sda",
- "hdc", ..
- + when installing from a disk partition, you are presented with an
- extract of the directory contents when you fail to give the
- correct location, which is very helpful to correct the input
- instead of simply rebooting to remember where on earth you
- mirrored the distribution on your disks
-
-+ Automatic mode (Redhat's equivalent is called "kickstart") is not
- performed according to a file on the floppy but from kernel parameters,
- which have many pros, among them: (1) we don't need the vfat filesystem
- for that purpose, and (2) with advanced bootloaders such as grub and
- lilo you can edit parameters on the fly at boot time.
-
-- no LABEL= in fstab (for auto renumbering of devices)
-- kerberos
-- LDAP
diff --git a/docs/net_object_class.fig b/docs/net_object_class.fig
deleted file mode 100644
index 19f7f5318..000000000
--- a/docs/net_object_class.fig
+++ /dev/null
@@ -1,73 +0,0 @@
-#FIG 3.2
-Landscape
-Center
-Inches
-Letter
-100.00
-Single
--2
-1200 2
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 4050 4162 675 338 4050 4162 4725 4500
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 5700 3112 675 338 5700 3112 6375 3450
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 7275 4087 675 338 7275 4087 7950 4425
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 4800 1462 975 487 4800 1462 5775 1950
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 2700 3112 675 338 2700 3112 3375 3450
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 4875 5887 975 487 4875 5887 5850 6375
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 9450 5062 675 338 9450 5062 10125 5400
-1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 4654 4038 3900 3225 4654 4038 754 813
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 4125 1875 3225 2850
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 4575 1950 4200 3750
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 5250 1950 5475 2775
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 3000 3450 3600 3900
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 5925 3450 6675 3900
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 2700 3450 4050 5550
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 4125 4500 4575 5400
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 5625 3450 5025 5400
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 5775 1575 9450 4725
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 7800 4275 9000 4800
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 4800 1950 4800 5400
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 9000 975 9450 4725
-2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
- 7500 75 10687 75 10687 975 7500 975 7500 75
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 7500 375 5400 1050
-2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 0 0 1.00 60.00 120.00
- 5550 1800 7200 3675
-4 0 0 50 0 0 12 0.0000 4 135 885 4350 1500 Netconnect\001
-4 0 0 50 0 0 12 0.0000 4 135 435 2475 3150 ISDN\001
-4 0 0 50 0 0 12 0.0000 4 135 720 3675 4200 MODEM\001
-4 0 0 50 0 0 12 0.0000 4 135 960 6825 4125 ETHERNET\001
-4 0 0 50 0 0 12 0.0000 4 135 480 5400 3150 ADSL\001
-4 0 0 50 0 0 12 0.0000 4 135 420 4650 5925 Tools\001
-4 0 0 50 0 0 12 0.0000 4 135 660 9150 5100 Network\001
-4 0 0 50 0 0 12 0.0000 4 135 1305 8400 375 Rest of the world\001
-4 0 0 50 0 0 12 0.0000 4 180 2595 7725 600 (draknet, printerdrake, tinyfirewall\001
-4 0 0 50 0 0 12 0.0000 4 180 2310 7725 825 ftp, http, net_monitor, drakgw)\001
-4 0 0 50 0 0 12 0.0000 4 195 2760 3525 6825 Global variables $in, $prefix, $install\001
-4 0 0 50 0 0 12 0.0000 4 180 2340 3525 7050 shared with the module globals\001
diff --git a/docs/object_class.fig b/docs/object_class.fig
deleted file mode 100644
index 44fd3fe89..000000000
--- a/docs/object_class.fig
+++ /dev/null
@@ -1,32 +0,0 @@
-#FIG 3.2
-Landscape
-Center
-Inches
-Letter
-100.00
-Single
--2
-1200 2
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 2625 1200 2625 1725
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 7575 1125 7575 1650
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 7575 2100 4350 3225
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 5025 2025 4350 3225
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 2625 2100 4350 3225
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 5025 2025 6075 4125
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 2625 1200 4950 1725
-2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
- 7575 1125 4950 1725
-4 0 0 100 0 0 12 0.0000 4 180 1755 1800 1050 install_steps_gtk\001
-4 0 0 100 0 0 12 0.0000 4 180 1440 6900 975 install_steps_stdio\001
-4 0 0 100 0 0 12 0.0000 4 180 1140 2100 1950 interactive_gtk\001
-4 0 0 100 0 0 12 0.0000 4 180 1275 6900 1950 interactive_stdio\001
-4 0 0 100 0 0 12 0.0000 4 180 1875 4125 1950 install_steps_interactive\001
-4 0 0 100 0 0 12 0.0000 4 135 810 3975 3450 interactive\001
-4 0 0 100 0 0 12 0.0000 4 180 975 5625 4350 install_steps\001
diff --git a/docs/porting-ugtk b/docs/porting-ugtk
deleted file mode 100755
index a72faabb6..000000000
--- a/docs/porting-ugtk
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/perl -pi
-#
-# $Id$
-#
-# This is not an automatic gtk+-1.x to gtk+-2.x port tool,
-# just a tool that ease perl apps' gtk2 port.
-# you'll have to fix all remaining problems, beginning by spotted warnings
-# it'll save you basic conversion work
-#
-# if you used Gtk::Text, a little more work will be needed (look at logdrake gtk2 port)
-# if you used Gtk::CTree, Gtk::CList or worse, Gtk::Tree, you'll need quite a lot of exhausting work :-(
-#
-# usage: porting-ugtk <file>
-#
-# hint: always use strict
-
-# switch to gtk2 :
-s!Gtk:!Gtk2:!g;
-/(use|require) Gtk/ and print STDERR "Warning: if this (bad) app that did not use my_gtk, you'll have a hard time :-)\n if not, using both Gtk && my_gtk was misdesigned ...\n";
-s!(use|require) Gtk.*!!g; #
-s!my_gtk!ugtk2!g;
-
-# one should pass the right ":stuff" to "use ugtk2 qw();"
-/ugtk::/ and print STDERR "Warning: you'll have to passe eiter :ask, :create, :helpers or :wrappers to ugtk\n";
-s!ugtk::!!g;
-# if my_gtk wasn't used, this'll be spotted by the lack of "use ugtk2;" anyway
-s!(require|use) ugtk.*!!g;
-
-
-# deprecated :
-/::(CTree|CList|Text[^V])/ and print STDERR "Warning: CTree, CList and Text widgets are deprecated... Good luck :-(\n";
-/gtkcreate_(png|xpm)/ and print STDERR "Warning: new Gtk::Pixmap(gtkcreate_(png|xpm)) should be replaced by gtkcreate_img\n";
-/set_policy/ and print STDERR "Warning: ->set_policy() should be replaced by allow_shrink/allow_grow/set_resizable\n";
-
-# obsoletes methods||functions :
-s!set_usize!set_size_request!g;
-s!gtkset_set_border_width!gtkset_border_width!g;
-s!border_width!set_border_width!g;
-s!-(end|spread|extended|start|single)!'\1'!g;
-s!createScrolledWindow!create_scrolled_window!g;
-# quite a lot less usefull with gtk+2 but who knows... :
-s!set_position\(1\)!set_position('center')!g;
-s!gtkpng!gtkcreate_img!g;
-# hacky but usefull in ->set_pixmap() context; else that'll be spoted at run time :
-s!gtkcreate_png!gtkcreate_img!g;
-# usefull sometimes but not in most cases :
-#s!new GtkVBox!create_vbox!g;
-#s!new GtkHBox!create_hbox!g;
diff --git a/docs/spec-DrakX-8.0.html b/docs/spec-DrakX-8.0.html
deleted file mode 100644
index 3fd545447..000000000
--- a/docs/spec-DrakX-8.0.html
+++ /dev/null
@@ -1,405 +0,0 @@
-<html><head><title>DrakX Specification for Linux-Mandrake 8.0</title></head>
-<body bgcolor="#FFFFFF" link="#0066FF" vlink="#0066FF" alink="#FF0000">
-<table border="0" cellpadding="0" cellspacing="0" width="100%">
-<tr>
-<td bgcolor="#99AAFF"><h2 align="left">DrakX Specification for Linux-Mandrake 8.0</h2></td></tr>
-<tr><td valign="top">
-Current team of Install group is :
-<p>
-<table cellpadding="2" cellspacing="2" border="1" width="30%">
-<tbody>
-<tr valign="Top">
-<td valign="Top">gc
-
-</td>
-</tr>
-<tr valign="Top">
-<td valign="Top">damien
-
-</td>
-</tr>
-<tr valign="Top">
-<td valign="Top">fpons
-
-</td>
-</tr>
-<tr valign="Top">
-<td valign="Top">pixel
-
-</td>
-</tr>
-</tbody>
-</table>
-<p>
-
-<pre>
-
- <b>Boot process (stage1)</b>
-
- Installation begin by booting from CD-ROM or Diskette. From CD-ROM all
-installation method are available (CD, HD, NFS, FTP, HTTP) on options. From
-Diskette according to image selected, only some related method (network or cdrom
-or hd) are available and module managed due to size limitation to 1.44Mb.
- Options are always available by pressing on F1.
-
- <b>DrakX process (stage2)</b>
-
- DrakX installation organized in steps (execution sequence described below).
-Steps listed on left side and help available on bottom right side. most of the
-screen is available for various dialog for interacting with the user. Steps
-execution sequence is automated and described below.
-
-Mouse is probed and if none has been found or if the mouse has not moved, a
-specific mouse configuration is displayed at the begining.
-
-
-Before the graphical steps, there is a detection step. It detects various
-hardware, including modems (from tty0 to tty7), mouse (serial, usb, ps/2) and
-tablets.
-
- <b>Steps</b>
-
- <i>Choose Your language</i>: step always displayed. default choice is previous one or
-<font color="#000080"><i>English</i></font>. After choosing a language, a license splash screen translated in the
-chosen language is displayed with <font color="#000080"><i>Accept</i></font> and <font color="#000080"><i>Refuse</i></font> buttons. <font color="#000080"><i>Refuse</i></font> should
-stop installation. <font color="#000080"><i>Accept</i></font> validate language choice which are propagated to all
-DrakX visible widget. Advanced mode allow to select other language available to
-be installed. Advanced mode allow to select language which will be installed on
-system.
- If step is redone, the license is no more displayed.
-
- <font color="#000080"><i>Select Install Class</i></font>: step always displayed. default choice is previous one
-or <font color="#000080"><i>Recommended</i></font>. Only one other option available is <font color="#000080"><i>Customized</i></font>. Two buttons
-available are <font color="#000080"><i>Install</i></font> or <font color="#000080"><i>Upgrade</i></font>. Available steps (left side) are changed
-according to installation class selected, where the default is the one of
-<font color="#000080"><i>Recommended</i></font> with <font color="#000080"><i>Install</i></font>.
-
- <font color="#000080"><i>Hard Drive Detection</i></font>: step always displayed. In recommended mode,
-automatically done. In Customized mode, all modules that manage SCSI/IDE cards
-are loaded automatically and a question asking for other module to load is
-displayed.
- If clicked later or if to the question to load other module the
-answer is <font color="#000080"><i>Yes</i></font>, a list of module is displayed (or if the question to other
-module to load is. When a module is chosen, two options are available
-<font color="#000080"><i>Autoprobe</i></font> and <font color="#000080"><i>Specify options</i></font>. Autoprobe try to load the module without any
-other user options (default module parameter). Specify options allow user to
-give module parameters individually in a list for all known parameters. At this
-point <font color="#000080"><i>Ok</i></font> or <font color="#000080"><i>Cancel</i></font> are available, Cancel should stop the module installation
-and go to next step. If any error occurs during module installation, a question
-asking to try with other parameter is displayed, the same module is still used.
-
- <font color="#000080"><i>Setup filesystems</i></font>: step always displayed. display a list of available choice
-accoding to what has been probed. May contains <font color="#000080"><i>Use free space</i></font>, "Use existing
-partition<font color="#000080"><i>, </i></font>Use the window partition for loopback<font color="#000080"><i>, </i></font>Use the free space on the
-Windows partition<font color="#000080"><i>, </i></font>Remove Windows(TM)<font color="#000080"><i>|</i></font>Erase entire disk" (according to disk
-configuration =&gt; only one big fat for the first case only), "Custom disk
-partitioning".
- If <font color="#000080"><i>Use free space</i></font> mode, auto allocation in available on available disk.
- If <font color="#000080"><i>Use existing partition</i></font> mode, a list of partition named in Linux
-scheme are displayed with their approximate size in Mb and propose mount point
-to choose in list boxes for each partitions available on hard drive.
- If <font color="#000080"><i>Use the window partition for loopback</i></font> mode, DrakX use available size
-on the windows partition to create a root file and a swap file which will be
-used in loopback, this means this is a lnx4win installation.
- If <font color="#000080"><i>Use the free space on the Windows partition</i></font> mode, DrakX will resize
-the windows partition and allocate true linux filesystem (at least / and swap).
- If <font color="#000080"><i>Remove Windows(TM)</i></font>|<font color="#000080"><i>Erase entire disk</i></font> mode, DrakX clean the
-partition table before auto allocating partition.
- If <font color="#000080"><i>Custom disk partitioning</i></font> mode, diskdrake is launch. TO BE DEFINED to
-change make diskdrake use only advanced mode.
-Diskdrake show all partition of all non-removable disk graphically. All special
-partition are hidden, only user accessible partition are visible: this remove
-extended partition, whole disk partition on sparc platform. Clicking on a disk
-notebook tab show all his partitions. Clicking on a partition show all actions
-available for this partition (depend if customized or advanced mode) as well as
-information on this partition (depend if customized or advanced mode). Most
-diskdrake operation are done without writing on disk (exception are Resizing
-partitions) and everything is written once on the disk when exiting diskdrake,
-at any time if writing partition table is necessary, there are always a dialog
-box asking the user to confirm the write. If no operation are modifying
-partition table, no dialog is displayed on exit (for example if giving mount
-point to partition). General action are available too:
- <font color="#000080"><i>Clear All</i></font>: clear all partition of the given disk.
- <font color="#000080"><i>Auto allocate</i></font>: try to allocate partition in available disk (not the
-seen disk).
- <font color="#000080"><i>Undo</i></font>: undo last operation.
- <font color="#000080"><i>Done</i></font>: quit and save changes.
-Other operations are available in advanced mode:
- <font color="#000080"><i>Rescue partition table</i></font>: try to rescue a lost partition table,
-absolutely no garantee to succeed and may destroy what could be saveable by
-another tools.
- <font color="#000080"><i>Reload</i></font>: reload partition table from disk, erasing all changes in
-memory done by the user.
- <font color="#000080"><i>Wizard</i></font>: go to partition wizard, that the partition filesystems default
-behaviour on startup.
- <font color="#000080"><i>Restore from floppy</i></font>: restore a partition table from previously saved
-partition table from diskdrake.
- <font color="#000080"><i>Save to floppy</i></font>: save partition table to floppy.
- <font color="#000080"><i>Options</i></font>: global options available for filesystem configuration. This
-include <font color="#000080"><i>Removable media automouting supermount</i></font> check box disabled by default.
- Operation available on partition are:
- <font color="#000080"><i>Mount point</i></font>: change or define mount point for partition, only
-available for true filesystem partition.
- <font color="#000080"><i>Resize</i></font>: resize partition, if a specific algorithm to keep data is
-used no data may be lost, else all data are lost but nothing is written by
-diskdrake on the partition data in this last case (this means data can be
-restored by restoring original size and location).
- <font color="#000080"><i>Delete</i></font>: delete partition, if the same partition is created (same type,
-location, size) all data can be restored as diskdrake doesn't write on partition
-data.
- Operation available on partition table but in advanced mode are:
- <font color="#000080"><i>Type</i></font>: change type of partition, all data will be lost but diskdrake as
-above does not destroy them, and everyting can be restored.
- <font color="#000080"><i>Format</i></font>: format partition, at this point, all data ARE LOST.
- <font color="#000080"><i>Mount</i></font>: mount partition now, usefull for swap to increase memory
-capacity for machine low on resource that are not available to complete setup
-filesystem step correctly (problably if a resize partition is used on FAT fs).
-allow Mounting swap on customized mode too.
- A legend for partition type colors is available
-(Ext2,ReiserFS,Swap,FAT,Other,Empty). It has additionnal features to create a
-partition or change its type (only available in advanced mode).
-
- <font color="#000080"><i>Format partitions</i></font>: step always displayed. display list of partition to
-format with click boxes. Some are defined according to type of partitions and if
-the partition has been created or taken back.
-If a partition has already been formated, it is not proposed, or if it should
-not be proposed (alrady existing partition like /mnt/windows).
-On Advanced tag, an additional dialog is displayed to select partition to format
-(all available partition listed) and to format them with bad block checking.
-
- <font color="#000080"><i>Choose packages</i></font>: step always displayed. default selection done to be
-<font color="#000080"><i>correct</i></font> according to size available, Install or Upgrade, Hardware available.
-This selection is done according to <font color="#000080"><i>Mandrake first choice</i></font> of packages.
-On all mode, display groups and main desktop used (KDE or Gnome), an
-individual package selection check box is available to allow selecting package
-individually. In this case, a dialog displaying a tree with groups, (Mandrake
-first choice/alternatives) and packages is shown on the left part, a description
-window for each packages is shown on the right part.
-
- <font color="#000080"><i>Install system</i></font>: step always displayed. no interactive and display
-installation progression. include if available and on a CD basis a spash screen
-of advertising and other (pub!).
-
- <font color="#000080"><i>Hardware panel</i></font>: step always displayed. show current configuration for
-Mouse, Keyboard, TimeZone, Graphic/TV Card, Monitor.
-At each values chosen (list boxes displayed a
-synthesis description) the current dialog is removed from screen and specific
-configuration panels are displayed (like currently for mouse, keyboard ...).
-And end of these specific configuration panels, this one is remapped on screen
-to be accepted in general.
-
- <b>Sub steps of Hardware panel:</b>
-
- <font color="#000080"><i>Configure mouse</i></font>: displayed on request or if the mouse has not been
-moved (so unsafe detection), but have to be displayed earlier. A mouse tree
-selection for type is displayed with default case as what is probed or
-<font color="#000080"><i>serial/Generic 2 button Mouse</i></font> if none has been probed. <font color="#000080"><i>Cancel</i></font> disable mouse
-modification and <font color="#000080"><i>Ok</i></font> allow next mouse configuration dialog. Then comes a serial
-port dialog for serial mice (default mouse connected to COM1 if nothing found).
-Then a mouse screen control is chown (according to mouse capacity: 3 buttons
-with or without mouse, need 7 buttons checking ?). Here <font color="#000080"><i>Ok</i></font> validate to go to
-next step and <font color="#000080"><i>Cancel</i></font> to first mouse dialog displayed (mouse tree selection for
-type).
-
- <font color="#000080"><i>Configure keyboard</i></font>: displayed on request. default is set according to
-TimeZone definition (itself defaulting to language selection at the beginning).
-A list of keyboard is shown to the user and <font color="#000080"><i>Ok</i></font> validates change and return to
-<font color="#000080"><i>Hardware panel</i></font> dialog with enabled change. <font color="#000080"><i>Cancel</i></font> abort any modification and
-return to the same <font color="#000080"><i>Hardware panel</i></font> dialog.
-
- <font color="#000080"><i>Configure timezone</i></font>: displayed on request. default is set according to
-language selection. A timezone tree selection is shown with only the subtree
-corresponding to the current selection expanded (as other tree dialog). <font color="#000080"><i>Ok</i></font>
-validates change and return to <font color="#000080"><i>Hardware panel</i></font> dialog whereas <font color="#000080"><i>Cancel</i></font> avoid
-the change before returning to the same main dialog.
-
- <font color="#000080"><i>Graphic Card</i></font>: display graphic card probed. No change available.
-
- <font color="#000080"><i>TV Card</i></font>: display TV/Tuner card probed. No change available.
-
- <font color="#000080"><i>Monitor</i></font>: need execution of ddcxinfos at this point. Only Size, Max
-resolution and depth displayed. No change available.
-
-
- Miscellaneous step have been removed and dispatched to other steps. "Use
-hard drive optimisation<font color="#000080"><i> and </i></font>Enable num lock at startup<font color="#000080"><i> are removed. </i></font>Choose
-security level<font color="#000080"><i> is moved to security step. </i></font>Precise RAM size if needed" and
-<font color="#000080"><i>Clean /tmp at each boot</i></font> are moved to bootloader step.
-<font color="#000080"><i>Removable media automouting</i></font> is moved to diskdrake options.
-
- <font color="#000080"><i>Security</i></font>: step displayed only in customized mode. TO BE DEFINED. should
-display at least securty level to choose. level are <font color="#000080"><i>Low</i></font>, <font color="#000080"><i>Medium</i></font>, <font color="#000080"><i>High</i></font> and
-for advanced there are <font color="#000080"><i>Welcome To Crackers</i></font>, <font color="#000080"><i>Poor</i></font>, <font color="#000080"><i>Paranoid</i></font> too.
-
- <font color="#000080"><i>Configure networking</i></font>: step always displayed. dialog always displayed in
-both <font color="#000080"><i>Recommended</i></font> and <font color="#000080"><i>Customized</i></font> mode. A list of network configuration
-entries are shown with the following:
- <font color="#000080"><i>Configure a normal modem connection</i></font>
- <font color="#000080"><i>Configure an ISDN connection</i></font>
- "Configure a DSL (or ADSL) connection
- <font color="#000080"><i>Configure a cable connection</i></font>
- <font color="#000080"><i>Configure local network</i></font>|<font color="#000080"><i>Reconfigure local network</i></font>
- <font color="#000080"><i>Disable networking</i></font>|<font color="#000080"><i>Enable networking</i></font>
- <font color="#000080"><i>Done</i></font>
- By cliking on a specific item, another dialog is displayed to configure
-some specific part of the network.
- <font color="#000080"><i>Configure a normal modem connection</i></font>: display a question to probe for a
-modem if not already detected, then if none are found or probe has been refused
-a list of possible serial device are listed (in the form ttySx / COM(x+1) with
-the current mouse device removed if it is serial). After that a dialog including
-all parameters than can be used is shown. This includes <font color="#000080"><i>Connection Name</i></font>,
-<font color="#000080"><i>Phone number</i></font>, <font color="#000080"><i>Login ID</i></font>, <font color="#000080"><i>Password</i></font>, <font color="#000080"><i>Authentication</i></font>, <font color="#000080"><i>Domain name</i></font>, <font color="#000080"><i>DNS 1</i></font>
-and <font color="#000080"><i>DNS 2</i></font>. Authentication is a combo of <font color="#000080"><i>PAP</i></font>, <font color="#000080"><i>Termina-Based</i></font> and
-<font color="#000080"><i>Script-Based</i></font> (It seems necessary to get CHAP back on this one, no way of
-testing TO BE DEFINED). If no DNS are given, the connection is configured to try
-using provider DNS. <font color="#000080"><i>Ok</i></font> and <font color="#000080"><i>Cancel</i></font> button are available.
- <font color="#000080"><i>Configure an ISDN connection</i></font>:
-Try to detect some PCI card. If not detected, asks if it's a ISA/pcmcia or PCI
-card, and gives the list of the cards. Information are then asked:
-<font color="#000080"><i>Card IRQ</i></font> only if ISA/pcmcia
-<font color="#000080"><i>Card mem (DMA)</i></font> only if ISA/pcmcia
-<font color="#000080"><i>Card IO</i></font> only if ISA/pcmcia
-<font color="#000080"><i>Card IO_0</i></font> only if ISA/pcmcia with io0
-<font color="#000080"><i>Card IO_1</i></font> only if ISA/pcmcia with io1
-<font color="#000080"><i>Your personal phone number</i></font> phone
-<font color="#000080"><i>Provider name (ex provider.net)</i></font>
-<font color="#000080"><i>Provider phone number</i></font>
-<font color="#000080"><i>Provider dns 1</i></font>
-<font color="#000080"><i>Provider dns 2</i></font>
-<font color="#000080"><i>Dialing mode</i></font> auto or manual
-<font color="#000080"><i>Account Login (user name)</i></font>
-<font color="#000080"><i>Account Password</i></font> hided
-<font color="#000080"><i>Confirm Password</i></font> again
- <font color="#000080"><i>Configure a DLS (or ADSL) connection</i></font>:
-The user chooses between pptp, pppoe and dhcp. If dhcp, redirection to LAN.
-If there is more than one ethernet card, The user must choose the card to use
-(displayed with the module). After that, some informations are asked:
-<font color="#000080"><i>Provider name (ex provider.net)</i></font>
-<font color="#000080"><i>Provider dns 1</i></font>
-<font color="#000080"><i>Provider dns 2</i></font>
-<font color="#000080"><i>Account Login (user name)</i></font>
-<font color="#000080"><i>Account Password</i></font> hided
-<font color="#000080"><i>Confirm Password</i></font> again
- <font color="#000080"><i>Configure a cable connection</i></font>: redirection to LAN
- <font color="#000080"><i>Configure local network</i></font>: display what has been probed with a question
-about using another module and <font color="#000080"><i>Yes</i></font>, <font color="#000080"><i>No</i></font> and <font color="#000080"><i>See hardware info</i></font> buttons.
-<font color="#000080"><i>No</i></font> is the default. If <font color="#000080"><i>Yes</i></font> is clicked a list of modules is displayed with
-<font color="#000080"><i>Ok</i></font> or <font color="#000080"><i>Cancel</i></font> buttons available. <font color="#000080"><i>Cancel</i></font> should go back to previous
-question. If <font color="#000080"><i>See hardware info</i></font> is clicked a list of probed hardware is
-displayed. If <font color="#000080"><i>Yes</i></font> is clicked, for each ethernet interface, a dialog asking for
-IP address, Netmask and Automatic IP check box (DHCP/BOOTP) is displayed. Then
-if DHCP has been chosen, only a dialog asking for Host name and another for HTTP
-proxy and FTP proxy if any. If DHCP has not been chosen, an IP address has to be
-defined and a dialog including <font color="#000080"><i>Host name</i></font>, <font color="#000080"><i>DNS server</i></font>, <font color="#000080"><i>Gateway</i></font> and "Gateway
-device" is displayed. Then the same HTTP proxy and FTP proxy dialog as above. As
-network configuration may to have been reworked a bit it has TO BE DEFINED if
-this is kept like that or not.
- <font color="#000080"><i>Disable networking</i></font>|<font color="#000080"><i>Enable networking</i></font> is just a way to toggle
-networking on or off, may be to be accessible only for advanced mode.
- <font color="#000080"><i>Quit</i></font> exit the network step.
-
-<b>NETWORK ADVANCED DOCUMENTATION:</b>
-Here is a list of entry points available in post install without using the ugly
-install graphic toolkit:
-
-<a href=<font color="#000080"><i>http://www.mandrakesoft.com/~damien/html/draknet_advanced_doc.txt</i></font>>http://www.mandrakesoft.com/~damien/html/draknet_advanced_doc.txt</a>
-
- <font color="#000080"><i>Configure Printer</i></font>: step always displayed. In recommended mode, only
-activated if a local printer is detected, else no printer are configured by
-default. In customized mode or if the step has been clicked a list of printer
-already configured is displayed and the possibility to add or exit the
-configuration. It allow configuration of printers for both LPR and CUPS
-individually (available by advanced mode when adding a printer). Printer
-protocol managed are local/usb/samba/ncp/lpd for LPR and
-local/usb/serial/samba/lpd/cups_network for CUPS.
-
- <font color="#000080"><i>Set root password</i></font>: step always displayed for Install only. In
-recommended mode display only a <font color="#000080"><i>Password</i></font> entry and a <font color="#000080"><i>Password (again)</i></font> entry
-to select the root password. In advanced mode, a Use NIS (yellow pages) check
-boxes and Use MD5 check box are available. <font color="#000080"><i>Ok</i></font> validate root password and "No
-password<font color="#000080"><i> avoid setting a password. </i></font>No password<font color="#000080"><i> is only available in </i></font>Low"
-security level or less. The length of the minimal password depend upon security level.
-
-In corporate firewall :
- <font color="#000080"><i>Set admin password</i></font>: step always displayed for Install only. It only
- displays a <font color="#000080"><i>Password</i></font> entry and a <font color="#000080"><i>Password (again)</i></font> entry
-to select the admin password.
-The length of the minimal password depend upon security level. (double of the
- security level)
-
- <font color="#000080"><i>Add a user</i></font>: step always displayed for Install Only. In recommend mode
-display <font color="#000080"><i>Real name</i></font>, <font color="#000080"><i>User name</i></font>, <font color="#000080"><i>Password</i></font>, <font color="#000080"><i>Password (again)</i></font> and icon
-choices as graphical. For customized mode a shell combo is available to choose a
-specific shell for the user depending on the package installed. The real name is
-the user friendly name of the user whereas user name is its login id name. The
-box display user that have already been added below the title. <font color="#000080"><i>Accept user</i></font>
-button allow the creation of the user and <font color="#000080"><i>Done</i></font> finish this step. High or
-higher security level implies the creation of at least one user. Password length
-are subject to same restriction according to security level. In advanced mode,
-allow to choose the user in auto login mode.
-
- <font color="#000080"><i>Create a boot disk</i></font>: step always displayed. In recommended mode this
-step is automatically done by doing nothing. If clicked or customized mode, the
-user is prompted to allow building a boot disk (default is yes). In advanced
-mode allow selection of floppy drive.
-
- <font color="#000080"><i>Install boot loader</i></font>: step always displayed. In recommended mode this
-step is automatically done. In customized mode, a combo <font color="#000080"><i>Boot device</i></font> list the
-various boot device that can be used where the bootloader can be installed. The
-boot device can the Linux description of the whole disk available (ex: /dev/hda)
-or partition available in these disk or floppy drives. Other platform
-specificity are not listed here.
- LBA check box is displayed in advanced mode (enabled by default) to
-allow using LBA addressing if available (PC with LILO). bootloader combo to
-select a given bootloader to use, available choice are <font color="#000080"><i>Grub</i></font>, "LILO with text
-menu<font color="#000080"><i>, </i></font>LILO with graphical menu<font color="#000080"><i>. default chosen is </i></font>LILO
-with graphical menu<font color="#000080"><i>. </i></font>Delay before booting default image" entry
-field is available with default value current setting (upgrade) or 5 else.
-<font color="#000080"><i>Precise RAM size if needed (found xx MB)</i></font> entry is displayed too,
-<font color="#000080"><i>clean /tmp</i></font> check box is disabled by default too.
-Boot in graphical mode (init 5) is available here in advanced mode too
-(previously in X configuration). <font color="#000080"><i>Video mode</i></font> combo, <font color="#000080"><i>Password</i></font>, <font color="#000080"><i>Password (again)</i></font>,
-<font color="#000080"><i>Restrict command line options</i></font> check box is displayed.
-Video mode combo list text mode and video mode used for frame buffer, video mode
-used for frame buffer are available only if the install managed to boot with
-frame buffer activated. Password are restricted according to security level as
-other password. Password are mandatory according to security level TO BE DEFINED.
-
- <font color="#000080"><i>Configure X</i></font>: step always displayed. By default on recommended mode,
-everything is done automatically if possible up to test of graphic card, and if
-the user accept the settings no more question are asked to him. In customized
-mode a dialog is displayed to choose resolution, color depth and which version
-of XFree (with 3D optionally) is available for the current card where only a
-short description is displayed. <font color="#000080"><i>Ok</i></font> button allow to jump to test phase (for the
-first time only) if available. <font color="#000080"><i>Cancel</i></font> return to main XFree configuration
-window allowing to change Monitor, Graphic card, Server options or Resolution
-with X version to choose. <font color="#000080"><i>Show all</i></font> extend resolution list to more resolutions
-according to card (with onboard memory) only and no more monitor capabilities.
- The main dialog is a list of command to change some X configuration aspect
-according to advanced mode or not :
- <font color="#000080"><i>Change Monitor</i></font>: display a tree selection of monitors where default one
-is selected. <font color="#000080"><i>Ok</i></font> and <font color="#000080"><i>Cancel</i></font> buttons are available.
- <font color="#000080"><i>Change Graphic card</i></font>: display a tree selection of graphic card where
-default one is selected. <font color="#000080"><i>Ok</i></font> and <font color="#000080"><i>Cancel</i></font> buttons are available. If <font color="#000080"><i>Unlisted</i></font>
-is chosen, then a tree of server/driver is displayed containing available server
-for XF3 or driver for XF4. <font color="#000080"><i>Cancel</i></font> return to main window and <font color="#000080"><i>Ok</i></font> validates
-change.
- <font color="#000080"><i>Change Server options</i></font>: available only in advanced mode. display list
-of check boxes options for server currently used. <font color="#000080"><i>Ok</i></font> and <font color="#000080"><i>Cancel</i></font> available.
- <font color="#000080"><i>Change Resolution</i></font>: change resolution and depth including with X server
-version chosen (relative to Xdrakres too).
- <font color="#000080"><i>Show Information</i></font>: display an information dialog showing current
-configuration internals of X.
- <font color="#000080"><i>Test again</i></font>: restart test with current configuration of X.
- <font color="#000080"><i>Quit</i></font>: exit X configuration main window. Other question about autologin
-and window manager to use are asked on Add user step.
-
- <font color="#000080"><i>Exit install</i></font>: step displayed only in customized mode but always
-executed. Only a text is displayed with a <font color="#000080"><i>Ok</i></font> button. If clicked and some step
-have not been executed/completed correctly, a question dialog ask the user if he
-really want to quit now, default answer is <font color="#000080"><i>No</i></font>. Advanced switch let user access
-to do the previously <font color="#000080"><i>Auto install floppy</i></font> step in DrakX &lt; 8.0. This is just a
-question asking the user to generate an auto install floppy automatically.
-</pre>
-</body>
-</html>
diff --git a/docs/wizard.doc b/docs/wizard.doc
deleted file mode 100644
index 0bbf8d254..000000000
--- a/docs/wizard.doc
+++ /dev/null
@@ -1,31 +0,0 @@
-How to handle wizard?
-
-to switch in wizard mode:
-set $::isWizard to true;
-if $::Wizard_no_previous is set to true, the wizard won't display the previous button. Usefull for first step
-if $::Wizard_finished is set to true, the wizard will display Finish instead of Next. Usefull for last step
-
-how to code:
-Code as if there were no wizard.
-OK button is displayed as Next
-Cancel is displayed as Previous
-a additional button Cancel is added, xhich die with the exception 'wizard_cancelled'
-
-You have to handle the previous button. For example:
-
-step 1:
-ask_from list( blablablabl) or return;
-step2:
-ask_from list( blablablabl) or goto step1;
-step3:
-ask_from list( blablablabl) or goto step2;
-
-etc... You don't have to handle the wizard Cancel button as it send an exception.
-
-Understood? If yes, you'll see that there is a pb with ask_yesorno. In this case, yes+next returns true, no+next returns false, Cancel send the exception 'wizard_canceled' and previous send the exception 'wizard previous'. So you have to handle the previous button manually.
-
-plop.
-
-dam's, pour vous servir
-
-
diff --git a/globetrotter/.perl_checker b/globetrotter/.perl_checker
deleted file mode 100644
index 444722de3..000000000
--- a/globetrotter/.perl_checker
+++ /dev/null
@@ -1,8 +0,0 @@
-Carp::Heavy
-Digest::base
-Gtk2::Gdk::Keysyms
-Net::Ping
-packdrake
-urpm
-warnings
-Packdrakeng
diff --git a/globetrotter/ChangeLog b/globetrotter/ChangeLog
deleted file mode 100644
index 9dad9b73a..000000000
--- a/globetrotter/ChangeLog
+++ /dev/null
@@ -1,276 +0,0 @@
-2005-06-09 13:43 Thierry Vignaud <tvignaud at mandriva.com>
-
- * Makefile: (changelog) only track HEAD changes
-
-2005-06-09 13:07 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: - sync with DrakX's API - add a few comments - we only
- need 4.6Gb for packages now (the DVD image) - update package
- list: o for 10.0 -> LE2005 changes (eg: switch to dkms and the
- like) o install all languages (marketing request) o install
- multimedia plugins & Java runtime environment o do not unselect
- anymore input methods
-
-2005-06-09 12:58 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: (installPackages) help packages' post-install scripts
-
-2005-06-09 12:58 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: (installPackages) help DrakX more
-
-2005-06-09 12:55 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: detect both old and new LaCie models
-
-2005-06-09 12:52 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: prevent building a disk w/o translation catalogs
-
-2005-06-09 12:50 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: prevent warning message about /proc to appear at boot
-
-2005-06-09 12:49 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: - urpmi syntax had changed - install all new media
-
-2005-06-09 12:48 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: devfs is dead
-
-2005-06-09 12:46 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: save X.org conf too on profile switch
-
-2005-06-09 12:31 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: set $::build_globetrotter
-
-2005-06-09 12:13 Thierry Vignaud <tvignaud at mandriva.com>
-
- * move.pm: (install2::configMove) prevent dm service to fail to
- startup because of /tmp/.font-unix's permissions
-
-2005-06-09 12:11 Thierry Vignaud <tvignaud at mandriva.com>
-
- * move.pm: (install2::configMove) workaround init reading inittab
- before any.pm alters it
-
-2005-06-09 12:09 Thierry Vignaud <tvignaud at mandriva.com>
-
- * move.pm: sync with drakx's API
-
-2005-06-09 12:08 Thierry Vignaud <tvignaud at mandriva.com>
-
- * move.pm: (automatic_xconf) class_discard is needed way earlier
-
-2005-06-09 12:07 Thierry Vignaud <tvignaud at mandriva.com>
-
- * move.pm: (install2::configMove) fix killing X11 due to XFree86 ->
- X.org switch
-
-2005-06-09 12:06 Thierry Vignaud <tvignaud at mandriva.com>
-
- * move.pm: (install2::configMove) if formatError() returns nothing,
- better display the raw error
-
-2005-06-09 11:59 Thierry Vignaud <tvignaud at mandriva.com>
-
- * Makefile: fix build
-
-2005-06-09 11:59 Thierry Vignaud <tvignaud at mandriva.com>
-
- * .perl_checker: blacklist more pakcages
-
-2005-06-09 11:58 Thierry Vignaud <tvignaud at mandriva.com>
-
- * runstage2: fix comment
-
-2005-06-02 05:20 Olivier Blin <oblin at mandriva.com>
-
- * hwprofile: fix netprofile stuff
-
-2005-05-25 10:56 Thierry Vignaud <tvignaud at mandriva.com>
-
- * fix-broken-hd.diff: fix broken hd
-
-2005-05-25 10:45 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: unmount partitions even when failled
-
-2005-05-25 10:41 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: display message earlier
-
-2005-05-25 10:40 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: on restoration, tell which one is the packages
- partition when found
-
-2005-05-25 10:39 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: nicely tell that the restoration is completed
-
-2005-05-25 10:39 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: use newly introduced my_exit() in order to display
- better messages
-
-2005-05-25 10:37 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: (my_exit) introduce it for smoother messages
-
-2005-05-25 10:36 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: handle smoothly packages partition with multiple
- kernel packages
-
-2005-05-25 10:35 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: fix fs checking prior to restoration, thus handling
- restoration on fscked hard disks
-
-2005-05-25 10:34 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: when we format the root fs prior to restoring the hd,
- set back the label on the fs so that we can handle an aborted
- restoration (power outrage, ...)
-
-2005-05-25 10:33 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: factorize some code through find_partition()
-
-2004-10-26 17:18 Thierry Vignaud <tvignaud at mandriva.com>
-
- * make_live: do not try to run killall until it has been installed
-
-2004-10-07 02:44 Pixel <pixel at mandriva.com>
-
- * move.pm: - XFdrake can detect a auxmouse which was not detected
- by mousedrake so we need to call various_xfree_conf() - this
- implies adding parameter $do_pkgs to a few functions
-
-2004-08-27 08:11 Thierry Vignaud <tvignaud at mandriva.com>
-
- * ChangeLog: initial commit
-
-2004-08-27 08:10 Thierry Vignaud <tvignaud at mandriva.com>
-
- * Makefile: add changelog target
-
-2004-07-20 04:42 Pixel <pixel@mandrakesoft.com>
-
- * hwprofile, move.pm, runstage2: MandrakeSoft -> Mandrakesoft
-
-2004-07-09 04:47 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: sometimes grub return non zero exit status w/o error
-
-2004-07-09 04:46 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: kill debug message
-
-2004-07-09 04:16 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: do not complain about unmounted usb fs in recue mode
-
-2004-07-09 03:45 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: fix restore mode (initrd's mount failled to mount ext2
- as ext3)
-
-2004-06-30 10:14 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * doc/BUILD: fix build explanation (else make_live will horribly
- die due to missing functions :-()
-
-2004-06-30 09:25 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * doc/BUILD: update how to build instructions
-
-2004-06-30 08:13 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * doc/BUILD: do not forget to update hdlists
-
-2004-06-30 08:12 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * README: fix required packages list
-
-2004-06-30 07:24 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: display a nicer error message when disk is not found
-
-2004-06-29 08:25 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: fix umounting
-
-2004-06-29 05:28 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: unselect uim since mdk10 package of uim IM break first
- time wizard when selecting english
-
-2004-06-29 04:09 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: perl_checker cleanups
-
-2004-06-29 03:36 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: add rescue support
-
-2004-06-24 11:41 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: (installPackages) kill debugging statements
-
-2004-06-24 10:17 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * hwprofile: create hw profile after having run first time wizard
- so that if one refuse the icense, he has to run it again
-
-2004-06-24 07:39 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: make share partition be writeable by unpriviliegied
- users
-
-2004-06-24 07:33 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: add fb2png in order to be able to take screenshots
-
-2004-06-24 07:31 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: per machine firewall configuration
-
-2004-06-18 05:44 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: force installation of both 2.4.x and 2.6.x centrino
- drivers
-
-2004-06-18 05:44 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: - use labels for home and packages partitions too -
- mount packages partition in read-only mode
-
-2004-06-18 04:08 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * make_live: install autologin as requested by QA
-
-2004-06-15 18:56 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * README: update package versions to reflect current globetrotter
-
-2004-06-15 18:54 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * README: update what's required in new initscripts
-
-2004-06-15 18:50 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * .perl_checker, Makefile, README, hwprofile, make_live,
- mandrake-globetrotter.spec, move.pm, runstage2, doc/BUGS,
- doc/BUILD, doc/NOTES: Imported Globetrotter
-
-2004-06-15 18:50 Thierry Vignaud <tvignaud@mandrakesoft.com>
-
- * .perl_checker, Makefile, README, hwprofile, make_live,
- mandrake-globetrotter.spec, move.pm, runstage2, doc/BUGS,
- doc/BUILD, doc/NOTES: Initial revision
-
diff --git a/globetrotter/Makefile b/globetrotter/Makefile
deleted file mode 100644
index d6a0756cd..000000000
--- a/globetrotter/Makefile
+++ /dev/null
@@ -1,97 +0,0 @@
-PACKAGE=mandrake-globetrotter
-PKGVERSION:=$(shell rpm -q --qf '%{VERSION}\n' --specfile $(PACKAGE).spec|head -n 1)
-RELEASE:=$(shell rpm -q --qf '%{RELEASE}\n' --specfile $(PACKAGE).spec|head -n 1)
-TAG := $(shell echo "V$(PKGVERSION)_$(RELEASE)" | tr -- '-.' '__')
-
-DIRS=share/po
-PREFIX =
-
-SBINDIR = $(PREFIX)/usr/sbin
-LIBDIR = $(PREFIX)/usr/lib
-LIBDEST = $(LIBDIR)/libDrakX
-DATADIR = $(PREFIX)/usr/share
-
-LANG_FILES = pixmaps/langs
-DISTFILES = hwprofile *.spec share/po/*.po share/po/Makefile Makefile Makefile.config *.pm runstage2 $(LANG_FILES)
-
-.PHONY: all install clean
-
-all:
- rm -f share/po/DrakX.pot # force rebuild of po's
- make -C share/po mofiles
-
-
-localcopy: clean
- cd .. ; rm -rf $(PACKAGE)-$(PKGVERSION) ; cp -af globetrotter $(PACKAGE)-$(PKGVERSION)
- # include pixmaps for language selector:
- mkdir ../$(PACKAGE)-$(PKGVERSION)/{pixmaps,share}
- cp -af ../perl-install/pixmaps/langs ../$(PACKAGE)-$(PKGVERSION)/pixmaps/langs
- # include drakx modules for first time wizard :
- # cp -af ../perl-install/share/po ../$(PACKAGE)-$(PKGVERSION)/share/
- mkdir ../$(PACKAGE)-$(PKGVERSION)/share/po
- # cp -af ../perl-install/share/po/{fr.po,Makefile,i18n_compssUsers} ../$(PACKAGE)-$(PKGVERSION)/share/po
- cp -af ../perl-install/share/po/{*.po,Makefile} ../$(PACKAGE)-$(PKGVERSION)/share/po
- # enable fast build:
- perl -pi -e 's!^.*msgmerge.*\n!!' ../$(PACKAGE)-$(PKGVERSION)/share/po/Makefile
- cp -af ../perl-install/{help,pkgs,install*}.pm ../$(PACKAGE)-$(PKGVERSION)/
- echo 'ALLPMS = *.pm' > ../$(PACKAGE)-$(PKGVERSION)/Makefile.config
- @make nuke_perl
-
-
-install:
- install -d $(LIBDEST) $(DATADIR)/libDrakX/pixmaps/langs $(SBINDIR)
- install -m 644 *.pm $(LIBDEST)
- install -m 755 runstage2 $(SBINDIR)/mdkmove
- cp -f pixmaps/langs/lang-*.png $(DATADIR)/libDrakX/pixmaps/langs
- $(MAKE) -C share/po install PREFIX=$(PREFIX) SUDO= DATADIR=$(DATADIR) NAME=libDrakX2
-# %make -C po install SUDO= NAME=libDrakX2 LOCALEDIR=$(DEST)/usr/share/locale_special
-
-
-rpm: localrpm
-localrpm: localdist buildrpm
-
-srpm: localsrpm
-localsrpm: spec_test localdist buildsrpm
-
-localdist: cleandist localcopy tar
-
-cleandist:
- rm -rf ../$(PACKAGE)-$(PKGVERSION) ../$(PACKAGE)-$(PKGVERSION).tar.bz2
-
-spec_test:
- @if [[ -z "$(PKGVERSION)" ]]; then echo "unable to get spec version"; exit 3;fi
- @if [[ -z "$(RELEASE)" ]]; then echo "unable to get spec release"; exit 2;fi
-
-tar:
- cd ../$(PACKAGE)-$(PKGVERSION) && rm -rf debug.log `find -name CVS`
- cd ..; tar cfj $(PACKAGE)-$(PKGVERSION).tar.bz2 $(patsubst %,$(PACKAGE)-$(PKGVERSION)/%,$(DISTFILES))
- #cd ..; rm -rf $(PACKAGE)-$(PKGVERSION)
-
-buildrpm:
- rpm -ta ../$(PACKAGE)-$(PKGVERSION).tar.bz2
-
-buildsrpm:
- rpm -ts --nodeps ../$(PACKAGE)-$(PKGVERSION).tar.bz2
-
-# rules to build a distributable rpm
-
-dist: cleandist export tar
-
-export:
- cd ..; cvs export -d $(PACKAGE)-$(PKGVERSION) -r $(TAG) $(PACKAGE)
- cd ../$(PACKAGE)-$(PKGVERSION)
- cd ..;
- @make nuke_perl
-
-nuke_perl:
- find ../$(PACKAGE)-$(PKGVERSION) -name '*.pm' | xargs perl -pi -e 's/\s*use\s+(diagnostics|strict|vars|warnings).*//g'
-
-img:
- /usr/bin/lilo-bmp2mdk mode:0x103 progress:397,190,14,6,64+8 clear:600,800,64+8 pos:0,0 < BOOTGTROTTER-install-lilo-8bis.bmp > isolinux_boot.msg
-
-.PHONY: log changelog
-
-log: changelog
-
-changelog:
- cvs2cl --accum -W 400 -U ../../soft/common/username -F TRUNK
diff --git a/globetrotter/README b/globetrotter/README
deleted file mode 100644
index 7052212b3..000000000
--- a/globetrotter/README
+++ /dev/null
@@ -1,64 +0,0 @@
- Mandrakelinux GlobeTrotter, powered by LaCie Mobile Hard Drive project
- ======================================================================
-
-
-
-Requirements:
-=============
-
-1) packages:
-------------
-
-you need to have the distro repositery mounted in /export.
-
-on top of the mdk10.0 base + its updates, the following packages were
-updated from cooker:
-
-- misc bug fixes:
- o drakconf-10-13mdk
- o {drakxtools,harddrake}*-10-34.2mdk
- o mdkonline-1.1-2.1.100mdk
- o menudrake-0.7.4-8mdk
- o perl-Libconf*-0.33-2mdk
- o rpmdrake-2.1.3-5mdk
- o initscripts-7.06-49.1mdk:
- * usb starting when usb host drivers were loaded by initrd
- * fix larsen on laptops
-- root=LABEL=foobar and boot from USB support:
- o mkinitrd-3.5.18-10mdk
- o bootloader-utils-1.7-1mdk
-- coexistance:
- o glibc with /etc/ld.so.conf.d/ support
- o ATI driver
- o NIVIDIA driver
-- new packages:
- o kdetv, libkdevideo
-- should we also take new kernel?
-
-Note: once you've updated some packages, you need to run "gendistrib
- /export".
-
-
-2) local checkout of drakx:
----------------------------
-
-you need a copy of gi/perl-install in ../perl-install as well as
-gi/mdk-stage1.
-
-you need to install the following packages: gcc, e2fsprogs,
-ldetect-devel, libext2fs2-devel, libxfree86-devel, perl-devel,
-perl-URPM, rpm-devel, rpmtools, and urpmi.
-
-then you need to type "make c" in ../perl-install.
-
-last but not least, you need to copy list_modules from gi/kernel into
-perl-instéall and gi/mdk-stage1/pcmcia_/probe.c into perl-install/c.
-
-
-
-Building the hd image:
-======================
-
-just type ./make_live
-
-it'll reformat the hard disk, mount it and install packages \ No newline at end of file
diff --git a/globetrotter/doc/BUGS b/globetrotter/doc/BUGS
deleted file mode 100644
index 97ff5d8b0..000000000
--- a/globetrotter/doc/BUGS
+++ /dev/null
@@ -1,6 +0,0 @@
--*- outline -*-
-
-* drakboot and diskdrake are not yet fully capable of managing LABEL= in
-/tc/fstab
-
-* lilo failed to boot from USB
diff --git a/globetrotter/doc/BUILD b/globetrotter/doc/BUILD
deleted file mode 100644
index 108c44650..000000000
--- a/globetrotter/doc/BUILD
+++ /dev/null
@@ -1,28 +0,0 @@
- How to build Mandrakelinux Globetrotter:
- ========================================
-
-- you need first to install all the drakxtools' build dependancies
- (thus running "urpmi /SRPMS/drakxtools-*" may be quite helpful)
-
-- copy the mdk10.0 DVD in /export
-- leave main as Mandrake/RPMS
-- copy h[cs]f*, FlashPlayer*, RealPlayer* into Mandrake/RPMS from Mandrake/RPMS[23]
-- move contribs as Mandrake/RPMS2
-- move other RPMS? somewhere else
-- add packages from ~tv/rpm/lacie on cluster
-- add updates from /mnt/BIG/dis/updates/10.0
-- add updated proprietary packages for kernel update from kameha
- (nplanel's work machine):
- echo "mget *2.4.25.5mdk* *2.6.3.13mdk*" | \
-lftp -u a,a ftp://kameha:/~/../nplanel/rpm/prop/RPMS/i586/
-- run the following in order to remove duplicated packages:
- doble [A-Z] | xargs rm -f
- doble [a-g] | xargs rm -f
- doble [h-z] | xargs rm -f
-- run "gendistrib --noclean /export"
-- plug the LaCie disk
-- check out the whole gi cvs module
-- run "C_DRAKX=1 make c" in gi/perl-install
-- go into gi/globetrotter
-- run make_live --partition --format --install --post in order to
- prepare the disk
diff --git a/globetrotter/doc/NOTES b/globetrotter/doc/NOTES
deleted file mode 100644
index 5a43af0e2..000000000
--- a/globetrotter/doc/NOTES
+++ /dev/null
@@ -1,17 +0,0 @@
- Mandrakelinux GlobeTrotter release notes
-
-
-
-* Arabic support
-
-
-you may want to enable the acon service from the acon package.
-Just type: "chkconfig --add jserver" as root or use the "Services"
-icon from the Mandrakelinux Control Center
-
-
-* Japanese support
-
-you may want to enable the jserver service from the FreeWnn package.
-Just type: "chkconfig --add jserver" as root or use the "Services"
-icon from the Mandrakelinux Control Center \ No newline at end of file
diff --git a/globetrotter/fix-broken-hd.diff b/globetrotter/fix-broken-hd.diff
deleted file mode 100644
index 6ae7fa491..000000000
--- a/globetrotter/fix-broken-hd.diff
+++ /dev/null
@@ -1,127 +0,0 @@
---- make_live 2005-05-25 17:42:35.000000000 +0200
-+++ make_live 2005-05-25 17:46:41.000000000 +0200
-@@ -8,6 +8,7 @@
- use standalone;
- use interactive;
- use common;
-+use detect_devices;
- use partition_table;
- use fsedit;
- use fs;
-@@ -321,8 +322,116 @@
-
- $::prefix = $ARGV[0] || '/tmp/live_tree';
-
-+#===========================================================================
-+# Fix disk if it's a bogus one:
-+
-+my @packages2delete = qw(
-+ Mandrake/RPMS/uqm-data-0.3-1mdk.noarch.rpm
-+
-+ Mandrake/RPMS2/kernel24-tmb-2.4.25-6.tmb.1mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-2.4.25-7.tmb.1mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-2.4.25-7.tmb.2mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-enterprise-2.4.25-6.tmb.1mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-enterprise-2.4.25-7.tmb.1mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-enterprise-2.4.25-7.tmb.2mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-i686-up-4GB-2.4.25-6.tmb.1mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-i686-up-4GB-2.4.25-7.tmb.1mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-i686-up-4GB-2.4.25-7.tmb.2mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel24-tmb-source-2.4.25-7.tmb.2mdk.i586.rpm
-+
-+ Mandrake/RPMS2/kernel-tmb-2.6.4-1.tmb.8mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-tmb-enterprise-2.6.4-1.tmb.8mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-tmb-i686-up-4GB-2.6.4-1.tmb.8mdk-1-1mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-tmb-source-2.6.4-1.tmb.8mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-2.4.25.5mdk-3-7mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-2.6.3.15mdk-3-8mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-enterprise-2.4.25.5mdk-3-7mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-enterprise-2.6.3.15mdk-3-8mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-i686-up-4GB-2.4.25.5mdk-3-7mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-i686-up-4GB-2.6.3.15mdk-3-8mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-p3-smp-64GB-2.4.25.5mdk-3-7mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-p3-smp-64GB-2.6.3.15mdk-3-8mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-smp-2.4.25.5mdk-3-7mdk.i586.rpm
-+ Mandrake/RPMS2/kernel-win4lin-smp-2.6.3.15mdk-3-8mdk.i586.rpm
-+ );
-+
-+# misc paths;
-+my $pkgs_mount_path = "/mnt/mdk_pkgs";
-+my $rescue_path = "/rescue-glob";
-+my $cd_mount_path = "/mnt/cdrom-glob";
-+
-+# enable to retry fixing partitions if fixing failed:
-+my $__need2befixed_mark = "Mandrake/RPMS/NEED_TO_BE_FIXED";
-+my $need2befixed_mark = "$pkgs_mount_path/__need2befixed_mark";
-+
-+{
-+ mkdir_p($pkgs_mount_path);
-+
-+ my $cleaner = before_leaving {
-+ if (my $err = $@) {
-+ print "\n>> an error happened: $err\n";
-+ }
-+ print "Cleaning on end of fixing\n";
-+ eval { fs::umount($_) } foreach $pkgs_mount_path, $cd_mount_path;
-+ undef $@; # do not propagate fs::umount exceptions
-+ };
-+
-+ print "Checking if the packages partition needs to be fixed\n";
-+ # system("mount /dev/$pkg_dev->{device} $pkgs_mount_path");
-+ fs::mount($pkg_dev->{device}, $pkgs_mount_path, 'ext3');
-+ # my $pkgs_mount_path = "/home/qa/broken"; # FIXME: TESTING
-+
-+ if (any { -e "$pkgs_mount_path/$_" } @packages2delete, $__need2befixed_mark) {
-+ print "Preparing to fixing the partition packages...\n";
-+ touch($need2befixed_mark);
-+
-+ # Cleaning the packages so that we get back some free space:
-+ unlink("$pkgs_mount_path/$_") foreach @packages2delete;
-+
-+
-+ # Lookup rescue CD:
-+
-+ my $cdrom_path;
-+
-+ my @cdroms = map { $_->{device} } detect_devices::cdroms();
-+
-+ mkdir_p($cd_mount_path);
-+
-+ my ($found, $cdrom_dev);
-+
-+ foreach my $cdrom (@cdroms) {
-+ eval { fs::mount($cdrom, $cd_mount_path, 'iso9660', 1) } or next; # nicely handle empty drives
-+ if (-d "$cd_mount_path/$rescue_path") {
-+ $cdrom_dev = $cdrom;
-+ $found = 1;
-+ last;
-+ }
-+ fs:umount($cd_mount_path);
-+ }
-+ undef $@; # do not propagate fs::mount exceptions
-+
-+ if ($found) {
-+ warn "Found rescue CDROM on $cdrom_dev\n";
-+ } else {
-+ warn "I failed to found the rescue CDROM\nPress enter to return to the menu";
-+ <STDIN>;
-+ # TODO : replace by sg else if merged within make_live
-+ exit(0);
-+ }
-+
-+
-+ print "Fixing the partition packages... in progress\n";
-+ # Copy Mandrake/base with the newly generated hdlists from the old repositery;
-+ cp_af($_, "$pkgs_mount_path/Mandrake/base") foreach glob_("$cd_mount_path/$rescue_path/Mandrake/base/*");
-+ cp_af($_, "$pkgs_mount_path/Mandrake/RPMS") foreach glob_("$cd_mount_path/$rescue_path/Mandrake/pkgs/*");
-+ unlink($need2befixed_mark);
-+ print "Fixing the partition packages... done\n";
-+ }
-+}
-+
-+
- #===========================================================================
- # Building the disk:
- -d $::prefix or mkdir $::prefix;
- print "Making live in $::prefix directory.\n";
-
diff --git a/globetrotter/hwprofile b/globetrotter/hwprofile
deleted file mode 100644
index a3b0574dd..000000000
--- a/globetrotter/hwprofile
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (c) 2004 Mandrakesoft
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-use lib qw(/usr/lib/libDrakX);
-
-use common;
-use standalone;
-use Digest::MD5 qw(md5_hex);
-use network::network;
-
-# md5_hex call came from move::machine_ident() :
-my $id = "MDK" . md5_hex(join("", (map { (split)[1] } cat_("/proc/bus/pci/devices"))));
-
-my $net = {};
-
-# first boot wizard:
-!glob_("/etc/netprofile/profiles/MDK*") and system('/usr/sbin/mdkmove');
-
-# create hardware profile if needed:
-if (! -d "/etc/netprofile/profiles/$id") {
- network::network::netprofile_read($net);
- network::network::netprofile_add($net, $id);
-}
-
-# restore hardware profile:
-eval { network::network::netprofile_set($net, $id) };
-
-# redo ldconfig cache for libGL (since we've both ATI and NVIDIA GLX packages):
-system("/sbin/ldconfig");
diff --git a/globetrotter/make_live b/globetrotter/make_live
deleted file mode 100755
index 2c1296e24..000000000
--- a/globetrotter/make_live
+++ /dev/null
@@ -1,538 +0,0 @@
-#!/usr/bin/perl
-
-$::isInstall = 1; # for /root/drakx/ddebug.log
-
-use strict;
-#use lib qw(/usr/lib/libDrakX);
-use lib "../perl-install";
-use standalone;
-use interactive;
-use common;
-use detect_devices;
-use partition_table;
-use fsedit;
-use fs;
-use any;
-use pkgs;
-use class_discard;
-use run_program;
-use modules;
-use modules::modules_conf;
-use modules::any_conf;
-use log;
-
-# my $in = interactive->vnew;
-
-$::isStandalone = undef; # for /tmp/ddebug.log
-$::build_globetrotter = 1;
-$::no_ugtk_init = 1;
-
-my (%options, @new_ARGV);
-
-foreach (@ARGV) {
- if (/^--(.*)/) {
- $options{$1} = 1;
- } else {
- push @new_ARGV, $_;
- }
-}
-
-my $rescue;
-
-if ($0 =~ /restore_globetrotter/) {
- %options = (install => 1, post => 1);
- $rescue = 1;
-}
-
-@ARGV = @new_ARGV;
-
-if (!$rescue) {
- die qq(\%_install_langs is not set to "all" in /etc/rpm/macros) if cat_('/etc/rpm/macros') !~ /\%_install_langs\s*all/;
-}
-
-my @suggestions = (
- { mntpoint => "/", size => 4500 << 11, type => 0x483, ratio => 1, maxsize => 6000 << 11, fs_type => 'ext3' },
- # splited / and /usr:
- # { mntpoint => "/", size => 250 << 11, type => 0x483, ratio => 1, maxsize => 2000 << 11 },
- # { mntpoint => "/usr", size => 300 << 11, type => 0x483, ratio => 4, maxsize => 4000 << 11 },
- { mntpoint => "/home", size => 2000 << 11, type => 0x483, ratio => 3, fs_type => 'ext3' },
-
- # share partition with windows:
- { mntpoint => "/mnt/share", size => 2000 << 11, type => 0xb, ratio => 3, fs_type => 'vfat' },
- { mntpoint => "/mnt/packages", size => 5000 << 11, type => 0x483, ratio => 3, maxsize => 5000 << 11, fs_type => 'ext3' },
- # allocated last b/c end of disk is usually faster:
- { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 1, maxsize => 500 << 11, fs_type => 'swap' },
- );
-
-
-sub get_hds() {
- my $all_hds = fsedit::get_hds();
- my $other;
- ($all_hds->{hds}, $other) = partition { $_->{usb_description} =~ /^LaCie|LaCie Hard( |)Drive USB/ } @{$all_hds->{hds}};
- my_exit("Your disk cannot be restored because it cannot be found!") if !$all_hds->{hds}[0];
- $all_hds, $all_hds->{hds}[0]; # $other
-}
-
-
-sub prepare_disk() {
- # repartion the hard disk:
- print "PARTITIONNING\n";
- my ($all_hds, $hd, $other) = get_hds();
- # partition_table::remove($hd, $_) while partition_table::get_normal_parts($hd);
- run_program::run("swapoff", "/dev/$all_hds->{hds}[0]{device}8") if any { /$all_hds->{hds}[0]{device}/ } cat_("/proc/partitions");
-
- partition_table::raw::zero_MBR_and_dirty($hd);
- fsedit::allocatePartitions($all_hds, \@suggestions);
- require diskdrake::interactive;
- require class_discard;
- # diskdrake::interactive::write_partitions(class_discard->new, $_, 'skip_check_rebootNeeded') foreach (@{$all_hds->{hds}});
- foreach (@{$all_hds->{hds}}) {
- local $::isStandalone = undef;
- print "WRITE PARTITION ON $_->{file}\n";
- diskdrake::interactive::write_partitions(class_discard->new, $_, 'skip_check_rebootNeeded')
- }
- # partition_table::write(@{$all_hds->{hds}});
- ($all_hds, $hd, $other);
-}
-
-
-sub formatdisk {
- my ($hd) = @_;
- print "FORMATTING\n";
- foreach (partition_table::get_normal_parts($hd)) {
- print qq(Formatting "$_->{device}" ($_->{mntpoint})\n);
- require fs::format;
- fs::format::part(undef, $_, $::prefix, undef) if !$::testing;
- }
-}
-
-
-#@ARGV <= 1 or die "usage: make_live [live_location=/tmp/live_tree]\n";
-
- if (!find { m!/proc/bus/usb! } run_program::get_stdout('mount')) {
- warn "USB service is *NOT* started" if !$rescue;
- run_program::get_stdout('service', 'usb', 'start');
- }
-
-sub my_exit {
- my ($msg) = @_;
- print "\n\n==============================================================\n\n";
- print $msg;
- print "\n\nPress <RETURN> to return back to menu\n\n";
- print "==============================================================\n\n";
- <STDIN>;
- c::_exit(0);
-}
-
-sub find_partition {
- my ($label, @parts) = @_;
- find { member(fs::type2fs($_), qw(ext2 ext3)) && chomp_(`e2label /dev/$_->{device} 2>/dev/root`) eq $label } @parts;
-}
-
-my $pkg_dev;
-if ($rescue) {
- system("mount -t tmpfs none /tmp");
- # let be able to see USB devices:
- system("mount -t usbfs none /proc/bus/usb");
- system("modprobe usb-storage; modprobe sd_mod");
- # let be able to detect SCSI hds:
- mkdir("/sys");
- system("mount -t sysfs none /sys");
-
- my ($all_hds, $hd, $other) = get_hds();
- print "Looking for the package partition\n";
- my @parts = partition_table::get_normal_parts($hd);
- $pkg_dev = find_partition("MDK-PKGS", @parts);
- #die "I cannot find the package partition which is needed in order to restore the system!"
- my_exit("Your disk cannot be restored because there is no more a restore partition!") if is_empty_hash_ref($pkg_dev) || !$pkg_dev->{device};
- print "Packages partition was found on $pkg_dev->{device}\n";
- my $root = find_partition("MDK-ROOT", @parts);
- $root = find { $_->{device} eq "sda1" } @parts if is_empty_hash_ref($root);
- #my_exit("I cannot find any hard disk to restore!") if is_empty_hash_ref($root) || !$root->{device};
- my_exit("Your disk cannot be restored because there is no more a root partition!") if is_empty_hash_ref($root) || !$root->{device};
- print "\nPlease wait, disk is being checked, this can take quite some time\n\n";
- run_program::run("e2fsck -C0 -y $_") foreach map {
- my $p = find_partition($_, @parts);
- if_($p, $p->{device}); # handle lost labels
- } "MDK-PKGS", "MDK-HOME"; # MDK-ROOT"
- print "Please wait, disk reinstallation is in progress, this can take quite some time\n";
- print "Formating $root->{device}\n";
- system("mkfs.ext2 -j /dev/$root->{device} > /dev/null\n");
- run_program::run('tune2fs', '-L', "MDK-ROOT", "/dev/$root->{device}"); # prevent lost label if restore aborts before the end
-}
-
-sub installPackages() {
- local $::testing = undef;
-
- # for a gconftool-2 cleaner:
- my $pid = fork();
- !defined $pid and die("cannot fork: $!");
- !$pid and do {
- while (1) {
- sleep(10);
- run_program::run('/usr/bin/killall', 'gconftool-2') if -x '/usr/bin/killall';
- }
- };
- my $_b = before_leaving { kill 'TERM', $pid if $pid };
-
- # ensure no %_install_langs:
- output_p("$::prefix/etc/rpm/macros", "%_install_langs all\n");
- # ensure boot from USB will work:
- output_p("$::prefix/etc/sysconfig/mkinitrd", "forceusb=yes\n");
-
- # help DrakX:
- mkdir_p("$::prefix/$_") foreach qw(tmp/headers var/lib/rpm root/drakx);
-
- # help packages' post scripts:
- run_program::run('mount', '-t', 'procfs', 'none', "$::prefix/proc");
- run_program::run('makedev', "$::prefix/dev");
-
- undef *install_any::setDefaultPackages;
- *install_any::setDefaultPackages = sub {};
-
- undef *install_any::getFile;
- *install_any::getFile = sub {
- my ($f, $o_method) = @_;
- log::l("getFile $f:$o_method");
- open(my $F, '/export/' . install_any::relGetFile($f)) or return;
- $F;
- };
-
- undef *c::kernel_version;
- *c::kernel_version = sub {
- #my @l = glob_('/export/Mandrake/RPMS/kernel-enterprise-2.6*');
- my @l = glob_('/export/media/main/kernel-2.6.*');
- @l >= 1 or die "can't find kernel";
- @l <= 1 or warn "too many kernels";
- first(`rpm -qp --qf '%{name}' $l[-1]` =~ /kernel-(.*)/);
- };
-
- my $kernel_version = c::kernel_version();
- # for third party drivers:
- my $dkms_kernel_version = $kernel_version;
- $dkms_kernel_version =~ s/\.(\d*mdk)$/-$1/;
-
- print "INSTALLING\n";
- install_any::setPackages(my $o = $::o =
- bless {
- prefix => $::prefix,
- meta_class => 'desktop',
- modules_conf => modules::modules_conf::read(modules::any_conf::vnew(), '/tmp/modules.conf'),
- default_packages => [
- #- for screenshots:
- qw(fb2png),
- qw(xorg-x11-server xorg-x11-xfs xorg-x11-FBDev),
- qw(openssh-server), #- fred wants it
- qw(alsa-utils cdialog newt),
- qw(k3b-dvd),
- qw(davfs nfs-utils samba-server sane-backends xsane xsane-gimp ntp),
- qw(acpi acpid), #- so that removing acpi=ht will work
- qw(mountloop), #- crypted folders
- #- doc:
- (map { "mandrake-doc-$_" } map { ("Drakxtools-Guide-$_", "Command-Line-$_", "Quick-Startup-Plus-$_", "Starter-$_") } qw(de en es fr it)),
- qw(autologin grub),
- qw(synaptics),
- #- network conf:
- qw(wireless-tools pcmcia-cs),
- #- zeroconf:
- qw(zcip dhcpcd tmdns),
- #- cnx stuff:
- qw(dhcp-client ppp kdenetwork-kppp ppp-pppoatm ppp-pppoe pptp-linux pptp-adsl rp-pppoe),
- "kernel-$kernel_version",
- #- for older machines:
- "kernel-i586-up-1GB-$kernel_version",
- #- ISDN stuff:
- # qw(isdn4net ibod isdn4k-utils), # not installed since it provides an interface (will be automatically installed by drakconnect)
- #- network file sharing:
- qw(nfs-utils-clients samba-client),
- #- network drivers and firmwares:
- qw(eagle-usb ipw2100-firmware ipw2200-firmware ndiswrapper speedtouch speedtouch_mgmt unicorn),
- #- configuration:
- qw(drakconf drakcronat drakfirsttime drakxtools harddrake-ui mdkonline rpmdrake userdrake),
- qw(cups cups-drivers foomatic-db gimpprint hpoj libnet-snmp mtools mtoolsfm nmap printer-filters printer-testpages printer-utils scli xojpanel xpp), #- printer stuff
- #qw(gcc),
- "ati-kernel-$dkms_kernel_version", "nvidia-kernel-$dkms_kernel_version", qw(ati nvidia dkms dkms-ati dkms-nvidia libMesaGLU1),
- # qw(hcfpcimodem hsflinmodem ltmodem), #- 2.4.x only
- qw(xinput), #- for some mice
- qw(bash-completion binutils emacs-X11 ntsysv perl-doc perl-Term-Readline-Gnu vim-enhanced openssh-clients lftp diffstat), #- allow debugging
- qw(openssh-askpass-gnome), #- openssh-askpass for mountloop doesn't allow to click on ok/cancel buttons
- qw(clanbomber freeciv-client freeciv-server crack-attack kdegames), #- more games
- qw(numlock), # shorewall # not installed since its default config breaks network (will be automatically installed by drakfirewall)
- qw(xawtv zapping kdetv), #- tv apps
- #- locales:
- qw(scim-hangul scim-m17n scim-tables scim-uim), #- Input Methods
- (map { "locales-$_" } qw(af am ar as az be bg bn br bs ca cs cy da de el en eo es et eu fa fi fo fr fur fy ga gd gl gu gv he hi hr hu hy id ik is it iu ja ka kl km kn ko ku kw ky li lo lt lv mi mk ml mn mr ms mt nds ne nl no oc pa ph pl pt ro ru sc se sk sl sq sr st sv sw ta te tg th tk tr tt uk ur uz vi wa xh yi zh zu)),
- (map { "kde-i18n-$_" } qw(af ar az be bg bn br bs ca cs cy da de el en_GB eo es et eu fa fi fo fr ga gl he hi hr hsb hu id is it ja ko ku lo lt lv mi mk mn ms mt nb nds nl nn nso oc pa pl pt pt_BR ro ru se sk sl sr ss sv ta tg th tr uk uz ven vi wa wen xh zh_CN.GB2312 zh_TW.Big5 zu)),
- (map { "koffice-i18n-$_" } qw(af az bg br ca cs cy da de el en_GB eo es et fa fi fr he hsb hu it ja lo lt mt nb nl nn pl pt pt_BR ru se sk sl sr sv ta tg th tr uk ven xh zh_CN zh_TW zu)),
- (map { "OpenOffice.org-l10n-$_" } qw(af ar ca cs cy da de el en es et eu fi fr he hu it ja ko nb nl nn ns pl pt pt_BR ru sk sl sv tr zh_CN zh_TW zu)),
- #- for GNOME:
- qw(gnome2),
- qw(mozilla-firefox gnome-terminal), # QA request
- (map { "mozilla-firefox-$_" } qw(af br ca cs da de devel el es fi fr ga he hu it ja ko nb nl pl pt pt_BR register ro ru sk sl sv tr zh_CN zh_TW)),
- qw(dosfstools mtools),
- qw(koffice konsole),
- qw(udev dynamic harddrake hotplug mandrake-globetrotter netprofile),
- qw(alsa-utils),
- qw(mozilla-firefox),
- #- plugins:
- qw(acroread acroread-nppdf acroread-plugins FlashPlayer j2re RealPlayer RealPlayer-Codecs RealPlayer-rpnp),
- qw(kdebase-nsplugins kdebase-kcontrol-nsplugins),
- #- fonts:
- qw(xorg-x11-100dpi-fonts xorg-x11-75dpi-fonts),
- qw(fonts-bitmap-tscii fonts-hebrew-elmar),
- (map { "fonts-ttf-$_" } qw(arabic armenian bengali big5 decoratives dejavu ethiopic gb2312 japanese kannada korean latex tamil thai tscii vera west_european)),
- (map { "fonts-type1-$_" } qw(cyrillic greek hebrew)),
- ],
- }, 'install_any');
-
- my %rpmsrate_flags_chosen = map { $_ => 1 } map { @{$_->{flags}} } @{$o->{compssUsers}};
- $rpmsrate_flags_chosen{$_} = 0 foreach qw(CAT_NETWORKING_MAIL_SERVERE);
- $rpmsrate_flags_chosen{$_} = 1 foreach qw(CAT_AUDIO CAT_KDE CAT_GNOME CAT_NETWORKING CAT_OFFICE CAT_SYSTEM DVD USB SOUND BURNER UTF8 DOCS TV 3D INSTALL);
- $rpmsrate_flags_chosen{qq(LOCALES"$_")} = 1 foreach lang::langsLANGUAGE({ all => 1 });
- pkgs::setSelectedFromCompssList($o->{packages}, \%rpmsrate_flags_chosen, 4, 0);
-
- my $unselect = sub {
- my ($pkg) = @_;
- my $p = pkgs::packageByName($o->{packages}, $pkg);
- pkgs::unselectPackage($o->{packages}, $p) if $p;
- };
-
- $unselect->("kernel-smp-$kernel_version");
-
- # unselect some packages whose services fsck up the box and whose services are not enabled by appropriate tools:
- # (shorewall must be deselected before iptables is)
- $unselect->($_) foreach qw(at hpoj shorewall iptables ntp tmdns zcip );
-
- # unselect uim since uim IM break first time wizard when selecting english:
- #$unselect->($_) foreach qw(uim-applet uim libuim0);
-
- my @toInstall = pkgs::packagesToInstall($o->{packages});
- local $ENV{DURING_INSTALL} = 1;
- $ENV{LD_LIBRARY_PATH} = "/lib:/usr/lib:/usr/X11R6/lib:/usr/lib/qt3/lib";
- pkgs::install(0, \@toInstall, $o->{packages});
-
- eval { fs::umount("$::prefix/proc") };
-}
-
-sub config_X_proprietary_drivers() {
- unlink "$::prefix/usr/lib/libGL.so";
-
- my %name_to_Driver = (NVIDIA_GLX => 'nvidia', ATI_GLX => 'fglrx');
-
- my $lib = 'libGL.so.1';
- symlinkf("/etc/X11/$lib", "$::prefix/usr/lib/$lib");
- foreach (keys %name_to_Driver) {
- my ($full_name) = run_program::rooted_get_stdout($::prefix, 'rpm', '-ql', $_) =~ m!/usr/lib/(\Q$lib\E\..*)! or die '';
- symlinkf($full_name, "$::prefix/usr/lib/$lib.$name_to_Driver{$_}");
- }
- #- remove the dirty hack done by NVIDIA_kernel-xxx proprietary package
- #- we do it by hand when needed
- substInFile { $_ = '' if $_ eq 'nvidia' } "$::prefix/etc/modules";
-}
-
-my $fstab;
-
-my $cleaner = before_leaving {
- if (my $err = $@) {
- print "\n>> an error happened: $err\n";
- }
- print "Cleaning on exiting\n";
- print "- Umounting partitions:\n";
- print "\tumounting /proc\n";
- eval { fs::umount("$::prefix/proc") };
- # fs::umount("$::prefix/$_") foreach 'mnt/packages', 'mnt/share', 'home', '';
- if ($fstab) {
- print "\tumounting everything else\n";
- eval { fs::umount_all($fstab, $::prefix) } or system("umount $::prefix");
- }
- print "\tumounting /tmp\n";
- eval { fs::umount("/tmp") } if $rescue;
- print "Cleaning done\n";
-};
-
-
-$::prefix = $ARGV[0] || '/tmp/live_tree';
-
-
-#===========================================================================
-# Building the disk:
--d $::prefix or mkdir $::prefix;
-print "Making live in $::prefix directory.\n";
-
-
-my ($all_hds, $hd, $other) = do {
- # here we want testing so that diskdrake still set mount points in data structure:
- local $::testing = !$options{partition};
- prepare_disk();
-};
-
-formatdisk($hd) if $options{format};
-
-add2hash($hd, $other);
-
-undef $::testing;
-
-my @parts = partition_table::get_normal_parts($hd);
-
-my ($root) = grep { $_->{mntpoint} eq "/" } @parts;
-print "Root is $root->{device}\n";
-run_program::run('tune2fs', '-L', "MDK-ROOT", "/dev/$root->{device}");
-# fs::mount_part($root, $::prefix);
-$fstab = [ fs::get::fstab($all_hds) ];
-
-# we need to mount every fs we want to see into /etc/fstab !!!
-fs::mount_part($_, $::prefix) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} } @$fstab;
-
-symlink("$::prefix/mnt/packages", "/export") if $rescue;
-
-eval {
- print "Installing packages\n";
- installPackages();
-} if $options{install};
-print "ERROR WHILE INSTALLING PACKAGES: $@\n" if $@;
-log::closeLog;
-
-sub doRootSubst {
- my ($file) = @_;
- substInFile {
- s!/dev/$root->{device}!LABEL=MDK-ROOT!g;
- } $file;
-}
-
-#fs::merge_info_from_mtab($fstab);
-fs::write_fstab($all_hds, $::prefix);
-append_to_file("$::prefix/etc/fstab",
- "none /dev/pts devpts mode=0620 0 0\n",
- "none /proc proc defaults 0 0\n");
-doRootSubst("$::prefix/etc/fstab");
-
-my ($home) = grep { $_->{mntpoint} eq "/home" } @parts;
-my ($mnt_pkgs) = grep { $_->{mntpoint} eq "/mnt/packages" } @parts;
-run_program::run('tune2fs', '-L', "MDK-HOME", "/dev/$home->{device}") if $home;
-run_program::run('tune2fs', '-L', "MDK-PKGS", "/dev/$mnt_pkgs->{device}") if $mnt_pkgs;
-
-substInFile {
- s!defaults\s!defaults,ro ! if m!/mnt/packages!;
- s!defaults\s!defaults,umask=0000 ! if m!/mnt/share!;
- s!/dev/$home->{device}!LABEL=MDK-HOME!g;
- s!/dev/$mnt_pkgs->{device}!LABEL=MDK-PKGS!g;
-} "$::prefix/etc/fstab";
-
-
-#-------------------------------------------------------------------
-#- Bootloader
-print "Configuring bootloader\n";
-system("modprobe loop");
-require keyboard;
-require bootloader;
-
-my $bootloader = {
- keytable => keyboard::keyboard2kmap(keyboard::lang2keyboard('fr')),
- bios => { '/dev/sda' => '0x80' },
- };
-
-bootloader::suggest($bootloader, $all_hds,
- vga_fb => 788,
- quiet => 1);
-
-# LILO failled to boot from SCSI:
-# $bootloader->{method} = 'lilo-graphic';
-$bootloader->{method} = 'grub';
-
-eval { bootloader::install($bootloader, $all_hds) };
-
-doRootSubst("$::prefix/boot/grub/menu.lst");
-run_program::rooted($::prefix, 'sh', '/boot/grub/install.sh');
-
-# fix GRUB configuration:
-substInFile {
- # use FB by default on versionned entries so that the initial versionned entry behave like those created by /sbin/installkernel:
- s/$/ vga=788/ if /^kernel.*\d\.\d\.\d/;
-} "$::prefix/boot/grub/menu.lst";
-
-
-## disable ISDN by default (bogus isdn4net came with an enabled interface :-():
-#substInFile {
-# s/#ONBOOT.*/ONBOOT="no"/
-#} "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0";
-#
-
-print "Post install misc configuration\n";
-
-
-# clean services:
-# cups-lpd ibod isdn4linux isdnlog)) {
-run_program::rooted($::prefix, '/sbin/chkconfig', '--del', $_) foreach qw(acon jserver oki4daemon);
-#foreach my $service (qw(acon atd cups-lpd hpoj ibod iptables isdn4linux isdnlog jserver ntpd oki4daemon shorewall tmdns)) {
-# run_program::rooted($::prefix, '/sbin/chkconfig', '--level', $_, $service, 'off') foreach qw(3 5);
-#}
-
-# probably useless:
-foreach my $service (qw(alsa dm harddrake hotplug sound)) {
- run_program::rooted($::prefix, '/sbin/chkconfig', '--level', $_, $service, 'on') foreach qw(3 5);
-}
-
-if ($options{post}) {
- #-------------------------------------------------------------------
- # save a few more files in profiles
- my $prof_cfg = "$::prefix/etc/netprofile/list";
- my @files = map { chomp_($_) } cat_($prof_cfg);
- # do not save the whole /etc/sysconfig;
- push @files, (map { "/etc/X11/$_" } qw(XF86Config XF86Config-4 xorg.conf)),
- (map { "/etc/sysconfig/$_" } qw(keyboard harddrake2/previous_hw harddisks)),
- (map { "/etc/$_" } qw(modprobe.conf modprobe.devfs modprobe.preload modules modules.conf modules.devfs)),
- qw(/etc/asound.state /etc/fstab /etc/ld.so.conf/GL.conf /etc/shorewall/);
-
- output($prof_cfg, join("\n", sort @files));
-
-
- #-------------------------------------------------------------------
- #- regenerate library loader and fonts cache
- run_program::rooted($::prefix, 'ldconfig');
- any::fix_broken_alternatives();
- run_program::rooted($::prefix, 'fc-cache'); #- generate cache in all directories mentioned in config file
-
- #- XFree
-
- touch("$::prefix/etc/menu/enable_simplified");
-
- {
- local $ENV{LC_ALL} = 'en_US'; #- update-menus doesn't work when there is no locale (aka locale "C")
- #local $ENV{HOME} = '/'; #- savekdemimetypes.pl needs this otherwise it's tmp file fails
- run_program::rooted($::prefix, 'update-menus', '-n');
- }
-
- run_program::rooted($::prefix, 'nspluginscan'); #- must be run before kbuildsycoca for the ksycoca to be flash plugin aware
-
- $ENV{HELP_BROWSER} = "kfmclient openProfile webbrowsing";
- $ENV{BROWSER} = "kfmclient openProfile webbrowsing";
- $ENV{DESKTOP} = "kde";
- #- faster boot:
- foreach my $lang (lang::list_langs()) {
- local $ENV{LC_ALL} = lang::getLANGUAGE($lang);
- unlink "$::prefix/usr/share/services/ksycoca";
- run_program::rooted($::prefix, 'kbuildsycoca', '--global');
- rename("$::prefix/usr/share/services/ksycoca", "$::prefix/usr/share/services/ksycoca-$lang");
- }
- symlinkf('/etc/X11/ksycoca', "$::prefix/usr/share/services/ksycoca");
-}
-
-# clean gconftool-2 mess:
-unlink $_ foreach glob("$::prefix/core.*");
-
-
-##- Mandrake
-#substInFile {
-# s!Mandrake(l| L)inux release (\S+) \(.*\)!Mandrakelinux Nomad, powered by LaCie Mobile Hard Drive)!;
-#} "$::prefix/etc/mandrake-release";
-#
-
-
-system("rsync -rvltp /export/ $::prefix/mnt/packages/") if !$rescue;
-unlink $_ foreach glob("$::prefix/var/lib/urpmi/*");
-run_program::rooted($::prefix, 'urpmi.addmedia', '--probe-hdlist', $_, "/mnt/packages/media/$_/") foreach qw(main contrib firmwares dkms modules plugins);
-
-# for fast test replaying:
-run_program::rooted($::prefix, 'tar', 'cfj', '/root/etc.tar.bz2', '/etc');
-
-my_exit("Your disk was succesfully restored!\nYou can now reboot your machine.");
diff --git a/globetrotter/mandrake-globetrotter.spec b/globetrotter/mandrake-globetrotter.spec
deleted file mode 100644
index 4bb3a8ac9..000000000
--- a/globetrotter/mandrake-globetrotter.spec
+++ /dev/null
@@ -1,45 +0,0 @@
-Summary: Mandrakelinux Globetrotter tools
-Name: mandrake-globetrotter
-Version: 10
-Release: 1mdk
-Url: http://www.mandrakelinux.com/en/drakx.php3
-Source0: %name-%version.tar.bz2
-License: GPL
-Group: System/Configuration/Other
-Requires: drakxtools netprofile
-BuildRoot: %_tmppath/%name-buildroot
-
-
-%description
-Contains many Mandrakelinux tools needed for Mandrakelinux Globetrotter.
-
-%prep
-%setup -q
-
-%build
-%make
-
-%install
-rm -rf $RPM_BUILD_ROOT
-
-mkdir -p $RPM_BUILD_ROOT/{%_initrddir,%_datadir/harddrake}
-%makeinstall_std PREFIX=$RPM_BUILD_ROOT
-install -m 755 hwprofile $RPM_BUILD_ROOT/%_datadir/harddrake/hwprofile
-
-%find_lang libDrakX2
-
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-
-%files -f libDrakX2.lang
-%defattr(-,root,root)
-%_datadir/harddrake/*
-%_sbindir/*
-/usr/lib/libDrakX/*pm
-/usr/share/libDrakX/pixmaps/lang*
-
-%changelog
-* Wed Apr 28 2004 Thierry Vignaud <tvignaud@mandrakesoft.com> 10-1mdk
-- initial release
diff --git a/globetrotter/move.pm b/globetrotter/move.pm
deleted file mode 100644
index 3a97be568..000000000
--- a/globetrotter/move.pm
+++ /dev/null
@@ -1,177 +0,0 @@
-package move; # $Id$
-
-#- Copyright (c) 2004-2005 Mandriva
-#-
-#- This program is free software; you can redistribute it and/or modify
-#- it under the terms of the GNU General Public License as published by
-#- the Free Software Foundation; either version 2, or (at your option)
-#- any later version.
-#-
-#- This program is distributed in the hope that it will be useful,
-#- but WITHOUT ANY WARRANTY; without even the implied warranty of
-#- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#- GNU General Public License for more details.
-#-
-#- You should have received a copy of the GNU General Public License
-#- along with this program; if not, write to the Free Software
-#- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-use diagnostics;
-use strict;
-
-use c;
-use common;
-use modules;
-use fs;
-use fsedit;
-use run_program;
-use partition_table qw(:types);
-use log;
-use lang;
-use detect_devices;
-
-sub symlinkf_short {
- my ($dest, $file) = @_;
- if (my $l = readlink $dest) {
- $dest = $l if $l =~ m!^/!;
- }
- -d $file and log::l("$file already exists and is a directory! writing in directory may be needed, not overwriting"), return;
- symlinkf($dest, $file);
-}
-
-#- run very soon at stage2 start, setup things on tmpfs rw / that
-#- were not necessary to start stage2 itself (there were setup
-#- by stage1 of course)
-sub init {
- my ($o) = @_;
-
- check_for_xserver() and c::bind_textdomain_codeset('libDrakX2', 'UTF8');
-
-
- -d '/lib/modules/' . c::kernel_version() or warn("ERROR: kernel package " . c::kernel_version() . " not installed\n"), c::_exit(1);
-
- run_program::run('sysctl', '-w', 'kernel.hotplug=/bin/true');
- modules::load_category('bus/usb');
- *c::pcmcia_probe = \&detect_devices::pcmcia_probe;
- $o->{pcmcia} ||= !$::noauto && c::pcmcia_probe();
- install_steps::setupSCSI($o);
- run_program::run('sysctl', '-w', 'kernel.hotplug=/sbin/hotplug');
-
-drakx_stuff:
- $o->{steps}{$_} = { reachable => 1, text => $_ }
- foreach qw(autoSelectLanguage configMove selectMouse setRootPassword addUser configureNetwork miscellaneous selectMouse);
- $o->{orderedSteps_orig} = $o->{orderedSteps};
- $o->{orderedSteps} = [ qw(selectLanguage acceptLicense selectMouse setupSCSI miscellaneous selectKeyboard setRootPassword addUser configureNetwork configMove ) ];
- $o->{steps}{first} = $o->{orderedSteps}[0];
-}
-
-
-
-
-sub enable_service {
- run_program::run('/sbin/chkconfig', '--level', 5, $_[0], 'on');
-}
-
-sub disable_service {
- run_program::run('/sbin/chkconfig', '--del', $_[0], 'on');
-}
-
-sub install2::configMove {
- my $o = $::o;
-
- security::level::set($o->{security});
-
- require install_steps;
- install_steps::addUser($o); # for test, when replaying wizard on an already configured machine
- while ($#{$o->{users}} ne -1) {
- install_steps::addUser($o);
- }
-
- $::noauto and goto after_autoconf;
-
- my $_wait = $o->wait_message(N("Auto configuration"), N("Please wait, detecting and configuring devices..."));
-
- #- automatic printer, timezone, network configs
- require install_steps_interactive;
- if (cat_('/proc/mounts') !~ /nfs/) {
- install_steps_interactive::configureNetwork($o);
- enable_service('network');
- }
- enable_service('netfs');
- install_steps_interactive::summaryBefore($o);
-
- modules::load_category('multimedia/sound');
- enable_service('sound');
-
- detect_devices::isLaptop() or enable_service('numlock');
-
-after_autoconf:
- require timezone;
- timezone::write($o->{timezone});
-
- $o->{useSupermount} = 1;
- fs::set_removable_mntpoints($o->{all_hds});
- require fs::mount_options;
- fs::mount_options::set_all_default($o->{all_hds}, %$o, lang::fs_options($o->{locale}));
-
- $o->{modules_conf}->write;
- require mouse;
- mouse::write_conf($o, $o->{mouse}, 1); #- write xfree mouse conf
- detect_devices::install_addons('');
-
- foreach my $step (@{$o->{orderedSteps_orig}}) {
- next if member($step, @{$o->{orderedSteps}});
- while (my $f = shift @{$o->{steps}{$step}{toBeDone} || []}) {
- log::l("doing remaining toBeDone for undone step $step");
- eval { &$f() };
- $o->ask_warn(N("Error"), [
-N("An error occurred, but I don't know how to handle it nicely.
-Continue at your own risk."). formatError($@) || $@ ]) if $@;
- }
- }
- run_program::run('killall', 'Xorg');
- output_p("$::prefix/etc/rpm/macros", "%_install_langs all\n");
- # workaround init reading inittab before any.pm alters it:
- if ($::o->{autologin}) {
- run_program::run('chkconfig', 'dm', 'on');
- run_program::run('telinit', 'Q');
- }
- # prevent dm service to fail to startup because of /tmp/.font-unix's permissions:
- run_program::run('service', 'xfs', 'stop');
- c::_exit(0);
-}
-
-
-
-sub automatic_xconf {
- my ($o) = @_;
-
- log::l('automatic XFree configuration');
-
- any::devfssymlinkf($o->{mouse}, 'mouse');
- local $o->{mouse}{device} = 'mouse';
-
- require Xconfig::default;
- require class_discard;
- $o->{raw_X} = Xconfig::default::configure(class_discard->new, { KEYBOARD => 'uk' }, $o->{mouse}); #- using uk instead of us for now to have less warnings
-
- require Xconfig::main;
- Xconfig::main::configure_everything_auto_install($o->{raw_X}, class_discard->new, {},
- { allowNVIDIA_rpms => sub { [] }, allowATI_rpms => sub { [] }, allowFB => $o->{allowFB} });
-
- modules::load_category('various/agpgart');
-
- my $file = '/etc/X11/XF86Config';
- $file = "$file-4" if -e "$file-4";
- my ($Driver) = cat_($file) =~ /Section "Device".*Driver\s*"(.*?)"/s;
- if ($Driver eq 'nvidia') {
- modules::load('nvidia');
- }
- my $lib = 'libGL.so.1';
- symlinkf_short(-e "/usr/lib/$lib.$Driver" ? "/usr/lib/$lib.$Driver" : "/usr/X11R6/lib/$lib", "/etc/X11/$lib");
-}
-
-sub handleI18NClp {}
-
-
-1;
diff --git a/globetrotter/runstage2 b/globetrotter/runstage2
deleted file mode 100755
index 26d10d4fa..000000000
--- a/globetrotter/runstage2
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-#- Copyright (c) 2004 Mandrakesoft
-#-
-#- This program is free software; you can redistribute it and/or modify
-#- it under the terms of the GNU General Public License as published by
-#- the Free Software Foundation; either version 2, or (at your option)
-#- any later version.
-#-
-#- This program is distributed in the hope that it will be useful,
-#- but WITHOUT ANY WARRANTY; without even the implied warranty of
-#- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#- GNU General Public License for more details.
-#-
-#- You should have received a copy of the GNU General Public License
-#- along with this program; if not, write to the Free Software
-#- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-# i18n: IMPORTANT: to get correct namespace (libDrakX2 instead of libDrakX)
-BEGIN { unshift @::textdomains, 'libDrakX2' }
-c::bind_textdomain_codeset($_, 'UTF8') foreach 'libDrakX', @::textdomains;
-
-use lib qw(../perl-install /usr/lib/libDrakX);
-use standalone;
-use install2;
-
-#$::isStandalone = 0;
-install2::main(@ARGV, '--globetrotter');
-
-c::_exit(0);
diff --git a/help.msg.xml b/help.msg.xml
deleted file mode 100644
index 37ead3180..000000000
--- a/help.msg.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<document>
- <green>Welcome to <blue>Mandrakelinux</blue> install help</green>
-
-In most cases, the best way to get started is to simply press the <yellow>&lt;Enter&gt;</yellow> key.
-If you experience problems with standard install, try one of the following
-install types (type the highlighted text and press <yellow>&lt;Enter&gt;</yellow>):
-
- o <white>vgalo</white> for low resolution graphical installation.
- o <white>text</white> for text installation instead of the graphical one.
- o <white>linux</white> for standard graphical installation at normal resolution.
-
-
-To repair an already installed system type <white>rescue</white> followed
-by <yellow>&lt;Enter&gt;</yellow>.
-
-You can also pass some <white>&lt;specific kernel options&gt;</white> to the Linux kernel.
-For example, try <white>linux noapic</white> if your system has trouble operating
-your network adapter correctly.
-<red>NOTE</red>: You cannot pass options to modules (SCSI, ethernet card) or devices
-such as CD-ROM drives in this way. If you need to do so, use noauto mode.
-</document>
diff --git a/isolinux-graphic-simple.bmp b/isolinux-graphic-simple.bmp
deleted file mode 100644
index eada90017..000000000
--- a/isolinux-graphic-simple.bmp
+++ /dev/null
Binary files differ
diff --git a/isolinux-graphic-simple.bmp.parameters b/isolinux-graphic-simple.bmp.parameters
deleted file mode 100644
index 8fd220512..000000000
--- a/isolinux-graphic-simple.bmp.parameters
+++ /dev/null
@@ -1,10 +0,0 @@
-clear_h=800
-clear_w=600
-isolinux_mode=1
-mode=259
-progress_c=189
-progress_h=13
-progress_real_w=425
-progress_w=4
-progress_x=186
-progress_y=396
diff --git a/isolinux-graphic.bmp b/isolinux-graphic.bmp
deleted file mode 100644
index 407c99721..000000000
--- a/isolinux-graphic.bmp
+++ /dev/null
Binary files differ
diff --git a/isolinux-graphic.bmp.parameters b/isolinux-graphic.bmp.parameters
deleted file mode 100644
index 8fd220512..000000000
--- a/isolinux-graphic.bmp.parameters
+++ /dev/null
@@ -1,10 +0,0 @@
-clear_h=800
-clear_w=600
-isolinux_mode=1
-mode=259
-progress_c=189
-progress_h=13
-progress_real_w=425
-progress_w=4
-progress_x=186
-progress_y=396
diff --git a/kernel/.cvsignore b/kernel/.cvsignore
deleted file mode 100644
index 6ba150ae1..000000000
--- a/kernel/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-modules.description
-all.kernels
-RPMS
diff --git a/kernel/Makefile b/kernel/Makefile
deleted file mode 100644
index 0b4695ba1..000000000
--- a/kernel/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-all: all.kernels
-
-all.kernels: ../mdk-stage1/mar/mar update_kernel list_modules.pm
- ./update_kernel
-
-../mdk-stage1/mar/mar:
- make -C `dirname $@` mar
-
-clean:
- rm -rf *~ modules.description all.kernels
-
-check:
- perl modules.pl check > /dev/null
- @echo "unlisted drivers: "
- @for i in $$(cut -f 2 -d \" /usr/share/ldetect-lst/pcitable|egrep -v '^#|ADSL:|Bad:|Card:|H[cs]f:|ISDN:|LT:'|sort|uniq|less);do fgrep -q $$i list_modules.pm|| echo -n "$$i ";done
- @echo
diff --git a/kernel/list_modules.pm b/kernel/list_modules.pm
deleted file mode 100644
index 62250c87f..000000000
--- a/kernel/list_modules.pm
+++ /dev/null
@@ -1,316 +0,0 @@
-package list_modules; # $Id$
-
-use MDK::Common;
-
-our @ISA = qw(Exporter);
-our @EXPORT = qw(load_dependencies dependencies_closure category2modules module2category sub_categories kernel_is_26 module_extension);
-
-# the categories have 2 purposes
-# - choosing modules to include on stage1's (cf update_kernel and mdk-stage1/pci-resource/update-pci-ids.pl)
-# - performing a load_category or probe_category (modules.pm and many files in perl-install)
-
-our %l = (
- ################################################################################
- network =>
- {
- atm => [ qw(ambassador eni firestream he horizon idt77252 iphase lanai nicstar zatm) ],
- main => [
- if_(arch() =~ /ppc/, qw(bmac ibm_emac mace oaknet sungem)),
- if_(arch() =~ /^sparc/, qw(sunbmac sunhme sunqe)),
- if_(arch() !~ /alpha|sparc/,
- qw(3c501 3c503 3c505 3c507 3c509 3c515 3c990 3c990fx),
- qw(82596 ac3200 acenic aironet4500_card amd8111e at1700 atp),
- qw(b44 bcm4400 com20020-pci cs89x0 de2104x de600 de620),
- qw(defxx), # most unused
- qw(depca dgrs dmfe e100 e2100 eepro eepro100 eexpress epic100 eth16i),
- qw(ewrk3 fealnx hamachi hp hp-plus hp100),
- qw(iph5526), #- fibre channel
- qw(lance natsemi ne ne2k-pci ni5010 ni52 ni65 nvnet),
- qw(pcnet32 plip prism2_plx rcpci rhineget),
- qw(sb1000 sis900 skfp smc-ultra smc9194 starfire),
- qw(tc35815 tlan tulip typhoon uli526x via-rhine),
- qw(wd winbond-840 forcedeth),
- qw(sungem sunhme), # drivers for ultrasparc, but compiled in ix86 kernels...
- ),
- qw(3c59x 8139too 8139cp sundance), #rtl8139
- ],
- firewire => [ qw(eth1394 pcilynx) ],
- gigabit => [
- qw(bnx2 cxgb dl2k e1000 ixgb myri_sbus ns83820 r8169 s2io sis190 sk98lin skge tg3 via-velocity yellowfin ),
- qw(bcm5820 bcm5700), #- encrypted
- ],
-
- raw => [
- qw(ppp_generic ppp_async ppp_deflate bsd_comp),
- ],
- pcmcia => [
- qw(3c574_cs 3c589_cs axnet_cs fmvj18x_cs),
- qw(ibmtr_cs nmclan_cs pcnet_cs smc91c92_cs),
- qw(xirc2ps_cs xircom_cb xircom_tulip_cb),
- ],
- #- generic NIC detection for USB seems broken (class, subclass,
- #- protocol reported are not accurate) so we match network adapters against
- #- known drivers :-(
- usb => [
- qw(catc CDCEther kaweth pegasus rtl8150 usbnet),
- ],
- wireless => [
- qw(acx100_pci adm8211 airo airo_cs aironet4500_cs aironet_cs),
- qw(at76c503-i3861 at76c503-i3863 at76c503-rfmd at76c503-rfmd-acc at76c505-rfmd at76c505-rfmd2958 at76c505a-rfmd2958),
- qw(ath_pci atmel_cs atmel_pci dyc_ar5),
- qw(hostap_pci hostap_plx ipw2100 ipw2200 madwifi_pci netwave_cs orinoco orinoco_cs orinoco_pci orinoco_plx orinoco_tmd),
- qw(prism2_cs prism2_pci prism2_usb prism54 r8180 ray_cs rt2400 rt2500 usbvnet_rfmd vt_ar5k wavelan_cs wvlan_cs zd1201),
- if_(arch() =~ /ppc/, qw(airport)),
- ],
- isdn => [
- qw(avmfritz c4 cdc-acm b1pci divas hfc4s8s_l1 hfc_usb hfc4s8s_l1 hisax hisax_st5481 hisax_fcpcipnp hysdn sedlfax t1pci tpam w6692pci),
- qw(fcpci fcdsl fcdsl fcdsl2 fcdslsl fcdslslusb fcdslusb fcdslusba fcusb fcusb2 fxusb fxusb_CZ)
- ],
- modem => [
- qw(ltmodem mwave ),
- ],
- slmodem => [
- qw(slamr slusb snd-ali5451 snd-atiixp-modem snd-intel8x0m snd-via82xx-modem),
- ],
- tokenring => [ qw(3c359 abyss ibmtr lanstreamer olympic proteon skisa smctr tms380tr tmspci) ],
- wan => [ qw(c101 cosa cyclomx cycx_drv dlci farsync hdlc hostess_sv11 n2 pc300 pci200syn sbni sdla sdladrv sealevel syncppp wanxl z85230) ],
- usb_dsl => [ qw(cxacru eagle-usb speedtch usbatm xusbatm) ],
- },
-
- ################################################################################
- disk =>
- {
- # ide drivers compiled as modules:
- ide => [ qw(aec62xx cs5520 cs5530 delkin_cb ide-generic rz1000 sc1200 slc90e66 triflex trm290) ],
- # ide drivers compiled in core kernel:
- all_ide => [
- qw(ali14xx amd74xx dtc2278 ht6560b qd65xx umc8672 aec62xx alim15x3 atiixp cmd64x cs5520 cs5530 cy82c693),
- qw(hpt34x hpt366 ns87415 opti621 pdc202xx_new pdc202xx_old piix rz1000 sc1200 serverworks),
- qw(siimage sis5513 slc90e66 triflex trm290 via82cxxx),
- ],
- scsi => [
- if_(arch() =~ /ppc/, qw(mesh mac53c94)),
- if_(arch() =~ /^sparc/, qw(qlogicpti)),
- if_(arch() !~ /alpha/ && arch() !~ /sparc/,
- '53c7,8xx',
- qw(AM53C974 BusLogic NCR53c406a a100u2w advansys aha152x aha1542 aha1740),
- qw(atp870u dc395x dc395x_trm dmx3191d dtc g_NCR5380 in2000 initio pas16 pci2220i psi240i fdomain),
- qw(qla1280 qla2x00 qlogicfas qlogicfc),
- qw(seagate wd7000 sim710 sym53c416 t128 tmscsim u14-34f ultrastor),
- qw(eata eata_pio eata_dma nsp32),
- ),
- qw(aic7xxx aic7xxx_old aic79xx pci2000 qlogicisp sym53c8xx lpfc lpfcdd), # ncr53c8xx
- ],
- sata => [
- # note that ata_piix manage RAID devices on ICH6R
- qw(ahci ata_adma ata_piix pata_pdc2027x sata_nv sata_promise sata_qstor sata_sil sata_sil24 sata_sis sata_svw sata_sx4 sata_uli sata_via sata_vsc sx8),
- ],
- hardware_raid => [
- if_(arch() =~ /^sparc/, qw(pluto)),
- if_(arch() !~ /alpha/ && arch() !~ /sparc/,
- # 3w-xxxx drives ATA-RAID, 3w-9xxx and arcmsr drive SATA-RAID
- qw(a320raid),
- qw(3w-9xxx 3w-xxxx aacraid arcmsr cciss cpqfc cpqarray DAC960 dpt_i2o gdth i2o_block ipr it821x it8212),
- qw(iteraid megaraid megaraid_mbox megaraid_sas mptscsih qla2100 qla2200 qla2300 qla2322 qla4xxx qla6312 qla6322 pdc-ultra),
- qw(ips ppa imm),
- if_(c::kernel_version =~ /^\Q2.4/,
- qw(ataraid hptraid silraid pdcraid)
- ),
- ),
- ],
- pcmcia => [ qw(aha152x_cs fdomain_cs nsp_cs qlogic_cs ide-cs) ], #ide_cs
- raw => [ qw(sd_mod) ],
- usb => [ qw(usb-storage) ],
- firewire => [ qw(sbp2) ],
- cdrom => [ qw(ide-cd sr_mod) ],
- },
-
- ################################################################################
-
- bus =>
- {
- usb => [ qw(usb-uhci usb-ohci ehci-hcd uhci-hcd ohci-hcd) ],
- bluetooth => [ qw(bcm203x bfusb bpa10x hci_usb) ],
- firewire => [ qw(ohci1394) ],
- i2c => [
- qw(i2c-ali1535 i2c-ali1563 i2c-ali15x3 i2c-amd756 i2c-amd8111 i2c-i801 i2c-i810 i2c-nforce2),
- qw(i2c-piix4 i2c-prosavage i2c-savage4 i2c-sis5595 i2c-sis630 i2c-sis96x i2c-via i2c-viapro i2c-voodoo3),
- if_(arch() !~ /^ppc/, qw(i2c-hydra i2c-ibm_iic i2c-mpc)),
- ],
- pcmcia => [
- if_(arch() !~ /^sparc/, qw(au1x00_ss i82365 i82092 pd6729 tcic vrc4171_card vrc4173_cardu yenta_socket)), # cb_enabler
- ],
- usb_keyboard => [ qw(usbkbd keybdev) ],
- #serial_cs
- #ftl_cs 3c575_cb apa1480_cb epic_cb serial_cb tulip_cb iflash2+_mtd iflash2_mtd
- #cb_enabler
- },
-
- fs =>
- {
- network => [ qw(af_packet nfs) ],
- cdrom => [ qw(isofs) ],
- loopback => [ qw(isofs loop cryptoloop gzloop), if_($ENV{MOVE}, qw(supermount)) ],
- local => [
- if_(arch() =~ /^i.86|x86_64/, qw(vfat ntfs)),
- if_(arch() =~ /^ppc/, qw(hfs)),
- qw(reiserfs),
- ],
- various => [ qw(smbfs romfs ext3 xfs jfs ufs ntfs) ],
-
- },
-
- ################################################################################
- multimedia =>
- {
- sound => [
- if_(arch() =~ /ppc/, qw(dmasound_pmac snd-powermac)),
- if_(arch() =~ /sparc/, qw(snd-sun-amd7930 snd-sun-cs4231 snd-sun-dbri)),
- if_(arch() !~ /^sparc/,
- qw(ad1816 ad1848 ad1889 ali5455 audigy audio awe_wave cmpci cs4232 cs4281 cs46xx),
- qw(emu10k1 es1370 es1371 esssolo1 forte gus i810_audio ice1712 kahlua mad16 maestro),
- qw(maestro3 mpu401 msnd_pinnacle nm256_audio nvaudio opl3 opl3sa opl3sa2 pas2 pss),
- qw(rme96xx sam9407 sb sgalaxy snd-ad1816a snd-ad1848 snd-ali5451 snd-als100),
- qw(snd-als4000 snd-atiixp snd-au8810 snd-au8820 snd-au8830 snd-audigyls snd-azt2320 snd-azt3328 snd-azx),
- qw(snd-bt87x snd-ca0106 snd-cmi8330 snd-cmipci snd-cs4231 snd-cs4232 snd-cs4236 snd-cs4281),
- qw(snd-cs46xx snd-darla20 snd-darla24 snd-dt019x snd-emu10k1 snd-emu10k1x snd-ens1370 snd-ens1371 snd-es1688 snd-es18xx),
- qw(snd-es1938 snd-es1968 snd-es968 snd-fm801 snd-gina20 snd-gina24 snd-gina3g snd-gusclassic snd-gusextreme),
- qw(snd-gusmax snd-hda-intel snd-hdsp snd-hdspm snd-ice1712 snd-ice1724 snd-indi snd-indigo snd-indigodj snd-indigoio snd-intel8x0 snd-interwave),
- qw(snd-interwave-stb snd-korg1212 snd-layla20 snd-layla24 snd-layla3g snd-maestro3 snd-mia snd-mixart snd-mona snd-mpu401 snd-nm256),
- qw(snd-opl3sa2 snd-opti92x-ad1848 snd-opti92x-cs4231 snd-opti93x snd-pcxhr snd-rme32),
- qw(snd-rme96 snd-rme9652 snd-sb16 snd-sb8 snd-sbawe snd-sgalaxy snd-sonicvibes),
- qw(snd-sscape snd-trident snd-via82xx snd-vx222 snd-vxp440 snd-vxpocket snd-wavefront),
- qw(snd-ymfpci sonicvibes sscape trident via82cxxx_audio wavefront ymfpci),
- ),
- ],
- tv => [ qw(bt878 bttv cx8800 cx88-blackbird dpc7146 ivtv saa7134 zr36067) ],
- dvb => [ qw(budget budget-av budget-ci cinergyT2 dvb-ttusb-budget dvb-usb-a800 dvb-dibusb dvb-usb-dibusb-mb dvb-ttpci dvb-usb-digitv dvb-usb-dtt200u dvb-usb-nova-t-usb2 dvb-usb-umt-010 dvb-usb-vp7045 hexium_orion hexium_gemini skystar2) ],
- photo => [ qw(dc2xx mdc800) ],
- radio => [ qw(radio-gemtek-pci radio-maxiradio) ],
- scanner => [ qw(scanner microtek) ],
- gameport => [ qw(cs461x ns558 emu10k1-gp fm801-gp lightning ns558 vortex) ],
- usb_sound => [ qw(audio dabusb dsbr100 snd-usb-audio snd-usb-usx2y usb-midi) ],
- webcam => [ qw(cpia_usb cyber2000fb ibmcam konicawc mod_quickcam ov511 ov511-alt ov518_decomp ovfx2 pwc quickcam se401 stv680 sn9c102 ultracam usbvideo usbvision vicam w9968cf) ],
- },
-
- # USB input stuff get automagically loaded by hotplug and thus
- # magically work through /dev/input/mice multiplexing:
- input => {
- joystick => [
- qw(iforce xpad),
- # there're more drivers in drivers/input/joystick but they support non USB or PCI devices
- # and thus cannot be detected but by slow (and maybe dangerous?) load_category:
- qw(a3d adi analog cobra db9 gamecon gf2k grip grip_mp guillemot interact),
- qw(joydump magellan sidewinder spaceball spaceorb stinger tmdc turbografx warrior)
- ],
- remote => [ qw(ati_remote) ],
- # USB tablets and touchscreens:
- tablet => [ qw(acecad aiptek wacom kbtab) ],
- touchscreen => [ qw(ads7846_ts gunze hp680_ts_input itmtouch mk712 mtouch mtouchusb touchkitusb) ],
- },
-
- various =>
- # just here for classification, unused categories (nor auto-detect, nor load_thiskind)
- {
- raid => [
- qw(dm-crypt dm-mirror dm-mod linear lvm-mod multipath raid0 raid1 raid10 raid5),
- ],
- mouse => [
- qw(atixlmouse busmouse generic_serial inport logibm logibusmouse msbusmouse pcips2 qpmouse synclinkmp),
- if_(arch() =~ /ppc/, 'macserial'),
- qw(hid mousedev usbhid usbmouse),
- ],
- char => [
- if_(arch() =~ /ia64/, qw(efivars)),
- qw(applicom n_r3964 nvram pc110pad ppdev),
- qw(wdt_pci i810-tco sx), #- what are these???
- ],
- crypto => [
- qw(amd768_rng amd7xx_tco i810_rng hw_random leedslite padlock),
- ],
- laptop => [
- qw(i8k sonypi toshiba),
- ],
- serial => [
- qw(8250_pci 8250 epca esp isicom istallion moxa mxser stallion sx synclink synclinkmp),
- ],
- other => [
- qw(defxx i810fb ide-floppy ide-scsi ide-tape loop lp nbd sg st),
- qw(parport_pc parport_serial),
- qw(btaudio),
-
- arch() =~ /i.86/ ? 'aes-i586' : 'aes',
- if_(arch() =~ /sparc/, 'openprom'),
-
- qw(evdev), qw(usblp printer), 'floppy',
-
- #- these need checking
- qw(rrunner meye),
- ],
- agpgart => [
- if_(arch() =~ /alpha/, qw(alpha-agp)),
- if_(arch() =~ /ia64/, qw(hp-agp i460-agp)),
- if_(arch() =~ /ppc/, qw(uninorth-agp)),
-
- qw(ali-agp amd64-agp amd-k7-agp ati-agp efficeon-agp intel-agp),
- qw(k7-agp mch-agp nvidia-agp sis-agp sworks-agp via-agp),
- ],
- },
-);
-
-my %dependencies;
-
-sub load_dependencies {
- my ($file) = @_;
-
- %dependencies = map {
- my ($f, $deps) = split ':';
- $f => [ split ' ', $deps ];
- } cat_($file);
-}
-
-sub dependencies_closure {
- my @l = map { dependencies_closure($_) } @{$dependencies{$_[0]} || []};
- (@l, $_[0]);
-}
-
-sub category2modules {
- map {
- my ($t1, $t2s) = m|(.*)/(.*)|;
- my @sub = $t2s eq '*' ? keys %{$l{$t1}} : split('\|', $t2s);
- map {
- my $l = $l{$t1}{$_} or die "bad category $t1/$_\n" . backtrace();
- @$l;
- } @sub;
- } split(' ', $_[0]);
-}
-
-sub all_modules() {
- map { @$_ } map { values %$_ } values %l;
-}
-
-sub module2category {
- my ($module) = @_;
- foreach my $t1 (keys %l) {
- my $h = $l{$t1};
- foreach my $t2 (keys %$h) {
- $module eq $_ and return "$t1/$t2" foreach @{$h->{$t2}};
- }
- }
- return;
-}
-
-sub ethernet_categories() {
- 'network/main|gigabit|pcmcia|tokenring|usb|wireless|firewire';
-}
-
-sub sub_categories {
- my ($t1) = @_;
- keys %{$l{$t1}};
-}
-
-sub kernel_is_26 { $_[0] =~ /^2\.6/ }
-
-sub module_extension { kernel_is_26($_[0]) ? 'ko' : 'o' }
-
-1;
diff --git a/kernel/modules.pl b/kernel/modules.pl
deleted file mode 100644
index 22f71e048..000000000
--- a/kernel/modules.pl
+++ /dev/null
@@ -1,280 +0,0 @@
-use strict;
-
-
-BEGIN {
- #- for testing purpose
- (my $f = __FILE__) =~ s|/[^/]*$||;
- push @INC, $f;
-}
-
-use MDK::Common;
-use list_modules;
-
-#- seldom used modules
-#- we don't bother making a special floppy for those
-my %modules_only_for_all_img = (
-
- 'network/main' => [
- qw(acenic),
- qw(aironet4500_card com20020-pci hamachi starfire winbond-840),
-
- if_(arch() =~ /alpha|ppc/, qw(sb1000)),
- qw(iph5526),
-
- qw(ac3200 at1700 atp ni5010 ni52 ni65), #- unused from Jeff
- ],
-
- 'disk/scsi' => [
- # ISA cards:
- qw(NCR53c406a aha152x psi240i qlogicfas qlogicfc wd7000 sim710 t128 ultrastor), '53c7,8xx',
- qw(qla2x00 in2000 pas16 a100u2w seagate g_NCR5380),
- if_(arch() =~ /x86_64/, qw(53c7,8xx nsp32 initio advansys atp870u)), #- old
- qw(AM53C974), # deprecated by tmscsim
- qw(u14-34f), #- duplicate from ultrastor.o
- #- still used, keeping them: qw(aha1542 sym53c416),
- qw(lpfcdd), #- HUGE!!
-
- qw(dc395x dc395x_trm dmx3191d qla1280 BusLogic fdomain),
- qw(pci2220i eata eata_pio eata_dma),
- 'aic7xxx_old', 'qlogicisp',
- 'dtc',
- ],
- 'disk/sata' => [
- qw(ahci ata_piix sata_nv sata_promise sata_sil sata_sis sata_svw sata_sx4 sata_uli sata_via sata_vsc sx8),
- ],
-
- 'disk/hardware_raid' => [
- qw(i2o_block qla2200 qla2300 cpqfc DAC960 gdth pdc-ultra mptscsih),
- ],
-);
-
-#- modules that will only be available in stage2
-#- those modules are NOT in all.img, network.img...
-#- there should only be modules that can't be used on stage1
-#- completly unused modules should be removed directly from the kernel
-#- (and so be removed from stage2 too)
-my %modules_removed_from_stage1 = (
- 'network/main' => [
- 'plip'
- ],
-
- 'disk/hardware_raid' => [
- qw(imm ppa),
- ],
-);
-
-my @modules_always_on_stage1 = qw(floppy);
-
-
-sub flatten_and_check {
- my ($h) = @_;
- map {
- my $category = $_;
- my @l = @{$h->{$category}};
- if (my @bad = difference2(\@l, [ category2modules($category) ])) {
- foreach (@bad) {
- if (my $cat = module2category($_)) {
- warn "ERROR in modules.pl: module $_ is in category $cat, not in $category\n";
- } else {
- warn "ERROR in modules.pl: unknown module $_\n";
- }
- }
- exit 1;
- }
- @l;
- } keys %$h;
-}
-
-my @modules_only_for_all_img = flatten_and_check(\%modules_only_for_all_img);
-my @modules_removed_from_stage1 = flatten_and_check(\%modules_removed_from_stage1);
-
-
-my %images = (
- pcmcia => 'fs/cdrom|loopback disk/cdrom|raw|pcmcia bus/pcmcia',
- cdrom => 'fs/cdrom|loopback disk/cdrom|raw|scsi',
- network => 'bus/usb|usb_keyboard|pcmcia disk/raw|usb',
- network_drivers => 'fs/network|loopback network/main|pcmcia|usb|raw|gigabit',
- all => 'fs/cdrom disk/cdrom|raw bus/usb|usb_keyboard disk/usb|scsi fs/loopback|local bus/pcmcia disk/ide|pcmcia|sata|hardware_raid fs/network network/main|pcmcia|usb|raw|gigabit|wireless|tokenring bus/firewire disk/firewire',
-);
-
-my $verbose = $ARGV[0] eq '-v' && shift;
-my ($f, @para) = @ARGV;
-$::{$f}->(@para);
-
-sub image2modules {
- my ($image) = @_;
- my $l = $images{$image};
-
- my @modules = if_($image !~ /drivers/, @modules_always_on_stage1);
- push @modules, map { category2modules($_) } split(' ', $l);
-
- @modules = difference2(\@modules, \@modules_removed_from_stage1);
-
- if ($image !~ /all/) {
- @modules = difference2(\@modules, \@modules_only_for_all_img);
- }
-
- @modules;
-}
-
-sub remove_unneeded_modules {
- my ($kern_ver) = @_;
-
- #- need creating a first time the modules.dep for all modules
- #- it will be redone in make_modules_dep when unneeded modules are removed
- make_modules_dep($kern_ver);
- load_dependencies("all.kernels/$kern_ver/modules.dep");
-
- my $ext = module_extension($kern_ver);
-
- my @all = list_modules::all_modules();
- my @all_with_deps = map { dependencies_closure($_) } @all;
- my %wanted_modules = map {; "$_.$ext" => 1 } @all_with_deps;
- foreach (all("all.kernels/$kern_ver/modules")) {
- $wanted_modules{$_} or unlink "all.kernels/$kern_ver/modules/$_";
- }
-}
-
-sub make_modules_per_image {
- my ($kern_ver) = @_;
-
- make_modules_dep($kern_ver);
- load_dependencies("all.kernels/$kern_ver/modules.dep");
-
- my $ext = module_extension($kern_ver);
-
- foreach my $image (keys %images) {
- my @modules_with_deps = uniq(map { dependencies_closure($_) } image2modules($image));
- my @l = map { "$_.$ext" } @modules_with_deps;
-
- my $dir = "all.kernels/$kern_ver/modules";
- @l = grep { -e "$dir/$_" } @l;
-
- if ($image =~ /all/) {
- system("cd $dir ; tar cf ../${image}_modules.tar @l") == 0 or die "tar failed\n";
- } else {
- my $gi_base_dir = chomp_(`pwd`) . '/..';
- system("cd $dir ; $gi_base_dir/mdk-stage1/mar/mar -c ../${image}_modules.mar @l") == 0 or die "mar failed\n";
- }
- }
-}
-
-sub make_modules_dep {
- my ($kern_ver) = @_;
-
- my @l =
- kernel_is_26($kern_ver) ?
- cat_("all.kernels/$kern_ver/lib/modules/$kern_ver/modules.dep") :
- `/sbin/depmod-24 -F all.kernels/$kern_ver/boot/System.map-$kern_ver -e *.o | perl -pe 's/\\\n//'`;
-
- @l = map {
- if (/(\S+):\s+(.*)/) {
- my ($module, @deps) = map { m!.*/(.*)\.k?o(\.gz)$! && $1 } $1, split(' ', $2);
- if (member($module, 'plip', 'ppa', 'imm')) {
- @deps = map { $_ eq 'parport' ? 'parport_pc' : $_ } @deps;
- } elsif ($module eq 'vfat') {
- push @deps, 'nls_cp437', 'nls_iso8859-1';
- }
- if_(@deps, join(' ', "$module:", @deps));
- } else {
- ();
- }
- } @l;
-
- output("all.kernels/$kern_ver/modules.dep", map { "$_\n" } @l);
-}
-
-sub make_modules_description {
- my ($kern_ver) = @_;
- my $ext = module_extension($kern_ver);
- my $dir = "all.kernels/$kern_ver/modules";
-
- my @l;
- if (kernel_is_26(`uname -r`)) { #- modinfo behaves differently depending on the build kernel used
- my $name;
- @l = map {
- $name = $1 if m!^filename:\s*(.*)\.$ext!;
- if_($name && /^description:\s*(.*)/, "$name\t$1");
- } `cd $dir ; /sbin/modinfo *.$ext`;
- } else {
- @l = map {
- if_(/(.*?)\.$ext "(.*)"/, "$1\t$2\n");
- } `cd $dir ; /sbin/modinfo-24 -f '%{filename} %{description}\n' *.$ext`;
- }
- output("modules.description", @l);
-}
-
-sub pci_modules4stage1 {
- my ($category) = @_;
- my @modules = difference2([ category2modules($category) ], \@modules_removed_from_stage1);
- print "$_\n" foreach uniq(map { dependencies_closure($_) } @modules);
-}
-
-sub check() {
- my $error;
- my %listed;
- while (my ($t1, $l) = each %list_modules::l) {
- while (my ($t2, $l) = each %$l) {
- ref $l or die "bad $l in $t1/$t2";
- foreach (@$l) {
- $listed{$_} = "$t1/$t2";
- }
- }
- }
-
- my %module2category;
- my %deprecated_modules = %listed;
- my $not_listed = sub {
- my ($msg, $verbose, @l) = @_;
- my %not_listed;
- foreach (@l) {
- my ($mod) = m|([^/]*)\.k?o(\.gz)?$| or next;
- delete $deprecated_modules{$mod};
- next if $listed{$mod};
- s|.*?mdk(BOOT)?/||;
- s|kernel/||; s|drivers/||; s|3rdparty/||;
- $_ = dirname $_;
- $_ = dirname $_ if $mod eq basename($_);
- $module2category{$mod} = $_;
- push @{$not_listed{$_}}, $mod;
- }
- if ($verbose) {
- print "$msg $_: ", join(" ", @{$not_listed{$_}}), "\n" foreach sort keys %not_listed;
- }
- };
- $not_listed->('NOT LISTED', 1, `cd all.kernels/2.6* ; find -name "*.k?o" -o -name "*.k?o.gz"`);
- $not_listed->('not listed', $verbose, `rpm -qpl /RPMS/kernel-2.6*`);
- if (%deprecated_modules) {
- my %per_cat;
- push @{$per_cat{$listed{$_}}}, $_ foreach keys %deprecated_modules;
- foreach my $cat (sort keys %per_cat) {
- print "bad/old modules ($cat) : ", join(" ", sort @{$per_cat{$cat}}), "\n";
- }
- }
-
- {
- require '/usr/bin/merge2pcitable.pl';
- my $pcitable = read_pcitable("/usr/share/ldetect-lst/pcitable");
- my $usbtable = read_pcitable("/usr/share/ldetect-lst/usbtable");
-
- my @l1 = uniq grep { !/:/ && $_ ne 'unknown' } map { $_->[0] } values %$pcitable;
- if (my @l = difference2(\@l1, [ keys %listed ])) {
- my %not_listed;
- push @{$not_listed{$module2category{$_}}}, $_ foreach @l;
- if (my $l = delete $not_listed{''}) {
- print "bad/old pcitable modules : ", join(" ", @$l), "\n";
- }
- print STDERR "PCITABLE MODULES NOT LISTED $_: ", join(" ", sort @{$not_listed{$_}}), "\n" foreach sort keys %not_listed;
- #$error = 1;
- }
-
- my @l2 = uniq grep { !/:/ && $_ ne 'unknown' } map { $_->[0] } values %$usbtable;
- if (my @l = difference2(\@l2, [ keys %listed ])) {
- my %not_listed;
- push @{$not_listed{$module2category{$_}}}, $_ foreach @l;
- print STDERR "usbtable modules not listed $_: ", join(" ", sort @{$not_listed{$_}}), "\n" foreach sort keys %not_listed;
- }
- }
-
- exit $error;
-}
diff --git a/kernel/strip_modules b/kernel/strip_modules
deleted file mode 100755
index cd4077a66..000000000
--- a/kernel/strip_modules
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/sh
-#
-# Given a list of objects, strip all static symbols except those
-# required by insmod.
-#
-# Copyright Keith Owens <kaos@ocs.com.au>. GPL.
-# Sat Feb 1 12:52:17 EST 1997
-#
-# Mainly intended for reducing the size of modules to save space
-# on emergency and install disks. Be aware that removing the
-# static symbols reduces the amount of diagnostic information
-# available for oops. Not recommended for normal module usage.
-#
-# This code requires the modules use MODULE_PARM and EXPORT_.
-# Do not strip modules that have not been converted to use
-# MODULE_PARM or are using the old method of exporting symbols.
-# In particular do not use on modules prior to 2.1.20 (approx).
-#
-# The objects are stripped in /tmp, only if the strip works is
-# the original overwritten. If the command line to strip the
-# symbols becomes too long, the strip is done in multiple passes.
-# Running strip_module twice on the same object is safe (and a
-# waste of time).
-#
-
-sizeofptr="/tmp/$$.sizeofptr"
-echo 'int main() { return sizeof(void *); }' | gcc -xc - -o $sizeofptr
-$sizeofptr
-export SIZEOF_POINTER=$?
-rm -f $sizeofptr
-
-cat > /tmp/$$.awk <<\EOF
-BEGIN {
- strip = "/usr/bin/objcopy";
- nm = "/usr/bin/nm";
- cp = "/bin/cp";
- mv = "/bin/mv";
- rm = "/bin/rm";
- tmp = "/tmp";
- command_size = 400; # arbitrary but safe
-
- getline < "/proc/self/stat";
- pid = $1;
- tmpcopy = tmp "/" pid ".object";
- nmout = tmp "/" pid ".nmout";
-
- for (i = 1; i < ARGC; ++i)
- strip_module(ARGV[i]);
-
- do_command(rm " -f " tmpcopy " " nmout);
-
- exit(0);
-}
-
-function strip_module(object,
- keep_symbol, to_strip, symbol, command, changed) {
- do_command(cp " -a " object " " tmpcopy);
- do_command(nm " " tmpcopy " > " nmout);
- # delete array_name sometimes breaks, internal error, play safe
- for (symbol in keep_symbol)
- delete keep_symbol[symbol];
- for (symbol in to_strip)
- delete to_strip[symbol];
- new_module_format = 0;
- ptrskip = 2 + 2 * ENVIRON["SIZEOF_POINTER"];
- while ((getline < nmout) > 0) {
- $0 = substr($0, ptrskip);
- # b static variable, uninitialised
- # d static variable, initialised
- # r static array, initialised
- # t static label/procedures
- if ($1 ~ /[bdrt]/)
- to_strip[$2] = "";
- else if ($2 ~ /R __ksymtab_/)
- keep_symbol[substr($2, 11)] = "";
- else if ($0 ~ /R __module_parm_/)
- keep_symbol[substr($2, 15)] = "";
- else if ($0 ~ /D __parm_/)
- keep_symbol[substr($2, 8)] = "";
- else if ($3 ~ /__ksymtab/) {
- keep_symbol[$5] = "";
- }
- else if ($1 != "?")
- keep_symbol[$2] = "";
- if ($2 ~ /__module/)
- new_module_format = 1;
- }
- close(nmout);
- command = "";
- changed = 0;
- failure = 0;
- if (new_module_format) {
- for (symbol in to_strip) {
- if (!(symbol in keep_symbol)) {
- changed = 1;
- if (length(command) > command_size) {
- failure = failure || do_command(strip command " " tmpcopy);
- command = "";
- }
- command = command " --strip-symbol=" symbol;
- }
- }
- }
- if (command != "") {
- changed = 1;
- failure = failure || do_command(strip command " " tmpcopy);
- }
- if (changed && !failure)
- do_command(mv " " tmpcopy " " object);
-}
-
-function do_command(command) {
- if ((ret = system(command)) != 0) {
- giveup("command \"" command "\" failed " ret, ret);
- return 1;
- }
- return 0;
-}
-
-function giveup(message, ret) {
- print "strip_module: " message > "/dev/stderr";
-# exit(ret);
-}
-EOF
-
-awk -f /tmp/$$.awk "$@"
-ret=$?
-rm -f /tmp/$$.awk
-exit $ret
diff --git a/kernel/update_kernel b/kernel/update_kernel
deleted file mode 100755
index a32878339..000000000
--- a/kernel/update_kernel
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/perl
-
-# this script takes kernels rpms from RPMS/ and create various files in all_kernels/
-# for each rpms in RPMS, it does:
-# RPMS/kernel-VER-*.rpm ->
-# all.kernels/VER/all_modules.tar (used for all.rdz)
-# all.kernels/VER/*.mar (used for other rdz)
-# all.kernels/VER/modules.cz (used for stage2)
-# all.kernels/VER/modules.dep
-# all.kernels/VER/vmlinuz
-#
-# if RPMS is empty, this script tries to find kernels in $main_repository
-
-use MDK::Common;
-use list_modules;
-
-my $main_repository = '/export/media/main';
-my $rpm = 'rpm --nosignature';
-
-
-my $MOVE = $ARGV[0] eq '--move' && shift;
-
-@ARGV <= 1 or die "usage: ./update_kernel [--move] [<kernel rpm>]\n";
-
-eval { rm_rf('all.kernels') }; #- remove old things
-mkdir 'all.kernels';
-
-my $main = chomp_(cat_('RPMS/.main'));
-my $main_BOOT = chomp_(cat_('RPMS/.main-BOOT'));
-
-if (@ARGV) {
- install_kernel($ARGV[0]);
-} elsif (! -d 'RPMS') {
- update_kernel_from_repository($main_repository, '2.6', 0);
- update_kernel_from_repository($main_repository, '2.6', 1);
- install_kernel(glob("$main_repository/kernel-xbox*"), 1) if arch() =~ /i.86/;
-}
-
-extract_kernel($_) foreach glob("RPMS/*.rpm");
-
-sub system_verbose { print join(' ', @_), "\n"; system(@_) }
-sub sys { &system_verbose; $? and die }
-
-sub rpm2version {
- my ($kernel_rpm) = @_;
- `$rpm -qpl $kernel_rpm` =~ m!/boot/vmlinuz-(.*)! && $1 or die "can't find vmlinuz in $kernel_rpm\n";
-}
-
-sub update_kernel_from_repository {
- my ($repository, $main_ver, $is_BOOT) = @_;
- my $rpm_wildcard = 'kernel-' . ($is_BOOT ? 'BOOT-' : (arch() =~ /i.86/ ? 'i586-up-1GB-' : '')) . $main_ver . '*.rpm';
- my @kernels = glob("$repository/$rpm_wildcard");
-
- install_kernel($_, 1) foreach @kernels;
-}
-
-sub install_kernel {
- my ($kernel_rpm) = @_;
- my $basename = basename($kernel_rpm);
- warn "Installing rpm $basename in RPMS\n";
- mkdir 'RPMS';
- cp_af($kernel_rpm, "RPMS/$basename");
-
- if (!$main) {
- $main = rpm2version($kernel_rpm);
- output('RPMS/.main', "$main\n");
- }
- if (!$main_BOOT && $kernel_rpm =~ /BOOT/) {
- $main_BOOT = rpm2version($kernel_rpm);
- output('RPMS/.main-BOOT', "$main_BOOT\n");
- }
-}
-
-sub extract_kernel {
- my ($kernel_rpm) = @_;
-
- my $kern_ver = rpm2version($kernel_rpm);
- my $dir = "all.kernels/$kern_ver";
-
- warn "Extracting kernel $kern_ver\n";
-
- eval { rm_rf($dir) };
- mkdir_p("$dir/modules");
- sys("rpm2cpio $kernel_rpm | (cd $dir ; cpio -id)");
-
- rename "$dir/boot/vmlinuz-$kern_ver", "$dir/vmlinuz" or die "can't find vmlinuz\n";
-
- sys("find $dir -name '*.gz' | xargs gunzip");
-
- my $ext = module_extension($kern_ver);
-
- open(my $F, "find $dir -name '*.$ext' |");
- my $file; while ($file = <$F>) {
- chomp($file);
- rename $file, "$dir/modules/" . basename($file) or warn "conflict for $file\n";
- }
-
- if (kernel_is_26($kern_ver)) {
- warn "no stripping on 2.6 since it breaks modules\n";
- } else {
- print STDERR "stripping $kern_ver: ";
- sys("./strip_modules $dir/modules/*.$ext");
- print STDERR "done\n";
- }
-
- sys('perl', 'modules.pl', 'remove_unneeded_modules', $kern_ver) if $kern_ver !~ /BOOT/;
-
- sys('perl', 'modules.pl', 'make_modules_per_image', $kern_ver);
- sys('perl', 'modules.pl', 'make_modules_description', $kern_ver) if $kern_ver eq $main;
-
- if (!$MOVE) {
- print STDERR "packdrake $kern_ver: ";
- sys("cd $dir/modules ; ls *.$ext | packdrake -b9s ../modules.cz 400000");
- print STDERR "done\n";
- }
-
- eval { rm_rf("$dir$_") } foreach qw(/boot /lib /usr /modules);
-}
diff --git a/make_boot_img b/make_boot_img
deleted file mode 100755
index a1e46bbf7..000000000
--- a/make_boot_img
+++ /dev/null
@@ -1,843 +0,0 @@
-#!/usr/bin/perl
-
-use Config;
-use MDK::Common;
-Config->import;
-my ($arch) = $Config{archname} =~ /(.*?)-/;
-
-my $default_append = "ramdisk_size=128000";
-# full acpi support for x86_64, enough acpi support for x86 ht, no acpi for others
-my $default_acpi = $arch =~ /i.86/ ? "acpi=ht" : $arch =~ /x86_64/ ? "" : "acpi=off";
-my $default_vga = "vga=788 splash=silent";
-my $timeout = 150;
-
-my $instdir = "mdk-stage1";
-my $tmp_mnt = '/tmp/drakx_mnt';
-my $tmp_mnt_initrd = '/tmp/drakx_mnt2';
-
-my $sudo;
-if ($>) {
- $sudo = "sudo";
- $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
-}
-
-sub __ { print @_, "\n"; system(@_) }
-sub _ { __ @_; $? and die }
-sub mke2fs {
- my ($f) = @_;
- _ "/sbin/mke2fs -q -m 0 -F -s 1 $f";
- _ "/sbin/tune2fs -c 0 -U clear -T 1970010101 $f";
-}
-
-_ "$sudo mkdir -p $tmp_mnt $tmp_mnt_initrd";
-mkdir "images";
-
-my $main = chomp_(cat_('kernel/RPMS/.main'));
-my $main_BOOT = chomp_(cat_('kernel/RPMS/.main-BOOT'));
-my @kernels = grep { !/xbox/ } all('kernel/all.kernels');
-my @kernels_BOOT = grep { /BOOT/ } @kernels;
-
-my @all_images = (
- if_($arch =~ /i.86|x86_64/, 'cdrom.img', 'cdrom-changedisk.img', 'pcmcia.img', 'isolinux', 'boot.iso', 'all.img', 'hd_grub.img', 'network.img', 'network_drivers.img'),
- if_($arch =~ /ia64/, 'all.img'),
- if_($arch =~ /ppc/, 'all.img'),
- );
-
-my @images = @ARGV ? @ARGV : map { "images/$_" } @all_images;
-
-if (any { /move/ } @images) {
- -e "$instdir/init-move" or die "ERROR: $instdir not built for move\n";
-} else {
- -e "$instdir/init-move" and die "ERROR: $instdir built for move\n";
-}
-
-foreach my $img (@images) {
- my ($type, $I, $extension) = $img =~ m!([^/]*)(64)?\.([^.]*)$!;
-
- if ($img =~ /hd_grub/) {
- hd_grub($img);
- } elsif ($img =~ /isolinux/) {
- isolinux($main, @kernels);
-
- if (my ($tftpboot) = grep { -e $_ } qw(/tftpboot /var/lib/tftpboot)) {
- system("/bin/cp -f isolinux/alt0/* $tftpboot");
- }
- } elsif ($img =~ /move/) {
- isolinux_move($main);
-
- if (my ($tftpboot) = grep { -e $_ } qw(/tftpboot /var/lib/tftpboot)) {
- system("/bin/cp -f move/isolinux/* $tftpboot/move 2>/dev/null");
- }
- } elsif ($img =~ /boot.iso/) {
- boot_iso($img, \@kernels);
- } elsif ($img =~ /drivers/) {
- drivers($type, $I, "$img-$_") foreach @kernels_BOOT;
- rename("$img-$main_BOOT", $img);
- } elsif ($extension eq 'rdz') {
- initrd($tmp_mnt_initrd, $type, $I, "$img-$_") foreach @kernels;
- } elsif ($extension eq 'img') {
- print STDERR "calling boot_img_$arch for $img\n";
- $::{"boot_img_$arch"}->($type, $I, "$img-$_", "kernel/all.kernels/$_/vmlinuz") foreach $type eq 'all' ? @kernels : @kernels_BOOT;
- rename("$img-$main", $img) or rename("$img-$main_BOOT", $img);
- } else {
- die "unknown image $img";
- }
-}
-
-sub syslinux_color {
- "0" . {
- default => '7',
- blue => '9',
- green => 'a',
- red => 'c',
- yellow => 'e',
- white => 'f',
- }->{$_[0]} || die "unknown color $_[0]\n";
-}
-
-sub syslinux_msg {
- my ($msg_xml_file, @more_text) = @_;
-
- require XML::Parser;
-
- sub xml_tree2syslinux {
- my ($current_color, $tree) = @_;
- my (undef, @l) = @$tree;
- join('', map {
- my ($type, $val) = @$_;
- if ($type eq '0') {
- $val;
- } else {
- syslinux_color($type) . xml_tree2syslinux($type, $val) . syslinux_color($current_color);
- }
- } group_by2(@l));
- }
-
- print "parsing $msg_xml_file\n";
- my $tree = XML::Parser->new(Style => 'Tree')->parsefile($msg_xml_file);
- $tree->[0] eq 'document' or die "bad file $msg_xml_file\n";
- my $text = xml_tree2syslinux('default', $tree->[1]);
-
- pack("C*", 0x0E, 0x80, 0x03, 0x00) . " "
- . $text . join('', @more_text)
- . "\n" . syslinux_color('red') . "[F1-Help] [F2-Advanced Help] [F3-Main]" . syslinux_color('default') . "\n";
-}
-
-sub syslinux_cfg {
- my (@entries) = @_;
-
- my $header = <<EOF;
-default linux
-prompt 1
-timeout $timeout
-display boot.msg
-F1 help.msg
-F2 advanced.msg
-F3 boot.msg
-EOF
-
- my @l = map {
- "label $_->{label}\n" .
- " kernel $_->{kernel}\n" .
- ($_->{initrd} ? " append initrd=$_->{initrd} $_->{append}\n" : '');
- } @entries;
-
- $header . join('', @l);
-}
-
-sub install_stripped { _ "strip $_[0]"; _ "$sudo install $_[0] $_[1]" }
-
-sub initrd {
- my ($mnt, $type, $I, $img, $o_raw_stage1_tree_kind) = @_;
- my $tmp = "$ENV{HOME}/tmp/initrd";
- my $tar = "$instdir/stage1-data/stage1$o_raw_stage1_tree_kind.tar.bz2";
-
- __ "$sudo umount $tmp $mnt 2>/dev/null";
- _ "dd if=/dev/zero of=$tmp bs=1k count=" . ($arch =~ /ia64/ || $type eq "all" ? 16384 : 2000);
- mke2fs($tmp);
- _ "$sudo mount -t ext2 $tmp $mnt -o loop";
-
- _ "$sudo tar xjC $mnt -f $tar";
- symlinkf "/tmp/stage2/lib64", "$mnt/lib64" if $arch =~ /x86_64/;
-
- {
- my $install = ${{
- network => "stage1-network",
- cdrom => "stage1-cdrom",
- }}{$type} || 'stage1-full';
- install_stripped("$instdir/init", "$mnt/sbin");
- install_stripped("$instdir/$install", "$mnt/sbin/stage1");
- }
-
- if (member($type, qw(network all))) {
- install_stripped("$instdir/ppp/pppd-bin", "$mnt/sbin/pppd");
- install_stripped("$instdir/rp-pppoe/pppoe-bin", "$mnt/sbin/pppoe");
- _ "$sudo mknod $mnt/dev/ppp c 108 0";
- _ "$sudo mknod $mnt/dev/ptyp0 c 2 0";
- _ "$sudo mknod $mnt/dev/ttyp0 c 3 0";
- }
-
- if (member($type, qw(pcmcia all network)) && $arch !~ /ppc|ia64/) {
- _ "$sudo cp -a /etc/pcmcia $mnt/etc";
- _ "cp $mnt/etc/pcmcia/config /tmp/pcmcia_config_tmp";
- _ "tools/patch_pcmcia_config.pl /tmp/pcmcia_config_tmp kernel/all.kernels/$main/modules.dep";
- _ "sudo mv /tmp/pcmcia_config_tmp $mnt/etc/pcmcia/config";
- }
- my ($ext) = $img =~ /rdz-(.*)/ or die "bad initrd name ($img)";
- my $modz = "kernel/all.kernels$I/$ext";
- if ($type eq 'all') {
- __ "$sudo tar xC $mnt/modules -f $modz/${type}_modules.tar";
- } else {
- _ "$sudo cp -f $modz/${type}_modules.mar $mnt/modules/modules$I.mar";
- }
- _ "$sudo cp -f $modz/modules.dep $mnt/modules/";
- _ "$sudo cp -f /sbin/sash $mnt/tmp/sh" if $type eq 'all' && $ENV{DEBUGSTAGE1};
- _ "$sudo umount $mnt";
-
-# Workaround for vfat-loop bug (quite touchy)
- _ "gzip -9f $tmp";
- _ "cp -f $tmp.gz $img";
- _ "rm -f $tmp.gz";
-# _ "gzip -9 -c $tmp > $img";
-# _ "rm -f $tmp";
-}
-
-sub entries_append {
- my ($type) = @_;
-
- my $automatic = $type =~ /cdrom/ ? 'automatic=method:cdrom ' : '';
- $automatic .= 'changedisk ' if $type =~ /changedisk/;
-
- my @simple_entries = (
- linux => $default_vga,
- vgalo => "vga=785",
- vgahi => "vga=791",
- vga16 => "vga16",
- text => "text",
- patch => "patch $default_vga",
- rescue => "rescue",
- );
- my @entries = (
- (map { $_->[0] => "$automatic$default_acpi $_->[1]" } group_by2(@simple_entries)),
- acpi => "$automatic$default_vga",
- );
-
- map { { label => $_->[0], append => "$default_append $_->[1]" } }
- group_by2(@entries);
-}
-
-sub syslinux_cfg_all {
- my ($type) = @_;
-
- syslinux_cfg(
- (map {
- { kernel => 'alt0/vmlinuz', initrd => 'alt0/all.rdz', %$_ };
- } entries_append($type)),
- (map_index {
- { label => "alt$::i", kernel => "alt$::i/vmlinuz", initrd => "alt$::i/all.rdz",
- append => "$default_append $default_acpi $default_vga" };
- } @kernels),
- { label => 'memtest', kernel => 'test/memtest.bin' },
- );
-}
-sub remove_ending_zero {
- my ($img) = @_;
- _(q(perl -0777 -pi -e 's/\0+$//' ) . $img);
-}
-
-sub boot_img_i386 {
- my ($type, $I, $img, $kernel) = @_;
-
- __ "$sudo umount $tmp_mnt 2>/dev/null";
-
- _ "dd if=/dev/zero of=$img bs=1k count=" . ($type eq 'all' ? 7000 : 1440);
- my $mk_options = $type eq 'all' ? '' : '-f 1 -r 16 -s 2'; # keep the FAT bookkeeping as small as possible
- _ "mkdosfs $mk_options $img";
- _ "$sudo syslinux-graphic $img";
-
- _ "$sudo mount -t vfat -o umask=0 $img $tmp_mnt -o loop";
- _ "cat $kernel > $tmp_mnt/vmlinuz";
- _ "lilo-bmp2mdk file:isolinux-graphic" . ($type eq 'all' ? '' : '-simple') . ".bmp >$tmp_mnt/boot.msg";
-
- output("$tmp_mnt/help.msg", syslinux_msg('help.msg.xml'));
- output("$tmp_mnt/advanced.msg", syslinux_msg('advanced.msg.xml'));
-
- (my $rdz = $img) =~ s/\.img/.rdz/;
- (my $initrd_type = $type) =~ s/-changedisk//;
- initrd($tmp_mnt_initrd, $initrd_type, $I, $rdz);
- my $short_type = substr($type, 0, 8);
-
- output("$tmp_mnt/syslinux.cfg",
- syslinux_cfg(map {
- { kernel => 'vmlinuz', initrd => "$short_type.rdz", %$_ };
- } entries_append($type)));
-
- eval { _ "cp -f $rdz $tmp_mnt/$short_type.rdz" };
- if ($@) {
- #- argh not enough room, try to suggest how to solve this
- unlink "$tmp_mnt/$short_type.rdz";
- my $avail = (split ' ', `df $tmp_mnt`)[-3];
- my $s = int((-s $rdz) / 1024);
-
- my ($ext) = $img =~ /\.img-(.*)/ or die "bad initrd name ($img)";
- my $dir = "kernel/all.kernels/$ext";
- my $pcitable = cat_('/usr/share/ldetect-lst/pcitable');
- my @l = sort { $a <=> $b } map {
- my ($name) = /(\S+)\.k?o$/ or die "bad file in .mar";
- my $gz_size = chomp_(`tar xOf $dir/all_modules.tar $_ | gzip | wc -c`);
- sprintf "%7d %6d %s\n", $gz_size, listlength($pcitable =~ /"$name"/g), $name;
- } split(' ', `mdk-stage1/mar/mar -l $dir/${initrd_type}_modules.mar`);
- output('.not-enough-room', "gz size - pcitable - name\n", @l);
-
- warn sprintf("not enough room for $rdz: need %dKB (available %dKB < needed %dKB)\n", $s - $avail, $avail, $s);
- die qq(check file ".not-enough-room" to see modules size and pcitable usage\n);
- }
- unlink $rdz;
-
- _ "sync";
- _ "df $tmp_mnt";
- _ "$sudo umount $tmp_mnt";
-}
-
-# alias to x86 variant, slightly bigger with images though
-sub boot_img_x86_64 { &boot_img_i386 }
-
-sub boot_img_alpha {
- my ($type, $I, $img) = @_;
-
- __ "$sudo umount $tmp_mnt 2>/dev/null";
- _ "dd if=/dev/zero of=$img bs=1k count=1440";
- mke2fs($img);
- _ "/sbin/e2writeboot $img /boot/bootlx";
- _ "$sudo mount -t ext2 $img $tmp_mnt -o loop";
- _ "cp -f vmlinux.gz $tmp_mnt";
- -f "$type.rdz" ? _ "cp -f $type.rdz $tmp_mnt" : initrd($tmp_mnt_initrd, $type, $I, "$tmp_mnt/$type.rdz");
-
- mkdir "$tmp_mnt/etc", 0777;
- output("$tmp_mnt/etc/aboot.conf",
-"0:vmlinux.gz initrd=$type.rdz rw $default_append $type
-1:vmlinux.gz initrd=$type.rdz rw $default_append text $type
-");
- _ "sync";
- _ "df $tmp_mnt";
-}
-
-sub boot_img_ia64 {
- my ($type, $_I, $img, $kernel) = @_;
- my $rdz = $img; $rdz =~ s/\.img/.rdz/;
-
- __ "$sudo umount $tmp_mnt 2>/dev/null";
- _ "dd if=/dev/zero of=$img bs=1k count=16384";
- _ "mkdosfs $img";
- _ "$sudo mount -t vfat $img $tmp_mnt -o loop,umask=000";
- _ "$sudo cp -f $kernel $tmp_mnt/vmlinux";
- _ "cp -f $rdz $tmp_mnt/$type.rdz";
- _ "$sudo cp -f tools/ia64/elilo.efi $tmp_mnt";
- output("$tmp_mnt/elilo.conf", qq(
-prompt
-timeout=50
-
-image=vmlinux
- label=linux
- initrd=$type.rdz
- append=" ramdisk_size=120000"
- read-only
-
-image=vmlinux
- label=rescue
- initrd=$type.rdz
- append=" rescue ramdisk_size=120000"
-"));
- _ "sync";
- _ "df $tmp_mnt";
-
-}
-
-sub boot_img_sparc {
- my ($type, $I, $_img) = @_;
- if ($type =~ /^live(.*)/) {
- #- hack to produce directly into /export the needed file for cdrom boot.
- my $dir = "/export";
- my $boot = "boot"; #- non-absolute pathname only!
-
- _ "mkdir -p $dir/$boot";
- _ "cp -f /boot/cd.b /boot/second.b $dir/$boot";
- _ "cp -f vmlinux$1 $dir/$boot/vmlinux$1";
- -f "live$1.rdz" ? _ "cp -f live$1.rdz $dir/$boot" : initrd($tmp_mnt_initrd, $type, $I, "$dir/$boot/live$1.rdz");
-
- output("$dir/$boot/silo.conf", qq(
-partition=1
-default=linux
-timeout=100
-read-write
-message=/$boot/boot.msg
-image="cat /$boot/boot.msg"
- label=1
- single-key
-image="cat /$boot/general.msg"
- label=2
- single-key
-image="cat /$boot/expert.msg"
- label=3
- single-key
-image="cat /$boot/rescue.msg"
- label=4
- single-key
-image="cat /$boot/kickit.msg"
- label=5
- single-key
-image="cat /$boot/param.msg"
- label=6
- single-key
-image[sun4c,sun4d,sun4m]=/$boot/vmlinux
- label=linux
- alias=install
- initrd=/$boot/live.rdz
- append="ramdisk_size=128000"
-image[sun4c,sun4d,sun4m]=/$boot/vmlinux
- label=text
- initrd=/$boot/live.rdz
- append="ramdisk_size=128000 text"
-image[sun4c,sun4d,sun4m]=/$boot/vmlinux
- label=expert
- initrd=/$boot/live.rdz
- append="ramdisk_size=128000 expert"
-image[sun4c,sun4d,sun4m]=/$boot/vmlinux
- label=ks
- initrd=/$boot/live.rdz
- append="ramdisk_size=128000 ks"
-image[sun4c,sun4d,sun4m]=/$boot/vmlinux
- label=rescue
- initrd=/$boot/live.rdz
- append="ramdisk_size=128000 rescue"
-image[sun4u]=/$boot/vmlinux64
- label=linux
- alias=install
- initrd=/$boot/live64.rdz
- append="ramdisk_size=128000"
-image[sun4u]=/$boot/vmlinux64
- label=text
- initrd=/$boot/live64.rdz
- append="ramdisk_size=128000 text"
-image[sun4u]=/$boot/vmlinux64
- label=expert
- initrd=/$boot/live64.rdz
- append="ramdisk_size=128000 expert"
-image[sun4u]=/$boot/vmlinux64
- label=ks
- initrd=/$boot/live64.rdz
- append="ramdisk_size=128000 ks"
-image[sun4u]=/$boot/vmlinux64
- label=rescue
- initrd=/$boot/live64.rdz
- append="ramdisk_size=128000 rescue"
-"));
-
- output("$dir/$boot/README", "
-To Build a Bootable CD-ROM, try:
- mkisofs -R -o t.iso -s /$boot/silo.conf /export
-");
- } elsif ($type =~ /^tftprd(.*)/) {
- my $dir = "/export";
- my $boot = "images";
- my $setarch = $1 ? "sparc64" : "sparc32";
-
- _ "mkdir -p $dir/$boot";
- -f "$type.rdz" or initrd($tmp_mnt_initrd, $type, $I, "$type.rdz");
- _ "cp -f vmlinux$1.aout $dir/$boot/$type.img";
- _ "$setarch kernel$1/src/arch/sparc$1/boot/piggyback $dir/$boot/$type.img kernel$1/boot/System.map $type.rdz";
- } elsif ($type =~ /^tftp(.*)/) {
- my $dir = "/export";
- my $boot = "images";
-
- _ "mkdir -p $dir/$boot";
- _ "cp -f vmlinux$1.aout $dir/$boot/$type.img";
- } else {
- my $dir = "floppy";
- __ "$sudo umount $tmp_mnt 2>/dev/null";
- _ "rm -rf $dir";
- _ "mkdir -p $dir";
- _ "cp -f /boot/fd.b /boot/second.b $dir";
- _ "cp -f vmlinuz$I $dir/vmlinux$I.gz";
- -f "$type.rdz" ? _ "cp -f $type.rdz $dir" : initrd($tmp_mnt_initrd, $type, $I, "$dir/$type.rdz");
-
- output("$dir/boot.msg", "
-Welcome to Mandrakelinux 7.1
-
-Press <Enter> to install or upgrade a system 7mMandrakelinux7m
-");
-
- output("$dir/silo.conf", qq(
-partition=1
-default=linux
-timeout=100
-read-write
-message=/boot.msg
-image=/vmlinux$I.gz
- label=linux
- initrd=/$type.rdz
- append="ramdisk_size=128000 $type"
-"));
- _ "genromfs -d $dir -f /dev/ram -A 2048,/.. -a 512 -V 'DrakX boot disk'";
- _ "$sudo mount -t romfs /dev/ram $tmp_mnt";
- _ "silo -r $tmp_mnt -F -i /fd.b -b /second.b -C /silo.conf";
- _ "$sudo umount $tmp_mnt";
- _ "dd if=/dev/ram of=$type.img bs=1440k count=1";
- _ "sync";
- _ "$sudo mount -t romfs /dev/ram $tmp_mnt";
- _ "df $tmp_mnt";
- }
-}
-
-sub boot_img_ppc() {
- #- hack to produce directly into /export the needed file for cdrom boot.
- my $dir = "/export";
- my $boot = "boot"; #- non-absolute pathname only!
- _ "rm -rf $dir/$boot"; mkdir "$dir/$boot", 0777;
- foreach (glob("kernel/all.kernels/*")) {
- my $ext = basename($_);
- if ($ext =~ /power4/) {
- _ "cp $_/boot/vmlinuz-$ext* $dir/$boot/vmlinux-power4";
- _ "cp images/all.rdz-$ext $dir/$boot/all-power4.gz";
- }
- elsif ($ext =~ /2.6/) {
- _ "cp $_/boot/vmlinuz-$ext $dir/$boot/vmlinux";
- _ "cp images/all.rdz-$ext $dir/$boot/all.gz";
- }
- elsif ($ext =~ /2.4/) {
- _ "cp $_/boot/vmlinux $dir/$boot/vmlinux-2.4";
- _ "cp images/all.rdz-$ext $dir/$boot/all-2.4.gz";
- }
- }
- _ "cp -f /usr/lib/yaboot/yaboot $dir/$boot/yaboot";
-
- output("$dir/$boot/ofboot.b", '<CHRP-BOOT>
-<COMPATIBLE>
-MacRISC
-</COMPATIBLE>
-<DESCRIPTION>
-Mandrakelinux PPC bootloader
-</DESCRIPTION>
-<BOOT-SCRIPT>
-" screen" output
-load-base release-load-area
-dev screen
-" "(0000000000aa00aa0000aaaaaa0000aa00aaaa5500aaaaaa)" drop 0 8 set-colors
-" "(5555555555ff55ff5555ffffff5555ff55ffffff55ffffff)" drop 8 8 set-colors
-device-end
-3 to foreground-color
-0 to background-color
-" "(0C)" fb8-write drop
-" Booting Mandrakelinux PPC..." fb8-write drop 100 ms
-boot cd:,\boot\yaboot
-</BOOT-SCRIPT>
-<OS-BADGE-ICONS>
-1010
-000000000000F8FEACF6000000000000
-0000000000F5FFFFFEFEF50000000000
-00000000002BFAFEFAFCF70000000000
-0000000000F65D5857812B0000000000
-0000000000F5350B2F88560000000000
-0000000000F6335708F8FE0000000000
-00000000005600F600F5FD8100000000
-00000000F9F8000000F5FAFFF8000000
-000000008100F5F50000F6FEFE000000
-000000F8F700F500F50000FCFFF70000
-00000088F70000F50000F5FCFF2B0000
-0000002F582A00F5000008ADE02C0000
-00090B0A35A62B0000002D3B350A0000
-000A0A0B0B3BF60000505E0B0A0B0A00
-002E350B0B2F87FAFCF45F0B2E090000
-00000007335FF82BF72B575907000000
-000000000000ACFFFF81000000000000
-000000000081FFFFFFFF810000000000
-0000000000FBFFFFFFFFAC0000000000
-000000000081DFDFDFFFFB0000000000
-000000000081DD5F83FFFD0000000000
-000000000081DDDF5EACFF0000000000
-0000000000FDF981F981FFFF00000000
-00000000FFACF9F9F981FFFFAC000000
-00000000FFF98181F9F981FFFF000000
-000000ACACF981F981F9F9FFFFAC0000
-000000FFACF9F981F9F981FFFFFB0000
-00000083DFFBF981F9F95EFFFFFC0000
-005F5F5FDDFFFBF9F9F983DDDD5F0000
-005F5F5F5FDD81F9F9E7DF5F5F5F5F00
-0083DD5F5F83FFFFFFFFDF5F835F0000
-000000FBDDDFACFBACFBDFDFFB000000
-000000000000FFFFFFFF000000000000
-0000000000FFFFFFFFFFFF0000000000
-0000000000FFFFFFFFFFFF0000000000
-0000000000FFFFFFFFFFFF0000000000
-0000000000FFFFFFFFFFFF0000000000
-0000000000FFFFFFFFFFFF0000000000
-0000000000FFFFFFFFFFFFFF00000000
-00000000FFFFFFFFFFFFFFFFFF000000
-00000000FFFFFFFFFFFFFFFFFF000000
-000000FFFFFFFFFFFFFFFFFFFFFF0000
-000000FFFFFFFFFFFFFFFFFFFFFF0000
-000000FFFFFFFFFFFFFFFFFFFFFF0000
-00FFFFFFFFFFFFFFFFFFFFFFFFFF0000
-00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00
-00FFFFFFFFFFFFFFFFFFFFFFFFFF0000
-000000FFFFFFFFFFFFFFFFFFFF000000
-</OS-BADGE-ICONS>
-</CHRP-BOOT>
-');
-
- output("$dir/$boot/yaboot.conf", '
-init-message = "\nWelcome to Mandrakelinux PPC!\nHit <TAB> for boot options.\n\n"
-timeout = 150
-device=cd:
-default = install-gui
-message=/boot/yaboot.msg
-
-image = /boot/vmlinux
- label = install-gui
- initrd = /boot/all.gz
- initrd-size = 34000
- append = " ramdisk_size=128000"
-
-image = /boot/vmlinux-power4
- label = install-gui-power4
- initrd = /boot/all-power4.gz
- initrd-size = 34000
- append = " ramdisk_size=128000"
-
-image = /boot/vmlinux
- label = install-text
- initrd = /boot/all.gz
- initrd-size = 34000
- append = " text ramdisk_size=128000"
-
-image = /boot/vmlinux-power4
- label = install-text-power4
- initrd = /boot/all-power4.gz
- initrd-size = 34000
- append = " text ramdisk_size=128000"
-
-image = /boot/vmlinux
- label = install-gui-old
- initrd = /boot/all.gz
- initrd-size = 34000
- append = " gui-old ramdisk_size=128000"
-
-image = /boot/vmlinux-power4
- label = install-gui-old-power4
- initrd = /boot/all-power4.gz
- initrd-size = 34000
- append = " gui-old ramdisk_size=128000"
-
-image = enet:0,vmlinux
- label = install-net
- initrd = enet:0,all.gz
- initrd-size = 34000
- append = " ramdisk_size=128000"
-
-image = enet:0,vmlinux-power4
- label = install-net-power4
- initrd = enet:0,all-power4.gz
- initrd-size = 34000
- append = " ramdisk_size=128000"
-
-image = enet:0,vmlinux
- label = install-net-text
- initrd = enet:0,all.gz
- initrd-size = 34000
- append = " text ramdisk_size=128000"
-
-image = enet:0,vmlinux-power4
- label = install-net-text-power4
- initrd = enet:0,all-power4.gz
- initrd-size = 34000
- append = " text ramdisk_size=128000"
-
-image = /boot/vmlinux
- label = rescue
- initrd = /boot/all.gz
- initrd-size = 34000
- append = " rescue ramdisk_size=128000"
-
-image = /boot/vmlinux-power4
- label = rescue-power4
- initrd = /boot/all-power4.gz
- initrd-size = 34000
- append = " rescue ramdisk_size=128000"
-
-image = enet:0,vmlinux
- label = rescue-net
- initrd = enet:0,all.gz
- initrd-size = 34000
- append = " rescue ramdisk_size=128000"
-
-image = enet:0,vmlinux-power4
- label = rescue-net-power4
- initrd = enet:0,all-power4.gz
- initrd-size = 34000
- append = " rescue ramdisk_size=128000"
-');
-
- output("$dir/$boot/yaboot.msg", '
-Thanks for choosing Mandrakelinux PPC. The following is a short
-explanation of the various options for booting the install CD.
-
-All options ending with "-power4" use the BOOT kernel for ppc 9xx and POWER4.
-The default syntax with no suffix uses the BOOT kernel for ppc 6xx 7xx and 7xxx.
-The default if you just hit enter is "install-gui".
-
-install-gui: uses Xorg fbdev mode
-install-text: text based install
-install-net: allows you to use a minimal boot CD,
- pulling the rest of the install from
- a network server
-install-net-text: text mode network install
-rescue: boots the rescue image
-rescue-net: boots the rescue image from a network server
-
-');
-
-}
-
-sub VERSION {
- my ($kernels) = @_;
-
- map { "$_\n" }
- $ENV{DISTRIB_DESCR},
- scalar gmtime(),
- '', @$kernels;
-}
-
-sub syslinux_all_files {
- my ($dir, $kernels) = @_;
-
- eval { rm_rf($dir) }; mkdir_p($dir);
-
- @$kernels or die "syslinux_all_files: no kernel\n";
-
- $default_vga =~ /788/ or die 'we rely on vga=788 for bootsplash';
- my $bootspash_cfg = '/etc/bootsplash/themes/Mandrakelinux/config/bootsplash-800x600.cfg';
- -e $bootspash_cfg or die "can't find $bootspash_cfg";
-
- each_index {
- mkdir "$dir/alt$::i", 0777;
- _ "cp kernel/all.kernels/$_/vmlinuz $dir/alt$::i";
- initrd($tmp_mnt_initrd, 'all', '', "images/all.rdz-$_");
- _ "splash -s -f $bootspash_cfg >> images/all.rdz-$_" if !/BOOT/;
- rename("images/all.rdz-$_", "$dir/alt$::i/all.rdz");
- } @$kernels;
-
- _ "lilo-bmp2mdk file:isolinux-graphic.bmp >$dir/boot.msg";
-
- _ "install -m 644 -D /boot/memtest* $dir/test/memtest.bin";
-
- output("$dir/help.msg", syslinux_msg('help.msg.xml'));
- output("$dir/advanced.msg", syslinux_msg('advanced.msg.xml',
- "\nYou can choose the following kernels :\n",
- map_index { " o " . syslinux_color('white') . "alt$::i" . syslinux_color('default') . " is kernel $_\n" } @$kernels));
-}
-
-sub isolinux {
- my ($main, @kernels) = @_;
- @kernels = ($main, grep { $_ ne $main } @kernels);
-
- syslinux_all_files('isolinux', \@kernels);
-
- _ "cp /usr/lib/syslinux/isolinux.bin isolinux/isolinux.bin";
- output("isolinux/isolinux.cfg", syslinux_cfg_all('cdrom'));
-}
-
-sub boot_iso {
- my ($iso, $kernels) = @_;
-
- syslinux_all_files('.boot_iso/isolinux', $kernels);
-
- output('.boot_iso/VERSION', VERSION($kernels));
-
- _ "cp /usr/lib/syslinux/isolinux.bin .boot_iso/isolinux/isolinux.bin";
- output('.boot_iso/isolinux/isolinux.cfg', syslinux_cfg_all(''));
-
- _ "mkisofs -r -f -J -cache-inodes -V 'Mdk Boot ISO' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o $iso .boot_iso";
- rm_rf('.boot_iso');
-}
-
-sub isolinux_move {
- my ($main) = @_;
-
- _ "cp kernel/all.kernels/$main/vmlinuz move/isolinux";
- initrd($tmp_mnt_initrd, 'all', '', "move/isolinux/all.rdz-$main", '-with-busybox');
- rename "move/isolinux/all.rdz-$main", "move/isolinux/all.rdz";
-
- _ "lilo-bmp2mdk file:move/data/isolinux-graphic.bmp >move/isolinux/boot.msg";
- _ "cp /usr/lib/syslinux/isolinux.bin move/isolinux/isolinux.bin";
-}
-
-sub hd_grub {
- my ($img) = @_;
- my $mapfile = '/tmp/device.map.tmp';
-
- my @grub_files = map { "/boot/grub/$_" } qw(stage1 stage2);
- my $size = 40_000 + sum(map { -s $_ } @grub_files);
-
- __ "$sudo umount $tmp_mnt 2>/dev/null";
- _ "dd if=/dev/zero of=$img bs=1 count=$size";
- _ "mkdosfs $img";
- _ "$sudo mount -t vfat -o umask=0 $img $tmp_mnt -o loop";
- _ "cp @grub_files $tmp_mnt";
-
- output("$tmp_mnt/menu.lst", <<EOF);
-timeout 10
-default 0
-fallback 1
-
-title Mandrake Install
-
-root (hd0,0)
-kernel /cooker/isolinux/alt0/vmlinuz $default_append $default_acpi $default_vga automatic=method:disk
-initrd /cooker/isolinux/alt0/all.rdz
-
-title Help
-
-pause To display the help, press <space> until you reach "HELP END"
-pause .
-pause Please see http://qa.mandrakesoft.com/hd_grub.cgi for a friendlier solution
-pause .
-pause To specify the location where Mandrakelinux is copied,
-pause choose "Mandrake Install", and press "e".
-pause Then change "root (hd0,0)". FYI:
-pause - (hd0,0) is the first partition on first bios hard drive (usually hda1)
-pause - (hd0,4) is the first extended partition (usually hda5)
-pause - (hd1,0) is the first partition on second bios hard drive
-pause Replace /cooker to suits the directory containing Mandrakelinux
-pause .
-pause HELP END
-EOF
-
- _ "$sudo umount $tmp_mnt";
-
- output($mapfile, "(fd0) $img\n");
-
- open(my $G, "| grub --device-map=$mapfile --batch");
- print $G <<EOF;
-root (fd0)
-install /stage1 d (fd0) /stage2 p /menu.lst
-quit
-EOF
- close $G;
- unlink $mapfile;
-}
-
-sub drivers {
- my ($type, $I, $img) = @_;
-
- _ "dd if=/dev/zero of=$img bs=1k count=1440";
- mke2fs($img);
- _ "$sudo mount -t ext2 $img $tmp_mnt -o loop";
-
- my ($ext) = $img =~ /img-(.*)/ or die "bad image name ($img)";
- _ "$sudo cp -f kernel/all.kernels$I/$ext/${type}_modules.mar $tmp_mnt/modules$I.mar";
-
- _ "sync";
- _ "df $tmp_mnt";
-
- _ "$sudo umount $tmp_mnt";
-}
diff --git a/mdk-stage1/.cvsignore b/mdk-stage1/.cvsignore
deleted file mode 100644
index 28f91e89f..000000000
--- a/mdk-stage1/.cvsignore
+++ /dev/null
@@ -1,15 +0,0 @@
-init
-init-stage2
-stage1-full
-stage1-cdrom
-stage1-disk
-stage1-medias-usb
-stage1-network
-stage1-network-usb
-debug.log
-.depend
-*.rdz*
-mkinitrd_helper.tar.bz2
-hack_*
-rescue-gui
-dhcp-client
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile
deleted file mode 100644
index f1721d292..000000000
--- a/mdk-stage1/Makefile
+++ /dev/null
@@ -1,263 +0,0 @@
- #******************************************************************************
- #
- # mdk-stage1 - the program that will load second-stage install
- #
- # $Id$
- #
- # Pixel (pixel@mandrakesoft.com) (mostly done by Guillaume Cottenceau)
- #
- # Copyright 2000-2004 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- # Portions from Erik Troan (ewt@redhat.com) Copyright 1996 Red Hat Software
- #
- #*****************************************************************************
- #
- # Currently:
- #
- # ix86
- # init with minilibc
- # stage1 with dietlibc
- #
- # ppc
- # init with dietlibc
- # stage1 with glibc
- #
- # ia64
- # init with glibc
- # stage1 with glibc
- #
- # x86-64
- # init with minilibc
- # stage1 with dietlibc
- #
- #*****************************************************************************
-
-
-top_dir = .
-
-include $(top_dir)/Makefile.common
-include $(top_dir)/../Makefile.config
-
-
-DEFS = -DDISTRIB_NAME=\"$(DISTRIB_NAME)\" -DDISTRIB_VERSION=\"$(DISTRIB_VERSION)\" -DDISTRIB_DESCR=\"$(DISTRIB_DESCR)\" $(ADDITIONAL_DEFS) -D_FILE_OFFSET_BITS=64
-
-COMPILE = $(CC) $(DEFS) $(CFLAGS)
-
-ifeq (ppc, $(ARCH))
-INIT_HEADERS=init-libc-headers.h
-else
-ifeq (DIETLIBC, $(L))
-INIT_HEADERS=minilibc.h
-else
-INIT_HEADERS=init-libc-headers.h
-endif
-endif
-
-INIT_DEFS = -DINIT_HEADERS=\"$(INIT_HEADERS)\"
-
-ifeq (DIETLIBC, $(L))
-INITSRC = minilibc.c init.c
-INIT_DEFS += -fno-builtin
-else
-INITSRC = init.c
-INIT_DEFS += $(GLIBC_INCLUDES)
-endif
-
-INIT_DEFS_ADD = -DBINARY=\"/sbin/stage1\"
-ifdef MOVE
-INIT_DEFS_ADD_STAGE2 = -DBINARY=\"/usr/bin/runstage2.pl\"
-else
-INIT_DEFS_ADD_STAGE2 = -DBINARY=\"/usr/bin/runinstall2\"
-endif
-
-INITOBJS = $(subst .c,.o,$(INITSRC))
-INITOBJS-STAGE2 = $(subst .c,-STAGE2.o,$(INITSRC))
-
-
- #- frontends
-NEWT_FRONTEND_SRC = newt-frontend.c
-NEWT_FRONTEND_LIBS = newt/libnewt.a slang/libslang.a
-
-STDIO_FRONTEND_SRC = stdio-frontend.c
-STDIO_FRONTEND_LIBS =
-STDIO_FRONTEND_LIBS =
-
-
-FRONTEND_OBJS = $(subst .c,.o,$($(F)_FRONTEND_SRC))
-
-FRONTEND_LINK = $(FRONTEND_OBJS) $($(F)_FRONTEND_LIBS)
-
-ifeq (DIETLIBC, $(L))
-INSMOD = insmod-busybox
-else
-INSMOD = insmod-modutils
-endif
-
-STAGE1_OWN_LIBS = $(INSMOD)/libinsmod.a mar/libmar.a bzlib/libbzlib.a
-
-
-ifeq (DIETLIBC, $(L))
-STAGE1_NETWORK_LIBS = /usr/$(LIB)/dietlibc/lib-$(ARCH)/librpc.a
-else
-STAGE1_NETWORK_LIBS = /usr/$(LIB)/libresolv.a
-endif
-
- #- stage1 itself
-STAGE1SRC = stage1.c log.c tools.c modules.c probing.c mount.c automatic.c frontend-common.c lomount.c thirdparty.c
-CDROMSRC = cdrom.c
-DISKSRC = disk.c directory.c partition.c
-NETWORKSRC = network.c nfsmount.c dhcp.c url.c dns.c adsl.c directory.c wireless.c
-
-# use sort to remove duplicates
-STAGE1_ALLSRC = $(sort $(STAGE1SRC) $(CDROMSRC) $(DISKSRC) $(NETWORKSRC))
-ALLSRC = $(INITSRC) $(STAGE1_ALLSRC)
-
-
-
-STAGE1OBJS-CDROM = $(subst .c,-CDROM.o,$(STAGE1SRC) $(CDROMSRC))
-
-CDROM_DEFS = -DSPAWN_SHELL -DDISABLE_DISK -DDISABLE_NETWORK
-
-
-STAGE1OBJS-NETWORK = $(subst .c,-NETWORK.o,$(STAGE1SRC) $(NETWORKSRC))
-
-NETWORK_DEFS = -DSPAWN_SHELL -DDISABLE_CDROM -DDISABLE_DISK
-
-
-STAGE1OBJS-NETWORK-STANDALONE = $(subst .c,-NETWORK-STANDALONE.o,$(STAGE1SRC) $(NETWORKSRC))
-
-NETWORK_STANDALONE_DEFS = -DDISABLE_CDROM -DDISABLE_DISK -DENABLE_NETWORK_STANDALONE
-
-
-STAGE1OBJS-FULL = $(subst .c,-FULL.o,$(STAGE1_ALLSRC))
-
-BINS = init init-stage2 stage1-full dhcp-client
-
-ifndef MOVE
-ifeq (i386, $(ARCH))
-BINS += stage1-cdrom stage1-network
-endif
-ifeq (x86_64, $(ARCH))
-BINS += stage1-cdrom stage1-network
-endif
-endif
-
-DIRS += mar pci-resource usb-resource bzlib $(INSMOD) slang newt ppp/pppd rp-pppoe/src
-ifeq (i386, $(ARCH))
-DIRS += pcmcia_
-endif
-ifeq (x86_64, $(ARCH))
-DIRS += pcmcia_
-endif
-
-
-ifeq (i386,$(ARCH))
-PCMCIA_LIB = pcmcia_/libpcmcia.a
-PCMCIA_DEFS = -DENABLE_PCMCIA
-endif
-ifeq (x86_64,$(ARCH))
-PCMCIA_LIB = pcmcia_/libpcmcia.a
-PCMCIA_DEFS = -DENABLE_PCMCIA
-endif
-
-
-USB_DEFS_GEN = -DENABLE_USB
-USB_DEFS = -DENABLE_USB -DDISABLE_PCIADAPTERS
-
-all: dirs $(BINS)
-
-dirs:
- @for n in . $(DIRS); do \
- [ "$$n" = "." ] || make -C $$n || exit 1 ;\
- done
-
-init: $(INITOBJS)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-init-stage2: $(INITOBJS-STAGE2)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-stage1-cdrom: $(STAGE1OBJS-CDROM) $(STAGE1_OWN_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-stage1-network: $(STAGE1OBJS-NETWORK) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) $(PCMCIA_LIB) $(STAGE1_LIBC)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-stage1-full: $(STAGE1OBJS-FULL) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) bootsplash.o $(PCMCIA_LIB) $(STAGE1_LIBC)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-dhcp-client: $(STAGE1OBJS-NETWORK-STANDALONE) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-
-$(INITOBJS): %.o: %.c
- $(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD) -c $<
-
-$(INITOBJS-STAGE2): %-STAGE2.o: %.c
- $(COMPILE) $(INIT_DEFS) $(INIT_DEFS_ADD_STAGE2) -c $< -o $@
-
-$(STAGE1OBJS-CDROM): %-CDROM.o: %.c
- $(DIET) $(COMPILE) $(INCLUDES) $(CDROM_DEFS) -c $< -o $@
-
-$(STAGE1OBJS-NETWORK): %-NETWORK.o: %.c
- $(DIET) $(COMPILE) $(INCLUDES) $(NETWORK_DEFS) $(PCMCIA_DEFS) $(USB_DEFS_GEN) -DENABLE_ADDITIONAL_MODULES -c $< -o $@
-
-$(STAGE1OBJS-NETWORK-STANDALONE): %-NETWORK-STANDALONE.o: %.c
- $(DIET) $(COMPILE) $(INCLUDES) $(NETWORK_STANDALONE_DEFS) $(USB_DEFS_GEN) -c $< -o $@
-
-$(STAGE1OBJS-FULL): %-FULL.o: %.c
- $(DIET) $(COMPILE) $(INCLUDES) -DSPAWN_SHELL $(USB_DEFS_GEN) $(PCMCIA_DEFS) -DENABLE_BOOTSPLASH -c $< -o $@
-
-.c.o:
- $(DIET) $(COMPILE) $(INCLUDES) -DENABLE_BOOTSPLASH -c $<
-
-
-clean: localclean
- @for n in $(DIRS); do \
- (cd $$n; make clean) \
- done
-
-localclean:
- rm -f *.o .depend *.rdz *.img rescue-gui init-move $(BINS)
-
-
-tar-mkinitrd_helper: clean
- rm -rf mkinitrd_helper-subdir
- mkdir mkinitrd_helper-subdir
- cd mkinitrd_helper-subdir ; cp -a ../insmod-busybox ../Makefile.common ../insmod.h ../log.h . ; \
- cp ../Makefile.mkinitrd_helper Makefile
- tar cfj mkinitrd_helper.tar.bz2 mkinitrd_helper-subdir --exclude CVS
- rm -rf mkinitrd_helper-subdir
-
-rescue-gui: rescue-gui.o frontend-common.o $(FRONTEND_LINK) $(STAGE1_LIBC)
- $(DIET) $(CC) $(LDFLAGS) -o $@ $^
- $(STRIPCMD) $@
-
-
-.depend:
- $(CPP) $(CFLAGS) -M $(ALLSRC) > .depend
-
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
-
-
-*-CDROM.o: %-CDROM.o: %.o
-
-*-NETWORK.o: %-NETWORK.o: %.o
-
-*-FULL.o: %-FULL.o: %.o
-
diff --git a/mdk-stage1/Makefile.common b/mdk-stage1/Makefile.common
deleted file mode 100644
index ce8aab84c..000000000
--- a/mdk-stage1/Makefile.common
+++ /dev/null
@@ -1,54 +0,0 @@
- # -*- makefile -*-
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-ARCH := $(patsubst i%86,i386,$(shell uname -m))
-ARCH := $(patsubst sparc%,sparc,$(ARCH))
-
- #- default lib is dietlibc (honoured by main Makefile whenever possible)
-L = DIETLIBC
-#L = GLIBC
-
- #- default frontend is newt (honoured by main Makefile whenever possible)
-F = NEWT
-# F = STDIO
-
- #- override in some situations
-ifeq (ia64, $(ARCH))
-L = GLIBC
-endif
-
-ifeq (DIETLIBC, $(L))
-DIET = diet
-endif
-
-#- flags used by all stuff
-CFLAGS = -Os -pipe -Wall -fomit-frame-pointer -fno-strict-aliasing
-
-ifneq (ppc, $(ARCH))
-CFLAGS += -Werror
-endif
-
-DIETLIBC_INCLUDES = -I/usr/lib/dietlibc/include -I. -I$(top_dir)/bzlib
-GLIBC_INCLUDES = -I. -I$(top_dir)/bzlib
-INCLUDES = $($(L)_INCLUDES)
-
-GLIBC_LDFLAGS = -static
-LDFLAGS = $($(L)_LDFLAGS)
-
-STAGE1_LIBC = $($(L)_LIBC)
-
-STRIPCMD = strip -R .note -R .comment
-
diff --git a/mdk-stage1/Makefile.mkinitrd_helper b/mdk-stage1/Makefile.mkinitrd_helper
deleted file mode 100644
index a8db2fbe0..000000000
--- a/mdk-stage1/Makefile.mkinitrd_helper
+++ /dev/null
@@ -1,30 +0,0 @@
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-
-DIRS = dietlibc insmod-busybox
-
-
-all: dirs
-
-dirs:
- @for n in . $(DIRS); do \
- [ "$$n" = "." ] || make -C $$n ;\
- done
-
-clean:
- @for n in $(DIRS); do \
- (cd $$n; make clean) \
- done
diff --git a/mdk-stage1/adsl.c b/mdk-stage1/adsl.c
deleted file mode 100644
index 595b3fae0..000000000
--- a/mdk-stage1/adsl.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <resolv.h>
-#include <signal.h>
-
-#include "stage1.h"
-#include "log.h"
-#include "network.h"
-#include "modules.h"
-#include "tools.h"
-#include "frontend.h"
-#include "automatic.h"
-
-#include "adsl.h"
-
-
-static enum return_type adsl_connect(struct interface_info * intf, char * username, char * password, char * acname)
-{
- char pppoe_call[500];
- char * pppd_launch[] = { "/sbin/pppd", "pty", pppoe_call, "noipdefault", "noauth", "default-asyncmap", "defaultroute",
- "hide-password", "nodetach", "usepeerdns", "local", "mtu", "1492", "mru", "1492", "noaccomp",
- "noccp", "nobsdcomp", "nodeflate", "nopcomp", "novj", "novjccomp", "user", username,
- "password", password, "lcp-echo-interval", "20", "lcp-echo-failure", "3", "lock", "persist", NULL };
- int fd;
- int retries = 10;
- char * tty_adsl = "/dev/tty6";
- enum return_type status = RETURN_ERROR;
- pid_t ppp_pid;
-
- snprintf(pppoe_call, sizeof(pppoe_call), "/sbin/pppoe -p /var/run/pppoe.conf-adsl.pid.pppoe -I %s -T 80 -U -m 1412", intf->device);
-
- if (!streq(acname, "")) {
- strcat(pppoe_call, "-C ");
- strcat(pppoe_call, acname);
- }
-
- fd = open(tty_adsl, O_RDWR);
- if (fd == -1) {
- log_message("cannot open tty -- no pppd");
- return RETURN_ERROR;
- }
- else if (access(pppd_launch[0], X_OK)) {
- log_message("cannot open pppd - %s doesn't exist", pppd_launch[0]);
- return RETURN_ERROR;
- }
-
- if (!(ppp_pid = fork())) {
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
-
- close(fd);
- setsid();
- if (ioctl(0, TIOCSCTTY, NULL))
- log_perror("could not set new controlling tty");
-
- printf("\t(exec of pppd)\n");
- execv(pppd_launch[0], pppd_launch);
- log_message("execve of %s failed: %s", pppd_launch[0], strerror(errno));
- exit(-1);
- }
- close(fd);
- while (retries > 0 && kill(ppp_pid, 0) == 0) {
- FILE * f;
- if ((f = fopen("/var/run/pppd.tdb", "rb"))) {
- while (1) {
- char buf[500];
- char *p;
- if (!fgets(buf, sizeof(buf), f))
- break;
- p = strstr(buf, "IPLOCAL=");
- if (p) {
- struct sockaddr_in addr;
- if (inet_aton(p + 8, &addr.sin_addr))
- intf->ip = addr.sin_addr;
- status = RETURN_OK;
- }
- }
- fclose(f);
- if (status == RETURN_OK) {
- log_message("PPP: connected!");
- break;
- }
- }
- retries--;
- log_message("PPP: <sleep>");
- sleep(2);
- }
-
- if (status != RETURN_OK) {
- log_message("PPP: could not connect");
- kill(ppp_pid, SIGTERM);
- sleep(1);
- kill(ppp_pid, SIGKILL);
- sleep(1);
- }
- return status;
-}
-
-
-enum return_type perform_adsl(struct interface_info * intf)
-{
- struct in_addr addr;
- char * questions[] = { "Username", "Password", "AC Name", NULL };
- char * questions_auto[] = { "adsluser", "adslpass", "adslacname", NULL };
- static char ** answers = NULL;
- enum return_type results;
-
- inet_aton("10.0.0.10", &addr);
- memcpy(&intf->ip, &addr, sizeof(addr));
-
- inet_aton("255.255.255.0", &addr);
- memcpy(&intf->netmask, &addr, sizeof(addr));
-
- *((uint32_t *) &intf->broadcast) = (*((uint32_t *) &intf->ip) &
- *((uint32_t *) &intf->netmask)) | ~(*((uint32_t *) &intf->netmask));
-
- intf->is_ptp = 0;
-
- if (configure_net_device(intf)) {
- stg1_error_message("Could not configure..");
- return RETURN_ERROR;
- }
-
- results = ask_from_entries_auto("Please enter the username and password for your ADSL account.\n"
- "Leave blank the AC Name field if you don't know what it means.\n"
- "(Warning! only PPPoE protocol is supported)",
- questions, &answers, 40, questions_auto, NULL);
- if (results != RETURN_OK)
- return results;
-
- intf->boot_proto = BOOTPROTO_ADSL_PPPOE;
-
- wait_message("Waiting for ADSL connection to show up...");
- my_insmod("ppp_generic", ANY_DRIVER_TYPE, NULL, 1);
- my_insmod("ppp_async", ANY_DRIVER_TYPE, NULL, 1);
- results = adsl_connect(intf, answers[0], answers[1], answers[2]);
- remove_wait_message();
-
- if (results != RETURN_OK) {
- wait_message("Retrying the ADSL connection...");
- results = adsl_connect(intf, answers[0], answers[1], answers[2]);
- remove_wait_message();
- } else {
- intf->user = strdup(answers[0]);
- intf->pass = strdup(answers[1]);
- intf->acname = strdup(answers[2]);
- }
-
- if (results != RETURN_OK) {
- stg1_error_message("I could not connect to the ADSL network.");
- return perform_adsl(intf);
- }
-
- sleep(1);
- res_init(); /* reinit the resolver, pppd modified /etc/resolv.conf */
-
- return RETURN_OK;
-}
diff --git a/mdk-stage1/adsl.h b/mdk-stage1/adsl.h
deleted file mode 100644
index fb0baf327..000000000
--- a/mdk-stage1/adsl.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * View the homepage: http://us.mandrakesoft.com/~gc/html/stage1.html
- *
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from GRUB -- GRand Unified Bootloader
- * Copyright (C) 2000 Free Software Foundation, Inc.
- *
- * Itself based on etherboot-4.6.4 by Martin Renters.
- *
- */
-
-#ifndef _ADSL_H_
-#define _ADSL_H_
-
-#include "stage1.h"
-#include "network.h"
-
-enum return_type perform_adsl(struct interface_info * intf);
-
-#endif
diff --git a/mdk-stage1/automatic.c b/mdk-stage1/automatic.c
deleted file mode 100644
index 3a816bab1..000000000
--- a/mdk-stage1/automatic.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * This is supposed to replace the redhat "kickstart", by name but
- * also by design (less code pollution).
- *
- */
-
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include "tools.h"
-#include "stage1.h"
-#include "frontend.h"
-#include "log.h"
-
-#include "automatic.h"
-
-
-static struct param_elem * automatic_params;
-static char * value_not_bound = "";
-
-void grab_automatic_params(char * line)
-{
- int i, p;
- struct param_elem tmp_params[50];
-
- i = 0; p = 0;
- while (line[i] != '\0') {
- char *name, *value;
- int k;
- int j = i;
- while (line[i] != ':' && line[i] != '\0')
- i++;
- name = memdup(&line[j], i-j + 1);
- name[i-j] = 0;
-
- k = i+1;
- i++;
- while (line[i] != ',' && line[i] != '\0')
- i++;
- value = memdup(&line[k], i-k + 1);
- value[i-k] = 0;
-
- tmp_params[p].name = name;
- tmp_params[p].value = value;
- p++;
- if (line[i] == '\0')
- break;
- i++;
- }
-
- tmp_params[p++].name = NULL;
- automatic_params = memdup(tmp_params, sizeof(struct param_elem) * p);
-
- log_message("AUTOMATIC MODE: got %d params", p-1);
-}
-
-
-char * get_auto_value(char * auto_param)
-{
- struct param_elem * ptr = automatic_params;
-
- struct param_elem short_aliases[] =
- { { "method", "met" }, { "network", "netw" }, { "interface", "int" }, { "gateway", "gat" },
- { "netmask", "netm" }, { "adsluser", "adslu" }, { "adslpass", "adslp" }, { "hostname", "hos" },
- { "domain", "dom" }, { "server", "ser" }, { "directory", "dir" }, { "user", "use" },
- { "pass", "pas" }, { "disk", "dis" }, { "partition", "par" }, { "proxy_host", "proxh" },
- { "proxy_port", "proxp" }, { NULL, NULL } };
- struct param_elem * ptr_alias = short_aliases;
- while (ptr_alias->name) {
- if (streq(auto_param, ptr_alias->name))
- break;
- ptr_alias++;
- }
-
- while (ptr->name) {
- if (streq(ptr->name, auto_param)
- || (ptr_alias->name && streq(ptr_alias->value, ptr->name)))
- return ptr->value;
- ptr++;
- }
-
- return value_not_bound;
-}
-
-
-enum return_type ask_from_list_auto(char *msg, char ** elems, char ** choice, char * auto_param, char ** elems_auto)
-{
- if (!IS_AUTOMATIC) {
- exit_bootsplash();
- return ask_from_list(msg, elems, choice);
- } else {
- char ** sav_elems = elems;
- char * tmp = get_auto_value(auto_param);
- while (elems && *elems) {
- if (!strcmp(tmp, *elems_auto)) {
- *choice = *elems;
- log_message("AUTOMATIC: parameter %s for %s means returning %s", tmp, auto_param, *elems);
- return RETURN_OK;
- }
- elems++;
- elems_auto++;
- }
- unset_automatic(); /* we are in a fallback mode */
- return ask_from_list(msg, sav_elems, choice);
- }
-}
-
-enum return_type ask_from_list_comments_auto(char *msg, char ** elems, char ** elems_comments, char ** choice, char * auto_param, char ** elems_auto)
-{
- if (!IS_AUTOMATIC) {
- exit_bootsplash();
- return ask_from_list_comments(msg, elems, elems_comments, choice);
- } else {
- char ** sav_elems = elems;
- char * tmp = get_auto_value(auto_param);
- while (elems && *elems) {
- if (!strcmp(tmp, *elems_auto)) {
- *choice = *elems;
- log_message("AUTOMATIC: parameter %s for %s means returning %s", tmp, auto_param, *elems);
- return RETURN_OK;
- }
- elems++;
- elems_auto++;
- }
- unset_automatic(); /* we are in a fallback mode */
- return ask_from_list_comments(msg, sav_elems, elems_comments, choice);
- }
-}
-
-
-enum return_type ask_from_entries_auto(char *msg, char ** questions, char *** answers, int entry_size, char ** questions_auto, void (*callback_func)(char ** strings))
-{
- if (!IS_AUTOMATIC) {
- exit_bootsplash();
- return ask_from_entries(msg, questions, answers, entry_size, callback_func);
- } else {
- char * tmp_answers[50];
- int i = 0;
- while (questions && *questions) {
- tmp_answers[i] = get_auto_value(*questions_auto);
- log_message("AUTOMATIC: question %s answers %s because of param %s", *questions, tmp_answers[i], *questions_auto);
- i++;
- questions++;
- questions_auto++;
-
- }
- *answers = memdup(tmp_answers, sizeof(char *) * i);
- return RETURN_OK;
- }
-}
diff --git a/mdk-stage1/automatic.h b/mdk-stage1/automatic.h
deleted file mode 100644
index a5bfe212b..000000000
--- a/mdk-stage1/automatic.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * This is supposed to replace the redhat "kickstart", by name but
- * also by design (no code pollution).
- *
- */
-
-#ifndef _AUTOMATIC_H_
-#define _AUTOMATIC_H_
-
-#include "stage1.h"
-
-void grab_automatic_params(char * line);
-char * get_auto_value(char * auto_param);
-
-enum return_type ask_from_list_auto(char *msg, char ** elems, char ** choice, char * auto_param, char ** elems_auto);
-enum return_type ask_from_list_comments_auto(char *msg, char ** elems, char ** elems_comments, char ** choice, char * auto_param, char ** elems_auto);
-enum return_type ask_from_entries_auto(char *msg, char ** questions, char *** answers, int entry_size, char ** questions_auto, void (*callback_func)(char ** strings));
-
-#endif
diff --git a/mdk-stage1/bootsplash.c b/mdk-stage1/bootsplash.c
deleted file mode 100644
index d51deb543..000000000
--- a/mdk-stage1/bootsplash.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Pixel (pixel@mandrakesoft.com)
- *
- * Copyright 2004 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdio.h>
-#include "bootsplash.h"
-#include "frontend.h"
-#include "log.h"
-
-static int total_size;
-static float previous;
-static FILE* splash = NULL;
-
-static void update_progression_only(int current_size)
-{
- if (splash && total_size) {
- float ratio = (float) (current_size + 1) / total_size;
- if (ratio > previous + 0.01) {
- fprintf(splash, "show %d\n", (int) (ratio * 65534));
- fflush(splash);
- previous = ratio;
- }
- }
-}
-
-static void open_bootsplash(void)
-{
- if (!splash) splash = fopen("/proc/splash", "w");
- if (!splash) log_message("opening /proc/splash failed");
-}
-
-void exit_bootsplash(void)
-{
- log_message("exiting bootsplash");
- open_bootsplash();
- if (splash) {
- fprintf(splash, "verbose\n");
- fflush(splash);
- }
-}
-
-
-void init_progression(char *msg, int size)
-{
- previous = 0; total_size = size;
- open_bootsplash();
- update_progression_only(0);
- init_progression_raw(msg, size);
-}
-
-void update_progression(int current_size)
-{
- update_progression_only(current_size);
- update_progression_raw(current_size);
-}
-
-void end_progression(void)
-{
- end_progression_raw();
-}
diff --git a/mdk-stage1/bootsplash.h b/mdk-stage1/bootsplash.h
deleted file mode 100644
index 7d1c8403c..000000000
--- a/mdk-stage1/bootsplash.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Pixel (pixel@mandrakesoft.com)
- *
- * Copyright 2004 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _BOOTSPLASH_H_
-#define _BOOTSPLASH_H_
-
-#ifdef ENABLE_BOOTSPLASH
-void exit_bootsplash(void);
-void tell_bootsplash(char *cmd);
-#else
-#define exit_bootsplash()
-#endif
-
-#endif
diff --git a/mdk-stage1/bzlib/Makefile b/mdk-stage1/bzlib/Makefile
deleted file mode 100644
index 929164253..000000000
--- a/mdk-stage1/bzlib/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-LIBNAME = libbzlib
-
-OBJS = blocksort.o bzlib.o compress.o crctable.o decompress.o huffman.o randtable.o
-
-DEFS =
-
-INCS =
-
-
-TARGETS = $(LIBNAME).a
-
-all: $(TARGETS)
-
-clean:
- rm -f *.o *.a
-
-$(LIBNAME).a: $(OBJS)
- ar -cru $@ $^
- ranlib $@
-
-$(OBJS): %.o: %.c
- $(DIET) $(CC) $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -c $< -o $@
diff --git a/mdk-stage1/bzlib/blocksort.c b/mdk-stage1/bzlib/blocksort.c
deleted file mode 100644
index c1b78c483..000000000
--- a/mdk-stage1/bzlib/blocksort.c
+++ /dev/null
@@ -1,1138 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Block sorting machinery ---*/
-/*--- blocksort.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
-
- To get some idea how the block sorting algorithms in this file
- work, read my paper
- On the Performance of BWT Sorting Algorithms
- in Proceedings of the IEEE Data Compression Conference 2000,
- Snowbird, Utah, USA, 27-30 March 2000. The main sort in this
- file implements the algorithm called cache in the paper.
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------*/
-/*--- Fallback O(N log(N)^2) sorting ---*/
-/*--- algorithm, for repetitive blocks ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-__inline__
-void fallbackSimpleSort ( UInt32* fmap,
- UInt32* eclass,
- Int32 lo,
- Int32 hi )
-{
- Int32 i, j, tmp;
- UInt32 ec_tmp;
-
- if (lo == hi) return;
-
- if (hi - lo > 3) {
- for ( i = hi-4; i >= lo; i-- ) {
- tmp = fmap[i];
- ec_tmp = eclass[tmp];
- for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 )
- fmap[j-4] = fmap[j];
- fmap[j-4] = tmp;
- }
- }
-
- for ( i = hi-1; i >= lo; i-- ) {
- tmp = fmap[i];
- ec_tmp = eclass[tmp];
- for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ )
- fmap[j-1] = fmap[j];
- fmap[j-1] = tmp;
- }
-}
-
-
-/*---------------------------------------------*/
-#define fswap(zz1, zz2) \
- { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define fvswap(zzp1, zzp2, zzn) \
-{ \
- Int32 yyp1 = (zzp1); \
- Int32 yyp2 = (zzp2); \
- Int32 yyn = (zzn); \
- while (yyn > 0) { \
- fswap(fmap[yyp1], fmap[yyp2]); \
- yyp1++; yyp2++; yyn--; \
- } \
-}
-
-
-#define fmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define fpush(lz,hz) { stackLo[sp] = lz; \
- stackHi[sp] = hz; \
- sp++; }
-
-#define fpop(lz,hz) { sp--; \
- lz = stackLo[sp]; \
- hz = stackHi[sp]; }
-
-#define FALLBACK_QSORT_SMALL_THRESH 10
-#define FALLBACK_QSORT_STACK_SIZE 100
-
-
-static
-void fallbackQSort3 ( UInt32* fmap,
- UInt32* eclass,
- Int32 loSt,
- Int32 hiSt )
-{
- Int32 unLo, unHi, ltLo, gtHi, n, m;
- Int32 sp, lo, hi;
- UInt32 med, r, r3;
- Int32 stackLo[FALLBACK_QSORT_STACK_SIZE];
- Int32 stackHi[FALLBACK_QSORT_STACK_SIZE];
-
- r = 0;
-
- sp = 0;
- fpush ( loSt, hiSt );
-
- while (sp > 0) {
-
- AssertH ( sp < FALLBACK_QSORT_STACK_SIZE, 1004 );
-
- fpop ( lo, hi );
- if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
- fallbackSimpleSort ( fmap, eclass, lo, hi );
- continue;
- }
-
- /* Random partitioning. Median of 3 sometimes fails to
- avoid bad cases. Median of 9 seems to help but
- looks rather expensive. This too seems to work but
- is cheaper. Guidance for the magic constants
- 7621 and 32768 is taken from Sedgewick's algorithms
- book, chapter 35.
- */
- r = ((r * 7621) + 1) % 32768;
- r3 = r % 3;
- if (r3 == 0) med = eclass[fmap[lo]]; else
- if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else
- med = eclass[fmap[hi]];
-
- unLo = ltLo = lo;
- unHi = gtHi = hi;
-
- while (1) {
- while (1) {
- if (unLo > unHi) break;
- n = (Int32)eclass[fmap[unLo]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unLo], fmap[ltLo]);
- ltLo++; unLo++;
- continue;
- };
- if (n > 0) break;
- unLo++;
- }
- while (1) {
- if (unLo > unHi) break;
- n = (Int32)eclass[fmap[unHi]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unHi], fmap[gtHi]);
- gtHi--; unHi--;
- continue;
- };
- if (n < 0) break;
- unHi--;
- }
- if (unLo > unHi) break;
- fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--;
- }
-
- AssertD ( unHi == unLo-1, "fallbackQSort3(2)" );
-
- if (gtHi < ltLo) continue;
-
- n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n);
- m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m);
-
- n = lo + unLo - ltLo - 1;
- m = hi - (gtHi - unHi) + 1;
-
- if (n - lo > hi - m) {
- fpush ( lo, n );
- fpush ( m, hi );
- } else {
- fpush ( m, hi );
- fpush ( lo, n );
- }
- }
-}
-
-#undef fmin
-#undef fpush
-#undef fpop
-#undef fswap
-#undef fvswap
-#undef FALLBACK_QSORT_SMALL_THRESH
-#undef FALLBACK_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > 0
- eclass exists for [0 .. nblock-1]
- ((UChar*)eclass) [0 .. nblock-1] holds block
- ptr exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)eclass) [0 .. nblock-1] holds block
- All other areas of eclass destroyed
- fmap [0 .. nblock-1] holds sorted order
- bhtab [ 0 .. 2+(nblock/32) ] destroyed
-*/
-
-#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31))
-#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31))
-#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31)))
-#define WORD_BH(zz) bhtab[(zz) >> 5]
-#define UNALIGNED_BH(zz) ((zz) & 0x01f)
-
-static
-void fallbackSort ( UInt32* fmap,
- UInt32* eclass,
- UInt32* bhtab,
- Int32 nblock,
- Int32 verb )
-{
- Int32 ftab[257];
- Int32 ftabCopy[256];
- Int32 H, i, j, k, l, r, cc, cc1;
- Int32 nNotDone;
- Int32 nBhtab;
- UChar* eclass8 = (UChar*)eclass;
-
- /*--
- Initial 1-char radix sort to generate
- initial fmap and initial BH bits.
- --*/
- if (verb >= 4)
- VPrintf0 ( " bucket sorting ...\n" );
- for (i = 0; i < 257; i++) ftab[i] = 0;
- for (i = 0; i < nblock; i++) ftab[eclass8[i]]++;
- for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i];
- for (i = 1; i < 257; i++) ftab[i] += ftab[i-1];
-
- for (i = 0; i < nblock; i++) {
- j = eclass8[i];
- k = ftab[j] - 1;
- ftab[j] = k;
- fmap[k] = i;
- }
-
- nBhtab = 2 + (nblock / 32);
- for (i = 0; i < nBhtab; i++) bhtab[i] = 0;
- for (i = 0; i < 256; i++) SET_BH(ftab[i]);
-
- /*--
- Inductively refine the buckets. Kind-of an
- "exponential radix sort" (!), inspired by the
- Manber-Myers suffix array construction algorithm.
- --*/
-
- /*-- set sentinel bits for block-end detection --*/
- for (i = 0; i < 32; i++) {
- SET_BH(nblock + 2*i);
- CLEAR_BH(nblock + 2*i + 1);
- }
-
- /*-- the log(N) loop --*/
- H = 1;
- while (1) {
-
- if (verb >= 4)
- VPrintf1 ( " depth %6d has ", H );
-
- j = 0;
- for (i = 0; i < nblock; i++) {
- if (ISSET_BH(i)) j = i;
- k = fmap[i] - H; if (k < 0) k += nblock;
- eclass[k] = j;
- }
-
- nNotDone = 0;
- r = -1;
- while (1) {
-
- /*-- find the next non-singleton bucket --*/
- k = r + 1;
- while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
- if (ISSET_BH(k)) {
- while (WORD_BH(k) == 0xffffffff) k += 32;
- while (ISSET_BH(k)) k++;
- }
- l = k - 1;
- if (l >= nblock) break;
- while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++;
- if (!ISSET_BH(k)) {
- while (WORD_BH(k) == 0x00000000) k += 32;
- while (!ISSET_BH(k)) k++;
- }
- r = k - 1;
- if (r >= nblock) break;
-
- /*-- now [l, r] bracket current bucket --*/
- if (r > l) {
- nNotDone += (r - l + 1);
- fallbackQSort3 ( fmap, eclass, l, r );
-
- /*-- scan bucket and generate header bits-- */
- cc = -1;
- for (i = l; i <= r; i++) {
- cc1 = eclass[fmap[i]];
- if (cc != cc1) { SET_BH(i); cc = cc1; };
- }
- }
- }
-
- if (verb >= 4)
- VPrintf1 ( "%6d unresolved strings\n", nNotDone );
-
- H *= 2;
- if (H > nblock || nNotDone == 0) break;
- }
-
- /*--
- Reconstruct the original block in
- eclass8 [0 .. nblock-1], since the
- previous phase destroyed it.
- --*/
- if (verb >= 4)
- VPrintf0 ( " reconstructing block ...\n" );
- j = 0;
- for (i = 0; i < nblock; i++) {
- while (ftabCopy[j] == 0) j++;
- ftabCopy[j]--;
- eclass8[fmap[i]] = (UChar)j;
- }
- AssertH ( j < 256, 1005 );
-}
-
-#undef SET_BH
-#undef CLEAR_BH
-#undef ISSET_BH
-#undef WORD_BH
-#undef UNALIGNED_BH
-
-
-/*---------------------------------------------*/
-/*--- The main, O(N^2 log(N)) sorting ---*/
-/*--- algorithm. Faster for "normal" ---*/
-/*--- non-repetitive blocks. ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-__inline__
-Bool mainGtU ( UInt32 i1,
- UInt32 i2,
- UChar* block,
- UInt16* quadrant,
- UInt32 nblock,
- Int32* budget )
-{
- Int32 k;
- UChar c1, c2;
- UInt16 s1, s2;
-
- AssertD ( i1 != i2, "mainGtU" );
- /* 1 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 2 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 3 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 4 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 5 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 6 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 7 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 8 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 9 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 10 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 11 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 12 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
-
- k = nblock + 8;
-
- do {
- /* 1 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 2 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 3 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 4 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 5 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 6 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 7 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 8 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
-
- if (i1 >= nblock) i1 -= nblock;
- if (i2 >= nblock) i2 -= nblock;
-
- k -= 8;
- (*budget)--;
- }
- while (k >= 0);
-
- return False;
-}
-
-
-/*---------------------------------------------*/
-/*--
- Knuth's increments seem to work better
- than Incerpi-Sedgewick here. Possibly
- because the number of elems to sort is
- usually small, typically <= 20.
---*/
-static
-Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280,
- 9841, 29524, 88573, 265720,
- 797161, 2391484 };
-
-static
-void mainSimpleSort ( UInt32* ptr,
- UChar* block,
- UInt16* quadrant,
- Int32 nblock,
- Int32 lo,
- Int32 hi,
- Int32 d,
- Int32* budget )
-{
- Int32 i, j, h, bigN, hp;
- UInt32 v;
-
- bigN = hi - lo + 1;
- if (bigN < 2) return;
-
- hp = 0;
- while (incs[hp] < bigN) hp++;
- hp--;
-
- for (; hp >= 0; hp--) {
- h = incs[hp];
-
- i = lo + h;
- while (True) {
-
- /*-- copy 1 --*/
- if (i > hi) break;
- v = ptr[i];
- j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
- ) ) {
- ptr[j] = ptr[j-h];
- j = j - h;
- if (j <= (lo + h - 1)) break;
- }
- ptr[j] = v;
- i++;
-
- /*-- copy 2 --*/
- if (i > hi) break;
- v = ptr[i];
- j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
- ) ) {
- ptr[j] = ptr[j-h];
- j = j - h;
- if (j <= (lo + h - 1)) break;
- }
- ptr[j] = v;
- i++;
-
- /*-- copy 3 --*/
- if (i > hi) break;
- v = ptr[i];
- j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
- ) ) {
- ptr[j] = ptr[j-h];
- j = j - h;
- if (j <= (lo + h - 1)) break;
- }
- ptr[j] = v;
- i++;
-
- if (*budget < 0) return;
- }
- }
-}
-
-
-/*---------------------------------------------*/
-/*--
- The following is an implementation of
- an elegant 3-way quicksort for strings,
- described in a paper "Fast Algorithms for
- Sorting and Searching Strings", by Robert
- Sedgewick and Jon L. Bentley.
---*/
-
-#define mswap(zz1, zz2) \
- { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define mvswap(zzp1, zzp2, zzn) \
-{ \
- Int32 yyp1 = (zzp1); \
- Int32 yyp2 = (zzp2); \
- Int32 yyn = (zzn); \
- while (yyn > 0) { \
- mswap(ptr[yyp1], ptr[yyp2]); \
- yyp1++; yyp2++; yyn--; \
- } \
-}
-
-static
-__inline__
-UChar mmed3 ( UChar a, UChar b, UChar c )
-{
- UChar t;
- if (a > b) { t = a; a = b; b = t; };
- if (b > c) {
- b = c;
- if (a > b) b = a;
- }
- return b;
-}
-
-#define mmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define mpush(lz,hz,dz) { stackLo[sp] = lz; \
- stackHi[sp] = hz; \
- stackD [sp] = dz; \
- sp++; }
-
-#define mpop(lz,hz,dz) { sp--; \
- lz = stackLo[sp]; \
- hz = stackHi[sp]; \
- dz = stackD [sp]; }
-
-
-#define mnextsize(az) (nextHi[az]-nextLo[az])
-
-#define mnextswap(az,bz) \
- { Int32 tz; \
- tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \
- tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \
- tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; }
-
-
-#define MAIN_QSORT_SMALL_THRESH 20
-#define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT)
-#define MAIN_QSORT_STACK_SIZE 100
-
-static
-void mainQSort3 ( UInt32* ptr,
- UChar* block,
- UInt16* quadrant,
- Int32 nblock,
- Int32 loSt,
- Int32 hiSt,
- Int32 dSt,
- Int32* budget )
-{
- Int32 unLo, unHi, ltLo, gtHi, n, m, med;
- Int32 sp, lo, hi, d;
-
- Int32 stackLo[MAIN_QSORT_STACK_SIZE];
- Int32 stackHi[MAIN_QSORT_STACK_SIZE];
- Int32 stackD [MAIN_QSORT_STACK_SIZE];
-
- Int32 nextLo[3];
- Int32 nextHi[3];
- Int32 nextD [3];
-
- sp = 0;
- mpush ( loSt, hiSt, dSt );
-
- while (sp > 0) {
-
- AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 );
-
- mpop ( lo, hi, d );
- if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
- d > MAIN_QSORT_DEPTH_THRESH) {
- mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
- if (*budget < 0) return;
- continue;
- }
-
- med = (Int32)
- mmed3 ( block[ptr[ lo ]+d],
- block[ptr[ hi ]+d],
- block[ptr[ (lo+hi)>>1 ]+d] );
-
- unLo = ltLo = lo;
- unHi = gtHi = hi;
-
- while (True) {
- while (True) {
- if (unLo > unHi) break;
- n = ((Int32)block[ptr[unLo]+d]) - med;
- if (n == 0) {
- mswap(ptr[unLo], ptr[ltLo]);
- ltLo++; unLo++; continue;
- };
- if (n > 0) break;
- unLo++;
- }
- while (True) {
- if (unLo > unHi) break;
- n = ((Int32)block[ptr[unHi]+d]) - med;
- if (n == 0) {
- mswap(ptr[unHi], ptr[gtHi]);
- gtHi--; unHi--; continue;
- };
- if (n < 0) break;
- unHi--;
- }
- if (unLo > unHi) break;
- mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--;
- }
-
- AssertD ( unHi == unLo-1, "mainQSort3(2)" );
-
- if (gtHi < ltLo) {
- mpush(lo, hi, d+1 );
- continue;
- }
-
- n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n);
- m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m);
-
- n = lo + unLo - ltLo - 1;
- m = hi - (gtHi - unHi) + 1;
-
- nextLo[0] = lo; nextHi[0] = n; nextD[0] = d;
- nextLo[1] = m; nextHi[1] = hi; nextD[1] = d;
- nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1;
-
- if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
- if (mnextsize(1) < mnextsize(2)) mnextswap(1,2);
- if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
-
- AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" );
- AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" );
-
- mpush (nextLo[0], nextHi[0], nextD[0]);
- mpush (nextLo[1], nextHi[1], nextD[1]);
- mpush (nextLo[2], nextHi[2], nextD[2]);
- }
-}
-
-#undef mswap
-#undef mvswap
-#undef mpush
-#undef mpop
-#undef mmin
-#undef mnextsize
-#undef mnextswap
-#undef MAIN_QSORT_SMALL_THRESH
-#undef MAIN_QSORT_DEPTH_THRESH
-#undef MAIN_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > N_OVERSHOOT
- block32 exists for [0 .. nblock-1 +N_OVERSHOOT]
- ((UChar*)block32) [0 .. nblock-1] holds block
- ptr exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)block32) [0 .. nblock-1] holds block
- All other areas of block32 destroyed
- ftab [0 .. 65536 ] destroyed
- ptr [0 .. nblock-1] holds sorted order
- if (*budget < 0), sorting was abandoned
-*/
-
-#define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8])
-#define SETMASK (1 << 21)
-#define CLEARMASK (~(SETMASK))
-
-static
-void mainSort ( UInt32* ptr,
- UChar* block,
- UInt16* quadrant,
- UInt32* ftab,
- Int32 nblock,
- Int32 verb,
- Int32* budget )
-{
- Int32 i, j, k, ss, sb;
- Int32 runningOrder[256];
- Bool bigDone[256];
- Int32 copyStart[256];
- Int32 copyEnd [256];
- UChar c1;
- Int32 numQSorted;
- UInt16 s;
- if (verb >= 4) VPrintf0 ( " main sort initialise ...\n" );
-
- /*-- set up the 2-byte frequency table --*/
- for (i = 65536; i >= 0; i--) ftab[i] = 0;
-
- j = block[0] << 8;
- i = nblock-1;
- for (; i >= 3; i -= 4) {
- quadrant[i] = 0;
- j = (j >> 8) | ( ((UInt16)block[i]) << 8);
- ftab[j]++;
- quadrant[i-1] = 0;
- j = (j >> 8) | ( ((UInt16)block[i-1]) << 8);
- ftab[j]++;
- quadrant[i-2] = 0;
- j = (j >> 8) | ( ((UInt16)block[i-2]) << 8);
- ftab[j]++;
- quadrant[i-3] = 0;
- j = (j >> 8) | ( ((UInt16)block[i-3]) << 8);
- ftab[j]++;
- }
- for (; i >= 0; i--) {
- quadrant[i] = 0;
- j = (j >> 8) | ( ((UInt16)block[i]) << 8);
- ftab[j]++;
- }
-
- /*-- (emphasises close relationship of block & quadrant) --*/
- for (i = 0; i < BZ_N_OVERSHOOT; i++) {
- block [nblock+i] = block[i];
- quadrant[nblock+i] = 0;
- }
-
- if (verb >= 4) VPrintf0 ( " bucket sorting ...\n" );
-
- /*-- Complete the initial radix sort --*/
- for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1];
-
- s = block[0] << 8;
- i = nblock-1;
- for (; i >= 3; i -= 4) {
- s = (s >> 8) | (block[i] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i;
- s = (s >> 8) | (block[i-1] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i-1;
- s = (s >> 8) | (block[i-2] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i-2;
- s = (s >> 8) | (block[i-3] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i-3;
- }
- for (; i >= 0; i--) {
- s = (s >> 8) | (block[i] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i;
- }
-
- /*--
- Now ftab contains the first loc of every small bucket.
- Calculate the running order, from smallest to largest
- big bucket.
- --*/
- for (i = 0; i <= 255; i++) {
- bigDone [i] = False;
- runningOrder[i] = i;
- }
-
- {
- Int32 vv;
- Int32 h = 1;
- do h = 3 * h + 1; while (h <= 256);
- do {
- h = h / 3;
- for (i = h; i <= 255; i++) {
- vv = runningOrder[i];
- j = i;
- while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) {
- runningOrder[j] = runningOrder[j-h];
- j = j - h;
- if (j <= (h - 1)) goto zero;
- }
- zero:
- runningOrder[j] = vv;
- }
- } while (h != 1);
- }
-
- /*--
- The main sorting loop.
- --*/
-
- numQSorted = 0;
-
- for (i = 0; i <= 255; i++) {
-
- /*--
- Process big buckets, starting with the least full.
- Basically this is a 3-step process in which we call
- mainQSort3 to sort the small buckets [ss, j], but
- also make a big effort to avoid the calls if we can.
- --*/
- ss = runningOrder[i];
-
- /*--
- Step 1:
- Complete the big bucket [ss] by quicksorting
- any unsorted small buckets [ss, j], for j != ss.
- Hopefully previous pointer-scanning phases have already
- completed many of the small buckets [ss, j], so
- we don't have to sort them at all.
- --*/
- for (j = 0; j <= 255; j++) {
- if (j != ss) {
- sb = (ss << 8) + j;
- if ( ! (ftab[sb] & SETMASK) ) {
- Int32 lo = ftab[sb] & CLEARMASK;
- Int32 hi = (ftab[sb+1] & CLEARMASK) - 1;
- if (hi > lo) {
- if (verb >= 4)
- VPrintf4 ( " qsort [0x%x, 0x%x] "
- "done %d this %d\n",
- ss, j, numQSorted, hi - lo + 1 );
- mainQSort3 (
- ptr, block, quadrant, nblock,
- lo, hi, BZ_N_RADIX, budget
- );
- numQSorted += (hi - lo + 1);
- if (*budget < 0) return;
- }
- }
- ftab[sb] |= SETMASK;
- }
- }
-
- AssertH ( !bigDone[ss], 1006 );
-
- /*--
- Step 2:
- Now scan this big bucket [ss] so as to synthesise the
- sorted order for small buckets [t, ss] for all t,
- including, magically, the bucket [ss,ss] too.
- This will avoid doing Real Work in subsequent Step 1's.
- --*/
- {
- for (j = 0; j <= 255; j++) {
- copyStart[j] = ftab[(j << 8) + ss] & CLEARMASK;
- copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1;
- }
- for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) {
- k = ptr[j]-1; if (k < 0) k += nblock;
- c1 = block[k];
- if (!bigDone[c1])
- ptr[ copyStart[c1]++ ] = k;
- }
- for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
- k = ptr[j]-1; if (k < 0) k += nblock;
- c1 = block[k];
- if (!bigDone[c1])
- ptr[ copyEnd[c1]-- ] = k;
- }
- }
-
- AssertH ( copyStart[ss]-1 == copyEnd[ss], 1007 );
-
- for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK;
-
- /*--
- Step 3:
- The [ss] big bucket is now done. Record this fact,
- and update the quadrant descriptors. Remember to
- update quadrants in the overshoot area too, if
- necessary. The "if (i < 255)" test merely skips
- this updating for the last bucket processed, since
- updating for the last bucket is pointless.
-
- The quadrant array provides a way to incrementally
- cache sort orderings, as they appear, so as to
- make subsequent comparisons in fullGtU() complete
- faster. For repetitive blocks this makes a big
- difference (but not big enough to be able to avoid
- the fallback sorting mechanism, exponential radix sort).
-
- The precise meaning is: at all times:
-
- for 0 <= i < nblock and 0 <= j <= nblock
-
- if block[i] != block[j],
-
- then the relative values of quadrant[i] and
- quadrant[j] are meaningless.
-
- else {
- if quadrant[i] < quadrant[j]
- then the string starting at i lexicographically
- precedes the string starting at j
-
- else if quadrant[i] > quadrant[j]
- then the string starting at j lexicographically
- precedes the string starting at i
-
- else
- the relative ordering of the strings starting
- at i and j has not yet been determined.
- }
- --*/
- bigDone[ss] = True;
-
- if (i < 255) {
- Int32 bbStart = ftab[ss << 8] & CLEARMASK;
- Int32 bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart;
- Int32 shifts = 0;
-
- while ((bbSize >> shifts) > 65534) shifts++;
-
- for (j = bbSize-1; j >= 0; j--) {
- Int32 a2update = ptr[bbStart + j];
- UInt16 qVal = (UInt16)(j >> shifts);
- quadrant[a2update] = qVal;
- if (a2update < BZ_N_OVERSHOOT)
- quadrant[a2update + nblock] = qVal;
- }
- AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 );
- }
-
- }
-
- if (verb >= 4)
- VPrintf3 ( " %d pointers, %d sorted, %d scanned\n",
- nblock, numQSorted, nblock - numQSorted );
-}
-
-#undef BIGFREQ
-#undef SETMASK
-#undef CLEARMASK
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > 0
- arr2 exists for [0 .. nblock-1 +N_OVERSHOOT]
- ((UChar*)arr2) [0 .. nblock-1] holds block
- arr1 exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)arr2) [0 .. nblock-1] holds block
- All other areas of block destroyed
- ftab [ 0 .. 65536 ] destroyed
- arr1 [0 .. nblock-1] holds sorted order
-*/
-void BZ2_blockSort ( EState* s )
-{
- UInt32* ptr = s->ptr;
- UChar* block = s->block;
- UInt32* ftab = s->ftab;
- Int32 nblock = s->nblock;
- Int32 verb = s->verbosity;
- Int32 wfact = s->workFactor;
- UInt16* quadrant;
- Int32 budget;
- Int32 budgetInit;
- Int32 i;
-
- if (nblock < 10000) {
- fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
- } else {
- /* Calculate the location for quadrant, remembering to get
- the alignment right. Assumes that &(block[0]) is at least
- 2-byte aligned -- this should be ok since block is really
- the first section of arr2.
- */
- i = nblock+BZ_N_OVERSHOOT;
- if (i & 1) i++;
- quadrant = (UInt16*)(&(block[i]));
-
- /* (wfact-1) / 3 puts the default-factor-30
- transition point at very roughly the same place as
- with v0.1 and v0.9.0.
- Not that it particularly matters any more, since the
- resulting compressed stream is now the same regardless
- of whether or not we use the main sort or fallback sort.
- */
- if (wfact < 1 ) wfact = 1;
- if (wfact > 100) wfact = 100;
- budgetInit = nblock * ((wfact-1) / 3);
- budget = budgetInit;
-
- mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
- if (verb >= 3)
- VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
- budgetInit - budget,
- nblock,
- (float)(budgetInit - budget) /
- (float)(nblock==0 ? 1 : nblock) );
- if (budget < 0) {
- if (verb >= 2)
- VPrintf0 ( " too repetitive; using fallback"
- " sorting algorithm\n" );
- fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
- }
- }
-
- s->origPtr = -1;
- for (i = 0; i < s->nblock; i++)
- if (ptr[i] == 0)
- { s->origPtr = i; break; };
-
- AssertH( s->origPtr != -1, 1003 );
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end blocksort.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/bzlib.c b/mdk-stage1/bzlib/bzlib.c
deleted file mode 100644
index b1fc85236..000000000
--- a/mdk-stage1/bzlib/bzlib.c
+++ /dev/null
@@ -1,1567 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Library top-level functions. ---*/
-/*--- bzlib.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-/*--
- CHANGES
- ~~~~~~~
- 0.9.0 -- original version.
-
- 0.9.0a/b -- no changes in this file.
-
- 0.9.0c
- * made zero-length BZ_FLUSH work correctly in bzCompress().
- * fixed bzWrite/bzRead to ignore zero-length requests.
- * fixed bzread to correctly handle read requests after EOF.
- * wrong parameter order in call to bzDecompressInit in
- bzBuffToBuffDecompress. Fixed.
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-/*--- Compression stuff ---*/
-/*---------------------------------------------------*/
-
-
-/*---------------------------------------------------*/
-#ifndef BZ_NO_STDIO
-void BZ2_bz__AssertH__fail ( int errcode )
-{
- fprintf(stderr,
- "\n\nbzip2/libbzip2: internal error number %d.\n"
- "This is a bug in bzip2/libbzip2, %s.\n"
- "Please report it to me at: jseward@acm.org. If this happened\n"
- "when you were using some program which uses libbzip2 as a\n"
- "component, you should also report this bug to the author(s)\n"
- "of that program. Please make an effort to report this bug;\n"
- "timely and accurate bug reports eventually lead to higher\n"
- "quality software. Thanks. Julian Seward, 21 March 2000.\n\n",
- errcode,
- BZ2_bzlibVersion()
- );
- exit(3);
-}
-#endif
-
-
-/*---------------------------------------------------*/
-static
-int bz_config_ok ( void )
-{
- if (sizeof(int) != 4) return 0;
- if (sizeof(short) != 2) return 0;
- if (sizeof(char) != 1) return 0;
- return 1;
-}
-
-
-/*---------------------------------------------------*/
-static
-void* default_bzalloc ( void* opaque __attribute__ ((unused)), Int32 items, Int32 size )
-{
- void* v = malloc ( items * size );
- return v;
-}
-
-static
-void default_bzfree ( void* opaque __attribute__ ((unused)), void* addr )
-{
- if (addr != NULL) free ( addr );
-}
-
-
-/*---------------------------------------------------*/
-static
-void prepare_new_block ( EState* s )
-{
- Int32 i;
- s->nblock = 0;
- s->numZ = 0;
- s->state_out_pos = 0;
- BZ_INITIALISE_CRC ( s->blockCRC );
- for (i = 0; i < 256; i++) s->inUse[i] = False;
- s->blockNo++;
-}
-
-
-/*---------------------------------------------------*/
-static
-void init_RL ( EState* s )
-{
- s->state_in_ch = 256;
- s->state_in_len = 0;
-}
-
-
-static
-Bool isempty_RL ( EState* s )
-{
- if (s->state_in_ch < 256 && s->state_in_len > 0)
- return False; else
- return True;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressInit)
- ( bz_stream* strm,
- int blockSize100k,
- int verbosity,
- int workFactor )
-{
- Int32 n;
- EState* s;
-
- if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
- if (strm == NULL ||
- blockSize100k < 1 || blockSize100k > 9 ||
- workFactor < 0 || workFactor > 250)
- return BZ_PARAM_ERROR;
-
- if (workFactor == 0) workFactor = 30;
- if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
- if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
- s = BZALLOC( sizeof(EState) );
- if (s == NULL) return BZ_MEM_ERROR;
- s->strm = strm;
-
- s->arr1 = NULL;
- s->arr2 = NULL;
- s->ftab = NULL;
-
- n = 100000 * blockSize100k;
- s->arr1 = BZALLOC( n * sizeof(UInt32) );
- s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
- s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
-
- if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
- if (s->arr1 != NULL) BZFREE(s->arr1);
- if (s->arr2 != NULL) BZFREE(s->arr2);
- if (s->ftab != NULL) BZFREE(s->ftab);
- if (s != NULL) BZFREE(s);
- return BZ_MEM_ERROR;
- }
-
- s->blockNo = 0;
- s->state = BZ_S_INPUT;
- s->mode = BZ_M_RUNNING;
- s->combinedCRC = 0;
- s->blockSize100k = blockSize100k;
- s->nblockMAX = 100000 * blockSize100k - 19;
- s->verbosity = verbosity;
- s->workFactor = workFactor;
-
- s->block = (UChar*)s->arr2;
- s->mtfv = (UInt16*)s->arr1;
- s->zbits = NULL;
- s->ptr = (UInt32*)s->arr1;
-
- strm->state = s;
- strm->total_in_lo32 = 0;
- strm->total_in_hi32 = 0;
- strm->total_out_lo32 = 0;
- strm->total_out_hi32 = 0;
- init_RL ( s );
- prepare_new_block ( s );
- return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-static
-void add_pair_to_block ( EState* s )
-{
- Int32 i;
- UChar ch = (UChar)(s->state_in_ch);
- for (i = 0; i < s->state_in_len; i++) {
- BZ_UPDATE_CRC( s->blockCRC, ch );
- }
- s->inUse[s->state_in_ch] = True;
- switch (s->state_in_len) {
- case 1:
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- break;
- case 2:
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- break;
- case 3:
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- break;
- default:
- s->inUse[s->state_in_len-4] = True;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = ((UChar)(s->state_in_len-4));
- s->nblock++;
- break;
- }
-}
-
-
-/*---------------------------------------------------*/
-static
-void flush_RL ( EState* s )
-{
- if (s->state_in_ch < 256) add_pair_to_block ( s );
- init_RL ( s );
-}
-
-
-/*---------------------------------------------------*/
-#define ADD_CHAR_TO_BLOCK(zs,zchh0) \
-{ \
- UInt32 zchh = (UInt32)(zchh0); \
- /*-- fast track the common case --*/ \
- if (zchh != zs->state_in_ch && \
- zs->state_in_len == 1) { \
- UChar ch = (UChar)(zs->state_in_ch); \
- BZ_UPDATE_CRC( zs->blockCRC, ch ); \
- zs->inUse[zs->state_in_ch] = True; \
- zs->block[zs->nblock] = (UChar)ch; \
- zs->nblock++; \
- zs->state_in_ch = zchh; \
- } \
- else \
- /*-- general, uncommon cases --*/ \
- if (zchh != zs->state_in_ch || \
- zs->state_in_len == 255) { \
- if (zs->state_in_ch < 256) \
- add_pair_to_block ( zs ); \
- zs->state_in_ch = zchh; \
- zs->state_in_len = 1; \
- } else { \
- zs->state_in_len++; \
- } \
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_input_until_stop ( EState* s )
-{
- Bool progress_in = False;
-
- if (s->mode == BZ_M_RUNNING) {
-
- /*-- fast track the common case --*/
- while (True) {
- /*-- block full? --*/
- if (s->nblock >= s->nblockMAX) break;
- /*-- no input? --*/
- if (s->strm->avail_in == 0) break;
- progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
- s->strm->next_in++;
- s->strm->avail_in--;
- s->strm->total_in_lo32++;
- if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
- }
-
- } else {
-
- /*-- general, uncommon case --*/
- while (True) {
- /*-- block full? --*/
- if (s->nblock >= s->nblockMAX) break;
- /*-- no input? --*/
- if (s->strm->avail_in == 0) break;
- /*-- flush/finish end? --*/
- if (s->avail_in_expect == 0) break;
- progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
- s->strm->next_in++;
- s->strm->avail_in--;
- s->strm->total_in_lo32++;
- if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
- s->avail_in_expect--;
- }
- }
- return progress_in;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_output_until_stop ( EState* s )
-{
- Bool progress_out = False;
-
- while (True) {
-
- /*-- no output space? --*/
- if (s->strm->avail_out == 0) break;
-
- /*-- block done? --*/
- if (s->state_out_pos >= s->numZ) break;
-
- progress_out = True;
- *(s->strm->next_out) = s->zbits[s->state_out_pos];
- s->state_out_pos++;
- s->strm->avail_out--;
- s->strm->next_out++;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- return progress_out;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool handle_compress ( bz_stream* strm )
-{
- Bool progress_in = False;
- Bool progress_out = False;
- EState* s = strm->state;
-
- while (True) {
-
- if (s->state == BZ_S_OUTPUT) {
- progress_out |= copy_output_until_stop ( s );
- if (s->state_out_pos < s->numZ) break;
- if (s->mode == BZ_M_FINISHING &&
- s->avail_in_expect == 0 &&
- isempty_RL(s)) break;
- prepare_new_block ( s );
- s->state = BZ_S_INPUT;
- if (s->mode == BZ_M_FLUSHING &&
- s->avail_in_expect == 0 &&
- isempty_RL(s)) break;
- }
-
- if (s->state == BZ_S_INPUT) {
- progress_in |= copy_input_until_stop ( s );
- if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
- flush_RL ( s );
- BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
- s->state = BZ_S_OUTPUT;
- }
- else
- if (s->nblock >= s->nblockMAX) {
- BZ2_compressBlock ( s, False );
- s->state = BZ_S_OUTPUT;
- }
- else
- if (s->strm->avail_in == 0) {
- break;
- }
- }
-
- }
-
- return progress_in || progress_out;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
-{
- Bool progress;
- EState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- preswitch:
- switch (s->mode) {
-
- case BZ_M_IDLE:
- return BZ_SEQUENCE_ERROR;
-
- case BZ_M_RUNNING:
- if (action == BZ_RUN) {
- progress = handle_compress ( strm );
- return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
- }
- else
- if (action == BZ_FLUSH) {
- s->avail_in_expect = strm->avail_in;
- s->mode = BZ_M_FLUSHING;
- goto preswitch;
- }
- else
- if (action == BZ_FINISH) {
- s->avail_in_expect = strm->avail_in;
- s->mode = BZ_M_FINISHING;
- goto preswitch;
- }
- else
- return BZ_PARAM_ERROR;
-
- case BZ_M_FLUSHING:
- if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
- return BZ_SEQUENCE_ERROR;
- progress = handle_compress ( strm );
- if (s->avail_in_expect > 0 || !isempty_RL(s) ||
- s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
- s->mode = BZ_M_RUNNING;
- return BZ_RUN_OK;
-
- case BZ_M_FINISHING:
- if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
- return BZ_SEQUENCE_ERROR;
- progress = handle_compress ( strm );
- if (!progress) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect > 0 || !isempty_RL(s) ||
- s->state_out_pos < s->numZ) return BZ_FINISH_OK;
- s->mode = BZ_M_IDLE;
- return BZ_STREAM_END;
- }
- return BZ_OK; /*--not reached--*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
-{
- EState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- if (s->arr1 != NULL) BZFREE(s->arr1);
- if (s->arr2 != NULL) BZFREE(s->arr2);
- if (s->ftab != NULL) BZFREE(s->ftab);
- BZFREE(strm->state);
-
- strm->state = NULL;
-
- return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-/*--- Decompression stuff ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressInit)
- ( bz_stream* strm,
- int verbosity,
- int small )
-{
- DState* s;
-
- if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
- if (strm == NULL) return BZ_PARAM_ERROR;
- if (small != 0 && small != 1) return BZ_PARAM_ERROR;
- if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR;
-
- if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
- if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
- s = BZALLOC( sizeof(DState) );
- if (s == NULL) return BZ_MEM_ERROR;
- s->strm = strm;
- strm->state = s;
- s->state = BZ_X_MAGIC_1;
- s->bsLive = 0;
- s->bsBuff = 0;
- s->calculatedCombinedCRC = 0;
- strm->total_in_lo32 = 0;
- strm->total_in_hi32 = 0;
- strm->total_out_lo32 = 0;
- strm->total_out_hi32 = 0;
- s->smallDecompress = (Bool)small;
- s->ll4 = NULL;
- s->ll16 = NULL;
- s->tt = NULL;
- s->currBlockNo = 0;
- s->verbosity = verbosity;
-
- return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-static
-void unRLE_obuf_to_output_FAST ( DState* s )
-{
- UChar k1;
-
- if (s->blockRandomised) {
-
- while (True) {
- /* try to finish existing run */
- while (True) {
- if (s->strm->avail_out == 0) return;
- if (s->state_out_len == 0) break;
- *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
- BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
- s->state_out_len--;
- s->strm->next_out++;
- s->strm->avail_out--;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- /* can a new run be started? */
- if (s->nblock_used == s->save_nblock+1) return;
-
-
- s->state_out_len = 1;
- s->state_out_ch = s->k0;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 2;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 3;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
- s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
- }
-
- } else {
-
- /* restore */
- UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC;
- UChar c_state_out_ch = s->state_out_ch;
- Int32 c_state_out_len = s->state_out_len;
- Int32 c_nblock_used = s->nblock_used;
- Int32 c_k0 = s->k0;
- UInt32* c_tt = s->tt;
- UInt32 c_tPos = s->tPos;
- char* cs_next_out = s->strm->next_out;
- unsigned int cs_avail_out = s->strm->avail_out;
- /* end restore */
-
- UInt32 avail_out_INIT = cs_avail_out;
- Int32 s_save_nblockPP = s->save_nblock+1;
- unsigned int total_out_lo32_old;
-
- while (True) {
-
- /* try to finish existing run */
- if (c_state_out_len > 0) {
- while (True) {
- if (cs_avail_out == 0) goto return_notr;
- if (c_state_out_len == 1) break;
- *( (UChar*)(cs_next_out) ) = c_state_out_ch;
- BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
- c_state_out_len--;
- cs_next_out++;
- cs_avail_out--;
- }
- s_state_out_len_eq_one:
- {
- if (cs_avail_out == 0) {
- c_state_out_len = 1; goto return_notr;
- };
- *( (UChar*)(cs_next_out) ) = c_state_out_ch;
- BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
- cs_next_out++;
- cs_avail_out--;
- }
- }
- /* can a new run be started? */
- if (c_nblock_used == s_save_nblockPP) {
- c_state_out_len = 0; goto return_notr;
- };
- c_state_out_ch = c_k0;
- BZ_GET_FAST_C(k1); c_nblock_used++;
- if (k1 != c_k0) {
- c_k0 = k1; goto s_state_out_len_eq_one;
- };
- if (c_nblock_used == s_save_nblockPP)
- goto s_state_out_len_eq_one;
-
- c_state_out_len = 2;
- BZ_GET_FAST_C(k1); c_nblock_used++;
- if (c_nblock_used == s_save_nblockPP) continue;
- if (k1 != c_k0) { c_k0 = k1; continue; };
-
- c_state_out_len = 3;
- BZ_GET_FAST_C(k1); c_nblock_used++;
- if (c_nblock_used == s_save_nblockPP) continue;
- if (k1 != c_k0) { c_k0 = k1; continue; };
-
- BZ_GET_FAST_C(k1); c_nblock_used++;
- c_state_out_len = ((Int32)k1) + 4;
- BZ_GET_FAST_C(c_k0); c_nblock_used++;
- }
-
- return_notr:
- total_out_lo32_old = s->strm->total_out_lo32;
- s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
- if (s->strm->total_out_lo32 < total_out_lo32_old)
- s->strm->total_out_hi32++;
-
- /* save */
- s->calculatedBlockCRC = c_calculatedBlockCRC;
- s->state_out_ch = c_state_out_ch;
- s->state_out_len = c_state_out_len;
- s->nblock_used = c_nblock_used;
- s->k0 = c_k0;
- s->tt = c_tt;
- s->tPos = c_tPos;
- s->strm->next_out = cs_next_out;
- s->strm->avail_out = cs_avail_out;
- /* end save */
- }
-}
-
-
-
-/*---------------------------------------------------*/
-__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
-{
- Int32 nb, na, mid;
- nb = 0;
- na = 256;
- do {
- mid = (nb + na) >> 1;
- if (indx >= cftab[mid]) nb = mid; else na = mid;
- }
- while (na - nb != 1);
- return nb;
-}
-
-
-/*---------------------------------------------------*/
-static
-void unRLE_obuf_to_output_SMALL ( DState* s )
-{
- UChar k1;
-
- if (s->blockRandomised) {
-
- while (True) {
- /* try to finish existing run */
- while (True) {
- if (s->strm->avail_out == 0) return;
- if (s->state_out_len == 0) break;
- *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
- BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
- s->state_out_len--;
- s->strm->next_out++;
- s->strm->avail_out--;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- /* can a new run be started? */
- if (s->nblock_used == s->save_nblock+1) return;
-
-
- s->state_out_len = 1;
- s->state_out_ch = s->k0;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 2;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 3;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
- s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
- }
-
- } else {
-
- while (True) {
- /* try to finish existing run */
- while (True) {
- if (s->strm->avail_out == 0) return;
- if (s->state_out_len == 0) break;
- *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
- BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
- s->state_out_len--;
- s->strm->next_out++;
- s->strm->avail_out--;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- /* can a new run be started? */
- if (s->nblock_used == s->save_nblock+1) return;
-
- s->state_out_len = 1;
- s->state_out_ch = s->k0;
- BZ_GET_SMALL(k1); s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 2;
- BZ_GET_SMALL(k1); s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 3;
- BZ_GET_SMALL(k1); s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_SMALL(k1); s->nblock_used++;
- s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_SMALL(s->k0); s->nblock_used++;
- }
-
- }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
-{
- DState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- while (True) {
- if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
- if (s->state == BZ_X_OUTPUT) {
- if (s->smallDecompress)
- unRLE_obuf_to_output_SMALL ( s ); else
- unRLE_obuf_to_output_FAST ( s );
- if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
- BZ_FINALISE_CRC ( s->calculatedBlockCRC );
- if (s->verbosity >= 3)
- VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC,
- s->calculatedBlockCRC );
- if (s->verbosity >= 2) VPrintf0 ( "]" );
- if (s->calculatedBlockCRC != s->storedBlockCRC)
- return BZ_DATA_ERROR;
- s->calculatedCombinedCRC
- = (s->calculatedCombinedCRC << 1) |
- (s->calculatedCombinedCRC >> 31);
- s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
- s->state = BZ_X_BLKHDR_1;
- } else {
- return BZ_OK;
- }
- }
- if (s->state >= BZ_X_MAGIC_1) {
- Int32 r = BZ2_decompress ( s );
- if (r == BZ_STREAM_END) {
- if (s->verbosity >= 3)
- VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x",
- s->storedCombinedCRC, s->calculatedCombinedCRC );
- if (s->calculatedCombinedCRC != s->storedCombinedCRC)
- return BZ_DATA_ERROR;
- return r;
- }
- if (s->state != BZ_X_OUTPUT) return r;
- }
- }
-
- AssertH ( 0, 6001 );
-
- return 0; /*NOTREACHED*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
-{
- DState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- if (s->tt != NULL) BZFREE(s->tt);
- if (s->ll16 != NULL) BZFREE(s->ll16);
- if (s->ll4 != NULL) BZFREE(s->ll4);
-
- BZFREE(strm->state);
- strm->state = NULL;
-
- return BZ_OK;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-/*--- File I/O stuff ---*/
-/*---------------------------------------------------*/
-
-#define BZ_SETERR(eee) \
-{ \
- if (bzerror != NULL) *bzerror = eee; \
- if (bzf != NULL) bzf->lastErr = eee; \
-}
-
-typedef
- struct {
- FILE* handle;
- Char buf[BZ_MAX_UNUSED];
- Int32 bufN;
- Bool writing;
- bz_stream strm;
- Int32 lastErr;
- Bool initialisedOk;
- }
- bzFile;
-
-
-/*---------------------------------------------*/
-static Bool myfeof ( FILE* f )
-{
- return feof(f) ? True : False;
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzWriteOpen)
- ( int* bzerror,
- FILE* f,
- int blockSize100k,
- int verbosity,
- int workFactor )
-{
- Int32 ret;
- bzFile* bzf = NULL;
-
- BZ_SETERR(BZ_OK);
-
- if (f == NULL ||
- (blockSize100k < 1 || blockSize100k > 9) ||
- (workFactor < 0 || workFactor > 250) ||
- (verbosity < 0 || verbosity > 4))
- { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
- if (ferror(f))
- { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
- bzf = malloc ( sizeof(bzFile) );
- if (bzf == NULL)
- { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
- BZ_SETERR(BZ_OK);
- bzf->initialisedOk = False;
- bzf->bufN = 0;
- bzf->handle = f;
- bzf->writing = True;
- bzf->strm.bzalloc = NULL;
- bzf->strm.bzfree = NULL;
- bzf->strm.opaque = NULL;
-
- if (workFactor == 0) workFactor = 30;
- ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
- verbosity, workFactor );
- if (ret != BZ_OK)
- { BZ_SETERR(ret); free(bzf); return NULL; };
-
- bzf->strm.avail_in = 0;
- bzf->initialisedOk = True;
- return bzf;
-}
-
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWrite)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
- int len )
-{
- Int32 n, n2, ret;
- bzFile* bzf = (bzFile*)b;
-
- BZ_SETERR(BZ_OK);
- if (bzf == NULL || buf == NULL || len < 0)
- { BZ_SETERR(BZ_PARAM_ERROR); return; };
- if (!(bzf->writing))
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
-
- if (len == 0)
- { BZ_SETERR(BZ_OK); return; };
-
- bzf->strm.avail_in = len;
- bzf->strm.next_in = buf;
-
- while (True) {
- bzf->strm.avail_out = BZ_MAX_UNUSED;
- bzf->strm.next_out = bzf->buf;
- ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
- if (ret != BZ_RUN_OK)
- { BZ_SETERR(ret); return; };
-
- if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
- n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
- n, bzf->handle );
- if (n != n2 || ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
- }
-
- if (bzf->strm.avail_in == 0)
- { BZ_SETERR(BZ_OK); return; };
- }
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWriteClose)
- ( int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in,
- unsigned int* nbytes_out )
-{
- BZ2_bzWriteClose64 ( bzerror, b, abandon,
- nbytes_in, NULL, nbytes_out, NULL );
-}
-
-
-void BZ_API(BZ2_bzWriteClose64)
- ( int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in_lo32,
- unsigned int* nbytes_in_hi32,
- unsigned int* nbytes_out_lo32,
- unsigned int* nbytes_out_hi32 )
-{
- Int32 n, n2, ret;
- bzFile* bzf = (bzFile*)b;
-
- if (bzf == NULL)
- { BZ_SETERR(BZ_OK); return; };
- if (!(bzf->writing))
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
-
- if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
- if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
- if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
- if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;
-
- if ((!abandon) && bzf->lastErr == BZ_OK) {
- while (True) {
- bzf->strm.avail_out = BZ_MAX_UNUSED;
- bzf->strm.next_out = bzf->buf;
- ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
- if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
- { BZ_SETERR(ret); return; };
-
- if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
- n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
- n, bzf->handle );
- if (n != n2 || ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
- }
-
- if (ret == BZ_STREAM_END) break;
- }
- }
-
- if ( !abandon && !ferror ( bzf->handle ) ) {
- fflush ( bzf->handle );
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
- }
-
- if (nbytes_in_lo32 != NULL)
- *nbytes_in_lo32 = bzf->strm.total_in_lo32;
- if (nbytes_in_hi32 != NULL)
- *nbytes_in_hi32 = bzf->strm.total_in_hi32;
- if (nbytes_out_lo32 != NULL)
- *nbytes_out_lo32 = bzf->strm.total_out_lo32;
- if (nbytes_out_hi32 != NULL)
- *nbytes_out_hi32 = bzf->strm.total_out_hi32;
-
- BZ_SETERR(BZ_OK);
- BZ2_bzCompressEnd ( &(bzf->strm) );
- free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzReadOpen)
- ( int* bzerror,
- FILE* f,
- int verbosity,
- int small,
- void* unused,
- int nUnused )
-{
- bzFile* bzf = NULL;
- int ret;
-
- BZ_SETERR(BZ_OK);
-
- if (f == NULL ||
- (small != 0 && small != 1) ||
- (verbosity < 0 || verbosity > 4) ||
- (unused == NULL && nUnused != 0) ||
- (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
- { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
- if (ferror(f))
- { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
- bzf = malloc ( sizeof(bzFile) );
- if (bzf == NULL)
- { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
- BZ_SETERR(BZ_OK);
-
- bzf->initialisedOk = False;
- bzf->handle = f;
- bzf->bufN = 0;
- bzf->writing = False;
- bzf->strm.bzalloc = NULL;
- bzf->strm.bzfree = NULL;
- bzf->strm.opaque = NULL;
-
- while (nUnused > 0) {
- bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
- unused = ((void*)( 1 + ((UChar*)(unused)) ));
- nUnused--;
- }
-
- ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
- if (ret != BZ_OK)
- { BZ_SETERR(ret); free(bzf); return NULL; };
-
- bzf->strm.avail_in = bzf->bufN;
- bzf->strm.next_in = bzf->buf;
-
- bzf->initialisedOk = True;
- return bzf;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
-{
- bzFile* bzf = (bzFile*)b;
-
- BZ_SETERR(BZ_OK);
- if (bzf == NULL)
- { BZ_SETERR(BZ_OK); return; };
-
- if (bzf->writing)
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-
- if (bzf->initialisedOk)
- (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
- free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzRead)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
- int len )
-{
- Int32 n, ret;
- bzFile* bzf = (bzFile*)b;
-
- BZ_SETERR(BZ_OK);
-
- if (bzf == NULL || buf == NULL || len < 0)
- { BZ_SETERR(BZ_PARAM_ERROR); return 0; };
-
- if (bzf->writing)
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };
-
- if (len == 0)
- { BZ_SETERR(BZ_OK); return 0; };
-
- bzf->strm.avail_out = len;
- bzf->strm.next_out = buf;
-
- while (True) {
-
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return 0; };
-
- if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
- n = fread ( bzf->buf, sizeof(UChar),
- BZ_MAX_UNUSED, bzf->handle );
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return 0; };
- bzf->bufN = n;
- bzf->strm.avail_in = bzf->bufN;
- bzf->strm.next_in = bzf->buf;
- }
-
- ret = BZ2_bzDecompress ( &(bzf->strm) );
-
- if (ret != BZ_OK && ret != BZ_STREAM_END)
- { BZ_SETERR(ret); return 0; };
-
- if (ret == BZ_OK && myfeof(bzf->handle) &&
- bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
- { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
-
- if (ret == BZ_STREAM_END)
- { BZ_SETERR(BZ_STREAM_END);
- return len - bzf->strm.avail_out; };
- if (bzf->strm.avail_out == 0)
- { BZ_SETERR(BZ_OK); return len; };
-
- }
-
- return 0; /*not reached*/
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadGetUnused)
- ( int* bzerror,
- BZFILE* b,
- void** unused,
- int* nUnused )
-{
- bzFile* bzf = (bzFile*)b;
- if (bzf == NULL)
- { BZ_SETERR(BZ_PARAM_ERROR); return; };
- if (bzf->lastErr != BZ_STREAM_END)
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
- if (unused == NULL || nUnused == NULL)
- { BZ_SETERR(BZ_PARAM_ERROR); return; };
-
- BZ_SETERR(BZ_OK);
- *nUnused = bzf->strm.avail_in;
- *unused = bzf->strm.next_in;
-}
-#endif
-
-
-/*---------------------------------------------------*/
-/*--- Misc convenience stuff ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress)
- ( char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
- int workFactor )
-{
- bz_stream strm;
- int ret;
-
- if (dest == NULL || destLen == NULL ||
- source == NULL ||
- blockSize100k < 1 || blockSize100k > 9 ||
- verbosity < 0 || verbosity > 4 ||
- workFactor < 0 || workFactor > 250)
- return BZ_PARAM_ERROR;
-
- if (workFactor == 0) workFactor = 30;
- strm.bzalloc = NULL;
- strm.bzfree = NULL;
- strm.opaque = NULL;
- ret = BZ2_bzCompressInit ( &strm, blockSize100k,
- verbosity, workFactor );
- if (ret != BZ_OK) return ret;
-
- strm.next_in = source;
- strm.next_out = dest;
- strm.avail_in = sourceLen;
- strm.avail_out = *destLen;
-
- ret = BZ2_bzCompress ( &strm, BZ_FINISH );
- if (ret == BZ_FINISH_OK) goto output_overflow;
- if (ret != BZ_STREAM_END) goto errhandler;
-
- /* normal termination */
- *destLen -= strm.avail_out;
- BZ2_bzCompressEnd ( &strm );
- return BZ_OK;
-
- output_overflow:
- BZ2_bzCompressEnd ( &strm );
- return BZ_OUTBUFF_FULL;
-
- errhandler:
- BZ2_bzCompressEnd ( &strm );
- return ret;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffDecompress)
- ( char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int small,
- int verbosity )
-{
- bz_stream strm;
- int ret;
-
- if (dest == NULL || destLen == NULL ||
- source == NULL ||
- (small != 0 && small != 1) ||
- verbosity < 0 || verbosity > 4)
- return BZ_PARAM_ERROR;
-
- strm.bzalloc = NULL;
- strm.bzfree = NULL;
- strm.opaque = NULL;
- ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
- if (ret != BZ_OK) return ret;
-
- strm.next_in = source;
- strm.next_out = dest;
- strm.avail_in = sourceLen;
- strm.avail_out = *destLen;
-
- ret = BZ2_bzDecompress ( &strm );
- if (ret == BZ_OK) goto output_overflow_or_eof;
- if (ret != BZ_STREAM_END) goto errhandler;
-
- /* normal termination */
- *destLen -= strm.avail_out;
- BZ2_bzDecompressEnd ( &strm );
- return BZ_OK;
-
- output_overflow_or_eof:
- if (strm.avail_out > 0) {
- BZ2_bzDecompressEnd ( &strm );
- return BZ_UNEXPECTED_EOF;
- } else {
- BZ2_bzDecompressEnd ( &strm );
- return BZ_OUTBUFF_FULL;
- };
-
- errhandler:
- BZ2_bzDecompressEnd ( &strm );
- return ret;
-}
-
-
-/*---------------------------------------------------*/
-/*--
- Code contributed by Yoshioka Tsuneo
- (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
- to support better zlib compatibility.
- This code is not _officially_ part of libbzip2 (yet);
- I haven't tested it, documented it, or considered the
- threading-safeness of it.
- If this code breaks, please contact both Yoshioka and me.
---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-/*--
- return version like "0.9.0c".
---*/
-const char * BZ_API(BZ2_bzlibVersion)(void)
-{
- return BZ_VERSION;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-
-#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
-# include <fcntl.h>
-# include <io.h>
-# define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
-#else
-# define SET_BINARY_MODE(file)
-#endif
-static
-BZFILE * bzopen_or_bzdopen
- ( const char *path, /* no use when bzdopen */
- int fd, /* no use when bzdopen */
- const char *mode,
- int open_mode) /* bzopen: 0, bzdopen:1 */
-{
- int bzerr;
- char unused[BZ_MAX_UNUSED];
- int blockSize100k = 9;
- int writing = 0;
- char mode2[10] = "";
- FILE *fp = NULL;
- BZFILE *bzfp = NULL;
- int verbosity = 0;
- int workFactor = 30;
- int smallMode = 0;
- int nUnused = 0;
-
- if (mode == NULL) return NULL;
- while (*mode) {
- switch (*mode) {
- case 'r':
- writing = 0; break;
- case 'w':
- writing = 1; break;
- case 's':
- smallMode = 1; break;
- default:
- if (isdigit((int)(*mode))) {
- blockSize100k = *mode-'0';
- }
- }
- mode++;
- }
- strcat(mode2, writing ? "w" : "r" );
- strcat(mode2,"b"); /* binary mode */
-
- if (open_mode==0) {
- if (path==NULL || strcmp(path,"")==0) {
- fp = (writing ? stdout : stdin);
- SET_BINARY_MODE(fp);
- } else {
- fp = fopen(path,mode2);
- }
- } else {
-#ifdef BZ_STRICT_ANSI
- fp = NULL;
-#else
- fp = fdopen(fd,mode2);
-#endif
- }
- if (fp == NULL) return NULL;
-
- if (writing) {
- /* Guard against total chaos and anarchy -- JRS */
- if (blockSize100k < 1) blockSize100k = 1;
- if (blockSize100k > 9) blockSize100k = 9;
- bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
- verbosity,workFactor);
- } else {
- bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode,
- unused,nUnused);
- }
- if (bzfp == NULL) {
- if (fp != stdin && fp != stdout) fclose(fp);
- return NULL;
- }
- return bzfp;
-}
-
-
-/*---------------------------------------------------*/
-/*--
- open file for read or write.
- ex) bzopen("file","w9")
- case path="" or NULL => use stdin or stdout.
---*/
-BZFILE * BZ_API(BZ2_bzopen)
- ( const char *path,
- const char *mode )
-{
- return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0);
-}
-
-
-/*---------------------------------------------------*/
-BZFILE * BZ_API(BZ2_bzdopen)
- ( int fd,
- const char *mode )
-{
- return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1);
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
-{
- int bzerr, nread;
- if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
- nread = BZ2_bzRead(&bzerr,b,buf,len);
- if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) {
- return nread;
- } else {
- return -1;
- }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
-{
- int bzerr;
-
- BZ2_bzWrite(&bzerr,b,buf,len);
- if(bzerr == BZ_OK){
- return len;
- }else{
- return -1;
- }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzflush) (BZFILE *b __attribute__ ((unused)))
-{
- /* do nothing now... */
- return 0;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzclose) (BZFILE* b)
-{
- int bzerr;
- FILE *fp = ((bzFile *)b)->handle;
-
- if (b==NULL) {return;}
- if(((bzFile*)b)->writing){
- BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
- if(bzerr != BZ_OK){
- BZ2_bzWriteClose(NULL,b,1,NULL,NULL);
- }
- }else{
- BZ2_bzReadClose(&bzerr,b);
- }
- if(fp!=stdin && fp!=stdout){
- fclose(fp);
- }
-}
-
-
-/*---------------------------------------------------*/
-/*--
- return last error code
---*/
-static char *bzerrorstrings[] = {
- "OK"
- ,"SEQUENCE_ERROR"
- ,"PARAM_ERROR"
- ,"MEM_ERROR"
- ,"DATA_ERROR"
- ,"DATA_ERROR_MAGIC"
- ,"IO_ERROR"
- ,"UNEXPECTED_EOF"
- ,"OUTBUFF_FULL"
- ,"CONFIG_ERROR"
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
-};
-
-
-const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
-{
- int err = ((bzFile *)b)->lastErr;
-
- if(err>0) err = 0;
- *errnum = err;
- return bzerrorstrings[err*-1];
-}
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/bzlib.h b/mdk-stage1/bzlib/bzlib.h
deleted file mode 100644
index c9447a295..000000000
--- a/mdk-stage1/bzlib/bzlib.h
+++ /dev/null
@@ -1,319 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Public header file for the library. ---*/
-/*--- bzlib.h ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-
-#ifndef _BZLIB_H
-#define _BZLIB_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BZ_RUN 0
-#define BZ_FLUSH 1
-#define BZ_FINISH 2
-
-#define BZ_OK 0
-#define BZ_RUN_OK 1
-#define BZ_FLUSH_OK 2
-#define BZ_FINISH_OK 3
-#define BZ_STREAM_END 4
-#define BZ_SEQUENCE_ERROR (-1)
-#define BZ_PARAM_ERROR (-2)
-#define BZ_MEM_ERROR (-3)
-#define BZ_DATA_ERROR (-4)
-#define BZ_DATA_ERROR_MAGIC (-5)
-#define BZ_IO_ERROR (-6)
-#define BZ_UNEXPECTED_EOF (-7)
-#define BZ_OUTBUFF_FULL (-8)
-#define BZ_CONFIG_ERROR (-9)
-
-typedef
- struct {
- char *next_in;
- unsigned int avail_in;
- unsigned int total_in_lo32;
- unsigned int total_in_hi32;
-
- char *next_out;
- unsigned int avail_out;
- unsigned int total_out_lo32;
- unsigned int total_out_hi32;
-
- void *state;
-
- void *(*bzalloc)(void *,int,int);
- void (*bzfree)(void *,void *);
- void *opaque;
- }
- bz_stream;
-
-
-#ifndef BZ_IMPORT
-#define BZ_EXPORT
-#endif
-
-#ifdef _WIN32
-# include <stdio.h>
-# include <windows.h>
-# ifdef small
- /* windows.h define small to char */
-# undef small
-# endif
-# ifdef BZ_EXPORT
-# define BZ_API(func) WINAPI func
-# define BZ_EXTERN extern
-# else
- /* import windows dll dynamically */
-# define BZ_API(func) (WINAPI * func)
-# define BZ_EXTERN
-# endif
-#else
-# define BZ_API(func) func
-# define BZ_EXTERN extern
-#endif
-
-
-/*-- Core (low-level) library functions --*/
-
-BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
- bz_stream* strm,
- int blockSize100k,
- int verbosity,
- int workFactor
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzCompress) (
- bz_stream* strm,
- int action
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
- bz_stream* strm
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
- bz_stream *strm,
- int verbosity,
- int small
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
- bz_stream* strm
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
- bz_stream *strm
- );
-
-
-
-/*-- High(er) level library functions --*/
-
-#ifndef BZ_NO_STDIO
-#define BZ_MAX_UNUSED 5000
-
-typedef void BZFILE;
-
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
- int* bzerror,
- FILE* f,
- int verbosity,
- int small,
- void* unused,
- int nUnused
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
- int* bzerror,
- BZFILE* b
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
- int* bzerror,
- BZFILE* b,
- void** unused,
- int* nUnused
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzRead) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
- int* bzerror,
- FILE* f,
- int blockSize100k,
- int verbosity,
- int workFactor
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzWrite) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in,
- unsigned int* nbytes_out
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in_lo32,
- unsigned int* nbytes_in_hi32,
- unsigned int* nbytes_out_lo32,
- unsigned int* nbytes_out_hi32
- );
-#endif
-
-
-/*-- Utility functions --*/
-
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
- char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
- int workFactor
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
- char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int small,
- int verbosity
- );
-
-
-/*--
- Code contributed by Yoshioka Tsuneo
- (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
- to support better zlib compatibility.
- This code is not _officially_ part of libbzip2 (yet);
- I haven't tested it, documented it, or considered the
- threading-safeness of it.
- If this code breaks, please contact both Yoshioka and me.
---*/
-
-BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
- void
- );
-
-#ifndef BZ_NO_STDIO
-BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
- const char *path,
- const char *mode
- );
-
-BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
- int fd,
- const char *mode
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzread) (
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzwrite) (
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzflush) (
- BZFILE* b
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzclose) (
- BZFILE* b
- );
-
-BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
- BZFILE *b,
- int *errnum
- );
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib.h ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/bzlib_private.h b/mdk-stage1/bzlib/bzlib_private.h
deleted file mode 100644
index fb51c7a1d..000000000
--- a/mdk-stage1/bzlib/bzlib_private.h
+++ /dev/null
@@ -1,530 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Private header file for the library. ---*/
-/*--- bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-
-#ifndef _BZLIB_PRIVATE_H
-#define _BZLIB_PRIVATE_H
-
-#include <stdlib.h>
-
-#ifndef BZ_NO_STDIO
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#endif
-
-#include "bzlib.h"
-
-
-
-/*-- General stuff. --*/
-
-#define BZ_VERSION "1.0.1, 23-June-2000"
-
-typedef char Char;
-typedef unsigned char Bool;
-typedef unsigned char UChar;
-typedef int Int32;
-typedef unsigned int UInt32;
-typedef short Int16;
-typedef unsigned short UInt16;
-
-#define True ((Bool)1)
-#define False ((Bool)0)
-
-#ifndef __GNUC__
-#define __inline__ /* */
-#endif
-
-#ifndef BZ_NO_STDIO
-extern void BZ2_bz__AssertH__fail ( int errcode );
-#define AssertH(cond,errcode) \
- { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
-#if BZ_DEBUG
-#define AssertD(cond,msg) \
- { if (!(cond)) { \
- fprintf ( stderr, \
- "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
- exit(1); \
- }}
-#else
-#define AssertD(cond,msg) /* */
-#endif
-#define VPrintf0(zf) \
- fprintf(stderr,zf)
-#define VPrintf1(zf,za1) \
- fprintf(stderr,zf,za1)
-#define VPrintf2(zf,za1,za2) \
- fprintf(stderr,zf,za1,za2)
-#define VPrintf3(zf,za1,za2,za3) \
- fprintf(stderr,zf,za1,za2,za3)
-#define VPrintf4(zf,za1,za2,za3,za4) \
- fprintf(stderr,zf,za1,za2,za3,za4)
-#define VPrintf5(zf,za1,za2,za3,za4,za5) \
- fprintf(stderr,zf,za1,za2,za3,za4,za5)
-#else
-extern void bz_internal_error ( int errcode );
-#define AssertH(cond,errcode) \
- { if (!(cond)) bz_internal_error ( errcode ); }
-#define AssertD(cond,msg) /* */
-#define VPrintf0(zf) /* */
-#define VPrintf1(zf,za1) /* */
-#define VPrintf2(zf,za1,za2) /* */
-#define VPrintf3(zf,za1,za2,za3) /* */
-#define VPrintf4(zf,za1,za2,za3,za4) /* */
-#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */
-#endif
-
-
-#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
-#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp))
-
-
-/*-- Constants for the back end. --*/
-
-#define BZ_MAX_ALPHA_SIZE 258
-#define BZ_MAX_CODE_LEN 23
-
-#define BZ_RUNA 0
-#define BZ_RUNB 1
-
-#define BZ_N_GROUPS 6
-#define BZ_G_SIZE 50
-#define BZ_N_ITERS 4
-
-#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
-
-
-
-/*-- Stuff for randomising repetitive blocks. --*/
-
-extern Int32 BZ2_rNums[512];
-
-#define BZ_RAND_DECLS \
- Int32 rNToGo; \
- Int32 rTPos \
-
-#define BZ_RAND_INIT_MASK \
- s->rNToGo = 0; \
- s->rTPos = 0 \
-
-#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
-
-#define BZ_RAND_UPD_MASK \
- if (s->rNToGo == 0) { \
- s->rNToGo = BZ2_rNums[s->rTPos]; \
- s->rTPos++; \
- if (s->rTPos == 512) s->rTPos = 0; \
- } \
- s->rNToGo--;
-
-
-
-/*-- Stuff for doing CRCs. --*/
-
-extern UInt32 BZ2_crc32Table[256];
-
-#define BZ_INITIALISE_CRC(crcVar) \
-{ \
- crcVar = 0xffffffffL; \
-}
-
-#define BZ_FINALISE_CRC(crcVar) \
-{ \
- crcVar = ~(crcVar); \
-}
-
-#define BZ_UPDATE_CRC(crcVar,cha) \
-{ \
- crcVar = (crcVar << 8) ^ \
- BZ2_crc32Table[(crcVar >> 24) ^ \
- ((UChar)cha)]; \
-}
-
-
-
-/*-- States and modes for compression. --*/
-
-#define BZ_M_IDLE 1
-#define BZ_M_RUNNING 2
-#define BZ_M_FLUSHING 3
-#define BZ_M_FINISHING 4
-
-#define BZ_S_OUTPUT 1
-#define BZ_S_INPUT 2
-
-#define BZ_N_RADIX 2
-#define BZ_N_QSORT 12
-#define BZ_N_SHELL 18
-#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
-
-
-
-
-/*-- Structure holding all the compression-side stuff. --*/
-
-typedef
- struct {
- /* pointer back to the struct bz_stream */
- bz_stream* strm;
-
- /* mode this stream is in, and whether inputting */
- /* or outputting data */
- Int32 mode;
- Int32 state;
-
- /* remembers avail_in when flush/finish requested */
- UInt32 avail_in_expect;
-
- /* for doing the block sorting */
- UInt32* arr1;
- UInt32* arr2;
- UInt32* ftab;
- Int32 origPtr;
-
- /* aliases for arr1 and arr2 */
- UInt32* ptr;
- UChar* block;
- UInt16* mtfv;
- UChar* zbits;
-
- /* for deciding when to use the fallback sorting algorithm */
- Int32 workFactor;
-
- /* run-length-encoding of the input */
- UInt32 state_in_ch;
- Int32 state_in_len;
- BZ_RAND_DECLS;
-
- /* input and output limits and current posns */
- Int32 nblock;
- Int32 nblockMAX;
- Int32 numZ;
- Int32 state_out_pos;
-
- /* map of bytes used in block */
- Int32 nInUse;
- Bool inUse[256];
- UChar unseqToSeq[256];
-
- /* the buffer for bit stream creation */
- UInt32 bsBuff;
- Int32 bsLive;
-
- /* block and combined CRCs */
- UInt32 blockCRC;
- UInt32 combinedCRC;
-
- /* misc administratium */
- Int32 verbosity;
- Int32 blockNo;
- Int32 blockSize100k;
-
- /* stuff for coding the MTF values */
- Int32 nMTF;
- Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
- UChar selector [BZ_MAX_SELECTORS];
- UChar selectorMtf[BZ_MAX_SELECTORS];
-
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- /* second dimension: only 3 needed; 4 makes index calculations faster */
- UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
-
- }
- EState;
-
-
-
-/*-- externs for compression. --*/
-
-extern void
-BZ2_blockSort ( EState* );
-
-extern void
-BZ2_compressBlock ( EState*, Bool );
-
-extern void
-BZ2_bsInitWrite ( EState* );
-
-extern void
-BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-
-extern void
-BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
-
-
-
-/*-- states for decompression. --*/
-
-#define BZ_X_IDLE 1
-#define BZ_X_OUTPUT 2
-
-#define BZ_X_MAGIC_1 10
-#define BZ_X_MAGIC_2 11
-#define BZ_X_MAGIC_3 12
-#define BZ_X_MAGIC_4 13
-#define BZ_X_BLKHDR_1 14
-#define BZ_X_BLKHDR_2 15
-#define BZ_X_BLKHDR_3 16
-#define BZ_X_BLKHDR_4 17
-#define BZ_X_BLKHDR_5 18
-#define BZ_X_BLKHDR_6 19
-#define BZ_X_BCRC_1 20
-#define BZ_X_BCRC_2 21
-#define BZ_X_BCRC_3 22
-#define BZ_X_BCRC_4 23
-#define BZ_X_RANDBIT 24
-#define BZ_X_ORIGPTR_1 25
-#define BZ_X_ORIGPTR_2 26
-#define BZ_X_ORIGPTR_3 27
-#define BZ_X_MAPPING_1 28
-#define BZ_X_MAPPING_2 29
-#define BZ_X_SELECTOR_1 30
-#define BZ_X_SELECTOR_2 31
-#define BZ_X_SELECTOR_3 32
-#define BZ_X_CODING_1 33
-#define BZ_X_CODING_2 34
-#define BZ_X_CODING_3 35
-#define BZ_X_MTF_1 36
-#define BZ_X_MTF_2 37
-#define BZ_X_MTF_3 38
-#define BZ_X_MTF_4 39
-#define BZ_X_MTF_5 40
-#define BZ_X_MTF_6 41
-#define BZ_X_ENDHDR_2 42
-#define BZ_X_ENDHDR_3 43
-#define BZ_X_ENDHDR_4 44
-#define BZ_X_ENDHDR_5 45
-#define BZ_X_ENDHDR_6 46
-#define BZ_X_CCRC_1 47
-#define BZ_X_CCRC_2 48
-#define BZ_X_CCRC_3 49
-#define BZ_X_CCRC_4 50
-
-
-
-/*-- Constants for the fast MTF decoder. --*/
-
-#define MTFA_SIZE 4096
-#define MTFL_SIZE 16
-
-
-
-/*-- Structure holding all the decompression-side stuff. --*/
-
-typedef
- struct {
- /* pointer back to the struct bz_stream */
- bz_stream* strm;
-
- /* state indicator for this stream */
- Int32 state;
-
- /* for doing the final run-length decoding */
- UChar state_out_ch;
- Int32 state_out_len;
- Bool blockRandomised;
- BZ_RAND_DECLS;
-
- /* the buffer for bit stream reading */
- UInt32 bsBuff;
- Int32 bsLive;
-
- /* misc administratium */
- Int32 blockSize100k;
- Bool smallDecompress;
- Int32 currBlockNo;
- Int32 verbosity;
-
- /* for undoing the Burrows-Wheeler transform */
- Int32 origPtr;
- UInt32 tPos;
- Int32 k0;
- Int32 unzftab[256];
- Int32 nblock_used;
- Int32 cftab[257];
- Int32 cftabCopy[257];
-
- /* for undoing the Burrows-Wheeler transform (FAST) */
- UInt32 *tt;
-
- /* for undoing the Burrows-Wheeler transform (SMALL) */
- UInt16 *ll16;
- UChar *ll4;
-
- /* stored and calculated CRCs */
- UInt32 storedBlockCRC;
- UInt32 storedCombinedCRC;
- UInt32 calculatedBlockCRC;
- UInt32 calculatedCombinedCRC;
-
- /* map of bytes used in block */
- Int32 nInUse;
- Bool inUse[256];
- Bool inUse16[16];
- UChar seqToUnseq[256];
-
- /* for decoding the MTF values */
- UChar mtfa [MTFA_SIZE];
- Int32 mtfbase[256 / MTFL_SIZE];
- UChar selector [BZ_MAX_SELECTORS];
- UChar selectorMtf[BZ_MAX_SELECTORS];
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-
- Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 minLens[BZ_N_GROUPS];
-
- /* save area for scalars in the main decompress code */
- Int32 save_i;
- Int32 save_j;
- Int32 save_t;
- Int32 save_alphaSize;
- Int32 save_nGroups;
- Int32 save_nSelectors;
- Int32 save_EOB;
- Int32 save_groupNo;
- Int32 save_groupPos;
- Int32 save_nextSym;
- Int32 save_nblockMAX;
- Int32 save_nblock;
- Int32 save_es;
- Int32 save_N;
- Int32 save_curr;
- Int32 save_zt;
- Int32 save_zn;
- Int32 save_zvec;
- Int32 save_zj;
- Int32 save_gSel;
- Int32 save_gMinlen;
- Int32* save_gLimit;
- Int32* save_gBase;
- Int32* save_gPerm;
-
- }
- DState;
-
-
-
-/*-- Macros for decompression. --*/
-
-#define BZ_GET_FAST(cccc) \
- s->tPos = s->tt[s->tPos]; \
- cccc = (UChar)(s->tPos & 0xff); \
- s->tPos >>= 8;
-
-#define BZ_GET_FAST_C(cccc) \
- c_tPos = c_tt[c_tPos]; \
- cccc = (UChar)(c_tPos & 0xff); \
- c_tPos >>= 8;
-
-#define SET_LL4(i,n) \
- { if (((i) & 0x1) == 0) \
- s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
- s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
- }
-
-#define GET_LL4(i) \
- ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
-
-#define SET_LL(i,n) \
- { s->ll16[i] = (UInt16)(n & 0x0000ffff); \
- SET_LL4(i, n >> 16); \
- }
-
-#define GET_LL(i) \
- (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
-
-#define BZ_GET_SMALL(cccc) \
- cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
- s->tPos = GET_LL(s->tPos);
-
-
-/*-- externs for decompression. --*/
-
-extern Int32
-BZ2_indexIntoF ( Int32, Int32* );
-
-extern Int32
-BZ2_decompress ( DState* );
-
-extern void
-BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
- Int32, Int32, Int32 );
-
-
-#endif
-
-
-/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
-
-#ifdef BZ_NO_STDIO
-#ifndef NULL
-#define NULL 0
-#endif
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/compress.c b/mdk-stage1/bzlib/compress.c
deleted file mode 100644
index 58d5abe7c..000000000
--- a/mdk-stage1/bzlib/compress.c
+++ /dev/null
@@ -1,720 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Compression machinery (not incl block sorting) ---*/
-/*--- compress.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-/*--
- CHANGES
- ~~~~~~~
- 0.9.0 -- original version.
-
- 0.9.0a/b -- no changes in this file.
-
- 0.9.0c
- * changed setting of nGroups in sendMTFValues() so as to
- do a bit better on small files
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-/*--- Bit stream I/O ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-void BZ2_bsInitWrite ( EState* s )
-{
- s->bsLive = 0;
- s->bsBuff = 0;
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsFinishWrite ( EState* s )
-{
- while (s->bsLive > 0) {
- s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24);
- s->numZ++;
- s->bsBuff <<= 8;
- s->bsLive -= 8;
- }
-}
-
-
-/*---------------------------------------------------*/
-#define bsNEEDW(nz) \
-{ \
- while (s->bsLive >= 8) { \
- s->zbits[s->numZ] \
- = (UChar)(s->bsBuff >> 24); \
- s->numZ++; \
- s->bsBuff <<= 8; \
- s->bsLive -= 8; \
- } \
-}
-
-
-/*---------------------------------------------------*/
-static
-__inline__
-void bsW ( EState* s, Int32 n, UInt32 v )
-{
- bsNEEDW ( n );
- s->bsBuff |= (v << (32 - s->bsLive - n));
- s->bsLive += n;
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsPutUInt32 ( EState* s, UInt32 u )
-{
- bsW ( s, 8, (u >> 24) & 0xffL );
- bsW ( s, 8, (u >> 16) & 0xffL );
- bsW ( s, 8, (u >> 8) & 0xffL );
- bsW ( s, 8, u & 0xffL );
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsPutUChar ( EState* s, UChar c )
-{
- bsW( s, 8, (UInt32)c );
-}
-
-
-/*---------------------------------------------------*/
-/*--- The back end proper ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-static
-void makeMaps_e ( EState* s )
-{
- Int32 i;
- s->nInUse = 0;
- for (i = 0; i < 256; i++)
- if (s->inUse[i]) {
- s->unseqToSeq[i] = s->nInUse;
- s->nInUse++;
- }
-}
-
-
-/*---------------------------------------------------*/
-static
-void generateMTFValues ( EState* s )
-{
- UChar yy[256];
- Int32 i, j;
- Int32 zPend;
- Int32 wr;
- Int32 EOB;
-
- /*
- After sorting (eg, here),
- s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
- and
- ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
- holds the original block data.
-
- The first thing to do is generate the MTF values,
- and put them in
- ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ].
- Because there are strictly fewer or equal MTF values
- than block values, ptr values in this area are overwritten
- with MTF values only when they are no longer needed.
-
- The final compressed bitstream is generated into the
- area starting at
- (UChar*) (&((UChar*)s->arr2)[s->nblock])
-
- These storage aliases are set up in bzCompressInit(),
- except for the last one, which is arranged in
- compressBlock().
- */
- UInt32* ptr = s->ptr;
- UChar* block = s->block;
- UInt16* mtfv = s->mtfv;
-
- makeMaps_e ( s );
- EOB = s->nInUse+1;
-
- for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0;
-
- wr = 0;
- zPend = 0;
- for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i;
-
- for (i = 0; i < s->nblock; i++) {
- UChar ll_i;
- AssertD ( wr <= i, "generateMTFValues(1)" );
- j = ptr[i]-1; if (j < 0) j += s->nblock;
- ll_i = s->unseqToSeq[block[j]];
- AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
-
- if (yy[0] == ll_i) {
- zPend++;
- } else {
-
- if (zPend > 0) {
- zPend--;
- while (True) {
- if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
- } else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
- }
- if (zPend < 2) break;
- zPend = (zPend - 2) / 2;
- };
- zPend = 0;
- }
- {
- register UChar rtmp;
- register UChar* ryy_j;
- register UChar rll_i;
- rtmp = yy[1];
- yy[1] = yy[0];
- ryy_j = &(yy[1]);
- rll_i = ll_i;
- while ( rll_i != rtmp ) {
- register UChar rtmp2;
- ryy_j++;
- rtmp2 = rtmp;
- rtmp = *ryy_j;
- *ryy_j = rtmp2;
- };
- yy[0] = rtmp;
- j = ryy_j - &(yy[0]);
- mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
- }
-
- }
- }
-
- if (zPend > 0) {
- zPend--;
- while (True) {
- if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
- } else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
- }
- if (zPend < 2) break;
- zPend = (zPend - 2) / 2;
- };
- zPend = 0;
- }
-
- mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++;
-
- s->nMTF = wr;
-}
-
-
-/*---------------------------------------------------*/
-#define BZ_LESSER_ICOST 0
-#define BZ_GREATER_ICOST 15
-
-static
-void sendMTFValues ( EState* s )
-{
- Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
- Int32 nSelectors, alphaSize, minLen, maxLen, selCtr;
- Int32 nGroups, nBytes;
-
- /*--
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- is a global since the decoder also needs it.
-
- Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- are also globals only used in this proc.
- Made global to keep stack frame size small.
- --*/
-
-
- UInt16 cost[BZ_N_GROUPS];
- Int32 fave[BZ_N_GROUPS];
-
- UInt16* mtfv = s->mtfv;
-
- if (s->verbosity >= 3)
- VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
- "%d+2 syms in use\n",
- s->nblock, s->nMTF, s->nInUse );
-
- alphaSize = s->nInUse+2;
- for (t = 0; t < BZ_N_GROUPS; t++)
- for (v = 0; v < alphaSize; v++)
- s->len[t][v] = BZ_GREATER_ICOST;
-
- /*--- Decide how many coding tables to use ---*/
- AssertH ( s->nMTF > 0, 3001 );
- if (s->nMTF < 200) nGroups = 2; else
- if (s->nMTF < 600) nGroups = 3; else
- if (s->nMTF < 1200) nGroups = 4; else
- if (s->nMTF < 2400) nGroups = 5; else
- nGroups = 6;
-
- /*--- Generate an initial set of coding tables ---*/
- {
- Int32 nPart, remF, tFreq, aFreq;
-
- nPart = nGroups;
- remF = s->nMTF;
- gs = 0;
- while (nPart > 0) {
- tFreq = remF / nPart;
- ge = gs-1;
- aFreq = 0;
- while (aFreq < tFreq && ge < alphaSize-1) {
- ge++;
- aFreq += s->mtfFreq[ge];
- }
-
- if (ge > gs
- && nPart != nGroups && nPart != 1
- && ((nGroups-nPart) % 2 == 1)) {
- aFreq -= s->mtfFreq[ge];
- ge--;
- }
-
- if (s->verbosity >= 3)
- VPrintf5( " initial group %d, [%d .. %d], "
- "has %d syms (%4.1f%%)\n",
- nPart, gs, ge, aFreq,
- (100.0 * (float)aFreq) / (float)(s->nMTF) );
-
- for (v = 0; v < alphaSize; v++)
- if (v >= gs && v <= ge)
- s->len[nPart-1][v] = BZ_LESSER_ICOST; else
- s->len[nPart-1][v] = BZ_GREATER_ICOST;
-
- nPart--;
- gs = ge+1;
- remF -= aFreq;
- }
- }
-
- /*---
- Iterate up to BZ_N_ITERS times to improve the tables.
- ---*/
- for (iter = 0; iter < BZ_N_ITERS; iter++) {
-
- for (t = 0; t < nGroups; t++) fave[t] = 0;
-
- for (t = 0; t < nGroups; t++)
- for (v = 0; v < alphaSize; v++)
- s->rfreq[t][v] = 0;
-
- /*---
- Set up an auxiliary length table which is used to fast-track
- the common case (nGroups == 6).
- ---*/
- if (nGroups == 6) {
- for (v = 0; v < alphaSize; v++) {
- s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
- s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
- s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
- }
- }
-
- nSelectors = 0;
- totc = 0;
- gs = 0;
- while (True) {
-
- /*--- Set group start & end marks. --*/
- if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
- if (ge >= s->nMTF) ge = s->nMTF-1;
-
- /*--
- Calculate the cost of this group as coded
- by each of the coding tables.
- --*/
- for (t = 0; t < nGroups; t++) cost[t] = 0;
-
- if (nGroups == 6 && 50 == ge-gs+1) {
- /*--- fast track the common case ---*/
- register UInt32 cost01, cost23, cost45;
- register UInt16 icv;
- cost01 = cost23 = cost45 = 0;
-
-# define BZ_ITER(nn) \
- icv = mtfv[gs+(nn)]; \
- cost01 += s->len_pack[icv][0]; \
- cost23 += s->len_pack[icv][1]; \
- cost45 += s->len_pack[icv][2]; \
-
- BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4);
- BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9);
- BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
- BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
- BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
- BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
- BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
- BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
- BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
- BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
-
-# undef BZ_ITER
-
- cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
- cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
- cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
-
- } else {
- /*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++) {
- UInt16 icv = mtfv[i];
- for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
- }
- }
-
- /*--
- Find the coding table which is best for this group,
- and record its identity in the selector table.
- --*/
- bc = 999999999; bt = -1;
- for (t = 0; t < nGroups; t++)
- if (cost[t] < bc) { bc = cost[t]; bt = t; };
- totc += bc;
- fave[bt]++;
- s->selector[nSelectors] = bt;
- nSelectors++;
-
- /*--
- Increment the symbol frequencies for the selected table.
- --*/
- if (nGroups == 6 && 50 == ge-gs+1) {
- /*--- fast track the common case ---*/
-
-# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++
-
- BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4);
- BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9);
- BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
- BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
- BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
- BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
- BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
- BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
- BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
- BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
-
-# undef BZ_ITUR
-
- } else {
- /*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++)
- s->rfreq[bt][ mtfv[i] ]++;
- }
-
- gs = ge+1;
- }
- if (s->verbosity >= 3) {
- VPrintf2 ( " pass %d: size is %d, grp uses are ",
- iter+1, totc/8 );
- for (t = 0; t < nGroups; t++)
- VPrintf1 ( "%d ", fave[t] );
- VPrintf0 ( "\n" );
- }
-
- /*--
- Recompute the tables based on the accumulated frequencies.
- --*/
- for (t = 0; t < nGroups; t++)
- BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
- alphaSize, 20 );
- }
-
-
- AssertH( nGroups < 8, 3002 );
- AssertH( nSelectors < 32768 &&
- nSelectors <= (2 + (900000 / BZ_G_SIZE)),
- 3003 );
-
-
- /*--- Compute MTF values for the selectors. ---*/
- {
- UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
- for (i = 0; i < nGroups; i++) pos[i] = i;
- for (i = 0; i < nSelectors; i++) {
- ll_i = s->selector[i];
- j = 0;
- tmp = pos[j];
- while ( ll_i != tmp ) {
- j++;
- tmp2 = tmp;
- tmp = pos[j];
- pos[j] = tmp2;
- };
- pos[0] = tmp;
- s->selectorMtf[i] = j;
- }
- };
-
- /*--- Assign actual codes for the tables. --*/
- for (t = 0; t < nGroups; t++) {
- minLen = 32;
- maxLen = 0;
- for (i = 0; i < alphaSize; i++) {
- if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
- if (s->len[t][i] < minLen) minLen = s->len[t][i];
- }
- AssertH ( !(maxLen > 20), 3004 );
- AssertH ( !(minLen < 1), 3005 );
- BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
- minLen, maxLen, alphaSize );
- }
-
- /*--- Transmit the mapping table. ---*/
- {
- Bool inUse16[16];
- for (i = 0; i < 16; i++) {
- inUse16[i] = False;
- for (j = 0; j < 16; j++)
- if (s->inUse[i * 16 + j]) inUse16[i] = True;
- }
-
- nBytes = s->numZ;
- for (i = 0; i < 16; i++)
- if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
-
- for (i = 0; i < 16; i++)
- if (inUse16[i])
- for (j = 0; j < 16; j++) {
- if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
- }
-
- if (s->verbosity >= 3)
- VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
- }
-
- /*--- Now the selectors. ---*/
- nBytes = s->numZ;
- bsW ( s, 3, nGroups );
- bsW ( s, 15, nSelectors );
- for (i = 0; i < nSelectors; i++) {
- for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
- bsW(s,1,0);
- }
- if (s->verbosity >= 3)
- VPrintf1( "selectors %d, ", s->numZ-nBytes );
-
- /*--- Now the coding tables. ---*/
- nBytes = s->numZ;
-
- for (t = 0; t < nGroups; t++) {
- Int32 curr = s->len[t][0];
- bsW ( s, 5, curr );
- for (i = 0; i < alphaSize; i++) {
- while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ };
- while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ };
- bsW ( s, 1, 0 );
- }
- }
-
- if (s->verbosity >= 3)
- VPrintf1 ( "code lengths %d, ", s->numZ-nBytes );
-
- /*--- And finally, the block data proper ---*/
- nBytes = s->numZ;
- selCtr = 0;
- gs = 0;
- while (True) {
- if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
- if (ge >= s->nMTF) ge = s->nMTF-1;
- AssertH ( s->selector[selCtr] < nGroups, 3006 );
-
- if (nGroups == 6 && 50 == ge-gs+1) {
- /*--- fast track the common case ---*/
- UInt16 mtfv_i;
- UChar* s_len_sel_selCtr
- = &(s->len[s->selector[selCtr]][0]);
- Int32* s_code_sel_selCtr
- = &(s->code[s->selector[selCtr]][0]);
-
-# define BZ_ITAH(nn) \
- mtfv_i = mtfv[gs+(nn)]; \
- bsW ( s, \
- s_len_sel_selCtr[mtfv_i], \
- s_code_sel_selCtr[mtfv_i] )
-
- BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4);
- BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9);
- BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
- BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
- BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
- BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
- BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
- BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
- BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
- BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
-
-# undef BZ_ITAH
-
- } else {
- /*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++) {
- bsW ( s,
- s->len [s->selector[selCtr]] [mtfv[i]],
- s->code [s->selector[selCtr]] [mtfv[i]] );
- }
- }
-
-
- gs = ge+1;
- selCtr++;
- }
- AssertH( selCtr == nSelectors, 3007 );
-
- if (s->verbosity >= 3)
- VPrintf1( "codes %d\n", s->numZ-nBytes );
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_compressBlock ( EState* s, Bool is_last_block )
-{
- if (s->nblock > 0) {
-
- BZ_FINALISE_CRC ( s->blockCRC );
- s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
- s->combinedCRC ^= s->blockCRC;
- if (s->blockNo > 1) s->numZ = 0;
-
- if (s->verbosity >= 2)
- VPrintf4( " block %d: crc = 0x%8x, "
- "combined CRC = 0x%8x, size = %d\n",
- s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
-
- BZ2_blockSort ( s );
- }
-
- s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
-
- /*-- If this is the first block, create the stream header. --*/
- if (s->blockNo == 1) {
- BZ2_bsInitWrite ( s );
- bsPutUChar ( s, 'B' );
- bsPutUChar ( s, 'Z' );
- bsPutUChar ( s, 'h' );
- bsPutUChar ( s, (UChar)('0' + s->blockSize100k) );
- }
-
- if (s->nblock > 0) {
-
- bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 );
- bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 );
- bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 );
-
- /*-- Now the block's CRC, so it is in a known place. --*/
- bsPutUInt32 ( s, s->blockCRC );
-
- /*--
- Now a single bit indicating (non-)randomisation.
- As of version 0.9.5, we use a better sorting algorithm
- which makes randomisation unnecessary. So always set
- the randomised bit to 'no'. Of course, the decoder
- still needs to be able to handle randomised blocks
- so as to maintain backwards compatibility with
- older versions of bzip2.
- --*/
- bsW(s,1,0);
-
- bsW ( s, 24, s->origPtr );
- generateMTFValues ( s );
- sendMTFValues ( s );
- }
-
-
- /*-- If this is the last block, add the stream trailer. --*/
- if (is_last_block) {
-
- bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
- bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
- bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
- bsPutUInt32 ( s, s->combinedCRC );
- if (s->verbosity >= 2)
- VPrintf1( " final combined CRC = 0x%x\n ", s->combinedCRC );
- bsFinishWrite ( s );
- }
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end compress.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/crctable.c b/mdk-stage1/bzlib/crctable.c
deleted file mode 100644
index c0ea3f769..000000000
--- a/mdk-stage1/bzlib/crctable.c
+++ /dev/null
@@ -1,148 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Table for doing CRCs ---*/
-/*--- crctable.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "bzlib_private.h"
-
-/*--
- I think this is an implementation of the AUTODIN-II,
- Ethernet & FDDI 32-bit CRC standard. Vaguely derived
- from code by Rob Warnock, in Section 51 of the
- comp.compression FAQ.
---*/
-
-UInt32 BZ2_crc32Table[256] = {
-
- /*-- Ugly, innit? --*/
-
- 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
- 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
- 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
- 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
- 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
- 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
- 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
- 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
- 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
- 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
- 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
- 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
- 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
- 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
- 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
- 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
- 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
- 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
- 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
- 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
- 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
- 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
- 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
- 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
- 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
- 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
- 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
- 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
- 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
- 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
- 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
- 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
- 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
- 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
- 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
- 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
- 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
- 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
- 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
- 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
- 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
- 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
- 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
- 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
- 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
- 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
- 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
- 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
- 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
- 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
- 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
- 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
- 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
- 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
- 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
- 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
- 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
- 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
- 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
- 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
- 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
- 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
- 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
- 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end crctable.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/decompress.c b/mdk-stage1/bzlib/decompress.c
deleted file mode 100644
index 65cf75d8f..000000000
--- a/mdk-stage1/bzlib/decompress.c
+++ /dev/null
@@ -1,664 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Decompression machinery ---*/
-/*--- decompress.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-static
-void makeMaps_d ( DState* s )
-{
- Int32 i;
- s->nInUse = 0;
- for (i = 0; i < 256; i++)
- if (s->inUse[i]) {
- s->seqToUnseq[s->nInUse] = i;
- s->nInUse++;
- }
-}
-
-
-/*---------------------------------------------------*/
-#define RETURN(rrr) \
- { retVal = rrr; goto save_state_and_return; };
-
-#define GET_BITS(lll,vvv,nnn) \
- case lll: s->state = lll; \
- while (True) { \
- if (s->bsLive >= nnn) { \
- UInt32 v; \
- v = (s->bsBuff >> \
- (s->bsLive-nnn)) & ((1 << nnn)-1); \
- s->bsLive -= nnn; \
- vvv = v; \
- break; \
- } \
- if (s->strm->avail_in == 0) RETURN(BZ_OK); \
- s->bsBuff \
- = (s->bsBuff << 8) | \
- ((UInt32) \
- (*((UChar*)(s->strm->next_in)))); \
- s->bsLive += 8; \
- s->strm->next_in++; \
- s->strm->avail_in--; \
- s->strm->total_in_lo32++; \
- if (s->strm->total_in_lo32 == 0) \
- s->strm->total_in_hi32++; \
- }
-
-#define GET_UCHAR(lll,uuu) \
- GET_BITS(lll,uuu,8)
-
-#define GET_BIT(lll,uuu) \
- GET_BITS(lll,uuu,1)
-
-/*---------------------------------------------------*/
-#define GET_MTF_VAL(label1,label2,lval) \
-{ \
- if (groupPos == 0) { \
- groupNo++; \
- if (groupNo >= nSelectors) \
- RETURN(BZ_DATA_ERROR); \
- groupPos = BZ_G_SIZE; \
- gSel = s->selector[groupNo]; \
- gMinlen = s->minLens[gSel]; \
- gLimit = &(s->limit[gSel][0]); \
- gPerm = &(s->perm[gSel][0]); \
- gBase = &(s->base[gSel][0]); \
- } \
- groupPos--; \
- zn = gMinlen; \
- GET_BITS(label1, zvec, zn); \
- while (1) { \
- if (zn > 20 /* the longest code */) \
- RETURN(BZ_DATA_ERROR); \
- if (zvec <= gLimit[zn]) break; \
- zn++; \
- GET_BIT(label2, zj); \
- zvec = (zvec << 1) | zj; \
- }; \
- if (zvec - gBase[zn] < 0 \
- || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \
- RETURN(BZ_DATA_ERROR); \
- lval = gPerm[zvec - gBase[zn]]; \
-}
-
-
-/*---------------------------------------------------*/
-Int32 BZ2_decompress ( DState* s )
-{
- UChar uc;
- Int32 retVal;
- Int32 minLen, maxLen;
- bz_stream* strm = s->strm;
-
- /* stuff that needs to be saved/restored */
- Int32 i;
- Int32 j;
- Int32 t;
- Int32 alphaSize;
- Int32 nGroups;
- Int32 nSelectors;
- Int32 EOB;
- Int32 groupNo;
- Int32 groupPos;
- Int32 nextSym;
- Int32 nblockMAX;
- Int32 nblock;
- Int32 es;
- Int32 N;
- Int32 curr;
- Int32 zt;
- Int32 zn;
- Int32 zvec;
- Int32 zj;
- Int32 gSel;
- Int32 gMinlen;
- Int32* gLimit;
- Int32* gBase;
- Int32* gPerm;
-
- if (s->state == BZ_X_MAGIC_1) {
- /*initialise the save area*/
- s->save_i = 0;
- s->save_j = 0;
- s->save_t = 0;
- s->save_alphaSize = 0;
- s->save_nGroups = 0;
- s->save_nSelectors = 0;
- s->save_EOB = 0;
- s->save_groupNo = 0;
- s->save_groupPos = 0;
- s->save_nextSym = 0;
- s->save_nblockMAX = 0;
- s->save_nblock = 0;
- s->save_es = 0;
- s->save_N = 0;
- s->save_curr = 0;
- s->save_zt = 0;
- s->save_zn = 0;
- s->save_zvec = 0;
- s->save_zj = 0;
- s->save_gSel = 0;
- s->save_gMinlen = 0;
- s->save_gLimit = NULL;
- s->save_gBase = NULL;
- s->save_gPerm = NULL;
- }
-
- /*restore from the save area*/
- i = s->save_i;
- j = s->save_j;
- t = s->save_t;
- alphaSize = s->save_alphaSize;
- nGroups = s->save_nGroups;
- nSelectors = s->save_nSelectors;
- EOB = s->save_EOB;
- groupNo = s->save_groupNo;
- groupPos = s->save_groupPos;
- nextSym = s->save_nextSym;
- nblockMAX = s->save_nblockMAX;
- nblock = s->save_nblock;
- es = s->save_es;
- N = s->save_N;
- curr = s->save_curr;
- zt = s->save_zt;
- zn = s->save_zn;
- zvec = s->save_zvec;
- zj = s->save_zj;
- gSel = s->save_gSel;
- gMinlen = s->save_gMinlen;
- gLimit = s->save_gLimit;
- gBase = s->save_gBase;
- gPerm = s->save_gPerm;
-
- retVal = BZ_OK;
-
- switch (s->state) {
-
- GET_UCHAR(BZ_X_MAGIC_1, uc);
- if (uc != 'B') RETURN(BZ_DATA_ERROR_MAGIC);
-
- GET_UCHAR(BZ_X_MAGIC_2, uc);
- if (uc != 'Z') RETURN(BZ_DATA_ERROR_MAGIC);
-
- GET_UCHAR(BZ_X_MAGIC_3, uc)
- if (uc != 'h') RETURN(BZ_DATA_ERROR_MAGIC);
-
- GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
- if (s->blockSize100k < '1' ||
- s->blockSize100k > '9') RETURN(BZ_DATA_ERROR_MAGIC);
- s->blockSize100k -= '0';
-
- if (s->smallDecompress) {
- s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
- s->ll4 = BZALLOC(
- ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
- );
- if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
- } else {
- s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
- if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
- }
-
- GET_UCHAR(BZ_X_BLKHDR_1, uc);
-
- if (uc == 0x17) goto endhdr_2;
- if (uc != 0x31) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_2, uc);
- if (uc != 0x41) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_3, uc);
- if (uc != 0x59) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_4, uc);
- if (uc != 0x26) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_5, uc);
- if (uc != 0x53) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_6, uc);
- if (uc != 0x59) RETURN(BZ_DATA_ERROR);
-
- s->currBlockNo++;
- if (s->verbosity >= 2)
- VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
-
- s->storedBlockCRC = 0;
- GET_UCHAR(BZ_X_BCRC_1, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_BCRC_2, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_BCRC_3, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_BCRC_4, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-
- GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
-
- s->origPtr = 0;
- GET_UCHAR(BZ_X_ORIGPTR_1, uc);
- s->origPtr = (s->origPtr << 8) | ((Int32)uc);
- GET_UCHAR(BZ_X_ORIGPTR_2, uc);
- s->origPtr = (s->origPtr << 8) | ((Int32)uc);
- GET_UCHAR(BZ_X_ORIGPTR_3, uc);
- s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-
- if (s->origPtr < 0)
- RETURN(BZ_DATA_ERROR);
- if (s->origPtr > 10 + 100000*s->blockSize100k)
- RETURN(BZ_DATA_ERROR);
-
- /*--- Receive the mapping table ---*/
- for (i = 0; i < 16; i++) {
- GET_BIT(BZ_X_MAPPING_1, uc);
- if (uc == 1)
- s->inUse16[i] = True; else
- s->inUse16[i] = False;
- }
-
- for (i = 0; i < 256; i++) s->inUse[i] = False;
-
- for (i = 0; i < 16; i++)
- if (s->inUse16[i])
- for (j = 0; j < 16; j++) {
- GET_BIT(BZ_X_MAPPING_2, uc);
- if (uc == 1) s->inUse[i * 16 + j] = True;
- }
- makeMaps_d ( s );
- if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
- alphaSize = s->nInUse+2;
-
- /*--- Now the selectors ---*/
- GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
- if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
- GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
- if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
- for (i = 0; i < nSelectors; i++) {
- j = 0;
- while (True) {
- GET_BIT(BZ_X_SELECTOR_3, uc);
- if (uc == 0) break;
- j++;
- if (j >= nGroups) RETURN(BZ_DATA_ERROR);
- }
- s->selectorMtf[i] = j;
- }
-
- /*--- Undo the MTF values for the selectors. ---*/
- {
- UChar pos[BZ_N_GROUPS], tmp, v;
- for (v = 0; v < nGroups; v++) pos[v] = v;
-
- for (i = 0; i < nSelectors; i++) {
- v = s->selectorMtf[i];
- tmp = pos[v];
- while (v > 0) { pos[v] = pos[v-1]; v--; }
- pos[0] = tmp;
- s->selector[i] = tmp;
- }
- }
-
- /*--- Now the coding tables ---*/
- for (t = 0; t < nGroups; t++) {
- GET_BITS(BZ_X_CODING_1, curr, 5);
- for (i = 0; i < alphaSize; i++) {
- while (True) {
- if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
- GET_BIT(BZ_X_CODING_2, uc);
- if (uc == 0) break;
- GET_BIT(BZ_X_CODING_3, uc);
- if (uc == 0) curr++; else curr--;
- }
- s->len[t][i] = curr;
- }
- }
-
- /*--- Create the Huffman decoding tables ---*/
- for (t = 0; t < nGroups; t++) {
- minLen = 32;
- maxLen = 0;
- for (i = 0; i < alphaSize; i++) {
- if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
- if (s->len[t][i] < minLen) minLen = s->len[t][i];
- }
- BZ2_hbCreateDecodeTables (
- &(s->limit[t][0]),
- &(s->base[t][0]),
- &(s->perm[t][0]),
- &(s->len[t][0]),
- minLen, maxLen, alphaSize
- );
- s->minLens[t] = minLen;
- }
-
- /*--- Now the MTF values ---*/
-
- EOB = s->nInUse+1;
- nblockMAX = 100000 * s->blockSize100k;
- groupNo = -1;
- groupPos = 0;
-
- for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
-
- /*-- MTF init --*/
- {
- Int32 ii, jj, kk;
- kk = MTFA_SIZE-1;
- for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
- for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
- s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
- kk--;
- }
- s->mtfbase[ii] = kk + 1;
- }
- }
- /*-- end MTF init --*/
-
- nblock = 0;
- GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
-
- while (True) {
-
- if (nextSym == EOB) break;
-
- if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
-
- es = -1;
- N = 1;
- do {
- if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
- if (nextSym == BZ_RUNB) es = es + (1+1) * N;
- N = N * 2;
- GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
- }
- while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
-
- es++;
- uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
- s->unzftab[uc] += es;
-
- if (s->smallDecompress)
- while (es > 0) {
- if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
- s->ll16[nblock] = (UInt16)uc;
- nblock++;
- es--;
- }
- else
- while (es > 0) {
- if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
- s->tt[nblock] = (UInt32)uc;
- nblock++;
- es--;
- };
-
- continue;
-
- } else {
-
- if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-
- /*-- uc = MTF ( nextSym-1 ) --*/
- {
- Int32 ii, jj, kk, pp, lno, off;
- UInt32 nn;
- nn = (UInt32)(nextSym - 1);
-
- if (nn < MTFL_SIZE) {
- /* avoid general-case expense */
- pp = s->mtfbase[0];
- uc = s->mtfa[pp+nn];
- while (nn > 3) {
- Int32 z = pp+nn;
- s->mtfa[(z) ] = s->mtfa[(z)-1];
- s->mtfa[(z)-1] = s->mtfa[(z)-2];
- s->mtfa[(z)-2] = s->mtfa[(z)-3];
- s->mtfa[(z)-3] = s->mtfa[(z)-4];
- nn -= 4;
- }
- while (nn > 0) {
- s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
- };
- s->mtfa[pp] = uc;
- } else {
- /* general case */
- lno = nn / MTFL_SIZE;
- off = nn % MTFL_SIZE;
- pp = s->mtfbase[lno] + off;
- uc = s->mtfa[pp];
- while (pp > s->mtfbase[lno]) {
- s->mtfa[pp] = s->mtfa[pp-1]; pp--;
- };
- s->mtfbase[lno]++;
- while (lno > 0) {
- s->mtfbase[lno]--;
- s->mtfa[s->mtfbase[lno]]
- = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
- lno--;
- }
- s->mtfbase[0]--;
- s->mtfa[s->mtfbase[0]] = uc;
- if (s->mtfbase[0] == 0) {
- kk = MTFA_SIZE-1;
- for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
- for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
- s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
- kk--;
- }
- s->mtfbase[ii] = kk + 1;
- }
- }
- }
- }
- /*-- end uc = MTF ( nextSym-1 ) --*/
-
- s->unzftab[s->seqToUnseq[uc]]++;
- if (s->smallDecompress)
- s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
- s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
- nblock++;
-
- GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
- continue;
- }
- }
-
- /* Now we know what nblock is, we can do a better sanity
- check on s->origPtr.
- */
- if (s->origPtr < 0 || s->origPtr >= nblock)
- RETURN(BZ_DATA_ERROR);
-
- s->state_out_len = 0;
- s->state_out_ch = 0;
- BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
- s->state = BZ_X_OUTPUT;
- if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
-
- /*-- Set up cftab to facilitate generation of T^(-1) --*/
- s->cftab[0] = 0;
- for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
- for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
-
- if (s->smallDecompress) {
-
- /*-- Make a copy of cftab, used in generation of T --*/
- for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
-
- /*-- compute the T vector --*/
- for (i = 0; i < nblock; i++) {
- uc = (UChar)(s->ll16[i]);
- SET_LL(i, s->cftabCopy[uc]);
- s->cftabCopy[uc]++;
- }
-
- /*-- Compute T^(-1) by pointer reversal on T --*/
- i = s->origPtr;
- j = GET_LL(i);
- do {
- Int32 tmp = GET_LL(j);
- SET_LL(j, i);
- i = j;
- j = tmp;
- }
- while (i != s->origPtr);
-
- s->tPos = s->origPtr;
- s->nblock_used = 0;
- if (s->blockRandomised) {
- BZ_RAND_INIT_MASK;
- BZ_GET_SMALL(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
- } else {
- BZ_GET_SMALL(s->k0); s->nblock_used++;
- }
-
- } else {
-
- /*-- compute the T^(-1) vector --*/
- for (i = 0; i < nblock; i++) {
- uc = (UChar)(s->tt[i] & 0xff);
- s->tt[s->cftab[uc]] |= (i << 8);
- s->cftab[uc]++;
- }
-
- s->tPos = s->tt[s->origPtr] >> 8;
- s->nblock_used = 0;
- if (s->blockRandomised) {
- BZ_RAND_INIT_MASK;
- BZ_GET_FAST(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
- } else {
- BZ_GET_FAST(s->k0); s->nblock_used++;
- }
-
- }
-
- RETURN(BZ_OK);
-
-
-
- endhdr_2:
-
- GET_UCHAR(BZ_X_ENDHDR_2, uc);
- if (uc != 0x72) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_3, uc);
- if (uc != 0x45) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_4, uc);
- if (uc != 0x38) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_5, uc);
- if (uc != 0x50) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_6, uc);
- if (uc != 0x90) RETURN(BZ_DATA_ERROR);
-
- s->storedCombinedCRC = 0;
- GET_UCHAR(BZ_X_CCRC_1, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_CCRC_2, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_CCRC_3, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_CCRC_4, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-
- s->state = BZ_X_IDLE;
- RETURN(BZ_STREAM_END);
-
- default: AssertH ( False, 4001 );
- }
-
- AssertH ( False, 4002 );
-
- save_state_and_return:
-
- s->save_i = i;
- s->save_j = j;
- s->save_t = t;
- s->save_alphaSize = alphaSize;
- s->save_nGroups = nGroups;
- s->save_nSelectors = nSelectors;
- s->save_EOB = EOB;
- s->save_groupNo = groupNo;
- s->save_groupPos = groupPos;
- s->save_nextSym = nextSym;
- s->save_nblockMAX = nblockMAX;
- s->save_nblock = nblock;
- s->save_es = es;
- s->save_N = N;
- s->save_curr = curr;
- s->save_zt = zt;
- s->save_zn = zn;
- s->save_zvec = zvec;
- s->save_zj = zj;
- s->save_gSel = gSel;
- s->save_gMinlen = gMinlen;
- s->save_gLimit = gLimit;
- s->save_gBase = gBase;
- s->save_gPerm = gPerm;
-
- return retVal;
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end decompress.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/huffman.c b/mdk-stage1/bzlib/huffman.c
deleted file mode 100644
index 8994f0bb9..000000000
--- a/mdk-stage1/bzlib/huffman.c
+++ /dev/null
@@ -1,232 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Huffman coding low-level stuff ---*/
-/*--- huffman.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------------*/
-#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
-#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
-#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
-
-#define ADDWEIGHTS(zw1,zw2) \
- (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
- (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
-
-#define UPHEAP(z) \
-{ \
- Int32 zz, tmp; \
- zz = z; tmp = heap[zz]; \
- while (weight[tmp] < weight[heap[zz >> 1]]) { \
- heap[zz] = heap[zz >> 1]; \
- zz >>= 1; \
- } \
- heap[zz] = tmp; \
-}
-
-#define DOWNHEAP(z) \
-{ \
- Int32 zz, yy, tmp; \
- zz = z; tmp = heap[zz]; \
- while (True) { \
- yy = zz << 1; \
- if (yy > nHeap) break; \
- if (yy < nHeap && \
- weight[heap[yy+1]] < weight[heap[yy]]) \
- yy++; \
- if (weight[tmp] < weight[heap[yy]]) break; \
- heap[zz] = heap[yy]; \
- zz = yy; \
- } \
- heap[zz] = tmp; \
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbMakeCodeLengths ( UChar *len,
- Int32 *freq,
- Int32 alphaSize,
- Int32 maxLen )
-{
- /*--
- Nodes and heap entries run from 1. Entry 0
- for both the heap and nodes is a sentinel.
- --*/
- Int32 nNodes, nHeap, n1, n2, i, j, k;
- Bool tooLong;
-
- Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
- Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
- Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
-
- for (i = 0; i < alphaSize; i++)
- weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
-
- while (True) {
-
- nNodes = alphaSize;
- nHeap = 0;
-
- heap[0] = 0;
- weight[0] = 0;
- parent[0] = -2;
-
- for (i = 1; i <= alphaSize; i++) {
- parent[i] = -1;
- nHeap++;
- heap[nHeap] = i;
- UPHEAP(nHeap);
- }
-
- AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
-
- while (nHeap > 1) {
- n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
- n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
- nNodes++;
- parent[n1] = parent[n2] = nNodes;
- weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
- parent[nNodes] = -1;
- nHeap++;
- heap[nHeap] = nNodes;
- UPHEAP(nHeap);
- }
-
- AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
-
- tooLong = False;
- for (i = 1; i <= alphaSize; i++) {
- j = 0;
- k = i;
- while (parent[k] >= 0) { k = parent[k]; j++; }
- len[i-1] = j;
- if (j > maxLen) tooLong = True;
- }
-
- if (! tooLong) break;
-
- for (i = 1; i < alphaSize; i++) {
- j = weight[i] >> 8;
- j = 1 + (j / 2);
- weight[i] = j << 8;
- }
- }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbAssignCodes ( Int32 *code,
- UChar *length,
- Int32 minLen,
- Int32 maxLen,
- Int32 alphaSize )
-{
- Int32 n, vec, i;
-
- vec = 0;
- for (n = minLen; n <= maxLen; n++) {
- for (i = 0; i < alphaSize; i++)
- if (length[i] == n) { code[i] = vec; vec++; };
- vec <<= 1;
- }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbCreateDecodeTables ( Int32 *limit,
- Int32 *base,
- Int32 *perm,
- UChar *length,
- Int32 minLen,
- Int32 maxLen,
- Int32 alphaSize )
-{
- Int32 pp, i, j, vec;
-
- pp = 0;
- for (i = minLen; i <= maxLen; i++)
- for (j = 0; j < alphaSize; j++)
- if (length[j] == i) { perm[pp] = j; pp++; };
-
- for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
- for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
-
- for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
-
- for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
- vec = 0;
-
- for (i = minLen; i <= maxLen; i++) {
- vec += (base[i+1] - base[i]);
- limit[i] = vec-1;
- vec <<= 1;
- }
- for (i = minLen + 1; i <= maxLen; i++)
- base[i] = ((limit[i-1] + 1) << 1) - base[i];
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end huffman.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/bzlib/randtable.c b/mdk-stage1/bzlib/randtable.c
deleted file mode 100644
index a1fc82cfb..000000000
--- a/mdk-stage1/bzlib/randtable.c
+++ /dev/null
@@ -1,128 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Table for randomising repetitive blocks ---*/
-/*--- randtable.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------*/
-Int32 BZ2_rNums[512] = {
- 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
- 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
- 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
- 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
- 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
- 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
- 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
- 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
- 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
- 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
- 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
- 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
- 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
- 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
- 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
- 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
- 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
- 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
- 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
- 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
- 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
- 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
- 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
- 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
- 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
- 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
- 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
- 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
- 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
- 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
- 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
- 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
- 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
- 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
- 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
- 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
- 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
- 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
- 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
- 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
- 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
- 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
- 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
- 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
- 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
- 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
- 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
- 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
- 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
- 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
- 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
- 936, 638
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end randtable.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/mdk-stage1/cdrom.c b/mdk-stage1/cdrom.c
deleted file mode 100644
index ef762a3c3..000000000
--- a/mdk-stage1/cdrom.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/mount.h>
-#include "stage1.h"
-#include "frontend.h"
-#include "modules.h"
-#include "probing.h"
-#include "log.h"
-#include "mount.h"
-
-#include "cdrom.h"
-
-
-static int mount_that_cd_device(char * dev_name)
-{
- char device_fullname[50];
-
- strcpy(device_fullname, "/dev/");
- strcat(device_fullname, dev_name);
-
-#ifdef MANDRAKE_MOVE
- return my_mount(device_fullname, IMAGE_LOCATION, "supermount", 0);
-#else
- return my_mount(device_fullname, IMAGE_LOCATION, "iso9660", 0);
-#endif
-}
-
-
-static enum return_type try_with_device(char * dev_name, char * dev_model);
-
-static enum return_type do_with_device(char * dev_name, char * dev_model)
-{
- if (!image_has_stage2()) {
- enum return_type results;
- umount(IMAGE_LOCATION);
- results = ask_yes_no("That CDROM disc does not seem to be a " DISTRIB_NAME " Installation CDROM.\nRetry with another disc?");
- if (results == RETURN_OK)
- return try_with_device(dev_name, dev_model);
- return results;
- }
-
- log_message("found a " DISTRIB_NAME " CDROM, good news!");
-
-#ifndef MANDRAKE_MOVE
- may_load_clp();
-
- if (!KEEP_MOUNTED)
- /* in rescue mode, we don't need the media anymore */
- umount(IMAGE_LOCATION);
-#endif
-
- add_to_env("METHOD", "cdrom");
- return RETURN_OK;
-}
-
-static enum return_type try_with_device(char * dev_name, char * dev_model)
-{
- wait_message("Trying to access a CDROM disc (drive %s)", dev_model);
-
- if (mount_that_cd_device(dev_name) == -1) {
- enum return_type results;
- char msg[500];
- unset_automatic(); /* we are in a fallback mode */
- remove_wait_message();
-
- snprintf(msg, sizeof(msg), "I can't access a " DISTRIB_NAME " Installation disc in your CDROM drive (%s).\nRetry?", dev_model);
- results = ask_yes_no(msg);
- if (results == RETURN_OK)
- return try_with_device(dev_name, dev_model);
- return results;
- }
- remove_wait_message();
-
- return do_with_device(dev_name, dev_model);
-}
-
-int try_automatic(char ** medias, char ** medias_models)
-{
- static char * already_tried[50] = { NULL };
- char ** model = medias_models;
- char ** ptr = medias;
- int i = 0;
- while (ptr && *ptr) {
- char ** p;
- for (p = already_tried; p && *p; p++)
- if (streq(*p, *ptr))
- goto try_automatic_already_tried;
- *p = strdup(*ptr);
- *(p+1) = NULL;
-
- wait_message("Trying to access " DISTRIB_NAME " CDROM disc (drive %s)", *model);
- if (mount_that_cd_device(*ptr) != -1) {
- if (image_has_stage2()) {
- remove_wait_message();
- return i;
- }
- else
- umount(IMAGE_LOCATION);
- }
- remove_wait_message();
-
- try_automatic_already_tried:
- ptr++;
- model++;
- i++;
- }
- return -1;
-}
-
-enum return_type cdrom_prepare(void)
-{
- char ** medias, ** ptr, ** medias_models;
- char * choice;
- int i, count = 0;
- enum return_type results;
- static int already_probed_ide_generic = 0;
-
- my_insmod("ide-cd", ANY_DRIVER_TYPE, NULL, 0);
-
- if (IS_AUTOMATIC) {
- get_medias(CDROM, &medias, &medias_models, BUS_IDE);
- if ((i = try_automatic(medias, medias_models)) != -1)
- return do_with_device(medias[i], medias_models[i]);
-
- my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL, 0);
- get_medias(CDROM, &medias, &medias_models, BUS_SCSI);
- if ((i = try_automatic(medias, medias_models)) != -1)
- return do_with_device(medias[i], medias_models[i]);
-
- get_medias(CDROM, &medias, &medias_models, BUS_USB);
- if ((i = try_automatic(medias, medias_models)) != -1)
- return do_with_device(medias[i], medias_models[i]);
-
- unset_automatic();
- } else
- my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL, 0);
-
-
- get_medias(CDROM, &medias, &medias_models, BUS_ANY);
- ptr = medias;
- while (ptr && *ptr) {
- count++;
- ptr++;
- }
-
- if (count == 0) {
- if (!already_probed_ide_generic) {
- already_probed_ide_generic = 1;
- my_insmod("ide-generic", ANY_DRIVER_TYPE, NULL, 0);
- return cdrom_prepare();
- }
- stg1_error_message("No CDROM device found.");
- i = ask_insmod(SCSI_ADAPTERS);
- if (i == RETURN_BACK)
- return RETURN_BACK;
- return cdrom_prepare();
- }
-
- if (count == 1) {
- results = try_with_device(*medias, *medias_models);
- if (results == RETURN_OK)
- return RETURN_OK;
- i = ask_insmod(SCSI_ADAPTERS);
- if (i == RETURN_BACK)
- return RETURN_BACK;
- return cdrom_prepare();
- }
-
- results = ask_from_list_comments("Please choose the CDROM drive to use for the installation.", medias, medias_models, &choice);
- if (results == RETURN_OK) {
- char ** model = medias_models;
- ptr = medias;
- while (ptr && *ptr && model && *model) {
- if (!strcmp(*ptr, choice))
- break;
- ptr++;
- model++;
- }
- results = try_with_device(choice, *model);
- } else
- return results;
-
- if (results == RETURN_OK)
- return RETURN_OK;
- if (results == RETURN_BACK)
- return cdrom_prepare();
-
- i = ask_insmod(SCSI_ADAPTERS);
- if (i == RETURN_BACK)
- return RETURN_BACK;
- return cdrom_prepare();
-}
diff --git a/mdk-stage1/cdrom.h b/mdk-stage1/cdrom.h
deleted file mode 100644
index c9ebc78aa..000000000
--- a/mdk-stage1/cdrom.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef _CDROM_H_
-#define _CDROM_H_
-
-#include "stage1.h"
-
-enum return_type cdrom_prepare(void);
-
-#endif
diff --git a/mdk-stage1/config-stage1.h b/mdk-stage1/config-stage1.h
deleted file mode 100644
index 3fd918ec7..000000000
--- a/mdk-stage1/config-stage1.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _CONFIG_STAGE1_H_
-#define _CONFIG_STAGE1_H_
-
-#ifdef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif
-#define _GNU_SOURCE 1
-
-
-/* If we have more than that amount of memory (in Mbytes), we assume we can load the second stage as a ramdisk */
-#define MEM_LIMIT_DRAKX 68
-/* If we have more than that amount of memory (in Mbytes), we preload the second stage as a ramdisk */
-#define MEM_LIMIT_DRAKX_PRELOAD 100
-
-/* If we have more than that amount of memory (in Mbytes), we assume we can load the rescue as a ramdisk */
-#define MEM_LIMIT_RESCUE 40
-/* If we have more than that amount of memory (in Mbytes), we preload the rescue as a ramdisk */
-#define MEM_LIMIT_RESCUE_PRELOAD 100
-
-
-#define SLASH_LOCATION "/sysroot"
-
-#ifdef MANDRAKE_MOVE
-
-#define MEM_LIMIT_MOVE 120
-
-#undef DISTRIB_NAME
-#define DISTRIB_NAME "Mandrakemove"
-#undef DISTRIB_DESCR
-#define DISTRIB_DESCR DISTRIB_NAME
-
-#define IMAGE_LOCATION_DIR SLASH_LOCATION "/"
-#define IMAGE_LOCATION_REL "cdrom"
-#define IMAGE_LOCATION IMAGE_LOCATION_DIR IMAGE_LOCATION_REL
-
-#define CLP_LOCATION IMAGE_LOCATION
-
-#define STAGE2_LOCATION_ROOTED "/image"
-#define STAGE2_LOCATION SLASH_LOCATION STAGE2_LOCATION_ROOTED
-
-#define BOOT_LOCATION SLASH_LOCATION "/image_boot"
-#define ALWAYS_LOCATION SLASH_LOCATION "/image_always"
-#define TOTEM_LOCATION SLASH_LOCATION "/image_totem"
-
-#else
-
-#define LIVE_LOCATION_REL "install/stage2/live/"
-#define CLP_LOCATION_REL "install/stage2/"
-#define CLP_STAGE2_NAME "mdkinst.clp"
-#define CLP_RESCUE_NAME "rescue.clp"
-#define CLP_NAME(prefix) (IS_RESCUE ? prefix CLP_RESCUE_NAME : prefix CLP_STAGE2_NAME)
-#define CLP_FILE_REL(prefix) CLP_NAME(prefix CLP_LOCATION_REL)
-
-/* the remote media is mounted in
- - IMAGE_LOCATION_DIR "nfsimage", and IMAGE_LOCATION is a symlink image -> nfsimage/mdk/mirror/dir
- - IMAGE_LOCATION_DIR "hdimage", and IMAGE_LOCATION is a symlink image -> hdimage/mdk/mirror/dir
- - directly in IMAGE_LOCATION (for cdroms and .iso images)
- */
-#define IMAGE_LOCATION_DIR SLASH_LOCATION "/tmp/"
-#define IMAGE_LOCATION_REL "image"
-#define IMAGE_LOCATION IMAGE_LOCATION_DIR IMAGE_LOCATION_REL
-
-#define CLP_LOCATION IMAGE_LOCATION "/" CLP_LOCATION_REL
-
-/* - if we use a clp : STAGE2_LOCATION is a the mount point
- - if we use the live: STAGE2_LOCATION is a relative symlink to IMAGE_LOCATION_REL/install/stage2/live
-*/
-#define STAGE2_LOCATION_ROOTED "/tmp/stage2"
-#define STAGE2_LOCATION SLASH_LOCATION STAGE2_LOCATION_ROOTED
-
-#endif
-
-
-/* user-definable (in Makefile): DISABLE_NETWORK, DISABLE_DISK, DISABLE_CDROM, DISABLE_PCMCIA */
-
-
-/* some factorizing for disabling more features */
-
-#ifdef DISABLE_DISK
-#ifdef DISABLE_CDROM
-#define DISABLE_MEDIAS
-#endif
-#endif
-
-/* path to mirror list for net install */
-#ifndef DISABLE_NETWORK
-#define MIRRORLIST_HOST "www.mandrivalinux.com"
-#define MIRRORLIST_PATH "/mirrorsfull.list"
-#endif
-
-#endif
diff --git a/mdk-stage1/dhcp.c b/mdk-stage1/dhcp.c
deleted file mode 100644
index f5de6543e..000000000
--- a/mdk-stage1/dhcp.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-/*
- * Portions from GRUB -- GRand Unified Bootloader
- * Copyright (C) 2000 Free Software Foundation, Inc.
- */
-
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <net/route.h>
-#include <errno.h>
-#include <net/ethernet.h>
-#include <netinet/ip.h>
-#include <netinet/udp.h>
-#include <sys/time.h>
-#include <time.h>
-#include <fcntl.h>
-#include <sys/poll.h>
-
-#include "stage1.h"
-#include "log.h"
-#include "network.h"
-#include "frontend.h"
-#include "automatic.h"
-
-#include "dhcp.h"
-
-
-typedef int bp_int32;
-typedef short bp_int16;
-
-#define BOOTP_OPTION_NETMASK 1
-#define BOOTP_OPTION_GATEWAY 3
-#define BOOTP_OPTION_DNS 6
-#define BOOTP_OPTION_HOSTNAME 12
-#define BOOTP_OPTION_DOMAIN 15
-#define BOOTP_OPTION_BROADCAST 28
-
-#define DHCP_OPTION_REQADDR 50
-#define DHCP_OPTION_LEASE 51
-#define DHCP_OPTION_TYPE 53
-#define DHCP_OPTION_SERVER 54
-#define DHCP_OPTION_OPTIONREQ 55
-#define DHCP_OPTION_MAXSIZE 57
-
-#define DHCP_OPTION_CLIENT_IDENTIFIER 61
-
-#define BOOTP_CLIENT_PORT 68
-#define BOOTP_SERVER_PORT 67
-
-#define BOOTP_OPCODE_REQUEST 1
-#define BOOTP_OPCODE_REPLY 2
-
-#define DHCP_TYPE_DISCOVER 1
-#define DHCP_TYPE_OFFER 2
-#define DHCP_TYPE_REQUEST 3
-#define DHCP_TYPE_ACK 5
-#define DHCP_TYPE_RELEASE 7
-
-#define BOOTP_VENDOR_LENGTH 64
-#define DHCP_VENDOR_LENGTH 340
-
-struct bootp_request {
- char opcode;
- char hw;
- char hwlength;
- char hopcount;
- bp_int32 id;
- bp_int16 secs;
- bp_int16 flags;
- bp_int32 ciaddr, yiaddr, server_ip, bootp_gw_ip;
- char hwaddr[16];
- char servername[64];
- char bootfile[128];
- char vendor[DHCP_VENDOR_LENGTH];
-} ;
-
-static const char vendor_cookie[] = { 99, 130, 83, 99, 255 };
-
-
-static unsigned int verify_checksum(void * buf2, int length2)
-{
- unsigned int csum = 0;
- unsigned short * sp;
-
- for (sp = (unsigned short *) buf2; length2 > 0; (length2 -= 2), sp++)
- csum += *sp;
-
- while (csum >> 16)
- csum = (csum & 0xffff) + (csum >> 16);
-
- return (csum == 0xffff);
-}
-
-
-static int initial_setup_interface(char * device, int s) {
- struct sockaddr_in * addrp;
- struct ifreq req;
- struct rtentry route;
- int true = 1;
-
- addrp = (struct sockaddr_in *) &req.ifr_addr;
-
- strcpy(req.ifr_name, device);
- addrp->sin_family = AF_INET;
- addrp->sin_port = 0;
- memset(&addrp->sin_addr, 0, sizeof(addrp->sin_addr));
-
- req.ifr_flags = 0; /* take it down */
- if (ioctl(s, SIOCSIFFLAGS, &req)) {
- log_perror("SIOCSIFFLAGS (downing)");
- return -1;
- }
-
- addrp->sin_family = AF_INET;
- addrp->sin_addr.s_addr = htonl(0);
- if (ioctl(s, SIOCSIFADDR, &req)) {
- log_perror("SIOCSIFADDR");
- return -1;
- }
-
- req.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING;
- if (ioctl(s, SIOCSIFFLAGS, &req)) {
- log_perror("SIOCSIFFLAGS (upping)");
- return -1;
- }
-
- memset(&route, 0, sizeof(route));
- memcpy(&route.rt_gateway, addrp, sizeof(*addrp));
-
- addrp->sin_family = AF_INET;
- addrp->sin_port = 0;
- addrp->sin_addr.s_addr = INADDR_ANY;
- memcpy(&route.rt_dst, addrp, sizeof(*addrp));
- memcpy(&route.rt_genmask, addrp, sizeof(*addrp));
-
- route.rt_dev = device;
- route.rt_flags = RTF_UP;
- route.rt_metric = 0;
-
- if (ioctl(s, SIOCADDRT, &route)) {
- if (errno != EEXIST) {
- close(s);
- log_perror("SIOCADDRT");
- return -1;
- }
- }
-
- if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &true, sizeof(true))) {
- close(s);
- log_perror("setsockopt");
- return -1;
- }
-
- /* I need to sleep a bit in order for kernel to finish init of the
- network device; this would allow to not send further multiple
- dhcp requests when only one is needed. */
- wait_message("Bringing up networking...");
- sleep(2);
- remove_wait_message();
-
- return 0;
-}
-
-
-void set_missing_ip_info(struct interface_info * intf)
-{
- bp_int32 ipNum = *((bp_int32 *) &intf->ip);
- bp_int32 nmNum;
-
- if (intf->netmask.s_addr == 0)
- inet_aton(guess_netmask(inet_ntoa(intf->ip)), &intf->netmask);
-
- nmNum = *((bp_int32 *) &intf->netmask);
-
- if (intf->broadcast.s_addr == 0)
- *((bp_int32 *) &intf->broadcast) = (ipNum & nmNum) | ~(nmNum);
-
- if (intf->network.s_addr == 0)
- *((bp_int32 *) &intf->network) = ipNum & nmNum;
-}
-
-static void parse_reply(struct bootp_request * breq, struct interface_info * intf)
-{
- unsigned char * chptr;
- unsigned char option, length;
-
- if (breq->bootfile && strlen(breq->bootfile) > 0) {
- if (IS_NETAUTO)
- add_to_env("KICKSTART", breq->bootfile);
- else
- log_message("warning: ignoring `bootfile' DHCP server parameter, since `netauto' boot parameter was not given; reboot with `linux netauto' (and anymore useful boot parameters) if you want `bootfile' to be used as a `auto_inst.cfg.pl' stage2 configuration file");
- }
-
- memcpy(&intf->ip, &breq->yiaddr, 4);
-
- chptr = (unsigned char *) breq->vendor;
- chptr += 4;
- while (*chptr != 0xFF && (void *) chptr < (void *) breq->vendor + DHCP_VENDOR_LENGTH) {
- char tmp_str[500];
- option = *chptr++;
- if (!option)
- continue;
- length = *chptr++;
-
- switch (option) {
- case BOOTP_OPTION_DNS:
- memcpy(&dns_server, chptr, sizeof(dns_server));
- log_message("got dns %s", inet_ntoa(dns_server));
- if (length >= sizeof(dns_server)*2) {
- memcpy(&dns_server2, chptr+sizeof(dns_server), sizeof(dns_server2));
- log_message("got dns2 %s", inet_ntoa(dns_server2));
- }
- break;
-
- case BOOTP_OPTION_NETMASK:
- memcpy(&intf->netmask, chptr, sizeof(intf->netmask));
- log_message("got netmask %s", inet_ntoa(intf->netmask));
- break;
-
- case BOOTP_OPTION_DOMAIN:
- memcpy(tmp_str, chptr, length);
- tmp_str[length] = '\0';
- domain = strdup(tmp_str);
- log_message("got domain %s", domain);
- break;
-
- case BOOTP_OPTION_BROADCAST:
- memcpy(&intf->broadcast, chptr, sizeof(intf->broadcast));
- log_message("got broadcast %s", inet_ntoa(intf->broadcast));
- break;
-
- case BOOTP_OPTION_GATEWAY:
- memcpy(&gateway, chptr, sizeof(gateway));
- log_message("got gateway %s", inet_ntoa(gateway));
- break;
-
- }
-
- chptr += length;
- }
-
- set_missing_ip_info(intf);
-}
-
-
-static void init_vendor_codes(struct bootp_request * breq) {
- memcpy(breq->vendor, vendor_cookie, sizeof(vendor_cookie));
-}
-
-static char gen_hwaddr[16];
-
-static int prepare_request(struct bootp_request * breq, int sock, char * device)
-{
- struct ifreq req;
-
- memset(breq, 0, sizeof(*breq));
-
- breq->opcode = BOOTP_OPCODE_REQUEST;
-
- strcpy(req.ifr_name, device);
- if (ioctl(sock, SIOCGIFHWADDR, &req)) {
- log_perror("SIOCSIFHWADDR");
- return -1;
- }
-
- breq->hw = req.ifr_hwaddr.sa_family;
- breq->hwlength = IFHWADDRLEN;
- memcpy(breq->hwaddr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
- memcpy(gen_hwaddr, req.ifr_hwaddr.sa_data, IFHWADDRLEN);
-
- breq->hopcount = 0;
-
- init_vendor_codes(breq);
-
- return 0;
-}
-
-static int get_vendor_code(struct bootp_request * bresp, unsigned char option, void * data)
-{
- unsigned char * chptr;
- unsigned int length, theOption;
-
- chptr = (unsigned char*) bresp->vendor + 4;
- while (*chptr != 0xFF && *chptr != option) {
- theOption = *chptr++;
- if (!theOption)
- continue;
- length = *chptr++;
- chptr += length;
- }
-
- if (*chptr++ == 0xff)
- return 1;
-
- length = *chptr++;
- memcpy(data, chptr, length);
-
- return 0;
-}
-
-
-static unsigned long currticks(void)
-{
- struct timeval tv;
- unsigned long csecs;
- unsigned long ticks_per_csec, ticks_per_usec;
-
- /* Note: 18.2 ticks/sec. */
-
- gettimeofday (&tv, 0);
- csecs = tv.tv_sec / 10;
- ticks_per_csec = csecs * 182;
- ticks_per_usec = (((tv.tv_sec - csecs * 10) * 1000000 + tv.tv_usec) * 182 / 10000000);
- return ticks_per_csec + ticks_per_usec;
-}
-
-
-#define BACKOFF_LIMIT 7
-#define TICKS_PER_SEC 18
-#define MAX_ARP_RETRIES 7
-
-static void rfc951_sleep(int exp)
-{
- static long seed = 0;
- long q;
- unsigned long tmo;
-
- if (exp > BACKOFF_LIMIT)
- exp = BACKOFF_LIMIT;
-
- if (!seed)
- /* Initialize linear congruential generator. */
- seed = (currticks () + *(long *) &gen_hwaddr + ((short *) gen_hwaddr)[2]);
-
- /* Simplified version of the LCG given in Bruce Scheier's
- "Applied Cryptography". */
- q = seed / 53668;
- if ((seed = 40014 * (seed - 53668 * q) - 12211 * q) < 0)
- seed += 2147483563l;
-
- /* Compute mask. */
- for (tmo = 63; tmo <= 60 * TICKS_PER_SEC && --exp > 0; tmo = 2 * tmo + 1)
- ;
-
- /* Sleep. */
- log_message("<sleep>");
-
- for (tmo = (tmo & seed) + currticks (); currticks () < tmo;);
-}
-
-
-static int handle_transaction(int s, struct bootp_request * breq, struct bootp_request * bresp,
- struct sockaddr_in * server_addr, int dhcp_type)
-{
- struct pollfd polls;
- int i, j;
- int retry = 1;
- int sin;
- char eth_packet[ETH_FRAME_LEN];
- struct iphdr * ip_hdr;
- struct udphdr * udp_hdr;
- unsigned char type;
- unsigned long starttime;
- int timeout = 1;
-
- breq->id = starttime = currticks();
- breq->secs = 0;
-
- sin = socket(AF_PACKET, SOCK_DGRAM, ntohs(ETH_P_IP));
- if (sin < 0) {
- log_perror("af_packet socket");
- return -1;
- }
-
- while (retry <= MAX_ARP_RETRIES) {
- i = sizeof(*breq);
-
- if (sendto(s, breq, i, 0, (struct sockaddr *) server_addr, sizeof(*server_addr)) != i) {
- close(s);
- log_perror("sendto");
- return -1;
- }
-
- polls.fd = sin;
- polls.events = POLLIN;
-
- while (poll(&polls, 1, timeout*1000) == 1) {
-
- if ((j = recv(sin, eth_packet, sizeof(eth_packet), 0)) == -1) {
- log_perror("recv");
- continue;
- }
-
- /* We need to do some basic sanity checking of the header */
- if (j < (signed)(sizeof(*ip_hdr) + sizeof(*udp_hdr)))
- continue;
-
- ip_hdr = (void *) eth_packet;
- if (!verify_checksum(ip_hdr, sizeof(*ip_hdr)))
- continue;
-
- if (ntohs(ip_hdr->tot_len) > j)
- continue;
-
- j = ntohs(ip_hdr->tot_len);
-
- if (ip_hdr->protocol != IPPROTO_UDP)
- continue;
-
- udp_hdr = (void *) (eth_packet + sizeof(*ip_hdr));
-
- if (ntohs(udp_hdr->source) != BOOTP_SERVER_PORT)
- continue;
-
- if (ntohs(udp_hdr->dest) != BOOTP_CLIENT_PORT)
- continue;
- /* Go on with this packet; it looks sane */
-
- /* Originally copied sizeof (*bresp) - this is a security
- problem due to a potential underflow of the source
- buffer. Also, it trusted that the packet was properly
- 0xFF terminated, which is not true in the case of the
- DHCP server on Cisco 800 series ISDN router. */
-
- memset (bresp, 0xFF, sizeof (*bresp));
- memcpy (bresp, (char *) udp_hdr + sizeof (*udp_hdr), j - sizeof (*ip_hdr) - sizeof (*udp_hdr));
-
- /* sanity checks */
- if (bresp->id != breq->id)
- continue;
- if (bresp->opcode != BOOTP_OPCODE_REPLY)
- continue;
- if (bresp->hwlength != breq->hwlength)
- continue;
- if (memcmp(bresp->hwaddr, breq->hwaddr, bresp->hwlength))
- continue;
- if (get_vendor_code(bresp, DHCP_OPTION_TYPE, &type) || type != dhcp_type)
- continue;
- if (memcmp(bresp->vendor, vendor_cookie, 4))
- continue;
- return 0;
- }
- rfc951_sleep(retry);
- breq->secs = htons ((currticks () - starttime) / 20);
- retry++;
- timeout *= 2;
- if (timeout > 5)
- timeout = 5;
- }
-
- return -1;
-}
-
-static void add_vendor_code(struct bootp_request * breq, unsigned char option, unsigned char length, void * data)
-{
- unsigned char * chptr;
- int theOption, theLength;
-
- chptr = (unsigned char*) breq->vendor;
- chptr += 4;
- while (*chptr != 0xFF && *chptr != option) {
- theOption = *chptr++;
- if (!theOption) continue;
- theLength = *chptr++;
- chptr += theLength;
- }
-
- *chptr++ = option;
- *chptr++ = length;
- memcpy(chptr, data, length);
- chptr[length] = 0xff;
-}
-
-
-char * dhcp_hostname = NULL;
-char * dhcp_domain = NULL;
-
-enum return_type perform_dhcp(struct interface_info * intf)
-{
- int s, i;
- struct sockaddr_in server_addr;
- struct sockaddr_in client_addr;
- struct sockaddr_in broadcast_addr;
- struct bootp_request breq, bresp;
- unsigned char messageType;
- unsigned int lease;
- short aShort;
- int num_options;
- char requested_options[50];
- char * client_id_str, * client_id_hwaddr;
-
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- log_perror("socket");
- return RETURN_ERROR;
- }
-
- {
- enum return_type results;
- char * questions[] = { "Host name", "Domain name", NULL };
- char * questions_auto[] = { "hostname", "domain" };
- static char ** answers = NULL;
- char * boulet;
-
- client_id_str = client_id_hwaddr = NULL;
-
- results = ask_from_entries_auto("If the DHCP server needs to know you by name; please fill in this information. "
- "Valid answers are for example: `mybox' for hostname and `mynetwork.com' for "
- "domain name, for a machine called `mybox.mynetwork.com' on the Internet.",
- questions, &answers, 32, questions_auto, NULL);
- if (results == RETURN_OK)
- {
- dhcp_hostname = answers[0];
- if ((boulet = strchr(dhcp_hostname, '.')) != NULL)
- boulet[0] = '\0';
- dhcp_domain = answers[1];
-
- if (*dhcp_hostname && *dhcp_domain) {
- /* if we have both, then create client id from them */
- client_id_str = malloc(1 + strlen(dhcp_hostname) + 1 + strlen(dhcp_domain) + 1);
- client_id_str[0] = '\0';
- sprintf(client_id_str+1, "%s.%s", dhcp_hostname, dhcp_domain);
- }
- }
- }
-
- if (initial_setup_interface(intf->device, s) != 0) {
- close(s);
- return RETURN_ERROR;
- }
-
- if (prepare_request(&breq, s, intf->device) != 0) {
- close(s);
- return RETURN_ERROR;
- }
-
- messageType = DHCP_TYPE_DISCOVER;
- add_vendor_code(&breq, DHCP_OPTION_TYPE, 1, &messageType);
-
- /* add pieces needed to have DDNS/DHCP IP selection based on requested name */
- if (dhcp_hostname && *dhcp_hostname) { /* pick client id form based on absence or presence of domain name */
- if (*dhcp_domain) /* alternate style <hostname>.<domainname> */
- add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, strlen(client_id_str+1)+1, client_id_str);
- else { /* usual style (aka windows / dhcpcd) */
- /* but put MAC in form required for client identifier first */
- client_id_hwaddr = malloc(IFHWADDRLEN+2);
- /* (from pump-0.8.22/dhcp.c)
- * Microsoft uses a client identifier field of the 802.3 address with a
- * pre-byte of a "1". In order to re-use the DHCP address that they set
- * for this interface, we have to mimic their identifier.
- */
- client_id_hwaddr[0] = 1; /* set flag for ethernet */
- memcpy(client_id_hwaddr+1, gen_hwaddr, IFHWADDRLEN);
- add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, IFHWADDRLEN+1, client_id_hwaddr);
- }
- /* this is the one that the dhcp server really wants for DDNS updates */
- add_vendor_code(&breq, BOOTP_OPTION_HOSTNAME, strlen(dhcp_hostname), dhcp_hostname);
- log_message("DHCP: telling server to use name = %s", dhcp_hostname);
- }
-
- memset(&client_addr.sin_addr, 0, sizeof(&client_addr.sin_addr));
- client_addr.sin_family = AF_INET;
- client_addr.sin_port = htons(BOOTP_CLIENT_PORT); /* bootp client */
-
- if (bind(s, (struct sockaddr *) &client_addr, sizeof(client_addr))) {
- log_perror("bind");
- return RETURN_ERROR;
- }
-
- broadcast_addr.sin_family = AF_INET;
- broadcast_addr.sin_port = htons(BOOTP_SERVER_PORT); /* bootp server */
- memset(&broadcast_addr.sin_addr, 0xff, sizeof(broadcast_addr.sin_addr)); /* broadcast */
-
- log_message("DHCP: sending DISCOVER");
-
- wait_message("Sending DHCP request...");
- i = handle_transaction(s, &breq, &bresp, &broadcast_addr, DHCP_TYPE_OFFER);
- remove_wait_message();
-
- if (i != 0) {
- stg1_error_message("No DHCP reply received.");
- close(s);
- return RETURN_ERROR;
- }
-
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = htons(BOOTP_SERVER_PORT); /* bootp server */
- if (get_vendor_code(&bresp, DHCP_OPTION_SERVER, &server_addr.sin_addr)) {
- close(s);
- log_message("DHCPOFFER didn't include server address");
- return RETURN_ERROR;
- }
-
- init_vendor_codes(&breq);
- messageType = DHCP_TYPE_REQUEST;
- add_vendor_code(&breq, DHCP_OPTION_TYPE, 1, &messageType);
- add_vendor_code(&breq, DHCP_OPTION_SERVER, 4, &server_addr.sin_addr);
- add_vendor_code(&breq, DHCP_OPTION_REQADDR, 4, &bresp.yiaddr);
-
- /* if used the first time, then have to use it again */
- if (dhcp_hostname && *dhcp_hostname) { /* add pieces needed to have DDNS/DHCP IP selection based on requested name */
- if (dhcp_domain && *dhcp_domain) /* alternate style */
- add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, strlen(client_id_str+1)+1, client_id_str);
- else /* usual style (aka windows / dhcpcd) */
- add_vendor_code(&breq, DHCP_OPTION_CLIENT_IDENTIFIER, IFHWADDRLEN+1, client_id_hwaddr);
- /* this is the one that the dhcp server really wants for DDNS updates */
- add_vendor_code(&breq, BOOTP_OPTION_HOSTNAME, strlen(dhcp_hostname), dhcp_hostname);
- }
-
- aShort = ntohs(sizeof(struct bootp_request));
- add_vendor_code(&breq, DHCP_OPTION_MAXSIZE, 2, &aShort);
-
- num_options = 0;
- requested_options[num_options++] = BOOTP_OPTION_NETMASK;
- requested_options[num_options++] = BOOTP_OPTION_GATEWAY;
- requested_options[num_options++] = BOOTP_OPTION_DNS;
- requested_options[num_options++] = BOOTP_OPTION_DOMAIN;
- requested_options[num_options++] = BOOTP_OPTION_BROADCAST;
- add_vendor_code(&breq, DHCP_OPTION_OPTIONREQ, num_options, requested_options);
-
- /* request a lease of 1 hour */
- i = htonl(60 * 60);
- add_vendor_code(&breq, DHCP_OPTION_LEASE, 4, &i);
-
- log_message("DHCP: sending REQUEST");
-
- i = handle_transaction(s, &breq, &bresp, &broadcast_addr, DHCP_TYPE_ACK);
-
- if (i != 0) {
- close(s);
- return RETURN_ERROR;
- }
-
- if (get_vendor_code(&bresp, DHCP_OPTION_LEASE, &lease)) {
- log_message("failed to get lease time\n");
- return RETURN_ERROR;
- }
- lease = ntohl(lease);
-
- close(s);
-
- intf->netmask.s_addr = 0;
- intf->broadcast.s_addr = 0;
- intf->network.s_addr = 0;
-
- parse_reply(&bresp, intf);
-
- return RETURN_OK;
-}
diff --git a/mdk-stage1/dhcp.h b/mdk-stage1/dhcp.h
deleted file mode 100644
index d1ad8ae9e..000000000
--- a/mdk-stage1/dhcp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * View the homepage: http://us.mandrakesoft.com/~gc/html/stage1.html
- *
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from GRUB -- GRand Unified Bootloader
- * Copyright (C) 2000 Free Software Foundation, Inc.
- *
- * Itself based on etherboot-4.6.4 by Martin Renters.
- *
- */
-
-#ifndef _DHCP_H_
-#define _DHCP_H_
-
-#include "stage1.h"
-#include "network.h"
-
-enum return_type perform_dhcp(struct interface_info * intf);
-
-extern char * dhcp_hostname;
-extern char * dhcp_domain;
-
-#endif
diff --git a/mdk-stage1/directory.c b/mdk-stage1/directory.c
deleted file mode 100644
index 6115b600c..000000000
--- a/mdk-stage1/directory.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- * Olivier Blin (oblin@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <unistd.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <libgen.h>
-#include "stage1.h"
-#include "frontend.h"
-#include "log.h"
-#include "lomount.h"
-
-char * extract_list_directory(char * direct)
-{
- char ** full = list_directory(direct);
- char tmp[20000] = "";
- int i;
- for (i=0; i<50 ; i++) {
- if (!full || !*full)
- break;
- strcat(tmp, *full);
- strcat(tmp, "\n");
- full++;
- }
- return strdup(tmp);
-}
-
-static void choose_iso_in_directory(char *directory, char *location_full)
-{
- char **file;
- char *stage2_isos[100] = { "Use directory as a mirror tree", "-----" };
- int stage2_iso_number = 2;
-
- log_message("\"%s\" exists and is a directory, looking for iso files", directory);
-
- for (file = list_directory(directory); *file; file++) {
- char isofile[500];
- char * loopdev = NULL;
-
- if (strstr(*file, ".iso") != *file + strlen(*file) - 4)
- /* file doesn't end in .iso, skipping */
- continue;
-
- strcpy(isofile, directory);
- strcat(isofile, "/");
- strcat(isofile, *file);
-
- if (lomount(isofile, IMAGE_LOCATION, &loopdev, 0)) {
- log_message("unable to mount iso file \"%s\", skipping", isofile);
- continue;
- }
-
- if (image_has_stage2()) {
- log_message("stage2 installer found in ISO image \"%s\"", isofile);
- stage2_isos[stage2_iso_number++] = strdup(*file);
- } else {
- log_message("ISO image \"%s\" doesn't contain stage2 installer", isofile);
- }
-
- umount(IMAGE_LOCATION);
- del_loop(loopdev);
- }
-
- stage2_isos[stage2_iso_number] = NULL;
-
- if (stage2_iso_number > 2) {
- enum return_type results;
- do {
- results = ask_from_list("Please choose the ISO image to be used to install the "
- DISTRIB_NAME " Distribution.",
- stage2_isos, file);
- if (results == RETURN_BACK) {
- return;
- } else if (results == RETURN_OK) {
- if (!strcmp(*file, stage2_isos[0])) {
- /* use directory as a mirror tree */
- continue;
- } else if (!strcmp(*file, stage2_isos[1])) {
- /* the separator has been selected */
- results = RETURN_ERROR;
- continue;
- } else {
- /* use selected ISO image */
- strcat(location_full, "/");
- strcat(location_full, *file);
- log_message("installer will use ISO image \"%s\"", location_full);
- }
- }
- } while (results == RETURN_ERROR);
- } else {
- log_message("no ISO image found in \"%s\" directory", location_full);
- }
-}
-
-
-enum return_type try_with_directory(char *directory, char *method_live, char *method_iso) {
- char location_full[500];
- char * loopdev = NULL;
- struct stat statbuf;
- enum return_type ret = RETURN_OK;
-
- unlink(IMAGE_LOCATION);
- strcpy(location_full, directory);
-
-#ifndef MANDRAKE_MOVE
- if (!stat(directory, &statbuf) && S_ISDIR(statbuf.st_mode)) {
- choose_iso_in_directory(directory, location_full);
- }
-#endif
-
- loopdev = NULL;
- if (!stat(location_full, &statbuf) && !S_ISDIR(statbuf.st_mode)) {
- log_message("%s exists and is not a directory, assuming this is an ISO image", location_full);
- if (lomount(location_full, IMAGE_LOCATION, &loopdev, 0)) {
- stg1_error_message("Could not mount file %s as an ISO image of the " DISTRIB_NAME " Distribution.", location_full);
- return RETURN_ERROR;
- }
- add_to_env("ISOPATH", location_full);
- add_to_env("METHOD", method_iso);
- } else {
- int offset = strncmp(location_full, IMAGE_LOCATION_DIR, sizeof(IMAGE_LOCATION_DIR) - 1) == 0 ? sizeof(IMAGE_LOCATION_DIR) - 1 : 0;
- log_message("assuming %s is a mirror tree", location_full + offset);
-
- rmdir(IMAGE_LOCATION); /* useful if we loopback mounted it */
- symlink(location_full + offset, IMAGE_LOCATION);
- add_to_env("METHOD", method_live);
- }
-
-#ifdef MANDRAKE_MOVE
- if (access(IMAGE_LOCATION "/live_tree/etc/fstab", R_OK) && access(IMAGE_LOCATION "/live_tree.clp", R_OK)) {
- stg1_error_message("I can't find the " DISTRIB_NAME " Distribution in the specified directory. "
- "(I need the file " IMAGE_LOCATION "/live_tree/etc/fstab" ")\n"
- "Here's a short extract of the files in the directory:\n"
- "%s", extract_list_directory(IMAGE_LOCATION));
- ret = RETURN_BACK;
- }
-#else
- if (access(IMAGE_LOCATION "/" CLP_LOCATION_REL, R_OK)) {
- stg1_error_message("I can't find the " DISTRIB_NAME " Distribution in the specified directory. "
- "(I need the subdirectory " CLP_LOCATION_REL ")\n"
- "Here's a short extract of the files in the directory:\n"
- "%s", extract_list_directory(IMAGE_LOCATION));
- ret = RETURN_BACK;
- } else if (may_load_clp() != RETURN_OK) {
- stg1_error_message("Could not load program into memory.");
- ret = RETURN_ERROR;
- }
-
- if (ret == RETURN_OK)
- log_message("found the " DISTRIB_NAME " Installation, good news!");
-
-#endif
- if (!KEEP_MOUNTED || ret != RETURN_OK) {
- /* in rescue mode, we don't need the media anymore */
- umount(IMAGE_LOCATION);
- del_loop(loopdev);
- }
-
- return ret;
-}
diff --git a/mdk-stage1/directory.h b/mdk-stage1/directory.h
deleted file mode 100644
index eb744520b..000000000
--- a/mdk-stage1/directory.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- * Olivier Blin (oblin@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef _DIRECTORY_H_
-#define _DIRECTORY_H_
-
-char * extract_list_directory(char * direct);
-enum return_type try_with_directory(char *location_full, char *method_live, char *method_iso);
-
-#endif
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
deleted file mode 100644
index e3e84d7da..000000000
--- a/mdk-stage1/disk.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <libgen.h>
-#include "stage1.h"
-#include "frontend.h"
-#include "modules.h"
-#include "probing.h"
-#include "log.h"
-#include "mount.h"
-#include "lomount.h"
-#include "automatic.h"
-#include "directory.h"
-#include "partition.h"
-
-#include "disk.h"
-
-static enum return_type try_with_device(char *dev_name)
-{
- char * questions_location[] = { "Directory or ISO images directory or ISO image", NULL };
- char * questions_location_auto[] = { "directory", NULL };
- static char ** answers_location = NULL;
- char location_full[500];
-
- char * disk_own_mount = IMAGE_LOCATION_DIR "hdimage";
-
- char * parts[50];
- char * parts_comments[50];
- enum return_type results;
- char * choice;
-
- if (list_partitions(dev_name, parts, parts_comments)) {
- stg1_error_message("Could not read partitions information.");
- return RETURN_ERROR;
- }
-
- /* uglyness to allow auto starting with devfs */
- if (!IS_AUTOMATIC || streq((choice = get_auto_value("partition")), "")) {
- if (parts[0] == NULL) {
- stg1_error_message("No partition found.");
- return RETURN_ERROR;
- }
-
- results = ask_from_list_comments_auto("Please select the partition containing the copy of the "
- DISTRIB_NAME " Distribution install source.",
- parts, parts_comments, &choice, "partition", parts);
- if (results != RETURN_OK)
- return results;
- }
-
- /* in testing mode, assume the partition is already mounted on IMAGE_LOCATION_DIR "hdimage" */
- if (!IS_TESTING && try_mount(choice, disk_own_mount)) {
- stg1_error_message("I can't find a valid filesystem (tried: ext2, vfat, ntfs, reiserfs). "
- "Make sure the partition has been cleanly unmounted.");
- return try_with_device(dev_name);
- }
-
- ask_dir:
- if (ask_from_entries_auto("Please enter the directory (or ISO image file) containing the "
- DISTRIB_NAME " Distribution install source.",
- questions_location, &answers_location, 24, questions_location_auto, NULL) != RETURN_OK) {
- umount(disk_own_mount);
- return try_with_device(dev_name);
- }
-
- strcpy(location_full, disk_own_mount);
- strcat(location_full, "/");
- strcat(location_full, answers_location[0]);
-
- if (access(location_full, R_OK)) {
- char * path = strdup(answers_location[0]);
- stg1_error_message("Directory or ISO image file could not be found on partition.\n"
- "Here's a short extract of the files in the directory %s:\n"
- "%s", dirname(path), extract_list_directory(dirname(location_full)));
- free(path);
- goto ask_dir;
- }
-
- results = try_with_directory(location_full, "disk", "disk-iso");
- if (results != RETURN_OK) {
- goto ask_dir;
- }
-
- if (!KEEP_MOUNTED)
- umount(disk_own_mount);
-
- return RETURN_OK;
-}
-
-enum return_type disk_prepare(void)
-{
- char ** medias, ** medias_models;
- char * choice;
- int i;
- enum return_type results;
- static int already_probed_ide_generic = 0;
-
- int count = get_disks(&medias, &medias_models);
-
- if (count == 0) {
- if (!already_probed_ide_generic) {
- already_probed_ide_generic = 1;
- my_insmod("ide-generic", ANY_DRIVER_TYPE, NULL, 0);
- return disk_prepare();
- }
- stg1_error_message("No DISK drive found.");
- i = ask_insmod(SCSI_ADAPTERS);
- if (i == RETURN_BACK)
- return RETURN_BACK;
- return disk_prepare();
- }
-
- if (count == 1) {
- results = try_with_device(*medias);
- if (results != RETURN_ERROR)
- return results;
- i = ask_insmod(SCSI_ADAPTERS);
- if (i == RETURN_BACK)
- return RETURN_BACK;
- return disk_prepare();
- }
-
- results = ask_from_list_comments_auto("Please select the disk containing the copy of the "
- DISTRIB_NAME " Distribution install source.",
- medias, medias_models, &choice, "disk", medias);
-
- if (results != RETURN_OK)
- return results;
-
- results = try_with_device(choice);
- if (results != RETURN_ERROR)
- return results;
- i = ask_insmod(SCSI_ADAPTERS);
- if (i == RETURN_BACK)
- return RETURN_BACK;
- return disk_prepare();
-}
diff --git a/mdk-stage1/disk.h b/mdk-stage1/disk.h
deleted file mode 100644
index fae890894..000000000
--- a/mdk-stage1/disk.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef _DISK_H_
-#define _DISK_H_
-
-enum return_type disk_prepare(void);
-
-#endif
diff --git a/mdk-stage1/dns.c b/mdk-stage1/dns.c
deleted file mode 100644
index 1d7d2d6c8..000000000
--- a/mdk-stage1/dns.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-
-// dietlibc can do hostname lookup, whereas glibc can't when linked statically :-(
-
-#if defined(__dietlibc__)
-
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <resolv.h>
-
-#include "network.h"
-#include "log.h"
-
-#include "dns.h"
-
-int mygethostbyname(char * name, struct in_addr * addr)
-{
- struct hostent * h;
-
- /* prevent from timeouts */
- if (_res.nscount == 0)
- return -1;
-
- h = gethostbyname(name);
-
- if (!h && domain) {
- // gethostbyname from dietlibc doesn't support domain handling
- char fully_qualified[500];
- sprintf(fully_qualified, "%s.%s", name, domain);
- h = gethostbyname(fully_qualified);
- }
-
- if (h && h->h_addr_list && (h->h_addr_list)[0]) {
- memcpy(addr, (h->h_addr_list)[0], sizeof(*addr));
- log_message("is-at: %s", inet_ntoa(*addr));
- return 0;
- }
-
- log_message("unknown host %s", name);
- return -1;
-}
-
-char * mygethostbyaddr(char * ipnum)
-{
- struct in_addr in;
- struct hostent * host;
-
- /* prevent from timeouts */
- if (_res.nscount == 0)
- return NULL;
-
- if (!inet_aton(ipnum, &in))
- return NULL;
- host = gethostbyaddr(&(in.s_addr), sizeof(in.s_addr) /* INADDRSZ */, AF_INET);
- if (host && host->h_name)
- return host->h_name;
- return NULL;
-}
-
-#elif defined(__GLIBC__)
-
-#include <alloca.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <resolv.h>
-#include <arpa/nameser.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "log.h"
-
-#include "dns.h"
-
-/* This is dumb, but glibc doesn't like to do hostname lookups w/o libc.so */
-
-union dns_response {
- HEADER hdr;
- u_char buf[PACKETSZ];
-} ;
-
-static int do_query(char * query, int queryType, char ** domainName, struct in_addr * ipNum)
-{
- int len, ancount, type;
- u_char * data, * end;
- char name[MAXDNAME];
- union dns_response response;
-
-#ifdef __sparc__
- /* from jj: */
- /* We have to wait till ethernet negotiation is done */
- _res.retry = 3;
-#else
- _res.retry = 2;
-#endif
-
-
- len = res_search(query, C_IN, queryType, (void *) &response, sizeof(response));
- if (len <= 0)
- return -1;
-
- if (ntohs(response.hdr.rcode) != NOERROR)
- return -1;
-
- ancount = ntohs(response.hdr.ancount);
- if (ancount < 1)
- return -1;
-
- data = response.buf + sizeof(HEADER);
- end = response.buf + len;
-
- /* skip the question */
- data += dn_skipname(data, end) + QFIXEDSZ;
-
- /* parse the answer(s) */
- while (--ancount >= 0 && data < end) {
-
- /* skip the domain name portion of the RR record */
- data += dn_skipname(data, end);
-
- /* get RR information */
- GETSHORT(type, data);
- data += INT16SZ; /* skipp class */
- data += INT32SZ; /* skipp TTL */
- GETSHORT(len, data);
-
- if (type == T_PTR) {
- /* we got a pointer */
- len = dn_expand(response.buf, end, data, name, sizeof(name));
- if (len <= 0) return -1;
- if (queryType == T_PTR && domainName) {
- /* we wanted a pointer */
- *domainName = malloc(strlen(name) + 1);
- strcpy(*domainName, name);
- return 0;
- }
- } else if (type == T_A) {
- /* we got an address */
- if (queryType == T_A && ipNum) {
- /* we wanted an address */
- memcpy(ipNum, data, sizeof(*ipNum));
- return 0;
- }
- }
-
- /* move ahead to next RR */
- data += len;
- }
-
- return -1;
-}
-
-char * mygethostbyaddr(char * ipnum) {
- int rc;
- char * result;
- char * strbuf;
- char * chptr;
- char * splits[4];
- int i;
-
- _res.retry = 1;
-
- strbuf = alloca(strlen(ipnum) + 1);
- strcpy(strbuf, ipnum);
-
- ipnum = alloca(strlen(strbuf) + 20);
-
- for (i = 0; i < 4; i++) {
- chptr = strbuf;
- while (*chptr && *chptr != '.')
- chptr++;
- *chptr = '\0';
-
- if (chptr - strbuf > 3) return NULL;
- splits[i] = strbuf;
- strbuf = chptr + 1;
- }
-
- sprintf(ipnum, "%s.%s.%s.%s.in-addr.arpa", splits[3], splits[2], splits[1], splits[0]);
-
- rc = do_query(ipnum, T_PTR, &result, NULL);
-
- if (rc)
- return NULL;
- else
- return result;
-}
-
-int mygethostbyname(char * name, struct in_addr * addr) {
- int rc = do_query(name, T_A, NULL, addr);
- if (!rc)
- log_message("is-at %s", inet_ntoa(*addr));
- return rc;
-}
-
-#else
-
-#error "Unsupported C library"
-
-#endif
diff --git a/mdk-stage1/dns.h b/mdk-stage1/dns.h
deleted file mode 100644
index 21d0c63ac..000000000
--- a/mdk-stage1/dns.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef H_DNS
-#define H_DNS
-
-#include <netinet/in.h>
-
-int mygethostbyname(char * name, struct in_addr * addr);
-char * mygethostbyaddr(char * ipnum);
-
-#endif
diff --git a/mdk-stage1/doc/HACKING b/mdk-stage1/doc/HACKING
deleted file mode 100644
index d196c8010..000000000
--- a/mdk-stage1/doc/HACKING
+++ /dev/null
@@ -1,31 +0,0 @@
-If you have to boot pretty often, you'll appreciate to speed the things up
-a little.
-
-Here's what we use: the GRUB feature to boot from the network using the
-DHCP protocol and the TFTP protocol.
-
-Here's the "menu.lst" to do that:
-
--=-=--
-
-timeout 0
-
-title linux
-dhcp
-tftpserver 192.168.1.17
-kernel (nd)/tftpboot/gc/vmlinuz ramdisk=32000 vga=788
-initrd (nd)/tftpboot/gc/network.rdz
-
--=-=--
-
-
-The option "tftpserver" is used to override the tftpserver address given
-as an answer by the DHCP server. That way, you'll not need to bother your
-system administrator to modify his dhcp server configuration.
-
-The directory /tftpboot seems to be the only one defaultly accepted by the
-server, and its subdirs.
-
-
-Of course, your GRUB needs to be compiled with the specific code for your
-network card; use ./configure --help in the GRUB build dir for more infos.
diff --git a/mdk-stage1/doc/README b/mdk-stage1/doc/README
deleted file mode 100644
index 6a1d92bf9..000000000
--- a/mdk-stage1/doc/README
+++ /dev/null
@@ -1,185 +0,0 @@
--------------------------------------------------------
-* Stage1 of the Mandrakelinux installation program *
--------------------------------------------------------
-
-
-[ Author ]
-
- Guillaume Cottenceau (gc at mandrakesoft.com)
-
-
-[ Copyright ]
-
- Copyright 2000, 2001, 2002 Mandrakesoft
-
- Partially inspired by Redhat stuff (install from 5.x and 7.x) copyright
- Red Hat Software, and Debian stuff (boot-floppies) copyright by their
- respective holders.
-
-
-[ Licence ]
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
- *** WARNING! ***
-
- This General Public License does not permit incorporating any part
- of this program as a library into proprietary programs.
-
-
-[ Online ]
-
- http://people.mandrakesoft.com/~gc/html/stage1.html
-
-
-[ Purpose ]
-
- This code will take the control of the computer after that Linux
- kernel booted properly, and will try to run the main installer
- (also known as "stage 2") from a series of different media
- including harddrive, cdrom, and network.
-
- Use the source, Luke.
-
-
-
-
- -=-=-- Okay, now, more details --=-=-
-
-
- [ Installing Mandrakelinux ]
-
-Per default, just insert your Mandrakelinux Installation CD into your
-CDROM tray, be sure your system BIOS is configured to boot on your CDROM,
-and that's all.
-
-If you have multiple CDROM drives and the installer can't autodetect in
-which CDROM drive is the disc, it may ask you to choose the correct drive,
-between your CDROM drives.
-
-Also, if you want to install from an SCSI CDROM, the installer should
-detect your SCSI adapter; if it fails you may have to select the right
-driver and/or supply additional parameters.
-
-
- [ Position of the problem ]
-
-The need for alternate installation methods come with more specific
-hardware configuration and/or need for frequent updates of the Installer
-software.
-
-All of these methods will require to use a special boot disk. The method
-is to download it and then to copy it "physically" to a floppy with the
-command:
-
-# dd if=<boot-disk> of=/dev/fd0
-
-Our boot disks are called "cdrom.img", "network.img", etc.
-
-
- [ Installation from CDROM ]
-
-The first situation you may encounter is an old BIOS which does not permit
-you to boot from your CDROM drive.
-
-In that case, you'll need to use the "cdrom.img" image file. The steps are
-the same as with CDROM boot, and everything should be automatic.
-
-
- [ Installation from DISK ]
-
-If you like trying occasionnally our development version, the Cooker, one
-of the easiest way is to grab a local copy of the Distribution on one of
-your local hard drives, and to install from that location.
-
-At present time, you can install from IDE or SCSI drives, from Linux
-(ext2), Windows (vfat) or Reiserfs partition.
-
-In that case, you'll need to use the "hd.img" image file. The dialogs will
-ask you to choose the DISK drive to use to install from, then the
-partition on which you copied the Distribution, then the location
-(directory) in which you copied the Distribution.
-
-
- [ Installation from NETWORK ]
-
-For convenience, you can also install from a NFS volume, from a FTP
-server, or from a HTTP server. NFS installs are maybe the fastest
-and most convenient possible, so if you need to do frequent and/or
-multiple installs, you may like this option.
-
-In that case, you'll need to use the "network.img" image file. If you have
-PCI network card(s), you'll probably have to only setup your network
-options. If not, you'll have to choose the appropriate driver(s) and/or
-optional parameters. Supported network configurations include static IP
-allocation and DHCP automatic configuration.
-
-
- [ Installation from PCMCIA ]
-
-If you want to perform an installation on your laptop that is not based on
-local IDE CDROM or DISK, nor on built-in network card, but on PCMCIA
-extension (probably a network adapter or CDROM drive), you'll need the
-"pcmcia.img" image file.
-
-PCMCIA services should automatically start and be transparent to you.
-Then, you'll follow the instructions according to your preferred
-installation method.
-
-
- [ Monitoring a stage1 session ]
-
-Linux supports virtual consoles. You can switch between them by issueing
-Ctrl+Alt+Fx key, in which 'x' is the number of the console. Here's console
-occupancy during stage1.
-
-(#1) The user-interface of the stage1 is on the first console. In case of
-newt interaction, it's provided with a neat blue and black color scheme,
-and nice widgets. In case of stdio interaction (cdrom and disk installs),
-it's more basic but still usable :-).
-
-(#2) A shell is provided on second console in some cases (you need to
-compile it with -DSPAWN_SHELL and you need to provide a valid shell in the
-initrd) and of course it's not in, in image files of Mandrakelinux
-releases because it's too much diskspace.
-
-(#3) The log is printed out on the third console. This is the location
-where you can find most valuable information, prefixed by a '*'. See
-"log.h" for calls that print things out to the log.
-
-(#4) The kernel messages are printed on the fourth console. There is a
-process forked very early in the init (the program before the stage1)
-which monitors /proc/kmsg for new kernel messages. Also, syslog stuff (the
-logs commited by the programs) should appear on the /dev/log Unix socket,
-this is also printed on this console.
-
-(#5) Former place for the stderr of insmod calls. It's not used anymore.
-
-(#6) Place where a trivial interactive communication with the stage1 is
-set up if the parameter -DSPAWN_INTERACTIVE is compiled in. Basically, you
-can set switches such as "expert" and "rescue" on the fly with this
-feature. It's implemented with a fork and a Unix pipe.
-
-
- [ Rescueing a system ]
-
-Since Mandrakelinux 7.1, we provide a rescue system through each of the
-previously described methods. You don't need a special "rescue.img" file.
-Just hit "F1" at boot time, type in "rescue", and follow the first steps
-of the installation according to the method you chose (choose
-disks/partitions for disk method, network parameters for network method,
-etc). Then, you'll end up with a workable system, very useful to rescue a
-damaged system, or do other basic actions.
diff --git a/mdk-stage1/doc/TECH-INFOS b/mdk-stage1/doc/TECH-INFOS
deleted file mode 100644
index e66c9daa5..000000000
--- a/mdk-stage1/doc/TECH-INFOS
+++ /dev/null
@@ -1,101 +0,0 @@
-
-| (*) Automatic install
-\----------------------
-
-This feature is used to replace redhat kickstart. It uses the kernel
-parameter "automatic" with keywords separated with commas and colons, on
-the following genres:
-
- automatic=method:nfs,network:static,ip:192.168.1.24,server:192.168.1.7,directory:/stable/i586
-
- automatic=method:ftp,network:dhcp,server:ftp.ciril.fr,directory:/pub/linux/mandrake-devel/cooker
-
- automatic=method:ftp,network:dhcp,server:companyserver,directory:/mdkinst,user:XXX,pass:XXX
-
- automatic=method:ftp,interface:eth1,network:dhcp,...
-
- automatic=method:ftp,network:adsl,adsluser:XXX,adslpass:XXX,...
-
- automatic=method:cdrom
-
- automatic=method:disk,disk:hdb,partition:hdb7,directory:/cooker
-
-
-The keywords correspond to each "virtual" question answered automatically,
-either from a list or from a free field.
-
-
-Keywords are:
-
-
-`method' <- (nfs,ftp,http,cdrom,disk)
-
-if nfs/ftp/http:
-
- `network' <- (static,dhcp,adsl)
-
- if multiple interfaces detected:
-
- `interface' <- (list-of-detected-interfaces)
-
- fi
-
- if static:
-
- `ip', `dns', `gateway', `netmask' (free fields)
-
- elsif adsl:
-
- `adsluser', `adslpass' (free field)
-
- fi
-
- if resolving fails:
-
- `hostname', `domain' (free fields)
-
- fi
-
- `server', `directory' (free fields)
-
- if ftp:
-
- `user', `pass' (free fields)
-
- fi
-
-fi
-
-if disk:
-
- `disk' <- (list-of-detected-disks)
-
- `partition' <- (list-of-detected-partitions)
-
- `directory' (free fields)
-
-fi
-
-
-
-You may use shorter versions of keywords (it helps reducing size of
-commandline), please find each keyword short-alias counterpart in file
-../automatic.c under the identifier named "short_aliases".
-
-This gives for example for:
-
- automatic=method:nfs,network:static,ip:192.168.1.24,server:192.168.1.7,directory:/stable/i586
-==>
- automatic=met:nfs,net:static,ip:192.168.1.24,ser:192.168.1.7,dir:/stable/i586
-
-
-
-You may specify a stage2 auto-install file, different from the
-default `auto_inst.cfg.pl' in install/, by filling the
-`bootfile' parameter of your DHCP server response.
-
-Note that if the name ends with `-IP' or `-IP.pl', IP will be
-replaced by the IP address given to the host, normalized to
-hexadecimal (that is, `192.168.100.57' would give 'C0A86439').
-
-
diff --git a/mdk-stage1/doc/UPDATEMODULES b/mdk-stage1/doc/UPDATEMODULES
deleted file mode 100644
index ceef21758..000000000
--- a/mdk-stage1/doc/UPDATEMODULES
+++ /dev/null
@@ -1,95 +0,0 @@
-This is the documentation for the "Update Modules" (Update Drivers)
-feature.
-
-This feature aims to propose new modules or replacement modules for the
-install and afterwards. This is useful when there is a firmware update for a
-given driver, an additional driver needed for something, etc.
-
-
-You must use a floppy disk with e2fs filesystem (NOT vfat/windows
-formatted). Use "mke2fs /dev/fd0" on your own box to format a floppy with
-e2fs filesystem.
-
-This disk may contain a number of kernel modules; some of them
-may replace existing modules, some of them may be added.
-This disk must contain a special file, named "to_load", on
-the root (not in a subdirectory). This file will contain a series of
-module names, with optional module options; the program will try to load
-all these modules one after another, using file on the floppy if present,
-else using file within standard module repository ("marfile" on the boot
-floppy). It can contain comments, these are strictly defined by the
-presence of a hash (#) character on column 0 of any line.
-
-This disk may also contain some update or new modules for installed kernels.
-Those modules must be placed in directory <kernel-version>. They must be
-gzipped if the installed kernel modules are gzipped.
-
-You may need to specify the "category" so that new modules are used correctly.
-For example, a scsi module should be put in category disk/scsi so that it is
-put in scsi_hostadapter and initrd.
-
-
-Here's a typical scenario:
-
-
-1. Boot the floppy (or cdrom) with the option "updatemodules"
-
- (you may do that by pressing F1 then entering "linux updatemodules")
-
-
-2. At the very beginning of the User Interface, you are asked to insert
- the Update Modules disk. Insert the Update Modules disk and press
- Enter.
-
---=----=----=----=----=----=----=----=----=--
-Our example disk contains:
-
-[root@obiwan mnt]# ll floppy/
-total 77
-drwxr-xr-x 2 root root 12288 Jul 26 12:02 lost+found/
--rw-r--r-- 1 root root 9051 Jul 26 12:43 msdos.ko
--rw-r--r-- 1 root root 13660 Jul 26 12:04 ppa.ko
--rw-r--r-- 1 root root 54 Jul 26 12:46 to_load
--rw-r--r-- 1 root root 32108 Jul 26 12:04 uhci.ko
--rw-r--r-- 1 root root 6572 Jul 26 12:04 wacom.ko
-drwxr-xr-x 4 root root 4096 Jul 26 12:04 2.6.8.1-20mdk
-drwxr-xr-x 4 root root 4096 Jul 26 12:04 2.6.8.1-20mdksmp
-[root@obiwan mnt]# cat floppy/to_load
-# Update Drivers description file
-3c59x
-# fat is a dep for msdos
-fat
-# updated msdos (handling of 9+4 filenames)
-msdos
-ppa
-# ISA network card needing options
-ne io=0x300 irq=7
-# New module [list_modules: disk/scsi]
-a320raid
-[root@obiwan mnt]# (cd floppy/2.6.8.1-20mdk ; find -type f)
-./kernel/fs/msdos/msdos.ko.gz
-./kernel/drivers/scsi/ppa.ko.gz
-./kernel/drivers/usb/host/uhci-hcd.ko.gz
-./kernel/drivers/usb/input/wacom.ko.gz
-[root@obiwan mnt]#
---=----=----=----=----=----=----=----=----=--
-
-
-3. The program reads the special file "to_load" and processes the files.
-
- a- 3c59x loaded from the marfile on the boot floppy
- b- fat loaded from the marfile on the boot floppy
- c- msdos loaded from the update modules floppy
- d- ppa loaded from the update modules floppy
- e- ne loaded from the marfile on the boot floppy
-
-
-
-!!! Beware !!!, the dependencies are not handled automatically in
-the case of load from the update modules floppy, that's why on
-our example we need to load "fat" from the standard modules
-before "msdos" from the update floppy.
-
-
-4. When system is installed, update floppy is asked again so that update
-modules for the installed kernels can be copied. Then depmod is called.
diff --git a/mdk-stage1/doc/WHY-DIETLIBC b/mdk-stage1/doc/WHY-DIETLIBC
deleted file mode 100644
index e7c526b49..000000000
--- a/mdk-stage1/doc/WHY-DIETLIBC
+++ /dev/null
@@ -1,50 +0,0 @@
-(the dietlibc is a replacement for the glibc, which aim is to produce
-smaller statically linked binaries)
-
-
-The use for dietlibc in the stage1 was clear because currently used
-install process on x86 is from a 1.44 Mbytes floppy. On this floppy we
-need to fit the kernel, modules (scsi and network access), and the code to
-do the basic things to load the stage2. The only part on which we could
-progress was the code.
-
-As always, figures demonstrate evidences. Here are the size of the
-binaries used for the cdrom, disk, network and full floppy installs, using
-newt as the UI library:
-
- - with glibc
-
--rwxr-xr-x 1 gc gc 569448 May 15 15:29 stage1-cdrom
--rwxr-xr-x 1 gc gc 572264 May 15 15:29 stage1-disk
--rwxr-xr-x 1 gc gc 624712 May 15 15:30 stage1-network
--rwxr-xr-x 1 gc gc 720360 May 15 15:29 stage1-full
-
- - with dietlibc
-
--rwxr-xr-x 1 gc gc 169332 May 15 14:26 stage1-cdrom
--rwxr-xr-x 1 gc gc 172180 May 15 14:26 stage1-disk
--rwxr-xr-x 1 gc gc 198612 May 15 14:26 stage1-network
--rwxr-xr-x 1 gc gc 251764 May 15 14:26 stage1-full
-
-
-The `stage1-full' binary has code for many things, most notably: data
-decrunching (bzlib), archive extraction (in-house format), module loading
-(insmod from busybox), PCI detection, ide and scsi handling,
-cdrom/disk/loopback mounting, DHCP client negociation (redhat+grub), NFS
-mounting (util-linux), FTP and HTTP transmission (redhat), pcmcia
-initializing (pcmcia-cs), UI interaction (slang/newt); with use of the
-dietlibc, the binary is only 250 kbytes!
-
-
-Due to the modular coding, it is also possible to choose to not use
-slang/newt as the UI, but a stdio-only UI. In that case, the binaries get
-even smaller:
-
--rwxr-xr-x 1 gc gc 104500 May 15 15:46 stage1-cdrom*
--rwxr-xr-x 1 gc gc 107348 May 15 15:46 stage1-disk*
--rwxr-xr-x 1 gc gc 133972 May 15 15:47 stage1-network*
--rwxr-xr-x 1 gc gc 187348 May 15 15:46 stage1-full*
-
-
-
-gc [Tue May 15 15:58:34 2001] \ No newline at end of file
diff --git a/mdk-stage1/doc/documented..frontend.h b/mdk-stage1/doc/documented..frontend.h
deleted file mode 100644
index 0e666d534..000000000
--- a/mdk-stage1/doc/documented..frontend.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Using high-level UI.
- *
- * These functions are frontend-independant: your program won't know each
- * `frontend' (e.g. each way to grab user input) will be used.
- *
- * Then you may link your binary against any `frontend' that implement all
- * these functions (and possibly necessary libraries).
- */
-
-
-#ifndef _FRONTEND_H_
-#define _FRONTEND_H_
-
-/* this must be called before anything else */
-void init_frontend(void);
-
-/* this must be called before exit of program */
-void finish_frontend(void);
-
-
-void info_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* (blocks program) */
-
-void error_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* (blocks program) */
-
-/* (doesn't block program)
- * (this is not necessarily stackable, e.g. only one wait_message at a time) */
-void wait_message(char *msg, ...) __attribute__ ((format (printf, 1, 2)));
-
-/* call this to finish the wait on wait_message */
-void remove_wait_message(void);
-
-/* monitor progression of something (downloading a file, etc)
- * if size of progression is unknown, use `0' */
-void init_progression(char *msg, int size);
-void update_progression(int current_size);
-void end_progression(void);
-
-enum frontend_return { RETURN_OK, RETURN_BACK, RETURN_ERROR };
-
-/* Yes == RETURN_OK No == RETURN_ERROR Back == RETURN_BACK */
-enum frontend_return ask_yes_no(char *msg);
-
-/* [elems] NULL terminated array of char*
- * [choice] address of a (unitialized) char* */
-enum frontend_return ask_from_list(char *msg, char ** elems, char ** choice);
-
-enum frontend_return ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice);
-
-/* [questions] NULL terminated array of char*
- * [answers] address of a (unitialized) char**, will contain a non-NULL terminated array of char*
- * [callback_func] function called at most when the answers change; it can examine the array of char* and assign some new char* */
-enum frontend_return ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size, void (*callback_func)(char ** strings));
-
-#endif
diff --git a/mdk-stage1/frontend-common.c b/mdk-stage1/frontend-common.c
deleted file mode 100644
index a66db457a..000000000
--- a/mdk-stage1/frontend-common.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include <probing.h>
-
-#include "frontend.h"
-
-
-void info_message(char *msg, ...)
-{
- va_list args;
- va_start(args, msg);
- vinfo_message(msg, args);
- va_end(args);
-}
-
-void wait_message(char *msg, ...)
-{
- va_list args;
- va_start(args, msg);
- vwait_message(msg, args);
- va_end(args);
-}
-
-void error_message(char *msg, ...)
-{
- va_list args;
- va_start(args, msg);
- verror_message(msg, args);
- va_end(args);
-}
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h
deleted file mode 100644
index 1737ee7e7..000000000
--- a/mdk-stage1/frontend.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * For doc please read doc/documented..frontend.h
- */
-
-#ifndef _FRONTEND_H_
-#define _FRONTEND_H_
-
-#include <stdarg.h>
-
-/* 'unused' atttribute, gcc specific and just to turn down some warnings. */
-#if defined __GNUC__
-#define UNUSED __attribute__((unused))
-#else
-#define UNUSED
-#endif
-
-enum return_type { RETURN_OK, RETURN_BACK, RETURN_ERROR };
-
-void init_frontend(char * welcome_msg);
-void finish_frontend(void);
-
-void error_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* blocking */
-void info_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* blocking */
-void wait_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* non-blocking */
-void remove_wait_message(void);
-
-void init_progression_raw(char *msg, int size);
-void update_progression_raw(int current_size);
-void end_progression_raw(void);
-
-#ifdef ENABLE_BOOTSPLASH
-void init_progression(char *msg, int size);
-void update_progression(int current_size);
-void end_progression(void);
-#else
-#define init_progression init_progression_raw
-#define update_progression update_progression_raw
-#define end_progression end_progression_raw
-#endif
-
-enum return_type ask_yes_no(char *msg);
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice);
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice);
-enum return_type ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size, void (*callback_func)(char ** strings));
-
-void suspend_to_console(void);
-void resume_from_suspend(void);
-
-void verror_message(char *msg, va_list ap);
-void vinfo_message(char *msg, va_list ap);
-void vwait_message(char *msg, va_list ap);
-
-#endif
diff --git a/mdk-stage1/init-libc-headers.h b/mdk-stage1/init-libc-headers.h
deleted file mode 100644
index 55d6f10b3..000000000
--- a/mdk-stage1/init-libc-headers.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mount.h>
-#include <linux/un.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#include <linux/unistd.h>
-#include <sys/select.h>
-#include <sys/ioctl.h>
-
-#ifndef SOCK_STREAM
-#define SOCK_STREAM 1
-#endif
-
-static inline _syscall3(int, syslog, int, type, char *, bufp, int, len);
-static inline _syscall3(int, reboot, int, magic, int, magic2, int, flag);
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c
deleted file mode 100644
index f5a46010b..000000000
--- a/mdk-stage1/init.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef INIT_HEADERS
-#include "init-libc-headers.h"
-#else
-#include INIT_HEADERS
-#endif
-
-#include "config-stage1.h"
-#include <linux/cdrom.h>
-
-#if defined(__powerpc__)
-#define TIOCSCTTY 0x540E
-#endif
-
-char * env[] = {
- "PATH=/usr/bin:/bin:/sbin:/usr/sbin:/mnt/sbin:/mnt/usr/sbin:/mnt/bin:/mnt/usr/bin",
- "LD_LIBRARY_PATH=/lib:/usr/lib:/mnt/lib:/mnt/usr/lib:/usr/X11R6/lib:/mnt/usr/X11R6/lib"
-#if defined(__x86_64__) || defined(__ppc64__)
- ":/lib64:/usr/lib64:/usr/X11R6/lib64:/mnt/lib64:/mnt/usr/lib64:/mnt/usr/X11R6/lib64"
-#endif
- ,
- "HOME=/",
- "TERM=linux",
- "TERMINFO=/etc/terminfo",
- NULL
-};
-
-
-/*
- * this needs to handle the following cases:
- *
- * 1) run from a CD root filesystem
- * 2) run from a read only nfs rooted filesystem
- * 3) run from a floppy
- * 4) run from a floppy that's been loaded into a ramdisk
- *
- */
-
-int testing = 0;
-int klog_pid;
-
-
-void fatal_error(char *msg)
-{
- printf("FATAL ERROR IN INIT: %s\n\nI can't recover from this, please reboot manually and send bugreport.\n", msg);
- select(0, NULL, NULL, NULL, NULL);
-}
-
-void print_error(char *msg)
-{
- printf("E: %s\n", msg);
-}
-
-void print_warning(char *msg)
-{
- printf("W: %s\n", msg);
-}
-
-void print_int_init(int fd, int i)
-{
- char buf[10];
- char * chptr = buf + 9;
- int j = 0;
-
- if (i < 0)
- {
- write(1, "-", 1);
- i = -1 * i;
- }
-
- while (i)
- {
- *chptr-- = '0' + (i % 10);
- j++;
- i = i / 10;
- }
-
- write(fd, chptr + 1, j);
-}
-
-void print_str_init(int fd, char * string)
-{
- write(fd, string, strlen(string));
-}
-
-/* fork to:
- * (1) watch /proc/kmsg and copy the stuff to /dev/tty4
- * (2) listens to /dev/log and copy also this stuff (log from programs)
- */
-void doklog()
-{
- fd_set readset, unixs;
- int in, out, i;
- int log;
- int s;
- int sock = -1;
- struct sockaddr_un sockaddr;
- char buf[1024];
- int readfd;
-
- /* open kernel message logger */
- in = open("/proc/kmsg", O_RDONLY,0);
- if (in < 0) {
- print_error("could not open /proc/kmsg");
- return;
- }
-
- mkdir("/tmp", 0755);
- if ((log = open("/tmp/syslog", O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0) {
- print_error("error opening /tmp/syslog");
- sleep(5);
- return;
- }
-
- if ((klog_pid = fork())) {
- close(in);
- close(log);
- return;
- } else {
- close(0);
- close(1);
- close(2);
- }
-
- out = open("/dev/tty4", O_WRONLY, 0);
- if (out < 0)
- print_warning("couldn't open tty for syslog -- still using /tmp/syslog\n");
-
- /* now open the syslog socket */
-// ############# LINUX 2.4 /dev/log IS BUGGED! --> apparently the syslogs can't reach me, and it's full up after a while
-// sockaddr.sun_family = AF_UNIX;
-// strncpy(sockaddr.sun_path, "/dev/log", UNIX_PATH_MAX);
-// sock = socket(AF_UNIX, SOCK_STREAM, 0);
-// if (sock < 0) {
-// printf("error creating socket: %d\n", errno);
-// sleep(5);
-// }
-//
-// print_str_init(log, "] got socket\n");
-// if (bind(sock, (struct sockaddr *) &sockaddr, sizeof(sockaddr.sun_family) + strlen(sockaddr.sun_path))) {
-// print_str_init(log, "] bind error: ");
-// print_int_init(log, errno);
-// print_str_init(log, "\n");
-// sleep(// }
-//
-// print_str_init(log, "] bound socket\n");
-// chmod("/dev/log", 0666);
-// if (listen(sock, 5)) {
-// print_str_init(log, "] listen error: ");
-// print_int_init(log, errno);
-// print_str_init(log, "\n");
-// sleep(5);
-// }
-
- /* disable on-console syslog output */
- syslog(8, NULL, 1);
-
- print_str_init(log, "] kernel/system logger ok\n");
- FD_ZERO(&unixs);
- while (1) {
- memcpy(&readset, &unixs, sizeof(unixs));
-
- if (sock >= 0)
- FD_SET(sock, &readset);
- FD_SET(in, &readset);
-
- i = select(20, &readset, NULL, NULL, NULL);
- if (i <= 0)
- continue;
-
- /* has /proc/kmsg things to tell us? */
- if (FD_ISSET(in, &readset)) {
- i = read(in, buf, sizeof(buf));
- if (i > 0) {
- if (out >= 0)
- write(out, buf, i);
- write(log, buf, i);
- }
- }
-
- /* examine some fd's in the hope to find some syslog outputs from programs */
- for (readfd = 0; readfd < 20; ++readfd) {
- if (FD_ISSET(readfd, &readset) && FD_ISSET(readfd, &unixs)) {
- i = read(readfd, buf, sizeof(buf));
- if (i > 0) {
- /* grep out the output of RPM telling that it installed/removed some packages */
- if (!strstr(buf, "mdk installed") && !strstr(buf, "mdk removed")) {
- if (out >= 0)
- write(out, buf, i);
- write(log, buf, i);
- }
- } else if (i == 0) {
- /* socket closed */
- close(readfd);
- FD_CLR(readfd, &unixs);
- }
- }
- }
-
- /* the socket has moved, new stuff to do */
- if (sock >= 0 && FD_ISSET(sock, &readset)) {
- s = sizeof(sockaddr);
- readfd = accept(sock, (struct sockaddr *) &sockaddr, &s);
- if (readfd < 0) {
- char * msg_error = "] error in accept\n";
- if (out >= 0)
- write(out, msg_error, strlen(msg_error));
- write(log, msg_error, strlen(msg_error));
- close(sock);
- sock = -1;
- }
- else
- FD_SET(readfd, &unixs);
- }
- }
-}
-
-
-#define LOOP_CLR_FD 0x4C01
-
-void del_loops(void)
-{
- char loopdev[] = "/dev/loop0";
- char chloopdev[] = "/dev/chloop0";
- int i;
- for (i=0; i<8; i++) {
- int fd;
- loopdev[9] = '0' + i;
- fd = open(loopdev, O_RDONLY, 0);
- if (fd > 0) {
- if (!ioctl(fd, LOOP_CLR_FD, 0))
- printf("\t%s\n", loopdev);
- close(fd);
- }
- chloopdev[11] = '0' + i;
- fd = open(chloopdev, O_RDONLY, 0);
- if (fd > 0) {
- if (!ioctl(fd, LOOP_CLR_FD, 0))
- printf("\t%s\n", chloopdev);
- close(fd);
- }
- }
-}
-
-struct filesystem
-{
- char * dev;
- char * name;
- char * fs;
- int mounted;
-};
-
-char* strcat(register char* s,register const char* t)
-{
- char *dest=s;
- s+=strlen(s);
- for (;;) {
- if (!(*s = *t)) break; ++s; ++t;
- }
- return dest;
-}
-
-/* attempt to unmount all filesystems in /proc/mounts */
-void unmount_filesystems(void)
-{
- int fd, size;
- char buf[65535]; /* this should be big enough */
- char *p;
- struct filesystem fs[500];
- int numfs = 0;
- int i, nb;
- int disallow_eject = 0;
-
- printf("unmounting filesystems...\n");
-
- fd = open("/proc/mounts", O_RDONLY, 0);
- if (fd < 1) {
- print_error("failed to open /proc/mounts");
- sleep(2);
- return;
- }
-
- size = read(fd, buf, sizeof(buf) - 1);
- buf[size] = '\0';
-
- close(fd);
-
- p = buf;
- while (*p) {
- fs[numfs].mounted = 1;
- fs[numfs].dev = p;
- while (*p != ' ') p++;
- *p++ = '\0';
- fs[numfs].name = p;
- while (*p != ' ') p++;
- *p++ = '\0';
- fs[numfs].fs = p;
- while (*p != ' ') p++;
- *p++ = '\0';
- while (*p != '\n') p++;
- p++;
- if (!strcmp(fs[numfs].fs, "nfs"))
- disallow_eject = 1;
- if (strcmp(fs[numfs].name, "/")
- && !strstr(fs[numfs].dev, "ram")
- && strcmp(fs[numfs].name, "/dev")
- && strcmp(fs[numfs].name, "/sys")
- && strncmp(fs[numfs].name, "/proc", 5))
- numfs++;
- }
-
- /* Pixel's ultra-optimized sorting algorithm:
- multiple passes trying to umount everything until nothing moves
- anymore (a.k.a holy shotgun method) */
- do {
- nb = 0;
- for (i = 0; i < numfs; i++) {
- /*printf("trying with %s\n", fs[i].name);*/
- del_loops();
- if (fs[i].mounted && umount(fs[i].name) == 0) {
- printf("\t%s\n", fs[i].name);
- fs[i].mounted = 0;
- nb++;
- }
- }
- } while (nb);
-
- for (i = nb = 0; i < numfs; i++)
- if (fs[i].mounted) {
-#ifdef MANDRAKE_MOVE
- if (!strcmp(fs[i].name, "/cdrom") || !strcmp(fs[i].name, "/image_always"))
- continue;
-#endif
- printf("\tumount failed: %s\n", fs[i].name);
- if (strcmp(fs[i].fs, "ext3") == 0) nb++; /* don't count not-ext3 umount failed */
- }
-
-#ifdef MANDRAKE_MOVE
- if (!disallow_eject) {
- fd = open("/proc/fs/supermount/subfs", O_RDONLY, 0);
- if (fd > 0) {
- char devices[100][100];
- int i = 0;
- char * ptr1, * ptr2;
- size = read(fd, buf, sizeof(buf) - 1);
- buf[size] = '\0';
- close(fd);
- ptr1 = buf;
- ptr2 = buf;
- while (*ptr1 && *ptr2) {
- char * ptrf = ptr1;
- while (*ptr2 && *ptr2 != '\n')
- ptr2++;
- while (*ptrf && *ptrf != ' ')
- ptrf++;
- if (*ptrf)
- *ptrf = '\0';
- strcpy(devices[i], ptr1);
- i++;
- if (*ptr2)
- ptr2++;
- ptr1 = ptr2;
- }
- while (i >= 1) {
- i--;
- strcat(devices[i], " release force");
- fd = open("/proc/fs/supermount/subfs", O_WRONLY, 0);
- write(fd, devices[i], strlen(devices[i]));
- close(fd);
- }
- }
- fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK, 0);
- if (fd > 0) {
- ioctl(fd, CDROM_LOCKDOOR, 0);
- close(fd);
- }
- fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK, 0);
- if (fd > 0) {
- ioctl(fd, CDROMEJECT, 0);
- close(fd);
- }
- }
-#endif
-
- if (nb) {
- printf("failed to umount some filesystems\n");
- select(0, NULL, NULL, NULL, NULL);
- }
-}
-
-#define BMAGIC_HARD 0x89ABCDEF
-#define BMAGIC_SOFT 0
-#define BMAGIC_REBOOT 0x01234567
-#define BMAGIC_HALT 0xCDEF0123
-#define BMAGIC_POWEROFF 0x4321FEDC
-int reboot_magic = BMAGIC_REBOOT;
-
-int in_reboot(void)
-{
- int fd;
- if ((fd = open("/var/run/rebootctl", O_RDONLY, 0)) > 0) {
- char buf[100];
- int i = read(fd, buf, sizeof(buf));
- close(fd);
- if (strstr(buf, "halt"))
- reboot_magic = BMAGIC_POWEROFF;
- return i > 0;
- }
- return 0;
-}
-
-int exit_value_proceed = 66;
-int exit_value_restart = 0x35;
-
-int main(int argc, char **argv)
-{
- pid_t installpid, childpid;
- int wait_status;
- int fd;
- int abnormal_termination = 0;
-
- if (argc > 1 && argv[1][0] >= '0' && argv[1][0] <= '9') {
- printf("This is no normal init, sorry.\n"
- "Call `reboot' or `halt' directly.\n");
- return 0;
- }
-
- if (!testing) {
- /* turn off screen blanking */
- printf("\033[9;0]");
- printf("\033[8]");
- }
- else
- printf("*** TESTING MODE *** (pid is %d)\n", getpid());
-
-
- if (!testing) {
- mkdir("/proc", 0755);
- if (mount("/proc", "/proc", "proc", 0, NULL))
- fatal_error("Unable to mount proc filesystem");
- }
-
-
- /* ignore Control-C and keyboard stop signals */
- signal(SIGINT, SIG_IGN);
- signal(SIGTSTP, SIG_IGN);
-
-#ifdef MANDRAKE_MOVE
- /* disallow Ctrl Alt Del to reboot */
- reboot(0xfee1dead, 672274793, BMAGIC_SOFT);
-#endif
-
- if (!testing) {
- fd = open("/dev/console", O_RDWR, 0);
- if (fd < 0)
- fatal_error("failed to open /dev/console");
-
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
- close(fd);
- }
-
-
- /* I set me up as session leader (probably not necessary?) */
- setsid();
-// if (ioctl(0, TIOCSCTTY, NULL))
-// print_error("could not set new controlling tty");
-
- if (!testing) {
- char my_hostname[] = "localhost";
- sethostname(my_hostname, sizeof(my_hostname));
- /* the default domainname (as of 2.0.35) is "(none)", which confuses
- glibc */
- setdomainname("", 0);
- }
-
- if (!testing)
- doklog();
-
- /* Go into normal init mode - keep going, and then do a orderly shutdown
- when:
-
- 1) install exits
- 2) we receive a SIGHUP
- */
-
- do {
- if (!(installpid = fork())) {
- /* child */
- char * child_argv[2];
- child_argv[0] = BINARY;
- child_argv[1] = NULL;
-
- execve(child_argv[0], child_argv, env);
- printf("error in exec of %s :-( [%d]\n", BINARY, errno);
- return 0;
- }
-
- do {
- childpid = wait4(-1, &wait_status, 0, NULL);
- } while (childpid != installpid);
- } while (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_restart);
-
- /* allow Ctrl Alt Del to reboot */
- reboot(0xfee1dead, 672274793, BMAGIC_HARD);
-
- if (in_reboot()) {
- // any exitcode is valid if we're in_reboot
- } else if (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_proceed) {
- kill(klog_pid, 9);
- printf("proceeding, please wait...\n");
- return 0;
- } else if (!WIFEXITED(wait_status) || WEXITSTATUS(wait_status) != 0) {
- printf("exited abnormally :-( ");
- if (WIFSIGNALED(wait_status))
- printf("-- received signal %d", WTERMSIG(wait_status));
- printf("\n");
- abnormal_termination = 1;
- }
-
- if (!abnormal_termination) {
- int i;
- for (i=0; i<50; i++)
- printf("\n"); /* cleanup startkde messages */
- }
-
- if (testing)
- return 0;
-
- sync(); sync();
- sleep(2);
-
- printf("sending termination signals...");
- kill(-1, 15);
- sleep(2);
- printf("done\n");
-
- printf("sending kill signals...");
- kill(-1, 9);
- sleep(2);
- printf("done\n");
-
- unmount_filesystems();
-
- sync(); sync();
-
- if (!abnormal_termination) {
- if (reboot_magic == BMAGIC_REBOOT) {
-#ifdef DEBUG
- printf("automatic reboot in 10 seconds\n");
- sleep(10);
-#endif
- reboot(0xfee1dead, 672274793, reboot_magic);
- } else {
- printf("you may safely poweroff your computer now\n");
- }
- } else {
- printf("you may safely reboot or halt your system\n");
- }
-
- select(0, NULL, NULL, NULL, NULL);
- return 0;
-}
diff --git a/mdk-stage1/insmod-busybox/.cvsignore b/mdk-stage1/insmod-busybox/.cvsignore
deleted file mode 100644
index 26a2c08c9..000000000
--- a/mdk-stage1/insmod-busybox/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-insmod
-insmod-DIET
diff --git a/mdk-stage1/insmod-busybox/Config.h b/mdk-stage1/insmod-busybox/Config.h
deleted file mode 100644
index f02ac0253..000000000
--- a/mdk-stage1/insmod-busybox/Config.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* vi: set sw=4 ts=4: */
-// This file defines the feature set to be compiled into busybox.
-// When you turn things off here, they won't be compiled in at all.
-//
-//// This file is parsed by sed. You MUST use single line comments.
-// i.e. //#define BB_BLAH
-//
-//
-// BusyBox Applications
-#define BB_INSMOD
-// End of Applications List
-//
-//
-//
-// ---------------------------------------------------------
-// This is where feature definitions go. Generally speaking,
-// turning this stuff off makes things a bit smaller (and less
-// pretty/useful).
-//
-//
-//
-// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
-// thereby eliminating the need for the /proc filesystem and thereby saving
-// lots and lots memory for more important things. You can not use this and
-// USE_PROCFS at the same time... NOTE: If you enable this feature, you
-// _must_ have patched the kernel to include the devps patch that is included
-// in the busybox/kernel-patches directory. You will also need to create some
-// device special files in /dev on your embedded system:
-// mknod /dev/mtab c 10 22
-// mknod /dev/ps c 10 21
-// I emailed Linus and this patch will not be going into the stock kernel.
-//#define BB_FEATURE_USE_DEVPS_PATCH
-//
-// enable features that use the /proc filesystem (apps that
-// break without this will tell you on compile)...
-// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
-// at the same time...
-#define BB_FEATURE_USE_PROCFS
-
-//
-// Enable tab completion in the shell (not yet
-// working very well -- so don't turn this on)
-//#define BB_FEATURE_SH_TAB_COMPLETION
-//
-//Turn on extra fbset options
-//#define BB_FEATURE_FBSET_FANCY
-//
-//Turn on fbset readmode support
-//#define BB_FEATURE_FBSET_READMODE
-//
-// You must enable one or both of these features
-// Support insmod/lsmod/rmmod for post 2.1 kernels
-#define BB_FEATURE_NEW_MODULE_INTERFACE
-//
-// Support insmod/lsmod/rmmod for pre 2.1 kernels
-//#define BB_FEATURE_OLD_MODULE_INTERFACE
-//
-// Support module version checking
-//#define BB_FEATURE_INSMOD_VERSION_CHECKING
-//
-// Support for Minix filesystem, version 2
-//#define BB_FEATURE_MINIX2
-//
-//
-// Enable busybox --install [-s]
-// to create links (or symlinks) for all the commands that are
-// compiled into the binary. (needs /proc filesystem)
-// #define BB_FEATURE_INSTALLER
-//
-// Clean up all memory before exiting -- usually not needed
-// as the OS can clean up... Don't enable this unless you
-// have a really good reason for cleaning things up manually.
-//#define BB_FEATURE_CLEAN_UP
-//
-// End of Features List
-//
-//
-//
-//
-//
-//
-//---------------------------------------------------
-// Nothing beyond this point should ever be touched by
-// mere mortals so leave this stuff alone.
-//
-#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
-#define BB_MTAB
-#endif
-//
-#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
-#define BB_CMDEDIT
-#endif
-//
-#ifdef BB_KILLALL
-#ifndef BB_KILL
-#define BB_KILL
-#endif
-#endif
-//
-#ifdef BB_FEATURE_LINUXRC
-#ifndef BB_INIT
-#define BB_INIT
-#endif
-#define BB_LINUXRC
-#endif
-//
-#ifdef BB_GZIP
-#ifndef BB_GUNZIP
-#define BB_GUNZIP
-#endif
-#endif
-//
-#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
-#define BB_NFSMOUNT
-#endif
-//
-#if defined BB_FEATURE_SH_COMMAND_EDITING
-#ifndef BB_FEATURE_USE_TERMIOS
-#define BB_FEATURE_USE_TERMIOS
-#endif
-#endif
-//
-#if defined BB_FEATURE_AUTOWIDTH
-#ifndef BB_FEATURE_USE_TERMIOS
-#define BB_FEATURE_USE_TERMIOS
-#endif
-#endif
-//
-#if defined BB_INSMOD
-#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
-#define BB_FEATURE_NEW_MODULE_INTERFACE
-#endif
-#endif
diff --git a/mdk-stage1/insmod-busybox/Makefile b/mdk-stage1/insmod-busybox/Makefile
deleted file mode 100644
index 236874f96..000000000
--- a/mdk-stage1/insmod-busybox/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
- #******************************************************************************
- #
- # insmod from busybox (i386 only)
- #
- # $Id$
- #
- # Copyright (C) 1999,2000 by Lineo, inc.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-all: insmod libinsmod.a
-
-clean:
- rm -f *.o insmod libinsmod.a
-
-
-FLAGS = -c -Wall -Os -fomit-frame-pointer -D_GNU_SOURCE -DBB_VER='"0.60.5"' -DBB_BT='"2003.04.16-15:25+0000"'
-
-
-insmod: insmod-frontend.o insmod.o utility-standalone.o
- $(DIET) gcc -o $@ $^
- $(STRIPCMD) $@
-
-libinsmod.a: insmod.o utility.o
- ar cru $@ $^
- ranlib $@
-
-insmod-frontend.o: insmod-frontend.c busybox.h
- $(DIET) gcc $(FLAGS) $(INCLUDES) insmod-frontend.c
-
-utility.o: utility.c busybox.h
- $(DIET) gcc $(FLAGS) $(INCLUDES) utility.c
-
-utility-standalone.o: utility.c busybox.h
- $(DIET) gcc $(FLAGS) $(INCLUDES) -o $@ -D_STANDALONE_ utility.c
-
-insmod.o: insmod.c busybox.h
- $(DIET) gcc $(FLAGS) $(INCLUDES) insmod.c
diff --git a/mdk-stage1/insmod-busybox/README b/mdk-stage1/insmod-busybox/README
deleted file mode 100644
index 0ae697e92..000000000
--- a/mdk-stage1/insmod-busybox/README
+++ /dev/null
@@ -1,8 +0,0 @@
-This insmod code comes from busybox-0.60.5
-
-<http://www.busybox.net/>
-
-Suported architectures: x86, x86-64, ppc, arm, sh3, sh4, m68k, mips.
-
-
-gb
diff --git a/mdk-stage1/insmod-busybox/busybox.h b/mdk-stage1/insmod-busybox/busybox.h
deleted file mode 100644
index 9e6052fce..000000000
--- a/mdk-stage1/insmod-busybox/busybox.h
+++ /dev/null
@@ -1,477 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Busybox main internal header file
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
- * Permission has been granted to redistribute this code under the GPL.
- *
- */
-#ifndef _BB_INTERNAL_H_
-#define _BB_INTERNAL_H_ 1
-
-#include "Config.h"
-
-#ifdef DMALLOC
-#include "dmalloc.h"
-#endif
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-/* for the _syscall() macros */
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-#include <linux/kernel.h>
-
-/* Some useful definitions */
-#define FALSE ((int) 1)
-#define TRUE ((int) 0)
-
-/* for mtab.c */
-#define MTAB_GETMOUNTPT '1'
-#define MTAB_GETDEVICE '2'
-
-#define BUF_SIZE 8192
-#define EXPAND_ALLOC 1024
-
-
-#define isBlank(ch) (((ch) == ' ') || ((ch) == '\t'))
-#define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9'))
-#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
-#define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '['))
-
-/* Macros for min/max. */
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
-#endif
-
-
-/* I don't like nested includes, but the string and io functions are used
- * too often
- */
-#include <stdio.h>
-#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
-# include <string.h>
-# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
-# include <memory.h>
-# endif
-# define memzero(s, n) memset ((void *)(s), 0, (n))
-#else
-# include <strings.h>
-# define strchr index
-# define strrchr rindex
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-# define memzero(s, n) bzero((s), (n))
-#endif
-
-
-enum Location {
- _BB_DIR_ROOT = 0,
- _BB_DIR_BIN,
- _BB_DIR_SBIN,
- _BB_DIR_USR_BIN,
- _BB_DIR_USR_SBIN
-};
-
-struct BB_applet {
- const char* name;
- int (*main)(int argc, char** argv);
- enum Location location;
- const char* usage;
-};
-/* From busybox.c */
-extern const struct BB_applet applets[];
-
-extern int ar_main(int argc, char **argv);
-extern int basename_main(int argc, char **argv);
-extern int bogomips_main(int argc, char **argv);
-extern int busybox_main(int argc, char** argv);
-extern int cat_main(int argc, char** argv);
-extern int chmod_chown_chgrp_main(int argc, char** argv);
-extern int chroot_main(int argc, char** argv);
-extern int chvt_main(int argc, char** argv);
-extern int clear_main(int argc, char** argv);
-extern int cp_mv_main(int argc, char** argv);
-extern int cut_main(int argc, char** argv);
-extern int date_main(int argc, char** argv);
-extern int dc_main(int argc, char** argv);
-extern int dd_main(int argc, char** argv);
-extern int dirname_main(int argc, char** argv);
-extern int deallocvt_main(int argc, char** argv);
-extern int df_main(int argc, char** argv);
-extern int dmesg_main(int argc, char** argv);
-extern int dos2unix_main(int argc, char** argv);
-extern int du_main(int argc, char** argv);
-extern int dumpkmap_main(int argc, char** argv);
-extern int dutmp_main(int argc, char** argv);
-extern int echo_main(int argc, char** argv);
-extern int expr_main(int argc, char** argv);
-extern int false_main(int argc, char** argv);
-extern int fbset_main(int argc, char** argv);
-extern int fdisk_main(int argc, char** argv);
-extern int fdflush_main(int argc, char **argv);
-extern int fsck_minix_main(int argc, char **argv);
-extern int find_main(int argc, char** argv);
-extern int free_main(int argc, char** argv);
-extern int freeramdisk_main(int argc, char** argv);
-extern int getopt_main(int argc, char** argv);
-extern int grep_main(int argc, char** argv);
-extern int gunzip_main (int argc, char** argv);
-extern int gzip_main(int argc, char** argv);
-extern int halt_main(int argc, char** argv);
-extern int head_main(int argc, char** argv);
-extern int hostid_main(int argc, char** argv);
-extern int hostname_main(int argc, char** argv);
-extern int id_main(int argc, char** argv);
-extern int init_main(int argc, char** argv);
-extern int insmod_main(int argc, char** argv);
-extern int kill_main(int argc, char** argv);
-extern int length_main(int argc, char** argv);
-extern int ln_main(int argc, char** argv);
-extern int loadacm_main(int argc, char** argv);
-extern int loadfont_main(int argc, char** argv);
-extern int loadkmap_main(int argc, char** argv);
-extern int losetup_main(int argc, char** argv);
-extern int logger_main(int argc, char **argv);
-extern int logname_main(int argc, char **argv);
-extern int ls_main(int argc, char** argv);
-extern int lsmod_main(int argc, char** argv);
-extern int makedevs_main(int argc, char** argv);
-extern int md5sum_main(int argc, char** argv);
-extern int mkdir_main(int argc, char** argv);
-extern int mkfifo_main(int argc, char **argv);
-extern int mkfs_minix_main(int argc, char **argv);
-extern int mknod_main(int argc, char** argv);
-extern int mkswap_main(int argc, char** argv);
-extern int mktemp_main(int argc, char **argv);
-extern int nc_main(int argc, char** argv);
-extern int more_main(int argc, char** argv);
-extern int mount_main(int argc, char** argv);
-extern int mt_main(int argc, char** argv);
-extern int nslookup_main(int argc, char **argv);
-extern int ping_main(int argc, char **argv);
-extern int poweroff_main(int argc, char **argv);
-extern int printf_main(int argc, char** argv);
-extern int ps_main(int argc, char** argv);
-extern int pwd_main(int argc, char** argv);
-extern int rdate_main(int argc, char** argv);
-extern int reboot_main(int argc, char** argv);
-extern int renice_main(int argc, char** argv);
-extern int reset_main(int argc, char** argv);
-extern int rm_main(int argc, char** argv);
-extern int rmdir_main(int argc, char **argv);
-extern int rmmod_main(int argc, char** argv);
-extern int sed_main(int argc, char** argv);
-extern int sfdisk_main(int argc, char** argv);
-extern int setkeycodes_main(int argc, char** argv);
-extern int shell_main(int argc, char** argv);
-extern int sleep_main(int argc, char** argv);
-extern int sort_main(int argc, char** argv);
-extern int swap_on_off_main(int argc, char** argv);
-extern int sync_main(int argc, char** argv);
-extern int syslogd_main(int argc, char **argv);
-extern int tail_main(int argc, char** argv);
-extern int tar_main(int argc, char** argv);
-extern int tee_main(int argc, char** argv);
-extern int test_main(int argc, char** argv);
-extern int telnet_main(int argc, char** argv);
-extern int touch_main(int argc, char** argv);
-extern int tr_main(int argc, char** argv);
-extern int true_main(int argc, char** argv);
-extern int tput_main(int argc, char** argv);
-extern int tryopen_main(int argc, char** argv);
-extern int tty_main(int argc, char** argv);
-extern int umount_main(int argc, char** argv);
-extern int uname_main(int argc, char** argv);
-extern int uniq_main(int argc, char** argv);
-extern int unix2dos_main(int argc, char** argv);
-extern int unrpm_main(int argc, char** argv);
-extern int update_main(int argc, char** argv);
-extern int uptime_main(int argc, char** argv);
-extern int usleep_main(int argc, char** argv);
-extern int uuencode_main(int argc, char** argv);
-extern int uudecode_main(int argc, char** argv);
-extern int wc_main(int argc, char** argv);
-extern int wget_main(int argc, char** argv);
-extern int which_main(int argc, char** argv);
-extern int whoami_main(int argc, char** argv);
-extern int xargs_main(int argc, char** argv);
-extern int yes_main(int argc, char** argv);
-
-extern const char ar_usage[];
-extern const char basename_usage[];
-extern const char cat_usage[];
-extern const char chgrp_usage[];
-extern const char chmod_usage[];
-extern const char chown_usage[];
-extern const char chroot_usage[];
-extern const char chvt_usage[];
-extern const char clear_usage[];
-extern const char cp_usage[];
-extern const char cut_usage[];
-extern const char date_usage[];
-extern const char dc_usage[];
-extern const char dd_usage[];
-extern const char deallocvt_usage[];
-extern const char df_usage[];
-extern const char dirname_usage[];
-extern const char dmesg_usage[];
-extern const char dos2unix_usage[];
-extern const char du_usage[];
-extern const char dumpkmap_usage[];
-extern const char dutmp_usage[];
-extern const char echo_usage[];
-extern const char expr_usage[];
-extern const char false_usage[];
-extern const char fdflush_usage[];
-extern const char find_usage[];
-extern const char free_usage[];
-extern const char freeramdisk_usage[];
-extern const char fsck_minix_usage[];
-extern const char grep_usage[];
-extern const char gunzip_usage[];
-extern const char gzip_usage[];
-extern const char halt_usage[];
-extern const char head_usage[];
-extern const char hostid_usage[];
-extern const char hostname_usage[];
-extern const char id_usage[];
-extern const char insmod_usage[];
-extern const char kill_usage[];
-extern const char killall_usage[];
-extern const char length_usage[];
-extern const char ln_usage[];
-extern const char loadacm_usage[];
-extern const char loadfont_usage[];
-extern const char loadkmap_usage[];
-extern const char logger_usage[];
-extern const char logname_usage[];
-extern const char ls_usage[];
-extern const char lsmod_usage[];
-extern const char makedevs_usage[];
-extern const char md5sum_usage[];
-extern const char mkdir_usage[];
-extern const char mkfifo_usage[];
-extern const char mkfs_minix_usage[];
-extern const char mknod_usage[];
-extern const char mkswap_usage[];
-extern const char mktemp_usage[];
-extern const char more_usage[];
-extern const char mount_usage[];
-extern const char mt_usage[];
-extern const char mv_usage[];
-extern const char nc_usage[];
-extern const char nslookup_usage[];
-extern const char ping_usage[];
-extern const char poweroff_usage[];
-extern const char printf_usage[];
-extern const char ps_usage[];
-extern const char pwd_usage[];
-extern const char rdate_usage[];
-extern const char reboot_usage[];
-extern const char renice_usage[];
-extern const char reset_usage[];
-extern const char rm_usage[];
-extern const char rmdir_usage[];
-extern const char rmmod_usage[];
-extern const char sed_usage[];
-extern const char setkeycodes_usage[];
-extern const char shell_usage[];
-extern const char sleep_usage[];
-extern const char sort_usage[];
-extern const char swapoff_usage[];
-extern const char swapon_usage[];
-extern const char sync_usage[];
-extern const char syslogd_usage[];
-extern const char tail_usage[];
-extern const char tar_usage[];
-extern const char tee_usage[];
-extern const char telnet_usage[];
-extern const char test_usage[];
-extern const char touch_usage[];
-extern const char tr_usage[];
-extern const char true_usage[];
-extern const char tty_usage[];
-extern const char umount_usage[];
-extern const char uname_usage[];
-extern const char uniq_usage[];
-extern const char unix2dos_usage[];
-extern const char unrpm_usage[];
-extern const char update_usage[];
-extern const char uptime_usage[];
-extern const char usleep_usage[];
-extern const char uudecode_usage[];
-extern const char uuencode_usage[];
-extern const char wc_usage[];
-extern const char wget_usage[];
-extern const char which_usage[];
-extern const char whoami_usage[];
-extern const char xargs_usage[];
-extern const char yes_usage[];
-
-extern const char *applet_name;
-
-extern void usage(const char *usage) __attribute__ ((noreturn));
-extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void logperror(char *s);
-extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-
-const char *modeString(int mode);
-const char *timeString(time_t timeVal);
-int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
-int isDevice(const char *name);
-
-typedef struct ino_dev_hash_bucket_struct {
- struct ino_dev_hash_bucket_struct *next;
- ino_t ino;
- dev_t dev;
- char name[1];
-} ino_dev_hashtable_bucket_t;
-int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
-void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
-void reset_ino_dev_hashtable(void);
-
-int copyFile(const char *srcName, const char *destName,
- int setModes, int followLinks, int forceFlag);
-int copySubFile(int srcFd, int dstFd, size_t remaining);
-char *buildName(const char *dirName, const char *fileName);
-int makeString(int argc, const char **argv, char *buf, int bufLen);
-char *getChunk(int size);
-char *chunkstrdup(const char *str);
-void freeChunks(void);
-int fullWrite(int fd, const char *buf, int len);
-int fullRead(int fd, char *buf, int len);
-int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
- int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
- int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
- void* userData);
-
-extern int createPath (const char *name, int mode);
-extern int parse_mode( const char* s, mode_t* theMode);
-
-extern int get_kernel_revision(void);
-
-extern int get_console_fd(char* tty_name);
-extern struct mntent *findMountPoint(const char *name, const char *table);
-extern void write_mtab(char* blockDevice, char* directory,
- char* filesystemType, long flags, char* string_flags);
-extern void erase_mtab(const char * name);
-extern void mtab_read(void);
-extern char *mtab_first(void **iter);
-extern char *mtab_next(void **iter);
-extern char *mtab_getinfo(const char *match, const char which);
-extern int check_wildcard_match(const char* text, const char* pattern);
-extern long getNum (const char *cp);
-extern pid_t* findPidByName( char* pidName);
-extern int find_real_root_device_name(char* name);
-extern char *get_line_from_file(FILE *file);
-extern void print_file(FILE *file);
-extern int print_file_by_name(char *filename);
-extern char process_escape_sequence(char **ptr);
-extern char *get_last_path_component(char *path);
-// extern void xregcomp(regex_t *preg, const char *regex, int cflags);
-
-#ifndef DMALLOC
-extern void *xmalloc (size_t size);
-extern void *xrealloc(void *old, size_t size);
-extern void *xcalloc(size_t nmemb, size_t size);
-extern char *xstrdup (const char *s);
-#endif
-extern char *xstrndup (const char *s, int n);
-
-
-/* These parse entries in /etc/passwd and /etc/group. This is desirable
- * for BusyBox since we want to avoid using the glibc NSS stuff, which
- * increases target size and is often not needed embedded systems. */
-extern long my_getpwnam(char *name);
-extern long my_getgrnam(char *name);
-extern void my_getpwuid(char *name, long uid);
-extern void my_getgrgid(char *group, long gid);
-extern long my_getpwnamegid(char *name);
-
-extern int device_open(char *device, int mode);
-
-#if defined BB_FEATURE_MOUNT_LOOP
-extern int del_loop(const char *device);
-extern int set_loop(const char *device, const char *file, int offset, int *loopro);
-extern char *find_unused_loop_device (void);
-#endif
-
-
-#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
-extern int vdprintf(int d, const char *format, va_list ap);
-#endif
-
-#if defined BB_NFSMOUNT
-int nfsmount(const char *spec, const char *node, int *flags,
- char **extra_opts, char **mount_opts, int running_bg);
-#endif
-
-#ifndef RB_POWER_OFF
-/* Stop system and switch power off if possible. */
-#define RB_POWER_OFF 0x4321fedc
-#endif
-
-/* Include our own copy of struct sysinfo to avoid binary compatability
- * problems with Linux 2.4, which changed things. Grumble, grumble. */
-//struct sysinfo {
-// long uptime; /* Seconds since boot */
-// unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
-// unsigned long totalram; /* Total usable main memory size */
-// unsigned long freeram; /* Available memory size */
-// unsigned long sharedram; /* Amount of shared memory */
-// unsigned long bufferram; /* Memory used by buffers */
-// unsigned long totalswap; /* Total swap space size */
-// unsigned long freeswap; /* swap space still available */
-// unsigned short procs; /* Number of current processes */
-// unsigned long totalhigh; /* Total high memory size */
-// unsigned long freehigh; /* Available high memory size */
-// unsigned int mem_unit; /* Memory unit size in bytes */
-// char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
-//};
-extern int sysinfo (struct sysinfo* info);
-
-/* Bit map related macros -- libc5 doens't provide these... sigh. */
-#ifndef setbit
-#define NBBY CHAR_BIT
-#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
-#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
-#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
-#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
-#endif
-
-/* Merge from busybox 0.60.5 */
-#define error_msg errorMsg
-#define perror_msg(FORMAT,...) error_msg(FORMAT ": %s", ## __VA_ARGS__, strerror(errno))
-#define recursive_action recursiveAction
-
-#define safe_strncpy(DST, SRC, SIZE) do { \
- (DST)[SIZE-1] = '\0'; \
- return strncpy((DST), (SRC),(SIZE)-1); \
-} while (0)
-
-#endif /* _BB_INTERNAL_H_ */
diff --git a/mdk-stage1/insmod-busybox/insmod-frontend.c b/mdk-stage1/insmod-busybox/insmod-frontend.c
deleted file mode 100644
index 963a96893..000000000
--- a/mdk-stage1/insmod-busybox/insmod-frontend.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdio.h>
-
-
-int insmod_main( int argc, char **argv);
-
-int main( int argc, char **argv)
-{
- printf("Using insmod provided by busybox.\n");
- return insmod_main(argc, argv);
-}
diff --git a/mdk-stage1/insmod-busybox/insmod.c b/mdk-stage1/insmod-busybox/insmod.c
deleted file mode 100644
index e6e5b8f5f..000000000
--- a/mdk-stage1/insmod-busybox/insmod.c
+++ /dev/null
@@ -1,3758 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Mini insmod implementation for busybox
- *
- * This version of insmod supports x86, ARM, SH3/4, powerpc, m68k,
- * MIPS, and x86-64.
- *
- *
- * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
- * Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
- * Written by Erik Andersen and Ron Alder <alder@lineo.com>
- *
- * Modified by Bryan Rittmeyer <bryan@ixiacom.com> to support SH4
- * and (theoretically) SH3. I have only tested SH4 in little endian mode.
- *
- * Modified by Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
- * Nicolas Ferre <nicolas.ferre@alcove.fr> to support ARM7TDMI. Only
- * very minor changes required to also work with StrongArm and presumably
- * all ARM based systems.
- *
- * Magnus Damm <damm@opensource.se> 22-May-2002.
- * The plt and got code are now using the same structs.
- * Added generic linked list code to fully support PowerPC.
- * Replaced the mess in arch_apply_relocation() with architecture blocks.
- * The arch_create_got() function got cleaned up with architecture blocks.
- * These blocks should be easy maintain and sync with obj_xxx.c in modutils.
- *
- * Magnus Damm <damm@opensource.se> added PowerPC support 20-Feb-2001.
- * PowerPC specific code stolen from modutils-2.3.16,
- * written by Paul Mackerras, Copyright 1996, 1997 Linux International.
- * I've only tested the code on mpc8xx platforms in big-endian mode.
- * Did some cleanup and added BB_USE_xxx_ENTRIES...
- *
- * Quinn Jensen <jensenq@lineo.com> added MIPS support 23-Feb-2001.
- * based on modutils-2.4.2
- * MIPS specific support for Elf loading and relocation.
- * Copyright 1996, 1997 Linux International.
- * Contributed by Ralf Baechle <ralf@gnu.ai.mit.edu>
- *
- * Based almost entirely on the Linux modutils-2.3.11 implementation.
- * Copyright 1996, 1997 Linux International.
- * New implementation contributed by Richard Henderson <rth@tamu.edu>
- * Based on original work by Bjorn Ekwall <bj0rn@blox.se>
- * Restructured (and partly rewritten) by:
- * Björn Ekwall <bj0rn@blox.se> February 1999
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "../insmod.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <errno.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <assert.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/utsname.h>
-#include "busybox.h"
-
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-# undef BB_FEATURE_OLD_MODULE_INTERFACE
-# define new_sys_init_module init_module
-#else
-# define old_sys_init_module init_module
-#endif
-
-/* FIXME: Remove once we switched to dietlibc 0.22 */
-#if 0
-
-#undef new_sys_init_module
-#define __NR_new_sys_init_module __NR_init_module
-struct new_module;
-_syscall2(int, new_sys_init_module, const char *, name,
- const struct new_module *, info)
-
-#undef old_sys_init_module
-#define __NR_old_sys_init_module __NR_init_module
-struct old_mod_routines;
-struct old_symbol_table;
-_syscall5(int, old_sys_init_module, const char *, name, char *, code,
- unsigned, codesize, struct old_mod_routines *, routines,
- struct old_symbol_table *, symtab)
-
-_syscall1(int, delete_module, const char *, name)
-
-#if defined(__i386__) || defined(__m68k__) || defined(__arm__)
-/* Jump through hoops to fixup error return codes */
-#define __NR__create_module __NR_create_module
-static inline _syscall2(long, _create_module, const char *, name, size_t,
- size)
-unsigned long create_module(const char *name, size_t size)
-{
- long ret = _create_module(name, size);
-
- if (ret == -1 && errno > 125) {
- ret = -errno;
- errno = 0;
- }
- return ret;
-}
-#else
-_syscall2(unsigned long, create_module, const char *, name, size_t, size)
-#endif
-
-#endif
-
-#ifdef BB_FEATURE_INSMOD_LOADINKMEM
-#define LOADBITS 0
-#else
-#define LOADBITS 1
-#endif
-
-#if defined(__arm__)
-#define BB_USE_PLT_ENTRIES
-#define BB_PLT_ENTRY_SIZE 8
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 8
-#define BB_USE_SINGLE
-
-#define MATCH_MACHINE(x) (x == EM_ARM)
-#define SHT_RELM SHT_REL
-#define Elf32_RelM Elf32_Rel
-#define ELFCLASSM ELFCLASS32
-#endif
-
-#if defined(__i386__)
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 4
-#define BB_USE_SINGLE
-
-#ifndef EM_486
-#define MATCH_MACHINE(x) (x == EM_386)
-#else
-#define MATCH_MACHINE(x) (x == EM_386 || x == EM_486)
-#endif
-
-#define SHT_RELM SHT_REL
-#define Elf32_RelM Elf32_Rel
-#define ELFCLASSM ELFCLASS32
-#endif
-
-#if defined(__x86_64__)
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 8
-#define BB_USE_SINGLE
-
-#define MATCH_MACHINE(x) (x == EM_X86_64)
-
-#define SHT_RELM SHT_RELA
-#define Elf64_RelM Elf64_Rela
-#define ELFCLASSM ELFCLASS64
-#endif
-
-#if defined(__mc68000__)
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 4
-#define BB_USE_SINGLE
-
-#define MATCH_MACHINE(x) (x == EM_68K)
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
-#endif
-
-#if defined(__mips__)
-/* Account for ELF spec changes. */
-#ifndef EM_MIPS_RS3_LE
-#ifdef EM_MIPS_RS4_BE
-#define EM_MIPS_RS3_LE EM_MIPS_RS4_BE
-#else
-#define EM_MIPS_RS3_LE 10
-#endif
-#endif /* !EM_MIPS_RS3_LE */
-
-#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
-#define SHT_RELM SHT_REL
-#define Elf32_RelM Elf32_Rel
-#define ELFCLASSM ELFCLASS32
-#define ARCHDATAM "__dbe_table"
-#endif
-
-#if defined(__powerpc__)
-#define BB_USE_PLT_ENTRIES
-#define BB_PLT_ENTRY_SIZE 16
-#define BB_USE_PLT_LIST
-#define BB_LIST_ARCHTYPE ElfW(Addr)
-#define BB_USE_LIST
-
-#define MATCH_MACHINE(x) (x == EM_PPC)
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
-#define ELFCLASSM ELFCLASS32
-#define ARCHDATAM "__ftr_fixup"
-#endif
-
-#if defined(__sh__)
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 4
-#define BB_USE_SINGLE
-
-#define MATCH_MACHINE(x) (x == EM_SH)
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
-#define ELFCLASSM ELFCLASS32
-
-/* the SH changes have only been tested on the SH4 in =little endian= mode */
-/* I'm not sure about big endian, so let's warn: */
-
-#if (defined(__SH4__) || defined(__SH3__)) && defined(__BIG_ENDIAN__)
-#error insmod.c may require changes for use on big endian SH4/SH3
-#endif
-
-/* it may or may not work on the SH1/SH2... So let's error on those
- also */
-#if (defined(__sh__) && (!(defined(__SH3__) || defined(__SH4__))))
-#error insmod.c may require changes for non-SH3/SH4 use
-#endif
-#endif
-
-#ifndef SHT_RELM
-#error Sorry, but insmod.c does not yet support this architecture...
-#endif
-
-//----------------------------------------------------------------------------
-//--------modutils module.h, lines 45-242
-//----------------------------------------------------------------------------
-
-/* Definitions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#ifndef MODUTILS_MODULE_H
-#define MODUTILS_MODULE_H
-
-/* This file contains the structures used by the 2.0 and 2.1 kernels.
- We do not use the kernel headers directly because we do not wish
- to be dependant on a particular kernel version to compile insmod. */
-
-
-/*======================================================================*/
-/* The structures used by Linux 2.0. */
-
-/* The symbol format used by get_kernel_syms(2). */
-struct old_kernel_sym
-{
- unsigned long value;
- char name[60];
-};
-
-struct old_module_ref
-{
- unsigned long module; /* kernel addresses */
- unsigned long next;
-};
-
-struct old_module_symbol
-{
- unsigned long addr;
- unsigned long name;
-};
-
-struct old_symbol_table
-{
- int size; /* total, including string table!!! */
- int n_symbols;
- int n_refs;
- struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */
- struct old_module_ref ref[0]; /* actual size defined by n_refs */
-};
-
-struct old_mod_routines
-{
- unsigned long init;
- unsigned long cleanup;
-};
-
-struct old_module
-{
- unsigned long next;
- unsigned long ref; /* the list of modules that refer to me */
- unsigned long symtab;
- unsigned long name;
- int size; /* size of module in pages */
- unsigned long addr; /* address of module */
- int state;
- unsigned long cleanup; /* cleanup routine */
-};
-
-/* Sent to init_module(2) or'ed into the code size parameter. */
-static const int OLD_MOD_AUTOCLEAN = 0x40000000; /* big enough, but no sign problems... */
-
-int get_kernel_syms(struct old_kernel_sym *);
-int old_sys_init_module(const char *name, char *code, unsigned codesize,
- struct old_mod_routines *, struct old_symbol_table *);
-
-/*======================================================================*/
-/* For sizeof() which are related to the module platform and not to the
- environment isnmod is running in, use sizeof_xx instead of sizeof(xx). */
-
-#define tgt_sizeof_char sizeof(char)
-#define tgt_sizeof_short sizeof(short)
-#define tgt_sizeof_int sizeof(int)
-#define tgt_sizeof_long sizeof(long)
-#define tgt_sizeof_char_p sizeof(char *)
-#define tgt_sizeof_void_p sizeof(void *)
-#define tgt_long long
-
-#if defined(__sparc__) && !defined(__sparc_v9__) && defined(ARCH_sparc64)
-#undef tgt_sizeof_long
-#undef tgt_sizeof_char_p
-#undef tgt_sizeof_void_p
-#undef tgt_long
-static const int tgt_sizeof_long = 8;
-static const int tgt_sizeof_char_p = 8;
-static const int tgt_sizeof_void_p = 8;
-#define tgt_long long long
-#endif
-
-/*======================================================================*/
-/* The structures used in Linux 2.1. */
-
-/* Note: new_module_symbol does not use tgt_long intentionally */
-struct new_module_symbol
-{
- unsigned long value;
- unsigned long name;
-};
-
-struct new_module_persist;
-
-struct new_module_ref
-{
- unsigned tgt_long dep; /* kernel addresses */
- unsigned tgt_long ref;
- unsigned tgt_long next_ref;
-};
-
-struct new_module
-{
- unsigned tgt_long size_of_struct; /* == sizeof(module) */
- unsigned tgt_long next;
- unsigned tgt_long name;
- unsigned tgt_long size;
-
- tgt_long usecount;
- unsigned tgt_long flags; /* AUTOCLEAN et al */
-
- unsigned nsyms;
- unsigned ndeps;
-
- unsigned tgt_long syms;
- unsigned tgt_long deps;
- unsigned tgt_long refs;
- unsigned tgt_long init;
- unsigned tgt_long cleanup;
- unsigned tgt_long ex_table_start;
- unsigned tgt_long ex_table_end;
-#ifdef __alpha__
- unsigned tgt_long gp;
-#endif
- /* Everything after here is extension. */
- unsigned tgt_long persist_start;
- unsigned tgt_long persist_end;
- unsigned tgt_long can_unload;
- unsigned tgt_long runsize;
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
- const char *kallsyms_start; /* All symbols for kernel debugging */
- const char *kallsyms_end;
- const char *archdata_start; /* arch specific data for module */
- const char *archdata_end;
- const char *kernel_data; /* Reserved for kernel internal use */
-#endif
-};
-
-#ifdef ARCHDATAM
-#define ARCHDATA_SEC_NAME ARCHDATAM
-#else
-#define ARCHDATA_SEC_NAME "__archdata"
-#endif
-#define KALLSYMS_SEC_NAME "__kallsyms"
-
-
-struct new_module_info
-{
- unsigned long addr;
- unsigned long size;
- unsigned long flags;
- long usecount;
-};
-
-/* Bits of module.flags. */
-static const int NEW_MOD_RUNNING = 1;
-static const int NEW_MOD_DELETED = 2;
-static const int NEW_MOD_AUTOCLEAN = 4;
-static const int NEW_MOD_VISITED = 8;
-static const int NEW_MOD_USED_ONCE = 16;
-
-int new_sys_init_module(const char *name, const struct new_module *);
-int query_module(const char *name, int which, void *buf, size_t bufsize,
- size_t *ret);
-
-/* Values for query_module's which. */
-
-static const int QM_MODULES = 1;
-static const int QM_DEPS = 2;
-static const int QM_REFS = 3;
-static const int QM_SYMBOLS = 4;
-static const int QM_INFO = 5;
-
-/*======================================================================*/
-/* The system calls unchanged between 2.0 and 2.1. */
-
-unsigned long create_module(const char *, size_t);
-int delete_module(const char *);
-
-
-#endif /* module.h */
-
-//----------------------------------------------------------------------------
-//--------end of modutils module.h
-//----------------------------------------------------------------------------
-
-
-
-//----------------------------------------------------------------------------
-//--------modutils obj.h, lines 253-462
-//----------------------------------------------------------------------------
-
-/* Elf object file loading and relocation routines.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#ifndef MODUTILS_OBJ_H
-static const int MODUTILS_OBJ_H = 1;
-
-/* The relocatable object is manipulated using elfin types. */
-
-#include <stdio.h>
-#include <elf.h>
-#include <endian.h>
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define ELFDATAM ELFDATA2LSB
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define ELFDATAM ELFDATA2MSB
-#endif
-
-#ifndef ElfW
-# if ELFCLASSM == ELFCLASS32
-# define ElfW(x) Elf32_ ## x
-# define ELFW(x) ELF32_ ## x
-# else
-# define ElfW(x) Elf64_ ## x
-# define ELFW(x) ELF64_ ## x
-# endif
-#endif
-
-/* For some reason this is missing from libc5. */
-#ifndef ELF32_ST_INFO
-# define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
-#endif
-
-#ifndef ELF64_ST_INFO
-# define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
-#endif
-
-struct obj_string_patch;
-struct obj_symbol_patch;
-
-struct obj_section
-{
- ElfW(Shdr) header;
- const char *name;
- char *contents;
- struct obj_section *load_next;
- int idx;
-};
-
-struct obj_symbol
-{
- struct obj_symbol *next; /* hash table link */
- const char *name;
- unsigned long value;
- unsigned long size;
- int secidx; /* the defining section index/module */
- int info;
- int ksymidx; /* for export to the kernel symtab */
- int referenced; /* actually used in the link */
-};
-
-/* Hardcode the hash table size. We shouldn't be needing so many
- symbols that we begin to degrade performance, and we get a big win
- by giving the compiler a constant divisor. */
-
-#define HASH_BUCKETS 521
-
-struct obj_file
-{
- ElfW(Ehdr) header;
- ElfW(Addr) baseaddr;
- struct obj_section **sections;
- struct obj_section *load_order;
- struct obj_section **load_order_search_start;
- struct obj_string_patch *string_patches;
- struct obj_symbol_patch *symbol_patches;
- int (*symbol_cmp)(const char *, const char *);
- unsigned long (*symbol_hash)(const char *);
- unsigned long local_symtab_size;
- struct obj_symbol **local_symtab;
- struct obj_symbol *symtab[HASH_BUCKETS];
-};
-
-enum obj_reloc
-{
- obj_reloc_ok,
- obj_reloc_overflow,
- obj_reloc_dangerous,
- obj_reloc_unhandled
-};
-
-struct obj_string_patch
-{
- struct obj_string_patch *next;
- int reloc_secidx;
- ElfW(Addr) reloc_offset;
- ElfW(Addr) string_offset;
-};
-
-struct obj_symbol_patch
-{
- struct obj_symbol_patch *next;
- int reloc_secidx;
- ElfW(Addr) reloc_offset;
- struct obj_symbol *sym;
-};
-
-
-/* Generic object manipulation routines. */
-
-static unsigned long obj_elf_hash(const char *);
-
-static unsigned long obj_elf_hash_n(const char *, unsigned long len);
-
-static struct obj_symbol *obj_find_symbol (struct obj_file *f,
- const char *name);
-
-static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
- struct obj_symbol *sym);
-
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
-static void obj_set_symbol_compare(struct obj_file *f,
- int (*cmp)(const char *, const char *),
- unsigned long (*hash)(const char *));
-#endif
-
-static struct obj_section *obj_find_section (struct obj_file *f,
- const char *name);
-
-static void obj_insert_section_load_order (struct obj_file *f,
- struct obj_section *sec);
-
-static struct obj_section *obj_create_alloced_section (struct obj_file *f,
- const char *name,
- unsigned long align,
- unsigned long size);
-
-static struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
- const char *name,
- unsigned long align,
- unsigned long size);
-
-static void *obj_extend_section (struct obj_section *sec, unsigned long more);
-
-static int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
- const char *string);
-
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-static int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
- struct obj_symbol *sym);
-#endif
-
-static int obj_check_undefineds(struct obj_file *f);
-
-static void obj_allocate_commons(struct obj_file *f);
-
-static unsigned long obj_load_size (struct obj_file *f);
-
-static int obj_relocate (struct obj_file *f, ElfW(Addr) base);
-
-static struct obj_file *obj_load(FILE *f, int loadprogbits);
-
-static int obj_create_image (struct obj_file *f, char *image);
-
-/* Architecture specific manipulation routines. */
-
-static struct obj_file *arch_new_file (void);
-
-static struct obj_section *arch_new_section (void);
-
-static struct obj_symbol *arch_new_symbol (void);
-
-static enum obj_reloc arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- ElfW(RelM) *rel, ElfW(Addr) value);
-
-static void arch_create_got (struct obj_file *f);
-
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-static int arch_init_module (struct obj_file *f, struct new_module *);
-#endif
-
-#endif /* obj.h */
-//----------------------------------------------------------------------------
-//--------end of modutils obj.h
-//----------------------------------------------------------------------------
-
-
-
-
-
-#define _PATH_MODULES "/lib/modules"
-static const int STRVERSIONLEN = 32;
-
-/*======================================================================*/
-
-static const int flag_force_load = 1;
-static const int flag_autoclean = 0;
-static const int flag_quiet = 0;
-static const int flag_export = 1;
-
-
-/*======================================================================*/
-
-#if defined(BB_USE_LIST)
-
-struct arch_list_entry
-{
- struct arch_list_entry *next;
- BB_LIST_ARCHTYPE addend;
- int offset;
- int inited : 1;
-};
-
-#endif
-
-#if defined(BB_USE_SINGLE)
-
-struct arch_single_entry
-{
- int offset;
- int inited : 1;
- int allocated : 1;
-};
-
-#endif
-
-#if defined(__mips__)
-struct mips_hi16
-{
- struct mips_hi16 *next;
- Elf32_Addr *addr;
- Elf32_Addr value;
-};
-#endif
-
-struct arch_file {
- struct obj_file root;
-#if defined(BB_USE_PLT_ENTRIES)
- struct obj_section *plt;
-#endif
-#if defined(BB_USE_GOT_ENTRIES)
- struct obj_section *got;
-#endif
-#if defined(__mips__)
- struct mips_hi16 *mips_hi16_list;
-#endif
-};
-
-struct arch_symbol {
- struct obj_symbol root;
-#if defined(BB_USE_PLT_ENTRIES)
-#if defined(BB_USE_PLT_LIST)
- struct arch_list_entry *pltent;
-#else
- struct arch_single_entry pltent;
-#endif
-#endif
-#if defined(BB_USE_GOT_ENTRIES)
- struct arch_single_entry gotent;
-#endif
-};
-
-
-struct external_module {
- const char *name;
- ElfW(Addr) addr;
- int used;
- size_t nsyms;
- struct new_module_symbol *syms;
-};
-
-static struct new_module_symbol *ksyms;
-static size_t nksyms;
-
-static struct external_module *ext_modules;
-static int n_ext_modules;
-static int n_ext_modules_used;
-extern int delete_module(const char *);
-
-#ifndef FILENAME_MAX
-#define FILENAME_MAX 4095
-#endif
-
-static char m_filename[FILENAME_MAX];
-static char m_fullName[FILENAME_MAX];
-
-
-
-/*======================================================================*/
-
-static struct obj_file *arch_new_file(void)
-{
- struct arch_file *f;
- f = xmalloc(sizeof(*f));
-
- memset(f, 0, sizeof(*f));
-
- return &f->root;
-}
-
-static struct obj_section *arch_new_section(void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-static struct obj_symbol *arch_new_symbol(void)
-{
- struct arch_symbol *sym;
- sym = xmalloc(sizeof(*sym));
-
- memset(sym, 0, sizeof(*sym));
-
- return &sym->root;
-}
-
-static enum obj_reloc
-arch_apply_relocation(struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- ElfW(RelM) *rel, ElfW(Addr) v)
-{
- struct arch_file *ifile = (struct arch_file *) f;
- enum obj_reloc ret = obj_reloc_ok;
- ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset);
- ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset;
-#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
- struct arch_symbol *isym = (struct arch_symbol *) sym;
-#endif
-#if defined(BB_USE_GOT_ENTRIES)
- ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0;
-#endif
-#if defined(BB_USE_PLT_ENTRIES)
- ElfW(Addr) plt = ifile->plt ? ifile->plt->header.sh_addr : 0;
- unsigned long *ip;
-#if defined(BB_USE_PLT_LIST)
- struct arch_list_entry *pe;
-#else
- struct arch_single_entry *pe;
-#endif
-#endif
-
- switch (ELF32_R_TYPE(rel->r_info)) {
-
-#if defined(__arm__)
- case R_ARM_NONE:
- break;
-
- case R_ARM_ABS32:
- *loc += v;
- break;
-
- case R_ARM_GOT32:
- goto bb_use_got;
-
- case R_ARM_GOTPC:
- /* relative reloc, always to _GLOBAL_OFFSET_TABLE_
- * (which is .got) similar to branch,
- * but is full 32 bits relative */
-
- assert(got);
- *loc += got - dot;
- break;
-
- case R_ARM_PC24:
- case R_ARM_PLT32:
- goto bb_use_plt;
-
- case R_ARM_GOTOFF: /* address relative to the got */
- assert(got);
- *loc += v - got;
- break;
-
-#elif defined(__i386__)
-
- case R_386_NONE:
- break;
-
- case R_386_32:
- *loc += v;
- break;
-
- case R_386_PLT32:
- case R_386_PC32:
- *loc += v - dot;
- break;
-
- case R_386_GLOB_DAT:
- case R_386_JMP_SLOT:
- *loc = v;
- break;
-
- case R_386_RELATIVE:
- *loc += f->baseaddr;
- break;
-
- case R_386_GOTPC:
- assert(got != 0);
- *loc += got - dot;
- break;
-
- case R_386_GOT32:
- goto bb_use_got;
-
- case R_386_GOTOFF:
- assert(got != 0);
- *loc += v - got;
- break;
-
-#elif defined(__x86_64__)
-
- case R_X86_64_NONE:
- break;
-
- case R_X86_64_64:
- *loc += v;
- break;
-
- case R_X86_64_32:
- *(unsigned int *) loc += v;
- break;
-
- case R_X86_64_32S:
- *(signed int *) loc += v;
- break;
-
- case R_X86_64_16:
- *(unsigned short *) loc += v;
- break;
-
- case R_X86_64_8:
- *(unsigned char *) loc += v;
- break;
-
- case R_X86_64_PC32:
- *(unsigned int *) loc += v - dot;
- break;
-
- case R_X86_64_PC16:
- *(unsigned short *) loc += v - dot;
- break;
-
- case R_X86_64_PC8:
- *(unsigned char *) loc += v - dot;
- break;
-
- case R_X86_64_GLOB_DAT:
- case R_X86_64_JUMP_SLOT:
- *loc = v;
- break;
-
- case R_X86_64_RELATIVE:
- *loc += f->baseaddr;
- break;
-
- case R_X86_64_GOT32:
- case R_X86_64_GOTPCREL:
- goto bb_use_got;
-
-#elif defined(__mc68000__)
-
- case R_68K_NONE:
- break;
-
- case R_68K_32:
- *loc += v;
- break;
-
- case R_68K_8:
- if (v > 0xff) {
- ret = obj_reloc_overflow;
- }
- *(char *)loc = v;
- break;
-
- case R_68K_16:
- if (v > 0xffff) {
- ret = obj_reloc_overflow;
- }
- *(short *)loc = v;
- break;
-
- case R_68K_PC8:
- v -= dot;
- if ((Elf32_Sword)v > 0x7f ||
- (Elf32_Sword)v < -(Elf32_Sword)0x80) {
- ret = obj_reloc_overflow;
- }
- *(char *)loc = v;
- break;
-
- case R_68K_PC16:
- v -= dot;
- if ((Elf32_Sword)v > 0x7fff ||
- (Elf32_Sword)v < -(Elf32_Sword)0x8000) {
- ret = obj_reloc_overflow;
- }
- *(short *)loc = v;
- break;
-
- case R_68K_PC32:
- *(int *)loc = v - dot;
- break;
-
- case R_68K_GLOB_DAT:
- case R_68K_JMP_SLOT:
- *loc = v;
- break;
-
- case R_68K_RELATIVE:
- *(int *)loc += f->baseaddr;
- break;
-
- case R_68K_GOT32:
- goto bb_use_got;
-
- case R_68K_GOTOFF:
- assert(got != 0);
- *loc += v - got;
- break;
-
-#elif defined(__mips__)
-
- case R_MIPS_NONE:
- break;
-
- case R_MIPS_32:
- *loc += v;
- break;
-
- case R_MIPS_26:
- if (v % 4)
- ret = obj_reloc_dangerous;
- if ((v & 0xf0000000) != ((dot + 4) & 0xf0000000))
- ret = obj_reloc_overflow;
- *loc =
- (*loc & ~0x03ffffff) | ((*loc + (v >> 2)) &
- 0x03ffffff);
- break;
-
- case R_MIPS_HI16:
- {
- struct mips_hi16 *n;
-
- /* We cannot relocate this one now because we don't know the value
- of the carry we need to add. Save the information, and let LO16
- do the actual relocation. */
- n = (struct mips_hi16 *) xmalloc(sizeof *n);
- n->addr = loc;
- n->value = v;
- n->next = ifile->mips_hi16_list;
- ifile->mips_hi16_list = n;
- break;
- }
-
- case R_MIPS_LO16:
- {
- unsigned long insnlo = *loc;
- Elf32_Addr val, vallo;
-
- /* Sign extend the addend we extract from the lo insn. */
- vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000;
-
- if (ifile->mips_hi16_list != NULL) {
- struct mips_hi16 *l;
-
- l = ifile->mips_hi16_list;
- while (l != NULL) {
- struct mips_hi16 *next;
- unsigned long insn;
-
- /* The value for the HI16 had best be the same. */
- assert(v == l->value);
-
- /* Do the HI16 relocation. Note that we actually don't
- need to know anything about the LO16 itself, except where
- to find the low 16 bits of the addend needed by the LO16. */
- insn = *l->addr;
- val =
- ((insn & 0xffff) << 16) +
- vallo;
- val += v;
-
- /* Account for the sign extension that will happen in the
- low bits. */
- val =
- ((val >> 16) +
- ((val & 0x8000) !=
- 0)) & 0xffff;
-
- insn = (insn & ~0xffff) | val;
- *l->addr = insn;
-
- next = l->next;
- free(l);
- l = next;
- }
-
- ifile->mips_hi16_list = NULL;
- }
-
- /* Ok, we're done with the HI16 relocs. Now deal with the LO16. */
- val = v + vallo;
- insnlo = (insnlo & ~0xffff) | (val & 0xffff);
- *loc = insnlo;
- break;
- }
-
-#elif defined(__powerpc__)
-
- case R_PPC_ADDR16_HA:
- *(unsigned short *)loc = (v + 0x8000) >> 16;
- break;
-
- case R_PPC_ADDR16_HI:
- *(unsigned short *)loc = v >> 16;
- break;
-
- case R_PPC_ADDR16_LO:
- *(unsigned short *)loc = v;
- break;
-
- case R_PPC_REL24:
- goto bb_use_plt;
-
- case R_PPC_REL32:
- *loc = v - dot;
- break;
-
- case R_PPC_ADDR32:
- *loc = v;
- break;
-
-#elif defined(__sh__)
-
- case R_SH_NONE:
- break;
-
- case R_SH_DIR32:
- *loc += v;
- break;
-
- case R_SH_REL32:
- *loc += v - dot;
- break;
-
- case R_SH_PLT32:
- *loc = v - dot;
- break;
-
- case R_SH_GLOB_DAT:
- case R_SH_JMP_SLOT:
- *loc = v;
- break;
-
- case R_SH_RELATIVE:
- *loc = f->baseaddr + rel->r_addend;
- break;
-
- case R_SH_GOTPC:
- assert(got != 0);
- *loc = got - dot + rel->r_addend;
- break;
-
- case R_SH_GOT32:
- goto bb_use_got;
-
- case R_SH_GOTOFF:
- assert(got != 0);
- *loc = v - got;
- break;
-
-#endif
-
- default:
- printf("Warning: unhandled reloc %d\n",(int)ELF32_R_TYPE(rel->r_info));
- ret = obj_reloc_unhandled;
- break;
-
-#if defined(BB_USE_PLT_ENTRIES)
-
- bb_use_plt:
-
- /* find the plt entry and initialize it if necessary */
- assert(isym != NULL);
-
-#if defined(BB_USE_PLT_LIST)
- for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend;)
- pe = pe->next;
- assert(pe != NULL);
-#else
- pe = &isym->pltent;
-#endif
-
- if (! pe->inited) {
- ip = (unsigned long *) (ifile->plt->contents + pe->offset);
-
- /* generate some machine code */
-
-#if defined(__arm__)
- ip[0] = 0xe51ff004; /* ldr pc,[pc,#-4] */
- ip[1] = v; /* sym@ */
-#endif
-#if defined(__powerpc__)
- ip[0] = 0x3d600000 + ((v + 0x8000) >> 16); /* lis r11,sym@ha */
- ip[1] = 0x396b0000 + (v & 0xffff); /* addi r11,r11,sym@l */
- ip[2] = 0x7d6903a6; /* mtctr r11 */
- ip[3] = 0x4e800420; /* bctr */
-#endif
- pe->inited = 1;
- }
-
- /* relative distance to target */
- v -= dot;
- /* if the target is too far away.... */
- if ((int)v < -0x02000000 || (int)v >= 0x02000000) {
- /* go via the plt */
- v = plt + pe->offset - dot;
- }
- if (v & 3)
- ret = obj_reloc_dangerous;
-
- /* merge the offset into the instruction. */
-#if defined(__arm__)
- /* Convert to words. */
- v >>= 2;
-
- *loc = (*loc & ~0x00ffffff) | ((v + *loc) & 0x00ffffff);
-#endif
-#if defined(__powerpc__)
- *loc = (*loc & ~0x03fffffc) | (v & 0x03fffffc);
-#endif
- break;
-#endif /* BB_USE_PLT_ENTRIES */
-
-#if defined(BB_USE_GOT_ENTRIES)
- bb_use_got:
-
- assert(isym != NULL);
- /* needs an entry in the .got: set it, once */
- if (!isym->gotent.inited) {
- isym->gotent.inited = 1;
- *(ElfW(Addr) *) (ifile->got->contents + isym->gotent.offset) = v;
- }
- /* make the reloc with_respect_to_.got */
-#if defined(__sh__)
- *loc += isym->gotent.offset + rel->r_addend;
-#elif defined(__i386__) || defined(__arm__) || defined(__mc68000__)
- *loc += isym->gotent.offset;
-#elif defined(__x86_64__)
- /* XXX are these really correct? */
- if (ELF64_R_TYPE(rel->r_info) == R_X86_64_GOTPCREL)
- *(unsigned int *) loc += v + isym->gotent.offset;
- else
- *loc += isym->gotent.offset;
-#endif
- break;
-
-#endif /* BB_USE_GOT_ENTRIES */
- }
-
- return ret;
-}
-
-#if defined(BB_USE_LIST)
-
-static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
- int offset, int size)
-{
- struct arch_list_entry *pe;
-
- for (pe = *list; pe != NULL; pe = pe->next) {
- if (pe->addend == rel->r_addend) {
- break;
- }
- }
-
- if (pe == NULL) {
- pe = xmalloc(sizeof(struct arch_list_entry));
- pe->next = *list;
- pe->addend = rel->r_addend;
- pe->offset = offset;
- pe->inited = 0;
- *list = pe;
- return size;
- }
- return 0;
-}
-
-#endif
-
-#if defined(BB_USE_SINGLE)
-
-static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
- int offset, int size)
-{
- if (single->allocated == 0) {
- single->allocated = 1;
- single->offset = offset;
- single->inited = 0;
- return size;
- }
- return 0;
-}
-
-#endif
-
-#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
-
-static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
- int offset, int size)
-{
- struct obj_section *myrelsec = obj_find_section(f, name);
-
- if (offset == 0) {
- offset += size;
- }
-
- if (myrelsec) {
- obj_extend_section(myrelsec, offset);
- } else {
- myrelsec = obj_create_alloced_section(f, name,
- size, offset);
- assert(myrelsec);
- }
-
- return myrelsec;
-}
-
-#endif
-
-static void arch_create_got(struct obj_file *f)
-{
-#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
- struct arch_file *ifile = (struct arch_file *) f;
- int i;
-#if defined(BB_USE_GOT_ENTRIES)
- int got_offset = 0, got_needed = 0, got_allocate;
-#endif
-#if defined(BB_USE_PLT_ENTRIES)
- int plt_offset = 0, plt_needed = 0, plt_allocate;
-#endif
- struct obj_section *relsec, *symsec, *strsec;
- ElfW(RelM) *rel, *relend;
- ElfW(Sym) *symtab, *extsym;
- const char *strtab, *name;
- struct arch_symbol *intsym;
-
- for (i = 0; i < f->header.e_shnum; ++i) {
- relsec = f->sections[i];
-
- if (relsec->header.sh_type != SHT_RELM)
- continue;
-
- symsec = f->sections[relsec->header.sh_link];
- strsec = f->sections[symsec->header.sh_link];
-
- rel = (ElfW(RelM) *) relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(ElfW(RelM)));
- symtab = (ElfW(Sym) *) symsec->contents;
- strtab = (const char *) strsec->contents;
-
- for (; rel < relend; ++rel) {
- extsym = &symtab[ELF32_R_SYM(rel->r_info)];
-
-#if defined(BB_USE_GOT_ENTRIES)
- got_allocate = 0;
-#endif
-#if defined(BB_USE_PLT_ENTRIES)
- plt_allocate = 0;
-#endif
-
- switch (ELF32_R_TYPE(rel->r_info)) {
-
-#if defined(__arm__)
-
- case R_ARM_PC24:
- case R_ARM_PLT32:
- plt_allocate = 1;
- break;
-
- case R_ARM_GOTOFF:
- case R_ARM_GOTPC:
- got_needed = 1;
- continue;
-
- case R_ARM_GOT32:
- got_allocate = 1;
- break;
-
-#elif defined(__i386__)
-
- case R_386_GOTPC:
- case R_386_GOTOFF:
- got_needed = 1;
- continue;
-
- case R_386_GOT32:
- got_allocate = 1;
- break;
-
-#elif defined(__x86_64__)
-
- case R_X86_64_GOTPCREL:
- case R_X86_64_GOT32:
- got_needed = 1;
- continue;
-
-#elif defined(__powerpc__)
-
- case R_PPC_REL24:
- plt_allocate = 1;
- break;
-
-#elif defined(__mc68000__)
-
- case R_68K_GOT32:
- got_allocate = 1;
- break;
-
- case R_68K_GOTOFF:
- got_needed = 1;
- continue;
-
-#elif defined(__sh__)
-
- case R_SH_GOT32:
- got_allocate = 1;
- break;
-
- case R_SH_GOTPC:
- case R_SH_GOTOFF:
- got_needed = 1;
- continue;
-
-#endif
- default:
- continue;
- }
-
- if (extsym->st_name != 0) {
- name = strtab + extsym->st_name;
- } else {
- name = f->sections[extsym->st_shndx]->name;
- }
- intsym = (struct arch_symbol *) obj_find_symbol(f, name);
-#if defined(BB_USE_GOT_ENTRIES)
- if (got_allocate) {
- got_offset += arch_single_init(
- rel, &intsym->gotent,
- got_offset, BB_GOT_ENTRY_SIZE);
-
- got_needed = 1;
- }
-#endif
-#if defined(BB_USE_PLT_ENTRIES)
- if (plt_allocate) {
-#if defined(BB_USE_PLT_LIST)
- plt_offset += arch_list_add(
- rel, &intsym->pltent,
- plt_offset, BB_PLT_ENTRY_SIZE);
-#else
- plt_offset += arch_single_init(
- rel, &intsym->pltent,
- plt_offset, BB_PLT_ENTRY_SIZE);
-#endif
- plt_needed = 1;
- }
-#endif
- }
- }
-
-#if defined(BB_USE_GOT_ENTRIES)
- if (got_needed) {
- ifile->got = arch_xsect_init(f, ".got", got_offset,
- BB_GOT_ENTRY_SIZE);
- }
-#endif
-
-#if defined(BB_USE_PLT_ENTRIES)
- if (plt_needed) {
- ifile->plt = arch_xsect_init(f, ".plt", plt_offset,
- BB_PLT_ENTRY_SIZE);
- }
-#endif
-
-#endif /* defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES) */
-}
-
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-static int arch_init_module(struct obj_file *f, struct new_module *mod)
-{
- return 1;
-}
-#endif
-
-
-/*======================================================================*/
-
-/* Standard ELF hash function. */
-static inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
-{
- unsigned long h = 0;
- unsigned long g;
- unsigned char ch;
-
- while (n > 0) {
- ch = *name++;
- h = (h << 4) + ch;
- if ((g = (h & 0xf0000000)) != 0) {
- h ^= g >> 24;
- h &= ~g;
- }
- n--;
- }
- return h;
-}
-
-static unsigned long obj_elf_hash(const char *name)
-{
- return obj_elf_hash_n(name, strlen(name));
-}
-
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
-/* String comparison for non-co-versioned kernel and module. */
-
-static int ncv_strcmp(const char *a, const char *b)
-{
- size_t alen = strlen(a), blen = strlen(b);
-
- if (blen == alen + 10 && b[alen] == '_' && b[alen + 1] == 'R')
- return strncmp(a, b, alen);
- else if (alen == blen + 10 && a[blen] == '_' && a[blen + 1] == 'R')
- return strncmp(a, b, blen);
- else
- return strcmp(a, b);
-}
-
-/* String hashing for non-co-versioned kernel and module. Here
- we are simply forced to drop the crc from the hash. */
-
-static unsigned long ncv_symbol_hash(const char *str)
-{
- size_t len = strlen(str);
- if (len > 10 && str[len - 10] == '_' && str[len - 9] == 'R')
- len -= 10;
- return obj_elf_hash_n(str, len);
-}
-
-static void
-obj_set_symbol_compare(struct obj_file *f,
- int (*cmp) (const char *, const char *),
- unsigned long (*hash) (const char *))
-{
- if (cmp)
- f->symbol_cmp = cmp;
- if (hash) {
- struct obj_symbol *tmptab[HASH_BUCKETS], *sym, *next;
- int i;
-
- f->symbol_hash = hash;
-
- memcpy(tmptab, f->symtab, sizeof(tmptab));
- memset(f->symtab, 0, sizeof(f->symtab));
-
- for (i = 0; i < HASH_BUCKETS; ++i)
- for (sym = tmptab[i]; sym; sym = next) {
- unsigned long h = hash(sym->name) % HASH_BUCKETS;
- next = sym->next;
- sym->next = f->symtab[h];
- f->symtab[h] = sym;
- }
- }
-}
-
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
-static struct obj_symbol *
-obj_add_symbol(struct obj_file *f, const char *name,
- unsigned long symidx, int info,
- int secidx, ElfW(Addr) value,
- unsigned long size)
-{
- struct obj_symbol *sym;
- unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
- int n_type = ELFW(ST_TYPE) (info);
- int n_binding = ELFW(ST_BIND) (info);
-
- for (sym = f->symtab[hash]; sym; sym = sym->next)
- if (f->symbol_cmp(sym->name, name) == 0) {
- int o_secidx = sym->secidx;
- int o_info = sym->info;
- int o_type = ELFW(ST_TYPE) (o_info);
- int o_binding = ELFW(ST_BIND) (o_info);
-
- /* A redefinition! Is it legal? */
-
- if (secidx == SHN_UNDEF)
- return sym;
- else if (o_secidx == SHN_UNDEF)
- goto found;
- else if (n_binding == STB_GLOBAL && o_binding == STB_LOCAL) {
- /* Cope with local and global symbols of the same name
- in the same object file, as might have been created
- by ld -r. The only reason locals are now seen at this
- level at all is so that we can do semi-sensible things
- with parameters. */
-
- struct obj_symbol *nsym, **p;
-
- nsym = arch_new_symbol();
- nsym->next = sym->next;
- nsym->ksymidx = -1;
-
- /* Excise the old (local) symbol from the hash chain. */
- for (p = &f->symtab[hash]; *p != sym; p = &(*p)->next)
- continue;
- *p = sym = nsym;
- goto found;
- } else if (n_binding == STB_LOCAL) {
- /* Another symbol of the same name has already been defined.
- Just add this to the local table. */
- sym = arch_new_symbol();
- sym->next = NULL;
- sym->ksymidx = -1;
- f->local_symtab[symidx] = sym;
- goto found;
- } else if (n_binding == STB_WEAK)
- return sym;
- else if (o_binding == STB_WEAK)
- goto found;
- /* Don't unify COMMON symbols with object types the programmer
- doesn't expect. */
- else if (secidx == SHN_COMMON
- && (o_type == STT_NOTYPE || o_type == STT_OBJECT))
- return sym;
- else if (o_secidx == SHN_COMMON
- && (n_type == STT_NOTYPE || n_type == STT_OBJECT))
- goto found;
- else {
- /* Don't report an error if the symbol is coming from
- the kernel or some external module. */
- if (secidx <= SHN_HIRESERVE)
- error_msg("%s multiply defined", name);
- return sym;
- }
- }
-
- /* Completely new symbol. */
- sym = arch_new_symbol();
- sym->next = f->symtab[hash];
- f->symtab[hash] = sym;
- sym->ksymidx = -1;
-
- if (ELFW(ST_BIND)(info) == STB_LOCAL && symidx != -1) {
- if (symidx >= f->local_symtab_size)
- error_msg("local symbol %s with index %ld exceeds local_symtab_size %ld",
- name, (long) symidx, (long) f->local_symtab_size);
- else
- f->local_symtab[symidx] = sym;
- }
-
- found:
- sym->name = name;
- sym->value = value;
- sym->size = size;
- sym->secidx = secidx;
- sym->info = info;
-
- return sym;
-}
-
-static struct obj_symbol *
-obj_find_symbol(struct obj_file *f, const char *name)
-{
- struct obj_symbol *sym;
- unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
-
- for (sym = f->symtab[hash]; sym; sym = sym->next)
- if (f->symbol_cmp(sym->name, name) == 0)
- return sym;
-
- return NULL;
-}
-
-static ElfW(Addr)
- obj_symbol_final_value(struct obj_file * f, struct obj_symbol * sym)
-{
- if (sym) {
- if (sym->secidx >= SHN_LORESERVE)
- return sym->value;
-
- return sym->value + f->sections[sym->secidx]->header.sh_addr;
- } else {
- /* As a special case, a NULL sym has value zero. */
- return 0;
- }
-}
-
-static struct obj_section *obj_find_section(struct obj_file *f, const char *name)
-{
- int i, n = f->header.e_shnum;
-
- for (i = 0; i < n; ++i)
- if (strcmp(f->sections[i]->name, name) == 0)
- return f->sections[i];
-
- return NULL;
-}
-
-static int obj_load_order_prio(struct obj_section *a)
-{
- unsigned long af, ac;
-
- af = a->header.sh_flags;
-
- ac = 0;
- if (a->name[0] != '.' || strlen(a->name) != 10 ||
- strcmp(a->name + 5, ".init"))
- ac |= 32;
- if (af & SHF_ALLOC)
- ac |= 16;
- if (!(af & SHF_WRITE))
- ac |= 8;
- if (af & SHF_EXECINSTR)
- ac |= 4;
- if (a->header.sh_type != SHT_NOBITS)
- ac |= 2;
-
- return ac;
-}
-
-static void
-obj_insert_section_load_order(struct obj_file *f, struct obj_section *sec)
-{
- struct obj_section **p;
- int prio = obj_load_order_prio(sec);
- for (p = f->load_order_search_start; *p; p = &(*p)->load_next)
- if (obj_load_order_prio(*p) < prio)
- break;
- sec->load_next = *p;
- *p = sec;
-}
-
-static struct obj_section *obj_create_alloced_section(struct obj_file *f,
- const char *name,
- unsigned long align,
- unsigned long size)
-{
- int newidx = f->header.e_shnum++;
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec));
- f->sections[newidx] = sec = arch_new_section();
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = SHF_WRITE | SHF_ALLOC;
- sec->header.sh_size = size;
- sec->header.sh_addralign = align;
- sec->name = name;
- sec->idx = newidx;
- if (size)
- sec->contents = xmalloc(size);
-
- obj_insert_section_load_order(f, sec);
-
- return sec;
-}
-
-static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
- const char *name,
- unsigned long align,
- unsigned long size)
-{
- int newidx = f->header.e_shnum++;
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec));
- f->sections[newidx] = sec = arch_new_section();
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = SHF_WRITE | SHF_ALLOC;
- sec->header.sh_size = size;
- sec->header.sh_addralign = align;
- sec->name = name;
- sec->idx = newidx;
- if (size)
- sec->contents = xmalloc(size);
-
- sec->load_next = f->load_order;
- f->load_order = sec;
- if (f->load_order_search_start == &f->load_order)
- f->load_order_search_start = &sec->load_next;
-
- return sec;
-}
-
-static void *obj_extend_section(struct obj_section *sec, unsigned long more)
-{
- unsigned long oldsize = sec->header.sh_size;
- if (more) {
- sec->contents = xrealloc(sec->contents, sec->header.sh_size += more);
- }
- return sec->contents + oldsize;
-}
-
-
-/* Conditionally add the symbols from the given symbol set to the
- new module. */
-
-static int
-add_symbols_from(
- struct obj_file *f,
- int idx, struct new_module_symbol *syms, size_t nsyms)
-{
- struct new_module_symbol *s;
- size_t i;
- int used = 0;
-
- for (i = 0, s = syms; i < nsyms; ++i, ++s) {
-
- /* Only add symbols that are already marked external. If we
- override locals we may cause problems for argument initialization.
- We will also create a false dependency on the module. */
- struct obj_symbol *sym;
-
- sym = obj_find_symbol(f, (char *) s->name);
- if (sym && !ELFW(ST_BIND) (sym->info) == STB_LOCAL) {
- sym = obj_add_symbol(f, (char *) s->name, -1,
- ELFW(ST_INFO) (STB_GLOBAL, STT_NOTYPE),
- idx, s->value, 0);
- /* Did our symbol just get installed? If so, mark the
- module as "used". */
- if (sym->secidx == idx)
- used = 1;
- }
- }
-
- return used;
-}
-
-static void add_kernel_symbols(struct obj_file *f)
-{
- struct external_module *m;
- int i, nused = 0;
-
- /* Add module symbols first. */
-
- for (i = 0, m = ext_modules; i < n_ext_modules; ++i, ++m)
- if (m->nsyms
- && add_symbols_from(f, SHN_HIRESERVE + 2 + i, m->syms,
- m->nsyms)) m->used = 1, ++nused;
-
- n_ext_modules_used = nused;
-
- /* And finally the symbols from the kernel proper. */
-
- if (nksyms)
- add_symbols_from(f, SHN_HIRESERVE + 1, ksyms, nksyms);
-}
-
-static char *get_modinfo_value(struct obj_file *f, const char *key)
-{
- struct obj_section *sec;
- char *p, *v, *n, *ep;
- size_t klen = strlen(key);
-
- sec = obj_find_section(f, ".modinfo");
- if (sec == NULL)
- return NULL;
- p = sec->contents;
- ep = p + sec->header.sh_size;
- while (p < ep) {
- v = strchr(p, '=');
- n = strchr(p, '\0');
- if (v) {
- if (p + klen == v && strncmp(p, key, klen) == 0)
- return v + 1;
- } else {
- if (p + klen == n && strcmp(p, key) == 0)
- return n;
- }
- p = n + 1;
- }
-
- return NULL;
-}
-
-
-/*======================================================================*/
-/* Functions relating to module loading in pre 2.1 kernels. */
-
-static int
-old_process_module_arguments(struct obj_file *f, int argc, char **argv)
-{
- while (argc > 0) {
- char *p, *q;
- struct obj_symbol *sym;
- int *loc;
-
- p = *argv;
- if ((q = strchr(p, '=')) == NULL) {
- argc--;
- continue;
- }
- *q++ = '\0';
-
- sym = obj_find_symbol(f, p);
-
- /* Also check that the parameter was not resolved from the kernel. */
- if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- error_msg("symbol for parameter %s not found", p);
- return 0;
- }
-
- loc = (int *) (f->sections[sym->secidx]->contents + sym->value);
-
- /* Do C quoting if we begin with a ". */
- if (*q == '"') {
- char *r, *str;
-
- str = alloca(strlen(q));
- for (r = str, q++; *q != '"'; ++q, ++r) {
- if (*q == '\0') {
- error_msg("improperly terminated string argument for %s", p);
- return 0;
- } else if (*q == '\\')
- switch (*++q) {
- case 'a':
- *r = '\a';
- break;
- case 'b':
- *r = '\b';
- break;
- case 'e':
- *r = '\033';
- break;
- case 'f':
- *r = '\f';
- break;
- case 'n':
- *r = '\n';
- break;
- case 'r':
- *r = '\r';
- break;
- case 't':
- *r = '\t';
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- int c = *q - '0';
- if (q[1] >= '0' && q[1] <= '7') {
- c = (c * 8) + *++q - '0';
- if (q[1] >= '0' && q[1] <= '7')
- c = (c * 8) + *++q - '0';
- }
- *r = c;
- }
- break;
-
- default:
- *r = *q;
- break;
- } else
- *r = *q;
- }
- *r = '\0';
- obj_string_patch(f, sym->secidx, sym->value, str);
- } else if (*q >= '0' && *q <= '9') {
- do
- *loc++ = strtoul(q, &q, 0);
- while (*q++ == ',');
- } else {
- char *contents = f->sections[sym->secidx]->contents;
- char *myloc = contents + sym->value;
- char *r; /* To search for commas */
-
- /* Break the string with comas */
- while ((r = strchr(q, ',')) != (char *) NULL) {
- *r++ = '\0';
- obj_string_patch(f, sym->secidx, myloc - contents, q);
- myloc += sizeof(char *);
- q = r;
- }
-
- /* last part */
- obj_string_patch(f, sym->secidx, myloc - contents, q);
- }
-
- argc--, argv++;
- }
-
- return 1;
-}
-
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
-static int old_is_module_checksummed(struct obj_file *f)
-{
- return obj_find_symbol(f, "Using_Versions") != NULL;
-}
-/* Get the module's kernel version in the canonical integer form. */
-
-static int
-old_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
-{
- struct obj_symbol *sym;
- char *p, *q;
- int a, b, c;
-
- sym = obj_find_symbol(f, "kernel_version");
- if (sym == NULL)
- return -1;
-
- p = f->sections[sym->secidx]->contents + sym->value;
- safe_strncpy(str, p, STRVERSIONLEN);
-
- a = strtoul(p, &p, 10);
- if (*p != '.')
- return -1;
- b = strtoul(p + 1, &p, 10);
- if (*p != '.')
- return -1;
- c = strtoul(p + 1, &q, 10);
- if (p + 1 == q)
- return -1;
-
- return a << 16 | b << 8 | c;
-}
-
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
-#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
-
-/* Fetch all the symbols and divvy them up as appropriate for the modules. */
-
-static int old_get_kernel_symbols(const char *m_name)
-{
- struct old_kernel_sym *ks, *k;
- struct new_module_symbol *s;
- struct external_module *mod;
- int nks, nms, nmod, i;
-
- nks = get_kernel_syms(NULL);
- if (nks <= 0) {
- if (nks)
- perror_msg("get_kernel_syms: %s", m_name);
- else
- error_msg("No kernel symbols");
- return 0;
- }
-
- ks = k = xmalloc(nks * sizeof(*ks));
-
- if (get_kernel_syms(ks) != nks) {
- perror("inconsistency with get_kernel_syms -- is someone else "
- "playing with modules?");
- free(ks);
- return 0;
- }
-
- /* Collect the module information. */
-
- mod = NULL;
- nmod = -1;
-
- while (k->name[0] == '#' && k->name[1]) {
- struct old_kernel_sym *k2;
-
- /* Find out how many symbols this module has. */
- for (k2 = k + 1; k2->name[0] != '#'; ++k2)
- continue;
- nms = k2 - k - 1;
-
- mod = xrealloc(mod, (++nmod + 1) * sizeof(*mod));
- mod[nmod].name = k->name + 1;
- mod[nmod].addr = k->value;
- mod[nmod].used = 0;
- mod[nmod].nsyms = nms;
- mod[nmod].syms = s = (nms ? xmalloc(nms * sizeof(*s)) : NULL);
-
- for (i = 0, ++k; i < nms; ++i, ++s, ++k) {
- s->name = (unsigned long) k->name;
- s->value = k->value;
- }
-
- k = k2;
- }
-
- ext_modules = mod;
- n_ext_modules = nmod + 1;
-
- /* Now collect the symbols for the kernel proper. */
-
- if (k->name[0] == '#')
- ++k;
-
- nksyms = nms = nks - (k - ks);
- ksyms = s = (nms ? xmalloc(nms * sizeof(*s)) : NULL);
-
- for (i = 0; i < nms; ++i, ++s, ++k) {
- s->name = (unsigned long) k->name;
- s->value = k->value;
- }
-
- return 1;
-}
-
-/* Return the kernel symbol checksum version, or zero if not used. */
-
-static int old_is_kernel_checksummed(void)
-{
- /* Using_Versions is the first symbol. */
- if (nksyms > 0
- && strcmp((char *) ksyms[0].name,
- "Using_Versions") == 0) return ksyms[0].value;
- else
- return 0;
-}
-
-
-static int old_create_mod_use_count(struct obj_file *f)
-{
- struct obj_section *sec;
-
- sec = obj_create_alloced_section_first(f, ".moduse", sizeof(long),
- sizeof(long));
-
- obj_add_symbol(f, "mod_use_count_", -1,
- ELFW(ST_INFO) (STB_LOCAL, STT_OBJECT), sec->idx, 0,
- sizeof(long));
-
- return 1;
-}
-
-static int
-old_init_module(const char *m_name, struct obj_file *f,
- unsigned long m_size)
-{
- char *image;
- struct old_mod_routines routines;
- struct old_symbol_table *symtab;
- int ret;
-
- /* Create the symbol table */
- {
- int nsyms = 0, strsize = 0, total;
-
- /* Size things first... */
- if (flag_export) {
- int i;
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (ELFW(ST_BIND) (sym->info) != STB_LOCAL
- && sym->secidx <= SHN_HIRESERVE)
- {
- sym->ksymidx = nsyms++;
- strsize += strlen(sym->name) + 1;
- }
- }
- }
-
- total = (sizeof(struct old_symbol_table)
- + nsyms * sizeof(struct old_module_symbol)
- + n_ext_modules_used * sizeof(struct old_module_ref)
- + strsize);
- symtab = xmalloc(total);
- symtab->size = total;
- symtab->n_symbols = nsyms;
- symtab->n_refs = n_ext_modules_used;
-
- if (flag_export && nsyms) {
- struct old_module_symbol *ksym;
- char *str;
- int i;
-
- ksym = symtab->symbol;
- str = ((char *) ksym + nsyms * sizeof(struct old_module_symbol)
- + n_ext_modules_used * sizeof(struct old_module_ref));
-
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (sym->ksymidx >= 0) {
- ksym->addr = obj_symbol_final_value(f, sym);
- ksym->name =
- (unsigned long) str - (unsigned long) symtab;
-
- strcpy(str, sym->name);
- str += strlen(sym->name) + 1;
- ksym++;
- }
- }
- }
-
- if (n_ext_modules_used) {
- struct old_module_ref *ref;
- int i;
-
- ref = (struct old_module_ref *)
- ((char *) symtab->symbol + nsyms * sizeof(struct old_module_symbol));
-
- for (i = 0; i < n_ext_modules; ++i)
- if (ext_modules[i].used)
- ref++->module = ext_modules[i].addr;
- }
- }
-
- /* Fill in routines. */
-
- routines.init =
- obj_symbol_final_value(f, obj_find_symbol(f, "init_module"));
- routines.cleanup =
- obj_symbol_final_value(f, obj_find_symbol(f, "cleanup_module"));
-
- /* Whew! All of the initialization is complete. Collect the final
- module image and give it to the kernel. */
-
- image = xmalloc(m_size);
- obj_create_image(f, image);
-
- /* image holds the complete relocated module, accounting correctly for
- mod_use_count. However the old module kernel support assume that
- it is receiving something which does not contain mod_use_count. */
- ret = old_sys_init_module(m_name, image + sizeof(long),
- m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
- : 0), &routines, symtab);
- if (ret)
- perror_msg("init_module: %s", m_name);
-
- free(image);
- free(symtab);
-
- return ret == 0;
-}
-
-#else
-
-#define old_create_mod_use_count(x) TRUE
-#define old_init_module(x, y, z) TRUE
-
-#endif /* BB_FEATURE_OLD_MODULE_INTERFACE */
-
-
-
-/*======================================================================*/
-/* Functions relating to module loading after 2.1.18. */
-
-static int
-new_process_module_arguments(struct obj_file *f, int argc, char **argv)
-{
- while (argc > 0) {
- char *p, *q, *key;
- struct obj_symbol *sym;
- char *contents, *loc;
- int min, max, n;
-
- p = *argv;
- if ((q = strchr(p, '=')) == NULL) {
- argc--;
- continue;
- }
-
- key = alloca(q - p + 6);
- memcpy(key, "parm_", 5);
- memcpy(key + 5, p, q - p);
- key[q - p + 5] = 0;
-
- p = get_modinfo_value(f, key);
- key += 5;
- if (p == NULL) {
- error_msg("invalid parameter %s", key);
- return 0;
- }
-
- sym = obj_find_symbol(f, key);
-
- /* Also check that the parameter was not resolved from the kernel. */
- if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- error_msg("symbol for parameter %s not found", key);
- return 0;
- }
-
- if (isdigit(*p)) {
- min = strtoul(p, &p, 10);
- if (*p == '-')
- max = strtoul(p + 1, &p, 10);
- else
- max = min;
- } else
- min = max = 1;
-
- contents = f->sections[sym->secidx]->contents;
- loc = contents + sym->value;
- n = (*++q != '\0');
-
- while (1) {
- if ((*p == 's') || (*p == 'c')) {
- char *str;
-
- /* Do C quoting if we begin with a ", else slurp the lot. */
- if (*q == '"') {
- char *r;
-
- str = alloca(strlen(q));
- for (r = str, q++; *q != '"'; ++q, ++r) {
- if (*q == '\0') {
- error_msg("improperly terminated string argument for %s",
- key);
- return 0;
- } else if (*q == '\\')
- switch (*++q) {
- case 'a':
- *r = '\a';
- break;
- case 'b':
- *r = '\b';
- break;
- case 'e':
- *r = '\033';
- break;
- case 'f':
- *r = '\f';
- break;
- case 'n':
- *r = '\n';
- break;
- case 'r':
- *r = '\r';
- break;
- case 't':
- *r = '\t';
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- int c = *q - '0';
- if (q[1] >= '0' && q[1] <= '7') {
- c = (c * 8) + *++q - '0';
- if (q[1] >= '0' && q[1] <= '7')
- c = (c * 8) + *++q - '0';
- }
- *r = c;
- }
- break;
-
- default:
- *r = *q;
- break;
- } else
- *r = *q;
- }
- *r = '\0';
- ++q;
- } else {
- char *r;
-
- /* In this case, the string is not quoted. We will break
- it using the coma (like for ints). If the user wants to
- include comas in a string, he just has to quote it */
-
- /* Search the next coma */
- r = strchr(q, ',');
-
- /* Found ? */
- if (r != (char *) NULL) {
- /* Recopy the current field */
- str = alloca(r - q + 1);
- memcpy(str, q, r - q);
-
- /* I don't know if it is usefull, as the previous case
- doesn't null terminate the string ??? */
- str[r - q] = '\0';
-
- /* Keep next fields */
- q = r;
- } else {
- /* last string */
- str = q;
- q = "";
- }
- }
-
- if (*p == 's') {
- /* Normal string */
- obj_string_patch(f, sym->secidx, loc - contents, str);
- loc += tgt_sizeof_char_p;
- } else {
- /* Array of chars (in fact, matrix !) */
- unsigned long charssize; /* size of each member */
-
- /* Get the size of each member */
- /* Probably we should do that outside the loop ? */
- if (!isdigit(*(p + 1))) {
- error_msg("parameter type 'c' for %s must be followed by"
- " the maximum size", key);
- return 0;
- }
- charssize = strtoul(p + 1, (char **) NULL, 10);
-
- /* Check length */
- if (strlen(str) >= charssize) {
- error_msg("string too long for %s (max %ld)", key,
- charssize - 1);
- return 0;
- }
-
- /* Copy to location */
- strcpy((char *) loc, str);
- loc += charssize;
- }
- } else {
- long v = strtoul(q, &q, 0);
- switch (*p) {
- case 'b':
- *loc++ = v;
- break;
- case 'h':
- *(short *) loc = v;
- loc += tgt_sizeof_short;
- break;
- case 'i':
- *(int *) loc = v;
- loc += tgt_sizeof_int;
- break;
- case 'l':
- *(long *) loc = v;
- loc += tgt_sizeof_long;
- break;
-
- default:
- error_msg("unknown parameter type '%c' for %s", *p, key);
- return 0;
- }
- }
-
- retry_end_of_value:
- switch (*q) {
- case '\0':
- goto end_of_arg;
-
- case ' ':
- case '\t':
- case '\n':
- case '\r':
- ++q;
- goto retry_end_of_value;
-
- case ',':
- if (++n > max) {
- error_msg("too many values for %s (max %d)", key, max);
- return 0;
- }
- ++q;
- break;
-
- default:
- error_msg("invalid argument syntax for %s", key);
- return 0;
- }
- }
-
- end_of_arg:
- if (n < min) {
- error_msg("too few values for %s (min %d)", key, min);
- return 0;
- }
-
- argc--, argv++;
- }
-
- return 1;
-}
-
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
-static int new_is_module_checksummed(struct obj_file *f)
-{
- const char *p = get_modinfo_value(f, "using_checksums");
- if (p)
- return atoi(p);
- else
- return 0;
-}
-
-/* Get the module's kernel version in the canonical integer form. */
-
-static int
-new_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
-{
- char *p, *q;
- int a, b, c;
-
- p = get_modinfo_value(f, "kernel_version");
- if (p == NULL)
- return -1;
- safe_strncpy(str, p, STRVERSIONLEN);
-
- a = strtoul(p, &p, 10);
- if (*p != '.')
- return -1;
- b = strtoul(p + 1, &p, 10);
- if (*p != '.')
- return -1;
- c = strtoul(p + 1, &q, 10);
- if (p + 1 == q)
- return -1;
-
- return a << 16 | b << 8 | c;
-}
-
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
-
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-
-/* Fetch the loaded modules, and all currently exported symbols. */
-
-static int new_get_kernel_symbols(void)
-{
- char *module_names, *mn;
- struct external_module *modules, *m;
- struct new_module_symbol *syms, *s;
- size_t ret, bufsize, nmod, nsyms, i, j;
-
- /* Collect the loaded modules. */
-
- module_names = xmalloc(bufsize = 256);
- retry_modules_load:
- if (query_module(NULL, QM_MODULES, module_names, bufsize, &ret)) {
- if (errno == ENOSPC && bufsize < ret) {
- module_names = xrealloc(module_names, bufsize = ret);
- goto retry_modules_load;
- }
- perror_msg("QM_MODULES");
- return 0;
- }
-
- n_ext_modules = nmod = ret;
-
- /* Collect the modules' symbols. */
-
- if (nmod){
- ext_modules = modules = xmalloc(nmod * sizeof(*modules));
- memset(modules, 0, nmod * sizeof(*modules));
- for (i = 0, mn = module_names, m = modules;
- i < nmod; ++i, ++m, mn += strlen(mn) + 1) {
- struct new_module_info info;
-
- if (query_module(mn, QM_INFO, &info, sizeof(info), &ret)) {
- if (errno == ENOENT) {
- /* The module was removed out from underneath us. */
- continue;
- }
- perror_msg("query_module: QM_INFO: %s", mn);
- return 0;
- }
-
- syms = xmalloc(bufsize = 1024);
- retry_mod_sym_load:
- if (query_module(mn, QM_SYMBOLS, syms, bufsize, &ret)) {
- switch (errno) {
- case ENOSPC:
- syms = xrealloc(syms, bufsize = ret);
- goto retry_mod_sym_load;
- case ENOENT:
- /* The module was removed out from underneath us. */
- continue;
- default:
- perror_msg("query_module: QM_SYMBOLS: %s", mn);
- return 0;
- }
- }
- nsyms = ret;
-
- m->name = mn;
- m->addr = info.addr;
- m->nsyms = nsyms;
- m->syms = syms;
-
- for (j = 0, s = syms; j < nsyms; ++j, ++s) {
- s->name += (unsigned long) syms;
- }
- }
- }
-
- /* Collect the kernel's symbols. */
-
- syms = xmalloc(bufsize = 16 * 1024);
- retry_kern_sym_load:
- if (query_module(NULL, QM_SYMBOLS, syms, bufsize, &ret)) {
- if (errno == ENOSPC && bufsize < ret) {
- syms = xrealloc(syms, bufsize = ret);
- goto retry_kern_sym_load;
- }
- perror_msg("kernel: QM_SYMBOLS");
- return 0;
- }
- nksyms = nsyms = ret;
- ksyms = syms;
-
- for (j = 0, s = syms; j < nsyms; ++j, ++s) {
- s->name += (unsigned long) syms;
- }
- return 1;
-}
-
-
-/* Return the kernel symbol checksum version, or zero if not used. */
-
-static int new_is_kernel_checksummed(void)
-{
- struct new_module_symbol *s;
- size_t i;
-
- /* Using_Versions is not the first symbol, but it should be in there. */
-
- for (i = 0, s = ksyms; i < nksyms; ++i, ++s)
- if (strcmp((char *) s->name, "Using_Versions") == 0)
- return s->value;
-
- return 0;
-}
-
-
-static int new_create_this_module(struct obj_file *f, const char *m_name)
-{
- struct obj_section *sec;
-
- sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long,
- sizeof(struct new_module));
- memset(sec->contents, 0, sizeof(struct new_module));
-
- obj_add_symbol(f, "__this_module", -1,
- ELFW(ST_INFO) (STB_LOCAL, STT_OBJECT), sec->idx, 0,
- sizeof(struct new_module));
-
- obj_string_patch(f, sec->idx, offsetof(struct new_module, name),
- m_name);
-
- return 1;
-}
-
-
-static int new_create_module_ksymtab(struct obj_file *f)
-{
- struct obj_section *sec;
- int i;
-
- /* We must always add the module references. */
-
- if (n_ext_modules_used) {
- struct new_module_ref *dep;
- struct obj_symbol *tm;
-
- sec = obj_create_alloced_section(f, ".kmodtab", tgt_sizeof_void_p,
- (sizeof(struct new_module_ref)
- * n_ext_modules_used));
- if (!sec)
- return 0;
-
- tm = obj_find_symbol(f, "__this_module");
- dep = (struct new_module_ref *) sec->contents;
- for (i = 0; i < n_ext_modules; ++i)
- if (ext_modules[i].used) {
- dep->dep = ext_modules[i].addr;
- obj_symbol_patch(f, sec->idx,
- (char *) &dep->ref - sec->contents, tm);
- dep->next_ref = 0;
- ++dep;
- }
- }
-
- if (flag_export && !obj_find_section(f, "__ksymtab")) {
- size_t nsyms;
- int *loaded;
-
- sec =
- obj_create_alloced_section(f, "__ksymtab", tgt_sizeof_void_p,
- 0);
-
- /* We don't want to export symbols residing in sections that
- aren't loaded. There are a number of these created so that
- we make sure certain module options don't appear twice. */
-
- loaded = alloca(sizeof(int) * (i = f->header.e_shnum));
- while (--i >= 0)
- loaded[i] = (f->sections[i]->header.sh_flags & SHF_ALLOC) != 0;
-
- for (nsyms = i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (ELFW(ST_BIND) (sym->info) != STB_LOCAL
- && sym->secidx <= SHN_HIRESERVE
- && (sym->secidx >= SHN_LORESERVE
- || loaded[sym->secidx])) {
- ElfW(Addr) ofs = nsyms * 2 * tgt_sizeof_void_p;
-
- obj_symbol_patch(f, sec->idx, ofs, sym);
- obj_string_patch(f, sec->idx, ofs + tgt_sizeof_void_p,
- sym->name);
-
- nsyms++;
- }
- }
-
- obj_extend_section(sec, nsyms * 2 * tgt_sizeof_char_p);
- }
-
- return 1;
-}
-
-
-static int
-new_init_module(const char *m_name, struct obj_file *f,
- unsigned long m_size)
-{
- struct new_module *module;
- struct obj_section *sec;
- void *image;
- int ret;
- tgt_long m_addr;
-
- sec = obj_find_section(f, ".this");
- if (!sec || !sec->contents) {
- perror_msg("corrupt module %s?",m_name);
- exit(EXIT_FAILURE);
- }
- module = (struct new_module *) sec->contents;
- m_addr = sec->header.sh_addr;
-
- module->size_of_struct = sizeof(*module);
- module->size = m_size;
- module->flags = flag_autoclean ? NEW_MOD_AUTOCLEAN : 0;
-
- sec = obj_find_section(f, "__ksymtab");
- if (sec && sec->header.sh_size) {
- module->syms = sec->header.sh_addr;
- module->nsyms = sec->header.sh_size / (2 * tgt_sizeof_char_p);
- }
-
- if (n_ext_modules_used) {
- sec = obj_find_section(f, ".kmodtab");
- module->deps = sec->header.sh_addr;
- module->ndeps = n_ext_modules_used;
- }
-
- module->init =
- obj_symbol_final_value(f, obj_find_symbol(f, "init_module"));
- module->cleanup =
- obj_symbol_final_value(f, obj_find_symbol(f, "cleanup_module"));
-
- sec = obj_find_section(f, "__ex_table");
- if (sec) {
- module->ex_table_start = sec->header.sh_addr;
- module->ex_table_end = sec->header.sh_addr + sec->header.sh_size;
- }
-
- sec = obj_find_section(f, ".text.init");
- if (sec) {
- module->runsize = sec->header.sh_addr - m_addr;
- }
- sec = obj_find_section(f, ".data.init");
- if (sec) {
- if (!module->runsize ||
- module->runsize > sec->header.sh_addr - m_addr)
- module->runsize = sec->header.sh_addr - m_addr;
- }
- sec = obj_find_section(f, ARCHDATA_SEC_NAME);
- if (sec && sec->header.sh_size) {
- module->archdata_start = (void*)sec->header.sh_addr;
- module->archdata_end = module->archdata_start + sec->header.sh_size;
- }
- sec = obj_find_section(f, KALLSYMS_SEC_NAME);
- if (sec && sec->header.sh_size) {
- module->kallsyms_start = (void*)sec->header.sh_addr;
- module->kallsyms_end = module->kallsyms_start + sec->header.sh_size;
- }
-
- if (!arch_init_module(f, module))
- return 0;
-
- /* Whew! All of the initialization is complete. Collect the final
- module image and give it to the kernel. */
-
- image = xmalloc(m_size);
- obj_create_image(f, image);
-
- ret = new_sys_init_module(m_name, (struct new_module *) image);
- if (ret)
- perror_msg("init_module: %s", m_name);
-
- free(image);
-
- return ret == 0;
-}
-
-#else
-
-#define new_init_module(x, y, z) TRUE
-#define new_create_this_module(x, y) 0
-#define new_create_module_ksymtab(x)
-#define query_module(v, w, x, y, z) -1
-
-#endif /* BB_FEATURE_NEW_MODULE_INTERFACE */
-
-
-/*======================================================================*/
-
-static int
-obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
- const char *string)
-{
- struct obj_string_patch *p;
- struct obj_section *strsec;
- size_t len = strlen(string) + 1;
- char *loc;
-
- p = xmalloc(sizeof(*p));
- p->next = f->string_patches;
- p->reloc_secidx = secidx;
- p->reloc_offset = offset;
- f->string_patches = p;
-
- strsec = obj_find_section(f, ".kstrtab");
- if (strsec == NULL) {
- strsec = obj_create_alloced_section(f, ".kstrtab", 1, len);
- p->string_offset = 0;
- loc = strsec->contents;
- } else {
- p->string_offset = strsec->header.sh_size;
- loc = obj_extend_section(strsec, len);
- }
- memcpy(loc, string, len);
-
- return 1;
-}
-
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-static int
-obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
- struct obj_symbol *sym)
-{
- struct obj_symbol_patch *p;
-
- p = xmalloc(sizeof(*p));
- p->next = f->symbol_patches;
- p->reloc_secidx = secidx;
- p->reloc_offset = offset;
- p->sym = sym;
- f->symbol_patches = p;
-
- return 1;
-}
-#endif
-
-static int obj_check_undefineds(struct obj_file *f)
-{
- unsigned long i;
- int ret = 1;
-
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (sym->secidx == SHN_UNDEF) {
- if (ELFW(ST_BIND) (sym->info) == STB_WEAK) {
- sym->secidx = SHN_ABS;
- sym->value = 0;
- } else {
- if (!flag_quiet) {
- error_msg("unresolved symbol %s", sym->name);
- }
- ret = 0;
- }
- }
- }
-
- return ret;
-}
-
-static void obj_allocate_commons(struct obj_file *f)
-{
- struct common_entry {
- struct common_entry *next;
- struct obj_symbol *sym;
- } *common_head = NULL;
-
- unsigned long i;
-
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (sym->secidx == SHN_COMMON) {
- /* Collect all COMMON symbols and sort them by size so as to
- minimize space wasted by alignment requirements. */
- {
- struct common_entry **p, *n;
- for (p = &common_head; *p; p = &(*p)->next)
- if (sym->size <= (*p)->sym->size)
- break;
-
- n = alloca(sizeof(*n));
- n->next = *p;
- n->sym = sym;
- *p = n;
- }
- }
- }
-
- for (i = 1; i < f->local_symtab_size; ++i) {
- struct obj_symbol *sym = f->local_symtab[i];
- if (sym && sym->secidx == SHN_COMMON) {
- struct common_entry **p, *n;
- for (p = &common_head; *p; p = &(*p)->next)
- if (sym == (*p)->sym)
- break;
- else if (sym->size < (*p)->sym->size) {
- n = alloca(sizeof(*n));
- n->next = *p;
- n->sym = sym;
- *p = n;
- break;
- }
- }
- }
-
- if (common_head) {
- /* Find the bss section. */
- for (i = 0; i < f->header.e_shnum; ++i)
- if (f->sections[i]->header.sh_type == SHT_NOBITS)
- break;
-
- /* If for some reason there hadn't been one, create one. */
- if (i == f->header.e_shnum) {
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (i + 1) * sizeof(sec));
- f->sections[i] = sec = arch_new_section();
- f->header.e_shnum = i + 1;
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = SHF_WRITE | SHF_ALLOC;
- sec->name = ".bss";
- sec->idx = i;
- }
-
- /* Allocate the COMMONS. */
- {
- ElfW(Addr) bss_size = f->sections[i]->header.sh_size;
- ElfW(Addr) max_align = f->sections[i]->header.sh_addralign;
- struct common_entry *c;
-
- for (c = common_head; c; c = c->next) {
- ElfW(Addr) align = c->sym->value;
-
- if (align > max_align)
- max_align = align;
- if (bss_size & (align - 1))
- bss_size = (bss_size | (align - 1)) + 1;
-
- c->sym->secidx = i;
- c->sym->value = bss_size;
-
- bss_size += c->sym->size;
- }
-
- f->sections[i]->header.sh_size = bss_size;
- f->sections[i]->header.sh_addralign = max_align;
- }
- }
-
- /* For the sake of patch relocation and parameter initialization,
- allocate zeroed data for NOBITS sections now. Note that after
- this we cannot assume NOBITS are really empty. */
- for (i = 0; i < f->header.e_shnum; ++i) {
- struct obj_section *s = f->sections[i];
- if (s->header.sh_type == SHT_NOBITS) {
- if (s->header.sh_size != 0)
- s->contents = memset(xmalloc(s->header.sh_size),
- 0, s->header.sh_size);
- else
- s->contents = NULL;
-
- s->header.sh_type = SHT_PROGBITS;
- }
- }
-}
-
-static unsigned long obj_load_size(struct obj_file *f)
-{
- unsigned long dot = 0;
- struct obj_section *sec;
-
- /* Finalize the positions of the sections relative to one another. */
-
- for (sec = f->load_order; sec; sec = sec->load_next) {
- ElfW(Addr) align;
-
- align = sec->header.sh_addralign;
- if (align && (dot & (align - 1)))
- dot = (dot | (align - 1)) + 1;
-
- sec->header.sh_addr = dot;
- dot += sec->header.sh_size;
- }
-
- return dot;
-}
-
-static int obj_relocate(struct obj_file *f, ElfW(Addr) base)
-{
- int i, n = f->header.e_shnum;
- int ret = 1;
-
- /* Finalize the addresses of the sections. */
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
-
- /* And iterate over all of the relocations. */
-
- for (i = 0; i < n; ++i) {
- struct obj_section *relsec, *symsec, *targsec, *strsec;
- ElfW(RelM) * rel, *relend;
- ElfW(Sym) * symtab;
- const char *strtab;
-
- relsec = f->sections[i];
- if (relsec->header.sh_type != SHT_RELM)
- continue;
-
- symsec = f->sections[relsec->header.sh_link];
- targsec = f->sections[relsec->header.sh_info];
- strsec = f->sections[symsec->header.sh_link];
-
- rel = (ElfW(RelM) *) relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(ElfW(RelM)));
- symtab = (ElfW(Sym) *) symsec->contents;
- strtab = (const char *) strsec->contents;
-
- for (; rel < relend; ++rel) {
- ElfW(Addr) value = 0;
- struct obj_symbol *intsym = NULL;
- unsigned long symndx;
- ElfW(Sym) * extsym = 0;
- const char *errmsg;
-
- /* Attempt to find a value to use for this relocation. */
-
- symndx = ELFW(R_SYM) (rel->r_info);
- if (symndx) {
- /* Note we've already checked for undefined symbols. */
-
- extsym = &symtab[symndx];
- if (ELFW(ST_BIND) (extsym->st_info) == STB_LOCAL) {
- /* Local symbols we look up in the local table to be sure
- we get the one that is really intended. */
- intsym = f->local_symtab[symndx];
- } else {
- /* Others we look up in the hash table. */
- const char *name;
- if (extsym->st_name)
- name = strtab + extsym->st_name;
- else
- name = f->sections[extsym->st_shndx]->name;
- intsym = obj_find_symbol(f, name);
- }
-
- value = obj_symbol_final_value(f, intsym);
- intsym->referenced = 1;
- }
-#if SHT_RELM == SHT_RELA
-#if defined(__alpha__) && defined(AXP_BROKEN_GAS)
- /* Work around a nasty GAS bug, that is fixed as of 2.7.0.9. */
- if (!extsym || !extsym->st_name ||
- ELFW(ST_BIND) (extsym->st_info) != STB_LOCAL)
-#endif
- value += rel->r_addend;
-#endif
-
- /* Do it! */
- switch (arch_apply_relocation
- (f, targsec, symsec, intsym, rel, value)) {
- case obj_reloc_ok:
- break;
-
- case obj_reloc_overflow:
- errmsg = "Relocation overflow";
- goto bad_reloc;
- case obj_reloc_dangerous:
- errmsg = "Dangerous relocation";
- goto bad_reloc;
- case obj_reloc_unhandled:
- errmsg = "Unhandled relocation";
- bad_reloc:
- if (extsym) {
- error_msg("%s of type %ld for %s", errmsg,
- (long) ELFW(R_TYPE) (rel->r_info),
- strtab + extsym->st_name);
- } else {
- error_msg("%s of type %ld", errmsg,
- (long) ELFW(R_TYPE) (rel->r_info));
- }
- ret = 0;
- break;
- }
- }
- }
-
- /* Finally, take care of the patches. */
-
- if (f->string_patches) {
- struct obj_string_patch *p;
- struct obj_section *strsec;
- ElfW(Addr) strsec_base;
- strsec = obj_find_section(f, ".kstrtab");
- strsec_base = strsec->header.sh_addr;
-
- for (p = f->string_patches; p; p = p->next) {
- struct obj_section *targsec = f->sections[p->reloc_secidx];
- *(ElfW(Addr) *) (targsec->contents + p->reloc_offset)
- = strsec_base + p->string_offset;
- }
- }
-
- if (f->symbol_patches) {
- struct obj_symbol_patch *p;
-
- for (p = f->symbol_patches; p; p = p->next) {
- struct obj_section *targsec = f->sections[p->reloc_secidx];
- *(ElfW(Addr) *) (targsec->contents + p->reloc_offset)
- = obj_symbol_final_value(f, p->sym);
- }
- }
-
- return ret;
-}
-
-static int obj_create_image(struct obj_file *f, char *image)
-{
- struct obj_section *sec;
- ElfW(Addr) base = f->baseaddr;
-
- for (sec = f->load_order; sec; sec = sec->load_next) {
- char *secimg;
-
- if (sec->contents == 0 || sec->header.sh_size == 0)
- continue;
-
- secimg = image + (sec->header.sh_addr - base);
-
- /* Note that we allocated data for NOBITS sections earlier. */
- memcpy(secimg, sec->contents, sec->header.sh_size);
- }
-
- return 1;
-}
-
-/*======================================================================*/
-
-static struct obj_file *obj_load(FILE * fp, int loadprogbits)
-{
- struct obj_file *f;
- ElfW(Shdr) * section_headers;
- int shnum, i;
- char *shstrtab;
-
- /* Read the file header. */
-
- f = arch_new_file();
- memset(f, 0, sizeof(*f));
- f->symbol_cmp = strcmp;
- f->symbol_hash = obj_elf_hash;
- f->load_order_search_start = &f->load_order;
-
- fseek(fp, 0, SEEK_SET);
- if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
- perror_msg("error reading ELF header");
- return NULL;
- }
-
- if (f->header.e_ident[EI_MAG0] != ELFMAG0
- || f->header.e_ident[EI_MAG1] != ELFMAG1
- || f->header.e_ident[EI_MAG2] != ELFMAG2
- || f->header.e_ident[EI_MAG3] != ELFMAG3) {
- error_msg("not an ELF file");
- return NULL;
- }
- if (f->header.e_ident[EI_CLASS] != ELFCLASSM
- || f->header.e_ident[EI_DATA] != ELFDATAM
- || f->header.e_ident[EI_VERSION] != EV_CURRENT
- || !MATCH_MACHINE(f->header.e_machine)) {
- error_msg("ELF file not for this architecture");
- return NULL;
- }
- if (f->header.e_type != ET_REL) {
- error_msg("ELF file not a relocatable object");
- return NULL;
- }
-
- /* Read the section headers. */
-
- if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
- error_msg("section header size mismatch: %lu != %lu",
- (unsigned long) f->header.e_shentsize,
- (unsigned long) sizeof(ElfW(Shdr)));
- return NULL;
- }
-
- shnum = f->header.e_shnum;
- f->sections = xmalloc(sizeof(struct obj_section *) * shnum);
- memset(f->sections, 0, sizeof(struct obj_section *) * shnum);
-
- section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
- fseek(fp, f->header.e_shoff, SEEK_SET);
- if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
- perror_msg("error reading ELF section headers");
- return NULL;
- }
-
- /* Read the section data. */
-
- for (i = 0; i < shnum; ++i) {
- struct obj_section *sec;
-
- f->sections[i] = sec = arch_new_section();
- memset(sec, 0, sizeof(*sec));
-
- sec->header = section_headers[i];
- sec->idx = i;
-
- if(sec->header.sh_size) switch (sec->header.sh_type) {
- case SHT_NULL:
- case SHT_NOTE:
- case SHT_NOBITS:
- /* ignore */
- break;
-
- case SHT_PROGBITS:
-#if LOADBITS
- if (!loadprogbits) {
- sec->contents = NULL;
- break;
- }
-#endif
- case SHT_SYMTAB:
- case SHT_STRTAB:
- case SHT_RELM:
- if (sec->header.sh_size > 0) {
- sec->contents = xmalloc(sec->header.sh_size);
- fseek(fp, sec->header.sh_offset, SEEK_SET);
- if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
- perror_msg("error reading ELF section data");
- return NULL;
- }
- } else {
- sec->contents = NULL;
- }
- break;
-
-#if SHT_RELM == SHT_REL
- case SHT_RELA:
- error_msg("RELA relocations not supported on this architecture");
- return NULL;
-#else
- case SHT_REL:
- error_msg("REL relocations not supported on this architecture");
- return NULL;
-#endif
-
- default:
- if (sec->header.sh_type >= SHT_LOPROC) {
- /* Assume processor specific section types are debug
- info and can safely be ignored. If this is ever not
- the case (Hello MIPS?), don't put ifdefs here but
- create an arch_load_proc_section(). */
- break;
- }
-
- error_msg("can't handle sections of type %ld",
- (long) sec->header.sh_type);
- return NULL;
- }
- }
-
- /* Do what sort of interpretation as needed by each section. */
-
- shstrtab = f->sections[f->header.e_shstrndx]->contents;
-
- for (i = 0; i < shnum; ++i) {
- struct obj_section *sec = f->sections[i];
- sec->name = shstrtab + sec->header.sh_name;
- }
-
- for (i = 0; i < shnum; ++i) {
- struct obj_section *sec = f->sections[i];
-
- /* .modinfo should be contents only but gcc has no attribute for that.
- * The kernel may have marked .modinfo as ALLOC, ignore this bit.
- */
- if (strcmp(sec->name, ".modinfo") == 0)
- sec->header.sh_flags &= ~SHF_ALLOC;
-
- if (sec->header.sh_flags & SHF_ALLOC)
- obj_insert_section_load_order(f, sec);
-
- switch (sec->header.sh_type) {
- case SHT_SYMTAB:
- {
- unsigned long nsym, j;
- char *strtab;
- ElfW(Sym) * sym;
-
- if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
- error_msg("symbol size mismatch: %lu != %lu",
- (unsigned long) sec->header.sh_entsize,
- (unsigned long) sizeof(ElfW(Sym)));
- return NULL;
- }
-
- nsym = sec->header.sh_size / sizeof(ElfW(Sym));
- strtab = f->sections[sec->header.sh_link]->contents;
- sym = (ElfW(Sym) *) sec->contents;
-
- /* Allocate space for a table of local symbols. */
- j = f->local_symtab_size = sec->header.sh_info;
- f->local_symtab = xcalloc(j, sizeof(struct obj_symbol *));
-
- /* Insert all symbols into the hash table. */
- for (j = 1, ++sym; j < nsym; ++j, ++sym) {
- const char *name;
- if (sym->st_name)
- name = strtab + sym->st_name;
- else
- name = f->sections[sym->st_shndx]->name;
-
- obj_add_symbol(f, name, j, sym->st_info, sym->st_shndx,
- sym->st_value, sym->st_size);
- }
- }
- break;
-
- case SHT_RELM:
- if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
- error_msg("relocation entry size mismatch: %lu != %lu",
- (unsigned long) sec->header.sh_entsize,
- (unsigned long) sizeof(ElfW(RelM)));
- return NULL;
- }
- break;
- /* XXX Relocation code from modutils-2.3.19 is not here.
- * Why? That's about 20 lines of code from obj/obj_load.c,
- * which gets done in a second pass through the sections.
- * This BusyBox insmod does similar work in obj_relocate(). */
- }
- }
-
- return f;
-}
-
-#ifdef BB_FEATURE_INSMOD_LOADINKMEM
-/*
- * load the unloaded sections directly into the memory allocated by
- * kernel for the module
- */
-
-static int obj_load_progbits(FILE * fp, struct obj_file* f, char* imagebase)
-{
- ElfW(Addr) base = f->baseaddr;
- struct obj_section* sec;
-
- for (sec = f->load_order; sec; sec = sec->load_next) {
-
- /* section already loaded? */
- if (sec->contents != NULL)
- continue;
-
- if (sec->header.sh_size == 0)
- continue;
-
- sec->contents = imagebase + (sec->header.sh_addr - base);
- fseek(fp, sec->header.sh_offset, SEEK_SET);
- if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
- error_msg("error reading ELF section data: %s\n", strerror(errno));
- return 0;
- }
-
- }
- return 1;
-}
-#endif
-
-static void hide_special_symbols(struct obj_file *f)
-{
- static const char *const specials[] = {
- "cleanup_module",
- "init_module",
- "kernel_version",
- NULL
- };
-
- struct obj_symbol *sym;
- const char *const *p;
-
- for (p = specials; *p; ++p)
- if ((sym = obj_find_symbol(f, *p)) != NULL)
- sym->info =
- ELFW(ST_INFO) (STB_LOCAL, ELFW(ST_TYPE) (sym->info));
-}
-
-#ifdef BB_FEATURE_INSMOD_CHECK_TAINTED
-static int obj_gpl_license(struct obj_file *f, const char **license)
-{
- struct obj_section *sec;
- /* This list must match *exactly* the list of allowable licenses in
- * linux/include/linux/module.h. Checking for leading "GPL" will not
- * work, somebody will use "GPL sucks, this is proprietary".
- */
- static const char *gpl_licenses[] = {
- "GPL",
- "GPL v2",
- "GPL and additional rights",
- "Dual BSD/GPL",
- "Dual MPL/GPL",
- };
-
- if ((sec = obj_find_section(f, ".modinfo"))) {
- const char *value, *ptr, *endptr;
- ptr = sec->contents;
- endptr = ptr + sec->header.sh_size;
- while (ptr < endptr) {
- if ((value = strchr(ptr, '=')) && strncmp(ptr, "license", value-ptr) == 0) {
- int i;
- if (license)
- *license = value+1;
- for (i = 0; i < sizeof(gpl_licenses)/sizeof(gpl_licenses[0]); ++i) {
- if (strcmp(value+1, gpl_licenses[i]) == 0)
- return(0);
- }
- return(2);
- }
- if (strchr(ptr, '\0'))
- ptr = strchr(ptr, '\0') + 1;
- else
- ptr = endptr;
- }
- }
- return(1);
-}
-
-#define TAINT_FILENAME "/proc/sys/kernel/tainted"
-#define TAINT_PROPRIETORY_MODULE (1<<0)
-#define TAINT_FORCED_MODULE (1<<1)
-#define TAINT_UNSAFE_SMP (1<<2)
-#define TAINT_URL "http://www.tux.org/lkml/#export-tainted"
-
-static void set_tainted(struct obj_file *f, int fd, char *m_name,
- int kernel_has_tainted, int taint, const char *text1, const char *text2)
-{
- char buf[80];
- int oldval;
- static int first = 1;
- if (fd < 0 && !kernel_has_tainted)
- return; /* New modutils on old kernel */
- printf("Warning: loading %s will taint the kernel: %s%s\n",
- m_name, text1, text2);
- if (first) {
- printf(" See %s for information about tainted modules\n", TAINT_URL);
- first = 0;
- }
- if (fd >= 0) {
- read(fd, buf, sizeof(buf)-1);
- buf[sizeof(buf)-1] = '\0';
- oldval = strtoul(buf, NULL, 10);
- sprintf(buf, "%d\n", oldval | taint);
- write(fd, buf, strlen(buf));
- }
-}
-#endif
-
-/* Check if loading this module will taint the kernel. */
-static void check_tainted_module(struct obj_file *f, char *m_name)
-{
-#ifdef BB_FEATURE_INSMOD_CHECK_TAINTED
- static const char tainted_file[] = TAINT_FILENAME;
- int fd, kernel_has_tainted;
- const char *ptr;
-
- kernel_has_tainted = 1;
- if ((fd = open(tainted_file, O_RDWR)) < 0) {
- if (errno == ENOENT)
- kernel_has_tainted = 0;
- else if (errno == EACCES)
- kernel_has_tainted = 1;
- else {
- perror(tainted_file);
- kernel_has_tainted = 0;
- }
- }
-
- switch (obj_gpl_license(f, &ptr)) {
- case 0:
- break;
- case 1:
- set_tainted(f, fd, m_name, kernel_has_tainted, TAINT_PROPRIETORY_MODULE, "no license", "");
- break;
- case 2:
- /* The module has a non-GPL license so we pretend that the
- * kernel always has a taint flag to get a warning even on
- * kernels without the proc flag.
- */
- set_tainted(f, fd, m_name, 1, TAINT_PROPRIETORY_MODULE, "non-GPL license - ", ptr);
- break;
- default:
- set_tainted(f, fd, m_name, 1, TAINT_PROPRIETORY_MODULE, "Unexpected return from obj_gpl_license", "");
- break;
- }
-
- if (flag_force_load)
- set_tainted(f, fd, m_name, 1, TAINT_FORCED_MODULE, "forced load", "");
-
- if (fd >= 0)
- close(fd);
-#endif
-}
-
-void my_usage(void)
-{
- printf("Usage.");
- exit(0);
-}
-
-extern int insmod_main( int argc, char **argv)
-{
- int k_crcs;
- int k_new_syscalls;
- int len;
- char *tmp;
- unsigned long m_size;
- ElfW(Addr) m_addr;
- FILE *fp;
- struct obj_file *f;
- char m_name[FILENAME_MAX] = "\0";
- int exit_status = EXIT_FAILURE;
- int m_has_modinfo;
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
- struct utsname uts_info;
- char m_strversion[STRVERSIONLEN];
- int m_version;
- int m_crcs;
-#endif
-
- if (argc <= 1)
- my_usage();
-
- argv++; argc--;
-
- /* Grab the module name */
- if ((tmp = strrchr(*argv, '/')) != NULL) {
- tmp++;
- } else {
- tmp = *argv;
- }
- len = strlen(tmp);
-
- if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o')
- len -= 2;
- memcpy(m_name, tmp, len);
- strcpy(m_fullName, m_name);
- strcat(m_fullName, ".o");
-
- /* Get a filedesc for the module. Check we we have a complete path */
- if ((fp = fopen(*argv, "r")) == NULL) {
- errorMsg("Module %s not found", *argv);
- return -1;
- } else
- memcpy(m_filename, *argv, strlen(*argv));
-
-
- if ((f = obj_load(fp, LOADBITS)) == NULL) {
- logperror("Could not load the module");
- goto out;
- }
-
- if (get_modinfo_value(f, "kernel_version") == NULL)
- m_has_modinfo = 0;
- else
- m_has_modinfo = 1;
-
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
- /* Version correspondence? */
- if (!flag_quiet) {
- if (uname(&uts_info) < 0)
- uts_info.release[0] = '\0';
- if (m_has_modinfo) {
- m_version = new_get_module_version(f, m_strversion);
- } else {
- m_version = old_get_module_version(f, m_strversion);
- if (m_version == -1) {
- error_msg("couldn't find the kernel version the module was "
- "compiled for");
- goto out;
- }
- }
-
- if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) {
- if (flag_force_load) {
- error_msg("Warning: kernel-module version mismatch\n"
- "\t%s was compiled for kernel version %s\n"
- "\twhile this kernel is version %s",
- m_filename, m_strversion, uts_info.release);
- } else {
- error_msg("kernel-module version mismatch\n"
- "\t%s was compiled for kernel version %s\n"
- "\twhile this kernel is version %s.",
- m_filename, m_strversion, uts_info.release);
- goto out;
- }
- }
- }
- k_crcs = 0;
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
- k_new_syscalls = !query_module(NULL, 0, NULL, 0, NULL);
-
- if (k_new_syscalls) {
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
- if (!new_get_kernel_symbols())
- goto out;
- k_crcs = new_is_kernel_checksummed();
-#else
- error_msg("Not configured to support new kernels");
- goto out;
-#endif
- } else {
-#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
- if (!old_get_kernel_symbols(m_name))
- goto out;
- k_crcs = old_is_kernel_checksummed();
-#else
- error_msg("Not configured to support old kernels");
- goto out;
-#endif
- }
-
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
- if (m_has_modinfo)
- m_crcs = new_is_module_checksummed(f);
- else
- m_crcs = old_is_module_checksummed(f);
-
- if (m_crcs != k_crcs)
- obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
- /* Let the module know about the kernel symbols. */
- add_kernel_symbols(f);
-
- /* Allocate common symbols, symbol tables, and string tables. */
-
- if (k_new_syscalls
- ? !new_create_this_module(f, m_name)
- : !old_create_mod_use_count(f))
- {
- goto out;
- }
-
- if (!obj_check_undefineds(f)) {
- goto out;
- }
- obj_allocate_commons(f);
- check_tainted_module(f, m_name);
-
- if (m_has_modinfo
- ? !new_process_module_arguments(f, argc - 1, argv + 1)
- : !old_process_module_arguments(f, argc - 1, argv + 1))
- {
- goto out;
- }
-
- arch_create_got(f);
- hide_special_symbols(f);
-
- if (k_new_syscalls)
- new_create_module_ksymtab(f);
-
- /* Find current size of the module */
- m_size = obj_load_size(f);
-
-
- m_addr = create_module(m_name, m_size);
- if (m_addr==-1) switch (errno) {
- case EEXIST:
- error_msg("A module named %s already exists", m_name);
- goto out;
- case ENOMEM:
- error_msg("Can't allocate kernel memory for module; needed %lu bytes",
- m_size);
- goto out;
- default:
- perror_msg("create_module: %s", m_name);
- goto out;
- }
-
-#if !LOADBITS
- /*
- * the PROGBITS section was not loaded by the obj_load
- * now we can load them directly into the kernel memory
- */
- if (!obj_load_progbits(fp, f, (char*)m_addr)) {
- delete_module(m_name);
- goto out;
- }
-#endif
-
- if (!obj_relocate(f, m_addr)) {
- delete_module(m_name);
- goto out;
- }
-
- if (k_new_syscalls
- ? !new_init_module(m_name, f, m_size)
- : !old_init_module(m_name, f, m_size))
- {
- delete_module(m_name);
- goto out;
- }
-
- exit_status = EXIT_SUCCESS;
-
-out:
- fclose(fp);
- return(exit_status);
-}
-
-int insmod_call(char * full_filename, char * params)
-{
- int argc = 2;
- char *argv[50];
- char * ptr = params;
- argv[0] = "stage1";
- argv[1] = full_filename;
-
- while (ptr != NULL) {
- argv[argc] = ptr;
- argc++;
- ptr = strchr(ptr, ' ');
- if (ptr) {
- ptr[0] = '\0';
- ptr++;
- }
- }
-
- return insmod_main(argc, argv);
-}
diff --git a/mdk-stage1/insmod-busybox/loop.h b/mdk-stage1/insmod-busybox/loop.h
deleted file mode 100644
index cba8c6b2b..000000000
--- a/mdk-stage1/insmod-busybox/loop.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <linux/posix_types.h>
-#undef dev_t
-#define dev_t __kernel_dev_t
-#include <linux/loop.h>
-#undef dev_t
diff --git a/mdk-stage1/insmod-busybox/messages.c b/mdk-stage1/insmod-busybox/messages.c
deleted file mode 100644
index 81fd9c75c..000000000
--- a/mdk-stage1/insmod-busybox/messages.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Copyright (C) 2000 by BitterSweet Enterprises, LLC.
- * Written by Karl M. Hegbloom <karlheg@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-/*
- * Let's put all of these messages in one place, and link this in as
- * a separate object module, so that there are not going to be
- * multiple non-unique but very similar strings in the binary.
- * Perhaps this will make it simpler to internationalize also, and
- * may make the binary slightly smaller.
- */
-
-// To use this header file, include something like this:
-//
-//#define BB_DECLARE_EXTERN
-//#define bb_need_memory_exhausted
-//#include "messages.c"
-//
-//Then just use the string memory_exhausted when it is needed.
-//
-
-#include "busybox.h"
-#ifndef _BB_MESSAGES_C
-#define _BB_MESSAGES_C
-
-#ifdef BB_DECLARE_EXTERN
-# define BB_DEF_MESSAGE(symbol, string_const) extern const char *symbol;
-#else
-# define BB_DEF_MESSAGE(symbol, string_const) const char *symbol = string_const;
-#endif
-
-
-#if defined bb_need_full_version || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(full_version,
- "BusyBox v" BB_VER " (" BB_BT ") multi-call binary -- GPL2")
-#endif
-#if defined bb_need_name_too_long || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(name_too_long, "file name too long\n")
-#endif
-#if defined bb_need_omitting_directory || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(omitting_directory, "%s: omitting directory\n")
-#endif
-#if defined bb_need_not_a_directory || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(not_a_directory, "%s: not a directory\n")
-#endif
-#if defined bb_need_memory_exhausted || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(memory_exhausted, "memory exhausted\n")
-#endif
-#if defined bb_need_invalid_date || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(invalid_date, "invalid date `%s'\n")
-#endif
-#if defined bb_need_invalid_option || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(invalid_option, "invalid option -- %c\n")
-#endif
-#if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n")
-#endif
-#if defined bb_need_help || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(dash_dash_help, "--help")
-#endif
-#if defined bb_need_write_error || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(write_error, "Write Error\n")
-#endif
-#if defined bb_need_too_few_args || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(too_few_args, "too few arguments\n")
-#endif
-#if defined bb_need_name_longer_then_foo || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(name_longer_then_foo, "Names longer then %d chars not supported.\n")
-#endif
-
-
-#endif /* _BB_MESSAGES_C */
-
diff --git a/mdk-stage1/insmod-busybox/utility.c b/mdk-stage1/insmod-busybox/utility.c
deleted file mode 100644
index ffd323347..000000000
--- a/mdk-stage1/insmod-busybox/utility.c
+++ /dev/null
@@ -1,1759 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) tons of folks. Tracking down who wrote what
- * isn't something I'm going to worry about... If you wrote something
- * here, please feel free to acknowledge your work.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
- * Permission has been granted to redistribute this code under the GPL.
- *
- */
-
-#include "busybox.h"
-#if defined (BB_CHMOD_CHOWN_CHGRP) \
- || defined (BB_CP_MV) \
- || defined (BB_FIND) \
- || defined (BB_INSMOD) \
- || defined (BB_LS) \
- || defined (BB_RM) \
- || defined (BB_TAR)
-/* same conditions as recursiveAction */
-#define bb_need_name_too_long
-#endif
-#define bb_need_memory_exhausted
-#define bb_need_full_version
-#define BB_DECLARE_EXTERN
-#include "messages.c"
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <time.h>
-#include <utime.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <sys/ioctl.h>
-#include <sys/utsname.h> /* for uname(2) */
-
-/* Busybox mount uses either /proc/filesystems or /dev/mtab to get the
- * list of available filesystems used for the -t auto option */
-#if defined BB_FEATURE_USE_PROCFS && defined BB_FEATURE_USE_DEVPS_PATCH
-//#error Sorry, but busybox can't use both /proc and /dev/ps at the same time -- Pick one and try again.
-#error "Sorry, but busybox can't use both /proc and /dev/ps at the same time -- Pick one and try again."
-#endif
-
-
-#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
-# if defined BB_MTAB
-const char mtab_file[] = "/etc/mtab";
-# else
-# if defined BB_FEATURE_USE_PROCFS
-const char mtab_file[] = "/proc/mounts";
-# else
-# if defined BB_FEATURE_USE_DEVPS_PATCH
-const char mtab_file[] = "/dev/mtab";
-# else
-# error With (BB_MOUNT||BB_UMOUNT||BB_DF) defined, you must define either BB_MTAB or ( BB_FEATURE_USE_PROCFS | BB_FEATURE_USE_DEVPS_PATCH)
-# endif
-# endif
-# endif
-#endif
-
-#ifdef _STANDALONE_
-void errorMsg(const char *s, ...)
-{
- va_list p;
-
- fflush(stdout);
- printf("busybox: ");
- va_start(p, s);
- vprintf(s, p);
- va_end(p);
- printf("\n");
- fflush(stdout);
-}
-
-extern void logperror(char *s)
-{
- perror(s);
-}
-
-void fatalError(const char *s, ...)
-{
- va_list p;
-
- fflush(stdout);
- fprintf(stdout, "busybox: ");
- va_start(p, s);
- vfprintf(stdout, s, p);
- va_end(p);
- fprintf(stdout, "\n");
- fflush(stdout);
- exit(FALSE);
-}
-#else /* _STANDALONE_ */
-#include "../log.h"
-extern void errorMsg(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- vlog_message(s, p);
- va_end(p);
-}
-
-extern void logperror(char *s)
-{
- log_perror(s);
-}
-
-extern void fatalError(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- vlog_message(s, p);
- va_end(p);
- while (1);
-}
-#endif /* _STANDALONE_ */
-
-
-#if defined BB_INIT
-/* Returns kernel version encoded as major*65536 + minor*256 + patch,
- * so, for example, to check if the kernel is greater than 2.2.11:
- * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
- */
-extern int get_kernel_revision(void)
-{
- struct utsname name;
- int major = 0, minor = 0, patch = 0;
-
- if (uname(&name) == -1) {
- perror("cannot get system information");
- return (0);
- }
- sscanf(name.version, "%d.%d.%d", &major, &minor, &patch);
- return major * 65536 + minor * 256 + patch;
-}
-#endif /* BB_INIT */
-
-
-
-#if defined BB_FREE || defined BB_INIT || defined BB_UNAME || defined BB_UPTIME
-_syscall1(int, sysinfo, struct sysinfo *, info);
-#endif /* BB_INIT */
-
-#if defined BB_MOUNT || defined BB_UMOUNT
-
-#ifndef __NR_umount2
-#define __NR_umount2 52
-#endif
-
-/* Include our own version of <sys/mount.h>, since libc5 doesn't
- * know about umount2 */
-extern _syscall1(int, umount, const char *, special_file);
-extern _syscall2(int, umount2, const char *, special_file, int, flags);
-extern _syscall5(int, mount, const char *, special_file, const char *, dir,
- const char *, fstype, unsigned long int, rwflag, const void *, data);
-#endif
-
-#if defined BB_INSMOD || defined BB_LSMOD
-#ifndef __NR_query_module
-#define __NR_query_module 167
-#endif
-_syscall5(int, query_module, const char *, name, int, which,
- void *, buf, size_t, bufsize, size_t*, ret);
-#endif
-
-
-#if defined (BB_CP_MV) || defined (BB_DU)
-
-#define HASH_SIZE 311 /* Should be prime */
-#define hash_inode(i) ((i) % HASH_SIZE)
-
-static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
-
-/*
- * Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
- * `ino_dev_hashtable', else return 0
- *
- * If NAME is a non-NULL pointer to a character pointer, and there is
- * a match, then set *NAME to the value of the name slot in that
- * bucket.
- */
-int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
-{
- ino_dev_hashtable_bucket_t *bucket;
-
- bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
- while (bucket != NULL) {
- if ((bucket->ino == statbuf->st_ino) &&
- (bucket->dev == statbuf->st_dev))
- {
- if (name) *name = bucket->name;
- return 1;
- }
- bucket = bucket->next;
- }
- return 0;
-}
-
-/* Add statbuf to statbuf hash table */
-void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
-{
- int i;
- size_t s;
- ino_dev_hashtable_bucket_t *bucket;
-
- i = hash_inode(statbuf->st_ino);
- s = name ? strlen(name) : 0;
- bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
- bucket->ino = statbuf->st_ino;
- bucket->dev = statbuf->st_dev;
- if (name)
- strcpy(bucket->name, name);
- else
- bucket->name[0] = '\0';
- bucket->next = ino_dev_hashtable[i];
- ino_dev_hashtable[i] = bucket;
-}
-
-/* Clear statbuf hash table */
-void reset_ino_dev_hashtable(void)
-{
- int i;
- ino_dev_hashtable_bucket_t *bucket;
-
- for (i = 0; i < HASH_SIZE; i++) {
- while (ino_dev_hashtable[i] != NULL) {
- bucket = ino_dev_hashtable[i]->next;
- free(ino_dev_hashtable[i]);
- ino_dev_hashtable[i] = bucket;
- }
- }
-}
-
-#endif /* BB_CP_MV || BB_DU */
-
-#if defined (BB_CP_MV) || defined (BB_DU) || defined (BB_LN) || defined (BB_AR)
-/*
- * Return TRUE if a fileName is a directory.
- * Nonexistant files return FALSE.
- */
-int isDirectory(const char *fileName, const int followLinks, struct stat *statBuf)
-{
- int status;
- int didMalloc = 0;
-
- if (statBuf == NULL) {
- statBuf = (struct stat *)xmalloc(sizeof(struct stat));
- ++didMalloc;
- }
-
- if (followLinks == TRUE)
- status = stat(fileName, statBuf);
- else
- status = lstat(fileName, statBuf);
-
- if (status < 0 || !(S_ISDIR(statBuf->st_mode))) {
- status = FALSE;
- }
- else status = TRUE;
-
- if (didMalloc) {
- free(statBuf);
- statBuf = NULL;
- }
- return status;
-}
-#endif
-
-#if defined (BB_AR) || defined BB_CP_MV
-/*
- * Copy readSize bytes between two file descriptors
- */
-int copySubFile(int srcFd, int dstFd, size_t remaining)
-{
- size_t size;
- char buffer[BUFSIZ];
-
- while (remaining > 0) {
- if (remaining > BUFSIZ)
- size = BUFSIZ;
- else
- size = remaining;
- if (fullWrite(dstFd, buffer, fullRead(srcFd, buffer, size)) < size)
- return(FALSE);
- remaining -= size;
- }
- return (TRUE);
-}
-#endif
-
-
-#if defined (BB_CP_MV)
-/*
- * Copy one file to another, while possibly preserving its modes, times, and
- * modes. Returns TRUE if successful, or FALSE on a failure with an error
- * message output. (Failure is not indicated if attributes cannot be set.)
- * -Erik Andersen
- */
-int
-copyFile(const char *srcName, const char *destName,
- int setModes, int followLinks, int forceFlag)
-{
- int rfd;
- int wfd;
- int status;
- struct stat srcStatBuf;
- struct stat dstStatBuf;
- struct utimbuf times;
-
- if (followLinks == TRUE)
- status = stat(srcName, &srcStatBuf);
- else
- status = lstat(srcName, &srcStatBuf);
-
- if (status < 0) {
- perror(srcName);
- return FALSE;
- }
-
- if (followLinks == TRUE)
- status = stat(destName, &dstStatBuf);
- else
- status = lstat(destName, &dstStatBuf);
-
- if (status < 0 || forceFlag==TRUE) {
- unlink(destName);
- dstStatBuf.st_ino = -1;
- dstStatBuf.st_dev = -1;
- }
-
- if ((srcStatBuf.st_dev == dstStatBuf.st_dev) &&
- (srcStatBuf.st_ino == dstStatBuf.st_ino)) {
- errorMsg("Copying file \"%s\" to itself\n", srcName);
- return FALSE;
- }
-
- if (S_ISDIR(srcStatBuf.st_mode)) {
- //fprintf(stderr, "copying directory %s to %s\n", srcName, destName);
- /* Make sure the directory is writable */
- status = mkdir(destName, 0777777 ^ umask(0));
- if (status < 0 && errno != EEXIST) {
- perror(destName);
- return FALSE;
- }
- } else if (S_ISLNK(srcStatBuf.st_mode)) {
- char link_val[BUFSIZ + 1];
- int link_size;
-
- //fprintf(stderr, "copying link %s to %s\n", srcName, destName);
- /* Warning: This could possibly truncate silently, to BUFSIZ chars */
- link_size = readlink(srcName, &link_val[0], BUFSIZ);
- if (link_size < 0) {
- perror(srcName);
- return FALSE;
- }
- link_val[link_size] = '\0';
- status = symlink(link_val, destName);
- if (status < 0) {
- perror(destName);
- return FALSE;
- }
-#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
- if (setModes == TRUE) {
- /* Try to set owner, but fail silently like GNU cp */
- lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
- }
-#endif
- return TRUE;
- } else if (S_ISFIFO(srcStatBuf.st_mode)) {
- //fprintf(stderr, "copying fifo %s to %s\n", srcName, destName);
- if (mkfifo(destName, 0644) < 0) {
- perror(destName);
- return FALSE;
- }
- } else if (S_ISBLK(srcStatBuf.st_mode) || S_ISCHR(srcStatBuf.st_mode)
- || S_ISSOCK(srcStatBuf.st_mode)) {
- //fprintf(stderr, "copying soc, blk, or chr %s to %s\n", srcName, destName);
- if (mknod(destName, srcStatBuf.st_mode, srcStatBuf.st_rdev) < 0) {
- perror(destName);
- return FALSE;
- }
- } else if (S_ISREG(srcStatBuf.st_mode)) {
- //fprintf(stderr, "copying regular file %s to %s\n", srcName, destName);
- rfd = open(srcName, O_RDONLY);
- if (rfd < 0) {
- perror(srcName);
- return FALSE;
- }
-
- wfd = open(destName, O_WRONLY | O_CREAT | O_TRUNC,
- srcStatBuf.st_mode);
- if (wfd < 0) {
- perror(destName);
- close(rfd);
- return FALSE;
- }
-
- if (copySubFile(rfd, wfd, srcStatBuf.st_size)==FALSE)
- goto error_exit;
-
- close(rfd);
- if (close(wfd) < 0) {
- return FALSE;
- }
- }
-
- if (setModes == TRUE) {
- /* This is fine, since symlinks never get here */
- if (chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid) < 0) {
- perror(destName);
- exit FALSE;
- }
- if (chmod(destName, srcStatBuf.st_mode) < 0) {
- perror(destName);
- exit FALSE;
- }
- times.actime = srcStatBuf.st_atime;
- times.modtime = srcStatBuf.st_mtime;
- if (utime(destName, &times) < 0) {
- perror(destName);
- exit FALSE;
- }
- }
-
- return TRUE;
-
- error_exit:
- perror(destName);
- close(rfd);
- close(wfd);
-
- return FALSE;
-}
-#endif /* BB_CP_MV */
-
-
-
-#if defined BB_TAR || defined BB_LS ||defined BB_AR
-
-#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
-#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
-
-/* The special bits. If set, display SMODE0/1 instead of MODE0/1 */
-static const mode_t SBIT[] = {
- 0, 0, S_ISUID,
- 0, 0, S_ISGID,
- 0, 0, S_ISVTX
-};
-
-/* The 9 mode bits to test */
-static const mode_t MBIT[] = {
- S_IRUSR, S_IWUSR, S_IXUSR,
- S_IRGRP, S_IWGRP, S_IXGRP,
- S_IROTH, S_IWOTH, S_IXOTH
-};
-
-#define MODE1 "rwxrwxrwx"
-#define MODE0 "---------"
-#define SMODE1 "..s..s..t"
-#define SMODE0 "..S..S..T"
-
-/*
- * Return the standard ls-like mode string from a file mode.
- * This is static and so is overwritten on each call.
- */
-const char *modeString(int mode)
-{
- static char buf[12];
-
- int i;
-
- buf[0] = TYPECHAR(mode);
- for (i = 0; i < 9; i++) {
- if (mode & SBIT[i])
- buf[i + 1] = (mode & MBIT[i]) ? SMODE1[i] : SMODE0[i];
- else
- buf[i + 1] = (mode & MBIT[i]) ? MODE1[i] : MODE0[i];
- }
- return buf;
-}
-#endif /* BB_TAR || BB_LS */
-
-
-#if defined BB_TAR || defined BB_AR
-/*
- * Return the standard ls-like time string from a time_t
- * This is static and so is overwritten on each call.
- */
-const char *timeString(time_t timeVal)
-{
- time_t now;
- char *str;
- static char buf[26];
-
- time(&now);
-
- str = ctime(&timeVal);
-
- strcpy(buf, &str[4]);
- buf[12] = '\0';
-
- if ((timeVal > now) || (timeVal < now - 365 * 24 * 60 * 60L)) {
- strcpy(&buf[7], &str[20]);
- buf[11] = '\0';
- }
-
- return buf;
-}
-#endif /* BB_TAR || BB_AR */
-
-#if defined BB_TAR || defined BB_CP_MV || defined BB_AR
-/*
- * Write all of the supplied buffer out to a file.
- * This does multiple writes as necessary.
- * Returns the amount written, or -1 on an error.
- */
-int fullWrite(int fd, const char *buf, int len)
-{
- int cc;
- int total;
-
- total = 0;
-
- while (len > 0) {
- cc = write(fd, buf, len);
-
- if (cc < 0)
- return -1;
-
- buf += cc;
- total += cc;
- len -= cc;
- }
-
- return total;
-}
-#endif /* BB_TAR || BB_CP_MV || BB_AR */
-
-
-#if defined BB_TAR || defined BB_TAIL || defined BB_AR || defined BB_SH || defined BB_CP_MV
-/*
- * Read all of the supplied buffer from a file.
- * This does multiple reads as necessary.
- * Returns the amount read, or -1 on an error.
- * A short read is returned on an end of file.
- */
-int fullRead(int fd, char *buf, int len)
-{
- int cc;
- int total;
-
- total = 0;
-
- while (len > 0) {
- cc = read(fd, buf, len);
-
- if (cc < 0)
- return -1;
-
- if (cc == 0)
- break;
-
- buf += cc;
- total += cc;
- len -= cc;
- }
-
- return total;
-}
-#endif /* BB_TAR || BB_TAIL || BB_AR || BB_SH */
-
-
-#if defined (BB_CHMOD_CHOWN_CHGRP) \
- || defined (BB_CP_MV) \
- || defined (BB_FIND) \
- || defined (BB_INSMOD) \
- || defined (BB_LS) \
- || defined (BB_RM) \
- || defined (BB_TAR)
-
-/*
- * Walk down all the directories under the specified
- * location, and do something (something specified
- * by the fileAction and dirAction function pointers).
- *
- * Unfortunatly, while nftw(3) could replace this and reduce
- * code size a bit, nftw() wasn't supported before GNU libc 2.1,
- * and so isn't sufficiently portable to take over since glibc2.1
- * is so stinking huge.
- */
-int recursiveAction(const char *fileName,
- int recurse, int followLinks, int depthFirst,
- int (*fileAction) (const char *fileName,
- struct stat * statbuf,
- void* userData),
- int (*dirAction) (const char *fileName,
- struct stat * statbuf,
- void* userData),
- void* userData)
-{
- int status;
- struct stat statbuf;
- struct dirent *next;
-
- if (followLinks == TRUE)
- status = stat(fileName, &statbuf);
- else
- status = lstat(fileName, &statbuf);
-
- if (status < 0) {
-#ifdef BB_DEBUG_PRINT_SCAFFOLD
- fprintf(stderr,
- "status=%d followLinks=%d TRUE=%d\n",
- status, followLinks, TRUE);
-#endif
- perror(fileName);
- return FALSE;
- }
-
- if ((followLinks == FALSE) && (S_ISLNK(statbuf.st_mode))) {
- if (fileAction == NULL)
- return TRUE;
- else
- return fileAction(fileName, &statbuf, userData);
- }
-
- if (recurse == FALSE) {
- if (S_ISDIR(statbuf.st_mode)) {
- if (dirAction != NULL)
- return (dirAction(fileName, &statbuf, userData));
- else
- return TRUE;
- }
- }
-
- if (S_ISDIR(statbuf.st_mode)) {
- DIR *dir;
-
- dir = opendir(fileName);
- if (!dir) {
- perror(fileName);
- return FALSE;
- }
- if (dirAction != NULL && depthFirst == FALSE) {
- status = dirAction(fileName, &statbuf, userData);
- if (status == FALSE) {
- perror(fileName);
- return FALSE;
- }
- }
- while ((next = readdir(dir)) != NULL) {
- char nextFile[BUFSIZ + 1];
-
- if ((strcmp(next->d_name, "..") == 0)
- || (strcmp(next->d_name, ".") == 0)) {
- continue;
- }
- if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) {
- errorMsg("name_too_long");
- return FALSE;
- }
- memset(nextFile, 0, sizeof(nextFile));
- sprintf(nextFile, "%s/%s", fileName, next->d_name);
- status =
- recursiveAction(nextFile, TRUE, followLinks, depthFirst,
- fileAction, dirAction, userData);
- if (status == FALSE) {
- closedir(dir);
- return FALSE;
- }
- }
- status = closedir(dir);
- if (status < 0) {
- perror(fileName);
- return FALSE;
- }
- if (dirAction != NULL && depthFirst == TRUE) {
- status = dirAction(fileName, &statbuf, userData);
- if (status == FALSE) {
- perror(fileName);
- return FALSE;
- }
- }
- } else {
- if (fileAction == NULL)
- return TRUE;
- else
- return fileAction(fileName, &statbuf, userData);
- }
- return TRUE;
-}
-
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_CP_MV || BB_FIND || BB_LS || BB_INSMOD */
-
-
-
-#if defined (BB_TAR) || defined (BB_MKDIR) || defined (BB_AR)
-/*
- * Attempt to create the directories along the specified path, except for
- * the final component. The mode is given for the final directory only,
- * while all previous ones get default protections. Errors are not reported
- * here, as failures to restore files can be reported later.
- */
-extern int createPath(const char *name, int mode)
-{
- char *cp;
- char *cpOld;
- char buf[BUFSIZ + 1];
- int retVal = 0;
-
- strcpy(buf, name);
- for (cp = buf; *cp == '/'; cp++);
- cp = strchr(cp, '/');
- while (cp) {
- cpOld = cp;
- cp = strchr(cp + 1, '/');
- *cpOld = '\0';
- retVal = mkdir(buf, cp ? 0777 : mode);
- if (retVal != 0 && errno != EEXIST) {
- perror(buf);
- return FALSE;
- }
- *cpOld = '/';
- }
- return TRUE;
-}
-#endif /* BB_TAR || BB_MKDIR */
-
-
-
-#if defined (BB_CHMOD_CHOWN_CHGRP) || defined (BB_MKDIR) \
- || defined (BB_MKFIFO) || defined (BB_MKNOD) || defined (BB_AR)
-/* [ugoa]{+|-|=}[rwxst] */
-
-
-
-extern int parse_mode(const char *s, mode_t * theMode)
-{
- mode_t andMode =
-
- S_ISVTX | S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
- mode_t orMode = 0;
- mode_t mode = 0;
- mode_t groups = 0;
- char type;
- char c;
-
- if (s==NULL)
- return (FALSE);
-
- do {
- for (;;) {
- switch (c = *s++) {
- case '\0':
- return -1;
- case 'u':
- groups |= S_ISUID | S_IRWXU;
- continue;
- case 'g':
- groups |= S_ISGID | S_IRWXG;
- continue;
- case 'o':
- groups |= S_IRWXO;
- continue;
- case 'a':
- groups |= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
- continue;
- case '+':
- case '=':
- case '-':
- type = c;
- if (groups == 0) /* The default is "all" */
- groups |=
- S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
- break;
- default:
- if (isdigit(c) && c >= '0' && c <= '7' &&
- mode == 0 && groups == 0) {
- *theMode = strtol(--s, NULL, 8);
- return (TRUE);
- } else
- return (FALSE);
- }
- break;
- }
-
- while ((c = *s++) != '\0') {
- switch (c) {
- case ',':
- break;
- case 'r':
- mode |= S_IRUSR | S_IRGRP | S_IROTH;
- continue;
- case 'w':
- mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- continue;
- case 'x':
- mode |= S_IXUSR | S_IXGRP | S_IXOTH;
- continue;
- case 's':
- mode |= S_IXGRP | S_ISUID | S_ISGID;
- continue;
- case 't':
- mode |= 0;
- continue;
- default:
- *theMode &= andMode;
- *theMode |= orMode;
- return (TRUE);
- }
- break;
- }
- switch (type) {
- case '=':
- andMode &= ~(groups);
- /* fall through */
- case '+':
- orMode |= mode & groups;
- break;
- case '-':
- andMode &= ~(mode & groups);
- orMode &= andMode;
- break;
- }
- } while (c == ',');
- *theMode &= andMode;
- *theMode |= orMode;
- return (TRUE);
-}
-
-
-#endif
-/* BB_CHMOD_CHOWN_CHGRP || BB_MKDIR || BB_MKFIFO || BB_MKNOD */
-
-
-
-
-
-#if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS \
- || defined BB_TAR || defined BB_ID || defined BB_LOGGER \
- || defined BB_LOGNAME || defined BB_WHOAMI
-
-/* This parses entries in /etc/passwd and /etc/group. This is desirable
- * for BusyBox, since we want to avoid using the glibc NSS stuff, which
- * increases target size and is often not needed or wanted for embedded
- * systems.
- *
- * /etc/passwd entries look like this:
- * root:x:0:0:root:/root:/bin/bash
- * and /etc/group entries look like this:
- * root:x:0:
- *
- * This uses buf as storage to hold things.
- *
- */
-unsigned long my_getid(const char *filename, char *name, long id, long *gid)
-{
- FILE *file;
- char *rname, *start, *end, buf[128];
- long rid;
- long rgid = 0;
-
- file = fopen(filename, "r");
- if (file == NULL) {
- /* Do not complain. It is ok for /etc/passwd and
- * friends to be missing... */
- return (-1);
- }
-
- while (fgets(buf, 128, file) != NULL) {
- if (buf[0] == '#')
- continue;
-
- /* username/group name */
- start = buf;
- end = strchr(start, ':');
- if (end == NULL)
- continue;
- *end = '\0';
- rname = start;
-
- /* password */
- start = end + 1;
- end = strchr(start, ':');
- if (end == NULL)
- continue;
-
- /* uid in passwd, gid in group */
- start = end + 1;
- rid = (unsigned long) strtol(start, &end, 10);
- if (end == start)
- continue;
-
- /* gid in passwd */
- start = end + 1;
- rgid = (unsigned long) strtol(start, &end, 10);
-
- if (name) {
- if (0 == strcmp(rname, name)) {
- if (gid) *gid = rgid;
- fclose(file);
- return (rid);
- }
- }
- if (id != -1 && id == rid) {
- strncpy(name, rname, 8);
- if (gid) *gid = rgid;
- fclose(file);
- return (TRUE);
- }
- }
- fclose(file);
- return (-1);
-}
-
-/* returns a uid given a username */
-long my_getpwnam(char *name)
-{
- return my_getid("/etc/passwd", name, -1, NULL);
-}
-
-/* returns a gid given a group name */
-long my_getgrnam(char *name)
-{
- return my_getid("/etc/group", name, -1, NULL);
-}
-
-/* gets a username given a uid */
-void my_getpwuid(char *name, long uid)
-{
- my_getid("/etc/passwd", name, uid, NULL);
-}
-
-/* gets a groupname given a gid */
-void my_getgrgid(char *group, long gid)
-{
- my_getid("/etc/group", group, gid, NULL);
-}
-
-/* gets a gid given a user name */
-long my_getpwnamegid(char *name)
-{
- long gid;
- my_getid("/etc/passwd", name, -1, &gid);
- return gid;
-}
-
-#endif
- /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR \
- || BB_ID || BB_LOGGER || BB_LOGNAME || BB_WHOAMI */
-
-
-#if (defined BB_CHVT) || (defined BB_DEALLOCVT) || (defined BB_SETKEYCODES)
-
-/* From <linux/kd.h> */
-#define KDGKBTYPE 0x4B33 /* get keyboard type */
-#define KB_84 0x01
-#define KB_101 0x02 /* this is what we always answer */
-
-int is_a_console(int fd)
-{
- char arg;
-
- arg = 0;
- return (ioctl(fd, KDGKBTYPE, &arg) == 0
- && ((arg == KB_101) || (arg == KB_84)));
-}
-
-static int open_a_console(char *fnam)
-{
- int fd;
-
- /* try read-only */
- fd = open(fnam, O_RDWR);
-
- /* if failed, try read-only */
- if (fd < 0 && errno == EACCES)
- fd = open(fnam, O_RDONLY);
-
- /* if failed, try write-only */
- if (fd < 0 && errno == EACCES)
- fd = open(fnam, O_WRONLY);
-
- /* if failed, fail */
- if (fd < 0)
- return -1;
-
- /* if not a console, fail */
- if (!is_a_console(fd)) {
- close(fd);
- return -1;
- }
-
- /* success */
- return fd;
-}
-
-/*
- * Get an fd for use with kbd/console ioctls.
- * We try several things because opening /dev/console will fail
- * if someone else used X (which does a chown on /dev/console).
- *
- * if tty_name is non-NULL, try this one instead.
- */
-
-int get_console_fd(char *tty_name)
-{
- int fd;
-
- if (tty_name) {
- if (-1 == (fd = open_a_console(tty_name)))
- return -1;
- else
- return fd;
- }
-
- fd = open_a_console("/dev/tty");
- if (fd >= 0)
- return fd;
-
- fd = open_a_console("/dev/tty0");
- if (fd >= 0)
- return fd;
-
- fd = open_a_console("/dev/console");
- if (fd >= 0)
- return fd;
-
- for (fd = 0; fd < 3; fd++)
- if (is_a_console(fd))
- return fd;
-
- errorMsg("Couldnt get a file descriptor referring to the console\n");
- return -1; /* total failure */
-}
-
-
-#endif /* BB_CHVT || BB_DEALLOCVT || BB_SETKEYCODES */
-
-
-#if defined BB_FIND || defined BB_INSMOD
-/*
- * Routine to see if a text string is matched by a wildcard pattern.
- * Returns TRUE if the text is matched, or FALSE if it is not matched
- * or if the pattern is invalid.
- * * matches zero or more characters
- * ? matches a single character
- * [abc] matches 'a', 'b' or 'c'
- * \c quotes character c
- * Adapted from code written by Ingo Wilken, and
- * then taken from sash, Copyright (c) 1999 by David I. Bell
- * Permission is granted to use, distribute, or modify this source,
- * provided that this copyright notice remains intact.
- * Permission to distribute this code under the GPL has been granted.
- */
-extern int check_wildcard_match(const char *text, const char *pattern)
-{
- const char *retryPat;
- const char *retryText;
- int ch;
- int found;
- int len;
-
- retryPat = NULL;
- retryText = NULL;
-
- while (*text || *pattern) {
- ch = *pattern++;
-
- switch (ch) {
- case '*':
- retryPat = pattern;
- retryText = text;
- break;
-
- case '[':
- found = FALSE;
-
- while ((ch = *pattern++) != ']') {
- if (ch == '\\')
- ch = *pattern++;
-
- if (ch == '\0')
- return FALSE;
-
- if (*text == ch)
- found = TRUE;
- }
- len=strlen(text);
- if (found == FALSE && len!=0) {
- return FALSE;
- }
- if (found == TRUE) {
- if (strlen(pattern)==0 && len==1) {
- return TRUE;
- }
- if (len!=0) {
- text++;
- continue;
- }
- }
-
- /* fall into next case */
-
- case '?':
- if (*text++ == '\0')
- return FALSE;
-
- break;
-
- case '\\':
- ch = *pattern++;
-
- if (ch == '\0')
- return FALSE;
-
- /* fall into next case */
-
- default:
- if (*text == ch) {
- if (*text)
- text++;
- break;
- }
-
- if (*text) {
- pattern = retryPat;
- text = ++retryText;
- break;
- }
-
- return FALSE;
- }
-
- if (pattern == NULL)
- return FALSE;
- }
-
- return TRUE;
-}
-#endif /* BB_FIND || BB_INSMOD */
-
-
-
-
-#if defined BB_DF || defined BB_MTAB
-/*
- * Given a block device, find the mount table entry if that block device
- * is mounted.
- *
- * Given any other file (or directory), find the mount table entry for its
- * filesystem.
- */
-extern struct mntent *findMountPoint(const char *name, const char *table)
-{
- struct stat s;
- dev_t mountDevice;
- FILE *mountTable;
- struct mntent *mountEntry;
-
- if (stat(name, &s) != 0)
- return 0;
-
- if ((s.st_mode & S_IFMT) == S_IFBLK)
- mountDevice = s.st_rdev;
- else
- mountDevice = s.st_dev;
-
-
- if ((mountTable = setmntent(table, "r")) == 0)
- return 0;
-
- while ((mountEntry = getmntent(mountTable)) != 0) {
- if (strcmp(name, mountEntry->mnt_dir) == 0
- || strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
- break;
- if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
- break;
- if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
- break;
- }
- endmntent(mountTable);
- return mountEntry;
-}
-#endif /* BB_DF || BB_MTAB */
-
-
-
-#if defined BB_DD || defined BB_TAIL
-/*
- * Read a number with a possible multiplier.
- * Returns -1 if the number format is illegal.
- */
-extern long getNum(const char *cp)
-{
- long value;
-
- if (!isDecimal(*cp))
- return -1;
-
- value = 0;
-
- while (isDecimal(*cp))
- value = value * 10 + *cp++ - '0';
-
- switch (*cp++) {
- case 'M':
- case 'm': /* `tail' uses it traditionally */
- value *= 1048576;
- break;
-
- case 'k':
- value *= 1024;
- break;
-
- case 'b':
- value *= 512;
- break;
-
- case 'w':
- value *= 2;
- break;
-
- case '\0':
- return value;
-
- default:
- return -1;
- }
-
- if (*cp)
- return -1;
-
- return value;
-}
-#endif /* BB_DD || BB_TAIL */
-
-
-#if defined BB_INIT || defined BB_SYSLOGD
-/* try to open up the specified device */
-extern int device_open(char *device, int mode)
-{
- int m, f, fd = -1;
-
- m = mode | O_NONBLOCK;
-
- /* Retry up to 5 times */
- for (f = 0; f < 5; f++)
- if ((fd = open(device, m, 0600)) >= 0)
- break;
- if (fd < 0)
- return fd;
- /* Reset original flags. */
- if (m != mode)
- fcntl(fd, F_SETFL, mode);
- return fd;
-}
-#endif /* BB_INIT BB_SYSLOGD */
-
-
-#if defined BB_KILLALL || ( defined BB_FEATURE_LINUXRC && ( defined BB_HALT || defined BB_REBOOT || defined BB_POWEROFF ))
-#ifdef BB_FEATURE_USE_DEVPS_PATCH
-#include <linux/devps.h> /* For Erik's nifty devps device driver */
-#endif
-
-#if defined BB_FEATURE_USE_DEVPS_PATCH
-/* findPidByName()
- *
- * This finds the pid of the specified process,
- * by using the /dev/ps device driver.
- *
- * Returns a list of all matching PIDs
- */
-extern pid_t* findPidByName( char* pidName)
-{
- int fd, i, j;
- char device[] = "/dev/ps";
- pid_t num_pids;
- pid_t* pid_array = NULL;
- pid_t* pidList=NULL;
-
- /* open device */
- fd = open(device, O_RDONLY);
- if (fd < 0)
- fatalError( "open failed for `%s': %s\n", device, strerror (errno));
-
- /* Find out how many processes there are */
- if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
- fatalError( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
-
- /* Allocate some memory -- grab a few extras just in case
- * some new processes start up while we wait. The kernel will
- * just ignore any extras if we give it too many, and will trunc.
- * the list if we give it too few. */
- pid_array = (pid_t*) xcalloc( num_pids+10, sizeof(pid_t));
- pid_array[0] = num_pids+10;
-
- /* Now grab the pid list */
- if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
- fatalError( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
-
- /* Now search for a match */
- for (i=1, j=0; i<pid_array[0] ; i++) {
- char* p;
- struct pid_info info;
-
- info.pid = pid_array[i];
- if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
- fatalError( "\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
-
- /* Make sure we only match on the process name */
- p=info.command_line+1;
- while ((*p != 0) && !isspace(*(p)) && (*(p-1) != '\\')) {
- (p)++;
- }
- if (isspace(*(p)))
- *p='\0';
-
- if ((strstr(info.command_line, pidName) != NULL)
- && (strlen(pidName) == strlen(info.command_line))) {
- pidList=xrealloc( pidList, sizeof(pid_t) * (j+2));
- pidList[j++]=info.pid;
- }
- }
- if (pidList)
- pidList[j]=0;
-
- /* Free memory */
- free( pid_array);
-
- /* close device */
- if (close (fd) != 0)
- fatalError( "close failed for `%s': %s\n",device, strerror (errno));
-
- return pidList;
-}
-#else /* BB_FEATURE_USE_DEVPS_PATCH */
-#if ! defined BB_FEATURE_USE_PROCFS
-#error Sorry, I depend on the /proc filesystem right now.
-#endif
-
-/* findPidByName()
- *
- * This finds the pid of the specified process.
- * Currently, it's implemented by rummaging through
- * the proc filesystem.
- *
- * Returns a list of all matching PIDs
- */
-extern pid_t* findPidByName( char* pidName)
-{
- DIR *dir;
- struct dirent *next;
- pid_t* pidList=NULL;
- int i=0;
-
- dir = opendir("/proc");
- if (!dir)
- fatalError( "Cannot open /proc: %s\n", strerror (errno));
-
- while ((next = readdir(dir)) != NULL) {
- FILE *status;
- char filename[256];
- char buffer[256];
-
- /* If it isn't a number, we don't want it */
- if (!isdigit(*next->d_name))
- continue;
-
- sprintf(filename, "/proc/%s/cmdline", next->d_name);
- status = fopen(filename, "r");
- if (!status) {
- continue;
- }
- fgets(buffer, 256, status);
- fclose(status);
-
- if (strstr(get_last_path_component(buffer), pidName) != NULL) {
- pidList=xrealloc( pidList, sizeof(pid_t) * (i+2));
- pidList[i++]=strtol(next->d_name, NULL, 0);
- }
- }
-
- if (pidList)
- pidList[i]=0;
- return pidList;
-}
-#endif /* BB_FEATURE_USE_DEVPS_PATCH */
-#endif /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */
-
-#ifndef DMALLOC
-/* this should really be farmed out to libbusybox.a */
-extern void *xmalloc(size_t size)
-{
- void *ptr = malloc(size);
-
- if (!ptr)
- fatalError("memory_exhausted");
- return ptr;
-}
-
-extern void *xrealloc(void *old, size_t size)
-{
- void *ptr;
- if (!size)
- size = 1;
- ptr = realloc(old, size);
- if (!ptr)
- fatalError("memory_exhausted");
- return ptr;
-}
-
-extern void *xcalloc(size_t nmemb, size_t size)
-{
- void *ptr = calloc(nmemb, size);
- if (!ptr)
- fatalError("memory_exhausted");
- return ptr;
-}
-#endif
-
-#if defined BB_FEATURE_NFSMOUNT || defined BB_SH || defined BB_LS
-# ifndef DMALLOC
-extern char * xstrdup (const char *s) {
- char *t;
-
- if (s == NULL)
- return NULL;
-
- t = strdup (s);
-
- if (t == NULL)
- fatalError("memory_exhausted");
-
- return t;
-}
-# endif
-#endif
-
-#if defined BB_FEATURE_NFSMOUNT
-extern char * xstrndup (const char *s, int n) {
- char *t;
-
- if (s == NULL)
- fatalError("xstrndup bug");
-
- t = xmalloc(n+1);
- strncpy(t,s,n);
- t[n] = 0;
-
- return t;
-}
-#endif
-
-
-#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
-extern int vdprintf(int d, const char *format, va_list ap)
-{
- char buf[BUF_SIZE];
- int len;
-
- len = vsprintf(buf, format, ap);
- return write(d, buf, len);
-}
-#endif /* BB_SYSLOGD */
-
-
-#if defined BB_FEATURE_MOUNT_LOOP
-#include <fcntl.h>
-#include "loop.h" /* Pull in loop device support */
-
-extern int del_loop(const char *device)
-{
- int fd;
-
- if ((fd = open(device, O_RDONLY)) < 0) {
- perror(device);
- return (FALSE);
- }
- if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
- perror("ioctl: LOOP_CLR_FD");
- return (FALSE);
- }
- close(fd);
- return (TRUE);
-}
-
-extern int set_loop(const char *device, const char *file, int offset,
- int *loopro)
-{
- struct loop_info loopinfo;
- int fd, ffd, mode;
-
- mode = *loopro ? O_RDONLY : O_RDWR;
- if ((ffd = open(file, mode)) < 0 && !*loopro
- && (errno != EROFS || (ffd = open(file, mode = O_RDONLY)) < 0)) {
- perror(file);
- return 1;
- }
- if ((fd = open(device, mode)) < 0) {
- close(ffd);
- perror(device);
- return 1;
- }
- *loopro = (mode == O_RDONLY);
-
- memset(&loopinfo, 0, sizeof(loopinfo));
- strncpy(loopinfo.lo_name, file, LO_NAME_SIZE);
- loopinfo.lo_name[LO_NAME_SIZE - 1] = 0;
-
- loopinfo.lo_offset = offset;
-
- loopinfo.lo_encrypt_key_size = 0;
- if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- perror("ioctl: LOOP_SET_FD");
- close(fd);
- close(ffd);
- return 1;
- }
- if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
- (void) ioctl(fd, LOOP_CLR_FD, 0);
- perror("ioctl: LOOP_SET_STATUS");
- close(fd);
- close(ffd);
- return 1;
- }
- close(fd);
- close(ffd);
- return 0;
-}
-
-extern char *find_unused_loop_device(void)
-{
- char dev[20];
- int i, fd;
- struct stat statbuf;
- struct loop_info loopinfo;
-
- for (i = 0; i <= 7; i++) {
- sprintf(dev, "/dev/loop%d", i);
- if (stat(dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
- if ((fd = open(dev, O_RDONLY)) >= 0) {
- if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) == -1) {
- if (errno == ENXIO) { /* probably free */
- close(fd);
- return strdup(dev);
- }
- }
- close(fd);
- }
- }
- }
- return NULL;
-}
-#endif /* BB_FEATURE_MOUNT_LOOP */
-
-#if defined BB_MOUNT || defined BB_DF || ( defined BB_UMOUNT && ! defined BB_MTAB)
-extern int find_real_root_device_name(char* name)
-{
- DIR *dir;
- struct dirent *entry;
- struct stat statBuf, rootStat;
- char fileName[BUFSIZ];
-
- if (stat("/", &rootStat) != 0) {
- errorMsg("could not stat '/'\n");
- return( FALSE);
- }
-
- dir = opendir("/dev");
- if (!dir) {
- errorMsg("could not open '/dev'\n");
- return( FALSE);
- }
-
- while((entry = readdir(dir)) != NULL) {
-
- /* Must skip ".." since that is "/", and so we
- * would get a false positive on ".." */
- if (strcmp(entry->d_name, "..") == 0)
- continue;
-
- snprintf( fileName, strlen(name)+1, "/dev/%s", entry->d_name);
-
- if (stat(fileName, &statBuf) != 0)
- continue;
- /* Some char devices have the same dev_t as block
- * devices, so make sure this is a block device */
- if (! S_ISBLK(statBuf.st_mode))
- continue;
- if (statBuf.st_rdev == rootStat.st_rdev) {
- strcpy(name, fileName);
- return ( TRUE);
- }
- }
-
- return( FALSE);
-}
-#endif
-
-
-/* get_line_from_file() - This function reads an entire line from a text file
- * up to a newline. It returns a malloc'ed char * which must be stored and
- * free'ed by the caller. */
-extern char *get_line_from_file(FILE *file)
-{
- static const int GROWBY = 80; /* how large we will grow strings by */
-
- int ch;
- int idx = 0;
- char *linebuf = NULL;
- int linebufsz = 0;
-
- while (1) {
- ch = fgetc(file);
- if (ch == EOF)
- break;
- /* grow the line buffer as necessary */
- while (idx > linebufsz-2)
- linebuf = xrealloc(linebuf, linebufsz += GROWBY);
- linebuf[idx++] = (char)ch;
- if ((char)ch == '\n')
- break;
- }
-
- if (idx == 0)
- return NULL;
-
- linebuf[idx] = 0;
- return linebuf;
-}
-
-#if defined BB_CAT
-extern void print_file(FILE *file)
-{
- int c;
-
- while ((c = getc(file)) != EOF)
- putc(c, stdout);
- fclose(file);
- fflush(stdout);
-}
-
-extern int print_file_by_name(char *filename)
-{
- FILE *file;
- file = fopen(filename, "r");
- if (file == NULL) {
- return FALSE;
- }
- print_file(file);
- return TRUE;
-}
-#endif /* BB_CAT || BB_LSMOD */
-
-#if defined BB_ECHO || defined BB_TR
-char process_escape_sequence(char **ptr)
-{
- char c;
-
- switch (c = *(*ptr)++) {
- case 'a':
- c = '\a';
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 't':
- c = '\t';
- break;
- case 'v':
- c = '\v';
- break;
- case '\\':
- c = '\\';
- break;
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- c -= '0';
- if ('0' <= **ptr && **ptr <= '7') {
- c = c * 8 + (*(*ptr)++ - '0');
- if ('0' <= **ptr && **ptr <= '7')
- c = c * 8 + (*(*ptr)++ - '0');
- }
- break;
- default:
- (*ptr)--;
- c = '\\';
- break;
- }
- return c;
-}
-#endif
-
-#if defined BB_BASENAME || defined BB_LN || defined BB_SH
-char *get_last_path_component(char *path)
-{
- char *s=path+strlen(path)-1;
-
- /* strip trailing slashes */
- while (s && *s == '/') {
- *s-- = '\0';
- }
-
- /* find last component */
- s = strrchr(path, '/');
- if (s==NULL) return path;
- else return s+1;
-}
-#endif
-
-#if defined BB_GREP || defined BB_SED
-void xregcomp(regex_t *preg, const char *regex, int cflags)
-{
- int ret;
- if ((ret = regcomp(preg, regex, cflags)) != 0) {
- int errmsgsz = regerror(ret, preg, NULL, 0);
- char *errmsg = xmalloc(errmsgsz);
- regerror(ret, preg, errmsg, errmsgsz);
- fatalError("bb_regcomp: %s\n", errmsg);
- }
-}
-#endif
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
diff --git a/mdk-stage1/insmod-modutils/Makefile b/mdk-stage1/insmod-modutils/Makefile
deleted file mode 100644
index 48508ba1f..000000000
--- a/mdk-stage1/insmod-modutils/Makefile
+++ /dev/null
@@ -1,59 +0,0 @@
- #******************************************************************************
- #
- # insmod from modutils (generic)
- #
- # $Id$
- #
- # Copyright 1996, 1997 Linux International.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-INCS = -I./include
-
-TAINT_URL = http://www.tux.org/lkml/\#export-tainted
-
-DEFS = -Wno-error -D_GNU_SOURCE \
- -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) \
- -DTAINT_URL='"$(TAINT_URL)"'
-
-
-DIRS = util obj
-
-all: dirs insmod libinsmod.a
-
-dirs:
- @for n in . $(DIRS); do \
- [ "$$n" = "." ] || make -C $$n ;\
- done
-
-clean:
- @for n in $(DIRS); do \
- (cd $$n; make clean) \
- done
- rm -rf t *.o insmod libinsmod.a
-
-
-insmod: insmod-frontend.o insmod.o ./util/libutil-STANDALONE.a ./obj/libobj.a
- $(DIET) gcc -o $@ $^
- $(STRIPCMD) $@
-
-t/.create_stuff: util/libutil.a obj/libobj.a
- rm -rf t
- mkdir t
- cd t && for e in $^; do ar -x ../$$e; done
- touch t/.create_stuff
-
-libinsmod.a: insmod.o t/.create_stuff
- ar cru $@ insmod.o t/*
- ranlib $@
-
-insmod-frontend.o: insmod-frontend.c insmod.c
- $(DIET) gcc $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -c insmod-frontend.c
-
-insmod.o: insmod.c
- $(DIET) gcc $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -c insmod.c
diff --git a/mdk-stage1/insmod-modutils/include/config.h b/mdk-stage1/insmod-modutils/include/config.h
deleted file mode 100644
index 3a37b00d4..000000000
--- a/mdk-stage1/insmod-modutils/include/config.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Configuration file management
- *
- * Copyright 1994, 1995, 1996, 1997:
- * Jacques Gelinas <jack@solucorp.qc.ca>
- * Björn Ekwall <bj0rn@blox.se> February, March 1999
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _CONFIG_H
-#define _CONFIG_H
-
-#include <stdio.h>
-#include <sys/utsname.h>
-
-#define MODUTILS_MACROS "/lib/modutils/macros"
-#define ETC_MODULES_CONF "/etc/modules.conf"
-
-#define EXEC_PRE_INSTALL 0
-#define EXEC_POST_INSTALL 1
-#define EXEC_PRE_REMOVE 2
-#define EXEC_POST_REMOVE 3
-#define EXEC_INSTALL 4
-#define EXEC_REMOVE 5
-
-struct PATH_TYPE {
- char *type;
- char *path;
-};
-
-struct EXEC_TYPE {
- int when;
- char *module;
- char *cmd;
-};
-
-typedef struct {
- char *name;
- GLOB_LIST *opts;
- int autoclean;
-} OPT_LIST;
-
-/* config.c */
-extern int flag_autoclean;
-extern struct utsname uts_info;
-extern char *aliaslist[];
-extern struct PATH_TYPE *modpath;
-extern int nmodpath;
-extern struct EXEC_TYPE *execs;
-extern int nexecs;
-extern char *insmod_opt;
-extern char *config_file;
-extern char *optlist[];
-extern char *prune[];
-extern OPT_LIST *opt_list;
-extern OPT_LIST *abovelist;
-extern OPT_LIST *belowlist;
-extern OPT_LIST *prunelist;
-extern OPT_LIST *probe_list;
-extern OPT_LIST *probeall_list;
-extern OPT_LIST *aliases;
-extern time_t config_mtime;
-extern int root_check_off; /* Check modules are owned by root? */
-
-/* Information about generated files */
-struct gen_files {
- char *base; /* xxx in /lib/modules/`uname -r`/modules.xxx */
- char *name; /* name actually used */
- time_t mtime;
-};
-
-extern struct gen_files gen_file[];
-extern const int gen_file_count;
-/* The enum order must match the gen_file initialization order in config.c */
-enum gen_file_enum {
- GEN_GENERIC_STRINGFILE,
- GEN_PCIMAPFILE,
- GEN_ISAPNPMAPFILE,
- GEN_USBMAPFILE,
- GEN_PARPORTMAPFILE,
- GEN_IEEE1394MAPFILE,
- GEN_PNPBIOSMAPFILE,
- GEN_DEPFILE,
-};
-
-extern char *persistdir;
-
-char *fgets_strip(char *buf, int sizebuf, FILE * fin, int *lineno);
-int config_read(int all, char *force_ver, char *base_dir, char *conf_file);
-GLOB_LIST *config_lstmod(const char *match, const char *type, int first_only);
-char *search_module_path(const char *base);
-
-#endif /* _CONFIG_H */
diff --git a/mdk-stage1/insmod-modutils/include/elf_alpha.h b/mdk-stage1/insmod-modutils/include/elf_alpha.h
deleted file mode 100644
index 4202bcc14..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_alpha.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for the Alpha. */
-
-#define ELFCLASSM ELFCLASS64
-#define ELFDATAM ELFDATA2LSB
-
-#define MATCH_MACHINE(x) (x == EM_ALPHA)
-
-#define SHT_RELM SHT_RELA
-#define Elf64_RelM Elf64_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_arm.h b/mdk-stage1/insmod-modutils/include/elf_arm.h
deleted file mode 100644
index cf04cafe0..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_arm.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for ARM. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2LSB
-
-#define MATCH_MACHINE(x) (x == EM_ARM)
-
-#define SHT_RELM SHT_REL
-#define Elf32_RelM Elf32_Rel
diff --git a/mdk-stage1/insmod-modutils/include/elf_hppa.h b/mdk-stage1/insmod-modutils/include/elf_hppa.h
deleted file mode 100644
index 9a1bd34ce..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_hppa.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for HP-PA. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2MSB
-
-#define MATCH_MACHINE(x) (x == EM_PARISC)
-
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_hppa64.h b/mdk-stage1/insmod-modutils/include/elf_hppa64.h
deleted file mode 100644
index 05b201aef..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_hppa64.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for HP-PA64. */
-
-#define ELFCLASSM ELFCLASS64
-#define ELFDATAM ELFDATA2MSB
-
-#define MATCH_MACHINE(x) (x == EM_PARISC)
-
-#define SHT_RELM SHT_RELA
-#define Elf64_RelM Elf64_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_i386.h b/mdk-stage1/insmod-modutils/include/elf_i386.h
deleted file mode 100644
index f5c57d384..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_i386.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for i386 et al. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2LSB
-
-#define MATCH_MACHINE(x) (x == EM_386)
-
-#define SHT_RELM SHT_REL
-#define Elf32_RelM Elf32_Rel
diff --git a/mdk-stage1/insmod-modutils/include/elf_ia64.h b/mdk-stage1/insmod-modutils/include/elf_ia64.h
deleted file mode 100644
index b4d902956..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_ia64.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for ia64. */
-
-#define ELFCLASSM ELFCLASS64
-#define ELFDATAM ELFDATA2LSB
-
-#define MATCH_MACHINE(x) (x == EM_IA_64)
-
-#define SHT_RELM SHT_RELA
-#define Elf64_RelM Elf64_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_m68k.h b/mdk-stage1/insmod-modutils/include/elf_m68k.h
deleted file mode 100644
index c488ba9d1..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_m68k.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for m68k. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2MSB
-
-#define MATCH_MACHINE(x) (x == EM_68K)
-
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_mips.h b/mdk-stage1/insmod-modutils/include/elf_mips.h
deleted file mode 100644
index 4b91ddd01..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_mips.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Machine-specific elf macros for MIPS. */
-
-#define ELFCLASSM ELFCLASS32
-#ifdef __MIPSEB__
-#define ELFDATAM ELFDATA2MSB
-#endif
-#ifdef __MIPSEL__
-#define ELFDATAM ELFDATA2LSB
-#endif
-
-/* Account for ELF spec changes. */
-#ifndef EM_MIPS_RS3_LE
-#ifdef EM_MIPS_RS4_BE
-#define EM_MIPS_RS3_LE EM_MIPS_RS4_BE
-#else
-#define EM_MIPS_RS3_LE 10
-#endif
-#endif /* !EM_MIPS_RS3_LE */
-
-#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
-
-#define SHT_RELM SHT_REL
-#define Elf32_RelM Elf32_Rel
diff --git a/mdk-stage1/insmod-modutils/include/elf_ppc.h b/mdk-stage1/insmod-modutils/include/elf_ppc.h
deleted file mode 100644
index b0060ace1..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_ppc.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for the PowerPC. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2MSB
-
-#define MATCH_MACHINE(x) (x == EM_PPC)
-
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_s390.h b/mdk-stage1/insmod-modutils/include/elf_s390.h
deleted file mode 100644
index 7a35bde93..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_s390.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Machine-specific elf macros for i386 et al. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2MSB
-
-#define EM_S390_OLD 0xa390
-
-#define MATCH_MACHINE(x) (x == EM_S390 || x == EM_S390_OLD)
-
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_sparc.h b/mdk-stage1/insmod-modutils/include/elf_sparc.h
deleted file mode 100644
index 8903b2654..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_sparc.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Machine-specific elf macros for the Sparc. */
-
-#define ELFCLASSM ELFCLASS32
-#define ELFDATAM ELFDATA2MSB
-
-#define MATCH_MACHINE(x) (x == EM_SPARC)
-
-#define SHT_RELM SHT_RELA
-#define Elf32_RelM Elf32_Rela
diff --git a/mdk-stage1/insmod-modutils/include/elf_sparc64.h b/mdk-stage1/insmod-modutils/include/elf_sparc64.h
deleted file mode 100644
index 891e0c3d9..000000000
--- a/mdk-stage1/insmod-modutils/include/elf_sparc64.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Machine-specific elf macros for the Sparc. */
-
-#define ELFCLASSM ELFCLASS64
-#define ELFDATAM ELFDATA2MSB
-
-#ifndef EM_SPARCV9
-#define EM_SPARCV9 43
-#endif
-#ifndef EM_SPARC64
-#define EM_SPARC64 11
-#endif
-#define MATCH_MACHINE(x) ((x) == EM_SPARCV9 || (x) == EM_SPARC64)
-
-#define SHT_RELM SHT_RELA
-#define Elf64_RelM Elf64_Rela
-
-#ifndef ELF64_R_SYM
-#define ELF64_R_SYM(x) ((x) >> 32)
-#define ELF64_R_TYPE(x) ((unsigned)(x))
-#endif
-
-#ifndef ELF64_ST_BIND
-#define ELF64_ST_BIND(x) ((x) >> 4)
-#define ELF64_ST_TYPE(x) ((x) & 0xf)
-#endif
-
diff --git a/mdk-stage1/insmod-modutils/include/kallsyms.h b/mdk-stage1/insmod-modutils/include/kallsyms.h
deleted file mode 100644
index 90bb75f22..000000000
--- a/mdk-stage1/insmod-modutils/include/kallsyms.h
+++ /dev/null
@@ -1,129 +0,0 @@
-#ifndef MODUTILS_KALLSYMS_H
-#define MODUTILS_KALLSYMS_H 1
-
-/* kallsyms headers
- Copyright 2000 Keith Owens <kaos@ocs.com.au>
-
- This file is part of the Linux modutils. It is exported to kernel
- space so debuggers can access the kallsyms data.
-
- The kallsyms data contains all the non-stack symbols from a kernel
- or a module. The kernel symbols are held between __start___kallsyms
- and __stop___kallsyms. The symbols for a module are accessed via
- the struct module chain which is based at module_list.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* Have to (re)define these ElfW entries here because external kallsyms
- * code does not have access to modutils/include/obj.h. This code is
- * included from user spaces tools (modutils) and kernel, they need
- * different includes.
- */
-
-#ifndef ELFCLASS32
-#ifdef __KERNEL__
-#include <linux/elf.h>
-#else /* __KERNEL__ */
-#include <elf.h>
-#endif /* __KERNEL__ */
-#endif /* ELFCLASS32 */
-
-#ifndef ELFCLASSM
-#define ELFCLASSM ELF_CLASS
-#endif
-
-#ifndef ElfW
-# if ELFCLASSM == ELFCLASS32
-# define ElfW(x) Elf32_ ## x
-# define ELFW(x) ELF32_ ## x
-# else
-# define ElfW(x) Elf64_ ## x
-# define ELFW(x) ELF64_ ## x
-# endif
-#endif
-
-/* Format of data in the kallsyms section.
- * Most of the fields are small numbers but the total size and all
- * offsets can be large so use the 32/64 bit types for these fields.
- *
- * Do not use sizeof() on these structures, modutils may be using extra
- * fields. Instead use the size fields in the header to access the
- * other bits of data.
- */
-
-struct kallsyms_header {
- int size; /* Size of this header */
- ElfW(Word) total_size; /* Total size of kallsyms data */
- int sections; /* Number of section entries */
- ElfW(Off) section_off; /* Offset to first section entry */
- int section_size; /* Size of one section entry */
- int symbols; /* Number of symbol entries */
- ElfW(Off) symbol_off; /* Offset to first symbol entry */
- int symbol_size; /* Size of one symbol entry */
- ElfW(Off) string_off; /* Offset to first string */
- ElfW(Addr) start; /* Start address of first section */
- ElfW(Addr) end; /* End address of last section */
-};
-
-struct kallsyms_section {
- ElfW(Addr) start; /* Start address of section */
- ElfW(Word) size; /* Size of this section */
- ElfW(Off) name_off; /* Offset to section name */
- ElfW(Word) flags; /* Flags from section */
-};
-
-struct kallsyms_symbol {
- ElfW(Off) section_off; /* Offset to section that owns this symbol */
- ElfW(Addr) symbol_addr; /* Address of symbol */
- ElfW(Off) name_off; /* Offset to symbol name */
-};
-
-#define KALLSYMS_SEC_NAME "__kallsyms"
-#define KALLSYMS_IDX 2 /* obj_kallsyms creates kallsyms as section 2 */
-
-#define kallsyms_next_sec(h,s) \
- ((s) = (struct kallsyms_section *)((char *)(s) + (h)->section_size))
-#define kallsyms_next_sym(h,s) \
- ((s) = (struct kallsyms_symbol *)((char *)(s) + (h)->symbol_size))
-
-int kallsyms_symbol_to_address(
- const char *name, /* Name to lookup */
- unsigned long *token, /* Which module to start with */
- const char **mod_name, /* Set to module name or "kernel" */
- unsigned long *mod_start, /* Set to start address of module */
- unsigned long *mod_end, /* Set to end address of module */
- const char **sec_name, /* Set to section name */
- unsigned long *sec_start, /* Set to start address of section */
- unsigned long *sec_end, /* Set to end address of section */
- const char **sym_name, /* Set to full symbol name */
- unsigned long *sym_start, /* Set to start address of symbol */
- unsigned long *sym_end /* Set to end address of symbol */
- );
-
-int kallsyms_address_to_symbol(
- unsigned long address, /* Address to lookup */
- const char **mod_name, /* Set to module name */
- unsigned long *mod_start, /* Set to start address of module */
- unsigned long *mod_end, /* Set to end address of module */
- const char **sec_name, /* Set to section name */
- unsigned long *sec_start, /* Set to start address of section */
- unsigned long *sec_end, /* Set to end address of section */
- const char **sym_name, /* Set to full symbol name */
- unsigned long *sym_start, /* Set to start address of symbol */
- unsigned long *sym_end /* Set to end address of symbol */
- );
-
-#endif /* kallsyms.h */
diff --git a/mdk-stage1/insmod-modutils/include/kerneld.h b/mdk-stage1/insmod-modutils/include/kerneld.h
deleted file mode 100644
index f32e34b4a..000000000
--- a/mdk-stage1/insmod-modutils/include/kerneld.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Definitions for the Linux kerneld SYSV IPC interface.
- This file was part of the Linux kernel, and so is covered by the GPL. */
-
-#ifndef MODUTILS_KERNELD_H
-#define MODUTILS_KERNELD_H
-
-#define KERNELD_SYSTEM 1
-#define KERNELD_REQUEST_MODULE 2 /* "insmod" */
-#define KERNELD_RELEASE_MODULE 3 /* "rmmod" */
-#define KERNELD_DELAYED_RELEASE_MODULE 4 /* "rmmod" */
-#define KERNELD_CANCEL_RELEASE_MODULE 5 /* "rmmod" */
-#define KERNELD_REQUEST_ROUTE 6 /* net/ipv4/route.c */
-#define KERNELD_BLANKER 7 /* drivers/char/console.c */
-#define KERNELD_PNP 8 /* drivers/pnp/kerneld.c */
-#define KERNELD_ARP 256 /* net/ipv4/arp.c */
-
-#ifdef NEW_KERNELD_PROTOCOL
-# define OLDIPC_KERNELD 00040000 /* old kerneld message channel */
-# define IPC_KERNELD 00140000 /* new kerneld message channel */
-# define KDHDR (sizeof(long) + sizeof(short) + sizeof(short))
-# define NULL_KDHDR 0, 2, 0
-#else /* NEW_KERNELD_PROTOCOL */
-# define IPC_KERNELD 00040000
-# define KDHDR (sizeof(long))
-# define NULL_KDHDR 0
-#endif /* NEW_KERNELD_PROTOCOL */
-
-#define KERNELD_MAXCMD 0x7ffeffff
-#define KERNELD_MINSEQ 0x7fff0000 /* "commands" legal up to 0x7ffeffff */
-#define KERNELD_WAIT 0x80000000
-#define KERNELD_NOWAIT 0
-
-struct kerneld_msg
- {
- long mtype;
- long id;
-#ifdef NEW_KERNELD_PROTOCOL
- short version;
- short pid;
-#endif /* NEW_KERNELD_PROTOCOL */
- char text[1];
- };
-
-#endif /* kerneld.h */
diff --git a/mdk-stage1/insmod-modutils/include/modstat.h b/mdk-stage1/insmod-modutils/include/modstat.h
deleted file mode 100644
index b8a58eeae..000000000
--- a/mdk-stage1/insmod-modutils/include/modstat.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * For kernel module status and information
- *
- * Add module_name_list and l_module_name_list.
- * Keith Owens <kaos@ocs.com.au> November 1999.
- * Björn Ekwall <bj0rn@blox.se> February 1999.
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-#ifndef _KERNEL_H
-#define _KERNEL_H
-
-#define K_SYMBOLS 1 /* Want info about symbols */
-#define K_INFO 2 /* Want extended module info */
-#define K_REFS 4 /* Want info about references */
-
-struct module_stat {
- char *name;
- unsigned long addr;
- unsigned long modstruct; /* COMPAT_2_0! *//* depends on architecture? */
- unsigned long size;
- unsigned long flags;
- long usecount;
- size_t nsyms;
- struct module_symbol *syms;
- size_t nrefs;
- struct module_stat **refs;
- unsigned long status;
-};
-
-extern struct module_stat *module_stat;
-extern size_t n_module_stat;
-extern char *module_name_list;
-extern size_t l_module_name_list;
-extern struct module_symbol *ksyms;
-extern size_t nksyms;
-extern int k_new_syscalls;
-
-int get_kernel_info(int type);
-
-#endif /* _KERNEL_H */
diff --git a/mdk-stage1/insmod-modutils/include/module.h b/mdk-stage1/insmod-modutils/include/module.h
deleted file mode 100644
index ae8224f8a..000000000
--- a/mdk-stage1/insmod-modutils/include/module.h
+++ /dev/null
@@ -1,217 +0,0 @@
-#ifndef MODUTILS_MODULE_H
-#define MODUTILS_MODULE_H 1
-
-/* Definitions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* This file contains the structures used by the 2.0 and 2.1 kernels.
- We do not use the kernel headers directly because we do not wish
- to be dependant on a particular kernel version to compile insmod. */
-
-
-/*======================================================================*/
-/* The structures used by Linux 2.0. */
-
-/* The symbol format used by get_kernel_syms(2). */
-struct old_kernel_sym
-{
- unsigned long value;
- char name[60];
-};
-
-struct old_module_ref
-{
- unsigned long module; /* kernel addresses */
- unsigned long next;
-};
-
-struct old_module_symbol
-{
- unsigned long addr;
- unsigned long name;
-};
-
-struct old_symbol_table
-{
- int size; /* total, including string table!!! */
- int n_symbols;
- int n_refs;
- struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */
- struct old_module_ref ref[0]; /* actual size defined by n_refs */
-};
-
-struct old_mod_routines
-{
- unsigned long init;
- unsigned long cleanup;
-};
-
-struct old_module
-{
- unsigned long next;
- unsigned long ref; /* the list of modules that refer to me */
- unsigned long symtab;
- unsigned long name;
- int size; /* size of module in pages */
- unsigned long addr; /* address of module */
- int state;
- unsigned long cleanup; /* cleanup routine */
-};
-
-/* Sent to init_module(2) or'ed into the code size parameter. */
-#define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
-
-int get_kernel_syms(struct old_kernel_sym *);
-int old_sys_init_module(const char *name, char *code, unsigned codesize,
- struct old_mod_routines *, struct old_symbol_table *);
-
-/*======================================================================*/
-/* For sizeof() which are related to the module platform and not to the
- environment isnmod is running in, use sizeof_xx instead of sizeof(xx). */
-
-#define tgt_sizeof_char sizeof(char)
-#define tgt_sizeof_short sizeof(short)
-#define tgt_sizeof_int sizeof(int)
-#define tgt_sizeof_long sizeof(long)
-#define tgt_sizeof_char_p sizeof(char *)
-#define tgt_sizeof_void_p sizeof(void *)
-#define tgt_long long
-#define tgt_long_fmt "l"
-
-/* This assumes that long long on a 32 bit system is equivalent to long on the
- * equivalent 64 bit system. Also that void and char pointers are 8 bytes on
- * all 64 bit systems. Add per system tweaks if it ever becomes necessary.
- */
-#if defined(COMMON_3264) && defined(ONLY_64)
-#undef tgt_long
-#undef tgt_long_fmt
-#undef tgt_sizeof_long
-#undef tgt_sizeof_char_p
-#undef tgt_sizeof_void_p
-#define tgt_long long long
-#define tgt_long_fmt "ll"
-#define tgt_sizeof_long 8
-#define tgt_sizeof_char_p 8
-#define tgt_sizeof_void_p 8
-#endif
-
-/*======================================================================*/
-/* The structures used in Linux 2.1 onwards. */
-
-/* Note: module_symbol does not use tgt_long intentionally */
-struct module_symbol
-{
- unsigned long value;
- unsigned long name;
-};
-
-struct module_ref
-{
- unsigned tgt_long dep; /* kernel addresses */
- unsigned tgt_long ref;
- unsigned tgt_long next_ref;
-};
-
-struct module
-{
- unsigned tgt_long size_of_struct; /* == sizeof(module) */
- unsigned tgt_long next;
- unsigned tgt_long name;
- unsigned tgt_long size;
-
- tgt_long usecount;
- unsigned tgt_long flags; /* AUTOCLEAN et al */
-
- unsigned nsyms;
- unsigned ndeps;
-
- unsigned tgt_long syms;
- unsigned tgt_long deps;
- unsigned tgt_long refs;
- unsigned tgt_long init;
- unsigned tgt_long cleanup;
- unsigned tgt_long ex_table_start;
- unsigned tgt_long ex_table_end;
-#ifdef __alpha__
- unsigned tgt_long gp;
-#endif
- /* Everything after here is extension. */
- unsigned tgt_long read_start; /* Read data from existing module */
- unsigned tgt_long read_end;
- unsigned tgt_long can_unload;
- unsigned tgt_long runsize;
- unsigned tgt_long kallsyms_start;
- unsigned tgt_long kallsyms_end;
- unsigned tgt_long archdata_start;
- unsigned tgt_long archdata_end;
- unsigned tgt_long kernel_data;
-};
-
-struct module_info
-{
- unsigned long addr;
- unsigned long size;
- unsigned long flags;
- long usecount;
-};
-
-/* Bits of module.flags. */
-#define NEW_MOD_RUNNING 1
-#define NEW_MOD_DELETED 2
-#define NEW_MOD_AUTOCLEAN 4
-#define NEW_MOD_VISITED 8
-#define NEW_MOD_USED_ONCE 16
-#define NEW_MOD_INITIALIZING 64
-
-int sys_init_module(const char *name, const struct module *);
-int query_module(const char *name, int which, void *buf, size_t bufsize,
- size_t *ret);
-
-/* Values for query_module's which. */
-
-#define QM_MODULES 1
-#define QM_DEPS 2
-#define QM_REFS 3
-#define QM_SYMBOLS 4
-#define QM_INFO 5
-
-/*======================================================================*/
-/* The system calls unchanged between 2.0 and 2.1. */
-
-unsigned long create_module(const char *, size_t);
-int delete_module(const char *);
-
-/* In safe mode the last parameter is forced to be a module name and meta
- * expansion is not allowed on that name.
- */
-extern unsigned int safemode;
-
-/*======================================================================*/
-/* Tainted kernel information. This must match include/linux/kernel.h */
-/* and kernel/panic.c. */
-
-#define TAINT_FILENAME "/proc/sys/kernel/tainted"
-#define TAINT_PROPRIETORY_MODULE (1<<0)
-#define TAINT_FORCED_MODULE (1<<1)
-#define TAINT_UNSAFE_SMP (1<<2)
-
-#endif /* module.h */
diff --git a/mdk-stage1/insmod-modutils/include/obj.h b/mdk-stage1/insmod-modutils/include/obj.h
deleted file mode 100644
index de346b16a..000000000
--- a/mdk-stage1/insmod-modutils/include/obj.h
+++ /dev/null
@@ -1,298 +0,0 @@
-#ifndef MODUTILS_OBJ_H
-#define MODUTILS_OBJ_H 1
-
-/* Elf object file loading and relocation routines.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
- obj_free() added by Björn Ekwall <bj0rn@blox.se> March 1999
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* The relocatable object is manipulated using elfin types. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <elf.h>
-#include ELF_MACHINE_H
-#include "module.h"
-
-#ifndef ElfW
-# if ELFCLASSM == ELFCLASS32
-# define ElfW(x) Elf32_ ## x
-# define ELFW(x) ELF32_ ## x
-# else
-# define ElfW(x) Elf64_ ## x
-# define ELFW(x) ELF64_ ## x
-# endif
-#endif
-
-#if defined(COMMON_3264) && defined(ONLY_32)
-# define ObjW(x) obj32_ ## x
-#else
-# if defined(COMMON_3264) && defined(ONLY_64)
-# define ObjW(x) obj64_ ## x
-# else
-# define ObjW(x) obj_ ## x
-# endif
-#endif
-
-/* For some reason this is missing from lib5. */
-#ifndef ELF32_ST_INFO
-# define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
-#endif
-
-#ifndef ELF64_ST_INFO
-# define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
-#endif
-
-struct obj_string_patch_struct;
-struct obj_symbol_patch_struct;
-
-struct obj_section
-{
- ElfW(Shdr) header;
- const char *name;
- char *contents;
- struct obj_section *load_next;
- int idx;
-};
-
-struct obj_symbol
-{
- struct obj_symbol *next; /* hash table link */
- const char *name;
- tgt_long value;
- unsigned long size;
- int secidx; /* the defining section index/module */
- int info;
- int ksymidx; /* for export to the kernel symtab */
- int r_type; /* relocation type */
-};
-
-/* Hardcode the hash table size. We shouldn't be needing so many
- symbols that we begin to degrade performance, and we get a big win
- by giving the compiler a constant divisor. */
-
-#define HASH_BUCKETS 521
-
-struct obj_file
-{
- ElfW(Ehdr) header;
- ElfW(Addr) baseaddr;
- struct obj_section **sections;
- struct obj_section *load_order;
- struct obj_section **load_order_search_start;
- struct obj_string_patch_struct *string_patches;
- struct obj_symbol_patch_struct *symbol_patches;
- int (*symbol_cmp)(const char *, const char *);
- unsigned long (*symbol_hash)(const char *);
- unsigned long local_symtab_size;
- struct obj_symbol **local_symtab;
- struct obj_symbol *symtab[HASH_BUCKETS];
- const char *filename;
- char *persist;
-};
-
-enum obj_reloc
-{
- obj_reloc_ok,
- obj_reloc_overflow,
- obj_reloc_dangerous,
- obj_reloc_unhandled,
- obj_reloc_constant_gp
-};
-
-struct obj_string_patch_struct
-{
- struct obj_string_patch_struct *next;
- int reloc_secidx;
- ElfW(Addr) reloc_offset;
- ElfW(Addr) string_offset;
-};
-
-struct obj_symbol_patch_struct
-{
- struct obj_symbol_patch_struct *next;
- int reloc_secidx;
- ElfW(Addr) reloc_offset;
- struct obj_symbol *sym;
-};
-
-
-/* Generic object manipulation routines. */
-
-#define obj_elf_hash ObjW(elf_hash)
-#define obj_elf_hash_n ObjW(elf_hash_n)
-#define obj_add_symbol ObjW(add_symbol)
-#define obj_find_symbol ObjW(find_symbol)
-#define obj_symbol_final_value ObjW(symbol_final_value)
-#define obj_set_symbol_compare ObjW(set_symbol_compare)
-#define obj_find_section ObjW(find_section)
-#define obj_insert_section_load_order ObjW(insert_section_load_order)
-#define obj_create_alloced_section ObjW(create_alloced_section)
-#define obj_create_alloced_section_first \
- ObjW(create_alloced_section_first)
-#define obj_extend_section ObjW(extend_section)
-#define obj_string_patch ObjW(string_patch)
-#define obj_symbol_patch ObjW(symbol_patch)
-#define obj_check_undefineds ObjW(check_undefineds)
-#define obj_clear_undefineds ObjW(clear_undefineds)
-#define obj_allocate_commons ObjW(allocate_commons)
-#define obj_load_size ObjW(load_size)
-#define obj_relocate ObjW(relocate)
-#define obj_load ObjW(load)
-#define obj_free ObjW(free)
-#define obj_create_image ObjW(create_image)
-#define obj_addr_to_native_ptr ObjW(addr_to_native_ptr)
-#define obj_native_ptr_to_addr ObjW(native_ptr_to_addr)
-#define obj_kallsyms ObjW(kallsyms)
-#define obj_gpl_license ObjW(gpl_license)
-#define arch_new_file ObjW(arch_new_file)
-#define arch_new_section ObjW(arch_new_section)
-#define arch_new_symbol ObjW(arch_new_symbol)
-#define arch_apply_relocation ObjW(arch_apply_relocation)
-#define arch_create_got ObjW(arch_create_got)
-#define arch_init_module ObjW(arch_init_module)
-#define arch_load_proc_section ObjW(arch_load_proc_section)
-#define arch_finalize_section_address ObjW(arch_finalize_section_address)
-#define arch_archdata ObjW(arch_archdata)
-
-unsigned long obj_elf_hash (const char *);
-
-unsigned long obj_elf_hash_n (const char *, unsigned long len);
-
-struct obj_symbol *obj_add_symbol (struct obj_file *f, const char *name,
- unsigned long symidx, int info, int secidx,
- ElfW(Addr) value, unsigned long size);
-
-struct obj_symbol *obj_find_symbol (struct obj_file *f,
- const char *name);
-
-ElfW(Addr) obj_symbol_final_value (struct obj_file *f,
- struct obj_symbol *sym);
-
-void obj_set_symbol_compare (struct obj_file *f,
- int (*cmp)(const char *, const char *),
- unsigned long (*hash)(const char *));
-
-struct obj_section *obj_find_section (struct obj_file *f,
- const char *name);
-
-void obj_insert_section_load_order (struct obj_file *f,
- struct obj_section *sec);
-
-struct obj_section *obj_create_alloced_section (struct obj_file *f,
- const char *name,
- unsigned long align,
- unsigned long size,
- unsigned long flags);
-
-struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
- const char *name,
- unsigned long align,
- unsigned long size);
-
-void *obj_extend_section (struct obj_section *sec, unsigned long more);
-
-int obj_string_patch (struct obj_file *f, int secidx, ElfW(Addr) offset,
- const char *string);
-
-int obj_symbol_patch (struct obj_file *f, int secidx, ElfW(Addr) offset,
- struct obj_symbol *sym);
-
-int obj_check_undefineds (struct obj_file *f, int quiet);
-
-void obj_clear_undefineds (struct obj_file *f);
-
-void obj_allocate_commons (struct obj_file *f);
-
-unsigned long obj_load_size (struct obj_file *f);
-
-int obj_relocate (struct obj_file *f, ElfW(Addr) base);
-
-struct obj_file *obj_load (int f, Elf32_Half e_type, const char *filename);
-
-void obj_free (struct obj_file *f);
-
-int obj_create_image (struct obj_file *f, char *image);
-
-int obj_kallsyms (struct obj_file *fin, struct obj_file **fout);
-
-/* Architecture specific manipulation routines. */
-
-struct obj_file *arch_new_file (void);
-
-struct obj_section *arch_new_section (void);
-
-struct obj_symbol *arch_new_symbol (void);
-
-enum obj_reloc arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- ElfW(RelM) *rel, ElfW(Addr) value);
-
-int arch_create_got (struct obj_file *f);
-
-struct module;
-int arch_init_module (struct obj_file *f, struct module *);
-
-int arch_load_proc_section (struct obj_section *sec, int fp);
-
-int arch_finalize_section_address (struct obj_file *f, ElfW(Addr) base);
-
-int arch_archdata (struct obj_file *fin, struct obj_section *sec);
-
-#define ARCHDATA_SEC_NAME "__archdata"
-
-/* Pointers in objects can be 32 or 64 bit */
-union obj_ptr_4 {
- Elf32_Word addr;
- void *ptr;
-};
-union obj_ptr_8 {
- u_int64_t addr; /* Should be Elf64_Xword but not all users have this yet */
- void *ptr;
-};
-
-void *obj_addr_to_native_ptr(ElfW(Addr));
-
-ElfW(Addr) obj_native_ptr_to_addr(void *);
-
-/* Standard method of finding relocation symbols, sets isym */
-#define obj_find_relsym(isym, f, find, rel, symtab, strtab) \
- { \
- unsigned long symndx = ELFW(R_SYM)((rel)->r_info); \
- ElfW(Sym) *extsym = (symtab)+symndx; \
- if (ELFW(ST_BIND)(extsym->st_info) == STB_LOCAL) { \
- isym = (typeof(isym)) (f)->local_symtab[symndx]; \
- } \
- else { \
- const char *name; \
- if (extsym->st_name) \
- name = (strtab) + extsym->st_name; \
- else \
- name = (f)->sections[extsym->st_shndx]->name; \
- isym = (typeof(isym)) obj_find_symbol((find), name); \
- } \
- }
-
-int obj_gpl_license(struct obj_file *, const char **);
-
-#endif /* obj.h */
diff --git a/mdk-stage1/insmod-modutils/include/util.h b/mdk-stage1/insmod-modutils/include/util.h
deleted file mode 100644
index 0a1354bec..000000000
--- a/mdk-stage1/insmod-modutils/include/util.h
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef MODUTILS_UTIL_H
-#define MODUTILS_UTIL_H 1
-
-/* Miscelaneous utility functions.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include <stdio.h>
-#include <sys/stat.h>
-
-#define SHELL_META "&();|<>$`\"'\\!{}[]~=+:?*" /* Sum of bj0rn and Debian */
-
-void *xmalloc(size_t);
-void *xrealloc(void *, size_t);
-char *xstrdup(const char *);
-char *xstrcat(char *, const char *, size_t);
-int xsystem(const char *, char *const[]);
-int arch64(void);
-
-typedef int (*xftw_func_t)(const char *, const struct stat *);
-extern int xftw(const char *directory, xftw_func_t);
-
-/* Error logging */
-extern int log;
-extern int errors;
-extern const char *error_file;
-
-extern int flag_verbose;
-extern void verbose(const char *ctl,...);
-
-void error(const char *fmt, ...)
-#ifdef __GNUC__
- __attribute__((format(printf, 1, 2)))
-#endif
- ;
-
-void lprintf(const char *fmt, ...)
-#ifdef __GNUC__
- __attribute__((format(printf, 1, 2)))
-#endif
- ;
-
-void setsyslog(const char *program);
-
-/*
- * Generic globlist <bj0rn@blox.se>
- */
-typedef struct {
- int pathc; /* Count of paths matched so far */
- char **pathv; /* List of matched pathnames. */
-} GLOB_LIST;
-int meta_expand(char *pt, GLOB_LIST *g, char *base_dir, char *version, int type);
-#define ME_BUILTIN_COMMAND 1
-#define ME_SHELL_COMMAND 2
-#define ME_GLOB 4
-#define ME_ALL (ME_GLOB|ME_SHELL_COMMAND|ME_BUILTIN_COMMAND)
-
-extern void snap_shot(const char *module_name, int number);
-extern void snap_shot_log(const char *fmt,...);
-
-#ifdef CONFIG_USE_ZLIB
-int gzf_open(const char *name, int mode);
-int gzf_read(int fd, void *buf, size_t count);
-off_t gzf_lseek(int fd, off_t offset, int whence);
-void gzf_close(int fd);
-
-#else /* ! CONFIG_USE_ZLIB */
-
-#include <unistd.h>
-
-#define gzf_open open
-#define gzf_read read
-#define gzf_lseek lseek
-#define gzf_close close
-
-#endif /* CONFIG_USE_ZLIB */
-
-#define SYMPREFIX "__insmod_";
-extern const char symprefix[10]; /* Must be sizeof(SYMPREFIX), including nul */
-
-#endif /* util.h */
diff --git a/mdk-stage1/insmod-modutils/include/version.h b/mdk-stage1/insmod-modutils/include/version.h
deleted file mode 100644
index 9ca0c57a9..000000000
--- a/mdk-stage1/insmod-modutils/include/version.h
+++ /dev/null
@@ -1 +0,0 @@
-#define MODUTILS_VERSION "2.4.19"
diff --git a/mdk-stage1/insmod-modutils/insmod-frontend.c b/mdk-stage1/insmod-modutils/insmod-frontend.c
deleted file mode 100644
index 26fe73c47..000000000
--- a/mdk-stage1/insmod-modutils/insmod-frontend.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdio.h>
-
-
-int insmod_main( int argc, char **argv);
-
-int main( int argc, char **argv)
-{
- printf("Using insmod provided by modutils.\n");
- return insmod_main(argc, argv);
-}
diff --git a/mdk-stage1/insmod-modutils/insmod.c b/mdk-stage1/insmod-modutils/insmod.c
deleted file mode 100644
index b0b7c2a0d..000000000
--- a/mdk-stage1/insmod-modutils/insmod.c
+++ /dev/null
@@ -1,2141 +0,0 @@
-/* Insert a module into a running kernel.
- Copyright 1996, 1997 Linux International.
-
- New implementation contributed by Richard Henderson <rth@tamu.edu>
- Based on original work by Bjorn Ekwall <bj0rn@blox.se>
- Restructured (and partly rewritten) by:
- Björn Ekwall <bj0rn@blox.se> February 1999
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
- /*
- Fixes:
-
- Adjust module size for mod_use_count in old_init_module:
- B. James Phillippe <bryan@terran.org>
-
- Merged modprobe + many fixes: Björn Ekwall <bj0rn@blox.se> February 1999
- SMP "friendliness" (and -P): Bill Zumach <zumach+@transarc.com>
-
- Ksymoops support: Keith Owens <kaos@ocs.com.au> August 1999.
-
- Add -r flag: Keith Owens <kaos@ocs.com.au> October 1999.
-
- More flexible recognition of the way the utility was called.
- Suggested by Stepan Kasal, implemented in a different way by Keith
- Owens <kaos@ocs.com.au> December 1999.
-
- Rationalize common code for 32/64 bit architectures.
- Keith Owens <kaos@ocs.com.au> December 1999.
- Add arch64().
- Keith Owens <kaos@ocs.com.au> December 1999.
- kallsyms support
- Keith Owens <kaos@ocs.com.au> April 2000.
- archdata support
- Keith Owens <kaos@ocs.com.au> August 2000.
- Add insmod -O, move print map before sys_init_module.
- Keith Owens <kaos@ocs.com.au> October 2000.
- Add insmod -S.
- Keith Owens <kaos@ocs.com.au> November 2000.
- Add persistent data support.
- Keith Owens <kaos@ocs.com.au> November 2000.
- Add tainted module support.
- Keith Owens <kaos@ocs.com.au> September 2001.
- */
-
-#include "../insmod.h"
-#include <sys/types.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <limits.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stddef.h>
-#include <getopt.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/fcntl.h>
-
-#include "module.h"
-#include "obj.h"
-#include "kallsyms.h"
-#include "util.h"
-#include "version.h"
-
-#include "modstat.h"
-#include "config.h"
-
-#define STRVERSIONLEN 32
-
-/*======================================================================*/
-
-static int flag_force_load = 0;
-static int flag_silent_probe = 0;
-static int flag_export = 1;
-static int flag_load_map = 0;
-static int flag_ksymoops = 1;
-static int flag_numeric_only = 0;
-
-static int n_ext_modules_used;
-static int m_has_modinfo;
-static int gplonly_seen;
-static int warnings;
-
-extern int insmod_main(int argc, char **argv);
-extern int insmod_main_32(int argc, char **argv);
-extern int insmod_main_64(int argc, char **argv);
-extern int modprobe_main(int argc, char **argv);
-extern int rmmod_main(int argc, char **argv);
-extern int ksyms_main(int argc, char **argv);
-extern int lsmod_main(int argc, char **argv);
-extern int kallsyms_main(int argc, char **argv);
-
-/*======================================================================*/
-
-/* Only use the numeric part of the version string? */
-
-static void use_numeric_only(int major, int minor, char *str)
-{
- if (((major << 8) + minor) >= 0x0205 /* kernel 2.5 */
- || flag_numeric_only)
- *str = '\0';
-}
-
-/* Get the kernel version in the canonical integer form. */
-
-static int get_kernel_version(char str[STRVERSIONLEN])
-{
- char *p, *q;
- int a, b, c;
-
- strncpy(str, uts_info.release, STRVERSIONLEN-1);
- str[STRVERSIONLEN-1] = '\0';
- p = str;
-
- a = strtoul(p, &p, 10);
- if (*p != '.')
- return -1;
- b = strtoul(p + 1, &p, 10);
- if (*p != '.')
- return -1;
- c = strtoul(p + 1, &q, 10);
- if (p + 1 == q)
- return -1;
- use_numeric_only(a, b, q);
-
- return a << 16 | b << 8 | c;
-}
-
-/* String comparison for non-co-versioned kernel and module.
- * prefix should be the same as used by genksyms for this kernel.
- */
-static char *ncv_prefix = NULL; /* Overridden by --prefix option */
-static int ncv_plen = 0;
-
-/* Only set prefix once. If set by the user, use it. If not set by the
- * user, look for a well known kernel symbol and derive the prefix from
- * there. Otherwise set the prefix depending on whether uts_info
- * includes SMP or not for backwards compatibility.
- */
-static void set_ncv_prefix(char *prefix)
-{
- static char derived_prefix[256];
- static const char *well_known_symbol[] = { "get_module_symbol_R",
- "inter_module_get_R",
- };
- struct module_symbol *s;
- int i, j, l, m, pl;
- const char *name;
- char *p;
-
- if (ncv_prefix)
- return;
-
- if (prefix)
- ncv_prefix = prefix;
- else {
- /* Extract the prefix (if any) from well known symbols */
- for (i = 0, s = ksyms; i < nksyms; ++i, ++s) {
- name = (char *) s->name;
- l = strlen(name);
- for (j = 0; j < sizeof(well_known_symbol)/sizeof(well_known_symbol[0]); ++j) {
- m = strlen(well_known_symbol[j]);
- if (m + 8 > l ||
- strncmp(name, well_known_symbol[j], m))
- continue;
- pl = l - m - 8;
- if (pl > sizeof(derived_prefix)-1)
- continue; /* Prefix is wrong length */
- /* Must end with 8 hex digits */
- (void) strtoul(name+l-8, &p, 16);
- if (*p == 0) {
- strncpy(derived_prefix, name+m, pl);
- *(derived_prefix+pl) = '\0';
- ncv_prefix = derived_prefix;
- break;
- }
- }
- }
- }
- if (!ncv_prefix) {
- p = strchr(uts_info.version, ' ');
- if (p && *(++p) && !strncmp(p, "SMP ", 4))
- ncv_prefix = "smp_";
- else
- ncv_prefix = "";
- }
- ncv_plen = strlen(ncv_prefix);
- if (flag_verbose)
- lprintf("Symbol version prefix '%s'", ncv_prefix);
-}
-
-static int ncv_strcmp(const char *a, const char *b)
-{
- size_t alen = strlen(a), blen = strlen(b);
-
- if (blen == alen + 10 + ncv_plen &&
- b[alen] == '_' &&
- b[alen + 1] == 'R' &&
- !(ncv_plen && strncmp(b + alen + 2, ncv_prefix, ncv_plen))) {
- return strncmp(a, b, alen);
- } else if (alen == blen + 10 + ncv_plen &&
- a[blen] == '_' && a[blen + 1] == 'R' &&
- !(ncv_plen && strncmp(a + blen + 2, ncv_prefix, ncv_plen))) {
- return strncmp(a, b, blen);
- } else
- return strcmp(a, b);
-}
-
-/*
- * String hashing for non-co-versioned kernel and module.
- * Here we are simply forced to drop the crc from the hash.
- */
-static unsigned long ncv_symbol_hash(const char *str)
-{
- size_t len = strlen(str);
-
- if (len > 10 + ncv_plen &&
- str[len - 10 - ncv_plen] == '_' &&
- str[len - 9 - ncv_plen] == 'R' &&
- !(
- ncv_plen &&
- strncmp(str + len - (8 + ncv_plen), ncv_prefix, ncv_plen)
- ))
- len -= 10 + ncv_plen;
- return obj_elf_hash_n(str, len);
-}
-
-/*
- * Conditionally add the symbols from the given symbol set
- * to the new module.
- */
-static int add_symbols_from(struct obj_file *f, int idx,
- struct module_symbol *syms, size_t nsyms, int gpl)
-{
- struct module_symbol *s;
- size_t i;
- int used = 0;
-
- for (i = 0, s = syms; i < nsyms; ++i, ++s) {
- /*
- * Only add symbols that are already marked external.
- * If we override locals we may cause problems for
- * argument initialization.
- * We will also create a false dependency on the module.
- */
- struct obj_symbol *sym;
-
- /* GPL licensed modules can use symbols exported with
- * EXPORT_SYMBOL_GPL, so ignore any GPLONLY_ prefix on the
- * exported names. Non-GPL modules never see any GPLONLY_
- * symbols so they cannot fudge it by adding the prefix on
- * their references.
- */
- if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) {
- gplonly_seen = 1;
- if (gpl)
- ((char *)s->name) += 8;
- else
- continue;
- }
-
- sym = obj_find_symbol(f, (char *) s->name);
-#ifdef ARCH_ppc64
- if (!sym)
- {
- static size_t buflen = 0;
- static char *buf = 0;
- int len;
-
- /* ppc64 is one of those architectures with
- function descriptors. A function is exported
- and accessed across object boundaries via its
- function descriptor. The function code symbol
- happens to be the function name, prefixed with
- '.', and a function call is a branch to the
- code symbol. The linker recognises when a call
- crosses object boundaries, and inserts a stub
- to call via the function descriptor.
- obj_ppc64.c of course does the same thing, so
- here we recognise that an undefined code symbol
- can be satisfied by the corresponding function
- descriptor symbol. */
-
- len = strlen ((char *) s->name) + 2;
- if (buflen < len)
- {
- buflen = len + (len >> 1);
- if (buf)
- free (buf);
- buf = malloc (buflen);
- }
- buf[0] = '.';
- strcpy (buf + 1, (char *) s->name);
- sym = obj_find_symbol(f, buf);
- }
-#endif /* ARCH_ppc64 */
-
- if (sym && ELFW(ST_BIND) (sym->info) != STB_LOCAL) {
- sym = obj_add_symbol(f, (char *) s->name, -1,
- ELFW(ST_INFO) (STB_GLOBAL, STT_NOTYPE),
- idx, s->value, 0);
- /*
- * Did our symbol just get installed?
- * If so, mark the module as "used".
- */
- if (sym->secidx == idx)
- used = 1;
- }
- }
-
- return used;
-}
-
-static void add_kernel_symbols(struct obj_file *f, int gpl)
-{
- struct module_stat *m;
- size_t i, nused = 0;
-
- /* Add module symbols first. */
- for (i = 0, m = module_stat; i < n_module_stat; ++i, ++m)
- if (m->nsyms &&
- add_symbols_from(f, SHN_HIRESERVE + 2 + i, m->syms, m->nsyms, gpl))
- m->status = 1 /* used */, ++nused;
- n_ext_modules_used = nused;
-
- /* And finally the symbols from the kernel proper. */
- if (nksyms)
- add_symbols_from(f, SHN_HIRESERVE + 1, ksyms, nksyms, gpl);
-}
-
-static void hide_special_symbols(struct obj_file *f)
-{
- struct obj_symbol *sym;
- const char *const *p;
- static const char *const specials[] =
- {
- "cleanup_module",
- "init_module",
- "kernel_version",
- NULL
- };
-
- for (p = specials; *p; ++p)
- if ((sym = obj_find_symbol(f, *p)) != NULL)
- sym->info = ELFW(ST_INFO) (STB_LOCAL, ELFW(ST_TYPE) (sym->info));
-}
-
-static void print_load_map(struct obj_file *f)
-{
- struct obj_symbol *sym;
- struct obj_symbol **all, **p;
- struct obj_section *sec;
- int load_map_cmp(const void *a, const void *b) {
- struct obj_symbol **as = (struct obj_symbol **) a;
- struct obj_symbol **bs = (struct obj_symbol **) b;
- unsigned long aa = obj_symbol_final_value(f, *as);
- unsigned long ba = obj_symbol_final_value(f, *bs);
- return aa < ba ? -1 : aa > ba ? 1 : 0;
- }
- int i, nsyms, *loaded;
-
- /* Report on the section layout. */
-
- lprintf("Sections: Size %-*s Align",
- (int) (2 * sizeof(void *)), "Address");
-
- for (sec = f->load_order; sec; sec = sec->load_next) {
- int a;
- unsigned long tmp;
-
- for (a = -1, tmp = sec->header.sh_addralign; tmp; ++a)
- tmp >>= 1;
- if (a == -1)
- a = 0;
-
- lprintf("%-15s %08lx %0*lx 2**%d",
- sec->name,
- (long)sec->header.sh_size,
- (int) (2 * sizeof(void *)),
- (long)sec->header.sh_addr,
- a);
- }
-
- /* Quick reference which section indicies are loaded. */
-
- loaded = alloca(sizeof(int) * (i = f->header.e_shnum));
- while (--i >= 0)
- loaded[i] = (f->sections[i]->header.sh_flags & SHF_ALLOC) != 0;
-
- /* Collect the symbols we'll be listing. */
-
- for (nsyms = i = 0; i < HASH_BUCKETS; ++i)
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (sym->secidx <= SHN_HIRESERVE
- && (sym->secidx >= SHN_LORESERVE || loaded[sym->secidx]))
- ++nsyms;
-
- all = alloca(nsyms * sizeof(struct obj_symbol *));
-
- for (i = 0, p = all; i < HASH_BUCKETS; ++i)
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (sym->secidx <= SHN_HIRESERVE
- && (sym->secidx >= SHN_LORESERVE || loaded[sym->secidx]))
- *p++ = sym;
-
- /* Sort them by final value. */
- qsort(all, nsyms, sizeof(struct obj_file *), load_map_cmp);
-
- /* And list them. */
- lprintf("\nSymbols:");
- for (p = all; p < all + nsyms; ++p) {
- char type = '?';
- unsigned long value;
-
- sym = *p;
- if (sym->secidx == SHN_ABS) {
- type = 'A';
- value = sym->value;
- } else if (sym->secidx == SHN_UNDEF) {
- type = 'U';
- value = 0;
- } else {
- struct obj_section *sec = f->sections[sym->secidx];
-
- if (sec->header.sh_type == SHT_NOBITS)
- type = 'B';
- else if (sec->header.sh_flags & SHF_ALLOC) {
- if (sec->header.sh_flags & SHF_EXECINSTR)
- type = 'T';
- else if (sec->header.sh_flags & SHF_WRITE)
- type = 'D';
- else
- type = 'R';
- }
- value = sym->value + sec->header.sh_addr;
- }
-
- if (ELFW(ST_BIND) (sym->info) == STB_LOCAL)
- type = tolower(type);
-
- lprintf("%0*lx %c %s", (int) (2 * sizeof(void *)), value,
- type, sym->name);
- }
-}
-
-/************************************************************************/
-/* begin compat */
-
-static char * get_modinfo_value(struct obj_file *f, const char *key)
-{
- struct obj_section *sec;
- char *p, *v, *n, *ep;
- size_t klen = strlen(key);
-
- sec = obj_find_section(f, ".modinfo");
- if (sec == NULL)
- return NULL;
-
- p = sec->contents;
- ep = p + sec->header.sh_size;
- while (p < ep) {
- v = strchr(p, '=');
- n = strchr(p, '\0');
- if (v) {
- if (v - p == klen && strncmp(p, key, klen) == 0)
- return v + 1;
- } else {
- if (n - p == klen && strcmp(p, key) == 0)
- return n;
- }
- p = n + 1;
- }
-
- return NULL;
-}
-
-static int create_this_module(struct obj_file *f, const char *m_name)
-{
- struct obj_section *sec;
-
- sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long,
- sizeof(struct module));
- memset(sec->contents, 0, sizeof(struct module));
-
- obj_add_symbol(f, "__this_module", -1, ELFW(ST_INFO) (STB_LOCAL, STT_OBJECT),
- sec->idx, 0, sizeof(struct module));
-
- obj_string_patch(f, sec->idx, offsetof(struct module, name), m_name);
-
- return 1;
-}
-
-#ifdef COMPAT_2_0
-static int old_create_mod_use_count(struct obj_file *f)
-{
- struct obj_section *sec;
- struct obj_symbol *got;
-
- sec = obj_create_alloced_section_first(f, ".moduse",
- sizeof(long), sizeof(long));
-
- obj_add_symbol(f, "mod_use_count_",
- -1, ELFW(ST_INFO)(STB_LOCAL, STT_OBJECT),
- sec->idx, 0, sizeof(long));
-
- /*
- * patb: if there is a _GLOBAL_OFFSET_TABLE_,
- * add .got section for PIC type modules;
- * we have to do this here, because obj_* calls are not made until
- * after obj_check_undefined
- * is there a better place for this exception?
- */
- got = obj_find_symbol(f, "_GLOBAL_OFFSET_TABLE_");
- if (got)
- {
- sec = obj_create_alloced_section(f, ".got",
- sizeof(long), sizeof(long),
- SHF_WRITE);
- got->secidx = sec->idx; /* mark the symbol as defined */
- }
- return 1;
-}
-#endif
-
-/* add an entry to the __ksymtab section, creating it if necessary */
-static void add_ksymtab(struct obj_file *f, struct obj_symbol *sym)
-{
- struct obj_section *sec;
- ElfW(Addr) ofs;
-
- /* ensure __ksymtab is allocated, EXPORT_NOSYMBOLS creates a non-alloc section.
- * If __ksymtab is defined but not marked alloc, x out the first character
- * (no obj_delete routine) and create a new __ksymtab with the correct
- * characteristics.
- */
- sec = obj_find_section(f, "__ksymtab");
- if (sec && !(sec->header.sh_flags & SHF_ALLOC)) {
- *((char *)(sec->name)) = 'x'; /* override const */
- sec = NULL;
- }
- if (!sec)
- sec = obj_create_alloced_section(f, "__ksymtab",
- tgt_sizeof_void_p, 0, 0);
- if (!sec)
- return;
- sec->header.sh_flags |= SHF_ALLOC;
-
- ofs = sec->header.sh_size;
- obj_symbol_patch(f, sec->idx, ofs, sym);
- obj_string_patch(f, sec->idx, ofs + tgt_sizeof_void_p, sym->name);
- obj_extend_section(sec, 2 * tgt_sizeof_char_p);
-}
-
-static int create_module_ksymtab(struct obj_file *f)
-{
- struct obj_section *sec;
- int i;
-
- /* We must always add the module references. */
-
- if (n_ext_modules_used) {
- struct module_ref *dep;
- struct obj_symbol *tm;
-
- sec = obj_create_alloced_section(f, ".kmodtab",
- tgt_sizeof_void_p,
- sizeof(struct module_ref) * n_ext_modules_used, 0);
- if (!sec)
- return 0;
-
- tm = obj_find_symbol(f, "__this_module");
- dep = (struct module_ref *) sec->contents;
- for (i = 0; i < n_module_stat; ++i)
- if (module_stat[i].status /* used */) {
- dep->dep = module_stat[i].addr;
-#ifdef ARCH_ppc64
- dep->dep |= ppc64_module_base (f);
-#endif
- obj_symbol_patch(f, sec->idx, (char *) &dep->ref - sec->contents, tm);
- dep->next_ref = 0;
- ++dep;
- }
- }
- if (flag_export && !obj_find_section(f, "__ksymtab")) {
- int *loaded;
-
- /* We don't want to export symbols residing in sections that
- aren't loaded. There are a number of these created so that
- we make sure certain module options don't appear twice. */
-
- loaded = alloca(sizeof(int) * (i = f->header.e_shnum));
- while (--i >= 0)
- loaded[i] = (f->sections[i]->header.sh_flags & SHF_ALLOC) != 0;
-
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next) {
- if (ELFW(ST_BIND) (sym->info) != STB_LOCAL
- && sym->secidx <= SHN_HIRESERVE
- && (sym->secidx >= SHN_LORESERVE
- || loaded[sym->secidx])) {
- add_ksymtab(f, sym);
- }
- }
- }
- }
- return 1;
-}
-
-/* Get the module's kernel version in the canonical integer form. */
-static int get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
-{
- int a, b, c;
- char *p, *q;
-
- if ((p = get_modinfo_value(f, "kernel_version")) == NULL) {
- struct obj_symbol *sym;
-
- m_has_modinfo = 0;
- if ((sym = obj_find_symbol(f, "kernel_version")) == NULL)
- sym = obj_find_symbol(f, "__module_kernel_version");
- if (sym == NULL)
- return -1;
- p = f->sections[sym->secidx]->contents + sym->value;
- } else
- m_has_modinfo = 1;
-
- strncpy(str, p, STRVERSIONLEN-1);
- str[STRVERSIONLEN-1] = '\0';
- p = str;
-
- a = strtoul(p, &p, 10);
- if (*p != '.')
- return -1;
- b = strtoul(p + 1, &p, 10);
- if (*p != '.')
- return -1;
- c = strtoul(p + 1, &q, 10);
- if (p + 1 == q)
- return -1;
- use_numeric_only(a, b, q);
-
- return a << 16 | b << 8 | c;
-}
-
-/* Return the kernel symbol checksum version, or zero if not used. */
-static int is_kernel_checksummed(void)
-{
- struct module_symbol *s;
- size_t i;
-
- /*
- * Using_Versions might not be the first symbol,
- * but it should be in there.
- */
- for (i = 0, s = ksyms; i < nksyms; ++i, ++s)
- if (strcmp((char *) s->name, "Using_Versions") == 0)
- return s->value;
-
- return 0;
-}
-
-static int is_module_checksummed(struct obj_file *f)
-{
- if (m_has_modinfo) {
- const char *p = get_modinfo_value(f, "using_checksums");
- if (p)
- return atoi(p);
- else
- return 0;
- } else
- return obj_find_symbol(f, "Using_Versions") != NULL;
-}
-
-/* add module source, timestamp, kernel version and a symbol for the
- * start of some sections. this info is used by ksymoops to do better
- * debugging.
- */
-static void add_ksymoops_symbols(struct obj_file *f, const char *filename,
- const char *m_name)
-{
- struct obj_section *sec;
- struct obj_symbol *sym;
- char *name, *absolute_filename;
- char str[STRVERSIONLEN], real[PATH_MAX];
- int i, l, lm_name, lfilename, use_ksymtab, version;
- struct stat statbuf;
-
- static const char *section_names[] = {
- ".text",
- ".rodata",
- ".data",
- ".bss"
- };
-
- if (realpath(filename, real)) {
- absolute_filename = xstrdup(real);
- }
- else {
- int save_errno = errno;
- error("cannot get realpath for %s", filename);
- errno = save_errno;
- perror("");
- absolute_filename = xstrdup(filename);
- }
-
- lm_name = strlen(m_name);
- lfilename = strlen(absolute_filename);
-
- /* add to ksymtab if it already exists or there is no ksymtab and other symbols
- * are not to be exported. otherwise leave ksymtab alone for now, the
- * "export all symbols" compatibility code will export these symbols later.
- */
-
- use_ksymtab = obj_find_section(f, "__ksymtab") || !flag_export;
-
- if ((sec = obj_find_section(f, ".this"))) {
- /* tag the module header with the object name, last modified
- * timestamp and module version. worst case for module version
- * is 0xffffff, decimal 16777215. putting all three fields in
- * one symbol is less readable but saves kernel space.
- */
- l = sizeof(symprefix)+ /* "__insmod_" */
- lm_name+ /* module name */
- 2+ /* "_O" */
- lfilename+ /* object filename */
- 2+ /* "_M" */
- 2*sizeof(statbuf.st_mtime)+ /* mtime in hex */
- 2+ /* "_V" */
- 8+ /* version in dec */
- 1; /* nul */
- name = xmalloc(l);
- if (stat(absolute_filename, &statbuf) != 0)
- statbuf.st_mtime = 0;
- version = get_module_version(f, str); /* -1 if not found */
- snprintf(name, l, "%s%s_O%s_M%0*lX_V%d",
- symprefix, m_name, absolute_filename,
- (int)(2*sizeof(statbuf.st_mtime)), statbuf.st_mtime,
- version);
- sym = obj_add_symbol(f, name, -1,
- ELFW(ST_INFO) (STB_GLOBAL, STT_NOTYPE),
- sec->idx, sec->header.sh_addr, 0);
- if (use_ksymtab)
- add_ksymtab(f, sym);
- }
- free(absolute_filename);
-
- /* record where the persistent data is going, same address as previous symbol */
-
- if (f->persist) {
- l = sizeof(symprefix)+ /* "__insmod_" */
- lm_name+ /* module name */
- 2+ /* "_P" */
- strlen(f->persist)+ /* data store */
- 1; /* nul */
- name = xmalloc(l);
- snprintf(name, l, "%s%s_P%s",
- symprefix, m_name, f->persist);
- sym = obj_add_symbol(f, name, -1, ELFW(ST_INFO) (STB_GLOBAL, STT_NOTYPE),
- sec->idx, sec->header.sh_addr, 0);
- if (use_ksymtab)
- add_ksymtab(f, sym);
- }
-
- /* tag the desired sections if size is non-zero */
-
- for (i = 0; i < sizeof(section_names)/sizeof(section_names[0]); ++i) {
- if ((sec = obj_find_section(f, section_names[i])) &&
- sec->header.sh_size) {
- l = sizeof(symprefix)+ /* "__insmod_" */
- lm_name+ /* module name */
- 2+ /* "_S" */
- strlen(sec->name)+ /* section name */
- 2+ /* "_L" */
- 8+ /* length in dec */
- 1; /* nul */
- name = xmalloc(l);
- snprintf(name, l, "%s%s_S%s_L%ld",
- symprefix, m_name, sec->name,
- (long)sec->header.sh_size);
- sym = obj_add_symbol(f, name, -1, ELFW(ST_INFO) (STB_GLOBAL, STT_NOTYPE),
- sec->idx, sec->header.sh_addr, 0);
- if (use_ksymtab)
- add_ksymtab(f, sym);
- }
- }
-}
-
-static int process_module_arguments(struct obj_file *f, int argc, char **argv, int required)
-{
- for (; argc > 0; ++argv, --argc) {
- struct obj_symbol *sym;
- int c;
- int min, max;
- int n;
- char *contents;
- char *input;
- char *fmt;
- char *key;
- char *loc;
-
- if ((input = strchr(*argv, '=')) == NULL)
- continue;
-
- n = input - *argv;
- input += 1; /* skip '=' */
-
- key = alloca(n + 6);
-
- if (m_has_modinfo) {
- memcpy(key, "parm_", 5);
- memcpy(key + 5, *argv, n);
- key[n + 5] = '\0';
- if ((fmt = get_modinfo_value(f, key)) == NULL) {
- if (required || flag_verbose) {
- lprintf("Warning: ignoring %s, no such parameter in this module", *argv);
- ++warnings;
- continue;
- }
- }
- key += 5;
-
- if (isdigit(*fmt)) {
- min = strtoul(fmt, &fmt, 10);
- if (*fmt == '-')
- max = strtoul(fmt + 1, &fmt, 10);
- else
- max = min;
- } else
- min = max = 1;
- } else { /* not m_has_modinfo */
- memcpy(key, *argv, n);
- key[n] = '\0';
-
- if (isdigit(*input))
- fmt = "i";
- else
- fmt = "s";
- min = max = 0;
- }
-
- sym = obj_find_symbol(f, key);
-
- /*
- * Also check that the parameter was not
- * resolved from the kernel.
- */
- if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- error("symbol for parameter %s not found", key);
- return 0;
- }
-
- contents = f->sections[sym->secidx]->contents;
- loc = contents + sym->value;
- n = 1;
-
- while (*input) {
- char *str;
-
- switch (*fmt) {
- case 's':
- case 'c':
- /*
- * Do C quoting if we begin with a ",
- * else slurp the lot.
- */
- if (*input == '"') {
- char *r;
-
- str = alloca(strlen(input));
- for (r = str, input++; *input != '"'; ++input, ++r) {
- if (*input == '\0') {
- error("improperly terminated string argument for %s", key);
- return 0;
- }
- /* else */
- if (*input != '\\') {
- *r = *input;
- continue;
- }
- /* else handle \ */
- switch (*++input) {
- case 'a': *r = '\a'; break;
- case 'b': *r = '\b'; break;
- case 'e': *r = '\033'; break;
- case 'f': *r = '\f'; break;
- case 'n': *r = '\n'; break;
- case 'r': *r = '\r'; break;
- case 't': *r = '\t'; break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- c = *input - '0';
- if ('0' <= input[1] && input[1] <= '7') {
- c = (c * 8) + *++input - '0';
- if ('0' <= input[1] && input[1] <= '7')
- c = (c * 8) + *++input - '0';
- }
- *r = c;
- break;
-
- default: *r = *input; break;
- }
- }
- *r = '\0';
- ++input;
- } else {
- /*
- * The string is not quoted.
- * We will break it using the comma
- * (like for ints).
- * If the user wants to include commas
- * in a string, he just has to quote it
- */
- char *r;
-
- /* Search the next comma */
- if ((r = strchr(input, ',')) != NULL) {
- /*
- * Found a comma
- * Recopy the current field
- */
- str = alloca(r - input + 1);
- memcpy(str, input, r - input);
- str[r - input] = '\0';
- /* Keep next fields */
- input = r;
- } else {
- /* last string */
- str = input;
- input = "";
- }
- }
-
- if (*fmt == 's') {
- /* Normal string */
- obj_string_patch(f, sym->secidx, loc - contents, str);
- loc += tgt_sizeof_char_p;
- } else {
- /* Array of chars (in fact, matrix !) */
- long charssize; /* size of each member */
-
- /* Get the size of each member */
- /* Probably we should do that outside the loop ? */
- if (!isdigit(*(fmt + 1))) {
- error("parameter type 'c' for %s must be followed by"
- " the maximum size", key);
- return 0;
- }
- charssize = strtoul(fmt + 1, (char **) NULL, 10);
-
- /* Check length */
- if (strlen(str) >= charssize-1) {
- error("string too long for %s (max %ld)",
- key, charssize - 1);
- return 0;
- }
- /* Copy to location */
- strcpy((char *) loc, str); /* safe, see check above */
- loc += charssize;
- }
- /*
- * End of 's' and 'c'
- */
- break;
-
- case 'b':
- *loc++ = strtoul(input, &input, 0);
- break;
-
- case 'h':
- *(short *) loc = strtoul(input, &input, 0);
- loc += tgt_sizeof_short;
- break;
-
- case 'i':
- *(int *) loc = strtoul(input, &input, 0);
- loc += tgt_sizeof_int;
- break;
-
- case 'l':
- *(long *) loc = strtoul(input, &input, 0);
- loc += tgt_sizeof_long;
- break;
-
- default:
- error("unknown parameter type '%c' for %s",
- *fmt, key);
- return 0;
- }
- /*
- * end of switch (*fmt)
- */
-
- while (*input && isspace(*input))
- ++input;
- if (*input == '\0')
- break; /* while (*input) */
- /* else */
-
- if (*input == ',') {
- if (max && (++n > max)) {
- error("too many values for %s (max %d)", key, max);
- return 0;
- }
- ++input;
- /* continue with while (*input) */
- } else {
- error("invalid argument syntax for %s: '%c'",
- key, *input);
- return 0;
- }
- } /* end of while (*input) */
-
- if (min && (n < min)) {
- error("too few values for %s (min %d)", key, min);
- return 0;
- }
- } /* end of for (;argc > 0;) */
-
- return 1;
-}
-
-
-/* Add a kallsyms section if the kernel supports all symbols. */
-static int add_kallsyms(struct obj_file *f,
- struct obj_section **module_kallsyms, int force_kallsyms)
-{
- struct module_symbol *s;
- struct obj_file *f_kallsyms;
- struct obj_section *sec_kallsyms;
- size_t i;
- int l;
- const char *p, *pt_R;
- unsigned long start = 0, stop = 0;
-
- for (i = 0, s = ksyms; i < nksyms; ++i, ++s) {
- p = (char *)s->name;
- pt_R = strstr(p, "_R");
- if (pt_R)
- l = pt_R - p;
- else
- l = strlen(p);
- if (strncmp(p, "__start_" KALLSYMS_SEC_NAME, l) == 0)
- start = s->value;
- else if (strncmp(p, "__stop_" KALLSYMS_SEC_NAME, l) == 0)
- stop = s->value;
- }
-
- if (start >= stop && !force_kallsyms)
- return(0);
-
- /* The kernel contains all symbols, do the same for this module. */
-
- /* Add an empty kallsyms section to the module if necessary */
- for (i = 0; i < f->header.e_shnum; ++i) {
- if (strcmp(f->sections[i]->name, KALLSYMS_SEC_NAME) == 0) {
- *module_kallsyms = f->sections[i];
- break;
- }
- }
- if (!*module_kallsyms)
- *module_kallsyms = obj_create_alloced_section(f, KALLSYMS_SEC_NAME, 0, 0, 0);
-
- /* Size and populate kallsyms */
- if (obj_kallsyms(f, &f_kallsyms))
- return(1);
- sec_kallsyms = f_kallsyms->sections[KALLSYMS_IDX];
- (*module_kallsyms)->header.sh_addralign = sec_kallsyms->header.sh_addralign;
- (*module_kallsyms)->header.sh_size = sec_kallsyms->header.sh_size;
- free((*module_kallsyms)->contents);
- (*module_kallsyms)->contents = sec_kallsyms->contents;
- sec_kallsyms->contents = NULL;
- obj_free(f_kallsyms);
-
- return 0;
-}
-
-
-/* Add an arch data section if the arch wants it. */
-static int add_archdata(struct obj_file *f,
- struct obj_section **sec)
-{
- size_t i;
-
- *sec = NULL;
- /* Add an empty archdata section to the module if necessary */
- for (i = 0; i < f->header.e_shnum; ++i) {
- if (strcmp(f->sections[i]->name, ARCHDATA_SEC_NAME) == 0) {
- *sec = f->sections[i];
- break;
- }
- }
- if (!*sec)
- *sec = obj_create_alloced_section(f, ARCHDATA_SEC_NAME, 16, 0, 0);
-
- /* Size and populate archdata */
- if (arch_archdata(f, *sec))
- return(1);
- return 0;
-}
-
-
-static int init_module(const char *m_name, struct obj_file *f,
- unsigned long m_size, const char *blob_name,
- unsigned int noload, unsigned int flag_load_map)
-{
- struct module *module;
- struct obj_section *sec;
- void *image;
- int ret = 0;
- tgt_long m_addr;
-
- sec = obj_find_section(f, ".this");
- module = (struct module *) sec->contents;
- m_addr = sec->header.sh_addr;
-
- module->size_of_struct = sizeof(*module);
- module->size = m_size;
- module->flags = flag_autoclean ? NEW_MOD_AUTOCLEAN : 0;
-
- sec = obj_find_section(f, "__ksymtab");
- if (sec && sec->header.sh_size) {
- module->syms = sec->header.sh_addr;
- module->nsyms = sec->header.sh_size / (2 * tgt_sizeof_char_p);
- }
- if (n_ext_modules_used) {
- sec = obj_find_section(f, ".kmodtab");
- module->deps = sec->header.sh_addr;
- module->ndeps = n_ext_modules_used;
- }
- module->init = obj_symbol_final_value(f, obj_find_symbol(f, "init_module"));
- module->cleanup = obj_symbol_final_value(f,
- obj_find_symbol(f, "cleanup_module"));
-
- sec = obj_find_section(f, "__ex_table");
- if (sec) {
- module->ex_table_start = sec->header.sh_addr;
- module->ex_table_end = sec->header.sh_addr + sec->header.sh_size;
- }
- sec = obj_find_section(f, ".text.init");
- if (sec) {
- module->runsize = sec->header.sh_addr - m_addr;
- }
- sec = obj_find_section(f, ".data.init");
- if (sec) {
- if (!module->runsize ||
- module->runsize > sec->header.sh_addr - m_addr)
- module->runsize = sec->header.sh_addr - m_addr;
- }
- sec = obj_find_section(f, ARCHDATA_SEC_NAME);
- if (sec && sec->header.sh_size) {
- module->archdata_start = sec->header.sh_addr;
- module->archdata_end = module->archdata_start + sec->header.sh_size;
- }
- sec = obj_find_section(f, KALLSYMS_SEC_NAME);
- if (sec && sec->header.sh_size) {
- module->kallsyms_start = sec->header.sh_addr;
- module->kallsyms_end = module->kallsyms_start + sec->header.sh_size;
- }
- if (!arch_init_module(f, module))
- return 0;
-
- /*
- * Whew! All of the initialization is complete.
- * Collect the final module image and give it to the kernel.
- */
- image = xmalloc(m_size);
- obj_create_image(f, image);
-
- if (flag_load_map)
- print_load_map(f);
-
- if (blob_name) {
- int fd, l;
- fd = open(blob_name, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
- if (fd < 0) {
- error("open %s failed %m", blob_name);
- ret = -1;
- }
- else {
- if ((l = write(fd, image, m_size)) != m_size) {
- error("write %s failed %m", blob_name);
- ret = -1;
- }
- close(fd);
- }
- }
-
- if (ret == 0 && !noload) {
- fflush(stdout); /* Flush any debugging output */
- ret = sys_init_module(m_name, (struct module *) image);
- if (ret) {
- error("init_module: %m");
- lprintf("Hint: insmod errors can be caused by incorrect module parameters, "
- "including invalid IO or IRQ parameters.\n"
- " You may find more information in syslog or the output from dmesg");
- }
- }
-
- free(image);
-
- return ret == 0;
-}
-
-#ifdef COMPAT_2_0
-static int old_init_module(const char *m_name, struct obj_file *f,
- unsigned long m_size)
-{
- char *image;
- struct old_mod_routines routines;
- struct old_symbol_table *symtab;
- int ret;
- int nsyms = 0, strsize = 0, total;
-
- /* Create the symbol table */
- /* Size things first... */
- if (flag_export) {
- int i;
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
-
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (ELFW(ST_BIND) (sym->info) != STB_LOCAL &&
- sym->secidx <= SHN_HIRESERVE) {
- sym->ksymidx = nsyms++;
- strsize += strlen(sym->name) + 1;
- }
- }
- }
- total = (sizeof(struct old_symbol_table) +
- nsyms * sizeof(struct old_module_symbol) +
- n_ext_modules_used * sizeof(struct old_module_ref) +
- strsize);
- symtab = xmalloc(total);
- symtab->size = total;
- symtab->n_symbols = nsyms;
- symtab->n_refs = n_ext_modules_used;
-
- if (flag_export && nsyms) {
- struct old_module_symbol *ksym;
- char *str;
- int i;
-
- ksym = symtab->symbol;
- str = ((char *) ksym +
- nsyms * sizeof(struct old_module_symbol) +
- n_ext_modules_used * sizeof(struct old_module_ref));
-
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym; sym = sym->next)
- if (sym->ksymidx >= 0) {
- ksym->addr = obj_symbol_final_value(f, sym);
- ksym->name = (unsigned long) str - (unsigned long) symtab;
-
- str = stpcpy(str, sym->name) + 1;
- ksym++;
- }
- }
- }
-
- if (n_ext_modules_used) {
- struct old_module_ref *ref;
- int i;
-
- ref = (struct old_module_ref *)
- ((char *) symtab->symbol + nsyms * sizeof(struct old_module_symbol));
-
- for (i = 0; i < n_module_stat; ++i) {
- if (module_stat[i].status /* used */) {
- ref++->module = module_stat[i].modstruct;
- }
- }
- }
-
- /* Fill in routines. */
-
- routines.init = obj_symbol_final_value(f, obj_find_symbol(f, "init_module"));
- routines.cleanup = obj_symbol_final_value(f,
- obj_find_symbol(f, "cleanup_module"));
-
- /*
- * Whew! All of the initialization is complete.
- * Collect the final module image and give it to the kernel.
- */
- image = xmalloc(m_size);
- obj_create_image(f, image);
-
- /*
- * image holds the complete relocated module,
- * accounting correctly for mod_use_count.
- * However the old module kernel support assume that it
- * is receiving something which does not contain mod_use_count.
- */
- ret = old_sys_init_module(m_name, image + sizeof(long),
- (m_size - sizeof(long)) |
- (flag_autoclean ? OLD_MOD_AUTOCLEAN : 0),
- &routines,
- symtab);
- if (ret)
- error("init_module: %m");
-
- free(image);
- free(symtab);
-
- return ret == 0;
-}
-#endif
-/* end compat */
-/************************************************************************/
-
-/* Check that a module parameter has a reasonable definition */
-static int check_module_parameter(struct obj_file *f, char *key, char *value, int *persist_flag)
-{
- struct obj_symbol *sym;
- int min, max;
- char *p = value;
-
- sym = obj_find_symbol(f, key);
- if (sym == NULL) {
- /* FIXME: For 2.2 kernel compatibility, only issue warnings for
- * most error conditions. Make these all errors in 2.5.
- */
- lprintf("Warning: %s symbol for parameter %s not found", error_file, key);
- ++warnings;
- return(1);
- }
-
- if (isdigit(*p)) {
- min = strtoul(p, &p, 10);
- if (*p == '-')
- max = strtoul(p + 1, &p, 10);
- else
- max = min;
- } else
- min = max = 1;
-
- if (max < min) {
- lprintf("Warning: %s parameter %s has max < min!", error_file, key);
- ++warnings;
- return(1);
- }
-
- switch (*p) {
- case 'c':
- if (!isdigit(p[1])) {
- lprintf("%s parameter %s has no size after 'c'!", error_file, key);
- ++warnings;
- return(1);
- }
- while (isdigit(p[1]))
- ++p; /* swallow c array size */
- break;
- case 'b': /* drop through */
- case 'h': /* drop through */
- case 'i': /* drop through */
- case 'l': /* drop through */
- case 's':
- break;
- case '\0':
- lprintf("%s parameter %s has no format character!", error_file, key);
- ++warnings;
- return(1);
- default:
- lprintf("%s parameter %s has unknown format character '%c'", error_file, key, *p);
- ++warnings;
- return(1);
- }
- switch (*++p) {
- case 'p':
- if (*(p-1) == 's') {
- error("parameter %s is invalid persistent string", key);
- return(1);
- }
- *persist_flag = 1;
- break;
- case '\0':
- break;
- default:
- lprintf("%s parameter %s has unknown format modifier '%c'", error_file, key, *p);
- ++warnings;
- return(1);
- }
- return(0);
-}
-
-/* Check that all module parameters have reasonable definitions */
-static void check_module_parameters(struct obj_file *f, int *persist_flag)
-{
- struct obj_section *sec;
- char *ptr, *value, *n, *endptr;
- int namelen, err = 0;
-
- sec = obj_find_section(f, ".modinfo");
- if (sec == NULL) {
- /* module does not support typed parameters */
- return;
- }
-
- ptr = sec->contents;
- endptr = ptr + sec->header.sh_size;
- while (ptr < endptr && !err) {
- value = strchr(ptr, '=');
- n = strchr(ptr, '\0');
- if (value) {
- namelen = value - ptr;
- if (namelen >= 5 && strncmp(ptr, "parm_", 5) == 0
- && !(namelen > 10 && strncmp(ptr, "parm_desc_", 10) == 0)) {
- char *pname = xmalloc(namelen + 1);
- strncpy(pname, ptr + 5, namelen - 5);
- pname[namelen - 5] = '\0';
- err = check_module_parameter(f, pname, value+1, persist_flag);
- free(pname);
- }
- } else {
- if (n - ptr >= 5 && strncmp(ptr, "parm_", 5) == 0) {
- error("parameter %s found with no value", ptr);
- err = 1;
- }
- }
- ptr = n + 1;
- }
-
- if (err)
- *persist_flag = 0;
- return;
-}
-
-static void set_tainted(struct obj_file *f, int fd, int kernel_has_tainted,
- int noload, int taint,
- const char *text1, const char *text2)
-{
- char buf[80];
- int oldval;
- static int first = 1;
- if (fd < 0 && !kernel_has_tainted)
- return; /* New modutils on old kernel */
- lprintf("Warning: loading %s will taint the kernel: %s%s",
- f->filename, text1, text2);
- ++warnings;
- if (first) {
- lprintf(" See %s for information about tainted modules", TAINT_URL);
- first = 0;
- }
- if (fd >= 0 && !noload) {
- read(fd, buf, sizeof(buf)-1);
- buf[sizeof(buf)-1] = '\0';
- oldval = strtoul(buf, NULL, 10);
- sprintf(buf, "%d\n", oldval | taint);
- write(fd, buf, strlen(buf));
- }
-}
-
-/* Check if loading this module will taint the kernel. */
-static void check_tainted_module(struct obj_file *f, int noload)
-{
- static const char tainted_file[] = TAINT_FILENAME;
- int fd, kernel_has_tainted;
- const char *ptr;
-
- if ((fd = open(tainted_file, O_RDWR)) < 0) {
- if (errno == ENOENT)
- kernel_has_tainted = 0;
- else if (errno == EACCES)
- kernel_has_tainted = 1;
- else {
- perror(tainted_file);
- kernel_has_tainted = 0;
- }
- }
- else
- kernel_has_tainted = 1;
-
- switch (obj_gpl_license(f, &ptr)) {
- case 0:
- break;
- case 1:
- set_tainted(f, fd, kernel_has_tainted, noload, TAINT_PROPRIETORY_MODULE, "no license", "");
- break;
- case 2:
- /* The module has a non-GPL license so we pretend that the
- * kernel always has a taint flag to get a warning even on
- * kernels without the proc flag.
- */
- set_tainted(f, fd, 1, noload, TAINT_PROPRIETORY_MODULE, "non-GPL license - ", ptr);
- break;
- default:
- set_tainted(f, fd, 1, noload, TAINT_PROPRIETORY_MODULE, "Unexpected return from obj_gpl_license", "");
- break;
- }
-
- if (flag_force_load)
- set_tainted(f, fd, 1, noload, TAINT_FORCED_MODULE, "forced load", "");
- if (fd >= 0)
- close(fd);
-}
-
-/* For common 3264 code, only compile the usage message once, in the 64 bit version */
-#if defined(COMMON_3264) && defined(ONLY_32)
-extern void insmod_usage(void); /* Use the copy in the 64 bit version */
-#else /* Common 64 bit version or any non common code - compile usage routine */
-void insmod_usage(void)
-{
- fputs("Usage:\n"
- "insmod [-fhkLmnpqrsSvVxXyYN] [-e persist_name] [-o module_name] [-O blob_name] [-P prefix] module [ symbol=value ... ]\n"
- "\n"
- " module Name of a loadable kernel module ('.o' can be omitted)\n"
- " -f, --force Force loading under wrong kernel version\n"
- " -h, --help Print this message\n"
- " -k, --autoclean Make module autoclean-able\n"
- " -L, --lock Prevent simultaneous loads of the same module\n"
- " -m, --map Generate load map (so crashes can be traced)\n"
- " -n, --noload Don't load, just show\n"
- " -p, --probe Probe mode; check if the module matches the kernel\n"
- " -q, --quiet Don't print unresolved symbols\n"
- " -r, --root Allow root to load modules not owned by root\n"
- " -s, --syslog Report errors via syslog\n"
- " -S, --kallsyms Force kallsyms on module\n"
- " -v, --verbose Verbose output\n"
- " -V, --version Show version\n"
- " -x, --noexport Do not export externs\n"
- " -X, --export Do export externs (default)\n"
- " -y, --noksymoops Do not add ksymoops symbols\n"
- " -Y, --ksymoops Do add ksymoops symbols (default)\n"
- " -N, --numeric-only Only check the numeric part of the kernel version\n"
- " -e persist_name\n"
- " --persist=persist_name Filename to hold any persistent data from the module\n"
- " -o NAME, --name=NAME Set internal module name to NAME\n"
- " -O NAME, --blob=NAME Save the object as a binary blob in NAME\n"
- " -P PREFIX\n"
- " --prefix=PREFIX Prefix for kernel or module symbols\n"
- ,stderr);
- exit(1);
-}
-#endif /* defined(COMMON_3264) && defined(ONLY_32) */
-
-#if defined(COMMON_3264) && defined(ONLY_32)
-#define INSMOD_MAIN insmod_main_32 /* 32 bit version */
-#elif defined(COMMON_3264) && defined(ONLY_64)
-#define INSMOD_MAIN insmod_main_64 /* 64 bit version */
-#else
-#define INSMOD_MAIN insmod_main /* Not common code */
-#endif
-
-int INSMOD_MAIN(int argc, char **argv)
-{
- int k_version;
- int k_crcs;
- char k_strversion[STRVERSIONLEN];
- struct option long_opts[] = {
- {"force", 0, 0, 'f'},
- {"help", 0, 0, 'h'},
- {"autoclean", 0, 0, 'k'},
- {"lock", 0, 0, 'L'},
- {"map", 0, 0, 'm'},
- {"noload", 0, 0, 'n'},
- {"probe", 0, 0, 'p'},
- {"poll", 0, 0, 'p'}, /* poll is deprecated, remove in 2.5 */
- {"quiet", 0, 0, 'q'},
- {"root", 0, 0, 'r'},
- {"syslog", 0, 0, 's'},
- {"kallsyms", 0, 0, 'S'},
- {"verbose", 0, 0, 'v'},
- {"version", 0, 0, 'V'},
- {"noexport", 0, 0, 'x'},
- {"export", 0, 0, 'X'},
- {"noksymoops", 0, 0, 'y'},
- {"ksymoops", 0, 0, 'Y'},
- {"persist", 1, 0, 'e'},
- {"numeric-only", 1, 0, 'N'},
- {"name", 1, 0, 'o'},
- {"blob", 1, 0, 'O'},
- {"prefix", 1, 0, 'P'},
- {0, 0, 0, 0}
- };
- char *m_name = NULL;
- char *blob_name = NULL; /* Save object as binary blob */
- int m_version;
- ElfW(Addr) m_addr;
- unsigned long m_size;
- int m_crcs;
- char m_strversion[STRVERSIONLEN];
- char *filename;
- char *persist_name = NULL; /* filename to hold any persistent data */
- int fp;
- struct obj_file *f;
- struct obj_section *kallsyms = NULL, *archdata = NULL;
- int o;
- int noload = 0;
- int dolock = 1; /*Note: was: 0; */
- int quiet = 0;
- int exit_status = 1;
- int force_kallsyms = 0;
- int persist_parms = 0; /* does module have persistent parms? */
- int i;
- int gpl;
-
- error_file = "insmod";
-
- /* To handle repeated calls from combined modprobe */
- errors = optind = 0;
-
- /* Process the command line. */
- while ((o = getopt_long(argc, argv, "fhkLmnpqrsSvVxXyYNe:o:O:P:R:",
- &long_opts[0], NULL)) != EOF)
- switch (o) {
- case 'f': /* force loading */
- flag_force_load = 1;
- break;
- case 'h': /* Print the usage message. */
- insmod_usage();
- break;
- case 'k': /* module loaded by kerneld, auto-cleanable */
- flag_autoclean = 1;
- break;
- case 'L': /* protect against recursion. */
- dolock = 1;
- break;
- case 'm': /* generate load map */
- flag_load_map = 1;
- break;
- case 'n': /* don't load, just check */
- noload = 1;
- break;
- case 'p': /* silent probe mode */
- flag_silent_probe = 1;
- break;
- case 'q': /* Don't print unresolved symbols */
- quiet = 1;
- break;
- case 'r': /* allow root to load non-root modules */
- root_check_off = !root_check_off;
- break;
- case 's': /* start syslog */
- setsyslog("insmod");
- break;
- case 'S': /* Force kallsyms */
- force_kallsyms = 1;
- break;
- case 'v': /* verbose output */
- flag_verbose = 1;
- break;
- case 'V':
- fputs("insmod version " MODUTILS_VERSION "\n", stderr);
- break;
- case 'x': /* do not export externs */
- flag_export = 0;
- break;
- case 'X': /* do export externs */
- flag_export = 1;
- break;
- case 'y': /* do not define ksymoops symbols */
- flag_ksymoops = 0;
- break;
- case 'Y': /* do define ksymoops symbols */
- flag_ksymoops = 1;
- break;
- case 'N': /* only check numeric part of kernel version */
- flag_numeric_only = 1;
- break;
-
- case 'e': /* persistent data filename */
- free(persist_name);
- persist_name = xstrdup(optarg);
- break;
- case 'o': /* name the output module */
- m_name = optarg;
- break;
- case 'O': /* save the output module object */
- blob_name = optarg;
- break;
- case 'P': /* use prefix on crc */
- set_ncv_prefix(optarg);
- break;
-
- default:
- insmod_usage();
- break;
- }
-
- if (optind >= argc) {
- insmod_usage();
- }
- filename = argv[optind++];
-
- if (config_read(0, NULL, "", NULL) < 0) {
- error("Failed handle configuration");
- }
-
- if (persist_name && !*persist_name &&
- (!persistdir || !*persistdir)) {
- free(persist_name);
- persist_name = NULL;
- if (flag_verbose) {
- lprintf("insmod: -e \"\" ignored, no persistdir");
- ++warnings;
- }
- }
-
- if (m_name == NULL) {
- size_t len;
- char *p;
-
- if ((p = strrchr(filename, '/')) != NULL)
- p++;
- else
- p = filename;
- len = strlen(p);
- if (len > 2 && p[len - 2] == '.' && p[len - 1] == 'o')
- len -= 2;
- else if (len > 4 && p[len - 4] == '.' && p[len - 3] == 'm'
- && p[len - 2] == 'o' && p[len - 1] == 'd')
- len -= 4;
-#ifdef CONFIG_USE_ZLIB
- else if (len > 5 && !strcmp(p + len - 5, ".o.gz"))
- len -= 5;
-#endif
-
- m_name = xmalloc(len + 1);
- memcpy(m_name, p, len);
- m_name[len] = '\0';
- }
-
- /* Locate the file to be loaded. */
- if (!strchr(filename, '/') && !strchr(filename, '.')) {
- char *tmp = search_module_path(filename);
- if (tmp == NULL) {
- error("%s: no module by that name found", filename);
- return 1;
- }
- filename = tmp;
- lprintf("Using %s", filename);
- } else if (flag_verbose)
- lprintf("Using %s", filename);
-
- /* And open it. */
- if ((fp = gzf_open(filename, O_RDONLY)) == -1) {
- error("%s: %m", filename);
- return 1;
- }
- /* Try to prevent multiple simultaneous loads. */
- if (dolock)
- flock(fp, LOCK_EX);
-
- if (!get_kernel_info(K_SYMBOLS))
- goto out;
-
- /*
- * Set the genksyms prefix if this is a versioned kernel
- * and it's not already set.
- */
- set_ncv_prefix(NULL);
-
- for (i = 0; !noload && i < n_module_stat; ++i) {
- if (strcmp(module_stat[i].name, m_name) == 0) {
- error("a module named %s already exists", m_name);
- goto out;
- }
- }
-
- error_file = filename;
- if ((f = obj_load(fp, ET_REL, filename)) == NULL)
- goto out;
-
- /* Version correspondence? */
- k_version = get_kernel_version(k_strversion);
- m_version = get_module_version(f, m_strversion);
- if (m_version == -1) {
- error("couldn't find the kernel version the module was compiled for");
- goto out;
- }
-
- k_crcs = is_kernel_checksummed();
- m_crcs = is_module_checksummed(f);
- if ((m_crcs == 0 || k_crcs == 0) &&
- strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
- if (flag_force_load) {
- lprintf("Warning: kernel-module version mismatch\n"
- "\t%s was compiled for kernel version %s\n"
- "\twhile this kernel is version %s",
- filename, m_strversion, k_strversion);
- ++warnings;
- } else {
- if (!quiet)
- error("kernel-module version mismatch\n"
- "\t%s was compiled for kernel version %s\n"
- "\twhile this kernel is version %s.",
- filename, m_strversion, k_strversion);
- goto out;
- }
- }
- if (m_crcs != k_crcs)
- obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
-
- /* Let the module know about the kernel symbols. */
- gpl = obj_gpl_license(f, NULL) == 0;
- add_kernel_symbols(f, gpl);
-
-#ifdef ARCH_ppc64
- if (!ppc64_process_syms (f))
- goto out;
-#endif
-
- /* Allocate common symbols, symbol tables, and string tables.
- *
- * The calls marked DEPMOD indicate the bits of code that depmod
- * uses to do a pseudo relocation, ignoring undefined symbols.
- * Any changes made to the relocation sequence here should be
- * checked against depmod.
- */
-#ifdef COMPAT_2_0
- if (k_new_syscalls
- ? !create_this_module(f, m_name)
- : !old_create_mod_use_count(f))
- goto out;
-#else
- if (!create_this_module(f, m_name))
- goto out;
-#endif
-
- arch_create_got(f); /* DEPMOD */
- if (!obj_check_undefineds(f, quiet)) { /* DEPMOD, obj_clear_undefineds */
- if (!gpl && !quiet) {
- if (gplonly_seen)
- error("\n"
- "Hint: You are trying to load a module without a GPL compatible license\n"
- " and it has unresolved symbols. The module may be trying to access\n"
- " GPLONLY symbols but the problem is more likely to be a coding or\n"
- " user error. Contact the module supplier for assistance, only they\n"
- " can help you.\n");
- else
- error("\n"
- "Hint: You are trying to load a module without a GPL compatible license\n"
- " and it has unresolved symbols. Contact the module supplier for\n"
- " assistance, only they can help you.\n");
- }
- goto out;
- }
- obj_allocate_commons(f); /* DEPMOD */
-
- check_module_parameters(f, &persist_parms);
- check_tainted_module(f, noload);
-
- if (optind < argc) {
- if (!process_module_arguments(f, argc - optind, argv + optind, 1))
- goto out;
- }
- hide_special_symbols(f);
-
- if (persist_parms && persist_name && *persist_name) {
- f->persist = persist_name;
- persist_name = NULL;
- }
-
- if (persist_parms &&
- persist_name && !*persist_name) {
- /* -e "". This is ugly. Take the filename, compare it against
- * each of the module paths until we find a match on the start
- * of the filename, assume the rest is the relative path. Have
- * to do it this way because modprobe uses absolute filenames
- * for module names in modules.dep and the format of modules.dep
- * does not allow for any backwards compatible changes, so there
- * is nowhere to store the relative filename. The only way this
- * should fail to calculate a relative path is "insmod ./xxx", for
- * that case the user has to specify -e filename.
- */
- int j, l = strlen(filename);
- char *relative = NULL;
- char *p;
- for (i = 0; i < nmodpath; ++i) {
- p = modpath[i].path;
- j = strlen(p);
- while (j && p[j] == '/')
- --j;
- if (j < l && strncmp(filename, p, j) == 0 && filename[j] == '/') {
- while (filename[j] == '/')
- ++j;
- relative = xstrdup(filename+j);
- break;
- }
- }
- if (relative) {
- i = strlen(relative);
- if (i > 3 && strcmp(relative+i-3, ".gz") == 0)
- relative[i -= 3] = '\0';
- if (i > 2 && strcmp(relative+i-2, ".o") == 0)
- relative[i -= 2] = '\0';
- else if (i > 4 && strcmp(relative+i-4, ".mod") == 0)
- relative[i -= 4] = '\0';
- f->persist = xmalloc(strlen(persistdir) + 1 + i + 1);
- strcpy(f->persist, persistdir); /* safe, xmalloc */
- strcat(f->persist, "/"); /* safe, xmalloc */
- strcat(f->persist, relative); /* safe, xmalloc */
- free(relative);
- }
- else
- error("Cannot calculate persistent filename");
- }
-
- if (f->persist && *(f->persist) != '/') {
- error("Persistent filenames must be absolute, ignoring '%s'",
- f->persist);
- free(f->persist);
- f->persist = NULL;
- }
-
- if (f->persist && !flag_ksymoops) {
- error("has persistent data but ksymoops symbols are not available");
- free(f->persist);
- f->persist = NULL;
- }
-
- if (f->persist && !k_new_syscalls) {
- error("has persistent data but the kernel is too old to support it");
- free(f->persist);
- f->persist = NULL;
- }
-
- if (persist_parms && flag_verbose) {
- if (f->persist)
- lprintf("Persist filename '%s'", f->persist);
- else
- lprintf("No persistent filename available");
- }
-
- if (f->persist) {
- FILE *fp = fopen(f->persist, "r");
- if (!fp) {
- if (flag_verbose)
- lprintf("Cannot open persist file '%s' %m", f->persist);
- }
- else {
- int pargc = 0;
- char *pargv[1000]; /* hard coded but big enough */
- char line[3000]; /* hard coded but big enough */
- char *p;
- while (fgets(line, sizeof(line), fp)) {
- p = strchr(line, '\n');
- if (!p) {
- error("Persistent data line is too long\n%s", line);
- break;
- }
- *p = '\0';
- p = line;
- while (isspace(*p))
- ++p;
- if (!*p || *p == '#')
- continue;
- if (pargc == sizeof(pargv)/sizeof(pargv[0])) {
- error("More than %d persistent parameters", pargc);
- break;
- }
- pargv[pargc++] = xstrdup(p);
- }
- fclose(fp);
- if (!process_module_arguments(f, pargc, pargv, 0))
- goto out;
- while (pargc--)
- free(pargv[pargc]);
- }
- }
-
- if (flag_ksymoops)
- add_ksymoops_symbols(f, filename, m_name);
-
- if (k_new_syscalls)
- create_module_ksymtab(f);
-
- /* archdata based on relocatable addresses */
- if (add_archdata(f, &archdata))
- goto out;
-
- /* kallsyms based on relocatable addresses */
- if (add_kallsyms(f, &kallsyms, force_kallsyms))
- goto out;
- /**** No symbols or sections to be changed after kallsyms above ***/
-
- if (errors)
- goto out;
-
- /* If we were just checking, we made it. */
- if (flag_silent_probe) {
- exit_status = 0;
- goto out;
- }
- /* Module has now finished growing; find its size and install it. */
- m_size = obj_load_size(f); /* DEPMOD */
-
- if (noload) {
- /* Don't bother actually touching the kernel. */
- m_addr = 0x12340000;
- } else {
- errno = 0;
- m_addr = create_module(m_name, m_size);
-#ifdef ARCH_ppc64
- m_addr |= ppc64_module_base (f);
-#endif
- switch (errno) {
- case 0:
- break;
- case EEXIST:
- if (dolock) {
- /*
- * Assume that we were just invoked
- * simultaneous with another insmod
- * and return success.
- */
- exit_status = 0;
- goto out;
- }
- error("a module named %s already exists", m_name);
- goto out;
- case ENOMEM:
- error("can't allocate kernel memory for module; needed %lu bytes",
- m_size);
- goto out;
- default:
- error("create_module: %m");
- goto out;
- }
- }
-
- /* module is already built, complete with ksymoops symbols for the
- * persistent filename. If the kernel does not support persistent data
- * then give an error but continue. It is too difficult to clean up at
- * this stage and this error will only occur on backported modules.
- * rmmod will also get an error so warn the user now.
- */
- if (f->persist && !noload) {
- struct {
- struct module m;
- int data;
- } test_read;
- memset(&test_read, 0, sizeof(test_read));
- test_read.m.size_of_struct = -sizeof(test_read.m); /* -ve size => read, not write */
- test_read.m.read_start = m_addr + sizeof(struct module);
- test_read.m.read_end = test_read.m.read_start + sizeof(test_read.data);
- if (sys_init_module(m_name, (struct module *) &test_read)) {
- int old_errors = errors;
- error("has persistent data but the kernel is too old to support it."
- " Expect errors during rmmod as well");
- errors = old_errors;
- }
- }
-
- if (!obj_relocate(f, m_addr)) { /* DEPMOD */
- if (!noload)
- delete_module(m_name);
- goto out;
- }
-
- /* Do archdata again, this time we have the final addresses */
- if (add_archdata(f, &archdata))
- goto out;
-
- /* Do kallsyms again, this time we have the final addresses */
- if (add_kallsyms(f, &kallsyms, force_kallsyms))
- goto out;
-
-#ifdef COMPAT_2_0
- if (k_new_syscalls)
- init_module(m_name, f, m_size, blob_name, noload, flag_load_map);
- else if (!noload)
- old_init_module(m_name, f, m_size);
-#else
- init_module(m_name, f, m_size, blob_name, noload, flag_load_map);
-#endif
- if (errors) {
- if (!noload)
- delete_module(m_name);
- goto out;
- }
- if (warnings && !noload)
- lprintf("Module %s loaded, with warnings", m_name);
- exit_status = 0;
-
- out:
- if (dolock)
- flock(fp, LOCK_UN);
- close(fp);
- if (!noload)
- snap_shot(NULL, 0);
-
- return exit_status;
-}
-
-/* For common 3264 code, add an overall insmod_main, in the 64 bit version. */
-#if defined(COMMON_3264) && defined(ONLY_64)
-int insmod_main(int argc, char **argv)
-{
- if (arch64())
- return insmod_main_64(argc, argv);
- else
- return insmod_main_32(argc, argv);
-}
-#endif /* defined(COMMON_3264) && defined(ONLY_64) */
-
-
-int insmod_call(char * full_filename, char * params)
-{
- int argc = 2;
- char *argv[50];
- char * ptr = params;
- argv[0] = "stage1";
- argv[1] = full_filename;
-
- while (ptr != NULL) {
- argv[argc] = ptr;
- argc++;
- ptr = strchr(ptr, ' ');
- if (ptr) {
- ptr[0] = '\0';
- ptr++;
- }
- }
-
- return insmod_main(argc, argv);
-}
diff --git a/mdk-stage1/insmod-modutils/obj/Makefile b/mdk-stage1/insmod-modutils/obj/Makefile
deleted file mode 100644
index d44b2a6c6..000000000
--- a/mdk-stage1/insmod-modutils/obj/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
- #******************************************************************************
- #
- # insmod from modutils (generic)
- #
- # $Id$
- #
- # Copyright 1996, 1997 Linux International.
- #
- #*****************************************************************************
-
-top_dir = ../..
-
-include $(top_dir)/Makefile.common
-
-
-all: libobj.a
-
-clean:
- rm -f *.o *.a
-
-
-INCS = -I./../include
-
-DEFS = -D_GNU_SOURCE -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) -DCONFIG_ROOT_CHECK_OFF=0
-
-ifeq (x86_64, $(ARCH))
-DEFS += -Wno-error
-endif
-
-OBJS = obj_kallsyms.o obj_common.o obj_load.o obj_reloc.o obj_$(ARCH).o \
- obj_gpl_license.o
-
-libobj.a: $(OBJS)
- ar cru $@ $^
- ranlib $@
-
-%.o: %.c
- $(DIET) gcc $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -c $<
diff --git a/mdk-stage1/insmod-modutils/obj/obj_alpha.c b/mdk-stage1/insmod-modutils/obj/obj_alpha.c
deleted file mode 100644
index 175012716..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_alpha.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/* Alpha specific support for Elf loading and relocation.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h>
-#include <assert.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/* This relocation got renamed, and the change hasn't propagated yet. */
-#ifndef R_ALPHA_GPREL16
-#define R_ALPHA_GPREL16 R_ALPHA_IMMED_GP_16
-#endif
-
-/*======================================================================*/
-
-struct alpha_got_entry
-{
- struct alpha_got_entry *next;
- ElfW(Addr) addend;
- int offset;
- int reloc_done;
-};
-
-struct alpha_file
-{
- struct obj_file root;
- struct obj_section *got;
-};
-
-struct alpha_symbol
-{
- struct obj_symbol root;
- struct alpha_got_entry *got_entries;
-};
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- struct alpha_file *f;
- f = xmalloc(sizeof(*f));
- f->got = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- struct alpha_symbol *sym;
- sym = xmalloc(sizeof(*sym));
- sym->got_entries = NULL;
- return &sym->root;
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf64_Rela *rel,
- Elf64_Addr v)
-{
- struct alpha_file *af = (struct alpha_file *)f;
- struct alpha_symbol *asym = (struct alpha_symbol *)sym;
-
- unsigned long *lloc = (unsigned long *)(targsec->contents + rel->r_offset);
- unsigned int *iloc = (unsigned int *)lloc;
- unsigned short *sloc = (unsigned short *)lloc;
- Elf64_Addr dot = targsec->header.sh_addr + rel->r_offset;
- Elf64_Addr gp = af->got->header.sh_addr + 0x8000;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF64_R_TYPE(rel->r_info))
- {
- case R_ALPHA_NONE:
- case R_ALPHA_LITUSE:
- break;
-
- case R_ALPHA_REFQUAD:
- *lloc += v;
- break;
-
- case R_ALPHA_GPREL16:
- v -= gp;
- if ((Elf64_Sxword)v > 0x7fff
- || (Elf64_Sxword)v < -(Elf64_Sxword)0x8000)
- ret = obj_reloc_overflow;
- *sloc = v;
- break;
-
- case R_ALPHA_GPRELLOW:
- /* GPRELLOW does not overflow. Errors are seen in the
- corresponding GPRELHIGH. */
- v -= gp;
- *sloc = v;
- break;
-
- case R_ALPHA_GPRELHIGH:
- v -= gp;
- v = ((Elf64_Sxword)v >> 16) + ((v >> 15) & 1);
- if ((Elf64_Sxword)v > 0x7fff
- || (Elf64_Sxword)v < -(Elf64_Sxword)0x8000)
- ret = obj_reloc_overflow;
- *sloc = v;
- break;
-
- case R_ALPHA_GPREL32:
- v -= gp;
- if ((Elf64_Sxword)v > 0x7fffffff
- || (Elf64_Sxword)v < -(Elf64_Sxword)0x80000000)
- ret = obj_reloc_overflow;
- *iloc = v;
- break;
-
- case R_ALPHA_LITERAL:
- {
- struct alpha_got_entry *gotent;
-
- assert(asym != NULL);
- gotent = asym->got_entries;
- while (gotent->addend != rel->r_addend)
- gotent = gotent->next;
-
- if (!gotent->reloc_done)
- {
- *(unsigned long *)(af->got->contents + gotent->offset) = v;
- gotent->reloc_done = 1;
- }
-
- *sloc = gotent->offset - 0x8000;
- }
- break;
-
- case R_ALPHA_GPDISP:
- {
- unsigned int *p_ldah, *p_lda;
- unsigned int i_ldah, i_lda, hi, lo;
-
- p_ldah = iloc;
- p_lda = (unsigned int *)((char *)iloc + rel->r_addend);
- i_ldah = *p_ldah;
- i_lda = *p_lda;
-
- /* Make sure the instructions are righteous. */
- if ((i_ldah >> 26) != 9 || (i_lda >> 26) != 8)
- ret = obj_reloc_dangerous;
-
- /* Extract the existing addend. */
- v = (i_ldah & 0xffff) << 16 | (i_lda & 0xffff);
- v = (v ^ 0x80008000) - 0x80008000;
-
- v += gp - dot;
-
- if ((Elf64_Sxword)v >= 0x7fff8000
- || (Elf64_Sxword)v < -(Elf64_Sxword)0x80000000)
- ret = obj_reloc_overflow;
-
- /* Modify the instructions and finish up. */
- lo = v & 0xffff;
- hi = ((v >> 16) + ((v >> 15) & 1)) & 0xffff;
-
- *p_ldah = (i_ldah & 0xffff0000) | hi;
- *p_lda = (i_lda & 0xffff0000) | lo;
- }
- break;
-
- case R_ALPHA_BRADDR:
- v -= dot + 4;
- if (v % 4)
- ret = obj_reloc_dangerous;
- else if ((Elf64_Sxword)v > 0x3fffff
- || (Elf64_Sxword)v < -(Elf64_Sxword)0x400000)
- ret = obj_reloc_overflow;
- v /= 4;
-
- *iloc = (*iloc & ~0x1fffff) | (v & 0x1fffff);
- break;
-
- case R_ALPHA_HINT:
- v -= dot + 4;
- if (v % 4)
- ret = obj_reloc_dangerous;
- v /= 4;
-
- *iloc = (*iloc & ~0x3fff) | (v & 0x3fff);
- break;
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *f)
-{
- struct alpha_file *af = (struct alpha_file *)f;
- int i, n, offset = 0;
-
- n = af->root.header.e_shnum;
- for (i = 0; i < n; ++i)
- {
- struct obj_section *relsec, *symsec, *strsec;
- Elf64_Rela *rel, *relend;
- Elf64_Sym *symtab;
- const char *strtab;
-
- relsec = af->root.sections[i];
- if (relsec->header.sh_type != SHT_RELA)
- continue;
-
- symsec = af->root.sections[relsec->header.sh_link];
- strsec = af->root.sections[symsec->header.sh_link];
-
- rel = (Elf64_Rela *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(Elf64_Rela));
- symtab = (Elf64_Sym *)symsec->contents;
- strtab = (const char *)strsec->contents;
-
- for (; rel < relend; ++rel)
- {
- struct alpha_got_entry *ent;
- struct alpha_symbol *intsym;
-
- if (ELF64_R_TYPE(rel->r_info) != R_ALPHA_LITERAL)
- continue;
-
- obj_find_relsym(intsym, f, &af->root, rel, symtab, strtab);
-
- for (ent = intsym->got_entries; ent ; ent = ent->next)
- if (ent->addend == rel->r_addend)
- goto found;
-
- ent = xmalloc(sizeof(*ent));
- ent->addend = rel->r_addend;
- ent->offset = offset;
- ent->reloc_done = 0;
- ent->next = intsym->got_entries;
- intsym->got_entries = ent;
- offset += 8;
-
- found:;
- }
- }
-
- if (offset > 0x10000)
- {
- error(".got section overflow: %#x > 0x10000", offset);
- return 0;
- }
-
- /* We always want a .got section so that we always have a GP for
- use with GPDISP and GPREL relocs. Besides, if the section
- is empty we don't use up space anyway. */
- af->got = obj_create_alloced_section(&af->root, ".got", 8, offset,
- SHF_WRITE | SHF_ALPHA_GPREL);
-
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- struct alpha_file *af = (struct alpha_file *)f;
-
- mod->gp = af->got->header.sh_addr + 0x8000;
-
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf64_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_arm.c b/mdk-stage1/insmod-modutils/obj/obj_arm.c
deleted file mode 100644
index 78b53700c..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_arm.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* ARM specific support for Elf loading and relocation.
- Copyright 1996, 1997, 1998 Linux International.
-
- Contributed by Phil Blundell <philb@gnu.org>
- and wms <woody@corelcomputer.com>
- based on the i386 code by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h>
-#include <assert.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct arm_plt_entry
-{
- int offset;
- int allocated:1;
- int inited:1; // has been set up
-};
-
-struct arm_got_entry
-{
- int offset;
- int allocated : 1;
- unsigned reloc_done : 1;
-};
-
-struct arm_file
-{
- struct obj_file root;
- struct obj_section *plt;
- struct obj_section *got;
-};
-
-struct arm_symbol
-{
- struct obj_symbol root;
- struct arm_plt_entry pltent;
- struct arm_got_entry gotent;
-};
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- struct arm_file *f;
- f = xmalloc(sizeof(*f));
- f->got = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- struct arm_symbol *sym;
- sym = xmalloc(sizeof(*sym));
- memset(&sym->gotent, 0, sizeof(sym->gotent));
- memset(&sym->pltent, 0, sizeof(sym->pltent));
- return &sym->root;
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rel *rel,
- Elf32_Addr v)
-{
- struct arm_file *afile = (struct arm_file *)f;
- struct arm_symbol *asym = (struct arm_symbol *)sym;
-
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
- Elf32_Addr got = afile->got ? afile->got->header.sh_addr : 0;
- Elf32_Addr plt = afile->plt ? afile->plt->header.sh_addr : 0;
-
- struct arm_plt_entry *pe;
- unsigned long *ip;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_ARM_NONE:
- break;
-
- case R_ARM_ABS32:
- *loc += v;
- break;
-
- case R_ARM_GOT32:
- /* needs an entry in the .got: set it, once */
- if (! asym->gotent.reloc_done)
- {
- asym->gotent.reloc_done = 1;
- *(Elf32_Addr *)(afile->got->contents + asym->gotent.offset) = v;
- }
- /* make the reloc with_respect_to_.got */
- *loc += asym->gotent.offset;
- break;
-
- /* relative reloc, always to _GLOBAL_OFFSET_TABLE_ (which is .got)
- similar to branch, but is full 32 bits relative */
- case R_ARM_GOTPC:
- assert(got);
- *loc += got - dot;
- break;
-
- case R_ARM_PC24:
- case R_ARM_PLT32:
- /* find the plt entry and initialize it if necessary */
- assert(asym != NULL);
- pe = (struct arm_plt_entry*) &asym->pltent;
- if (! pe->inited)
- {
- ip = (unsigned long *) (afile->plt->contents + pe->offset);
- ip[0] = 0xe51ff004; /* ldr pc,[pc,#-4] */
- ip[1] = v; /* sym@ */
- pe->inited = 1;
- }
-
- /* relative distance to target */
- v -= dot;
- /* if the target is too far away.... */
- if ((int)v < -0x02000000 || (int)v >= 0x02000000)
- {
- /* go via the plt */
- v = plt + pe->offset - dot;
- }
- if (v & 3)
- ret = obj_reloc_dangerous;
-
- /* Convert to words. */
- v >>= 2;
-
- /* merge the offset into the instruction. */
- *loc = (*loc & ~0x00ffffff) | ((v + *loc) & 0x00ffffff);
- break;
-
- /* address relative to the got */
- case R_ARM_GOTOFF:
- assert(got);
- *loc += v - got;
- break;
-
- default:
- printf("Warning: unhandled reloc %d\n",ELF32_R_TYPE(rel->r_info));
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *f)
-{
- struct arm_file *afile = (struct arm_file *) f;
- int i;
- struct obj_section *sec, *syms, *strs;
- ElfW(Rel) *rel, *relend;
- ElfW(Sym) *symtab, *extsym;
- const char *strtab;
- struct arm_symbol *intsym;
- struct arm_plt_entry *pe;
- struct arm_got_entry *ge;
- int got_offset = 0, plt_offset = 0;
-
- for (i = 0; i < f->header.e_shnum; ++i)
- {
- sec = f->sections[i];
- if (sec->header.sh_type != SHT_RELM)
- continue;
- syms = f->sections[sec->header.sh_link];
- strs = f->sections[syms->header.sh_link];
-
- rel = (ElfW(RelM) *) sec->contents;
- relend = rel + (sec->header.sh_size / sizeof(ElfW(RelM)));
- symtab = (ElfW(Sym) *) syms->contents;
- strtab = (const char *) strs->contents;
-
- for (; rel < relend; ++rel)
- {
- extsym = &symtab[ELF32_R_SYM(rel->r_info)];
-
- switch(ELF32_R_TYPE(rel->r_info)) {
- case R_ARM_PC24:
- case R_ARM_PLT32:
- obj_find_relsym(intsym, f, f, rel, symtab, strtab);
-
- pe = &intsym->pltent;
-
- if (! pe->allocated)
- {
- pe->allocated = 1;
- pe->offset = plt_offset;
- plt_offset += 8;
- pe->inited = 0;
- }
- break;
-
- /* these two don_t need got entries, but they need
- the .got to exist */
- case R_ARM_GOTOFF:
- case R_ARM_GOTPC:
- if (got_offset==0) got_offset = 4;
- break;
-
- case R_ARM_GOT32:
- obj_find_relsym(intsym, f, f, rel, symtab, strtab);
-
- ge = (struct arm_got_entry *) &intsym->gotent;
- if (! ge->allocated)
- {
- ge->allocated = 1;
- ge->offset = got_offset;
- got_offset += sizeof(void*);
- }
- break;
-
- default:
- continue;
- }
- }
- }
-
- /* if there was a _GLOBAL_OFFSET_TABLE_, then the .got section
- exists already; find it and use it */
- if (got_offset)
- {
- struct obj_section* sec = obj_find_section(f, ".got");
- if (sec)
- obj_extend_section(sec, got_offset);
- else
- {
- sec = obj_create_alloced_section(f, ".got", 8, got_offset,
- SHF_WRITE);
- assert(sec);
- }
- afile->got = sec;
- }
-
- if (plt_offset)
- afile->plt = obj_create_alloced_section(f, ".plt", 8, plt_offset,
- SHF_WRITE);
-
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_common.c b/mdk-stage1/insmod-modutils/obj/obj_common.c
deleted file mode 100644
index a957ff1be..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_common.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/* Elf file, section, and symbol manipulation routines.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <alloca.h>
-
-#include <obj.h>
-#include <util.h>
-#include <module.h>
-
-/*======================================================================*/
-
-/* Standard ELF hash function. */
-inline unsigned long
-obj_elf_hash_n(const char *name, unsigned long n)
-{
- unsigned long h = 0;
- unsigned long g;
- unsigned char ch;
-
- while (n > 0)
- {
- ch = *name++;
- h = (h << 4) + ch;
- if ((g = (h & 0xf0000000)) != 0)
- {
- h ^= g >> 24;
- h &= ~g;
- }
- n--;
- }
- return h;
-}
-
-unsigned long
-obj_elf_hash (const char *name)
-{
- return obj_elf_hash_n(name, strlen(name));
-}
-
-void
-obj_set_symbol_compare (struct obj_file *f,
- int (*cmp)(const char *, const char *),
- unsigned long (*hash)(const char *))
-{
- if (cmp)
- f->symbol_cmp = cmp;
- if (hash)
- {
- struct obj_symbol *tmptab[HASH_BUCKETS], *sym, *next;
- int i;
-
- f->symbol_hash = hash;
-
- memcpy(tmptab, f->symtab, sizeof(tmptab));
- memset(f->symtab, 0, sizeof(f->symtab));
-
- for (i = 0; i < HASH_BUCKETS; ++i)
- for (sym = tmptab[i]; sym ; sym = next)
- {
- unsigned long h = hash(sym->name) % HASH_BUCKETS;
- next = sym->next;
- sym->next = f->symtab[h];
- f->symtab[h] = sym;
- }
- }
-}
-
-struct obj_symbol *
-obj_add_symbol (struct obj_file *f, const char *name, unsigned long symidx,
- int info, int secidx, ElfW(Addr) value, unsigned long size)
-{
- struct obj_symbol *sym;
- unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
- int n_type = ELFW(ST_TYPE)(info);
- int n_binding = ELFW(ST_BIND)(info);
-
- for (sym = f->symtab[hash]; sym; sym = sym->next)
- if (f->symbol_cmp(sym->name, name) == 0)
- {
- int o_secidx = sym->secidx;
- int o_info = sym->info;
- int o_type = ELFW(ST_TYPE)(o_info);
- int o_binding = ELFW(ST_BIND)(o_info);
-
- /* A redefinition! Is it legal? */
-
- if (secidx == SHN_UNDEF)
- return sym;
- else if (o_secidx == SHN_UNDEF)
- goto found;
- else if (n_binding == STB_GLOBAL && o_binding == STB_LOCAL)
- {
- /* Cope with local and global symbols of the same name
- in the same object file, as might have been created
- by ld -r. The only reason locals are now seen at this
- level at all is so that we can do semi-sensible things
- with parameters. */
-
- struct obj_symbol *nsym, **p;
-
- nsym = arch_new_symbol();
- nsym->next = sym->next;
- nsym->ksymidx = -1;
-
- /* Excise the old (local) symbol from the hash chain. */
- for (p = &f->symtab[hash]; *p != sym; p = &(*p)->next)
- continue;
- *p = sym = nsym;
- goto found;
- }
- else if (n_binding == STB_LOCAL)
- {
- /* Another symbol of the same name has already been defined.
- Just add this to the local table. */
- sym = arch_new_symbol();
- sym->next = NULL;
- sym->ksymidx = -1;
- f->local_symtab[symidx] = sym;
- goto found;
- }
- else if (n_binding == STB_WEAK)
- return sym;
- else if (o_binding == STB_WEAK)
- goto found;
- /* Don't unify COMMON symbols with object types the programmer
- doesn't expect. */
- else if (secidx == SHN_COMMON
- && (o_type == STT_NOTYPE || o_type == STT_OBJECT))
- return sym;
- else if (o_secidx == SHN_COMMON
- && (n_type == STT_NOTYPE || n_type == STT_OBJECT))
- goto found;
- else
- {
- /* Don't report an error if the symbol is coming from
- the kernel or some external module. */
- if (secidx <= SHN_HIRESERVE)
- error("%s multiply defined", name);
- return sym;
- }
- }
-
- /* Completely new symbol. */
- sym = arch_new_symbol();
- sym->next = f->symtab[hash];
- f->symtab[hash] = sym;
- sym->ksymidx = -1;
-
- if (ELFW(ST_BIND)(info) == STB_LOCAL && symidx != -1) {
- if (symidx >= f->local_symtab_size)
- error("local symbol %s with index %ld exceeds local_symtab_size %ld",
- name, (long) symidx, (long) f->local_symtab_size);
- else
- f->local_symtab[symidx] = sym;
- }
-
-found:
- sym->name = name;
- sym->value = value;
- sym->size = size;
- sym->secidx = secidx;
- sym->info = info;
- sym->r_type = 0; /* should be R_arch_NONE for all arch */
-
- return sym;
-}
-
-struct obj_symbol *
-obj_find_symbol (struct obj_file *f, const char *name)
-{
- struct obj_symbol *sym;
- unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
-
- for (sym = f->symtab[hash]; sym; sym = sym->next)
- if (f->symbol_cmp(sym->name, name) == 0)
- return sym;
-
- return NULL;
-}
-
-ElfW(Addr)
-obj_symbol_final_value (struct obj_file *f, struct obj_symbol *sym)
-{
- if (sym)
- {
- if (sym->secidx >= SHN_LORESERVE)
- return sym->value;
-
- return sym->value + f->sections[sym->secidx]->header.sh_addr;
- }
- else
- {
- /* As a special case, a NULL sym has value zero. */
- return 0;
- }
-}
-
-struct obj_section *
-obj_find_section (struct obj_file *f, const char *name)
-{
- int i, n = f->header.e_shnum;
-
- for (i = 0; i < n; ++i)
- if (strcmp(f->sections[i]->name, name) == 0)
- return f->sections[i];
-
- return NULL;
-}
-
-#if defined (ARCH_alpha)
-#define ARCH_SHF_SHORT SHF_ALPHA_GPREL
-#elif defined (ARCH_ia64)
-#define ARCH_SHF_SHORT SHF_IA_64_SHORT
-#else
-#define ARCH_SHF_SHORT 0
-#endif
-
-static int
-obj_load_order_prio(struct obj_section *a)
-{
- unsigned long af, ac;
-
- af = a->header.sh_flags;
-
- ac = 0;
- if (a->name[0] != '.'
- || strlen(a->name) != 10
- || strcmp(a->name + 5, ".init"))
- ac |= 64;
- if (af & SHF_ALLOC) ac |= 32;
- if (af & SHF_EXECINSTR) ac |= 16;
- if (!(af & SHF_WRITE)) ac |= 8;
- if (a->header.sh_type != SHT_NOBITS) ac |= 4;
- /* Desired order is
- P S AC & 7
- .data 1 0 4
- .got 1 1 3
- .sdata 1 1 1
- .sbss 0 1 1
- .bss 0 0 0 */
- if (strcmp (a->name, ".got") == 0) ac |= 2;
- if (af & ARCH_SHF_SHORT)
- ac = (ac & ~4) | 1;
-
- return ac;
-}
-
-void
-obj_insert_section_load_order (struct obj_file *f, struct obj_section *sec)
-{
- struct obj_section **p;
- int prio = obj_load_order_prio(sec);
- for (p = f->load_order_search_start; *p ; p = &(*p)->load_next)
- if (obj_load_order_prio(*p) < prio)
- break;
- sec->load_next = *p;
- *p = sec;
-}
-
-struct obj_section *
-obj_create_alloced_section (struct obj_file *f, const char *name,
- unsigned long align, unsigned long size,
- unsigned long flags)
-{
- int newidx = f->header.e_shnum++;
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (newidx+1) * sizeof(sec));
- f->sections[newidx] = sec = arch_new_section();
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = flags | SHF_ALLOC;
- sec->header.sh_size = size;
- sec->header.sh_addralign = align;
- sec->name = name;
- sec->idx = newidx;
- if (size)
- sec->contents = xmalloc(size);
-
- obj_insert_section_load_order(f, sec);
-
- return sec;
-}
-
-struct obj_section *
-obj_create_alloced_section_first (struct obj_file *f, const char *name,
- unsigned long align, unsigned long size)
-{
- int newidx = f->header.e_shnum++;
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (newidx+1) * sizeof(sec));
- f->sections[newidx] = sec = arch_new_section();
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = SHF_WRITE|SHF_ALLOC;
- sec->header.sh_size = size;
- sec->header.sh_addralign = align;
- sec->name = name;
- sec->idx = newidx;
- if (size)
- sec->contents = xmalloc(size);
-
- sec->load_next = f->load_order;
- f->load_order = sec;
- if (f->load_order_search_start == &f->load_order)
- f->load_order_search_start = &sec->load_next;
-
- return sec;
-}
-
-void *
-obj_extend_section (struct obj_section *sec, unsigned long more)
-{
- unsigned long oldsize = sec->header.sh_size;
- sec->contents = xrealloc(sec->contents, sec->header.sh_size += more);
- return sec->contents + oldsize;
-}
-
-/* Convert an object pointer (address) to a native pointer and vice versa.
- * It gets interesting when the object has 64 bit pointers but modutils
- * is running 32 bit. This is nasty code but it stops the compiler giving
- * spurious warning messages. "I know what I am doing" ...
- */
-
-void *
-obj_addr_to_native_ptr (ElfW(Addr) addr)
-{
- unsigned int convert = (sizeof(void *) << 8) + sizeof(addr); /* to, from */
- union obj_ptr_4 p4;
- union obj_ptr_8 p8;
- switch (convert) {
- case 0x0404:
- p4.addr = addr;
- return(p4.ptr);
- break;
- case 0x0408:
- p4.addr = addr;
- if (p4.addr != addr) {
- error("obj_addr_to_native_ptr truncation %" tgt_long_fmt "x",
- (tgt_long) addr);
- exit(1);
- }
- return(p4.ptr);
- break;
- case 0x0804:
- p8.addr = addr;
- return(p8.ptr);
- break;
- case 0x0808:
- p8.addr = addr;
- return(p8.ptr);
- break;
- default:
- error("obj_addr_to_native_ptr unknown conversion 0x%04x", convert);
- exit(1);
- }
-}
-
-ElfW(Addr)
-obj_native_ptr_to_addr (void *ptr)
-{
- unsigned int convert = (sizeof(ElfW(Addr)) << 8) + sizeof(ptr); /* to, from */
- union obj_ptr_4 p4;
- union obj_ptr_8 p8;
- switch (convert) {
- case 0x0404:
- p4.ptr = ptr;
- return(p4.addr);
- break;
- case 0x0408:
- p8.ptr = ptr;
- p4.addr = p8.addr;
- if (p4.addr != p8.addr) {
- error("obj_native_ptr_to_addr truncation %" tgt_long_fmt "x",
- (tgt_long) p8.addr);
- exit(1);
- }
- return(p4.addr);
- break;
- case 0x0804:
- p4.ptr = ptr;
- return(p4.addr); /* compiler expands to 8 */
- break;
- case 0x0808:
- p8.ptr = ptr;
- return(p8.addr);
- break;
- default:
- error("obj_native_ptr_to_addr unknown conversion 0x%04x", convert);
- exit(1);
- }
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_hppa.c b/mdk-stage1/insmod-modutils/obj/obj_hppa.c
deleted file mode 100644
index a6f703c5d..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_hppa.c
+++ /dev/null
@@ -1,638 +0,0 @@
-/*
- * PA-RISC specific support for Elf loading and relocation.
- * Copyright 2000 David Huggins-Daines <dhd@linuxcare.com>, Linuxcare Inc.
- * Copyright 2000 Richard Hirst <rhirst@linuxcare.com>, Linuxcare Inc.
- *
- * Based on the IA-64 support, which is:
- * Copyright 2000 Mike Stephens <mike.stephens@intel.com>
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-#include <modstat.h> /* For ksyms */
-
-
-typedef struct _hppa_stub_t
-{
- struct _hppa_stub_t *next;
- int offset;
- int reloc_done;
-} hppa_stub_t;
-
-typedef struct _hppa_symbol_t
-{
- struct obj_symbol root;
- hppa_stub_t *stub;
-} hppa_symbol_t;
-
-typedef struct _hppa_file_t
-{
- struct obj_file root;
- struct obj_section *stub;
- Elf32_Addr dp;
-} hppa_file_t;
-
-/* The ABI defines various more esoteric types, but these are the only
- ones we actually need. */
-enum hppa_fsel
-{
- e_fsel,
- e_lsel,
- e_rsel,
- e_lrsel,
- e_rrsel
-};
-
-struct obj_file *
-arch_new_file (void)
-{
- hppa_file_t *f;
- f = xmalloc(sizeof(*f));
- f->stub = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- hppa_symbol_t *sym;
- sym = xmalloc(sizeof(*sym));
- sym->stub = NULL;
- return &sym->root;
-}
-
-/* This is called for architecture specific sections we might need to
- do special things to. */
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-/* =================================================================
-
- These functions are from libhppa.h in the GNU BFD library.
- (c) 1990, 91, 92, 93, 94, 95, 96, 98, 99, 2000
- Free Software Foundation, Inc.
-
- ================================================================= */
-
-/* The *sign_extend functions are used to assemble various bitfields
- taken from an instruction and return the resulting immediate
- value. */
-
-static inline int
-sign_extend (x, len)
- int x, len;
-{
- int signbit = (1 << (len - 1));
- int mask = (signbit << 1) - 1;
- return ((x & mask) ^ signbit) - signbit;
-}
-
-static inline int
-low_sign_extend (x, len)
- int x, len;
-{
- return (x >> 1) - ((x & 1) << (len - 1));
-}
-
-
-/* The re_assemble_* functions prepare an immediate value for
- insertion into an opcode. pa-risc uses all sorts of weird bitfields
- in the instruction to hold the value. */
-
-static inline int
-sign_unext (x, len)
- int x, len;
-{
- int len_ones;
-
- len_ones = (1 << len) - 1;
-
- return x & len_ones;
-}
-
-static inline int
-low_sign_unext (x, len)
- int x, len;
-{
- int temp;
- int sign;
-
- sign = (x >> (len-1)) & 1;
-
- temp = sign_unext (x, len-1);
-
- return (temp << 1) | sign;
-}
-
-static inline int
-re_assemble_3 (as3)
- int as3;
-{
- return (( (as3 & 4) << (13-2))
- | ((as3 & 3) << (13+1)));
-}
-
-static inline int
-re_assemble_12 (as12)
- int as12;
-{
- return (( (as12 & 0x800) >> 11)
- | ((as12 & 0x400) >> (10 - 2))
- | ((as12 & 0x3ff) << (1 + 2)));
-}
-
-static inline int
-re_assemble_14 (as14)
- int as14;
-{
- return (( (as14 & 0x1fff) << 1)
- | ((as14 & 0x2000) >> 13));
-}
-
-static inline int
-re_assemble_16 (as16)
- int as16;
-{
- int s, t;
-
- /* Unusual 16-bit encoding, for wide mode only. */
- t = (as16 << 1) & 0xffff;
- s = (as16 & 0x8000);
- return (t ^ s ^ (s >> 1)) | (s >> 15);
-}
-
-static inline int
-re_assemble_17 (as17)
- int as17;
-{
- return (( (as17 & 0x10000) >> 16)
- | ((as17 & 0x0f800) << (16 - 11))
- | ((as17 & 0x00400) >> (10 - 2))
- | ((as17 & 0x003ff) << (1 + 2)));
-}
-
-static inline int
-re_assemble_21 (as21)
- int as21;
-{
- return (( (as21 & 0x100000) >> 20)
- | ((as21 & 0x0ffe00) >> 8)
- | ((as21 & 0x000180) << 7)
- | ((as21 & 0x00007c) << 14)
- | ((as21 & 0x000003) << 12));
-}
-
-static inline int
-re_assemble_22 (as22)
- int as22;
-{
- return (( (as22 & 0x200000) >> 21)
- | ((as22 & 0x1f0000) << (21 - 16))
- | ((as22 & 0x00f800) << (16 - 11))
- | ((as22 & 0x000400) >> (10 - 2))
- | ((as22 & 0x0003ff) << (1 + 2)));
-}
-
-
-/* Handle field selectors for PA instructions.
- The L and R (and LS, RS etc.) selectors are used in pairs to form a
- full 32 bit address. eg.
-
- LDIL L'start,%r1 ; put left part into r1
- LDW R'start(%r1),%r2 ; add r1 and right part to form address
-
- This function returns sign extended values in all cases.
-*/
-
-static inline unsigned int
-hppa_field_adjust (value, addend, r_field)
- unsigned int value;
- int addend;
- enum hppa_fsel r_field;
-{
- unsigned int sym_val;
-
- sym_val = value - addend;
- switch (r_field)
- {
- case e_fsel:
- /* F: No change. */
- break;
-
- case e_lsel:
- /* L: Select top 21 bits. */
- value = value >> 11;
- break;
-
- case e_rsel:
- /* R: Select bottom 11 bits. */
- value = value & 0x7ff;
- break;
-
- case e_lrsel:
- /* LR: L with rounding of the addend to nearest 8k. */
- value = sym_val + ((addend + 0x1000) & -0x2000);
- value = value >> 11;
- break;
-
- case e_rrsel:
- /* RR: R with rounding of the addend to nearest 8k.
- We need to return a value such that 2048 * LR'x + RR'x == x
- ie. RR'x = s+a - (s + (((a + 0x1000) & -0x2000) & -0x800))
- . = s+a - ((s & -0x800) + ((a + 0x1000) & -0x2000))
- . = (s & 0x7ff) + a - ((a + 0x1000) & -0x2000) */
- value = (sym_val & 0x7ff) + (((addend & 0x1fff) ^ 0x1000) - 0x1000);
- break;
-
- default:
- abort();
- }
- return value;
-}
-
-/* Insert VALUE into INSN using R_FORMAT to determine exactly what
- bits to change. */
-
-static inline int
-hppa_rebuild_insn (insn, value, r_format)
- int insn;
- int value;
- int r_format;
-{
- switch (r_format)
- {
- case 11:
- return (insn & ~ 0x7ff) | low_sign_unext (value, 11);
-
- case 12:
- return (insn & ~ 0x1ffd) | re_assemble_12 (value);
-
-
- case 10:
- return (insn & ~ 0x3ff1) | re_assemble_14 (value & -8);
-
- case -11:
- return (insn & ~ 0x3ff9) | re_assemble_14 (value & -4);
-
- case 14:
- return (insn & ~ 0x3fff) | re_assemble_14 (value);
-
-
- case -10:
- return (insn & ~ 0xfff1) | re_assemble_16 (value & -8);
-
- case -16:
- return (insn & ~ 0xfff9) | re_assemble_16 (value & -4);
-
- case 16:
- return (insn & ~ 0xffff) | re_assemble_16 (value);
-
-
- case 17:
- return (insn & ~ 0x1f1ffd) | re_assemble_17 (value);
-
- case 21:
- return (insn & ~ 0x1fffff) | re_assemble_21 (value);
-
- case 22:
- return (insn & ~ 0x3ff1ffd) | re_assemble_22 (value);
-
- case 32:
- return value;
-
- default:
- abort ();
- }
- return insn;
-}
-
-/* ====================================================================
-
- End of functions from GNU BFD.
-
- ==================================================================== */
-
-/* This is where we get the opportunity to create any extra dynamic
- sections we might need. In our case we do not need a GOT because
- our code is not PIC, but we do need to create a stub section.
-
- This is significantly less complex than what we do for shared
- libraries because, obviously, modules are not shared. Also we have
- no issues related to symbol visibility, lazy linking, etc.
- The kernels dp is fixed (at symbol $global$), and we can fix up any
- DPREL refs in the module to use that same dp value.
- All PCREL* refs result in a stub with the following format:
-
- ldil L'func_addr,%r1
- be,n R'func_addr(%sr4,%r1)
-
- Note, all PCREL* get a stub, regardless of whether they are
- local or external. With local ones, and external ones to other
- modules, there is a good chance we could manage without the stub.
- I'll leave that for a future optimisation.
- */
-
-#define LDIL_R1 0x20200000 /* ldil L'XXX,%r1 */
-#define BE_N_SR4_R1 0xe0202002 /* be,n R'XXX(%sr4,%r1) */
-
-#define STUB_SIZE 8
-
-int
-arch_create_got(struct obj_file *f)
-{
- hppa_file_t *hfile = (hppa_file_t *)f;
- int i, n;
- int stub_offset = 0;
-
- /* Create stub section.
- * XXX set flags, see obj_ia64.c
- */
- hfile->stub = obj_create_alloced_section(f, ".stub", STUB_SIZE,
- 0, SHF_WRITE);
-
- /* Actually this is a lot like check_relocs() in a BFD backend. We
- walk all sections and all their relocations and look for ones
- that need special treatment. */
- n = hfile->root.header.e_shnum;
- for (i = 0; i < n; ++i)
- {
- struct obj_section *relsec, *symsec, *strsec;
- Elf32_Rela *rel, *relend;
- Elf32_Sym *symtab;
- char const *strtab;
-
- relsec = hfile->root.sections[i];
- if (relsec->header.sh_type != SHT_RELA)
- continue;
-
- symsec = hfile->root.sections[relsec->header.sh_link];
- strsec = hfile->root.sections[symsec->header.sh_link];
-
- rel = (Elf32_Rela *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(Elf32_Rela));
- symtab = (Elf32_Sym *)symsec->contents;
- strtab = (char const *)strsec->contents;
-
- for (; rel < relend; rel++)
- {
- int need_stub = 0;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- default:
- continue;
-
- case R_PARISC_PCREL17F:
- case R_PARISC_PCREL22F:
- need_stub = 1;
- break;
- }
-
- if (need_stub)
- {
- hppa_symbol_t *hsym;
- int local;
-
- obj_find_relsym(hsym, f, f, rel, symtab, strtab);
- local = hsym->root.secidx <= SHN_HIRESERVE;
-
- if (need_stub)
- {
- hppa_stub_t *stub;
-
- if (hsym->stub == NULL)
- {
- stub = (hppa_stub_t *) xmalloc(sizeof(hppa_stub_t));
- stub->offset = stub_offset;
- stub->reloc_done = 0;
- hsym->stub = stub;
- stub_offset += STUB_SIZE;
- need_stub = 0;
- }
- }
- }
- }
- }
- if (stub_offset)
- {
- hfile->stub->contents = xmalloc(stub_offset);
- hfile->stub->header.sh_size = stub_offset;
- }
- return 1;
-}
-
-
-enum obj_reloc
-arch_apply_relocation(struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rela *rel,
- Elf32_Addr v)
-{
- hppa_file_t *hfile = (hppa_file_t *) f;
- hppa_symbol_t *hsym = (hppa_symbol_t *) sym;
-
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = (targsec->header.sh_addr + rel->r_offset) & ~0x03;
- Elf32_Addr dp = hfile->dp;
- Elf32_Word r_info = ELF32_R_TYPE(rel->r_info);
-
- enum obj_reloc ret = obj_reloc_ok;
- enum hppa_fsel fsel = e_fsel; /* Avoid compiler warning */
- unsigned int r_format;
-
- /* Fix up the value, and determine whether we can handle this
- relocation. */
- switch (r_info)
- {
- case R_PARISC_PLABEL32:
- case R_PARISC_DIR32:
- case R_PARISC_DIR21L:
- case R_PARISC_DIR14R:
- /* Easy. */
- break;
-
- case R_PARISC_SEGREL32:
- v -= f->baseaddr;
- break;
-
- case R_PARISC_DPREL21L:
- case R_PARISC_DPREL14R:
- v -= dp;
- break;
-
- case R_PARISC_PCREL17F:
- case R_PARISC_PCREL22F:
- /* Find an import stub. */
- assert(hsym->stub != NULL);
- assert(hfile->stub != NULL);
- /* XXX Optimise. We may not need a stub for short branches */
- if (!hsym->stub->reloc_done) {
- /* Need to create the .stub entry */
- Elf32_Addr *pstub, stubv;
-
- pstub = (Elf32_Addr *)(hfile->stub->contents + hsym->stub->offset);
- pstub[0] = LDIL_R1;
- pstub[1] = BE_N_SR4_R1;
- stubv = hppa_field_adjust(v, rel->r_addend, e_lrsel);
- pstub[0] = hppa_rebuild_insn(pstub[0], stubv, 21);
- stubv = hppa_field_adjust(v, rel->r_addend, e_rrsel);
- stubv >>= 2; /* Branch; divide by 4 */
- pstub[1] = hppa_rebuild_insn(pstub[1], stubv, 17);
- hsym->stub->reloc_done = 1;
- }
- v = hsym->stub->offset + hfile->stub->header.sh_addr;
- break;
-
- default:
- return obj_reloc_unhandled;
- }
-
- /* Find the field selector. */
- switch (r_info)
- {
- case R_PARISC_DIR32:
- case R_PARISC_PLABEL32:
- case R_PARISC_PCREL17F:
- case R_PARISC_SEGREL32:
- case R_PARISC_PCREL22F:
- fsel = e_fsel;
- break;
-
- case R_PARISC_DPREL21L:
- case R_PARISC_DIR21L:
- fsel = e_lrsel;
- break;
-
- case R_PARISC_DPREL14R:
- case R_PARISC_DIR14R:
- fsel = e_rrsel;
- break;
- }
-
- v = hppa_field_adjust(v, rel->r_addend, fsel);
-
- switch (r_info)
- {
- case R_PARISC_PCREL17F:
- case R_PARISC_PCREL17R:
- case R_PARISC_PCREL22F:
- v = v - dot - 8;
- case R_PARISC_DIR17F:
- case R_PARISC_DIR17R:
- /* This is a branch. Divide the offset by four. */
- v >>= 2;
- break;
- default:
- break;
- }
-
- /* Find the format. */
- switch (r_info)
- {
- case R_PARISC_DIR32:
- case R_PARISC_PLABEL32:
- case R_PARISC_SEGREL32:
- r_format = 32;
- break;
-
- case R_PARISC_DPREL21L:
- case R_PARISC_DIR21L:
- r_format = 21;
- break;
-
- case R_PARISC_PCREL17F:
- r_format = 17;
- break;
-
- case R_PARISC_DPREL14R:
- case R_PARISC_DIR14R:
- r_format = 14;
- break;
-
- case R_PARISC_PCREL22F:
- r_format = 22;
- break;
-
- default:
- abort();
- }
-
- *loc = hppa_rebuild_insn(*loc, v, r_format);
-
- return ret;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *f, struct obj_section *sec)
-{
- struct module_symbol *s;
- int i;
- hppa_file_t *hfile = (hppa_file_t *)f;
-
- /* Initialise dp to the kernels dp (symbol $global$)
- */
- for (i = 0, s = ksyms; i < nksyms; i++, s++)
- if (!strcmp((char *)s->name, "$global$"))
- break;
- if (i >= nksyms) {
- error("Cannot initialise dp, '$global$' not found\n");
- return 1;
- }
- hfile->dp = s->value;
-
- return 0;
-}
-
diff --git a/mdk-stage1/insmod-modutils/obj/obj_hppa64.c b/mdk-stage1/insmod-modutils/obj/obj_hppa64.c
deleted file mode 100644
index d9f1ada9d..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_hppa64.c
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- * hppa parisc64 specific support for Elf loading and relocation.
- * Copyright 2000 Richard Hirst <rhirst@linuxcare.com>, Linuxcare Inc.
- *
- * Based on ia64 specific support which was
- * Copyright 2000 Mike Stephens <mike.stephens@intel.com>
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE ~FALSE
-#endif
-
-/*======================================================================*/
-
-typedef struct _hppa64_opd_t
-{
- int offset;
- int reloc_done;
-} hppa64_opd_t;
-
-typedef struct _hppa64_stub_t
-{
- struct _hppa64_stub_t *next;
- Elf64_Addr addend;
- int offset;
- int reloc_done;
-} hppa64_stub_t;
-
-typedef struct _hppa64_got_t
-{
- struct _hppa64_got_t *next;
- Elf64_Addr addend;
- int offset;
- int reloc_done;
-} hppa64_got_t;
-
-typedef struct _hppa64_symbol_t
-{
- struct obj_symbol root;
- hppa64_got_t *gotent;
- hppa64_opd_t *opdent;
- hppa64_stub_t *stubent;
-} hppa64_symbol_t;
-
-typedef struct _hppa64_file_t
-{
- struct obj_file root;
- struct obj_section *got;
- struct obj_section *opd;
- struct obj_section *stub;
- Elf64_Addr gp;
- Elf64_Addr text;
- Elf64_Addr data;
- Elf64_Addr bss;
-} hppa64_file_t;
-
-/*
- * XXX This stub assumes it can reach the .got entry with a +/- 8K offset
- * from dp. Perhaps we should use a .plt for these entries to give a
- * greater chance of that being true.
- *
- * 53 7b 00 00 ldd 0(dp),dp
- * R_PARISC_LTOFF14R <.got entry offset from dp>
- * 53 61 00 20 ldd 10(dp),r1
- * e8 20 d0 00 bve (r1)
- * 53 7b 00 30 ldd 18(dp),dp
- *
- * We need a different stub for millicode calls, which doesn't depend on
- * or modify dp:
- *
- * 20 20 00 00 ldil 0,r1
- * R_PARISC_DIR21L <addr of kernels opd entry>
- * 34 21 00 00 ldo 0(r1),r1
- * R_PARISC_DIR14R <addr of kernels opd entry>
- * 50 21 00 20 ldd 10(r1),r1
- * e8 20 d0 02 bve,n (r1)
- */
-
-/* NOTE: to keep the code cleaner we make all stubs the same size.
- */
-
-#define SIZEOF_STUB 16
-
-unsigned char hppa64_stub_extern[] =
-{
- 0x53, 0x7b, 0x00, 0x00,
- 0x53, 0x61, 0x00, 0x20,
- 0xe8, 0x20, 0xd0, 0x00,
- 0x53, 0x7b, 0x00, 0x30,
-};
-
-unsigned char hppa64_stub_millicode[] =
-{
- 0x20, 0x20, 0x00, 0x00,
- 0x34, 0x21, 0x00, 0x00,
- 0x50, 0x21, 0x00, 0x20,
- 0xe8, 0x20, 0xd0, 0x02,
-};
-
-/*======================================================================*/
-
-enum obj_reloc
-patch_14r(Elf64_Xword v64, Elf64_Word *p)
-{
- Elf64_Word i = *p;
- Elf64_Word v = (Elf64_Word)v64;
-
- if (v & 0x80000000)
- v |= ~0x7ff;
- else
- v &= 0x7ff;
- i &= ~ 0x3fff;
- i |= (v & 0x1fff) << 1 |
- (v & 0x2000) >> 13;
- *p = i;
-
- return obj_reloc_ok;
-}
-
-enum obj_reloc
-patch_21l(Elf64_Xword v64, Elf64_Word *p)
-{
- Elf64_Word i = *p;
- Elf64_Word v = (Elf64_Word)v64;
-
- v &= 0xfffff800;
- if (v & 0x80000000)
- v += 0x800;
- i &= ~ 0x1fffff;
- i |= (v & 0x80000000) >> 31 |
- (v & 0x7ff00000) >> 19 |
- (v & 0x000c0000) >> 4 |
- (v & 0x0003e000) << 3 |
- (v & 0x00001800) << 1;
- *p = i;
-
- return obj_reloc_ok;
-}
-
-
-/* All 14 bits this time... This is used to patch the .got offset in
- * a stub for PCREL22F.
- */
-
-enum obj_reloc
-patch_14r2(Elf64_Xword v64, Elf64_Word *p)
-{
- Elf64_Word i = *p;
- Elf64_Word v = (Elf64_Word)v64;
-
- if ((Elf64_Sxword)v64 > 0x1fffL ||
- (Elf64_Sxword)v64 < -0x2000L)
- return obj_reloc_overflow;
- i &= ~ 0x3fff;
- i |= (v & 0x2000) >> 13 |
- (v & 0x1fff) << 1;
- *p = i;
-
- return obj_reloc_ok;
-}
-
-
-enum obj_reloc
-patch_22f(Elf64_Xword v64, Elf64_Word *p)
-{
- Elf64_Word i = *p;
- Elf64_Word v = (Elf64_Word)v64;
-
- if ((Elf64_Sxword)v64 > 0x800000-1 ||
- (Elf64_Sxword)v64 < -0x800000)
- return obj_reloc_overflow;
-
- i &= ~ 0x03ff1ffd;
- i |= (v & 0x00800000) >> 23 |
- (v & 0x007c0000) << 3 |
- (v & 0x0003e000) << 3 |
- (v & 0x00001000) >> 10 |
- (v & 0x00000ffc) << 1;
- *p = i;
-
- return obj_reloc_ok;
-}
-
-
-struct obj_section *
-obj_hppa64_create_alloced_section (struct obj_file *f, const char *name,
- unsigned long align, unsigned long size, unsigned long sh_flags)
-{
- int newidx = f->header.e_shnum++;
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (newidx+1) * sizeof(sec));
- f->sections[newidx] = sec = arch_new_section();
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = sh_flags;
- sec->header.sh_size = size;
- sec->header.sh_addralign = align;
- sec->name = name;
- sec->idx = newidx;
- if (size)
- sec->contents = xmalloc(size);
-
- obj_insert_section_load_order(f, sec);
-
- return sec;
-}
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- hppa64_file_t *f;
- f = xmalloc(sizeof(*f));
- f->got = NULL;
- f->opd = NULL;
- f->stub = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- hppa64_symbol_t *sym;
- sym = xmalloc(sizeof(*sym));
- sym->gotent = NULL;
- sym->opdent = NULL;
- sym->stubent = NULL;
- return &sym->root;
-}
-
-/* This may not be needed, but does no harm (copied from ia64).
- */
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- switch (sec->header.sh_type)
- {
- case SHT_PARISC_EXT :
- sec->contents = NULL;
- break;
-
- case SHT_PARISC_UNWIND :
- if (sec->header.sh_size > 0)
- {
- sec->contents = xmalloc(sec->header.sh_size);
- gzf_lseek(fp, sec->header.sh_offset, SEEK_SET);
- if (gzf_read(fp, sec->contents, sec->header.sh_size) != sec->header.sh_size)
- {
- error("error reading ELF section data: %m");
- return -1;
- }
- }
- else
- sec->contents = NULL;
- break;
- default:
- error("Unknown section header type: %08x", sec->header.sh_type);
- return -1;
- }
- return 0;
-}
-
-int
-arch_create_got(struct obj_file *f)
-{
- hppa64_file_t *hfile = (hppa64_file_t *)f;
- int i;
- int n;
- int got_offset = 0;
- int opd_offset = 64;
- int stub_offset = 0;
-
- n = hfile->root.header.e_shnum;
- for (i = 0; i < n; ++i)
- {
- struct obj_section *relsec, *symsec, *strsec;
- Elf64_Rela *rel, *relend;
- Elf64_Sym *symtab;
- const char *strtab;
-
- relsec = hfile->root.sections[i];
- if (relsec->header.sh_type != SHT_RELA)
- continue;
-
- symsec = hfile->root.sections[relsec->header.sh_link];
- strsec = hfile->root.sections[symsec->header.sh_link];
-
- rel = (Elf64_Rela *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(Elf64_Rela));
- symtab = (Elf64_Sym *)symsec->contents;
- strtab = (const char *)strsec->contents;
-
- for (; rel < relend; ++rel)
- {
- int need_got = FALSE;
- int need_opd = FALSE;
- int need_stub = FALSE;
-
- switch (ELF64_R_TYPE(rel->r_info))
- {
- default:
- {
- unsigned r_info = ELF64_R_TYPE(rel->r_info);
- printf("r_info 0x%x not handled\n", r_info);
- }
- continue;
- case R_PARISC_LTOFF14R:
- case R_PARISC_LTOFF21L:
- /* These are simple indirect references to symbols through the
- * DLT. We need to create a DLT entry for any symbols which
- * appears in a DLTIND relocation.
- */
- need_got = TRUE;
- break;
- case R_PARISC_PCREL22F:
- /* These are function calls. Depending on their precise
- * target we may need to make a stub for them. The stub
- * uses the dlt, so we need to create dlt entries for
- * these symbols too.
- */
- need_got = TRUE;
- need_stub = TRUE;
- break;
- case R_PARISC_DIR64:
- case R_PARISC_SEGREL32:
- break;
- case R_PARISC_FPTR64:
- /* This is a simple OPD entry (only created for local symbols,
- * see below).
- */
- need_opd = TRUE;
- break;
- }
-
- if (need_got || need_opd || need_stub)
- {
- hppa64_symbol_t *isym;
- int local;
-
- obj_find_relsym(isym, f, f, rel, symtab, strtab);
- local = isym->root.secidx <= SHN_HIRESERVE;
-
- if (need_stub)
- {
- hppa64_stub_t *stub;
-
- for (stub = isym->stubent; stub != NULL; stub = stub->next)
- if (stub->addend == rel->r_addend)
- break;
- if (stub == NULL)
- {
- stub = (hppa64_stub_t *) xmalloc(sizeof(hppa64_stub_t));
- stub->next = isym->stubent;
- stub->addend = rel->r_addend;
- stub->offset = stub_offset;
- stub->reloc_done = FALSE;
- isym->stubent = stub;
- {
- stub_offset += SIZEOF_STUB;
- }
- need_stub = FALSE;
- }
- }
- if (need_got)
- {
- hppa64_got_t *got;
-
- for (got = isym->gotent; got != NULL; got = got->next)
- if (got->addend == rel->r_addend)
- break;
- if (got == NULL)
- {
- got = (hppa64_got_t *) xmalloc(sizeof(hppa64_got_t));
- got->next = isym->gotent;
- got->addend = rel->r_addend;
- got->offset = got_offset;
- got->reloc_done = FALSE;
- isym->gotent = got;
- got_offset += 8;
- need_got = FALSE;
- }
- }
- if (need_opd && local)
- {
- hppa64_opd_t *opd;
-
- if (isym->opdent == NULL)
- {
- opd = (hppa64_opd_t *) xmalloc(sizeof(hppa64_opd_t));
- opd->offset = opd_offset;
- opd->reloc_done = FALSE;
- isym->opdent = opd;
- opd_offset += 32;
- need_opd = FALSE;
- }
- }
- }
- }
- }
-
- hfile->got = obj_hppa64_create_alloced_section(f, ".got", 8, got_offset,
- (SHF_ALLOC | SHF_WRITE | SHF_PARISC_SHORT));
- assert(hfile->got != NULL);
-
- hfile->opd = obj_hppa64_create_alloced_section(f, ".opd", 16, opd_offset,
- (SHF_ALLOC | SHF_WRITE | SHF_PARISC_SHORT));
- assert(hfile->opd != NULL);
-
- if (stub_offset > 0)
- {
- hfile->stub = obj_hppa64_create_alloced_section(f, ".stub", 16,
- stub_offset, (SHF_ALLOC | SHF_EXECINSTR | SHF_PARISC_SHORT));
- assert(hfile->stub != NULL);
- }
-
- return 1;
-}
-
-
-/* This is a small simple version which seems to work fine. ia64 has
- * a much more complex algorithm. We point dp at the end of the .got,
- * which is the start of the .opd.
- */
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf64_Addr base)
-{
- hppa64_file_t *hfile = (hppa64_file_t *)f;
- int n = f->header.e_shnum;
- int i;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
-
- /* Pick a sensible value for gp */
- hfile->gp = hfile->got->header.sh_addr + hfile->got->header.sh_size;
-
- return 1;
-}
-
-
-enum obj_reloc
-arch_apply_relocation(struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf64_Rela *rel,
- Elf64_Addr v)
-{
- hppa64_file_t *hfile = (hppa64_file_t *) f;
- hppa64_symbol_t *isym = (hppa64_symbol_t *) sym;
-
- Elf64_Word *loc = (Elf64_Word *)(targsec->contents + rel->r_offset);
- Elf64_Addr dot = (targsec->header.sh_addr + rel->r_offset) & ~0x03;
-
- Elf64_Addr got = hfile->got->header.sh_addr;
- Elf64_Addr gp = hfile->gp;
-
- Elf64_Xword r_info = ELF64_R_TYPE(rel->r_info);
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (r_info)
- {
- default:
- ret = obj_reloc_unhandled;
- break;
- case R_PARISC_LTOFF14R:
- case R_PARISC_LTOFF21L:
- {
- hppa64_got_t *ge;
-
- assert(isym != NULL);
- for (ge = isym->gotent; ge != NULL && ge->addend != rel->r_addend; )
- ge = ge->next;
- assert(ge != NULL);
- if (!ge->reloc_done)
- {
- ge->reloc_done = TRUE;
- *(Elf64_Addr *)(hfile->got->contents + ge->offset) = v;
- }
- v = got + ge->offset - gp;
- if (r_info == R_PARISC_LTOFF14R)
- ret = patch_14r(v, loc);
- else
- ret = patch_21l(v, loc);
- }
- break;
- case R_PARISC_PCREL22F:
- {
- hppa64_got_t *ge;
-
- assert(isym != NULL);
- for (ge = isym->gotent; ge != NULL && ge->addend != rel->r_addend; )
- ge = ge->next;
- assert(ge != NULL);
- if (!ge->reloc_done)
- {
- ge->reloc_done = TRUE;
- *(Elf64_Addr *)(hfile->got->contents + ge->offset) = v;
- }
- if ((isym->root.secidx > SHN_HIRESERVE) ||
- ((Elf64_Sxword) (v - dot - 8) > 0x800000-1) ||
- ((Elf64_Sxword) (v - dot - 8) < -0x800000))
- {
- hppa64_stub_t *se;
-
- for (se = isym->stubent; se != NULL && se->addend != rel->r_addend; )
- se = se->next;
- assert(se != NULL);
- if (!se->reloc_done)
- {
- /* This requires that we can get from dp to the entry in +/- 8K,
- * or +/- 1000 entries. patch_14r2() will check that.
- * Only need these dlt entries for calls to external/far
- * functions, so should probably put them in a seperate section
- * before dlt and point dp at the section. Change to that
- * scheme if we hit problems with big modules.
- */
- unsigned char *stub;
-
- if (!strncmp(isym->root.name, "$$", 2)) {
- stub = hppa64_stub_millicode;
- memcpy((Elf64_Addr *)(hfile->stub->contents + se->offset),
- stub, SIZEOF_STUB);
- v = (Elf64_Addr)isym->root.value;
- ret = patch_21l(v, (Elf64_Word *)(hfile->stub->contents + se->offset));
- if (ret == obj_reloc_ok)
- ret = patch_14r(v, (Elf64_Word *)(hfile->stub->contents + se->offset + 4));
- }
- else {
- stub = hppa64_stub_extern;
- memcpy((Elf64_Addr *)(hfile->stub->contents + se->offset),
- stub, SIZEOF_STUB);
- v = (Elf64_Addr)(hfile->got->header.sh_addr + ge->offset) - gp;
- ret = patch_14r2(v, (Elf64_Word *)(hfile->stub->contents + se->offset));
- }
- se->reloc_done = TRUE;
- }
- v = hfile->stub->header.sh_addr + se->offset;
- }
- v = v - dot - 8;
- if (ret == obj_reloc_ok)
- ret = patch_22f(v, loc);
- }
- break;
- case R_PARISC_DIR64:
- {
- loc[0] = v >> 32;
- loc[1] = v;
- }
- break;
- case R_PARISC_SEGREL32:
- {
- loc[0] = v - f->baseaddr;
- }
- break;
- case R_PARISC_FPTR64:
- {
- assert(isym != NULL);
- if (isym->root.secidx <= SHN_HIRESERVE) /* local */
- {
- assert(isym->opdent != NULL);
- if (!isym->opdent->reloc_done)
- {
- isym->opdent->reloc_done = TRUE;
- *(Elf64_Addr *)(hfile->opd->contents + isym->opdent->offset + 16) = v;
- *(Elf64_Addr *)(hfile->opd->contents + isym->opdent->offset + 24) = gp;
- }
- v = hfile->opd->header.sh_addr + isym->opdent->offset;
- }
- loc[0] = v >> 32;
- loc[1] = v;
- }
- break;
- }
- return ret;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- hppa64_file_t *hfile = (hppa64_file_t *)f;
- Elf64_Addr *opd = (Elf64_Addr *)(hfile->opd->contents);
-
- opd[0] = 0;
- opd[1] = 0;
- if ((opd[2] = mod->init) != 0)
- {
- opd[3] = hfile->gp;
- mod->init = hfile->opd->header.sh_addr;
- }
-
- opd[4] = 0;
- opd[5] = 0;
- if ((opd[6] = mod->cleanup) != 0)
- {
- opd[7] = hfile->gp;
- mod->cleanup = hfile->opd->header.sh_addr + 32;
- }
-
- return 1;
-}
-
-/* XXX Is this relevant to parisc? */
-
-int
-arch_archdata (struct obj_file *f, struct obj_section *archdata_sec)
-{
- hppa64_file_t *hfile = (hppa64_file_t *)f;
- struct archdata {
- unsigned tgt_long unw_table;
- unsigned tgt_long segment_base;
- unsigned tgt_long unw_start;
- unsigned tgt_long unw_end;
- unsigned tgt_long gp;
- } *ad;
- int i;
- struct obj_section *sec;
-
- free(archdata_sec->contents);
- archdata_sec->contents = xmalloc(sizeof(struct archdata));
- memset(archdata_sec->contents, 0, sizeof(struct archdata));
- archdata_sec->header.sh_size = sizeof(struct archdata);
-
- ad = (struct archdata *)(archdata_sec->contents);
- ad->gp = hfile->gp;
- ad->unw_start = 0;
- ad->unw_end = 0;
- ad->unw_table = 0;
- ad->segment_base = f->sections[1]->header.sh_addr;
- for (i = 0; i < f->header.e_shnum; ++i)
- {
- sec = f->sections[i];
- if (sec->header.sh_type == SHT_PARISC_UNWIND)
- {
- ad->unw_start = sec->header.sh_addr;
- ad->unw_end = sec->header.sh_addr + sec->header.sh_size;
- break;
- }
- }
-
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_i386.c b/mdk-stage1/insmod-modutils/obj/obj_i386.c
deleted file mode 100644
index fcbce8e04..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_i386.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/* i386 specific support for Elf loading and relocation.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h>
-#include <assert.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct i386_got_entry
-{
- int offset;
- unsigned offset_done : 1;
- unsigned reloc_done : 1;
-};
-
-struct i386_file
-{
- struct obj_file root;
- struct obj_section *got;
-};
-
-struct i386_symbol
-{
- struct obj_symbol root;
- struct i386_got_entry gotent;
-};
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- struct i386_file *f;
- f = xmalloc(sizeof(*f));
- f->got = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- struct i386_symbol *sym;
- sym = xmalloc(sizeof(*sym));
- memset(&sym->gotent, 0, sizeof(sym->gotent));
- return &sym->root;
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rel *rel,
- Elf32_Addr v)
-{
- struct i386_file *ifile = (struct i386_file *)f;
- struct i386_symbol *isym = (struct i386_symbol *)sym;
-
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
- Elf32_Addr got = ifile->got ? ifile->got->header.sh_addr : 0;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_386_NONE:
- break;
-
- case R_386_32:
- *loc += v;
- break;
-
- case R_386_PLT32:
- case R_386_PC32:
- *loc += v - dot;
- break;
-
- case R_386_GLOB_DAT:
- case R_386_JMP_SLOT:
- *loc = v;
- break;
-
- case R_386_RELATIVE:
- *loc += f->baseaddr;
- break;
-
- case R_386_GOTPC:
- assert(got != 0);
- *loc += got - dot;
- break;
-
- case R_386_GOT32:
- assert(isym != NULL);
- if (!isym->gotent.reloc_done)
- {
- isym->gotent.reloc_done = 1;
- *(Elf32_Addr *)(ifile->got->contents + isym->gotent.offset) = v;
- }
- *loc += isym->gotent.offset;
- break;
-
- case R_386_GOTOFF:
- assert(got != 0);
- *loc += v - got;
- break;
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *f)
-{
- struct i386_file *ifile = (struct i386_file *)f;
- int i, n, offset = 0, gotneeded = 0;
-
- n = ifile->root.header.e_shnum;
- for (i = 0; i < n; ++i)
- {
- struct obj_section *relsec, *symsec, *strsec;
- Elf32_Rel *rel, *relend;
- Elf32_Sym *symtab;
- const char *strtab;
-
- relsec = ifile->root.sections[i];
- if (relsec->header.sh_type != SHT_REL)
- continue;
-
- symsec = ifile->root.sections[relsec->header.sh_link];
- strsec = ifile->root.sections[symsec->header.sh_link];
-
- rel = (Elf32_Rel *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(Elf32_Rel));
- symtab = (Elf32_Sym *)symsec->contents;
- strtab = (const char *)strsec->contents;
-
- for (; rel < relend; ++rel)
- {
- struct i386_symbol *intsym;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_386_GOTPC:
- case R_386_GOTOFF:
- gotneeded = 1;
- default:
- continue;
-
- case R_386_GOT32:
- break;
- }
-
- obj_find_relsym(intsym, f, &ifile->root, rel, symtab, strtab);
-
- if (!intsym->gotent.offset_done)
- {
- intsym->gotent.offset_done = 1;
- intsym->gotent.offset = offset;
- offset += 4;
- }
- }
- }
-
- if (offset > 0 || gotneeded)
- ifile->got = obj_create_alloced_section(&ifile->root, ".got", 4, offset,
- SHF_WRITE);
-
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_ia64.c b/mdk-stage1/insmod-modutils/obj/obj_ia64.c
deleted file mode 100644
index d207a9042..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_ia64.c
+++ /dev/null
@@ -1,1022 +0,0 @@
-/*
- * ia64 specific support for Elf loading and relocation.
- * Copyright 2000 Mike Stephens <mike.stephens@intel.com>
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE ~FALSE
-#endif
-
-/*======================================================================*/
-
-typedef struct _ia64_opd_t
-{
- int offset;
- int reloc_done;
-} ia64_opd_t;
-
-typedef struct _ia64_plt_t
-{
- struct _ia64_plt_t *next;
- Elf64_Addr addend;
- int text_offset;
- int data_offset;
- int reloc_done;
-} ia64_plt_t;
-
-typedef struct _ia64_got_t
-{
- struct _ia64_got_t *next;
- Elf64_Addr addend;
- int offset;
- int reloc_done;
-} ia64_got_t;
-
-typedef struct _ia64_symbol_t
-{
- struct obj_symbol root;
- ia64_got_t *gotent;
- ia64_opd_t *opdent;
- ia64_plt_t *pltent;
-} ia64_symbol_t;
-
-typedef struct _ia64_file_t
-{
- struct obj_file root;
- struct obj_section *got;
- struct obj_section *opd;
- struct obj_section *pltt;
- struct obj_section *pltd;
- Elf64_Addr gp;
- Elf64_Addr text;
- Elf64_Addr data;
- Elf64_Addr bss;
-} ia64_file_t;
-
-/*
- * aa=gp rel address of the function descriptor in the .IA_64.pltoff section
- */
-unsigned char ia64_plt_local[] =
-{
- 0x0b, 0x78, 0x00, 0x02, 0x00, 0x24, /* [MMI] addl r15=aa,gp;; */
- 0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0, /* ld8 r16=[r15],8 */
- 0x01, 0x08, 0x00, 0x84, /* mov r14=gp;; */
- 0x11, 0x08, 0x00, 0x1e, 0x18, 0x10, /* [MIB] ld8 gp=[r15] */
- 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */
- 0x60, 0x00, 0x80, 0x00 /* br.few b6;; */
-};
-
-unsigned char ia64_plt_extern[] =
-{
- 0x0b, 0x80, 0x00, 0x02, 0x00, 0x24, /* [MMI] addl r16=aa,gp;; */
- 0xf0, 0x00, 0x40, 0x30, 0x20, 0x00, /* ld8 r15=[r16] */
- 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0;; */
- 0x0b, 0x80, 0x20, 0x1e, 0x18, 0x14, /* [MMI] ld8 r16=[r15],8;; */
- 0x10, 0x00, 0x3c, 0x30, 0x20, 0xc0, /* ld8 gp=[r15] */
- 0x00, 0x09, 0x00, 0x07, /* mov b6=r16;; */
- 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MIB] nop.m 0x0 */
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* nop.i 0x0 */
- 0x60, 0x00, 0x80, 0x00 /* br.few b6;; */
-};
-
-/*======================================================================*/
-
-/*
- * return the instruction at slot in bundle
- */
-Elf64_Xword
-obj_ia64_ins_extract_from_bundle(Elf64_Addr *bundle, Elf64_Xword slot)
-{
- switch (slot)
- {
- case 0 :
- return (*bundle >> 5) & 0x1ffffffffff;
-
- case 1 :
- return (((*bundle >> 46) & 0x3ffff) |
- (*(bundle + 1) << 18)) & 0x1ffffffffff;
-
- case 2 :
- return (*(bundle + 1) >> 23) & 0x1ffffffffff;
-
- default:
- }
- return (-1);
-}
-
-/*
- * insert a instruction at slot in bundle
- */
-void
-obj_ia64_ins_insert_in_bundle(Elf64_Addr *bundle, Elf64_Xword slot, Elf64_Xword ins)
-{
- Elf64_Xword i;
- Elf64_Xword in = ins & 0x1ffffffffff;
-
- switch (slot)
- {
- case 0 :
- i = *bundle & 0xffffc0000000001f;
- *bundle = i | (in << 5);
- break;
-
- case 1 :
- i = *bundle & 0x00003fffffffffff;
- *bundle = i | (in << 46);
-
- ++bundle;
- i = *bundle & 0xffffffffff800000;
- *bundle = i | (in >> 18);
- break;
-
- case 2 :
- ++bundle;
- i = *bundle & 0x00000000007fffff;
- *bundle = i | (in << 23);
- break;
- }
-}
-
-/*
- * add a immediate 14 value to the instruction at slot in bundle
- */
-enum obj_reloc
-obj_ia64_ins_imm14(Elf64_Xword v, Elf64_Addr *bundle, Elf64_Xword slot)
-{
- Elf64_Xword ins;
-
- ins = obj_ia64_ins_extract_from_bundle(bundle, slot);
- ins &= 0xffffffee07f01fff;
- ins |= ((v & 0x2000) << 23) | ((v & 0x1f80) << 20) | ((v & 0x007f) << 13);
- obj_ia64_ins_insert_in_bundle(bundle, slot, ins);
- if (((Elf64_Sxword) v > 8191) || ((Elf64_Sxword) v < -8192))
- return obj_reloc_overflow;
- return obj_reloc_ok;
-}
-
-/*
- * add a immediate 22 value to the instruction at slot in bundle
- */
-enum obj_reloc
-obj_ia64_ins_imm22(Elf64_Xword v, Elf64_Addr *bundle, Elf64_Xword slot)
-{
- Elf64_Xword ins;
-
- ins = obj_ia64_ins_extract_from_bundle(bundle, slot);
- ins &= 0xffffffe000301fff;
- ins |= ((v & 0x200000) << 15) | ((v & 0x1f0000) << 6) |
- ((v & 0x00ff80) << 20) | ((v & 0x00007f) << 13);
- obj_ia64_ins_insert_in_bundle(bundle, slot, ins);
- if (((Elf64_Sxword) v > 2097151) || ((Elf64_Sxword) v < -2097152))
- return obj_reloc_overflow;
- return obj_reloc_ok;
-}
-
-/*
- * add a immediate 21 value (form 1) to the instruction at slot in bundle
- */
-enum obj_reloc
-obj_ia64_ins_pcrel21b(Elf64_Xword v, Elf64_Addr *bundle, Elf64_Xword slot)
-{
- Elf64_Xword ins;
-
- ins = obj_ia64_ins_extract_from_bundle(bundle, slot);
- ins &= 0xffffffee00001fff;
- ins |= ((v & 0x1000000) << 12) | ((v & 0x0fffff0) << 9);
- obj_ia64_ins_insert_in_bundle(bundle, slot, ins);
- return obj_reloc_ok;
-}
-
-/*
- * add a immediate 21 value (form 2) to the instruction at slot in bundle
- */
-enum obj_reloc
-obj_ia64_ins_pcrel21m(Elf64_Xword v, Elf64_Addr *bundle, Elf64_Xword slot)
-{
- Elf64_Xword ins;
-
- ins = obj_ia64_ins_extract_from_bundle(bundle, slot);
- ins &= 0xffffffee000fe03f;
- ins |= ((v & 0x1000000) << 12) | ((v & 0x0fff800) << 9) |
- ((v & 0x00007f0) << 2);
- obj_ia64_ins_insert_in_bundle(bundle, slot, ins);
- return obj_reloc_ok;
-}
-
-/*
- * add a immediate 21 value (form 3) to the instruction at slot in bundle
- */
-enum obj_reloc
-obj_ia64_ins_pcrel21f(Elf64_Xword v, Elf64_Addr *bundle, Elf64_Xword slot)
-{
- Elf64_Xword ins;
-
- ins = obj_ia64_ins_extract_from_bundle(bundle, slot);
- ins &= 0xffffffeffc00003f;
- ins |= ((v & 0x1000000) << 12) | ((v & 0x0fffff0) << 2);
- obj_ia64_ins_insert_in_bundle(bundle, slot, ins);
- return obj_reloc_ok;
-}
-
-/*
- * add a immediate 64 value to the instruction at slot in bundle
- */
-enum obj_reloc
-obj_ia64_ins_imm64(Elf64_Xword v, Elf64_Addr *bundle, Elf64_Xword slot)
-{
- Elf64_Xword ins;
-
- assert(slot == 2);
-
- ins = obj_ia64_ins_extract_from_bundle(bundle, slot);
- ins &= 0xffffffe000101fff;
- ins |= ((v & 0x8000000000000000) >> 27) | ((v & 0x0000000000200000)) |
- ((v & 0x00000000001f0000) << 6) | ((v & 0x000000000000ff80) << 20) |
- ((v & 0x000000000000007f) << 13);
- obj_ia64_ins_insert_in_bundle(bundle, slot, ins);
- obj_ia64_ins_insert_in_bundle(bundle, --slot, ((v & 0x7fffffffffc00000) >> 22));
- return obj_reloc_ok;
-}
-
-/*
- * create a plt entry
- */
-enum obj_reloc
-obj_ia64_generate_plt(Elf64_Addr v,
- Elf64_Addr gp,
- ia64_file_t *ifile,
- ia64_symbol_t *isym,
- ia64_plt_t *pltent)
-{
- *(Elf64_Addr *)(ifile->pltd->contents + pltent->data_offset) = v;
- if (isym->root.secidx <= SHN_HIRESERVE)
- {
- /* local entry */
- *(Elf64_Addr *)(ifile->pltd->contents + pltent->data_offset + 8) = gp;
- memcpy((Elf64_Addr *)(ifile->pltt->contents + pltent->text_offset),
- ia64_plt_local, sizeof(ia64_plt_local));
- }
- else
- {
- /* external entry */
- memcpy((Elf64_Addr *)(ifile->pltt->contents + pltent->text_offset),
- ia64_plt_extern, sizeof(ia64_plt_extern));
- }
- return obj_ia64_ins_imm22(
- (ifile->pltd->header.sh_addr + pltent->data_offset - gp),
- (Elf64_Addr *)(ifile->pltt->contents + pltent->text_offset), 0);
-}
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- ia64_file_t *f;
- f = xmalloc(sizeof(*f));
- f->got = NULL;
- f->opd = NULL;
- f->pltt = NULL;
- f->pltd = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- ia64_symbol_t *sym;
- sym = xmalloc(sizeof(*sym));
- sym->gotent = NULL;
- sym->opdent = NULL;
- sym->pltent = NULL;
- return &sym->root;
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- switch (sec->header.sh_type)
- {
- case SHT_IA_64_EXT :
- sec->contents = NULL;
- break;
-
- case SHT_IA_64_UNWIND :
- if (sec->header.sh_size > 0)
- {
- sec->contents = xmalloc(sec->header.sh_size);
- gzf_lseek(fp, sec->header.sh_offset, SEEK_SET);
- if (gzf_read(fp, sec->contents, sec->header.sh_size) != sec->header.sh_size)
- {
- error("error reading ELF section data: %m");
- return -1;
- }
- }
- else
- sec->contents = NULL;
- break;
-
- default:
- error("Unknown section header type: %08x", sec->header.sh_type);
- return -1;
- }
- return 0;
-}
-
-int
-arch_create_got(struct obj_file *f)
-{
- ia64_file_t *ifile = (ia64_file_t *)f;
- int i;
- int n;
- int got_offset = 0;
- int opd_offset = 32;
- int plt_text_offset = 0;
- int plt_data_offset = 0;
-
- n = ifile->root.header.e_shnum;
- for (i = 0; i < n; ++i)
- {
- struct obj_section *relsec, *symsec, *strsec;
- Elf64_Rela *rel, *relend;
- Elf64_Sym *symtab;
- const char *strtab;
-
- relsec = ifile->root.sections[i];
- if (relsec->header.sh_type != SHT_RELA)
- continue;
-
- symsec = ifile->root.sections[relsec->header.sh_link];
- strsec = ifile->root.sections[symsec->header.sh_link];
-
- rel = (Elf64_Rela *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(Elf64_Rela));
- symtab = (Elf64_Sym *)symsec->contents;
- strtab = (const char *)strsec->contents;
-
- for (; rel < relend; ++rel)
- {
- int need_got = FALSE;
- int need_opd = FALSE;
- int need_plt = FALSE;
-
- switch (ELF64_R_TYPE(rel->r_info))
- {
- default:
- continue;
-
- case R_IA64_FPTR64I : /* @fptr(sym + add), mov imm64 */
- case R_IA64_FPTR32LSB : /* @fptr(sym + add), data4 LSB */
- case R_IA64_FPTR64LSB : /* @fptr(sym + add), data8 LSB */
- need_opd = TRUE;
- break;
-
- case R_IA64_LTOFF22 : /* @ltoff(sym + add), add imm22 */
- case R_IA64_LTOFF22X :
- case R_IA64_LTOFF64I : /* @ltoff(sym + add), mov imm64 */
- need_got = TRUE;
- break;
-
- case R_IA64_LTOFF_FPTR22 : /* @ltoff(@fptr(s+a)), imm22 */
- case R_IA64_LTOFF_FPTR64I : /* @ltoff(@fptr(s+a)), imm64 */
- case R_IA64_LTOFF_FPTR32LSB :
- case R_IA64_LTOFF_FPTR64LSB :
- need_got = TRUE;
- need_opd = TRUE;
- break;
-
- case R_IA64_PLTOFF22 : /* @pltoff(sym + add), add imm22 */
- case R_IA64_PLTOFF64I : /* @pltoff(sym + add), mov imm64 */
- case R_IA64_PLTOFF64LSB : /* @pltoff(sym + add), data8 LSB */
-
- case R_IA64_PCREL21B : /* @pcrel(sym + add), ptb, call */
- case R_IA64_PCREL21M : /* @pcrel(sym + add), chk.s */
- case R_IA64_PCREL21F : /* @pcrel(sym + add), fchkf */
- need_plt = TRUE;
- break;
- }
-
- if (need_got || need_opd || need_plt)
- {
- ia64_symbol_t *isym;
- int local;
-
- obj_find_relsym(isym, f, f, rel, symtab, strtab);
- local = isym->root.secidx <= SHN_HIRESERVE;
-
- if (need_plt)
- {
- ia64_plt_t *plt;
-
- for (plt = isym->pltent; plt != NULL; plt = plt->next)
- if (plt->addend == rel->r_addend)
- break;
- if (plt == NULL)
- {
- plt = (ia64_plt_t *) xmalloc(sizeof(ia64_plt_t));
- plt->next = isym->pltent;
- plt->addend = rel->r_addend;
- plt->text_offset = plt_text_offset;
- plt->data_offset = plt_data_offset;
- plt->reloc_done = FALSE;
- isym->pltent = plt;
- if (local)
- {
- plt_text_offset += sizeof(ia64_plt_local);
- plt_data_offset += 16;
- }
- else
- {
- plt_text_offset += sizeof(ia64_plt_extern);
- plt_data_offset += 8;
- }
- need_plt = FALSE;
- }
- }
- if (need_got)
- {
- ia64_got_t *got;
-
- for (got = isym->gotent; got != NULL; got = got->next)
- if (got->addend == rel->r_addend)
- break;
- if (got == NULL)
- {
- got = (ia64_got_t *) xmalloc(sizeof(ia64_got_t));
- got->next = isym->gotent;
- got->addend = rel->r_addend;
- got->offset = got_offset;
- got->reloc_done = FALSE;
- isym->gotent = got;
- got_offset += 8;
- need_got = FALSE;
- }
- }
- if (need_opd && local)
- {
- ia64_opd_t *opd;
-
- if (isym->opdent == NULL)
- {
- opd = (ia64_opd_t *) xmalloc(sizeof(ia64_opd_t));
- opd->offset = opd_offset;
- opd->reloc_done = FALSE;
- isym->opdent = opd;
- opd_offset += 16;
- need_opd = FALSE;
- }
- }
- }
- }
- }
-
- ifile->got = obj_create_alloced_section(f, ".got", 8, got_offset,
- SHF_WRITE | SHF_IA_64_SHORT);
- assert(ifile->got != NULL);
-
- ifile->opd = obj_create_alloced_section(f, ".opd", 16, opd_offset,
- SHF_WRITE | SHF_IA_64_SHORT);
- assert(ifile->opd != NULL);
-
- if (plt_text_offset > 0)
- {
- ifile->pltt = obj_create_alloced_section(f, ".plt", 16,
- plt_text_offset,
- SHF_WRITE | SHF_IA_64_SHORT);
- ifile->pltd = obj_create_alloced_section(f, ".IA_64.pltoff", 16,
- plt_data_offset,
- SHF_WRITE | SHF_IA_64_SHORT);
- assert(ifile->pltt != NULL);
- assert(ifile->pltd != NULL);
- }
-
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf64_Addr base)
-{
- ia64_file_t *ifile = (ia64_file_t *)f;
- Elf64_Addr min_addr = (Elf64_Addr) -1;
- Elf64_Addr max_addr = 0;
- Elf64_Addr min_short_addr = (Elf64_Addr) -1;
- Elf64_Addr max_short_addr = 0;
- Elf64_Addr gp;
- Elf64_Addr text = (Elf64_Addr) -1;
- Elf64_Addr data = (Elf64_Addr) -1;
- Elf64_Addr bss = (Elf64_Addr) -1;
- int n = f->header.e_shnum;
- int i;
-
- /*
- * Finalize the addresses of the sections, find the min and max
- * address of all sections marked short, and collect min and max
- * address of any type, for use in selecting a nice gp.
- *
- * The algorithm used for selecting set the GP value was taken from
- * the ld/bfd code contributed by David Mosberger-Tang <davidm@hpl.hp.com>
- */
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- {
- Elf64_Shdr *header = &f->sections[i]->header;
- Elf64_Addr lo;
- Elf64_Addr hi;
-
- header->sh_addr += base;
- if (header->sh_flags & SHF_ALLOC)
- {
- lo = header->sh_addr;
- hi = header->sh_addr + header->sh_size;
- if (hi < lo)
- hi = (Elf64_Addr) -1;
-
- if (min_addr > lo)
- min_addr = lo;
- if (max_addr < hi)
- max_addr = hi;
- if (header->sh_flags & SHF_IA_64_SHORT)
- {
- if (min_short_addr > lo)
- min_short_addr = lo;
- if (max_short_addr < hi)
- max_short_addr = hi;
- }
- if ((header->sh_type & SHT_NOBITS) && (lo < bss))
- bss = lo;
- else if ((header->sh_flags & SHF_EXECINSTR) && (lo < text))
- text = lo;
- else if (lo < data)
- data = lo;
- }
- }
- /* Pick a sensible value for gp */
-
- /* Start with just the address of the .got */
- gp = ifile->got->header.sh_addr;
-
- /*
- * If it is possible to address the entire image, but we
- * don't with the choice above, adjust.
- */
- if ((max_addr - min_addr < 0x400000) && (max_addr - gp <= 0x200000) &&
- (gp - min_addr > 0x200000))
- {
- gp = min_addr + 0x200000;
- }
- else if (max_short_addr != 0)
- {
- /* If we don't cover all the short data, adjust */
- if (max_short_addr - gp >= 0x200000)
- gp = min_short_addr + 0x200000;
-
- /* If we're addressing stuff past the end, adjust back */
- if (gp > max_addr)
- gp = max_addr - 0x200000 + 8;
- }
-
- /*
- * Validate whether all SHF_IA_64_SHORT sections are within
- * range of the chosen GP.
- */
- if (max_short_addr != 0)
- {
- if (max_short_addr - min_short_addr >= 0x400000)
- {
- error("short data segment overflowed (0x%lx >= 0x400000)",
- (unsigned long)(max_short_addr - min_short_addr));
- return 0;
- }
- else if (((gp > min_short_addr) && (gp - min_short_addr > 0x200000)) ||
- ((gp < max_short_addr) && (max_short_addr - gp >= 0x200000)))
- {
- error("GP does not cover short data segment");
- return 0;
- }
- }
- ifile->gp = gp;
- ifile->text = text;
- ifile->data = data;
- ifile->bss = bss;
- return 1;
-}
-
-/* Targets can be unaligned, use memcpy instead of assignment */
-#define COPY_64LSB(loc, v) \
- do { \
- Elf64_Xword reloc = (v); \
- memcpy((void *)(loc), &reloc, 8); \
- } while(0)
-#define COPY_32LSB(loc, v) \
- do { \
- Elf32_Xword reloc = (v); \
- memcpy((void *)(loc), &reloc, 4); \
- if ((v) != reloc) \
- ret = obj_reloc_overflow; \
- } while(0)
-
-enum obj_reloc
-arch_apply_relocation(struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf64_Rela *rel,
- Elf64_Addr v)
-{
- ia64_file_t *ifile = (ia64_file_t *) f;
- ia64_symbol_t *isym = (ia64_symbol_t *) sym;
-
- Elf64_Addr loc = (Elf64_Addr)(targsec->contents + rel->r_offset);
- Elf64_Addr dot = (targsec->header.sh_addr + rel->r_offset) & ~0x03;
-
- Elf64_Addr got = ifile->got->header.sh_addr;
- Elf64_Addr gp = ifile->gp;
-
- Elf64_Addr *bundle = (Elf64_Addr *)(loc & ~0x03);
- Elf64_Xword slot = loc & 0x03;
-
- Elf64_Xword r_info = ELF64_R_TYPE(rel->r_info);
-
- enum obj_reloc ret = obj_reloc_ok;
-
- /* We cannot load modules compiled with -mconstant-gp */
-#ifndef EF_IA_64_CONS_GP
-#define EF_IA_64_CONS_GP 0x00000040
-#endif
-#ifndef EF_IA_64_NOFUNCDESC_CONS_GP
-#define EF_IA_64_NOFUNCDESC_CONS_GP 0x00000080
-#endif
- if (f->header.e_flags & (EF_IA_64_CONS_GP | EF_IA_64_NOFUNCDESC_CONS_GP))
- return obj_reloc_constant_gp;
-
- switch (r_info)
- {
- case R_IA64_NONE : /* none */
- case R_IA64_LDXMOV : /* Use of LTOFF22X. */
- break;
-
- case R_IA64_IMM14 : /* symbol + addend, add imm14 */
- ret = obj_ia64_ins_imm14(v, bundle, slot);
- break;
-
- case R_IA64_IMM22 : /* symbol + addend, add imm22 */
- ret = obj_ia64_ins_imm22(v, bundle, slot);
- break;
-
- case R_IA64_IMM64 : /* symbol + addend, movl imm64 */
- ret = obj_ia64_ins_imm64(v, bundle, slot);
- break;
-
- case R_IA64_DIR32LSB : /* symbol + addend, data4 LSB */
- COPY_32LSB(loc, v);
- break;
-
- case R_IA64_DIR64LSB : /* symbol + addend, data8 LSB */
- COPY_64LSB(loc, v);
- break;
-
- case R_IA64_GPREL22 : /* @gprel(sym + add), add imm22 */
- v -= gp;
- ret = obj_ia64_ins_imm22(v, bundle, slot);
- break;
-
- case R_IA64_GPREL64I : /* @gprel(sym + add), mov imm64 */
- v -= gp;
- ret = obj_ia64_ins_imm64(v, bundle, slot);
- break;
-
- case R_IA64_GPREL32LSB : /* @gprel(sym + add), data4 LSB */
- COPY_32LSB(loc, v-gp);
- break;
-
- case R_IA64_GPREL64LSB : /* @gprel(sym + add), data8 LSB */
- COPY_64LSB(loc, v-gp);
- break;
-
- case R_IA64_LTOFF22 : /* @ltoff(sym + add), add imm22 */
- case R_IA64_LTOFF22X : /* LTOFF22, relaxable. */
- case R_IA64_LTOFF64I : /* @ltoff(sym + add), mov imm64 */
- {
- ia64_got_t *ge;
-
- assert(isym != NULL);
- for (ge = isym->gotent; ge != NULL && ge->addend != rel->r_addend; )
- ge = ge->next;
- assert(ge != NULL);
- if (!ge->reloc_done)
- {
- ge->reloc_done = TRUE;
- *(Elf64_Addr *)(ifile->got->contents + ge->offset) = v;
- }
- v = got + ge->offset - gp;
- if (r_info == R_IA64_LTOFF64I)
- ret = obj_ia64_ins_imm64(v, bundle, slot);
- else
- ret = obj_ia64_ins_imm22(v, bundle, slot);
- }
- break;
-
- case R_IA64_PLTOFF22 : /* @pltoff(sym + add), add imm22 */
- case R_IA64_PLTOFF64I : /* @pltoff(sym + add), mov imm64 */
- case R_IA64_PLTOFF64LSB : /* @pltoff(sym + add), data8 LSB */
- {
- ia64_plt_t *pe;
-
- assert(isym != NULL);
- for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend; )
- pe = pe->next;
- assert(pe != NULL);
- if (!pe->reloc_done)
- {
- pe->reloc_done = TRUE;
- ret = obj_ia64_generate_plt(v, gp, ifile, isym, pe);
- }
- v = ifile->pltt->header.sh_addr + pe->text_offset - gp;
- switch (r_info)
- {
- case R_IA64_PLTOFF22 :
- ret = obj_ia64_ins_imm22(v, bundle, slot);
- break;
-
- case R_IA64_PLTOFF64I :
- ret = obj_ia64_ins_imm64(v, bundle, slot);
- break;
-
- case R_IA64_PLTOFF64LSB :
- COPY_64LSB(loc, v);
- break;
- }
- }
- break;
-
- case R_IA64_FPTR64I : /* @fptr(sym + add), mov imm64 */
- case R_IA64_FPTR32LSB : /* @fptr(sym + add), data4 LSB */
- case R_IA64_FPTR64LSB : /* @fptr(sym + add), data8 LSB */
- assert(isym != NULL);
- if (isym->root.secidx <= SHN_HIRESERVE)
- {
- assert(isym->opdent != NULL);
- if (!isym->opdent->reloc_done)
- {
- isym->opdent->reloc_done = TRUE;
- *(Elf64_Addr *)(ifile->opd->contents + isym->opdent->offset) = v;
- *(Elf64_Addr *)(ifile->opd->contents + isym->opdent->offset + 8) = gp;
- }
- v = ifile->opd->header.sh_addr + isym->opdent->offset;
- }
- switch (r_info)
- {
- case R_IA64_FPTR64I :
- ret = obj_ia64_ins_imm64(v, bundle, slot);
- break;
-
- case R_IA64_FPTR32LSB :
- COPY_32LSB(loc, v);
- break;
-
- case R_IA64_FPTR64LSB : /* @fptr(sym + add), data8 LSB */
- /* Target can be unaligned */
- COPY_64LSB(loc, v);
- break;
- }
- break;
-
- case R_IA64_PCREL21B : /* @pcrel(sym + add), ptb, call */
- case R_IA64_PCREL21M : /* @pcrel(sym + add), chk.s */
- case R_IA64_PCREL21F : /* @pcrel(sym + add), fchkf */
- assert(isym != NULL);
- if ((isym->root.secidx > SHN_HIRESERVE) ||
- ((Elf64_Sxword) (v - dot) > 16777215) ||
- ((Elf64_Sxword) (v - dot) < -16777216))
- {
- ia64_plt_t *pe;
-
- for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend; )
- pe = pe->next;
- assert(pe != NULL);
- if (!pe->reloc_done)
- {
- pe->reloc_done = TRUE;
- ret = obj_ia64_generate_plt(v, gp, ifile, isym, pe);
- }
- v = ifile->pltt->header.sh_addr + pe->text_offset;
- }
- v -= dot;
- switch (r_info)
- {
- case R_IA64_PCREL21B :
- ret = obj_ia64_ins_pcrel21b(v, bundle, slot);
- break;
-
- case R_IA64_PCREL21M :
- ret = obj_ia64_ins_pcrel21m(v, bundle, slot);
- break;
-
- case R_IA64_PCREL21F :
- ret = obj_ia64_ins_pcrel21f(v, bundle, slot);
- break;
- }
- break;
-
- case R_IA64_PCREL32LSB : /* @pcrel(sym + add), data4 LSB */
- COPY_32LSB(loc, v-dot);
- break;
-
- case R_IA64_PCREL64LSB : /* @pcrel(sym + add), data8 LSB */
- COPY_64LSB(loc, v-dot);
- break;
-
- case R_IA64_LTOFF_FPTR22 : /* @ltoff(@fptr(s+a)), imm22 */
- case R_IA64_LTOFF_FPTR64I : /* @ltoff(@fptr(s+a)), imm64 */
- case R_IA64_LTOFF_FPTR32LSB : /* @ltoff(@fptr(s+a)), data4 */
- case R_IA64_LTOFF_FPTR64LSB : /* @ltoff(@fptr(s+a)), data8 */
- {
- ia64_got_t *ge;
-
- assert(isym != NULL);
- if (isym->root.secidx <= SHN_HIRESERVE)
- {
- assert(isym->opdent != NULL);
- if (!isym->opdent->reloc_done)
- {
- isym->opdent->reloc_done = TRUE;
- *(Elf64_Addr *)(ifile->opd->contents + isym->opdent->offset) = v;
- *(Elf64_Addr *)(ifile->opd->contents + isym->opdent->offset + 8) = gp;
- }
- v = ifile->opd->header.sh_addr + isym->opdent->offset;
- }
- for (ge = isym->gotent; ge != NULL && ge->addend != rel->r_addend; )
- ge = ge->next;
- assert(ge != NULL);
- if (!ge->reloc_done)
- {
- ge->reloc_done = TRUE;
- *(Elf64_Addr *)(ifile->got->contents + ge->offset) = v;
- }
- v = got + ge->offset - gp;
- switch (r_info)
- {
- case R_IA64_LTOFF_FPTR22 :
- ret = obj_ia64_ins_imm22(v, bundle, slot);
- break;
-
- case R_IA64_LTOFF_FPTR64I :
- ret = obj_ia64_ins_imm64(v, bundle, slot);
- break;
-
- case R_IA64_LTOFF_FPTR32LSB :
- COPY_32LSB(loc, v);
- break;
-
- case R_IA64_LTOFF_FPTR64LSB :
- COPY_64LSB(loc, v);
- break;
- }
- }
- break;
-
- case R_IA64_SEGREL32LSB : /* @segrel(sym + add), data4 LSB */
- case R_IA64_SEGREL64LSB : /* @segrel(sym + add), data8 LSB */
- /* Only one segment for modules, see segment_base in arch_archdata */
- v -= f->sections[1]->header.sh_addr;
- if (r_info == R_IA64_SEGREL32LSB)
- COPY_32LSB(loc, v);
- else
- COPY_64LSB(loc, v);
- break;
-
- case R_IA64_SECREL32LSB : /* @secrel(sym + add), data4 LSB */
- COPY_32LSB(loc, targsec->header.sh_addr - v);
- break;
-
- case R_IA64_SECREL64LSB : /* @secrel(sym + add), data8 LSB */
- COPY_64LSB(loc, targsec->header.sh_addr - v);
- break;
-
- /*
- * We don't handle the big-endian relocates
- *
- * R_IA64_DIR32MSB symbol + addend, data4 MSB
- * R_IA64_DIR64MSB symbol + addend, data8 MSB
- * R_IA64_GPREL32MSB @gprel(sym + add), data4 MSB
- * R_IA64_GPREL64MSB @gprel(sym + add), data8 MSB
- * R_IA64_PLTOFF64MSB @pltoff(sym + add), data8 MSB
- * R_IA64_FPTR32MSB @fptr(sym + add), data4 MSB
- * R_IA64_FPTR64MSB @fptr(sym + add), data8 MSB
- * R_IA64_PCREL32MSB @pcrel(sym + add), data4 MSB
- * R_IA64_PCREL64MSB @pcrel(sym + add), data8 MSB
- * R_IA64_SEGREL32MSB @segrel(sym + add), data4 MSB
- * R_IA64_SEGREL64MSB @segrel(sym + add), data8 MSB
- * R_IA64_SECREL32MSB @secrel(sym + add), data4 MSB
- * R_IA64_SECREL64MSB @secrel(sym + add), data8 MSB
- * R_IA64_REL32MSB data 4 + REL
- * R_IA64_REL64MSB data 8 + REL
- * R_IA64_LTV32MSB symbol + addend, data4 MSB
- * R_IA64_LTV64MSB symbol + addend, data8 MSB
- * R_IA64_IPLTMSB dynamic reloc, imported PLT, MSB
- */
- default:
- case R_IA64_REL32LSB : /* data 4 + REL */
- case R_IA64_REL64LSB : /* data 8 + REL */
- case R_IA64_LTV32LSB : /* symbol + addend, data4 LSB */
- case R_IA64_LTV64LSB : /* symbol + addend, data8 LSB */
- case R_IA64_IPLTLSB : /* dynamic reloc, imported PLT, LSB */
- ret = obj_reloc_unhandled;
- break;
- }
- return ret;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- ia64_file_t *ifile = (ia64_file_t *)f;
- Elf64_Addr *opd = (Elf64_Addr *)(ifile->opd->contents);
-
- if ((opd[0] = mod->init) != 0)
- {
- opd[1] = ifile->gp;
- mod->init = ifile->opd->header.sh_addr;
- }
-
- if ((opd[2] = mod->cleanup) != 0)
- {
- opd[3] = ifile->gp;
- mod->cleanup = ifile->opd->header.sh_addr + 16;
- }
-
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *f, struct obj_section *archdata_sec)
-{
- ia64_file_t *ifile = (ia64_file_t *)f;
- struct archdata {
- unsigned tgt_long unw_table;
- unsigned tgt_long segment_base;
- unsigned tgt_long unw_start;
- unsigned tgt_long unw_end;
- unsigned tgt_long gp;
- } *ad;
- int i;
- struct obj_section *sec;
-
- free(archdata_sec->contents);
- archdata_sec->contents = xmalloc(sizeof(struct archdata));
- memset(archdata_sec->contents, 0, sizeof(struct archdata));
- archdata_sec->header.sh_size = sizeof(struct archdata);
-
- ad = (struct archdata *)(archdata_sec->contents);
- ad->gp = ifile->gp;
- ad->unw_start = 0;
- ad->unw_end = 0;
- ad->unw_table = 0;
- ad->segment_base = f->sections[1]->header.sh_addr;
- for (i = 0; i < f->header.e_shnum; ++i)
- {
- sec = f->sections[i];
- if (sec->header.sh_type == SHT_IA_64_UNWIND)
- {
- ad->unw_start = sec->header.sh_addr;
- ad->unw_end = sec->header.sh_addr + sec->header.sh_size;
- break;
- }
- }
-
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_kallsyms.c b/mdk-stage1/insmod-modutils/obj/obj_kallsyms.c
deleted file mode 100644
index 1836141e9..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_kallsyms.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/* Build a section containing all non-stack symbols.
- Copyright 2000 Keith Owens <kaos@ocs.com.au>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <malloc.h>
-
-#include "obj.h"
-#include "kallsyms.h"
-#include "util.h"
-
-/*======================================================================*/
-
-#define EXPAND_BY 4096 /* Arbitrary */
-
-/* Append a string to the big list of strings */
-
-static void
-append_string (const char *s, char **strings,
- ElfW(Word) *strings_size, ElfW(Word) *strings_left)
-{
- size_t l = strlen(s) + 1;
- while (l > *strings_left) {
- *strings = xrealloc(*strings, *strings_size += EXPAND_BY);
- *strings_left += EXPAND_BY;
- }
- memcpy((char *)*strings+*strings_size-*strings_left, s, l);
- *strings_left -= l;
-}
-
-
-/* Append a symbol to the big list of symbols */
-
-static void
-append_symbol (const struct kallsyms_symbol *s,
- struct kallsyms_symbol **symbols,
- ElfW(Word) *symbols_size, ElfW(Word) *symbols_left)
-{
- size_t l = sizeof(*s);
- while (l > *symbols_left) {
- *symbols = xrealloc(*symbols, *symbols_size += EXPAND_BY);
- *symbols_left += EXPAND_BY;
- }
- memcpy((char *)*symbols+*symbols_size-*symbols_left, s, l);
- *symbols_left -= l;
-}
-
-/* qsort compare routine to sort symbols */
-
-static const char *sym_strings;
-
-static int
-symbol_compare (const void *a, const void *b)
-{
- struct kallsyms_symbol *c = (struct kallsyms_symbol *) a;
- struct kallsyms_symbol *d = (struct kallsyms_symbol *) b;
-
- if (c->symbol_addr > d->symbol_addr)
- return(1);
- if (c->symbol_addr < d->symbol_addr)
- return(-1);
- return(strcmp(sym_strings+c->name_off, sym_strings+d->name_off));
-}
-
-
-/* Extract all symbols from the input obj_file, ignore ones that are
- * no use for debugging, build an output obj_file containing only the
- * kallsyms section.
- *
- * The kallsyms section is a bit unusual. It deliberately has no
- * relocatable data, all "pointers" are represented as byte offsets
- * into the the section. This means it can be stored anywhere without
- * relocation problems. In particular it can be stored within a kernel
- * image, it can be stored separately from the kernel image, it can be
- * appended to a module just before loading, it can be stored in a
- * separate area etc.
- *
- * Format of the kallsyms section.
- *
- * Header:
- * Size of header.
- * Total size of kallsyms data, including strings.
- * Number of loaded sections.
- * Offset to first section entry from start of header.
- * Size of each section entry, excluding the name string.
- * Number of symbols.
- * Offset to first symbol entry from start of header.
- * Size of each symbol entry, excluding the name string.
- *
- * Section entry - one per loaded section.
- * Start of section[1].
- * Size of section.
- * Offset to name of section, from start of strings.
- * Section flags.
- *
- * Symbol entry - one per symbol in the input file[2].
- * Offset of section that owns this symbol, from start of section data.
- * Address of symbol within the real section[1].
- * Offset to name of symbol, from start of strings.
- *
- * Notes: [1] This is an exception to the "represent pointers as
- * offsets" rule, it is a value, not an offset. The start
- * address of a section or a symbol is extracted from the
- * obj_file data which may contain absolute or relocatable
- * addresses. If the addresses are relocatable then the
- * caller must adjust the section and/or symbol entries in
- * kallsyms after relocation.
- * [2] Only symbols that fall within loaded sections are stored.
- */
-
-int
-obj_kallsyms (struct obj_file *fin, struct obj_file **fout_result)
-{
- struct obj_file *fout;
- int i, loaded = 0, *fin_to_allsym_map;
- struct obj_section *isec, *osec;
- struct kallsyms_header *a_hdr;
- struct kallsyms_section *a_sec;
- ElfW(Off) sec_off;
- struct kallsyms_symbol *symbols = NULL, a_sym;
- ElfW(Word) symbols_size = 0, symbols_left = 0;
- char *strings = NULL, *p;
- ElfW(Word) strings_size = 0, strings_left = 0;
- ElfW(Off) file_offset;
- static char strtab[] = "\000" KALLSYMS_SEC_NAME;
-
- /* Create the kallsyms section. */
- fout = arch_new_file();
- memset(fout, 0, sizeof(*fout));
- fout->symbol_cmp = strcmp;
- fout->symbol_hash = obj_elf_hash;
- fout->load_order_search_start = &fout->load_order;
-
- /* Copy file characteristics from input file and modify to suit */
- memcpy(&fout->header, &fin->header, sizeof(fout->header));
- fout->header.e_type = ET_REL; /* Output is relocatable */
- fout->header.e_entry = 0; /* No entry point */
- fout->header.e_phoff = 0; /* No program header */
- file_offset = sizeof(fout->header); /* Step over Elf header */
- fout->header.e_shoff = file_offset; /* Section headers next */
- fout->header.e_phentsize = 0; /* No program header */
- fout->header.e_phnum = 0; /* No program header */
- fout->header.e_shnum = KALLSYMS_IDX+1; /* Initial, strtab, kallsyms */
- fout->header.e_shstrndx = KALLSYMS_IDX-1; /* strtab */
- file_offset += fout->header.e_shentsize * fout->header.e_shnum;
-
- /* Populate the section data for kallsyms itself */
- fout->sections = xmalloc(sizeof(*(fout->sections))*fout->header.e_shnum);
- memset(fout->sections, 0, sizeof(*(fout->sections))*fout->header.e_shnum);
-
- fout->sections[0] = osec = arch_new_section();
- memset(osec, 0, sizeof(*osec));
- osec->header.sh_type = SHT_NULL;
- osec->header.sh_link = SHN_UNDEF;
-
- fout->sections[KALLSYMS_IDX-1] = osec = arch_new_section();
- memset(osec, 0, sizeof(*osec));
- osec->name = ".strtab";
- osec->header.sh_type = SHT_STRTAB;
- osec->header.sh_link = SHN_UNDEF;
- osec->header.sh_offset = file_offset;
- osec->header.sh_size = sizeof(strtab);
- osec->contents = xmalloc(sizeof(strtab));
- memcpy(osec->contents, strtab, sizeof(strtab));
- file_offset += osec->header.sh_size;
-
- fout->sections[KALLSYMS_IDX] = osec = arch_new_section();
- memset(osec, 0, sizeof(*osec));
- osec->name = KALLSYMS_SEC_NAME;
- osec->header.sh_name = 1; /* Offset in strtab */
- osec->header.sh_type = SHT_PROGBITS; /* Load it */
- osec->header.sh_flags = SHF_ALLOC; /* Read only data */
- osec->header.sh_link = SHN_UNDEF;
- osec->header.sh_addralign = sizeof(ElfW(Word));
- file_offset = (file_offset + osec->header.sh_addralign - 1)
- & -(osec->header.sh_addralign);
- osec->header.sh_offset = file_offset;
-
- /* How many loaded sections are there? */
- for (i = 0; i < fin->header.e_shnum; ++i) {
- if (fin->sections[i]->header.sh_flags & SHF_ALLOC)
- ++loaded;
- }
-
- /* Initial contents, header + one entry per input section. No strings. */
- osec->header.sh_size = sizeof(*a_hdr) + loaded*sizeof(*a_sec);
- a_hdr = (struct kallsyms_header *) osec->contents =
- xmalloc(osec->header.sh_size);
- memset(osec->contents, 0, osec->header.sh_size);
- a_hdr->size = sizeof(*a_hdr);
- a_hdr->sections = loaded;
- a_hdr->section_off = a_hdr->size;
- a_hdr->section_size = sizeof(*a_sec);
- a_hdr->symbol_off = osec->header.sh_size;
- a_hdr->symbol_size = sizeof(a_sym);
- a_hdr->start = (ElfW(Addr))(~0);
-
- /* Map input section numbers to kallsyms section offsets. */
- sec_off = 0; /* Offset to first kallsyms section entry */
- fin_to_allsym_map = xmalloc(sizeof(*fin_to_allsym_map)*fin->header.e_shnum);
- for (i = 0; i < fin->header.e_shnum; ++i) {
- isec = fin->sections[i];
- if (isec->header.sh_flags & SHF_ALLOC) {
- fin_to_allsym_map[isec->idx] = sec_off;
- sec_off += a_hdr->section_size;
- }
- else
- fin_to_allsym_map[isec->idx] = -1; /* Ignore this section */
- }
-
- /* Copy the loaded section data. */
- a_sec = (struct kallsyms_section *) ((char *) a_hdr + a_hdr->section_off);
- for (i = 0; i < fin->header.e_shnum; ++i) {
- isec = fin->sections[i];
- if (!(isec->header.sh_flags & SHF_ALLOC))
- continue;
- a_sec->start = isec->header.sh_addr;
- a_sec->size = isec->header.sh_size;
- a_sec->flags = isec->header.sh_flags;
- a_sec->name_off = strings_size - strings_left;
- append_string(isec->name, &strings, &strings_size, &strings_left);
- if (a_sec->start < a_hdr->start)
- a_hdr->start = a_sec->start;
- if (a_sec->start+a_sec->size > a_hdr->end)
- a_hdr->end = a_sec->start+a_sec->size;
- ++a_sec;
- }
-
- /* Build the kallsyms symbol table from the symbol hashes. */
- for (i = 0; i < HASH_BUCKETS; ++i) {
- struct obj_symbol *sym = fin->symtab[i];
- for (sym = fin->symtab[i]; sym ; sym = sym->next) {
- if (!sym || sym->secidx >= fin->header.e_shnum)
- continue;
- if ((a_sym.section_off = fin_to_allsym_map[sym->secidx]) == -1)
- continue;
- if (strcmp(sym->name, "gcc2_compiled.") == 0 ||
- strncmp(sym->name, "__insmod_", 9) == 0)
- continue;
- a_sym.symbol_addr = sym->value;
- if (fin->header.e_type == ET_REL)
- a_sym.symbol_addr += fin->sections[sym->secidx]->header.sh_addr;
- a_sym.name_off = strings_size - strings_left;
- append_symbol(&a_sym, &symbols, &symbols_size, &symbols_left);
- append_string(sym->name, &strings, &strings_size, &strings_left);
- ++a_hdr->symbols;
- }
- }
- free(fin_to_allsym_map);
-
- /* Sort the symbols into ascending order by address and name */
- sym_strings = strings; /* For symbol_compare */
- qsort((char *) symbols, (unsigned) a_hdr->symbols,
- sizeof(* symbols), symbol_compare);
- sym_strings = NULL;
-
- /* Put the lot together */
- osec->header.sh_size = a_hdr->total_size =
- a_hdr->symbol_off +
- a_hdr->symbols*a_hdr->symbol_size +
- strings_size - strings_left;
- a_hdr = (struct kallsyms_header *) osec->contents =
- xrealloc(a_hdr, a_hdr->total_size);
- p = (char *)a_hdr + a_hdr->symbol_off;
- memcpy(p, symbols, a_hdr->symbols*a_hdr->symbol_size);
- free(symbols);
- p += a_hdr->symbols*a_hdr->symbol_size;
- a_hdr->string_off = p - (char *)a_hdr;
- memcpy(p, strings, strings_size - strings_left);
- free(strings);
-
- *fout_result = fout;
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_load.c b/mdk-stage1/insmod-modutils/obj/obj_load.c
deleted file mode 100644
index 62977acb7..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_load.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/* Elf file reader.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
- obj_free() added by Björn Ekwall <bj0rn@blox.se> March 1999
- Support for kallsyms Keith Owens <kaos@ocs.com.au> April 2000
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <alloca.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "obj.h"
-#include "util.h"
-
-/*======================================================================*/
-
-struct obj_file *
-obj_load (int fp, Elf32_Half e_type, const char *filename)
-{
- struct obj_file *f;
- ElfW(Shdr) *section_headers;
- int shnum, i;
- char *shstrtab;
-
- /* Read the file header. */
-
- f = arch_new_file();
- memset(f, 0, sizeof(*f));
- f->symbol_cmp = strcmp;
- f->symbol_hash = obj_elf_hash;
- f->load_order_search_start = &f->load_order;
-
- gzf_lseek(fp, 0, SEEK_SET);
- if (gzf_read(fp, &f->header, sizeof(f->header)) != sizeof(f->header))
- {
- error("cannot read ELF header from %s", filename);
- return NULL;
- }
-
- if (f->header.e_ident[EI_MAG0] != ELFMAG0
- || f->header.e_ident[EI_MAG1] != ELFMAG1
- || f->header.e_ident[EI_MAG2] != ELFMAG2
- || f->header.e_ident[EI_MAG3] != ELFMAG3)
- {
- error("%s is not an ELF file", filename);
- return NULL;
- }
- if (f->header.e_ident[EI_CLASS] != ELFCLASSM
- || f->header.e_ident[EI_DATA] != ELFDATAM
- || f->header.e_ident[EI_VERSION] != EV_CURRENT
- || !MATCH_MACHINE(f->header.e_machine))
- {
- error("ELF file %s not for this architecture", filename);
- return NULL;
- }
- if (f->header.e_type != e_type && e_type != ET_NONE)
- {
- switch (e_type) {
- case ET_REL:
- error("ELF file %s not a relocatable object", filename);
- break;
- case ET_EXEC:
- error("ELF file %s not an executable object", filename);
- break;
- default:
- error("ELF file %s has wrong type, expecting %d got %d",
- filename, e_type, f->header.e_type);
- break;
- }
- return NULL;
- }
-
- /* Read the section headers. */
-
- if (f->header.e_shentsize != sizeof(ElfW(Shdr)))
- {
- error("section header size mismatch %s: %lu != %lu",
- filename,
- (unsigned long)f->header.e_shentsize,
- (unsigned long)sizeof(ElfW(Shdr)));
- return NULL;
- }
-
- shnum = f->header.e_shnum;
- f->sections = xmalloc(sizeof(struct obj_section *) * shnum);
- memset(f->sections, 0, sizeof(struct obj_section *) * shnum);
-
- section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
- gzf_lseek(fp, f->header.e_shoff, SEEK_SET);
- if (gzf_read(fp, section_headers, sizeof(ElfW(Shdr))*shnum) != sizeof(ElfW(Shdr))*shnum)
- {
- error("error reading ELF section headers %s: %m", filename);
- return NULL;
- }
-
- /* Read the section data. */
-
- for (i = 0; i < shnum; ++i)
- {
- struct obj_section *sec;
-
- f->sections[i] = sec = arch_new_section();
- memset(sec, 0, sizeof(*sec));
-
- sec->header = section_headers[i];
- sec->idx = i;
-
- switch (sec->header.sh_type)
- {
- case SHT_NULL:
- case SHT_NOTE:
- case SHT_NOBITS:
- /* ignore */
- break;
-
- case SHT_PROGBITS:
- case SHT_SYMTAB:
- case SHT_STRTAB:
- case SHT_RELM:
- if (sec->header.sh_size > 0)
- {
- sec->contents = xmalloc(sec->header.sh_size);
- gzf_lseek(fp, sec->header.sh_offset, SEEK_SET);
- if (gzf_read(fp, sec->contents, sec->header.sh_size) != sec->header.sh_size)
- {
- error("error reading ELF section data %s: %m", filename);
- return NULL;
- }
- }
- else
- sec->contents = NULL;
- break;
-
-#if SHT_RELM == SHT_REL
- case SHT_RELA:
- if (sec->header.sh_size) {
- error("RELA relocations not supported on this architecture %s", filename);
- return NULL;
- }
- break;
-#else
- case SHT_REL:
- if (sec->header.sh_size) {
- error("REL relocations not supported on this architecture %s", filename);
- return NULL;
- }
- break;
-#endif
-
- default:
- if (sec->header.sh_type >= SHT_LOPROC)
- {
- if (arch_load_proc_section(sec, fp) < 0)
- return NULL;
- break;
- }
-
- error("can't handle sections of type %ld %s",
- (long)sec->header.sh_type, filename);
- return NULL;
- }
- }
-
- /* Do what sort of interpretation as needed by each section. */
-
- shstrtab = f->sections[f->header.e_shstrndx]->contents;
-
- for (i = 0; i < shnum; ++i)
- {
- struct obj_section *sec = f->sections[i];
- sec->name = shstrtab + sec->header.sh_name;
- }
-
- for (i = 0; i < shnum; ++i)
- {
- struct obj_section *sec = f->sections[i];
-
- /* .modinfo and .modstring should be contents only but gcc has no
- * attribute for that. The kernel may have marked these sections as
- * ALLOC, ignore the allocate bit.
- */
- if (strcmp(sec->name, ".modinfo") == 0 ||
- strcmp(sec->name, ".modstring") == 0)
- sec->header.sh_flags &= ~SHF_ALLOC;
-
- if (sec->header.sh_flags & SHF_ALLOC)
- obj_insert_section_load_order(f, sec);
-
- switch (sec->header.sh_type)
- {
- case SHT_SYMTAB:
- {
- unsigned long nsym, j;
- char *strtab;
- ElfW(Sym) *sym;
-
- if (sec->header.sh_entsize != sizeof(ElfW(Sym)))
- {
- error("symbol size mismatch %s: %lu != %lu",
- filename,
- (unsigned long)sec->header.sh_entsize,
- (unsigned long)sizeof(ElfW(Sym)));
- return NULL;
- }
-
- nsym = sec->header.sh_size / sizeof(ElfW(Sym));
- strtab = f->sections[sec->header.sh_link]->contents;
- sym = (ElfW(Sym) *) sec->contents;
-
- /* Allocate space for a table of local symbols. */
- j = f->local_symtab_size = sec->header.sh_info;
- f->local_symtab = xmalloc(j *= sizeof(struct obj_symbol *));
- memset(f->local_symtab, 0, j);
-
- /* Insert all symbols into the hash table. */
- for (j = 1, ++sym; j < nsym; ++j, ++sym)
- {
- const char *name;
- if (sym->st_name)
- name = strtab+sym->st_name;
- else
- name = f->sections[sym->st_shndx]->name;
-
- obj_add_symbol(f, name, j, sym->st_info, sym->st_shndx,
- sym->st_value, sym->st_size);
-
- }
- }
- break;
- }
- }
-
- /* second pass to add relocation data to symbols */
- for (i = 0; i < shnum; ++i)
- {
- struct obj_section *sec = f->sections[i];
- switch (sec->header.sh_type)
- {
- case SHT_RELM:
- {
- unsigned long nrel, j, nsyms;
- ElfW(RelM) *rel;
- struct obj_section *symtab;
- char *strtab;
- if (sec->header.sh_entsize != sizeof(ElfW(RelM)))
- {
- error("relocation entry size mismatch %s: %lu != %lu",
- filename,
- (unsigned long)sec->header.sh_entsize,
- (unsigned long)sizeof(ElfW(RelM)));
- return NULL;
- }
-
- nrel = sec->header.sh_size / sizeof(ElfW(RelM));
- rel = (ElfW(RelM) *) sec->contents;
- symtab = f->sections[sec->header.sh_link];
- nsyms = symtab->header.sh_size / symtab->header.sh_entsize;
- strtab = f->sections[symtab->header.sh_link]->contents;
-
- /* Save the relocate type in each symbol entry. */
- for (j = 0; j < nrel; ++j, ++rel)
- {
- struct obj_symbol *intsym;
- unsigned long symndx;
- symndx = ELFW(R_SYM)(rel->r_info);
- if (symndx)
- {
- if (symndx >= nsyms)
- {
- error("%s: Bad symbol index: %08lx >= %08lx",
- filename, symndx, nsyms);
- continue;
- }
-
- obj_find_relsym(intsym, f, f, rel, (ElfW(Sym) *)(symtab->contents), strtab);
- intsym->r_type = ELFW(R_TYPE)(rel->r_info);
- }
- }
- }
- break;
- }
- }
-
- f->filename = xstrdup(filename);
-
- return f;
-}
-
-void obj_free(struct obj_file *f)
-{
- struct obj_section *sec;
- struct obj_symbol *sym;
- struct obj_symbol *next;
- int i;
- int n;
-
- if (f->sections) {
- n = f->header.e_shnum;
- for (i = 0; i < n; ++i) {
- if ((sec = f->sections[i]) != NULL) {
- if (sec->contents)
- free(sec->contents);
- free(sec);
- }
- }
- free(f->sections);
- }
-
- for (i = 0; i < HASH_BUCKETS; ++i) {
- for (sym = f->symtab[i]; sym; sym = next) {
- next = sym->next;
- free(sym);
- }
- }
-
- if (f->local_symtab)
- free(f->local_symtab);
-
- if (f->filename)
- free((char *)(f->filename));
-
- if (f->persist)
- free((char *)(f->persist));
-
- free(f);
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_m68k.c b/mdk-stage1/insmod-modutils/obj/obj_m68k.c
deleted file mode 100644
index abc070bca..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_m68k.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* m68k specific support for Elf loading and relocation.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stddef.h>
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- return xmalloc(sizeof(struct obj_file));
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- return xmalloc(sizeof(struct obj_symbol));
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *ef,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rela *rel,
- Elf32_Addr v)
-{
- char *loc = targsec->contents + rel->r_offset;
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_68K_NONE:
- break;
-
- case R_68K_8:
- if (v > 0xff)
- ret = obj_reloc_overflow;
- *(char *)loc = v;
- break;
- case R_68K_16:
- if (v > 0xffff)
- ret = obj_reloc_overflow;
- *(short *)loc = v;
- break;
- case R_68K_32:
- *(int *)loc = v;
- break;
-
- case R_68K_PC8:
- v -= dot;
- if ((Elf32_Sword)v > 0x7f || (Elf32_Sword)v < -(Elf32_Sword)0x80)
- ret = obj_reloc_overflow;
- *(char *)loc = v;
- break;
- case R_68K_PC16:
- v -= dot;
- if ((Elf32_Sword)v > 0x7fff || (Elf32_Sword)v < -(Elf32_Sword)0x8000)
- ret = obj_reloc_overflow;
- *(short *)loc = v;
- break;
- case R_68K_PC32:
- *(int *)loc = v - dot;
- break;
-
- case R_68K_RELATIVE:
- *(int *)loc += ef->baseaddr;
- break;
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *ef)
-{
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_mips.c b/mdk-stage1/insmod-modutils/obj/obj_mips.c
deleted file mode 100644
index 2db0791b6..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_mips.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* MIPS specific support for Elf loading and relocation.
- Copyright 1997, 1998 Linux International.
- Contributed by Ralf Baechle <ralf@gnu.ai.mit.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct mips_hi16
-{
- struct mips_hi16 *next;
- Elf32_Addr *addr;
- Elf32_Addr value;
-};
-
-struct mips_file
-{
- struct obj_file root;
- struct mips_hi16 *mips_hi16_list;
-};
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- struct mips_file *mf;
-
- mf = xmalloc(sizeof(*mf));
- mf->mips_hi16_list = NULL;
-
- return (struct obj_file *) mf;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- return xmalloc(sizeof(struct obj_symbol));
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- switch (sec->header.sh_type)
- {
- case SHT_MIPS_DEBUG:
- case SHT_MIPS_REGINFO:
- /* Actually these two sections are as useless as something can be ... */
- sec->contents = NULL;
- break;
-
- case SHT_MIPS_LIBLIST:
- case SHT_MIPS_CONFLICT:
- case SHT_MIPS_GPTAB:
- case SHT_MIPS_UCODE:
- case SHT_MIPS_OPTIONS:
- case SHT_MIPS_DWARF:
- case SHT_MIPS_EVENTS:
- /* These shouldn't ever be in a module file. */
- error("Unhandled section header type: %08x", sec->header.sh_type);
-
- default:
- /* We don't even know the type. This time it might as well be a
- supernova. */
- error("Unknown section header type: %08x", sec->header.sh_type);
- return -1;
- }
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rel *rel,
- Elf32_Addr v)
-{
- struct mips_file *mf = (struct mips_file *)f;
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
- enum obj_reloc ret = obj_reloc_ok;
-
- /* _gp_disp is a magic symbol for PIC which is not supported for
- the kernel and loadable modules. */
- if (strcmp(sym->name, "_gp_disp") == 0)
- ret = obj_reloc_unhandled;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_MIPS_NONE:
- break;
-
- case R_MIPS_32:
- *loc += v;
- break;
-
- case R_MIPS_26:
- if (v % 4)
- ret = obj_reloc_dangerous;
- if ((v & 0xf0000000) != ((dot + 4) & 0xf0000000))
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x03ffffff) | ((*loc + (v >> 2)) & 0x03ffffff);
- break;
-
- case R_MIPS_HI16:
- {
- struct mips_hi16 *n;
-
- /* We cannot relocate this one now because we don't know the value
- of the carry we need to add. Save the information, and let LO16
- do the actual relocation. */
- n = (struct mips_hi16 *) xmalloc (sizeof *n);
- n->addr = loc;
- n->value = v;
- n->next = mf->mips_hi16_list;
- mf->mips_hi16_list = n;
- break;
- }
-
- case R_MIPS_LO16:
- {
- unsigned long insnlo = *loc;
- Elf32_Addr val, vallo;
-
- /* Sign extend the addend we extract from the lo insn. */
- vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000;
-
- if (mf->mips_hi16_list != NULL)
- {
- struct mips_hi16 *l;
-
- l = mf->mips_hi16_list;
- while (l != NULL)
- {
- struct mips_hi16 *next;
- unsigned long insn;
-
- /* The value for the HI16 had best be the same. */
- assert(v == l->value);
-
- /* Do the HI16 relocation. Note that we actually don't
- need to know anything about the LO16 itself, except where
- to find the low 16 bits of the addend needed by the LO16. */
- insn = *l->addr;
- val = ((insn & 0xffff) << 16) + vallo;
- val += v;
-
- /* Account for the sign extension that will happen in the
- low bits. */
- val = ((val >> 16) + ((val & 0x8000) != 0)) & 0xffff;
-
- insn = (insn &~ 0xffff) | val;
- *l->addr = insn;
-
- next = l->next;
- free(l);
- l = next;
- }
-
- mf->mips_hi16_list = NULL;
- }
-
- /* Ok, we're done with the HI16 relocs. Now deal with the LO16. */
- val = v + vallo;
- insnlo = (insnlo & ~0xffff) | (val & 0xffff);
- *loc = insnlo;
- break;
- }
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *f)
-{
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *f, struct obj_section *archdata_sec)
-{
- struct archdata {
- unsigned tgt_long __start___dbe_table;
- unsigned tgt_long __stop___dbe_table;
- } *ad;
- struct obj_section *sec;
-
- if (archdata_sec->contents)
- free(archdata_sec->contents);
- archdata_sec->header.sh_size = 0;
- sec = obj_find_section(f, "__dbe_table");
- if (sec) {
- ad = (struct archdata *) (archdata_sec->contents) = xmalloc(sizeof(*ad));
- memset(ad, 0, sizeof(*ad));
- archdata_sec->header.sh_size = sizeof(*ad);
- ad->__start___dbe_table = sec->header.sh_addr;
- ad->__stop___dbe_table = sec->header.sh_addr + sec->header.sh_size;
- }
-
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_ppc.c b/mdk-stage1/insmod-modutils/obj/obj_ppc.c
deleted file mode 100644
index 4889454f2..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_ppc.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/* PowerPC specific support for Elf loading and relocation.
- Copyright 1996, 1997 Linux International.
-
- Adapted by Paul Mackerras <paulus@cs.anu.edu.au> from the
- obj-sparc.c and obj-alpha.c files.
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stddef.h>
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-#include <assert.h>
-
-
-/*======================================================================*/
-
-/*
- * Unfortunately, the bl (branch-and-link) instruction used for
- * procedure calls on the PowerPC can only reach +/- 32MB from the
- * current instruction. If the module is loaded far enough away from
- * the main kernel text (or other modules) that this limit is
- * exceeded, we have to redirect procedure calls via a procedure
- * linkage table (PLT). Each entry in the PLT contains instructions
- * to put the address of the procedure in a register and jump to it.
- */
-
-typedef unsigned int instruction; /* a powerpc instruction (4 bytes) */
-
-struct ppc_plt_entry
-{
- struct ppc_plt_entry *next;
- ElfW(Addr) addend;
- int offset;
- int inited;
-};
-
-struct ppc_file
-{
- struct obj_file file;
- struct obj_section *plt;
-};
-
-struct ppc_symbol
-{
- struct obj_symbol sym;
- struct ppc_plt_entry *plt_entries;
-};
-
-struct obj_file *
-arch_new_file (void)
-{
- struct ppc_file *f;
-
- f = xmalloc(sizeof(struct ppc_file));
- f->plt = NULL;
- return &f->file;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- struct ppc_symbol *p;
-
- p = xmalloc(sizeof(struct ppc_symbol));
- p->plt_entries = NULL;
- return &p->sym;
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *ef,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rela *rel,
- Elf32_Addr v)
-{
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
- struct ppc_file *pf = (struct ppc_file *) ef;
- struct ppc_symbol *psym = (struct ppc_symbol *) sym;
- struct ppc_plt_entry *pe;
- instruction *ip;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_PPC_ADDR16_HA:
- *(unsigned short *)loc = (v + 0x8000) >> 16;
- break;
-
- case R_PPC_ADDR16_HI:
- *(unsigned short *)loc = v >> 16;
- break;
-
- case R_PPC_ADDR16_LO:
- *(unsigned short *)loc = v;
- break;
-
- case R_PPC_REL24:
- /* find the plt entry and initialize it if necessary */
- assert(psym != NULL);
- for (pe = psym->plt_entries; pe != NULL && pe->addend != rel->r_addend; )
- pe = pe->next;
- assert(pe != NULL);
- if (!pe->inited)
- {
- ip = (instruction *) (pf->plt->contents + pe->offset);
- ip[0] = 0x3d600000 + ((v + 0x8000) >> 16); /* lis r11,sym@ha */
- ip[1] = 0x396b0000 + (v & 0xffff); /* addi r11,r11,sym@l */
- ip[2] = 0x7d6903a6; /* mtctr r11 */
- ip[3] = 0x4e800420; /* bctr */
- pe->inited = 1;
- }
-
- v -= dot;
- if ((int)v < -0x02000000 || (int)v >= 0x02000000)
- {
- /* go via the plt */
- v = pf->plt->header.sh_addr + pe->offset - dot;
- }
- if (v & 3)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x03fffffc) | (v & 0x03fffffc);
- break;
-
- case R_PPC_REL32:
- *loc = v - dot;
- break;
-
- case R_PPC_ADDR32:
- *loc = v;
- break;
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *f)
-{
- struct ppc_file *pf = (struct ppc_file *) f;
- int i, offset;
- struct obj_section *sec, *syms, *strs;
- ElfW(Rela) *rel, *relend;
- ElfW(Sym) *symtab;
- const char *strtab;
- struct ppc_symbol *intsym;
- struct ppc_plt_entry *pe;
-
- offset = 0;
- for (i = 0; i < f->header.e_shnum; ++i)
- {
- sec = f->sections[i];
- if (sec->header.sh_type != SHT_RELM)
- continue;
- syms = f->sections[sec->header.sh_link];
- strs = f->sections[syms->header.sh_link];
-
- rel = (ElfW(RelM) *) sec->contents;
- relend = rel + (sec->header.sh_size / sizeof(ElfW(RelM)));
- symtab = (ElfW(Sym) *) syms->contents;
- strtab = (const char *) strs->contents;
-
- for (; rel < relend; ++rel)
- {
- if (ELF32_R_TYPE(rel->r_info) != R_PPC_REL24)
- continue;
- obj_find_relsym(intsym, f, f, rel, symtab, strtab);
-
- for (pe = intsym->plt_entries; pe != NULL; pe = pe->next)
- if (pe->addend == rel->r_addend)
- break;
- if (pe == NULL)
- {
- pe = xmalloc(sizeof(struct ppc_plt_entry));
- pe->next = intsym->plt_entries;
- pe->addend = rel->r_addend;
- pe->offset = offset;
- pe->inited = 0;
- intsym->plt_entries = pe;
- offset += 16;
- }
- }
- }
-
- pf->plt = obj_create_alloced_section(f, ".plt", 16, offset, SHF_WRITE);
-
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *f, struct obj_section *archdata_sec)
-{
- struct archdata {
- unsigned tgt_long __start___ftr_fixup;
- unsigned tgt_long __stop___ftr_fixup;
- } *ad;
- struct obj_section *sec;
-
- if (archdata_sec->contents)
- free(archdata_sec->contents);
- archdata_sec->header.sh_size = 0;
- sec = obj_find_section(f, "__ftr_fixup");
- if (sec) {
- ad = (struct archdata *) (archdata_sec->contents) = xmalloc(sizeof(*ad));
- memset(ad, 0, sizeof(*ad));
- archdata_sec->header.sh_size = sizeof(*ad);
- ad->__start___ftr_fixup = sec->header.sh_addr;
- ad->__stop___ftr_fixup = sec->header.sh_addr + sec->header.sh_size;
- }
-
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_reloc.c b/mdk-stage1/insmod-modutils/obj/obj_reloc.c
deleted file mode 100644
index 3f2c8aab0..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_reloc.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/* Elf relocation routines.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h>
-#include <assert.h>
-#include <alloca.h>
-
-#include <obj.h>
-#include <util.h>
-
-/*======================================================================*/
-
-int
-obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
- const char *string)
-{
- struct obj_string_patch_struct *p;
- struct obj_section *strsec;
- size_t len = strlen(string)+1;
- char *loc;
-
- p = xmalloc(sizeof(*p));
- p->next = f->string_patches;
- p->reloc_secidx = secidx;
- p->reloc_offset = offset;
- f->string_patches = p;
-
- strsec = obj_find_section(f, ".kstrtab");
- if (strsec == NULL)
- {
- strsec = obj_create_alloced_section(f, ".kstrtab", 1, len, 0);
- p->string_offset = 0;
- loc = strsec->contents;
- }
- else
- {
- p->string_offset = strsec->header.sh_size;
- loc = obj_extend_section(strsec, len);
- }
- memcpy(loc, string, len);
-
- return 1;
-}
-
-int
-obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
- struct obj_symbol *sym)
-{
- struct obj_symbol_patch_struct *p;
-
- p = xmalloc(sizeof(*p));
- p->next = f->symbol_patches;
- p->reloc_secidx = secidx;
- p->reloc_offset = offset;
- p->sym = sym;
- f->symbol_patches = p;
-
- return 1;
-}
-
-int
-obj_check_undefineds(struct obj_file *f, int quiet)
-{
- unsigned long i;
- int ret = 1;
-
- for (i = 0; i < HASH_BUCKETS; ++i)
- {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym ; sym = sym->next)
- if (sym->secidx == SHN_UNDEF)
- {
- if (ELFW(ST_BIND)(sym->info) == STB_WEAK)
- {
- sym->secidx = SHN_ABS;
- sym->value = 0;
- }
- else if (sym->r_type) /* assumes R_arch_NONE is 0 on all arch */
- {
- if (!quiet)
- error("unresolved symbol %s", sym->name);
- ret = 0;
- }
- }
- }
-
- return ret;
-}
-
-void
-obj_clear_undefineds(struct obj_file *f)
-{
- unsigned long i;
- struct obj_symbol *sym;
- for (i = 0; i < HASH_BUCKETS; ++i)
- {
- for (sym = f->symtab[i]; sym ; sym = sym->next)
- if (sym->secidx == SHN_UNDEF)
- {
- sym->secidx = SHN_ABS;
- sym->value = 0;
- }
- }
-}
-
-void
-obj_allocate_commons(struct obj_file *f)
-{
- struct common_entry
- {
- struct common_entry *next;
- struct obj_symbol *sym;
- } *common_head = NULL;
-
- unsigned long i;
-
- for (i = 0; i < HASH_BUCKETS; ++i)
- {
- struct obj_symbol *sym;
- for (sym = f->symtab[i]; sym ; sym = sym->next)
- if (sym->secidx == SHN_COMMON)
- {
- /* Collect all COMMON symbols and sort them by size so as to
- minimize space wasted by alignment requirements. */
- {
- struct common_entry **p, *n;
- for (p = &common_head; *p ; p = &(*p)->next)
- if (sym->size <= (*p)->sym->size)
- break;
-
- n = alloca(sizeof(*n));
- n->next = *p;
- n->sym = sym;
- *p = n;
- }
- }
- }
-
- for (i = 1; i < f->local_symtab_size; ++i)
- {
- struct obj_symbol *sym = f->local_symtab[i];
- if (sym && sym->secidx == SHN_COMMON)
- {
- struct common_entry **p, *n;
- for (p = &common_head; *p ; p = &(*p)->next)
- if (sym == (*p)->sym)
- break;
- else if (sym->size < (*p)->sym->size)
- {
- n = alloca(sizeof(*n));
- n->next = *p;
- n->sym = sym;
- *p = n;
- break;
- }
- }
- }
-
- if (common_head)
- {
- /* Find the bss section. */
- for (i = 0; i < f->header.e_shnum; ++i)
- if (f->sections[i]->header.sh_type == SHT_NOBITS)
- break;
-
- /* If for some reason there hadn't been one, create one. */
- if (i == f->header.e_shnum)
- {
- struct obj_section *sec;
-
- f->sections = xrealloc(f->sections, (i+1) * sizeof(sec));
- f->sections[i] = sec = arch_new_section();
- f->header.e_shnum = i+1;
-
- memset(sec, 0, sizeof(*sec));
- sec->header.sh_type = SHT_PROGBITS;
- sec->header.sh_flags = SHF_WRITE|SHF_ALLOC;
- sec->name = ".bss";
- sec->idx = i;
- }
-
- /* Allocate the COMMONS. */
- {
- ElfW(Addr) bss_size = f->sections[i]->header.sh_size;
- ElfW(Addr) max_align = f->sections[i]->header.sh_addralign;
- struct common_entry *c;
-
- for (c = common_head; c ; c = c->next)
- {
- ElfW(Addr) align = c->sym->value;
-
- if (align > max_align)
- max_align = align;
- if (bss_size & (align - 1))
- bss_size = (bss_size | (align - 1)) + 1;
-
- c->sym->secidx = i;
- c->sym->value = bss_size;
-
- bss_size += c->sym->size;
- }
-
- f->sections[i]->header.sh_size = bss_size;
- f->sections[i]->header.sh_addralign = max_align;
- }
- }
-
- /* For the sake of patch relocation and parameter initialization,
- allocate zeroed data for NOBITS sections now. Note that after
- this we cannot assume NOBITS are really empty. */
- for (i = 0; i < f->header.e_shnum; ++i)
- {
- struct obj_section *s = f->sections[i];
- if (s->header.sh_type == SHT_NOBITS)
- {
- if (s->header.sh_size)
- s->contents = memset(xmalloc(s->header.sh_size),
- 0, s->header.sh_size);
- else
- s->contents = NULL;
- s->header.sh_type = SHT_PROGBITS;
- }
- }
-}
-
-unsigned long
-obj_load_size (struct obj_file *f)
-{
- unsigned long dot = 0;
- struct obj_section *sec;
-
- /* Finalize the positions of the sections relative to one another. */
-
- for (sec = f->load_order; sec ; sec = sec->load_next)
- {
- ElfW(Addr) align;
-
- align = sec->header.sh_addralign;
- if (align && (dot & (align - 1)))
- dot = (dot | (align - 1)) + 1;
-
- sec->header.sh_addr = dot;
- dot += sec->header.sh_size;
- }
-
- return dot;
-}
-
-int
-obj_relocate (struct obj_file *f, ElfW(Addr) base)
-{
- int i, n = f->header.e_shnum;
- int ret = 1;
-
- /* Finalize the addresses of the sections. */
-
- arch_finalize_section_address(f, base);
-
- /* And iterate over all of the relocations. */
-
- for (i = 0; i < n; ++i)
- {
- struct obj_section *relsec, *symsec, *targsec, *strsec;
- ElfW(RelM) *rel, *relend;
- ElfW(Sym) *symtab;
- const char *strtab;
- unsigned long nsyms;
-
- relsec = f->sections[i];
- if (relsec->header.sh_type != SHT_RELM)
- continue;
-
- symsec = f->sections[relsec->header.sh_link];
- targsec = f->sections[relsec->header.sh_info];
- strsec = f->sections[symsec->header.sh_link];
-
- if (!(targsec->header.sh_flags & SHF_ALLOC))
- continue;
-
- rel = (ElfW(RelM) *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(ElfW(RelM)));
- symtab = (ElfW(Sym) *)symsec->contents;
- nsyms = symsec->header.sh_size / symsec->header.sh_entsize;
- strtab = (const char *)strsec->contents;
-
- for (; rel < relend; ++rel)
- {
- ElfW(Addr) value = 0;
- struct obj_symbol *intsym = NULL;
- unsigned long symndx;
- const char *errmsg;
-
- /* Attempt to find a value to use for this relocation. */
-
- symndx = ELFW(R_SYM)(rel->r_info);
- if (symndx)
- {
- /* Note we've already checked for undefined symbols. */
-
- if (symndx >= nsyms)
- {
- error("Bad symbol index: %08lx >= %08lx",
- symndx, nsyms);
- continue;
- }
-
- obj_find_relsym(intsym, f, f, rel, symtab, strtab);
- value = obj_symbol_final_value(f, intsym);
- }
-
-#if SHT_RELM == SHT_RELA
- value += rel->r_addend;
-#endif
-
- /* Do it! */
- switch (arch_apply_relocation(f,targsec,symsec,intsym,rel,value))
- {
- case obj_reloc_ok:
- break;
-
- case obj_reloc_overflow:
- errmsg = "Relocation overflow";
- goto bad_reloc;
- case obj_reloc_dangerous:
- errmsg = "Dangerous relocation";
- goto bad_reloc;
- case obj_reloc_unhandled:
- errmsg = "Unhandled relocation";
- goto bad_reloc;
- case obj_reloc_constant_gp:
- errmsg = "Modules compiled with -mconstant-gp cannot be loaded";
- goto bad_reloc;
- bad_reloc:
- error("%s of type %ld for %s", errmsg,
- (long)ELFW(R_TYPE)(rel->r_info), intsym->name);
- ret = 0;
- break;
- }
- }
- }
-
- /* Finally, take care of the patches. */
-
- if (f->string_patches)
- {
- struct obj_string_patch_struct *p;
- struct obj_section *strsec;
- ElfW(Addr) strsec_base;
- strsec = obj_find_section(f, ".kstrtab");
- strsec_base = strsec->header.sh_addr;
-
- for (p = f->string_patches; p ; p = p->next)
- {
- struct obj_section *targsec = f->sections[p->reloc_secidx];
- *(ElfW(Addr) *)(targsec->contents + p->reloc_offset)
- = strsec_base + p->string_offset;
- }
- }
-
- if (f->symbol_patches)
- {
- struct obj_symbol_patch_struct *p;
-
- for (p = f->symbol_patches; p; p = p->next)
- {
- struct obj_section *targsec = f->sections[p->reloc_secidx];
- *(ElfW(Addr) *)(targsec->contents + p->reloc_offset)
- = obj_symbol_final_value(f, p->sym);
- }
- }
-
- return ret;
-}
-
-int
-obj_create_image (struct obj_file *f, char *image)
-{
- struct obj_section *sec;
- ElfW(Addr) base = f->baseaddr;
-
- for (sec = f->load_order; sec ; sec = sec->load_next)
- {
- char *secimg;
-
- if (sec->contents == 0)
- continue;
-
- secimg = image + (sec->header.sh_addr - base);
-
- /* Note that we allocated data for NOBITS sections earlier. */
- memcpy(secimg, sec->contents, sec->header.sh_size);
- }
-
- return 1;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_s390.c b/mdk-stage1/insmod-modutils/obj/obj_s390.c
deleted file mode 100644
index a76e28479..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_s390.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/* IBM S/390 31-bit specific support for Elf loading and relocation.
- Copyright 2000, 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation.
-
- Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>
-
- Derived from obj/obj_i386.c:
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h>
-#include <assert.h>
-
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct s390_plt_entry
-{
- long offset;
- int allocated:1;
- int initialized:1;
-};
-
-struct s390_got_entry
-{
- long offset;
- unsigned allocated:1;
- unsigned reloc_done : 1;
-};
-
-struct s390_file
-{
- struct obj_file root;
- struct obj_section *plt;
- struct obj_section *got;
-};
-
-struct s390_symbol
-{
- struct obj_symbol root;
- struct s390_plt_entry pltent;
- struct s390_got_entry gotent;
-};
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- struct s390_file *f;
- f = xmalloc(sizeof(*f));
- f->got = NULL;
- f->plt = NULL;
- return &f->root;
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- struct s390_symbol *sym;
- sym = xmalloc(sizeof(*sym));
- memset(&sym->gotent, 0, sizeof(sym->gotent));
- memset(&sym->pltent, 0, sizeof(sym->pltent));
- return &sym->root;
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *f,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rela *rel,
- Elf32_Addr v)
-{
- struct s390_file *ifile = (struct s390_file *) f;
- struct s390_symbol *isym = (struct s390_symbol *) sym;
- struct s390_plt_entry *pe;
-
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
- Elf32_Addr got = ifile->got ? ifile->got->header.sh_addr : 0;
- Elf32_Addr plt = ifile->plt ? ifile->plt->header.sh_addr : 0;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_390_NONE:
- break;
-
- case R_390_32:
- *(unsigned int *) loc += v;
- break;
- case R_390_16:
- *(unsigned short *) loc += v;
- break;
- case R_390_8:
- *(unsigned char *) loc += v;
- break;
-
- case R_390_PC32:
- *(unsigned int *) loc += v - dot;
- break;
- case R_390_PC16DBL:
- *(unsigned short *) loc += (v - dot) >> 1;
- break;
- case R_390_PC16:
- *(unsigned short *) loc += v - dot;
- break;
-
- case R_390_PLT32:
- case R_390_PLT16DBL:
- /* find the plt entry and initialize it. */
- assert(isym != NULL);
- pe = (struct s390_plt_entry *) &isym->pltent;
- assert(pe->allocated);
- if (pe->initialized == 0) {
- unsigned int *ip = (unsigned int *)(ifile->plt->contents + pe->offset);
- ip[0] = 0x0d105810; /* basr 1,0; lg 1,10(1); br 1 */
- ip[1] = 0x100607f1;
- if (ELF32_R_TYPE(rel->r_info) == R_390_PLT16DBL)
- ip[2] = v - 2;
- else
- ip[2] = v;
- pe->initialized = 1;
- }
-
- /* Insert relative distance to target. */
- v = plt + pe->offset - dot;
- if (ELF32_R_TYPE(rel->r_info) == R_390_PLT32)
- *(unsigned int *) loc = (unsigned int) v;
- else if (ELF32_R_TYPE(rel->r_info) == R_390_PLT16DBL)
- *(unsigned short *) loc = (unsigned short) ((v + 2) >> 1);
- break;
-
- case R_390_GLOB_DAT:
- case R_390_JMP_SLOT:
- *loc = v;
- break;
-
- case R_390_RELATIVE:
- *loc += f->baseaddr;
- break;
-
- case R_390_GOTPC:
- assert(got != 0);
- *(unsigned long *) loc += got - dot;
- break;
-
- case R_390_GOT12:
- case R_390_GOT16:
- case R_390_GOT32:
- assert(isym != NULL);
- assert(got != 0);
- if (!isym->gotent.reloc_done)
- {
- isym->gotent.reloc_done = 1;
- *(Elf32_Addr *)(ifile->got->contents + isym->gotent.offset) = v;
- }
- if (ELF32_R_TYPE(rel->r_info) == R_390_GOT12)
- *(unsigned short *) loc |= (*(unsigned short *) loc + isym->gotent.offset) & 0xfff;
- else if (ELF32_R_TYPE(rel->r_info) == R_390_GOT16)
- *(unsigned short *) loc += isym->gotent.offset;
- else if (ELF32_R_TYPE(rel->r_info) == R_390_GOT32)
- *(unsigned int *) loc += isym->gotent.offset;
- break;
-
- case R_390_GOTOFF:
- assert(got != 0);
- *loc += v - got;
- break;
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *f)
-{
- struct s390_file *ifile = (struct s390_file *) f;
- int i, got_offset = 0, plt_offset = 0, gotneeded = 0;
-
- for (i = 0; i < f->header.e_shnum; ++i)
- {
- struct obj_section *relsec, *symsec, *strsec;
- Elf32_Rela *rel, *relend;
- Elf32_Sym *symtab;
- const char *strtab;
-
- relsec = f->sections[i];
- if (relsec->header.sh_type != SHT_RELA)
- continue;
-
- symsec = f->sections[relsec->header.sh_link];
- strsec = f->sections[symsec->header.sh_link];
-
- rel = (Elf32_Rela *)relsec->contents;
- relend = rel + (relsec->header.sh_size / sizeof(Elf32_Rela));
- symtab = (Elf32_Sym *)symsec->contents;
- strtab = (const char *)strsec->contents;
-
- for (; rel < relend; ++rel)
- {
- struct s390_symbol *intsym;
- struct s390_plt_entry *pe;
- struct s390_got_entry *ge;
-
- switch (ELF32_R_TYPE(rel->r_info)) {
- /* These four relocations refer to a plt entry. */
- case R_390_PLT16DBL:
- case R_390_PLT32:
- obj_find_relsym(intsym, f, f, rel, symtab, strtab);
- assert(intsym);
- pe = &intsym->pltent;
- if (!pe->allocated) {
- pe->allocated = 1;
- pe->offset = plt_offset;
- plt_offset += 12;
- }
- break;
- /* The next three don't need got entries but the address
- of the got itself. */
- case R_390_GOTPC:
- case R_390_GOTOFF:
- gotneeded = 1;
- break;
-
- case R_390_GOT12:
- case R_390_GOT16:
- case R_390_GOT32:
- obj_find_relsym(intsym, f, f, rel, symtab, strtab);
- assert(intsym);
- ge = (struct s390_got_entry *) &intsym->gotent;
- if (!ge->allocated) {
- ge->allocated = 1;
- ge->offset = got_offset;
- got_offset += sizeof(void*);
- }
- break;
-
- default:
- break;
- }
- }
- }
-
- if (got_offset > 0 || gotneeded) {
- struct obj_section *gotsec;
- struct obj_symbol *gotsym;
-
- gotsec = obj_find_section(f, ".got");
- if (gotsec == NULL)
- gotsec = obj_create_alloced_section(f, ".got", 4, got_offset, SHF_WRITE);
- else
- obj_extend_section(gotsec, got_offset);
- gotsym = obj_add_symbol(f, "_GLOBAL_OFFSET_TABLE_", -1,
- ELFW(ST_INFO) (STB_LOCAL, STT_OBJECT),
- gotsec->idx, 0, 0);
- gotsym->secidx = gotsec->idx; /* mark the symbol as defined */
- ifile->got = gotsec;
- }
-
- if (plt_offset > 0)
- ifile->plt = obj_create_alloced_section(f, ".plt", 4, plt_offset,
- SHF_WRITE);
-
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
-
diff --git a/mdk-stage1/insmod-modutils/obj/obj_sparc.c b/mdk-stage1/insmod-modutils/obj/obj_sparc.c
deleted file mode 100644
index d1eb3da44..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_sparc.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* Sparc specific support for Elf loading and relocation.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stddef.h>
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- return xmalloc(sizeof(struct obj_file));
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- return xmalloc(sizeof(struct obj_symbol));
-}
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *ef,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf32_Rela *rel,
- Elf32_Addr v)
-{
- Elf32_Addr *loc = (Elf32_Addr *)(targsec->contents + rel->r_offset);
- Elf32_Addr dot = targsec->header.sh_addr + rel->r_offset;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF32_R_TYPE(rel->r_info))
- {
- case R_SPARC_NONE:
- break;
- case R_SPARC_8:
- if (v > 0xff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xff) | (v & 0xff);
- break;
- case R_SPARC_16:
- if (v > 0xffff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xffff) | (v & 0xffff);
- break;
- case R_SPARC_32:
- *loc = v;
- break;
- case R_SPARC_DISP8:
- v -= dot;
- if (v > 0xff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xff) | (v & 0xff);
- break;
- case R_SPARC_DISP16:
- v -= dot;
- if (v > 0xffff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xffff) | (v & 0xffff);
- break;
- case R_SPARC_DISP32:
- v -= dot;
- *loc = v;
- break;
- case R_SPARC_WDISP30:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x3fffffff) | (v >> 2);
- break;
- case R_SPARC_WDISP22:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x3fffff) | ((v >> 2) & 0x3fffff);
- break;
- case R_SPARC_HI22:
- *loc = (*loc & ~0x3fffff) | (v >> 10);
- break;
- case R_SPARC_22:
- if (v > 0x3fffff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x3fffff) | (v & 0x3fffff);
- break;
- case R_SPARC_13:
- if (v > 0x1fff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x1fff) | (v & 0x1fff);
- break;
- case R_SPARC_LO10:
- *loc = (*loc & ~0x3ff) | (v & 0x3ff);
- break;
-
- case R_SPARC_PC10:
- v -= dot;
- *loc = (*loc & ~0x3ff) | (v & 0x3ff);
- break;
- case R_SPARC_PC22:
- v -= dot;
- *loc = (*loc & ~0x3fffff) | (v >> 10);
- break;
-
- case R_SPARC_UA32:
- *(((char *)loc) + 0) = (char)(v >> 24);
- *(((char *)loc) + 1) = (char)(v >> 16);
- *(((char *)loc) + 2) = (char)(v >> 8);
- *(((char *)loc) + 3) = (char)v;
- break;
-
-#ifdef R_SPARC_10
- case R_SPARC_10:
- if (v > 0x3ff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x3ff) | (v & 0x3ff);
- break;
- case R_SPARC_11:
- if (v > 0x7ff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x7ff) | (v & 0x7ff);
- break;
- case R_SPARC_WDISP16:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x303fff) | ((v << 4) & 0x300000) | ((v >> 2) & 0x3fff);
- break;
- case R_SPARC_WDISP19:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x7ffff) | ((v >> 2) & 0x7ffff);
- break;
- case R_SPARC_7:
- if (v > 0x7f)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x7f) | (v & 0x7f);
- break;
- case R_SPARC_5:
- if (v > 0x1f)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x1f) | (v & 0x1f);
- break;
- case R_SPARC_6:
- if (v > 0x3f)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x3f) | (v & 0x3f);
- break;
-#endif /* R_SPARC_10 */
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *ef)
-{
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf32_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/obj/obj_sparc64.c b/mdk-stage1/insmod-modutils/obj/obj_sparc64.c
deleted file mode 100644
index f025667f8..000000000
--- a/mdk-stage1/insmod-modutils/obj/obj_sparc64.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/* Sparc64 specific support for Elf loading and relocation.
- Copyright 1997 Linux International.
-
- Contributed by Jakub Jelinek <jj@sunsite.mff.cuni.cz>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stddef.h>
-#include <module.h>
-#include <obj.h>
-#include <util.h>
-
-
-/*======================================================================*/
-
-struct obj_file *
-arch_new_file (void)
-{
- return xmalloc(sizeof(struct obj_file));
-}
-
-struct obj_section *
-arch_new_section (void)
-{
- return xmalloc(sizeof(struct obj_section));
-}
-
-struct obj_symbol *
-arch_new_symbol (void)
-{
- return xmalloc(sizeof(struct obj_symbol));
-}
-
-#ifdef BROKEN_SPARC64_RELOCS
-
-#undef R_SPARC_PLT32
-#undef R_SPARC_HIPLT22
-#undef R_SPARC_LOPLT10
-#undef R_SPARC_PCPLT32
-#undef R_SPARC_PCPLT22
-#undef R_SPARC_PCPLT10
-#undef R_SPARC_10
-#undef R_SPARC_11
-#undef R_SPARC_64
-#undef R_SPARC_OLO10
-#undef R_SPARC_HH22
-#undef R_SPARC_HM10
-#undef R_SPARC_LM22
-#undef R_SPARC_PC_HH22
-#undef R_SPARC_PC_HM10
-#undef R_SPARC_PC_LM22
-#undef R_SPARC_WDISP16
-#undef R_SPARC_WDISP19
-#undef R_SPARC_GLOB_JMP
-#undef R_SPARC_7
-#undef R_SPARC_5
-#undef R_SPARC_6
-
-#define R_SPARC_10 24
-#define R_SPARC_11 25
-#define R_SPARC_64 26
-#define R_SPARC_OLO10 27
-#define R_SPARC_HH22 28
-#define R_SPARC_HM10 29
-#define R_SPARC_LM22 30
-#define R_SPARC_PC_HH22 31
-#define R_SPARC_PC_HM10 32
-#define R_SPARC_PC_LM22 33
-#define R_SPARC_WDISP16 34
-#define R_SPARC_WDISP19 35
-#define R_SPARC_GLOB_JMP 36
-#define R_SPARC_7 37
-#define R_SPARC_5 38
-#define R_SPARC_6 39
-
-#else
-
-#ifndef R_SPARC_64
-
-#define R_SPARC_64 32
-#define R_SPARC_OLO10 33
-#define R_SPARC_HH22 34
-#define R_SPARC_HM10 35
-#define R_SPARC_LM22 36
-#define R_SPARC_PC_HH22 37
-#define R_SPARC_PC_HM10 38
-#define R_SPARC_PC_LM22 39
-
-#endif
-
-#endif
-
-int
-arch_load_proc_section(struct obj_section *sec, int fp)
-{
- /* Assume it's just a debugging section that we can safely
- ignore ... */
- sec->contents = NULL;
-
- return 0;
-}
-
-#define ELF64_R_TYPE_ID(info) ((info) & 0xff)
-#define ELF64_R_TYPE_DATA(info) ((info) >> 8)
-
-enum obj_reloc
-arch_apply_relocation (struct obj_file *ef,
- struct obj_section *targsec,
- struct obj_section *symsec,
- struct obj_symbol *sym,
- Elf64_Rela *rel,
- Elf64_Addr v)
-{
- unsigned int *loc = (unsigned int *)(targsec->contents + rel->r_offset);
- unsigned int dot = targsec->header.sh_addr + rel->r_offset;
-
- enum obj_reloc ret = obj_reloc_ok;
-
- switch (ELF64_R_TYPE_ID(rel->r_info))
- {
- case R_SPARC_NONE:
- break;
-
- case R_SPARC_64:
- case R_SPARC_UA64:
- if (! ((long) loc & 3)) {
- /* Common in .eh_frame */
- ((unsigned int *) loc) [0] = v >> 32;
- ((unsigned int *) loc) [1] = v;
- break;
- }
- ((unsigned char *) loc) [0] = v >> 56;
- ((unsigned char *) loc) [1] = v >> 48;
- ((unsigned char *) loc) [2] = v >> 40;
- ((unsigned char *) loc) [3] = v >> 32;
- ((unsigned char *) loc) [4] = v >> 24;
- ((unsigned char *) loc) [5] = v >> 16;
- ((unsigned char *) loc) [6] = v >> 8;
- ((unsigned char *) loc) [7] = v;
- break;
- case R_SPARC_32:
- case R_SPARC_UA32:
- if (! ((long) loc & 3)) {
- *loc = v;
- break;
- }
- ((unsigned char *) loc) [0] = v >> 24;
- ((unsigned char *) loc) [1] = v >> 16;
- ((unsigned char *) loc) [2] = v >> 8;
- ((unsigned char *) loc) [3] = v;
- break;
- case R_SPARC_16:
- if (v > 0xffff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xffff) | (v & 0xffff);
- break;
- case R_SPARC_8:
- if (v > 0xff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xff) | (v & 0xff);
- break;
-
- case R_SPARC_DISP32:
- v -= dot;
- *loc = v;
- break;
- case R_SPARC_DISP16:
- v -= dot;
- if (v > 0xffff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xffff) | (v & 0xffff);
- break;
- case R_SPARC_DISP8:
- v -= dot;
- if (v > 0xff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0xff) | (v & 0xff);
- break;
- case R_SPARC_WDISP30:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x3fffffff) | ((v >> 2) & 0x3fffffff);
- break;
-
- /* MEDLOW code model relocs */
- case R_SPARC_LO10:
- *loc = (*loc & ~0x3ff) | (v & 0x3ff);
- break;
- case R_SPARC_HI22:
- *loc = (*loc & ~0x3fffff) | (v >> 10);
- break;
- case R_SPARC_OLO10:
- *loc = (*loc & ~0x1fff) | (((v & 0x3ff) + ELF64_R_TYPE_DATA (rel->r_info)) & 0x1fff);
- break;
-
- /* MEDMID code model relocs */
- case R_SPARC_H44:
- *loc = (*loc & ~0x3fffff) | (v >> 22);
- break;
- case R_SPARC_M44:
- *loc = (*loc & ~0x3ff) | ((v >> 12) & 0x3ff);
- break;
- case R_SPARC_L44:
- *loc = (*loc & ~0xfff) | (v & 0xfff);
- break;
-
- /* MEDANY code model relocs */
- case R_SPARC_HH22:
- *loc = (*loc & ~0x3fffff) | (v >> 42);
- break;
- case R_SPARC_HM10:
- *loc = (*loc & ~0x3ff) | ((v >> 32) & 0x3ff);
- break;
- case R_SPARC_LM22:
- *loc = (*loc & ~0x3fffff) | ((v >> 10) & 0x3fffff);
- break;
-
- case R_SPARC_WDISP22:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x3fffff) | ((v >> 2) & 0x3fffff);
- break;
- case R_SPARC_22:
- if (v > 0x3fffff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x3fffff) | (v & 0x3fffff);
- break;
- case R_SPARC_13:
- if (v > 0x1fff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x1fff) | (v & 0x1fff);
- break;
-
- case R_SPARC_PC10:
- v -= dot;
- *loc = (*loc & ~0x3ff) | (v & 0x3ff);
- break;
- case R_SPARC_PC22:
- v -= dot;
- *loc = (*loc & ~0x3fffff) | ((v >> 10) & 0x3fffff);
- break;
-
-#ifdef R_SPARC_10
- case R_SPARC_10:
- if (v > 0x3ff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x3ff) | (v & 0x3ff);
- break;
- case R_SPARC_11:
- if (v > 0x7ff)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x7ff) | (v & 0x7ff);
- break;
-
-#ifdef R_SPARC_64
- case R_SPARC_PC_HH22:
- v -= dot;
- *loc = (*loc & ~0x3fffff) | (v >> 42);
- break;
- case R_SPARC_PC_HM10:
- v -= dot;
- *loc = (*loc & ~0x3ff) | ((v >> 32) & 0x3ff);
- break;
- case R_SPARC_PC_LM22:
- v -= dot;
- *loc = (*loc & ~0x3fffff) | ((v >> 10) & 0x3fffff);
- break;
-#endif
-
- case R_SPARC_WDISP16:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x303fff) | ((v << 4) & 0x300000) | ((v >> 2) & 0x3fff);
- break;
- case R_SPARC_WDISP19:
- v -= dot;
- if (v % 4)
- ret = obj_reloc_dangerous;
- *loc = (*loc & ~0x7ffff) | ((v >> 2) & 0x7ffff);
- break;
- case R_SPARC_7:
- if (v > 0x7f)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x7f) | (v & 0x7f);
- break;
- case R_SPARC_5:
- if (v > 0x1f)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x1f) | (v & 0x1f);
- break;
- case R_SPARC_6:
- if (v > 0x3f)
- ret = obj_reloc_overflow;
- *loc = (*loc & ~0x3f) | (v & 0x3f);
- break;
-#endif /* R_SPARC_10 */
-
- default:
- ret = obj_reloc_unhandled;
- break;
- }
-
- return ret;
-}
-
-int
-arch_create_got (struct obj_file *ef)
-{
- return 1;
-}
-
-int
-arch_init_module (struct obj_file *f, struct module *mod)
-{
- return 1;
-}
-
-int
-arch_finalize_section_address(struct obj_file *f, Elf64_Addr base)
-{
- int i, n = f->header.e_shnum;
-
- f->baseaddr = base;
- for (i = 0; i < n; ++i)
- f->sections[i]->header.sh_addr += base;
- return 1;
-}
-
-int
-arch_archdata (struct obj_file *fin, struct obj_section *sec)
-{
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/util/Makefile b/mdk-stage1/insmod-modutils/util/Makefile
deleted file mode 100644
index dd8107435..000000000
--- a/mdk-stage1/insmod-modutils/util/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
- #******************************************************************************
- #
- # insmod from modutils (generic)
- #
- # $Id$
- #
- # Copyright 1996, 1997 Linux International.
- #
- #*****************************************************************************
-
-top_dir = ../..
-
-include $(top_dir)/Makefile.common
-
-
-all: libutil.a libutil-STANDALONE.a
-
-clean:
- rm -f *.o *.a
-
-
-INCS = -I./../include
-
-DEFS = -Wno-error -D_GNU_SOURCE -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) -DHAVE_WORDEXP=1 -DHAVE_GLOB=1 -DCONFIG_ROOT_CHECK_OFF=0
-
-
-OBJS = xmalloc.o xrealloc.o xstrcat.o xstrdup.o xsystem.o xftw.o \
- modstat.o meta_expand.o config.o snap_shot.o arch64.o gzfiles.o sys_nim.o sys_oim.o
-
-libutil.a: $(OBJS) logger.o
- ar cru $@ $^
- ranlib $@
-
-libutil-STANDALONE.a: $(OBJS) logger-standalone.o
- ar cru $@ $^
- ranlib $@
-
-logger-standalone.o: logger.c
- $(DIET) gcc $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -o $@ -D_STANDALONE_ -c logger.c
-
-%.o: %.c
- $(DIET) gcc $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -c $<
diff --git a/mdk-stage1/insmod-modutils/util/alias.h b/mdk-stage1/insmod-modutils/util/alias.h
deleted file mode 100644
index 7d0c08938..000000000
--- a/mdk-stage1/insmod-modutils/util/alias.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * This file is split out from config.c for easier editing
- */
-
-/*
- * tbpath and tbtype are used to build the complete set of paths for finding
- * modules, but only when we search for individual directories, they are not
- * used for [boot] and [toplevel] searches.
- */
-static char *tbpath[] =
-{
- "/lib/modules",
- NULL /* marks the end of the list! */
-};
-
-char *tbtype[] =
-{
- "kernel", /* as of 2.3.14 this must be first */
- "fs",
- "net",
- "scsi",
- "block",
- "cdrom",
- "ipv4",
- "ipv6",
- "sound",
- "fc4",
- "video",
- "misc",
- "pcmcia",
- "atm",
- "usb",
- "ide",
- "ieee1394",
- "mtd",
- NULL /* marks the end of the list! */
-};
-
-/*
- * This is the list of pre-defined aliases.
- * Each entry can be overridden by an entry in /etc/modules.conf
- */
-char *aliaslist[] =
-{
- "binfmt-0000 off",
- "binfmt-204 binfmt_aout",
- "binfmt-263 binfmt_aout",
- "binfmt-264 binfmt_aout",
- "binfmt-267 binfmt_aout",
- "binfmt-387 binfmt_aout",
- "binfmt-332 iBCS",
- "binfmt--310 binfmt_java",
-
- "block-major-1 rd",
- "block-major-2 floppy",
- "block-major-3 ide-probe-mod",
- "block-major-7 loop",
- "block-major-8 sd_mod",
- "block-major-9 md", /* For modular RAID */
- "block-major-11 sr_mod",
- "block-major-13 xd",
- "block-major-15 cdu31a",
- "block-major-16 gscd",
- "block-major-17 optcd",
- "block-major-18 sjcd",
- "block-major-20 mcdx",
- "block-major-22 ide-probe-mod",
- "block-major-23 mcd",
- "block-major-24 sonycd535",
- "block-major-25 sbpcd",
- "block-major-26 sbpcd",
- "block-major-27 sbpcd",
- "block-major-29 aztcd",
- "block-major-32 cm206",
- "block-major-33 ide-probe-mod",
- "block-major-34 ide-probe-mod",
- "block-major-37 ide-tape",
- "block-major-44 ftl", /* from David Woodhouse <dwmw2@infradead.org> */
- "block-major-46 pcd",
- "block-major-47 pf",
- "block-major-56 ide-probe-mod",
- "block-major-57 ide-probe-mod",
- "block-major-58 lvm-mod",
- "block-major-88 ide-probe-mod",
- "block-major-89 ide-probe-mod",
- "block-major-90 ide-probe-mod",
- "block-major-91 ide-probe-mod",
- "block-major-93 nftl", /* from David Woodhouse <dwmw2@infradead.org> */
- "block-major-97 pg",
-
-#if !defined(__s390__) && !defined(__s390x__)
- "char-major-4 serial",
-#else
- "char-major-4 off",
-#endif
- "char-major-5 serial",
- "char-major-6 lp",
- "char-major-9 st",
- "char-major-10 off", /* was: mouse, was: misc */
- "char-major-10-0 busmouse", /* /dev/logibm Logitech bus mouse */
- "char-major-10-1 off", /* /dev/psaux PS/2-style mouse port */
- "char-major-10-2 msbusmouse", /* /dev/inportbm Microsoft Inport bus mouse */
- "char-major-10-3 atixlmouse", /* /dev/atibm ATI XL bus mouse */
- /* /dev/jbm J-mouse */
- /* /dev/amigamouse Amiga mouse (68k/Amiga) */
- /* /dev/atarimouse Atari mouse */
- /* /dev/sunmouse Sun mouse */
- /* /dev/beep Fancy beep device */
- /* /dev/modreq Kernel module load request */
- "char-major-10-130 wdt", /* /dev/watchdog Watchdog timer port */
- "char-major-10-131 wdt", /* /dev/temperature Machine internal temperature */
- /* /dev/hwtrap Hardware fault trap */
- /* /dev/exttrp External device trap */
- "char-major-10-135 rtc", /* /dev/rtc Real time clock */
- "char-major-10-139 openprom", /* /dev/openprom Linux/Sparc interface */
- "char-major-10-144 nvram", /* from Tigran Aivazian <tigran@sco.COM> */
- "char-major-10-157 applicom", /* from David Woodhouse <dwmw2@infradead.org> */
- "char-major-10-175 agpgart", /* /dev/agpgart GART AGP mapping access */
- "char-major-10-184 microcode", /* Tigran Aivazian <tigran@veritas.com> */
-
- "char-major-13 input",
- "char-major-13-32 mousedev",
- "char-major-14 soundcore",
- "char-major-19 cyclades",
- "char-major-20 cyclades",
- "char-major-21 sg",
- "char-major-22 pcxx", /* ?? */
- "char-major-23 pcxx", /* ?? */
- "char-major-27 ftape",
- "char-major-34 scc",
- "char-major-35 tclmidi",
- "char-major-36 netlink",
- "char-major-37 ide-tape",
- "char-major-48 riscom8",
- "char-major-49 riscom8",
- "char-major-57 esp",
- "char-major-58 esp",
- "char-major-63 kdebug",
- "char-major-90 mtdchar", /* from David Woodhouse <dwmw2@infradead.org> */
- "char-major-96 pt",
- "char-major-99 ppdev",
- "char-major-107 3dfx", /* from Tigran Aivazian <tigran@sco.COM> */
- "char-major-108 ppp_generic",
- "char-major-109 lvm-mod",
- "char-major-161 ircomm-tty",
- "char-major-171 raw1394",
- "char-major-195 NVdriver",
- "char-major-200 vxspec",
-
- "dos msdos",
- "dummy0 dummy",
- "dummy1 dummy",
- "eth0 off",
- "iso9660 isofs",
- "md-personality-1 linear",
- "md-personality-2 raid0",
- "md-personality-3 raid1",
- "md-personality-4 raid5",
- "md-personality-7 multipath",
-
- "net-pf-1 unix", /* PF_UNIX 1 Unix domain sockets */
- "net-pf-2 ipv4", /* PF_INET 2 Internet IP Protocol */
- "net-pf-3 off", /* PF_AX25 3 Amateur Radio AX.25 */
- "net-pf-4 ipx", /* PF_IPX 4 Novell IPX */
- "net-pf-5 appletalk", /* PF_APPLETALK 5 Appletalk DDP */
- "net-pf-6 off", /* PF_NETROM 6 Amateur radio NetROM */
- /* PF_BRIDGE 7 Multiprotocol bridge */
- /* PF_AAL5 8 Reserved for Werner's ATM */
- /* PF_X25 9 Reserved for X.25 project */
- "net-pf-10 off", /* PF_INET6 10 IP version 6 */
-
- /* next two from <dairiki@matthews.dairiki.org> Thanks! */
- "net-pf-17 af_packet",
- "net-pf-19 off", /* acorn econet */
-
- "netalias-2 ip_alias",
-
- /* To be able to attach some dongles */
- "irlan0 irlan",
- "irda-dongle-0 tekram",
- "irda-dongle-1 esi",
- "irda-dongle-2 actisys",
- "irda-dongle-3 actisys",
- "irda-dongle-4 girbil",
- "irda-dongle-5 litelink",
- "irda-dongle-6 airport",
- "irda-dongle-7 old_belkin",
-
- "plip0 plip",
- "plip1 plip",
- "tunl0 ipip",
- "cipcb0 cipcb",
- "cipcb1 cipcb",
- "cipcb2 cipcb",
- "cipcb3 cipcb",
-#if defined(__s390__) || defined(__s390x__)
- "ctc0 ctc",
- "ctc1 ctc",
- "ctc2 ctc",
- "iucv0 netiucv",
- "iucv1 netiucv",
-#endif
- "ppp0 ppp",
- "ppp1 ppp",
- "slip0 slip",
- "slip1 slip",
- "tty-ldisc-1 slip",
- "tty-ldisc-3 ppp_async",
- "tty-ldisc-11 irtty", /* IrDA over a normal serial port, or a serial port compatible IrDA port */
- "tty-ldisc-14 ppp_synctty",
- "ppp-compress-18 ppp_mppe",
- "ppp-compress-21 bsd_comp",
- "ppp-compress-24 ppp_deflate",
- "ppp-compress-26 ppp_deflate",
- "ppp ppp_async", /* for 2.4 */
-
-#ifndef __sparc__
- "parport_lowlevel parport_pc",
-#else
- "parport_lowlevel parport_ax",
-#endif
-
- "usbdevfs usbcore",
-
- NULL /* marks the end of the list! */
-};
-
-/*
- * This is the list of pre-defined options.
- * Each entry can be overridden by an entry in /etc/modules.conf
- */
-char *optlist[] =
-{
- "dummy0 -o dummy0",
- "dummy1 -o dummy1",
- "sb io=0x220 irq=7 dma=1 dma16=5 mpu_io=0x330",
- NULL /* marks the end of the list! */
-};
-
-/*
- * This is the list of pre-defined "above"s,
- * used for pull-in of additional modules
- * Each entry can be overridden by an entry in /etc/modules.conf
- */
-char *above[] =
-{
- "hid keybdev mousedev",
- "usbmouse hid",
- "wacom evdev",
- NULL /* marks the end of the list! */
-};
-
-/*
- * This is the list of pre-defined "below"s,
- * used for push-in of additional modules
- * Each entry can be overridden by an entry in /etc/modules.conf
- */
-char *below[] =
-{
- NULL /* marks the end of the list! */
-};
-
-/*
- * This is the list of pre-defined "post-install"s,
- * used to execute commands after loading modules.
- * /etc/modules.conf can add entries but not remove them.
- */
-char *post_install[] =
-{
- "binfmt_misc /bin/mount -t binfmt_misc none /proc/sys/fs/binfmt_misc > /dev/null 2>&1 || :",
- NULL
-};
-
-/*
- * This is the list of pre-defined "pre-remove"s,
- * used to execute commands before unloading modules.
- * /etc/modules.conf can add entries but not remove them.
- */
-char *pre_remove[] =
-{
- "binfmt_misc /bin/umount /proc/sys/fs/binfmt_misc > /dev/null 2>&1 || :",
- NULL
-};
-
-/*
- * This is the list of pre-defined "prune"s,
- * used to exclude paths from scan of /lib/modules.
- * /etc/modules.conf can add entries but not remove them.
- */
-char *prune[] =
-{
- "modules.dep",
- "modules.description",
- "modules.generic_string",
- "modules.pcimap",
- "modules.isapnpmap",
- "modules.usbmap",
- "modules.parportmap",
- "modules.ieee1394map",
- "modules.pnpbiosmap",
- "System.map",
- ".config",
- "build", /* symlink to source tree */
- "vmlinux",
- "vmlinuz",
- "bzImage",
- "zImage",
- ".rhkmvtag", /* wish RedHat had told me before they did this */
- NULL /* marks the end of the list! */
-};
diff --git a/mdk-stage1/insmod-modutils/util/arch64.c b/mdk-stage1/insmod-modutils/util/arch64.c
deleted file mode 100644
index 90886d16b..000000000
--- a/mdk-stage1/insmod-modutils/util/arch64.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Misc utility functions.
- Copyright 1996, 1997 Linux International.
- Written by Keith Owens <kaos@ocs.com.au>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/utsname.h>
-#include "util.h"
-
-/*======================================================================*/
-
-/* Indicate if the current machine uses 64 bit architecture */
-int arch64(void)
-{
- struct utsname uts;
- char *uname_m;
- if (uname(&uts))
- return(0);
- if ((uname_m = getenv("UNAME_MACHINE"))) {
- int l = strlen(uname_m);
- if (l >= sizeof(uts.machine))
- l = sizeof(uts.machine)-1;
- memcpy(uts.machine, uname_m, l);
- uts.machine[l] = '\0';
- }
- return(strstr(uts.machine, "64") != NULL);
-}
diff --git a/mdk-stage1/insmod-modutils/util/config.c b/mdk-stage1/insmod-modutils/util/config.c
deleted file mode 100644
index 7568d955f..000000000
--- a/mdk-stage1/insmod-modutils/util/config.c
+++ /dev/null
@@ -1,1614 +0,0 @@
-/*
- * Handle the configuration, including /etc/modules.conf
- *
- * Copyright 1994, 1995, 1996, 1997:
- * Jacques Gelinas <jack@solucorp.qc.ca>
- * Björn Ekwall <bj0rn@blox.se> February 1999
- * Keith Owens <kaos@ocs.com.au> October 1999
- *
- * "kernelversion" idea from the Debian release via:
- * Wichert Akkerman <wakkerma@cs.leidenuniv.nl>
- *
- * Björn, inspired by Richard Henderson <rth@twiddle.net>, cleaned up
- * the wildcard handling and started using ftw in March 1999
- * Cleanup of hardcoded arrays: Björn Ekwall <bj0rn@blox.se> March 1999
- * Many additional keywords: Björn Ekwall <bj0rn@blox.se> (C) March 1999
- * Standardize on /etc/modules.conf Keith Owens <kaos@ocs.com.au> October 1999
- *
- * Alpha typecast:Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/*
- * Specification: /etc/modules.conf / format
- * Modules may be located at different places in the filesystem.
- *
- * The file /etc/modules.conf contains different definitions to
- * control the manipulation of modules.
- *
- * Standard Unix style comments and continuation line are supported.
- * Comments begin with a # and continue until the end of the line.
- * A line continues on the next one if the last non-white character
- * is a \.
- */
-/* #Specification: /etc/modules.conf / format / official name */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <limits.h>
-#include <sys/param.h>
-#include <errno.h>
-
-#include "util.h"
-#include "config.h"
-#include "alias.h"
-
-int flag_autoclean; /* set/used by modprobe and insmod */
-
-struct utsname uts_info;
-
-struct PATH_TYPE *modpath;
-int nmodpath = 0;
-static int maxpath = 0;
-
-struct EXEC_TYPE *execs;
-int nexecs = 0;
-static int maxexecs = 0;
-
-OPT_LIST *opt_list;
-static int n_opt_list;
-
-OPT_LIST *abovelist;
-static int n_abovelist;
-
-OPT_LIST *belowlist;
-static int n_belowlist;
-
-OPT_LIST *prunelist;
-static int n_prunelist;
-
-OPT_LIST *probe_list;
-static int n_probe_list;
-
-OPT_LIST *probeall_list;
-static int n_probeall_list;
-
-OPT_LIST *aliases;
-static int n_aliases;
-
-char *persistdir = "/var/lib/modules/persist";
-
-const char symprefix[] = SYMPREFIX;
-
-char *insmod_opt = NULL;
-char *config_file = NULL; /* Which file was actually used */
-time_t config_mtime;
-int root_check_off = CONFIG_ROOT_CHECK_OFF; /* Default is modules must be owned by root */
-static char *config_version; /* Hack for config_add */
-int quick = 0; /* Option -A */
-
-/* The initialization order must match the gen_file_enum order in config.h */
-struct gen_files gen_file[] = {
- {"generic_string", NULL, 0},
- {"pcimap", NULL, 0},
- {"isapnpmap", NULL, 0},
- {"usbmap", NULL, 0},
- {"parportmap", NULL, 0},
- {"ieee1394map", NULL, 0},
- {"pnpbiosmap", NULL, 0},
- {"dep", NULL, 0},
-};
-
-const int gen_file_count = sizeof(gen_file)/sizeof(gen_file[0]);
-
-int flag_verbose;
-
-unsigned long safemode;
-
-void verbose(const char *ctl,...)
-{
- if (flag_verbose) {
- va_list list;
- va_start(list, ctl);
- vprintf(ctl, list);
- va_end(list);
- fflush(stdout);
- }
-}
-
-
-/*
- * Check to see if the existing modules.xxx files need updating,
- * based on the timestamps of the modules and the config file.
- */
-static int check_update (const char *file, const struct stat *sb)
-{
- int len = strlen(file);
- int i;
-
- if (!S_ISREG(sb->st_mode))
- return 0;
- for (i = 0; i < gen_file_count; ++i) {
- if (sb->st_mtime > gen_file[i].mtime)
- break;
- }
- if (i == gen_file_count)
- return 0; /* All generated files are up to date */
-
- if (len > 2 && !strcmp(file + len - 2, ".o"))
- return 1;
- else if (len > 4 && !strcmp(file + len - 4, ".mod"))
- return 1;
-#ifdef CONFIG_USE_ZLIB
- else if (len > 5 && !strcmp(file + len - 5, ".o.gz"))
- return 1;
-#endif
- return 0;
-}
-
-static int need_update (const char *force_ver, const char *base_dir)
-{
- struct stat tmp;
- char dep[PATH_MAX];
- int i;
- uname (&uts_info);
- if (!force_ver)
- force_ver = uts_info.release;
-
- if (strlen (force_ver) > 50)
- /* That's just silly. */
- return 1;
-
- for (i = 0; i < gen_file_count; ++i) {
- if (stat(gen_file[i].name, &tmp))
- return 1; /* No dependency file yet, so we need to build it. */
- gen_file[i].mtime = tmp.st_mtime;
- }
-
- if (stat ("/etc/modules.conf", &tmp) &&
- stat ("/etc/conf.modules", &tmp))
- return 1;
-
- for (i = 0; i < gen_file_count; ++i) {
- if (tmp.st_mtime > gen_file[i].mtime)
- return 1; /* Config file is newer. */
- }
-
- snprintf (dep, sizeof(dep), "%s/lib/modules/%s", base_dir, force_ver);
- return xftw (dep, check_update);
-}
-
-
-/*
- * Strip white char at the end of a string.
- * Return the address of the last non white char + 1 (point on the '\0').
- */
-static char *strip_end(char *str)
-{
- int len = strlen(str);
-
- for (str += len - 1; len > 0 && (isspace(*str)); --len, --str)
- *str = '\0';
- return str + 1;
-}
-
-/*
- * Read a line of a configuration file and process continuation lines.
- * Return buf, or NULL if EOF.
- * Blank at the end of line are always stripped.
- * Everything on a line following comchar is a comment.
- *
- * Continuation character is \
- * Comment character is #
- */
-char *fgets_strip(char *buf, int sizebuf, FILE * fin, int *lineno)
-{
- int nocomment = 1; /* No comments found ? */
- int contline = 0;
- char *start = buf;
- char *ret = NULL;
- char comchar = '#';
- char contchar = '\\';
-
- *buf = '\0';
-
- while (fgets(buf, sizebuf, fin) != NULL) {
- char *end = strip_end(buf);
- char *pt = strchr(buf, comchar);
-
- if (pt != NULL) {
- nocomment = 0;
- *pt = '\0';
- end = strip_end(buf);
- }
-
- if (lineno != NULL)
- (*lineno)++;
- ret = start;
- if (contline) {
- char *pt = buf;
-
- while (isspace(*pt))
- pt++;
- if (pt > buf + 1) {
- strcpy(buf + 1, pt); /* safe, backward copy */
- buf[0] = ' ';
- end -= (int) (pt - buf) - 1;
- } else if (pt == buf + 1) {
- buf[0] = ' ';
- }
- }
- if (end > buf && *(end - 1) == contchar) {
- if (end == buf + 1 || *(end - 2) != contchar) {
- /* Continuation */
- contline = 1;
- end--;
- *end = '\0';
- buf = end;
- } else {
- *(end - 1) = '\0';
- break;
- }
- } else {
- break;
- }
- }
-
- return ret;
-}
-
-static char *next_word(char *pt)
-{
- char *match;
- char *pt2;
-
- /* find end of word */
- for (pt2 = pt; *pt2 && !(isspace(*pt2)); ++pt2) {
- if ((match = strchr("\"'`", *pt2)) != NULL) {
- for (++pt2; *pt2 && *pt2 != *match; ++pt2) {
- if (*pt2 == '\\' && *(pt2 + 1) == *match)
- ++pt2;
- }
- }
- }
-
- /* skip leading whitespace before next word */
- if (*pt2) {
- *pt2++ = '\0'; /* terminate last word */
- while (*pt2 && isspace(*pt2))
- ++pt2;
- }
- return pt2;
-}
-
-static GLOB_LIST *addlist(GLOB_LIST *orig, GLOB_LIST *add)
-{
- if (!orig)
- return add;
- /* else */
- orig->pathv = (char **)xrealloc(orig->pathv,
- (orig->pathc + add->pathc + 1) *
- sizeof(char *));
- memcpy(orig->pathv + orig->pathc, add->pathv,
- add->pathc * sizeof(char *));
- orig->pathc += add->pathc;
- orig->pathv[orig->pathc] = NULL;
- /*
- free(add->pathv);
- free(add);
- */
- return orig;
-}
-
-static void decode_list(int *n, OPT_LIST **list, char *arg, int adding,
- char *version, int opts)
-{
- GLOB_LIST *pg;
- GLOB_LIST *prevlist = NULL;
- int i, autoclean = 1;
- int where = *n;
- char *arg2 = next_word(arg);
-
- if (opts && !strcmp (arg, "-k")) {
- if (!*arg2)
- error("Missing module argument after -k\n");
- arg = arg2;
- arg2 = next_word(arg);
- autoclean = 0;
- }
-
- for (i = 0; i < *n; ++i) {
- if (strcmp((*list)[i].name, arg) == 0) {
- if (adding)
- prevlist = (*list)[i].opts;
- else
- free((*list)[i].opts);
- (*list)[i].opts = NULL;
- where = i;
- break;
- }
- }
- if (where == *n) {
- (*list) = (OPT_LIST *)xrealloc((*list),
- (*n + 2) * sizeof(OPT_LIST));
- (*list)[*n].name = xstrdup(arg);
- (*list)[*n].autoclean = autoclean;
- *n += 1;
- memset(&(*list)[*n], 0, sizeof(OPT_LIST));
- } else if (!autoclean)
- (*list)[where].autoclean = 0;
- pg = (GLOB_LIST *)xmalloc(sizeof(GLOB_LIST));
- meta_expand(arg2, pg, NULL, version, ME_ALL);
- (*list)[where].opts = addlist(prevlist, pg);
-}
-
-static void decode_exec(char *arg, int type)
-{
- char *arg2;
-
- execs[nexecs].when = type;
- arg2 = next_word(arg);
- execs[nexecs].module = xstrdup(arg);
- execs[nexecs].cmd = xstrdup(arg2);
- if (++nexecs >= maxexecs) {
- maxexecs += 10;
- execs = (struct EXEC_TYPE *)xrealloc(execs,
- maxexecs * sizeof(struct EXEC_TYPE));
- }
-}
-
-static int build_list(char **in, OPT_LIST **out, char *version, int opts)
-{
- GLOB_LIST *pg;
- int i;
-
- for (i = 0; in[i]; ++i) {
- char *p = xstrdup(in[i]);
- char *pt = next_word(p);
- char *pn = p;
-
- *out = (OPT_LIST *)xrealloc(*out, (i + 2) * sizeof(OPT_LIST));
- (*out)[i].autoclean = 1;
- if (opts && !strcmp (p, "-k")) {
- pn = pt;
- pt = next_word(pn);
- (*out)[i].autoclean = 0;
- }
- pg = (GLOB_LIST *)xmalloc(sizeof(GLOB_LIST));
- meta_expand(pt, pg, NULL, version, ME_ALL);
- (*out)[i].name = xstrdup(pn);
- (*out)[i].opts = pg;
- free(p);
- }
- memset(&(*out)[i], 0, sizeof(OPT_LIST));
-
- return i;
-}
-
-/* Environment variables can override defaults, testing only */
-static void gen_file_env(struct gen_files *gf)
-{
- if (!safemode) {
- char *e = xmalloc(strlen(gf->base)+5), *p1 = gf->base, *p2 = e;
- while ((*p2++ = toupper(*p1++))) ;
- strcpy(p2-1, "PATH"); /* safe, xmalloc */
- if ((p2 = getenv(e)) != NULL) {
- free(gf->name);
- gf->name = xstrdup(p2);
- }
- free(e);
- }
-}
-
-/* Read a config option for a generated filename */
-static int gen_file_conf(struct gen_files *gf, int assgn, const char *parm, const char *arg)
-{
-
- int l = strlen(gf->base);
- if (assgn &&
- strncmp(parm, gf->base, l) == 0 &&
- strcmp(parm+l, "file") == 0 &&
- !gf->name) {
- gf->name = xstrdup(arg);
- return(0);
- }
- return(1);
-}
-
-/* Check we have a name for a generated file */
-static int gen_file_check(struct gen_files *gf, GLOB_LIST *g,
- char *base_dir, char *version)
-{
- char tmp[PATH_MAX];
- int ret = 0;
- if (!gf->name) {
- /*
- * Specification: config file / no xxxfile parameter
- * The default value for generated filename xxx is:
- *
- * xxxfile=/lib/modules/`uname -r`/modules.xxx
- *
- * If the config file exists but lacks an xxxfile
- * specification, the default value is used since
- * the system can't work without one.
- */
- snprintf(tmp, sizeof(tmp), "%s/lib/modules/%s/modules.%s",
- base_dir, version, gf->base);
- gf->name = xstrdup(tmp);
- } else { /* xxxfile defined in modules.conf */
- /*
- * If we have a xxxfile definition in the configuration file
- * we must resolve any shell meta-chars in its value.
- */
- if (meta_expand(gf->name, g, base_dir, version, ME_ALL))
- ret = -1;
- else if (!g->pathv || g->pathv[0] == NULL)
- ret = -1;
- else {
- free(gf->name);
- gf->name = xstrdup(g->pathv[0]);
- }
- }
- return(ret);
-}
-
-/*
- * Read the configuration file.
- * If parameter "all" == 0 then ignore everything except path info
- * Return -1 if any error.
- * Error messages generated.
- */
-static int do_read(int all, char *force_ver, char *base_dir, char *conf_file, int depth)
-{
- #define MAX_LEVEL 20
- FILE *fin;
- GLOB_LIST g;
- int i;
- int assgn;
- int drop_default_paths = 1;
- int lineno = 0;
- int ret = 0;
- int state[MAX_LEVEL + 1]; /* nested "if" */
- int level = 0;
- char buf[3000];
- char tmpline[PATH_MAX];
- char **pathp;
- char *envpath;
- char *version;
- char *type;
- char **glb;
- char old_name[] = "/etc/conf.modules";
- int conf_file_specified = 0;
-
- /*
- * The configuration file is optional.
- * No error is printed if it is missing.
- * If it is missing the following content is assumed.
- *
- * path[boot]=/lib/modules/boot
- *
- * path[toplevel]=/lib/modules/`uname -r`
- *
- * path[toplevel]=/lib/modules/`kernelversion`
- * (where kernelversion gives the major kernel version: "2.0", "2.2"...)
- *
- * path[toplevel]=/lib/modules/default
- *
- * path[kernel]=/lib/modules/kernel
- * path[fs]=/lib/modules/fs
- * path[net]=/lib/modules/net
- * path[scsi]=/lib/modules/scsi
- * path[block]=/lib/modules/block
- * path[cdrom]=/lib/modules/cdrom
- * path[ipv4]=/lib/modules/ipv4
- * path[ipv6]=/lib/modules/ipv6
- * path[sound]=/lib/modules/sound
- * path[fc4]=/lib/modules/fc4
- * path[video]=/lib/modules/video
- * path[misc]=/lib/modules/misc
- * path[pcmcia]=/lib/modules/pcmcia
- * path[atm]=/lib/modules/atm
- * path[usb]=/lib/modules/usb
- * path[ide]=/lib/modules/ide
- * path[ieee1394]=/lib/modules/ieee1394
- * path[mtd]=/lib/modules/mtd
- *
- * The idea is that modprobe will look first if the
- * modules are compiled for the current release of the kernel.
- * If not found, it will look for modules that fit for the
- * general kernelversion (2.0, 2.2 and so on).
- * If still not found, it will look into the default release.
- * And if still not found, it will look in the other directories.
- *
- * The strategy should be like this:
- * When you install a new linux kernel, the modules should go
- * into a directory related to the release (version) of the kernel.
- * Then you can do a symlink "default" to this directory.
- *
- * Each time you compile a new kernel, the make modules_install
- * will create a new directory, but it won't change thee default.
- *
- * When you get a module unrelated to the kernel distribution
- * you can place it in one of the last three directory types.
- *
- * This is the default strategy. Of course you can overide
- * this in /etc/modules.conf.
- *
- * 2.3.15 added a new file tree walk algorithm which made it possible to
- * point at a top level directory and get the same behaviour as earlier
- * versions of modutils. 2.3.16 takes this one stage further, it
- * removes all the individual directory names from most of the scans,
- * only pointing at the top level directory. The only exception is the
- * last ditch scan, scanning all of /lib/modules would be a bad idea(TM)
- * so the last ditch scan still runs individual directory names under
- * /lib/modules.
- *
- * Additional syntax:
- *
- * [add] above module module1 ...
- * Specify additional modules to pull in on top of a module
- *
- * [add] below module module1 ...
- * Specify additional modules needed to be able to load a module
- *
- * [add] prune filename ...
- *
- * [add] probe name module1 ...
- * When "name" is requested, modprobe tries to install each
- * module in the list until it succeeds.
- *
- * [add] probeall name module1 ...
- * When "name" is requested, modprobe tries to install all
- * modules in the list.
- * If any module is installed, the command has succeeded.
- *
- * [add] options module option_list
- *
- * For all of the above, the optional "add" prefix is used to
- * add to a list instead of replacing the contents.
- *
- * include FILE_TO_INCLUDE
- * This does what you expect. No limitation on include levels.
- *
- * persistdir=persist_directory
- * Name the directory to save persistent data from modules.
- *
- * In the following WORD is a sequence if non-white characters.
- * If ' " or ` is found in the string, all characters up to the
- * matching ' " or ` will also be included, even whitespace.
- * Every WORD will then be expanded w.r.t. meta-characters.
- * If the expanded result gives more than one word, then only
- * the first word of the result will be used.
- *
- *
- * define CODE WORD
- * Do a putenv("CODE=WORD")
- *
- * EXPRESSION below can be:
- * WORD compare_op WORD
- * where compare_op is one of == != < <= >= >
- * The string values of the WORDs are compared
- * or
- * -n WORD compare_op WORD
- * where compare_op is one of == != < <= >= >
- * The numeric values of the WORDs are compared
- * or
- * WORD
- * if the expansion of WORD fails, or if the
- * expansion is "0" (zero), "false" or "" (empty)
- * then the expansion has the value FALSE.
- * Otherwise the expansion has the value TRUE
- * or
- * -f FILENAME
- * Test if the file FILENAME exists
- * or
- * -k
- * Test if "autoclean" (i.e. called from the kernel)
- * or
- * ! EXPRESSION
- * A negated expression is also an expression
- *
- * if EXPRESSION
- * any config line
- * ...
- * elseif EXPRESSION
- * any config line
- * ...
- * else
- * any config line
- * ...
- * endif
- *
- * The else and elseif keywords are optional.
- * "if"-statements nest up to 20 levels.
- */
-
- state[0] = 1;
-
- if (force_ver)
- version = force_ver;
- else
- version = uts_info.release;
-
- config_version = xstrdup(version);
-
- /* Only read the default entries on the first file */
- if (depth == 0) {
- maxpath = 100;
- modpath = (struct PATH_TYPE *)xmalloc(maxpath * sizeof(struct PATH_TYPE));
- nmodpath = 0;
-
- maxexecs = 10;
- execs = (struct EXEC_TYPE *)xmalloc(maxexecs * sizeof(struct EXEC_TYPE));
- nexecs = 0;
-
- /*
- * Build predef options
- */
- if (all && optlist[0])
- n_opt_list = build_list(optlist, &opt_list, version, 1);
-
- /*
- * Build predef above
- */
- if (all && above[0])
- n_abovelist = build_list(above, &abovelist, version, 0);
-
- /*
- * Build predef below
- */
- if (all && below[0])
- n_belowlist = build_list(below, &belowlist, version, 0);
-
- /*
- * Build predef prune list
- */
- if (prune[0])
- n_prunelist = build_list(prune, &prunelist, version, 0);
-
- /*
- * Build predef aliases
- */
- if (all && aliaslist[0])
- n_aliases = build_list(aliaslist, &aliases, version, 0);
-
- /*
- * Build predef postinstalls
- */
- if (all && post_install[0])
- for (i=0 ; post_install[i] ; i++ )
- decode_exec(xstrdup(post_install[i]), EXEC_POST_INSTALL);
-
- /*
- * Build predef preremoves
- */
- if (all && pre_remove[0])
- for (i=0 ; pre_remove[i] ; i++ )
- decode_exec(xstrdup(pre_remove[i]), EXEC_PRE_REMOVE);
-
- /* Order and priority is now: (MODPATH + modules.conf) || (predefs + modules.conf) */
- if ((envpath = getenv("MODPATH")) != NULL && !safemode) {
- size_t len;
- char *p;
- char *path;
-
- /* Make a copy so's we can mung it with strtok. */
- len = strlen(envpath) + 1;
- p = alloca(len);
- memcpy(p, envpath, len);
- path = alloca(PATH_MAX);
-
- for (p = strtok(p, ":"); p != NULL; p = strtok(NULL, ":")) {
- len = snprintf(path, PATH_MAX, p, version);
- modpath[nmodpath].path = xstrdup(path);
- if ((type = strrchr(path, '/')) != NULL)
- type += 1;
- else
- type = "misc";
- modpath[nmodpath].type = xstrdup(type);
- if (++nmodpath >= maxpath) {
- maxpath += 100;
- modpath = (struct PATH_TYPE *)xrealloc(modpath,
- maxpath * sizeof(struct PATH_TYPE));
- }
-
- }
- } else {
- /*
- * Build the default "path[type]" configuration
- */
- int n;
- char *k;
-
- /* The first entry in the path list */
- modpath[nmodpath].type = xstrdup("boot");
- snprintf(tmpline, sizeof(tmpline), "%s/lib/modules/boot", base_dir);
- modpath[nmodpath].path = xstrdup(tmpline);
- ++nmodpath;
-
- /* The second entry in the path list, `uname -r` */
- modpath[nmodpath].type = xstrdup("toplevel");
- snprintf(tmpline, sizeof(tmpline), "%s/lib/modules/%s", base_dir, version);
- modpath[nmodpath].path = xstrdup(tmpline);
- ++nmodpath;
-
- /* The third entry in the path list, `kernelversion` */
- modpath[nmodpath].type = xstrdup("toplevel");
- for (n = 0, k = version; *k; ++k) {
- if (*k == '.' && ++n == 2)
- break;
- }
- snprintf(tmpline, sizeof(tmpline), "%s/lib/modules/%.*s", base_dir,
- (/* typecast for Alpha */ int)(k - version), version);
- modpath[nmodpath].path = xstrdup(tmpline);
- ++nmodpath;
-
- /* The rest of the entries in the path list */
- for (pathp = tbpath; *pathp; ++pathp) {
- char **type;
-
- for (type = tbtype; *type; ++type) {
- char path[PATH_MAX];
-
- snprintf(path, sizeof(path), "%s%s/%s", base_dir, *pathp, *type);
- if (meta_expand(path, &g, NULL, version, ME_ALL))
- return -1;
-
- for (glb = g.pathv; glb && *glb; ++glb) {
- modpath[nmodpath].type = xstrdup(*type);
- modpath[nmodpath].path = *glb;
- if (++nmodpath >= maxpath) {
- maxpath += 100;
- modpath = (struct PATH_TYPE *)xrealloc(modpath,
- maxpath * sizeof(struct PATH_TYPE));
- }
- }
- }
- }
- }
-
- /* Environment overrides for testing only, undocumented */
- for (i = 0; i < gen_file_count; ++i)
- gen_file_env(gen_file+i);
-
- } /* End of depth == 0 */
-
- if (conf_file ||
- ((conf_file = getenv("MODULECONFIG")) != NULL && *conf_file && !safemode)) {
- if (!(fin = fopen(conf_file, "r"))) {
- error("Can't open %s", conf_file);
- return -1;
- }
- conf_file_specified = 1;
- } else {
- if (!(fin = fopen((conf_file = ETC_MODULES_CONF), "r"))) {
- /* Fall back to non-standard name */
- if ((fin = fopen((conf_file = old_name), "r"))) {
- fprintf(stderr,
- "Warning: modutils is reading from %s because\n"
- " %s does not exist. The use of %s is\n"
- " deprecated, please rename %s to %s\n"
- " as soon as possible. Command\n"
- " mv %s %s\n",
- old_name, ETC_MODULES_CONF,
- old_name, old_name, ETC_MODULES_CONF,
- old_name, ETC_MODULES_CONF);
- }
- /* So what... use the default configuration */
- }
- }
-
- if (fin) {
- struct stat statbuf1, statbuf2;
- if (fstat(fileno(fin), &statbuf1) == 0)
- config_mtime = statbuf1.st_mtime;
- config_file = xstrdup(conf_file); /* Save name actually used */
- if (!conf_file_specified &&
- stat(ETC_MODULES_CONF, &statbuf1) == 0 &&
- stat(old_name, &statbuf2) == 0) {
- /* Both /etc files exist */
- if (statbuf1.st_dev == statbuf2.st_dev &&
- statbuf1.st_ino == statbuf2.st_ino) {
- if (lstat(ETC_MODULES_CONF, &statbuf1) == 0 &&
- S_ISLNK(statbuf1.st_mode))
- fprintf(stderr,
- "Warning: You do not need a link from %s to\n"
- " %s. The use of %s is deprecated,\n"
- " please remove %s and rename %s\n"
- " to %s as soon as possible. Commands.\n"
- " rm %s\n"
- " mv %s %s\n",
- ETC_MODULES_CONF, old_name,
- old_name, ETC_MODULES_CONF, old_name, ETC_MODULES_CONF,
- ETC_MODULES_CONF,
- old_name, ETC_MODULES_CONF);
- else {
-#ifndef NO_WARN_ON_OLD_LINK
- fprintf(stderr,
- "Warning: You do not need a link from %s to\n"
- " %s. The use of %s is deprecated,\n"
- " please remove %s as soon as possible. Command\n"
- " rm %s\n",
- old_name, ETC_MODULES_CONF,
- old_name, old_name,
- old_name);
-#endif
- }
- }
- else
- fprintf(stderr,
- "Warning: modutils is reading from %s and\n"
- " ignoring %s. The use of %s is deprecated,\n"
- " please remove %s as soon as possible. Command\n"
- " rm %s\n",
- ETC_MODULES_CONF, old_name,
- old_name, old_name,
- old_name);
- }
- }
-
- /*
- * Finally, decode the file
- */
- while (fin && fgets_strip(buf, sizeof(buf) - 1, fin, &lineno) != NULL) {
- char *arg2;
- char *parm = buf;
- char *arg;
- int one_err = 0;
- int adding;
-
- while (isspace(*parm))
- parm++;
-
- if (strncmp(parm, "add", 3) == 0) {
- adding = 1;
- parm += 3;
- while (isspace(*parm))
- parm++;
- } else
- adding = 0;
-
- arg = parm;
-
- if (*parm == '\0')
- continue;
-
- one_err = 1;
-
- while (*arg > ' ' && *arg != '=')
- arg++;
-
- if (*arg == '=')
- assgn = 1;
- else
- assgn = 0;
- *arg++ = '\0';
- while (isspace(*arg))
- arg++;
-
- /*
- * endif
- */
- if (!assgn && strcmp(parm, "endif") == 0) {
- if (level > 0)
- --level;
- else {
- error("unmatched endif in line %d", lineno);
- return -1;
- }
- continue;
- }
-
- /*
- * else
- */
- if (!assgn && strcmp(parm, "else") == 0) {
- if (level <= 0) {
- error("else without if in line %d", lineno);
- return -1;
- }
- state[level] = !state[level];
- continue;
- }
-
- /*
- * elseif
- */
- if (!assgn && strcmp(parm, "elseif") == 0) {
- if (level <= 0) {
- error("elseif without if in line %d", lineno);
- return -1;
- }
- if (state[level] != 0) {
- /*
- * We have already found a TRUE
- * if statement in this "chain".
- * That's what "2" means.
- */
- state[level] = 2;
- continue;
- }
- /* else: No TRUE if has been found, cheat */
- /*
- * The "if" handling increments level,
- * but this is the _same_ level as before.
- * So, compensate for it.
- */
- --level;
- parm = "if";
- /* Fallthru to "if" */
- }
-
- /*
- * if
- */
- if (strcmp(parm, "if") == 0) {
- char *cmp;
- int not = 0;
- int numeric = 0;
-
- if (level >= MAX_LEVEL) {
- error("Too many nested if's in line %d\n", lineno);
- return -1;
- }
- state[++level] = 0; /* default false */
-
- if (*arg == '!') {
- not = 1;
- arg = next_word(arg);
- }
-
- if (strncmp(arg, "-k", 2) == 0) {
- state[level] = flag_autoclean;
- continue;
- }
-
- if (strncmp(arg, "-f", 2) == 0) {
- char *file = next_word(arg);
- meta_expand(file, &g, NULL, version, ME_ALL);
- if (access(g.pathc ? g.pathv[0] : file, R_OK) == 0)
- state[level] = !not;
- else
- state[level] = not;
- continue;
- }
-
- if (strncmp(arg, "-n", 2) == 0) {
- numeric = 1;
- arg = next_word(arg);
- }
-
-
- cmp = next_word(arg);
- if (*cmp) {
- GLOB_LIST g2;
- long n1 = 0;
- long n2 = 0;
- char *w1 = "";
- char *w2 = "";
-
- arg2 = next_word(cmp);
-
- meta_expand(arg, &g, NULL, version, ME_ALL);
- if (g.pathc && g.pathv[0])
- w1 = g.pathv[0];
-
- meta_expand(arg2, &g2, NULL, version, ME_ALL);
- if (g2.pathc && g2.pathv[0])
- w2 = g2.pathv[0];
-
- if (numeric) {
- n1 = strtol(w1, NULL, 0);
- n2 = strtol(w2, NULL, 0);
- }
-
- if (strcmp(cmp, "==") == 0 ||
- strcmp(cmp, "=") == 0) {
- if (numeric)
- state[level] = (n1 == n2);
- else
- state[level] = strcmp(w1, w2) == 0;
- } else if (strcmp(cmp, "!=") == 0) {
- if (numeric)
- state[level] = (n1 != n2);
- else
- state[level] = strcmp(w1, w2) != 0;
- } else if (strcmp(cmp, ">=") == 0) {
- if (numeric)
- state[level] = (n1 >= n2);
- else
- state[level] = strcmp(w1, w2) >= 0;
- } else if (strcmp(cmp, "<=") == 0) {
- if (numeric)
- state[level] = (n1 <= n2);
- else
- state[level] = strcmp(w1, w2) <= 0;
- } else if (strcmp(cmp, ">") == 0) {
- if (numeric)
- state[level] = (n1 > n2);
- else
- state[level] = strcmp(w1, w2) > 0;
- } else if (strcmp(cmp, "<") == 0) {
- if (numeric)
- state[level] = (n1 < n2);
- else
- state[level] = strcmp(w1, w2) < 0;
- }
- } else { /* Check defined value, if any */
- /* undef or defined as
- * "" or "0" or "false" => false
- * defined => true
- */
- if (!meta_expand(arg, &g, NULL, version, ME_ALL) &&
- g.pathc > 0 &&
- strcmp(g.pathv[0], "0") != 0 &&
- strcmp(g.pathv[0], "false") != 0 &&
- strlen(g.pathv[0]) != 0)
- state[level] = 1; /* true */
- }
- if (not)
- state[level] = !state[level];
-
- continue;
- }
-
- /*
- * Should we bother?
- */
- if (state[level] != 1)
- continue;
-
- /*
- * define
- */
- if (!assgn && strcmp(parm, "define") == 0) {
- char env[PATH_MAX];
-
- arg2 = next_word(arg);
- meta_expand(arg2, &g, NULL, version, ME_ALL);
- snprintf(env, sizeof(env), "%s=%s", arg, (g.pathc ? g.pathv[0] : ""));
- putenv(xstrdup(env));
- one_err = 0;
- }
-
- /*
- * include
- */
- if (!assgn && strcmp(parm, "include") == 0) {
- meta_expand(arg, &g, NULL, version, ME_ALL);
-
- if (!do_read(all, version, base_dir, g.pathc ? g.pathv[0] : arg, depth+1))
- one_err = 0;
- else
- error("include %s failed\n", arg);
- }
-
- /*
- * above
- */
- else if (all && !assgn && strcmp(parm, "above") == 0) {
- decode_list(&n_abovelist, &abovelist, arg, adding, version, 0);
- one_err = 0;
- }
-
- /*
- * below
- */
- else if (all && !assgn && strcmp(parm, "below") == 0) {
- decode_list(&n_belowlist, &belowlist, arg, adding, version, 0);
- one_err = 0;
- }
-
- /*
- * prune
- */
- else if (!assgn && strcmp(parm, "prune") == 0) {
- decode_list(&n_prunelist, &prunelist, arg, adding, version, 0);
- one_err = 0;
- }
-
- /*
- * probe
- */
- else if (all && !assgn && strcmp(parm, "probe") == 0) {
- decode_list(&n_probe_list, &probe_list, arg, adding, version, 0);
- one_err = 0;
- }
-
- /*
- * probeall
- */
- else if (all && !assgn && strcmp(parm, "probeall") == 0) {
- decode_list(&n_probeall_list, &probeall_list, arg, adding, version, 0);
- one_err = 0;
- }
-
- /*
- * options
- */
- else if (all && !assgn && strcmp(parm, "options") == 0) {
- decode_list(&n_opt_list, &opt_list, arg, adding, version, 1);
- one_err = 0;
- }
-
- /*
- * alias
- */
- else if (all && !assgn && strcmp(parm, "alias") == 0) {
- /*
- * Replace any previous (default) definitions
- * for the same module
- */
- decode_list(&n_aliases, &aliases, arg, 0, version, 0);
- one_err = 0;
- }
-
- /*
- * Specification: /etc/modules.conf
- * The format of the commands in /etc/modules.conf are:
- *
- * pre-install module command
- * install module command
- * post-install module command
- * pre-remove module command
- * remove module command
- * post-remove module command
- *
- * The different words are separated by tabs or spaces.
- */
- /*
- * pre-install
- */
- else if (all && !assgn && (strcmp(parm, "pre-install") == 0)) {
- decode_exec(arg, EXEC_PRE_INSTALL);
- one_err = 0;
- }
-
- /*
- * install
- */
- else if (all && !assgn && (strcmp(parm, "install") == 0)) {
- decode_exec(arg, EXEC_INSTALL);
- one_err = 0;
- }
-
- /*
- * post-install
- */
- else if (all && !assgn && (strcmp(parm, "post-install") == 0)) {
- decode_exec(arg, EXEC_POST_INSTALL);
- one_err = 0;
- }
-
- /*
- * pre-remove
- */
- else if (all && !assgn && (strcmp(parm, "pre-remove") == 0)) {
- decode_exec(arg, EXEC_PRE_REMOVE);
- one_err = 0;
- }
-
- /*
- * remove
- */
- else if (all && !assgn && (strcmp(parm, "remove") == 0)) {
- decode_exec(arg, EXEC_REMOVE);
- one_err = 0;
- }
-
- /*
- * post-remove
- */
- else if (all && !assgn && (strcmp(parm, "post-remove") == 0)) {
- decode_exec(arg, EXEC_POST_REMOVE);
- one_err = 0;
- }
-
- /*
- * insmod_opt=
- */
- else if (assgn && (strcmp(parm, "insmod_opt") == 0)) {
- insmod_opt = xstrdup(arg);
- one_err = 0;
- }
-
- /*
- * keep
- */
- else if (!assgn && (strcmp(parm, "keep") == 0)) {
- drop_default_paths = 0;
- one_err = 0;
- }
-
- /*
- * path...=
- */
- else if (assgn && strncmp(parm, "path", 4) == 0) {
- /*
- * Specification: config file / path parameter
- * The path parameter specifies a directory to
- * search for modules.
- * This parameter may be repeated multiple times.
- *
- * Note that the actual path may be defined using
- * wildcards and other shell meta-chars, such as "*?`".
- * For example:
- * path[misc]=/lib/modules/1.1.5?/misc
- *
- * Optionally the path keyword carries a tag.
- * This tells us a little more about the purpose of
- * this directory and allows some automated operations.
- * A path is marked with a tag by adding the tag,
- * enclosed in square brackets, to the path keyword:
- * #
- * path[boot]=/lib/modules/boot
- * #
- * This case identifies the path a of directory
- * holding modules loadable a boot time.
- */
-
- if (drop_default_paths) {
- int n;
-
- /*
- * Specification: config file / path / default
- *
- * Whenever there is a path[] specification
- * in the config file, all the default
- * path are reset.
- *
- * If one instead wants to _add_ to the default
- * set of paths, one has to have the option
- * keep
- * before the first path[]-specification line
- * in the configuration file.
- */
- drop_default_paths = 0;
- for (n = 0; n < nmodpath; n++) {
- free(modpath[n].path);
- free(modpath[n].type);
- }
- nmodpath = 0;
- }
-
- /*
- * Get (the optional) tag
- * If the tag is missing, the word "misc"
- * is assumed.
- */
- type = "misc";
-
- if (parm[4] == '[') {
- char *pt_type = parm + 5;
-
- while (*pt_type != '\0' && *pt_type != ']')
- pt_type++;
-
- if (*pt_type == ']' && pt_type[1] == '\0') {
- *pt_type = '\0';
- type = parm + 5;
- } /* else CHECKME */
- }
-
- /*
- * Handle the actual path description
- */
- if (meta_expand(arg, &g, base_dir, version, ME_ALL))
- return -1;
- for (glb = g.pathv; glb && *glb; ++glb) {
- modpath[nmodpath].type = xstrdup(type);
- modpath[nmodpath].path = *glb;
- if (++nmodpath >= maxpath) {
- maxpath += 100;
- modpath = (struct PATH_TYPE *)xrealloc(modpath,
- maxpath * sizeof(struct PATH_TYPE));
- }
- }
- one_err = 0;
- }
-
- /*
- * persistdir
- */
- else if (assgn && strcmp(parm, "persistdir") == 0) {
- meta_expand(arg, &g, NULL, version, ME_ALL);
- persistdir = xstrdup(g.pathc ? g.pathv[0] : arg);
- one_err = 0;
- }
-
- /* Names for generated files in config file */
- for (i = 0; one_err && i < gen_file_count; ++i)
- one_err = gen_file_conf(gen_file+i, assgn, parm, arg);
-
- /*
- * any errors so far?
- */
- if (all == 0)
- one_err = 0;
- else if (one_err) {
- error("Invalid line %d in %s\n\t%s",
- lineno, conf_file, buf);
- ret = -1;
- }
- }
- if (fin)
- fclose(fin);
-
- if (level) {
- error("missing endif at %s EOF", conf_file);
- ret = -1;
- }
-
- if (ret)
- return ret;
- /* else */
-
- if (depth == 0) {
- /* Check we have names for generated files */
- for (i = 0; !ret && i < gen_file_count; ++i)
- ret = gen_file_check(gen_file+i, &g, base_dir, version);
- }
-
- return ret;
-}
-
-int config_read(int all, char *force_ver, char *base_dir, char *conf_file)
-{
- int r;
- if (modpath != NULL)
- return 0; /* already initialized */
-
- if (uname(&uts_info) < 0) {
- error("Failed to find kernel name information");
- return -1;
- }
-
- if (access(MODUTILS_MACROS, R_OK) == 0){
- r = do_read(all, force_ver, base_dir, MODUTILS_MACROS, 0);
- r = do_read(all, force_ver, "", conf_file, 1);
- } else {
- r = do_read(all, force_ver, base_dir, conf_file, 0);
- }
-
- if (quick && !r && !need_update (force_ver, base_dir))
- exit (0);
-
- return r;
-}
-
-/****************************************************************************/
-/*
- * FIXME: Far too much global state. KAO.
- */
-static int found;
-static int favail;
-static int one_only;
-static int meta_expand_type;
-char **list;
-static const char *filter_by_file;
-static char *filter_by_dir;
-
-/*
- * Add a file name if it exist
- */
-static int config_add(const char *file, const struct stat *sb)
-{
- int i;
- int npaths = 0;
- char **paths = NULL;
-
- if (meta_expand_type) {
- GLOB_LIST g;
- char **p;
- char full[PATH_MAX];
-
- snprintf(full, sizeof(full), "%s/%s", file, filter_by_file);
-
- if (filter_by_dir && !strstr(full, filter_by_dir))
- return 0;
-
- if (meta_expand(full, &g, NULL, config_version, meta_expand_type))
- return 1;
- for (p = g.pathv; p && *p; ++p) {
- paths = (char **)xrealloc(paths,
- (npaths + 1) * sizeof(char *));
- paths[npaths++] = *p;
- }
- } else { /* normal path match or match with "*" */
- if (!S_ISREG(sb->st_mode))
- return 0;
-
- if (strcmp(filter_by_file, "*")) {
- char *p;
-
- if ((p = strrchr(file, '/')) == NULL)
- p = (char *)file;
- else
- p += 1;
-
- if (strcmp(p, filter_by_file))
- return 0;
- }
- if (filter_by_dir && !strstr(file, filter_by_dir))
- return 0;
- paths = (char **)xmalloc(sizeof(char **));
- *paths = xstrdup(file);
- npaths = 1;
- }
-
- for (i = 0; i < npaths; ++i) {
- struct stat sbuf;
-
- if (S_ISDIR(sb->st_mode)) {
- if (stat(paths[i], &sbuf) == 0)
- sb = &sbuf;
- }
- if (S_ISREG(sb->st_mode) && sb->st_mode & S_IRUSR) {
- int j;
- char **this;
-
- if (!root_check_off) {
- if (sb->st_uid != 0) {
- error("%s is not owned by root", paths[i]);
- continue;
- }
- }
-
- /* avoid duplicates */
- for (j = 0, this = list; j < found; ++j, ++this) {
- if (strcmp(*this, paths[i]) == 0) {
- free(paths[i]);
- goto next;
- }
- }
-
- list[found] = paths[i];
- if (++found >= favail)
- list = (char **)xrealloc(list,
- (favail += 100) * sizeof(char *));
-
- if (one_only) {
- for (j = i + 1; j < npaths; ++j)
- free(paths[j]);
- free(paths);
- return 1; /* finish xftw */
- }
- }
- next:
- }
-
- if (npaths > 0)
- free(paths);
-
- return 0;
-}
-
-/*
- * Find modules matching the name "match" in directory of type "type"
- * (type == NULL matches all)
- *
- * Return a pointer to the list of modules found (or NULL if error).
- * Update the counter (sent as parameter).
- */
-GLOB_LIST *config_lstmod(const char *match, const char *type, int first_only)
-{
- /*
- * Note:
- * There are _no_ wildcards remaining in the path descriptions!
- */
- struct stat sb;
- int i;
- int ret = 0;
- char *path = NULL;
- char this[PATH_MAX];
-
- if (!match)
- match = "*";
- one_only = first_only;
- found = 0;
- filter_by_file = match;
- filter_by_dir = NULL;
- if (type) {
- char tmpdir[PATH_MAX];
- snprintf(tmpdir, sizeof(tmpdir), "/%s/", type);
- filter_by_dir = xstrdup(tmpdir);
- }
- /* In safe mode, the module name is always handled as is, without meta
- * expansion. It might have come from an end user via kmod and must
- * not be trusted. Even in unsafe mode, only apply globbing to the
- * module name, not command expansion. We trust config file input so
- * applying command expansion is safe, we do not trust command line input.
- * This assumes that the only time the user can specify -C config file
- * is when they run under their own authority. In particular all
- * mechanisms that call modprobe as root on behalf of the user must
- * run in safe mode, without letting the user supply a config filename.
- */
- meta_expand_type = 0;
- if (strpbrk(match, SHELL_META) && strcmp(match, "*") && !safemode)
- meta_expand_type = ME_GLOB|ME_BUILTIN_COMMAND;
-
- list = (char **)xmalloc((favail = 100) * sizeof(char *));
-
- for (i = 0; i < nmodpath; i++) {
- path = modpath[i].path;
- /* Special case: insmod: handle single, non-wildcard match */
- if (first_only && strpbrk(match, SHELL_META) == NULL) {
- /* Fix for "2.1.121 syntax */
- snprintf(this, sizeof(this), "%s/%s/%s", path,
- modpath[i].type, match);
- if (stat(this, &sb) == 0 &&
- config_add(this, &sb))
- break;
- /* End fix for "2.1.121 syntax */
-
- snprintf(this, sizeof(this), "%s/%s", path, match);
- if (stat(this, &sb) == 0 &&
- config_add(this, &sb))
- break;
- }
-
- /* Start looking */
- if ((ret = xftw(path, config_add))) {
- break;
- }
- }
- if (ret >= 0) {
- GLOB_LIST *g = (GLOB_LIST *)xmalloc(sizeof(GLOB_LIST));
- g->pathc = found;
- g->pathv = list;
- free(filter_by_dir);
- return g;
- }
- free(list);
- free(filter_by_dir);
- return NULL;
-}
-
-/* Given a bare module name, poke through the module path to find the file. */
-char *search_module_path(const char *base)
-{
- GLOB_LIST *g;
-
- if (config_read(0, NULL, "", NULL) < 0)
- return NULL;
- /* else */
- g = config_lstmod(base, NULL, 1);
- if (g == NULL || g->pathc == 0) {
- char base_o[PATH_MAX];
-
- snprintf(base_o, sizeof(base_o), "%s.o", base);
- g = config_lstmod(base_o, NULL, 1);
-#ifdef CONFIG_USE_ZLIB
- if (g == NULL || g->pathc == 0) {
- snprintf(base_o, sizeof(base_o), "%s.o.gz", base);
- g = config_lstmod(base_o, NULL, 1);
- }
-#endif
- }
- if (g == NULL || g->pathc == 0)
- return NULL;
- /* else */
- return g->pathv[0];
-}
diff --git a/mdk-stage1/insmod-modutils/util/gzfiles.c b/mdk-stage1/insmod-modutils/util/gzfiles.c
deleted file mode 100644
index 8d02253bb..000000000
--- a/mdk-stage1/insmod-modutils/util/gzfiles.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This simple library intends to make it transparent to read gzipped and/or
- * standard files. This is simple enough to fit modutils' needs, but may be
- * easily adapted to anyone's needs. It's completely free, do what you want
- * with it . - Willy Tarreau <willy@meta-x.org> - 2000/05/05 -
- */
-
-#ifdef CONFIG_USE_ZLIB
-
-#include <stdio.h>
-#include <zlib.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-/* redefinition of gz_stream which isn't exported by zlib */
-typedef struct gz_stream {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- FILE *file; /* .gz file */
- Byte *inbuf; /* input buffer */
- Byte *outbuf; /* output buffer */
- uLong crc; /* crc32 of uncompressed data */
- char *msg; /* error message */
- char *path; /* path name for debugging only */
- int transparent; /* 1 if input file is not a .gz file */
- char mode; /* 'w' or 'r' */
- long startpos; /* start of compressed data in file (header skipped) */
-} gz_stream;
-
-/* maximum number of simultaneous open files, also greater file descriptor number */
-#define MAXFD 64
-
-/* this static list is assumed to be filled with NULLs at runtime */
-static gzFile gzf_fds[MAXFD];
-
-/* returns the filedesc of the opened file. */
-int gzf_open(const char *name, int mode) {
- int fd;
- gzFile g;
-
- if ((g=gzopen(name, "rb")) != NULL) {
- fd=fileno(((gz_stream*)g)->file);
- gzf_fds[fd]=g;
- }
- else if ((fd=open(name, mode)) != -1) {
- gzf_fds[fd]=NULL; /* NULL means not GZ mode */
- }
- return fd;
-}
-
-off_t gzf_lseek(int fd, off_t offset, int whence) {
- if (fd<0 || fd>=MAXFD || gzf_fds[fd]==NULL)
- return lseek(fd, offset, whence);
- else
- return gzseek(gzf_fds[fd], offset, whence);
-}
-
-int gzf_read(int fd, void *buf, size_t count) {
- if (fd<0 || fd>=MAXFD || gzf_fds[fd]==NULL)
- return read(fd, buf, count);
- else
- return gzread(gzf_fds[fd], buf, count);
-}
-
-void gzf_close(int fd) {
- if (fd<0 || fd>=MAXFD || gzf_fds[fd]==NULL)
- close(fd);
- else
- gzclose(gzf_fds[fd]);
-}
-#endif
-
diff --git a/mdk-stage1/insmod-modutils/util/logger.c b/mdk-stage1/insmod-modutils/util/logger.c
deleted file mode 100644
index 4774a0beb..000000000
--- a/mdk-stage1/insmod-modutils/util/logger.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Error logging facilities.
- Copyright 1996, 1997 Linux International.
-
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <syslog.h>
-
-#include "util.h"
-
-/*======================================================================*/
-
-int log;
-
-int errors;
-const char *error_file;
-
-#define STOREMSG
-#ifdef STOREMSG
-struct cbuf {
- struct cbuf *next;
- int type;
- char *msg;
-} *head, *tail;
-
-static void dumpmsg(void)
-{
- for (;head; head = head->next)
- syslog(head->type, "%s", head->msg);
-}
-#endif /* STOREMSG */
-
-void setsyslog(const char *program)
-{
- openlog(program, LOG_CONS, LOG_DAEMON);
-#ifdef STOREMSG
- atexit(dumpmsg);
-#endif
- log = 1;
-}
-
-#ifdef _STANDALONE_
-static int silent;
-
-const char *program_name;
-
-static void savemsg(int type, char *msg)
-{
- struct cbuf *me = (struct cbuf *)xmalloc(sizeof(struct cbuf));
- char *s = xstrdup(msg);
-
- me->next = NULL;
- me->type = type;
- me->msg = s;
-
- if (tail)
- tail->next = me;
- else
- head = me;
- tail = me;
-}
-
-void error(const char *fmt,...)
-{
- va_list args;
-
- if (silent)
- ;
- else if (log) {
- char buf[2*PATH_MAX];
- int n;
-
- if (error_file)
- n = snprintf(buf, sizeof(buf), "%s: ", error_file);
- else
- n = 0;
- va_start(args, fmt);
- vsnprintf(buf + n, sizeof(buf) - n, fmt, args);
- va_end(args);
-#ifdef STOREMSG
- savemsg(LOG_ERR, buf);
-#else
- syslog(LOG_ERR, "%s", buf);
-#endif
- } else {
- if (error_file)
- fprintf(stderr, "%s: ", error_file);
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
- putc('\n', stderr);
- }
-
- errors++;
-}
-
-void lprintf(const char *fmt,...)
-{
- va_list args;
-
- if (silent);
- else if (log) {
- char buf[2*PATH_MAX];
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
-#ifdef STOREMSG
- savemsg(LOG_INFO, buf);
-#else
- syslog(LOG_INFO, "%s", buf);
-#endif
- } else {
- va_start(args, fmt);
- vfprintf(stdout, fmt, args);
- va_end(args);
- putchar('\n');
- }
-}
-#else /* _STANDALONE_ */
-#include "../../log.h"
-void error(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- vlog_message(s, p);
- va_end(p);
-}
-
-void lprintf(const char *s, ...)
-{
- va_list p;
-
- va_start(p, s);
- vlog_message(s, p);
- va_end(p);
-}
-#endif
-
diff --git a/mdk-stage1/insmod-modutils/util/meta_expand.c b/mdk-stage1/insmod-modutils/util/meta_expand.c
deleted file mode 100644
index 41fb4024c..000000000
--- a/mdk-stage1/insmod-modutils/util/meta_expand.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Handle expansion of meta charaters
- *
- * Copyright 1999 Björn Ekwall <bj0rn@blox.se>
- *
- * "kernelversion" idea from the Debian release via:
- * Wichert Akkerman <wakkerma@cs.leidenuniv.nl>
- *
- * Use wordexp(): idea from Tim Waugh <tim@cyberelk.demon.co.uk>
- *
- * Alpha typecast: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_WORDEXP
-#undef HAVE_WORDEXP
-#define HAVE_WORDEXP 0
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include <ctype.h>
-#if HAVE_WORDEXP
-#include <wordexp.h>
-#elif HAVE_GLOB
-#include <glob.h>
-#endif
-#include "util.h"
-
-/*
- * Split into words delimited by whitespace,
- * handle remaining quotes though...
- * If strip_quotes != 0 then strip one level of quotes from the line.
- */
-static void split_line(GLOB_LIST *g, char *line, int strip_quotes)
-{
- int len;
- char *d;
- char *e;
- char *p;
- char tmpline[PATH_MAX];
-
- for (p = line; *p; p = e) {
- /* Skip leading whitespace */
- while (*p && isspace(*p))
- ++p;
-
- /* find end of word */
- d = tmpline;
- for (e = p; *e && !(isspace(*e)); ++e) {
- char match;
-
- /* Quote handling */
- switch (*e) {
- case '\\':
- if (!strip_quotes)
- *d++ = *e;
- break;
-
- case '"':
- case '\'':
- match = *e;
- if (!strip_quotes)
- *d++ = *e;
- for (++e; *e && *e != match; ++e) {
- *d++ = *e;
- if (*e == '\\' && *(e + 1) == match)
- *d++ = *++e;
- }
- if (!strip_quotes)
- *d++ = *e;
- break;
-
- default:
- *d++ = *e;
- break;
- }
- }
-
- if ((len = (int)(d - tmpline)) > 0) {
- char *str = xmalloc(len + 1);
- strncpy(str, tmpline, len);
- str[len] = '\0';
- g->pathv = (char **)xrealloc(g->pathv,
- (g->pathc + 2) * sizeof(char *));
- g->pathv[g->pathc++] = str;
- }
- }
-
- if (g->pathc)
- g->pathv[g->pathc] = NULL;
-}
-
-static int glob_it(char *pt, GLOB_LIST *g)
-{
-#if HAVE_WORDEXP
- wordexp_t w;
-
- memset(&w, 0, sizeof(w));
- if (wordexp(pt, &w, WRDE_UNDEF)) {
- /*
- error("wordexp %s failed", pt);
- */
- return -1;
- }
- /* else */
- g->pathc = w.we_wordc;
- g->pathv = w.we_wordv;
-
- return 0;
-#elif HAVE_GLOB /* but not wordexp */
- glob_t w;
-
- memset(&w, 0, sizeof(w));
- if (glob(pt, GLOB_NOSORT, NULL, &w)) {
- /*
- error("glob %s failed", pt);
- */
- return -1;
- }
- /* else */
- if (w.gl_pathc && strpbrk(w.gl_pathv[0], SHELL_META)) {
- globfree(&w);
- return -1;
- }
- g->pathc = w.gl_pathc;
- g->pathv = w.gl_pathv;
-
- return 0;
-#else /* Neither wordexp nor glob */
- return -1;
-#endif
-}
-
-/*
- * Expand the string (including meta-character) to a list of matches
- *
- * Return 0 if OK else -1
- */
-int meta_expand(char *pt, GLOB_LIST *g, char *base_dir, char *version, int type)
-{
- FILE *fin;
- int len = 0;
- char *line = NULL;
- char *p, *p1;
- char tmpline[PATH_MAX + 1];
- char wrk[sizeof(tmpline)];
- char tmpcmd[2*sizeof(tmpline)+20]; /* room for /bin/echo "text" */
-
- g->pathc = 0;
- g->pathv = NULL;
-
- /*
- * Take care of version dependent expansions
- * Needed for forced version handling
- */
- if ((p = strchr(pt, '`')) != NULL && (type & ME_BUILTIN_COMMAND)) {
- do {
- char *s;
-
- for (s = p + 1; isspace(*s); ++s)
- ;
-
- if (strncmp(s, "uname -r", 8) == 0) {
- while (*s && (*s != '`'))
- ++s;
- if (*s == '`') {
- *p = '\0';
- snprintf(wrk, sizeof(wrk), "%s%s%s",
- pt,
- version,
- s + 1);
- *p = '`';
- }
- strcpy(tmpline, wrk); /* safe, same size */
- pt = tmpline;
- } else if (strncmp(s, "kernelversion", 13) == 0) {
- while (*s && (*s != '`'))
- ++s;
- if (*s == '`') {
- int n;
- char *k;
-
- *p = '\0';
- for (n = 0, k = version; *k; ++k) {
- if (*k == '.' && ++n == 2)
- break;
- }
- snprintf(wrk, sizeof(wrk), "%s%.*s%s",
- pt,
- /* typecast for Alpha */
- (int)(k - version),
- version,
- s + 1);
- *p = '`';
- strcpy(tmpline, wrk); /* safe, same size */
- pt = tmpline;
- }
- } else
- break;
- } while ((p = strchr(pt, '`')) != NULL);
- }
-
- /*
- * Any remaining meta-chars?
- */
- if (strpbrk(pt, SHELL_META) == NULL) {
- /*
- * No meta-chars.
- * Split into words, delimited by whitespace.
- */
- snprintf(wrk, sizeof(wrk), "%s%s", (base_dir ? base_dir : ""), pt);
- strcpy(tmpline, wrk); /* safe, same size */
- if ((p = strtok(tmpline, " \t\n")) != NULL) {
- while (p) {
- g->pathv = (char **)xrealloc(g->pathv,
- (g->pathc + 2) * sizeof(char *));
- g->pathv[g->pathc++] = xstrdup(p);
- p = strtok(NULL, " \t\n");
- }
- }
- if (g->pathc)
- g->pathv[g->pathc] = NULL;
- return 0;
- }
- /* else */
- /*
- * Handle remaining meta-chars
- */
-
- /*
- * Just plain quotes?
- */
- if (strpbrk(pt, "&();|<>$`!{}[]~=+:?*") == NULL &&
- (p = strpbrk(pt, "\"'\\"))) {
- split_line(g, pt, 1);
- return 0;
- }
-
- if (strpbrk(pt, "&();|<>$`\"'\\!{}~+:[]~?*") == NULL) {
- /* Only "=" remaining, should be module options */
- split_line(g, pt, 0);
- return 0;
- }
-
- /*
- * If there are meta-characters and
- * if they are only shell glob meta-characters: do globbing
- */
-#if HAVE_WORDEXP
- if (strpbrk(pt, "&();|<>`\"'\\!{}~=+:") == NULL &&
- strpbrk(pt, "$[]~?*"))
-#else
- if (strpbrk(pt, "&();|<>$`\"'\\!{}~=+:") == NULL &&
- strpbrk(pt, "[]~?*"))
-#endif
- if ((type & ME_GLOB) && glob_it(pt, g) == 0)
- return 0;
-
- if (strpbrk(pt, "&();|<>$`\"'\\!{}~+:[]~?*") == NULL) {
- /* Only "=" remaining, should be module options */
- split_line(g, pt, 0);
- return 0;
- }
-
- /*
- * Last resort: Use "echo".
- * DANGER: Applying shell expansion to user supplied input is a
- * major security risk. Modutils code should only do meta
- * expansion via shell commands for trusted data. Basically
- * this means only for data in the config file. Even that
- * assumes that the user cannot run modprobe as root with
- * their own config file. Programs (including the kernel)
- * that invoke modprobe as root with user supplied input must
- * pass exactly one user supplied parameter and must set
- * safe mode.
- */
- if (!(type & ME_SHELL_COMMAND))
- return 0;
- snprintf(wrk, sizeof(wrk), "%s%s", (base_dir ? base_dir : ""), pt);
- strcpy(tmpline, wrk); /* safe, same size */
- snprintf(tmpcmd, sizeof(tmpcmd), "/bin/echo \"");
- for (p = tmpline, p1 = tmpcmd + strlen(tmpcmd); *p; ++p, ++p1) {
- if (*p == '"' || *p == '\\')
- *p1++ = '\\';
- *p1 = *p;
- }
- *p1++ = '"';
- *p1++ = '\0';
- if (p1 - tmpcmd > sizeof(tmpcmd)) {
- error("tmpcmd overflow, should never happen");
- exit(1);
- }
- if ((fin = popen(tmpcmd, "r")) == NULL) {
- error("Can't execute: %s", tmpcmd);
- return -1;
- }
- /* else */
-
- /*
- * Collect the result
- */
- while (fgets(tmpcmd, PATH_MAX, fin) != NULL) {
- int l = strlen(tmpcmd);
-
- line = (char *)xrealloc(line, len + l + 1);
- line[len] = '\0';
- strcat(line + len, tmpcmd); /* safe, realloc */
- len += l;
- }
- pclose(fin);
-
- if (line) {
- /* shell used to strip one set of quotes. Paranoia code in
- * 2.3.20 stops that strip so we do it ourselves.
- */
- split_line(g, line, 1);
- free(line);
- }
-
- return 0;
-}
diff --git a/mdk-stage1/insmod-modutils/util/modstat.c b/mdk-stage1/insmod-modutils/util/modstat.c
deleted file mode 100644
index ad82306c0..000000000
--- a/mdk-stage1/insmod-modutils/util/modstat.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Get kernel symbol table(s) and other relevant module info.
- *
- * Add module_name_list and l_module_name_list.
- * Keith Owens <kaos@ocs.com.au> November 1999.
- * Björn Ekwall <bj0rn@blox.se> in February 1999 (C)
- * Initial work contributed by Richard Henderson <rth@tamu.edu>
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "util.h"
-#include "module.h"
-#include "obj.h"
-#include "modstat.h"
-
-struct module_stat *module_stat;
-size_t n_module_stat;
-char *module_name_list;
-size_t l_module_name_list;
-struct module_symbol *ksyms;
-size_t nksyms;
-int k_new_syscalls;
-
-static void *old_kernsym;
-
-/************************************************************************/
-static void drop(void)
-{
- /*
- * Clean the slate for multiple runs
- */
- if (module_stat) {
- struct module_stat *m;
- int i;
-
- for (i = 0, m = module_stat; i < n_module_stat; ++i, ++m) {
- if (m->syms)
- free(m->syms);
- if (m->refs)
- free(m->refs);
- }
- free(module_stat);
- module_stat = NULL;
- n_module_stat = 0;
- }
- if (module_name_list) {
- free(module_name_list);
- module_name_list = NULL;
- l_module_name_list = 0;
- }
- if (ksyms) {
- free(ksyms);
- ksyms = NULL;
- nksyms = 0;
- }
- if (old_kernsym) {
- free(old_kernsym);
- old_kernsym = NULL;
- }
-}
-
-static int new_get_kernel_info(int type)
-{
- struct module_stat *modules;
- struct module_stat *m;
- struct module_symbol *syms;
- struct module_symbol *s;
- size_t ret;
- size_t bufsize;
- size_t nmod;
- size_t nsyms;
- size_t i;
- size_t j;
- char *module_names;
- char *mn;
-
- drop();
-
- /*
- * Collect the loaded modules
- */
- module_names = xmalloc(bufsize = 256);
- while (query_module(NULL, QM_MODULES, module_names, bufsize, &ret)) {
- if (errno != ENOSPC) {
- error("QM_MODULES: %m\n");
- return 0;
- }
- module_names = xrealloc(module_names, bufsize = ret);
- }
- module_name_list = module_names;
- l_module_name_list = bufsize;
- n_module_stat = nmod = ret;
- module_stat = modules = xmalloc(nmod * sizeof(struct module_stat));
- memset(modules, 0, nmod * sizeof(struct module_stat));
-
- /* Collect the info from the modules */
- for (i = 0, mn = module_names, m = modules;
- i < nmod;
- ++i, ++m, mn += strlen(mn) + 1) {
- struct module_info info;
-
- m->name = mn;
- if (query_module(mn, QM_INFO, &info, sizeof(info), &ret)) {
- if (errno == ENOENT) {
- /* The module was removed out from underneath us. */
- m->flags = NEW_MOD_DELETED;
- continue;
- }
- /* else oops */
- error("module %s: QM_INFO: %m", mn);
- return 0;
- }
-
- m->addr = info.addr;
-
- if (type & K_INFO) {
- m->size = info.size;
- m->flags = info.flags;
- m->usecount = info.usecount;
- m->modstruct = info.addr;
- }
-
- if (type & K_REFS) {
- int mm;
- char *mrefs;
- char *mr;
-
- mrefs = xmalloc(bufsize = 64);
- while (query_module(mn, QM_REFS, mrefs, bufsize, &ret)) {
- if (errno != ENOSPC) {
- error("QM_REFS: %m");
- return 1;
- }
- mrefs = xrealloc(mrefs, bufsize = ret);
- }
- for (j = 0, mr = mrefs;
- j < ret;
- ++j, mr += strlen(mr) + 1) {
- for (mm = 0; mm < i; ++mm) {
- if (strcmp(mr, module_stat[mm].name) == 0) {
- m->nrefs += 1;
- m->refs = xrealloc(m->refs, m->nrefs * sizeof(struct module_stat **));
- m->refs[m->nrefs - 1] = module_stat + mm;
- break;
- }
- }
- }
- free(mrefs);
- }
-
- if (type & K_SYMBOLS) { /* Want info about symbols */
- syms = xmalloc(bufsize = 1024);
- while (query_module(mn, QM_SYMBOLS, syms, bufsize, &ret)) {
- if (errno == ENOSPC) {
- syms = xrealloc(syms, bufsize = ret);
- continue;
- }
- if (errno == ENOENT) {
- /*
- * The module was removed out
- * from underneath us.
- */
- m->flags = NEW_MOD_DELETED;
- free(syms);
- goto next;
- } else {
- error("module %s: QM_SYMBOLS: %m", mn);
- return 0;
- }
- }
- nsyms = ret;
-
- m->nsyms = nsyms;
- m->syms = syms;
-
- /* Convert string offsets to string pointers */
- for (j = 0, s = syms; j < nsyms; ++j, ++s)
- s->name += (unsigned long) syms;
- }
- next:
- }
-
- if (type & K_SYMBOLS) { /* Want info about symbols */
- /* Collect the kernel's symbols. */
- syms = xmalloc(bufsize = 16 * 1024);
- while (query_module(NULL, QM_SYMBOLS, syms, bufsize, &ret)) {
- if (errno != ENOSPC) {
- error("kernel: QM_SYMBOLS: %m");
- return 0;
- }
- syms = xrealloc(syms, bufsize = ret);
- }
- nksyms = nsyms = ret;
- ksyms = syms;
-
- /* Convert string offsets to string pointers */
- for (j = 0, s = syms; j < nsyms; ++j, ++s)
- s->name += (unsigned long) syms;
- }
-
- return 1;
-}
-
-#ifdef COMPAT_2_0
-/************************************************************************/
-
-#define mscan(offs,siz,ptr) \
- if (lseek(kmem_fd, (off_t)(offs), SEEK_SET) == -1 || \
- read(kmem_fd, (ptr), (siz)) != (siz)) { \
- if (kmem_fd != -1) \
- close(kmem_fd); \
- error("kmem: %m"); \
- return 0; \
- }
-
-#define OLD_MOD_RUNNING 1
-#define OLD_MOD_DELETED 2
-#define OLD_MOD_VISITED 0x20000000
-
-/* Fetch all the symbols and divvy them up as appropriate for the modules. */
-static int old_get_kernel_info(int type)
-{
- struct old_kernel_sym *kernsym;
- struct old_kernel_sym *k;
- struct module_stat *module;
- struct module_stat *mod;
- struct module_symbol *s = NULL;
- int kmem_fd = -1;
- int nkernsym;
- int nmod;
- int nm;
- int nms;
- int i;
-
- drop();
- module_name_list = xmalloc(1);
- *module_name_list = '\0';
-
- if ((nkernsym = get_kernel_syms(NULL)) < 0) {
- error("get_kernel_syms: %m");
- return 0;
- }
- kernsym = k = xmalloc(nkernsym * sizeof(struct old_kernel_sym));
- old_kernsym = kernsym;
- if (get_kernel_syms(kernsym) != nkernsym) {
- error("inconsistency with get_kernel_syms -- is someone else "
- "playing with modules?");
- free(kernsym);
- return 0;
- }
-
- /* Number of modules */
- for (k = kernsym, nmod = 0, i = 0; i < nkernsym; ++i, ++k) {
- if (k->name[0] == '#') {
- if (k->name[1]) {
- ++nmod;
- i = strlen(k->name+1) + 1;
- module_name_list =
- xrealloc(module_name_list,
- l_module_name_list + i);
- strcpy(module_name_list+l_module_name_list, /* safe, xrealloc */
- k->name+1);
- l_module_name_list += i; /* NUL separated strings */
- }
- else
- break;
- }
- }
- module_stat = mod = module = xmalloc(nmod * sizeof(struct module_stat));
- memset(module, 0, nmod * sizeof(struct module_stat));
- n_module_stat = nmod;
-
- /*
- * Will we need kernel internal info?
- */
- if ((type & K_INFO) || (type & K_REFS)) {
- if ((kmem_fd = open("/dev/kmem", O_RDONLY)) < 0) {
- perror("ksyms: open /dev/kmem");
- return 0;
- }
- }
-
- /*
- * Collect the module information.
- */
- for (k = kernsym, nm = 0, i = 0; i < nkernsym; ++i, ++k) {
- if (k->name[0] == '#') {
- struct old_kernel_sym *p;
- struct old_module info;
-
- if (k->name[1] == '\0')
- break; /* kernel resident symbols follow */
- /* else normal module */
-
- module = mod++;
- ++nm;
- module->name = k->name + 1;
- module->modstruct = k->value;
-
- if ((type & K_INFO) || (type & K_REFS)) {
- long tmp;
- /*
- * k->value is the address of the
- * struct old_module
- * in the kernel (for use via /dev/kmem)
- */
- mscan(k->value, sizeof(info), &info);
- module->addr = info.addr;
- module->size = info.size * getpagesize();
-
- mscan(info.addr, sizeof(long), &tmp);
- module->flags = info.state &
- (OLD_MOD_RUNNING | OLD_MOD_DELETED);
- module->flags |= NEW_MOD_USED_ONCE; /* Cheat */
- if (tmp & OLD_MOD_AUTOCLEAN)
- module->flags |= NEW_MOD_AUTOCLEAN;
- if (tmp & OLD_MOD_VISITED)
- module->flags |= NEW_MOD_VISITED;
-
- module->usecount = tmp & ~(OLD_MOD_AUTOCLEAN | OLD_MOD_VISITED);
- }
-
- if ((type & K_REFS) && info.ref) {
- struct old_module_ref mr;
- int j;
- unsigned long ref = info.ref;
-
- do {
- mscan(ref, sizeof(struct old_module_ref), &mr);
- for (j = 0; j < nm -1; ++j) {
- if (mr.module == module_stat[j].modstruct) {
- module->nrefs += 1;
- module->refs = xrealloc(module->refs, module->nrefs * sizeof(struct module_stat **));
- module->refs[module->nrefs - 1] = module_stat + j;
- break;
- }
- }
- } while ((ref = mr.next) != 0);
- }
-
- if (!(type & K_SYMBOLS))
- continue;
- /*
- * Find out how many symbols this module has.
- */
- for (nms = 0, p = k+1; p->name[0] != '#'; ++p)
- ++nms;
- s = xmalloc(nms * sizeof(struct module_symbol));
- module->syms = s;
- module->nsyms = nms;
- } else if (type & K_SYMBOLS) { /* Want info about symbols */
- s->name = (unsigned long) k->name;
- s->value = k->value;
- ++s;
- }
- }
- if ((type & K_INFO) || (type & K_REFS)) {
- if (kmem_fd != -1)
- close(kmem_fd);
- }
-
- /*
- * Kernel resident symbols follows
- */
- if (type & K_SYMBOLS) { /* Want info about symbols */
- if (k->name[0] == '#')
- ++k;
- nksyms = nkernsym - (k - kernsym);
- if (nksyms) {
- ksyms = s = xmalloc(nksyms * sizeof(struct module_symbol));
- for (i = 0; i < nksyms; ++i, ++k) {
- if (k->name[0] != '#') {
- s->name = (unsigned long) k->name;
- s->value = k->value;
- ++s;
- }
- }
- nksyms = s - ksyms;
- } else
- ksyms = NULL;
- }
-
- return 1;
-}
-#endif /* COMPAT_2_0 */
-
-int get_kernel_info(int type)
-{
- k_new_syscalls = !query_module(NULL, 0, NULL, 0, NULL);
-
-#ifdef COMPAT_2_0
- if (!k_new_syscalls)
- return old_get_kernel_info(type);
-#endif /* COMPAT_2_0 */
-
- return new_get_kernel_info(type);
-}
diff --git a/mdk-stage1/insmod-modutils/util/snap_shot.c b/mdk-stage1/insmod-modutils/util/snap_shot.c
deleted file mode 100644
index adf54d28e..000000000
--- a/mdk-stage1/insmod-modutils/util/snap_shot.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Take a snap shot of ksyms and modules for Oops debugging
- Copyright 1999 Linux International.
-
- Contributed by Keith Owens <kaos@ocs.com.au>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <time.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "module.h"
-#include "obj.h"
-#include "modstat.h"
-#include "util.h"
-
-static char snap_dir[] = "/var/log/ksymoops";
-
-/* If snap_dir exists, take a snap shot of ksyms and modules to snap_dir.
- * Prefix the files with the equivalent of
- * date +%Y%m%d%T%M%S | sed -e 's/://g'
- */
-void snap_shot(const char *module_names, int n_module_names)
-{
- char file[] = "ccyymmddhhmmss.modules", buffer[4096];
- static char *infile[] = { "/proc/ksyms", "/proc/modules" };
- static char *suffix[] = { "ksyms", "modules" };
- struct tm *local;
- time_t t;
- int i, l;
- FILE *in, *out;
-
- if (module_names) {
- /* Only snap shot if the list of modules has changed.
- * Otherwise auto cleanup takes a snap shot every time
- * and ends up with a large snap shot directory.
- */
- char *new_module_names;
- size_t n_new_module_names;
- get_kernel_info(0);
- new_module_names = module_name_list;
- n_new_module_names = n_module_stat;
- if (n_module_names && n_new_module_names == n_module_names) {
- while (n_module_names) {
- if (strcmp(module_names, new_module_names))
- break; /* difference detected */
- i = strlen(module_names) + 1;
- module_names += i;
- new_module_names += i;
- --n_module_names;
- }
- }
- if (!n_module_names)
- return; /* no difference, no need for snap shot */
- }
-
- if (chdir(snap_dir))
- return;
- t = time(NULL);
- local = localtime(&t);
- for (i = 0; i < sizeof(infile)/sizeof(infile[0]); ++i) {
- snprintf(file, sizeof(file), "%04d%02d%02d%02d%02d%02d.%s",
- local->tm_year+1900,
- local->tm_mon + 1,
- local->tm_mday,
- local->tm_hour,
- local->tm_min,
- local->tm_sec,
- suffix[i]);
- out = fopen(file, "w");
- if (!out) {
- error("cannot create %s/%s %m", snap_dir, file);
- return;
- }
- in = fopen(infile[i], "r");
- if (!in) {
- error("cannot open %s %m", infile[i]);
- return;
- }
- while ((l = fread(buffer, 1, sizeof(buffer), in)) > 0) {
- if (fwrite(buffer, l, 1, out) != 1) {
- error("unable to write to %s %m", file);
- fclose(in);
- fclose(out);
- return;
- }
- }
- if (ferror(in))
- error("unable to read from %s %m", infile[i]);
- fclose(in);
- fflush(out);
- fclose(out);
- }
-}
-
-/* If snap_dir exists, log a message to snap_dir. The log file is called the
- * equivalent of date +%Y%m%d | sed -e 's/://g'. Each line is prefixed with
- * timestamp down to seconds and followed by a newline.
- */
-void snap_shot_log(const char *fmt,...)
-{
- char date[] = "ccyymmdd", file[] = "ccyymmdd.log", stamp[] = "ccyymmdd hhmmss";
- struct tm *local;
- time_t t;
- FILE *log;
- va_list args;
- int save_errno = errno;
-
- if (chdir(snap_dir))
- return;
- t = time(NULL);
- local = localtime(&t);
- snprintf(date, sizeof(date), "%04d%02d%02d",
- local->tm_year+1900,
- local->tm_mon + 1,
- local->tm_mday);
- snprintf(file, sizeof(file), "%s.log", date);
- log = fopen(file, "a");
- if (!log) {
- error("cannot create %s/%s %m", snap_dir, file);
- return;
- }
- snprintf(stamp, sizeof(stamp), "%s %02d%02d%02d",
- date,
- local->tm_hour,
- local->tm_min,
- local->tm_sec);
- fprintf(log, "%s ", stamp);
- va_start(args, fmt);
- errno = save_errno; /* fmt may use %m */
- vfprintf(log, fmt, args);
- va_end(args);
- fprintf(log, "\n");
- fflush(log);
- fclose(log);
-}
diff --git a/mdk-stage1/insmod-modutils/util/sys_cm.c b/mdk-stage1/insmod-modutils/util/sys_cm.c
deleted file mode 100644
index d19a5ba4b..000000000
--- a/mdk-stage1/insmod-modutils/util/sys_cm.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Functions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "module.h"
-
-/* Kernel headers before 2.1.mumble need this on the Alpha to get
- _syscall* defined. */
-#define __LIBRARY__
-
-#include <asm/unistd.h>
-
-
-/*======================================================================*/
-
-#if defined(__i386__) || defined(__m68k__) || defined(__arm__)
-
-#define __NR__create_module __NR_create_module
-static inline _syscall2(long, _create_module, const char *, name, size_t, size)
-
-unsigned long create_module(const char *name, size_t size)
-{
- /* Why all this fuss?
-
- In linux 2.1, the address returned by create module point in
- kernel space which is now mapped at the top of user space (at
- 0xc0000000 on i386). This looks like a negative number for a
- long. The normal syscall macro of linux 2.0 (and all libc compile
- with linux 2.0 or below) consider that the return value is a
- negative number and consider it is an error number (A kernel
- convention, return value are positive or negative, indicating the
- error number).
-
- By checking the value of errno, we know if we have been fooled by
- the syscall2 macro and we fix it. */
-
- long ret = _create_module(name, size);
- if (ret == -1 && errno > 125)
- {
- ret = -errno;
- errno = 0;
- }
- return ret;
-}
-
-#elif defined(__alpha__)
-
-/* Alpha doesn't have the same problem, exactly, but a bug in older
- kernels fails to clear the error flag. Clear it here explicitly. */
-
-#define __NR__create_module __NR_create_module
-static inline _syscall4(unsigned long, _create_module, const char *, name,
- size_t, size, size_t, dummy, size_t, err);
-
-unsigned long create_module(const char *name, size_t size)
-{
- return _create_module(name, size, 0, 0);
-}
-
-#else
-
-/* Sparc, MIPS, (and Alpha, but that's another problem) don't mistake
- return values for errors due to the nature of the system call. */
-
-_syscall2(unsigned long, create_module, const char *, name, size_t, size)
-
-#endif
diff --git a/mdk-stage1/insmod-modutils/util/sys_dm.c b/mdk-stage1/insmod-modutils/util/sys_dm.c
deleted file mode 100644
index 611234efa..000000000
--- a/mdk-stage1/insmod-modutils/util/sys_dm.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Functions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "module.h"
-
-/* Kernel headers before 2.1.mumble need this on the Alpha to get
- _syscall* defined. */
-#define __LIBRARY__
-
-#include <asm/unistd.h>
-
-
-/*======================================================================*/
-
-_syscall1(int, delete_module, const char *, name)
diff --git a/mdk-stage1/insmod-modutils/util/sys_gks.c b/mdk-stage1/insmod-modutils/util/sys_gks.c
deleted file mode 100644
index b639fc990..000000000
--- a/mdk-stage1/insmod-modutils/util/sys_gks.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Functions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "module.h"
-
-/* Kernel headers before 2.1.mumble need this on the Alpha to get
- _syscall* defined. */
-#define __LIBRARY__
-
-#include <asm/unistd.h>
-
-
-/*======================================================================*/
-
-_syscall1(int, get_kernel_syms, struct old_kernel_sym *, ksyms)
diff --git a/mdk-stage1/insmod-modutils/util/sys_nim.c b/mdk-stage1/insmod-modutils/util/sys_nim.c
deleted file mode 100644
index c267ddf10..000000000
--- a/mdk-stage1/insmod-modutils/util/sys_nim.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Functions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "module.h"
-
-/* Kernel headers before 2.1.mumble need this on the Alpha to get
- _syscall* defined. */
-#define __LIBRARY__
-
-#include <asm/unistd.h>
-
-
-/*======================================================================*/
-
-#ifndef CONFIG_USE_SYSCALL
-
-extern int init_module(const char *name, const struct module *info);
-
-int
-sys_init_module(const char *name, const struct module *info)
-{
- return init_module(name, info);
-}
-
-#else
-
-#define __NR_sys_init_module __NR_init_module
-_syscall2(int, sys_init_module, const char *, name,
- const struct module *, info)
-
-#endif
diff --git a/mdk-stage1/insmod-modutils/util/sys_oim.c b/mdk-stage1/insmod-modutils/util/sys_oim.c
deleted file mode 100644
index b915e36a5..000000000
--- a/mdk-stage1/insmod-modutils/util/sys_oim.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Functions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "module.h"
-
-/* Kernel headers before 2.1.mumble need this on the Alpha to get
- _syscall* defined. */
-#define __LIBRARY__
-
-#include <asm/unistd.h>
-
-
-/*======================================================================*/
-
-#define __NR_old_sys_init_module __NR_init_module
-_syscall5(int, old_sys_init_module, const char *, name, char *, code,
- unsigned, codesize, struct old_mod_routines *, routines,
- struct old_symbol_table *, symtab)
diff --git a/mdk-stage1/insmod-modutils/util/sys_qm.c b/mdk-stage1/insmod-modutils/util/sys_qm.c
deleted file mode 100644
index ba478832b..000000000
--- a/mdk-stage1/insmod-modutils/util/sys_qm.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Functions for the Linux module syscall interface.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "module.h"
-
-/* Kernel headers before 2.1.mumble need this on the Alpha to get
- _syscall* defined. */
-#define __LIBRARY__
-
-#include <asm/unistd.h>
-
-
-/*======================================================================*/
-
-/* I am fucking tired of the "this doesn't build on 2.0.x" questions.
- But if you ask, we still officially require 2.1.x to build. */
-#if !defined(__NR_query_module)
-# if defined(__i386__)
-# define __NR_query_module 167
-# elif defined(__alpha__)
-# define __NR_query_module 347
-# elif defined(__sparc__)
-# define __NR_query_module 184
-# elif defined(__mc68000__)
-# define __NR_query_module 167
-# elif defined(__arm__)
-# define __NR_query_module (__NR_SYSCALL_BASE + 167)
-# elif defined(__mips__)
-# define __NR_query_module 4187
-# endif
-#endif
-
-_syscall5(int, query_module, const char *, name, int, which,
- void *, buf, size_t, bufsize, size_t *, ret);
diff --git a/mdk-stage1/insmod-modutils/util/xftw.c b/mdk-stage1/insmod-modutils/util/xftw.c
deleted file mode 100644
index fe764a63c..000000000
--- a/mdk-stage1/insmod-modutils/util/xftw.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * modutils specific implementation of ftw().
- *
- * Copyright 2000:
- * Keith Owens <kaos@ocs.com.au> August 2000
- *
- * This file is part of the Linux modutils.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/*
- modutils requires special processing during the file tree walk
- of /lib/modules/<version> and any paths that the user specifies.
- The standard ftw() does a blind walk of all paths and can end
- up following the build symlink down the kernel source tree.
- Although nftw() has the option to get more control such as not
- automatically following symbolic links, even that is not enough
- for modutils. The requirements are:
-
- Paths must be directories or symlinks to directories.
-
- Each directory is read and sorted into alphabetical order
- before processing.
-
- A directory is type 1 iff it was specified on a path statement
- (either explicit or default) and the directory contains a
- subdirectory with one of the known names and the directory name
- does not end with "/kernel". Otherwise it is type 2.
-
- In a type 1 directory, walk the kernel subdirectory if it exists,
- then the old known names in their historical order then any
- remaining directory entries in alphabetical order and finally any
- non-directory entries in alphabetical order.
-
- Entries in a type 1 directory are filtered against the "prune"
- list. A type 1 directory can contain additional files which
- are not modules nor symlinks to modules. The prune list skips
- known additional files, if a distribution wants to store
- additional text files in the top level directory they should be
- added to the prune list.
-
- A type 2 directory must contain only modules or symlinks to
- modules. They are processed in alphabetical order, without
- pruning. Symlinks to directories are an error in type 2
- directories.
-
- The user function is not called for type 1 directories, nor for
- pruned entries. It is called for type 2 directories and their
- contents. It is also called for any files left in a type 1
- directory after pruning and processing type 2 subdirectories.
- The user function never sees symlinks, they are resolved before
- calling the function.
-
- Why have different directory types? The original file tree
- walk was not well defined. Some users specified each directory
- individually, others just pointed at the top level directory.
- Either version worked until the "build" symlink was added. Now
- users who specify the top level directory end up running the
- entire kernel source tree looking for modules, not nice. We
- cannot just ignore symlinks because pcmcia uses symlinks to
- modules for backwards compatibility.
-
- Type 1 is when a user specifies the top level directory which needs
- special processing, type 2 is individual subdirectories. But the
- only way to tell the difference is by looking at the contents. The
- "/kernel" directory introduced in 2.3.12 either contains nothing
- (old make modules_install) or contains all the kernel modules using
- the same tree structure as the source. Because "/kernel" can
- contain old names but is really a type 2 directory, it is detected
- as a special case.
- */
-
-#include <dirent.h>
-#include <errno.h>
-#include <limits.h>
-#include <malloc.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "util.h"
-#include "config.h"
-
-extern char *tbpath[];
-
-extern OPT_LIST *prune_list;
-extern int n_prune_list;
-
-extern char *tbtype[];
-
-struct xftw_dirent {
- struct stat statbuf;
- char *name;
- char *fullname;
-};
-
-#define XFTW_MAXDEPTH 64 /* Maximum directory depth handled */
-
-typedef struct {
- struct xftw_dirent *contents;
- int size;
- int used;
-} xftw_tree_t;
-
-static xftw_tree_t tree[XFTW_MAXDEPTH];
-
-/* Free all data for one tree level */
-static void xftw_free_tree(int depth)
-{
- int i;
- xftw_tree_t *t = tree+depth;
- for (i = 0; i < t->size; ++i) {
- free(t->contents[i].name);
- free(t->contents[i].fullname);
- }
- free(t->contents);
- t->contents = NULL;
- t->size = 0;
- t->used = 0;
-}
-
-/* Increment dirents used at this depth, resizing if necessary */
-static void xftw_add_dirent(int depth)
-{
- xftw_tree_t *t = tree+depth;
- int i, size = t->size;
- if (++t->used < size)
- return;
- size += 10; /* arbitrary increment */
- t->contents = xrealloc(t->contents, size*sizeof(*(t->contents)));
- for (i = t->size; i < size; ++i) {
- memset(&(t->contents[i].statbuf), 0, sizeof(t->contents[i].statbuf));
- t->contents[i].name = NULL;
- t->contents[i].fullname = NULL;
- }
- t->size = size;
-}
-
-/* Concatenate directory name and entry name into one string.
- * Note: caller must free result or leak.
- */
-static char *xftw_dir_name(const char *directory, const char *entry)
-{
- int i = strlen(directory);
- char *name;
- if (entry)
- i += strlen(entry);
- i += 2;
- name = xmalloc(i);
- strcpy(name, directory); /* safe, xmalloc */
- if (*directory && entry)
- strcat(name, "/"); /* safe, xmalloc */
- if (entry)
- strcat(name, entry); /* safe, xmalloc */
- return(name);
-}
-
-/* Call the user function for a directory entry */
-static int xftw_do_name(const char *directory, const char *entry, struct stat *sb, xftw_func_t funcptr)
-{
- int ret = 0;
- char *name = xftw_dir_name(directory, entry);
-
- if (S_ISLNK(sb->st_mode)) {
- char real[PATH_MAX], *newname;
- verbose("resolving %s symlink to ", name);
- if (!(newname = realpath(name, real))) {
- if (errno == ENOENT) {
- verbose("%s: does not exist, dangling symlink ignored\n", real);
- goto cleanup;
- }
- perror("... failed");
- goto cleanup;
- }
- verbose("%s ", newname);
- if (lstat(newname, sb)) {
- error("lstat on %s failed ", newname);
- perror("");
- goto cleanup;
- }
- free(name);
- name = xstrdup(newname);
- }
-
- if (!S_ISREG(sb->st_mode) &&
- !S_ISDIR(sb->st_mode)) {
- error("%s is not plain file nor directory\n", name);
- goto cleanup;
- }
-
- verbose("user function %s\n", name);
- ret = (*funcptr)(name, sb);
-cleanup:
- free(name);
- return(ret);
-}
-
-/* Sort directory entries into alphabetical order */
-static int xftw_sortdir(const void *a, const void *b)
-{
- return(strcmp(((struct xftw_dirent *)a)->name, ((struct xftw_dirent *)b)->name));
-}
-
-/* Read a directory and sort it, ignoring "." and ".." */
-static int xftw_readdir(const char *directory, int depth)
-{
- DIR *d;
- struct dirent *ent;
- verbose("xftw_readdir %s\n", directory);
- if (!(d = opendir(directory))) {
- perror(directory);
- return(1);
- }
- while ((ent = readdir(d))) {
- char *name;
- struct xftw_dirent *f;
- if (strcmp(ent->d_name, ".") == 0 ||
- strcmp(ent->d_name, "..") == 0)
- continue;
- name = xftw_dir_name(directory, ent->d_name);
- xftw_add_dirent(depth);
- f = tree[depth].contents+tree[depth].used-1;
- f->name = xstrdup(ent->d_name);
- f->fullname = name; /* do not free name, it is in use */
- if (lstat(name, &(f->statbuf))) {
- perror(name);
- return(1);
- }
- }
- closedir(d);
- qsort(tree[depth].contents, tree[depth].used, sizeof(*(tree[0].contents)), &xftw_sortdir);
- return(0);
-}
-
-/* Process a type 2 directory */
-int xftw_type2(const char *directory, const char *entry, int depth, xftw_func_t funcptr)
-{
- int ret, i;
- xftw_tree_t *t = tree+depth;
- struct stat statbuf;
- char *dirname = xftw_dir_name(directory, entry);
-
- verbose("type 2 %s\n", dirname);
- if (depth > XFTW_MAXDEPTH) {
- error("xftw_type2 exceeded maxdepth\n");
- ret = 1;
- goto cleanup;
- }
- if ((ret = xftw_readdir(dirname, depth)))
- goto cleanup;
-
- t = tree+depth;
- /* user function sees type 2 directories */
- if ((ret = lstat(dirname, &statbuf)) ||
- (ret = xftw_do_name("", dirname, &statbuf, funcptr)))
- goto cleanup;
-
- /* user sees all contents of type 2 directory, no pruning */
- for (i = 0; i < t->used; ++i) {
- struct xftw_dirent *c = t->contents+i;
- if (S_ISLNK(c->statbuf.st_mode)) {
- if (!stat(c->name, &(c->statbuf))) {
- if (S_ISDIR(c->statbuf.st_mode)) {
- error("symlink to directory is not allowed, %s ignored\n", c->name);
- *(c->name) = '\0'; /* ignore it */
- }
- }
- }
- if (!*(c->name))
- continue;
- if (S_ISDIR(c->statbuf.st_mode)) {
- /* recursion is the curse of the programming classes */
- ret = xftw_type2(dirname, c->name, depth+1, funcptr);
- if (ret)
- goto cleanup;
- }
- else if ((ret = xftw_do_name(dirname, c->name, &(c->statbuf), funcptr)))
- goto cleanup;
- *(c->name) = '\0'; /* processed */
- }
-
- ret = 0;
-cleanup:
- free(dirname);
- return(ret);
-}
-
-/* Only external visible function. Decide on the type of directory and
- * process accordingly.
- */
-int xftw(const char *directory, xftw_func_t funcptr)
-{
- struct stat statbuf;
- int ret, i, j, type;
- xftw_tree_t *t;
- struct xftw_dirent *c;
-
- verbose("xftw starting at %s ", directory);
- if (lstat(directory, &statbuf)) {
- verbose("lstat on %s failed\n", directory);
- return(0);
- }
- if (S_ISLNK(statbuf.st_mode)) {
- char real[PATH_MAX];
- verbose("resolving symlink to ");
- if (!(directory = realpath(directory, real))) {
- if (errno == ENOENT) {
- verbose("%s: does not exist, dangling symlink ignored\n", real);
- return(0);
- }
- perror("... failed");
- return(-1);
- }
- verbose("%s ", directory);
- if (lstat(directory, &statbuf)) {
- error("lstat on %s failed ", directory);
- perror("");
- return(-1);
- }
- }
- if (!S_ISDIR(statbuf.st_mode)) {
- error("%s is not a directory\n", directory);
- return(-1);
- }
- verbose("\n");
-
- /* All returns after this point must be via cleanup */
-
- if ((ret = xftw_readdir(directory, 0)))
- goto cleanup;
-
- t = tree; /* depth 0 */
- type = 2;
- for (i = 0 ; type == 2 && i < t->used; ++i) {
- c = t->contents+i;
- for (j = 0; tbtype[j]; ++j) {
- if (strcmp(c->name, tbtype[j]) == 0 &&
- S_ISDIR(c->statbuf.st_mode)) {
- const char *p = directory + strlen(directory) - 1;
- if (*p == '/')
- --p;
- if (p - directory >= 6 && strncmp(p-6, "/kernel", 7) == 0)
- continue; /* "/kernel" path is a special case, type 2 */
- type = 1; /* known subdirectory */
- break;
- }
- }
- }
-
- if (type == 1) {
- OPT_LIST *p;
- /* prune entries in type 1 directories only */
- for (i = 0 ; i < t->used; ++i) {
- for (p = prunelist; p->name; ++p) {
- c = t->contents+i;
- if (strcmp(p->name, c->name) == 0) {
- verbose("pruned %s\n", c->name);
- *(c->name) = '\0'; /* ignore */
- }
- }
- }
- /* run known subdirectories first in historical order, "kernel" is now top of list */
- for (i = 0 ; i < t->used; ++i) {
- c = t->contents+i;
- for (j = 0; tbtype[j]; ++j) {
- if (*(c->name) &&
- strcmp(c->name, tbtype[j]) == 0 &&
- S_ISDIR(c->statbuf.st_mode)) {
- if ((ret = xftw_type2(directory, c->name, 1, funcptr)))
- goto cleanup;
- *(c->name) = '\0'; /* processed */
- }
- }
- }
- /* any other directories left, in alphabetical order */
- for (i = 0 ; i < t->used; ++i) {
- c = t->contents+i;
- if (*(c->name) &&
- S_ISDIR(c->statbuf.st_mode)) {
- if ((ret = xftw_type2(directory, c->name, 1, funcptr)))
- goto cleanup;
- *(c->name) = '\0'; /* processed */
- }
- }
- /* anything else is passed to the user function */
- for (i = 0 ; i < t->used; ++i) {
- c = t->contents+i;
- if (*(c->name)) {
- verbose("%s found in type 1 directory %s\n", c->name, directory);
- if ((ret = xftw_do_name(directory, c->name, &(c->statbuf), funcptr)))
- goto cleanup;
- *(c->name) = '\0'; /* processed */
- }
- }
- }
- else {
- /* type 2 */
- xftw_free_tree(0);
- if ((ret = xftw_type2(directory, NULL, 0, funcptr)))
- goto cleanup;
- }
-
- /* amazing, it all worked */
- ret = 0;
-cleanup:
- for (i = 0; i < XFTW_MAXDEPTH; ++i)
- xftw_free_tree(i);
- return(ret);
-}
diff --git a/mdk-stage1/insmod-modutils/util/xmalloc.c b/mdk-stage1/insmod-modutils/util/xmalloc.c
deleted file mode 100644
index da0be2953..000000000
--- a/mdk-stage1/insmod-modutils/util/xmalloc.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Misc utility functions.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include "util.h"
-
-
-/*======================================================================*/
-
-void *
-xmalloc(size_t size)
-{
- void *ptr = malloc(size ? size : 1);
- if (!ptr)
- {
- error("Out of memory");
- exit(1);
- }
- return ptr;
-}
diff --git a/mdk-stage1/insmod-modutils/util/xrealloc.c b/mdk-stage1/insmod-modutils/util/xrealloc.c
deleted file mode 100644
index adc0558f1..000000000
--- a/mdk-stage1/insmod-modutils/util/xrealloc.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Misc utility functions.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include "util.h"
-
-
-/*======================================================================*/
-
-void *
-xrealloc(void *old, size_t size)
-{
- void *ptr = realloc(old, size);
- if (!ptr)
- {
- error("Out of memory");
- exit(1);
- }
- return ptr;
-}
diff --git a/mdk-stage1/insmod-modutils/util/xstrcat.c b/mdk-stage1/insmod-modutils/util/xstrcat.c
deleted file mode 100644
index ed4a2bf20..000000000
--- a/mdk-stage1/insmod-modutils/util/xstrcat.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Misc utility functions.
- Copyright 2000 Keith Owens <kaos@ocs.com.au>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <string.h>
-#include "util.h"
-
-
-/*======================================================================*/
-
-char *
-xstrcat(char *dest, const char *src, size_t size)
-{
- int ldest = strlen(dest);
- int lsrc = strlen(src);
- if ((size - ldest - 1) < lsrc) {
- error("xstrcat: destination overflow");
- exit(1);
- }
- memcpy(dest+ldest, src, lsrc+1);
- return(dest);
-}
diff --git a/mdk-stage1/insmod-modutils/util/xstrdup.c b/mdk-stage1/insmod-modutils/util/xstrdup.c
deleted file mode 100644
index 46889a094..000000000
--- a/mdk-stage1/insmod-modutils/util/xstrdup.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Misc utility functions.
- Copyright 1996, 1997 Linux International.
- Contributed by Richard Henderson <rth@tamu.edu>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "util.h"
-
-
-/*======================================================================*/
-
-char *
-xstrdup(const char *s)
-{
- char *n = strdup(s);
- if (!n)
- {
- error("Out of memory");
- exit(1);
- }
- return n;
-}
diff --git a/mdk-stage1/insmod-modutils/util/xsystem.c b/mdk-stage1/insmod-modutils/util/xsystem.c
deleted file mode 100644
index 8ffa490a9..000000000
--- a/mdk-stage1/insmod-modutils/util/xsystem.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Misc utility functions.
- Copyright 2000 Keith Owens <kaos@ocs.com.au>
-
- This file is part of the Linux modutils.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <unistd.h>
-
-
-/*======================================================================*/
-
-/* Clone of the system() function From Steven's Advanced Programming in a Unix
- * Environment. Modified to use *argv[] and execvp to avoid shell expansion
- * problems, modutils runs as root so system() is unsafe.
- */
-
-int
-xsystem(const char *file, char *const argv[])
-{
- pid_t pid;
- int status;
- if ((pid = fork()) < 0)
- return(-1);
- if (pid == 0) {
- execvp(file, argv);
- _exit(127);
- }
- while (waitpid(pid, &status, 0) < 0) {
- if (errno != EINTR)
- return(-1);
- }
- return(status);
-}
diff --git a/mdk-stage1/insmod.h b/mdk-stage1/insmod.h
deleted file mode 100644
index 67a746858..000000000
--- a/mdk-stage1/insmod.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _INSMOD_INTERFACE_H_
-#define _INSMOD_INTERFACE_H_
-
-int insmod_call(char * full_filename, char * params);
-
-#endif
diff --git a/mdk-stage1/linux-2.2/nfs.h b/mdk-stage1/linux-2.2/nfs.h
deleted file mode 100644
index 7936d5a71..000000000
--- a/mdk-stage1/linux-2.2/nfs.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * NFS protocol definitions
- */
-#ifndef _LINUX_NFS_H
-#define _LINUX_NFS_H
-
-#include <linux/sunrpc/msg_prot.h>
-
-#define NFS_PORT 2049
-#define NFS_MAXDATA 8192
-#define NFS_MAXPATHLEN 1024
-#define NFS_MAXNAMLEN 255
-#define NFS_MAXGROUPS 16
-#define NFS_FHSIZE 32
-#define NFS_COOKIESIZE 4
-#define NFS_FIFO_DEV (-1)
-#define NFSMODE_FMT 0170000
-#define NFSMODE_DIR 0040000
-#define NFSMODE_CHR 0020000
-#define NFSMODE_BLK 0060000
-#define NFSMODE_REG 0100000
-#define NFSMODE_LNK 0120000
-#define NFSMODE_SOCK 0140000
-#define NFSMODE_FIFO 0010000
-
-
-enum nfs_stat {
- NFS_OK = 0,
- NFSERR_PERM = 1,
- NFSERR_NOENT = 2,
- NFSERR_IO = 5,
- NFSERR_NXIO = 6,
- NFSERR_EAGAIN = 11,
- NFSERR_ACCES = 13,
- NFSERR_EXIST = 17,
- NFSERR_XDEV = 18,
- NFSERR_NODEV = 19,
- NFSERR_NOTDIR = 20,
- NFSERR_ISDIR = 21,
- NFSERR_INVAL = 22, /* that Sun forgot */
- NFSERR_FBIG = 27,
- NFSERR_NOSPC = 28,
- NFSERR_ROFS = 30,
- NFSERR_OPNOTSUPP = 45,
- NFSERR_NAMETOOLONG = 63,
- NFSERR_NOTEMPTY = 66,
- NFSERR_DQUOT = 69,
- NFSERR_STALE = 70,
- NFSERR_WFLUSH = 99
-};
-
-enum nfs_ftype {
- NFNON = 0,
- NFREG = 1,
- NFDIR = 2,
- NFBLK = 3,
- NFCHR = 4,
- NFLNK = 5,
- NFSOCK = 6,
- NFBAD = 7,
- NFFIFO = 8
-};
-
-struct nfs_fh {
- char data[NFS_FHSIZE];
-};
-
-#define NFS_PROGRAM 100003
-#define NFS_VERSION 2
-#define NFSPROC_NULL 0
-#define NFSPROC_GETATTR 1
-#define NFSPROC_SETATTR 2
-#define NFSPROC_ROOT 3
-#define NFSPROC_LOOKUP 4
-#define NFSPROC_READLINK 5
-#define NFSPROC_READ 6
-#define NFSPROC_WRITECACHE 7
-#define NFSPROC_WRITE 8
-#define NFSPROC_CREATE 9
-#define NFSPROC_REMOVE 10
-#define NFSPROC_RENAME 11
-#define NFSPROC_LINK 12
-#define NFSPROC_SYMLINK 13
-#define NFSPROC_MKDIR 14
-#define NFSPROC_RMDIR 15
-#define NFSPROC_READDIR 16
-#define NFSPROC_STATFS 17
-
-/* Mount support for NFSroot */
-#ifdef __KERNEL__
-#define NFS_MNT_PROGRAM 100005
-#define NFS_MNT_VERSION 1
-#define NFS_MNT_PORT 627
-#define NFS_MNTPROC_MNT 1
-#define NFS_MNTPROC_UMNT 3
-#endif
-
-#if defined(__KERNEL__) || defined(NFS_NEED_KERNEL_TYPES)
-
-extern struct rpc_program nfs_program;
-extern struct rpc_stat nfs_rpcstat;
-
-struct nfs_time {
- __u32 seconds;
- __u32 useconds;
-};
-
-struct nfs_fattr {
- enum nfs_ftype type;
- __u32 mode;
- __u32 nlink;
- __u32 uid;
- __u32 gid;
- __u32 size;
- __u32 blocksize;
- __u32 rdev;
- __u32 blocks;
- __u32 fsid;
- __u32 fileid;
- struct nfs_time atime;
- struct nfs_time mtime;
- struct nfs_time ctime;
-};
-
-struct nfs_sattr {
- __u32 mode;
- __u32 uid;
- __u32 gid;
- __u32 size;
- struct nfs_time atime;
- struct nfs_time mtime;
-};
-
-struct nfs_fsinfo {
- __u32 tsize;
- __u32 bsize;
- __u32 blocks;
- __u32 bfree;
- __u32 bavail;
-};
-
-struct nfs_writeargs {
- struct nfs_fh * fh;
- __u32 offset;
- __u32 count;
- const void * buffer;
-};
-
-#ifdef NFS_NEED_XDR_TYPES
-
-struct nfs_sattrargs {
- struct nfs_fh * fh;
- struct nfs_sattr * sattr;
-};
-
-struct nfs_diropargs {
- struct nfs_fh * fh;
- const char * name;
-};
-
-struct nfs_readargs {
- struct nfs_fh * fh;
- __u32 offset;
- __u32 count;
- void * buffer;
-};
-
-struct nfs_createargs {
- struct nfs_fh * fh;
- const char * name;
- struct nfs_sattr * sattr;
-};
-
-struct nfs_renameargs {
- struct nfs_fh * fromfh;
- const char * fromname;
- struct nfs_fh * tofh;
- const char * toname;
-};
-
-struct nfs_linkargs {
- struct nfs_fh * fromfh;
- struct nfs_fh * tofh;
- const char * toname;
-};
-
-struct nfs_symlinkargs {
- struct nfs_fh * fromfh;
- const char * fromname;
- const char * topath;
- struct nfs_sattr * sattr;
-};
-
-struct nfs_readdirargs {
- struct nfs_fh * fh;
- __u32 cookie;
- void * buffer;
- unsigned int bufsiz;
-};
-
-struct nfs_diropok {
- struct nfs_fh * fh;
- struct nfs_fattr * fattr;
-};
-
-struct nfs_readres {
- struct nfs_fattr * fattr;
- unsigned int count;
-};
-
-struct nfs_readlinkres {
- char ** string;
- unsigned int * lenp;
- unsigned int maxlen;
- void * buffer;
-};
-
-struct nfs_readdirres {
- void * buffer;
- unsigned int bufsiz;
-};
-
-#endif /* NFS_NEED_XDR_TYPES */
-#endif /* __KERNEL__ */
-
-#endif
diff --git a/mdk-stage1/linux-2.2/nfs_mount.h b/mdk-stage1/linux-2.2/nfs_mount.h
deleted file mode 100644
index 60493b150..000000000
--- a/mdk-stage1/linux-2.2/nfs_mount.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef _LINUX_NFS_MOUNT_H
-#define _LINUX_NFS_MOUNT_H
-
-/*
- * linux/include/linux/nfs_mount.h
- *
- * Copyright (C) 1992 Rick Sladkey
- *
- * structure passed from user-space to kernel-space during an nfs mount
- */
-
-/*
- * WARNING! Do not delete or change the order of these fields. If
- * a new field is required then add it to the end. The version field
- * tracks which fields are present. This will ensure some measure of
- * mount-to-kernel version compatibility. Some of these aren't used yet
- * but here they are anyway.
- */
-#define NFS_MOUNT_VERSION 3
-
-struct nfs_mount_data {
- int version; /* 1 */
- int fd; /* 1 */
- struct nfs_fh root; /* 1 */
- int flags; /* 1 */
- int rsize; /* 1 */
- int wsize; /* 1 */
- int timeo; /* 1 */
- int retrans; /* 1 */
- int acregmin; /* 1 */
- int acregmax; /* 1 */
- int acdirmin; /* 1 */
- int acdirmax; /* 1 */
- struct sockaddr_in addr; /* 1 */
- char hostname[256]; /* 1 */
- int namlen; /* 2 */
- unsigned int bsize; /* 3 */
-};
-
-/* bits in the flags field */
-
-#define NFS_MOUNT_SOFT 0x0001 /* 1 */
-#define NFS_MOUNT_INTR 0x0002 /* 1 */
-#define NFS_MOUNT_SECURE 0x0004 /* 1 */
-#define NFS_MOUNT_POSIX 0x0008 /* 1 */
-#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
-#define NFS_MOUNT_NOAC 0x0020 /* 1 */
-#define NFS_MOUNT_TCP 0x0040 /* 2 */
-#define NFS_MOUNT_VER3 0x0080 /* 3 */
-#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
-#define NFS_MOUNT_NONLM 0x0200 /* 3 */
-
-#endif
diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c
deleted file mode 100644
index c108a8f50..000000000
--- a/mdk-stage1/log.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include "stage1.h"
-
-#include "log.h"
-
-static FILE * logtty = NULL;
-static FILE * logfile = NULL;
-
-
-void vlog_message(const char * s, va_list args)
-{
- va_list args_copy;
- va_copy(args_copy, args);
-
- if (logfile) {
- fprintf(logfile, "* ");
- vfprintf(logfile, s, args);
- fprintf(logfile, "\n");
- fflush(logfile);
- }
- if (logtty) {
- fprintf(logtty, "* ");
- vfprintf(logtty, s, args_copy);
- fprintf(logtty, "\n");
- fflush(logtty);
- }
-
- va_end(args_copy);
-}
-
-
-void log_message(const char * s, ...)
-{
- va_list args;
- va_start(args, s);
- vlog_message(s, args);
- va_end(args);
-
- return;
-}
-
-void log_perror(const char *msg)
-{
- log_message("%s: %s", msg, strerror(errno));
-}
-
-
-void open_log(void)
-{
- if (!IS_TESTING) {
- logtty = fopen("/dev/tty3", "w");
- logfile = fopen(SLASH_LOCATION "/tmp/stage1.log", "w");
- }
- else
- logfile = fopen("debug.log", "w");
-}
-
-void close_log(void)
-{
- if (logfile) {
- log_message("stage1: disconnecting life support systems");
- fclose(logfile);
- if (logtty)
- fclose(logtty);
- }
-}
diff --git a/mdk-stage1/log.h b/mdk-stage1/log.h
deleted file mode 100644
index 6a30fea8f..000000000
--- a/mdk-stage1/log.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-
-#ifndef _LOG_H_
-#define _LOG_H_
-
-#include <stdarg.h>
-
-void log_message(const char * s, ...) __attribute__ ((format (printf, 1, 2)));
-void vlog_message(const char * s, va_list args);
-void log_perror(const char *msg);
-void open_log(void);
-void close_log(void);
-
-#endif
diff --git a/mdk-stage1/lomount.c b/mdk-stage1/lomount.c
deleted file mode 100644
index e1142e4dd..000000000
--- a/mdk-stage1/lomount.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/* This code comes from util-linux-2.10n (mount/lomount.c)
- * (this is a simplified version of this code)
- */
-
-#include <sys/types.h>
-#include <sys/mount.h>
-#include <sys/ioctl.h>
-#include <sys/mount.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "stage1.h"
-#include "frontend.h"
-#include "log.h"
-#include "mount.h"
-#include "modules.h"
-
-#include "lomount.h"
-
-
-#define LO_NAME_SIZE 64
-#define LO_KEY_SIZE 32
-
-struct loop_info
-{
- int lo_number; /* ioctl r/o */
- dev_t lo_device; /* ioctl r/o */
- unsigned long lo_inode; /* ioctl r/o */
- dev_t lo_rdevice; /* ioctl r/o */
- int lo_offset;
- int lo_encrypt_type;
- int lo_encrypt_key_size; /* ioctl w/o */
- int lo_flags; /* ioctl r/o */
- char lo_name[LO_NAME_SIZE];
- unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
- unsigned long lo_init[2];
- char reserved[4];
-};
-
-#define LOOP_SET_FD 0x4C00
-#define LOOP_CLR_FD 0x4C01
-#define LOOP_SET_STATUS 0x4C02
-#define LOOP_GET_STATUS 0x4C03
-
-int
-set_loop (const char *device, const char *file, int gz)
-{
- struct loop_info loopinfo;
- int fd, ffd, mode;
-
- mode = O_RDONLY;
-
- if ((ffd = open (file, mode)) < 0)
- return 1;
-
- if ((fd = open (device, mode)) < 0) {
- close(ffd);
- return 1;
- }
-
- memset(&loopinfo, 0, sizeof (loopinfo));
- strncpy(loopinfo.lo_name, file, LO_NAME_SIZE);
- loopinfo.lo_name[LO_NAME_SIZE - 1] = 0;
- loopinfo.lo_offset = 0;
- if (gz) {
- my_insmod("cryptoloop", ANY_DRIVER_TYPE, NULL, 1);
- my_insmod("zlib_inflate", ANY_DRIVER_TYPE, NULL, 1);
- my_insmod("gzloop", ANY_DRIVER_TYPE, NULL, 1);
- loopinfo.lo_encrypt_type = 13; /* LO_CRYPT_GZ */
- }
-
-#ifdef MCL_FUTURE
- /*
- * Oh-oh, sensitive data coming up. Better lock into memory to prevent
- * passwd etc being swapped out and left somewhere on disk.
- */
-
- if(mlockall(MCL_CURRENT|MCL_FUTURE)) {
- log_message("CRITICAL Couldn't lock into memory! %s (memlock)", strerror(errno));
- return 1;
- }
-#endif
-
- if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- close(fd);
- close(ffd);
- return 1;
- }
-
- if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
- (void) ioctl (fd, LOOP_CLR_FD, 0);
- close(fd);
- close(ffd);
- return 1;
- }
-
- close(fd);
- close(ffd);
- return 0;
-}
-
-
-char* find_free_loop()
-{
- struct loop_info loopinfo;
- int i;
- for (i=0; i<256; i++) {
- int fd;
- char ldev[100];
- sprintf(ldev, "/dev/loop%d", i);
- ensure_dev_exists(ldev);
- fd = open(ldev, O_RDONLY);
- if (!ioctl(fd, LOOP_GET_STATUS, &loopinfo)) {
- close(fd);
- continue;
- }
- if (errno == ENXIO) {
- log_message("%s is available", ldev);
- close(fd);
- return strdup(ldev);
- } else {
- log_perror("LOOP_GET_STATUS(unexpected error)");
- close(fd);
- continue;
- }
- }
- return NULL;
-}
-
-void
-del_loop(char * loopdev)
-{
- int fd;
-
- if (!loopdev)
- return;
-
- if ((fd = open (loopdev, O_RDONLY)) < 0)
- return;
-
- if (ioctl (fd, LOOP_CLR_FD, 0) < 0)
- return;
-
- close (fd);
-}
-
-int
-lomount(char *loopfile, char *where, char **dev, int gz)
-{
-
- long int flag;
- char * loopdev;
-
- flag = MS_MGC_VAL;
- flag |= MS_RDONLY;
-
- my_insmod("loop", ANY_DRIVER_TYPE, "max_loop=256", 1);
-
- if (!(loopdev = find_free_loop())) {
- log_message("could not find a free loop");
- return 1;
- }
- if (dev)
- *dev = loopdev;
-
- if (set_loop(loopdev, loopfile, gz)) {
- log_message("set_loop failed on %s (%s)", loopdev, strerror(errno));
- return 1;
- }
-
- if (my_mount(loopdev, where, "iso9660", 0)) {
- del_loop(loopdev);
- return 1;
- }
-
- log_message("lomount succeeded for %s on %s", loopfile, where);
- return 0;
-}
-
-
diff --git a/mdk-stage1/lomount.h b/mdk-stage1/lomount.h
deleted file mode 100644
index 05ddd520b..000000000
--- a/mdk-stage1/lomount.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef LOMOUNT_H
-#define LOMOUNT_H
-
-int lomount(char *loopfile, char *where, char **loopdev, int gz);
-void del_loop(char *loopdev);
-
-#endif
diff --git a/mdk-stage1/mar/.cvsignore b/mdk-stage1/mar/.cvsignore
deleted file mode 100644
index bfde37886..000000000
--- a/mdk-stage1/mar/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-mar
diff --git a/mdk-stage1/mar/Makefile b/mdk-stage1/mar/Makefile
deleted file mode 100644
index 4271bb954..000000000
--- a/mdk-stage1/mar/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
- #******************************************************************************
- #
- # mar - The Mandrake Archiver
- #
- # $Id$
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-TARGETS = libmar.a mar
-
-
-all: $(TARGETS)
-
-clean:
- rm -f *.o libmar.a mar
-
-
-mar: mar-frontend.o mar-extract-only-standalone.o
- gcc -o mar mar-frontend.o mar-extract-only-standalone.o -lbz2
- $(STRIPCMD) $@
-
-libmar.a: mar-extract-only.o
- ar -cru $@ $^
- ranlib $@
-
-mar-extract-only.o: mar-extract-only.c mar-extract-only.h mar.h
- $(DIET) gcc $(CFLAGS) $(INCLUDES) -c mar-extract-only.c
-
-mar-frontend.o: mar-frontend.c mar.h mar-extract-only.h
- gcc $(CFLAGS) $(GLIBC_INCLUDES) -c mar-frontend.c
-
-mar-extract-only-standalone.o: mar-extract-only.c mar-extract-only.h mar.h
- gcc $(CFLAGS) $(GLIBC_INCLUDES) -o $@ -D_STANDALONE_ -c mar-extract-only.c
diff --git a/mdk-stage1/mar/mar-extract-only.c b/mdk-stage1/mar/mar-extract-only.c
deleted file mode 100644
index dbc9c1bbc..000000000
--- a/mdk-stage1/mar/mar-extract-only.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * mar - The Mandrake Archiver
- *
- * An archiver that supports compression (through zlib).
- *
- */
-
-/*
- * This code should suffice for stage1 on-the-fly uncompression of kernel modules.
- * (and it DOES perform tests and return values, blaaaah..)
- */
-
-#include "mar-extract-only.h"
-#include "mar.h"
-
-#ifdef _STANDALONE_
-void
-zerr(BZFILE * f) /* decrease code size */
-{
- fprintf(stderr, BZ2_bzerror(f, &z_errnum));
-}
-
-inline void
-log_perror(char *msg)
-{
- perror(msg);
-}
-void
-log_message(char *msg)
-{
- fprintf(stderr, msg);
-}
-#else /* _STANDALONE_ */
-#include "../log.h"
-void
-zerr(BZFILE * f) /* decrease code size */
-{
- log_message(BZ2_bzerror(f, &z_errnum));
-}
-#endif /* _STANDALONE_ */
-
-
-static int
-mar_open_file(char *filename, struct mar_stream *s)
-{
- int end_filetable = 0;
- struct mar_element * previous_element = NULL;
-
- /* mar_zfile */
- s->mar_zfile = BZ2_bzopen(filename, "rb");
- if (!s->mar_zfile)
- {
- log_perror(filename);
- return -1;
- }
-
- while (end_filetable == 0)
- {
- char buf[512];
- int ptr = 0;
- /* read filename */
- do
- {
- if (BZ2_bzread(s->mar_zfile, &(buf[ptr]), sizeof(char)) != sizeof(char))
- {
- zerr(s->mar_zfile);
- return -1;
- }
- ptr++;
- } while ((buf[ptr-1] != 0) && (ptr < 512));
- /* ptr == 1 when we arrive on the "char 0" of the end of the filetable */
- if (ptr > 1)
- {
- struct mar_element * e = (struct mar_element *) malloc(sizeof(struct mar_element));
- e->filename = strdup(buf);
- /* read file_length */
- if (BZ2_bzread(s->mar_zfile, &(e->file_length), sizeof(int)) != sizeof(int))
- {
- zerr(s->mar_zfile);
- return -1;
- }
- /* read data_offset */
- if (BZ2_bzread(s->mar_zfile, &(e->data_offset), sizeof(int)) != sizeof(int))
- {
- zerr(s->mar_zfile);
- return -1;
- }
- /* write down chaining */
- if (previous_element)
- previous_element->next_element = e;
- else
- s->first_element = e;
- previous_element = e;
- }
- else
- end_filetable = 1;
-
- }
- /* chaining for last element */
- previous_element->next_element = NULL;
-
- return 0;
-}
-
-
-char **
-mar_list_contents(char * mar_filename)
-{
- struct mar_stream s;
- struct mar_element * elem;
- char * tmp_contents[500];
- char ** answ;
- int i = 0;
-
- if (mar_open_file(mar_filename, &s))
- return NULL;
-
- elem = s.first_element;
- while (elem)
- {
- tmp_contents[i++] = strdup(elem->filename);
- elem = elem->next_element;
- }
- tmp_contents[i++] = NULL;
- answ = (char **) malloc(sizeof(char *) * i);
- memcpy(answ, tmp_contents, sizeof(char *) * i);
- return answ;
-}
-
-
-int
-mar_extract_file(char *mar_filename, char *filename_to_extract, char *dest_dir)
-{
- struct mar_stream s;
- struct mar_element * elem;
-
- if (mar_open_file(mar_filename, &s))
- return -1;
-
- elem = s.first_element;
- while (elem)
- {
- if (strcmp(elem->filename, filename_to_extract) == 0)
- {
- char garb_buf[4096];
- char *buf;
- char *dest_file;
- int fd;
- size_t i;
- dest_file = (char *) alloca(strlen(dest_dir) + strlen(filename_to_extract) + 1);
- strcpy(dest_file, dest_dir);
- strcat(dest_file, filename_to_extract);
- fd = creat(dest_file, 00660);
- if (fd == -1)
- {
- log_perror(dest_file);
- return -1;
- }
- buf = (char *) alloca(elem->file_length);
- if (!buf)
- {
- log_perror(dest_file);
- return -1;
- }
- i = elem->data_offset;
- while (i > 0) {
- int to_read = i > sizeof(garb_buf) ? sizeof(garb_buf) : i;
- if (BZ2_bzread(s.mar_zfile, garb_buf, to_read) != to_read) {
- log_message("MAR: unexpected EOF in stream");
- close(fd);
- unlink(dest_file);
- return -1;
- }
- i -= to_read;
- }
- if (BZ2_bzread(s.mar_zfile, buf, elem->file_length) != elem->file_length)
- {
- zerr(s.mar_zfile);
- close(fd);
- unlink(dest_file);
- return -1;
- }
- if (write(fd, buf, elem->file_length) != elem->file_length)
- {
- log_perror(dest_file);
- close(fd);
- unlink(dest_file);
- return -1;
- }
- close(fd); /* do not check return value for code size */
- BZ2_bzclose(s.mar_zfile);
- return 0;
- }
- elem = elem->next_element;
- }
- BZ2_bzclose(s.mar_zfile);
- return 1; /* 1 for file_not_found_in_archive */
-}
-
-
diff --git a/mdk-stage1/mar/mar-extract-only.h b/mdk-stage1/mar/mar-extract-only.h
deleted file mode 100644
index 715d75556..000000000
--- a/mdk-stage1/mar/mar-extract-only.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * mar - The Mandrake Archiver
- *
- * An archiver that supports compression (through zlib).
- *
- */
-
-/*
- * Header for stage1 on-the-fly needs.
- */
-
-#ifndef MAR_EXTRACT_ONLY_H
-#define MAR_EXTRACT_ONLY_H
-
-int mar_extract_file(char *mar_filename, char *filename_to_extract, char *dest_dir);
-char ** mar_list_contents(char *mar_filename);
-
-#endif
diff --git a/mdk-stage1/mar/mar-frontend.c b/mdk-stage1/mar/mar-frontend.c
deleted file mode 100644
index cfffc34ae..000000000
--- a/mdk-stage1/mar/mar-frontend.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * mar - The Mandrake Archiver
- *
- * An archiver that supports compression (through zlib).
- *
- */
-
-/*
- * This code includes the extracting and creating features.
- *
- */
-
-#include "mar.h"
-#include "mar-extract-only.h"
-
-
-int
-file_size(char *filename)
-{
- struct stat buf;
- if (stat(filename, &buf) != 0)
- {
- perror(filename);
- return -1;
- }
- return buf.st_size;
-}
-
-
-/* Yes I don't use the datastructure I directly write the final fileformat in memory then write down it.
- * Yes it's bad.
- */
-/* ``files'' is a NULL-terminated array of char* */
-
-char * fnf_tag = "FILE_NOT_FOUND&";
-
-int
-mar_create_file(char *dest_file, char **files)
-{
- int filenum = 0;
- int current_offset_filetable = 0;
- int current_delta_rawdata = 0;
- int filetable_size;
- char * temp_marfile_buffer;
- int total_length = 0;
-
- filetable_size = sizeof(char); /* ``char 0'' */
- while (files[filenum])
- {
- int fsiz = file_size(files[filenum]);
- if (fsiz == -1)
- files[filenum] = fnf_tag;
- else {
- filetable_size += 2*sizeof(int) /* file_length, data_offset */ + strlen(files[filenum]) + 1;
- total_length += fsiz;
- }
- filenum++;
- }
-
- total_length += filetable_size;
-
- temp_marfile_buffer = (char *) malloc(total_length); /* create the whole file in-memory (not with alloca! it can be bigger than typical limit for stack of programs (ulimit -s) */
- DEBUG_MAR(printf("D: mar::create_marfile total-length %d\n", total_length););
-
- filenum = 0;
- while (files[filenum])
- {
- if (strcmp(files[filenum], fnf_tag)) {
- FILE * f = fopen(files[filenum], "r");
- int fsize;
- if (!f)
- {
- perror(files[filenum]);
- return -1;
- }
-
- /* filename */
- strcpy(&(temp_marfile_buffer[current_offset_filetable]), files[filenum]);
- current_offset_filetable += strlen(files[filenum]) + 1;
-
- /* file_length */
- fsize = file_size(files[filenum]);
- if (fsize == -1) return -1;
- memcpy(&temp_marfile_buffer[current_offset_filetable], &fsize, sizeof(int));
- current_offset_filetable += sizeof(int);
-
- /* data_offset */
- memcpy(&temp_marfile_buffer[current_offset_filetable], &current_delta_rawdata, sizeof(int));
- current_offset_filetable += sizeof(int);
-
- /* data_raw_data */
- if (fread(&temp_marfile_buffer[current_delta_rawdata + filetable_size], 1, fsize, f) != (size_t)fsize)
- {
- perror(files[filenum]);
- return -1;
- }
- fclose(f);
-
- current_delta_rawdata += fsize;
- }
-
- filenum++;
- }
-
- /* write down ``char 0'' to terminate file table */
- memset(&temp_marfile_buffer[current_offset_filetable], 0, sizeof(char));
-
- /* ok, buffer is ready, let's write it on-disk */
- {
- BZFILE * f = BZ2_bzopen(dest_file, "w9");
- if (!f)
- {
- perror(dest_file);
- return -1;
- }
- if (BZ2_bzwrite(f, temp_marfile_buffer, total_length) != total_length)
- {
- fprintf(stderr, BZ2_bzerror(f, &z_errnum));
- return -1;
- }
- BZ2_bzclose(f);
- }
-
- printf("mar: created archive %s (%d files, length %d)\n", dest_file, filenum, total_length);
- return 0;
-}
-
-
-void
-print_usage(char *progname)
-{
- printf("Usage: %s [-lxc] [files..]\n", progname);
- exit(0);
-}
-
-int
-main(int argc, char **argv)
-{
- if (argc <= 2)
- print_usage(argv[0]);
-
- if (argc >= 3)
- {
- if (strcmp(argv[1], "-l") == 0)
- {
- char ** contents = mar_list_contents(argv[2]);
- if (contents)
- while (contents && *contents) {
- printf("\t%s\n", *contents);
- contents++;
- }
- exit(0);
- }
- if ((strcmp(argv[1], "-x") == 0) && argc == 4)
- {
- int res = mar_extract_file(argv[2], argv[3], "./");
- if (res == 1)
- fprintf(stderr, "W: file-not-found-in-archive %s\n", argv[3]);
- if (res == -1)
- exit(-1);
- exit(0);
- }
- if ((strcmp(argv[1], "-c") == 0) && argc >= 4)
- {
- char **files = (char **) alloca(((argc-3)+1) * sizeof(char *));
- int i = 3;
- while (i < argc)
- {
- files[i-3] = argv[i];
- i++;
- }
- files[argc-3] = NULL;
- {
- int results;
- results = mar_create_file(argv[2], files);
- if (results != 0)
- fprintf(stderr, "E: create-marfile-failed\n");
- exit(results);
- }
-
- }
- }
-
- return 0;
-}
diff --git a/mdk-stage1/mar/mar.h b/mdk-stage1/mar/mar.h
deleted file mode 100644
index 61b50ca90..000000000
--- a/mdk-stage1/mar/mar.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * mar - The Mandrake Archiver
- *
- * An archiver that supports compression (through bzlib).
- *
- * Designed to be small so these bad designs are inside:
- * . archive and compression are mixed together
- * . create the mar file in-memory
- * . does not free memory
- *
- */
-
-#ifndef MAR_H
-#define MAR_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include <bzlib.h>
-
-/*
- * Format of a mar file:
- *
- * ASCIIZ filename \ |
- * int file_length | repeated | bzipped
- * int pointer_in_archive / |
- * char 0 |
- * raw_files_data /
- *
- */
-
-struct mar_element
-{
- char * filename; /* filename (ASCIIZ) of the element */
- int file_length; /* length (in bytes) of the raw data of the element */
- int data_offset; /* seek start of the raw data in the underlying mar stream */
- struct mar_element * next_element; /* pointer to the next element in the mar stream; NULL if last */
-};
-
-struct mar_stream
-{
- struct mar_element * first_element; /* pointer to the first element inside the mar stream */
- BZFILE * mar_zfile; /* associated zfile (opened) */
-};
-
-int z_errnum;
-
-#define DEBUG_MAR(x)
-
-#endif
diff --git a/mdk-stage1/minilibc.c b/mdk-stage1/minilibc.c
deleted file mode 100644
index 7388c527c..000000000
--- a/mdk-stage1/minilibc.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-
-#define MINILIBC_INTERNAL
-
-#include "minilibc.h"
-
-int atexit (void (*__func) (void) __attribute__ ((unused)))
-{
- return 0;
-}
-
-void exit()
-{
- _do_exit(0);
- for (;;); /* Shut up gcc */
-}
-
-
-char ** _environ = NULL;
-int errno = 0;
-
-void _init (int __status __attribute__ ((unused)))
-{
-}
-
-void __libc_init_first (int __status __attribute__ ((unused)))
-{
-}
-
-void __libc_csu_fini(int __status __attribute__ ((unused)))
-{
-}
-
-void __libc_csu_init(int __status __attribute__ ((unused)))
-{
-}
-
-
-int __libc_start_main (int (*main) (int, char **, char **), int argc,
- char **argv, void (*init) (void) __attribute__ ((unused)), void (*fini) (void) __attribute__ ((unused)),
- void (*rtld_fini) (void) __attribute__ ((unused)), void *stack_end __attribute__ ((unused)))
-{
- exit ((*main) (argc, argv, NULL));
- /* never get here */
- return 0;
-}
-
-void _fini (int __status __attribute__ ((unused)))
-{
-}
-
-#ifdef __x86_64__
-/* x86-64 implementation of signal() derived from glibc sources */
-
-static inline int sigemptyset(sigset_t *set) {
- *set = 0;
- return 0;
-}
-
-static inline int sigaddset(sigset_t *set, int sig) {
- __asm__("btsq %1,%0" : "=m" (*set) : "Ir" (sig - 1L) : "cc");
- return 0;
-}
-
-#define __NR___rt_sigaction __NR_rt_sigaction
-static inline _syscall3(int,__rt_sigaction,int,signum,const void *,act,void *,oldact)
-#define __NR___rt_sigreturn __NR_rt_sigreturn
-static _syscall1(int,__rt_sigreturn,unsigned long,unused)
-
-static void restore_rt(void) {
- __rt_sigreturn(0);
-}
-
-int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) {
- struct sigaction *newact = (struct sigaction *)act;
- if (act) {
- newact = __builtin_alloca(sizeof(*newact));
- newact->sa_handler = act->sa_handler;
- newact->sa_flags = act->sa_flags | SA_RESTORER;
- newact->sa_restorer = &restore_rt;
- newact->sa_mask = act->sa_mask;
- }
- return __rt_sigaction(signum, newact, oldact);
-}
-
-__sighandler_t signal(int signum, __sighandler_t action) {
- struct sigaction sa,oa;
- sa.sa_handler=action;
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask,signum);
- sa.sa_flags=SA_RESTART;
- if (sigaction(signum,&sa,&oa))
- return SIG_ERR;
- return oa.sa_handler;
-}
-
-#endif
-
-#ifdef __NR_socketcall
-
-int socket(int a, int b, int c)
-{
- unsigned long args[] = { a, b, c };
-
- return socketcall(SYS_SOCKET, args);
-}
-
-int bind(int a, void * b, int c)
-{
- unsigned long args[] = { a, (long) b, c };
-
- return socketcall(SYS_BIND, args);
-}
-
-int listen(int a, int b)
-{
- unsigned long args[] = { a, b, 0 };
-
- return socketcall(SYS_LISTEN, args);
-}
-
-int accept(int a, void * addr, void * addr2)
-{
- unsigned long args[] = { a, (long) addr, (long) addr2 };
-
- return socketcall(SYS_ACCEPT, args);
-}
-
-#else
-
-_syscall3(int,socket,int,domain,int,type,int,protocol)
-_syscall3(int,bind,int,sockfd,void *,my_addr,int,addrlen)
-_syscall2(int,listen,int,s,int,backlog)
-_syscall3(int,accept,int,s,void *,addr,void *,addrlen)
-
-#endif
-
-
-void sleep(int secs)
-{
- struct timeval tv;
-
- tv.tv_sec = secs;
- tv.tv_usec = 0;
-
- select(0, NULL, NULL, NULL, &tv);
-}
-
-
-int strlen(const char * string)
-{
- int i = 0;
-
- while (*string++) i++;
-
- return i;
-}
-
-char * strncpy(char * dst, const char * src, int len)
-{
- char * chptr = dst;
- int i = 0;
-
- while (*src && i < len) *dst++ = *src++, i++;
- if (i < len) *dst = '\0';
-
- return chptr;
-}
-
-char * strcpy(char * dst, const char * src)
-{
- char * chptr = dst;
-
- while (*src) *dst++ = *src++;
- *dst = '\0';
-
- return chptr;
-}
-
-void * memcpy(void * dst, const void * src, size_t count)
-{
- char * a = dst;
- const char * b = src;
-
- while (count--)
- *a++ = *b++;
-
- return dst;
-}
-
-
-int strcmp(const char * a, const char * b)
-{
- int i, j;
-
- i = strlen(a); j = strlen(b);
- if (i < j)
- return -1;
- else if (j < i)
- return 1;
-
- while (*a && (*a == *b)) a++, b++;
-
- if (!*a) return 0;
-
- if (*a < *b)
- return -1;
- else
- return 1;
-}
-
-int strncmp(const char * a, const char * b, int len)
-{
- char buf1[1000], buf2[1000];
-
- strncpy(buf1, a, len);
- strncpy(buf2, b, len);
- buf1[len] = '\0';
- buf2[len] = '\0';
-
- return strcmp(buf1, buf2);
-}
-
-char * strchr(char * str, int ch)
-{
- char * chptr;
-
- chptr = str;
- while (*chptr)
- {
- if (*chptr == ch) return chptr;
- chptr++;
- }
-
- return NULL;
-}
-
-
-char * strstr(char *haystack, char *needle)
-{
- char * tmp = haystack;
- while ((tmp = strchr(tmp, needle[0])) != NULL) {
- int i = 1;
- while (i < strlen(tmp) && i < strlen(needle) && tmp[i] == needle[i])
- i++;
- if (needle[i] == '\0')
- return tmp;
- tmp++;
- }
- return NULL;
-}
-
-
-/* Minimum printf which handles only characters, %d's and %s's */
-void printf(char * fmt, ...)
-{
- char buf[2048];
- char * start = buf;
- char * chptr = buf;
- va_list args;
- char * strarg;
- int numarg;
-
- strncpy(buf, fmt, sizeof(buf));
- va_start(args, fmt);
-
- while (start)
- {
- while (*chptr != '%' && *chptr) chptr++;
-
- if (*chptr == '%')
- {
- *chptr++ = '\0';
- print_str_init(1, start);
-
- switch (*chptr++)
- {
- case 's':
- strarg = va_arg(args, char *);
- print_str_init(1, strarg);
- break;
-
- case 'd':
- numarg = va_arg(args, int);
- print_int_init(1, numarg);
- break;
- }
-
- start = chptr;
- }
- else
- {
- print_str_init(1, start);
- start = NULL;
- }
- }
-}
diff --git a/mdk-stage1/minilibc.h b/mdk-stage1/minilibc.h
deleted file mode 100644
index e1d3e5b1f..000000000
--- a/mdk-stage1/minilibc.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-
-#include <stdarg.h>
-
-#define _LOOSE_KERNEL_NAMES 1
-
-#define NULL ((void *) 0)
-
-#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
-#define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
-#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
-#define WTERMSIG(status) ((status) & 0x7f)
-#define WSTOPSIG(status) WEXITSTATUS(status)
-#define WIFEXITED(status) (WTERMSIG(status) == 0)
-
-#define MS_MGC_VAL 0xc0ed0000
-
-#define isspace(a) (a == ' ' || a == '\t')
-
-extern char ** _environ;
-
-extern int errno;
-
-/* Aieee, gcc 2.95+ creates a stub for posix_types.h on i386 which brings
- glibc headers in and thus makes __FD_SET etc. not defined with 2.3+ kernels. */
-#define _FEATURES_H 1
-#include <linux/posix_types.h>
-#include <linux/socket.h>
-#include <linux/types.h>
-#include <linux/time.h>
-#include <linux/if.h>
-#include <linux/un.h>
-#include <linux/loop.h>
-#include <linux/net.h>
-#include <asm/termios.h>
-#include <asm/ioctls.h>
-#include <asm/unistd.h>
-#include <asm/fcntl.h>
-#include <asm/signal.h>
-
-#ifndef __NR__newselect
-#define __NR__newselect __NR_select
-#endif
-
-#ifndef MINILIBC_INTERNAL
-static inline _syscall5(int,mount,const char *,spec,const char *,dir,const char *,type,unsigned long,rwflag,const void *,data);
-static inline _syscall5(int,_newselect,int,n,fd_set *,rd,fd_set *,wr,fd_set *,ex,struct timeval *,timeval);
-static inline _syscall4(int,wait4,pid_t,pid,int *,status,int,opts,void *,rusage)
-static inline _syscall3(int,write,int,fd,const char *,buf,unsigned long,count)
-static inline _syscall3(int,reboot,int,magic,int,magic_too,int,flag)
-static inline _syscall3(int,execve,const char *,fn,void *,argv,void *,envp)
-static inline _syscall3(int,read,int,fd,const char *,buf,unsigned long,count)
-static inline _syscall3(int,open,const char *,fn,int,flags,mode_t,mode)
-static inline _syscall3(int,ioctl,int,fd,int,request,void *,argp)
-static inline _syscall2(int,dup2,int,one,int,two)
-static inline _syscall2(int,kill,pid_t,pid,int,sig)
-static inline _syscall2(int,symlink,const char *,a,const char *,b)
-static inline _syscall2(int,chmod,const char * ,path,mode_t,mode)
-static inline _syscall2(int,sethostname,const char *,name,int,len)
-static inline _syscall2(int,setdomainname,const char *,name,int,len)
-static inline _syscall2(int,setpgid,int,name,int,len)
-static inline _syscall2(int,mkdir,const char *,pathname,mode_t,mode)
-#ifdef __x86_64__
-extern __sighandler_t signal(int signum, __sighandler_t handler);
-#else
-static inline _syscall2(int,signal,int,num,void *,len)
-#endif
-#ifdef __NR_umount
-static inline _syscall1(int,umount,const char *,dir)
-#else
-static inline _syscall2(int,umount2,const char *,dir,int,flags)
-static inline int umount(const char * dir) { return umount2(dir, 0); }
-#endif
-static inline _syscall1(int,unlink,const char *,fn)
-static inline _syscall1(int,close,int,fd)
-static inline _syscall1(int,swapoff,const char *,fn)
-static inline _syscall0(int,getpid)
-static inline _syscall0(int,sync)
-#ifdef __sparc__
-/* Nonstandard fork calling convention :( */
-static inline int fork(void) {
- int __res;
- __asm__ __volatile__ (
- "mov %0, %%g1\n\t"
- "t 0x10\n\t"
- "bcc 1f\n\t"
- "dec %%o1\n\t"
- "sethi %%hi(%2), %%g1\n\t"
- "st %%o0, [%%g1 + %%lo(%2)]\n\t"
- "b 2f\n\t"
- "mov -1, %0\n\t"
- "1:\n\t"
- "and %%o0, %%o1, %0\n\t"
- "2:\n\t"
- : "=r" (__res)
- : "0" (__NR_fork), "i" (&errno)
- : "g1", "o0", "cc");
- return __res;
-}
-#else
-static inline _syscall0(int,fork)
-#endif
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,syslog,int, type, char *, buf, int, len);
-#else
-static inline _syscall5(int,_newselect,int,n,fd_set *,rd,fd_set *,wr,fd_set *,ex,struct timeval *,timeval);
-static inline _syscall3(int,write,int,fd,const char *,buf,unsigned long,count)
-#ifdef __NR_socketcall
-static inline _syscall2(int,socketcall,int,code,unsigned long *, args)
-#endif
-#define __NR__do_exit __NR_exit
-static inline _syscall1(int,_do_exit,int,exitcode)
-#endif
-
-#define select _newselect
-
-extern int errno;
-
-int socket(int a, int b, int c);
-int bind(int a, void * b, int c);
-int listen(int a, int b);
-int accept(int a, void * addr, void * addr2);
-
-void sleep(int secs);
-
-int strlen(const char * string);
-char * strcpy(char * dst, const char * src);
-void * memcpy(void * dst, const void * src, size_t count);
-int strcmp(const char * a, const char * b);
-int strncmp(const char * a, const char * b, int len);
-char * strchr(char * str, int ch);
-char * strstr(char *haystack, char *needle);
-char * strncpy(char * dst, const char * src, int len);
-
-void print_str_init(int fd, char * string);
-void print_int_init(int fd, int i);
-/* Minimum printf which handles only characters, %d's and %s's */
-void printf(char * fmt, ...) __attribute__ ((format (printf, 1, 2)));
-
diff --git a/mdk-stage1/mkinitrd_helper/Makefile b/mdk-stage1/mkinitrd_helper/Makefile
deleted file mode 100644
index 269fd3ddc..000000000
--- a/mdk-stage1/mkinitrd_helper/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-VERSION = 1.1.1
-
-DEFS = -DVERSION=\"$(VERSION)\"
-
-
-MKINITRD_HELPER_SRC = mkinitrd_helper.c
-MKINITRD_HELPER_LIBS = ../insmod-busybox/libinsmod-DIET.a
-
-MKINITRD_HELPER_OBJS = $(subst .c,.o,$(MKINITRD_HELPER_SRC))
-
-BIN = mkinitrd_helper
-
-all: $(BIN)
-
-clean:
- rm -f *.o $(BIN)
-
-FLAGS = -Wall -Werror -Os -fomit-frame-pointer -c
-
-
-$(MKINITRD_HELPER_OBJS): %.o: %.c
- $(CC) $(DEFS) $(DIETLIBC_INCLUDES) -I.. -c $< -o $@
-
-mkinitrd_helper: $(MKINITRD_HELPER_OBJS) $(MKINITRD_HELPER_LIBS) $(DIETLIBC_LIBC)
- $(CC) $(DIETLIBC_LDFLAGS_STAGE1) -o $@ $^
- $(STRIPCMD) $@
diff --git a/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c b/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c
deleted file mode 100644
index 3e47bca2d..000000000
--- a/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2001 Mandrakesoft
- *
- * This software is covered by the GPL license.
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * This little program replaces usual sash and insmod.static based script
- * from mkinitrd (that insmod modules, plus possibly mount a partition and
- * losetup a loopback-based / on the partition).
- *
- *
- * On my machine:
- * gzipped sash + insmod.static 502491 bytes
- * gzipped <this-program> 14243 bytes
- *
- * There will be room for linux-2.4 and many modules, now. Cool.
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/mount.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-
-#include "insmod.h"
-
-int quiet = 0;
-
-void vlog_message(const char * s, va_list args)
-{
- vprintf(s, args);
- printf("\n");
-}
-
-void log_perror(char *msg)
-{
- perror(msg);
-}
-
-
-static void fatal_error(char *msg)
-{
- printf("[] E: %s\n[] giving hand to kernel.\n", msg);
- exit(-1);
-}
-
-static void warning(char *msg)
-{
- printf("[] W: %s\n", msg);
-}
-
-static void parse_parms(const char * parm, char ** parm1, char ** parm2, char ** parm3)
-{
- char * ptr;
-
- ptr = strchr(parm, '\n');
- if (!ptr)
- fatal_error("bad config file: no newline after parms");
-
- *parm1 = malloc(ptr-parm+1); /* yup, never freed :-) */
- memcpy(*parm1, parm, ptr-parm);
- (*parm1)[ptr-parm] = '\0';
-
- if (!parm2)
- return;
-
- *parm2 = strchr(*parm1, ' ');
- if (!*parm2)
- return;
- **parm2 = '\0';
- (*parm2)++;
-
- if (!parm3)
- return;
-
- *parm3 = strchr(*parm2, ' ');
- if (!*parm3)
- return;
- **parm3 = '\0';
- (*parm3)++;
-}
-
-
-static void insmod_(const char * parm)
-{
- char * mod_name, * options;
-
- parse_parms(parm, &mod_name, &options, NULL);
-
-#ifdef DEBUG
- printf("insmod %s options %s\n", mod_name, options);
-#endif
- if (!quiet)
- printf("[] Loading module %s\n", mod_name);
-
- if (insmod_call(mod_name, options))
- perror("insmod failed");
-}
-
-
-static void mount_(const char * parm)
-{
- char * dev, * location, * fs;
- unsigned long flags;
- char * opts = NULL;
-
- parse_parms(parm, &dev, &location, &fs);
-
-#ifdef DEBUG
- printf("mounting %s on %s as type %s\n", dev, location, fs);
-#endif
- if (!quiet)
- printf("[] Mounting device containing loopback root filesystem\n");
-
- flags = MS_MGC_VAL;
-
- if (!strcmp(fs, "vfat"))
- opts = "check=relaxed";
-
- if (mount(dev, location, fs, flags, opts))
- perror("mount failed");
-}
-
-
-#define LO_NAME_SIZE 64
-#define LO_KEY_SIZE 32
-
-struct loop_info
-{
- int lo_number; /* ioctl r/o */
- dev_t lo_device; /* ioctl r/o */
- unsigned long lo_inode; /* ioctl r/o */
- dev_t lo_rdevice; /* ioctl r/o */
- int lo_offset;
- int lo_encrypt_type;
- int lo_encrypt_key_size; /* ioctl w/o */
- int lo_flags; /* ioctl r/o */
- char lo_name[LO_NAME_SIZE];
- unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
- unsigned long lo_init[2];
- char reserved[4];
-};
-
-#define LOOP_SET_FD 0x4C00
-#define LOOP_CLR_FD 0x4C01
-#define LOOP_SET_STATUS 0x4C02
-
-static void set_loop_(const char * parm)
-{
- struct loop_info loopinfo;
- int fd, ffd;
- char * device, * file;
-
- parse_parms(parm, &device, &file, NULL);
-
-#ifdef DEBUG
- printf("set_looping %s with %s\n", device, file);
-#endif
- if (!quiet)
- printf("[] Setting up loopback file %s\n", file);
-
- if ((ffd = open(file, O_RDWR)) < 0) {
- perror("set_loop, opening file in rw");
- exit(-1);
- }
-
- if ((fd = open(device, O_RDWR)) < 0) {
- perror("set_loop, opening loop device in rw");
- close(ffd);
- exit(-1);
- }
-
- memset(&loopinfo, 0, sizeof (loopinfo));
- strncpy(loopinfo.lo_name, file, LO_NAME_SIZE);
- loopinfo.lo_name[LO_NAME_SIZE - 1] = 0;
- loopinfo.lo_offset = 0;
-
- if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- close(fd);
- close(ffd);
- perror("LOOP_SET_FD");
- exit(-1);
- }
-
- if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
- (void) ioctl (fd, LOOP_CLR_FD, 0);
- close(fd);
- close(ffd);
- perror("LOOP_SET_STATUS");
- exit(-1);
- }
-
- close(fd);
- close(ffd);
-}
-
-
-#define MD_MAJOR 9
-#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
-#include <linux/raid/md_u.h>
-
-static void raidautorun_(const char * parm)
-{
- char * device;
- int fd;
-
- parse_parms(parm, &device, NULL, NULL);
-
- if (!quiet)
- printf("[] Calling raid autorun for %s\n", device);
-
- fd = open(device, O_RDWR, 0);
- if (fd < 0) {
- printf("raidautorun: failed to open %s: %d\n", device, errno);
- return;
- }
-
- if (ioctl(fd, RAID_AUTORUN, 0)) {
- printf("raidautorun: RAID_AUTORUN failed: %d\n", errno);
- }
-
- close(fd);
-}
-
-static int handle_command(char ** ptr, char * cmd_name, void (*cmd_func)(const char * parm))
-{
- if (!strncmp(*ptr, cmd_name, strlen(cmd_name))) {
- *ptr = strchr(*ptr, '\n');
- if (!*ptr)
- fatal_error("Bad config file: no newline after command");
- (*ptr)++;
- cmd_func(*ptr);
- *ptr = strchr(*ptr, '\n');
- if (!*ptr)
- exit(0);
- (*ptr)++;
- return 1;
- }
- return 0;
-}
-
-
-int main(int argc, char **argv)
-{
- int fd_conf, i;
- char buf[5000];
- char * ptr;
-
- if (strstr(argv[0], "modprobe"))
- exit(0);
-
- if (mount("/proc", "/loopfs", "proc", 0, NULL))
- printf("[] couldn't mount proc filesystem\n");
- else {
- int fd_cmdline = open("/loopfs/cmdline", O_RDONLY);
- if (fd_cmdline > 0) {
- i = read(fd_cmdline, buf, sizeof(buf));
- if (i == -1)
- warning("could not read cmdline");
- else {
- buf[i] = '\0';
- if (strstr(buf, "quiet"))
- quiet = 1;
- }
- close(fd_cmdline);
- }
- umount("/loopfs");
- }
-
- if (!quiet)
- printf("[] initrd_helper v" VERSION "\n");
-
- if ((fd_conf = open("/mkinitrd_helper.conf", O_RDONLY)) < 0)
- fatal_error("could not open mkinitrd_helper config file");
-
- i = read(fd_conf, buf, sizeof(buf));
- if (i == -1)
- fatal_error("could not read mkinitrd_helper config file");
- buf[i] = '\0';
- close(fd_conf);
-
- ptr = buf;
-
- while (*ptr)
- if (!(handle_command(&ptr, "insmod", insmod_) +
- handle_command(&ptr, "mount", mount_) +
- handle_command(&ptr, "raidautorun", raidautorun_) +
- handle_command(&ptr, "set_loop", set_loop_)))
- warning("unkown command (trying to continue)");
-
- return 0;
-}
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c
deleted file mode 100644
index 11e118030..000000000
--- a/mdk-stage1/modules.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * (1) calculate dependencies
- * (2) unarchive relevant modules
- * (3) insmod them
- */
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include "insmod.h"
-#include "stage1.h"
-#include "log.h"
-#include "mar/mar-extract-only.h"
-#include "frontend.h"
-#include "mount.h"
-#include "modules_descr.h"
-
-#include "modules.h"
-
-static struct module_deps_elem * modules_deps = NULL;
-
-static char archive_name[] = "/modules/modules.mar";
-static char additional_archive_name[] = "/tmp/tmpfs/modules.mar";
-int allow_additional_modules_floppy = 1;
-
-extern long init_module(void *, unsigned long, const char *);
-
-
-static const char *moderror(int err)
-{
- switch (err) {
- case ENOEXEC:
- return "Invalid module format";
- case ENOENT:
- return "Unknown symbol in module";
- case ESRCH:
- return "Module has wrong symbol version";
- case EINVAL:
- return "Invalid parameters";
- default:
- return strerror(err);
- }
-}
-
-static void *grab_file(const char *filename, unsigned long *size)
-{
- unsigned int max = 16384;
- int ret, fd;
- void *buffer = malloc(max);
-
- fd = open(filename, O_RDONLY, 0);
- if (fd < 0)
- return NULL;
-
- *size = 0;
- while ((ret = read(fd, buffer + *size, max - *size)) > 0) {
- *size += ret;
- if (*size == max)
- buffer = realloc(buffer, max *= 2);
- }
- if (ret < 0) {
- free(buffer);
- buffer = NULL;
- }
- close(fd);
- return buffer;
-}
-
-static enum return_type ensure_additional_modules_available(void)
-{
-#ifdef ENABLE_ADDITIONAL_MODULES
- struct stat statbuf;
- if (stat(additional_archive_name, &statbuf)) {
- char floppy_mount_location[] = "/tmp/floppy";
- char floppy_modules_mar[] = "/tmp/floppy/modules.mar";
- int ret;
- int automatic = 0;
-
- if (stat("/tmp/tmpfs", &statbuf)) {
- if (scall(mkdir("/tmp/tmpfs", 0755), "mkdir"))
- return RETURN_ERROR;
- if (scall(mount("none", "/tmp/tmpfs", "tmpfs", MS_MGC_VAL, NULL), "mount tmpfs"))
- return RETURN_ERROR;
- }
-
- if (IS_AUTOMATIC) {
- unset_automatic();
- automatic = 1;
- }
-
- retry:
- stg1_info_message("Please insert the Additional Drivers floppy.");;
-
- while (my_mount(floppy_device(), floppy_mount_location, "ext2", 0) == -1) {
- enum return_type results = ask_yes_no(errno == ENXIO ?
- "There is no detected floppy drive, or no floppy disk in drive.\nRetry?"
- : errno == EINVAL ?
- "Floppy is not a Linux ext2 floppy in first floppy drive.\nRetry?"
- : "Can't find a linux ext2 floppy in first floppy drive.\nRetry?");
- if (results != RETURN_OK) {
- allow_additional_modules_floppy = 0;
- if (automatic)
- set_param(MODE_AUTOMATIC);
- return results;
- }
- }
-
- if (stat(floppy_modules_mar, &statbuf)) {
- stg1_error_message("This is not an Additional Drivers floppy, as far as I can see.");
- umount(floppy_mount_location);
- goto retry;
- }
-
- init_progression("Copying...", file_size(floppy_modules_mar));
- ret = copy_file(floppy_modules_mar, additional_archive_name, update_progression);
- end_progression();
- umount(floppy_mount_location);
- if (automatic)
- set_param(MODE_AUTOMATIC);
- return ret;
- } else
- return RETURN_OK;
-#else
- allow_additional_modules_floppy = 0;
- return RETURN_ERROR;
-#endif
-}
-
-int insmod_local_file(char * path, char * options)
-{
- if (kernel_version() <= 4) {
- return insmod_call(path, options);
- } else {
- void *file;
- unsigned long len;
- int rc;
-
- file = grab_file(path, &len);
-
- if (!file) {
- log_perror(asprintf_("\terror reading %s", path));
- return -1;
- }
-
- rc = init_module(file, len, options ? options : "");
- if (rc)
- log_message("\terror: %s", moderror(errno));
- return rc;
- }
-}
-
-static char *kernel_module_extension(void)
-{
- return kernel_version() <= 4 ? ".o" : ".ko";
-}
-
-/* unarchive and insmod given module
- * WARNING: module must not contain the trailing ".o"
- */
-static enum insmod_return insmod_archived_file(const char * mod_name, char * options, int allow_modules_floppy)
-{
- char module_name[50];
- char final_name[50] = "/tmp/";
- int i, rc;
-
- strncpy(module_name, mod_name, sizeof(module_name));
- strcat(module_name, kernel_module_extension());
- i = mar_extract_file(archive_name, module_name, "/tmp/");
- if (i == 1) {
- static int recurse = 0;
- if (allow_additional_modules_floppy && allow_modules_floppy && !recurse) {
- recurse = 1;
- if (ensure_additional_modules_available() == RETURN_OK)
- i = mar_extract_file(additional_archive_name, module_name, "/tmp/");
- recurse = 0;
- }
- }
- if (i == 1) {
- log_message("file-not-found-in-archive %s (maybe you can try another boot floppy such as 'hdcdrom_usb.img')", module_name);
- return INSMOD_FAILED_FILE_NOT_FOUND;
- }
- if (i != 0)
- return INSMOD_FAILED;
-
- strcat(final_name, module_name);
-
- rc = insmod_local_file(final_name, options);
-
- unlink(final_name); /* sucking no space left on device */
-
- if (rc) {
- log_message("\tfailed");
- return INSMOD_FAILED;
- }
- return INSMOD_OK;
-}
-
-
-
-static int load_modules_dependencies(void)
-{
- char * deps_file = "/modules/modules.dep";
- char * buf, * ptr, * start, * end;
- struct stat s;
- int fd, line, i;
-
- log_message("loading modules dependencies");
-
- if (IS_TESTING)
- return 0;
-
- fd = open(deps_file, O_RDONLY);
- if (fd == -1) {
- log_perror(deps_file);
- return -1;
- }
-
- fstat(fd, &s);
- buf = alloca(s.st_size + 1);
- if (read(fd, buf, s.st_size) != (ssize_t)s.st_size) {
- log_perror(deps_file);
- return -1;
- }
- buf[s.st_size] = '\0';
- close(fd);
-
- ptr = buf;
- line = 0;
- while (ptr) {
- line++;
- ptr = strchr(ptr + 1, '\n');
- }
-
- modules_deps = malloc(sizeof(*modules_deps) * (line+1));
-
- start = buf;
- line = 0;
- while (start < (buf+s.st_size) && *start) {
- char * tmp_deps[50];
-
- end = strchr(start, '\n');
- *end = '\0';
-
- ptr = strchr(start, ':');
- if (!ptr) {
- start = end + 1;
- continue;
- }
- *ptr = '\0';
- ptr++;
-
- while (*ptr && (*ptr == ' ')) ptr++;
- if (!*ptr) {
- start = end + 1;
- continue;
- }
-
- /* sort of a good line */
- modules_deps[line].name = strdup(start);
-
- start = ptr;
- i = 0;
- while (start && *start) {
- ptr = strchr(start, ' ');
- if (ptr) *ptr = '\0';
- tmp_deps[i++] = strdup(start);
- if (ptr)
- start = ptr + 1;
- else
- start = NULL;
- while (start && *start && *start == ' ')
- start++;
- }
- tmp_deps[i++] = NULL;
-
- modules_deps[line].deps = memdup(tmp_deps, sizeof(char *) * i);
-
- line++;
- start = end + 1;
- }
- modules_deps[line].name = NULL;
-
- return 0;
-}
-
-
-void init_modules_insmoding(void)
-{
- if (load_modules_dependencies()) {
- fatal_error("warning, error initing modules stuff, modules loading disabled");
- }
-}
-
-
-static void add_modules_conf(char * str)
-{
- static char data[5000] = "";
- char * target = "/tmp/modules.conf";
- int fd;
-
- if (strlen(data) + strlen(str) >= sizeof(data))
- return;
-
- strcat(data, str);
- strcat(data, "\n");
-
- fd = open(target, O_CREAT|O_WRONLY|O_TRUNC, 00660);
-
- if (fd == -1) {
- log_perror(str);
- return;
- }
-
- if (write(fd, data, strlen(data) + 1) != (ssize_t) (strlen(data) + 1))
- log_perror(str);
-
- close(fd);
-}
-
-
-int module_already_present(const char * name)
-{
- FILE * f;
- int answ = 0;
-
- if ((f = fopen("/proc/modules", "rb"))) {
- while (1) {
- char buf[500];
- if (!fgets(buf, sizeof(buf), f)) break;
- if (!strncmp(name, buf, strlen(name)) && buf[strlen(name)] == ' ')
- answ = 1;
- }
- fclose(f);
- }
- return answ;
-}
-
-
-static enum insmod_return insmod_with_deps(const char * mod_name, char * options, int allow_modules_floppy)
-{
- struct module_deps_elem * dep;
-
- dep = modules_deps;
- while (dep && dep->name && strcmp(dep->name, mod_name)) dep++;
-
- if (dep && dep->name && dep->deps) {
- char ** one_dep;
- one_dep = dep->deps;
- while (*one_dep) {
- /* here, we can fail but we don't care, if the error is
- * important, the desired module will fail also */
- insmod_with_deps(*one_dep, NULL, allow_modules_floppy);
- one_dep++;
- }
- }
-
- if (module_already_present(mod_name))
- return INSMOD_OK;
-
- log_message("needs %s", mod_name);
- {
- char *file = asprintf_("/modules/%s%s", mod_name, kernel_module_extension());
- if (access(file, R_OK) == 0)
- return insmod_local_file(file, options);
- else
- return insmod_archived_file(mod_name, options, allow_modules_floppy);
- }
-}
-
-
-static const char * get_name_kernel_26_transition(const char * name)
-{
- struct kernel_24_26_mapping {
- const char * name_24;
- const char * name_26;
- };
- static struct kernel_24_26_mapping mappings[] = {
- { "usb-ohci", "ohci-hcd" },
- { "usb-uhci", "uhci-hcd" },
- { "uhci", "uhci-hcd" },
-// { "printer", "usblp" },
- { "bcm4400", "b44" },
- { "3c559", "3c359" },
- { "3c90x", "3c59x" },
- { "dc395x_trm", "dc395x" },
-// { "audigy", "snd-emu10k1" },
- };
- int mappings_nb = sizeof(mappings) / sizeof(struct kernel_24_26_mapping);
- int i;
-
- /* pcitable contains 2.4 names. this will need to change if/when it contains 2.6 names! */
- if (kernel_version() > 4)
- for (i=0; i<mappings_nb; i++) {
- if (streq(name, mappings[i].name_24))
- return mappings[i].name_26;
- }
- return name;
-}
-
-
-#ifndef DISABLE_NETWORK
-enum insmod_return my_insmod(const char * mod_name, enum driver_type type, char * options, int allow_modules_floppy)
-#else
-enum insmod_return my_insmod(const char * mod_name, enum driver_type type __attribute__ ((unused)), char * options, int allow_modules_floppy)
-#endif
-{
- int i;
-#ifndef DISABLE_NETWORK
- char ** net_devices = NULL; /* fucking compiler */
-#endif
-
- const char * real_mod_name = get_name_kernel_26_transition(mod_name);
-
- if (module_already_present(real_mod_name))
- return INSMOD_OK;
-
- log_message("have to insmod %s", real_mod_name);
-
-#ifndef DISABLE_NETWORK
- if (type == NETWORK_DEVICES)
- net_devices = get_net_devices();
-#endif
-
- if (IS_TESTING)
- return INSMOD_OK;
-
-#ifdef ENABLE_NETWORK_STANDALONE
- {
- char *cmd = options ? asprintf_("/sbin/modprobe %s %s", mod_name, options) :
- asprintf_("/sbin/modprobe %s", mod_name);
- log_message("running %s", cmd);
- i = system(cmd);
- }
-#else
- i = insmod_with_deps(real_mod_name, options, allow_modules_floppy);
-#endif
- if (i == 0) {
- log_message("\tsucceeded %s", real_mod_name);
-#ifndef DISABLE_NETWORK
- if (type == NETWORK_DEVICES) {
- char ** new_net_devices = get_net_devices();
- while (new_net_devices && *new_net_devices) {
- char alias[500];
- char ** ptr = net_devices;
- while (ptr && *ptr) {
- if (!strcmp(*new_net_devices, *ptr))
- goto already_present;
- ptr++;
- }
- sprintf(alias, "alias %s %s", *new_net_devices, mod_name);
- add_modules_conf(alias);
- log_message("NET: %s", alias);
- net_discovered_interface(*new_net_devices);
-
- already_present:
- new_net_devices++;
- }
- }
-#endif
- } else
- log_message("warning, insmod failed (%s %s) (%d)", real_mod_name, options, i);
-
- return i;
-
-}
-
-static enum return_type insmod_with_options(char * mod, enum driver_type type)
-{
- char * questions[] = { "Options", NULL };
- static char ** answers = NULL;
- enum return_type results;
- char options[500] = "options ";
-
- results = ask_from_entries("Please enter the parameters to give to the kernel:", questions, &answers, 24, NULL);
- if (results != RETURN_OK)
- return results;
-
- strcat(options, mod);
- strcat(options, " ");
- strcat(options, answers[0]); // because my_insmod will eventually modify the string
-
- if (my_insmod(mod, type, answers[0], 1) != INSMOD_OK) {
- stg1_error_message("Insmod failed.");
- return RETURN_ERROR;
- }
-
- add_modules_conf(options);
-
- return RETURN_OK;
-}
-
-enum return_type ask_insmod(enum driver_type type)
-{
- char * mytype;
- char msg[200];
- enum return_type results;
- char * choice;
-
- unset_automatic(); /* we are in a fallback mode */
-
- if (type == SCSI_ADAPTERS)
- mytype = "SCSI";
- else if (type == NETWORK_DEVICES)
- mytype = "NET";
- else
- return RETURN_ERROR;
-
- snprintf(msg, sizeof(msg), "Which driver should I try to gain %s access?", mytype);
-
- {
- char ** modules = mar_list_contents(ensure_additional_modules_available() == RETURN_OK ? additional_archive_name
- : archive_name);
- char ** descrs = malloc(sizeof(char *) * string_array_length(modules));
- char ** p_modules = modules;
- char ** p_descrs = descrs;
- while (p_modules && *p_modules) {
- int i;
- *p_descrs = NULL;
- for (i = 0 ; i < modules_descriptions_num ; i++) {
- if (!strncmp(*p_modules, modules_descriptions[i].module, strlen(modules_descriptions[i].module))
- && (*p_modules)[strlen(modules_descriptions[i].module)] == '.') /* one contains '.o' not the other */
- *p_descrs = modules_descriptions[i].descr;
- }
- p_modules++;
- p_descrs++;
- }
- if (modules && *modules)
- results = ask_from_list_comments(msg, modules, descrs, &choice);
- else
- results = RETURN_BACK;
- }
-
- if (results == RETURN_OK) {
- choice[strlen(choice)-strlen(kernel_module_extension())] = '\0'; /* remove trailing .ko or .o */
- return insmod_with_options(choice, type);
- } else
- return results;
-}
diff --git a/mdk-stage1/modules.h b/mdk-stage1/modules.h
deleted file mode 100644
index d42d55218..000000000
--- a/mdk-stage1/modules.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _MODULES_H_
-#define _MODULES_H_
-
-#include "stage1.h"
-#include "probing.h"
-
-enum insmod_return { INSMOD_OK, INSMOD_FAILED, INSMOD_FAILED_FILE_NOT_FOUND };
-
-void init_modules_insmoding(void);
-int insmod_local_file(char * path, char * options);
-enum insmod_return my_insmod(const char * mod_name, enum driver_type type, char * options, int allow_modules_floppy);
-enum return_type ask_insmod(enum driver_type);
-int module_already_present(const char * name);
-
-struct module_deps_elem {
- char * name;
- char ** deps;
-};
-
-extern int disable_modules;
-extern int allow_additional_modules_floppy;
-
-#endif
diff --git a/mdk-stage1/modules_descr.h b/mdk-stage1/modules_descr.h
deleted file mode 100644
index 8faf726af..000000000
--- a/mdk-stage1/modules_descr.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2001 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _MODULES_DESCR_H_
-#define _MODULES_DESCR_H_
-
-struct module_descr {
- const char * module;
- char * descr;
-};
-
-struct module_descr modules_descriptions[] = {
-#ifndef DISABLE_NETWORK
- /* description of network drivers that have not very explicit names */
- { "ne", "NE1000/NE2000/clones" },
- { "ne2k-pci", "PCI NE2000" },
- { "depca", "DEC DEPCA/DE100/DE101/DE200/DE201/DE202/DE210/DE422" },
- { "dgrs", "Digi RightSwitch SE-X" },
- { "ewrk3", "DEC DE203/DE204/DE205" },
- { "lance", "Allied Telesis AT1500, HP J2405A, NE2100/NE2500" },
- { "sis900", "SiS 900/7016/630E, Am79c901, RTL8201" },
- { "via-rhine", "VIA VT86c100A Rhine-II, 3043 Rhine-I" },
- { "tulip", "DEC 21040-family based cards" },
- { "wd", "WD8003/WD8013" },
- { "bmac", "Macintosh integrated ethernet (G3)" },
- { "gmac", "Macintosh integrated ethernet (G4/iBook)" },
- { "mace", "Macintosh integrated ethernet (PowerMac)" },
-#endif
-
-#ifndef DISABLE_MEDIAS
- /* description of scsi drivers that have not very explicit names */
- { "53c7,8xx", "NCR53c810/700" },
- { "sim710", "NCR53c710" },
- { "aic7xxx", "Adaptec 7xxx family (AIC/AHA/etc)" },
- { "atp870u", "ACARD/ARTOP AEC-6710/6712" },
- { "ncr53c8xx", "Symbios 53c family" },
- { "sym53c8xx", "Symbios 53c family" },
- { "sim710", "NCR53C710 family" },
- { "mesh", "Macintosh integrated SCSI (NewWorld or internal SCSI)" },
- { "mac53c94", "Macintosh integrated SCSI (OldWorld or external SCSI)" },
-#endif
-
-#ifdef ENABLE_USB
- /* description of usb drivers that have not very explicit names */
- { "usbnet", "Netchip or Prolific USB-USB Bridge" },
- { "pegasus", "ADMtek AN986 (USB Ethernet chipset)" },
- { "kaweth", "KL5KUSB101 (USB Ethernet chipset)" },
- { "catc", "CATC EL1210A NetMate USB Ethernet" },
-#endif
-};
-
-int modules_descriptions_num = sizeof(modules_descriptions) / sizeof(struct module_descr);
-
-
-#endif
diff --git a/mdk-stage1/mount.c b/mdk-stage1/mount.c
deleted file mode 100644
index 40b94a8ec..000000000
--- a/mdk-stage1/mount.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include "log.h"
-#include "modules.h"
-
-#include "mount.h"
-
-
-
-/* WARNING: this won't work if the argument is not /dev/ based */
-int ensure_dev_exists(const char * dev)
-{
- int major, minor;
- int type = S_IFBLK; /* my default type is block. don't forget to change for chars */
- const char * name;
- struct stat buf;
- char * ptr;
-
- name = &dev[5]; /* we really need that dev be passed as /dev/something.. */
-
- if (!stat(dev, &buf))
- return 0; /* if the file already exists, we assume it's correct */
-
- if (ptr_begins_static_str(name, "sd")) {
- /* SCSI disks */
- major = 8;
- minor = (name[2] - 'a') << 4;
- if (name[3] && name[4])
- minor += 10 + (name[4] - '0');
- else if (name[3])
- minor += (name[3] - '0');
- } else if (ptr_begins_static_str(name, "hd")) {
- /* IDE disks/cd's */
- if (name[2] == 'a')
- major = 3, minor = 0;
- else if (name[2] == 'b')
- major = 3, minor = 64;
- else if (name[2] == 'c')
- major = 22, minor = 0;
- else if (name[2] == 'd')
- major = 22, minor = 64;
- else if (name[2] == 'e')
- major = 33, minor = 0;
- else if (name[2] == 'f')
- major = 33, minor = 64;
- else if (name[2] == 'g')
- major = 34, minor = 0;
- else if (name[2] == 'h')
- major = 34, minor = 64;
- else if (name[2] == 'i')
- major = 56, minor = 0;
- else if (name[2] == 'j')
- major = 56, minor = 64;
- else if (name[2] == 'k')
- major = 57, minor = 0;
- else if (name[2] == 'l')
- major = 57, minor = 64;
- else if (name[2] == 'm')
- major = 88, minor = 0;
- else if (name[2] == 'n')
- major = 88, minor = 64;
- else if (name[2] == 'o')
- major = 89, minor = 0;
- else if (name[2] == 'p')
- major = 89, minor = 64;
- else if (name[2] == 'q')
- major = 90, minor = 0;
- else if (name[2] == 'r')
- major = 90, minor = 64;
- else if (name[2] == 's')
- major = 91, minor = 0;
- else if (name[2] == 't')
- major = 91, minor = 64;
- else
- return -1;
-
- if (name[3] && name[4])
- minor += 10 + (name[4] - '0');
- else if (name[3])
- minor += (name[3] - '0');
- } else if (ptr_begins_static_str(name , "sr")) {
- /* SCSI cd's */
- major = 11;
- minor = name[2] - '0';
- } else if (ptr_begins_static_str(name, "ida/") ||
- ptr_begins_static_str(name, "cciss/")) {
- /* Compaq Smart Array "ida/c0d0{p1}" */
- ptr = strchr(name, '/');
- mkdir("/dev/ida", 0755);
- mkdir("/dev/cciss", 0755);
- major = ptr_begins_static_str(name, "ida/") ? 72 : 104 + charstar_to_int(ptr+2);
- ptr = strchr(ptr, 'd');
- minor = 16 * charstar_to_int(ptr+1);
- ptr = strchr(ptr, 'p');
- minor += charstar_to_int(ptr+1);
- } else if (ptr_begins_static_str(name, "rd/")) {
- /* DAC960 "rd/cXdXXpX" */
- mkdir("/dev/rd", 0755);
- major = 48 + charstar_to_int(name+4);
- ptr = strchr(name+4, 'd');
- minor = 8 * charstar_to_int(ptr+1);
- ptr = strchr(ptr, 'p');
- minor += charstar_to_int(ptr+1);
- } else if (ptr_begins_static_str(name, "loop")) {
- major = 7;
- minor = name[4] - '0';
- } else if (ptr_begins_static_str(name, "chloop")) {
- major = 100;
- minor = name[6] - '0';
- } else {
- log_message("I don't know how to create device %s, please post bugreport to me!", dev);
- return -1;
- }
-
- if (mknod(dev, type | 0600, makedev(major, minor))) {
- log_perror(dev);
- return -1;
- }
-
- return 0;
-}
-
-
-/* mounts, creating the device if needed+possible */
-int my_mount(char *dev, char *location, char *fs, int force_rw)
-{
- unsigned long flags = MS_MGC_VAL | (force_rw ? 0 : MS_RDONLY);
- char * opts = NULL;
- struct stat buf;
- int rc;
-
- if (strcmp(fs, "nfs")) {
- rc = ensure_dev_exists(dev);
- if (rc != 0) {
- log_message("could not create required device file");
- return -1;
- }
- }
-
- log_message("mounting %s on %s as type %s", dev, location, fs);
-
- if (stat(location, &buf)) {
- if (mkdir(location, 0755)) {
- log_perror("could not create location dir");
- return -1;
- }
- } else if (!S_ISDIR(buf.st_mode)) {
- log_message("not a dir %s, will unlink and mkdir", location);
- if (unlink(location)) {
- log_perror("could not unlink");
- return -1;
- }
- if (mkdir(location, 0755)) {
- log_perror("could not create location dir");
- return -1;
- }
- }
-
- if (!strcmp(fs, "supermount")) {
- my_insmod("supermount", ANY_DRIVER_TYPE, NULL, 1);
- my_insmod("isofs", ANY_DRIVER_TYPE, NULL, 1);
- opts = alloca(500);
- sprintf(opts, "dev=%s,fs=iso9660,tray_lock=always", dev);
- dev = "none";
- }
-
-#ifndef DISABLE_MEDIAS
- if (!strcmp(fs, "vfat")) {
- my_insmod("vfat", ANY_DRIVER_TYPE, NULL, 1);
- opts = "check=relaxed";
- }
-
- if (!strcmp(fs, "ntfs")) {
- my_insmod("ntfs", ANY_DRIVER_TYPE, NULL, 1);
- }
-
- if (!strcmp(fs, "reiserfs"))
- my_insmod("reiserfs", ANY_DRIVER_TYPE, NULL, 1);
-
-#endif
- if (!strcmp(fs, "iso9660"))
- my_insmod("isofs", ANY_DRIVER_TYPE, NULL, 1);
-
-#ifndef DISABLE_NETWORK
- if (!strcmp(fs, "nfs")) {
- my_insmod("nfs", ANY_DRIVER_TYPE, NULL, 1);
- log_message("preparing nfsmount for %s", dev);
- rc = nfsmount_prepare(dev, &opts);
- if (rc != 0)
- return rc;
- }
-#endif
-
- rc = mount(dev, location, fs, flags, opts);
- if (rc != 0) {
- log_perror("mount failed");
- rmdir(location);
- }
-
- return rc;
-}
diff --git a/mdk-stage1/mount.h b/mdk-stage1/mount.h
deleted file mode 100644
index 4a4317182..000000000
--- a/mdk-stage1/mount.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef _MOUNT_H_
-#define _MOUNT_H_
-
-#ifndef DISABLE_NETWORK
-#include "nfsmount.h"
-#endif
-
-int my_mount(char *dev, char *location, char *fs, int force_rw);
-int ensure_dev_exists(const char * dev);
-
-#endif
diff --git a/mdk-stage1/mount_rpcgen.h b/mdk-stage1/mount_rpcgen.h
deleted file mode 100644
index d70ccaf9d..000000000
--- a/mdk-stage1/mount_rpcgen.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef _MOUNT_H_RPCGEN
-#define _MOUNT_H_RPCGEN
-
-#include <rpc/rpc.h>
-
-#define MNTPATHLEN 1024
-#define MNTNAMLEN 255
-#define FHSIZE 32
-
-typedef char fhandle[FHSIZE];
-#ifdef __cplusplus
-extern "C" bool_t xdr_fhandle(XDR *, fhandle);
-#elif __STDC__
-extern bool_t xdr_fhandle(XDR *, fhandle);
-#else /* Old Style C */
-bool_t xdr_fhandle();
-#endif /* Old Style C */
-
-
-struct fhstatus {
- u_int fhs_status;
- union {
- fhandle fhs_fhandle;
- } fhstatus_u;
-};
-typedef struct fhstatus fhstatus;
-#ifdef __cplusplus
-extern "C" bool_t xdr_fhstatus(XDR *, fhstatus*);
-#elif __STDC__
-extern bool_t xdr_fhstatus(XDR *, fhstatus*);
-#else /* Old Style C */
-bool_t xdr_fhstatus();
-#endif /* Old Style C */
-
-
-typedef char *dirpath;
-#ifdef __cplusplus
-extern "C" bool_t xdr_dirpath(XDR *, dirpath*);
-#elif __STDC__
-extern bool_t xdr_dirpath(XDR *, dirpath*);
-#else /* Old Style C */
-bool_t xdr_dirpath();
-#endif /* Old Style C */
-
-
-typedef char *name;
-#ifdef __cplusplus
-extern "C" bool_t xdr_name(XDR *, name*);
-#elif __STDC__
-extern bool_t xdr_name(XDR *, name*);
-#else /* Old Style C */
-bool_t xdr_name();
-#endif /* Old Style C */
-
-
-typedef struct mountbody *mountlist;
-#ifdef __cplusplus
-extern "C" bool_t xdr_mountlist(XDR *, mountlist*);
-#elif __STDC__
-extern bool_t xdr_mountlist(XDR *, mountlist*);
-#else /* Old Style C */
-bool_t xdr_mountlist();
-#endif /* Old Style C */
-
-
-struct mountbody {
- name ml_hostname;
- dirpath ml_directory;
- mountlist ml_next;
-};
-typedef struct mountbody mountbody;
-#ifdef __cplusplus
-extern "C" bool_t xdr_mountbody(XDR *, mountbody*);
-#elif __STDC__
-extern bool_t xdr_mountbody(XDR *, mountbody*);
-#else /* Old Style C */
-bool_t xdr_mountbody();
-#endif /* Old Style C */
-
-
-typedef struct groupnode *groups;
-#ifdef __cplusplus
-extern "C" bool_t xdr_groups(XDR *, groups*);
-#elif __STDC__
-extern bool_t xdr_groups(XDR *, groups*);
-#else /* Old Style C */
-bool_t xdr_groups();
-#endif /* Old Style C */
-
-
-struct groupnode {
- name gr_name;
- groups gr_next;
-};
-typedef struct groupnode groupnode;
-#ifdef __cplusplus
-extern "C" bool_t xdr_groupnode(XDR *, groupnode*);
-#elif __STDC__
-extern bool_t xdr_groupnode(XDR *, groupnode*);
-#else /* Old Style C */
-bool_t xdr_groupnode();
-#endif /* Old Style C */
-
-
-typedef struct exportnode *exports;
-#ifdef __cplusplus
-extern "C" bool_t xdr_exports(XDR *, exports*);
-#elif __STDC__
-extern bool_t xdr_exports(XDR *, exports*);
-#else /* Old Style C */
-bool_t xdr_exports();
-#endif /* Old Style C */
-
-
-struct exportnode {
- dirpath ex_dir;
- groups ex_groups;
- exports ex_next;
-};
-typedef struct exportnode exportnode;
-#ifdef __cplusplus
-extern "C" bool_t xdr_exportnode(XDR *, exportnode*);
-#elif __STDC__
-extern bool_t xdr_exportnode(XDR *, exportnode*);
-#else /* Old Style C */
-bool_t xdr_exportnode();
-#endif /* Old Style C */
-
-
-#define MOUNTPROG ((u_long)100005)
-#define MOUNTVERS ((u_long)1)
-
-#ifdef __cplusplus
-#define MOUNTPROC_NULL ((u_long)0)
-extern "C" void * mountproc_null_1(void *, CLIENT *);
-extern "C" void * mountproc_null_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_MNT ((u_long)1)
-extern "C" fhstatus * mountproc_mnt_1(dirpath *, CLIENT *);
-extern "C" fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_DUMP ((u_long)2)
-extern "C" mountlist * mountproc_dump_1(void *, CLIENT *);
-extern "C" mountlist * mountproc_dump_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_UMNT ((u_long)3)
-extern "C" void * mountproc_umnt_1(dirpath *, CLIENT *);
-extern "C" void * mountproc_umnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_UMNTALL ((u_long)4)
-extern "C" void * mountproc_umntall_1(void *, CLIENT *);
-extern "C" void * mountproc_umntall_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORT ((u_long)5)
-extern "C" exports * mountproc_export_1(void *, CLIENT *);
-extern "C" exports * mountproc_export_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORTALL ((u_long)6)
-extern "C" exports * mountproc_exportall_1(void *, CLIENT *);
-extern "C" exports * mountproc_exportall_1_svc(void *, struct svc_req *);
-
-#elif __STDC__
-#define MOUNTPROC_NULL ((u_long)0)
-extern void * mountproc_null_1(void *, CLIENT *);
-extern void * mountproc_null_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_MNT ((u_long)1)
-extern fhstatus * mountproc_mnt_1(dirpath *, CLIENT *);
-extern fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_DUMP ((u_long)2)
-extern mountlist * mountproc_dump_1(void *, CLIENT *);
-extern mountlist * mountproc_dump_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_UMNT ((u_long)3)
-extern void * mountproc_umnt_1(dirpath *, CLIENT *);
-extern void * mountproc_umnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_UMNTALL ((u_long)4)
-extern void * mountproc_umntall_1(void *, CLIENT *);
-extern void * mountproc_umntall_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORT ((u_long)5)
-extern exports * mountproc_export_1(void *, CLIENT *);
-extern exports * mountproc_export_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORTALL ((u_long)6)
-extern exports * mountproc_exportall_1(void *, CLIENT *);
-extern exports * mountproc_exportall_1_svc(void *, struct svc_req *);
-
-#else /* Old Style C */
-#define MOUNTPROC_NULL ((u_long)0)
-extern void * mountproc_null_1();
-extern void * mountproc_null_1_svc();
-#define MOUNTPROC_MNT ((u_long)1)
-extern fhstatus * mountproc_mnt_1();
-extern fhstatus * mountproc_mnt_1_svc();
-#define MOUNTPROC_DUMP ((u_long)2)
-extern mountlist * mountproc_dump_1();
-extern mountlist * mountproc_dump_1_svc();
-#define MOUNTPROC_UMNT ((u_long)3)
-extern void * mountproc_umnt_1();
-extern void * mountproc_umnt_1_svc();
-#define MOUNTPROC_UMNTALL ((u_long)4)
-extern void * mountproc_umntall_1();
-extern void * mountproc_umntall_1_svc();
-#define MOUNTPROC_EXPORT ((u_long)5)
-extern exports * mountproc_export_1();
-extern exports * mountproc_export_1_svc();
-#define MOUNTPROC_EXPORTALL ((u_long)6)
-extern exports * mountproc_exportall_1();
-extern exports * mountproc_exportall_1_svc();
-#endif /* Old Style C */
-
-#endif /* !_MOUNT_H_RPCGEN */
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
deleted file mode 100644
index 29ea5dc10..000000000
--- a/mdk-stage1/network.c
+++ /dev/null
@@ -1,1161 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-/* define _GNU_SOURCE so strndup is available */
-#define _GNU_SOURCE
-#include <string.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <net/route.h>
-#include <sys/ioctl.h>
-#include <sys/mount.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <sys/utsname.h>
-
-#include "stage1.h"
-#include "frontend.h"
-#include "modules.h"
-#include "probing.h"
-#include "log.h"
-#include "mount.h"
-#include "automatic.h"
-#include "dhcp.h"
-#include "adsl.h"
-#include "url.h"
-#include "dns.h"
-
-#include "network.h"
-#include "directory.h"
-#include "wireless.h"
-
-static void error_message_net(void) /* reduce code size */
-{
- stg1_error_message("Could not configure network.");
-}
-
-
-int configure_net_device(struct interface_info * intf)
-{
- struct ifreq req;
- struct rtentry route;
- int s;
- struct sockaddr_in addr;
- struct in_addr ia;
- char ip[20], nm[20], nw[20], bc[20];
-
- addr.sin_family = AF_INET;
- addr.sin_port = 0;
-
- memcpy(&ia, &intf->ip, sizeof(intf->ip));
- strcpy(ip, inet_ntoa(ia));
-
- memcpy(&ia, &intf->netmask, sizeof(intf->netmask));
- strcpy(nm, inet_ntoa(ia));
-
- memcpy(&ia, &intf->broadcast, sizeof(intf->broadcast));
- strcpy(bc, inet_ntoa(ia));
-
- memcpy(&ia, &intf->network, sizeof(intf->network));
- strcpy(nw, inet_ntoa(ia));
-
- log_message("configuring device %s ip: %s nm: %s nw: %s bc: %s", intf->device, ip, nm, nw, bc);
-
- if (IS_TESTING)
- return 0;
-
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- log_perror("socket");
- error_message_net();
- return 1;
- }
-
- strcpy(req.ifr_name, intf->device);
-
- if (intf->is_up == 1) {
- log_message("interface already up, downing before reconfigure");
-
- req.ifr_flags = 0;
- if (ioctl(s, SIOCSIFFLAGS, &req)) {
- close(s);
- log_perror("SIOCSIFFLAGS (downing)");
- error_message_net();
- return 1;
- }
- }
-
- /* sets IP address */
- addr.sin_port = 0;
- memcpy(&addr.sin_addr, &intf->ip, sizeof(intf->ip));
- memcpy(&req.ifr_addr, &addr, sizeof(addr));
- if (ioctl(s, SIOCSIFADDR, &req)) {
- close(s);
- log_perror("SIOCSIFADDR");
- error_message_net();
- return 1;
- }
-
- /* sets broadcast */
- memcpy(&addr.sin_addr, &intf->broadcast, sizeof(intf->broadcast));
- memcpy(&req.ifr_broadaddr, &addr, sizeof(addr));
- if (ioctl(s, SIOCSIFBRDADDR, &req)) {
- close(s);
- log_perror("SIOCSIFBRDADDR");
- error_message_net();
- return 1;
- }
-
- /* sets netmask */
- memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask));
- memcpy(&req.ifr_netmask, &addr, sizeof(addr));
- if (ioctl(s, SIOCSIFNETMASK, &req)) {
- close(s);
- log_perror("SIOCSIFNETMASK");
- error_message_net();
- return 1;
- }
-
- if (intf->is_ptp)
- req.ifr_flags = IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_NOARP;
- else
- req.ifr_flags = IFF_UP | IFF_RUNNING | IFF_BROADCAST;
-
- /* brings up networking! */
- if (ioctl(s, SIOCSIFFLAGS, &req)) {
- close(s);
- log_perror("SIOCSIFFLAGS (upping)");
- error_message_net();
- return 1;
- }
-
- memset(&route, 0, sizeof(route));
- route.rt_dev = intf->device;
- route.rt_flags = RTF_UP;
-
- memcpy(&addr.sin_addr, &intf->network, sizeof(intf->network));
- memcpy(&route.rt_dst, &addr, sizeof(addr));
-
- memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask));
- memcpy(&route.rt_genmask, &addr, sizeof(addr));
-
- /* adds route */
- if (ioctl(s, SIOCADDRT, &route)) {
- close(s);
- log_perror("SIOCADDRT");
- error_message_net();
- return 1;
- }
-
- close(s);
-
- intf->is_up = 1;
-
- if (intf->boot_proto != BOOTPROTO_DHCP && !streq(intf->device, "lo")) {
- /* I need to sleep a bit in order for kernel to finish
- init of the network device; if not, first sendto() for
- gethostbyaddr will get an EINVAL. */
- wait_message("Bringing up networking...");
- sleep(2);
- remove_wait_message();
- }
-
- return 0;
-}
-
-/* host network informations */
-char * hostname = NULL;
-char * domain = NULL;
-struct in_addr gateway = { 0 };
-struct in_addr dns_server = { 0 };
-struct in_addr dns_server2 = { 0 };
-
-static int add_default_route(void)
-{
- int s;
- struct rtentry route;
- struct sockaddr_in addr;
-
- if (IS_TESTING)
- return 0;
-
- if (gateway.s_addr == 0) {
- log_message("no gateway provided, can't add default route");
- return 0;
- }
-
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- close(s);
- log_perror("socket");
- error_message_net();
- return 1;
- }
-
- memset(&route, 0, sizeof(route));
-
- addr.sin_family = AF_INET;
- addr.sin_port = 0;
- addr.sin_addr = gateway;
- memcpy(&route.rt_gateway, &addr, sizeof(addr));
-
- addr.sin_addr.s_addr = INADDR_ANY;
- memcpy(&route.rt_dst, &addr, sizeof(addr));
- memcpy(&route.rt_genmask, &addr, sizeof(addr));
-
- route.rt_flags = RTF_UP | RTF_GATEWAY;
- route.rt_metric = 0;
-
- if (ioctl(s, SIOCADDRT, &route)) {
- close(s);
- log_perror("SIOCADDRT");
- error_message_net();
- return 1;
- }
-
- close(s);
-
- return 0;
-}
-
-
-static int write_resolvconf(void)
-{
- char * filename = "/etc/resolv.conf";
- FILE * f;
-
- if (dns_server.s_addr == 0) {
- log_message("resolvconf needs a dns server");
- return -1;
- }
-
- f = fopen(filename, "w");
- if (!f) {
- log_perror(filename);
- return -1;
- }
-
- if (domain)
- fprintf(f, "search %s\n", domain); /* we can live without the domain search (user will have to enter fully-qualified names) */
- fprintf(f, "nameserver %s\n", inet_ntoa(dns_server));
- if (dns_server2.s_addr != 0)
- fprintf(f, "nameserver %s\n", inet_ntoa(dns_server2));
-
- fclose(f);
- res_init(); /* reinit the resolver so DNS changes take affect */
-
- return 0;
-}
-
-
-static int save_netinfo(struct interface_info * intf)
-{
- char * file_network = "/tmp/network";
- char file_intf[500];
- FILE * f;
-
- f = fopen(file_network, "w");
- if (!f) {
- log_perror(file_network);
- return -1;
- }
-
- fprintf(f, "NETWORKING=yes\n");
- fprintf(f, "FORWARD_IPV4=false\n");
-
- if (hostname && !intf->boot_proto == BOOTPROTO_DHCP)
- fprintf(f, "HOSTNAME=%s\n", hostname);
- if (gateway.s_addr != 0)
- fprintf(f, "GATEWAY=%s\n", inet_ntoa(gateway));
-
- fclose(f);
-
-
- strcpy(file_intf, "/tmp/ifcfg-");
- strcat(file_intf, intf->device);
-
- f = fopen(file_intf, "w");
- if (!f) {
- log_perror(file_intf);
- return -1;
- }
-
- fprintf(f, "DEVICE=%s\n", intf->device);
-
- if (intf->boot_proto == BOOTPROTO_DHCP) {
- fprintf(f, "BOOTPROTO=dhcp\n");
- if (dhcp_hostname && !streq(dhcp_hostname, ""))
- fprintf(f, "DHCP_HOSTNAME=%s\n", dhcp_hostname);
- } else if (intf->boot_proto == BOOTPROTO_STATIC) {
- fprintf(f, "BOOTPROTO=static\n");
- fprintf(f, "IPADDR=%s\n", inet_ntoa(intf->ip));
- fprintf(f, "NETMASK=%s\n", inet_ntoa(intf->netmask));
- fprintf(f, "NETWORK=%s\n", inet_ntoa(intf->network));
- fprintf(f, "BROADCAST=%s\n", inet_ntoa(intf->broadcast));
- } else if (intf->boot_proto == BOOTPROTO_ADSL_PPPOE) {
- fprintf(f, "BOOTPROTO=adsl_pppoe\n");
- fprintf(f, "USER=%s\n", intf->user);
- fprintf(f, "PASS=%s\n", intf->pass);
- fprintf(f, "ACNAME=%s\n", intf->acname);
- }
-
- fclose(f);
-
- return 0;
-}
-
-
-char * guess_netmask(char * ip_addr)
-{
- struct in_addr addr;
- unsigned long int tmp;
-
- if (streq(ip_addr, "") || !inet_aton(ip_addr, &addr))
- return "";
-
- log_message("guessing netmask");
-
- tmp = ntohl(addr.s_addr);
-
- if (((tmp & 0xFF000000) >> 24) <= 127)
- return "255.0.0.0";
- else if (((tmp & 0xFF000000) >> 24) <= 191)
- return "255.255.0.0";
- else
- return "255.255.255.0";
-}
-
-
-char * guess_domain_from_hostname(char *hostname)
-{
- char *domain = strchr(strdup(hostname), '.');
- if (!domain || domain[1] == '\0') {
- log_message("unable to guess domain from hostname: %s", hostname);
- return NULL;
- }
- return domain + 1; /* skip '.' */
-}
-
-
-static void static_ip_callback(char ** strings)
-{
- struct in_addr addr;
-
- static int done = 0;
- if (done)
- return;
- if (streq(strings[0], "") || !inet_aton(strings[0], &addr))
- return;
- done = 1;
-
- if (!strcmp(strings[1], "")) {
- char * ptr;
- strings[1] = strdup(strings[0]);
- ptr = strrchr(strings[1], '.');
- if (ptr)
- *(ptr+1) = '\0';
- }
-
- if (!strcmp(strings[2], ""))
- strings[2] = strdup(strings[1]);
-
- if (!strcmp(strings[3], ""))
- strings[3] = strdup(guess_netmask(strings[0]));
-}
-
-
-static enum return_type setup_network_interface(struct interface_info * intf)
-{
- enum return_type results;
- char * bootprotos[] = { "Static", "DHCP", "ADSL", NULL };
- char * bootprotos_auto[] = { "static", "dhcp", "adsl" };
- char * choice;
-
- results = ask_from_list_auto("Please select your network connection type.", bootprotos, &choice, "network", bootprotos_auto);
- if (results != RETURN_OK)
- return results;
-
- if (!strcmp(choice, "Static")) {
- char * questions[] = { "IP of this machine", "IP of DNS", "IP of default gateway", "Netmask", NULL };
- char * questions_auto[] = { "ip", "dns", "gateway", "netmask" };
- static char ** answers = NULL;
- struct in_addr addr;
-
- results = ask_from_entries_auto("Please enter the network information. (leave netmask blank for Internet standard)",
- questions, &answers, 16, questions_auto, static_ip_callback);
- if (results != RETURN_OK)
- return setup_network_interface(intf);
-
- if (streq(answers[0], "") || !inet_aton(answers[0], &addr)) {
- stg1_error_message("Invalid IP address.");
- return setup_network_interface(intf);
- }
- memcpy(&intf->ip, &addr, sizeof(addr));
-
- if (!inet_aton(answers[1], &dns_server)) {
- log_message("invalid DNS");
- dns_server.s_addr = 0; /* keep an understandable state */
- }
-
- if (streq(answers[0], answers[1])) {
- log_message("IP and DNS are the same, guess you don't want a DNS, disabling it");
- dns_server.s_addr = 0; /* keep an understandable state */
- }
-
- if (!inet_aton(answers[2], &gateway)) {
- log_message("invalid gateway");
- gateway.s_addr = 0; /* keep an understandable state */
- }
-
- if ((streq(answers[3], "") && inet_aton(guess_netmask(answers[0]), &addr))
- || inet_aton(answers[3], &addr))
- memcpy(&intf->netmask, &addr, sizeof(addr));
- else {
- stg1_error_message("Invalid netmask.");
- return setup_network_interface(intf);
- }
-
- *((uint32_t *) &intf->broadcast) = (*((uint32_t *) &intf->ip) &
- *((uint32_t *) &intf->netmask)) | ~(*((uint32_t *) &intf->netmask));
-
- inet_aton("255.255.255.255", &addr);
- if (!memcmp(&addr, &intf->netmask, sizeof(addr))) {
- log_message("netmask is 255.255.255.255 -> point to point device");
- intf->network = gateway;
- intf->is_ptp = 1;
- } else {
- *((uint32_t *) &intf->network) = *((uint32_t *) &intf->ip) & *((uint32_t *) &intf->netmask);
- intf->is_ptp = 0;
- }
- intf->boot_proto = BOOTPROTO_STATIC;
-
- if (configure_net_device(intf))
- return RETURN_ERROR;
-
- } else if (streq(choice, "DHCP")) {
- results = perform_dhcp(intf);
-
- if (results == RETURN_BACK)
- return setup_network_interface(intf);
- if (results == RETURN_ERROR)
- return results;
- intf->boot_proto = BOOTPROTO_DHCP;
-
- if (configure_net_device(intf))
- return RETURN_ERROR;
-
- } else if (streq(choice, "ADSL")) {
- results = perform_adsl(intf);
-
- if (results == RETURN_BACK)
- return setup_network_interface(intf);
- if (results == RETURN_ERROR)
- return results;
- } else
- return RETURN_ERROR;
-
- return add_default_route();
-}
-
-
-static enum return_type configure_network(struct interface_info * intf)
-{
- char * dnshostname;
-
- if (hostname && domain)
- return RETURN_OK;
-
- dnshostname = mygethostbyaddr(inet_ntoa(intf->ip));
-
- if (dnshostname) {
- if (intf->boot_proto == BOOTPROTO_STATIC)
- hostname = strdup(dnshostname);
- domain = guess_domain_from_hostname(dnshostname);
- if (domain) {
- log_message("got hostname and domain from dns entry, %s and %s", dnshostname, domain);
- return RETURN_OK;
- }
- } else
- log_message("reverse name lookup on self failed");
-
- if (domain)
- return RETURN_OK;
-
- dnshostname = NULL;
- if (dns_server.s_addr != 0) {
- wait_message("Trying to resolve dns...");
- dnshostname = mygethostbyaddr(inet_ntoa(dns_server));
- remove_wait_message();
- if (dnshostname) {
- log_message("got DNS fullname, %s", dnshostname);
- domain = guess_domain_from_hostname(dnshostname);
- } else
- log_message("reverse name lookup on DNS failed");
- } else
- log_message("no DNS, unable to guess domain");
-
- if (domain) {
- log_message("got domain from DNS fullname, %s", domain);
- } else {
- enum return_type results;
- char * questions[] = { "Host name", "Domain name", NULL };
- char * questions_auto[] = { "hostname", "domain" };
- static char ** answers = NULL;
- char * boulet;
-
- if (dhcp_hostname || dhcp_domain) {
- answers = (char **) malloc(sizeof(questions));
- answers[0] = strdup(dhcp_hostname);
- answers[1] = strdup(dhcp_domain);
- }
-
- if (!dhcp_hostname || !dhcp_hostname) {
- results = ask_from_entries_auto("I could not guess hostname and domain name; please fill in this information. "
- "Valid answers are for example: `mybox' for hostname and `mynetwork.com' for "
- "domain name, for a machine called `mybox.mynetwork.com' on the Internet.",
- questions, &answers, 32, questions_auto, NULL);
- if (results != RETURN_OK)
- return results;
- }
-
- hostname = answers[0];
- if ((boulet = strchr(hostname, '.')) != NULL)
- boulet[0] = '\0';
- domain = answers[1];
- }
-
- log_message("using hostname %s", hostname);
- log_message("using domain %s", domain);
-
- return RETURN_OK;
-}
-
-
-static enum return_type bringup_networking(struct interface_info * intf)
-{
- static struct interface_info loopback;
- enum return_type results;
-
- my_insmod("af_packet", ANY_DRIVER_TYPE, NULL, 1);
-
- do {
- results = configure_wireless(intf->device);
- } while (results == RETURN_ERROR);
-
- if (results == RETURN_BACK)
- return RETURN_BACK;
-
- do {
- results = setup_network_interface(intf);
- if (results != RETURN_OK)
- return results;
- write_resolvconf();
- results = configure_network(intf);
- } while (results == RETURN_ERROR);
-
- if (results == RETURN_BACK)
- return bringup_networking(intf);
-
- write_resolvconf(); /* maybe we have now domain to write also */
-
- if (loopback.is_up == 0) {
- int rc;
- strcpy(loopback.device, "lo");
- loopback.is_ptp = 0;
- loopback.is_up = 0;
- loopback.ip.s_addr = htonl(0x7f000001);
- loopback.netmask.s_addr = htonl(0xff000000);
- loopback.broadcast.s_addr = htonl(0x7fffffff);
- loopback.network.s_addr = htonl(0x7f000000);
- rc = configure_net_device(&loopback);
- if (rc)
- return RETURN_ERROR;
- }
-
- return RETURN_OK;
-}
-
-
-static char * interface_select(void)
-{
- char ** interfaces, ** ptr;
- char * descriptions[50];
- char * choice;
- int i, count = 0;
- enum return_type results;
-
- interfaces = get_net_devices();
-
- ptr = interfaces;
- while (ptr && *ptr) {
- count++;
- ptr++;
- }
-
- if (count == 0) {
- stg1_error_message("No NET device found.\n"
- "Hint: if you're using a Laptop, note that PCMCIA Network adapters are now supported either with `pcmcia.img' or `network.img', please try both these bootdisks.");
- i = ask_insmod(NETWORK_DEVICES);
- if (i == RETURN_BACK)
- return NULL;
- return interface_select();
- }
-
- if (count == 1)
- return *interfaces;
-
- i = 0;
- while (interfaces[i]) {
- descriptions[i] = get_net_intf_description(interfaces[i]);
- i++;
- }
-
- results = ask_from_list_comments_auto("Please choose the NET device to use for the installation.",
- interfaces, descriptions, &choice, "interface", interfaces);
-
- if (results != RETURN_OK)
- return NULL;
-
- return choice;
-}
-
-#ifndef MANDRAKE_MOVE
-static enum return_type get_http_proxy(char **http_proxy_host, char **http_proxy_port)
-{
- char *questions[] = { "HTTP proxy host", "HTTP proxy port", NULL };
- char *questions_auto[] = { "proxy_host", "proxy_port", NULL };
- static char ** answers = NULL;
- enum return_type results;
-
- results = ask_from_entries_auto("Please enter HTTP proxy host and port if you need it, else leave them blank or cancel.",
- questions, &answers, 40, questions_auto, NULL);
- if (results == RETURN_OK) {
- *http_proxy_host = answers[0];
- *http_proxy_port = answers[1];
- } else {
- *http_proxy_host = NULL;
- *http_proxy_port = NULL;
- }
-
- return results;
-}
-
-
-static int mirrorlist_entry_split(const char *entry, char *mirror[4]) /* mirror = { medium, protocol, host, path } */
-{
- char *medium_sep, *protocol_sep, *host_sep, *path_sep;
-
- medium_sep = strchr(entry, ':');
- if (!medium_sep || medium_sep == entry) {
- log_message("NETWORK: no medium in \"%s\"", entry);
- return -1;
- }
-
- mirror[0] = strndup(entry, medium_sep - entry);
- entry = medium_sep + 1;
-
- protocol_sep = strstr(entry, "://");
- if (!protocol_sep || protocol_sep == entry) {
- log_message("NETWORK: no protocol in \"%s\"", entry);
- return -1;
- }
-
- mirror[1] = strndup(entry, protocol_sep - entry);
- entry = protocol_sep + 3;
-
- host_sep = strchr(entry, '/');
- if (!host_sep || host_sep == entry) {
- log_message("NETWORK: no hostname in \"%s\"", entry);
- return -1;
- }
-
- mirror[2] = strndup(entry, host_sep - entry);
- entry = host_sep;
-
- path_sep = strstr(entry, "/media/main");
- if (!path_sep || path_sep == entry) {
- log_message("NETWORK: this path isn't valid : \"%s\"", entry);
- return -1;
- }
-
- mirror[3] = strndup(entry, path_sep - entry);
-
- return 0;
-}
-
-
-#define MIRRORLIST_MAX_ITEMS 500
-#define MIRRORLIST_MAX_MEDIA 10
-
-static int choose_mirror_from_host_list(char *mirrorlist[][4], const char *protocol, char *medium, char **selected_host, char **filepath)
-{
- enum return_type results;
- char *hostlist[MIRRORLIST_MAX_ITEMS+1] = { "Specify the mirror manually", "-----" };
- int hostlist_index = 2, mirrorlist_index;
-
- /* select hosts matching medium and protocol */
- for (mirrorlist_index = 0; mirrorlist[mirrorlist_index][0]; mirrorlist_index++) {
- if (!strcmp(mirrorlist[mirrorlist_index][0], medium) &&
- !strcmp(mirrorlist[mirrorlist_index][1], protocol)) {
- hostlist[hostlist_index] = mirrorlist[mirrorlist_index][2];
- hostlist_index++;
- if (hostlist_index == MIRRORLIST_MAX_ITEMS)
- break;
- }
- }
- hostlist[hostlist_index] = NULL;
-
- do {
- results = ask_from_list("Please select a mirror from the list below.",
- hostlist, selected_host);
-
- if (results == RETURN_BACK) {
- return RETURN_ERROR;
- } else if (results == RETURN_OK) {
- if (!strcmp(*selected_host, hostlist[0])) {
- /* enter the mirror manually */
- return RETURN_OK;
- } else if (!strcmp(*selected_host, hostlist[1])) {
- /* the separator has been selected */
- results = RETURN_ERROR;
- continue;
- }
- }
-
- /* select the path according to medium, protocol and host */
- for (mirrorlist_index = 0; mirrorlist[mirrorlist_index][0]; mirrorlist_index++) {
- if (!strcmp(mirrorlist[mirrorlist_index][0], medium) &&
- !strcmp(mirrorlist[mirrorlist_index][1], protocol) &&
- !strcmp(mirrorlist[mirrorlist_index][2], *selected_host)) {
- *filepath = mirrorlist[mirrorlist_index][3];
- return RETURN_OK;
- }
- }
-
- stg1_info_message("Unable to find the path for this mirror, please select another one");
- results = RETURN_ERROR;
-
- } while (results == RETURN_ERROR);
-
- return RETURN_ERROR;
-}
-
-
-static int choose_mirror_from_list(char *http_proxy_host, char *http_proxy_port, const char *protocol, char **selected_host, char **filepath)
-{
- enum return_type results;
- char *mirrorlist[MIRRORLIST_MAX_ITEMS+1][4];
- int mirrorlist_number = 0;
- char *medialist[MIRRORLIST_MAX_MEDIA+1] = { "Specify the mirror manually", "-----" };
- int media_number = 2;
- char *selected_medium;
- int fd, size, line_pos = 0;
- char line[500];
- int use_http_proxy = http_proxy_host && http_proxy_port && !streq(http_proxy_host, "") && !streq(http_proxy_port, "");
-
- fd = http_download_file(MIRRORLIST_HOST, MIRRORLIST_PATH, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port);
- if (fd < 0) {
- log_message("HTTP: unable to get mirrors list");
- return RETURN_ERROR;
- }
-
- while (read(fd, line + line_pos, 1) > 0) {
- if (line[line_pos] == '\n') {
- line[line_pos] = '\0';
- line_pos = 0;
-
- /* skip medium if it looks like an updates one */
- if (strstr(line, "updates"))
- continue;
-
- if (mirrorlist_entry_split(line, mirrorlist[mirrorlist_number]) < 0)
- continue;
-
- /* add medium in media list if different from previous one */
- if (media_number == 2 ||
- strcmp(mirrorlist[mirrorlist_number][0], medialist[media_number-1])) {
- medialist[media_number] = mirrorlist[mirrorlist_number][0];
- media_number++;
- }
-
- mirrorlist_number++;
- } else {
- line_pos++;
- }
-
- if (mirrorlist_number >= MIRRORLIST_MAX_ITEMS || media_number >= MIRRORLIST_MAX_MEDIA)
- break;
- }
- close(fd);
-
- mirrorlist[mirrorlist_number][0] = NULL;
- medialist[media_number] = NULL;
-
- do {
- results = ask_from_list("Please select a medium from the list below.",
- medialist, &selected_medium);
-
- if (results == RETURN_BACK) {
- return RETURN_BACK;
- } else if (results == RETURN_OK) {
- if (!strcmp(selected_medium, medialist[0])) {
- /* enter the mirror manually */
- return RETURN_OK;
- } else if (!strcmp(selected_medium, medialist[1])) {
- /* the separator has been selected */
- results = RETURN_ERROR;
- continue;
- } else {
- /* a medium has been selected */
- results = choose_mirror_from_host_list(mirrorlist, protocol, selected_medium, selected_host, filepath);
- }
- }
- } while (results == RETURN_ERROR);
-
- return results;
-}
-#endif
-
-
-/* -=-=-- */
-
-
-enum return_type intf_select_and_up()
-{
- static struct interface_info intf[20];
- static int num_interfaces = 0;
- struct interface_info * sel_intf = NULL;
- int i;
- enum return_type results;
- char * iface = interface_select();
-
- if (iface == NULL)
- return RETURN_BACK;
-
- for (i = 0; i < num_interfaces ; i++)
- if (!strcmp(intf[i].device, iface))
- sel_intf = &(intf[i]);
-
- if (sel_intf == NULL) {
- sel_intf = &(intf[num_interfaces]);
- strcpy(sel_intf->device, iface);
- sel_intf->is_up = 0;
- num_interfaces++;
- }
-
- results = bringup_networking(sel_intf);
-
- if (results == RETURN_OK)
- save_netinfo(sel_intf);
-
- return results;
-}
-
-
-
-enum return_type nfs_prepare(void)
-{
- char * questions[] = { "NFS server name", DISTRIB_NAME " directory", NULL };
- char * questions_auto[] = { "server", "directory", NULL };
- static char ** answers = NULL;
- char * nfs_own_mount = IMAGE_LOCATION_DIR "nfsimage";
- char * nfsmount_location;
- enum return_type results = intf_select_and_up(NULL, NULL);
-
- if (results != RETURN_OK)
- return results;
-
- do {
- results = ask_from_entries_auto("Please enter the name or IP address of your NFS server, "
- "and the directory containing the " DISTRIB_NAME " Distribution.",
- questions, &answers, 40, questions_auto, NULL);
- if (results != RETURN_OK || streq(answers[0], "")) {
- unset_automatic(); /* we are in a fallback mode */
- return nfs_prepare();
- }
-
- nfsmount_location = malloc(strlen(answers[0]) + strlen(answers[1]) + 2);
- strcpy(nfsmount_location, answers[0]);
- strcat(nfsmount_location, ":");
- strcat(nfsmount_location, answers[1]);
-
- if (my_mount(nfsmount_location, nfs_own_mount, "nfs", 0) == -1) {
- stg1_error_message("I can't mount the directory from the NFS server.");
- results = RETURN_BACK;
- continue;
- }
-
- results = try_with_directory(nfs_own_mount, "nfs", "nfs-iso");
- if (results != RETURN_OK)
- umount(nfs_own_mount);
- if (results == RETURN_ERROR)
- return RETURN_ERROR;
- }
- while (results == RETURN_BACK);
-
- return RETURN_OK;
-}
-
-
-#ifndef MANDRAKE_MOVE
-enum return_type ftp_prepare(void)
-{
- char * questions[] = { "FTP server", DISTRIB_NAME " directory", "Login", "Password", NULL };
- char * questions_auto[] = { "server", "directory", "user", "pass", NULL };
- static char ** answers = NULL;
- enum return_type results;
- struct utsname kernel_uname;
- char *http_proxy_host, *http_proxy_port;
- int use_http_proxy;
-
- if (!ramdisk_possible()) {
- stg1_error_message("FTP install needs more than %d Mbytes of memory (detected %d Mbytes). You may want to try an NFS install.",
- MEM_LIMIT_DRAKX, total_memory());
- return RETURN_ERROR;
- }
-
- results = intf_select_and_up();
-
- if (results != RETURN_OK)
- return results;
-
- get_http_proxy(&http_proxy_host, &http_proxy_port);
- use_http_proxy = http_proxy_host && http_proxy_port && !streq(http_proxy_host, "") && !streq(http_proxy_port, "");
-
- uname(&kernel_uname);
-
- do {
- char location_full[500];
- int ftp_serv_response = -1;
- int fd, size;
- char ftp_hostname[500];
-
- if (!IS_AUTOMATIC) {
- if (answers == NULL)
- answers = (char **) malloc(sizeof(questions));
-
- results = choose_mirror_from_list(http_proxy_host, http_proxy_port, "ftp", &answers[0], &answers[1]);
-
- if (results == RETURN_BACK)
- return ftp_prepare();
-
- if (use_http_proxy) {
- results = ask_yes_no("Do you want to use this HTTP proxy for FTP connections too ?");
-
- if (results == RETURN_BACK)
- return ftp_prepare();
-
- use_http_proxy = results == RETURN_OK;
- }
- }
-
- results = ask_from_entries_auto("Please enter the name or IP address of the FTP server, "
- "the directory containing the " DISTRIB_NAME " Distribution, "
- "and the login/pass if necessary (leave login blank for anonymous). ",
- questions, &answers, 40, questions_auto, NULL);
- if (results != RETURN_OK || streq(answers[0], "")) {
- unset_automatic(); /* we are in a fallback mode */
- return ftp_prepare();
- }
-
- strcpy(location_full, answers[1][0] == '/' ? "" : "/");
- strcat(location_full, answers[1]);
-
- if (use_http_proxy) {
- log_message("FTP: don't connect to %s directly, will use proxy", answers[0]);
- } else {
- char *kernels_list_file, *kernels_list;
-
- log_message("FTP: trying to connect to %s", answers[0]);
- ftp_serv_response = ftp_open_connection(answers[0], answers[2], answers[3], "");
- if (ftp_serv_response < 0) {
- log_message("FTP: error connect %d", ftp_serv_response);
- if (ftp_serv_response == FTPERR_BAD_HOSTNAME)
- stg1_error_message("Error: bad hostname.");
- else if (ftp_serv_response == FTPERR_FAILED_CONNECT)
- stg1_error_message("Error: failed to connect to remote host.");
- else
- stg1_error_message("Error: couldn't connect.");
- results = RETURN_BACK;
- continue;
- }
- kernels_list_file = asprintf_("%s/" CLP_LOCATION_REL "mdkinst.kernels", location_full);
-
- log_message("FTP: trying to retrieve %s", kernels_list_file);
- fd = ftp_start_download(ftp_serv_response, kernels_list_file, &size);
-
- if (fd < 0) {
- char *msg = str_ftp_error(fd);
- log_message("FTP: error get %d for remote file %s", fd, kernels_list_file);
- stg1_error_message("Error: %s.", msg ? msg : "couldn't retrieve list of kernel versions");
- results = RETURN_BACK;
- continue;
- }
-
- kernels_list = alloca(size);
- size = read(fd, kernels_list, size);
- close(fd);
- ftp_end_data_command(ftp_serv_response);
-
- if (!strstr(kernels_list, asprintf_("%s\n", kernel_uname.release))) {
- stg1_info_message("The modules for this kernel (%s) can't be found on this mirror, please update your boot disk", kernel_uname.release);
- results = RETURN_BACK;
- continue;
- }
- }
-
- strcat(location_full, CLP_FILE_REL("/"));
-
- log_message("FTP: trying to retrieve %s", location_full);
-
- if (use_http_proxy) {
- if (strcmp(answers[2], "")) {
- strcpy(ftp_hostname, answers[2]); /* user name */
- strcat(ftp_hostname, ":");
- strcat(ftp_hostname, answers[3]); /* password */
- strcat(ftp_hostname, "@");
- } else {
- strcpy(ftp_hostname, "");
- }
- strcat(ftp_hostname, answers[0]);
- fd = http_download_file(ftp_hostname, location_full, &size, "ftp", http_proxy_host, http_proxy_port);
- } else {
- fd = ftp_start_download(ftp_serv_response, location_full, &size);
- }
-
- if (fd < 0) {
- char *msg = str_ftp_error(fd);
- log_message("FTP: error get %d for remote file %s", fd, location_full);
- stg1_error_message("Error: %s.", msg ? msg : "couldn't retrieve Installation program");
- results = RETURN_BACK;
- continue;
- }
-
- log_message("FTP: size of download %d bytes", size);
-
- results = load_clp_fd(fd, size);
- if (results == RETURN_OK) {
- if (!use_http_proxy)
- ftp_end_data_command(ftp_serv_response);
- } else {
- unset_automatic(); /* we are in a fallback mode */
- return results;
- }
-
- if (use_http_proxy) {
- add_to_env("METHOD", "http");
- sprintf(location_full, "ftp://%s%s", ftp_hostname, answers[1]);
- add_to_env("URLPREFIX", location_full);
- add_to_env("PROXY", http_proxy_host);
- add_to_env("PROXYPORT", http_proxy_port);
- } else {
- add_to_env("METHOD", "ftp");
- add_to_env("HOST", answers[0]);
- add_to_env("PREFIX", answers[1]);
- if (!streq(answers[2], "")) {
- add_to_env("LOGIN", answers[2]);
- add_to_env("PASSWORD", answers[3]);
- }
- }
- }
- while (results == RETURN_BACK);
-
- return RETURN_OK;
-}
-
-enum return_type http_prepare(void)
-{
- char * questions[] = { "HTTP server", DISTRIB_NAME " directory", NULL };
- char * questions_auto[] = { "server", "directory", NULL };
- static char ** answers = NULL;
- enum return_type results;
- char *http_proxy_host, *http_proxy_port;
-
- if (!ramdisk_possible()) {
- stg1_error_message("HTTP install needs more than %d Mbytes of memory (detected %d Mbytes). You may want to try an NFS install.",
- MEM_LIMIT_DRAKX, total_memory());
- return RETURN_ERROR;
- }
-
- results = intf_select_and_up();
-
- if (results != RETURN_OK)
- return results;
-
- get_http_proxy(&http_proxy_host, &http_proxy_port);
-
- do {
- char location_full[500];
- int fd, size;
- int use_http_proxy;
-
- results = ask_from_entries_auto("Please enter the name or IP address of the HTTP server, "
- "and the directory containing the " DISTRIB_NAME " Distribution.",
- questions, &answers, 40, questions_auto, NULL);
- if (results != RETURN_OK || streq(answers[0], "")) {
- unset_automatic(); /* we are in a fallback mode */
- return http_prepare();
- }
-
- strcpy(location_full, answers[1][0] == '/' ? "" : "/");
- strcat(location_full, answers[1]);
- strcat(location_full, CLP_FILE_REL("/"));
-
- log_message("HTTP: trying to retrieve %s from %s", location_full, answers[0]);
-
- use_http_proxy = http_proxy_host && http_proxy_port && !streq(http_proxy_host, "") && !streq(http_proxy_port, "");
-
- fd = http_download_file(answers[0], location_full, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port);
- if (fd < 0) {
- log_message("HTTP: error %d", fd);
- if (fd == FTPERR_FAILED_CONNECT)
- stg1_error_message("Error: couldn't connect to server.");
- else
- stg1_error_message("Error: couldn't get file (%s).", location_full);
- results = RETURN_BACK;
- continue;
- }
-
- log_message("HTTP: size of download %d bytes", size);
-
- if (load_clp_fd(fd, size) != RETURN_OK) {
- unset_automatic(); /* we are in a fallback mode */
- return RETURN_ERROR;
- }
-
- add_to_env("METHOD", "http");
- sprintf(location_full, "http://%s%s%s", answers[0], answers[1][0] == '/' ? "" : "/", answers[1]);
- add_to_env("URLPREFIX", location_full);
- if (!streq(http_proxy_host, ""))
- add_to_env("PROXY", http_proxy_host);
- if (!streq(http_proxy_port, ""))
- add_to_env("PROXYPORT", http_proxy_port);
- }
- while (results == RETURN_BACK);
-
- return RETURN_OK;
-
-}
-#endif
diff --git a/mdk-stage1/network.h b/mdk-stage1/network.h
deleted file mode 100644
index a94f8150b..000000000
--- a/mdk-stage1/network.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef _NETWORK_H_
-#define _NETWORK_H_
-
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <arpa/inet.h>
-
-enum return_type intf_select_and_up();
-
-enum return_type nfs_prepare(void);
-#ifndef MANDRAKE_MOVE
-enum return_type ftp_prepare(void);
-enum return_type http_prepare(void);
-#endif
-
-
-enum boot_proto_type { BOOTPROTO_STATIC, BOOTPROTO_DHCP, BOOTPROTO_ADSL_PPPOE };
-
-/* all of these in_addr things are in network byte order! */
-struct interface_info {
- char device[10];
- int is_ptp, is_up;
- struct in_addr ip, netmask, broadcast, network;
- enum boot_proto_type boot_proto;
- char *user, *pass, *acname; /* for ADSL connection */
-};
-
-
-/* these are to be used only by dhcp.c */
-
-char * guess_netmask(char * ip_addr);
-
-int configure_net_device(struct interface_info * intf);
-
-extern char * hostname;
-extern char * domain;
-extern struct in_addr gateway;
-extern struct in_addr dns_server;
-extern struct in_addr dns_server2;
-
-
-
-#endif
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
deleted file mode 100644
index 4bedda82b..000000000
--- a/mdk-stage1/newt-frontend.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-
-/*
- * Each different frontend must implement all functions defined in frontend.h
- */
-
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/time.h>
-#include "newt/newt.h"
-
-#include <probing.h>
-
-#include "frontend.h"
-
-void init_frontend(char * welcome_msg)
-{
- int i;
- for (i=0; i<38; i++) printf("\n");
- newtInit();
- newtCls();
-
- newtDrawRootText(0, 0, welcome_msg);
-
- if (welcome_msg[0])
- newtPushHelpLine(" <Alt-F1> for here, <Alt-F3> to see the logs, <Alt-F4> for kernel msg");
-
- newtRefresh();
-}
-
-
-void finish_frontend(void)
-{
- newtFinished();
-}
-
-
-void verror_message(char *msg, va_list ap)
-{
- newtWinMessagev("Error", "Ok", msg, ap);
-}
-
-void vinfo_message(char *msg, va_list ap)
-{
- newtWinMessagev("Notice", "Ok", msg, ap);
-}
-
-
-void vwait_message(char *msg, va_list ap)
-{
- int width, height;
- char * title = "Please wait...";
- newtComponent c, f;
- newtGrid grid;
- char * buf = NULL;
- char * flowed;
- int size = 0;
- int i = 0;
-
- do {
- size += 1000;
- if (buf) free(buf);
- buf = malloc(size);
- i = vsnprintf(buf, size, msg, ap);
- } while (i >= size || i == -1);
-
- flowed = newtReflowText(buf, 60, 5, 5, &width, &height);
-
- c = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP);
- newtTextboxSetText(c, flowed);
-
- grid = newtCreateGrid(1, 1);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, c, 0, 0, 0, 0, 0, 0);
- newtGridWrappedWindow(grid, title);
-
- free(flowed);
- free(buf);
-
- f = newtForm(NULL, NULL, 0);
- newtFormAddComponent(f, c);
-
- newtDrawForm(f);
- newtRefresh();
- newtFormDestroy(f);
-}
-
-void remove_wait_message(void)
-{
- newtPopWindow();
-}
-
-
-static newtComponent form = NULL, scale = NULL;
-static int size_progress;
-static int actually_drawn;
-static char * msg_progress;
-
-void init_progression_raw(char *msg, int size)
-{
- size_progress = size;
- if (size) {
- actually_drawn = 0;
- newtCenteredWindow(70, 5, "Please wait...");
- form = newtForm(NULL, NULL, 0);
- newtFormAddComponent(form, newtLabel(1, 1, msg));
- scale = newtScale(1, 3, 68, size);
- newtFormAddComponent(form, scale);
- newtDrawForm(form);
- newtRefresh();
- }
- else {
- wait_message(msg);
- msg_progress = msg;
- }
-}
-
-void update_progression_raw(int current_size)
-{
- if (size_progress) {
- if (current_size <= size_progress)
- newtScaleSet(scale, current_size);
- newtRefresh();
- }
- else {
- struct timeval t;
- int time;
- static int last_time = -1;
- gettimeofday(&t, NULL);
- time = t.tv_sec*3 + t.tv_usec/300000;
- if (time != last_time) {
- char msg_prog_final[500];
- sprintf(msg_prog_final, "%s (%d bytes read) ", msg_progress, current_size);
- remove_wait_message();
- wait_message(msg_prog_final);
- }
- last_time = time;
- }
-}
-
-void end_progression_raw(void)
-{
- if (size_progress) {
- newtPopWindow();
- newtFormDestroy(form);
- }
- else
- remove_wait_message();
-}
-
-
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
-{
- char * items[500];
- int answer = 0, rc;
- char ** sav_elems = elems;
- int i;
-
- i = 0;
- while (elems && *elems) {
- int j = (*elems_comments) ? strlen(*elems_comments) : 0;
- items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
- strcpy(items[i], *elems);
- if (*elems_comments) {
- strcat(items[i], " (");
- strcat(items[i], *elems_comments);
- strcat(items[i], ")");
- }
- elems_comments++;
- i++;
- elems++;
- }
- items[i] = NULL;
-
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, items, &answer, "Ok", "Cancel", NULL);
-
- if (rc == 2)
- return RETURN_BACK;
-
- *choice = strdup(sav_elems[answer]);
-
- return RETURN_OK;
-}
-
-
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
-{
- int answer = 0, rc;
-
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL);
-
- if (rc == 2)
- return RETURN_BACK;
-
- *choice = strdup(elems[answer]);
-
- return RETURN_OK;
-}
-
-
-enum return_type ask_yes_no(char *msg)
-{
- int rc;
-
- rc = newtWinTernary("Please answer...", "Yes", "No", "Back", msg);
-
- if (rc == 1)
- return RETURN_OK;
- else if (rc == 3)
- return RETURN_BACK;
- else return RETURN_ERROR;
-}
-
-
-static void (*callback_real_function)(char ** strings) = NULL;
-
-static void default_callback(newtComponent co __attribute__ ((unused)), void * data)
-{
- newtComponent * entries = data;
- char * strings[50], ** ptr;
-
- if (!callback_real_function)
- return;
-
- ptr = strings;
- while (entries && *entries) {
- *ptr = newtEntryGetValue(*entries);
- entries++;
- ptr++;
- }
-
- callback_real_function(strings);
-
- ptr = strings;
- entries = data;
- while (entries && *entries) {
- newtEntrySet(*entries, strdup(*ptr), 1);
- entries++;
- ptr++;
- }
-}
-
-/* only supports up to 50 buttons and entries -- shucks! */
-static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
- int flexUp, int dataWidth, void (*callback_func)(char ** strings),
- struct newtWinEntry * items, char * button1, ...) {
- newtComponent buttons[50], result, form, textw;
- newtGrid grid, buttonBar, subgrid;
- int numItems;
- int rc, i;
- int numButtons;
- char * buttonName;
- newtComponent entries[50];
-
- va_list args;
-
- textw = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
- flexUp, 0);
-
- for (numItems = 0; items[numItems].text; numItems++);
-
- buttonName = button1, numButtons = 0;
- va_start(args, button1);
- while (buttonName) {
- buttons[numButtons] = newtButton(-1, -1, buttonName);
- numButtons++;
- buttonName = va_arg(args, char *);
- }
-
- va_end(args);
-
- buttonBar = newtCreateGrid(numButtons, 1);
- for (i = 0; i < numButtons; i++) {
- newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT,
- buttons[i],
- i ? 1 : 0, 0, 0, 0, 0, 0);
- }
-
- if (callback_func) {
- callback_real_function = callback_func;
- entries[numItems] = NULL;
- }
- else
- callback_real_function = NULL;
-
- subgrid = newtCreateGrid(2, numItems);
- for (i = 0; i < numItems; i++) {
- newtComponent entr = newtEntry(-1, -1, items[i].value ?
- *items[i].value : NULL, dataWidth,
- items[i].value, items[i].flags);
-
- newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,
- newtLabel(-1, -1, items[i].text),
- 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(subgrid, 1, i, NEWT_GRID_COMPONENT,
- entr,
- 1, 0, 0, 0, 0, 0);
- if (callback_func) {
- entries[i] = entr;
- newtComponentAddCallback(entr, default_callback, entries);
- }
- }
-
-
- grid = newtCreateGrid(1, 3);
- form = newtForm(NULL, 0, 0);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw,
- 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid,
- 0, 1, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar,
- 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
- newtGridAddComponentsToForm(grid, form, 1);
- newtGridWrappedWindow(grid, title);
- newtGridFree(grid, 1);
-
- result = newtRunForm(form);
-
- for (rc = 0; rc < numItems; rc++)
- *items[rc].value = strdup(*items[rc].value);
-
- for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
- if (rc == numButtons)
- rc = 0; /* F12 */
- else
- rc++;
-
- newtFormDestroy(form);
- newtPopWindow();
-
- return rc;
-}
-
-
-enum return_type ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size, void (*callback_func)(char ** strings))
-{
- struct newtWinEntry entries[50];
- int j, i = 0;
- int rc;
- char ** already_answers = NULL;
-
- while (questions && *questions) {
- entries[i].text = *questions;
- entries[i].flags = NEWT_FLAG_SCROLL | (!strcmp(*questions, "Password") ? NEWT_FLAG_PASSWORD : 0);
- i++;
- questions++;
- }
- entries[i].text = NULL;
- entries[i].value = NULL;
-
- if (*answers == NULL)
- *answers = (char **) malloc(sizeof(char *) * i);
- else
- already_answers = *answers;
-
- for (j = 0 ; j < i ; j++) {
- entries[j].value = &((*answers)[j]);
- if (already_answers && *already_answers) {
- *(entries[j].value) = *already_answers;
- already_answers++;
- } else
- *(entries[j].value) = NULL;
- }
-
- rc = mynewtWinEntries("Please fill in entries...", msg, 52, 5, 5, entry_size, callback_func, entries, "Ok", "Cancel", NULL);
-
- if (rc == 3)
- return RETURN_BACK;
- if (rc != 1)
- return RETURN_ERROR;
-
- return RETURN_OK;
-}
-
-
-void suspend_to_console(void) { newtSuspend(); }
-void resume_from_suspend(void) { newtResume(); }
diff --git a/mdk-stage1/newt/Makefile b/mdk-stage1/newt/Makefile
deleted file mode 100644
index fb6cdd5ff..000000000
--- a/mdk-stage1/newt/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-LIBNAME = libnewt
-
-OBJS = newt.o button.o form.o checkbox.o entry.o label.o listbox.o scrollbar.o textbox.o scale.o grid.o windows.o buttonbar.o checkboxtree.o
-
-DEFS = -DVERSION=\"0.50.19\"
-
-INCS = -I../slang
-
-
-TARGETS = $(LIBNAME).a
-
-all: $(TARGETS)
-
-clean:
- rm -f *.o *.a
-
-$(LIBNAME).a: $(OBJS)
- ar -cru $@ $^
- ranlib $@
-
-$(OBJS): %.o: %.c
- $(DIET) gcc $(CFLAGS) $(DEFS) $(INCS) $(INCLUDES) -c $< -o $@
diff --git a/mdk-stage1/newt/button.c b/mdk-stage1/newt/button.c
deleted file mode 100644
index d7da58175..000000000
--- a/mdk-stage1/newt/button.c
+++ /dev/null
@@ -1,192 +0,0 @@
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct button {
- char * text;
- int compact;
-};
-
-static void buttonDrawIt(newtComponent co, int active, int pushed);
-static void buttonDrawText(newtComponent co, int active, int pushed);
-
-static void buttonDraw(newtComponent c);
-static void buttonDestroy(newtComponent co);
-static struct eventResult buttonEvent(newtComponent c,
- struct event ev);
-static void buttonPlace(newtComponent co, int newLeft, int newTop);
-
-static struct componentOps buttonOps = {
- buttonDraw,
- buttonEvent,
- buttonDestroy,
- buttonPlace,
- newtDefaultMappedHandler,
-} ;
-
-static newtComponent createButton(int left, int row, const char * text, int compact) {
- newtComponent co;
- struct button * bu;
-
- co = malloc(sizeof(*co));
- bu = malloc(sizeof(struct button));
- co->data = bu;
-
- bu->text = strdup(text);
- bu->compact = compact;
- co->ops = &buttonOps;
-
- if (bu->compact) {
- co->height = 1;
- co->width = strlen(text) + 3;
- } else {
- co->height = 4;
- co->width = strlen(text) + 5;
- }
-
- co->top = row;
- co->left = left;
- co->takesFocus = 1;
- co->isMapped = 0;
-
- newtGotorc(co->top, co->left);
-
- return co;
-}
-
-newtComponent newtCompactButton(int left, int row, const char * text) {
- return createButton(left, row, text, 1);
-}
-
-newtComponent newtButton(int left, int row, const char * text) {
- return createButton(left, row, text, 0);
-}
-
-static void buttonDestroy(newtComponent co) {
- struct button * bu = co->data;
-
- free(bu->text);
- free(bu);
- free(co);
-}
-
-static void buttonPlace(newtComponent co, int newLeft, int newTop) {
- co->top = newTop;
- co->left = newLeft;
-
- newtGotorc(co->top, co->left);
-}
-
-static void buttonDraw(newtComponent co) {
- buttonDrawIt(co, 0, 0);
-}
-
-static void buttonDrawIt(newtComponent co, int active, int pushed) {
- struct button * bu = co->data;
-
- if (!co->isMapped) return;
-
- SLsmg_set_color(NEWT_COLORSET_BUTTON);
-
- if (bu->compact) {
- if (active)
- SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
- else
- SLsmg_set_color(NEWT_COLORSET_BUTTON);
- newtGotorc(co->top+ pushed, co->left + 1 + pushed);
- SLsmg_write_char('<');
- SLsmg_write_string(bu->text);
- SLsmg_write_char('>');
- } else {
- if (pushed) {
- SLsmg_set_color(NEWT_COLORSET_BUTTON);
- newtDrawBox(co->left + 1, co->top + 1, co->width - 1, 3, 0);
-
- SLsmg_set_color(NEWT_COLORSET_WINDOW);
- newtClearBox(co->left, co->top, co->width, 1);
- newtClearBox(co->left, co->top, 1, co->height);
- } else {
- newtDrawBox(co->left, co->top, co->width - 1, 3, 1);
- }
-
- buttonDrawText(co, active, pushed);
- }
-}
-
-static void buttonDrawText(newtComponent co, int active, int pushed) {
- struct button * bu = co->data;
-
- if (pushed) pushed = 1;
-
- if (active)
- SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
- else
- SLsmg_set_color(NEWT_COLORSET_BUTTON);
-
- newtGotorc(co->top + 1 + pushed, co->left + 1 + pushed);
- SLsmg_write_char(' ');
- SLsmg_write_string(bu->text);
- SLsmg_write_char(' ');
-}
-
-static struct eventResult buttonEvent(newtComponent co,
- struct event ev) {
- struct eventResult er;
- struct button * bu = co->data;
- er.result = ER_IGNORED;
- er.u.focus = NULL;
-
- if (ev.when == EV_NORMAL) {
- switch (ev.event) {
- case EV_FOCUS:
- buttonDrawIt(co, 1, 0);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_UNFOCUS:
- buttonDrawIt(co, 0, 0);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_KEYPRESS:
- if (ev.u.key == ' ' || ev.u.key == '\r') {
- if (!bu->compact) {
- /* look pushed */
- buttonDrawIt(co, 1, 1);
- newtRefresh();
- newtDelay(150000);
- buttonDrawIt(co, 1, 0);
- newtRefresh();
- newtDelay(150000);
- }
-
- er.result = ER_EXITFORM;
- } else
- er.result = ER_IGNORED;
- break;
- case EV_MOUSE:
- if (ev.u.mouse.type == MOUSE_BUTTON_DOWN &&
- co->top <= ev.u.mouse.y &&
- co->top + co->height - !bu->compact > ev.u.mouse.y &&
- co->left <= ev.u.mouse.x &&
- co->left + co->width - !bu->compact > ev.u.mouse.x) {
- if (!bu->compact) {
- buttonDrawIt(co, 1, 1);
- newtRefresh();
- newtDelay(150000);
- buttonDrawIt(co, 1, 0);
- newtRefresh();
- newtDelay(150000);
- }
- er.result = ER_EXITFORM;
- }
- break;
- }
- } else
- er.result = ER_IGNORED;
-
- return er;
-}
diff --git a/mdk-stage1/newt/buttonbar.c b/mdk-stage1/newt/buttonbar.c
deleted file mode 100644
index 45473c9d2..000000000
--- a/mdk-stage1/newt/buttonbar.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <stdarg.h>
-
-#include "newt.h"
-
-/* if they try and pack more then 50 buttons, screw 'em */
-newtGrid newtButtonBarv(char * button1, newtComponent * b1comp, va_list args) {
- newtGrid grid;
- struct buttonInfo {
- char * name;
- newtComponent * compPtr;
- } buttons[50];
- int num;
- int i;
-
- buttons[0].name = button1, buttons[0].compPtr = b1comp, num = 1;
- while (1) {
- buttons[num].name = va_arg(args, char *);
- if (!buttons[num].name) break;
- buttons[num].compPtr = va_arg(args, newtComponent *);
- num++;
- }
-
- grid = newtCreateGrid(num, 1);
-
- for (i = 0; i < num; i++) {
- *buttons[i].compPtr = newtButton(-1, -1, buttons[i].name);
- newtGridSetField(grid, i, 0, NEWT_GRID_COMPONENT,
- *buttons[i].compPtr,
- num ? 1 : 0, 0, 0, 0, 0, 0);
- }
-
- return grid;
-}
-
-newtGrid newtButtonBar(char * button1, newtComponent * b1comp, ...) {
- va_list args;
- newtGrid grid;
-
- va_start(args, b1comp);
-
- grid = newtButtonBarv(button1, b1comp, args);
-
- va_end(args);
-
- return grid;
-}
diff --git a/mdk-stage1/newt/checkbox.c b/mdk-stage1/newt/checkbox.c
deleted file mode 100644
index 643609d34..000000000
--- a/mdk-stage1/newt/checkbox.c
+++ /dev/null
@@ -1,292 +0,0 @@
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-enum type { CHECK, RADIO };
-
-struct checkbox {
- char * text;
- char * seq;
- char * result;
- newtComponent prevButton, lastButton;
- enum type type;
- char value;
- int active, inactive;
- const void * data;
- int flags;
- int hasFocus;
-};
-
-static void makeActive(newtComponent co);
-
-static void cbDraw(newtComponent c);
-static void cbDestroy(newtComponent co);
-struct eventResult cbEvent(newtComponent co, struct event ev);
-
-static struct componentOps cbOps = {
- cbDraw,
- cbEvent,
- cbDestroy,
- newtDefaultPlaceHandler,
- newtDefaultMappedHandler,
-} ;
-
-newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
- newtComponent prevButton) {
- newtComponent co;
- newtComponent curr;
- struct checkbox * rb;
- char initialValue;
-
- if (isDefault)
- initialValue = '*';
- else
- initialValue = ' ';
-
- co = newtCheckbox(left, top, text, initialValue, " *", NULL);
- rb = co->data;
- rb->type = RADIO;
-
- rb->prevButton = prevButton;
-
- for (curr = co; curr; curr = rb->prevButton) {
- rb = curr->data;
- rb->lastButton = co;
- }
-
- return co;
-}
-
-newtComponent newtRadioGetCurrent(newtComponent setMember) {
- struct checkbox * rb = setMember->data;
-
- setMember = rb->lastButton;
- rb = setMember->data;
-
- while (rb && rb->value != '*') {
- setMember = rb->prevButton;
- if (!setMember)
- return NULL;
- rb = setMember->data;
- }
-
- return setMember;
-}
-
-char newtCheckboxGetValue(newtComponent co) {
- struct checkbox * cb = co->data;
-
- return cb->value;
-}
-
-void newtCheckboxSetValue(newtComponent co, char value) {
- struct checkbox * cb = co->data;
-
- *cb->result = value;
- cbDraw(co);
-}
-
-newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
- const char * seq, char * result) {
- newtComponent co;
- struct checkbox * cb;
-
- if (!seq) seq = " *";
-
- co = malloc(sizeof(*co));
- cb = malloc(sizeof(struct checkbox));
- co->data = cb;
- cb->flags = 0;
- if (result)
- cb->result = result;
- else
- cb->result = &cb->value;
-
- cb->text = strdup(text);
- cb->seq = strdup(seq);
- cb->type = CHECK;
- cb->hasFocus = 0;
- cb->inactive = COLORSET_CHECKBOX;
- cb->active = COLORSET_ACTCHECKBOX;
- defValue ? (*cb->result = defValue) : (*cb->result = cb->seq[0]);
-
- co->ops = &cbOps;
-
- co->callback = NULL;
- co->height = 1;
- co->width = strlen(text) + 4;
- co->top = top;
- co->left = left;
- co->takesFocus = 1;
-
- return co;
-}
-
-void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
- struct checkbox * cb = co->data;
- int row, col;
-
- cb->flags = newtSetFlags(cb->flags, flags, sense);
-
- if (!(cb->flags & NEWT_FLAG_DISABLED))
- co->takesFocus = 1;
- else
- co->takesFocus = 0;
-
- newtGetrc(&row, &col);
- cbDraw(co);
- newtGotorc(row, col);
-}
-
-static void cbDraw(newtComponent c) {
- struct checkbox * cb = c->data;
-
- if (c->top == -1 || !c->isMapped) return;
-
- if (cb->flags & NEWT_FLAG_DISABLED) {
- cb->inactive = NEWT_COLORSET_DISENTRY;
- cb->active = NEWT_COLORSET_DISENTRY;
- } else {
- cb->inactive = COLORSET_CHECKBOX;
- cb->active = COLORSET_ACTCHECKBOX;
- }
-
- SLsmg_set_color(cb->inactive);
-
- newtGotorc(c->top, c->left);
-
- switch (cb->type) {
- case RADIO:
- SLsmg_write_string("( ) ");
- break;
-
- case CHECK:
- SLsmg_write_string("[ ] ");
- break;
-
- default:
- break;
- }
-
- SLsmg_write_string(cb->text);
-
- if (cb->hasFocus)
- SLsmg_set_color(cb->active);
-
- newtGotorc(c->top, c->left + 1);
- SLsmg_write_char(*cb->result);
-}
-
-static void cbDestroy(newtComponent co) {
- struct checkbox * cb = co->data;
-
- free(cb->text);
- free(cb->seq);
- free(cb);
- free(co);
-}
-
-struct eventResult cbEvent(newtComponent co, struct event ev) {
- struct checkbox * cb = co->data;
- struct eventResult er;
- const char * cur;
- er.result = ER_IGNORED;
- er.u.focus = NULL;
-
- if (ev.when == EV_NORMAL) {
- switch (ev.event) {
- case EV_FOCUS:
- cb->hasFocus = 1;
- cbDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_UNFOCUS:
- cb->hasFocus = 0;
- cbDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_KEYPRESS:
- if (ev.u.key == ' ') {
- if (cb->type == RADIO) {
- makeActive(co);
- } else if (cb->type == CHECK) {
- cur = strchr(cb->seq, *cb->result);
- if (!cur)
- *cb->result = *cb->seq;
- else {
- cur++;
- if (! *cur)
- *cb->result = *cb->seq;
- else
- *cb->result = *cur;
- }
- cbDraw(co);
- er.result = ER_SWALLOWED;
-
- if (co->callback)
- co->callback(co, co->callbackData);
- } else {
- er.result = ER_IGNORED;
- }
- } else if(ev.u.key == NEWT_KEY_ENTER) {
- er.result = ER_IGNORED;
- } else {
- er.result = ER_IGNORED;
- }
- break;
- case EV_MOUSE:
- if (ev.u.mouse.type == MOUSE_BUTTON_DOWN) {
- if (cb->type == RADIO) {
- makeActive(co);
- } else if (cb->type == CHECK) {
- cur = strchr(cb->seq, *cb->result);
- if (!cur)
- *cb->result = *cb->seq;
- else {
- cur++;
- if (! *cur)
- *cb->result = *cb->seq;
- else
- *cb->result = *cur;
- }
- cbDraw(co);
- er.result = ER_SWALLOWED;
-
- if (co->callback)
- co->callback(co, co->callbackData);
- }
- }
- }
- } else
- er.result = ER_IGNORED;
-
- return er;
-}
-
-static void makeActive(newtComponent co) {
- struct checkbox * cb = co->data;
- struct checkbox * rb;
- newtComponent curr;
-
- /* find the one that's turned off */
- curr = cb->lastButton;
- rb = curr->data;
- while (curr && rb->value == rb->seq[0]) {
- curr = rb->prevButton;
- if (curr) rb = curr->data;
- }
- if (curr) {
- rb->value = rb->seq[0];
- cbDraw(curr);
- }
- cb->value = cb->seq[1];
- cbDraw(co);
-
- if (co->callback)
- co->callback(co, co->callbackData);
-}
diff --git a/mdk-stage1/newt/checkboxtree.c b/mdk-stage1/newt/checkboxtree.c
deleted file mode 100644
index 00113f23e..000000000
--- a/mdk-stage1/newt/checkboxtree.c
+++ /dev/null
@@ -1,714 +0,0 @@
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct items {
- char * text;
- const void *data;
- unsigned char selected;
- struct items *next;
- struct items *prev;
- struct items *branch;
- int flags;
- int depth;
-};
-
-struct CheckboxTree {
- newtComponent sb;
- int curWidth; /* size of text w/o scrollbar or border*/
- int curHeight; /* size of text w/o border */
- struct items * itemlist;
- struct items ** flatList, ** currItem, ** firstItem;
- int flatCount;
- int flags;
- int pad;
- char * seq;
- char * result;
-};
-
-static void ctDraw(newtComponent c);
-static void ctDestroy(newtComponent co);
-static void ctPlace(newtComponent co, int newLeft, int newTop);
-struct eventResult ctEvent(newtComponent co, struct event ev);
-static void ctMapped(newtComponent co, int isMapped);
-static struct items * findItem(struct items * items, const void * data);
-static void buildFlatList(newtComponent co);
-static void doBuildFlatList(struct CheckboxTree * ct, struct items * item);
-enum countWhat { COUNT_EXPOSED=0, COUNT_SELECTED=1 };
-static int countItems(struct items * item, enum countWhat justExposed);
-
-static struct componentOps ctOps = {
- ctDraw,
- ctEvent,
- ctDestroy,
- ctPlace,
- ctMapped,
-} ;
-
-static int countItems(struct items * item, enum countWhat what) {
- int count = 0;
-
- while (item) {
- if ((!item->branch && item->selected == what) || (what == COUNT_EXPOSED))
- count++;
- if (item->branch || (what == COUNT_EXPOSED && item->selected))
- count += countItems(item->branch, what);
- item = item->next;
- }
-
- return count;
-}
-
-static void doBuildFlatList(struct CheckboxTree * ct, struct items * item) {
- while (item) {
- ct->flatList[ct->flatCount++] = item;
- if (item->branch && item->selected) doBuildFlatList(ct, item->branch);
- item = item->next;
- }
-}
-
-static void buildFlatList(newtComponent co) {
- struct CheckboxTree * ct = co->data;
-
- if (ct->flatList) free(ct->flatList);
- ct->flatCount = countItems(ct->itemlist, COUNT_EXPOSED);
-
- ct->flatList = malloc(sizeof(*ct->flatList) * (ct->flatCount+1));
- ct->flatCount = 0;
- doBuildFlatList(ct, ct->itemlist);
- ct->flatList[ct->flatCount] = NULL;
-}
-
-int newtCheckboxTreeAddItem(newtComponent co,
- const char * text, const void * data,
- int flags, int index, ...) {
- va_list argList;
- int numIndexes;
- int * indexes;
- int i;
-
- va_start(argList, index);
- numIndexes = 0;
- i = index;
- while (i != NEWT_ARG_LAST) {
- numIndexes++;
- i = va_arg(argList, int);
- }
-
- va_end(argList);
-
- indexes = alloca(sizeof(*indexes) * (numIndexes + 1));
- va_start(argList, index);
- numIndexes = 0;
- i = index;
- va_start(argList, index);
- while (i != NEWT_ARG_LAST) {
- indexes[numIndexes++] = i;
- i = va_arg(argList, int);
- }
- va_end(argList);
-
- indexes[numIndexes++] = NEWT_ARG_LAST;
-
- return newtCheckboxTreeAddArray(co, text, data, flags, indexes);
-}
-
-static int doFindItemPath(struct items * items, void * data, int * path,
- int * len) {
- int where = 0;
-
- while (items) {
- if (items->data == data) {
- if (path) path[items->depth] = where;
- if (len) *len = items->depth + 1;
- return 1;
- }
-
- if (items->branch && doFindItemPath(items->branch, data, path, len)) {
- if (path) path[items->depth] = where;
- return 1;
- }
-
- items = items->next;
- where++;
- }
-
- return 0;
-}
-
-int * newtCheckboxTreeFindItem(newtComponent co, void * data) {
- int len;
- int * path;
- struct CheckboxTree * ct = co->data;
-
- if (!doFindItemPath(ct->itemlist, data, NULL, &len)) return NULL;
-
- path = malloc(sizeof(*path) * (len + 1));
- doFindItemPath(ct->itemlist, data, path, NULL);
- path[len] = NEWT_ARG_LAST;
-
- return path;
-}
-
-int newtCheckboxTreeAddArray(newtComponent co,
- const char * text, const void * data,
- int flags, int * indexes) {
- struct items * curList, * newNode, * item = NULL;
- struct items ** listPtr = NULL;
- int i, index, numIndexes;
- struct CheckboxTree * ct = co->data;
-
- numIndexes = 0;
- while (indexes[numIndexes] != NEWT_ARG_LAST) numIndexes++;
-
- if (!ct->itemlist) {
- if (numIndexes > 1) return -1;
-
- ct->itemlist = malloc(sizeof(*ct->itemlist));
- item = ct->itemlist;
- item->prev = NULL;
- item->next = NULL;
- } else {
- curList = ct->itemlist;
- listPtr = &ct->itemlist;
-
- i = 0;
- index = indexes[i];
- while (i < numIndexes) {
- item = curList;
-
- if (index == NEWT_ARG_APPEND) {
- item = NULL;
- } else {
- while (index && item)
- item = item->next, index--;
- }
-
- i++;
- if (i < numIndexes) {
- curList = item->branch;
- listPtr = &item->branch;
- if (!curList && (i + 1 != numIndexes)) return -1;
-
- index = indexes[i];
- }
- }
-
- if (!curList) { /* create a new branch */
- item = malloc(sizeof(*curList->prev));
- item->next = item->prev = NULL;
- *listPtr = item;
- } else if (!item) { /* append to end */
- item = curList;
- while (item->next) item = item->next;
- item->next = malloc(sizeof(*curList->prev));
- item->next->prev = item;
- item = item->next;
- item->next = NULL;
- } else {
- newNode = malloc(sizeof(*newNode));
- newNode->prev = item->prev;
- newNode->next = item;
-
- if (item->prev) item->prev->next = newNode;
- item->prev = newNode;
- item = newNode;
- if (!item->prev) *listPtr = item;
- }
- }
-
- item->text = strdup(text);
- item->data = data;
- if (flags & NEWT_FLAG_SELECTED) {
- item->selected = 1;
- } else {
- item->selected = 0;
- }
- item->flags = flags;
- item->branch = NULL;
- item->depth = numIndexes - 1;
-
- i = 4 + (3 * item->depth);
-
- if ((strlen(text) + i + ct->pad) > (size_t)co->width) {
- co->width = strlen(text) + i + ct->pad;
- }
-
- return 0;
-}
-
-static struct items * findItem(struct items * items, const void * data) {
- struct items * i;
-
- while (items) {
- if (items->data == data) return items;
- if (items->branch) {
- i = findItem(items->branch, data);
- if (i) return i;
- }
-
- items = items->next;
- }
-
- return NULL;
-}
-
-static void listSelected(struct items * items, int * num, const void ** list, int seqindex) {
- while (items) {
- if ((seqindex ? items->selected==seqindex : items->selected) && !items->branch)
- list[(*num)++] = (void *) items->data;
- if (items->branch)
- listSelected(items->branch, num, list, seqindex);
- items = items->next;
- }
-}
-
-const void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems)
-{
- return newtCheckboxTreeGetMultiSelection(co, numitems, 0);
-}
-
-const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum)
-{
- struct CheckboxTree * ct;
- const void **retval;
- int seqindex=0;
-
- if(!co || !numitems) return NULL;
-
- ct = co->data;
-
- if (seqnum) {
- while( ct->seq[seqindex] && ( ct->seq[seqindex] != seqnum )) seqindex++;
- } else {
- seqindex = 0;
- }
-
- *numitems = countItems(ct->itemlist, (seqindex ? seqindex : COUNT_SELECTED));
- if (!*numitems) return NULL;
-
- retval = malloc(*numitems * sizeof(void *));
- *numitems = 0;
- listSelected(ct->itemlist, numitems, retval, seqindex);
-
- return retval;
-}
-
-newtComponent newtCheckboxTree(int left, int top, int height, int flags) {
- return newtCheckboxTreeMulti(left, top, height, NULL, flags);
-}
-
-newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, int flags) {
- newtComponent co;
- struct CheckboxTree * ct;
-
- co = malloc(sizeof(*co));
- ct = malloc(sizeof(struct CheckboxTree));
- co->callback = NULL;
- co->data = ct;
- co->ops = &ctOps;
- co->takesFocus = 1;
- co->height = height;
- co->width = 0;
- co->isMapped = 0;
- ct->itemlist = NULL;
- ct->firstItem = NULL;
- ct->currItem = NULL;
- ct->flatList = NULL;
- if (seq)
- ct->seq = strdup(seq);
- else
- ct->seq = strdup(" *");
- if (flags & NEWT_FLAG_SCROLL) {
- ct->sb = newtVerticalScrollbar(left, top, height,
- COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
- ct->pad = 2;
- } else {
- ct->sb = NULL;
- ct->pad = 0;
- }
-
- return co;
-}
-
-static void ctMapped(newtComponent co, int isMapped) {
- struct CheckboxTree * ct = co->data;
-
- co->isMapped = isMapped;
- if (ct->sb)
- ct->sb->ops->mapped(ct->sb, isMapped);
-}
-
-static void ctPlace(newtComponent co, int newLeft, int newTop) {
- struct CheckboxTree * ct = co->data;
-
- co->top = newTop;
- co->left = newLeft;
-
- if (ct->sb)
- ct->sb->ops->place(ct->sb, co->left + co->width - 1, co->top);
-}
-
-int ctSetItem(newtComponent co, struct items *item, enum newtFlagsSense sense)
-{
- struct CheckboxTree * ct = co->data;
- struct items * currItem;
- struct items * firstItem;
-
- if (!item)
- return 1;
-
- switch(sense) {
- case NEWT_FLAGS_RESET:
- item->selected = 0;
- break;
- case NEWT_FLAGS_SET:
- item->selected = 1;
- break;
- case NEWT_FLAGS_TOGGLE:
- if (item->branch)
- item->selected = !item->selected;
- else {
- item->selected++;
- if (item->selected==strlen(ct->seq))
- item->selected = 0;
- }
- break;
- }
-
- if (item->branch) {
- currItem = *ct->currItem;
- firstItem = *ct->firstItem;
-
- buildFlatList(co);
-
- ct->currItem = ct->flatList;
- while (*ct->currItem != currItem) ct->currItem++;
-
- ct->firstItem = ct->flatList;
- if (ct->flatCount > co->height) {
- struct items ** last = ct->flatList + ct->flatCount - co->height;
- while (*ct->firstItem != firstItem && ct->firstItem != last)
- ct->firstItem++;
- }
- }
-
- return 0;
-}
-
-static void ctSetItems(struct items *item, int selected)
-{
- for (; item; item = item->next) {
- if (!item->branch)
- item->selected = selected;
- else
- ctSetItems(item->branch, selected);
- }
-}
-
-static void ctDraw(newtComponent co) {
- struct CheckboxTree * ct = co->data;
- struct items ** item;
- int i, j;
- char * spaces = NULL;
- int currRow = -1;
-
- if (!co->isMapped) return ;
-
- if (!ct->firstItem) {
- buildFlatList(co);
- ct->firstItem = ct->currItem = ct->flatList;
- }
-
- item = ct->firstItem;
-
- i = 0;
- while (*item && i < co->height) {
- newtGotorc(co->top + i, co->left);
- if (*item == *ct->currItem) {
- SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
- currRow = co->top + i;
- } else
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
- for (j = 0; j < (*item)->depth; j++)
- SLsmg_write_string(" ");
-
- if ((*item)->branch) {
- if ((*item)->selected)
- SLsmg_write_string("<-> ");
- else
- SLsmg_write_string("<+> ");
- } else {
- char tmp[5];
- snprintf(tmp,5,"[%c] ",ct->seq[(*item)->selected]);
- SLsmg_write_string(tmp);
- }
-
- SLsmg_write_nstring((*item)->text, co->width - 4 -
- (3 * (*item)->depth));
- item++;
- i++;
- }
-
- /* There could be empty lines left (i.e. if the user closes an expanded
- list which is the last thing in the tree, and whose elements are
- displayed at the bottom of the screen */
- if (i < co->height) {
- spaces = alloca(co->width);
- memset(spaces, ' ', co->width);
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
- }
- while (i < co->height) {
- newtGotorc(co->top + i, co->left);
- SLsmg_write_nstring(spaces, co->width);
- i++;
- }
-
- if(ct->sb) {
- newtScrollbarSet(ct->sb, ct->currItem - ct->flatList,
- ct->flatCount - 1);
- ct->sb->ops->draw(ct->sb);
- }
-
- newtGotorc(currRow, co->left + 1);
-}
-
-static void ctDestroy(newtComponent co) {
- struct CheckboxTree * ct = co->data;
- struct items * item, * nextitem;
-
- nextitem = item = ct->itemlist;
-
- while (item != NULL) {
- nextitem = item->next;
- free(item->text);
- free(item);
- item = nextitem;
- }
-
- free(ct->seq);
- free(ct);
- free(co);
-}
-
-struct eventResult ctEvent(newtComponent co, struct event ev) {
- struct CheckboxTree * ct = co->data;
- struct eventResult er;
- struct items ** listEnd, ** lastItem;
- int key, selnum = 1;
-
- er.result = ER_IGNORED;
-
- if(ev.when == EV_EARLY || ev.when == EV_LATE) {
- return er;
- }
-
- switch(ev.event) {
- case EV_KEYPRESS:
- key = ev.u.key;
- if (key == (char) key && key != ' ') {
- for (selnum = 0; ct->seq[selnum]; selnum++)
- if (key == ct->seq[selnum])
- break;
- if (!ct->seq[selnum])
- switch (key) {
- case '-': selnum = 0; break;
- case '+':
- case '*': selnum = 1; break;
- }
- if (ct->seq[selnum])
- key = '*';
- }
- switch(key) {
- case ' ':
- case NEWT_KEY_ENTER:
- ctSetItem(co, *ct->currItem, NEWT_FLAGS_TOGGLE);
- er.result = ER_SWALLOWED;
- if (!(*ct->currItem)->branch || (*ct->currItem)->selected)
- key = NEWT_KEY_DOWN;
- else
- key = '*';
- break;
- case '*':
- if ((*ct->currItem)->branch) {
- ctSetItems((*ct->currItem)->branch, selnum);
- if (!(*ct->currItem)->selected)
- key = NEWT_KEY_DOWN;
- } else {
- (*ct->currItem)->selected = selnum;
- key = NEWT_KEY_DOWN;
- }
- er.result = ER_SWALLOWED;
- break;
- }
- switch (key) {
- case '*':
- ctDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- return er;
- case NEWT_KEY_HOME:
- ct->currItem = ct->flatList;
- ct->firstItem = ct->flatList;
- ctDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- return er;
- case NEWT_KEY_END:
- ct->currItem = ct->flatList + ct->flatCount - 1;
- if (ct->flatCount <= co->height)
- ct->firstItem = ct->flatList;
- else
- ct->firstItem = ct->flatList + ct->flatCount - co->height;
- ctDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- return er;
- case NEWT_KEY_DOWN:
- if (ev.u.key != NEWT_KEY_DOWN) {
- if(co->callback) co->callback(co, co->callbackData);
- if (strlen(ct->seq) != 2) {
- ctDraw(co);
- return er;
- }
- }
- if ((ct->currItem - ct->flatList + 1) < ct->flatCount) {
- ct->currItem++;
-
- if (ct->currItem - ct->firstItem >= co->height)
- ct->firstItem++;
-
- ctDraw(co);
- } else if (ev.u.key != NEWT_KEY_DOWN)
- ctDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- return er;
- case NEWT_KEY_UP:
- if (ct->currItem != ct->flatList) {
- ct->currItem--;
-
- if (ct->currItem < ct->firstItem)
- ct->firstItem = ct->currItem;
-
- ctDraw(co);
- }
- er.result = ER_SWALLOWED;
- if(co->callback) co->callback(co, co->callbackData);
- return er;
- case NEWT_KEY_PGUP:
- if (ct->firstItem - co->height < ct->flatList) {
- ct->firstItem = ct->currItem = ct->flatList;
- } else {
- ct->currItem -= co->height;
- ct->firstItem -= co->height;
- }
-
- ctDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- return er;
- case NEWT_KEY_PGDN:
- listEnd = ct->flatList + ct->flatCount - 1;
- lastItem = ct->firstItem + co->height - 1;
-
- if (lastItem + co->height > listEnd) {
- ct->firstItem = listEnd - co->height + 1;
- ct->currItem = listEnd;
- } else {
- ct->currItem += co->height;
- ct->firstItem += co->height;
- }
-
- ctDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- return er;
- }
- break;
-
- case EV_FOCUS:
- ctDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_UNFOCUS:
- ctDraw(co);
- er.result = ER_SWALLOWED;
- break;
- default:
- break;
- }
-
- return er;
-}
-
-const void * newtCheckboxTreeGetCurrent(newtComponent co) {
- struct CheckboxTree * ct = co->data;
-
- if (!ct->currItem) return NULL;
- return (*ct->currItem)->data;
-}
-
-void newtCheckboxTreeSetEntry(newtComponent co, const void * data, const char * text)
-{
- struct CheckboxTree * ct;
- struct items * item;
- int i;
-
- if (!co) return;
- ct = co->data;
- item = findItem(ct->itemlist, data);
- if (!item) return;
-
- free(item->text);
- item->text = strdup(text);
-
- i = 4 + (3 * item->depth);
-
- if ((strlen(text) + i + ct->pad) > (size_t)co->width) {
- co->width = strlen(text) + i + ct->pad;
- }
-
- ctDraw(co);
-}
-
-char newtCheckboxTreeGetEntryValue(newtComponent co, const void * data)
-{
- struct CheckboxTree * ct;
- struct items * item;
-
- if (!co) return -1;
- ct = co->data;
- item = findItem(ct->itemlist, data);
- if (!item) return -1;
- if (item->branch)
- return item->selected ? NEWT_CHECKBOXTREE_EXPANDED : NEWT_CHECKBOXTREE_COLLAPSED;
- else
- return ct->seq[item->selected];
-}
-
-void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data, char value)
-{
- struct CheckboxTree * ct;
- struct items * item;
- int i;
-
- if (!co) return;
- ct = co->data;
- item = findItem(ct->itemlist, data);
- if (!item || item->branch) return;
-
- for(i = 0; ct->seq[i]; i++)
- if (value == ct->seq[i])
- break;
-
- if (!ct->seq[i]) return;
- item->selected = i;
-
- ctDraw(co);
-}
-
diff --git a/mdk-stage1/newt/entry.c b/mdk-stage1/newt/entry.c
deleted file mode 100644
index 0ee449cf9..000000000
--- a/mdk-stage1/newt/entry.c
+++ /dev/null
@@ -1,378 +0,0 @@
-#include <ctype.h>
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct entry {
- int flags;
- char * buf;
- char ** resultPtr;
- int bufAlloced;
- int bufUsed; /* amount of the buffer that's been used */
- int cursorPosition; /* cursor *in the string* on on screen */
- int firstChar; /* first character position being shown */
- newtEntryFilter filter;
- void * filterData;
-};
-
-static void entryDraw(newtComponent co);
-static void entryDestroy(newtComponent co);
-static struct eventResult entryEvent(newtComponent co,
- struct event ev);
-
-static struct eventResult entryHandleKey(newtComponent co, int key);
-
-static struct componentOps entryOps = {
- entryDraw,
- entryEvent,
- entryDestroy,
- newtDefaultPlaceHandler,
- newtDefaultMappedHandler,
-} ;
-
-void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd) {
- struct entry * en = co->data;
-
- if ((strlen(value) + 1) > (unsigned int)en->bufAlloced) {
- free(en->buf);
- en->bufAlloced = strlen(value) + 1;
- en->buf = malloc(en->bufAlloced);
- if (en->resultPtr) *en->resultPtr = en->buf;
- }
- memset(en->buf, 0, en->bufAlloced); /* clear the buffer */
- strcpy(en->buf, value);
- en->bufUsed = strlen(value);
- en->firstChar = 0;
- if (cursorAtEnd)
- en->cursorPosition = en->bufUsed;
- else
- en->cursorPosition = 0;
-
- entryDraw(co);
-} ;
-
-newtComponent newtEntry(int left, int top, const char * initialValue, int width,
- char ** resultPtr, int flags) {
- newtComponent co;
- struct entry * en;
-
- co = malloc(sizeof(*co));
- en = malloc(sizeof(struct entry));
- co->data = en;
-
- co->top = top;
- co->left = left;
- co->height = 1;
- co->width = width;
- co->isMapped = 0;
- co->callback = NULL;
-
- co->ops = &entryOps;
-
- en->flags = flags;
- en->cursorPosition = 0;
- en->firstChar = 0;
- en->bufUsed = 0;
- en->bufAlloced = width + 1;
- en->filter = NULL;
-
- if (!(en->flags & NEWT_FLAG_DISABLED))
- co->takesFocus = 1;
- else
- co->takesFocus = 0;
-
- if (initialValue && strlen(initialValue) > (unsigned int)width) {
- en->bufAlloced = strlen(initialValue) + 1;
- }
- en->buf = malloc(en->bufAlloced);
- en->resultPtr = resultPtr;
- if (en->resultPtr) *en->resultPtr = en->buf;
-
- memset(en->buf, 0, en->bufAlloced);
- if (initialValue) {
- strcpy(en->buf, initialValue);
- en->bufUsed = strlen(initialValue);
- en->cursorPosition = en->bufUsed;
- } else {
- *en->buf = '\0';
- en->bufUsed = 0;
- en->cursorPosition = 0;
- }
-
- return co;
-}
-
-static void entryDraw(newtComponent co) {
- struct entry * en = co->data;
- int i;
- char * chptr;
- int len;
-
- if (!co->isMapped) return;
-
- if (en->flags & NEWT_FLAG_DISABLED)
- SLsmg_set_color(NEWT_COLORSET_DISENTRY);
- else
- SLsmg_set_color(NEWT_COLORSET_ENTRY);
-
- if (en->flags & NEWT_FLAG_HIDDEN) {
- newtGotorc(co->top, co->left);
- for (i = 0; i < co->width; i++)
- SLsmg_write_char('_');
- newtGotorc(co->top, co->left);
-
- return;
- }
-
- newtGotorc(co->top, co->left);
-
- if (en->cursorPosition < en->firstChar) {
- /* scroll to the left */
- en->firstChar = en->cursorPosition;
- } else if ((en->firstChar + co->width) <= en->cursorPosition) {
- /* scroll to the right */
- en->firstChar = en->cursorPosition - co->width + 1;
- }
-
- chptr = en->buf + en->firstChar;
-
- if (en->flags & NEWT_FLAG_PASSWORD) {
- char *tmpptr, *p;
-
- tmpptr = alloca(strlen(chptr+2));
- strcpy(tmpptr, chptr);
- for (p = tmpptr; *p; p++)
- *p = '*';
- chptr = tmpptr;
- }
-
- len = strlen(chptr);
-
- if (len <= co->width) {
- i = len;
- SLsmg_write_string(chptr);
- while (i < co->width) {
- SLsmg_write_char('_');
- i++;
- }
- } else {
- SLsmg_write_nstring(chptr, co->width);
- }
-
- if (en->flags & NEWT_FLAG_HIDDEN)
- newtGotorc(co->top, co->left);
- else
- newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar));
-}
-
-void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
- struct entry * en = co->data;
- int row, col;
-
- en->flags = newtSetFlags(en->flags, flags, sense);
-
- if (!(en->flags & NEWT_FLAG_DISABLED))
- co->takesFocus = 1;
- else
- co->takesFocus = 0;
-
- newtGetrc(&row, &col);
- entryDraw(co);
- newtGotorc(row, col);
-}
-
-static void entryDestroy(newtComponent co) {
- struct entry * en = co->data;
-
- free(en->buf);
- free(en);
- free(co);
-}
-
-static struct eventResult entryEvent(newtComponent co,
- struct event ev) {
- struct entry * en = co->data;
- struct eventResult er;
- int ch;
- er.result = ER_IGNORED;
- er.u.focus = NULL;
-
- if (ev.when == EV_NORMAL) {
- switch (ev.event) {
- case EV_FOCUS:
- newtCursorOn();
- if (en->flags & NEWT_FLAG_HIDDEN)
- newtGotorc(co->top, co->left);
- else
- newtGotorc(co->top, co->left +
- (en->cursorPosition - en->firstChar));
- er.result = ER_SWALLOWED;
- break;
-
- case EV_UNFOCUS:
- newtCursorOff();
- newtGotorc(0, 0);
- er.result = ER_SWALLOWED;
- if (co->callback)
- co->callback(co, co->callbackData);
- break;
-
- case EV_KEYPRESS:
- ch = ev.u.key;
- if (en->filter)
- ch = en->filter(co, en->filterData, ch, en->cursorPosition);
- if (ch) er = entryHandleKey(co, ch);
- break;
-
- case EV_MOUSE:
- if ((ev.u.mouse.type == MOUSE_BUTTON_DOWN) &&
- (en->flags ^ NEWT_FLAG_HIDDEN)) {
- if (strlen(en->buf) >= (size_t) (ev.u.mouse.x - co->left)) {
- en->cursorPosition = ev.u.mouse.x - co->left;
- newtGotorc(co->top,
- co->left +(en->cursorPosition - en->firstChar));
- } else {
- en->cursorPosition = strlen(en->buf);
- newtGotorc(co->top,
- co->left +(en->cursorPosition - en->firstChar));
- }
- }
- break;
- }
- } else
- er.result = ER_IGNORED;
-
- return er;
-}
-
-static struct eventResult entryHandleKey(newtComponent co, int key) {
- struct entry * en = co->data;
- struct eventResult er;
- char * chptr, * insPoint;
-
- er.result = ER_SWALLOWED;
- switch (key) {
- case '\r': /* Return */
- if (en->flags & NEWT_FLAG_RETURNEXIT) {
- er.result = ER_EXITFORM;
- } else {
- er.result = ER_NEXTCOMP;
- }
- break;
-
- case '\001': /* ^A */
- case NEWT_KEY_HOME:
- en->cursorPosition = 0;
- break;
-
- case '\005': /* ^E */
- case NEWT_KEY_END:
- en->cursorPosition = en->bufUsed;
- break;
-
- case '\013': /* ^K */
- en->bufUsed = en->cursorPosition;
- memset(en->buf + en->bufUsed, 0, en->bufAlloced - en->bufUsed);
- break;
-
- case '\002': /* ^B */
- case NEWT_KEY_LEFT:
- if (en->cursorPosition)
- en->cursorPosition--;
- break;
-
- case '\004':
- case NEWT_KEY_DELETE:
- chptr = en->buf + en->cursorPosition;
- if (*chptr) {
- chptr++;
- while (*chptr) {
- *(chptr - 1) = *chptr;
- chptr++;
- }
- *(chptr - 1) = '\0';
- en->bufUsed--;
- }
- break;
-
- case NEWT_KEY_BKSPC:
- if (en->cursorPosition) {
- /* if this isn't true, there's nothing to erase */
- chptr = en->buf + en->cursorPosition;
- en->bufUsed--;
- en->cursorPosition--;
- while (*chptr) {
- *(chptr - 1) = *chptr;
- chptr++;
- }
- *(chptr - 1) = '\0';
- }
- break;
-
- case '\006': /* ^B */
- case NEWT_KEY_RIGHT:
- if (en->cursorPosition < en->bufUsed)
- en->cursorPosition++;
- break;
-
- default:
- if ((key >= 0x20 && key <= 0x7e) || (key >= 0xa0 && key <= 0xff)) {
- if (!(en->flags & NEWT_FLAG_SCROLL) && en->bufUsed >= co->width) {
- SLtt_beep();
- break;
- }
-
- if ((en->bufUsed + 1) == en->bufAlloced) {
- en->bufAlloced += 20;
- en->buf = realloc(en->buf, en->bufAlloced);
- if (en->resultPtr) *en->resultPtr = en->buf;
- memset(en->buf + en->bufUsed + 1, 0, 20);
- }
-
- if (en->cursorPosition == en->bufUsed) {
- en->bufUsed++;
- } else {
- /* insert the new character */
-
- /* chptr is the last character in the string */
- chptr = (en->buf + en->bufUsed) - 1;
- if ((en->bufUsed + 1) == en->bufAlloced) {
- /* this string fills the buffer, so clip it */
- chptr--;
- } else
- en->bufUsed++;
-
- insPoint = en->buf + en->cursorPosition;
-
- while (chptr >= insPoint) {
- *(chptr + 1) = *chptr;
- chptr--;
- }
-
- }
-
- en->buf[en->cursorPosition++] = key;
- } else {
- er.result = ER_IGNORED;
- }
- }
-
- entryDraw(co);
-
- return er;
-}
-
-char * newtEntryGetValue(newtComponent co) {
- struct entry * en = co->data;
-
- return en->buf;
-}
-
-void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data) {
- struct entry * en = co->data;
- en->filter = filter;
- en->filterData = data;
-}
diff --git a/mdk-stage1/newt/form.c b/mdk-stage1/newt/form.c
deleted file mode 100644
index ad7520e95..000000000
--- a/mdk-stage1/newt/form.c
+++ /dev/null
@@ -1,713 +0,0 @@
-#include <unistd.h>
-#include <slang.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-
-/****************************************************************************
- These forms handle vertical scrolling of components with a height of 1
-
- Horizontal scrolling won't work, and scrolling large widgets will fail
- miserably. It shouldn't be too hard to fix either of those if anyone
- cares to. I only use scrolling for listboxes and text boxes though so
- I didn't bother.
-*****************************************************************************/
-
-struct element {
- int top, left; /* Actual, not virtual. These are translated */
- newtComponent co; /* into actual through vertOffset */
-};
-
-struct fdInfo {
- int fd;
- int flags;
-};
-
-struct form {
- int numCompsAlloced;
- struct element * elements;
- int numComps;
- int currComp;
- int fixedHeight;
- int flags;
- int vertOffset;
- newtComponent vertBar, exitComp;
- const char * help;
- int numRows;
- int * hotKeys;
- int numHotKeys;
- int background;
- int beenSet;
- int numFds;
- struct fdInfo * fds;
- int maxFd;
- int timer; /* in milliseconds */
- struct timeval lastTimeout;
- void * helpTag;
- newtCallback helpCb;
-};
-
-static void gotoComponent(struct form * form, int newComp);
-static struct eventResult formEvent(newtComponent co, struct event ev);
-static struct eventResult sendEvent(newtComponent comp, struct event ev);
-static void formPlace(newtComponent co, int left, int top);
-
-/* Global, ick */
-static newtCallback helpCallback;
-
-/* this isn't static as grid.c tests against it to find forms */
-struct componentOps formOps = {
- newtDrawForm,
- formEvent,
- newtFormDestroy,
- formPlace,
- newtDefaultMappedHandler,
-} ;
-
-static inline int componentFits(newtComponent co, int compNum) {
- struct form * form = co->data;
- struct element * el = form->elements + compNum;
-
- if ((co->top + form->vertOffset) > el->top) return 0;
- if ((co->top + form->vertOffset + co->height) <
- (el->top + el->co->height)) return 0;
-
- return 1;
-}
-
-newtComponent newtForm(newtComponent vertBar, void * help, int flags) {
- newtComponent co;
- struct form * form;
-
- co = malloc(sizeof(*co));
- form = malloc(sizeof(*form));
- co->data = form;
- co->width = 0;
- co->height = 0;
- co->top = -1;
- co->left = -1;
- co->isMapped = 0;
-
- co->takesFocus = 0; /* we may have 0 components */
- co->ops = &formOps;
-
- form->help = help;
- form->flags = flags;
- form->numCompsAlloced = 5;
- form->numComps = 0;
- form->currComp = -1;
- form->vertOffset = 0;
- form->fixedHeight = 0;
- form->numRows = 0;
- form->numFds = 0;
- form->maxFd = 0;
- form->fds = NULL;
- form->beenSet = 0;
- form->elements = malloc(sizeof(*(form->elements)) * form->numCompsAlloced);
-
- form->background = COLORSET_WINDOW;
- form->hotKeys = malloc(sizeof(int));
- form->numHotKeys = 0;
- form->timer = 0;
- form->lastTimeout.tv_sec = form->lastTimeout.tv_usec = 0;
- if (!(form->flags & NEWT_FLAG_NOF12)) {
- newtFormAddHotKey(co, NEWT_KEY_F12);
- }
-
- if (vertBar)
- form->vertBar = vertBar;
- else
- form->vertBar = NULL;
-
- form->helpTag = help;
- form->helpCb = helpCallback;
-
- return co;
-}
-
-newtComponent newtFormGetCurrent(newtComponent co) {
- struct form * form = co->data;
-
- return form->elements[form->currComp].co;
-}
-
-void newtFormSetCurrent(newtComponent co, newtComponent subco) {
- struct form * form = co->data;
- int i, new;
-
- for (i = 0; i < form->numComps; i++) {
- if (form->elements[i].co == subco) break;
- }
-
- if (form->elements[i].co != subco) return;
- new = i;
-
- if (co->isMapped && !componentFits(co, new)) {
- gotoComponent(form, -1);
- form->vertOffset = form->elements[new].top - co->top - 1;
- if (form->vertOffset > (form->numRows - co->height))
- form->vertOffset = form->numRows - co->height;
- }
-
- gotoComponent(form, new);
-}
-
-void newtFormSetTimer(newtComponent co, int millisecs) {
- struct form * form = co->data;
-
- form->timer = millisecs;
- form->lastTimeout.tv_usec = 0;
- form->lastTimeout.tv_sec = 0;
-}
-
-void newtFormSetHeight(newtComponent co, int height) {
- struct form * form = co->data;
-
- form->fixedHeight = 1;
- co->height = height;
-}
-
-void newtFormSetWidth(newtComponent co, int width) {
- co->width = width;
-}
-
-void newtFormAddComponent(newtComponent co, newtComponent newco) {
- struct form * form = co->data;
-
- co->takesFocus = 1;
-
- if (form->numCompsAlloced == form->numComps) {
- form->numCompsAlloced += 5;
- form->elements = realloc(form->elements,
- sizeof(*(form->elements)) * form->numCompsAlloced);
- }
-
- /* we grab real values for these a bit later */
- form->elements[form->numComps].left = -2;
- form->elements[form->numComps].top = -2;
- form->elements[form->numComps].co = newco;
-
- if (newco->takesFocus && form->currComp == -1)
- form->currComp = form->numComps;
-
- form->numComps++;
-}
-
-void newtFormAddComponents(newtComponent co, ...) {
- va_list ap;
- newtComponent subco;
-
- va_start(ap, co);
-
- while ((subco = va_arg(ap, newtComponent)))
- newtFormAddComponent(co, subco);
-
- va_end(ap);
-}
-
-static void formPlace(newtComponent co, int left, int top) {
- struct form * form = co->data;
- int vertDelta, horizDelta;
- struct element * el;
- int i;
-
- newtFormSetSize(co);
-
- vertDelta = top - co->top;
- horizDelta = left - co->left;
- co->top = top;
- co->left = left;
-
- for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
- el->co->top += vertDelta;
- el->top += vertDelta;
- el->co->left += horizDelta;
- el->left += horizDelta;
- }
-}
-
-void newtDrawForm(newtComponent co) {
- struct form * form = co->data;
- struct element * el;
- int i;
-
- newtFormSetSize(co);
-
- SLsmg_set_color(form->background);
- newtClearBox(co->left, co->top, co->width, co->height);
- for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
- /* the scrollbar *always* fits somewhere */
- if (el->co == form->vertBar) {
- el->co->ops->mapped(el->co, 1);
- el->co->ops->draw(el->co);
- } else {
- /* only draw it if it'll fit on the screen vertically */
- if (componentFits(co, i)) {
- el->co->top = el->top - form->vertOffset;
- el->co->ops->mapped(el->co, 1);
- el->co->ops->draw(el->co);
- } else {
- el->co->ops->mapped(el->co, 0);
- }
- }
- }
-
- if (form->vertBar)
- newtScrollbarSet(form->vertBar, form->vertOffset,
- form->numRows - co->height);
-}
-
-static struct eventResult formEvent(newtComponent co, struct event ev) {
- struct form * form = co->data;
- newtComponent subco = form->elements[form->currComp].co;
- int new, wrap = 0;
- struct eventResult er;
- int dir = 0, page = 0;
- int i, num, found;
- struct element * el;
-
- er.result = ER_IGNORED;
- if (!form->numComps) return er;
-
- subco = form->elements[form->currComp].co;
-
- switch (ev.when) {
- case EV_EARLY:
- if (ev.event == EV_KEYPRESS) {
- if (ev.u.key == NEWT_KEY_TAB) {
- er.result = ER_SWALLOWED;
- dir = 1;
- wrap = 1;
- } else if (ev.u.key == NEWT_KEY_UNTAB) {
- er.result = ER_SWALLOWED;
- dir = -1;
- wrap = 1;
- }
- }
-
- if (form->numComps) {
- i = form->currComp;
- num = 0;
- while (er.result == ER_IGNORED && num != form->numComps ) {
- er = form->elements[i].co->ops->event(form->elements[i].co, ev);
-
- num++;
- i++;
- if (i == form->numComps) i = 0;
- }
- }
-
- break;
-
- case EV_NORMAL:
- if (ev.event == EV_MOUSE) {
- found = 0;
- for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
- if ((el->co->top <= ev.u.mouse.y) &&
- (el->co->top + el->co->height > ev.u.mouse.y) &&
- (el->co->left <= ev.u.mouse.x) &&
- (el->co->left + el->co->width > ev.u.mouse.x)) {
- found = 1;
- if (el->co->takesFocus) {
- gotoComponent(form, i);
- subco = form->elements[form->currComp].co;
- }
- }
- /* If we did not find a co to send this event to, we
- should just swallow the event here. */
- }
- if (!found) {
- er.result = ER_SWALLOWED;
-
- return er;
- }
- }
- er = subco->ops->event(subco, ev);
- switch (er.result) {
- case ER_NEXTCOMP:
- er.result = ER_SWALLOWED;
- dir = 1;
- break;
-
- case ER_EXITFORM:
- form->exitComp = subco;
- break;
-
- default:
- break;
- }
- break;
-
- case EV_LATE:
- er = subco->ops->event(subco, ev);
-
- if (er.result == ER_IGNORED) {
- switch (ev.u.key) {
- case NEWT_KEY_UP:
- case NEWT_KEY_LEFT:
- case NEWT_KEY_BKSPC:
- er.result = ER_SWALLOWED;
- dir = -1;
- break;
-
- case NEWT_KEY_DOWN:
- case NEWT_KEY_RIGHT:
- er.result = ER_SWALLOWED;
- dir = 1;
- break;
-
- case NEWT_KEY_PGUP:
- er.result = ER_SWALLOWED;
- dir = -1;
- page = 1;
- break;
-
- case NEWT_KEY_PGDN:
- er.result = ER_SWALLOWED;
- dir = 1;
- page = 1;
- break;
- }
- }
- }
-
- if (dir) {
- new = form->currComp;
-
- if (page) {
- new += dir * co->height;
- if (new < 0)
- new = 0;
- else if (new >= form->numComps)
- new = (form->numComps - 1);
-
- while (!form->elements[new].co->takesFocus)
- new = new - dir;
- } else {
- do {
- new += dir;
-
- if (wrap) {
- if (new < 0)
- new = form->numComps - 1;
- else if (new >= form->numComps)
- new = 0;
- } else if (new < 0 || new >= form->numComps)
- return er;
- } while (!form->elements[new].co->takesFocus);
- }
-
- /* make sure this component is visible */
- if (!componentFits(co, new)) {
- gotoComponent(form, -1);
-
- if (dir < 0) {
- /* make the new component the first one */
- form->vertOffset = form->elements[new].top - co->top;
- } else {
- /* make the new component the last one */
- form->vertOffset = (form->elements[new].top +
- form->elements[new].co->height) -
- (co->top + co->height);
- }
-
- if (form->vertOffset < 0) form->vertOffset = 0;
- if (form->vertOffset > (form->numRows - co->height))
- form->vertOffset = form->numRows - co->height;
-
- newtDrawForm(co);
- }
-
- gotoComponent(form, new);
- er.result = ER_SWALLOWED;
- }
-
- return er;
-}
-
-/* this also destroys all of the components on the form */
-void newtFormDestroy(newtComponent co) {
- newtComponent subco;
- struct form * form = co->data;
- int i;
-
- /* first, destroy all of the components */
- for (i = 0; i < form->numComps; i++) {
- subco = form->elements[i].co;
- if (subco->ops->destroy) {
- subco->ops->destroy(subco);
- } else {
- if (subco->data) free(subco->data);
- free(subco);
- }
- }
-
- if (form->hotKeys) free(form->hotKeys);
-
- free(form->elements);
- free(form);
- free(co);
-}
-
-newtComponent newtRunForm(newtComponent co) {
- struct newtExitStruct es;
-
- newtFormRun(co, &es);
- if (es.reason == NEWT_EXIT_HOTKEY) {
- if (es.u.key == NEWT_KEY_F12) {
- es.reason = NEWT_EXIT_COMPONENT;
- es.u.co = co;
- } else {
- return NULL;
- }
- }
-
- return es.u.co;
-}
-
-void newtFormAddHotKey(newtComponent co, int key) {
- struct form * form = co->data;
-
- form->numHotKeys++;
- form->hotKeys = realloc(form->hotKeys, sizeof(int) * form->numHotKeys);
- form->hotKeys[form->numHotKeys - 1] = key;
-}
-
-void newtFormSetSize(newtComponent co) {
- struct form * form = co->data;
- int delta, i;
- struct element * el;
-
- if (form->beenSet) return;
-
- form->beenSet = 1;
-
- if (!form->numComps) return;
-
- co->width = 0;
- if (!form->fixedHeight) co->height = 0;
-
- co->top = form->elements[0].co->top;
- co->left = form->elements[0].co->left;
- for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
- if (el->co->ops == &formOps)
- newtFormSetSize(el->co);
-
- el->left = el->co->left;
- el->top = el->co->top;
-
- if (co->left > el->co->left) {
- delta = co->left - el->co->left;
- co->left -= delta;
- co->width += delta;
- }
-
- if (co->top > el->co->top) {
- delta = co->top - el->co->top;
- co->top -= delta;
- if (!form->fixedHeight)
- co->height += delta;
- }
-
- if ((co->left + co->width) < (el->co->left + el->co->width))
- co->width = (el->co->left + el->co->width) - co->left;
-
- if (!form->fixedHeight) {
- if ((co->top + co->height) < (el->co->top + el->co->height))
- co->height = (el->co->top + el->co->height) - co->top;
- }
-
- if ((el->co->top + el->co->height - co->top) > form->numRows) {
- form->numRows = el->co->top + el->co->height - co->top;
- }
- }
-}
-
-void newtFormRun(newtComponent co, struct newtExitStruct * es) {
- struct form * form = co->data;
- struct event ev;
- struct eventResult er;
- int key, i, max;
- int done = 0;
- fd_set readSet, writeSet;
- struct timeval nextTimeout, now, timeout;
-
- newtFormSetSize(co);
- /* draw all of the components */
- newtDrawForm(co);
-
- if (form->currComp == -1) {
- gotoComponent(form, 0);
- } else
- gotoComponent(form, form->currComp);
-
- while (!done) {
- newtRefresh();
-
- FD_ZERO(&readSet);
- FD_ZERO(&writeSet);
- FD_SET(0, &readSet);
- max = form->maxFd;
-
- for (i = 0; i < form->numFds; i++) {
- if (form->fds[i].flags & NEWT_FD_READ)
- FD_SET(form->fds[i].fd, &readSet);
- if (form->fds[i].flags & NEWT_FD_WRITE)
- FD_SET(form->fds[i].fd, &writeSet);
- }
-
- if (form->timer) {
- /* Calculate when we next need to return with a timeout. Do
- this inside the loop in case a callback resets the timer. */
- if (!form->lastTimeout.tv_sec && !form->lastTimeout.tv_usec)
- gettimeofday(&form->lastTimeout, NULL);
-
- nextTimeout.tv_sec = form->lastTimeout.tv_sec +
- (form->timer / 1000);
- nextTimeout.tv_usec = form->lastTimeout.tv_usec +
- (form->timer % 1000) * 1000;
-
- gettimeofday(&now, 0);
-
- if (now.tv_sec > nextTimeout.tv_sec) {
- timeout.tv_sec = timeout.tv_usec = 0;
- } else if (now.tv_sec == nextTimeout.tv_sec) {
- timeout.tv_sec = 0;
- if (now.tv_usec > nextTimeout.tv_usec)
- timeout.tv_usec = 0;
- else
- timeout.tv_usec = nextTimeout.tv_usec - now.tv_usec;
- } else if (now.tv_sec < nextTimeout.tv_sec) {
- timeout.tv_sec = nextTimeout.tv_sec - now.tv_sec;
- if (now.tv_usec > nextTimeout.tv_usec)
- timeout.tv_sec--,
- timeout.tv_usec = nextTimeout.tv_usec + 1000000 -
- now.tv_usec;
- else
- timeout.tv_usec = nextTimeout.tv_usec - now.tv_usec;
- }
- } else {
- timeout.tv_sec = timeout.tv_usec = 0;
- }
-
- i = select(max + 1, &readSet, &writeSet, NULL,
- form->timer ? &timeout : NULL);
- if (i < 0) continue; /* ?? What should we do here? */
-
- if (i == 0) {
- done = 1;
- es->reason = NEWT_EXIT_TIMER;
- gettimeofday(&form->lastTimeout, NULL);
- } else
- {
- if (FD_ISSET(0, &readSet)) {
-
- key = newtGetKey();
-
- if (key == NEWT_KEY_RESIZE) {
- /* newtResizeScreen(1); */
- continue;
- }
-
- for (i = 0; i < form->numHotKeys; i++) {
- if (form->hotKeys[i] == key) {
- es->reason = NEWT_EXIT_HOTKEY;
- es->u.key = key;
- done = 1;
- break;
- }
- }
-
- if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb)
- form->helpCb(co, form->helpTag);
-
- if (!done) {
- ev.event = EV_KEYPRESS;
- ev.u.key = key;
-
- er = sendEvent(co, ev);
-
- if (er.result == ER_EXITFORM) {
- done = 1;
- es->reason = NEWT_EXIT_COMPONENT;
- es->u.co = form->exitComp;
- }
- }
- } else {
- es->reason = NEWT_EXIT_FDREADY;
- done = 1;
- }
- }
- }
- newtRefresh();
-}
-
-static struct eventResult sendEvent(newtComponent co, struct event ev) {
- struct eventResult er;
-
- ev.when = EV_EARLY;
- er = co->ops->event(co, ev);
-
- if (er.result == ER_IGNORED) {
- ev.when = EV_NORMAL;
- er = co->ops->event(co, ev);
- }
-
- if (er.result == ER_IGNORED) {
- ev.when = EV_LATE;
- er = co->ops->event(co, ev);
- }
-
- return er;
-}
-
-static void gotoComponent(struct form * form, int newComp) {
- struct event ev;
-
- if (form->currComp != -1) {
- ev.event = EV_UNFOCUS;
- sendEvent(form->elements[form->currComp].co, ev);
- }
-
- form->currComp = newComp;
-
- if (form->currComp != -1) {
- ev.event = EV_FOCUS;
- ev.when = EV_NORMAL;
- sendEvent(form->elements[form->currComp].co, ev);
- }
-}
-
-void newtComponentAddCallback(newtComponent co, newtCallback f, void * data) {
- co->callback = f;
- co->callbackData = data;
-}
-
-void newtComponentTakesFocus(newtComponent co, int val) {
- co->takesFocus = val;
-}
-
-void newtFormSetBackground(newtComponent co, int color) {
- struct form * form = co->data;
-
- form->background = color;
-}
-
-void newtFormWatchFd(newtComponent co, int fd, int fdFlags) {
- struct form * form = co->data;
-
- form->fds = realloc(form->fds, (form->numFds + 1) * sizeof(*form->fds));
- form->fds[form->numFds].fd = fd;
- form->fds[form->numFds++].flags = fdFlags;
- if (form->maxFd < fd) form->maxFd = fd;
-}
-
-void newtSetHelpCallback(newtCallback cb) {
- helpCallback = cb;
-}
diff --git a/mdk-stage1/newt/grid.c b/mdk-stage1/newt/grid.c
deleted file mode 100644
index 37d2b2e74..000000000
--- a/mdk-stage1/newt/grid.c
+++ /dev/null
@@ -1,389 +0,0 @@
-#include <alloca.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct gridField {
- enum newtGridElement type;
- union {
- newtGrid grid;
- newtComponent co;
- } u;
- int padLeft, padTop, padRight, padBottom;
- int anchor;
- int flags;
-};
-
-struct grid_s {
- int rows, cols;
- int width, height; /* totals, -1 means unknown */
- struct gridField ** fields;
-};
-
-/* this is a bit of a hack */
-extern struct componentOps formOps[];
-
-newtGrid newtCreateGrid(int cols, int rows) {
- newtGrid grid;
-
- grid = malloc(sizeof(*grid));
- grid->rows = rows;
- grid->cols = cols;
-
- grid->fields = malloc(sizeof(*grid->fields) * cols);
- while (cols--) {
- grid->fields[cols] = malloc(sizeof(**(grid->fields)) * rows);
- memset(grid->fields[cols], 0, sizeof(**(grid->fields)) * rows);
- }
-
- grid->width = grid->height = -1;
-
- return grid;
-}
-
-void newtGridSetField(newtGrid grid, int col, int row,
- enum newtGridElement type, void * val, int padLeft,
- int padTop, int padRight, int padBottom, int anchor,
- int flags) {
- struct gridField * field = &grid->fields[col][row];
-
- if (field->type == NEWT_GRID_SUBGRID)
- newtGridFree(field->u.grid, 1);
-
- field->type = type;
- field->u.co = (void *) val;
-
- field->padLeft = padLeft;
- field->padRight = padRight;
- field->padTop = padTop;
- field->padBottom = padBottom;
- field->anchor = anchor;
- field->flags = flags;
-
- grid->width = grid->height = -1;
-}
-
-static void distSpace(int extra, int items, int * list) {
- int all, some, i;
-
- all = extra / items;
- some = extra % items;
- for (i = 0; i < items; i++) {
- list[i] += all;
- if (some) {
- list[i]++;
- some--;
- }
- }
-}
-
-static void shuffleGrid(newtGrid grid, int left, int top, int set) {
- struct gridField * field;
- int row, col;
- int i, j;
- int minWidth, minHeight;
- int * widths, * heights;
- int thisLeft, thisTop;
- int x, y, remx, remy;
-
- widths = alloca(sizeof(*widths) * grid->cols);
- memset(widths, 0, sizeof(*widths) * grid->cols);
- heights = alloca(sizeof(*heights) * grid->rows);
- memset(heights, 0, sizeof(*heights) * grid->rows);
-
- minWidth = 0;
- for (row = 0; row < grid->rows; row++) {
- i = 0;
- for (col = 0; col < grid->cols; col++) {
- field = &grid->fields[col][row];
- if (field->type == NEWT_GRID_SUBGRID) {
- /* we'll have to redo this later */
- if (field->u.grid->width == -1)
- shuffleGrid(field->u.grid, left, top, 0);
- j = field->u.grid->width;
- } else if (field->type == NEWT_GRID_COMPONENT) {
- if (field->u.co->ops == formOps)
- newtFormSetSize(field->u.co);
- j = field->u.co->width;
- } else
- j = 0;
-
- j += field->padLeft + field->padRight;
-
- if (j > widths[col]) widths[col] = j;
- i += widths[col];
- }
-
- if (i > minWidth) minWidth = i;
- }
-
- minHeight = 0;
- for (col = 0; col < grid->cols; col++) {
- i = 0;
- for (row = 0; row < grid->rows; row++) {
- field = &grid->fields[col][row];
- if (field->type == NEWT_GRID_SUBGRID) {
- /* we'll have to redo this later */
- if (field->u.grid->height == -1)
- shuffleGrid(field->u.grid, 0, 0, 0);
- j = field->u.grid->height;
- } else if (field->type == NEWT_GRID_COMPONENT){
- j = field->u.co->height;
- } else
- j = 0;
-
- j += field->padTop + field->padBottom;
-
- if (j > heights[row]) heights[row] = j;
- i += heights[row];
- }
-
- if (i > minHeight) minHeight = i;
- }
-
- /* this catches the -1 case */
- if (grid->width < minWidth) grid->width = minWidth; /* ack! */
- if (grid->height < minHeight) grid->height = minHeight; /* ditto! */
-
- if (!set) return;
-
- distSpace(grid->width - minWidth, grid->cols, widths);
- distSpace(grid->height - minHeight, grid->rows, heights);
-
- thisTop = top;
- for (row = 0; row < grid->rows; row++) {
- i = 0;
- thisLeft = left;
- for (col = 0; col < grid->cols; col++) {
- field = &grid->fields[col][row];
-
- if (field->type == NEWT_GRID_EMPTY) continue;
-
- x = thisLeft + field->padLeft;
- remx = widths[col] - field->padLeft - field->padRight;
- y = thisTop + field->padTop;
- remy = heights[row] - field->padTop - field->padBottom;
-
- if (field->type == NEWT_GRID_SUBGRID) {
- remx -= field->u.grid->width;
- remy -= field->u.grid->height;
- } else if (field->type == NEWT_GRID_COMPONENT) {
- remx -= field->u.co->width;
- remy -= field->u.co->height;
- }
-
- if (!(field->flags & NEWT_GRID_FLAG_GROWX)) {
- if (field->anchor & NEWT_ANCHOR_RIGHT)
- x += remx;
- else if (!(field->anchor & NEWT_ANCHOR_LEFT))
- x += (remx / 2);
- }
-
- if (!(field->flags & NEWT_GRID_FLAG_GROWY)) {
- if (field->anchor & NEWT_ANCHOR_BOTTOM)
- y += remx;
- else if (!(field->anchor & NEWT_ANCHOR_TOP))
- y += (remy / 2);
- }
-
- if (field->type == NEWT_GRID_SUBGRID) {
- if (field->flags & NEWT_GRID_FLAG_GROWX)
- field->u.grid->width = widths[col] - field->padLeft
- - field->padRight;
- if (field->flags & NEWT_GRID_FLAG_GROWY)
- field->u.grid->height = heights[col] - field->padTop
- - field->padBottom;
-
- shuffleGrid(field->u.grid, x, y, 1);
- } else if (field->type == NEWT_GRID_COMPONENT) {
- field->u.co->ops->place(field->u.co, x, y);
- }
-
- thisLeft += widths[col];
- }
-
- thisTop += heights[row];
- }
-}
-
-void newtGridPlace(newtGrid grid, int left, int top) {
- shuffleGrid(grid, left, top, 1);
-}
-
-void newtGridFree(newtGrid grid, int recurse) {
- int row, col;
-
- for (col = 0; col < grid->cols; col++) {
- if (recurse) {
- for (row = 0; row < grid->rows; row++) {
- if (grid->fields[col][row].type == NEWT_GRID_SUBGRID)
- newtGridFree(grid->fields[col][row].u.grid, 1);
- }
- }
-
- free(grid->fields[col]);
- }
-
- free(grid->fields);
- free(grid);
-}
-
-void newtGridGetSize(newtGrid grid, int * width, int * height) {
- if (grid->width == -1 || grid->height == -1) {
- grid->width = grid->height = -1;
- shuffleGrid(grid, 0, 0, 1);
- }
-
- *width = grid->width;
- *height = grid->height;
-}
-
-void newtGridWrappedWindow(newtGrid grid, char * title) {
- int width, height, offset = 0;
-
- newtGridGetSize(grid, &width, &height);
- if ((size_t)width < strlen(title) + 2) {
- offset = ((strlen(title) + 2) - width) / 2;
- width = strlen(title) + 2;
- }
- newtCenteredWindow(width + 2, height + 2, title);
- newtGridPlace(grid, 1 + offset, 1);
-}
-
-void newtGridWrappedWindowAt(newtGrid grid, char * title, int left, int top) {
- int width, height;
-
- newtGridGetSize(grid, &width, &height);
- newtOpenWindow(left, top, width + 2, height + 2, title);
- newtGridPlace(grid, 1, 1);
-}
-
-void newtGridAddComponentsToForm(newtGrid grid, newtComponent form,
- int recurse) {
- int row, col;
-
- for (col = 0; col < grid->cols; col++) {
- for (row = 0; row < grid->rows; row++) {
- if (grid->fields[col][row].type == NEWT_GRID_SUBGRID && recurse)
- newtGridAddComponentsToForm(grid->fields[col][row].u.grid,
- form, 1);
- else if (grid->fields[col][row].type == NEWT_GRID_COMPONENT)
- newtFormAddComponent(form, grid->fields[col][row].u.co);
- }
- }
-}
-
-/* this handles up to 50 items */
-static newtGrid stackem(int isVert, enum newtGridElement type1, void * what1,
- va_list args, int close) {
- struct item {
- enum newtGridElement type;
- void * what;
- } items[50];
- int i, num;
- newtGrid grid;
-
- items[0].type = type1, items[0].what = what1, num = 1;
- while (1) {
- items[num].type = va_arg(args, enum newtGridElement);
- if (items[num].type == NEWT_GRID_EMPTY) break;
-
- items[num].what = va_arg(args, void *);
- num++;
- }
-
- grid = newtCreateGrid(isVert ? 1 : num, isVert ? num : 1);
-
- for (i = 0; i < num; i++) {
- newtGridSetField(grid, isVert ? 0 : i, isVert ? i : 0,
- items[i].type, items[i].what,
- close ? 0 : (i ? (isVert ? 0 : 1) : 0),
- close ? 0 : (i ? (isVert ? 1 : 0) : 0), 0, 0, 0, 0);
- }
-
- return grid;
-}
-
-newtGrid newtGridHCloseStacked(enum newtGridElement type1, void * what1, ...) {
- va_list args;
- newtGrid grid;
-
- va_start(args, what1);
-
- grid = stackem(0, type1, what1, args, 1);
-
- va_start(args, what1);
-
- return grid;
-}
-
-newtGrid newtGridVCloseStacked(enum newtGridElement type1, void * what1, ...) {
- va_list args;
- newtGrid grid;
-
- va_start(args, what1);
-
- grid = stackem(1, type1, what1, args, 1);
-
- va_start(args, what1);
-
- return grid;
-}
-
-newtGrid newtGridVStacked(enum newtGridElement type1, void * what1, ...) {
- va_list args;
- newtGrid grid;
-
- va_start(args, what1);
-
- grid = stackem(1, type1, what1, args, 0);
-
- va_start(args, what1);
-
- return grid;
-}
-
-newtGrid newtGridHStacked(enum newtGridElement type1, void * what1, ...) {
- va_list args;
- newtGrid grid;
-
- va_start(args, what1);
-
- grid = stackem(0, type1, what1, args, 0);
-
- va_start(args, what1);
-
- return grid;
-}
-
-newtGrid newtGridBasicWindow(newtComponent text, newtGrid middle,
- newtGrid buttons) {
- newtGrid grid;
-
- grid = newtCreateGrid(1, 3);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
- 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, middle,
- 0, 1, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons,
- 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
-
- return grid;
-}
-
-newtGrid newtGridSimpleWindow(newtComponent text, newtComponent middle,
- newtGrid buttons) {
- newtGrid grid;
-
- grid = newtCreateGrid(1, 3);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
- 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, middle,
- 0, 1, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons,
- 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
-
- return grid;
-}
diff --git a/mdk-stage1/newt/label.c b/mdk-stage1/newt/label.c
deleted file mode 100644
index f1a9cebbf..000000000
--- a/mdk-stage1/newt/label.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct label {
- char * text;
- int length;
-};
-
-static void labelDraw(newtComponent co);
-static void labelDestroy(newtComponent co);
-
-static struct componentOps labelOps = {
- labelDraw,
- newtDefaultEventHandler,
- labelDestroy,
- newtDefaultPlaceHandler,
- newtDefaultMappedHandler,
-} ;
-
-newtComponent newtLabel(int left, int top, const char * text) {
- newtComponent co;
- struct label * la;
-
- co = malloc(sizeof(*co));
- la = malloc(sizeof(struct label));
- co->data = la;
-
- co->ops = &labelOps;
-
- co->height = 1;
- co->width = strlen(text);
- co->top = top;
- co->left = left;
- co->takesFocus = 0;
-
- la->length = strlen(text);
- la->text = strdup(text);
-
- return co;
-}
-
-void newtLabelSetText(newtComponent co, const char * text) {
- int newLength;
- struct label * la = co->data;
-
- newLength = strlen(text);
- if (newLength <= la->length) {
- memset(la->text, ' ', la->length);
- memcpy(la->text, text, newLength);
- } else {
- free(la->text);
- la->text = strdup(text);
- la->length = newLength;
- co->width = newLength;
- }
-
- labelDraw(co);
-}
-
-static void labelDraw(newtComponent co) {
- struct label * la = co->data;
-
- if (co->isMapped == -1) return;
-
- SLsmg_set_color(COLORSET_LABEL);
-
- newtGotorc(co->top, co->left);
- SLsmg_write_string(la->text);
-}
-
-static void labelDestroy(newtComponent co) {
- struct label * la = co->data;
-
- free(la->text);
- free(la);
- free(co);
-}
diff --git a/mdk-stage1/newt/listbox.c b/mdk-stage1/newt/listbox.c
deleted file mode 100644
index cdbf792ca..000000000
--- a/mdk-stage1/newt/listbox.c
+++ /dev/null
@@ -1,752 +0,0 @@
-/* This goofed-up box whacked into shape by Elliot Lee <sopwith@cuc.edu>
- (from the original listbox by Erik Troan <ewt@redhat.com>)
- and contributed to newt for use under the LGPL license.
- Copyright (C) 1996, 1997 Elliot Lee */
-
-#include <slang.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-
-/* Linked list of items in the listbox */
-struct items {
- char * text;
- const void *data;
- unsigned char isSelected;
- struct items *next;
-};
-
-/* Holds all the relevant information for this listbox */
-struct listbox {
- newtComponent sb; /* Scrollbar on right side of listbox */
- int curWidth; /* size of text w/o scrollbar or border*/
- int curHeight; /* size of text w/o border */
- int sbAdjust;
- int bdxAdjust, bdyAdjust;
- int numItems, numSelected;
- int userHasSetWidth;
- int currItem, startShowItem; /* startShowItem is the first item displayed
- on the screen */
- int isActive; /* If we handle key events all the time, it seems
- to do things even when they are supposed to be for
- another button/whatever */
- struct items *boxItems;
- int grow;
- int flags; /* flags for this listbox, right now just
- NEWT_FLAG_RETURNEXIT */
-};
-
-static void listboxDraw(newtComponent co);
-static void listboxDestroy(newtComponent co);
-static struct eventResult listboxEvent(newtComponent co, struct event ev);
-static void newtListboxRealSetCurrent(newtComponent co);
-static void listboxPlace(newtComponent co, int newLeft, int newTop);
-static inline void updateWidth(newtComponent co, struct listbox * li,
- int maxField);
-static void listboxMapped(newtComponent co, int isMapped);
-
-static struct componentOps listboxOps = {
- listboxDraw,
- listboxEvent,
- listboxDestroy,
- listboxPlace,
- listboxMapped,
-};
-
-static void listboxMapped(newtComponent co, int isMapped) {
- struct listbox * li = co->data;
-
- co->isMapped = isMapped;
- if (li->sb)
- li->sb->ops->mapped(li->sb, isMapped);
-}
-
-static void listboxPlace(newtComponent co, int newLeft, int newTop) {
- struct listbox * li = co->data;
-
- co->top = newTop;
- co->left = newLeft;
-
- if (li->sb)
- li->sb->ops->place(li->sb, co->left + co->width - li->bdxAdjust - 1,
- co->top);
-}
-
-newtComponent newtListbox(int left, int top, int height, int flags) {
- newtComponent co, sb;
- struct listbox * li;
-
- if (!(co = malloc(sizeof(*co))))
- return NULL;
-
- if (!(li = malloc(sizeof(struct listbox)))) {
- free(co);
- return NULL;
- }
-
- li->boxItems = NULL;
- li->numItems = 0;
- li->currItem = 0;
- li->numSelected = 0;
- li->isActive = 0;
- li->userHasSetWidth = 0;
- li->startShowItem = 0;
- li->sbAdjust = 0;
- li->bdxAdjust = 0;
- li->bdyAdjust = 0;
- li->flags = flags & (NEWT_FLAG_RETURNEXIT | NEWT_FLAG_BORDER |
- NEWT_FLAG_MULTIPLE);
-
- if (li->flags & NEWT_FLAG_BORDER) {
- li->bdxAdjust = 2;
- li->bdyAdjust = 1;
- }
-
- co->height = height;
- li->curHeight = co->height - (2 * li->bdyAdjust);
-
- if (height) {
- li->grow = 0;
- if (flags & NEWT_FLAG_SCROLL) {
- sb = newtVerticalScrollbar(left, top + li->bdyAdjust,
- li->curHeight,
- COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
- li->sbAdjust = 3;
- } else {
- sb = NULL;
- }
- } else {
- li->grow = 1;
- sb = NULL;
- }
-
- li->sb = sb;
- co->data = li;
- co->isMapped = 0;
- co->left = left;
- co->top = top;
- co->ops = &listboxOps;
- co->takesFocus = 1;
- co->callback = NULL;
-
- updateWidth(co, li, 5);
-
- return co;
-}
-
-static inline void updateWidth(newtComponent co, struct listbox * li,
- int maxField) {
- li->curWidth = maxField;
- co->width = li->curWidth + li->sbAdjust + 2 * li->bdxAdjust;
-
- if (li->sb)
- li->sb->left = co->left + co->width - li->bdxAdjust - 1;
-}
-
-void newtListboxSetCurrentByKey(newtComponent co, void * key) {
- struct listbox * li = co->data;
- struct items * item;
- int i;
-
- item = li->boxItems, i = 0;
- while (item && item->data != key)
- item = item->next, i++;
-
- if (item)
- newtListboxSetCurrent(co, i);
-}
-
-void newtListboxSetCurrent(newtComponent co, int num)
-{
- struct listbox * li = co->data;
-
- if (num >= li->numItems)
- li->currItem = li->numItems - 1;
- else if (num < 0)
- li->currItem = 0;
- else
- li->currItem = num;
-
- if (li->currItem < li->startShowItem)
- li->startShowItem = li->currItem;
- else if (li->currItem - li->startShowItem > li->curHeight - 1)
- li->startShowItem = li->currItem - li->curHeight + 1;
- if (li->startShowItem + li->curHeight > li->numItems)
- li->startShowItem = li->numItems - li->curHeight;
- if(li->startShowItem < 0)
- li->startShowItem = 0;
-
- newtListboxRealSetCurrent(co);
-}
-
-static void newtListboxRealSetCurrent(newtComponent co)
-{
- struct listbox * li = co->data;
-
- if(li->sb)
- newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
- listboxDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
-}
-
-void newtListboxSetWidth(newtComponent co, int width) {
- struct listbox * li = co->data;
-
- co->width = width;
- li->curWidth = co->width - li->sbAdjust - 2 * li->bdxAdjust;
- li->userHasSetWidth = 1;
- if (li->sb) li->sb->left = co->width + co->left - 1;
- listboxDraw(co);
-}
-
-void * newtListboxGetCurrent(newtComponent co) {
- struct listbox * li = co->data;
- int i;
- struct items *item;
-
- for(i = 0, item = li->boxItems; item != NULL && i < li->currItem;
- i++, item = item->next);
-
- if (item)
- return (void *)item->data;
- else
- return NULL;
-}
-
-void newtListboxSelectItem(newtComponent co, const void * key,
- enum newtFlagsSense sense)
-{
- struct listbox * li = co->data;
- int i;
- struct items * item;
-
- item = li->boxItems, i = 0;
- while (item && item->data != key)
- item = item->next, i++;
-
- if (!item) return;
-
- if (item->isSelected)
- li->numSelected--;
-
- switch(sense) {
- case NEWT_FLAGS_RESET:
- item->isSelected = 0; break;
- case NEWT_FLAGS_SET:
- item->isSelected = 1; break;
- case NEWT_FLAGS_TOGGLE:
- item->isSelected = !item->isSelected;
- }
-
- if (item->isSelected)
- li->numSelected++;
-
- listboxDraw(co);
-}
-
-void newtListboxClearSelection(newtComponent co)
-{
- struct items *item;
- struct listbox * li = co->data;
-
- for(item = li->boxItems; item != NULL;
- item = item->next)
- item->isSelected = 0;
- li->numSelected = 0;
- listboxDraw(co);
-}
-
-/* Free the returned array after use, but NOT the values in the array */
-void ** newtListboxGetSelection(newtComponent co, int *numitems)
-{
- struct listbox * li;
- int i;
- void **retval;
- struct items *item;
-
- if(!co || !numitems) return NULL;
-
- li = co->data;
- if(!li || !li->numSelected) return NULL;
-
- retval = malloc(li->numSelected * sizeof(void *));
- for(i = 0, item = li->boxItems; item != NULL;
- item = item->next)
- if(item->isSelected)
- retval[i++] = (void *)item->data;
- *numitems = li->numSelected;
- return retval;
-}
-
-void newtListboxSetEntry(newtComponent co, int num, const char * text) {
- struct listbox * li = co->data;
- int i;
- struct items *item;
-
- for(i = 0, item = li->boxItems; item != NULL && i < num;
- i++, item = item->next);
-
- if(!item)
- return;
- else {
- free(item->text);
- item->text = strdup(text);
- }
- if (li->userHasSetWidth == 0 && strlen(text) > (size_t)li->curWidth) {
- updateWidth(co, li, strlen(text));
- }
-
- if (num >= li->startShowItem && num <= li->startShowItem + co->height)
- listboxDraw(co);
-}
-
-void newtListboxSetData(newtComponent co, int num, void * data) {
- struct listbox * li = co->data;
- int i;
- struct items *item;
-
- for(i = 0, item = li->boxItems; item != NULL && i < num;
- i++, item = item->next);
-
- item->data = data;
-}
-
-int newtListboxAppendEntry(newtComponent co, const char * text,
- const void * data) {
- struct listbox * li = co->data;
- struct items *item;
-
- if(li->boxItems) {
- for (item = li->boxItems; item->next != NULL; item = item->next);
-
- item = item->next = malloc(sizeof(struct items));
- } else {
- item = li->boxItems = malloc(sizeof(struct items));
- }
-
- if (!li->userHasSetWidth && text && (strlen(text) > (size_t)li->curWidth))
- updateWidth(co, li, strlen(text));
-
- item->text = strdup(text); item->data = data; item->next = NULL;
- item->isSelected = 0;
-
- if (li->grow)
- co->height++, li->curHeight++;
- li->numItems++;
-
- return 0;
-}
-
-int newtListboxInsertEntry(newtComponent co, const char * text,
- const void * data, void * key) {
- struct listbox * li = co->data;
- struct items *item, *t;
-
- if (li->boxItems) {
- if (key) {
- item = li->boxItems;
- while (item && item->data != key) item = item->next;
-
- if (!item) return 1;
-
- t = item->next;
- item = item->next = malloc(sizeof(struct items));
- item->next = t;
- } else {
- t = li->boxItems;
- item = li->boxItems = malloc(sizeof(struct items));
- item->next = t;
- }
- } else if (key) {
- return 1;
- } else {
- item = li->boxItems = malloc(sizeof(struct items));
- item->next = NULL;
- }
-
- if (!li->userHasSetWidth && text && (strlen(text) > (size_t)li->curWidth))
- updateWidth(co, li, strlen(text));
-
- item->text = strdup(text?text:"(null)"); item->data = data;
- item->isSelected = 0;
-
- if (li->sb)
- li->sb->left = co->left + co->width - li->bdxAdjust - 1;
- li->numItems++;
-
- listboxDraw(co);
-
- return 0;
-}
-
-int newtListboxDeleteEntry(newtComponent co, void * key) {
- struct listbox * li = co->data;
- int widest = 0, t;
- struct items *item, *item2 = NULL;
- int num;
-
- if (li->boxItems == NULL || li->numItems <= 0)
- return 0;
-
- num = 0;
-
- item2 = NULL, item = li->boxItems;
- while (item && item->data != key) {
- item2 = item;
- item = item->next;
- num++;
- }
-
- if (!item)
- return -1;
-
- if (item2)
- item2->next = item->next;
- else
- li->boxItems = item->next;
-
- free(item->text);
- free(item);
- li->numItems--;
-
- if (!li->userHasSetWidth) {
- widest = 0;
- for (item = li->boxItems; item != NULL; item = item->next)
- if ((t = strlen(item->text)) > widest) widest = t;
- }
-
- if (li->currItem >= num)
- li->currItem--;
-
- if (!li->userHasSetWidth) {
- updateWidth(co, li, widest);
- }
-
- listboxDraw(co);
-
- return 0;
-}
-
-void newtListboxClear(newtComponent co)
-{
- struct listbox * li;
- struct items *anitem, *nextitem;
- if(co == NULL || (li = co->data) == NULL)
- return;
- for(anitem = li->boxItems; anitem != NULL; anitem = nextitem) {
- nextitem = anitem->next;
- free(anitem->text);
- free(anitem);
- }
- li->numItems = li->numSelected = li->currItem = li->startShowItem = 0;
- li->boxItems = NULL;
- if (!li->userHasSetWidth)
- updateWidth(co, li, 5);
-}
-
-/* If you don't want to get back the text, pass in NULL for the ptr-ptr. Same
- goes for the data. */
-void newtListboxGetEntry(newtComponent co, int num, char **text, void **data) {
- struct listbox * li = co->data;
- int i;
- struct items *item;
-
- if (!li->boxItems || num >= li->numItems) {
- if(text)
- *text = NULL;
- if(data)
- *data = NULL;
- return;
- }
-
- i = 0;
- item = li->boxItems;
- while (item && i < num) {
- i++, item = item->next;
- }
-
- if (item) {
- if (text)
- *text = item->text;
- if (data)
- *data = (void *)item->data;
- }
-}
-
-static void listboxDraw(newtComponent co)
-{
- struct listbox * li = co->data;
- struct items *item;
- int i, j;
-
- if (!co->isMapped) return ;
-
- if(li->flags & NEWT_FLAG_BORDER) {
- if(li->isActive)
- SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
- else
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
- newtDrawBox(co->left, co->top, co->width, co->height, 0);
- }
-
- if(li->sb)
- li->sb->ops->draw(li->sb);
-
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
- for(i = 0, item = li->boxItems; item != NULL && i < li->startShowItem;
- i++, item = item->next);
-
- j = i;
-
- for (i = 0; item != NULL && i < li->curHeight; i++, item = item->next) {
- if (!item->text) continue;
-
- newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
- if(j + i == li->currItem) {
- if(item->isSelected)
- SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX);
- else
- SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
- } else if(item->isSelected)
- SLsmg_set_color(NEWT_COLORSET_SELLISTBOX);
- else
- SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
- SLsmg_write_nstring(item->text, li->curWidth);
-
- }
- newtGotorc(co->top + (li->currItem - li->startShowItem), co->left);
-}
-
-static struct eventResult listboxEvent(newtComponent co, struct event ev) {
- struct eventResult er;
- struct listbox * li = co->data;
- struct items *item;
- int i;
-
- er.result = ER_IGNORED;
-
- if(ev.when == EV_EARLY || ev.when == EV_LATE) {
- return er;
- }
-
- switch(ev.event) {
- case EV_KEYPRESS:
- if (!li->isActive) break;
-
- switch(ev.u.key) {
- case ' ':
- if(!(li->flags & NEWT_FLAG_MULTIPLE)) break;
- newtListboxSelectItem(co, li->boxItems[li->currItem].data,
- NEWT_FLAGS_TOGGLE);
- er.result = ER_SWALLOWED;
- /* We don't break here, because it is cool to be able to
- hold space to select a bunch of items in a list at once */
-
- case NEWT_KEY_DOWN:
- if(li->numItems <= 0) break;
- if(li->currItem < li->numItems - 1) {
- li->currItem++;
- if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
- li->startShowItem = li->currItem - li->curHeight + 1;
- if(li->startShowItem + li->curHeight > li->numItems)
- li->startShowItem = li->numItems - li->curHeight;
- }
- if(li->sb)
- newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
- listboxDraw(co);
- }
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_ENTER:
- if(li->numItems <= 0) break;
- if(li->flags & NEWT_FLAG_RETURNEXIT)
- er.result = ER_EXITFORM;
- break;
-
- case NEWT_KEY_UP:
- if(li->numItems <= 0) break;
- if(li->currItem > 0) {
- li->currItem--;
- if(li->currItem < li->startShowItem)
- li->startShowItem = li->currItem;
- if(li->sb)
- newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
- listboxDraw(co);
- }
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_PGUP:
- if(li->numItems <= 0) break;
- li->startShowItem -= li->curHeight - 1;
- if(li->startShowItem < 0)
- li->startShowItem = 0;
- li->currItem -= li->curHeight - 1;
- if(li->currItem < 0)
- li->currItem = 0;
- newtListboxRealSetCurrent(co);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_PGDN:
- if(li->numItems <= 0) break;
- li->startShowItem += li->curHeight;
- if(li->startShowItem > (li->numItems - li->curHeight)) {
- li->startShowItem = li->numItems - li->curHeight;
- }
- li->currItem += li->curHeight;
- if(li->currItem >= li->numItems) {
- li->currItem = li->numItems - 1;
- }
- newtListboxRealSetCurrent(co);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_HOME:
- if(li->numItems <= 0) break;
- newtListboxSetCurrent(co, 0);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_END:
- if(li->numItems <= 0) break;
- li->startShowItem = li->numItems - li->curHeight;
- if(li->startShowItem < 0)
- li->startShowItem = 0;
- li->currItem = li->numItems - 1;
- newtListboxRealSetCurrent(co);
- er.result = ER_SWALLOWED;
- break;
- default:
- if (li->numItems <= 0) break;
- if (ev.u.key < NEWT_KEY_EXTRA_BASE && isalpha(ev.u.key)) {
- for(i = 0, item = li->boxItems; item != NULL &&
- i < li->currItem; i++, item = item->next);
-
- if (item && item->text && (toupper(*item->text) == toupper(ev.u.key))) {
- item = item->next;
- i++;
- } else {
- item = li->boxItems;
- i = 0;
- }
- while (item && item->text &&
- toupper(*item->text) != toupper(ev.u.key)) {
- item = item->next;
- i++;
- }
- if (item) {
- li->currItem = i;
- if(li->currItem < li->startShowItem ||
- li->currItem > li->startShowItem)
- li->startShowItem =
- li->currItem > li->numItems - li->curHeight ?
- li->startShowItem = li->numItems - li->curHeight :
- li->currItem;
- if(li->sb)
- newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
- newtListboxRealSetCurrent(co);
- er.result = ER_SWALLOWED;
- }
- }
- }
- break;
-
- case EV_FOCUS:
- li->isActive = 1;
- listboxDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_UNFOCUS:
- li->isActive = 0;
- listboxDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case EV_MOUSE:
- /* if this mouse click was within the listbox, make the current
- item the item clicked on. */
- /* Up scroll arrow */
- if (li->sb &&
- ev.u.mouse.x == co->left + co->width - li->bdxAdjust - 1 &&
- ev.u.mouse.y == co->top + li->bdyAdjust) {
- if(li->numItems <= 0) break;
- if(li->currItem > 0) {
- li->currItem--;
- if(li->currItem < li->startShowItem)
- li->startShowItem = li->currItem;
- if(li->sb)
- newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
- listboxDraw(co);
- }
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- break;
- }
- /* Down scroll arrow */
- if (li->sb &&
- ev.u.mouse.x == co->left + co->width - li->bdxAdjust - 1 &&
- ev.u.mouse.y == co->top + co->height - li->bdyAdjust - 1) {
- if(li->numItems <= 0) break;
- if(li->currItem < li->numItems - 1) {
- li->currItem++;
- if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
- li->startShowItem = li->currItem - li->curHeight + 1;
- if(li->startShowItem + li->curHeight > li->numItems)
- li->startShowItem = li->numItems - li->curHeight;
- }
- if(li->sb)
- newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
- listboxDraw(co);
- }
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- break;
- }
- if ((ev.u.mouse.y >= co->top + li->bdyAdjust) &&
- (ev.u.mouse.y <= co->top + co->height - (li->bdyAdjust * 2)) &&
- (ev.u.mouse.x >= co->left + li->bdxAdjust) &&
- (ev.u.mouse.x <= co->left + co->width + (li->bdxAdjust * 2))) {
- li->currItem = li->startShowItem +
- (ev.u.mouse.y - li->bdyAdjust - co->top);
- newtListboxRealSetCurrent(co);
- listboxDraw(co);
- if(co->callback) co->callback(co, co->callbackData);
- er.result = ER_SWALLOWED;
- break;
- }
- }
-
- return er;
-}
-
-static void listboxDestroy(newtComponent co) {
- struct listbox * li = co->data;
- struct items * item, * nextitem;
-
- nextitem = item = li->boxItems;
-
- while (item != NULL) {
- nextitem = item->next;
- free(item->text);
- free(item);
- item = nextitem;
- }
-
- if (li->sb) li->sb->ops->destroy(li->sb);
-
- free(li);
- free(co);
-}
diff --git a/mdk-stage1/newt/newt.c b/mdk-stage1/newt/newt.c
deleted file mode 100644
index a41b7900b..000000000
--- a/mdk-stage1/newt/newt.c
+++ /dev/null
@@ -1,672 +0,0 @@
-#include <slang.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/signal.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct Window {
- int height, width, top, left;
- short * buffer;
- char * title;
-};
-
-struct keymap {
- char * str;
- int code;
- char * tc;
-};
-
-static struct Window windowStack[20];
-static struct Window * currentWindow = NULL;
-
-static char * helplineStack[20];
-static char ** currentHelpline = NULL;
-
-static int cursorRow, cursorCol;
-static int needResize;
-static int cursorOn = 1;
-
-static const char * defaultHelpLine =
-" <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen"
-;
-
-const struct newtColors newtDefaultColorPalette = {
- "cyan", "black", /* root fg, bg */
- "black", "blue", /* border fg, bg */
- "white", "blue", /* window fg, bg */
- "white", "black", /* shadow fg, bg */
- "white", "blue", /* title fg, bg */
- "black", "cyan", /* button fg, bg */
- "yellow", "cyan", /* active button fg, bg */
- "yellow", "blue", /* checkbox fg, bg */
- "blue", "brown", /* active checkbox fg, bg */
- "yellow", "blue", /* entry box fg, bg */
- "white", "blue", /* label fg, bg */
- "black", "cyan", /* listbox fg, bg */
- "yellow", "cyan", /* active listbox fg, bg */
- "white", "blue", /* textbox fg, bg */
- "cyan", "black", /* active textbox fg, bg */
- "white", "blue", /* help line */
- "yellow", "blue", /* root text */
- "blue", /* scale full */
- "red", /* scale empty */
- "blue", "cyan", /* disabled entry fg, bg */
- "white", "blue", /* compact button fg, bg */
- "yellow", "red", /* active & sel listbox */
- "black", "brown" /* selected listbox */
-};
-
-static const struct keymap keymap[] = {
- { "\033OA", NEWT_KEY_UP, "kh" },
- { "\033[A", NEWT_KEY_UP, "ku" },
- { "\033OB", NEWT_KEY_DOWN, "kd" },
- { "\033[B", NEWT_KEY_DOWN, "kd" },
- { "\033[C", NEWT_KEY_RIGHT, "kr" },
- { "\033OC", NEWT_KEY_RIGHT, "kr" },
- { "\033[D", NEWT_KEY_LEFT, "kl" },
- { "\033OD", NEWT_KEY_LEFT, "kl" },
- { "\033[H", NEWT_KEY_HOME, "kh" },
- { "\033[1~", NEWT_KEY_HOME, "kh" },
- { "\033Ow", NEWT_KEY_END, "kH" },
- { "\033[4~", NEWT_KEY_END, "kH" },
-
- { "\033[3~", NEWT_KEY_DELETE, "kl" },
- { "\033[2~", NEWT_KEY_INSERT, NULL },
-
- { "\033\t", NEWT_KEY_UNTAB, NULL },
-
- { "\033[5~", NEWT_KEY_PGUP, NULL },
- { "\033[6~", NEWT_KEY_PGDN, NULL },
- { "\033V", NEWT_KEY_PGUP, "kH" },
- { "\033v", NEWT_KEY_PGUP, "kH" },
-
- { "\033[[A", NEWT_KEY_F1, NULL },
- { "\033[[B", NEWT_KEY_F2, NULL },
- { "\033[[C", NEWT_KEY_F3, NULL },
- { "\033[[D", NEWT_KEY_F4, NULL },
- { "\033[[E", NEWT_KEY_F5, NULL },
-
- { "\033OP", NEWT_KEY_F1, NULL },
- { "\033OQ", NEWT_KEY_F2, NULL },
- { "\033OR", NEWT_KEY_F3, NULL },
- { "\033OS", NEWT_KEY_F4, NULL },
-
- { "\033[11~", NEWT_KEY_F1, NULL },
- { "\033[12~", NEWT_KEY_F2, NULL },
- { "\033[13~", NEWT_KEY_F3, NULL },
- { "\033[14~", NEWT_KEY_F4, NULL },
- { "\033[15~", NEWT_KEY_F5, NULL },
- { "\033[17~", NEWT_KEY_F6, NULL },
- { "\033[18~", NEWT_KEY_F7, NULL },
- { "\033[19~", NEWT_KEY_F8, NULL },
- { "\033[20~", NEWT_KEY_F9, NULL },
- { "\033[21~", NEWT_KEY_F10, NULL },
- { "\033[23~", NEWT_KEY_F11, NULL },
- { "\033[24~", NEWT_KEY_F12, NULL },
-
- { NULL, 0, NULL }, /* LEAVE this one */
-};
-static char keyPrefix = '\033';
-
-static const char * version = "Newt windowing library version " VERSION
- " - (C) 1996-2000 Red Hat Software. "
- "Redistributable under the term of the Library "
- "GNU Public License. "
- "Written by Erik Troan\n";
-
-static newtSuspendCallback suspendCallback = NULL;
-static void * suspendCallbackData = NULL;
-
-void newtSetSuspendCallback(newtSuspendCallback cb, void * data) {
- suspendCallback = cb;
- suspendCallbackData = data;
-}
-
-static void handleSigwinch(int signum __attribute__ ((unused))) {
- needResize = 1;
-}
-
-static int getkeyInterruptHook(void) {
- return -1;
-}
-
-void newtFlushInput(void) {
- while (SLang_input_pending(0)) {
- SLang_getkey();
- }
-}
-
-void newtRefresh(void) {
- SLsmg_refresh();
-}
-
-void newtSuspend(void) {
- SLtt_set_cursor_visibility (1);
- SLsmg_suspend_smg();
- SLang_reset_tty();
- SLtt_set_cursor_visibility (cursorOn);
-}
-
-void newtResume(void) {
- SLsmg_resume_smg ();
- SLsmg_refresh();
- SLang_init_tty(0, 0, 0);
-}
-
-void newtCls(void) {
- SLsmg_set_color(NEWT_COLORSET_ROOT);
- SLsmg_gotorc(0, 0);
- SLsmg_erase_eos();
-
- newtRefresh();
-}
-
-#if defined(THIS_DOESNT_WORK)
-void newtResizeScreen(int redraw) {
- newtPushHelpLine("");
-
- SLtt_get_screen_size();
- SLang_init_tty(0, 0, 0);
-
- SLsmg_touch_lines (0, SLtt_Screen_Rows - 1);
-
- /* I don't know why I need this */
- SLsmg_refresh();
-
- newtPopHelpLine();
-
- if (redraw)
- SLsmg_refresh();
-}
-#endif
-
-int newtInit(void) {
- char * MonoValue, * MonoEnv = "NEWT_MONO";
-
- /* use the version variable just to be sure it gets included */
- strlen(version);
-
- SLtt_get_terminfo();
- SLtt_get_screen_size();
-
- MonoValue = getenv(MonoEnv);
- if ( MonoValue == NULL ) {
- SLtt_Use_Ansi_Colors = 1;
- } else {
- SLtt_Use_Ansi_Colors = 0;
- }
-
- SLsmg_init_smg();
- SLang_init_tty(0, 0, 0);
-
- newtSetColors(newtDefaultColorPalette);
- newtCursorOff();
- /*initKeymap();*/
-
- /*memset(&sa, 0, sizeof(sa));
- sa.sa_handler = handleSigwinch;
- sigaction(SIGWINCH, &sa, NULL);*/
-
- SLsignal_intr(SIGWINCH, handleSigwinch);
- SLang_getkey_intr_hook = getkeyInterruptHook;
-
-
-
- return 0;
-}
-
-int newtFinished(void) {
- SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
- newtCursorOn();
- SLsmg_refresh();
- SLsmg_reset_smg();
- SLang_reset_tty();
-
- return 0;
-}
-
-void newtSetColors(struct newtColors colors) {
- SLtt_set_color(NEWT_COLORSET_ROOT, "", colors.rootFg, colors.rootBg);
- SLtt_set_color(NEWT_COLORSET_BORDER, "", colors.borderFg, colors.borderBg);
- SLtt_set_color(NEWT_COLORSET_WINDOW, "", colors.windowFg, colors.windowBg);
- SLtt_set_color(NEWT_COLORSET_SHADOW, "", colors.shadowFg, colors.shadowBg);
- SLtt_set_color(NEWT_COLORSET_TITLE, "", colors.titleFg, colors.titleBg);
- SLtt_set_color(NEWT_COLORSET_BUTTON, "", colors.buttonFg, colors.buttonBg);
- SLtt_set_color(NEWT_COLORSET_ACTBUTTON, "", colors.actButtonFg,
- colors.actButtonBg);
- SLtt_set_color(NEWT_COLORSET_CHECKBOX, "", colors.checkboxFg,
- colors.checkboxBg);
- SLtt_set_color(NEWT_COLORSET_ACTCHECKBOX, "", colors.actCheckboxFg,
- colors.actCheckboxBg);
- SLtt_set_color(NEWT_COLORSET_ENTRY, "", colors.entryFg, colors.entryBg);
- SLtt_set_color(NEWT_COLORSET_LABEL, "", colors.labelFg, colors.labelBg);
- SLtt_set_color(NEWT_COLORSET_LISTBOX, "", colors.listboxFg,
- colors.listboxBg);
- SLtt_set_color(NEWT_COLORSET_ACTLISTBOX, "", colors.actListboxFg,
- colors.actListboxBg);
- SLtt_set_color(NEWT_COLORSET_TEXTBOX, "", colors.textboxFg,
- colors.textboxBg);
- SLtt_set_color(NEWT_COLORSET_ACTTEXTBOX, "", colors.actTextboxFg,
- colors.actTextboxBg);
- SLtt_set_color(NEWT_COLORSET_HELPLINE, "", colors.helpLineFg,
- colors.helpLineBg);
- SLtt_set_color(NEWT_COLORSET_ROOTTEXT, "", colors.rootTextFg,
- colors.rootTextBg);
-
- SLtt_set_color(NEWT_COLORSET_EMPTYSCALE, "", "black",
- colors.emptyScale);
- SLtt_set_color(NEWT_COLORSET_FULLSCALE, "", "black",
- colors.fullScale);
- SLtt_set_color(NEWT_COLORSET_DISENTRY, "", colors.disabledEntryFg,
- colors.disabledEntryBg);
-
- SLtt_set_color(NEWT_COLORSET_COMPACTBUTTON, "", colors.compactButtonFg,
- colors.compactButtonBg);
-
- SLtt_set_color(NEWT_COLORSET_ACTSELLISTBOX, "", colors.actSelListboxFg,
- colors.actSelListboxBg);
- SLtt_set_color(NEWT_COLORSET_SELLISTBOX, "", colors.selListboxFg,
- colors.selListboxBg);
-}
-
-int newtGetKey(void) {
- int key;
- char buf[10], * chptr = buf;
- const struct keymap * curr;
-
- do {
- key = SLang_getkey();
- if (key == 0xFFFF) {
- if (needResize)
- return NEWT_KEY_RESIZE;
-
- /* ignore other signals */
- continue;
- }
-
- if (key == NEWT_KEY_SUSPEND && suspendCallback)
- suspendCallback(suspendCallbackData);
- } while (key == NEWT_KEY_SUSPEND);
-
- switch (key) {
- case 'v' | 0x80:
- case 'V' | 0x80:
- return NEWT_KEY_PGUP;
-
- case 22:
- return NEWT_KEY_PGDN;
-
- return NEWT_KEY_BKSPC;
- case 0x7f:
- return NEWT_KEY_BKSPC;
-
- case 0x08:
- return NEWT_KEY_BKSPC;
-
- default:
- if (key != keyPrefix) return key;
- }
-
- memset(buf, 0, sizeof(buf));
-
- *chptr++ = key;
- while (SLang_input_pending(5)) {
- key = SLang_getkey();
- if (key == keyPrefix) {
- /* he hit unknown keys too many times -- start over */
- memset(buf, 0, sizeof(buf));
- chptr = buf;
- }
-
- *chptr++ = key;
-
- /* this search should use bsearch(), but when we only look through
- a list of 20 (or so) keymappings, it's probably faster just to
- do a inline linear search */
-
- for (curr = keymap; curr->code; curr++) {
- if (curr->str) {
- if (!strcmp(curr->str, buf))
- return curr->code;
- }
- }
- }
-
- for (curr = keymap; curr->code; curr++) {
- if (curr->str) {
- if (!strcmp(curr->str, buf))
- return curr->code;
- }
- }
-
- /* Looks like we were a bit overzealous in reading characters. Return
- just the first character, and put everything else back in the buffer
- for later */
-
- chptr--;
- while (chptr > buf)
- SLang_ungetkey(*chptr--);
-
- return *chptr;
-}
-
-void newtWaitForKey(void) {
- newtRefresh();
-
- SLang_getkey();
- newtClearKeyBuffer();
-}
-
-void newtClearKeyBuffer(void) {
- while (SLang_input_pending(1)) {
- SLang_getkey();
- }
-}
-
-int newtOpenWindow(int left, int top, int width, int height,
- const char * title) {
- int j, row, col;
- int n;
- int i;
-
- newtFlushInput();
-
- if (!currentWindow) {
- currentWindow = windowStack;
- } else {
- currentWindow++;
- }
-
- currentWindow->left = left;
- currentWindow->top = top;
- currentWindow->width = width;
- currentWindow->height = height;
- currentWindow->title = title ? strdup(title) : NULL;
-
- currentWindow->buffer = malloc(sizeof(short) * (width + 3) * (height + 3));
-
- row = top - 1;
- col = left - 1;
- n = 0;
- for (j = 0; j < height + 3; j++, row++) {
- SLsmg_gotorc(row, col);
- SLsmg_read_raw((SLsmg_Char_Type *)currentWindow->buffer + n,
- currentWindow->width + 3);
- n += currentWindow->width + 3;
- }
-
- SLsmg_set_color(NEWT_COLORSET_BORDER);
- SLsmg_draw_box(top - 1, left - 1, height + 2, width + 2);
-
- if (currentWindow->title) {
- i = strlen(currentWindow->title) + 4;
- i = ((width - i) / 2) + left;
- SLsmg_gotorc(top - 1, i);
- SLsmg_set_char_set(1);
- SLsmg_write_char(SLSMG_RTEE_CHAR);
- SLsmg_set_char_set(0);
- SLsmg_write_char(' ');
- SLsmg_set_color(NEWT_COLORSET_TITLE);
- SLsmg_write_string((char *)currentWindow->title);
- SLsmg_set_color(NEWT_COLORSET_BORDER);
- SLsmg_write_char(' ');
- SLsmg_set_char_set(1);
- SLsmg_write_char(SLSMG_LTEE_CHAR);
- SLsmg_set_char_set(0);
- }
-
- SLsmg_set_color(NEWT_COLORSET_WINDOW);
- SLsmg_fill_region(top, left, height, width, ' ');
-
- SLsmg_set_color(NEWT_COLORSET_SHADOW);
- SLsmg_fill_region(top + height + 1, left, 1, width + 2, ' ');
- SLsmg_fill_region(top, left + width + 1, height + 1, 1, ' ');
-
- for (i = top; i < (top + height + 1); i++) {
- SLsmg_gotorc(i, left + width + 1);
- SLsmg_write_string(" ");
- }
-
- return 0;
-}
-
-int newtCenteredWindow(int width, int height, const char * title) {
- int top, left;
-
- top = (SLtt_Screen_Rows - height) / 2;
-
- /* I don't know why, but this seems to look better */
- if ((SLtt_Screen_Rows % 2) && (top % 2)) top--;
-
- left = (SLtt_Screen_Cols - width) / 2;
-
- newtOpenWindow(left, top, width, height, title);
-
- return 0;
-}
-
-void newtPopWindow(void) {
- int j, row, col;
- int n = 0;
-
- row = col = 0;
-
- row = currentWindow->top - 1;
- col = currentWindow->left - 1;
- for (j = 0; j < currentWindow->height + 3; j++, row++) {
- SLsmg_gotorc(row, col);
- SLsmg_write_raw((SLsmg_Char_Type *)currentWindow->buffer + n,
- currentWindow->width + 3);
- n += currentWindow->width + 3;
- }
-
- free(currentWindow->buffer);
- free(currentWindow->title);
-
- if (currentWindow == windowStack)
- currentWindow = NULL;
- else
- currentWindow--;
-
- SLsmg_set_char_set(0);
-
- newtRefresh();
-}
-
-void newtGetWindowPos(int * x, int * y) {
- if (currentWindow) {
- *x = currentWindow->left;
- *y = currentWindow->top;
- } else
- *x = *y = 0;
-}
-
-void newtGetrc(int * row, int * col) {
- *row = cursorRow;
- *col = cursorCol;
-}
-
-void newtGotorc(int newRow, int newCol) {
- if (currentWindow) {
- newRow += currentWindow->top;
- newCol += currentWindow->left;
- }
-
- cursorRow = newRow;
- cursorCol = newCol;
- SLsmg_gotorc(cursorRow, cursorCol);
-}
-
-void newtDrawBox(int left, int top, int width, int height, int shadow) {
- if (currentWindow) {
- top += currentWindow->top;
- left += currentWindow->left;
- }
-
- SLsmg_draw_box(top, left, height, width);
-
- if (shadow) {
- SLsmg_set_color(NEWT_COLORSET_SHADOW);
- SLsmg_fill_region(top + height, left + 1, 1, width - 1, ' ');
- SLsmg_fill_region(top + 1, left + width, height, 1, ' ');
- }
-}
-
-void newtClearBox(int left, int top, int width, int height) {
- if (currentWindow) {
- top += currentWindow->top;
- left += currentWindow->left;
- }
-
- SLsmg_fill_region(top, left, height, width, ' ');
-}
-
-#if 0
-/* This doesn't seem to work quite right. I don't know why not, but when
- I rsh from an rxvt into a box and run this code, the machine returns
- console key's (\033[B) rather then xterm ones (\033OB). */
-static void initKeymap(void) {
- struct keymap * curr;
-
- for (curr = keymap; curr->code; curr++) {
- if (!curr->str)
- curr->str = SLtt_tgetstr(curr->tc);
- }
-
- /* Newt's keymap handling is a bit broken. It assumes that any extended
- keystrokes begin with ESC. If you're using a homebrek terminal you
- will probably need to fix this, or just yell at me and I'll be so
- ashamed of myself for doing it this way I'll fix it */
-
- keyPrefix = 0x1b; /* ESC */
-}
-#endif
-
-void newtDelay(int usecs) {
- fd_set set;
- struct timeval tv;
-
- FD_ZERO(&set);
-
- tv.tv_sec = usecs / 1000000;
- tv.tv_usec = usecs % 1000000;
-
- select(0, &set, &set, &set, &tv);
-}
-
-struct eventResult newtDefaultEventHandler(newtComponent c __attribute__ ((unused)),
- struct event ev __attribute__ ((unused))) {
- struct eventResult er;
-
- er.result = ER_IGNORED;
- return er;
-}
-
-void newtRedrawHelpLine(void) {
- char * buf;
-
- SLsmg_set_color(NEWT_COLORSET_HELPLINE);
-
- buf = alloca(SLtt_Screen_Cols + 1);
- memset(buf, ' ', SLtt_Screen_Cols);
- buf[SLtt_Screen_Cols] = '\0';
-
- if (currentHelpline)
- memcpy(buf, *currentHelpline, strlen(*currentHelpline));
-
- SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
- SLsmg_write_string(buf);
-}
-
-void newtPushHelpLine(const char * text) {
- if (!text)
- text = defaultHelpLine;
-
- if (currentHelpline)
- (*(++currentHelpline)) = strdup(text);
- else {
- currentHelpline = helplineStack;
- *currentHelpline = strdup(text);
- }
-
- newtRedrawHelpLine();
-}
-
-void newtPopHelpLine(void) {
- if (!currentHelpline) return;
-
- free(*currentHelpline);
- if (currentHelpline == helplineStack)
- currentHelpline = NULL;
- else
- currentHelpline--;
-
- newtRedrawHelpLine();
-}
-
-void newtDrawRootText(int col, int row, const char * text) {
- SLsmg_set_color(NEWT_COLORSET_ROOTTEXT);
-
- if (col < 0) {
- col = SLtt_Screen_Cols + col;
- }
-
- if (row < 0) {
- row = SLtt_Screen_Rows + row;
- }
-
- SLsmg_gotorc(row, col);
- SLsmg_write_string((char *)text);
-}
-
-int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense) {
- switch (sense) {
- case NEWT_FLAGS_SET:
- return oldFlags | newFlags;
-
- case NEWT_FLAGS_RESET:
- return oldFlags & (~newFlags);
-
- case NEWT_FLAGS_TOGGLE:
- return oldFlags ^ newFlags;
-
- default:
- return oldFlags;
- }
-}
-
-void newtBell(void)
-{
- SLtt_beep();
-}
-
-void newtGetScreenSize(int * cols, int * rows) {
- if (rows) *rows = SLtt_Screen_Rows;
- if (cols) *cols = SLtt_Screen_Cols;
-}
-
-void newtDefaultPlaceHandler(newtComponent c, int newLeft, int newTop) {
- c->left = newLeft;
- c->top = newTop;
-}
-
-void newtDefaultMappedHandler(newtComponent c, int isMapped) {
- c->isMapped = isMapped;
-}
-
-void newtCursorOff(void) {
- cursorOn = 0;
- SLtt_set_cursor_visibility (cursorOn);
-}
-
-void newtCursorOn(void) {
- cursorOn = 1;
- SLtt_set_cursor_visibility (cursorOn);
-}
diff --git a/mdk-stage1/newt/newt.h b/mdk-stage1/newt/newt.h
deleted file mode 100644
index d3fd8bedc..000000000
--- a/mdk-stage1/newt/newt.h
+++ /dev/null
@@ -1,362 +0,0 @@
-#ifndef H_NEWT
-#define H_NEWT
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdarg.h>
-
-#define NEWT_COLORSET_ROOT 2
-#define NEWT_COLORSET_BORDER 3
-#define NEWT_COLORSET_WINDOW 4
-#define NEWT_COLORSET_SHADOW 5
-#define NEWT_COLORSET_TITLE 6
-#define NEWT_COLORSET_BUTTON 7
-#define NEWT_COLORSET_ACTBUTTON 8
-#define NEWT_COLORSET_CHECKBOX 9
-#define NEWT_COLORSET_ACTCHECKBOX 10
-#define NEWT_COLORSET_ENTRY 11
-#define NEWT_COLORSET_LABEL 12
-#define NEWT_COLORSET_LISTBOX 13
-#define NEWT_COLORSET_ACTLISTBOX 14
-#define NEWT_COLORSET_TEXTBOX 15
-#define NEWT_COLORSET_ACTTEXTBOX 16
-#define NEWT_COLORSET_HELPLINE 17
-#define NEWT_COLORSET_ROOTTEXT 18
-#define NEWT_COLORSET_EMPTYSCALE 19
-#define NEWT_COLORSET_FULLSCALE 20
-#define NEWT_COLORSET_DISENTRY 21
-#define NEWT_COLORSET_COMPACTBUTTON 22
-#define NEWT_COLORSET_ACTSELLISTBOX 23
-#define NEWT_COLORSET_SELLISTBOX 24
-
-#define NEWT_ARG_LAST -100000
-#define NEWT_ARG_APPEND -1
-
-struct newtColors {
- char * rootFg, * rootBg;
- char * borderFg, * borderBg;
- char * windowFg, * windowBg;
- char * shadowFg, * shadowBg;
- char * titleFg, * titleBg;
- char * buttonFg, * buttonBg;
- char * actButtonFg, * actButtonBg;
- char * checkboxFg, * checkboxBg;
- char * actCheckboxFg, * actCheckboxBg;
- char * entryFg, * entryBg;
- char * labelFg, * labelBg;
- char * listboxFg, * listboxBg;
- char * actListboxFg, * actListboxBg;
- char * textboxFg, * textboxBg;
- char * actTextboxFg, * actTextboxBg;
- char * helpLineFg, * helpLineBg;
- char * rootTextFg, * rootTextBg;
- char * emptyScale, * fullScale;
- char * disabledEntryFg, * disabledEntryBg;
- char * compactButtonFg, * compactButtonBg;
- char * actSelListboxFg, * actSelListboxBg;
- char * selListboxFg, * selListboxBg;
-};
-
-enum newtFlagsSense { NEWT_FLAGS_SET, NEWT_FLAGS_RESET, NEWT_FLAGS_TOGGLE };
-
-#define NEWT_FLAG_RETURNEXIT (1 << 0)
-#define NEWT_FLAG_HIDDEN (1 << 1)
-#define NEWT_FLAG_SCROLL (1 << 2)
-#define NEWT_FLAG_DISABLED (1 << 3)
-/* OBSOLETE #define NEWT_FLAG_NOSCROLL (1 << 4) for listboxes */
-#define NEWT_FLAG_BORDER (1 << 5)
-#define NEWT_FLAG_WRAP (1 << 6)
-#define NEWT_FLAG_NOF12 (1 << 7)
-#define NEWT_FLAG_MULTIPLE (1 << 8)
-#define NEWT_FLAG_SELECTED (1 << 9)
-#define NEWT_FLAG_CHECKBOX (1 << 10)
-#define NEWT_FLAG_PASSWORD (1 << 11) /* draw '*' of chars in entrybox */
-#define NEWT_FD_READ (1 << 0)
-#define NEWT_FD_WRITE (1 << 1)
-
-#define NEWT_CHECKBOXTREE_COLLAPSED '\0'
-#define NEWT_CHECKBOXTREE_EXPANDED '\1'
-#define NEWT_CHECKBOXTREE_UNSELECTED ' '
-#define NEWT_CHECKBOXTREE_SELECTED '*'
-
-/* Backwards compatibility */
-#define NEWT_LISTBOX_RETURNEXIT NEWT_FLAG_RETURNEXIT
-#define NEWT_ENTRY_SCROLL NEWT_FLAG_SCROLL
-#define NEWT_ENTRY_HIDDEN NEWT_FLAG_HIDDEN
-#define NEWT_ENTRY_RETURNEXIT NEWT_FLAG_RETURNEXIT
-#define NEWT_ENTRY_DISABLED NEWT_FLAG_DISABLED
-
-#define NEWT_TEXTBOX_WRAP NEWT_FLAG_WRAP
-#define NEWT_TEXTBOX_SCROLL NEWT_FLAG_SCROLL
-#define NEWT_FORM_NOF12 NEWT_FLAG_NOF12
-
-#define newtListboxAddEntry newtListboxAppendEntry
-
-
-typedef struct newtComponent_struct * newtComponent;
-
-extern const struct newtColors newtDefaultColorPalette;
-
-typedef void (*newtCallback)(newtComponent, void *);
-typedef void (*newtSuspendCallback)(void * data);
-
-int newtInit(void);
-int newtFinished(void);
-void newtCls(void);
-void newtResizeScreen(int redraw);
-void newtWaitForKey(void);
-void newtClearKeyBuffer(void);
-void newtDelay(int usecs);
-/* top, left are *not* counting the border */
-int newtOpenWindow(int left, int top, int width, int height,
- const char * title);
-int newtCenteredWindow(int width, int height, const char * title);
-void newtPopWindow(void);
-void newtSetColors(struct newtColors colors);
-void newtRefresh(void);
-void newtSuspend(void);
-void newtSetSuspendCallback(newtSuspendCallback cb, void * data);
-void newtSetHelpCallback(newtCallback cb);
-void newtResume(void);
-void newtPushHelpLine(const char * text);
-void newtRedrawHelpLine(void);
-void newtPopHelpLine(void);
-void newtDrawRootText(int col, int row, const char * text);
-void newtBell(void);
-void newtCursorOff(void);
-void newtCursorOn(void);
-
-/* Components */
-
-newtComponent newtCompactButton(int left, int top, const char * text);
-newtComponent newtButton(int left, int top, const char * text);
-newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
- const char * seq, char * result);
-char newtCheckboxGetValue(newtComponent co);
-void newtCheckboxSetValue(newtComponent co, char value);
-void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
-
-
-newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
- newtComponent prevButton);
-newtComponent newtRadioGetCurrent(newtComponent setMember);
-newtComponent newtListitem(int left, int top, const char * text, int isDefault,
- newtComponent prevItem, const void * data, int flags);
-void newtListitemSet(newtComponent co, const char * text);
-void * newtListitemGetData(newtComponent co);
-void newtGetScreenSize(int * cols, int * rows);
-
-newtComponent newtLabel(int left, int top, const char * text);
-void newtLabelSetText(newtComponent co, const char * text);
-newtComponent newtVerticalScrollbar(int left, int top, int height,
- int normalColorset, int thumbColorset);
-void newtScrollbarSet(newtComponent co, int where, int total);
-
-newtComponent newtListbox(int left, int top, int height, int flags);
-void * newtListboxGetCurrent(newtComponent co);
-void newtListboxSetCurrent(newtComponent co, int num);
-void newtListboxSetCurrentByKey(newtComponent co, void * key);
-void newtListboxSetEntry(newtComponent co, int num, const char * text);
-void newtListboxSetWidth(newtComponent co, int width);
-void newtListboxSetData(newtComponent co, int num, void * data);
-int newtListboxAppendEntry(newtComponent co, const char * text,
- const void * data);
-/* Send the key to insert after, or NULL to insert at the top */
-int newtListboxInsertEntry(newtComponent co, const char * text, const void * data, void * key);
-int newtListboxDeleteEntry(newtComponent co, void * data);
-void newtListboxClear(newtComponent co); /* removes all entries from listbox */
-void newtListboxGetEntry(newtComponent co, int num, char **text, void **data);
-/* Returns an array of data pointers from items, last element is NULL */
-void **newtListboxGetSelection(newtComponent co, int *numitems);
-void newtListboxClearSelection(newtComponent co);
-void newtListboxSelectItem(newtComponent co, const void * key,
- enum newtFlagsSense sense);
-
-newtComponent newtCheckboxTree(int left, int top, int height, int flags);
-newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, int flags);
-const void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems);
-const void * newtCheckboxTreeGetCurrent(newtComponent co);
-const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum);
-/* last item is NEWT_ARG_LAST for all of these */
-int newtCheckboxTreeAddItem(newtComponent co,
- const char * text, const void * data,
- int flags, int index, ...);
-int newtCheckboxTreeAddArray(newtComponent co,
- const char * text, const void * data,
- int flags, int * indexes);
-int * newtCheckboxTreeFindItem(newtComponent co, void * data);
-void newtCheckboxTreeSetEntry(newtComponent co, const void * data,
- const char * text);
-char newtCheckboxTreeGetEntryValue(newtComponent co, const void * data);
-void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data,
- char value);
-
-newtComponent newtTextboxReflowed(int left, int top, char * text, int width,
- int flexDown, int flexUp, int flags);
-newtComponent newtTextbox(int left, int top, int width, int height, int flags);
-void newtTextboxSetText(newtComponent co, const char * text);
-void newtTextboxSetHeight(newtComponent co, int height);
-int newtTextboxGetNumLines(newtComponent co);
-char * newtReflowText(char * text, int width, int flexDown, int flexUp,
- int * actualWidth, int * actualHeight);
-
-struct newtExitStruct {
- enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY,
- NEWT_EXIT_TIMER } reason;
- union {
- int key;
- newtComponent co;
- } u;
-} ;
-
-newtComponent newtForm(newtComponent vertBar, void * helpTag, int flags);
-void newtFormSetTimer(newtComponent form, int millisecs);
-void newtFormWatchFd(newtComponent form, int fd, int fdFlags);
-void newtFormSetSize(newtComponent co);
-newtComponent newtFormGetCurrent(newtComponent co);
-void newtFormSetBackground(newtComponent co, int color);
-void newtFormSetCurrent(newtComponent co, newtComponent subco);
-void newtFormAddComponent(newtComponent form, newtComponent co);
-void newtFormAddComponents(newtComponent form, ...);
-void newtFormSetHeight(newtComponent co, int height);
-void newtFormSetWidth(newtComponent co, int width);
-newtComponent newtRunForm(newtComponent form); /* obsolete */
-void newtFormRun(newtComponent co, struct newtExitStruct * es);
-void newtDrawForm(newtComponent form);
-void newtFormAddHotKey(newtComponent co, int key);
-
-typedef int (*newtEntryFilter)(newtComponent entry, void * data, int ch,
- int cursor);
-newtComponent newtEntry(int left, int top, const char * initialValue, int width,
- char ** resultPtr, int flags);
-void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd);
-void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data);
-char * newtEntryGetValue(newtComponent co);
-void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
-
-newtComponent newtScale(int left, int top, int width, int fullValue);
-void newtScaleSet(newtComponent co, unsigned int amount);
-
-void newtComponentAddCallback(newtComponent co, newtCallback f, void * data);
-void newtComponentTakesFocus(newtComponent co, int val);
-
-/* this also destroys all of the components (including other forms) on the
- form */
-void newtFormDestroy(newtComponent form);
-
-/* Key codes */
-
-#define NEWT_KEY_TAB '\t'
-#define NEWT_KEY_ENTER '\r'
-#define NEWT_KEY_SUSPEND '\032' /* ctrl - z*/
-#define NEWT_KEY_RETURN NEWT_KEY_ENTER
-
-#define NEWT_KEY_EXTRA_BASE 0x8000
-#define NEWT_KEY_UP NEWT_KEY_EXTRA_BASE + 1
-#define NEWT_KEY_DOWN NEWT_KEY_EXTRA_BASE + 2
-#define NEWT_KEY_LEFT NEWT_KEY_EXTRA_BASE + 4
-#define NEWT_KEY_RIGHT NEWT_KEY_EXTRA_BASE + 5
-#define NEWT_KEY_BKSPC NEWT_KEY_EXTRA_BASE + 6
-#define NEWT_KEY_DELETE NEWT_KEY_EXTRA_BASE + 7
-#define NEWT_KEY_HOME NEWT_KEY_EXTRA_BASE + 8
-#define NEWT_KEY_END NEWT_KEY_EXTRA_BASE + 9
-#define NEWT_KEY_UNTAB NEWT_KEY_EXTRA_BASE + 10
-#define NEWT_KEY_PGUP NEWT_KEY_EXTRA_BASE + 11
-#define NEWT_KEY_PGDN NEWT_KEY_EXTRA_BASE + 12
-#define NEWT_KEY_INSERT NEWT_KEY_EXTRA_BASE + 13
-
-#define NEWT_KEY_F1 NEWT_KEY_EXTRA_BASE + 101
-#define NEWT_KEY_F2 NEWT_KEY_EXTRA_BASE + 102
-#define NEWT_KEY_F3 NEWT_KEY_EXTRA_BASE + 103
-#define NEWT_KEY_F4 NEWT_KEY_EXTRA_BASE + 104
-#define NEWT_KEY_F5 NEWT_KEY_EXTRA_BASE + 105
-#define NEWT_KEY_F6 NEWT_KEY_EXTRA_BASE + 106
-#define NEWT_KEY_F7 NEWT_KEY_EXTRA_BASE + 107
-#define NEWT_KEY_F8 NEWT_KEY_EXTRA_BASE + 108
-#define NEWT_KEY_F9 NEWT_KEY_EXTRA_BASE + 109
-#define NEWT_KEY_F10 NEWT_KEY_EXTRA_BASE + 110
-#define NEWT_KEY_F11 NEWT_KEY_EXTRA_BASE + 111
-#define NEWT_KEY_F12 NEWT_KEY_EXTRA_BASE + 112
-
-/* not really a key, but newtGetKey returns it */
-#define NEWT_KEY_RESIZE NEWT_KEY_EXTRA_BASE + 113
-
-#define NEWT_ANCHOR_LEFT (1 << 0)
-#define NEWT_ANCHOR_RIGHT (1 << 1)
-#define NEWT_ANCHOR_TOP (1 << 2)
-#define NEWT_ANCHOR_BOTTOM (1 << 3)
-
-#define NEWT_GRID_FLAG_GROWX (1 << 0)
-#define NEWT_GRID_FLAG_GROWY (1 << 1)
-
-typedef struct grid_s * newtGrid;
-enum newtGridElement { NEWT_GRID_EMPTY = 0,
- NEWT_GRID_COMPONENT, NEWT_GRID_SUBGRID };
-
-newtGrid newtCreateGrid(int cols, int rows);
-/* TYPE, what, TYPE, what, ..., NULL */
-newtGrid newtGridVStacked(enum newtGridElement type, void * what, ...);
-newtGrid newtGridVCloseStacked(enum newtGridElement type, void * what, ...);
-newtGrid newtGridHStacked(enum newtGridElement type1, void * what1, ...);
-newtGrid newtGridHCloseStacked(enum newtGridElement type1, void * what1, ...);
-newtGrid newtGridBasicWindow(newtComponent text, newtGrid middle,
- newtGrid buttons);
-newtGrid newtGridSimpleWindow(newtComponent text, newtComponent middle,
- newtGrid buttons);
-void newtGridSetField(newtGrid grid, int col, int row,
- enum newtGridElement type, void * val, int padLeft,
- int padTop, int padRight, int padBottom, int anchor,
- int flags);
-void newtGridPlace(newtGrid grid, int left, int top);
-#define newtGridDestroy newtGridFree
-void newtGridFree(newtGrid grid, int recurse);
-void newtGridGetSize(newtGrid grid, int * width, int * height);
-void newtGridWrappedWindow(newtGrid grid, char * title);
-void newtGridWrappedWindowAt(newtGrid grid, char * title, int left, int top);
-void newtGridAddComponentsToForm(newtGrid grid, newtComponent form,
- int recurse);
-
-/* convienve */
-newtGrid newtButtonBarv(char * button1, newtComponent * b1comp, va_list args);
-newtGrid newtButtonBar(char * button1, newtComponent * b1comp, ...);
-
-/* automatically centered and shrink wrapped */
-void newtWinMessage(char * title, char * buttonText, char * text, ...);
-void newtWinMessagev(char * title, char * buttonText, char * text,
- va_list argv);
-
-/* having separate calls for these two seems silly, but having two separate
- variable length-arg lists seems like a bad idea as well */
-
-/* Returns 0 if F12 was pressed, 1 for button1, 2 for button2 */
-int newtWinChoice(char * title, char * button1, char * button2,
- char * text, ...);
-/* Returns 0 if F12 was pressed, 1 for button1, 2 for button2,
- 3 for button3 */
-int newtWinTernary(char * title, char * button1, char * button2,
- char * button3, char * message, ...);
-
-/* Returns the button number pressed, 0 on F12 */
-int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
- int flexUp, int maxListHeight, char ** items, int * listItem,
- char * button1, ...);
-
-struct newtWinEntry {
- char * text;
- char ** value; /* may be initialized to set default */
- int flags;
-};
-
-/* Returns the button number pressed, 0 on F12. The final values are
- dynamically allocated, and need to be freed. */
-int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
- int flexUp, int dataWidth,
- struct newtWinEntry * items, char * button1, ...);
-
-#ifdef __cplusplus
-} /* End of extern "C" { */
-#endif
-
-#endif /* H_NEWT */
diff --git a/mdk-stage1/newt/newt_pr.h b/mdk-stage1/newt/newt_pr.h
deleted file mode 100644
index 76f5e2f6f..000000000
--- a/mdk-stage1/newt/newt_pr.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef H_NEWT_PR
-#define H_NEWT_PR
-
-#define COLORSET_ROOT NEWT_COLORSET_ROOT
-#define COLORSET_BORDER NEWT_COLORSET_BORDER
-#define COLORSET_WINDOW NEWT_COLORSET_WINDOW
-#define COLORSET_SHADOW NEWT_COLORSET_SHADOW
-#define COLORSET_TITLE NEWT_COLORSET_TITLE
-#define COLORSET_BUTTON NEWT_COLORSET_BUTTON
-#define COLORSET_ACTBUTTON NEWT_COLORSET_ACTBUTTON
-#define COLORSET_CHECKBOX NEWT_COLORSET_CHECKBOX
-#define COLORSET_ACTCHECKBOX NEWT_COLORSET_ACTCHECKBOX
-#define COLORSET_ENTRY NEWT_COLORSET_ENTRY
-#define COLORSET_LABEL NEWT_COLORSET_LABEL
-#define COLORSET_LISTBOX NEWT_COLORSET_LISTBOX
-#define COLORSET_ACTLISTBOX NEWT_COLORSET_ACTLISTBOX
-#define COLORSET_TEXTBOX NEWT_COLORSET_TEXTBOX
-#define COLORSET_ACTTEXTBOX NEWT_COLORSET_ACTTEXTBOX
-
-int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense);
-
-void newtGotorc(int row, int col);
-void newtGetrc(int * row, int * col);
-void newtGetWindowPos(int * x, int * y);
-void newtDrawBox(int left, int top, int width, int height, int shadow);
-void newtClearBox(int left, int top, int width, int height);
-
-int newtGetKey(void);
-
-struct newtComponent_struct {
- /* common data */
- int height, width;
- int top, left;
- int takesFocus;
- int isMapped;
-
- struct componentOps * ops;
-
- newtCallback callback;
- void * callbackData;
-
- void * data;
-} ;
-
-enum eventResultTypes { ER_IGNORED, ER_SWALLOWED, ER_EXITFORM, ER_SETFOCUS,
- ER_NEXTCOMP };
-struct eventResult {
- enum eventResultTypes result;
- union {
- newtComponent focus;
- } u;
-};
-
-enum eventTypes { EV_FOCUS, EV_UNFOCUS, EV_KEYPRESS, EV_MOUSE };
-enum eventSequence { EV_EARLY, EV_NORMAL, EV_LATE };
-
-struct event {
- enum eventTypes event;
- enum eventSequence when;
- union {
- int key;
- struct {
- enum { MOUSE_MOTION, MOUSE_BUTTON_DOWN, MOUSE_BUTTON_UP } type;
- int x, y;
- } mouse;
- } u;
-} ;
-
-struct componentOps {
- void (* draw)(newtComponent c);
- struct eventResult (* event)(newtComponent c, struct event ev);
- void (* destroy)(newtComponent c);
- void (* place)(newtComponent c, int newLeft, int newTop);
- void (* mapped)(newtComponent c, int isMapped);
-} ;
-
-void newtDefaultPlaceHandler(newtComponent c, int newLeft, int newTop);
-void newtDefaultMappedHandler(newtComponent c, int isMapped);
-struct eventResult newtDefaultEventHandler(newtComponent c,
- struct event ev);
-
-#endif /* H_NEWT_PR */
diff --git a/mdk-stage1/newt/scale.c b/mdk-stage1/newt/scale.c
deleted file mode 100644
index 800958580..000000000
--- a/mdk-stage1/newt/scale.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct scale {
- int fullValue;
- int charsSet;
-};
-
-static void scaleDraw(newtComponent co);
-
-static struct componentOps scaleOps = {
- scaleDraw,
- newtDefaultEventHandler,
- NULL,
- newtDefaultPlaceHandler,
- newtDefaultMappedHandler,
-} ;
-
-newtComponent newtScale(int left, int top, int width, int fullValue) {
- newtComponent co;
- struct scale * sc;
-
- co = malloc(sizeof(*co));
- sc = malloc(sizeof(struct scale));
- co->data = sc;
-
- co->ops = &scaleOps;
-
- co->height = 1;
- co->width = width;
- co->top = top;
- co->left = left;
- co->takesFocus = 0;
-
- sc->fullValue = fullValue;
- sc->charsSet = 0;
-
- return co;
-}
-
-void newtScaleSet(newtComponent co, unsigned int amount) {
- struct scale * sc = co->data;
- int newCharsSet;
-
- newCharsSet = (amount * co->width) / sc->fullValue;
-
- if (newCharsSet != sc->charsSet) {
- sc->charsSet = newCharsSet;
- scaleDraw(co);
- }
-}
-
-static void scaleDraw(newtComponent co) {
- struct scale * sc = co->data;
- int i;
-
- if (co->top == -1) return;
-
- newtGotorc(co->top, co->left);
-
- SLsmg_set_color(NEWT_COLORSET_FULLSCALE);
- for (i = 0; i < sc->charsSet; i++)
- SLsmg_write_string(" ");
-
- SLsmg_set_color(NEWT_COLORSET_EMPTYSCALE);
- for (i = 0; i < (co->width - sc->charsSet); i++)
- SLsmg_write_string(" ");
-}
diff --git a/mdk-stage1/newt/scrollbar.c b/mdk-stage1/newt/scrollbar.c
deleted file mode 100644
index cb4bc2757..000000000
--- a/mdk-stage1/newt/scrollbar.c
+++ /dev/null
@@ -1,124 +0,0 @@
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct scrollbar {
- int curr;
- int cs, csThumb;
- int arrows;
-} ;
-
-static void sbDraw(newtComponent co);
-static void sbDestroy(newtComponent co);
-static void sbDrawThumb(newtComponent co, int isOn);
-
-static struct componentOps sbOps = {
- sbDraw,
- newtDefaultEventHandler,
- sbDestroy,
- newtDefaultPlaceHandler,
- newtDefaultMappedHandler,
-} ;
-
-void newtScrollbarSet(newtComponent co, int where, int total) {
- struct scrollbar * sb = co->data;
- int new;
-
- if (sb->arrows)
- new = (where * (co->height - 3)) / (total ? total : 1) + 1;
- else
- new = (where * (co->height - 1)) / (total ? total : 1);
- if (new != sb->curr) {
- sbDrawThumb(co, 0);
- sb->curr = new;
- sbDrawThumb(co, 1);
- }
-}
-
-newtComponent newtVerticalScrollbar(int left, int top, int height,
- int normalColorset, int thumbColorset) {
- newtComponent co;
- struct scrollbar * sb;
-
- co = malloc(sizeof(*co));
- sb = malloc(sizeof(*sb));
- co->data = sb;
-
- if (!strcmp(getenv("TERM"), "linux") && height >= 2) {
- sb->arrows = 1;
- sb->curr = 1;
- } else {
- sb->arrows = 0;
- sb->curr = 0;
- }
- sb->cs = normalColorset;
- sb->csThumb = thumbColorset;
-
- co->ops = &sbOps;
- co->isMapped = 0;
- co->left = left;
- co->top = top;
- co->height = height;
- co->width = 1;
- co->takesFocus = 0;
-
- return co;
-}
-
-static void sbDraw(newtComponent co) {
- struct scrollbar * sb = co->data;
- int i;
-
- if (!co->isMapped) return;
-
- SLsmg_set_color(sb->cs);
-
- SLsmg_set_char_set(1);
- if (sb->arrows) {
- newtGotorc(co->top, co->left);
- SLsmg_write_char('\x2d');
- for (i = 1; i < co->height - 1; i++) {
- newtGotorc(i + co->top, co->left);
- SLsmg_write_char('\x61');
- }
- newtGotorc(co->top + co->height - 1, co->left);
- SLsmg_write_char('\x2e');
- } else {
- for (i = 0; i < co->height; i++) {
- newtGotorc(i + co->top, co->left);
- SLsmg_write_char('\x61');
- }
- }
-
- SLsmg_set_char_set(0);
-
- sbDrawThumb(co, 1);
-}
-
-static void sbDrawThumb(newtComponent co, int isOn) {
- struct scrollbar * sb = co->data;
- char ch = isOn ? '#' : '\x61';
-
- if (!co->isMapped) return;
-
- newtGotorc(sb->curr + co->top, co->left);
- SLsmg_set_char_set(1);
-
- /*if (isOn)
- SLsmg_set_color(sb->csThumb);
- else*/
- SLsmg_set_color(sb->cs);
-
- SLsmg_write_char(ch);
- SLsmg_set_char_set(0);
-}
-
-static void sbDestroy(newtComponent co) {
- struct scrollbar * sb = co->data;
-
- free(sb);
- free(co);
-}
diff --git a/mdk-stage1/newt/textbox.c b/mdk-stage1/newt/textbox.c
deleted file mode 100644
index 8eb4ae4db..000000000
--- a/mdk-stage1/newt/textbox.c
+++ /dev/null
@@ -1,409 +0,0 @@
-#include <ctype.h>
-#include <slang.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "newt.h"
-#include "newt_pr.h"
-
-struct textbox {
- char ** lines;
- int numLines;
- int linesAlloced;
- int doWrap;
- newtComponent sb;
- int topLine;
- int textWidth;
-};
-
-static char * expandTabs(const char * text);
-static void textboxDraw(newtComponent co);
-static void addLine(newtComponent co, const char * s, int len);
-static void doReflow(const char * text, char ** resultPtr, int width,
- int * badness, int * heightPtr);
-static struct eventResult textboxEvent(newtComponent c,
- struct event ev);
-static void textboxDestroy(newtComponent co);
-static void textboxPlace(newtComponent co, int newLeft, int newTop);
-static void textboxMapped(newtComponent co, int isMapped);
-
-static struct componentOps textboxOps = {
- textboxDraw,
- textboxEvent,
- textboxDestroy,
- textboxPlace,
- textboxMapped,
-} ;
-
-static void textboxMapped(newtComponent co, int isMapped) {
- struct textbox * tb = co->data;
-
- co->isMapped = isMapped;
- if (tb->sb)
- tb->sb->ops->mapped(tb->sb, isMapped);
-}
-
-static void textboxPlace(newtComponent co, int newLeft, int newTop) {
- struct textbox * tb = co->data;
-
- co->top = newTop;
- co->left = newLeft;
-
- if (tb->sb)
- tb->sb->ops->place(tb->sb, co->left + co->width - 1, co->top);
-}
-
-void newtTextboxSetHeight(newtComponent co, int height) {
- co->height = height;
-}
-
-int newtTextboxGetNumLines(newtComponent co) {
- struct textbox * tb = co->data;
-
- return (tb->numLines);
-}
-
-newtComponent newtTextboxReflowed(int left, int top, char * text, int width,
- int flexDown, int flexUp, int flags __attribute__ ((unused))) {
- newtComponent co;
- char * reflowedText;
- int actWidth, actHeight;
-
- reflowedText = newtReflowText(text, width, flexDown, flexUp,
- &actWidth, &actHeight);
-
- co = newtTextbox(left, top, actWidth, actHeight, NEWT_FLAG_WRAP);
- newtTextboxSetText(co, reflowedText);
- free(reflowedText);
-
- return co;
-}
-
-newtComponent newtTextbox(int left, int top, int width, int height, int flags) {
- newtComponent co;
- struct textbox * tb;
-
- co = malloc(sizeof(*co));
- tb = malloc(sizeof(*tb));
- co->data = tb;
-
- co->ops = &textboxOps;
-
- co->height = height;
- co->top = top;
- co->left = left;
- co->takesFocus = 0;
- co->width = width;
-
- tb->doWrap = flags & NEWT_FLAG_WRAP;
- tb->numLines = 0;
- tb->linesAlloced = 0;
- tb->lines = NULL;
- tb->topLine = 0;
- tb->textWidth = width;
-
- if (flags & NEWT_FLAG_SCROLL) {
- co->width += 2;
- tb->sb = newtVerticalScrollbar(co->left + co->width - 1, co->top,
- co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX);
- } else {
- tb->sb = NULL;
- }
-
- return co;
-}
-
-static char * expandTabs(const char * text) {
- int bufAlloced = strlen(text) + 40;
- char * buf, * dest;
- const char * src;
- int bufUsed = 0;
- int linePos = 0;
- int i;
-
- buf = malloc(bufAlloced + 1);
- for (src = text, dest = buf; *src; src++) {
- if ((bufUsed + 10) > bufAlloced) {
- bufAlloced += strlen(text) / 2;
- buf = realloc(buf, bufAlloced + 1);
- dest = buf + bufUsed;
- }
- if (*src == '\t') {
- i = 8 - (linePos & 8);
- memset(dest, ' ', i);
- dest += i, bufUsed += i, linePos += i;
- } else {
- if (*src == '\n')
- linePos = 0;
- else
- linePos++;
-
- *dest++ = *src;
- bufUsed++;
- }
- }
-
- *dest = '\0';
- return buf;
-}
-
-#define iseuckanji(c) (0xa1 <= (unsigned char)(c&0xff) && (unsigned char)(c&0xff) <= 0xfe)
-
-static void doReflow(const char * text, char ** resultPtr, int width,
- int * badness, int * heightPtr) {
- char * result = NULL;
- const char * chptr, * end;
- int i;
- int howbad = 0;
- int height = 0;
- int kanji = 0;
-
- if (resultPtr) {
- /* XXX I think this will work */
- result = malloc(strlen(text) + (strlen(text) / width) + 50);
- *result = '\0';
- }
-
- while (*text) {
- kanji = 0;
- end = strchr(text, '\n');
- if (!end)
- end = text + strlen(text);
-
- while (*text && text < end) {
- if (end - text < width) {
- if (result) {
- strncat(result, text, end - text);
- strcat(result, "\n");
- height++;
- }
-
- if (end - text < (width / 2))
- howbad += ((width / 2) - (end - text)) / 2;
- text = end;
- if (*text) text++;
- } else {
- chptr = text;
- kanji = 0;
- for ( i = 0; i < width - 1; i++ ) {
- if ( !iseuckanji(*chptr)) {
- kanji = 0;
- } else if ( kanji == 1 ) {
- kanji = 2;
- } else {
- kanji = 1;
- }
- chptr++;
- }
- if (kanji == 0) {
- while (chptr > text && !isspace(*chptr)) chptr--;
- while (chptr > text && isspace(*chptr)) chptr--;
- chptr++;
- }
-
- if (chptr-text == 1 && !isspace(*chptr))
- chptr = text + width - 1;
-
- if (chptr > text)
- howbad += width - (chptr - text) + 1;
- if (result) {
- if (kanji == 1) {
- strncat(result, text, chptr - text + 1);
- chptr++;
- kanji = 0;
- } else {
- strncat(result, text, chptr - text);
- }
- strcat(result, "\n");
- height++;
- }
-
- if (isspace(*chptr))
- text = chptr + 1;
- else
- text = chptr;
- while (isspace(*text)) text++;
- }
- }
- }
-
-// if (result) printf("result: %s\n", result);
-
- if (badness) *badness = howbad;
- if (resultPtr) *resultPtr = result;
- if (heightPtr) *heightPtr = height;
-}
-
-char * newtReflowText(char * text, int width, int flexDown, int flexUp,
- int * actualWidth, int * actualHeight) {
- int min, max;
- int i;
- char * result;
- int minbad, minbadwidth, howbad;
- char * expandedText;
-
- expandedText = expandTabs(text);
-
- if (flexDown || flexUp) {
- min = width - flexDown;
- max = width + flexUp;
-
- minbad = -1;
- minbadwidth = width;
-
- for (i = min; i <= max; i++) {
- doReflow(expandedText, NULL, i, &howbad, NULL);
-
- if (minbad == -1 || howbad < minbad) {
- minbad = howbad;
- minbadwidth = i;
- }
- }
-
- width = minbadwidth;
- }
-
- doReflow(expandedText, &result, width, NULL, actualHeight);
- free(expandedText);
- if (actualWidth) *actualWidth = width;
- return result;
-}
-
-void newtTextboxSetText(newtComponent co, const char * text) {
- const char * start, * end;
- struct textbox * tb = co->data;
- char * reflowed, * expanded;
- int badness, height;
-
- if (tb->lines) {
- free(tb->lines);
- tb->linesAlloced = tb->numLines = 0;
- }
-
- expanded = expandTabs(text);
-
- if (tb->doWrap) {
- doReflow(expanded, &reflowed, tb->textWidth, &badness, &height);
- free(expanded);
- expanded = reflowed;
- }
-
- for (start = expanded; *start; start++)
- if (*start == '\n') tb->linesAlloced++;
-
- /* This ++ leaves room for an ending line w/o a \n */
- tb->linesAlloced++;
- tb->lines = malloc(sizeof(char *) * tb->linesAlloced);
-
- start = expanded;
- while ((end = strchr(start, '\n'))) {
- addLine(co, start, end - start);
- start = end + 1;
- }
-
- if (*start)
- addLine(co, start, strlen(start));
-
- free(expanded);
-}
-
-/* This assumes the buffer is allocated properly! */
-static void addLine(newtComponent co, const char * s, int len) {
- struct textbox * tb = co->data;
-
- if (len > tb->textWidth) len = tb->textWidth;
-
- tb->lines[tb->numLines] = malloc(tb->textWidth + 1);
- memset(tb->lines[tb->numLines], ' ', tb->textWidth);
- memcpy(tb->lines[tb->numLines], s, len);
- tb->lines[tb->numLines++][tb->textWidth] = '\0';
-}
-
-static void textboxDraw(newtComponent c) {
- int i;
- struct textbox * tb = c->data;
- int size;
-
- if (tb->sb) {
- size = tb->numLines - c->height;
- newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
- tb->sb->ops->draw(tb->sb);
- }
-
- SLsmg_set_color(NEWT_COLORSET_TEXTBOX);
-
- for (i = 0; (i + tb->topLine) < tb->numLines && i < c->height; i++) {
- newtGotorc(c->top + i, c->left);
- SLsmg_write_string(tb->lines[i + tb->topLine]);
- }
-}
-
-static struct eventResult textboxEvent(newtComponent co,
- struct event ev) {
- struct textbox * tb = co->data;
- struct eventResult er;
-
- er.result = ER_IGNORED;
-
- if (ev.when == EV_EARLY && ev.event == EV_KEYPRESS && tb->sb) {
- switch (ev.u.key) {
- case NEWT_KEY_UP:
- if (tb->topLine) tb->topLine--;
- textboxDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_DOWN:
- if (tb->topLine < (tb->numLines - co->height)) tb->topLine++;
- textboxDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_PGDN:
- tb->topLine += co->height;
- if (tb->topLine > (tb->numLines - co->height)) {
- tb->topLine = tb->numLines - co->height;
- if (tb->topLine < 0) tb->topLine = 0;
- }
- textboxDraw(co);
- er.result = ER_SWALLOWED;
- break;
-
- case NEWT_KEY_PGUP:
- tb->topLine -= co->height;
- if (tb->topLine < 0) tb->topLine = 0;
- textboxDraw(co);
- er.result = ER_SWALLOWED;
- break;
- }
- }
- if (ev.when == EV_EARLY && ev.event == EV_MOUSE && tb->sb) {
- /* Top scroll arrow */
- if (ev.u.mouse.x == co->width && ev.u.mouse.y == co->top) {
- if (tb->topLine) tb->topLine--;
- textboxDraw(co);
-
- er.result = ER_SWALLOWED;
- }
- /* Bottom scroll arrow */
- if (ev.u.mouse.x == co->width &&
- ev.u.mouse.y == co->top + co->height - 1) {
- if (tb->topLine < (tb->numLines - co->height)) tb->topLine++;
- textboxDraw(co);
-
- er.result = ER_SWALLOWED;
- }
- }
- return er;
-}
-
-static void textboxDestroy(newtComponent co) {
- int i;
- struct textbox * tb = co->data;
-
- for (i = 0; i < tb->numLines; i++)
- free(tb->lines[i]);
- free(tb->lines);
- free(tb);
- free(co);
-}
diff --git a/mdk-stage1/newt/windows.c b/mdk-stage1/newt/windows.c
deleted file mode 100644
index 30a8d526c..000000000
--- a/mdk-stage1/newt/windows.c
+++ /dev/null
@@ -1,275 +0,0 @@
-#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "errno.h"
-#include "newt.h"
-
-static void * newtvwindow(char * title, char * button1, char * button2,
- char * button3, char * message, va_list args) {
- newtComponent b1, b2 = NULL, b3 = NULL, t, f, answer;
- char * buf = NULL;
- int size = 0;
- int i = 0;
- int scroll = 0;
- int width, height;
- char * flowedText;
- newtGrid grid, buttonGrid;
-
- do {
- size += 1000;
- if (buf) free(buf);
- buf = malloc(size);
- i = vsnprintf(buf, size, message, args);
- } while (i >= size || i == -1);
-
- flowedText = newtReflowText(buf, 50, 5, 5, &width, &height);
- if (height > 6) {
- free(flowedText);
- flowedText = newtReflowText(buf, 60, 5, 5, &width, &height);
- }
- free(buf);
-
- if (height > 12) {
- height = 12;
- scroll = NEWT_FLAG_SCROLL;
- }
- t = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP | scroll);
- newtTextboxSetText(t, flowedText);
- free(flowedText);
-
- if (button3) {
- buttonGrid = newtButtonBar(button1, &b1, button2, &b2,
- button3, &b3, NULL);
- } else if (button2) {
- buttonGrid = newtButtonBar(button1, &b1, button2, &b2, NULL);
- } else {
- buttonGrid = newtButtonBar(button1, &b1, NULL);
- }
-
- newtGridSetField(buttonGrid, 0, 0, NEWT_GRID_COMPONENT, b1,
- 0, 0, button2 ? 1 : 0, 0, 0, 0);
-
- grid = newtCreateGrid(1, 2);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, t, 0, 0, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, buttonGrid,
- 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
- newtGridWrappedWindow(grid, title);
-
- f = newtForm(NULL, NULL, 0);
- newtFormAddComponents(f, t, b1, NULL);
-
- if (button2)
- newtFormAddComponent(f, b2);
- if (button3)
- newtFormAddComponent(f, b3);
-
- answer = newtRunForm(f);
- newtGridFree(grid, 1);
-
- newtFormDestroy(f);
- newtPopWindow();
-
- if (answer == f)
- return NULL;
- else if (answer == b1)
- return button1;
- else if (answer == b2)
- return button2;
-
- return button3;
-}
-
-int newtWinChoice(char * title, char * button1, char * button2,
- char * message, ...) {
- va_list args;
- void * rc;
-
- va_start(args, message);
- rc = newtvwindow(title, button1, button2, NULL, message, args);
- va_end(args);
-
- if (rc == button1)
- return 1;
- else if (rc == button2)
- return 2;
-
- return 0;
-}
-
-void newtWinMessage(char * title, char * buttonText, char * text, ...) {
- va_list args;
-
- va_start(args, text);
- newtvwindow(title, buttonText, NULL, NULL, text, args);
- va_end(args);
-}
-
-void newtWinMessagev(char * title, char * buttonText, char * text,
- va_list argv) {
- newtvwindow(title, buttonText, NULL, NULL, text, argv);
-}
-
-int newtWinTernary(char * title, char * button1, char * button2,
- char * button3, char * message, ...) {
- va_list args;
- void * rc;
-
- va_start(args, message);
- rc = newtvwindow(title, button1, button2, button3, message, args);
- va_end(args);
-
- if (rc == button1)
- return 1;
- else if (rc == button2)
- return 2;
- else if (rc == button3)
- return 3;
-
- return 0;
-}
-
-/* only supports up to 50 buttons -- shucks! */
-int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
- int flexUp, int maxListHeight, char ** items, int * listItem,
- char * button1, ...) {
- newtComponent textbox, listbox, result, form;
- va_list args;
- newtComponent buttons[50];
- newtGrid grid, buttonBar;
- int numButtons;
- int i, rc;
- int needScroll;
- char * buttonName;
-
- textbox = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
- flexUp, 0);
-
- for (i = 0; items[i]; i++) ;
- if (i < maxListHeight) maxListHeight = i;
- needScroll = i > maxListHeight;
-
- listbox = newtListbox(-1, -1, maxListHeight,
- (needScroll ? NEWT_FLAG_SCROLL : 0) | NEWT_FLAG_RETURNEXIT);
- for (i = 0; items[i]; i++) {
- newtListboxAddEntry(listbox, items[i], (void *) (long)i);
- }
-
- newtListboxSetCurrent(listbox, *listItem);
-
- buttonName = button1, numButtons = 0;
- va_start(args, button1);
- while (buttonName) {
- buttons[numButtons] = newtButton(-1, -1, buttonName);
- numButtons++;
- buttonName = va_arg(args, char *);
- }
-
- va_end(args);
-
- buttonBar = newtCreateGrid(numButtons, 1);
- for (i = 0; i < numButtons; i++) {
- newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT,
- buttons[i],
- i ? 1 : 0, 0, 0, 0, 0, 0);
- }
-
- grid = newtGridSimpleWindow(textbox, listbox, buttonBar);
- newtGridWrappedWindow(grid, title);
-
- form = newtForm(NULL, 0, 0);
- newtGridAddComponentsToForm(grid, form, 1);
- newtGridFree(grid, 1);
-
- result = newtRunForm(form);
-
- *listItem = ((long) newtListboxGetCurrent(listbox));
-
- for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
- if (rc == numButtons)
- rc = 0; /* F12 or return-on-exit (which are the same for us) */
- else
- rc++;
-
- newtFormDestroy(form);
- newtPopWindow();
-
- return rc;
-}
-
-/* only supports up to 50 buttons and entries -- shucks! */
-int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
- int flexUp, int dataWidth,
- struct newtWinEntry * items, char * button1, ...) {
- newtComponent buttons[50], result, form, textw;
- newtGrid grid, buttonBar, subgrid;
- int numItems;
- int rc, i;
- int numButtons;
- char * buttonName;
- va_list args;
-
- textw = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
- flexUp, 0);
-
- for (numItems = 0; items[numItems].text; numItems++);
-
- buttonName = button1, numButtons = 0;
- va_start(args, button1);
- while (buttonName) {
- buttons[numButtons] = newtButton(-1, -1, buttonName);
- numButtons++;
- buttonName = va_arg(args, char *);
- }
-
- va_end(args);
-
- buttonBar = newtCreateGrid(numButtons, 1);
- for (i = 0; i < numButtons; i++) {
- newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT,
- buttons[i],
- i ? 1 : 0, 0, 0, 0, 0, 0);
- }
-
- subgrid = newtCreateGrid(2, numItems);
- for (i = 0; i < numItems; i++) {
- newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,
- newtLabel(-1, -1, items[i].text),
- 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(subgrid, 1, i, NEWT_GRID_COMPONENT,
- newtEntry(-1, -1, items[i].value ?
- *items[i].value : NULL, dataWidth,
- items[i].value, items[i].flags),
- 1, 0, 0, 0, 0, 0);
- }
-
- grid = newtCreateGrid(1, 3);
- form = newtForm(NULL, 0, 0);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw,
- 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid,
- 0, 1, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar,
- 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
- newtGridAddComponentsToForm(grid, form, 1);
- newtGridWrappedWindow(grid, title);
- newtGridFree(grid, 1);
-
- result = newtRunForm(form);
-
- for (rc = 0; rc < numItems; rc++)
- *items[rc].value = strdup(*items[rc].value);
-
- for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
- if (rc == numButtons)
- rc = 0; /* F12 */
- else
- rc++;
-
- newtFormDestroy(form);
- newtPopWindow();
-
- return rc;
-}
diff --git a/mdk-stage1/nfs_mount4.h b/mdk-stage1/nfs_mount4.h
deleted file mode 100644
index 85650773a..000000000
--- a/mdk-stage1/nfs_mount4.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * We want to be able to compile mount on old kernels in such a way
- * that the binary will work well on more recent kernels.
- * Thus, if necessary we teach nfsmount.c the structure of new fields
- * that will come later.
- *
- * Moreover, the new kernel includes conflict with glibc includes
- * so it is easiest to ignore the kernel altogether (at compile time).
- */
-
-#define NFS_MOUNT_VERSION 4
-
-struct nfs2_fh {
- char data[32];
-};
-struct nfs3_fh {
- unsigned short size;
- unsigned char data[64];
-};
-
-struct nfs_mount_data {
- int version; /* 1 */
- int fd; /* 1 */
- struct nfs2_fh old_root; /* 1 */
- int flags; /* 1 */
- int rsize; /* 1 */
- int wsize; /* 1 */
- int timeo; /* 1 */
- int retrans; /* 1 */
- int acregmin; /* 1 */
- int acregmax; /* 1 */
- int acdirmin; /* 1 */
- int acdirmax; /* 1 */
- struct sockaddr_in addr; /* 1 */
- char hostname[256]; /* 1 */
- int namlen; /* 2 */
- unsigned int bsize; /* 3 */
- struct nfs3_fh root; /* 4 */
-};
-
-/* bits in the flags field */
-
-#define NFS_MOUNT_SOFT 0x0001 /* 1 */
-#define NFS_MOUNT_INTR 0x0002 /* 1 */
-#define NFS_MOUNT_SECURE 0x0004 /* 1 */
-#define NFS_MOUNT_POSIX 0x0008 /* 1 */
-#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
-#define NFS_MOUNT_NOAC 0x0020 /* 1 */
-#define NFS_MOUNT_TCP 0x0040 /* 2 */
-#define NFS_MOUNT_VER3 0x0080 /* 3 */
-#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
-#define NFS_MOUNT_NONLM 0x0200 /* 3 */
-#define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */
-
diff --git a/mdk-stage1/nfsmount.c b/mdk-stage1/nfsmount.c
deleted file mode 100644
index 55a0b0b1e..000000000
--- a/mdk-stage1/nfsmount.c
+++ /dev/null
@@ -1,740 +0,0 @@
- /*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2003 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * basing on nfsmount.c from util-linux-2.11z:
- * - use our logging facilities
- * - use our host resolving stuff
- * - remove unneeded code
- */
-
-/*
- * nfsmount.c -- Linux NFS mount
- * Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Wed Feb 8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port
- * numbers to be specified on the command line.
- *
- * Fri, 8 Mar 1996 18:01:39, Swen Thuemmler <swen@uni-paderborn.de>:
- * Omit the call to connect() for Linux version 1.3.11 or later.
- *
- * Wed Oct 1 23:55:28 1997: Dick Streefland <dick_streefland@tasking.com>
- * Implemented the "bg", "fg" and "retry" mount options for NFS.
- *
- * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
- * - added Native Language Support
- *
- * Modified by Olaf Kirch and Trond Myklebust for new NFS code,
- * plus NFSv3 stuff.
- *
- * 2003-04-14 David Black <david.black@xilinx.com>
- * - added support for multiple hostname NFS mounts
- */
-
-/*
- * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
- */
-
-#define HAVE_rpcsvc_nfs_prot_h
-#define HAVE_inet_aton
-
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <netdb.h>
-#include <time.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/utsname.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <values.h>
-
-#include "nfsmount.h"
-
-#ifdef HAVE_rpcsvc_nfs_prot_h
-#include <rpcsvc/nfs_prot.h>
-#else
-#include <linux/nfs.h>
-#define nfsstat nfs_stat
-#endif
-
-#include "nfs_mount4.h"
-
-#include "log.h"
-#include "dns.h"
-
-#ifndef NFS_PORT
-#define NFS_PORT 2049
-#endif
-#ifndef NFS_FHSIZE
-#define NFS_FHSIZE 32
-#endif
-
-static char *nfs_strerror(int stat);
-
-#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
-
-#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
-
-bool_t
-xdr_fhandle3 (XDR *xdrs, fhandle3 *objp)
-{
- if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_mountstat3 (XDR *xdrs, mountstat3 *objp)
-{
- if (!xdr_enum (xdrs, (enum_t *) objp))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp)
-{
- if (!xdr_fhandle3 (xdrs, &objp->fhandle))
- return FALSE;
- if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0,
- sizeof (int), (xdrproc_t) xdr_int))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_mountres3 (XDR *xdrs, mountres3 *objp)
-{
- if (!xdr_mountstat3 (xdrs, &objp->fhs_status))
- return FALSE;
- switch (objp->fhs_status) {
- case MNT_OK:
- if (!xdr_mountres3_ok (xdrs, &objp->mountres3_u.mountinfo))
- return FALSE;
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-bool_t
-xdr_dirpath (XDR *xdrs, dirpath *objp)
-{
- if (!xdr_string (xdrs, objp, MNTPATHLEN))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_fhandle (XDR *xdrs, fhandle objp)
-{
- if (!xdr_opaque (xdrs, objp, FHSIZE))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_fhstatus (XDR *xdrs, fhstatus *objp)
-{
- if (!xdr_u_int (xdrs, &objp->fhs_status))
- return FALSE;
- switch (objp->fhs_status) {
- case 0:
- if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle))
- return FALSE;
- break;
- default:
- break;
- }
- return TRUE;
-}
-
-
-static int
-linux_version_code(void) {
- struct utsname my_utsname;
- int p, q, r;
-
- if (uname(&my_utsname) == 0) {
- p = atoi(strtok(my_utsname.release, "."));
- q = atoi(strtok(NULL, "."));
- r = atoi(strtok(NULL, "."));
- return MAKE_VERSION(p,q,r);
- }
- return 0;
-}
-
-/*
- * Unfortunately, the kernel prints annoying console messages
- * in case of an unexpected nfs mount version (instead of
- * just returning some error). Therefore we'll have to try
- * and figure out what version the kernel expects.
- *
- * Variables:
- * NFS_MOUNT_VERSION: these nfsmount sources at compile time
- * nfs_mount_version: version this source and running kernel can handle
- */
-static int
-find_kernel_nfs_mount_version(void) {
- static int kernel_version = -1;
- int nfs_mount_version = NFS_MOUNT_VERSION;
-
- if (kernel_version == -1)
- kernel_version = linux_version_code();
-
- if (kernel_version) {
- if (kernel_version < MAKE_VERSION(2,1,32))
- nfs_mount_version = 1;
- else if (kernel_version < MAKE_VERSION(2,2,18))
- nfs_mount_version = 3;
- else if (kernel_version < MAKE_VERSION(2,3,0))
- nfs_mount_version = 4; /* since 2.2.18pre9 */
- else if (kernel_version < MAKE_VERSION(2,3,99))
- nfs_mount_version = 3;
- else
- nfs_mount_version = 4; /* since 2.3.99pre4 */
- }
- if (nfs_mount_version > NFS_MOUNT_VERSION)
- nfs_mount_version = NFS_MOUNT_VERSION;
- log_message("nfsmount: kernel_nfs_mount_version: %d", nfs_mount_version);
- return nfs_mount_version;
-}
-
-static struct pmap *
-get_mountport(struct sockaddr_in *server_addr,
- long unsigned prog,
- long unsigned version,
- long unsigned proto,
- long unsigned port,
- int nfs_mount_version)
-{
- struct pmaplist *pmap;
- static struct pmap p = {0, 0, 0, 0};
-
- if (version > MAX_NFSPROT)
- version = MAX_NFSPROT;
- if (!prog)
- prog = MOUNTPROG;
- p.pm_prog = prog;
- p.pm_vers = version;
- p.pm_prot = proto;
- p.pm_port = port;
-
- server_addr->sin_port = PMAPPORT;
- pmap = pmap_getmaps(server_addr);
-
- while (pmap) {
- if (pmap->pml_map.pm_prog != prog)
- goto next;
- if (!version && p.pm_vers > pmap->pml_map.pm_vers)
- goto next;
- if (version > 2 && pmap->pml_map.pm_vers != version)
- goto next;
- if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
- goto next;
- if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
- (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) ||
- (port && pmap->pml_map.pm_port != port))
- goto next;
- memcpy(&p, &pmap->pml_map, sizeof(p));
- next:
- pmap = pmap->pml_next;
- }
- if (!p.pm_vers)
- p.pm_vers = MOUNTVERS;
- if (!p.pm_prot)
- p.pm_prot = IPPROTO_TCP;
- return &p;
-}
-
-
-
-int nfsmount_prepare(const char *spec, char **mount_opts)
-{
- char hostdir[1024];
- CLIENT *mclient;
- char *hostname, *dirname, *mounthost = NULL;
- struct timeval total_timeout;
- enum clnt_stat clnt_stat;
- static struct nfs_mount_data data;
- int nfs_mount_version;
- int val;
- struct sockaddr_in server_addr;
- struct sockaddr_in mount_server_addr;
- struct pmap *pm_mnt;
- int msock, fsock;
- struct timeval retry_timeout;
- union {
- struct fhstatus nfsv2;
- struct mountres3 nfsv3;
- } status;
- char *s;
- int port, mountport, proto, soft, intr;
- int posix, nocto, noac, broken_suid, nolock;
- int retry, tcp;
- int mountprog, mountvers, nfsprog, nfsvers;
- int retval;
- time_t t;
- time_t prevt;
- time_t timeout;
-
- nfs_mount_version = find_kernel_nfs_mount_version();
-
- retval = -1;
- msock = fsock = -1;
- mclient = NULL;
- if (strlen(spec) >= sizeof(hostdir)) {
- log_message("nfsmount: excessively long host:dir argument");
- goto fail;
- }
- strcpy(hostdir, spec);
- if ((s = strchr(hostdir, ':'))) {
- hostname = hostdir;
- dirname = s + 1;
- *s = '\0';
- } else {
- log_message("nfsmount: directory to mount not in host:dir format");
- goto fail;
- }
-
- server_addr.sin_family = AF_INET;
-#ifdef HAVE_inet_aton
- if (!inet_aton(hostname, &server_addr.sin_addr))
-#endif
- {
- if (mygethostbyname(hostname, &server_addr.sin_addr)) {
- log_message("nfsmount: can't get address for %s", hostname);
- goto fail;
- }
- }
-
- memcpy (&mount_server_addr, &server_addr, sizeof (mount_server_addr));
-
-
-
- /* Set default options.
- * rsize/wsize are set to 8192 to enable nfs install on
- * old i586 machines
- * timeo is filled in after we know whether it'll be TCP or UDP. */
- memset(&data, 0, sizeof(data));
- data.rsize = 8192;
- data.wsize = 8192;
- data.retrans = 30;
- data.acregmin = 3;
- data.acregmax = 60;
- data.acdirmin = 30;
- data.acdirmax = 60;
-#if NFS_MOUNT_VERSION >= 2
- data.namlen = NAME_MAX;
-#endif
-
- soft = 1;
- intr = 0;
- posix = 0;
- nocto = 0;
- nolock = 1;
- broken_suid = 0;
- noac = 0;
- retry = 10000; /* 10000 minutes ~ 1 week */
- tcp = 0;
-
- mountprog = MOUNTPROG;
- mountvers = 0;
- port = 0;
- mountport = 0;
- nfsprog = NFS_PROGRAM;
- nfsvers = 0;
-
-
-
-retry_mount:
- proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
-
- data.flags = (soft ? NFS_MOUNT_SOFT : 0)
- | (intr ? NFS_MOUNT_INTR : 0)
- | (posix ? NFS_MOUNT_POSIX : 0)
- | (nocto ? NFS_MOUNT_NOCTO : 0)
- | (noac ? NFS_MOUNT_NOAC : 0);
-#if NFS_MOUNT_VERSION >= 2
- if (nfs_mount_version >= 2)
- data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
-#endif
-#if NFS_MOUNT_VERSION >= 3
- if (nfs_mount_version >= 3)
- data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
-#endif
-#if NFS_MOUNT_VERSION >= 4
- if (nfs_mount_version >= 4)
- data.flags |= (broken_suid ? NFS_MOUNT_BROKEN_SUID : 0);
-#endif
- if (nfsvers > MAX_NFSPROT) {
- log_message("NFSv%d not supported!", nfsvers);
- return 0;
- }
- if (mountvers > MAX_NFSPROT) {
- log_message("NFSv%d not supported!", nfsvers);
- return 0;
- }
- if (nfsvers && !mountvers)
- mountvers = (nfsvers < 3) ? 1 : nfsvers;
- if (nfsvers && nfsvers < mountvers)
- mountvers = nfsvers;
-
- /* Adjust options if none specified */
- if (!data.timeo)
- data.timeo = tcp ? 70 : 7;
-
-#ifdef NFS_MOUNT_DEBUG
- log_message("rsize = %d, wsize = %d, timeo = %d, retrans = %d",
- data.rsize, data.wsize, data.timeo, data.retrans);
- log_message("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)",
- data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
- log_message("port = %d, retry = %d, flags = %.8x",
- port, retry, data.flags);
- log_message("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d",
- mountprog, mountvers, nfsprog, nfsvers);
- log_message("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d",
- (data.flags & NFS_MOUNT_SOFT) != 0,
- (data.flags & NFS_MOUNT_INTR) != 0,
- (data.flags & NFS_MOUNT_POSIX) != 0,
- (data.flags & NFS_MOUNT_NOCTO) != 0,
- (data.flags & NFS_MOUNT_NOAC) != 0);
-#if NFS_MOUNT_VERSION >= 2
- log_message("tcp = %d",
- (data.flags & NFS_MOUNT_TCP) != 0);
-#endif
-#endif
-
- data.version = nfs_mount_version;
- *mount_opts = (char *) &data;
-
-
- /* create mount deamon client */
- /* See if the nfs host = mount host. */
- if (mounthost) {
- if (mounthost[0] >= '0' && mounthost[0] <= '9') {
- mount_server_addr.sin_family = AF_INET;
- mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
- } else {
- if (mygethostbyname(mounthost, &mount_server_addr.sin_addr)) {
- log_message("nfsmount: can't get address for %s", mounthost);
- goto fail;
- }
- }
- }
-
- /*
- * The following loop implements the mount retries. On the first
- * call, "running_bg" is 0. When the mount times out, and the
- * "bg" option is set, the exit status EX_BG will be returned.
- * For a backgrounded mount, there will be a second call by the
- * child process with "running_bg" set to 1.
- *
- * The case where the mount point is not present and the "bg"
- * option is set, is treated as a timeout. This is done to
- * support nested mounts.
- *
- * The "retry" count specified by the user is the number of
- * minutes to retry before giving up.
- *
- * Only the first error message will be displayed.
- */
- retry_timeout.tv_sec = 3;
- retry_timeout.tv_usec = 0;
- total_timeout.tv_sec = 20;
- total_timeout.tv_usec = 0;
- timeout = time(NULL) + 60 * retry;
- prevt = 0;
- t = 30;
- val = 1;
-
-
- /* be careful not to use too many CPU cycles */
- if (t - prevt < 30)
- sleep(30);
-
- pm_mnt = get_mountport(&mount_server_addr,
- mountprog,
- mountvers,
- proto,
- mountport,
- nfs_mount_version);
-
- /* contact the mount daemon via TCP */
- mount_server_addr.sin_port = htons(pm_mnt->pm_port);
- msock = RPC_ANYSOCK;
-
- switch (pm_mnt->pm_prot) {
- case IPPROTO_UDP:
- mclient = clntudp_create(&mount_server_addr,
- pm_mnt->pm_prog,
- pm_mnt->pm_vers,
- retry_timeout,
- &msock);
- if (mclient)
- break;
- mount_server_addr.sin_port =
- htons(pm_mnt->pm_port);
- msock = RPC_ANYSOCK;
- case IPPROTO_TCP:
- mclient = clnttcp_create(&mount_server_addr,
- pm_mnt->pm_prog,
- pm_mnt->pm_vers,
- &msock, 0, 0);
- break;
- default:
- mclient = 0;
- }
-
- if (mclient) {
- /* try to mount hostname:dirname */
- mclient->cl_auth = authunix_create_default();
-
- /* make pointers in xdr_mountres3 NULL so
- * that xdr_array allocates memory for us
- */
- memset(&status, 0, sizeof(status));
-
- log_message("nfsmount: doing client call in nfs version: %ld", pm_mnt->pm_vers);
- if (pm_mnt->pm_vers == 3)
- clnt_stat = clnt_call(mclient,
- MOUNTPROC3_MNT,
- (xdrproc_t) xdr_dirpath,
- (caddr_t) &dirname,
- (xdrproc_t) xdr_mountres3,
- (caddr_t) &status,
- total_timeout);
- else
- clnt_stat = clnt_call(mclient,
- MOUNTPROC_MNT,
- (xdrproc_t) xdr_dirpath,
- (caddr_t) &dirname,
- (xdrproc_t) xdr_fhstatus,
- (caddr_t) &status,
- total_timeout);
-
- if (clnt_stat == RPC_SUCCESS)
- goto succeeded;
-
- if (prevt == 0)
- log_message("could not call server: probably protocol or version error");
- auth_destroy(mclient->cl_auth);
- clnt_destroy(mclient);
- mclient = 0;
- close(msock);
- } else {
- log_message("could not create rpc client: host probably not found or NFS server is down");
- }
- prevt = t;
-
- goto fail;
-
- succeeded:
- nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
-
- if (nfsvers == 2) {
- if (status.nfsv2.fhs_status != 0) {
- log_message("nfsmount: %s:%s failed, reason given by server: %s",
- hostname, dirname, nfs_strerror(status.nfsv2.fhs_status));
- goto fail;
- }
- memcpy(data.root.data,
- (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
- NFS_FHSIZE);
-#if NFS_MOUNT_VERSION >= 4
- data.root.size = NFS_FHSIZE;
- memcpy(data.old_root.data,
- (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
- NFS_FHSIZE);
-#endif
- } else {
-#if NFS_MOUNT_VERSION >= 4
- fhandle3 *fhandle;
- if (status.nfsv3.fhs_status != 0) {
- log_message("nfsmount: %s:%s failed, reason given by server: %s",
- hostname, dirname, nfs_strerror(status.nfsv3.fhs_status));
- goto fail;
- }
- fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
- memset(data.old_root.data, 0, NFS_FHSIZE);
- memset(&data.root, 0, sizeof(data.root));
- data.root.size = fhandle->fhandle3_len;
- memcpy(data.root.data,
- (char *) fhandle->fhandle3_val,
- fhandle->fhandle3_len);
-
- data.flags |= NFS_MOUNT_VER3;
-#endif
- }
-
- /* create nfs socket for kernel */
-
- if (tcp) {
- if (nfs_mount_version < 3) {
- log_message("NFS over TCP is not supported.");
- goto fail;
- }
- fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- } else
- fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (fsock < 0) {
- log_perror("nfs socket");
- goto fail;
- }
- if (bindresvport(fsock, 0) < 0) {
- log_perror("nfs bindresvport");
- goto fail;
- }
- if (port == 0) {
- server_addr.sin_port = PMAPPORT;
- port = pmap_getport(&server_addr, nfsprog, nfsvers,
- tcp ? IPPROTO_TCP : IPPROTO_UDP);
-#if 1
- /* Here we check to see if user is mounting with the
- * tcp option. If so, and if the portmap returns a
- * '0' for port (service unavailable), we then notify
- * the user, and retry with udp.
- */
- if (port == 0 && tcp == 1) {
- log_message("NFS server reported TCP not available, retrying with UDP...");
- tcp = 0;
- goto retry_mount;
- }
-#endif
-
- if (port == 0)
- port = NFS_PORT;
-#ifdef NFS_MOUNT_DEBUG
- else
- log_message("used portmapper to find NFS port");
-#endif
- }
-#ifdef NFS_MOUNT_DEBUG
- log_message("using port %d for nfs deamon", port);
-#endif
- server_addr.sin_port = htons(port);
- /*
- * connect() the socket for kernels 1.3.10 and below only,
- * to avoid problems with multihomed hosts.
- * --Swen
- */
- if (linux_version_code() <= 66314
- && connect(fsock, (struct sockaddr *) &server_addr,
- sizeof (server_addr)) < 0) {
- log_perror("nfs connect");
- goto fail;
- }
-
- /* prepare data structure for kernel */
-
- data.fd = fsock;
- memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
- strncpy(data.hostname, hostname, sizeof(data.hostname));
-
- /* clean up */
-
- auth_destroy(mclient->cl_auth);
- clnt_destroy(mclient);
- close(msock);
- return 0;
-
- /* abort */
-
- fail:
- if (msock != -1) {
- if (mclient) {
- auth_destroy(mclient->cl_auth);
- clnt_destroy(mclient);
- }
- close(msock);
- }
- if (fsock != -1)
- close(fsock);
- return retval;
-}
-
-/*
- * We need to translate between nfs status return values and
- * the local errno values which may not be the same.
- *
- * Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>: change errno:
- * "after #include <errno.h> the symbol errno is reserved for any use,
- * it cannot even be used as a struct tag or field name".
- */
-
-#ifndef EDQUOT
-#define EDQUOT ENOSPC
-#endif
-
-static struct {
- enum nfsstat stat;
- int errnum;
-} nfs_errtbl[] = {
- { NFS_OK, 0 },
- { NFSERR_PERM, EPERM },
- { NFSERR_NOENT, ENOENT },
- { NFSERR_IO, EIO },
- { NFSERR_NXIO, ENXIO },
- { NFSERR_ACCES, EACCES },
- { NFSERR_EXIST, EEXIST },
- { NFSERR_NODEV, ENODEV },
- { NFSERR_NOTDIR, ENOTDIR },
- { NFSERR_ISDIR, EISDIR },
-#ifdef NFSERR_INVAL
- { NFSERR_INVAL, EINVAL }, /* that Sun forgot */
-#endif
- { NFSERR_FBIG, EFBIG },
- { NFSERR_NOSPC, ENOSPC },
- { NFSERR_ROFS, EROFS },
- { NFSERR_NAMETOOLONG, ENAMETOOLONG },
- { NFSERR_NOTEMPTY, ENOTEMPTY },
- { NFSERR_DQUOT, EDQUOT },
- { NFSERR_STALE, ESTALE },
-#ifdef EWFLUSH
- { NFSERR_WFLUSH, EWFLUSH },
-#endif
- /* Throw in some NFSv3 values for even more fun (HP returns these) */
- { 71, EREMOTE },
-
- { -1, EIO }
-};
-
-static char *nfs_strerror(int stat)
-{
- int i;
- static char buf[256];
-
- for (i = 0; nfs_errtbl[i].stat != (unsigned)-1; i++) {
- if (nfs_errtbl[i].stat == (unsigned)stat)
- return strerror(nfs_errtbl[i].errnum);
- }
- sprintf(buf, "unknown nfs status return value: %d", stat);
- return buf;
-}
-
diff --git a/mdk-stage1/nfsmount.h b/mdk-stage1/nfsmount.h
deleted file mode 100644
index a27e8a8d7..000000000
--- a/mdk-stage1/nfsmount.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef _NFSMOUNT_H_RPCGEN
-#define _NFSMOUNT_H_RPCGEN
-
-#include <rpc/rpc.h>
-
-int nfsmount_prepare(const char *spec, char **mount_opts);
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user or with the express written consent of
- * Sun Microsystems, Inc.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-/*
- * Copyright (c) 1985, 1990 by Sun Microsystems, Inc.
- */
-
-/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */
-#ifndef _rpcsvc_mount_h
-#define _rpcsvc_mount_h
-#include <asm/types.h>
-#define MNTPATHLEN 1024
-#define MNTNAMLEN 255
-#define FHSIZE 32
-#define FHSIZE3 64
-
-typedef char fhandle[FHSIZE];
-
-typedef struct {
- u_int fhandle3_len;
- char *fhandle3_val;
-} fhandle3;
-
-enum mountstat3 {
- MNT_OK = 0,
- MNT3ERR_PERM = 1,
- MNT3ERR_NOENT = 2,
- MNT3ERR_IO = 5,
- MNT3ERR_ACCES = 13,
- MNT3ERR_NOTDIR = 20,
- MNT3ERR_INVAL = 22,
- MNT3ERR_NAMETOOLONG = 63,
- MNT3ERR_NOTSUPP = 10004,
- MNT3ERR_SERVERFAULT = 10006,
-};
-typedef enum mountstat3 mountstat3;
-
-struct fhstatus {
- u_int fhs_status;
- union {
- fhandle fhs_fhandle;
- } fhstatus_u;
-};
-typedef struct fhstatus fhstatus;
-
-struct mountres3_ok {
- fhandle3 fhandle;
- struct {
- u_int auth_flavours_len;
- int *auth_flavours_val;
- } auth_flavours;
-};
-typedef struct mountres3_ok mountres3_ok;
-
-struct mountres3 {
- mountstat3 fhs_status;
- union {
- mountres3_ok mountinfo;
- } mountres3_u;
-};
-typedef struct mountres3 mountres3;
-
-typedef char *dirpath;
-
-typedef char *name;
-
-typedef struct mountbody *mountlist;
-
-struct mountbody {
- name ml_hostname;
- dirpath ml_directory;
- mountlist ml_next;
-};
-typedef struct mountbody mountbody;
-
-typedef struct groupnode *groups;
-
-struct groupnode {
- name gr_name;
- groups gr_next;
-};
-typedef struct groupnode groupnode;
-
-typedef struct exportnode *exports;
-
-struct exportnode {
- dirpath ex_dir;
- groups ex_groups;
- exports ex_next;
-};
-typedef struct exportnode exportnode;
-
-struct ppathcnf {
- int pc_link_max;
- short pc_max_canon;
- short pc_max_input;
- short pc_name_max;
- short pc_path_max;
- short pc_pipe_buf;
- u_char pc_vdisable;
- char pc_xxx;
- short pc_mask[2];
-};
-typedef struct ppathcnf ppathcnf;
-#endif /*!_rpcsvc_mount_h*/
-
-#define MOUNTPROG 100005
-#define MOUNTVERS 1
-
-#if defined(__STDC__) || defined(__cplusplus)
-#define MOUNTPROC_NULL 0
-extern void * mountproc_null_1(void *, CLIENT *);
-extern void * mountproc_null_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_MNT 1
-extern fhstatus * mountproc_mnt_1(dirpath *, CLIENT *);
-extern fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_DUMP 2
-extern mountlist * mountproc_dump_1(void *, CLIENT *);
-extern mountlist * mountproc_dump_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_UMNT 3
-extern void * mountproc_umnt_1(dirpath *, CLIENT *);
-extern void * mountproc_umnt_1_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC_UMNTALL 4
-extern void * mountproc_umntall_1(void *, CLIENT *);
-extern void * mountproc_umntall_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORT 5
-extern exports * mountproc_export_1(void *, CLIENT *);
-extern exports * mountproc_export_1_svc(void *, struct svc_req *);
-#define MOUNTPROC_EXPORTALL 6
-extern exports * mountproc_exportall_1(void *, CLIENT *);
-extern exports * mountproc_exportall_1_svc(void *, struct svc_req *);
-extern int mountprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
-
-#else /* K&R C */
-#define MOUNTPROC_NULL 0
-extern void * mountproc_null_1();
-extern void * mountproc_null_1_svc();
-#define MOUNTPROC_MNT 1
-extern fhstatus * mountproc_mnt_1();
-extern fhstatus * mountproc_mnt_1_svc();
-#define MOUNTPROC_DUMP 2
-extern mountlist * mountproc_dump_1();
-extern mountlist * mountproc_dump_1_svc();
-#define MOUNTPROC_UMNT 3
-extern void * mountproc_umnt_1();
-extern void * mountproc_umnt_1_svc();
-#define MOUNTPROC_UMNTALL 4
-extern void * mountproc_umntall_1();
-extern void * mountproc_umntall_1_svc();
-#define MOUNTPROC_EXPORT 5
-extern exports * mountproc_export_1();
-extern exports * mountproc_export_1_svc();
-#define MOUNTPROC_EXPORTALL 6
-extern exports * mountproc_exportall_1();
-extern exports * mountproc_exportall_1_svc();
-extern int mountprog_1_freeresult ();
-#endif /* K&R C */
-#define MOUNTVERS_POSIX 2
-
-#if defined(__STDC__) || defined(__cplusplus)
-extern void * mountproc_null_2(void *, CLIENT *);
-extern void * mountproc_null_2_svc(void *, struct svc_req *);
-extern fhstatus * mountproc_mnt_2(dirpath *, CLIENT *);
-extern fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *);
-extern mountlist * mountproc_dump_2(void *, CLIENT *);
-extern mountlist * mountproc_dump_2_svc(void *, struct svc_req *);
-extern void * mountproc_umnt_2(dirpath *, CLIENT *);
-extern void * mountproc_umnt_2_svc(dirpath *, struct svc_req *);
-extern void * mountproc_umntall_2(void *, CLIENT *);
-extern void * mountproc_umntall_2_svc(void *, struct svc_req *);
-extern exports * mountproc_export_2(void *, CLIENT *);
-extern exports * mountproc_export_2_svc(void *, struct svc_req *);
-extern exports * mountproc_exportall_2(void *, CLIENT *);
-extern exports * mountproc_exportall_2_svc(void *, struct svc_req *);
-#define MOUNTPROC_PATHCONF 7
-extern ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *);
-extern ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *);
-extern int mountprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
-
-#else /* K&R C */
-extern void * mountproc_null_2();
-extern void * mountproc_null_2_svc();
-extern fhstatus * mountproc_mnt_2();
-extern fhstatus * mountproc_mnt_2_svc();
-extern mountlist * mountproc_dump_2();
-extern mountlist * mountproc_dump_2_svc();
-extern void * mountproc_umnt_2();
-extern void * mountproc_umnt_2_svc();
-extern void * mountproc_umntall_2();
-extern void * mountproc_umntall_2_svc();
-extern exports * mountproc_export_2();
-extern exports * mountproc_export_2_svc();
-extern exports * mountproc_exportall_2();
-extern exports * mountproc_exportall_2_svc();
-#define MOUNTPROC_PATHCONF 7
-extern ppathcnf * mountproc_pathconf_2();
-extern ppathcnf * mountproc_pathconf_2_svc();
-extern int mountprog_2_freeresult ();
-#endif /* K&R C */
-#define MOUNT_V3 3
-
-#if defined(__STDC__) || defined(__cplusplus)
-#define MOUNTPROC3_NULL 0
-extern void * mountproc3_null_3(void *, CLIENT *);
-extern void * mountproc3_null_3_svc(void *, struct svc_req *);
-#define MOUNTPROC3_MNT 1
-extern mountres3 * mountproc3_mnt_3(dirpath *, CLIENT *);
-extern mountres3 * mountproc3_mnt_3_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC3_DUMP 2
-extern mountlist * mountproc3_dump_3(void *, CLIENT *);
-extern mountlist * mountproc3_dump_3_svc(void *, struct svc_req *);
-#define MOUNTPROC3_UMNT 3
-extern void * mountproc3_umnt_3(dirpath *, CLIENT *);
-extern void * mountproc3_umnt_3_svc(dirpath *, struct svc_req *);
-#define MOUNTPROC3_UMNTALL 4
-extern void * mountproc3_umntall_3(void *, CLIENT *);
-extern void * mountproc3_umntall_3_svc(void *, struct svc_req *);
-#define MOUNTPROC3_EXPORT 5
-extern exports * mountproc3_export_3(void *, CLIENT *);
-extern exports * mountproc3_export_3_svc(void *, struct svc_req *);
-extern int mountprog_3_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
-
-#else /* K&R C */
-#define MOUNTPROC3_NULL 0
-extern void * mountproc3_null_3();
-extern void * mountproc3_null_3_svc();
-#define MOUNTPROC3_MNT 1
-extern mountres3 * mountproc3_mnt_3();
-extern mountres3 * mountproc3_mnt_3_svc();
-#define MOUNTPROC3_DUMP 2
-extern mountlist * mountproc3_dump_3();
-extern mountlist * mountproc3_dump_3_svc();
-#define MOUNTPROC3_UMNT 3
-extern void * mountproc3_umnt_3();
-extern void * mountproc3_umnt_3_svc();
-#define MOUNTPROC3_UMNTALL 4
-extern void * mountproc3_umntall_3();
-extern void * mountproc3_umntall_3_svc();
-#define MOUNTPROC3_EXPORT 5
-extern exports * mountproc3_export_3();
-extern exports * mountproc3_export_3_svc();
-extern int mountprog_3_freeresult ();
-#endif /* K&R C */
-
-/* the xdr functions */
-
-#if defined(__STDC__) || defined(__cplusplus)
-extern bool_t xdr_fhandle (XDR *, fhandle);
-extern bool_t xdr_fhandle3 (XDR *, fhandle3*);
-extern bool_t xdr_mountstat3 (XDR *, mountstat3*);
-extern bool_t xdr_fhstatus (XDR *, fhstatus*);
-extern bool_t xdr_mountres3_ok (XDR *, mountres3_ok*);
-extern bool_t xdr_mountres3 (XDR *, mountres3*);
-extern bool_t xdr_dirpath (XDR *, dirpath*);
-extern bool_t xdr_name (XDR *, name*);
-extern bool_t xdr_mountlist (XDR *, mountlist*);
-extern bool_t xdr_mountbody (XDR *, mountbody*);
-extern bool_t xdr_groups (XDR *, groups*);
-extern bool_t xdr_groupnode (XDR *, groupnode*);
-extern bool_t xdr_exports (XDR *, exports*);
-extern bool_t xdr_exportnode (XDR *, exportnode*);
-extern bool_t xdr_ppathcnf (XDR *, ppathcnf*);
-
-#else /* K&R C */
-extern bool_t xdr_fhandle ();
-extern bool_t xdr_fhandle3 ();
-extern bool_t xdr_mountstat3 ();
-extern bool_t xdr_fhstatus ();
-extern bool_t xdr_mountres3_ok ();
-extern bool_t xdr_mountres3 ();
-extern bool_t xdr_dirpath ();
-extern bool_t xdr_name ();
-extern bool_t xdr_mountlist ();
-extern bool_t xdr_mountbody ();
-extern bool_t xdr_groups ();
-extern bool_t xdr_groupnode ();
-extern bool_t xdr_exports ();
-extern bool_t xdr_exportnode ();
-extern bool_t xdr_ppathcnf ();
-
-#endif /* K&R C */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_NFSMOUNT_H_RPCGEN */
-
diff --git a/mdk-stage1/partition.c b/mdk-stage1/partition.c
deleted file mode 100644
index 8fd581017..000000000
--- a/mdk-stage1/partition.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <libgen.h>
-#include "stage1.h"
-#include "frontend.h"
-#include "modules.h"
-#include "probing.h"
-#include "log.h"
-#include "mount.h"
-#include "lomount.h"
-#include "automatic.h"
-
-#include "disk.h"
-#include "partition.h"
-
-struct partition_detection_anchor {
- off_t offset;
- const char * anchor;
-};
-
-static int seek_and_compare(int fd, struct partition_detection_anchor anch)
-{
- char buf[500];
- size_t count;
- if (lseek(fd, anch.offset, SEEK_SET) == (off_t)-1) {
- log_perror("seek failed");
- return -1;
- }
- count = read(fd, buf, strlen(anch.anchor));
- if (count != strlen(anch.anchor)) {
- log_perror("read failed");
- return -1;
- }
- buf[count] = '\0';
- if (strcmp(anch.anchor, buf))
- return 1;
- return 0;
-}
-
-static const char * detect_partition_type(char * dev)
-{
- struct partition_detection_info {
- const char * name;
- struct partition_detection_anchor anchor0;
- struct partition_detection_anchor anchor1;
- struct partition_detection_anchor anchor2;
- };
- struct partition_detection_info partitions_signatures[] = {
- { "Linux Swap", { 4086, "SWAP-SPACE" }, { 0, NULL }, { 0, NULL } },
- { "Linux Swap", { 4086, "SWAPSPACE2" }, { 0, NULL }, { 0, NULL } },
- { "Ext2", { 0x438, "\x53\xEF" }, { 0, NULL }, { 0, NULL } },
- { "ReiserFS", { 0x10034, "ReIsErFs" }, { 0, NULL }, { 0, NULL } },
- { "ReiserFS", { 0x10034, "ReIsEr2Fs" }, { 0, NULL }, { 0, NULL } },
- { "XFS", { 0, "XFSB" }, { 0x200, "XAGF" }, { 0x400, "XAGI" } },
- { "JFS", { 0x8000, "JFS1" }, { 0, NULL }, { 0, NULL } },
- { "NTFS", { 0x1FE, "\x55\xAA" }, { 0x3, "NTFS" }, { 0, NULL } },
- { "FAT32", { 0x1FE, "\x55\xAA" }, { 0x52, "FAT32" }, { 0, NULL } },
- { "FAT", { 0x1FE, "\x55\xAA" }, { 0x36, "FAT" }, { 0, NULL } },
- { "Linux LVM", { 0, "HM\1\0" }, { 0, NULL }, { 0, NULL } }
- };
- int partitions_signatures_nb = sizeof(partitions_signatures) / sizeof(struct partition_detection_info);
- int i;
- int fd;
- const char *part_type = NULL;
-
- char device_fullname[50];
- strcpy(device_fullname, "/dev/");
- strcat(device_fullname, dev);
-
- if (ensure_dev_exists(device_fullname))
- return NULL;
- log_message("guessing type of %s", device_fullname);
-
- if ((fd = open(device_fullname, O_RDONLY, 0)) < 0) {
- log_perror("open");
- return NULL;
- }
-
- for (i=0; i<partitions_signatures_nb; i++) {
- int results = seek_and_compare(fd, partitions_signatures[i].anchor0);
- if (results == -1)
- goto detect_partition_type_end;
- if (results == 1)
- continue;
- if (!partitions_signatures[i].anchor1.anchor)
- goto detect_partition_found_it;
-
- results = seek_and_compare(fd, partitions_signatures[i].anchor1);
- if (results == -1)
- goto detect_partition_type_end;
- if (results == 1)
- continue;
- if (!partitions_signatures[i].anchor2.anchor)
- goto detect_partition_found_it;
-
- results = seek_and_compare(fd, partitions_signatures[i].anchor2);
- if (results == -1)
- goto detect_partition_type_end;
- if (results == 1)
- continue;
-
- detect_partition_found_it:
- part_type = partitions_signatures[i].name;
- break;
- }
-
- detect_partition_type_end:
- close(fd);
- return part_type;
-}
-
-int list_partitions(char * dev_name, char ** parts, char ** comments)
-{
- int major, minor, blocks;
- char name[100];
- FILE * f;
- int i = 0;
- char buf[512];
-
- if (!(f = fopen("/proc/partitions", "rb")) || !fgets(buf, sizeof(buf), f) || !fgets(buf, sizeof(buf), f)) {
- log_perror(dev_name);
- return 1;
- }
-
- while (fgets(buf, sizeof(buf), f)) {
- memset(name, 0, sizeof(name));
- sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, name);
- if ((strstr(name, dev_name) == name) && (blocks > 1) && (name[strlen(dev_name)] != '\0')) {
- const char * partition_type = detect_partition_type(name);
- parts[i] = strdup(name);
- comments[i] = (char *) malloc(sizeof(char) * 100);
- sprintf(comments[i], "size: %d Mbytes", blocks >> 10);
- if (partition_type) {
- strcat(comments[i], ", type: ");
- strcat(comments[i], partition_type);
- }
- i++;
- }
- }
- parts[i] = NULL;
- fclose(f);
-
- return 0;
-}
diff --git a/mdk-stage1/partition.h b/mdk-stage1/partition.h
deleted file mode 100644
index e901662df..000000000
--- a/mdk-stage1/partition.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Olivier Blin (oblin@mandrakesoft.com)
- *
- * Copyright 2005 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-/*
- * Portions from Erik Troan (ewt@redhat.com)
- *
- * Copyright 1996 Red Hat Software
- *
- */
-
-#ifndef _PARTITION_H_
-#define _PARTITION_H_
-
-int list_partitions(char * dev_name, char ** parts, char ** comments);
-
-#endif
-
diff --git a/mdk-stage1/pci-resource/.cvsignore b/mdk-stage1/pci-resource/.cvsignore
deleted file mode 100644
index 4c7b0844b..000000000
--- a/mdk-stage1/pci-resource/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-pci-ids.h
diff --git a/mdk-stage1/pci-resource/Makefile b/mdk-stage1/pci-resource/Makefile
deleted file mode 100644
index 955c92f5e..000000000
--- a/mdk-stage1/pci-resource/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
- #******************************************************************************
- #
- # $Id$
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-
-all: pci-ids.h
-
-pci-ids.h: /usr/share/ldetect-lst/pcitable update-pci-ids.pl
- perl update-pci-ids.pl > $@ || { rm -f $@; exit 1; }
-
-clean:
- rm -f pci-ids.h
diff --git a/mdk-stage1/pci-resource/update-pci-ids.pl b/mdk-stage1/pci-resource/update-pci-ids.pl
deleted file mode 100755
index 01839dcf2..000000000
--- a/mdk-stage1/pci-resource/update-pci-ids.pl
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use MDK::Common;
-
-require '/usr/bin/merge2pcitable.pl';
-my $pci = read_pcitable("/usr/share/ldetect-lst/pcitable");
-
-print '
-#define PCI_REVISION_ID 0x08 /* Revision ID */
-
-struct pci_module_map {
- unsigned short vendor; /* PCI vendor id */
- unsigned short device; /* PCI device id */
- const char *name; /* PCI human readable name */
- const char *module; /* module to load */
-};
-
-struct pci_module_map_full {
- unsigned short vendor; /* PCI vendor id */
- unsigned short device; /* PCI device id */
- unsigned short subvendor; /* PCI subvendor id */
- unsigned short subdevice; /* PCI subdevice id */
- const char *name; /* PCI human readable name */
- const char *module; /* module to load */
-};
-
-';
-
-my %t = (
- network => 'network/main|gigabit|tokenring|wireless',
- medias => 'disk/scsi|hardware_raid|sata',
-);
-
-foreach my $type (keys %t) {
- my @modules = chomp_(`perl ../../kernel/modules.pl pci_modules4stage1 "$t{$type}"`);
-
- my (@entries, @entries_full);
-
- foreach my $k (sort keys %$pci) {
- my $v = $pci->{$k};
- member($v->[0], @modules) or next;
- $k =~ /^(....)(....)(....)(....)/;
- my $values = { vendor => $1, device => $2, subvendor => $3, subdevice => $4, driver => $v->[0], description => $v->[1] };
- if ($values->{subdevice} eq 'ffff' && $values->{subvendor} eq 'ffff') {
- push @entries, $values;
- } else {
- push @entries_full, $values;
- }
- }
-
- print "#ifndef DISABLE_".uc($type)."
-struct pci_module_map ${type}_pci_ids[] = {
-";
- printf qq|\t{ 0x%s, 0x%s, "%s", "%s" },\n|, $_->{vendor}, $_->{device}, $_->{description}, $_->{driver}
- foreach @entries;
- print "};
-unsigned int ${type}_num_ids = sizeof(${type}_pci_ids) / sizeof(struct pci_module_map);
-";
-
- print "
-struct pci_module_map_full ${type}_pci_ids_full[] = {
-";
- printf qq|\t{ 0x%s, 0x%s, 0x%s, 0x%s, "%s", "%s" },\n|, $_->{vendor}, $_->{device}, $_->{subvendor}, $_->{subdevice}, $_->{description}, $_->{driver}
- foreach @entries_full;
- print "};
-unsigned int ${type}_num_ids_full = sizeof(${type}_pci_ids_full) / sizeof(struct pci_module_map_full);
-
-#endif
-
-";
-}
diff --git a/mdk-stage1/pcmcia_/Makefile b/mdk-stage1/pcmcia_/Makefile
deleted file mode 100644
index 9cecc8784..000000000
--- a/mdk-stage1/pcmcia_/Makefile
+++ /dev/null
@@ -1,37 +0,0 @@
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2001 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-top_dir = ..
-
-include $(top_dir)/Makefile.common
-
-
-all: libpcmcia.a
-
-clean:
- rm -f *.o libpcmcia.a
-
-FLAGS = -D__linux__ -Wall -Werror -Wno-deprecated-declarations -Os -fomit-frame-pointer -pipe -c -I.. -D_BSD_SOURCE
-
-
-OBJS = probe.o cardmgr.o lex_config.o yacc_config.o
-
-
-libpcmcia.a: $(OBJS)
- ar -cru $@ $^
- ranlib $@
-
-$(OBJS): %.o: %.c
- $(DIET) gcc $(FLAGS) $(INCLUDES) -c $< -o $@
diff --git a/mdk-stage1/pcmcia_/bulkmem.h b/mdk-stage1/pcmcia_/bulkmem.h
deleted file mode 100644
index 7748d4432..000000000
--- a/mdk-stage1/pcmcia_/bulkmem.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Definitions for bulk memory services
- *
- * bulkmem.h 1.13 2001/08/24 12:16:12
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- * bulkmem.h 1.3 1995/05/27 04:49:49
- */
-
-#ifndef _LINUX_BULKMEM_H
-#define _LINUX_BULKMEM_H
-
-/* For GetFirstRegion and GetNextRegion */
-typedef struct region_info_t {
- u_int Attributes;
- u_int CardOffset;
- u_int RegionSize;
- u_int AccessSpeed;
- u_int BlockSize;
- u_int PartMultiple;
- u_char JedecMfr, JedecInfo;
- memory_handle_t next;
-} region_info_t;
-
-#define REGION_TYPE 0x0001
-#define REGION_TYPE_CM 0x0000
-#define REGION_TYPE_AM 0x0001
-#define REGION_PREFETCH 0x0008
-#define REGION_CACHEABLE 0x0010
-#define REGION_BAR_MASK 0xe000
-#define REGION_BAR_SHIFT 13
-
-/* For OpenMemory */
-typedef struct open_mem_t {
- u_int Attributes;
- u_int Offset;
-} open_mem_t;
-
-/* Attributes for OpenMemory */
-#define MEMORY_TYPE 0x0001
-#define MEMORY_TYPE_CM 0x0000
-#define MEMORY_TYPE_AM 0x0001
-#define MEMORY_EXCLUSIVE 0x0002
-#define MEMORY_PREFETCH 0x0008
-#define MEMORY_CACHEABLE 0x0010
-#define MEMORY_BAR_MASK 0xe000
-#define MEMORY_BAR_SHIFT 13
-
-typedef struct eraseq_entry_t {
- memory_handle_t Handle;
- u_char State;
- u_int Size;
- u_int Offset;
- void *Optional;
-} eraseq_entry_t;
-
-typedef struct eraseq_hdr_t {
- int QueueEntryCnt;
- eraseq_entry_t *QueueEntryArray;
-} eraseq_hdr_t;
-
-#define ERASE_QUEUED 0x00
-#define ERASE_IN_PROGRESS(n) (((n) > 0) && ((n) < 0x80))
-#define ERASE_IDLE 0xff
-#define ERASE_PASSED 0xe0
-#define ERASE_FAILED 0xe1
-
-#define ERASE_MISSING 0x80
-#define ERASE_MEDIA_WRPROT 0x84
-#define ERASE_NOT_ERASABLE 0x85
-#define ERASE_BAD_OFFSET 0xc1
-#define ERASE_BAD_TECH 0xc2
-#define ERASE_BAD_SOCKET 0xc3
-#define ERASE_BAD_VCC 0xc4
-#define ERASE_BAD_VPP 0xc5
-#define ERASE_BAD_SIZE 0xc6
-
-/* For CopyMemory */
-typedef struct copy_op_t {
- u_int Attributes;
- u_int SourceOffset;
- u_int DestOffset;
- u_int Count;
-} copy_op_t;
-
-/* For ReadMemory and WriteMemory */
-typedef struct mem_op_t {
- u_int Attributes;
- u_int Offset;
- u_int Count;
-} mem_op_t;
-
-#define MEM_OP_BUFFER 0x01
-#define MEM_OP_BUFFER_USER 0x00
-#define MEM_OP_BUFFER_KERNEL 0x01
-#define MEM_OP_DISABLE_ERASE 0x02
-#define MEM_OP_VERIFY 0x04
-
-/* For RegisterMTD */
-typedef struct mtd_reg_t {
- u_int Attributes;
- u_int Offset;
- u_long MediaID;
-} mtd_reg_t;
-
-/*
- * Definitions for MTD requests
- */
-
-typedef struct mtd_request_t {
- u_int SrcCardOffset;
- u_int DestCardOffset;
- u_int TransferLength;
- u_int Function;
- u_long MediaID;
- u_int Status;
- u_int Timeout;
-} mtd_request_t;
-
-/* Fields in MTD Function */
-#define MTD_REQ_ACTION 0x003
-#define MTD_REQ_ERASE 0x000
-#define MTD_REQ_READ 0x001
-#define MTD_REQ_WRITE 0x002
-#define MTD_REQ_COPY 0x003
-#define MTD_REQ_NOERASE 0x004
-#define MTD_REQ_VERIFY 0x008
-#define MTD_REQ_READY 0x010
-#define MTD_REQ_TIMEOUT 0x020
-#define MTD_REQ_LAST 0x040
-#define MTD_REQ_FIRST 0x080
-#define MTD_REQ_KERNEL 0x100
-
-/* Status codes */
-#define MTD_WAITREQ 0x00
-#define MTD_WAITTIMER 0x01
-#define MTD_WAITRDY 0x02
-#define MTD_WAITPOWER 0x03
-
-/*
- * Definitions for MTD helper functions
- */
-
-/* For MTDModifyWindow */
-typedef struct mtd_mod_win_t {
- u_int Attributes;
- u_int AccessSpeed;
- u_int CardOffset;
-} mtd_mod_win_t;
-
-/* For MTDSetVpp */
-typedef struct mtd_vpp_req_t {
- u_char Vpp1, Vpp2;
-} mtd_vpp_req_t;
-
-/* For MTDRDYMask */
-typedef struct mtd_rdy_req_t {
- u_int Mask;
-} mtd_rdy_req_t;
-
-enum mtd_helper {
- MTDRequestWindow, MTDModifyWindow, MTDReleaseWindow,
- MTDSetVpp, MTDRDYMask
-};
-
-#ifdef IN_CARD_SERVICES
-extern int MTDHelperEntry(int func, void *a1, void *a2);
-#else
-extern int MTDHelperEntry(int func, ...);
-#endif
-
-#endif /* _LINUX_BULKMEM_H */
diff --git a/mdk-stage1/pcmcia_/cardmgr.c b/mdk-stage1/pcmcia_/cardmgr.c
deleted file mode 100644
index f67b02f72..000000000
--- a/mdk-stage1/pcmcia_/cardmgr.c
+++ /dev/null
@@ -1,1652 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * Code comes from /anonymous@projects.sourceforge.net:/pub/pcmcia-cs/pcmcia-cs-3.1.29.tar.bz2
- *
- * Licence of this code follows:
- *
- */
-/*======================================================================
-
- PCMCIA Card Manager daemon
-
- cardmgr.c 1.161 2001/08/24 12:19:19
-
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The initial developer of the original code is David A. Hinds
- <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU General Public License version 2 (the "GPL"), in
- which case the provisions of the GPL are applicable instead of the
- above. If you wish to allow the use of your version of this file
- only under the terms of the GPL and not to allow others to use
- your version of this file under the MPL, indicate your decision
- by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
-======================================================================*/
-
-#ifndef __linux__
-#include <pcmcia/u_compat.h>
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-//mdk-stage1// #include <syslog.h>
-//mdk-stage1// #include <getopt.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-#include <sys/file.h>
-
-#include <pcmcia_/version.h>
-//mdk-stage1// #include <pcmcia/config.h>
-#include <pcmcia_/cs_types.h>
-#include <pcmcia_/cs.h>
-#include <pcmcia_/cistpl.h>
-#include <pcmcia_/ds.h>
-
-#include "cardmgr.h"
-
-#include "../log.h"
-#include "modules.h"
-#include "pcmcia.h"
-
-/*====================================================================*/
-
-typedef struct socket_info_t {
- int fd;
- int state;
- card_info_t *card;
- bind_info_t *bind[MAX_BINDINGS];
- mtd_ident_t *mtd[2*CISTPL_MAX_DEVICES];
-} socket_info_t;
-
-#define SOCKET_PRESENT 0x01
-#define SOCKET_READY 0x02
-#define SOCKET_HOTPLUG 0x04
-
-/* Linked list of resource adjustments */
-struct adjust_list_t *root_adjust = NULL;
-
-/* Linked list of device definitions */
-struct device_info_t *root_device = NULL;
-
-/* Special pointer to "anonymous" card definition */
-struct card_info_t *blank_card = NULL;
-
-/* Linked list of card definitions */
-struct card_info_t *root_card = NULL;
-
-/* Linked list of function definitions */
-struct card_info_t *root_func = NULL;
-
-/* Linked list of MTD definitions */
-struct mtd_ident_t *root_mtd = NULL;
-
-/* Default MTD */
-struct mtd_ident_t *default_mtd = NULL;
-
-static int sockets;
-static struct socket_info_t socket[MAX_SOCKS];
-
-/* Default path for config file, device scripts */
-#ifdef ETC
-static char *configpath = ETC;
-#else
-static char *configpath = "/etc/pcmcia";
-#endif
-
-/* Default path for pid file */
-//mdk-stage1// static char *pidfile = "/var/run/cardmgr.pid";
-
-#ifdef __linux__
-/* Default path for finding modules */
-//mdk-stage1// static char *modpath = NULL;
-#endif
-
-/* Default path for socket info table */
-static char *stabfile;
-
-/* If set, don't generate beeps when cards are inserted */
-//mdk-stage1// static int be_quiet = 0;
-
-/* If set, use modprobe instead of insmod */
-//mdk-stage1// static int do_modprobe = 0;
-
-/* If set, configure already inserted cards, then exit */
-//mdk-stage1// static int one_pass = 0;
-
-/* Extra message logging? */
-//mdk-stage1// static int verbose = 0;
-
-/*====================================================================*/
-
-#ifdef __linux__
-
-static int major = 0;
-
-static int lookup_dev(char *name)
-{
- FILE *f;
- int n;
- char s[32], t[32];
-
- f = fopen("/proc/devices", "r");
- if (f == NULL)
- return -errno;
- while (fgets(s, 32, f) != NULL) {
- if (sscanf(s, "%d %s", &n, t) == 2)
- if (strcmp(name, t) == 0)
- break;
- }
- fclose(f);
- if (strcmp(name, t) == 0)
- return n;
- else
- return -ENODEV;
-}
-
-int open_dev(dev_t dev, int mode)
-{
- char * fn = "/tmp/cardmgr_tmp";
- int fd;
-
- unlink(fn);
- if (mknod(fn, mode, dev) != 0)
- return -1;
- fd = open(fn, (mode&S_IWRITE)?O_RDWR:O_RDONLY);
- if (fd < 0)
- fd = open(fn, O_NONBLOCK|((mode&S_IWRITE)?O_RDWR:O_RDONLY));
- unlink(fn);
- return fd;
-}
-
-#endif /* __linux__ */
-
-int open_sock(int sock, int mode)
-{
-#ifdef __linux__
- dev_t dev = (major<<8)+sock;
- return open_dev(dev, mode);
-#endif
-#ifdef __BEOS__
- int fd;
- char fn[B_OS_NAME_LENGTH];
- sprintf(fn, "/dev/pcmcia/sock%d", sock);
- return open(fn, (mode & S_IWRITE) ? O_RDWR: O_RDONLY);
-#endif
-}
-
-/*======================================================================
-
- xlate_scsi_name() is a sort-of-hack used to deduce the minor
- device numbers of SCSI devices, from the information available to
- the low-level driver.
-
-======================================================================*/
-
-#ifdef __linux__
-
-#include <linux/major.h>
-#include <scsi/scsi.h>
-//mdk-stage1// #define VERSION(v,p,s) (((v)<<16)+(p<<8)+s)
-//mdk-stage1// #if (LINUX_VERSION_CODE < VERSION(2,1,126))
-//mdk-stage1// #define SCSI_DISK0_MAJOR SCSI_DISK_MAJOR
-//mdk-stage1// #endif
-
-static int xlate_scsi_name(bind_info_t *bind)
-{
- int i, fd, mode, minor;
- u_int arg[2], id1, id2;
-
- id1 = strtol(bind->name+3, NULL, 16);
- if ((bind->major == SCSI_DISK0_MAJOR) ||
- (bind->major == SCSI_CDROM_MAJOR))
- mode = S_IREAD|S_IFBLK;
- else
- mode = S_IREAD|S_IFCHR;
-
- for (i = 0; i < 16; i++) {
- minor = (bind->major == SCSI_DISK0_MAJOR) ? (i<<4) : i;
- fd = open_dev((bind->major<<8)+minor, mode);
- if (fd < 0)
- continue;
- if (ioctl(fd, SCSI_IOCTL_GET_IDLUN, arg) == 0) {
- id2 = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
- ((arg[0]>>8)&0xf00) + ((arg[0]>>12)&0xf000);
- if (id1 == id2) {
- close(fd);
- switch (bind->major) {
- case SCSI_DISK0_MAJOR:
- case SCSI_GENERIC_MAJOR:
- sprintf(bind->name+2, "%c", 'a'+i); break;
- case SCSI_CDROM_MAJOR:
- sprintf(bind->name, "scd%d", i); break;
- case SCSI_TAPE_MAJOR:
- sprintf(bind->name+2, "%d", i); break;
- }
- bind->minor = minor;
- return 0;
- }
- }
- close(fd);
- }
- return -1;
-}
-#endif
-
-/*====================================================================*/
-
-#define BEEP_TIME 150
-#define BEEP_OK 1000
-#define BEEP_WARN 2000
-#define BEEP_ERR 4000
-
-#ifdef __linux__
-
-//mdk-stage1// #include <sys/kd.h>
-//mdk-stage1//
-static void beep(unsigned int ms, unsigned int freq)
-{
-//mdk-stage1// int fd, arg;
-//mdk-stage1//
-//mdk-stage1// if (be_quiet)
-//mdk-stage1// return;
-//mdk-stage1// fd = open("/dev/console", O_RDWR);
-//mdk-stage1// if (fd < 0)
-//mdk-stage1// return;
-//mdk-stage1// arg = (ms << 16) | freq;
-//mdk-stage1// ioctl(fd, KDMKTONE, arg);
-//mdk-stage1// close(fd);
-//mdk-stage1// usleep(ms*1000);
-}
-
-#endif /* __linux__ */
-
-#ifdef __BEOS__
-static void beep(unsigned int ms, unsigned int freq)
-{
- if (!be_quiet) system("/bin/beep");
-}
-#endif
-
-/*====================================================================*/
-
-//mdk-stage1// static void write_pid(void)
-//mdk-stage1// {
-//mdk-stage1// FILE *f;
-//mdk-stage1// f = fopen(pidfile, "w");
-//mdk-stage1// if (f == NULL)
-//mdk-stage1// syslog(LOG_WARNING, "could not open %s: %m", pidfile);
-//mdk-stage1// else {
-//mdk-stage1// fprintf(f, "%d\n", getpid());
-//mdk-stage1// fclose(f);
-//mdk-stage1// }
-//mdk-stage1// }
-
-static void write_stab(void)
-{
- int i, j, k;
- FILE *f;
- socket_info_t *s;
- bind_info_t *bind;
-
- f = fopen(stabfile, "w");
- if (f == NULL) {
- log_message("CM: fopen(stabfile) failed: %m");
- return;
- }
-#ifndef __BEOS__
- if (flock(fileno(f), LOCK_EX) != 0) {
- log_message("CM: flock(stabfile) failed: %m");
- return;
- }
-#endif
- for (i = 0; i < sockets; i++) {
- s = &socket[i];
- fprintf(f, "Socket %d: ", i);
- if (!(s->state & SOCKET_PRESENT)) {
- fprintf(f, "empty\n");
-//mdk-stage1// } else if (s->state & SOCKET_HOTPLUG) {
-//mdk-stage1// fprintf(f, "CardBus hotplug device\n");
- } else if (!s->card) {
- fprintf(f, "unsupported card\n");
- } else {
- fprintf(f, "%s\n", s->card->name);
- for (j = 0; j < s->card->bindings; j++)
- for (k = 0, bind = s->bind[j];
- bind != NULL;
- k++, bind = bind->next) {
- char *class = s->card->device[j]->class;
- fprintf(f, "%d\t%s\t%s\t%d\t%s",
- i, (class ? class : "none"),
- bind->dev_info, k, bind->name);
- if (bind->major)
- fprintf(f, "\t%d\t%d\n",
- bind->major, bind->minor);
- else
- fputc('\n', f);
- }
- }
- }
- fflush(f);
-#ifndef __BEOS__
- flock(fileno(f), LOCK_UN);
-#endif
- fclose(f);
-}
-
-/*====================================================================*/
-
-static int get_tuple(int ns, cisdata_t code, ds_ioctl_arg_t *arg)
-{
- socket_info_t *s = &socket[ns];
-
- arg->tuple.DesiredTuple = code;
- arg->tuple.Attributes = 0;
- if (ioctl(s->fd, DS_GET_FIRST_TUPLE, arg) != 0)
- return -1;
- arg->tuple.TupleOffset = 0;
- if (ioctl(s->fd, DS_GET_TUPLE_DATA, arg) != 0) {
- log_message("CM: error reading CIS data on socket %d: %m", ns);
- return -1;
- }
- if (ioctl(s->fd, DS_PARSE_TUPLE, arg) != 0) {
- log_message("CM: error parsing CIS on socket %d: %m", ns);
- return -1;
- }
- return 0;
-}
-
-/*======================================================================
-
- Code to fetch a 2.4 kernel's hot plug PCI driver list
-
- This is distasteful but is the best I could come up with.
-
-======================================================================*/
-
-#ifdef __linux__
-
-typedef struct pci_id {
- u_short vendor, device;
- struct pci_id *next;
-} pci_id_t;
-
-static int get_pci_id(int ns, pci_id_t *id)
-{
- socket_info_t *s = &socket[ns];
- config_info_t config;
-
- config.Function = config.ConfigBase = 0;
- if ((ioctl(s->fd, DS_GET_CONFIGURATION_INFO, &config) != 0) ||
- (config.IntType != INT_CARDBUS) || !config.ConfigBase)
- return 0;
- id->vendor = config.ConfigBase & 0xffff;
- id->device = config.ConfigBase >> 16;
- return 1;
-}
-
-#endif /* __linux__ */
-
-/*====================================================================*/
-
-//mdk-stage1// static void log_card_info(cistpl_vers_1_t *vers,
-//mdk-stage1// cistpl_manfid_t *manfid,
-//mdk-stage1// cistpl_funcid_t *funcid,
-//mdk-stage1// pci_id_t *pci_id)
-//mdk-stage1// {
-//mdk-stage1// char v[256] = "";
-//mdk-stage1// int i;
-//mdk-stage1// static char *fn[] = {
-//mdk-stage1// "multi", "memory", "serial", "parallel", "fixed disk",
-//mdk-stage1// "video", "network", "AIMS", "SCSI"
-//mdk-stage1// };
-//mdk-stage1//
-//mdk-stage1// if (vers) {
-//mdk-stage1// for (i = 0; i < vers->ns; i++)
-//mdk-stage1// sprintf(v+strlen(v), "%s\"%s\"",
-//mdk-stage1// (i>0) ? ", " : "", vers->str+vers->ofs[i]);
-//mdk-stage1// syslog(LOG_INFO, " product info: %s", v);
-//mdk-stage1// } else {
-//mdk-stage1// syslog(LOG_INFO, " no product info available");
-//mdk-stage1// }
-//mdk-stage1// *v = '\0';
-//mdk-stage1// if (manfid->manf != 0)
-//mdk-stage1// sprintf(v, " manfid: 0x%04x, 0x%04x",
-//mdk-stage1// manfid->manf, manfid->card);
-//mdk-stage1// if (funcid->func != 0xff)
-//mdk-stage1// sprintf(v+strlen(v), " function: %d (%s)", funcid->func,
-//mdk-stage1// fn[funcid->func]);
-//mdk-stage1// if (strlen(v) > 0) syslog(LOG_INFO, "%s", v);
-//mdk-stage1// if (pci_id->vendor != 0)
-//mdk-stage1// syslog(LOG_INFO, " PCI id: 0x%04x, 0x%04x",
-//mdk-stage1// pci_id->vendor, pci_id->device);
-//mdk-stage1// }
-
-static card_info_t *lookup_card(int ns)
-{
- socket_info_t *s = &socket[ns];
- card_info_t *card = NULL;
- ds_ioctl_arg_t arg;
- cistpl_vers_1_t *vers = NULL;
- cistpl_manfid_t manfid = { 0, 0 };
- pci_id_t pci_id = { 0, 0 };
- cistpl_funcid_t funcid = { 0xff, 0xff };
- cs_status_t status;
- int i, ret, has_cis = 0;
-
- /* Do we have a CIS structure? */
- ret = ioctl(s->fd, DS_VALIDATE_CIS, &arg);
- has_cis = ((ret == 0) && (arg.cisinfo.Chains > 0));
-
- /* Try to read VERS_1, MANFID tuples */
- if (has_cis) {
- /* rule of thumb: cards with no FUNCID, but with common memory
- device geometry information, are probably memory cards */
- if (get_tuple(ns, CISTPL_FUNCID, &arg) == 0)
- memcpy(&funcid, &arg.tuple_parse.parse.funcid,
- sizeof(funcid));
- else if (get_tuple(ns, CISTPL_DEVICE_GEO, &arg) == 0)
- funcid.func = CISTPL_FUNCID_MEMORY;
- if (get_tuple(ns, CISTPL_MANFID, &arg) == 0)
- memcpy(&manfid, &arg.tuple_parse.parse.manfid,
- sizeof(manfid));
- if (get_tuple(ns, CISTPL_VERS_1, &arg) == 0)
- vers = &arg.tuple_parse.parse.version_1;
-
- for (card = root_card; card; card = card->next) {
-
- if (card->ident_type &
- ~(VERS_1_IDENT|MANFID_IDENT|TUPLE_IDENT))
- continue;
-
- if (card->ident_type & VERS_1_IDENT) {
- if (vers == NULL)
- continue;
- for (i = 0; i < card->id.vers.ns; i++) {
- if (strcmp(card->id.vers.pi[i], "*") == 0)
- continue;
- if (i >= vers->ns)
- break;
- if (strcmp(card->id.vers.pi[i],
- vers->str+vers->ofs[i]) != 0)
- break;
- }
- if (i < card->id.vers.ns)
- continue;
- }
-
- if (card->ident_type & MANFID_IDENT) {
- if ((manfid.manf != card->manfid.manf) ||
- (manfid.card != card->manfid.card))
- continue;
- }
-
- if (card->ident_type & TUPLE_IDENT) {
- arg.tuple.DesiredTuple = card->id.tuple.code;
- arg.tuple.Attributes = 0;
- ret = ioctl(s->fd, DS_GET_FIRST_TUPLE, &arg);
- if (ret != 0) continue;
- arg.tuple.TupleOffset = card->id.tuple.ofs;
- ret = ioctl(s->fd, DS_GET_TUPLE_DATA, &arg);
- if (ret != 0) continue;
- if (strncmp((char *)arg.tuple_parse.data,
- card->id.tuple.info,
- strlen(card->id.tuple.info)) != 0)
- continue;
- }
-
- break; /* we have a match */
- }
- }
-
- /* Check PCI vendor/device info */
- status.Function = 0;
- ioctl(s->fd, DS_GET_STATUS, &status);
- if (status.CardState & CS_EVENT_CB_DETECT) {
- if (get_pci_id(ns, &pci_id)) {
- if (!card) {
- for (card = root_card; card; card = card->next)
- if ((card->ident_type == PCI_IDENT) &&
- (pci_id.vendor == card->manfid.manf) &&
- (pci_id.device == card->manfid.card))
- break;
- }
- } else {
- /* this is a 2.4 kernel; hotplug handles these cards */
-//mdk-stage1// s->state |= SOCKET_HOTPLUG;
- log_message("CM: socket %d: CardBus hotplug device", ns);
- //beep(BEEP_TIME, BEEP_OK);
-//mdk-stage1// return NULL;
- }
- }
-
- /* Try for a FUNCID match */
- if (!card && (funcid.func != 0xff)) {
- for (card = root_func; card; card = card->next)
- if (card->id.func.funcid == funcid.func)
- break;
- }
-
- if (card) {
- log_message("CM: socket %d: %s", ns, card->name);
- beep(BEEP_TIME, BEEP_OK);
-//mdk-stage1// if (verbose) log_card_info(vers, &manfid, &funcid, &pci_id);
- return card;
- }
-
- if (!blank_card || (status.CardState & CS_EVENT_CB_DETECT) ||
- manfid.manf || manfid.card || pci_id.vendor || vers) {
- log_message("CM: unsupported card in socket %d", ns);
-//mdk-stage1// if (one_pass) return NULL;
- beep(BEEP_TIME, BEEP_ERR);
-//mdk-stage1// log_card_info(vers, &manfid, &funcid, &pci_id);
- return NULL;
- } else {
- card = blank_card;
- log_message("CM: socket %d: %s", ns, card->name);
- beep(BEEP_TIME, BEEP_WARN);
- return card;
- }
-}
-
-/*====================================================================*/
-
-static int load_config(void)
-{
- if (chdir(configpath) != 0) {
- log_message("CM: chdir to %s failed: %m", configpath);
- return -1;
- }
- if (parse_configfile("config") != 0) {
- log_message("CM: parsing of config file failed: %m");
- return -1;
- }
- if (root_device == NULL)
- log_message("CM: no device drivers defined");
- if ((root_card == NULL) && (root_func == NULL))
- log_message("CM: no cards defined");
- return 0;
-}
-
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static void free_card(card_info_t *card)
-//mdk-stage1// {
-//mdk-stage1// if (card && (--card->refs == 0)) {
-//mdk-stage1// int i;
-//mdk-stage1// free(card->name);
-//mdk-stage1// switch(card->ident_type) {
-//mdk-stage1// case VERS_1_IDENT:
-//mdk-stage1// for (i = 0; i < card->id.vers.ns; i++)
-//mdk-stage1// free(card->id.vers.pi[i]);
-//mdk-stage1// break;
-//mdk-stage1// case TUPLE_IDENT:
-//mdk-stage1// free(card->id.tuple.info);
-//mdk-stage1// break;
-//mdk-stage1// default:
-//mdk-stage1// break;
-//mdk-stage1// }
-//mdk-stage1// free(card);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static void free_device(device_info_t *dev)
-//mdk-stage1// {
-//mdk-stage1// if (dev && (--dev->refs == 0)) {
-//mdk-stage1// int i;
-//mdk-stage1// for (i = 0; i < dev->modules; i++) {
-//mdk-stage1// free(dev->module[i]);
-//mdk-stage1// if (dev->opts[i]) free(dev->opts[i]);
-//mdk-stage1// }
-//mdk-stage1// if (dev->class) free(dev->class);
-//mdk-stage1// free(dev);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static void free_mtd(mtd_ident_t *mtd)
-//mdk-stage1// {
-//mdk-stage1// if (mtd && (--mtd->refs == 0)) {
-//mdk-stage1// free(mtd->name);
-//mdk-stage1// free(mtd->module);
-//mdk-stage1// free(mtd);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static void free_config(void)
-//mdk-stage1// {
-//mdk-stage1// while (root_adjust != NULL) {
-//mdk-stage1// adjust_list_t *adj = root_adjust;
-//mdk-stage1// root_adjust = root_adjust->next;
-//mdk-stage1// free(adj);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// while (root_device != NULL) {
-//mdk-stage1// device_info_t *dev = root_device;
-//mdk-stage1// root_device = root_device->next;
-//mdk-stage1// free_device(dev);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// while (root_card != NULL) {
-//mdk-stage1// card_info_t *card = root_card;
-//mdk-stage1// root_card = root_card->next;
-//mdk-stage1// free_card(card);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// while (root_func != NULL) {
-//mdk-stage1// card_info_t *card = root_func;
-//mdk-stage1// root_func = root_func->next;
-//mdk-stage1// free_card(card);
-//mdk-stage1// }
-//mdk-stage1// blank_card = NULL;
-//mdk-stage1//
-//mdk-stage1// while (root_mtd != NULL) {
-//mdk-stage1// mtd_ident_t *mtd = root_mtd;
-//mdk-stage1// root_mtd = root_mtd->next;
-//mdk-stage1// free_mtd(mtd);
-//mdk-stage1// }
-//mdk-stage1// default_mtd = NULL;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static int execute(char *msg, char *cmd)
-//mdk-stage1// {
-//mdk-stage1// int ret;
-//mdk-stage1// FILE *f;
-//mdk-stage1// char line[256];
-//mdk-stage1//
-//mdk-stage1// syslog(LOG_INFO, "executing: '%s'", cmd);
-//mdk-stage1// strcat(cmd, " 2>&1");
-//mdk-stage1// f = popen(cmd, "r");
-//mdk-stage1// while (fgets(line, 255, f)) {
-//mdk-stage1// line[strlen(line)-1] = '\0';
-//mdk-stage1// syslog(LOG_INFO, "+ %s", line);
-//mdk-stage1// }
-//mdk-stage1// ret = pclose(f);
-//mdk-stage1// if (WIFEXITED(ret)) {
-//mdk-stage1// if (WEXITSTATUS(ret))
-//mdk-stage1// syslog(LOG_INFO, "%s exited with status %d",
-//mdk-stage1// msg, WEXITSTATUS(ret));
-//mdk-stage1// return WEXITSTATUS(ret);
-//mdk-stage1// } else
-//mdk-stage1// syslog(LOG_INFO, "%s exited on signal %d",
-//mdk-stage1// msg, WTERMSIG(ret));
-//mdk-stage1// return -1;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static int execute_on_dev(char *action, char *class, char *dev)
-//mdk-stage1// {
-//mdk-stage1// /* Fixed length strings are ok here */
-//mdk-stage1// char msg[128], cmd[128];
-//mdk-stage1//
-//mdk-stage1// sprintf(msg, "%s cmd", action);
-//mdk-stage1// sprintf(cmd, "./%s %s %s", class, action, dev);
-//mdk-stage1// return execute(msg, cmd);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static int execute_on_all(char *cmd, char *class, int sn, int fn)
-//mdk-stage1// {
-//mdk-stage1// socket_info_t *s = &socket[sn];
-//mdk-stage1// bind_info_t *bind;
-//mdk-stage1// int ret = 0;
-//mdk-stage1// for (bind = s->bind[fn]; bind != NULL; bind = bind->next)
-//mdk-stage1// if (bind->name[0] && (bind->name[2] != '#'))
-//mdk-stage1// ret |= execute_on_dev(cmd, class, bind->name);
-//mdk-stage1// return ret;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// #ifdef __linux__
-//mdk-stage1//
-//mdk-stage1// typedef struct module_list_t {
-//mdk-stage1// char *mod;
-//mdk-stage1// int usage;
-//mdk-stage1// struct module_list_t *next;
-//mdk-stage1// } module_list_t;
-//mdk-stage1//
-//mdk-stage1// static module_list_t *module_list = NULL;
-//mdk-stage1//
-//mdk-stage1// static int try_insmod(char *mod, char *opts)
-//mdk-stage1// {
-//mdk-stage1// char *cmd = malloc(strlen(mod) + strlen(modpath) +
-//mdk-stage1// (opts ? strlen(opts) : 0) + 30);
-//mdk-stage1// int ret;
-//mdk-stage1//
-//mdk-stage1// strcpy(cmd, "insmod ");
-//mdk-stage1// if (strchr(mod, '/') != NULL)
-//mdk-stage1// sprintf(cmd+7, "%s/%s.o", modpath, mod);
-//mdk-stage1// else
-//mdk-stage1// sprintf(cmd+7, "%s/pcmcia/%s.o", modpath, mod);
-//mdk-stage1// if (access(cmd+7, R_OK) != 0) {
-//mdk-stage1// syslog(LOG_INFO, "module %s not available", cmd+7);
-//mdk-stage1// free(cmd);
-//mdk-stage1// return -1;
-//mdk-stage1// }
-//mdk-stage1// if (opts) {
-//mdk-stage1// strcat(cmd, " ");
-//mdk-stage1// strcat(cmd, opts);
-//mdk-stage1// }
-//mdk-stage1// ret = execute("insmod", cmd);
-//mdk-stage1// free(cmd);
-//mdk-stage1// return ret;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static int try_modprobe(char *mod, char *opts)
-//mdk-stage1// {
-//mdk-stage1// char *cmd = malloc(strlen(mod) + (opts ? strlen(opts) : 0) + 20);
-//mdk-stage1// char *s = strrchr(mod, '/');
-//mdk-stage1// int ret;
-//mdk-stage1//
-//mdk-stage1// sprintf(cmd, "modprobe %s", (s) ? s+1 : mod);
-//mdk-stage1// if (opts) {
-//mdk-stage1// strcat(cmd, " ");
-//mdk-stage1// strcat(cmd, opts);
-//mdk-stage1// }
-//mdk-stage1// ret = execute("modprobe", cmd);
-//mdk-stage1// free(cmd);
-//mdk-stage1// return ret;
-//mdk-stage1// }
-
-static void install_module(char *mod, char *opts)
-{
- my_insmod(mod, ANY_DRIVER_TYPE, opts, 1);
-//mdk-stage1// module_list_t *ml;
-//mdk-stage1//
-//mdk-stage1// for (ml = module_list; ml != NULL; ml = ml->next)
-//mdk-stage1// if (strcmp(mod, ml->mod) == 0) break;
-//mdk-stage1// if (ml == NULL) {
-//mdk-stage1// ml = (module_list_t *)malloc(sizeof(struct module_list_t));
-//mdk-stage1// ml->mod = mod;
-//mdk-stage1// ml->usage = 0;
-//mdk-stage1// ml->next = module_list;
-//mdk-stage1// module_list = ml;
-//mdk-stage1// }
-//mdk-stage1// ml->usage++;
-//mdk-stage1// if (ml->usage != 1)
-//mdk-stage1// return;
-//mdk-stage1//
-//mdk-stage1// #ifdef __linux__
-//mdk-stage1// if (access("/proc/bus/pccard/drivers", R_OK) == 0) {
-//mdk-stage1// FILE *f = fopen("/proc/bus/pccard/drivers", "r");
-//mdk-stage1// if (f) {
-//mdk-stage1// char a[61], s[33];
-//mdk-stage1// while (fgets(a, 60, f)) {
-//mdk-stage1// int is_kernel;
-//mdk-stage1// sscanf(a, "%s %d", s, &is_kernel);
-//mdk-stage1// if (strcmp(s, mod) != 0) continue;
-//mdk-stage1// /* If it isn't a module, we won't try to rmmod */
-//mdk-stage1// ml->usage += is_kernel;
-//mdk-stage1// fclose(f);
-//mdk-stage1// return;
-//mdk-stage1// }
-//mdk-stage1// fclose(f);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// #endif
-//mdk-stage1//
-//mdk-stage1// if (do_modprobe) {
-//mdk-stage1// if (try_modprobe(mod, opts) != 0)
-//mdk-stage1// try_insmod(mod, opts);
-//mdk-stage1// } else {
-//mdk-stage1// if (try_insmod(mod, opts) != 0)
-//mdk-stage1// try_modprobe(mod, opts);
-//mdk-stage1// }
-}
-
-//mdk-stage1// static void remove_module(char *mod)
-//mdk-stage1// {
-//mdk-stage1// char *s, cmd[128];
-//mdk-stage1// module_list_t *ml;
-//mdk-stage1//
-//mdk-stage1// for (ml = module_list; ml != NULL; ml = ml->next)
-//mdk-stage1// if (strcmp(mod, ml->mod) == 0) break;
-//mdk-stage1// if (ml != NULL) {
-//mdk-stage1// ml->usage--;
-//mdk-stage1// if (ml->usage == 0) {
-//mdk-stage1// /* Strip off leading path names */
-//mdk-stage1// s = strrchr(mod, '/');
-//mdk-stage1// s = (s) ? s+1 : mod;
-//mdk-stage1// sprintf(cmd, do_modprobe ? "modprobe -r %s" : "rmmod %s", s);
-//mdk-stage1// execute(do_modprobe ? "modprobe" : "rmmod", cmd);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// #endif /* __linux__ */
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// #ifdef __BEOS__
-//mdk-stage1//
-//mdk-stage1// #define install_module(a,b)
-//mdk-stage1// #define remove_module(a)
-//mdk-stage1//
-//mdk-stage1// static void republish_driver(char *mod)
-//mdk-stage1// {
-//mdk-stage1// int fd = open("/dev", O_RDWR);
-//mdk-stage1// write(fd, mod, strlen(mod));
-//mdk-stage1// close(fd);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// #endif /* __BEOS__ */
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-
-static mtd_ident_t *lookup_mtd(region_info_t *region)
-{
- mtd_ident_t *mtd;
- int match = 0;
-
- for (mtd = root_mtd; mtd; mtd = mtd->next) {
- switch (mtd->mtd_type) {
- case JEDEC_MTD:
- if ((mtd->jedec_mfr == region->JedecMfr) &&
- (mtd->jedec_info == region->JedecInfo)) {
- match = 1;
- break;
- }
- case DTYPE_MTD:
- break;
- default:
- break;
- }
- if (match) break;
- }
- if (mtd)
- return mtd;
- else
- return default_mtd;
-}
-
-/*====================================================================*/
-
-static void bind_mtd(int sn)
-{
- socket_info_t *s = &socket[sn];
- region_info_t region;
- bind_info_t bind;
- mtd_info_t mtd_info;
- mtd_ident_t *mtd;
- int i, attr, ret, nr;
-
- nr = 0;
- for (attr = 0; attr < 2; attr++) {
- region.Attributes = attr;
- ret = ioctl(s->fd, DS_GET_FIRST_REGION, &region);
- while (ret == 0) {
- mtd = lookup_mtd(&region);
- if (mtd) {
- /* Have we seen this MTD before? */
- for (i = 0; i < nr; i++)
- if (s->mtd[i] == mtd) break;
- if (i == nr) {
- install_module(mtd->module, mtd->opts);
- s->mtd[nr] = mtd;
- mtd->refs++;
- nr++;
- }
- log_message("CM: %s memory region at 0x%x: %s",
- attr ? "Attribute" : "Common", region.CardOffset,
- mtd->name);
- /* Bind MTD to this region */
- strcpy(mtd_info.dev_info, s->mtd[i]->module);
- mtd_info.Attributes = region.Attributes;
- mtd_info.CardOffset = region.CardOffset;
- if (ioctl(s->fd, DS_BIND_MTD, &mtd_info) != 0) {
- log_message("CM: bind MTD '%s' to region at 0x%x failed: %m",
- (char *)mtd_info.dev_info, region.CardOffset);
- }
- }
- ret = ioctl(s->fd, DS_GET_NEXT_REGION, &region);
- }
- }
- s->mtd[nr] = NULL;
-
- /* Now bind each unique MTD as a normal client of this socket */
- for (i = 0; i < nr; i++) {
- strcpy(bind.dev_info, s->mtd[i]->module);
- bind.function = 0;
- if (ioctl(s->fd, DS_BIND_REQUEST, &bind) != 0)
- log_message("CM: bind MTD '%s' to socket %d failed: %m",
- (char *)bind.dev_info, sn);
- }
-}
-
-/*====================================================================*/
-
-static void update_cis(socket_info_t *s)
-{
- cisdump_t cis;
- FILE *f = fopen(s->card->cis_file, "r");
- if (f == NULL)
- log_message("CM: could not open '%s': %m", s->card->cis_file);
- else {
- cis.Length = fread(cis.Data, 1, CISTPL_MAX_CIS_SIZE, f);
- fclose(f);
- if (ioctl(s->fd, DS_REPLACE_CIS, &cis) != 0)
- log_message("CM: could not replace CIS: %m");
- }
-}
-
-/*====================================================================*/
-
-static void do_insert(int sn)
-{
- socket_info_t *s = &socket[sn];
- card_info_t *card;
- device_info_t **dev;
- bind_info_t *bind, **tail;
- int i, j, ret;
-
- /* Already identified? */
- if ((s->card != NULL) && (s->card != blank_card))
- return;
-
- log_message("CM: initializing socket %d", sn);
- card = lookup_card(sn);
- if (s->state & SOCKET_HOTPLUG) {
- write_stab();
- return;
- }
- /* Make sure we've learned something new before continuing */
- if (card == s->card)
- return;
- s->card = card;
- card->refs++;
- if (card->cis_file) update_cis(s);
-
- dev = card->device;
-
- /* Set up MTD's */
- for (i = 0; i < card->bindings; i++)
- if (dev[i]->needs_mtd)
- break;
- if (i < card->bindings)
- bind_mtd(sn);
-
-#ifdef __linux__
- /* Install kernel modules */
- for (i = 0; i < card->bindings; i++) {
- dev[i]->refs++;
- for (j = 0; j < dev[i]->modules; j++)
- install_module(dev[i]->module[j], dev[i]->opts[j]);
- }
-#endif
-
- /* Bind drivers by their dev_info identifiers */
- for (i = 0; i < card->bindings; i++) {
- bind = calloc(1, sizeof(bind_info_t));
- strcpy((char *)bind->dev_info, (char *)dev[i]->dev_info);
- if (strcmp(bind->dev_info, "cb_enabler") == 0)
- bind->function = BIND_FN_ALL;
- else
- bind->function = card->dev_fn[i];
- if (ioctl(s->fd, DS_BIND_REQUEST, bind) != 0) {
- if (errno == EBUSY) {
- log_message("CM: '%s' already bound to socket %d",
- (char *)bind->dev_info, sn);
- } else {
- log_message("CM: bind '%s' to socket %d failed: %m",
- (char *)bind->dev_info, sn);
- beep(BEEP_TIME, BEEP_ERR);
- write_stab();
- return;
- }
- }
-
-#ifdef __BEOS__
- republish_driver(dev[i]->module[0]);
-#endif
-
- for (ret = j = 0; j < 10; j++) {
- ret = ioctl(s->fd, DS_GET_DEVICE_INFO, bind);
- if ((ret == 0) || (errno != EAGAIN))
- break;
- usleep(100000);
- }
- if (ret != 0) {
- log_message("CM: get dev info on socket %d failed: %m",
- sn);
- ioctl(s->fd, DS_UNBIND_REQUEST, bind);
- beep(BEEP_TIME, BEEP_ERR);
- write_stab();
- return;
- }
- tail = &s->bind[i];
- while (ret == 0) {
- bind_info_t *old;
-#ifdef __linux__
- if ((strlen(bind->name) > 3) && (bind->name[2] == '#'))
- xlate_scsi_name(bind);
-#endif
- old = *tail = bind; tail = (bind_info_t **)&bind->next;
- bind = (bind_info_t *)malloc(sizeof(bind_info_t));
- memcpy(bind, old, sizeof(bind_info_t));
- ret = ioctl(s->fd, DS_GET_NEXT_DEVICE, bind);
- }
- *tail = NULL; free(bind);
- write_stab();
- }
-
-//mdk-stage1// /* Run "start" commands */
-//mdk-stage1// for (i = ret = 0; i < card->bindings; i++)
-//mdk-stage1// if (dev[i]->class)
-//mdk-stage1// ret |= execute_on_all("start", dev[i]->class, sn, i);
-//mdk-stage1// beep(BEEP_TIME, (ret) ? BEEP_ERR : BEEP_OK);
-
-}
-
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static int do_check(int sn)
-//mdk-stage1// {
-//mdk-stage1// socket_info_t *s = &socket[sn];
-//mdk-stage1// card_info_t *card;
-//mdk-stage1// device_info_t **dev;
-//mdk-stage1// int i, ret;
-//mdk-stage1//
-//mdk-stage1// card = s->card;
-//mdk-stage1// if (card == NULL)
-//mdk-stage1// return 0;
-//mdk-stage1//
-//mdk-stage1// /* Run "check" commands */
-//mdk-stage1// dev = card->device;
-//mdk-stage1// for (i = 0; i < card->bindings; i++) {
-//mdk-stage1// if (dev[i]->class) {
-//mdk-stage1// ret = execute_on_all("check", dev[i]->class, sn, i);
-//mdk-stage1// if (ret != 0)
-//mdk-stage1// return CS_IN_USE;
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// return 0;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static void do_remove(int sn)
-//mdk-stage1// {
-//mdk-stage1// socket_info_t *s = &socket[sn];
-//mdk-stage1// card_info_t *card;
-//mdk-stage1// device_info_t **dev;
-//mdk-stage1// bind_info_t *bind;
-//mdk-stage1// int i, j;
-//mdk-stage1//
-//mdk-stage1// if (verbose) syslog(LOG_INFO, "shutting down socket %d", sn);
-//mdk-stage1//
-//mdk-stage1// card = s->card;
-//mdk-stage1// if (card == NULL)
-//mdk-stage1// goto done;
-//mdk-stage1//
-//mdk-stage1// /* Run "stop" commands */
-//mdk-stage1// dev = card->device;
-//mdk-stage1// for (i = 0; i < card->bindings; i++) {
-//mdk-stage1// if (dev[i]->class) {
-//mdk-stage1// execute_on_all("stop", dev[i]->class, sn, i);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /* unbind driver instances */
-//mdk-stage1// for (i = 0; i < card->bindings; i++) {
-//mdk-stage1// if (s->bind[i]) {
-//mdk-stage1// if (ioctl(s->fd, DS_UNBIND_REQUEST, s->bind[i]) != 0)
-//mdk-stage1// syslog(LOG_INFO, "unbind '%s' from socket %d failed: %m",
-//mdk-stage1// (char *)s->bind[i]->dev_info, sn);
-//mdk-stage1// while (s->bind[i]) {
-//mdk-stage1// bind = s->bind[i];
-//mdk-stage1// s->bind[i] = bind->next;
-//mdk-stage1// free(bind);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// for (i = 0; (s->mtd[i] != NULL); i++) {
-//mdk-stage1// bind_info_t b;
-//mdk-stage1// strcpy(b.dev_info, s->mtd[i]->module);
-//mdk-stage1// b.function = 0;
-//mdk-stage1// if (ioctl(s->fd, DS_UNBIND_REQUEST, &b) != 0)
-//mdk-stage1// syslog(LOG_INFO, "unbind MTD '%s' from socket %d failed: %m",
-//mdk-stage1// s->mtd[i]->module, sn);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /* remove kernel modules in inverse order */
-//mdk-stage1// for (i = 0; i < card->bindings; i++) {
-//mdk-stage1// for (j = dev[i]->modules-1; j >= 0; j--)
-//mdk-stage1// remove_module(dev[i]->module[j]);
-//mdk-stage1// free_device(dev[i]);
-//mdk-stage1// }
-//mdk-stage1// /* Remove any MTD's bound to this socket */
-//mdk-stage1// for (i = 0; (s->mtd[i] != NULL); i++) {
-//mdk-stage1// remove_module(s->mtd[i]->module);
-//mdk-stage1// free_mtd(s->mtd[i]);
-//mdk-stage1// s->mtd[i] = NULL;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// done:
-//mdk-stage1// beep(BEEP_TIME, BEEP_OK);
-//mdk-stage1// free_card(card);
-//mdk-stage1// s->card = NULL;
-//mdk-stage1// write_stab();
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static void do_suspend(int sn)
-//mdk-stage1// {
-//mdk-stage1// socket_info_t *s = &socket[sn];
-//mdk-stage1// card_info_t *card;
-//mdk-stage1// device_info_t **dev;
-//mdk-stage1// int i, ret;
-//mdk-stage1//
-//mdk-stage1// card = s->card;
-//mdk-stage1// if (card == NULL)
-//mdk-stage1// return;
-//mdk-stage1// dev = card->device;
-//mdk-stage1// for (i = 0; i < card->bindings; i++) {
-//mdk-stage1// if (dev[i]->class) {
-//mdk-stage1// ret = execute_on_all("suspend", dev[i]->class, sn, i);
-//mdk-stage1// if (ret != 0)
-//mdk-stage1// beep(BEEP_TIME, BEEP_ERR);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static void do_resume(int sn)
-//mdk-stage1// {
-//mdk-stage1// socket_info_t *s = &socket[sn];
-//mdk-stage1// card_info_t *card;
-//mdk-stage1// device_info_t **dev;
-//mdk-stage1// int i, ret;
-//mdk-stage1//
-//mdk-stage1// card = s->card;
-//mdk-stage1// if (card == NULL)
-//mdk-stage1// return;
-//mdk-stage1// dev = card->device;
-//mdk-stage1// for (i = 0; i < card->bindings; i++) {
-//mdk-stage1// if (dev[i]->class) {
-//mdk-stage1// ret = execute_on_all("resume", dev[i]->class, sn, i);
-//mdk-stage1// if (ret != 0)
-//mdk-stage1// beep(BEEP_TIME, BEEP_ERR);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// }
-
-/*====================================================================*/
-
-static void wait_for_pending(void)
-{
- cs_status_t status;
- int i;
- status.Function = 0;
- for (;;) {
- usleep(100000);
- for (i = 0; i < sockets; i++)
- if ((ioctl(socket[i].fd, DS_GET_STATUS, &status) == 0) &&
- (status.CardState & CS_EVENT_CARD_INSERTION))
- break;
- if (i == sockets) break;
- }
-}
-
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static void free_resources(void)
-//mdk-stage1// {
-//mdk-stage1// adjust_list_t *al;
-//mdk-stage1// int fd = socket[0].fd;
-//mdk-stage1//
-//mdk-stage1// for (al = root_adjust; al; al = al->next) {
-//mdk-stage1// if (al->adj.Action == ADD_MANAGED_RESOURCE) {
-//mdk-stage1// al->adj.Action = REMOVE_MANAGED_RESOURCE;
-//mdk-stage1// ioctl(fd, DS_ADJUST_RESOURCE_INFO, &al->adj);
-//mdk-stage1// } else if ((al->adj.Action == REMOVE_MANAGED_RESOURCE) &&
-//mdk-stage1// (al->adj.Resource == RES_IRQ)) {
-//mdk-stage1// al->adj.Action = ADD_MANAGED_RESOURCE;
-//mdk-stage1// ioctl(fd, DS_ADJUST_RESOURCE_INFO, &al->adj);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// }
-
-/*====================================================================*/
-
-static void adjust_resources(void)
-{
- adjust_list_t *al;
- int ret;
- char tmp[64];
- int fd = socket[0].fd;
-
- for (al = root_adjust; al; al = al->next) {
- ret = ioctl(fd, DS_ADJUST_RESOURCE_INFO, &al->adj);
- if (ret != 0) {
- switch (al->adj.Resource) {
- case RES_MEMORY_RANGE:
- sprintf(tmp, "memory %#lx-%#lx",
- al->adj.resource.memory.Base,
- al->adj.resource.memory.Base +
- al->adj.resource.memory.Size - 1);
- break;
- case RES_IO_RANGE:
- sprintf(tmp, "IO ports %#x-%#x",
- al->adj.resource.io.BasePort,
- al->adj.resource.io.BasePort +
- al->adj.resource.io.NumPorts - 1);
- break;
- case RES_IRQ:
- sprintf(tmp, "irq %u", al->adj.resource.irq.IRQ);
- break;
- }
- log_message("CM: could not adjust resource: %s: %m", tmp);
- }
- }
-}
-
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// static int cleanup_files = 0;
-//mdk-stage1//
-//mdk-stage1// static void fork_now(void)
-//mdk-stage1// {
-//mdk-stage1// int ret;
-//mdk-stage1// if ((ret = fork()) > 0) {
-//mdk-stage1// cleanup_files = 0;
-//mdk-stage1// exit(0);
-//mdk-stage1// }
-//mdk-stage1// if (ret == -1)
-//mdk-stage1// syslog(LOG_ERR, "forking: %m");
-//mdk-stage1// if (setsid() < 0)
-//mdk-stage1// syslog(LOG_ERR, "detaching from tty: %m");
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static void done(void)
-//mdk-stage1// {
-//mdk-stage1// syslog(LOG_INFO, "exiting");
-//mdk-stage1// if (cleanup_files) {
-//mdk-stage1// unlink(pidfile);
-//mdk-stage1// unlink(stabfile);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// /* most recent signal */
-//mdk-stage1// static int caught_signal = 0;
-//mdk-stage1//
-//mdk-stage1// static void catch_signal(int sig)
-//mdk-stage1// {
-//mdk-stage1// caught_signal = sig;
-//mdk-stage1// if (signal(sig, catch_signal) == SIG_ERR)
-//mdk-stage1// syslog(LOG_INFO, "signal(%d): %m", sig);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// static void handle_signal(void)
-//mdk-stage1// {
-//mdk-stage1// int i;
-//mdk-stage1// switch (caught_signal) {
-//mdk-stage1// case SIGTERM:
-//mdk-stage1// case SIGINT:
-//mdk-stage1// for (i = 0; i < sockets; i++)
-//mdk-stage1// if ((socket[i].state & SOCKET_PRESENT) &&
-//mdk-stage1// (do_check(i) == 0)) do_remove(i);
-//mdk-stage1// free_resources();
-//mdk-stage1// exit(0);
-//mdk-stage1// break;
-//mdk-stage1// case SIGHUP:
-//mdk-stage1// free_resources();
-//mdk-stage1// free_config();
-//mdk-stage1// syslog(LOG_INFO, "re-loading config file");
-//mdk-stage1// load_config();
-//mdk-stage1// adjust_resources();
-//mdk-stage1// break;
-//mdk-stage1// #ifdef SIGPWR
-//mdk-stage1// case SIGPWR:
-//mdk-stage1// break;
-//mdk-stage1// #endif
-//mdk-stage1// }
-//mdk-stage1// }
-
-/*====================================================================*/
-
-static int init_sockets(void)
-{
- int fd, i;
- servinfo_t serv;
-
-#ifdef __linux__
- major = lookup_dev("pcmcia");
- if (major < 0) {
- if (major == -ENODEV)
- log_message("CM: no pcmcia driver in /proc/devices");
- else
- log_message("CM: could not open /proc/devices: %m");
- return -1;
- }
-#endif
- for (fd = -1, i = 0; i < MAX_SOCKS; i++) {
- fd = open_sock(i, S_IFCHR|S_IREAD|S_IWRITE);
- if (fd < 0) break;
- socket[i].fd = fd;
- socket[i].state = 0;
- }
- if ((fd < 0) && (errno != ENODEV) && (errno != ENOENT))
- log_message("CM: open_sock(socket %d) failed: %m", i);
- sockets = i;
- if (sockets == 0) {
- log_message("CM: no sockets found!");
- return -1;
- } else
- log_message("CM: watching %d sockets", sockets);
-
- if (ioctl(socket[0].fd, DS_GET_CARD_SERVICES_INFO, &serv) == 0) {
- if (serv.Revision != CS_RELEASE_CODE)
- log_message("CM: warning, Card Services release does not match kernel (generally harmless)");
- } else {
- log_message("CM: could not get CS revision info!");
- return -1;
- }
- adjust_resources();
- return 0;
-}
-
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// int main(int argc, char *argv[])
-//mdk-stage1// {
-//mdk-stage1// int optch, errflg;
-//mdk-stage1// int i, max_fd, ret, event, pass;
-//mdk-stage1// int delay_fork = 0;
-//mdk-stage1// struct timeval tv;
-//mdk-stage1// fd_set fds;
-//mdk-stage1//
-//mdk-stage1// if (access("/var/lib/pcmcia", R_OK) == 0) {
-//mdk-stage1// stabfile = "/var/lib/pcmcia/stab";
-//mdk-stage1// } else {
-//mdk-stage1// stabfile = "/var/run/stab";
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// errflg = 0;
-//mdk-stage1// while ((optch = getopt(argc, argv, "Vqdvofc:m:p:s:")) != -1) {
-//mdk-stage1// switch (optch) {
-//mdk-stage1// case 'V':
-//mdk-stage1// fprintf(stderr, "cardmgr version " CS_RELEASE "\n");
-//mdk-stage1// return 0;
-//mdk-stage1// break;
-//mdk-stage1// case 'q':
-//mdk-stage1// be_quiet = 1; break;
-//mdk-stage1// case 'v':
-//mdk-stage1// verbose = 1; break;
-//mdk-stage1// case 'o':
-//mdk-stage1// one_pass = 1; break;
-//mdk-stage1// case 'f':
-//mdk-stage1// delay_fork = 1; break;
-//mdk-stage1// case 'c':
-//mdk-stage1// configpath = strdup(optarg); break;
-//mdk-stage1// #ifdef __linux__
-//mdk-stage1// case 'd':
-//mdk-stage1// do_modprobe = 1; break;
-//mdk-stage1// case 'm':
-//mdk-stage1// modpath = strdup(optarg); break;
-//mdk-stage1// #endif
-//mdk-stage1// case 'p':
-//mdk-stage1// pidfile = strdup(optarg); break;
-//mdk-stage1// case 's':
-//mdk-stage1// stabfile = strdup(optarg); break;
-//mdk-stage1// default:
-//mdk-stage1// errflg = 1; break;
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// if (errflg || (optind < argc)) {
-//mdk-stage1// fprintf(stderr, "usage: %s [-V] [-q] [-v] [-d] [-o] [-f] "
-//mdk-stage1// "[-c configpath] [-m modpath]\n "
-//mdk-stage1// "[-p pidfile] [-s stabfile]\n", argv[0]);
-//mdk-stage1// exit(EXIT_FAILURE);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// #ifdef DEBUG
-//mdk-stage1// openlog("cardmgr", LOG_PID|LOG_PERROR, LOG_DAEMON);
-//mdk-stage1// #else
-//mdk-stage1// openlog("cardmgr", LOG_PID|LOG_CONS, LOG_DAEMON);
-//mdk-stage1// close(0); close(1); close(2);
-//mdk-stage1// if (!delay_fork && !one_pass)
-//mdk-stage1// fork_now();
-//mdk-stage1// #endif
-//mdk-stage1//
-//mdk-stage1// syslog(LOG_INFO, "starting, version is " CS_RELEASE);
-//mdk-stage1// atexit(&done);
-//mdk-stage1// putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin");
-//mdk-stage1// if (verbose)
-//mdk-stage1// putenv("VERBOSE=1");
-//mdk-stage1//
-//mdk-stage1// #ifdef __linux__
-//mdk-stage1// if (modpath == NULL) {
-//mdk-stage1// if (access("/lib/modules/preferred", X_OK) == 0)
-//mdk-stage1// modpath = "/lib/modules/preferred";
-//mdk-stage1// else {
-//mdk-stage1// struct utsname utsname;
-//mdk-stage1// if (uname(&utsname) != 0) {
-//mdk-stage1// syslog(LOG_ERR, "uname(): %m");
-//mdk-stage1// exit(EXIT_FAILURE);
-//mdk-stage1// }
-//mdk-stage1// modpath = (char *)malloc(strlen(utsname.release)+14);
-//mdk-stage1// sprintf(modpath, "/lib/modules/%s", utsname.release);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// if (access(modpath, X_OK) != 0)
-//mdk-stage1// syslog(LOG_INFO, "cannot access %s: %m", modpath);
-//mdk-stage1// /* We default to using modprobe if it is available */
-//mdk-stage1// do_modprobe |= (access("/sbin/modprobe", X_OK) == 0);
-//mdk-stage1// #endif /* __linux__ */
-//mdk-stage1//
-//mdk-stage1// load_config();
-//mdk-stage1//
-//mdk-stage1// if (init_sockets() != 0)
-//mdk-stage1// exit(EXIT_FAILURE);
-//mdk-stage1//
-//mdk-stage1// /* If we've gotten this far, then clean up pid and stab at exit */
-//mdk-stage1// write_pid();
-//mdk-stage1// write_stab();
-//mdk-stage1// cleanup_files = 1;
-//mdk-stage1//
-//mdk-stage1// if (signal(SIGHUP, catch_signal) == SIG_ERR)
-//mdk-stage1// syslog(LOG_ERR, "signal(SIGHUP): %m");
-//mdk-stage1// if (signal(SIGTERM, catch_signal) == SIG_ERR)
-//mdk-stage1// syslog(LOG_ERR, "signal(SIGTERM): %m");
-//mdk-stage1// if (signal(SIGINT, catch_signal) == SIG_ERR)
-//mdk-stage1// syslog(LOG_ERR, "signal(SIGINT): %m");
-//mdk-stage1// #ifdef SIGPWR
-//mdk-stage1// if (signal(SIGPWR, catch_signal) == SIG_ERR)
-//mdk-stage1// syslog(LOG_ERR, "signal(SIGPWR): %m");
-//mdk-stage1// #endif
-//mdk-stage1//
-//mdk-stage1// for (i = max_fd = 0; i < sockets; i++)
-//mdk-stage1// max_fd = (socket[i].fd > max_fd) ? socket[i].fd : max_fd;
-//mdk-stage1//
-//mdk-stage1// /* First select() call: poll, don't wait */
-//mdk-stage1// tv.tv_sec = tv.tv_usec = 0;
-//mdk-stage1//
-//mdk-stage1// /* Wait for sockets in setup-pending state to settle */
-//mdk-stage1// if (one_pass || delay_fork)
-//mdk-stage1// wait_for_pending();
-//mdk-stage1//
-//mdk-stage1// for (pass = 0; ; pass++) {
-//mdk-stage1// FD_ZERO(&fds);
-//mdk-stage1// for (i = 0; i < sockets; i++)
-//mdk-stage1// FD_SET(socket[i].fd, &fds);
-//mdk-stage1//
-//mdk-stage1// while ((ret = select(max_fd+1, &fds, NULL, NULL,
-//mdk-stage1// ((pass == 0) ? &tv : NULL))) < 0) {
-//mdk-stage1// if (errno == EINTR) {
-//mdk-stage1// handle_signal();
-//mdk-stage1// } else {
-//mdk-stage1// syslog(LOG_ERR, "select(): %m");
-//mdk-stage1// exit(EXIT_FAILURE);
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// for (i = 0; i < sockets; i++) {
-//mdk-stage1// if (!FD_ISSET(socket[i].fd, &fds))
-//mdk-stage1// continue;
-//mdk-stage1// ret = read(socket[i].fd, &event, 4);
-//mdk-stage1// if ((ret == -1) && (errno != EAGAIN))
-//mdk-stage1// syslog(LOG_INFO, "read(%d): %m\n", i);
-//mdk-stage1// if (ret != 4)
-//mdk-stage1// continue;
-//mdk-stage1//
-//mdk-stage1// switch (event) {
-//mdk-stage1// case CS_EVENT_CARD_REMOVAL:
-//mdk-stage1// socket[i].state = 0;
-//mdk-stage1// do_remove(i);
-//mdk-stage1// break;
-//mdk-stage1// case CS_EVENT_EJECTION_REQUEST:
-//mdk-stage1// ret = do_check(i);
-//mdk-stage1// if (ret == 0) {
-//mdk-stage1// socket[i].state = 0;
-//mdk-stage1// do_remove(i);
-//mdk-stage1// }
-//mdk-stage1// write(socket[i].fd, &ret, 4);
-//mdk-stage1// break;
-//mdk-stage1// case CS_EVENT_CARD_INSERTION:
-//mdk-stage1// case CS_EVENT_INSERTION_REQUEST:
-//mdk-stage1// socket[i].state |= SOCKET_PRESENT;
-//mdk-stage1// case CS_EVENT_CARD_RESET:
-//mdk-stage1// socket[i].state |= SOCKET_READY;
-//mdk-stage1// do_insert(i);
-//mdk-stage1// break;
-//mdk-stage1// case CS_EVENT_RESET_PHYSICAL:
-//mdk-stage1// socket[i].state &= ~SOCKET_READY;
-//mdk-stage1// break;
-//mdk-stage1// case CS_EVENT_PM_SUSPEND:
-//mdk-stage1// do_suspend(i);
-//mdk-stage1// break;
-//mdk-stage1// case CS_EVENT_PM_RESUME:
-//mdk-stage1// do_resume(i);
-//mdk-stage1// break;
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// if (one_pass)
-//mdk-stage1// exit(EXIT_SUCCESS);
-//mdk-stage1// if (delay_fork) {
-//mdk-stage1// fork_now();
-//mdk-stage1// write_pid();
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// } /* repeat */
-//mdk-stage1// return 0;
-//mdk-stage1// }
-
-
-
-static void cardmgr_fail(void)
-{
- log_message("CM: cardmgr: failed");
-}
-
-int cardmgr_call(void)
-{
- int i, max_fd, ret, event;
- struct timeval tv;
- fd_set fds;
-
- stabfile = "/var/run/stab";
-
- log_message("CM: cardmgr/hacked starting, version is " CS_RELEASE);
-
- if (load_config()) {
- cardmgr_fail();
- return -1;
- }
-
- if (init_sockets()) {
- cardmgr_fail();
- return -1;
- }
-
- /* If we've gotten this far, then clean up pid and stab at exit */
- write_stab();
-
- for (i = max_fd = 0; i < sockets; i++)
- max_fd = (socket[i].fd > max_fd) ? socket[i].fd : max_fd;
-
- /* First select() call: poll, don't wait */
- tv.tv_sec = tv.tv_usec = 0;
-
- /* Wait for sockets in setup-pending state to settle */
- wait_for_pending();
-
-
- FD_ZERO(&fds);
- for (i = 0; i < sockets; i++)
- FD_SET(socket[i].fd, &fds);
-
- if (select(max_fd+1, &fds, NULL, NULL, &tv) < 0) {
- log_perror("CM: select fails");
- return -1;
- }
-
- for (i = 0; i < sockets; i++) {
- if (!FD_ISSET(socket[i].fd, &fds))
- continue;
- ret = read(socket[i].fd, &event, 4);
- if ((ret == -1) && (errno != EAGAIN))
- log_message("CM: read(%d): %m", i);
- if (ret != 4)
- continue;
-
- switch (event) {
- case CS_EVENT_CARD_INSERTION:
- case CS_EVENT_INSERTION_REQUEST:
- socket[i].state |= SOCKET_PRESENT;
- case CS_EVENT_CARD_RESET:
- socket[i].state |= SOCKET_READY;
- do_insert(i);
- break;
- case CS_EVENT_RESET_PHYSICAL:
- socket[i].state &= ~SOCKET_READY;
- break;
- }
-
- }
-
- return 0;
-
-}
diff --git a/mdk-stage1/pcmcia_/cardmgr.h b/mdk-stage1/pcmcia_/cardmgr.h
deleted file mode 100644
index 1d002e972..000000000
--- a/mdk-stage1/pcmcia_/cardmgr.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * cardmgr.h 1.37 2001/08/24 12:19:20
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#define MAX_SOCKS 8
-#define MAX_BINDINGS 4
-#define MAX_MODULES 4
-
-typedef struct adjust_list_t {
- adjust_t adj;
- struct adjust_list_t *next;
-} adjust_list_t;
-
-typedef struct func_ident_t {
- u_char funcid;
-} func_ident_t;
-
-typedef struct manfid_ident_t {
- u_short manf;
- u_short card;
-} manfid_ident_t;
-
-typedef struct vers_ident_t {
- int ns;
- char *pi[4];
-} vers_ident_t;
-
-typedef struct tuple_ident_t {
- cisdata_t code;
- long ofs;
- char *info;
-} tuple_ident_t;
-
-typedef struct device_info_t {
- dev_info_t dev_info;
- int needs_mtd;
- int modules;
- char *module[MAX_MODULES];
- char *opts[MAX_MODULES];
- char *class;
- int refs;
- struct device_info_t *next;
-} device_info_t;
-
-#define VERS_1_IDENT 0x0001
-#define MANFID_IDENT 0x0002
-#define TUPLE_IDENT 0x0010
-#define FUNC_IDENT 0x0020
-#define BLANK_IDENT 0x0040
-#define PCI_IDENT 0x0080
-#define EXCL_IDENT 0x00f0
-
-typedef struct card_info_t {
- char *name;
- int ident_type;
- union {
- vers_ident_t vers;
- tuple_ident_t tuple;
- func_ident_t func;
- } id;
- manfid_ident_t manfid;
- int bindings;
- device_info_t *device[MAX_BINDINGS];
- int dev_fn[MAX_BINDINGS];
- char *cis_file;
- int refs;
- struct card_info_t *next;
-} card_info_t;
-
-typedef struct mtd_ident_t {
- char *name;
- enum {
- JEDEC_MTD=1, DTYPE_MTD, DEFAULT_MTD
- } mtd_type;
- int dtype, jedec_mfr, jedec_info;
- char *module, *opts;
- int refs;
- struct mtd_ident_t *next;
-} mtd_ident_t;
-
-extern adjust_list_t *root_adjust;
-extern device_info_t *root_device;
-extern card_info_t *blank_card;
-extern card_info_t *root_card, *root_func;
-extern mtd_ident_t *root_mtd, *default_mtd;
-
-int parse_configfile(char *fn);
diff --git a/mdk-stage1/pcmcia_/cirrus.h b/mdk-stage1/pcmcia_/cirrus.h
deleted file mode 100644
index 78f73b26d..000000000
--- a/mdk-stage1/pcmcia_/cirrus.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * cirrus.h 1.10 2001/08/24 12:15:33
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_CIRRUS_H
-#define _LINUX_CIRRUS_H
-
-#ifndef PCI_VENDOR_ID_CIRRUS
-#define PCI_VENDOR_ID_CIRRUS 0x1013
-#endif
-#ifndef PCI_DEVICE_ID_CIRRUS_6729
-#define PCI_DEVICE_ID_CIRRUS_6729 0x1100
-#endif
-#ifndef PCI_DEVICE_ID_CIRRUS_6832
-#define PCI_DEVICE_ID_CIRRUS_6832 0x1110
-#endif
-
-#define PD67_MISC_CTL_1 0x16 /* Misc control 1 */
-#define PD67_FIFO_CTL 0x17 /* FIFO control */
-#define PD67_MISC_CTL_2 0x1E /* Misc control 2 */
-#define PD67_CHIP_INFO 0x1f /* Chip information */
-#define PD67_ATA_CTL 0x026 /* 6730: ATA control */
-#define PD67_EXT_INDEX 0x2e /* Extension index */
-#define PD67_EXT_DATA 0x2f /* Extension data */
-
-/* PD6722 extension registers -- indexed in PD67_EXT_INDEX */
-#define PD67_DATA_MASK0 0x01 /* Data mask 0 */
-#define PD67_DATA_MASK1 0x02 /* Data mask 1 */
-#define PD67_DMA_CTL 0x03 /* DMA control */
-
-/* PD6730 extension registers -- indexed in PD67_EXT_INDEX */
-#define PD67_EXT_CTL_1 0x03 /* Extension control 1 */
-#define PD67_MEM_PAGE(n) ((n)+5) /* PCI window bits 31:24 */
-#define PD67_EXTERN_DATA 0x0a
-#define PD67_MISC_CTL_3 0x25
-#define PD67_SMB_PWR_CTL 0x26
-
-/* I/O window address offset */
-#define PD67_IO_OFF(w) (0x36+((w)<<1))
-
-/* Timing register sets */
-#define PD67_TIME_SETUP(n) (0x3a + 3*(n))
-#define PD67_TIME_CMD(n) (0x3b + 3*(n))
-#define PD67_TIME_RECOV(n) (0x3c + 3*(n))
-
-/* Flags for PD67_MISC_CTL_1 */
-#define PD67_MC1_5V_DET 0x01 /* 5v detect */
-#define PD67_MC1_MEDIA_ENA 0x01 /* 6730: Multimedia enable */
-#define PD67_MC1_VCC_3V 0x02 /* 3.3v Vcc */
-#define PD67_MC1_PULSE_MGMT 0x04
-#define PD67_MC1_PULSE_IRQ 0x08
-#define PD67_MC1_SPKR_ENA 0x10
-#define PD67_MC1_INPACK_ENA 0x80
-
-/* Flags for PD67_FIFO_CTL */
-#define PD67_FIFO_EMPTY 0x80
-
-/* Flags for PD67_MISC_CTL_2 */
-#define PD67_MC2_FREQ_BYPASS 0x01
-#define PD67_MC2_DYNAMIC_MODE 0x02
-#define PD67_MC2_SUSPEND 0x04
-#define PD67_MC2_5V_CORE 0x08
-#define PD67_MC2_LED_ENA 0x10 /* IRQ 12 is LED enable */
-#define PD67_MC2_FAST_PCI 0x10 /* 6729: PCI bus > 25 MHz */
-#define PD67_MC2_3STATE_BIT7 0x20 /* Floppy change bit */
-#define PD67_MC2_DMA_MODE 0x40
-#define PD67_MC2_IRQ15_RI 0x80 /* IRQ 15 is ring enable */
-
-/* Flags for PD67_CHIP_INFO */
-#define PD67_INFO_SLOTS 0x20 /* 0 = 1 slot, 1 = 2 slots */
-#define PD67_INFO_CHIP_ID 0xc0
-#define PD67_INFO_REV 0x1c
-
-/* Fields in PD67_TIME_* registers */
-#define PD67_TIME_SCALE 0xc0
-#define PD67_TIME_SCALE_1 0x00
-#define PD67_TIME_SCALE_16 0x40
-#define PD67_TIME_SCALE_256 0x80
-#define PD67_TIME_SCALE_4096 0xc0
-#define PD67_TIME_MULT 0x3f
-
-/* Fields in PD67_DMA_CTL */
-#define PD67_DMA_MODE 0xc0
-#define PD67_DMA_OFF 0x00
-#define PD67_DMA_DREQ_INPACK 0x40
-#define PD67_DMA_DREQ_WP 0x80
-#define PD67_DMA_DREQ_BVD2 0xc0
-#define PD67_DMA_PULLUP 0x20 /* Disable socket pullups? */
-
-/* Fields in PD67_EXT_CTL_1 */
-#define PD67_EC1_VCC_PWR_LOCK 0x01
-#define PD67_EC1_AUTO_PWR_CLEAR 0x02
-#define PD67_EC1_LED_ENA 0x04
-#define PD67_EC1_INV_CARD_IRQ 0x08
-#define PD67_EC1_INV_MGMT_IRQ 0x10
-#define PD67_EC1_PULLUP_CTL 0x20
-
-/* Fields in PD67_MISC_CTL_3 */
-#define PD67_MC3_IRQ_MASK 0x03
-#define PD67_MC3_IRQ_PCPCI 0x00
-#define PD67_MC3_IRQ_EXTERN 0x01
-#define PD67_MC3_IRQ_PCIWAY 0x02
-#define PD67_MC3_IRQ_PCI 0x03
-#define PD67_MC3_PWR_MASK 0x0c
-#define PD67_MC3_PWR_SERIAL 0x00
-#define PD67_MC3_PWR_TI2202 0x08
-#define PD67_MC3_PWR_SMB 0x0c
-
-/* Register definitions for Cirrus PD6832 PCI-to-CardBus bridge */
-
-/* PD6832 extension registers -- indexed in PD67_EXT_INDEX */
-#define PD68_EXT_CTL_2 0x0b
-#define PD68_PCI_SPACE 0x22
-#define PD68_PCCARD_SPACE 0x23
-#define PD68_WINDOW_TYPE 0x24
-#define PD68_EXT_CSC 0x2e
-#define PD68_MISC_CTL_4 0x2f
-#define PD68_MISC_CTL_5 0x30
-#define PD68_MISC_CTL_6 0x31
-
-/* Extra flags in PD67_MISC_CTL_3 */
-#define PD68_MC3_HW_SUSP 0x10
-#define PD68_MC3_MM_EXPAND 0x40
-#define PD68_MC3_MM_ARM 0x80
-
-/* Bridge Control Register */
-#define PD6832_BCR_MGMT_IRQ_ENA 0x0800
-
-/* Socket Number Register */
-#define PD6832_SOCKET_NUMBER 0x004c /* 8 bit */
-
-#endif /* _LINUX_CIRRUS_H */
diff --git a/mdk-stage1/pcmcia_/cistpl.h b/mdk-stage1/pcmcia_/cistpl.h
deleted file mode 100644
index 1d4cac20e..000000000
--- a/mdk-stage1/pcmcia_/cistpl.h
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * cistpl.h 1.35 2001/08/24 12:16:12
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_CISTPL_H
-#define _LINUX_CISTPL_H
-
-#define CISTPL_NULL 0x00
-#define CISTPL_DEVICE 0x01
-#define CISTPL_LONGLINK_CB 0x02
-#define CISTPL_INDIRECT 0x03
-#define CISTPL_CONFIG_CB 0x04
-#define CISTPL_CFTABLE_ENTRY_CB 0x05
-#define CISTPL_LONGLINK_MFC 0x06
-#define CISTPL_BAR 0x07
-#define CISTPL_PWR_MGMNT 0x08
-#define CISTPL_EXTDEVICE 0x09
-#define CISTPL_CHECKSUM 0x10
-#define CISTPL_LONGLINK_A 0x11
-#define CISTPL_LONGLINK_C 0x12
-#define CISTPL_LINKTARGET 0x13
-#define CISTPL_NO_LINK 0x14
-#define CISTPL_VERS_1 0x15
-#define CISTPL_ALTSTR 0x16
-#define CISTPL_DEVICE_A 0x17
-#define CISTPL_JEDEC_C 0x18
-#define CISTPL_JEDEC_A 0x19
-#define CISTPL_CONFIG 0x1a
-#define CISTPL_CFTABLE_ENTRY 0x1b
-#define CISTPL_DEVICE_OC 0x1c
-#define CISTPL_DEVICE_OA 0x1d
-#define CISTPL_DEVICE_GEO 0x1e
-#define CISTPL_DEVICE_GEO_A 0x1f
-#define CISTPL_MANFID 0x20
-#define CISTPL_FUNCID 0x21
-#define CISTPL_FUNCE 0x22
-#define CISTPL_SWIL 0x23
-#define CISTPL_END 0xff
-/* Layer 2 tuples */
-#define CISTPL_VERS_2 0x40
-#define CISTPL_FORMAT 0x41
-#define CISTPL_GEOMETRY 0x42
-#define CISTPL_BYTEORDER 0x43
-#define CISTPL_DATE 0x44
-#define CISTPL_BATTERY 0x45
-#define CISTPL_FORMAT_A 0x47
-/* Layer 3 tuples */
-#define CISTPL_ORG 0x46
-#define CISTPL_SPCL 0x90
-
-typedef struct cistpl_longlink_t {
- u_int addr;
-} cistpl_longlink_t;
-
-typedef struct cistpl_checksum_t {
- u_short addr;
- u_short len;
- u_char sum;
-} cistpl_checksum_t;
-
-#define CISTPL_MAX_FUNCTIONS 8
-#define CISTPL_MFC_ATTR 0x00
-#define CISTPL_MFC_COMMON 0x01
-
-typedef struct cistpl_longlink_mfc_t {
- u_char nfn;
- struct {
- u_char space;
- u_int addr;
- } fn[CISTPL_MAX_FUNCTIONS];
-} cistpl_longlink_mfc_t;
-
-#define CISTPL_MAX_ALTSTR_STRINGS 4
-
-typedef struct cistpl_altstr_t {
- u_char ns;
- u_char ofs[CISTPL_MAX_ALTSTR_STRINGS];
- char str[254];
-} cistpl_altstr_t;
-
-#define CISTPL_DTYPE_NULL 0x00
-#define CISTPL_DTYPE_ROM 0x01
-#define CISTPL_DTYPE_OTPROM 0x02
-#define CISTPL_DTYPE_EPROM 0x03
-#define CISTPL_DTYPE_EEPROM 0x04
-#define CISTPL_DTYPE_FLASH 0x05
-#define CISTPL_DTYPE_SRAM 0x06
-#define CISTPL_DTYPE_DRAM 0x07
-#define CISTPL_DTYPE_FUNCSPEC 0x0d
-#define CISTPL_DTYPE_EXTEND 0x0e
-
-#define CISTPL_MAX_DEVICES 4
-
-typedef struct cistpl_device_t {
- u_char ndev;
- struct {
- u_char type;
- u_char wp;
- u_int speed;
- u_int size;
- } dev[CISTPL_MAX_DEVICES];
-} cistpl_device_t;
-
-#define CISTPL_DEVICE_MWAIT 0x01
-#define CISTPL_DEVICE_3VCC 0x02
-
-typedef struct cistpl_device_o_t {
- u_char flags;
- cistpl_device_t device;
-} cistpl_device_o_t;
-
-#define CISTPL_VERS_1_MAX_PROD_STRINGS 4
-
-typedef struct cistpl_vers_1_t {
- u_char major;
- u_char minor;
- u_char ns;
- u_char ofs[CISTPL_VERS_1_MAX_PROD_STRINGS];
- char str[254];
-} cistpl_vers_1_t;
-
-typedef struct cistpl_jedec_t {
- u_char nid;
- struct {
- u_char mfr;
- u_char info;
- } id[CISTPL_MAX_DEVICES];
-} cistpl_jedec_t;
-
-typedef struct cistpl_manfid_t {
- u_short manf;
- u_short card;
-} cistpl_manfid_t;
-
-#define CISTPL_FUNCID_MULTI 0x00
-#define CISTPL_FUNCID_MEMORY 0x01
-#define CISTPL_FUNCID_SERIAL 0x02
-#define CISTPL_FUNCID_PARALLEL 0x03
-#define CISTPL_FUNCID_FIXED 0x04
-#define CISTPL_FUNCID_VIDEO 0x05
-#define CISTPL_FUNCID_NETWORK 0x06
-#define CISTPL_FUNCID_AIMS 0x07
-#define CISTPL_FUNCID_SCSI 0x08
-
-#define CISTPL_SYSINIT_POST 0x01
-#define CISTPL_SYSINIT_ROM 0x02
-
-typedef struct cistpl_funcid_t {
- u_char func;
- u_char sysinit;
-} cistpl_funcid_t;
-
-typedef struct cistpl_funce_t {
- u_char type;
- u_char data[0];
-} cistpl_funce_t;
-
-/*======================================================================
-
- Modem Function Extension Tuples
-
-======================================================================*/
-
-#define CISTPL_FUNCE_SERIAL_IF 0x00
-#define CISTPL_FUNCE_SERIAL_CAP 0x01
-#define CISTPL_FUNCE_SERIAL_SERV_DATA 0x02
-#define CISTPL_FUNCE_SERIAL_SERV_FAX 0x03
-#define CISTPL_FUNCE_SERIAL_SERV_VOICE 0x04
-#define CISTPL_FUNCE_SERIAL_CAP_DATA 0x05
-#define CISTPL_FUNCE_SERIAL_CAP_FAX 0x06
-#define CISTPL_FUNCE_SERIAL_CAP_VOICE 0x07
-#define CISTPL_FUNCE_SERIAL_IF_DATA 0x08
-#define CISTPL_FUNCE_SERIAL_IF_FAX 0x09
-#define CISTPL_FUNCE_SERIAL_IF_VOICE 0x0a
-
-/* UART identification */
-#define CISTPL_SERIAL_UART_8250 0x00
-#define CISTPL_SERIAL_UART_16450 0x01
-#define CISTPL_SERIAL_UART_16550 0x02
-#define CISTPL_SERIAL_UART_8251 0x03
-#define CISTPL_SERIAL_UART_8530 0x04
-#define CISTPL_SERIAL_UART_85230 0x05
-
-/* UART capabilities */
-#define CISTPL_SERIAL_UART_SPACE 0x01
-#define CISTPL_SERIAL_UART_MARK 0x02
-#define CISTPL_SERIAL_UART_ODD 0x04
-#define CISTPL_SERIAL_UART_EVEN 0x08
-#define CISTPL_SERIAL_UART_5BIT 0x01
-#define CISTPL_SERIAL_UART_6BIT 0x02
-#define CISTPL_SERIAL_UART_7BIT 0x04
-#define CISTPL_SERIAL_UART_8BIT 0x08
-#define CISTPL_SERIAL_UART_1STOP 0x10
-#define CISTPL_SERIAL_UART_MSTOP 0x20
-#define CISTPL_SERIAL_UART_2STOP 0x40
-
-typedef struct cistpl_serial_t {
- u_char uart_type;
- u_char uart_cap_0;
- u_char uart_cap_1;
-} cistpl_serial_t;
-
-typedef struct cistpl_modem_cap_t {
- u_char flow;
- u_char cmd_buf;
- u_char rcv_buf_0, rcv_buf_1, rcv_buf_2;
- u_char xmit_buf_0, xmit_buf_1, xmit_buf_2;
-} cistpl_modem_cap_t;
-
-#define CISTPL_SERIAL_MOD_103 0x01
-#define CISTPL_SERIAL_MOD_V21 0x02
-#define CISTPL_SERIAL_MOD_V23 0x04
-#define CISTPL_SERIAL_MOD_V22 0x08
-#define CISTPL_SERIAL_MOD_212A 0x10
-#define CISTPL_SERIAL_MOD_V22BIS 0x20
-#define CISTPL_SERIAL_MOD_V26 0x40
-#define CISTPL_SERIAL_MOD_V26BIS 0x80
-#define CISTPL_SERIAL_MOD_V27BIS 0x01
-#define CISTPL_SERIAL_MOD_V29 0x02
-#define CISTPL_SERIAL_MOD_V32 0x04
-#define CISTPL_SERIAL_MOD_V32BIS 0x08
-#define CISTPL_SERIAL_MOD_V34 0x10
-
-#define CISTPL_SERIAL_ERR_MNP2_4 0x01
-#define CISTPL_SERIAL_ERR_V42_LAPM 0x02
-
-#define CISTPL_SERIAL_CMPR_V42BIS 0x01
-#define CISTPL_SERIAL_CMPR_MNP5 0x02
-
-#define CISTPL_SERIAL_CMD_AT1 0x01
-#define CISTPL_SERIAL_CMD_AT2 0x02
-#define CISTPL_SERIAL_CMD_AT3 0x04
-#define CISTPL_SERIAL_CMD_MNP_AT 0x08
-#define CISTPL_SERIAL_CMD_V25BIS 0x10
-#define CISTPL_SERIAL_CMD_V25A 0x20
-#define CISTPL_SERIAL_CMD_DMCL 0x40
-
-typedef struct cistpl_data_serv_t {
- u_char max_data_0;
- u_char max_data_1;
- u_char modulation_0;
- u_char modulation_1;
- u_char error_control;
- u_char compression;
- u_char cmd_protocol;
- u_char escape;
- u_char encrypt;
- u_char misc_features;
- u_char ccitt_code[0];
-} cistpl_data_serv_t;
-
-typedef struct cistpl_fax_serv_t {
- u_char max_data_0;
- u_char max_data_1;
- u_char modulation;
- u_char encrypt;
- u_char features_0;
- u_char features_1;
- u_char ccitt_code[0];
-} cistpl_fax_serv_t;
-
-typedef struct cistpl_voice_serv_t {
- u_char max_data_0;
- u_char max_data_1;
-} cistpl_voice_serv_t;
-
-/*======================================================================
-
- LAN Function Extension Tuples
-
-======================================================================*/
-
-#define CISTPL_FUNCE_LAN_TECH 0x01
-#define CISTPL_FUNCE_LAN_SPEED 0x02
-#define CISTPL_FUNCE_LAN_MEDIA 0x03
-#define CISTPL_FUNCE_LAN_NODE_ID 0x04
-#define CISTPL_FUNCE_LAN_CONNECTOR 0x05
-
-/* LAN technologies */
-#define CISTPL_LAN_TECH_ARCNET 0x01
-#define CISTPL_LAN_TECH_ETHERNET 0x02
-#define CISTPL_LAN_TECH_TOKENRING 0x03
-#define CISTPL_LAN_TECH_LOCALTALK 0x04
-#define CISTPL_LAN_TECH_FDDI 0x05
-#define CISTPL_LAN_TECH_ATM 0x06
-#define CISTPL_LAN_TECH_WIRELESS 0x07
-
-typedef struct cistpl_lan_tech_t {
- u_char tech;
-} cistpl_lan_tech_t;
-
-typedef struct cistpl_lan_speed_t {
- u_int speed;
-} cistpl_lan_speed_t;
-
-/* LAN media definitions */
-#define CISTPL_LAN_MEDIA_UTP 0x01
-#define CISTPL_LAN_MEDIA_STP 0x02
-#define CISTPL_LAN_MEDIA_THIN_COAX 0x03
-#define CISTPL_LAN_MEDIA_THICK_COAX 0x04
-#define CISTPL_LAN_MEDIA_FIBER 0x05
-#define CISTPL_LAN_MEDIA_900MHZ 0x06
-#define CISTPL_LAN_MEDIA_2GHZ 0x07
-#define CISTPL_LAN_MEDIA_5GHZ 0x08
-#define CISTPL_LAN_MEDIA_DIFF_IR 0x09
-#define CISTPL_LAN_MEDIA_PTP_IR 0x0a
-
-typedef struct cistpl_lan_media_t {
- u_char media;
-} cistpl_lan_media_t;
-
-typedef struct cistpl_lan_node_id_t {
- u_char nb;
- u_char id[16];
-} cistpl_lan_node_id_t;
-
-typedef struct cistpl_lan_connector_t {
- u_char code;
-} cistpl_lan_connector_t;
-
-/*======================================================================
-
- IDE Function Extension Tuples
-
-======================================================================*/
-
-#define CISTPL_IDE_INTERFACE 0x01
-
-typedef struct cistpl_ide_interface_t {
- u_char interface;
-} cistpl_ide_interface_t;
-
-/* First feature byte */
-#define CISTPL_IDE_SILICON 0x04
-#define CISTPL_IDE_UNIQUE 0x08
-#define CISTPL_IDE_DUAL 0x10
-
-/* Second feature byte */
-#define CISTPL_IDE_HAS_SLEEP 0x01
-#define CISTPL_IDE_HAS_STANDBY 0x02
-#define CISTPL_IDE_HAS_IDLE 0x04
-#define CISTPL_IDE_LOW_POWER 0x08
-#define CISTPL_IDE_REG_INHIBIT 0x10
-#define CISTPL_IDE_HAS_INDEX 0x20
-#define CISTPL_IDE_IOIS16 0x40
-
-typedef struct cistpl_ide_feature_t {
- u_char feature1;
- u_char feature2;
-} cistpl_ide_feature_t;
-
-#define CISTPL_FUNCE_IDE_IFACE 0x01
-#define CISTPL_FUNCE_IDE_MASTER 0x02
-#define CISTPL_FUNCE_IDE_SLAVE 0x03
-
-/*======================================================================
-
- Configuration Table Entries
-
-======================================================================*/
-
-#define CISTPL_BAR_SPACE 0x07
-#define CISTPL_BAR_SPACE_IO 0x10
-#define CISTPL_BAR_PREFETCH 0x20
-#define CISTPL_BAR_CACHEABLE 0x40
-#define CISTPL_BAR_1MEG_MAP 0x80
-
-typedef struct cistpl_bar_t {
- u_char attr;
- u_int size;
-} cistpl_bar_t;
-
-typedef struct cistpl_config_t {
- u_char last_idx;
- u_int base;
- u_int rmask[4];
- u_char subtuples;
-} cistpl_config_t;
-
-/* These are bits in the 'present' field, and indices in 'param' */
-#define CISTPL_POWER_VNOM 0
-#define CISTPL_POWER_VMIN 1
-#define CISTPL_POWER_VMAX 2
-#define CISTPL_POWER_ISTATIC 3
-#define CISTPL_POWER_IAVG 4
-#define CISTPL_POWER_IPEAK 5
-#define CISTPL_POWER_IDOWN 6
-
-#define CISTPL_POWER_HIGHZ_OK 0x01
-#define CISTPL_POWER_HIGHZ_REQ 0x02
-
-typedef struct cistpl_power_t {
- u_char present;
- u_char flags;
- u_int param[7];
-} cistpl_power_t;
-
-typedef struct cistpl_timing_t {
- u_int wait, waitscale;
- u_int ready, rdyscale;
- u_int reserved, rsvscale;
-} cistpl_timing_t;
-
-#define CISTPL_IO_LINES_MASK 0x1f
-#define CISTPL_IO_8BIT 0x20
-#define CISTPL_IO_16BIT 0x40
-#define CISTPL_IO_RANGE 0x80
-
-#define CISTPL_IO_MAX_WIN 16
-
-typedef struct cistpl_io_t {
- u_char flags;
- u_char nwin;
- struct {
- u_int base;
- u_int len;
- } win[CISTPL_IO_MAX_WIN];
-} cistpl_io_t;
-
-typedef struct cistpl_irq_t {
- u_int IRQInfo1;
- u_int IRQInfo2;
-} cistpl_irq_t;
-
-#define CISTPL_MEM_MAX_WIN 8
-
-typedef struct cistpl_mem_t {
- u_char flags;
- u_char nwin;
- struct {
- u_int len;
- u_int card_addr;
- u_int host_addr;
- } win[CISTPL_MEM_MAX_WIN];
-} cistpl_mem_t;
-
-#define CISTPL_CFTABLE_DEFAULT 0x0001
-#define CISTPL_CFTABLE_BVDS 0x0002
-#define CISTPL_CFTABLE_WP 0x0004
-#define CISTPL_CFTABLE_RDYBSY 0x0008
-#define CISTPL_CFTABLE_MWAIT 0x0010
-#define CISTPL_CFTABLE_AUDIO 0x0800
-#define CISTPL_CFTABLE_READONLY 0x1000
-#define CISTPL_CFTABLE_PWRDOWN 0x2000
-
-typedef struct cistpl_cftable_entry_t {
- u_char index;
- u_short flags;
- u_char interface;
- cistpl_power_t vcc, vpp1, vpp2;
- cistpl_timing_t timing;
- cistpl_io_t io;
- cistpl_irq_t irq;
- cistpl_mem_t mem;
- u_char subtuples;
-} cistpl_cftable_entry_t;
-
-#define CISTPL_CFTABLE_MASTER 0x000100
-#define CISTPL_CFTABLE_INVALIDATE 0x000200
-#define CISTPL_CFTABLE_VGA_PALETTE 0x000400
-#define CISTPL_CFTABLE_PARITY 0x000800
-#define CISTPL_CFTABLE_WAIT 0x001000
-#define CISTPL_CFTABLE_SERR 0x002000
-#define CISTPL_CFTABLE_FAST_BACK 0x004000
-#define CISTPL_CFTABLE_BINARY_AUDIO 0x010000
-#define CISTPL_CFTABLE_PWM_AUDIO 0x020000
-
-typedef struct cistpl_cftable_entry_cb_t {
- u_char index;
- u_int flags;
- cistpl_power_t vcc, vpp1, vpp2;
- u_char io;
- cistpl_irq_t irq;
- u_char mem;
- u_char subtuples;
-} cistpl_cftable_entry_cb_t;
-
-typedef struct cistpl_device_geo_t {
- u_char ngeo;
- struct {
- u_char buswidth;
- u_int erase_block;
- u_int read_block;
- u_int write_block;
- u_int partition;
- u_int interleave;
- } geo[CISTPL_MAX_DEVICES];
-} cistpl_device_geo_t;
-
-typedef struct cistpl_vers_2_t {
- u_char vers;
- u_char comply;
- u_short dindex;
- u_char vspec8, vspec9;
- u_char nhdr;
- u_char vendor, info;
- char str[244];
-} cistpl_vers_2_t;
-
-typedef struct cistpl_org_t {
- u_char data_org;
- char desc[30];
-} cistpl_org_t;
-
-#define CISTPL_ORG_FS 0x00
-#define CISTPL_ORG_APPSPEC 0x01
-#define CISTPL_ORG_XIP 0x02
-
-typedef struct cistpl_format_t {
- u_char type;
- u_char edc;
- u_int offset;
- u_int length;
-} cistpl_format_t;
-
-#define CISTPL_FORMAT_DISK 0x00
-#define CISTPL_FORMAT_MEM 0x01
-
-#define CISTPL_EDC_NONE 0x00
-#define CISTPL_EDC_CKSUM 0x01
-#define CISTPL_EDC_CRC 0x02
-#define CISTPL_EDC_PCC 0x03
-
-typedef union cisparse_t {
- cistpl_device_t device;
- cistpl_checksum_t checksum;
- cistpl_longlink_t longlink;
- cistpl_longlink_mfc_t longlink_mfc;
- cistpl_vers_1_t version_1;
- cistpl_altstr_t altstr;
- cistpl_jedec_t jedec;
- cistpl_manfid_t manfid;
- cistpl_funcid_t funcid;
- cistpl_funce_t funce;
- cistpl_bar_t bar;
- cistpl_config_t config;
- cistpl_cftable_entry_t cftable_entry;
- cistpl_cftable_entry_cb_t cftable_entry_cb;
- cistpl_device_geo_t device_geo;
- cistpl_vers_2_t vers_2;
- cistpl_org_t org;
- cistpl_format_t format;
-} cisparse_t;
-
-typedef struct tuple_t {
- u_int Attributes;
- cisdata_t DesiredTuple;
- u_int Flags; /* internal use */
- u_int LinkOffset; /* internal use */
- u_int CISOffset; /* internal use */
- cisdata_t TupleCode;
- cisdata_t TupleLink;
- cisdata_t TupleOffset;
- cisdata_t TupleDataMax;
- cisdata_t TupleDataLen;
- cisdata_t *TupleData;
-} tuple_t;
-
-/* Special cisdata_t value */
-#define RETURN_FIRST_TUPLE 0xff
-
-/* Attributes for tuple calls */
-#define TUPLE_RETURN_LINK 0x01
-#define TUPLE_RETURN_COMMON 0x02
-
-/* For ValidateCIS */
-typedef struct cisinfo_t {
- u_int Chains;
-} cisinfo_t;
-
-#define CISTPL_MAX_CIS_SIZE 0x200
-
-/* For ReplaceCIS */
-typedef struct cisdump_t {
- u_int Length;
- cisdata_t Data[CISTPL_MAX_CIS_SIZE];
-} cisdump_t;
-
-#endif /* LINUX_CISTPL_H */
diff --git a/mdk-stage1/pcmcia_/cs.h b/mdk-stage1/pcmcia_/cs.h
deleted file mode 100644
index 9abeac216..000000000
--- a/mdk-stage1/pcmcia_/cs.h
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * cs.h 1.73 2001/08/24 12:16:12
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_CS_H
-#define _LINUX_CS_H
-
-/* For AccessConfigurationRegister */
-typedef struct conf_reg_t {
- u_char Function;
- u_int Action;
- off_t Offset;
- u_int Value;
-} conf_reg_t;
-
-/* Actions */
-#define CS_READ 1
-#define CS_WRITE 2
-
-/* for AdjustResourceInfo */
-typedef struct adjust_t {
- u_int Action;
- u_int Resource;
- u_int Attributes;
- union {
- struct memory {
- unsigned long Base;
- unsigned long Size;
- } memory;
- struct io {
- ioaddr_t BasePort;
- ioaddr_t NumPorts;
- u_int IOAddrLines;
- } io;
- struct irq {
- u_int IRQ;
- } irq;
- } resource;
-} adjust_t;
-
-/* Action field */
-#define REMOVE_MANAGED_RESOURCE 1
-#define ADD_MANAGED_RESOURCE 2
-#define GET_FIRST_MANAGED_RESOURCE 3
-#define GET_NEXT_MANAGED_RESOURCE 4
-/* Resource field */
-#define RES_MEMORY_RANGE 1
-#define RES_IO_RANGE 2
-#define RES_IRQ 3
-/* Attribute field */
-#define RES_IRQ_TYPE 0x03
-#define RES_IRQ_TYPE_EXCLUSIVE 0
-#define RES_IRQ_TYPE_TIME 1
-#define RES_IRQ_TYPE_DYNAMIC 2
-#define RES_IRQ_CSC 0x04
-#define RES_SHARED 0x08
-#define RES_RESERVED 0x10
-#define RES_ALLOCATED 0x20
-#define RES_REMOVED 0x40
-
-typedef struct servinfo_t {
- char Signature[2];
- u_int Count;
- u_int Revision;
- u_int CSLevel;
- char *VendorString;
-} servinfo_t;
-
-typedef struct event_callback_args_t {
- client_handle_t client_handle;
- void *info;
- void *mtdrequest;
- void *buffer;
- void *misc;
- void *client_data;
- struct bus_operations *bus;
-} event_callback_args_t;
-
-/* for GetConfigurationInfo */
-typedef struct config_info_t {
- u_char Function;
- u_int Attributes;
- u_int Vcc, Vpp1, Vpp2;
- u_int IntType;
- u_int ConfigBase;
- u_char Status, Pin, Copy, Option, ExtStatus;
- u_int Present;
- u_int CardValues;
- u_int AssignedIRQ;
- u_int IRQAttributes;
- ioaddr_t BasePort1;
- ioaddr_t NumPorts1;
- u_int Attributes1;
- ioaddr_t BasePort2;
- ioaddr_t NumPorts2;
- u_int Attributes2;
- u_int IOAddrLines;
-} config_info_t;
-
-/* For CardValues field */
-#define CV_OPTION_VALUE 0x01
-#define CV_STATUS_VALUE 0x02
-#define CV_PIN_REPLACEMENT 0x04
-#define CV_COPY_VALUE 0x08
-#define CV_EXT_STATUS 0x10
-
-/* For GetFirst/NextClient */
-typedef struct client_req_t {
- socket_t Socket;
- u_int Attributes;
-} client_req_t;
-
-#define CLIENT_THIS_SOCKET 0x01
-
-/* For RegisterClient */
-typedef struct client_reg_t {
- dev_info_t *dev_info;
- u_int Attributes;
- u_int EventMask;
- int (*event_handler)(event_t event, int priority,
- event_callback_args_t *);
- event_callback_args_t event_callback_args;
- u_int Version;
-} client_reg_t;
-
-/* ModifyConfiguration */
-typedef struct modconf_t {
- u_int Attributes;
- u_int Vcc, Vpp1, Vpp2;
-} modconf_t;
-
-/* Attributes for ModifyConfiguration */
-#define CONF_IRQ_CHANGE_VALID 0x100
-#define CONF_VCC_CHANGE_VALID 0x200
-#define CONF_VPP1_CHANGE_VALID 0x400
-#define CONF_VPP2_CHANGE_VALID 0x800
-
-/* For RequestConfiguration */
-typedef struct config_req_t {
- u_int Attributes;
- u_int Vcc, Vpp1, Vpp2;
- u_int IntType;
- u_int ConfigBase;
- u_char Status, Pin, Copy, ExtStatus;
- u_char ConfigIndex;
- u_int Present;
-} config_req_t;
-
-/* Attributes for RequestConfiguration */
-#define CONF_ENABLE_IRQ 0x01
-#define CONF_ENABLE_DMA 0x02
-#define CONF_ENABLE_SPKR 0x04
-#define CONF_VALID_CLIENT 0x100
-
-/* IntType field */
-#define INT_MEMORY 0x01
-#define INT_MEMORY_AND_IO 0x02
-#define INT_CARDBUS 0x04
-#define INT_ZOOMED_VIDEO 0x08
-
-/* For RequestIO and ReleaseIO */
-typedef struct io_req_t {
- ioaddr_t BasePort1;
- ioaddr_t NumPorts1;
- u_int Attributes1;
- ioaddr_t BasePort2;
- ioaddr_t NumPorts2;
- u_int Attributes2;
- u_int IOAddrLines;
-} io_req_t;
-
-/* Attributes for RequestIO and ReleaseIO */
-#define IO_SHARED 0x01
-#define IO_FIRST_SHARED 0x02
-#define IO_FORCE_ALIAS_ACCESS 0x04
-#define IO_DATA_PATH_WIDTH 0x18
-#define IO_DATA_PATH_WIDTH_8 0x00
-#define IO_DATA_PATH_WIDTH_16 0x08
-#define IO_DATA_PATH_WIDTH_AUTO 0x10
-
-/* For RequestIRQ and ReleaseIRQ */
-typedef struct irq_req_t {
- u_int Attributes;
- u_int AssignedIRQ;
- u_int IRQInfo1, IRQInfo2;
- void *Handler;
- void *Instance;
-} irq_req_t;
-
-/* Attributes for RequestIRQ and ReleaseIRQ */
-#define IRQ_TYPE 0x03
-#define IRQ_TYPE_EXCLUSIVE 0x00
-#define IRQ_TYPE_TIME 0x01
-#define IRQ_TYPE_DYNAMIC_SHARING 0x02
-#define IRQ_FORCED_PULSE 0x04
-#define IRQ_FIRST_SHARED 0x08
-#define IRQ_HANDLE_PRESENT 0x10
-#define IRQ_PULSE_ALLOCATED 0x100
-
-/* Bits in IRQInfo1 field */
-#define IRQ_MASK 0x0f
-#define IRQ_NMI_ID 0x01
-#define IRQ_IOCK_ID 0x02
-#define IRQ_BERR_ID 0x04
-#define IRQ_VEND_ID 0x08
-#define IRQ_INFO2_VALID 0x10
-#define IRQ_LEVEL_ID 0x20
-#define IRQ_PULSE_ID 0x40
-#define IRQ_SHARE_ID 0x80
-
-typedef struct eventmask_t {
- u_int Attributes;
- u_int EventMask;
-} eventmask_t;
-
-#define CONF_EVENT_MASK_VALID 0x01
-
-/* Configuration registers present */
-#define PRESENT_OPTION 0x001
-#define PRESENT_STATUS 0x002
-#define PRESENT_PIN_REPLACE 0x004
-#define PRESENT_COPY 0x008
-#define PRESENT_EXT_STATUS 0x010
-#define PRESENT_IOBASE_0 0x020
-#define PRESENT_IOBASE_1 0x040
-#define PRESENT_IOBASE_2 0x080
-#define PRESENT_IOBASE_3 0x100
-#define PRESENT_IOSIZE 0x200
-
-/* For GetMemPage, MapMemPage */
-typedef struct memreq_t {
- u_int CardOffset;
- page_t Page;
-} memreq_t;
-
-/* For ModifyWindow */
-typedef struct modwin_t {
- u_int Attributes;
- u_int AccessSpeed;
-} modwin_t;
-
-/* For RequestWindow */
-typedef struct win_req_t {
- u_int Attributes;
- unsigned long Base;
- u_int Size;
- u_int AccessSpeed;
-} win_req_t;
-
-/* Attributes for RequestWindow */
-#define WIN_ADDR_SPACE 0x0001
-#define WIN_ADDR_SPACE_MEM 0x0000
-#define WIN_ADDR_SPACE_IO 0x0001
-#define WIN_MEMORY_TYPE 0x0002
-#define WIN_MEMORY_TYPE_CM 0x0000
-#define WIN_MEMORY_TYPE_AM 0x0002
-#define WIN_ENABLE 0x0004
-#define WIN_DATA_WIDTH 0x0018
-#define WIN_DATA_WIDTH_8 0x0000
-#define WIN_DATA_WIDTH_16 0x0008
-#define WIN_DATA_WIDTH_32 0x0010
-#define WIN_PAGED 0x0020
-#define WIN_SHARED 0x0040
-#define WIN_FIRST_SHARED 0x0080
-#define WIN_USE_WAIT 0x0100
-#define WIN_STRICT_ALIGN 0x0200
-#define WIN_MAP_BELOW_1MB 0x0400
-#define WIN_PREFETCH 0x0800
-#define WIN_CACHEABLE 0x1000
-#define WIN_BAR_MASK 0xe000
-#define WIN_BAR_SHIFT 13
-
-/* Attributes for RegisterClient */
-#define INFO_MASTER_CLIENT 0x01
-#define INFO_IO_CLIENT 0x02
-#define INFO_MTD_CLIENT 0x04
-#define INFO_MEM_CLIENT 0x08
-#define MAX_NUM_CLIENTS 3
-
-#define INFO_CARD_SHARE 0x10
-#define INFO_CARD_EXCL 0x20
-
-typedef struct cs_status_t {
- u_char Function;
- event_t CardState;
- event_t SocketState;
-} cs_status_t;
-
-typedef struct error_info_t {
- int func;
- int retcode;
-} error_info_t;
-
-/* Special stuff for binding drivers to sockets */
-typedef struct bind_req_t {
- socket_t Socket;
- u_char Function;
- dev_info_t *dev_info;
-} bind_req_t;
-
-/* Flag to bind to all functions */
-#define BIND_FN_ALL 0xff
-
-typedef struct mtd_bind_t {
- socket_t Socket;
- u_int Attributes;
- u_int CardOffset;
- dev_info_t *dev_info;
-} mtd_bind_t;
-
-/* Events */
-#define CS_EVENT_PRI_LOW 0
-#define CS_EVENT_PRI_HIGH 1
-
-#define CS_EVENT_WRITE_PROTECT 0x000001
-#define CS_EVENT_CARD_LOCK 0x000002
-#define CS_EVENT_CARD_INSERTION 0x000004
-#define CS_EVENT_CARD_REMOVAL 0x000008
-#define CS_EVENT_BATTERY_DEAD 0x000010
-#define CS_EVENT_BATTERY_LOW 0x000020
-#define CS_EVENT_READY_CHANGE 0x000040
-#define CS_EVENT_CARD_DETECT 0x000080
-#define CS_EVENT_RESET_REQUEST 0x000100
-#define CS_EVENT_RESET_PHYSICAL 0x000200
-#define CS_EVENT_CARD_RESET 0x000400
-#define CS_EVENT_REGISTRATION_COMPLETE 0x000800
-#define CS_EVENT_RESET_COMPLETE 0x001000
-#define CS_EVENT_PM_SUSPEND 0x002000
-#define CS_EVENT_PM_RESUME 0x004000
-#define CS_EVENT_INSERTION_REQUEST 0x008000
-#define CS_EVENT_EJECTION_REQUEST 0x010000
-#define CS_EVENT_MTD_REQUEST 0x020000
-#define CS_EVENT_ERASE_COMPLETE 0x040000
-#define CS_EVENT_REQUEST_ATTENTION 0x080000
-#define CS_EVENT_CB_DETECT 0x100000
-#define CS_EVENT_3VCARD 0x200000
-#define CS_EVENT_XVCARD 0x400000
-
-/* Return codes */
-#define CS_SUCCESS 0x00
-#define CS_BAD_ADAPTER 0x01
-#define CS_BAD_ATTRIBUTE 0x02
-#define CS_BAD_BASE 0x03
-#define CS_BAD_EDC 0x04
-#define CS_BAD_IRQ 0x06
-#define CS_BAD_OFFSET 0x07
-#define CS_BAD_PAGE 0x08
-#define CS_READ_FAILURE 0x09
-#define CS_BAD_SIZE 0x0a
-#define CS_BAD_SOCKET 0x0b
-#define CS_BAD_TYPE 0x0d
-#define CS_BAD_VCC 0x0e
-#define CS_BAD_VPP 0x0f
-#define CS_BAD_WINDOW 0x11
-#define CS_WRITE_FAILURE 0x12
-#define CS_NO_CARD 0x14
-#define CS_UNSUPPORTED_FUNCTION 0x15
-#define CS_UNSUPPORTED_MODE 0x16
-#define CS_BAD_SPEED 0x17
-#define CS_BUSY 0x18
-#define CS_GENERAL_FAILURE 0x19
-#define CS_WRITE_PROTECTED 0x1a
-#define CS_BAD_ARG_LENGTH 0x1b
-#define CS_BAD_ARGS 0x1c
-#define CS_CONFIGURATION_LOCKED 0x1d
-#define CS_IN_USE 0x1e
-#define CS_NO_MORE_ITEMS 0x1f
-#define CS_OUT_OF_RESOURCE 0x20
-#define CS_BAD_HANDLE 0x21
-
-#define CS_BAD_TUPLE 0x40
-
-#ifdef __KERNEL__
-
-/*
- * The main Card Services entry point
- */
-
-enum service {
- AccessConfigurationRegister, AddSocketServices,
- AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory,
- DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo,
- GetClientInfo, GetConfigurationInfo, GetEventMask,
- GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple,
- GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple,
- GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage,
- MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow,
- OpenMemory, ParseTuple, ReadMemory, RegisterClient,
- RegisterEraseQueue, RegisterMTD, RegisterTimer,
- ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ,
- ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices,
- RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ,
- RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry,
- SetEventMask, SetRegion, ValidateCIS, VendorSpecific,
- WriteMemory, BindDevice, BindMTD, ReportError,
- SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS,
- GetFirstWindow, GetNextWindow, GetMemPage
-};
-
-#ifdef IN_CARD_SERVICES
-extern int CardServices(int func, void *a1, void *a2, void *a3);
-#else
-extern int CardServices(int func, ...);
-#endif
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_CS_H */
diff --git a/mdk-stage1/pcmcia_/cs_types.h b/mdk-stage1/pcmcia_/cs_types.h
deleted file mode 100644
index 4598d7f48..000000000
--- a/mdk-stage1/pcmcia_/cs_types.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * cs_types.h 1.19 2001/08/24 12:16:12
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_CS_TYPES_H
-#define _LINUX_CS_TYPES_H
-
-#ifdef __linux__
-#ifdef __KERNEL__
-#include <linux/types.h>
-#else
-#include <sys/types.h>
-#endif
-#endif
-
-#ifdef __arm__
-typedef u_int ioaddr_t;
-#else
-typedef u_short ioaddr_t;
-#endif
-
-typedef u_short socket_t;
-typedef u_int event_t;
-typedef u_char cisdata_t;
-typedef u_short page_t;
-
-struct client_t;
-typedef struct client_t *client_handle_t;
-
-struct window_t;
-typedef struct window_t *window_handle_t;
-
-struct region_t;
-typedef struct region_t *memory_handle_t;
-
-struct eraseq_t;
-typedef struct eraseq_t *eraseq_handle_t;
-
-#ifndef DEV_NAME_LEN
-#define DEV_NAME_LEN 32
-#endif
-
-typedef char dev_info_t[DEV_NAME_LEN];
-
-#endif /* _LINUX_CS_TYPES_H */
diff --git a/mdk-stage1/pcmcia_/driver_ops.h b/mdk-stage1/pcmcia_/driver_ops.h
deleted file mode 100644
index 2f0a066d3..000000000
--- a/mdk-stage1/pcmcia_/driver_ops.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * driver_ops.h 1.16 2001/08/24 12:16:13
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_DRIVER_OPS_H
-#define _LINUX_DRIVER_OPS_H
-
-#ifndef DEV_NAME_LEN
-#define DEV_NAME_LEN 32
-#endif
-
-#ifdef __KERNEL__
-
-typedef struct dev_node_t {
- char dev_name[DEV_NAME_LEN];
- u_short major, minor;
- struct dev_node_t *next;
-} dev_node_t;
-
-typedef struct dev_locator_t {
- enum { LOC_ISA, LOC_PCI } bus;
- union {
- struct {
- u_short io_base_1, io_base_2;
- u_long mem_base;
- u_char irq, dma;
- } isa;
- struct {
- u_char bus;
- u_char devfn;
- } pci;
- } b;
-} dev_locator_t;
-
-typedef struct driver_operations {
- char *name;
- dev_node_t *(*attach) (dev_locator_t *loc);
- void (*suspend) (dev_node_t *dev);
- void (*resume) (dev_node_t *dev);
- void (*detach) (dev_node_t *dev);
-} driver_operations;
-
-int register_driver(struct driver_operations *ops);
-void unregister_driver(struct driver_operations *ops);
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_DRIVER_OPS_H */
diff --git a/mdk-stage1/pcmcia_/ds.h b/mdk-stage1/pcmcia_/ds.h
deleted file mode 100644
index 29db7b415..000000000
--- a/mdk-stage1/pcmcia_/ds.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * ds.h 1.57 2001/08/24 12:16:13
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_DS_H
-#define _LINUX_DS_H
-
-#include <pcmcia_/driver_ops.h>
-#include <pcmcia_/bulkmem.h>
-
-typedef struct tuple_parse_t {
- tuple_t tuple;
- cisdata_t data[255];
- cisparse_t parse;
-} tuple_parse_t;
-
-typedef struct win_info_t {
- window_handle_t handle;
- win_req_t window;
- memreq_t map;
-} win_info_t;
-
-typedef struct bind_info_t {
- dev_info_t dev_info;
- u_char function;
- struct dev_link_t *instance;
- char name[DEV_NAME_LEN];
- u_short major, minor;
- void *next;
-} bind_info_t;
-
-typedef struct mtd_info_t {
- dev_info_t dev_info;
- u_int Attributes;
- u_int CardOffset;
-} mtd_info_t;
-
-typedef union ds_ioctl_arg_t {
- servinfo_t servinfo;
- adjust_t adjust;
- config_info_t config;
- tuple_t tuple;
- tuple_parse_t tuple_parse;
- client_req_t client_req;
- cs_status_t status;
- conf_reg_t conf_reg;
- cisinfo_t cisinfo;
- region_info_t region;
- bind_info_t bind_info;
- mtd_info_t mtd_info;
- win_info_t win_info;
- cisdump_t cisdump;
-} ds_ioctl_arg_t;
-
-#define DS_GET_CARD_SERVICES_INFO _IOR ('d', 1, servinfo_t)
-#define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t)
-#define DS_GET_CONFIGURATION_INFO _IOWR('d', 3, config_info_t)
-#define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t)
-#define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t)
-#define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t)
-#define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t)
-#define DS_RESET_CARD _IO ('d', 8)
-#define DS_GET_STATUS _IOWR('d', 9, cs_status_t)
-#define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t)
-#define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t)
-#define DS_SUSPEND_CARD _IO ('d', 12)
-#define DS_RESUME_CARD _IO ('d', 13)
-#define DS_EJECT_CARD _IO ('d', 14)
-#define DS_INSERT_CARD _IO ('d', 15)
-#define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t)
-#define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t)
-#define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t)
-#define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t)
-#define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t)
-#define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t)
-
-#define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t)
-#define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t)
-#define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t)
-#define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t)
-#define DS_BIND_MTD _IOWR('d', 64, mtd_info_t)
-
-#ifdef __KERNEL__
-
-typedef struct dev_link_t {
- dev_node_t *dev;
- u_int state, open;
- wait_queue_head_t pending;
- struct timer_list release;
- client_handle_t handle;
- io_req_t io;
- irq_req_t irq;
- config_req_t conf;
- window_handle_t win;
- void *priv;
- struct dev_link_t *next;
-} dev_link_t;
-
-/* Flags for device state */
-#define DEV_PRESENT 0x01
-#define DEV_CONFIG 0x02
-#define DEV_STALE_CONFIG 0x04 /* release on close */
-#define DEV_STALE_LINK 0x08 /* detach on release */
-#define DEV_CONFIG_PENDING 0x10
-#define DEV_RELEASE_PENDING 0x20
-#define DEV_SUSPEND 0x40
-#define DEV_BUSY 0x80
-
-#define DEV_OK(l) \
- ((l) && ((l->state & ~DEV_BUSY) == (DEV_CONFIG|DEV_PRESENT)))
-
-int register_pccard_driver(dev_info_t *dev_info,
- dev_link_t *(*attach)(void),
- void (*detach)(dev_link_t *));
-
-int unregister_pccard_driver(dev_info_t *dev_info);
-
-#define register_pcmcia_driver register_pccard_driver
-#define unregister_pcmcia_driver unregister_pccard_driver
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_DS_H */
diff --git a/mdk-stage1/pcmcia_/i82365.h b/mdk-stage1/pcmcia_/i82365.h
deleted file mode 100644
index 38ff167fb..000000000
--- a/mdk-stage1/pcmcia_/i82365.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * i82365.h 1.21 2001/08/24 12:15:33
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_I82365_H
-#define _LINUX_I82365_H
-
-/* register definitions for the Intel 82365SL PCMCIA controller */
-
-/* Offsets for PCIC registers */
-#define I365_IDENT 0x00 /* Identification and revision */
-#define I365_STATUS 0x01 /* Interface status */
-#define I365_POWER 0x02 /* Power and RESETDRV control */
-#define I365_INTCTL 0x03 /* Interrupt and general control */
-#define I365_CSC 0x04 /* Card status change */
-#define I365_CSCINT 0x05 /* Card status change interrupt control */
-#define I365_ADDRWIN 0x06 /* Address window enable */
-#define I365_IOCTL 0x07 /* I/O control */
-#define I365_GENCTL 0x16 /* Card detect and general control */
-#define I365_GBLCTL 0x1E /* Global control register */
-
-/* Offsets for I/O and memory window registers */
-#define I365_IO(map) (0x08+((map)<<2))
-#define I365_MEM(map) (0x10+((map)<<3))
-#define I365_W_START 0
-#define I365_W_STOP 2
-#define I365_W_OFF 4
-
-/* Flags for I365_STATUS */
-#define I365_CS_BVD1 0x01
-#define I365_CS_STSCHG 0x01
-#define I365_CS_BVD2 0x02
-#define I365_CS_SPKR 0x02
-#define I365_CS_DETECT 0x0C
-#define I365_CS_WRPROT 0x10
-#define I365_CS_READY 0x20 /* Inverted */
-#define I365_CS_POWERON 0x40
-#define I365_CS_GPI 0x80
-
-/* Flags for I365_POWER */
-#define I365_PWR_OFF 0x00 /* Turn off the socket */
-#define I365_PWR_OUT 0x80 /* Output enable */
-#define I365_PWR_NORESET 0x40 /* Disable RESETDRV on resume */
-#define I365_PWR_AUTO 0x20 /* Auto pwr switch enable */
-#define I365_VCC_MASK 0x18 /* Mask for turning off Vcc */
-/* There are different layouts for B-step and DF-step chips: the B
- step has independent Vpp1/Vpp2 control, and the DF step has only
- Vpp1 control, plus 3V control */
-#define I365_VCC_5V 0x10 /* Vcc = 5.0v */
-#define I365_VCC_3V 0x18 /* Vcc = 3.3v */
-#define I365_VPP2_MASK 0x0c /* Mask for turning off Vpp2 */
-#define I365_VPP2_5V 0x04 /* Vpp2 = 5.0v */
-#define I365_VPP2_12V 0x08 /* Vpp2 = 12.0v */
-#define I365_VPP1_MASK 0x03 /* Mask for turning off Vpp1 */
-#define I365_VPP1_5V 0x01 /* Vpp2 = 5.0v */
-#define I365_VPP1_12V 0x02 /* Vpp2 = 12.0v */
-
-/* Flags for I365_INTCTL */
-#define I365_RING_ENA 0x80
-#define I365_PC_RESET 0x40
-#define I365_PC_IOCARD 0x20
-#define I365_INTR_ENA 0x10
-#define I365_IRQ_MASK 0x0F
-
-/* Flags for I365_CSC and I365_CSCINT*/
-#define I365_CSC_BVD1 0x01
-#define I365_CSC_STSCHG 0x01
-#define I365_CSC_BVD2 0x02
-#define I365_CSC_READY 0x04
-#define I365_CSC_DETECT 0x08
-#define I365_CSC_ANY 0x0F
-#define I365_CSC_GPI 0x10
-
-/* Flags for I365_ADDRWIN */
-#define I365_ENA_IO(map) (0x40 << (map))
-#define I365_ENA_MEM(map) (0x01 << (map))
-
-/* Flags for I365_IOCTL */
-#define I365_IOCTL_MASK(map) (0x0F << (map<<2))
-#define I365_IOCTL_WAIT(map) (0x08 << (map<<2))
-#define I365_IOCTL_0WS(map) (0x04 << (map<<2))
-#define I365_IOCTL_IOCS16(map) (0x02 << (map<<2))
-#define I365_IOCTL_16BIT(map) (0x01 << (map<<2))
-
-/* Flags for I365_GENCTL */
-#define I365_CTL_16DELAY 0x01
-#define I365_CTL_RESET 0x02
-#define I365_CTL_GPI_ENA 0x04
-#define I365_CTL_GPI_CTL 0x08
-#define I365_CTL_RESUME 0x10
-#define I365_CTL_SW_IRQ 0x20
-
-/* Flags for I365_GBLCTL */
-#define I365_GBL_PWRDOWN 0x01
-#define I365_GBL_CSC_LEV 0x02
-#define I365_GBL_WRBACK 0x04
-#define I365_GBL_IRQ_0_LEV 0x08
-#define I365_GBL_IRQ_1_LEV 0x10
-
-/* Flags for memory window registers */
-#define I365_MEM_16BIT 0x8000 /* In memory start high byte */
-#define I365_MEM_0WS 0x4000
-#define I365_MEM_WS1 0x8000 /* In memory stop high byte */
-#define I365_MEM_WS0 0x4000
-#define I365_MEM_WRPROT 0x8000 /* In offset high byte */
-#define I365_MEM_REG 0x4000
-
-#define I365_REG(slot, reg) (((slot) << 6) + reg)
-
-#endif /* _LINUX_I82365_H */
diff --git a/mdk-stage1/pcmcia_/lex_config.c b/mdk-stage1/pcmcia_/lex_config.c
deleted file mode 100644
index 2f990618d..000000000
--- a/mdk-stage1/pcmcia_/lex_config.c
+++ /dev/null
@@ -1,2053 +0,0 @@
-/* A lexical scanner generated by flex */
-
-/* Scanner skeleton version:
- * $Header$
- */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-
-#include <stdio.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-#include <unistd.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
- YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-//mdk-stage1// #define unput(c) yyunput( c, yytext_ptr )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart YY_PROTO(( FILE *input_file ));
-
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
-
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
-
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
-
-typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-typedef int yy_state_type;
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 45
-#define YY_END_OF_BUFFER 46
-static yyconst short int yy_accept[247] =
- { 0,
- 5, 5, 2, 2, 46, 44, 5, 4, 5, 44,
- 6, 41, 41, 44, 44, 44, 44, 44, 44, 44,
- 44, 44, 44, 44, 44, 44, 44, 44, 44, 3,
- 2, 45, 5, 5, 6, 0, 43, 0, 6, 41,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 30, 0,
- 0, 0, 3, 2, 0, 43, 0, 42, 0, 0,
- 0, 0, 9, 0, 0, 0, 0, 0, 0, 0,
- 0, 18, 0, 0, 0, 0, 23, 0, 0, 0,
-
- 0, 26, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, 10, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 25,
- 0, 27, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 11, 0, 0, 14, 0, 0, 0, 0,
- 19, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 31, 0, 0, 0, 0, 0, 13, 0,
- 0, 0, 0, 20, 21, 22, 0, 0, 0, 28,
- 0, 0, 0, 1, 0, 0, 0, 0, 12, 15,
- 0, 0, 17, 0, 0, 0, 0, 29, 0, 0,
-
- 32, 0, 0, 0, 0, 16, 0, 0, 0, 0,
- 0, 0, 0, 39, 7, 0, 0, 24, 0, 0,
- 0, 0, 0, 36, 0, 0, 0, 0, 0, 0,
- 33, 0, 0, 0, 34, 0, 0, 0, 40, 0,
- 0, 35, 37, 0, 38, 0
- } ;
-
-static yyconst int yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 4, 1, 5, 6, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 7, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 1, 6, 1,
- 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 10, 1, 1, 11, 1, 12, 13, 14, 15,
-
- 16, 17, 18, 1, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst int yy_meta[36] =
- { 0,
- 1, 2, 3, 2, 1, 1, 4, 4, 4, 1,
- 1, 4, 4, 4, 4, 4, 4, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst short int yy_base[253] =
- { 0,
- 0, 0, 34, 37, 293, 294, 40, 294, 41, 41,
- 0, 41, 45, 31, 273, 42, 40, 257, 38, 34,
- 274, 47, 273, 262, 53, 271, 57, 35, 60, 0,
- 79, 294, 82, 83, 0, 83, 294, 87, 0, 87,
- 0, 263, 260, 260, 255, 253, 269, 74, 245, 265,
- 244, 253, 262, 248, 259, 249, 249, 256, 255, 80,
- 239, 240, 248, 238, 80, 236, 236, 232, 294, 236,
- 233, 245, 0, 97, 95, 97, 108, 0, 230, 234,
- 242, 241, 294, 226, 242, 234, 226, 229, 234, 235,
- 226, 294, 231, 229, 220, 213, 294, 228, 209, 212,
-
- 228, 294, 209, 219, 221, 217, 216, 206, 211, 203,
- 215, 219, 194, 294, 294, 199, 196, 212, 209, 193,
- 208, 192, 190, 206, 200, 190, 195, 187, 190, 294,
- 192, 294, 188, 184, 200, 198, 195, 192, 188, 181,
- 191, 181, 294, 181, 186, 294, 186, 189, 180, 183,
- 294, 182, 161, 179, 183, 165, 170, 167, 158, 177,
- 166, 171, 294, 161, 174, 172, 158, 152, 294, 165,
- 165, 154, 162, 294, 166, 294, 153, 154, 158, 294,
- 157, 157, 160, 294, 146, 157, 140, 136, 294, 294,
- 147, 141, 294, 150, 133, 151, 139, 294, 148, 133,
-
- 294, 143, 142, 127, 126, 294, 142, 138, 140, 140,
- 124, 124, 136, 294, 294, 126, 118, 294, 130, 118,
- 113, 114, 115, 294, 125, 127, 108, 116, 99, 87,
- 294, 90, 87, 86, 294, 96, 78, 74, 294, 75,
- 64, 294, 294, 46, 294, 294, 118, 122, 126, 130,
- 134, 64
- } ;
-
-static yyconst short int yy_def[253] =
- { 0,
- 246, 1, 247, 247, 246, 246, 246, 246, 246, 248,
- 249, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 250,
- 246, 246, 246, 246, 249, 248, 246, 251, 249, 246,
- 252, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 250, 246, 248, 248, 251, 252, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
-
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
-
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 0, 246, 246, 246, 246,
- 246, 246
- } ;
-
-static yyconst short int yy_nxt[330] =
- { 0,
- 6, 7, 8, 9, 10, 11, 12, 13, 6, 6,
- 6, 14, 15, 16, 17, 18, 19, 6, 20, 21,
- 6, 6, 22, 23, 24, 25, 6, 26, 27, 28,
- 6, 29, 6, 6, 6, 31, 32, 31, 31, 32,
- 31, 33, 33, 33, 34, 37, 35, 40, 40, 42,
- 38, 40, 40, 45, 43, 48, 51, 53, 56, 69,
- 46, 54, 57, 47, 62, 70, 63, 78, 52, 49,
- 66, 58, 67, 245, 41, 71, 59, 64, 72, 244,
- 74, 68, 74, 33, 33, 33, 34, 37, 35, 36,
- 85, 76, 38, 40, 40, 98, 77, 104, 74, 37,
-
- 74, 37, 243, 242, 38, 86, 38, 241, 105, 99,
- 36, 240, 76, 239, 238, 237, 236, 77, 30, 30,
- 30, 30, 36, 36, 36, 36, 39, 39, 235, 39,
- 73, 234, 233, 73, 75, 75, 75, 75, 232, 231,
- 230, 229, 228, 227, 226, 225, 224, 223, 222, 221,
- 220, 219, 218, 217, 216, 215, 214, 213, 212, 211,
- 210, 209, 208, 207, 206, 205, 204, 203, 202, 201,
- 200, 199, 198, 197, 196, 195, 194, 193, 192, 191,
- 190, 189, 188, 187, 186, 185, 184, 183, 182, 181,
- 180, 179, 178, 177, 176, 175, 174, 173, 172, 171,
-
- 170, 169, 168, 167, 166, 165, 164, 163, 162, 161,
- 160, 159, 158, 157, 156, 155, 154, 153, 152, 151,
- 150, 149, 148, 147, 146, 145, 144, 143, 142, 141,
- 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,
- 130, 129, 128, 127, 126, 125, 124, 123, 122, 121,
- 120, 119, 118, 117, 116, 115, 114, 113, 112, 111,
- 110, 109, 108, 107, 106, 103, 102, 101, 100, 97,
- 96, 95, 94, 93, 92, 91, 90, 89, 88, 87,
- 84, 83, 82, 81, 80, 79, 65, 61, 60, 55,
- 50, 44, 246, 5, 246, 246, 246, 246, 246, 246,
-
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246
- } ;
-
-static yyconst short int yy_chk[330] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 3, 3, 4, 4,
- 4, 7, 9, 7, 9, 10, 9, 12, 12, 14,
- 10, 13, 13, 16, 14, 17, 19, 20, 22, 28,
- 16, 20, 22, 16, 25, 28, 25, 252, 19, 17,
- 27, 22, 27, 244, 12, 29, 22, 25, 29, 241,
- 31, 27, 31, 33, 34, 33, 34, 36, 34, 38,
- 48, 38, 36, 40, 40, 60, 38, 65, 74, 75,
-
- 74, 76, 240, 238, 75, 48, 76, 237, 65, 60,
- 77, 236, 77, 234, 233, 232, 230, 77, 247, 247,
- 247, 247, 248, 248, 248, 248, 249, 249, 229, 249,
- 250, 228, 227, 250, 251, 251, 251, 251, 226, 225,
- 223, 222, 221, 220, 219, 217, 216, 213, 212, 211,
- 210, 209, 208, 207, 205, 204, 203, 202, 200, 199,
- 197, 196, 195, 194, 192, 191, 188, 187, 186, 185,
- 183, 182, 181, 179, 178, 177, 175, 173, 172, 171,
- 170, 168, 167, 166, 165, 164, 162, 161, 160, 159,
- 158, 157, 156, 155, 154, 153, 152, 150, 149, 148,
-
- 147, 145, 144, 142, 141, 140, 139, 138, 137, 136,
- 135, 134, 133, 131, 129, 128, 127, 126, 125, 124,
- 123, 122, 121, 120, 119, 118, 117, 116, 113, 112,
- 111, 110, 109, 108, 107, 106, 105, 104, 103, 101,
- 100, 99, 98, 96, 95, 94, 93, 91, 90, 89,
- 88, 87, 86, 85, 84, 82, 81, 80, 79, 72,
- 71, 70, 68, 67, 66, 64, 63, 62, 61, 59,
- 58, 57, 56, 55, 54, 53, 52, 51, 50, 49,
- 47, 46, 45, 44, 43, 42, 26, 24, 23, 21,
- 18, 15, 5, 246, 246, 246, 246, 246, 246, 246,
-
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
- 246, 246, 246, 246, 246, 246, 246, 246, 246
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "lex_config.l"
-#define INITIAL 0
-/* Special state for handling include files */
-#define src 1
-
-#line 5 "lex_config.l"
-/*
- * lex_config.l 1.40 2001/08/24 12:21:25
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#undef src
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <syslog.h>
-#include <glob.h>
-#define src 1
-
-#include <pcmcia_/cs_types.h>
-#include <pcmcia_/cs.h>
-
-#include "yacc_config.h"
-
-/* For assembling nice error messages */
-char *current_file;
-int current_lineno;
-
-static int lex_number(char *s);
-static int lex_string(char *s);
-static void do_source(char *fn);
-static int do_eof(void);
-
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
-#else
-extern int yywrap YY_PROTO(( void ));
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-//mdk-stage1// static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-#endif
-
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
- { \
- int c = '*', n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp = NULL, *yy_bp = NULL;
- register int yy_act;
-
-#line 63 "lex_config.l"
-
-
-
- if ( yy_init )
- {
- yy_init = 0;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 247 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 294 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-
-do_action: /* This label is used only to access EOF actions. */
-
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 65 "lex_config.l"
-BEGIN(src);
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 66 "lex_config.l"
-/* skip */ ;
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 67 "lex_config.l"
-do_source(yytext); BEGIN(INITIAL);
- YY_BREAK
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(src):
-#line 68 "lex_config.l"
-if (do_eof()) yyterminate();
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 70 "lex_config.l"
-current_lineno++;
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 71 "lex_config.l"
-/* skip */ ;
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 72 "lex_config.l"
-/* skip */ ;
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 74 "lex_config.l"
-return ANONYMOUS;
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 75 "lex_config.l"
-return BIND;
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 76 "lex_config.l"
-return CIS;
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 77 "lex_config.l"
-return CARD;
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 78 "lex_config.l"
-return CLASS;
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 79 "lex_config.l"
-return DEFAULT;
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 80 "lex_config.l"
-return DEVICE;
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 81 "lex_config.l"
-return DTYPE;
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 82 "lex_config.l"
-return EXCLUDE;
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 83 "lex_config.l"
-return FUNCTION;
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 84 "lex_config.l"
-return INCLUDE;
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 85 "lex_config.l"
-return IRQ_NO;
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 86 "lex_config.l"
-return JEDEC;
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 87 "lex_config.l"
-return MANFID;
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 88 "lex_config.l"
-return MEMORY;
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 89 "lex_config.l"
-return MODULE;
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 90 "lex_config.l"
-return MTD;
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 91 "lex_config.l"
-return NEEDS_MTD;
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 92 "lex_config.l"
-return OPTS;
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 93 "lex_config.l"
-return PCI;
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 94 "lex_config.l"
-return PORT;
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 95 "lex_config.l"
-return REGION;
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 96 "lex_config.l"
-return RESERVE;
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 97 "lex_config.l"
-return TO;
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 98 "lex_config.l"
-return TUPLE;
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 99 "lex_config.l"
-return VERSION;
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 101 "lex_config.l"
-return lex_number("1");
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 102 "lex_config.l"
-return lex_number("2");
- YY_BREAK
-case 35:
-YY_RULE_SETUP
-#line 103 "lex_config.l"
-return lex_number("3");
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 104 "lex_config.l"
-return lex_number("4");
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-#line 105 "lex_config.l"
-return lex_number("5");
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 106 "lex_config.l"
-return lex_number("6");
- YY_BREAK
-case 39:
-YY_RULE_SETUP
-#line 107 "lex_config.l"
-return lex_number("7");
- YY_BREAK
-case 40:
-YY_RULE_SETUP
-#line 108 "lex_config.l"
-return lex_number("8");
- YY_BREAK
-case 41:
-YY_RULE_SETUP
-#line 110 "lex_config.l"
-return lex_number(yytext);
- YY_BREAK
-case 42:
-YY_RULE_SETUP
-#line 112 "lex_config.l"
-return lex_number(yytext);
- YY_BREAK
-case 43:
-YY_RULE_SETUP
-#line 114 "lex_config.l"
-return lex_string(yytext);
- YY_BREAK
-case 44:
-YY_RULE_SETUP
-#line 116 "lex_config.l"
-return yytext[0];
- YY_BREAK
-case 45:
-YY_RULE_SETUP
-#line 118 "lex_config.l"
-ECHO;
- YY_BREAK
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( yy_current_buffer->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
-
- else
- {
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
-
- int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yy_current_buffer->yy_buf_size -
- number_to_move - 1;
-#endif
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
-
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
-
- return ret_val;
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = yy_start;
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 247 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
- register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 247 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 246);
-
- return yy_is_jam ? 0 : yy_current_state;
- }
-
-
-//mdk-stage1// #ifndef YY_NO_UNPUT
-//mdk-stage1// #ifdef YY_USE_PROTOS
-//mdk-stage1// static void yyunput( int c, register char *yy_bp )
-//mdk-stage1// #else
-//mdk-stage1// static void yyunput( c, yy_bp )
-//mdk-stage1// int c;
-//mdk-stage1// register char *yy_bp;
-//mdk-stage1// #endif
-//mdk-stage1// {
-//mdk-stage1// register char *yy_cp = yy_c_buf_p;
-//mdk-stage1//
-//mdk-stage1// /* undo effects of setting up yytext */
-//mdk-stage1// *yy_cp = yy_hold_char;
-//mdk-stage1//
-//mdk-stage1// if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
-//mdk-stage1// { /* need to shift things up to make room */
-//mdk-stage1// /* +2 for EOB chars. */
-//mdk-stage1// register int number_to_move = yy_n_chars + 2;
-//mdk-stage1// register char *dest = &yy_current_buffer->yy_ch_buf[
-//mdk-stage1// yy_current_buffer->yy_buf_size + 2];
-//mdk-stage1// register char *source =
-//mdk-stage1// &yy_current_buffer->yy_ch_buf[number_to_move];
-//mdk-stage1//
-//mdk-stage1// while ( source > yy_current_buffer->yy_ch_buf )
-//mdk-stage1// *--dest = *--source;
-//mdk-stage1//
-//mdk-stage1// yy_cp += (int) (dest - source);
-//mdk-stage1// yy_bp += (int) (dest - source);
-//mdk-stage1// yy_current_buffer->yy_n_chars =
-//mdk-stage1// yy_n_chars = yy_current_buffer->yy_buf_size;
-//mdk-stage1//
-//mdk-stage1// if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
-//mdk-stage1// YY_FATAL_ERROR( "flex scanner push-back overflow" );
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// *--yy_cp = (char) c;
-//mdk-stage1//
-//mdk-stage1//
-//mdk-stage1// yytext_ptr = yy_bp;
-//mdk-stage1// yy_hold_char = *yy_cp;
-//mdk-stage1// yy_c_buf_p = yy_cp;
-//mdk-stage1// }
-//mdk-stage1// #endif /* ifndef YY_NO_UNPUT */
-
-
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
- {
- int c;
-
- *yy_c_buf_p = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* This was really a NUL. */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart( yyin );
-
- /* fall through */
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- return EOF;
-
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
-
- return c;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer( b, file );
-
- return b;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
- if ( ! b )
- return;
-
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
-
- yy_flex_free( (void *) b );
- }
-
-
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
-
- {
- yy_flush_buffer( b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
-#if YY_ALWAYS_INTERACTIVE
- b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
- {
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
- }
-
-
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer( b );
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
-
- return yy_scan_bytes( yy_str, len );
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
- {
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
- buf = (char *) yy_flex_alloc( n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
-
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer( buf, n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- yy_size_t new_size;
-
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
-
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
-
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
-
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
-
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
- BEGIN(new_state);
- }
-#endif
-
-
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
-
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-#endif
-
-
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-#endif
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
- }
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
- {
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
- }
-#endif
-
-#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
- {
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
- }
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
- {
- return (void *) malloc( size );
- }
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
- {
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
- }
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
-
-#if YY_MAIN
-int main()
- {
- yylex();
- return 0;
- }
-#endif
-#line 118 "lex_config.l"
-
-
-#ifndef yywrap
-int yywrap() { return 1; }
-#endif
-
-/*======================================================================
-
- Stuff to parse basic data types
-
-======================================================================*/
-
-static int lex_number(char *s)
-{
- yylval.num = strtoul(s, NULL, 0);
- return NUMBER;
-}
-
-static int lex_string(char *s)
-{
- int n = strlen(s);
- yylval.str = malloc(n-1);
- strncpy(yylval.str, s+1, n-2);
- yylval.str[n-2] = '\0';
- return STRING;
-}
-
-/*======================================================================
-
- Code to support nesting of configuration files
-
-======================================================================*/
-
-#define MAX_SOURCE_DEPTH 4
-struct source_stack {
- YY_BUFFER_STATE buffer;
- char *filename;
- int lineno, fileno;
- FILE *file;
- glob_t glob;
-} source_stack[MAX_SOURCE_DEPTH];
-static int source_stack_ptr = 0;
-static int parse_env = 0;
-
-static int get_glob(void)
-{
- struct source_stack *s = &source_stack[source_stack_ptr];
- while (s->fileno < s->glob.gl_pathc) {
- char *fn = s->glob.gl_pathv[s->fileno];
- s->file = fopen(fn, "r");
- if (s->file == NULL) {
- if (strpbrk(fn, "?*[") == NULL)
- syslog(LOG_INFO, "could not open '%s': %m", fn);
- s->fileno++;
- } else {
- current_lineno = 1;
- current_file = strdup(fn);
- yy_switch_to_buffer(yy_create_buffer(s->file, YY_BUF_SIZE));
- source_stack_ptr++;
- s->fileno++;
- return 0;
- }
- }
- return -1;
-}
-
-static void do_source(char *fn)
-{
- struct source_stack *s = &source_stack[source_stack_ptr];
-
- if (source_stack_ptr >= MAX_SOURCE_DEPTH) {
- syslog(LOG_INFO, "source depth limit exceeded");
- return;
- }
- glob(fn, GLOB_NOCHECK, NULL, &s->glob);
- s->fileno = 0;
- s->buffer = YY_CURRENT_BUFFER;
- s->lineno = current_lineno;
- s->filename = current_file;
- get_glob();
-}
-
-static int do_eof(void)
-{
- struct source_stack *s = &source_stack[--source_stack_ptr];
- if (source_stack_ptr < 0) {
- if (parse_env == 0) {
- char *t = getenv("PCMCIA_OPTS");
- if (t == NULL) return -1;
- parse_env = 1;
- source_stack_ptr = 0;
- current_file = "PCMCIA_OPTS";
- current_lineno = 1;
- yy_scan_string(t);
- return 0;
- } else
- return -1;
- }
- fclose(s->file);
- free(current_file);
- yy_delete_buffer(YY_CURRENT_BUFFER);
- if (get_glob() != 0) {
- yy_switch_to_buffer(s->buffer);
- current_lineno = s->lineno;
- current_file = s->filename;
- }
- return 0;
-}
-
-/*======================================================================
-
- The main entry point... returns -1 if the file can't be accessed.
-
-======================================================================*/
-int yyparse(void);
-
-int parse_configfile(char *fn)
-{
- FILE *f;
-
- f = fopen(fn, "r");
- if (!f) {
- syslog(LOG_INFO, "could not open '%s': %m", fn);
- return -1;
- }
- current_lineno = 1;
- current_file = fn;
- source_stack_ptr = 0;
- yyrestart(f);
- yyparse();
- fclose(f);
- return 0;
-}
-
diff --git a/mdk-stage1/pcmcia_/merge_from_pcitable b/mdk-stage1/pcmcia_/merge_from_pcitable
deleted file mode 100755
index 3b88a1cd8..000000000
--- a/mdk-stage1/pcmcia_/merge_from_pcitable
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/perl
-
-# This program will show on stdout yenta_socket stuff from pcitable
-# which is not in probe.c
-
-use MDK::Common;
-
-my %probes;
-foreach (cat_('probe.c')) {
- if (/^pci_id_t pci_id\[\] = {/ ... /^};/) {
- /^\s*{\s*0x([\da-f]+),\s*0x([\da-f]+),\s*"([^"]*)",\s*"([^"]*)"\s*}/
- and $probes{"$1$2"} = { vendor => $1, device => $2, driver => $3, name => $4 };
- }
-}
-
-require '/usr/bin/merge2pcitable.pl';
-my $drivers = read_pcitable("/usr/share/ldetect-lst/pcitable");
-
-my %pcitable = map_each {
- $::a =~ /^(....)(....)/ or die;
- "$1$2" => { vendor => $1, device => $2, driver => $::b->[0], name => $::b->[1] };
-} %$drivers;
-
-my @yenta_socket_ids = grep { $pcitable{$_}{driver} eq 'yenta_socket' } keys %pcitable;
-
-if (my @missing_in_probe_c = difference2(\@yenta_socket_ids, [ keys %probes ])) {
- print "Missing in `probe.c':\n",
- map {
- my $p = $pcitable{$_};
- qq( { 0x$p->{vendor}, 0x$p->{device}, "yenta_socket", "$p->{name}" },\n);
- } sort @missing_in_probe_c;
-}
-
-my @res;
-foreach my $id (keys %probes) {
- my $p = $probes{$id};
- my $r = $pcitable{$id};
- if (!$r || $r->{driver} ne 'yenta_socket') {
- push @res, qq(0x$p->{vendor}\t0x$p->{device}\t"yenta_socket"\t") . ($r ? $r->{name} : '(COMPLETELY MISSING)') . qq("\n);
- }
- if ($r && $r->{driver} ne 'unknown' && $r->{driver} ne $p->{driver}) {
- warn "WARNING: $id: pcitable:$r->{driver} vs probe.c:$p->{driver}\n";
- }
-}
-if (@res) {
- print "\n", "Missing in pcitable:\n", sort @res;
-}
diff --git a/mdk-stage1/pcmcia_/pcmcia.h b/mdk-stage1/pcmcia_/pcmcia.h
deleted file mode 100644
index 3559d5fd6..000000000
--- a/mdk-stage1/pcmcia_/pcmcia.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#ifndef _PCMCIA_CARDMGR_INTERFACE_H_
-#define _PCMCIA_CARDMGR_INTERFACE_H_
-
-char * pcmcia_probe(void);
-int cardmgr_call(void);
-
-#endif
diff --git a/mdk-stage1/pcmcia_/probe.c b/mdk-stage1/pcmcia_/probe.c
deleted file mode 100644
index 8f8a4bc8e..000000000
--- a/mdk-stage1/pcmcia_/probe.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
- *
- * Copyright 2000-2001 Mandrakesoft
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * Code comes from /anonymous@projects.sourceforge.net:/pub/pcmcia-cs/pcmcia-cs-3.1.29.tar.bz2
- */
-
-/*======================================================================
-
- PCMCIA controller probe
-
- probe.c 1.55 2001/08/24 12:19:20
-
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The initial developer of the original code is David A. Hinds
- <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU General Public License version 2 (the "GPL"), in
- which case the provisions of the GPL are applicable instead of the
- above. If you wish to allow the use of your version of this file
- only under the terms of the GPL and not to allow others to use
- your version of this file under the MPL, indicate your decision
- by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
-======================================================================*/
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-
-//mdk-stage1// #include <pcmcia/config.h>
-#include "log.h"
-#include "pcmcia.h"
-
-/*====================================================================*/
-
-//mdk-stage1// #ifdef CONFIG_PCI
-
-typedef struct {
- u_short vendor, device;
- char *modname;
- char *name;
-} pci_id_t;
-
-pci_id_t pci_id[] = {
- { 0x1013, 0x1100, "i82365", "Cirrus Logic CL 6729" },
- { 0x1013, 0x1110, "yenta_socket", "Cirrus Logic PD 6832" },
- { 0x10b3, 0xb106, "yenta_socket", "SMC 34C90" },
- { 0x1180, 0x0465, "yenta_socket", "Ricoh RL5C465" },
- { 0x1180, 0x0466, "yenta_socket", "Ricoh RL5C466" },
- { 0x1180, 0x0475, "yenta_socket", "Ricoh RL5C475" },
- { 0x1180, 0x0476, "yenta_socket", "Ricoh RL5C476" },
- { 0x1180, 0x0477, "yenta_socket", "Ricoh RL5C477" },
- { 0x1180, 0x0478, "yenta_socket", "Ricoh RL5C478" },
- { 0x104c, 0xac12, "yenta_socket", "Texas Instruments PCI1130" },
- { 0x104c, 0xac13, "yenta_socket", "Texas Instruments PCI1031" },
- { 0x104c, 0xac15, "yenta_socket", "Texas Instruments PCI1131" },
- { 0x104c, 0xac1a, "yenta_socket", "Texas Instruments PCI1210" },
- { 0x104c, 0xac1e, "yenta_socket", "Texas Instruments PCI1211" },
- { 0x104c, 0xac17, "yenta_socket", "Texas Instruments PCI1220" },
- { 0x104c, 0xac19, "yenta_socket", "Texas Instruments PCI1221" },
- { 0x104c, 0xac1c, "yenta_socket", "Texas Instruments PCI1225" },
- { 0x104c, 0xac16, "yenta_socket", "Texas Instruments PCI1250" },
- { 0x104c, 0xac1d, "yenta_socket", "Texas Instruments PCI1251A" },
- { 0x104c, 0xac1f, "yenta_socket", "Texas Instruments PCI1251B" },
- { 0x104c, 0xac50, "yenta_socket", "Texas Instruments PCI1410" },
- { 0x104c, 0xac51, "yenta_socket", "Texas Instruments PCI1420" },
- { 0x104c, 0xac1b, "yenta_socket", "Texas Instruments PCI1450" },
- { 0x104c, 0xac52, "yenta_socket", "Texas Instruments PCI1451" },
- { 0x104c, 0xac56, "yenta_socket", "Texas Instruments PCI1510" },
- { 0x104c, 0xac55, "yenta_socket", "Texas Instruments PCI1520" },
- { 0x104c, 0xac54, "yenta_socket", "Texas Instruments PCI1620" },
- { 0x104c, 0xac41, "yenta_socket", "Texas Instruments PCI4410" },
- { 0x104c, 0xac40, "yenta_socket", "Texas Instruments PCI4450" },
- { 0x104c, 0xac42, "yenta_socket", "Texas Instruments PCI4451" },
- { 0x104c, 0xac44, "yenta_socket", "Texas Instruments PCI4510" },
- { 0x104c, 0xac46, "yenta_socket", "Texas Instruments PCI4520" },
- { 0x104c, 0xac49, "yenta_socket", "Texas Instruments PCI7410" },
- { 0x104c, 0xac47, "yenta_socket", "Texas Instruments PCI7510" },
- { 0x104c, 0xac48, "yenta_socket", "Texas Instruments PCI7610" },
- { 0x104c, 0xac8e, "yenta_socket", "Texas Instruments PCI7420" },
- { 0x1217, 0x6729, "i82365", "O2 Micro 6729" },
- { 0x1217, 0x673a, "i82365", "O2 Micro 6730" },
- { 0x1217, 0x6832, "yenta_socket", "O2 Micro 6832/6833" },
- { 0x1217, 0x6836, "yenta_socket", "O2 Micro 6836/6860" },
- { 0x1217, 0x6872, "yenta_socket", "O2 Micro 6812" },
- { 0x1217, 0x6925, "yenta_socket", "O2 Micro 6922" },
- { 0x1217, 0x6933, "yenta_socket", "O2 Micro 6933" },
- { 0x1217, 0x6972, "yenta_socket", "O2 Micro 6912" },
- { 0x1217, 0x7114, "yenta_socket", "O2 Micro 711M1" },
- { 0x1179, 0x0603, "i82365", "Toshiba ToPIC95-A" },
- { 0x1179, 0x060a, "yenta_socket", "Toshiba ToPIC95-B" },
- { 0x1179, 0x060f, "yenta_socket", "Toshiba ToPIC97" },
- { 0x1179, 0x0617, "yenta_socket", "Toshiba ToPIC100" },
- { 0x119b, 0x1221, "i82365", "Omega Micro 82C092G" },
- { 0x8086, 0x1221, "i82092", "Intel 82092AA_0" },
- { 0x8086, 0x1222, "i82092", "Intel 82092AA_1" },
- { 0x1524, 0x1211, "yenta_socket", "ENE 1211" },
- { 0x1524, 0x1225, "yenta_socket", "ENE 1225" },
- { 0x1524, 0x1410, "yenta_socket", "ENE 1410" },
- { 0x1524, 0x1411, "yenta_socket", "ENE Technology CB1411" },
- { 0x1524, 0x1420, "yenta_socket", "ENE 1420" },
-};
-#define PCI_COUNT (sizeof(pci_id)/sizeof(pci_id_t))
-
-char * driver = NULL;
-
-static int pci_probe(void)
-{
- char s[256], *name = NULL;
- u_int device, vendor, i;
- FILE *f;
-
-//mdk-stage1// if (!module)
- log_message("PCMCIA: probing PCI bus..");
-
- if ((f = fopen("/proc/bus/pci/devices", "r")) != NULL) {
- while (fgets(s, 256, f) != NULL) {
- u_int n = strtoul(s+5, NULL, 16);
- vendor = (n >> 16); device = (n & 0xffff);
- for (i = 0; i < PCI_COUNT; i++)
- if ((vendor == pci_id[i].vendor) &&
- (device == pci_id[i].device)) break;
- if (i < PCI_COUNT) {
- name = pci_id[i].name;
- driver = pci_id[i].modname;
- }
- }
- }
-//mdk-stage1// else if ((f = fopen("/proc/pci", "r")) != NULL) {
-//mdk-stage1// while (fgets(s, 256, f) != NULL) {
-//mdk-stage1// t = strstr(s, "Device id=");
-//mdk-stage1// if (t) {
-//mdk-stage1// device = strtoul(t+10, NULL, 16);
-//mdk-stage1// t = strstr(s, "Vendor id=");
-//mdk-stage1// vendor = strtoul(t+10, NULL, 16);
-//mdk-stage1// for (i = 0; i < PCI_COUNT; i++)
-//mdk-stage1// if ((vendor == pci_id[i].vendor) &&
-//mdk-stage1// (device == pci_id[i].device)) break;
-//mdk-stage1// } else
-//mdk-stage1// for (i = 0; i < PCI_COUNT; i++)
-//mdk-stage1// if (strstr(s, pci_id[i].tag) != NULL) break;
-//mdk-stage1// if (i != PCI_COUNT) {
-//mdk-stage1// name = pci_id[i].name;
-//mdk-stage1// break;
-//mdk-stage1// } else {
-//mdk-stage1// t = strstr(s, "CardBus bridge");
-//mdk-stage1// if (t != NULL) {
-//mdk-stage1// name = t + 16;
-//mdk-stage1// t = strchr(s, '(');
-//mdk-stage1// t[-1] = '\0';
-//mdk-stage1// break;
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// }
- fclose(f);
-
- if (name) {
-//mdk-stage1// if (module)
-//mdk-stage1// printf("i82365\n");
-//mdk-stage1// else
- log_message("\t%s found, 2 sockets (driver %s).", name, driver);
- return 0;
- } else {
-//mdk-stage1// if (!module)
- log_message("\tnot found.");
- return -ENODEV;
- }
-}
-//mdk-stage1// #endif
-
-/*====================================================================*/
-
-//mdk-stage1// #ifdef CONFIG_ISA
-//mdk-stage1//
-//mdk-stage1// #ifdef __GLIBC__
-#include <sys/io.h>
-//mdk-stage1// #else
-//mdk-stage1// #include <asm/io.h>
-//mdk-stage1// #endif
-typedef u_short ioaddr_t;
-
-#include "i82365.h"
-#include "cirrus.h"
-#include "vg468.h"
-
-static ioaddr_t i365_base = 0x03e0;
-
-static u_char i365_get(u_short sock, u_short reg)
-{
- u_char val = I365_REG(sock, reg);
- outb(val, i365_base); val = inb(i365_base+1);
- return val;
-}
-
-static void i365_set(u_short sock, u_short reg, u_char data)
-{
- u_char val = I365_REG(sock, reg);
- outb(val, i365_base); outb(data, i365_base+1);
-}
-
-static void i365_bset(u_short sock, u_short reg, u_char mask)
-{
- u_char d = i365_get(sock, reg);
- d |= mask;
- i365_set(sock, reg, d);
-}
-
-static void i365_bclr(u_short sock, u_short reg, u_char mask)
-{
- u_char d = i365_get(sock, reg);
- d &= ~mask;
- i365_set(sock, reg, d);
-}
-
-int i365_probe(void)
-{
- int val, sock, done;
- char *name = "i82365sl";
-
-//mdk-stage1// if (!module)
- log_message("PCMCIA: probing for Intel PCIC (ISA)..");
-//mdk-stage1// if (verbose) printf("\n");
-
- sock = done = 0;
- if (ioperm(i365_base, 4, 1)) {
- log_perror("PCMCIA: ioperm");
- return -1;
- }
- ioperm(0x80, 1, 1);
- for (; sock < 2; sock++) {
- val = i365_get(sock, I365_IDENT);
-//mdk-stage1// if (verbose)
-//mdk-stage1// printf(" ident(%d)=%#2.2x", sock, val);
- switch (val) {
- case 0x82:
- name = "i82365sl A step";
- break;
- case 0x83:
- name = "i82365sl B step";
- break;
- case 0x84:
- name = "VLSI 82C146";
- break;
- case 0x88: case 0x89: case 0x8a:
- name = "IBM Clone";
- break;
- case 0x8b: case 0x8c:
- break;
- default:
- done = 1;
- }
- if (done) break;
- }
-
-//mdk-stage1// if (verbose) printf("\n ");
- if (sock == 0) {
-//mdk-stage1// if (!module)
- log_message("\tnot found.");
- return -ENODEV;
- }
-
- if ((sock == 2) && (strcmp(name, "VLSI 82C146") == 0))
- name = "i82365sl DF";
-
- /* Check for Vadem chips */
- outb(0x0e, i365_base);
- outb(0x37, i365_base);
- i365_bset(0, VG468_MISC, VG468_MISC_VADEMREV);
- val = i365_get(0, I365_IDENT);
- if (val & I365_IDENT_VADEM) {
- if ((val & 7) < 4)
- name = "Vadem VG-468";
- else
- name = "Vadem VG-469";
- i365_bclr(0, VG468_MISC, VG468_MISC_VADEMREV);
- }
-
- /* Check for Cirrus CL-PD67xx chips */
- i365_set(0, PD67_CHIP_INFO, 0);
- val = i365_get(0, PD67_CHIP_INFO);
- if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) {
- val = i365_get(0, PD67_CHIP_INFO);
- if ((val & PD67_INFO_CHIP_ID) == 0) {
- if (val & PD67_INFO_SLOTS)
- name = "Cirrus CL-PD672x";
- else {
- name = "Cirrus CL-PD6710";
- sock = 1;
- }
- i365_set(0, PD67_EXT_INDEX, 0xe5);
- if (i365_get(0, PD67_EXT_INDEX) != 0xe5)
- name = "VIA VT83C469";
- }
- }
-
-//mdk-stage1// if (module)
-//mdk-stage1// printf("i82365\n");
-//mdk-stage1// else
- printf("\t%s found, %d sockets.\n", name, sock);
- return 0;
-
-} /* i365_probe */
-
-//mdk-stage1//#endif /* CONFIG_ISA */
-
-/*====================================================================*/
-
-//mdk-stage1//#ifdef CONFIG_ISA
-
-#include "tcic.h"
-
-//mdk-stage1//static ioaddr_t tcic_base = TCIC_BASE;
-
-static u_char tcic_getb(ioaddr_t base, u_char reg)
-{
- u_char val = inb(base+reg);
- return val;
-}
-
-static void tcic_setb(ioaddr_t base, u_char reg, u_char data)
-{
- outb(data, base+reg);
-}
-
-static u_short tcic_getw(ioaddr_t base, u_char reg)
-{
- u_short val = inw(base+reg);
- return val;
-}
-
-static void tcic_setw(ioaddr_t base, u_char reg, u_short data)
-{
- outw(data, base+reg);
-}
-
-static u_short tcic_aux_getw(ioaddr_t base, u_short reg)
-{
- u_char mode = (tcic_getb(base, TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;
- tcic_setb(base, TCIC_MODE, mode);
- return tcic_getw(base, TCIC_AUX);
-}
-
-static void tcic_aux_setw(ioaddr_t base, u_short reg, u_short data)
-{
- u_char mode = (tcic_getb(base, TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;
- tcic_setb(base, TCIC_MODE, mode);
- tcic_setw(base, TCIC_AUX, data);
-}
-
-static int get_tcic_id(ioaddr_t base)
-{
- u_short id;
- tcic_aux_setw(base, TCIC_AUX_TEST, TCIC_TEST_DIAG);
- id = tcic_aux_getw(base, TCIC_AUX_ILOCK);
- id = (id & TCIC_ILOCKTEST_ID_MASK) >> TCIC_ILOCKTEST_ID_SH;
- tcic_aux_setw(base, TCIC_AUX_TEST, 0);
- return id;
-}
-
-int tcic_probe_at(ioaddr_t base)
-{
- int i;
- u_short old;
-
- /* Anything there?? */
- for (i = 0; i < 0x10; i += 2)
- if (tcic_getw(base, i) == 0xffff)
- return -1;
-
-//mdk-stage1// if (!module)
- log_message("\tat %#3.3x: ", base); fflush(stdout);
-
- /* Try to reset the chip */
- tcic_setw(base, TCIC_SCTRL, TCIC_SCTRL_RESET);
- tcic_setw(base, TCIC_SCTRL, 0);
-
- /* Can we set the addr register? */
- old = tcic_getw(base, TCIC_ADDR);
- tcic_setw(base, TCIC_ADDR, 0);
- if (tcic_getw(base, TCIC_ADDR) != 0) {
- tcic_setw(base, TCIC_ADDR, old);
- return -2;
- }
-
- tcic_setw(base, TCIC_ADDR, 0xc3a5);
- if (tcic_getw(base, TCIC_ADDR) != 0xc3a5)
- return -3;
-
- return 2;
-}
-
-int tcic_probe(void)
-{
- int sock, id;
-
-//mdk-stage1// if (!module)
- log_message("PCMCIA: probing for Databook TCIC-2 (ISA).."); fflush(stdout);
-
- if (ioperm(TCIC_BASE, 16, 1)) {
- log_perror("PCMCIA: ioperm");
- return -1;
- }
- ioperm(0x80, 1, 1);
- sock = tcic_probe_at(TCIC_BASE);
-
- if (sock <= 0) {
-//mdk-stage1// if (!module)
- log_message("\tnot found.");
- return -ENODEV;
- }
-
-//mdk-stage1// if (module)
-//mdk-stage1// printf("tcic\n");
-//mdk-stage1// else {
- id = get_tcic_id(TCIC_BASE);
- switch (id) {
- case TCIC_ID_DB86082:
- log_message("DB86082"); break;
- case TCIC_ID_DB86082A:
- log_message("DB86082A"); break;
- case TCIC_ID_DB86084:
- log_message("DB86084"); break;
- case TCIC_ID_DB86084A:
- log_message("DB86084A"); break;
- case TCIC_ID_DB86072:
- log_message("DB86072"); break;
- case TCIC_ID_DB86184:
- log_message("DB86184"); break;
- case TCIC_ID_DB86082B:
- log_message("DB86082B"); break;
- default:
- log_message("Unknown TCIC-2 ID 0x%02x", id);
- }
- log_message(" found at %#6x, %d sockets.", TCIC_BASE, sock);
-//mdk-stage1// }
- return 0;
-
-} /* tcic_probe */
-
-//mdk-stage1// #endif /* CONFIG_ISA */
-
-//mdk-stage1// /*====================================================================*/
-//mdk-stage1//
-//mdk-stage1// int main(int argc, char *argv[])
-//mdk-stage1// {
-//mdk-stage1// int optch, errflg;
-//mdk-stage1// extern char *optarg;
-//mdk-stage1// int verbose = 0, module = 0;
-//mdk-stage1//
-//mdk-stage1// errflg = 0;
-//mdk-stage1// while ((optch = getopt(argc, argv, "t:vxm")) != -1) {
-//mdk-stage1// switch (optch) {
-//mdk-stage1// #ifdef CONFIG_ISA
-//mdk-stage1// case 't':
-//mdk-stage1// tcic_base = strtoul(optarg, NULL, 0); break;
-//mdk-stage1// #endif
-//mdk-stage1// case 'v':
-//mdk-stage1// verbose = 1; break;
-//mdk-stage1// case 'm':
-//mdk-stage1// module = 1; break;
-//mdk-stage1// default:
-//mdk-stage1// errflg = 1; break;
-//mdk-stage1// }
-//mdk-stage1// }
-//mdk-stage1// if (errflg || (optind < argc)) {
-//mdk-stage1// fprintf(stderr, "usage: %s [-t tcic_base] [-v] [-m]\n", argv[0]);
-//mdk-stage1// exit(EXIT_FAILURE);
-//mdk-stage1// }
-//mdk-stage1//
-//mdk-stage1// #ifdef CONFIG_PCI
-//mdk-stage1// if (pci_probe(verbose, module) == 0)
-//mdk-stage1// exit(EXIT_SUCCESS);
-//mdk-stage1// #endif
-//mdk-stage1// #ifdef CONFIG_ISA
-//mdk-stage1// if (i365_probe(verbose, module) == 0)
-//mdk-stage1// exit(EXIT_SUCCESS);
-//mdk-stage1// else if (tcic_probe(verbose, module, tcic_base) == 0)
-//mdk-stage1// exit(EXIT_SUCCESS);
-//mdk-stage1// #endif
-//mdk-stage1// exit(EXIT_FAILURE);
-//mdk-stage1// return 0;
-//mdk-stage1// }
-
-
-char * pcmcia_probe(void)
-{
- if (!pci_probe())
- return driver;
- else if (!i365_probe())
- return "i82365";
- else if (!tcic_probe())
- return "tcic";
- else
- return NULL;
-}
diff --git a/mdk-stage1/pcmcia_/tcic.h b/mdk-stage1/pcmcia_/tcic.h
deleted file mode 100644
index cad193885..000000000
--- a/mdk-stage1/pcmcia_/tcic.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * tcic.h 1.15 2001/08/24 12:15:34
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_TCIC_H
-#define _LINUX_TCIC_H
-
-#define TCIC_BASE 0x240
-
-/* offsets of registers from TCIC_BASE */
-#define TCIC_DATA 0x00
-#define TCIC_ADDR 0x02
-#define TCIC_SCTRL 0x06
-#define TCIC_SSTAT 0x07
-#define TCIC_MODE 0x08
-#define TCIC_PWR 0x09
-#define TCIC_EDC 0x0A
-#define TCIC_ICSR 0x0C
-#define TCIC_IENA 0x0D
-#define TCIC_AUX 0x0E
-
-#define TCIC_SS_SHFT 12
-#define TCIC_SS_MASK 0x7000
-
-/* Flags for TCIC_ADDR */
-#define TCIC_ADR2_REG 0x8000
-#define TCIC_ADR2_INDREG 0x0800
-
-#define TCIC_ADDR_REG 0x80000000
-#define TCIC_ADDR_SS_SHFT (TCIC_SS_SHFT+16)
-#define TCIC_ADDR_SS_MASK (TCIC_SS_MASK<<16)
-#define TCIC_ADDR_INDREG 0x08000000
-#define TCIC_ADDR_IO 0x04000000
-#define TCIC_ADDR_MASK 0x03ffffff
-
-/* Flags for TCIC_SCTRL */
-#define TCIC_SCTRL_ENA 0x01
-#define TCIC_SCTRL_INCMODE 0x18
-#define TCIC_SCTRL_INCMODE_HOLD 0x00
-#define TCIC_SCTRL_INCMODE_WORD 0x08
-#define TCIC_SCTRL_INCMODE_REG 0x10
-#define TCIC_SCTRL_INCMODE_AUTO 0x18
-#define TCIC_SCTRL_EDCSUM 0x20
-#define TCIC_SCTRL_RESET 0x80
-
-/* Flags for TCIC_SSTAT */
-#define TCIC_SSTAT_6US 0x01
-#define TCIC_SSTAT_10US 0x02
-#define TCIC_SSTAT_PROGTIME 0x04
-#define TCIC_SSTAT_LBAT1 0x08
-#define TCIC_SSTAT_LBAT2 0x10
-#define TCIC_SSTAT_RDY 0x20 /* Inverted */
-#define TCIC_SSTAT_WP 0x40
-#define TCIC_SSTAT_CD 0x80 /* Card detect */
-
-/* Flags for TCIC_MODE */
-#define TCIC_MODE_PGMMASK 0x1f
-#define TCIC_MODE_NORMAL 0x00
-#define TCIC_MODE_PGMWR 0x01
-#define TCIC_MODE_PGMRD 0x02
-#define TCIC_MODE_PGMCE 0x04
-#define TCIC_MODE_PGMDBW 0x08
-#define TCIC_MODE_PGMWORD 0x10
-#define TCIC_MODE_AUXSEL_MASK 0xe0
-
-/* Registers accessed through TCIC_AUX, by setting TCIC_MODE */
-#define TCIC_AUX_TCTL (0<<5)
-#define TCIC_AUX_PCTL (1<<5)
-#define TCIC_AUX_WCTL (2<<5)
-#define TCIC_AUX_EXTERN (3<<5)
-#define TCIC_AUX_PDATA (4<<5)
-#define TCIC_AUX_SYSCFG (5<<5)
-#define TCIC_AUX_ILOCK (6<<5)
-#define TCIC_AUX_TEST (7<<5)
-
-/* Flags for TCIC_PWR */
-#define TCIC_PWR_VCC(sock) (0x01<<(sock))
-#define TCIC_PWR_VCC_MASK 0x03
-#define TCIC_PWR_VPP(sock) (0x08<<(sock))
-#define TCIC_PWR_VPP_MASK 0x18
-#define TCIC_PWR_CLIMENA 0x40
-#define TCIC_PWR_CLIMSTAT 0x80
-
-/* Flags for TCIC_ICSR */
-#define TCIC_ICSR_CLEAR 0x01
-#define TCIC_ICSR_SET 0x02
-#define TCIC_ICSR_JAM (TCIC_ICSR_CLEAR|TCIC_ICSR_SET)
-#define TCIC_ICSR_STOPCPU 0x04
-#define TCIC_ICSR_ILOCK 0x08
-#define TCIC_ICSR_PROGTIME 0x10
-#define TCIC_ICSR_ERR 0x20
-#define TCIC_ICSR_CDCHG 0x40
-#define TCIC_ICSR_IOCHK 0x80
-
-/* Flags for TCIC_IENA */
-#define TCIC_IENA_CFG_MASK 0x03
-#define TCIC_IENA_CFG_OFF 0x00 /* disabled */
-#define TCIC_IENA_CFG_OD 0x01 /* active low, open drain */
-#define TCIC_IENA_CFG_LOW 0x02 /* active low, totem pole */
-#define TCIC_IENA_CFG_HIGH 0x03 /* active high, totem pole */
-#define TCIC_IENA_ILOCK 0x08
-#define TCIC_IENA_PROGTIME 0x10
-#define TCIC_IENA_ERR 0x20 /* overcurrent or iochk */
-#define TCIC_IENA_CDCHG 0x40
-
-/* Flags for TCIC_AUX_WCTL */
-#define TCIC_WAIT_COUNT_MASK 0x001f
-#define TCIC_WAIT_ASYNC 0x0020
-#define TCIC_WAIT_SENSE 0x0040
-#define TCIC_WAIT_SRC 0x0080
-#define TCIC_WCTL_WR 0x0100
-#define TCIC_WCTL_RD 0x0200
-#define TCIC_WCTL_CE 0x0400
-#define TCIC_WCTL_LLBAT1 0x0800
-#define TCIC_WCTL_LLBAT2 0x1000
-#define TCIC_WCTL_LRDY 0x2000
-#define TCIC_WCTL_LWP 0x4000
-#define TCIC_WCTL_LCD 0x8000
-
-/* Flags for TCIC_AUX_SYSCFG */
-#define TCIC_SYSCFG_IRQ_MASK 0x000f
-#define TCIC_SYSCFG_MCSFULL 0x0010
-#define TCIC_SYSCFG_IO1723 0x0020
-#define TCIC_SYSCFG_MCSXB 0x0040
-#define TCIC_SYSCFG_ICSXB 0x0080
-#define TCIC_SYSCFG_NOPDN 0x0100
-#define TCIC_SYSCFG_MPSEL_SHFT 9
-#define TCIC_SYSCFG_MPSEL_MASK 0x0e00
-#define TCIC_SYSCFG_MPSENSE 0x2000
-#define TCIC_SYSCFG_AUTOBUSY 0x4000
-#define TCIC_SYSCFG_ACC 0x8000
-
-#define TCIC_ILOCK_OUT 0x01
-#define TCIC_ILOCK_SENSE 0x02
-#define TCIC_ILOCK_CRESET 0x04
-#define TCIC_ILOCK_CRESENA 0x08
-#define TCIC_ILOCK_CWAIT 0x10
-#define TCIC_ILOCK_CWAITSNS 0x20
-#define TCIC_ILOCK_HOLD_MASK 0xc0
-#define TCIC_ILOCK_HOLD_CCLK 0xc0
-
-#define TCIC_ILOCKTEST_ID_SH 8
-#define TCIC_ILOCKTEST_ID_MASK 0x7f00
-#define TCIC_ILOCKTEST_MCIC_1 0x8000
-
-#define TCIC_ID_DB86082 0x02
-#define TCIC_ID_DB86082A 0x03
-#define TCIC_ID_DB86084 0x04
-#define TCIC_ID_DB86084A 0x08
-#define TCIC_ID_DB86072 0x15
-#define TCIC_ID_DB86184 0x14
-#define TCIC_ID_DB86082B 0x17
-
-#define TCIC_TEST_DIAG 0x8000
-
-/*
- * Indirectly addressed registers
- */
-
-#define TCIC_SCF1(sock) ((sock)<<3)
-#define TCIC_SCF2(sock) (((sock)<<3)+2)
-
-/* Flags for SCF1 */
-#define TCIC_SCF1_IRQ_MASK 0x000f
-#define TCIC_SCF1_IRQ_OFF 0x0000
-#define TCIC_SCF1_IRQOC 0x0010
-#define TCIC_SCF1_PCVT 0x0020
-#define TCIC_SCF1_IRDY 0x0040
-#define TCIC_SCF1_ATA 0x0080
-#define TCIC_SCF1_DMA_SHIFT 8
-#define TCIC_SCF1_DMA_MASK 0x0700
-#define TCIC_SCF1_DMA_OFF 0
-#define TCIC_SCF1_DREQ2 2
-#define TCIC_SCF1_IOSTS 0x0800
-#define TCIC_SCF1_SPKR 0x1000
-#define TCIC_SCF1_FINPACK 0x2000
-#define TCIC_SCF1_DELWR 0x4000
-#define TCIC_SCF1_HD7IDE 0x8000
-
-/* Flags for SCF2 */
-#define TCIC_SCF2_RI 0x0001
-#define TCIC_SCF2_IDBR 0x0002
-#define TCIC_SCF2_MDBR 0x0004
-#define TCIC_SCF2_MLBAT1 0x0008
-#define TCIC_SCF2_MLBAT2 0x0010
-#define TCIC_SCF2_MRDY 0x0020
-#define TCIC_SCF2_MWP 0x0040
-#define TCIC_SCF2_MCD 0x0080
-#define TCIC_SCF2_MALL 0x00f8
-
-/* Indirect addresses for memory window registers */
-#define TCIC_MWIN(sock,map) (0x100+(((map)+((sock)<<2))<<3))
-#define TCIC_MBASE_X 2
-#define TCIC_MMAP_X 4
-#define TCIC_MCTL_X 6
-
-#define TCIC_MBASE_4K_BIT 0x4000
-#define TCIC_MBASE_HA_SHFT 12
-#define TCIC_MBASE_HA_MASK 0x0fff
-
-#define TCIC_MMAP_REG 0x8000
-#define TCIC_MMAP_CA_SHFT 12
-#define TCIC_MMAP_CA_MASK 0x3fff
-
-#define TCIC_MCTL_WSCNT_MASK 0x001f
-#define TCIC_MCTL_WCLK 0x0020
-#define TCIC_MCTL_WCLK_CCLK 0x0000
-#define TCIC_MCTL_WCLK_BCLK 0x0020
-#define TCIC_MCTL_QUIET 0x0040
-#define TCIC_MCTL_WP 0x0080
-#define TCIC_MCTL_ACC 0x0100
-#define TCIC_MCTL_KE 0x0200
-#define TCIC_MCTL_EDC 0x0400
-#define TCIC_MCTL_B8 0x0800
-#define TCIC_MCTL_SS_SHFT TCIC_SS_SHFT
-#define TCIC_MCTL_SS_MASK TCIC_SS_MASK
-#define TCIC_MCTL_ENA 0x8000
-
-/* Indirect addresses for I/O window registers */
-#define TCIC_IWIN(sock,map) (0x200+(((map)+((sock)<<1))<<2))
-#define TCIC_IBASE_X 0
-#define TCIC_ICTL_X 2
-
-#define TCIC_ICTL_WSCNT_MASK TCIC_MCTL_WSCNT_MASK
-#define TCIC_ICTL_QUIET TCIC_MCTL_QUIET
-#define TCIC_ICTL_1K 0x0080
-#define TCIC_ICTL_PASS16 0x0100
-#define TCIC_ICTL_ACC TCIC_MCTL_ACC
-#define TCIC_ICTL_TINY 0x0200
-#define TCIC_ICTL_B16 0x0400
-#define TCIC_ICTL_B8 TCIC_MCTL_B8
-#define TCIC_ICTL_BW_MASK (TCIC_ICTL_B16|TCIC_ICTL_B8)
-#define TCIC_ICTL_BW_DYN 0
-#define TCIC_ICTL_BW_8 TCIC_ICTL_B8
-#define TCIC_ICTL_BW_16 TCIC_ICTL_B16
-#define TCIC_ICTL_BW_ATA (TCIC_ICTL_B16|TCIC_ICTL_B8)
-#define TCIC_ICTL_SS_SHFT TCIC_SS_SHFT
-#define TCIC_ICTL_SS_MASK TCIC_SS_MASK
-#define TCIC_ICTL_ENA TCIC_MCTL_ENA
-
-#endif /* _LINUX_TCIC_H */
diff --git a/mdk-stage1/pcmcia_/version.h b/mdk-stage1/pcmcia_/version.h
deleted file mode 100644
index 3be8f28bc..000000000
--- a/mdk-stage1/pcmcia_/version.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* version.h 1.101 2001/08/09 12:29:14 (David Hinds) */
-
-#define CS_RELEASE "3.1.29"
-#define CS_RELEASE_CODE 0x311d
diff --git a/mdk-stage1/pcmcia_/vg468.h b/mdk-stage1/pcmcia_/vg468.h
deleted file mode 100644
index 23890cd07..000000000
--- a/mdk-stage1/pcmcia_/vg468.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * vg468.h 1.14 2001/08/24 12:15:34
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#ifndef _LINUX_VG468_H
-#define _LINUX_VG468_H
-
-/* Special bit in I365_IDENT used for Vadem chip detection */
-#define I365_IDENT_VADEM 0x08
-
-/* Special definitions in I365_POWER */
-#define VG468_VPP2_MASK 0x0c
-#define VG468_VPP2_5V 0x04
-#define VG468_VPP2_12V 0x08
-
-/* Unique Vadem registers */
-#define VG469_VSENSE 0x1f /* Card voltage sense */
-#define VG469_VSELECT 0x2f /* Card voltage select */
-#define VG468_CTL 0x38 /* Control register */
-#define VG468_TIMER 0x39 /* Timer control */
-#define VG468_MISC 0x3a /* Miscellaneous */
-#define VG468_GPIO_CFG 0x3b /* GPIO configuration */
-#define VG469_EXT_MODE 0x3c /* Extended mode register */
-#define VG468_SELECT 0x3d /* Programmable chip select */
-#define VG468_SELECT_CFG 0x3e /* Chip select configuration */
-#define VG468_ATA 0x3f /* ATA control */
-
-/* Flags for VG469_VSENSE */
-#define VG469_VSENSE_A_VS1 0x01
-#define VG469_VSENSE_A_VS2 0x02
-#define VG469_VSENSE_B_VS1 0x04
-#define VG469_VSENSE_B_VS2 0x08
-
-/* Flags for VG469_VSELECT */
-#define VG469_VSEL_VCC 0x03
-#define VG469_VSEL_5V 0x00
-#define VG469_VSEL_3V 0x03
-#define VG469_VSEL_MAX 0x0c
-#define VG469_VSEL_EXT_STAT 0x10
-#define VG469_VSEL_EXT_BUS 0x20
-#define VG469_VSEL_MIXED 0x40
-#define VG469_VSEL_ISA 0x80
-
-/* Flags for VG468_CTL */
-#define VG468_CTL_SLOW 0x01 /* 600ns memory timing */
-#define VG468_CTL_ASYNC 0x02 /* Asynchronous bus clocking */
-#define VG468_CTL_TSSI 0x08 /* Tri-state some outputs */
-#define VG468_CTL_DELAY 0x10 /* Card detect debounce */
-#define VG468_CTL_INPACK 0x20 /* Obey INPACK signal? */
-#define VG468_CTL_POLARITY 0x40 /* VCCEN polarity */
-#define VG468_CTL_COMPAT 0x80 /* Compatibility stuff */
-
-#define VG469_CTL_WS_COMPAT 0x04 /* Wait state compatibility */
-#define VG469_CTL_STRETCH 0x10 /* LED stretch */
-
-/* Flags for VG468_TIMER */
-#define VG468_TIMER_ZEROPWR 0x10 /* Zero power control */
-#define VG468_TIMER_SIGEN 0x20 /* Power up */
-#define VG468_TIMER_STATUS 0x40 /* Activity timer status */
-#define VG468_TIMER_RES 0x80 /* Timer resolution */
-#define VG468_TIMER_MASK 0x0f /* Activity timer timeout */
-
-/* Flags for VG468_MISC */
-#define VG468_MISC_GPIO 0x04 /* General-purpose IO */
-#define VG468_MISC_DMAWSB 0x08 /* DMA wait state control */
-#define VG469_MISC_LEDENA 0x10 /* LED enable */
-#define VG468_MISC_VADEMREV 0x40 /* Vadem revision control */
-#define VG468_MISC_UNLOCK 0x80 /* Unique register lock */
-
-/* Flags for VG469_EXT_MODE_A */
-#define VG469_MODE_VPPST 0x03 /* Vpp steering control */
-#define VG469_MODE_INT_SENSE 0x04 /* Internal voltage sense */
-#define VG469_MODE_CABLE 0x08
-#define VG469_MODE_COMPAT 0x10 /* i82365sl B or DF step */
-#define VG469_MODE_TEST 0x20
-#define VG469_MODE_RIO 0x40 /* Steer RIO to INTR? */
-
-/* Flags for VG469_EXT_MODE_B */
-#define VG469_MODE_B_3V 0x01 /* 3.3v for socket B */
-
-#endif /* _LINUX_VG468_H */
diff --git a/mdk-stage1/pcmcia_/yacc_config.c b/mdk-stage1/pcmcia_/yacc_config.c
deleted file mode 100644
index 2262d52f3..000000000
--- a/mdk-stage1/pcmcia_/yacc_config.c
+++ /dev/null
@@ -1,1015 +0,0 @@
-#define YYBYACC 1
-#define YYMAJOR 1
-#define YYMINOR 9
-#define yyclearin (yychar=(-1))
-#define yyerrok (yyerrflag=0)
-#define YYRECOVERING (yyerrflag!=0)
-#define YYPREFIX "yy"
-#line 2 "yacc_config.y"
-/*
- * yacc_config.y 1.53 2001/08/24 12:21:34
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
- *
- * The initial developer of the original code is David A. Hinds
- * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
- *
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in
- * which case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
- */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
-#include <sys/types.h>
-
-#include <pcmcia_/cs_types.h>
-#include <pcmcia_/cs.h>
-#include <pcmcia_/cistpl.h>
-#include <pcmcia_/ds.h>
-
-#include "cardmgr.h"
-
-/* If bison: generate nicer error messages */
-#define YYERROR_VERBOSE 1
-
-/* from lex_config, for nice error messages */
-extern char *current_file;
-extern int current_lineno;
-
-void yyerror(char *msg, ...);
-
-static int add_binding(card_info_t *card, char *name, int fn);
-static int add_module(device_info_t *card, char *name);
-
-#line 65 "yacc_config.y"
-typedef union {
- char *str;
- unsigned long num;
- struct device_info_t *device;
- struct card_info_t *card;
- struct mtd_ident_t *mtd;
- struct adjust_list_t *adjust;
-} YYSTYPE;
-#line 77 "y.tab.c"
-#define DEVICE 257
-#define CARD 258
-#define ANONYMOUS 259
-#define TUPLE 260
-#define MANFID 261
-#define VERSION 262
-#define FUNCTION 263
-#define PCI 264
-#define BIND 265
-#define CIS 266
-#define TO 267
-#define NEEDS_MTD 268
-#define MODULE 269
-#define OPTS 270
-#define CLASS 271
-#define REGION 272
-#define JEDEC 273
-#define DTYPE 274
-#define DEFAULT 275
-#define MTD 276
-#define INCLUDE 277
-#define EXCLUDE 278
-#define RESERVE 279
-#define IRQ_NO 280
-#define PORT 281
-#define MEMORY 282
-#define STRING 283
-#define NUMBER 284
-#define YYERRCODE 256
-short yylhs[] = { -1,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 2, 2, 2, 3, 3, 3, 3, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 8, 9,
- 10, 11, 12, 12, 13, 15, 14, 14, 14, 14,
- 4, 21, 5, 5, 5, 6, 16, 16, 16, 16,
- 18, 17, 19, 20, 20, 22,
-};
-short yylen[] = { 2,
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 3, 2, 4, 4, 2, 1, 1, 1, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 7,
- 5, 5, 3, 3, 3, 3, 3, 5, 3, 5,
- 2, 4, 3, 3, 3, 3, 2, 1, 1, 1,
- 3, 4, 2, 3, 3, 4,
-};
-short yydefred[] = { 1,
- 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 17, 0, 19, 0, 21, 22, 23, 24,
- 0, 26, 0, 28, 0, 49, 48, 50, 0, 6,
- 7, 16, 20, 0, 47, 0, 0, 0, 0, 9,
- 10, 11, 0, 41, 0, 0, 0, 0, 29, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 53, 0, 0, 0, 0, 13, 0, 0, 12, 43,
- 46, 44, 45, 0, 0, 33, 35, 0, 0, 36,
- 34, 0, 0, 51, 54, 55, 42, 56, 0, 0,
- 0, 0, 0, 0, 0, 52, 14, 15, 0, 31,
- 32, 38, 40, 0, 30,
-};
-short yydgoto[] = { 1,
- 11, 40, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31,
-};
-short yysindex[] = { 0,
- -250, 0, -279, -278, -274, -265, -259, -242, -242, -242,
- -10, -248, 0, -44, 0, -249, 0, 0, 0, 0,
- -9, 0, -3, 0, -243, 0, 0, 0, -233, 0,
- 0, 0, 0, -228, 0, -227, -240, -238, -237, 0,
- 0, 0, -242, 0, -235, -232, -231, -230, 0, -234,
- -229, -226, -225, -224, -222, -221, -220, -219, -218, -217,
- 0, -215, -213, -212, -211, 0, 9, 11, 0, 0,
- 0, 0, 0, 14, 21, 0, 0, 30, -192, 0,
- 0, -191, -207, 0, 0, 0, 0, 0, -206, -205,
- -204, -203, -202, -201, -200, 0, 0, 0, 41, 0,
- 0, 0, 0, -197, 0,
-};
-short yyrindex[] = { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 107, 149, 0, 90, 0, 124, 0, 0, 0, 0,
- 49, 0, 73, 0, 0, 0, 0, 0, 141, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
- 0, 25, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
-};
-short yygindex[] = { 0,
- 0, -7, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0,
-};
-#define YYTABLESIZE 428
-short yytable[] = { 48,
- 37, 41, 42, 32, 33, 2, 3, 4, 34, 49,
- 50, 51, 52, 53, 54, 55, 56, 35, 5, 44,
- 45, 6, 46, 36, 39, 7, 8, 9, 10, 59,
- 60, 61, 62, 43, 57, 69, 63, 37, 38, 39,
- 58, 64, 65, 66, 37, 67, 68, 70, 25, 74,
- 71, 72, 73, 89, 75, 90, 76, 91, 77, 78,
- 79, 80, 81, 82, 92, 83, 84, 85, 39, 86,
- 87, 88, 27, 93, 94, 95, 96, 97, 98, 99,
- 100, 101, 102, 103, 104, 105, 0, 0, 0, 18,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 5, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, 0, 0, 0, 0, 0, 0, 0, 3, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 47, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 37, 37, 37, 37,
- 37, 37, 37, 37, 37, 37, 37, 0, 0, 37,
- 0, 0, 37, 0, 0, 0, 37, 37, 37, 37,
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 0, 0, 39, 0, 0, 39, 0, 0, 0,
- 39, 39, 39, 39, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 0, 0, 25, 0, 0,
- 25, 0, 0, 0, 25, 25, 25, 25, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 0,
- 0, 27, 0, 0, 27, 18, 18, 18, 27, 27,
- 27, 27, 0, 0, 0, 0, 0, 18, 18, 0,
- 18, 18, 2, 2, 2, 18, 18, 18, 18, 0,
- 0, 0, 0, 0, 0, 2, 0, 0, 2, 5,
- 5, 5, 2, 2, 2, 2, 0, 0, 0, 0,
- 0, 0, 5, 0, 0, 5, 4, 4, 4, 5,
- 5, 5, 5, 0, 3, 3, 3, 0, 0, 4,
- 0, 0, 4, 0, 0, 0, 4, 4, 4, 4,
- 3, 0, 0, 0, 3, 3, 3, 3,
-};
-short yycheck[] = { 44,
- 0, 9, 10, 283, 283, 256, 257, 258, 283, 259,
- 260, 261, 262, 263, 264, 265, 266, 283, 269, 268,
- 269, 272, 271, 283, 0, 276, 277, 278, 279, 273,
- 274, 275, 276, 44, 44, 43, 270, 280, 281, 282,
- 44, 270, 270, 284, 44, 284, 284, 283, 0, 284,
- 283, 283, 283, 45, 284, 45, 283, 44, 284, 284,
- 283, 283, 283, 283, 44, 284, 284, 283, 44, 283,
- 283, 283, 0, 44, 267, 267, 284, 284, 284, 284,
- 284, 284, 284, 284, 44, 283, -1, -1, -1, 0,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 0, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 0, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, -1, -1, -1, -1, -1, -1, -1, 0, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 270, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 256, 257, 258, 259,
- 260, 261, 262, 263, 264, 265, 266, -1, -1, 269,
- -1, -1, 272, -1, -1, -1, 276, 277, 278, 279,
- 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
- 266, -1, -1, 269, -1, -1, 272, -1, -1, -1,
- 276, 277, 278, 279, 256, 257, 258, 259, 260, 261,
- 262, 263, 264, 265, 266, -1, -1, 269, -1, -1,
- 272, -1, -1, -1, 276, 277, 278, 279, 256, 257,
- 258, 259, 260, 261, 262, 263, 264, 265, 266, -1,
- -1, 269, -1, -1, 272, 256, 257, 258, 276, 277,
- 278, 279, -1, -1, -1, -1, -1, 268, 269, -1,
- 271, 272, 256, 257, 258, 276, 277, 278, 279, -1,
- -1, -1, -1, -1, -1, 269, -1, -1, 272, 256,
- 257, 258, 276, 277, 278, 279, -1, -1, -1, -1,
- -1, -1, 269, -1, -1, 272, 256, 257, 258, 276,
- 277, 278, 279, -1, 256, 257, 258, -1, -1, 269,
- -1, -1, 272, -1, -1, -1, 276, 277, 278, 279,
- 272, -1, -1, -1, 276, 277, 278, 279,
-};
-#define YYFINAL 1
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
-#define YYMAXTOKEN 284
-#if YYDEBUG
-char *yyname[] = {
-"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,"','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"DEVICE","CARD",
-"ANONYMOUS","TUPLE","MANFID","VERSION","FUNCTION","PCI","BIND","CIS","TO",
-"NEEDS_MTD","MODULE","OPTS","CLASS","REGION","JEDEC","DTYPE","DEFAULT","MTD",
-"INCLUDE","EXCLUDE","RESERVE","IRQ_NO","PORT","MEMORY","STRING","NUMBER",
-};
-char *yyrule[] = {
-"$accept : list",
-"list :",
-"list : list adjust",
-"list : list device",
-"list : list mtd",
-"list : list card",
-"list : list opts",
-"list : list mtd_opts",
-"list : list error",
-"adjust : INCLUDE resource",
-"adjust : EXCLUDE resource",
-"adjust : RESERVE resource",
-"adjust : adjust ',' resource",
-"resource : IRQ_NO NUMBER",
-"resource : PORT NUMBER '-' NUMBER",
-"resource : MEMORY NUMBER '-' NUMBER",
-"device : DEVICE STRING",
-"device : needs_mtd",
-"device : module",
-"device : class",
-"card : CARD STRING",
-"card : anonymous",
-"card : tuple",
-"card : manfid",
-"card : pci",
-"card : version",
-"card : function",
-"card : bind",
-"card : cis",
-"anonymous : card ANONYMOUS",
-"tuple : card TUPLE NUMBER ',' NUMBER ',' STRING",
-"manfid : card MANFID NUMBER ',' NUMBER",
-"pci : card PCI NUMBER ',' NUMBER",
-"version : card VERSION STRING",
-"version : version ',' STRING",
-"function : card FUNCTION NUMBER",
-"cis : card CIS STRING",
-"bind : card BIND STRING",
-"bind : card BIND STRING TO NUMBER",
-"bind : bind ',' STRING",
-"bind : bind ',' STRING TO NUMBER",
-"needs_mtd : device NEEDS_MTD",
-"opts : MODULE STRING OPTS STRING",
-"module : device MODULE STRING",
-"module : module OPTS STRING",
-"module : module ',' STRING",
-"class : device CLASS STRING",
-"region : REGION STRING",
-"region : dtype",
-"region : jedec",
-"region : default",
-"dtype : region DTYPE NUMBER",
-"jedec : region JEDEC NUMBER NUMBER",
-"default : region DEFAULT",
-"mtd : region MTD STRING",
-"mtd : mtd OPTS STRING",
-"mtd_opts : MTD STRING OPTS STRING",
-};
-#endif
-#ifdef YYSTACKSIZE
-#undef YYMAXDEPTH
-#define YYMAXDEPTH YYSTACKSIZE
-#else
-#ifdef YYMAXDEPTH
-#define YYSTACKSIZE YYMAXDEPTH
-#else
-#define YYSTACKSIZE 500
-#define YYMAXDEPTH 500
-#endif
-#endif
-int yydebug;
-int yynerrs;
-int yyerrflag;
-int yychar;
-short *yyssp;
-YYSTYPE *yyvsp;
-YYSTYPE yyval;
-YYSTYPE yylval;
-short yyss[YYSTACKSIZE];
-YYSTYPE yyvs[YYSTACKSIZE];
-#define yystacksize YYSTACKSIZE
-#line 468 "yacc_config.y"
-void yyerror(char *msg, ...)
-{
- va_list ap;
- char str[256];
-
- va_start(ap, msg);
- sprintf(str, "config error, file '%s' line %d: ",
- current_file, current_lineno);
- vsprintf(str+strlen(str), msg, ap);
-#if YYDEBUG
- fprintf(stderr, "%s\n", str);
-#else
- syslog(LOG_ERR, "%s", str);
-#endif
- va_end(ap);
-}
-
-static int add_binding(card_info_t *card, char *name, int fn)
-{
- device_info_t *dev = root_device;
- if (card->bindings == MAX_BINDINGS) {
- yyerror("too many bindings\n");
- return -1;
- }
- for (; dev; dev = dev->next)
- if (strcmp((char *)dev->dev_info, name) == 0) break;
- if (dev == NULL) {
- yyerror("unknown device: %s", name);
- return -1;
- }
- card->device[card->bindings] = dev;
- card->dev_fn[card->bindings] = fn;
- card->bindings++;
- free(name);
- return 0;
-}
-
-static int add_module(device_info_t *dev, char *name)
-{
- if (dev->modules == MAX_MODULES) {
- yyerror("too many modules");
- return -1;
- }
- dev->module[dev->modules] = name;
- dev->opts[dev->modules] = NULL;
- dev->modules++;
- return 0;
-}
-
-#if YYDEBUG
-adjust_list_t *root_adjust = NULL;
-device_info_t *root_device = NULL;
-card_info_t *root_card = NULL, *blank_card = NULL, *root_func = NULL;
-mtd_ident_t *root_mtd = NULL, *default_mtd = NULL;
-
-void main(int argc, char *argv[])
-{
- yydebug = 1;
- if (argc > 1)
- parse_configfile(argv[1]);
-}
-#endif
-#line 426 "y.tab.c"
-#define YYABORT goto yyabort
-#define YYREJECT goto yyabort
-#define YYACCEPT goto yyaccept
-#define YYERROR goto yyerrlab
-int yylex(void);
-int
-yyparse()
-{
- register int yym, yyn, yystate;
-#if YYDEBUG
- register char *yys;
- extern char *getenv();
-
- if (yys = getenv("YYDEBUG"))
- {
- yyn = *yys;
- if (yyn >= '0' && yyn <= '9')
- yydebug = yyn - '0';
- }
-#endif
-
- yynerrs = 0;
- yyerrflag = 0;
- yychar = (-1);
-
- yyssp = yyss;
- yyvsp = yyvs;
- *yyssp = yystate = 0;
-
-yyloop:
- if ((yyn = yydefred[yystate])) goto yyreduce;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, shifting to state %d\n",
- YYPREFIX, yystate, yytable[yyn]);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- yychar = (-1);
- if (yyerrflag > 0) --yyerrflag;
- goto yyloop;
- }
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- yyn = yytable[yyn];
- goto yyreduce;
- }
- if (yyerrflag) goto yyinrecovery;
- yyerror("syntax error");
-#ifdef lint
- goto yyerrlab;
-#endif
-yyerrlab:
- ++yynerrs;
-yyinrecovery:
- if (yyerrflag < 3)
- {
- yyerrflag = 3;
- for (;;)
- {
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, error recovery shifting\
- to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- goto yyloop;
- }
- else
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: error recovery discarding state %d\n",
- YYPREFIX, *yyssp);
-#endif
- if (yyssp <= yyss) goto yyabort;
- --yyssp;
- --yyvsp;
- }
- }
- }
- else
- {
- if (yychar == 0) goto yyabort;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- yychar = (-1);
- goto yyloop;
- }
-yyreduce:
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, reducing by rule %d (%s)\n",
- YYPREFIX, yystate, yyn, yyrule[yyn]);
-#endif
- yym = yylen[yyn];
- yyval = yyvsp[1-yym];
- switch (yyn)
- {
-case 2:
-#line 84 "yacc_config.y"
-{
- adjust_list_t **tail = &root_adjust;
- while (*tail != NULL) tail = &(*tail)->next;
- *tail = yyvsp[0].adjust;
- }
-break;
-case 3:
-#line 90 "yacc_config.y"
-{
- yyvsp[0].device->next = root_device;
- root_device = yyvsp[0].device;
- }
-break;
-case 4:
-#line 95 "yacc_config.y"
-{
- if (yyvsp[0].mtd->mtd_type == 0) {
- yyerror("no ID method for this card");
- YYERROR;
- }
- if (yyvsp[0].mtd->module == NULL) {
- yyerror("no MTD module specified");
- YYERROR;
- }
- yyvsp[0].mtd->next = root_mtd;
- root_mtd = yyvsp[0].mtd;
- }
-break;
-case 5:
-#line 108 "yacc_config.y"
-{
- if (yyvsp[0].card->ident_type == 0) {
- yyerror("no ID method for this card");
- YYERROR;
- }
- if (yyvsp[0].card->bindings == 0) {
- yyerror("no function bindings");
- YYERROR;
- }
- if (yyvsp[0].card->ident_type == FUNC_IDENT) {
- yyvsp[0].card->next = root_func;
- root_func = yyvsp[0].card;
- } else {
- yyvsp[0].card->next = root_card;
- root_card = yyvsp[0].card;
- }
- }
-break;
-case 9:
-#line 131 "yacc_config.y"
-{
- yyvsp[0].adjust->adj.Action = ADD_MANAGED_RESOURCE;
- yyval.adjust = yyvsp[0].adjust;
- }
-break;
-case 10:
-#line 136 "yacc_config.y"
-{
- yyvsp[0].adjust->adj.Action = REMOVE_MANAGED_RESOURCE;
- yyval.adjust = yyvsp[0].adjust;
- }
-break;
-case 11:
-#line 141 "yacc_config.y"
-{
- yyvsp[0].adjust->adj.Action = ADD_MANAGED_RESOURCE;
- yyvsp[0].adjust->adj.Attributes |= RES_RESERVED;
- yyval.adjust = yyvsp[0].adjust;
- }
-break;
-case 12:
-#line 147 "yacc_config.y"
-{
- yyvsp[0].adjust->adj.Action = yyvsp[-2].adjust->adj.Action;
- yyvsp[0].adjust->adj.Attributes = yyvsp[-2].adjust->adj.Attributes;
- yyvsp[0].adjust->next = yyvsp[-2].adjust;
- yyval.adjust = yyvsp[0].adjust;
- }
-break;
-case 13:
-#line 156 "yacc_config.y"
-{
- yyval.adjust = calloc(sizeof(adjust_list_t), 1);
- yyval.adjust->adj.Resource = RES_IRQ;
- yyval.adjust->adj.resource.irq.IRQ = yyvsp[0].num;
- }
-break;
-case 14:
-#line 162 "yacc_config.y"
-{
- if ((yyvsp[0].num < yyvsp[-2].num) || (yyvsp[0].num > 0xffff)) {
- yyerror("invalid port range");
- YYERROR;
- }
- yyval.adjust = calloc(sizeof(adjust_list_t), 1);
- yyval.adjust->adj.Resource = RES_IO_RANGE;
- yyval.adjust->adj.resource.io.BasePort = yyvsp[-2].num;
- yyval.adjust->adj.resource.io.NumPorts = yyvsp[0].num - yyvsp[-2].num + 1;
- }
-break;
-case 15:
-#line 173 "yacc_config.y"
-{
- if (yyvsp[0].num < yyvsp[-2].num) {
- yyerror("invalid address range");
- YYERROR;
- }
- yyval.adjust = calloc(sizeof(adjust_list_t), 1);
- yyval.adjust->adj.Resource = RES_MEMORY_RANGE;
- yyval.adjust->adj.resource.memory.Base = yyvsp[-2].num;
- yyval.adjust->adj.resource.memory.Size = yyvsp[0].num - yyvsp[-2].num + 1;
- }
-break;
-case 16:
-#line 186 "yacc_config.y"
-{
- yyval.device = calloc(sizeof(device_info_t), 1);
- yyval.device->refs = 1;
- strcpy(yyval.device->dev_info, yyvsp[0].str);
- free(yyvsp[0].str);
- }
-break;
-case 20:
-#line 198 "yacc_config.y"
-{
- yyval.card = calloc(sizeof(card_info_t), 1);
- yyval.card->refs = 1;
- yyval.card->name = yyvsp[0].str;
- }
-break;
-case 29:
-#line 214 "yacc_config.y"
-{
- if (yyvsp[-1].card->ident_type != 0) {
- yyerror("ID method already defined");
- YYERROR;
- }
- if (blank_card) {
- yyerror("Anonymous card already defined");
- YYERROR;
- }
- yyvsp[-1].card->ident_type = BLANK_IDENT;
- blank_card = yyvsp[-1].card;
- }
-break;
-case 30:
-#line 229 "yacc_config.y"
-{
- if (yyvsp[-6].card->ident_type != 0) {
- yyerror("ID method already defined");
- YYERROR;
- }
- yyvsp[-6].card->ident_type = TUPLE_IDENT;
- yyvsp[-6].card->id.tuple.code = yyvsp[-4].num;
- yyvsp[-6].card->id.tuple.ofs = yyvsp[-2].num;
- yyvsp[-6].card->id.tuple.info = yyvsp[0].str;
- }
-break;
-case 31:
-#line 242 "yacc_config.y"
-{
- if (yyvsp[-4].card->ident_type & EXCL_IDENT) {
- yyerror("ID method already defined");
- YYERROR;
- }
- yyvsp[-4].card->ident_type = MANFID_IDENT;
- yyvsp[-4].card->manfid.manf = yyvsp[-2].num;
- yyvsp[-4].card->manfid.card = yyvsp[0].num;
- }
-break;
-case 32:
-#line 253 "yacc_config.y"
-{
- if (yyvsp[-4].card->ident_type != 0) {
- yyerror("ID method already defined");
- YYERROR;
- }
- yyvsp[-4].card->ident_type = PCI_IDENT;
- yyvsp[-4].card->manfid.manf = yyvsp[-2].num;
- yyvsp[-4].card->manfid.card = yyvsp[0].num;
- }
-break;
-case 33:
-#line 264 "yacc_config.y"
-{
- if (yyvsp[-2].card->ident_type & EXCL_IDENT) {
- yyerror("ID method already defined\n");
- YYERROR;
- }
- yyvsp[-2].card->ident_type = VERS_1_IDENT;
- yyvsp[-2].card->id.vers.ns = 1;
- yyvsp[-2].card->id.vers.pi[0] = yyvsp[0].str;
- }
-break;
-case 34:
-#line 274 "yacc_config.y"
-{
- if (yyvsp[-2].card->id.vers.ns == 4) {
- yyerror("too many version strings");
- YYERROR;
- }
- yyvsp[-2].card->id.vers.pi[yyvsp[-2].card->id.vers.ns] = yyvsp[0].str;
- yyvsp[-2].card->id.vers.ns++;
- }
-break;
-case 35:
-#line 285 "yacc_config.y"
-{
- if (yyvsp[-2].card->ident_type != 0) {
- yyerror("ID method already defined\n");
- YYERROR;
- }
- yyvsp[-2].card->ident_type = FUNC_IDENT;
- yyvsp[-2].card->id.func.funcid = yyvsp[0].num;
- }
-break;
-case 36:
-#line 296 "yacc_config.y"
-{ yyvsp[-2].card->cis_file = strdup(yyvsp[0].str); }
-break;
-case 37:
-#line 300 "yacc_config.y"
-{
- if (add_binding(yyvsp[-2].card, yyvsp[0].str, 0) != 0)
- YYERROR;
- }
-break;
-case 38:
-#line 305 "yacc_config.y"
-{
- if (add_binding(yyvsp[-4].card, yyvsp[-2].str, yyvsp[0].num) != 0)
- YYERROR;
- }
-break;
-case 39:
-#line 310 "yacc_config.y"
-{
- if (add_binding(yyvsp[-2].card, yyvsp[0].str, 0) != 0)
- YYERROR;
- }
-break;
-case 40:
-#line 315 "yacc_config.y"
-{
- if (add_binding(yyvsp[-4].card, yyvsp[-2].str, yyvsp[0].num) != 0)
- YYERROR;
- }
-break;
-case 41:
-#line 322 "yacc_config.y"
-{
- yyvsp[-1].device->needs_mtd = 1;
- }
-break;
-case 42:
-#line 328 "yacc_config.y"
-{
- device_info_t *d;
- int i, found = 0;
- for (d = root_device; d; d = d->next) {
- for (i = 0; i < d->modules; i++)
- if (strcmp(yyvsp[-2].str, d->module[i]) == 0) break;
- if (i < d->modules) {
- if (d->opts[i])
- free(d->opts[i]);
- d->opts[i] = strdup(yyvsp[0].str);
- found = 1;
- }
- }
- free(yyvsp[-2].str); free(yyvsp[0].str);
- if (!found) {
- yyerror("module name not found!");
- YYERROR;
- }
- }
-break;
-case 43:
-#line 350 "yacc_config.y"
-{
- if (add_module(yyvsp[-2].device, yyvsp[0].str) != 0)
- YYERROR;
- }
-break;
-case 44:
-#line 355 "yacc_config.y"
-{
- if (yyvsp[-2].device->opts[yyvsp[-2].device->modules-1] == NULL) {
- yyvsp[-2].device->opts[yyvsp[-2].device->modules-1] = yyvsp[0].str;
- } else {
- yyerror("too many options");
- YYERROR;
- }
- }
-break;
-case 45:
-#line 364 "yacc_config.y"
-{
- if (add_module(yyvsp[-2].device, yyvsp[0].str) != 0)
- YYERROR;
- }
-break;
-case 46:
-#line 371 "yacc_config.y"
-{
- if (yyvsp[-2].device->class != NULL) {
- yyerror("extra class string");
- YYERROR;
- }
- yyvsp[-2].device->class = yyvsp[0].str;
- }
-break;
-case 47:
-#line 381 "yacc_config.y"
-{
- yyval.mtd = calloc(sizeof(mtd_ident_t), 1);
- yyval.mtd->refs = 1;
- yyval.mtd->name = yyvsp[0].str;
- }
-break;
-case 51:
-#line 392 "yacc_config.y"
-{
- if (yyvsp[-2].mtd->mtd_type != 0) {
- yyerror("ID method already defined");
- YYERROR;
- }
- yyvsp[-2].mtd->mtd_type = DTYPE_MTD;
- yyvsp[-2].mtd->dtype = yyvsp[0].num;
- }
-break;
-case 52:
-#line 403 "yacc_config.y"
-{
- if (yyvsp[-3].mtd->mtd_type != 0) {
- yyerror("ID method already defined");
- YYERROR;
- }
- yyvsp[-3].mtd->mtd_type = JEDEC_MTD;
- yyvsp[-3].mtd->jedec_mfr = yyvsp[-1].num;
- yyvsp[-3].mtd->jedec_info = yyvsp[0].num;
- }
-break;
-case 53:
-#line 415 "yacc_config.y"
-{
- if (yyvsp[-1].mtd->mtd_type != 0) {
- yyerror("ID method already defined");
- YYERROR;
- }
- if (default_mtd) {
- yyerror("Default MTD already defined");
- YYERROR;
- }
- yyvsp[-1].mtd->mtd_type = DEFAULT_MTD;
- default_mtd = yyvsp[-1].mtd;
- }
-break;
-case 54:
-#line 430 "yacc_config.y"
-{
- if (yyvsp[-2].mtd->module != NULL) {
- yyerror("extra MTD entry");
- YYERROR;
- }
- yyvsp[-2].mtd->module = yyvsp[0].str;
- }
-break;
-case 55:
-#line 438 "yacc_config.y"
-{
- if (yyvsp[-2].mtd->opts == NULL) {
- yyvsp[-2].mtd->opts = yyvsp[0].str;
- } else {
- yyerror("too many options");
- YYERROR;
- }
- }
-break;
-case 56:
-#line 449 "yacc_config.y"
-{
- mtd_ident_t *m;
- int found = 0;
- for (m = root_mtd; m; m = m->next)
- if (strcmp(yyvsp[-2].str, m->module) == 0) break;
- if (m) {
- if (m->opts) free(m->opts);
- m->opts = strdup(yyvsp[0].str);
- found = 1;
- }
- free(yyvsp[-2].str); free(yyvsp[0].str);
- if (!found) {
- yyerror("MTD name not found!");
- YYERROR;
- }
- }
-break;
-#line 966 "y.tab.c"
- }
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state 0 to\
- state %d\n", YYPREFIX, YYFINAL);
-#endif
- yystate = YYFINAL;
- *++yyssp = YYFINAL;
- *++yyvsp = yyval;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, YYFINAL, yychar, yys);
- }
-#endif
- }
- if (yychar == 0) goto yyaccept;
- goto yyloop;
- }
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
- yystate = yytable[yyn];
- else
- yystate = yydgoto[yym];
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state %d \
-to state %d\n", YYPREFIX, *yyssp, yystate);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate;
- *++yyvsp = yyval;
- goto yyloop;
-yyoverflow:
- yyerror("yacc stack overflow");
-yyabort:
- return (1);
-yyaccept:
- return (0);
-}
diff --git a/mdk-stage1/pcmcia_/yacc_config.h b/mdk-stage1/pcmcia_/yacc_config.h
deleted file mode 100644
index f9b881def..000000000
--- a/mdk-stage1/pcmcia_/yacc_config.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#define DEVICE 257
-#define CARD 258
-#define ANONYMOUS 259
-#define TUPLE 260
-#define MANFID 261
-#define VERSION 262
-#define FUNCTION 263
-#define PCI 264
-#define BIND 265
-#define CIS 266
-#define TO 267
-#define NEEDS_MTD 268
-#define MODULE 269
-#define OPTS 270
-#define CLASS 271
-#define REGION 272
-#define JEDEC 273
-#define DTYPE 274
-#define DEFAULT 275
-#define MTD 276
-#define INCLUDE 277
-#define EXCLUDE 278
-#define RESERVE 279
-#define IRQ_NO 280
-#define PORT 281
-#define MEMORY 282
-#define STRING 283
-#define NUMBER 284
-typedef union {
- char *str;
- unsigned long num;
- struct device_info_t *device;
- struct card_info_t *card;
- struct mtd_ident_t *mtd;
- struct adjust_list_t *adjust;
-} YYSTYPE;
-extern YYSTYPE yylval;
diff --git a/mdk-stage1/ppp/.cvsignore b/mdk-stage1/ppp/.cvsignore
deleted file mode 100644
index c258b925d..000000000
--- a/mdk-stage1/ppp/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-pppd-bin
diff --git a/mdk-stage1/ppp/Changes-2.3 b/mdk-stage1/ppp/Changes-2.3
deleted file mode 100644
index f5c954b4b..000000000
--- a/mdk-stage1/ppp/Changes-2.3
+++ /dev/null
@@ -1,441 +0,0 @@
-What was new in ppp-2.3.11.
-***************************
-
-* Support for Solaris 8 has been added, including support for
- replumbing and IPV6.
-
-* The Solaris `snoop' utility should now work on ppp interfaces.
-
-* New hooks have been added - pap_logout_hook, ip_up_hook, and
- ip_down_hook.
-
-* A new `passprompt' plugin is included, thanks to Alan Curry, which
- makes it possible for pppd to call an external program to get the
- PAP password to send to the peer.
-
-* The error messages for the situation where authentication is
- required because the system has a default route have been improved.
-
-* There is a new connect_delay option which specifies how long pppd
- should pause after the connect script finishes. Previously this
- delay was fixed at 1 second. (This delay terminates as soon as pppd
- sees a valid PPP frame from the peer.)
-
-* The `hide-password' option is now the default, and there is a new
- `show-password' option to enable the printing of password strings in
- the debug output.
-
-* A fairly complete list of the names of PPP protocols has been added
- so that when pppd rejects a frame because its protocol is not
- supported, it can print the name of the unsupported protocol.
-
-* Synchronous serial lines are supported under Linux 2.3.x.
-
-* The bug where pppd would not recognize a modem hangup under Linux
- 2.3.x kernels has been fixed.
-
-
-What was new in ppp-2.3.10.
-***************************
-
-* Pppd now supports `plugins', which are pieces of code (packaged as
- shared libraries) which can be loaded into pppd at runtime and which
- can affect its behaviour. The intention is that plugins provide a
- way for people to customize the behaviour of pppd for their own
- needs without needing to change the base pppd source. I have added
- some hooks into pppd (places where pppd will call a function
- pointer, if non-zero, to replace some of pppd's code) and I will be
- receptive to suggestions about places to add more hooks. Plugins
- are supported under Linux and Solaris at present.
-
-* We have a new maintainer for the Solaris port, Adi Masputra of Sun
- Microsystems, and he has updated the Solaris port so that it should
- work on 64-bit machines under Solaris 7 and later.
-
-* Pppd now has an `allow-ip' option, which takes an argument which is
- an IP address (or subnet) which peers are permitted to use without
- authenticating themselves. The argument takes the same form as each
- element of the allowed IP address list in the secrets files. The
- allow-ip option is privileged and may be specified multiple times.
- Using the allow-ip option should be cleaner than putting a line like
- `"" * "" address' in /etc/ppp/pap-secrets.
-
-* Chat can now substitute environment variables into the script. This
- is enabled by the -E flag. (Thanks to Andreas Arens for the patch.)
-
-* If the PAP username and password from the peer contains unprintable
- characters, they will be translated to a printable form before
- looking in the pap-secrets file. Characters >= 0x80 are translated
- to a M- form, and characters from 0 to 0x1f (and 0x7f as well) are
- translated to a ^X form. If this change causes you grief, let me
- know what would be a better translation. It appears that some peers
- send nulls or other control characters in their usernames and
- passwords.
-
-* Pppd has new `ktune' and `noktune' options, which enable/disable
- it to change kernel settings as appropriate. This is only
- implemented under Linux, and requires the /proc filesystem to be
- mounted. Under Linux, with the ktune option, pppd will enable IP
- forwarding in the kernel if the proxyarp option is used, and will
- enable the dynamic IP address kernel option in demand mode if the
- local IP address changes.
-
-* Pppd no longer requires a remote address to be specified for demand
- dialling. If none is specified, it will use a default value of
- 10.112.112.112+unit_number. (It will not propose this default to
- the peer.)
-
-* The default holdoff is now 0 if no connect script is given.
-
-* The IPV6 code from Tommi Komulainen, which I unfortunately only
- partially merged in to ppp-2.3.9, has been fixed and updated.
-
-* The linux compilation glitches should be fixed now.
-
-
-What was new in ppp-2.3.9.
-**************************
-
-* Support for the new generic PPP layer under development for the
- Linux kernel.
-
-* You can now place extra options to apply to specific users at the
- end of the line with their password in the pap-secrets or
- chap-secrets file, separated from the IP address(es) with a "--"
- separator. These options are parsed after the peer is authenticated
- but before network protocol (IPCP, IPXCP) or CCP negotiation
- commences.
-
-* Pppd will apply the holdoff period if the link was terminated by the
- peer. It doesn't apply it if the link was terminated because the
- local pppd thought it was idle.
-
-* Synchronous support for Solaris has been added, thanks to John
- Morrison, and for FreeBSD, thanks to Paul Fulghum.
-
-* IPV6 support has been merged in, from Tommi Komulainen. At the
- moment it only supports Linux and it is not tested by me.
-
-* The `nodefaultip' option can be used in demand mode to say that pppd
- should not suggest its local IP address to the peer.
-
-* The `init' option has been added; this causes pppd to run a script
- to initialize the serial device (e.g. by sending an init string to
- the modem). Unlike the connect option, this can be used in a
- dial-in situation. (Thanks to Tobias Ringstrom.)
-
-* There is a new `logfile' option to send log messages to a file as
- well as syslog.
-
-* There is a new, privileged `linkname' option which sets a logical
- name for the link. Pppd will create a /var/run/ppp-<linkname>.pid
- file containing its process ID.
-
-* There is a new `maxfail' option which specifies how many consecutive
- failed connection attempts are permitted before pppd will exit. The
- default value is 10, and 0 means infinity. :-)
-
-* Sundry bugs fixed.
-
-
-What was new in ppp-2.3.8.
-**************************
-
-* The exit status of pppd will now indicate whether the link was
- successfully established, or if not, what error was encountered.
-
-* Pppd has two new options: fdlog <n> will send log messages to file
- descriptor <n> instead of standard output, and nofdlog will stop log
- messages from being sent to any file descriptor (they will still be
- sent to syslog). Pppd now will not send log messages to a file
- descriptor if the serial port is open on that file descriptor.
-
-* Pppd sets an environment variable called PPPLOGNAME for scripts that
- it runs, indicating the login name of the user who invoked pppd.
-
-* Pppd sets environment variables CONNECT_TIME, BYTES_SENT and
- BYTES_RCVD for the ip-down and auth-down scripts indicating the
- statistics for the connection just terminated. (CONNECT_TIME is in
- seconds.)
-
-* If the user has the serial device open on standard input and
- specifies a symbolic link to the serial device on the command line,
- pppd will detect this and behave correctly (i.e. not detach from its
- controlling terminal). Furthermore, if the serial port is open for
- reading and writing on standard input, pppd will assume that it is
- locked by its invoker and not lock it itself.
-
-* Chat now has a feature where if a string to be sent begins with an
- at sign (@), the rest of the string is taken as the name of a file
- (regular file or named pipe), and the actual string to send is taken
- from that file.
-
-* Support for FreeBSD-2.2.8 and 3.0 has been added, thanks to Paul
- Fulghum.
-
-* The Tru64 (aka Digital Unix aka OSF/1) port has been updated.
-
-* The system panics on Solaris SMP systems related to PPP connections
- being established and terminated should no longer occur.
-
-* Fixed quite a few bugs.
-
-
-What was new in ppp-2.3.7.
-**************************
-
-* Pppd can now automatically allocate itself a pseudo-tty to use as
- the serial device. This has made three new options possible:
-
- - `pty script' will run `script' with its standard input and output
- connected to the master side of the pty. For example:
- pppd pty 'ssh -t server.my.net pppd'
- is a basic command for setting up a PPP link (tunnel) over ssh.
- (In practice you may need to specify other options such as IP
- addresses, etc.)
-
- - `notty' tells pppd to communicate over its standard input and
- output, which do not have to be a terminal device.
-
- - `record filename' tells pppd to record all of the characters sent
- and received over the serial device to a file called `filename'.
- The data is recorded in a tagged format with timestamps, which can
- be printed in a readable form with the pppdump program, which is
- included in this distribution.
-
-* Pppd now logs the connect time and number of bytes sent and received
- (at the level of the serial device) when the connection is
- terminated.
-
-* If you use the updetach or nodetach option, pppd will print its
- messages to standard output as well as logging them with syslog
- (provided of course pppd isn't using its standard input or output as
- its serial device).
-
-* There is a new `privgroup groupname' option (a privileged option).
- If the user running pppd is in group `groupname', s/he can use
- privileged options without restriction.
-
-* There is a new `receive-all' option, which causes pppd to accept all
- control characters, even the ones that the peer should be escaping
- (i.e. the receive asyncmap is 0). This is useful with some buggy
- peers.
-
-* The default asyncmap is now 0.
-
-* There is a new `sync' option, currently only implemented under
- Linux, which allows pppd to run on synchronous HDLC devices.
-
-* If a value for the device name or for the connect, disconnect,
- welcome or pty option is given in a privileged option file
- (i.e. /etc/ppp/options or a file loaded with the `call' option), it
- cannot be overridden by a non-privileged user.
-
-* Many bugs have been fixed, notably:
- - signals are not blocked unnecessarily, as they were in 2.3.6.
- - the usepeerdns option should work now.
- - the SPEED environment variable for scripts is set correctly.
- - the /etc/ppp/auth-down script is not run until auth-up completes.
- - the device is opened as root if it is the device on standard
- input.
- - pppd doesn't die with the ioctl(PPPIOCSASYNCMAP) error under linux
- if a hangup occurs at the wrong time.
-
-* Some error messages have been changed to be clearer (I hope :-)
-
-
-What was new in ppp-2.3.6.
-**************************
-
-* Pppd now opens the tty device as the user (rather than as root) if
- the device name was given by the user, i.e. on the command line or
- in the ~/.ppprc file. If the device name was given in
- /etc/ppp/options or in a file loaded with the `call' option, the
- device is opened as root.
-
-* The default behaviour of pppd is now to let a peer which has not
- authenticated itself (e.g. your ISP) use any IP address to which the
- system does not already have a route. (This is currently only
- supported under Linux, Solaris and Digital Unix; on the other
- systems, the peer must now authenticate itself unless the noauth
- option is used.)
-
-* Added new option `usepeerdns', thanks to Nick Walker
- <nickwalker@email.com>. If the peer supplies DNS addresses, these
- will be written to /etc/ppp/resolv.conf. The ip-up script can then
- be used to add these addresses to /etc/resolv.conf if desired (see
- the ip-up.local.add and ip-down.local.add files in the scripts
- directory).
-
-* The Solaris ppp driver should now work correctly on SMP systems.
-
-* Minor corrections so that the code can compile under Solaris 7,
- and under Linux with glibc-2.1.
-
-* The Linux kernel driver has been restructured for improved
- performance.
-
-* Pppd now won't start the ip-down script until the ip-up script has
- finished.
-
-
-What was new in ppp-2.3.5.
-**************************
-
-* Minor corrections to the Digital UNIX and NetBSD ports.
-
-* A workaround to avoid tickling a bug in the `se' serial port driver
-on Sun PCI Ultra machines running Solaris.
-
-* Fixed a bug in the negotiation of the Microsoft WINS server address
-option.
-
-* Fixed a bug in the Linux port where it would fail for kernel
-versions above 2.1.99.
-
-
-What was new in ppp-2.3.4.
-**************************
-
-* The NeXT port has been updated, thanks to Steve Perkins.
-
-* ppp-2.3.4 compiles and works under Solaris 2.6, using either gcc or
-cc.
-
-* With the Solaris, SVR4 and SunOS ports, you can control the choice
-of C compiler, C compiler options, and installation directories by
-editing the svr4/Makedefs or sunos4/Makedefs file.
-
-* Until now, we have been using the number 24 to identify Deflate
-compression in the CCP negotiations, which was the number in the draft
-RFC describing Deflate. The number actually assigned to Deflate is
-26. The code has been changed to use 26, but to allow the use of 24
-for now for backwards compatibility. (This can be disabled with the
-`nodeflatedraft' option to pppd.)
-
-* Fixed some bugs in the linux driver and deflate compressor which
-were causing compression problems, including corrupting long
-incompressible packets sometimes.
-
-* Fixes to the PAM and shadow password support in pppd, from Al
-Longyear and others.
-
-* Pppd now sets some environment variables for scripts it invokes
-(ip-up/down, auth-ip/down), giving information about the connection.
-The variables it sets are PEERNAME, IPLOCAL, IPREMOTE, UID, DEVICE,
-SPEED, and IFNAME.
-
-* Pppd now has an `updetach' option, which will cause it to detach
-from its controlling terminal once the link has come up (i.e. once it
-is available for IP traffic).
-
-
-What was new in ppp-2.3.3.
-**************************
-
-* Fixed compilation problems under SunOS.
-
-* Fixed a bug introduced into chat in 2.3.2, and compilation problems
-introduced into the MS-CHAP implementation in 2.3.2.
-
-* The linux kernel driver has been updated for recent 2.1-series
-kernel changes, and it now will ask kerneld to load compression
-modules when required, if the kernel is configured to support kerneld.
-
-* Pppd should now compile correctly under linux on systems with glibc.
-
-
-What was new in ppp-2.3.2.
-**************************
-
-* In 2.3.1, I made a change which was intended to make pppd able to
-detect loss of CD during or immediately after the connection script
-runs. Unfortunately, this had the side-effect that the connection
-script wouldn't work at all on some systems. This change has been
-reversed.
-
-* Fix compilation problems in the Linux kernel driver.
-
-
-What was new in ppp-2.3.1.
-**************************
-
-* Enhancements to chat, thanks to Francis Demierre. Chat can now
-accept comments in the chat script file, and has new SAY, HANGUP,
-CLR_ABORT and CLR_REPORT keywords.
-
-* Fixed a bug which causes 2.3.0 to crash Solaris systems.
-
-* Bug-fixes and restructuring of the Linux kernel driver.
-
-* The holdoff behaviour of pppd has been changed slightly: now, if
-the link comes up for IP (or other network protocol) traffic, we
-consider that the link has been successfully established, and don't
-enforce the holdoff period after the link goes down.
-
-* Pppd should now correctly wait for CD (carrier detect) from the
-modem, even when the serial port initially had CLOCAL set, and it
-should also detect loss of CD during or immediately after the
-connection script runs.
-
-* Under linux, pppd will work with older 2.2.0* version kernel
-drivers, although demand-dialling is not supported with them.
-
-* Minor bugfixes for pppd.
-
-
-What was new in ppp-2.3.
-************************
-
-* Demand-dialling. Pppd now has a mode where it will establish the
-network interface immediately when it starts, but not actually bring
-the link up until it sees some data to be sent. Look for the demand
-option description in the pppd man page. Demand-dialling is not
-supported under Ultrix or NeXTStep.
-
-* Idle timeout. Pppd will optionally terminate the link if no data
-packets are sent or received within a certain time interval.
-
-* Pppd now runs the /etc/ppp/auth-up script, if it exists, when the
-peer successfully authenticates itself, and /etc/ppp/auth-down when
-the connection is subsequently terminated. This can be useful for
-accounting purposes.
-
-* A new packet compression scheme, Deflate, has been implemented.
-This uses the same compression method as `gzip'. This method is free
-of patent or copyright restrictions, and it achieves better
-compression than BSD-Compress. It does consume more CPU cycles for
-compression than BSD-Compress, but this shouldn't be a problem for
-links running at 100kbit/s or less.
-
-* There is no code in this distribution which is covered by Brad
-Clements' restrictive copyright notice. The STREAMS modules for SunOS
-and OSF/1 have been rewritten, based on the Solaris 2 modules, which
-were written from scratch without any Clements code.
-
-* Pppstats has been reworked to clean up the output format somewhat.
-It also has a new -d option which displays data rate in kbyte/s for
-those columns which would normally display bytes.
-
-* Pppd options beginning with - or + have been renamed, e.g. -ip
-became noip, +chap became require-chap, etc. The old options are
-still accepted for compatibility but may be removed in future.
-
-* Pppd now has some options (such as the new `noauth' option) which
-can only be specified if it is being run by root, or in an
-"privileged" options file: /etc/ppp/options or an options file in the
-/etc/ppp/peers directory. There is a new "call" option to read
-options from a file in /etc/ppp/peers, making it possible for non-root
-users to make unauthenticated connections, but only to certain trusted
-peers. My intention is to make the `auth' option the default in a
-future release.
-
-* Several minor new features have been added to pppd, including the
-maxconnect and welcome options. Pppd will now terminate the
-connection when there are no network control protocols running. The
-allowed IP address(es) field in the secrets files can now specify
-subnets (with a notation like 123.45.67.89/24) and addresses which are
-not acceptable (put a ! on the front).
-
-* Numerous bugs have been fixed (no doubt some have been introduced :-)
-Thanks to those who reported bugs in ppp-2.2.
diff --git a/mdk-stage1/ppp/FAQ b/mdk-stage1/ppp/FAQ
deleted file mode 100644
index 96bc5c708..000000000
--- a/mdk-stage1/ppp/FAQ
+++ /dev/null
@@ -1,634 +0,0 @@
-This is a list of Frequently Asked Questions about using ppp-2.x and
-their answers.
-
-
-------------------------------------------------------------------------
-
-Q: Can you give me an example of how I might set up my machine to dial
-out to an ISP?
-
-A: Here's an example for dialling out to an ISP via a modem on
-/dev/tty02. The modem uses hardware (CTS/RTS) flow control, and the
-serial port is run at 38400 baud. The ISP assigns our IP address.
-
-To configure pppd for this connection, create a file under
-/etc/ppp/peers called (say) my-isp containing the following:
-
-tty02 crtscts 38400
-connect 'chat -v -f /etc/ppp/chat/my-isp'
-defaultroute
-
-The ppp connection is then initiated using the following command:
-
-pppd call my-isp
-
-Of course, if the directory containing pppd is not in your path, you
-will need to give the full pathname for pppd, for example,
-/usr/sbin/pppd.
-
-When you run this, pppd will use the chat program to dial the ISP and
-invoke its ppp service. Chat will read the file specified with -f,
-namely /etc/ppp/chat/my-isp, to find a list of strings to expect to
-receive, and strings to send. This file would contain something like
-this:
-
-ABORT "NO CARRIER"
-ABORT "NO DIALTONE"
-ABORT "ERROR"
-ABORT "NO ANSWER"
-ABORT "BUSY"
-ABORT "Username/Password Incorrect"
-"" "at"
-OK "at&d2&c1"
-OK "atdt2479381"
-"name:" "^Uusername"
-"word:" "\qpassword"
-"annex" "\q^Uppp"
-"Switching to PPP-ppp-Switching to PPP"
-
-You will need to change the details here. The first string on each
-line is a string to expect to receive; the second is the string to
-send. You can add or delete lines according to the dialog required to
-access your ISP's system. This example is for a modem with a standard
-AT command set, dialling out to an Annex terminal server. The \q
-toggles "quiet" mode; when quiet mode is on, the strings to be sent
-are replaced by ?????? in the log. You may need to go through the
-dialog manually using kermit or tip first to determine what should go
-in the script.
-
-To terminate the link, run the following script, called (say)
-kill-ppp:
-
-#!/bin/sh
-unit=ppp${1-0}
-piddir=/var/run
-if [ -f $piddir/$unit.pid ]; then
- kill -1 `cat $piddir/$unit.pid`
-fi
-
-On some systems (SunOS, Solaris, Ultrix), you will need to change
-/var/run to /etc/ppp.
-
-
-------------------------------------------------------------------------
-
-Q: Can you give me an example of how I could set up my office machine
-so I can dial in to it from home?
-
-A: Let's assume that the office machine is called "office" and is on a
-local ethernet subnet. Call the home machine "home" and give it an IP
-address on the same subnet as "office". We'll require both machines
-to authenticate themselves to each other.
-
-Set up the files on "office" as follows:
-
-/etc/ppp/options contains:
-
-auth # require the peer to authenticate itself
-lock
-# other options can go here if desired
-
-/etc/ppp/chap-secrets contains:
-
-home office "beware the frub-jub" home
-office home "bird, my son!%&*" -
-
-Set up a modem on a serial port so that users can dial in to the
-modem and get a login prompt.
-
-On "home", set up the files as follows:
-
-/etc/ppp/options contains the same as on "office".
-
-/etc/ppp/chap-secrets contains:
-
-home office "beware the frub-jub" -
-office home "bird, my son!%&*" office
-
-Create a file called /etc/ppp/peers/office containing the following:
-
-tty02 crtscts 38400
-connect 'chat -v -f /etc/ppp/chat/office'
-defaultroute
-
-(You may need to change some of the details here.)
-
-Create the /etc/ppp/chat/office file containing the following:
-
-ABORT "NO CARRIER"
-ABORT "NO DIALTONE"
-ABORT "ERROR"
-ABORT "NO ANSWER"
-ABORT "BUSY"
-ABORT "ogin incorrect"
-"" "at"
-OK "at&d2&c1"
-OK "atdt2479381"
-"name:" "^Uusername"
-"word:" "\qpassword"
-"$" "\q^U/usr/sbin/pppd proxyarp"
-"~"
-
-You will need to change the details. Note that the "$" in the
-second-last line is expecting the shell prompt after a successful
-login - you may need to change it to "%" or something else.
-
-You then initiate the connection (from home) with the command:
-
-pppd call office
-
-------------------------------------------------------------------------
-
-Q: When I try to establish a connection, the modem successfully dials
-the remote system, but then hangs up a few seconds later. How do I
-find out what's going wrong?
-
-A: There are a number of possible problems here. The first thing to
-do is to ensure that pppd's messages are visible. Pppd uses the
-syslog facility to log messages which help to identify specific
-problems. Messages from pppd have facility "daemon" and levels
-ranging from "debug" to "error".
-
-Usually it is useful to see messages of level "notice" or higher on
-the console. To see these, find the line in /etc/syslog.conf which
-has /dev/console on the right-hand side, and add "daemon.notice" in
-the list on the left. The line will end up looking something like
-this:
-
-*.err;kern.debug;auth.notice;mail.crit;daemon.notice /dev/console
-
-Note that the whitespace is tabs, *not* spaces.
-
-If you are having problems, it may be useful to see messages of level
-"info" as well, in which case you would change "daemon.notice" to
-"daemon.info".
-
-In addition, it is useful to collect pppd's debugging output in a
-file - the debug option to pppd causes it to log the contents of all
-control packets sent and received in human-readable form. To do this,
-add a line like this to /etc/syslog.conf:
-
-daemon,local2.debug /etc/ppp/log
-
-and create an empty /etc/ppp/log file.
-
-When you change syslog.conf, you will need to send a HUP signal to
-syslogd to causes it to re-read syslog.conf. You can do this with a
-command like this (as root):
-
- kill -HUP `cat /etc/syslogd.pid`
-
-(On some systems, you need to use /var/run/syslog.pid instead of
-/etc/syslogd.pid.)
-
-After setting up syslog like this, you can use the -v flag to chat and
-the `debug' option to pppd to get more information. Try initiating
-the connection again; when it fails, inspect /etc/ppp/log to see what
-happened and where the connection failed.
-
-
-------------------------------------------------------------------------
-
-Q: When I try to establish a connection, I get an error message saying
-"Serial link is not 8-bit clean". Why?
-
-A: The most common cause is that your connection script hasn't
-successfully dialled out to the remote system and invoked ppp service
-there. Instead, pppd is talking to something (a shell or login
-process on the remote machine, or maybe just the modem) which is only
-outputting 7-bit characters.
-
-This can also arise with a modem which uses an AT command set if the
-dial command is issued before pppd is invoked, rather than within a
-connect script started by pppd. If the serial port is set to 7
-bits/character plus parity when the last AT command is issued, the
-modem serial port will be set to the same setting.
-
-Note that pppd *always* sets the local serial port to 8 bits per
-character, with no parity and 1 stop bit. So you shouldn't need to
-issue an stty command before invoking pppd.
-
-
-------------------------------------------------------------------------
-
-Q: When I try to establish a connection, I get an error message saying
-"Serial line is looped back". Why?
-
-A: Probably your connection script hasn't successfully dialled out to
-the remote system and invoked ppp service there. Instead, pppd is
-talking to something which is just echoing back the characters it
-receives. The -v option to chat can help you find out what's going
-on. It can be useful to include "~" as the last expect string to
-chat, so chat won't return until it's seen the start of the first PPP
-frame from the remote system.
-
-Another possibility is that your phone connection has dropped for some
-obscure reason and the modem is echoing the characters it receives
-from your system.
-
-
-------------------------------------------------------------------------
-
-Q: I installed pppd successfully, but when I try to run it, I get a
-message saying something like "peer authentication required but no
-authentication files accessible".
-
-A: When pppd is used on a machine which already has a connection to
-the Internet (or to be more precise, one which has a default route in
-its routing table), it will require all peers to authenticate
-themselves. The reason for this is that if you don't require
-authentication, you have a security hole, because the peer can
-basically choose any IP address it wants, even the IP address of some
-trusted host (for example, a host mentioned in some .rhosts file).
-
-On machines which don't have a default route, pppd does not require
-the peer to authenticate itself. The reason is that such machines
-would mostly be using pppd to dial out to an ISP which will refuse to
-authenticate itself. In that case the peer can use any IP address as
-long as the system does not already have a route to that address.
-For example, if you have a local ethernet network, the peer can't use
-an address on that network. (In fact it could if it authenticated
-itself and it was permitted to use that address by the pap-secrets or
-chap-secrets file.)
-
-There are 3 ways around the problem:
-
-1. If possible, arrange for the peer to authenticate itself, and
-create the necessary secrets files (/etc/ppp/pap-secrets and/or
-/etc/ppp/chap-secrets).
-
-2. If the peer refuses to authenticate itself, and will always be
-using the same IP address, or one of a small set of IP addresses, you
-can create an entry in the /etc/ppp/pap-secrets file like this:
-
- "" * "" his-ip.his-domain his-other-ip.other-domain
-
-(that is, using the empty string for the client name and password
-fields). Of couse, you replace the 4th and following fields in the
-example above with the IP address(es) that the peer may use. You can
-use either hostnames or numeric IP addresses.
-
-3. You can add the `noauth' option to the /etc/ppp/options file.
-Pppd will then not ask the peer to authenticate itself. If you do
-this, I *strongly* recommend that you remove the set-uid bit from the
-permissions on the pppd executable, with a command like this:
-
- chmod u-s /usr/sbin/pppd
-
-Then, an intruder could only use pppd maliciously if they had already
-become root, in which case they couldn't do any more damage using pppd
-than they could anyway.
-
-
-------------------------------------------------------------------------
-
-Q: What do I need to put in the secrets files?
-
-A: Three things:
- - secrets (i.e. passwords) to use for authenticating this host to
- other hosts (i.e., for proving our identity to others);
- - secrets which other hosts can use for authenticating themselves
- to us (i.e., so that they can prove their identity to us); and
- - information about which IP addresses other hosts may use, once
- they have authenticated themselves.
-
-There are two authentication files: /etc/ppp/pap-secrets, which
-contains secrets for use with PAP (the Password Authentication
-Protocol), and /etc/ppp/chap-secrets, which contains secrets for use
-with CHAP (the Challenge Handshake Authentication Protocol). Both
-files have the same simple format, which is as follows:
-
-- The file contains a series of entries, each of which contains a
-secret for authenticating one machine to another.
-
-- Each entry is contained on a single logical line. A logical line
-may be continued across several lines by placing a backslash (\) at
-the end of each line except the last.
-
-- Each entry has 3 or more fields, separated by whitespace (spaces
-and/or tabs). These fields are, in order:
- * The name of the machine that is authenticating itself
- (the "client").
- * The name of the machine that is authenticating the client
- (the "server").
- * The secret to be used for authenticating that client to that
- server. If this field begins with the at-sign `@', the rest
- of the field is taken as the name of a file containing the
- actual secret.
- * The 4th and any following fields list the IP address(es)
- that the client may use.
-
-- The file may contain comments, which begin with a `#' and continue
-to the end of the line.
-
-- Double quotes `"' should be used around a field if it contains
-characters with special significance, such as space, tab, `#', etc.
-
-- The backslash `\' may be used before characters with special
-significance (space, tab, `#', `\', etc.) to remove that significance.
-
-Some important points to note:
-
-* A machine can be *both* a "client" and a "server" for the purposes
-of authentication - this happens when both peers require the other to
-authenticate itself. So A would authenticate itself to B, and B would
-also authenticate itself to A (possibly using a different
-authentication protocol).
-
-* If both the "client" and the "server" are running ppp-2.x, they need
-to have a similar entry in the appropriate secrets file; the first two
-fields are *not* swapped on the client, compared to the server. So
-the client might have an entry like this:
-
- ay bee "our little secret" -
-
-and the corresponding entry on the server could look like this:
-
- ay bee "our little secret" 123.45.67.89
-
-
-------------------------------------------------------------------------
-
-Q: Explain about PAP and CHAP?
-
-PAP stands for the Password Authentication Protocol. With this
-protocol, the "client" (the machine that needs to authenticate itself)
-sends its name and a password, in clear text, to the "server". The
-server returns a message indicating whether the name and password are
-valid.
-
-CHAP stands for the Challenge Handshake Authentication Protocol. It
-is designed to address some of the deficiencies and vulnerabilities of
-PAP. Like PAP, it is based on the client and server having a shared
-secret, but the secret is never passed in clear text over the link.
-Instead, the server sends a "challenge" - an arbitrary string of
-bytes, and the client must prove it knows the shared secret by
-generating a hash value from the challenge combined with the shared
-secret, and sending the hash value back to the server. The server
-also generates the hash value and compares it with the value received
-from the client.
-
-At a practical level, CHAP can be slightly easier to configure than
-PAP because the server sends its name with the challenge. Thus, when
-finding the appropriate secret in the secrets file, the client knows
-the server's name. In contrast, with PAP, the client has to find its
-password (i.e. the shared secret) before it has received anything from
-the server. Thus, it may be necessary to use the `remotename' option
-to pppd when using PAP authentication so that it can select the
-appropriate secret from /etc/ppp/pap-secrets.
-
-Microsoft also has a variant of CHAP which uses a different hashing
-arrangement from normal CHAP. There is a client-side implementation
-of Microsoft's CHAP in ppp-2.3; see README.MSCHAP80.
-
-
-------------------------------------------------------------------------
-
-Q: When the modem hangs up, without the remote system having
-terminated the connection properly, pppd does not notice the hangup,
-but just keeps running. How do I get pppd to notice the hangup and
-exit?
-
-A: Pppd detects modem hangup by looking for an end-of-file indication
-from the serial driver, which should be generated when the CD (carrier
-detect) signal on the serial port is deasserted. For this to work:
-
-- The modem has to be set to assert CD when the connection is made and
-deassert it when the phone line hangs up. Usually the AT&C1 modem
-command sets this mode.
-
-- The cable from the modem to the serial port must connect the CD
-signal (on pin 8).
-
-- Some serial drivers have a "software carrier detect" mode, which
-must be *disabled*. The method of doing this varies between systems.
-Under SunOS, use the ttysoftcar command. Under NetBSD, edit /etc/ttys
-to remove the "softcar" flag from the line for the serial port, and
-run ttyflags.
-
-
-------------------------------------------------------------------------
-
-Q: Why should I use PPP compression (BSD-Compress or Deflate) when my
-modem already does V.42 compression? Won't it slow the CPU down a
-lot?
-
-A: Using PPP compression is preferable, especially when using modems
-over phone lines, for the following reasons:
-
-- The V.42 compression in the modem isn't very strong - it's an LZW
-technique (same as BSD-Compress) with a 10, 11 or 12 bit code size.
-With BSD-Compress you can use a code size of up to 15 bits and get
-much better compression, or you can use Deflate and get even better
-compression ratios.
-
-- I have found that enabling V.42 compression in my 14.4k modem
-increases the round-trip time for a character to be sent, echoed and
-returned by around 40ms, from 160ms to 200ms (with error correction
-enabled). This is enough to make it feel less responsive on rlogin or
-telnet sessions. Using PPP compression adds less than 5ms (small
-enough that I couldn't measure it reliably). I admit my modem is a
-cheapie and other modems may well perform better.
-
-- While compression and decompression do require some CPU time, they
-reduce the amount of time spent in the serial driver to transmit a
-given amount of data. Many machines require an interrupt for each
-character sent or received, and the interrupt handler can take a
-significant amount of CPU time. So the increase in CPU load isn't as
-great as you might think. My measurements indicate that a system with
-a 33MHz 486 CPU should be able to do Deflate compression for serial
-link speeds of up to 100kb/s or more. It depends somewhat on the type
-of data, of course; for example, when compressing a string of nulls
-with Deflate, it's hard to get a high output data rate from the
-compressor, simply because it compresses strings of nulls so well that
-it has to eat a very large amount of input data to get each byte of
-output.
-
-
-------------------------------------------------------------------------
-
-Q: I get messages saying "Unsupported protocol (...) received". What do
-these mean?
-
-A: If you only get one or two when pppd starts negotiating with the
-peer, they mean that the peer wanted to negotiate some PPP protocol
-that pppd doesn't understand. This doesn't represent a problem, it
-simply means that there is some functionality that the peer supports
-that pppd doesn't, so that functionality can't be used.
-
-If you get them sporadically while the link is operating, or if the
-protocol numbers (in parentheses) don't correspond to any valid PPP
-protocol that the peer might be using, then the problem is probably
-that characters are getting corrupted on the receive side, or that
-extra characters are being inserted into the receive stream somehow.
-If this is happening, most packets that get corrupted should get
-discarded by the FCS (Frame Check Sequence, a 16-bit CRC) check, but a
-small number may get through.
-
-One possibility may be that you are receiving broadcast messages on
-the remote system which are being sent over your serial link. Another
-possibility is that your modem is set for XON/XOFF (software) flow
-control and is inserting ^Q and ^S characters into the receive data
-stream.
-
-
-------------------------------------------------------------------------
-
-Q: I get messages saying "Protocol-Reject for unsupported protocol ...".
-What do these mean?
-
-A: This is the other side of the previous question. If characters are
-getting corrupted on the way to the peer, or if your system is
-inserting extra bogus characters into the transmit data stream, the
-peer may send protocol-reject messages to you, resulting in the above
-message (since your pppd doesn't recognize the protocol number
-either.)
-
-
-------------------------------------------------------------------------
-
-Q: I get a message saying something like "ioctl(TIOCSETD): Operation
-not permitted". How do I fix this?
-
-A: This is because pppd is not running as root. If you have not
-installed pppd setuid-root, you will have to be root to run it. If
-you have installed pppd setuid-root and you still get this message, it
-is probably because your shell is using some other copy of pppd than
-the installed one - for example, if you are in the pppd directory
-where you've just built pppd and your $PATH has . before /usr/sbin (or
-wherever pppd gets installed).
-
-
-------------------------------------------------------------------------
-
-Q: Has your package been ported to HP/UX or IRIX or AIX?
-
-A: No. I don't have access to systems running HP/UX or AIX. No-one
-has volunteered to port it to HP/UX. I had someone who did a port for
-AIX 4.x, but who is no longer able to maintain it. And apparently AIX
-3.x is quite different, so it would need a separate port.
-
-IRIX includes a good PPP implementation in the standard distribution,
-as far as I know.
-
-
-------------------------------------------------------------------------
-
-Q: Under SunOS 4, when I try to modload the ppp modules, I get the
-message "can't open /dev/vd: No such device".
-
-A: First check in /dev that there is an entry like this:
-
-crw-r--r-- 1 root 57, 0 Oct 2 1991 vd
-
-If not, make one (mknod /dev/vd c 57 0). If the problem still exists,
-probably your kernel has been configured without the vd driver
-included. The vd driver is needed for loadable module support.
-
-First, identify the config file that was used. When you boot your
-machine, or if you run /etc/dmesg, you'll see a line that looks
-something like this:
-
-SunOS Release 4.1.3_U1 (CAP_XBOX) #7: Thu Mar 21 15:31:56 EST 1996
- ^^^^^^^^
- this is the config file name
-
-The config file will be in the /sys/`arch -k`/conf directory (arch -k
-should return sun4m for a SparcStation 10, sun3x for a Sun 3/80,
-etc.). Look in there for a line saying "options VDDRV". If that line
-isn't present (or is commented out), add it (or uncomment it).
-
-You then need to rebuild the kernel as described in the SunOS
-manuals. Basically you need to run config and make like this:
-
- /usr/etc/config CAP_XBOX
- cd ../CAP_XBOX
- make
-
-(replacing the string CAP_XBOX by the name of the config file for your
-kernel, of course).
-
-Then copy the new kernel to /:
-
- mv /vmunix /vmunix.working
- cp vmunix /
-
-and reboot. Modload should then work.
-
-
-------------------------------------------------------------------------
-
-Q: I'm running Linux (or NetBSD or FreeBSD), and my system comes with
-PPP already. Should I consider installing this package? Why?
-
-A: The PPP that is already installed in your system is (or is derived
-from) some version of this PPP package. You can find out what version
-of this package is already installed with the command "pppd --help".
-If this is older than the latest version, you may wish to install the
-latest version so that you can take advantage of the new features or
-bug fixes.
-
-
-------------------------------------------------------------------------
-
-Q: I'm running pppd in demand mode, and I find that pppd often dials
-out unnecessarily when I try to make a connection within my local
-machine or with a machine on my local LAN. What can I do about this?
-
-A: Very often the cause of this is that a program is trying to contact
-a nameserver to resolve a hostname, and the nameserver (specified in
-/etc/resolv.conf, usually) is on the far side of the ppp link. You
-can try executing a command such as `ping myhost' (where myhost is the
-name of the local machine, or some other machine on a local LAN), to
-see whether that starts the ppp link. If it does, check the setup of
-your /etc/hosts file to make sure you have the local machine and any
-hosts on your local LAN listed, and /etc/resolv.conf and/or
-/etc/nsswitch.conf files to make sure you resolve hostnames from
-/etc/hosts if possible before trying to contact a nameserver.
-
-
-------------------------------------------------------------------------
-
-Q: Since I installed ppp-2.3.6, dialin users to my server have been
-getting this message when they run pppd:
-
-peer authentication required but no suitable secret(s) found for
-authenticating any peer to us (ispserver)
-
-A: In 2.3.6, the default is to let an unauthenticated peer only use IP
-addresses to which the machine doesn't already have a route. So on a
-machine with a default route, everyone has to authenticate. If you
-really don't want that, you can put `noauth' in the /etc/ppp/options
-file. Note that there is then no check on who is using which IP
-address. IMHO, this is undesirably insecure, but I guess it may be
-tolerable as long as you don't use any .rhosts files or anything like
-that. I recommend that you require dialin users to authenticate, even
-if just with PAP using their login password (using the `login' option
-to pppd). If you do use `noauth', you should at least have a pppusers
-group and set the permissions on pppd to allow only user and group to
-execute it.
-
-------------------------------------------------------------------------
-
-Q: When running pppd as a dial-in server, I often get the message
-"LCP: timeout sending Config-Requests" from pppd. It seems to be
-random, but dial-out always works fine. What is wrong?
-
-A: Most modern modems auto-detects the speed of the serial line
-between the modem and the computer. This auto-detection occurs when
-the computer sends characters to the modem, when the modem is in
-command mode. It does not occur when the modem is in data mode.
-Thus, if you send commands to the modem at 2400 bps, and then change
-the serial port speed to 115200 bps, the modem will not detect this
-change until something is transmitted from the computer to the modem.
-When running pppd in dial-in mode (i.e. without a connect script),
-pppd sets the speed of the serial port, but does not transmit
-anything. If the modem was already running at the specified speed,
-everything is fine, but if not, you will just receive garbage from the
-modem. To cure this, use an init script such as the following:
-
- pppd ttyS0 115200 modem crtscts init "chat '' AT OK"
-
-To reset the modem and enable auto-answer, use:
-
- pppd ttyS0 115200 modem crtscts init "chat '' ATZ OK ATS0=1 OK"
diff --git a/mdk-stage1/ppp/PLUGINS b/mdk-stage1/ppp/PLUGINS
deleted file mode 100644
index 0eeabe249..000000000
--- a/mdk-stage1/ppp/PLUGINS
+++ /dev/null
@@ -1,131 +0,0 @@
-Starting with version 2.3.10, pppd includes support for `plugins' -
-pieces of code which can be loaded into pppd at runtime and which can
-affect its behaviour in various ways. The idea of plugins is to
-provide a way for people to customize the behaviour of pppd without
-having to either apply local patches to each version or get their
-patches accepted into the standard distribution. My aim is that
-plugins will be able to be used with successive versions of pppd
-without needing to recompile the plugins.
-
-A plugin is a standard shared library object, typically with a name
-ending in .so. They are loaded using the standard dlopen() library
-call, so plugins are only supported on systems which support shared
-libraries and the dlopen call. At present pppd is compiled with
-plugin support only under Linux and Solaris.
-
-Plugins are loaded into pppd using the `plugin' option, which takes
-one argument, the name of a shared object file. The plugin option is
-a privileged option. I suggest that you give the full path name of
-the shared object file; if you don't, it may be possible for
-unscrupulous users to substitute another shared object file for the
-one you mean to load, e.g. by setting the LD_LIBRARY_PATH variable.
-
-Plugins are usually written in C and compiled and linked to a shared
-object file in the appropriate manner for your platform. Using gcc
-under Linux, a plugin called `xyz' could be compiled and linked with
-the following commands:
-
- gcc -c -O xyz.c
- gcc -shared -o xyz.so xyz.o
-
-There are some example plugins in the pppd/plugins directory in the
-ppp distribution. Currently there is one example, minconn.c, which
-implements a `minconnect' option, which specifies a minimum connect
-time before the idle timeout applies.
-
-Plugins can access global variables within pppd, so it is useful for
-them to #include "pppd.h" from the pppd source directory.
-
-Every plugin must contain a global procedure called `plugin_init'.
-This procedure will get called (with no arguments) immediately after
-the plugin is loaded.
-
-Plugins can affect the behaviour of pppd in at least three ways:
-
-1. They can add extra options which pppd will then recognize. This is
- done by calling the add_options() procedure with a pointer to an
- array of option_t structures. The last entry in the array must
- have its name field set to NULL.
-
-2. Pppd contains `hook' variables which are procedure pointers. If a
- given hook is not NULL, pppd will call the procedure it points to
- at the appropriate point in its processing. The plugin can set any
- of these hooks to point to its own procedures. See below for a
- description of the hooks which are currently implemented.
-
-3. Plugin code can call any global procedures and access any global
- variables in pppd.
-
-Here is a list of the currently implemented hooks in pppd.
-
-
-int (*idle_time_hook)(struct ppp_idle *idlep);
-
-The idle_time_hook is called when the link first comes up (i.e. when
-the first network protocol comes up) and at intervals thereafter. On
-the first call, the idlep parameter is NULL, and the return value is
-the number of seconds before pppd should check the link activity, or 0
-if there is to be no idle timeout.
-
-On subsequent calls, idlep points to a structure giving the number of
-seconds since the last packets were sent and received. If the return
-value is > 0, pppd will wait that many seconds before checking again.
-If it is <= 0, that indicates that the link should be terminated due
-to lack of activity.
-
-
-int (*holdoff_hook)(void);
-
-The holdoff_hook is called when an attempt to bring up the link fails,
-or the link is terminated, and the persist or demand option was used.
-It returns the number of seconds that pppd should wait before trying
-to reestablish the link (0 means immediately).
-
-
-int (*pap_check_hook)(void);
-int (*pap_passwd_hook)(char *user, char *passwd);
-int (*pap_auth_hook)(char *user, int userlen,
- char *passwd, int passlen,
- char **msgp, int *msglenp,
- struct wordlist **paddrs,
- struct wordlist **popts);
-
-These hooks are designed to allow a plugin to replace the normal PAP
-password processing in pppd with something different (e.g. contacting
-an external server).
-
-The pap_check_hook is called to check whether there is any possibility
-that the peer could authenticate itself to us. If it returns 1, pppd
-will ask the peer to authenticate itself. If it returns 0, pppd will
-not ask the peer to authenticate itself (but if authentication is
-required, pppd may exit, or terminate the link before network protocol
-negotiation). If it returns -1, pppd will look in the pap-secrets
-file as it would normally.
-
-The pap_passwd_hook is called to determine what username and password
-pppd should use in authenticating itself to the peer with PAP. The
-user string will already be initialized, by the `user' option, the
-`name' option, or from the hostname, but can be changed if necessary.
-MAXNAMELEN bytes of space are available at *user, and MAXSECRETLEN
-bytes of space at *passwd. If this hook returns 0, pppd will use the
-values at *user and *passwd; if it returns -1, pppd will look in the
-pap-secrets file, or use the value from the +ua or password option, as
-it would normally.
-
-The pap_auth_hook is called to determine whether the username and
-password supplied by the peer are valid. user and passwd point to
-null-terminated strings containing the username and password supplied
-by the peer, with non-printable characters converted to a printable
-form. The pap_auth_hook function should set msg to a string to be
-returned to the peer and return 1 if the username/password was valid
-and 0 if not. If the hook returns -1, pppd will look in the
-pap-secrets file as usual.
-
-If the username/password was valid, the hook can set *paddrs to point
-to a wordlist containing the IP address(es) which the peer is
-permitted to use, formatted as in the pap-secrets file. It can also
-set *popts to a wordlist containing any extra options for this user
-which pppd should apply at this point.
-
-
-## $Id$ ##
diff --git a/mdk-stage1/ppp/README b/mdk-stage1/ppp/README
deleted file mode 100644
index aa1e5f9c2..000000000
--- a/mdk-stage1/ppp/README
+++ /dev/null
@@ -1,168 +0,0 @@
-This is the README file for ppp-2.4, a package which implements the
-Point-to-Point Protocol (PPP) to provide Internet connections over
-serial lines.
-
-
-Introduction.
-*************
-
-The Point-to-Point Protocol (PPP) provides a standard way to establish
-a network connection over a serial link. At present, this package
-supports IP and the protocols layered above IP, such as TCP and UDP.
-The Linux and Solaris ports of this package have optional support for
-IPV6; the Linux port of this package also has support for IPX.
-
-This software consists of two parts:
-
-- Kernel code, which establishes a network interface and passes
-packets between the serial port, the kernel networking code and the
-PPP daemon (pppd). This code is implemented using STREAMS modules on
-SunOS 4.x and Solaris, and as a line discipline under Linux and FreeBSD.
-
-- The PPP daemon (pppd), which negotiates with the peer to establish
-the link and sets up the ppp network interface. Pppd includes support
-for authentication, so you can control which other systems may make a
-PPP connection and what IP addresses they may use.
-
-The primary platforms supported by this package are Linux and Solaris.
-Code for SunOS 4.x is included here but is largely untested. I have
-code for NeXTStep, FreeBSD, SVR4, Tru64 (Digital Unix), AIX and Ultrix
-but no active maintainers for these platforms. Code for all of these
-except AIX is included in the ppp-2.3.11 release.
-
-
-Installation.
-*************
-
-The file SETUP contains general information about setting up your
-system for using PPP. There is also a README file for each supported
-system, which contains more specific details for installing PPP on
-that system. The supported systems, and the corresponding README
-files, are:
-
- Linux README.linux
- Solaris 2 README.sol2
- SunOS 4.x README.sunos4
-
-In each case you start by running the ./configure script. This works
-out which operating system you are using and creates symbolic links to
-the appropriate makefiles. You then run `make' to compile the
-user-level code, and (as root) `make install' to install the
-user-level programs pppd, chat and pppstats.
-
-N.B. Since 2.3.0, leaving the permitted IP addresses column of the
-pap-secrets or chap-secrets file empty means that no addresses are
-permitted. You need to put a "*" in that column to allow the peer to
-use any IP address. (This only applies where the peer is
-authenticating itself to you, of course.)
-
-
-What's new in ppp-2.4.1.
-************************
-
-* Pppd can now print out the set of options that are in effect. The
- new `dump' option causes pppd to print out the option values after
- option parsing is complete. The `dryrun' option causes pppd to
- print the options and then exit.
-
-* The option parsing code has been fixed so that options in the
- per-tty options file are parsed correctly, and don't override values
- from the command line in most cases.
-
-* The plugin option now looks in /usr/lib/pppd/<pppd-version> (for
- example, /usr/lib/pppd/2.4.1b1) for shared objects for plugins if
- there is no slash in the plugin name.
-
-* When loading a plugin, pppd will now check the version of pppd for
- which the plugin was compiled, and refuse to load it if it is
- different to pppd's version string. To enable this, the plugin
- source needs to #include "pppd.h" and have a line saying:
- char pppd_version[] = VERSION;
-
-* There is a bug in zlib, discovered by James Carlson, which can cause
- kernel memory corruption if Deflate is used with the lowest setting,
- 8. As a workaround pppd will now insist on using at least 9.
-
-* Pppd should compile on Solaris and SunOS again.
-
-* Pppd should now set the MTU correctly on demand-dialled interfaces.
-
-
-What was new in ppp-2.4.0.
-**************************
-
-* Multilink: this package now allows you to combine multiple serial
- links into one logical link or `bundle', for increased bandwidth and
- reduced latency. This is currently only supported under the
- Linux-2.3.99pre5 or later kernels.
-
-* All the pppd processes running on a system now write information
- into a common database. I used the `tdb' code from samba for this.
-
-* New hooks have been added.
-
-For a list of the changes made during the 2.3 series releases of this
-package, see the Changes-2.3 file.
-
-
-Compression methods.
-********************
-
-This package supports two packet compression methods: Deflate and
-BSD-Compress. Other compression methods which are in common use
-include Predictor, LZS, and MPPC. These methods are not supported for
-two reasons - they are patent-encumbered, and they cause some packets
-to expand slightly, which pppd doesn't currently allow for.
-BSD-Compress is also patent-encumbered (its inclusion in this package
-can be considered a historical anomaly :-) but it doesn't ever expand
-packets. Neither does Deflate, which uses the same algorithm as gzip.
-
-
-Patents.
-********
-
-The BSD-Compress algorithm used for packet compression is the same as
-that used in the Unix "compress" command. It is apparently covered by
-U.S. patents 4,814,746 (owned by IBM) and 4,558,302 (owned by Unisys),
-and corresponding patents in various other countries (but not
-Australia). If this is of concern, you can build the package without
-including BSD-Compress. To do this, edit net/ppp-comp.h to change the
-definition of DO_BSD_COMPRESS to 0. The bsd-comp.c files are then no
-longer needed, so the references to bsd-comp.o may optionally be
-removed from the Makefiles.
-
-
-Contacts.
-*********
-
-The comp.protocols.ppp newsgroup is a useful place to get help if you
-have trouble getting your ppp connections to work. Please do not send
-me questions of the form "please help me get connected to my ISP" -
-I'm sorry, but I simply do not have the time to answer all the
-questions like this that I get.
-
-If you find bugs in this package, please report them to the maintainer
-for the port for the operating system you are using:
-
-Linux Paul Mackerras <paulus@linuxcare.com>
-Solaris 2 James Carlson <james.d.carlson@east.sun.com>
-SunOS 4.x Adi Masputra <adi.masputra@sun.com>
-
-
-Copyrights:
-***********
-
-All of the code can be freely used and redistributed. The individual
-source files each have their own copyright and permission notice; some
-have a BSD-style notice and some are under the GPL.
-
-
-Distribution:
-*************
-
-The primary site for releases of this software is:
-
- ftp://linuxcare.com.au/pub/ppp/
-
-
-($Id$)
diff --git a/mdk-stage1/ppp/README.MSCHAP80 b/mdk-stage1/ppp/README.MSCHAP80
deleted file mode 100644
index d3ed291b7..000000000
--- a/mdk-stage1/ppp/README.MSCHAP80
+++ /dev/null
@@ -1,284 +0,0 @@
-PPP Client Support for Microsoft's CHAP-80
-==========================================
-
-Eric Rosenquist rosenqui@strataware.com
-(updated by Paul Mackerras)
-(updated by Al Longyear)
-(updated by Farrell Woods)
-
-INTRODUCTION
-
-Microsoft has introduced an extension to the Challenge/Handshake
-Authentication Protocol (CHAP) which avoids storing cleartext
-passwords on a server. (Unfortunately, this is not as secure as it
-sounds, because the encrypted password stored on a server can be used
-by a bogus client to gain access to the server just as easily as if
-the password were stored in cleartext.) The details of the Microsoft
-extensions can be found in the document:
-
- <ftp://ftp.microsoft.com/developr/rfc/chapexts.txt>
-
-In short, MS-CHAP is identified as <auth chap 80> since the hex value
-of 80 is used to designate Microsoft's scheme. Standard PPP CHAP uses
-a value of 5. If you enable PPP debugging with the "debug" option and
-see something like the following in your logs, the remote server is
-requesting MS-CHAP:
-
- rcvd [LCP ConfReq id=0x2 <asyncmap 0x0> <auth chap 80> <magic 0x46a3>]
- ^^^^^^^^^^^^
-
-The standard pppd implementation will indicate its lack of support for
-MS-CHAP by NAKing it:
-
- sent [LCP ConfNak id=0x2 <auth chap 05>]
-
-Windows NT Server systems are often configured to "Accept only
-Microsoft Authentication" (this is intended to enhance security). Up
-until now, that meant that you couldn't use this version of PPPD to
-connect to such a system. I've managed to get a client-only
-implementation of MS-CHAP working; it will authenticate itself to
-another system using MS-CHAP, but if you're using PPPD as a dial-in
-server, you won't be able to use MS-CHAP to authenticate the clients.
-This would not be a lot of extra work given that the framework is in
-place, but I didn't need it myself so I didn't implement it.
-
-
-BUILDING THE PPPD
-
-MS-CHAP uses a combination of MD4 hashing and DES encryption for
-authentication. You may need to get Eric Young's libdes library in
-order to use my MS-CHAP extensions. A lot of UNIX systems already
-have DES encryption available via the crypt(3), encrypt(3) and
-setkey(3) interfaces. Some may (such as that on Digital UNIX)
-provide only the encryption mechanism and will not perform
-decryption. This is okay. We only need to encrypt to perform
-MS-CHAP authentication.
-
-If you have encrypt/setkey available, then hopefully you need only
-define these two things in your Makefile: -DUSE_CRYPT and -DCHAPMS.
-Skip the paragraphs below about obtaining and building libdes. Do
-the "make clean" and "make" as described below. Linux users
-should not need to modify their Makefiles. Instead,
-just do "make CHAPMS=1 USE_CRYPT=1".
-
-If you don't have encrypt and setkey, you will need Eric Young's
-libdes library. You can find it in:
-
-ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.psy.uq.oz.au/DES/libdes-3.06.tar.gz
-
-Australian residents can get libdes from Eric Young's site:
-
-ftp://ftp.psy.uq.oz.au/pub/Crypto/DES/libdes-3.06.tar.gz
-
-It is also available on many other sites (ask Archie).
-
-I used libdes-3.06, but hopefully anything newer than that will work
-also. Get the library, build and test it on your system, and install
-it somewhere (typically /usr/local/lib and /usr/local/include).
-
-
-
-You should now be ready to (re)compile the PPPD. Go to the pppd
-subdirectory and make sure the Makefile contains "-DCHAPMS" in the
-CFLAGS or COMPILE_FLAGS macro, and that the LIBS macro (or LDADD for
-BSD systems) contains "-ldes". Depending on your system and where the
-DES library was installed, you may also need to alter the include and
-library paths used by your compiler.
-
-Do a "make clean" and then a "make" to rebuild pppd. Assuming all
-goes well, install the new pppd and move on to the CONFIGURATION
-section.
-
-
-CONFIGURATION
-
-If you've never used PPPD with CHAP before, read the man page (type
-"man pppd") and read the description in there. Basically, you need to
-edit the "chap-secrets" file typically named /etc/ppp/chap-secrets.
-This should contain the following two lines for each system with which
-you use CHAP (with no leading blanks):
-
- RemoteHost Account Secret
- Account RemoteHost Secret
-
-Note that you need both lines and that item 1 and 2 are swapped in the
-second line. I'm not sure why you need it twice, but it works and I didn't
-have time to look into it further. The "RemoteHost" is a somewhat
-arbitrary name for the remote Windows NT system you're dialing. It doesn't
-have to match the NT system's name, but it *does* have to match what you
-use with the "remotename" parameter. The "Account" is the Windows NT
-account name you have been told to use when dialing, and the "Secret" is
-the password for that account. For example, if your service provider calls
-their machine "DialupNT" and tells you your account and password are
-"customer47" and "foobar", add the following to your chap-secrets file:
-
- DialupNT customer47 foobar
- customer47 DialupNT foobar
-
-The only other thing you need to do for MS-CHAP (compared to normal CHAP)
-is to always use the "remotename" option, either on the command line or in
-your "options" file (see the pppd man page for details). In the case of
-the above example, you would need to use the following command line:
-
- pppd name customer47 remotename DialupNT <other options>
-
-or add:
-
- name customer47
- remotename DialupNT
-
-to your PPPD "options" file.
-
-The "remotename" option is required for MS-CHAP since Microsoft PPP servers
-don't send their system name in the CHAP challenge packet.
-
-
-E=691 (AUTHENTICATION_FAILURE) ERRORS WHEN YOU HAVE THE VALID SECRET (PASSWORD)
-
-If your RAS server is not the domain controller and is not a 'stand-alone'
-server then it must make a query to the domain controller for your domain.
-
-You need to specify the domain name with the user name when you attempt to
-use this type of a configuration. The domain name is specified with the
-local name in the chap-secrets file and with the option for the 'name'
-parameter.
-
-For example, the previous example would become:
-
- DialupNT domain\\customer47 foobar
- domain\\customer47 DialupNT foobar
-
-and
-
- pppd name 'domain\\customer47' remotename DialupNT <other options>
-
-or add:
-
- name domain\\customer47
- remotename DialupNT
-
-when the Windows NT domain name is simply called 'domain'.
-
-
-TROUBLESHOOTING
-
-Assuming that everything else has been configured correctly for PPP and
-CHAP, the MS-CHAP-specific problems you're likely to encounter are mostly
-related to your Windows NT account and its settings. A Microsoft server
-returns error codes in its CHAP response. The following are extracted from
-Microsoft's "chapexts.txt" file referenced above:
-
- 646 ERROR_RESTRICTED_LOGON_HOURS
- 647 ERROR_ACCT_DISABLED
- 648 ERROR_PASSWD_EXPIRED
- 649 ERROR_NO_DIALIN_PERMISSION
- 691 ERROR_AUTHENTICATION_FAILURE
- 709 ERROR_CHANGING_PASSWORD
-
-You'll see these in your pppd log as a line similar to:
-
- Remote message: E=649 R=0
-
-The "E=" is the error number from the table above, and the "R=" flag
-indicates whether the error is transient and the client should retry. If
-you consistently get error 691, then either you're using the wrong account
-name/password, or the DES library or MD4 hashing (in md4.c) aren't working
-properly. Verify your account name and password (use a Windows NT or
-Windows 95 system to dial-in if you have one available). If that checks
-out, test the DES library with the "destest" program included with the DES
-library. If DES checks out, the md4.c routines are probably failing
-(system byte ordering may be a problem) or my code is screwing up. I've
-only got access to a Linux system, so you're on your own for anything else.
-
-Another thing that might cause problems is that some RAS servers won't
-respond at all to LCP config requests without seeing the word "CLIENT"
-from the other end. If you see pppd sending out LCP config requests
-without getting any reply, try putting something in your chat script
-to send the word CLIENT after the modem has connected.
-
-If everything compiles cleanly, but fails at authentication time, then
-it might be a case of the MD4 or DES code screwing up. The following
-small program can be used to test the MS-CHAP code to see if it
-produces a known response:
-
------------------
-#include <stdio.h>
-
-#include "pppd.h"
-#include "chap.h"
-#include "chap_ms.h"
-
-int main(argc, argv)
- int argc;
- char *argv[];
-{
- u_char challenge[8];
- int challengeInt[sizeof(challenge)];
- chap_state cstate;
- int i;
-
- if (argc != 3) {
- fprintf(stderr, "Usage: %s <16-hexchar challenge> <password>\n",
- argv[0]); exit(1);
- }
-
- sscanf(argv[1], "%2x%2x%2x%2x%2x%2x%2x%2x",
- challengeInt + 0, challengeInt + 1, challengeInt + 2,
- challengeInt + 3, challengeInt + 4, challengeInt + 5,
- challengeInt + 6, challengeInt + 7);
-
- for (i = 0; i < sizeof(challenge); i++)
- challenge[i] = (u_char)challengeInt[i];
-
- ChapMS(&cstate, challenge, sizeof(challenge), argv[2], strlen(argv[2]));
- printf("Response length is %d, response is:", cstate.resp_length);
-
- for (i = 0; i < cstate.resp_length; i++) {
- if (i % 8 == 0)
- putchar('\n');
- printf("%02X ", (unsigned int)cstate.response[i]);
- }
-
- putchar('\n');
-
- exit(0);
-}
--------------
-
-This needs to link against chap_ms.o, md4.o, and the DES library. When
-you run it with the command line:
-
- $ testchap 00000000000000000000000000000000 hello
-
-it should output the following:
-
- Response length is 49, response is:
- 00 00 00 00 00 00 00 00
- 00 00 00 00 00 00 00 00
- 00 00 00 00 00 00 00 00
- F4 D9 9D AF 82 64 DC 3C
- 53 F9 BC 92 14 B5 5D 9E
- 78 C4 21 48 9D B7 A8 B4
- 01
-
-if not, then either the DES library is not working, the MD4 code isn't
-working, or there are some problems with the port of the code in
-chap_ms.c.
-
-
-STILL TO DO
-
-A site using only MS-CHAP to authenticate has no need to store cleartext
-passwords in the "chap-secrets" file. A utility that spits out the ASCII
-hex MD4 hash of a given password would be nice, and would allow that hash
-to be used in chap-secrets in place of the password. The code to do this
-could quite easily be lifted from chap_ms.c (you have to convert the
-password to Unicode before hashing it). The chap_ms.c file would also have
-to be changed to recognize a password hash (16 binary bytes == 32 ASCII hex
-characters) and skip the hashing stage.
-
-A server implementation would allow MS-CHAP to be used with Windows NT and
-Windows 95 clients for enhanced security. Some new command-line options
-would be required, as would code to generate the Challenge packet and
-verify the response. Most of the helper functions are in place, so this
-shouldn't be too hard for someone to add.
diff --git a/mdk-stage1/ppp/README.cbcp b/mdk-stage1/ppp/README.cbcp
deleted file mode 100644
index 6f7b7685e..000000000
--- a/mdk-stage1/ppp/README.cbcp
+++ /dev/null
@@ -1,97 +0,0 @@
- Microsoft Call Back Configuration Protocol.
- by Pedro Roque Marques
- (updated by Paul Mackerras)
-
-The CBCP is a method by which the Microsoft Windows NT Server may
-implement additional security. It is possible to configure the server
-in such a manner so as to require that the client systems which
-connect with it are required that following a valid authentication to
-leave a method by which the number may be returned call.
-
-It is a requirement of servers so configured that the protocol be
-exchanged.
-
-So, this set of patches may be applied to the pppd process to enable
-the cbcp client *only* portion of the specification. It is primarily
-meant to permit connection with Windows NT Servers.
-
-The ietf-working specification may be obtained from ftp.microsoft.com
-in the developr/rfc directory.
-
-The ietf task group has decided to recommend that the LCP sequence be
-extended to permit the callback operation. For this reason, these
-patches are not 'part' of pppd but are an adjunct to the code.
-
-To enable CBCP support, all that is required is to change the
-appropriate Makefile in the pppd subdirectory to add "-DCBCP_SUPPORT"
-to the CFLAGS definition and add cbcp.o to the list of object files,
-and then recompile pppd. The patch below does this for Makefile.bsd
-and Makefile.linux.
-
-
---------------------------------cut here-------------------------------
-diff -r -c ppp-2.3.orig/pppd/Makefile.bsd ppp-2.3/pppd/Makefile.bsd
-*** ppp-2.3.orig/pppd/Makefile.bsd Tue Oct 8 13:33:33 1996
---- ppp-2.3/pppd/Makefile.bsd Fri Apr 11 23:59:15 1997
-***************
-*** 4,14 ****
- # -D_BITYPES is for FreeBSD, which doesn't define anything to
- # tell us that u_int32_t gets defined if <sys/types.h> is included.
- # Remove for older *BSD systems for which this isn't true.
-! CFLAGS+= -g -I.. -DHAVE_PATHS_H -D_BITYPES
-
- PROG= pppd
- SRCS= main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
-! demand.c auth.c options.c sys-bsd.c
- MAN= pppd.cat8
- MAN8= pppd.8
- BINMODE=4555
---- 4,14 ----
- # -D_BITYPES is for FreeBSD, which doesn't define anything to
- # tell us that u_int32_t gets defined if <sys/types.h> is included.
- # Remove for older *BSD systems for which this isn't true.
-! CFLAGS+= -I.. -DHAVE_PATHS_H -D_BITYPES -DCBCP_SUPPORT
-
- PROG= pppd
- SRCS= main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
-! demand.c auth.c options.c sys-bsd.c cbcp.c
- MAN= pppd.cat8
- MAN8= pppd.8
- BINMODE=4555
-diff -r -c ppp-2.3.orig/pppd/Makefile.linux ppp-2.3/pppd/Makefile.linux
-*** ppp-2.3.orig/pppd/Makefile.linux Tue Oct 8 15:42:41 1996
---- ppp-2.3/pppd/Makefile.linux Sat Apr 12 00:02:28 1997
-***************
-*** 14,20 ****
- ipxcp.h cbcp.h
- MANPAGES = pppd.8
- PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
-! auth.o options.o demand.o sys-linux.o ipxcp.o
-
- all: pppd
-
---- 14,20 ----
- ipxcp.h cbcp.h
- MANPAGES = pppd.8
- PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
-! auth.o options.o demand.o sys-linux.o ipxcp.o cbcp.o
-
- all: pppd
-
-***************
-*** 36,42 ****
- #INCLUDE_DIRS= -I/usr/include -I..
- INCLUDE_DIRS=
-
-! COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE
-
- CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
-
---- 36,42 ----
- #INCLUDE_DIRS= -I/usr/include -I..
- INCLUDE_DIRS=
-
-! COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DCBCP_SUPPORT
-
- CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
-
diff --git a/mdk-stage1/ppp/README.linux b/mdk-stage1/ppp/README.linux
deleted file mode 100644
index 62ed9ca7f..000000000
--- a/mdk-stage1/ppp/README.linux
+++ /dev/null
@@ -1,297 +0,0 @@
- PPP for Linux
- -------------
-
- Paul Mackerras
- 8 March 2001
-
- for ppp-2.4.1
-
-1. Introduction
----------------
-
-The Linux PPP implementation includes both kernel and user-level
-parts. This package contains the user-level part, which consists of
-the PPP daemon (pppd) and associated utilities. In the past this
-package has contained updated kernel drivers. This is no longer
-necessary, as the current 2.2 and 2.4 kernel sources contain
-up-to-date drivers.
-
-The Linux PPP implementation is capable of being used both for
-initiating PPP connections (as a `client') or for handling incoming
-PPP connections (as a `server'). Note that this is an operational
-distinction, based on how the connection is created, rather than a
-distinction that is made in the PPP protocols themselves.
-
-Mostly this package is used for PPP connections over modems connected
-via asynchronous serial ports, so this guide concentrates on this
-situation.
-
-The PPP protocol consists of two parts. One is a scheme for framing
-and encoding packets, the other is a series of protocols called LCP,
-IPCP, PAP and CHAP, for negotiating link options and for
-authentication. This package similarly consists of two parts: a
-kernel module which handles PPP's low-level framing protocol, and a
-user-level program called pppd which implements PPP's negotiation
-protocols.
-
-The kernel module assembles/disassembles PPP frames, handles error
-detection, and forwards packets between the serial port and either the
-kernel network code or the user-level program pppd. IP packets go
-directly to the kernel network code. So once pppd has negotiated the
-link, it in practice lies completely dormant until you want to take
-the link down, when it negotiates a graceful disconnect.
-
-
-2. Installation
----------------
-
-2.1 Kernel driver
-
-Assuming you are running a recent 2.2 or 2.4 (or later) series kernel,
-the kernel source code will contain an up-to-date kernel PPP driver.
-If the PPP driver was included in your kernel configuration when your
-kernel was built, then you only need to install the user-level
-programs. Otherwise you will need to get the source tree for your
-kernel version, configure it with PPP included, and recompile. Most
-Linux distribution vendors ship kernels with PPP included in the
-configuration.
-
-The PPP driver can be either compiled into the kernel or compiled as a
-kernel module. If it is compiled into the kernel, the PPP driver is
-included in the kernel image which is loaded at boot time. If it is
-compiled as a module, the PPP driver is present in one or more files
-under /lib/modules and is loaded into the kernel when needed.
-
-The 2.2 series kernels contain an older version of the kernel PPP
-driver, one which doesn't support multilink. If you want multilink,
-you need to run the latest 2.4 series kernel. The kernel PPP driver
-was completely rewritten for the 2.4 series kernels to support
-multilink and to allow it to operate over diverse kinds of
-communication medium (the 2.2 driver only operates over serial ports
-and devices which look like serial ports, such as pseudo-ttys).
-
-Under the 2.2 kernels, if PPP is compiled as a module, the PPP driver
-modules should be present in the /lib/modules/`uname -r`/net directory
-(where `uname -r` represents the kernel version number). The PPP
-driver module itself is called ppp.o, and there will usually be
-compression modules there, ppp_deflate.o and bsd_comp.o, as well as
-slhc.o, which handles TCP/IP header compression. If the PPP driver is
-compiled into the kernel, the compression code will still be compiled
-as modules, for kernels before 2.2.17pre12. For 2.2.17pre12 and later,
-if the PPP driver is compiled in, the compression code will also.
-
-Under the 2.4 kernels, there are two PPP modules, ppp_generic.o and
-ppp_async.o, plus the compression modules (ppp_deflate.o, bsd_comp.o
-and slhc.o). If the PPP generic driver is compiled into the kernel,
-the other four can then be present either as modules or compiled into
-the kernel. There is a sixth module, ppp_synctty.o, which is used for
-synchronous tty devices such as high-speed WAN adaptors.
-
-
-2.2 User-level programs
-
-If you obtained this package in .rpm or .deb format, you simply follow
-the usual procedure for installing the package.
-
-If you are using the .tar.gz form of this package, then cd into the
-ppp-2.4.1b1 directory you obtained by unpacking the archive and issue
-the following commands:
-
-$ ./configure
-$ make
-# make install
-
-The `make install' has to be done as root. This makes and installs
-four programs and their man pages: pppd, chat, pppstats and pppdump.
-If the /etc/ppp configuration directory doesn't exist, the `make
-install' step will create it and install some default configuration
-files.
-
-
-2.3 System setup for 2.4 kernels
-
-Under the 2.4 series kernels, pppd needs to be able to open /dev/ppp,
-character device (108,0). If you are using devfs (the device
-filesystem), the /dev/ppp node will automagically appear when the
-ppp_generic module is loaded, or at startup if ppp_generic is compiled
-in.
-
-If you have ppp_generic as a module, and you are using devfsd (the
-devfs daemon), you will need to add a line like this to your
-/etc/devfsd.conf:
-
-LOOKUP ppp MODLOAD
-
-Otherwise you will need to create a /dev/ppp device node with the
-commands:
-
-# mknod /dev/ppp c 108 0
-# chmod 600 /dev/ppp
-
-If you use module autoloading and have PPP as a module, you will need
-to add the following to your /etc/modules.conf or /etc/conf.modules:
-
-alias /dev/ppp ppp_generic
-alias char-major-108 ppp_generic
-alias tty-ldisc-3 ppp_async
-alias tty-ldisc-14 ppp_synctty
-alias ppp-compress-21 bsd_comp
-alias ppp-compress-24 ppp_deflate
-alias ppp-compress-26 ppp_deflate
-
-
-2.4 System setup under 2.2 series kernels
-
-Under the 2.2 series kernels, you should add the following to your
-/etc/modules.conf or /etc/conf.modules:
-
-alias tty-ldisc-3 ppp
-alias ppp-compress-21 bsd_comp
-alias ppp-compress-24 ppp_deflate
-alias ppp-compress-26 ppp_deflate
-
-
-3. Getting help with problems
------------------------------
-
-If you have problems with your PPP setup, or you just want to ask some
-questions, or better yet if you can help others with their PPP
-questions, then you should join the linux-ppp mailing list. Send an
-email to majordomo@vger.kernel.org with a line in the body saying
-
-subscribe linux-ppp
-
-To leave the mailing list, send an email to majordomo@vger.kernel.org
-with a line in the body saying
-
-unsubscribe linux-ppp
-
-To send a message to the list, email it to linux-ppp@vger.kernel.org.
-You don't have to be subscribed to send messages to the list.
-
-You can also email me (paulus@linuxcare.com.au) but I am overloaded
-with email and I can't respond to most messages I get in a timely
-fashion.
-
-There are also several relevant news groups, such as comp.protocols.ppp,
-comp.os.linux.networking, or comp.os.linux.setup.
-
-
-4. Configuring your dial-out PPP connections
---------------------------------------------
-
-Some Linux distribution makers include tools in their distributions
-for setting up PPP connections. For example, for Red Hat Linux and
-derivatives, you should probably use linuxconf or netcfg to set up
-your PPP connections.
-
-The two main windowing environments for Linux, KDE and Gnome, both
-come with GUI utilities for configuring and controlling PPP dial-out
-connections. They are convenient and relatively easy to configure.
-
-A third alternative is to use a PPP front-end package such as wvdial
-or ezppp. These also will handle most of the details of talking to
-the modem and setting up the PPP connection for you.
-
-Assuming that you don't want to use any of these tools, you want to
-set up the configuration manually yourself, then read on. This
-document gives a brief description and example. More details can be
-found by reading the pppd and chat man pages and the PPP-HOWTO.
-
-We assume that you have a modem that uses the Hayes-compatible AT
-command set connected to an async serial port (e.g. /dev/ttyS0) and
-that you are dialling out to an ISP.
-
-The trickiest and most variable part of setting up a dial-out PPP
-connection is the part which involves getting the modem to dial and
-then invoking PPP service at the far end. Generally, once both ends
-are talking PPP the rest is relatively straightforward.
-
-Now in fact pppd doesn't know anything about how to get modems to dial
-or what you have to say to the system at the far end to get it to talk
-PPP. That's handled by an external program such as chat, specified
-with the connect option to pppd. Chat takes a series of strings to
-expect from the modem interleaved with a series of strings to send to
-the modem. See the chat man page for more information. Here is a
-simple example for connecting to an ISP, assuming that the ISP's
-system starts talking PPP as soon as it answers the phone:
-
-pppd connect 'chat -v "" AT OK ATDT5551212 ~' \
- /dev/ttyS0 57600 crtscts debug defaultroute
-
-Going through pppd's options in order:
- connect 'chat ...' This gives a command to run to contact the
- PPP server. Here the supplied 'chat' program is used to dial a
- remote computer. The whole command is enclosed in single quotes
- because pppd expects a one-word argument for the 'connect' option.
- The options to 'chat' itself are:
-
- -v verbose mode; log what we do to syslog
- "" don't wait for any prompt, but instead...
- AT send the string "AT"
- OK expect the response "OK", then
- ATDT5551212 dial the modem, then
- ~ wait for a ~ character, indicating the start
- of a PPP frame from the server
-
- /dev/ttyS0 specifies which serial port the modem is connected to
- 57600 specifies the baud rate to use
- crtscts use hardware flow control using the RTS & CTS signals
- debug log the PPP negotiation with syslog
- defaultroute add default network route via the PPP link
-
-Pppd will write error messages and debugging logs to the syslogd
-daemon using the facility name "daemon". These messages may already
-be logged to the console or to a file like /var/log/messages; consult
-your /etc/syslog.conf file to see. If you want to make all pppd
-messages go to a file such as /var/log/ppp-debug, add the line
-
-daemon.* /var/log/ppp-debug
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- This is one or more tabs. Do not use spaces.
-
-to syslog.conf; make sure to put one or more TAB characters (not
-spaces!) between the two fields. Then you need to create an empty
-/var/log/ppp-debug file with a command such as
-
- touch /var/log/ppp-debug
-
-and then restart syslogd, usually by sending it a SIGHUP signal with a
-command like this:
-
- killall -HUP syslogd
-
-
-4.1 Is the link up?
-
-The main way to tell if your PPP link is up and operational is the
-ifconfig ("interface configuration") command. Type
-
- /sbin/ifconfig
-
-at a shell prompt. It should print a list of interfaces including one
-like this example:
-
-ppp0 Link encap Point-to-Point Protocol
- inet addr 192.76.32.3 P-t-P 129.67.1.165 Mask 255.255.255.0
- UP POINTOPOINT RUNNING MTU 1500 Metric 1
- RX packets 33 errors 0 dropped 0 overrun 0
- TX packets 42 errors 0 dropped 0 overrun 0
-
-Assuming that ifconfig shows the ppp network interface, you can test
-the link using the ping command like this:
-
- /sbin/ping -c 3 129.67.1.165
-
-where the address you give is the address shown as the P-t-P address
-in the ifconfig output. If the link is operating correctly, you
-should see output like this:
-
- PING 129.67.1.165 (129.67.1.165): 56 data bytes
- 64 bytes from 129.67.1.165: icmp_seq=0 ttl=255 time=268 ms
- 64 bytes from 129.67.1.165: icmp_seq=1 ttl=255 time=247 ms
- 64 bytes from 129.67.1.165: icmp_seq=2 ttl=255 time=266 ms
- --- 129.67.1.165 ping statistics ---
- 3 packets transmitted, 3 packets received, 0% packet loss
- round-trip min/avg/max = 247/260/268 ms
-
diff --git a/mdk-stage1/ppp/README.sol2 b/mdk-stage1/ppp/README.sol2
deleted file mode 100644
index 4c862208f..000000000
--- a/mdk-stage1/ppp/README.sol2
+++ /dev/null
@@ -1,220 +0,0 @@
-This file describes the installation process for ppp-2.3 on systems
-running Solaris 2. The Solaris 2 and SVR4 ports share a lot of code
-but are not identical. The STREAMS kernel modules and driver for
-Solaris 2 are in the svr4 directory (and use some code from the
-modules directory).
-
-NOTE: Although the kernel driver and modules have been designed to
-operate correctly on SMP systems, they have not been extensively
-tested on SMP machines. Some users of SMP Solaris x86 systems have
-reported system problems apparently linked to the use of previous
-versions of this software. I believe these problems have been fixed.
-
-
-Installation.
-*************
-
-1. Run the configure script and make the user-level programs and the
-kernel modules.
-
- ./configure
- make
-
-If you wish to use gcc (or another compiler) instead of Sun's cc, edit
-the svr4/Makedefs file and uncomment the definition of CC. You can
-also change the options passed to the C compiler by editing the COPTS
-definition.
-
-2. Install the programs and kernel modules: as root, do
-
- make install
-
-This installs pppd, chat and pppstats in /usr/local/bin and the kernel
-modules in /kernel/drv and /kernel/strmod, and creates the /etc/ppp
-directory and populates it with default configuration files. You can
-change the installation directories by editing svr4/Makedefs.
-
-If your system normally has only one network interface, the default
-Solaris 2 system startup scripts will disable IP forwarding in the IP
-kernel module. This will prevent the remote machine from using the
-local machine as a gateway to access other hosts. The solution is to
-create an /etc/ppp/ip-up script containing something like this:
-
- #!/bin/sh
- /usr/sbin/ndd -set /dev/ip ip_forwarding 1
-
-See the man page for ip(7p) for details.
-
-Dynamic STREAMS Re-Plumbing Support.
-************************************
-
-Solaris 8 includes dynamic re-plumbing support. With this, modules
-below ip can be inserted, or removed, without having the ip stream be
-unplumbed, and re-plumbed again. All states in ip for an interface
-will therefore now be preserved. Users can install (or upgrade)
-modules like firewall, bandwidth manager, cache manager, tunneling,
-etc., without shutting the machine down.
-
-To support this, ppp driver now uses /dev/udp instead of /dev/ip for
-the ip stream. The interface stream (where ip module pushed on top of
-ppp) is then I_PLINK'ed below the ip stream. /dev/udp is used because
-STREAMS will not let a driver be PLINK'ed under itself, and /dev/ip is
-typically the driver at the bottom of the tunneling interfaces
-stream. The mux ids of the ip streams are then added using
-SIOCSxIFMUXID ioctl.
-
-Users will be able to see the modules on the interface stream by, for
-example:
-
- pikapon% ifconfig ppp modlist
- 0 ip
- 1 ppp
-
-Or arbitrarily if bandwidth manager and firewall modules are installed:
-
- pikapon% ifconfig hme0 modlist
- 0 arp
- 1 ip
- 2 ipqos
- 3 firewall
- 4 hme
-
-Snoop Support.
-**************
-
-This version includes support for /usr/sbin/snoop. Tests has been done
-on both Solaris 7 and 8. Only IPv4 and IPv6 packets will be sent up to
-stream(s) marked as promiscuous, e.g, snoop et al.
-
-Users will be able to see the packets on the ppp interface by, for example:
-
- snoop -d ppp0
-
-See the man page for snoop(1M) for details.
-
-IPv6 Support.
-*************
-
-This is for Solaris 8 and later.
-
-This version has been tested under Solaris 8 running IPv6. As of now,
-interoperability testing has only been done between Solaris machines
-in terms of the IPV6 NCP. An additional command line option for the
-pppd daemon has been added: ipv6cp-use-persistent.
-
-By default, compilation for IPv6 support is not enabled. Uncomment
-the necessary lines in pppd/Makefile.sol2 to enable it. Once done, the
-quickest way to get IPv6 running is to add the following somewhere in
-the command line option:
-
- +ipv6 ipv6cp-use-persistent
-
-The persistent id for the link-local address was added to conform to
-RFC 2472; such that if there's an EUI-48 available, use that to make
-up the EUI-64. As of now, the Solaris implementation extracts the
-EUI-48 id from the Ethernet's MAC address (the ethernet interface
-needs to be up). Future works might support other ways of obtaining a
-unique yet persistent id, such as EEPROM serial numbers, etc.
-
-There need not be any up/down scripts for ipv6, e.g. /etc/ppp/ipv6-up
-or /etc/ppp/ipv6-down, to trigger IPv6 neighbor discovery for auto
-configuration and routing. The in.ndpd daemon will perform all of the
-necessary jobs in the background. /etc/inet/ndpd.conf can be further
-customized to enable the machine as an IPv6 router. See the man page
-for in.ndpd(1M) and ndpd.conf(4) for details.
-
-Below is a sample output of "ifconfig -a" with persistent link-local
-address. Note the UNNUMBERED flag is set because hme0 and ppp0 both
-have identical link-local IPv6 addresses:
-
-lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
- inet 127.0.0.1 netmask ff000000
-hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
- inet 129.146.86.248 netmask ffffff00 broadcast 129.146.86.255
- ether 8:0:20:8d:38:c1
-lo0: flags=2000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6> mtu 8252 index 1
- inet6 ::1/128
-hme0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2
- ether 8:0:20:8d:38:c1
- inet6 fe80::a00:20ff:fe8d:38c1/10
-hme0:1: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
- inet6 fec0::56:a00:20ff:fe8d:38c1/64
-hme0:2: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
- inet6 2000::56:a00:20ff:fe8d:38c1/64
-hme0:3: flags=2080841<UP,RUNNING,MULTICAST,ADDRCONF,IPv6> mtu 1500 index 2
- inet6 2::56:a00:20ff:fe8d:38c1/64
-ppp0: flags=10008d1<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4> mtu 1500 index 12
- inet 172.16.1.1 --> 172.16.1.2 netmask ffffff00
-ppp0: flags=2202851<UP,POINTOPOINT,RUNNING,MULTICAST,UNNUMBERED,NONUD,IPv6> mtu 1500 index 12
- inet6 fe80::a00:20ff:fe8d:38c1/10 --> fe80::a00:20ff:fe7a:24fb
-
-Note also that a plumbed ipv6 interface stream will exist throughout
-the entire PPP session in the case where the peer rejects IPV6CP,
-which further causes the interface state to stay down. Unplumbing will
-happen when the daemon exits. This is done by design and is not a bug.
-
-64-bit Support.
-***************
-
-This version has been tested under Solaris 7 (and Solaris 8 ) in both
-32- and 64-bits environments (Ultra class machines). Installing the
-package by executing "make install" will result in additional files
-residing in /kernel/drv/sparcv9 and /kernel/strmod/sparcv9
-subdirectories.
-
-64-bit modules and driver have been compiled and tested using Sun's cc.
-
-Synchronous Serial Support.
-***************************
-
-This version has working but limited support for the on-board
-synchronous HDLC interfaces. It has been tested with the /dev/se_hdlc
-and /dev/zsh drivers. Synchronous mode was tested with a Cisco
-router.
-
-There ppp daemon does not directly support controlling the serial
-interface. It relies on the /usr/sbin/syncinit command to initialize
-HDLC mode and clocking.
-
-Some bugs remain: large sized frames are not sent/received properly,
-and may be related to the IP mtu. This may be due to bugs in pppd
-itself, bugs in Solaris or the serial drivers. The /dev/zsh driver
-seems more larger and can send/receive larger frames than the
-/dev/se_hdlc driver. There is a confirmed bug with NRZ/NRZI mode in
-the /dev/se_hdlc driver, and Solaris patch 104596-11 is needed to
-correct it. (However this patch seems to introduce other serial
-problems. If you don't apply the patch, the workaround is to change
-the nrzi mode to yes or no, whichever works)
-
-How to start pppd with synchronous support:
-
-#!/bin/sh
-
-local=1.1.1.1 # your ip address here
-baud=38400 # needed, but ignored by serial driver
-
-# Change to the correct serial driver/port
-#dev=/dev/zsh0
-dev=/dev/se_hdlc0
-
-# Change the driver, nrzi mode, speed and clocking to match your setup
-# This configuration is for external clocking from the DCE
-connect="syncinit se_hdlc0 nrzi=no speed=64000 txc=rxc rxc=rxc"
-
-/usr/sbin/pppd $dev sync $baud novj noauth $local: connect "$connect"
-
-
-Sample Cisco router config excerpt:
-
-!
-! Cisco router setup as DCE with RS-232 DCE cable
-!
-!
-interface Serial0
- ip address 1.1.1.2 255.255.255.0
- encapsulation ppp
- clockrate 64000
- no nrzi-encoding
- no shutdown
-!
-
diff --git a/mdk-stage1/ppp/README.sunos4 b/mdk-stage1/ppp/README.sunos4
deleted file mode 100644
index b48aec377..000000000
--- a/mdk-stage1/ppp/README.sunos4
+++ /dev/null
@@ -1,62 +0,0 @@
-This file describes the installation process for ppp-2.3 on systems
-running SunOS 4.1.x (or the equivalent).
-
-The STREAMS modules in the sunos4 directory provide kernel support for
-PPP on SunOS 4.1.x systems. They have been tested under SunOS 4.1.3
-on a SparcStation 1+. They should work under earlier SunOS 4.1.x
-systems, but no guarantees are given.
-
-These modules are designed to be loaded into the running kernel using
-the `modload' command.
-
-
-Installation.
-*************
-
-1. Run the configure script and make the user-level programs and the
-kernel modules.
-
- ./configure
- make
-
-If you wish to compile using gcc instead of cc, edit the
-sunos4/Makedefs file and uncomment the line saying "CC = gcc". You
-can also change the C compiler options by editing the COPTS
-definition.
-
-2. Install the pppd, pppstats and chat programs and the loadable
-module object files (you need to be root to do this):
-
- make install
-
-By default, the programs and the loadable module object files go into
-/usr/local/etc. Doing `make install' also copies a script called
-ppp.INSTALL into /dev, and makes ppp.LOAD, ppp.UNLOAD, ppp.MKDEV and
-ppp.RMDEV links to it. You can change the installation directories by
-editing sunos4/Makedefs.
-
-3. Load the ppp modules (you need to be root for this too):
-
- /dev/ppp.LOAD
-
-You will want to do this in your /etc/rc.local file once you have
-everything installed. I suggest you put something like the following
-in /etc/rc.local (or /etc/loadable, if you have one):
-
- if [ -f /dev/ppp.AUTOLOAD ]; then
- /dev/ppp.LOAD
- fi
-
-and then create a /dev/ppp.AUTOLOAD file with the command
-
- touch /dev/ppp.AUTOLOAD
-
-It is not advisable to unload the "if_ppp" module, because it creates
-network interface units, and SunOS does not provide any way to destroy
-network interfaces once created. If you do unload it, the system will
-probably crash at some later stage.
-
-If you have previously had ppp-2.2 installed, you may have statements
-in your /etc/rc.local to load the ppp module. You will need to remove
-those. Having done this, you will need to reboot to remove the old
-ppp module and load the new modules.
diff --git a/mdk-stage1/ppp/SETUP b/mdk-stage1/ppp/SETUP
deleted file mode 100644
index fb28a2138..000000000
--- a/mdk-stage1/ppp/SETUP
+++ /dev/null
@@ -1,111 +0,0 @@
- Configuring a PPP link.
-
-After you have compiled and installed this package, there are some
-configuration files which will generally need to be set up. The
-pppd(8) man page is the best reference for the full details; this file
-outlines the configuration process for the most common case, where
-this package is being used to enable a machine to dial an ISP and
-connect to the internet. The FAQ and README.linux files also provide
-useful information about setting up PPP.
-
-Dialling an ISP.
-****************
-
-Usually, an ISP will assign an IP address to your machine, and will
-refuse to authenticate itself to you. Some ISPs require a username
-and password to be entered before PPP service commences, while others
-use PPP authentication (using either the PAP or CHAP protocols).
-
-The recommended way to set up to dial an ISP is for the system
-administrator to create a file under /etc/ppp/peers, named for the ISP
-that you will be dialling. For example, suppose the file is called
-/etc/ppp/peers/isp. This file would contain something like this:
-
-cua0 # modem is connected to /dev/cua0
-38400 # run the serial port at 38400 baud
-crtscts # use hardware flow control
-noauth # don't require the ISP to authenticate itself
-defaultroute # use the ISP as our default route
-connect '/usr/sbin/chat -v -f /etc/ppp/chat-isp'
-
-If there are any other pppd options that should apply when calling
-this ISP, they can also be placed in this file.
-
-The /etc/ppp/chat-isp file named in the last line contains the script
-for chat(8) to use to dial the ISP and go through any username/
-password authentication required before PPP service starts. Here is
-an example (for dialling an Annex terminal server):
-
-ABORT "NO CARRIER"
-ABORT "NO DIALTONE"
-ABORT "ERROR"
-ABORT "NO ANSWER"
-ABORT "BUSY"
-ABORT "Username/Password Incorrect"
-"" "at"
-OK "at&d2&c1"
-OK "atdt2479381"
-"name:" "^Uusername"
-"word:" "\qpassword"
-"annex" "ppp"
-"Switching to PPP-ppp-Switching to PPP"
-
-See the chat(8) man page for details of the script. If you are not
-sure how the initial dialog with your ISP will go, you could use
-a terminal emulator such as kermit or minicom to go through the
-process manually.
-
-If your ISP requires PAP or CHAP authentication, you will have to
-create a line in /etc/ppp/pap-secrets or /etc/ppp/chap-secrets like
-this:
-
-myhostname * "password"
-
-(Replace myhostname with the hostname of your machine.)
-
-At this point, you can initiate the link with the command:
-
-/usr/sbin/pppd call isp
-
-(N.B.: pppd might be installed in a different directory on some
-systems).
-
-This will return to the shell prompt immediately, as pppd will detach
-itself from its controlling terminal. (If you don't want it to do
-this, use the "nodetach" option.)
-
-Pppd will log messages describing the progress of the connection and
-any errors using the syslog facility (see the syslogd(8) and
-syslog.conf(5) man pages). Pppd issues messages using syslog facility
-daemon (or local2 if it has been compiled with debugging enabled);
-chat uses facility local2. It is often useful to see messages of
-priority notice or higher on the console. To see these, find the line
-in /etc/syslog.conf which has /dev/console on the right-hand side, and
-add `daemon.notice' on the left. This line should end up something
-like this:
-
-*.err;kern.debug;daemon,local2,auth.notice;mail.crit /dev/console
-
-If you want to see more messages from pppd, request messages of
-priority info or higher for facility daemon, like this:
-
-*.err;kern.debug;daemon.info;local2,auth.notice;mail.crit /dev/console
-
-It is also useful to add a line like this:
-
-daemon,local2.debug /etc/ppp/ppp-log
-
-If you do this, you will need to create an empty /etc/ppp/ppp-log
-file.
-
-After modifying syslog.conf, you will then need to send a HUP signal
-to syslogd (or reboot).
-
-When you wish terminate the PPP link, you should send a TERM or INTR
-signal to pppd. Pppd writes its process ID to a file called
-ppp<n>.pid in /var/run (or /etc/ppp on older systems such as SunOS or
-Ultrix). Here <n> is the PPP interface unit number, which will be 0
-unless you have more than one PPP link running simultaneously. Thus
-you can terminate the link with a command like
-
- kill `cat /var/run/ppp0.pid`
diff --git a/mdk-stage1/ppp/chat/Makefile.linux b/mdk-stage1/ppp/chat/Makefile.linux
deleted file mode 100644
index 586cbd876..000000000
--- a/mdk-stage1/ppp/chat/Makefile.linux
+++ /dev/null
@@ -1,27 +0,0 @@
-# $Id$
-
-CDEF1= -DTERMIOS # Use the termios structure
-CDEF2= -DSIGTYPE=void # Standard definition
-CDEF3= -UNO_SLEEP # Use the usleep function
-CDEF4= -DFNDELAY=O_NDELAY # Old name value
-CDEFS= $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)
-
-CFLAGS= $(RPM_OPT_FLAGS) $(CDEFS)
-
-INSTALL= install
-
-all: chat
-
-chat: chat.o
- $(CC) -o chat chat.o
-
-chat.o: chat.c
- $(CC) -c $(CFLAGS) -o chat.o chat.c
-
-install: chat
- mkdir -p $(BINDIR)
- $(INSTALL) -s -c chat $(BINDIR)
- $(INSTALL) -c -m 644 chat.8 $(MANDIR)/man8
-
-clean:
- rm -f chat.o chat *~
diff --git a/mdk-stage1/ppp/chat/Makefile.linux.makeopt b/mdk-stage1/ppp/chat/Makefile.linux.makeopt
deleted file mode 100644
index 974680a93..000000000
--- a/mdk-stage1/ppp/chat/Makefile.linux.makeopt
+++ /dev/null
@@ -1,27 +0,0 @@
-# $Id$
-
-CDEF1= -DTERMIOS # Use the termios structure
-CDEF2= -DSIGTYPE=void # Standard definition
-CDEF3= -UNO_SLEEP # Use the usleep function
-CDEF4= -DFNDELAY=O_NDELAY # Old name value
-CDEFS= $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)
-
-CFLAGS= -O2 -g -pipe $(CDEFS)
-
-INSTALL= install
-
-all: chat
-
-chat: chat.o
- $(CC) -o chat chat.o
-
-chat.o: chat.c
- $(CC) -c $(CFLAGS) -o chat.o chat.c
-
-install: chat
- mkdir -p $(BINDIR)
- $(INSTALL) -s -c chat $(BINDIR)
- $(INSTALL) -c -m 644 chat.8 $(MANDIR)/man8
-
-clean:
- rm -f chat.o chat *~
diff --git a/mdk-stage1/ppp/chat/Makefile.sol2 b/mdk-stage1/ppp/chat/Makefile.sol2
deleted file mode 100644
index f566cc68b..000000000
--- a/mdk-stage1/ppp/chat/Makefile.sol2
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for chat on Solaris 2
-#
-
-include ../solaris/Makedefs
-
-CFLAGS = $(COPTS) -DNO_USLEEP -DSOL2
-
-all: chat
-
-chat: chat.o
- $(CC) -o chat chat.o
-
-install: chat
- $(INSTALL) -f $(BINDIR) chat
- $(INSTALL) -m 444 -f $(MANDIR)/man8 chat.8
-
-clean:
- rm -f *~ *.o chat
diff --git a/mdk-stage1/ppp/chat/Makefile.sunos4 b/mdk-stage1/ppp/chat/Makefile.sunos4
deleted file mode 100644
index b3507360e..000000000
--- a/mdk-stage1/ppp/chat/Makefile.sunos4
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Makefile for chat on suns
-#
-
-include ../sunos4/Makedefs
-
-CFLAGS = -DSUNOS $(COPTS)
-
-all: chat
-
-chat: chat.o
- $(CC) -o chat chat.o
-
-install: chat
- $(INSTALL) -c chat $(BINDIR)/chat
- $(INSTALL) -c -m 444 chat.8 $(MANDIR)/man8/chat.8
-
-clean:
- rm -f *~ *.o chat
diff --git a/mdk-stage1/ppp/chat/chat.8 b/mdk-stage1/ppp/chat/chat.8
deleted file mode 100644
index 8d2029609..000000000
--- a/mdk-stage1/ppp/chat/chat.8
+++ /dev/null
@@ -1,515 +0,0 @@
-.\" -*- nroff -*-
-.\" manual page [] for chat 1.8
-.\" $Id$
-.\" SH section heading
-.\" SS subsection heading
-.\" LP paragraph
-.\" IP indented paragraph
-.\" TP hanging label
-.TH CHAT 8 "22 May 1999" "Chat Version 1.22"
-.SH NAME
-chat \- Automated conversational script with a modem
-.SH SYNOPSIS
-.B chat
-[
-.I options
-]
-.I script
-.SH DESCRIPTION
-.LP
-The \fIchat\fR program defines a conversational exchange between the
-computer and the modem. Its primary purpose is to establish the
-connection between the Point-to-Point Protocol Daemon (\fIpppd\fR) and
-the remote's \fIpppd\fR process.
-.SH OPTIONS
-.TP
-.B -f \fI<chat file>
-Read the chat script from the chat \fIfile\fR. The use of this option
-is mutually exclusive with the chat script parameters. The user must
-have read access to the file. Multiple lines are permitted in the
-file. Space or horizontal tab characters should be used to separate
-the strings.
-.TP
-.B -t \fI<timeout>
-Set the timeout for the expected string to be received. If the string
-is not received within the time limit then the reply string is not
-sent. An alternate reply may be sent or the script will fail if there
-is no alternate reply string. A failed script will cause the
-\fIchat\fR program to terminate with a non-zero error code.
-.TP
-.B -r \fI<report file>
-Set the file for output of the report strings. If you use the keyword
-\fIREPORT\fR, the resulting strings are written to this file. If this
-option is not used and you still use \fIREPORT\fR keywords, the
-\fIstderr\fR file is used for the report strings.
-.TP
-.B -e
-Start with the echo option turned on. Echoing may also be turned on
-or off at specific points in the chat script by using the \fIECHO\fR
-keyword. When echoing is enabled, all output from the modem is echoed
-to \fIstderr\fR.
-.TP
-.B -E
-Enables environment variable substituion within chat scripts using the
-standard \fI$xxx\fR syntax.
-.TP
-.B -v
-Request that the \fIchat\fR script be executed in a verbose mode. The
-\fIchat\fR program will then log the execution state of the chat
-script as well as all text received from the modem and the output
-strings sent to the modem. The default is to log through the SYSLOG;
-the logging method may be altered with the -S and -s flags.
-.TP
-.B -V
-Request that the \fIchat\fR script be executed in a stderr verbose
-mode. The \fIchat\fR program will then log all text received from the
-modem and the output strings sent to the modem to the stderr device. This
-device is usually the local console at the station running the chat or
-pppd program.
-.TP
-.B -s
-Use stderr. All log messages from '-v' and all error messages will be
-sent to stderr.
-.TP
-.B -S
-Do not use the SYSLOG. By default, error messages are sent to the
-SYSLOG. The use of -S will prevent both log messages from '-v' and
-error messages from being sent to the SYSLOG.
-.TP
-.B -T \fI<phone number>
-Pass in an arbitary string, usually a phone number, that will be
-substituted for the \\T substitution metacharacter in a send string.
-.TP
-.B -U \fI<phone number 2>
-Pass in a second string, usually a phone number, that will be
-substituted for the \\U substitution metacharacter in a send string.
-This is useful when dialing an ISDN terminal adapter that requires two
-numbers.
-.TP
-.B script
-If the script is not specified in a file with the \fI-f\fR option then
-the script is included as parameters to the \fIchat\fR program.
-.SH CHAT SCRIPT
-.LP
-The \fIchat\fR script defines the communications.
-.LP
-A script consists of one or more "expect-send" pairs of strings,
-separated by spaces, with an optional "subexpect-subsend" string pair,
-separated by a dash as in the following example:
-.IP
-ogin:-BREAK-ogin: ppp ssword: hello2u2
-.LP
-This line indicates that the \fIchat\fR program should expect the string
-"ogin:". If it fails to receive a login prompt within the time interval
-allotted, it is to send a break sequence to the remote and then expect the
-string "ogin:". If the first "ogin:" is received then the break sequence is
-not generated.
-.LP
-Once it received the login prompt the \fIchat\fR program will send the
-string ppp and then expect the prompt "ssword:". When it receives the
-prompt for the password, it will send the password hello2u2.
-.LP
-A carriage return is normally sent following the reply string. It is not
-expected in the "expect" string unless it is specifically requested by using
-the \\r character sequence.
-.LP
-The expect sequence should contain only what is needed to identify the
-string. Since it is normally stored on a disk file, it should not contain
-variable information. It is generally not acceptable to look for time
-strings, network identification strings, or other variable pieces of data as
-an expect string.
-.LP
-To help correct for characters which may be corrupted during the initial
-sequence, look for the string "ogin:" rather than "login:". It is possible
-that the leading "l" character may be received in error and you may never
-find the string even though it was sent by the system. For this reason,
-scripts look for "ogin:" rather than "login:" and "ssword:" rather than
-"password:".
-.LP
-A very simple script might look like this:
-.IP
-ogin: ppp ssword: hello2u2
-.LP
-In other words, expect ....ogin:, send ppp, expect ...ssword:, send hello2u2.
-.LP
-In actual practice, simple scripts are rare. At the vary least, you
-should include sub-expect sequences should the original string not be
-received. For example, consider the following script:
-.IP
-ogin:--ogin: ppp ssword: hello2u2
-.LP
-This would be a better script than the simple one used earlier. This would look
-for the same login: prompt, however, if one was not received, a single
-return sequence is sent and then it will look for login: again. Should line
-noise obscure the first login prompt then sending the empty line will
-usually generate a login prompt again.
-.SH COMMENTS
-Comments can be embedded in the chat script. A comment is a line which
-starts with the \fB#\fR (hash) character in column 1. Such comment
-lines are just ignored by the chat program. If a '#' character is to
-be expected as the first character of the expect sequence, you should
-quote the expect string.
-If you want to wait for a prompt that starts with a # (hash)
-character, you would have to write something like this:
-.IP
-# Now wait for the prompt and send logout string
-.br
-\'# ' logout
-.LP
-
-.SH SENDING DATA FROM A FILE
-If the string to send starts with an at sign (@), the rest of the
-string is taken to be the name of a file to read to get the string to
-send. If the last character of the data read is a newline, it is
-removed. The file can be a named pipe (or fifo) instead of a regular
-file. This provides a way for \fBchat\fR to communicate with another
-program, for example, a program to prompt the user and receive a
-password typed in.
-.LP
-
-.SH ABORT STRINGS
-Many modems will report the status of the call as a string. These
-strings may be \fBCONNECTED\fR or \fBNO CARRIER\fR or \fBBUSY\fR. It
-is often desirable to terminate the script should the modem fail to
-connect to the remote. The difficulty is that a script would not know
-exactly which modem string it may receive. On one attempt, it may
-receive \fBBUSY\fR while the next time it may receive \fBNO CARRIER\fR.
-.LP
-These "abort" strings may be specified in the script using the \fIABORT\fR
-sequence. It is written in the script as in the following example:
-.IP
-ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATDT5551212 CONNECT
-.LP
-This sequence will expect nothing; and then send the string ATZ. The
-expected response to this is the string \fIOK\fR. When it receives \fIOK\fR,
-the string ATDT5551212 to dial the telephone. The expected string is
-\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder of the
-script is executed. However, should the modem find a busy telephone, it will
-send the string \fIBUSY\fR. This will cause the string to match the abort
-character sequence. The script will then fail because it found a match to
-the abort string. If it received the string \fINO CARRIER\fR, it will abort
-for the same reason. Either string may be received. Either string will
-terminate the \fIchat\fR script.
-.SH CLR_ABORT STRINGS
-This sequence allows for clearing previously set \fBABORT\fR strings.
-\fBABORT\fR strings are kept in an array of a pre-determined size (at
-compilation time); \fBCLR_ABORT\fR will reclaim the space for cleared
-entries so that new strings can use that space.
-.SH SAY STRINGS
-The \fBSAY\fR directive allows the script to send strings to the user
-at the terminal via standard error. If \fBchat\fR is being run by
-pppd, and pppd is running as a daemon (detached from its controlling
-terminal), standard error will normally be redirected to the file
-/etc/ppp/connect-errors.
-.LP
-\fBSAY\fR strings must be enclosed in single or double quotes. If
-carriage return and line feed are needed in the string to be output,
-you must explicitely add them to your string.
-.LP
-The SAY strings could be used to give progress messages in sections of
-the script where you want to have 'ECHO OFF' but still let the user
-know what is happening. An example is:
-.IP
-ABORT BUSY
-.br
-ECHO OFF
-.br
-SAY "Dialling your ISP...\\n"
-.br
-\'' ATDT5551212
-.br
-TIMEOUT 120
-.br
-SAY "Waiting up to 2 minutes for connection ... "
-.br
-CONNECT ''
-.br
-SAY "Connected, now logging in ...\n"
-.br
-ogin: account
-.br
-ssword: pass
-.br
-$ \c
-SAY "Logged in OK ...\n"
-\fIetc ...\fR
-.LP
-This sequence will only present the SAY strings to the user and all
-the details of the script will remain hidden. For example, if the
-above script works, the user will see:
-.IP
-Dialling your ISP...
-.br
-Waiting up to 2 minutes for connection ... Connected, now logging in ...
-.br
-Logged in OK ...
-.LP
-
-.SH REPORT STRINGS
-A \fBreport\fR string is similar to the ABORT string. The difference
-is that the strings, and all characters to the next control character
-such as a carriage return, are written to the report file.
-.LP
-The report strings may be used to isolate the transmission rate of the
-modem's connect string and return the value to the chat user. The
-analysis of the report string logic occurs in conjunction with the
-other string processing such as looking for the expect string. The use
-of the same string for a report and abort sequence is probably not
-very useful, however, it is possible.
-.LP
-The report strings to no change the completion code of the program.
-.LP
-These "report" strings may be specified in the script using the \fIREPORT\fR
-sequence. It is written in the script as in the following example:
-.IP
-REPORT CONNECT ABORT BUSY '' ATDT5551212 CONNECT '' ogin: account
-.LP
-This sequence will expect nothing; and then send the string
-ATDT5551212 to dial the telephone. The expected string is
-\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder
-of the script is executed. In addition the program will write to the
-expect-file the string "CONNECT" plus any characters which follow it
-such as the connection rate.
-.SH CLR_REPORT STRINGS
-This sequence allows for clearing previously set \fBREPORT\fR strings.
-\fBREPORT\fR strings are kept in an array of a pre-determined size (at
-compilation time); \fBCLR_REPORT\fR will reclaim the space for cleared
-entries so that new strings can use that space.
-.SH ECHO
-The echo options controls whether the output from the modem is echoed
-to \fIstderr\fR. This option may be set with the \fI-e\fR option, but
-it can also be controlled by the \fIECHO\fR keyword. The "expect-send"
-pair \fIECHO\fR \fION\fR enables echoing, and \fIECHO\fR \fIOFF\fR
-disables it. With this keyword you can select which parts of the
-conversation should be visible. For instance, with the following
-script:
-.IP
-ABORT 'BUSY'
-.br
-ABORT 'NO CARRIER'
-.br
-'' ATZ
-.br
-OK\\r\\n ATD1234567
-.br
-\\r\\n \\c
-.br
-ECHO ON
-.br
-CONNECT \\c
-.br
-ogin: account
-.LP
-all output resulting from modem configuration and dialing is not visible,
-but starting with the \fICONNECT\fR (or \fIBUSY\fR) message, everything
-will be echoed.
-.SH HANGUP
-The HANGUP options control whether a modem hangup should be considered
-as an error or not. This option is useful in scripts for dialling
-systems which will hang up and call your system back. The HANGUP
-options can be \fBON\fR or \fBOFF\fR.
-.br
-When HANGUP is set OFF and the modem hangs up (e.g., after the first
-stage of logging in to a callback system), \fBchat\fR will continue
-running the script (e.g., waiting for the incoming call and second
-stage login prompt). As soon as the incoming call is connected, you
-should use the \fBHANGUP ON\fR directive to reinstall normal hang up
-signal behavior. Here is an (simple) example script:
-.IP
-ABORT 'BUSY'
-.br
-'' ATZ
-.br
-OK\\r\\n ATD1234567
-.br
-\\r\\n \\c
-.br
-CONNECT \\c
-.br
-\'Callback login:' call_back_ID
-.br
-HANGUP OFF
-.br
-ABORT "Bad Login"
-.br
-\'Callback Password:' Call_back_password
-.br
-TIMEOUT 120
-.br
-CONNECT \\c
-.br
-HANGUP ON
-.br
-ABORT "NO CARRIER"
-.br
-ogin:--BREAK--ogin: real_account
-.br
-\fIetc ...\fR
-.LP
-.SH TIMEOUT
-The initial timeout value is 45 seconds. This may be changed using the \fB-t\fR
-parameter.
-.LP
-To change the timeout value for the next expect string, the following
-example may be used:
-.IP
-ATZ OK ATDT5551212 CONNECT TIMEOUT 10 ogin:--ogin: TIMEOUT 5 assword: hello2u2
-.LP
-This will change the timeout to 10 seconds when it expects the login:
-prompt. The timeout is then changed to 5 seconds when it looks for the
-password prompt.
-.LP
-The timeout, once changed, remains in effect until it is changed again.
-.SH SENDING EOT
-The special reply string of \fIEOT\fR indicates that the chat program
-should send an EOT character to the remote. This is normally the
-End-of-file character sequence. A return character is not sent
-following the EOT.
-.PR
-The EOT sequence may be embedded into the send string using the
-sequence \fI^D\fR.
-.SH GENERATING BREAK
-The special reply string of \fIBREAK\fR will cause a break condition
-to be sent. The break is a special signal on the transmitter. The
-normal processing on the receiver is to change the transmission rate.
-It may be used to cycle through the available transmission rates on
-the remote until you are able to receive a valid login prompt.
-.PR
-The break sequence may be embedded into the send string using the
-\fI\\K\fR sequence.
-.SH ESCAPE SEQUENCES
-The expect and reply strings may contain escape sequences. All of the
-sequences are legal in the reply string. Many are legal in the expect.
-Those which are not valid in the expect sequence are so indicated.
-.TP
-.B ''
-Expects or sends a null string. If you send a null string then it will still
-send the return character. This sequence may either be a pair of apostrophe
-or quote characters.
-.TP
-.B \\\\b
-represents a backspace character.
-.TP
-.B \\\\c
-Suppresses the newline at the end of the reply string. This is the only
-method to send a string without a trailing return character. It must
-be at the end of the send string. For example,
-the sequence hello\\c will simply send the characters h, e, l, l, o.
-.I (not valid in expect.)
-.TP
-.B \\\\d
-Delay for one second. The program uses sleep(1) which will delay to a
-maximum of one second.
-.I (not valid in expect.)
-.TP
-.B \\\\K
-Insert a BREAK
-.I (not valid in expect.)
-.TP
-.B \\\\n
-Send a newline or linefeed character.
-.TP
-.B \\\\N
-Send a null character. The same sequence may be represented by \\0.
-.I (not valid in expect.)
-.TP
-.B \\\\p
-Pause for a fraction of a second. The delay is 1/10th of a second.
-.I (not valid in expect.)
-.TP
-.B \\\\q
-Suppress writing the string to the SYSLOG file. The string ?????? is
-written to the log in its place.
-.I (not valid in expect.)
-.TP
-.B \\\\r
-Send or expect a carriage return.
-.TP
-.B \\\\s
-Represents a space character in the string. This may be used when it
-is not desirable to quote the strings which contains spaces. The
-sequence 'HI TIM' and HI\\sTIM are the same.
-.TP
-.B \\\\t
-Send or expect a tab character.
-.TP
-.B \\\\T
-Send the phone number string as specified with the \fI-T\fR option
-.I (not valid in expect.)
-.TP
-.B \\\\U
-Send the phone number 2 string as specified with the \fI-U\fR option
-.I (not valid in expect.)
-.TP
-.B \\\\\\\\
-Send or expect a backslash character.
-.TP
-.B \\\\ddd
-Collapse the octal digits (ddd) into a single ASCII character and send that
-character.
-.I (some characters are not valid in expect.)
-.TP
-.B \^^C
-Substitute the sequence with the control character represented by C.
-For example, the character DC1 (17) is shown as \^^Q.
-.I (some characters are not valid in expect.)
-.SH ENVIRONMENT VARIABLES
-Environment variables are available within chat scripts, if the \fI-E\fR
-option was specified in the command line. The metacharacter \fI$\fR is used
-to introduce the name of the environment variable to substitute. If the
-substition fails, because the requested environment variable is not set,
-\fInothing\fR is replaced for the variable.
-.SH TERMINATION CODES
-The \fIchat\fR program will terminate with the following completion
-codes.
-.TP
-.B 0
-The normal termination of the program. This indicates that the script
-was executed without error to the normal conclusion.
-.TP
-.B 1
-One or more of the parameters are invalid or an expect string was too
-large for the internal buffers. This indicates that the program as not
-properly executed.
-.TP
-.B 2
-An error occurred during the execution of the program. This may be due
-to a read or write operation failing for some reason or chat receiving
-a signal such as SIGINT.
-.TP
-.B 3
-A timeout event occurred when there was an \fIexpect\fR string without
-having a "-subsend" string. This may mean that you did not program the
-script correctly for the condition or that some unexpected event has
-occurred and the expected string could not be found.
-.TP
-.B 4
-The first string marked as an \fIABORT\fR condition occurred.
-.TP
-.B 5
-The second string marked as an \fIABORT\fR condition occurred.
-.TP
-.B 6
-The third string marked as an \fIABORT\fR condition occurred.
-.TP
-.B 7
-The fourth string marked as an \fIABORT\fR condition occurred.
-.TP
-.B ...
-The other termination codes are also strings marked as an \fIABORT\fR
-condition.
-.LP
-Using the termination code, it is possible to determine which event
-terminated the script. It is possible to decide if the string "BUSY"
-was received from the modem as opposed to "NO DIAL TONE". While the
-first event may be retried, the second will probably have little
-chance of succeeding during a retry.
-.SH SEE ALSO
-Additional information about \fIchat\fR scripts may be found with UUCP
-documentation. The \fIchat\fR script was taken from the ideas proposed
-by the scripts used by the \fIuucico\fR program.
-.LP
-uucico(1), uucp(1)
-.SH COPYRIGHT
-The \fIchat\fR program is in public domain. This is not the GNU public
-license. If it breaks then you get to keep both pieces.
diff --git a/mdk-stage1/ppp/chat/chat.c b/mdk-stage1/ppp/chat/chat.c
deleted file mode 100644
index 1b22907a8..000000000
--- a/mdk-stage1/ppp/chat/chat.c
+++ /dev/null
@@ -1,1756 +0,0 @@
-/*
- * Chat -- a program for automatic session establishment (i.e. dial
- * the phone and log in).
- *
- * Standard termination codes:
- * 0 - successful completion of the script
- * 1 - invalid argument, expect string too large, etc.
- * 2 - error on an I/O operation or fatal error condition.
- * 3 - timeout waiting for a simple string.
- * 4 - the first string declared as "ABORT"
- * 5 - the second string declared as "ABORT"
- * 6 - ... and so on for successive ABORT strings.
- *
- * This software is in the public domain.
- *
- * -----------------
- * 22-May-99 added environment substitutuion, enabled with -E switch.
- * Andreas Arens <andras@cityweb.de>.
- *
- * 12-May-99 added a feature to read data to be sent from a file,
- * if the send string starts with @. Idea from gpk <gpk@onramp.net>.
- *
- * added -T and -U option and \T and \U substitution to pass a phone
- * number into chat script. Two are needed for some ISDN TA applications.
- * Keith Dart <kdart@cisco.com>
- *
- *
- * Added SAY keyword to send output to stderr.
- * This allows to turn ECHO OFF and to output specific, user selected,
- * text to give progress messages. This best works when stderr
- * exists (i.e.: pppd in nodetach mode).
- *
- * Added HANGUP directives to allow for us to be called
- * back. When HANGUP is set to NO, chat will not hangup at HUP signal.
- * We rely on timeouts in that case.
- *
- * Added CLR_ABORT to clear previously set ABORT string. This has been
- * dictated by the HANGUP above as "NO CARRIER" (for example) must be
- * an ABORT condition until we know the other host is going to close
- * the connection for call back. As soon as we have completed the
- * first stage of the call back sequence, "NO CARRIER" is a valid, non
- * fatal string. As soon as we got called back (probably get "CONNECT"),
- * we should re-arm the ABORT "NO CARRIER". Hence the CLR_ABORT command.
- * Note that CLR_ABORT packs the abort_strings[] array so that we do not
- * have unused entries not being reclaimed.
- *
- * In the same vein as above, added CLR_REPORT keyword.
- *
- * Allow for comments. Line starting with '#' are comments and are
- * ignored. If a '#' is to be expected as the first character, the
- * expect string must be quoted.
- *
- *
- * Francis Demierre <Francis@SwissMail.Com>
- * Thu May 15 17:15:40 MET DST 1997
- *
- *
- * Added -r "report file" switch & REPORT keyword.
- * Robert Geer <bgeer@xmission.com>
- *
- * Added -s "use stderr" and -S "don't use syslog" switches.
- * June 18, 1997
- * Karl O. Pinc <kop@meme.com>
- *
- *
- * Added -e "echo" switch & ECHO keyword
- * Dick Streefland <dicks@tasking.nl>
- *
- *
- * Considerable updates and modifications by
- * Al Longyear <longyear@pobox.com>
- * Paul Mackerras <paulus@cs.anu.edu.au>
- *
- *
- * The original author is:
- *
- * Karl Fox <karl@MorningStar.Com>
- * Morning Star Technologies, Inc.
- * 1760 Zollinger Road
- * Columbus, OH 43221
- * (614)451-1883
- *
- */
-
-#ifndef __STDC__
-#define const
-#endif
-
-#ifndef lint
-static const char rcsid[] = "$Id$";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <time.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <syslog.h>
-
-#ifndef TERMIO
-#undef TERMIOS
-#define TERMIOS
-#endif
-
-#ifdef TERMIO
-#include <termio.h>
-#endif
-#ifdef TERMIOS
-#include <termios.h>
-#endif
-
-#define STR_LEN 1024
-
-#ifndef SIGTYPE
-#define SIGTYPE void
-#endif
-
-#undef __P
-#undef __V
-
-#ifdef __STDC__
-#include <stdarg.h>
-#define __V(x) x
-#define __P(x) x
-#else
-#include <varargs.h>
-#define __V(x) (va_alist) va_dcl
-#define __P(x) ()
-#define const
-#endif
-
-#ifndef O_NONBLOCK
-#define O_NONBLOCK O_NDELAY
-#endif
-
-#ifdef SUNOS
-extern int sys_nerr;
-extern char *sys_errlist[];
-#define memmove(to, from, n) bcopy(from, to, n)
-#define strerror(n) ((unsigned)(n) < sys_nerr? sys_errlist[(n)] :\
- "unknown error")
-#endif
-
-/*************** Micro getopt() *********************************************/
-#define OPTION(c,v) (_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
- (--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
- &&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
-#define OPTARG(c,v) (_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
- (_O=4,(char*)0):(char*)0)
-#define OPTONLYARG(c,v) (_O&2&&**v?(_O=1,--c,*v++):(char*)0)
-#define ARG(c,v) (c?(--c,*v++):(char*)0)
-
-static int _O = 0; /* Internal state */
-/*************** Micro getopt() *********************************************/
-
-char *program_name;
-
-#define MAX_ABORTS 50
-#define MAX_REPORTS 50
-#define DEFAULT_CHAT_TIMEOUT 45
-
-int echo = 0;
-int verbose = 0;
-int to_log = 1;
-int to_stderr = 0;
-int Verbose = 0;
-int quiet = 0;
-int report = 0;
-int use_env = 0;
-int exit_code = 0;
-FILE* report_fp = (FILE *) 0;
-char *report_file = (char *) 0;
-char *chat_file = (char *) 0;
-char *phone_num = (char *) 0;
-char *phone_num2 = (char *) 0;
-int timeout = DEFAULT_CHAT_TIMEOUT;
-
-int have_tty_parameters = 0;
-
-#ifdef TERMIO
-#define term_parms struct termio
-#define get_term_param(param) ioctl(0, TCGETA, param)
-#define set_term_param(param) ioctl(0, TCSETA, param)
-struct termio saved_tty_parameters;
-#endif
-
-#ifdef TERMIOS
-#define term_parms struct termios
-#define get_term_param(param) tcgetattr(0, param)
-#define set_term_param(param) tcsetattr(0, TCSANOW, param)
-struct termios saved_tty_parameters;
-#endif
-
-char *abort_string[MAX_ABORTS], *fail_reason = (char *)0,
- fail_buffer[50];
-int n_aborts = 0, abort_next = 0, timeout_next = 0, echo_next = 0;
-int clear_abort_next = 0;
-
-char *report_string[MAX_REPORTS] ;
-char report_buffer[50] ;
-int n_reports = 0, report_next = 0, report_gathering = 0 ;
-int clear_report_next = 0;
-
-int say_next = 0, hup_next = 0;
-
-void *dup_mem __P((void *b, size_t c));
-void *copy_of __P((char *s));
-void usage __P((void));
-void logf __P((const char *fmt, ...));
-void fatal __P((int code, const char *fmt, ...));
-SIGTYPE sigalrm __P((int signo));
-SIGTYPE sigint __P((int signo));
-SIGTYPE sigterm __P((int signo));
-SIGTYPE sighup __P((int signo));
-void unalarm __P((void));
-void init __P((void));
-void set_tty_parameters __P((void));
-void echo_stderr __P((int));
-void break_sequence __P((void));
-void terminate __P((int status));
-void do_file __P((char *chat_file));
-int get_string __P((register char *string));
-int put_string __P((register char *s));
-int write_char __P((int c));
-int put_char __P((int c));
-int get_char __P((void));
-void chat_send __P((register char *s));
-char *character __P((int c));
-void chat_expect __P((register char *s));
-char *clean __P((register char *s, int sending));
-void break_sequence __P((void));
-void terminate __P((int status));
-void pack_array __P((char **array, int end));
-char *expect_strtok __P((char *, char *));
-int vfmtmsg __P((char *, int, const char *, va_list)); /* vsprintf++ */
-
-int main __P((int, char *[]));
-
-void *dup_mem(b, c)
-void *b;
-size_t c;
-{
- void *ans = malloc (c);
- if (!ans)
- fatal(2, "memory error!");
-
- memcpy (ans, b, c);
- return ans;
-}
-
-void *copy_of (s)
-char *s;
-{
- return dup_mem (s, strlen (s) + 1);
-}
-
-/*
- * chat [ -v ] [ -E ] [ -T number ] [ -U number ] [ -t timeout ] [ -f chat-file ] \
- * [ -r report-file ] \
- * [...[[expect[-say[-expect...]] say expect[-say[-expect]] ...]]]
- *
- * Perform a UUCP-dialer-like chat script on stdin and stdout.
- */
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- int option;
- char *arg;
-
- program_name = *argv;
- tzset();
-
- while ((option = OPTION(argc, argv)) != 0) {
- switch (option) {
- case 'e':
- ++echo;
- break;
-
- case 'E':
- ++use_env;
- break;
-
- case 'v':
- ++verbose;
- break;
-
- case 'V':
- ++Verbose;
- break;
-
- case 's':
- ++to_stderr;
- break;
-
- case 'S':
- to_log = 0;
- break;
-
- case 'f':
- if ((arg = OPTARG(argc, argv)) != NULL)
- chat_file = copy_of(arg);
- else
- usage();
- break;
-
- case 't':
- if ((arg = OPTARG(argc, argv)) != NULL)
- timeout = atoi(arg);
- else
- usage();
- break;
-
- case 'r':
- arg = OPTARG (argc, argv);
- if (arg) {
- if (report_fp != NULL)
- fclose (report_fp);
- report_file = copy_of (arg);
- report_fp = fopen (report_file, "a");
- if (report_fp != NULL) {
- if (verbose)
- fprintf (report_fp, "Opening \"%s\"...\n",
- report_file);
- report = 1;
- }
- }
- break;
-
- case 'T':
- if ((arg = OPTARG(argc, argv)) != NULL)
- phone_num = copy_of(arg);
- else
- usage();
- break;
-
- case 'U':
- if ((arg = OPTARG(argc, argv)) != NULL)
- phone_num2 = copy_of(arg);
- else
- usage();
- break;
-
- default:
- usage();
- break;
- }
- }
-/*
- * Default the report file to the stderr location
- */
- if (report_fp == NULL)
- report_fp = stderr;
-
- if (to_log) {
-#ifdef ultrix
- openlog("chat", LOG_PID);
-#else
- openlog("chat", LOG_PID | LOG_NDELAY, LOG_LOCAL2);
-
- if (verbose)
- setlogmask(LOG_UPTO(LOG_INFO));
- else
- setlogmask(LOG_UPTO(LOG_WARNING));
-#endif
- }
-
- init();
-
- if (chat_file != NULL) {
- arg = ARG(argc, argv);
- if (arg != NULL)
- usage();
- else
- do_file (chat_file);
- } else {
- while ((arg = ARG(argc, argv)) != NULL) {
- chat_expect(arg);
-
- if ((arg = ARG(argc, argv)) != NULL)
- chat_send(arg);
- }
- }
-
- terminate(0);
- return 0;
-}
-
-/*
- * Process a chat script when read from a file.
- */
-
-void do_file (chat_file)
-char *chat_file;
-{
- int linect, sendflg;
- char *sp, *arg, quote;
- char buf [STR_LEN];
- FILE *cfp;
-
- cfp = fopen (chat_file, "r");
- if (cfp == NULL)
- fatal(1, "%s -- open failed: %m", chat_file);
-
- linect = 0;
- sendflg = 0;
-
- while (fgets(buf, STR_LEN, cfp) != NULL) {
- sp = strchr (buf, '\n');
- if (sp)
- *sp = '\0';
-
- linect++;
- sp = buf;
-
- /* lines starting with '#' are comments. If a real '#'
- is to be expected, it should be quoted .... */
- if ( *sp == '#' )
- continue;
-
- while (*sp != '\0') {
- if (*sp == ' ' || *sp == '\t') {
- ++sp;
- continue;
- }
-
- if (*sp == '"' || *sp == '\'') {
- quote = *sp++;
- arg = sp;
- while (*sp != quote) {
- if (*sp == '\0')
- fatal(1, "unterminated quote (line %d)", linect);
-
- if (*sp++ == '\\') {
- if (*sp != '\0')
- ++sp;
- }
- }
- }
- else {
- arg = sp;
- while (*sp != '\0' && *sp != ' ' && *sp != '\t')
- ++sp;
- }
-
- if (*sp != '\0')
- *sp++ = '\0';
-
- if (sendflg)
- chat_send (arg);
- else
- chat_expect (arg);
- sendflg = !sendflg;
- }
- }
- fclose (cfp);
-}
-
-/*
- * We got an error parsing the command line.
- */
-void usage()
-{
- fprintf(stderr, "\
-Usage: %s [-e] [-E] [-v] [-V] [-t timeout] [-r report-file]\n\
- [-T phone-number] [-U phone-number2] {-f chat-file | chat-script}\n", program_name);
- exit(1);
-}
-
-char line[1024];
-
-/*
- * Send a message to syslog and/or stderr.
- */
-void logf __V((const char *fmt, ...))
-{
- va_list args;
-
-#ifdef __STDC__
- va_start(args, fmt);
-#else
- char *fmt;
- va_start(args);
- fmt = va_arg(args, char *);
-#endif
-
- vfmtmsg(line, sizeof(line), fmt, args);
- if (to_log)
- syslog(LOG_INFO, "%s", line);
- if (to_stderr)
- fprintf(stderr, "%s\n", line);
-}
-
-/*
- * Print an error message and terminate.
- */
-
-void fatal __V((int code, const char *fmt, ...))
-{
- va_list args;
-
-#ifdef __STDC__
- va_start(args, fmt);
-#else
- int code;
- char *fmt;
- va_start(args);
- code = va_arg(args, int);
- fmt = va_arg(args, char *);
-#endif
-
- vfmtmsg(line, sizeof(line), fmt, args);
- if (to_log)
- syslog(LOG_ERR, "%s", line);
- if (to_stderr)
- fprintf(stderr, "%s\n", line);
- terminate(code);
-}
-
-int alarmed = 0;
-
-SIGTYPE sigalrm(signo)
-int signo;
-{
- int flags;
-
- alarm(1);
- alarmed = 1; /* Reset alarm to avoid race window */
- signal(SIGALRM, sigalrm); /* that can cause hanging in read() */
-
- if ((flags = fcntl(0, F_GETFL, 0)) == -1)
- fatal(2, "Can't get file mode flags on stdin: %m");
-
- if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1)
- fatal(2, "Can't set file mode flags on stdin: %m");
-
- if (verbose)
- logf("alarm");
-}
-
-void unalarm()
-{
- int flags;
-
- if ((flags = fcntl(0, F_GETFL, 0)) == -1)
- fatal(2, "Can't get file mode flags on stdin: %m");
-
- if (fcntl(0, F_SETFL, flags & ~O_NONBLOCK) == -1)
- fatal(2, "Can't set file mode flags on stdin: %m");
-}
-
-SIGTYPE sigint(signo)
-int signo;
-{
- fatal(2, "SIGINT");
-}
-
-SIGTYPE sigterm(signo)
-int signo;
-{
- fatal(2, "SIGTERM");
-}
-
-SIGTYPE sighup(signo)
-int signo;
-{
- fatal(2, "SIGHUP");
-}
-
-void init()
-{
- signal(SIGINT, sigint);
- signal(SIGTERM, sigterm);
- signal(SIGHUP, sighup);
-
- set_tty_parameters();
- signal(SIGALRM, sigalrm);
- alarm(0);
- alarmed = 0;
-}
-
-void set_tty_parameters()
-{
-#if defined(get_term_param)
- term_parms t;
-
- if (get_term_param (&t) < 0)
- fatal(2, "Can't get terminal parameters: %m");
-
- saved_tty_parameters = t;
- have_tty_parameters = 1;
-
- t.c_iflag |= IGNBRK | ISTRIP | IGNPAR;
- t.c_oflag = 0;
- t.c_lflag = 0;
- t.c_cc[VERASE] =
- t.c_cc[VKILL] = 0;
- t.c_cc[VMIN] = 1;
- t.c_cc[VTIME] = 0;
-
- if (set_term_param (&t) < 0)
- fatal(2, "Can't set terminal parameters: %m");
-#endif
-}
-
-void break_sequence()
-{
-#ifdef TERMIOS
- tcsendbreak (0, 0);
-#endif
-}
-
-void terminate(status)
-int status;
-{
- static int terminating = 0;
-
- if (terminating)
- exit(status);
- terminating = 1;
- echo_stderr(-1);
-/*
- * Allow the last of the report string to be gathered before we terminate.
- */
- if (report_gathering) {
- int c, rep_len;
-
- rep_len = strlen(report_buffer);
- while (rep_len + 1 <= sizeof(report_buffer)) {
- alarm(1);
- c = get_char();
- alarm(0);
- if (c < 0 || iscntrl(c))
- break;
- report_buffer[rep_len] = c;
- ++rep_len;
- }
- report_buffer[rep_len] = 0;
- fprintf (report_fp, "chat: %s\n", report_buffer);
- }
- if (report_file != (char *) 0 && report_fp != (FILE *) NULL) {
- if (verbose)
- fprintf (report_fp, "Closing \"%s\".\n", report_file);
- fclose (report_fp);
- report_fp = (FILE *) NULL;
- }
-
-#if defined(get_term_param)
- if (have_tty_parameters) {
- if (set_term_param (&saved_tty_parameters) < 0)
- fatal(2, "Can't restore terminal parameters: %m");
- }
-#endif
-
- exit(status);
-}
-
-/*
- * 'Clean up' this string.
- */
-char *clean(s, sending)
-register char *s;
-int sending; /* set to 1 when sending (putting) this string. */
-{
- char temp[STR_LEN], env_str[STR_LEN], cur_chr;
- register char *s1, *phchar;
- int add_return = sending;
-#define isoctal(chr) (((chr) >= '0') && ((chr) <= '7'))
-#define isalnumx(chr) ((((chr) >= '0') && ((chr) <= '9')) \
- || (((chr) >= 'a') && ((chr) <= 'z')) \
- || (((chr) >= 'A') && ((chr) <= 'Z')) \
- || (chr) == '_')
-
- s1 = temp;
- while (*s) {
- cur_chr = *s++;
- if (cur_chr == '^') {
- cur_chr = *s++;
- if (cur_chr == '\0') {
- *s1++ = '^';
- break;
- }
- cur_chr &= 0x1F;
- if (cur_chr != 0) {
- *s1++ = cur_chr;
- }
- continue;
- }
-
- if (use_env && cur_chr == '$') { /* ARI */
- phchar = env_str;
- while (isalnumx(*s))
- *phchar++ = *s++;
- *phchar = '\0';
- phchar = getenv(env_str);
- if (phchar)
- while (*phchar)
- *s1++ = *phchar++;
- continue;
- }
-
- if (cur_chr != '\\') {
- *s1++ = cur_chr;
- continue;
- }
-
- cur_chr = *s++;
- if (cur_chr == '\0') {
- if (sending) {
- *s1++ = '\\';
- *s1++ = '\\';
- }
- break;
- }
-
- switch (cur_chr) {
- case 'b':
- *s1++ = '\b';
- break;
-
- case 'c':
- if (sending && *s == '\0')
- add_return = 0;
- else
- *s1++ = cur_chr;
- break;
-
- case '\\':
- case 'K':
- case 'p':
- case 'd':
- if (sending)
- *s1++ = '\\';
- *s1++ = cur_chr;
- break;
-
- case 'T':
- if (sending && phone_num) {
- for (phchar = phone_num; *phchar != '\0'; phchar++)
- *s1++ = *phchar;
- }
- else {
- *s1++ = '\\';
- *s1++ = 'T';
- }
- break;
-
- case 'U':
- if (sending && phone_num2) {
- for (phchar = phone_num2; *phchar != '\0'; phchar++)
- *s1++ = *phchar;
- }
- else {
- *s1++ = '\\';
- *s1++ = 'U';
- }
- break;
-
- case 'q':
- quiet = 1;
- break;
-
- case 'r':
- *s1++ = '\r';
- break;
-
- case 'n':
- *s1++ = '\n';
- break;
-
- case 's':
- *s1++ = ' ';
- break;
-
- case 't':
- *s1++ = '\t';
- break;
-
- case 'N':
- if (sending) {
- *s1++ = '\\';
- *s1++ = '\0';
- }
- else
- *s1++ = 'N';
- break;
-
- case '$': /* ARI */
- if (use_env) {
- *s1++ = cur_chr;
- break;
- }
- /* FALL THROUGH */
-
- default:
- if (isoctal (cur_chr)) {
- cur_chr &= 0x07;
- if (isoctal (*s)) {
- cur_chr <<= 3;
- cur_chr |= *s++ - '0';
- if (isoctal (*s)) {
- cur_chr <<= 3;
- cur_chr |= *s++ - '0';
- }
- }
-
- if (cur_chr != 0 || sending) {
- if (sending && (cur_chr == '\\' || cur_chr == 0))
- *s1++ = '\\';
- *s1++ = cur_chr;
- }
- break;
- }
-
- if (sending)
- *s1++ = '\\';
- *s1++ = cur_chr;
- break;
- }
- }
-
- if (add_return)
- *s1++ = '\r';
-
- *s1++ = '\0'; /* guarantee closure */
- *s1++ = '\0'; /* terminate the string */
- return dup_mem (temp, (size_t) (s1 - temp)); /* may have embedded nuls */
-}
-
-/*
- * A modified version of 'strtok'. This version skips \ sequences.
- */
-
-char *expect_strtok (s, term)
- char *s, *term;
-{
- static char *str = "";
- int escape_flag = 0;
- char *result;
-
-/*
- * If a string was specified then do initial processing.
- */
- if (s)
- str = s;
-
-/*
- * If this is the escape flag then reset it and ignore the character.
- */
- if (*str)
- result = str;
- else
- result = (char *) 0;
-
- while (*str) {
- if (escape_flag) {
- escape_flag = 0;
- ++str;
- continue;
- }
-
- if (*str == '\\') {
- ++str;
- escape_flag = 1;
- continue;
- }
-
-/*
- * If this is not in the termination string, continue.
- */
- if (strchr (term, *str) == (char *) 0) {
- ++str;
- continue;
- }
-
-/*
- * This is the terminator. Mark the end of the string and stop.
- */
- *str++ = '\0';
- break;
- }
- return (result);
-}
-
-/*
- * Process the expect string
- */
-
-void chat_expect (s)
-char *s;
-{
- char *expect;
- char *reply;
-
- if (strcmp(s, "HANGUP") == 0) {
- ++hup_next;
- return;
- }
-
- if (strcmp(s, "ABORT") == 0) {
- ++abort_next;
- return;
- }
-
- if (strcmp(s, "CLR_ABORT") == 0) {
- ++clear_abort_next;
- return;
- }
-
- if (strcmp(s, "REPORT") == 0) {
- ++report_next;
- return;
- }
-
- if (strcmp(s, "CLR_REPORT") == 0) {
- ++clear_report_next;
- return;
- }
-
- if (strcmp(s, "TIMEOUT") == 0) {
- ++timeout_next;
- return;
- }
-
- if (strcmp(s, "ECHO") == 0) {
- ++echo_next;
- return;
- }
-
- if (strcmp(s, "SAY") == 0) {
- ++say_next;
- return;
- }
-
-/*
- * Fetch the expect and reply string.
- */
- for (;;) {
- expect = expect_strtok (s, "-");
- s = (char *) 0;
-
- if (expect == (char *) 0)
- return;
-
- reply = expect_strtok (s, "-");
-
-/*
- * Handle the expect string. If successful then exit.
- */
- if (get_string (expect))
- return;
-
-/*
- * If there is a sub-reply string then send it. Otherwise any condition
- * is terminal.
- */
- if (reply == (char *) 0 || exit_code != 3)
- break;
-
- chat_send (reply);
- }
-
-/*
- * The expectation did not occur. This is terminal.
- */
- if (fail_reason)
- logf("Failed (%s)", fail_reason);
- else
- logf("Failed");
- terminate(exit_code);
-}
-
-/*
- * Translate the input character to the appropriate string for printing
- * the data.
- */
-
-char *character(c)
-int c;
-{
- static char string[10];
- char *meta;
-
- meta = (c & 0x80) ? "M-" : "";
- c &= 0x7F;
-
- if (c < 32)
- sprintf(string, "%s^%c", meta, (int)c + '@');
- else if (c == 127)
- sprintf(string, "%s^?", meta);
- else
- sprintf(string, "%s%c", meta, c);
-
- return (string);
-}
-
-/*
- * process the reply string
- */
-void chat_send (s)
-register char *s;
-{
- char file_data[STR_LEN];
-
- if (say_next) {
- say_next = 0;
- s = clean(s, 1);
- write(2, s, strlen(s));
- free(s);
- return;
- }
-
- if (hup_next) {
- hup_next = 0;
- if (strcmp(s, "OFF") == 0)
- signal(SIGHUP, SIG_IGN);
- else
- signal(SIGHUP, sighup);
- return;
- }
-
- if (echo_next) {
- echo_next = 0;
- echo = (strcmp(s, "ON") == 0);
- return;
- }
-
- if (abort_next) {
- char *s1;
-
- abort_next = 0;
-
- if (n_aborts >= MAX_ABORTS)
- fatal(2, "Too many ABORT strings");
-
- s1 = clean(s, 0);
-
- if (strlen(s1) > strlen(s)
- || strlen(s1) + 1 > sizeof(fail_buffer))
- fatal(1, "Illegal or too-long ABORT string ('%v')", s);
-
- abort_string[n_aborts++] = s1;
-
- if (verbose)
- logf("abort on (%v)", s);
- return;
- }
-
- if (clear_abort_next) {
- char *s1;
- int i;
- int old_max;
- int pack = 0;
-
- clear_abort_next = 0;
-
- s1 = clean(s, 0);
-
- if (strlen(s1) > strlen(s)
- || strlen(s1) + 1 > sizeof(fail_buffer))
- fatal(1, "Illegal or too-long CLR_ABORT string ('%v')", s);
-
- old_max = n_aborts;
- for (i=0; i < n_aborts; i++) {
- if ( strcmp(s1,abort_string[i]) == 0 ) {
- free(abort_string[i]);
- abort_string[i] = NULL;
- pack++;
- n_aborts--;
- if (verbose)
- logf("clear abort on (%v)", s);
- }
- }
- free(s1);
- if (pack)
- pack_array(abort_string,old_max);
- return;
- }
-
- if (report_next) {
- char *s1;
-
- report_next = 0;
- if (n_reports >= MAX_REPORTS)
- fatal(2, "Too many REPORT strings");
-
- s1 = clean(s, 0);
-
- if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1)
- fatal(1, "Illegal or too-long REPORT string ('%v')", s);
-
- report_string[n_reports++] = s1;
-
- if (verbose)
- logf("report (%v)", s);
- return;
- }
-
- if (clear_report_next) {
- char *s1;
- int i;
- int old_max;
- int pack = 0;
-
- clear_report_next = 0;
-
- s1 = clean(s, 0);
-
- if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1)
- fatal(1, "Illegal or too-long REPORT string ('%v')", s);
-
- old_max = n_reports;
- for (i=0; i < n_reports; i++) {
- if ( strcmp(s1,report_string[i]) == 0 ) {
- free(report_string[i]);
- report_string[i] = NULL;
- pack++;
- n_reports--;
- if (verbose)
- logf("clear report (%v)", s);
- }
- }
- free(s1);
- if (pack)
- pack_array(report_string,old_max);
-
- return;
- }
-
- if (timeout_next) {
- timeout_next = 0;
- timeout = atoi(s);
-
- if (timeout <= 0)
- timeout = DEFAULT_CHAT_TIMEOUT;
-
- if (verbose)
- logf("timeout set to %d seconds", timeout);
-
- return;
- }
-
- /*
- * The syntax @filename means read the string to send from the
- * file `filename'.
- */
- if (s[0] == '@') {
- /* skip the @ and any following white-space */
- char *fn = s;
- while (*++fn == ' ' || *fn == '\t')
- ;
-
- if (*fn != 0) {
- FILE *f;
- int n = 0;
-
- /* open the file and read until STR_LEN-1 bytes or end-of-file */
- f = fopen(fn, "r");
- if (f == NULL)
- fatal(1, "%s -- open failed: %m", fn);
- while (n < STR_LEN - 1) {
- int nr = fread(&file_data[n], 1, STR_LEN - 1 - n, f);
- if (nr < 0)
- fatal(1, "%s -- read error", fn);
- if (nr == 0)
- break;
- n += nr;
- }
- fclose(f);
-
- /* use the string we got as the string to send,
- but trim off the final newline if any. */
- if (n > 0 && file_data[n-1] == '\n')
- --n;
- file_data[n] = 0;
- s = file_data;
- }
- }
-
- if (strcmp(s, "EOT") == 0)
- s = "^D\\c";
- else if (strcmp(s, "BREAK") == 0)
- s = "\\K\\c";
-
- if (!put_string(s))
- fatal(1, "Failed");
-}
-
-int get_char()
-{
- int status;
- char c;
-
- status = read(0, &c, 1);
-
- switch (status) {
- case 1:
- return ((int)c & 0x7F);
-
- default:
- logf("warning: read() on stdin returned %d", status);
-
- case -1:
- if ((status = fcntl(0, F_GETFL, 0)) == -1)
- fatal(2, "Can't get file mode flags on stdin: %m");
-
- if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1)
- fatal(2, "Can't set file mode flags on stdin: %m");
-
- return (-1);
- }
-}
-
-int put_char(c)
-int c;
-{
- int status;
- char ch = c;
-
- usleep(10000); /* inter-character typing delay (?) */
-
- status = write(1, &ch, 1);
-
- switch (status) {
- case 1:
- return (0);
-
- default:
- logf("warning: write() on stdout returned %d", status);
-
- case -1:
- if ((status = fcntl(0, F_GETFL, 0)) == -1)
- fatal(2, "Can't get file mode flags on stdin, %m");
-
- if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1)
- fatal(2, "Can't set file mode flags on stdin: %m");
-
- return (-1);
- }
-}
-
-int write_char (c)
-int c;
-{
- if (alarmed || put_char(c) < 0) {
- alarm(0);
- alarmed = 0;
-
- if (verbose) {
- if (errno == EINTR || errno == EWOULDBLOCK)
- logf(" -- write timed out");
- else
- logf(" -- write failed: %m");
- }
- return (0);
- }
- return (1);
-}
-
-int put_string (s)
-register char *s;
-{
- quiet = 0;
- s = clean(s, 1);
-
- if (verbose) {
- if (quiet)
- logf("send (??????)");
- else
- logf("send (%v)", s);
- }
-
- alarm(timeout); alarmed = 0;
-
- while (*s) {
- register char c = *s++;
-
- if (c != '\\') {
- if (!write_char (c))
- return 0;
- continue;
- }
-
- c = *s++;
- switch (c) {
- case 'd':
- sleep(1);
- break;
-
- case 'K':
- break_sequence();
- break;
-
- case 'p':
- usleep(10000); /* 1/100th of a second (arg is microseconds) */
- break;
-
- default:
- if (!write_char (c))
- return 0;
- break;
- }
- }
-
- alarm(0);
- alarmed = 0;
- return (1);
-}
-
-/*
- * Echo a character to stderr.
- * When called with -1, a '\n' character is generated when
- * the cursor is not at the beginning of a line.
- */
-void echo_stderr(n)
-int n;
-{
- static int need_lf;
- char *s;
-
- switch (n) {
- case '\r': /* ignore '\r' */
- break;
- case -1:
- if (need_lf == 0)
- break;
- /* fall through */
- case '\n':
- write(2, "\n", 1);
- need_lf = 0;
- break;
- default:
- s = character(n);
- write(2, s, strlen(s));
- need_lf = 1;
- break;
- }
-}
-
-/*
- * 'Wait for' this string to appear on this file descriptor.
- */
-int get_string(string)
-register char *string;
-{
- char temp[STR_LEN];
- int c, printed = 0, len, minlen;
- register char *s = temp, *end = s + STR_LEN;
- char *logged = temp;
-
- fail_reason = (char *)0;
- string = clean(string, 0);
- len = strlen(string);
- minlen = (len > sizeof(fail_buffer)? len: sizeof(fail_buffer)) - 1;
-
- if (verbose)
- logf("expect (%v)", string);
-
- if (len > STR_LEN) {
- logf("expect string is too long");
- exit_code = 1;
- return 0;
- }
-
- if (len == 0) {
- if (verbose)
- logf("got it");
- return (1);
- }
-
- alarm(timeout);
- alarmed = 0;
-
- while ( ! alarmed && (c = get_char()) >= 0) {
- int n, abort_len, report_len;
-
- if (echo)
- echo_stderr(c);
- if (verbose && c == '\n') {
- if (s == logged)
- logf(""); /* blank line */
- else
- logf("%0.*v", s - logged, logged);
- logged = s + 1;
- }
-
- *s++ = c;
-
- if (verbose && s >= logged + 80) {
- logf("%0.*v", s - logged, logged);
- logged = s;
- }
-
- if (Verbose) {
- if (c == '\n')
- fputc( '\n', stderr );
- else if (c != '\r')
- fprintf( stderr, "%s", character(c) );
- }
-
- if (!report_gathering) {
- for (n = 0; n < n_reports; ++n) {
- if ((report_string[n] != (char*) NULL) &&
- s - temp >= (report_len = strlen(report_string[n])) &&
- strncmp(s - report_len, report_string[n], report_len) == 0) {
- time_t time_now = time ((time_t*) NULL);
- struct tm* tm_now = localtime (&time_now);
-
- strftime (report_buffer, 20, "%b %d %H:%M:%S ", tm_now);
- strcat (report_buffer, report_string[n]);
-
- report_string[n] = (char *) NULL;
- report_gathering = 1;
- break;
- }
- }
- }
- else {
- if (!iscntrl (c)) {
- int rep_len = strlen (report_buffer);
- report_buffer[rep_len] = c;
- report_buffer[rep_len + 1] = '\0';
- }
- else {
- report_gathering = 0;
- fprintf (report_fp, "chat: %s\n", report_buffer);
- }
- }
-
- if (s - temp >= len &&
- c == string[len - 1] &&
- strncmp(s - len, string, len) == 0) {
- if (verbose) {
- if (s > logged)
- logf("%0.*v", s - logged, logged);
- logf(" -- got it\n");
- }
-
- alarm(0);
- alarmed = 0;
- return (1);
- }
-
- for (n = 0; n < n_aborts; ++n) {
- if (s - temp >= (abort_len = strlen(abort_string[n])) &&
- strncmp(s - abort_len, abort_string[n], abort_len) == 0) {
- if (verbose) {
- if (s > logged)
- logf("%0.*v", s - logged, logged);
- logf(" -- failed");
- }
-
- alarm(0);
- alarmed = 0;
- exit_code = n + 4;
- strcpy(fail_reason = fail_buffer, abort_string[n]);
- return (0);
- }
- }
-
- if (s >= end) {
- if (logged < s - minlen) {
- if (verbose)
- logf("%0.*v", s - logged, logged);
- logged = s;
- }
- s -= minlen;
- memmove(temp, s, minlen);
- logged = temp + (logged - s);
- s = temp + minlen;
- }
-
- if (alarmed && verbose)
- logf("warning: alarm synchronization problem");
- }
-
- alarm(0);
-
- if (verbose && printed) {
- if (alarmed)
- logf(" -- read timed out");
- else
- logf(" -- read failed: %m");
- }
-
- exit_code = 3;
- alarmed = 0;
- return (0);
-}
-
-/*
- * Gross kludge to handle Solaris versions >= 2.6 having usleep.
- */
-#ifdef SOL2
-#include <sys/param.h>
-#if MAXUID > 65536 /* then this is Solaris 2.6 or later */
-#undef NO_USLEEP
-#endif
-#endif /* SOL2 */
-
-#ifdef NO_USLEEP
-#include <sys/types.h>
-#include <sys/time.h>
-
-/*
- usleep -- support routine for 4.2BSD system call emulations
- last edit: 29-Oct-1984 D A Gwyn
- */
-
-extern int select();
-
-int
-usleep( usec ) /* returns 0 if ok, else -1 */
- long usec; /* delay in microseconds */
-{
- static struct { /* `timeval' */
- long tv_sec; /* seconds */
- long tv_usec; /* microsecs */
- } delay; /* _select() timeout */
-
- delay.tv_sec = usec / 1000000L;
- delay.tv_usec = usec % 1000000L;
-
- return select(0, (long *)0, (long *)0, (long *)0, &delay);
-}
-#endif
-
-void
-pack_array (array, end)
- char **array; /* The address of the array of string pointers */
- int end; /* The index of the next free entry before CLR_ */
-{
- int i, j;
-
- for (i = 0; i < end; i++) {
- if (array[i] == NULL) {
- for (j = i+1; j < end; ++j)
- if (array[j] != NULL)
- array[i++] = array[j];
- for (; i < end; ++i)
- array[i] = NULL;
- break;
- }
- }
-}
-
-/*
- * vfmtmsg - format a message into a buffer. Like vsprintf except we
- * also specify the length of the output buffer, and we handle the
- * %m (error message) format.
- * Doesn't do floating-point formats.
- * Returns the number of chars put into buf.
- */
-#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
-
-int
-vfmtmsg(buf, buflen, fmt, args)
- char *buf;
- int buflen;
- const char *fmt;
- va_list args;
-{
- int c, i, n;
- int width, prec, fillch;
- int base, len, neg, quoted;
- unsigned long val = 0;
- char *str, *buf0;
- const char *f;
- unsigned char *p;
- char num[32];
- static char hexchars[] = "0123456789abcdef";
-
- buf0 = buf;
- --buflen;
- while (buflen > 0) {
- for (f = fmt; *f != '%' && *f != 0; ++f)
- ;
- if (f > fmt) {
- len = f - fmt;
- if (len > buflen)
- len = buflen;
- memcpy(buf, fmt, len);
- buf += len;
- buflen -= len;
- fmt = f;
- }
- if (*fmt == 0)
- break;
- c = *++fmt;
- width = prec = 0;
- fillch = ' ';
- if (c == '0') {
- fillch = '0';
- c = *++fmt;
- }
- if (c == '*') {
- width = va_arg(args, int);
- c = *++fmt;
- } else {
- while (isdigit(c)) {
- width = width * 10 + c - '0';
- c = *++fmt;
- }
- }
- if (c == '.') {
- c = *++fmt;
- if (c == '*') {
- prec = va_arg(args, int);
- c = *++fmt;
- } else {
- while (isdigit(c)) {
- prec = prec * 10 + c - '0';
- c = *++fmt;
- }
- }
- }
- str = 0;
- base = 0;
- neg = 0;
- ++fmt;
- switch (c) {
- case 'd':
- i = va_arg(args, int);
- if (i < 0) {
- neg = 1;
- val = -i;
- } else
- val = i;
- base = 10;
- break;
- case 'o':
- val = va_arg(args, unsigned int);
- base = 8;
- break;
- case 'x':
- val = va_arg(args, unsigned int);
- base = 16;
- break;
- case 'p':
- val = (unsigned long) va_arg(args, void *);
- base = 16;
- neg = 2;
- break;
- case 's':
- str = va_arg(args, char *);
- break;
- case 'c':
- num[0] = va_arg(args, int);
- num[1] = 0;
- str = num;
- break;
- case 'm':
- str = strerror(errno);
- break;
- case 'v': /* "visible" string */
- case 'q': /* quoted string */
- quoted = c == 'q';
- p = va_arg(args, unsigned char *);
- if (fillch == '0' && prec > 0) {
- n = prec;
- } else {
- n = strlen((char *)p);
- if (prec > 0 && prec < n)
- n = prec;
- }
- while (n > 0 && buflen > 0) {
- c = *p++;
- --n;
- if (!quoted && c >= 0x80) {
- OUTCHAR('M');
- OUTCHAR('-');
- c -= 0x80;
- }
- if (quoted && (c == '"' || c == '\\'))
- OUTCHAR('\\');
- if (c < 0x20 || (0x7f <= c && c < 0xa0)) {
- if (quoted) {
- OUTCHAR('\\');
- switch (c) {
- case '\t': OUTCHAR('t'); break;
- case '\n': OUTCHAR('n'); break;
- case '\b': OUTCHAR('b'); break;
- case '\f': OUTCHAR('f'); break;
- default:
- OUTCHAR('x');
- OUTCHAR(hexchars[c >> 4]);
- OUTCHAR(hexchars[c & 0xf]);
- }
- } else {
- if (c == '\t')
- OUTCHAR(c);
- else {
- OUTCHAR('^');
- OUTCHAR(c ^ 0x40);
- }
- }
- } else
- OUTCHAR(c);
- }
- continue;
- default:
- *buf++ = '%';
- if (c != '%')
- --fmt; /* so %z outputs %z etc. */
- --buflen;
- continue;
- }
- if (base != 0) {
- str = num + sizeof(num);
- *--str = 0;
- while (str > num + neg) {
- *--str = hexchars[val % base];
- val = val / base;
- if (--prec <= 0 && val == 0)
- break;
- }
- switch (neg) {
- case 1:
- *--str = '-';
- break;
- case 2:
- *--str = 'x';
- *--str = '0';
- break;
- }
- len = num + sizeof(num) - 1 - str;
- } else {
- len = strlen(str);
- if (prec > 0 && len > prec)
- len = prec;
- }
- if (width > 0) {
- if (width > buflen)
- width = buflen;
- if ((n = width - len) > 0) {
- buflen -= n;
- for (; n > 0; --n)
- *buf++ = fillch;
- }
- }
- if (len > buflen)
- len = buflen;
- memcpy(buf, str, len);
- buf += len;
- buflen -= len;
- }
- *buf = 0;
- return buf - buf0;
-}
diff --git a/mdk-stage1/ppp/common/zlib.c b/mdk-stage1/ppp/common/zlib.c
deleted file mode 100644
index 503076886..000000000
--- a/mdk-stage1/ppp/common/zlib.c
+++ /dev/null
@@ -1,5376 +0,0 @@
-/*
- * This file is derived from various .h and .c files from the zlib-1.0.4
- * distribution by Jean-loup Gailly and Mark Adler, with some additions
- * by Paul Mackerras to aid in implementing Deflate compression and
- * decompression for PPP packets. See zlib.h for conditions of
- * distribution and use.
- *
- * Changes that have been made include:
- * - added Z_PACKET_FLUSH (see zlib.h for details)
- * - added inflateIncomp and deflateOutputPending
- * - allow strm->next_out to be NULL, meaning discard the output
- *
- * $Id$
- */
-
-/*
- * ==FILEVERSION 971210==
- *
- * This marker is used by the Linux installation script to determine
- * whether an up-to-date version of this file is already installed.
- */
-
-#define NO_DUMMY_DECL
-#define NO_ZCFUNCS
-#define MY_ZCALLOC
-
-#if defined(__FreeBSD__) && (defined(KERNEL) || defined(_KERNEL))
-#define inflate inflate_ppp /* FreeBSD already has an inflate :-( */
-#endif
-
-
-/* +++ zutil.h */
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-1996 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* From: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */
-
-#ifndef _Z_UTIL_H
-#define _Z_UTIL_H
-
-#include "zlib.h"
-
-#if defined(KERNEL) || defined(_KERNEL)
-/* Assume this is a *BSD or SVR4 kernel */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/systm.h>
-#undef u
-# define HAVE_MEMCPY
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memset(d, v, n) bzero((d), (n))
-# define memcmp bcmp
-
-#else
-#if defined(__KERNEL__)
-/* Assume this is a Linux kernel */
-#include <linux/string.h>
-#define HAVE_MEMCPY
-
-#else /* not kernel */
-
-#if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
-# include <stddef.h>
-# include <errno.h>
-#else
- extern int errno;
-#endif
-#ifdef STDC
-# include <string.h>
-# include <stdlib.h>
-#endif
-#endif /* __KERNEL__ */
-#endif /* _KERNEL || KERNEL */
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#ifdef MSDOS
-# define OS_CODE 0x00
-# ifdef __TURBOC__
-# include <alloc.h>
-# else /* MSC or DJGPP */
-# include <malloc.h>
-# endif
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-#endif
-
-#ifdef WIN32 /* Window 95 & Windows NT */
-# define OS_CODE 0x0b
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define FOPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef MACOS
-# define OS_CODE 0x07
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0F
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
- /* Common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef FOPEN
-# define FOPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#ifdef HAVE_STRERROR
- extern char *strerror OF((int));
-# define zstrerror(errnum) strerror(errnum)
-#else
-# define zstrerror(errnum) ""
-#endif
-
-#if defined(pyr)
-# define NO_MEMCPY
-#endif
-#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
- extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG_ZLIB
-# include <stdio.h>
-# ifndef verbose
-# define verbose 0
-# endif
- extern void z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) fprintf x
-# define Tracev(x) {if (verbose) fprintf x ;}
-# define Tracevv(x) {if (verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
-
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-#endif /* _Z_UTIL_H */
-/* --- zutil.h */
-
-/* +++ deflate.h */
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-1996 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* From: deflate.h,v 1.10 1996/07/02 12:41:00 me Exp $ */
-
-#ifndef _DEFLATE_H
-#define _DEFLATE_H
-
-/* #include "zutil.h" */
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define INIT_STATE 42
-#define BUSY_STATE 113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-typedef struct static_tree_desc_s static_tree_desc;
-
-typedef struct tree_desc_s {
- ct_data *dyn_tree; /* the dynamic tree */
- int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct deflate_state {
- z_streamp strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
- int pending; /* nb of bytes in the pending buffer */
- int noheader; /* suppress zlib header and adler32 */
- Byte data_type; /* UNKNOWN, BINARY or ASCII */
- Byte method; /* STORED (for zip only) or DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
-
- /* used by deflate.c: */
-
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
-
- Bytef *window;
- /* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least wSize
- * bytes. With this organization, matches are limited to a distance of
- * wSize-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: use the user input buffer as sliding window.
- */
-
- ulg window_size;
- /* Actual size of window: 2*wSize, except when the user input buffer
- * is directly used as sliding window.
- */
-
- Posf *prev;
- /* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
- Posf *head; /* Heads of the hash chains or NIL. */
-
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
-
- uInt hash_shift;
- /* Number of bits by which ins_h must be shifted at each input
- * step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * hash_shift * MIN_MATCH >= hash_bits
- */
-
- long block_start;
- /* Window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
-
- uInt prev_length;
- /* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- uInt max_chain_length;
- /* To speed up deflation, hash chains are never searched beyond this
- * length. A higher limit improves compression ratio but degrades the
- * speed.
- */
-
- uInt max_lazy_match;
- /* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-# define max_insert_length max_lazy_match
- /* Insert new strings in the hash table only if the match length is not
- * greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
- int level; /* compression level (1..9) */
- int strategy; /* favor or force Huffman coding*/
-
- uInt good_match;
- /* Use a faster search when the previous match is longer than this */
-
- int nice_match; /* Stop searching when current match exceeds this */
-
- /* used by trees.c: */
- /* Didn't use ct_data typedef below to supress compiler warning */
- struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
- struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
- struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
-
- struct tree_desc_s l_desc; /* desc. for literal tree */
- struct tree_desc_s d_desc; /* desc. for distance tree */
- struct tree_desc_s bl_desc; /* desc. for bit length tree */
-
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
- int heap_len; /* number of elements in the heap */
- int heap_max; /* element of largest frequency */
- /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
- uch depth[2*L_CODES+1];
- /* Depth of each subtree used as tie breaker for trees of equal frequency
- */
-
- uchf *l_buf; /* buffer for literals or lengths */
-
- uInt lit_bufsize;
- /* Size of match buffer for literals/lengths. There are 4 reasons for
- * limiting lit_bufsize to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
- * data is still in the window so we can still emit a stored block even
- * when input comes from standard input. (This can also be done for
- * all blocks if lit_bufsize is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * This is applicable only for zip (not gzip or zlib).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
- * trees more frequently.
- * - I can't count above 4
- */
-
- uInt last_lit; /* running index in l_buf */
-
- ushf *d_buf;
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
- * the same number of elements. To use different lengths, an extra flag
- * array would be necessary.
- */
-
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- ulg compressed_len; /* total bit length of compressed file */
- uInt matches; /* number of string matches in current block */
- int last_eob_len; /* bit length of EOB code for last block */
-
-#ifdef DEBUG_ZLIB
- ulg bits_sent; /* bit length of the compressed data */
-#endif
-
- ush bi_buf;
- /* Output buffer. bits are inserted starting at the bottom (least
- * significant bits).
- */
- int bi_valid;
- /* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-} FAR deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
- /* in trees.c */
-void _tr_init OF((deflate_state *s));
-int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-void _tr_align OF((deflate_state *s));
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-void _tr_stored_type_only OF((deflate_state *));
-
-#endif
-/* --- deflate.h */
-
-/* +++ deflate.c */
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-1996 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many people for bug reports and testing.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- * Available in ftp://ds.internic.net/rfc/rfc1951.txt
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* From: deflate.c,v 1.15 1996/07/24 13:40:58 me Exp $ */
-
-/* #include "deflate.h" */
-
-char deflate_copyright[] = " deflate 1.0.4 Copyright 1995-1996 Jean-loup Gailly ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* ===========================================================================
- * Function prototypes.
- */
-typedef enum {
- need_more, /* block not completed, need more input or more output */
- block_done, /* block flush performed */
- finish_started, /* finish started, need only more output at next deflate */
- finish_done /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-local block_state deflate_slow OF((deflate_state *s, int flush));
-local void lm_init OF((deflate_state *s));
-local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, charf *buf, unsigned size));
-#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
- uInt longest_match OF((deflate_state *s, IPos cur_match));
-#else
-local uInt longest_match OF((deflate_state *s, IPos cur_match));
-#endif
-
-#ifdef DEBUG_ZLIB
-local void check_match OF((deflate_state *s, IPos start, IPos match,
- int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
-} config;
-
-local config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* maximum speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
- s->head[s->hash_size-1] = NIL; \
- zmemzero((charf *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-/* ========================================================================= */
-int deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
-{
- return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
- /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
-{
- deflate_state *s;
- int noheader = 0;
- static char* my_version = ZLIB_VERSION;
-
- ushf *overlay;
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
- * output size for (length,distance) codes is <= 24 bits.
- */
-
- if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
- }
- if (strm == Z_NULL) return Z_STREAM_ERROR;
-
- strm->msg = Z_NULL;
-#ifndef NO_ZCFUNCS
- if (strm->zalloc == Z_NULL) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == Z_NULL) strm->zfree = zcfree;
-#endif
-
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-
- if (windowBits < 0) { /* undocumented feature: suppress zlib header */
- noheader = 1;
- windowBits = -windowBits;
- }
- if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
- return Z_STREAM_ERROR;
- }
- s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
- strm->state = (struct internal_state FAR *)s;
- s->strm = strm;
-
- s->noheader = noheader;
- s->w_bits = windowBits;
- s->w_size = 1 << s->w_bits;
- s->w_mask = s->w_size - 1;
-
- s->hash_bits = memLevel + 7;
- s->hash_size = 1 << s->hash_bits;
- s->hash_mask = s->hash_size - 1;
- s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
-
- s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
- if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
- strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
- deflateEnd (strm);
- return Z_MEM_ERROR;
- }
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
- s->level = level;
- s->strategy = strategy;
- s->method = (Byte)method;
-
- return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
-{
- deflate_state *s;
- uInt length = dictLength;
- uInt n;
- IPos hash_head = 0;
-
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
- return Z_STREAM_ERROR;
-
- s = (deflate_state *) strm->state;
- if (s->status != INIT_STATE) return Z_STREAM_ERROR;
-
- strm->adler = adler32(strm->adler, dictionary, dictLength);
-
- if (length < MIN_MATCH) return Z_OK;
- if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
-#ifndef USE_DICT_HEAD
- dictionary += dictLength - length; /* use the tail of the dictionary */
-#endif
- }
- zmemcpy((charf *)s->window, dictionary, length);
- s->strstart = length;
- s->block_start = (long)length;
-
- /* Insert all strings in the hash table (except for the last two bytes).
- * s->lookahead stays null, so s->ins_h will be recomputed at the next
- * call of fill_window.
- */
- s->ins_h = s->window[0];
- UPDATE_HASH(s, s->ins_h, s->window[1]);
- for (n = 0; n <= length - MIN_MATCH; n++) {
- INSERT_STRING(s, n, hash_head);
- }
- if (hash_head) hash_head = 0; /* to make compiler happy */
- return Z_OK;
-}
-
-/* ========================================================================= */
-int deflateReset (strm)
- z_streamp strm;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR;
-
- strm->total_in = strm->total_out = 0;
- strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
- strm->data_type = Z_UNKNOWN;
-
- s = (deflate_state *)strm->state;
- s->pending = 0;
- s->pending_out = s->pending_buf;
-
- if (s->noheader < 0) {
- s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */
- }
- s->status = s->noheader ? BUSY_STATE : INIT_STATE;
- strm->adler = 1;
- s->last_flush = Z_NO_FLUSH;
-
- _tr_init(s);
- lm_init(s);
-
- return Z_OK;
-}
-
-/* ========================================================================= */
-int deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
-{
- deflate_state *s;
- compress_func func;
- int err = Z_OK;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = (deflate_state *) strm->state;
-
- if (level == Z_DEFAULT_COMPRESSION) {
- level = 6;
- }
- if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
- return Z_STREAM_ERROR;
- }
- func = configuration_table[s->level].func;
-
- if (func != configuration_table[level].func && strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
- }
- if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
- }
- s->strategy = strategy;
- return err;
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
-{
- put_byte(s, (Byte)(b >> 8));
- put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(strm)
- z_streamp strm;
-{
- deflate_state *s = (deflate_state *) strm->state;
- unsigned len = s->pending;
-
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
-
- if (strm->next_out != Z_NULL) {
- zmemcpy(strm->next_out, s->pending_out, len);
- strm->next_out += len;
- }
- s->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- s->pending -= len;
- if (s->pending == 0) {
- s->pending_out = s->pending_buf;
- }
-}
-
-/* ========================================================================= */
-int deflate (strm, flush)
- z_streamp strm;
- int flush;
-{
- int old_flush; /* value of flush param for previous deflate call */
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
- return Z_STREAM_ERROR;
- }
- s = (deflate_state *) strm->state;
-
- if ((strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
- ERR_RETURN(strm, Z_STREAM_ERROR);
- }
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
- s->strm = strm; /* just in case */
- old_flush = s->last_flush;
- s->last_flush = flush;
-
- /* Write the zlib header */
- if (s->status == INIT_STATE) {
-
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags = (s->level-1) >> 1;
-
- if (level_flags > 3) level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
-
- s->status = BUSY_STATE;
- putShortMSB(s, header);
-
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = 1L;
- }
-
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
- flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
- s->last_flush = -1;
- return Z_OK;
- }
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUFF_ERROR.
- */
- } else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* Start a new block or continue the current one.
- */
- if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- block_state bstate;
-
- bstate = (*(configuration_table[s->level].func))(s, flush);
-
- if (bstate == finish_started || bstate == finish_done) {
- s->status = FINISH_STATE;
- }
- if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
- if (bstate == block_done) {
- if (flush == Z_PARTIAL_FLUSH) {
- _tr_align(s);
- } else if (flush == Z_PACKET_FLUSH) {
- /* Output just the 3-bit `stored' block type value,
- but not a zero length. */
- _tr_stored_type_only(s);
- } else { /* FULL_FLUSH or SYNC_FLUSH */
- _tr_stored_block(s, (char*)0, 0L, 0);
- /* For a full flush, this empty block will be recognized
- * as a special marker by inflate_sync().
- */
- if (flush == Z_FULL_FLUSH) {
- CLEAR_HASH(s); /* forget history */
- }
- }
- flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
- }
- }
- Assert(strm->avail_out > 0, "bug2");
-
- if (flush != Z_FINISH) return Z_OK;
- if (s->noheader) return Z_STREAM_END;
-
- /* Write the zlib trailer (adler32) */
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- flush_pending(strm);
- /* If avail_out is zero, the application will call deflate again
- * to flush the rest.
- */
- s->noheader = -1; /* write the trailer only once! */
- return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int deflateEnd (strm)
- z_streamp strm;
-{
- int status;
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = (deflate_state *) strm->state;
-
- status = s->status;
- if (status != INIT_STATE && status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
-
- /* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, s->pending_buf);
- TRY_FREE(strm, s->head);
- TRY_FREE(strm, s->prev);
- TRY_FREE(strm, s->window);
-
- ZFREE(strm, s);
- strm->state = Z_NULL;
-
- return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- */
-int deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
-{
- deflate_state *ds;
- deflate_state *ss;
- ushf *overlay;
-
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL)
- return Z_STREAM_ERROR;
- ss = (deflate_state *) source->state;
-
- zmemcpy(dest, source, sizeof(*dest));
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- dest->state = (struct internal_state FAR *) ds;
- zmemcpy(ds, ss, sizeof(*ds));
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
-
- if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
- return Z_MEM_ERROR;
- }
- /* ??? following zmemcpy doesn't work for 16-bit MSDOS */
- zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
- zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
- zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
- ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
- ds->l_desc.dyn_tree = ds->dyn_ltree;
- ds->d_desc.dyn_tree = ds->dyn_dtree;
- ds->bl_desc.dyn_tree = ds->bl_tree;
-
- return Z_OK;
-}
-
-/* ===========================================================================
- * Return the number of bytes of output which are immediately available
- * for output from the decompressor.
- */
-int deflateOutputPending (strm)
- z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return 0;
-
- return ((deflate_state *)(strm->state))->pending;
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(strm, buf, size)
- z_streamp strm;
- charf *buf;
- unsigned size;
-{
- unsigned len = strm->avail_in;
-
- if (len > size) len = size;
- if (len == 0) return 0;
-
- strm->avail_in -= len;
-
- if (!((deflate_state *)(strm->state))->noheader) {
- strm->adler = adler32(strm->adler, strm->next_in, len);
- }
- zmemcpy(buf, strm->next_in, len);
- strm->next_in += len;
- strm->total_in += len;
-
- return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (s)
- deflate_state *s;
-{
- s->window_size = (ulg)2L*s->w_size;
-
- CLEAR_HASH(s);
-
- /* Set the default configuration parameters:
- */
- s->max_lazy_match = configuration_table[s->level].max_lazy;
- s->good_match = configuration_table[s->level].good_length;
- s->nice_match = configuration_table[s->level].nice_length;
- s->max_chain_length = configuration_table[s->level].max_chain;
-
- s->strstart = 0;
- s->block_start = 0L;
- s->lookahead = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- s->ins_h = 0;
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-}
-
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
- int nice_match = s->nice_match; /* stop if match long enough */
- IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
- Posf *prev = s->prev;
- uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
-#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
-#endif
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- /* Do not waste too much time if we already have a good match: */
- if (s->prev_length >= s->good_match) {
- chain_length >>= 2;
- }
- /* Do not look for matches beyond the end of the input. This is necessary
- * to make deflate deterministic.
- */
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- do {
- Assert(cur_match < s->strstart, "no future");
- match = s->window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2:
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- Assert(scan[2] == match[2], "scan[2]?");
- scan++, match++;
- do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- s->match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
-
- if ((uInt)best_len <= s->lookahead) return best_len;
- return s->lookahead;
-}
-#endif /* ASMV */
-
-#ifdef DEBUG_ZLIB
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (zmemcmp((charf *)s->window + match,
- (charf *)s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
- do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
- z_error("invalid match");
- }
- if (z_verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(s, start, match, length)
-#endif
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or avail_in == 0; reads are
- * performed for at least two bytes (required for the zip translate_eol
- * option -- not supported here).
- */
-local void fill_window(s)
- deflate_state *s;
-{
- register unsigned n, m;
- register Posf *p;
- unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
-
- do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
- /* Deal with !@#$% 64K limit: */
- if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
- more = wsize;
-
- } else if (more == (unsigned)(-1)) {
- /* Very unlikely, but possible on 16 bit machine if strstart == 0
- * and lookahead == 1 (input done one byte at time)
- */
- more--;
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- } else if (s->strstart >= wsize+MAX_DIST(s)) {
-
- zmemcpy((charf *)s->window, (charf *)s->window+wsize,
- (unsigned)wsize);
- s->match_start -= wsize;
- s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
- s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
- more += wsize;
- }
- if (s->strm->avail_in == 0) return;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the BIG_MEM or MMAP case (not yet supported),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(more >= 2, "more < 2");
-
- n = read_buf(s->strm, (charf *)s->window + s->strstart + s->lookahead,
- more);
- s->lookahead += n;
-
- /* Initialize the hash value now that we have some input: */
- if (s->lookahead >= MIN_MATCH) {
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- }
- /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
- * but this is not important since only literal bytes will be emitted.
- */
-
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK_ONLY(s, eof) { \
- _tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
- (ulg)((long)s->strstart - s->block_start), \
- (eof)); \
- s->block_start = s->strstart; \
- flush_pending(s->strm); \
- Tracev((stderr,"[FLUSH]")); \
-}
-
-/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, eof) { \
- FLUSH_BLOCK_ONLY(s, eof); \
- if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
-{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
- */
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
-
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
-
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
- if (s->lookahead == 0) break; /* flush the current block */
- }
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
- */
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
- }
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of the hash chain */
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- if (s->strategy != Z_HUFFMAN_ONLY) {
- s->match_length = longest_match (s, hash_head);
- }
- /* longest_match() sets match_start */
- }
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->match_start, s->match_length);
-
- bflush = _tr_tally(s, s->strstart - s->match_start,
- s->match_length - MIN_MATCH);
-
- s->lookahead -= s->match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
- if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
- s->match_length--; /* string at strstart already in hash table */
- do {
- s->strstart++;
- INSERT_STRING(s, s->strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead.
- */
- } while (--s->match_length != 0);
- s->strstart++;
- } else {
- s->strstart += s->match_length;
- s->match_length = 0;
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
- * matter since it will be recomputed at next deflate call.
- */
- }
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- bflush = _tr_tally (s, 0, s->window[s->strstart]);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of hash chain */
- int bflush; /* set if current block must be flushed */
-
- /* Process the input block. */
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- */
- s->prev_length = s->match_length, s->prev_match = s->match_start;
- s->match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- if (s->strategy != Z_HUFFMAN_ONLY) {
- s->match_length = longest_match (s, hash_head);
- }
- /* longest_match() sets match_start */
-
- if (s->match_length <= 5 && (s->strategy == Z_FILTERED ||
- (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR))) {
-
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- s->match_length = MIN_MATCH-1;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
- uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
- /* Do not insert strings in hash table beyond this. */
-
- check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
- bflush = _tr_tally(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted. If there is not
- * enough lookahead, the last two strings are not inserted in
- * the hash table.
- */
- s->lookahead -= s->prev_length-1;
- s->prev_length -= 2;
- do {
- if (++s->strstart <= max_insert) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
- } while (--s->prev_length != 0);
- s->match_available = 0;
- s->match_length = MIN_MATCH-1;
- s->strstart++;
-
- if (bflush) FLUSH_BLOCK(s, 0);
-
- } else if (s->match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- if (_tr_tally (s, 0, s->window[s->strstart-1])) {
- FLUSH_BLOCK_ONLY(s, 0);
- }
- s->strstart++;
- s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- s->match_available = 1;
- s->strstart++;
- s->lookahead--;
- }
- }
- Assert (flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally (s, 0, s->window[s->strstart-1]);
- s->match_available = 0;
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-/* --- deflate.c */
-
-/* +++ trees.c */
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-1996 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values). The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* From: trees.c,v 1.11 1996/07/24 13:41:06 me Exp $ */
-
-/* #include "deflate.h" */
-
-#ifdef DEBUG_ZLIB
-# include <ctype.h>
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-local int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-local uch dist_code[512];
-/* distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-local uch length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-struct static_tree_desc_s {
- ct_data *static_tree; /* static tree or NULL */
- intf *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
-};
-
-local static_tree_desc static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc static_d_desc =
-{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-
-local static_tree_desc static_bl_desc =
-{(ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- int blcodes));
-local void compress_block OF((deflate_state *s, ct_data *ltree,
- ct_data *dtree));
-local void set_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
-
-#ifndef DEBUG_ZLIB
-# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG_ZLIB */
-# define send_code(s, c, tree) \
- { if (verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-#define d_code(dist) \
- ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. dist_code[256] and dist_code[257] are never
- * used.
- */
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
- put_byte(s, (uch)((w) & 0xff)); \
- put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG_ZLIB
-local void send_bits OF((deflate_state *s, int value, int length));
-
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
-{
- Tracevv((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
-
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (value << s->bi_valid);
- put_short(s, s->bi_buf);
- s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
- s->bi_valid += length - Buf_size;
- } else {
- s->bi_buf |= value << s->bi_valid;
- s->bi_valid += length;
- }
-}
-#else /* !DEBUG_ZLIB */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
- if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
- s->bi_buf |= (val << s->bi_valid);\
- put_short(s, s->bi_buf);\
- s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
- s->bi_valid += len - Buf_size;\
- } else {\
- s->bi_buf |= (value) << s->bi_valid;\
- s->bi_valid += len;\
- }\
-}
-#endif /* DEBUG_ZLIB */
-
-
-#define MAX(a,b) (a >= b ? a : b)
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables. In a multi-threaded environment,
- * this function may be called by two threads concurrently, but this is
- * harmless since both invocations do exactly the same thing.
- */
-local void tr_static_init()
-{
- static int static_init_done = 0;
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- if (static_init_done) return;
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- length_code[length++] = (uch)code;
- }
- }
- Assert (length == 256, "tr_static_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- length_code[length-1] = (uch)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- dist_code[dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse((unsigned)n, 5);
- }
- static_init_done = 1;
-}
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void _tr_init(s)
- deflate_state *s;
-{
- tr_static_init();
-
- s->compressed_len = 0L;
-
- s->l_desc.dyn_tree = s->dyn_ltree;
- s->l_desc.stat_desc = &static_l_desc;
-
- s->d_desc.dyn_tree = s->dyn_dtree;
- s->d_desc.stat_desc = &static_d_desc;
-
- s->bl_desc.dyn_tree = s->bl_tree;
- s->bl_desc.stat_desc = &static_bl_desc;
-
- s->bi_buf = 0;
- s->bi_valid = 0;
- s->last_eob_len = 8; /* enough lookahead for inflate */
-#ifdef DEBUG_ZLIB
- s->bits_sent = 0L;
-#endif
-
- /* Initialize the first block of the first file: */
- init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(s)
- deflate_state *s;
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
- s->dyn_ltree[END_BLOCK].Freq = 1;
- s->opt_len = s->static_len = 0L;
- s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
- top = s->heap[SMALLEST]; \
- s->heap[SMALLEST] = s->heap[s->heap_len--]; \
- pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = s->heap[k];
- int j = k << 1; /* left son of k */
- while (j <= s->heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
- j++;
- }
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
-
- /* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- ct_data *stree = desc->stat_desc->static_tree;
- intf *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
- for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
- n = s->heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- s->bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
- s->bl_count[bits]--; /* move one leaf down the tree */
- s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
- s->bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = s->bl_count[bits];
- while (n != 0) {
- m = s->heap[--h];
- if (m > max_code) continue;
- if (tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
- "inconsistent bit counts");
- Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
-
- Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
- }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- ct_data *stree = desc->stat_desc->static_tree;
- int elems = desc->stat_desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node; /* new node being created */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- s->heap[++(s->heap_len)] = max_code = n;
- s->depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (s->heap_len < 2) {
- node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
- tree[node].Freq = 1;
- s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
- /* node is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- node = elems; /* next internal node of the tree */
- do {
- pqremove(s, tree, n); /* n = node of least frequency */
- m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
- s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
- s->heap[--(s->heap_max)] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- s->depth[node] = (uch) (MAX(s->depth[n], s->depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == s->bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- s->heap[SMALLEST] = node++;
- pqdownheap(s, tree, SMALLEST);
-
- } while (s->heap_len >= 2);
-
- s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen(s, (tree_desc *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
- s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- s->bl_tree[REPZ_3_10].Freq++;
- } else {
- s->bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(s)
- deflate_state *s;
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
- scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree(s, (tree_desc *)(&(s->bl_desc)));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
- s->opt_len, s->static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(s, dcodes-1, 5);
- send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void _tr_stored_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
- s->compressed_len += (stored_len + 4) << 3;
-
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* Send just the `stored block' type code without any length bytes or data.
- */
-void _tr_stored_type_only(s)
- deflate_state *s;
-{
- send_bits(s, (STORED_BLOCK << 1), 3);
- bi_windup(s);
- s->compressed_len = (s->compressed_len + 3) & ~7L;
-}
-
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- * The current inflate code requires 9 bits of lookahead. If the
- * last two codes for the previous block (real code plus EOB) were coded
- * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
- * the last real code. In this case we send two empty static blocks instead
- * of one. (There are no problems if the previous block is stored or fixed.)
- * To simplify the code, we assume the worst case of last real code encoded
- * on one bit only.
- */
-void _tr_align(s)
- deflate_state *s;
-{
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
- s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
- bi_flush(s);
- /* Of the 10 bits for the empty block, we have already sent
- * (10 - bi_valid) bits. The lookahead for the last real code (before
- * the EOB of the previous block) was thus at least one plus the length
- * of the EOB plus what we have just sent of the empty static block.
- */
- if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
- s->compressed_len += 10L;
- bi_flush(s);
- }
- s->last_eob_len = 7;
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file. This function
- * returns the total compressed length for the file so far.
- */
-ulg _tr_flush_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex = 0; /* index of last bit length code of non zero freq */
-
- /* Build the Huffman trees unless a stored block is forced */
- if (s->level > 0) {
-
- /* Check if the file is ascii or binary */
- if (s->data_type == Z_UNKNOWN) set_data_type(s);
-
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
-
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
-
- /* Determine the best encoding. Compute first the block length in bytes*/
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
-
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- } else {
- Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
- }
-
- /* If compression failed and this is the first and last block,
- * and if the .zip file can be seeked (to rewrite the local header),
- * the whole file is transformed into a stored file:
- */
-#ifdef STORED_FILE_OK
-# ifdef FORCE_STORED_FILE
- if (eof && s->compressed_len == 0L) { /* force stored file */
-# else
- if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
-# endif
- /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
- if (buf == (charf*)0) error ("block vanished");
-
- copy_block(s, buf, (unsigned)stored_len, 0); /* without header */
- s->compressed_len = stored_len << 3;
- s->method = STORED;
- } else
-#endif /* STORED_FILE_OK */
-
-#ifdef FORCE_STORED
- if (buf != (char*)0) { /* force stored block */
-#else
- if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- _tr_stored_block(s, buf, stored_len, eof);
-
-#ifdef FORCE_STATIC
- } else if (static_lenb >= 0) { /* force static trees */
-#else
- } else if (static_lenb == opt_lenb) {
-#endif
- send_bits(s, (STATIC_TREES<<1)+eof, 3);
- compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
- s->compressed_len += 3 + s->static_len;
- } else {
- send_bits(s, (DYN_TREES<<1)+eof, 3);
- send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
- max_blindex+1);
- compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
- s->compressed_len += 3 + s->opt_len;
- }
- Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- init_block(s);
-
- if (eof) {
- bi_windup(s);
- s->compressed_len += 7; /* align on byte boundary */
- }
- Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*eof));
-
- return s->compressed_len >> 3;
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
-{
- s->d_buf[s->last_lit] = (ush)dist;
- s->l_buf[s->last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- s->dyn_ltree[lc].Freq++;
- } else {
- s->matches++;
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST(s) &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
-
- s->dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
- s->dyn_dtree[d_code(dist)].Freq++;
- }
-
- /* Try to guess if it is profitable to stop the current block here */
- if (s->level > 2 && (s->last_lit & 0xfff) == 0) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
- }
- return (s->last_lit == s->lit_bufsize-1);
- /* We avoid equality with lit_bufsize because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
-
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert(s->pending < s->lit_bufsize + 2*lx, "pendingBuf overflow");
-
- } while (lx < s->last_lit);
-
- send_code(s, END_BLOCK, ltree);
- s->last_eob_len = ltree[END_BLOCK].Len;
-}
-
-/* ===========================================================================
- * Set the data type to ASCII or BINARY, using a crude approximation:
- * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
- * IN assertion: the fields freq of dyn_ltree are set and the total of all
- * frequencies does not exceed 64K (to fit in an int on 16 bit machines).
- */
-local void set_data_type(s)
- deflate_state *s;
-{
- int n = 0;
- unsigned ascii_freq = 0;
- unsigned bin_freq = 0;
- while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
- while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
- while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
- s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Flush the bit buffer, keeping at most 7 bits in it.
- */
-local void bi_flush(s)
- deflate_state *s;
-{
- if (s->bi_valid == 16) {
- put_short(s, s->bi_buf);
- s->bi_buf = 0;
- s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
- put_byte(s, (Byte)s->bi_buf);
- s->bi_buf >>= 8;
- s->bi_valid -= 8;
- }
-}
-
-/* ===========================================================================
- * Flush the bit buffer and align the output on a byte boundary
- */
-local void bi_windup(s)
- deflate_state *s;
-{
- if (s->bi_valid > 8) {
- put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
- put_byte(s, (Byte)s->bi_buf);
- }
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG_ZLIB
- s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
- s->last_eob_len = 8; /* enough lookahead for inflate */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG_ZLIB
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG_ZLIB
- s->bits_sent += (ulg)len<<3;
-#endif
- /* bundle up the put_byte(s, *buf++) calls */
- zmemcpy(&s->pending_buf[s->pending], buf, len);
- s->pending += len;
-}
-/* --- trees.c */
-
-/* +++ inflate.c */
-/* inflate.c -- zlib interface to inflate modules
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* #include "zutil.h" */
-
-/* +++ infblock.h */
-/* infblock.h -- header to use infblock.c
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-struct inflate_blocks_state;
-typedef struct inflate_blocks_state FAR inflate_blocks_statef;
-
-extern inflate_blocks_statef * inflate_blocks_new OF((
- z_streamp z,
- check_func c, /* check function */
- uInt w)); /* window size */
-
-extern int inflate_blocks OF((
- inflate_blocks_statef *,
- z_streamp ,
- int)); /* initial return code */
-
-extern void inflate_blocks_reset OF((
- inflate_blocks_statef *,
- z_streamp ,
- uLongf *)); /* check value on output */
-
-extern int inflate_blocks_free OF((
- inflate_blocks_statef *,
- z_streamp ,
- uLongf *)); /* check value on output */
-
-extern void inflate_set_dictionary OF((
- inflate_blocks_statef *s,
- const Bytef *d, /* dictionary */
- uInt n)); /* dictionary length */
-
-extern int inflate_addhistory OF((
- inflate_blocks_statef *,
- z_streamp));
-
-extern int inflate_packet_flush OF((
- inflate_blocks_statef *));
-/* --- infblock.h */
-
-#ifndef NO_DUMMY_DECL
-struct inflate_blocks_state {int dummy;}; /* for buggy compilers */
-#endif
-
-/* inflate private state */
-struct internal_state {
-
- /* mode */
- enum {
- METHOD, /* waiting for method byte */
- FLAG, /* waiting for flag byte */
- DICT4, /* four dictionary check bytes to go */
- DICT3, /* three dictionary check bytes to go */
- DICT2, /* two dictionary check bytes to go */
- DICT1, /* one dictionary check byte to go */
- DICT0, /* waiting for inflateSetDictionary */
- BLOCKS, /* decompressing blocks */
- CHECK4, /* four check bytes to go */
- CHECK3, /* three check bytes to go */
- CHECK2, /* two check bytes to go */
- CHECK1, /* one check byte to go */
- DONE, /* finished check, done */
- BAD} /* got an error--stay here */
- mode; /* current inflate mode */
-
- /* mode dependent information */
- union {
- uInt method; /* if FLAGS, method byte */
- struct {
- uLong was; /* computed check value */
- uLong need; /* stream check value */
- } check; /* if CHECK, check values to compare */
- uInt marker; /* if BAD, inflateSync's marker bytes count */
- } sub; /* submode */
-
- /* mode independent information */
- int nowrap; /* flag for no wrapper */
- uInt wbits; /* log2(window size) (8..15, defaults to 15) */
- inflate_blocks_statef
- *blocks; /* current inflate_blocks state */
-
-};
-
-
-int inflateReset(z)
-z_streamp z;
-{
- uLong c;
-
- if (z == Z_NULL || z->state == Z_NULL)
- return Z_STREAM_ERROR;
- z->total_in = z->total_out = 0;
- z->msg = Z_NULL;
- z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
- inflate_blocks_reset(z->state->blocks, z, &c);
- Trace((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-
-int inflateEnd(z)
-z_streamp z;
-{
- uLong c;
-
- if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
- return Z_STREAM_ERROR;
- if (z->state->blocks != Z_NULL)
- inflate_blocks_free(z->state->blocks, z, &c);
- ZFREE(z, z->state);
- z->state = Z_NULL;
- Trace((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-
-int inflateInit2_(z, w, version, stream_size)
-z_streamp z;
-int w;
-const char *version;
-int stream_size;
-{
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != sizeof(z_stream))
- return Z_VERSION_ERROR;
-
- /* initialize state */
- if (z == Z_NULL)
- return Z_STREAM_ERROR;
- z->msg = Z_NULL;
-#ifndef NO_ZCFUNCS
- if (z->zalloc == Z_NULL)
- {
- z->zalloc = zcalloc;
- z->opaque = (voidpf)0;
- }
- if (z->zfree == Z_NULL) z->zfree = zcfree;
-#endif
- if ((z->state = (struct internal_state FAR *)
- ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
- return Z_MEM_ERROR;
- z->state->blocks = Z_NULL;
-
- /* handle undocumented nowrap option (no zlib header or check) */
- z->state->nowrap = 0;
- if (w < 0)
- {
- w = - w;
- z->state->nowrap = 1;
- }
-
- /* set window size */
- if (w < 8 || w > 15)
- {
- inflateEnd(z);
- return Z_STREAM_ERROR;
- }
- z->state->wbits = (uInt)w;
-
- /* create inflate_blocks state */
- if ((z->state->blocks =
- inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
- == Z_NULL)
- {
- inflateEnd(z);
- return Z_MEM_ERROR;
- }
- Trace((stderr, "inflate: allocated\n"));
-
- /* reset state */
- inflateReset(z);
- return Z_OK;
-}
-
-
-int inflateInit_(z, version, stream_size)
-z_streamp z;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(z, DEF_WBITS, version, stream_size);
-}
-
-
-#define NEEDBYTE {if(z->avail_in==0)goto empty;r=Z_OK;}
-#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
-
-int inflate(z, f)
-z_streamp z;
-int f;
-{
- int r;
- uInt b;
-
- if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL || f < 0)
- return Z_STREAM_ERROR;
- r = Z_BUF_ERROR;
- while (1) switch (z->state->mode)
- {
- case METHOD:
- NEEDBYTE
- if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED)
- {
- z->state->mode = BAD;
- z->msg = (char*)"unknown compression method";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
- {
- z->state->mode = BAD;
- z->msg = (char*)"invalid window size";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- z->state->mode = FLAG;
- case FLAG:
- NEEDBYTE
- b = NEXTBYTE;
- if (((z->state->sub.method << 8) + b) % 31)
- {
- z->state->mode = BAD;
- z->msg = (char*)"incorrect header check";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- Trace((stderr, "inflate: zlib header ok\n"));
- if (!(b & PRESET_DICT))
- {
- z->state->mode = BLOCKS;
- break;
- }
- z->state->mode = DICT4;
- case DICT4:
- NEEDBYTE
- z->state->sub.check.need = (uLong)NEXTBYTE << 24;
- z->state->mode = DICT3;
- case DICT3:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE << 16;
- z->state->mode = DICT2;
- case DICT2:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE << 8;
- z->state->mode = DICT1;
- case DICT1:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE;
- z->adler = z->state->sub.check.need;
- z->state->mode = DICT0;
- return Z_NEED_DICT;
- case DICT0:
- z->state->mode = BAD;
- z->msg = (char*)"need dictionary";
- z->state->sub.marker = 0; /* can try inflateSync */
- return Z_STREAM_ERROR;
- case BLOCKS:
- r = inflate_blocks(z->state->blocks, z, r);
- if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0)
- r = inflate_packet_flush(z->state->blocks);
- if (r == Z_DATA_ERROR)
- {
- z->state->mode = BAD;
- z->state->sub.marker = 0; /* can try inflateSync */
- break;
- }
- if (r != Z_STREAM_END)
- return r;
- r = Z_OK;
- inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
- if (z->state->nowrap)
- {
- z->state->mode = DONE;
- break;
- }
- z->state->mode = CHECK4;
- case CHECK4:
- NEEDBYTE
- z->state->sub.check.need = (uLong)NEXTBYTE << 24;
- z->state->mode = CHECK3;
- case CHECK3:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE << 16;
- z->state->mode = CHECK2;
- case CHECK2:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE << 8;
- z->state->mode = CHECK1;
- case CHECK1:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE;
-
- if (z->state->sub.check.was != z->state->sub.check.need)
- {
- z->state->mode = BAD;
- z->msg = (char*)"incorrect data check";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- Trace((stderr, "inflate: zlib check ok\n"));
- z->state->mode = DONE;
- case DONE:
- return Z_STREAM_END;
- case BAD:
- return Z_DATA_ERROR;
- default:
- return Z_STREAM_ERROR;
- }
-
- empty:
- if (f != Z_PACKET_FLUSH)
- return r;
- z->state->mode = BAD;
- z->msg = (char *)"need more for packet flush";
- z->state->sub.marker = 0; /* can try inflateSync */
- return Z_DATA_ERROR;
-}
-
-
-int inflateSetDictionary(z, dictionary, dictLength)
-z_streamp z;
-const Bytef *dictionary;
-uInt dictLength;
-{
- uInt length = dictLength;
-
- if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0)
- return Z_STREAM_ERROR;
-
- if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
- z->adler = 1L;
-
- if (length >= ((uInt)1<<z->state->wbits))
- {
- length = (1<<z->state->wbits)-1;
- dictionary += dictLength - length;
- }
- inflate_set_dictionary(z->state->blocks, dictionary, length);
- z->state->mode = BLOCKS;
- return Z_OK;
-}
-
-/*
- * This subroutine adds the data at next_in/avail_in to the output history
- * without performing any output. The output buffer must be "caught up";
- * i.e. no pending output (hence s->read equals s->write), and the state must
- * be BLOCKS (i.e. we should be willing to see the start of a series of
- * BLOCKS). On exit, the output will also be caught up, and the checksum
- * will have been updated if need be.
- */
-
-int inflateIncomp(z)
-z_stream *z;
-{
- if (z->state->mode != BLOCKS)
- return Z_DATA_ERROR;
- return inflate_addhistory(z->state->blocks, z);
-}
-
-
-int inflateSync(z)
-z_streamp z;
-{
- uInt n; /* number of bytes to look at */
- Bytef *p; /* pointer to bytes */
- uInt m; /* number of marker bytes found in a row */
- uLong r, w; /* temporaries to save total_in and total_out */
-
- /* set up */
- if (z == Z_NULL || z->state == Z_NULL)
- return Z_STREAM_ERROR;
- if (z->state->mode != BAD)
- {
- z->state->mode = BAD;
- z->state->sub.marker = 0;
- }
- if ((n = z->avail_in) == 0)
- return Z_BUF_ERROR;
- p = z->next_in;
- m = z->state->sub.marker;
-
- /* search */
- while (n && m < 4)
- {
- if (*p == (Byte)(m < 2 ? 0 : 0xff))
- m++;
- else if (*p)
- m = 0;
- else
- m = 4 - m;
- p++, n--;
- }
-
- /* restore */
- z->total_in += p - z->next_in;
- z->next_in = p;
- z->avail_in = n;
- z->state->sub.marker = m;
-
- /* return no joy or set up to restart on a new block */
- if (m != 4)
- return Z_DATA_ERROR;
- r = z->total_in; w = z->total_out;
- inflateReset(z);
- z->total_in = r; z->total_out = w;
- z->state->mode = BLOCKS;
- return Z_OK;
-}
-
-#undef NEEDBYTE
-#undef NEXTBYTE
-/* --- inflate.c */
-
-/* +++ infblock.c */
-/* infblock.c -- interpret and process block types to last block
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* #include "zutil.h" */
-/* #include "infblock.h" */
-
-/* +++ inftrees.h */
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Huffman code lookup table entry--this entry is four bytes for machines
- that have 16-bit pointers (e.g. PC's in the small or medium model). */
-
-typedef struct inflate_huft_s FAR inflate_huft;
-
-struct inflate_huft_s {
- union {
- struct {
- Byte Exop; /* number of extra bits or operation */
- Byte Bits; /* number of bits in this code or subcode */
- } what;
- Bytef *pad; /* pad structure to a power of 2 (4 bytes for */
- } word; /* 16-bit, 8 bytes for 32-bit machines) */
- union {
- uInt Base; /* literal, length base, or distance base */
- inflate_huft *Next; /* pointer to next level of table */
- } more;
-};
-
-#ifdef DEBUG_ZLIB
- extern uInt inflate_hufts;
-#endif
-
-extern int inflate_trees_bits OF((
- uIntf *, /* 19 code lengths */
- uIntf *, /* bits tree desired/actual depth */
- inflate_huft * FAR *, /* bits tree result */
- z_streamp )); /* for zalloc, zfree functions */
-
-extern int inflate_trees_dynamic OF((
- uInt, /* number of literal/length codes */
- uInt, /* number of distance codes */
- uIntf *, /* that many (total) code lengths */
- uIntf *, /* literal desired/actual bit depth */
- uIntf *, /* distance desired/actual bit depth */
- inflate_huft * FAR *, /* literal/length tree result */
- inflate_huft * FAR *, /* distance tree result */
- z_streamp )); /* for zalloc, zfree functions */
-
-extern int inflate_trees_fixed OF((
- uIntf *, /* literal desired/actual bit depth */
- uIntf *, /* distance desired/actual bit depth */
- inflate_huft * FAR *, /* literal/length tree result */
- inflate_huft * FAR *)); /* distance tree result */
-
-extern int inflate_trees_free OF((
- inflate_huft *, /* tables to free */
- z_streamp )); /* for zfree function */
-
-/* --- inftrees.h */
-
-/* +++ infcodes.h */
-/* infcodes.h -- header to use infcodes.c
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-struct inflate_codes_state;
-typedef struct inflate_codes_state FAR inflate_codes_statef;
-
-extern inflate_codes_statef *inflate_codes_new OF((
- uInt, uInt,
- inflate_huft *, inflate_huft *,
- z_streamp ));
-
-extern int inflate_codes OF((
- inflate_blocks_statef *,
- z_streamp ,
- int));
-
-extern void inflate_codes_free OF((
- inflate_codes_statef *,
- z_streamp ));
-
-/* --- infcodes.h */
-
-/* +++ infutil.h */
-/* infutil.h -- types and macros common to blocks and codes
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-#ifndef _INFUTIL_H
-#define _INFUTIL_H
-
-typedef enum {
- TYPE, /* get type bits (3, including end bit) */
- LENS, /* get lengths for stored */
- STORED, /* processing stored block */
- TABLE, /* get table lengths */
- BTREE, /* get bit lengths tree for a dynamic block */
- DTREE, /* get length, distance trees for a dynamic block */
- CODES, /* processing fixed or dynamic block */
- DRY, /* output remaining window bytes */
- DONEB, /* finished last block, done */
- BADB} /* got a data error--stuck here */
-inflate_block_mode;
-
-/* inflate blocks semi-private state */
-struct inflate_blocks_state {
-
- /* mode */
- inflate_block_mode mode; /* current inflate_block mode */
-
- /* mode dependent information */
- union {
- uInt left; /* if STORED, bytes left to copy */
- struct {
- uInt table; /* table lengths (14 bits) */
- uInt index; /* index into blens (or border) */
- uIntf *blens; /* bit lengths of codes */
- uInt bb; /* bit length tree depth */
- inflate_huft *tb; /* bit length decoding tree */
- } trees; /* if DTREE, decoding info for trees */
- struct {
- inflate_huft *tl;
- inflate_huft *td; /* trees to free */
- inflate_codes_statef
- *codes;
- } decode; /* if CODES, current state */
- } sub; /* submode */
- uInt last; /* true if this block is the last block */
-
- /* mode independent information */
- uInt bitk; /* bits in bit buffer */
- uLong bitb; /* bit buffer */
- Bytef *window; /* sliding window */
- Bytef *end; /* one byte after sliding window */
- Bytef *read; /* window read pointer */
- Bytef *write; /* window write pointer */
- check_func checkfn; /* check function */
- uLong check; /* check on output */
-
-};
-
-
-/* defines for inflate input/output */
-/* update pointers and return */
-#define UPDBITS {s->bitb=b;s->bitk=k;}
-#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
-#define UPDOUT {s->write=q;}
-#define UPDATE {UPDBITS UPDIN UPDOUT}
-#define LEAVE {UPDATE return inflate_flush(s,z,r);}
-/* get bytes and bits */
-#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
-#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
-#define NEXTBYTE (n--,*p++)
-#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define DUMPBITS(j) {b>>=(j);k-=(j);}
-/* output bytes */
-#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
-#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
-#define WWRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
-#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
-#define NEEDOUT {if(m==0){WWRAP if(m==0){FLUSH WWRAP if(m==0) LEAVE}}r=Z_OK;}
-#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
-/* load local pointers */
-#define LOAD {LOADIN LOADOUT}
-
-/* masks for lower bits (size given to avoid silly warnings with Visual C++) */
-extern uInt inflate_mask[17];
-
-/* copy as much as possible from the sliding window to the output area */
-extern int inflate_flush OF((
- inflate_blocks_statef *,
- z_streamp ,
- int));
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#endif
-/* --- infutil.h */
-
-#ifndef NO_DUMMY_DECL
-struct inflate_codes_state {int dummy;}; /* for buggy compilers */
-#endif
-
-/* Table for deflate from PKZIP's appnote.txt. */
-local const uInt border[] = { /* Order of the bit length code lengths */
- 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
-/*
- Notes beyond the 1.93a appnote.txt:
-
- 1. Distance pointers never point before the beginning of the output
- stream.
- 2. Distance pointers can point back across blocks, up to 32k away.
- 3. There is an implied maximum of 7 bits for the bit length table and
- 15 bits for the actual data.
- 4. If only one code exists, then it is encoded using one bit. (Zero
- would be more efficient, but perhaps a little confusing.) If two
- codes exist, they are coded using one bit each (0 and 1).
- 5. There is no way of sending zero distance codes--a dummy must be
- sent if there are none. (History: a pre 2.0 version of PKZIP would
- store blocks with no distance codes, but this was discovered to be
- too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
- zero distance codes, which is sent as one code of zero bits in
- length.
- 6. There are up to 286 literal/length codes. Code 256 represents the
- end-of-block. Note however that the static length tree defines
- 288 codes just to fill out the Huffman codes. Codes 286 and 287
- cannot be used though, since there is no length base or extra bits
- defined for them. Similarily, there are up to 30 distance codes.
- However, static trees define 32 codes (all 5 bits) to fill out the
- Huffman codes, but the last two had better not show up in the data.
- 7. Unzip can check dynamic Huffman blocks for complete code sets.
- The exception is that a single code would not be complete (see #4).
- 8. The five bits following the block type is really the number of
- literal codes sent minus 257.
- 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
- (1+6+6). Therefore, to output three times the length, you output
- three codes (1+1+1), whereas to output four times the same length,
- you only need two codes (1+3). Hmm.
- 10. In the tree reconstruction algorithm, Code = Code + Increment
- only if BitLength(i) is not zero. (Pretty obvious.)
- 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
- 12. Note: length code 284 can represent 227-258, but length code 285
- really is 258. The last length deserves its own, short code
- since it gets used a lot in very redundant files. The length
- 258 is special since 258 - 3 (the min match length) is 255.
- 13. The literal/length and distance code bit lengths are read as a
- single stream of lengths. It is possible (and advantageous) for
- a repeat code (16, 17, or 18) to go across the boundary between
- the two sets of lengths.
- */
-
-
-void inflate_blocks_reset(s, z, c)
-inflate_blocks_statef *s;
-z_streamp z;
-uLongf *c;
-{
- if (s->checkfn != Z_NULL)
- *c = s->check;
- if (s->mode == BTREE || s->mode == DTREE)
- ZFREE(z, s->sub.trees.blens);
- if (s->mode == CODES)
- {
- inflate_codes_free(s->sub.decode.codes, z);
- inflate_trees_free(s->sub.decode.td, z);
- inflate_trees_free(s->sub.decode.tl, z);
- }
- s->mode = TYPE;
- s->bitk = 0;
- s->bitb = 0;
- s->read = s->write = s->window;
- if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(0L, Z_NULL, 0);
- Trace((stderr, "inflate: blocks reset\n"));
-}
-
-
-inflate_blocks_statef *inflate_blocks_new(z, c, w)
-z_streamp z;
-check_func c;
-uInt w;
-{
- inflate_blocks_statef *s;
-
- if ((s = (inflate_blocks_statef *)ZALLOC
- (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
- return s;
- if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
- {
- ZFREE(z, s);
- return Z_NULL;
- }
- s->end = s->window + w;
- s->checkfn = c;
- s->mode = TYPE;
- Trace((stderr, "inflate: blocks allocated\n"));
- inflate_blocks_reset(s, z, &s->check);
- return s;
-}
-
-
-#ifdef DEBUG_ZLIB
- extern uInt inflate_hufts;
-#endif
-int inflate_blocks(s, z, r)
-inflate_blocks_statef *s;
-z_streamp z;
-int r;
-{
- uInt t; /* temporary storage */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
-
- /* copy input/output information to locals (UPDATE macro restores) */
- LOAD
-
- /* process input based on current state */
- while (1) switch (s->mode)
- {
- case TYPE:
- NEEDBITS(3)
- t = (uInt)b & 7;
- s->last = t & 1;
- switch (t >> 1)
- {
- case 0: /* stored */
- Trace((stderr, "inflate: stored block%s\n",
- s->last ? " (last)" : ""));
- DUMPBITS(3)
- t = k & 7; /* go to byte boundary */
- DUMPBITS(t)
- s->mode = LENS; /* get length of stored block */
- break;
- case 1: /* fixed */
- Trace((stderr, "inflate: fixed codes block%s\n",
- s->last ? " (last)" : ""));
- {
- uInt bl, bd;
- inflate_huft *tl, *td;
-
- inflate_trees_fixed(&bl, &bd, &tl, &td);
- s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
- if (s->sub.decode.codes == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- s->sub.decode.tl = Z_NULL; /* don't try to free these */
- s->sub.decode.td = Z_NULL;
- }
- DUMPBITS(3)
- s->mode = CODES;
- break;
- case 2: /* dynamic */
- Trace((stderr, "inflate: dynamic codes block%s\n",
- s->last ? " (last)" : ""));
- DUMPBITS(3)
- s->mode = TABLE;
- break;
- case 3: /* illegal */
- DUMPBITS(3)
- s->mode = BADB;
- z->msg = (char*)"invalid block type";
- r = Z_DATA_ERROR;
- LEAVE
- }
- break;
- case LENS:
- NEEDBITS(32)
- if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
- {
- s->mode = BADB;
- z->msg = (char*)"invalid stored block lengths";
- r = Z_DATA_ERROR;
- LEAVE
- }
- s->sub.left = (uInt)b & 0xffff;
- b = k = 0; /* dump bits */
- Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
- s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
- break;
- case STORED:
- if (n == 0)
- LEAVE
- NEEDOUT
- t = s->sub.left;
- if (t > n) t = n;
- if (t > m) t = m;
- zmemcpy(q, p, t);
- p += t; n -= t;
- q += t; m -= t;
- if ((s->sub.left -= t) != 0)
- break;
- Tracev((stderr, "inflate: stored end, %lu total out\n",
- z->total_out + (q >= s->read ? q - s->read :
- (s->end - s->read) + (q - s->window))));
- s->mode = s->last ? DRY : TYPE;
- break;
- case TABLE:
- NEEDBITS(14)
- s->sub.trees.table = t = (uInt)b & 0x3fff;
-#ifndef PKZIP_BUG_WORKAROUND
- if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
- {
- s->mode = BADB;
- z->msg = (char*)"too many length or distance symbols";
- r = Z_DATA_ERROR;
- LEAVE
- }
-#endif
- t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
- if (t < 19)
- t = 19;
- if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- DUMPBITS(14)
- s->sub.trees.index = 0;
- Tracev((stderr, "inflate: table sizes ok\n"));
- s->mode = BTREE;
- case BTREE:
- while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
- {
- NEEDBITS(3)
- s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
- DUMPBITS(3)
- }
- while (s->sub.trees.index < 19)
- s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
- s->sub.trees.bb = 7;
- t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
- &s->sub.trees.tb, z);
- if (t != Z_OK)
- {
- ZFREE(z, s->sub.trees.blens);
- r = t;
- if (r == Z_DATA_ERROR)
- s->mode = BADB;
- LEAVE
- }
- s->sub.trees.index = 0;
- Tracev((stderr, "inflate: bits tree ok\n"));
- s->mode = DTREE;
- case DTREE:
- while (t = s->sub.trees.table,
- s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
- {
- inflate_huft *h;
- uInt i, j, c;
-
- t = s->sub.trees.bb;
- NEEDBITS(t)
- h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
- t = h->word.what.Bits;
- c = h->more.Base;
- if (c < 16)
- {
- DUMPBITS(t)
- s->sub.trees.blens[s->sub.trees.index++] = c;
- }
- else /* c == 16..18 */
- {
- i = c == 18 ? 7 : c - 14;
- j = c == 18 ? 11 : 3;
- NEEDBITS(t + i)
- DUMPBITS(t)
- j += (uInt)b & inflate_mask[i];
- DUMPBITS(i)
- i = s->sub.trees.index;
- t = s->sub.trees.table;
- if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
- (c == 16 && i < 1))
- {
- inflate_trees_free(s->sub.trees.tb, z);
- ZFREE(z, s->sub.trees.blens);
- s->mode = BADB;
- z->msg = (char*)"invalid bit length repeat";
- r = Z_DATA_ERROR;
- LEAVE
- }
- c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
- do {
- s->sub.trees.blens[i++] = c;
- } while (--j);
- s->sub.trees.index = i;
- }
- }
- inflate_trees_free(s->sub.trees.tb, z);
- s->sub.trees.tb = Z_NULL;
- {
- uInt bl, bd;
- inflate_huft *tl, *td;
- inflate_codes_statef *c;
-
- bl = 9; /* must be <= 9 for lookahead assumptions */
- bd = 6; /* must be <= 9 for lookahead assumptions */
- t = s->sub.trees.table;
-#ifdef DEBUG_ZLIB
- inflate_hufts = 0;
-#endif
- t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
- s->sub.trees.blens, &bl, &bd, &tl, &td, z);
- ZFREE(z, s->sub.trees.blens);
- if (t != Z_OK)
- {
- if (t == (uInt)Z_DATA_ERROR)
- s->mode = BADB;
- r = t;
- LEAVE
- }
- Tracev((stderr, "inflate: trees ok, %d * %d bytes used\n",
- inflate_hufts, sizeof(inflate_huft)));
- if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
- {
- inflate_trees_free(td, z);
- inflate_trees_free(tl, z);
- r = Z_MEM_ERROR;
- LEAVE
- }
- s->sub.decode.codes = c;
- s->sub.decode.tl = tl;
- s->sub.decode.td = td;
- }
- s->mode = CODES;
- case CODES:
- UPDATE
- if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
- return inflate_flush(s, z, r);
- r = Z_OK;
- inflate_codes_free(s->sub.decode.codes, z);
- inflate_trees_free(s->sub.decode.td, z);
- inflate_trees_free(s->sub.decode.tl, z);
- LOAD
- Tracev((stderr, "inflate: codes end, %lu total out\n",
- z->total_out + (q >= s->read ? q - s->read :
- (s->end - s->read) + (q - s->window))));
- if (!s->last)
- {
- s->mode = TYPE;
- break;
- }
- if (k > 7) /* return unused byte, if any */
- {
- Assert(k < 16, "inflate_codes grabbed too many bytes")
- k -= 8;
- n++;
- p--; /* can always return one */
- }
- s->mode = DRY;
- case DRY:
- FLUSH
- if (s->read != s->write)
- LEAVE
- s->mode = DONEB;
- case DONEB:
- r = Z_STREAM_END;
- LEAVE
- case BADB:
- r = Z_DATA_ERROR;
- LEAVE
- default:
- r = Z_STREAM_ERROR;
- LEAVE
- }
-}
-
-
-int inflate_blocks_free(s, z, c)
-inflate_blocks_statef *s;
-z_streamp z;
-uLongf *c;
-{
- inflate_blocks_reset(s, z, c);
- ZFREE(z, s->window);
- ZFREE(z, s);
- Trace((stderr, "inflate: blocks freed\n"));
- return Z_OK;
-}
-
-
-void inflate_set_dictionary(s, d, n)
-inflate_blocks_statef *s;
-const Bytef *d;
-uInt n;
-{
- zmemcpy((charf *)s->window, d, n);
- s->read = s->write = s->window + n;
-}
-
-/*
- * This subroutine adds the data at next_in/avail_in to the output history
- * without performing any output. The output buffer must be "caught up";
- * i.e. no pending output (hence s->read equals s->write), and the state must
- * be BLOCKS (i.e. we should be willing to see the start of a series of
- * BLOCKS). On exit, the output will also be caught up, and the checksum
- * will have been updated if need be.
- */
-int inflate_addhistory(s, z)
-inflate_blocks_statef *s;
-z_stream *z;
-{
- uLong b; /* bit buffer */ /* NOT USED HERE */
- uInt k; /* bits in bit buffer */ /* NOT USED HERE */
- uInt t; /* temporary storage */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
-
- if (s->read != s->write)
- return Z_STREAM_ERROR;
- if (s->mode != TYPE)
- return Z_DATA_ERROR;
-
- /* we're ready to rock */
- LOAD
- /* while there is input ready, copy to output buffer, moving
- * pointers as needed.
- */
- while (n) {
- t = n; /* how many to do */
- /* is there room until end of buffer? */
- if (t > m) t = m;
- /* update check information */
- if (s->checkfn != Z_NULL)
- s->check = (*s->checkfn)(s->check, q, t);
- zmemcpy(q, p, t);
- q += t;
- p += t;
- n -= t;
- z->total_out += t;
- s->read = q; /* drag read pointer forward */
-/* WWRAP */ /* expand WWRAP macro by hand to handle s->read */
- if (q == s->end) {
- s->read = q = s->window;
- m = WAVAIL;
- }
- }
- UPDATE
- return Z_OK;
-}
-
-
-/*
- * At the end of a Deflate-compressed PPP packet, we expect to have seen
- * a `stored' block type value but not the (zero) length bytes.
- */
-int inflate_packet_flush(s)
- inflate_blocks_statef *s;
-{
- if (s->mode != LENS)
- return Z_DATA_ERROR;
- s->mode = TYPE;
- return Z_OK;
-}
-/* --- infblock.c */
-
-/* +++ inftrees.c */
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* #include "zutil.h" */
-/* #include "inftrees.h" */
-
-char inflate_copyright[] = " inflate 1.0.4 Copyright 1995-1996 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-/* simplify the use of the inflate_huft type with some defines */
-#define base more.Base
-#define next more.Next
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-
-local int huft_build OF((
- uIntf *, /* code lengths in bits */
- uInt, /* number of codes */
- uInt, /* number of "simple" codes */
- const uIntf *, /* list of base values for non-simple codes */
- const uIntf *, /* list of extra bits for non-simple codes */
- inflate_huft * FAR*,/* result: starting table */
- uIntf *, /* maximum lookup bits (returns actual) */
- z_streamp )); /* for zalloc function */
-
-local voidpf falloc OF((
- voidpf, /* opaque pointer (not used) */
- uInt, /* number of items */
- uInt)); /* size of item */
-
-/* Tables for deflate from PKZIP's appnote.txt. */
-local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- /* see note #13 above about 258 */
-local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
- 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
-local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577};
-local const uInt cpdext[30] = { /* Extra bits for distance codes */
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
- 12, 12, 13, 13};
-
-/*
- Huffman code decoding is performed using a multi-level table lookup.
- The fastest way to decode is to simply build a lookup table whose
- size is determined by the longest code. However, the time it takes
- to build this table can also be a factor if the data being decoded
- is not very long. The most common codes are necessarily the
- shortest codes, so those codes dominate the decoding time, and hence
- the speed. The idea is you can have a shorter table that decodes the
- shorter, more probable codes, and then point to subsidiary tables for
- the longer codes. The time it costs to decode the longer codes is
- then traded against the time it takes to make longer tables.
-
- This results of this trade are in the variables lbits and dbits
- below. lbits is the number of bits the first level table for literal/
- length codes can decode in one step, and dbits is the same thing for
- the distance codes. Subsequent tables are also less than or equal to
- those sizes. These values may be adjusted either when all of the
- codes are shorter than that, in which case the longest code length in
- bits is used, or when the shortest code is *longer* than the requested
- table size, in which case the length of the shortest code in bits is
- used.
-
- There are two different values for the two tables, since they code a
- different number of possibilities each. The literal/length table
- codes 286 possible values, or in a flat code, a little over eight
- bits. The distance table codes 30 possible values, or a little less
- than five bits, flat. The optimum values for speed end up being
- about one bit more than those, so lbits is 8+1 and dbits is 5+1.
- The optimum values may differ though from machine to machine, and
- possibly even between compilers. Your mileage may vary.
- */
-
-
-/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
-#define BMAX 15 /* maximum bit length of any code */
-#define N_MAX 288 /* maximum number of codes in any set */
-
-#ifdef DEBUG_ZLIB
- uInt inflate_hufts;
-#endif
-
-local int huft_build(b, n, s, d, e, t, m, zs)
-uIntf *b; /* code lengths in bits (all assumed <= BMAX) */
-uInt n; /* number of codes (assumed <= N_MAX) */
-uInt s; /* number of simple-valued codes (0..s-1) */
-const uIntf *d; /* list of base values for non-simple codes */
-const uIntf *e; /* list of extra bits for non-simple codes */
-inflate_huft * FAR *t; /* result: starting table */
-uIntf *m; /* maximum lookup bits, returns actual */
-z_streamp zs; /* for zalloc function */
-/* Given a list of code lengths and a maximum table size, make a set of
- tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
- if the given code set is incomplete (the tables are still built in this
- case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
- lengths), or Z_MEM_ERROR if not enough memory. */
-{
-
- uInt a; /* counter for codes of length k */
- uInt c[BMAX+1]; /* bit length count table */
- uInt f; /* i repeats in table every f entries */
- int g; /* maximum code length */
- int h; /* table level */
- register uInt i; /* counter, current code */
- register uInt j; /* counter */
- register int k; /* number of bits in current code */
- int l; /* bits per table (returned in m) */
- register uIntf *p; /* pointer into c[], b[], or v[] */
- inflate_huft *q; /* points to current table */
- struct inflate_huft_s r; /* table entry for structure assignment */
- inflate_huft *u[BMAX]; /* table stack */
- uInt v[N_MAX]; /* values in order of bit length */
- register int w; /* bits before this table == (l * h) */
- uInt x[BMAX+1]; /* bit offsets, then code stack */
- uIntf *xp; /* pointer into x */
- int y; /* number of dummy codes added */
- uInt z; /* number of entries in current table */
-
-
- /* Generate counts for each bit length */
- p = c;
-#define C0 *p++ = 0;
-#define C2 C0 C0 C0 C0
-#define C4 C2 C2 C2 C2
- C4 /* clear c[]--assume BMAX+1 is 16 */
- p = b; i = n;
- do {
- c[*p++]++; /* assume all entries <= BMAX */
- } while (--i);
- if (c[0] == n) /* null input--all zero length codes */
- {
- *t = (inflate_huft *)Z_NULL;
- *m = 0;
- return Z_OK;
- }
-
-
- /* Find minimum and maximum length, bound *m by those */
- l = *m;
- for (j = 1; j <= BMAX; j++)
- if (c[j])
- break;
- k = j; /* minimum code length */
- if ((uInt)l < j)
- l = j;
- for (i = BMAX; i; i--)
- if (c[i])
- break;
- g = i; /* maximum code length */
- if ((uInt)l > i)
- l = i;
- *m = l;
-
-
- /* Adjust last length count to fill out codes, if needed */
- for (y = 1 << j; j < i; j++, y <<= 1)
- if ((y -= c[j]) < 0)
- return Z_DATA_ERROR;
- if ((y -= c[i]) < 0)
- return Z_DATA_ERROR;
- c[i] += y;
-
-
- /* Generate starting offsets into the value table for each length */
- x[1] = j = 0;
- p = c + 1; xp = x + 2;
- while (--i) { /* note that i == g from above */
- *xp++ = (j += *p++);
- }
-
-
- /* Make a table of values in order of bit lengths */
- p = b; i = 0;
- do {
- if ((j = *p++) != 0)
- v[x[j]++] = i;
- } while (++i < n);
- n = x[g]; /* set n to length of v */
-
-
- /* Generate the Huffman codes and for each, make the table entries */
- x[0] = i = 0; /* first Huffman code is zero */
- p = v; /* grab values in bit order */
- h = -1; /* no tables yet--level -1 */
- w = -l; /* bits decoded == (l * h) */
- u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
- q = (inflate_huft *)Z_NULL; /* ditto */
- z = 0; /* ditto */
-
- /* go through the bit lengths (k already is bits in shortest code) */
- for (; k <= g; k++)
- {
- a = c[k];
- while (a--)
- {
- /* here i is the Huffman code of length k bits for value *p */
- /* make tables up to required level */
- while (k > w + l)
- {
- h++;
- w += l; /* previous table always l bits */
-
- /* compute minimum size table less than or equal to l bits */
- z = g - w;
- z = z > (uInt)l ? l : z; /* table size upper limit */
- if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
- { /* too few codes for k-w bit table */
- f -= a + 1; /* deduct codes from patterns left */
- xp = c + k;
- if (j < z)
- while (++j < z) /* try smaller tables up to z bits */
- {
- if ((f <<= 1) <= *++xp)
- break; /* enough codes to use up j bits */
- f -= *xp; /* else deduct codes from patterns */
- }
- }
- z = 1 << j; /* table entries for j-bit table */
-
- /* allocate and link in new table */
- if ((q = (inflate_huft *)ZALLOC
- (zs,z + 1,sizeof(inflate_huft))) == Z_NULL)
- {
- if (h)
- inflate_trees_free(u[0], zs);
- return Z_MEM_ERROR; /* not enough memory */
- }
-#ifdef DEBUG_ZLIB
- inflate_hufts += z + 1;
-#endif
- *t = q + 1; /* link to list for huft_free() */
- *(t = &(q->next)) = Z_NULL;
- u[h] = ++q; /* table starts after link */
-
- /* connect to last table, if there is one */
- if (h)
- {
- x[h] = i; /* save pattern for backing up */
- r.bits = (Byte)l; /* bits to dump before this table */
- r.exop = (Byte)j; /* bits in this table */
- r.next = q; /* pointer to this table */
- j = i >> (w - l); /* (get around Turbo C bug) */
- u[h-1][j] = r; /* connect to last table */
- }
- }
-
- /* set up table entry in r */
- r.bits = (Byte)(k - w);
- if (p >= v + n)
- r.exop = 128 + 64; /* out of values--invalid code */
- else if (*p < s)
- {
- r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
- r.base = *p++; /* simple code is just the value */
- }
- else
- {
- r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
- r.base = d[*p++ - s];
- }
-
- /* fill code-like entries with r */
- f = 1 << (k - w);
- for (j = i >> w; j < z; j += f)
- q[j] = r;
-
- /* backwards increment the k-bit code i */
- for (j = 1 << (k - 1); i & j; j >>= 1)
- i ^= j;
- i ^= j;
-
- /* backup over finished tables */
- while ((i & ((1 << w) - 1)) != x[h])
- {
- h--; /* don't need to update q */
- w -= l;
- }
- }
- }
-
-
- /* Return Z_BUF_ERROR if we were given an incomplete table */
- return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
-}
-
-
-int inflate_trees_bits(c, bb, tb, z)
-uIntf *c; /* 19 code lengths */
-uIntf *bb; /* bits tree desired/actual depth */
-inflate_huft * FAR *tb; /* bits tree result */
-z_streamp z; /* for zfree function */
-{
- int r;
-
- r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z);
- if (r == Z_DATA_ERROR)
- z->msg = (char*)"oversubscribed dynamic bit lengths tree";
- else if (r == Z_BUF_ERROR || *bb == 0)
- {
- inflate_trees_free(*tb, z);
- z->msg = (char*)"incomplete dynamic bit lengths tree";
- r = Z_DATA_ERROR;
- }
- return r;
-}
-
-
-int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z)
-uInt nl; /* number of literal/length codes */
-uInt nd; /* number of distance codes */
-uIntf *c; /* that many (total) code lengths */
-uIntf *bl; /* literal desired/actual bit depth */
-uIntf *bd; /* distance desired/actual bit depth */
-inflate_huft * FAR *tl; /* literal/length tree result */
-inflate_huft * FAR *td; /* distance tree result */
-z_streamp z; /* for zfree function */
-{
- int r;
-
- /* build literal/length tree */
- r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z);
- if (r != Z_OK || *bl == 0)
- {
- if (r == Z_DATA_ERROR)
- z->msg = (char*)"oversubscribed literal/length tree";
- else if (r != Z_MEM_ERROR)
- {
- inflate_trees_free(*tl, z);
- z->msg = (char*)"incomplete literal/length tree";
- r = Z_DATA_ERROR;
- }
- return r;
- }
-
- /* build distance tree */
- r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z);
- if (r != Z_OK || (*bd == 0 && nl > 257))
- {
- if (r == Z_DATA_ERROR)
- z->msg = (char*)"oversubscribed distance tree";
- else if (r == Z_BUF_ERROR) {
-#ifdef PKZIP_BUG_WORKAROUND
- r = Z_OK;
- }
-#else
- inflate_trees_free(*td, z);
- z->msg = (char*)"incomplete distance tree";
- r = Z_DATA_ERROR;
- }
- else if (r != Z_MEM_ERROR)
- {
- z->msg = (char*)"empty distance tree with lengths";
- r = Z_DATA_ERROR;
- }
- inflate_trees_free(*tl, z);
- return r;
-#endif
- }
-
- /* done */
- return Z_OK;
-}
-
-
-/* build fixed tables only once--keep them here */
-local int fixed_built = 0;
-#define FIXEDH 530 /* number of hufts used by fixed tables */
-local inflate_huft fixed_mem[FIXEDH];
-local uInt fixed_bl;
-local uInt fixed_bd;
-local inflate_huft *fixed_tl;
-local inflate_huft *fixed_td;
-
-
-local voidpf falloc(q, n, s)
-voidpf q; /* opaque pointer */
-uInt n; /* number of items */
-uInt s; /* size of item */
-{
- Assert(s == sizeof(inflate_huft) && n <= *(intf *)q,
- "inflate_trees falloc overflow");
- *(intf *)q -= n+s-s; /* s-s to avoid warning */
- return (voidpf)(fixed_mem + *(intf *)q);
-}
-
-
-int inflate_trees_fixed(bl, bd, tl, td)
-uIntf *bl; /* literal desired/actual bit depth */
-uIntf *bd; /* distance desired/actual bit depth */
-inflate_huft * FAR *tl; /* literal/length tree result */
-inflate_huft * FAR *td; /* distance tree result */
-{
- /* build fixed tables if not already (multiple overlapped executions ok) */
- if (!fixed_built)
- {
- int k; /* temporary variable */
- unsigned c[288]; /* length list for huft_build */
- z_stream z; /* for falloc function */
- int f = FIXEDH; /* number of hufts left in fixed_mem */
-
- /* set up fake z_stream for memory routines */
- z.zalloc = falloc;
- z.zfree = Z_NULL;
- z.opaque = (voidpf)&f;
-
- /* literal table */
- for (k = 0; k < 144; k++)
- c[k] = 8;
- for (; k < 256; k++)
- c[k] = 9;
- for (; k < 280; k++)
- c[k] = 7;
- for (; k < 288; k++)
- c[k] = 8;
- fixed_bl = 7;
- huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, &z);
-
- /* distance table */
- for (k = 0; k < 30; k++)
- c[k] = 5;
- fixed_bd = 5;
- huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, &z);
-
- /* done */
- Assert(f == 0, "invalid build of fixed tables");
- fixed_built = 1;
- }
- *bl = fixed_bl;
- *bd = fixed_bd;
- *tl = fixed_tl;
- *td = fixed_td;
- return Z_OK;
-}
-
-
-int inflate_trees_free(t, z)
-inflate_huft *t; /* table to free */
-z_streamp z; /* for zfree function */
-/* Free the malloc'ed tables built by huft_build(), which makes a linked
- list of the tables it made, with the links in a dummy first entry of
- each table. */
-{
- register inflate_huft *p, *q, *r;
-
- /* Reverse linked list */
- p = Z_NULL;
- q = t;
- while (q != Z_NULL)
- {
- r = (q - 1)->next;
- (q - 1)->next = p;
- p = q;
- q = r;
- }
- /* Go through linked list, freeing from the malloced (t[-1]) address. */
- while (p != Z_NULL)
- {
- q = (--p)->next;
- ZFREE(z,p);
- p = q;
- }
- return Z_OK;
-}
-/* --- inftrees.c */
-
-/* +++ infcodes.c */
-/* infcodes.c -- process literals and length/distance pairs
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* #include "zutil.h" */
-/* #include "inftrees.h" */
-/* #include "infblock.h" */
-/* #include "infcodes.h" */
-/* #include "infutil.h" */
-
-/* +++ inffast.h */
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-extern int inflate_fast OF((
- uInt,
- uInt,
- inflate_huft *,
- inflate_huft *,
- inflate_blocks_statef *,
- z_streamp ));
-/* --- inffast.h */
-
-/* simplify the use of the inflate_huft type with some defines */
-#define base more.Base
-#define next more.Next
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* inflate codes private state */
-struct inflate_codes_state {
-
- /* mode */
- enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
- START, /* x: set up for LEN */
- LEN, /* i: get length/literal/eob next */
- LENEXT, /* i: getting length extra (have base) */
- DIST, /* i: get distance next */
- DISTEXT, /* i: getting distance extra */
- COPY, /* o: copying bytes in window, waiting for space */
- LIT, /* o: got literal, waiting for output space */
- WASH, /* o: got eob, possibly still output waiting */
- END, /* x: got eob and all data flushed */
- BADCODE} /* x: got error */
- mode; /* current inflate_codes mode */
-
- /* mode dependent information */
- uInt len;
- union {
- struct {
- inflate_huft *tree; /* pointer into tree */
- uInt need; /* bits needed */
- } code; /* if LEN or DIST, where in tree */
- uInt lit; /* if LIT, literal */
- struct {
- uInt get; /* bits to get for extra */
- uInt dist; /* distance back to copy from */
- } copy; /* if EXT or COPY, where and how much */
- } sub; /* submode */
-
- /* mode independent information */
- Byte lbits; /* ltree bits decoded per branch */
- Byte dbits; /* dtree bits decoder per branch */
- inflate_huft *ltree; /* literal/length/eob tree */
- inflate_huft *dtree; /* distance tree */
-
-};
-
-
-inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
-uInt bl, bd;
-inflate_huft *tl;
-inflate_huft *td; /* need separate declaration for Borland C++ */
-z_streamp z;
-{
- inflate_codes_statef *c;
-
- if ((c = (inflate_codes_statef *)
- ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
- {
- c->mode = START;
- c->lbits = (Byte)bl;
- c->dbits = (Byte)bd;
- c->ltree = tl;
- c->dtree = td;
- Tracev((stderr, "inflate: codes new\n"));
- }
- return c;
-}
-
-
-int inflate_codes(s, z, r)
-inflate_blocks_statef *s;
-z_streamp z;
-int r;
-{
- uInt j; /* temporary storage */
- inflate_huft *t; /* temporary pointer */
- uInt e; /* extra bits or operation */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
- Bytef *f; /* pointer to copy strings from */
- inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
-
- /* copy input/output information to locals (UPDATE macro restores) */
- LOAD
-
- /* process input and output based on current state */
- while (1) switch (c->mode)
- { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
- case START: /* x: set up for LEN */
-#ifndef SLOW
- if (m >= 258 && n >= 10)
- {
- UPDATE
- r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
- LOAD
- if (r != Z_OK)
- {
- c->mode = r == Z_STREAM_END ? WASH : BADCODE;
- break;
- }
- }
-#endif /* !SLOW */
- c->sub.code.need = c->lbits;
- c->sub.code.tree = c->ltree;
- c->mode = LEN;
- case LEN: /* i: get length/literal/eob next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e == 0) /* literal */
- {
- c->sub.lit = t->base;
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", t->base));
- c->mode = LIT;
- break;
- }
- if (e & 16) /* length */
- {
- c->sub.copy.get = e & 15;
- c->len = t->base;
- c->mode = LENEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t->next;
- break;
- }
- if (e & 32) /* end of block */
- {
- Tracevv((stderr, "inflate: end of block\n"));
- c->mode = WASH;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = (char*)"invalid literal/length code";
- r = Z_DATA_ERROR;
- LEAVE
- case LENEXT: /* i: getting length extra (have base) */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->len += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- c->sub.code.need = c->dbits;
- c->sub.code.tree = c->dtree;
- Tracevv((stderr, "inflate: length %u\n", c->len));
- c->mode = DIST;
- case DIST: /* i: get distance next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e & 16) /* distance */
- {
- c->sub.copy.get = e & 15;
- c->sub.copy.dist = t->base;
- c->mode = DISTEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t->next;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = (char*)"invalid distance code";
- r = Z_DATA_ERROR;
- LEAVE
- case DISTEXT: /* i: getting distance extra */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->sub.copy.dist += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
- c->mode = COPY;
- case COPY: /* o: copying bytes in window, waiting for space */
-#ifndef __TURBOC__ /* Turbo C bug for following expression */
- f = (uInt)(q - s->window) < c->sub.copy.dist ?
- s->end - (c->sub.copy.dist - (q - s->window)) :
- q - c->sub.copy.dist;
-#else
- f = q - c->sub.copy.dist;
- if ((uInt)(q - s->window) < c->sub.copy.dist)
- f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
-#endif
- while (c->len)
- {
- NEEDOUT
- OUTBYTE(*f++)
- if (f == s->end)
- f = s->window;
- c->len--;
- }
- c->mode = START;
- break;
- case LIT: /* o: got literal, waiting for output space */
- NEEDOUT
- OUTBYTE(c->sub.lit)
- c->mode = START;
- break;
- case WASH: /* o: got eob, possibly more output */
- FLUSH
- if (s->read != s->write)
- LEAVE
- c->mode = END;
- case END:
- r = Z_STREAM_END;
- LEAVE
- case BADCODE: /* x: got error */
- r = Z_DATA_ERROR;
- LEAVE
- default:
- r = Z_STREAM_ERROR;
- LEAVE
- }
-}
-
-
-void inflate_codes_free(c, z)
-inflate_codes_statef *c;
-z_streamp z;
-{
- ZFREE(z, c);
- Tracev((stderr, "inflate: codes free\n"));
-}
-/* --- infcodes.c */
-
-/* +++ infutil.c */
-/* inflate_util.c -- data and routines common to blocks and codes
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* #include "zutil.h" */
-/* #include "infblock.h" */
-/* #include "inftrees.h" */
-/* #include "infcodes.h" */
-/* #include "infutil.h" */
-
-#ifndef NO_DUMMY_DECL
-struct inflate_codes_state {int dummy;}; /* for buggy compilers */
-#endif
-
-/* And'ing with mask[n] masks the lower n bits */
-uInt inflate_mask[17] = {
- 0x0000,
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-
-
-/* copy as much as possible from the sliding window to the output area */
-int inflate_flush(s, z, r)
-inflate_blocks_statef *s;
-z_streamp z;
-int r;
-{
- uInt n;
- Bytef *p;
- Bytef *q;
-
- /* local copies of source and destination pointers */
- p = z->next_out;
- q = s->read;
-
- /* compute number of bytes to copy as far as end of window */
- n = (uInt)((q <= s->write ? s->write : s->end) - q);
- if (n > z->avail_out) n = z->avail_out;
- if (n && r == Z_BUF_ERROR) r = Z_OK;
-
- /* update counters */
- z->avail_out -= n;
- z->total_out += n;
-
- /* update check information */
- if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(s->check, q, n);
-
- /* copy as far as end of window */
- if (p != Z_NULL) {
- zmemcpy(p, q, n);
- p += n;
- }
- q += n;
-
- /* see if more to copy at beginning of window */
- if (q == s->end)
- {
- /* wrap pointers */
- q = s->window;
- if (s->write == s->end)
- s->write = s->window;
-
- /* compute bytes to copy */
- n = (uInt)(s->write - q);
- if (n > z->avail_out) n = z->avail_out;
- if (n && r == Z_BUF_ERROR) r = Z_OK;
-
- /* update counters */
- z->avail_out -= n;
- z->total_out += n;
-
- /* update check information */
- if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(s->check, q, n);
-
- /* copy */
- if (p != Z_NULL) {
- zmemcpy(p, q, n);
- p += n;
- }
- q += n;
- }
-
- /* update pointers */
- z->next_out = p;
- s->read = q;
-
- /* done */
- return r;
-}
-/* --- infutil.c */
-
-/* +++ inffast.c */
-/* inffast.c -- process literals and length/distance pairs fast
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* #include "zutil.h" */
-/* #include "inftrees.h" */
-/* #include "infblock.h" */
-/* #include "infcodes.h" */
-/* #include "infutil.h" */
-/* #include "inffast.h" */
-
-#ifndef NO_DUMMY_DECL
-struct inflate_codes_state {int dummy;}; /* for buggy compilers */
-#endif
-
-/* simplify the use of the inflate_huft type with some defines */
-#define base more.Base
-#define next more.Next
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* macros for bit input with no checking and for returning unused bytes */
-#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define UNGRAB {n+=(c=k>>3);p-=c;k&=7;}
-
-/* Called with number of bytes left to write in window at least 258
- (the maximum string length) and number of input bytes available
- at least ten. The ten bytes are six bytes for the longest length/
- distance pair plus four bytes for overloading the bit buffer. */
-
-int inflate_fast(bl, bd, tl, td, s, z)
-uInt bl, bd;
-inflate_huft *tl;
-inflate_huft *td; /* need separate declaration for Borland C++ */
-inflate_blocks_statef *s;
-z_streamp z;
-{
- inflate_huft *t; /* temporary pointer */
- uInt e; /* extra bits or operation */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
- uInt ml; /* mask for literal/length tree */
- uInt md; /* mask for distance tree */
- uInt c; /* bytes to copy */
- uInt d; /* distance back to copy from */
- Bytef *r; /* copy source pointer */
-
- /* load input, output, bit values */
- LOAD
-
- /* initialize masks */
- ml = inflate_mask[bl];
- md = inflate_mask[bd];
-
- /* do until not enough input or output space for fast loop */
- do { /* assume called with m >= 258 && n >= 10 */
- /* get literal/length code */
- GRABBITS(20) /* max bits for literal/length code */
- if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- continue;
- }
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits for length */
- e &= 15;
- c = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv((stderr, "inflate: * length %u\n", c));
-
- /* decode distance base of block to copy */
- GRABBITS(15); /* max bits for distance code */
- e = (t = td + ((uInt)b & md))->exop;
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits to add to distance base */
- e &= 15;
- GRABBITS(e) /* get extra bits (up to 13) */
- d = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv((stderr, "inflate: * distance %u\n", d));
-
- /* do the copy */
- m -= c;
- if ((uInt)(q - s->window) >= d) /* offset before dest */
- { /* just copy */
- r = q - d;
- *q++ = *r++; c--; /* minimum count is three, */
- *q++ = *r++; c--; /* so unroll loop a little */
- }
- else /* else offset after destination */
- {
- e = d - (uInt)(q - s->window); /* bytes from offset to end */
- r = s->end - e; /* pointer to offset */
- if (c > e) /* if source crosses, */
- {
- c -= e; /* copy to end of window */
- do {
- *q++ = *r++;
- } while (--e);
- r = s->window; /* copy rest from start of window */
- }
- }
- do { /* copy all or what's left */
- *q++ = *r++;
- } while (--c);
- break;
- }
- else if ((e & 64) == 0)
- e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop;
- else
- {
- z->msg = (char*)"invalid distance code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- break;
- }
- if ((e & 64) == 0)
- {
- if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- break;
- }
- }
- else if (e & 32)
- {
- Tracevv((stderr, "inflate: * end of block\n"));
- UNGRAB
- UPDATE
- return Z_STREAM_END;
- }
- else
- {
- z->msg = (char*)"invalid literal/length code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- } while (m >= 258 && n >= 10);
-
- /* not enough input or output--restore pointers and return */
- UNGRAB
- UPDATE
- return Z_OK;
-}
-/* --- inffast.c */
-
-/* +++ zutil.c */
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-1996 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* From: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */
-
-#ifdef DEBUG_ZLIB
-#include <stdio.h>
-#endif
-
-/* #include "zutil.h" */
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef STDC
-extern void exit OF((int));
-#endif
-
-const char *z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char *zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-#ifdef DEBUG_ZLIB
-void z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void zmemcpy(dest, source, len)
- Bytef* dest;
- Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int zmemcmp(s1, s2, len)
- Bytef* s1;
- Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-#ifdef __TURBOC__
-#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__)
-/* Small and medium model in Turbo C are for now limited to near allocation
- * with reduced MAX_WBITS and MAX_MEM_LEVEL
- */
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-#endif
-#endif /* __TURBOC__ */
-
-
-#if defined(M_I86) && !defined(__32BIT__)
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER < 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* MSC */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return (voidpf)calloc(items, size);
-}
-
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
-/* --- zutil.c */
-
-/* +++ adler32.c */
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-1996 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* From: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */
-
-/* #include "zlib.h" */
-
-#define BASE 65521L /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* ========================================================================= */
-uLong adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long s1 = adler & 0xffff;
- unsigned long s2 = (adler >> 16) & 0xffff;
- int k;
-
- if (buf == Z_NULL) return 1L;
-
- while (len > 0) {
- k = len < NMAX ? len : NMAX;
- len -= k;
- while (k >= 16) {
- DO16(buf);
- buf += 16;
- k -= 16;
- }
- if (k != 0) do {
- s1 += *buf++;
- s2 += s1;
- } while (--k);
- s1 %= BASE;
- s2 %= BASE;
- }
- return (s2 << 16) | s1;
-}
-/* --- adler32.c */
diff --git a/mdk-stage1/ppp/common/zlib.h b/mdk-stage1/ppp/common/zlib.h
deleted file mode 100644
index 188ddaff9..000000000
--- a/mdk-stage1/ppp/common/zlib.h
+++ /dev/null
@@ -1,1010 +0,0 @@
-/* $Id$ */
-
-/*
- * This file is derived from zlib.h and zconf.h from the zlib-1.0.4
- * distribution by Jean-loup Gailly and Mark Adler, with some additions
- * by Paul Mackerras to aid in implementing Deflate compression and
- * decompression for PPP packets.
- */
-
-/*
- * ==FILEVERSION 971127==
- *
- * This marker is used by the Linux installation script to determine
- * whether an up-to-date version of this file is already installed.
- */
-
-
-/* +++ zlib.h */
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.0.4, Jul 24th, 1996.
-
- Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- gzip@prep.ai.mit.edu madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
- (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-#ifndef _ZLIB_H
-#define _ZLIB_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* +++ zconf.h */
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-1996 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* From: zconf.h,v 1.20 1996/07/02 15:09:28 me Exp $ */
-
-#ifndef _ZCONF_H
-#define _ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflateParams z_deflateParams
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateReset z_inflateReset
-# define compress z_compress
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
-# define WIN32
-#endif
-#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
-# ifndef __32BIT__
-# define __32BIT__
-# endif
-#endif
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#if defined(MSDOS) && !defined(__32BIT__)
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
-# define STDC
-#endif
-#if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC)
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- 1 << (windowBits+2) + 1 << (memLevel+9)
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR __far
-# else
-# define FAR far
-# endif
-#endif
-#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
-# ifndef __32BIT__
-# define SMALL_MEDIUM
-# define FAR __far
-# endif
-#endif
-#ifndef FAR
-# define FAR
-#endif
-
-typedef unsigned char Byte; /* 8 bits */
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#if defined(__BORLANDC__) && defined(SMALL_MEDIUM)
- /* Borland C/C++ ignores FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-
-/* Compile with -DZLIB_DLL for Windows DLL support */
-#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL)
-# include <windows.h>
-# define EXPORT WINAPI
-#else
-# define EXPORT
-#endif
-
-#endif /* _ZCONF_H */
-/* --- zconf.h */
-
-#define ZLIB_VERSION "1.0.4P"
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms may be added later and will have the same
- stream interface.
-
- For compression the application must provide the output buffer and
- may optionally provide the input buffer for optimization. For decompression,
- the application must provide the input buffer and may optionally provide
- the output buffer for optimization.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The library does not install any signal handler. It is recommended to
- add at least a handler for SIGSEGV when decompressing; the library checks
- the consistency of the input data whenever possible but may go nuts
- for some forms of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total nb of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total nb of bytes output so far */
-
- char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: ascii or binary */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1
-#define Z_PACKET_FLUSH 2
-#define Z_SYNC_FLUSH 3
-#define Z_FULL_FLUSH 4
-#define Z_FINISH 5
-/* Allowed flush values; see deflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_ASCII 1
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
- /* basic functions */
-
-extern const char * EXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-extern int EXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
-*/
-
-
-extern int EXPORT deflate OF((z_streamp strm, int flush));
-/*
- Performs one or both of the following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
-
- If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression
- block is terminated and flushed to the output buffer so that the
- decompressor can get all input data available so far. For method 9, a future
- variant on method 8, the current block will be flushed but not terminated.
- Z_SYNC_FLUSH has the same effect as partial flush except that the compressed
- output is byte aligned (the compressor can clear its internal bit buffer)
- and the current block is always terminated; this can be useful if the
- compressor has to be restarted from scratch after an interruption (in which
- case the internal state of the compressor may be lost).
- If flush is set to Z_FULL_FLUSH, the compression block is terminated, a
- special marker is output and the compression dictionary is discarded; this
- is useful to allow the decompressor to synchronize if one compressed block
- has been damaged (see inflateSync below). Flushing degrades compression and
- so should be used only when necessary. Using Z_FULL_FLUSH too often can
- seriously degrade the compression. If deflate returns with avail_out == 0,
- this function must be called again with the same value of the flush
- parameter and more output space (updated avail_out), until the flush is
- complete (deflate returns with non-zero avail_out).
-
- If the parameter flush is set to Z_PACKET_FLUSH, the compression
- block is terminated, and a zero-length stored block is output,
- omitting the length bytes (the effect of this is that the 3-bit type
- code 000 for a stored block is output, and the output is then
- byte-aligned). This is designed for use at the end of a PPP packet.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- 0.1% larger than avail_in plus 12 bytes. If deflate does not return
- Z_STREAM_END, then it must be called again as described above.
-
- deflate() may update data_type if it can make a good guess about
- the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible.
-*/
-
-
-extern int EXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-extern int EXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- zalloc, zfree and opaque must be initialized before by the caller. If
- zalloc and zfree are set to Z_NULL, inflateInit updates them to use default
- allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_VERSION_ERROR if the zlib library version is incompatible
- with the version assumed by the caller. msg is set to null if there is no
- error message. inflateInit does not perform any decompression: this will be
- done by inflate().
-*/
-
-
-extern int EXPORT inflate OF((z_streamp strm, int flush));
-/*
- Performs one or both of the following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH,
- inflate flushes as much output as possible to the output buffer. The
- flushing behavior of inflate is not specified for values of the flush
- parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
- current implementation actually flushes as much output as possible
- anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data
- has been consumed, it is expecting to see the length field of a stored
- block; if not, it returns Z_DATA_ERROR.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster routine
- may be used for the single inflate() call.
-
- inflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if the end of the
- compressed data has been reached and all uncompressed output has been
- produced, Z_NEED_DICT if a preset dictionary is needed at this point (see
- inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted,
- Z_STREAM_ERROR if the stream structure was inconsistent (for example if
- next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in
- the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the
- application may then call inflateSync to look for a good compression block.
- In the Z_NEED_DICT case, strm->adler is set to the Adler32 value of the
- dictionary chosen by the compressor.
-*/
-
-
-extern int EXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-extern int EXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library. (Method 9 will allow a 64K history buffer and
- partial block flushes.)
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library (the value 16 will be allowed for method 9). Larger
- values of this parameter result in better compression at the expense of
- memory usage. The default value is 15 if deflateInit is used instead.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match). Filtered data consists mostly of small values with a
- somewhat random distribution. In this case, the compression algorithm is
- tuned to compress them better. The effect of Z_FILTERED is to force more
- Huffman coding and less string matching; it is somewhat intermediate
- between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
- the compression ratio but not the correctness of the compressed output even
- if it is not set appropriately.
-
- If next_in is not null, the library will use this buffer to hold also
- some history information; the buffer must either hold the entire input
- data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in
- is null, the library will allocate its own history buffer (and leave next_in
- null). next_out need not be provided here but must be provided by the
- application for the next call of deflate().
-
- If the history buffer is provided by the application, next_in must
- must never be changed by the application since the compressor maintains
- information inside this buffer from call to call; the application
- must provide more input only by increasing avail_in. next_in is always
- reset by the library in this case.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
- not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
- an invalid method). msg is set to null if there is no error message.
- deflateInit2 does not perform any compression: this will be done by
- deflate().
-*/
-
-extern int EXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary (history buffer) from the given
- byte sequence without producing any compressed output. This function must
- be called immediately after deflateInit or deflateInit2, before any call
- of deflate. The compressor and decompressor must use exactly the same
- dictionary (see inflateSetDictionary).
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and
- can be predicted with good accuracy; the data can then be compressed better
- than with the default empty dictionary. In this version of the library,
- only the last 32K bytes of the dictionary are used.
- Upon return of this function, strm->adler is set to the Adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The Adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.)
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state
- is inconsistent (for example if deflate has already been called for this
- stream). deflateSetDictionary does not perform any compression: this will
- be done by deflate().
-*/
-
-extern int EXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream. If
- the source stream is using an application-supplied history buffer, a new
- buffer is allocated for the destination stream. The compressed output
- buffer is always application-supplied. It's the responsibility of the
- application to provide the correct values of next_out and avail_out for the
- next call of deflate.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-extern int EXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-extern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy));
-/*
- Dynamically update the compression level and compression strategy.
- This can be used to switch between compression and straight copy of
- the input data, or to switch to a different kind of input data requiring
- a different strategy. If the compression level is changed, the input
- available so far is compressed with the old level (and may be flushed);
- the new level will take effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
-*/
-
-extern int EXPORT deflateOutputPending OF((z_streamp strm));
-/*
- Returns the number of bytes of output which are immediately
- available from the compressor (i.e. without any further input
- or flush).
-*/
-
-/*
-extern int EXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with more compression options. The
- fields next_out, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library (the value 16 will be allowed soon). The
- default value is 15 if inflateInit is used instead. If a compressed stream
- with a larger window size is given as input, inflate() will return with
- the error code Z_DATA_ERROR instead of trying to allocate a larger window.
-
- If next_out is not null, the library will use this buffer for the history
- buffer; the buffer must either be large enough to hold the entire output
- data, or have at least 1<<windowBits bytes. If next_out is null, the
- library will allocate its own buffer (and leave next_out null). next_in
- need not be provided here but must be provided by the application for the
- next call of inflate().
-
- If the history buffer is provided by the application, next_out must
- never be changed by the application since the decompressor maintains
- history information inside this buffer from call to call; the application
- can only reset next_out to the beginning of the history buffer when
- avail_out is zero and all output has been consumed.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
- not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
- windowBits < 8). msg is set to null if there is no error message.
- inflateInit2 does not perform any decompression: this will be done by
- inflate().
-*/
-
-extern int EXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary (history buffer) from the given
- uncompressed byte sequence. This function must be called immediately after
- a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen
- by the compressor can be determined from the Adler32 value returned by this
- call of inflate. The compressor and decompressor must use exactly the same
- dictionary (see deflateSetDictionary).
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect Adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-extern int EXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until the special marker (see deflate()
- above) can be found, or until all available input is skipped. No output
- is provided.
-
- inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no marker has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-extern int EXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-extern int inflateIncomp OF((z_stream *strm));
-/*
- This function adds the data at next_in (avail_in bytes) to the output
- history without performing any output. There must be no pending output,
- and the decompressor must be expecting to see the start of a block.
- Calling this function is equivalent to decompressing a stored block
- containing the data at next_in (except that the data is not output).
-*/
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level, window size,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-*/
-
-extern int EXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least 0.1% larger than
- sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-
-
-typedef voidp gzFile;
-
-extern gzFile EXPORT gzopen OF((const char *path, const char *mode));
-/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9"). gzopen can be used to read a file which is not in gzip format;
- in this case gzread will directly read from the file without decompression.
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR).
-*/
-
-extern gzFile EXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
-*/
-
-extern int EXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
-
-extern int EXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
-*/
-
-extern int EXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
-*/
-
-extern int EXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
-*/
-
-extern const char * EXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-*/
-
-extern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-extern uLong EXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running crc with the bytes buf[0..len-1] and return the updated
- crc. If buf is NULL, this function returns the required initial value
- for the crc. Pre- and post-conditioning (one's complement) is performed
- within this function so it shouldn't be done by the application.
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-extern int EXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-extern int EXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-extern int EXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel, int strategy,
- const char *version, int stream_size));
-extern int EXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-
-#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-uLongf *get_crc_table OF((void)); /* can be used by asm versions of crc32() */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _ZLIB_H */
-/* --- zlib.h */
diff --git a/mdk-stage1/ppp/configure b/mdk-stage1/ppp/configure
deleted file mode 100755
index 544fb0d71..000000000
--- a/mdk-stage1/ppp/configure
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/bin/sh
-# $Id$
-
-# if [ -d /NextApps ]; then
-# system="NeXTStep"
-# else
- system=`uname -s`
- release=`uname -r`
- machine=`uname -p`
- arch=`uname -m`
-# fi
-state="unknown"
-
-case $system in
- Linux)
- makext="linux";
- ksrc="linux";
- state="known";;
- SunOS)
- case $release in
-# [0-3]*) state="ancient";;
-# 4*) state="known"; ksrc="sunos4"; makext="sunos4";;
- 5.[1-6]*) state="known"; ksrc="solaris"; makext="sol2";;
- 5.[7-9]*) state="known"; ksrc="solaris"; makext="sol2";
- case $arch in
- sun4u) lp64='y';;
- *) ;;
- esac;;
- esac;;
- NetBSD|FreeBSD|ULTRIX|OSF1|NeXTStep|SINIX-?|UNIX_SV|UNIX_System_V)
- state="notincluded";;
-# NetBSD)
-# makext="bsd";
-# case $release in
-# 0.*) state="ancient";;
-# 1.0*) state="ancient";;
-# 1.1*) state="known"; ksrc="netbsd-1.1";;
-# 1.2*) state="known"; ksrc="netbsd-1.2"; makext="netbsd-1.2";;
-# 1.[3-9]*|[2-9]*)
-# state="late"; ksrc="netbsd-1.2";;
-# esac;;
-# ULTRIX)
-# makext="ultrix";
-# case $release in
-# [0-3]*) state="ancient";;
-# 4.[01]*) state="early"; ksrc="ultrix";;
-# 4.[234]) state="known"; ksrc="ultrix";;
-# esac;;
-# OSF1)
-# makext="osf";
-# case $release in
-# V1.*) state="neolithic"; ksrc="osf1";;
-# V[23].*) state="neolithic"; ksrc="osf1";;
-# V4.*) state="known"; ksrc="osf1";;
-# V[5-9]*) state="late"; ksrc="osf1";;
-# esac;;
-# FreeBSD)
-# makext="bsd";
-# case $release in
-# 1.*) state="known"; ksrc="freebsd-old";;
-# 2.[01]*) state="known"; ksrc="freebsd-2.0";;
-# 2.2.[2-7]*) state="late"; ksrc="freebsd-2.0";;
-# 2.2.8*) state="known"; ksrc="freebsd-2.2.8";;
-# 3.[0-1]*) state="known"; ksrc="freebsd-3.0";;
-# esac;;
-# NeXTStep)
-# makext="NeXT";
-# ksrc="NeXT";
-# state="known";;
-# SINIX-?)
-# case $release in
-# 5.4[01]) state=known; ksrc=svr4; makext=svr4;;
-# 5.4[2-9]) state=late; ksrc=svr4; makext=svr4;;
-# esac;;
-# # Intel SVR4 systems come with a bug in the uname program. Unless
-# # your provider fixed the bug, or you get a fix for it, uname -S will
-# # overwrite the system name with the node name!
-# UNIX_SV|UNIX_System_V|`uname -n`)
-# case $release in
-# 4.0) state=known; ksrc=svr4; makext=svr4;;
-# 4.2) state=late; ksrc=svr4; makext=svr4;;
-# esac;;
-esac
-
-if [ -d "$ksrc" ]; then :; else
- state="notincluded"
- unset ksrc
-fi
-
-case $state in
- neolithic)
- echo "This is a newer release on an outdated OS ($system)."
- echo " This software may or may not work on this OS."
- echo " You may want to download an older version of PPP for this OS.";;
- ancient)
- echo "This is an old release of a supported OS ($system)."
- echo "This software cannot be used as-is on this system,"
- echo "but you may be able to port it. Good luck!"
- exit;;
- early)
- echo "This is an old release of a supported OS ($system)."
- echo "This software should install and run on this system,"
- echo "but it hasn't been tested.";;
- late)
- echo "This is a newer release of $system than is supported by"
- echo "this software. It may or may not work.";;
- unknown)
- echo "This software has not been ported to this system. Sorry.";;
- notincluded)
- echo "Support for this system has not been included"
- echo "in this distribution. Sorry.";;
-esac
-
-orig_makext=$makext
-
-if [ -d "$ksrc" ]; then
- echo "Creating links to Makefiles."
- rm -f Makefile
- ln -s $ksrc/Makefile.top Makefile
- echo " Makefile -> $ksrc/Makefile.top"
- if [ "$ksrc" = solaris ]; then
- # Point to 64-bit Makefile extension
- if [ "$lp64" = y ]; then
- makext=$makext-64
- fi
- rm -f $ksrc/Makefile
- ln -s Makefile.$makext $ksrc/Makefile
- echo " $ksrc/Makefile -> Makefile.$makext"
- # Restore extension
- if [ "$lp64" = y ]; then
- makext=$orig_makext
- fi
- fi
- for dir in pppd pppstats chat pppdump; do
- rm -f $dir/Makefile
- if [ -f $dir/Makefile.$makext ]; then
- ln -s Makefile.$makext $dir/Makefile
- echo " $dir/Makefile -> Makefile.$makext"
- fi
- done
-fi
diff --git a/mdk-stage1/ppp/contrib/pppgetpass/Makefile.linux b/mdk-stage1/ppp/contrib/pppgetpass/Makefile.linux
deleted file mode 100644
index 7eb217dac..000000000
--- a/mdk-stage1/ppp/contrib/pppgetpass/Makefile.linux
+++ /dev/null
@@ -1,16 +0,0 @@
-all: pppgetpass.vt pppgetpass.gtk
-
-pppgetpass.vt: pppgetpass.vt.o
-
-pppgetpass.gtk: pppgetpass.gtk.o
- $(CC) $(LDFLAGS) pppgetpass.gtk.o `gtk-config --libs` -o pppgetpass.gtk
-pppgetpass.gtk.o: pppgetpass.gtk.c
- $(CC) $(CFLAGS) -c pppgetpass.gtk.c `gtk-config --cflags`
-
-install: all
- install -m 755 pppgetpass.sh /usr/bin/pppgetpass
- install -m 4755 -o root -g root pppgetpass.vt /usr/bin/
- install -m 755 -o root -g root pppgetpass.gtk /usr/X11/bin/
-
-clean:
- rm -f *.o pppgetpass.gtk pppgetpass.vt core
diff --git a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.8 b/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.8
deleted file mode 100644
index ade576970..000000000
--- a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.8
+++ /dev/null
@@ -1,18 +0,0 @@
-.TH PPPGETPASS 8 "26 Sep 1999"
-.SH NAME
-pppgetpass \- prompt for PAP password
-.SH SYNOPSIS
-.B pppgetpass
-.I client server fd
-.SH DESCRIPTION
-.B pppgetpass
-the outer half of a plugin for PAP password prompting in pppd.
-If the peer requires PAP, and the
-.B passprompt.so
-plugin is loaded into pppd, it will run
-.B /usr/sbin/pppgetpass
-(or another program specified by the
-.B promptprog
-option) to prompt the user for the password.
-.SH SEE ALSO
-pppd(8)
diff --git a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.gtk.c b/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.gtk.c
deleted file mode 100644
index 48ca04202..000000000
--- a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.gtk.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <glib.h>
-#include <gdk/gdk.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtksignal.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <syslog.h>
-
-int outfd;
-int err;
-
-static void okpressed(void *widget, void *clientdata)
-{
- GtkWidget *answer=clientdata;
- gchar *pass;
- int passlen;
- ssize_t wrote;
- (void)widget;
-
- pass=gtk_entry_get_text(GTK_ENTRY(answer));
-
- passlen=strlen(pass);
- if(!passlen)
- return;
-
- if((wrote=write(outfd, pass, passlen))!=passlen) {
- if(wrote<0)
- syslog(LOG_ERR, "write error on outpipe: %m");
- else
- syslog(LOG_ERR, "short write on outpipe");
- err=1;
- }
- gtk_main_quit();
-}
-
-int main(int argc, char **argv)
-{
- GtkWidget *mainwindow, *vbox, *question, *answer, *ok;
- char buf[1024];
- gtk_init(&argc, &argv);
-
- openlog(argv[0], LOG_PID, LOG_DAEMON);
- if(argc!=4) {
- syslog(LOG_WARNING, "Usage error");
- return 1;
- }
- outfd=atoi(argv[3]);
- mainwindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(mainwindow), "pppgetpass");
- gtk_signal_connect(GTK_OBJECT(mainwindow), "destroy",
- GTK_SIGNAL_FUNC(gtk_main_quit), 0);
-
- vbox=gtk_vbox_new(FALSE, 5);
- gtk_container_add(GTK_CONTAINER(mainwindow), vbox);
- gtk_widget_show(vbox);
-
- if(argv[1][0] && argv[2][0])
- snprintf(buf, sizeof buf, "Password for PPP client %s on server %s: ", argv[1], argv[2]);
- else if(argv[1][0] && !argv[2][0])
- snprintf(buf, sizeof buf, "Password for PPP client %s: ", argv[1]);
- else if(!argv[1][0] && argv[2][0])
- snprintf(buf, sizeof buf, "Password for PPP on server %s: ", argv[2]);
- else
- snprintf(buf, sizeof buf, "Enter PPP password: ");
- question=gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(vbox), question, FALSE, TRUE, 0);
- gtk_widget_show(question);
-
- answer=gtk_entry_new();
- gtk_entry_set_visibility(GTK_ENTRY(answer), 0);
- gtk_box_pack_start(GTK_BOX(vbox), answer, FALSE, TRUE, 0);
- gtk_widget_show(answer);
-
- ok=gtk_button_new_with_label("OK");
- gtk_box_pack_start(GTK_BOX(vbox), ok, FALSE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(ok), "clicked",
- GTK_SIGNAL_FUNC(okpressed), answer);
- gtk_widget_show(ok);
-
- gtk_widget_show(mainwindow);
- gtk_main();
-
- return err;
-}
diff --git a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.sh b/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.sh
deleted file mode 100644
index 09c480519..000000000
--- a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-if [ -z "$DISPLAY" ]; then
- exec pppgetpass.vt "$@"
-else
- exec pppgetpass.gtk "$@"
-fi
diff --git a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.vt.c b/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.vt.c
deleted file mode 100644
index a1520883c..000000000
--- a/mdk-stage1/ppp/contrib/pppgetpass/pppgetpass.vt.c
+++ /dev/null
@@ -1,218 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <syslog.h>
-#include <termios.h>
-#include <sys/vt.h>
-
-static int console_owner(uid_t, int);
-
-int main(int argc, char **argv)
-{
- int console;
- uid_t uid;
- struct vt_stat origstate;
- int openvtnum;
- char openvtname[256];
- int openvt;
- gid_t gid;
- int chowned;
- FILE *fp;
- struct termios t;
- char pass[256], *nl;
- int outfd, passlen;
- ssize_t wrote;
- console=open("/dev/console", O_RDWR);
-
- uid=getuid();
- gid=getgid();
- seteuid(uid);
-
- openlog(argv[0], LOG_PID, LOG_DAEMON);
-
- if(argc!=4) {
- syslog(LOG_WARNING, "Usage error");
- return 1;
- }
-
- if(console<0) {
- syslog(LOG_ERR, "open(/dev/console): %m");
- return 1;
- }
-
- if(ioctl(console, VT_GETSTATE, &origstate)<0) {
- syslog(LOG_ERR, "VT_GETSTATE: %m");
- return 1;
- }
-
- if(uid) {
- if(!console_owner(uid, origstate.v_active)) {
- int i;
- for(i=0;i<64;++i) {
- if(i!=origstate.v_active && console_owner(uid, i))
- break;
- }
- if(i==64) {
- syslog(LOG_WARNING, "run by uid %lu not at console", (unsigned long)uid);
- return 1;
- }
- }
- }
-
- if(ioctl(console, VT_OPENQRY, &openvtnum)<0) {
- syslog(LOG_ERR, "VT_OPENQRY: %m");
- return 1;
- }
- if(openvtnum==-1) {
- syslog(LOG_ERR, "No free VTs");
- return 1;
- }
-
- snprintf(openvtname, sizeof openvtname, "/dev/tty%d", openvtnum);
- seteuid(0);
- openvt=open(openvtname, O_RDWR);
- if(openvt<0) {
- seteuid(uid);
- syslog(LOG_ERR, "open(%s): %m", openvtname);
- return 1;
- }
-
- chowned=fchown(openvt, uid, gid);
- if(chowned<0) {
- seteuid(uid);
- syslog(LOG_ERR, "fchown(%s): %m", openvtname);
- return 1;
- }
-
- close(console);
-
- if(ioctl(openvt, VT_ACTIVATE, openvtnum)<0) {
- seteuid(uid);
- syslog(LOG_ERR, "VT_ACTIVATE(%d): %m", openvtnum);
- return 1;
- }
-
- while(ioctl(openvt, VT_WAITACTIVE, openvtnum)<0) {
- if(errno!=EINTR) {
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "VT_WAITACTIVE(%d): %m", openvtnum);
- return 1;
- }
- }
-
- seteuid(uid);
- fp=fdopen(openvt, "r+");
- if(!fp) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "fdopen(%s): %m", openvtname);
- return 1;
- }
-
- if(tcgetattr(openvt, &t)<0) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "tcgetattr(%s): %m", openvtname);
- return 1;
- }
- t.c_lflag &= ~ECHO;
- if(tcsetattr(openvt, TCSANOW, &t)<0) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "tcsetattr(%s): %m", openvtname);
- return 1;
- }
-
- if(fprintf(fp, "\033[2J\033[H")<0) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "write error on %s: %m", openvtname);
- return 1;
- }
- if(argv[1][0] && argv[2][0]) {
- if(fprintf(fp, "Password for PPP client %s on server %s: ", argv[1], argv[2])<0) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "write error on %s: %m", openvtname);
- return 1;
- }
- } else if(argv[1][0] && !argv[2][0]) {
- if(fprintf(fp, "Password for PPP client %s: ", argv[1])<0) {
- syslog(LOG_ERR, "write error on %s: %m", openvtname);
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- return 1;
- }
- } else if(!argv[1][0] && argv[2][0]) {
- if(fprintf(fp, "Password for PPP on server %s: ", argv[2])<0) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "write error on %s: %m", openvtname);
- return 1;
- }
- } else {
- if(fprintf(fp, "Enter PPP password: ")<0) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- syslog(LOG_ERR, "write error on %s: %m", openvtname);
- return 1;
- }
- }
-
- if(!fgets(pass, sizeof pass, fp)) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- if(ferror(fp)) {
- syslog(LOG_ERR, "read error on %s: %m", openvtname);
- }
- return 1;
- }
- if((nl=strchr(pass, '\n')))
- *nl=0;
- passlen=strlen(pass);
-
- outfd=atoi(argv[3]);
- if((wrote=write(outfd, pass, passlen))!=passlen) {
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- if(wrote<0)
- syslog(LOG_ERR, "write error on outpipe: %m");
- else
- syslog(LOG_ERR, "short write on outpipe");
- return 1;
- }
-
- seteuid(0);
- ioctl(openvt, VT_ACTIVATE, origstate.v_active);
- seteuid(uid);
- return 0;
-}
-
-static int console_owner(uid_t uid, int cons)
-{
- char name[256];
- struct stat st;
- snprintf(name, sizeof name, "/dev/tty%d", cons);
- if(stat(name, &st)<0) {
- if(errno!=ENOENT)
- syslog(LOG_ERR, "stat(%s): %m", name);
- return 0;
- }
- return uid==st.st_uid;
-}
diff --git a/mdk-stage1/ppp/etc.ppp/chap-secrets b/mdk-stage1/ppp/etc.ppp/chap-secrets
deleted file mode 100644
index 7d1c3cd7c..000000000
--- a/mdk-stage1/ppp/etc.ppp/chap-secrets
+++ /dev/null
@@ -1,2 +0,0 @@
-# Secrets for authentication using CHAP
-# client server secret IP addresses
diff --git a/mdk-stage1/ppp/etc.ppp/options b/mdk-stage1/ppp/etc.ppp/options
deleted file mode 100644
index 0f77a9aa0..000000000
--- a/mdk-stage1/ppp/etc.ppp/options
+++ /dev/null
@@ -1,5 +0,0 @@
-lock
-noauth
-noipdefault
-usepeerdns
-
diff --git a/mdk-stage1/ppp/etc.ppp/options.options b/mdk-stage1/ppp/etc.ppp/options.options
deleted file mode 100644
index 4b67b6a0d..000000000
--- a/mdk-stage1/ppp/etc.ppp/options.options
+++ /dev/null
@@ -1 +0,0 @@
-lock
diff --git a/mdk-stage1/ppp/etc.ppp/pap-secrets b/mdk-stage1/ppp/etc.ppp/pap-secrets
deleted file mode 100644
index f8b7dce3c..000000000
--- a/mdk-stage1/ppp/etc.ppp/pap-secrets
+++ /dev/null
@@ -1,2 +0,0 @@
-# Secrets for authentication using PAP
-# client server secret IP addresses
diff --git a/mdk-stage1/ppp/include/linux/if_ppp.h b/mdk-stage1/ppp/include/linux/if_ppp.h
deleted file mode 100644
index 1febf0931..000000000
--- a/mdk-stage1/ppp/include/linux/if_ppp.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/* $Id$ */
-
-/*
- * if_ppp.h - Point-to-Point Protocol definitions.
- *
- * Copyright (c) 1989 Carnegie Mellon University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-/*
- * ==FILEVERSION 20000724==
- *
- * NOTE TO MAINTAINERS:
- * If you modify this file at all, please set the above date.
- * if_ppp.h is shipped with a PPP distribution as well as with the kernel;
- * if everyone increases the FILEVERSION number above, then scripts
- * can do the right thing when deciding whether to install a new if_ppp.h
- * file. Don't change the format of that line otherwise, so the
- * installation script can recognize it.
- */
-
-#ifndef _IF_PPP_H_
-#define _IF_PPP_H_
-
-/*
- * Packet sizes
- */
-
-#define PPP_MTU 1500 /* Default MTU (size of Info field) */
-#define PPP_MAXMRU 65000 /* Largest MRU we allow */
-#define PROTO_IPX 0x002b /* protocol numbers */
-#define PROTO_DNA_RT 0x0027 /* DNA Routing */
-
-
-/*
- * Bit definitions for flags.
- */
-
-#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */
-#define SC_COMP_AC 0x00000002 /* header compression (output) */
-#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */
-#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */
-#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */
-#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */
-#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */
-#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */
-#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */
-#define SC_LOOP_TRAFFIC 0x00000200 /* send traffic to pppd */
-#define SC_MULTILINK 0x00000400 /* do multilink encapsulation */
-#define SC_MP_SHORTSEQ 0x00000800 /* use short MP sequence numbers */
-#define SC_COMP_RUN 0x00001000 /* compressor has been inited */
-#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */
-#define SC_MP_XSHORTSEQ 0x00004000 /* transmit short MP seq numbers */
-#define SC_DEBUG 0x00010000 /* enable debug messages */
-#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */
-#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */
-#define SC_LOG_RAWIN 0x00080000 /* log all chars received */
-#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */
-#define SC_SYNC 0x00200000 /* synchronous serial mode */
-#define SC_MASK 0x0f200fff /* bits that user can change */
-
-/* state bits */
-#define SC_XMIT_BUSY 0x10000000 /* (used by isdn_ppp?) */
-#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */
-#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */
-#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */
-#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */
-#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */
-#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */
-
-/*
- * Ioctl definitions.
- */
-
-struct npioctl {
- int protocol; /* PPP protocol, e.g. PPP_IP */
- enum NPmode mode;
-};
-
-/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
-struct ppp_option_data {
- __u8 *ptr;
- __u32 length;
- int transmit;
-};
-
-struct ifpppstatsreq {
- struct ifreq b;
- struct ppp_stats stats; /* statistic information */
-};
-
-struct ifpppcstatsreq {
- struct ifreq b;
- struct ppp_comp_stats stats;
-};
-
-#define ifr__name b.ifr_ifrn.ifrn_name
-#define stats_ptr b.ifr_ifru.ifru_data
-
-/*
- * Ioctl definitions.
- */
-
-#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
-#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
-#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
-#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */
-#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */
-#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */
-#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */
-#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */
-#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */
-#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */
-#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
-#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
-#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */
-#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
-#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */
-#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
-#define PPPIOCSPASS _IOW('t', 71, struct sock_fprog) /* set pass filter */
-#define PPPIOCSACTIVE _IOW('t', 70, struct sock_fprog) /* set active filt */
-#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */
-#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */
-#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */
-#define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */
-#define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */
-#define PPPIOCDETACH _IOW('t', 60, int) /* detach from ppp unit/chan */
-#define PPPIOCSMRRU _IOW('t', 59, int) /* set multilink MRU */
-#define PPPIOCCONNECT _IOW('t', 58, int) /* connect channel to unit */
-#define PPPIOCDISCONN _IO('t', 57) /* disconnect channel */
-#define PPPIOCATTCHAN _IOW('t', 56, int) /* attach to ppp channel */
-#define PPPIOCGCHAN _IOR('t', 55, int) /* get ppp channel number */
-
-#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0)
-#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */
-#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2)
-
-#if !defined(ifr_mtu)
-#define ifr_mtu ifr_ifru.ifru_metric
-#endif
-
-#endif /* _IF_PPP_H_ */
diff --git a/mdk-stage1/ppp/include/linux/if_pppvar.h b/mdk-stage1/ppp/include/linux/if_pppvar.h
deleted file mode 100644
index b2485cd9d..000000000
--- a/mdk-stage1/ppp/include/linux/if_pppvar.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* From: if_pppvar.h,v 1.2 1995/06/12 11:36:51 paulus Exp */
-/*
- * if_pppvar.h - private structures and declarations for PPP.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * Copyright (c) 1989 Carnegie Mellon University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * ==FILEVERSION 990911==
- *
- * NOTE TO MAINTAINERS:
- * If you modify this file at all, please set the above date.
- * if_pppvar.h is shipped with a PPP distribution as well as with the kernel;
- * if everyone increases the FILEVERSION number above, then scripts
- * can do the right thing when deciding whether to install a new if_pppvar.h
- * file. Don't change the format of that line otherwise, so the
- * installation script can recognize it.
- */
-
-/*
- * Supported network protocols. These values are used for
- * indexing sc_npmode.
- */
-
-#define NP_IP 0 /* Internet Protocol */
-#define NP_IPX 1 /* IPX protocol */
-#define NP_AT 2 /* Appletalk protocol */
-#define NP_IPV6 3 /* Internet Protocol */
-#define NUM_NP 4 /* Number of NPs. */
-
-#define OBUFSIZE 256 /* # chars of output buffering */
-
-/*
- * Structure describing each ppp unit.
- */
-
-struct ppp {
- int magic; /* magic value for structure */
- struct ppp *next; /* unit with next index */
- unsigned long inuse; /* are we allocated? */
- int line; /* network interface unit # */
- __u32 flags; /* miscellaneous control flags */
- int mtu; /* maximum xmit frame size */
- int mru; /* maximum receive frame size */
- struct slcompress *slcomp; /* for TCP header compression */
- struct sk_buff_head xmt_q; /* frames to send from pppd */
- struct sk_buff_head rcv_q; /* frames for pppd to read */
- unsigned long xmit_busy; /* bit 0 set when xmitter busy */
-
- /* Information specific to using ppp on async serial lines. */
- struct tty_struct *tty; /* ptr to TTY structure */
- struct tty_struct *backup_tty; /* TTY to use if tty gets closed */
- __u8 escape; /* 0x20 if prev char was PPP_ESC */
- __u8 toss; /* toss this frame */
- volatile __u8 tty_pushing; /* internal state flag */
- volatile __u8 woke_up; /* internal state flag */
- __u32 xmit_async_map[8]; /* 1 bit means that given control
- character is quoted on output*/
- __u32 recv_async_map; /* 1 bit means that given control
- character is ignored on input*/
- __u32 bytes_sent; /* Bytes sent on frame */
- __u32 bytes_rcvd; /* Bytes recvd on frame */
-
- /* Async transmission information */
- struct sk_buff *tpkt; /* frame currently being sent */
- int tpkt_pos; /* how much of it we've done */
- __u16 tfcs; /* FCS so far for it */
- unsigned char *optr; /* where we're up to in sending */
- unsigned char *olim; /* points past last valid char */
-
- /* Async reception information */
- struct sk_buff *rpkt; /* frame currently being rcvd */
- __u16 rfcs; /* FCS so far of rpkt */
-
- /* Queues for select() functionality */
- struct wait_queue *read_wait; /* queue for reading processes */
-
- /* info for detecting idle channels */
- unsigned long last_xmit; /* time of last transmission */
- unsigned long last_recv; /* time last packet received */
-
- /* Statistic information */
- struct pppstat stats; /* statistic information */
-
- /* PPP compression protocol information */
- struct compressor *sc_xcomp; /* transmit compressor */
- void *sc_xc_state; /* transmit compressor state */
- struct compressor *sc_rcomp; /* receive decompressor */
- void *sc_rc_state; /* receive decompressor state */
-
- enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
- int sc_xfer; /* PID of reserved PPP table */
- char name[8]; /* space for unit name */
- struct device dev; /* net device structure */
- struct enet_statistics estats; /* more detailed stats */
-
- /* tty output buffer */
- unsigned char obuf[OBUFSIZE]; /* buffer for characters to send */
-};
-
-#define PPP_MAGIC 0x5002
-#define PPP_VERSION "2.3.11"
diff --git a/mdk-stage1/ppp/include/linux/ppp-comp.h b/mdk-stage1/ppp/include/linux/ppp-comp.h
deleted file mode 100644
index 3184d0731..000000000
--- a/mdk-stage1/ppp/include/linux/ppp-comp.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * ppp-comp.h - Definitions for doing PPP packet compression.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-/*
- * ==FILEVERSION 980319==
- *
- * NOTE TO MAINTAINERS:
- * If you modify this file at all, please set the above date.
- * ppp-comp.h is shipped with a PPP distribution as well as with the kernel;
- * if everyone increases the FILEVERSION number above, then scripts
- * can do the right thing when deciding whether to install a new ppp-comp.h
- * file. Don't change the format of that line otherwise, so the
- * installation script can recognize it.
- */
-
-#ifndef _NET_PPP_COMP_H
-#define _NET_PPP_COMP_H
-
-/*
- * The following symbols control whether we include code for
- * various compression methods.
- */
-
-#ifndef DO_BSD_COMPRESS
-#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
-#endif
-#ifndef DO_DEFLATE
-#define DO_DEFLATE 1 /* by default, include Deflate */
-#endif
-#define DO_PREDICTOR_1 0
-#define DO_PREDICTOR_2 0
-
-/*
- * Structure giving methods for compression/decompression.
- */
-
-struct compressor {
- int compress_proto; /* CCP compression protocol number */
-
- /* Allocate space for a compressor (transmit side) */
- void *(*comp_alloc) (unsigned char *options, int opt_len);
-
- /* Free space used by a compressor */
- void (*comp_free) (void *state);
-
- /* Initialize a compressor */
- int (*comp_init) (void *state, unsigned char *options,
- int opt_len, int unit, int opthdr, int debug);
-
- /* Reset a compressor */
- void (*comp_reset) (void *state);
-
- /* Compress a packet */
- int (*compress) (void *state, unsigned char *rptr,
- unsigned char *obuf, int isize, int osize);
-
- /* Return compression statistics */
- void (*comp_stat) (void *state, struct compstat *stats);
-
- /* Allocate space for a decompressor (receive side) */
- void *(*decomp_alloc) (unsigned char *options, int opt_len);
-
- /* Free space used by a decompressor */
- void (*decomp_free) (void *state);
-
- /* Initialize a decompressor */
- int (*decomp_init) (void *state, unsigned char *options,
- int opt_len, int unit, int opthdr, int mru,
- int debug);
-
- /* Reset a decompressor */
- void (*decomp_reset) (void *state);
-
- /* Decompress a packet. */
- int (*decompress) (void *state, unsigned char *ibuf, int isize,
- unsigned char *obuf, int osize);
-
- /* Update state for an incompressible packet received */
- void (*incomp) (void *state, unsigned char *ibuf, int icnt);
-
- /* Return decompression statistics */
- void (*decomp_stat) (void *state, struct compstat *stats);
-};
-
-/*
- * The return value from decompress routine is the length of the
- * decompressed packet if successful, otherwise DECOMP_ERROR
- * or DECOMP_FATALERROR if an error occurred.
- *
- * We need to make this distinction so that we can disable certain
- * useful functionality, namely sending a CCP reset-request as a result
- * of an error detected after decompression. This is to avoid infringing
- * a patent held by Motorola.
- * Don't you just lurve software patents.
- */
-
-#define DECOMP_ERROR -1 /* error detected before decomp. */
-#define DECOMP_FATALERROR -2 /* error detected after decomp. */
-
-/*
- * CCP codes.
- */
-
-#define CCP_CONFREQ 1
-#define CCP_CONFACK 2
-#define CCP_TERMREQ 5
-#define CCP_TERMACK 6
-#define CCP_RESETREQ 14
-#define CCP_RESETACK 15
-
-/*
- * Max # bytes for a CCP option
- */
-
-#define CCP_MAX_OPTION_LENGTH 32
-
-/*
- * Parts of a CCP packet.
- */
-
-#define CCP_CODE(dp) ((dp)[0])
-#define CCP_ID(dp) ((dp)[1])
-#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
-#define CCP_HDRLEN 4
-
-#define CCP_OPT_CODE(dp) ((dp)[0])
-#define CCP_OPT_LENGTH(dp) ((dp)[1])
-#define CCP_OPT_MINLEN 2
-
-/*
- * Definitions for BSD-Compress.
- */
-
-#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
-#define CILEN_BSD_COMPRESS 3 /* length of config. option */
-
-/* Macros for handling the 3rd byte of the BSD-Compress config option. */
-#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
-#define BSD_VERSION(x) ((x) >> 5) /* version of option format */
-#define BSD_CURRENT_VERSION 1 /* current version number */
-#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
-
-#define BSD_MIN_BITS 9 /* smallest code size supported */
-#define BSD_MAX_BITS 15 /* largest code size supported */
-
-/*
- * Definitions for Deflate.
- */
-
-#define CI_DEFLATE 26 /* config option for Deflate */
-#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
-#define CILEN_DEFLATE 4 /* length of its config option */
-
-#define DEFLATE_MIN_SIZE 8
-#define DEFLATE_MAX_SIZE 15
-#define DEFLATE_METHOD_VAL 8
-#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
-#define DEFLATE_METHOD(x) ((x) & 0x0F)
-#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
- + DEFLATE_METHOD_VAL)
-#define DEFLATE_CHK_SEQUENCE 0
-
-/*
- * Definitions for other, as yet unsupported, compression methods.
- */
-
-#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
-#define CILEN_PREDICTOR_1 2 /* length of its config option */
-#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
-#define CILEN_PREDICTOR_2 2 /* length of its config option */
-
-#ifdef __KERNEL__
-extern int ppp_register_compressor(struct compressor *);
-extern void ppp_unregister_compressor(struct compressor *);
-#endif /* __KERNEL__ */
-
-#endif /* _NET_PPP_COMP_H */
diff --git a/mdk-stage1/ppp/include/linux/ppp_defs.h b/mdk-stage1/ppp/include/linux/ppp_defs.h
deleted file mode 100644
index 46946fbdc..000000000
--- a/mdk-stage1/ppp/include/linux/ppp_defs.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/* $Id$ */
-
-/*
- * ppp_defs.h - PPP definitions.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- */
-
-/*
- * ==FILEVERSION 20000114==
- *
- * NOTE TO MAINTAINERS:
- * If you modify this file at all, please set the above date.
- * ppp_defs.h is shipped with a PPP distribution as well as with the kernel;
- * if everyone increases the FILEVERSION number above, then scripts
- * can do the right thing when deciding whether to install a new ppp_defs.h
- * file. Don't change the format of that line otherwise, so the
- * installation script can recognize it.
- */
-
-#ifndef _PPP_DEFS_H_
-#define _PPP_DEFS_H_
-
-/*
- * The basic PPP frame.
- */
-#define PPP_HDRLEN 4 /* octets for standard ppp header */
-#define PPP_FCSLEN 2 /* octets for FCS */
-#define PPP_MRU 1500 /* default MRU = max length of info field */
-
-#define PPP_ADDRESS(p) (((__u8 *)(p))[0])
-#define PPP_CONTROL(p) (((__u8 *)(p))[1])
-#define PPP_PROTOCOL(p) ((((__u8 *)(p))[2] << 8) + ((__u8 *)(p))[3])
-
-/*
- * Significant octet values.
- */
-#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
-#define PPP_UI 0x03 /* Unnumbered Information */
-#define PPP_FLAG 0x7e /* Flag Sequence */
-#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
-#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
-
-/*
- * Protocol field values.
- */
-#define PPP_IP 0x21 /* Internet Protocol */
-#define PPP_AT 0x29 /* AppleTalk Protocol */
-#define PPP_IPX 0x2b /* IPX protocol */
-#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
-#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
-#define PPP_MP 0x3d /* Multilink protocol */
-#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
-#define PPP_COMPFRAG 0xfb /* fragment compressed below bundle */
-#define PPP_COMP 0xfd /* compressed packet */
-#define PPP_IPCP 0x8021 /* IP Control Protocol */
-#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
-#define PPP_IPXCP 0x802b /* IPX Control Protocol */
-#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
-#define PPP_CCPFRAG 0x80fb /* CCP at link level (below MP bundle) */
-#define PPP_CCP 0x80fd /* Compression Control Protocol */
-#define PPP_LCP 0xc021 /* Link Control Protocol */
-#define PPP_PAP 0xc023 /* Password Authentication Protocol */
-#define PPP_LQR 0xc025 /* Link Quality Report protocol */
-#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
-#define PPP_CBCP 0xc029 /* Callback Control Protocol */
-
-/*
- * Values for FCS calculations.
- */
-
-#define PPP_INITFCS 0xffff /* Initial FCS value */
-#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
-#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
-
-/*
- * Extended asyncmap - allows any character to be escaped.
- */
-
-typedef __u32 ext_accm[8];
-
-/*
- * What to do with network protocol (NP) packets.
- */
-enum NPmode {
- NPMODE_PASS, /* pass the packet through */
- NPMODE_DROP, /* silently drop the packet */
- NPMODE_ERROR, /* return an error */
- NPMODE_QUEUE /* save it up for later. */
-};
-
-/*
- * Statistics for LQRP and pppstats
- */
-struct pppstat {
- __u32 ppp_discards; /* # frames discarded */
-
- __u32 ppp_ibytes; /* bytes received */
- __u32 ppp_ioctects; /* bytes received not in error */
- __u32 ppp_ipackets; /* packets received */
- __u32 ppp_ierrors; /* receive errors */
- __u32 ppp_ilqrs; /* # LQR frames received */
-
- __u32 ppp_obytes; /* raw bytes sent */
- __u32 ppp_ooctects; /* frame bytes sent */
- __u32 ppp_opackets; /* packets sent */
- __u32 ppp_oerrors; /* transmit errors */
- __u32 ppp_olqrs; /* # LQR frames sent */
-};
-
-struct vjstat {
- __u32 vjs_packets; /* outbound packets */
- __u32 vjs_compressed; /* outbound compressed packets */
- __u32 vjs_searches; /* searches for connection state */
- __u32 vjs_misses; /* times couldn't find conn. state */
- __u32 vjs_uncompressedin; /* inbound uncompressed packets */
- __u32 vjs_compressedin; /* inbound compressed packets */
- __u32 vjs_errorin; /* inbound unknown type packets */
- __u32 vjs_tossed; /* inbound packets tossed because of error */
-};
-
-struct compstat {
- __u32 unc_bytes; /* total uncompressed bytes */
- __u32 unc_packets; /* total uncompressed packets */
- __u32 comp_bytes; /* compressed bytes */
- __u32 comp_packets; /* compressed packets */
- __u32 inc_bytes; /* incompressible bytes */
- __u32 inc_packets; /* incompressible packets */
-
- /* the compression ratio is defined as in_count / bytes_out */
- __u32 in_count; /* Bytes received */
- __u32 bytes_out; /* Bytes transmitted */
-
- double ratio; /* not computed in kernel. */
-};
-
-struct ppp_stats {
- struct pppstat p; /* basic PPP statistics */
- struct vjstat vj; /* VJ header compression statistics */
-};
-
-struct ppp_comp_stats {
- struct compstat c; /* packet compression statistics */
- struct compstat d; /* packet decompression statistics */
-};
-
-/*
- * The following structure records the time in seconds since
- * the last NP packet was sent or received.
- */
-struct ppp_idle {
- time_t xmit_idle; /* time since last NP packet sent */
- time_t recv_idle; /* time since last NP packet received */
-};
-
-#ifndef __P
-#ifdef __STDC__
-#define __P(x) x
-#else
-#define __P(x) ()
-#endif
-#endif
-
-#endif /* _PPP_DEFS_H_ */
diff --git a/mdk-stage1/ppp/include/net/if_ppp.h b/mdk-stage1/ppp/include/net/if_ppp.h
deleted file mode 100644
index 1527ecf3f..000000000
--- a/mdk-stage1/ppp/include/net/if_ppp.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* $Id$ */
-
-/*
- * if_ppp.h - Point-to-Point Protocol definitions.
- *
- * Copyright (c) 1989 Carnegie Mellon University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _IF_PPP_H_
-#define _IF_PPP_H_
-
-/*
- * Bit definitions for flags.
- */
-#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */
-#define SC_COMP_AC 0x00000002 /* header compression (output) */
-#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */
-#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */
-#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */
-#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */
-#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */
-#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */
-#define SC_DEBUG 0x00010000 /* enable debug messages */
-#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */
-#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */
-#define SC_LOG_RAWIN 0x00080000 /* log all chars received */
-#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */
-#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */
-#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */
-#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */
-#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */
-#define SC_SYNC 0x00200000 /* use synchronous HDLC framing */
-#define SC_MASK 0x0fff00ff /* bits that user can change */
-
-/*
- * State bits in sc_flags, not changeable by user.
- */
-#define SC_TIMEOUT 0x00000400 /* timeout is currently pending */
-#define SC_VJ_RESET 0x00000800 /* need to reset VJ decomp */
-#define SC_COMP_RUN 0x00001000 /* compressor has been inited */
-#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */
-#define SC_DC_ERROR 0x00004000 /* non-fatal decomp error detected */
-#define SC_DC_FERROR 0x00008000 /* fatal decomp error detected */
-#define SC_TBUSY 0x10000000 /* xmitter doesn't need a packet yet */
-#define SC_PKTLOST 0x20000000 /* have lost or dropped a packet */
-#define SC_FLUSH 0x40000000 /* flush input until next PPP_FLAG */
-#define SC_ESCAPED 0x80000000 /* saw a PPP_ESCAPE */
-
-/*
- * Ioctl definitions.
- */
-
-struct npioctl {
- int protocol; /* PPP procotol, e.g. PPP_IP */
- enum NPmode mode;
-};
-
-/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
-struct ppp_option_data {
- u_char *ptr;
- u_int length;
- int transmit;
-};
-
-struct ifpppstatsreq {
- char ifr_name[IFNAMSIZ];
- struct ppp_stats stats;
-};
-
-struct ifpppcstatsreq {
- char ifr_name[IFNAMSIZ];
- struct ppp_comp_stats stats;
-};
-
-/*
- * Ioctl definitions.
- */
-
-#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
-#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
-#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
-#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */
-#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */
-#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */
-#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */
-#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */
-#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */
-#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */
-#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
-#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
-#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */
-#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
-#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */
-#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
-#define PPPIOCGIDLE _IOR('t', 74, struct ppp_idle) /* get idle time */
-#ifdef PPP_FILTER
-#define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */
-#define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */
-#endif /* PPP_FILTER */
-
-/* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */
-#define PPPIOCGMTU _IOR('t', 73, int) /* get interface MTU */
-#define PPPIOCSMTU _IOW('t', 72, int) /* set interface MTU */
-
-/*
- * These two are interface ioctls so that pppstats can do them on
- * a socket without having to open the serial device.
- */
-#define SIOCGPPPSTATS _IOWR('i', 123, struct ifpppstatsreq)
-#define SIOCGPPPCSTATS _IOWR('i', 122, struct ifpppcstatsreq)
-
-#if !defined(ifr_mtu)
-#define ifr_mtu ifr_ifru.ifru_metric
-#endif
-
-#if (defined(_KERNEL) || defined(KERNEL)) && !defined(NeXT)
-void pppattach __P((void));
-void pppintr __P((void));
-#endif
-#endif /* _IF_PPP_H_ */
diff --git a/mdk-stage1/ppp/include/net/ppp-comp.h b/mdk-stage1/ppp/include/net/ppp-comp.h
deleted file mode 100644
index 0e6a9c672..000000000
--- a/mdk-stage1/ppp/include/net/ppp-comp.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * ppp-comp.h - Definitions for doing PPP packet compression.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-#ifndef _NET_PPP_COMP_H
-#define _NET_PPP_COMP_H
-
-/*
- * The following symbols control whether we include code for
- * various compression methods.
- */
-#ifndef DO_BSD_COMPRESS
-#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
-#endif
-#ifndef DO_DEFLATE
-#define DO_DEFLATE 1 /* by default, include Deflate */
-#endif
-#define DO_PREDICTOR_1 0
-#define DO_PREDICTOR_2 0
-
-/*
- * Structure giving methods for compression/decompression.
- */
-#ifdef PACKETPTR
-struct compressor {
- int compress_proto; /* CCP compression protocol number */
-
- /* Allocate space for a compressor (transmit side) */
- void *(*comp_alloc) __P((u_char *options, int opt_len));
- /* Free space used by a compressor */
- void (*comp_free) __P((void *state));
- /* Initialize a compressor */
- int (*comp_init) __P((void *state, u_char *options, int opt_len,
- int unit, int hdrlen, int debug));
- /* Reset a compressor */
- void (*comp_reset) __P((void *state));
- /* Compress a packet */
- int (*compress) __P((void *state, PACKETPTR *mret,
- PACKETPTR mp, int orig_len, int max_len));
- /* Return compression statistics */
- void (*comp_stat) __P((void *state, struct compstat *stats));
-
- /* Allocate space for a decompressor (receive side) */
- void *(*decomp_alloc) __P((u_char *options, int opt_len));
- /* Free space used by a decompressor */
- void (*decomp_free) __P((void *state));
- /* Initialize a decompressor */
- int (*decomp_init) __P((void *state, u_char *options, int opt_len,
- int unit, int hdrlen, int mru, int debug));
- /* Reset a decompressor */
- void (*decomp_reset) __P((void *state));
- /* Decompress a packet. */
- int (*decompress) __P((void *state, PACKETPTR mp,
- PACKETPTR *dmpp));
- /* Update state for an incompressible packet received */
- void (*incomp) __P((void *state, PACKETPTR mp));
- /* Return decompression statistics */
- void (*decomp_stat) __P((void *state, struct compstat *stats));
-};
-#endif /* PACKETPTR */
-
-/*
- * Return values for decompress routine.
- * We need to make these distinctions so that we can disable certain
- * useful functionality, namely sending a CCP reset-request as a result
- * of an error detected after decompression. This is to avoid infringing
- * a patent held by Motorola.
- * Don't you just lurve software patents.
- */
-#define DECOMP_OK 0 /* everything went OK */
-#define DECOMP_ERROR 1 /* error detected before decomp. */
-#define DECOMP_FATALERROR 2 /* error detected after decomp. */
-
-/*
- * CCP codes.
- */
-#define CCP_CONFREQ 1
-#define CCP_CONFACK 2
-#define CCP_TERMREQ 5
-#define CCP_TERMACK 6
-#define CCP_RESETREQ 14
-#define CCP_RESETACK 15
-
-/*
- * Max # bytes for a CCP option
- */
-#define CCP_MAX_OPTION_LENGTH 32
-
-/*
- * Parts of a CCP packet.
- */
-#define CCP_CODE(dp) ((dp)[0])
-#define CCP_ID(dp) ((dp)[1])
-#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
-#define CCP_HDRLEN 4
-
-#define CCP_OPT_CODE(dp) ((dp)[0])
-#define CCP_OPT_LENGTH(dp) ((dp)[1])
-#define CCP_OPT_MINLEN 2
-
-/*
- * Definitions for BSD-Compress.
- */
-#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
-#define CILEN_BSD_COMPRESS 3 /* length of config. option */
-
-/* Macros for handling the 3rd byte of the BSD-Compress config option. */
-#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
-#define BSD_VERSION(x) ((x) >> 5) /* version of option format */
-#define BSD_CURRENT_VERSION 1 /* current version number */
-#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
-
-#define BSD_MIN_BITS 9 /* smallest code size supported */
-#define BSD_MAX_BITS 15 /* largest code size supported */
-
-/*
- * Definitions for Deflate.
- */
-#define CI_DEFLATE 26 /* config option for Deflate */
-#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
-#define CILEN_DEFLATE 4 /* length of its config option */
-
-#define DEFLATE_MIN_SIZE 8
-#define DEFLATE_MAX_SIZE 15
-#define DEFLATE_METHOD_VAL 8
-#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
-#define DEFLATE_METHOD(x) ((x) & 0x0F)
-#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
- + DEFLATE_METHOD_VAL)
-#define DEFLATE_CHK_SEQUENCE 0
-
-/*
- * Definitions for other, as yet unsupported, compression methods.
- */
-#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
-#define CILEN_PREDICTOR_1 2 /* length of its config option */
-#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
-#define CILEN_PREDICTOR_2 2 /* length of its config option */
-
-#endif /* _NET_PPP_COMP_H */
diff --git a/mdk-stage1/ppp/include/net/ppp_defs.h b/mdk-stage1/ppp/include/net/ppp_defs.h
deleted file mode 100644
index 46bef52bb..000000000
--- a/mdk-stage1/ppp/include/net/ppp_defs.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/* $Id$ */
-
-/*
- * ppp_defs.h - PPP definitions.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- */
-
-#ifndef _PPP_DEFS_H_
-#define _PPP_DEFS_H_
-
-/*
- * The basic PPP frame.
- */
-#define PPP_HDRLEN 4 /* octets for standard ppp header */
-#define PPP_FCSLEN 2 /* octets for FCS */
-
-/*
- * Packet sizes
- *
- * Note - lcp shouldn't be allowed to negotiate stuff outside these
- * limits. See lcp.h in the pppd directory.
- * (XXX - these constants should simply be shared by lcp.c instead
- * of living in lcp.h)
- */
-#define PPP_MTU 1500 /* Default MTU (size of Info field) */
-#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN)
-#define PPP_MINMTU 64
-#define PPP_MRU 1500 /* default MRU = max length of info field */
-#define PPP_MAXMRU 65000 /* Largest MRU we allow */
-#define PPP_MINMRU 128
-
-#define PPP_ADDRESS(p) (((u_char *)(p))[0])
-#define PPP_CONTROL(p) (((u_char *)(p))[1])
-#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
-
-/*
- * Significant octet values.
- */
-#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
-#define PPP_UI 0x03 /* Unnumbered Information */
-#define PPP_FLAG 0x7e /* Flag Sequence */
-#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
-#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
-
-/*
- * Protocol field values.
- */
-#define PPP_IP 0x21 /* Internet Protocol */
-#define PPP_AT 0x29 /* AppleTalk Protocol */
-#define PPP_IPX 0x2b /* IPX protocol */
-#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
-#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
-#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
-#define PPP_COMP 0xfd /* compressed packet */
-#define PPP_IPCP 0x8021 /* IP Control Protocol */
-#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
-#define PPP_IPXCP 0x802b /* IPX Control Protocol */
-#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
-#define PPP_CCP 0x80fd /* Compression Control Protocol */
-#define PPP_LCP 0xc021 /* Link Control Protocol */
-#define PPP_PAP 0xc023 /* Password Authentication Protocol */
-#define PPP_LQR 0xc025 /* Link Quality Report protocol */
-#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
-#define PPP_CBCP 0xc029 /* Callback Control Protocol */
-
-/*
- * Values for FCS calculations.
- */
-#define PPP_INITFCS 0xffff /* Initial FCS value */
-#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
-#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
-
-/*
- * A 32-bit unsigned integral type.
- */
-
-#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
- && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__dietlibc__)
-#ifdef UINT32_T
-typedef UINT32_T u_int32_t;
-#else
-typedef unsigned int u_int32_t;
-typedef unsigned short u_int16_t;
-#endif
-#endif
-
-/*
- * Extended asyncmap - allows any character to be escaped.
- */
-typedef u_int32_t ext_accm[8];
-
-/*
- * What to do with network protocol (NP) packets.
- */
-enum NPmode {
- NPMODE_PASS, /* pass the packet through */
- NPMODE_DROP, /* silently drop the packet */
- NPMODE_ERROR, /* return an error */
- NPMODE_QUEUE /* save it up for later. */
-};
-
-/*
- * Statistics.
- */
-struct pppstat {
- unsigned int ppp_ibytes; /* bytes received */
- unsigned int ppp_ipackets; /* packets received */
- unsigned int ppp_ierrors; /* receive errors */
- unsigned int ppp_obytes; /* bytes sent */
- unsigned int ppp_opackets; /* packets sent */
- unsigned int ppp_oerrors; /* transmit errors */
-};
-
-struct vjstat {
- unsigned int vjs_packets; /* outbound packets */
- unsigned int vjs_compressed; /* outbound compressed packets */
- unsigned int vjs_searches; /* searches for connection state */
- unsigned int vjs_misses; /* times couldn't find conn. state */
- unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
- unsigned int vjs_compressedin; /* inbound compressed packets */
- unsigned int vjs_errorin; /* inbound unknown type packets */
- unsigned int vjs_tossed; /* inbound packets tossed because of error */
-};
-
-struct ppp_stats {
- struct pppstat p; /* basic PPP statistics */
- struct vjstat vj; /* VJ header compression statistics */
-};
-
-struct compstat {
- unsigned int unc_bytes; /* total uncompressed bytes */
- unsigned int unc_packets; /* total uncompressed packets */
- unsigned int comp_bytes; /* compressed bytes */
- unsigned int comp_packets; /* compressed packets */
- unsigned int inc_bytes; /* incompressible bytes */
- unsigned int inc_packets; /* incompressible packets */
- unsigned int ratio; /* recent compression ratio << 8 */
-};
-
-struct ppp_comp_stats {
- struct compstat c; /* packet compression statistics */
- struct compstat d; /* packet decompression statistics */
-};
-
-/*
- * The following structure records the time in seconds since
- * the last NP packet was sent or received.
- */
-struct ppp_idle {
- time_t xmit_idle; /* time since last NP packet sent */
- time_t recv_idle; /* time since last NP packet received */
-};
-
-#ifndef __P
-#ifdef __STDC__
-#define __P(x) x
-#else
-#define __P(x) ()
-#endif
-#endif
-
-#endif /* _PPP_DEFS_H_ */
diff --git a/mdk-stage1/ppp/include/net/pppio.h b/mdk-stage1/ppp/include/net/pppio.h
deleted file mode 100644
index 9db1ca9ab..000000000
--- a/mdk-stage1/ppp/include/net/pppio.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * pppio.h - ioctl and other misc. definitions for STREAMS modules.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-#define _PPPIO(n) (('p' << 8) + (n))
-
-#define PPPIO_NEWPPA _PPPIO(130) /* allocate a new PPP unit */
-#define PPPIO_GETSTAT _PPPIO(131) /* get PPP statistics */
-#define PPPIO_GETCSTAT _PPPIO(132) /* get PPP compression stats */
-#define PPPIO_MTU _PPPIO(133) /* set max transmission unit */
-#define PPPIO_MRU _PPPIO(134) /* set max receive unit */
-#define PPPIO_CFLAGS _PPPIO(135) /* set/clear/get compression flags */
-#define PPPIO_XCOMP _PPPIO(136) /* alloc transmit compressor */
-#define PPPIO_RCOMP _PPPIO(137) /* alloc receive decompressor */
-#define PPPIO_XACCM _PPPIO(138) /* set transmit asyncmap */
-#define PPPIO_RACCM _PPPIO(139) /* set receive asyncmap */
-#define PPPIO_VJINIT _PPPIO(140) /* initialize VJ comp/decomp */
-#define PPPIO_ATTACH _PPPIO(141) /* attach to a ppa (without putmsg) */
-#define PPPIO_LASTMOD _PPPIO(142) /* mark last ppp module */
-#define PPPIO_GCLEAN _PPPIO(143) /* get 8-bit-clean flags */
-#define PPPIO_DEBUG _PPPIO(144) /* request debug information */
-#define PPPIO_BIND _PPPIO(145) /* bind to SAP */
-#define PPPIO_NPMODE _PPPIO(146) /* set mode for handling data pkts */
-#define PPPIO_GIDLE _PPPIO(147) /* get time since last data pkt */
-#define PPPIO_PASSFILT _PPPIO(148) /* set filter for packets to pass */
-#define PPPIO_ACTIVEFILT _PPPIO(149) /* set filter for "link active" pkts */
-
-/*
- * Values for PPPIO_CFLAGS
- */
-#define COMP_AC 0x1 /* compress address/control */
-#define DECOMP_AC 0x2 /* decompress address/control */
-#define COMP_PROT 0x4 /* compress PPP protocol */
-#define DECOMP_PROT 0x8 /* decompress PPP protocol */
-
-#define COMP_VJC 0x10 /* compress TCP/IP headers */
-#define COMP_VJCCID 0x20 /* compress connection ID as well */
-#define DECOMP_VJC 0x40 /* decompress TCP/IP headers */
-#define DECOMP_VJCCID 0x80 /* accept compressed connection ID */
-
-#define CCP_ISOPEN 0x100 /* look at CCP packets */
-#define CCP_ISUP 0x200 /* do packet comp/decomp */
-#define CCP_ERROR 0x400 /* (status) error in packet decomp */
-#define CCP_FATALERROR 0x800 /* (status) fatal error ditto */
-#define CCP_COMP_RUN 0x1000 /* (status) seen CCP ack sent */
-#define CCP_DECOMP_RUN 0x2000 /* (status) seen CCP ack rcvd */
-
-/*
- * Values for 8-bit-clean flags.
- */
-#define RCV_B7_0 1 /* have rcvd char with bit 7 = 0 */
-#define RCV_B7_1 2 /* have rcvd char with bit 7 = 1 */
-#define RCV_EVNP 4 /* have rcvd char with even parity */
-#define RCV_ODDP 8 /* have rcvd char with odd parity */
-
-/*
- * Values for the first byte of M_CTL messages passed between
- * PPP modules.
- */
-#define PPPCTL_OERROR 0xe0 /* output error [up] */
-#define PPPCTL_IERROR 0xe1 /* input error (e.g. FCS) [up] */
-#define PPPCTL_MTU 0xe2 /* set MTU [down] */
-#define PPPCTL_MRU 0xe3 /* set MRU [down] */
-#define PPPCTL_UNIT 0xe4 /* note PPP unit number [down] */
-
-/*
- * Values for the integer argument to PPPIO_DEBUG.
- */
-#define PPPDBG_DUMP 0x10000 /* print out debug info now */
-#define PPPDBG_LOG 0x100 /* log various things */
-#define PPPDBG_DRIVER 0 /* identifies ppp driver as target */
-#define PPPDBG_IF 1 /* identifies ppp network i/f target */
-#define PPPDBG_COMP 2 /* identifies ppp compression target */
-#define PPPDBG_AHDLC 3 /* identifies ppp async hdlc target */
diff --git a/mdk-stage1/ppp/include/net/slcompress.h b/mdk-stage1/ppp/include/net/slcompress.h
deleted file mode 100644
index 9e19bc0ed..000000000
--- a/mdk-stage1/ppp/include/net/slcompress.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Definitions for tcp compression routines.
- *
- * $Id$
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- * - Initial distribution.
- */
-
-#ifndef _SLCOMPRESS_H_
-#define _SLCOMPRESS_H_
-
-#define MAX_STATES 16 /* must be > 2 and < 256 */
-#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */
-
-/*
- * Compressed packet format:
- *
- * The first octet contains the packet type (top 3 bits), TCP
- * 'push' bit, and flags that indicate which of the 4 TCP sequence
- * numbers have changed (bottom 5 bits). The next octet is a
- * conversation number that associates a saved IP/TCP header with
- * the compressed packet. The next two octets are the TCP checksum
- * from the original datagram. The next 0 to 15 octets are
- * sequence number changes, one change per bit set in the header
- * (there may be no changes and there are two special cases where
- * the receiver implicitly knows what changed -- see below).
- *
- * There are 5 numbers which can change (they are always inserted
- * in the following order): TCP urgent pointer, window,
- * acknowlegement, sequence number and IP ID. (The urgent pointer
- * is different from the others in that its value is sent, not the
- * change in value.) Since typical use of SLIP links is biased
- * toward small packets (see comments on MTU/MSS below), changes
- * use a variable length coding with one octet for numbers in the
- * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
- * range 256 - 65535 or 0. (If the change in sequence number or
- * ack is more than 65535, an uncompressed packet is sent.)
- */
-
-/*
- * Packet types (must not conflict with IP protocol version)
- *
- * The top nibble of the first octet is the packet type. There are
- * three possible types: IP (not proto TCP or tcp with one of the
- * control flags set); uncompressed TCP (a normal IP/TCP packet but
- * with the 8-bit protocol field replaced by an 8-bit connection id --
- * this type of packet syncs the sender & receiver); and compressed
- * TCP (described above).
- *
- * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
- * is logically part of the 4-bit "changes" field that follows. Top
- * three bits are actual packet type. For backward compatibility
- * and in the interest of conserving bits, numbers are chosen so the
- * IP protocol version number (4) which normally appears in this nibble
- * means "IP packet".
- */
-
-/* packet types */
-#define TYPE_IP 0x40
-#define TYPE_UNCOMPRESSED_TCP 0x70
-#define TYPE_COMPRESSED_TCP 0x80
-#define TYPE_ERROR 0x00
-
-/* Bits in first octet of compressed packet */
-#define NEW_C 0x40 /* flag bits for what changed in a packet */
-#define NEW_I 0x20
-#define NEW_S 0x08
-#define NEW_A 0x04
-#define NEW_W 0x02
-#define NEW_U 0x01
-
-/* reserved, special-case values of above */
-#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
-#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
-#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
-
-#define TCP_PUSH_BIT 0x10
-
-
-/*
- * "state" data for each active tcp conversation on the wire. This is
- * basically a copy of the entire IP/TCP header from the last packet
- * we saw from the conversation together with a small identifier
- * the transmit & receive ends of the line use to locate saved header.
- */
-struct cstate {
- struct cstate *cs_next; /* next most recently used cstate (xmit only) */
- u_short cs_hlen; /* size of hdr (receive only) */
- u_char cs_id; /* connection # associated with this state */
- u_char cs_filler;
- union {
- char csu_hdr[MAX_HDR];
- struct ip csu_ip; /* ip/tcp hdr from most recent packet */
- } slcs_u;
-};
-#define cs_ip slcs_u.csu_ip
-#define cs_hdr slcs_u.csu_hdr
-
-/*
- * all the state data for one serial line (we need one of these
- * per line).
- */
-struct slcompress {
- struct cstate *last_cs; /* most recently used tstate */
- u_char last_recv; /* last rcvd conn. id */
- u_char last_xmit; /* last sent conn. id */
- u_short flags;
-#ifndef SL_NO_STATS
- int sls_packets; /* outbound packets */
- int sls_compressed; /* outbound compressed packets */
- int sls_searches; /* searches for connection state */
- int sls_misses; /* times couldn't find conn. state */
- int sls_uncompressedin; /* inbound uncompressed packets */
- int sls_compressedin; /* inbound compressed packets */
- int sls_errorin; /* inbound unknown type packets */
- int sls_tossed; /* inbound packets tossed because of error */
-#endif
- struct cstate tstate[MAX_STATES]; /* xmit connection states */
- struct cstate rstate[MAX_STATES]; /* receive connection states */
-};
-/* flag values */
-#define SLF_TOSS 1 /* tossing rcvd frames because of input err */
-
-void sl_compress_init __P((struct slcompress *));
-void sl_compress_setup __P((struct slcompress *, int));
-u_int sl_compress_tcp __P((struct mbuf *,
- struct ip *, struct slcompress *, int));
-int sl_uncompress_tcp __P((u_char **, int, u_int, struct slcompress *));
-int sl_uncompress_tcp_core __P((u_char *, int, int, u_int,
- struct slcompress *, u_char **, u_int *));
-
-#endif /* _SLCOMPRESS_H_ */
diff --git a/mdk-stage1/ppp/include/net/vjcompress.h b/mdk-stage1/ppp/include/net/vjcompress.h
deleted file mode 100644
index c64596926..000000000
--- a/mdk-stage1/ppp/include/net/vjcompress.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Definitions for tcp compression routines.
- *
- * $Id$
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- * - Initial distribution.
- */
-
-#ifndef _VJCOMPRESS_H_
-#define _VJCOMPRESS_H_
-
-#define MAX_STATES 16 /* must be > 2 and < 256 */
-#define MAX_HDR 128
-
-/*
- * Compressed packet format:
- *
- * The first octet contains the packet type (top 3 bits), TCP
- * 'push' bit, and flags that indicate which of the 4 TCP sequence
- * numbers have changed (bottom 5 bits). The next octet is a
- * conversation number that associates a saved IP/TCP header with
- * the compressed packet. The next two octets are the TCP checksum
- * from the original datagram. The next 0 to 15 octets are
- * sequence number changes, one change per bit set in the header
- * (there may be no changes and there are two special cases where
- * the receiver implicitly knows what changed -- see below).
- *
- * There are 5 numbers which can change (they are always inserted
- * in the following order): TCP urgent pointer, window,
- * acknowlegement, sequence number and IP ID. (The urgent pointer
- * is different from the others in that its value is sent, not the
- * change in value.) Since typical use of SLIP links is biased
- * toward small packets (see comments on MTU/MSS below), changes
- * use a variable length coding with one octet for numbers in the
- * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
- * range 256 - 65535 or 0. (If the change in sequence number or
- * ack is more than 65535, an uncompressed packet is sent.)
- */
-
-/*
- * Packet types (must not conflict with IP protocol version)
- *
- * The top nibble of the first octet is the packet type. There are
- * three possible types: IP (not proto TCP or tcp with one of the
- * control flags set); uncompressed TCP (a normal IP/TCP packet but
- * with the 8-bit protocol field replaced by an 8-bit connection id --
- * this type of packet syncs the sender & receiver); and compressed
- * TCP (described above).
- *
- * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
- * is logically part of the 4-bit "changes" field that follows. Top
- * three bits are actual packet type. For backward compatibility
- * and in the interest of conserving bits, numbers are chosen so the
- * IP protocol version number (4) which normally appears in this nibble
- * means "IP packet".
- */
-
-/* packet types */
-#define TYPE_IP 0x40
-#define TYPE_UNCOMPRESSED_TCP 0x70
-#define TYPE_COMPRESSED_TCP 0x80
-#define TYPE_ERROR 0x00
-
-/* Bits in first octet of compressed packet */
-#define NEW_C 0x40 /* flag bits for what changed in a packet */
-#define NEW_I 0x20
-#define NEW_S 0x08
-#define NEW_A 0x04
-#define NEW_W 0x02
-#define NEW_U 0x01
-
-/* reserved, special-case values of above */
-#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
-#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
-#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
-
-#define TCP_PUSH_BIT 0x10
-
-
-/*
- * "state" data for each active tcp conversation on the wire. This is
- * basically a copy of the entire IP/TCP header from the last packet
- * we saw from the conversation together with a small identifier
- * the transmit & receive ends of the line use to locate saved header.
- */
-struct cstate {
- struct cstate *cs_next; /* next most recently used state (xmit only) */
- u_short cs_hlen; /* size of hdr (receive only) */
- u_char cs_id; /* connection # associated with this state */
- u_char cs_filler;
- union {
- char csu_hdr[MAX_HDR];
- struct ip csu_ip; /* ip/tcp hdr from most recent packet */
- } vjcs_u;
-};
-#define cs_ip vjcs_u.csu_ip
-#define cs_hdr vjcs_u.csu_hdr
-
-/*
- * all the state data for one serial line (we need one of these per line).
- */
-struct vjcompress {
- struct cstate *last_cs; /* most recently used tstate */
- u_char last_recv; /* last rcvd conn. id */
- u_char last_xmit; /* last sent conn. id */
- u_short flags;
-#ifndef VJ_NO_STATS
- struct vjstat stats;
-#endif
- struct cstate tstate[MAX_STATES]; /* xmit connection states */
- struct cstate rstate[MAX_STATES]; /* receive connection states */
-};
-
-/* flag values */
-#define VJF_TOSS 1 /* tossing rcvd frames because of input err */
-
-extern void vj_compress_init __P((struct vjcompress *comp, int max_state));
-extern u_int vj_compress_tcp __P((struct ip *ip, u_int mlen,
- struct vjcompress *comp, int compress_cid_flag,
- u_char **vjhdrp));
-extern void vj_uncompress_err __P((struct vjcompress *comp));
-extern int vj_uncompress_uncomp __P((u_char *buf, int buflen,
- struct vjcompress *comp));
-extern int vj_uncompress_tcp __P((u_char *buf, int buflen, int total_len,
- struct vjcompress *comp, u_char **hdrp,
- u_int *hlenp));
-
-#endif /* _VJCOMPRESS_H_ */
diff --git a/mdk-stage1/ppp/include/pcap-int.h b/mdk-stage1/ppp/include/pcap-int.h
deleted file mode 100644
index 323994929..000000000
--- a/mdk-stage1/ppp/include/pcap-int.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Computer Systems
- * Engineering Group at Lawrence Berkeley Laboratory.
- * 4. Neither the name of the University nor of the Laboratory may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#) $Header$ (LBL)
- */
-
-#ifndef pcap_int_h
-#define pcap_int_h
-
-#include <pcap.h>
-
-/*
- * Savefile
- */
-struct pcap_sf {
- FILE *rfile;
- int swapped;
- int version_major;
- int version_minor;
- u_char *base;
-};
-
-struct pcap_md {
- struct pcap_stat stat;
- /*XXX*/
- int use_bpf;
- u_long TotPkts; /* can't oflow for 79 hrs on ether */
- u_long TotAccepted; /* count accepted by filter */
- u_long TotDrops; /* count of dropped packets */
- long TotMissed; /* missed by i/f during this run */
- long OrigMissed; /* missed by i/f before this run */
-#ifdef linux
- int pad;
- int skip;
- char *device;
-#endif
-};
-
-struct pcap {
- int fd;
- int snapshot;
- int linktype;
- int tzoff; /* timezone offset */
- int offset; /* offset for proper alignment */
-
- struct pcap_sf sf;
- struct pcap_md md;
-
- /*
- * Read buffer.
- */
- int bufsize;
- u_char *buffer;
- u_char *bp;
- int cc;
-
- /*
- * Place holder for pcap_next().
- */
- u_char *pkt;
-
-
- /*
- * Placeholder for filter code if bpf not in kernel.
- */
- struct bpf_program fcode;
-
- char errbuf[PCAP_ERRBUF_SIZE];
-};
-
-int yylex(void);
-
-#ifndef min
-#define min(a, b) ((a) > (b) ? (b) : (a))
-#endif
-
-/* XXX should these be in pcap.h? */
-int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
-int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
-
-/* Ultrix pads to make everything line up on a nice boundary */
-#if defined(ultrix) || defined(__alpha)
-#define PCAP_FDDIPAD 3
-#endif
-
-/* XXX */
-extern int pcap_fddipad;
-#endif
diff --git a/mdk-stage1/ppp/linux/Makefile.top b/mdk-stage1/ppp/linux/Makefile.top
deleted file mode 100644
index fa34ce59f..000000000
--- a/mdk-stage1/ppp/linux/Makefile.top
+++ /dev/null
@@ -1,55 +0,0 @@
-# PPP top-level Makefile for Linux.
-
-
-BINDIR = $(DESTDIR)/usr/sbin
-MANDIR = $(DESTDIR)/usr/man
-ETCDIR = $(DESTDIR)/etc/ppp
-
-# uid 0 = root
-INSTALL= install
-
-all:
- cd chat; $(MAKE) $(MFLAGS) all
- cd pppd; $(MAKE) $(MFLAGS) all
- cd pppstats; $(MAKE) $(MFLAGS) all
- cd pppdump; $(MAKE) $(MFLAGS) all
-
-install: $(BINDIR) $(MANDIR)/man8 install-progs install-etcppp
-
-install-progs:
- cd chat; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install
- cd pppd; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install
- cd pppstats; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install
- cd pppdump; $(MAKE) BINDIR=$(BINDIR) MANDIR=$(MANDIR) $(MFLAGS) install
-
-install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
- $(ETCDIR)/chap-secrets
-
-$(ETCDIR)/options:
- $(INSTALL) -c -m 644 etc.ppp/options $@
-$(ETCDIR)/pap-secrets:
- $(INSTALL) -c -m 600 etc.ppp/pap-secrets $@
-$(ETCDIR)/chap-secrets:
- $(INSTALL) -c -m 600 etc.ppp/chap-secrets $@
-
-$(BINDIR):
- $(INSTALL) -d -m 755 $@
-$(MANDIR)/man8:
- $(INSTALL) -d -m 755 $@
-$(ETCDIR):
- $(INSTALL) -d -m 755 $@
-
-clean:
- rm -f `find . -name '*.[oas]' -print`
- rm -f `find . -name 'core' -print`
- rm -f `find . -name '*~' -print`
- cd chat; $(MAKE) clean
- cd pppd; $(MAKE) clean
- cd pppstats; $(MAKE) clean
- cd pppdump; $(MAKE) clean
-
-dist-clean: clean
- rm -f Makefile `find . -name Makefile -print`
-
-#kernel:
-# cd linux; ./kinstall.sh
diff --git a/mdk-stage1/ppp/modules/bsd-comp.c b/mdk-stage1/ppp/modules/bsd-comp.c
deleted file mode 100644
index b1b9325c7..000000000
--- a/mdk-stage1/ppp/modules/bsd-comp.c
+++ /dev/null
@@ -1,1116 +0,0 @@
-/* Because this code is derived from the 4.3BSD compress source:
- *
- *
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This version is for use with STREAMS under SunOS 4.x,
- * Digital UNIX, AIX 4.x, and SVR4 systems including Solaris 2.
- *
- * $Id$
- */
-
-#ifdef AIX4
-#include <net/net_globals.h>
-#endif
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stream.h>
-#include <net/ppp_defs.h>
-#include "ppp_mod.h"
-
-#ifdef SVR4
-#include <sys/byteorder.h>
-#ifndef _BIG_ENDIAN
-#define BSD_LITTLE_ENDIAN
-#endif
-#endif
-
-#ifdef __osf__
-#undef FIRST
-#undef LAST
-#define BSD_LITTLE_ENDIAN
-#endif
-
-#define PACKETPTR mblk_t *
-#include <net/ppp-comp.h>
-
-#if DO_BSD_COMPRESS
-
-/*
- * PPP "BSD compress" compression
- * The differences between this compression and the classic BSD LZW
- * source are obvious from the requirement that the classic code worked
- * with files while this handles arbitrarily long streams that
- * are broken into packets. They are:
- *
- * When the code size expands, a block of junk is not emitted by
- * the compressor and not expected by the decompressor.
- *
- * New codes are not necessarily assigned every time an old
- * code is output by the compressor. This is because a packet
- * end forces a code to be emitted, but does not imply that a
- * new sequence has been seen.
- *
- * The compression ratio is checked at the first end of a packet
- * after the appropriate gap. Besides simplifying and speeding
- * things up, this makes it more likely that the transmitter
- * and receiver will agree when the dictionary is cleared when
- * compression is not going well.
- */
-
-/*
- * A dictionary for doing BSD compress.
- */
-struct bsd_db {
- int totlen; /* length of this structure */
- u_int hsize; /* size of the hash table */
- u_char hshift; /* used in hash function */
- u_char n_bits; /* current bits/code */
- u_char maxbits;
- u_char debug;
- u_char unit;
- u_short seqno; /* sequence number of next packet */
- u_int hdrlen; /* header length to preallocate */
- u_int mru;
- u_int maxmaxcode; /* largest valid code */
- u_int max_ent; /* largest code in use */
- u_int in_count; /* uncompressed bytes, aged */
- u_int bytes_out; /* compressed bytes, aged */
- u_int ratio; /* recent compression ratio */
- u_int checkpoint; /* when to next check the ratio */
- u_int clear_count; /* times dictionary cleared */
- u_int incomp_count; /* incompressible packets */
- u_int incomp_bytes; /* incompressible bytes */
- u_int uncomp_count; /* uncompressed packets */
- u_int uncomp_bytes; /* uncompressed bytes */
- u_int comp_count; /* compressed packets */
- u_int comp_bytes; /* compressed bytes */
- u_short *lens; /* array of lengths of codes */
- struct bsd_dict {
- union { /* hash value */
- u_int32_t fcode;
- struct {
-#ifdef BSD_LITTLE_ENDIAN
- u_short prefix; /* preceding code */
- u_char suffix; /* last character of new code */
- u_char pad;
-#else
- u_char pad;
- u_char suffix; /* last character of new code */
- u_short prefix; /* preceding code */
-#endif
- } hs;
- } f;
- u_short codem1; /* output of hash table -1 */
- u_short cptr; /* map code to hash table entry */
- } dict[1];
-};
-
-#define BSD_OVHD 2 /* BSD compress overhead/packet */
-#define BSD_INIT_BITS BSD_MIN_BITS
-
-static void *bsd_comp_alloc __P((u_char *options, int opt_len));
-static void *bsd_decomp_alloc __P((u_char *options, int opt_len));
-static void bsd_free __P((void *state));
-static int bsd_comp_init __P((void *state, u_char *options, int opt_len,
- int unit, int hdrlen, int debug));
-static int bsd_decomp_init __P((void *state, u_char *options, int opt_len,
- int unit, int hdrlen, int mru, int debug));
-static int bsd_compress __P((void *state, mblk_t **mret,
- mblk_t *mp, int slen, int maxolen));
-static void bsd_incomp __P((void *state, mblk_t *dmsg));
-static int bsd_decompress __P((void *state, mblk_t *cmp, mblk_t **dmpp));
-static void bsd_reset __P((void *state));
-static void bsd_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to ppp_comp.c.
- */
-struct compressor ppp_bsd_compress = {
- CI_BSD_COMPRESS, /* compress_proto */
- bsd_comp_alloc, /* comp_alloc */
- bsd_free, /* comp_free */
- bsd_comp_init, /* comp_init */
- bsd_reset, /* comp_reset */
- bsd_compress, /* compress */
- bsd_comp_stats, /* comp_stat */
- bsd_decomp_alloc, /* decomp_alloc */
- bsd_free, /* decomp_free */
- bsd_decomp_init, /* decomp_init */
- bsd_reset, /* decomp_reset */
- bsd_decompress, /* decompress */
- bsd_incomp, /* incomp */
- bsd_comp_stats, /* decomp_stat */
-};
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define CLEAR 256 /* table clear output code */
-#define FIRST 257 /* first free entry */
-#define LAST 255
-
-#define MAXCODE(b) ((1 << (b)) - 1)
-#define BADCODEM1 MAXCODE(BSD_MAX_BITS)
-
-#define BSD_HASH(prefix,suffix,hshift) ((((u_int32_t)(suffix)) << (hshift)) \
- ^ (u_int32_t)(prefix))
-#define BSD_KEY(prefix,suffix) ((((u_int32_t)(suffix)) << 16) \
- + (u_int32_t)(prefix))
-
-#define CHECK_GAP 10000 /* Ratio check interval */
-
-#define RATIO_SCALE_LOG 8
-#define RATIO_SCALE (1<<RATIO_SCALE_LOG)
-#define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG)
-
-#define DECOMP_CHUNK 256
-
-/*
- * clear the dictionary
- */
-static void
-bsd_clear(db)
- struct bsd_db *db;
-{
- db->clear_count++;
- db->max_ent = FIRST-1;
- db->n_bits = BSD_INIT_BITS;
- db->ratio = 0;
- db->bytes_out = 0;
- db->in_count = 0;
- db->checkpoint = CHECK_GAP;
-}
-
-/*
- * If the dictionary is full, then see if it is time to reset it.
- *
- * Compute the compression ratio using fixed-point arithmetic
- * with 8 fractional bits.
- *
- * Since we have an infinite stream instead of a single file,
- * watch only the local compression ratio.
- *
- * Since both peers must reset the dictionary at the same time even in
- * the absence of CLEAR codes (while packets are incompressible), they
- * must compute the same ratio.
- */
-static int /* 1=output CLEAR */
-bsd_check(db)
- struct bsd_db *db;
-{
- u_int new_ratio;
-
- if (db->in_count >= db->checkpoint) {
- /* age the ratio by limiting the size of the counts */
- if (db->in_count >= RATIO_MAX
- || db->bytes_out >= RATIO_MAX) {
- db->in_count -= db->in_count/4;
- db->bytes_out -= db->bytes_out/4;
- }
-
- db->checkpoint = db->in_count + CHECK_GAP;
-
- if (db->max_ent >= db->maxmaxcode) {
- /* Reset the dictionary only if the ratio is worse,
- * or if it looks as if it has been poisoned
- * by incompressible data.
- *
- * This does not overflow, because
- * db->in_count <= RATIO_MAX.
- */
- new_ratio = db->in_count << RATIO_SCALE_LOG;
- if (db->bytes_out != 0)
- new_ratio /= db->bytes_out;
-
- if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) {
- bsd_clear(db);
- return 1;
- }
- db->ratio = new_ratio;
- }
- }
- return 0;
-}
-
-/*
- * Return statistics.
- */
-static void
-bsd_comp_stats(state, stats)
- void *state;
- struct compstat *stats;
-{
- struct bsd_db *db = (struct bsd_db *) state;
- u_int out;
-
- stats->unc_bytes = db->uncomp_bytes;
- stats->unc_packets = db->uncomp_count;
- stats->comp_bytes = db->comp_bytes;
- stats->comp_packets = db->comp_count;
- stats->inc_bytes = db->incomp_bytes;
- stats->inc_packets = db->incomp_count;
- stats->ratio = db->in_count;
- out = db->bytes_out;
- if (stats->ratio <= 0x7fffff)
- stats->ratio <<= 8;
- else
- out >>= 8;
- if (out != 0)
- stats->ratio /= out;
-}
-
-/*
- * Reset state, as on a CCP ResetReq.
- */
-static void
-bsd_reset(state)
- void *state;
-{
- struct bsd_db *db = (struct bsd_db *) state;
-
- db->seqno = 0;
- bsd_clear(db);
- db->clear_count = 0;
-}
-
-/*
- * Allocate space for a (de) compressor.
- */
-static void *
-bsd_alloc(options, opt_len, decomp)
- u_char *options;
- int opt_len, decomp;
-{
- int bits;
- u_int newlen, hsize, hshift, maxmaxcode;
- struct bsd_db *db;
-
- if (opt_len != 3 || options[0] != CI_BSD_COMPRESS || options[1] != 3
- || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
- return NULL;
-
- bits = BSD_NBITS(options[2]);
- switch (bits) {
- case 9: /* needs 82152 for both directions */
- case 10: /* needs 84144 */
- case 11: /* needs 88240 */
- case 12: /* needs 96432 */
- hsize = 5003;
- hshift = 4;
- break;
- case 13: /* needs 176784 */
- hsize = 9001;
- hshift = 5;
- break;
- case 14: /* needs 353744 */
- hsize = 18013;
- hshift = 6;
- break;
- case 15: /* needs 691440 */
- hsize = 35023;
- hshift = 7;
- break;
- case 16: /* needs 1366160--far too much, */
- /* hsize = 69001; */ /* and 69001 is too big for cptr */
- /* hshift = 8; */ /* in struct bsd_db */
- /* break; */
- default:
- return NULL;
- }
-
- maxmaxcode = MAXCODE(bits);
- newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
-#ifdef __osf__
- db = (struct bsd_db *) ALLOC_SLEEP(newlen);
-#else
- db = (struct bsd_db *) ALLOC_NOSLEEP(newlen);
-#endif
- if (!db)
- return NULL;
- bzero(db, sizeof(*db) - sizeof(db->dict));
-
- if (!decomp) {
- db->lens = NULL;
- } else {
-#ifdef __osf__
- db->lens = (u_short *) ALLOC_SLEEP((maxmaxcode+1) * sizeof(db->lens[0]));
-#else
- db->lens = (u_short *) ALLOC_NOSLEEP((maxmaxcode+1) * sizeof(db->lens[0]));
-#endif
- if (!db->lens) {
- FREE(db, newlen);
- return NULL;
- }
- }
-
- db->totlen = newlen;
- db->hsize = hsize;
- db->hshift = hshift;
- db->maxmaxcode = maxmaxcode;
- db->maxbits = bits;
-
- return (void *) db;
-}
-
-static void
-bsd_free(state)
- void *state;
-{
- struct bsd_db *db = (struct bsd_db *) state;
-
- if (db->lens)
- FREE(db->lens, (db->maxmaxcode+1) * sizeof(db->lens[0]));
- FREE(db, db->totlen);
-}
-
-static void *
-bsd_comp_alloc(options, opt_len)
- u_char *options;
- int opt_len;
-{
- return bsd_alloc(options, opt_len, 0);
-}
-
-static void *
-bsd_decomp_alloc(options, opt_len)
- u_char *options;
- int opt_len;
-{
- return bsd_alloc(options, opt_len, 1);
-}
-
-/*
- * Initialize the database.
- */
-static int
-bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
- struct bsd_db *db;
- u_char *options;
- int opt_len, unit, hdrlen, mru, debug, decomp;
-{
- int i;
-
- if (opt_len < CILEN_BSD_COMPRESS
- || options[0] != CI_BSD_COMPRESS || options[1] != CILEN_BSD_COMPRESS
- || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION
- || BSD_NBITS(options[2]) != db->maxbits
- || decomp && db->lens == NULL)
- return 0;
-
- if (decomp) {
- i = LAST+1;
- while (i != 0)
- db->lens[--i] = 1;
- }
- i = db->hsize;
- while (i != 0) {
- db->dict[--i].codem1 = BADCODEM1;
- db->dict[i].cptr = 0;
- }
-
- db->unit = unit;
- db->hdrlen = hdrlen;
- db->mru = mru;
- if (debug)
- db->debug = 1;
-
- bsd_reset(db);
-
- return 1;
-}
-
-static int
-bsd_comp_init(state, options, opt_len, unit, hdrlen, debug)
- void *state;
- u_char *options;
- int opt_len, unit, hdrlen, debug;
-{
- return bsd_init((struct bsd_db *) state, options, opt_len,
- unit, hdrlen, 0, debug, 0);
-}
-
-static int
-bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
- void *state;
- u_char *options;
- int opt_len, unit, hdrlen, mru, debug;
-{
- return bsd_init((struct bsd_db *) state, options, opt_len,
- unit, hdrlen, mru, debug, 1);
-}
-
-
-/*
- * compress a packet
- * One change from the BSD compress command is that when the
- * code size expands, we do not output a bunch of padding.
- *
- * N.B. at present, we ignore the hdrlen specified in the comp_init call.
- */
-static int /* new slen */
-bsd_compress(state, mretp, mp, slen, maxolen)
- void *state;
- mblk_t **mretp; /* return compressed mbuf chain here */
- mblk_t *mp; /* from here */
- int slen; /* uncompressed length */
- int maxolen; /* max compressed length */
-{
- struct bsd_db *db = (struct bsd_db *) state;
- int hshift = db->hshift;
- u_int max_ent = db->max_ent;
- u_int n_bits = db->n_bits;
- u_int bitno = 32;
- u_int32_t accm = 0, fcode;
- struct bsd_dict *dictp;
- u_char c;
- int hval, disp, ent, ilen;
- mblk_t *np, *mret;
- u_char *rptr, *wptr;
- u_char *cp_end;
- int olen;
- mblk_t *m, **mnp;
-
-#define PUTBYTE(v) { \
- if (wptr) { \
- *wptr++ = (v); \
- if (wptr >= cp_end) { \
- m->b_wptr = wptr; \
- m = m->b_cont; \
- if (m) { \
- wptr = m->b_wptr; \
- cp_end = m->b_datap->db_lim; \
- } else \
- wptr = NULL; \
- } \
- } \
- ++olen; \
-}
-
-#define OUTPUT(ent) { \
- bitno -= n_bits; \
- accm |= ((ent) << bitno); \
- do { \
- PUTBYTE(accm >> 24); \
- accm <<= 8; \
- bitno += 8; \
- } while (bitno <= 24); \
-}
-
- /*
- * First get the protocol and check that we're
- * interested in this packet.
- */
- *mretp = NULL;
- rptr = mp->b_rptr;
- if (rptr + PPP_HDRLEN > mp->b_wptr) {
- if (!pullupmsg(mp, PPP_HDRLEN))
- return 0;
- rptr = mp->b_rptr;
- }
- ent = PPP_PROTOCOL(rptr); /* get the protocol */
- if (ent < 0x21 || ent > 0xf9)
- return 0;
-
- /* Don't generate compressed packets which are larger than
- the uncompressed packet. */
- if (maxolen > slen)
- maxolen = slen;
-
- /* Allocate enough message blocks to give maxolen total space. */
- mnp = &mret;
- for (olen = maxolen; olen > 0; ) {
- m = allocb((olen < 4096? olen: 4096), BPRI_MED);
- *mnp = m;
- if (m == NULL) {
- if (mret != NULL) {
- freemsg(mret);
- mnp = &mret;
- }
- break;
- }
- mnp = &m->b_cont;
- olen -= m->b_datap->db_lim - m->b_wptr;
- }
- *mnp = NULL;
-
- if ((m = mret) != NULL) {
- wptr = m->b_wptr;
- cp_end = m->b_datap->db_lim;
- } else
- wptr = cp_end = NULL;
- olen = 0;
-
- /*
- * Copy the PPP header over, changing the protocol,
- * and install the 2-byte sequence number.
- */
- if (wptr) {
- wptr[0] = PPP_ADDRESS(rptr);
- wptr[1] = PPP_CONTROL(rptr);
- wptr[2] = 0; /* change the protocol */
- wptr[3] = PPP_COMP;
- wptr[4] = db->seqno >> 8;
- wptr[5] = db->seqno;
- wptr += PPP_HDRLEN + BSD_OVHD;
- }
- ++db->seqno;
- rptr += PPP_HDRLEN;
-
- slen = mp->b_wptr - rptr;
- ilen = slen + 1;
- np = mp->b_cont;
- for (;;) {
- if (slen <= 0) {
- if (!np)
- break;
- rptr = np->b_rptr;
- slen = np->b_wptr - rptr;
- np = np->b_cont;
- if (!slen)
- continue; /* handle 0-length buffers */
- ilen += slen;
- }
-
- slen--;
- c = *rptr++;
- fcode = BSD_KEY(ent, c);
- hval = BSD_HASH(ent, c, hshift);
- dictp = &db->dict[hval];
-
- /* Validate and then check the entry. */
- if (dictp->codem1 >= max_ent)
- goto nomatch;
- if (dictp->f.fcode == fcode) {
- ent = dictp->codem1+1;
- continue; /* found (prefix,suffix) */
- }
-
- /* continue probing until a match or invalid entry */
- disp = (hval == 0) ? 1 : hval;
- do {
- hval += disp;
- if (hval >= db->hsize)
- hval -= db->hsize;
- dictp = &db->dict[hval];
- if (dictp->codem1 >= max_ent)
- goto nomatch;
- } while (dictp->f.fcode != fcode);
- ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */
- continue;
-
- nomatch:
- OUTPUT(ent); /* output the prefix */
-
- /* code -> hashtable */
- if (max_ent < db->maxmaxcode) {
- struct bsd_dict *dictp2;
- /* expand code size if needed */
- if (max_ent >= MAXCODE(n_bits))
- db->n_bits = ++n_bits;
-
- /* Invalidate old hash table entry using
- * this code, and then take it over.
- */
- dictp2 = &db->dict[max_ent+1];
- if (db->dict[dictp2->cptr].codem1 == max_ent)
- db->dict[dictp2->cptr].codem1 = BADCODEM1;
- dictp2->cptr = hval;
- dictp->codem1 = max_ent;
- dictp->f.fcode = fcode;
-
- db->max_ent = ++max_ent;
- }
- ent = c;
- }
-
- OUTPUT(ent); /* output the last code */
- db->bytes_out += olen;
- db->in_count += ilen;
- if (bitno < 32)
- ++db->bytes_out; /* count complete bytes */
-
- if (bsd_check(db))
- OUTPUT(CLEAR); /* do not count the CLEAR */
-
- /*
- * Pad dribble bits of last code with ones.
- * Do not emit a completely useless byte of ones.
- */
- if (bitno != 32)
- PUTBYTE((accm | (0xff << (bitno-8))) >> 24);
-
- /*
- * Increase code size if we would have without the packet
- * boundary and as the decompressor will.
- */
- if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
- db->n_bits++;
-
- db->uncomp_bytes += ilen;
- ++db->uncomp_count;
- if (olen + PPP_HDRLEN + BSD_OVHD > maxolen && mret != NULL) {
- /* throw away the compressed stuff if it is longer than uncompressed */
- freemsg(mret);
- mret = NULL;
- ++db->incomp_count;
- db->incomp_bytes += ilen;
- } else if (wptr != NULL) {
- m->b_wptr = wptr;
- if (m->b_cont) {
- freemsg(m->b_cont);
- m->b_cont = NULL;
- }
- ++db->comp_count;
- db->comp_bytes += olen + BSD_OVHD;
- }
-
- *mretp = mret;
- return olen + PPP_HDRLEN + BSD_OVHD;
-#undef OUTPUT
-#undef PUTBYTE
-}
-
-
-/*
- * Update the "BSD Compress" dictionary on the receiver for
- * incompressible data by pretending to compress the incoming data.
- */
-static void
-bsd_incomp(state, dmsg)
- void *state;
- mblk_t *dmsg;
-{
- struct bsd_db *db = (struct bsd_db *) state;
- u_int hshift = db->hshift;
- u_int max_ent = db->max_ent;
- u_int n_bits = db->n_bits;
- struct bsd_dict *dictp;
- u_int32_t fcode;
- u_char c;
- long hval, disp;
- int slen, ilen;
- u_int bitno = 7;
- u_char *rptr;
- u_int ent;
-
- rptr = dmsg->b_rptr;
- if (rptr + PPP_HDRLEN > dmsg->b_wptr) {
- if (!pullupmsg(dmsg, PPP_HDRLEN))
- return;
- rptr = dmsg->b_rptr;
- }
- ent = PPP_PROTOCOL(rptr); /* get the protocol */
- if (ent < 0x21 || ent > 0xf9)
- return;
-
- db->seqno++;
- ilen = 1; /* count the protocol as 1 byte */
- rptr += PPP_HDRLEN;
- for (;;) {
- slen = dmsg->b_wptr - rptr;
- if (slen <= 0) {
- dmsg = dmsg->b_cont;
- if (!dmsg)
- break;
- rptr = dmsg->b_rptr;
- continue; /* skip zero-length buffers */
- }
- ilen += slen;
-
- do {
- c = *rptr++;
- fcode = BSD_KEY(ent, c);
- hval = BSD_HASH(ent, c, hshift);
- dictp = &db->dict[hval];
-
- /* validate and then check the entry */
- if (dictp->codem1 >= max_ent)
- goto nomatch;
- if (dictp->f.fcode == fcode) {
- ent = dictp->codem1+1;
- continue; /* found (prefix,suffix) */
- }
-
- /* continue probing until a match or invalid entry */
- disp = (hval == 0) ? 1 : hval;
- do {
- hval += disp;
- if (hval >= db->hsize)
- hval -= db->hsize;
- dictp = &db->dict[hval];
- if (dictp->codem1 >= max_ent)
- goto nomatch;
- } while (dictp->f.fcode != fcode);
- ent = dictp->codem1+1;
- continue; /* finally found (prefix,suffix) */
-
- nomatch: /* output (count) the prefix */
- bitno += n_bits;
-
- /* code -> hashtable */
- if (max_ent < db->maxmaxcode) {
- struct bsd_dict *dictp2;
- /* expand code size if needed */
- if (max_ent >= MAXCODE(n_bits))
- db->n_bits = ++n_bits;
-
- /* Invalidate previous hash table entry
- * assigned this code, and then take it over.
- */
- dictp2 = &db->dict[max_ent+1];
- if (db->dict[dictp2->cptr].codem1 == max_ent)
- db->dict[dictp2->cptr].codem1 = BADCODEM1;
- dictp2->cptr = hval;
- dictp->codem1 = max_ent;
- dictp->f.fcode = fcode;
-
- db->max_ent = ++max_ent;
- db->lens[max_ent] = db->lens[ent]+1;
- }
- ent = c;
- } while (--slen != 0);
- }
- bitno += n_bits; /* output (count) the last code */
- db->bytes_out += bitno/8;
- db->in_count += ilen;
- (void)bsd_check(db);
-
- ++db->incomp_count;
- db->incomp_bytes += ilen;
- ++db->uncomp_count;
- db->uncomp_bytes += ilen;
-
- /* Increase code size if we would have without the packet
- * boundary and as the decompressor will.
- */
- if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
- db->n_bits++;
-}
-
-
-/*
- * Decompress "BSD Compress"
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression. For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-static int
-bsd_decompress(state, cmsg, dmpp)
- void *state;
- mblk_t *cmsg, **dmpp;
-{
- struct bsd_db *db = (struct bsd_db *) state;
- u_int max_ent = db->max_ent;
- u_int32_t accm = 0;
- u_int bitno = 32; /* 1st valid bit in accm */
- u_int n_bits = db->n_bits;
- u_int tgtbitno = 32-n_bits; /* bitno when we have a code */
- struct bsd_dict *dictp;
- int explen, i, seq, len;
- u_int incode, oldcode, finchar;
- u_char *p, *rptr, *wptr;
- mblk_t *dmsg, *mret;
- int adrs, ctrl, ilen;
- int dlen, space, codelen, extra;
-
- /*
- * Get at least the BSD Compress header in the first buffer
- */
- rptr = cmsg->b_rptr;
- if (rptr + PPP_HDRLEN + BSD_OVHD >= cmsg->b_wptr) {
- if (!pullupmsg(cmsg, PPP_HDRLEN + BSD_OVHD + 1)) {
- if (db->debug)
- printf("bsd_decomp%d: failed to pullup\n", db->unit);
- return DECOMP_ERROR;
- }
- rptr = cmsg->b_rptr;
- }
-
- /*
- * Save the address/control from the PPP header
- * and then get the sequence number.
- */
- adrs = PPP_ADDRESS(rptr);
- ctrl = PPP_CONTROL(rptr);
- rptr += PPP_HDRLEN;
- seq = (rptr[0] << 8) + rptr[1];
- rptr += BSD_OVHD;
- ilen = len = cmsg->b_wptr - rptr;
-
- /*
- * Check the sequence number and give up if it is not what we expect.
- */
- if (seq != db->seqno++) {
- if (db->debug)
- printf("bsd_decomp%d: bad sequence # %d, expected %d\n",
- db->unit, seq, db->seqno - 1);
- return DECOMP_ERROR;
- }
-
- /*
- * Allocate one message block to start with.
- */
- if ((dmsg = allocb(DECOMP_CHUNK + db->hdrlen, BPRI_MED)) == NULL)
- return DECOMP_ERROR;
- mret = dmsg;
- dmsg->b_wptr += db->hdrlen;
- dmsg->b_rptr = wptr = dmsg->b_wptr;
-
- /* Fill in the ppp header, but not the last byte of the protocol
- (that comes from the decompressed data). */
- wptr[0] = adrs;
- wptr[1] = ctrl;
- wptr[2] = 0;
- wptr += PPP_HDRLEN - 1;
- space = dmsg->b_datap->db_lim - wptr;
-
- oldcode = CLEAR;
- explen = 0;
- for (;;) {
- if (len == 0) {
- cmsg = cmsg->b_cont;
- if (!cmsg) /* quit at end of message */
- break;
- rptr = cmsg->b_rptr;
- len = cmsg->b_wptr - rptr;
- ilen += len;
- continue; /* handle 0-length buffers */
- }
-
- /*
- * Accumulate bytes until we have a complete code.
- * Then get the next code, relying on the 32-bit,
- * unsigned accm to mask the result.
- */
- bitno -= 8;
- accm |= *rptr++ << bitno;
- --len;
- if (tgtbitno < bitno)
- continue;
- incode = accm >> tgtbitno;
- accm <<= n_bits;
- bitno += n_bits;
-
- if (incode == CLEAR) {
- /*
- * The dictionary must only be cleared at
- * the end of a packet. But there could be an
- * empty message block at the end.
- */
- if (len > 0 || cmsg->b_cont != 0) {
- if (cmsg->b_cont)
- len += msgdsize(cmsg->b_cont);
- if (len > 0) {
- freemsg(dmsg);
- if (db->debug)
- printf("bsd_decomp%d: bad CLEAR\n", db->unit);
- return DECOMP_FATALERROR;
- }
- }
- bsd_clear(db);
- explen = ilen = 0;
- break;
- }
-
- if (incode > max_ent + 2 || incode > db->maxmaxcode
- || incode > max_ent && oldcode == CLEAR) {
- freemsg(dmsg);
- if (db->debug) {
- printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
- db->unit, incode, oldcode);
- printf("max_ent=0x%x dlen=%d seqno=%d\n",
- max_ent, dlen, db->seqno);
- }
- return DECOMP_FATALERROR; /* probably a bug */
- }
-
- /* Special case for KwKwK string. */
- if (incode > max_ent) {
- finchar = oldcode;
- extra = 1;
- } else {
- finchar = incode;
- extra = 0;
- }
-
- codelen = db->lens[finchar];
- explen += codelen + extra;
- if (explen > db->mru + 1) {
- freemsg(dmsg);
- if (db->debug)
- printf("bsd_decomp%d: ran out of mru\n", db->unit);
- return DECOMP_FATALERROR;
- }
-
- /*
- * Decode this code and install it in the decompressed buffer.
- */
- space -= codelen + extra;
- if (space < 0) {
- /* Allocate another message block. */
- dmsg->b_wptr = wptr;
- dlen = codelen + extra;
- if (dlen < DECOMP_CHUNK)
- dlen = DECOMP_CHUNK;
- if ((dmsg->b_cont = allocb(dlen, BPRI_MED)) == NULL) {
- freemsg(dmsg);
- return DECOMP_ERROR;
- }
- dmsg = dmsg->b_cont;
- wptr = dmsg->b_wptr;
- space = dmsg->b_datap->db_lim - wptr - codelen - extra;
- }
- p = (wptr += codelen);
- while (finchar > LAST) {
- dictp = &db->dict[db->dict[finchar].cptr];
-#ifdef DEBUG
- --codelen;
- if (codelen <= 0) {
- freemsg(dmsg);
- printf("bsd_decomp%d: fell off end of chain ", db->unit);
- printf("0x%x at 0x%x by 0x%x, max_ent=0x%x\n",
- incode, finchar, db->dict[finchar].cptr, max_ent);
- return DECOMP_FATALERROR;
- }
- if (dictp->codem1 != finchar-1) {
- freemsg(dmsg);
- printf("bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",
- db->unit, incode, finchar);
- printf("oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode,
- db->dict[finchar].cptr, dictp->codem1);
- return DECOMP_FATALERROR;
- }
-#endif
- *--p = dictp->f.hs.suffix;
- finchar = dictp->f.hs.prefix;
- }
- *--p = finchar;
-
-#ifdef DEBUG
- if (--codelen != 0)
- printf("bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n",
- db->unit, codelen, incode, max_ent);
-#endif
-
- if (extra) /* the KwKwK case again */
- *wptr++ = finchar;
-
- /*
- * If not first code in a packet, and
- * if not out of code space, then allocate a new code.
- *
- * Keep the hash table correct so it can be used
- * with uncompressed packets.
- */
- if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
- struct bsd_dict *dictp2;
- u_int32_t fcode;
- int hval, disp;
-
- fcode = BSD_KEY(oldcode,finchar);
- hval = BSD_HASH(oldcode,finchar,db->hshift);
- dictp = &db->dict[hval];
-
- /* look for a free hash table entry */
- if (dictp->codem1 < max_ent) {
- disp = (hval == 0) ? 1 : hval;
- do {
- hval += disp;
- if (hval >= db->hsize)
- hval -= db->hsize;
- dictp = &db->dict[hval];
- } while (dictp->codem1 < max_ent);
- }
-
- /*
- * Invalidate previous hash table entry
- * assigned this code, and then take it over
- */
- dictp2 = &db->dict[max_ent+1];
- if (db->dict[dictp2->cptr].codem1 == max_ent) {
- db->dict[dictp2->cptr].codem1 = BADCODEM1;
- }
- dictp2->cptr = hval;
- dictp->codem1 = max_ent;
- dictp->f.fcode = fcode;
-
- db->max_ent = ++max_ent;
- db->lens[max_ent] = db->lens[oldcode]+1;
-
- /* Expand code size if needed. */
- if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
- db->n_bits = ++n_bits;
- tgtbitno = 32-n_bits;
- }
- }
- oldcode = incode;
- }
- dmsg->b_wptr = wptr;
-
- /*
- * Keep the checkpoint right so that incompressible packets
- * clear the dictionary at the right times.
- */
- db->bytes_out += ilen;
- db->in_count += explen;
- if (bsd_check(db) && db->debug) {
- printf("bsd_decomp%d: peer should have cleared dictionary\n",
- db->unit);
- }
-
- ++db->comp_count;
- db->comp_bytes += ilen + BSD_OVHD;
- ++db->uncomp_count;
- db->uncomp_bytes += explen;
-
- *dmpp = mret;
- return DECOMP_OK;
-}
-#endif /* DO_BSD_COMPRESS */
diff --git a/mdk-stage1/ppp/modules/deflate.c b/mdk-stage1/ppp/modules/deflate.c
deleted file mode 100644
index 1b9054412..000000000
--- a/mdk-stage1/ppp/modules/deflate.c
+++ /dev/null
@@ -1,760 +0,0 @@
-/*
- * ppp_deflate.c - interface the zlib procedures for Deflate compression
- * and decompression (as used by gzip) to the PPP code.
- * This version is for use with STREAMS under SunOS 4.x, Solaris 2,
- * SVR4, OSF/1 and AIX 4.x.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-#ifdef AIX4
-#include <net/net_globals.h>
-#endif
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stream.h>
-#include <net/ppp_defs.h>
-#include "ppp_mod.h"
-
-#define PACKETPTR mblk_t *
-#include <net/ppp-comp.h>
-
-#ifdef __osf__
-#include "zlib.h"
-#else
-#include "../common/zlib.h"
-#endif
-
-#if DO_DEFLATE
-
-#define DEFLATE_DEBUG 1
-
-/*
- * State for a Deflate (de)compressor.
- */
-struct deflate_state {
- int seqno;
- int w_size;
- int unit;
- int hdrlen;
- int mru;
- int debug;
- z_stream strm;
- struct compstat stats;
-};
-
-#define DEFLATE_OVHD 2 /* Deflate overhead/packet */
-
-static void *z_alloc __P((void *, u_int items, u_int size));
-static void *z_alloc_init __P((void *, u_int items, u_int size));
-static void z_free __P((void *, void *ptr));
-static void *z_comp_alloc __P((u_char *options, int opt_len));
-static void *z_decomp_alloc __P((u_char *options, int opt_len));
-static void z_comp_free __P((void *state));
-static void z_decomp_free __P((void *state));
-static int z_comp_init __P((void *state, u_char *options, int opt_len,
- int unit, int hdrlen, int debug));
-static int z_decomp_init __P((void *state, u_char *options, int opt_len,
- int unit, int hdrlen, int mru, int debug));
-static int z_compress __P((void *state, mblk_t **mret,
- mblk_t *mp, int slen, int maxolen));
-static void z_incomp __P((void *state, mblk_t *dmsg));
-static int z_decompress __P((void *state, mblk_t *cmp,
- mblk_t **dmpp));
-static void z_comp_reset __P((void *state));
-static void z_decomp_reset __P((void *state));
-static void z_comp_stats __P((void *state, struct compstat *stats));
-
-/*
- * Procedures exported to ppp_comp.c.
- */
-struct compressor ppp_deflate = {
- CI_DEFLATE, /* compress_proto */
- z_comp_alloc, /* comp_alloc */
- z_comp_free, /* comp_free */
- z_comp_init, /* comp_init */
- z_comp_reset, /* comp_reset */
- z_compress, /* compress */
- z_comp_stats, /* comp_stat */
- z_decomp_alloc, /* decomp_alloc */
- z_decomp_free, /* decomp_free */
- z_decomp_init, /* decomp_init */
- z_decomp_reset, /* decomp_reset */
- z_decompress, /* decompress */
- z_incomp, /* incomp */
- z_comp_stats, /* decomp_stat */
-};
-
-struct compressor ppp_deflate_draft = {
- CI_DEFLATE_DRAFT, /* compress_proto */
- z_comp_alloc, /* comp_alloc */
- z_comp_free, /* comp_free */
- z_comp_init, /* comp_init */
- z_comp_reset, /* comp_reset */
- z_compress, /* compress */
- z_comp_stats, /* comp_stat */
- z_decomp_alloc, /* decomp_alloc */
- z_decomp_free, /* decomp_free */
- z_decomp_init, /* decomp_init */
- z_decomp_reset, /* decomp_reset */
- z_decompress, /* decompress */
- z_incomp, /* incomp */
- z_comp_stats, /* decomp_stat */
-};
-
-#define DECOMP_CHUNK 512
-
-/*
- * Space allocation and freeing routines for use by zlib routines.
- */
-struct zchunk {
- u_int size;
- u_int guard;
-};
-
-#define GUARD_MAGIC 0x77a6011a
-
-static void *
-z_alloc_init(notused, items, size)
- void *notused;
- u_int items, size;
-{
- struct zchunk *z;
-
- size = items * size + sizeof(struct zchunk);
-#ifdef __osf__
- z = (struct zchunk *) ALLOC_SLEEP(size);
-#else
- z = (struct zchunk *) ALLOC_NOSLEEP(size);
-#endif
- z->size = size;
- z->guard = GUARD_MAGIC;
- return (void *) (z + 1);
-}
-
-static void *
-z_alloc(notused, items, size)
- void *notused;
- u_int items, size;
-{
- struct zchunk *z;
-
- size = items * size + sizeof(struct zchunk);
- z = (struct zchunk *) ALLOC_NOSLEEP(size);
- z->size = size;
- z->guard = GUARD_MAGIC;
- return (void *) (z + 1);
-}
-
-static void
-z_free(notused, ptr)
- void *notused;
- void *ptr;
-{
- struct zchunk *z = ((struct zchunk *) ptr) - 1;
-
- if (z->guard != GUARD_MAGIC) {
- printf("ppp: z_free of corrupted chunk at %x (%x, %x)\n",
- z, z->size, z->guard);
- return;
- }
- FREE(z, z->size);
-}
-
-/*
- * Allocate space for a compressor.
- */
-static void *
-z_comp_alloc(options, opt_len)
- u_char *options;
- int opt_len;
-{
- struct deflate_state *state;
- int w_size;
-
- if (opt_len != CILEN_DEFLATE
- || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return NULL;
- w_size = DEFLATE_SIZE(options[2]);
- /*
- * N.B. the 9 below should be DEFLATE_MIN_SIZE (8), but using
- * 8 will cause kernel crashes because of a bug in zlib.
- */
- if (w_size < 9 || w_size > DEFLATE_MAX_SIZE)
- return NULL;
-
-
-#ifdef __osf__
- state = (struct deflate_state *) ALLOC_SLEEP(sizeof(*state));
-#else
- state = (struct deflate_state *) ALLOC_NOSLEEP(sizeof(*state));
-#endif
-
- if (state == NULL)
- return NULL;
-
- state->strm.next_in = NULL;
- state->strm.zalloc = (alloc_func) z_alloc_init;
- state->strm.zfree = (free_func) z_free;
- if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
- -w_size, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
- FREE(state, sizeof(*state));
- return NULL;
- }
-
- state->strm.zalloc = (alloc_func) z_alloc;
- state->w_size = w_size;
- bzero(&state->stats, sizeof(state->stats));
- return (void *) state;
-}
-
-static void
-z_comp_free(arg)
- void *arg;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
-
- deflateEnd(&state->strm);
- FREE(state, sizeof(*state));
-}
-
-static int
-z_comp_init(arg, options, opt_len, unit, hdrlen, debug)
- void *arg;
- u_char *options;
- int opt_len, unit, hdrlen, debug;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
-
- if (opt_len < CILEN_DEFLATE
- || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || DEFLATE_SIZE(options[2]) != state->w_size
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return 0;
-
- state->seqno = 0;
- state->unit = unit;
- state->hdrlen = hdrlen;
- state->debug = debug;
-
- deflateReset(&state->strm);
-
- return 1;
-}
-
-static void
-z_comp_reset(arg)
- void *arg;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
-
- state->seqno = 0;
- deflateReset(&state->strm);
-}
-
-static int
-z_compress(arg, mret, mp, orig_len, maxolen)
- void *arg;
- mblk_t **mret; /* compressed packet (out) */
- mblk_t *mp; /* uncompressed packet (in) */
- int orig_len, maxolen;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
- u_char *rptr, *wptr;
- int proto, olen, wspace, r, flush;
- mblk_t *m;
-
- /*
- * Check that the protocol is in the range we handle.
- */
- *mret = NULL;
- rptr = mp->b_rptr;
- if (rptr + PPP_HDRLEN > mp->b_wptr) {
- if (!pullupmsg(mp, PPP_HDRLEN))
- return 0;
- rptr = mp->b_rptr;
- }
- proto = PPP_PROTOCOL(rptr);
- if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
- return orig_len;
-
- /* Allocate one mblk initially. */
- if (maxolen > orig_len)
- maxolen = orig_len;
- if (maxolen <= PPP_HDRLEN + 2) {
- wspace = 0;
- m = NULL;
- } else {
- wspace = maxolen + state->hdrlen;
- if (wspace > 4096)
- wspace = 4096;
- m = allocb(wspace, BPRI_MED);
- }
- if (m != NULL) {
- *mret = m;
- if (state->hdrlen + PPP_HDRLEN + 2 < wspace) {
- m->b_rptr += state->hdrlen;
- m->b_wptr = m->b_rptr;
- wspace -= state->hdrlen;
- }
- wptr = m->b_wptr;
-
- /*
- * Copy over the PPP header and store the 2-byte sequence number.
- */
- wptr[0] = PPP_ADDRESS(rptr);
- wptr[1] = PPP_CONTROL(rptr);
- wptr[2] = PPP_COMP >> 8;
- wptr[3] = PPP_COMP;
- wptr += PPP_HDRLEN;
- wptr[0] = state->seqno >> 8;
- wptr[1] = state->seqno;
- wptr += 2;
- state->strm.next_out = wptr;
- state->strm.avail_out = wspace - (PPP_HDRLEN + 2);
- } else {
- state->strm.next_out = NULL;
- state->strm.avail_out = 1000000;
- }
- ++state->seqno;
-
- rptr += (proto > 0xff)? 2: 3; /* skip 1st proto byte if 0 */
- state->strm.next_in = rptr;
- state->strm.avail_in = mp->b_wptr - rptr;
- mp = mp->b_cont;
- flush = (mp == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
- olen = 0;
- for (;;) {
- r = deflate(&state->strm, flush);
- if (r != Z_OK) {
- printf("z_compress: deflate returned %d (%s)\n",
- r, (state->strm.msg? state->strm.msg: ""));
- break;
- }
- if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
- break; /* all done */
- if (state->strm.avail_in == 0 && mp != NULL) {
- state->strm.next_in = mp->b_rptr;
- state->strm.avail_in = mp->b_wptr - mp->b_rptr;
- mp = mp->b_cont;
- if (mp == NULL)
- flush = Z_PACKET_FLUSH;
- }
- if (state->strm.avail_out == 0) {
- if (m != NULL) {
- m->b_wptr += wspace;
- olen += wspace;
- wspace = maxolen - olen;
- if (wspace <= 0) {
- wspace = 0;
- m->b_cont = NULL;
- } else {
- if (wspace < 32)
- wspace = 32;
- else if (wspace > 4096)
- wspace = 4096;
- m->b_cont = allocb(wspace, BPRI_MED);
- }
- m = m->b_cont;
- if (m != NULL) {
- state->strm.next_out = m->b_wptr;
- state->strm.avail_out = wspace;
- }
- }
- if (m == NULL) {
- state->strm.next_out = NULL;
- state->strm.avail_out = 1000000;
- }
- }
- }
- if (m != NULL) {
- m->b_wptr += wspace - state->strm.avail_out;
- olen += wspace - state->strm.avail_out;
- }
-
- /*
- * See if we managed to reduce the size of the packet.
- */
- if (olen < orig_len && m != NULL) {
- state->stats.comp_bytes += olen;
- state->stats.comp_packets++;
- } else {
- if (*mret != NULL) {
- freemsg(*mret);
- *mret = NULL;
- }
- state->stats.inc_bytes += orig_len;
- state->stats.inc_packets++;
- olen = orig_len;
- }
- state->stats.unc_bytes += orig_len;
- state->stats.unc_packets++;
-
- return olen;
-}
-
-static void
-z_comp_stats(arg, stats)
- void *arg;
- struct compstat *stats;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
- u_int out;
-
- *stats = state->stats;
- stats->ratio = stats->unc_bytes;
- out = stats->comp_bytes + stats->unc_bytes;
- if (stats->ratio <= 0x7ffffff)
- stats->ratio <<= 8;
- else
- out >>= 8;
- if (out != 0)
- stats->ratio /= out;
-}
-
-/*
- * Allocate space for a decompressor.
- */
-static void *
-z_decomp_alloc(options, opt_len)
- u_char *options;
- int opt_len;
-{
- struct deflate_state *state;
- int w_size;
-
- if (opt_len != CILEN_DEFLATE
- || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return NULL;
- w_size = DEFLATE_SIZE(options[2]);
- /*
- * N.B. the 9 below should be DEFLATE_MIN_SIZE (8), but using
- * 8 will cause kernel crashes because of a bug in zlib.
- */
- if (w_size < 9 || w_size > DEFLATE_MAX_SIZE)
- return NULL;
-
-#ifdef __osf__
- state = (struct deflate_state *) ALLOC_SLEEP(sizeof(*state));
-#else
- state = (struct deflate_state *) ALLOC_NOSLEEP(sizeof(*state));
-#endif
- if (state == NULL)
- return NULL;
-
- state->strm.next_out = NULL;
- state->strm.zalloc = (alloc_func) z_alloc_init;
- state->strm.zfree = (free_func) z_free;
- if (inflateInit2(&state->strm, -w_size) != Z_OK) {
- FREE(state, sizeof(*state));
- return NULL;
- }
-
- state->strm.zalloc = (alloc_func) z_alloc;
- state->w_size = w_size;
- bzero(&state->stats, sizeof(state->stats));
- return (void *) state;
-}
-
-static void
-z_decomp_free(arg)
- void *arg;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
-
- inflateEnd(&state->strm);
- FREE(state, sizeof(*state));
-}
-
-static int
-z_decomp_init(arg, options, opt_len, unit, hdrlen, mru, debug)
- void *arg;
- u_char *options;
- int opt_len, unit, hdrlen, mru, debug;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
-
- if (opt_len < CILEN_DEFLATE
- || (options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT)
- || options[1] != CILEN_DEFLATE
- || DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL
- || DEFLATE_SIZE(options[2]) != state->w_size
- || options[3] != DEFLATE_CHK_SEQUENCE)
- return 0;
-
- state->seqno = 0;
- state->unit = unit;
- state->hdrlen = hdrlen;
- state->debug = debug;
- state->mru = mru;
-
- inflateReset(&state->strm);
-
- return 1;
-}
-
-static void
-z_decomp_reset(arg)
- void *arg;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
-
- state->seqno = 0;
- inflateReset(&state->strm);
-}
-
-/*
- * Decompress a Deflate-compressed packet.
- *
- * Because of patent problems, we return DECOMP_ERROR for errors
- * found by inspecting the input data and for system problems, but
- * DECOMP_FATALERROR for any errors which could possibly be said to
- * be being detected "after" decompression. For DECOMP_ERROR,
- * we can issue a CCP reset-request; for DECOMP_FATALERROR, we may be
- * infringing a patent of Motorola's if we do, so we take CCP down
- * instead.
- *
- * Given that the frame has the correct sequence number and a good FCS,
- * errors such as invalid codes in the input most likely indicate a
- * bug, so we return DECOMP_FATALERROR for them in order to turn off
- * compression, even though they are detected by inspecting the input.
- */
-static int
-z_decompress(arg, mi, mop)
- void *arg;
- mblk_t *mi, **mop;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
- mblk_t *mo, *mo_head;
- u_char *rptr, *wptr;
- int rlen, olen, ospace;
- int seq, i, flush, r, decode_proto;
- u_char hdr[PPP_HDRLEN + DEFLATE_OVHD];
-
- *mop = NULL;
- rptr = mi->b_rptr;
- for (i = 0; i < PPP_HDRLEN + DEFLATE_OVHD; ++i) {
- while (rptr >= mi->b_wptr) {
- mi = mi->b_cont;
- if (mi == NULL)
- return DECOMP_ERROR;
- rptr = mi->b_rptr;
- }
- hdr[i] = *rptr++;
- }
-
- /* Check the sequence number. */
- seq = (hdr[PPP_HDRLEN] << 8) + hdr[PPP_HDRLEN+1];
- if (seq != state->seqno) {
-#if !DEFLATE_DEBUG
- if (state->debug)
-#endif
- printf("z_decompress%d: bad seq # %d, expected %d\n",
- state->unit, seq, state->seqno);
- return DECOMP_ERROR;
- }
- ++state->seqno;
-
- /* Allocate an output message block. */
- mo = allocb(DECOMP_CHUNK + state->hdrlen, BPRI_MED);
- if (mo == NULL)
- return DECOMP_ERROR;
- mo_head = mo;
- mo->b_cont = NULL;
- mo->b_rptr += state->hdrlen;
- mo->b_wptr = wptr = mo->b_rptr;
- ospace = DECOMP_CHUNK;
- olen = 0;
-
- /*
- * Fill in the first part of the PPP header. The protocol field
- * comes from the decompressed data.
- */
- wptr[0] = PPP_ADDRESS(hdr);
- wptr[1] = PPP_CONTROL(hdr);
- wptr[2] = 0;
-
- /*
- * Set up to call inflate. We set avail_out to 1 initially so we can
- * look at the first byte of the output and decide whether we have
- * a 1-byte or 2-byte protocol field.
- */
- state->strm.next_in = rptr;
- state->strm.avail_in = mi->b_wptr - rptr;
- mi = mi->b_cont;
- flush = (mi == NULL)? Z_PACKET_FLUSH: Z_NO_FLUSH;
- rlen = state->strm.avail_in + PPP_HDRLEN + DEFLATE_OVHD;
- state->strm.next_out = wptr + 3;
- state->strm.avail_out = 1;
- decode_proto = 1;
-
- /*
- * Call inflate, supplying more input or output as needed.
- */
- for (;;) {
- r = inflate(&state->strm, flush);
- if (r != Z_OK) {
-#if !DEFLATE_DEBUG
- if (state->debug)
-#endif
- printf("z_decompress%d: inflate returned %d (%s)\n",
- state->unit, r, (state->strm.msg? state->strm.msg: ""));
- freemsg(mo_head);
- return DECOMP_FATALERROR;
- }
- if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
- break; /* all done */
- if (state->strm.avail_in == 0 && mi != NULL) {
- state->strm.next_in = mi->b_rptr;
- state->strm.avail_in = mi->b_wptr - mi->b_rptr;
- rlen += state->strm.avail_in;
- mi = mi->b_cont;
- if (mi == NULL)
- flush = Z_PACKET_FLUSH;
- }
- if (state->strm.avail_out == 0) {
- if (decode_proto) {
- state->strm.avail_out = ospace - PPP_HDRLEN;
- if ((wptr[3] & 1) == 0) {
- /* 2-byte protocol field */
- wptr[2] = wptr[3];
- --state->strm.next_out;
- ++state->strm.avail_out;
- }
- decode_proto = 0;
- } else {
- mo->b_wptr += ospace;
- olen += ospace;
- mo->b_cont = allocb(DECOMP_CHUNK, BPRI_MED);
- mo = mo->b_cont;
- if (mo == NULL) {
- freemsg(mo_head);
- return DECOMP_ERROR;
- }
- state->strm.next_out = mo->b_rptr;
- state->strm.avail_out = ospace = DECOMP_CHUNK;
- }
- }
- }
- if (decode_proto) {
- freemsg(mo_head);
- return DECOMP_ERROR;
- }
- mo->b_wptr += ospace - state->strm.avail_out;
- olen += ospace - state->strm.avail_out;
-
-#if DEFLATE_DEBUG
- if (olen > state->mru + PPP_HDRLEN)
- printf("ppp_deflate%d: exceeded mru (%d > %d)\n",
- state->unit, olen, state->mru + PPP_HDRLEN);
-#endif
-
- state->stats.unc_bytes += olen;
- state->stats.unc_packets++;
- state->stats.comp_bytes += rlen;
- state->stats.comp_packets++;
-
- *mop = mo_head;
- return DECOMP_OK;
-}
-
-/*
- * Incompressible data has arrived - add it to the history.
- */
-static void
-z_incomp(arg, mi)
- void *arg;
- mblk_t *mi;
-{
- struct deflate_state *state = (struct deflate_state *) arg;
- u_char *rptr;
- int rlen, proto, r;
-
- /*
- * Check that the protocol is one we handle.
- */
- rptr = mi->b_rptr;
- if (rptr + PPP_HDRLEN > mi->b_wptr) {
- if (!pullupmsg(mi, PPP_HDRLEN))
- return;
- rptr = mi->b_rptr;
- }
- proto = PPP_PROTOCOL(rptr);
- if (proto > 0x3fff || proto == 0xfd || proto == 0xfb)
- return;
-
- ++state->seqno;
-
- /*
- * Iterate through the message blocks, adding the characters in them
- * to the decompressor's history. For the first block, we start
- * at the either the 1st or 2nd byte of the protocol field,
- * depending on whether the protocol value is compressible.
- */
- rlen = mi->b_wptr - mi->b_rptr;
- state->strm.next_in = rptr + 3;
- state->strm.avail_in = rlen - 3;
- if (proto > 0xff) {
- --state->strm.next_in;
- ++state->strm.avail_in;
- }
- for (;;) {
- r = inflateIncomp(&state->strm);
- if (r != Z_OK) {
- /* gak! */
-#if !DEFLATE_DEBUG
- if (state->debug)
-#endif
- printf("z_incomp%d: inflateIncomp returned %d (%s)\n",
- state->unit, r, (state->strm.msg? state->strm.msg: ""));
- return;
- }
- mi = mi->b_cont;
- if (mi == NULL)
- break;
- state->strm.next_in = mi->b_rptr;
- state->strm.avail_in = mi->b_wptr - mi->b_rptr;
- rlen += state->strm.avail_in;
- }
-
- /*
- * Update stats.
- */
- state->stats.inc_bytes += rlen;
- state->stats.inc_packets++;
- state->stats.unc_bytes += rlen;
- state->stats.unc_packets++;
-}
-
-#endif /* DO_DEFLATE */
diff --git a/mdk-stage1/ppp/modules/if_ppp.c b/mdk-stage1/ppp/modules/if_ppp.c
deleted file mode 100644
index 14e89eb4a..000000000
--- a/mdk-stage1/ppp/modules/if_ppp.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*
- * if_ppp.c - a network interface connected to a STREAMS module.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-/*
- * This file is used under SunOS 4 and Digital UNIX.
- *
- * This file provides the glue between PPP and IP.
- */
-
-#define INET 1
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/netisr.h>
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-#ifdef __osf__
-#include <sys/ioctl.h>
-#include <net/if_types.h>
-#else
-#include <sys/sockio.h>
-#endif
-#include "ppp_mod.h"
-
-#include <sys/stream.h>
-
-#ifdef SNIT_SUPPORT
-#include <sys/time.h>
-#include <net/nit_if.h>
-#include <netinet/if_ether.h>
-#endif
-
-#ifdef __osf__
-#define SIOCSIFMTU SIOCSIPMTU
-#define SIOCGIFMTU SIOCRIPMTU
-#define IFA_ADDR(ifa) (*(ifa)->ifa_addr)
-#else
-#define IFA_ADDR(ifa) ((ifa)->ifa_addr)
-#endif
-
-#define ifr_mtu ifr_metric
-
-static int if_ppp_open __P((queue_t *, int, int, int));
-static int if_ppp_close __P((queue_t *, int));
-static int if_ppp_wput __P((queue_t *, mblk_t *));
-static int if_ppp_rput __P((queue_t *, mblk_t *));
-
-#define PPP_IF_ID 0x8021
-static struct module_info minfo = {
- PPP_IF_ID, "if_ppp", 0, INFPSZ, 4096, 128
-};
-
-static struct qinit rinit = {
- if_ppp_rput, NULL, if_ppp_open, if_ppp_close, NULL, &minfo, NULL
-};
-
-static struct qinit winit = {
- if_ppp_wput, NULL, NULL, NULL, NULL, &minfo, NULL
-};
-
-struct streamtab if_pppinfo = {
- &rinit, &winit, NULL, NULL
-};
-
-typedef struct if_ppp_state {
- int unit;
- queue_t *q;
- int flags;
-} if_ppp_t;
-
-/* Values for flags */
-#define DBGLOG 1
-
-static int if_ppp_count; /* Number of currently-active streams */
-
-static int ppp_nalloc; /* Number of elements of ifs and states */
-static struct ifnet **ifs; /* Array of pointers to interface structs */
-static if_ppp_t **states; /* Array of pointers to state structs */
-
-static int if_ppp_output __P((struct ifnet *, struct mbuf *,
- struct sockaddr *));
-static int if_ppp_ioctl __P((struct ifnet *, u_int, caddr_t));
-static struct mbuf *make_mbufs __P((mblk_t *, int));
-static mblk_t *make_message __P((struct mbuf *, int));
-
-#ifdef SNIT_SUPPORT
-/* Fake ether header for SNIT */
-static struct ether_header snit_ehdr = {{0}, {0}, ETHERTYPE_IP};
-#endif
-
-#ifndef __osf__
-static void ppp_if_detach __P((struct ifnet *));
-
-/*
- * Detach all the interfaces before unloading.
- * Not sure this works.
- */
-int
-if_ppp_unload()
-{
- int i;
-
- if (if_ppp_count > 0)
- return EBUSY;
- for (i = 0; i < ppp_nalloc; ++i)
- if (ifs[i] != 0)
- ppp_if_detach(ifs[i]);
- if (ifs) {
- FREE(ifs, ppp_nalloc * sizeof (struct ifnet *));
- FREE(states, ppp_nalloc * sizeof (struct if_ppp_t *));
- }
- ppp_nalloc = 0;
- return 0;
-}
-#endif /* __osf__ */
-
-/*
- * STREAMS module entry points.
- */
-static int
-if_ppp_open(q, dev, flag, sflag)
- queue_t *q;
- int dev;
- int flag, sflag;
-{
- if_ppp_t *sp;
-
- if (q->q_ptr == 0) {
- sp = (if_ppp_t *) ALLOC_SLEEP(sizeof (if_ppp_t));
- if (sp == 0)
- return OPENFAIL;
- bzero(sp, sizeof (if_ppp_t));
- q->q_ptr = (caddr_t) sp;
- WR(q)->q_ptr = (caddr_t) sp;
- sp->unit = -1; /* no interface unit attached at present */
- sp->q = WR(q);
- sp->flags = 0;
- ++if_ppp_count;
- }
- return 0;
-}
-
-static int
-if_ppp_close(q, flag)
- queue_t *q;
- int flag;
-{
- if_ppp_t *sp;
- struct ifnet *ifp;
-
- sp = (if_ppp_t *) q->q_ptr;
- if (sp != 0) {
- if (sp->flags & DBGLOG)
- printf("if_ppp closed, q=%x sp=%x\n", q, sp);
- if (sp->unit >= 0) {
- if (sp->unit < ppp_nalloc) {
- states[sp->unit] = 0;
- ifp = ifs[sp->unit];
- if (ifp != 0)
- ifp->if_flags &= ~(IFF_UP | IFF_RUNNING);
-#ifdef DEBUG
- } else {
- printf("if_ppp: unit %d nonexistent!\n", sp->unit);
-#endif
- }
- }
- FREE(sp, sizeof (if_ppp_t));
- --if_ppp_count;
- }
- return 0;
-}
-
-static int
-if_ppp_wput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- if_ppp_t *sp;
- struct iocblk *iop;
- int error, unit;
- struct ifnet *ifp;
-
- sp = (if_ppp_t *) q->q_ptr;
- switch (mp->b_datap->db_type) {
- case M_DATA:
- /*
- * Now why would we be getting data coming in here??
- */
- if (sp->flags & DBGLOG)
- printf("if_ppp: got M_DATA len=%d\n", msgdsize(mp));
- freemsg(mp);
- break;
-
- case M_IOCTL:
- iop = (struct iocblk *) mp->b_rptr;
- error = EINVAL;
-
- if (sp->flags & DBGLOG)
- printf("if_ppp: got ioctl cmd=%x count=%d\n",
- iop->ioc_cmd, iop->ioc_count);
-
- switch (iop->ioc_cmd) {
- case PPPIO_NEWPPA: /* well almost */
- if (iop->ioc_count != sizeof(int) || sp->unit >= 0)
- break;
- if ((error = NOTSUSER()) != 0)
- break;
- unit = *(int *)mp->b_cont->b_rptr;
-
- /* Check that this unit isn't already in use */
- if (unit < ppp_nalloc && states[unit] != 0) {
- error = EADDRINUSE;
- break;
- }
-
- /* Extend ifs and states arrays if necessary. */
- error = ENOSR;
- if (unit >= ppp_nalloc) {
- int newn;
- struct ifnet **newifs;
- if_ppp_t **newstates;
-
- newn = unit + 4;
- if (sp->flags & DBGLOG)
- printf("if_ppp: extending ifs to %d\n", newn);
- newifs = (struct ifnet **)
- ALLOC_NOSLEEP(newn * sizeof (struct ifnet *));
- if (newifs == 0)
- break;
- bzero(newifs, newn * sizeof (struct ifnet *));
- newstates = (if_ppp_t **)
- ALLOC_NOSLEEP(newn * sizeof (struct if_ppp_t *));
- if (newstates == 0) {
- FREE(newifs, newn * sizeof (struct ifnet *));
- break;
- }
- bzero(newstates, newn * sizeof (struct if_ppp_t *));
- bcopy(ifs, newifs, ppp_nalloc * sizeof(struct ifnet *));
- bcopy(states, newstates, ppp_nalloc * sizeof(if_ppp_t *));
- if (ifs) {
- FREE(ifs, ppp_nalloc * sizeof(struct ifnet *));
- FREE(states, ppp_nalloc * sizeof(if_ppp_t *));
- }
- ifs = newifs;
- states = newstates;
- ppp_nalloc = newn;
- }
-
- /* Allocate a new ifnet struct if necessary. */
- ifp = ifs[unit];
- if (ifp == 0) {
- ifp = (struct ifnet *) ALLOC_NOSLEEP(sizeof (struct ifnet));
- if (ifp == 0)
- break;
- bzero(ifp, sizeof (struct ifnet));
- ifs[unit] = ifp;
- ifp->if_name = "ppp";
- ifp->if_unit = unit;
- ifp->if_mtu = PPP_MTU;
- ifp->if_flags = IFF_POINTOPOINT | IFF_RUNNING;
-#ifndef __osf__
-#ifdef IFF_MULTICAST
- ifp->if_flags |= IFF_MULTICAST;
-#endif
-#endif /* __osf__ */
- ifp->if_output = if_ppp_output;
-#ifdef __osf__
- ifp->if_version = "Point-to-Point Protocol, version 2.3.11";
- ifp->if_mediamtu = PPP_MTU;
- ifp->if_type = IFT_PPP;
- ifp->if_hdrlen = PPP_HDRLEN;
- ifp->if_addrlen = 0;
- ifp->if_flags |= IFF_NOARP | IFF_SIMPLEX | IFF_NOTRAILERS;
-#ifdef IFF_VAR_MTU
- ifp->if_flags |= IFF_VAR_MTU;
-#endif
-#ifdef NETMASTERCPU
- ifp->if_affinity = NETMASTERCPU;
-#endif
-#endif
- ifp->if_ioctl = if_ppp_ioctl;
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- if_attach(ifp);
- if (sp->flags & DBGLOG)
- printf("if_ppp: created unit %d\n", unit);
- } else {
- ifp->if_mtu = PPP_MTU;
- ifp->if_flags |= IFF_RUNNING;
- }
-
- states[unit] = sp;
- sp->unit = unit;
-
- error = 0;
- iop->ioc_count = 0;
- if (sp->flags & DBGLOG)
- printf("if_ppp: attached unit %d, sp=%x q=%x\n", unit,
- sp, sp->q);
- break;
-
- case PPPIO_DEBUG:
- error = -1;
- if (iop->ioc_count == sizeof(int)) {
- if (*(int *)mp->b_cont->b_rptr == PPPDBG_LOG + PPPDBG_IF) {
- printf("if_ppp: debug log enabled, q=%x sp=%x\n", q, sp);
- sp->flags |= DBGLOG;
- error = 0;
- iop->ioc_count = 0;
- }
- }
- break;
-
- default:
- error = -1;
- break;
- }
-
- if (sp->flags & DBGLOG)
- printf("if_ppp: ioctl result %d\n", error);
- if (error < 0)
- putnext(q, mp);
- else if (error == 0) {
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
- } else {
- mp->b_datap->db_type = M_IOCNAK;
- iop->ioc_count = 0;
- iop->ioc_error = error;
- qreply(q, mp);
- }
- break;
-
- default:
- putnext(q, mp);
- }
- return 0;
-}
-
-static int
-if_ppp_rput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- if_ppp_t *sp;
- int proto, s;
- struct mbuf *mb;
- struct ifqueue *inq;
- struct ifnet *ifp;
- int len;
-
- sp = (if_ppp_t *) q->q_ptr;
- switch (mp->b_datap->db_type) {
- case M_DATA:
- /*
- * Convert the message into an mbuf chain
- * and inject it into the network code.
- */
- if (sp->flags & DBGLOG)
- printf("if_ppp: rput pkt len %d data %x %x %x %x %x %x %x %x\n",
- msgdsize(mp), mp->b_rptr[0], mp->b_rptr[1], mp->b_rptr[2],
- mp->b_rptr[3], mp->b_rptr[4], mp->b_rptr[5], mp->b_rptr[6],
- mp->b_rptr[7]);
-
- if (sp->unit < 0) {
- freemsg(mp);
- break;
- }
- if (sp->unit >= ppp_nalloc || (ifp = ifs[sp->unit]) == 0) {
-#ifdef DEBUG
- printf("if_ppp: no unit %d!\n", sp->unit);
-#endif
- freemsg(mp);
- break;
- }
-
- if ((ifp->if_flags & IFF_UP) == 0) {
- freemsg(mp);
- break;
- }
- ++ifp->if_ipackets;
-
- proto = PPP_PROTOCOL(mp->b_rptr);
- adjmsg(mp, PPP_HDRLEN);
- len = msgdsize(mp);
- mb = make_mbufs(mp, sizeof(struct ifnet *));
- freemsg(mp);
- if (mb == NULL) {
- if (sp->flags & DBGLOG)
- printf("if_ppp%d: make_mbufs failed\n", ifp->if_unit);
- ++ifp->if_ierrors;
- break;
- }
-
-#ifdef SNIT_SUPPORT
- if (proto == PPP_IP && (ifp->if_flags & IFF_PROMISC)) {
- struct nit_if nif;
-
- nif.nif_header = (caddr_t) &snit_ehdr;
- nif.nif_hdrlen = sizeof(snit_ehdr);
- nif.nif_bodylen = len;
- nif.nif_promisc = 0;
- snit_intr(ifp, mb, &nif);
- }
-#endif
-
-/*
- * For Digital UNIX, there's space set aside in the header mbuf
- * for the interface info.
- *
- * For Sun it's smuggled around via a pointer at the front of the mbuf.
- */
-#ifdef __osf__
- mb->m_pkthdr.rcvif = ifp;
- mb->m_pkthdr.len = len;
-#else
- mb->m_off -= sizeof(struct ifnet *);
- mb->m_len += sizeof(struct ifnet *);
- *mtod(mb, struct ifnet **) = ifp;
-#endif
-
- inq = 0;
- switch (proto) {
- case PPP_IP:
- inq = &ipintrq;
- schednetisr(NETISR_IP);
- }
-
- if (inq != 0) {
- s = splhigh();
- if (IF_QFULL(inq)) {
- IF_DROP(inq);
- ++ifp->if_ierrors;
- if (sp->flags & DBGLOG)
- printf("if_ppp: inq full, proto=%x\n", proto);
- m_freem(mb);
- } else {
- IF_ENQUEUE(inq, mb);
- }
- splx(s);
- } else {
- if (sp->flags & DBGLOG)
- printf("if_ppp%d: proto=%x?\n", ifp->if_unit, proto);
- ++ifp->if_ierrors;
- m_freem(mb);
- }
- break;
-
- default:
- putnext(q, mp);
- }
- return 0;
-}
-
-/*
- * Network code wants to output a packet.
- * Turn it into a STREAMS message and send it down.
- */
-static int
-if_ppp_output(ifp, m0, dst)
- struct ifnet *ifp;
- struct mbuf *m0;
- struct sockaddr *dst;
-{
- mblk_t *mp;
- int proto, s;
- if_ppp_t *sp;
- u_char *p;
-
- if ((ifp->if_flags & IFF_UP) == 0) {
- m_freem(m0);
- return ENETDOWN;
- }
-
- if ((unsigned)ifp->if_unit >= ppp_nalloc) {
-#ifdef DEBUG
- printf("if_ppp_output: unit %d?\n", ifp->if_unit);
-#endif
- m_freem(m0);
- return EINVAL;
- }
- sp = states[ifp->if_unit];
- if (sp == 0) {
-#ifdef DEBUG
- printf("if_ppp_output: no queue?\n");
-#endif
- m_freem(m0);
- return ENETDOWN;
- }
-
- if (sp->flags & DBGLOG) {
- p = mtod(m0, u_char *);
- printf("if_ppp_output%d: af=%d data=%x %x %x %x %x %x %x %x q=%x\n",
- ifp->if_unit, dst->sa_family, p[0], p[1], p[2], p[3], p[4],
- p[5], p[6], p[7], sp->q);
- }
-
- switch (dst->sa_family) {
- case AF_INET:
- proto = PPP_IP;
-#ifdef SNIT_SUPPORT
- if (ifp->if_flags & IFF_PROMISC) {
- struct nit_if nif;
- struct mbuf *m;
- int len;
-
- for (len = 0, m = m0; m != NULL; m = m->m_next)
- len += m->m_len;
- nif.nif_header = (caddr_t) &snit_ehdr;
- nif.nif_hdrlen = sizeof(snit_ehdr);
- nif.nif_bodylen = len;
- nif.nif_promisc = 0;
- snit_intr(ifp, m0, &nif);
- }
-#endif
- break;
-
- default:
- m_freem(m0);
- return EAFNOSUPPORT;
- }
-
- ++ifp->if_opackets;
- mp = make_message(m0, PPP_HDRLEN);
- m_freem(m0);
- if (mp == 0) {
- ++ifp->if_oerrors;
- return ENOBUFS;
- }
- mp->b_rptr -= PPP_HDRLEN;
- mp->b_rptr[0] = PPP_ALLSTATIONS;
- mp->b_rptr[1] = PPP_UI;
- mp->b_rptr[2] = proto >> 8;
- mp->b_rptr[3] = proto;
-
- s = splstr();
- if (sp->flags & DBGLOG)
- printf("if_ppp: putnext(%x, %x), r=%x w=%x p=%x\n",
- sp->q, mp, mp->b_rptr, mp->b_wptr, proto);
- putnext(sp->q, mp);
- splx(s);
-
- return 0;
-}
-
-/*
- * Socket ioctl routine for ppp interfaces.
- */
-static int
-if_ppp_ioctl(ifp, cmd, data)
- struct ifnet *ifp;
- u_int cmd;
- caddr_t data;
-{
- int s, error;
- struct ifreq *ifr = (struct ifreq *) data;
- struct ifaddr *ifa = (struct ifaddr *) data;
- u_short mtu;
-
- error = 0;
- s = splimp();
- switch (cmd) {
- case SIOCSIFFLAGS:
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- ifp->if_flags &= ~IFF_UP;
- break;
-
- case SIOCSIFADDR:
- if (IFA_ADDR(ifa).sa_family != AF_INET)
- error = EAFNOSUPPORT;
- break;
-
- case SIOCSIFDSTADDR:
- if (IFA_ADDR(ifa).sa_family != AF_INET)
- error = EAFNOSUPPORT;
- break;
-
- case SIOCSIFMTU:
- if ((error = NOTSUSER()) != 0)
- break;
-#ifdef __osf__
- /* this hack is necessary because ifioctl checks ifr_data
- * in 4.0 and 5.0, but ifr_data and ifr_metric overlay each
- * other in the definition of struct ifreq so pppd can't set both.
- */
- bcopy(ifr->ifr_data, &mtu, sizeof (u_short));
- ifr->ifr_mtu = mtu;
-#endif
-
- if (ifr->ifr_mtu < PPP_MINMTU || ifr->ifr_mtu > PPP_MAXMTU) {
- error = EINVAL;
- break;
- }
- ifp->if_mtu = ifr->ifr_mtu;
- break;
-
- case SIOCGIFMTU:
- ifr->ifr_mtu = ifp->if_mtu;
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- switch(ifr->ifr_addr.sa_family) {
- case AF_INET:
- break;
- default:
- error = EAFNOSUPPORT;
- break;
- }
- break;
-
- default:
- error = EINVAL;
- }
- splx(s);
- return (error);
-}
-
-/*
- * Turn a STREAMS message into an mbuf chain.
- */
-static struct mbuf *
-make_mbufs(mp, off)
- mblk_t *mp;
- int off;
-{
- struct mbuf *head, **prevp, *m;
- int len, space, n;
- unsigned char *cp, *dp;
-
- len = msgdsize(mp);
- if (len == 0)
- return 0;
- prevp = &head;
- space = 0;
- cp = mp->b_rptr;
-#ifdef __osf__
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- m->m_len = 0;
- space = MHLEN;
- *prevp = m;
- prevp = &m->m_next;
- dp = mtod(m, unsigned char *);
- len -= space;
- off = 0;
-#endif
- for (;;) {
- while (cp >= mp->b_wptr) {
- mp = mp->b_cont;
- if (mp == 0) {
- *prevp = 0;
- return head;
- }
- cp = mp->b_rptr;
- }
- n = mp->b_wptr - cp;
- if (space == 0) {
- MGET(m, M_DONTWAIT, MT_DATA);
- *prevp = m;
- if (m == 0) {
- if (head != 0)
- m_freem(head);
- return 0;
- }
- if (len + off > 2 * MLEN) {
-#ifdef __osf__
- MCLGET(m, M_DONTWAIT);
-#else
- MCLGET(m);
-#endif
- }
-#ifdef __osf__
- space = ((m->m_flags & M_EXT) ? MCLBYTES : MLEN);
-#else
- space = (m->m_off > MMAXOFF? MCLBYTES: MLEN) - off;
- m->m_off += off;
-#endif
- m->m_len = 0;
- len -= space;
- dp = mtod(m, unsigned char *);
- off = 0;
- prevp = &m->m_next;
- }
- if (n > space)
- n = space;
- bcopy(cp, dp, n);
- cp += n;
- dp += n;
- space -= n;
- m->m_len += n;
- }
-}
-
-/*
- * Turn an mbuf chain into a STREAMS message.
- */
-#define ALLOCB_MAX 4096
-
-static mblk_t *
-make_message(m, off)
- struct mbuf *m;
- int off;
-{
- mblk_t *head, **prevp, *mp;
- int len, space, n, nb;
- unsigned char *cp, *dp;
- struct mbuf *nm;
-
- len = 0;
- for (nm = m; nm != 0; nm = nm->m_next)
- len += nm->m_len;
- prevp = &head;
- space = 0;
- cp = mtod(m, unsigned char *);
- nb = m->m_len;
- for (;;) {
- while (nb <= 0) {
- m = m->m_next;
- if (m == 0) {
- *prevp = 0;
- return head;
- }
- cp = mtod(m, unsigned char *);
- nb = m->m_len;
- }
- if (space == 0) {
- space = len + off;
- if (space > ALLOCB_MAX)
- space = ALLOCB_MAX;
- mp = allocb(space, BPRI_LO);
- *prevp = mp;
- if (mp == 0) {
- if (head != 0)
- freemsg(head);
- return 0;
- }
- dp = mp->b_rptr += off;
- space -= off;
- len -= space;
- off = 0;
- prevp = &mp->b_cont;
- }
- n = nb < space? nb: space;
- bcopy(cp, dp, n);
- cp += n;
- dp += n;
- nb -= n;
- space -= n;
- mp->b_wptr = dp;
- }
-}
-
-/*
- * Digital UNIX doesn't allow for removing ifnet structures
- * from the list. But then we're not using this as a loadable
- * module anyway, so that's OK.
- *
- * Under SunOS, this should allow the module to be unloaded.
- * Unfortunately, it doesn't seem to detach all the references,
- * so your system may well crash after you unload this module :-(
- */
-#ifndef __osf__
-
-/*
- * Remove an interface from the system.
- * This routine contains magic.
- */
-#include <net/route.h>
-#include <netinet/in_pcb.h>
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-
-static void
-ppp_if_detach(ifp)
- struct ifnet *ifp;
-{
- int s;
- struct inpcb *pcb;
- struct ifaddr *ifa;
- struct in_ifaddr **inap;
- struct ifnet **ifpp;
-
- s = splhigh();
-
- /*
- * Clear the interface from any routes currently cached in
- * TCP or UDP protocol control blocks.
- */
- for (pcb = tcb.inp_next; pcb != &tcb; pcb = pcb->inp_next)
- if (pcb->inp_route.ro_rt && pcb->inp_route.ro_rt->rt_ifp == ifp)
- in_losing(pcb);
- for (pcb = udb.inp_next; pcb != &udb; pcb = pcb->inp_next)
- if (pcb->inp_route.ro_rt && pcb->inp_route.ro_rt->rt_ifp == ifp)
- in_losing(pcb);
-
- /*
- * Delete routes through all addresses of the interface.
- */
- for (ifa = ifp->if_addrlist; ifa != 0; ifa = ifa->ifa_next) {
- rtinit(ifa, ifa, SIOCDELRT, RTF_HOST);
- rtinit(ifa, ifa, SIOCDELRT, 0);
- }
-
- /*
- * Unlink the interface's address(es) from the in_ifaddr list.
- */
- for (inap = &in_ifaddr; *inap != 0; ) {
- if ((*inap)->ia_ifa.ifa_ifp == ifp)
- *inap = (*inap)->ia_next;
- else
- inap = &(*inap)->ia_next;
- }
-
- /*
- * Delete the interface from the ifnet list.
- */
- for (ifpp = &ifnet; (*ifpp) != 0; ) {
- if (*ifpp == ifp)
- break;
- ifpp = &(*ifpp)->if_next;
- }
- if (*ifpp == 0)
- printf("couldn't find interface ppp%d in ifnet list\n", ifp->if_unit);
- else
- *ifpp = ifp->if_next;
-
- splx(s);
-}
-
-#endif /* __osf__ */
diff --git a/mdk-stage1/ppp/modules/ppp.c b/mdk-stage1/ppp/modules/ppp.c
deleted file mode 100644
index 44bf08dff..000000000
--- a/mdk-stage1/ppp/modules/ppp.c
+++ /dev/null
@@ -1,2486 +0,0 @@
-/*
- * ppp.c - STREAMS multiplexing pseudo-device driver for PPP.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-/*
- * This file is used under Solaris 2, SVR4, SunOS 4, and Digital UNIX.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/stream.h>
-#include <sys/stropts.h>
-#include <sys/errno.h>
-#ifdef __osf__
-#include <sys/ioctl.h>
-#include <sys/cmn_err.h>
-#define queclass(mp) ((mp)->b_band & QPCTL)
-#else
-#include <sys/ioccom.h>
-#endif
-#include <sys/time.h>
-#ifdef SVR4
-#include <sys/cmn_err.h>
-#include <sys/conf.h>
-#include <sys/dlpi.h>
-#include <sys/ddi.h>
-#ifdef SOL2
-#include <sys/ksynch.h>
-#include <sys/kstat.h>
-#include <sys/sunddi.h>
-#include <sys/ethernet.h>
-#else
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#endif /* SOL2 */
-#else /* not SVR4 */
-#include <sys/user.h>
-#endif /* SVR4 */
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include "ppp_mod.h"
-
-/*
- * Modifications marked with #ifdef PRIOQ are for priority queueing of
- * interactive traffic, and are due to Marko Zec <zec@japa.tel.fer.hr>.
- */
-#ifdef PRIOQ
-#endif /* PRIOQ */
-
-#include <netinet/in.h> /* leave this outside of PRIOQ for htons */
-
-#ifdef __STDC__
-#define __P(x) x
-#else
-#define __P(x) ()
-#endif
-
-/*
- * The IP module may use this SAP value for IP packets.
- */
-#ifndef ETHERTYPE_IP
-#define ETHERTYPE_IP 0x800
-#endif
-
-#if !defined(ETHERTYPE_IPV6)
-#define ETHERTYPE_IPV6 0x86dd
-#endif /* !defined(ETHERTYPE_IPV6) */
-
-#if !defined(ETHERTYPE_ALLSAP) && defined(SOL2)
-#define ETHERTYPE_ALLSAP 0
-#endif /* !defined(ETHERTYPE_ALLSAP) && defined(SOL2) */
-
-#if !defined(PPP_ALLSAP) && defined(SOL2)
-#define PPP_ALLSAP PPP_ALLSTATIONS
-#endif /* !defined(PPP_ALLSAP) && defined(SOL2) */
-
-extern time_t time;
-
-#ifdef SOL2
-/*
- * We use this reader-writer lock to ensure that the lower streams
- * stay connected to the upper streams while the lower-side put and
- * service procedures are running. Essentially it is an existence
- * lock for the upper stream associated with each lower stream.
- */
-krwlock_t ppp_lower_lock;
-#define LOCK_LOWER_W rw_enter(&ppp_lower_lock, RW_WRITER)
-#define LOCK_LOWER_R rw_enter(&ppp_lower_lock, RW_READER)
-#define TRYLOCK_LOWER_R rw_tryenter(&ppp_lower_lock, RW_READER)
-#define UNLOCK_LOWER rw_exit(&ppp_lower_lock)
-
-#define MT_ENTER(x) mutex_enter(x)
-#define MT_EXIT(x) mutex_exit(x)
-
-/*
- * Notes on multithreaded implementation for Solaris 2:
- *
- * We use an inner perimeter around each queue pair and an outer
- * perimeter around the whole driver. The inner perimeter is
- * entered exclusively for all entry points (open, close, put,
- * service). The outer perimeter is entered exclusively for open
- * and close and shared for put and service. This is all done for
- * us by the streams framework.
- *
- * I used to think that the perimeters were entered for the lower
- * streams' put and service routines as well as for the upper streams'.
- * Because of problems experienced by people, and after reading the
- * documentation more closely, I now don't think that is true. So we
- * now use ppp_lower_lock to give us an existence guarantee on the
- * upper stream controlling each lower stream.
- *
- * Shared entry to the outer perimeter protects the existence of all
- * the upper streams and their upperstr_t structures, and guarantees
- * that the following fields of any upperstr_t won't change:
- * nextmn, next, nextppa. It guarantees that the lowerq field of an
- * upperstr_t won't go from non-zero to zero, that the global `ppas'
- * won't change and that the no lower stream will get unlinked.
- *
- * Shared (reader) access to ppa_lower_lock guarantees that no lower
- * stream will be unlinked and that the lowerq field of all upperstr_t
- * structures won't change.
- */
-
-#else /* SOL2 */
-#define LOCK_LOWER_W 0
-#define LOCK_LOWER_R 0
-#define TRYLOCK_LOWER_R 1
-#define UNLOCK_LOWER 0
-#define MT_ENTER(x) 0
-#define MT_EXIT(x) 0
-
-#endif /* SOL2 */
-
-/*
- * Private information; one per upper stream.
- */
-typedef struct upperstr {
- minor_t mn; /* minor device number */
- struct upperstr *nextmn; /* next minor device */
- queue_t *q; /* read q associated with this upper stream */
- int flags; /* flag bits, see below */
- int state; /* current DLPI state */
- int sap; /* service access point */
- int req_sap; /* which SAP the DLPI client requested */
- struct upperstr *ppa; /* control stream for our ppa */
- struct upperstr *next; /* next stream for this ppa */
- uint ioc_id; /* last ioctl ID for this stream */
- enum NPmode npmode; /* what to do with packets on this SAP */
- unsigned char rblocked; /* flow control has blocked upper read strm */
- /* N.B. rblocked is only changed by control stream's put/srv procs */
- /*
- * There is exactly one control stream for each PPA.
- * The following fields are only used for control streams.
- */
- int ppa_id;
- queue_t *lowerq; /* write queue attached below this PPA */
- struct upperstr *nextppa; /* next control stream */
- int mru;
- int mtu;
- struct pppstat stats; /* statistics */
- time_t last_sent; /* time last NP packet sent */
- time_t last_recv; /* time last NP packet rcvd */
-#ifdef SOL2
- kmutex_t stats_lock; /* lock for stats updates */
- kstat_t *kstats; /* stats for netstat */
-#endif /* SOL2 */
-#ifdef LACHTCP
- int ifflags;
- char ifname[IFNAMSIZ];
- struct ifstats ifstats;
-#endif /* LACHTCP */
-} upperstr_t;
-
-/* Values for flags */
-#define US_PRIV 1 /* stream was opened by superuser */
-#define US_CONTROL 2 /* stream is a control stream */
-#define US_BLOCKED 4 /* flow ctrl has blocked lower write stream */
-#define US_LASTMOD 8 /* no PPP modules below us */
-#define US_DBGLOG 0x10 /* log various occurrences */
-#define US_RBLOCKED 0x20 /* flow ctrl has blocked upper read stream */
-
-#if defined(SOL2)
-#if DL_CURRENT_VERSION >= 2
-#define US_PROMISC 0x40 /* stream is promiscuous */
-#endif /* DL_CURRENT_VERSION >= 2 */
-#define US_RAWDATA 0x80 /* raw M_DATA, no DLPI header */
-#endif /* defined(SOL2) */
-
-#ifdef PRIOQ
-static u_char max_band=0;
-static u_char def_band=0;
-
-#define IPPORT_DEFAULT 65535
-
-/*
- * Port priority table
- * Highest priority ports are listed first, lowest are listed last.
- * ICMP & packets using unlisted ports will be treated as "default".
- * If IPPORT_DEFAULT is not listed here, "default" packets will be
- * assigned lowest priority.
- * Each line should be terminated with "0".
- * Line containing only "0" marks the end of the list.
- */
-
-static u_short prioq_table[]= {
- 113, 53, 0,
- 22, 23, 513, 517, 518, 0,
- 514, 21, 79, 111, 0,
- 25, 109, 110, 0,
- IPPORT_DEFAULT, 0,
- 20, 70, 80, 8001, 8008, 8080, 0, /* 8001,8008,8080 - common proxy ports */
-0 };
-
-#endif /* PRIOQ */
-
-
-static upperstr_t *minor_devs = NULL;
-static upperstr_t *ppas = NULL;
-
-#ifdef SVR4
-static int pppopen __P((queue_t *, dev_t *, int, int, cred_t *));
-static int pppclose __P((queue_t *, int, cred_t *));
-#else
-static int pppopen __P((queue_t *, int, int, int));
-static int pppclose __P((queue_t *, int));
-#endif /* SVR4 */
-static int pppurput __P((queue_t *, mblk_t *));
-static int pppuwput __P((queue_t *, mblk_t *));
-static int pppursrv __P((queue_t *));
-static int pppuwsrv __P((queue_t *));
-static int ppplrput __P((queue_t *, mblk_t *));
-static int ppplwput __P((queue_t *, mblk_t *));
-static int ppplrsrv __P((queue_t *));
-static int ppplwsrv __P((queue_t *));
-#ifndef NO_DLPI
-static void dlpi_request __P((queue_t *, mblk_t *, upperstr_t *));
-static void dlpi_error __P((queue_t *, upperstr_t *, int, int, int));
-static void dlpi_ok __P((queue_t *, int));
-#endif
-static int send_data __P((mblk_t *, upperstr_t *));
-static void new_ppa __P((queue_t *, mblk_t *));
-static void attach_ppa __P((queue_t *, mblk_t *));
-static void detach_ppa __P((queue_t *, mblk_t *));
-static void detach_lower __P((queue_t *, mblk_t *));
-static void debug_dump __P((queue_t *, mblk_t *));
-static upperstr_t *find_dest __P((upperstr_t *, int));
-#if defined(SOL2)
-static upperstr_t *find_promisc __P((upperstr_t *, int));
-static mblk_t *prepend_ether __P((upperstr_t *, mblk_t *, int));
-static mblk_t *prepend_udind __P((upperstr_t *, mblk_t *, int));
-static void promisc_sendup __P((upperstr_t *, mblk_t *, int, int));
-#endif /* defined(SOL2) */
-static int putctl2 __P((queue_t *, int, int, int));
-static int putctl4 __P((queue_t *, int, int, int));
-static int pass_packet __P((upperstr_t *ppa, mblk_t *mp, int outbound));
-#ifdef FILTER_PACKETS
-static int ip_hard_filter __P((upperstr_t *ppa, mblk_t *mp, int outbound));
-#endif /* FILTER_PACKETS */
-
-#define PPP_ID 0xb1a6
-static struct module_info ppp_info = {
-#ifdef PRIOQ
- PPP_ID, "ppp", 0, 512, 512, 384
-#else
- PPP_ID, "ppp", 0, 512, 512, 128
-#endif /* PRIOQ */
-};
-
-static struct qinit pppurint = {
- pppurput, pppursrv, pppopen, pppclose, NULL, &ppp_info, NULL
-};
-
-static struct qinit pppuwint = {
- pppuwput, pppuwsrv, NULL, NULL, NULL, &ppp_info, NULL
-};
-
-static struct qinit ppplrint = {
- ppplrput, ppplrsrv, NULL, NULL, NULL, &ppp_info, NULL
-};
-
-static struct qinit ppplwint = {
- ppplwput, ppplwsrv, NULL, NULL, NULL, &ppp_info, NULL
-};
-
-#ifdef LACHTCP
-extern struct ifstats *ifstats;
-int pppdevflag = 0;
-#endif
-
-struct streamtab pppinfo = {
- &pppurint, &pppuwint,
- &ppplrint, &ppplwint
-};
-
-int ppp_count;
-
-/*
- * How we maintain statistics.
- */
-#ifdef SOL2
-#define INCR_IPACKETS(ppa) \
- if (ppa->kstats != 0) { \
- KSTAT_NAMED_PTR(ppa->kstats)[0].value.ul++; \
- }
-#define INCR_IERRORS(ppa) \
- if (ppa->kstats != 0) { \
- KSTAT_NAMED_PTR(ppa->kstats)[1].value.ul++; \
- }
-#define INCR_OPACKETS(ppa) \
- if (ppa->kstats != 0) { \
- KSTAT_NAMED_PTR(ppa->kstats)[2].value.ul++; \
- }
-#define INCR_OERRORS(ppa) \
- if (ppa->kstats != 0) { \
- KSTAT_NAMED_PTR(ppa->kstats)[3].value.ul++; \
- }
-#endif
-
-#ifdef LACHTCP
-#define INCR_IPACKETS(ppa) ppa->ifstats.ifs_ipackets++;
-#define INCR_IERRORS(ppa) ppa->ifstats.ifs_ierrors++;
-#define INCR_OPACKETS(ppa) ppa->ifstats.ifs_opackets++;
-#define INCR_OERRORS(ppa) ppa->ifstats.ifs_oerrors++;
-#endif
-
-/*
- * STREAMS driver entry points.
- */
-static int
-#ifdef SVR4
-pppopen(q, devp, oflag, sflag, credp)
- queue_t *q;
- dev_t *devp;
- int oflag, sflag;
- cred_t *credp;
-#else
-pppopen(q, dev, oflag, sflag)
- queue_t *q;
- int dev; /* really dev_t */
- int oflag, sflag;
-#endif
-{
- upperstr_t *up;
- upperstr_t **prevp;
- minor_t mn;
-#ifdef PRIOQ
- u_short *ptr;
- u_char new_band;
-#endif /* PRIOQ */
-
- if (q->q_ptr)
- DRV_OPEN_OK(dev); /* device is already open */
-
-#ifdef PRIOQ
- /* Calculate max_bband & def_band from definitions in prioq.h
- This colud be done at some more approtiate time (less often)
- but this way it works well so I'll just leave it here */
-
- max_band = 1;
- def_band = 0;
- ptr = prioq_table;
- while (*ptr) {
- new_band = 1;
- while (*ptr)
- if (*ptr++ == IPPORT_DEFAULT) {
- new_band = 0;
- def_band = max_band;
- }
- max_band += new_band;
- ptr++;
- }
- if (def_band)
- def_band = max_band - def_band;
- --max_band;
-#endif /* PRIOQ */
-
- if (sflag == CLONEOPEN) {
- mn = 0;
- for (prevp = &minor_devs; (up = *prevp) != 0; prevp = &up->nextmn) {
- if (up->mn != mn)
- break;
- ++mn;
- }
- } else {
-#ifdef SVR4
- mn = getminor(*devp);
-#else
- mn = minor(dev);
-#endif
- for (prevp = &minor_devs; (up = *prevp) != 0; prevp = &up->nextmn) {
- if (up->mn >= mn)
- break;
- }
- if (up->mn == mn) {
- /* this can't happen */
- q->q_ptr = WR(q)->q_ptr = (caddr_t) up;
- DRV_OPEN_OK(dev);
- }
- }
-
- /*
- * Construct a new minor node.
- */
- up = (upperstr_t *) ALLOC_SLEEP(sizeof(upperstr_t));
- bzero((caddr_t) up, sizeof(upperstr_t));
- if (up == 0) {
- DPRINT("pppopen: out of kernel memory\n");
- OPEN_ERROR(ENXIO);
- }
- up->nextmn = *prevp;
- *prevp = up;
- up->mn = mn;
-#ifdef SVR4
- *devp = makedevice(getmajor(*devp), mn);
-#endif
- up->q = q;
- if (NOTSUSER() == 0)
- up->flags |= US_PRIV;
-#ifndef NO_DLPI
- up->state = DL_UNATTACHED;
-#endif
-#ifdef LACHTCP
- up->ifflags = IFF_UP | IFF_POINTOPOINT;
-#endif
- up->sap = -1;
- up->last_sent = up->last_recv = time;
- up->npmode = NPMODE_DROP;
- q->q_ptr = (caddr_t) up;
- WR(q)->q_ptr = (caddr_t) up;
- noenable(WR(q));
-#ifdef SOL2
- mutex_init(&up->stats_lock, NULL, MUTEX_DRIVER, NULL);
-#endif
- ++ppp_count;
-
- qprocson(q);
- DRV_OPEN_OK(makedev(major(dev), mn));
-}
-
-static int
-#ifdef SVR4
-pppclose(q, flag, credp)
- queue_t *q;
- int flag;
- cred_t *credp;
-#else
-pppclose(q, flag)
- queue_t *q;
- int flag;
-#endif
-{
- upperstr_t *up, **upp;
- upperstr_t *as, *asnext;
- upperstr_t **prevp;
-
- qprocsoff(q);
-
- up = (upperstr_t *) q->q_ptr;
- if (up == 0) {
- DPRINT("pppclose: q_ptr = 0\n");
- return 0;
- }
- if (up->flags & US_DBGLOG)
- DPRINT2("ppp/%d: close, flags=%x\n", up->mn, up->flags);
- if (up->flags & US_CONTROL) {
-#ifdef LACHTCP
- struct ifstats *ifp, *pifp;
-#endif
- if (up->lowerq != 0) {
- /* Gack! the lower stream should have be unlinked earlier! */
- DPRINT1("ppp%d: lower stream still connected on close?\n",
- up->mn);
- LOCK_LOWER_W;
- up->lowerq->q_ptr = 0;
- RD(up->lowerq)->q_ptr = 0;
- up->lowerq = 0;
- UNLOCK_LOWER;
- }
-
- /*
- * This stream represents a PPA:
- * For all streams attached to the PPA, clear their
- * references to this PPA.
- * Then remove this PPA from the list of PPAs.
- */
- for (as = up->next; as != 0; as = asnext) {
- asnext = as->next;
- as->next = 0;
- as->ppa = 0;
- if (as->flags & US_BLOCKED) {
- as->flags &= ~US_BLOCKED;
- flushq(WR(as->q), FLUSHDATA);
- }
- }
- for (upp = &ppas; *upp != 0; upp = &(*upp)->nextppa)
- if (*upp == up) {
- *upp = up->nextppa;
- break;
- }
-#ifdef LACHTCP
- /* Remove the statistics from the active list. */
- for (ifp = ifstats, pifp = 0; ifp; ifp = ifp->ifs_next) {
- if (ifp == &up->ifstats) {
- if (pifp)
- pifp->ifs_next = ifp->ifs_next;
- else
- ifstats = ifp->ifs_next;
- break;
- }
- pifp = ifp;
- }
-#endif
- } else {
- /*
- * If this stream is attached to a PPA,
- * remove it from the PPA's list.
- */
- if ((as = up->ppa) != 0) {
- for (; as->next != 0; as = as->next)
- if (as->next == up) {
- as->next = up->next;
- break;
- }
- }
- }
-
-#ifdef SOL2
- if (up->kstats)
- kstat_delete(up->kstats);
- mutex_destroy(&up->stats_lock);
-#endif
-
- q->q_ptr = NULL;
- WR(q)->q_ptr = NULL;
-
- for (prevp = &minor_devs; *prevp != 0; prevp = &(*prevp)->nextmn) {
- if (*prevp == up) {
- *prevp = up->nextmn;
- break;
- }
- }
- FREE(up, sizeof(upperstr_t));
- --ppp_count;
-
- return 0;
-}
-
-/*
- * A message from on high. We do one of three things:
- * - qreply()
- * - put the message on the lower write stream
- * - queue it for our service routine
- */
-static int
-pppuwput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *us, *ppa, *nps;
- struct iocblk *iop;
- struct linkblk *lb;
-#ifdef LACHTCP
- struct ifreq *ifr;
- int i;
-#endif
- queue_t *lq;
- int error, n, sap;
- mblk_t *mq;
- struct ppp_idle *pip;
-#ifdef PRIOQ
- queue_t *tlq;
-#endif /* PRIOQ */
-#ifdef NO_DLPI
- upperstr_t *os;
-#endif
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("pppuwput: q_ptr = 0!\n");
- return 0;
- }
- if (mp == 0) {
- DPRINT1("pppuwput/%d: mp = 0!\n", us->mn);
- return 0;
- }
- if (mp->b_datap == 0) {
- DPRINT1("pppuwput/%d: mp->b_datap = 0!\n", us->mn);
- return 0;
- }
- switch (mp->b_datap->db_type) {
-#ifndef NO_DLPI
- case M_PCPROTO:
- case M_PROTO:
- dlpi_request(q, mp, us);
- break;
-#endif /* NO_DLPI */
-
- case M_DATA:
- if (us->flags & US_DBGLOG)
- DPRINT3("ppp/%d: uwput M_DATA len=%d flags=%x\n",
- us->mn, msgdsize(mp), us->flags);
- if (us->ppa == 0 || msgdsize(mp) > us->ppa->mtu + PPP_HDRLEN
-#ifndef NO_DLPI
- || (us->flags & US_CONTROL) == 0
-#endif /* NO_DLPI */
- ) {
- DPRINT1("pppuwput: junk data len=%d\n", msgdsize(mp));
- freemsg(mp);
- break;
- }
-#ifdef NO_DLPI
- if ((us->flags & US_CONTROL) == 0 && !pass_packet(us, mp, 1))
- break;
-#endif
- if (!send_data(mp, us))
- putq(q, mp);
- break;
-
- case M_IOCTL:
- iop = (struct iocblk *) mp->b_rptr;
- error = EINVAL;
- if (us->flags & US_DBGLOG)
- DPRINT3("ppp/%d: ioctl %x count=%d\n",
- us->mn, iop->ioc_cmd, iop->ioc_count);
- switch (iop->ioc_cmd) {
-#if defined(SOL2)
- case DLIOCRAW: /* raw M_DATA mode */
- us->flags |= US_RAWDATA;
- error = 0;
- break;
-#endif /* defined(SOL2) */
- case I_LINK:
- if ((us->flags & US_CONTROL) == 0 || us->lowerq != 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl I_LINK b_cont = 0!\n", us->mn);
- break;
- }
- lb = (struct linkblk *) mp->b_cont->b_rptr;
- lq = lb->l_qbot;
- if (lq == 0) {
- DPRINT1("pppuwput/%d: ioctl I_LINK l_qbot = 0!\n", us->mn);
- break;
- }
- LOCK_LOWER_W;
- us->lowerq = lq;
- lq->q_ptr = (caddr_t) q;
- RD(lq)->q_ptr = (caddr_t) us->q;
- UNLOCK_LOWER;
- iop->ioc_count = 0;
- error = 0;
- us->flags &= ~US_LASTMOD;
- /* Unblock upper streams which now feed this lower stream. */
- qenable(q);
- /* Send useful information down to the modules which
- are now linked below us. */
- putctl2(lq, M_CTL, PPPCTL_UNIT, us->ppa_id);
- putctl4(lq, M_CTL, PPPCTL_MRU, us->mru);
- putctl4(lq, M_CTL, PPPCTL_MTU, us->mtu);
-#ifdef PRIOQ
- /* Lower tty driver's queue hiwat/lowat from default 4096/128
- to 256/128 since we don't want queueing of data on
- output to physical device */
-
- freezestr(lq);
- for (tlq = lq; tlq->q_next != NULL; tlq = tlq->q_next)
- ;
- strqset(tlq, QHIWAT, 0, 256);
- strqset(tlq, QLOWAT, 0, 128);
- unfreezestr(lq);
-#endif /* PRIOQ */
- break;
-
- case I_UNLINK:
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl I_UNLINK b_cont = 0!\n", us->mn);
- break;
- }
- lb = (struct linkblk *) mp->b_cont->b_rptr;
-#if DEBUG
- if (us->lowerq != lb->l_qbot) {
- DPRINT2("ppp unlink: lowerq=%x qbot=%x\n",
- us->lowerq, lb->l_qbot);
- break;
- }
-#endif
- iop->ioc_count = 0;
- qwriter(q, mp, detach_lower, PERIM_OUTER);
- error = -1;
- break;
-
- case PPPIO_NEWPPA:
- if (us->flags & US_CONTROL)
- break;
- if ((us->flags & US_PRIV) == 0) {
- error = EPERM;
- break;
- }
- /* Arrange to return an int */
- if ((mq = mp->b_cont) == 0
- || mq->b_datap->db_lim - mq->b_rptr < sizeof(int)) {
- mq = allocb(sizeof(int), BPRI_HI);
- if (mq == 0) {
- error = ENOSR;
- break;
- }
- if (mp->b_cont != 0)
- freemsg(mp->b_cont);
- mp->b_cont = mq;
- mq->b_cont = 0;
- }
- iop->ioc_count = sizeof(int);
- mq->b_wptr = mq->b_rptr + sizeof(int);
- qwriter(q, mp, new_ppa, PERIM_OUTER);
- error = -1;
- break;
-
- case PPPIO_ATTACH:
- /* like dlpi_attach, for programs which can't write to
- the stream (like pppstats) */
- if (iop->ioc_count != sizeof(int) || us->ppa != 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl PPPIO_ATTACH b_cont = 0!\n", us->mn);
- break;
- }
- n = *(int *)mp->b_cont->b_rptr;
- for (ppa = ppas; ppa != 0; ppa = ppa->nextppa)
- if (ppa->ppa_id == n)
- break;
- if (ppa == 0)
- break;
- us->ppa = ppa;
- iop->ioc_count = 0;
- qwriter(q, mp, attach_ppa, PERIM_OUTER);
- error = -1;
- break;
-
-#ifdef NO_DLPI
- case PPPIO_BIND:
- /* Attach to a given SAP. */
- if (iop->ioc_count != sizeof(int) || us->ppa == 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl PPPIO_BIND b_cont = 0!\n", us->mn);
- break;
- }
- n = *(int *)mp->b_cont->b_rptr;
- /* n must be a valid PPP network protocol number. */
- if (n < 0x21 || n > 0x3fff || (n & 0x101) != 1)
- break;
- /* check that no other stream is bound to this sap already. */
- for (os = us->ppa; os != 0; os = os->next)
- if (os->sap == n)
- break;
- if (os != 0)
- break;
- us->sap = n;
- iop->ioc_count = 0;
- error = 0;
- break;
-#endif /* NO_DLPI */
-
- case PPPIO_MRU:
- if (iop->ioc_count != sizeof(int) || (us->flags & US_CONTROL) == 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl PPPIO_MRU b_cont = 0!\n", us->mn);
- break;
- }
- n = *(int *)mp->b_cont->b_rptr;
- if (n <= 0 || n > PPP_MAXMRU)
- break;
- if (n < PPP_MRU)
- n = PPP_MRU;
- us->mru = n;
- if (us->lowerq)
- putctl4(us->lowerq, M_CTL, PPPCTL_MRU, n);
- error = 0;
- iop->ioc_count = 0;
- break;
-
- case PPPIO_MTU:
- if (iop->ioc_count != sizeof(int) || (us->flags & US_CONTROL) == 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl PPPIO_MTU b_cont = 0!\n", us->mn);
- break;
- }
- n = *(int *)mp->b_cont->b_rptr;
- if (n <= 0 || n > PPP_MAXMTU)
- break;
- us->mtu = n;
-#ifdef LACHTCP
- /* The MTU reported in netstat, not used as IP max packet size! */
- us->ifstats.ifs_mtu = n;
-#endif
- if (us->lowerq)
- putctl4(us->lowerq, M_CTL, PPPCTL_MTU, n);
- error = 0;
- iop->ioc_count = 0;
- break;
-
- case PPPIO_LASTMOD:
- us->flags |= US_LASTMOD;
- error = 0;
- break;
-
- case PPPIO_DEBUG:
- if (iop->ioc_count != sizeof(int))
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl PPPIO_DEBUG b_cont = 0!\n", us->mn);
- break;
- }
- n = *(int *)mp->b_cont->b_rptr;
- if (n == PPPDBG_DUMP + PPPDBG_DRIVER) {
- qwriter(q, NULL, debug_dump, PERIM_OUTER);
- iop->ioc_count = 0;
- error = -1;
- } else if (n == PPPDBG_LOG + PPPDBG_DRIVER) {
- DPRINT1("ppp/%d: debug log enabled\n", us->mn);
- us->flags |= US_DBGLOG;
- iop->ioc_count = 0;
- error = 0;
- } else {
- if (us->ppa == 0 || us->ppa->lowerq == 0)
- break;
- putnext(us->ppa->lowerq, mp);
- error = -1;
- }
- break;
-
- case PPPIO_NPMODE:
- if (iop->ioc_count != 2 * sizeof(int))
- break;
- if ((us->flags & US_CONTROL) == 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("pppuwput/%d: ioctl PPPIO_NPMODE b_cont = 0!\n", us->mn);
- break;
- }
- sap = ((int *)mp->b_cont->b_rptr)[0];
- for (nps = us->next; nps != 0; nps = nps->next) {
- if (us->flags & US_DBGLOG)
- DPRINT2("us = 0x%x, us->next->sap = 0x%x\n", nps, nps->sap);
- if (nps->sap == sap)
- break;
- }
- if (nps == 0) {
- if (us->flags & US_DBGLOG)
- DPRINT2("ppp/%d: no stream for sap %x\n", us->mn, sap);
- break;
- }
- /* XXX possibly should use qwriter here */
- nps->npmode = (enum NPmode) ((int *)mp->b_cont->b_rptr)[1];
- if (nps->npmode != NPMODE_QUEUE && (nps->flags & US_BLOCKED) != 0)
- qenable(WR(nps->q));
- iop->ioc_count = 0;
- error = 0;
- break;
-
- case PPPIO_GIDLE:
- if ((ppa = us->ppa) == 0)
- break;
- mq = allocb(sizeof(struct ppp_idle), BPRI_HI);
- if (mq == 0) {
- error = ENOSR;
- break;
- }
- if (mp->b_cont != 0)
- freemsg(mp->b_cont);
- mp->b_cont = mq;
- mq->b_cont = 0;
- pip = (struct ppp_idle *) mq->b_wptr;
- pip->xmit_idle = time - ppa->last_sent;
- pip->recv_idle = time - ppa->last_recv;
- mq->b_wptr += sizeof(struct ppp_idle);
- iop->ioc_count = sizeof(struct ppp_idle);
- error = 0;
- break;
-
-#ifdef LACHTCP
- case SIOCSIFNAME:
- /* Sent from IP down to us. Attach the ifstats structure. */
- if (iop->ioc_count != sizeof(struct ifreq) || us->ppa == 0)
- break;
- ifr = (struct ifreq *)mp->b_cont->b_rptr;
- /* Find the unit number in the interface name. */
- for (i = 0; i < IFNAMSIZ; i++) {
- if (ifr->ifr_name[i] == 0 ||
- (ifr->ifr_name[i] >= '0' &&
- ifr->ifr_name[i] <= '9'))
- break;
- else
- us->ifname[i] = ifr->ifr_name[i];
- }
- us->ifname[i] = 0;
-
- /* Convert the unit number to binary. */
- for (n = 0; i < IFNAMSIZ; i++) {
- if (ifr->ifr_name[i] == 0) {
- break;
- }
- else {
- n = n * 10 + ifr->ifr_name[i] - '0';
- }
- }
-
- /* Verify the ppa. */
- if (us->ppa->ppa_id != n)
- break;
- ppa = us->ppa;
-
- /* Set up the netstat block. */
- strncpy (ppa->ifname, us->ifname, IFNAMSIZ);
-
- ppa->ifstats.ifs_name = ppa->ifname;
- ppa->ifstats.ifs_unit = n;
- ppa->ifstats.ifs_active = us->state != DL_UNBOUND;
- ppa->ifstats.ifs_mtu = ppa->mtu;
-
- /* Link in statistics used by netstat. */
- ppa->ifstats.ifs_next = ifstats;
- ifstats = &ppa->ifstats;
-
- iop->ioc_count = 0;
- error = 0;
- break;
-
- case SIOCGIFFLAGS:
- if (!(us->flags & US_CONTROL)) {
- if (us->ppa)
- us = us->ppa;
- else
- break;
- }
- ((struct iocblk_in *)iop)->ioc_ifflags = us->ifflags;
- error = 0;
- break;
-
- case SIOCSIFFLAGS:
- if (!(us->flags & US_CONTROL)) {
- if (us->ppa)
- us = us->ppa;
- else
- break;
- }
- us->ifflags = ((struct iocblk_in *)iop)->ioc_ifflags;
- error = 0;
- break;
-
- case SIOCSIFADDR:
- if (!(us->flags & US_CONTROL)) {
- if (us->ppa)
- us = us->ppa;
- else
- break;
- }
- us->ifflags |= IFF_RUNNING;
- ((struct iocblk_in *)iop)->ioc_ifflags |= IFF_RUNNING;
- error = 0;
- break;
-
- case SIOCSIFMTU:
- /*
- * Vanilla SVR4 systems don't handle SIOCSIFMTU, rather
- * they take the MTU from the DL_INFO_ACK we sent in response
- * to their DL_INFO_REQ. Fortunately, they will update the
- * MTU if we send an unsolicited DL_INFO_ACK up.
- */
- if ((mq = allocb(sizeof(dl_info_req_t), BPRI_HI)) == 0)
- break; /* should do bufcall */
- ((union DL_primitives *)mq->b_rptr)->dl_primitive = DL_INFO_REQ;
- mq->b_wptr = mq->b_rptr + sizeof(dl_info_req_t);
- dlpi_request(q, mq, us);
- error = 0;
- break;
-
- case SIOCGIFNETMASK:
- case SIOCSIFNETMASK:
- case SIOCGIFADDR:
- case SIOCGIFDSTADDR:
- case SIOCSIFDSTADDR:
- case SIOCGIFMETRIC:
- error = 0;
- break;
-#endif /* LACHTCP */
-
- default:
- if (us->ppa == 0 || us->ppa->lowerq == 0)
- break;
- us->ioc_id = iop->ioc_id;
- error = -1;
- switch (iop->ioc_cmd) {
- case PPPIO_GETSTAT:
- case PPPIO_GETCSTAT:
- if (us->flags & US_LASTMOD) {
- error = EINVAL;
- break;
- }
- putnext(us->ppa->lowerq, mp);
- break;
- default:
- if (us->flags & US_PRIV)
- putnext(us->ppa->lowerq, mp);
- else {
- DPRINT1("ppp ioctl %x rejected\n", iop->ioc_cmd);
- error = EPERM;
- }
- break;
- }
- break;
- }
-
- if (error > 0) {
- iop->ioc_error = error;
- mp->b_datap->db_type = M_IOCNAK;
- qreply(q, mp);
- } else if (error == 0) {
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
- }
- break;
-
- case M_FLUSH:
- if (us->flags & US_DBGLOG)
- DPRINT2("ppp/%d: flush %x\n", us->mn, *mp->b_rptr);
- if (*mp->b_rptr & FLUSHW)
- flushq(q, FLUSHDATA);
- if (*mp->b_rptr & FLUSHR) {
- *mp->b_rptr &= ~FLUSHW;
- qreply(q, mp);
- } else
- freemsg(mp);
- break;
-
- default:
- freemsg(mp);
- break;
- }
- return 0;
-}
-
-#ifndef NO_DLPI
-static void
-dlpi_request(q, mp, us)
- queue_t *q;
- mblk_t *mp;
- upperstr_t *us;
-{
- union DL_primitives *d = (union DL_primitives *) mp->b_rptr;
- int size = mp->b_wptr - mp->b_rptr;
- mblk_t *reply, *np;
- upperstr_t *ppa, *os;
- int sap, len;
- dl_info_ack_t *info;
- dl_bind_ack_t *ackp;
-#if DL_CURRENT_VERSION >= 2
- dl_phys_addr_ack_t *paddrack;
- static struct ether_addr eaddr = {0};
-#endif
-
- if (us->flags & US_DBGLOG)
- DPRINT3("ppp/%d: dlpi prim %x len=%d\n", us->mn,
- d->dl_primitive, size);
- switch (d->dl_primitive) {
- case DL_INFO_REQ:
- if (size < sizeof(dl_info_req_t))
- goto badprim;
- if ((reply = allocb(sizeof(dl_info_ack_t), BPRI_HI)) == 0)
- break; /* should do bufcall */
- reply->b_datap->db_type = M_PCPROTO;
- info = (dl_info_ack_t *) reply->b_wptr;
- reply->b_wptr += sizeof(dl_info_ack_t);
- bzero((caddr_t) info, sizeof(dl_info_ack_t));
- info->dl_primitive = DL_INFO_ACK;
- info->dl_max_sdu = us->ppa? us->ppa->mtu: PPP_MAXMTU;
- info->dl_min_sdu = 1;
- info->dl_addr_length = sizeof(uint);
- info->dl_mac_type = DL_ETHER; /* a bigger lie */
- info->dl_current_state = us->state;
- info->dl_service_mode = DL_CLDLS;
- info->dl_provider_style = DL_STYLE2;
-#if DL_CURRENT_VERSION >= 2
- info->dl_sap_length = sizeof(uint);
- info->dl_version = DL_CURRENT_VERSION;
-#endif
- qreply(q, reply);
- break;
-
- case DL_ATTACH_REQ:
- if (size < sizeof(dl_attach_req_t))
- goto badprim;
- if (us->state != DL_UNATTACHED || us->ppa != 0) {
- dlpi_error(q, us, DL_ATTACH_REQ, DL_OUTSTATE, 0);
- break;
- }
- for (ppa = ppas; ppa != 0; ppa = ppa->nextppa)
- if (ppa->ppa_id == d->attach_req.dl_ppa)
- break;
- if (ppa == 0) {
- dlpi_error(q, us, DL_ATTACH_REQ, DL_BADPPA, 0);
- break;
- }
- us->ppa = ppa;
- qwriter(q, mp, attach_ppa, PERIM_OUTER);
- return;
-
- case DL_DETACH_REQ:
- if (size < sizeof(dl_detach_req_t))
- goto badprim;
- if (us->state != DL_UNBOUND || us->ppa == 0) {
- dlpi_error(q, us, DL_DETACH_REQ, DL_OUTSTATE, 0);
- break;
- }
- qwriter(q, mp, detach_ppa, PERIM_OUTER);
- return;
-
- case DL_BIND_REQ:
- if (size < sizeof(dl_bind_req_t))
- goto badprim;
- if (us->state != DL_UNBOUND || us->ppa == 0) {
- dlpi_error(q, us, DL_BIND_REQ, DL_OUTSTATE, 0);
- break;
- }
-#if 0
- /* apparently this test fails (unnecessarily?) on some systems */
- if (d->bind_req.dl_service_mode != DL_CLDLS) {
- dlpi_error(q, us, DL_BIND_REQ, DL_UNSUPPORTED, 0);
- break;
- }
-#endif
-
- /* saps must be valid PPP network protocol numbers,
- except that we accept ETHERTYPE_IP in place of PPP_IP. */
- sap = d->bind_req.dl_sap;
- us->req_sap = sap;
-
-#if defined(SOL2)
- if (us->flags & US_DBGLOG)
- DPRINT2("DL_BIND_REQ: ip gives sap = 0x%x, us = 0x%x", sap, us);
-
- if (sap == ETHERTYPE_IP) /* normal IFF_IPV4 */
- sap = PPP_IP;
- else if (sap == ETHERTYPE_IPV6) /* when IFF_IPV6 is set */
- sap = PPP_IPV6;
- else if (sap == ETHERTYPE_ALLSAP) /* snoop gives sap of 0 */
- sap = PPP_ALLSAP;
- else {
- DPRINT2("DL_BIND_REQ: unrecognized sap = 0x%x, us = 0x%x", sap, us);
- dlpi_error(q, us, DL_BIND_REQ, DL_BADADDR, 0);
- break;
- }
-#else
- if (sap == ETHERTYPE_IP)
- sap = PPP_IP;
- if (sap < 0x21 || sap > 0x3fff || (sap & 0x101) != 1) {
- dlpi_error(q, us, DL_BIND_REQ, DL_BADADDR, 0);
- break;
- }
-#endif /* defined(SOL2) */
-
- /* check that no other stream is bound to this sap already. */
- for (os = us->ppa; os != 0; os = os->next)
- if (os->sap == sap)
- break;
- if (os != 0) {
- dlpi_error(q, us, DL_BIND_REQ, DL_NOADDR, 0);
- break;
- }
-
- us->sap = sap;
- us->state = DL_IDLE;
-
- if ((reply = allocb(sizeof(dl_bind_ack_t) + sizeof(uint),
- BPRI_HI)) == 0)
- break; /* should do bufcall */
- ackp = (dl_bind_ack_t *) reply->b_wptr;
- reply->b_wptr += sizeof(dl_bind_ack_t) + sizeof(uint);
- reply->b_datap->db_type = M_PCPROTO;
- bzero((caddr_t) ackp, sizeof(dl_bind_ack_t));
- ackp->dl_primitive = DL_BIND_ACK;
- ackp->dl_sap = sap;
- ackp->dl_addr_length = sizeof(uint);
- ackp->dl_addr_offset = sizeof(dl_bind_ack_t);
- *(uint *)(ackp+1) = sap;
- qreply(q, reply);
- break;
-
- case DL_UNBIND_REQ:
- if (size < sizeof(dl_unbind_req_t))
- goto badprim;
- if (us->state != DL_IDLE) {
- dlpi_error(q, us, DL_UNBIND_REQ, DL_OUTSTATE, 0);
- break;
- }
- us->sap = -1;
- us->state = DL_UNBOUND;
-#ifdef LACHTCP
- us->ppa->ifstats.ifs_active = 0;
-#endif
- dlpi_ok(q, DL_UNBIND_REQ);
- break;
-
- case DL_UNITDATA_REQ:
- if (size < sizeof(dl_unitdata_req_t))
- goto badprim;
- if (us->state != DL_IDLE) {
- dlpi_error(q, us, DL_UNITDATA_REQ, DL_OUTSTATE, 0);
- break;
- }
- if ((ppa = us->ppa) == 0) {
- cmn_err(CE_CONT, "ppp: in state dl_idle but ppa == 0?\n");
- break;
- }
- len = mp->b_cont == 0? 0: msgdsize(mp->b_cont);
- if (len > ppa->mtu) {
- DPRINT2("dlpi data too large (%d > %d)\n", len, ppa->mtu);
- break;
- }
-
-#if defined(SOL2)
- /*
- * Should there be any promiscuous stream(s), send the data
- * up for each promiscuous stream that we recognize.
- */
- if (mp->b_cont)
- promisc_sendup(ppa, mp->b_cont, us->sap, 0);
-#endif /* defined(SOL2) */
-
- mp->b_band = 0;
-#ifdef PRIOQ
- /* Extract s_port & d_port from IP-packet, the code is a bit
- dirty here, but so am I, too... */
- if (mp->b_datap->db_type == M_PROTO && us->sap == PPP_IP
- && mp->b_cont != 0) {
- u_char *bb, *tlh;
- int iphlen, len;
- u_short *ptr;
- u_char band_unset, cur_band, syn;
- u_short s_port, d_port;
-
- bb = mp->b_cont->b_rptr; /* bb points to IP-header*/
- len = mp->b_cont->b_wptr - mp->b_cont->b_rptr;
- syn = 0;
- s_port = IPPORT_DEFAULT;
- d_port = IPPORT_DEFAULT;
- if (len >= 20) { /* 20 = minimum length of IP header */
- iphlen = (bb[0] & 0x0f) * 4;
- tlh = bb + iphlen;
- len -= iphlen;
- switch (bb[9]) {
- case IPPROTO_TCP:
- if (len >= 20) { /* min length of TCP header */
- s_port = (tlh[0] << 8) + tlh[1];
- d_port = (tlh[2] << 8) + tlh[3];
- syn = tlh[13] & 0x02;
- }
- break;
- case IPPROTO_UDP:
- if (len >= 8) { /* min length of UDP header */
- s_port = (tlh[0] << 8) + tlh[1];
- d_port = (tlh[2] << 8) + tlh[3];
- }
- break;
- }
- }
-
- /*
- * Now calculate b_band for this packet from the
- * port-priority table.
- */
- ptr = prioq_table;
- cur_band = max_band;
- band_unset = 1;
- while (*ptr) {
- while (*ptr && band_unset)
- if (s_port == *ptr || d_port == *ptr++) {
- mp->b_band = cur_band;
- band_unset = 0;
- break;
- }
- ptr++;
- cur_band--;
- }
- if (band_unset)
- mp->b_band = def_band;
- /* It may be usable to urge SYN packets a bit */
- if (syn)
- mp->b_band++;
- }
-#endif /* PRIOQ */
- /* this assumes PPP_HDRLEN <= sizeof(dl_unitdata_req_t) */
- if (mp->b_datap->db_ref > 1) {
- np = allocb(PPP_HDRLEN, BPRI_HI);
- if (np == 0)
- break; /* gak! */
- np->b_cont = mp->b_cont;
- mp->b_cont = 0;
- freeb(mp);
- mp = np;
- } else
- mp->b_datap->db_type = M_DATA;
- /* XXX should use dl_dest_addr_offset/length here,
- but we would have to translate ETHERTYPE_IP -> PPP_IP */
- mp->b_wptr = mp->b_rptr + PPP_HDRLEN;
- mp->b_rptr[0] = PPP_ALLSTATIONS;
- mp->b_rptr[1] = PPP_UI;
- mp->b_rptr[2] = us->sap >> 8;
- mp->b_rptr[3] = us->sap;
- if (pass_packet(us, mp, 1)) {
- if (!send_data(mp, us))
- putq(q, mp);
- }
- return;
-
-#if DL_CURRENT_VERSION >= 2
- case DL_PHYS_ADDR_REQ:
- if (size < sizeof(dl_phys_addr_req_t))
- goto badprim;
-
- /*
- * Don't check state because ifconfig sends this one down too
- */
-
- if ((reply = allocb(sizeof(dl_phys_addr_ack_t)+ETHERADDRL,
- BPRI_HI)) == 0)
- break; /* should do bufcall */
- reply->b_datap->db_type = M_PCPROTO;
- paddrack = (dl_phys_addr_ack_t *) reply->b_wptr;
- reply->b_wptr += sizeof(dl_phys_addr_ack_t);
- bzero((caddr_t) paddrack, sizeof(dl_phys_addr_ack_t)+ETHERADDRL);
- paddrack->dl_primitive = DL_PHYS_ADDR_ACK;
- paddrack->dl_addr_length = ETHERADDRL;
- paddrack->dl_addr_offset = sizeof(dl_phys_addr_ack_t);
- bcopy(&eaddr, reply->b_wptr, ETHERADDRL);
- reply->b_wptr += ETHERADDRL;
- qreply(q, reply);
- break;
-
-#if defined(SOL2)
- case DL_PROMISCON_REQ:
- if (size < sizeof(dl_promiscon_req_t))
- goto badprim;
- us->flags |= US_PROMISC;
- dlpi_ok(q, DL_PROMISCON_REQ);
- break;
-
- case DL_PROMISCOFF_REQ:
- if (size < sizeof(dl_promiscoff_req_t))
- goto badprim;
- us->flags &= ~US_PROMISC;
- dlpi_ok(q, DL_PROMISCOFF_REQ);
- break;
-#else
- case DL_PROMISCON_REQ: /* fall thru */
- case DL_PROMISCOFF_REQ: /* fall thru */
-#endif /* defined(SOL2) */
-#endif /* DL_CURRENT_VERSION >= 2 */
-
-#if DL_CURRENT_VERSION >= 2
- case DL_SET_PHYS_ADDR_REQ:
- case DL_SUBS_BIND_REQ:
- case DL_SUBS_UNBIND_REQ:
- case DL_ENABMULTI_REQ:
- case DL_DISABMULTI_REQ:
- case DL_XID_REQ:
- case DL_TEST_REQ:
- case DL_REPLY_UPDATE_REQ:
- case DL_REPLY_REQ:
- case DL_DATA_ACK_REQ:
-#endif
- case DL_CONNECT_REQ:
- case DL_TOKEN_REQ:
- dlpi_error(q, us, d->dl_primitive, DL_NOTSUPPORTED, 0);
- break;
-
- case DL_CONNECT_RES:
- case DL_DISCONNECT_REQ:
- case DL_RESET_REQ:
- case DL_RESET_RES:
- dlpi_error(q, us, d->dl_primitive, DL_OUTSTATE, 0);
- break;
-
- case DL_UDQOS_REQ:
- dlpi_error(q, us, d->dl_primitive, DL_BADQOSTYPE, 0);
- break;
-
-#if DL_CURRENT_VERSION >= 2
- case DL_TEST_RES:
- case DL_XID_RES:
- break;
-#endif
-
- default:
- cmn_err(CE_CONT, "ppp: unknown dlpi prim 0x%x\n", d->dl_primitive);
- /* fall through */
- badprim:
- dlpi_error(q, us, d->dl_primitive, DL_BADPRIM, 0);
- break;
- }
- freemsg(mp);
-}
-
-static void
-dlpi_error(q, us, prim, err, uerr)
- queue_t *q;
- upperstr_t *us;
- int prim, err, uerr;
-{
- mblk_t *reply;
- dl_error_ack_t *errp;
-
- if (us->flags & US_DBGLOG)
- DPRINT3("ppp/%d: dlpi error, prim=%x, err=%x\n", us->mn, prim, err);
- reply = allocb(sizeof(dl_error_ack_t), BPRI_HI);
- if (reply == 0)
- return; /* XXX should do bufcall */
- reply->b_datap->db_type = M_PCPROTO;
- errp = (dl_error_ack_t *) reply->b_wptr;
- reply->b_wptr += sizeof(dl_error_ack_t);
- errp->dl_primitive = DL_ERROR_ACK;
- errp->dl_error_primitive = prim;
- errp->dl_errno = err;
- errp->dl_unix_errno = uerr;
- qreply(q, reply);
-}
-
-static void
-dlpi_ok(q, prim)
- queue_t *q;
- int prim;
-{
- mblk_t *reply;
- dl_ok_ack_t *okp;
-
- reply = allocb(sizeof(dl_ok_ack_t), BPRI_HI);
- if (reply == 0)
- return; /* XXX should do bufcall */
- reply->b_datap->db_type = M_PCPROTO;
- okp = (dl_ok_ack_t *) reply->b_wptr;
- reply->b_wptr += sizeof(dl_ok_ack_t);
- okp->dl_primitive = DL_OK_ACK;
- okp->dl_correct_primitive = prim;
- qreply(q, reply);
-}
-#endif /* NO_DLPI */
-
-static int
-pass_packet(us, mp, outbound)
- upperstr_t *us;
- mblk_t *mp;
- int outbound;
-{
- int pass;
- upperstr_t *ppa;
-
- if ((ppa = us->ppa) == 0) {
- freemsg(mp);
- return 0;
- }
-
-#ifdef FILTER_PACKETS
- pass = ip_hard_filter(us, mp, outbound);
-#else
- /*
- * Here is where we might, in future, decide whether to pass
- * or drop the packet, and whether it counts as link activity.
- */
- pass = 1;
-#endif /* FILTER_PACKETS */
-
- if (pass < 0) {
- /* pass only if link already up, and don't update time */
- if (ppa->lowerq == 0) {
- freemsg(mp);
- return 0;
- }
- pass = 1;
- } else if (pass) {
- if (outbound)
- ppa->last_sent = time;
- else
- ppa->last_recv = time;
- }
-
- return pass;
-}
-
-/*
- * We have some data to send down to the lower stream (or up the
- * control stream, if we don't have a lower stream attached).
- * Returns 1 if the message was dealt with, 0 if it wasn't able
- * to be sent on and should therefore be queued up.
- */
-static int
-send_data(mp, us)
- mblk_t *mp;
- upperstr_t *us;
-{
- upperstr_t *ppa;
-
- if ((us->flags & US_BLOCKED) || us->npmode == NPMODE_QUEUE)
- return 0;
- ppa = us->ppa;
- if (ppa == 0 || us->npmode == NPMODE_DROP || us->npmode == NPMODE_ERROR) {
- if (us->flags & US_DBGLOG)
- DPRINT2("ppp/%d: dropping pkt (npmode=%d)\n", us->mn, us->npmode);
- freemsg(mp);
- return 1;
- }
- if (ppa->lowerq == 0) {
- /* try to send it up the control stream */
- if (bcanputnext(ppa->q, mp->b_band)) {
- /*
- * The message seems to get corrupted for some reason if
- * we just send the message up as it is, so we send a copy.
- */
- mblk_t *np = copymsg(mp);
- freemsg(mp);
- if (np != 0)
- putnext(ppa->q, np);
- return 1;
- }
- } else {
- if (bcanputnext(ppa->lowerq, mp->b_band)) {
- MT_ENTER(&ppa->stats_lock);
- ppa->stats.ppp_opackets++;
- ppa->stats.ppp_obytes += msgdsize(mp);
-#ifdef INCR_OPACKETS
- INCR_OPACKETS(ppa);
-#endif
- MT_EXIT(&ppa->stats_lock);
- /*
- * The lower queue is only ever detached while holding an
- * exclusive lock on the whole driver. So we can be confident
- * that the lower queue is still there.
- */
- putnext(ppa->lowerq, mp);
- return 1;
- }
- }
- us->flags |= US_BLOCKED;
- return 0;
-}
-
-/*
- * Allocate a new PPA id and link this stream into the list of PPAs.
- * This procedure is called with an exclusive lock on all queues in
- * this driver.
- */
-static void
-new_ppa(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *us, *up, **usp;
- int ppa_id;
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("new_ppa: q_ptr = 0!\n");
- return;
- }
-
- usp = &ppas;
- ppa_id = 0;
- while ((up = *usp) != 0 && ppa_id == up->ppa_id) {
- ++ppa_id;
- usp = &up->nextppa;
- }
- us->ppa_id = ppa_id;
- us->ppa = us;
- us->next = 0;
- us->nextppa = *usp;
- *usp = us;
- us->flags |= US_CONTROL;
- us->npmode = NPMODE_PASS;
-
- us->mtu = PPP_MTU;
- us->mru = PPP_MRU;
-
-#ifdef SOL2
- /*
- * Create a kstats record for our statistics, so netstat -i works.
- */
- if (us->kstats == 0) {
- char unit[32];
-
- sprintf(unit, "ppp%d", us->ppa->ppa_id);
- us->kstats = kstat_create("ppp", us->ppa->ppa_id, unit,
- "net", KSTAT_TYPE_NAMED, 4, 0);
- if (us->kstats != 0) {
- kstat_named_t *kn = KSTAT_NAMED_PTR(us->kstats);
-
- strcpy(kn[0].name, "ipackets");
- kn[0].data_type = KSTAT_DATA_ULONG;
- strcpy(kn[1].name, "ierrors");
- kn[1].data_type = KSTAT_DATA_ULONG;
- strcpy(kn[2].name, "opackets");
- kn[2].data_type = KSTAT_DATA_ULONG;
- strcpy(kn[3].name, "oerrors");
- kn[3].data_type = KSTAT_DATA_ULONG;
- kstat_install(us->kstats);
- }
- }
-#endif /* SOL2 */
-
- *(int *)mp->b_cont->b_rptr = ppa_id;
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
-}
-
-static void
-attach_ppa(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *us, *t;
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("attach_ppa: q_ptr = 0!\n");
- return;
- }
-
-#ifndef NO_DLPI
- us->state = DL_UNBOUND;
-#endif
- for (t = us->ppa; t->next != 0; t = t->next)
- ;
- t->next = us;
- us->next = 0;
- if (mp->b_datap->db_type == M_IOCTL) {
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
- } else {
-#ifndef NO_DLPI
- dlpi_ok(q, DL_ATTACH_REQ);
-#endif
- }
-}
-
-static void
-detach_ppa(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *us, *t;
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("detach_ppa: q_ptr = 0!\n");
- return;
- }
-
- for (t = us->ppa; t->next != 0; t = t->next)
- if (t->next == us) {
- t->next = us->next;
- break;
- }
- us->next = 0;
- us->ppa = 0;
-#ifndef NO_DLPI
- us->state = DL_UNATTACHED;
- dlpi_ok(q, DL_DETACH_REQ);
-#endif
-}
-
-/*
- * We call this with qwriter in order to give the upper queue procedures
- * the guarantee that the lower queue is not going to go away while
- * they are executing.
- */
-static void
-detach_lower(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *us;
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("detach_lower: q_ptr = 0!\n");
- return;
- }
-
- LOCK_LOWER_W;
- us->lowerq->q_ptr = 0;
- RD(us->lowerq)->q_ptr = 0;
- us->lowerq = 0;
- UNLOCK_LOWER;
-
- /* Unblock streams which now feed back up the control stream. */
- qenable(us->q);
-
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
-}
-
-static int
-pppuwsrv(q)
- queue_t *q;
-{
- upperstr_t *us, *as;
- mblk_t *mp;
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("pppuwsrv: q_ptr = 0!\n");
- return 0;
- }
-
- /*
- * If this is a control stream, then this service procedure
- * probably got enabled because of flow control in the lower
- * stream being enabled (or because of the lower stream going
- * away). Therefore we enable the service procedure of all
- * attached upper streams.
- */
- if (us->flags & US_CONTROL) {
- for (as = us->next; as != 0; as = as->next)
- qenable(WR(as->q));
- }
-
- /* Try to send on any data queued here. */
- us->flags &= ~US_BLOCKED;
- while ((mp = getq(q)) != 0) {
- if (!send_data(mp, us)) {
- putbq(q, mp);
- break;
- }
- }
-
- return 0;
-}
-
-/* should never get called... */
-static int
-ppplwput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- putnext(q, mp);
- return 0;
-}
-
-static int
-ppplwsrv(q)
- queue_t *q;
-{
- queue_t *uq;
-
- /*
- * Flow control has back-enabled this stream:
- * enable the upper write service procedure for
- * the upper control stream for this lower stream.
- */
- LOCK_LOWER_R;
- uq = (queue_t *) q->q_ptr;
- if (uq != 0)
- qenable(uq);
- UNLOCK_LOWER;
- return 0;
-}
-
-/*
- * This should only get called for control streams.
- */
-static int
-pppurput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *ppa, *us;
- int proto, len;
- struct iocblk *iop;
-
- ppa = (upperstr_t *) q->q_ptr;
- if (ppa == 0) {
- DPRINT("pppurput: q_ptr = 0!\n");
- return 0;
- }
-
- switch (mp->b_datap->db_type) {
- case M_CTL:
- MT_ENTER(&ppa->stats_lock);
- switch (*mp->b_rptr) {
- case PPPCTL_IERROR:
-#ifdef INCR_IERRORS
- INCR_IERRORS(ppa);
-#endif
- ppa->stats.ppp_ierrors++;
- break;
- case PPPCTL_OERROR:
-#ifdef INCR_OERRORS
- INCR_OERRORS(ppa);
-#endif
- ppa->stats.ppp_oerrors++;
- break;
- }
- MT_EXIT(&ppa->stats_lock);
- freemsg(mp);
- break;
-
- case M_IOCACK:
- case M_IOCNAK:
- /*
- * Attempt to match up the response with the stream
- * that the request came from.
- */
- iop = (struct iocblk *) mp->b_rptr;
- for (us = ppa; us != 0; us = us->next)
- if (us->ioc_id == iop->ioc_id)
- break;
- if (us == 0)
- freemsg(mp);
- else
- putnext(us->q, mp);
- break;
-
- case M_HANGUP:
- /*
- * The serial device has hung up. We don't want to send
- * the M_HANGUP message up to pppd because that will stop
- * us from using the control stream any more. Instead we
- * send a zero-length message as an end-of-file indication.
- */
- freemsg(mp);
- mp = allocb(1, BPRI_HI);
- if (mp == 0) {
- DPRINT1("ppp/%d: couldn't allocate eof message!\n", ppa->mn);
- break;
- }
- putnext(ppa->q, mp);
- break;
-
- default:
- if (mp->b_datap->db_type == M_DATA) {
- len = msgdsize(mp);
- if (mp->b_wptr - mp->b_rptr < PPP_HDRLEN) {
- PULLUP(mp, PPP_HDRLEN);
- if (mp == 0) {
- DPRINT1("ppp_urput: msgpullup failed (len=%d)\n", len);
- break;
- }
- }
- MT_ENTER(&ppa->stats_lock);
- ppa->stats.ppp_ipackets++;
- ppa->stats.ppp_ibytes += len;
-#ifdef INCR_IPACKETS
- INCR_IPACKETS(ppa);
-#endif
- MT_EXIT(&ppa->stats_lock);
-
- proto = PPP_PROTOCOL(mp->b_rptr);
-
-#if defined(SOL2)
- /*
- * Should there be any promiscuous stream(s), send the data
- * up for each promiscuous stream that we recognize.
- */
- promisc_sendup(ppa, mp, proto, 1);
-#endif /* defined(SOL2) */
-
- if (proto < 0x8000 && (us = find_dest(ppa, proto)) != 0) {
- /*
- * A data packet for some network protocol.
- * Queue it on the upper stream for that protocol.
- * XXX could we just putnext it? (would require thought)
- * The rblocked flag is there to ensure that we keep
- * messages in order for each network protocol.
- */
- if (!pass_packet(us, mp, 0))
- break;
- if (!us->rblocked && !canput(us->q))
- us->rblocked = 1;
- if (!us->rblocked)
- putq(us->q, mp);
- else
- putq(q, mp);
- break;
- }
- }
- /*
- * A control frame, a frame for an unknown protocol,
- * or some other message type.
- * Send it up to pppd via the control stream.
- */
- if (queclass(mp) == QPCTL || canputnext(ppa->q))
- putnext(ppa->q, mp);
- else
- putq(q, mp);
- break;
- }
-
- return 0;
-}
-
-static int
-pppursrv(q)
- queue_t *q;
-{
- upperstr_t *us, *as;
- mblk_t *mp, *hdr;
-#ifndef NO_DLPI
- dl_unitdata_ind_t *ud;
-#endif
- int proto;
-
- us = (upperstr_t *) q->q_ptr;
- if (us == 0) {
- DPRINT("pppursrv: q_ptr = 0!\n");
- return 0;
- }
-
- if (us->flags & US_CONTROL) {
- /*
- * A control stream.
- * If there is no lower queue attached, run the write service
- * routines of other upper streams attached to this PPA.
- */
- if (us->lowerq == 0) {
- as = us;
- do {
- if (as->flags & US_BLOCKED)
- qenable(WR(as->q));
- as = as->next;
- } while (as != 0);
- }
-
- /*
- * Messages get queued on this stream's read queue if they
- * can't be queued on the read queue of the attached stream
- * that they are destined for. This is for flow control -
- * when this queue fills up, the lower read put procedure will
- * queue messages there and the flow control will propagate
- * down from there.
- */
- while ((mp = getq(q)) != 0) {
- proto = PPP_PROTOCOL(mp->b_rptr);
- if (proto < 0x8000 && (as = find_dest(us, proto)) != 0) {
- if (!canput(as->q))
- break;
- putq(as->q, mp);
- } else {
- if (!canputnext(q))
- break;
- putnext(q, mp);
- }
- }
- if (mp) {
- putbq(q, mp);
- } else {
- /* can now put stuff directly on network protocol streams again */
- for (as = us->next; as != 0; as = as->next)
- as->rblocked = 0;
- }
-
- /*
- * If this stream has a lower stream attached,
- * enable the read queue's service routine.
- * XXX we should really only do this if the queue length
- * has dropped below the low-water mark.
- */
- if (us->lowerq != 0)
- qenable(RD(us->lowerq));
-
- } else {
- /*
- * A network protocol stream. Put a DLPI header on each
- * packet and send it on.
- * (Actually, it seems that the IP module will happily
- * accept M_DATA messages without the DL_UNITDATA_IND header.)
- */
- while ((mp = getq(q)) != 0) {
- if (!canputnext(q)) {
- putbq(q, mp);
- break;
- }
-#ifndef NO_DLPI
- proto = PPP_PROTOCOL(mp->b_rptr);
- mp->b_rptr += PPP_HDRLEN;
- hdr = allocb(sizeof(dl_unitdata_ind_t) + 2 * sizeof(uint),
- BPRI_MED);
- if (hdr == 0) {
- /* XXX should put it back and use bufcall */
- freemsg(mp);
- continue;
- }
- hdr->b_datap->db_type = M_PROTO;
- ud = (dl_unitdata_ind_t *) hdr->b_wptr;
- hdr->b_wptr += sizeof(dl_unitdata_ind_t) + 2 * sizeof(uint);
- hdr->b_cont = mp;
- ud->dl_primitive = DL_UNITDATA_IND;
- ud->dl_dest_addr_length = sizeof(uint);
- ud->dl_dest_addr_offset = sizeof(dl_unitdata_ind_t);
- ud->dl_src_addr_length = sizeof(uint);
- ud->dl_src_addr_offset = ud->dl_dest_addr_offset + sizeof(uint);
-#if DL_CURRENT_VERSION >= 2
- ud->dl_group_address = 0;
-#endif
- /* Send the DLPI client the data with the SAP they requested,
- (e.g. ETHERTYPE_IP) rather than the PPP protocol number
- (e.g. PPP_IP) */
- ((uint *)(ud + 1))[0] = us->req_sap; /* dest SAP */
- ((uint *)(ud + 1))[1] = us->req_sap; /* src SAP */
- putnext(q, hdr);
-#else /* NO_DLPI */
- putnext(q, mp);
-#endif /* NO_DLPI */
- }
- /*
- * Now that we have consumed some packets from this queue,
- * enable the control stream's read service routine so that we
- * can process any packets for us that might have got queued
- * there for flow control reasons.
- */
- if (us->ppa)
- qenable(us->ppa->q);
- }
-
- return 0;
-}
-
-static upperstr_t *
-find_dest(ppa, proto)
- upperstr_t *ppa;
- int proto;
-{
- upperstr_t *us;
-
- for (us = ppa->next; us != 0; us = us->next)
- if (proto == us->sap)
- break;
- return us;
-}
-
-#if defined (SOL2)
-/*
- * Test upstream promiscuous conditions. As of now, only pass IPv4 and
- * Ipv6 packets upstream (let PPP packets be decoded elsewhere).
- */
-static upperstr_t *
-find_promisc(us, proto)
- upperstr_t *us;
- int proto;
-{
-
- if ((proto != PPP_IP) && (proto != PPP_IPV6))
- return (upperstr_t *)0;
-
- for ( ; us; us = us->next) {
- if ((us->flags & US_PROMISC) && (us->state == DL_IDLE))
- return us;
- }
-
- return (upperstr_t *)0;
-}
-
-/*
- * Prepend an empty Ethernet header to msg for snoop, et al.
- */
-static mblk_t *
-prepend_ether(us, mp, proto)
- upperstr_t *us;
- mblk_t *mp;
- int proto;
-{
- mblk_t *eh;
- int type;
-
- if ((eh = allocb(sizeof(struct ether_header), BPRI_HI)) == 0) {
- freemsg(mp);
- return (mblk_t *)0;
- }
-
- if (proto == PPP_IP)
- type = ETHERTYPE_IP;
- else if (proto == PPP_IPV6)
- type = ETHERTYPE_IPV6;
- else
- type = proto; /* What else? Let decoder decide */
-
- eh->b_wptr += sizeof(struct ether_header);
- bzero((caddr_t)eh->b_rptr, sizeof(struct ether_header));
- ((struct ether_header *)eh->b_rptr)->ether_type = htons((short)type);
- eh->b_cont = mp;
- return (eh);
-}
-
-/*
- * Prepend DL_UNITDATA_IND mblk to msg
- */
-static mblk_t *
-prepend_udind(us, mp, proto)
- upperstr_t *us;
- mblk_t *mp;
- int proto;
-{
- dl_unitdata_ind_t *dlu;
- mblk_t *dh;
- size_t size;
-
- size = sizeof(dl_unitdata_ind_t);
- if ((dh = allocb(size, BPRI_MED)) == 0) {
- freemsg(mp);
- return (mblk_t *)0;
- }
-
- dh->b_datap->db_type = M_PROTO;
- dh->b_wptr = dh->b_datap->db_lim;
- dh->b_rptr = dh->b_wptr - size;
-
- dlu = (dl_unitdata_ind_t *)dh->b_rptr;
- dlu->dl_primitive = DL_UNITDATA_IND;
- dlu->dl_dest_addr_length = 0;
- dlu->dl_dest_addr_offset = sizeof(dl_unitdata_ind_t);
- dlu->dl_src_addr_length = 0;
- dlu->dl_src_addr_offset = sizeof(dl_unitdata_ind_t);
- dlu->dl_group_address = 0;
-
- dh->b_cont = mp;
- return (dh);
-}
-
-/*
- * For any recognized promiscuous streams, send data upstream
- */
-static void
-promisc_sendup(ppa, mp, proto, skip)
- upperstr_t *ppa;
- mblk_t *mp;
- int proto, skip;
-{
- mblk_t *dup_mp, *dup_dup_mp;
- upperstr_t *prus, *nprus;
-
- if ((prus = find_promisc(ppa, proto)) != 0) {
- if (dup_mp = dupmsg(mp)) {
-
- if (skip)
- dup_mp->b_rptr += PPP_HDRLEN;
-
- for ( ; nprus = find_promisc(prus->next, proto);
- prus = nprus) {
-
- if (dup_dup_mp = dupmsg(dup_mp)) {
- if (canputnext(prus->q)) {
- if (prus->flags & US_RAWDATA) {
- dup_dup_mp = prepend_ether(prus, dup_dup_mp, proto);
- putnext(prus->q, dup_dup_mp);
- } else {
- dup_dup_mp = prepend_udind(prus, dup_dup_mp, proto);
- putnext(prus->q, dup_dup_mp);
- }
- } else {
- DPRINT("ppp_urput: data to promisc q dropped\n");
- freemsg(dup_dup_mp);
- }
- }
- }
-
- if (canputnext(prus->q)) {
- if (prus->flags & US_RAWDATA) {
- dup_mp = prepend_ether(prus, dup_mp, proto);
- putnext(prus->q, dup_mp);
- } else {
- dup_mp = prepend_udind(prus, dup_mp, proto);
- putnext(prus->q, dup_mp);
- }
- } else {
- DPRINT("ppp_urput: data to promisc q dropped\n");
- freemsg(dup_mp);
- }
- }
- }
-}
-#endif /* defined(SOL2) */
-
-/*
- * We simply put the message on to the associated upper control stream
- * (either here or in ppplrsrv). That way we enter the perimeters
- * before looking through the list of attached streams to decide which
- * stream it should go up.
- */
-static int
-ppplrput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- queue_t *uq;
- struct iocblk *iop;
-
- switch (mp->b_datap->db_type) {
- case M_IOCTL:
- iop = (struct iocblk *) mp->b_rptr;
- iop->ioc_error = EINVAL;
- mp->b_datap->db_type = M_IOCNAK;
- qreply(q, mp);
- return 0;
- case M_FLUSH:
- if (*mp->b_rptr & FLUSHR)
- flushq(q, FLUSHDATA);
- if (*mp->b_rptr & FLUSHW) {
- *mp->b_rptr &= ~FLUSHR;
- qreply(q, mp);
- } else
- freemsg(mp);
- return 0;
- }
-
- /*
- * If we can't get the lower lock straight away, queue this one
- * rather than blocking, to avoid the possibility of deadlock.
- */
- if (!TRYLOCK_LOWER_R) {
- putq(q, mp);
- return 0;
- }
-
- /*
- * Check that we're still connected to the driver.
- */
- uq = (queue_t *) q->q_ptr;
- if (uq == 0) {
- UNLOCK_LOWER;
- DPRINT1("ppplrput: q = %x, uq = 0??\n", q);
- freemsg(mp);
- return 0;
- }
-
- /*
- * Try to forward the message to the put routine for the upper
- * control stream for this lower stream.
- * If there are already messages queued here, queue this one so
- * they don't get out of order.
- */
- if (queclass(mp) == QPCTL || (qsize(q) == 0 && canput(uq)))
- put(uq, mp);
- else
- putq(q, mp);
-
- UNLOCK_LOWER;
- return 0;
-}
-
-static int
-ppplrsrv(q)
- queue_t *q;
-{
- mblk_t *mp;
- queue_t *uq;
-
- /*
- * Packets get queued here for flow control reasons
- * or if the lrput routine couldn't get the lower lock
- * without blocking.
- */
- LOCK_LOWER_R;
- uq = (queue_t *) q->q_ptr;
- if (uq == 0) {
- UNLOCK_LOWER;
- flushq(q, FLUSHALL);
- DPRINT1("ppplrsrv: q = %x, uq = 0??\n", q);
- return 0;
- }
- while ((mp = getq(q)) != 0) {
- if (queclass(mp) == QPCTL || canput(uq))
- put(uq, mp);
- else {
- putbq(q, mp);
- break;
- }
- }
- UNLOCK_LOWER;
- return 0;
-}
-
-static int
-putctl2(q, type, code, val)
- queue_t *q;
- int type, code, val;
-{
- mblk_t *mp;
-
- mp = allocb(2, BPRI_HI);
- if (mp == 0)
- return 0;
- mp->b_datap->db_type = type;
- mp->b_wptr[0] = code;
- mp->b_wptr[1] = val;
- mp->b_wptr += 2;
- putnext(q, mp);
- return 1;
-}
-
-static int
-putctl4(q, type, code, val)
- queue_t *q;
- int type, code, val;
-{
- mblk_t *mp;
-
- mp = allocb(4, BPRI_HI);
- if (mp == 0)
- return 0;
- mp->b_datap->db_type = type;
- mp->b_wptr[0] = code;
- ((short *)mp->b_wptr)[1] = val;
- mp->b_wptr += 4;
- putnext(q, mp);
- return 1;
-}
-
-static void
-debug_dump(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- upperstr_t *us;
- queue_t *uq, *lq;
-
- DPRINT("ppp upper streams:\n");
- for (us = minor_devs; us != 0; us = us->nextmn) {
- uq = us->q;
- DPRINT3(" %d: q=%x rlev=%d",
- us->mn, uq, (uq? qsize(uq): 0));
- DPRINT3(" wlev=%d flags=0x%b", (uq? qsize(WR(uq)): 0),
- us->flags, "\020\1priv\2control\3blocked\4last");
- DPRINT3(" state=%x sap=%x req_sap=%x", us->state, us->sap,
- us->req_sap);
- if (us->ppa == 0)
- DPRINT(" ppa=?\n");
- else
- DPRINT1(" ppa=%d\n", us->ppa->ppa_id);
- if (us->flags & US_CONTROL) {
- lq = us->lowerq;
- DPRINT3(" control for %d lq=%x rlev=%d",
- us->ppa_id, lq, (lq? qsize(RD(lq)): 0));
- DPRINT3(" wlev=%d mru=%d mtu=%d\n",
- (lq? qsize(lq): 0), us->mru, us->mtu);
- }
- }
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
-}
-
-#ifdef FILTER_PACKETS
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/udp.h>
-#include <netinet/tcp.h>
-
-#define MAX_IPHDR 128 /* max TCP/IP header size */
-
-
-/* The following table contains a hard-coded list of protocol/port pairs.
- * Any matching packets are either discarded unconditionally, or,
- * if ok_if_link_up is non-zero when a connection does not currently exist
- * (i.e., they go through if the connection is present, but never initiate
- * a dial-out).
- * This idea came from a post by dm@garage.uun.org (David Mazieres)
- */
-static struct pktfilt_tab {
- int proto;
- u_short port;
- u_short ok_if_link_up;
-} pktfilt_tab[] = {
- { IPPROTO_UDP, 520, 1 }, /* RIP, ok to pass if link is up */
- { IPPROTO_UDP, 123, 1 }, /* NTP, don't keep up the link for it */
- { -1, 0, 0 } /* terminator entry has port == -1 */
-};
-
-
-static int
-ip_hard_filter(us, mp, outbound)
- upperstr_t *us;
- mblk_t *mp;
- int outbound;
-{
- struct ip *ip;
- struct pktfilt_tab *pft;
- mblk_t *temp_mp;
- int proto;
- int len, hlen;
-
-
- /* Note, the PPP header has already been pulled up in all cases */
- proto = PPP_PROTOCOL(mp->b_rptr);
- if (us->flags & US_DBGLOG)
- DPRINT3("ppp/%d: filter, proto=0x%x, out=%d\n", us->mn, proto, outbound);
-
- switch (proto)
- {
- case PPP_IP:
- if ((mp->b_wptr - mp->b_rptr) == PPP_HDRLEN && mp->b_cont != 0) {
- temp_mp = mp->b_cont;
- len = msgdsize(temp_mp);
- hlen = (len < MAX_IPHDR) ? len : MAX_IPHDR;
- PULLUP(temp_mp, hlen);
- if (temp_mp == 0) {
- DPRINT2("ppp/%d: filter, pullup next failed, len=%d\n",
- us->mn, hlen);
- mp->b_cont = 0; /* PULLUP() freed the rest */
- freemsg(mp);
- return 0;
- }
- ip = (struct ip *)mp->b_cont->b_rptr;
- }
- else {
- len = msgdsize(mp);
- hlen = (len < (PPP_HDRLEN+MAX_IPHDR)) ? len : (PPP_HDRLEN+MAX_IPHDR);
- PULLUP(mp, hlen);
- if (mp == 0) {
- DPRINT2("ppp/%d: filter, pullup failed, len=%d\n",
- us->mn, hlen);
- return 0;
- }
- ip = (struct ip *)(mp->b_rptr + PPP_HDRLEN);
- }
-
- /* For IP traffic, certain packets (e.g., RIP) may be either
- * 1. ignored - dropped completely
- * 2. will not initiate a connection, but
- * will be passed if a connection is currently up.
- */
- for (pft=pktfilt_tab; pft->proto != -1; pft++) {
- if (ip->ip_p == pft->proto) {
- switch(pft->proto) {
- case IPPROTO_UDP:
- if (((struct udphdr *) &((int *)ip)[ip->ip_hl])->uh_dport
- == htons(pft->port)) goto endfor;
- break;
- case IPPROTO_TCP:
- if (((struct tcphdr *) &((int *)ip)[ip->ip_hl])->th_dport
- == htons(pft->port)) goto endfor;
- break;
- }
- }
- }
- endfor:
- if (pft->proto != -1) {
- if (us->flags & US_DBGLOG)
- DPRINT3("ppp/%d: found IP pkt, proto=0x%x (%d)\n",
- us->mn, pft->proto, pft->port);
- /* Discard if not connected, or if not pass_with_link_up */
- /* else, if link is up let go by, but don't update time */
- return pft->ok_if_link_up? -1: 0;
- }
- break;
- } /* end switch (proto) */
-
- return 1;
-}
-#endif /* FILTER_PACKETS */
-
diff --git a/mdk-stage1/ppp/modules/ppp_ahdlc.c b/mdk-stage1/ppp/modules/ppp_ahdlc.c
deleted file mode 100644
index d0b961258..000000000
--- a/mdk-stage1/ppp/modules/ppp_ahdlc.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/*
- * ppp_ahdlc.c - STREAMS module for doing PPP asynchronous HDLC.
- *
- * Re-written by Adi Masputra <adi.masputra@sun.com>, based on
- * the original ppp_ahdlc.c
- *
- * Copyright (c) 2000 by Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies.
- *
- * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-/*
- * This file is used under Solaris 2, SVR4, SunOS 4, and Digital UNIX.
- */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stream.h>
-#include <sys/errno.h>
-
-#ifdef SVR4
-#include <sys/conf.h>
-#include <sys/kmem.h>
-#include <sys/cmn_err.h>
-#include <sys/ddi.h>
-#else
-#include <sys/user.h>
-#ifdef __osf__
-#include <sys/cmn_err.h>
-#endif
-#endif /* SVR4 */
-
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include "ppp_mod.h"
-
-/*
- * Right now, mutex is only enabled for Solaris 2.x
- */
-#if defined(SOL2)
-#define USE_MUTEX
-#endif /* SOL2 */
-
-/*
- * intpointer_t and uintpointer_t are signed and unsigned integer types
- * large enough to hold any data pointer; that is, data pointers can be
- * assigned into or from these integer types without losing precision.
- * On recent Solaris releases, these types are defined in sys/int_types.h,
- * but not on SunOS 4.x or the earlier Solaris versions.
- */
-#if defined(_LP64) || defined(_I32LPx)
-typedef long intpointer_t;
-typedef unsigned long uintpointer_t;
-#else
-typedef int intpointer_t;
-typedef unsigned int uintpointer_t;
-#endif
-
-MOD_OPEN_DECL(ahdlc_open);
-MOD_CLOSE_DECL(ahdlc_close);
-static int ahdlc_wput __P((queue_t *, mblk_t *));
-static int ahdlc_rput __P((queue_t *, mblk_t *));
-static void ahdlc_encode __P((queue_t *, mblk_t *));
-static void ahdlc_decode __P((queue_t *, mblk_t *));
-static int msg_byte __P((mblk_t *, unsigned int));
-
-#if defined(SOL2)
-/*
- * Don't send HDLC start flag is last transmit is within 1.5 seconds -
- * FLAG_TIME is defined is microseconds
- */
-#define FLAG_TIME 1500
-#define ABS(x) (x >= 0 ? x : (-x))
-#endif /* SOL2 */
-
-/*
- * Extract byte i of message mp
- */
-#define MSG_BYTE(mp, i) ((i) < (mp)->b_wptr - (mp)->b_rptr? (mp)->b_rptr[i]: \
- msg_byte((mp), (i)))
-
-/*
- * Is this LCP packet one we have to transmit using LCP defaults?
- */
-#define LCP_USE_DFLT(mp) (1 <= (code = MSG_BYTE((mp), 4)) && code <= 7)
-
-/*
- * Standard STREAMS declarations
- */
-static struct module_info minfo = {
- 0x7d23, "ppp_ahdl", 0, INFPSZ, 32768, 512
-};
-
-static struct qinit rinit = {
- ahdlc_rput, NULL, ahdlc_open, ahdlc_close, NULL, &minfo, NULL
-};
-
-static struct qinit winit = {
- ahdlc_wput, NULL, NULL, NULL, NULL, &minfo, NULL
-};
-
-#if defined(SVR4) && !defined(SOL2)
-int phdldevflag = 0;
-#define ppp_ahdlcinfo phdlinfo
-#endif /* defined(SVR4) && !defined(SOL2) */
-
-struct streamtab ppp_ahdlcinfo = {
- &rinit, /* ptr to st_rdinit */
- &winit, /* ptr to st_wrinit */
- NULL, /* ptr to st_muxrinit */
- NULL, /* ptr to st_muxwinit */
-#if defined(SUNOS4)
- NULL /* ptr to ptr to st_modlist */
-#endif /* SUNOS4 */
-};
-
-#if defined(SUNOS4)
-int ppp_ahdlc_count = 0; /* open counter */
-#endif /* SUNOS4 */
-
-/*
- * Per-stream state structure
- */
-typedef struct ahdlc_state {
-#if defined(USE_MUTEX)
- kmutex_t lock; /* lock for this structure */
-#endif /* USE_MUTEX */
- int flags; /* link flags */
- mblk_t *rx_buf; /* ptr to receive buffer */
- int rx_buf_size; /* receive buffer size */
- ushort_t infcs; /* calculated rx HDLC FCS */
- u_int32_t xaccm[8]; /* 256-bit xmit ACCM */
- u_int32_t raccm; /* 32-bit rcv ACCM */
- int mtu; /* interface MTU */
- int mru; /* link MRU */
- int unit; /* current PPP unit number */
- struct pppstat stats; /* statistic structure */
-#if defined(SOL2)
- clock_t flag_time; /* time in usec between flags */
- clock_t lbolt; /* last updated lbolt */
-#endif /* SOL2 */
-} ahdlc_state_t;
-
-/*
- * Values for flags
- */
-#define ESCAPED 0x100 /* last saw escape char on input */
-#define IFLUSH 0x200 /* flushing input due to error */
-
-/*
- * RCV_B7_1, etc., defined in net/pppio.h, are stored in flags also.
- */
-#define RCV_FLAGS (RCV_B7_1|RCV_B7_0|RCV_ODDP|RCV_EVNP)
-
-/*
- * FCS lookup table as calculated by genfcstab.
- */
-static u_short fcstab[256] = {
- 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
- 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
- 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
- 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
- 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
- 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
- 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
- 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
- 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
- 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
- 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
- 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
- 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
- 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
- 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
- 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
- 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
- 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
- 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
- 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
- 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
- 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
- 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
- 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
- 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
- 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
- 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
- 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
- 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
- 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
- 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
- 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-
-static u_int32_t paritytab[8] =
-{
- 0x96696996, 0x69969669, 0x69969669, 0x96696996,
- 0x69969669, 0x96696996, 0x96696996, 0x69969669
-};
-
-/*
- * STREAMS module open (entry) point
- */
-MOD_OPEN(ahdlc_open)
-{
- ahdlc_state_t *state;
-
- /*
- * Return if it's already opened
- */
- if (q->q_ptr) {
- return 0;
- }
-
- /*
- * This can only be opened as a module
- */
- if (sflag != MODOPEN) {
- return 0;
- }
-
- state = (ahdlc_state_t *) ALLOC_NOSLEEP(sizeof(ahdlc_state_t));
- if (state == 0)
- OPEN_ERROR(ENOSR);
- bzero((caddr_t) state, sizeof(ahdlc_state_t));
-
- q->q_ptr = (caddr_t) state;
- WR(q)->q_ptr = (caddr_t) state;
-
-#if defined(USE_MUTEX)
- mutex_init(&state->lock, NULL, MUTEX_DEFAULT, NULL);
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
-
- state->xaccm[0] = ~0; /* escape 0x00 through 0x1f */
- state->xaccm[3] = 0x60000000; /* escape 0x7d and 0x7e */
- state->mru = PPP_MRU; /* default of 1500 bytes */
-#if defined(SOL2)
- state->flag_time = drv_usectohz(FLAG_TIME);
-#endif /* SOL2 */
-
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
-
-#if defined(SUNOS4)
- ppp_ahdlc_count++;
-#endif /* SUNOS4 */
-
- qprocson(q);
-
- return 0;
-}
-
-/*
- * STREAMS module close (exit) point
- */
-MOD_CLOSE(ahdlc_close)
-{
- ahdlc_state_t *state;
-
- qprocsoff(q);
-
- state = (ahdlc_state_t *) q->q_ptr;
-
- if (state == 0) {
- DPRINT("state == 0 in ahdlc_close\n");
- return 0;
- }
-
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
-
- if (state->rx_buf != 0) {
- freemsg(state->rx_buf);
- state->rx_buf = 0;
- }
-
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
- mutex_destroy(&state->lock);
-#endif /* USE_MUTEX */
-
- FREE(q->q_ptr, sizeof(ahdlc_state_t));
- q->q_ptr = NULL;
- OTHERQ(q)->q_ptr = NULL;
-
-#if defined(SUNOS4)
- if (ppp_ahdlc_count)
- ppp_ahdlc_count--;
-#endif /* SUNOS4 */
-
- return 0;
-}
-
-/*
- * Write side put routine
- */
-static int
-ahdlc_wput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- ahdlc_state_t *state;
- struct iocblk *iop;
- int error;
- mblk_t *np;
- struct ppp_stats *psp;
-
- state = (ahdlc_state_t *) q->q_ptr;
- if (state == 0) {
- DPRINT("state == 0 in ahdlc_wput\n");
- freemsg(mp);
- return 0;
- }
-
- switch (mp->b_datap->db_type) {
- case M_DATA:
- /*
- * A data packet - do character-stuffing and FCS, and
- * send it onwards.
- */
- ahdlc_encode(q, mp);
- freemsg(mp);
- break;
-
- case M_IOCTL:
- iop = (struct iocblk *) mp->b_rptr;
- error = EINVAL;
- switch (iop->ioc_cmd) {
- case PPPIO_XACCM:
- if ((iop->ioc_count < sizeof(u_int32_t)) ||
- (iop->ioc_count > sizeof(ext_accm))) {
- break;
- }
- if (mp->b_cont == 0) {
- DPRINT1("ahdlc_wput/%d: PPPIO_XACCM b_cont = 0!\n", state->unit);
- break;
- }
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- bcopy((caddr_t)mp->b_cont->b_rptr, (caddr_t)state->xaccm,
- iop->ioc_count);
- state->xaccm[2] &= ~0x40000000; /* don't escape 0x5e */
- state->xaccm[3] |= 0x60000000; /* do escape 0x7d, 0x7e */
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- iop->ioc_count = 0;
- error = 0;
- break;
-
- case PPPIO_RACCM:
- if (iop->ioc_count != sizeof(u_int32_t))
- break;
- if (mp->b_cont == 0) {
- DPRINT1("ahdlc_wput/%d: PPPIO_RACCM b_cont = 0!\n", state->unit);
- break;
- }
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- bcopy((caddr_t)mp->b_cont->b_rptr, (caddr_t)&state->raccm,
- sizeof(u_int32_t));
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- iop->ioc_count = 0;
- error = 0;
- break;
-
- case PPPIO_GCLEAN:
- np = allocb(sizeof(int), BPRI_HI);
- if (np == 0) {
- error = ENOSR;
- break;
- }
- if (mp->b_cont != 0)
- freemsg(mp->b_cont);
- mp->b_cont = np;
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- *(int *)np->b_wptr = state->flags & RCV_FLAGS;
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- np->b_wptr += sizeof(int);
- iop->ioc_count = sizeof(int);
- error = 0;
- break;
-
- case PPPIO_GETSTAT:
- np = allocb(sizeof(struct ppp_stats), BPRI_HI);
- if (np == 0) {
- error = ENOSR;
- break;
- }
- if (mp->b_cont != 0)
- freemsg(mp->b_cont);
- mp->b_cont = np;
- psp = (struct ppp_stats *) np->b_wptr;
- np->b_wptr += sizeof(struct ppp_stats);
- bzero((caddr_t)psp, sizeof(struct ppp_stats));
- psp->p = state->stats;
- iop->ioc_count = sizeof(struct ppp_stats);
- error = 0;
- break;
-
- case PPPIO_LASTMOD:
- /* we knew this anyway */
- error = 0;
- break;
-
- default:
- error = -1;
- break;
- }
-
- if (error < 0)
- putnext(q, mp);
- else if (error == 0) {
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
- } else {
- mp->b_datap->db_type = M_IOCNAK;
- iop->ioc_count = 0;
- iop->ioc_error = error;
- qreply(q, mp);
- }
- break;
-
- case M_CTL:
- switch (*mp->b_rptr) {
- case PPPCTL_MTU:
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- state->mtu = ((unsigned short *)mp->b_rptr)[1];
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- freemsg(mp);
- break;
- case PPPCTL_MRU:
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- state->mru = ((unsigned short *)mp->b_rptr)[1];
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- freemsg(mp);
- break;
- case PPPCTL_UNIT:
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- state->unit = mp->b_rptr[1];
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- break;
- default:
- putnext(q, mp);
- }
- break;
-
- default:
- putnext(q, mp);
- }
-
- return 0;
-}
-
-/*
- * Read side put routine
- */
-static int
-ahdlc_rput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- ahdlc_state_t *state;
-
- state = (ahdlc_state_t *) q->q_ptr;
- if (state == 0) {
- DPRINT("state == 0 in ahdlc_rput\n");
- freemsg(mp);
- return 0;
- }
-
- switch (mp->b_datap->db_type) {
- case M_DATA:
- ahdlc_decode(q, mp);
- freemsg(mp);
- break;
-
- case M_HANGUP:
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
- if (state->rx_buf != 0) {
- /* XXX would like to send this up for debugging */
- freemsg(state->rx_buf);
- state->rx_buf = 0;
- }
- state->flags = IFLUSH;
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- putnext(q, mp);
- break;
-
- default:
- putnext(q, mp);
- }
- return 0;
-}
-
-/*
- * Extract bit c from map m, to determine if c needs to be escaped
- */
-#define IN_TX_MAP(c, m) ((m)[(c) >> 5] & (1 << ((c) & 0x1f)))
-
-static void
-ahdlc_encode(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- ahdlc_state_t *state;
- u_int32_t *xaccm, loc_xaccm[8];
- ushort_t fcs;
- size_t outmp_len;
- mblk_t *outmp, *tmp;
- uchar_t *dp, fcs_val;
- int is_lcp, code;
-#if defined(SOL2)
- clock_t lbolt;
-#endif /* SOL2 */
-
- if (msgdsize(mp) < 4) {
- return;
- }
-
- state = (ahdlc_state_t *)q->q_ptr;
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
-
- /*
- * Allocate an output buffer large enough to handle a case where all
- * characters need to be escaped
- */
- outmp_len = (msgdsize(mp) << 1) + /* input block x 2 */
- (sizeof(fcs) << 2) + /* HDLC FCS x 4 */
- (sizeof(uchar_t) << 1); /* HDLC flags x 2 */
-
- outmp = allocb(outmp_len, BPRI_MED);
- if (outmp == NULL) {
- state->stats.ppp_oerrors++;
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
- putctl1(RD(q)->q_next, M_CTL, PPPCTL_OERROR);
- return;
- }
-
-#if defined(SOL2)
- /*
- * Check if our last transmit happenned within flag_time, using
- * the system's LBOLT value in clock ticks
- */
- if (drv_getparm(LBOLT, &lbolt) != -1) {
- if (ABS((clock_t)lbolt - state->lbolt) > state->flag_time) {
- *outmp->b_wptr++ = PPP_FLAG;
- }
- state->lbolt = lbolt;
- } else {
- *outmp->b_wptr++ = PPP_FLAG;
- }
-#else
- /*
- * If the driver below still has a message to process, skip the
- * HDLC flag, otherwise, put one in the beginning
- */
- if (qsize(q->q_next) == 0) {
- *outmp->b_wptr++ = PPP_FLAG;
- }
-#endif
-
- /*
- * All control characters must be escaped for LCP packets with code
- * values between 1 (Conf-Req) and 7 (Code-Rej).
- */
- is_lcp = ((MSG_BYTE(mp, 0) == PPP_ALLSTATIONS) &&
- (MSG_BYTE(mp, 1) == PPP_UI) &&
- (MSG_BYTE(mp, 2) == (PPP_LCP >> 8)) &&
- (MSG_BYTE(mp, 3) == (PPP_LCP & 0xff)) &&
- LCP_USE_DFLT(mp));
-
- xaccm = state->xaccm;
- if (is_lcp) {
- bcopy((caddr_t)state->xaccm, (caddr_t)loc_xaccm, sizeof(loc_xaccm));
- loc_xaccm[0] = ~0; /* force escape on 0x00 through 0x1f */
- xaccm = loc_xaccm;
- }
-
- fcs = PPP_INITFCS; /* Initial FCS is 0xffff */
-
- /*
- * Process this block and the rest (if any) attached to the this one
- */
- for (tmp = mp; tmp; tmp = tmp->b_cont) {
- if (tmp->b_datap->db_type == M_DATA) {
- for (dp = tmp->b_rptr; dp < tmp->b_wptr; dp++) {
- fcs = PPP_FCS(fcs, *dp);
- if (IN_TX_MAP(*dp, xaccm)) {
- *outmp->b_wptr++ = PPP_ESCAPE;
- *outmp->b_wptr++ = *dp ^ PPP_TRANS;
- } else {
- *outmp->b_wptr++ = *dp;
- }
- }
- } else {
- continue; /* skip if db_type is something other than M_DATA */
- }
- }
-
- /*
- * Append the HDLC FCS, making sure that escaping is done on any
- * necessary bytes
- */
- fcs_val = (fcs ^ 0xffff) & 0xff;
- if (IN_TX_MAP(fcs_val, xaccm)) {
- *outmp->b_wptr++ = PPP_ESCAPE;
- *outmp->b_wptr++ = fcs_val ^ PPP_TRANS;
- } else {
- *outmp->b_wptr++ = fcs_val;
- }
-
- fcs_val = ((fcs ^ 0xffff) >> 8) & 0xff;
- if (IN_TX_MAP(fcs_val, xaccm)) {
- *outmp->b_wptr++ = PPP_ESCAPE;
- *outmp->b_wptr++ = fcs_val ^ PPP_TRANS;
- } else {
- *outmp->b_wptr++ = fcs_val;
- }
-
- /*
- * And finally, append the HDLC flag, and send it away
- */
- *outmp->b_wptr++ = PPP_FLAG;
-
- state->stats.ppp_obytes += msgdsize(outmp);
- state->stats.ppp_opackets++;
-
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
-
- putnext(q, outmp);
- return;
-}
-
-/*
- * Checks the 32-bit receive ACCM to see if the byte needs un-escaping
- */
-#define IN_RX_MAP(c, m) ((((unsigned int) (uchar_t) (c)) < 0x20) && \
- (m) & (1 << (c)))
-
-
-/*
- * Process received characters.
- */
-static void
-ahdlc_decode(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- ahdlc_state_t *state;
- mblk_t *om;
- uchar_t *dp;
- ushort_t fcs;
-#if defined(SOL2)
- mblk_t *zmp;
-#endif /* SOL2 */
-
-#if defined(SOL2)
- /*
- * In case the driver (or something below) doesn't send
- * data upstream in one message block, concatenate everything
- */
- if (!((mp->b_wptr - mp->b_rptr == msgdsize(mp)) &&
- ((intpointer_t)mp->b_rptr % sizeof(intpointer_t) == 0))) {
-
- zmp = msgpullup(mp, -1);
- freemsg(mp);
- mp = zmp;
- if (mp == 0)
- return;
- }
-#endif /* SOL2 */
-
- state = (ahdlc_state_t *) q->q_ptr;
-
-#if defined(USE_MUTEX)
- mutex_enter(&state->lock);
-#endif /* USE_MUTEX */
-
- state->stats.ppp_ibytes += msgdsize(mp);
-
- for (dp = mp->b_rptr; dp < mp->b_wptr; dp++) {
-
- /*
- * This should detect the lack of 8-bit communication channel
- * which is necessary for PPP to work. In addition, it also
- * checks on the parity.
- */
- if (*dp & 0x80)
- state->flags |= RCV_B7_1;
- else
- state->flags |= RCV_B7_0;
-
- if (paritytab[*dp >> 5] & (1 << (*dp & 0x1f)))
- state->flags |= RCV_ODDP;
- else
- state->flags |= RCV_EVNP;
-
- /*
- * So we have a HDLC flag ...
- */
- if (*dp == PPP_FLAG) {
-
- /*
- * If we think that it marks the beginning of the frame,
- * then continue to process the next octects
- */
- if ((state->flags & IFLUSH) ||
- (state->rx_buf == 0) ||
- (msgdsize(state->rx_buf) == 0)) {
-
- state->flags &= ~IFLUSH;
- continue;
- }
-
- /*
- * We get here because the above condition isn't true,
- * in which case the HDLC flag was there to mark the end
- * of the frame (or so we think)
- */
- om = state->rx_buf;
-
- if (state->infcs == PPP_GOODFCS) {
- state->stats.ppp_ipackets++;
- adjmsg(om, -PPP_FCSLEN);
- putnext(q, om);
- } else {
- DPRINT2("ppp%d: bad fcs (len=%d)\n",
- state->unit, msgdsize(state->rx_buf));
- freemsg(state->rx_buf);
- state->flags &= ~(IFLUSH | ESCAPED);
- state->stats.ppp_ierrors++;
- putctl1(q->q_next, M_CTL, PPPCTL_IERROR);
- }
-
- state->rx_buf = 0;
- continue;
- }
-
- if (state->flags & IFLUSH) {
- continue;
- }
-
- /*
- * Allocate a receive buffer, large enough to store a frame (after
- * un-escaping) of at least 1500 octets. If MRU is negotiated to
- * be more than the default, then allocate that much. In addition,
- * we add an extra 32-bytes for a fudge factor
- */
- if (state->rx_buf == 0) {
- state->rx_buf_size = (state->mru < PPP_MRU ? PPP_MRU : state->mru);
- state->rx_buf_size += (sizeof(u_int32_t) << 3);
- state->rx_buf = allocb(state->rx_buf_size, BPRI_MED);
-
- /*
- * If allocation fails, try again on the next frame
- */
- if (state->rx_buf == 0) {
- state->flags |= IFLUSH;
- continue;
- }
- state->flags &= ~(IFLUSH | ESCAPED);
- state->infcs = PPP_INITFCS;
- }
-
- if (*dp == PPP_ESCAPE) {
- state->flags |= ESCAPED;
- continue;
- }
-
- /*
- * Make sure we un-escape the necessary characters, as well as the
- * ones in our receive async control character map
- */
- if (state->flags & ESCAPED) {
- *dp ^= PPP_TRANS;
- state->flags &= ~ESCAPED;
- } else if (IN_RX_MAP(*dp, state->raccm))
- continue;
-
- /*
- * Unless the peer lied to us about the negotiated MRU, we should
- * never get a frame which is too long. If it happens, toss it away
- * and grab the next incoming one
- */
- if (msgdsize(state->rx_buf) < state->rx_buf_size) {
- state->infcs = PPP_FCS(state->infcs, *dp);
- *state->rx_buf->b_wptr++ = *dp;
- } else {
- DPRINT2("ppp%d: frame too long (%d)\n",
- state->unit, msgdsize(state->rx_buf));
- freemsg(state->rx_buf);
- state->rx_buf = 0;
- state->flags |= IFLUSH;
- }
- }
-
-#if defined(USE_MUTEX)
- mutex_exit(&state->lock);
-#endif /* USE_MUTEX */
-}
-
-static int
-msg_byte(mp, i)
- mblk_t *mp;
- unsigned int i;
-{
- while (mp != 0 && i >= mp->b_wptr - mp->b_rptr)
- mp = mp->b_cont;
- if (mp == 0)
- return -1;
- return mp->b_rptr[i];
-}
diff --git a/mdk-stage1/ppp/modules/ppp_comp.c b/mdk-stage1/ppp/modules/ppp_comp.c
deleted file mode 100644
index f6eef5ab1..000000000
--- a/mdk-stage1/ppp/modules/ppp_comp.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*
- * ppp_comp.c - STREAMS module for kernel-level compression and CCP support.
- *
- * Copyright (c) 1994 The Australian National University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation is hereby granted, provided that the above copyright
- * notice appears in all copies. This software is provided without any
- * warranty, express or implied. The Australian National University
- * makes no representations about the suitability of this software for
- * any purpose.
- *
- * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
- * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
- * OR MODIFICATIONS.
- *
- * $Id$
- */
-
-/*
- * This file is used under SVR4, Solaris 2, SunOS 4, and Digital UNIX.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/stream.h>
-
-#ifdef SVR4
-#include <sys/conf.h>
-#include <sys/cmn_err.h>
-#include <sys/ddi.h>
-#else
-#include <sys/user.h>
-#ifdef __osf__
-#include <sys/cmn_err.h>
-#endif
-#endif /* SVR4 */
-
-#include <net/ppp_defs.h>
-#include <net/pppio.h>
-#include "ppp_mod.h"
-
-#ifdef __osf__
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#endif
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <net/vjcompress.h>
-
-#define PACKETPTR mblk_t *
-#include <net/ppp-comp.h>
-
-MOD_OPEN_DECL(ppp_comp_open);
-MOD_CLOSE_DECL(ppp_comp_close);
-static int ppp_comp_rput __P((queue_t *, mblk_t *));
-static int ppp_comp_rsrv __P((queue_t *));
-static int ppp_comp_wput __P((queue_t *, mblk_t *));
-static int ppp_comp_wsrv __P((queue_t *));
-static void ppp_comp_ccp __P((queue_t *, mblk_t *, int));
-static int msg_byte __P((mblk_t *, unsigned int));
-
-/* Extract byte i of message mp. */
-#define MSG_BYTE(mp, i) ((i) < (mp)->b_wptr - (mp)->b_rptr? (mp)->b_rptr[i]: \
- msg_byte((mp), (i)))
-
-/* Is this LCP packet one we have to transmit using LCP defaults? */
-#define LCP_USE_DFLT(mp) (1 <= (code = MSG_BYTE((mp), 4)) && code <= 7)
-
-#define PPP_COMP_ID 0xbadf
-static struct module_info minfo = {
-#ifdef PRIOQ
- PPP_COMP_ID, "ppp_comp", 0, INFPSZ, 16512, 16384,
-#else
- PPP_COMP_ID, "ppp_comp", 0, INFPSZ, 16384, 4096,
-#endif
-};
-
-static struct qinit r_init = {
- ppp_comp_rput, ppp_comp_rsrv, ppp_comp_open, ppp_comp_close,
- NULL, &minfo, NULL
-};
-
-static struct qinit w_init = {
- ppp_comp_wput, ppp_comp_wsrv, NULL, NULL, NULL, &minfo, NULL
-};
-
-#if defined(SVR4) && !defined(SOL2)
-int pcmpdevflag = 0;
-#define ppp_compinfo pcmpinfo
-#endif
-struct streamtab ppp_compinfo = {
- &r_init, &w_init, NULL, NULL
-};
-
-int ppp_comp_count; /* number of module instances in use */
-
-#ifdef __osf__
-
-static void ppp_comp_alloc __P((comp_state_t *));
-typedef struct memreq {
- unsigned char comp_opts[20];
- int cmd;
- int thread_status;
- char *returned_mem;
-} memreq_t;
-
-#endif
-
-typedef struct comp_state {
- int flags;
- int mru;
- int mtu;
- int unit;
- struct compressor *xcomp;
- void *xstate;
- struct compressor *rcomp;
- void *rstate;
- struct vjcompress vj_comp;
- int vj_last_ierrors;
- struct pppstat stats;
-#ifdef __osf__
- memreq_t memreq;
- thread_t thread;
-#endif
-} comp_state_t;
-
-
-#ifdef __osf__
-extern task_t first_task;
-#endif
-
-/* Bits in flags are as defined in pppio.h. */
-#define CCP_ERR (CCP_ERROR | CCP_FATALERROR)
-#define LAST_MOD 0x1000000 /* no ppp modules below us */
-#define DBGLOG 0x2000000 /* log debugging stuff */
-
-#define MAX_IPHDR 128 /* max TCP/IP header size */
-#define MAX_VJHDR 20 /* max VJ compressed header size (?) */
-
-#undef MIN /* just in case */
-#define MIN(a, b) ((a) < (b)? (a): (b))
-
-/*
- * List of compressors we know about.
- */
-
-#if DO_BSD_COMPRESS
-extern struct compressor ppp_bsd_compress;
-#endif
-#if DO_DEFLATE
-extern struct compressor ppp_deflate, ppp_deflate_draft;
-#endif
-
-struct compressor *ppp_compressors[] = {
-#if DO_BSD_COMPRESS
- &ppp_bsd_compress,
-#endif
-#if DO_DEFLATE
- &ppp_deflate,
- &ppp_deflate_draft,
-#endif
- NULL
-};
-
-/*
- * STREAMS module entry points.
- */
-MOD_OPEN(ppp_comp_open)
-{
- comp_state_t *cp;
-#ifdef __osf__
- thread_t thread;
-#endif
-
- if (q->q_ptr == NULL) {
- cp = (comp_state_t *) ALLOC_SLEEP(sizeof(comp_state_t));
- if (cp == NULL)
- OPEN_ERROR(ENOSR);
- bzero((caddr_t)cp, sizeof(comp_state_t));
- WR(q)->q_ptr = q->q_ptr = (caddr_t) cp;
- cp->mru = PPP_MRU;
- cp->mtu = PPP_MTU;
- cp->xstate = NULL;
- cp->rstate = NULL;
- vj_compress_init(&cp->vj_comp, -1);
-#ifdef __osf__
- if (!(thread = kernel_thread_w_arg(first_task, ppp_comp_alloc, (void *)cp)))
- OPEN_ERROR(ENOSR);
- cp->thread = thread;
-#endif
- ++ppp_comp_count;
- qprocson(q);
- }
- return 0;
-}
-
-MOD_CLOSE(ppp_comp_close)
-{
- comp_state_t *cp;
-
- qprocsoff(q);
- cp = (comp_state_t *) q->q_ptr;
- if (cp != NULL) {
- if (cp->xstate != NULL)
- (*cp->xcomp->comp_free)(cp->xstate);
- if (cp->rstate != NULL)
- (*cp->rcomp->decomp_free)(cp->rstate);
-#ifdef __osf__
- if (!cp->thread)
- printf("ppp_comp_close: NULL thread!\n");
- else
- thread_terminate(cp->thread);
-#endif
- FREE(cp, sizeof(comp_state_t));
- q->q_ptr = NULL;
- OTHERQ(q)->q_ptr = NULL;
- --ppp_comp_count;
- }
- return 0;
-}
-
-#ifdef __osf__
-
-/* thread for calling back to a compressor's memory allocator
- * Needed for Digital UNIX since it's VM can't handle requests
- * for large amounts of memory without blocking. The thread
- * provides a context in which we can call a memory allocator
- * that may block.
- */
-static void
-ppp_comp_alloc(comp_state_t *cp)
-{
- int len, cmd;
- unsigned char *compressor_options;
- thread_t thread;
- void *(*comp_allocator)();
-
-
-#if defined(MAJOR_VERSION) && (MAJOR_VERSION <= 2)
-
- /* In 2.x and earlier the argument gets passed
- * in the thread structure itself. Yuck.
- */
- thread = current_thread();
- cp = thread->reply_port;
- thread->reply_port = PORT_NULL;
-
-#endif
-
- for (;;) {
- assert_wait((vm_offset_t)&cp->memreq.thread_status, TRUE);
- thread_block();
-
- if (thread_should_halt(current_thread()))
- thread_halt_self();
- cmd = cp->memreq.cmd;
- compressor_options = &cp->memreq.comp_opts[0];
- len = compressor_options[1];
- if (cmd == PPPIO_XCOMP) {
- cp->memreq.returned_mem = cp->xcomp->comp_alloc(compressor_options, len);
- if (!cp->memreq.returned_mem) {
- cp->memreq.thread_status = ENOSR;
- } else {
- cp->memreq.thread_status = 0;
- }
- } else {
- cp->memreq.returned_mem = cp->rcomp->decomp_alloc(compressor_options, len);
- if (!cp->memreq.returned_mem) {
- cp->memreq.thread_status = ENOSR;
- } else {
- cp->memreq.thread_status = 0;
- }
- }
- }
-}
-
-#endif /* __osf__ */
-
-/* here's the deal with memory allocation under Digital UNIX.
- * Some other may also benefit from this...
- * We can't ask for huge chunks of memory in a context where
- * the caller can't be put to sleep (like, here.) The alloc
- * is likely to fail. Instead we do this: the first time we
- * get called, kick off a thread to do the allocation. Return
- * immediately to the caller with EAGAIN, as an indication that
- * they should send down the ioctl again. By the time the
- * second call comes in it's likely that the memory allocation
- * thread will have returned with the requested memory. We will
- * continue to return EAGAIN however until the thread has completed.
- * When it has, we return zero (and the memory) if the allocator
- * was successful and ENOSR otherwise.
- *
- * Callers of the RCOMP and XCOMP ioctls are encouraged (but not
- * required) to loop for some number of iterations with a small
- * delay in the loop body (for instance a 1/10-th second "sleep"
- * via select.)
- */
-static int
-ppp_comp_wput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- struct iocblk *iop;
- comp_state_t *cp;
- int error, len, n;
- int flags, mask;
- mblk_t *np;
- struct compressor **comp;
- struct ppp_stats *psp;
- struct ppp_comp_stats *csp;
- unsigned char *opt_data;
- int nxslots, nrslots;
-
- cp = (comp_state_t *) q->q_ptr;
- if (cp == 0) {
- DPRINT("cp == 0 in ppp_comp_wput\n");
- freemsg(mp);
- return 0;
- }
-
- switch (mp->b_datap->db_type) {
-
- case M_DATA:
- putq(q, mp);
- break;
-
- case M_IOCTL:
- iop = (struct iocblk *) mp->b_rptr;
- error = EINVAL;
- switch (iop->ioc_cmd) {
-
- case PPPIO_CFLAGS:
- /* set/get CCP state */
- if (iop->ioc_count != 2 * sizeof(int))
- break;
- if (mp->b_cont == 0) {
- DPRINT1("ppp_comp_wput/%d: PPPIO_CFLAGS b_cont = 0!\n", cp->unit);
- break;
- }
- flags = ((int *) mp->b_cont->b_rptr)[0];
- mask = ((int *) mp->b_cont->b_rptr)[1];
- cp->flags = (cp->flags & ~mask) | (flags & mask);
- if ((mask & CCP_ISOPEN) && (flags & CCP_ISOPEN) == 0) {
- if (cp->xstate != NULL) {
- (*cp->xcomp->comp_free)(cp->xstate);
- cp->xstate = NULL;
- }
- if (cp->rstate != NULL) {
- (*cp->rcomp->decomp_free)(cp->rstate);
- cp->rstate = NULL;
- }
- cp->flags &= ~CCP_ISUP;
- }
- error = 0;
- iop->ioc_count = sizeof(int);
- ((int *) mp->b_cont->b_rptr)[0] = cp->flags;
- mp->b_cont->b_wptr = mp->b_cont->b_rptr + sizeof(int);
- break;
-
- case PPPIO_VJINIT:
- /*
- * Initialize VJ compressor/decompressor
- */
- if (iop->ioc_count != 2)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("ppp_comp_wput/%d: PPPIO_VJINIT b_cont = 0!\n", cp->unit);
- break;
- }
- nxslots = mp->b_cont->b_rptr[0] + 1;
- nrslots = mp->b_cont->b_rptr[1] + 1;
- if (nxslots > MAX_STATES || nrslots > MAX_STATES)
- break;
- vj_compress_init(&cp->vj_comp, nxslots);
- cp->vj_last_ierrors = cp->stats.ppp_ierrors;
- error = 0;
- iop->ioc_count = 0;
- break;
-
- case PPPIO_XCOMP:
- case PPPIO_RCOMP:
- if (iop->ioc_count <= 0)
- break;
- if (mp->b_cont == 0) {
- DPRINT1("ppp_comp_wput/%d: PPPIO_[XR]COMP b_cont = 0!\n", cp->unit);
- break;
- }
- opt_data = mp->b_cont->b_rptr;
- len = mp->b_cont->b_wptr - opt_data;
- if (len > iop->ioc_count)
- len = iop->ioc_count;
- if (opt_data[1] < 2 || opt_data[1] > len)
- break;
- for (comp = ppp_compressors; *comp != NULL; ++comp)
- if ((*comp)->compress_proto == opt_data[0]) {
- /* here's the handler! */
- error = 0;
-#ifndef __osf__
- if (iop->ioc_cmd == PPPIO_XCOMP) {
- /* A previous call may have fetched memory for a compressor
- * that's now being retired or reset. Free it using it's
- * mechanism for freeing stuff.
- */
- if (cp->xstate != NULL) {
- (*cp->xcomp->comp_free)(cp->xstate);
- cp->xstate = NULL;
- }
- cp->xcomp = *comp;
- cp->xstate = (*comp)->comp_alloc(opt_data, len);
- if (cp->xstate == NULL)
- error = ENOSR;
- } else {
- if (cp->rstate != NULL) {
- (*cp->rcomp->decomp_free)(cp->rstate);
- cp->rstate = NULL;
- }
- cp->rcomp = *comp;
- cp->rstate = (*comp)->decomp_alloc(opt_data, len);
- if (cp->rstate == NULL)
- error = ENOSR;
- }
-#else
- if ((error = cp->memreq.thread_status) != EAGAIN)
- if (iop->ioc_cmd == PPPIO_XCOMP) {
- if (cp->xstate) {
- (*cp->xcomp->comp_free)(cp->xstate);
- cp->xstate = 0;
- }
- /* sanity check for compressor options
- */
- if (sizeof (cp->memreq.comp_opts) < len) {
- printf("can't handle options for compressor %d (%d)\n", opt_data[0],
- opt_data[1]);
- cp->memreq.thread_status = ENOSR;
- cp->memreq.returned_mem = 0;
- }
- /* fill in request for the thread and kick it off
- */
- if (cp->memreq.thread_status == 0 && !cp->memreq.returned_mem) {
- bcopy(opt_data, cp->memreq.comp_opts, len);
- cp->memreq.cmd = PPPIO_XCOMP;
- cp->xcomp = *comp;
- error = cp->memreq.thread_status = EAGAIN;
- thread_wakeup((vm_offset_t)&cp->memreq.thread_status);
- } else {
- cp->xstate = cp->memreq.returned_mem;
- cp->memreq.returned_mem = 0;
- cp->memreq.thread_status = 0;
- }
- } else {
- if (cp->rstate) {
- (*cp->rcomp->decomp_free)(cp->rstate);
- cp->rstate = NULL;
- }
- if (sizeof (cp->memreq.comp_opts) < len) {
- printf("can't handle options for compressor %d (%d)\n", opt_data[0],
- opt_data[1]);
- cp->memreq.thread_status = ENOSR;
- cp->memreq.returned_mem = 0;
- }
- if (cp->memreq.thread_status == 0 && !cp->memreq.returned_mem) {
- bcopy(opt_data, cp->memreq.comp_opts, len);
- cp->memreq.cmd = PPPIO_RCOMP;
- cp->rcomp = *comp;
- error = cp->memreq.thread_status = EAGAIN;
- thread_wakeup((vm_offset_t)&cp->memreq.thread_status);
- } else {
- cp->rstate = cp->memreq.returned_mem;
- cp->memreq.returned_mem = 0;
- cp->memreq.thread_status = 0;
- }
- }
-#endif
- break;
- }
- iop->ioc_count = 0;
- break;
-
- case PPPIO_GETSTAT:
- if ((cp->flags & LAST_MOD) == 0) {
- error = -1; /* let the ppp_ahdl module handle it */
- break;
- }
- np = allocb(sizeof(struct ppp_stats), BPRI_HI);
- if (np == 0) {
- error = ENOSR;
- break;
- }
- if (mp->b_cont != 0)
- freemsg(mp->b_cont);
- mp->b_cont = np;
- psp = (struct ppp_stats *) np->b_wptr;
- np->b_wptr += sizeof(struct ppp_stats);
- iop->ioc_count = sizeof(struct ppp_stats);
- psp->p = cp->stats;
- psp->vj = cp->vj_comp.stats;
- error = 0;
- break;
-
- case PPPIO_GETCSTAT:
- np = allocb(sizeof(struct ppp_comp_stats), BPRI_HI);
- if (np == 0) {
- error = ENOSR;
- break;
- }
- if (mp->b_cont != 0)
- freemsg(mp->b_cont);
- mp->b_cont = np;
- csp = (struct ppp_comp_stats *) np->b_wptr;
- np->b_wptr += sizeof(struct ppp_comp_stats);
- iop->ioc_count = sizeof(struct ppp_comp_stats);
- bzero((caddr_t)csp, sizeof(struct ppp_comp_stats));
- if (cp->xstate != 0)
- (*cp->xcomp->comp_stat)(cp->xstate, &csp->c);
- if (cp->rstate != 0)
- (*cp->rcomp->decomp_stat)(cp->rstate, &csp->d);
- error = 0;
- break;
-
- case PPPIO_DEBUG:
- if (iop->ioc_count != sizeof(int))
- break;
- if (mp->b_cont == 0) {
- DPRINT1("ppp_comp_wput/%d: PPPIO_DEBUG b_cont = 0!\n", cp->unit);
- break;
- }
- n = *(int *)mp->b_cont->b_rptr;
- if (n == PPPDBG_LOG + PPPDBG_COMP) {
- DPRINT1("ppp_comp%d: debug log enabled\n", cp->unit);
- cp->flags |= DBGLOG;
- error = 0;
- iop->ioc_count = 0;
- } else {
- error = -1;
- }
- break;
-
- case PPPIO_LASTMOD:
- cp->flags |= LAST_MOD;
- error = 0;
- break;
-
- default:
- error = -1;
- break;
- }
-
- if (error < 0)
- putnext(q, mp);
- else if (error == 0) {
- mp->b_datap->db_type = M_IOCACK;
- qreply(q, mp);
- } else {
- mp->b_datap->db_type = M_IOCNAK;
- iop->ioc_error = error;
- iop->ioc_count = 0;
- qreply(q, mp);
- }
- break;
-
- case M_CTL:
- switch (*mp->b_rptr) {
- case PPPCTL_MTU:
- cp->mtu = ((unsigned short *)mp->b_rptr)[1];
- break;
- case PPPCTL_MRU:
- cp->mru = ((unsigned short *)mp->b_rptr)[1];
- break;
- case PPPCTL_UNIT:
- cp->unit = mp->b_rptr[1];
- break;
- }
- putnext(q, mp);
- break;
-
- default:
- putnext(q, mp);
- }
-
- return 0;
-}
-
-static int
-ppp_comp_wsrv(q)
- queue_t *q;
-{
- mblk_t *mp, *cmp = NULL;
- comp_state_t *cp;
- int len, proto, type, hlen, code;
- struct ip *ip;
- unsigned char *vjhdr, *dp;
-
- cp = (comp_state_t *) q->q_ptr;
- if (cp == 0) {
- DPRINT("cp == 0 in ppp_comp_wsrv\n");
- return 0;
- }
-
- while ((mp = getq(q)) != 0) {
- /* assert(mp->b_datap->db_type == M_DATA) */
-#ifdef PRIOQ
- if (!bcanputnext(q,mp->b_band))
-#else
- if (!canputnext(q))
-#endif PRIOQ
- {
- putbq(q, mp);
- break;
- }
-
- /*
- * First check the packet length and work out what the protocol is.
- */
- len = msgdsize(mp);
- if (len < PPP_HDRLEN) {
- DPRINT1("ppp_comp_wsrv: bogus short packet (%d)\n", len);
- freemsg(mp);
- cp->stats.ppp_oerrors++;
- putctl1(RD(q)->q_next, M_CTL, PPPCTL_OERROR);
- continue;
- }
- proto = (MSG_BYTE(mp, 2) << 8) + MSG_BYTE(mp, 3);
-
- /*
- * Make sure we've got enough data in the first mblk
- * and that we are its only user.
- */
- if (proto == PPP_CCP)
- hlen = len;
- else if (proto == PPP_IP)
- hlen = PPP_HDRLEN + MAX_IPHDR;
- else
- hlen = PPP_HDRLEN;
- if (hlen > len)
- hlen = len;
- if (mp->b_wptr < mp->b_rptr + hlen || mp->b_datap->db_ref > 1) {
- PULLUP(mp, hlen);
- if (mp == 0) {
- DPRINT1("ppp_comp_wsrv: pullup failed (%d)\n", hlen);
- cp->stats.ppp_oerrors++;
- putctl1(RD(q)->q_next, M_CTL, PPPCTL_OERROR);
- continue;
- }
- }
-
- /*
- * Do VJ compression if requested.
- */
- if (proto == PPP_IP && (cp->flags & COMP_VJC)) {
- ip = (struct ip *) (mp->b_rptr + PPP_HDRLEN);
- if (ip->ip_p == IPPROTO_TCP) {
- type = vj_compress_tcp(ip, len - PPP_HDRLEN, &cp->vj_comp,
- (cp->flags & COMP_VJCCID), &vjhdr);
- switch (type) {
- case TYPE_UNCOMPRESSED_TCP:
- mp->b_rptr[3] = proto = PPP_VJC_UNCOMP;
- break;
- case TYPE_COMPRESSED_TCP:
- dp = vjhdr - PPP_HDRLEN;
- dp[1] = mp->b_rptr[1]; /* copy control field */
- dp[0] = mp->b_rptr[0]; /* copy address field */
- dp[2] = 0; /* set protocol field */
- dp[3] = proto = PPP_VJC_COMP;
- mp->b_rptr = dp;
- break;
- }
- }
- }
-
- /*
- * Do packet compression if enabled.
- */
- if (proto == PPP_CCP)
- ppp_comp_ccp(q, mp, 0);
- else if (proto != PPP_LCP && (cp->flags & CCP_COMP_RUN)
- && cp->xstate != NULL) {
- len = msgdsize(mp);
- (*cp->xcomp->compress)(cp->xstate, &cmp, mp, len,
- (cp->flags & CCP_ISUP? cp->mtu + PPP_HDRLEN: 0));
- if (cmp != NULL) {
-#ifdef PRIOQ
- cmp->b_band=mp->b_band;
-#endif PRIOQ
- freemsg(mp);
- mp = cmp;
- }
- }
-
- /*
- * Do address/control and protocol compression if enabled.
- */
- if ((cp->flags & COMP_AC)
- && !(proto == PPP_LCP && LCP_USE_DFLT(mp))) {
- mp->b_rptr += 2; /* drop the address & ctrl fields */
- if (proto < 0x100 && (cp->flags & COMP_PROT))
- ++mp->b_rptr; /* drop the high protocol byte */
- } else if (proto < 0x100 && (cp->flags & COMP_PROT)) {
- /* shuffle up the address & ctrl fields */
- mp->b_rptr[2] = mp->b_rptr[1];
- mp->b_rptr[1] = mp->b_rptr[0];
- ++mp->b_rptr;
- }
-
- cp->stats.ppp_opackets++;
- cp->stats.ppp_obytes += msgdsize(mp);
- putnext(q, mp);
- }
-
- return 0;
-}
-
-static int
-ppp_comp_rput(q, mp)
- queue_t *q;
- mblk_t *mp;
-{
- comp_state_t *cp;
- struct iocblk *iop;
- struct ppp_stats *psp;
-
- cp = (comp_state_t *) q->q_ptr;
- if (cp == 0) {
- DPRINT("cp == 0 in ppp_comp_rput\n");
- freemsg(mp);
- return 0;
- }
-
- switch (mp->b_datap->db_type) {
-
- case M_DATA:
- putq(q, mp);
- break;
-
- case M_IOCACK:
- iop = (struct iocblk *) mp->b_rptr;
- switch (iop->ioc_cmd) {
- case PPPIO_GETSTAT:
- /*
- * Catch this on the way back from the ppp_ahdl module
- * so we can fill in the VJ stats.
- */
- if (mp->b_cont == 0 || iop->ioc_count != sizeof(struct ppp_stats))
- break;
- psp = (struct ppp_stats *) mp->b_cont->b_rptr;
- psp->vj = cp->vj_comp.stats;
- break;
- }
- putnext(q, mp);
- break;
-
- case M_CTL:
- switch (mp->b_rptr[0]) {
- case PPPCTL_IERROR:
- ++cp->stats.ppp_ierrors;
- break;
- case PPPCTL_OERROR:
- ++cp->stats.ppp_oerrors;
- break;
- }
- putnext(q, mp);
- break;
-
- default:
- putnext(q, mp);
- }
-
- return 0;
-}
-
-static int
-ppp_comp_rsrv(q)
- queue_t *q;
-{
- int proto, rv, i;
- mblk_t *mp, *dmp = NULL, *np;
- uchar_t *dp, *iphdr;
- comp_state_t *cp;
- int len, hlen, vjlen;
- u_int iphlen;
-
- cp = (comp_state_t *) q->q_ptr;
- if (cp == 0) {
- DPRINT("cp == 0 in ppp_comp_rsrv\n");
- return 0;
- }
-
- while ((mp = getq(q)) != 0) {
- /* assert(mp->b_datap->db_type == M_DATA) */
- if (!canputnext(q)) {
- putbq(q, mp);
- break;
- }
-
- len = msgdsize(mp);
- cp->stats.ppp_ibytes += len;
- cp->stats.ppp_ipackets++;
-
- /*
- * First work out the protocol and where the PPP header ends.
- */
- i = 0;
- proto = MSG_BYTE(mp, 0);
- if (proto == PPP_ALLSTATIONS) {
- i = 2;
- proto = MSG_BYTE(mp, 2);
- }
- if ((proto & 1) == 0) {
- ++i;
- proto = (proto << 8) + MSG_BYTE(mp, i);
- }
- hlen = i + 1;
-
- /*
- * Now reconstruct a complete, contiguous PPP header at the
- * start of the packet.
- */
- if (hlen < ((cp->flags & DECOMP_AC)? 0: 2)
- + ((cp->flags & DECOMP_PROT)? 1: 2)) {
- /* count these? */
- goto bad;
- }
- if (mp->b_rptr + hlen > mp->b_wptr) {
- adjmsg(mp, hlen); /* XXX check this call */
- hlen = 0;
- }
- if (hlen != PPP_HDRLEN) {
- /*
- * We need to put some bytes on the front of the packet
- * to make a full-length PPP header.
- * If we can put them in *mp, we do, otherwise we
- * tack another mblk on the front.
- * XXX we really shouldn't need to carry around
- * the address and control at this stage.
- */
- dp = mp->b_rptr + hlen - PPP_HDRLEN;
- if (dp < mp->b_datap->db_base || mp->b_datap->db_ref > 1) {
- np = allocb(PPP_HDRLEN, BPRI_MED);
- if (np == 0)
- goto bad;
- np->b_cont = mp;
- mp->b_rptr += hlen;
- mp = np;
- dp = mp->b_wptr;
- mp->b_wptr += PPP_HDRLEN;
- } else
- mp->b_rptr = dp;
-
- dp[0] = PPP_ALLSTATIONS;
- dp[1] = PPP_UI;
- dp[2] = proto >> 8;
- dp[3] = proto;
- }
-
- /*
- * Now see if we have a compressed packet to decompress,
- * or a CCP packet to take notice of.
- */
- proto = PPP_PROTOCOL(mp->b_rptr);
- if (proto == PPP_CCP) {
- len = msgdsize(mp);
- if (mp->b_wptr < mp->b_rptr + len) {
- PULLUP(mp, len);
- if (mp == 0)
- goto bad;
- }
- ppp_comp_ccp(q, mp, 1);
- } else if (proto == PPP_COMP) {
- if ((cp->flags & CCP_ISUP)
- && (cp->flags & CCP_DECOMP_RUN) && cp->rstate
- && (cp->flags & CCP_ERR) == 0) {
- rv = (*cp->rcomp->decompress)(cp->rstate, mp, &dmp);
- switch (rv) {
- case DECOMP_OK:
- freemsg(mp);
- mp = dmp;
- if (mp == NULL) {
- /* no error, but no packet returned either. */
- continue;
- }
- break;
- case DECOMP_ERROR:
- cp->flags |= CCP_ERROR;
- ++cp->stats.ppp_ierrors;
- putctl1(q->q_next, M_CTL, PPPCTL_IERROR);
- break;
- case DECOMP_FATALERROR:
- cp->flags |= CCP_FATALERROR;
- ++cp->stats.ppp_ierrors;
- putctl1(q->q_next, M_CTL, PPPCTL_IERROR);
- break;
- }
- }
- } else if (cp->rstate && (cp->flags & CCP_DECOMP_RUN)) {
- (*cp->rcomp->incomp)(cp->rstate, mp);
- }
-
- /*
- * Now do VJ decompression.
- */
- proto = PPP_PROTOCOL(mp->b_rptr);
- if (proto == PPP_VJC_COMP || proto == PPP_VJC_UNCOMP) {
- len = msgdsize(mp) - PPP_HDRLEN;
- if ((cp->flags & DECOMP_VJC) == 0 || len <= 0)
- goto bad;
-
- /*
- * Advance past the ppp header.
- * Here we assume that the whole PPP header is in the first mblk.
- */
- np = mp;
- dp = np->b_rptr + PPP_HDRLEN;
- if (dp >= mp->b_wptr) {
- np = np->b_cont;
- dp = np->b_rptr;
- }
-
- /*
- * Make sure we have sufficient contiguous data at this point.
- */
- hlen = (proto == PPP_VJC_COMP)? MAX_VJHDR: MAX_IPHDR;
- if (hlen > len)
- hlen = len;
- if (np->b_wptr < dp + hlen || np->b_datap->db_ref > 1) {
- PULLUP(mp, hlen + PPP_HDRLEN);
- if (mp == 0)
- goto bad;
- np = mp;
- dp = np->b_rptr + PPP_HDRLEN;
- }
-
- if (proto == PPP_VJC_COMP) {
- /*
- * Decompress VJ-compressed packet.
- * First reset compressor if an input error has occurred.
- */
- if (cp->stats.ppp_ierrors != cp->vj_last_ierrors) {
- if (cp->flags & DBGLOG)
- DPRINT1("ppp%d: resetting VJ\n", cp->unit);
- vj_uncompress_err(&cp->vj_comp);
- cp->vj_last_ierrors = cp->stats.ppp_ierrors;
- }
-
- vjlen = vj_uncompress_tcp(dp, np->b_wptr - dp, len,
- &cp->vj_comp, &iphdr, &iphlen);
- if (vjlen < 0) {
- if (cp->flags & DBGLOG)
- DPRINT2("ppp%d: vj_uncomp_tcp failed, pkt len %d\n",
- cp->unit, len);
- ++cp->vj_last_ierrors; /* so we don't reset next time */
- goto bad;
- }
-
- /* drop ppp and vj headers off */
- if (mp != np) {
- freeb(mp);
- mp = np;
- }
- mp->b_rptr = dp + vjlen;
-
- /* allocate a new mblk for the ppp and ip headers */
- if ((np = allocb(iphlen + PPP_HDRLEN + 4, BPRI_MED)) == 0)
- goto bad;
- dp = np->b_rptr; /* prepend mblk with TCP/IP hdr */
- dp[0] = PPP_ALLSTATIONS; /* reconstruct PPP header */
- dp[1] = PPP_UI;
- dp[2] = PPP_IP >> 8;
- dp[3] = PPP_IP;
- bcopy((caddr_t)iphdr, (caddr_t)dp + PPP_HDRLEN, iphlen);
- np->b_wptr = dp + iphlen + PPP_HDRLEN;
- np->b_cont = mp;
-
- /* XXX there seems to be a bug which causes panics in strread
- if we make an mbuf with only the IP header in it :-( */
- if (mp->b_wptr - mp->b_rptr > 4) {
- bcopy((caddr_t)mp->b_rptr, (caddr_t)np->b_wptr, 4);
- mp->b_rptr += 4;
- np->b_wptr += 4;
- } else {
- bcopy((caddr_t)mp->b_rptr, (caddr_t)np->b_wptr,
- mp->b_wptr - mp->b_rptr);
- np->b_wptr += mp->b_wptr - mp->b_rptr;
- np->b_cont = mp->b_cont;
- freeb(mp);
- }
-
- mp = np;
-
- } else {
- /*
- * "Decompress" a VJ-uncompressed packet.
- */
- cp->vj_last_ierrors = cp->stats.ppp_ierrors;
- if (!vj_uncompress_uncomp(dp, hlen, &cp->vj_comp)) {
- if (cp->flags & DBGLOG)
- DPRINT2("ppp%d: vj_uncomp_uncomp failed, pkt len %d\n",
- cp->unit, len);
- ++cp->vj_last_ierrors; /* don't need to reset next time */
- goto bad;
- }
- mp->b_rptr[3] = PPP_IP; /* fix up the PPP protocol field */
- }
- }
-
- putnext(q, mp);
- continue;
-
- bad:
- if (mp != 0)
- freemsg(mp);
- cp->stats.ppp_ierrors++;
- putctl1(q->q_next, M_CTL, PPPCTL_IERROR);
- }
-
- return 0;
-}
-
-/*
- * Handle a CCP packet being sent or received.
- * Here all the data in the packet is in a single mbuf.
- */
-static void
-ppp_comp_ccp(q, mp, rcvd)
- queue_t *q;
- mblk_t *mp;
- int rcvd;
-{
- int len, clen;
- comp_state_t *cp;
- unsigned char *dp;
-
- len = msgdsize(mp);
- if (len < PPP_HDRLEN + CCP_HDRLEN)
- return;
-
- cp = (comp_state_t *) q->q_ptr;
- dp = mp->b_rptr + PPP_HDRLEN;
- len -= PPP_HDRLEN;
- clen = CCP_LENGTH(dp);
- if (clen > len)
- return;
-
- switch (CCP_CODE(dp)) {
- case CCP_CONFREQ:
- case CCP_TERMREQ:
- case CCP_TERMACK:
- cp->flags &= ~CCP_ISUP;
- break;
-
- case CCP_CONFACK:
- if ((cp->flags & (CCP_ISOPEN | CCP_ISUP)) == CCP_ISOPEN
- && clen >= CCP_HDRLEN + CCP_OPT_MINLEN
- && clen >= CCP_HDRLEN + CCP_OPT_LENGTH(dp + CCP_HDRLEN)) {
- if (!rcvd) {
- if (cp->xstate != NULL
- && (*cp->xcomp->comp_init)
- (cp->xstate, dp + CCP_HDRLEN, clen - CCP_HDRLEN,
- cp->unit, 0, ((cp->flags & DBGLOG) != 0)))
- cp->flags |= CCP_COMP_RUN;
- } else {
- if (cp->rstate != NULL
- && (*cp->rcomp->decomp_init)
- (cp->rstate, dp + CCP_HDRLEN, clen - CCP_HDRLEN,
- cp->unit, 0, cp->mru, ((cp->flags & DBGLOG) != 0)))
- cp->flags = (cp->flags & ~CCP_ERR) | CCP_DECOMP_RUN;
- }
- }
- break;
-
- case CCP_RESETACK:
- if (cp->flags & CCP_ISUP) {
- if (!rcvd) {
- if (cp->xstate && (cp->flags & CCP_COMP_RUN))
- (*cp->xcomp->comp_reset)(cp->xstate);
- } else {
- if (cp->rstate && (cp->flags & CCP_DECOMP_RUN)) {
- (*cp->rcomp->decomp_reset)(cp->rstate);
- cp->flags &= ~CCP_ERROR;
- }
- }
- }
- break;
- }
-}
-
-#if 0
-dump_msg(mp)
- mblk_t *mp;
-{
- dblk_t *db;
-
- while (mp != 0) {
- db = mp->b_datap;
- DPRINT2("mp=%x cont=%x ", mp, mp->b_cont);
- DPRINT3("rptr=%x wptr=%x datap=%x\n", mp->b_rptr, mp->b_wptr, db);
- DPRINT2(" base=%x lim=%x", db->db_base, db->db_lim);
- DPRINT2(" ref=%d type=%d\n", db->db_ref, db->db_type);
- mp = mp->b_cont;
- }
-}
-#endif
-
-static int
-msg_byte(mp, i)
- mblk_t *mp;
- unsigned int i;
-{
- while (mp != 0 && i >= mp->b_wptr - mp->b_rptr)
- mp = mp->b_cont;
- if (mp == 0)
- return -1;
- return mp->b_rptr[i];
-}
diff --git a/mdk-stage1/ppp/modules/ppp_mod.h b/mdk-stage1/ppp/modules/ppp_mod.h
deleted file mode 100644
index f0af00886..000000000
--- a/mdk-stage1/ppp/modules/ppp_mod.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Miscellaneous definitions for PPP STREAMS modules.
- */
-
-/*
- * Macros for allocating and freeing kernel memory.
- */
-#ifdef SVR4 /* SVR4, including Solaris 2 */
-#include <sys/kmem.h>
-#define ALLOC_SLEEP(n) kmem_alloc((n), KM_SLEEP)
-#define ALLOC_NOSLEEP(n) kmem_alloc((n), KM_NOSLEEP)
-#define FREE(p, n) kmem_free((p), (n))
-#endif
-
-#ifdef SUNOS4
-#include <sys/kmem_alloc.h> /* SunOS 4.x */
-#define ALLOC_SLEEP(n) kmem_alloc((n), KMEM_SLEEP)
-#define ALLOC_NOSLEEP(n) kmem_alloc((n), KMEM_NOSLEEP)
-#define FREE(p, n) kmem_free((p), (n))
-#define NOTSUSER() (suser()? 0: EPERM)
-#define bcanputnext(q, band) canputnext((q))
-#endif /* SunOS 4 */
-
-#ifdef __osf__
-#include <sys/malloc.h>
-
-/* caution: this mirrors macros in sys/malloc.h, and uses interfaces
- * which are subject to change.
- * The problems are that:
- * - the official MALLOC macro wants the lhs of the assignment as an argument,
- * and it takes care of the assignment itself (yuck.)
- * - PPP insists on using "FREE" which conflicts with a macro of the same name.
- *
- */
-#ifdef BUCKETINDX /* V2.0 */
-#define ALLOC_SLEEP(n) (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_WAITOK)
-#define ALLOC_NOSLEEP(n) (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_NOWAIT)
-#else
-#define ALLOC_SLEEP(n) (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_WAITOK)
-#define ALLOC_NOSLEEP(n) (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_NOWAIT)
-#endif
-
-#define bcanputnext(q, band) canputnext((q))
-
-#ifdef FREE
-#undef FREE
-#endif
-#define FREE(p, n) free((void *)(p), M_DEVBUF)
-
-#define NO_DLPI 1
-
-#ifndef IFT_PPP
-#define IFT_PPP 0x17
-#endif
-
-#include <sys/proc.h>
-#define NOTSUSER() (suser(u.u_procp->p_rcred, &u.u_acflag) ? EPERM : 0)
-
-/* #include "ppp_osf.h" */
-
-#endif /* __osf__ */
-
-#ifdef AIX4
-#define ALLOC_SLEEP(n) xmalloc((n), 0, pinned_heap) /* AIX V4.x */
-#define ALLOC_NOSLEEP(n) xmalloc((n), 0, pinned_heap) /* AIX V4.x */
-#define FREE(p, n) xmfree((p), pinned_heap)
-#define NOTSUSER() (suser()? 0: EPERM)
-#endif /* AIX */
-
-/*
- * Macros for printing debugging stuff.
- */
-#ifdef DEBUG
-#if defined(SVR4) || defined(__osf__)
-#if defined(SNI)
-#include <sys/strlog.h>
-#define STRLOG_ID 4712
-#define DPRINT(f) strlog(STRLOG_ID, 0, 0, SL_TRACE, f)
-#define DPRINT1(f, a1) strlog(STRLOG_ID, 0, 0, SL_TRACE, f, a1)
-#define DPRINT2(f, a1, a2) strlog(STRLOG_ID, 0, 0, SL_TRACE, f, a1, a2)
-#define DPRINT3(f, a1, a2, a3) strlog(STRLOG_ID, 0, 0, SL_TRACE, f, a1, a2, a3)
-#else
-#define DPRINT(f) cmn_err(CE_CONT, f)
-#define DPRINT1(f, a1) cmn_err(CE_CONT, f, a1)
-#define DPRINT2(f, a1, a2) cmn_err(CE_CONT, f, a1, a2)
-#define DPRINT3(f, a1, a2, a3) cmn_err(CE_CONT, f, a1, a2, a3)
-#endif /* SNI */
-#else
-#define DPRINT(f) printf(f)
-#define DPRINT1(f, a1) printf(f, a1)
-#define DPRINT2(f, a1, a2) printf(f, a1, a2)
-#define DPRINT3(f, a1, a2, a3) printf(f, a1, a2, a3)
-#endif /* SVR4 or OSF */
-
-#else
-#define DPRINT(f) 0
-#define DPRINT1(f, a1) 0
-#define DPRINT2(f, a1, a2) 0
-#define DPRINT3(f, a1, a2, a3) 0
-#endif /* DEBUG */
-
-#ifndef SVR4
-typedef unsigned char uchar_t;
-typedef unsigned short ushort_t;
-#ifndef __osf__
-typedef int minor_t;
-#endif
-#endif
-
-/*
- * If we don't have multithreading support, define substitutes.
- */
-#ifndef D_MP
-# define qprocson(q)
-# define qprocsoff(q)
-# define put(q, mp) ((*(q)->q_qinfo->qi_putp)((q), (mp)))
-# define canputnext(q) canput((q)->q_next)
-# define qwriter(q, mp, func, scope) (func)((q), (mp))
-#endif
-
-#ifdef D_MP
-/* Use msgpullup if we have other multithreading support. */
-#define PULLUP(mp, len) \
- do { \
- mblk_t *np = msgpullup((mp), (len)); \
- freemsg((mp)); \
- mp = np; \
- } while (0)
-
-#else
-/* Use pullupmsg if we don't have any multithreading support. */
-#define PULLUP(mp, len) \
- do { \
- if (!pullupmsg((mp), (len))) { \
- freemsg((mp)); \
- mp = 0; \
- } \
- } while (0)
-#endif
-
-/*
- * How to declare the open and close procedures for a module.
- */
-#ifdef SVR4
-#define MOD_OPEN_DECL(name) \
-static int name __P((queue_t *, dev_t *, int, int, cred_t *))
-
-#define MOD_CLOSE_DECL(name) \
-static int name __P((queue_t *, int, cred_t *))
-
-#define MOD_OPEN(name) \
-static int name(q, devp, flag, sflag, credp) \
- queue_t *q; \
- dev_t *devp; \
- int flag, sflag; \
- cred_t *credp;
-
-#define MOD_CLOSE(name) \
-static int name(q, flag, credp) \
- queue_t *q; \
- int flag; \
- cred_t *credp;
-
-#define OPEN_ERROR(x) return (x)
-#define DRV_OPEN_OK(dev) return 0
-
-#define NOTSUSER() (drv_priv(credp))
-
-#else /* not SVR4 */
-#define MOD_OPEN_DECL(name) \
-static int name __P((queue_t *, int, int, int))
-
-#define MOD_CLOSE_DECL(name) \
-static int name __P((queue_t *, int))
-
-#define MOD_OPEN(name) \
-static int name(q, dev, flag, sflag) \
- queue_t *q; \
- int dev; \
- int flag, sflag;
-
-#define MOD_CLOSE(name) \
-static int name(q, flag) \
- queue_t *q; \
- int flag;
-
-#define OPEN_ERROR(x) { u.u_error = (x); return OPENFAIL; }
-#define DRV_OPEN_OK(dev) return (dev)
-
-#endif /* SVR4 */
diff --git a/mdk-stage1/ppp/modules/vjcompress.c b/mdk-stage1/ppp/modules/vjcompress.c
deleted file mode 100644
index 809b87231..000000000
--- a/mdk-stage1/ppp/modules/vjcompress.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/*
- * Routines to compress and uncompess tcp packets (for transmission
- * over low speed serial lines.
- *
- * Copyright (c) 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- * - Initial distribution.
- *
- * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au,
- * so that the entire packet being decompressed doesn't have
- * to be in contiguous memory (just the compressed header).
- */
-
-/*
- * This version is used under SunOS 4.x, Digital UNIX, AIX 4.x,
- * and SVR4 systems including Solaris 2.
- *
- * $Id$
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-
-#ifdef SVR4
-#ifndef __GNUC__
-#include <sys/byteorder.h> /* for ntohl, etc. */
-#else
-/* make sure we don't get the gnu "fixed" one! */
-#include "/usr/include/sys/byteorder.h"
-#endif
-#endif
-
-#ifdef __osf__
-#include <net/net_globals.h>
-#endif
-#include <netinet/in.h>
-
-#ifdef AIX4
-#define _NETINET_IN_SYSTM_H_
-typedef u_long n_long;
-#else
-#include <netinet/in_systm.h>
-#endif
-
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include <net/ppp_defs.h>
-#include <net/vjcompress.h>
-
-#ifndef VJ_NO_STATS
-#define INCR(counter) ++comp->stats.counter
-#else
-#define INCR(counter)
-#endif
-
-#define BCMP(p1, p2, n) bcmp((char *)(p1), (char *)(p2), (int)(n))
-#undef BCOPY
-#define BCOPY(p1, p2, n) bcopy((char *)(p1), (char *)(p2), (int)(n))
-#ifndef KERNEL
-#define ovbcopy bcopy
-#endif
-
-#ifdef __osf__
-#define getip_hl(base) (((base).ip_vhl)&0xf)
-#define getth_off(base) ((((base).th_xoff)&0xf0)>>4)
-
-#else
-#define getip_hl(base) ((base).ip_hl)
-#define getth_off(base) ((base).th_off)
-#endif
-
-void
-vj_compress_init(comp, max_state)
- struct vjcompress *comp;
- int max_state;
-{
- register u_int i;
- register struct cstate *tstate = comp->tstate;
-
- if (max_state == -1)
- max_state = MAX_STATES - 1;
- bzero((char *)comp, sizeof(*comp));
- for (i = max_state; i > 0; --i) {
- tstate[i].cs_id = i;
- tstate[i].cs_next = &tstate[i - 1];
- }
- tstate[0].cs_next = &tstate[max_state];
- tstate[0].cs_id = 0;
- comp->last_cs = &tstate[0];
- comp->last_recv = 255;
- comp->last_xmit = 255;
- comp->flags = VJF_TOSS;
-}
-
-
-/* ENCODE encodes a number that is known to be non-zero. ENCODEZ
- * checks for zero (since zero has to be encoded in the long, 3 byte
- * form).
- */
-#define ENCODE(n) { \
- if ((u_short)(n) >= 256) { \
- *cp++ = 0; \
- cp[1] = (n); \
- cp[0] = (n) >> 8; \
- cp += 2; \
- } else { \
- *cp++ = (n); \
- } \
-}
-#define ENCODEZ(n) { \
- if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \
- *cp++ = 0; \
- cp[1] = (n); \
- cp[0] = (n) >> 8; \
- cp += 2; \
- } else { \
- *cp++ = (n); \
- } \
-}
-
-#define DECODEL(f) { \
- if (*cp == 0) {\
- u_int32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \
- (f) = htonl(tmp); \
- cp += 3; \
- } else { \
- u_int32_t tmp = ntohl(f) + (u_int32_t)*cp++; \
- (f) = htonl(tmp); \
- } \
-}
-
-#define DECODES(f) { \
- if (*cp == 0) {\
- u_short tmp = ntohs(f) + ((cp[1] << 8) | cp[2]); \
- (f) = htons(tmp); \
- cp += 3; \
- } else { \
- u_short tmp = ntohs(f) + (u_int32_t)*cp++; \
- (f) = htons(tmp); \
- } \
-}
-
-#define DECODEU(f) { \
- if (*cp == 0) {\
- (f) = htons((cp[1] << 8) | cp[2]); \
- cp += 3; \
- } else { \
- (f) = htons((u_int32_t)*cp++); \
- } \
-}
-
-u_int
-vj_compress_tcp(ip, mlen, comp, compress_cid, vjhdrp)
- register struct ip *ip;
- u_int mlen;
- struct vjcompress *comp;
- int compress_cid;
- u_char **vjhdrp;
-{
- register struct cstate *cs = comp->last_cs->cs_next;
- register u_int hlen = getip_hl(*ip);
- register struct tcphdr *oth;
- register struct tcphdr *th;
- register u_int deltaS, deltaA;
- register u_int changes = 0;
- u_char new_seq[16];
- register u_char *cp = new_seq;
-
- /*
- * Bail if this is an IP fragment or if the TCP packet isn't
- * `compressible' (i.e., ACK isn't set or some other control bit is
- * set). (We assume that the caller has already made sure the
- * packet is IP proto TCP).
- */
- if ((ip->ip_off & htons(0x3fff)) || mlen < 40)
- return (TYPE_IP);
-
- th = (struct tcphdr *)&((int *)ip)[hlen];
- if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
- return (TYPE_IP);
- /*
- * Packet is compressible -- we're going to send either a
- * COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need
- * to locate (or create) the connection state. Special case the
- * most recently used connection since it's most likely to be used
- * again & we don't have to do any reordering if it's used.
- */
- INCR(vjs_packets);
- if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
- ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
- *(int *)th != ((int *)&cs->cs_ip)[getip_hl(cs->cs_ip)]) {
- /*
- * Wasn't the first -- search for it.
- *
- * States are kept in a circularly linked list with
- * last_cs pointing to the end of the list. The
- * list is kept in lru order by moving a state to the
- * head of the list whenever it is referenced. Since
- * the list is short and, empirically, the connection
- * we want is almost always near the front, we locate
- * states via linear search. If we don't find a state
- * for the datagram, the oldest state is (re-)used.
- */
- register struct cstate *lcs;
- register struct cstate *lastcs = comp->last_cs;
-
- do {
- lcs = cs; cs = cs->cs_next;
- INCR(vjs_searches);
- if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
- && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
- && *(int *)th == ((int *)&cs->cs_ip)[getip_hl(cs->cs_ip)])
- goto found;
- } while (cs != lastcs);
-
- /*
- * Didn't find it -- re-use oldest cstate. Send an
- * uncompressed packet that tells the other side what
- * connection number we're using for this conversation.
- * Note that since the state list is circular, the oldest
- * state points to the newest and we only need to set
- * last_cs to update the lru linkage.
- */
- INCR(vjs_misses);
- comp->last_cs = lcs;
- hlen += getth_off(*th);
- hlen <<= 2;
- if (hlen > mlen)
- return (TYPE_IP);
- goto uncompressed;
-
- found:
- /*
- * Found it -- move to the front on the connection list.
- */
- if (cs == lastcs)
- comp->last_cs = lcs;
- else {
- lcs->cs_next = cs->cs_next;
- cs->cs_next = lastcs->cs_next;
- lastcs->cs_next = cs;
- }
- }
-
- /*
- * Make sure that only what we expect to change changed. The first
- * line of the `if' checks the IP protocol version, header length &
- * type of service. The 2nd line checks the "Don't fragment" bit.
- * The 3rd line checks the time-to-live and protocol (the protocol
- * check is unnecessary but costless). The 4th line checks the TCP
- * header length. The 5th line checks IP options, if any. The 6th
- * line checks TCP options, if any. If any of these things are
- * different between the previous & current datagram, we send the
- * current datagram `uncompressed'.
- */
- oth = (struct tcphdr *)&((int *)&cs->cs_ip)[hlen];
- deltaS = hlen;
- hlen += getth_off(*th);
- hlen <<= 2;
- if (hlen > mlen)
- return (TYPE_IP);
-
- if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
- ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
- ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] ||
- getth_off(*th) != getth_off(*oth) ||
- (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
- (getth_off(*th) > 5 && BCMP(th + 1, oth + 1, (getth_off(*th) - 5) << 2)))
- goto uncompressed;
-
- /*
- * Figure out which of the changing fields changed. The
- * receiver expects changes in the order: urgent, window,
- * ack, seq (the order minimizes the number of temporaries
- * needed in this section of code).
- */
- if (th->th_flags & TH_URG) {
- deltaS = ntohs(th->th_urp);
- ENCODEZ(deltaS);
- changes |= NEW_U;
- } else if (th->th_urp != oth->th_urp)
- /* argh! URG not set but urp changed -- a sensible
- * implementation should never do this but RFC793
- * doesn't prohibit the change so we have to deal
- * with it. */
- goto uncompressed;
-
- if ((deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) > 0) {
- ENCODE(deltaS);
- changes |= NEW_W;
- }
-
- if ((deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) > 0) {
- if (deltaA > 0xffff)
- goto uncompressed;
- ENCODE(deltaA);
- changes |= NEW_A;
- }
-
- if ((deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) > 0) {
- if (deltaS > 0xffff)
- goto uncompressed;
- ENCODE(deltaS);
- changes |= NEW_S;
- }
-
- switch(changes) {
-
- case 0:
- /*
- * Nothing changed. If this packet contains data and the
- * last one didn't, this is probably a data packet following
- * an ack (normal on an interactive connection) and we send
- * it compressed. Otherwise it's probably a retransmit,
- * retransmitted ack or window probe. Send it uncompressed
- * in case the other side missed the compressed version.
- */
- if (ip->ip_len != cs->cs_ip.ip_len &&
- ntohs(cs->cs_ip.ip_len) == hlen)
- break;
-
- /* (fall through) */
-
- case SPECIAL_I:
- case SPECIAL_D:
- /*
- * actual changes match one of our special case encodings --
- * send packet uncompressed.
- */
- goto uncompressed;
-
- case NEW_S|NEW_A:
- if (deltaS == deltaA && deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
- /* special case for echoed terminal traffic */
- changes = SPECIAL_I;
- cp = new_seq;
- }
- break;
-
- case NEW_S:
- if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
- /* special case for data xfer */
- changes = SPECIAL_D;
- cp = new_seq;
- }
- break;
- }
-
- deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
- if (deltaS != 1) {
- ENCODEZ(deltaS);
- changes |= NEW_I;
- }
- if (th->th_flags & TH_PUSH)
- changes |= TCP_PUSH_BIT;
- /*
- * Grab the cksum before we overwrite it below. Then update our
- * state with this packet's header.
- */
- deltaA = ntohs(th->th_sum);
- BCOPY(ip, &cs->cs_ip, hlen);
-
- /*
- * We want to use the original packet as our compressed packet.
- * (cp - new_seq) is the number of bytes we need for compressed
- * sequence numbers. In addition we need one byte for the change
- * mask, one for the connection id and two for the tcp checksum.
- * So, (cp - new_seq) + 4 bytes of header are needed. hlen is how
- * many bytes of the original packet to toss so subtract the two to
- * get the new packet size.
- */
- deltaS = cp - new_seq;
- cp = (u_char *)ip;
- if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
- comp->last_xmit = cs->cs_id;
- hlen -= deltaS + 4;
- *vjhdrp = (cp += hlen);
- *cp++ = changes | NEW_C;
- *cp++ = cs->cs_id;
- } else {
- hlen -= deltaS + 3;
- *vjhdrp = (cp += hlen);
- *cp++ = changes;
- }
- *cp++ = deltaA >> 8;
- *cp++ = deltaA;
- BCOPY(new_seq, cp, deltaS);
- INCR(vjs_compressed);
- return (TYPE_COMPRESSED_TCP);
-
- /*
- * Update connection state cs & send uncompressed packet (that is,
- * a regular ip/tcp packet but with the 'conversation id' we hope
- * to use on future compressed packets in the protocol field).
- */
- uncompressed:
- BCOPY(ip, &cs->cs_ip, hlen);
- ip->ip_p = cs->cs_id;
- comp->last_xmit = cs->cs_id;
- return (TYPE_UNCOMPRESSED_TCP);
-}
-
-/*
- * Called when we may have missed a packet.
- */
-void
-vj_uncompress_err(comp)
- struct vjcompress *comp;
-{
- comp->flags |= VJF_TOSS;
- INCR(vjs_errorin);
-}
-
-/*
- * "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP.
- */
-int
-vj_uncompress_uncomp(buf, buflen, comp)
- u_char *buf;
- int buflen;
- struct vjcompress *comp;
-{
- register u_int hlen;
- register struct cstate *cs;
- register struct ip *ip;
-
- ip = (struct ip *) buf;
- hlen = getip_hl(*ip) << 2;
- if (ip->ip_p >= MAX_STATES
- || hlen + sizeof(struct tcphdr) > buflen
- || (hlen += getth_off(*((struct tcphdr *)&((char *)ip)[hlen])) << 2)
- > buflen
- || hlen > MAX_HDR) {
- comp->flags |= VJF_TOSS;
- INCR(vjs_errorin);
- return (0);
- }
- cs = &comp->rstate[comp->last_recv = ip->ip_p];
- comp->flags &=~ VJF_TOSS;
- ip->ip_p = IPPROTO_TCP;
- BCOPY(ip, &cs->cs_ip, hlen);
- cs->cs_hlen = hlen;
- INCR(vjs_uncompressedin);
- return (1);
-}
-
-/*
- * Uncompress a packet of type TYPE_COMPRESSED_TCP.
- * The packet starts at buf and is of total length total_len.
- * The first buflen bytes are at buf; this must include the entire
- * compressed TCP/IP header. This procedure returns the length
- * of the VJ header, with a pointer to the uncompressed IP header
- * in *hdrp and its length in *hlenp.
- */
-int
-vj_uncompress_tcp(buf, buflen, total_len, comp, hdrp, hlenp)
- u_char *buf;
- int buflen, total_len;
- struct vjcompress *comp;
- u_char **hdrp;
- u_int *hlenp;
-{
- register u_char *cp;
- register u_int hlen, changes;
- register struct tcphdr *th;
- register struct cstate *cs;
- register u_short *bp;
- register u_int vjlen;
- register u_int32_t tmp;
-
- INCR(vjs_compressedin);
- cp = buf;
- changes = *cp++;
- if (changes & NEW_C) {
- /* Make sure the state index is in range, then grab the state.
- * If we have a good state index, clear the 'discard' flag. */
- if (*cp >= MAX_STATES)
- goto bad;
-
- comp->flags &=~ VJF_TOSS;
- comp->last_recv = *cp++;
- } else {
- /* this packet has an implicit state index. If we've
- * had a line error since the last time we got an
- * explicit state index, we have to toss the packet. */
- if (comp->flags & VJF_TOSS) {
- INCR(vjs_tossed);
- return (-1);
- }
- }
- cs = &comp->rstate[comp->last_recv];
- hlen = getip_hl(cs->cs_ip) << 2;
- th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
- th->th_sum = htons((*cp << 8) | cp[1]);
- cp += 2;
- if (changes & TCP_PUSH_BIT)
- th->th_flags |= TH_PUSH;
- else
- th->th_flags &=~ TH_PUSH;
-
- switch (changes & SPECIALS_MASK) {
- case SPECIAL_I:
- {
- register u_int32_t i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
- /* some compilers can't nest inline assembler.. */
- tmp = ntohl(th->th_ack) + i;
- th->th_ack = htonl(tmp);
- tmp = ntohl(th->th_seq) + i;
- th->th_seq = htonl(tmp);
- }
- break;
-
- case SPECIAL_D:
- /* some compilers can't nest inline assembler.. */
- tmp = ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
- th->th_seq = htonl(tmp);
- break;
-
- default:
- if (changes & NEW_U) {
- th->th_flags |= TH_URG;
- DECODEU(th->th_urp);
- } else
- th->th_flags &=~ TH_URG;
- if (changes & NEW_W)
- DECODES(th->th_win);
- if (changes & NEW_A)
- DECODEL(th->th_ack);
- if (changes & NEW_S)
- DECODEL(th->th_seq);
- break;
- }
- if (changes & NEW_I) {
- DECODES(cs->cs_ip.ip_id);
- } else {
- cs->cs_ip.ip_id = ntohs(cs->cs_ip.ip_id) + 1;
- cs->cs_ip.ip_id = htons(cs->cs_ip.ip_id);
- }
-
- /*
- * At this point, cp points to the first byte of data in the
- * packet. Fill in the IP total length and update the IP
- * header checksum.
- */
- vjlen = cp - buf;
- buflen -= vjlen;
- if (buflen < 0)
- /* we must have dropped some characters (crc should detect
- * this but the old slip framing won't) */
- goto bad;
-
- total_len += cs->cs_hlen - vjlen;
- cs->cs_ip.ip_len = htons(total_len);
-
- /* recompute the ip header checksum */
- bp = (u_short *) &cs->cs_ip;
- cs->cs_ip.ip_sum = 0;
- for (changes = 0; hlen > 0; hlen -= 2)
- changes += *bp++;
- changes = (changes & 0xffff) + (changes >> 16);
- changes = (changes & 0xffff) + (changes >> 16);
- cs->cs_ip.ip_sum = ~ changes;
-
- *hdrp = (u_char *) &cs->cs_ip;
- *hlenp = cs->cs_hlen;
- return vjlen;
-
- bad:
- comp->flags |= VJF_TOSS;
- INCR(vjs_errorin);
- return (-1);
-}
diff --git a/mdk-stage1/ppp/pppd/.cvsignore b/mdk-stage1/ppp/pppd/.cvsignore
deleted file mode 100644
index 476ef2253..000000000
--- a/mdk-stage1/ppp/pppd/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-pppd
-pppd-DIET
diff --git a/mdk-stage1/ppp/pppd/Makefile b/mdk-stage1/ppp/pppd/Makefile
deleted file mode 100644
index 3544dd19d..000000000
--- a/mdk-stage1/ppp/pppd/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
- #******************************************************************************
- #
- # Guillaume Cottenceau (gc@mandrakesoft.com)
- #
- # Copyright 2000 Mandrakesoft
- #
- # This software may be freely redistributed under the terms of the GNU
- # public license.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- #*****************************************************************************
-
-top_dir = ../..
-
-include $(top_dir)/Makefile.common
-
-
-TARGETS = pppd
-
-BINTARGET = ../pppd-bin
-
-
-all: $(TARGETS)
-
-clean:
- rm -f *.o *.a $(BINTARGET) pppd
-
-FLAGS = -Wall -Wno-deprecated-declarations -Werror -Os -fomit-frame-pointer -DDO_BSD_COMPRESS=0 -D_linux_=1 -DHAVE_MMAP -DNO_DRAND48 -D_BSD_SOURCE -D_GNU_SOURCE
-
-INCS = -I../include -I.
-
-ifeq (GLIBC, $(L))
-LIBS = -static -lcrypt
-endif
-
-
-OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o tdb.o tty.o
-
-
-pppd: $(OBJS)
- $(DIET) gcc -o $@ $^ $(LIBS)
- $(STRIPCMD) $@
- cp -f $@ $(BINTARGET)
-
-$(OBJS): %.o: %.c
- $(DIET) gcc $(FLAGS) $(INCS) $(INCLUDES) -c $< -o $@
diff --git a/mdk-stage1/ppp/pppd/Makefile.linux b/mdk-stage1/ppp/pppd/Makefile.linux
deleted file mode 100644
index 47d6ba01e..000000000
--- a/mdk-stage1/ppp/pppd/Makefile.linux
+++ /dev/null
@@ -1,129 +0,0 @@
-#
-# pppd makefile for Linux
-# $Id$
-#
-
-# Default installation locations
-BINDIR = $(DESTDIR)/usr/sbin
-MANDIR = $(DESTDIR)/usr/man
-
-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
- ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \
- demand.c utils.c multilink.c tdb.c tty.c
-HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \
- ipxcp.h cbcp.h tdb.h
-MANPAGES = pppd.8
-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
- auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \
- tdb.o tty.o
-
-all: pppd
-
-#
-# include dependancies if present and backup if as a header file
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
-
-CC = gcc
-#
-COPTS = -Wall $(RPM_OPT_FLAGS)
-LIBS = -lutil
-
-ifneq ($(wildcard /usr/lib/libcrypt.*),)
-LIBS += -lcrypt
-endif
-
-# Uncomment the next 2 lines to include support for Microsoft's
-# MS-CHAP authentication protocol.
-CHAPMS=y
-USE_CRYPT=y
-ifneq ($(wildcard /usr/lib/libcrypt.*),)
-HAVE_CRYPT_H=y
-endif
-
-# Uncomment the next line to include support for PPP packet filtering.
-# This requires that the libpcap library and headers be installed
-# and that the kernel driver support PPP packet filtering, which it
-# doesn't yet.
-#FILTER=y
-
-HAS_SHADOW=y
-USE_PAM=y
-#HAVE_INET6=y
-
-PLUGIN=y
-
-INCLUDE_DIRS= -I../include
-
-COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MULTILINK -DHAVE_MMAP
-
-CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
-
-ifdef CHAPMS
-CFLAGS += -DCHAPMS=1
-ifndef USE_CRYPT
-LIBS := -ldes $(LIBS)
-else
-CFLAGS += -DUSE_CRYPT=1
-ifneq ($(wildcard /usr/include/crypt.h),)
-CFLAGS += -DHAVE_CRYPT_H=1
-endif
-endif
-PPPDOBJS += md4.o chap_ms.o
-ifdef MSLANMAN
-CFLAGS += -DMSLANMAN=1
-endif
-endif
-
-ifdef HAS_SHADOW
-CFLAGS += -DHAS_SHADOW
-#LIBS := -lshadow $(LIBS)
-endif
-
-# For "Pluggable Authentication Modules", see ftp.redhat.com:/pub/pam/.
-ifdef USE_PAM
-CFLAGS += -DUSE_PAM
-LIBS := -lpam -ldl $(LIBS)
-endif
-
-# Lock library binary for Linux is included in 'linux' subdirectory.
-ifdef LOCKLIB
-LIBS := -llock $(LIBS)
-CFLAGS += -DLOCKLIB=1
-endif
-
-ifdef PLUGIN
-CFLAGS += -DPLUGIN
-LDFLAGS += -Wl,-E
-LIBS += -ldl
-endif
-
-ifdef FILTER
-LIBS += -lpcap
-CFLAGS += -DPPP_FILTER -I/usr/include/pcap
-endif
-
-ifdef HAVE_INET6
- PPPDSRCS += ipv6cp.c eui64.c
- HEADERS += ipv6cp.h eui64.h
- PPPDOBJS += ipv6cp.o eui64.o
- CFLAGS += -DINET6=1
-endif
-
-
-INSTALL= install
-
-install: pppd
- mkdir -p $(BINDIR) $(MANDIR)
- $(INSTALL) -m 555 pppd $(BINDIR)/pppd
- $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8
-
-pppd: $(PPPDOBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-clean:
- rm -f $(PPPDOBJS) pppd *~ #* core
-
-depend:
- $(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
diff --git a/mdk-stage1/ppp/pppd/Makefile.linux.make b/mdk-stage1/ppp/pppd/Makefile.linux.make
deleted file mode 100644
index d98a32562..000000000
--- a/mdk-stage1/ppp/pppd/Makefile.linux.make
+++ /dev/null
@@ -1,131 +0,0 @@
-#
-# pppd makefile for Linux
-# $Id$
-#
-
-# Default installation locations
-BINDIR = /usr/sbin
-MANDIR = /usr/man
-
-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
- ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \
- demand.c utils.c multilink.c tdb.c tty.c
-HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \
- ipxcp.h cbcp.h tdb.h
-MANPAGES = pppd.8
-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
- auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \
- tdb.o tty.o
-
-all: pppd
-
-#
-# include dependancies if present and backup if as a header file
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
-
-# CC = gcc
-#
-COPTS = -O2 -pipe -Wall -g
-LIBS =
-
-ifneq ($(wildcard /usr/lib/libcrypt.*),)
-LIBS += -lcrypt
-endif
-
-# Uncomment the next 2 lines to include support for Microsoft's
-# MS-CHAP authentication protocol.
-CHAPMS=y
-USE_CRYPT=y
-ifneq ($(wildcard /usr/lib/libcrypt.*),)
-HAVE_CRYPT_H=y
-endif
-
-# Uncomment the next line to include support for PPP packet filtering.
-# This requires that the libpcap library and headers be installed
-# and that the kernel driver support PPP packet filtering, which it
-# doesn't yet.
-#FILTER=y
-
-HAS_SHADOW=y
-#USE_PAM=y
-#HAVE_INET6=y
-
-PLUGIN=y
-
-INCLUDE_DIRS= -I../include
-
-COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MULTILINK -DHAVE_MMAP
-
-CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
-
-ifdef CHAPMS
-CFLAGS += -DCHAPMS=1
-ifndef USE_CRYPT
-LIBS := -ldes $(LIBS)
-else
-CFLAGS += -DUSE_CRYPT=1
-ifneq ($(wildcard /usr/include/crypt.h),)
-CFLAGS += -DHAVE_CRYPT_H=1
-endif
-endif
-PPPDOBJS += md4.o chap_ms.o
-ifdef MSLANMAN
-CFLAGS += -DMSLANMAN=1
-endif
-endif
-
-ifdef HAS_SHADOW
-CFLAGS += -DHAS_SHADOW
-#LIBS := -lshadow $(LIBS)
-endif
-
-# For "Pluggable Authentication Modules", see ftp.redhat.com:/pub/pam/.
-ifdef USE_PAM
-CFLAGS += -DUSE_PAM
-LIBS := -lpam -ldl $(LIBS)
-endif
-
-# Lock library binary for Linux is included in 'linux' subdirectory.
-ifdef LOCKLIB
-LIBS := -llock $(LIBS)
-CFLAGS += -DLOCKLIB=1
-endif
-
-ifdef PLUGIN
-CFLAGS += -DPLUGIN
-LDFLAGS += -Wl,-E
-LIBS += -ldl
-endif
-
-ifdef FILTER
-LIBS += -lpcap
-CFLAGS += -DPPP_FILTER -I/usr/include/pcap
-endif
-
-ifdef HAVE_INET6
- PPPDSRCS += ipv6cp.c eui64.c
- HEADERS += ipv6cp.h eui64.h
- PPPDOBJS += ipv6cp.o eui64.o
- CFLAGS += -DINET6=1
-endif
-
-
-INSTALL= install -o root
-
-install: pppd
- mkdir -p $(BINDIR) $(MANDIR)
- $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
- if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
- chmod o-rx,u+s $(BINDIR)/pppd; fi
- $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8
-
-pppd: $(PPPDOBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-clean:
- rm -f $(PPPDOBJS) pppd *~ #* core
-
-depend:
- $(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
diff --git a/mdk-stage1/ppp/pppd/Makefile.linux.makeopt b/mdk-stage1/ppp/pppd/Makefile.linux.makeopt
deleted file mode 100644
index 3094c941c..000000000
--- a/mdk-stage1/ppp/pppd/Makefile.linux.makeopt
+++ /dev/null
@@ -1,129 +0,0 @@
-#
-# pppd makefile for Linux
-# $Id$
-#
-
-# Default installation locations
-BINDIR = $(DESTDIR)/usr/sbin
-MANDIR = $(DESTDIR)/usr/man
-
-PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
- ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \
- demand.c utils.c multilink.c tdb.c tty.c
-HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \
- ipxcp.h cbcp.h tdb.h
-MANPAGES = pppd.8
-PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
- auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \
- tdb.o tty.o
-
-all: pppd
-
-#
-# include dependancies if present and backup if as a header file
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
-
-CC = gcc
-#
-COPTS = -O2 -pipe -Wall -g
-LIBS = -lutil
-
-ifneq ($(wildcard /usr/lib/libcrypt.*),)
-LIBS += -lcrypt
-endif
-
-# Uncomment the next 2 lines to include support for Microsoft's
-# MS-CHAP authentication protocol.
-CHAPMS=y
-USE_CRYPT=y
-ifneq ($(wildcard /usr/lib/libcrypt.*),)
-HAVE_CRYPT_H=y
-endif
-
-# Uncomment the next line to include support for PPP packet filtering.
-# This requires that the libpcap library and headers be installed
-# and that the kernel driver support PPP packet filtering, which it
-# doesn't yet.
-#FILTER=y
-
-HAS_SHADOW=y
-USE_PAM=y
-#HAVE_INET6=y
-
-PLUGIN=y
-
-INCLUDE_DIRS= -I../include
-
-COMPILE_FLAGS= -D_linux_=1 -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MULTILINK -DHAVE_MMAP
-
-CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
-
-ifdef CHAPMS
-CFLAGS += -DCHAPMS=1
-ifndef USE_CRYPT
-LIBS := -ldes $(LIBS)
-else
-CFLAGS += -DUSE_CRYPT=1
-ifneq ($(wildcard /usr/include/crypt.h),)
-CFLAGS += -DHAVE_CRYPT_H=1
-endif
-endif
-PPPDOBJS += md4.o chap_ms.o
-ifdef MSLANMAN
-CFLAGS += -DMSLANMAN=1
-endif
-endif
-
-ifdef HAS_SHADOW
-CFLAGS += -DHAS_SHADOW
-#LIBS := -lshadow $(LIBS)
-endif
-
-# For "Pluggable Authentication Modules", see ftp.redhat.com:/pub/pam/.
-ifdef USE_PAM
-CFLAGS += -DUSE_PAM
-LIBS := -lpam -ldl $(LIBS)
-endif
-
-# Lock library binary for Linux is included in 'linux' subdirectory.
-ifdef LOCKLIB
-LIBS := -llock $(LIBS)
-CFLAGS += -DLOCKLIB=1
-endif
-
-ifdef PLUGIN
-CFLAGS += -DPLUGIN
-LDFLAGS += -Wl,-E
-LIBS += -ldl
-endif
-
-ifdef FILTER
-LIBS += -lpcap
-CFLAGS += -DPPP_FILTER -I/usr/include/pcap
-endif
-
-ifdef HAVE_INET6
- PPPDSRCS += ipv6cp.c eui64.c
- HEADERS += ipv6cp.h eui64.h
- PPPDOBJS += ipv6cp.o eui64.o
- CFLAGS += -DINET6=1
-endif
-
-
-INSTALL= install
-
-install: pppd
- mkdir -p $(BINDIR) $(MANDIR)
- $(INSTALL) -m 555 pppd $(BINDIR)/pppd
- $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8
-
-pppd: $(PPPDOBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
-
-clean:
- rm -f $(PPPDOBJS) pppd *~ #* core
-
-depend:
- $(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
diff --git a/mdk-stage1/ppp/pppd/Makefile.sol2 b/mdk-stage1/ppp/pppd/Makefile.sol2
deleted file mode 100644
index dfdcddd97..000000000
--- a/mdk-stage1/ppp/pppd/Makefile.sol2
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Makefile for pppd under Solaris 2.
-# $Id$
-#
-
-include ../solaris/Makedefs
-
-COPTS += -xO2 -xspace -W0,-Lt
-CFLAGS = -I../include -DSVR4 -DSOL2 $(COPTS)
-LIBS = -lsocket -lnsl
-
-OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o tty.o \
- ccp.o auth.o options.o demand.o utils.o sys-solaris.o tdb.o
-
-#
-# uncomment the following to enable plugins
-#
-CFLAGS += -DPLUGIN
-LIBS += -ldl
-
-#
-# Solaris 8 and above accomodates /var/run, so uncomment the
-# following to place pppd process IDs on that location
-#
-#CFLAGS += -D_PATH_VARRUN='"/var/run/"'
-
-#
-# uncomment the following to enable IPv6
-#
-# Solaris 8 and on includes support for IPv6
-#
-#CFLAGS += -DINET6
-#OBJS += ipv6cp.o eui64.o
-
-#
-# Make targets
-#
-all: pppd
-
-pppd: $(OBJS)
- $(CC) -o pppd $(OBJS) $(LIBS)
-
-install:
- $(INSTALL) -f $(BINDIR) -m 4755 -u root pppd
- $(INSTALL) -f $(MANDIR)/man8 -m 444 pppd.8
-
-clean:
- rm -f $(OBJS) pppd *~ core y.tab.c y.tab.h
diff --git a/mdk-stage1/ppp/pppd/Makefile.sunos4 b/mdk-stage1/ppp/pppd/Makefile.sunos4
deleted file mode 100644
index 694ac341f..000000000
--- a/mdk-stage1/ppp/pppd/Makefile.sunos4
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Makefile for pppd under SunOS 4.
-# $Id$
-#
-
-include ../sunos4/Makedefs
-
-LIBS =
-
-CFLAGS = $(COPTS) -I../include -DSUNOS4 -DGIDSET_TYPE=int \
- -DLOCK_DIR=\"/usr/spool/locks\"
-
-all: pppd
-
-OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
- auth.o options.o demand.o utils.o sys-sunos4.o tty.o
-
-pppd: $(OBJS)
- $(CC) -o pppd $(OBJS) $(LIBS)
-
-install:
- $(INSTALL) -c -m 4555 pppd $(BINDIR)/pppd
- $(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8/pppd.8
-
-clean:
- rm -f $(OBJS) pppd *~ core
diff --git a/mdk-stage1/ppp/pppd/auth.c b/mdk-stage1/ppp/pppd/auth.c
deleted file mode 100644
index 5f95a2982..000000000
--- a/mdk-stage1/ppp/pppd/auth.c
+++ /dev/null
@@ -1,1939 +0,0 @@
-/*
- * auth.c - PPP authentication and phase control.
- *
- * Copyright (c) 1993 The Australian National University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Australian National University. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Copyright (c) 1989 Carnegie Mellon University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define RCSID "$Id$"
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <grp.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <utmp.h>
-#include <fcntl.h>
-#if defined(_PATH_LASTLOG) && defined(_linux_)
-#include <lastlog.h>
-#endif
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#ifdef USE_PAM
-#include <security/pam_appl.h>
-#endif
-
-#ifdef HAS_SHADOW
-#include <shadow.h>
-#ifndef PW_PPP
-#define PW_PPP PW_LOGIN
-#endif
-#endif
-
-#include "pppd.h"
-#include "fsm.h"
-#include "lcp.h"
-#include "ipcp.h"
-#include "upap.h"
-#include "chap.h"
-#ifdef CBCP_SUPPORT
-#include "cbcp.h"
-#endif
-#include "pathnames.h"
-
-#include <time.h>
-
-static const char rcsid[] = RCSID;
-
-/* Bits in scan_authfile return value */
-#define NONWILD_SERVER 1
-#define NONWILD_CLIENT 2
-
-#define ISWILD(word) (word[0] == '*' && word[1] == 0)
-
-/* The name by which the peer authenticated itself to us. */
-char peer_authname[MAXNAMELEN];
-
-/* Records which authentication operations haven't completed yet. */
-static int auth_pending[NUM_PPP];
-
-/* Set if we have successfully called plogin() */
-static int logged_in;
-
-/* List of addresses which the peer may use. */
-static struct permitted_ip *addresses[NUM_PPP];
-
-/* Wordlist giving addresses which the peer may use
- without authenticating itself. */
-static struct wordlist *noauth_addrs;
-
-/* Extra options to apply, from the secrets file entry for the peer. */
-static struct wordlist *extra_options;
-
-/* Number of network protocols which we have opened. */
-static int num_np_open;
-
-/* Number of network protocols which have come up. */
-static int num_np_up;
-
-/* Set if we got the contents of passwd[] from the pap-secrets file. */
-static int passwd_from_file;
-
-/* Set if we require authentication only because we have a default route. */
-static bool default_auth;
-
-/* Hook to enable a plugin to control the idle time limit */
-int (*idle_time_hook) __P((struct ppp_idle *)) = NULL;
-
-/* Hook for a plugin to say whether we can possibly authenticate any peer */
-int (*pap_check_hook) __P((void)) = NULL;
-
-/* Hook for a plugin to check the PAP user and password */
-int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
- struct wordlist **paddrs,
- struct wordlist **popts)) = NULL;
-
-/* Hook for a plugin to know about the PAP user logout */
-void (*pap_logout_hook) __P((void)) = NULL;
-
-/* Hook for a plugin to get the PAP password for authenticating us */
-int (*pap_passwd_hook) __P((char *user, char *passwd)) = NULL;
-
-/*
- * This is used to ensure that we don't start an auth-up/down
- * script while one is already running.
- */
-enum script_state {
- s_down,
- s_up
-};
-
-static enum script_state auth_state = s_down;
-static enum script_state auth_script_state = s_down;
-static pid_t auth_script_pid = 0;
-
-static int used_login; /* peer authenticated against login database */
-
-/*
- * Option variables.
- */
-bool uselogin = 0; /* Use /etc/passwd for checking PAP */
-bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */
-bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */
-bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */
-bool usehostname = 0; /* Use hostname for our_name */
-bool auth_required = 0; /* Always require authentication from peer */
-bool allow_any_ip = 0; /* Allow peer to use any IP address */
-bool explicit_remote = 0; /* User specified explicit remote name */
-char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
-
-static char *uafname; /* name of most recent +ua file */
-
-/* Bits in auth_pending[] */
-#define PAP_WITHPEER 1
-#define PAP_PEER 2
-#define CHAP_WITHPEER 4
-#define CHAP_PEER 8
-
-extern char *crypt __P((const char *, const char *));
-
-/* Prototypes for procedures local to this file. */
-
-static void network_phase __P((int));
-static void check_idle __P((void *));
-static void connect_time_expired __P((void *));
-static int plogin __P((char *, char *, char **));
-static void plogout __P((void));
-static int null_login __P((int));
-static int get_pap_passwd __P((char *));
-static int have_pap_secret __P((int *));
-static int have_chap_secret __P((char *, char *, int, int *));
-static int ip_addr_check __P((u_int32_t, struct permitted_ip *));
-static int scan_authfile __P((FILE *, char *, char *, char *,
- struct wordlist **, struct wordlist **,
- char *));
-static void free_wordlist __P((struct wordlist *));
-static void auth_script __P((char *));
-static void auth_script_done __P((void *));
-static void set_allowed_addrs __P((int, struct wordlist *, struct wordlist *));
-static int some_ip_ok __P((struct wordlist *));
-static int setupapfile __P((char **));
-static int privgroup __P((char **));
-static int set_noauth_addr __P((char **));
-static void check_access __P((FILE *, char *));
-static int wordlist_count __P((struct wordlist *));
-
-/*
- * Authentication-related options.
- */
-option_t auth_options[] = {
- { "auth", o_bool, &auth_required,
- "Require authentication from peer", OPT_PRIO | 1 },
- { "noauth", o_bool, &auth_required,
- "Don't require peer to authenticate", OPT_PRIOSUB | OPT_PRIV,
- &allow_any_ip },
- { "require-pap", o_bool, &lcp_wantoptions[0].neg_upap,
- "Require PAP authentication from peer",
- OPT_PRIOSUB | 1, &auth_required },
- { "+pap", o_bool, &lcp_wantoptions[0].neg_upap,
- "Require PAP authentication from peer",
- OPT_ALIAS | OPT_PRIOSUB | 1, &auth_required },
- { "require-chap", o_bool, &lcp_wantoptions[0].neg_chap,
- "Require CHAP authentication from peer",
- OPT_PRIOSUB | 1, &auth_required },
- { "+chap", o_bool, &lcp_wantoptions[0].neg_chap,
- "Require CHAP authentication from peer",
- OPT_ALIAS | OPT_PRIOSUB | 1, &auth_required },
-
- { "refuse-pap", o_bool, &refuse_pap,
- "Don't agree to auth to peer with PAP", 1 },
- { "-pap", o_bool, &refuse_pap,
- "Don't allow PAP authentication with peer", OPT_ALIAS | 1 },
-
- { "refuse-chap", o_bool, &refuse_chap,
- "Don't agree to auth to peer with CHAP", 1 },
- { "-chap", o_bool, &refuse_chap,
- "Don't allow CHAP authentication with peer", OPT_ALIAS | 1 },
-
- { "name", o_string, our_name,
- "Set local name for authentication",
- OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXNAMELEN },
-
- { "+ua", o_special, (void *)setupapfile,
- "Get PAP user and password from file",
- OPT_PRIO | OPT_A2STRVAL, &uafname },
-
- { "user", o_string, user,
- "Set name for auth with peer", OPT_PRIO | OPT_STATIC, NULL, MAXNAMELEN },
-
- { "password", o_string, passwd,
- "Password for authenticating us to the peer",
- OPT_PRIO | OPT_STATIC | OPT_HIDE, NULL, MAXSECRETLEN },
-
- { "usehostname", o_bool, &usehostname,
- "Must use hostname for authentication", 1 },
-
- { "remotename", o_string, remote_name,
- "Set remote name for authentication", OPT_PRIO | OPT_STATIC,
- &explicit_remote, MAXNAMELEN },
-
- { "login", o_bool, &uselogin,
- "Use system password database for PAP", 1 },
-
- { "papcrypt", o_bool, &cryptpap,
- "PAP passwords are encrypted", 1 },
-
- { "privgroup", o_special, (void *)privgroup,
- "Allow group members to use privileged options", OPT_PRIV | OPT_A2LIST },
-
- { "allow-ip", o_special, (void *)set_noauth_addr,
- "Set IP address(es) which can be used without authentication",
- OPT_PRIV | OPT_A2LIST },
-
- { NULL }
-};
-
-/*
- * setupapfile - specifies UPAP info for authenticating with peer.
- */
-static int
-setupapfile(argv)
- char **argv;
-{
- FILE *ufile;
- int l;
- char u[MAXNAMELEN], p[MAXSECRETLEN];
- char *fname;
-
- lcp_allowoptions[0].neg_upap = 1;
-
- /* open user info file */
- fname = strdup(*argv);
- if (fname == NULL)
- novm("+ua file name");
- seteuid(getuid());
- ufile = fopen(fname, "r");
- seteuid(0);
- if (ufile == NULL) {
- option_error("unable to open user login data file %s", fname);
- return 0;
- }
- check_access(ufile, fname);
- uafname = fname;
-
- /* get username */
- if (fgets(u, MAXNAMELEN - 1, ufile) == NULL
- || fgets(p, MAXSECRETLEN - 1, ufile) == NULL){
- option_error("unable to read user login data file %s", fname);
- return 0;
- }
- fclose(ufile);
-
- /* get rid of newlines */
- l = strlen(u);
- if (l > 0 && u[l-1] == '\n')
- u[l-1] = 0;
- l = strlen(p);
- if (l > 0 && p[l-1] == '\n')
- p[l-1] = 0;
-
- if (override_value("user", option_priority, fname))
- strlcpy(user, u, sizeof(user));
- if (override_value("passwd", option_priority, fname))
- strlcpy(passwd, p, sizeof(passwd));
-
- return (1);
-}
-
-
-/*
- * privgroup - allow members of the group to have privileged access.
- */
-static int
-privgroup(argv)
- char **argv;
-{
- struct group *g;
- int i;
-
- g = getgrnam(*argv);
- if (g == 0) {
- option_error("group %s is unknown", *argv);
- return 0;
- }
- for (i = 0; i < ngroups; ++i) {
- if (groups[i] == g->gr_gid) {
- privileged = 1;
- break;
- }
- }
- return 1;
-}
-
-
-/*
- * set_noauth_addr - set address(es) that can be used without authentication.
- * Equivalent to specifying an entry like `"" * "" addr' in pap-secrets.
- */
-static int
-set_noauth_addr(argv)
- char **argv;
-{
- char *addr = *argv;
- int l = strlen(addr) + 1;
- struct wordlist *wp;
-
- wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l);
- if (wp == NULL)
- novm("allow-ip argument");
- wp->word = (char *) (wp + 1);
- wp->next = noauth_addrs;
- BCOPY(addr, wp->word, l);
- noauth_addrs = wp;
- return 1;
-}
-
-
-/*
- * An Open on LCP has requested a change from Dead to Establish phase.
- * Do what's necessary to bring the physical layer up.
- */
-void
-link_required(unit)
- int unit;
-{
-}
-
-/*
- * LCP has terminated the link; go to the Dead phase and take the
- * physical layer down.
- */
-void
-link_terminated(unit)
- int unit;
-{
- if (phase == PHASE_DEAD)
- return;
- if (pap_logout_hook) {
- pap_logout_hook();
- } else {
- if (logged_in)
- plogout();
- }
- new_phase(PHASE_DEAD);
- notice("Connection terminated.");
-}
-
-/*
- * LCP has gone down; it will either die or try to re-establish.
- */
-void
-link_down(unit)
- int unit;
-{
- int i;
- struct protent *protp;
-
- auth_state = s_down;
- if (auth_script_state == s_up && auth_script_pid == 0) {
- update_link_stats(unit);
- auth_script_state = s_down;
- auth_script(_PATH_AUTHDOWN);
- }
- for (i = 0; (protp = protocols[i]) != NULL; ++i) {
- if (!protp->enabled_flag)
- continue;
- if (protp->protocol != PPP_LCP && protp->lowerdown != NULL)
- (*protp->lowerdown)(unit);
- if (protp->protocol < 0xC000 && protp->close != NULL)
- (*protp->close)(unit, "LCP down");
- }
- num_np_open = 0;
- num_np_up = 0;
- if (phase != PHASE_DEAD)
- new_phase(PHASE_TERMINATE);
-}
-
-/*
- * The link is established.
- * Proceed to the Dead, Authenticate or Network phase as appropriate.
- */
-void
-link_established(unit)
- int unit;
-{
- int auth;
- lcp_options *wo = &lcp_wantoptions[unit];
- lcp_options *go = &lcp_gotoptions[unit];
- lcp_options *ho = &lcp_hisoptions[unit];
- int i;
- struct protent *protp;
-
- /*
- * Tell higher-level protocols that LCP is up.
- */
- for (i = 0; (protp = protocols[i]) != NULL; ++i)
- if (protp->protocol != PPP_LCP && protp->enabled_flag
- && protp->lowerup != NULL)
- (*protp->lowerup)(unit);
-
- if (auth_required && !(go->neg_chap || go->neg_upap)) {
- /*
- * We wanted the peer to authenticate itself, and it refused:
- * if we have some address(es) it can use without auth, fine,
- * otherwise treat it as though it authenticated with PAP using
- * a username * of "" and a password of "". If that's not OK,
- * boot it out.
- */
- if (noauth_addrs != NULL) {
- set_allowed_addrs(unit, NULL, NULL);
- } else if (!wo->neg_upap || uselogin || !null_login(unit)) {
- warn("peer refused to authenticate: terminating link");
- lcp_close(unit, "peer refused to authenticate");
- status = EXIT_PEER_AUTH_FAILED;
- return;
- }
- }
-
- new_phase(PHASE_AUTHENTICATE);
- used_login = 0;
- auth = 0;
- if (go->neg_chap) {
- ChapAuthPeer(unit, our_name, go->chap_mdtype);
- auth |= CHAP_PEER;
- } else if (go->neg_upap) {
- upap_authpeer(unit);
- auth |= PAP_PEER;
- }
- if (ho->neg_chap) {
- ChapAuthWithPeer(unit, user, ho->chap_mdtype);
- auth |= CHAP_WITHPEER;
- } else if (ho->neg_upap) {
- if (passwd[0] == 0) {
- passwd_from_file = 1;
- if (!get_pap_passwd(passwd))
- error("No secret found for PAP login");
- }
- upap_authwithpeer(unit, user, passwd);
- auth |= PAP_WITHPEER;
- }
- auth_pending[unit] = auth;
-
- if (!auth)
- network_phase(unit);
-}
-
-/*
- * Proceed to the network phase.
- */
-static void
-network_phase(unit)
- int unit;
-{
- lcp_options *go = &lcp_gotoptions[unit];
-
- /*
- * If the peer had to authenticate, run the auth-up script now.
- */
- if (go->neg_chap || go->neg_upap) {
- auth_state = s_up;
- if (auth_script_state == s_down && auth_script_pid == 0) {
- auth_script_state = s_up;
- auth_script(_PATH_AUTHUP);
- }
- }
-
-#ifdef CBCP_SUPPORT
- /*
- * If we negotiated callback, do it now.
- */
- if (go->neg_cbcp) {
- new_phase(PHASE_CALLBACK);
- (*cbcp_protent.open)(unit);
- return;
- }
-#endif
-
- /*
- * Process extra options from the secrets file
- */
- if (extra_options) {
- options_from_list(extra_options, 1);
- free_wordlist(extra_options);
- extra_options = 0;
- }
- start_networks();
-}
-
-void
-start_networks()
-{
- int i;
- struct protent *protp;
-
- new_phase(PHASE_NETWORK);
-
-#ifdef HAVE_MULTILINK
- if (multilink) {
- if (mp_join_bundle()) {
- if (updetach && !nodetach)
- detach();
- return;
- }
- }
-#endif /* HAVE_MULTILINK */
-
-#ifdef PPP_FILTER
- if (!demand)
- set_filters(&pass_filter, &active_filter);
-#endif
- for (i = 0; (protp = protocols[i]) != NULL; ++i)
- if (protp->protocol < 0xC000 && protp->enabled_flag
- && protp->open != NULL) {
- (*protp->open)(0);
- if (protp->protocol != PPP_CCP)
- ++num_np_open;
- }
-
- if (num_np_open == 0)
- /* nothing to do */
- lcp_close(0, "No network protocols running");
-}
-
-/*
- * The peer has failed to authenticate himself using `protocol'.
- */
-void
-auth_peer_fail(unit, protocol)
- int unit, protocol;
-{
- /*
- * Authentication failure: take the link down
- */
- lcp_close(unit, "Authentication failed");
- status = EXIT_PEER_AUTH_FAILED;
-}
-
-/*
- * The peer has been successfully authenticated using `protocol'.
- */
-void
-auth_peer_success(unit, protocol, name, namelen)
- int unit, protocol;
- char *name;
- int namelen;
-{
- int bit;
-
- switch (protocol) {
- case PPP_CHAP:
- bit = CHAP_PEER;
- break;
- case PPP_PAP:
- bit = PAP_PEER;
- break;
- default:
- warn("auth_peer_success: unknown protocol %x", protocol);
- return;
- }
-
- /*
- * Save the authenticated name of the peer for later.
- */
- if (namelen > sizeof(peer_authname) - 1)
- namelen = sizeof(peer_authname) - 1;
- BCOPY(name, peer_authname, namelen);
- peer_authname[namelen] = 0;
- script_setenv("PEERNAME", peer_authname, 0);
-
- /*
- * If there is no more authentication still to be done,
- * proceed to the network (or callback) phase.
- */
- if ((auth_pending[unit] &= ~bit) == 0)
- network_phase(unit);
-}
-
-/*
- * We have failed to authenticate ourselves to the peer using `protocol'.
- */
-void
-auth_withpeer_fail(unit, protocol)
- int unit, protocol;
-{
- if (passwd_from_file)
- BZERO(passwd, MAXSECRETLEN);
- /*
- * We've failed to authenticate ourselves to our peer.
- * Some servers keep sending CHAP challenges, but there
- * is no point in persisting without any way to get updated
- * authentication secrets.
- */
- lcp_close(unit, "Failed to authenticate ourselves to peer");
- status = EXIT_AUTH_TOPEER_FAILED;
-}
-
-/*
- * We have successfully authenticated ourselves with the peer using `protocol'.
- */
-void
-auth_withpeer_success(unit, protocol)
- int unit, protocol;
-{
- int bit;
-
- switch (protocol) {
- case PPP_CHAP:
- bit = CHAP_WITHPEER;
- break;
- case PPP_PAP:
- if (passwd_from_file)
- BZERO(passwd, MAXSECRETLEN);
- bit = PAP_WITHPEER;
- break;
- default:
- warn("auth_withpeer_success: unknown protocol %x", protocol);
- bit = 0;
- }
-
- /*
- * If there is no more authentication still being done,
- * proceed to the network (or callback) phase.
- */
- if ((auth_pending[unit] &= ~bit) == 0)
- network_phase(unit);
-}
-
-
-/*
- * np_up - a network protocol has come up.
- */
-void
-np_up(unit, proto)
- int unit, proto;
-{
- int tlim;
-
- if (num_np_up == 0) {
- /*
- * At this point we consider that the link has come up successfully.
- */
- status = EXIT_OK;
- unsuccess = 0;
- new_phase(PHASE_RUNNING);
-
- if (idle_time_hook != 0)
- tlim = (*idle_time_hook)(NULL);
- else
- tlim = idle_time_limit;
- if (tlim > 0)
- TIMEOUT(check_idle, NULL, tlim);
-
- /*
- * Set a timeout to close the connection once the maximum
- * connect time has expired.
- */
- if (maxconnect > 0)
- TIMEOUT(connect_time_expired, 0, maxconnect);
-
- /*
- * Detach now, if the updetach option was given.
- */
- if (updetach && !nodetach)
- detach();
- }
- ++num_np_up;
-}
-
-/*
- * np_down - a network protocol has gone down.
- */
-void
-np_down(unit, proto)
- int unit, proto;
-{
- if (--num_np_up == 0) {
- UNTIMEOUT(check_idle, NULL);
- new_phase(PHASE_NETWORK);
- }
-}
-
-/*
- * np_finished - a network protocol has finished using the link.
- */
-void
-np_finished(unit, proto)
- int unit, proto;
-{
- if (--num_np_open <= 0) {
- /* no further use for the link: shut up shop. */
- lcp_close(0, "No network protocols running");
- }
-}
-
-/*
- * check_idle - check whether the link has been idle for long
- * enough that we can shut it down.
- */
-static void
-check_idle(arg)
- void *arg;
-{
- struct ppp_idle idle;
- time_t itime;
- int tlim;
-
- if (!get_idle_time(0, &idle))
- return;
- if (idle_time_hook != 0) {
- tlim = idle_time_hook(&idle);
- } else {
- itime = MIN(idle.xmit_idle, idle.recv_idle);
- tlim = idle_time_limit - itime;
- }
- if (tlim <= 0) {
- /* link is idle: shut it down. */
- notice("Terminating connection due to lack of activity.");
- lcp_close(0, "Link inactive");
- need_holdoff = 0;
- status = EXIT_IDLE_TIMEOUT;
- } else {
- TIMEOUT(check_idle, NULL, tlim);
- }
-}
-
-/*
- * connect_time_expired - log a message and close the connection.
- */
-static void
-connect_time_expired(arg)
- void *arg;
-{
- info("Connect time expired");
- lcp_close(0, "Connect time expired"); /* Close connection */
- status = EXIT_CONNECT_TIME;
-}
-
-/*
- * auth_check_options - called to check authentication options.
- */
-void
-auth_check_options()
-{
- lcp_options *wo = &lcp_wantoptions[0];
- int can_auth;
- int lacks_ip;
-
- /* Default our_name to hostname, and user to our_name */
- if (our_name[0] == 0 || usehostname)
- strlcpy(our_name, hostname, sizeof(our_name));
- if (user[0] == 0)
- strlcpy(user, our_name, sizeof(user));
-
- /*
- * If we have a default route, require the peer to authenticate
- * unless the noauth option was given or the real user is root.
- */
- if (!auth_required && !allow_any_ip && have_route_to(0) && !privileged) {
- auth_required = 1;
- default_auth = 1;
- }
-
- /* If authentication is required, ask peer for CHAP or PAP. */
- if (auth_required) {
- allow_any_ip = 0;
- if (!wo->neg_chap && !wo->neg_upap) {
- wo->neg_chap = 1;
- wo->neg_upap = 1;
- }
- } else {
- wo->neg_chap = 0;
- wo->neg_upap = 0;
- }
-
- /*
- * Check whether we have appropriate secrets to use
- * to authenticate the peer.
- */
- lacks_ip = 0;
- can_auth = wo->neg_upap && (uselogin || have_pap_secret(&lacks_ip));
- if (!can_auth && wo->neg_chap) {
- can_auth = have_chap_secret((explicit_remote? remote_name: NULL),
- our_name, 1, &lacks_ip);
- }
-
- if (auth_required && !can_auth && noauth_addrs == NULL) {
- if (default_auth) {
- option_error(
-"By default the remote system is required to authenticate itself");
- option_error(
-"(because this system has a default route to the internet)");
- } else if (explicit_remote)
- option_error(
-"The remote system (%s) is required to authenticate itself",
- remote_name);
- else
- option_error(
-"The remote system is required to authenticate itself");
- option_error(
-"but I couldn't find any suitable secret (password) for it to use to do so.");
- if (lacks_ip)
- option_error(
-"(None of the available passwords would let it use an IP address.)");
-
- exit(1);
- }
-}
-
-/*
- * auth_reset - called when LCP is starting negotiations to recheck
- * authentication options, i.e. whether we have appropriate secrets
- * to use for authenticating ourselves and/or the peer.
- */
-void
-auth_reset(unit)
- int unit;
-{
- lcp_options *go = &lcp_gotoptions[unit];
- lcp_options *ao = &lcp_allowoptions[0];
-
- ao->neg_upap = !refuse_pap && (passwd[0] != 0 || get_pap_passwd(NULL));
- ao->neg_chap = !refuse_chap
- && (passwd[0] != 0
- || have_chap_secret(user, (explicit_remote? remote_name: NULL),
- 0, NULL));
-
- if (go->neg_upap && !uselogin && !have_pap_secret(NULL))
- go->neg_upap = 0;
- if (go->neg_chap) {
- if (!have_chap_secret((explicit_remote? remote_name: NULL),
- our_name, 1, NULL))
- go->neg_chap = 0;
- }
-}
-
-
-/*
- * check_passwd - Check the user name and passwd against the PAP secrets
- * file. If requested, also check against the system password database,
- * and login the user if OK.
- *
- * returns:
- * UPAP_AUTHNAK: Authentication failed.
- * UPAP_AUTHACK: Authentication succeeded.
- * In either case, msg points to an appropriate message.
- */
-int
-check_passwd(unit, auser, userlen, apasswd, passwdlen, msg)
- int unit;
- char *auser;
- int userlen;
- char *apasswd;
- int passwdlen;
- char **msg;
-{
- int ret;
- char *filename;
- FILE *f;
- struct wordlist *addrs = NULL, *opts = NULL;
- char passwd[256], user[256];
- char secret[MAXWORDLEN];
- static int attempts = 0;
-
- /*
- * Make copies of apasswd and auser, then null-terminate them.
- * If there are unprintable characters in the password, make
- * them visible.
- */
- slprintf(passwd, sizeof(passwd), "%.*v", passwdlen, apasswd);
- slprintf(user, sizeof(user), "%.*v", userlen, auser);
- *msg = "";
-
- /*
- * Check if a plugin wants to handle this.
- */
- if (pap_auth_hook) {
- ret = (*pap_auth_hook)(user, passwd, msg, &addrs, &opts);
- if (ret >= 0) {
- if (ret)
- set_allowed_addrs(unit, addrs, opts);
- BZERO(passwd, sizeof(passwd));
- if (addrs != 0)
- free_wordlist(addrs);
- return ret? UPAP_AUTHACK: UPAP_AUTHNAK;
- }
- }
-
- /*
- * Open the file of pap secrets and scan for a suitable secret
- * for authenticating this user.
- */
- filename = _PATH_UPAPFILE;
- addrs = opts = NULL;
- ret = UPAP_AUTHNAK;
- f = fopen(filename, "r");
- if (f == NULL) {
- error("Can't open PAP password file %s: %m", filename);
-
- } else {
- check_access(f, filename);
- if (scan_authfile(f, user, our_name, secret, &addrs, &opts, filename) < 0) {
- warn("no PAP secret found for %s", user);
- } else {
- /*
- * If the secret is "@login", it means to check
- * the password against the login database.
- */
- int login_secret = strcmp(secret, "@login") == 0;
- ret = UPAP_AUTHACK;
- if (uselogin || login_secret) {
- /* login option or secret is @login */
- ret = plogin(user, passwd, msg);
- if (ret == UPAP_AUTHNAK)
- warn("PAP login failure for %s", user);
- else
- used_login = 1;
- }
- if (secret[0] != 0 && !login_secret) {
- /* password given in pap-secrets - must match */
- if ((cryptpap || strcmp(passwd, secret) != 0)
- && strcmp(crypt(passwd, secret), secret) != 0) {
- ret = UPAP_AUTHNAK;
- warn("PAP authentication failure for %s", user);
- }
- }
- }
- fclose(f);
- }
-
- if (ret == UPAP_AUTHNAK) {
- if (**msg == 0)
- *msg = "Login incorrect";
- /*
- * XXX can we ever get here more than once??
- * Frustrate passwd stealer programs.
- * Allow 10 tries, but start backing off after 3 (stolen from login).
- * On 10'th, drop the connection.
- */
- if (attempts++ >= 10) {
- warn("%d LOGIN FAILURES ON %s, %s", attempts, devnam, user);
- lcp_close(unit, "login failed");
- }
- if (attempts > 3)
- sleep((u_int) (attempts - 3) * 5);
- if (opts != NULL)
- free_wordlist(opts);
-
- } else {
- attempts = 0; /* Reset count */
- if (**msg == 0)
- *msg = "Login ok";
- set_allowed_addrs(unit, addrs, opts);
- }
-
- if (addrs != NULL)
- free_wordlist(addrs);
- BZERO(passwd, sizeof(passwd));
- BZERO(secret, sizeof(secret));
-
- return ret;
-}
-
-/*
- * This function is needed for PAM.
- */
-
-#ifdef USE_PAM
-/* Static variables used to communicate between the conversation function
- * and the server_login function
- */
-static char *PAM_username;
-static char *PAM_password;
-static int PAM_error = 0;
-static pam_handle_t *pamh = NULL;
-
-/* PAM conversation function
- * Here we assume (for now, at least) that echo on means login name, and
- * echo off means password.
- */
-
-static int PAM_conv (int num_msg, const struct pam_message **msg,
- struct pam_response **resp, void *appdata_ptr)
-{
- int replies = 0;
- struct pam_response *reply = NULL;
-
-#define COPY_STRING(s) (s) ? strdup(s) : NULL
-
- reply = malloc(sizeof(struct pam_response) * num_msg);
- if (!reply) return PAM_CONV_ERR;
-
- for (replies = 0; replies < num_msg; replies++) {
- switch (msg[replies]->msg_style) {
- case PAM_PROMPT_ECHO_ON:
- reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = COPY_STRING(PAM_username);
- /* PAM frees resp */
- break;
- case PAM_PROMPT_ECHO_OFF:
- reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = COPY_STRING(PAM_password);
- /* PAM frees resp */
- break;
- case PAM_TEXT_INFO:
- /* fall through */
- case PAM_ERROR_MSG:
- /* ignore it, but pam still wants a NULL response... */
- reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = NULL;
- break;
- default:
- /* Must be an error of some sort... */
- free (reply);
- PAM_error = 1;
- return PAM_CONV_ERR;
- }
- }
- *resp = reply;
- return PAM_SUCCESS;
-}
-
-static struct pam_conv PAM_conversation = {
- &PAM_conv,
- NULL
-};
-#endif /* USE_PAM */
-
-/*
- * plogin - Check the user name and password against the system
- * password database, and login the user if OK.
- *
- * returns:
- * UPAP_AUTHNAK: Login failed.
- * UPAP_AUTHACK: Login succeeded.
- * In either case, msg points to an appropriate message.
- */
-
-static int
-plogin(user, passwd, msg)
- char *user;
- char *passwd;
- char **msg;
-{
- char *tty;
-
-#ifdef USE_PAM
- int pam_error;
-
- pam_error = pam_start ("ppp", user, &PAM_conversation, &pamh);
- if (pam_error != PAM_SUCCESS) {
- *msg = (char *) pam_strerror (pamh, pam_error);
- reopen_log();
- return UPAP_AUTHNAK;
- }
- /*
- * Define the fields for the credential validation
- */
-
- PAM_username = user;
- PAM_password = passwd;
- PAM_error = 0;
- pam_set_item (pamh, PAM_TTY, devnam); /* this might be useful to some modules */
-
- /*
- * Validate the user
- */
- pam_error = pam_authenticate (pamh, PAM_SILENT);
- if (pam_error == PAM_SUCCESS && !PAM_error) {
- pam_error = pam_acct_mgmt (pamh, PAM_SILENT);
- if (pam_error == PAM_SUCCESS)
- pam_error = pam_open_session (pamh, PAM_SILENT);
- }
-
- *msg = (char *) pam_strerror (pamh, pam_error);
-
- /*
- * Clean up the mess
- */
- reopen_log(); /* apparently the PAM stuff does closelog() */
- PAM_username = NULL;
- PAM_password = NULL;
- if (pam_error != PAM_SUCCESS)
- return UPAP_AUTHNAK;
-#else /* #ifdef USE_PAM */
-
-/*
- * Use the non-PAM methods directly
- */
-
-#ifdef HAS_SHADOW
- struct spwd *spwd;
- struct spwd *getspnam();
-#endif
- struct passwd *pw = getpwnam(user);
-
- endpwent();
- if (pw == NULL)
- return (UPAP_AUTHNAK);
-
-#ifdef HAS_SHADOW
- spwd = getspnam(user);
- endspent();
- if (spwd) {
- /* check the age of the password entry */
- long now = time(NULL) / 86400L;
-
- if ((spwd->sp_expire > 0 && now >= spwd->sp_expire)
- || ((spwd->sp_max >= 0 && spwd->sp_max < 10000)
- && spwd->sp_lstchg >= 0
- && now >= spwd->sp_lstchg + spwd->sp_max)) {
- warn("Password for %s has expired", user);
- return (UPAP_AUTHNAK);
- }
- pw->pw_passwd = spwd->sp_pwdp;
- }
-#endif
-
- /*
- * If no passwd, don't let them login.
- */
- if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2
- || strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd) != 0)
- return (UPAP_AUTHNAK);
-
-#endif /* #ifdef USE_PAM */
-
- /*
- * Write a wtmp entry for this user.
- */
-
- tty = devnam;
- if (strncmp(tty, "/dev/", 5) == 0)
- tty += 5;
-// logwtmp(tty, user, remote_name); /* Add wtmp login entry */
-
-#if defined(_PATH_LASTLOG) && !defined(USE_PAM)
- if (pw != (struct passwd *)NULL) {
- struct lastlog ll;
- int fd;
-
- if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
- (void)lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET);
- memset((void *)&ll, 0, sizeof(ll));
- (void)time(&ll.ll_time);
- (void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
- (void)write(fd, (char *)&ll, sizeof(ll));
- (void)close(fd);
- }
- }
-#endif /* _PATH_LASTLOG and not USE_PAM */
-
- info("user %s logged in", user);
- logged_in = 1;
-
- return (UPAP_AUTHACK);
-}
-
-/*
- * plogout - Logout the user.
- */
-static void
-plogout()
-{
-#ifdef USE_PAM
- int pam_error;
-
- if (pamh != NULL) {
- pam_error = pam_close_session (pamh, PAM_SILENT);
- pam_end (pamh, pam_error);
- pamh = NULL;
- }
- /* Apparently the pam stuff does closelog(). */
- reopen_log();
-#else /* ! USE_PAM */
- char *tty;
-
- tty = devnam;
- if (strncmp(tty, "/dev/", 5) == 0)
- tty += 5;
-// logwtmp(tty, "", ""); /* Wipe out utmp logout entry */
-#endif /* ! USE_PAM */
- logged_in = 0;
-}
-
-
-/*
- * null_login - Check if a username of "" and a password of "" are
- * acceptable, and iff so, set the list of acceptable IP addresses
- * and return 1.
- */
-static int
-null_login(unit)
- int unit;
-{
- char *filename;
- FILE *f;
- int i, ret;
- struct wordlist *addrs, *opts;
- char secret[MAXWORDLEN];
-
- /*
- * Open the file of pap secrets and scan for a suitable secret.
- */
- filename = _PATH_UPAPFILE;
- addrs = NULL;
- f = fopen(filename, "r");
- if (f == NULL)
- return 0;
- check_access(f, filename);
-
- i = scan_authfile(f, "", our_name, secret, &addrs, &opts, filename);
- ret = i >= 0 && secret[0] == 0;
- BZERO(secret, sizeof(secret));
-
- if (ret)
- set_allowed_addrs(unit, addrs, opts);
- else if (opts != 0)
- free_wordlist(opts);
- if (addrs != 0)
- free_wordlist(addrs);
-
- fclose(f);
- return ret;
-}
-
-
-/*
- * get_pap_passwd - get a password for authenticating ourselves with
- * our peer using PAP. Returns 1 on success, 0 if no suitable password
- * could be found.
- * Assumes passwd points to MAXSECRETLEN bytes of space (if non-null).
- */
-static int
-get_pap_passwd(passwd)
- char *passwd;
-{
- char *filename;
- FILE *f;
- int ret;
- char secret[MAXWORDLEN];
-
- /*
- * Check whether a plugin wants to supply this.
- */
- if (pap_passwd_hook) {
- ret = (*pap_passwd_hook)(user, passwd);
- if (ret >= 0)
- return ret;
- }
-
- filename = _PATH_UPAPFILE;
- f = fopen(filename, "r");
- if (f == NULL)
- return 0;
- check_access(f, filename);
- ret = scan_authfile(f, user,
- (remote_name[0]? remote_name: NULL),
- secret, NULL, NULL, filename);
- fclose(f);
- if (ret < 0)
- return 0;
- if (passwd != NULL)
- strlcpy(passwd, secret, MAXSECRETLEN);
- BZERO(secret, sizeof(secret));
- return 1;
-}
-
-
-/*
- * have_pap_secret - check whether we have a PAP file with any
- * secrets that we could possibly use for authenticating the peer.
- */
-static int
-have_pap_secret(lacks_ipp)
- int *lacks_ipp;
-{
- FILE *f;
- int ret;
- char *filename;
- struct wordlist *addrs;
-
- /* let the plugin decide, if there is one */
- if (pap_check_hook) {
- ret = (*pap_check_hook)();
- if (ret >= 0)
- return ret;
- }
-
- filename = _PATH_UPAPFILE;
- f = fopen(filename, "r");
- if (f == NULL)
- return 0;
-
- ret = scan_authfile(f, (explicit_remote? remote_name: NULL), our_name,
- NULL, &addrs, NULL, filename);
- fclose(f);
- if (ret >= 0 && !some_ip_ok(addrs)) {
- if (lacks_ipp != 0)
- *lacks_ipp = 1;
- ret = -1;
- }
- if (addrs != 0)
- free_wordlist(addrs);
-
- return ret >= 0;
-}
-
-
-/*
- * have_chap_secret - check whether we have a CHAP file with a
- * secret that we could possibly use for authenticating `client'
- * on `server'. Either can be the null string, meaning we don't
- * know the identity yet.
- */
-static int
-have_chap_secret(client, server, need_ip, lacks_ipp)
- char *client;
- char *server;
- int need_ip;
- int *lacks_ipp;
-{
- FILE *f;
- int ret;
- char *filename;
- struct wordlist *addrs;
-
- filename = _PATH_CHAPFILE;
- f = fopen(filename, "r");
- if (f == NULL)
- return 0;
-
- if (client != NULL && client[0] == 0)
- client = NULL;
- else if (server != NULL && server[0] == 0)
- server = NULL;
-
- ret = scan_authfile(f, client, server, NULL, &addrs, NULL, filename);
- fclose(f);
- if (ret >= 0 && need_ip && !some_ip_ok(addrs)) {
- if (lacks_ipp != 0)
- *lacks_ipp = 1;
- ret = -1;
- }
- if (addrs != 0)
- free_wordlist(addrs);
-
- return ret >= 0;
-}
-
-
-/*
- * get_secret - open the CHAP secret file and return the secret
- * for authenticating the given client on the given server.
- * (We could be either client or server).
- */
-int
-get_secret(unit, client, server, secret, secret_len, am_server)
- int unit;
- char *client;
- char *server;
- char *secret;
- int *secret_len;
- int am_server;
-{
- FILE *f;
- int ret, len;
- char *filename;
- struct wordlist *addrs, *opts;
- char secbuf[MAXWORDLEN];
-
- if (!am_server && passwd[0] != 0) {
- strlcpy(secbuf, passwd, sizeof(secbuf));
- } else {
- filename = _PATH_CHAPFILE;
- addrs = NULL;
- secbuf[0] = 0;
-
- f = fopen(filename, "r");
- if (f == NULL) {
- error("Can't open chap secret file %s: %m", filename);
- return 0;
- }
- check_access(f, filename);
-
- ret = scan_authfile(f, client, server, secbuf, &addrs, &opts, filename);
- fclose(f);
- if (ret < 0)
- return 0;
-
- if (am_server)
- set_allowed_addrs(unit, addrs, opts);
- else if (opts != 0)
- free_wordlist(opts);
- if (addrs != 0)
- free_wordlist(addrs);
- }
-
- len = strlen(secbuf);
- if (len > MAXSECRETLEN) {
- error("Secret for %s on %s is too long", client, server);
- len = MAXSECRETLEN;
- }
- BCOPY(secbuf, secret, len);
- BZERO(secbuf, sizeof(secbuf));
- *secret_len = len;
-
- return 1;
-}
-
-/*
- * set_allowed_addrs() - set the list of allowed addresses.
- * Also looks for `--' indicating options to apply for this peer
- * and leaves the following words in extra_options.
- */
-static void
-set_allowed_addrs(unit, addrs, opts)
- int unit;
- struct wordlist *addrs;
- struct wordlist *opts;
-{
- int n;
- struct wordlist *ap, **plink;
- struct permitted_ip *ip;
- char *ptr_word, *ptr_mask;
- struct hostent *hp;
- u_int32_t a, mask, offset;
- struct ipcp_options *wo = &ipcp_wantoptions[unit];
- u_int32_t suggested_ip = 0;
-
- if (addresses[unit] != NULL)
- free(addresses[unit]);
- addresses[unit] = NULL;
- if (extra_options != NULL)
- free_wordlist(extra_options);
- extra_options = opts;
-
- /*
- * Count the number of IP addresses given.
- */
- n = wordlist_count(addrs) + wordlist_count(noauth_addrs);
- if (n == 0)
- return;
- ip = (struct permitted_ip *) malloc((n + 1) * sizeof(struct permitted_ip));
- if (ip == 0)
- return;
-
- /* temporarily append the noauth_addrs list to addrs */
- for (plink = &addrs; *plink != NULL; plink = &(*plink)->next)
- ;
- *plink = noauth_addrs;
-
- n = 0;
- for (ap = addrs; ap != NULL; ap = ap->next) {
- /* "-" means no addresses authorized, "*" means any address allowed */
- ptr_word = ap->word;
- if (strcmp(ptr_word, "-") == 0)
- break;
- if (strcmp(ptr_word, "*") == 0) {
- ip[n].permit = 1;
- ip[n].base = ip[n].mask = 0;
- ++n;
- break;
- }
-
- ip[n].permit = 1;
- if (*ptr_word == '!') {
- ip[n].permit = 0;
- ++ptr_word;
- }
-
- mask = ~ (u_int32_t) 0;
- offset = 0;
- ptr_mask = strchr (ptr_word, '/');
- if (ptr_mask != NULL) {
- int bit_count;
- char *endp;
-
- bit_count = (int) strtol (ptr_mask+1, &endp, 10);
- if (bit_count <= 0 || bit_count > 32) {
- warn("invalid address length %v in auth. address list",
- ptr_mask+1);
- continue;
- }
- bit_count = 32 - bit_count; /* # bits in host part */
- if (*endp == '+') {
- offset = ifunit + 1;
- ++endp;
- }
- if (*endp != 0) {
- warn("invalid address length syntax: %v", ptr_mask+1);
- continue;
- }
- *ptr_mask = '\0';
- mask <<= bit_count;
- }
-
- hp = gethostbyname(ptr_word);
- if (hp != NULL && hp->h_addrtype == AF_INET) {
- a = *(u_int32_t *)hp->h_addr;
- } else {
- printf("*** getnetbyname is unsupported, please report bug! ***\n");
- return;
- }
-
- if (ptr_mask != NULL)
- *ptr_mask = '/';
-
- if (a == (u_int32_t)-1L) {
- warn("unknown host %s in auth. address list", ap->word);
- continue;
- }
- if (offset != 0) {
- if (offset >= ~mask) {
- warn("interface unit %d too large for subnet %v",
- ifunit, ptr_word);
- continue;
- }
- a = htonl((ntohl(a) & mask) + offset);
- mask = ~(u_int32_t)0;
- }
- ip[n].mask = htonl(mask);
- ip[n].base = a & ip[n].mask;
- ++n;
- if (~mask == 0 && suggested_ip == 0)
- suggested_ip = a;
- }
- *plink = NULL;
-
- ip[n].permit = 0; /* make the last entry forbid all addresses */
- ip[n].base = 0; /* to terminate the list */
- ip[n].mask = 0;
-
- addresses[unit] = ip;
-
- /*
- * If the address given for the peer isn't authorized, or if
- * the user hasn't given one, AND there is an authorized address
- * which is a single host, then use that if we find one.
- */
- if (suggested_ip != 0
- && (wo->hisaddr == 0 || !auth_ip_addr(unit, wo->hisaddr))) {
- wo->hisaddr = suggested_ip;
- /*
- * Do we insist on this address? No, if there are other
- * addresses authorized than the suggested one.
- */
- if (n > 1)
- wo->accept_remote = 1;
- }
-}
-
-/*
- * auth_ip_addr - check whether the peer is authorized to use
- * a given IP address. Returns 1 if authorized, 0 otherwise.
- */
-int
-auth_ip_addr(unit, addr)
- int unit;
- u_int32_t addr;
-{
- int ok;
-
- /* don't allow loopback or multicast address */
- if (bad_ip_adrs(addr))
- return 0;
-
- if (addresses[unit] != NULL) {
- ok = ip_addr_check(addr, addresses[unit]);
- if (ok >= 0)
- return ok;
- }
- if (auth_required)
- return 0; /* no addresses authorized */
- return allow_any_ip || privileged || !have_route_to(addr);
-}
-
-static int
-ip_addr_check(addr, addrs)
- u_int32_t addr;
- struct permitted_ip *addrs;
-{
- for (; ; ++addrs)
- if ((addr & addrs->mask) == addrs->base)
- return addrs->permit;
-}
-
-/*
- * bad_ip_adrs - return 1 if the IP address is one we don't want
- * to use, such as an address in the loopback net or a multicast address.
- * addr is in network byte order.
- */
-int
-bad_ip_adrs(addr)
- u_int32_t addr;
-{
- addr = ntohl(addr);
- return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET
- || IN_MULTICAST(addr) || IN_BADCLASS(addr);
-}
-
-/*
- * some_ip_ok - check a wordlist to see if it authorizes any
- * IP address(es).
- */
-static int
-some_ip_ok(addrs)
- struct wordlist *addrs;
-{
- for (; addrs != 0; addrs = addrs->next) {
- if (addrs->word[0] == '-')
- break;
- if (addrs->word[0] != '!')
- return 1; /* some IP address is allowed */
- }
- return 0;
-}
-
-/*
- * check_access - complain if a secret file has too-liberal permissions.
- */
-static void
-check_access(f, filename)
- FILE *f;
- char *filename;
-{
- struct stat sbuf;
-
- if (fstat(fileno(f), &sbuf) < 0) {
- warn("cannot stat secret file %s: %m", filename);
- } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) {
- warn("Warning - secret file %s has world and/or group access",
- filename);
- }
-}
-
-
-/*
- * scan_authfile - Scan an authorization file for a secret suitable
- * for authenticating `client' on `server'. The return value is -1
- * if no secret is found, otherwise >= 0. The return value has
- * NONWILD_CLIENT set if the secret didn't have "*" for the client, and
- * NONWILD_SERVER set if the secret didn't have "*" for the server.
- * Any following words on the line up to a "--" (i.e. address authorization
- * info) are placed in a wordlist and returned in *addrs. Any
- * following words (extra options) are placed in a wordlist and
- * returned in *opts.
- * We assume secret is NULL or points to MAXWORDLEN bytes of space.
- */
-static int
-scan_authfile(f, client, server, secret, addrs, opts, filename)
- FILE *f;
- char *client;
- char *server;
- char *secret;
- struct wordlist **addrs;
- struct wordlist **opts;
- char *filename;
-{
- int newline, xxx;
- int got_flag, best_flag;
- FILE *sf;
- struct wordlist *ap, *addr_list, *alist, **app;
- char word[MAXWORDLEN];
- char atfile[MAXWORDLEN];
- char lsecret[MAXWORDLEN];
-
- if (addrs != NULL)
- *addrs = NULL;
- if (opts != NULL)
- *opts = NULL;
- addr_list = NULL;
- if (!getword(f, word, &newline, filename))
- return -1; /* file is empty??? */
- newline = 1;
- best_flag = -1;
- for (;;) {
- /*
- * Skip until we find a word at the start of a line.
- */
- while (!newline && getword(f, word, &newline, filename))
- ;
- if (!newline)
- break; /* got to end of file */
-
- /*
- * Got a client - check if it's a match or a wildcard.
- */
- got_flag = 0;
- if (client != NULL && strcmp(word, client) != 0 && !ISWILD(word)) {
- newline = 0;
- continue;
- }
- if (!ISWILD(word))
- got_flag = NONWILD_CLIENT;
-
- /*
- * Now get a server and check if it matches.
- */
- if (!getword(f, word, &newline, filename))
- break;
- if (newline)
- continue;
- if (!ISWILD(word)) {
- if (server != NULL && strcmp(word, server) != 0)
- continue;
- got_flag |= NONWILD_SERVER;
- }
-
- /*
- * Got some sort of a match - see if it's better than what
- * we have already.
- */
- if (got_flag <= best_flag)
- continue;
-
- /*
- * Get the secret.
- */
- if (!getword(f, word, &newline, filename))
- break;
- if (newline)
- continue;
-
- if (secret != NULL) {
- /*
- * Special syntax: @/pathname means read secret from file.
- */
- if (word[0] == '@' && word[1] == '/') {
- strlcpy(atfile, word+1, sizeof(atfile));
- if ((sf = fopen(atfile, "r")) == NULL) {
- warn("can't open indirect secret file %s", atfile);
- continue;
- }
- check_access(sf, atfile);
- if (!getword(sf, word, &xxx, atfile)) {
- warn("no secret in indirect secret file %s", atfile);
- fclose(sf);
- continue;
- }
- fclose(sf);
- }
- strlcpy(lsecret, word, sizeof(lsecret));
- }
-
- /*
- * Now read address authorization info and make a wordlist.
- */
- app = &alist;
- for (;;) {
- if (!getword(f, word, &newline, filename) || newline)
- break;
- ap = (struct wordlist *)
- malloc(sizeof(struct wordlist) + strlen(word) + 1);
- if (ap == NULL)
- novm("authorized addresses");
- ap->word = (char *) (ap + 1);
- strcpy(ap->word, word);
- *app = ap;
- app = &ap->next;
- }
- *app = NULL;
-
- /*
- * This is the best so far; remember it.
- */
- best_flag = got_flag;
- if (addr_list)
- free_wordlist(addr_list);
- addr_list = alist;
- if (secret != NULL)
- strlcpy(secret, lsecret, MAXWORDLEN);
-
- if (!newline)
- break;
- }
-
- /* scan for a -- word indicating the start of options */
- for (app = &addr_list; (ap = *app) != NULL; app = &ap->next)
- if (strcmp(ap->word, "--") == 0)
- break;
- /* ap = start of options */
- if (ap != NULL) {
- ap = ap->next; /* first option */
- free(*app); /* free the "--" word */
- *app = NULL; /* terminate addr list */
- }
- if (opts != NULL)
- *opts = ap;
- else if (ap != NULL)
- free_wordlist(ap);
- if (addrs != NULL)
- *addrs = addr_list;
- else if (addr_list != NULL)
- free_wordlist(addr_list);
-
- return best_flag;
-}
-
-/*
- * wordlist_count - return the number of items in a wordlist
- */
-static int
-wordlist_count(wp)
- struct wordlist *wp;
-{
- int n;
-
- for (n = 0; wp != NULL; wp = wp->next)
- ++n;
- return n;
-}
-
-/*
- * free_wordlist - release memory allocated for a wordlist.
- */
-static void
-free_wordlist(wp)
- struct wordlist *wp;
-{
- struct wordlist *next;
-
- while (wp != NULL) {
- next = wp->next;
- free(wp);
- wp = next;
- }
-}
-
-/*
- * auth_script_done - called when the auth-up or auth-down script
- * has finished.
- */
-static void
-auth_script_done(arg)
- void *arg;
-{
- auth_script_pid = 0;
- switch (auth_script_state) {
- case s_up:
- if (auth_state == s_down) {
- auth_script_state = s_down;
- auth_script(_PATH_AUTHDOWN);
- }
- break;
- case s_down:
- if (auth_state == s_up) {
- auth_script_state = s_up;
- auth_script(_PATH_AUTHUP);
- }
- break;
- }
-}
-
-/*
- * auth_script - execute a script with arguments
- * interface-name peer-name real-user tty speed
- */
-static void
-auth_script(script)
- char *script;
-{
- char strspeed[32];
- struct passwd *pw;
- char struid[32];
- char *user_name;
- char *argv[8];
-
- if ((pw = getpwuid(getuid())) != NULL && pw->pw_name != NULL)
- user_name = pw->pw_name;
- else {
- slprintf(struid, sizeof(struid), "%d", getuid());
- user_name = struid;
- }
- slprintf(strspeed, sizeof(strspeed), "%d", baud_rate);
-
- argv[0] = script;
- argv[1] = ifname;
- argv[2] = peer_authname;
- argv[3] = user_name;
- argv[4] = devnam;
- argv[5] = strspeed;
- argv[6] = NULL;
-
- auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL);
-}
diff --git a/mdk-stage1/ppp/pppd/cbcp.c b/mdk-stage1/ppp/pppd/cbcp.c
deleted file mode 100644
index 8c57b3cde..000000000
--- a/mdk-stage1/ppp/pppd/cbcp.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * cbcp - Call Back Configuration Protocol.
- *
- * Copyright (c) 1995 Pedro Roque Marques
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Pedro Roque Marques. The name of the author may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define RCSID "$Id$"
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include "pppd.h"
-#include "cbcp.h"
-#include "fsm.h"
-#include "lcp.h"
-
-static const char rcsid[] = RCSID;
-
-/*
- * Options.
- */
-static int setcbcp __P((char **));
-
-static option_t cbcp_option_list[] = {
- { "callback", o_special, setcbcp,
- "Ask for callback", OPT_PRIO | OPT_A2STRVAL, &cbcp[0].us_number },
- { NULL }
-};
-
-/*
- * Protocol entry points.
- */
-static void cbcp_init __P((int unit));
-static void cbcp_open __P((int unit));
-static void cbcp_lowerup __P((int unit));
-static void cbcp_input __P((int unit, u_char *pkt, int len));
-static void cbcp_protrej __P((int unit));
-static int cbcp_printpkt __P((u_char *pkt, int len,
- void (*printer) __P((void *, char *, ...)),
- void *arg));
-
-struct protent cbcp_protent = {
- PPP_CBCP,
- cbcp_init,
- cbcp_input,