aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-07-24 08:01:31 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-07-24 08:01:31 +0000
commitb70981b68efcce5256eb11c6cd26ae123b10b6ea (patch)
treea38be6efae5e2ba15c2e839504632f9b7bfd5f91 /main
parent2b4df81538b8398442d5296650905c70341dd8d3 (diff)
moved extra/* to main/
and fixed misc build issues
Diffstat (limited to 'main')
-rw-r--r--main/acct/APKBUILD27
-rw-r--r--main/acf-alpine-baselayout/APKBUILD15
-rw-r--r--main/acf-alpine-conf/APKBUILD15
-rw-r--r--main/acf-apk-tools/APKBUILD16
-rw-r--r--main/acf-asterisk/APKBUILD21
-rw-r--r--main/acf-chrony/APKBUILD15
-rw-r--r--main/acf-clamav/APKBUILD21
-rw-r--r--main/acf-clamsmtp/APKBUILD21
-rw-r--r--main/acf-core/APKBUILD15
-rw-r--r--main/acf-dansguardian/APKBUILD21
-rw-r--r--main/acf-dhcp/APKBUILD21
-rw-r--r--main/acf-dnscache/APKBUILD15
-rw-r--r--main/acf-dnsmasq/APKBUILD15
-rw-r--r--main/acf-dovecot/APKBUILD21
-rw-r--r--main/acf-fetchmail/APKBUILD21
-rw-r--r--main/acf-gnats/APKBUILD15
-rw-r--r--main/acf-gross/APKBUILD15
-rw-r--r--main/acf-ipsec-tools/APKBUILD15
-rw-r--r--main/acf-iptables/APKBUILD21
-rw-r--r--main/acf-mdadm/APKBUILD22
-rw-r--r--main/acf-opennhrp/APKBUILD15
-rw-r--r--main/acf-openntpd/APKBUILD21
-rw-r--r--main/acf-openssh/APKBUILD15
-rw-r--r--main/acf-openssl/APKBUILD21
-rw-r--r--main/acf-openvpn/APKBUILD21
-rw-r--r--main/acf-pingu/APKBUILD21
-rw-r--r--main/acf-postfix/APKBUILD21
-rw-r--r--main/acf-postgresql/APKBUILD22
-rw-r--r--main/acf-ppp/APKBUILD15
-rw-r--r--main/acf-quagga/APKBUILD15
-rw-r--r--main/acf-samba/APKBUILD21
-rw-r--r--main/acf-shorewall/APKBUILD15
-rw-r--r--main/acf-skins/APKBUILD15
-rw-r--r--main/acf-snort/APKBUILD21
-rw-r--r--main/acf-squid/APKBUILD21
-rw-r--r--main/acf-tcpproxy/APKBUILD21
-rw-r--r--main/acf-tinydns/APKBUILD15
-rw-r--r--main/acf-weblog/APKBUILD20
-rw-r--r--main/alsa-lib/APKBUILD22
-rw-r--r--main/alsa-lib/nocxx.patch15
-rw-r--r--main/amavisd-new/APKBUILD50
-rwxr-xr-xmain/amavisd-new/amavisd-new.post-install14
-rw-r--r--main/amavisd-new/amavisd.init23
-rw-r--r--main/apr-util/APKBUILD32
-rw-r--r--main/apr/APKBUILD35
-rw-r--r--main/arpwatch/APKBUILD36
-rw-r--r--main/arpwatch/arpwatch.confd12
-rw-r--r--main/arpwatch/arpwatch.initd37
-rw-r--r--main/aspell/APKBUILD31
-rw-r--r--main/aspell/libmath.patch11
-rw-r--r--main/asterisk/100-uclibc-daemon.patch44
-rw-r--r--main/asterisk/101-caps-uclibc.patch17
-rw-r--r--main/asterisk/102-gsm-pic.patch54
-rw-r--r--main/asterisk/103-rundir.patch11
-rw-r--r--main/asterisk/APKBUILD96
-rw-r--r--main/asterisk/asterisk.confd91
-rw-r--r--main/asterisk/asterisk.initd250
-rw-r--r--main/asterisk/asterisk.post-install11
-rw-r--r--main/asterisk/asterisk.pre-install9
-rw-r--r--main/aumix/APKBUILD38
-rw-r--r--main/aumix/aumix-2.8-mute.patch16
-rw-r--r--main/aumix/aumix-2.8-nohome.patch12
-rw-r--r--main/aumix/aumix-2.8-save_load.patch45
-rw-r--r--main/aumix/aumix.initd42
-rw-r--r--main/b43-fwcutter/APKBUILD24
-rw-r--r--main/bc/APKBUILD27
-rw-r--r--main/beep/APKBUILD29
-rw-r--r--main/beep/beep-1.2.2-nosuid.patch33
-rw-r--r--main/bind/APKBUILD95
-rw-r--r--main/bind/bind.127.zone11
-rw-r--r--main/bind/bind.conf53
-rw-r--r--main/bind/bind.confd14
-rw-r--r--main/bind/bind.initd24
-rw-r--r--main/bind/bind.localhost.zone11
-rw-r--r--main/bind/bind.named.ca85
-rw-r--r--main/bind/bind.post-install5
-rw-r--r--main/bind/bind.pre-install5
-rw-r--r--main/bind/bind.so_bsdcompat.patch11
-rw-r--r--main/bitlib/APKBUILD21
-rw-r--r--main/bridge-utils/APKBUILD25
-rw-r--r--main/bzip2/APKBUILD48
-rw-r--r--main/bzip2/bzip2-1.0.4-POSIX-shell.patch21
-rw-r--r--main/bzip2/bzip2-1.0.4-makefile-CFLAGS.patch25
-rw-r--r--main/bzip2/bzip2-1.0.4-man-links.patch12
-rw-r--r--main/bzip2/bzip2-1.0.4-saneso.patch13
-rw-r--r--main/bzip2/bzip2.post-deinstall3
-rw-r--r--main/c-ares/APKBUILD26
-rw-r--r--main/ca-certificates/APKBUILD30
-rw-r--r--main/ca-certificates/ca-certificates.post-install5
-rw-r--r--main/ccache/APKBUILD32
-rw-r--r--main/cdrkit/APKBUILD31
-rw-r--r--main/cgit/APKBUILD29
-rw-r--r--main/chrony/APKBUILD60
-rw-r--r--main/chrony/chrony-1.20-chrony.conf.example-gentoo.diff46
-rw-r--r--main/chrony/chrony-1.20-conf.c-gentoo.diff11
-rw-r--r--main/chrony/chrony-1.21-makefile.diff15
-rw-r--r--main/chrony/chrony-1.23-reply-ip.diff242
-rw-r--r--main/chrony/chrony-1.23-sources.diff56
-rw-r--r--main/chrony/chrony.conf7
-rw-r--r--main/chrony/chronyd.confd18
-rw-r--r--main/chrony/chronyd.initd58
-rw-r--r--main/cksfv/APKBUILD22
-rw-r--r--main/clamav/APKBUILD72
-rw-r--r--main/clamav/clamav-0.95.1-nls.patch11
-rw-r--r--main/clamav/clamav.logrotate15
-rw-r--r--main/clamav/clamav.post-install3
-rw-r--r--main/clamav/clamav.pre-install4
-rw-r--r--main/clamav/clamav.pre-upgrade16
-rw-r--r--main/clamav/clamd.confd6
-rw-r--r--main/clamav/clamd.initd56
-rw-r--r--main/clamav/freshclam.confd3
-rw-r--r--main/clamav/freshclam.initd58
-rw-r--r--main/clamsmtp/0001-extra-clamsmtp-renamed-init.d-script-to-clamsmtpd.patch181
-rw-r--r--main/clamsmtp/APKBUILD38
-rw-r--r--main/clamsmtp/clamsmtp.post-upgrade17
-rw-r--r--main/clamsmtp/clamsmtp.pre-upgrade12
-rw-r--r--main/clamsmtp/clamsmtpd.confd5
-rw-r--r--main/clamsmtp/clamsmtpd.initd22
-rw-r--r--main/cmake/APKBUILD35
-rw-r--r--main/conntrack-tools/APKBUILD28
-rw-r--r--main/conntrack-tools/conntrackd.confd15
-rw-r--r--main/conntrack-tools/conntrackd.initd99
-rw-r--r--main/coreutils/APKBUILD31
-rw-r--r--main/coreutils/coreutils.post-deinstall3
l---------main/coreutils/coreutils.post-upgrade1
-rw-r--r--main/cpufreqd/APKBUILD26
-rw-r--r--main/cpufreqd/cpufreqd.initd43
-rw-r--r--main/cpufrequtils/APKBUILD42
-rw-r--r--main/cpufrequtils/cpufrequtils-005-build.patch24
-rw-r--r--main/cpufrequtils/cpufrequtils-005-nls.patch73
-rw-r--r--main/cpufrequtils/cpufrequtils.confd7
-rw-r--r--main/cpufrequtils/cpufrequtils.initd22
-rw-r--r--main/cracklib-words/APKBUILD21
-rw-r--r--main/cracklib/APKBUILD31
-rw-r--r--main/ctags/APKBUILD26
-rw-r--r--main/cutter/APKBUILD27
-rw-r--r--main/cvs/APKBUILD27
-rw-r--r--main/cyrus-sasl/APKBUILD55
-rw-r--r--main/cyrus-sasl/cyrus-sasl-2.1.19-checkpw.c.patch170
-rw-r--r--main/cyrus-sasl/db-4.7.patch20
-rw-r--r--main/cyrus-sasl/saslauthd.initd21
-rw-r--r--main/dahdi-linux-grsec/APKBUILD57
-rw-r--r--main/dahdi-linux-grsec/dahdi-bri_dchan.patch161
-rw-r--r--main/dahdi-linux-grsec/dahdi-depmod.patch22
-rw-r--r--main/dahdi-linux-grsec/dahdi-linux-2.2.0-hfc-4s.patch553
-rw-r--r--main/dahdi-linux-grsec/dahdi-zaphfc.patch1429
-rw-r--r--main/dahdi-linux-grsec/zaphfc-dahdi-flortz.diff1232
-rw-r--r--main/dahdi-linux/APKBUILD35
-rw-r--r--main/dahdi-tools/APKBUILD32
-rw-r--r--main/dahdi-tools/dahdi-tools.initd21
-rw-r--r--main/dansguardian/APKBUILD39
-rw-r--r--main/dansguardian/dansguardian.initd32
-rw-r--r--main/dansguardian/dansguardian.pre-install5
-rw-r--r--main/db/APKBUILD49
-rw-r--r--main/db/patch.4.7.25.175
-rw-r--r--main/db/patch.4.7.25.271
-rw-r--r--main/db/patch.4.7.25.3314
-rw-r--r--main/db/patch.4.7.25.4183
-rw-r--r--main/dhcp/APKBUILD36
-rw-r--r--main/dhcp/dhcp.post-upgrade18
-rw-r--r--main/dhcp/dhcp.pre-upgrade8
-rw-r--r--main/dhcp/dhcpd.confd30
-rw-r--r--main/dhcp/dhcpd.initd72
-rw-r--r--main/dhcpcd/APKBUILD26
-rw-r--r--main/dialog/APKBUILD27
-rw-r--r--main/diffutils/APKBUILD26
-rw-r--r--main/diffutils/diffutils.post-deinstall2
-rw-r--r--main/dircproxy/1.0.5-CVE-2007-5226.patch12
-rw-r--r--main/dircproxy/1.1.0-less-lag-on-attach.patch53
-rw-r--r--main/dircproxy/APKBUILD40
-rw-r--r--main/dircproxy/dircproxy-gcc4.patch47
-rw-r--r--main/djbdns/1.05-errno.patch11
-rw-r--r--main/djbdns/1.05-response.patch11
-rw-r--r--main/djbdns/APKBUILD86
-rw-r--r--main/djbdns/dnscache.confd23
-rwxr-xr-xmain/djbdns/dnscache.initd59
-rw-r--r--main/djbdns/dnscache.pre-install5
-rw-r--r--main/djbdns/dnsroots.patch18
-rw-r--r--main/djbdns/dnstracesort.patch11
-rw-r--r--main/djbdns/headtail.patch67
-rw-r--r--main/djbdns/tinydns.confd2
-rwxr-xr-xmain/djbdns/tinydns.initd87
-rw-r--r--main/djbdns/tinydns.pre-install5
-rw-r--r--main/dnsmasq/APKBUILD37
-rw-r--r--main/dnsmasq/dnsmasq.confd4
-rw-r--r--main/dnsmasq/dnsmasq.initd38
-rw-r--r--main/dovecot/APKBUILD35
-rw-r--r--main/dovecot/dovecot.initd57
-rw-r--r--main/dovecot/dovecot.pre-install4
-rw-r--r--main/dropbear/APKBUILD38
-rw-r--r--main/dropbear/dropbear.confd6
-rw-r--r--main/dropbear/dropbear.initd36
-rw-r--r--main/dtach/APKBUILD23
-rw-r--r--main/eggdrop/APKBUILD69
-rw-r--r--main/eggdrop/eggdrop-installer84
-rw-r--r--main/eggdrop/eggdrop.post-install6
-rw-r--r--main/eggdrop/gseen.mod.patch5123
-rw-r--r--main/eggdrop/logs2html.mod.patch2404
-rw-r--r--main/email/APKBUILD25
-rw-r--r--main/email/email-3.1.0-doc.patch10
-rw-r--r--main/email/email-3.1.0-ldflags.patch11
-rw-r--r--main/espeak/APKBUILD42
-rw-r--r--main/espeak/espeak-1.40.02-uclibc++.patch21
-rw-r--r--main/ethtool/APKBUILD21
-rw-r--r--main/faac/APKBUILD24
-rw-r--r--main/faad2/APKBUILD28
-rw-r--r--main/fcgi/10-fcgi-2.4.0-Makefile.patch24
-rw-r--r--main/fcgi/20-fcgi-2.4.0-clientdata-pointer.patch96
-rw-r--r--main/fcgi/30-fcgi-2.4.0-html-updates.patch65
-rw-r--r--main/fcgi/APKBUILD42
-rw-r--r--main/fetchmail/APKBUILD44
-rwxr-xr-xmain/fetchmail/fetchmail.initd33
-rw-r--r--main/fetchmail/fetchmail.post-install3
-rw-r--r--main/fetchmail/fetchmail.pre-install4
-rw-r--r--main/flac/APKBUILD30
-rw-r--r--main/fping/APKBUILD23
-rw-r--r--main/freetds/APKBUILD26
-rw-r--r--main/freetype/10-bytecode.patch29
-rw-r--r--main/freetype/20-enable-spr.patch11
-rw-r--r--main/freetype/30-enable-valid.patch20
-rw-r--r--main/freetype/40-memcpy-fix.patch14
-rw-r--r--main/freetype/APKBUILD41
-rw-r--r--main/gawk/APKBUILD30
-rw-r--r--main/gawk/gawk.post-deinstall3
-rw-r--r--main/gd/APKBUILD32
-rw-r--r--main/gdb/50_all_gdb-pie-1.patch1330
-rw-r--r--main/gdb/50_all_gdb-pie-2.patch2122
-rw-r--r--main/gdb/APKBUILD41
-rw-r--r--main/gdbm/10-gdbm-1.8.3-fix-install-ownership.patch45
-rw-r--r--main/gdbm/20-gdbm-1.8.3-compat-linking.patch19
-rw-r--r--main/gdbm/30-gdbm-1.8.3-build.patch21
-rw-r--r--main/gdbm/APKBUILD40
-rw-r--r--main/gettext/APKBUILD23
-rw-r--r--main/ghostscript/APKBUILD45
-rw-r--r--main/glib/APKBUILD33
-rw-r--r--main/gnats/APKBUILD32
-rw-r--r--main/gnats/gnats.pre-install4
-rw-r--r--main/gnupg/APKBUILD21
-rw-r--r--main/gnutls/APKBUILD28
-rw-r--r--main/gperf/APKBUILD21
-rw-r--r--main/grep/APKBUILD30
-rw-r--r--main/grep/grep.post-deinstall3
-rw-r--r--main/gross/APKBUILD57
-rw-r--r--main/gross/gross-1.0.1-configure.ac.patch20
-rw-r--r--main/gross/gross-1.0.1-default-conf.patch17
-rw-r--r--main/gross/gross-1.0.1-user.patch72
-rw-r--r--main/gross/gross.post-install2
-rw-r--r--main/gross/gross.post-upgrade16
-rw-r--r--main/gross/gross.pre-install3
-rw-r--r--main/gross/gross.pre-upgrade12
-rw-r--r--main/gross/grossd.confd6
-rw-r--r--main/gross/grossd.initd35
-rw-r--r--main/gzip/APKBUILD34
-rw-r--r--main/gzip/gzip.post-deinstall3
-rw-r--r--main/haserl/APKBUILD22
-rw-r--r--main/heimdal/001_all_heimdal-no_libedit.patch10
-rw-r--r--main/heimdal/002_all_heimdal-fPIC.patch12
-rw-r--r--main/heimdal/003_all_heimdal-rxapps.patch22
-rw-r--r--main/heimdal/005_all_heimdal-suid_fix.patch20
-rw-r--r--main/heimdal/013_all_heimdal-pthread-lib.patch11
-rw-r--r--main/heimdal/014_all_heimdal-path.patch50
-rw-r--r--main/heimdal/022_all_heimdal-as-needed.patch22
-rw-r--r--main/heimdal/APKBUILD161
-rwxr-xr-xmain/heimdal/heimdal-kadmind.init24
-rwxr-xr-xmain/heimdal/heimdal-kdc.init23
-rwxr-xr-xmain/heimdal/heimdal-kpasswdd.init24
-rw-r--r--main/heimdal/heimdal-r23235-kb5-libwind_la.patch10
-rw-r--r--main/heimdal/heimdal-r23238-kb5_locl_h-wind_h.patch11
-rw-r--r--main/heimdal/heimdal-system_sqlite.patch56
-rw-r--r--main/htop/APKBUILD21
-rw-r--r--main/hunspell/APKBUILD23
-rw-r--r--main/hylafax/APKBUILD82
-rw-r--r--main/hylafax/hylafax.post-install5
-rw-r--r--main/hypermail/APKBUILD36
-rw-r--r--main/hypermail/mdir2mbox.lua96
-rw-r--r--main/iaxmodem/APKBUILD54
-rw-r--r--main/iaxmodem/iaxmodem.confd7
-rw-r--r--main/iaxmodem/iaxmodem.initd43
-rw-r--r--main/iaxmodem/nocxx.patch15
-rw-r--r--main/icu/APKBUILD27
-rw-r--r--main/imagemagick/APKBUILD35
-rw-r--r--main/iproute2-qos/APKBUILD21
-rw-r--r--main/iproute2-qos/qos.confd314
-rw-r--r--main/iproute2-qos/qos.initd293
-rw-r--r--main/iproute2-qos/setup-qos67
-rw-r--r--main/ipsec-tools/00-verify-cert-leak.patch11
-rw-r--r--main/ipsec-tools/20-natoa-fix.patch33
-rw-r--r--main/ipsec-tools/30-natt-ports-cleanup.patch393
-rw-r--r--main/ipsec-tools/40-cmpsaddr-cleanup.patch1403
-rw-r--r--main/ipsec-tools/50-reverse-connect.patch207
-rw-r--r--main/ipsec-tools/60-debug-quick.patch211
-rw-r--r--main/ipsec-tools/APKBUILD59
-rw-r--r--main/ipsec-tools/racoon.confd19
-rw-r--r--main/ipsec-tools/racoon.initd58
-rw-r--r--main/iptraf/APKBUILD37
-rw-r--r--main/iputils/APKBUILD28
-rw-r--r--main/iputils/iputils-20070202-no-open-max.patch16
-rw-r--r--main/iputils/iputils.post-install3
-rw-r--r--main/irssi/APKBUILD34
-rw-r--r--main/jpeg/APKBUILD35
-rw-r--r--main/json4lua/APKBUILD15
-rw-r--r--main/ksymoops/APKBUILD25
-rw-r--r--main/less/APKBUILD28
-rw-r--r--main/less/less.post-deinstall3
-rw-r--r--main/lftp/APKBUILD31
-rw-r--r--main/lha/APKBUILD26
-rw-r--r--main/libao/APKBUILD22
-rw-r--r--main/libart-lgpl/APKBUILD19
-rw-r--r--main/libassuan/APKBUILD18
-rw-r--r--main/libcap/APKBUILD23
-rw-r--r--main/libcap/include-order.patch16
-rw-r--r--main/libconfig/APKBUILD23
-rw-r--r--main/libexif/APKBUILD20
-rw-r--r--main/libgcrypt/APKBUILD27
-rw-r--r--main/libgcrypt/nocxx.patch15
-rw-r--r--main/libgpg-error/APKBUILD32
-rw-r--r--main/libgpg-error/nocxx.patch15
-rw-r--r--main/libiconv/APKBUILD21
-rw-r--r--main/libid3tag/APKBUILD27
-rw-r--r--main/libidn/APKBUILD29
-rw-r--r--main/libksba/APKBUILD20
-rw-r--r--main/libmcrypt/APKBUILD24
-rw-r--r--main/libnet/APKBUILD36
-rw-r--r--main/libnet/libnet-1.1.2.1-autotools.patch79
-rw-r--r--main/libnet/libnet-1.1.2.1-fix-chksum.patch27
-rw-r--r--main/libnetfilter_conntrack/APKBUILD26
-rw-r--r--main/libnfnetlink/APKBUILD24
-rw-r--r--main/libogg/APKBUILD25
-rw-r--r--main/libogg/nocxx.patch15
-rw-r--r--main/libpng/APKBUILD27
-rw-r--r--main/libpri/APKBUILD33
-rw-r--r--main/libpri/libpri-1.4.9-i14292.patch5668
-rw-r--r--main/libpri/libpri-cflags.patch21
-rw-r--r--main/libsamplerate/APKBUILD18
-rw-r--r--main/libsndfile/APKBUILD22
-rw-r--r--main/libtasn1/APKBUILD20
-rw-r--r--main/libtheora/APKBUILD26
-rw-r--r--main/libusb-compat/APKBUILD20
-rw-r--r--main/libusb/APKBUILD20
-rw-r--r--main/libvorbis/APKBUILD23
-rw-r--r--main/libxml2/APKBUILD29
-rw-r--r--main/libxml2/nocxx.patch15
-rw-r--r--main/libxslt/APKBUILD20
-rw-r--r--main/lighttpd/APKBUILD81
-rw-r--r--main/lighttpd/lighttpd.conf321
-rw-r--r--main/lighttpd/lighttpd.confd12
-rw-r--r--main/lighttpd/lighttpd.initd67
-rw-r--r--main/lighttpd/lighttpd.logrotate17
-rw-r--r--main/lighttpd/lighttpd.post-install4
-rw-r--r--main/lighttpd/lighttpd.pre-install4
-rw-r--r--main/lighttpd/mime-types.conf76
-rw-r--r--main/lighttpd/mod_cgi.conf33
-rw-r--r--main/lighttpd/mod_fastcgi.conf17
-rw-r--r--main/lighttpd/spawn-fcgi.confd35
-rw-r--r--main/lighttpd/spawn-fcgi.initd51
-rw-r--r--main/links/APKBUILD25
-rw-r--r--main/lm_sensors/APKBUILD63
-rw-r--r--main/lm_sensors/fancontrol.initd33
-rw-r--r--main/lm_sensors/lm_sensors-3.1.0-sensors-detect-alpine.patch39
-rw-r--r--main/lm_sensors/lm_sensors.initd105
-rw-r--r--main/lm_sensors/sensord.confd3
-rw-r--r--main/lm_sensors/sensord.initd33
-rw-r--r--main/lm_sensors/sensors.install12
-rw-r--r--main/logrotate/APKBUILD23
-rw-r--r--main/lpc/APKBUILD18
-rw-r--r--main/lua/APKBUILD48
-rw-r--r--main/lua/lua-5.1-make.patch64
-rw-r--r--main/lua/lua-5.1-module_paths.patch30
-rw-r--r--main/luaposix/APKBUILD18
-rw-r--r--main/luasql-postgres/APKBUILD27
-rw-r--r--main/luasql-postgres/config.new59
-rw-r--r--main/lzo/APKBUILD27
-rw-r--r--main/man-pages/APKBUILD28
-rw-r--r--main/man/APKBUILD35
-rw-r--r--main/man/man-troff.patch16
-rwxr-xr-xmain/man/whatis.periodic.daily9
-rw-r--r--main/md5/APKBUILD19
-rw-r--r--main/mini_httpd/APKBUILD42
-rw-r--r--main/mini_httpd/mini_httpd.conf.sample50
-rw-r--r--main/mini_httpd/mini_httpd.initd25
-rw-r--r--main/mlmmj/APKBUILD21
-rw-r--r--main/mpg123/APKBUILD25
-rw-r--r--main/mysql/APKBUILD70
-rw-r--r--main/mysql/mysql.initd38
-rw-r--r--main/mysql/mysql.mycnf49
-rw-r--r--main/nano/APKBUILD33
-rw-r--r--main/ncftp/APKBUILD38
-rw-r--r--main/ncftp/ncftp.post-install7
-rw-r--r--main/neon/APKBUILD27
-rw-r--r--main/net-snmp/APKBUILD57
-rw-r--r--main/net-snmp/snmpd.confd14
-rw-r--r--main/net-snmp/snmpd.initd30
-rw-r--r--main/net-snmp/snmptrapd.confd12
-rw-r--r--main/net-snmp/snmptrapd.initd22
-rw-r--r--main/newt/APKBUILD35
-rw-r--r--main/newt/newt-0.52.7-notcl.patch35
-rw-r--r--main/nfs-utils/APKBUILD54
-rw-r--r--main/nfs-utils/nfs-utils-mtab-sym.patch38
-rw-r--r--main/nfs-utils/nfs-utils-no-exec.patch13
-rw-r--r--main/nfs-utils/nfs.confd30
-rw-r--r--main/nfs-utils/nfs.exports7
-rw-r--r--main/nfs-utils/nfs.initd154
-rw-r--r--main/ngircd/APKBUILD36
-rw-r--r--main/ngircd/ngircd.initd21
-rw-r--r--main/ngircd/ngircd.pre-install4
-rw-r--r--main/nmap/APKBUILD47
-rw-r--r--main/nmap/nmap-4.53-uclibc++-output.cc.patch11
-rw-r--r--main/ntfs-3g/APKBUILD29
-rw-r--r--main/ntfs-3g/nocxx.patch15
-rw-r--r--main/oidentd/APKBUILD34
-rw-r--r--main/oidentd/oidentd.conf22
-rw-r--r--main/oidentd/oidentd.confd4
-rw-r--r--main/oidentd/oidentd.initd42
-rw-r--r--main/openldap/APKBUILD80
-rw-r--r--main/openldap/openldap-2.4-ppolicy.patch13
-rw-r--r--main/openldap/openldap-2.4.11-libldap_r.patch11
-rw-r--r--main/openldap/openldap.post-install4
-rw-r--r--main/openldap/openldap.pre-install3
-rw-r--r--main/openldap/slapd.confd9
-rw-r--r--main/openldap/slapd.initd20
-rw-r--r--main/openldap/slurpd.initd22
-rw-r--r--main/opennhrp/APKBUILD33
-rw-r--r--main/opennhrp/opennhrp-0.9.2-fix-false-assert.patch13
-rw-r--r--main/opennhrp/opennhrp-0.9.3-peer-up-bgp.patch11
-rw-r--r--main/opennhrp/opennhrp.confd2
-rwxr-xr-xmain/opennhrp/opennhrp.initd32
-rw-r--r--main/openvpn/APKBUILD54
-rw-r--r--main/openvpn/openvpn-2.0.9-persistent.patch44
-rw-r--r--main/openvpn/openvpn.initd63
-rw-r--r--main/p7zip/APKBUILD36
-rw-r--r--main/p7zip/p7zip-cc-cxx.patch22
-rw-r--r--main/pciutils/APKBUILD29
-rw-r--r--main/pcmciautils/APKBUILD21
-rw-r--r--main/pcre/APKBUILD26
-rw-r--r--main/perl-archive-zip/APKBUILD26
-rw-r--r--main/perl-convert-binhex/APKBUILD26
-rw-r--r--main/perl-convert-tnef/APKBUILD26
-rw-r--r--main/perl-convert-uulib/APKBUILD26
-rw-r--r--main/perl-crypt-openssl-random/APKBUILD26
-rw-r--r--main/perl-crypt-openssl-rsa/APKBUILD26
-rw-r--r--main/perl-db/APKBUILD26
-rw-r--r--main/perl-db_file/APKBUILD26
-rw-r--r--main/perl-digest-sha1/APKBUILD26
-rw-r--r--main/perl-getopt-long/APKBUILD26
-rw-r--r--main/perl-html-parser/APKBUILD26
-rw-r--r--main/perl-inline/APKBUILD26
-rw-r--r--main/perl-io-stringy/APKBUILD26
-rw-r--r--main/perl-mail-clamav/APKBUILD26
-rw-r--r--main/perl-mail-dkim/APKBUILD26
-rw-r--r--main/perl-mail-domainkeys/APKBUILD26
-rw-r--r--main/perl-mail-spamassassin/APKBUILD25
-rw-r--r--main/perl-mail-spf/APKBUILD24
-rw-r--r--main/perl-mail-tools/APKBUILD26
-rw-r--r--main/perl-mime-tools/APKBUILD26
-rw-r--r--main/perl-net-dns/APKBUILD26
-rw-r--r--main/perl-net-ip/APKBUILD26
-rw-r--r--main/perl-net-server/APKBUILD26
-rw-r--r--main/perl-parse-recdescent/APKBUILD26
-rw-r--r--main/perl-test-pod/APKBUILD26
-rw-r--r--main/perl-time-date/APKBUILD26
-rw-r--r--main/perl-unix-syslog/APKBUILD27
-rw-r--r--main/perl-uri-escape/APKBUILD26
-rw-r--r--main/perl-uri/APKBUILD22
-rw-r--r--main/perl-xml-parser/APKBUILD21
-rw-r--r--main/perl-xml-simple/APKBUILD22
-rw-r--r--main/pgcluster/APKBUILD51
-rw-r--r--main/pgcluster/pgcluster.confd57
-rw-r--r--main/pgcluster/pgcluster.initd172
-rw-r--r--main/pgpool/APKBUILD29
-rw-r--r--main/pgpool/pgpool.initd24
-rw-r--r--main/php-apc/APKBUILD29
-rw-r--r--main/php-apc/apc.ini11
-rw-r--r--main/php-fileinfo/APKBUILD26
-rw-r--r--main/php-fileinfo/magic.patch13
-rw-r--r--main/php/APKBUILD144
-rw-r--r--main/pinentry/APKBUILD42
-rw-r--r--main/pingu/APKBUILD23
-rw-r--r--main/pingu/pingu.initd27
-rw-r--r--main/portmap/APKBUILD39
-rw-r--r--main/portmap/portmap-6.0-tcpd.patch18
-rw-r--r--main/portmap/portmap.confd5
-rw-r--r--main/portmap/portmap.initd46
-rw-r--r--main/portmap/portmap.pre-install3
-rw-r--r--main/postfix/APKBUILD151
-rw-r--r--main/postfix/dynamicmaps.cf16
-rw-r--r--main/postfix/postfix-2.6.1-dynamicmaps.patch5273
-rw-r--r--main/postfix/postfix-ldap.post-install19
-rw-r--r--main/postfix/postfix-mysql.post-install19
-rw-r--r--main/postfix/postfix-pcre.post-install25
-rw-r--r--main/postfix/postfix-pgsql.post-install19
-rw-r--r--main/postfix/postfix.initd48
-rw-r--r--main/postfix/postfix.post-install6
-rw-r--r--main/postfix/postfix.pre-install7
-rw-r--r--main/postgresql/APKBUILD50
-rw-r--r--main/postgresql/postgresql.confd52
-rw-r--r--main/postgresql/postgresql.initd113
-rw-r--r--main/pth/APKBUILD35
-rw-r--r--main/pth/pth-2.0.5-parallelfix.patch15
-rw-r--r--main/pth/pth-2.0.6-ldflags.patch17
-rw-r--r--main/pth/pth-2.0.6-sigstack.patch22
-rw-r--r--main/python/APKBUILD33
-rw-r--r--main/python/python-2.6-internal-expat.patch33
-rw-r--r--main/quagga/APKBUILD79
-rw-r--r--main/quagga/bgpd.initd33
-rw-r--r--main/quagga/ospf6d.initd33
-rw-r--r--main/quagga/ospfd.initd33
-rw-r--r--main/quagga/quagga-0.99.11-del-routes.patch44
-rw-r--r--main/quagga/quagga-0.99.11-fd-leak.patch19
-rw-r--r--main/quagga/quagga-0.99.11-ipv6-only.patch29
-rw-r--r--main/quagga/quagga-0.99.11-link-libcap.patch24
-rw-r--r--main/quagga/quagga-0.99.11-zombie.patch29
-rw-r--r--main/quagga/quagga.post-install6
-rw-r--r--main/quagga/quagga.pre-install6
-rw-r--r--main/quagga/ripd.initd33
-rw-r--r--main/quagga/ripngd.initd33
-rw-r--r--main/quagga/zebra.confd7
-rw-r--r--main/quagga/zebra.initd41
-rw-r--r--main/razor/APKBUILD26
-rw-r--r--main/roundcubemail/APKBUILD19
-rw-r--r--main/rrdtool/APKBUILD36
-rw-r--r--main/rsync/APKBUILD36
-rw-r--r--main/rsync/rsyncd.conf10
-rw-r--r--main/rsync/rsyncd.confd5
-rw-r--r--main/rsync/rsyncd.initd23
-rw-r--r--main/rsync/rsyncd.logrotate9
-rw-r--r--main/ruby/APKBUILD44
-rw-r--r--main/rubygems/APKBUILD21
-rw-r--r--main/rubygems/rubygems-1.3.1-setup.patch53
-rw-r--r--main/run-parts/APKBUILD19
-rw-r--r--main/samba/APKBUILD99
-rw-r--r--main/samba/samba.confd6
-rw-r--r--main/samba/samba.initd64
-rw-r--r--main/screen/APKBUILD33
-rw-r--r--main/screen/screen-4.0.3.patch272
-rw-r--r--main/sed/APKBUILD27
-rw-r--r--main/sed/sed.post-deinstall3
-rw-r--r--main/sfic/APKBUILD29
-rw-r--r--main/sfic/sfic-0.1.7-signal.patch10
-rw-r--r--main/shorewall-common/APKBUILD21
-rw-r--r--main/shorewall-common/shorewall.initd80
-rw-r--r--main/shorewall-lite/APKBUILD20
-rwxr-xr-xmain/shorewall-lite/shorewall-lite.initd65
-rw-r--r--main/shorewall-perl/APKBUILD16
-rw-r--r--main/shorewall-shell/APKBUILD17
-rw-r--r--main/shorewall/APKBUILD16
-rw-r--r--main/sic/APKBUILD20
-rw-r--r--main/slang/APKBUILD27
-rw-r--r--main/slang/slang-2.1.3-uclibc.patch12
-rw-r--r--main/snort/APKBUILD40
-rw-r--r--main/snort/nocxx.patch15
-rw-r--r--main/snort/snort.confd16
-rw-r--r--main/snort/snort.initd31
-rw-r--r--main/snort/snort.pre-install4
-rw-r--r--main/sntpc/APKBUILD26
-rw-r--r--main/sntpc/sntpc.confd9
-rw-r--r--main/sntpc/sntpc.initd30
-rw-r--r--main/spamassassin/APKBUILD30
-rw-r--r--main/spamassassin/spamd.conf46
-rw-r--r--main/spamassassin/spamd.init39
-rw-r--r--main/sqlite/APKBUILD31
-rw-r--r--main/sqlite/license.txt33
-rw-r--r--main/squid/APKBUILD278
-rw-r--r--main/squid/squid-2.7-gentoo.patch298
-rw-r--r--main/squid/squid.confd15
-rw-r--r--main/squid/squid.initd97
-rw-r--r--main/squid/squid.logrotate11
-rw-r--r--main/squid/squid.post-install5
-rw-r--r--main/ssmtp/APKBUILD32
-rw-r--r--main/ssmtp/CVE-2008-3962.patch14
-rw-r--r--main/ssmtp/generate_config.patch49
-rw-r--r--main/strace/APKBUILD20
-rw-r--r--main/subversion/APKBUILD38
-rw-r--r--main/subversion/subversion.pre-install6
-rw-r--r--main/subversion/svnserve.confd10
-rw-r--r--main/subversion/svnserve.initd44
-rw-r--r--main/sysfsutils/APKBUILD24
-rw-r--r--main/sysklogd/APKBUILD50
-rw-r--r--main/sysklogd/LICENSE16
-rw-r--r--main/sysklogd/sysklogd-1.4.2-caen-owl-klogd-drop-root.diff162
-rw-r--r--main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-bind.diff103
-rw-r--r--main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff118
-rw-r--r--main/sysklogd/sysklogd-1.5-build.patch20
-rw-r--r--main/sysklogd/sysklogd.confd6
-rw-r--r--main/sysklogd/sysklogd.initd79
-rw-r--r--main/sysklogd/sysklogd.logrotate6
-rw-r--r--main/sysstat/APKBUILD27
-rw-r--r--main/tar/APKBUILD25
-rw-r--r--main/tar/tar.post-deinstall3
-rw-r--r--main/tcl/APKBUILD33
-rw-r--r--main/tcpdump/APKBUILD24
-rw-r--r--main/tcpproxy/APKBUILD26
-rw-r--r--main/tcpproxy/tcpproxy.initd14
-rw-r--r--main/tiff/APKBUILD26
-rw-r--r--main/tinyproxy/APKBUILD40
-rw-r--r--main/tinyproxy/tinyproxy.initd45
-rw-r--r--main/tinyproxy/tinyproxy.install13
-rw-r--r--main/tmux/APKBUILD27
-rw-r--r--main/tmux/build.patch23
-rw-r--r--main/transmission/APKBUILD32
-rw-r--r--main/transmission/transmission-daemon.confd18
-rw-r--r--main/transmission/transmission-daemon.initd21
-rw-r--r--main/transmission/transmission.pre-install5
-rw-r--r--main/udev/APKBUILD41
-rwxr-xr-xmain/udev/move_tmp_persistent_rules.sh25
-rwxr-xr-xmain/udev/udev-mount.initd83
-rwxr-xr-xmain/udev/udev-postmount.initd31
-rw-r--r--main/udev/udev-start.sh51
-rwxr-xr-xmain/udev/udev.initd239
-rwxr-xr-xmain/udev/write_root_link_rule29
-rw-r--r--main/uiconv/APKBUILD17
-rw-r--r--main/unarj/APKBUILD22
-rw-r--r--main/unfs3/APKBUILD22
-rw-r--r--main/unixodbc/APKBUILD27
-rw-r--r--main/unrar/APKBUILD26
-rw-r--r--main/usbutils/APKBUILD24
-rw-r--r--main/v86d/APKBUILD21
-rw-r--r--main/v86d/modprobe.uvesafb10
-rw-r--r--main/vala/APKBUILD22
-rw-r--r--main/valgrind/APKBUILD55
-rw-r--r--main/valgrind/valgrind-3.4.0-uclibc.patch12
-rw-r--r--main/vim/APKBUILD519
-rw-r--r--main/vim/vimrc15
-rw-r--r--main/vsftpd/APKBUILD36
-rw-r--r--main/vsftpd/vsftpd-enable-ssl.patch11
-rw-r--r--main/vsftpd/vsftpd.confd9
-rw-r--r--main/vsftpd/vsftpd.initd25
-rw-r--r--main/wget/APKBUILD29
-rw-r--r--main/wget/wget.post-deinstall3
-rw-r--r--main/xvidcore/APKBUILD25
-rw-r--r--main/zip/10-zip-3.0-build.patch36
-rw-r--r--main/zip/20-zip-3.0-exec-stack.patch22
-rw-r--r--main/zip/30-zip-3.0-pic.patch15
-rw-r--r--main/zip/APKBUILD30
-rw-r--r--main/zonenotify/APKBUILD18
634 files changed, 49271 insertions, 0 deletions
diff --git a/main/acct/APKBUILD b/main/acct/APKBUILD
new file mode 100644
index 00000000000..29657feed9e
--- /dev/null
+++ b/main/acct/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acct
+pkgver=6.3.2
+pkgrel=1
+pkgdesc="The GNU Accounting Utilities"
+url="http://www.gnu.org/software/acct/"
+license="GPL"
+depends=
+makedepends=
+install=
+subpackages="$pkgname-doc"
+source="http://ftp.gnu.org/gnu/acct/${pkgname}-${pkgver}.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # seems like this makefile does not respect DESTDIR
+ ./configure --prefix=/usr \
+ --mandir="$pkgdir"/usr/share/man \
+ --infodir="$pkgdir"/usr/share/info
+
+ make || return 1
+ make prefix="$pkgdir/usr" install
+}
+
+md5sums="da0055b254f7da8b8920db83ef1ebba1 acct-6.3.2.tar.gz"
diff --git a/main/acf-alpine-baselayout/APKBUILD b/main/acf-alpine-baselayout/APKBUILD
new file mode 100644
index 00000000000..1f29cfb0b14
--- /dev/null
+++ b/main/acf-alpine-baselayout/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-alpine-baselayout
+pkgver=0.5.1
+pkgrel=0
+pkgdesc="A web-based system administration interface for alpine-baselayout"
+url="http://git.alpinelinux.org/cgit/acf-alpine-baselayout"
+license="GPL-2"
+depends="acf-core json4lua lua luaposix"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="385620401b12c68e7bea1138505a1376 acf-alpine-baselayout-0.5.1.tar.bz2"
diff --git a/main/acf-alpine-conf/APKBUILD b/main/acf-alpine-conf/APKBUILD
new file mode 100644
index 00000000000..fdb808017c0
--- /dev/null
+++ b/main/acf-alpine-conf/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-alpine-conf
+pkgver=0.3.14
+pkgrel=0
+pkgdesc="A web-based system administration interface for alpine-conf"
+url="http://git.alpinelinux.org/cgit/acf-alpine-conf"
+license="GPL-2"
+depends="acf-core lua luaposix"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="7f1f61e3188c0eadeba80b9436b26ebb acf-alpine-conf-0.3.14.tar.bz2"
diff --git a/main/acf-apk-tools/APKBUILD b/main/acf-apk-tools/APKBUILD
new file mode 100644
index 00000000000..040645d3121
--- /dev/null
+++ b/main/acf-apk-tools/APKBUILD
@@ -0,0 +1,16 @@
+# Contributor: Mika Havela <mika.havela@gmail.com>
+pkgname=acf-apk-tools
+pkgver=0.3.0
+pkgrel=0
+pkgdesc="ACF module for apk"
+url="http://git.alpinelinux.org/cgit/acf-apk-tools"
+license="GPL-2"
+depends="acf-core lua luaposix"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="ae4b99240a69c37f5ec60668518b4db0 acf-apk-tools-0.3.0.tar.bz2"
diff --git a/main/acf-asterisk/APKBUILD b/main/acf-asterisk/APKBUILD
new file mode 100644
index 00000000000..c7abd3b02fb
--- /dev/null
+++ b/main/acf-asterisk/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-asterisk
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for asterisk"
+url="http://git.alpinelinux.org/cgit/acf-asterisk"
+license="GPL-2"
+depends="acf-core lua asterisk"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="50481ed7662a93f24610e2af92ca6cd5 acf-asterisk-0.2.0.tar.bz2"
diff --git a/main/acf-chrony/APKBUILD b/main/acf-chrony/APKBUILD
new file mode 100644
index 00000000000..9db7c4d0007
--- /dev/null
+++ b/main/acf-chrony/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-chrony
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for chrony"
+url="http://git.alpinelinux.org/cgit/acf-chrony"
+license="GPL-2"
+depends="acf-core lua luaposix chrony"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="04a3b4f80eafc65b29cf93266049b804 acf-chrony-0.2.0.tar.bz2"
diff --git a/main/acf-clamav/APKBUILD b/main/acf-clamav/APKBUILD
new file mode 100644
index 00000000000..511844df491
--- /dev/null
+++ b/main/acf-clamav/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-clamav
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for clamav"
+url="http://git.alpinelinux.org/cgit/acf-clamav"
+license="GPL-2"
+depends="acf-core lua clamav"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="a3da6fc06f95a947819e308f8092e77b acf-clamav-0.2.0.tar.bz2"
diff --git a/main/acf-clamsmtp/APKBUILD b/main/acf-clamsmtp/APKBUILD
new file mode 100644
index 00000000000..b72fc2e32b8
--- /dev/null
+++ b/main/acf-clamsmtp/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-clamsmtp
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for clamsmtp"
+url="http://git.alpinelinux.org/cgit/acf-clamsmtp"
+license="GPL-2"
+depends="acf-core lua clamsmtp"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="139d06632bf900d58c9a145b13e39517 acf-clamsmtp-0.2.0.tar.bz2"
diff --git a/main/acf-core/APKBUILD b/main/acf-core/APKBUILD
new file mode 100644
index 00000000000..dd9f65bbc71
--- /dev/null
+++ b/main/acf-core/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-core
+pkgver=0.8.0
+pkgrel=0
+pkgdesc="A web-based system administration interface framework"
+url="http://git.alpinelinux.org/cgit/acf-core"
+license="GPL-2"
+depends="acf-skins haserl lua luaposix md5"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="a51c0f4a1931ebc0ca4d303b3330b484 acf-core-0.8.0.tar.bz2"
diff --git a/main/acf-dansguardian/APKBUILD b/main/acf-dansguardian/APKBUILD
new file mode 100644
index 00000000000..c5d5ef7dd5d
--- /dev/null
+++ b/main/acf-dansguardian/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-dansguardian
+pkgver=0.3.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for dansguardian"
+url="http://git.alpinelinux.org/cgit/acf-dansguardian"
+license="GPL-2"
+depends="acf-core lua dansguardian"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="23740882f651776070bad5d4959f8035 acf-dansguardian-0.3.0.tar.bz2"
diff --git a/main/acf-dhcp/APKBUILD b/main/acf-dhcp/APKBUILD
new file mode 100644
index 00000000000..bc92419bb99
--- /dev/null
+++ b/main/acf-dhcp/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-dhcp
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for dhcp"
+url="http://git.alpinelinux.org/cgit/acf-dhcp"
+license="GPL-2"
+depends="acf-core lua dhcp"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="a30d069327655fd562e40fc118810eb7 acf-dhcp-0.4.0.tar.bz2"
diff --git a/main/acf-dnscache/APKBUILD b/main/acf-dnscache/APKBUILD
new file mode 100644
index 00000000000..979df43c19b
--- /dev/null
+++ b/main/acf-dnscache/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-dnscache
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for dnscache"
+url="http://git.alpinelinux.org/cgit/acf-dnscache"
+license="GPL-2"
+depends="acf-core lua luaposix dnscache"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="58c991b5ccb59c51b20779fa0a7189fa acf-dnscache-0.2.0.tar.bz2"
diff --git a/main/acf-dnsmasq/APKBUILD b/main/acf-dnsmasq/APKBUILD
new file mode 100644
index 00000000000..8f0b8397b3c
--- /dev/null
+++ b/main/acf-dnsmasq/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-dnsmasq
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for dnsmasq"
+url="http://git.alpinelinux.org/cgit/acf-dnsmasq"
+license="GPL-2"
+depends="acf-core lua dnsmasq"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="320ac909465f25a49eb9e427e456a3e6 acf-dnsmasq-0.2.0.tar.bz2"
diff --git a/main/acf-dovecot/APKBUILD b/main/acf-dovecot/APKBUILD
new file mode 100644
index 00000000000..a95208ad6ef
--- /dev/null
+++ b/main/acf-dovecot/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-dovecot
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for dovecot"
+url="http://git.alpinelinux.org/cgit/acf-dovecot"
+license="GPL-2"
+depends="acf-core lua dovecot"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="fc5ca553148b77550bbfa731acab62f5 acf-dovecot-0.2.0.tar.bz2"
diff --git a/main/acf-fetchmail/APKBUILD b/main/acf-fetchmail/APKBUILD
new file mode 100644
index 00000000000..c4638e342d8
--- /dev/null
+++ b/main/acf-fetchmail/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-fetchmail
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for fetchmail"
+url="http://git.alpinelinux.org/cgit/acf-fetchmail"
+license="GPL-2"
+depends="acf-core lua fetchmail"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="71c9d1245d4fa700e452e7a728ab42a8 acf-fetchmail-0.4.0.tar.bz2"
diff --git a/main/acf-gnats/APKBUILD b/main/acf-gnats/APKBUILD
new file mode 100644
index 00000000000..0dc58acd835
--- /dev/null
+++ b/main/acf-gnats/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-gnats
+pkgver=0.3.5
+pkgrel=0
+pkgdesc="ACF module for gnats"
+url="http://git.alpinelinux.org/cgit/acf-gnats"
+license="GPL-2"
+depends="acf-core gnats lua"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="0cc0496301fd6a8287e767fa13363519 acf-gnats-0.3.5.tar.bz2"
diff --git a/main/acf-gross/APKBUILD b/main/acf-gross/APKBUILD
new file mode 100644
index 00000000000..4dcf979d183
--- /dev/null
+++ b/main/acf-gross/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-gross
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for gross"
+url="http://git.alpinelinux.org/cgit/acf-gross"
+license="GPL-2"
+depends="acf-core lua gross"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="11e4f72ffb2ed0ef2fceca1f1dc88251 acf-gross-0.2.0.tar.bz2"
diff --git a/main/acf-ipsec-tools/APKBUILD b/main/acf-ipsec-tools/APKBUILD
new file mode 100644
index 00000000000..2da2f90f293
--- /dev/null
+++ b/main/acf-ipsec-tools/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-ipsec-tools
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for ipsec-tools"
+url="http://git.alpinelinux.org/cgit/acf-ipsec-tools"
+license="GPL-2"
+depends="acf-core lua ipsec-tools"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="3c3dd54927f539245fb3907bf90b7a26 acf-ipsec-tools-0.4.0.tar.bz2"
diff --git a/main/acf-iptables/APKBUILD b/main/acf-iptables/APKBUILD
new file mode 100644
index 00000000000..12665845f86
--- /dev/null
+++ b/main/acf-iptables/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-iptables
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for iptables"
+url="http://git.alpinelinux.org/cgit/acf-iptables"
+license="GPL-2"
+depends="acf-core lua iptables"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="dcecc96699add7e9f4b58c866e6adcb0 acf-iptables-0.2.0.tar.bz2"
diff --git a/main/acf-mdadm/APKBUILD b/main/acf-mdadm/APKBUILD
new file mode 100644
index 00000000000..5069fa0c41a
--- /dev/null
+++ b/main/acf-mdadm/APKBUILD
@@ -0,0 +1,22 @@
+# Contributor: Mika Havela <mika.havela@gmail.com>
+# Maintainer: Mika Havela <mika.havela@gmail.com>
+pkgname=acf-mdadm
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="ACF module for mdadm"
+url="http://git.alpinelinux.org/cgit/$pkgname"
+license="GPL-2"
+depends="acf-core lua mdadm"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="3a94b48e2f678bef0dc5aad6ef699ee2 acf-mdadm-0.2.0.tar.bz2"
diff --git a/main/acf-opennhrp/APKBUILD b/main/acf-opennhrp/APKBUILD
new file mode 100644
index 00000000000..4bc246496ba
--- /dev/null
+++ b/main/acf-opennhrp/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-opennhrp
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for opennhrp"
+url="http://git.alpinelinux.org/cgit/acf-opennhrp"
+license="GPL-2"
+depends="acf-core lua luaposix opennhrp"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="3b86f9859871b6c788b3aee1e90ee9fc acf-opennhrp-0.4.0.tar.bz2"
diff --git a/main/acf-openntpd/APKBUILD b/main/acf-openntpd/APKBUILD
new file mode 100644
index 00000000000..f33272d176b
--- /dev/null
+++ b/main/acf-openntpd/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-openntpd
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for openntpd"
+url="http://git.alpinelinux.org/cgit/acf-openntpd"
+license="GPL-2"
+depends="acf-core lua openntpd"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="43cbfc627ddd51451917c2a99e587224 acf-openntpd-0.4.0.tar.bz2"
diff --git a/main/acf-openssh/APKBUILD b/main/acf-openssh/APKBUILD
new file mode 100644
index 00000000000..9228bacd75d
--- /dev/null
+++ b/main/acf-openssh/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-openssh
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for openssh"
+url="http://git.alpinelinux.org/cgit/acf-openssh"
+license="GPL-2"
+depends="acf-core lua openssh"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="aa975654ce91969a978cc100dc046c63 acf-openssh-0.2.0.tar.bz2"
diff --git a/main/acf-openssl/APKBUILD b/main/acf-openssl/APKBUILD
new file mode 100644
index 00000000000..abaeeed12ae
--- /dev/null
+++ b/main/acf-openssl/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-openssl
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for openssl"
+url="http://git.alpinelinux.org/cgit/acf-openssl"
+license="GPL-2"
+depends="acf-core lua openssl"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="468be0f280214d83084ff56c2fab202d acf-openssl-0.2.0.tar.bz2"
diff --git a/main/acf-openvpn/APKBUILD b/main/acf-openvpn/APKBUILD
new file mode 100644
index 00000000000..34febc34c4f
--- /dev/null
+++ b/main/acf-openvpn/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-openvpn
+pkgver=0.4.1
+pkgrel=0
+pkgdesc="A web-based system administration interface for openvpn"
+url="http://git.alpinelinux.org/cgit/acf-openvpn"
+license="GPL-2"
+depends="acf-core lua openvpn"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="4730a60d862b08c6e9de2a474acb35be acf-openvpn-0.4.1.tar.bz2"
diff --git a/main/acf-pingu/APKBUILD b/main/acf-pingu/APKBUILD
new file mode 100644
index 00000000000..9efbf5b9a3e
--- /dev/null
+++ b/main/acf-pingu/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-pingu
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for pingu"
+url="http://git.alpinelinux.org/cgit/acf-pingu"
+license="GPL-2"
+depends="acf-core lua pingu"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="db13e3b589995915a3f7cbc41ce02a4a acf-pingu-0.2.0.tar.bz2"
diff --git a/main/acf-postfix/APKBUILD b/main/acf-postfix/APKBUILD
new file mode 100644
index 00000000000..b525015e0d6
--- /dev/null
+++ b/main/acf-postfix/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-postfix
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for postfix"
+url="http://git.alpinelinux.org/cgit/acf-postfix"
+license="GPL-2"
+depends="acf-core lua postfix"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="7ac128ba01fcf58ed517cffad5caf8fe acf-postfix-0.2.0.tar.bz2"
diff --git a/main/acf-postgresql/APKBUILD b/main/acf-postgresql/APKBUILD
new file mode 100644
index 00000000000..88e8d68c75d
--- /dev/null
+++ b/main/acf-postgresql/APKBUILD
@@ -0,0 +1,22 @@
+# Contributor: Mika Havela <mika.havela@gmail.com>
+# Maintainer: Mika Havela <mika.havela@gmail.com>
+pkgname=acf-postgresql
+pkgver=0.3.0
+pkgrel=0
+pkgdesc="ACF module for postgresql"
+url="http://git.alpinelinux.org/cgit/$pkgname"
+license="GPL-2"
+depends="acf-core lua postgresql"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="e2d712f1522c9ce9bd8f4a2a5bbe3209 acf-postgresql-0.3.0.tar.bz2"
diff --git a/main/acf-ppp/APKBUILD b/main/acf-ppp/APKBUILD
new file mode 100644
index 00000000000..cca9f5e0e00
--- /dev/null
+++ b/main/acf-ppp/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-ppp
+pkgver=0.1.1
+pkgrel=0
+pkgdesc="A web-based system administration interface for ppp"
+url="http://git.alpinelinux.org/cgit/acf-ppp"
+license="GPL-2"
+depends="acf-core lua ppp"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="3865436480e610453dfdfc923beb4ec2 acf-ppp-0.1.1.tar.bz2"
diff --git a/main/acf-quagga/APKBUILD b/main/acf-quagga/APKBUILD
new file mode 100644
index 00000000000..01c71c88517
--- /dev/null
+++ b/main/acf-quagga/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-quagga
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for quagga"
+url="http://git.alpinelinux.org/cgit/acf-quagga"
+license="GPL-2"
+depends="acf-core lua quagga"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="ff46d473979a147abb3111e058f33993 acf-quagga-0.4.0.tar.bz2"
diff --git a/main/acf-samba/APKBUILD b/main/acf-samba/APKBUILD
new file mode 100644
index 00000000000..af075485946
--- /dev/null
+++ b/main/acf-samba/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-samba
+pkgver=0.2.1
+pkgrel=0
+pkgdesc="A web-based system administration interface for samba"
+url="http://git.alpinelinux.org/cgit/acf-samba"
+license="GPL-2"
+depends="acf-core lua samba"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="927edc6bb2204369b44ee8cd6dbc18a0 acf-samba-0.2.1.tar.bz2"
diff --git a/main/acf-shorewall/APKBUILD b/main/acf-shorewall/APKBUILD
new file mode 100644
index 00000000000..64bd03a81e6
--- /dev/null
+++ b/main/acf-shorewall/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-shorewall
+pkgver=0.5.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for shorewall"
+url="http://git.alpinelinux.org/cgit/acf-shorewall"
+license="GPL-2"
+depends="acf-core lua shorewall"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="12d8bbc1242ee2e0206fa7369a60ca66 acf-shorewall-0.5.0.tar.bz2"
diff --git a/main/acf-skins/APKBUILD b/main/acf-skins/APKBUILD
new file mode 100644
index 00000000000..4e377d4b7fe
--- /dev/null
+++ b/main/acf-skins/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-skins
+pkgver=0.1.6
+pkgrel=0
+pkgdesc="Skins for ACF"
+url="http://git.alpinelinux.org/cgit/acf-skins"
+license="GPL-2"
+depends=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="d93b59939b2d1e63ccbd0af0ad840d7a acf-skins-0.1.6.tar.bz2"
diff --git a/main/acf-snort/APKBUILD b/main/acf-snort/APKBUILD
new file mode 100644
index 00000000000..abe972d44ad
--- /dev/null
+++ b/main/acf-snort/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-snort
+pkgver=0.4.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for snort"
+url="http://git.alpinelinux.org/cgit/acf-snort"
+license="GPL-2"
+depends="acf-core lua snort"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="8d8114c3ec17a752a2a0b6ce3e37fdfd acf-snort-0.4.0.tar.bz2"
diff --git a/main/acf-squid/APKBUILD b/main/acf-squid/APKBUILD
new file mode 100644
index 00000000000..9016b580451
--- /dev/null
+++ b/main/acf-squid/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-squid
+pkgver=0.5.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for squid"
+url="http://git.alpinelinux.org/cgit/acf-squid"
+license="GPL-2"
+depends="acf-core lua squid"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="0ea0596b90cfeb3abae5c7641d6f6cd4 acf-squid-0.5.0.tar.bz2"
diff --git a/main/acf-tcpproxy/APKBUILD b/main/acf-tcpproxy/APKBUILD
new file mode 100644
index 00000000000..c483088c620
--- /dev/null
+++ b/main/acf-tcpproxy/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=acf-tcpproxy
+pkgver=0.1.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for tcpproxy"
+url="http://git.alpinelinux.org/cgit/acf-tcpproxy"
+license="GPL-2"
+depends="acf-core lua tcpproxy"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="96e3448e51ced1782492bc714587eb78 acf-tcpproxy-0.1.0.tar.bz2"
diff --git a/main/acf-tinydns/APKBUILD b/main/acf-tinydns/APKBUILD
new file mode 100644
index 00000000000..75eeab0b1af
--- /dev/null
+++ b/main/acf-tinydns/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=acf-tinydns
+pkgver=0.3.0
+pkgrel=0
+pkgdesc="A web-based system administration interface for tinydns"
+url="http://git.alpinelinux.org/cgit/acf-tinydns"
+license="GPL-2"
+depends="acf-core lua tinydns"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+}
+md5sums="0f24bd338b0918fcc2047c42e2d59522 acf-tinydns-0.3.0.tar.bz2"
diff --git a/main/acf-weblog/APKBUILD b/main/acf-weblog/APKBUILD
new file mode 100644
index 00000000000..15847a3f488
--- /dev/null
+++ b/main/acf-weblog/APKBUILD
@@ -0,0 +1,20 @@
+# Contributor: Ted Trask <ttrask01@yahoo.com>
+# Maintainer: Ted Trask <ttrask01@yahoo.com>
+pkgname=acf-weblog
+pkgver=0.2.0
+pkgrel=1
+pkgdesc="ACF for web proxy (squid and dansguardian) logfiles"
+url="http://git.alpinelinux.org/cgit/acf-weblog"
+license="GPL-2"
+depends="acf-core lua luasql-postgres wget postgresql-client"
+makedepends=""
+install=
+subpackages=""
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="c3981ef8eca4684480d3df9474fc338b acf-weblog-0.2.0.tar.bz2"
diff --git a/main/alsa-lib/APKBUILD b/main/alsa-lib/APKBUILD
new file mode 100644
index 00000000000..b844b54ff09
--- /dev/null
+++ b/main/alsa-lib/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=alsa-lib
+pkgver=1.0.20
+pkgrel=0
+pkgdesc="An alternative implementation of Linux sound support"
+url="http://www.alsa-project.org"
+license="GPL"
+depends="uclibc"
+subpackages="$pkgname-dev"
+source="ftp://ftp.alsa-project.org/pub/lib/$pkgname-$pkgver.tar.bz2
+ nocxx.patch"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ patch configure < ../nocxx.patch || return 1
+ ./configure --prefix=/usr --disable-python
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+}
+md5sums="6e9080ba1faa5d3739d14dd76c62d8dc alsa-lib-1.0.20.tar.bz2
+28513788ba4d556ccd538867dc6205ab nocxx.patch"
diff --git a/main/alsa-lib/nocxx.patch b/main/alsa-lib/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/alsa-lib/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/amavisd-new/APKBUILD b/main/amavisd-new/APKBUILD
new file mode 100644
index 00000000000..daad650daa5
--- /dev/null
+++ b/main/amavisd-new/APKBUILD
@@ -0,0 +1,50 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=amavisd-new
+pkgver=2.6.3
+pkgrel=0
+pkgdesc="High-performance interface between mailer (MTA) and content checkers"
+url="http://www.ijs.si/software/amavisd"
+license="GPL-2"
+depends="uclibc sed file perl perl-archive-zip perl-convert-tnef
+perl-convert-uulib perl-mime-tools perl-mail-tools perl-net-server
+perl-io-stringy perl-unix-syslog perl-db perl-mail-dkim"
+makedepends=""
+install="$pkgname.post-install"
+subpackages=""
+source="http://www.ijs.si/software/amavisd/$pkgname-$pkgver.tar.gz
+$pkgname.post-install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ HOME=/var/amavis
+ QUARANTINE=$HOME/quarantine
+ USER=amavis
+ GROUP=amavis
+ DIRS="$HOME $HOME/tmp $HOME/var $HOME/db $HOME/home $QUARANTINE"
+ CONFIG=/etc/amavisd.conf
+
+ for dir in $DIRS
+ do
+ if [ ! -d "${pkgdir}$dir" ]; then
+ mkdir -p ${pkgdir}$dir
+ fi
+ chown -R amavis.amavis $HOME
+ done
+
+ install -m 755 -o root -D amavisd $pkgdir/usr/sbin/amavisd
+ install -m 755 -o root -D amavisd-nanny $pkgdir/usr/bin/amavisd-nanny
+ install -m 755 -o root -D amavisd-release $pkgdir/usr/bin/amavisd-release
+ sed -e "s:^.*\$MYHOME = .*$:\$MYHOME = '$HOME';:" \
+ -e 's:^.*\$TEMPBASE = .*$:\$TEMPBASE = "\$MYHOME/tmp";:' \
+ -e 's:^.*\$db_home = .*$:\$db_home = "$MYHOME/db";:' \
+ -e "s:^.*\$QUARANTINEDIR = .*$:\$QUARANTINEDIR = '$QUARANTINE';:" \
+ -e "s:^.*\$daemon_user = 'vscan';\(.*\)$:\$daemon_user = 'amavis';\1:" \
+ -e "s:^.*\$daemon_group = 'vscan';\(.*\)$:\$daemon_group = 'amavis';\1:" < amavisd.conf > amavisd.conf.alpine
+ install -m 640 -o root -g amavis -D amavisd.conf.alpine ${pkgdir}${CONFIG}
+ install -m 755 -D ../../amavisd.init $pkgdir/etc/init.d/amavisd
+}
+
+md5sums="02b0bd38b40258841c60479603dc6842 amavisd-new-2.6.3.tar.gz
+4b5cb0c750ab11d9d211a4e389545d6d amavisd-new.post-install"
diff --git a/main/amavisd-new/amavisd-new.post-install b/main/amavisd-new/amavisd-new.post-install
new file mode 100755
index 00000000000..56cad39f523
--- /dev/null
+++ b/main/amavisd-new/amavisd-new.post-install
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+HOME=/var/amavis
+QUARANTINE=$HOME/quarantine
+USER=amavis
+GROUP=amavis
+DIRS="$HOME $HOME/tmp $HOME/var $HOME/db $HOME/home $QUARANTINE"
+CONFIG=/etc/amavisd.conf
+
+addgroup $USER
+adduser -h $HOME -s /bin/false -G $GROUP -D $USER
+chown -R $USER:$GROUP $HOME
+chmod -R 750 $HOME
+chown root:$GROUP $CONFIG
diff --git a/main/amavisd-new/amavisd.init b/main/amavisd-new/amavisd.init
new file mode 100644
index 00000000000..23f92af3f36
--- /dev/null
+++ b/main/amavisd-new/amavisd.init
@@ -0,0 +1,23 @@
+#!/sbin/runscript
+
+PIDFILE="/var/amavis/amavisd.pid"
+
+depend() {
+ need net
+ use logger
+ use antivirus
+ before mta
+}
+
+start() {
+ ebegin "Starting amavisd-new"
+ start-stop-daemon --start --quiet --name amavisd --pidfile ${PIDFILE} \
+ --exec /usr/sbin/amavisd
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping amavisd-new"
+ start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
+ eend $?
+}
diff --git a/main/apr-util/APKBUILD b/main/apr-util/APKBUILD
new file mode 100644
index 00000000000..38ab8eadf3c
--- /dev/null
+++ b/main/apr-util/APKBUILD
@@ -0,0 +1,32 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=apr-util
+pkgver=1.3.7
+pkgrel=0
+pkgdesc="The Apache Portable Runtime"
+url="http://apr.apache.org/"
+license="APACHE"
+depends=
+subpackages="$pkgname-dev"
+makedepends="apr-dev expat-dev e2fsprogs-dev"
+source="http://www.apache.org/dist/apr/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --with-apr=/usr \
+ --without-pgsql \
+ --without-mysql \
+ --without-sqlite2 \
+ --without-sqlite3 \
+ --without-berkeley-db \
+ --without-gdbm \
+ --without-ldap-lib
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ # we dont need this one
+ rm "$pkgdir"/usr/lib/*.exp
+}
+
+md5sums="2ed3ae6734290296faa193e1177d50e6 apr-util-1.3.7.tar.bz2"
diff --git a/main/apr/APKBUILD b/main/apr/APKBUILD
new file mode 100644
index 00000000000..bee01f8dca4
--- /dev/null
+++ b/main/apr/APKBUILD
@@ -0,0 +1,35 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=apr
+pkgver=1.3.5
+pkgrel=0
+pkgdesc="The Apache Portable Runtime"
+url="http://apr.apache.org/"
+license="APACHE"
+depends=
+makedepends="e2fsprogs-dev"
+subpackages="$pkgname-dev"
+source="http://www.apache.org/dist/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --datadir=/usr/share \
+ --enable-nonportable-atomics \
+ --with-devrandom=/dev/urandom
+ make || return 1
+ make DESTDIR=${pkgdir} install
+}
+
+# basicly everything thats not a *.so* file belongs to the -dev package
+# we override the pre-defined func.
+dev() {
+ local i
+ depends="$pkgname"
+ mkdir -p "$subpkgdir"
+ mv "$pkgdir"/* "$subpkgdir"/
+ mkdir -p "$pkgdir"/usr/lib
+ mv "$subpkgdir"/usr/lib/*.so* "$pkgdir"/usr/lib/
+ return 0
+}
+
+md5sums="9ac9a00eaa190937fdbbde7b4f03ac1e apr-1.3.5.tar.bz2"
diff --git a/main/arpwatch/APKBUILD b/main/arpwatch/APKBUILD
new file mode 100644
index 00000000000..ed18e59661f
--- /dev/null
+++ b/main/arpwatch/APKBUILD
@@ -0,0 +1,36 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer:
+pkgname=arpwatch
+pkgver=2.1a15
+pkgrel=0
+pkgdesc="Ethernet monitoring program"
+url="http://www-nrg.ee.lbl.gov/"
+license="GPL"
+depends="uclibc libpcap"
+makedepends="libpcap-dev"
+install=
+subpackages=""
+source="ftp://ftp.ee.lbl.gov/$pkgname.tar.gz
+ arpwatch.confd
+ arpwatch.initd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make -j1 || return 1
+ #install command wouldn't create directory ?
+ mkdir -p "$pkgdir"/usr/sbin/
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+
+}
+
+md5sums="cebfeb99c4a7c2a6cee2564770415fe7 arpwatch.tar.gz
+dc8300ce5f02d6be95899a2982397064 arpwatch.confd
+404226ad0d10ce9b46b76f058e572426 arpwatch.initd"
diff --git a/main/arpwatch/arpwatch.confd b/main/arpwatch/arpwatch.confd
new file mode 100644
index 00000000000..f44221aa36c
--- /dev/null
+++ b/main/arpwatch/arpwatch.confd
@@ -0,0 +1,12 @@
+# Config file for /etc/init.d/arpwatch
+# see arpwatch.8 for more information
+
+#IFACES="eth0 eth1"
+IFACES="eth0"
+
+# Additional options to pass to arpwatch.
+OPTIONS="-N -p"
+
+# Comment this line if you wish arpwatch to run as root user (not recommended)
+ARPUSER="arpwatch"
+
diff --git a/main/arpwatch/arpwatch.initd b/main/arpwatch/arpwatch.initd
new file mode 100644
index 00000000000..e039e1db8ab
--- /dev/null
+++ b/main/arpwatch/arpwatch.initd
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-analyzer/arpwatch/files/arpwatch.initd,v 1.1 2007/06/02 22:37:16 jokey Exp $
+
+depend() {
+ need net
+}
+
+start() {
+ for IFACE in ${IFACES}
+ do
+ ebegin "Starting arpwatch on ${IFACE}"
+ DATAFILE=/var/lib/arpwatch/${IFACE}.dat
+ [ ! -f ${DATAFILE} ] && touch ${DATAFILE}
+
+ if [ -z ${ARPUSER} ]; then
+ start-stop-daemon --start --quiet --pidfile=/var/run/arpwatch.${IFACE}.pid --exec \
+ /usr/sbin/arpwatch -- -i ${IFACE} -f ${DATAFILE} -P /var/run/arpwatch.${IFACE}.pid ${OPTIONS}
+ else
+ chown ${ARPUSER} ${DATAFILE}
+ start-stop-daemon --start --quiet --pidfile=/var/run/arpwatch.${IFACE}.pid --exec \
+ /usr/sbin/arpwatch -- -i $IFACE -u ${ARPUSER} -f ${DATAFILE} -P /var/run/arpwatch.${IFACE}.pid ${OPTIONS}
+ fi
+ eend $?
+ done
+}
+
+stop() {
+ for IFACE in ${IFACES}
+ do
+ ebegin "Stopping arpwatch on ${IFACE}"
+ start-stop-daemon --stop --quiet --pidfile=/var/run/arpwatch.${IFACE}.pid --exec \
+ /usr/sbin/arpwatch
+ eend $?
+ done
+}
diff --git a/main/aspell/APKBUILD b/main/aspell/APKBUILD
new file mode 100644
index 00000000000..30589a1a34e
--- /dev/null
+++ b/main/aspell/APKBUILD
@@ -0,0 +1,31 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=aspell
+pkgver=0.60.6
+_pkgmajorver=${pkgver%.*}
+pkgrel=0
+pkgdesc="A spell checker designed to eventually replace Ispell"
+url="http://aspell.net/"
+license="LGPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc ncurses libgcc uclibc++"
+makedepends="ncurses-dev uclibc++-dev"
+install=
+source="ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ libmath.patch"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ export CXX=${CXX_UC:-g++-uc}
+
+ ./configure --prefix=/usr || return 1
+
+ # we want add -lm to linker flag for libaspell so wil build that
+ # separately. this is just an ugly workaround
+ make libaspell.la LDFLAGS="$LDFLAGS -lm" || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ ln -s $pkgname-${_pkgmajorver} "$pkgdir"/usr/lib/$pkgname || return 1
+}
+md5sums="bc80f0198773d5c05086522be67334eb aspell-0.60.6.tar.gz
+715f4e138ab33b27201d90cbc98b4fb3 libmath.patch"
diff --git a/main/aspell/libmath.patch b/main/aspell/libmath.patch
new file mode 100644
index 00000000000..3fad33a5d2c
--- /dev/null
+++ b/main/aspell/libmath.patch
@@ -0,0 +1,11 @@
+--- a/Makefile.orig 2009-05-21 08:22:51.000000000 +0000
++++ b/Makefile 2009-05-21 08:23:06.000000000 +0000
+@@ -568,7 +568,7 @@
+ lib/string_list-c.cpp lib/find_speller.cpp lib/speller-c.cpp \
+ lib/string_pair_enumeration-c.cpp lib/new_checker.cpp \
+ modules/filter/url.cpp $(am__append_3)
+-libaspell_la_LIBADD = $(LTLIBINTL) $(PTHREAD_LIB)
++libaspell_la_LIBADD = $(LTLIBINTL) $(PTHREAD_LIB) -lm
+ libaspell_la_LDFLAGS = -version-info 16:4:1 -no-undefined
+ #libaspell_la_LDFLAGS = -version-info 16:4:0 -no-undefined
+ libpspell_la_SOURCES = lib/dummy.cpp
diff --git a/main/asterisk/100-uclibc-daemon.patch b/main/asterisk/100-uclibc-daemon.patch
new file mode 100644
index 00000000000..4956791d4df
--- /dev/null
+++ b/main/asterisk/100-uclibc-daemon.patch
@@ -0,0 +1,44 @@
+diff -Nru asterisk-1.6.1-beta4.org/main/asterisk.c asterisk-1.6.1-beta4/main/asterisk.c
+--- asterisk-1.6.1-beta4.org/main/asterisk.c 2008-12-12 23:05:58.000000000 +0100
++++ asterisk-1.6.1-beta4/main/asterisk.c 2008-12-23 15:28:21.000000000 +0100
+@@ -3295,9 +3295,40 @@
+ #if HAVE_WORKING_FORK
+ if (ast_opt_always_fork || !ast_opt_no_fork) {
+ #ifndef HAVE_SBIN_LAUNCHD
++#ifndef __UCLIBC__
+ if (daemon(1, 0) < 0) {
+ ast_log(LOG_ERROR, "daemon() failed: %s\n", strerror(errno));
+ }
++#else
++ /*
++ * workaround for uClibc-0.9.29 mipsel bug:
++ * recursive mutexes do not work if uClibc daemon() function has been called,
++ * if parent thread locks a mutex
++ * the child thread cannot acquire a lock with the same name
++ * (same code works if daemon() is not called)
++ * but duplication of uClibc daemon.c code in here does work.
++ */
++ int fd;
++ switch (fork()) {
++ case -1:
++ exit(1);
++ case 0:
++ break;
++ default:
++ _exit(0);
++ }
++ if (setsid() == -1)
++ exit(1);
++ if (fork())
++ _exit(0);
++ if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
++ dup2(fd, STDIN_FILENO);
++ dup2(fd, STDOUT_FILENO);
++ dup2(fd, STDERR_FILENO);
++ if (fd > 2)
++ close(fd);
++ }
++#endif
+ ast_mainpid = getpid();
+ /* Blindly re-write pid file since we are forking */
+ unlink(ast_config_AST_PID);
diff --git a/main/asterisk/101-caps-uclibc.patch b/main/asterisk/101-caps-uclibc.patch
new file mode 100644
index 00000000000..1acf87f34fe
--- /dev/null
+++ b/main/asterisk/101-caps-uclibc.patch
@@ -0,0 +1,17 @@
+--- asterisk-1.6.0-beta7.1/configure.ac.orig 2008-04-04 07:31:06 +0000
++++ asterisk-1.6.0-beta7.1/configure.ac 2008-04-04 07:36:14 +0000
+@@ -522,9 +522,11 @@
+
+ AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
+
+-if test "x${host_os}" = "xlinux-gnu" ; then
+- AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
+-fi
++case "${host_os}" in
++ linux*)
++ AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
++ ;;
++esac
+
+ # BSD might not have exp2, and/or log2
+ AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
diff --git a/main/asterisk/102-gsm-pic.patch b/main/asterisk/102-gsm-pic.patch
new file mode 100644
index 00000000000..71370ec0b7b
--- /dev/null
+++ b/main/asterisk/102-gsm-pic.patch
@@ -0,0 +1,54 @@
+--- a/codecs/gsm/Makefile.org 2008-03-29 11:33:09.000000000 +0100
++++ b/codecs/gsm/Makefile 2008-03-29 11:44:40.000000000 +0100
+@@ -37,23 +37,6 @@
+ ######### ppro's, etc, as well as the AMD K6 and K7. The compile will
+ ######### probably require gcc.
+
+-ifeq (, $(findstring $(OSARCH) , Darwin SunOS ))
+-ifeq (, $(findstring $(PROC) , x86_64 amd64 ultrasparc sparc64 arm armv5b armeb ppc powerpc ppc64 ia64 s390 bfin mipsel mips))
+-ifeq (, $(findstring $(shell uname -m) , ppc ppc64 alpha armv4l s390 ))
+-OPTIMIZE+=-march=$(PROC)
+-endif
+-endif
+-endif
+-
+-#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
+-#This works for even old (2.96) versions of gcc and provides a small boost either way.
+-#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
+-#So we go lowest common available by gcc and go a step down, still a step up from
+-#the default as we now have a better instruction set to work with. - Belgarath
+-ifeq ($(PROC),ultrasparc)
+-OPTIMIZE+=-mcpu=v8 -mtune=$(PROC) -O3
+-endif
+-
+ PG =
+ #PG = -g -pg
+ ######### Profiling flags. If you don't know what that means, leave it blank.
+@@ -208,12 +191,10 @@
+ # XXX Keep a space after each findstring argument
+ # XXX should merge with GSM_OBJECTS
+ ifeq ($(OSARCH),linux-gnu)
+-ifeq (,$(findstring $(shell uname -m) , x86_64 amd64 ppc ppc64 alpha armv4l sparc64 parisc s390 ))
+-ifeq (,$(findstring $(PROC) , arm armv5b armeb powerpc ia64 s390 bfin mipsel mips ))
++ifneq ($(K6OPT),)
+ GSM_SOURCES+= $(SRC)/k6opt.s
+ endif
+ endif
+-endif
+
+ TOAST_SOURCES = $(SRC)/toast.c \
+ $(SRC)/toast_lin.c \
+@@ -260,12 +241,10 @@
+ $(SRC)/table.o
+
+ ifeq ($(OSARCH),linux-gnu)
+-ifeq (,$(findstring $(shell uname -m) , x86_64 amd64 ppc ppc64 alpha armv4l sparc64 parisc ))
+-ifeq (,$(findstring $(PROC) , arm armv5b armeb powerpc ia64 bfin mipsel mips ))
++ifneq ($(K6OPT),)
+ GSM_OBJECTS+= $(SRC)/k6opt.o
+ endif
+ endif
+-endif
+
+ TOAST_OBJECTS = $(SRC)/toast.o \
+ $(SRC)/toast_lin.o \
diff --git a/main/asterisk/103-rundir.patch b/main/asterisk/103-rundir.patch
new file mode 100644
index 00000000000..367dc7163f5
--- /dev/null
+++ b/main/asterisk/103-rundir.patch
@@ -0,0 +1,11 @@
+--- asterisk-1.4.0/Makefile.orig 2006-12-24 03:07:19.000000000 +0000
++++ asterisk-1.4.0/Makefile 2006-12-24 03:07:57.000000000 +0000
+@@ -109,7 +109,7 @@
+ ASTSBINDIR=$(sbindir)
+ ASTSPOOLDIR=$(localstatedir)/spool/asterisk
+ ASTLOGDIR=$(localstatedir)/log/asterisk
+- ASTVARRUNDIR=$(localstatedir)/run
++ ASTVARRUNDIR=$(localstatedir)/run/asterisk
+ ASTMANDIR=$(mandir)
+ ifeq ($(OSARCH),FreeBSD)
+ ASTVARLIBDIR=$(prefix)/share/asterisk
diff --git a/main/asterisk/APKBUILD b/main/asterisk/APKBUILD
new file mode 100644
index 00000000000..7e8bb1d1829
--- /dev/null
+++ b/main/asterisk/APKBUILD
@@ -0,0 +1,96 @@
+# Contributor: Timo Teras <timo.teras@iki.fi>
+# Maintainer: Timo Teras <timo.teras@iki.fi>
+pkgname=asterisk
+pkgver=1.6.0.10
+pkgrel=1
+pkgdesc="Asterisk: A Module Open Source PBX System"
+url="http://www.asterisk.org/"
+license="GPL"
+depends=
+makedepends="autoconf automake libtool ncurses-dev popt-dev newt-dev zlib-dev
+ postgresql-dev unixodbc-dev dahdi-tools-dev libpri-dev tar
+ freetds-dev openssl-dev"
+install="$pkgname.pre-install $pkgname.post-install"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-pgsql $pkgname-odbc
+ $pkgname-tds"
+source="http://downloads.digium.com/pub/asterisk/releases/$pkgname-$pkgver.tar.gz
+ 100-uclibc-daemon.patch
+ 101-caps-uclibc.patch
+ 102-gsm-pic.patch
+ 103-rundir.patch
+ asterisk.pre-install
+ asterisk.post-install
+ asterisk.initd
+ asterisk.confd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../[1-9]*.patch; do
+ msg "Apply $i"
+ patch -p1 < $i || return 1
+ done
+
+ sed -i -e 's/PBX_ICONV=1/PBX_ICONV=0/g' configure.ac
+
+ ./bootstrap.sh
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --libdir=/usr/lib \
+ --localstatedir=/var \
+ --disable-xmldoc --with-gsm=internal \
+ --without-iconv --with-popt --with-z --with-newt \
+ --with-odbc --with-postgres --with-tds \
+ --with-dahdi --with-pri --with-tonezone \
+ --without-x11 \
+ || return 1
+
+ # and figure out which modules to build
+ rm menuselect.makeopts
+ make menuselect.makeopts
+ make -j1 || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -d "$pkgdir"/var/run/asterisk
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+}
+
+_find_and_move() {
+ local pattern="$1"
+ cd "$pkgdir" || return 1
+ find -name "$pattern" -type f | while read f; do
+ local dest="$subpkgdir/${f%/*}"
+ mkdir -p "$dest"
+ mv "$f" "$dest"
+ done
+}
+
+pgsql() {
+ depends=
+ install=
+ _find_and_move '*_pgsql*'
+}
+
+odbc() {
+ depends=
+ install=
+ _find_and_move '*odbc*'
+}
+
+tds() {
+ depends=
+ install=
+ _find_and_move '*_tds*'
+}
+
+md5sums="c5e3ceaea876e602b1057d751278b497 asterisk-1.6.0.10.tar.gz
+b00c9d98ce2ad445501248a197c6e436 100-uclibc-daemon.patch
+929f740db7043b4553544ebcc7315c91 101-caps-uclibc.patch
+97b39fd9777a2521d4f9f095482b7ac2 102-gsm-pic.patch
+5008f51c737ec91f5047519bc9f25b85 103-rundir.patch
+b4a97cb1ec3cc3f71a10ce8c067ab430 asterisk.pre-install
+62ecffc90b6714b85f377d1fac73c58b asterisk.post-install
+c618b7fdf4a9edf4cde6d8ccd1e32ee6 asterisk.initd
+ed31d7ba37bcf8b0346dcf8593c395f0 asterisk.confd"
diff --git a/main/asterisk/asterisk.confd b/main/asterisk/asterisk.confd
new file mode 100644
index 00000000000..fe9f138ab7f
--- /dev/null
+++ b/main/asterisk/asterisk.confd
@@ -0,0 +1,91 @@
+#
+# Additional options for asterisk
+#
+# see "asterisk -h" for a list of options
+#
+ASTERISK_OPTS=""
+
+#
+# User and group to run asterisk as
+#
+# Value: double-colon separated list of user and group, or empty to run as root:
+#
+#
+# "asterisk:asterisk" to run as user "asterisk" and group "asterisk"
+# "asterisk" to run as user "asterisk" and all groups that user "asterisk" is a member of
+# ":asterisk" to run as user "root" and group "asterisk"
+# "" to run as user "root" and group "root"
+#
+ASTERISK_USER="asterisk"
+
+#
+# Nicelevel
+#
+# Set the priority of the asterisk process
+#
+# Value: (highest) -20..19 (lowest)
+#
+#ASTERISK_NICE="19"
+
+#
+# Wrapper script
+#
+# Value: yes or no/empty
+#
+ASTERISK_WRAPPER="no"
+
+############# Wrapper script settings #############
+
+#
+# Send crash notifications emails to this address
+# (needs a working mail service and /usr/sbin/sendmail to do so (e.g. ssmtp))
+#
+# Value: Email address or empty to disable
+#
+#ASTERISK_NOTIFY_EMAIL="root"
+
+#
+# Send asterisk's output to this terminal
+#
+# Value: Full path to device node or a number
+#
+#ASTERISK_TTY="/dev/tty9"
+
+#
+# Start an asterisk console on the terminal specified by ASTERISK_TTY
+#
+# Warning! Use only for debugging, this is a potential security issue!
+#
+# Value: yes or no/empty
+#
+ASTERISK_CONSOLE="no"
+
+#
+# Maximum size of core files.
+#
+# Value: Size in bytes, unlimited for no limit or empty to disable.
+#
+#ASTERISK_CORE_SIZE="unlimited"
+
+#
+# ASTERISK_CORE_DIR
+#
+# Value: Directory (will be created if non-existant), default is /tmp
+#
+ASTERISK_CORE_DIR="/var/lib/asterisk/coredump"
+
+#
+# Max number of filedescriptors
+#
+# Value: Number of descriptors
+#
+#ASTERISK_MAX_FD="1024"
+
+#
+# Kill these tasks after asterisk crashed (ASTERISK_WRAPPER=yes only!)
+#
+# Warning! This will kill _ALL_ tasks with the specified names!
+#
+# Value: Space separated list of names in double quotes (e.g. "mpg123 mad")
+#
+#ASTERISK_CLEANUP_ON_CRASH="mpg123 asterisk-mpg123 mad"
diff --git a/main/asterisk/asterisk.initd b/main/asterisk/asterisk.initd
new file mode 100644
index 00000000000..864a96b3cf6
--- /dev/null
+++ b/main/asterisk/asterisk.initd
@@ -0,0 +1,250 @@
+#!/sbin/runscript
+
+opts="${opts} forcestop reload"
+
+depend() {
+ need net
+ use nscd dns zaptel mysql postgresql slapd capi
+}
+
+is_running() {
+ if [ -z "$(pidof asterisk)" ]; then
+ return 1
+ else
+ PID="$(cat /var/run/asterisk/asterisk.pid 2>/dev/null)"
+ for x in $(pidof asterisk); do
+ if [ "${x}" = "${PID}" ]; then
+ return 0
+ fi
+ done
+ fi
+
+ return 1
+}
+
+asterisk_run_loop() {
+ local OPTS ARGS MSG NICE=""
+ local result=0 signal=0
+
+ # default options
+ OPTS="-f" # don't fork / detach breaks wrapper script...
+
+ # filter (redundant) arguments
+ ARGS="$(echo "${@}" | sed -e "s:-c\|-f::g")"
+
+ # mangle yes/no options
+ ASTERISK_CONSOLE="$(echo ${ASTERISK_CONSOLE} | tr '[:lower:]' '[:upper:]')"
+
+ if [ -n "${ASTERISK_CORE_SIZE}" ] &&
+ [ "${ASTERISK_CORE_SIZE}" != "0" ]; then
+ ulimit -c ${ASTERISK_CORE_SIZE}
+
+ if [ -n "${ASTERISK_CORE_DIR}" ] && \
+ [ ! -d "${ASTERISK_CORE_DIR}" ]
+ then
+ mkdir -m750 -p "${ASTERISK_CORE_DIR}"
+
+ if [ -n "${ASTERISK_USER}" ]; then
+ chown -R "${ASTERISK_USER}" "${ASTERISK_CORE_DIR}"
+ fi
+ fi
+ ASTERISK_CORE_DIR="${ASTERISK_CORE_DIR:-/tmp}"
+
+ cd "${ASTERISK_CORE_DIR}"
+ echo " Core dump size : ${ASTERISK_CORE_SIZE}"
+ echo " Core dump location : ${ASTERISK_CORE_DIR}"
+ fi
+
+ if [ -n "${ASTERISK_MAX_FD}" ]; then
+ ulimit -n ${ASTERISK_MAX_FD}
+ echo " Max open filedescriptors : ${ASTERISK_MAX_FD}"
+ fi
+
+ if [ -n "${ASTERISK_NICE}" ]; then
+ echo " Nice level : ${ASTERISK_NICE}"
+ NICE="nice -n ${ASTERISK_NICE} --"
+ fi
+
+ if [ -n "${ASTERISK_NOTIFY_EMAIL}" ]; then
+ if [ -x /usr/sbin/sendmail ]; then
+ echo " Email notifications go to : ${ASTERISK_NOTIFY_EMAIL}"
+ else
+ echo " Notifications disabled, /usr/sbin/sendmail doesn't exist or is not executable!"
+ unset ASTERISK_NOTIFY_EMAIL
+ fi
+ fi
+
+ if [ -n "${ASTERISK_TTY}" ]; then
+ for x in ${ASTERISK_TTY} \
+ /dev/tty${ASTERISK_TTY} \
+ /dev/vc/${ASTERISK_TTY}
+ do
+ if [ -c "${x}" ]; then
+ TTY="${x}"
+ fi
+ done
+ [ -n "${TTY}" ] && \
+ echo " Messages are sent to : ${TTY}"
+ fi
+
+ if [ "${ASTERISK_CONSOLE}" = "YES" ] && [ -n "${TTY}" ]; then
+ echo " Starting Asterisk console : ${ASTERISK_CONSOLE}"
+ OPTS="${OPTS} -c"
+ fi
+
+ OPTS="${OPTS} ${ARGS}"
+
+ while :; do
+
+ if [ -n "${TTY}" ]; then
+ /usr/bin/stty -F ${TTY} sane
+ ${NICE} /usr/sbin/asterisk ${OPTS} >${TTY} 2>&1 <${TTY}
+ result=$?
+ else
+ ${NICE} /usr/sbin/asterisk ${OPTS} &>/dev/null
+ result=$?
+ fi
+
+ if [ $result -eq 0 ]; then
+ echo "Asterisk terminated normally"
+ break
+ else
+ if [ $result -gt 128 ]; then
+ signal=$((result - 128))
+ MSG="Asterisk terminated with Signal: $signal"
+
+ CORE_TARGET="core-$(date "+%Y%m%d-%h%M%s")"
+
+ local CORE_DUMPED=0
+ if [ -f "${ASTERISK_CORE_DIR}/core" ]; then
+ mv "${ASTERISK_CORE_DIR}/core" \
+ "${ASTERISK_CORE_DIR}/${CORE_TARGET}"
+ CORE_DUMPED=1
+
+ elif [ -f "${ASTERISK_CORE_DIR}/core.${PID}" ]; then
+ mv "${ASTERISK_CORE_DIR}/core.${PID}" \
+ "${ASTERISK_CORE_DIR}/${CORE_TARGET}"
+ CORE_DUMPED=1
+
+ fi
+
+ [ $CORE_DUMPED -eq 1 ] && \
+ MSG="${MSG}\n\rCore dumped: ${ASTERISK_CORE_DIR}/${CORE_TARGET}"
+ else
+ MSG="Asterisk terminated with return code: $result"
+ fi
+
+ # kill left-over tasks
+ for X in ${ASTERISK_CLEANUP_ON_CRASH}; do
+ kill -9 $(pidof ${X});
+ done
+ fi
+
+ [ -n "${TTY}" ] \
+ && echo "${MSG}" >${TTY} \
+ || echo "${MSG}"
+
+
+ if [ -n "${ASTERISK_NOTIFY_EMAIL}" ] && \
+ [ -x /usr/sbin/sendmail ]; then
+ echo -e -n "Subject: Asterisk crashed\n\r${MSG}\n\r" |\
+ /usr/sbin/sendmail "${ASTERISK_NOTIFY_EMAIL}"
+ fi
+ sleep 5
+ echo "Restarting Asterisk..."
+ done
+ return 0
+}
+
+start() {
+ local OPTS USER GROUP PID
+ local tmp x
+
+ if [ -n "${ASTERISK_NICE}" ]; then
+ if [ ${ASTERISK_NICE} -ge -20 ] && \
+ [ ${ASTERISK_NICE} -le 19 ]; then
+ OPTS="--nicelevel ${ASTERISK_NICE}"
+ else
+ eerror "Nice value must be between -20 and 19"
+ return 1
+ fi
+ fi
+
+ if [ -n "${ASTERISK_USER}" ]; then
+ USER=$(echo $ASTERISK_USER | sed 's/:.*//')
+ GROUP=$(echo $ASTERISK_USER | awk -F: '/.*:.*/ { print $2 }')
+ if [ -n "${USER}" ]; then
+ ASTERISK_OPTS="${ASTERISK_OPTS} -U ${USER}"
+ fi
+ if [ -n "${GROUP}" ]; then
+ ASTERISK_OPTS="${ASTERISK_OPTS} -G ${GROUP}"
+ GROUP=":${GROUP}" # make it look nice...
+ fi
+ ebegin "Starting asterisk PBX (as ${USER}${GROUP})"
+ else
+ ebegin "Starting asterisk PBX (as root)"
+ fi
+
+ if [ "$(echo ${ASTERISK_WRAPPER} | tr '[:upper:]' '[:lower:]')" != "yes" ]; then
+ start-stop-daemon --start --exec /usr/sbin/asterisk \
+ ${OPTS} -- ${ASTERISK_OPTS}
+ result=$?
+ else
+ asterisk_run_loop ${ASTERISK_OPTS} 2>/dev/null &
+ result=$?
+ fi
+
+ if [ $result -eq 0 ]; then
+ # 2 seconds should be enough for asterisk to start
+ sleep 2
+ is_running
+ result=$?
+ fi
+
+ eend $result
+}
+
+forcestop() {
+ ebegin "Stopping asterisk PBX"
+ start-stop-daemon --stop --pidfile /var/run/asterisk/asterisk.pid
+ eend $?
+}
+
+stop() {
+ if ! is_running; then
+ eerror "Asterisk is not running!"
+ return 0
+ fi
+
+ ebegin "Stopping asterisk PBX now"
+ /usr/sbin/asterisk -r -x "core stop now" &>/dev/null
+ # Now we have to wait until asterisk has _really_ stopped.
+ sleep 1
+ if is_running; then
+ einfon "Waiting for asterisk to shutdown ."
+ local cnt=0
+ while is_running; do
+ cnt=`expr $cnt + 1`
+ if [ $cnt -gt 60 ] ; then
+ # Waited 120 seconds now. Fail.
+ echo
+ eend 1 "Failed."
+ return
+ fi
+ sleep 2
+ echo -n "."
+ done
+ echo
+ fi
+ eend 0
+}
+
+reload() {
+ if is_running; then
+ ebegin "Forcing asterisk to reload configuration"
+ /usr/sbin/asterisk -r -x "modules reload" &>/dev/null
+ eend $?
+ else
+ eerror "Asterisk is not running!"
+ fi
+}
diff --git a/main/asterisk/asterisk.post-install b/main/asterisk/asterisk.post-install
new file mode 100644
index 00000000000..fd51c7fa5d9
--- /dev/null
+++ b/main/asterisk/asterisk.post-install
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+chown -R asterisk:asterisk /var/*/asterisk
+chown -R asterisk:asterisk /etc/asterisk
+chmod -R u=rwX,g=rX,o= /etc/asterisk
+
+# set IP ToS
+# iptables -A OUTPUT -t mangle -p udp -m udp --dport 5060 -j DSCP --set-dscp 0x28
+#iptables -A OUTPUT -t mangle -p udp -m udp --sport 10000:20000 -j DSCP --set-dscp 0x28
+# more info: http://www.voip-info.org/wiki-Asterisk+non-root
+
diff --git a/main/asterisk/asterisk.pre-install b/main/asterisk/asterisk.pre-install
new file mode 100644
index 00000000000..f4724251f38
--- /dev/null
+++ b/main/asterisk/asterisk.pre-install
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+user=asterisk
+home=/var/lib/asterisk
+adduser -h $home -s /bin/false -D $user 2>/dev/null
+mkdir -p $home
+chown $user:$user $home
+exit 0
+
diff --git a/main/aumix/APKBUILD b/main/aumix/APKBUILD
new file mode 100644
index 00000000000..034613b7251
--- /dev/null
+++ b/main/aumix/APKBUILD
@@ -0,0 +1,38 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=aumix
+pkgver=2.8
+pkgrel=0
+pkgdesc="A color text mode sound mixer"
+url="http://www.jpj.net/~trevor/aumix.html"
+license="GPL"
+depends="uclibc ncurses ncurses-terminfo"
+makedepends="ncurses-dev"
+source="http://jpj.net/~trevor/aumix/aumix-$pkgver.tar.bz2
+ aumix-2.8-mute.patch
+ aumix-2.8-nohome.patch
+ aumix-2.8-save_load.patch
+ aumix.initd
+ "
+
+build() {
+ cd "$srcdir"/aumix-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --without-gtk1 \
+ --without-gtk \
+ --disable-nls
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/aumix
+}
+md5sums="dc3fc7209752207c23e7c94ab886b340 aumix-2.8.tar.bz2
+3611c0372870a0ad67630231fe576e32 aumix-2.8-mute.patch
+6c8d691beb495257d8309e58c127acd2 aumix-2.8-nohome.patch
+113377f0f69925467a5a5b633a78160c aumix-2.8-save_load.patch
+affaa735ad9b65a540842994caba18fd aumix.initd"
diff --git a/main/aumix/aumix-2.8-mute.patch b/main/aumix/aumix-2.8-mute.patch
new file mode 100644
index 00000000000..8a32fd5b9b8
--- /dev/null
+++ b/main/aumix/aumix-2.8-mute.patch
@@ -0,0 +1,16 @@
+Fix mute script: save volume and then set it to 0 instead of saving it directly
+to 0. Bug #122087.
+Index: aumix-2.8/src/mute
+===================================================================
+--- aumix-2.8.orig/src/mute
++++ aumix-2.8/src/mute
+@@ -8,7 +8,8 @@
+ volumes=$(aumix -vq |tr -d ,)
+ if [ $(echo $volumes | awk '{print $2}') -ne 0 -o \
+ $(echo $volumes | awk '{print $3}') -ne 0 ]; then
+- aumix -S -v 0
++ aumix -S
++ aumix -v 0
+ else
+ aumix -L > /dev/null
+ fi
diff --git a/main/aumix/aumix-2.8-nohome.patch b/main/aumix/aumix-2.8-nohome.patch
new file mode 100644
index 00000000000..bf20f0372c0
--- /dev/null
+++ b/main/aumix/aumix-2.8-nohome.patch
@@ -0,0 +1,12 @@
+diff -Naur aumix-2.8.orig/src/common.c aumix-2.8/src/common.c
+--- aumix-2.8.orig/src/common.c 2002-10-29 13:27:51.000000000 -0800
++++ aumix-2.8/src/common.c 2004-07-22 01:28:07.684999900 -0700
+@@ -591,7 +591,7 @@
+ char filename[PATH_MAX];
+ if (save_filename == NULL) {
+ home = getenv("HOME");
+- if ((strlen(home) + strlen(AUMIXRC) + 2) < PATH_MAX) {
++ if (home && (strlen(home) + strlen(AUMIXRC) + 2) < PATH_MAX) {
+ sprintf(filename, "%s/.%s", home, AUMIXRC);
+ setfile = CheckAndOpen(filename, mode);
+ }
diff --git a/main/aumix/aumix-2.8-save_load.patch b/main/aumix/aumix-2.8-save_load.patch
new file mode 100644
index 00000000000..498716b517a
--- /dev/null
+++ b/main/aumix/aumix-2.8-save_load.patch
@@ -0,0 +1,45 @@
+--- a/src/common.c 2002-11-28 14:22:00.000000000 +0100
++++ b/src/common.c 2002-11-28 14:23:11.000000000 +0100
+@@ -116,6 +116,7 @@
+ int main(int argc, char *argv[])
+ {
+ int optn, ii;
++ int save = 0, load = 0;
+ #ifdef HAVE_CURSES
+ int setcolors = FALSE;
+ #endif /* HAVE_CURSES */
+@@ -171,14 +172,10 @@
+ break;
+ #endif /* HAVE_CURSES */
+ case 'S': /* Save to file. */
+- if (mixer_fd == -1)
+- ErrorExitWarn(InitializeMixer(device_filename), 'e');
+- ErrorExitWarn(SaveSettings(), 'e');
++ save = 1;
+ break;
+ case 'L': /* Load from file. */
+- if (mixer_fd == -1)
+- ErrorExitWarn(InitializeMixer(device_filename), 'e');
+- ErrorExitWarn(LoadSettings(), 'e');
++ load = 1;
+ break;
+ #if defined (HAVE_CURSES) || defined (HAVE_GTK) || defined (HAVE_GTK1)
+ case 'I': /* User asked for interactive mode. */
+@@ -194,6 +191,17 @@
+ }
+ }
+ }
++ if (save | load) {
++ if (mixer_fd == -1)
++ ErrorExitWarn(InitializeMixer(device_filename), 'e');
++ if (save)
++ ErrorExitWarn(SaveSettings(), 'e');
++ else
++ ErrorExitWarn(LoadSettings(), 'e');
++ close(mixer_fd);
++ exit(EXIT_SUCCESS);
++ }
++
+ #if defined (HAVE_CURSES) || defined (HAVE_GTK) || defined (HAVE_GTK1)
+ /* Be interactive if no options were given. */
+ if (!interactive && argc <= 1)
diff --git a/main/aumix/aumix.initd b/main/aumix/aumix.initd
new file mode 100644
index 00000000000..2c1741b3b98
--- /dev/null
+++ b/main/aumix/aumix.initd
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/media-sound/aumix/files/aumix.rc6,v 1.12 2007/03/25 13:05:51 drac Exp $
+
+depend() {
+ use modules hotplug coldplug alsasound
+}
+
+checkconfig() {
+ if ! grep -q -E 'sound|OSS|sparcaudio' /proc/devices && [ ! -d /proc/asound ] ; then
+ eerror "Sound support has not been compiled into the kernel,"
+ eerror "or is disabled. Please check that the correct modules"
+ eerror "is loaded."
+ return 1
+ fi
+ # /dev/mixer can be a symlink
+ if [ ! -e /dev/mixer ] ; then
+ eerror "/dev/mixer does not exist, please create it, or load the"
+ eerror "correct modules to enable your card's mixer"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ if [ -f /etc/aumixrc ] ; then
+ ebegin "Loading Mixer settings"
+ /usr/bin/aumix -f /etc/aumixrc -L >/dev/null 2>&1
+ else
+ ebegin "Setting Mixer settings"
+ /usr/bin/aumix -v75 -c75 -w75 >/dev/null 2>&1
+ fi
+ eend $?
+}
+
+stop() {
+ checkconfig || return 1
+ ebegin "Saving Mixer settings"
+ /usr/bin/aumix -f /etc/aumixrc -S >/dev/null 2>&1
+ eend $?
+}
diff --git a/main/b43-fwcutter/APKBUILD b/main/b43-fwcutter/APKBUILD
new file mode 100644
index 00000000000..0a7f4cc6a4f
--- /dev/null
+++ b/main/b43-fwcutter/APKBUILD
@@ -0,0 +1,24 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=b43-fwcutter
+pkgver=012
+pkgrel=0
+pkgdesc="Tool to extract firmware from Broadcom drivers"
+url="http://linuxwireless.org/en/users/Drivers/b43"
+license="GPL"
+depends=""
+makedepends=""
+install=
+subpackages="$pkgname-doc"
+source="http://bu3sch.de/b43/fwcutter/b43-fwcutter-012.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make || return 1
+ make PREFIX="$pkgdir"/usr install
+ mkdir -p "$pkgdir"/usr/share/
+ mv "$pkgdir"/usr/man "$pkgdir"/usr/share/
+}
+
+md5sums="69eadf67b459f313a8d6b37aaabef96c b43-fwcutter-012.tar.bz2"
diff --git a/main/bc/APKBUILD b/main/bc/APKBUILD
new file mode 100644
index 00000000000..d5f1851f2d3
--- /dev/null
+++ b/main/bc/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=bc
+pkgver=1.06
+pkgrel=1
+pkgdesc="arbitrary precision numeric processing language (calculator)"
+url="http://www.gnu.org/software/bc/bc.html"
+license="GPL"
+depends=
+makedepends="flex readline-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://mirrors.kernel.org/gnu/bc/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="d44b5dddebd8a7a7309aea6c36fda117 bc-1.06.tar.gz"
diff --git a/main/beep/APKBUILD b/main/beep/APKBUILD
new file mode 100644
index 00000000000..742998204e0
--- /dev/null
+++ b/main/beep/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=beep
+pkgver=1.2.2
+pkgrel=0
+pkgdesc="A terminal bell"
+url="http://johnath.com/beep"
+license="GPL-2"
+depends="uclibc"
+makedepends=""
+#install=
+subpackages="$pkgname-doc"
+source="http://johnath.com/$pkgname/$pkgname-$pkgver.tar.gz
+ beep-1.2.2-nosuid.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ patch beep.c < ../../beep-1.2.2-nosuid.patch
+
+ make || return 1
+
+ install -m755 -D "$srcdir/$pkgname-$pkgver/beep" "$pkgdir"/usr/bin/beep
+ install -m644 -D "$srcdir/$pkgname-$pkgver/beep.1.gz" "$pkgdir"/usr/share/man/man1/beep.1.gz
+}
+
+md5sums="d541419fd7e5642952d7b48cbb40c712 beep-1.2.2.tar.gz
+38e2fc3ea98ced50038799ca80fdd9ee beep-1.2.2-nosuid.patch"
+
diff --git a/main/beep/beep-1.2.2-nosuid.patch b/main/beep/beep-1.2.2-nosuid.patch
new file mode 100644
index 00000000000..33e6affa9ff
--- /dev/null
+++ b/main/beep/beep-1.2.2-nosuid.patch
@@ -0,0 +1,33 @@
+--- beep.c.orig 2005-07-23 13:37:01.000000000 -0400
++++ beep.c 2005-07-23 14:00:55.000000000 -0400
+@@ -218,22 +218,20 @@
+ int i; /* loop counter */
+
+ /* try to snag the console */
+- if((console_fd = open("/dev/console", O_WRONLY)) == -1) {
+- fprintf(stderr, "Could not open /dev/console for writing.\n");
+- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */
+- perror("open");
+- exit(1);
+- }
++ console_fd = open("/dev/console", O_WRONLY);
+
+ /* Beep */
+ for (i = 0; i < parms.reps; i++) { /* start beep */
+- if(ioctl(console_fd, KIOCSOUND, (int)(CLOCK_TICK_RATE/parms.freq)) < 0) {
+- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */
+- perror("ioctl");
++ if (console_fd >= 0) {
++ ioctl(console_fd, KIOCSOUND, (int)(CLOCK_TICK_RATE/parms.freq));
++ } else {
++ printf("\a"); /* Output the fall back for usefulness we don't have to be suid to work at all */
++ fflush(stdout);
+ }
+ /* Look ma, I'm not ansi C compatible! */
+ usleep(1000*parms.length); /* wait... */
+- ioctl(console_fd, KIOCSOUND, 0); /* stop beep */
++ if (console_fd >= 0)
++ ioctl(console_fd, KIOCSOUND, 0); /* stop beep */
+ if(parms.end_delay || (i+1 < parms.reps))
+ usleep(1000*parms.delay); /* wait... */
+ } /* repeat. */
diff --git a/main/bind/APKBUILD b/main/bind/APKBUILD
new file mode 100644
index 00000000000..533bfa7177a
--- /dev/null
+++ b/main/bind/APKBUILD
@@ -0,0 +1,95 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=bind
+pkgver=9.6.0_p1
+pkgrel=1
+pkgdesc="BIND - Berkeley Internet Name Domain - Name Server and tools"
+url="http://www.isc.org"
+license="as-is"
+depends=uclibc
+makedepends="openssl-dev"
+install="$pkgname.pre-install $pkgname.post-install"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-libs $pkgname-tools"
+source="http://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz
+ bind.so_bsdcompat.patch
+ $pkgname.initd
+ $pkgname.confd
+ $pkgname.conf
+ $pkgname.127.zone
+ $pkgname.localhost.zone
+ $pkgname.named.ca
+ $install"
+
+build() {
+ cd "$srcdir/bind-9.6.0-P1"
+
+ ### http://bugs.gentoo.org/show_bug.cgi?id=227333
+ export CFLAGS="$CFLAGS -D_GNU_SOURCE"
+
+ # Adjusting PATHs in manpages
+ for i in bin/named/named.8 bin/check/named-checkconf.8 bin/rndc/rndc.8; do
+ sed -i \
+ -e 's:/etc/named.conf:/etc/bind/named.conf:g' \
+ -e 's:/etc/rndc.conf:/etc/bind/rndc.conf:g' \
+ -e 's:/etc/rndc.key:/etc/bind/rndc.key:g' \
+ "${i}" || return 1
+ done
+
+ patch -p0 -i "$srcdir"/bind.so_bsdcompat.patch || return 1
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/bind \
+ --localstatedir=/var \
+ --with-openssl=/usr \
+ --disable-linux-caps \
+ --without-libxml2 \
+ --disable-threads \
+ --enable-ipv6 \
+ --enable-shared \
+ --enable-static \
+ --with-libtool \
+ --with-randomdev=/dev/random \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ depends="$depends $pkgname-libs"
+
+ install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/named || return 1
+ install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/named || return 1
+ install -Dm644 "$srcdir"/$pkgname.conf "$pkgdir"/etc/bind/named.conf || return 1
+ install -Dm644 "$srcdir"/$pkgname.named.ca "$pkgdir"/var/bind/named.ca || return 1
+ install -Dm644 "$srcdir"/$pkgname.127.zone "$pkgdir"/var/bind/pri/127.zone || return 1
+ install -Dm644 "$srcdir"/$pkgname.localhost.zone "$pkgdir"/var/bind/pri/localhost.zone || return 1
+ mkdir -p "$pkgdir"/var/bind/sec || return 1
+ cd "$pkgdir"/var/bind
+ ln -s named.ca root.cache || return 1
+}
+
+libs() {
+ install=""
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
+}
+
+tools() {
+ install=""
+ depends="$pkgname-libs"
+ mkdir -p "$subpkgdir"/usr/bin
+ for i in dig host nslookup nsupdate; do
+ mv "$pkgdir"/usr/bin/${i} "$subpkgdir"/usr/bin/ || return 1
+ done
+}
+
+md5sums="886b7eae55cfdc8cd8d2ca74a2f99c6e bind-9.6.0-P1.tar.gz
+f270a5b0a28ab6e818840c5c368ddbcc bind.so_bsdcompat.patch
+3adc904c1c12f81839d9369f7241022b bind.initd
+8b05a287976d66d51c18b73ee7523671 bind.confd
+be5fd752bdbd59385f2a559d603098d5 bind.conf
+a7455b009b7fccd74ac6f6eaa6902a00 bind.127.zone
+c3220168fabfb31a25e8c3a545545e34 bind.localhost.zone
+a94e29ac677846f3d4d618c50b7d34f1 bind.named.ca
+d3137e2de6f82acfc914d4916999cf2a bind.pre-install
+695c957be18ec4f8ea46d0b1ff50b09b bind.post-install"
diff --git a/main/bind/bind.127.zone b/main/bind/bind.127.zone
new file mode 100644
index 00000000000..2ad28de52c3
--- /dev/null
+++ b/main/bind/bind.127.zone
@@ -0,0 +1,11 @@
+$ORIGIN 127.in-addr.arpa.
+$TTL 1W
+@ 1D IN SOA localhost. root.localhost. (
+ 2002081601 ; serial
+ 3H ; refresh
+ 15M ; retry
+ 1W ; expiry
+ 1D ) ; minimum
+
+ 1D IN NS localhost.
+1 1D IN PTR localhost.
diff --git a/main/bind/bind.conf b/main/bind/bind.conf
new file mode 100644
index 00000000000..d58c61bde0c
--- /dev/null
+++ b/main/bind/bind.conf
@@ -0,0 +1,53 @@
+options {
+ directory "/var/bind";
+
+ // uncomment the following lines to turn on DNS forwarding,
+ // and change the forwarding ip address(es) :
+ //forward first;
+ //forwarders {
+ // 123.123.123.123;
+ // 123.123.123.123;
+ //};
+
+ listen-on-v6 { none; };
+ listen-on { 127.0.0.1; };
+
+ // to allow only specific hosts to use the DNS server:
+ //allow-query {
+ // 127.0.0.1;
+ //};
+
+ // if you have problems and are behind a firewall:
+ //query-source address * port 53;
+ pid-file "/var/run/named/named.pid";
+};
+
+// Briefly, a zone which has been declared delegation-only will be effectively
+// limited to containing NS RRs for subdomains, but no actual data beyond its
+// own apex (for example, its SOA RR and apex NS RRset). This can be used to
+// filter out "wildcard" or "synthesized" data from NAT boxes or from
+// authoritative name servers whose undelegated (in-zone) data is of no
+// interest.
+// See http://www.isc.org/products/BIND/delegation-only.html for more info
+
+//zone "COM" { type delegation-only; };
+//zone "NET" { type delegation-only; };
+
+zone "." IN {
+ type hint;
+ file "named.ca";
+};
+
+zone "localhost" IN {
+ type master;
+ file "pri/localhost.zone";
+ allow-update { none; };
+ notify no;
+};
+
+zone "127.in-addr.arpa" IN {
+ type master;
+ file "pri/127.zone";
+ allow-update { none; };
+ notify no;
+};
diff --git a/main/bind/bind.confd b/main/bind/bind.confd
new file mode 100644
index 00000000000..82d37635090
--- /dev/null
+++ b/main/bind/bind.confd
@@ -0,0 +1,14 @@
+# Set various named options here.
+OPTS=""
+
+# Set this to the number of processors you have.
+CPU="1"
+
+# User which named should run as
+USER="named"
+
+# Default pid file location
+PIDFILE="/var/run/named/named.pid"
+
+# Scheduling priority: 19 is the lowest and -20 is the highest.
+NICELEVEL="0"
diff --git a/main/bind/bind.initd b/main/bind/bind.initd
new file mode 100644
index 00000000000..6469ee79ac4
--- /dev/null
+++ b/main/bind/bind.initd
@@ -0,0 +1,24 @@
+#!/sbin/runscript
+
+NAME=named
+DAEMON=/usr/sbin/$NAME
+
+depend() {
+ need net
+ use logger
+ provide dns
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet --background \
+ --exec ${DAEMON} --nicelevel ${NICELEVEL} \
+ -- -u ${USER} -n ${CPU} ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE
+ eend $?
+}
diff --git a/main/bind/bind.localhost.zone b/main/bind/bind.localhost.zone
new file mode 100644
index 00000000000..338d7050ca0
--- /dev/null
+++ b/main/bind/bind.localhost.zone
@@ -0,0 +1,11 @@
+$TTL 1W
+@ IN SOA ns.localhost. root.localhost. (
+ 2002081601 ; Serial
+ 28800 ; Refresh
+ 14400 ; Retry
+ 604800 ; Expire - 1 week
+ 86400 ) ; Minimum
+@ IN NS ns
+ns IN A 127.0.0.1
+
+ns IN AAAA ::1
diff --git a/main/bind/bind.named.ca b/main/bind/bind.named.ca
new file mode 100644
index 00000000000..902a7047f9c
--- /dev/null
+++ b/main/bind/bind.named.ca
@@ -0,0 +1,85 @@
+; This file holds the information on root name servers needed to
+; initialize cache of Internet domain name servers
+; (e.g. reference this file in the "cache . <file>"
+; configuration file of BIND domain name servers).
+;
+; This file is made available by InterNIC
+; under anonymous FTP as
+; file /domain/named.root
+; on server FTP.INTERNIC.NET
+; -OR- RS.INTERNIC.NET
+;
+; last update: Feb 04, 2008
+; related version of root zone: 2008020400
+;
+; formerly NS.INTERNIC.NET
+;
+. 3600000 IN NS A.ROOT-SERVERS.NET.
+A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
+A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30
+;
+; formerly NS1.ISI.EDU
+;
+. 3600000 NS B.ROOT-SERVERS.NET.
+B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
+;
+; formerly C.PSI.NET
+;
+. 3600000 NS C.ROOT-SERVERS.NET.
+C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
+;
+; formerly TERP.UMD.EDU
+;
+. 3600000 NS D.ROOT-SERVERS.NET.
+D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
+;
+; formerly NS.NASA.GOV
+;
+. 3600000 NS E.ROOT-SERVERS.NET.
+E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
+;
+; formerly NS.ISC.ORG
+;
+. 3600000 NS F.ROOT-SERVERS.NET.
+F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
+F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2f::f
+;
+; formerly NS.NIC.DDN.MIL
+;
+. 3600000 NS G.ROOT-SERVERS.NET.
+G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
+;
+; formerly AOS.ARL.ARMY.MIL
+;
+. 3600000 NS H.ROOT-SERVERS.NET.
+H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
+H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803f:235
+;
+; formerly NIC.NORDU.NET
+;
+. 3600000 NS I.ROOT-SERVERS.NET.
+I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
+;
+; operated by VeriSign, Inc.
+;
+. 3600000 NS J.ROOT-SERVERS.NET.
+J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
+J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30
+;
+; operated by RIPE NCC
+;
+. 3600000 NS K.ROOT-SERVERS.NET.
+K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
+K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7fd::1
+;
+; operated by ICANN
+;
+. 3600000 NS L.ROOT-SERVERS.NET.
+L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42
+;
+; operated by WIDE
+;
+. 3600000 NS M.ROOT-SERVERS.NET.
+M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
+M.ROOT-SERVERS.NET. 3600000 AAAA 2001:dc3::35
+; End of File
diff --git a/main/bind/bind.post-install b/main/bind/bind.post-install
new file mode 100644
index 00000000000..7e091c097ca
--- /dev/null
+++ b/main/bind/bind.post-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+install -dD -o named -g named /var/run/named
+chown -R named:named /var/bind
+
diff --git a/main/bind/bind.pre-install b/main/bind/bind.pre-install
new file mode 100644
index 00000000000..c7996345029
--- /dev/null
+++ b/main/bind/bind.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+adduser -h /etc/bind -s /bin/false -D named 2>/dev/null
+exit 0
+
diff --git a/main/bind/bind.so_bsdcompat.patch b/main/bind/bind.so_bsdcompat.patch
new file mode 100644
index 00000000000..83120f77de2
--- /dev/null
+++ b/main/bind/bind.so_bsdcompat.patch
@@ -0,0 +1,11 @@
+--- lib/isc/unix/socket.c.orig 2005-11-03 17:08:42.000000000 -0600
++++ lib/isc/unix/socket.c 2006-02-18 13:09:15.000000000 -0600
+@@ -245,6 +245,8 @@
+
+ #define SOCK_DEAD(s) ((s)->references == 0)
+
++#undef SO_BSDCOMPAT
++
+ static void
+ manager_log(isc_socketmgr_t *sockmgr,
+ isc_logcategory_t *category, isc_logmodule_t *module, int level,
diff --git a/main/bitlib/APKBUILD b/main/bitlib/APKBUILD
new file mode 100644
index 00000000000..91400afc909
--- /dev/null
+++ b/main/bitlib/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=bitlib
+pkgver=25
+pkgrel=0
+pkgdesc="A lua library providing bitwise operations"
+url="http://luaforge.net/projects/bitlib"
+license="MIT/X11"
+depends="uclibc lua"
+makedepends="lua-dev"
+subpackages="$pkgname-dev"
+source=http://luaforge.net/frs/download.php/3065/bitlib-$pkgver.tar.gz
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="18f124c80c685f2269296a7172e600fe bitlib-25.tar.gz"
diff --git a/main/bridge-utils/APKBUILD b/main/bridge-utils/APKBUILD
new file mode 100644
index 00000000000..0caaed9bcfe
--- /dev/null
+++ b/main/bridge-utils/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=bridge-utils
+pkgver=1.4
+pkgrel=0
+pkgdesc="Tools for configuring the Linux kernel 802.1d Ethernet Bridge"
+url="http://bridge.sourceforge.net/"
+license="GPL-2"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc"
+makedepends="autoconf"
+source="http://download.sourceforge.net/bridge/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ autoconf
+ # src_compile
+ configure --prefix=/ \
+ --mandir=/usr/share/man \
+ --libdir=/usr/lib \
+ --includedir=/usr/include \
+ || return 1
+ make || return 1
+ make install DESTDIR="$pkgdir" || return 1
+}
+md5sums="0182fcac3a2b307113bbec34e5f1c673 bridge-utils-1.4.tar.gz"
diff --git a/main/bzip2/APKBUILD b/main/bzip2/APKBUILD
new file mode 100644
index 00000000000..09721bb7609
--- /dev/null
+++ b/main/bzip2/APKBUILD
@@ -0,0 +1,48 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=bzip2
+pkgver=1.0.5
+pkgrel=1
+pkgdesc="A high-quality data compression program"
+url="http://sources.redhat.com/bzip2"
+license="BZIP2"
+depends="uclibc"
+install="$pkgname.post-deinstall"
+source="http://www.bzip.org/$pkgver/$pkgname-$pkgver.tar.gz
+ $install
+ bzip2-1.0.4-POSIX-shell.patch
+ bzip2-1.0.4-makefile-CFLAGS.patch
+ bzip2-1.0.4-man-links.patch
+ bzip2-1.0.4-saneso.patch
+ "
+subpackages="$pkgname-dev $pkgname-doc"
+
+build () {
+ local i
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying ${i##*/}"
+ patch -p1 < $i || return 1
+ done
+
+ # Fix man path
+ # Generate relative symlinks
+ sed -i \
+ -e 's:\$(PREFIX)/man:\$(PREFIX)/share/man:g' \
+ -e 's:ln -s -f $(PREFIX)/bin/:ln -s :' \
+ Makefile || return 1
+
+ # fixup broken version stuff
+ sed -i \
+ -e "s:1\.0\.4:$pkgver:" \
+ bzip2.1 bzip2.txt Makefile-libbz2_so manual.* || return 1
+
+ make -f Makefile-libbz2_so all || return 1
+ make all || return 1
+ make PREFIX="$pkgdir"/usr install || return 1
+}
+md5sums="3c15a0c8d1d3ee1c46a1634d00617b1a bzip2-1.0.5.tar.gz
+b84506d253e04db3c5af9016fead45a3 bzip2.post-deinstall
+2e9bcfeb1614b55f5ba2d087ac65a3fe bzip2-1.0.4-POSIX-shell.patch
+56b90131e3c2ae425b758de9c7be7682 bzip2-1.0.4-makefile-CFLAGS.patch
+fd13ef6bc55276c7e3adc346bde56cd1 bzip2-1.0.4-man-links.patch
+643983e8134723ebe53c858b1a3938ad bzip2-1.0.4-saneso.patch"
diff --git a/main/bzip2/bzip2-1.0.4-POSIX-shell.patch b/main/bzip2/bzip2-1.0.4-POSIX-shell.patch
new file mode 100644
index 00000000000..74f8df000b1
--- /dev/null
+++ b/main/bzip2/bzip2-1.0.4-POSIX-shell.patch
@@ -0,0 +1,21 @@
+bzgrep uses !/bin/sh but then uses the bashism ${var//} so replace those
+with calls to sed so POSIX shells work
+
+http://bugs.gentoo.org/193365
+
+--- a/bzgrep
++++ b/bzgrep
+@@ -63,10 +63,9 @@
+ bzip2 -cdfq "$i" | $grep $opt "$pat"
+ r=$?
+ else
+- j=${i//\\/\\\\}
+- j=${j//|/\\|}
+- j=${j//&/\\&}
+- j=`printf "%s" "$j" | tr '\n' ' '`
++ # the backslashes here are doubled up as we have to escape each one for the
++ # shell and then escape each one for the sed expression
++ j=`printf "%s" "${i}" | sed -e 's:\\\\:\\\\\\\\:g' -e 's:[|]:\\\\|:g' -e 's:[&]:\\\\&:g' | tr '\n' ' '`
+ bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
+ r=$?
+ fi
diff --git a/main/bzip2/bzip2-1.0.4-makefile-CFLAGS.patch b/main/bzip2/bzip2-1.0.4-makefile-CFLAGS.patch
new file mode 100644
index 00000000000..85a3c6af6c3
--- /dev/null
+++ b/main/bzip2/bzip2-1.0.4-makefile-CFLAGS.patch
@@ -0,0 +1,25 @@
+--- a/Makefile
++++ b/Makefile
+@@ -18,10 +18,9 @@
+ CC=gcc
+ AR=ar
+ RANLIB=ranlib
+-LDFLAGS=
+
+ BIGFILES=-D_FILE_OFFSET_BITS=64
+-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
++CFLAGS+=-Wall -Winline $(BIGFILES)
+
+ # Where you want it installed when you do 'make install'
+ PREFIX=/usr/local
+--- a/Makefile-libbz2_so
++++ b/Makefile-libbz2_so
+@@ -24,7 +24,7 @@
+ SHELL=/bin/sh
+ CC=gcc
+ BIGFILES=-D_FILE_OFFSET_BITS=64
+-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
++CFLAGS+=-fpic -fPIC -Wall -Winline $(BIGFILES)
+
+ OBJS= blocksort.o \
+ huffman.o \
diff --git a/main/bzip2/bzip2-1.0.4-man-links.patch b/main/bzip2/bzip2-1.0.4-man-links.patch
new file mode 100644
index 00000000000..2427d6a7fb1
--- /dev/null
+++ b/main/bzip2/bzip2-1.0.4-man-links.patch
@@ -0,0 +1,12 @@
+http://bugs.gentoo.org/172986
+
+--- bzip2-1.0.4/Makefile
++++ bzip2-1.0.4/Makefile
+@@ -85,4 +85,7 @@
+ cp -f bzip2.1 $(PREFIX)/share/man/man1
+ chmod a+r $(PREFIX)/share/man/man1/bzip2.1
++ ln -s bzip2.1 $(PREFIX)/share/man/man1/bunzip2.1
++ ln -s bzip2.1 $(PREFIX)/share/man/man1/bzcat.1
++ ln -s bzip2.1 $(PREFIX)/share/man/man1/bzip2recover.1
+ cp -f bzlib.h $(PREFIX)/include
+ chmod a+r $(PREFIX)/include/bzlib.h
diff --git a/main/bzip2/bzip2-1.0.4-saneso.patch b/main/bzip2/bzip2-1.0.4-saneso.patch
new file mode 100644
index 00000000000..9a71342ca9d
--- /dev/null
+++ b/main/bzip2/bzip2-1.0.4-saneso.patch
@@ -0,0 +1,13 @@
+--- a/Makefile-libbz2_so
++++ b/Makefile-libbz2_so
+@@ -35,8 +35,8 @@
+ bzlib.o
+
+ all: $(OBJS)
+- $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS)
+- $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4
++ $(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,libbz2.so.1 -o libbz2.so.1.0.4 $(OBJS)
++ $(CC) $(LDFLAGS) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4
+ rm -f libbz2.so.1.0
+ ln -s libbz2.so.1.0.4 libbz2.so.1.0
+
diff --git a/main/bzip2/bzip2.post-deinstall b/main/bzip2/bzip2.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/bzip2/bzip2.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/c-ares/APKBUILD b/main/c-ares/APKBUILD
new file mode 100644
index 00000000000..889eab3591d
--- /dev/null
+++ b/main/c-ares/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=c-ares
+pkgver=1.6.0
+pkgrel=1
+pkgdesc="An asynchronously DNS/names resolver library"
+url="http://c-ares.haxx.se/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://c-ares.haxx.se/${pkgname}-${pkgver}.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-shared
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="4503b0db3dd79d3c1f58d87722dbab46 c-ares-1.6.0.tar.gz"
+
diff --git a/main/ca-certificates/APKBUILD b/main/ca-certificates/APKBUILD
new file mode 100644
index 00000000000..e39567de177
--- /dev/null
+++ b/main/ca-certificates/APKBUILD
@@ -0,0 +1,30 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ca-certificates
+pkgver=20090709
+pkgrel=0
+pkgdesc="Common CA certificates PEM files"
+url="http://packages.debian.org/sid/ca-certificates"
+license="MPL GPL"
+depends="run-parts openssl"
+install=ca-certificates.post-install
+source="http://ftp.no.debian.org/debian/pool/main/c/$pkgname/${pkgname}_${pkgver}_all.deb
+ $install
+ "
+
+build () {
+ cd "$srcdir"
+ ar x "$srcdir"/${pkgname}_${pkgver}_all.deb || return 1
+ tar -zxf ./data.tar.gz
+
+ mkdir -p "$pkgdir"
+ cp -Ra usr etc "$pkgdir"/
+ (
+ echo "# Automatically generated by ${pkgname}-${pkgver}-${pkgrel}"
+ echo "# $(date -u)"
+ echo "# Do not edit."
+ cd "$pkgdir"/usr/share/ca-certificates
+ find . -name '*.crt' | sort | cut -b3-
+ ) > "$pkgdir"/etc/ca-certificates.conf
+}
+md5sums="72c284149d15b336a1758af819192d21 ca-certificates_20090709_all.deb
+83a92f371137ac9f046c94452bf17058 ca-certificates.post-install"
diff --git a/main/ca-certificates/ca-certificates.post-install b/main/ca-certificates/ca-certificates.post-install
new file mode 100644
index 00000000000..439cfca52e3
--- /dev/null
+++ b/main/ca-certificates/ca-certificates.post-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+/usr/sbin/update-ca-certificates --fresh &> /dev/null
+
+exit 0;
diff --git a/main/ccache/APKBUILD b/main/ccache/APKBUILD
new file mode 100644
index 00000000000..2143bdb7286
--- /dev/null
+++ b/main/ccache/APKBUILD
@@ -0,0 +1,32 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ccache
+pkgver=2.4
+pkgrel=0
+pkgdesc="ccache is a compiler cache"
+url="http://ccache.samba.org/"
+license="GPL"
+subpackages="$pkgname-doc"
+depends="uclibc"
+makedepends=""
+source="http://samba.org/ftp/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr
+ make || return 1
+ install -Dm 755 ccache "$pkgdir"/usr/bin/ccache
+ install -Dm 644 ccache.1 "$pkgdir"/usr/share/man/man1/ccache.1
+ mkdir -p "$pkgdir"/usr/lib/ccache/bin
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/cc
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/gcc
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/g++
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/cpp
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/c++
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/${CHOST}-cc
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/${CHOST}-gcc
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/${CHOST}-g++
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/${CHOST}-cpp
+ ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/${CHOST}-c++
+}
+md5sums="73c1ed1e767c1752dd0f548ec1e66ce7 ccache-2.4.tar.gz"
diff --git a/main/cdrkit/APKBUILD b/main/cdrkit/APKBUILD
new file mode 100644
index 00000000000..a5ca8d77104
--- /dev/null
+++ b/main/cdrkit/APKBUILD
@@ -0,0 +1,31 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cdrkit
+pkgver=1.1.9
+pkgrel=1
+pkgdesc="Suite of programs for CD/DVD recording, ISO image creation, and audio CD extraction"
+url="http://cdrkit.org/"
+license="GPL2"
+depends="libcap file bzip2 zlib"
+makedepends="cmake libcap-dev bzip2-dev zlib-dev"
+source="http://$pkgname.org/releases/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc"
+
+build ()
+{
+ cd "$srcdir/cdrkit-$pkgver"
+ make || return 1
+ make PREFIX="$pkgdir/usr" install || return 1
+ cd "$pkgdir/usr/bin"
+ ln -s wodim cdrecord || return 1
+ ln -s readom readcd || return 1
+ ln -s genisoimage mkisofs || return 1
+ ln -s genisoimage mkhybrid || return 1
+ ln -s icedax cdda2wav || return 1
+ cd "$pkgdir/usr/share/man/man1"
+ ln -s wodim.1 cdrecord.1 || return 1
+ ln -s readom.1 readcd.1 || return 1
+ ln -s genisoimage.1 mkisofs.1 || return 1
+ ln -s genisoimage.1 mkhybrid.1 || return 1
+ ln -s icedax.1 cdda2wav.1 || return 1
+}
+md5sums="cbc0647e5d85f0e8fb3a692ba1d42edd cdrkit-1.1.9.tar.gz"
diff --git a/main/cgit/APKBUILD b/main/cgit/APKBUILD
new file mode 100644
index 00000000000..d7578539c82
--- /dev/null
+++ b/main/cgit/APKBUILD
@@ -0,0 +1,29 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cgit
+pkgver=0.8.2.1
+pkgrel=1
+_gitver=1.6.2.4
+pkgdesc="a fast webinterface for git"
+url="http://hjemli.net/git/cgit"
+license=GPL-2
+makedepends="openssl-dev zlib-dev"
+depends="uclibc openssl zlib"
+source="
+ http://hjemli.net/git/cgit/snapshot/$pkgname-$pkgver.tar.gz
+ http://www.kernel.org/pub/software/scm/git/git-$_gitver.tar.bz2
+ "
+
+build() {
+ local makeopts="NO_ICONV=YesPlease NO_CURL=YesPlease"
+ cd "$srcdir/$pkgname-$pkgver"
+ rm -rf git
+ ln -s ../git-$_gitver git
+ make $makeopts || return 1
+ make $makeopts DESTDIR="$pkgdir" \
+ CGIT_SCRIPT_PATH=/usr/share/webapps/cgit \
+ install
+ ln -s cgit.cgi "$pkgdir"/usr/share/webapps/cgit/cgit
+}
+
+md5sums="12f5468a948be40c275445253e73d309 cgit-0.8.2.1.tar.gz
+c24d796879bb09e1cc5545bf3a3d7cf6 git-1.6.2.4.tar.bz2"
diff --git a/main/chrony/APKBUILD b/main/chrony/APKBUILD
new file mode 100644
index 00000000000..21f8924a66b
--- /dev/null
+++ b/main/chrony/APKBUILD
@@ -0,0 +1,60 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=chrony
+pkgver=1.23
+pkgrel=2
+pkgdesc="NTP client and server programs"
+url="http://chrony.sunsite.dk/"
+license="GPL-2"
+depends=
+makedepends="texinfo"
+subpackages="$pkgname-doc"
+source="http://chrony.sunsite.dk/download/$pkgname-$pkgver.tar.gz
+ $pkgname-1.20-conf.c-gentoo.diff
+ $pkgname-1.20-chrony.conf.example-gentoo.diff
+ $pkgname-1.21-makefile.diff
+ $pkgname-1.23-sources.diff
+ $pkgname-1.23-reply-ip.diff
+ chronyd.confd
+ chronyd.initd
+ chrony.conf
+ "
+
+build() {
+ local i
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for i in ../*.diff; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+ sed -i "s:/etc/chrony:/etc/chrony/chrony:g" \
+ chrony*.[158] faq.txt chrony.texi || die "sed failed"
+
+ ./configure --prefix=/usr \
+ --infodir=/usr/share/info \
+ --mandir=/usr/share/man \
+ --disable-readline
+
+ make all docs || return 1
+ make DESTDIR="$pkgdir" install
+
+ mv "$pkgdir"/usr/doc "$pkgdir"/usr/share/
+ install -D -m644 examples/*.example "$pkgdir"/usr/share/doc/chrony/
+
+ install -m755 -D "$srcdir"/chronyd.initd "$pkgdir"/etc/init.d/chronyd
+ install -m644 -D "$srcdir"/chronyd.confd "$pkgdir"/etc/conf.d/chronyd
+ mkdir -p "$pkgdir"/var/lib/chrony \
+ "$pkgdir"/var/log/chrony \
+ "$pkgdir"/etc/chrony
+ touch "$pkgdir"/etc/chrony/chrony.drift
+ install -m644 "$srcdir"/chrony.conf "$pkgdir"/etc/chrony/chrony.conf
+}
+md5sums="ffce77695e55d8efda19ab0b78309c23 chrony-1.23.tar.gz
+bd6bd57363865d3ed0c3187d0c9f7151 chrony-1.20-conf.c-gentoo.diff
+b2a23e02f7af50bebdd5d18bccdedbf0 chrony-1.20-chrony.conf.example-gentoo.diff
+d47015a34b6b2f9eebca77ef939cec72 chrony-1.21-makefile.diff
+39cbce9f66638b67623e1ee6bb0f943f chrony-1.23-sources.diff
+caa6589a1a1cd56f64957e312d1ef84c chrony-1.23-reply-ip.diff
+d5c09be46226774d22c08c5a4c28093a chronyd.confd
+dac8aa4913d7c323abfa1719ddd7e5e4 chronyd.initd
+46f42c52953d398ca44d6baa449618d7 chrony.conf"
diff --git a/main/chrony/chrony-1.20-chrony.conf.example-gentoo.diff b/main/chrony/chrony-1.20-chrony.conf.example-gentoo.diff
new file mode 100644
index 00000000000..498b2417509
--- /dev/null
+++ b/main/chrony/chrony-1.20-chrony.conf.example-gentoo.diff
@@ -0,0 +1,46 @@
+--- a/examples/chrony.conf.example.orig 2003-06-16 11:59:01.000000000 -0400
++++ b/examples/chrony.conf.example 2003-06-16 12:00:13.000000000 -0400
+@@ -3,5 +3,5 @@
+ #
+ # This is an example chrony configuration file. You should copy it to
+-# /etc/chrony.conf after uncommenting and editing the options that you
++# /etc/chrony/chrony.conf after uncommenting and editing the options that you
+ # want to enable. I have not included the more obscure options. Refer
+ # to the documentation for these.
+@@ -91,5 +91,5 @@
+ # generally want this, so it is uncommented.
+
+-driftfile /etc/chrony.drift
++driftfile /etc/chrony/chrony.drift
+
+ # If you want to use the program called chronyc to configure aspects of
+@@ -100,5 +100,5 @@
+ # assumed by default.
+
+-keyfile /etc/chrony.keys
++keyfile /etc/chrony/chrony.keys
+
+ # Tell chronyd which numbered key in the file is used as the password
+@@ -158,6 +158,6 @@
+ ! log measurements statistics tracking
+
+-If you have real time clock support enabled (see below), you might want
+-this line instead:
++# If you have real time clock support enabled (see below), you might want
++# this line instead:
+
+ ! log measurements statistics tracking rtc
+@@ -269,5 +269,5 @@
+ # kernel. (Note, these options apply only to Linux.)
+
+-! rtcfile /etc/chrony.rtc
++! rtcfile /etc/chrony/chrony.rtc
+
+ # Your RTC can be set to keep Universal Coordinated Time (UTC) or local
+@@ -285,5 +285,5 @@
+ # using devfs), uncomment and edit the following line.
+
+-! rtcdevice /dev/misc/rtc
++rtcdevice /dev/misc/rtc
+
+ #######################################################################
diff --git a/main/chrony/chrony-1.20-conf.c-gentoo.diff b/main/chrony/chrony-1.20-conf.c-gentoo.diff
new file mode 100644
index 00000000000..4917d445be0
--- /dev/null
+++ b/main/chrony/chrony-1.20-conf.c-gentoo.diff
@@ -0,0 +1,11 @@
+--- a/conf.c.orig Sun May 12 14:07:31 2002
++++ b/conf.c Sun May 12 14:07:52 2002
+@@ -45,7 +45,7 @@
+
+ /* ================================================== */
+
+-#define DEFAULT_CONF_FILE "/etc/chrony.conf"
++#define DEFAULT_CONF_FILE "/etc/chrony/chrony.conf"
+
+ /* ================================================== */
+ /* Forward prototypes */
diff --git a/main/chrony/chrony-1.21-makefile.diff b/main/chrony/chrony-1.21-makefile.diff
new file mode 100644
index 00000000000..2eec4e84289
--- /dev/null
+++ b/main/chrony/chrony-1.21-makefile.diff
@@ -0,0 +1,15 @@
+--- a/Makefile.in_old 2006-08-12 17:42:57.000000000 +0200
++++ b/Makefile.in 2006-08-12 17:44:35.000000000 +0200
+@@ -68,10 +68,10 @@
+ all : chronyd chronyc
+
+ chronyd : $(OBJS) $(EXTRA_OBJS)
+- $(CC) $(OPTFLAGS) -o chronyd $(OBJS) $(EXTRA_OBJS) $(LIBS) $(EXTRA_LIBS)
++ $(CC) $(OPTFLAGS) $(LDFLAGS) -o chronyd $(OBJS) $(EXTRA_OBJS) $(LIBS) $(EXTRA_LIBS)
+
+ chronyc : $(CLI_OBJS)
+- $(CC) $(OPTFLAGS) -o chronyc $(CLI_OBJS) @READLINE_LINK@ $(LIBS) $(EXTRA_CLI_LIBS)
++ $(CC) $(OPTFLAGS) $(LDFLAGS) -o chronyc $(CLI_OBJS) @READLINE_LINK@ $(LIBS) $(EXTRA_CLI_LIBS)
+
+ client.o : client.c
+ $(CC) $(CFLAGS) $(DEFS) @READLINE_COMPILE@ -c $<
diff --git a/main/chrony/chrony-1.23-reply-ip.diff b/main/chrony/chrony-1.23-reply-ip.diff
new file mode 100644
index 00000000000..f4e5d8eff42
--- /dev/null
+++ b/main/chrony/chrony-1.23-reply-ip.diff
@@ -0,0 +1,242 @@
+
+Currently, on multihomed host, when chrony is not bound to a specific
+IP address, a query is sent to an interface and the default source IP
+hint for the back route differs, the reply will have a source IP
+different than where the query was destinied to. This will cause
+problems because connection tracking firewalls will drop the replies
+and most likely the client program will get confused too.
+
+This patch uses the IP_PKTINFO mechanism to get the IP address where
+received packets where targetted to and use that IP address as source
+hint when sending a reply.
+---
+ addressing.h | 1 +
+ broadcast.c | 1 +
+ cmdmon.c | 3 ++
+ conf.c | 1 +
+ ntp_io.c | 92 +++++++++++++++++++++++++++++++++++++++++----------------
+ 5 files changed, 72 insertions(+), 26 deletions(-)
+
+diff --git a/addressing.h b/addressing.h
+index aa20ed9..05152f4 100644
+--- a/addressing.h
++++ b/addressing.h
+@@ -36,6 +36,7 @@
+ typedef struct {
+ unsigned long ip_addr;
+ unsigned short port;
++ unsigned long local_ip_addr;
+ } NTP_Remote_Address;
+
+ #if 0
+diff --git a/broadcast.c b/broadcast.c
+index be217e7..c979741 100644
+--- a/broadcast.c
++++ b/broadcast.c
+@@ -146,6 +146,7 @@ BRD_AddDestination(unsigned long addr, unsigned short port, int interval)
+
+ destinations[n_destinations].addr.ip_addr = addr;
+ destinations[n_destinations].addr.port = port;
++ destinations[n_destinations].addr.local_ip_addr = 0;
+ destinations[n_destinations].interval = interval;
+
+ SCH_AddTimeoutInClass((double) interval, 1.0,
+diff --git a/cmdmon.c b/cmdmon.c
+index 819977c..8affb0b 100644
+--- a/cmdmon.c
++++ b/cmdmon.c
+@@ -1097,6 +1097,7 @@ handle_add_server(CMD_Request *rx_message, CMD_Reply *tx_message)
+
+ rem_addr.ip_addr = ntohl(rx_message->data.ntp_source.ip_addr);
+ rem_addr.port = (unsigned short)(ntohl(rx_message->data.ntp_source.port));
++ rem_addr.local_ip_addr = 0;
+ params.minpoll = ntohl(rx_message->data.ntp_source.minpoll);
+ params.maxpoll = ntohl(rx_message->data.ntp_source.maxpoll);
+ params.presend_minpoll = ntohl(rx_message->data.ntp_source.presend_minpoll);
+@@ -1133,6 +1134,7 @@ handle_add_peer(CMD_Request *rx_message, CMD_Reply *tx_message)
+
+ rem_addr.ip_addr = ntohl(rx_message->data.ntp_source.ip_addr);
+ rem_addr.port = (unsigned short)(ntohl(rx_message->data.ntp_source.port));
++ rem_addr.local_ip_addr = 0;
+ params.minpoll = ntohl(rx_message->data.ntp_source.minpoll);
+ params.maxpoll = ntohl(rx_message->data.ntp_source.maxpoll);
+ params.presend_minpoll = ntohl(rx_message->data.ntp_source.presend_minpoll);
+@@ -1167,6 +1169,7 @@ handle_del_source(CMD_Request *rx_message, CMD_Reply *tx_message)
+
+ rem_addr.ip_addr = ntohl(rx_message->data.del_source.ip_addr);
+ rem_addr.port = 0;
++ rem_addr.local_ip_addr = 0;
+
+ status = NSR_RemoveSource(&rem_addr);
+ switch (status) {
+diff --git a/conf.c b/conf.c
+index e34927e..ddd13f1 100644
+--- a/conf.c
++++ b/conf.c
+@@ -949,6 +949,7 @@ CNF_AddSources(void) {
+ for (i=0; i<n_ntp_sources; i++) {
+ server.ip_addr = ntp_sources[i].ip_addr;
+ server.port = ntp_sources[i].port;
++ server.local_ip_addr = 0;
+
+ switch (ntp_sources[i].type) {
+ case SERVER:
+diff --git a/ntp_io.c b/ntp_io.c
+index afb6ad1..db89758 100644
+--- a/ntp_io.c
++++ b/ntp_io.c
+@@ -118,6 +118,12 @@ NIO_Initialise(void)
+ LOG(LOGS_ERR, LOGF_NtpIO, "Could not set broadcast socket options");
+ /* Don't quit - we might survive anyway */
+ }
++ /* We want the local IP info too */
++ if (setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
++ LOG(LOGS_ERR, LOGF_NtpIO, "Could not request packet info using socket option");
++ /* Don't quit - we might survive anyway */
++ }
++
+
+ /* Bind the port */
+ my_addr.sin_family = AF_INET;
+@@ -182,22 +188,30 @@ read_from_socket(void *anything)
+
+ int status;
+ ReceiveBuffer message;
+- int message_length;
+ struct sockaddr_in where_from;
+- socklen_t from_length;
+ unsigned int flags = 0;
+ struct timeval now;
+ NTP_Remote_Address remote_addr;
+ double local_clock_err;
++ char cmsgbuf[256];
++ struct cmsghdr *cmsg;
++ struct msghdr msg;
++ struct iovec iov;
+
+ assert(initialised);
+
+- from_length = sizeof(where_from);
+- message_length = sizeof(message);
++ iov.iov_base = message.arbitrary;
++ iov.iov_len = sizeof(message);
++ msg.msg_name = &where_from;
++ msg.msg_namelen = sizeof(where_from);
++ msg.msg_iov = &iov;
++ msg.msg_iovlen = 1;
++ msg.msg_control = (void *) cmsgbuf;
++ msg.msg_controllen = sizeof(cmsgbuf);
++ msg.msg_flags = 0;
+
+ LCL_ReadCookedTime(&now, &local_clock_err);
+- status = recvfrom(sock_fd, (char *)&message, message_length, flags,
+- (struct sockaddr *)&where_from, &from_length);
++ status = recvmsg(sock_fd, &msg, flags);
+
+ /* Don't bother checking if read failed or why if it did. More
+ likely than not, it will be connection refused, resulting from a
+@@ -209,6 +223,13 @@ read_from_socket(void *anything)
+ if (status > 0) {
+ remote_addr.ip_addr = ntohl(where_from.sin_addr.s_addr);
+ remote_addr.port = ntohs(where_from.sin_port);
++ remote_addr.local_ip_addr = 0;
++
++ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
++ if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
++ remote_addr.local_ip_addr =
++ ntohl(((struct in_pktinfo *) CMSG_DATA(cmsg))->ipi_spec_dst.s_addr);
++ }
+
+ if (status == NTP_NORMAL_PACKET_SIZE) {
+
+@@ -229,21 +250,45 @@ read_from_socket(void *anything)
+ }
+
+ /* ================================================== */
+-/* Send an unauthenticated packet to a given address */
++/* Send a packet to given address */
+
+-void
+-NIO_SendNormalPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
++static void
++NIO_SendPacket(NTP_Packet *packet, int packetlen, NTP_Remote_Address *remote_addr)
+ {
+ struct sockaddr_in remote;
++ struct msghdr msg;
++ struct iovec iov;
++ struct {
++ struct cmsghdr cm;
++ struct in_pktinfo ipi;
++ } cmsg;
+
+ assert(initialised);
+
+ remote.sin_family = AF_INET;
+ remote.sin_port = htons(remote_addr->port);
+ remote.sin_addr.s_addr = htonl(remote_addr->ip_addr);
++ iov.iov_base = (void *) packet;
++ iov.iov_len = packetlen;
++ msg.msg_name = &remote;
++ msg.msg_namelen = sizeof(remote);
++ msg.msg_iov = &iov;
++ msg.msg_iovlen = 1;
++ if (remote_addr->local_ip_addr) {
++ cmsg.cm.cmsg_len = sizeof(cmsg);
++ cmsg.cm.cmsg_level = IPPROTO_IP;
++ cmsg.cm.cmsg_type = IP_PKTINFO;
++ memset(&cmsg.ipi, 0, sizeof(cmsg.ipi));
++ cmsg.ipi.ipi_spec_dst.s_addr = htonl(remote_addr->local_ip_addr);
++ msg.msg_control = (void *) &cmsg;
++ msg.msg_controllen = sizeof(cmsg);
++ } else {
++ msg.msg_control = NULL;
++ msg.msg_controllen = 0;
++ }
++ msg.msg_flags = 0;
+
+- if (sendto(sock_fd, (void *) packet, NTP_NORMAL_PACKET_SIZE, 0,
+- (struct sockaddr *) &remote, sizeof(remote)) < 0) {
++ if (sendmsg(sock_fd, &msg, 0) < 0) {
+ LOG(LOGS_WARN, LOGF_NtpIO, "Could not send to %s:%d : %s",
+ UTI_IPToDottedQuad(remote_addr->ip_addr), remote_addr->port, strerror(errno));
+ }
+@@ -252,26 +297,21 @@ NIO_SendNormalPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
+ }
+
+ /* ================================================== */
+-/* Send an authenticated packet to a given address */
++/* Send an unauthenticated packet to a given address */
+
+ void
+-NIO_SendAuthenticatedPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
++NIO_SendNormalPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
+ {
+- struct sockaddr_in remote;
+-
+- assert(initialised);
+-
+- remote.sin_family = AF_INET;
+- remote.sin_port = htons(remote_addr->port);
+- remote.sin_addr.s_addr = htonl(remote_addr->ip_addr);
++ NIO_SendPacket(packet, NTP_NORMAL_PACKET_SIZE, remote_addr);
++}
+
+- if (sendto(sock_fd, (void *) packet, sizeof(NTP_Packet), 0,
+- (struct sockaddr *) &remote, sizeof(remote)) < 0) {
+- LOG(LOGS_WARN, LOGF_NtpIO, "Could not send to %s:%d : %s",
+- UTI_IPToDottedQuad(remote_addr->ip_addr), remote_addr->port, strerror(errno));
+- }
++/* ================================================== */
++/* Send an authenticated packet to a given address */
+
+- return;
++void
++NIO_SendAuthenticatedPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
++{
++ NIO_SendPacket(packet, sizeof(NTP_Packet), remote_addr);
+ }
+
+ /* ================================================== */
+--
+1.5.6.3
+
diff --git a/main/chrony/chrony-1.23-sources.diff b/main/chrony/chrony-1.23-sources.diff
new file mode 100644
index 00000000000..5f39ca3321f
--- /dev/null
+++ b/main/chrony/chrony-1.23-sources.diff
@@ -0,0 +1,56 @@
+commit 2f2446c7dc074b2d1728a5e3f7a600c10cea2425
+Author: Goswin Brederlow <brederlo@informatik.uni-tuebingen.de>
+Date: Sat Mar 29 20:49:59 2008 +0000
+
+ Fix for chronyc "sources" command on 64 bit machines
+
+ (Taken from
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=348412
+ )
+
+ Attached is a patchlet to make the "sources" command of chrony output properly
+ signed numbers. The chronyd code (see e.g. ntp.h) properly uses int32_t and
+ friends to get the right number of bits per datatype while client.c just uses
+ short, int, long. But long will be 64 bit or 32 bit depending on the cpu.
+
+diff --git a/client.c b/client.c
+index b7e5bcb..85d6e84 100644
+--- a/client.c
++++ b/client.c
+@@ -45,6 +45,12 @@
+ #include <readline/history.h>
+ #endif
+
++#ifdef HAS_STDINT_H
++#include <stdint.h>
++#elif defined(HAS_INTTYPES_H)
++#include <inttypes.h>
++#endif
++
+ /* ================================================== */
+
+ static int sock_fd;
+@@ -1383,16 +1389,16 @@ process_cmd_sources(char *line)
+ int n_sources, i;
+ int verbose = 0;
+
+- long orig_latest_meas, latest_meas, est_offset;
+- unsigned long ip_addr;
+- unsigned long latest_meas_err, est_offset_err;
+- unsigned long latest_meas_ago;
+- unsigned short poll, stratum;
+- unsigned short state, mode;
++ int32_t orig_latest_meas, latest_meas, est_offset;
++ uint32_t ip_addr;
++ uint32_t latest_meas_err, est_offset_err;
++ uint32_t latest_meas_ago;
++ uint16_t poll, stratum;
++ uint16_t state, mode;
+ double resid_freq, resid_skew;
+ const char *dns_lookup;
+ char hostname_buf[32];
+- unsigned short status;
++ uint16_t status;
+
+ /* Check whether to output verbose headers */
+ verbose = check_for_verbose_flag(line);
diff --git a/main/chrony/chrony.conf b/main/chrony/chrony.conf
new file mode 100644
index 00000000000..d99b1e01d4f
--- /dev/null
+++ b/main/chrony/chrony.conf
@@ -0,0 +1,7 @@
+# default config
+
+server pool.ntp.org
+initstepslew 10 pool.ntp.org
+commandkey 10
+keyfile /etc/chrony/chrony.keys
+driftfile /etc/chrony/chrony.drift
diff --git a/main/chrony/chronyd.confd b/main/chrony/chronyd.confd
new file mode 100644
index 00000000000..560825c2c82
--- /dev/null
+++ b/main/chrony/chronyd.confd
@@ -0,0 +1,18 @@
+# /etc/conf.d/chronyd
+
+CFGFILE="/etc/chrony/chrony.conf"
+
+# Configuration dependant options :
+# -s - Set system time from RTC if rtcfile directive present
+# -r - Reload sample histories if dumponexit directive present
+#
+# The combination of "-s -r" allows chronyd to perform long term averaging of
+# the gain or loss rate across system reboots and shutdowns.
+
+ARGS=""
+
+# devfs creates the device for RTC if it's compiled into kernel
+test -c /dev/rtc && {
+ grep -q '^rtcfile' "${CFGFILE}" && ARGS="${ARGS} -s"
+}
+grep -q '^dumponexit$' "${CFGFILE}" && ARGS="${ARGS} -r"
diff --git a/main/chrony/chronyd.initd b/main/chrony/chronyd.initd
new file mode 100644
index 00000000000..49d7526bb58
--- /dev/null
+++ b/main/chrony/chronyd.initd
@@ -0,0 +1,58 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/chrony/files/chronyd.rc,v 1.8 2007/03/22 14:32:09 tove Exp $
+
+depend() {
+ need net
+ use dns
+}
+
+checkconfig() {
+ # Note that /etc/chrony/chrony.keys is *NOT* checked. This
+ # is because the user may have specified another key
+ # file, and we don't want to force the user to use that
+ # exact name for the key file.
+ if [ ! -f "${CFGFILE}" ] ; then
+ eerror "Please create ${CFGFILE} and the"
+ eerror "chrony key file (usually /etc/chrony/chrony.keys)"
+ eerror "by using the"
+ eerror ""
+ eerror " chrony.conf.example"
+ eerror " chrony.keys.example"
+ eerror ""
+ eerror "files (from the documentation directory)"
+ eerror "as templates."
+ return 1
+ else
+ # Actually, I tried it, and chrony seems to ignore the pidfile
+ # option. I'm going to leave it here anyway, since you never
+ # know if it might be handy
+ PIDFILE=`awk '/^ *pidfile/{print $2}' "${CFGFILE}"`
+ fi
+ return 0
+}
+
+start() {
+ checkconfig || return $?
+
+ [ -n "${PIDFILE}" ] || PIDFILE=/var/run/chronyd.pid
+
+ ebegin "Starting chronyd"
+ start-stop-daemon --start --quiet \
+ --exec /usr/sbin/chronyd \
+ --pidfile "${PIDFILE}" \
+ -- -f "${CFGFILE}" ${ARGS}
+ eend $? "Failed to start chronyd"
+}
+
+stop() {
+ checkconfig || return $?
+
+ [ -n "${PIDFILE}" ] || PIDFILE=/var/run/chronyd.pid
+
+ ebegin "Stopping chronyd"
+ start-stop-daemon --stop --quiet \
+ --pidfile "${PIDFILE}"
+ eend $? "Failed to stop chronyd"
+}
diff --git a/main/cksfv/APKBUILD b/main/cksfv/APKBUILD
new file mode 100644
index 00000000000..bf2049a167c
--- /dev/null
+++ b/main/cksfv/APKBUILD
@@ -0,0 +1,22 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=cksfv
+pkgver=1.3.13
+pkgrel=0
+pkgdesc="Simple File Verification"
+url="http://zakalwe.fi/~shd/foss/cksfv"
+license="GPL"
+depends="uclibc"
+subpackages="$pkgname-doc"
+source="http://zakalwe.fi/~shd/foss/cksfv/files/${pkgname}-${pkgver}.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr
+ make || return 1
+ install -cD src/cksfv "$pkgdir"/usr/bin/cksfv
+ install -cD cksfv.1 "$pkgdir"/usr/share/man/man1/cksfv.1
+}
+
+md5sums="a6d7e4f2dc267e670ebb48eb8b806993 cksfv-1.3.13.tar.bz2"
diff --git a/main/clamav/APKBUILD b/main/clamav/APKBUILD
new file mode 100644
index 00000000000..a4daebc2fff
--- /dev/null
+++ b/main/clamav/APKBUILD
@@ -0,0 +1,72 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=clamav
+pkgver=0.95.2
+pkgrel=0
+pkgdesc="An anti-virus toolkit for UNIX"
+url="http://www.clamav.net/"
+license="GPL"
+depends="logrotate"
+install="$pkgname.pre-install $pkgname.post-install $pkgname.pre-upgrade"
+makedepends="ncurses-dev zlib-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ clamd.initd
+ clamd.confd
+ freshclam.initd
+ freshclam.confd
+ clamav-0.95.1-nls.patch
+ clamav.logrotate
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ patch -p0 -i "$srcdir/clamav-0.95.1-nls.patch" || return 1
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/clamav \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --without-iconv
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ # Change /etc/clamd.conf to be usable out of the box
+ sed -i -e "s:^\(Example\):\# \1:" \
+ -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/clamd.pid:" \
+ -e "s:.*\(LocalSocket\) .*:\1 /var/run/clamav/clamd.sock:" \
+ -e "s:.*\(User\) .*:\1 clamav:" \
+ -e "s:^\#\(LogFile\) .*:\1 /var/log/clamav/clamd.log:" \
+ -e "s:^\#\(LogTime\).*:\1 yes:" \
+ -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
+ "$pkgdir"/etc/clamav/clamd.conf
+
+ # Do the same for /etc/freshclam.conf
+ sed -i -e "s:^\(Example\):\# \1:" \
+ -e "s:.*\(PidFile\) .*:\1 /var/run/clamav/freshclam.pid:" \
+ -e "s:.*\(DatabaseOwner\) .*:\1 clamav:" \
+ -e "s:^\#\(UpdateLogFile\) .*:\1 /var/log/clamav/freshclam.log:" \
+ -e "s:^\#\(NotifyClamd\).*:\1 /etc/clamav/clamd.conf:" \
+ -e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
+ -e "s:^\#\(AllowSupplementaryGroups\).*:\1 yes:" \
+ "$pkgdir"/etc/clamav/freshclam.conf
+
+ install -m755 -D "$srcdir"/clamd.initd "$pkgdir"/etc/init.d/clamd
+ install -m644 -D "$srcdir"/clamd.confd "$pkgdir"/etc/conf.d/clamd
+ install -m755 -D "$srcdir"/freshclam.initd "$pkgdir"/etc/init.d/freshclam
+ install -m644 -D "$srcdir"/freshclam.confd "$pkgdir"/etc/conf.d/freshclam
+ install -m644 -D "$srcdir"/clamav.logrotate "$pkgdir"/etc/logrotate.d/clamav
+ mkdir -p "$pkgdir"/var/run/clamav "$pkgdir"/var/log/clamav
+}
+
+md5sums="930362397d30e01ba81b5f24c1046d48 clamav-0.95.2.tar.gz
+adbbfa835f9dea213289719d983f1600 clamd.initd
+567bc32b657dd7031b9b7beaa946203a clamd.confd
+f43b987a0c37e6576face04a830263ac freshclam.initd
+e48466ddfb56f66c623b83e58777b778 freshclam.confd
+0d08fd29656bd4b018ecf8ce9706ac55 clamav-0.95.1-nls.patch
+dffa5af2e7a563fc00fcd52ec4c02347 clamav.logrotate
+275e05587e2da782781829a1862d57b1 clamav.pre-install
+ec4d600097a15e64dfb714e7739a1804 clamav.post-install
+c9e80578c6e82d6154bc91f18dfd23ea clamav.pre-upgrade"
diff --git a/main/clamav/clamav-0.95.1-nls.patch b/main/clamav/clamav-0.95.1-nls.patch
new file mode 100644
index 00000000000..82ae88f576d
--- /dev/null
+++ b/main/clamav/clamav-0.95.1-nls.patch
@@ -0,0 +1,11 @@
+--- shared/output.c-orig 2009-04-04 10:17:42 +0000
++++ shared/output.c 2009-04-04 10:18:30 +0000
+@@ -67,7 +67,7 @@
+ pthread_mutex_t logg_mutex = PTHREAD_MUTEX_INITIALIZER;
+ #endif
+
+-#ifdef C_LINUX
++#if defined(C_LINUX) && defined(HAVE_LIBINTL_H)
+ #include <libintl.h>
+ #include <locale.h>
+
diff --git a/main/clamav/clamav.logrotate b/main/clamav/clamav.logrotate
new file mode 100644
index 00000000000..7574428413f
--- /dev/null
+++ b/main/clamav/clamav.logrotate
@@ -0,0 +1,15 @@
+/var/log/clamav/clamd.log {
+ missingok
+ postrotate
+ /etc/init.d/clamd logfix
+ /bin/kill -HUP `cat /var/run/clamav/clamd.pid 2> /dev/null` 2>/dev/null || true
+ endscript
+}
+
+/var/log/clamav/freshclam.log {
+ missingok
+ postrotate
+ /etc/init.d/freshclam logfix
+ /bin/kill -HUP `cat /var/run/clamav/freshclam.pid 2> /dev/null` 2>/dev/null || true
+ endscript
+}
diff --git a/main/clamav/clamav.post-install b/main/clamav/clamav.post-install
new file mode 100644
index 00000000000..49302061015
--- /dev/null
+++ b/main/clamav/clamav.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+chown -R clamav:clamav /usr/share/clamav /var/run/clamav /var/log/clamav
diff --git a/main/clamav/clamav.pre-install b/main/clamav/clamav.pre-install
new file mode 100644
index 00000000000..59ac60a44dd
--- /dev/null
+++ b/main/clamav/clamav.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -s /bin/false -D clamav 2>/dev/null
+exit 0
diff --git a/main/clamav/clamav.pre-upgrade b/main/clamav/clamav.pre-upgrade
new file mode 100644
index 00000000000..9956f95d63a
--- /dev/null
+++ b/main/clamav/clamav.pre-upgrade
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# make sure we don't lose our config
+mkdir -p /etc/clamav
+if [ -f /etc/clamav.conf ]; then
+ mv /etc/clamav.conf /etc/clamav/
+ ln -s clamav/clamav.conf /etc/clamav.conf
+fi
+
+if [ -f /etc/freshclam.conf ]; then
+ mv /etc/freshclam.conf /etc/clamav/
+ ln -s clamav/freshclam.conf /etc/freshclam.conf
+fi
+
+exit 0
+
diff --git a/main/clamav/clamd.confd b/main/clamav/clamd.confd
new file mode 100644
index 00000000000..bc8072aead9
--- /dev/null
+++ b/main/clamav/clamd.confd
@@ -0,0 +1,6 @@
+
+CLAMD_NICELEVEL=0
+
+# make sure we also start freshclam
+# comment out if you dont want start freshclam
+rc_need="freshclam"
diff --git a/main/clamav/clamd.initd b/main/clamav/clamd.initd
new file mode 100644
index 00000000000..d3b9155572d
--- /dev/null
+++ b/main/clamav/clamd.initd
@@ -0,0 +1,56 @@
+#!/sbin/runscript
+
+opts="logfix reload"
+NAME=clamd
+CONF=/etc/clamav/clamd.conf
+
+depend() {
+ need net
+ provide antivirus
+}
+
+start() {
+ local clamd_socket=$(awk '$1 == "LocalSocket" { print $2 }' $CONF)
+
+ logfix
+
+ if [ -S "${clamd_socket:=/tmp/clamd}" ]; then
+ rm -f ${clamd_socket}
+ fi
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet \
+ --nicelevel ${CLAMD_NICELEVEL:-0} \
+ --exec /usr/sbin/clamd
+ eend $? "Failed to start ${NAME}"
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/clamd
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${NAME}"
+ if ! service_started "${NAME}" ; then
+ eend 1 "${NAME} is not started"
+ return 1
+ fi
+ start-stop-daemon --stop --oknodo --signal HUP \
+ --exec /usr/sbin/clamd
+ eend $?
+}
+
+logfix() {
+ # fix clamd log permissions
+ # (might be clobbered by logrotate or something)
+ local logfile=`awk '$1 == "LogFile" { print $2 }' $CONF`
+ local clamav_user=`awk '$1 == "User" { print $2 }' $CONF`
+ if [ -n "${logfile}" ] && [ -n "${clamav_user}" ]; then
+ if [ ! -f "${logfile}" ]; then
+ touch ${logfile}
+ fi
+ chown ${clamav_user} ${logfile}
+ chmod 640 ${logfile}
+ fi
+}
diff --git a/main/clamav/freshclam.confd b/main/clamav/freshclam.confd
new file mode 100644
index 00000000000..17559037dac
--- /dev/null
+++ b/main/clamav/freshclam.confd
@@ -0,0 +1,3 @@
+
+FRESHCLAM_NICELEVEL=0
+
diff --git a/main/clamav/freshclam.initd b/main/clamav/freshclam.initd
new file mode 100644
index 00000000000..7961c7f8070
--- /dev/null
+++ b/main/clamav/freshclam.initd
@@ -0,0 +1,58 @@
+#!/sbin/runscript
+
+opts="logfix reload"
+
+NAME=freshclam
+DAEMON=/usr/bin/$NAME
+CONF=/etc/clamav/freshclam.conf
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting freshclam"
+ start-stop-daemon --start --quiet \
+ --nicelevel ${FRESHCLAM_NICELEVEL:-0} \
+ --exec /usr/bin/freshclam -- -d
+ retcode=$?
+ if [ ${retcode} = 1 ]; then
+ eend 0
+ einfo "Virus databases are already up to date."
+ else
+ eend ${retcode} "Failed to start freshclam"
+ fi
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet --name ${NAME}
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${NAME}"
+ if ! service_started "${NAME}" ; then
+ eend 1 "${NAME} is not started"
+ return 1
+ fi
+ start-stop-daemon --stop --oknodo --signal HUP \
+ --exec ${DAEMON} --name $NAME
+ eend $?
+}
+
+
+logfix() {
+ # fix freshclam log permissions
+ # (might be clobbered by logrotate or something)
+ logfile=$(awk '$1 == "UpdateLogFile" { print $2 }' $CONF)
+ local freshclam_user=$(awk '$1 == "DatabaseOwner" { print $2 }' $CONF)
+ if [ -n "${logfile}" -a -n "${clamav_user}" ]; then
+ if [ ! -f "${logfile}" ]; then
+ touch ${logfile}
+ fi
+ chown ${freshclam_user} ${logfile}
+ chmod 640 ${logfile}
+ fi
+}
+
diff --git a/main/clamsmtp/0001-extra-clamsmtp-renamed-init.d-script-to-clamsmtpd.patch b/main/clamsmtp/0001-extra-clamsmtp-renamed-init.d-script-to-clamsmtpd.patch
new file mode 100644
index 00000000000..c0032bae07f
--- /dev/null
+++ b/main/clamsmtp/0001-extra-clamsmtp-renamed-init.d-script-to-clamsmtpd.patch
@@ -0,0 +1,181 @@
+From 539dfdd4b0358fa78f26c38853c36fabc65c54cd Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 17 Jul 2009 08:48:42 +0000
+Subject: [PATCH] extra/clamsmtp: renamed init.d script to clamsmtpd
+
+partly fixes #64
+---
+ extra/clamsmtp/APKBUILD | 18 +++++++++++-------
+ extra/clamsmtp/clamsmtp.confd | 5 -----
+ extra/clamsmtp/clamsmtp.initd | 22 ----------------------
+ extra/clamsmtp/clamsmtp.post-upgrade | 16 ++++++++++++++++
+ extra/clamsmtp/clamsmtp.pre-upgrade | 12 ++++++++++++
+ extra/clamsmtp/clamsmtpd.confd | 5 +++++
+ extra/clamsmtp/clamsmtpd.initd | 22 ++++++++++++++++++++++
+ 7 files changed, 66 insertions(+), 34 deletions(-)
+ delete mode 100644 extra/clamsmtp/clamsmtp.confd
+ delete mode 100644 extra/clamsmtp/clamsmtp.initd
+ create mode 100644 extra/clamsmtp/clamsmtp.post-upgrade
+ create mode 100644 extra/clamsmtp/clamsmtp.pre-upgrade
+ create mode 100644 extra/clamsmtp/clamsmtpd.confd
+ create mode 100644 extra/clamsmtp/clamsmtpd.initd
+
+diff --git a/extra/clamsmtp/APKBUILD b/extra/clamsmtp/APKBUILD
+index 5402d09..0ad433a 100644
+--- a/extra/clamsmtp/APKBUILD
++++ b/extra/clamsmtp/APKBUILD
+@@ -2,16 +2,18 @@
+ # Maintainer: Carlo Landmeter <clandmeter at gmail>
+ pkgname=clamsmtp
+ pkgver=1.10
+-pkgrel=1
++pkgrel=2
+ pkgdesc="An SMTP Virus Filter"
+ url="http://memberwebs.com/stef/software/clamsmtp/"
+ license="as-is"
+-depends="uclibc"
+-makedepends=""
++depends=
++makedepends=
++install="$pkgname.pre-upgrade $pkgname.post-upgrade"
+ subpackages="$pkgname-doc"
+ source="http://memberwebs.com/stef/software/clamsmtp/${pkgname}-${pkgver}.tar.gz
+-clamsmtp.confd
+-clamsmtp.initd"
++ clamsmtpd.confd
++ clamsmtpd.initd
++ $install"
+
+ build() {
+ cd "$srcdir/$pkgname-$pkgver"
+@@ -30,5 +32,7 @@ build() {
+ }
+
+ md5sums="b068ba6e444859782bbdd88f290c1abf clamsmtp-1.10.tar.gz
+-e84205681f64c07af9ec5b6a3dd8bc38 clamsmtp.confd
+-161baf2fb444b67d8a08fbfe4375a12c clamsmtp.initd"
++e84205681f64c07af9ec5b6a3dd8bc38 clamsmtpd.confd
++161baf2fb444b67d8a08fbfe4375a12c clamsmtpd.initd
++32e7b12f3a1f4669d080d8cfdb537e78 clamsmtp.pre-upgrade
++d9fbdc217d12cf1e85b0323f822b7e47 clamsmtp.post-upgrade"
+diff --git a/extra/clamsmtp/clamsmtp.confd b/extra/clamsmtp/clamsmtp.confd
+deleted file mode 100644
+index 8d08b68..0000000
+--- a/extra/clamsmtp/clamsmtp.confd
++++ /dev/null
+@@ -1,5 +0,0 @@
+-#
+-# Specify daemon $OPTS here.
+-#
+-
+-OPTS=""
+diff --git a/extra/clamsmtp/clamsmtp.initd b/extra/clamsmtp/clamsmtp.initd
+deleted file mode 100644
+index dbd817f..0000000
+--- a/extra/clamsmtp/clamsmtp.initd
++++ /dev/null
+@@ -1,22 +0,0 @@
+-#!/sbin/runscript
+-
+-NAME=clamsmtpd
+-DAEMON=/usr/sbin/$NAME
+-
+-depend() {
+- need net
+-}
+-
+-start() {
+- ebegin "Starting ${NAME}"
+- start-stop-daemon --start --quiet \
+- --exec ${DAEMON} -- ${OPTS}
+- eend $?
+-}
+-
+-stop() {
+- ebegin "Stopping ${NAME}"
+- start-stop-daemon --stop --quiet \
+- --exec ${DAEMON}
+- eend $?
+-}
+diff --git a/extra/clamsmtp/clamsmtp.post-upgrade b/extra/clamsmtp/clamsmtp.post-upgrade
+new file mode 100644
+index 0000000..c418ff8
+--- /dev/null
++++ b/extra/clamsmtp/clamsmtp.post-upgrade
+@@ -0,0 +1,16 @@
++#!/bin/sh
++
++moved=
++for i in /etc/runlevels/*/clamsmtp; do
++ if [ -L $i ]; then
++ mv ${i} ${i}d
++ moved=1
++ fi
++done
++
++if [ -n "$moved" ]; then
++ echo " *"
++ echo " * NOTICE: /etc/init.d/clamsmtp is renamed to /etc/init.d/clamsmtpd"
++ echo " *"
++fi
++
+diff --git a/extra/clamsmtp/clamsmtp.pre-upgrade b/extra/clamsmtp/clamsmtp.pre-upgrade
+new file mode 100644
+index 0000000..12de39f
+--- /dev/null
++++ b/extra/clamsmtp/clamsmtp.pre-upgrade
+@@ -0,0 +1,12 @@
++#!/bin/sh
++
++old=/etc/conf.d/clamsmtp
++new=/etc/conf.d/clamsmtpd
++
++if [ -f "$old" ] && [ ! -f "$new" ]; then
++ mv "$old" "$new"
++ echo " *"
++ echo " * NOTICE: $old was renamed to $new"
++ echo " *"
++fi
++
+diff --git a/extra/clamsmtp/clamsmtpd.confd b/extra/clamsmtp/clamsmtpd.confd
+new file mode 100644
+index 0000000..8d08b68
+--- /dev/null
++++ b/extra/clamsmtp/clamsmtpd.confd
+@@ -0,0 +1,5 @@
++#
++# Specify daemon $OPTS here.
++#
++
++OPTS=""
+diff --git a/extra/clamsmtp/clamsmtpd.initd b/extra/clamsmtp/clamsmtpd.initd
+new file mode 100644
+index 0000000..dbd817f
+--- /dev/null
++++ b/extra/clamsmtp/clamsmtpd.initd
+@@ -0,0 +1,22 @@
++#!/sbin/runscript
++
++NAME=clamsmtpd
++DAEMON=/usr/sbin/$NAME
++
++depend() {
++ need net
++}
++
++start() {
++ ebegin "Starting ${NAME}"
++ start-stop-daemon --start --quiet \
++ --exec ${DAEMON} -- ${OPTS}
++ eend $?
++}
++
++stop() {
++ ebegin "Stopping ${NAME}"
++ start-stop-daemon --stop --quiet \
++ --exec ${DAEMON}
++ eend $?
++}
+--
+1.6.3.3
+
diff --git a/main/clamsmtp/APKBUILD b/main/clamsmtp/APKBUILD
new file mode 100644
index 00000000000..82442549231
--- /dev/null
+++ b/main/clamsmtp/APKBUILD
@@ -0,0 +1,38 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=clamsmtp
+pkgver=1.10
+pkgrel=3
+pkgdesc="An SMTP Virus Filter"
+url="http://memberwebs.com/stef/software/clamsmtp/"
+license="as-is"
+depends=
+makedepends=
+install="$pkgname.pre-upgrade $pkgname.post-upgrade"
+subpackages="$pkgname-doc"
+source="http://memberwebs.com/stef/software/clamsmtp/${pkgname}-${pkgver}.tar.gz
+ clamsmtpd.confd
+ clamsmtpd.initd
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ install -Dm644 doc/clamsmtpd.conf "$pkgdir"/etc/clamsmtpd.conf
+ install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+md5sums="b068ba6e444859782bbdd88f290c1abf clamsmtp-1.10.tar.gz
+e84205681f64c07af9ec5b6a3dd8bc38 clamsmtpd.confd
+161baf2fb444b67d8a08fbfe4375a12c clamsmtpd.initd
+32e7b12f3a1f4669d080d8cfdb537e78 clamsmtp.pre-upgrade
+63c7360d9a0a75433bca461fe819bc49 clamsmtp.post-upgrade"
diff --git a/main/clamsmtp/clamsmtp.post-upgrade b/main/clamsmtp/clamsmtp.post-upgrade
new file mode 100644
index 00000000000..2dbccbb22aa
--- /dev/null
+++ b/main/clamsmtp/clamsmtp.post-upgrade
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+moved=
+for i in /etc/runlevels/*/clamsmtp; do
+ if [ -L $i ]; then
+ rm $i
+ ln -s /etc/init.d/clamsmtpd ${i}d
+ moved=1
+ fi
+done
+
+if [ -n "$moved" ]; then
+ echo " *"
+ echo " * NOTICE: /etc/init.d/clamsmtp is renamed to /etc/init.d/clamsmtpd"
+ echo " *"
+fi
+
diff --git a/main/clamsmtp/clamsmtp.pre-upgrade b/main/clamsmtp/clamsmtp.pre-upgrade
new file mode 100644
index 00000000000..12de39f7b15
--- /dev/null
+++ b/main/clamsmtp/clamsmtp.pre-upgrade
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+old=/etc/conf.d/clamsmtp
+new=/etc/conf.d/clamsmtpd
+
+if [ -f "$old" ] && [ ! -f "$new" ]; then
+ mv "$old" "$new"
+ echo " *"
+ echo " * NOTICE: $old was renamed to $new"
+ echo " *"
+fi
+
diff --git a/main/clamsmtp/clamsmtpd.confd b/main/clamsmtp/clamsmtpd.confd
new file mode 100644
index 00000000000..8d08b6868c5
--- /dev/null
+++ b/main/clamsmtp/clamsmtpd.confd
@@ -0,0 +1,5 @@
+#
+# Specify daemon $OPTS here.
+#
+
+OPTS=""
diff --git a/main/clamsmtp/clamsmtpd.initd b/main/clamsmtp/clamsmtpd.initd
new file mode 100644
index 00000000000..dbd817f370c
--- /dev/null
+++ b/main/clamsmtp/clamsmtpd.initd
@@ -0,0 +1,22 @@
+#!/sbin/runscript
+
+NAME=clamsmtpd
+DAEMON=/usr/sbin/$NAME
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet \
+ --exec ${DAEMON} -- ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet \
+ --exec ${DAEMON}
+ eend $?
+}
diff --git a/main/cmake/APKBUILD b/main/cmake/APKBUILD
new file mode 100644
index 00000000000..71d74182e8d
--- /dev/null
+++ b/main/cmake/APKBUILD
@@ -0,0 +1,35 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cmake
+pkgver=2.6.4
+pkgrel=0
+pkgdesc="CMake is a cross-platform open-source make system"
+url="http://www.cmake.org"
+license="CMake"
+depends="uclibc libgcc g++ ncurses"
+makedepends="ncurses-dev"
+source="http://www.$pkgname.org/files/v2.6/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc"
+
+
+parallel_opt() {
+ local i n
+ for i in $MAKEOPTS; do
+ case "$i" in
+ -j*) n=${i#-j};;
+ esac;
+ done
+ [ -n "$n" ] && echo "--parallel $n"
+}
+
+build ()
+{
+ cd $startdir/src/$pkgname-$pkgver
+ ./bootstrap --prefix=/usr \
+ --mandir=/share/man \
+ --docdir=/share/cmake-2.6/doc \
+ $(parallel_opt)
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="50f387d0436696c4a68b5512a72c9cde cmake-2.6.4.tar.gz"
diff --git a/main/conntrack-tools/APKBUILD b/main/conntrack-tools/APKBUILD
new file mode 100644
index 00000000000..96a402a2f16
--- /dev/null
+++ b/main/conntrack-tools/APKBUILD
@@ -0,0 +1,28 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=conntrack-tools
+pkgver=0.9.10
+pkgrel=0
+pkgdesc="Connection tracking userspace tools"
+url="http://conntrack-tools.netfilter.org"
+license="GPL-2"
+subpackages="$pkgname-doc"
+depends="uclibc libnfnetlink libnetfilter_conntrack"
+makedepends="pkgconfig libnfnetlink-dev libnetfilter_conntrack-dev"
+source="http://www.netfilter.org/projects/conntrack-tools/files/$pkgname-$pkgver.tar.bz2
+ conntrackd.initd
+ conntrackd.confd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ install -Dm755 ../conntrackd.initd "$pkgdir"/etc/init.d/conntrackd
+ install -Dm644 ../conntrackd.confd "$pkgdir"/etc/conf.d/conntrackd
+ install -Dm644 doc/stats/conntrackd.conf "$pkgdir"/etc/conntrackd
+}
+md5sums="cd46ed2d5cd4797add0cd444a209c1e7 conntrack-tools-0.9.10.tar.bz2
+144831a8a79561ef184b84ba94f0837b conntrackd.initd
+8ebf3838b69d20e6bb4a173844502039 conntrackd.confd"
diff --git a/main/conntrack-tools/conntrackd.confd b/main/conntrack-tools/conntrackd.confd
new file mode 100644
index 00000000000..7c937cbd9e3
--- /dev/null
+++ b/main/conntrack-tools/conntrackd.confd
@@ -0,0 +1,15 @@
+# conntrackd config file
+# default: /etc/conntrackd/conntrackd.conf
+#CONNTRACKD_CFG=/etc/conntrackd/conntrackd.conf
+
+# conntrackd lockfile (must match the "LockFile" entry
+# from the "General" section in the config file)
+# default: /var/lock/conntrack.lock
+#CONNTRACKD_LOCK=/var/lock/conntrack.lock
+
+# extra options for conntrackd
+#CONNTRACKD_OPTS="" # you must NOT use -C here!
+
+# depend on a specific network interface
+#RC_NEED="net.eth1" # baselayout-1
+#rc_need="net.eth1" # baselayout-2/OpenRC
diff --git a/main/conntrack-tools/conntrackd.initd b/main/conntrack-tools/conntrackd.initd
new file mode 100644
index 00000000000..9394badca12
--- /dev/null
+++ b/main/conntrack-tools/conntrackd.initd
@@ -0,0 +1,99 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+CONNTRACKD_BIN="/usr/sbin/conntrackd"
+CONNTRACKD_CFG=${CONNTRACKD_CFG:-/etc/conntrackd/conntrackd.conf}
+CONNTRACKD_LOCK=${CONNTRACKD_LOCK:-/var/lock/conntrack.lock}
+
+depend() {
+ use logger
+ need net
+}
+
+checkconfig() {
+ # check for netfilter conntrack kernel support
+ local nf_ct_available=0
+ for k in net.netfilter.nf_conntrack_max \
+ net.ipv4.netfilter.ip_conntrack_max \
+ net.nf_conntrack_max; do
+ if sysctl -e -n ${k} &>/dev/null; then
+ nf_ct_available=1 # sysctl key found
+ break
+ fi
+ done
+ if [ ${nf_ct_available} -eq 0 ]; then
+ eerror
+ eerror "Your kernel is missing netfilter conntrack support!"
+ eerror "Make sure your kernel was compiled with netfilter conntrack support."
+ eerror
+ eerror "If it was compiled as a module you need to ensure the module is being"
+ eerror "loaded before starting conntrackd."
+ eerror "Either add an entry to /etc/modules.autoload/[...] (for baselayout-1)"
+ eerror "or /etc/conf.d/modules (for baselayout-2/OpenRC) or load the module"
+ eerror "by hand like this, depending on your kernel version:"
+ eerror
+ eerror " modprobe nf_conntrack # (for newer kernels)"
+ eerror " modprobe ip_conntrack # (for older kernels)"
+ eerror
+ return 1
+ fi
+ # check if netfilter conntrack TCP window tracking is disabled
+ local nf_ct_tcp_be_liberal=0
+ for k in net.netfilter.nf_conntrack_tcp_be_liberal \
+ net.ipv4.netfilter.ip_conntrack_tcp_be_liberal; do
+ nf_ct_tcp_be_liberal=$(sysctl -e -n ${k} 2>/dev/null)
+ if [ ${?} -ne 0 ]; then
+ continue # sysctl key not found
+ else
+ break # sysctl key found
+ fi
+ done
+ if [ ${nf_ct_tcp_be_liberal} -ne 1 ]; then
+ eerror
+ eerror "You need to disable TCP window tracking!"
+ eerror "Add the following line to your /etc/sysctl.conf:"
+ eerror
+ eerror " ${k} = 1"
+ eerror
+ eerror "...and run this to activate the setting: sysctl -q -p"
+ eerror
+ return 1
+ fi
+ # check for config file
+ if [ ! -e "${CONNTRACKD_CFG}" ]; then
+ eerror
+ eerror "The conntrackd config file (${CONNTRACKD_CFG})"
+ eerror "is missing!"
+ eerror
+ return 1
+ fi
+ # check for leftover lockfile
+ if [ -f "${CONNTRACKD_LOCK}" ]; then
+ ewarn
+ ewarn "The conntrackd lockfile (${CONNTRACKD_LOCK})"
+ ewarn "exists although the service is not marked as started."
+ ewarn "Will remove the lockfile and start the service in 10s"
+ ewarn "if not interrupted..."
+ ewarn
+ sleep 10
+ if ! rm -f "${CONNTRACKD_LOCK}"; then
+ eerror "Failed to remove the conntrackd lockfile (${CONNTRACKD_LOCK})"
+ return 1
+ fi
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting conntrackd"
+ start-stop-daemon --start --exec "${CONNTRACKD_BIN}" \
+ -- -d -C "${CONNTRACKD_CFG}" ${CONNTRACKD_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping conntrackd"
+ start-stop-daemon --stop --exec "${CONNTRACKD_BIN}"
+ eend $?
+}
diff --git a/main/coreutils/APKBUILD b/main/coreutils/APKBUILD
new file mode 100644
index 00000000000..4f3a62cb357
--- /dev/null
+++ b/main/coreutils/APKBUILD
@@ -0,0 +1,31 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=coreutils
+pkgver=7.4
+pkgrel=0
+pkgdesc="The basic file, shell and text manipulation utilities"
+url="http://www.gnu.org/software/coreutils/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install="$pkgname.post-deinstall $pkgname.post-upgrade"
+subpackages="$pkgname-doc"
+source="http://ftp.gnu.org/gnu/coreutils/$pkgname-$pkgver.tar.gz
+ $install"
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls \
+ --without-gmp
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="c52f4f64dda9a245c38e74c09fdd86d2 coreutils-7.4.tar.gz
+b84506d253e04db3c5af9016fead45a3 coreutils.post-deinstall
+b84506d253e04db3c5af9016fead45a3 coreutils.post-upgrade"
diff --git a/main/coreutils/coreutils.post-deinstall b/main/coreutils/coreutils.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/coreutils/coreutils.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/coreutils/coreutils.post-upgrade b/main/coreutils/coreutils.post-upgrade
new file mode 120000
index 00000000000..3e2b3c2a22f
--- /dev/null
+++ b/main/coreutils/coreutils.post-upgrade
@@ -0,0 +1 @@
+coreutils.post-deinstall \ No newline at end of file
diff --git a/main/cpufreqd/APKBUILD b/main/cpufreqd/APKBUILD
new file mode 100644
index 00000000000..98d7f94cf37
--- /dev/null
+++ b/main/cpufreqd/APKBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cpufreqd
+pkgver=2.3.4
+pkgrel=1
+pkgdesc="A small daemon to adjust cpu speed (and indeed voltage)"
+url="http://sourceforge.net/projects/cpufreqd"
+license="GPL2"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="cpufrequtils sysfsutils uclibc"
+makedepends="cpufrequtils-dev sysfsutils-dev g++"
+install=
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2
+ cpufreqd.initd"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc
+ make LIBS=-lpthread || return 1
+ make DESTDIR="$pkgdir" install
+ install -Dm 755 ../cpufreqd.initd "$pkgdir"/etc/init.d/cpufreqd \
+ || return 1
+}
+md5sums="f4193f688305566a8422dd3989667668 cpufreqd-2.3.4.tar.bz2
+4c3298abc888ac4f688249ee542ce784 cpufreqd.initd"
diff --git a/main/cpufreqd/cpufreqd.initd b/main/cpufreqd/cpufreqd.initd
new file mode 100644
index 00000000000..fbacebad75c
--- /dev/null
+++ b/main/cpufreqd/cpufreqd.initd
@@ -0,0 +1,43 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/cpufreqd/files/cpufreqd-init.d,v 1.1 2007/05/17 08:51:45 phreak Exp $
+
+CONFIGFILE=/etc/cpufreqd.conf
+
+depend() {
+ need localmount
+ use logger lm_sensors
+}
+
+checkconfig() {
+ if [ ! -f ${CONFIGFILE} ]; then
+ eerror "Configuration file ${CONFIGFILE} not found"
+ return 1
+ fi
+
+ if [ ! -e /proc/cpufreq ] ; then
+ for cpu in /sys/devices/system/cpu/cpu[0-9]* ; do
+ # We need just one cpu supporting freq scaling.
+ [ -e ${cpu}/cpufreq ] && return 0
+ done
+ eerror "cpufreqd requires the kernel to be configured with CONFIG_CPU_FREQ"
+ eerror "Make sure that the appropiate drivers for your CPU are available."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting CPU Frequency Daemon"
+ start-stop-daemon --start --exec /usr/sbin/cpufreqd -- \
+ -f ${CONFIGFILE}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping CPU Frequency Daemon"
+ start-stop-daemon --stop --exec /usr/sbin/cpufreqd
+ eend ${?}
+}
diff --git a/main/cpufrequtils/APKBUILD b/main/cpufrequtils/APKBUILD
new file mode 100644
index 00000000000..50cb2d1b08d
--- /dev/null
+++ b/main/cpufrequtils/APKBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cpufrequtils
+pkgver=005
+pkgrel=0
+pkgdesc="Userspace tools for the kernel cpufreq subsystem"
+url="http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html"
+license="GPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="sysfsutils uclibc"
+makedepends="sysfsutils-dev uclibc libtool"
+source="http://www.kernel.org/pub/linux/utils/kernel/cpufreq/$pkgname-$pkgver.tar.bz2
+ cpufrequtils-005-build.patch
+ cpufrequtils-005-nls.patch
+ $pkgname.initd
+ $pkgname.confd"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ # distcc and ccache makes libtool confused about the tag.
+ # we save 4k by disabling the 2.4 kernel support (PROC=false)
+ make -j1 LIBTOOL_OPT="--tag=CC --silent" \
+ NLS=false \
+ PROC=false \
+ || return 1
+ make mandir=/usr/share/man \
+ NLS=false \
+ DESTDIR="$pkgdir" \
+ install || return 1
+ install -D -m755 ../$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -D -m644 ../$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+}
+md5sums="73a41589fe74b73fc530f4179f2c6142 cpufrequtils-005.tar.bz2
+0b007dbd9fcb3acf55a8570f21b2f5d4 cpufrequtils-005-build.patch
+d88bee4d20c8b72d8edd50c2af5d4600 cpufrequtils-005-nls.patch
+b9b80ef2f1b6c5e7ce0476037a8bce6b cpufrequtils.initd
+d47ff635eef03248c633486eaeec191d cpufrequtils.confd"
diff --git a/main/cpufrequtils/cpufrequtils-005-build.patch b/main/cpufrequtils/cpufrequtils-005-build.patch
new file mode 100644
index 00000000000..7dbe57043a3
--- /dev/null
+++ b/main/cpufrequtils/cpufrequtils-005-build.patch
@@ -0,0 +1,24 @@
+--- a/Makefile
++++ b/Makefile
+@@ -158,10 +158,10 @@ endif
+
+ # if DEBUG is enabled, then we do not strip or optimize
+ ifeq ($(strip $(DEBUG)),true)
+- CFLAGDEF += -O1 -g -DDEBUG
++ CFLAGDEF += -DDEBUG
+ STRIPCMD = /bin/true -Since_we_are_debugging
+ else
+- CFLAGDEF += $(OPTIMIZATION) -fomit-frame-pointer
++ CFLAGDEF += $(OPTIMIZATION)
+ STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
+ endif
+
+@@ -191,7 +191,7 @@ libcpufreq: libcpufreq.la
+
+ cpufreq-%: libcpufreq.la $(UTIL_OBJS)
+ $(QUIET) $(CC) $(CFLAGDEF) $(CFLAGS) -g -I. -I./lib/ -c -o utils/$@.o utils/$*.c
+- $(QUIET) $(CC) $(CFLAGDEF) $(CFLAGS) -g -I./lib/ -L. -L./.libs/ -lcpufreq -o $@ utils/$@.o
++ $(QUIET) $(CC) $(CFLAGDEF) $(CFLAGS) -g $(LDFLAGS) -I./lib/ -L. -L./.libs/ -o $@ utils/$@.o -lcpufreq
+ $(QUIET) $(STRIPCMD) $@
+
+ utils: cpufreq-info cpufreq-set
diff --git a/main/cpufrequtils/cpufrequtils-005-nls.patch b/main/cpufrequtils/cpufrequtils-005-nls.patch
new file mode 100644
index 00000000000..7a0336fff4c
--- /dev/null
+++ b/main/cpufrequtils/cpufrequtils-005-nls.patch
@@ -0,0 +1,73 @@
+make nls/gettext support optional
+
+patch by Jos van der Ende <seraph@xs4all.nl>
+
+http://bugs.gentoo.org/205576
+
+--- cpufrequtils-005/Makefile
++++ cpufrequtils-005/Makefile
+@@ -141,6 +141,7 @@
+ ifeq ($(strip $(NLS)),true)
+ INSTALL_NLS += install-gmo
+ COMPILE_NLS += update-gmo
++ CFLAGDEF += -DNLS
+ endif
+
+
+--- cpufrequtils-005/utils/info.c
++++ cpufrequtils-005/utils/info.c
+@@ -10,7 +10,6 @@
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <libintl.h>
+ #include <locale.h>
+
+ #include <getopt.h>
+@@ -18,9 +17,18 @@
+ #include "cpufreq.h"
+
+
++#ifdef NLS
++#include <libintl.h>
+ #define _(String) gettext (String)
+ #define gettext_noop(String) String
+ #define N_(String) gettext_noop (String)
++#else
++#define gettext_noop(String) String
++#define _(String) gettext_noop (String)
++#define gettext(String) gettext_noop (String)
++#define N_(String) gettext_noop (String)
++#define textdomain(String)
++#endif
+
+ #define LINE_LEN 10
+
+--- cpufrequtils-005/utils/set.c
++++ cpufrequtils-005/utils/set.c
+@@ -12,16 +12,24 @@
+ #include <limits.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include <libintl.h>
+ #include <locale.h>
+
+ #include <getopt.h>
+
+ #include "cpufreq.h"
+
++#ifdef NLS
++#include <libintl.h>
+ #define _(String) gettext (String)
+ #define gettext_noop(String) String
+ #define N_(String) gettext_noop (String)
++#else
++#define gettext_noop(String) String
++#define _(String) gettext_noop (String)
++#define gettext(String) gettext_noop (String)
++#define N_(String) gettext_noop (String)
++#define textdomain(String)
++#endif
+
+ #define NORM_FREQ_LEN 32
+
diff --git a/main/cpufrequtils/cpufrequtils.confd b/main/cpufrequtils/cpufrequtils.confd
new file mode 100644
index 00000000000..68f5b7594c6
--- /dev/null
+++ b/main/cpufrequtils/cpufrequtils.confd
@@ -0,0 +1,7 @@
+# /etc/conf.d/cpufrequtils: config file for /etc/init.d/cpufrequtils
+
+# Options when starting cpufreq (given to the `cpufreq-set` program)
+START_OPTS="--governor ondemand"
+
+# Options when stopping cpufreq (given to the `cpufreq-set` program)
+STOP_OPTS="--governor performance"
diff --git a/main/cpufrequtils/cpufrequtils.initd b/main/cpufrequtils/cpufrequtils.initd
new file mode 100644
index 00000000000..9aadd94c10b
--- /dev/null
+++ b/main/cpufrequtils/cpufrequtils.initd
@@ -0,0 +1,22 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/cpufrequtils/files/cpufrequtils-init.d-005,v 1.2 2008/10/21 21:20:59 vapier Exp $
+
+affect_change() {
+ local c ret=0
+ ebegin "Running cpufreq-set $*"
+ for c in $(cpufreq-info -o | awk '$1 == "CPU" { print $2 }') ; do
+ cpufreq-set -c ${c} $*
+ : $((ret+=$?))
+ done
+ eend ${ret}
+}
+
+start() {
+ affect_change ${START_OPTS}
+}
+
+stop() {
+ affect_change ${STOP_OPTS}
+}
diff --git a/main/cracklib-words/APKBUILD b/main/cracklib-words/APKBUILD
new file mode 100644
index 00000000000..b460439263f
--- /dev/null
+++ b/main/cracklib-words/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer:
+pkgname=cracklib-words
+pkgver=20080507
+pkgrel=0
+pkgdesc="Large list of words for crack/craclib"
+url="http://sourceforge.net/projects/cracklib"
+license="public domain"
+depends=""
+makedepends=""
+install=
+subpackages=""
+source="http://downloads.sourceforge.net/cracklib/$pkgname-$pkgver.gz"
+
+build() {
+ cd "$srcdir"
+ gunzip "$pkgname-$pkgver".gz
+ install -m644 -D "$pkgname-$pkgver" "$pkgdir"/usr/share/dict/cracklib-words
+}
+
+md5sums="7fa6ba0cd50e7f9ccaf4707c810b14f1 cracklib-words-20080507.gz"
diff --git a/main/cracklib/APKBUILD b/main/cracklib/APKBUILD
new file mode 100644
index 00000000000..e03c6a7700e
--- /dev/null
+++ b/main/cracklib/APKBUILD
@@ -0,0 +1,31 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Michael Mason <ms13sp@gmail.com>
+pkgname=cracklib
+pkgver=2.8.13
+pkgrel=0
+pkgdesc="A library used to enforce strong passwords"
+url="http://sourceforge.net/projects/cracklib"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages="$pkgname-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ "
+build() {
+
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --without-python \
+ --disable-nls \
+ --with-default-dict
+ make -j1 all || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+}
+
+md5sums="5beb4c6b3c31c83fc98c4c225b25cd94 cracklib-2.8.13.tar.gz"
diff --git a/main/ctags/APKBUILD b/main/ctags/APKBUILD
new file mode 100644
index 00000000000..0d45e287c33
--- /dev/null
+++ b/main/ctags/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=ctags
+pkgver=5.7
+pkgrel=0
+pkgdesc="Generator of tags for all types of C/C++ languages"
+url="http://ctags.sourceforge.net/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages=""
+source="http://prdownloads.sourceforge.net/ctags/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+
+ install -m755 -D $pkgname "$pkgdir"/usr/bin/$pkgname
+}
+
+md5sums="643cab63b39c8a24377dc4c781547d40 ctags-5.7.tar.gz"
diff --git a/main/cutter/APKBUILD b/main/cutter/APKBUILD
new file mode 100644
index 00000000000..be27d880c7d
--- /dev/null
+++ b/main/cutter/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Michael Mason <ms13sp@gmail.com>
+pkgname=cutter
+pkgver=1.03
+pkgrel=1
+pkgdesc="A program that allows firewall administrators to abort TCP/IP connections."
+url="http://www.lowth.com/cutter"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages=""
+source="http://www.lowth.com/cutter/software/$pkgname-$pkgver.tgz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ #no make install and no configure script
+
+ make || return 1
+
+ mkdir -p "$pkgdir"/usr/sbin/
+
+ install -m755 -D cutter "$pkgdir"/usr/sbin/cutter
+
+}
+
+md5sums="50093db9b64277643969ee75b83ebbd1 cutter-1.03.tgz"
diff --git a/main/cvs/APKBUILD b/main/cvs/APKBUILD
new file mode 100644
index 00000000000..bcfcea6f248
--- /dev/null
+++ b/main/cvs/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer:
+pkgname=cvs
+pkgver=1.11.23
+pkgrel=0
+pkgdesc="Concurrent Versions System"
+url="http://www.nongnu.org/cvs/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages="$pkgname-doc"
+source="http://ftp.gnu.org/non-gnu/cvs/source/stable/1.11.23/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="bf185eb51b5918330a04671c3f3cccde cvs-1.11.23.tar.gz"
diff --git a/main/cyrus-sasl/APKBUILD b/main/cyrus-sasl/APKBUILD
new file mode 100644
index 00000000000..4e9075769af
--- /dev/null
+++ b/main/cyrus-sasl/APKBUILD
@@ -0,0 +1,55 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cyrus-sasl
+pkgver=2.1.23
+pkgrel=0
+pkgdesc="Cyrus Simple Authentication Service Layer (SASL)"
+url="http://cyrusimap.web.cmu.edu/downloads.html#sasl"
+license="custom"
+subpackages="$pkgname-dev $pkgname-doc libsasl"
+depends="db openssl uclibc libsasl"
+makedepends="db-dev openssl-dev"
+#install=libsasl.install
+source="ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/$pkgname-$pkgver.tar.gz
+ saslauthd.initd
+ cyrus-sasl-2.1.19-checkpw.c.patch
+ db-4.7.patch"
+
+build ()
+{
+ cd "$srcdir"/cyrus-sasl-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p0 -i $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --disable-anon \
+ --disable-cram \
+ --disable-digest \
+ --disable-gssapi \
+ --enable-login \
+ --disable-otp \
+ --enable-plain \
+ --with-devrandom=/dev/urandom \
+ --mandir=/usr/share/man
+
+ make -j1 || return 1
+ make -j1 DESTDIR="$pkgdir" install || return 1
+ install -D -m644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+
+ install -Dm755 ../saslauthd.initd "$pkgdir"/etc/init.d/saslauthd
+}
+
+libsasl() {
+ depends="uclibc db"
+ pkgdesc="Cyrus Simple Authentication and Security Layer (SASL) library"
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
+}
+
+md5sums="2eb0e48106f0e9cd8001e654f267ecbc cyrus-sasl-2.1.23.tar.gz
+9045c1b9c79a6ae0727b31e602d098ad saslauthd.initd
+e27ddff076342e7a3041c4759817d04b cyrus-sasl-2.1.19-checkpw.c.patch
+71a3b7454f4d7cc2966b347bdf03f2fc db-4.7.patch"
diff --git a/main/cyrus-sasl/cyrus-sasl-2.1.19-checkpw.c.patch b/main/cyrus-sasl/cyrus-sasl-2.1.19-checkpw.c.patch
new file mode 100644
index 00000000000..f7bf44b7941
--- /dev/null
+++ b/main/cyrus-sasl/cyrus-sasl-2.1.19-checkpw.c.patch
@@ -0,0 +1,170 @@
+diff -ur ../cyrus-sasl-2.1.19.orig/lib/Makefile.in ./lib/Makefile.in
+--- ../cyrus-sasl-2.1.19.orig/lib/Makefile.in 2004-07-02 21:40:15.000000000 +0200
++++ ./lib/Makefile.in 2004-09-07 13:21:22.746680576 +0200
+@@ -120,7 +120,7 @@
+ JAVA_TRUE = @JAVA_TRUE@
+ LDFLAGS = @LDFLAGS@
+ LIBOBJS = @LIBOBJS@
+-LIBS = @LIBS@
++LIBS = -lcrypt @LIBS@
+ LIBTOOL = @LIBTOOL@
+ LIB_CRYPT = @LIB_CRYPT@
+ LIB_DES = @LIB_DES@
+diff -ur ../cyrus-sasl-2.1.19.orig/lib/checkpw.c ./lib/checkpw.c
+--- ../cyrus-sasl-2.1.19.orig/lib/checkpw.c 2004-03-17 14:58:13.000000000 +0100
++++ ./lib/checkpw.c 2004-09-07 13:21:12.645916147 +0200
+@@ -94,6 +94,23 @@
+ # endif
+ #endif
+
++/******************************
++ * crypt(3) patch start *
++ ******************************/
++char *crypt(const char *key, const char *salt);
++
++/* cleartext password formats */
++#define PASSWORD_FORMAT_CLEARTEXT 1
++#define PASSWORD_FORMAT_CRYPT 2
++#define PASSWORD_FORMAT_CRYPTTRAD 3
++#define PASSWORD_SALT_BUF_LEN 22
++
++/* weeds out crypt(3) password's salt */
++int _sasl_get_salt (char *dest, char *src, int format);
++
++/******************************
++ * crypt(3) patch stop *
++ ******************************/
+
+ /* we store the following secret to check plaintext passwords:
+ *
+@@ -143,7 +160,51 @@
+ "*cmusaslsecretPLAIN",
+ NULL };
+ struct propval auxprop_values[3];
+-
++
++ /******************************
++ * crypt(3) patch start *
++ * for password format check *
++ ******************************/
++ sasl_getopt_t *getopt;
++ void *context;
++ const char *p = NULL;
++ /**
++ * MD5: 12 char salt
++ * BLOWFISH: 16 char salt
++ */
++ char salt[PASSWORD_SALT_BUF_LEN];
++ int password_format;
++
++ /* get password format from auxprop configuration */
++ if (_sasl_getcallback(conn, SASL_CB_GETOPT, &getopt, &context) == SASL_OK) {
++ getopt(context, NULL, "password_format", &p, NULL);
++ }
++
++ /* set password format */
++ if (p) {
++ /*
++ memset(pass_format_str, '\0', PASSWORD_FORMAT_STR_LEN);
++ strncpy(pass_format_str, p, (PASSWORD_FORMAT_STR_LEN - 1));
++ */
++ /* modern, modular crypt(3) */
++ if (strncmp(p, "crypt", 11) == 0)
++ password_format = PASSWORD_FORMAT_CRYPT;
++ /* traditional crypt(3) */
++ else if (strncmp(p, "crypt_trad", 11) == 0)
++ password_format = PASSWORD_FORMAT_CRYPTTRAD;
++ /* cleartext password */
++ else
++ password_format = PASSWORD_FORMAT_CLEARTEXT;
++ } else {
++ /* cleartext password */
++ password_format = PASSWORD_FORMAT_CLEARTEXT;
++ }
++
++ /******************************
++ * crypt(3) patch stop *
++ * for password format check *
++ ******************************/
++
+ if (!conn || !userstr)
+ return SASL_BADPARAM;
+
+@@ -180,14 +241,31 @@
+ goto done;
+ }
+
+- /* At the point this has been called, the username has been canonified
+- * and we've done the auxprop lookup. This should be easy. */
+- if(auxprop_values[0].name
+- && auxprop_values[0].values
+- && auxprop_values[0].values[0]
+- && !strcmp(auxprop_values[0].values[0], passwd)) {
+- /* We have a plaintext version and it matched! */
+- return SASL_OK;
++
++ /******************************
++ * crypt(3) patch start *
++ ******************************/
++
++ /* get salt */
++ _sasl_get_salt(salt, (char *) auxprop_values[0].values[0], password_format);
++
++ /* crypt(3)-ed password? */
++ if (password_format != PASSWORD_FORMAT_CLEARTEXT) {
++ /* compare password */
++ if (auxprop_values[0].name && auxprop_values[0].values && auxprop_values[0].values[0] && strcmp(crypt(passwd, salt), auxprop_values[0].values[0]) == 0)
++ return SASL_OK;
++ else
++ ret = SASL_BADAUTH;
++ }
++ else if (password_format == PASSWORD_FORMAT_CLEARTEXT) {
++ /* compare passwords */
++ if (auxprop_values[0].name && auxprop_values[0].values && auxprop_values[0].values[0] && strcmp(auxprop_values[0].values[0], passwd) == 0)
++ return SASL_OK;
++ else
++ ret = SASL_BADAUTH;
++ /******************************
++ * crypt(3) patch stop *
++ ******************************/
+ } else if(auxprop_values[1].name
+ && auxprop_values[1].values
+ && auxprop_values[1].values[0]) {
+@@ -975,3 +1053,37 @@
+ #endif
+ { NULL, NULL }
+ };
++
++/* weeds out crypt(3) password's salt */
++int _sasl_get_salt (char *dest, char *src, int format) {
++ int num; /* how many characters is salt long? */
++ switch (format) {
++ case PASSWORD_FORMAT_CRYPT:
++ /* md5 crypt */
++ if (src[1] == '1')
++ num = 12;
++ /* blowfish crypt */
++ else if (src[1] == '2')
++ num = (src[1] == '2' && src[2] == 'a') ? 17 : 16;
++ /* traditional crypt */
++ else
++ num = 2;
++ break;
++
++ case PASSWORD_FORMAT_CRYPTTRAD:
++ num = 2;
++ break;
++
++ default:
++ return 1;
++ }
++
++ /* destroy destination */
++ memset(dest, '\0', (num + 1));
++
++ /* copy salt to destination */
++ strncpy(dest, src, num);
++
++ return 1;
++}
++
diff --git a/main/cyrus-sasl/db-4.7.patch b/main/cyrus-sasl/db-4.7.patch
new file mode 100644
index 00000000000..8937d7633d9
--- /dev/null
+++ b/main/cyrus-sasl/db-4.7.patch
@@ -0,0 +1,20 @@
+--- configure 2006-05-18 21:30:13.000000000 +0200
++++ configure.new 2007-09-29 00:22:42.000000000 +0200
+@@ -5125,7 +5125,7 @@
+ fi
+
+ saved_LIBS=$LIBS
+- for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
++ for dbname in db-4.7 db4.7 db47 db-4.54 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
+ do
+ LIBS="$saved_LIBS -l$dbname"
+ cat >conftest.$ac_ext <<_ACEOF
+@@ -5882,7 +5882,7 @@
+ fi
+
+ saved_LIBS=$LIBS
+- for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
++ for dbname in db-4.7 db4.7 db47 db-4.54 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
+ do
+ LIBS="$saved_LIBS -l$dbname"
+ cat >conftest.$ac_ext <<_ACEOF
diff --git a/main/cyrus-sasl/saslauthd.initd b/main/cyrus-sasl/saslauthd.initd
new file mode 100644
index 00000000000..a5e9a440616
--- /dev/null
+++ b/main/cyrus-sasl/saslauthd.initd
@@ -0,0 +1,21 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/cyrus-sasl/files/saslauthd2.rc6,v 1.7 2007/04/07 13:03:55 chtekk Exp $
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting saslauthd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/saslauthd \
+ -- ${SASLAUTHD_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping saslauthd"
+ start-stop-daemon --stop --quiet --pidfile /var/lib/sasl2/saslauthd.pid
+ eend $?
+}
diff --git a/main/dahdi-linux-grsec/APKBUILD b/main/dahdi-linux-grsec/APKBUILD
new file mode 100644
index 00000000000..6aa684043ca
--- /dev/null
+++ b/main/dahdi-linux-grsec/APKBUILD
@@ -0,0 +1,57 @@
+# Contributor: Timo Teras <timo.teras@iki.fi>
+# Maintainer: Timo Teras <timo.teras@iki.fi>
+
+_flavor=grsec
+
+# source the kernel version
+if [ -f ../../core/linux-${_flavor}/APKBUILD ]; then
+ . ../../core/linux-${_flavor}/APKBUILD
+fi
+
+_abi_release=${pkgver:-2.6.29.5}-${_flavor}
+_realname=dahdi-linux
+
+pkgname=${_realname}-${_flavor}
+pkgver=2.2.0
+pkgrel=3
+pkgdesc="Digium Asterisk Hardware Device Interface drivers"
+url="http://www.asterisk.org"
+license="GPL"
+depends="dahdi-linux"
+# we need wget and tar because make install downloads firmware and uses fancy
+# options for tar and wget.
+makedepends="linux-${_flavor}-dev wget tar perl"
+install=
+subpackages=
+source="http://downloads.digium.com/pub/telephony/dahdi-linux/releases/${_realname}-$pkgver.tar.gz
+ dahdi-depmod.patch
+ dahdi-bri_dchan.patch
+ dahdi-zaphfc.patch
+ zaphfc-dahdi-flortz.diff
+ dahdi-linux-2.2.0-hfc-4s.patch
+ "
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+ for i in ../*.patch ../*.diff; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1;
+ done
+
+ make KVERS="${_abi_release}" DYNFS="yes" MODULES_EXTRA="zaphfc" \
+ || return 1
+ make KVERS="${_abi_release}" DYNFS="yes" MODULES_EXTRA="zaphfc" \
+ DESTDIR="$pkgdir" install
+}
+
+# since we sourced the APKBUILD above we got the dev() function there to
+# so we override it again.
+dev() {
+ default_dev
+}
+md5sums="a6b1a24a436e1c1fd08b99d27cfe3f38 dahdi-linux-2.2.0.tar.gz
+c78fb8d80f9efdffd950297c88ff9273 dahdi-depmod.patch
+4b41a82ff390ac64c08092c5a3eab6a8 dahdi-bri_dchan.patch
+a822c092f0548cd13f5e8d8cba053af6 dahdi-zaphfc.patch
+291c5c44c86ab02443a742415461ddca zaphfc-dahdi-flortz.diff
+68dfe17a49cca15ae439fd83f4ccfbc5 dahdi-linux-2.2.0-hfc-4s.patch"
diff --git a/main/dahdi-linux-grsec/dahdi-bri_dchan.patch b/main/dahdi-linux-grsec/dahdi-bri_dchan.patch
new file mode 100644
index 00000000000..d7a3fe859b0
--- /dev/null
+++ b/main/dahdi-linux-grsec/dahdi-bri_dchan.patch
@@ -0,0 +1,161 @@
+# Translate the D channels to a standard channel data.
+# The HFC chipset provides us the D channel as data, but
+# Zaptel expects it as a standard channel with 1000 samples
+# per second.
+
+--- a/include/dahdi/kernel.h
++++ b/include/dahdi/kernel.h
+@@ -132,6 +132,13 @@ struct dahdi_chan {
+ int do_ppp_error;
+ struct sk_buff_head ppp_rq;
+ #endif
++#ifdef CONFIG_DAHDI_BRI_DCHANS
++ int bytes2receive;
++ int maxbytes2transmit; /* size of the tx buffer in the card driver */
++ int bytes2transmit;
++ int eofrx;
++ int eoftx;
++#endif
+ spinlock_t lock;
+ char name[40];
+ /* Specified by DAHDI */
+@@ -462,6 +469,9 @@ enum {
+ DAHDI_FLAGBIT_LOOPED = 18, /*!< Loopback the receive data from the channel to the transmit */
+ DAHDI_FLAGBIT_MTP2 = 19, /*!< Repeats last message in buffer and also discards repeating messages sent to us */
+ DAHDI_FLAGBIT_HDLC56 = 20, /*!< Sets the given channel (if in HDLC mode) to use 56K HDLC instead of 64K */
++#if defined(CONFIG_DAHDI_BRI_DCHANS)
++ DAHDI_FLAGBIT_BRIDCHAN = 21, /*!< hardhdlc-like handling of the D channel */
++#endif
+ };
+
+ /* map flagbits to flag masks */
+@@ -500,6 +510,7 @@ enum {
+ #define DAHDI_FLAG_LOOPED DAHDI_FLAG(LOOPED)
+ #define DAHDI_FLAG_MTP2 DAHDI_FLAG(MTP2)
+ #define DAHDI_FLAG_HDLC56 DAHDI_FLAG(HDLC56)
++#define DAHDI_FLAG_BRIDCHAN DAHDI_FLAG(BRIDCHAN)
+
+ struct dahdi_span {
+ spinlock_t lock;
+--- a/include/dahdi/dahdi_config.h
++++ b/include/dahdi/dahdi_config.h
+@@ -174,4 +174,10 @@
+ */
+ /* #define OPTIMIZE_CHANMUTE */
+
++/*
++ * Uncomment the following for BRI D channels
++ *
++ */
++#define CONFIG_DAHDI_BRI_DCHANS
++
+ #endif
+--- a/drivers/dahdi/dahdi-base.c
++++ b/drivers/dahdi/dahdi-base.c
+@@ -5907,11 +5907,40 @@ static inline void __dahdi_getbuf_chunk(
+ *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
+ }
+ bytes -= left;
++#ifdef CONFIG_DAHDI_BRI_DCHANS
++ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
++ /*
++ * Let's get this right, we want to transmit complete frames only.
++ * The card driver will do the dirty HDLC work for us.
++ * txb (transmit buffer) is supposed to be big enough to store one frame
++ * we will make this as big as the D fifo (1KB or 2KB)
++ */
++
++ /* there are 'left' bytes in the user buffer left to transmit */
++ left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
++ if (left > ms->maxbytes2transmit) {
++ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
++ ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
++ txb += ms->maxbytes2transmit;
++ ms->bytes2transmit = ms->maxbytes2transmit;
++ ms->eoftx = 0;
++ } else {
++ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
++ ms->writeidx[ms->outwritebuf] += left + 2;
++ txb += left + 2;
++ ms->bytes2transmit = left;
++ ms->eoftx = 1;
++ }
++ bytes = 0;
++#endif
+ } else {
+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
+ ms->writeidx[ms->outwritebuf]+=left;
+ txb += left;
+ bytes -= left;
++#if defined(CONFIG_DAHDI_BRI_DCHANS)
++ ms->bytes2transmit=DAHDI_CHUNKSIZE;
++#endif
+ }
+ /* Check buffer status */
+ if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
+@@ -5968,6 +5997,17 @@ out in the later versions, and is put ba
+ /* Transmit a flag if this is an HDLC channel */
+ if (ms->flags & DAHDI_FLAG_HDLC)
+ fasthdlc_tx_frame_nocheck(&ms->txhdlc);
++#if defined(CONFIG_DAHDI_BRI_DCHANS)
++ if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
++ // if (ms->bytes2transmit > 0) {
++ // txb += 2;
++ // ms->bytes2transmit -= 2;
++ bytes=0;
++ ms->eoftx = 1;
++// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
++ // }
++ }
++#endif
+ #ifdef CONFIG_DAHDI_NET
+ if (ms->flags & DAHDI_FLAG_NETDEV)
+ netif_wake_queue(ztchan_to_dev(ms));
+@@ -6028,6 +6068,12 @@ out in the later versions, and is put ba
+ memset(txb, 0xFF, bytes);
+ }
+ bytes = 0;
++#if defined(CONFIG_DAHDI_BRI_DCHANS)
++ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
++ ms->bytes2transmit = 0;
++ ms->eoftx = 0;
++ bytes = 0;
++#endif
+ } else {
+ memset(txb, DAHDI_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
+ bytes = 0;
+@@ -6840,6 +6886,14 @@ static inline void __putbuf_chunk(struct
+ int res;
+ int left, x;
+
++#if defined(CONFIG_DAHDI_BRI_DCHANS)
++ if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
++ bytes = ms->bytes2receive;
++ if (bytes < 1) return;
++// printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
++ }
++#endif
++
+ while(bytes) {
+ #if defined(CONFIG_DAHDI_NET) || defined(CONFIG_DAHDI_PPP)
+ skb = NULL;
+@@ -6897,6 +6951,19 @@ static inline void __putbuf_chunk(struct
+ }
+ }
+ }
++#ifdef CONFIG_DAHDI_BRI_DCHANS
++ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
++ memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
++ rxb += left;
++ ms->readidx[ms->inreadbuf] += left;
++ bytes -= left;
++ if (ms->eofrx == 1) {
++ eof=1;
++ }
++// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
++ ms->bytes2receive = 0;
++ ms->eofrx = 0;
++#endif
+ } else {
+ /* Not HDLC */
+ memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
diff --git a/main/dahdi-linux-grsec/dahdi-depmod.patch b/main/dahdi-linux-grsec/dahdi-depmod.patch
new file mode 100644
index 00000000000..289aad403b3
--- /dev/null
+++ b/main/dahdi-linux-grsec/dahdi-depmod.patch
@@ -0,0 +1,22 @@
+Index: dahdi-linux-2.0.0-rc4/Makefile
+===================================================================
+--- dahdi-linux-2.0.0-rc4.orig/Makefile 2008-09-09 14:07:23.000000000 +0300
++++ dahdi-linux-2.0.0-rc4/Makefile 2008-09-09 14:12:31.000000000 +0300
+@@ -190,7 +190,7 @@
+ build_tools/uninstall-modules dahdi $(KVERS)
+ endif
+ $(KMAKE) INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=dahdi modules_install
+- [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
++ [ -z "$(DESTDIR)" -a `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
+
+ uninstall-modules:
+ ifdef DESTDIR
+@@ -203,7 +203,7 @@
+ rm -rf /lib/modules/$(KVERS)/dahdi; \
+ echo "done."; \
+ fi
+- [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
++ [ -z "$(DESTDIR)" -a `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
+ endif
+
+ update:
diff --git a/main/dahdi-linux-grsec/dahdi-linux-2.2.0-hfc-4s.patch b/main/dahdi-linux-grsec/dahdi-linux-2.2.0-hfc-4s.patch
new file mode 100644
index 00000000000..67857e2f7d4
--- /dev/null
+++ b/main/dahdi-linux-grsec/dahdi-linux-2.2.0-hfc-4s.patch
@@ -0,0 +1,553 @@
+--- a/drivers/dahdi/wcb4xxp/base.c 2009-06-24 13:17:03.000000000 +0000
++++ b/drivers/dahdi/wcb4xxp/base.c 2009-06-24 13:40:15.000000000 +0000
+@@ -75,7 +75,7 @@
+ #define DBG_SPANFILTER ((1 << bspan->port) & spanfilter)
+
+ static int debug = 0;
+-static int spanfilter = 15;
++static int spanfilter = 255; /* Bitmap .. 1, 2, 4, 8, 16, 32, 64, 128 for ports 1-8 */
+ #ifdef LOOPBACK_SUPPORTED
+ static int loopback = 0;
+ #endif
+@@ -114,9 +114,21 @@
+ struct devtype {
+ char *desc;
+ unsigned int flags;
++ int ports; /* Number of ports the card has */
++ int has_ec; /* Does the card have an Echo Canceller */
++ enum cards_ids card_type; /* Card type - Digium B410P, ... */
+ };
+
+-static struct devtype wcb4xxp = { "Wildcard B410P", 0 };
++static struct devtype wcb4xxp = { "Wildcard B410P", .ports = 4, .has_ec = 1, .card_type = B410P };
++static struct devtype hfc2s = { "HFC-2S Junghanns.NET duoBRI PCI", .ports = 2, .has_ec = 0, .card_type = DUOBRI };
++static struct devtype hfc4s = { "HFC-4S Junghanns.NET quadBRI PCI", .ports = 4, .has_ec = 0, .card_type = QUADBRI };
++static struct devtype hfc8s = { "HFC-4S Junghanns.NET octoBRI PCI", .ports = 8, .has_ec = 0, .card_type = OCTOBRI };
++static struct devtype hfc2s_OV ={ "OpenVox B200P", .ports = 2, .has_ec = 0, .card_type = B200P_OV };
++static struct devtype hfc4s_OV ={ "OpenVox B400P", .ports = 4, .has_ec = 0, .card_type = B400P_OV };
++static struct devtype hfc8s_OV ={ "OpenVox B800P", .ports = 8, .has_ec = 0, .card_type = B800P_OV };
++static struct devtype hfc2s_BN ={ "BeroNet BN2S0", .ports = 2, .has_ec = 0, .card_type = BN2S0 };
++static struct devtype hfc4s_BN ={ "BeroNet BN4S0", .ports = 4, .has_ec = 0, .card_type = BN4S0 };
++static struct devtype hfc8s_BN ={ "BeroNet BN8S0", .ports = 8, .has_ec = 0, .card_type = BN8S0 };
+
+ static int echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
+ struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec);
+@@ -403,7 +415,14 @@
+
+ mb();
+
+- b4xxp_setreg8(b4, R_GPIO_SEL, 0xf0); /* GPIO0..7 S/T, 8..15 GPIO */
++ if ((b4->card_type == OCTOBRI) || (b4->card_type == B800P_OV) || (b4->card_type == BN8S0))
++ {
++ b4xxp_setreg8(b4, R_GPIO_SEL, 0x00); /* GPIO0..15 S/T - HFC-8S uses GPIO8-15 for S/T ports 5-8 */
++ }
++ else
++ {
++ b4xxp_setreg8(b4, R_GPIO_SEL, 0xf0); /* GPIO0..7 S/T, 8..15 GPIO */
++ }
+
+ mb();
+
+@@ -618,13 +637,16 @@
+ unsigned char b;
+ unsigned int i, j, mask;
+
++ if (! b4->has_ec) /* Avoid Echo Cancelling for non hardware echo canceller cards */
++ return;
++
+ /* Setup GPIO */
+ for (i=0; i < NUM_EC; i++) {
+ b = ec_read(b4, i, 0x1a0);
+
+ dev_info(b4->dev, "VPM %d/%d init: chip ver %02x\n", i, NUM_EC - 1, b);
+
+- for (j=0; j < 4; j++) {
++ for (j=0; j < b4->numspans; j++) {
+ ec_write(b4, i, 0x1a8 + j, 0x00); /* GPIO out */
+ ec_write(b4, i, 0x1ac + j, 0x00); /* GPIO dir */
+ ec_write(b4, i, 0x1b0 + j, 0x00); /* GPIO sel */
+@@ -1008,7 +1030,15 @@
+ int fifo, hfc_chan;
+ unsigned long irq_flags;
+
+- fifo = port + 8;
++ if ((b4->card_type == B800P_OV) || (b4->card_type == OCTOBRI) || (b4->card_type == BN8S0))
++ {
++ fifo = port + 16; /* In HFC-8S cards we can't use ports 8-11 for dchan FIFOs */
++ }
++ else
++ {
++ fifo = port + 8;
++ }
++
+ hfc_chan = (port * 4) + 2;
+
+ /* record the host's FIFO # in the span fifo array */
+@@ -1210,7 +1240,7 @@
+ int i, j;
+ struct b4xxp_span *s;
+
+- for (i=0; i < 4; i++) {
++ for (i=0; i < b4->numspans; i++) {
+ s = &b4->spans[i];
+
+ for (j=HFC_T1; j <= HFC_T3; j++) {
+@@ -1413,12 +1443,21 @@
+
+ gpio = b4xxp_getreg8(b4, R_GPI_IN3);
+
+- for (i=0; i < 4; i++) {
++ for (i=0; i < b4->numspans; i++) {
+ s = &b4->spans[i];
+ s->parent = b4;
+ s->port = i;
+
+- nt = ((gpio & (1 << (i + 4))) == 0); /* GPIO=0 = NT mode */
++ /* The way the Digium B410P card reads the NT/TE mode
++ * jumper is the oposite of how other HFC-4S cards do:
++ * - In B410P: GPIO=0: NT
++ * - In Junghanns: GPIO=0: TE
++ */
++ if (b4->card_type == B410P)
++ nt = ((gpio & (1 << (i + 4))) == 0);
++ else
++ nt = ((gpio & (1 << (i + 4))) != 0);
++
+ s->te_mode = !nt;
+
+ dev_info(b4->dev, "Port %d: %s mode\n", i + 1, (nt ? "NT" : "TE"));
+@@ -1774,9 +1813,15 @@
+
+ /*
+ * set up the clock controller
+- * we have a 24.576MHz crystal, so the PCM clock is 2x the incoming clock.
++ * B410P has a 24.576MHz crystal, so the PCM clock is 2x the incoming clock.
++ * Other cards have a 49.152Mhz crystal, so the PCM clock equals incoming clock.
+ */
+- b4xxp_setreg8(b4, R_BRG_PCM_CFG, 0x02);
++
++ if (b4->card_type == B410P)
++ b4xxp_setreg8(b4, R_BRG_PCM_CFG,0x02);
++ else
++ b4xxp_setreg8(b4, R_BRG_PCM_CFG, V_PCM_CLK);
++
+ flush_pci();
+
+ udelay(100); /* wait a bit for clock to settle */
+@@ -1807,7 +1852,7 @@
+
+ /*
+ * set up the flow controller.
+- * B channel map:
++ * B channel map: (4 ports cards with Hardware Echo Cancel present & active)
+ * FIFO 0 connects Port 1 B0 using HFC channel 16 and PCM timeslots 0/1.
+ * FIFO 1 connects Port 1 B1 using HFC channel 17 and PCM timeslots 4/5.
+ * FIFO 2 connects Port 2 B0 using HFC channel 20 and PCM timeslots 8/9.
+@@ -1822,14 +1867,35 @@
+ *
+ * D channels are handled by FIFOs 8-11.
+ * FIFO 8 connects Port 1 D using HFC channel 3
+- * FIFO 9 connects Port 1 D using HFC channel 7
+- * FIFO 10 connects Port 1 D using HFC channel 11
+- * FIFO 11 connects Port 1 D using HFC channel 15
++ * FIFO 9 connects Port 2 D using HFC channel 7
++ * FIFO 10 connects Port 3 D using HFC channel 11
++ * FIFO 11 connects Port 4 D using HFC channel 15
++ *
++ * D channel FIFOs are operated in HDLC mode and interrupt on end of frame.
++ *
++ * B channel map: (8 ports cards without Hardware Echo Cancel)
++ * FIFO 0 connects Port 1 B0 using HFC channel 0
++ * FIFO 1 connects Port 1 B1 using HFC channel 1
++ * FIFO 2 connects Port 2 B0 using HFC channel 4
++ * FIFO 3 connects Port 2 B1 using HFC channel 5
++ * .........................
++ * FIFO 14 connects Port 8 B0 using HFC channel 28
++ * FIFO 15 connects Port 8 B1 using HFC channel 29
++ *
++ * All B channel FIFOs have their HDLC controller in transparent mode,
++ * and only the FIFO for B0 on each port has its interrupt operational.
+ *
++ * D channels are handled by FIFOs 16-23.
++ * FIFO 16 connects Port 1 D using HFC channel 3
++ * FIFO 17 connects Port 2 D using HFC channel 7
++ * FIFO 18 connects Port 3 D using HFC channel 11
++ * FIFO 19 connects Port 4 D using HFC channel 15
++ * ................
++ * FIFO 23 connects Port 8 D using HFC channel 31
+ * D channel FIFOs are operated in HDLC mode and interrupt on end of frame.
+ */
+ for (span=0; span < b4->numspans; span++) {
+- if (vpmsupport) {
++ if ((vpmsupport) && (b4->has_ec)) {
+ hfc_assign_bchan_fifo_ec(b4, span, 0);
+ hfc_assign_bchan_fifo_ec(b4, span, 1);
+ } else {
+@@ -1854,6 +1920,145 @@
+ ec_write(b4, 0, 0x1a8 + 3, val);
+ }
+
++static void b4xxp_update_leds_hfc_8s(struct b4xxp *b4)
++{
++ unsigned long lled;
++ unsigned long leddw;
++ int i,j;
++ struct b4xxp_span *bspan;
++ lled = 0;
++ j=8;
++
++ b4->blinktimer++;
++ for (i=0; i < 8; i++) {
++ bspan = &b4->spans[i];
++ j = j -1 ; /* Leds are in reverse order - Led 7 => Port 0 */
++ if (bspan->span.flags & DAHDI_FLAG_RUNNING) {
++ if (bspan->span.alarms) {
++ lled |= 1 << j; /* Led OFF in alarm state */
++ } else if (bspan->span.mainttimer || bspan->span.maintstat) {
++ if (b4->blinktimer >= 0x7f) /* Led Blinking in maint state */
++ {
++ lled |= 1 << j;
++ }
++ else
++ {
++ lled |= 0 << j;
++ }
++ } else {
++
++ lled |= 0 << j; /* Led ON - No alarms */
++ }
++ }
++ else
++ lled |= 1 << j; /* Led OFF - Not running */
++ }
++ /* Write Leds...*/
++ leddw = lled << 24 | lled << 16 | lled << 8 | lled;
++ b4xxp_setreg8(b4, R_BRG_PCM_CFG, 0x21);
++ iowrite16(0x4000, b4->ioaddr + 4);
++ iowrite32(leddw, b4->ioaddr);
++ b4xxp_setreg8(b4, R_BRG_PCM_CFG, 0x20);
++
++ if (b4->blinktimer == 0xff) {
++ b4->blinktimer = -1;
++ }
++}
++
++static void b4xxp_update_leds_hfc(struct b4xxp *b4)
++{
++ int i, leds;
++ int led[4];
++ struct b4xxp_span *bspan;
++
++ b4->blinktimer++;
++ for (i=0; i < b4->numspans; i++) {
++ bspan = &b4->spans[i];
++
++ if (bspan->span.flags & DAHDI_FLAG_RUNNING) {
++ if (bspan->span.alarms) {
++ if (b4->blinktimer >= 0x7f) /* Red blinking -> Alarm */
++ {
++ led[i] = 2;
++ }
++ else
++ {
++ led[i] = 0;
++ }
++ } else if (bspan->span.mainttimer || bspan->span.maintstat) {
++ if (b4->blinktimer >= 0x7f) /* Green blinking -> Maint status */
++ {
++ led[i] = 1;
++ }
++ else
++ {
++ led[i] = 0;
++ }
++ } else {
++ /* No Alarm - Green */
++ led[i] = 1;
++ }
++ }
++ else
++ led[i] = 0; /* OFF - Not running */
++ }
++
++ /* Each card manage leds in a different way. So one section per card type */
++
++ if (b4->card_type == B400P_OV) {
++ leds = ((led[0] > 0) << 0) | ((led[1] > 0) << 1) |
++ ((led[2] > 0) << 2) | ((led[3] > 0) << 3) |
++ ((led[0] & 1) << 4) | ((led[1] & 1) << 5) |
++ ((led[2] & 1) << 6) | ((led[3] & 1) << 7); /* Tested OK */
++ b4xxp_setreg8(b4, R_GPIO_EN1, leds & 0x0f);
++ b4xxp_setreg8(b4, R_GPIO_OUT1, leds >> 4);
++ }
++
++ else if (b4->card_type == QUADBRI) {
++ leds = ((led[0] > 0) << 0) | ((led[1] > 0) << 1) |
++ ((led[2] > 0) << 2) | ((led[3] > 0) << 3) |
++ ((led[0] & 1) << 4) | ((led[1] & 1) << 5) |
++ ((led[2] & 1) << 6) | ((led[3] & 1) << 7); /* UNTESTED */
++ b4xxp_setreg8(b4, R_GPIO_EN1, leds & 0x0f);
++ b4xxp_setreg8(b4, R_GPIO_OUT1, leds >> 4);
++ }
++
++ else if (b4->card_type == BN4S0) {
++ leds = ((led[0] > 0) << 0) | ((led[1] > 0) << 1) |
++ ((led[2] > 0) << 2) | ((led[3] > 0) << 3) |
++ ((led[0] & 1) << 4) | ((led[1] & 1) << 5) |
++ ((led[2] & 1) << 6) | ((led[3] & 1) << 7); /* UNTESTED */
++ b4xxp_setreg8(b4, R_GPIO_EN1, leds & 0x0f);
++ b4xxp_setreg8(b4, R_GPIO_OUT1, leds >> 4);
++ }
++
++ else if (b4->card_type == B200P_OV) {
++ leds = ((led[0] > 0) << 0) | ((led[1] > 0) << 1) |
++ ((led[0] & 1) << 4) | ((led[1] & 1) << 5);
++ b4xxp_setreg8(b4, R_GPIO_EN1, leds & 0x0f);
++ b4xxp_setreg8(b4, R_GPIO_OUT1, leds >> 4); /* Tested OK */
++ }
++
++ else if (b4->card_type == DUOBRI) {
++ leds = ((led[0] > 0) << 0) | ((led[1] > 0) << 1) |
++ ((led[0] & 1) << 4) | ((led[1] & 1) << 5);
++ b4xxp_setreg8(b4, R_GPIO_EN1, leds & 0x0f);
++ b4xxp_setreg8(b4, R_GPIO_OUT1, leds >> 4); /* UNTESTED */
++ }
++
++ else if (b4->card_type == BN2S0) {
++ leds = ((led[0] > 0) << 0) | ((led[1] > 0) << 1) |
++ ((led[0] & 1) << 4) | ((led[1] & 1) << 5);
++ b4xxp_setreg8(b4, R_GPIO_EN1, leds & 0x0f);
++ b4xxp_setreg8(b4, R_GPIO_OUT1, leds >> 4); /* UNTESTED */
++ }
++
++ if (b4->blinktimer == 0xff) {
++ b4->blinktimer = -1;
++ }
++
++}
++
+ static void b4xxp_set_span_led(struct b4xxp *b4, int span, unsigned char val)
+ {
+ int shift, spanmask;
+@@ -1871,6 +2076,18 @@
+ int i;
+ struct b4xxp_span *bspan;
+
++ if (b4->numspans == 8) {
++ /* Use the alternative function for non-Digium HFC-8S cards */
++ b4xxp_update_leds_hfc_8s(b4);
++ return;
++ }
++
++ if (b4->card_type != B410P) {
++ /* Use the alternative function for non-Digium HFC-4S cards */
++ b4xxp_update_leds_hfc(b4);
++ return;
++ }
++
+ b4->blinktimer++;
+ for (i=0; i < b4->numspans; i++) {
+ bspan = &b4->spans[i];
+@@ -2174,7 +2391,7 @@
+ bspan->span.close = b4xxp_close;
+ bspan->span.ioctl = b4xxp_ioctl;
+ bspan->span.hdlc_hard_xmit = b4xxp_hdlc_hard_xmit;
+- if (vpmsupport)
++ if (vpmsupport && b4->has_ec)
+ bspan->span.echocan_create = echocan_create;
+
+ /* HDLC stuff */
+@@ -2281,13 +2498,24 @@
+ static void b4xxp_bottom_half(unsigned long data)
+ {
+ struct b4xxp *b4 = (struct b4xxp *)data;
+- int i, j, k, gotrxfifo, fifo;
++ int i, j, k, gotrxfifo, fifo, fifo_low, fifo_high;
+ unsigned char b, b2;
+
+ if (b4->shutdown)
+ return;
+
+ gotrxfifo = 0;
++ if ( b4->numspans == 8 ) /* HFC-4S d-chan fifos 8-11 *** HFC-8S d-chan fifos 16-23 */
++ {
++ fifo_low = 16;
++ fifo_high = 23;
++ }
++ else
++ {
++ fifo_low = 8;
++ fifo_high = 11;
++ }
++
+
+ for (i=0; i < 8; i++) {
+ b = b2 = b4->fifo_irqstatus[i];
+@@ -2296,7 +2524,7 @@
+ fifo = i*4 + j;
+
+ if (b & V_IRQ_FIFOx_TX) {
+- if (fifo >=8 && fifo <= 11) { /* d-chan fifo */
++ if (fifo >= fifo_low && fifo <= fifo_high) { /* d-chan fifos */
+ /*
+ * WOW I don't like this.
+ * It's bad enough that I have to send a fake frame to get an HDLC TX FIFO interrupt,
+@@ -2305,7 +2533,7 @@
+ * Yuck. It works well, but yuck.
+ */
+ do {
+- k = hdlc_tx_frame(&b4->spans[fifo - 8]);
++ k = hdlc_tx_frame(&b4->spans[fifo - fifo_low]);
+ } while (k);
+ } else {
+ if (printk_ratelimit())
+@@ -2314,7 +2542,7 @@
+ }
+
+ if (b & V_IRQ_FIFOx_RX) {
+- if (fifo >=8 && fifo <= 11) {
++ if (fifo >= fifo_low && fifo <= fifo_high) { /* dchan fifos */
+ /*
+ * I have to loop here until hdlc_rx_frame says there are no more frames waiting.
+ * for whatever reason, the HFC will not generate another interrupt if there are
+@@ -2322,7 +2550,7 @@
+ * i.e. I get an int when F1 changes, not when F1 != F2.
+ */
+ do {
+- k = hdlc_rx_frame(&b4->spans[fifo - 8]);
++ k = hdlc_rx_frame(&b4->spans[fifo - fifo_low]);
+ } while (k);
+ } else {
+ if (printk_ratelimit())
+@@ -2404,8 +2632,8 @@
+ sprintf(sBuf, "Card %d, PCI identifier %s, IRQ %d\n", b4->cardno + 1, b4->dev->bus_id, b4->irq);
+
+ strcat(sBuf,"Tx:\n");
+- for (j=0; j<8; j++) {
+- for (i=0; i<12; i++) {
++ for (j=0; j<(b4->numspans * 2) ; j++) { /* B Channels */
++ for (i=0; i<(b4->numspans * 3) ; i++) { /* All Channels */
+ chan = b4->spans[i/3].chans[i%3];
+ sprintf(str, "%02x ", chan->writechunk[j]);
+ strcat(sBuf, str);
+@@ -2415,8 +2643,8 @@
+ }
+
+ strcat(sBuf, "\nRx:\n");
+- for (j=0; j < 8; j++) {
+- for (i=0; i < 12; i++) {
++ for (j=0; j < (b4->numspans * 2); j++) { /* B Channels */
++ for (i=0; i < (b4->numspans * 3); i++) { /* All Channels */
+ chan = b4->spans[i / 3].chans[i % 3];
+ sprintf(str, "%02x%c", chan->readchunk[j], (i == 11) ? '\n' : ' ');
+ strcat(sBuf, str);
+@@ -2424,7 +2652,7 @@
+ }
+
+ strcat(sBuf, "\nPort states:\n");
+- for (i=0; i < 4; i++) {
++ for (i=0; i < b4->numspans; i++) {
+ int state;
+ char *x;
+ struct b4xxp_span *s = &b4->spans[i];
+@@ -2519,7 +2747,8 @@
+ /* card found, enabled and main struct allocated. Fill it out. */
+ b4->magic = WCB4XXP_MAGIC;
+ b4->variety = dt->desc;
+-
++ b4->has_ec = dt->has_ec;
++ b4->card_type = dt->card_type;
+ b4->pdev = pdev;
+ b4->dev = &pdev->dev;
+ pci_set_drvdata(pdev, b4);
+@@ -2533,7 +2762,7 @@
+ spin_lock_init(&b4->fifolock);
+
+ x = b4xxp_getreg8(b4, R_CHIP_ID);
+- if (x != 0xc0) { /* wrong chip? */
++ if ((x != 0xc0) && ( x != 0x80)) { /* wrong chip? */
+ dev_err(&pdev->dev, "Unknown/unsupported controller detected (R_CHIP_ID = 0x%02x)\n", x);
+ goto err_out_free_mem;
+ }
+@@ -2548,7 +2777,7 @@
+ */
+
+ /* TODO: determine whether this is a 2, 4 or 8 port card */
+- b4->numspans = 4;
++ b4->numspans = dt->ports;
+ b4->syncspan = -1; /* sync span is unknown */
+ if (b4->numspans > MAX_SPANS_PER_CARD) {
+ dev_err(b4->dev, "Driver does not know how to handle a %d span card!\n", b4->numspans);
+@@ -2696,7 +2925,17 @@
+ static struct pci_device_id b4xx_ids[] __devinitdata =
+ {
+ { 0xd161, 0xb410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wcb4xxp },
+- { 0, }
++ { 0x1397, 0x16b8, 0x1397, 0xe552, 0, 0, (unsigned long)&hfc8s },
++ { 0x1397, 0x08b4, 0x1397, 0xb520, 0, 0, (unsigned long)&hfc4s },
++ { 0x1397, 0x08b4, 0x1397, 0xb556, 0, 0, (unsigned long)&hfc2s },
++ { 0x1397, 0x08b4, 0x1397, 0xe884, 0, 0, (unsigned long)&hfc2s_OV },
++ { 0x1397, 0x08b4, 0x1397, 0xe888, 0, 0, (unsigned long)&hfc4s_OV },
++ { 0x1397, 0x16b8, 0x1397, 0xe998, 0, 0, (unsigned long)&hfc8s_OV },
++ { 0x1397, 0x08b4, 0x1397, 0xb566, 0, 0, (unsigned long)&hfc2s_BN },
++ { 0x1397, 0x08b4, 0x1397, 0xb560, 0, 0, (unsigned long)&hfc4s_BN },
++ { 0x1397, 0x16b8, 0x1397, 0xb562, 0, 0, (unsigned long)&hfc8s_BN },
++ {0, }
++
+ };
+
+ static struct pci_driver b4xx_driver = {
+@@ -2756,7 +2995,7 @@
+ MODULE_PARM_DESC(timer_3_ms, "TE: msec to wait for link activation, NT: unused.");
+
+ MODULE_AUTHOR("Digium Incorporated <support@digium.com>");
+-MODULE_DESCRIPTION("B410P quad-port BRI module driver.");
++MODULE_DESCRIPTION("B410P & Similars multi-port BRI module driver.");
+ MODULE_LICENSE("GPL");
+
+ MODULE_DEVICE_TABLE(pci, b4xx_ids);
+--- a/drivers/dahdi/wcb4xxp/wcb4xxp.h 2009-06-24 13:17:03.000000000 +0000
++++ b/drivers/dahdi/wcb4xxp/wcb4xxp.h 2009-06-24 13:18:07.000000000 +0000
+@@ -378,7 +378,7 @@
+ #define HFC_T3 2
+
+ #define WCB4XXP_MAGIC 0xb410c0de
+-#define MAX_SPANS_PER_CARD 4
++#define MAX_SPANS_PER_CARD 8
+
+ #define WCB4XXP_CHANNELS_PER_SPAN 3 /* 2 B-channels and 1 D-Channel for each BRI span */
+ #define WCB4XXP_HDLC_BUF_LEN 32 /* arbitrary, just the max # of byts we will send to DAHDI per call */
+@@ -415,6 +415,19 @@
+ struct dahdi_chan _chans[WCB4XXP_CHANNELS_PER_SPAN]; /* Backing memory */
+ };
+
++enum cards_ids { /* Cards ==> Brand & Model */
++ B410P = 0, /* Digium B410P */
++ B200P_OV, /* OpenVox B200P */
++ B400P_OV, /* OpenVox B400P */
++ B800P_OV, /* OpenVox B800P */
++ DUOBRI, /* HFC-2S Junghanns.NET duoBRI PCI */
++ QUADBRI, /* HFC-4S Junghanns.NET quadBRI PCI */
++ OCTOBRI, /* HFC-8S Junghanns.NET octoBRI PCI */
++ BN2S0, /* BeroNet BN2S0 */
++ BN4S0, /* Beronet BN4S0 */
++ BN8S0 /* BeroNet BN8S0 */
++ };
++
+ /* This structure exists one per card */
+ struct b4xxp {
+ unsigned magic; /* magic value to make sure we're looking at our struct */
+@@ -449,10 +462,12 @@
+ int globalconfig; /* Whether global setup has been done */
+ int syncspan; /* span that HFC uses for sync on this card */
+ int running; /* interrupts are enabled */
+-
++
+ struct b4xxp_span spans[MAX_SPANS_PER_CARD]; /* Individual spans */
+ int order; /* Order */
+ int flags; /* Device flags */
++ int has_ec; /* Has ECHO Cancel */
++ enum cards_ids card_type; /* Card Identifier (using ids_cards enum)*/
+ int master; /* Are we master */
+ int ledreg; /* copy of the LED Register */
+ unsigned int gpio;
diff --git a/main/dahdi-linux-grsec/dahdi-zaphfc.patch b/main/dahdi-linux-grsec/dahdi-zaphfc.patch
new file mode 100644
index 00000000000..b711c07ff9c
--- /dev/null
+++ b/main/dahdi-linux-grsec/dahdi-zaphfc.patch
@@ -0,0 +1,1429 @@
+Index: dahdi-linux-2.1.0/drivers/dahdi/zaphfc.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ dahdi-linux-2.1.0/drivers/dahdi/zaphfc.c 2008-12-10 12:46:14.000000000 +0200
+@@ -0,0 +1,1129 @@
++/*
++ * zaphfc.c - Zaptel driver for HFC-S PCI A based ISDN BRI cards
++ *
++ * kernel module inspired by HFC PCI ISDN4Linux and Zaptel drivers
++ *
++ * Copyright (C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH
++ *
++ * Klaus-Peter Junghanns <kpj@junghanns.net>
++ *
++ * This program is free software and may be modified and
++ * distributed under the terms of the GNU Public License.
++ *
++ */
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++#ifdef RTAITIMING
++#include <asm/io.h>
++#include <rtai.h>
++#include <rtai_sched.h>
++#include <rtai_fifos.h>
++#endif
++#include <linux/pci.h>
++#include <linux/init.h>
++#include <linux/interrupt.h>
++#include <linux/delay.h>
++#include <dahdi/kernel.h>
++#include "zaphfc.h"
++
++#include <linux/moduleparam.h>
++
++#if CONFIG_PCI
++
++#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */
++#define CLKDEL_NT 0x6c /* CLKDEL in NT mode */
++
++typedef struct {
++ int vendor_id;
++ int device_id;
++ char *vendor_name;
++ char *card_name;
++} PCI_ENTRY;
++
++static const PCI_ENTRY id_list[] =
++{
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_2BD0, "CCD/Billion/Asuscom", "2BD0"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B000, "Billion", "B000"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B006, "Billion", "B006"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B007, "Billion", "B007"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B008, "Billion", "B008"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B009, "Billion", "B009"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00A, "Billion", "B00A"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, "Billion", "B00B"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, "Billion", "B00C"},
++ {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, "Seyeon", "B100"},
++ {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, "Abocom/Magitek", "2BD1"},
++ {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, "Asuscom/Askey", "675"},
++ {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, "German telekom", "T-Concept"},
++ {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A1T, "German telekom", "A1T"},
++ {PCI_VENDOR_ID_ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575, "Motorola MC145575", "MC145575"},
++ {PCI_VENDOR_ID_ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0, "Zoltrix", "2BD0"},
++ {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E,"Digi International", "Digi DataFire Micro V IOM2 (Europe)"},
++ {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E,"Digi International", "Digi DataFire Micro V (Europe)"},
++ {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A,"Digi International", "Digi DataFire Micro V IOM2 (North America)"},
++ {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A,"Digi International", "Digi DataFire Micro V (North America)"},
++ {0x182d, 0x3069,"Sitecom","Isdn 128 PCI"},
++ {0, 0, NULL, NULL},
++};
++
++static struct hfc_card *hfc_dev_list = NULL;
++static int hfc_dev_count = 0;
++static int modes = 0; // all TE
++static int debug = 0;
++static struct pci_dev *multi_hfc = NULL;
++static spinlock_t registerlock = SPIN_LOCK_UNLOCKED;
++
++void hfc_shutdownCard(struct hfc_card *hfctmp) {
++ unsigned long flags;
++
++ if (hfctmp == NULL) {
++ return;
++ }
++
++ if (hfctmp->pci_io == NULL) {
++ return;
++ }
++
++ spin_lock_irqsave(&hfctmp->lock,flags);
++
++ printk(KERN_INFO "zaphfc: shutting down card at %p.\n",hfctmp->pci_io);
++
++ /* Clear interrupt mask */
++ hfctmp->regs.int_m2 = 0;
++ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
++
++ /* Reset pending interrupts */
++ hfc_inb(hfctmp, hfc_INT_S1);
++
++ /* Wait for interrupts that might still be pending */
++ spin_unlock_irqrestore(&hfctmp->lock, flags);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ schedule_timeout((30 * HZ) / 1000); // wait 30 ms
++ spin_lock_irqsave(&hfctmp->lock,flags);
++
++ /* Remove interrupt handler */
++ if (hfctmp->irq) {
++ free_irq(hfctmp->irq, hfctmp);
++ }
++
++ /* Soft-reset the card */
++ hfc_outb(hfctmp, hfc_CIRM, hfc_CIRM_RESET); // softreset on
++
++ spin_unlock_irqrestore(&hfctmp->lock, flags);
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ schedule_timeout((30 * HZ) / 1000); // wait 30 ms
++ spin_lock_irqsave(&hfctmp->lock,flags);
++
++ hfc_outb(hfctmp,hfc_CIRM,0); // softreset off
++
++ pci_write_config_word(hfctmp->pcidev, PCI_COMMAND, 0); // disable memio and bustmaster
++
++ if (hfctmp->fifomem != NULL) {
++ kfree(hfctmp->fifomem);
++ }
++ iounmap((void *) hfctmp->pci_io);
++ hfctmp->pci_io = NULL;
++ if (hfctmp->pcidev != NULL) {
++ pci_disable_device(hfctmp->pcidev);
++ }
++ spin_unlock_irqrestore(&hfctmp->lock,flags);
++ if (hfctmp->ztdev != NULL) {
++ dahdi_unregister(&hfctmp->ztdev->span);
++ kfree(hfctmp->ztdev);
++ printk(KERN_INFO "unregistered from DAHDI.\n");
++ }
++}
++
++void hfc_resetCard(struct hfc_card *hfctmp) {
++ unsigned long flags;
++
++ spin_lock_irqsave(&hfctmp->lock,flags);
++ pci_write_config_word(hfctmp->pcidev, PCI_COMMAND, PCI_COMMAND_MEMORY); // enable memio
++ hfctmp->regs.int_m2 = 0;
++ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
++
++// printk(KERN_INFO "zaphfc: resetting card.\n");
++ pci_set_master(hfctmp->pcidev);
++ hfc_outb(hfctmp, hfc_CIRM, hfc_CIRM_RESET); // softreset on
++ spin_unlock_irqrestore(&hfctmp->lock, flags);
++
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ schedule_timeout((30 * HZ) / 1000); // wait 30 ms
++ hfc_outb(hfctmp, hfc_CIRM, 0); // softreset off
++
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ schedule_timeout((20 * HZ) / 1000); // wait 20 ms
++ if (hfc_inb(hfctmp,hfc_STATUS) & hfc_STATUS_PCI_PROC) {
++ printk(KERN_WARNING "zaphfc: hfc busy.\n");
++ }
++
++// hfctmp->regs.fifo_en = hfc_FIFOEN_D | hfc_FIFOEN_B1 | hfc_FIFOEN_B2;
++// hfctmp->regs.fifo_en = hfc_FIFOEN_D; /* only D fifos enabled */
++ hfctmp->regs.fifo_en = 0; /* no fifos enabled */
++ hfc_outb(hfctmp, hfc_FIFO_EN, hfctmp->regs.fifo_en);
++
++ hfctmp->regs.trm = 2;
++ hfc_outb(hfctmp, hfc_TRM, hfctmp->regs.trm);
++
++ if (hfctmp->regs.nt_mode == 1) {
++ hfc_outb(hfctmp, hfc_CLKDEL, CLKDEL_NT); /* ST-Bit delay for NT-Mode */
++ } else {
++ hfc_outb(hfctmp, hfc_CLKDEL, CLKDEL_TE); /* ST-Bit delay for TE-Mode */
++ }
++ hfctmp->regs.sctrl_e = hfc_SCTRL_E_AUTO_AWAKE;
++ hfc_outb(hfctmp, hfc_SCTRL_E, hfctmp->regs.sctrl_e); /* S/T Auto awake */
++ hfctmp->regs.bswapped = 0; /* no exchange */
++
++ hfctmp->regs.ctmt = hfc_CTMT_TRANSB1 | hfc_CTMT_TRANSB2; // all bchans are transparent , no freaking hdlc
++ hfc_outb(hfctmp, hfc_CTMT, hfctmp->regs.ctmt);
++
++ hfctmp->regs.int_m1 = 0;
++ hfc_outb(hfctmp, hfc_INT_M1, hfctmp->regs.int_m1);
++
++#ifdef RTAITIMING
++ hfctmp->regs.int_m2 = 0;
++#else
++ hfctmp->regs.int_m2 = hfc_M2_PROC_TRANS;
++#endif
++ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
++
++ /* Clear already pending ints */
++ hfc_inb(hfctmp, hfc_INT_S1);
++
++ if (hfctmp->regs.nt_mode == 1) {
++ hfctmp->regs.sctrl = 3 | hfc_SCTRL_NONE_CAP | hfc_SCTRL_MODE_NT; /* set tx_lo mode, error in datasheet ! */
++ } else {
++ hfctmp->regs.sctrl = 3 | hfc_SCTRL_NONE_CAP | hfc_SCTRL_MODE_TE; /* set tx_lo mode, error in datasheet ! */
++ }
++
++ hfctmp->regs.mst_mode = hfc_MST_MODE_MASTER; /* HFC Master Mode */
++ hfc_outb(hfctmp, hfc_MST_MODE, hfctmp->regs.mst_mode);
++
++ hfc_outb(hfctmp, hfc_SCTRL, hfctmp->regs.sctrl);
++ hfctmp->regs.sctrl_r = 3;
++ hfc_outb(hfctmp, hfc_SCTRL_R, hfctmp->regs.sctrl_r);
++
++ hfctmp->regs.connect = 0;
++ hfc_outb(hfctmp, hfc_CONNECT, hfctmp->regs.connect);
++
++ hfc_outb(hfctmp, hfc_CIRM, 0x80 | 0x40); // bit order
++
++ /* Finally enable IRQ output */
++#ifndef RTAITIMING
++ hfctmp->regs.int_m2 |= hfc_M2_IRQ_ENABLE;
++ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
++#endif
++
++ /* clear pending ints */
++ hfc_inb(hfctmp, hfc_INT_S1);
++ hfc_inb(hfctmp, hfc_INT_S2);
++}
++
++void hfc_registerCard(struct hfc_card *hfccard) {
++ spin_lock(&registerlock);
++ if (hfccard != NULL) {
++ hfccard->cardno = hfc_dev_count++;
++ hfccard->next = hfc_dev_list;
++ hfc_dev_list = hfccard;
++ }
++ spin_unlock(&registerlock);
++}
++
++static void hfc_btrans(struct hfc_card *hfctmp, char whichB) {
++ // we are called with irqs disabled from the irq handler
++ int count, maxlen, total;
++ unsigned char *f1, *f2;
++ unsigned short *z1, *z2, newz1;
++ int freebytes;
++
++ if (whichB == 1) {
++ f1 = (char *)(hfctmp->fifos + hfc_FIFO_B1TX_F1);
++ f2 = (char *)(hfctmp->fifos + hfc_FIFO_B1TX_F2);
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1TX_Z1 + (*f1 * 4));
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1TX_Z2 + (*f1 * 4));
++ } else {
++ f1 = (char *)(hfctmp->fifos + hfc_FIFO_B2TX_F1);
++ f2 = (char *)(hfctmp->fifos + hfc_FIFO_B2TX_F2);
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2TX_Z1 + (*f1 * 4));
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2TX_Z2 + (*f1 * 4));
++ }
++
++ freebytes = *z2 - *z1;
++ if (freebytes <= 0) {
++ freebytes += hfc_B_FIFO_SIZE;
++ }
++ count = DAHDI_CHUNKSIZE;
++
++ total = count;
++ if (freebytes < count) {
++ hfctmp->clicks++;
++ /* only spit out this warning once per second to not make things worse! */
++ if (hfctmp->clicks > 100) {
++ printk(KERN_CRIT "zaphfc: bchan tx fifo full, dropping audio! (z1=%d, z2=%d)\n",*z1,*z2);
++ hfctmp->clicks = 0;
++ }
++ return;
++ }
++
++ maxlen = (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL) - *z1;
++ if (maxlen > count) {
++ maxlen = count;
++ }
++ newz1 = *z1 + total;
++ if (newz1 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) { newz1 -= hfc_B_FIFO_SIZE; }
++
++ if (whichB == 1) {
++ memcpy((char *)(hfctmp->fifos + hfc_FIFO_B1TX_ZOFF + *z1),hfctmp->ztdev->chans[0].writechunk, maxlen);
++ } else {
++ memcpy((char *)(hfctmp->fifos + hfc_FIFO_B2TX_ZOFF + *z1),hfctmp->ztdev->chans[1].writechunk, maxlen);
++ }
++
++ count -= maxlen;
++ if (count > 0) {
++ // Buffer wrap
++ if (whichB == 1) {
++ memcpy((char *)(hfctmp->fifos + hfc_FIFO_B1TX_ZOFF + hfc_B_SUB_VAL),hfctmp->ztdev->chans[0].writechunk+maxlen, count);
++ } else {
++ memcpy((char *)(hfctmp->fifos + hfc_FIFO_B2TX_ZOFF + hfc_B_SUB_VAL),hfctmp->ztdev->chans[1].writechunk+maxlen, count);
++ }
++ }
++
++ *z1 = newz1; /* send it now */
++
++// if (count > 0) printk(KERN_CRIT "zaphfc: bchan tx fifo (f1=%d, f2=%d, z1=%d, z2=%d)\n",(*f1) & hfc_FMASK,(*f2) & hfc_FMASK, *z1, *z2);
++ return;
++}
++
++static void hfc_brec(struct hfc_card *hfctmp, char whichB) {
++ // we are called with irqs disabled from the irq handler
++ int count, maxlen, drop;
++ volatile unsigned char *f1, *f2;
++ volatile unsigned short *z1, *z2, newz2;
++ int bytes = 0;
++
++ if (whichB == 1) {
++ f1 = (char *)(hfctmp->fifos + hfc_FIFO_B1RX_F1);
++ f2 = (char *)(hfctmp->fifos + hfc_FIFO_B1RX_F2);
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1RX_Z1 + (*f1 * 4));
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1RX_Z2 + (*f1 * 4));
++ } else {
++ f1 = (char *)(hfctmp->fifos + hfc_FIFO_B2RX_F1);
++ f2 = (char *)(hfctmp->fifos + hfc_FIFO_B2RX_F2);
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2RX_Z1 + (*f1 * 4));
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2RX_Z2 + (*f1 * 4));
++ }
++
++ bytes = *z1 - *z2;
++ if (bytes < 0) {
++ bytes += hfc_B_FIFO_SIZE;
++ }
++ count = DAHDI_CHUNKSIZE;
++
++ if (bytes < DAHDI_CHUNKSIZE) {
++#ifndef RTAITIMING
++ printk(KERN_CRIT "zaphfc: bchan rx fifo not enough bytes to receive! (z1=%d, z2=%d, wanted %d got %d), probably a buffer overrun.\n",*z1,*z2,DAHDI_CHUNKSIZE,bytes);
++#endif
++ return;
++ }
++
++ /* allowing the buffering of hfc_BCHAN_BUFFER bytes of audio data works around irq jitter */
++ if (bytes > hfc_BCHAN_BUFFER + DAHDI_CHUNKSIZE) {
++ /* if the system is too slow to handle it, we will have to drop it all (except 1 DAHDI chunk) */
++ drop = bytes - DAHDI_CHUNKSIZE;
++ hfctmp->clicks++;
++ /* only spit out this warning once per second to not make things worse! */
++ if (hfctmp->clicks > 100) {
++ printk(KERN_CRIT "zaphfc: dropped audio (z1=%d, z2=%d, wanted %d got %d, dropped %d).\n",*z1,*z2,count,bytes,drop);
++ hfctmp->clicks = 0;
++ }
++ /* hm, we are processing the b chan data tooooo slowly... let's drop the lost audio */
++ newz2 = *z2 + drop;
++ if (newz2 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) {
++ newz2 -= hfc_B_FIFO_SIZE;
++ }
++ *z2 = newz2;
++ }
++
++
++ maxlen = (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL) - *z2;
++ if (maxlen > count) {
++ maxlen = count;
++ }
++ if (whichB == 1) {
++ memcpy(hfctmp->ztdev->chans[0].readchunk,(char *)(hfctmp->fifos + hfc_FIFO_B1RX_ZOFF + *z2), maxlen);
++ } else {
++ memcpy(hfctmp->ztdev->chans[1].readchunk,(char *)(hfctmp->fifos + hfc_FIFO_B2RX_ZOFF + *z2), maxlen);
++ }
++ newz2 = *z2 + count;
++ if (newz2 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) {
++ newz2 -= hfc_B_FIFO_SIZE;
++ }
++ *z2 = newz2;
++
++ count -= maxlen;
++ if (count > 0) {
++ // Buffer wrap
++ if (whichB == 1) {
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1RX_Z2 + (*f1 * 4));
++ memcpy(hfctmp->ztdev->chans[0].readchunk + maxlen,(char *)(hfctmp->fifos + hfc_FIFO_B1RX_ZOFF + hfc_B_SUB_VAL), count);
++ } else {
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2RX_Z2 + (*f1 * 4));
++ memcpy(hfctmp->ztdev->chans[1].readchunk + maxlen,(char *)(hfctmp->fifos + hfc_FIFO_B2RX_ZOFF + hfc_B_SUB_VAL), count);
++ }
++ newz2 = *z2 + count;
++ if (newz2 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) {
++ newz2 -= hfc_B_FIFO_SIZE;
++ }
++ }
++
++
++ if (whichB == 1) {
++ dahdi_ec_chunk(&hfctmp->ztdev->chans[0], hfctmp->ztdev->chans[0].readchunk, hfctmp->ztdev->chans[0].writechunk);
++ } else {
++ dahdi_ec_chunk(&hfctmp->ztdev->chans[1], hfctmp->ztdev->chans[1].readchunk, hfctmp->ztdev->chans[1].writechunk);
++ }
++ return;
++}
++
++
++static void hfc_dtrans(struct hfc_card *hfctmp) {
++ // we are called with irqs disabled from the irq handler
++ int x;
++ int count, maxlen, total;
++ unsigned char *f1, *f2, newf1;
++ unsigned short *z1, *z2, newz1;
++ int frames, freebytes;
++
++ if (hfctmp->ztdev->chans[2].bytes2transmit == 0) {
++ return;
++ }
++
++ f1 = (char *)(hfctmp->fifos + hfc_FIFO_DTX_F1);
++ f2 = (char *)(hfctmp->fifos + hfc_FIFO_DTX_F2);
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DTX_Z1 + (*f1 * 4));
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DTX_Z2 + (*f1 * 4));
++
++ frames = (*f1 - *f2) & hfc_FMASK;
++ if (frames < 0) {
++ frames += hfc_MAX_DFRAMES + 1;
++ }
++
++ if (frames >= hfc_MAX_DFRAMES) {
++ printk(KERN_CRIT "zaphfc: dchan tx fifo total number of frames exceeded!\n");
++ return;
++ }
++
++ freebytes = *z2 - *z1;
++ if (freebytes <= 0) {
++ freebytes += hfc_D_FIFO_SIZE;
++ }
++ count = hfctmp->ztdev->chans[2].bytes2transmit;
++
++ total = count;
++ if (freebytes < count) {
++ printk(KERN_CRIT "zaphfc: dchan tx fifo not enough free bytes! (z1=%d, z2=%d)\n",*z1,*z2);
++ return;
++ }
++
++ newz1 = (*z1 + count) & hfc_ZMASK;
++ newf1 = ((*f1 + 1) & hfc_MAX_DFRAMES) | (hfc_MAX_DFRAMES + 1); // next frame
++
++ if (count > 0) {
++ if (debug) {
++ printk(KERN_CRIT "zaphfc: card %d TX [ ", hfctmp->cardno);
++ for (x=0; x<count; x++) {
++ printk("%#2x ",hfctmp->dtransbuf[x]);
++ }
++ if (hfctmp->ztdev->chans[2].eoftx == 1) {
++ printk("] %d bytes\n", count);
++ } else {
++ printk("..] %d bytes\n", count);
++ }
++ }
++ maxlen = hfc_D_FIFO_SIZE - *z1;
++ if (maxlen > count) {
++ maxlen = count;
++ }
++ memcpy((char *)(hfctmp->fifos + hfc_FIFO_DTX_ZOFF + *z1),hfctmp->ztdev->chans[2].writechunk, maxlen);
++ count -= maxlen;
++ if (count > 0) {
++ memcpy((char *)(hfctmp->fifos + hfc_FIFO_DTX_ZOFF),(char *)(hfctmp->ztdev->chans[2].writechunk + maxlen), count);
++ }
++ }
++
++ *z1 = newz1;
++
++ if (hfctmp->ztdev->chans[2].eoftx == 1) {
++ *f1 = newf1;
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DTX_Z1 + (*f1 * 4));
++ *z1 = newz1;
++ hfctmp->ztdev->chans[2].eoftx = 0;
++ }
++// printk(KERN_CRIT "zaphfc: dchan tx fifo (f1=%d, f2=%d, z1=%d, z2=%d)\n",(*f1) & hfc_FMASK,(*f2) & hfc_FMASK, *z1, *z2);
++ return;
++}
++
++/* receive a complete hdlc frame, skip broken or short frames */
++static void hfc_drec(struct hfc_card *hfctmp) {
++ int count=0, maxlen=0, framelen=0;
++ unsigned char *f1, *f2, *crcstat;
++ unsigned short *z1, *z2, oldz2, newz2;
++
++ hfctmp->ztdev->chans[2].bytes2receive=0;
++ hfctmp->ztdev->chans[2].eofrx = 0;
++
++ /* put the received data into the DAHDI buffer
++ we'll call dahdi_receive() later when the timer fires. */
++ f1 = (char *)(hfctmp->fifos + hfc_FIFO_DRX_F1);
++ f2 = (char *)(hfctmp->fifos + hfc_FIFO_DRX_F2);
++
++ if (*f1 == *f2) return; /* nothing received, strange eh? */
++
++ z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z1 + (*f2 * 4));
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z2 + (*f2 * 4));
++
++ /* calculate length of frame, including 2 bytes CRC and 1 byte STAT */
++ count = *z1 - *z2;
++
++ if (count < 0) {
++ count += hfc_D_FIFO_SIZE; /* ring buffer wrapped */
++ }
++ count++;
++ framelen = count;
++
++ crcstat = (char *)(hfctmp->fifos + hfc_FIFO_DRX_ZOFF + *z1);
++
++ if ((framelen < 4) || (*crcstat != 0x0)) {
++ /* the frame is too short for a valid HDLC frame or the CRC is borked */
++ printk(KERN_CRIT "zaphfc: empty HDLC frame or bad CRC received (framelen = %d, stat = %#x, card = %d).\n", framelen, *crcstat, hfctmp->cardno);
++ oldz2 = *z2;
++ *f2 = ((*f2 + 1) & hfc_MAX_DFRAMES) | (hfc_MAX_DFRAMES + 1); /* NEXT!!! */
++ // recalculate z2, because Z2 is a function of F2 Z2(F2) and we INCed F2!!!
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z2 + (*f2 * 4));
++ *z2 = (oldz2 + framelen) & hfc_ZMASK;
++ hfctmp->drecinframe = 0;
++ hfctmp->regs.int_drec--;
++ /* skip short or broken frames */
++ hfctmp->ztdev->chans[2].bytes2receive = 0;
++ return;
++ }
++
++ count -= 1; /* strip STAT */
++ hfctmp->ztdev->chans[2].eofrx = 1;
++
++ if (count + *z2 <= hfc_D_FIFO_SIZE) {
++ maxlen = count;
++ } else {
++ maxlen = hfc_D_FIFO_SIZE - *z2;
++ }
++
++ /* copy first part */
++ memcpy(hfctmp->drecbuf, (char *)(hfctmp->fifos + hfc_FIFO_DRX_ZOFF + *z2), maxlen);
++ hfctmp->ztdev->chans[2].bytes2receive += maxlen;
++
++ count -= maxlen;
++ if (count > 0) {
++ /* ring buffer wrapped, copy rest from start of d fifo */
++ memcpy(hfctmp->drecbuf + maxlen, (char *)(hfctmp->fifos + hfc_FIFO_DRX_ZOFF), count);
++ hfctmp->ztdev->chans[2].bytes2receive += count;
++ }
++
++ /* frame read */
++ oldz2 = *z2;
++ newz2 = (oldz2 + framelen) & hfc_ZMASK;
++ *f2 = ((*f2 + 1) & hfc_MAX_DFRAMES) | (hfc_MAX_DFRAMES + 1); /* NEXT!!! */
++ /* recalculate z2, because Z2 is a function of F2 Z2(F2) and we INCed F2!!! */
++ z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z2 + (*f2 * 4));
++ *z2 = newz2;
++ hfctmp->drecinframe = 0;
++ hfctmp->regs.int_drec--;
++}
++
++#ifndef RTAITIMING
++DAHDI_IRQ_HANDLER(hfc_interrupt) {
++ struct hfc_card *hfctmp = dev_id;
++ unsigned long flags = 0;
++ unsigned char stat;
++#else
++static void hfc_service(struct hfc_card *hfctmp) {
++#endif
++ struct dahdi_hfc *zthfc;
++ unsigned char s1, s2, l1state;
++ int x;
++
++ if (!hfctmp) {
++#ifndef RTAITIMING
++ return IRQ_NONE;
++#else
++ /* rtai */
++ return;
++#endif
++ }
++
++ if (!hfctmp->pci_io) {
++ printk(KERN_WARNING "%s: IO-mem disabled, cannot handle interrupt\n",
++ __FUNCTION__);
++#ifndef RTAITIMING
++ return IRQ_NONE;
++#else
++ /* rtai */
++ return;
++#endif
++ }
++
++ /* we assume a few things in this irq handler:
++ - the hfc-pci will only generate "timer" irqs (proc/non-proc)
++ - we need to use every 8th IRQ (to generate 1khz timing)
++ OR
++ - if we use rtai for timing the hfc-pci will not generate ANY irq,
++ instead rtai will call this "fake" irq with a 1khz realtime timer. :)
++ - rtai will directly service the card, not like it used to by triggering
++ the linux irq
++ */
++
++#ifndef RTAITIMING
++ spin_lock_irqsave(&hfctmp->lock, flags);
++ stat = hfc_inb(hfctmp, hfc_STATUS);
++
++ if ((stat & hfc_STATUS_ANYINT) == 0) {
++ // maybe we are sharing the irq
++ spin_unlock_irqrestore(&hfctmp->lock,flags);
++ return IRQ_NONE;
++ }
++#endif
++
++ s1 = hfc_inb(hfctmp, hfc_INT_S1);
++ s2 = hfc_inb(hfctmp, hfc_INT_S2);
++ if (s1 != 0) {
++ if (s1 & hfc_INTS_TIMER) {
++ // timer (bit 7)
++ // printk(KERN_CRIT "timer %d %d %d.\n", stat, s1, s2);
++ }
++ if (s1 & hfc_INTS_L1STATE) {
++ // state machine (bit 6)
++ // printk(KERN_CRIT "zaphfc: layer 1 state machine interrupt\n");
++ zthfc = hfctmp->ztdev;
++ l1state = hfc_inb(hfctmp,hfc_STATES) & hfc_STATES_STATE_MASK;
++ if (hfctmp->regs.nt_mode == 1) {
++ if (debug) {
++ printk(KERN_CRIT "zaphfc: card %d layer 1 state = G%d\n", hfctmp->cardno, l1state);
++ }
++ switch (l1state) {
++ case 3:
++#ifdef RTAITIMING
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 ACTIVATED (G%d) [realtime]", hfctmp->cardno, l1state);
++#else
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 ACTIVATED (G%d)", hfctmp->cardno, l1state);
++#endif
++ break;
++ default:
++#ifdef RTAITIMING
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 DEACTIVATED (G%d) [realtime]", hfctmp->cardno, l1state);
++#else
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 DEACTIVATED (G%d)", hfctmp->cardno, l1state);
++#endif
++ }
++ if (l1state == 2) {
++ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_ACTIVATE | hfc_STATES_DO_ACTION | hfc_STATES_NT_G2_G3);
++ } else if (l1state == 3) {
++ // fix to G3 state (see specs)
++ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_LOAD_STATE | 3);
++ }
++ } else {
++ if (debug) {
++ printk(KERN_CRIT "zaphfc: card %d layer 1 state = F%d\n", hfctmp->cardno, l1state);
++ }
++ switch (l1state) {
++ case 7:
++#ifdef RTAITIMING
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 ACTIVATED (F%d) [realtime]", hfctmp->cardno, l1state);
++#else
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 ACTIVATED (F%d)", hfctmp->cardno, l1state);
++#endif
++ break;
++ default:
++#ifdef RTAITIMING
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 DEACTIVATED (F%d) [realtime]", hfctmp->cardno, l1state);
++#else
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 DEACTIVATED (F%d)", hfctmp->cardno, l1state);
++#endif
++ }
++ if (l1state == 3) {
++ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_DO_ACTION | hfc_STATES_ACTIVATE);
++ }
++ }
++
++ }
++ if (s1 & hfc_INTS_DREC) {
++ // D chan RX (bit 5)
++ hfctmp->regs.int_drec++;
++ // mr. zapata there is something for you!
++ // printk(KERN_CRIT "d chan rx\n");
++ }
++ if (s1 & hfc_INTS_B2REC) {
++ // B2 chan RX (bit 4)
++ }
++ if (s1 & hfc_INTS_B1REC) {
++ // B1 chan RX (bit 3)
++ }
++ if (s1 & hfc_INTS_DTRANS) {
++ // D chan TX (bit 2)
++// printk(KERN_CRIT "zaphfc: dchan frame transmitted.\n");
++ }
++ if (s1 & hfc_INTS_B2TRANS) {
++ // B2 chan TX (bit 1)
++ }
++ if (s1 & hfc_INTS_B1TRANS) {
++ // B1 chan TX (bit 0)
++ }
++ }
++#ifdef RTAITIMING
++ /* fake an irq */
++ s2 |= hfc_M2_PROC_TRANS;
++#endif
++ if (s2 != 0) {
++ if (s2 & hfc_M2_PMESEL) {
++ // kaboom irq (bit 7)
++ printk(KERN_CRIT "zaphfc: sync lost, pci performance too low. you might have some cpu throtteling enabled.\n");
++ }
++ if (s2 & hfc_M2_GCI_MON_REC) {
++ // RxR monitor channel (bit 2)
++ }
++ if (s2 & hfc_M2_GCI_I_CHG) {
++ // GCI I-change (bit 1)
++ }
++ if (s2 & hfc_M2_PROC_TRANS) {
++ // processing/non-processing transition (bit 0)
++ hfctmp->ticks++;
++#ifndef RTAITIMING
++ if (hfctmp->ticks > 7) {
++ // welcome to DAHDI timing :)
++#endif
++ hfctmp->ticks = 0;
++
++ if (hfctmp->ztdev->span.flags & DAHDI_FLAG_RUNNING) {
++ // clear dchan buffer
++ hfctmp->ztdev->chans[2].bytes2transmit = 0;
++ hfctmp->ztdev->chans[2].maxbytes2transmit = hfc_D_FIFO_SIZE;
++
++ dahdi_transmit(&(hfctmp->ztdev->span));
++
++ hfc_btrans(hfctmp,1);
++ hfc_btrans(hfctmp,2);
++ hfc_dtrans(hfctmp);
++ }
++
++ hfc_brec(hfctmp,1);
++ hfc_brec(hfctmp,2);
++ if (hfctmp->regs.int_drec > 0) {
++ // dchan data to read
++ hfc_drec(hfctmp);
++ if (hfctmp->ztdev->chans[2].bytes2receive > 0) {
++ if (debug) {
++ printk(KERN_CRIT "zaphfc: card %d RX [ ", hfctmp->cardno);
++ if (hfctmp->ztdev->chans[2].eofrx) {
++ /* dont output CRC == less user confusion */
++ for (x=0; x < hfctmp->ztdev->chans[2].bytes2receive - 2; x++) {
++ printk("%#2x ", hfctmp->drecbuf[x]);
++ }
++ printk("] %d bytes\n", hfctmp->ztdev->chans[2].bytes2receive - 2);
++ } else {
++ for (x=0; x < hfctmp->ztdev->chans[2].bytes2receive; x++) {
++ printk("%#2x ", hfctmp->drecbuf[x]);
++ }
++ printk("..] %d bytes\n", hfctmp->ztdev->chans[2].bytes2receive);
++ }
++ }
++ }
++ } else {
++ // hmm....ok, let DAHDI receive nothing
++ hfctmp->ztdev->chans[2].bytes2receive = 0;
++ }
++ if (hfctmp->ztdev->span.flags & DAHDI_FLAG_RUNNING) {
++ dahdi_receive(&(hfctmp->ztdev->span));
++ }
++
++#ifndef RTAITIMING
++ }
++#endif
++ }
++
++ }
++#ifndef RTAITIMING
++ spin_unlock_irqrestore(&hfctmp->lock,flags);
++ return IRQ_RETVAL(1);
++#endif
++}
++
++
++static int zthfc_open(struct dahdi_chan *chan) {
++ struct dahdi_hfc *zthfc = chan->pvt;
++ struct hfc_card *hfctmp = zthfc->card;
++
++ if (!hfctmp) {
++ return 0;
++ }
++ try_module_get(THIS_MODULE);
++ return 0;
++}
++
++static int zthfc_close(struct dahdi_chan *chan) {
++ struct dahdi_hfc *zthfc = chan->pvt;
++ struct hfc_card *hfctmp = zthfc->card;
++
++ if (!hfctmp) {
++ return 0;
++ }
++
++ module_put(THIS_MODULE);
++ return 0;
++}
++
++static int zthfc_rbsbits(struct dahdi_chan *chan, int bits) {
++ return 0;
++}
++
++static int zthfc_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data) {
++ switch(cmd) {
++ default:
++ return -ENOTTY;
++ }
++ return 0;
++}
++
++static int zthfc_startup(struct dahdi_span *span) {
++ struct dahdi_hfc *zthfc = span->pvt;
++ struct hfc_card *hfctmp = zthfc->card;
++ int alreadyrunning;
++
++ if (hfctmp == NULL) {
++ printk(KERN_INFO "zaphfc: no card for span at startup!\n");
++ }
++ alreadyrunning = span->flags & DAHDI_FLAG_RUNNING;
++
++ if (!alreadyrunning) {
++ span->chans[2]->flags &= ~DAHDI_FLAG_HDLC;
++ span->chans[2]->flags |= DAHDI_FLAG_BRIDCHAN;
++
++ span->flags |= DAHDI_FLAG_RUNNING;
++
++ hfctmp->ticks = -2;
++ hfctmp->clicks = 0;
++ hfctmp->regs.fifo_en = hfc_FIFOEN_D | hfc_FIFOEN_B1 | hfc_FIFOEN_B2;
++ hfc_outb(hfctmp, hfc_FIFO_EN, hfctmp->regs.fifo_en);
++ } else {
++ return 0;
++ }
++
++ // drivers, start engines!
++ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_DO_ACTION | hfc_STATES_ACTIVATE);
++ return 0;
++}
++
++static int zthfc_shutdown(struct dahdi_span *span) {
++ return 0;
++}
++
++static int zthfc_maint(struct dahdi_span *span, int cmd) {
++ return 0;
++}
++
++static int zthfc_chanconfig(struct dahdi_chan *chan, int sigtype) {
++// printk(KERN_CRIT "chan_config sigtype=%d\n", sigtype);
++ return 0;
++}
++
++static int zthfc_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) {
++ span->lineconfig = lc->lineconfig;
++ return 0;
++}
++
++static int zthfc_initialize(struct dahdi_hfc *zthfc) {
++ struct hfc_card *hfctmp = zthfc->card;
++ int i;
++
++ memset(&zthfc->span, 0x0, sizeof(struct dahdi_span)); // you never can tell...
++
++ sprintf(zthfc->span.name, "ZTHFC%d", hfc_dev_count + 1);
++ if (hfctmp->regs.nt_mode == 1) {
++#ifdef RTAITIMING
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] [realtime]", hfc_dev_count + 1);
++#else
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT]", hfc_dev_count + 1);
++#endif
++ } else {
++#ifdef RTAITIMING
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] [realtime]", hfc_dev_count + 1);
++#else
++ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE]", hfc_dev_count + 1);
++#endif
++ }
++
++ zthfc->span.spanconfig = zthfc_spanconfig;
++ zthfc->span.chanconfig = zthfc_chanconfig;
++ zthfc->span.startup = zthfc_startup;
++ zthfc->span.shutdown = zthfc_shutdown;
++ zthfc->span.maint = zthfc_maint;
++ zthfc->span.rbsbits = zthfc_rbsbits;
++ zthfc->span.open = zthfc_open;
++ zthfc->span.close = zthfc_close;
++ zthfc->span.ioctl = zthfc_ioctl;
++
++ zthfc->span.channels = 3;
++ zthfc->span.chans = zthfc->_chans;
++ for (i = 0; i < zthfc->span.channels; i++)
++ zthfc->_chans[i] = &zthfc->chans[i];
++
++ zthfc->span.deflaw = DAHDI_LAW_ALAW;
++ zthfc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_CCS; // <--- this is really BS
++ zthfc->span.offset = 0;
++ init_waitqueue_head(&zthfc->span.maintq);
++ zthfc->span.pvt = zthfc;
++
++ for (i = 0; i < zthfc->span.channels; i++) {
++ memset(&(zthfc->chans[i]), 0x0, sizeof(struct dahdi_chan));
++ sprintf(zthfc->chans[i].name, "ZTHFC%d/%d/%d", hfc_dev_count + 1,0,i + 1);
++ zthfc->chans[i].pvt = zthfc;
++ zthfc->chans[i].sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_FXSLS | DAHDI_SIG_FXSGS | DAHDI_SIG_FXSKS | DAHDI_SIG_FXOLS | DAHDI_SIG_FXOGS | DAHDI_SIG_FXOKS | DAHDI_SIG_CAS | DAHDI_SIG_SF;
++ zthfc->chans[i].chanpos = i + 1;
++ }
++
++ if (dahdi_register(&zthfc->span,0)) {
++ printk(KERN_CRIT "unable to register DAHDI device!\n");
++ return -1;
++ }
++// printk(KERN_CRIT "zaphfc: registered DAHDI device!\n");
++ return 0;
++}
++
++#ifdef RTAITIMING
++#define TICK_PERIOD 1000000
++#define TICK_PERIOD2 1000000000
++#define TASK_PRIORITY 1
++#define STACK_SIZE 10000
++
++static RT_TASK rt_task;
++static struct hfc_card *rtai_hfc_list[hfc_MAX_CARDS];
++static unsigned char rtai_hfc_counter = 0;
++
++static void rtai_register_hfc(struct hfc_card *hfctmp) {
++ rtai_hfc_list[rtai_hfc_counter++] = hfctmp;
++}
++
++static void rtai_loop(int t) {
++ int i=0;
++ for (;;) {
++ for (i=0; i < rtai_hfc_counter; i++) {
++ if (rtai_hfc_list[i] != NULL)
++ hfc_service(rtai_hfc_list[i]);
++ }
++ rt_task_wait_period();
++ }
++}
++#endif
++
++int hfc_findCards(int pcivendor, int pcidevice, char *vendor_name, char *card_name) {
++ struct pci_dev *tmp;
++ struct hfc_card *hfctmp = NULL;
++ struct dahdi_hfc *zthfc = NULL;
++
++ tmp = pci_get_device(pcivendor, pcidevice, multi_hfc);
++ while (tmp != NULL) {
++ multi_hfc = tmp; // skip this next time.
++
++ if (pci_enable_device(tmp)) {
++ multi_hfc = NULL;
++ return -1;
++ }
++ pci_set_master(tmp);
++
++ hfctmp = kmalloc(sizeof(struct hfc_card), GFP_KERNEL);
++ if (!hfctmp) {
++ printk(KERN_WARNING "zaphfc: unable to kmalloc!\n");
++ pci_disable_device(tmp);
++ multi_hfc = NULL;
++ return -ENOMEM;
++ }
++ memset(hfctmp, 0x0, sizeof(struct hfc_card));
++ spin_lock_init(&hfctmp->lock);
++
++ hfctmp->pcidev = tmp;
++ hfctmp->pcibus = tmp->bus->number;
++ hfctmp->pcidevfn = tmp->devfn;
++
++ if (!tmp->irq) {
++ printk(KERN_WARNING "zaphfc: no irq!\n");
++ } else {
++ hfctmp->irq = tmp->irq;
++ }
++
++ hfctmp->pci_io = (char *) tmp->resource[1].start;
++ if (!hfctmp->pci_io) {
++ printk(KERN_WARNING "zaphfc: no iomem!\n");
++ kfree(hfctmp);
++ pci_disable_device(tmp);
++ multi_hfc = NULL;
++ return -1;
++ }
++
++ hfctmp->fifomem = kmalloc(65536, GFP_KERNEL);
++ if (!hfctmp->fifomem) {
++ printk(KERN_WARNING "zaphfc: unable to kmalloc fifomem!\n");
++ kfree(hfctmp);
++ pci_disable_device(tmp);
++ multi_hfc = NULL;
++ return -ENOMEM;
++ } else {
++ memset(hfctmp->fifomem, 0x0, 65536);
++ hfctmp->fifos = (void *)(((ulong) hfctmp->fifomem) & ~0x7FFF) + 0x8000;
++ pci_write_config_dword(hfctmp->pcidev, 0x80, (u_int) virt_to_bus(hfctmp->fifos));
++ hfctmp->pci_io = ioremap((ulong) hfctmp->pci_io, 256);
++ }
++
++#ifdef RTAITIMING
++ /* we need no stinking irq */
++ hfctmp->irq = 0;
++#else
++ if (request_irq(hfctmp->irq, &hfc_interrupt, DAHDI_IRQ_SHARED, "zaphfc", hfctmp)) {
++ printk(KERN_WARNING "zaphfc: unable to register irq\n");
++ kfree(hfctmp->fifomem);
++ kfree(hfctmp);
++ iounmap((void *) hfctmp->pci_io);
++ pci_disable_device(tmp);
++ multi_hfc = NULL;
++ return -EIO;
++ }
++#endif
++
++#ifdef RTAITIMING
++ rtai_register_hfc(hfctmp);
++#endif
++ printk(KERN_INFO
++ "zaphfc: %s %s configured at mem %lx fifo %lx(%#x) IRQ %d HZ %d\n",
++ vendor_name, card_name,
++ (unsigned long) hfctmp->pci_io,
++ (unsigned long) hfctmp->fifos,
++ (u_int) virt_to_bus(hfctmp->fifos),
++ hfctmp->irq, HZ);
++ pci_write_config_word(hfctmp->pcidev, PCI_COMMAND, PCI_COMMAND_MEMORY); // enable memio
++ hfctmp->regs.int_m1 = 0; // no ints
++ hfctmp->regs.int_m2 = 0; // not at all
++ hfc_outb(hfctmp,hfc_INT_M1,hfctmp->regs.int_m1);
++ hfc_outb(hfctmp,hfc_INT_M2,hfctmp->regs.int_m2);
++
++ if ((modes & (1 << hfc_dev_count)) != 0) {
++ printk(KERN_INFO "zaphfc: Card %d configured for NT mode\n",hfc_dev_count);
++ hfctmp->regs.nt_mode = 1;
++ } else {
++ printk(KERN_INFO "zaphfc: Card %d configured for TE mode\n",hfc_dev_count);
++ hfctmp->regs.nt_mode = 0;
++ }
++
++ zthfc = kmalloc(sizeof(struct dahdi_hfc),GFP_KERNEL);
++ if (!zthfc) {
++ printk(KERN_CRIT "zaphfc: unable to kmalloc!\n");
++ hfc_shutdownCard(hfctmp);
++ kfree(hfctmp);
++ multi_hfc = NULL;
++ return -ENOMEM;
++ }
++ memset(zthfc, 0x0, sizeof(struct dahdi_hfc));
++
++ zthfc->card = hfctmp;
++ zthfc_initialize(zthfc);
++ hfctmp->ztdev = zthfc;
++
++ memset(hfctmp->drecbuf, 0x0, sizeof(hfctmp->drecbuf));
++ hfctmp->ztdev->chans[2].readchunk = hfctmp->drecbuf;
++
++ memset(hfctmp->dtransbuf, 0x0, sizeof(hfctmp->dtransbuf));
++ hfctmp->ztdev->chans[2].writechunk = hfctmp->dtransbuf;
++
++ memset(hfctmp->brecbuf[0], 0x0, sizeof(hfctmp->brecbuf[0]));
++ hfctmp->ztdev->chans[0].readchunk = hfctmp->brecbuf[0];
++ memset(hfctmp->btransbuf[0], 0x0, sizeof(hfctmp->btransbuf[0]));
++ hfctmp->ztdev->chans[0].writechunk = hfctmp->btransbuf[0];
++
++ memset(hfctmp->brecbuf[1], 0x0, sizeof(hfctmp->brecbuf[1]));
++ hfctmp->ztdev->chans[1].readchunk = hfctmp->brecbuf[1];
++ memset(hfctmp->btransbuf[1], 0x0, sizeof(hfctmp->btransbuf[1]));
++ hfctmp->ztdev->chans[1].writechunk = hfctmp->btransbuf[1];
++
++
++ hfc_registerCard(hfctmp);
++ hfc_resetCard(hfctmp);
++ tmp = pci_get_device(pcivendor, pcidevice, multi_hfc);
++ }
++ return 0;
++}
++
++
++
++int init_module(void) {
++ int i = 0;
++#ifdef RTAITIMING
++ RTIME tick_period;
++ for (i=0; i < hfc_MAX_CARDS; i++) {
++ rtai_hfc_list[i] = NULL;
++ }
++ rt_set_periodic_mode();
++#endif
++ i = 0;
++ while (id_list[i].vendor_id) {
++ multi_hfc = NULL;
++ hfc_findCards(id_list[i].vendor_id, id_list[i].device_id, id_list[i].vendor_name, id_list[i].card_name);
++ i++;
++ }
++#ifdef RTAITIMING
++ for (i=0; i < hfc_MAX_CARDS; i++) {
++ if (rtai_hfc_list[i]) {
++ printk(KERN_INFO
++ "zaphfc: configured %d at mem %#x fifo %#x(%#x) for realtime servicing\n",
++ rtai_hfc_list[i]->cardno,
++ (u_int) rtai_hfc_list[i]->pci_io,
++ (u_int) rtai_hfc_list[i]->fifos,
++ (u_int) virt_to_bus(rtai_hfc_list[i]->fifos));
++
++ }
++ }
++ rt_task_init(&rt_task, rtai_loop, 1, STACK_SIZE, TASK_PRIORITY, 0, 0);
++ tick_period = start_rt_timer(nano2count(TICK_PERIOD));
++ rt_task_make_periodic(&rt_task, rt_get_time() + tick_period, tick_period);
++#endif
++ printk(KERN_INFO "zaphfc: %d hfc-pci card(s) in this box.\n", hfc_dev_count);
++ return 0;
++}
++
++void cleanup_module(void) {
++ struct hfc_card *tmpcard;
++#ifdef RTAITIMING
++ stop_rt_timer();
++ rt_task_delete(&rt_task);
++#endif
++ printk(KERN_INFO "zaphfc: stop\n");
++// spin_lock(&registerlock);
++ while (hfc_dev_list != NULL) {
++ if (hfc_dev_list == NULL) break;
++ hfc_shutdownCard(hfc_dev_list);
++ tmpcard = hfc_dev_list;
++ hfc_dev_list = hfc_dev_list->next;
++ if (tmpcard != NULL) {
++ kfree(tmpcard);
++ tmpcard = NULL;
++ printk(KERN_INFO "zaphfc: freed one card.\n");
++ }
++ }
++// spin_unlock(&registerlock);
++}
++#endif
++
++
++module_param(modes, int, 0600);
++module_param(debug, int, 0600);
++
++MODULE_DESCRIPTION("HFC-S PCI A Zaptel Driver");
++MODULE_AUTHOR("Klaus-Peter Junghanns <kpj@junghanns.net>");
++#ifdef MODULE_LICENSE
++MODULE_LICENSE("GPL");
++#endif
+Index: dahdi-linux-2.1.0/drivers/dahdi/zaphfc.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ dahdi-linux-2.1.0/drivers/dahdi/zaphfc.h 2008-12-10 12:46:14.000000000 +0200
+@@ -0,0 +1,290 @@
++/*
++ * zaphfc.h - Zaptel driver for HFC-S PCI A based ISDN BRI cards
++ *
++ * kernel module based on HFC PCI ISDN4Linux and Zaptel drivers
++ *
++ * Copyright (C) 2002, 2003, 2004, 2005 Junghanns.NET GmbH
++ *
++ * Klaus-Peter Junghanns <kpj@junghanns.net>
++ *
++ * This program is free software and may be modified and
++ * distributed under the terms of the GNU Public License.
++ *
++ */
++
++/* HFC register addresses - accessed using memory mapped I/O */
++/* For a list, see datasheet section 3.2.1 at page 21 */
++
++#define hfc_outb(a,b,c) (writeb((c),(a)->pci_io+(b)))
++#define hfc_inb(a,b) (readb((a)->pci_io+(b)))
++
++/* GCI/IOM bus monitor registers */
++
++#define hfc_C_I 0x08
++#define hfc_TRxR 0x0C
++#define hfc_MON1_D 0x28
++#define hfc_MON2_D 0x2C
++
++
++/* GCI/IOM bus timeslot registers */
++
++#define hfc_B1_SSL 0x80
++#define hfc_B2_SSL 0x84
++#define hfc_AUX1_SSL 0x88
++#define hfc_AUX2_SSL 0x8C
++#define hfc_B1_RSL 0x90
++#define hfc_B2_RSL 0x94
++#define hfc_AUX1_RSL 0x98
++#define hfc_AUX2_RSL 0x9C
++
++/* GCI/IOM bus data registers */
++
++#define hfc_B1_D 0xA0
++#define hfc_B2_D 0xA4
++#define hfc_AUX1_D 0xA8
++#define hfc_AUX2_D 0xAC
++
++/* GCI/IOM bus configuration registers */
++
++#define hfc_MST_EMOD 0xB4
++#define hfc_MST_MODE 0xB8
++#define hfc_CONNECT 0xBC
++
++
++/* Interrupt and status registers */
++
++#define hfc_FIFO_EN 0x44
++#define hfc_TRM 0x48
++#define hfc_B_MODE 0x4C
++#define hfc_CHIP_ID 0x58
++#define hfc_CIRM 0x60
++#define hfc_CTMT 0x64
++#define hfc_INT_M1 0x68
++#define hfc_INT_M2 0x6C
++#define hfc_INT_S1 0x78
++#define hfc_INT_S2 0x7C
++#define hfc_STATUS 0x70
++
++/* S/T section registers */
++
++#define hfc_STATES 0xC0
++#define hfc_SCTRL 0xC4
++#define hfc_SCTRL_E 0xC8
++#define hfc_SCTRL_R 0xCC
++#define hfc_SQ 0xD0
++#define hfc_CLKDEL 0xDC
++#define hfc_B1_REC 0xF0
++#define hfc_B1_SEND 0xF0
++#define hfc_B2_REC 0xF4
++#define hfc_B2_SEND 0xF4
++#define hfc_D_REC 0xF8
++#define hfc_D_SEND 0xF8
++#define hfc_E_REC 0xFC
++
++/* Bits and values in various HFC PCI registers */
++
++/* bits in status register (READ) */
++#define hfc_STATUS_PCI_PROC 0x02
++#define hfc_STATUS_NBUSY 0x04
++#define hfc_STATUS_TIMER_ELAP 0x10
++#define hfc_STATUS_STATINT 0x20
++#define hfc_STATUS_FRAMEINT 0x40
++#define hfc_STATUS_ANYINT 0x80
++
++/* bits in CTMT (Write) */
++#define hfc_CTMT_CLTIMER 0x80
++#define hfc_CTMT_TIM3_125 0x04
++#define hfc_CTMT_TIM25 0x10
++#define hfc_CTMT_TIM50 0x14
++#define hfc_CTMT_TIM400 0x18
++#define hfc_CTMT_TIM800 0x1C
++#define hfc_CTMT_AUTO_TIMER 0x20
++#define hfc_CTMT_TRANSB2 0x02
++#define hfc_CTMT_TRANSB1 0x01
++
++/* bits in CIRM (Write) */
++#define hfc_CIRM_AUX_MSK 0x07
++#define hfc_CIRM_RESET 0x08
++#define hfc_CIRM_B1_REV 0x40
++#define hfc_CIRM_B2_REV 0x80
++
++/* bits in INT_M1 and INT_S1 */
++#define hfc_INTS_B1TRANS 0x01
++#define hfc_INTS_B2TRANS 0x02
++#define hfc_INTS_DTRANS 0x04
++#define hfc_INTS_B1REC 0x08
++#define hfc_INTS_B2REC 0x10
++#define hfc_INTS_DREC 0x20
++#define hfc_INTS_L1STATE 0x40
++#define hfc_INTS_TIMER 0x80
++
++/* bits in INT_M2 */
++#define hfc_M2_PROC_TRANS 0x01
++#define hfc_M2_GCI_I_CHG 0x02
++#define hfc_M2_GCI_MON_REC 0x04
++#define hfc_M2_IRQ_ENABLE 0x08
++#define hfc_M2_PMESEL 0x80
++
++/* bits in STATES */
++#define hfc_STATES_STATE_MASK 0x0F
++#define hfc_STATES_LOAD_STATE 0x10
++#define hfc_STATES_ACTIVATE 0x20
++#define hfc_STATES_DO_ACTION 0x40
++#define hfc_STATES_NT_G2_G3 0x80
++
++/* bits in HFCD_MST_MODE */
++#define hfc_MST_MODE_MASTER 0x01
++#define hfc_MST_MODE_SLAVE 0x00
++/* remaining bits are for codecs control */
++
++/* bits in HFCD_SCTRL */
++#define hfc_SCTRL_B1_ENA 0x01
++#define hfc_SCTRL_B2_ENA 0x02
++#define hfc_SCTRL_MODE_TE 0x00
++#define hfc_SCTRL_MODE_NT 0x04
++#define hfc_SCTRL_LOW_PRIO 0x08
++#define hfc_SCTRL_SQ_ENA 0x10
++#define hfc_SCTRL_TEST 0x20
++#define hfc_SCTRL_NONE_CAP 0x40
++#define hfc_SCTRL_PWR_DOWN 0x80
++
++/* bits in SCTRL_E */
++#define hfc_SCTRL_E_AUTO_AWAKE 0x01
++#define hfc_SCTRL_E_DBIT_1 0x04
++#define hfc_SCTRL_E_IGNORE_COL 0x08
++#define hfc_SCTRL_E_CHG_B1_B2 0x80
++
++/* bits in FIFO_EN register */
++#define hfc_FIFOEN_B1TX 0x01
++#define hfc_FIFOEN_B1RX 0x02
++#define hfc_FIFOEN_B2TX 0x04
++#define hfc_FIFOEN_B2RX 0x08
++#define hfc_FIFOEN_DTX 0x10
++#define hfc_FIFOEN_DRX 0x20
++
++#define hfc_FIFOEN_B1 (hfc_FIFOEN_B1TX|hfc_FIFOEN_B1RX)
++#define hfc_FIFOEN_B2 (hfc_FIFOEN_B2TX|hfc_FIFOEN_B2RX)
++#define hfc_FIFOEN_D (hfc_FIFOEN_DTX|hfc_FIFOEN_DRX)
++
++/* bits in the CONNECT register */
++#define hfc_CONNECT_B1_shift 0
++#define hfc_CONNECT_B2_shift 3
++
++#define hfc_CONNECT_HFC_from_ST 0x0
++#define hfc_CONNECT_HFC_from_GCI 0x1
++#define hfc_CONNECT_ST_from_HFC 0x0
++#define hfc_CONNECT_ST_from_GCI 0x2
++#define hfc_CONNECT_GCI_from_HFC 0x0
++#define hfc_CONNECT_GCI_from_ST 0x4
++
++/* bits in the __SSL and __RSL registers */
++#define hfc_SRSL_STIO 0x40
++#define hfc_SRSL_ENABLE 0x80
++#define hfc_SRCL_SLOT_MASK 0x1f
++
++/* FIFO memory definitions */
++
++#define hfc_FMASK 0x000f
++#define hfc_ZMASK 0x01ff
++#define hfc_ZMASKB 0x1fff
++
++#define hfc_D_FIFO_SIZE 0x0200
++#define hfc_B_SUB_VAL 0x0200
++#define hfc_B_FIFO_SIZE 0x1E00
++#define hfc_MAX_DFRAMES 0x000f
++
++#define hfc_FIFO_DTX_Z1 0x2080
++#define hfc_FIFO_DTX_Z2 0x2082
++#define hfc_FIFO_DTX_F1 0x20a0
++#define hfc_FIFO_DTX_F2 0x20a1
++#define hfc_FIFO_DTX 0x0000
++#define hfc_FIFO_DTX_ZOFF 0x000
++
++#define hfc_FIFO_DRX_Z1 0x6080
++#define hfc_FIFO_DRX_Z2 0x6082
++#define hfc_FIFO_DRX_F1 0x60a0
++#define hfc_FIFO_DRX_F2 0x60a1
++#define hfc_FIFO_DRX 0x4000
++#define hfc_FIFO_DRX_ZOFF 0x4000
++
++#define hfc_FIFO_B1TX_Z1 0x2000
++#define hfc_FIFO_B1TX_Z2 0x2002
++#define hfc_FIFO_B1RX_Z1 0x6000
++#define hfc_FIFO_B1RX_Z2 0x6002
++
++#define hfc_FIFO_B1TX_F1 0x2080
++#define hfc_FIFO_B1TX_F2 0x2081
++#define hfc_FIFO_B1RX_F1 0x6080
++#define hfc_FIFO_B1RX_F2 0x6081
++
++#define hfc_FIFO_B1RX_ZOFF 0x4000
++#define hfc_FIFO_B1TX_ZOFF 0x0000
++
++#define hfc_FIFO_B2TX_Z1 0x2100
++#define hfc_FIFO_B2TX_Z2 0x2102
++#define hfc_FIFO_B2RX_Z1 0x6100
++#define hfc_FIFO_B2RX_Z2 0x6102
++
++#define hfc_FIFO_B2TX_F1 0x2180
++#define hfc_FIFO_B2TX_F2 0x2181
++#define hfc_FIFO_B2RX_F1 0x6180
++#define hfc_FIFO_B2RX_F2 0x6181
++
++#define hfc_FIFO_B2RX_ZOFF 0x6000
++#define hfc_FIFO_B2TX_ZOFF 0x2000
++
++#define hfc_BTRANS_THRESHOLD 128
++#define hfc_BTRANS_THRESMASK 0x00
++
++/* Structures */
++
++typedef struct hfc_regs {
++ unsigned char fifo_en;
++ unsigned char ctmt;
++ unsigned char int_m1;
++ unsigned char int_m2;
++ unsigned char sctrl;
++ unsigned char sctrl_e;
++ unsigned char sctrl_r;
++ unsigned char connect;
++ unsigned char trm;
++ unsigned char mst_mode;
++ unsigned char bswapped;
++ unsigned char nt_mode;
++ unsigned char int_drec;
++} hfc_regs;
++
++typedef struct hfc_card {
++ spinlock_t lock;
++ unsigned int irq;
++ unsigned int iomem;
++ int ticks;
++ int clicks;
++ unsigned char *pci_io;
++ void *fifomem; // start of the shared mem
++ volatile void *fifos; // 32k aligned mem for the fifos
++ struct hfc_regs regs;
++ unsigned int pcibus;
++ unsigned int pcidevfn;
++ struct pci_dev *pcidev;
++ struct dahdi_hfc *ztdev;
++ int drecinframe;
++ unsigned char drecbuf[hfc_D_FIFO_SIZE];
++ unsigned char dtransbuf[hfc_D_FIFO_SIZE];
++ unsigned char brecbuf[2][DAHDI_CHUNKSIZE];
++ unsigned char btransbuf[2][DAHDI_CHUNKSIZE];
++ unsigned char cardno;
++ struct hfc_card *next;
++} hfc_card;
++
++typedef struct dahdi_hfc {
++ unsigned int usecount;
++ struct dahdi_span span;
++ struct dahdi_chan chans[3];
++ struct dahdi_chan *_chans[3];
++ struct hfc_card *card;
++} dahdi_hfc;
++
++/* tune this */
++#define hfc_BCHAN_BUFFER 8
++#define hfc_MAX_CARDS 8
diff --git a/main/dahdi-linux-grsec/zaphfc-dahdi-flortz.diff b/main/dahdi-linux-grsec/zaphfc-dahdi-flortz.diff
new file mode 100644
index 00000000000..719accdc690
--- /dev/null
+++ b/main/dahdi-linux-grsec/zaphfc-dahdi-flortz.diff
@@ -0,0 +1,1232 @@
+Index: dahdi-linux-2.1.0.4/drivers/dahdi/zaphfc.h
+===================================================================
+--- dahdi-linux-2.1.0.4.orig/drivers/dahdi/zaphfc.h 2009-03-17 18:13:54.000000000 +0200
++++ dahdi-linux-2.1.0.4/drivers/dahdi/zaphfc.h 2009-03-17 18:14:44.000000000 +0200
+@@ -135,8 +135,12 @@
+ /* bits in HFCD_MST_MODE */
+ #define hfc_MST_MODE_MASTER 0x01
+ #define hfc_MST_MODE_SLAVE 0x00
++#define hfc_MST_MODE_F0_LONG_DURATION 0x08
+ /* remaining bits are for codecs control */
+
++/* bits in HFCD_MST_EMOD */
++#define hfc_MST_EMOD_SLOW_CLOCK_ADJ 0x01
++
+ /* bits in HFCD_SCTRL */
+ #define hfc_SCTRL_B1_ENA 0x01
+ #define hfc_SCTRL_B2_ENA 0x02
+@@ -236,6 +240,9 @@
+ #define hfc_BTRANS_THRESHOLD 128
+ #define hfc_BTRANS_THRESMASK 0x00
+
++#define hfc_FIFO_MEM_SIZE_BYTES (32*1024)
++#define hfc_FIFO_MEM_SIZE_PAGES ((hfc_FIFO_MEM_SIZE_BYTES+PAGE_SIZE-1)/PAGE_SIZE)
++
+ /* Structures */
+
+ typedef struct hfc_regs {
+@@ -249,20 +256,67 @@
+ unsigned char connect;
+ unsigned char trm;
+ unsigned char mst_mode;
++ unsigned char mst_emod;
+ unsigned char bswapped;
+ unsigned char nt_mode;
+ unsigned char int_drec;
+ } hfc_regs;
+
++struct bch {
++ int fill_fifo,checkcnt,initialized;
++ struct {
++ u16 z2;
++ struct {
++ volatile u16 *z1p;
++ volatile u8 *fifo_base;
++ int filled;
++ } c[2];
++ int diff;
++ } rx;
++ struct {
++ u16 z1;
++ struct {
++ volatile u16 *z1p,*z2p;
++ volatile u8 *fifo_base;
++ int filled;
++ } c[2];
++ int diff;
++ } tx;
++};
++
++struct dch {
++ struct {
++ struct {
++ volatile u8 *p;
++ } f1;
++ struct {
++ u8 v;
++ struct {
++ u16 v;
++ } z2;
++ } f2;
++ } rx;
++ struct {
++ struct {
++ u8 v;
++ volatile u8 *p;
++ struct {
++ u16 v;
++ } z1;
++ } f1;
++ struct {
++ volatile u8 *p;
++ } f2;
++ } tx;
++};
++
+ typedef struct hfc_card {
+ spinlock_t lock;
+ unsigned int irq;
+ unsigned int iomem;
+ int ticks;
+- int clicks;
+ unsigned char *pci_io;
+- void *fifomem; // start of the shared mem
+- volatile void *fifos; // 32k aligned mem for the fifos
++ void *fifos; // 32k aligned mem for the fifos
+ struct hfc_regs regs;
+ unsigned int pcibus;
+ unsigned int pcidevfn;
+@@ -274,6 +328,9 @@
+ unsigned char brecbuf[2][DAHDI_CHUNKSIZE];
+ unsigned char btransbuf[2][DAHDI_CHUNKSIZE];
+ unsigned char cardno;
++ int active;
++ struct bch bch;
++ struct dch dch;
+ struct hfc_card *next;
+ } hfc_card;
+
+@@ -285,6 +342,3 @@
+ struct hfc_card *card;
+ } dahdi_hfc;
+
+-/* tune this */
+-#define hfc_BCHAN_BUFFER 8
+-#define hfc_MAX_CARDS 8
+Index: dahdi-linux-2.1.0.4/drivers/dahdi/zaphfc.c
+===================================================================
+--- dahdi-linux-2.1.0.4.orig/drivers/dahdi/zaphfc.c 2009-03-17 18:52:47.000000000 +0200
++++ dahdi-linux-2.1.0.4/drivers/dahdi/zaphfc.c 2009-03-17 18:53:43.000000000 +0200
+@@ -7,19 +7,21 @@
+ *
+ * Klaus-Peter Junghanns <kpj@junghanns.net>
+ *
++ * Copyright (C) 2004, 2005, 2006 Florian Zumbiehl <florz@gmx.de>
++ * - support for slave mode of the HFC-S chip which allows it to
++ * sync its sample clock to an external source/another HFC chip
++ * - support for "interrupt bundling" (let only one card generate
++ * 8 kHz timing interrupt no matter how many cards there are
++ * in the system)
++ * - interrupt loss tolerant b channel handling
++ *
+ * This program is free software and may be modified and
+- * distributed under the terms of the GNU Public License.
++ * distributed under the terms of the GNU General Public License.
+ *
+ */
+
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+-#ifdef RTAITIMING
+-#include <asm/io.h>
+-#include <rtai.h>
+-#include <rtai_sched.h>
+-#include <rtai_fifos.h>
+-#endif
+ #include <linux/pci.h>
+ #include <linux/init.h>
+ #include <linux/interrupt.h>
+@@ -29,6 +31,8 @@
+
+ #include <linux/moduleparam.h>
+
++#define log2(n) ffz(~(n))
++
+ #if CONFIG_PCI
+
+ #define CLKDEL_TE 0x0f /* CLKDEL in TE mode */
+@@ -70,42 +74,31 @@
+ static struct hfc_card *hfc_dev_list = NULL;
+ static int hfc_dev_count = 0;
+ static int modes = 0; // all TE
++static int sync_slave = 0; // all master
++static int timer_card = 0;
++static int jitterbuffer = 1;
+ static int debug = 0;
+ static struct pci_dev *multi_hfc = NULL;
+ static spinlock_t registerlock = SPIN_LOCK_UNLOCKED;
+
+-void hfc_shutdownCard(struct hfc_card *hfctmp) {
+- unsigned long flags;
+-
+- if (hfctmp == NULL) {
+- return;
+- }
+-
+- if (hfctmp->pci_io == NULL) {
+- return;
+- }
+-
+- spin_lock_irqsave(&hfctmp->lock,flags);
+-
++void hfc_shutdownCard1(struct hfc_card *hfctmp) {
+ printk(KERN_INFO "zaphfc: shutting down card at %p.\n",hfctmp->pci_io);
+
+ /* Clear interrupt mask */
+ hfctmp->regs.int_m2 = 0;
+ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
+
+- /* Reset pending interrupts */
+- hfc_inb(hfctmp, hfc_INT_S1);
++ /* Remove interrupt handler */
++ free_irq(hfctmp->irq,hfctmp);
++}
++
++void hfc_shutdownCard2(struct hfc_card *hfctmp) {
++ unsigned long flags;
+
+- /* Wait for interrupts that might still be pending */
+- spin_unlock_irqrestore(&hfctmp->lock, flags);
+- set_current_state(TASK_UNINTERRUPTIBLE);
+- schedule_timeout((30 * HZ) / 1000); // wait 30 ms
+ spin_lock_irqsave(&hfctmp->lock,flags);
+
+- /* Remove interrupt handler */
+- if (hfctmp->irq) {
+- free_irq(hfctmp->irq, hfctmp);
+- }
++ /* Reset pending interrupts */
++ hfc_inb(hfctmp, hfc_INT_S1);
+
+ /* Soft-reset the card */
+ hfc_outb(hfctmp, hfc_CIRM, hfc_CIRM_RESET); // softreset on
+@@ -119,8 +112,8 @@
+
+ pci_write_config_word(hfctmp->pcidev, PCI_COMMAND, 0); // disable memio and bustmaster
+
+- if (hfctmp->fifomem != NULL) {
+- kfree(hfctmp->fifomem);
++ if (hfctmp->fifos != NULL) {
++ free_pages((unsigned long)hfctmp->fifos,log2(hfc_FIFO_MEM_SIZE_PAGES));
+ }
+ iounmap((void *) hfctmp->pci_io);
+ hfctmp->pci_io = NULL;
+@@ -130,11 +123,24 @@
+ spin_unlock_irqrestore(&hfctmp->lock,flags);
+ if (hfctmp->ztdev != NULL) {
+ dahdi_unregister(&hfctmp->ztdev->span);
+- kfree(hfctmp->ztdev);
++ vfree(hfctmp->ztdev);
+ printk(KERN_INFO "unregistered from DAHDI.\n");
+ }
+ }
+
++void hfc_shutdownCard(struct hfc_card *hfctmp) {
++ if (hfctmp == NULL) {
++ return;
++ }
++
++ if (hfctmp->pci_io == NULL) {
++ return;
++ }
++
++ hfc_shutdownCard1(hfctmp);
++ hfc_shutdownCard2(hfctmp);
++}
++
+ void hfc_resetCard(struct hfc_card *hfctmp) {
+ unsigned long flags;
+
+@@ -178,14 +184,14 @@
+ hfctmp->regs.ctmt = hfc_CTMT_TRANSB1 | hfc_CTMT_TRANSB2; // all bchans are transparent , no freaking hdlc
+ hfc_outb(hfctmp, hfc_CTMT, hfctmp->regs.ctmt);
+
+- hfctmp->regs.int_m1 = 0;
++ hfctmp->regs.int_m1=hfc_INTS_L1STATE;
++ if(hfctmp->cardno==timer_card){
++ hfctmp->regs.int_m2=hfc_M2_PROC_TRANS;
++ }else{
++ hfctmp->regs.int_m1|=hfc_INTS_DREC;
++ hfctmp->regs.int_m2=0;
++ }
+ hfc_outb(hfctmp, hfc_INT_M1, hfctmp->regs.int_m1);
+-
+-#ifdef RTAITIMING
+- hfctmp->regs.int_m2 = 0;
+-#else
+- hfctmp->regs.int_m2 = hfc_M2_PROC_TRANS;
+-#endif
+ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
+
+ /* Clear already pending ints */
+@@ -197,8 +203,8 @@
+ hfctmp->regs.sctrl = 3 | hfc_SCTRL_NONE_CAP | hfc_SCTRL_MODE_TE; /* set tx_lo mode, error in datasheet ! */
+ }
+
+- hfctmp->regs.mst_mode = hfc_MST_MODE_MASTER; /* HFC Master Mode */
+ hfc_outb(hfctmp, hfc_MST_MODE, hfctmp->regs.mst_mode);
++ hfc_outb(hfctmp, hfc_MST_EMOD, hfctmp->regs.mst_emod);
+
+ hfc_outb(hfctmp, hfc_SCTRL, hfctmp->regs.sctrl);
+ hfctmp->regs.sctrl_r = 3;
+@@ -210,10 +216,8 @@
+ hfc_outb(hfctmp, hfc_CIRM, 0x80 | 0x40); // bit order
+
+ /* Finally enable IRQ output */
+-#ifndef RTAITIMING
+ hfctmp->regs.int_m2 |= hfc_M2_IRQ_ENABLE;
+ hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
+-#endif
+
+ /* clear pending ints */
+ hfc_inb(hfctmp, hfc_INT_S1);
+@@ -230,368 +234,210 @@
+ spin_unlock(&registerlock);
+ }
+
+-static void hfc_btrans(struct hfc_card *hfctmp, char whichB) {
+- // we are called with irqs disabled from the irq handler
+- int count, maxlen, total;
+- unsigned char *f1, *f2;
+- unsigned short *z1, *z2, newz1;
+- int freebytes;
+-
+- if (whichB == 1) {
+- f1 = (char *)(hfctmp->fifos + hfc_FIFO_B1TX_F1);
+- f2 = (char *)(hfctmp->fifos + hfc_FIFO_B1TX_F2);
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1TX_Z1 + (*f1 * 4));
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1TX_Z2 + (*f1 * 4));
+- } else {
+- f1 = (char *)(hfctmp->fifos + hfc_FIFO_B2TX_F1);
+- f2 = (char *)(hfctmp->fifos + hfc_FIFO_B2TX_F2);
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2TX_Z1 + (*f1 * 4));
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2TX_Z2 + (*f1 * 4));
+- }
+-
+- freebytes = *z2 - *z1;
+- if (freebytes <= 0) {
+- freebytes += hfc_B_FIFO_SIZE;
+- }
+- count = DAHDI_CHUNKSIZE;
+-
+- total = count;
+- if (freebytes < count) {
+- hfctmp->clicks++;
+- /* only spit out this warning once per second to not make things worse! */
+- if (hfctmp->clicks > 100) {
+- printk(KERN_CRIT "zaphfc: bchan tx fifo full, dropping audio! (z1=%d, z2=%d)\n",*z1,*z2);
+- hfctmp->clicks = 0;
+- }
+- return;
+- }
+-
+- maxlen = (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL) - *z1;
+- if (maxlen > count) {
+- maxlen = count;
+- }
+- newz1 = *z1 + total;
+- if (newz1 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) { newz1 -= hfc_B_FIFO_SIZE; }
++/*===========================================================================*/
+
+- if (whichB == 1) {
+- memcpy((char *)(hfctmp->fifos + hfc_FIFO_B1TX_ZOFF + *z1),hfctmp->ztdev->chans[0].writechunk, maxlen);
+- } else {
+- memcpy((char *)(hfctmp->fifos + hfc_FIFO_B2TX_ZOFF + *z1),hfctmp->ztdev->chans[1].writechunk, maxlen);
+- }
+-
+- count -= maxlen;
+- if (count > 0) {
+- // Buffer wrap
+- if (whichB == 1) {
+- memcpy((char *)(hfctmp->fifos + hfc_FIFO_B1TX_ZOFF + hfc_B_SUB_VAL),hfctmp->ztdev->chans[0].writechunk+maxlen, count);
+- } else {
+- memcpy((char *)(hfctmp->fifos + hfc_FIFO_B2TX_ZOFF + hfc_B_SUB_VAL),hfctmp->ztdev->chans[1].writechunk+maxlen, count);
+- }
+- }
++#if hfc_B_FIFO_SIZE%DAHDI_CHUNKSIZE
++#error hfc_B_FIFO_SIZE is not a multiple of DAHDI_CHUNKSIZE even though the code assumes this
++#endif
++
++static void hfc_dch_init(struct hfc_card *hfctmp){
++ struct dch *chtmp=&hfctmp->dch;
+
+- *z1 = newz1; /* send it now */
++ chtmp->rx.f1.p=(u8 *)(hfctmp->fifos+hfc_FIFO_DRX_F1);
++ chtmp->rx.f2.v=0x1f;
++ chtmp->rx.f2.z2.v=0x1ff;
+
+-// if (count > 0) printk(KERN_CRIT "zaphfc: bchan tx fifo (f1=%d, f2=%d, z1=%d, z2=%d)\n",(*f1) & hfc_FMASK,(*f2) & hfc_FMASK, *z1, *z2);
+- return;
++ chtmp->tx.f1.p=(u8 *)(hfctmp->fifos+hfc_FIFO_DTX_F1);
++ chtmp->tx.f1.v=0x1f;
++ chtmp->tx.f1.z1.v=0x1ff;
++ chtmp->tx.f2.p=(u8 *)(hfctmp->fifos+hfc_FIFO_DTX_F2);
+ }
+
+-static void hfc_brec(struct hfc_card *hfctmp, char whichB) {
+- // we are called with irqs disabled from the irq handler
+- int count, maxlen, drop;
+- volatile unsigned char *f1, *f2;
+- volatile unsigned short *z1, *z2, newz2;
+- int bytes = 0;
+-
+- if (whichB == 1) {
+- f1 = (char *)(hfctmp->fifos + hfc_FIFO_B1RX_F1);
+- f2 = (char *)(hfctmp->fifos + hfc_FIFO_B1RX_F2);
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1RX_Z1 + (*f1 * 4));
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1RX_Z2 + (*f1 * 4));
+- } else {
+- f1 = (char *)(hfctmp->fifos + hfc_FIFO_B2RX_F1);
+- f2 = (char *)(hfctmp->fifos + hfc_FIFO_B2RX_F2);
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2RX_Z1 + (*f1 * 4));
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2RX_Z2 + (*f1 * 4));
+- }
++static void hfc_bch_init(struct hfc_card *hfctmp){
++ struct bch *chtmp=&hfctmp->bch;
+
+- bytes = *z1 - *z2;
+- if (bytes < 0) {
+- bytes += hfc_B_FIFO_SIZE;
+- }
+- count = DAHDI_CHUNKSIZE;
+-
+- if (bytes < DAHDI_CHUNKSIZE) {
+-#ifndef RTAITIMING
+- printk(KERN_CRIT "zaphfc: bchan rx fifo not enough bytes to receive! (z1=%d, z2=%d, wanted %d got %d), probably a buffer overrun.\n",*z1,*z2,DAHDI_CHUNKSIZE,bytes);
+-#endif
+- return;
+- }
++ chtmp->checkcnt=0;
++ chtmp->fill_fifo=0;
+
+- /* allowing the buffering of hfc_BCHAN_BUFFER bytes of audio data works around irq jitter */
+- if (bytes > hfc_BCHAN_BUFFER + DAHDI_CHUNKSIZE) {
+- /* if the system is too slow to handle it, we will have to drop it all (except 1 DAHDI chunk) */
+- drop = bytes - DAHDI_CHUNKSIZE;
+- hfctmp->clicks++;
+- /* only spit out this warning once per second to not make things worse! */
+- if (hfctmp->clicks > 100) {
+- printk(KERN_CRIT "zaphfc: dropped audio (z1=%d, z2=%d, wanted %d got %d, dropped %d).\n",*z1,*z2,count,bytes,drop);
+- hfctmp->clicks = 0;
+- }
+- /* hm, we are processing the b chan data tooooo slowly... let's drop the lost audio */
+- newz2 = *z2 + drop;
+- if (newz2 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) {
+- newz2 -= hfc_B_FIFO_SIZE;
+- }
+- *z2 = newz2;
+- }
++ chtmp->rx.c[0].z1p=(unsigned short *)(hfctmp->fifos+hfc_FIFO_B1RX_Z1+0x1f*4);
++ chtmp->rx.c[0].fifo_base=(char *)(hfctmp->fifos+hfc_FIFO_B1RX_ZOFF);
++ chtmp->rx.c[1].z1p=(unsigned short *)(hfctmp->fifos+hfc_FIFO_B2RX_Z1+0x1f*4);
++ chtmp->rx.c[1].fifo_base=(char *)(hfctmp->fifos+hfc_FIFO_B2RX_ZOFF);
++ chtmp->rx.z2=hfc_B_SUB_VAL;
++ chtmp->rx.diff=0;
+
+-
+- maxlen = (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL) - *z2;
+- if (maxlen > count) {
+- maxlen = count;
+- }
+- if (whichB == 1) {
+- memcpy(hfctmp->ztdev->chans[0].readchunk,(char *)(hfctmp->fifos + hfc_FIFO_B1RX_ZOFF + *z2), maxlen);
+- } else {
+- memcpy(hfctmp->ztdev->chans[1].readchunk,(char *)(hfctmp->fifos + hfc_FIFO_B2RX_ZOFF + *z2), maxlen);
+- }
+- newz2 = *z2 + count;
+- if (newz2 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) {
+- newz2 -= hfc_B_FIFO_SIZE;
++ chtmp->tx.c[0].z1p=(unsigned short *)(hfctmp->fifos+hfc_FIFO_B1TX_Z1+0x1f*4);
++ chtmp->tx.c[0].z2p=(unsigned short *)(hfctmp->fifos+hfc_FIFO_B1TX_Z2+0x1f*4);
++ chtmp->tx.c[0].fifo_base=(char *)(hfctmp->fifos+hfc_FIFO_B1TX_ZOFF);
++ chtmp->tx.c[0].filled=0;
++ chtmp->tx.c[1].z1p=(unsigned short *)(hfctmp->fifos+hfc_FIFO_B2TX_Z1+0x1f*4);
++ chtmp->tx.c[1].z2p=(unsigned short *)(hfctmp->fifos+hfc_FIFO_B2TX_Z2+0x1f*4);
++ chtmp->tx.c[1].fifo_base=(char *)(hfctmp->fifos+hfc_FIFO_B2TX_ZOFF);
++ chtmp->tx.c[1].filled=0;
++ chtmp->tx.z1=hfc_B_SUB_VAL;
++ chtmp->tx.diff=0;
++
++ hfc_dch_init(hfctmp);
++
++ chtmp->initialized=0;
++}
++
++static int hfc_bch_check(struct hfc_card *hfctmp){
++ struct bch *chtmp=&hfctmp->bch;
++ int x,r;
++
++ for(x=0;x<2;x++){
++ chtmp->tx.c[x].filled=(chtmp->tx.z1-*chtmp->tx.c[x].z2p+hfc_B_FIFO_SIZE)%hfc_B_FIFO_SIZE;
++ chtmp->rx.c[x].filled=(*chtmp->rx.c[x].z1p-chtmp->rx.z2+hfc_B_FIFO_SIZE)%hfc_B_FIFO_SIZE;
+ }
+- *z2 = newz2;
+-
+- count -= maxlen;
+- if (count > 0) {
+- // Buffer wrap
+- if (whichB == 1) {
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B1RX_Z2 + (*f1 * 4));
+- memcpy(hfctmp->ztdev->chans[0].readchunk + maxlen,(char *)(hfctmp->fifos + hfc_FIFO_B1RX_ZOFF + hfc_B_SUB_VAL), count);
+- } else {
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_B2RX_Z2 + (*f1 * 4));
+- memcpy(hfctmp->ztdev->chans[1].readchunk + maxlen,(char *)(hfctmp->fifos + hfc_FIFO_B2RX_ZOFF + hfc_B_SUB_VAL), count);
+- }
+- newz2 = *z2 + count;
+- if (newz2 >= (hfc_B_FIFO_SIZE + hfc_B_SUB_VAL)) {
+- newz2 -= hfc_B_FIFO_SIZE;
++ if(chtmp->fill_fifo){
++ chtmp->checkcnt++;
++ chtmp->checkcnt%=DAHDI_CHUNKSIZE;
++ r=!chtmp->checkcnt;
++ }else{
++ x=chtmp->tx.c[0].filled-chtmp->tx.c[1].filled;
++ if(abs(x-chtmp->tx.diff)>1){
++ printk(KERN_CRIT "zaphfc[%d]: tx sync changed: %d, %d\n",hfctmp->cardno,chtmp->tx.c[0].filled,chtmp->tx.c[1].filled);
++ chtmp->tx.diff=x;
+ }
++ r=chtmp->tx.c[0].filled<=DAHDI_CHUNKSIZE*jitterbuffer&&chtmp->tx.c[1].filled<=DAHDI_CHUNKSIZE*jitterbuffer;
+ }
++ return(r);
++}
+
++#define hfc_bch_inc_z(a,b) (a)=((a)-hfc_B_SUB_VAL+(b))%hfc_B_FIFO_SIZE+hfc_B_SUB_VAL
+
+- if (whichB == 1) {
+- dahdi_ec_chunk(&hfctmp->ztdev->chans[0], hfctmp->ztdev->chans[0].readchunk, hfctmp->ztdev->chans[0].writechunk);
+- } else {
+- dahdi_ec_chunk(&hfctmp->ztdev->chans[1], hfctmp->ztdev->chans[1].readchunk, hfctmp->ztdev->chans[1].writechunk);
++static void hfc_bch_tx(struct hfc_card *hfctmp){
++ struct bch *chtmp=&hfctmp->bch;
++ int x;
++
++ for(x=0;x<2;x++)
++ memcpy((void *)(chtmp->tx.c[x].fifo_base+chtmp->tx.z1),hfctmp->ztdev->chans[x].writechunk,DAHDI_CHUNKSIZE);
++ hfc_bch_inc_z(chtmp->tx.z1,DAHDI_CHUNKSIZE);
++ if(chtmp->fill_fifo){
++ chtmp->fill_fifo--;
++ }else if(chtmp->tx.c[0].filled<=1||chtmp->tx.c[1].filled<=1){
++ chtmp->fill_fifo=jitterbuffer;
++ if(chtmp->initialized)
++ printk(KERN_CRIT "zaphfc[%d]: b channel buffer underrun: %d, %d\n",hfctmp->cardno,chtmp->tx.c[0].filled,chtmp->tx.c[1].filled);
+ }
+- return;
++ if(!chtmp->fill_fifo)
++ for(x=0;x<2;x++)*chtmp->tx.c[x].z1p=chtmp->tx.z1;
+ }
+
+-
+-static void hfc_dtrans(struct hfc_card *hfctmp) {
+- // we are called with irqs disabled from the irq handler
++static void hfc_bch_rx(struct hfc_card *hfctmp){
++ struct bch *chtmp=&hfctmp->bch;
+ int x;
+- int count, maxlen, total;
+- unsigned char *f1, *f2, newf1;
+- unsigned short *z1, *z2, newz1;
+- int frames, freebytes;
+
+- if (hfctmp->ztdev->chans[2].bytes2transmit == 0) {
+- return;
++ x=chtmp->rx.c[0].filled-chtmp->rx.c[1].filled;
++ if(abs(x-chtmp->rx.diff)>1){
++ printk(KERN_CRIT "zaphfc[%d]: rx sync changed: %d, %d\n",hfctmp->cardno,chtmp->rx.c[0].filled,chtmp->rx.c[1].filled);
++ chtmp->rx.diff=x;
+ }
+-
+- f1 = (char *)(hfctmp->fifos + hfc_FIFO_DTX_F1);
+- f2 = (char *)(hfctmp->fifos + hfc_FIFO_DTX_F2);
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DTX_Z1 + (*f1 * 4));
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DTX_Z2 + (*f1 * 4));
+-
+- frames = (*f1 - *f2) & hfc_FMASK;
+- if (frames < 0) {
+- frames += hfc_MAX_DFRAMES + 1;
++ if(chtmp->rx.c[0].filled>=DAHDI_CHUNKSIZE&&chtmp->rx.c[1].filled>=DAHDI_CHUNKSIZE){
++ if((chtmp->rx.c[0].filled>=DAHDI_CHUNKSIZE*(jitterbuffer+2)&&chtmp->rx.c[1].filled>=DAHDI_CHUNKSIZE*(jitterbuffer+2))||!chtmp->initialized){
++ if(chtmp->initialized)
++ printk(KERN_CRIT "zaphfc[%d]: b channel buffer overflow: %d, %d\n",hfctmp->cardno,chtmp->rx.c[0].filled,chtmp->rx.c[1].filled);
++ hfc_bch_inc_z(chtmp->rx.z2,chtmp->rx.c[0].filled-chtmp->rx.c[0].filled%DAHDI_CHUNKSIZE-DAHDI_CHUNKSIZE);
++ chtmp->initialized=1;
++ }
++ for(x=0;x<2;x++){
++ memcpy(hfctmp->ztdev->chans[x].readchunk,(void *)(chtmp->rx.c[x].fifo_base+chtmp->rx.z2),DAHDI_CHUNKSIZE);
++ dahdi_ec_chunk(&hfctmp->ztdev->chans[x],hfctmp->ztdev->chans[x].readchunk,hfctmp->ztdev->chans[x].writechunk);
++ }
++ hfc_bch_inc_z(chtmp->rx.z2,DAHDI_CHUNKSIZE);
+ }
++}
+
+- if (frames >= hfc_MAX_DFRAMES) {
+- printk(KERN_CRIT "zaphfc: dchan tx fifo total number of frames exceeded!\n");
+- return;
+- }
++/*===========================================================================*/
+
+- freebytes = *z2 - *z1;
+- if (freebytes <= 0) {
+- freebytes += hfc_D_FIFO_SIZE;
+- }
+- count = hfctmp->ztdev->chans[2].bytes2transmit;
+-
+- total = count;
+- if (freebytes < count) {
+- printk(KERN_CRIT "zaphfc: dchan tx fifo not enough free bytes! (z1=%d, z2=%d)\n",*z1,*z2);
+- return;
+- }
+-
+- newz1 = (*z1 + count) & hfc_ZMASK;
+- newf1 = ((*f1 + 1) & hfc_MAX_DFRAMES) | (hfc_MAX_DFRAMES + 1); // next frame
+-
+- if (count > 0) {
+- if (debug) {
+- printk(KERN_CRIT "zaphfc: card %d TX [ ", hfctmp->cardno);
+- for (x=0; x<count; x++) {
++static void hfc_dch_tx(struct hfc_card *hfctmp){
++ struct dch *chtmp=&hfctmp->dch;
++ u8 tx_f2_v;
++ u16 x;
++
++ if(hfctmp->ztdev->chans[2].bytes2transmit){
++ if(debug){
++ printk(KERN_CRIT "zaphfc[%d]: card TX [ ",hfctmp->cardno);
++ for(x=0;x<hfctmp->ztdev->chans[2].bytes2transmit;x++){
+ printk("%#2x ",hfctmp->dtransbuf[x]);
+ }
+- if (hfctmp->ztdev->chans[2].eoftx == 1) {
+- printk("] %d bytes\n", count);
+- } else {
+- printk("..] %d bytes\n", count);
+- }
+- }
+- maxlen = hfc_D_FIFO_SIZE - *z1;
+- if (maxlen > count) {
+- maxlen = count;
++ printk("] %d bytes\n",hfctmp->ztdev->chans[2].bytes2transmit);
+ }
+- memcpy((char *)(hfctmp->fifos + hfc_FIFO_DTX_ZOFF + *z1),hfctmp->ztdev->chans[2].writechunk, maxlen);
+- count -= maxlen;
+- if (count > 0) {
+- memcpy((char *)(hfctmp->fifos + hfc_FIFO_DTX_ZOFF),(char *)(hfctmp->ztdev->chans[2].writechunk + maxlen), count);
++ tx_f2_v=*chtmp->tx.f2.p;
++ if(!(tx_f2_v-chtmp->tx.f1.v+hfc_MAX_DFRAMES+1-1)&(hfc_MAX_DFRAMES+1-1)){
++ printk(KERN_CRIT "zaphfc[%d]: dchan tx fifo total number of frames exceeded!\n",hfctmp->cardno);
++ }else{
++ if(((*(volatile u16 *)(hfctmp->fifos+hfc_FIFO_DTX_Z2+tx_f2_v*4)-chtmp->tx.f1.z1.v+hfc_D_FIFO_SIZE-1)&(hfc_D_FIFO_SIZE-1))<hfctmp->ztdev->chans[2].bytes2transmit){
++ printk(KERN_CRIT "zaphfc[%d]: dchan tx fifo not enough space for frame!\n",hfctmp->cardno);
++ }else{
++ chtmp->tx.f1.v=((chtmp->tx.f1.v+1)&hfc_MAX_DFRAMES)|(hfc_MAX_DFRAMES+1);
++ x=min(hfctmp->ztdev->chans[2].bytes2transmit,hfc_D_FIFO_SIZE-chtmp->tx.f1.z1.v);
++ memcpy(hfctmp->fifos+hfc_FIFO_DTX_ZOFF+chtmp->tx.f1.z1.v,hfctmp->ztdev->chans[2].writechunk,x);
++ memcpy(hfctmp->fifos+hfc_FIFO_DTX_ZOFF,hfctmp->ztdev->chans[2].writechunk+x,hfctmp->ztdev->chans[2].bytes2transmit-x);
++ *(volatile u16 *)(hfctmp->fifos+hfc_FIFO_DTX_Z2+chtmp->tx.f1.v*4)=chtmp->tx.f1.z1.v;
++ chtmp->tx.f1.z1.v=(chtmp->tx.f1.z1.v+hfctmp->ztdev->chans[2].bytes2transmit+hfc_D_FIFO_SIZE)&(hfc_D_FIFO_SIZE-1);
++ *(volatile u16 *)(hfctmp->fifos+hfc_FIFO_DTX_Z1+chtmp->tx.f1.v*4)=chtmp->tx.f1.z1.v;
++ *chtmp->tx.f1.p=chtmp->tx.f1.v;
++ }
+ }
+ }
+-
+- *z1 = newz1;
+-
+- if (hfctmp->ztdev->chans[2].eoftx == 1) {
+- *f1 = newf1;
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DTX_Z1 + (*f1 * 4));
+- *z1 = newz1;
+- hfctmp->ztdev->chans[2].eoftx = 0;
+- }
+-// printk(KERN_CRIT "zaphfc: dchan tx fifo (f1=%d, f2=%d, z1=%d, z2=%d)\n",(*f1) & hfc_FMASK,(*f2) & hfc_FMASK, *z1, *z2);
+- return;
+ }
+
+-/* receive a complete hdlc frame, skip broken or short frames */
+-static void hfc_drec(struct hfc_card *hfctmp) {
+- int count=0, maxlen=0, framelen=0;
+- unsigned char *f1, *f2, *crcstat;
+- unsigned short *z1, *z2, oldz2, newz2;
++static void hfc_dch_rx(struct hfc_card *hfctmp){
++ struct dch *chtmp=&hfctmp->dch;
++ u16 size;
+
+ hfctmp->ztdev->chans[2].bytes2receive=0;
+- hfctmp->ztdev->chans[2].eofrx = 0;
+-
+- /* put the received data into the DAHDI buffer
+- we'll call dahdi_receive() later when the timer fires. */
+- f1 = (char *)(hfctmp->fifos + hfc_FIFO_DRX_F1);
+- f2 = (char *)(hfctmp->fifos + hfc_FIFO_DRX_F2);
+-
+- if (*f1 == *f2) return; /* nothing received, strange eh? */
+-
+- z1 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z1 + (*f2 * 4));
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z2 + (*f2 * 4));
+-
+- /* calculate length of frame, including 2 bytes CRC and 1 byte STAT */
+- count = *z1 - *z2;
+-
+- if (count < 0) {
+- count += hfc_D_FIFO_SIZE; /* ring buffer wrapped */
+- }
+- count++;
+- framelen = count;
+-
+- crcstat = (char *)(hfctmp->fifos + hfc_FIFO_DRX_ZOFF + *z1);
+-
+- if ((framelen < 4) || (*crcstat != 0x0)) {
+- /* the frame is too short for a valid HDLC frame or the CRC is borked */
+- printk(KERN_CRIT "zaphfc: empty HDLC frame or bad CRC received (framelen = %d, stat = %#x, card = %d).\n", framelen, *crcstat, hfctmp->cardno);
+- oldz2 = *z2;
+- *f2 = ((*f2 + 1) & hfc_MAX_DFRAMES) | (hfc_MAX_DFRAMES + 1); /* NEXT!!! */
+- // recalculate z2, because Z2 is a function of F2 Z2(F2) and we INCed F2!!!
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z2 + (*f2 * 4));
+- *z2 = (oldz2 + framelen) & hfc_ZMASK;
+- hfctmp->drecinframe = 0;
+- hfctmp->regs.int_drec--;
+- /* skip short or broken frames */
+- hfctmp->ztdev->chans[2].bytes2receive = 0;
+- return;
+- }
+-
+- count -= 1; /* strip STAT */
+- hfctmp->ztdev->chans[2].eofrx = 1;
+-
+- if (count + *z2 <= hfc_D_FIFO_SIZE) {
+- maxlen = count;
+- } else {
+- maxlen = hfc_D_FIFO_SIZE - *z2;
++ hfctmp->ztdev->chans[2].eofrx=0;
++ if(*chtmp->rx.f1.p==chtmp->rx.f2.v){
++ hfctmp->regs.int_drec=0;
++ }else{
++ size=((*(volatile u16 *)(hfctmp->fifos+hfc_FIFO_DRX_Z1+chtmp->rx.f2.v*4)-chtmp->rx.f2.z2.v+hfc_D_FIFO_SIZE)&(hfc_D_FIFO_SIZE-1))+1;
++ if(size<4){
++ printk(KERN_CRIT "zaphfc[%d]: empty HDLC frame received.\n",hfctmp->cardno);
++ }else{
++ u16 x=min(size,(u16)(hfc_D_FIFO_SIZE-chtmp->rx.f2.z2.v));
++ memcpy(hfctmp->drecbuf,hfctmp->fifos+hfc_FIFO_DRX_ZOFF+chtmp->rx.f2.z2.v,x);
++ memcpy(hfctmp->drecbuf+x,hfctmp->fifos+hfc_FIFO_DRX_ZOFF,size-x);
++ if(hfctmp->drecbuf[size-1]){
++ printk(KERN_CRIT "zaphfc[%d]: received d channel frame with bad CRC.\n",hfctmp->cardno);
++ }else{
++ hfctmp->ztdev->chans[2].bytes2receive=size-1;
++ hfctmp->ztdev->chans[2].eofrx=1;
++ }
++ }
++ chtmp->rx.f2.z2.v=(chtmp->rx.f2.z2.v+size)&(hfc_D_FIFO_SIZE-1);
++ chtmp->rx.f2.v=((chtmp->rx.f2.v+1)&hfc_MAX_DFRAMES)|(hfc_MAX_DFRAMES+1);
+ }
+-
+- /* copy first part */
+- memcpy(hfctmp->drecbuf, (char *)(hfctmp->fifos + hfc_FIFO_DRX_ZOFF + *z2), maxlen);
+- hfctmp->ztdev->chans[2].bytes2receive += maxlen;
+-
+- count -= maxlen;
+- if (count > 0) {
+- /* ring buffer wrapped, copy rest from start of d fifo */
+- memcpy(hfctmp->drecbuf + maxlen, (char *)(hfctmp->fifos + hfc_FIFO_DRX_ZOFF), count);
+- hfctmp->ztdev->chans[2].bytes2receive += count;
+- }
+-
+- /* frame read */
+- oldz2 = *z2;
+- newz2 = (oldz2 + framelen) & hfc_ZMASK;
+- *f2 = ((*f2 + 1) & hfc_MAX_DFRAMES) | (hfc_MAX_DFRAMES + 1); /* NEXT!!! */
+- /* recalculate z2, because Z2 is a function of F2 Z2(F2) and we INCed F2!!! */
+- z2 = (unsigned short *)(hfctmp->fifos + hfc_FIFO_DRX_Z2 + (*f2 * 4));
+- *z2 = newz2;
+- hfctmp->drecinframe = 0;
+- hfctmp->regs.int_drec--;
+ }
+
+-#ifndef RTAITIMING
+ DAHDI_IRQ_HANDLER(hfc_interrupt) {
+ struct hfc_card *hfctmp = dev_id;
+- unsigned long flags = 0;
+- unsigned char stat;
+-#else
+-static void hfc_service(struct hfc_card *hfctmp) {
+-#endif
++ struct hfc_card *hfctmp2;
+ struct dahdi_hfc *zthfc;
+- unsigned char s1, s2, l1state;
++ unsigned char stat, s1, s2, l1state;
++ unsigned long flags = 0;
++ unsigned long flags2 = 0;
+ int x;
+
+ if (!hfctmp) {
+-#ifndef RTAITIMING
+- return IRQ_NONE;
+-#else
+- /* rtai */
+- return;
+-#endif
++ return IRQ_NONE;
+ }
+
+ if (!hfctmp->pci_io) {
+ printk(KERN_WARNING "%s: IO-mem disabled, cannot handle interrupt\n",
+ __FUNCTION__);
+-#ifndef RTAITIMING
+ return IRQ_NONE;
+-#else
+- /* rtai */
+- return;
+-#endif
+ }
+
+- /* we assume a few things in this irq handler:
+- - the hfc-pci will only generate "timer" irqs (proc/non-proc)
+- - we need to use every 8th IRQ (to generate 1khz timing)
+- OR
+- - if we use rtai for timing the hfc-pci will not generate ANY irq,
+- instead rtai will call this "fake" irq with a 1khz realtime timer. :)
+- - rtai will directly service the card, not like it used to by triggering
+- the linux irq
+- */
+-
+-#ifndef RTAITIMING
+ spin_lock_irqsave(&hfctmp->lock, flags);
+ stat = hfc_inb(hfctmp, hfc_STATUS);
+-
+ if ((stat & hfc_STATUS_ANYINT) == 0) {
+ // maybe we are sharing the irq
+ spin_unlock_irqrestore(&hfctmp->lock,flags);
+ return IRQ_NONE;
+ }
+-#endif
+
+ s1 = hfc_inb(hfctmp, hfc_INT_S1);
+ s2 = hfc_inb(hfctmp, hfc_INT_S2);
+@@ -611,18 +457,10 @@
+ }
+ switch (l1state) {
+ case 3:
+-#ifdef RTAITIMING
+- sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 ACTIVATED (G%d) [realtime]", hfctmp->cardno, l1state);
+-#else
+ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 ACTIVATED (G%d)", hfctmp->cardno, l1state);
+-#endif
+ break;
+ default:
+-#ifdef RTAITIMING
+- sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 DEACTIVATED (G%d) [realtime]", hfctmp->cardno, l1state);
+-#else
+ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] layer 1 DEACTIVATED (G%d)", hfctmp->cardno, l1state);
+-#endif
+ }
+ if (l1state == 2) {
+ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_ACTIVATE | hfc_STATES_DO_ACTION | hfc_STATES_NT_G2_G3);
+@@ -636,18 +474,10 @@
+ }
+ switch (l1state) {
+ case 7:
+-#ifdef RTAITIMING
+- sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 ACTIVATED (F%d) [realtime]", hfctmp->cardno, l1state);
+-#else
+ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 ACTIVATED (F%d)", hfctmp->cardno, l1state);
+-#endif
+ break;
+ default:
+-#ifdef RTAITIMING
+- sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 DEACTIVATED (F%d) [realtime]", hfctmp->cardno, l1state);
+-#else
+ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] layer 1 DEACTIVATED (F%d)", hfctmp->cardno, l1state);
+-#endif
+ }
+ if (l1state == 3) {
+ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_DO_ACTION | hfc_STATES_ACTIVATE);
+@@ -657,7 +487,7 @@
+ }
+ if (s1 & hfc_INTS_DREC) {
+ // D chan RX (bit 5)
+- hfctmp->regs.int_drec++;
++ hfctmp->regs.int_drec = 1;
+ // mr. zapata there is something for you!
+ // printk(KERN_CRIT "d chan rx\n");
+ }
+@@ -678,14 +508,10 @@
+ // B1 chan TX (bit 0)
+ }
+ }
+-#ifdef RTAITIMING
+- /* fake an irq */
+- s2 |= hfc_M2_PROC_TRANS;
+-#endif
+ if (s2 != 0) {
+ if (s2 & hfc_M2_PMESEL) {
+ // kaboom irq (bit 7)
+- printk(KERN_CRIT "zaphfc: sync lost, pci performance too low. you might have some cpu throtteling enabled.\n");
++ //printk(KERN_CRIT "zaphfc: sync lost, pci performance too low. you might have some cpu throtteling enabled.\n");
+ }
+ if (s2 & hfc_M2_GCI_MON_REC) {
+ // RxR monitor channel (bit 2)
+@@ -693,32 +519,31 @@
+ if (s2 & hfc_M2_GCI_I_CHG) {
+ // GCI I-change (bit 1)
+ }
+- if (s2 & hfc_M2_PROC_TRANS) {
++ if((s2&hfc_M2_PROC_TRANS)&&(hfctmp->cardno==timer_card)){
+ // processing/non-processing transition (bit 0)
+- hfctmp->ticks++;
+-#ifndef RTAITIMING
+- if (hfctmp->ticks > 7) {
+- // welcome to DAHDI timing :)
+-#endif
+- hfctmp->ticks = 0;
+-
+- if (hfctmp->ztdev->span.flags & DAHDI_FLAG_RUNNING) {
++ hfctmp2=hfctmp;
++ hfctmp=hfc_dev_list;
++ while(hfctmp){
++ if(hfctmp->active){
++ if(hfctmp!=hfctmp2)spin_lock_irqsave(&hfctmp->lock, flags2);
++ if(hfc_bch_check(hfctmp)){
++ if (hfctmp->ztdev->span.flags & DAHDI_FLAG_RUNNING) {
+ // clear dchan buffer
++ // memset(hfctmp->drecbuf, 0x0, sizeof(hfctmp->drecbuf));
++
+ hfctmp->ztdev->chans[2].bytes2transmit = 0;
+ hfctmp->ztdev->chans[2].maxbytes2transmit = hfc_D_FIFO_SIZE;
+
+ dahdi_transmit(&(hfctmp->ztdev->span));
+
+- hfc_btrans(hfctmp,1);
+- hfc_btrans(hfctmp,2);
+- hfc_dtrans(hfctmp);
++ hfc_bch_tx(hfctmp);
++ hfc_dch_tx(hfctmp);
+ }
+
+- hfc_brec(hfctmp,1);
+- hfc_brec(hfctmp,2);
+- if (hfctmp->regs.int_drec > 0) {
++ hfc_bch_rx(hfctmp);
++ if (hfctmp->regs.int_drec) {
+ // dchan data to read
+- hfc_drec(hfctmp);
++ hfc_dch_rx(hfctmp);
+ if (hfctmp->ztdev->chans[2].bytes2receive > 0) {
+ if (debug) {
+ printk(KERN_CRIT "zaphfc: card %d RX [ ", hfctmp->cardno);
+@@ -743,17 +568,16 @@
+ if (hfctmp->ztdev->span.flags & DAHDI_FLAG_RUNNING) {
+ dahdi_receive(&(hfctmp->ztdev->span));
+ }
+-
+-#ifndef RTAITIMING
+ }
+-#endif
++ if(hfctmp!=hfctmp2)spin_unlock_irqrestore(&hfctmp->lock,flags2);
++ }
++ hfctmp=hfctmp->next;
++ }
++ hfctmp=hfctmp2;
+ }
+-
+ }
+-#ifndef RTAITIMING
+ spin_unlock_irqrestore(&hfctmp->lock,flags);
+- return IRQ_RETVAL(1);
+-#endif
++ return IRQ_RETVAL(1);
+ }
+
+
+@@ -802,22 +626,22 @@
+ }
+ alreadyrunning = span->flags & DAHDI_FLAG_RUNNING;
+
+- if (!alreadyrunning) {
+- span->chans[2]->flags &= ~DAHDI_FLAG_HDLC;
+- span->chans[2]->flags |= DAHDI_FLAG_BRIDCHAN;
+-
+- span->flags |= DAHDI_FLAG_RUNNING;
++ if (alreadyrunning) return 0;
+
+- hfctmp->ticks = -2;
+- hfctmp->clicks = 0;
+- hfctmp->regs.fifo_en = hfc_FIFOEN_D | hfc_FIFOEN_B1 | hfc_FIFOEN_B2;
+- hfc_outb(hfctmp, hfc_FIFO_EN, hfctmp->regs.fifo_en);
+- } else {
+- return 0;
+- }
++ span->chans[2]->flags &= ~DAHDI_FLAG_HDLC;
++ span->chans[2]->flags |= DAHDI_FLAG_BRIDCHAN;
++
++ span->flags |= DAHDI_FLAG_RUNNING;
++
++ hfctmp->ticks = -2;
++ hfctmp->regs.fifo_en = hfc_FIFOEN_D | hfc_FIFOEN_B1 | hfc_FIFOEN_B2;
++ hfc_outb(hfctmp, hfc_FIFO_EN, hfctmp->regs.fifo_en);
++
++ hfc_bch_init(hfctmp);
+
+ // drivers, start engines!
+ hfc_outb(hfctmp, hfc_STATES, hfc_STATES_DO_ACTION | hfc_STATES_ACTIVATE);
++ hfctmp->active=1;
+ return 0;
+ }
+
+@@ -847,17 +671,9 @@
+
+ sprintf(zthfc->span.name, "ZTHFC%d", hfc_dev_count + 1);
+ if (hfctmp->regs.nt_mode == 1) {
+-#ifdef RTAITIMING
+- sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT] [realtime]", hfc_dev_count + 1);
+-#else
+ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [NT]", hfc_dev_count + 1);
+-#endif
+ } else {
+-#ifdef RTAITIMING
+- sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE] [realtime]", hfc_dev_count + 1);
+-#else
+ sprintf(zthfc->span.desc, "HFC-S PCI A ISDN card %d [TE]", hfc_dev_count + 1);
+-#endif
+ }
+
+ zthfc->span.spanconfig = zthfc_spanconfig;
+@@ -897,32 +713,6 @@
+ return 0;
+ }
+
+-#ifdef RTAITIMING
+-#define TICK_PERIOD 1000000
+-#define TICK_PERIOD2 1000000000
+-#define TASK_PRIORITY 1
+-#define STACK_SIZE 10000
+-
+-static RT_TASK rt_task;
+-static struct hfc_card *rtai_hfc_list[hfc_MAX_CARDS];
+-static unsigned char rtai_hfc_counter = 0;
+-
+-static void rtai_register_hfc(struct hfc_card *hfctmp) {
+- rtai_hfc_list[rtai_hfc_counter++] = hfctmp;
+-}
+-
+-static void rtai_loop(int t) {
+- int i=0;
+- for (;;) {
+- for (i=0; i < rtai_hfc_counter; i++) {
+- if (rtai_hfc_list[i] != NULL)
+- hfc_service(rtai_hfc_list[i]);
+- }
+- rt_task_wait_period();
+- }
+-}
+-#endif
+-
+ int hfc_findCards(int pcivendor, int pcidevice, char *vendor_name, char *card_name) {
+ struct pci_dev *tmp;
+ struct hfc_card *hfctmp = NULL;
+@@ -938,9 +728,9 @@
+ }
+ pci_set_master(tmp);
+
+- hfctmp = kmalloc(sizeof(struct hfc_card), GFP_KERNEL);
++ hfctmp = vmalloc(sizeof(struct hfc_card));
+ if (!hfctmp) {
+- printk(KERN_WARNING "zaphfc: unable to kmalloc!\n");
++ printk(KERN_WARNING "zaphfc: unable to vmalloc!\n");
+ pci_disable_device(tmp);
+ multi_hfc = NULL;
+ return -ENOMEM;
+@@ -948,6 +738,7 @@
+ memset(hfctmp, 0x0, sizeof(struct hfc_card));
+ spin_lock_init(&hfctmp->lock);
+
++ hfctmp->active=0;
+ hfctmp->pcidev = tmp;
+ hfctmp->pcibus = tmp->bus->number;
+ hfctmp->pcidevfn = tmp->devfn;
+@@ -961,49 +752,39 @@
+ hfctmp->pci_io = (char *) tmp->resource[1].start;
+ if (!hfctmp->pci_io) {
+ printk(KERN_WARNING "zaphfc: no iomem!\n");
+- kfree(hfctmp);
++ vfree(hfctmp);
+ pci_disable_device(tmp);
+ multi_hfc = NULL;
+ return -1;
+ }
+-
+- hfctmp->fifomem = kmalloc(65536, GFP_KERNEL);
+- if (!hfctmp->fifomem) {
+- printk(KERN_WARNING "zaphfc: unable to kmalloc fifomem!\n");
+- kfree(hfctmp);
++
++ hfctmp->fifos=(void *)__get_free_pages(GFP_KERNEL,log2(hfc_FIFO_MEM_SIZE_PAGES));
++ if (!hfctmp->fifos) {
++ printk(KERN_WARNING "zaphfc: unable to __get_free_pages fifomem!\n");
++ vfree(hfctmp);
+ pci_disable_device(tmp);
+ multi_hfc = NULL;
+ return -ENOMEM;
+ } else {
+- memset(hfctmp->fifomem, 0x0, 65536);
+- hfctmp->fifos = (void *)(((ulong) hfctmp->fifomem) & ~0x7FFF) + 0x8000;
+ pci_write_config_dword(hfctmp->pcidev, 0x80, (u_int) virt_to_bus(hfctmp->fifos));
+ hfctmp->pci_io = ioremap((ulong) hfctmp->pci_io, 256);
+ }
+
+-#ifdef RTAITIMING
+- /* we need no stinking irq */
+- hfctmp->irq = 0;
+-#else
+ if (request_irq(hfctmp->irq, &hfc_interrupt, DAHDI_IRQ_SHARED, "zaphfc", hfctmp)) {
+ printk(KERN_WARNING "zaphfc: unable to register irq\n");
+- kfree(hfctmp->fifomem);
+- kfree(hfctmp);
++ free_pages((unsigned long)hfctmp->fifos,log2(hfc_FIFO_MEM_SIZE_PAGES));
++ vfree(hfctmp);
+ iounmap((void *) hfctmp->pci_io);
+ pci_disable_device(tmp);
+ multi_hfc = NULL;
+ return -EIO;
+ }
+-#endif
+
+-#ifdef RTAITIMING
+- rtai_register_hfc(hfctmp);
+-#endif
+ printk(KERN_INFO
+- "zaphfc: %s %s configured at mem %lx fifo %lx(%#x) IRQ %d HZ %d\n",
++ "zaphfc: %s %s configured at mem %#x fifo %#x(%#x) IRQ %d HZ %d\n",
+ vendor_name, card_name,
+- (unsigned long) hfctmp->pci_io,
+- (unsigned long) hfctmp->fifos,
++ (u_int) hfctmp->pci_io,
++ (u_int) hfctmp->fifos,
+ (u_int) virt_to_bus(hfctmp->fifos),
+ hfctmp->irq, HZ);
+ pci_write_config_word(hfctmp->pcidev, PCI_COMMAND, PCI_COMMAND_MEMORY); // enable memio
+@@ -1020,11 +801,21 @@
+ hfctmp->regs.nt_mode = 0;
+ }
+
+- zthfc = kmalloc(sizeof(struct dahdi_hfc),GFP_KERNEL);
++ if(sync_slave&(1<<hfc_dev_count)){
++ printk(KERN_INFO "zaphfc: Card %d configured for slave mode\n",hfc_dev_count);
++ hfctmp->regs.mst_mode=hfc_MST_MODE_SLAVE|hfc_MST_MODE_F0_LONG_DURATION;
++ hfctmp->regs.mst_emod=hfc_MST_EMOD_SLOW_CLOCK_ADJ;
++ }else{
++ printk(KERN_INFO "zaphfc: Card %d configured for master mode\n",hfc_dev_count);
++ hfctmp->regs.mst_mode=hfc_MST_MODE_MASTER|hfc_MST_MODE_F0_LONG_DURATION;
++ hfctmp->regs.mst_emod=0;
++ }
++
++ zthfc = vmalloc(sizeof(struct dahdi_hfc));
+ if (!zthfc) {
+- printk(KERN_CRIT "zaphfc: unable to kmalloc!\n");
++ printk(KERN_CRIT "zaphfc: unable to vmalloc!\n");
+ hfc_shutdownCard(hfctmp);
+- kfree(hfctmp);
++ vfree(hfctmp);
+ multi_hfc = NULL;
+ return -ENOMEM;
+ }
+@@ -1050,7 +841,6 @@
+ memset(hfctmp->btransbuf[1], 0x0, sizeof(hfctmp->btransbuf[1]));
+ hfctmp->ztdev->chans[1].writechunk = hfctmp->btransbuf[1];
+
+-
+ hfc_registerCard(hfctmp);
+ hfc_resetCard(hfctmp);
+ tmp = pci_get_device(pcivendor, pcidevice, multi_hfc);
+@@ -1058,58 +848,42 @@
+ return 0;
+ }
+
+-
+-
+ int init_module(void) {
+ int i = 0;
+-#ifdef RTAITIMING
+- RTIME tick_period;
+- for (i=0; i < hfc_MAX_CARDS; i++) {
+- rtai_hfc_list[i] = NULL;
++ if(jitterbuffer<1){
++ printk(KERN_INFO "zaphfc: invalid jitterbuffer size specified: %d - changing to minimum of 1\n",jitterbuffer);
++ jitterbuffer=1;
++ }else if(jitterbuffer>500){
++ printk(KERN_INFO "zaphfc: invalid jitterbuffer size specified: %d - changing to maximum of 500\n",jitterbuffer);
++ jitterbuffer=500;
+ }
+- rt_set_periodic_mode();
+-#endif
+- i = 0;
++ printk(KERN_INFO "zaphfc: jitterbuffer size: %d\n",jitterbuffer);
+ while (id_list[i].vendor_id) {
+ multi_hfc = NULL;
+ hfc_findCards(id_list[i].vendor_id, id_list[i].device_id, id_list[i].vendor_name, id_list[i].card_name);
+ i++;
+ }
+-#ifdef RTAITIMING
+- for (i=0; i < hfc_MAX_CARDS; i++) {
+- if (rtai_hfc_list[i]) {
+- printk(KERN_INFO
+- "zaphfc: configured %d at mem %#x fifo %#x(%#x) for realtime servicing\n",
+- rtai_hfc_list[i]->cardno,
+- (u_int) rtai_hfc_list[i]->pci_io,
+- (u_int) rtai_hfc_list[i]->fifos,
+- (u_int) virt_to_bus(rtai_hfc_list[i]->fifos));
+-
+- }
+- }
+- rt_task_init(&rt_task, rtai_loop, 1, STACK_SIZE, TASK_PRIORITY, 0, 0);
+- tick_period = start_rt_timer(nano2count(TICK_PERIOD));
+- rt_task_make_periodic(&rt_task, rt_get_time() + tick_period, tick_period);
+-#endif
+ printk(KERN_INFO "zaphfc: %d hfc-pci card(s) in this box.\n", hfc_dev_count);
+ return 0;
+ }
+
+ void cleanup_module(void) {
+ struct hfc_card *tmpcard;
+-#ifdef RTAITIMING
+- stop_rt_timer();
+- rt_task_delete(&rt_task);
+-#endif
++
+ printk(KERN_INFO "zaphfc: stop\n");
+ // spin_lock(&registerlock);
++ tmpcard=hfc_dev_list;
++ while(tmpcard){
++ hfc_shutdownCard1(tmpcard);
++ tmpcard=tmpcard->next;
++ }
+ while (hfc_dev_list != NULL) {
+ if (hfc_dev_list == NULL) break;
+- hfc_shutdownCard(hfc_dev_list);
++ hfc_shutdownCard2(hfc_dev_list);
+ tmpcard = hfc_dev_list;
+ hfc_dev_list = hfc_dev_list->next;
+ if (tmpcard != NULL) {
+- kfree(tmpcard);
++ vfree(tmpcard);
+ tmpcard = NULL;
+ printk(KERN_INFO "zaphfc: freed one card.\n");
+ }
+@@ -1119,8 +893,11 @@
+ #endif
+
+
+-module_param(modes, int, 0600);
++module_param(modes, int, 0400);
+ module_param(debug, int, 0600);
++module_param(sync_slave, int, 0400);
++module_param(timer_card, int, 0400);
++module_param(jitterbuffer, int, 0400);
+
+ MODULE_DESCRIPTION("HFC-S PCI A Zaptel Driver");
+ MODULE_AUTHOR("Klaus-Peter Junghanns <kpj@junghanns.net>");
diff --git a/main/dahdi-linux/APKBUILD b/main/dahdi-linux/APKBUILD
new file mode 100644
index 00000000000..b0f6edf789b
--- /dev/null
+++ b/main/dahdi-linux/APKBUILD
@@ -0,0 +1,35 @@
+# Contributor: Timo Teras <timo.teras@iki.fi>
+# Maintainer: Timo Teras <timo.teras@iki.fi>
+
+pkgname=dahdi-linux
+pkgver=2.2.0
+pkgrel=1
+pkgdesc="Firmware for Digium Asterisk Hardware Device Interface drivers"
+url="http://www.asterisk.org"
+license="GPL"
+depends=
+# we need wget and tar because make install downloads firmware and uses fancy
+# options for tar and wget.
+makedepends="wget tar"
+install=
+subpackages="$pkgname-dev"
+source="http://downloads.digium.com/pub/telephony/dahdi-linux/releases/$pkgname-$pkgver.tar.gz"
+
+# We onlin install the firwares in this package since those are common for all
+# kernel flavors. We also install the headers for the -dev package.
+#
+# The kernel drivers themselves are built from separate build recipe.
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch ../*.diff; do
+ [ -f "$i" ] || continue
+ msg "Applying $i"
+ patch -p1 < $i || return 1;
+ done
+
+ make DESTDIR="$pkgdir" HOTPLUG_FIRMWARE=yes \
+ install-include install-firmware
+}
+
+md5sums="a6b1a24a436e1c1fd08b99d27cfe3f38 dahdi-linux-2.2.0.tar.gz"
diff --git a/main/dahdi-tools/APKBUILD b/main/dahdi-tools/APKBUILD
new file mode 100644
index 00000000000..9a1538fab65
--- /dev/null
+++ b/main/dahdi-tools/APKBUILD
@@ -0,0 +1,32 @@
+# Contributor: Timo Teras <timo.teras@iki.fi>
+# Maintainer: Timo Teras <timo.teras@iki.fi>
+pkgname=dahdi-tools
+pkgver=2.2.0
+pkgrel=0
+pkgdesc="Digium Asterisk Hardware Device Interface management utilities"
+url="http://www.asterisk.org"
+license="GPL"
+depends="dahdi-linux"
+depends_dev="dahdi-linux-dev newt-dev"
+makedepends="dahdi-linux-dev perl newt-dev"
+install=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://downloads.digium.com/pub/telephony/dahdi-tools/releases/$pkgname-$pkgver.tar.gz
+ $pkgname.initd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ sed -i -e 's/$(CC) $(LDFLAGS) -o $@ $^/$(CC) $^ $(LDFLAGS) -o $@/' Makefile
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/dahdi
+}
+
+md5sums="a018f452f3851a312ff51705ac44de37 dahdi-tools-2.2.0.tar.gz
+d9702271dba6ff250f4d9a252f4dbf4c dahdi-tools.initd"
diff --git a/main/dahdi-tools/dahdi-tools.initd b/main/dahdi-tools/dahdi-tools.initd
new file mode 100644
index 00000000000..5e99122a5a7
--- /dev/null
+++ b/main/dahdi-tools/dahdi-tools.initd
@@ -0,0 +1,21 @@
+#!/sbin/runscript
+
+conf=/etc/dahdi/system.conf
+
+depend() {
+ before asterisk
+ after hwdrivers modules
+ keyword novserver
+}
+
+start() {
+ ebegin "Starting dahdi"
+ /usr/sbin/dahdi_cfg
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping dahdi"
+ /usr/sbin/dahdi_cfg -s
+ eend $?
+}
diff --git a/main/dansguardian/APKBUILD b/main/dansguardian/APKBUILD
new file mode 100644
index 00000000000..24c50a63339
--- /dev/null
+++ b/main/dansguardian/APKBUILD
@@ -0,0 +1,39 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dansguardian
+pkgver=2.10.0.3
+pkgrel=3
+pkgdesc="Web content filter"
+url="http://dansguardian.org"
+license="GPL"
+depends=
+makedepends="zlib-dev uclibc++-dev pcre-dev pkgconfig libiconv-dev"
+install="$pkgname.pre-install"
+subpackages="$pkgname-doc"
+source="http://dansguardian.org/downloads/2/Stable/$pkgname-$pkgver.tar.gz
+ dansguardian.initd
+ $install
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ export CXX=g++-uc
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-proxyuser=dansguar \
+ --with-proxygroup=dansguar \
+ --with-logdir=/var/log/dansguardian \
+ --with-piddir=/var/run/ \
+ --enable-ntlm
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -D -m 755 ../dansguardian.initd "$pkgdir"/etc/init.d/dansguardian
+}
+
+md5sums="68c8e9a97a3b58d2467a19cb15db5599 dansguardian-2.10.0.3.tar.gz
+0c04f74cd5db9fc7a8e80b407ec34214 dansguardian.initd
+ab4e1104633aad0595a8b530fceb810a dansguardian.pre-install"
diff --git a/main/dansguardian/dansguardian.initd b/main/dansguardian/dansguardian.initd
new file mode 100644
index 00000000000..e8f8e94cc30
--- /dev/null
+++ b/main/dansguardian/dansguardian.initd
@@ -0,0 +1,32 @@
+#!/sbin/runscript
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/dansguardian/files/dansguardian.init,v 1.2 2005/12/08 22:15:11 mrness Exp $
+
+opts="{$opts} reload"
+
+depend() {
+ need net
+ use dns \
+ squid apache2 bfilter mman junkbuster oops polipo privoxy tinyproxy wwwoffled
+}
+
+start() {
+ ebegin "Starting DansGuardian"
+ start-stop-daemon --start --quiet --pidfile /var/run/dansguardian.pid \
+ --exec /usr/sbin/dansguardian
+eend 0
+}
+
+stop() {
+ ebegin "Stopping DansGuardian"
+ start-stop-daemon --stop --quiet --pidfile /var/run/dansguardian.pid
+eend 0
+}
+
+reload() {
+ ebegin "Reloading DansGuardian"
+ /usr/sbin/dansguardian -g
+eend 0
+}
+
diff --git a/main/dansguardian/dansguardian.pre-install b/main/dansguardian/dansguardian.pre-install
new file mode 100644
index 00000000000..2d06f3a6f67
--- /dev/null
+++ b/main/dansguardian/dansguardian.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+adduser -h /var/log/dansguardian -s /bin/false -D dansguar 2>/dev/null
+exit 0
+
diff --git a/main/db/APKBUILD b/main/db/APKBUILD
new file mode 100644
index 00000000000..00940e41c6c
--- /dev/null
+++ b/main/db/APKBUILD
@@ -0,0 +1,49 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=db
+pkgver=4.7.25.4
+_ver=${pkgver%.*}
+pkgrel=0
+pkgdesc="The Berkeley DB embedded database system 4.7"
+url="http://www.oracle.com/technology/software/products/berkeley-db/index.html"
+license="custom"
+depends=
+makedepends=
+subpackages="$pkgname-dev $pkgname-doc"
+# Patches were found here:
+# http://www.oracle.com/technology/products/berkeley-db/db/update/4.7.25/patch.4.7.25.html
+source="http://download-uk.oracle.com/berkeley-db/db-$_ver.tar.gz
+ patch.$_ver.1
+ patch.$_ver.2
+ patch.$_ver.3
+ patch.$_ver.4
+ "
+
+build () {
+ cd "$srcdir"/db-$_ver
+ for i in ../patch.*; do
+ msg "Applying $i..."
+ patch -p0 < $i || return 1
+ done
+
+ cd build_unix
+ ../dist/configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --enable-compat185 \
+ --enable-shared \
+ --disable-static \
+ --disable-cxx
+ make LIBSO_LIBS=-lpthread || return 1
+ make DESTDIR="$pkgdir" install
+
+ mkdir -p "$pkgdir"/usr/share/doc
+ mv "$pkgdir"/usr/docs "$pkgdir"/usr/share/doc/$pkgname
+
+ install -D -m644 "$srcdir"/db-$_ver/LICENSE \
+ "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+}
+
+md5sums="ec2b87e833779681a0c3a814aa71359e db-4.7.25.tar.gz
+5fdf101259e5164dea1c8c86214fde38 patch.4.7.25.1
+bd410a11c71fee52fddb6aa2d8d4f80c patch.4.7.25.2
+6fcd69f64f5b34bfe8f0a63cc2e402c1 patch.4.7.25.3
+42c5d1a727e4a7f59b9dce12ff2f6b84 patch.4.7.25.4"
diff --git a/main/db/patch.4.7.25.1 b/main/db/patch.4.7.25.1
new file mode 100644
index 00000000000..3c7e23ce079
--- /dev/null
+++ b/main/db/patch.4.7.25.1
@@ -0,0 +1,75 @@
+*** sequence/sequence.c.orig 2008-05-05 13:25:09.000000000 -0700
+--- sequence/sequence.c 2008-08-15 09:58:46.000000000 -0700
+***************
+*** 187,193 ****
+ if ((ret = __db_get_flags(dbp, &tflags)) != 0)
+ goto err;
+
+! if (DB_IS_READONLY(dbp)) {
+ ret = __db_rdonly(dbp->env, "DB_SEQUENCE->open");
+ goto err;
+ }
+--- 187,197 ----
+ if ((ret = __db_get_flags(dbp, &tflags)) != 0)
+ goto err;
+
+! /*
+! * We can let replication clients open sequences, but must
+! * check later that they do not update them.
+! */
+! if (F_ISSET(dbp, DB_AM_RDONLY)) {
+ ret = __db_rdonly(dbp->env, "DB_SEQUENCE->open");
+ goto err;
+ }
+***************
+*** 244,249 ****
+--- 248,258 ----
+ if ((ret != DB_NOTFOUND && ret != DB_KEYEMPTY) ||
+ !LF_ISSET(DB_CREATE))
+ goto err;
++ if (IS_REP_CLIENT(env) &&
++ !F_ISSET(dbp, DB_AM_NOT_DURABLE)) {
++ ret = __db_rdonly(env, "DB_SEQUENCE->open");
++ goto err;
++ }
+ ret = 0;
+
+ rp = &seq->seq_record;
+***************
+*** 296,302 ****
+ */
+ rp = seq->seq_data.data;
+ if (rp->seq_version == DB_SEQUENCE_OLDVER) {
+! oldver: rp->seq_version = DB_SEQUENCE_VERSION;
+ if (!F_ISSET(env, ENV_LITTLEENDIAN)) {
+ if (IS_DB_AUTO_COMMIT(dbp, txn)) {
+ if ((ret =
+--- 305,316 ----
+ */
+ rp = seq->seq_data.data;
+ if (rp->seq_version == DB_SEQUENCE_OLDVER) {
+! oldver: if (IS_REP_CLIENT(env) &&
+! !F_ISSET(dbp, DB_AM_NOT_DURABLE)) {
+! ret = __db_rdonly(env, "DB_SEQUENCE->open");
+! goto err;
+! }
+! rp->seq_version = DB_SEQUENCE_VERSION;
+ if (!F_ISSET(env, ENV_LITTLEENDIAN)) {
+ if (IS_DB_AUTO_COMMIT(dbp, txn)) {
+ if ((ret =
+***************
+*** 707,712 ****
+--- 721,733 ----
+
+ MUTEX_LOCK(env, seq->mtx_seq);
+
++ if (handle_check && IS_REP_CLIENT(env) &&
++ !F_ISSET(dbp, DB_AM_NOT_DURABLE)) {
++ ret = __db_rdonly(env, "DB_SEQUENCE->get");
++ goto err;
++ }
++
++
+ if (rp->seq_min + delta > rp->seq_max) {
+ __db_errx(env, "Sequence overflow");
+ ret = EINVAL;
diff --git a/main/db/patch.4.7.25.2 b/main/db/patch.4.7.25.2
new file mode 100644
index 00000000000..1f42dcec71f
--- /dev/null
+++ b/main/db/patch.4.7.25.2
@@ -0,0 +1,71 @@
+Index: lock/lock.c
+===================================================================
+RCS file: /a/CVSROOT/db/lock/lock.c,v
+retrieving revision 12.61
+diff -c -r12.61 lock.c
+*** lock/lock.c 22 Jul 2008 12:08:53 -0000 12.61
+--- lock/lock.c 19 Aug 2008 17:28:24 -0000
+***************
+*** 1278,1287 ****
+ SH_TAILQ_REMOVE(
+ &lt->obj_tab[obj_ndx], sh_obj, links, __db_lockobj);
+ if (sh_obj->lockobj.size > sizeof(sh_obj->objdata)) {
+! LOCK_REGION_LOCK(env);
+ __env_alloc_free(&lt->reginfo,
+ SH_DBT_PTR(&sh_obj->lockobj));
+! LOCK_REGION_UNLOCK(env);
+ }
+ SH_TAILQ_INSERT_HEAD(
+ &FREE_OBJS(lt, part_id), sh_obj, links, __db_lockobj);
+--- 1278,1289 ----
+ SH_TAILQ_REMOVE(
+ &lt->obj_tab[obj_ndx], sh_obj, links, __db_lockobj);
+ if (sh_obj->lockobj.size > sizeof(sh_obj->objdata)) {
+! if (region->part_t_size != 1)
+! LOCK_REGION_LOCK(env);
+ __env_alloc_free(&lt->reginfo,
+ SH_DBT_PTR(&sh_obj->lockobj));
+! if (region->part_t_size != 1)
+! LOCK_REGION_UNLOCK(env);
+ }
+ SH_TAILQ_INSERT_HEAD(
+ &FREE_OBJS(lt, part_id), sh_obj, links, __db_lockobj);
+***************
+*** 1470,1484 ****
+ if (obj->size <= sizeof(sh_obj->objdata))
+ p = sh_obj->objdata;
+ else {
+! LOCK_REGION_LOCK(env);
+ if ((ret =
+ __env_alloc(&lt->reginfo, obj->size, &p)) != 0) {
+ __db_errx(env,
+ "No space for lock object storage");
+! LOCK_REGION_UNLOCK(env);
+ goto err;
+ }
+! LOCK_REGION_UNLOCK(env);
+ }
+
+ memcpy(p, obj->data, obj->size);
+--- 1472,1492 ----
+ if (obj->size <= sizeof(sh_obj->objdata))
+ p = sh_obj->objdata;
+ else {
+! /*
+! * If we have only one partition, the region is locked.
+! */
+! if (region->part_t_size != 1)
+! LOCK_REGION_LOCK(env);
+ if ((ret =
+ __env_alloc(&lt->reginfo, obj->size, &p)) != 0) {
+ __db_errx(env,
+ "No space for lock object storage");
+! if (region->part_t_size != 1)
+! LOCK_REGION_UNLOCK(env);
+ goto err;
+ }
+! if (region->part_t_size != 1)
+! LOCK_REGION_UNLOCK(env);
+ }
+
+ memcpy(p, obj->data, obj->size);
diff --git a/main/db/patch.4.7.25.3 b/main/db/patch.4.7.25.3
new file mode 100644
index 00000000000..b58a43074fd
--- /dev/null
+++ b/main/db/patch.4.7.25.3
@@ -0,0 +1,314 @@
+*** lock/lock_deadlock.c 2008-03-11 00:31:33.000000000 +1100
+--- lock/lock_deadlock.c 2008-12-16 21:54:18.000000000 +1100
+***************
+*** 121,127 ****
+ DB_LOCKTAB *lt;
+ db_timespec now;
+ locker_info *idmap;
+! u_int32_t *bitmap, *copymap, **deadp, **free_me, *tmpmap;
+ u_int32_t i, cid, keeper, killid, limit, nalloc, nlockers;
+ u_int32_t lock_max, txn_max;
+ int ret, status;
+--- 121,127 ----
+ DB_LOCKTAB *lt;
+ db_timespec now;
+ locker_info *idmap;
+! u_int32_t *bitmap, *copymap, **deadp, **deadlist, *tmpmap;
+ u_int32_t i, cid, keeper, killid, limit, nalloc, nlockers;
+ u_int32_t lock_max, txn_max;
+ int ret, status;
+***************
+*** 133,139 ****
+ if (IS_REP_CLIENT(env))
+ atype = DB_LOCK_MINWRITE;
+
+! free_me = NULL;
+
+ lt = env->lk_handle;
+ if (rejectp != NULL)
+--- 133,140 ----
+ if (IS_REP_CLIENT(env))
+ atype = DB_LOCK_MINWRITE;
+
+! copymap = tmpmap = NULL;
+! deadlist = NULL;
+
+ lt = env->lk_handle;
+ if (rejectp != NULL)
+***************
+*** 179,189 ****
+ memcpy(copymap, bitmap, nlockers * sizeof(u_int32_t) * nalloc);
+
+ if ((ret = __os_calloc(env, sizeof(u_int32_t), nalloc, &tmpmap)) != 0)
+! goto err1;
+
+ /* Find a deadlock. */
+ if ((ret =
+! __dd_find(env, bitmap, idmap, nlockers, nalloc, &deadp)) != 0)
+ return (ret);
+
+ /*
+--- 180,190 ----
+ memcpy(copymap, bitmap, nlockers * sizeof(u_int32_t) * nalloc);
+
+ if ((ret = __os_calloc(env, sizeof(u_int32_t), nalloc, &tmpmap)) != 0)
+! goto err;
+
+ /* Find a deadlock. */
+ if ((ret =
+! __dd_find(env, bitmap, idmap, nlockers, nalloc, &deadlist)) != 0)
+ return (ret);
+
+ /*
+***************
+*** 204,211 ****
+ txn_max = TXN_MAXIMUM;
+
+ killid = BAD_KILLID;
+! free_me = deadp;
+! for (; *deadp != NULL; deadp++) {
+ if (rejectp != NULL)
+ ++*rejectp;
+ killid = (u_int32_t)(*deadp - bitmap) / nalloc;
+--- 205,211 ----
+ txn_max = TXN_MAXIMUM;
+
+ killid = BAD_KILLID;
+! for (deadp = deadlist; *deadp != NULL; deadp++) {
+ if (rejectp != NULL)
+ ++*rejectp;
+ killid = (u_int32_t)(*deadp - bitmap) / nalloc;
+***************
+*** 342,352 ****
+ __db_msg(env,
+ "Aborting locker %lx", (u_long)idmap[killid].id);
+ }
+! __os_free(env, tmpmap);
+! err1: __os_free(env, copymap);
+!
+! err: if (free_me != NULL)
+! __os_free(env, free_me);
+ __os_free(env, bitmap);
+ __os_free(env, idmap);
+
+--- 342,353 ----
+ __db_msg(env,
+ "Aborting locker %lx", (u_long)idmap[killid].id);
+ }
+! err: if(copymap != NULL)
+! __os_free(env, copymap);
+! if (deadlist != NULL)
+! __os_free(env, deadlist);
+! if(tmpmap != NULL)
+! __os_free(env, tmpmap);
+ __os_free(env, bitmap);
+ __os_free(env, idmap);
+
+***************
+*** 360,365 ****
+--- 361,377 ----
+
+ #define DD_INVALID_ID ((u_int32_t) -1)
+
++ /*
++ * __dd_build --
++ * Build the lock dependency bit maps.
++ * Notes on syncronization:
++ * LOCK_SYSTEM_LOCK is used to hold objects locked when we have
++ * a single partition.
++ * LOCK_LOCKERS is held while we are walking the lockers list and
++ * to single thread the use of lockerp->dd_id.
++ * LOCK_DD protects the DD list of objects.
++ */
++
+ static int
+ __dd_build(env, atype, bmp, nlockers, allocp, idmap, rejectp)
+ ENV *env;
+***************
+*** 393,398 ****
+--- 405,411 ----
+ * In particular we do not build the conflict array and our caller
+ * needs to expect this.
+ */
++ LOCK_SYSTEM_LOCK(lt, region);
+ if (atype == DB_LOCK_EXPIRE) {
+ skip: LOCK_DD(env, region);
+ op = SH_TAILQ_FIRST(&region->dd_objs, __db_lockobj);
+***************
+*** 430,446 ****
+ OBJECT_UNLOCK(lt, region, indx);
+ }
+ UNLOCK_DD(env, region);
+ goto done;
+ }
+
+ /*
+! * We'll check how many lockers there are, add a few more in for
+! * good measure and then allocate all the structures. Then we'll
+! * verify that we have enough room when we go back in and get the
+! * mutex the second time.
+ */
+! retry: count = region->stat.st_nlockers;
+ if (count == 0) {
+ *nlockers = 0;
+ return (0);
+ }
+--- 443,460 ----
+ OBJECT_UNLOCK(lt, region, indx);
+ }
+ UNLOCK_DD(env, region);
++ LOCK_SYSTEM_UNLOCK(lt, region);
+ goto done;
+ }
+
+ /*
+! * Allocate after locking the region
+! * to make sure the structures are large enough.
+ */
+! LOCK_LOCKERS(env, region);
+! count = region->stat.st_nlockers;
+ if (count == 0) {
++ UNLOCK_LOCKERS(env, region);
+ *nlockers = 0;
+ return (0);
+ }
+***************
+*** 448,497 ****
+ if (FLD_ISSET(env->dbenv->verbose, DB_VERB_DEADLOCK))
+ __db_msg(env, "%lu lockers", (u_long)count);
+
+- count += 20;
+ nentries = (u_int32_t)DB_ALIGN(count, 32) / 32;
+
+! /*
+! * Allocate enough space for a count by count bitmap matrix.
+! *
+! * XXX
+! * We can probably save the malloc's between iterations just
+! * reallocing if necessary because count grew by too much.
+! */
+ if ((ret = __os_calloc(env, (size_t)count,
+! sizeof(u_int32_t) * nentries, &bitmap)) != 0)
+ return (ret);
+
+ if ((ret = __os_calloc(env,
+ sizeof(u_int32_t), nentries, &tmpmap)) != 0) {
+ __os_free(env, bitmap);
+ return (ret);
+ }
+
+ if ((ret = __os_calloc(env,
+ (size_t)count, sizeof(locker_info), &id_array)) != 0) {
+ __os_free(env, bitmap);
+ __os_free(env, tmpmap);
+ return (ret);
+ }
+
+ /*
+- * Now go back in and actually fill in the matrix.
+- */
+- if (region->stat.st_nlockers > count) {
+- __os_free(env, bitmap);
+- __os_free(env, tmpmap);
+- __os_free(env, id_array);
+- goto retry;
+- }
+-
+- /*
+ * First we go through and assign each locker a deadlock detector id.
+ */
+ id = 0;
+- LOCK_LOCKERS(env, region);
+ SH_TAILQ_FOREACH(lip, &region->lockers, ulinks, __db_locker) {
+ if (lip->master_locker == INVALID_ROFF) {
+ lip->dd_id = id++;
+ id_array[lip->dd_id].id = lip->id;
+ switch (atype) {
+--- 462,498 ----
+ if (FLD_ISSET(env->dbenv->verbose, DB_VERB_DEADLOCK))
+ __db_msg(env, "%lu lockers", (u_long)count);
+
+ nentries = (u_int32_t)DB_ALIGN(count, 32) / 32;
+
+! /* Allocate enough space for a count by count bitmap matrix. */
+ if ((ret = __os_calloc(env, (size_t)count,
+! sizeof(u_int32_t) * nentries, &bitmap)) != 0) {
+! UNLOCK_LOCKERS(env, region);
+ return (ret);
++ }
+
+ if ((ret = __os_calloc(env,
+ sizeof(u_int32_t), nentries, &tmpmap)) != 0) {
++ UNLOCK_LOCKERS(env, region);
+ __os_free(env, bitmap);
+ return (ret);
+ }
+
+ if ((ret = __os_calloc(env,
+ (size_t)count, sizeof(locker_info), &id_array)) != 0) {
++ UNLOCK_LOCKERS(env, region);
+ __os_free(env, bitmap);
+ __os_free(env, tmpmap);
+ return (ret);
+ }
+
+ /*
+ * First we go through and assign each locker a deadlock detector id.
+ */
+ id = 0;
+ SH_TAILQ_FOREACH(lip, &region->lockers, ulinks, __db_locker) {
+ if (lip->master_locker == INVALID_ROFF) {
++ DB_ASSERT(env, id < count);
+ lip->dd_id = id++;
+ id_array[lip->dd_id].id = lip->id;
+ switch (atype) {
+***************
+*** 510,516 ****
+ lip->dd_id = DD_INVALID_ID;
+
+ }
+- UNLOCK_LOCKERS(env, region);
+
+ /*
+ * We only need consider objects that have waiters, so we use
+--- 511,516 ----
+***************
+*** 669,675 ****
+ * status after building the bit maps so that we will not detect
+ * a blocked transaction without noting that it is already aborting.
+ */
+- LOCK_LOCKERS(env, region);
+ for (id = 0; id < count; id++) {
+ if (!id_array[id].valid)
+ continue;
+--- 669,674 ----
+***************
+*** 738,743 ****
+--- 737,743 ----
+ id_array[id].in_abort = 1;
+ }
+ UNLOCK_LOCKERS(env, region);
++ LOCK_SYSTEM_UNLOCK(lt, region);
+
+ /*
+ * Now we can release everything except the bitmap matrix that we
+***************
+*** 839,844 ****
+--- 839,845 ----
+ ret = 0;
+
+ /* We must lock so this locker cannot go away while we abort it. */
++ LOCK_SYSTEM_LOCK(lt, region);
+ LOCK_LOCKERS(env, region);
+
+ /*
+***************
+*** 895,900 ****
+--- 896,902 ----
+ done: OBJECT_UNLOCK(lt, region, info->last_ndx);
+ err:
+ out: UNLOCK_LOCKERS(env, region);
++ LOCK_SYSTEM_UNLOCK(lt, region);
+ return (ret);
+ }
+
diff --git a/main/db/patch.4.7.25.4 b/main/db/patch.4.7.25.4
new file mode 100644
index 00000000000..7a55340023b
--- /dev/null
+++ b/main/db/patch.4.7.25.4
@@ -0,0 +1,183 @@
+*** dbinc/repmgr.h.orig 2009-05-04 10:33:55.000000000 -0400
+--- dbinc/repmgr.h 2009-05-04 10:27:26.000000000 -0400
+***************
+*** 374,379 ****
+--- 374,380 ----
+ #define SITE_FROM_EID(eid) (&db_rep->sites[eid])
+ #define EID_FROM_SITE(s) ((int)((s) - (&db_rep->sites[0])))
+ #define IS_VALID_EID(e) ((e) >= 0)
++ #define IS_KNOWN_REMOTE_SITE(e) ((e) >= 0 && ((u_int)(e)) < db_rep->site_cnt)
+ #define SELF_EID INT_MAX
+
+ #define IS_PEER_POLICY(p) ((p) == DB_REPMGR_ACKS_ALL_PEERS || \
+*** rep/rep_elect.c.orig 2009-05-04 10:35:50.000000000 -0400
+--- rep/rep_elect.c 2009-05-04 10:31:24.000000000 -0400
+***************
+*** 33,39 ****
+ static int __rep_fire_elected __P((ENV *, REP *, u_int32_t));
+ static void __rep_elect_master __P((ENV *, REP *));
+ static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t));
+! static int __rep_wait __P((ENV *, db_timeout_t *, int *, int, u_int32_t));
+
+ /*
+ * __rep_elect --
+--- 33,39 ----
+ static int __rep_fire_elected __P((ENV *, REP *, u_int32_t));
+ static void __rep_elect_master __P((ENV *, REP *));
+ static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t));
+! static int __rep_wait __P((ENV *, db_timeout_t *, int, u_int32_t));
+
+ /*
+ * __rep_elect --
+***************
+*** 55,61 ****
+ ENV *env;
+ LOG *lp;
+ REP *rep;
+! int done, eid, elected, full_elect, locked, in_progress, need_req;
+ int ret, send_vote, t_ret;
+ u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri;
+ u_int32_t tiebreaker;
+--- 55,61 ----
+ ENV *env;
+ LOG *lp;
+ REP *rep;
+! int done, elected, full_elect, locked, in_progress, need_req;
+ int ret, send_vote, t_ret;
+ u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri;
+ u_int32_t tiebreaker;
+***************
+*** 181,188 ****
+ REP_SYSTEM_UNLOCK(env);
+ (void)__rep_send_message(env, DB_EID_BROADCAST,
+ REP_MASTER_REQ, NULL, NULL, 0, 0);
+! ret = __rep_wait(env, &to, &eid,
+! 0, REP_F_EPHASE0);
+ REP_SYSTEM_LOCK(env);
+ F_CLR(rep, REP_F_EPHASE0);
+ switch (ret) {
+--- 181,187 ----
+ REP_SYSTEM_UNLOCK(env);
+ (void)__rep_send_message(env, DB_EID_BROADCAST,
+ REP_MASTER_REQ, NULL, NULL, 0, 0);
+! ret = __rep_wait(env, &to, 0, REP_F_EPHASE0);
+ REP_SYSTEM_LOCK(env);
+ F_CLR(rep, REP_F_EPHASE0);
+ switch (ret) {
+***************
+*** 286,296 ****
+ REP_SYSTEM_LOCK(env);
+ goto vote;
+ }
+! ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE1);
+ switch (ret) {
+ case 0:
+ /* Check if election complete or phase complete. */
+! if (eid != DB_EID_INVALID && !IN_ELECTION(rep)) {
+ RPRINT(env, DB_VERB_REP_ELECT,
+ (env, "Ended election phase 1"));
+ goto edone;
+--- 285,295 ----
+ REP_SYSTEM_LOCK(env);
+ goto vote;
+ }
+! ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE1);
+ switch (ret) {
+ case 0:
+ /* Check if election complete or phase complete. */
+! if (!IN_ELECTION(rep)) {
+ RPRINT(env, DB_VERB_REP_ELECT,
+ (env, "Ended election phase 1"));
+ goto edone;
+***************
+*** 398,412 ****
+ REP_SYSTEM_LOCK(env);
+ goto i_won;
+ }
+! ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE2);
+ RPRINT(env, DB_VERB_REP_ELECT,
+ (env, "Ended election phase 2 %d", ret));
+ switch (ret) {
+ case 0:
+! if (eid != DB_EID_INVALID)
+! goto edone;
+! ret = DB_REP_UNAVAIL;
+! break;
+ case DB_REP_EGENCHG:
+ if (to > timeout)
+ to = timeout;
+--- 397,408 ----
+ REP_SYSTEM_LOCK(env);
+ goto i_won;
+ }
+! ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE2);
+ RPRINT(env, DB_VERB_REP_ELECT,
+ (env, "Ended election phase 2 %d", ret));
+ switch (ret) {
+ case 0:
+! goto edone;
+ case DB_REP_EGENCHG:
+ if (to > timeout)
+ to = timeout;
+***************
+*** 1050,1062 ****
+ ENV *env;
+ REP *rep;
+ {
+- /*
+- * We often come through here twice, sometimes even more. We mustn't
+- * let the redundant calls affect stats counting. But rep_elect relies
+- * on this first part for setting eidp.
+- */
+- rep->master_id = rep->eid;
+-
+ if (F_ISSET(rep, REP_F_MASTERELECT | REP_F_MASTER)) {
+ /* We've been through here already; avoid double counting. */
+ return;
+--- 1046,1051 ----
+***************
+*** 1093,1102 ****
+ (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
+
+ static int
+! __rep_wait(env, timeoutp, eidp, full_elect, flags)
+ ENV *env;
+ db_timeout_t *timeoutp;
+! int *eidp, full_elect;
+ u_int32_t flags;
+ {
+ DB_REP *db_rep;
+--- 1082,1091 ----
+ (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
+
+ static int
+! __rep_wait(env, timeoutp, full_elect, flags)
+ ENV *env;
+ db_timeout_t *timeoutp;
+! int full_elect;
+ u_int32_t flags;
+ {
+ DB_REP *db_rep;
+***************
+*** 1174,1180 ****
+ F_CLR(rep, REP_F_EGENUPDATE);
+ ret = DB_REP_EGENCHG;
+ } else if (phase_over) {
+- *eidp = rep->master_id;
+ done = 1;
+ ret = 0;
+ }
+--- 1163,1168 ----
+*** repmgr/repmgr_net.c.orig 2009-05-04 10:34:46.000000000 -0400
+--- repmgr/repmgr_net.c 2009-05-04 10:27:26.000000000 -0400
+***************
+*** 100,105 ****
+--- 100,107 ----
+ control, rec, &nsites_sent, &npeers_sent)) != 0)
+ goto out;
+ } else {
++ DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid));
++
+ /*
+ * If this is a request that can be sent anywhere, then see if
+ * we can send it to our peer (to save load on the master), but
diff --git a/main/dhcp/APKBUILD b/main/dhcp/APKBUILD
new file mode 100644
index 00000000000..01bb25e91d1
--- /dev/null
+++ b/main/dhcp/APKBUILD
@@ -0,0 +1,36 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dhcp
+pkgver=4.1.0_p1
+_realver=4.1.0p1
+pkgrel=0
+pkgdesc="ISC Dynamic Host Configuration Protocol (DHCP)"
+url="https://www.isc.org/"
+license="GPL"
+depends=
+makedepends=
+install="dhcp.pre-upgrade dhcp.post-upgrade"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://ftp.isc.org/isc/dhcp/$pkgname-$_realver.tar.gz
+ $install
+ dhcpd.confd
+ dhcpd.initd"
+
+build() {
+ cd "$srcdir/$pkgname-$_realver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/dhcpd.initd "$pkgdir"/etc/init.d/dhcpd
+ install -m644 -D "$srcdir"/dhcpd.confd "$pkgdir"/etc/conf.d/dhcpd
+}
+
+md5sums="325ff8338c5a21f89d5304ac13ffebdf dhcp-4.1.0p1.tar.gz
+6cc49497f3c30ccd37fc7c032f7810c6 dhcp.pre-upgrade
+a7b81948ceab73dd10de275ebc00e7eb dhcp.post-upgrade
+df32707f5bbe5363306420b5dc6e6b40 dhcpd.confd
+5df9a87539bedc98a1cbc7e38b290928 dhcpd.initd"
diff --git a/main/dhcp/dhcp.post-upgrade b/main/dhcp/dhcp.post-upgrade
new file mode 100644
index 00000000000..b16fea6b4af
--- /dev/null
+++ b/main/dhcp/dhcp.post-upgrade
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# we have renamed dhcp to dhcpd. Try cleanup for users
+
+moved=
+for i in /etc/runlevel/*/dhcp; do
+ if [ -L "$i" ]; then
+ mv ${i} ${i}d
+ moved=1
+ fi
+done
+
+if [ -n "$moved" ]; then
+ echo " *"
+ echo " * NOTICE: the /etc/init.d/dhcp script have been renamed to /etc/init.d/dhcpd"
+ echo " *"
+fi
+
diff --git a/main/dhcp/dhcp.pre-upgrade b/main/dhcp/dhcp.pre-upgrade
new file mode 100644
index 00000000000..090f654b9a4
--- /dev/null
+++ b/main/dhcp/dhcp.pre-upgrade
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# script renamed. Try save users settings if needed
+
+if [ -f /etc/conf.d/dhcp ] && [ ! -f /etc/conf.d/dhcpd ]; then
+ mv /etc/conf.d/dhcp /etc/conf.d/dhcpd
+fi
+
diff --git a/main/dhcp/dhcpd.confd b/main/dhcp/dhcpd.confd
new file mode 100644
index 00000000000..df09ec7082f
--- /dev/null
+++ b/main/dhcp/dhcpd.confd
@@ -0,0 +1,30 @@
+# /etc/conf.d/dhcpd: config file for /etc/init.d/dhcpd
+
+# If you require more than one instance of dhcpd you can create symbolic
+# links to dhcpd service like so
+# cd /etc/init.d
+# ln -s dhcpd dhcpd.foo
+# cd ../conf.d
+# cp dhcpd dhcpd.foo
+# Now you can edit dhcpd.foo and specify a different configuration file.
+# You'll also need to specify a pidfile in that dhcpd.conf file.
+# See the pid-file-name option in the dhcpd.conf man page for details.
+
+# If you wish to run dhcpd in a chroot, uncomment the following line
+# DHCPD_CHROOT="/chroot/dhcp"
+
+# Then run emerge dhcp --config
+# All file paths below are relative to the chroot.
+# You can specify a different chroot directory but MAKE SURE it's empty.
+
+# Specify a configuration file - the default is /etc/dhcp/dhcpd.conf
+# DHCPD_CONF="/etc/dhcp/dhcpd.conf"
+
+# Configure which interface or interfaces to for dhcpd to listen on.
+# List all interfaces space separated. If this is not specified then
+# we listen on all interfaces.
+# DHCPD_IFACE=""
+
+# Insert any other dhcpd options - see the man page for a full list.
+# DHCPD_OPTS=""
+
diff --git a/main/dhcp/dhcpd.initd b/main/dhcp/dhcpd.initd
new file mode 100644
index 00000000000..cc9727fc7c8
--- /dev/null
+++ b/main/dhcp/dhcpd.initd
@@ -0,0 +1,72 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-misc/dhcp/files/dhcpd.init,v 1.5 2007/04/02 12:34:01 uberlord Exp $
+
+DHCPD_CONF=${DHCPD_CONF:-/etc/dhcp/dhcpd.conf}
+
+depend() {
+ need net
+ use logger dns
+}
+
+get_var() {
+ sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' \
+ "${DHCPD_CHROOT}/${DHCPD_CONF}"
+}
+
+start() {
+ # Work out our cffile if it's on our DHCPD_OPTS
+ case " ${DHCPD_OPTS} " in
+ *" -cf "*)
+ DHCPD_CONF=" ${DHCPD_OPTS} "
+ DHCPD_CONF="${DHCPD_CONF##* -cf }"
+ DHCPD_CONF="${DHCPD_CONF%% *}"
+ ;;
+ *) DHCPD_OPTS="${DHCPD_OPTS} -cf ${DHCPD_CONF}"
+ ;;
+ esac
+
+ if [ ! -f "${DHCPD_CHROOT}/${DHCPD_CONF}" ] ; then
+ eerror "${DHCPD_CHROOT}/${DHCPD_CONF} does not exist"
+ return 1
+ fi
+
+ local leasefile="$(get_var lease-file-name)"
+ leasefile="${DHCPD_CHROOT}/${leasefile:-/var/lib/dhcp/dhcpd.leases}"
+ if [ ! -f "${leasefile}" ] ; then
+ ebegin "Creating ${leasefile}"
+ touch "${leasefile}"
+ chown dhcp:dhcp "${leasefile}"
+ eend $? || return 1
+ fi
+
+ # Setup LD_PRELOAD so name resolution works in our chroot.
+ if [ -n "${DHCPD_CHROOT}" ] ; then
+ LD_PRELOAD="${LD_PRELOAD} /usr/lib/libresolv.so"
+ export LD_PRELOAD="${LD_PRELOAD} /usr/lib/libnss_dns.so"
+ fi
+
+ local pidfile="$(get_var pid-file-name)"
+ pidfile="${pidfile:-/var/run/dhcp/dhcpd.pid}"
+
+ ebegin "Starting ${DHCPD_CHROOT:+chrooted }${SVCNAME}"
+ start-stop-daemon --start --exec /usr/sbin/dhcpd \
+ --pidfile "${DHCPD_CHROOT}/${pidfile}" \
+ -- ${DHCPD_OPTS} -q -pf "${pidfile}" \
+ -user dhcp -group dhcp \
+ ${DHCPD_CHROOT:+-chroot} ${DHCPD_CHROOT} ${DHCPD_IFACE}
+ eend $? \
+ && save_options chroot "${DHCPD_CHROOT}" \
+ && save_options pidfile "${pidfile}"
+}
+
+stop() {
+ local chroot="$(get_options chroot)"
+
+ ebegin "Stopping ${chroot:+chrooted }${SVCNAME}"
+ start-stop-daemon --stop --exec /usr/sbin/dhcpd \
+ --pidfile "${chroot}/$(get_options pidfile)"
+ eend $?
+}
+
diff --git a/main/dhcpcd/APKBUILD b/main/dhcpcd/APKBUILD
new file mode 100644
index 00000000000..110f2c4c0b3
--- /dev/null
+++ b/main/dhcpcd/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dhcpcd
+pkgver=5.0.6
+pkgrel=0
+pkgdesc="RFC2131 compliant DHCP client"
+url="http://roy.marples.name/projects/dhcpcd/"
+license="BSD-2"
+depends=
+makedepends=""
+install=
+subpackages="$pkgname-doc"
+source="http://roy.marples.name/downloads/dhcpcd/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make LIBEXECDIR=/lib/dhcpcd \
+ DBDIR=/var/lib/dhcpcd
+ make LIBEXECDIR=/lib/dhcpcd \
+ DBDIR=/var/lib/dhcpcd \
+ DESTDIR="$pkgdir" \
+ install
+
+}
+
+md5sums="600716ddbfa2525a7ef7ae0968a8158a dhcpcd-5.0.6.tar.bz2"
diff --git a/main/dialog/APKBUILD b/main/dialog/APKBUILD
new file mode 100644
index 00000000000..99619e31cff
--- /dev/null
+++ b/main/dialog/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dialog
+pkgver=1.1.20080819
+_ver=${pkgver%.*}-${pkgver##*.}
+pkgrel=0
+pkgdesc="A script-interpreter which provides a set of curses"
+url="http://invisible-island.net/dialog/dialog.html"
+license="GPL"
+depends="uclibc ncurses"
+makedepends="ncurses-dev"
+install=
+subpackages="$pkgname-doc"
+source="ftp://invisible-island.net/dialog/$pkgname.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$_ver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="3caebd641a9f337b980becb4444336c5 dialog.tar.gz"
diff --git a/main/diffutils/APKBUILD b/main/diffutils/APKBUILD
new file mode 100644
index 00000000000..5a9177130f2
--- /dev/null
+++ b/main/diffutils/APKBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=diffutils
+pkgver=2.8.1
+pkgrel=1
+pkgdesc="Show differences among files"
+subpackages="$pkgname-doc"
+url="http://www.gnu.org/software/diffutils/"
+license="GPL2"
+depends="uclibc"
+makedepends=""
+install="$pkgname.post-deinstall"
+source="http://ftp.gnu.org/pub/gnu/diffutils/diffutils-2.8.1.tar.gz
+$install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make check || return 1
+ make install DESTDIR=$pkgdir
+}
+md5sums="71f9c5ae19b60608f6c7f162da86a428 diffutils-2.8.1.tar.gz
+e8da9a22c2389fe5e2846b8c0de45767 diffutils.post-deinstall"
diff --git a/main/diffutils/diffutils.post-deinstall b/main/diffutils/diffutils.post-deinstall
new file mode 100644
index 00000000000..c59247ad416
--- /dev/null
+++ b/main/diffutils/diffutils.post-deinstall
@@ -0,0 +1,2 @@
+#!/bin/sh
+busybox --install -s
diff --git a/main/dircproxy/1.0.5-CVE-2007-5226.patch b/main/dircproxy/1.0.5-CVE-2007-5226.patch
new file mode 100644
index 00000000000..1d9994228bd
--- /dev/null
+++ b/main/dircproxy/1.0.5-CVE-2007-5226.patch
@@ -0,0 +1,12 @@
+diff -u dircproxy-1.0.5/src/irc_server.c dircproxy-1.0.5/src/irc_server.c
+--- dircproxy-1.0.5/src/irc_server.c
++++ dircproxy-1.0.5/src/irc_server.c
+@@ -1078,7 +1078,7 @@
+
+ if (!strcmp(cmsg.cmd, "ACTION")) {
+ if (p->conn_class->log_events & IRC_LOG_ACTION)
+- irclog_ctcp(p, msg.params[0], msg.src.orig, "%s", cmsg.orig);
++ irclog_ctcp(p, (msg.params != NULL ) ? msg.params[0]: "none", msg.src.orig, "%s", cmsg.orig);
+
+ } else if (!strcmp(cmsg.cmd, "DCC")
+ && p->conn_class->dcc_proxy_incoming) {
diff --git a/main/dircproxy/1.1.0-less-lag-on-attach.patch b/main/dircproxy/1.1.0-less-lag-on-attach.patch
new file mode 100644
index 00000000000..2eb3998db1c
--- /dev/null
+++ b/main/dircproxy/1.1.0-less-lag-on-attach.patch
@@ -0,0 +1,53 @@
+--- a/src/irc_client.c 2005-01-06 02:48:12.964637427 +0100
++++ b/src/irc_client.c.lessflood 2005-01-06 02:47:50.433376383 +0100
+@@ -1910,13 +1910,34 @@
+ /* Recall channel log files, and get channel topic and members from server */
+ if (p->channels) {
+ struct ircchannel *c;
++ unsigned int cnames_length = 0;
++ char *cnames = 0;
++
++ c = p->channels;
++ while (c) {
++ if (!c->inactive && !c->unjoined) {
++ cnames_length += strlen(c->name) + 1; // +1 to hold comma
++ }
++
++ c = c->next;
++ }
++
++ if(cnames_length)
++ {
++ cnames = (char *)malloc(cnames_length + 1);
++ memset(cnames, 0, cnames_length + 1);
++ }
+
+ c = p->channels;
+ while (c) {
+ if (!c->inactive && !c->unjoined) {
+ ircclient_send_selfcmd(p, "JOIN", ":%s", c->name);
+- ircserver_send_command(p, "TOPIC", ":%s", c->name);
+- ircserver_send_command(p, "NAMES", ":%s", c->name);
++ if(cnames_length) {
++ if(c == p->channels) // first channel in list
++ sprintf(cnames, "%s", c->name);
++ else
++ sprintf(cnames, "%s,%s", cnames, c->name);
++ }
+
+ if (p->conn_class->chan_log_enabled) {
+ irclog_autorecall(p, c->name);
+@@ -1926,6 +1948,13 @@
+
+ c = c->next;
+ }
++
++ if(cnames_length)
++ {
++ ircserver_send_command(p, "TOPIC", ":%s", cnames);
++ ircserver_send_command(p, "NAMES", ":%s", cnames);
++ free(cnames);
++ }
+ }
+
+ /* Recall private log file */
diff --git a/main/dircproxy/APKBUILD b/main/dircproxy/APKBUILD
new file mode 100644
index 00000000000..becb8133ae9
--- /dev/null
+++ b/main/dircproxy/APKBUILD
@@ -0,0 +1,40 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dircproxy
+pkgver=1.1.0
+pkgrel=0
+pkgdesc="IRC proxy server designed for people who use IRC from lots of different workstations or clients"
+url="http://code.google.com/p/dircproxy/"
+license="GPL"
+depends=""
+makedepends=""
+install=
+subpackages="$pkgname-doc"
+source="http://dircproxy.googlecode.com/files/$pkgname-$pkgver.tar.gz
+ 1.0.5-CVE-2007-5226.patch
+ 1.1.0-less-lag-on-attach.patch
+ dircproxy-gcc4.patch
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 -i $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ # install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ # install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+}
+
+md5sums="066bd39d80f286ae5ce69a2adbbd01e4 dircproxy-1.1.0.tar.gz
+fdd98d0bad6ef36afba7fa2604c43520 1.0.5-CVE-2007-5226.patch
+a83ab2a3bce526ba0d8f8a05c88f9a47 1.1.0-less-lag-on-attach.patch
+3b70d62b2eb88013548871e634e33c43 dircproxy-gcc4.patch"
diff --git a/main/dircproxy/dircproxy-gcc4.patch b/main/dircproxy/dircproxy-gcc4.patch
new file mode 100644
index 00000000000..727d8db2b48
--- /dev/null
+++ b/main/dircproxy/dircproxy-gcc4.patch
@@ -0,0 +1,47 @@
+--- a/src/dcc_net.c 2001-12-21 21:15:55.000000000 +0100
++++ b/src/dcc_net.c 2004-12-14 15:40:45.976549384 +0100
+@@ -364,7 +364,8 @@
+ n = p->next;
+ _dccnet_free(p);
+
+- p = (l ? l->next : proxies) = n;
++ if (l) l->next = n; else proxies = n;
++ p = n;
+ } else {
+ l = p;
+ p = p->next;
+diff -urN a/src/irc_server.c ./src/irc_server.c
+--- a/src/irc_server.c 2002-01-31 15:56:37.000000000 +0100
++++ b/src/irc_server.c 2004-12-14 15:39:49.163186328 +0100
+@@ -700,7 +700,8 @@
+ free(s);
+
+ /* Was in the squelch list, so remove it and stop looking */
+- s = (l ? l->next : p->squelch_modes) = n;
++ if (l) l->next = n; else p->squelch_modes = n;
++ s = n;
+ squelch = 1;
+ break;
+ } else {
+@@ -741,7 +742,8 @@
+ free(s);
+
+ /* Was in the squelch list, so remove it and stop looking */
+- s = (l ? l->next : p->squelch_modes) = n;
++ if (l) l->next = n; else p->squelch_modes = n;
++ s = n;
+ squelch = 1;
+ break;
+ } else {
+diff -urN ../tmp-orig/dircproxy-1.0.5/src/net.c ./src/net.c
+--- a/src/net.c 2002-01-01 18:55:23.000000000 +0100
++++ b/src/net.c 2004-12-14 15:41:43.499804520 +0100
+@@ -459,7 +459,7 @@
+ return 0;
+ }
+
+- l = &(buff == SB_IN ? s->in_buff_last : s->out_buff_last);
++ l = (buff == SB_IN) ? &s->in_buff_last : &s->out_buff_last;
+
+ /* Check whether we can just add to the existing buffer */
+ if ((mode == SM_RAW) && *l && ((*l)->mode == mode)) {
diff --git a/main/djbdns/1.05-errno.patch b/main/djbdns/1.05-errno.patch
new file mode 100644
index 00000000000..58f2f4b6c97
--- /dev/null
+++ b/main/djbdns/1.05-errno.patch
@@ -0,0 +1,11 @@
+--- a/error.h 2001-02-11 15:11:45.000000000 -0600
++++ b/error.h 2003-02-26 02:10:21.000000000 -0600
+@@ -1,7 +1,7 @@
+ #ifndef ERROR_H
+ #define ERROR_H
+
+-extern int errno;
++#include <errno.h>
+
+ extern int error_intr;
+ extern int error_nomem;
diff --git a/main/djbdns/1.05-response.patch b/main/djbdns/1.05-response.patch
new file mode 100644
index 00000000000..eb6ae59049a
--- /dev/null
+++ b/main/djbdns/1.05-response.patch
@@ -0,0 +1,11 @@
+--- a/response.c.orig 2009-02-24 21:04:06.000000000 -0800
++++ b/response.c 2009-02-24 21:04:25.000000000 -0800
+@@ -34,7 +34,7 @@
+ uint16_pack_big(buf,49152 + name_ptr[i]);
+ return response_addbytes(buf,2);
+ }
+- if (dlen <= 128)
++ if ((dlen <= 128) && (response_len < 16384))
+ if (name_num < NAMES) {
+ byte_copy(name[name_num],dlen,d);
+ name_ptr[name_num] = response_len;
diff --git a/main/djbdns/APKBUILD b/main/djbdns/APKBUILD
new file mode 100644
index 00000000000..0596907a798
--- /dev/null
+++ b/main/djbdns/APKBUILD
@@ -0,0 +1,86 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=djbdns
+pkgver=1.05
+pkgrel=26
+pkgdesc="Excellent high-performance DNS services"
+url="http://cr.yp.to/djbdns.html"
+license="public-domain"
+depends=
+subpackages="tinydns dnscache"
+source="http://cr.yp.to/djbdns/$pkgname-$pkgver.tar.gz
+ headtail.patch
+ dnsroots.patch
+ dnstracesort.patch
+ $pkgver-errno.patch
+ $pkgver-response.patch
+ tinydns.pre-install
+ tinydns.initd
+ tinydns.confd
+ dnscache.pre-install
+ dnscache.initd
+ dnscache.confd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ echo "${CC:-"gcc"} ${CFLAGS}" > conf-cc
+ echo "${CC:-"gcc"} ${LDFLAGS}" > conf-ld
+ echo "/usr" > conf-home
+ make -j1 || return 1
+
+ mkdir -p "$pkgdir"/etc/
+ cp dnsroots.global "$pkgdir"/etc/
+ mkdir -p "$pkgdir"/usr/bin
+ cp *-conf dnscache tinydns walldns rbldns pickdns axfrdns \
+ *-get *-data *-edit dnsip dnsipq dnsname dnstxt dnsmx \
+ dnsfilter random-ip dnsqr dnsq dnstrace dnstracesort \
+ "$pkgdir"/usr/bin/
+ mkdir -p "$pkgdir"/usr/share/doc/djbdns
+}
+
+tinydns() {
+ pkgdesc="A small and secure DNS server"
+ install=tinydns.pre-install
+ mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/etc/tinydns \
+ "$subpkgdir"/var/cache/tinydns
+ mv "$pkgdir"/usr/bin/tinydns* "$subpkgdir"/usr/bin
+ install -D -m755 "$srcdir"/tinydns.initd \
+ "$subpkgdir"/etc/init.d/tinydns
+ install -D -m644 "$srcdir"/tinydns.confd \
+ "$subpkgdir"/etc/conf.d/tinydns
+}
+
+dnscache() {
+ pkgdesc="A recursive resolver"
+ install=dnscache.pre-install
+ mkdir -p "$subpkgdir"/usr/bin \
+ "$subpkgdir"/etc/dnscache/ip \
+ "$subpkgdir"/etc/dnscache/servers
+
+ cp "$pkgdir"/etc/dnsroots.global "$subpkgdir"/etc/dnscache/servers/@
+ touch "$subpkgdir"/etc/dnscache/ip/127 || return 1
+
+ mv "$pkgdir"/usr/bin/dnscache* "$subpkgdir"/usr/bin
+ install -D -m755 "$srcdir"/dnscache.initd \
+ "$subpkgdir"/etc/init.d/dnscache
+ install -D -m644 "$srcdir"/dnscache.confd \
+ "$subpkgdir"/etc/conf.d/dnscache
+}
+
+md5sums="3147c5cd56832aa3b41955c7a51cbeb2 djbdns-1.05.tar.gz
+0d2adaf9f1626043e8702b825cdccdd6 headtail.patch
+dfd675b2775efcbb604413a84db8bf1a dnsroots.patch
+6fe7f473233f1c86b76261afd8345bf0 dnstracesort.patch
+c7be73fe2fb4ae02d5096fa2c1f55a68 1.05-errno.patch
+1292500c04baba3995d9753fe40fdc94 1.05-response.patch
+7695bf50559c09798ec852b578ac8698 tinydns.pre-install
+e8a84fc4ee5ff1525b4f74889422e93c tinydns.initd
+7dcf6674c07d46c736b3c25d9c92384a tinydns.confd
+e09c3a6ba6917e16f4736ab5c070dbe9 dnscache.pre-install
+e368a86ddc320937d663dd47684ba410 dnscache.initd
+e2938593277d7a87806e70e145a90c3f dnscache.confd"
diff --git a/main/djbdns/dnscache.confd b/main/djbdns/dnscache.confd
new file mode 100644
index 00000000000..f456bf8db99
--- /dev/null
+++ b/main/djbdns/dnscache.confd
@@ -0,0 +1,23 @@
+# DNSCACHE configuration variables:
+
+# IPSEND - ip address to use for requests use 0.0.0.0 for default route
+IPSEND=0.0.0.0
+
+# CACHESIZE - Num bytes to use for the cache
+CACHESIZE=1000000
+
+# IP - IP addr to listen on
+IP=127.0.0.1
+
+#------------------------------------------------------------------------
+# The following are flags. Setting them to ANY value
+# (even "false" or "off") will turn the feature on.
+#------------------------------------------------------------------------
+
+# HIDETTL - always return TTL as 0
+#HIDETTL=
+
+# FORWARDONLY - servers/@ are parent caches, not root servers
+#FORWARDONLY=
+
+
diff --git a/main/djbdns/dnscache.initd b/main/djbdns/dnscache.initd
new file mode 100755
index 00000000000..481022496ef
--- /dev/null
+++ b/main/djbdns/dnscache.initd
@@ -0,0 +1,59 @@
+#!/sbin/runscript
+# control n instances of dnscache, without daemontools
+# written for alpine linux - NBA April 2007
+
+# -- Statrup variables
+UID=$( grep dnscache /etc/passwd | cut -f3 -d: )
+GID=$( grep dnscache /etc/group | cut -f3 -d: )
+ROOT=/etc/dnscache
+DAEMON=/usr/bin/dnscache
+VARRUN=/var/run/dnscache
+
+
+#-----------------------------------------------------------------
+# Main program
+
+start() {
+
+ ebegin "Starting dnscache"
+ if [ -z "$UID" ] || [ -z "$GID" ]; then
+ eend 1 "dnscache user or group missing"
+ return 1
+ fi
+
+ # if its already running, just report it is
+ if [ -e ${VARRUN}.pid ] && [ -d /proc/$( cat ${VARRUN}.pid ) ]; then
+ eend 0
+ return 0
+ fi
+
+ (
+ export UID GID ROOT
+ [ -n "$IPSEND" ] && export IPSEND
+ [ -n "$IP" ] && export IP
+ [ -n "$HIDETTL" ] && export HIDETTL
+ [ -n "$IPSEND" ] && export IPSEND
+ [ -n "$CACHESIZE" ] && export CACHESIZE
+ [ -n "$FORWARDONLY" ] && export FORWARDONLY
+
+ $DAEMON </dev/urandom >/dev/null 2>/dev/null &
+ pid=$!
+ sleep 1
+ # Check if its still running
+ if ! [ -d /proc/$pid ]; then
+ $DAEMON </dev/urandom
+ return 1
+ fi
+ echo $pid > ${VARRUN}.pid
+ eend $?
+ return 0
+ )
+}
+
+stop() {
+ ebegin "Stopping dnscache"
+ start-stop-daemon --stop -m --pidfile ${VARRUN}.pid --oknodo \
+ --exec $DAEMON && rm ${VARRUN}.pid
+ eend $?
+}
+
diff --git a/main/djbdns/dnscache.pre-install b/main/djbdns/dnscache.pre-install
new file mode 100644
index 00000000000..061b8f02800
--- /dev/null
+++ b/main/djbdns/dnscache.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+adduser -h /etc/dnscache -g dnscache -s /bin/false -H -D dnscache 2>/dev/null
+exit 0
+
diff --git a/main/djbdns/dnsroots.patch b/main/djbdns/dnsroots.patch
new file mode 100644
index 00000000000..5db44ec8f41
--- /dev/null
+++ b/main/djbdns/dnsroots.patch
@@ -0,0 +1,18 @@
+--- djbdns-1.05.old/dnsroots.global.old Fri May 31 19:42:37 2002
++++ djbdns-1.05/dnsroots.global Thu Jan 29 21:41:56 2004
+@@ -1,5 +1,5 @@
+ 198.41.0.4
+-128.9.0.107
++192.228.79.201
+ 192.33.4.12
+ 128.8.10.90
+ 192.203.230.10
+@@ -7,7 +7,7 @@
+ 192.112.36.4
+ 128.63.2.53
+ 192.36.148.17
+-198.41.0.10
++192.58.128.30
+ 193.0.14.129
+ 198.32.64.12
+ 202.12.27.33
diff --git a/main/djbdns/dnstracesort.patch b/main/djbdns/dnstracesort.patch
new file mode 100644
index 00000000000..3bf56f5a1ce
--- /dev/null
+++ b/main/djbdns/dnstracesort.patch
@@ -0,0 +1,11 @@
+--- djbdns-1.05/dnstracesort.sh.orig 2006-04-26 21:52:54.000000000 +0200
++++ djbdns-1.05/dnstracesort.sh 2006-04-26 21:53:02.000000000 +0200
+@@ -12,7 +12,7 @@
+ }
+ print
+ }
+-' | sort -t: +0 -2 +4 +3 -4 +2 -3 | uniq | awk -F: '
++' | sort -t: -k 1,3 -k 5 -k 4,5 -k 3,4 | uniq | awk -F: '
+ {
+ type = $1
+ q = $2
diff --git a/main/djbdns/headtail.patch b/main/djbdns/headtail.patch
new file mode 100644
index 00000000000..31854803ba8
--- /dev/null
+++ b/main/djbdns/headtail.patch
@@ -0,0 +1,67 @@
+diff -Naur /tmp/djbdns-1.05/Makefile djbdns-1.05/Makefile
+--- a/Makefile 2003-11-16 20:33:41.000000000 +0100
++++ b/Makefile 2003-11-16 20:35:15.000000000 +0100
+@@ -31,7 +31,7 @@
+
+ auto_home.c: \
+ auto-str conf-home
+- ./auto-str auto_home `head -1 conf-home` > auto_home.c
++ ./auto-str auto_home `head -n 1 conf-home` > auto_home.c
+
+ auto_home.o: \
+ compile auto_home.c
+@@ -205,14 +205,14 @@
+ choose: \
+ warn-auto.sh choose.sh conf-home
+ cat warn-auto.sh choose.sh \
+- | sed s}HOME}"`head -1 conf-home`"}g \
++ | sed s}HOME}"`head -n 1 conf-home`"}g \
+ > choose
+ chmod 755 choose
+
+ compile: \
+ warn-auto.sh conf-cc
+ ( cat warn-auto.sh; \
+- echo exec "`head -1 conf-cc`" '-c $${1+"$$@"}' \
++ echo exec "`head -n 1 conf-cc`" '-c $${1+"$$@"}' \
+ ) > compile
+ chmod 755 compile
+
+@@ -449,7 +449,7 @@
+ dnstracesort: \
+ warn-auto.sh dnstracesort.sh conf-home
+ cat warn-auto.sh dnstracesort.sh \
+- | sed s}HOME}"`head -1 conf-home`"}g \
++ | sed s}HOME}"`head -n 1 conf-home`"}g \
+ > dnstracesort
+ chmod 755 dnstracesort
+
+@@ -570,7 +570,7 @@
+ warn-auto.sh conf-ld
+ ( cat warn-auto.sh; \
+ echo 'main="$$1"; shift'; \
+- echo exec "`head -1 conf-ld`" \
++ echo exec "`head -n 1 conf-ld`" \
+ '-o "$$main" "$$main".o $${1+"$$@"}' \
+ ) > load
+ chmod 755 load
+@@ -758,7 +758,7 @@
+ rts: \
+ warn-auto.sh rts.sh conf-home
+ cat warn-auto.sh rts.sh \
+- | sed s}HOME}"`head -1 conf-home`"}g \
++ | sed s}HOME}"`head -n 1 conf-home`"}g \
+ > rts
+ chmod 755 rts
+
+@@ -901,8 +901,8 @@
+ systype: \
+ find-systype.sh conf-cc conf-ld trycpp.c x86cpuid.c
+ ( cat warn-auto.sh; \
+- echo CC=\'`head -1 conf-cc`\'; \
+- echo LD=\'`head -1 conf-ld`\'; \
++ echo CC=\'`head -n 1 conf-cc`\'; \
++ echo LD=\'`head -n 1 conf-ld`\'; \
+ cat find-systype.sh; \
+ ) | sh > systype
+
diff --git a/main/djbdns/tinydns.confd b/main/djbdns/tinydns.confd
new file mode 100644
index 00000000000..840570a63c2
--- /dev/null
+++ b/main/djbdns/tinydns.confd
@@ -0,0 +1,2 @@
+# IP is the ip address to listen on
+IP=127.0.0.1
diff --git a/main/djbdns/tinydns.initd b/main/djbdns/tinydns.initd
new file mode 100755
index 00000000000..a68474c4ecb
--- /dev/null
+++ b/main/djbdns/tinydns.initd
@@ -0,0 +1,87 @@
+#!/sbin/runscript
+# control an instance of tinydns, without daemontools
+# written for alpine linux - NBA April 2007
+
+opts="reload"
+
+# -- Statrup variables
+DAEMON=/usr/bin/tinydns
+COMPILER=/usr/bin/tinydns-data
+
+IFACE="${SVCNAME#*.}"
+if [ -n "$IFACE" ] && [ "${SVCNAME}" != "tinydns" ]; then
+ ROOT=${ROOT:-/var/cache/tinydns.$IFACE}
+ VARRUN=${VARRUN:-/var/run/tinydns.$IFACE}
+ DATADIR=${DATADIR:-/etc/tinydns.$IFACE}
+else
+ ROOT=${ROOT:-/var/cache/tinydns}
+ VARRUN=${VARRUN:-/var/run/tinydns}
+ DATADIR=${DATADIR:-/etc/tinydns}
+fi
+
+
+#-----------------------------------------------------------------
+# Main program
+reload() {
+ local rc opwd="$opwd"
+ UID=$( grep tinydns /etc/passwd | cut -f3 -d: )
+ GID=$( grep tinydns /etc/group | cut -f3 -d: )
+
+ # Create the $ROOT directory if necessary
+ if [ ! -d "$ROOT" ]; then
+ mkdir -p "$ROOT"
+ chown $UID:$GID "$ROOT"
+ fi
+
+ # If a file named "data" exists in the $ROOT dir
+ # Then we just use it and ignore anything else
+ # If the "data" file does not exist, we attempt
+ # to build one out of the "zone files".
+ ebegin "Generating tinydns cache"
+ rm -f "$ROOT/data"
+ if [ -e $DATADIR/data ]; then
+ ln -sf "$DATADIR/data" "$ROOT/data"
+ else
+ set -- $( find $DATADIR -type f )
+ if [ $# -eq 0 ]; then
+ eend 1 "Missing data or zone files in $DATADIR"
+ return 1
+ fi
+ cat "$@" > "$ROOT/data"
+ fi
+ cd "$ROOT" || return 1
+ [ -e data ] || rm -f data.cdb
+ $COMPILER
+ rc=$?
+ cd "$opwd"
+ eend $rc
+ return $rc
+}
+
+start() {
+ # Always do a reload on start
+ reload || return 1
+
+ ebegin "Starting tinydns"
+ if [ -z "$UID" ] || [ -z "$GID" ]; then
+ eend 1 "tinydns user or group missing"
+ return 1
+ fi
+
+ if [ -z "$IP" ]; then
+ eend 1 "IP is not specified in /etc/conf.d/$SVCNAME"
+ return 1
+ fi
+
+ start-stop-daemon --start --env "UID=$UID" --env "GID=$GID" \
+ --env "ROOT=$ROOT" --env "IP=$IP" --pidfile ${VARRUN}.pid \
+ --background --make-pidfile --exec $DAEMON
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping tinydns"
+ start-stop-daemon --stop --pidfile ${VARRUN}.pid --exec $DAEMON
+ eend $?
+}
+
diff --git a/main/djbdns/tinydns.pre-install b/main/djbdns/tinydns.pre-install
new file mode 100644
index 00000000000..11ea87abcb9
--- /dev/null
+++ b/main/djbdns/tinydns.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+adduser -h /etc/tinydns -g tinydns -s /bin/false -H -D tinydns 2>/dev/null
+exit 0
+
diff --git a/main/dnsmasq/APKBUILD b/main/dnsmasq/APKBUILD
new file mode 100644
index 00000000000..328d54dfded
--- /dev/null
+++ b/main/dnsmasq/APKBUILD
@@ -0,0 +1,37 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dnsmasq
+pkgver=2.49
+pkgrel=0
+pkgdesc="Small forwarding DNS server"
+url="http://www.thekelleys.org.uk/dnsmasq/"
+license="GPL-2"
+depends=
+subpackages="$pkgname-doc"
+source="http://www.thekelleys.org.uk/dnsmasq/$pkgname-$pkgver.tar.gz
+ $pkgname.initd
+ $pkgname.confd
+ "
+
+build() {
+ # src_unpack
+ cd "$srcdir/$pkgname-$pkgver"
+ sed -i -e 's/^AWK.*/AWK = awk/' Makefile
+ make PREFIX=/usr \
+ CFLAGS="$CFLAGS" \
+ DBUS_LIBS= \
+ DBUS_CFLAGS= \
+ DBUS_MINOR= \
+ all || return 1
+ make PREFIX=/usr \
+ DESTDIR="$pkgdir" \
+ DBUS_LIBS= \
+ DBUS_CFLAGS= \
+ DBUS_MINOR= \
+ install
+ install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ install dnsmasq.conf.example "$pkgdir"/etc/dnsmasq.conf
+}
+md5sums="7ccc861d8a733474f9c0a0a127006ee9 dnsmasq-2.49.tar.gz
+fbea3f4a794a6a00cc6fe79c6d44606a dnsmasq.initd
+5990c2d2cb92209feacf8f3a5a7d0831 dnsmasq.confd"
diff --git a/main/dnsmasq/dnsmasq.confd b/main/dnsmasq/dnsmasq.confd
new file mode 100644
index 00000000000..47826dd5082
--- /dev/null
+++ b/main/dnsmasq/dnsmasq.confd
@@ -0,0 +1,4 @@
+# /etc/conf.d/dnsmasq: config file for /etc/init.d/dnsmasq
+
+# See the dnsmasq(8) man page for possible options to put here.
+DNSMASQ_OPTS=""
diff --git a/main/dnsmasq/dnsmasq.initd b/main/dnsmasq/dnsmasq.initd
new file mode 100644
index 00000000000..44109e98295
--- /dev/null
+++ b/main/dnsmasq/dnsmasq.initd
@@ -0,0 +1,38 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/files/dnsmasq-init,v 1.13 2008/01/29 15:06:30 flameeyes Exp $
+
+opts="reload"
+
+depend() {
+ provide dns
+ need localmount net
+ after bootmisc
+}
+
+start() {
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --exec /usr/sbin/dnsmasq \
+ --pidfile /var/run/dnsmasq.pid \
+ -- -x /var/run/dnsmasq.pid ${DNSMASQ_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --exec /usr/sbin/dnsmasq \
+ --pidfile /var/run/dnsmasq.pid
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${SVCNAME}"
+ if ! service_started "${SVCNAME}" ; then
+ eend 1 "${SVCNAME} is not started"
+ return 1
+ fi
+ start-stop-daemon --stop --oknodo --signal HUP \
+ --exec /usr/sbin/dnsmasq --pidfile /var/run/dnsmasq.pid
+ eend $?
+}
diff --git a/main/dovecot/APKBUILD b/main/dovecot/APKBUILD
new file mode 100644
index 00000000000..67d1c870782
--- /dev/null
+++ b/main/dovecot/APKBUILD
@@ -0,0 +1,35 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=dovecot
+pkgver=1.2.1
+pkgrel=0
+pkgdesc="IMAP and POP3 server"
+url="http://www.dovecot.org/"
+license="LGPL-2.1"
+depends=
+makedepends="libcap-dev zlib-dev openssl-dev bzip2-dev"
+install="dovecot.pre-install"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://www.dovecot.org/releases/1.2/$pkgname-$pkgver.tar.gz
+ dovecot.initd
+ $install
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/dovecot \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-ssl=openssl || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+}
+
+md5sums="c269cfe38fc40061e232dd28e5fe3721 dovecot-1.2.1.tar.gz
+573e14589a6f8424d55753a2794ab99a dovecot.initd
+f0f8893411f5e482e14f40a81a177b19 dovecot.pre-install"
diff --git a/main/dovecot/dovecot.initd b/main/dovecot/dovecot.initd
new file mode 100644
index 00000000000..d9799c0dce2
--- /dev/null
+++ b/main/dovecot/dovecot.initd
@@ -0,0 +1,57 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-mail/dovecot/files/dovecot.init-r2,v 1.1 2008/11/03 17:22:59 wschlich Exp $
+
+opts="reload"
+
+depend() {
+ need localmount net
+ after bootmisc ldap mysql ntp-client ntpd postgresql saslauthd slapd
+ use logger
+}
+
+checkconfig() {
+ DOVECOT_INSTANCE=${SVCNAME##*.}
+ if [ -n "${DOVECOT_INSTANCE}" -a "${SVCNAME}" != "dovecot" ]; then
+ DOVECOT_CONF=/etc/dovecot/dovecot.${DOVECOT_INSTANCE}.conf
+ else
+ DOVECOT_CONF=/etc/dovecot/dovecot.conf
+ fi
+ if [ ! -e ${DOVECOT_CONF} ]; then
+ eerror "You will need an ${DOVECOT_CONF} first"
+ return 1
+ fi
+ DOVECOT_BASEDIR=$(/usr/sbin/dovecot -c ${DOVECOT_CONF} -a | sed -ne '/^base_dir/{s#^base_dir:[[:space:]]*\(.*[^/]\)/\?$#\1#;p}')
+ DOVECOT_BASEDIR=${DOVECOT_BASEDIR:-/var/run/dovecot}
+ DOVECOT_PIDFILE=${DOVECOT_BASEDIR}/master.pid
+ if [ ! -d "${DOVECOT_BASEDIR}" ]; then
+ ebegin "Creating missing base_dir ${DOVECOT_BASEDIR}"
+ install -d -o root -g root -m 0755 "${DOVECOT_BASEDIR}"
+ eend $?
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --exec /usr/sbin/dovecot \
+ --pidfile "${DOVECOT_PIDFILE}" -- -c "${DOVECOT_CONF}"
+ eend $?
+}
+
+stop() {
+ checkconfig || return 1
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --exec /usr/sbin/dovecot \
+ --pidfile "${DOVECOT_PIDFILE}"
+ eend $?
+}
+
+reload() {
+ checkconfig || return 1
+ ebegin "Reloading ${SVCNAME} configs and restarting auth/login processes"
+ start-stop-daemon --stop --oknodo --exec /usr/sbin/dovecot \
+ --pidfile "${DOVECOT_PIDFILE}" --signal HUP
+ eend $?
+}
diff --git a/main/dovecot/dovecot.pre-install b/main/dovecot/dovecot.pre-install
new file mode 100644
index 00000000000..5acdcb5c8d8
--- /dev/null
+++ b/main/dovecot/dovecot.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -h /dev/null -s /bin/false -D dovecot 2>/dev/null
+exit 0
diff --git a/main/dropbear/APKBUILD b/main/dropbear/APKBUILD
new file mode 100644
index 00000000000..ca4af482cfb
--- /dev/null
+++ b/main/dropbear/APKBUILD
@@ -0,0 +1,38 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+pkgname=dropbear
+pkgver=0.52
+pkgrel=1
+pkgdesc="small SSH 2 client/server designed for small memory environments"
+url="http://matt.ucc.asn.au/dropbear/dropbear.html"
+license='MIT'
+depends="zlib"
+makedepends="zlib-dev"
+source="http://matt.ucc.asn.au/dropbear/releases/${pkgname}-${pkgver}.tar.bz2
+dropbear.initd
+dropbear.confd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --disable-lastlog
+ progs="dbclient dropbearkey dropbearconvert scp"
+ make PROGRAMS="dropbear ${progs}" MULTI=1 || return 1
+ install -Dm755 "$srcdir/$pkgname-$pkgver"/dropbearmulti "$pkgdir"/usr/bin/dropbearmulti || return 1
+ cd "$pkgdir/usr/bin" || return 1
+ for i in ${progs}; do
+ msg "linking ${i##*/}"
+ ln -s dropbearmulti $i || return 1
+ done
+ msg "linking dropbear"
+ mkdir -p "$pkgdir"/usr/sbin || return 1
+ cd "$pkgdir/usr/sbin" || return 1
+ ln -s ../bin/dropbearmulti dropbear || return 1
+ install -D -m755 "$srcdir"/dropbear.initd "$pkgdir"/etc/init.d/dropbear || return 1
+ install -D -m644 "$srcdir"/dropbear.confd "$pkgdir"/etc/conf.d/dropbear || return 1
+}
+
+md5sums="a1fc7adf601bca53330a792a9c873439 dropbear-0.52.tar.bz2
+34fea1c967596ebcd6d10d38444f2b92 dropbear.initd
+af73c487e2be37d65d0e8bf80489357e dropbear.confd"
+
diff --git a/main/dropbear/dropbear.confd b/main/dropbear/dropbear.confd
new file mode 100644
index 00000000000..555f275d993
--- /dev/null
+++ b/main/dropbear/dropbear.confd
@@ -0,0 +1,6 @@
+# /etc/conf.d/dropbear: config file for /etc/init.d/dropbear
+
+# see `dropbear -h` for more information
+# -w disables root logins
+# -p # changes the port number to listen on
+DROPBEAR_OPTS=""
diff --git a/main/dropbear/dropbear.initd b/main/dropbear/dropbear.initd
new file mode 100644
index 00000000000..afdee8c6d3c
--- /dev/null
+++ b/main/dropbear/dropbear.initd
@@ -0,0 +1,36 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/dropbear/files/dropbear.init.d,v 1.2 2004/07/14 23:57:35 agriffis Exp $
+
+depend() {
+ use logger dns
+ need net
+}
+
+check_config() {
+ if [ ! -e /etc/dropbear/ ] ; then
+ mkdir /etc/dropbear/
+ fi
+ if [ ! -e /etc/dropbear/dropbear_dss_host_key ] ; then
+ einfo "Generating DSS-Hostkey..."
+ /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
+ fi
+ if [ ! -e /etc/dropbear/dropbear_rsa_host_key ] ; then
+ einfo "Generating RSA-Hostkey..."
+ /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
+ fi
+}
+
+start() {
+ check_config || return 1
+ ebegin "Starting dropbear"
+ /usr/sbin/dropbear ${DROPBEAR_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping dropbear"
+ start-stop-daemon --stop --pidfile /var/run/dropbear.pid
+ eend $?
+}
diff --git a/main/dtach/APKBUILD b/main/dtach/APKBUILD
new file mode 100644
index 00000000000..120ef4eee78
--- /dev/null
+++ b/main/dtach/APKBUILD
@@ -0,0 +1,23 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=dtach
+pkgver=0.8
+pkgrel=0
+pkgdesc="A program that emulates the detach feature of screen"
+url="http://dtach.sourceforge.net"
+license='GPL'
+depends="uclibc"
+makedepends=""
+source="http://surfnet.dl.sourceforge.net/sourceforge/dtach/dtach-0.8.tar.gz"
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr
+ make || return 1
+ install -Dm755 "$srcdir"/dtach-0.8/dtach "$pkgdir"/usr/bin/dtach
+ install -Dm644 "$srcdir"/dtach-0.8/dtach.1 "$pkgdir"/usr/share/man/man1/dtach.1
+ install -Dm644 "$srcdir"/dtach-0.8/README "$pkgdir"/usr/share/doc/README
+}
+
+md5sums="ec5999f3b6bb67da19754fcb2e5221f3 dtach-0.8.tar.gz"
diff --git a/main/eggdrop/APKBUILD b/main/eggdrop/APKBUILD
new file mode 100644
index 00000000000..59c21f2e07b
--- /dev/null
+++ b/main/eggdrop/APKBUILD
@@ -0,0 +1,69 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+pkgname=eggdrop
+pkgver=1.6.19
+pkgrel=1
+pkgdesc="World's most popular Open Source IRC bot"
+url="http://www.eggheads.org/"
+license='GPL-2'
+depends="tcl"
+makedepends="tcl-dev !bind-libs"
+install="$pkgname.post-install"
+subpackages="$pkgname-logs2html $pkgname-gseen"
+source="ftp://ftp.eggheads.org/pub/eggdrop/GNU/1.6/${pkgname}${pkgver}.tar.bz2
+eggdrop-installer
+$install
+gseen.mod.patch
+logs2html.mod.patch"
+
+build() {
+ cd "$srcdir/${pkgname}${pkgver}"
+
+ for i in "$srcdir"/*.patch; do
+ msg "Applying ${i}"
+ patch -p0 -i $i || return 1
+ done
+
+ ./configure --prefix=/usr
+ make config || return 1
+ make || return 1
+ mkdir -p $pkgdir/opt/eggdrop
+ make -j1 DEST="$pkgdir/opt/eggdrop" install
+ install -Dm755 "$srcdir"/eggdrop-installer "$pkgdir"/usr/bin/eggdrop-installer || return 1
+}
+
+logs2html() {
+ install=""
+ cd "$srcdir/${pkgname}${pkgver}"
+
+ for dirs in language help; do
+ mkdir -p "$subpkgdir"/opt/eggdrop/${dirs}
+ mv "$pkgdir"/opt/eggdrop/${dirs}/logs2html.* "$subpkgdir"/opt/eggdrop/${dirs}/ || return 1
+ done
+
+ mkdir -p "$subpkgdir"/opt/eggdrop/modules/
+ mv "$pkgdir"/opt/eggdrop/modules/logs2html.so "$subpkgdir"/opt/eggdrop/modules/ || return 1
+ mkdir -p "$subpkgdir"/opt/eggdrop/log2html
+
+ for files in logs2html.conf top100.tpl user.css readme.txt chan.list; do
+ cp src/mod/logs2html.mod/${files} "$subpkgdir"/opt/eggdrop/log2html/ || return 1
+ done
+}
+
+
+gseen() {
+ install=""
+ cd "$srcdir/${pkgname}${pkgver}"
+ mkdir -p "$subpkgdir"/opt/eggdrop/language
+ mv "$pkgdir"/opt/eggdrop/language/gseen.* "$subpkgdir"/opt/eggdrop/language/ || return 1
+ mkdir -p "$subpkgdir"/opt/eggdrop/modules/
+ mv "$pkgdir"/opt/eggdrop/modules/gseen.so "$subpkgdir"/opt/eggdrop/modules/ || return 1
+ mkdir -p "$subpkgdir"/opt/eggdrop/gseen
+ cp src/mod/gseen.mod/gseen.conf "$subpkgdir"/opt/eggdrop/gseen/ || return 1
+ cp src/mod/gseen.mod/README "$subpkgdir"/opt/eggdrop/gseen/ || return 1
+}
+
+md5sums="b706bbe4fdd05964e0ea0cd920f28539 eggdrop1.6.19.tar.bz2
+d5214dc16c07c55edff22f495c9c367b eggdrop-installer
+48ac9f366630ca18281ab2c98a5091ba eggdrop.post-install
+37b82f60413913758cd4161dbc2e7849 gseen.mod.patch
+490ffd522d5058413c96b8325d19b838 logs2html.mod.patch"
diff --git a/main/eggdrop/eggdrop-installer b/main/eggdrop/eggdrop-installer
new file mode 100644
index 00000000000..69faa00dca8
--- /dev/null
+++ b/main/eggdrop/eggdrop-installer
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-irc/eggdrop/files/eggdrop-installer,v 1.10 2007/03/14 17:52:24 drac Exp $
+
+source /sbin/functions.sh || {
+ echo "${0}: Could not source /etc/init.d/functions.sh!"
+ exit 1
+}
+
+# Checks to see if user is trying to install eggdrop as root.
+root_check() {
+ if [ "${HOME}" = "/root" ] || [ "$(whoami)" = "root" ]
+ then
+ ewarn "You should not be installing eggdrop as root."
+ ewarn
+ ewarn "Installing eggdrop as root leaves your computer vulnerable"
+ ewarn "to attack from other irc clients. Please use the eggdrop-installer"
+ ewarn "script as the user who you wish to run eggdrop with"
+ exit 1
+ fi
+}
+
+# Usage information
+usage() {
+ cat <<USAGE_END
+Usage: eggdrop-installer <bot-name>
+Install eggdrop for a specific user, creating the directories and files
+needed for eggdrop to run securely and safely.
+USAGE_END
+ exit 1
+}
+
+# Install eggdrop
+install_eggdrop() {
+ einfo "Installing Eggdrop"
+ einfo
+
+ root_check
+
+ if [ -d "${bot_dir}" ]
+ then
+ einfo "Already found a bot home directory for ${bot_name}"
+ exit 1
+ fi
+
+ einfo "Creating directories for your eggdrop..."
+ for dir in logs filesys/incoming text tmp scripts var
+ do
+ mkdir -p "${bot_dir}/${dir}"
+ done
+
+ einfo "Creating symlinks to required files for your bot to run..."
+ for file in help language modules eggdrop
+ do
+ ln -s "/opt/eggdrop/${file}" "${bot_dir}/${file}"
+ done
+
+ einfo "Copying motd, banner, scripts and config file..."
+ cp /opt/eggdrop/text/* "${bot_dir}/text"
+ cp /opt/eggdrop/scripts/* "${bot_dir}/scripts"
+ cp /opt/eggdrop/eggdrop.conf "${bot_dir}/eggdrop.conf"
+
+ einfo "Finished..."
+ einfo
+ einfo "Please edit your ${bot_dir}/eggdrop.conf!"
+ einfo
+ einfo "The bot needs to be run from the ${bot_dir} directory."
+ einfo "Run 'cd ${bot_dir} && ./eggdrop -m eggdrop.conf'"
+ einfo "to create the user file and then remove the -m command line option"
+ einfo "to start your eggdrop bot."
+ einfo
+ einfo "If you need any help please refer to the man page, or"
+ einfo "eggdrop website at http://www.egghelp.org/"
+}
+
+if [ -z "${1}" ]
+then
+ usage
+else
+ bot_name="${1}"
+ bot_dir="${HOME}/.eggdrop/${bot_name}"
+ install_eggdrop
+fi
diff --git a/main/eggdrop/eggdrop.post-install b/main/eggdrop/eggdrop.post-install
new file mode 100644
index 00000000000..44b43cf34ef
--- /dev/null
+++ b/main/eggdrop/eggdrop.post-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+echo "*"
+echo "* Please run /usr/bin/eggdrop-installer to install your eggdrop bot."
+echo "*"
+exit 0
+
diff --git a/main/eggdrop/gseen.mod.patch b/main/eggdrop/gseen.mod.patch
new file mode 100644
index 00000000000..e70aef88734
--- /dev/null
+++ b/main/eggdrop/gseen.mod.patch
@@ -0,0 +1,5123 @@
+diff -Nur src/mod/gseen.mod/Makefile src/mod/gseen.mod/Makefile
+--- src/mod/gseen.mod/Makefile 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/Makefile 2002-10-26 13:17:44.000000000 +0200
+@@ -0,0 +1,28 @@
++# Makefile for src/mod/gseen.mod/
++
++doofus:
++ @echo ""
++ @echo "Let's try this from the right directory..."
++ @echo ""
++ @cd ../../../; make
++
++clean:
++ @rm -f *.o *.$(MOD_EXT) *~
++
++static: ../gseen.o
++
++modules: ../../../gseen.$(MOD_EXT)
++
++../gseen.o: ../module.h ../modvals.h ../../eggdrop.h datahandling.c \
++ gseen.c sensors.c gseencmds.c gseencmds.c do_seen.c ai.c tclcmds.c \
++ misc.c seentree.c generic_binary_tree.c slang_gseen_commands.c \
++ slang.c slang_text.c slang_ids.c slang_chanlang.c seenlang.h \
++ slang_multitext.c gseen.h
++ $(CC) $(CFLAGS) $(CPPFLAGS) -DMAKING_MODS -c gseen.c
++ rm -f ../gseen.o
++ mv gseen.o ../
++
++../../../gseen.$(MOD_EXT): ../gseen.o
++ $(LD) -o ../../../gseen.$(MOD_EXT) ../gseen.o $(XLIBS)
++
++#safety hash
+diff -Nur src/mod/gseen.mod/README src/mod/gseen.mod/README
+--- src/mod/gseen.mod/README 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/README 2002-10-26 13:17:45.000000000 +0200
+@@ -0,0 +1,140 @@
++Description:
++------------
++
++gseen.mod is a seen module for eggdrop that tracks not only the users in the
++bot's userfile, but everyone who enters one of the bots channels.
++It does pretty much the same as the popular script bseen and has a few
++additional features like AI-seen and seen-notification.
++It's also way faster than any corresponding script because scripts are always
++much slower than modules. Especially scripts that deal with large amount of
++data often become incredible slow.
++
++Installation:
++-------------
++
++gseen.mod is written for eggdrop1.6, but it should also work with eggdrop 1.4.
++
++You need the eggdrop source to compile the module.
++
++The following instructions assume, ~/eggdrop1.6.2/ is the directory
++where you installed your eggdrop from. (of course, other source dirs
++will work as well)
++
++Put gseen.mod.1.1.0.tar.gz in ~/eggdrop1.6.2/src/mod/,
++and unpack it (tar xfz gseen.mod.1.1.0.tar.gz). Change directory
++back to ~/eggdrop1.6.2/.
++
++Now just do what you've done when you compiled your bot:
++"./configure"
++"make config" (you can skip this command on eggdrop 1.4)
++"make"
++"make install"
++
++Don't forget to copy the langfiles from eggdrop1.6.2/src/mod/gseen.mod/ to
++eggdrop/language.
++
++All settings can be found in ~/eggdrop1.6.2/src/mod/gseen.mod/gseen.conf
++Copy it to your eggdrop directory, edit it to fit your needs and put
++"source gseen.conf" at the end of your eggdrop config file. The last thing
++to do is to .rehash your bot.
++
++
++Public commands:
++----------------
++
++!seen <nick>
++ I think this command doesn't need an explanation. ^_^
++!seen <mask>
++ Searches the database for entries that match <mask>
++ for example "!seen *!user@dialin-*.isp.com"
++!seennick <nick>
++ !seen also checks if a user was online later with a
++ different nick. !seennick only seens for <nick>
++!seenstats
++ just a little report on how many nicks are tracked
++
++All commands are also accessible via /msg.
++("/msg <bot> seen <nick>", for example)
++
++
++AI seen:
++--------
++
++This module has a simple built in AI routine.
++A short example:
++
++<G`Quann> Argo: have you seen Fabian recently?
++<|Argo|> G`Quann, fabian (~fabian@dns.gifs.de) was last seen quitting
++from #eggdev 1 week 4 days 9 hours 40 minutes 56 seconds ago
++(20.02. 01:39) stating ".....zzzzZZZzzZZZzZZZZZZZZZZzzz..".
++
++Well, it's not a very intelligent AI, it's rather brute-force. So don't
++forget to use the ai-seen-ignore setting.
++I know that's not coded very elegant, but if you configure it correctly,
++the failure-rate is way lower than with other AI scripts...
++
++DCC commands:
++-------------
++
++.seen
++.seennick
++.seenstats
++ just the same as the public versions
++.purgeseens
++ deletes expired data (this also happens automatically once a day)
++ (m)
++
++Channel Settings:
++-----------------
++
++ +noseendata
++ don't log any seen data in this channel
++ +quietseens
++ send answers directly via notice to the person who asked and
++ don't bother the rest of the channel with the reply
++ +quietaiseens
++ same as +quietseens, but for AI seens
++ +nopubseens
++ ignore every seen-command in this channel
++
++TCL commands:
++-------------
++
++There are no special tcl commands, only the usual bind procs.
++
++The only one that should be mentioned is:
++
++*pubm:seen <nick> <uhost> <hand> <chan> <text>
++ triggers the AI seen
++ returns: 1 if a reply was sent, 0 otherwise
++
++So if you're using another AI script on your bot, you can modify it to
++use this proc and avoid doubled replies this way.
++
++Other:
++------
++
++There is absolutely NO WARRANTY on this module. I do my best to make it
++work properly, but if anything gets screwed up, I'm not responsible. Use
++this module at your own risk.
++
++Feedback:
++---------
++
++Feel free to send feedback and bugreports (I hope there won't be any<g>) to
++gseen.mod@visions-of-fantasy.de
++
++The newest gseen version can always be found at:
++http://www.visions-of-fantasy.de/gseen.mod/
++
++Thanks to:
++----------
++
++- Fabian for teaching me plenty of things
++- everyone who tested the many buggy development versions :)
++- the eggdev team for developing eggdrop
++
++Most of all, I would like to thank Bass for writing bseen.tcl because alot
++of the ideas for this module came from using that tcl script. It's still the
++most powerful seen script, so if you want something that's easier to use than
++a module, get a copy of bseen.tcl.
+diff -Nur src/mod/gseen.mod/UPDATES src/mod/gseen.mod/UPDATES
+--- src/mod/gseen.mod/UPDATES 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/UPDATES 2002-10-26 13:17:46.000000000 +0200
+@@ -0,0 +1,55 @@
++Changes in gseen.mod: (since v1.0.0)
++--------------------
++
++1.1.1
++- fixed "no newline" compilation warnings that appeared on some systems.
++- fixed uninitialized "li" variable in do_seen()
++- fixed lacking compatibility to eggdrop1.4 (confirmation anyone?)
++- new option: hide-secret-chans
++
++1.1.0 (15.6.2001)
++- added multilang support
++- removed static buffers
++- organized data in a binary search tree (much faster)
++- optimized a few other things
++- added settings:
++ - fuzzy-search
++ - max-matches
++ - wildcard-search
++
++1.0.8
++- quiet-seens wasn't working for !seennick
++- added quiet-ai-seens
++- renamed nopub to nopubseens and nolog to noseendata and
++ quietseen to quietseens
++
++1.0.7
++- added compatibility to !channels
++- fixed a bug relating strict-host 0 had some strange effects on
++ !seen requests for users with ~ in their ident
++
++1.0.6
++- fixed a very evil bug that allowed anyone to crash the bot, sorry
++
++1.0.5
++- quietseens wasn't working correctly
++- added support for egg1.5's udef chansets
++
++1.0.4
++- added GPL stuff
++- changed error msg that appears if no gseen file exists
++
++1.0.3
++- readme updates
++- fixed a grammatical error in do_seen
++
++1.0.2
++- bot wanted to free a NULL pointer sometimes
++
++1.0.1
++- !seen without parameter returned stupid results :)
++- fixed little typo in .purgeseens
++- "I found 1 matches..." -> "I found 1 match..."
++
++1.0.0
++- release :)
+diff -Nur src/mod/gseen.mod/addons/gseen.selectlang.1.0.0.tcl src/mod/gseen.mod/addons/gseen.selectlang.1.0.0.tcl
+--- src/mod/gseen.mod/addons/gseen.selectlang.1.0.0.tcl 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/addons/gseen.selectlang.1.0.0.tcl 2002-10-26 13:18:14.000000000 +0200
+@@ -0,0 +1,80 @@
++#####################################################################
++#
++# gseen.selectlang v1.0.0
++#
++# This is a simple script which selects a language based on the
++# user's host.
++#
++# It only works for /msg commands.
++#
++# If the user is in a channel which has a language defined, gseen's
++# internal functions will override this selection and use the language
++# of the channel instead.
++#
++#####################################################################
++
++
++# Here you can define which language to use for which host.
++# The first part is the mask for the host, and the second part
++# is the language which should be used for this host.
++
++set tld-langs {
++ {"*.de" "de"}
++ {"*.at" "de"}
++ {"*.ch" "de"}
++ {"*.t-dialin.net" "de"}
++ {"*.t-ipconnect.net" "de"}
++ {"*.pl" "pl"}
++ {"*.jp" "ja"}
++}
++
++#################################################
++
++
++proc selectlang:getlang {uhost} {
++ global tld-langs
++
++ foreach tld ${tld-langs} {
++ if {[string match [lindex $tld 0] $uhost]} {
++ return [lindex $tld 1]
++ }
++ }
++ return ""
++}
++
++proc sl:rebind {oldtarget newtarget} {
++ foreach binding [binds msg] {
++ if {[lindex $binding 4] == $oldtarget} {
++ unbind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] [lindex $binding 4]
++ bind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] $newtarget
++ }
++ }
++}
++
++proc sl:msg:trigger {nick uhost hand rest target} {
++ global default-slang
++
++ set lang [selectlang:getlang $uhost]
++ set old-slang ${default-slang}
++ if {$lang != ""} {
++ set default-slang $lang
++ putlog "using '$lang'..."
++ }
++ $target $nick $uhost $hand $rest
++ set default-slang ${old-slang}
++}
++
++sl:rebind *msg:seen sl:msg:seen
++proc sl:msg:seen {nick uhost hand rest} {
++ sl:msg:trigger $nick $uhost $hand $rest *msg:seen
++}
++
++sl:rebind *msg:seenstats sl:msg:seenstats
++proc sl:msg:seenstats {nick uhost hand rest} {
++ sl:msg:trigger $nick $uhost $hand $rest *msg:seenstats
++}
++
++sl:rebind *msg:seennick sl:msg:seennick
++proc sl:msg:seennick {nick uhost hand rest} {
++ sl:msg:trigger $nick $uhost $hand $rest *msg:seennick
++}
+\ No newline at end of file
+diff -Nur src/mod/gseen.mod/ai.c src/mod/gseen.mod/ai.c
+--- src/mod/gseen.mod/ai.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/ai.c 2002-10-26 13:17:47.000000000 +0200
+@@ -0,0 +1,151 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++static int quietaiseens(char *chan)
++{
++ char buf[121], *b;
++
++ Context;
++ strncpy(buf, quiet_ai_seen, 120);
++ buf[120] = 0;
++ b = buf;
++ while (b[0])
++ if (!strcasecmp(chan, newsplit(&b)))
++ return 1;
++#if EGG_IS_MIN_VER(10503)
++ if (ngetudef("quietaiseens", chan))
++ return 1;
++#endif
++ return 0;
++}
++
++static int tcl_pubmseen STDVAR
++{
++ char *nick, *uhost, *hand, *chan, *text;
++ char buf[1024];
++ char *words, *word;
++ seendat *l;
++ int i;
++
++ Context;
++ BADARGS(6, 6, " nick uhost hand chan text");
++ nick = argv[1];
++ uhost = argv[2];
++ hand = argv[3];
++ chan = argv[4];
++ text = argv[5];
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, chan));
++ glob_nick = nick;
++ for (i = 0; i < strlen(text); i++)
++ if (strchr("!?.,\"", text[i]))
++ text[i] = ' ';
++ strncpy(buf, ignore_words, 1023);
++ buf[1023] = 0;
++ words = buf;
++ while (words[0])
++ add_ignoredword(newsplit(&words));
++ strncpy(buf, text, 1023);
++ buf[1023] = 0;
++ words = buf;
++ while (words[0]) {
++ word = newsplit(&words);
++ if (word_is_ignored(word))
++ continue;
++ l = findseen(word);
++ if (l) {
++ if (quietaiseens(chan)) {
++ set_prefix(SLNOTPREFIX);
++ dprintf(DP_HELP, "NOTICE %s :%s%s\n", nick, reply_prefix,
++ do_seen(word, nick, uhost, chan, 0));
++ } else {
++ set_prefix(SLPUBPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", chan, reply_prefix,
++ do_seen(word, nick, uhost, chan, 0));
++ }
++ add_seenreq(word, nick, uhost, chan, now);
++ free_ignoredwords();
++ Tcl_AppendResult(irp, "1", NULL);
++ return TCL_OK;
++ }
++ }
++ free_ignoredwords();
++ Tcl_AppendResult(irp, "0", NULL);
++ return TCL_OK;
++}
++
++static tcl_cmds mytcls[] =
++{
++ {"*pubm:seen", tcl_pubmseen},
++ {"*chjn:gseen", gseen_chjn},
++ {"*chpt:gseen", gseen_chpt},
++ {0, 0}
++};
++
++static void add_ignoredword(char *word)
++{
++ ignoredword *l, *nl;
++
++ l = ignoredwords;
++ while (l && l->next)
++ l = l->next;
++ nl = nmalloc(sizeof(ignoredword));
++ nl->word = nmalloc(strlen(word) + 1);
++ strcpy(nl->word, word);
++ nl->next = NULL;
++ if (ignoredwords)
++ l->next = nl;
++ else
++ ignoredwords = nl;
++}
++
++static void free_ignoredwords()
++{
++ ignoredword *l, *ll;
++
++ l = ignoredwords;
++ while (l) {
++ ll = l->next;
++ nfree(l->word);
++ nfree(l);
++ l = ll;
++ }
++ ignoredwords = NULL;
++}
++
++static int expmem_ignoredwords()
++{
++ ignoredword *l;
++ int size = 0;
++
++ for (l = ignoredwords; l; l = l->next) {
++ size += sizeof(ignoredword);
++ size += strlen(l->word) + 1;
++ }
++ return size;
++}
++
++static int word_is_ignored(char *word)
++{
++ ignoredword *l;
++
++ for (l = ignoredwords; l; l = l->next)
++ if (!strcasecmp(l->word, word))
++ return 1;
++ return 0;
++}
+diff -Nur src/mod/gseen.mod/datahandling.c src/mod/gseen.mod/datahandling.c
+--- src/mod/gseen.mod/datahandling.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/datahandling.c 2002-10-26 13:17:48.000000000 +0200
+@@ -0,0 +1,151 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++
++static void write_seens()
++{
++ seenreq *r;
++ seenreq_by *b;
++ FILE *f;
++ char s[125];
++
++ Context;
++ /* putlog(LOG_MISC, "*", "Saving seen data..."); */
++ if (!gseenfile[0])
++ return;
++ sprintf(s, "%s~new", gseenfile);
++ f = fopen(s, "w");
++ chmod(s, 0600);
++ if (f == NULL) {
++ putlog(LOG_MISC, "*", "ERROR writing gseen file.");
++ return;
++ }
++ fprintf(f, "# gseen data file v1.\n");
++ write_seen_tree_target = f;
++ btree_getall(&seentree, write_seen_tree);
++ for (r = requests; r; r = r->next)
++ for (b = r->by; b; b = b->next)
++ /* @ nick by host chan when */
++ fprintf(f, "@ %s %s %s %s %lu\n", r->nick, b->who, b->host, b->chan,
++ b->when);
++ fclose(f);
++ unlink(gseenfile);
++ movefile(s, gseenfile);
++ /* putlog(LOG_MISC, "*", "Done."); */
++ return;
++}
++
++static void read_seens()
++{
++ FILE *f;
++ char buf[512], *s, *type, *nick, *host, *chan, *msg, *by;
++ time_t when;
++ int spent, iType, i;
++
++ Context;
++ f = fopen(gseenfile, "r");
++ if (f == NULL) {
++ putlog(LOG_MISC, "*", "Can't open gseen file, creating new database...");
++ return;
++ }
++ while (!feof(f)) {
++ buf[0] = 0;
++ s = buf;
++ fgets(s, 511, f);
++ i = strlen(buf);
++ if (buf[i - 1] == '\n')
++ buf[i - 1] = 0;
++ if ((buf[0] == 0) || (buf[0] == '#'))
++ continue;
++ type = newsplit(&s);
++ if (!strcmp(type, "!")) {
++ nick = newsplit(&s);
++ host = newsplit(&s);
++ chan = newsplit(&s);
++ iType = atoi(newsplit(&s));
++ when = (time_t) atoi(newsplit(&s));
++ spent = atoi(newsplit(&s));
++ msg = s;
++ add_seen(iType, nick, host, chan, msg, when, spent);
++ } else if (!strcmp(type, "@")) {
++ nick = newsplit(&s);
++ by = newsplit(&s);
++ host = newsplit(&s);
++ chan = newsplit(&s);
++ when = (time_t) atoi(newsplit(&s));
++ add_seenreq(nick, by, host, chan, when);
++ }
++ }
++ fclose(f);
++ Context;
++ return;
++}
++
++static void purge_seens()
++{
++ seenreq *r, *rr;
++ seenreq_by *b, *bb;
++
++ Context;
++ if (!expire_seens)
++ return;
++ btree_getall_expanded(&seentree, purge_seen_tree);
++ debug0("purge done");
++ r = requests;
++ rr = NULL;
++ while (r) {
++ b = r->by;
++ bb = NULL;
++ while (b) {
++ if ((now - b->when) > (expire_seens * 86400)) {
++ debug2("request for %s from %s has expired.", r->nick, b->who);
++ nfree(b->who);
++ nfree(b->host);
++ nfree(b->chan);
++ if (bb) {
++ bb->next = b->next;
++ nfree(b);
++ b = bb->next;
++ } else {
++ r->by = b->next;
++ nfree(b);
++ b = r->by;
++ }
++ } else {
++ bb = b;
++ b = b->next;
++ }
++ }
++ if (!r->by) {
++ debug1("no further seen requests for %s, deleting", r->nick);
++ nfree(r->nick);
++ if (rr) {
++ rr->next = r->next;
++ nfree(r);
++ r = rr->next;
++ } else {
++ requests = r->next;
++ nfree(r);
++ r = requests;
++ }
++ } else {
++ rr = r;
++ r = r->next;
++ }
++ }
++}
+diff -Nur src/mod/gseen.mod/do_seen.c src/mod/gseen.mod/do_seen.c
+--- src/mod/gseen.mod/do_seen.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/do_seen.c 2002-10-26 13:17:50.000000000 +0200
+@@ -0,0 +1,840 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++/* do_seen(): Checks if someone matches the mask, and returns the reply
++ * mask : first paramater (e.g. "G`Quann", "G`Quann", "*!*@*.isp.de", ...)
++ * nick : nick of the one, who triggered the command
++ * uhost: user@host of nick
++ * chan : chan, where the command was triggered
++ * bns :
++ * 1 : do a botnet-seen if no matches are found
++ * 0 : don't do a botnet-seen
++ * -1 : return NULL instead of text, if no matches were found
++ * (necessary for botnet seen)
++ */
++static char *do_seen(char *mask, char *nick, char *uhost, char *chan, int bns)
++{
++ char hostbuf[UHOSTLEN + 1], *host, *newhost, *tmp, *dur;
++ seendat *l;
++ gseenres *r;
++ int wild, nr;
++ char bnquery[256];
++ struct userrec *u;
++ struct laston_info *li;
++ struct chanset_t *ch;
++
++ Context;
++ start_seentime_calc();
++ if (seen_reply) {
++ nfree(seen_reply);
++ seen_reply = NULL;
++ }
++ l = NULL;
++ li = NULL;
++ host = hostbuf;
++ newhost = NULL;
++ mask = newsplit(&mask);
++ glob_query = mask;
++ while (mask[0] == ' ')
++ mask++;
++ if (!mask[0]) {
++ return SLNOPARAM;
++ }
++ if (strchr(mask, '?') || strchr(mask, '*')) {
++ // if wildcard-searches ares not allowed, then either return
++ // NULL (for botnet-seen), or a appropriate warning
++ if (!wildcard_search) {
++ if (bns == -1)
++ return NULL;
++ else
++ return SLNOWILDCARDS;
++ } else
++ wild = 1;
++ } else {
++ if (strlen(mask) > seen_nick_len) // don't process if requested nick is too long
++ return SLTOOLONGNICK; // (e.g. stop stupid jokes)
++ if (!strcasecmp(mask, nick)) {
++ return SLMIRROR;
++ }
++ // check if the nick is on the current channel
++ if (onchan(mask, chan))
++ return SLONCHAN;
++ if ((glob_othernick = handonchan(mask, chan)))
++ return SLHANDONCHAN;
++ // check if it is on any other channel
++ if ((ch = onanychan(mask))) {
++#if EGG_IS_MIN_VER(10500)
++ if (!secretchan(ch->dname)) {
++ glob_otherchan = ch->dname;
++ return SLONOTHERCHAN;
++ }
++#else
++ if (!secretchan(ch->name)) {
++ glob_otherchan = ch->name;
++ return SLONOTHERCHAN;
++ }
++#endif
++ }
++ // check if the user who uses this handle is on the channel under
++ // a different nick
++ if ((ch = handonanychan(mask))) {
++#if EGG_IS_MIN_VER(10500)
++ if (!secretchan(ch->dname)) {
++ glob_otherchan = ch->dname;
++ return SLONOTHERCHAN;
++ }
++#else
++ if (!secretchan(ch->name)) {
++ glob_otherchan = ch->name;
++ return SLONOTHERCHAN;
++ }
++#endif
++ }
++ add_seenreq(mask, nick, uhost, chan, now);
++ wild = 0;
++ l = findseen(mask);
++ // if there's a result, and if we don't want to search for the same user
++ // under a different nick, just make a do_seennick on the result
++ if (l && !fuzzy_search) {
++ tmp = do_seennick(l);
++ end_seentime_calc();
++ return tmp;
++ }
++ if (!l) {
++ u = get_user_by_handle(userlist, mask);
++ if (u) {
++ li = get_user(&USERENTRY_LASTON, u);
++ }
++ if (!u || !li) {
++ if (bns == -1) { // if bns is 0, then do_seen() was triggered by
++ end_seentime_calc(); // a botnet seen function, which needs a clear
++ return NULL; // NULL to detect if there was a result or not
++ }
++ tmp = SLNOTSEEN;
++ if (bns && ((strlen(mask) + strlen(nick) + strlen(uhost)
++ + strlen(chan) + 20) < 255)) {
++ debug0("trying botnet seen");
++ if (bnsnick)
++ nfree(bnsnick);
++ if (bnschan)
++ nfree(bnschan);
++ bnsnick = nmalloc(strlen(nick) + 1);
++ strcpy(bnsnick, nick);
++ bnschan = nmalloc(strlen(chan) + 1);
++ strcpy(bnschan, chan);
++ sprintf(bnquery, "gseen_req %s %s %s %s", mask, nick, uhost, chan);
++ botnet_send_zapf_broad(-1, botnetnick, NULL, bnquery);
++ }
++ } else {
++ // we have a matching handle, no seen-entry, but a laston entry
++ // in the userbase, so let's just return that one.
++ dur = gseen_duration(now - li->laston);
++ glob_laston = dur;
++ tmp = SLPOORSEEN;
++ seen_reply = nmalloc(strlen(tmp) + 1);
++ strcpy(seen_reply, tmp);
++ end_seentime_calc();
++ return seen_reply;
++ }
++ end_seentime_calc();
++ return tmp;
++ }
++ // now prepare the host for fuzzy-search
++ if (strlen(l->host) < UHOSTLEN) {
++ maskstricthost(l->host, host);
++ host = strchr(host, '!') + 1; // strip nick from host for faster search
++ } else {
++ end_seentime_calc();
++ return "error, too long host";
++ }
++ }
++ if (l && (l->type == SEEN_CHPT)) {
++ tmp = do_seennick(l);
++ end_seentime_calc();
++ return tmp;
++ }
++ numresults = 0;
++ // wildmatch_seens uses a global var to store hosts in it
++ // (to prevent massive nmalloc/nfree-usage), so don't forget
++ // to initialize and free it
++ temp_wildmatch_host = my_malloc(1);
++ wildmatch_seens(host, mask, wild);
++ my_free(temp_wildmatch_host);
++ temp_wildmatch_host = NULL;
++ if (!results) {
++ end_seentime_calc();
++ if (bns == -1)
++ return NULL; // let the botnet seen function know, that seen failed
++ return SLNOMATCH;
++ }
++ if (numresults >= max_matches) {
++ end_seentime_calc();
++ free_seenresults();
++ return SLTOOMANYMATCHES;
++ }
++ sortresults();
++ if (strcasecmp(results->seen->nick, mask)) {
++ // if the user's latest nick is not the nick for which we were searching,
++ // say that there were multiple matches and display the latest one
++ if (numresults == 1)
++ tmp = SLONEMATCH;
++ else if (numresults <= 5)
++ tmp = SLLITTLEMATCHES;
++ else
++ tmp = SLMANYMATCHES;
++ seen_reply = nmalloc(strlen(tmp) + 1);
++ strcpy(seen_reply, tmp);
++ nr = 0;
++ for (r = results; (r && (nr < 5)); r = r->next) {
++ nr++;
++ if (nr > 1) {
++ seen_reply = nrealloc(seen_reply, 1 + strlen(seen_reply) + 1 + strlen(r->seen->nick) + 1);
++ strcat(seen_reply, ", ");
++ } else {
++ seen_reply = nrealloc(seen_reply, 1 + strlen(seen_reply) + strlen(r->seen->nick) + 1);
++ strcat(seen_reply, " ");
++ }
++ strcat(seen_reply, r->seen->nick);
++ }
++ tmp = do_seennick(results->seen);
++ seen_reply = nrealloc(seen_reply, 2 + strlen(seen_reply) + strlen(tmp) + 1);
++ sprintf(seen_reply, "%s. %s", seen_reply, tmp);
++ } else { // first result is the nick which we were searching for
++ // just return the info for this nick and don't care about other results
++ tmp = do_seennick(results->seen);
++ seen_reply = nmalloc(strlen(tmp) + 1);
++ strcpy(seen_reply, tmp);
++ }
++ free_seenresults();
++ end_seentime_calc();
++ return seen_reply;
++}
++
++/* do_seennick():
++ * takes a seen-dataset and produces the corresponding reply basically
++ * by referencing to the lang entry with the same number as the seen-type.
++ */
++static char *do_seennick(seendat *l)
++{
++// char buf[256], *msg;
++ int stype;
++
++ Context;
++ if (!l) {
++ debug0("ERROR! Tryed to do a seennick on a NULL pointer!");
++ return "ERROR! seendat == NULL!!!";
++ }
++ glob_seendat = l;
++ // l->type is the basic language-entry-number
++ stype = l->type + 100;
++ // in some cases, we might need a special reply, so modify the
++ // number if neccessary
++ switch (l->type) {
++ case SEEN_JOIN:
++ if (!onchan(l->nick, l->chan))
++ stype += 20;
++ break;
++ case SEEN_PART:
++ /* nothing to do here */
++ break;
++ case SEEN_SIGN:
++ /* nothing again */
++ break;
++ case SEEN_NICK:
++ if (!onchan(l->msg, l->chan))
++ stype += 20;
++ break;
++ case SEEN_NCKF:
++ if (!onchan(l->nick, l->chan))
++ stype += 20;
++ break;
++ case SEEN_KICK:
++/* msg = buf;
++ strncpy(buf, l->msg, 255);
++ msg[255] = 0;
++ sglobpunisher = newsplit(&msg);
++ sglobreason = msg; */
++ break;
++ case SEEN_SPLT:
++ /* nothing to do here */
++ break;
++ case SEEN_REJN:
++ if (!onchan(l->nick, l->chan))
++ stype += 20;
++ break;
++ case SEEN_CHJN:
++ case SEEN_CHPT:
++ if (!strcmp(l->chan, "0"))
++ stype += 20;
++ break;
++ default:
++ stype = 140;
++ }
++ return getslang(stype);
++}
++
++/* findseens():
++ * interface for webseen.mod
++ * find all results for a query and return a pointer to this list
++ * (basically the core of do_seen())
++ */
++static gseenres *findseens(char *mask, int *ret, int fuzzy)
++{
++ char hostbuf[UHOSTLEN + 1], *host, *newhost;
++ seendat *l;
++ int wild;
++
++ Context;
++ start_seentime_calc();
++ *ret = WS_OK;
++ l = NULL;
++ host = hostbuf;
++ newhost = NULL;
++ mask = newsplit(&mask);
++ while (mask[0] == ' ')
++ mask++;
++ if (!mask[0]) {
++ *ret = WS_NOPARAM;
++ return NULL;
++ }
++ if (strchr(mask, '?') || strchr(mask, '*')) {
++ // if wildcard-searches ares not allowed, then either return
++ // NULL (for botnet-seen), or a appropriate warning
++ if (!wildcard_search) {
++ *ret = WS_NOWILDCARDS;
++ return NULL;
++ }
++ wild = 1;
++ } else {
++ if (strlen(mask) > seen_nick_len) { // don't process if requested nick is too long
++ *ret = WS_TOOLONGNICK; // (e.g. stop stupid jokes)
++ return NULL;
++ }
++ add_seenreq(mask, "www-user", "unknown_host", "webinterface", now);
++ wild = 0;
++ l = findseen(mask);
++ // if there's a result, and if we don't want to search for the same user
++ // under a different nick, just return this result
++ if (l && (!fuzzy_search || !fuzzy)) {
++ numresults = 1;
++ add_seenresult(l);
++ end_seentime_calc();
++ return results;
++ }
++ if (!l) {
++ // no matching user was found :(
++ *ret = WS_NORESULT;
++ end_seentime_calc();
++ return NULL;
++ }
++ // now prepare the host for fuzzy-search
++ if (strlen(l->host) < UHOSTLEN) {
++ maskstricthost(l->host, host);
++ host = strchr(host, '!') + 1; // strip nick from host for faster search
++ } else {
++ *ret = WS_TOOLONGHOST;
++ end_seentime_calc();
++ return NULL;
++ }
++ }
++ if (l && (l->type == SEEN_CHPT)) {
++ numresults = 1;
++ add_seenresult(l);
++ end_seentime_calc();
++ return results;
++ }
++ numresults = 0;
++ // wildmatch_seens uses a global var to store hosts in it
++ // (to prevent massive nmalloc/nfree-usage), so don't forget
++ // to initialize and free it
++ temp_wildmatch_host = my_malloc(1);
++ wildmatch_seens(host, mask, wild);
++ my_free(temp_wildmatch_host);
++ temp_wildmatch_host = NULL;
++ if (!results) {
++ // no match :(
++ *ret = WS_NORESULT;
++ end_seentime_calc();
++ return NULL;
++ }
++ if (numresults >= max_matches) {
++ free_seenresults();
++ *ret = WS_TOOMANYMATCHES;
++ end_seentime_calc();
++ return NULL;
++ }
++ sortresults();
++ *ret = 0;
++ end_seentime_calc();
++ return results;
++}
++
++
++char seenstats_reply[512];
++static char *do_seenstats()
++{
++ glob_totalnicks = count_seens();
++ glob_totalbytes = gseen_expmem();
++ sprintf(seenstats_reply, "%s", SLSEENSTATS);
++ return seenstats_reply;
++}
++
++// add an seen result (to the top of the list)
++static void add_seenresult(seendat *seen)
++{
++ gseenres *nl;
++
++ numresults++;
++ if (numresults > max_matches)
++ return;
++ nl = nmalloc(sizeof(gseenres));
++ nl->seen = seen;
++ nl->next = results;
++ results = nl;
++}
++
++static int expmem_seenresults()
++{
++ int bytes = 0;
++ gseenres *l;
++
++ for (l = results; l; l = l->next)
++ bytes += sizeof(gseenres);
++ return bytes;
++}
++
++static void free_seenresults()
++{
++ gseenres *l, *ll;
++
++ l = results;
++ while (l) {
++ ll = l->next;
++ nfree(l);
++ l = ll;
++ }
++ results = NULL;
++}
++
++static void sortresults()
++{
++ int again = 1;
++ gseenres *last, *p, *c, *n;
++ int a, b;
++
++ Context;
++ again = 1;
++ last = NULL;
++ while ((results != last) && (again)) {
++ p = NULL;
++ c = results;
++ n = c->next;
++ again = 0;
++ while (n != last) {
++ if (!c || !n)
++ a = b = 0;
++ else
++ a = c->seen->when;
++ b = n->seen->when;
++ if (a < b) {
++ again = 1;
++ c->next = n->next;
++ n->next = c;
++ if (p == NULL)
++ results = n;
++ else
++ p->next = n;
++ }
++ p = c;
++ c = n;
++ n = n->next;
++ }
++ last = c;
++ }
++ Context;
++ return;
++}
++
++static void sortrequests(seenreq *l)
++{
++ int again = 1;
++ seenreq_by *last, *p, *c, *n;
++ int a, b;
++
++ Context;
++ again = 1;
++ last = NULL;
++ while ((l->by != last) && (again)) {
++ p = NULL;
++ c = l->by;
++ n = c->next;
++ again = 0;
++ while (n != last) {
++ if (!c || !n)
++ a = b = 0;
++ else
++ a = c->when;
++ b = n->when;
++ if (a < b) {
++ again = 1;
++ c->next = n->next;
++ n->next = c;
++ if (p == NULL)
++ l->by = n;
++ else
++ p->next = n;
++ }
++ p = c;
++ c = n;
++ n = n->next;
++ }
++ last = c;
++ }
++ Context;
++ return;
++}
++
++/* stolen from tcl_duration in tclmisc.c */
++char gs_duration_temp[256];
++static char *gseen_duration(int seconds)
++{
++ char s[256];
++ time_t sec;
++
++ sec = seconds;
++ s[0] = 0;
++ if (sec < 1) {
++ snprintf(gs_duration_temp, sizeof(gs_duration_temp), "%s", SLSOMETIME);
++ return gs_duration_temp;
++ }
++ if (sec < 60) {
++ sprintf(gs_duration_temp, "%d %s", (int) (sec / 1),
++ ((int) (sec / 1) > 1) ? SLSECONDS : SLSECOND);
++ return gs_duration_temp;
++ }
++ if (sec >= 31536000) {
++ sprintf(s, "%d %s ", (int) (sec / 31536000),
++ ((int) (sec / 31536000) > 1) ? SLYEARS : SLYEAR);
++ sec -= (((int) (sec / 31536000)) * 31536000);
++ }
++ if (sec >= 604800) {
++ sprintf(&s[strlen(s)], "%d %s ", (int) (sec / 604800),
++ ((int) (sec / 604800) > 1) ? SLWEEKS : SLWEEK);
++ sec -= (((int) (sec / 604800)) * 604800);
++ }
++ if (sec >= 86400) {
++ sprintf(&s[strlen(s)], "%d %s ", (int) (sec / 86400),
++ ((int) (sec / 86400) > 1) ? SLDAYS : SLDAY);
++ sec -= (((int) (sec / 86400)) * 86400);
++ }
++ if (sec >= 3600) {
++ sprintf(&s[strlen(s)], "%d %s ", (int) (sec / 3600),
++ ((int) (sec / 3600) > 1) ? SLHOURS : SLHOUR);
++ sec -= (((int) (sec / 3600)) * 3600);
++ }
++ if (sec >= 60) {
++ sprintf(&s[strlen(s)], "%d %s ", (int) (sec / 60),
++ ((int) (sec / 60) > 1) ? SLMINUTES : SLMINUTE);
++ sec -= (((int) (sec / 60)) * 60);
++ }
++ strcpy(gs_duration_temp, s);
++ if (gs_duration_temp[strlen(gs_duration_temp) - 1] == ' ')
++ gs_duration_temp[strlen(gs_duration_temp) - 1] = 0;
++ return gs_duration_temp;
++}
++
++static int onchan(char *nick, char *chan)
++{
++ struct chanset_t *ch;
++ memberlist *m;
++
++ ch = findchan_by_dname(chan);
++ if (!ch)
++ return 0;
++ m = ismember(ch, nick);
++ if (!m)
++ return 0;
++ else if (chan_issplit(m))
++ return 0;
++ else
++ return 1;
++}
++
++/* handonchan():
++ * checks if the given user is on the channel and returns its nick
++ */
++static char *handonchan(char *hand, char *chan)
++{
++ struct chanset_t *ch;
++ memberlist *m;
++
++ ch = findchan_by_dname(chan);
++ if (!ch)
++ return 0;
++ if (ch->channel.members > 0) {
++ for (m = ch->channel.member; m; m = m->next) {
++ if (m->user) {
++ if (m->user->handle && !rfc_casecmp(m->user->handle, hand))
++ return m->nick;
++ }
++ }
++ }
++ return NULL;
++}
++
++/* onanychan():
++ * checks if the given nickname is on any of the bot's chans.
++ */
++static struct chanset_t *onanychan(char *nick)
++{
++ struct chanset_t *ch;
++ memberlist *m;
++
++ for (ch = chanset; ch; ch = ch->next) {
++ m = ismember(ch, nick);
++ if (m && !chan_issplit(m))
++ return ch;
++ }
++ return NULL;
++}
++
++/* handonanychan():
++ * checks if the given user is on any channel (no matter under which nick)
++ */
++static struct chanset_t *handonanychan(char *hand)
++{
++ struct chanset_t *ch;
++ memberlist *m;
++
++ for (ch = chanset; ch; ch = ch->next) {
++ if (ch->channel.members > 0) {
++ for (m = ch->channel.member; m; m = m->next) {
++ if (m->user) {
++ if (m->user->handle && !rfc_casecmp(m->user->handle, hand))
++ return ch;
++ }
++ }
++ }
++ }
++ return NULL;
++}
++
++static void add_seenreq(char *nick, char *from, char *host, char *chan,
++ time_t when)
++{
++ seenreq *l, *nl;
++ seenreq_by *b, *nb;
++ char buf[10] = "[secret]";
++
++ Context;
++ if (!tell_seens)
++ return;
++ if (strcmp(chan, "[partyline]") && secretchan(chan))
++ chan = buf;
++ for (l = requests; l; l = l->next) {
++ if (!strcasecmp(nick, l->nick)) {
++ for (b = l->by; b; b = b->next) {
++ if (!strcasecmp(from, b->who)) {
++ nfree(b->chan);
++ b->chan = nmalloc(strlen(chan) + 1);
++ strcpy(b->chan, chan);
++ b->when = when;
++ return;
++ }
++ }
++ b = l->by;
++ while (b && b->next)
++ b = b->next;
++ nb = nmalloc(sizeof(seenreq_by));
++ nb->who = nmalloc(strlen(from) + 1);
++ strcpy(nb->who, from);
++ nb->host = nmalloc(strlen(host) + 1);
++ strcpy(nb->host, host);
++ nb->chan = nmalloc(strlen(chan) + 1);
++ strcpy(nb->chan, chan);
++ nb->when = when;
++ nb->next = NULL;
++ if (l->by)
++ b->next = nb;
++ else
++ l->by = nb;
++ return;
++ }
++ }
++ nb = nmalloc(sizeof(seenreq_by));
++ nb->who = nmalloc(strlen(from) + 1);
++ strcpy(nb->who, from);
++ nb->host = nmalloc(strlen(host) + 1);
++ strcpy(nb->host, host);
++ nb->chan = nmalloc(strlen(chan) + 1);
++ strcpy(nb->chan, chan);
++ nb->when = when;
++ nb->next = NULL;
++ l = requests;
++ while (l && l->next)
++ l = l->next;
++ nl = nmalloc(sizeof(seenreq));
++ nl->nick = nmalloc(strlen(nick) + 1);
++ strcpy(nl->nick, nick);
++ nl->by = nb;
++ nl->next = NULL;
++ if (requests)
++ l->next = nl;
++ else
++ requests = nl;
++}
++
++static int expmem_seenreq()
++{
++ seenreq *l;
++ seenreq_by *b;
++ int size;
++
++ size = 0;
++ for (l = requests; l; l = l->next) {
++ size += sizeof(seenreq);
++ size += strlen(l->nick) + 1;
++ for (b = l->by; b; b = b->next) {
++ size += sizeof(seenreq_by);
++ size += strlen(b->who) + 1;
++ size += strlen(b->host) + 1;
++ size += strlen(b->chan) + 1;
++ }
++ }
++ return size;
++}
++
++static int count_seenreq(seenreq_by *b)
++{
++ seenreq_by *l;
++ int nr;
++
++ nr = 0;
++ for (l = b; l; l = l->next)
++ nr++;
++ return nr;
++}
++
++static void free_seenreq()
++{
++ seenreq *l, *ll;
++ seenreq_by *b, *bb;
++
++ Context;
++ l = requests;
++ while (l) {
++ b = l->by;
++ while (b) {
++ bb = b->next;
++ nfree(b->who);
++ nfree(b->host);
++ nfree(b->chan);
++ nfree(b);
++ b = bb;
++ }
++ ll = l->next;
++ nfree(l->nick);
++ nfree(l);
++ l = ll;
++ }
++ requests = NULL;
++}
++
++static void report_seenreq(char *channel, char *nick)
++{
++ seenreq *l, *ll;
++ seenreq_by *b, *bb;
++ char *reply, *tmp;
++ int nr;
++
++ if (!tell_seens)
++ return;
++ ll = NULL;
++ l = requests;
++ reply = NULL;
++ while (l) {
++ if (!strcasecmp(l->nick, nick)) {
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, channel));
++ glob_nick = nick;
++ nr = count_seenreq(l->by);
++ if (nr == 1) {
++ glob_seenrequest = l;
++ dprintf(DP_HELP, "NOTICE %s :%s\n", l->nick, SLONELOOK);
++ } else {
++ sortrequests(l);
++ glob_seenrequest = l;
++ glob_seenrequests = nr;
++ tmp = SLMORELOOKS;
++ reply = nmalloc(strlen(tmp) + 1);
++ strcpy(reply, tmp);
++ nr = 0;
++ for (b = l->by; b; b = b->next) {
++ nr++;
++ reply = nrealloc(reply, strlen(reply) + ((nr == 1) ? 1 : 2) + strlen(b->who) + 1);
++ sprintf(reply, "%s%s%s", reply, (nr == 1) ? " " : ", ", b->who);
++ }
++ tmp = SLLASTLOOK;
++ reply = nrealloc(reply, strlen(reply) + 2 + strlen(tmp) + 1);
++ sprintf(reply, "%s. %s", reply, tmp);
++ dprintf(DP_HELP, "NOTICE %s :%s\n", l->nick, reply);
++ nfree(reply);
++ }
++ b = l->by;
++ while (b) {
++ bb = b->next;
++ nfree(b->who);
++ nfree(b->host);
++ nfree(b->chan);
++ nfree(b);
++ b = bb;
++ }
++ nfree(l->nick);
++ if (ll)
++ ll->next = l->next;
++ else
++ requests = l->next;
++ nfree(l);
++ if (ll)
++ l = ll->next;
++ else
++ l = requests;
++ } else {
++ ll = l;
++ l = l->next;
++ }
++ }
++}
++
++static void start_seentime_calc()
++{
++ struct timeval t;
++
++ gettimeofday(&t, NULL);
++ glob_presearch = (float) t.tv_sec + (((float) t.tv_usec) / 1000000);
++}
++
++static void end_seentime_calc()
++{
++ struct timeval t;
++
++ gettimeofday(&t, NULL);
++ glob_aftersearch = (float) t.tv_sec + (((float) t.tv_usec) / 1000000);
++ glob_total_searchtime += glob_aftersearch - glob_presearch;
++ glob_total_queries++;
++}
+diff -Nur src/mod/gseen.mod/generic_binary_tree.c src/mod/gseen.mod/generic_binary_tree.c
+--- src/mod/gseen.mod/generic_binary_tree.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/generic_binary_tree.c 2002-10-26 13:17:51.000000000 +0200
+@@ -0,0 +1,311 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++#define GENERIC_BINARY_TREE 1
++
++struct generic_binary_tree {
++ void *root;
++ int (*comparedata) (void *data1, void *data2);
++ int (*expmemdata) (void *data);
++ void (*freedata) (void *data);
++};
++
++struct generic_binary_tree_node {
++ void *data;
++ void *left;
++ void *right;
++};
++
++static void btree_add(struct generic_binary_tree *, void *);
++static int btree_expmem(struct generic_binary_tree *);
++static int btree_recursive_expmem(struct generic_binary_tree *, struct generic_binary_tree_node *);
++static void *btree_get(struct generic_binary_tree *, void *t);
++static void btree_freetree(struct generic_binary_tree *);
++static void btree_recursive_free(struct generic_binary_tree *,
++ struct generic_binary_tree_node *);
++static void btree_getall(struct generic_binary_tree *, void (*) (void *));
++static void btree_recursive_getall(struct generic_binary_tree_node *,
++ void (*) (void *));
++static void btree_getall_expanded(struct generic_binary_tree *tree, void (*) (void *));
++static void btree_recursive_getall_expanded(struct generic_binary_tree_node *,
++ void (*) (void *));
++static void btree_remove(struct generic_binary_tree *, void *);
++
++static void btree_add(struct generic_binary_tree *tree, void *data)
++{
++ struct generic_binary_tree_node *node, *lastnode;
++ int cmp, lastcmp;
++
++ Assert(tree);
++ Assert(data);
++ cmp = lastcmp = 0;
++ node = tree->root;
++ lastnode = NULL;
++ while (node) {
++ cmp = tree->comparedata(node->data, data);
++ if (!cmp) {
++ // item is identical -> free old data and insert new
++ tree->freedata(node->data);
++ node->data = data;
++ return;
++ }
++ lastnode = node;
++ lastcmp = cmp;
++ if (cmp < 0)
++ node = node->left;
++ else
++ node = node->right;
++ }
++ node = nmalloc(sizeof(struct generic_binary_tree_node));
++ node->left = NULL;
++ node->right = NULL;
++ node->data = data;
++ if (!lastnode)
++ tree->root = node;
++ else {
++ Assert(lastcmp);
++ if (lastcmp < 0) {
++ Assert(!lastnode->left);
++ lastnode->left = node;
++ } else {
++ Assert(!lastnode->right);
++ lastnode->right = node;
++ }
++ }
++}
++
++static int btree_expmem(struct generic_binary_tree *tree)
++{
++ int size = 0;
++
++ Assert(tree);
++ size += btree_recursive_expmem(tree, tree->root);
++ return size;
++}
++
++static int btree_recursive_expmem(struct generic_binary_tree *tree, struct generic_binary_tree_node *node)
++{
++ int size = 0;
++
++ if (!node)
++ return 0;
++ size += sizeof(struct generic_binary_tree_node);
++ size += tree->expmemdata(node->data);
++ size += btree_recursive_expmem(tree, node->left);
++ size += btree_recursive_expmem(tree, node->right);
++ return size;
++}
++
++static void *btree_get(struct generic_binary_tree *tree, void *what)
++{
++ struct generic_binary_tree_node *node;
++ int cmp;
++
++ node = tree->root;
++ while (node) {
++ cmp = tree->comparedata(node->data, what);
++ if (!cmp)
++ return node->data;
++ if (cmp < 0)
++ node = node->left;
++ else
++ node = node->right;
++ }
++ return NULL;
++}
++
++static void btree_freetree(struct generic_binary_tree *tree)
++{
++ btree_recursive_free(tree, tree->root);
++}
++
++static void btree_recursive_free(struct generic_binary_tree *tree,
++ struct generic_binary_tree_node *node)
++{
++ if (!node)
++ return;
++ btree_recursive_free(tree, node->left);
++ btree_recursive_free(tree, node->right);
++ tree->freedata(node->data);
++ nfree(node);
++}
++
++/* btree_getall():
++ * calls the specified function for each item in the tree.
++ * NOTE: getall() calls the proc _before_ it proceeds into recursion. This way,
++ * one can savely store the tree into a file without mixing up its form.
++ * But if you delete an item from the called prcedure, this function
++ * WILL crash. Use btree_getall() expanded instead.
++ */
++static void btree_getall(struct generic_binary_tree *tree, void (*func) (void *))
++{
++ Assert(tree);
++ btree_recursive_getall(tree->root, func);
++}
++
++static void btree_recursive_getall(struct generic_binary_tree_node *node,
++ void (*func) (void *))
++{
++ if (!node)
++ return;
++ // first call the function, then proceed into recursion
++ // this way, the tree keeps in form if its saved to a file, for example
++ Assert(func);
++ func(node->data);
++
++ btree_recursive_getall(node->left, func);
++ btree_recursive_getall(node->right, func);
++}
++
++/* btree_getall_expanded():
++ * the same as btree_getall(), but calls the function after the greatest level of recursion
++ * has been reached. The node-pointers won't be accessed anymore when the first function
++ * gets called. You can savely use this to free items.
++ */
++static void btree_getall_expanded(struct generic_binary_tree *tree, void (*func) (void *))
++{
++ Assert(tree);
++ btree_recursive_getall_expanded(tree->root, func);
++}
++
++static void btree_recursive_getall_expanded(struct generic_binary_tree_node *node,
++ void (*func) (void *))
++{
++ if (!node)
++ return;
++ btree_recursive_getall_expanded(node->left, func);
++ btree_recursive_getall_expanded(node->right, func);
++
++ Assert(func);
++ func(node->data);
++}
++
++static void btree_remove(struct generic_binary_tree *tree, void *data)
++{
++ struct generic_binary_tree_node *node, *last, *largenode, *lastlarge;
++ int ret, lastret;
++
++ Assert(tree);
++ Assert(data);
++ last = NULL;
++ lastret = 0;
++ node = tree->root;
++ while (node) {
++ ret = tree->comparedata(node->data, data);
++ if (ret == 0)
++ break;
++ last = node;
++ lastret = ret;
++ if (ret < 0)
++ node = node->left;
++ else
++ node = node->right;
++ }
++ if (!node) // oops, item not found
++ return;
++ if (!node->left && !node->right) {
++ // *freu* no sub-branches! We can easily delete this item.
++ if (last) {
++ if (lastret < 0)
++ last->left = NULL;
++ else
++ last->right = NULL;
++ } else
++ tree->root = NULL;
++ } else if (!node->left) {
++ // also pretty easy. Just connect the child to the parent.
++ if (last) {
++ if (lastret < 0)
++ last->left = node->right;
++ else
++ last->right = node->right;
++ } else
++ tree->root = node->right;
++ } else if (!node->right) {
++ // same as above, but mirrored
++ if (last) {
++ if (lastret < 0)
++ last->left = node->left;
++ else
++ last->right = node->left;
++ } else
++ tree->root = node->left;
++ } else {
++ // aaargh... two sub-trees! The world is not fair... *sigh*
++ debug0("argl... worst case, two subtrees. :( Let's pray...");
++ // now we take the largest item from the left subtree and replace the
++ // doomed node with it.
++ // since it is the largest val, the tree remains valid and doesn't
++ // get deformed too much.
++
++ // at first, we have to find this node and cut it from the tree
++ largenode = node->left;
++ lastlarge = NULL;
++ while (largenode && largenode->right) {
++ lastlarge = largenode;
++ largenode = largenode->right;
++ }
++
++ // only set largenode->left to node->left if largenode exists.
++ // otherwise node->left points to largenode, which would result
++ // in a nice short-circuit
++ // If it does not exist, just leave largenode->left as it is because we just
++ // move largenode one level up, so it can keep its left subtree.
++ if (lastlarge) {
++ lastlarge->right = largenode->left;
++ largenode->left = node->left;
++ }
++
++ // now connect node's subtrees to it
++ largenode->right = node->right;
++
++ // and finally replace node with largenode
++ if (last) {
++ if (lastret < 0)
++ last->left = largenode;
++ else
++ last->right = largenode;
++ } else
++ tree->root = largenode;
++ }
++ // finally kill the node... we shouldn't need it anymore
++ tree->freedata(node->data);
++ nfree(node);
++ node = NULL;
++}
++
++#ifdef BTREE_WITHOPTIMIZE
++static void btree_optimize(struct generic_binary_tree *tree,
++ struct generic_binary_tree_node *node,
++ struct generic_binary_tree_node *last,
++ int limit)
++{
++/* int leftdepth, rightdepth;
++
++ if (!node)
++ return;
++ btree_optimize(tree, node->left, node, last, limit);
++ btree_optimize(tree, node->right, node, last, limit);
++ leftdepth = btree_depth(node->left);
++ rightdepth = btree_depth(node->right);
++ if ((leftdepth - rightdepth) > limit) {
++
++ }
++*/
++}
++#endif
+diff -Nur src/mod/gseen.mod/global_vars.c src/mod/gseen.mod/global_vars.c
+--- src/mod/gseen.mod/global_vars.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/global_vars.c 2002-10-26 13:18:09.000000000 +0200
+@@ -0,0 +1,34 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++static char *glob_query, *glob_laston, *glob_otherchan, *glob_othernick;
++static char *glob_remotebot, *glob_nick;
++static struct slang_header *glob_slang;
++static seendat *glob_seendat;
++static seenreq *glob_seenrequest;
++static int glob_seenrequests, glob_totalnicks, glob_totalbytes;
++
++static void reset_global_vars()
++{
++ glob_query = glob_laston = glob_otherchan = glob_othernick = NULL;
++ glob_remotebot = glob_nick = NULL;
++ glob_seendat = NULL;
++ glob_slang = NULL;
++ glob_seenrequest = NULL;
++ glob_seenrequests = glob_totalnicks = glob_totalbytes = 0;
++}
+diff -Nur src/mod/gseen.mod/gseen.c src/mod/gseen.mod/gseen.c
+--- src/mod/gseen.mod/gseen.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/gseen.c 2002-10-26 14:24:48.000000000 +0200
+@@ -0,0 +1,328 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++#define MAKING_GSEEN
++#define MODULE_NAME "gseen"
++#define MODULE_VERSION "1.1.1 dev3"
++#define MODULE_NUMVERSION 10100
++#include "../module.h"
++#include "../irc.mod/irc.h"
++#include "../server.mod/server.h"
++#include "../channels.mod/channels.h"
++#include <stdlib.h>
++#include <sys/stat.h>
++#include <time.h> /* for time_t */
++
++#undef global
++static Function *global = NULL, *irc_funcs = NULL, *server_funcs = NULL, *channels_funcs = NULL;
++
++#ifndef EGG_IS_MIN_VER
++#define EGG_IS_MIN_VER(ver) ((ver) <= 10400)
++#endif
++
++#ifndef EGG_IS_MAX_VER
++#define EGG_IS_MAX_VER(ver) ((ver) >= 10400)
++#endif
++
++#ifndef Context
++#define Context context
++#endif
++
++#ifndef findchan_by_dname
++#define findchan_by_dname findchan
++#endif
++
++#include "gseen.h"
++#include "seenlang.h"
++
++static struct slang_header *coreslangs = NULL;
++static gseenres *results = NULL;
++static seenreq *requests = NULL;
++static ignoredword *ignoredwords = NULL;
++static char *bnsnick = NULL;
++static char *bnschan = NULL;
++static char *seen_reply = NULL;
++static char *temp_wildmatch_host;
++static int numresults = 0;
++static double glob_presearch, glob_aftersearch;
++int numseens, glob_total_queries;
++double glob_total_searchtime;
++
++static char gseenfile[121] = "gseen.dat";
++static char no_pub[121];
++static char quiet_seen[121];
++static char quiet_ai_seen[121];
++static char no_log[121];
++static char ignore_words[1024];
++static char default_slang[21] = "eng";
++static int gseen_numversion = MODULE_NUMVERSION;
++static int save_seens = 60;
++static int save_seens_temp = 1;
++static int expire_seens = 60;
++static int maxseen_thr = 0;
++static int maxseen_time = 0;
++static int seenflood_thr = 0;
++static time_t seenflood_time = 0;
++static int use_handles = 0;
++static int tell_seens = 1;
++static int botnet_seen = 1;
++int fuzzy_search = 1; // search for the same user under a differnt nick
++static int wildcard_search = 1;// allow wildcard seaching? ("*!*@*.isp.de")
++static int max_matches = 500; // break if there are more than X matches
++static int hide_secret_chans = 1; // #chan (+secret) => [secret]
++static int seen_nick_len = 32;
++
++#include "global_vars.c"
++#define SLANG_NOTYPES 1
++#define SLANG_NOFACTS 1
++#define SLANG_NOGETALL 1
++#define SLANG_NOVALIDATE 1
++#include "slang.c"
++#include "slang_gseen_commands.c"
++#include "generic_binary_tree.c"
++#include "seentree.c"
++#include "datahandling.c"
++#include "sensors.c"
++#include "do_seen.c"
++#include "gseencmds.c"
++#include "ai.c"
++#include "misc.c"
++#include "tclcmds.c"
++
++static int gseen_expmem()
++{
++ int size = 0;
++
++ size += seentree_expmem();
++ size += expmem_seenresults();
++ size += expmem_seenreq();
++ size += expmem_ignoredwords();
++ size += slang_expmem(coreslangs);
++ size += slang_glob_expmem();
++ size += slang_chanlang_expmem(chanlangs);
++ if (bnsnick)
++ size += strlen(bnsnick) + 1;
++ if (bnschan)
++ size += strlen(bnschan) + 1;
++ if (seen_reply) {
++ size += strlen(seen_reply) + 1;
++ }
++ return size;
++}
++
++static void free_gseen()
++{
++ seentree_free();
++ slang_free(coreslangs);
++ slang_chanlang_free(chanlangs);
++ if (seen_reply)
++ nfree(seen_reply);
++ return;
++}
++
++/* a report on the module status */
++static void gseen_report(int idx, int details)
++{
++ int size = 0;
++
++ Context;
++ if (details) {
++ size = gseen_expmem();
++ dprintf(idx, " using %d bytes\n", size);
++ }
++}
++
++static void gseen_minutely ()
++{
++ if (save_seens_temp >= save_seens) {
++ write_seens();
++ save_seens_temp = 1;
++ } else
++ save_seens_temp++;
++}
++
++static void gseen_daily ()
++{
++ Context;
++ purge_seens();
++}
++
++static tcl_strings my_tcl_strings[] =
++{
++ {"gseenfile", gseenfile, 121, 0},
++ {"ai-seen-ignore", ignore_words, 1024, 0},
++ {"no-pub-seens", no_pub, 121, 0},
++ {"quiet-seens", quiet_seen, 121, 0},
++ {"quiet-ai-seens", quiet_ai_seen, 121, 0},
++ {"no-log", no_log, 121, 0},
++ {"no-seendata", no_log, 121, 0},
++ {"default-slang", default_slang, 20, 0},
++ {0, 0, 0, 0}
++};
++
++static tcl_ints my_tcl_ints[] =
++{
++ {"save-seens", &save_seens, 0},
++ {"expire-seens", &expire_seens, 0},
++ {"use-handles", &use_handles, 0},
++ {"tell-seens", &tell_seens, 0},
++ {"botnet-seens", &botnet_seen, 0},
++ {"max-matches", &max_matches, 0},
++ {"fuzzy-search", &fuzzy_search, 0},
++ {"wildcard-search", &wildcard_search, 0},
++ {"hide-secret-chans", &hide_secret_chans, 0},
++ {"seen-nick-len", &seen_nick_len, 0},
++ {0, 0, 0}
++};
++
++static tcl_coups my_tcl_coups[] =
++{
++ {"max-seens", &maxseen_thr, &maxseen_time},
++ {0, 0, 0},
++};
++
++static char *gseen_close()
++{
++ Context;
++ write_seens();
++ slang_glob_free();
++ free_gseen();
++ free_seenreq();
++ free_seenresults();
++ free_ignoredwords();
++ if (bnsnick)
++ nfree(bnsnick);
++ if (bnschan)
++ nfree(bnschan);
++ rem_tcl_strings(my_tcl_strings);
++ rem_tcl_ints(my_tcl_ints);
++ rem_tcl_coups(my_tcl_coups);
++ rem_tcl_commands(mytcls);
++ rem_tcl_commands(gseentcls);
++ rem_tcl_commands(seendebugtcls);
++ rem_tcl_commands(gseentcls);
++ rem_builtins(H_dcc, mydcc);
++ rem_builtins(H_join, seen_join);
++ rem_builtins(H_kick, seen_kick);
++ rem_builtins(H_nick, seen_nick);
++ rem_builtins(H_part, seen_part);
++ rem_builtins(H_sign, seen_sign);
++ rem_builtins(H_splt, seen_splt);
++ rem_builtins(H_rejn, seen_rejn);
++ rem_builtins(H_pub, seen_pub);
++ rem_builtins(H_msg, seen_msg);
++ rem_builtins(H_bot, seen_bot);
++ del_hook(HOOK_MINUTELY, (Function) gseen_minutely);
++ del_hook(HOOK_DAILY, (Function) gseen_daily);
++ module_undepend(MODULE_NAME);
++ return NULL;
++}
++
++char *gseen_start();
++
++static Function gseen_table[] =
++{
++ (Function) gseen_start,
++ (Function) gseen_close,
++ (Function) gseen_expmem,
++ (Function) gseen_report,
++ /* 4 - 7 */
++ (Function) findseens,
++ (Function) free_seenresults,
++ (Function) gseen_duration,
++ (Function) & glob_seendat,
++ (Function) & numresults,
++ (Function) & fuzzy_search,
++ (Function) & numseens,
++ (Function) & glob_total_queries,
++ (Function) & glob_total_searchtime,
++ (Function) & gseen_numversion,
++};
++
++char *gseen_start(Function * global_funcs)
++{
++ global = global_funcs;
++ Context;
++ module_register(MODULE_NAME, gseen_table, 1, 1);
++ if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0)))
++ return "You need the irc module to use the gseen module.";
++ if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0)))
++ return "You need the server module to use the gseen module.";
++ if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0)))
++ return "You need the channels module to use the gseen module.";
++ if (!module_depend(MODULE_NAME, "eggdrop", 107, 0)) {
++ if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
++ if (!module_depend(MODULE_NAME, "eggdrop", 105, 0)) {
++ if (!module_depend(MODULE_NAME, "eggdrop", 104, 0)) {
++ module_undepend(MODULE_NAME);
++ return "This module requires eggdrop1.4.0 or later";
++ }
++ }
++ }
++ }
++ chanlangs = NULL;
++ coreslangs = NULL;
++ slang_glob_init();
++
++ results = NULL;
++ requests = NULL;
++ ignoredwords = NULL;
++ bnsnick = NULL;
++ bnschan = NULL;
++ seen_reply = NULL;
++
++ numresults = 0;
++ numseens = 0;
++ glob_total_queries = 0;
++ glob_total_searchtime = 0.0;
++ ignore_words[0] = 0;
++ no_pub[0] = 0;
++ quiet_seen[0] = 0;
++ no_log[0] = 0;
++ seentree_init();
++ add_tcl_strings(my_tcl_strings);
++ add_tcl_ints(my_tcl_ints);
++ add_tcl_coups(my_tcl_coups);
++ add_tcl_commands(mytcls);
++ add_tcl_commands(seendebugtcls);
++ add_tcl_commands(gseentcls);
++ add_builtins(H_dcc, mydcc);
++ add_builtins(H_join, seen_join);
++ add_builtins(H_kick, seen_kick);
++ add_builtins(H_nick, seen_nick);
++ add_builtins(H_part, seen_part);
++ add_builtins(H_sign, seen_sign);
++ add_builtins(H_sign, seen_sign);
++ add_builtins(H_splt, seen_splt);
++ add_builtins(H_rejn, seen_rejn);
++ add_builtins(H_pub, seen_pub);
++ add_builtins(H_msg, seen_msg);
++ add_builtins(H_bot, seen_bot);
++ read_seens();
++ add_hook(HOOK_MINUTELY, (Function) gseen_minutely);
++ add_hook(HOOK_DAILY, (Function) gseen_daily);
++#if EGG_IS_MIN_VER(10503)
++ initudef(1, "noseendata", 1);
++ initudef(1, "quietseens", 1);
++ initudef(1, "quietaiseens", 1);
++ initudef(1, "nopubseens", 1);
++#endif
++ glob_slang_cmd_list = slang_commands_list_add(glob_slang_cmd_list, slang_text_gseen_command_table);
++ putlog(LOG_MISC, "*", "gseen.mod v%s loaded.", MODULE_VERSION);
++ return NULL;
++}
+diff -Nur src/mod/gseen.mod/gseen.conf src/mod/gseen.mod/gseen.conf
+--- src/mod/gseen.mod/gseen.conf 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/gseen.conf 2002-10-26 13:17:54.000000000 +0200
+@@ -0,0 +1,147 @@
++
++######
++#####
++### General Settings
++#####
++######
++
++# the file where the seen data will be backuped.
++# WARNING: set this _before_ the module is loaded.
++set gseenfile "gseen.dat"
++
++# now load the module
++loadmodule gseen
++
++# load the English language file
++loadseenslang "en" "English" language/gseen.en.lang
++
++# load the German language file
++loadseenslang "de" "Deutsch" language/gseen.de.lang
++
++# set the default language to english...
++set default-slang "en"
++
++# ... but let #xwp use the german langfile
++setchanseenlang #xwp "de"
++
++# the char that marks public commands (!seen, etc...)
++# "" is a valid option
++set cmdchar "!"
++
++# delete data sets that are older than x days
++set expire-seens 60
++
++# only answer x seen requests in y seconds to prevent flooding
++set max-seens 7:60
++
++# tell users if someone was !seen'ing for them
++set tell-seens 1
++
++# check if the user was online under a different nick
++set fuzzy-search 1
++
++# allow user to include wildcards in the search?
++set wildcard-search 1
++
++# break search if there are more than x matches
++set max-matches 250
++
++# forward a request to other bots, if a !seen returned no result?
++set botnet-seens 1
++
++# store channels, which are +secret on the bot as [secret]?
++set hide-secret-chans 1
++
++# backup the seen data every x minutes
++set save-seens 60
++
++######
++#####
++### AI Settings
++#####
++######
++
++# this setting configures on which sentences your bot should
++# attempt to do an ai-seen. Each of them is a simple wildcard
++# mask. Set this to "" if you want to deactivate ai-seens or
++# create more precise masks if the bots reacts too often.
++set ai-seen-binds {
++ "${nick}*seen*"
++ "${botnet-nick}*seen*"
++ "${nick}*gesehen*"
++ "${botnet-nick}*gesehen*"
++}
++
++# this is just the same as above, but if triggered it will
++# not do an ai-seen, but display its seen-stats.
++set ai-seenstats-binds {
++ "${nick}*seenstats*"
++ "${botnet-nick}*seenstats*"
++}
++
++# when doing an AI seen, ignore the following words (otherwise
++# the bot might give weird answers like "<bot> nick, bot was last seen..." :)
++set ai-seen-ignore "$nick ${botnet-nick} seen"
++
++######
++#####
++### special stuff (can be ignored in most cases)
++#####
++######
++
++# if the user is known by the bot, log their handle instead of the nick
++# (not recommended, might cause confusion by the users)
++set use-handles 0
++
++######
++#####
++### outdated settings (only important for eggdropv1.4 users)
++#####
++######
++
++# channels where you do not want your bot to reply to public queries
++set no-pub-seens ""
++
++# channels where you want your bot to send replies via notice to the user and
++# not to the channel
++set quiet-seens ""
++
++# same as quiet-seens but for AI seen
++set quiet-ai-seens ""
++
++# channels where you do not want your bot to log seen data
++set no-seendata ""
++
++
++###############################################################################
++# end of configuration
++# just ignore everything below ^_^
++###############################################################################
++
++bind chjn - * *chjn:gseen
++bind chpt - * *chpt:gseen
++
++catch "unbind pub - !seen *pub:!seen"
++catch "unbind pub - !seennick *pub:!seennick"
++catch "unbind pub - !seenstats *pub:!seenstats"
++bind pub - ${cmdchar}seen *pub:!seen
++bind pub - ${cmdchar}seennick *pub:!seennick
++bind pub - ${cmdchar}seenstats *pub:!seenstats
++
++foreach bnd [binds pubm] {
++ if {([lindex $bnd 2] == "*pubm:seen") || ([lindex $bnd 2] == "*pub:!seenstats")} {
++ unbind [lindex $bnd 0] [lindex $bnd 1] [lindex $bnd 2] [lindex $bnd 4]
++ }
++}
++
++if {${ai-seen-binds} != ""} {
++ foreach mask ${ai-seen-binds} {
++ bind pubm -|- "% [subst $mask]" *pubm:seen
++ }
++}
++
++if {${ai-seenstats-binds} != ""} {
++ foreach mask ${ai-seenstats-binds} {
++ bind pubm -|- "% [subst $mask]" *pub:!seenstats
++ }
++}
+diff -Nur src/mod/gseen.mod/language/gseen.de.lang src/mod/gseen.mod/language/gseen.de.lang
+--- src/mod/gseen.mod/language/gseen.de.lang 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/language/gseen.de.lang 2002-10-26 13:18:12.000000000 +0200
+@@ -0,0 +1,131 @@
++#####################################################################
++#
++# Deutsche Sprachdatei für GSeen.Mod v1.1.0
++#
++# Der Text in dieser Datei kann nach belieben verändert werden. Du
++# kannst Tags hinzufügen oder entfernen, wie es Dir gefällt. Die Tags
++# müssen nicht in einer bestimmten Reihenfolge oder Anzahl vorkommen.
++#
++# Wenn Du mehr als eine Zeile pro ID angibst, dann wird bei der
++# Antwort per Zufall eine daraus ausgewählt. (das funktioniert nicht
++# bei den Zeiteinheiten)
++#
++# Falls Du denkst, daß hier noch ein paar wichtige Tags fehlen, dann
++# schick mir einfach eine email. Vielleicht füge ich sie dann in der
++# nächsten Version hinzu.
++#
++# Eine komplette Liste der Verfügbaren Tags befindet sich am Ende von
++# slang_gseen_commands.c (leider ohne Erklährungen)
++#
++#####################################################################
++
++#
++## Zeiteinheiten
++#
++# jeweils in Singular und Plural
++#
++D 0 Jahr
++D 1 Jahre
++D 2 Woche
++D 3 Wochen
++D 4 Tag
++D 5 Tage
++D 6 Stunde
++D 7 Stunden
++D 8 Minute
++D 9 Minuten
++D 10 Sekunde
++D 11 Sekunden
++# falls ein üngültiger Zeitwert angegeben war, dann wird dieser Text ausgegeben:
++D 12 einiger Zeit
++
++
++#
++## Präfixe
++#
++# Dieses Fragment wird jeweils vor eine Antwort gesetzt. Dadurch
++# ist beispielsweise bei öffentlichen Anfragen ersichtlich, für
++# wen die Antwort ist.
++# Achtung: Die Nummer muss auf jeden Fall definiert werden. Sie muss
++# zwar keinen Text beinhalten, aber wenn sie nicht vorhanden
++# ist, dann gibt es eine Fehlermeldung
++
++# für Antworten, die in den Channel geschrieben werden:
++10 <?nick/?>,
++# für Antworten, die per NOTICE an den User geschickt werden:
++11
++# für Antworten auf Anfragen, die per "/msg <bot> seen" erfolgt sind:
++12
++# und für Antworten auf der Partyline:
++13
++
++#
++## Fehlermeldungen
++#
++54 weißt Du was ein Parameter ist? ^_^
++54 ich würde Dir ja gerne helfen, aber solange Du nicht sagst, nach wem Du suchst, kann ich nicht viel tun.
++54 meinst Du nicht, es wäre geschickter zu sagen, nach wem Du überhaupt suchst?
++54 42.
++55 sehe ich etwa wie ein Spiegel aus? ^_^
++55 Spieglein, Spieglein an der Wand...
++55 leidest Du etwa unter multiplen Persönlichkeiten? *eg*
++56 also wenn Du <?query/?> jetzt hier nicht sehen kannst, dann brauchst Du sicherlich eine neue Brille ^_^
++56 ich muss mir unbedingt mal die Tarnkappe von <?query/?> ausleihen. Scheint ja prima zu funktioneren.
++56 schau Dir bitte nochmal ganz genau an, wer grade alles im Channel ist.
++57 Tut mir leid, aber Wildcards ('?', oder '*') sind bei der Suche nicht erlaubt.
++58 Öhm... naja... etwas arg lang, dieser Nick... :)
++
++#
++## Kein Ergebnis
++#
++65 Ich kann mich nicht daran erinnern, <?query/?> gesehen zu haben...
++65 <?query/?>? Hmm... ich bin mir nicht sicher... vielleicht... eventuell... nein, kenne ich nicht.
++65 der Name sagt mir nichts. Hast Du Dich vielleicht vertippt?
++66 Ich hab' <?query/?> seit <?laston/?> nicht mehr gesehen.
++67 Sorry, aber zu deiner Anfrage passt nichts in meiner Datenbank :(
++68 Autschi, das gab viel zu viele Ergebnisse. Bitte formuliere deine Suche etwas genauer.
++
++73 <?query/?> ist grade unter dem Nick "<?othernick/?>" in diesem Channel zu finden.
++74 <?query/?> ist gerade in <?otherchan/?>.
++75 Deine Anfrage führte zu genau einem Ergebnis:
++76 Immerhin <?numresults/?> Treffer ergab deine Anfrage:
++77 Wow, auf deine Anfrage passen sogar <?numresults/?> Einträge in meiner Datenbank! Dies sind die 5 aktuellsten:
++
++#
++## falls ein anderer Bot etwas gefunden hat:
++#
++85 <?remotebot/?> sagt:
++
++#
++## die eigentliche Information
++#
++101 Ich habe <?snick/?> (<?shost/?>) zuletzt <?schan/?> vor <?swhen/?> betreten sehen (<?stime/?>). <?snick/?> ist noch immer da.
++121 Ich habe <?snick/?> (<?shost/?>) zuletzt <?schan/?> vor <?swhen/?> betreten sehen (<?stime/?>), aber <?snick/?> verschwand mysteriöserweise.
++102 Ich habe <?snick/?> (<?shost/?>) zuletzt <?schan/?> vor <?swhen/?> nach <?spent/?> verchatteter Zeit verlassen sehen (<?stime/?>)
++103 Ich habe <?snick/?> (<?shost/?>) zuletzt in <?schan/?> gesehen, als er/sie vor <?swhen/?> (<?stime/?>) nach <?spent/?> das IRC verließ ("<?smsg/?>").
++104 Zuletzt habe ich <?snick/?> (<?shost/?>) vor <?swhen/?> in <?schan/?> gesehen, den Nick zu <?snick2/?> wechselnd. <?snick2/?> ist noch immer dort.
++124 <?snick/?> (<?shost/?>) was last seen changing his/her nick to <?snick2/?> on <?schan/?> <?swhen/?> ago (<?stime/?>), but <?snick2/?> mysteriously dematerialized.
++105 Zuletzt habe ich <?snick/?> (<?shost/?>) vor <?swhen/?> in <?schan/?> gesehen, den Nick von <?snick2/?> wechselnd. <?snick/?> ist noch immer dort.
++125 <?snick/?> (<?shost/?>) was last seen changing his/her nick from <?snick2/?> on <?schan/?> <?swhen/?> ago (<?stime/?>), but <?snick/?> mysteriously dematerialized.
++106 Zuletzt habe ich <?snick/?> (<?shost/?>) gesehen, als er vor <?swhen/?> (<?stime/?>) von <?punisher/?> aus <?schan/?> gejagt wurde. (<?kickreason/?>)
++107 <?snick/?> (<?shost/?>) habe ich zuletzt vor <?swhen/?> gesehen, als er/sie von <?schan/?> aus in einem Netsplit verschwand.
++108 <?snick/?> (<?shost/?>) habe ich zuletzt vor <?swhen/?> gesehen, als er/sie nach einem Netsplit in <?schan/?> zurück kam. <?snick/?> ist noch immer dort.
++128 <?snick/?> (<?shost/?>) habe ich zuletzt vor <?swhen/?> gesehen, als er/sie nach einem Netsplit in <?schan/?> zurück kam. Allerdings konnte <?snick/?> dem Gott der Netsplits nicht endgültig entkommen und ist wieder verschollen...
++109 <?snick/?> was last seen joining the botnet channel <?schan/?> on <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++129 <?snick/?> was last seen joining the partyline on <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++110 <?snick/?> was last seen leaving the botnet channel <?schan/?> from <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++130 <?snick/?> was last seen leaving the partyline from <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++140 <?snick/?> (<?shost/?>) was last seen on <?schan/?> <?swhen/?> ago (<?stime/?>).
++
++#
++## Seen-Mitteilungen
++#
++170 <?rnick/?> (<?rhost/?>) scheint vor <?rwhen/?> (<?rtime/?>) in <?rchan/?> auf der Suche nach Dir gewesen zu sein.
++171 <?requests/?> Leute haben sich nach Dir erkundigt:
++172 Der/die letzte war <?rnick/?> (<?rhost/?>) in <?rchan/?> vor <?rwhen/?> (<?rtime/?>).
++
++#
++## Statistiken
++#
++180 Momentan sind <?totalnicks/?> Nicks in meiner Datenbank. Gesamter Speicherverbrauch: <?totalbytes/?> Bytes
++180 In meiner Datenbank befinden sich <?totalnicks/?> Nicks und verbrauchen <?totalbytes/?> Bytes Speicher.
+diff -Nur src/mod/gseen.mod/language/gseen.en.lang src/mod/gseen.mod/language/gseen.en.lang
+--- src/mod/gseen.mod/language/gseen.en.lang 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/language/gseen.en.lang 2002-10-26 13:18:13.000000000 +0200
+@@ -0,0 +1,131 @@
++#####################################################################
++#
++# Default English langfile for GSeen.Mod v1.1.0
++#
++# Just edit the text below to fit your needs. You can add or remove
++# any tag just like you want, they do not need to appear in a special
++# order (or number).
++#
++# If you enter more than one line per ID, then a random one will be
++# chosen for each reply. (this does not work for the time strings)
++#
++# If you think you need more tags, just email me and maybe I'll add
++# them in the next release.
++#
++# A complete list of available Tags can be found at the end of the
++# file slang_gseen_commands.c (unfortunately, it does not contain any
++# descriptions for the tags)
++#
++#####################################################################
++
++#
++## time string
++#
++# each time string in singular and plural
++#
++D 0 year
++D 1 years
++D 2 week
++D 3 weeks
++D 4 day
++D 5 days
++D 6 hour
++D 7 hours
++D 8 minute
++D 9 minutes
++D 10 second
++D 11 seconds
++# if an invalid time value was supplied, output the following string
++D 12 some time
++
++#
++## Prefixes
++#
++# These are the prefixes of the replies. By default, there's only
++# a prefix for public requests (so you know for whom the answer is),
++# but you can also define prefixes for other requests.
++
++# for replies in the channel:
++10 <?nick/?>,
++# for replies via notice:
++11
++# for replies via PRIVMSG
++12
++# for replies on the partyline
++13
++
++#
++## error messages
++#
++54 do you know what a parameter is?
++54 don't you think it would be more reasonable to say for whom you are searching?
++54 42.
++55 do I look like a mirror? ^_^
++55 mirror mirror on the wall...
++55 do you have a split personality? *eg*
++56 if you can't see <?query/?> here right now, you probably need new glasses. ^_^
++56 please look a bit closer at the memberlist of this channel.
++57 I'm sorry, but wildcards ('?' or '*') are not allowed in a search.
++58 Hum... don't you think this nick is a bit long? ^_^
++58 you know that the length of nicks is limited, don't you?
++
++#
++## no result
++#
++65 I don't remember seeing <?query/?>.
++65 <?query/?>? hmm... I'm trying to remember... maybe... I'm not sure... no. I don't remember <?query/?>.
++66 I haven't seen <?query/?> for <?laston/?>.
++67 I found no matches to your query.
++67 I'm sorry, but your search didn't return any results.
++68 Ouch, your search returned way too many matches. Please refine it.
++
++#
++## victim is online
++#
++73 <?query/?> is <?othernick/?>, who is on this channel right now.
++74 <?query/?> is on <?otherchan/?> right now.
++
++#
++## results found
++#
++75 I found one match to your query:
++76 I found <?numresults/?> matches to your query:
++77 I found <?numresults/?> matches to your query. These are the 5 most recent ones:
++
++#
++## results found by another bot in the botnet
++#
++85 <?remotebot/?> says:
++
++#
++## the core info
++#
++101 <?snick/?> (<?shost/?>) was last seen joining <?schan/?> <?swhen/?> ago (<?stime/?>). <?snick/?> is still there.
++121 <?snick/?> (<?shost/?>) was last seen joining <?schan/?> <?swhen/?> ago (<?stime/?>), but <?snick/?> mysteriously dematerialized.
++102 <?snick/?> (<?shost/?>) was last seen parting <?schan/?> <?swhen/?> ago (<?stime/?>), after spending <?spent/?> there.
++103 <?snick/?> (<?shost/?>) was last seen quitting <?schan/?> <?swhen/?> ago (<?stime/?>) stating "<?smsg/?>" after spending <?spent/?> there.
++104 <?snick/?> (<?shost/?>) was last seen changing his/her nick to <?snick2/?> on <?schan/?> <?swhen/?> ago (<?stime/?>). <?snick2/?> is still there.
++124 <?snick/?> (<?shost/?>) was last seen changing his/her nick to <?snick2/?> on <?schan/?> <?swhen/?> ago (<?stime/?>), but <?snick2/?> mysteriously dematerialized.
++105 <?snick/?> (<?shost/?>) was last seen changing his/her nick from <?snick2/?> on <?schan/?> <?swhen/?> ago (<?stime/?>). <?snick/?> is still there.
++125 <?snick/?> (<?shost/?>) was last seen changing his/her nick from <?snick2/?> on <?schan/?> <?swhen/?> ago (<?stime/?>), but <?snick/?> mysteriously dematerialized.
++106 <?snick/?> (<?shost/?>) was last seen being kicked from <?schan/?> by <?punisher/?> (<?kickreason/?>) <?swhen/?> ago (<?stime/?>), after spending <?spent/?> there.
++107 <?snick/?> (<?shost/?>) was last seen splitting from <?schan/?> <?swhen/?> ago (<?stime/?>), after spending <?spent/?> there.
++108 <?snick/?> (<?shost/?>) was last seen rejoining <?schan/?> from a netsplit <?swhen/?> ago (<?stime/?>) <?snick/?> is still there.
++128 <?snick/?> (<?shost/?>) was last seen rejoining <?schan/?> from a netsplit <?swhen/?> ago (<?stime/?>), but the god of netsplits didn't let him escape, so he's not here now.
++109 <?snick/?> was last seen joining the botnet channel <?schan/?> on <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++129 <?snick/?> was last seen joining the partyline on <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++110 <?snick/?> was last seen leaving the botnet channel <?schan/?> from <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++130 <?snick/?> was last seen leaving the partyline from <?bnbot/?> <?swhen/?> ago (<?stime/?>).
++140 <?snick/?> (<?shost/?>) was last seen on <?schan/?> <?swhen/?> ago (<?stime/?>).
++
++#
++## seen notification
++#
++170 <?rnick/?> (<?rhost/?>) was looking for you on <?rchan/?> <?rwhen/?> ago (<?rtime/?>).
++171 There have been <?requests/?> users looking for you:
++172 The last one was <?rnick/?> (<?rhost/?>) on <?rchan/?> <?rwhen/?> ago (<?rtime/?>).
++
++#
++## seen stats
++#
++180 I'm currently tracking <?totalnicks/?> nicks using <?totalbytes/?> bytes.
+diff -Nur src/mod/gseen.mod/gseen.h src/mod/gseen.mod/gseen.h
+--- src/mod/gseen.mod/gseen.h 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/gseen.h 2002-10-26 13:17:55.000000000 +0200
+@@ -0,0 +1,157 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++/* #define USE_MEMDEBUG 1 */
++
++#define SEEN_JOIN 1
++#define SEEN_PART 2
++#define SEEN_SIGN 3
++#define SEEN_NICK 4
++#define SEEN_NCKF 5
++#define SEEN_KICK 6
++#define SEEN_SPLT 7
++#define SEEN_REJN 8
++#define SEEN_CHPT 9
++#define SEEN_CHJN 10
++
++typedef struct gseen_data {
++ int type;
++ char *nick;
++ char *host;
++ char *chan;
++ char *msg;
++ time_t when;
++ int spent;
++} seendat;
++
++typedef struct gseen_result {
++ struct gseen_result *next;
++ seendat *seen;
++} gseenres;
++
++typedef struct gseen_requests {
++ struct gseen_requests *next;
++ char *who;
++ char *host;
++ char *chan;
++ time_t when;
++} seenreq_by;
++
++typedef struct gseen_request {
++ struct gseen_request *next;
++ char *nick;
++ struct gseen_requests *by;
++} seenreq;
++
++typedef struct gseen_ignorewords {
++ struct gseen_ignorewords *next;
++ char *word;
++} ignoredword;
++
++#ifdef MAKING_GSEEN
++static int gseen_expmem();
++static void free_gseen();
++static int get_spent(char *, char *);
++static void write_seens();
++static void read_seens();
++static char *do_seen(char *, char *, char *, char *, int);
++static void add_seenresult(seendat *);
++static int expmem_seenresults();
++static void free_seenresults();
++static void sortresults();
++static char *do_seennick(seendat *);
++static int onchan(char *, char *);
++static char *handonchan(char *, char *);
++static struct chanset_t *onanychan(char *);
++static struct chanset_t *handonanychan(char *);
++static char *do_seenstats();
++static void add_seenreq(char *, char *, char *, char *, time_t);
++static int expmem_seenreq();
++static void free_seenreq();
++static void sortrequests(seenreq *);
++static void report_seenreq(char *, char *);
++static int count_seenreq(seenreq_by *b);
++static int expmem_ignoredwords();
++static void free_ignoredwords();
++static void add_ignoredword(char *word);
++static int word_is_ignored(char *word);
++static void purge_seens();
++static int seenflood();
++static int secretchan(char *);
++static int nopub(char *);
++static int quietseen(char *);
++static int quietaiseens(char *);
++static int nolog(char *);
++static void start_seentime_calc();
++static void end_seentime_calc();
++#endif
++
++
++#ifdef MAKING_GSEEN
++
++// tree stuff
++static void maskstricthost(const char *, char *);
++#endif
++
++// interface for webseen
++#define WS_OK 0
++#define WS_NORESULT 1
++#define WS_NOPARAM 2
++#define WS_NOWILDCARDS 3
++#define WS_TOOLONGNICK 4
++#define WS_TOOMANYMATCHES 5
++#define WS_TOOLONGHOST 6
++
++#ifndef MAKING_GSEEN
++#define findseens ((gseenres *(*)(char *, int *, int))gseen_funcs[4])
++#define free_seenresults ((void (*)())gseen_funcs[5])
++#define gseen_duration ((char *(*)(int))gseen_funcs[6])
++#define numresults (*(int *)(gseen_funcs[12]))
++#define fuzzy_search (*(int *)(gseen_funcs[13]))
++#define numseens (*(int *)(gseen_funcs[15]))
++#define glob_total_queries (*(int *)(gseen_funcs[16]))
++#define glob_total_searchtime (*(double *)(gseen_funcs[17]))
++#define gseen_numversion (*(int *)(gseen_funcs[19]))
++#else
++static gseenres *findseens(char *, int *, int);
++static char *gseen_duration(int);
++#endif
++
++#ifdef MAKING_GSEEN
++
++#ifdef malloc
++#undef malloc
++#endif
++#ifdef free
++#undef free
++#endif
++#ifdef realloc
++#undef realloc
++#endif
++
++#ifdef USE_MEMDEBUG
++#define my_malloc nmalloc
++#define my_free nfree
++#define my_realloc nrealloc
++#else
++#define my_malloc malloc
++#define my_free free
++#define my_realloc realloc
++#endif
++
++#endif
+diff -Nur src/mod/gseen.mod/gseencmds.c src/mod/gseen.mod/gseencmds.c
+--- src/mod/gseen.mod/gseencmds.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/gseencmds.c 2002-10-26 13:17:56.000000000 +0200
+@@ -0,0 +1,420 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++#define PREFIX_LENGTH 20
++
++static char reply_prefix[PREFIX_LENGTH + 1];
++#define set_prefix(x) strncpy(reply_prefix, x, PREFIX_LENGTH); \
++ reply_prefix[PREFIX_LENGTH] = 0;
++
++static int seenflood()
++{
++ if (!maxseen_thr || !maxseen_time)
++ return 0;
++ if ((now - seenflood_time) > maxseen_time) {
++ seenflood_time = now;
++ seenflood_thr = 0;
++ }
++ seenflood_thr++;
++ if (seenflood_thr > maxseen_thr)
++ return 1;
++ else
++ return 0;
++}
++
++static int nopub(char *chan)
++{
++ char buf[121], *b;
++
++ Context;
++ strncpy(buf, no_pub, 120);
++ buf[120] = 0;
++ b = buf;
++ while (b[0])
++ if (!strcasecmp(chan, newsplit(&b)))
++ return 1;
++#if EGG_IS_MIN_VER(10503)
++ if (ngetudef("nopubseens", chan))
++ return 1;
++#endif
++ return 0;
++}
++
++static int quietseen(char *chan)
++{
++ char buf[121], *b;
++
++ Context;
++ strncpy(buf, quiet_seen, 120);
++ buf[120] = 0;
++ b = buf;
++ while (b[0])
++ if (!strcasecmp(chan, newsplit(&b)))
++ return 1;
++#if EGG_IS_MIN_VER(10503)
++ if (ngetudef("quietseens", chan))
++ return 1;
++#endif
++ return 0;
++}
++
++static int cmd_seen(struct userrec *u, int idx, char *par)
++{
++ char *query;
++
++ Context;
++ if (seenflood())
++ return 0;
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, default_slang);
++ glob_nick = dcc[idx].nick;
++ query = newsplit(&par);
++ glob_query = query;
++ set_prefix(SLDCCPREFIX);
++ putlog(LOG_CMDS, "*", "#%s# seen %s", dcc[idx].nick, par);
++ dprintf(idx, "%s%s\n", reply_prefix, do_seen(query, dcc[idx].nick,
++ dcc[idx].host, "[partyline]", botnet_seen));
++ return 0;
++}
++
++static int cmd_seenstats(struct userrec *u, int idx, char *par)
++{
++ Context;
++ if (seenflood())
++ return 0;
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, default_slang);
++ glob_nick = dcc[idx].nick;
++ set_prefix(SLDCCPREFIX);
++ putlog(LOG_CMDS, "*", "#%s# seenstats", dcc[idx].nick);
++ dprintf(idx, "%s%s\n", reply_prefix, do_seenstats());
++ return 0;
++}
++
++static int cmd_purgeseens(struct userrec *u, int idx, char *par)
++{
++ Context;
++ purge_seens();
++ putlog(LOG_CMDS, "*", "#%s# purgeseens", dcc[idx].nick);
++ return 0;
++}
++
++static int pub_seen(char *nick, char *host, char *hand,
++ char *channel, char *text)
++{
++ char *dest;
++#if EGG_IS_MIN_VER(10500)
++ struct chanset_t *chan;
++#endif
++
++ Context;
++ if (seenflood() || nopub(channel))
++ return 0;
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, channel));
++ glob_nick = nick;
++ putlog(LOG_CMDS, "*", "<<%s>> !%s! seen %s", nick, hand, text);
++ if (quietseen(channel)) {
++ set_prefix(SLNOTPREFIX);
++ dprintf(DP_HELP, "NOTICE %s :%s%s\n", nick, reply_prefix,
++ do_seen(newsplit(&text), nick, host, channel, botnet_seen));
++ return 0;
++ }
++#if EGG_IS_MIN_VER(10500)
++ chan = findchan_by_dname(channel);
++ if (chan)
++ dest = chan->name;
++ else
++ dest = channel;
++#else
++ dest = channel;
++#endif
++ set_prefix(SLPUBPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", dest, reply_prefix,
++ do_seen(newsplit(&text), nick, host, channel, botnet_seen));
++ return 0;
++}
++
++static int pub_seenstats(char *nick, char *host, char *hand,
++ char *channel, char *text)
++{
++ char *dest;
++#if EGG_IS_MIN_VER(10500)
++ struct chanset_t *chan;
++#endif
++
++ Context;
++ if (seenflood())
++ return 0;
++ if (nopub(channel))
++ return 0;
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, channel));
++ glob_nick = nick;
++ putlog(LOG_CMDS, "*", "<<%s>> !%s! seenstats", nick, hand);
++ if (quietseen(channel)) {
++ set_prefix(SLNOTPREFIX);
++ dprintf(DP_HELP, "NOTICE %s :%s%s\n", nick, reply_prefix, do_seenstats());
++ return 0;
++ }
++#if EGG_IS_MIN_VER(10500)
++ chan = findchan_by_dname(channel);
++ if (chan)
++ dest = chan->name;
++ else
++ dest = channel;
++#else
++ dest = channel;
++#endif
++ set_prefix(SLPUBPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", dest, reply_prefix, do_seenstats());
++ return 1;
++}
++
++static int msg_seen(char *nick, char *uhost, struct userrec *u, char *text)
++{
++ Context;
++ if (seenflood())
++ return 0;
++ reset_global_vars();
++ glob_slang = slang_getbynick(coreslangs, nick);
++ glob_nick = nick;
++ putlog(LOG_CMDS, "*", "(%s!%s) !%s! seen %s", nick, uhost, u ? u->handle : "*", text);
++ set_prefix(SLMSGPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", nick, reply_prefix,
++ do_seen(newsplit(&text), nick, uhost, "[/msg]", botnet_seen));
++ return 1;
++}
++
++static int pub_seennick(char *nick, char *host, char *hand,
++ char *channel, char *text)
++{
++ seendat *l;
++ char *dest;
++#if EGG_IS_MIN_VER(10500)
++ struct chanset_t *chan;
++#endif
++
++ Context;
++ if (seenflood())
++ return 0;
++ if (nopub(channel))
++ return 0;
++ putlog(LOG_CMDS, "*", "<<%s>> !%s! seennick %s", nick, hand, text);
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, channel));
++ glob_nick = nick;
++#if EGG_IS_MIN_VER(10500)
++ chan = findchan_by_dname(channel);
++ if (chan)
++ dest = chan->name;
++ else
++ dest = channel;
++#else
++ dest = channel;
++#endif
++ text = newsplit(&text);
++ l = findseen(text);
++ if (!l) {
++ glob_query = text;
++ if (quietseen(channel)) {
++ set_prefix(SLNOTPREFIX);
++ dprintf(DP_HELP, "NOTICE %s :%s%s\n", nick, reply_prefix, SLNOTSEEN);
++ } else {
++ set_prefix(SLPUBPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", dest, reply_prefix, SLNOTSEEN);
++ }
++ return 0;
++ }
++ if (quietseen(channel)) {
++ set_prefix(SLNOTPREFIX);
++ dprintf(DP_HELP, "NOTICE %s :%s%s\n", nick, reply_prefix, do_seennick(l));
++ } else {
++ set_prefix(SLPUBPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", dest, reply_prefix, do_seennick(l));
++ }
++ return 0;
++}
++
++static int msg_seennick(char *nick, char *uhost, struct userrec *u, char *text)
++{
++ seendat *l;
++
++ Context;
++ if (seenflood())
++ return 0;
++ putlog(LOG_CMDS, "*", "(%s!%s) !%s! seennick %s", nick, uhost, u ? u->handle : "*", text);
++ reset_global_vars();
++ glob_slang = slang_getbynick(coreslangs, nick);
++ glob_nick = nick;
++ set_prefix(SLMSGPREFIX);
++ text = newsplit(&text);
++ l = findseen(text);
++ if (!l) {
++ glob_query = text;
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", nick, reply_prefix, SLNOTSEEN);
++ return 0;
++ }
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s\n", nick, reply_prefix, do_seennick(l));
++ return 0;
++}
++
++static int cmd_seennick(struct userrec *u, int idx, char *text)
++{
++ seendat *l;
++
++ Context;
++ if (seenflood())
++ return 0;
++ putlog(LOG_CMDS, "*", "#%s# seennick %s", dcc[idx].nick, text);
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, default_slang);
++ glob_nick = dcc[idx].nick;
++ set_prefix(SLMSGPREFIX);
++ text = newsplit(&text);
++ l = findseen(text);
++ if (!l) {
++ glob_query = text;
++ dprintf(idx, "%s%s\n", reply_prefix, SLNOTSEEN);
++ return 0;
++ }
++ dprintf(idx, "%s%s\n", reply_prefix, do_seennick(l));
++ return 0;
++}
++
++static int bot_gseen_req(char *bot, char *code, char *par)
++{
++ char *mask, *nick, *uhost, *chan, *reply;
++ char tosend[256];
++ int i;
++
++ Context;
++ if (seenflood())
++ return 0;
++ i = nextbot(bot);
++ if (i < 0) {
++ debug1("Couldn't answer botnet-seen-request from %s: no such bot", bot);
++ return 0;
++ }
++ mask = newsplit(&par);
++ nick = newsplit(&par);
++ uhost = newsplit(&par);
++ chan = newsplit(&par);
++ reset_global_vars();
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, chan));
++ glob_nick = nick;
++ reply = do_seen(mask, nick, uhost, chan, -1);
++ if (!reply)
++ return 0;
++ if ((strlen(nick) + strlen(chan) + strlen(reply)) < 255) {
++ sprintf(tosend, "gseen_rep %s %s %s", nick, chan, reply);
++ botnet_send_zapf(i, botnetnick, bot, tosend);
++ }
++ return 0;
++}
++
++static int bot_gseen_rep(char *bot, char *code, char *par)
++{
++ char *nick, *chan, *reply;
++ int i;
++
++ Context;
++ if (seenflood())
++ return 0;
++ if (!bnsnick || !bnschan) {
++ if (bnsnick)
++ nfree(bnsnick);
++ if (bnschan)
++ nfree(bnschan);
++ bnsnick = bnschan = NULL;
++ return 0;
++ }
++ nick = newsplit(&par);
++ chan = newsplit(&par);
++ reset_global_vars();
++ glob_remotebot = bot;
++ glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, chan));
++ glob_nick = nick;
++ reply = par;
++ if (strcmp(nick, bnsnick) || strcmp(chan, bnschan))
++ return 0; /* unwanted reply */
++ if (findchan(chan)) {
++ if (nopub(chan)) {
++ nfree(bnsnick);
++ nfree(bnschan);
++ bnsnick = bnschan = NULL;
++ debug1("%s is nopub, bns-reply dropped", chan);
++ return 0;
++ }
++ if (quietseen(chan)) {
++ set_prefix(SLNOTPREFIX);
++ dprintf(DP_HELP, "NOTICE %s :%s%s%s\n", nick, reply_prefix, SLRBOTSAYS, reply);
++ } else {
++ set_prefix(SLPUBPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s%s\n", chan, reply_prefix, SLRBOTSAYS, reply);
++ }
++ } else if (!strcmp(chan, "[/msg]")) {
++ set_prefix(SLMSGPREFIX);
++ dprintf(DP_HELP, "PRIVMSG %s :%s%s%s\n", nick, reply_prefix, SLRBOTSAYS, reply);
++ } else if (!strcmp(chan, "[partyline]")) {
++ for (i = 0; i < dcc_total; i++) {
++ if ((!strcasecmp(nick, dcc[i].nick)) &&
++ (dcc[i].type->flags & DCT_SIMUL)) {
++ set_prefix(SLDCCPREFIX);
++ dprintf(i, "%s%s%s\n", reply_prefix, SLRBOTSAYS, reply);
++ break;
++ }
++ }
++ } else
++ debug1("Couldn't send received bns answer, no such chan %s", chan);
++ nfree(bnsnick);
++ nfree(bnschan);
++ bnsnick = bnschan = NULL;
++ return 0;
++}
++
++static cmd_t mydcc[] =
++{
++ {"seen", "-|-", cmd_seen, NULL},
++ {"seenstats", "-|-", cmd_seenstats, NULL},
++ {"purgeseens", "m", cmd_purgeseens, NULL},
++ {"seennick", "-|-", cmd_seennick, NULL},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_pub[] =
++{
++ {"!seen", "", pub_seen, 0},
++ {"!seenstats", "", pub_seenstats, 0},
++ {"!seennick", "", pub_seennick, 0},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_msg[] =
++{
++ {"seen", "", msg_seen, 0},
++ {"seennick", "", msg_seennick, 0},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_bot[] =
++{
++ {"gseen_req", "", bot_gseen_req, 0},
++ {"gseen_rep", "", bot_gseen_rep, 0},
++ {0, 0, 0, 0}
++};
+diff -Nur src/mod/gseen.mod/misc.c src/mod/gseen.mod/misc.c
+--- src/mod/gseen.mod/misc.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/misc.c 2002-10-26 13:17:57.000000000 +0200
+@@ -0,0 +1,116 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++/* maskstricthost():
++ * basically the same as maskhost() from src/misc.c, but _never_ stripts
++ * "~+-^=" off the host
++ * maskhost() version: * $Id: misc.c,v 1.30 2000/10/27 19:27:32 fabian Exp $
++ */
++static void maskstricthost(const char *s, char *nw)
++{
++ register const char *p, *q, *e, *f;
++ int i;
++
++ *nw++ = '*';
++ *nw++ = '!';
++ p = (q = strchr(s, '!')) ? q + 1 : s;
++ /* Strip of any nick, if a username is found, use last 8 chars */
++ if ((q = strchr(p, '@'))) {
++ int fl = 0;
++
++ if ((q - p) > 9) {
++ nw[0] = '*';
++ p = q - 7;
++ i = 1;
++ } else
++ i = 0;
++ while (*p != '@') {
++ if (!fl && strchr("~+-^=", *p)) {
++// if (strict_host)
++ nw[i] = '?';
++// else
++// i--;
++ } else
++ nw[i] = *p;
++ fl++;
++ p++;
++ i++;
++ }
++ nw[i++] = '@';
++ q++;
++ } else {
++ nw[0] = '*';
++ nw[1] = '@';
++ i = 2;
++ q = s;
++ }
++ nw += i;
++ e = NULL;
++ /* Now q points to the hostname, i point to where to put the mask */
++ if ((!(p = strchr(q, '.')) || !(e = strchr(p + 1, '.'))) && !strchr(q, ':'))
++ /* TLD or 2 part host */
++ strcpy(nw, q);
++ else {
++ if (e == NULL) { /* IPv6 address? */
++ const char *mask_str;
++
++ f = strrchr(q, ':');
++ if (strchr(f, '.')) { /* IPv4 wrapped in an IPv6? */
++ f = strrchr(f, '.');
++ mask_str = ".*";
++ } else /* ... no, true IPv6. */
++ mask_str = ":*";
++ strncpy(nw, q, f - q);
++ /* No need to nw[f-q] = 0 here, as the strcpy below will
++ * terminate the string for us.
++ */
++ nw += (f - q);
++ strcpy(nw, mask_str);
++ } else {
++ for (f = e; *f; f++);
++ f--;
++ if (*f >= '0' && *f <= '9') { /* Numeric IP address */
++ while (*f != '.')
++ f--;
++ strncpy(nw, q, f - q);
++ /* No need to nw[f-q] = 0 here, as the strcpy below will
++ * terminate the string for us.
++ */
++ nw += (f - q);
++ strcpy(nw, ".*");
++ } else { /* Normal host >= 3 parts */
++ /* a.b.c -> *.b.c
++ * a.b.c.d -> *.b.c.d if tld is a country (2 chars)
++ * OR *.c.d if tld is com/edu/etc (3 chars)
++ * a.b.c.d.e -> *.c.d.e etc
++ */
++ const char *x = strchr(e + 1, '.');
++
++ if (!x)
++ x = p;
++ else if (strchr(x + 1, '.'))
++ x = e;
++ else if (strlen(x) == 3)
++ x = p;
++ else
++ x = e;
++ sprintf(nw, "*%s", x);
++ }
++ }
++ }
++}
+diff -Nur src/mod/gseen.mod/seenlang.h src/mod/gseen.mod/seenlang.h
+--- src/mod/gseen.mod/seenlang.h 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/seenlang.h 2002-10-26 13:17:58.000000000 +0200
+@@ -0,0 +1,61 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++#define SLPUBPREFIX getslang(10)
++#define SLNOTPREFIX getslang(11)
++#define SLMSGPREFIX getslang(12)
++#define SLDCCPREFIX getslang(13)
++
++#define SLNOPARAM getslang(54)
++#define SLMIRROR getslang(55)
++#define SLONCHAN getslang(56)
++#define SLNOWILDCARDS getslang(57)
++#define SLTOOLONGNICK getslang(58)
++
++#define SLNOTSEEN getslang(65)
++#define SLPOORSEEN getslang(66)
++#define SLNOMATCH getslang(67)
++#define SLTOOMANYMATCHES getslang(68)
++
++#define SLHANDONCHAN getslang(73)
++#define SLONOTHERCHAN getslang(74)
++#define SLONEMATCH getslang(75)
++#define SLLITTLEMATCHES getslang(76)
++#define SLMANYMATCHES getslang(77)
++
++#define SLRBOTSAYS getslang(85)
++
++#define SLYEAR getdur(0)
++#define SLYEARS getdur(1)
++#define SLWEEK getdur(2)
++#define SLWEEKS getdur(3)
++#define SLDAY getdur(4)
++#define SLDAYS getdur(5)
++#define SLHOUR getdur(6)
++#define SLHOURS getdur(7)
++#define SLMINUTE getdur(8)
++#define SLMINUTES getdur(9)
++#define SLSECOND getdur(10)
++#define SLSECONDS getdur(11)
++#define SLSOMETIME getdur(12)
++
++#define SLONELOOK getslang(170)
++#define SLMORELOOKS getslang(171)
++#define SLLASTLOOK getslang(172)
++
++#define SLSEENSTATS getslang(180)
+diff -Nur src/mod/gseen.mod/seentree.c src/mod/gseen.mod/seentree.c
+--- src/mod/gseen.mod/seentree.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/seentree.c 2002-10-26 13:18:10.000000000 +0200
+@@ -0,0 +1,213 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++static struct generic_binary_tree seentree;
++
++static void seentree_init();
++static int seentree_expmem();
++static void seentree_free();
++static int compareseens(void *, void *);
++static int expmemseen(void *);
++static void add_seen(int, char *, char *, char *, char *,
++ time_t, int);
++static void freeseen(void *);
++static seendat *findseen(char *);
++static void wildmatch_seens(char *, char *, int);
++static void process_wildmatch_seens(void *);
++static void write_seen_tree(void *);
++static void purge_seen_tree(void *);
++static int count_seens();
++static void _count_seens(void *);
++
++
++static void seentree_init()
++{
++ seentree.root = NULL;
++ seentree.comparedata = compareseens;
++ seentree.expmemdata = expmemseen;
++ seentree.freedata = freeseen;
++}
++
++static int seentree_expmem()
++{
++ return btree_expmem(&seentree);
++}
++
++static void seentree_free()
++{
++ btree_freetree(&seentree);
++ seentree.root = NULL;
++}
++
++static int compareseens(void *first, void *second)
++{
++ return rfc_casecmp(((seendat *) first)->nick, ((seendat *) second)->nick);
++}
++
++// add another entry to the tree
++static void add_seen(int type, char *nick, char *host, char *chan, char *msg,
++ time_t when, int spent)
++{
++ seendat *newseen;
++
++ newseen = nmalloc(sizeof(seendat));
++ newseen->type = type;
++ newseen->nick = nmalloc(strlen(nick) + 1);
++ strcpy(newseen->nick, nick);
++ newseen->host = nmalloc(strlen(host) + 1);
++ strcpy(newseen->host, host);
++ newseen->chan = nmalloc(strlen(chan) + 1);
++ strcpy(newseen->chan, chan);
++ newseen->msg = nmalloc(strlen(msg) + 1);
++ strcpy(newseen->msg, msg);
++ newseen->when = when;
++ newseen->spent = spent;
++ btree_add(&seentree, newseen);
++}
++
++static void freeseen(void *what)
++{
++ seendat *s = (seendat *) what;
++
++ Assert(s);
++ Assert(s->nick);
++ Assert(s->host);
++ Assert(s->chan);
++ Assert(s->msg);
++
++ nfree(s->nick);
++ nfree(s->host);
++ nfree(s->chan);
++ nfree(s->msg);
++ nfree(s);
++}
++
++static int expmemseen(void *what)
++{
++ int size = 0;
++ seendat *d = (seendat *) what;
++
++ size += sizeof(seendat);
++ size += strlen(d->nick) + 1;
++ size += strlen(d->host) + 1;
++ size += strlen(d->chan) + 1;
++ size += strlen(d->msg) + 1;
++ return size;
++}
++
++// finds a seen entry in the tree
++seendat findseen_temp;
++static seendat *findseen(char *nick)
++{
++ findseen_temp.nick = nick;
++ return btree_get(&seentree, &findseen_temp);
++}
++
++// function to find all nicks that match a host
++// (calls btree_getall() which calls a target function for each item)
++// host: user's hostmask (used if search query doesn't contain any wildcards)
++// mask: search mask
++// wild: defines if we want to use the mask, or host for the search
++static char *wildmatch_host, *wildmatch_mask;
++int wildmatch_wild;
++static void wildmatch_seens(char *host, char *mask, int wild)
++{
++ wildmatch_host = host;
++ wildmatch_mask = mask;
++ wildmatch_wild = wild;
++ btree_getall(&seentree, process_wildmatch_seens);
++}
++
++/* process_wildmatch_seens():
++ * gets called from the binary tree for each existing item.
++ */
++static void process_wildmatch_seens(void *data)
++{
++ seendat *s = (seendat *) data;
++
++ if ((numresults > max_matches) && (max_matches > 0)) // Don't return too many
++ return; // matches...
++ if (!wildmatch_wild) {
++ if (wild_match(wildmatch_host, s->host))
++ add_seenresult(s);
++ } else {
++ temp_wildmatch_host = my_realloc(temp_wildmatch_host, strlen(s->nick) + 1 + strlen(s->host) + 1);
++ strcpy(temp_wildmatch_host, s->nick);
++ strcat(temp_wildmatch_host, "!");
++ strcat(temp_wildmatch_host, s->host);
++ if (wild_match(wildmatch_mask, s->nick) || wild_match(wildmatch_mask, temp_wildmatch_host))
++ add_seenresult(s);
++ }
++}
++
++// write seendata in the datafile
++FILE *write_seen_tree_target;
++static void write_seen_tree(void *data)
++{
++ seendat *node = (seendat *) data;
++
++ /* format: "! nick host chan type when spent msg" */
++ fprintf(write_seen_tree_target, "! %s %s %s %d %lu %d %s\n", node->nick,
++ node->host, node->chan, node->type, node->when, node->spent,
++ node->msg);
++}
++
++// recursive function to remove old data
++// QUESTION: What happens if one of the nodes get moved by killseen()?
++// Possible bug/crash?
++// I think it should not be a problem. When killseen() is called the
++// first time, recursion already reached its end and no pointers
++// are accessed anymore. But I'm not sure... maybe I'm wrong.
++static void purge_seen_tree(void *data)
++{
++ seendat *node = (seendat *) data;
++
++ if ((now - node->when) > (expire_seens * 86400)) {
++ debug1("seen data for %s has expired.", node->nick);
++ btree_remove(&seentree, node);
++ }
++}
++
++// counts the number of nicks in the database
++static int count_seens_temp;
++static int count_seens()
++{
++ count_seens_temp = 0;
++ btree_getall(&seentree, _count_seens);
++ return count_seens_temp;
++}
++
++static void _count_seens(void *node)
++{
++ count_seens_temp++;
++}
++
++static int tcl_killseen STDVAR
++{
++ Context;
++ BADARGS(2, 2, " nick");
++ findseen_temp.nick = argv[1];
++ btree_remove(&seentree, &findseen_temp);
++ return TCL_OK;
++}
++
++static tcl_cmds seendebugtcls[] =
++{
++ {"killseen", tcl_killseen},
++ {0, 0}
++};
+diff -Nur src/mod/gseen.mod/sensors.c src/mod/gseen.mod/sensors.c
+--- src/mod/gseen.mod/sensors.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/sensors.c 2002-10-26 13:18:00.000000000 +0200
+@@ -0,0 +1,273 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++static int get_spent(char *nick, char *chan)
++{
++ struct chanset_t *ch = NULL;
++ memberlist *m = NULL;
++
++ int spent;
++ ch = findchan_by_dname(chan);
++ if (ch)
++ m = ismember(ch, nick);
++ if (m && m->joined)
++ spent = now - m->joined;
++ else
++ spent = -1;
++ return spent;
++}
++
++static int secretchan(char *chan)
++{
++ struct chanset_t *ch;
++
++ ch = findchan_by_dname(chan);
++ if (!ch)
++ return 0;
++ if (ch->status & CHAN_SECRET)
++ return 1;
++ return 0;
++}
++
++static int nolog(char *chan)
++{
++ char buf[121], *b;
++
++ Context;
++ strncpy(buf, no_log, 120);
++ buf[120] = 0;
++ b = buf;
++ while (b[0])
++ if (!strcasecmp(chan, newsplit(&b)))
++ return 1;
++#if EGG_IS_MIN_VER(10503)
++ if (ngetudef("noseendata", chan))
++ return 1;
++#endif
++ return 0;
++}
++
++static int gseen_join(char *nick, char *uhost, char *hand, char *chan)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_JOIN, nick, uhost, chan, "", now, get_spent(nick, chan));
++ report_seenreq(chan, nick);
++ if ((hand[0] == '*') && strcasecmp(nick, hand))
++ report_seenreq(chan, hand);
++ return 0;
++}
++
++static int gseen_kick(char *nick, char *uhost, char *hand, char *chan,
++ char *victim, char *reason)
++{
++ struct chanset_t *ch = NULL;
++ memberlist *m = NULL;
++ char msg[1024], *s;
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ ch = findchan_by_dname(chan);
++ if (!ch) {
++ debug2("Unable to seen %s getting kicked from %s", victim, chan);
++ return 0;
++ }
++ if (secretchan(chan))
++ chan = buf;
++ s = msg;
++ s[0] = 0;
++ m = ismember(ch, victim);
++ if (!m) {
++ debug2("Unable to seen %s getting kicked from %s", victim, chan);
++ return 0;
++ }
++ if ((strlen(nick) + strlen(reason) + 2) < 1024)
++ sprintf(s, "%s %s", nick, reason);
++ add_seen(SEEN_KICK, victim, m->userhost, chan, s, now,
++ get_spent(victim, chan));
++ return 0;
++}
++
++static int gseen_nick(char *nick, char *uhost, char *hand, char *chan,
++ char *newnick)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_NICK, nick, uhost, chan, newnick, now, get_spent(nick, chan));
++ if (!(use_handles && (hand[0] != '*')))
++ add_seen(SEEN_NCKF, newnick, uhost, chan, nick, now, get_spent(nick, chan));
++ report_seenreq(chan, newnick);
++ if ((hand[0] != '*') && strcasecmp(newnick, hand))
++ report_seenreq(chan, hand);
++ return 0;
++}
++
++#if EGG_IS_MIN_VER(10502)
++static int gseen_part(char *nick, char *uhost, char *hand, char *chan,
++ char *reason)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_PART, nick, uhost, chan, reason, now, get_spent(nick, chan));
++ return 0;
++}
++#else
++static int gseen_part(char *nick, char *uhost, char *hand, char *chan)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_PART, nick, uhost, chan, "", now, get_spent(nick, chan));
++ return 0;
++}
++#endif
++
++static int gseen_sign(char *nick, char *uhost, char *hand, char *chan,
++ char *reason)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_SIGN, nick, uhost, chan, reason, now, get_spent(nick, chan));
++ return 0;
++}
++
++static int gseen_splt(char *nick, char *uhost, char *hand, char *chan)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_SPLT, nick, uhost, chan, "", now, get_spent(nick, chan));
++ return 0;
++}
++
++static int gseen_rejn(char *nick, char *uhost, char *hand, char *chan)
++{
++ char buf[10] = "[secret]";
++
++ Context;
++ if (nolog(chan))
++ return 0;
++ if (use_handles && (hand[0] != '*'))
++ nick = hand;
++ if (secretchan(chan))
++ chan = buf;
++ add_seen(SEEN_REJN, nick, uhost, chan, "", now, get_spent(nick, chan));
++ return 0;
++}
++
++static int gseen_chjn STDVAR
++{
++ Context;
++ BADARGS(7, 7, " bot hand chan flag idx host");
++ add_seen(SEEN_CHJN, argv[2], argv[6], argv[3], argv[1], now, -1);
++ return 0;
++}
++
++static int gseen_chpt STDVAR
++{
++ Context;
++ BADARGS(5, 5, " bot hand idx chan");
++ add_seen(SEEN_CHPT, argv[2], "unknown", argv[4], argv[1], now, -1);
++ return 0;
++}
++
++static cmd_t seen_kick[] =
++{
++ {"*", "", (Function) gseen_kick, "gseen"},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_nick[] =
++{
++ {"*", "", (Function) gseen_nick, "gseen"},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_join[] =
++{
++ {"*", "", (Function) gseen_join, "gseen"},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_part[] =
++{
++ {"*", "", (Function) gseen_part, "gseen"},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_sign[] =
++{
++ {"*", "", (Function) gseen_sign, "gseen"},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_splt[] =
++{
++ {"*", "", (Function) gseen_splt, "gseen"},
++ {0, 0, 0, 0}
++};
++
++static cmd_t seen_rejn[] =
++{
++ {"*", "", (Function) gseen_rejn, "gseen"},
++ {0, 0, 0, 0}
++};
+diff -Nur src/mod/gseen.mod/slang.c src/mod/gseen.mod/slang.c
+--- src/mod/gseen.mod/slang.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang.c 2002-10-26 13:18:03.000000000 +0200
+@@ -0,0 +1,309 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++static struct slang_header *slang_find(struct slang_header *, char *);
++
++#include "slang_text.c"
++#include "slang_multitext.c"
++#include "slang_ids.c"
++#ifndef SLANG_NOTYPES
++#include "slang_types.c"
++#endif
++#include "slang_duration.c"
++#ifndef SLANG_NOFACTS
++#include "slang_facts_places.c"
++#include "slang_facts.c"
++#endif
++#include "slang_chanlang.c"
++
++
++struct slang_header {
++ struct slang_header *next;
++ char *lang;
++ char *desc;
++ struct slang_id *ids;
++#ifndef SLANG_NOTYPES
++ struct slang_type *types;
++#endif
++ struct slang_duration *durations;
++};
++
++static void slang_glob_init()
++{
++ glob_slang_cmd_list = NULL;
++}
++
++static int slang_glob_expmem()
++{
++ return slang_commands_list_expmem(glob_slang_cmd_list);
++}
++
++static void slang_glob_free()
++{
++ slang_commands_list_free(glob_slang_cmd_list);
++ glob_slang_cmd_list = NULL;
++}
++
++static struct slang_header *slang_create(struct slang_header *list, char *lang, char *desc)
++{
++ struct slang_header *nslang, *l;
++
++ Assert(lang);
++ debug2("Creating language '%s' starting by %d", lang, (int) list);
++ for (nslang = list; nslang; nslang = nslang->next)
++ if (!strcasecmp(nslang->lang, lang))
++ return list;
++ nslang = nmalloc(sizeof(struct slang_header));
++ nslang->next = NULL;
++ nslang->desc = NULL;
++ nslang->lang = nmalloc(strlen(lang) + 1);
++ strcpy(nslang->lang, lang);
++ nslang->desc = nmalloc(strlen(desc) + 1);
++ strcpy(nslang->desc, desc);
++ nslang->ids = NULL;
++#ifndef SLANG_NOTYPES
++ nslang->types = NULL;
++#endif
++ nslang->durations = NULL;
++ for (l = list; l && l->next; l = l->next);
++ if (l)
++ l->next = nslang;
++ else {
++ Assert(!list);
++ list = nslang;
++ }
++ return list;
++}
++
++static int slang_expmem(struct slang_header *what)
++{
++ int size = 0;
++
++ while (what) {
++ size += sizeof(struct slang_header);
++ size += strlen(what->lang) + 1;
++ size += strlen(what->desc) + 1;
++ size += slang_id_expmem(what->ids);
++#ifndef SLANG_NOTYPES
++ size += slang_type_expmem(what->types);
++#endif
++ size += slang_duration_expmem(what->durations);
++ what = what->next;
++ }
++ return size;
++}
++
++static void slang_free(struct slang_header *what)
++{
++ struct slang_header *next;
++
++ while (what) {
++ next = what->next;
++ slang_id_free(what->ids);
++#ifndef SLANG_NOTYPES
++ slang_type_free(what->types);
++#endif
++ slang_duration_free(what->durations);
++ nfree(what->lang);
++ nfree(what->desc);
++ nfree(what);
++ what = next;
++ }
++}
++
++static int slang_load(struct slang_header *slang, char *filename)
++{
++ FILE *f;
++ char *buffer, *s;
++ char *cmd, *sid, *strtol_ret;
++#ifndef SLANG_NOTYPES
++ char *type;
++#endif
++ int line, id;
++
++ Assert(slang);
++ putlog(LOG_MISC, "*", "Loading language \"%s\" from %s...", slang->lang, filename);
++ f = fopen(filename, "r");
++ if (!f) {
++ putlog(LOG_MISC, "*", "Couldn't open slangfile \"%s\"!", filename);
++ return 0;
++ }
++ buffer = nmalloc(2000);
++ line = 0;
++ while (!feof(f)) {
++ s = buffer;
++ if (fgets(s, 2000, f)) {
++ line++;
++ // at first, kill those stupid line feeds and carriage returns...
++ if (s[strlen(s) - 1] == '\n')
++ s[strlen(s) - 1] = 0;
++ if (s[strlen(s) - 1] == '\r')
++ s[strlen(s) - 1] = 0;
++ if (!s[0])
++ continue;
++ cmd = newsplit(&s);
++
++ if (!strcasecmp(cmd, "T")) {
++#ifndef SLANG_NOTYPES
++ type = newsplit(&s);
++ slang->types = slang_type_add(slang->types, type, s);
++#endif
++ } else if (!strcasecmp(cmd, "D")) {
++ sid = newsplit(&s);
++ id = strtol(sid, &strtol_ret, 10);
++ if (strtol_ret == sid) {
++ putlog(LOG_MISC, "*", "ERROR in slangfile \"%s\", line %d: %s is not a valid "
++ "duration index!", filename, line, sid);
++ continue;
++ }
++ slang->durations = slang_duration_add(slang->durations, id, s);
++ } else {
++ id = strtol(cmd, &strtol_ret, 10);
++ if (strtol_ret == cmd)
++ continue;
++ slang->ids = slang_id_add(slang->ids, id, s);
++ }
++ }
++ }
++ fclose(f);
++ nfree(buffer);
++ return 1;
++}
++
++static struct slang_header *slang_find(struct slang_header *where, char *language)
++{
++ struct slang_header *slang = NULL;
++
++ // at first, search for the specified language
++ for (slang = where; slang; slang = slang->next)
++ if (!strcasecmp(slang->lang, language))
++ return slang;
++ // oops... language seems to be invalid. Let's find the default.
++ Assert(default_slang);
++ for (slang = where; slang; slang = slang->next)
++ if (!strcasecmp(slang->lang, default_slang))
++ return slang;
++ // default_slang wasn't found either? *sigh*
++ // Let's return the first known language then.
++ return where;
++}
++
++#ifndef SLANG_NOVALIDATE
++/* slang_valid():
++ * check if the given language is a valid one
++ */
++static int slang_valid(struct slang_header *where, char *language)
++{
++ struct slang_header *slang = NULL;
++
++ for (slang = where; slang; slang = slang->next)
++ if (!strcasecmp(slang->lang, language))
++ return 1;
++ return 0;
++}
++#endif
++
++static char getslang_error[12];
++static char *getslang(int id)
++{
++ char *text;
++
++ if (!glob_slang) {
++ putlog(LOG_MISC, "*", "WARNING! No language selected! (getslang())");
++ return "NOLANG";
++ }
++ text = slang_id_get(glob_slang->ids, id);
++ if (!text) {
++ snprintf(getslang_error, sizeof(getslang_error), "SLANG%d", id);
++ return getslang_error;
++ }
++ return text;
++}
++
++static char *getdur(int idx)
++{
++ char *text;
++
++ Assert((idx >= 0) && (idx < DURATIONS));
++ if (!glob_slang) {
++ putlog(LOG_MISC, "*", "WARNING! No language selected! (getdur())");
++ return "NOLANG";
++ }
++ text = slang_duration_get(glob_slang->durations, idx);
++ if (!text) {
++ snprintf(getslang_error, sizeof(getslang_error), "DUR%d", idx);
++ return getslang_error;
++ }
++ return text;
++}
++
++#ifndef SLANG_NOTYPES
++static char *getslangtype(char *type)
++{
++ char *stype;
++
++ if (!glob_slang) {
++ putlog(LOG_MISC, "*", "WARNING! No language selected! (getslangtype())");
++ return "NOLANG";
++ }
++ stype = slang_type_get(glob_slang->types, type);
++ if (stype)
++ return stype;
++ else
++ return type;
++}
++
++static int slangtypetoi(char *slangtype)
++{
++ char *type;
++
++ if (!glob_slang) {
++ putlog(LOG_MISC, "*", "WARNING! No language selected! (slangtypetoi())");
++ return T_ERROR;
++ }
++ type = slang_type_slang2type(glob_slang->types, slangtype);
++ if (type) {
++ debug1("type: %s", type);
++ return typetoi(type);
++ } else
++ return typetoi(slangtype);
++}
++#endif
++
++#ifndef SLANG_NOGETALL
++static char *getslang_first(int id)
++{
++ char *text;
++
++ if (!glob_slang) {
++ putlog(LOG_MISC, "*", "WARNING! No language selected! (getslang())");
++ return "NOLANG";
++ }
++ text = slang_id_get_first(glob_slang->ids, id);
++ if (!text) {
++ snprintf(getslang_error, sizeof(getslang_error), "SLANG%d", id);
++ return getslang_error;
++ }
++ return text;
++}
++
++static char *getslang_next()
++{
++ return slang_id_get_next();
++}
++#endif
+diff -Nur src/mod/gseen.mod/slang_chanlang.c src/mod/gseen.mod/slang_chanlang.c
+--- src/mod/gseen.mod/slang_chanlang.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang_chanlang.c 2002-10-26 13:18:02.000000000 +0200
+@@ -0,0 +1,113 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++struct slang_chanlang {
++ struct slang_chanlang *next;
++ char *chan;
++ char *lang;
++};
++
++static struct slang_chanlang *chanlangs = NULL;
++
++static struct slang_chanlang *slang_chanlang_add(struct slang_chanlang *, char *, char *);
++static int slang_chanlang_expmem(struct slang_chanlang *);
++static void slang_chanlang_free(struct slang_chanlang *);
++static char *slang_chanlang_get(struct slang_chanlang *, char *);
++
++static struct slang_chanlang *slang_chanlang_add(struct slang_chanlang *where, char *chan, char *lang)
++{
++ struct slang_chanlang *item;
++
++ for (item = where; item; item = item->next)
++ if (!rfc_casecmp(item->chan, chan))
++ break;
++ if (!item) {
++ item = nmalloc(sizeof(struct slang_chanlang));
++ item->chan = nmalloc(strlen(chan) + 1);
++ strcpy(item->chan, chan);
++ item->lang = nmalloc(strlen(lang) + 1);
++ strcpy(item->lang, lang);
++ item->next = where;
++ where = item;
++ } else {
++ Assert(item->lang);
++ item->lang = nrealloc(item->lang, strlen(lang) + 1);
++ strcpy(item->lang, lang);
++ }
++ return where;
++}
++
++static int slang_chanlang_expmem(struct slang_chanlang *what)
++{
++ int size = 0;
++
++ while (what) {
++ Assert(what);
++ Assert(what->chan);
++ Assert(what->lang);
++ size += sizeof(struct slang_chanlang);
++ size += strlen(what->chan) + 1;
++ size += strlen(what->lang) + 1;
++ what = what->next;
++ }
++ return size;
++}
++
++static void slang_chanlang_free(struct slang_chanlang *what)
++{
++ struct slang_chanlang *next;
++
++ while (what) {
++ Assert(what);
++ Assert(what->chan);
++ Assert(what->lang);
++ next = what->next;
++ nfree(what->chan);
++ nfree(what->lang);
++ nfree(what);
++ what = next;
++ }
++}
++
++static char *slang_chanlang_get(struct slang_chanlang *where, char *chan)
++{
++ while (where) {
++ if (!rfc_casecmp(where->chan, chan))
++ return where->lang;
++ where = where->next;
++ }
++ return default_slang;
++}
++
++/* slang_getbynick():
++ * tries to find an appropriate language for nick by searching
++ * him on a channel and using the language of this channel.
++ */
++static struct slang_header *slang_getbynick(struct slang_header *where, char *nick)
++{
++ struct chanset_t *chan;
++
++ for (chan = chanset; chan; chan = chan->next)
++ if (ismember(chan, nick))
++#if EGG_IS_MIN_VER(10500)
++ return slang_find(where, slang_chanlang_get(chanlangs, chan->dname));
++#else
++ return slang_find(where, slang_chanlang_get(chanlangs, chan->name));
++#endif
++ return slang_find(where, default_slang);
++}
+diff -Nur src/mod/gseen.mod/slang_duration.c src/mod/gseen.mod/slang_duration.c
+--- src/mod/gseen.mod/slang_duration.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang_duration.c 2002-10-26 13:18:01.000000000 +0200
+@@ -0,0 +1,82 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++#define DURATIONS 13
++
++struct slang_duration {
++ char *durs[DURATIONS];
++};
++
++static struct slang_duration *slang_duration_add(struct slang_duration *where, int idx, char *text)
++{
++ int i;
++
++ if ((idx < 0) || (idx >= DURATIONS)) {
++ putlog(LOG_MISC, "*", "Warning: Invalid duration index \"%d\".", idx);
++ return where;
++ }
++ debug2("Adding duration[%d]: %s", idx, text);
++ if (!where) {
++ where = nmalloc(sizeof(struct slang_duration));
++ for (i = 0; i < DURATIONS; i++)
++ where->durs[i] = NULL;
++ }
++ if (where->durs[idx])
++ nfree(where->durs[idx]);
++ where->durs[idx] = nmalloc(strlen(text) + 1);
++ strcpy(where->durs[idx], text);
++ return where;
++}
++
++static int slang_duration_expmem(struct slang_duration *what)
++{
++ int i, size = 0;
++
++ if (!what)
++ return 0;
++ size += sizeof(struct slang_duration);
++ for (i = 0; i < DURATIONS; i++)
++ if (what->durs[i])
++ size += strlen(what->durs[i]) + 1;
++ return size;
++}
++
++static void slang_duration_free(struct slang_duration *what)
++{
++ int i;
++
++ if (what) {
++ for (i = 0; i < DURATIONS; i++)
++ if (what->durs[i])
++ nfree(what->durs[i]);
++ nfree(what);
++ }
++}
++
++static char *slang_duration_get(struct slang_duration *where, int idx)
++{
++ if (!where) {
++ debug0("no where");
++ return NULL;
++ }
++ if ((idx < 0) || (idx >= DURATIONS)) {
++ debug1("invalid duration index: %d", idx);
++ return NULL;
++ }
++ return where->durs[idx];
++}
+diff -Nur src/mod/gseen.mod/slang_gseen_commands.c src/mod/gseen.mod/slang_gseen_commands.c
+--- src/mod/gseen.mod/slang_gseen_commands.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang_gseen_commands.c 2002-10-26 13:18:06.000000000 +0200
+@@ -0,0 +1,235 @@
++static void slang_send_botnick()
++{
++ strncat(slang_text_buf, botname, sizeof(slang_text_buf));
++}
++
++static void slang_send_query()
++{
++ if (glob_query)
++ strncat(slang_text_buf, glob_query, sizeof(slang_text_buf));
++}
++
++static void slang_send_laston()
++{
++ if (glob_laston)
++ strncat(slang_text_buf, glob_laston, sizeof(slang_text_buf));
++}
++
++static void slang_send_otherchan()
++{
++ if (glob_otherchan)
++ strncat(slang_text_buf, glob_otherchan, sizeof(slang_text_buf));
++}
++
++static void slang_send_othernick()
++{
++ if (glob_othernick)
++ strncat(slang_text_buf, glob_othernick, sizeof(slang_text_buf));
++}
++
++static void slang_send_remotebot()
++{
++ if (glob_remotebot)
++ strncat(slang_text_buf, glob_remotebot, sizeof(slang_text_buf));
++}
++
++static void slang_send_snick()
++{
++ if (glob_seendat)
++ strncat(slang_text_buf, glob_seendat->nick, sizeof(slang_text_buf));
++}
++
++static void slang_send_shost()
++{
++ if (glob_seendat)
++ strncat(slang_text_buf, glob_seendat->host, sizeof(slang_text_buf));
++}
++
++static void slang_send_schan()
++{
++ if (glob_seendat)
++ strncat(slang_text_buf, glob_seendat->chan, sizeof(slang_text_buf));
++}
++
++static void slang_send_swhen()
++{
++ char *dur;
++
++ if (glob_seendat) {
++ dur = gseen_duration(now - glob_seendat->when);
++ strncat(slang_text_buf, dur, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_stime()
++{
++ time_t tt;
++ char t[20];
++
++ if (glob_seendat) {
++ tt = glob_seendat->when;
++ strftime(t, 19, "%d.%m. %H:%M", localtime(&tt));
++ strncat(slang_text_buf, t, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_spent()
++{
++ char *dur;
++
++ if (glob_seendat) {
++ dur = gseen_duration(glob_seendat->spent);
++ strncat(slang_text_buf, dur, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_smsg()
++{
++ if (glob_seendat)
++ strncat(slang_text_buf, glob_seendat->msg, sizeof(slang_text_buf));
++}
++
++static void slang_send_numresults()
++{
++ char buf[7];
++
++ snprintf(buf, sizeof(buf), "%d", numresults);
++ strncat(slang_text_buf, buf, sizeof(slang_text_buf));
++}
++
++static void slang_send_punisher()
++{
++ char *reason;
++ int len;
++
++ if (glob_seendat) {
++ reason = strchr(glob_seendat->msg, ' ');
++ if (!reason)
++ strncat(slang_text_buf, glob_seendat->msg, sizeof(slang_text_buf));
++ else {
++ len = (int) reason - (int) glob_seendat->msg;
++ strncat(slang_text_buf, glob_seendat->msg, (sizeof(slang_text_buf) < len) ? sizeof(slang_text_buf) : len);
++ }
++ }
++}
++
++static void slang_send_kickreason()
++{
++ char *reason;
++
++ if (glob_seendat) {
++ reason = strchr(glob_seendat->msg, ' ');
++ if (reason)
++ strncat(slang_text_buf, reason, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_rnick()
++{
++ if (glob_seenrequest) {
++ Assert(glob_seenrequest->by);
++ Assert(glob_seenrequest->by->who);
++ strncat(slang_text_buf, glob_seenrequest->by->who, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_rchan()
++{
++ if (glob_seenrequest) {
++ Assert(glob_seenrequest->by);
++ Assert(glob_seenrequest->by->chan);
++ strncat(slang_text_buf, glob_seenrequest->by->chan, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_rhost()
++{
++ if (glob_seenrequest) {
++ Assert(glob_seenrequest->by);
++ Assert(glob_seenrequest->by->host);
++ strncat(slang_text_buf, glob_seenrequest->by->host, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_rtime()
++{
++ time_t tt;
++ char t[20];
++
++ if (glob_seenrequest) {
++ Assert(glob_seenrequest->by);
++ tt = glob_seenrequest->by->when;
++ strftime(t, sizeof(t), "%d.%m. %H:%M", localtime(&tt));
++ strncat(slang_text_buf, t, sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_rwhen()
++{
++ if (glob_seenrequest) {
++ Assert(glob_seenrequest->by);
++ strncat(slang_text_buf, gseen_duration(now - glob_seenrequest->by->when), sizeof(slang_text_buf));
++ }
++}
++
++static void slang_send_requests()
++{
++ char buf[7];
++
++ snprintf(buf, sizeof(buf), "%d", glob_seenrequests);
++ strncat(slang_text_buf, buf, sizeof(slang_text_buf));
++}
++
++static void slang_send_totalnicks()
++{
++ char buf[7];
++
++ snprintf(buf, sizeof(buf), "%d", glob_totalnicks);
++ strncat(slang_text_buf, buf, sizeof(slang_text_buf));
++}
++
++static void slang_send_totalbytes()
++{
++ char buf[20];
++
++ snprintf(buf, sizeof(buf), "%d", glob_totalbytes);
++ strncat(slang_text_buf, buf, sizeof(slang_text_buf));
++}
++
++static void slang_send_nick()
++{
++ if (glob_nick)
++ strncat(slang_text_buf, glob_nick, sizeof(slang_text_buf));
++}
++
++struct slang_text_commands slang_text_gseen_command_table[] =
++{
++ {"botnick", slang_send_botnick},
++ {"query", slang_send_query},
++ {"laston", slang_send_laston},
++ {"otherchan", slang_send_otherchan},
++ {"othernick", slang_send_othernick},
++ {"remotebot", slang_send_remotebot},
++ {"snick", slang_send_snick},
++ {"swhen", slang_send_swhen},
++ {"stime", slang_send_stime},
++ {"shost", slang_send_shost},
++ {"schan", slang_send_schan},
++ {"spent", slang_send_spent},
++ {"smsg", slang_send_smsg},
++ {"numresults", slang_send_numresults},
++ {"snick2", slang_send_smsg},
++ {"bnbot", slang_send_smsg},
++ {"punisher", slang_send_punisher},
++ {"kickreason", slang_send_kickreason},
++ {"rnick", slang_send_rnick},
++ {"rchan", slang_send_rchan},
++ {"rhost", slang_send_rhost},
++ {"rtime", slang_send_rtime},
++ {"rwhen", slang_send_rwhen},
++ {"requests", slang_send_requests},
++ {"totalnicks", slang_send_totalnicks},
++ {"totalbytes", slang_send_totalbytes},
++ {"nick", slang_send_nick},
++ {0, 0}
++};
+diff -Nur src/mod/gseen.mod/slang_ids.c src/mod/gseen.mod/slang_ids.c
+--- src/mod/gseen.mod/slang_ids.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang_ids.c 2002-10-26 13:18:04.000000000 +0200
+@@ -0,0 +1,104 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++struct slang_id {
++ struct slang_id *next;
++ int id;
++ struct slang_multitext *mtext;
++};
++
++static struct slang_id* slang_id_add(struct slang_id *, int, char *);
++static int slang_id_expmem(struct slang_id *);
++static void slang_id_free(struct slang_id *);
++static char *slang_id_get(struct slang_id *, int);
++
++static struct slang_id* slang_id_add(struct slang_id *where, int id, char *text)
++{
++ struct slang_id *newitem;
++
++ newitem = NULL;
++ if (where) {
++ for (newitem = where; newitem; newitem = newitem->next)
++ if (newitem->id == id)
++ break;
++ }
++ if (!newitem) {
++ newitem = nmalloc(sizeof(struct slang_id));
++ newitem->next = NULL;
++ newitem->id = id;
++ newitem->mtext = NULL;
++ if (where)
++ newitem->next = where;
++ else
++ newitem->next = NULL;
++ where = newitem;
++ }
++ newitem->mtext = slang_mtext_add(newitem->mtext, text);
++ return where;
++}
++
++static int slang_id_expmem(struct slang_id *what)
++{
++ int size = 0;
++
++ for (; what; what = what->next) {
++ size += sizeof(struct slang_id);
++ size += slang_multitext_expmem(what->mtext);
++ }
++ return size;
++}
++
++static void slang_id_free(struct slang_id *what)
++{
++ struct slang_id *next;
++
++ while (what) {
++ next = what->next;
++ slang_multitext_free(what->mtext);
++ nfree(what);
++ what = next;
++ }
++}
++
++static char *slang_id_get(struct slang_id *where, int i)
++{
++ while (where) {
++ if (where->id == i)
++ return slang_multitext_getrandomtext(where->mtext);
++ where = where->next;
++ }
++ return NULL;
++}
++
++#ifndef SLANG_NOGETALL
++static char *slang_id_get_first(struct slang_id *where, int id)
++{
++ while (where) {
++ if (where->id == id) {
++ return slang_multitext_get_first(where->mtext);
++ }
++ where = where->next;
++ }
++ return NULL;
++}
++
++static char *slang_id_get_next()
++{
++ return slang_multitext_get_next();
++}
++#endif
+diff -Nur src/mod/gseen.mod/slang_multitext.c src/mod/gseen.mod/slang_multitext.c
+--- src/mod/gseen.mod/slang_multitext.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang_multitext.c 2002-10-26 13:18:05.000000000 +0200
+@@ -0,0 +1,151 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++struct slang_mt_content {
++ struct slang_mt_content *next;
++ struct slang_text *text;
++};
++
++struct slang_multitext {
++ int nr;
++ struct slang_mt_content *contents;
++};
++
++static struct slang_multitext *slang_mtext_add(struct slang_multitext *, char *);
++static int slang_multitext_expmem(struct slang_multitext *);
++static void slang_multitext_free(struct slang_multitext *);
++static char *slang_multitext_getrandomtext(struct slang_multitext *);
++#ifndef SLANG_NOTYPES
++static struct slang_text *slang_multitext_find(struct slang_multitext *, char *);
++#endif
++#ifndef SLANG_NOGETALL
++static char *slang_multitext_get_first(struct slang_multitext *);
++static char *slang_multitext_get_next();
++#endif
++
++static struct slang_multitext *slang_mtext_add(struct slang_multitext *where, char *text)
++{
++ struct slang_mt_content *oc, *nc;
++
++ if (!where) {
++ where = nmalloc(sizeof(struct slang_multitext));
++ where->nr = 0;
++ where->contents = NULL;
++ }
++ nc = nmalloc(sizeof(struct slang_mt_content));
++ nc->next = NULL;
++ nc->text = slang_text_parse(text);
++ for (oc = where->contents; oc && oc->next; oc = oc->next);
++ if (oc) {
++ Assert(!oc->next);
++ oc->next = nc;
++ } else
++ where->contents = nc;
++ where->nr++;
++ return where;
++}
++
++static int slang_multitext_expmem(struct slang_multitext *what)
++{
++ struct slang_mt_content *content;
++ int size = 0;
++
++ if (!what) {
++ debug0("WARNING! slang_multitext_expmem() called with NULL pointer!");
++ return 0;
++ }
++ size += sizeof(struct slang_multitext);
++ for (content = what->contents; content; content = content->next) {
++ size += sizeof(struct slang_mt_content);
++ size += slang_text_expmem(content->text);
++ }
++ return size;
++}
++
++static void slang_multitext_free(struct slang_multitext *what)
++{
++ struct slang_mt_content *content, *next;
++
++ if (!what) {
++ debug0("WARNING! slang_multitext_free() called with NULL pointer!");
++ return;
++ }
++ content = what->contents;
++ while (content) {
++ next = content->next;
++ slang_text_free(content->text);
++ nfree(content);
++ content = next;
++ }
++ nfree(what);
++}
++
++static char *slang_multitext_getrandomtext(struct slang_multitext *where)
++{
++ struct slang_mt_content *content;
++ unsigned long x;
++
++ if (!where)
++ return NULL;
++ x = random() % where->nr;
++ for (content = where->contents; content; content = content->next)
++ if (!x)
++ return slang_text_get(content->text);
++ else
++ x--;
++ // we should never reach this part
++ debug0("warning: getrandomtext didn't find anything!");
++ return NULL;
++}
++
++#ifndef SLANG_NOTYPES
++static struct slang_text *slang_multitext_find(struct slang_multitext *where, char *what)
++{
++ struct slang_mt_content *content;
++
++ Assert(where);
++ for (content = where->contents; content; content = content->next) {
++ Assert(content->text);
++ if (!slang_text_strcasecmp(content->text, what))
++ return content->text;
++ }
++ return NULL;
++}
++#endif
++
++#ifndef SLANG_NOGETALL
++static struct slang_mt_content *glob_mtext_content;
++static char *slang_multitext_get_first(struct slang_multitext *where)
++{
++ Assert(where);
++ glob_mtext_content = where->contents;
++ if (glob_mtext_content)
++ return slang_text_get(glob_mtext_content->text);
++ else
++ return NULL;
++}
++
++static char *slang_multitext_get_next()
++{
++ glob_mtext_content = glob_mtext_content->next;
++ if (glob_mtext_content)
++ return slang_text_get(glob_mtext_content->text);
++ else
++ return NULL;
++}
++#endif
+diff -Nur src/mod/gseen.mod/slang_text.c src/mod/gseen.mod/slang_text.c
+--- src/mod/gseen.mod/slang_text.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/slang_text.c 2002-10-26 13:18:07.000000000 +0200
+@@ -0,0 +1,200 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++struct slang_text {
++ struct slang_text *next;
++ char *string;
++ void (*command) ();
++};
++
++struct slang_text_commands {
++ char *command;
++ void (*targetfunc) ();
++};
++
++struct slang_command_list {
++ struct slang_command_list *next;
++ struct slang_text_commands *commands;
++};
++
++static struct slang_text *slang_text_parse(char *);
++static struct slang_text *slang_text_create(struct slang_text *);
++static void slang_text_add_string(struct slang_text *, char *);
++static void slang_text_add_command(struct slang_text *, char *);
++static void slang_text_free(struct slang_text *);
++static int slang_text_expmem(struct slang_text *);
++static char *slang_text_get(struct slang_text *);
++#ifndef SLANG_NOTYPES
++static int slang_text_strcasecmp(struct slang_text *, char *);
++#endif
++
++static struct slang_text *slang_text_parse(char *text)
++{
++ char *cmdstart, *cmdend;
++ struct slang_text *firstitem, *item;
++
++ firstitem = slang_text_create(NULL);
++ item = firstitem;
++ while ((cmdstart = strstr(text, "<?"))) {
++ cmdstart[0] = 0;
++ slang_text_add_string(item, text);
++ item = slang_text_create(item);
++ text += 2;
++ cmdstart += 2;
++ cmdend = strstr(cmdstart, "/?>");
++ if (!cmdend) {
++ putlog(LOG_MISC, "*", "ERROR parsing slang text: unterminated command \"%s\"!", cmdstart);
++ break;
++ }
++ cmdend[0] = 0;
++ slang_text_add_command(item, cmdstart);
++ item = slang_text_create(item);
++ text = cmdend + 3;
++ }
++ slang_text_add_string(item, text);
++ return firstitem;
++}
++
++static struct slang_text *slang_text_create(struct slang_text *where)
++{
++ struct slang_text *newpart;
++
++ newpart = nmalloc(sizeof(struct slang_text));
++ newpart->next = NULL;
++ newpart->string = NULL;
++ newpart->command = NULL;
++ while (where && where->next)
++ where = where->next;
++ if (where)
++ where->next = newpart;
++ return newpart;
++}
++
++static void slang_text_add_string(struct slang_text *item, char *s)
++{
++ Assert(item);
++ Assert(!item->string);
++ item->string = nmalloc(strlen(s) + 1);
++ strcpy(item->string, s);
++}
++
++static void slang_text_free(struct slang_text *item)
++{
++ if (!item)
++ return;
++ slang_text_free(item->next);
++ if (item->string)
++ nfree(item->string);
++ nfree(item);
++}
++
++static int slang_text_expmem(struct slang_text *item)
++{
++ int size = 0;
++
++ while (item) {
++ size += sizeof(struct slang_text);
++ if (item->string)
++ size += strlen(item->string) + 1;
++ item = item->next;
++ }
++ return size;
++}
++
++#ifndef SLANG_NOTYPES
++static int slang_text_strcasecmp(struct slang_text *item, char *text)
++{
++ Assert(item);
++ debug2("s_t_sc: '%s', '%s'", text, item->string);
++ if (item->command || item->next)
++ return 1;
++ return strcasecmp(item->string, text);
++}
++#endif
++
++static char slang_text_buf[500];
++static char *slang_text_get(struct slang_text *item)
++{
++ slang_text_buf[0] = 0;
++ while (item) {
++ if (item->string)
++ strncat(slang_text_buf, item->string, sizeof(slang_text_buf));
++ else if (item->command)
++ item->command();
++ item = item->next;
++ }
++ return slang_text_buf;
++}
++
++/*****************************************************/
++
++
++static struct slang_command_list *glob_slang_cmd_list;
++
++static struct slang_command_list *slang_commands_list_add(struct slang_command_list *where, struct slang_text_commands *what)
++{
++ struct slang_command_list *newcommandlist;
++
++ newcommandlist = nmalloc(sizeof(struct slang_command_list));
++ newcommandlist->commands = what;
++ newcommandlist->next = where;
++ return newcommandlist;
++}
++
++static int slang_commands_list_expmem(struct slang_command_list *what)
++{
++ int size = 0;
++
++ while (what) {
++ size += sizeof(struct slang_command_list);
++ what = what->next;
++ }
++ return size;
++}
++
++static void slang_commands_list_free(struct slang_command_list *what)
++{
++ struct slang_command_list *next;
++
++ while (what) {
++ next = what->next;
++ nfree(what);
++ what = next;
++ }
++}
++
++static void slang_text_add_command(struct slang_text *item, char *s)
++{
++ struct slang_command_list *cmdlist;
++ char *cmd;
++ int i;
++
++ cmd = newsplit(&s);
++ i = 0;
++ for (cmdlist = glob_slang_cmd_list; cmdlist; cmdlist = cmdlist->next) {
++ for (i = 0; 1; i++) {
++ if (!cmdlist->commands[i].command)
++ break;
++ if (!strcasecmp(cmdlist->commands[i].command, cmd)) {
++ item->command = cmdlist->commands[i].targetfunc;
++ return;
++ }
++ }
++ }
++ putlog(LOG_MISC, "*", "ERROR! Unknown slang-command: '%s'", cmd);
++}
+diff -Nur src/mod/gseen.mod/tclcmds.c src/mod/gseen.mod/tclcmds.c
+--- src/mod/gseen.mod/tclcmds.c 1970-01-01 01:00:00.000000000 +0100
++++ src/mod/gseen.mod/tclcmds.c 2002-10-26 13:18:08.000000000 +0200
+@@ -0,0 +1,53 @@
++/*
++ * Copyright (C) 2000,2001 Florian Sander
++ *
++ * 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.
++ */
++
++static int tcl_setchanseenlang STDVAR
++{
++ Context;
++ BADARGS(3, 3, " channel language");
++ chanlangs = slang_chanlang_add(chanlangs, argv[1], argv[2]);
++ return TCL_OK;
++}
++
++static int tcl_loadseenslang STDVAR
++{
++// int ret = 0;
++ char *shortname, *longname, *filename;
++ struct slang_header *slang;
++
++ Context;
++ BADARGS(4, 4, " language description langfile");
++ shortname = argv[1];
++ longname = argv[2];
++ filename = argv[3];
++ coreslangs = slang_create(coreslangs, shortname, longname);
++ slang = slang_find(coreslangs, shortname);
++ Assert(slang);
++ if (!slang_load(slang, filename)) {
++ Tcl_AppendResult(irp, "Couldn't open seenslang file!!!", NULL);
++ return TCL_ERROR;
++ }
++ return TCL_OK;
++}
++
++static tcl_cmds gseentcls[] =
++{
++ {"loadseenslang", tcl_loadseenslang},
++ {"setchanseenlang", tcl_setchanseenlang},
++ {0, 0}
++};
diff --git a/main/eggdrop/logs2html.mod.patch b/main/eggdrop/logs2html.mod.patch
new file mode 100644
index 00000000000..8ea2e94e629
--- /dev/null
+++ b/main/eggdrop/logs2html.mod.patch
@@ -0,0 +1,2404 @@
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/Makefile eggdrop1.6.19/src/mod/logs2html.mod/Makefile
+--- src/mod/logs2html.mod/Makefile 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/Makefile 2009-03-28 01:32:21.000000000 +0000
+@@ -0,0 +1,42 @@
++# Makefile for src/mod/logs2html.mod/
++
++srcdir = .
++
++
++doofus:
++ @echo ""
++ @echo "Let's try this from the right directory..."
++ @echo ""
++ @cd ../../../ && make
++
++static: ../logs2html.o
++
++modules: ../../../logs2html.$(MOD_EXT)
++
++../logs2html.o:
++ $(CC) $(CFLAGS) $(CPPFLAGS) -DMAKING_MODS -c $(srcdir)/logs2html.c
++ @rm -f ../logs2html.o
++ mv logs2html.o ../
++
++../../../logs2html.$(MOD_EXT): ../logs2html.o
++ $(LD) -o ../../../logs2html.$(MOD_EXT) ../logs2html.o
++ $(STRIP) ../../../logs2html.$(MOD_EXT)
++
++depend:
++ $(CC) $(CFLAGS) $(CPPFLAGS) -MM $(srcdir)/logs2html.c > .depend
++
++clean:
++ @rm -f .depend *.o *.$(MOD_EXT) *~
++distclean: clean
++
++#safety hash
++../logs2html.o: .././logs2html.mod/logs2html.c \
++ ../../../src/mod/module.h ../../../src/main.h ../../../src/lang.h \
++ ../../../src/eggdrop.h ../../../src/flags.h ../../../src/proto.h \
++ ../../../lush.h ../../../src/misc_file.h ../../../src/cmdt.h \
++ ../../../src/tclegg.h ../../../src/tclhash.h ../../../src/chan.h \
++ ../../../src/users.h ../../../src/compat/compat.h \
++ ../../../src/compat/inet_aton.h \
++ ../../../src/compat/snprintf.h ../../../src/compat/memset.h \
++ ../../../src/compat/memcpy.h ../../../src/compat/strcasecmp.h \
++ ../../../src/compat/strftime.h ../../../src/mod/modvals.h
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/chan.list eggdrop1.6.19/src/mod/logs2html.mod/chan.list
+--- src/mod/logs2html.mod/chan.list 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/chan.list 2009-03-28 01:43:40.000000000 +0000
+@@ -0,0 +1,22 @@
++# Add your channels here. The format is:
++# addlogs2htmlchan channel output-path main-page-name main-page-title logs-page-prefix logs-page-title
++# channel - your channel which logs you want to convert
++# output-path - your ftp path, where converted files will be put
++# (don't forget to check settings to be sure bot have
++# permision write to the path you specify)
++# main-page-name - name of your mainpage (i.e. page with calendar) for
++# this channel
++# main-page-title - your mainpage title for this channel (will be shown
++# as the caption of the web page in your browser and as
++# the title of calendar)
++# logs-page-prefix - your logs page name (prefix) for this channel.
++# Resulting name'll be 'logs-page-prefixYYmmdd'
++# logs-page-title - your logs page title for this channel (will be shown
++# as the caption of the web page in your browser)
++# Example:
++# addlogs2htmlchan "#MyChan" "logs" "index" "Logs of MyChan" "mychan" "Log of MyChan"
++#
++# Note: expression "logs2html" MUST be one line (i.e. without linefeeds
++# and carrige returns) and every parameter in the expression MUST be enclosed
++# with ".
++
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/fileoperations.c eggdrop1.6.19/src/mod/logs2html.mod/fileoperations.c
+--- src/mod/logs2html.mod/fileoperations.c 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/fileoperations.c 2009-03-28 01:45:19.000000000 +0000
+@@ -0,0 +1,142 @@
++/*
++ * fileoperations.c -- part of logs2html.mod
++ *
++ * Written by Fedotov Alexander aka Gray_Angel aka Shmupsik <shurikvz@mail.ru>
++ *
++ * 2004-2005 year
++ */
++/*
++ * 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 <stdarg.h>
++
++/****************************************************************************/
++/*
++ * function FILE *openfile(char *newfilename, const char *mode, bool silent)
++ *
++ * Input:
++ * newfilename - èìÿ ôàéëà, êîòîðûé íåîáõîäèìî ñîçäàòü
++ * mode - ðåæèì îòêðûòèÿ ôàéëà
++ *
++ * Output:
++ * óêàçàòåëü íà ôàéë
++ *
++ * Discription:
++ * ôóíêöèÿ îñóùåñòâëÿåò ñîçäàíèå è îòêðûòèå ôàéëà â óêàçàííîì ðåæèìå
++ * è âîçâðàùàåò óêàçàòåëü íà ñîçäàííûé ôàéë
++ */
++static FILE *openfile(char *newfilename, const char *mode, bool silent) {
++ FILE *file;
++ static char *filename = NULL;
++
++ Context;
++
++ filename = (char *)nmalloc(sizeof(char) * (strlen(newfilename) + 1));
++
++ if (filename == NULL) {
++ putlog(LOG_MISC, "*", "logs2html: ERROR! Can't allocate enough space for filename.");
++ return NULL;
++ }
++
++ sprintf(filename, "%s", newfilename);
++ file = fopen(filename, mode);
++ if ((file == NULL) && (!silent)) {
++ putlog(LOG_MISC, "*", "logs2html: Warning! Can't open file \"%s\".", filename);
++ }
++
++ nfree(filename); filename = NULL;
++
++ return file;
++} /* openfile() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function void writefromexfile(FILE *dst_file, char *exfilename)
++ *
++ * Input:
++ *
++ *
++ *
++ *
++ * Output:
++ *
++ *
++ * Discription:
++ *
++ *
++ */
++static void writefromexfile(FILE *dst_file, char *exfilename) {
++ FILE *addfile;
++ char buffer[512];
++ size_t n;
++
++ if (strlen(exfilename) > 0) {
++ if ((addfile = openfile(exfilename, "r", false)) != NULL) {
++ while(!feof(addfile)) {
++ n = fread(buffer, sizeof(char), sizeof buffer, addfile);
++ fwrite(buffer, sizeof(char), n, dst_file);
++ }
++ fclose(addfile);
++ }
++ }
++
++ return;
++} /* writefromexfile() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function void str_write(FILE *file, char *fmt, ... )
++ *
++ * Input:
++ * file - ôàéë â êîòîðûé ïèøåì äàííûå
++ * fmt - ñòðîêà äëÿ çàïèñè ñî ñïåöèôèêàòîðàìè ôîðìàòà
++ * ... - äàííûå äëÿ çàïèñè â ñòðîêó
++ *
++ * Output:
++ * íè÷åãî
++ *
++ * Discription:
++ * ôóíêöèÿ îñóùåñòâëÿåò çàïèñü ïåðåäàííîé ñòðîêè â óêàçàííûé ôàéë,
++ * ïðîèçâîäÿ ñîîòâåòñòâóþùåå åå ôîðìàòèðîâàíèå
++ */
++static void str_write(FILE *file, char *fstr, ... ) {
++ va_list ap;
++ int nchars;
++ int size = 256;
++ static char *buffer = NULL;
++
++ Context;
++ buffer = (char *)nmalloc(size);
++
++ va_start(ap, fstr);
++ while (true) {
++ nchars = egg_vsnprintf(buffer, size, fstr, ap);
++ if (nchars < size) break;
++ size *= 2;
++ buffer = (char *)nrealloc(buffer, size);
++ }
++ va_end(ap);
++ fwrite(buffer, sizeof(char), strlen(buffer), file);
++ nfree(buffer); buffer = NULL;
++
++ return;
++} /* str_write() */
++/****************************************************************************/
++
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/help/logs2html.help eggdrop1.6.19/src/mod/logs2html.mod/help/logs2html.help
+--- src/mod/logs2html.mod/help/logs2html.help 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/help/logs2html.help 2009-03-28 01:32:21.000000000 +0000
+@@ -0,0 +1,22 @@
++%{help=convertalllogs}%{+n}
++### %bconvertalllogs%b
++ Reconverts all your logs.
++
++See also: makemainpage
++%{help=makemainpage}%{+n}
++### %bmakemainpage%b
++ Redraws your mainpages.
++
++See also: convertalllogs
++%{help=logs2html module}%{+n}
++### %blogs2html module%b
++ This module convert all existing log files of your eggdrop for giving
++ channels to their html representation.
++
++ The following commands are provided by the logs2html module:
++%{+n}
++ %bconvertalllogs makemainpage%b
++%{help=all}%{+n}
++### %blogs2html module%b commands
++%{+n}
++ %bconvertalllogs makemainpage%b
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/language/logs2html.english.lang eggdrop1.6.19/src/mod/logs2html.mod/language/logs2html.english.lang
+--- src/mod/logs2html.mod/language/logs2html.english.lang 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/language/logs2html.english.lang 2009-03-28 01:32:53.000000000 +0000
+@@ -0,0 +1,38 @@
++# logs2html.english.lang
++# language messages for the logs2html module
++
++# Year
++0xe000,year
++
++# Back to mainpage link
++0xe001,Main page
++
++# Up link
++0xe002,up
++
++# Backward, forward link
++0xe003,back
++0xe004,next
++
++# Month names
++0xe005,January
++0xe006,February
++0xe007,March
++0xe008,April
++0xe009,May
++0xe010,June
++0xe011,July
++0xe012,August
++0xe013,September
++0xe014,October
++0xe015,November
++0xe016,December
++
++# Days of week names
++0xe017,Su
++0xe018,Mo
++0xe019,Tu
++0xe020,Wn
++0xe021,Th
++0xe022,Fr
++0xe023,St
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/language/logs2html.french.lang eggdrop1.6.19/src/mod/logs2html.mod/language/logs2html.french.lang
+--- src/mod/logs2html.mod/language/logs2html.french.lang 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/language/logs2html.french.lang 2009-03-28 01:32:53.000000000 +0000
+@@ -0,0 +1,38 @@
++# logs2html.french.lang
++# language messages for the logs2html module
++
++# Year
++0xe000,Année
++
++# Back to mainpage link
++0xe001,Page principale
++
++# Up link
++0xe002,haut
++
++# Backward, forward link
++0xe003,Précédente
++0xe004,Suivante
++
++# Month names
++0xe005,Janvier
++0xe006,Février
++0xe007,Mars
++0xe008,Avril
++0xe009,Mai
++0xe010,Juin
++0xe011,Juillet
++0xe012,Août
++0xe013,Septembre
++0xe014,Octobre
++0xe015,Novembre
++0xe016,Décembre
++
++# Days of week names
++0xe017,Di
++0xe018,Lu
++0xe019,Ma
++0xe020,Me
++0xe021,Je
++0xe022,Ve
++0xe023,Sa
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/language/logs2html.russian.lang eggdrop1.6.19/src/mod/logs2html.mod/language/logs2html.russian.lang
+--- src/mod/logs2html.mod/language/logs2html.russian.lang 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/language/logs2html.russian.lang 2009-03-28 01:32:21.000000000 +0000
+@@ -0,0 +1,38 @@
++# logs2html.ru.lang
++# language messages for the logs2html module
++
++# Year
++0xe000,ãîä
++
++# Back to mainpage link
++0xe001,Íà ãëàâíóþ ñòðàíèöó
++
++# Up link
++0xe002,íàâåðõ
++
++# Backward, forward link
++0xe003,ïðåäûäóùàÿ
++0xe004,ñëåäóþùàÿ
++
++# Month names
++0xe005,ßíâàðü
++0xe006,Ôåâðàëü
++0xe007,Ìàðò
++0xe008,Àïðåëü
++0xe009,Ìàé
++0xe010,Èþíü
++0xe011,Èþëü
++0xe012,Àâãóñò
++0xe013,Ñåíòÿáðü
++0xe014,Îêòÿáðü
++0xe015,Íîÿáðü
++0xe016,Äåêàáðü
++
++# Days of week names
++0xe017,Âñ
++0xe018,Ïí
++0xe019,Âò
++0xe020,Ñð
++0xe021,×ò
++0xe022,Ïò
++0xe023,Ñá
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/language.h eggdrop1.6.19/src/mod/logs2html.mod/language.h
+--- src/mod/logs2html.mod/language.h 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/language.h 2009-03-28 01:32:21.000000000 +0000
+@@ -0,0 +1,51 @@
++/*
++ * language.h -- part of logs2html.mod
++ *
++ * Written by Fedotov Alexander aka Gray_Angel aka Shmupsik <shurikvz@mail.ru>
++ *
++ * 2004-2005 year
++ */
++/*
++ * 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.
++ */
++
++
++#define LOGS2HTML_YEAR get_language(0xe000)
++#define LOGS2HTML_MAINPAGE get_language(0xe001)
++#define LOGS2HTML_UP get_language(0xe002)
++#define LOGS2HTML_BACK get_language(0xe003)
++#define LOGS2HTML_NEXT get_language(0xe004)
++
++#define LOGS2HTML_JANUARY get_language(0xe005)
++#define LOGS2HTML_FEBRIARY get_language(0xe006)
++#define LOGS2HTML_MARCH get_language(0xe007)
++#define LOGS2HTML_APRIL get_language(0xe008)
++#define LOGS2HTML_MAY get_language(0xe009)
++#define LOGS2HTML_JUNE get_language(0xe010)
++#define LOGS2HTML_JULY get_language(0xe011)
++#define LOGS2HTML_AUGUST get_language(0xe012)
++#define LOGS2HTML_SEPTEMBER get_language(0xe013)
++#define LOGS2HTML_OCTOBER get_language(0xe014)
++#define LOGS2HTML_NOVEMBER get_language(0xe015)
++#define LOGS2HTML_DECEMBER get_language(0xe016)
++
++#define LOGS2HTML_SUNDAY get_language(0xe017)
++#define LOGS2HTML_MONDAY get_language(0xe018)
++#define LOGS2HTML_TUESDAY get_language(0xe019)
++#define LOGS2HTML_WEDNESDAY get_language(0xe020)
++#define LOGS2HTML_THURSDAY get_language(0xe021)
++#define LOGS2HTML_FRIDAY get_language(0xe022)
++#define LOGS2HTML_SATURDAY get_language(0xe023)
++
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/logs2html.c eggdrop1.6.19/src/mod/logs2html.mod/logs2html.c
+--- src/mod/logs2html.mod/logs2html.c 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/logs2html.c 2009-03-28 01:32:53.000000000 +0000
+@@ -0,0 +1,1572 @@
++/*
++ * logs2html.c -- part of logs2html.mod
++ *
++ * Written by Fedotov Alexander aka Gray_Angel aka Shmupsik <shurikvz@mail.ru>
++ *
++ * 2004-2005 year
++ */
++/*
++ * 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.
++ */
++
++
++#define MODULE_NAME "logs2html"
++#define MAKING_LOGS2HTML
++#include "src/mod/module.h"
++
++#include <stdlib.h>
++#include <stdio.h>
++#include <string.h>
++#include <time.h>
++#include <ctype.h>
++#include <sys/types.h>
++#include <math.h>
++#include "logs2html.h"
++#include "language.h"
++
++#undef global
++
++#define MODULE_MAJOR 2
++#define MODULE_MINOR 3
++#define MODULE_SUBMINOR 4
++
++static Function *global = NULL;
++
++#include "fileoperations.c"
++
++
++static int shtime;
++static int keep_all_logs;
++static char logfile_suffix[21];
++static char configfile[121];
++static int lines_per_page;
++
++static int days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
++
++static int month_cols_count = 3;
++static int month_rows_count = 4;
++
++static char mainpage_top_filename[257] = "\0";
++static char mainpage_bottom_filename[257] = "\0";
++static char logspage_top_filename[257] = "\0";
++static char logspage_bottom_filename[257] = "\0";
++static char chanlist_filename[257] = "\0";
++static char userstyle_filename[257] = "\0";
++static char encoding_string[31] = "\0";
++
++static logs2htmlchan *logs2htmlchanlist = NULL;
++
++/* for language file */
++static char month_names[12][21];
++static char days_names[7][21];
++
++static void logs2html_hook_5minutely(void);
++static void logs2html_hook_daily(void);
++static void logs2html_hook_pre_rehash(void);
++static void logs2html_hook_rehash(void);
++
++
++/* Calculate the memory we keep allocated.
++ */
++static int logs2html_expmem()
++{
++ logs2htmlchan *p;
++ int size = 0;
++
++ Context;
++ p = logs2htmlchanlist;
++ while (p != NULL) {
++ size++;
++ p = p->next;
++ }
++
++ size *= sizeof(struct logs2html_data);
++
++ return size;
++}
++
++
++/****************************************************************************/
++/*
++ * function int convertalllogs(struct userrec *u, int idx, char *par)
++ *
++ * Input:
++ *
++ *
++ *
++ * Output:
++ *
++ *
++ * Discription:
++ *
++ */
++static int cmd_convertalllogs(struct userrec *u, int idx, char *par) {
++ int add_day;
++ logs2htmlchan *p;
++ int i, j, k;
++ struct tm tblock;
++ time_t t = time(NULL);
++ struct tm *st = localtime(&t);
++
++ tblock.tm_year = st->tm_year;
++ tblock.tm_isdst = st->tm_isdst;
++ tblock.tm_hour = 0;
++ tblock.tm_min = 0;
++ tblock.tm_sec = 1;
++ /* Other fields not necessary here
++ tblock.tm_mday = st->tm_mday;
++ tblock.tm_mon = st->tm_mon;
++ tblock.tm_wday = st->tm_wday;
++ tblock.tm_yday = st->tm_yday;
++ */
++
++ putlog(LOG_CMDS, "*", "#%s# start converting all log files.", dcc[idx].nick);
++ for (i = 0; i < 12; i++) {
++ add_day = ((i == 1) && isleap(tblock.tm_year)) ? 1 : 0;
++ for (j = 0; j < ((days_in_month[i]) + add_day); j++) {
++ tblock.tm_mon = i; tblock.tm_mday = j + 1;
++
++ tblock.tm_wday = (getdayofweek(tblock.tm_year + 1900, tblock.tm_mon + 1, tblock.tm_mday) + 1) % 7;
++ tblock.tm_yday = 0;
++ for (k = 0; k < tblock.tm_mon; k++) tblock.tm_yday += days_in_month[k];
++ tblock.tm_yday += tblock.tm_mday - 1;
++
++ p = logs2htmlchanlist;
++ while (p != NULL) {
++ convertfile(&tblock, p);
++ p = p->next;
++ }
++ }
++ }
++ putlog(LOG_CMDS, "*", "#%s# converting of all log files done.", dcc[idx].nick);
++
++ return 0;
++} /* convertalllogs() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function int cmd_makemainpage(struct userrec *u, int idx, char *par)
++ *
++ * Input:
++ *
++ *
++ *
++ * Output:
++ *
++ *
++ * Discription:
++ *
++ */
++static int cmd_makemainpage(struct userrec *u, int idx, char *par) {
++ logs2htmlchan *p;
++
++ putlog(LOG_CMDS, "*", "#%s# starting making mainpages.", dcc[idx].nick);
++ p = logs2htmlchanlist;
++ while (p != NULL) {
++ dprintf(idx, "Making mainpage for channel '%s'...\n", p->channame);
++ makemainpage(p);
++ p = p->next;
++ }
++ putlog(LOG_CMDS, "*", "#%s# making of mainpages done.", dcc[idx].nick);
++
++ return 0;
++} /* convertalllogs() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function bool isvalidlink(char *link)
++ *
++ * Input:
++ * link - ñòðîêà óêàçûâàþùàÿ íà ññûëêó
++ *
++ *
++ * Output:
++ *
++ *
++ * Discription:
++ * Ôóíêöèÿ ïðîâåðÿåò ÿâëÿþòñÿ ëè ïåðåäàííûå â ñòðîêå ñèìâîëû - ñèìâîëàìè
++ * äîïóñòèìûìè â ññûëêàõ
++ */
++static patternkind whatisit(char *pattern) {
++ char alpha_common[] = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789._-";
++ char alpha_http[] = "=?&/:%";
++ char *p;
++
++ if (strstr(pattern, "..") != NULL) {
++ return ITS_NOTHING;
++ }
++
++ p = strchr(pattern, '@');
++ if (p) {
++ /* it's can't be www link */
++
++ /* well, i can't imagine e-mail shorter than i@m.ru */
++ /* let's check it */
++ *p = '\0';
++ if (strlen(pattern) < 1) {
++ *p = '@';
++ return ITS_NOTHING;
++ }
++ while (*pattern) {
++ if (strchr(alpha_common, *pattern) == NULL) {
++ *p = '@';
++ return ITS_NOTHING;
++ }
++ pattern++;
++ }
++ *p = '@';
++ p++;
++ if (strlen(p) < 4) {
++ return ITS_NOTHING;
++ }
++ while (*p) {
++ if (strchr(alpha_common, *p) == NULL) return ITS_NOTHING;
++ p++;
++ }
++
++ return ITS_EMAIL;
++ } else {
++ if ((strncmp(pattern, "http://", 7) != 0) && (strncmp(pattern, "ftp://", 6) != 0)) {
++ if (strncmp(pattern, "www.", 4) != 0) {
++ return ITS_NOTHING;
++ } else {
++ while (*pattern) {
++ if ((strchr(alpha_common, *pattern) == NULL) && (strchr(alpha_http, *pattern) == NULL)) return ITS_NOTHING;
++ pattern++;
++ }
++
++ return ITS_TRUNKLINK;
++ }
++ }
++
++ while (*pattern) {
++ if ((strchr(alpha_common, *pattern) == NULL) && (strchr(alpha_http, *pattern) == NULL)) return ITS_NOTHING;
++ pattern++;
++ }
++
++ return ITS_LINK;
++ }
++
++ return ITS_NOTHING;
++} /* whatisit() */
++/****************************************************************************/
++
++
++/* A report on the module status.
++ *
++ * details is either 0 or 1:
++ * 0 - `.status'
++ * 1 - `.status all' or `.module woobie'
++ */
++static void logs2html_report(int idx, int details)
++{
++ if (details) {
++ int size = logs2html_expmem();
++
++ dprintf(idx, " Using %d byte%s of memory\n", size,
++ (size != 1) ? "s" : "");
++ }
++}
++
++static cmd_t mydcc[] = {
++ {"convertalllogs", "n", cmd_convertalllogs, NULL},
++ {"makemainpage", "n", cmd_makemainpage, NULL},
++ {NULL, NULL, NULL, NULL} /* Mark end. */
++};
++
++static tcl_strings my_tcl_strings[] = {
++ {"logfile-suffix", logfile_suffix, 20, STR_PROTECT},
++ {"config", configfile, 121, STR_PROTECT},
++ {"mainpage-top", mainpage_top_filename, 256, 0},
++ {"mainpage-bottom", mainpage_bottom_filename, 256, 0},
++ {"logspage-top", logspage_top_filename, 256, 0},
++ {"logspage-bottom", logspage_bottom_filename, 256, 0},
++ {"channels-list", chanlist_filename, 256, 0},
++ {"user-style", userstyle_filename, 256, 0},
++ {"insert-encoding-str", encoding_string, 30, 0},
++ {NULL, NULL, 0, 0} /* Mark end. */
++};
++
++static tcl_ints my_tcl_ints[] = {
++ {"col-count", &month_cols_count, 0},
++ {"lines-per-page", &lines_per_page, 0},
++ {"log-time", &shtime, 1},
++ {"keep-all-logs", &keep_all_logs, 1},
++ {NULL, NULL, 0} /* Mark end. */
++};
++
++static char *logs2html_close()
++{
++ logs2htmlchan *p, *q;
++
++ Context;
++ q = p = logs2htmlchanlist;
++ while (q != NULL) {
++ q = p->next;
++ nfree(p);
++ p = q;
++ }
++ logs2htmlchanlist = p = q = NULL;
++
++ del_lang_section(MODULE_NAME);
++ rem_help_reference(MODULE_NAME ".help");
++
++ del_hook(HOOK_DAILY, (Function)logs2html_hook_daily);
++ del_hook(HOOK_5MINUTELY, (Function)logs2html_hook_5minutely);
++ del_hook(HOOK_PRE_REHASH, (Function)logs2html_hook_pre_rehash);
++ del_hook(HOOK_REHASH, (Function)logs2html_hook_rehash);
++
++ rem_builtins(H_dcc, mydcc);
++ rem_tcl_ints(my_tcl_ints);
++ rem_tcl_strings(my_tcl_strings);
++
++ module_undepend(MODULE_NAME);
++ return NULL;
++}
++
++EXPORT_SCOPE char *logs2html_start();
++
++static Function logs2html_table[] = {
++ (Function) logs2html_start,
++ (Function) logs2html_close,
++ (Function) logs2html_expmem,
++ (Function) logs2html_report,
++};
++
++char *logs2html_start(Function *global_funcs)
++{
++ logs2htmlchan *ptr;
++
++ global = global_funcs;
++
++ Context;
++ /* Register the module. */
++ module_register(MODULE_NAME, logs2html_table, MODULE_MAJOR, MODULE_MINOR);
++
++ if (!module_depend(MODULE_NAME, "eggdrop", 106, 15)) {
++ module_undepend(MODULE_NAME);
++ return "This module requires Eggdrop 1.6.15 or later.";
++ }
++
++ add_tcl_ints(my_tcl_ints);
++
++ if (!keep_all_logs) {
++ rem_tcl_ints(my_tcl_ints);
++ module_undepend(MODULE_NAME);
++ return "This module requires \"keep-all-logs\" set to \"1\". Please check settings in your config file.";
++ }
++ logs2htmlchanlist = NULL; if (lines_per_page < 0) lines_per_page = 0;
++
++ add_tcl_strings(my_tcl_strings);
++
++ if (addchannels()) {
++ ptr = logs2htmlchanlist;
++ while (ptr != NULL) {
++ putlog(LOG_CMDS, "*", "logs2html: added channel %s, with path to logfiles \"%s\"...\n", ptr->channame, ptr->logfilename);
++ ptr = ptr->next;
++ }
++ } else {
++ rem_tcl_strings(my_tcl_strings);
++ rem_tcl_ints(my_tcl_ints);
++ module_undepend(MODULE_NAME);
++ return "No channels added. Please check settings in your eggdrop config file to be sure there is logfiles with mode set to \"p\".";
++ }
++
++ add_builtins(H_dcc, mydcc);
++
++ add_hook(HOOK_5MINUTELY, (Function)logs2html_hook_5minutely); //Äëÿ îáíîâëåíèÿ ëîãà çà òåêóùèé äåíü
++ add_hook(HOOK_DAILY, (Function)logs2html_hook_daily); //Ïîñëåäíèå 5 ìèíóò çà ïðîøëûé äåíü
++ add_hook(HOOK_PRE_REHASH, (Function)logs2html_hook_pre_rehash);
++ add_hook(HOOK_REHASH, (Function)logs2html_hook_rehash);
++
++ add_lang_section(MODULE_NAME);
++ add_help_reference(MODULE_NAME ".help");
++
++ month_names[0][0] = month_names[1][0] = month_names[2][0] = month_names[3][0] =
++ month_names[4][0] = month_names[5][0] = month_names[6][0] = month_names[7][0] =
++ month_names[8][0] = month_names[9][0] = month_names[10][0] = month_names[11][0] =
++ days_names[0][0] = days_names[1][0] = days_names[2][0] = days_names[3][0] =
++ days_names[4][0] = days_names[5][0] = days_names[6][0] = '\0';
++
++ strncpyz(month_names[0], LOGS2HTML_JANUARY, sizeof month_names[0]);
++ strncpyz(month_names[1], LOGS2HTML_FEBRIARY, sizeof month_names[1]);
++ strncpyz(month_names[2], LOGS2HTML_MARCH, sizeof month_names[2]);
++ strncpyz(month_names[3], LOGS2HTML_APRIL, sizeof month_names[3]);
++ strncpyz(month_names[4], LOGS2HTML_MAY, sizeof month_names[4]);
++ strncpyz(month_names[5], LOGS2HTML_JUNE, sizeof month_names[5]);
++ strncpyz(month_names[6], LOGS2HTML_JULY, sizeof month_names[6]);
++ strncpyz(month_names[7], LOGS2HTML_AUGUST, sizeof month_names[7]);
++ strncpyz(month_names[8], LOGS2HTML_SEPTEMBER, sizeof month_names[8]);
++ strncpyz(month_names[9], LOGS2HTML_OCTOBER, sizeof month_names[9]);
++ strncpyz(month_names[10], LOGS2HTML_NOVEMBER, sizeof month_names[10]);
++ strncpyz(month_names[11], LOGS2HTML_DECEMBER, sizeof month_names[11]);
++ strncpyz(days_names[0], LOGS2HTML_MONDAY, sizeof days_names[0]);
++ strncpyz(days_names[1], LOGS2HTML_TUESDAY, sizeof days_names[1]);
++ strncpyz(days_names[2], LOGS2HTML_WEDNESDAY, sizeof days_names[2]);
++ strncpyz(days_names[3], LOGS2HTML_THURSDAY, sizeof days_names[3]);
++ strncpyz(days_names[4], LOGS2HTML_FRIDAY, sizeof days_names[4]);
++ strncpyz(days_names[5], LOGS2HTML_SATURDAY, sizeof days_names[5]);
++ strncpyz(days_names[6], LOGS2HTML_SUNDAY, sizeof days_names[6]);
++
++ return NULL;
++}
++
++/*
++ * Code starts here
++ */
++
++/*
++ * getdayofweek()
++ * Input:
++ * year - ãîä
++ * month - ìåñÿö
++ * day - äåíü
++ *
++ * Output:
++ * 0 - Ïîíåäåëüíèê, 1 - Âòîðíèê, 2 - Ñðåäà è.ò.ä.
++ *
++ * Description:
++ * Ôóíêöèÿ âû÷èñëÿåò íà êàêîé äåíü íåäåëè ïðèõîäèòñÿ ïåðåäàííàÿ äàòà
++ */
++static int getdayofweek(int year, int month, int day)
++{
++ long int d1, d2, d3;
++
++ long int tdays = year * 12 + month - 3;
++ month = tdays % 12;
++ year = (tdays - month) / 12;
++
++ d1 = ((146097 * (year - (year % 100)) / 100) - ((146097 * (year - (year % 100)) / 100) % 4)) / 4;
++ d2 = ((1461 * (year % 100)) - ((1461 * (year % 100)) % 4)) / 4;
++ d3 = ((153 * month + 2) - ((153 * month + 2) % 5)) / 5 + day + 1721119;
++
++ return (d1 + d2 + d3) % 7;
++} /* getdayofweek() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function static int addchannels() {
++ *
++ * Input:
++ *
++ *
++ *
++ *
++ * Output:
++ *
++ *
++ * Discription:
++ *
++ *
++ */
++static int addchannels() {
++ char buffer[512];
++ char *buf_ptr, *p;
++ logs2htmlchan *newchan, *ptr;
++ FILE *src_file;
++ int field_num;
++ int filelineread;
++ int channels_count = 0;
++
++
++ Context;
++ filelineread = 0;
++ if ((src_file = openfile(chanlist_filename, "r", true)) == NULL) return 0;
++ while (!feof(src_file)) {
++ buf_ptr = fgets(buffer, sizeof(buffer)-1, src_file);
++ if (buf_ptr == NULL) break;
++ filelineread++;
++
++ p = strrchr(buf_ptr, '\n');
++ if (p) *p = '\0';
++ p = strrchr(buf_ptr, '\r');
++ if (p) *p = '\0';
++ if (strlen(buf_ptr) == 0) continue;
++ while (isspace(*buf_ptr)) buf_ptr++;
++/* while (egg_isspace(*buf_ptr)) buf_ptr++; */
++ if (strncmp(buf_ptr, "addlogs2htmlchan", 16) == 0) p = buf_ptr += 16; else continue;
++ while (*p++) if (isspace(*p)) *p = ' ';
++/* while (*p++) if (egg_isspace(*p)) *p = ' '; */
++ if (!isspace(*buf_ptr)) continue;
++/* if (!egg_isspace(*buf_ptr)) continue; */
++ /*
++ At that point we have string of params of command "addlogs2htmlchan"
++ pointed by buf_ptr, with leading ' ';
++ */
++
++ newchan = (logs2htmlchan *)nmalloc(sizeof(logs2htmlchan) * 1);
++ if (newchan == NULL) {
++ nfree(newchan); newchan = NULL;
++ fclose(src_file);
++ putlog(LOG_MISC, "*", "Can't allocate enough space to add new channel!");
++ break;
++ }
++
++ newchan->next = NULL;
++ newchan->logfilename[0] = '\0';
++ newchan->channame[0] = '\0';
++ newchan->outputpath[0] = '\0';
++ newchan->mainpagename[0] = '\0';
++ newchan->mainpagetitle[0] = '\0';
++ newchan->logspagename[0] = '\0';
++ newchan->logspagetitle[0] = '\0';
++
++ field_num = 0;
++ while (*buf_ptr) {
++ while ((*buf_ptr) && (*buf_ptr == ' ')) buf_ptr++;
++ p = ++buf_ptr;
++ while ((*p) && (*p != '"')) p++;
++ *p = '\0';
++ switch (field_num) {
++ case 0: /* newchan->channame */
++ strncpyz(newchan->channame, buf_ptr, sizeof newchan->channame);
++ field_num = 1;
++ break;
++ case 1: /* newchan->outputpath */
++ strncpyz(newchan->outputpath, buf_ptr, sizeof newchan->outputpath);
++ field_num = 2;
++ break;
++ case 2: /* newchan->mainpagename */
++ strncpyz(newchan->mainpagename, buf_ptr, sizeof newchan->mainpagename);
++ field_num = 3;
++ break;
++ case 3: /* newchan->mainpagetitle */
++ strncpyz(newchan->mainpagetitle, buf_ptr, sizeof newchan->mainpagetitle);
++ field_num = 4;
++ break;
++ case 4: /* newchan->logspagename */
++ strncpyz(newchan->logspagename, buf_ptr, sizeof newchan->logspagename);
++ field_num = 5;
++ break;
++ case 5: /* newchan->logspagetitle */
++ strncpyz(newchan->logspagetitle, buf_ptr, sizeof newchan->logspagetitle);
++ field_num = 6;
++ break;
++ }
++ buf_ptr = ++p;
++ }
++
++
++ if (field_num != 6) {
++ nfree(newchan); newchan = NULL;
++ putlog(LOG_MISC, "*", "Error in file %s. String %d. Invalid expression \"addlogs2htmlchan\".", chanlist_filename, filelineread);
++ continue;
++ }
++
++ ptr = logs2htmlchanlist;
++ if (ptr == NULL) {
++ logs2htmlchanlist = newchan;
++ } else {
++ while (ptr->next != NULL) {
++ ptr = ptr->next;
++ }
++ ptr->next = newchan;
++ }
++ newchan = NULL;
++
++ }
++ fclose(src_file);
++
++ if ((src_file = openfile(configfile, "r", true)) == NULL) return 0;
++ while (!feof(src_file)) {
++ buf_ptr = fgets(buffer, sizeof(buffer)-1, src_file);
++ if (buf_ptr == NULL) break;
++
++ p = strrchr(buf_ptr, '\n');
++ if (p) *p = '\0';
++ p = strrchr(buf_ptr, '\r');
++ if (p) *p = '\0';
++ if (strlen(buf_ptr) == 0) continue;
++ while (isspace(*buf_ptr)) buf_ptr++;
++/* while (egg_isspace(*buf_ptr)) buf_ptr++; */
++ if (strncmp(buf_ptr, "logfile", 7) == 0) p = buf_ptr += 7; else continue;
++ while (*p++) if (isspace(*p)) *p = ' ';
++/* while (*p++) if (egg_isspace(*p)) *p = ' '; */
++ if (!isspace(*buf_ptr)) continue;
++/* if (!egg_isspace(*buf_ptr)) continue; */
++ /*
++ At that point we have string of params of command "logfile"
++ pointed by buf_ptr, with leading ' ';
++ */
++
++ p = newsplit(&buf_ptr);
++ if (logmodes(p) & LOG_PUBLIC) {
++ p = newsplit(&buf_ptr);
++ /*
++ At that point we have channel of command "logfile" pointed by p,
++ and the rest of the string (path to file), pointed by buf_ptr and enclosed with "
++ */
++ buf_ptr++; buf_ptr[strlen(buf_ptr)-1] = '\0';
++
++ ptr = logs2htmlchanlist;
++ while (ptr != NULL) {
++ if ((*p == '*') || (!rfc_casecmp(ptr->channame, p))) {
++ egg_snprintf(ptr->logfilename, sizeof ptr->logfilename, "%s", buf_ptr);
++ }
++ ptr = ptr->next;
++ }
++ }
++
++
++ }
++ fclose(src_file);
++
++
++ while (logs2htmlchanlist != NULL) {
++ if (strlen(logs2htmlchanlist->logfilename) == 0) {
++ ptr = logs2htmlchanlist;
++ logs2htmlchanlist = logs2htmlchanlist->next;
++ nfree(ptr);
++ } else {
++ ptr = logs2htmlchanlist;
++ while (ptr->next != NULL) {
++ if (strlen(ptr->next->logfilename) == 0) {
++ newchan = ptr->next;
++ ptr->next = ptr->next->next;
++ nfree(newchan);
++ } else {
++ ptr = ptr->next;
++ }
++ }
++ break;
++ }
++ }
++
++ ptr = logs2htmlchanlist;
++ while (ptr != NULL) {
++ channels_count++;
++ ptr = ptr->next;
++ }
++
++ ptr = newchan = NULL;
++
++ return channels_count;
++} /* addchannels() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function int convertfile(int year, int month, int day, bool convertifexists)
++ *
++ * Input:
++ *
++ *
++ *
++ * Output:
++ *
++ *
++ * Discription:
++ * ïåðåâîäèò ôàéëû èç òåêñòîâîãî âèäà â ôîðìàò HTML
++ */
++static void convertfile(struct tm *t, logs2htmlchan *ch) {
++ char *buf_ptr, *p, *q, *r;
++ char buffer[LOGLINELEN], data[LOGLINELEN], ct[81], stamp[33];
++ char f_color[3], bg_color[3], text_style[6];
++ int mc_openteg_count = 0, pages_count = 0;
++ int i, j, k, lines_count, tsl;
++ char src_filename[257], dst_filename[257];
++ FILE *src_file, *dst_file;
++ bool bold_isopen, underline_isopen;
++ bool noneedtoclose, skipemail, linkfound;
++ char openspace[3] = " ( ";
++ char closespace[3] = " ),";
++ char *cuted_string = NULL;
++ int cuted_string_len, old_cuted_string_len, delta_cuted_string_len;
++ int r_offset, q_offset;
++ int *original_idx = NULL;
++
++ Context;
++ /* Let first write our default CSS file */
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%sdefault.css", ch->outputpath, SEP);
++ if ((dst_file = openfile(dst_filename, "wb", false)) != NULL) {
++ str_write(dst_file, "BODY {\n");
++ str_write(dst_file, "font-family: serif;\n");
++ str_write(dst_file, "font-style: normal\n");
++ str_write(dst_file, "font-variant: normal;\n");
++ str_write(dst_file, "font-weight: normal;\n");
++ str_write(dst_file, "font-stretch: normal;\n");
++ str_write(dst_file, "font-size: 12pt;\n");
++ str_write(dst_file, "text-align: left;\n");
++ str_write(dst_file, "color: rgb(0,0,0);\n");
++ str_write(dst_file, "background-color: transparent;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "BODY.mainpage {\n");
++ str_write(dst_file, "background-color: whitesmoke;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "BODY.logspage {\n");
++ str_write(dst_file, "background-color: lightyellow;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "TD {\n");
++ str_write(dst_file, "width: %d%%;\n", (int)floor(100.0/((double)month_cols_count * 8)));
++ str_write(dst_file, "background-color: lavender;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "TD.space {\n");
++ str_write(dst_file, "width: auto;\n");
++ str_write(dst_file, "background-color: whitesmoke;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "TD.dayname {\n");
++ str_write(dst_file, "width: auto;\n");
++ str_write(dst_file, "font-weight: bold;\n");
++ str_write(dst_file, "text-align: right;\n");
++ str_write(dst_file, "background-color: lightskyblue;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "TD.weekend {\n");
++ str_write(dst_file, "width: auto;\n");
++ str_write(dst_file, "font-weight: bold;\n");
++ str_write(dst_file, "text-align: right;\n");
++ str_write(dst_file, "color: red;\n");
++ str_write(dst_file, "background-color: lightskyblue;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "TH {\n");
++ str_write(dst_file, "font-weight: bold;\n");
++ str_write(dst_file, "text-align: center;\n");
++ str_write(dst_file, "background-color: lavender;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "SPAN.time {\n");
++ str_write(dst_file, "color: silver;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "SPAN.nick {\n");
++ str_write(dst_file, "color: mediumblue;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "SPAN.else {\n");
++ str_write(dst_file, "color: green;\n");
++ str_write(dst_file, "font-style: italic;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "SPAN.action {\n");
++ str_write(dst_file, "color: violet;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "#footer {\n");
++ str_write(dst_file, " font-size: 10px;\n");
++ str_write(dst_file, " text-align: center;\n");
++ str_write(dst_file, " border-top-width: 1px;\n");
++ str_write(dst_file, " border-top-style: solid;\n");
++ str_write(dst_file, " border-color: #CCCCCC;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "h1 {\n");
++ str_write(dst_file, " text-align: center;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "#calendar {\n");
++ str_write(dst_file, " margin-right: auto;\n");
++ str_write(dst_file, " margin-left: auto;\n");
++ str_write(dst_file, " width: 90%;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "#navtop {\n");
++ str_write(dst_file, " text-align: center;\n");
++ str_write(dst_file, " margin-top: 10px;\n");
++ str_write(dst_file, " margin-bottom: 10px;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "#navbottom {\n");
++ str_write(dst_file, " text-align: center;\n");
++ str_write(dst_file, " margin-top: 10px;\n");
++ str_write(dst_file, " margin-bottom: 5px;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "#totop {\n");
++ str_write(dst_file, " text-align: center;\n");
++ str_write(dst_file, " margin-top: 5px;\n");
++ str_write(dst_file, " margin-bottom: 10px;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "#log {\n");
++ str_write(dst_file, " margin-top: 10px;\n");
++ str_write(dst_file, " margin-bottom: 10px;\n");
++ str_write(dst_file, " padding-top: 10px;\n");
++ str_write(dst_file, " padding-bottom: 10px;\n");
++ str_write(dst_file, " border-width: thin;\n");
++ str_write(dst_file, " border-top-style: solid;\n");
++ str_write(dst_file, " border-bottom-style: solid;\n");
++ str_write(dst_file, " border-color: #CCCCCC;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, ".mainpage #title {\n");
++ str_write(dst_file, " font-size: 36px;\n");
++ str_write(dst_file, " text-align: center;\n");
++ str_write(dst_file, " margin-bottom: 20px;\n");
++ str_write(dst_file, " border-width: thin;\n");
++ str_write(dst_file, " border-color: #CCCCCC;\n");
++ str_write(dst_file, " border-bottom-style: solid;\n");
++ str_write(dst_file, "}\n");
++ str_write(dst_file, "SPAN.c0000, SPAN.c0100, SPAN.c0200, SPAN.c0300, SPAN.c0400, SPAN.c0500, SPAN.c0600, SPAN.c0700, SPAN.c0800, SPAN.c0900, SPAN.c1000, SPAN.c1100, SPAN.c1200, SPAN.c1300, SPAN.c1400, SPAN.c1500 {background-color: white;}\n");
++ str_write(dst_file, "SPAN.c0001, SPAN.c0101, SPAN.c0201, SPAN.c0301, SPAN.c0401, SPAN.c0501, SPAN.c0601, SPAN.c0701, SPAN.c0801, SPAN.c0901, SPAN.c1001, SPAN.c1101, SPAN.c1201, SPAN.c1301, SPAN.c1401, SPAN.c1501 {background-color: black;}\n");
++ str_write(dst_file, "SPAN.c0002, SPAN.c0102, SPAN.c0202, SPAN.c0302, SPAN.c0402, SPAN.c0502, SPAN.c0602, SPAN.c0702, SPAN.c0802, SPAN.c0902, SPAN.c1002, SPAN.c1102, SPAN.c1202, SPAN.c1302, SPAN.c1402, SPAN.c1502 {background-color: navy;}\n");
++ str_write(dst_file, "SPAN.c0003, SPAN.c0103, SPAN.c0203, SPAN.c0303, SPAN.c0403, SPAN.c0503, SPAN.c0603, SPAN.c0703, SPAN.c0803, SPAN.c0903, SPAN.c1003, SPAN.c1103, SPAN.c1203, SPAN.c1303, SPAN.c1403, SPAN.c1503 {background-color: green;}\n");
++ str_write(dst_file, "SPAN.c0004, SPAN.c0104, SPAN.c0204, SPAN.c0304, SPAN.c0404, SPAN.c0504, SPAN.c0604, SPAN.c0704, SPAN.c0804, SPAN.c0904, SPAN.c1004, SPAN.c1104, SPAN.c1204, SPAN.c1304, SPAN.c1404, SPAN.c1504 {background-color: red;}\n");
++ str_write(dst_file, "SPAN.c0005, SPAN.c0105, SPAN.c0205, SPAN.c0305, SPAN.c0405, SPAN.c0505, SPAN.c0605, SPAN.c0705, SPAN.c0805, SPAN.c0905, SPAN.c1005, SPAN.c1105, SPAN.c1205, SPAN.c1305, SPAN.c1405, SPAN.c1505 {background-color: maroon;}\n");
++ str_write(dst_file, "SPAN.c0006, SPAN.c0106, SPAN.c0206, SPAN.c0306, SPAN.c0406, SPAN.c0506, SPAN.c0606, SPAN.c0706, SPAN.c0806, SPAN.c0906, SPAN.c1006, SPAN.c1106, SPAN.c1206, SPAN.c1306, SPAN.c1406, SPAN.c1506 {background-color: purple;}\n");
++ str_write(dst_file, "SPAN.c0007, SPAN.c0107, SPAN.c0207, SPAN.c0307, SPAN.c0407, SPAN.c0507, SPAN.c0607, SPAN.c0707, SPAN.c0807, SPAN.c0907, SPAN.c1007, SPAN.c1107, SPAN.c1207, SPAN.c1307, SPAN.c1407, SPAN.c1507 {background-color: orange;}\n");
++ str_write(dst_file, "SPAN.c0008, SPAN.c0108, SPAN.c0208, SPAN.c0308, SPAN.c0408, SPAN.c0508, SPAN.c0608, SPAN.c0708, SPAN.c0808, SPAN.c0908, SPAN.c1008, SPAN.c1108, SPAN.c1208, SPAN.c1308, SPAN.c1408, SPAN.c1508 {background-color: yellow;}\n");
++ str_write(dst_file, "SPAN.c0009, SPAN.c0109, SPAN.c0209, SPAN.c0309, SPAN.c0409, SPAN.c0509, SPAN.c0609, SPAN.c0709, SPAN.c0809, SPAN.c0909, SPAN.c1009, SPAN.c1109, SPAN.c1209, SPAN.c1309, SPAN.c1409, SPAN.c1509 {background-color: lime;}\n");
++ str_write(dst_file, "SPAN.c0010, SPAN.c0110, SPAN.c0210, SPAN.c0310, SPAN.c0410, SPAN.c0510, SPAN.c0610, SPAN.c0710, SPAN.c0810, SPAN.c0910, SPAN.c1010, SPAN.c1110, SPAN.c1210, SPAN.c1310, SPAN.c1410, SPAN.c1510 {background-color: teal;}\n");
++ str_write(dst_file, "SPAN.c0011, SPAN.c0111, SPAN.c0211, SPAN.c0311, SPAN.c0411, SPAN.c0511, SPAN.c0611, SPAN.c0711, SPAN.c0811, SPAN.c0911, SPAN.c1011, SPAN.c1111, SPAN.c1211, SPAN.c1311, SPAN.c1411, SPAN.c1511 {background-color: cyan;}\n");
++ str_write(dst_file, "SPAN.c0012, SPAN.c0112, SPAN.c0212, SPAN.c0312, SPAN.c0412, SPAN.c0512, SPAN.c0612, SPAN.c0712, SPAN.c0812, SPAN.c0912, SPAN.c1012, SPAN.c1112, SPAN.c1212, SPAN.c1312, SPAN.c1412, SPAN.c1512 {background-color: blue;}\n");
++ str_write(dst_file, "SPAN.c0013, SPAN.c0113, SPAN.c0213, SPAN.c0313, SPAN.c0413, SPAN.c0513, SPAN.c0613, SPAN.c0713, SPAN.c0813, SPAN.c0913, SPAN.c1013, SPAN.c1113, SPAN.c1213, SPAN.c1313, SPAN.c1413, SPAN.c1513 {background-color: magenta;}\n");
++ str_write(dst_file, "SPAN.c0014, SPAN.c0114, SPAN.c0214, SPAN.c0314, SPAN.c0414, SPAN.c0514, SPAN.c0614, SPAN.c0714, SPAN.c0814, SPAN.c0914, SPAN.c1014, SPAN.c1114, SPAN.c1214, SPAN.c1314, SPAN.c1414, SPAN.c1514 {background-color: silver;}\n");
++ str_write(dst_file, "SPAN.c0015, SPAN.c0115, SPAN.c0215, SPAN.c0315, SPAN.c0415, SPAN.c0515, SPAN.c0615, SPAN.c0715, SPAN.c0815, SPAN.c0915, SPAN.c1015, SPAN.c1114, SPAN.c1215, SPAN.c1315, SPAN.c1415, SPAN.c1515 {background-color: gray;}\n");
++ str_write(dst_file, "SPAN.c0000, SPAN.c0001, SPAN.c0002, SPAN.c0003, SPAN.c0004, SPAN.c0005, SPAN.c0006, SPAN.c0007, SPAN.c0008, SPAN.c0009, SPAN.c0010, SPAN.c0011, SPAN.c0012, SPAN.c0013, SPAN.c0014, SPAN.c0015 {color: white;}\n");
++ str_write(dst_file, "SPAN.c0100, SPAN.c0101, SPAN.c0102, SPAN.c0103, SPAN.c0104, SPAN.c0105, SPAN.c0106, SPAN.c0107, SPAN.c0108, SPAN.c0109, SPAN.c0110, SPAN.c0111, SPAN.c0112, SPAN.c0113, SPAN.c0114, SPAN.c0115 {color: black;}\n");
++ str_write(dst_file, "SPAN.c0200, SPAN.c0201, SPAN.c0202, SPAN.c0203, SPAN.c0204, SPAN.c0205, SPAN.c0206, SPAN.c0207, SPAN.c0208, SPAN.c0209, SPAN.c0210, SPAN.c0211, SPAN.c0212, SPAN.c0213, SPAN.c0214, SPAN.c0215 {color: navy;}\n");
++ str_write(dst_file, "SPAN.c0300, SPAN.c0301, SPAN.c0302, SPAN.c0303, SPAN.c0304, SPAN.c0305, SPAN.c0306, SPAN.c0307, SPAN.c0308, SPAN.c0309, SPAN.c0310, SPAN.c0311, SPAN.c0312, SPAN.c0313, SPAN.c0314, SPAN.c0315 {color: green;}\n");
++ str_write(dst_file, "SPAN.c0400, SPAN.c0401, SPAN.c0402, SPAN.c0403, SPAN.c0404, SPAN.c0405, SPAN.c0406, SPAN.c0407, SPAN.c0408, SPAN.c0409, SPAN.c0410, SPAN.c0411, SPAN.c0412, SPAN.c0413, SPAN.c0414, SPAN.c0415 {color: red;}\n");
++ str_write(dst_file, "SPAN.c0500, SPAN.c0501, SPAN.c0502, SPAN.c0503, SPAN.c0504, SPAN.c0505, SPAN.c0506, SPAN.c0507, SPAN.c0508, SPAN.c0509, SPAN.c0510, SPAN.c0511, SPAN.c0512, SPAN.c0513, SPAN.c0514, SPAN.c0515 {color: maroon;}\n");
++ str_write(dst_file, "SPAN.c0600, SPAN.c0601, SPAN.c0602, SPAN.c0603, SPAN.c0604, SPAN.c0605, SPAN.c0606, SPAN.c0607, SPAN.c0608, SPAN.c0609, SPAN.c0610, SPAN.c0611, SPAN.c0612, SPAN.c0613, SPAN.c0614, SPAN.c0615 {color: purple;}\n");
++ str_write(dst_file, "SPAN.c0700, SPAN.c0701, SPAN.c0702, SPAN.c0703, SPAN.c0704, SPAN.c0705, SPAN.c0706, SPAN.c0707, SPAN.c0708, SPAN.c0709, SPAN.c0710, SPAN.c0711, SPAN.c0712, SPAN.c0713, SPAN.c0714, SPAN.c0715 {color: orange;}\n");
++ str_write(dst_file, "SPAN.c0800, SPAN.c0801, SPAN.c0802, SPAN.c0803, SPAN.c0804, SPAN.c0805, SPAN.c0806, SPAN.c0807, SPAN.c0808, SPAN.c0809, SPAN.c0810, SPAN.c0811, SPAN.c0812, SPAN.c0813, SPAN.c0814, SPAN.c0815 {color: yellow;}\n");
++ str_write(dst_file, "SPAN.c0900, SPAN.c0901, SPAN.c0902, SPAN.c0903, SPAN.c0904, SPAN.c0905, SPAN.c0906, SPAN.c0907, SPAN.c0908, SPAN.c0909, SPAN.c0910, SPAN.c0911, SPAN.c0912, SPAN.c0913, SPAN.c0914, SPAN.c0915 {color: lime;}\n");
++ str_write(dst_file, "SPAN.c1000, SPAN.c1001, SPAN.c1002, SPAN.c1003, SPAN.c1004, SPAN.c1005, SPAN.c1006, SPAN.c1007, SPAN.c1008, SPAN.c1009, SPAN.c1010, SPAN.c1011, SPAN.c1012, SPAN.c1013, SPAN.c1014, SPAN.c1015 {color: teal;}\n");
++ str_write(dst_file, "SPAN.c1100, SPAN.c1101, SPAN.c1102, SPAN.c1103, SPAN.c1104, SPAN.c1105, SPAN.c1106, SPAN.c1107, SPAN.c1108, SPAN.c1109, SPAN.c1110, SPAN.c1111, SPAN.c1112, SPAN.c1113, SPAN.c1114, SPAN.c1115 {color: cyan;}\n");
++ str_write(dst_file, "SPAN.c1200, SPAN.c1201, SPAN.c1202, SPAN.c1203, SPAN.c1204, SPAN.c1205, SPAN.c1206, SPAN.c1207, SPAN.c1208, SPAN.c1209, SPAN.c1210, SPAN.c1211, SPAN.c1212, SPAN.c1213, SPAN.c1214, SPAN.c1215 {color: blue;}\n");
++ str_write(dst_file, "SPAN.c1300, SPAN.c1301, SPAN.c1302, SPAN.c1303, SPAN.c1304, SPAN.c1305, SPAN.c1306, SPAN.c1307, SPAN.c1308, SPAN.c1309, SPAN.c1310, SPAN.c1311, SPAN.c1312, SPAN.c1313, SPAN.c1314, SPAN.c1315 {color: magenta;}\n");
++ str_write(dst_file, "SPAN.c1400, SPAN.c1401, SPAN.c1402, SPAN.c1403, SPAN.c1404, SPAN.c1405, SPAN.c1406, SPAN.c1407, SPAN.c1408, SPAN.c1409, SPAN.c1410, SPAN.c1411, SPAN.c1412, SPAN.c1413, SPAN.c1414, SPAN.c1415 {color: silver;}\n");
++ str_write(dst_file, "SPAN.c1500, SPAN.c1501, SPAN.c1502, SPAN.c1503, SPAN.c1504, SPAN.c1505, SPAN.c1506, SPAN.c1507, SPAN.c1508, SPAN.c1509, SPAN.c1510, SPAN.c1511, SPAN.c1512, SPAN.c1513, SPAN.c1514, SPAN.c1515 {color: gray;}\n");
++ str_write(dst_file, "SPAN.f00 {color: white;}\n");
++ str_write(dst_file, "SPAN.f01 {color: black;}\n");
++ str_write(dst_file, "SPAN.f02 {color: navy;}\n");
++ str_write(dst_file, "SPAN.f03 {color: green;}\n");
++ str_write(dst_file, "SPAN.f04 {color: red;}\n");
++ str_write(dst_file, "SPAN.f05 {color: maroon;}\n");
++ str_write(dst_file, "SPAN.f06 {color: purple;}\n");
++ str_write(dst_file, "SPAN.f07 {color: orange;}\n");
++ str_write(dst_file, "SPAN.f08 {color: yellow;}\n");
++ str_write(dst_file, "SPAN.f09 {color: lime;}\n");
++ str_write(dst_file, "SPAN.f10 {color: teal;}\n");
++ str_write(dst_file, "SPAN.f11 {color: cyan;}\n");
++ str_write(dst_file, "SPAN.f12 {color: blue;}\n");
++ str_write(dst_file, "SPAN.f13 {color: magenta;}\n");
++ str_write(dst_file, "SPAN.f14 {color: silver;}\n");
++ str_write(dst_file, "SPAN.f15 {color: gray;}\n");
++ str_write(dst_file, "SPAN.b00 {background-color: white;}\n");
++ str_write(dst_file, "SPAN.b01 {background-color: black;}\n");
++ str_write(dst_file, "SPAN.b02 {background-color: navy;}\n");
++ str_write(dst_file, "SPAN.b03 {background-color: green;}\n");
++ str_write(dst_file, "SPAN.b04 {background-color: red;}\n");
++ str_write(dst_file, "SPAN.b05 {background-color: maroon;}\n");
++ str_write(dst_file, "SPAN.b06 {background-color: purple;}\n");
++ str_write(dst_file, "SPAN.b07 {background-color: orange;}\n");
++ str_write(dst_file, "SPAN.b08 {background-color: yellow;}\n");
++ str_write(dst_file, "SPAN.b09 {background-color: lime;}\n");
++ str_write(dst_file, "SPAN.b10 {background-color: teal;}\n");
++ str_write(dst_file, "SPAN.b11 {background-color: cyan;}\n");
++ str_write(dst_file, "SPAN.b12 {background-color: blue;}\n");
++ str_write(dst_file, "SPAN.b13 {background-color: magenta;}\n");
++ str_write(dst_file, "SPAN.b14 {background-color: silver;}\n");
++ str_write(dst_file, "SPAN.b15 {background-color: gray;}\n");
++ fclose(dst_file);
++ }
++ /* Now write user CSS file */
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%suser.css", ch->outputpath, SEP);
++ if ((dst_file = openfile(dst_filename, "wb", false)) != NULL) {
++ writefromexfile(dst_file, userstyle_filename);
++ fclose(dst_file);
++ }
++
++ if (!logfile_suffix[0])
++ egg_strftime(ct, 12, ".%d%b%Y", t);
++ else
++ egg_strftime(ct, 80, logfile_suffix, t);
++ ct[80] = '\0';
++
++ egg_snprintf(src_filename, sizeof src_filename, "%s%s", ch->logfilename, ct);
++ if ((src_file = openfile(src_filename, "r", true)) == NULL) return;
++
++ while(!feof(src_file)) {
++ lines_count = lines_per_page; pages_count++;
++
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%s%s%d%02d%02d_pg%d.html", ch->outputpath, SEP, ch->logspagename, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, pages_count);
++ if ((dst_file = openfile(dst_filename, "wb", false)) == NULL) {
++ fclose(src_file);
++ putlog(LOG_MISC, "*", "logs2html: Error occured on converting %d page of file \"%s\"!", pages_count, dst_filename);
++ return;
++ }
++
++ str_write(dst_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
++ str_write(dst_file, "<html>\n");
++ str_write(dst_file, "<head>\n");
++ if (strlen(encoding_string) > 0) {
++ str_write(dst_file, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n", encoding_string);
++ }
++ str_write(dst_file, "<meta name=\"title\" content=\"%s\">\n", ch->logspagetitle);
++ str_write(dst_file, "<meta name=\"Description\" content=\"%s\">\n", ch->logspagetitle);
++ str_write(dst_file, "<meta name=\"Generator\" content=\"logs2html module for Eggdrop v.%d.%d.%d\">\n", MODULE_MAJOR, MODULE_MINOR, MODULE_SUBMINOR);
++ str_write(dst_file, "<meta name=\"Author\" content=\"Fedotov Alexander aka Gray_Angel\">\n");
++ str_write(dst_file, "<meta name=\"Keywords\" content=\"logs, logging, channel, irc, bot, eggdrop, windrop, module, logs2html\">\n");
++ str_write(dst_file, "<meta name=\"robots\" content= \"index,all\">\n");
++ str_write(dst_file, "<link rel=stylesheet type=\"text/css\" href=\"default.css\">\n");
++ if (strlen(userstyle_filename) > 0) str_write(dst_file, "<link rel=stylesheet type=\"text/css\" href=\"user.css\">\n");
++ str_write(dst_file, "<title>%s. %d/%d/%d</title>\n", ch->logspagetitle, t->tm_mday, t->tm_mon + 1, t->tm_year + 1900);
++ str_write(dst_file, "</head>\n");
++ str_write(dst_file, "<body class=\"logspage\">\n");
++
++ writefromexfile(dst_file, logspage_top_filename);
++
++ str_write(dst_file, "<a name=\"top\"></a>\n");
++ str_write(dst_file, "<div id=\"navtop\"><a href=\"%s.html\">%s</a></div>\n", ch->mainpagename, LOGS2HTML_MAINPAGE);
++ str_write(dst_file, "<div id=\"log\">\n");
++
++ while ((lines_count > 0) || (lines_per_page == 0)) {
++ lines_count--;
++
++ buf_ptr = fgets(buffer, sizeof buffer, src_file);
++ if (buf_ptr == NULL) break;
++
++ p = strrchr(buf_ptr, '\n');
++ if (p) *p = '\0';
++ p = strrchr(buf_ptr, '\r');
++ if (p) *p = '\0';
++ if (!buf_ptr[0]) continue;
++
++ /* if timestamp exist cut time from string */
++ data[0] = '\0';
++ if (shtime) {
++ egg_strftime(stamp, sizeof(stamp) - 1, LOG_TS, t); /* Print dummy time */
++ tsl = strlen(stamp);
++ strncat(data, buf_ptr, tsl);
++ buf_ptr += (++tsl);
++ }
++ if (strncmp(buf_ptr, "--- ", 4) == 0) { /* we don't really need this string I think */
++ continue;
++ }
++ if (data && data[0]) {
++ str_write(dst_file, "<span class=\"time\">%s</span>", data);
++ }
++
++ data[0] = '\0'; noneedtoclose = false; skipemail = false;
++ if (strncmp(buf_ptr, "Action: ", 8) == 0) { /* command: /me */
++ buf_ptr += 7;
++ str_write(dst_file, "<span class=\"action\"> ***");
++ } else { /* nick */
++ p = strstr(buf_ptr, "> ");
++ if ((strncmp(buf_ptr, "<", 1) == 0) && (p != NULL)) {
++ buf_ptr++;
++ strncat(data, buf_ptr, p - buf_ptr);
++ str_write(dst_file, "<span class=\"nick\"> &lt;%s&gt;</span>", data);
++ buf_ptr += (p - buf_ptr + 1);
++ noneedtoclose = true;
++ } else {
++ str_write(dst_file, "<span class=\"else\"> ");
++ skipemail = true;
++ }
++ }
++
++ cuted_string_len = strlen(buf_ptr) + 2;
++ original_idx = (int *)nmalloc(sizeof(int) * (cuted_string_len + 1));
++ for (i = 0; i < cuted_string_len; i++) original_idx[i] = i - 1; original_idx[cuted_string_len] = -1;
++
++ cuted_string = (char *)nmalloc(cuted_string_len + 1);
++ egg_memset(cuted_string, 0, cuted_string_len + 1);
++ snprintf(cuted_string, cuted_string_len + 1, " %s ", buf_ptr);
++ q = r = cuted_string + 1;
++ /*
++ * Code copied from Eggdrop's src/dcc.c and then modified...
++ * Copyright (C) 1997 Robey Pointer
++ * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
++ */
++ while (*r) {
++ switch (*r) {
++ case 0xf:
++ case 3: /* mIRC colors? */
++ if (isdigit(r[1])) { /* Is the first char a number? */
++ r += 2; /* Skip over the ^C and the first digit */
++ if (isdigit(*r)) r++; /* Is this a double digit number? */
++ if (*r == ',') { /* Do we have a background color next? */
++ if (isdigit(r[1])) r += 2; /* Skip over the first background digit */
++ if (isdigit(*r)) r++; /* Is it a double digit? */
++ }
++ } else {
++ r++;
++ }
++ continue;
++ case 2: /* Bold text */
++ case 7:
++ case 0x16: /* Reverse video */
++ case 0x1f: /* Underlined text */
++ case 0x3c: /* < */
++ case 0x3e: /* > */
++ r++;
++ continue;
++ case 033:
++ r++;
++ if (*r == '[') {
++ r++;
++ while ((*r == ';') || isdigit(*r)) r++;
++ if (*r) r++; /* also kill the following char */
++ }
++ continue;
++ }
++ original_idx[q - cuted_string] = r - cuted_string - 1;
++ *q++ = *r++; /* Move on to the next char */
++ }
++ *q = '\0';
++ /*
++ * Ends here...
++ */
++
++ linkfound = false;
++ q = cuted_string;
++ while (*q) {
++ for (k = 0; k < MIN(sizeof openspace, sizeof closespace); k++) {
++ if (openspace[k] == *q) {
++ r = q + 1;
++ while (*r) {
++ if (closespace[k] == *r) {
++ *r = '\0';
++ p = q + 1;
++ switch (whatisit(p)) {
++ case ITS_NOTHING:
++ break;
++ case ITS_EMAIL:
++ if (!skipemail) { /* If class = "else", lets skip mail, because it ident@host */
++ egg_memset(data, 0, sizeof data);
++ sprintf(data, "<a href=\"mailto:%s\">", p);
++ linkfound = true;
++ }
++ break;
++ case ITS_LINK:
++ egg_memset(data, 0, sizeof data);
++ sprintf(data, "<a href=\"%s\">", p);
++ linkfound = true;
++ break;
++ case ITS_TRUNKLINK:
++ egg_memset(data, 0, sizeof data);
++ sprintf(data, "<a href=\"http://%s\">", p);
++ linkfound = true;
++ break;
++ }
++ *r = closespace[k];
++ if (linkfound) {
++ /* will after reallocation r & q pointers be aviable?
++ * i.e. will cuted_string begin with the same adress?
++ * to make them aviable let's count offset.
++ */
++ r_offset = r - cuted_string; q_offset = q - cuted_string;
++ old_cuted_string_len = strlen(cuted_string); delta_cuted_string_len = strlen(data) + strlen(T_LINKC);
++ cuted_string = (char *)nrealloc(cuted_string, old_cuted_string_len + delta_cuted_string_len + 1);
++ original_idx = (int *)nrealloc(original_idx, sizeof(int) * (old_cuted_string_len + delta_cuted_string_len + 1));
++ r = cuted_string + r_offset; q = cuted_string + q_offset;
++ for (i = old_cuted_string_len; i < (old_cuted_string_len + delta_cuted_string_len + 1); i++) {
++ original_idx[i] = -1; cuted_string[i] = '\0';
++ }
++ for (i = old_cuted_string_len - 1; i >= r_offset; i--) {
++ cuted_string[i + delta_cuted_string_len] = cuted_string[i];
++ original_idx[i + delta_cuted_string_len] = original_idx[i]; original_idx[i] = -1;
++ }
++ for (i = strlen(T_LINKC); i--; ) {
++ cuted_string[r_offset + delta_cuted_string_len - strlen(T_LINKC) + i] = T_LINKC[i];
++ }
++ for (i = r_offset - 1; i > q_offset; i--) {
++ cuted_string[i + delta_cuted_string_len - strlen(T_LINKC)] = cuted_string[i];
++ original_idx[i + delta_cuted_string_len - strlen(T_LINKC)] = original_idx[i]; original_idx[i] = -1;
++ }
++ for (i = 0; i < strlen(data); i++) {
++ cuted_string[q_offset + i + 1] = data[i];
++ original_idx[q_offset + i + 1] = -1;
++ }
++ }
++ if (linkfound) q = r - 1;
++ break;
++ }
++ r++;
++ }
++ }
++ if (linkfound) {
++ linkfound = false;
++ break;
++ }
++ }
++ q++;
++ }
++
++ cuted_string[strlen(cuted_string) - 1] = '\0';
++ egg_memset(data, 0, sizeof data);
++ bold_isopen = false; underline_isopen = false;
++ p = cuted_string + 1; /* Don't need first char cause it = ' ' */
++ q = buf_ptr;
++ while (*p) {
++ if ((original_idx[p - cuted_string] == -1) || (original_idx[p - cuted_string] == (q - buf_ptr))) {
++ if ((strlen(data) + 1) > (sizeof data - 1)) {
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ }
++ strncat(data, p, 1);
++ p++;
++ if (original_idx[p - cuted_string] != -1) q++;
++ } else {
++ /*
++ * Code copied from Eggdrop's src/dcc.c and then modified...
++ * Copyright (C) 1997 Robey Pointer
++ * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
++ */
++ switch (*q) {
++ case 2: /* Bold text */
++ if (bold_isopen) {
++ bold_isopen = false;
++ str_write(dst_file, "%s%s", data, T_BOLDC);
++ egg_memset(data, 0, sizeof data);
++ } else {
++ bold_isopen = true;
++ str_write(dst_file, "%s%s", data, T_BOLDO);
++ egg_memset(data, 0, sizeof data);
++ }
++ q++;
++ break;
++ case 3: /* mIRC colors? */
++ case 0xf: /* don't know, maybe broken client? but also mIRC colors */
++ egg_memset(f_color, 0, sizeof f_color); egg_memset(bg_color, 0, sizeof bg_color);
++ if (isdigit(q[1])) { /* Is the first char a number? */
++ f_color[0] = q[1];
++ if (isdigit(q[2])) {f_color[1] = q[2]; q++;}
++ q += 2;
++ if (*q == ',') {
++ if (isdigit(q[1])) { /* Is the first char a number? */
++ bg_color[0] = q[1];
++ if (isdigit(q[2])) {bg_color[1] = q[2]; q++;}
++ q += 2;
++ }
++ }
++ if (strlen(bg_color) > 0) {
++ /* If we have background color - let's close all previous "SPAN" */
++ for (mc_openteg_count++; --mc_openteg_count; ) {
++ if ((strlen(data) + strlen(T_SPANC)) > (sizeof data - 1)) {
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ }
++ strncat(data, T_SPANC, strlen(T_SPANC));
++ }
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ }
++
++ if ((strlen(f_color) > 0) && ((atoi(f_color) < 0) || (atoi(f_color) > 15))) {
++ egg_memset(f_color, 0, sizeof f_color);
++ }
++ if ((strlen(bg_color) > 0) && ((atoi(bg_color) < 0) || (atoi(bg_color) > 15))) {
++ egg_memset(bg_color, 0, sizeof bg_color);
++ }
++ if ((strlen(f_color) > 0) || (strlen(bg_color) > 0)) {
++ mc_openteg_count++;
++ text_style[0] = '\0';
++ if ((strlen(f_color) > 0) && (strlen(bg_color) > 0)) egg_snprintf(text_style, sizeof text_style, "c%02.2d%02.2d", atoi(f_color), atoi(bg_color));
++ if (strlen(bg_color) == 0) egg_snprintf(text_style, sizeof text_style, "f%02.2d", atoi(f_color));
++ if (strlen(f_color) == 0) egg_snprintf(text_style, sizeof text_style, "b%02.2d", atoi(bg_color));
++ str_write(dst_file, "%s<span class=\"%s\">", data, text_style);
++ egg_memset(data, 0, sizeof data);
++ }
++ } else {
++ /* It was "close-color" tag -> let's close all "SPAN" */
++ for (mc_openteg_count++; --mc_openteg_count; ) {
++ if ((strlen(data) + strlen(T_SPANC)) > (sizeof data - 1)) {
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ }
++ strncat(data, T_SPANC, strlen(T_SPANC));
++ }
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ q++;
++ }
++ break;
++ case 7: /* Bells */
++ q++;
++ break;
++ case 0x16: /* Reverse video */
++ q++;
++ break;
++ case 0x1f: /* Underlined text */
++ if (underline_isopen) {
++ underline_isopen = false;
++ str_write(dst_file, "%s%s", data, T_UNDERLINEC);
++ egg_memset(data, 0, sizeof data);
++ } else {
++ underline_isopen = true;
++ str_write(dst_file, "%s%s", data, T_UNDERLINEO);
++ egg_memset(data, 0, sizeof data);
++ }
++ q++;
++ break;
++ case 0x3c: /* < */
++ str_write(dst_file, "%s%s", data, T_LT);
++ egg_memset(data, 0, sizeof data);
++ q++;
++ break;
++ case 0x3e: /* > */
++ str_write(dst_file, "%s%s", data, T_GT);
++ egg_memset(data, 0, sizeof data);
++ q++;
++ break;
++ case 033:
++ q++;
++ if (*q == '[') {
++ q++;
++ while ((*q == ';') || isdigit(*q)) q++;
++ if (*q) q++; /* also kill the following char */
++ }
++ break;
++ default:
++ /* I think we should never get here, but if so... */
++ strncat(data, q, 1);
++ q++;
++ break;
++ }
++ /*
++ * Ends here...
++ */
++ }
++ }
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ if (bold_isopen) str_write(dst_file, "%s", T_BOLDC);
++ if (underline_isopen) str_write(dst_file, "%s", T_UNDERLINEC);
++ for (mc_openteg_count++; --mc_openteg_count; ) {
++ if ((strlen(data) + strlen(T_SPANC)) > (sizeof data - 1)) {
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++ }
++ strncat(data, T_SPANC, strlen(T_SPANC));
++ }
++ str_write(dst_file, "%s", data);
++ egg_memset(data, 0, sizeof data);
++
++ nfree(original_idx); original_idx = NULL;
++ nfree(cuted_string); cuted_string = NULL;
++
++ str_write(dst_file, "%s", data); data[0] = '\0';
++ str_write(dst_file, noneedtoclose ? "<br />\n":"</span><br />\n");
++ }
++ fclose(dst_file);
++ }
++ fclose(src_file);
++
++ for (i = 1; i <= pages_count; i++) {
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%s%s%d%02d%02d_pg%d.html", ch->outputpath, SEP, ch->logspagename, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, i);
++ if ((dst_file = openfile(dst_filename, "ab", false)) == NULL) {
++ putlog(LOG_MISC, "*", "logs2html: Error occured on converting %d page of file \"%s\"!", i, dst_filename);
++ return;
++ }
++ str_write(dst_file, "</div>\n");
++ if (pages_count > 1) {
++ str_write(dst_file, "<div id=\"navbottom\">");
++ if (i == 1) {
++ str_write(dst_file, LOGS2HTML_BACK);
++ } else {
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%d%02d%02d_pg%d.html", ch->logspagename, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, i-1);
++ str_write(dst_file, "<span>&larr;</span>&nbsp;<a href=\"%s\">%s</a>", dst_filename, LOGS2HTML_BACK);
++ }
++ str_write(dst_file, "&nbsp;");
++ if (i == pages_count) {
++ str_write(dst_file, LOGS2HTML_NEXT);
++ } else {
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%d%02d%02d_pg%d.html", ch->logspagename, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, i+1);
++ str_write(dst_file, "<a href=\"%s\">%s</a>&nbsp;<span>&rarr;</span>", dst_filename, LOGS2HTML_NEXT);
++ }
++ str_write(dst_file, "<br />");
++ for (j = 1; j <= pages_count; j++) {
++ egg_snprintf(dst_filename, sizeof dst_filename, "%s%d%02d%02d_pg%d.html", ch->logspagename, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, j);
++ if (j != i) {
++ str_write(dst_file, "<span> <a href=\"%s\">%d</a> </span>", dst_filename, j);
++ } else {
++ str_write(dst_file, "<b>%d</b>", j);
++ }
++ }
++ str_write(dst_file, "</div>\n");
++ }
++
++ str_write(dst_file, "<div id=\"totop\"><a href=\"#top\">%s</a></div>\n", LOGS2HTML_UP);
++
++ writefromexfile(dst_file, logspage_bottom_filename);
++
++ str_write(dst_file, "<div id=\"footer\">\nGenerated by logs2html module for eggdrop v.%d.%d.%d<br />\n", MODULE_MAJOR, MODULE_MINOR, MODULE_SUBMINOR);
++ str_write(dst_file, "Find latest version at <a href=\"http://sourceforge.net/projects/logs2html\">http://sourceforge.net/projects/logs2html</a> or <a href=\"http://shmupsik.osetia.org\">http://shmupsik.osetia.org</a>\n</div>\n");
++
++ str_write(dst_file, "</body>\n");
++ str_write(dst_file, "</html>");
++
++ fclose(dst_file);
++ }
++
++ return;
++} /* convertfile() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++/*
++ * function void makemainpage(logs2htmlchan *ch)
++ *
++ * Input:
++ * íè÷åãî
++ *
++ * Output:
++ * íè÷åãî
++ *
++ * Discription:
++ * Ãåíåðàöèÿ îñíîâíîé ñòðàíèöû (êàëåíäàðÿ)
++ * + âûçûâàåòñÿ ïðîöåäóðà äëÿ êîíâåðòèðîâàíèÿ ëîãîâ â ôîðìàò HTML
++ */
++static void makemainpage(logs2htmlchan *ch) {
++ int i, j, k, m, l;
++ int add_day;
++ FILE *file;
++ char filename[256];
++ bool endofyear;
++ struct tm tblock;
++ int delta_day = 0;
++ time_t t = time(NULL);
++ struct tm *st = localtime(&t);
++
++ tblock.tm_year = st->tm_year;
++ tblock.tm_isdst = st->tm_isdst;
++ tblock.tm_hour = 0;
++ tblock.tm_min = 0;
++ tblock.tm_sec = 1;
++ /* Other fields not necessary here
++ tblock.tm_mday = st->tm_mday;
++ tblock.tm_mon = st->tm_mon;
++ tblock.tm_wday = st->tm_wday;
++ tblock.tm_yday = st->tm_yday;
++ */
++
++ egg_snprintf(filename, sizeof filename, "%s%s%s.html", ch->outputpath, SEP, ch->mainpagename);
++ if ((file = openfile(filename, "wb", false)) == NULL) return;
++
++ str_write(file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
++ str_write(file, "<html>\n");
++ str_write(file, "<head>\n");
++ if (strlen(encoding_string) > 0) {
++ str_write(file, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n", encoding_string);
++ }
++ str_write(file, "<meta name=\"title\" content=\"%s\">\n", ch->mainpagetitle);
++ str_write(file, "<meta name=\"Description\" content=\"%s\">\n", ch->mainpagetitle);
++ str_write(file, "<meta name=\"Generator\" content=\"logs2html module for Eggdrop v.%d.%d.%d\">\n", MODULE_MAJOR, MODULE_MINOR, MODULE_SUBMINOR);
++ str_write(file, "<meta name=\"Author\" content=\"Fedotov Alexander aka Gray_Angel\">\n");
++ str_write(file, "<meta name=\"Keywords\" content=\"logs, logging, channel, irc, bot, eggdrop, windrop, module, logs2html\">\n");
++ str_write(file, "<meta name=\"robots\" content= \"index,all\">\n");
++ str_write(file, "<link rel=stylesheet type=\"text/css\" href=\"default.css\">\n");
++ if (strlen(userstyle_filename) > 0) str_write(file, "<link rel=stylesheet type=\"text/css\" href=\"user.css\">\n");
++ str_write(file, "<title>%s %d %s</title>\n", ch->mainpagetitle, tblock.tm_year + 1900, LOGS2HTML_YEAR);
++ str_write(file, "</head>\n");
++ str_write(file, "<body class=\"mainpage\">\n");
++
++ writefromexfile(file, mainpage_top_filename);
++
++ str_write(file, "<div id=\"title\">%s<br />%d %s</div>\n", ch->mainpagetitle, tblock.tm_year + 1900, LOGS2HTML_YEAR);
++ str_write(file, "<div id=\"calendar\">\n");
++
++
++ /* Âû÷èñëÿåì ñêîëüêî ðÿäîâ ïîòðåáóåòñÿ äëÿ ðàçìåùåíèÿ 12 ìåñÿöåâ ïðè çàäàííîì ÷èñëå ñòîëáöîâ */
++ month_rows_count = (int)ceil(12.0 / (double)month_cols_count);
++
++ str_write(file, "<table width=\"100%%\" cellspacing=\"2\" cellpadding=\"1\" border=\"0\">\n");
++
++ /* öèêë ïî ðÿäàì ìåñÿöåâ */
++ for(i = 0; i < month_rows_count; i++) {
++
++ /* â êàæäîì ðÿäó: 1 ñòðîêà (íàçâàíèå ìåñÿöà) + 7 ñòðîê (äíè íåäåëè) */
++ for (j = 0; j < 8; j++) {
++ str_write(file, "<tr align=center>\n");
++
++ /* öèêë ïî ñòîëáöàì ìåñÿöåâ */
++ for (k = 0; k < month_cols_count; k++) {
++ tblock.tm_mon = i * month_cols_count + k;
++ endofyear = (tblock.tm_mon > 11 ) ? true : false;
++
++ if (j == 0) {
++ str_write(file, "<td class=\"space\"></td>");
++ str_write(file, "<th colspan=7>%s</th>\n", endofyear ? "&nbsp;": month_names[tblock.tm_mon]);
++ continue;
++ }
++
++ /* Åñëè ãîä âèñîêîñíûé, òî äîáàâëÿåì ê ôåâðàëþ 1 äåíü */
++ add_day = ((tblock.tm_mon == 1) && isleap(tblock.tm_year)) ? 1 : 0;
++
++ /* Äëÿ äàííîãî ìåñÿöà äàííîãî ãîäà âû÷èñëÿåì íà êàêîé äåíü íåäåëè ïðèõîäèòñÿ 1 ÷èñëî */
++ if (!endofyear) {
++ delta_day = getdayofweek(tblock.tm_year + 1900, tblock.tm_mon + 1, 1);
++ }
++
++ /* â êàæäîì ìåñÿöå: 2 ñòîëáöà (íàçâàíèå äíåé íåäåëè) + 6 ñòîëáöîâ (íåäåëè) */
++ for (m = 0; m < 7; m++) {
++ if (endofyear) {
++ str_write(file, "<td>&nbsp;</td>\n");
++ continue;
++ }
++ if (m == 0) {
++ str_write(file, "<td class=\"space\"></td>");
++ switch (j)
++ {
++ case 1:
++ case 2:
++ case 3:
++ case 4:
++ case 5:
++ case 6:
++ str_write(file, "<td class=\"dayname\">%s</td>\n", days_names[j-1]);
++ break;
++ case 7:
++ str_write(file, "<td class=\"weekend\">%s</td>\n", days_names[j-1]);
++ break;
++ default:
++ /* Uuups.. We should never get to this point.. and if it so, that mean's something wrong...:( */
++ str_write(file, "<td>&nbsp;</td>\n");
++ }
++ continue;
++ }
++ tblock.tm_mday = (m - 1) * 7 + j - delta_day;
++ if ((tblock.tm_mday >= 1) && (tblock.tm_mday <= (days_in_month[tblock.tm_mon] + add_day))) {
++ tblock.tm_wday = (getdayofweek(tblock.tm_year + 1900, tblock.tm_mon + 1, tblock.tm_mday) + 1) % 7;
++ tblock.tm_yday = 0;
++ for (l = 0; l < tblock.tm_mon; l++) tblock.tm_yday += days_in_month[l];
++ tblock.tm_yday += tblock.tm_mday - 1;
++
++ egg_snprintf(filename, sizeof filename, "%s%s%s%d%02d%02d_pg%d.html", ch->outputpath, SEP, ch->logspagename, tblock.tm_year + 1900, tblock.tm_mon + 1, tblock.tm_mday, 1);
++ if (!file_readable(filename)) convertfile(&tblock, ch);
++ if (file_readable(filename)) {
++ /* let write withount full path */
++ egg_snprintf(filename, sizeof filename, "%s%d%02d%02d_pg%d.html", ch->logspagename, tblock.tm_year + 1900, tblock.tm_mon + 1, tblock.tm_mday, 1);
++ str_write(file, "<td><a href=\"%s\">%d</A></td>\n", filename, tblock.tm_mday);
++ } else {
++ str_write(file, "<td>%d</td>\n", tblock.tm_mday);
++ }
++ } else {
++ str_write(file, "<td>&nbsp;</td>\n");
++ }
++ }
++ }
++ str_write(file, "</tr>\n");
++ }
++ str_write(file, "<tr><td class=\"space\" colspan=%d>&nbsp;</td></tr>\n", month_cols_count * 8);
++ }
++
++ str_write(file, "</table>\n");
++ str_write(file, "</div>\n");
++
++ writefromexfile(file, mainpage_bottom_filename);
++
++ str_write(file, "<div id=\"footer\">\nGenerated by logs2html module for eggdrop v.%d.%d.%d<br />\n", MODULE_MAJOR, MODULE_MINOR, MODULE_SUBMINOR);
++ str_write(file, "Find latest version at <a href=\"http://sourceforge.net/projects/logs2html\">http://sourceforge.net/projects/logs2html</a> or <a href=\"http://shmupsik.osetia.org\">http://shmupsik.osetia.org</a>\n</div>\n");
++
++ str_write(file, "</body>\n");
++ str_write(file, "</html>");
++
++ fclose(file);
++
++ return;
++} /* makemainpage() */
++/****************************************************************************/
++
++
++/****************************************************************************/
++static void logs2html_hook_5minutely(void)
++{
++ logs2htmlchan *p;
++ struct tm tblock;
++ time_t t = time(NULL);
++ struct tm *st = localtime(&t);
++
++ tblock.tm_year = st->tm_year;
++ tblock.tm_isdst = st->tm_isdst;
++ tblock.tm_mday = st->tm_mday;
++ tblock.tm_mon = st->tm_mon;
++ tblock.tm_wday = st->tm_wday;
++ tblock.tm_yday = st->tm_yday;
++ tblock.tm_hour = 0;
++ tblock.tm_min = 0;
++ tblock.tm_sec = 1;
++
++ p = logs2htmlchanlist;
++ while (p != NULL) {
++ convertfile(&tblock, p);
++ makemainpage(p);
++ p = p->next;
++ }
++
++ return;
++}
++/****************************************************************************/
++
++/****************************************************************************/
++static void logs2html_hook_daily(void)
++{
++ logs2htmlchan *p;
++ struct tm tblock;
++ time_t t = time(NULL);
++ struct tm *st = localtime(&t);
++
++ tblock.tm_year = st->tm_year;
++ tblock.tm_isdst = st->tm_isdst;
++ tblock.tm_mday = st->tm_mday;
++ tblock.tm_mon = st->tm_mon;
++ tblock.tm_wday = st->tm_wday;
++ tblock.tm_yday = st->tm_yday;
++ tblock.tm_hour = 0;
++ tblock.tm_min = 0;
++ tblock.tm_sec = 1;
++
++ if (!--tblock.tm_mday) {
++ if (!tblock.tm_mon) {
++ /* it's 1st January; lets go one day before */
++ tblock.tm_year--;
++ tblock.tm_mon = 11;
++ tblock.tm_mday = 31;
++ tblock.tm_yday = 364 + isleap(tblock.tm_year) ? 1 : 0;
++ } else {
++ tblock.tm_mon--;
++ tblock.tm_mday = days_in_month[tblock.tm_mon] + ((tblock.tm_mon == 1) && isleap(tblock.tm_year)) ? 1 : 0;
++ tblock.tm_yday--;
++ }
++ } else {
++ tblock.tm_yday--;
++ }
++ tblock.tm_wday = (tblock.tm_wday + 6) % 7;
++
++ p = logs2htmlchanlist;
++ while (p != NULL) {
++ convertfile(&tblock, p);
++ makemainpage(p);
++ p = p->next;
++ }
++
++ return;
++}
++/****************************************************************************/
++
++
++/****************************************************************************/
++static void logs2html_hook_pre_rehash(void)
++{
++ logs2htmlchan *p, *q;
++
++ q = p = logs2htmlchanlist;
++ while (q != NULL) {
++ q = p->next;
++ nfree(p);
++ p = q;
++ }
++ logs2htmlchanlist = p = q = NULL;
++
++ return;
++}
++/****************************************************************************/
++
++/****************************************************************************/
++static void logs2html_hook_rehash(void)
++{
++ if (lines_per_page < 0) lines_per_page = 0;
++
++ return;
++}
++/****************************************************************************/
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/logs2html.conf eggdrop1.6.19/src/mod/logs2html.mod/logs2html.conf
+--- src/mod/logs2html.mod/logs2html.conf 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/logs2html.conf 2009-03-28 01:43:58.000000000 +0000
+@@ -0,0 +1,38 @@
++######
++#####
++### General Settings
++#####
++######
++
++# number of rows the month'll put out
++set col-count 3
++
++# set how many lines there'll be on one page of converted logfile. If it
++# set to 0 then all converted log will dispalay as one page.
++set lines-per-page 200
++
++# Here specify file with "addlogs2html" expressions.
++set channels-list chan.list
++
++# Uncomment line if you want specify file with your color settings for
++# generated pages
++#set user-style user.css
++
++# This setting allows you to insert meta tag
++# <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=..."> in your
++# HTML files. You can comment next line, that will mean that this tag'll not
++# be insert in the resulting page.
++set insert-encoding-str "windows-1251"
++
++# Here you can specify path to files which content will be put to converted
++# logfile (or mainpage). Uncomment the line you need and put there
++# filename with path for example: set mainpage-top "top100.tpl"
++# Note: the content of specified file puts to the resulting file "as is",
++# without any transformation
++#set mainpage-top ""
++#set mainpage-bottom ""
++#set logspage-top ""
++#set logspage-bottom ""
++
++# now load the module
++loadmodule logs2html
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/logs2html.h eggdrop1.6.19/src/mod/logs2html.mod/logs2html.h
+--- src/mod/logs2html.mod/logs2html.h 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/logs2html.h 2009-03-28 01:46:28.000000000 +0000
+@@ -0,0 +1,76 @@
++/*
++ * logs2html.h -- part of logs2html.mod
++ *
++ * Written by Fedotov Alexander aka Gray_Angel aka Shmupsik <shurikvz@mail.ru>
++ *
++ * 2004-2005 year
++ */
++/*
++ * 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 "src/lang.h"
++
++#define SEP "/"
++
++#undef false
++#undef true
++typedef enum {false = 0, true} bool;
++
++#ifdef MIN
++# undef MIN
++#endif
++#define MIN(p,q) ((p < q) ? p : q)
++
++#ifndef isleap
++ /* Nonzero if YEAR is a leap year (every 4 years,
++ except every 100th isn't, and every 400th is). */
++#define isleap(year) \
++ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
++#endif
++
++#define T_LT "&lt;"
++#define T_GT "&gt;"
++#define T_BOLDO "<B>"
++#define T_BOLDC "</B>"
++#define T_UNDERLINEO "<U>"
++#define T_UNDERLINEC "</U>"
++#define T_SPANC "</SPAN>"
++#define T_LINKC "</A>"
++
++typedef struct logs2html_data {
++ struct logs2html_data *next;
++ char channame[81]; /* Èìÿ êàíàëà äëÿ êîòîðîãî êîíâåðòèðîâàòü ëîãè */
++ char logfilename[128]; /* Èìÿ (ïðåôèêñ) äàííîãî êàíàëà (âû÷èñëÿåòñÿ èç âûðàæåíèÿ logfile â êîíôèãå áîòà) */
++ char outputpath[128]; /* Êóäà âûâîäèòü êîíâåðòèðîâàííûå ëîãè */
++ char mainpagename[61]; /* Èìÿ ãëàâíîé ñòðàíèöû */
++ char mainpagetitle[256]; /* Çàãîëîâîê íà ãëàâíîé ñòðàíèöå */
++ char logspagename[61]; /* Èìÿ (ïðåôèêñ) ñòðàíèöû ïåðåêîíâåðòèðîâàííîãî ëîãôàéëà */
++ char logspagetitle[256]; /* Çàãîëîâîê ñòðàíèöû ëîãôàéëà */
++} logs2htmlchan;
++
++typedef enum {ITS_NOTHING, ITS_EMAIL, ITS_LINK, ITS_TRUNKLINK} patternkind;
++
++static int cmd_convertalllogs(struct userrec *u, int idx, char *par);
++static int cmd_makemainpage(struct userrec *u, int idx, char *par);
++static int getdayofweek(int year, int month, int day);
++static FILE *openfile(char *newfilename, const char *mode, bool silent);
++static void str_write(FILE *file, char *fstr, ... );
++static void makemainpage(logs2htmlchan *ch);
++static void convertfile(struct tm *t, logs2htmlchan *ch);
++static void writefromexfile(FILE *dst_file, char *exfilename);
++static int addchannels(void);
++static patternkind whatisit(char *pattern);
++
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/logs2html.mod.desc eggdrop1.6.19/src/mod/logs2html.mod/logs2html.mod.desc
+--- src/mod/logs2html.mod/logs2html.mod.desc 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/logs2html.mod.desc 2009-03-28 01:46:37.000000000 +0000
+@@ -0,0 +1 @@
++This module convert all existing log files (and those, that will be created after module installation) of your eggdrop for givving channel to their html representation to be show in the web. and also the calendar page with links to that converted files.
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/modinfo eggdrop1.6.19/src/mod/logs2html.mod/modinfo
+--- src/mod/logs2html.mod/modinfo 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/modinfo 2009-03-28 01:32:21.000000000 +0000
+@@ -0,0 +1,4 @@
++DESC:This module convert all existing log files (and those, that will be
++DESC:created after module installation) of your eggdrop for givving channel
++DESC:to their html representation to be show in the web. and also the
++DESC:calendar page with links to that converted files.
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/readme.txt eggdrop1.6.19/src/mod/logs2html.mod/readme.txt
+--- src/mod/logs2html.mod/readme.txt 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/readme.txt 2009-03-28 01:44:20.000000000 +0000
+@@ -0,0 +1,85 @@
++logs2html.mod v.2.3.4 by Alexander Fedotov aka Gray_Angel aka Shmupsik #ircnet.ru
++e-mail: shurikvz@mail.ru
++
++This module convert all existing log files (and those, that will be created after module installation) of your eggdrop for giving channels to their html representation to be show in the web. and also the calendar page with links to that converted files.
++
++*******************************************************************************
++To install this module:
++ - copy the contents of "language" directory to your eggdrops "language" directory
++ - copy the contents of "help" directory to your eggdrops "help" directory
++ - copy *.dll (for windows) or *.so (for unix/linux) module to your eggdrops "modules" directory (only if you have download an arhive file with precompiled modules)
++ - copy logs2html.conf, chan.list files to your eggdrop directory
++ - if you decide to use your own style for pages copy user.css file to your eggdrop directory
++ - (Of course don't forget to edit logs2html.conf, chan.list and user.css files)
++ - put "source logs2html.conf" into your eggdrop config file and restart your bot
++
++Module has 2 commands, which you can use from dcc chat:
++ - convertalllogs - reconverts ALL your logs for current year (you'll need it for example if you decided to change style of your output logs even those which was created before your decision)
++ - makemainpage - redraws mainpages
++*******************************************************************************
++
++
++
++*******************************************************************************
++You can see the example of output on http://www.osetia.org/logs
++You can try to find latest version on http://sourceforge.net/projects/logs2html or http://shmupsik.osetia.org
++*******************************************************************************
++
++
++
++*******************************************************************************
++So, if you want to make a donation (for some strange reason I probably will never understand...) to me,
++you can do it using WebMoney (http://www.webmoney.ru).
++And here (http://webmoney.ru/wminouttrans1.shtml) a list of sites where you can exchange your money if you are not using WebMoney system.. :)
++
++My cash number: WMID:215902813411
++ U838552550724
++ E023251651728
++ R735356625383
++*******************************************************************************
++
++
++
++*******************************************************************************
++Version history:
++15.10.05 - version 2.3.4
++ - added setting in config file, which allow to change value of meta tag <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=..."> in generated HTML files.
++
++
++04.10.05 - version 2.3.3
++ - fixed bug with broken e-mail (strings with broken e-mails were truncated)
++
++
++ 24.09.05 - version 2.3.2
++ - added support for <B> and <U> tags
++ - fixed bug with [%H:%M:%S] timestamp (I hope.. :-))
++
++
++ 26.07.05 - version 2.3.1
++ - bug fixed
++
++
++ 24.07.05 - version 2.3.0
++ - page style discriptions moved to CSS file
++ - no need for tcl now
++ - small bugs fixed
++
++
++ 25.04.05 - version 2.1.0
++ - added support for http links and e-mail.
++
++
++ 27.02.05 - version 2.0
++ - converting logs for multiply channels
++ - possibility to change colors of HTML pages
++ - now you can aim number of lines on the one generated HTML page
++
++
++ 16.12.04 - version 1.0
++ - initial realise
++*******************************************************************************
++
++
++
++P.S. Sorry for my bad english
++
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/top100.tpl eggdrop1.6.19/src/mod/logs2html.mod/top100.tpl
+--- src/mod/logs2html.mod/top100.tpl 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/top100.tpl 2009-03-28 01:43:24.000000000 +0000
+@@ -0,0 +1,50 @@
++
++<p align="center">
++<!--Rating@Mail.ru COUNTER--><script language="JavaScript"><!--
++d=document;a='';a+=';r='+escape(d.referrer)
++js=10//--></script><script language="JavaScript1.1"><!--
++a+=';j='+navigator.javaEnabled()
++js=11//--></script><script language="JavaScript1.2"><!--
++s=screen;a+=';s='+s.width+'*'+s.height
++a+=';d='+(s.colorDepth?s.colorDepth:s.pixelDepth)
++js=12//--></script><script language="JavaScript1.3"><!--
++js=13//--></script><script language="JavaScript"><!--
++d.write('<img src="http://top.list.ru/counter'+'?id=606627;js='+js+a+';rand='+Math.random()+'" height=1 width=1>')
++if(js>11)d.write('<'+'!-- ')//--></script><noscript><img
++src="http://top.list.ru/counter?js=na;id=606627"
++height=1 width=1 alt=""></noscript><script language="JavaScript"><!--
++if(js>11)d.write('--'+'>')//--></script><!--/COUNTER-->
++<!-- SpyLOG f:0210 -->
++<script language="javascript"><!--
++Mu="u5131.64.spylog.com";Md=document;Mnv=navigator;Mp=1;
++Mn=(Mnv.appName.substring(0,2)=="Mi")?0:1;Mrn=Math.random();
++Mt=(new Date()).getTimezoneOffset();
++Mz="p="+Mp+"&rn="+Mrn+"&tl=0&ls=0&ln=0&t="+Mt;
++My="";
++My+="<img src='http://"+Mu+"/cnt?cid=513164&"+Mz+"&r="+escape(Md.referrer)+"&pg="+escape(window.location.href)+"'border=0 width=1 height=1 alt='SpyLOG'>";
++Md.write(My);//--></script><noscript>
++<img src="http://u5131.64.spylog.com/cnt?cid=513164&p=1" alt='SpyLOG' border='0' width=1
++height=1 >
++</noscript>
++<!-- SpyLOG -->
++<!--begin of Top100 logo-->
++<a href="http://top100.rambler.ru/top100/">
++<img src="http://top100-images.rambler.ru/top100/banner-88x31-rambler-blue.gif" alt="Rambler's Top100" width=88 height=31 border=0></a>
++<!--end of Top100 logo -->
++<script language="javascript"><!--
++Mrn=Math.random();Mz="";
++My="<a href='http://u5131.64.spylog.com/cnt?cid=513164&f=3&rn="+Mrn+"' target='_blank'><img src='http://u5131.64.spylog.com/cnt?cid=513164&";
++My+="p=1&f=4&rn="+Mrn+Mz+"' border=0 width=88 height=31 alt='SpyLOG'></a>";Md.write(My);
++//--></script><noscript>
++<a href="http://u5131.64.spylog.com/cnt?cid=513164&f=3&p=1" target="_blank">
++<img src="http://u5131.64.spylog.com/cnt?cid=513164&p=1&f=4" alt='SpyLOG' border='0' width=88 height=31 ></a>
++</noscript>
++<!--Rating@Mail.ru LOGO--><a target=_top
++href="http://top.mail.ru/jump?from=606627"><img src="http://top.list.ru/counter?id=606627;t=231;l=1"
++border=0 height=31 width=88
++alt="Ðåéòèíã@Mail.ru"></a><!--/LOGO-->
++<!--begin of Rambler's Top100 code -->
++<a href="http://top100.rambler.ru/top100/">
++<img src="http://counter.rambler.ru/top100.cnt?503447" alt="" width=1 height=1 border=0></a>
++<!--end of Top100 code-->
++</p>
+diff -urpN eggdrop1.6.19-orig/src/mod/logs2html.mod/user.css eggdrop1.6.19/src/mod/logs2html.mod/user.css
+--- src/mod/logs2html.mod/user.css 1970-01-01 00:00:00.000000000 +0000
++++ src/mod/logs2html.mod/user.css 2009-03-28 01:32:53.000000000 +0000
+@@ -0,0 +1,121 @@
++BODY {
++font-family: serif;
++font-style: normal
++font-variant: normal;
++font-weight: normal;
++font-stretch: normal;
++font-size: 12pt;
++text-align: left;
++color: rgb(0,0,0);
++background-color: transparent;
++}
++BODY.mainpage {
++background-color: whitesmoke;
++}
++BODY.logspage {
++background-color: lightyellow;
++}
++TD {
++width: 4%;
++background-color: lavender;
++}
++TD.space {
++width: auto;
++background-color: whitesmoke;
++}
++TD.dayname {
++width: auto;
++font-weight: bold;
++text-align: right;
++background-color: lightskyblue;
++}
++TD.weekend {
++color: red;
++width: auto;
++font-weight: bold;
++text-align: right;
++width: auto;
++background-color: lightskyblue;
++}
++TH {
++font-weight: bold;
++text-align: center;
++background-color: lavender;
++}
++SPAN.time {
++color: silver;
++}
++SPAN.nick {
++color: mediumblue;
++}
++SPAN.else {
++color: green;
++font-style: italic;
++}
++SPAN.action {
++color: violet;
++}
++SPAN.c0000, SPAN.c0100, SPAN.c0200, SPAN.c0300, SPAN.c0400, SPAN.c0500, SPAN.c0600, SPAN.c0700, SPAN.c0800, SPAN.c0900, SPAN.c1000, SPAN.c1100, SPAN.c1200, SPAN.c1300, SPAN.c1400, SPAN.c1500 {background-color: white;}
++SPAN.c0001, SPAN.c0101, SPAN.c0201, SPAN.c0301, SPAN.c0401, SPAN.c0501, SPAN.c0601, SPAN.c0701, SPAN.c0801, SPAN.c0901, SPAN.c1001, SPAN.c1101, SPAN.c1201, SPAN.c1301, SPAN.c1401, SPAN.c1501 {background-color: black;}
++SPAN.c0002, SPAN.c0102, SPAN.c0202, SPAN.c0302, SPAN.c0402, SPAN.c0502, SPAN.c0602, SPAN.c0702, SPAN.c0802, SPAN.c0902, SPAN.c1002, SPAN.c1102, SPAN.c1202, SPAN.c1302, SPAN.c1402, SPAN.c1502 {background-color: navy;}
++SPAN.c0003, SPAN.c0103, SPAN.c0203, SPAN.c0303, SPAN.c0403, SPAN.c0503, SPAN.c0603, SPAN.c0703, SPAN.c0803, SPAN.c0903, SPAN.c1003, SPAN.c1103, SPAN.c1203, SPAN.c1303, SPAN.c1403, SPAN.c1503 {background-color: green;}
++SPAN.c0004, SPAN.c0104, SPAN.c0204, SPAN.c0304, SPAN.c0404, SPAN.c0504, SPAN.c0604, SPAN.c0704, SPAN.c0804, SPAN.c0904, SPAN.c1004, SPAN.c1104, SPAN.c1204, SPAN.c1304, SPAN.c1404, SPAN.c1504 {background-color: red;}
++SPAN.c0005, SPAN.c0105, SPAN.c0205, SPAN.c0305, SPAN.c0405, SPAN.c0505, SPAN.c0605, SPAN.c0705, SPAN.c0805, SPAN.c0905, SPAN.c1005, SPAN.c1105, SPAN.c1205, SPAN.c1305, SPAN.c1405, SPAN.c1505 {background-color: maroon;}
++SPAN.c0006, SPAN.c0106, SPAN.c0206, SPAN.c0306, SPAN.c0406, SPAN.c0506, SPAN.c0606, SPAN.c0706, SPAN.c0806, SPAN.c0906, SPAN.c1006, SPAN.c1106, SPAN.c1206, SPAN.c1306, SPAN.c1406, SPAN.c1506 {background-color: purple;}
++SPAN.c0007, SPAN.c0107, SPAN.c0207, SPAN.c0307, SPAN.c0407, SPAN.c0507, SPAN.c0607, SPAN.c0707, SPAN.c0807, SPAN.c0907, SPAN.c1007, SPAN.c1107, SPAN.c1207, SPAN.c1307, SPAN.c1407, SPAN.c1507 {background-color: orange;}
++SPAN.c0008, SPAN.c0108, SPAN.c0208, SPAN.c0308, SPAN.c0408, SPAN.c0508, SPAN.c0608, SPAN.c0708, SPAN.c0808, SPAN.c0908, SPAN.c1008, SPAN.c1108, SPAN.c1208, SPAN.c1308, SPAN.c1408, SPAN.c1508 {background-color: yellow;}
++SPAN.c0009, SPAN.c0109, SPAN.c0209, SPAN.c0309, SPAN.c0409, SPAN.c0509, SPAN.c0609, SPAN.c0709, SPAN.c0809, SPAN.c0909, SPAN.c1009, SPAN.c1109, SPAN.c1209, SPAN.c1309, SPAN.c1409, SPAN.c1509 {background-color: lime;}
++SPAN.c0010, SPAN.c0110, SPAN.c0210, SPAN.c0310, SPAN.c0410, SPAN.c0510, SPAN.c0610, SPAN.c0710, SPAN.c0810, SPAN.c0910, SPAN.c1010, SPAN.c1110, SPAN.c1210, SPAN.c1310, SPAN.c1410, SPAN.c1510 {background-color: teal;}
++SPAN.c0011, SPAN.c0111, SPAN.c0211, SPAN.c0311, SPAN.c0411, SPAN.c0511, SPAN.c0611, SPAN.c0711, SPAN.c0811, SPAN.c0911, SPAN.c1011, SPAN.c1111, SPAN.c1211, SPAN.c1311, SPAN.c1411, SPAN.c1511 {background-color: cyan;}
++SPAN.c0012, SPAN.c0112, SPAN.c0212, SPAN.c0312, SPAN.c0412, SPAN.c0512, SPAN.c0612, SPAN.c0712, SPAN.c0812, SPAN.c0912, SPAN.c1012, SPAN.c1112, SPAN.c1212, SPAN.c1312, SPAN.c1412, SPAN.c1512 {background-color: blue;}
++SPAN.c0013, SPAN.c0113, SPAN.c0213, SPAN.c0313, SPAN.c0413, SPAN.c0513, SPAN.c0613, SPAN.c0713, SPAN.c0813, SPAN.c0913, SPAN.c1013, SPAN.c1113, SPAN.c1213, SPAN.c1313, SPAN.c1413, SPAN.c1513 {background-color: magenta;}
++SPAN.c0014, SPAN.c0114, SPAN.c0214, SPAN.c0314, SPAN.c0414, SPAN.c0514, SPAN.c0614, SPAN.c0714, SPAN.c0814, SPAN.c0914, SPAN.c1014, SPAN.c1114, SPAN.c1214, SPAN.c1314, SPAN.c1414, SPAN.c1514 {background-color: silver;}
++SPAN.c0015, SPAN.c0115, SPAN.c0215, SPAN.c0315, SPAN.c0415, SPAN.c0515, SPAN.c0615, SPAN.c0715, SPAN.c0815, SPAN.c0915, SPAN.c1015, SPAN.c1114, SPAN.c1215, SPAN.c1315, SPAN.c1415, SPAN.c1515 {background-color: gray;}
++SPAN.c0000, SPAN.c0001, SPAN.c0002, SPAN.c0003, SPAN.c0004, SPAN.c0005, SPAN.c0006, SPAN.c0007, SPAN.c0008, SPAN.c0009, SPAN.c0010, SPAN.c0011, SPAN.c0012, SPAN.c0013, SPAN.c0014, SPAN.c0015 {color: white;}
++SPAN.c0100, SPAN.c0101, SPAN.c0102, SPAN.c0103, SPAN.c0104, SPAN.c0105, SPAN.c0106, SPAN.c0107, SPAN.c0108, SPAN.c0109, SPAN.c0110, SPAN.c0111, SPAN.c0112, SPAN.c0113, SPAN.c0114, SPAN.c0115 {color: black;}
++SPAN.c0200, SPAN.c0201, SPAN.c0202, SPAN.c0203, SPAN.c0204, SPAN.c0205, SPAN.c0206, SPAN.c0207, SPAN.c0208, SPAN.c0209, SPAN.c0210, SPAN.c0211, SPAN.c0212, SPAN.c0213, SPAN.c0214, SPAN.c0215 {color: navy;}
++SPAN.c0300, SPAN.c0301, SPAN.c0302, SPAN.c0303, SPAN.c0304, SPAN.c0305, SPAN.c0306, SPAN.c0307, SPAN.c0308, SPAN.c0309, SPAN.c0310, SPAN.c0311, SPAN.c0312, SPAN.c0313, SPAN.c0314, SPAN.c0315 {color: green;}
++SPAN.c0400, SPAN.c0401, SPAN.c0402, SPAN.c0403, SPAN.c0404, SPAN.c0405, SPAN.c0406, SPAN.c0407, SPAN.c0408, SPAN.c0409, SPAN.c0410, SPAN.c0411, SPAN.c0412, SPAN.c0413, SPAN.c0414, SPAN.c0415 {color: red;}
++SPAN.c0500, SPAN.c0501, SPAN.c0502, SPAN.c0503, SPAN.c0504, SPAN.c0505, SPAN.c0506, SPAN.c0507, SPAN.c0508, SPAN.c0509, SPAN.c0510, SPAN.c0511, SPAN.c0512, SPAN.c0513, SPAN.c0514, SPAN.c0515 {color: maroon;}
++SPAN.c0600, SPAN.c0601, SPAN.c0602, SPAN.c0603, SPAN.c0604, SPAN.c0605, SPAN.c0606, SPAN.c0607, SPAN.c0608, SPAN.c0609, SPAN.c0610, SPAN.c0611, SPAN.c0612, SPAN.c0613, SPAN.c0614, SPAN.c0615 {color: purple;}
++SPAN.c0700, SPAN.c0701, SPAN.c0702, SPAN.c0703, SPAN.c0704, SPAN.c0705, SPAN.c0706, SPAN.c0707, SPAN.c0708, SPAN.c0709, SPAN.c0710, SPAN.c0711, SPAN.c0712, SPAN.c0713, SPAN.c0714, SPAN.c0715 {color: orange;}
++SPAN.c0800, SPAN.c0801, SPAN.c0802, SPAN.c0803, SPAN.c0804, SPAN.c0805, SPAN.c0806, SPAN.c0807, SPAN.c0808, SPAN.c0809, SPAN.c0810, SPAN.c0811, SPAN.c0812, SPAN.c0813, SPAN.c0814, SPAN.c0815 {color: yellow;}
++SPAN.c0900, SPAN.c0901, SPAN.c0902, SPAN.c0903, SPAN.c0904, SPAN.c0905, SPAN.c0906, SPAN.c0907, SPAN.c0908, SPAN.c0909, SPAN.c0910, SPAN.c0911, SPAN.c0912, SPAN.c0913, SPAN.c0914, SPAN.c0915 {color: lime;}
++SPAN.c1000, SPAN.c1001, SPAN.c1002, SPAN.c1003, SPAN.c1004, SPAN.c1005, SPAN.c1006, SPAN.c1007, SPAN.c1008, SPAN.c1009, SPAN.c1010, SPAN.c1011, SPAN.c1012, SPAN.c1013, SPAN.c1014, SPAN.c1015 {color: teal;}
++SPAN.c1100, SPAN.c1101, SPAN.c1102, SPAN.c1103, SPAN.c1104, SPAN.c1105, SPAN.c1106, SPAN.c1107, SPAN.c1108, SPAN.c1109, SPAN.c1110, SPAN.c1111, SPAN.c1112, SPAN.c1113, SPAN.c1114, SPAN.c1115 {color: cyan;}
++SPAN.c1200, SPAN.c1201, SPAN.c1202, SPAN.c1203, SPAN.c1204, SPAN.c1205, SPAN.c1206, SPAN.c1207, SPAN.c1208, SPAN.c1209, SPAN.c1210, SPAN.c1211, SPAN.c1212, SPAN.c1213, SPAN.c1214, SPAN.c1215 {color: blue;}
++SPAN.c1300, SPAN.c1301, SPAN.c1302, SPAN.c1303, SPAN.c1304, SPAN.c1305, SPAN.c1306, SPAN.c1307, SPAN.c1308, SPAN.c1309, SPAN.c1310, SPAN.c1311, SPAN.c1312, SPAN.c1313, SPAN.c1314, SPAN.c1315 {color: magenta;}
++SPAN.c1400, SPAN.c1401, SPAN.c1402, SPAN.c1403, SPAN.c1404, SPAN.c1405, SPAN.c1406, SPAN.c1407, SPAN.c1408, SPAN.c1409, SPAN.c1410, SPAN.c1411, SPAN.c1412, SPAN.c1413, SPAN.c1414, SPAN.c1415 {color: silver;}
++SPAN.c1500, SPAN.c1501, SPAN.c1502, SPAN.c1503, SPAN.c1504, SPAN.c1505, SPAN.c1506, SPAN.c1507, SPAN.c1508, SPAN.c1509, SPAN.c1510, SPAN.c1511, SPAN.c1512, SPAN.c1513, SPAN.c1514, SPAN.c1515 {color: gray;}
++SPAN.f00 {color: white;}
++SPAN.f01 {color: black;}
++SPAN.f02 {color: navy;}
++SPAN.f03 {color: green;}
++SPAN.f04 {color: red;}
++SPAN.f05 {color: maroon;}
++SPAN.f06 {color: purple;}
++SPAN.f07 {color: orange;}
++SPAN.f08 {color: yellow;}
++SPAN.f09 {color: lime;}
++SPAN.f10 {color: teal;}
++SPAN.f11 {color: cyan;}
++SPAN.f12 {color: blue;}
++SPAN.f13 {color: magenta;}
++SPAN.f14 {color: silver;}
++SPAN.f15 {color: gray;}
++SPAN.b00 {background-color: white;}
++SPAN.b01 {background-color: black;}
++SPAN.b02 {background-color: navy;}
++SPAN.b03 {background-color: green;}
++SPAN.b04 {background-color: red;}
++SPAN.b05 {background-color: maroon;}
++SPAN.b06 {background-color: purple;}
++SPAN.b07 {background-color: orange;}
++SPAN.b08 {background-color: yellow;}
++SPAN.b09 {background-color: lime;}
++SPAN.b10 {background-color: teal;}
++SPAN.b11 {background-color: cyan;}
++SPAN.b12 {background-color: blue;}
++SPAN.b13 {background-color: magenta;}
++SPAN.b14 {background-color: silver;}
++SPAN.b15 {background-color: gray;}
diff --git a/main/email/APKBUILD b/main/email/APKBUILD
new file mode 100644
index 00000000000..a1301fe0446
--- /dev/null
+++ b/main/email/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=email
+pkgver=3.1.2
+pkgrel=0
+pkgdesc="A command line SMTP client that's simple"
+url="http://www.cleancode.org/projects/email"
+license="GPL"
+depends="uclibc openssl"
+makedepends="openssl-dev"
+source="http://www.cleancode.org/downloads/email/email-3.1.2.tar.bz2"
+
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="468c32758a01d1def084b5a7aaf631ac email-3.1.2.tar.bz2"
diff --git a/main/email/email-3.1.0-doc.patch b/main/email/email-3.1.0-doc.patch
new file mode 100644
index 00000000000..d7467844f06
--- /dev/null
+++ b/main/email/email-3.1.0-doc.patch
@@ -0,0 +1,10 @@
+--- email-3.1.0.orig/configure.in Thu Jan 1 12:00:53 2009
++++ email-3.1.0/configure.in Thu Jan 1 12:01:16 2009
+@@ -65,7 +65,6 @@
+ CFLAGS="$CFLAGS -DUSE_GNU_STRFTIME"
+ fi
+
+-AC_SUBST(docdir, ["\${prefix}/doc/email-${version}"])
+ AC_SUBST(ver, ["$version"])
+
+ CFLAGS="$CFLAGS -I$cwd -I$cwd/src -I$cwd/include -I../include -I$cwd/dlib/include"
diff --git a/main/email/email-3.1.0-ldflags.patch b/main/email/email-3.1.0-ldflags.patch
new file mode 100644
index 00000000000..d08896ee3af
--- /dev/null
+++ b/main/email/email-3.1.0-ldflags.patch
@@ -0,0 +1,11 @@
+--- email-3.1.0.orig/src/Makefile.in Tue Dec 30 13:16:08 2008
++++ email-3.1.0/src/Makefile.in Tue Dec 30 13:17:00 2008
+@@ -18,7 +18,7 @@
+ remotesmtp.o sig_file.o smtpcommands.o utils.o
+
+ all: $(FILES)
+- $(CC) $(CFLAGS) -o email $(FILES) $(OTHER_FILES) $(LDFLAGS) $(LIBS) $(DLIB)
++ $(CC) $(CFLAGS) -o email $(FILES) $(OTHER_FILES) $(DLIB) $(LDFLAGS) $(LIBS)
+
+ clean:
+ rm -f *.o *.d email
diff --git a/main/espeak/APKBUILD b/main/espeak/APKBUILD
new file mode 100644
index 00000000000..bf005e00a5d
--- /dev/null
+++ b/main/espeak/APKBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=espeak
+pkgver=1.40.02
+pkgrel=0
+pkgdesc="Speech synthesizer for English and other languages"
+url="http://espeak.sourceforge.net/"
+license="GPL-3"
+subpackages="$pkgname-dev"
+depends="uclibc uclibc++"
+makedepends="uclibc++-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver-source.zip
+ $pkgname-$pkgver-uclibc++.patch"
+
+build() {
+ local s="$srcdir"/$pkgname-$pkgver-source
+ cd "$s"
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ export CXX=g++-uc
+
+ cd src
+ make CXXFLAGS="${CXXFLAGS}" AUDIO=none all || return 1
+
+ msg "Fixing byte order of phoneme data files"
+ cd "$s"/platforms/big_endian
+ make
+ ./espeak-phoneme-data "$s"/espeak-data
+ cp -f phondata phonindex phontab "$s"/espeak-data
+
+ cd "$s"/src
+ make DESTDIR="$pkgdir" AUDIO=none install || return 1
+
+ cd "$s"
+ install -d "$pkgdir"/usr/share/espeak-data
+ cp -r dictsource "$pkgdir"/usr/share/espeak-data
+}
+
+md5sums="708954b44c526e8174df8b88a6382738 espeak-1.40.02-source.zip
+c13bb95088c5777b4d3e5ea10ca37517 espeak-1.40.02-uclibc++.patch"
diff --git a/main/espeak/espeak-1.40.02-uclibc++.patch b/main/espeak/espeak-1.40.02-uclibc++.patch
new file mode 100644
index 00000000000..68992205259
--- /dev/null
+++ b/main/espeak/espeak-1.40.02-uclibc++.patch
@@ -0,0 +1,21 @@
+--- espeak-1.40.02-source.orig/src/Makefile 2008-12-26 10:11:49 +0000
++++ espeak-1.40.02-source/src/Makefile 2008-12-26 10:27:48 +0000
+@@ -60,15 +60,15 @@
+
+ SRCS1=$(speak_SOURCES)
+ OBJS1=$(patsubst %.cpp,%.o,$(SRCS1))
+-LIBS1=-lstdc++ $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
++LIBS1=-lm $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
+
+ SRCS2=$(libespeak_SOURCES)
+ OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2))
+-LIBS2=-lstdc++ $(LIB_AUDIO) -lpthread
++LIBS2=-lm $(LIB_AUDIO) -lpthread
+
+ SRCS3 = espeak.cpp
+ OBJS3=$(patsubst %.cpp,%.o,$(SRCS3))
+-LIBS3=-lstdc++ -L . -lespeak
++LIBS3=-L . -lespeak -lpthread
+
+ CXXFLAGS=-O2
+
diff --git a/main/ethtool/APKBUILD b/main/ethtool/APKBUILD
new file mode 100644
index 00000000000..50c92d40ec3
--- /dev/null
+++ b/main/ethtool/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ethtool
+pkgver=6
+pkgrel=0
+pkgdesc="gkernel ethtool"
+url="http://sourceforge.net/projects/gkernel/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+source="http://easynews.dl.sf.net/sourceforge/gkernel/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="3b721ec27f17ebf320ba8c505cf66d9c ethtool-6.tar.gz"
diff --git a/main/faac/APKBUILD b/main/faac/APKBUILD
new file mode 100644
index 00000000000..3e523a4d517
--- /dev/null
+++ b/main/faac/APKBUILD
@@ -0,0 +1,24 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=faac
+pkgver=1.28
+pkgrel=0
+pkgdesc="FAAC is an AAC audio encoder."
+url="http://www.audiocoding.com/"
+license="GPL custom"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+makedepends="autoconf automake libtool uclibc++-dev"
+source="http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ export CXX="${UC_CXX:-g++-uc}"
+ ./bootstrap
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -D -m644 "$srcdir"/$pkgname-$pkgver/libfaac/kiss_fft/COPYING \
+ "$pkgdir"/usr/share/licenses/faac/COPYING.kiss_fft
+}
+md5sums="80763728d392c7d789cde25614c878f6 faac-1.28.tar.gz"
diff --git a/main/faad2/APKBUILD b/main/faad2/APKBUILD
new file mode 100644
index 00000000000..e1453df902b
--- /dev/null
+++ b/main/faad2/APKBUILD
@@ -0,0 +1,28 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=faad2
+pkgver=2.7
+pkgrel=0
+pkgdesc="ISO AAC audio decoder"
+url="http://www.audiocoding.com/"
+license="custom:GPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+makedepends="autoconf automake libtool"
+source="http://downloads.sourceforge.net/sourceforge/faac/$pkgname-$pkgver.tar.bz2"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+
+ # manfile has bad name
+ mv frontend/faad.man frontend/faad.1 && \
+ sed -i -e 's:faad\.man:faad.1:' frontend/Makefile.am \
+ || return 1
+
+ sh bootstrap
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -m644 common/mp4ff/mp4ff_int_types.h "$pkgdir"/usr/include/mp4ff_int_types.h || return 1
+}
+md5sums="4c332fa23febc0e4648064685a3d4332 faad2-2.7.tar.bz2"
diff --git a/main/fcgi/10-fcgi-2.4.0-Makefile.patch b/main/fcgi/10-fcgi-2.4.0-Makefile.patch
new file mode 100644
index 00000000000..dad4cd6e02d
--- /dev/null
+++ b/main/fcgi/10-fcgi-2.4.0-Makefile.patch
@@ -0,0 +1,24 @@
+Index: fcgi-2.4.0/cgi-fcgi/Makefile.am
+===================================================================
+--- fcgi-2.4.0.orig/cgi-fcgi/Makefile.am
++++ fcgi-2.4.0/cgi-fcgi/Makefile.am
+@@ -11,5 +11,5 @@ INCLUDE_FILES = $(INCLUDEDIR)/fastcgi.
+ LIBDIR = ../libfcgi
+ LIBFCGI = $(LIBDIR)/libfcgi.la
+
+-LDADD = $(LIBFCGI)
++LDADD = $(LIBFCGI) -lm
+ cgi_fcgi_SOURCES = $(INCLUDE_FILES) cgi-fcgi.c
+Index: fcgi-2.4.0/examples/Makefile.am
+===================================================================
+--- fcgi-2.4.0.orig/examples/Makefile.am
++++ fcgi-2.4.0/examples/Makefile.am
+@@ -21,7 +21,7 @@ INCLUDE_FILES = $(INCLUDEDIR)/fastcgi.
+ LIBDIR = ../libfcgi
+ LIBFCGI = $(LIBDIR)/libfcgi.la
+
+-LDADD = $(LIBFCGI)
++LDADD = $(LIBFCGI) -lm
+
+ echo_SOURCES = $(INCLUDE_FILES) echo.c
+ echo_x_SOURCES = $(INCLUDE_FILES) echo-x.c
diff --git a/main/fcgi/20-fcgi-2.4.0-clientdata-pointer.patch b/main/fcgi/20-fcgi-2.4.0-clientdata-pointer.patch
new file mode 100644
index 00000000000..ba4793765d5
--- /dev/null
+++ b/main/fcgi/20-fcgi-2.4.0-clientdata-pointer.patch
@@ -0,0 +1,96 @@
+Index: fcgi-2.4.0/cgi-fcgi/cgi-fcgi.c
+===================================================================
+--- fcgi-2.4.0.orig/cgi-fcgi/cgi-fcgi.c
++++ fcgi-2.4.0/cgi-fcgi/cgi-fcgi.c
+@@ -21,6 +21,7 @@ static const char rcsid[] = "$Id: cgi-fc
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <sys/types.h>
+
+ #include "fcgi_config.h"
+
+@@ -145,7 +146,7 @@ static FCGI_BeginRequestBody MakeBeginRe
+
+
+ static int bytesToRead; /* number of bytes to read from Web Server */
+-static int appServerSock = -1; /* Socket connected to FastCGI application,
++static size_t appServerSock = -1; /* Socket connected to FastCGI application,
+ * used by AppServerReadHandler and
+ * AppServerWriteHandler. */
+ static Buffer fromAS; /* Bytes read from the FCGI application server. */
+@@ -640,7 +641,7 @@ static int ParseArgs(int argc, char *arg
+ }
+ if((av[ac] = (char *)malloc(strlen(tp1)+1)) == NULL) {
+ fprintf(stderr, "Cannot allocate %d bytes\n",
+- strlen(tp1)+1);
++ (int)strlen(tp1)+1);
+ exit(-1);
+ }
+ strcpy(av[ac++], tp1);
+Index: fcgi-2.4.0/examples/threaded.c
+===================================================================
+--- fcgi-2.4.0.orig/examples/threaded.c
++++ fcgi-2.4.0/examples/threaded.c
+@@ -24,7 +24,7 @@ static int counts[THREAD_COUNT];
+
+ static void *doit(void *a)
+ {
+- int rc, i, thread_id = (int)a;
++ size_t rc, i, thread_id = (size_t)a;
+ pid_t pid = getpid();
+ FCGX_Request request;
+ char *server_name;
+@@ -53,7 +53,7 @@ static void *doit(void *a)
+ "<h1>FastCGI Hello! (multi-threaded C, fcgiapp library)</h1>"
+ "Thread %d, Process %ld<p>"
+ "Request counts for %d threads running on host <i>%s</i><p><code>",
+- thread_id, pid, THREAD_COUNT, server_name ? server_name : "?");
++ (int)thread_id, pid, THREAD_COUNT, server_name ? server_name : "?");
+
+ sleep(2);
+
+@@ -71,7 +71,7 @@ static void *doit(void *a)
+
+ int main(void)
+ {
+- int i;
++ size_t i;
+ pthread_t id[THREAD_COUNT];
+
+ FCGX_Init();
+Index: fcgi-2.4.0/include/fcgios.h
+===================================================================
+--- fcgi-2.4.0.orig/include/fcgios.h
++++ fcgi-2.4.0/include/fcgios.h
+@@ -93,7 +93,7 @@ extern "C" {
+ # if defined(__STDC__) || defined(__cplusplus)
+ typedef void *ClientData;
+ # else
+- typedef int *ClientData;
++ typedef size_t *ClientData;
+ # endif /* __STDC__ */
+ #define _CLIENTDATA
+ #endif
+Index: fcgi-2.4.0/libfcgi/os_unix.c
+===================================================================
+--- fcgi-2.4.0.orig/libfcgi/os_unix.c
++++ fcgi-2.4.0/libfcgi/os_unix.c
+@@ -1155,7 +1155,7 @@ int OS_Accept(int listen_sock, int fail_
+
+ for (;;) {
+ do {
+-#ifdef HAVE_SOCKLEN
++#ifdef HAVE_SYS_SOCKET_H
+ socklen_t len = sizeof(sa);
+ #else
+ int len = sizeof(sa);
+@@ -1255,7 +1255,7 @@ int OS_IsFcgi(int sock)
+ struct sockaddr_in in;
+ struct sockaddr_un un;
+ } sa;
+-#ifdef HAVE_SOCKLEN
++#ifdef HAVE_SYS_SOCKET_H
+ socklen_t len = sizeof(sa);
+ #else
+ int len = sizeof(sa);
diff --git a/main/fcgi/30-fcgi-2.4.0-html-updates.patch b/main/fcgi/30-fcgi-2.4.0-html-updates.patch
new file mode 100644
index 00000000000..ca10a6a6039
--- /dev/null
+++ b/main/fcgi/30-fcgi-2.4.0-html-updates.patch
@@ -0,0 +1,65 @@
+Index: fcgi-2.4.0/doc/fcgi-devel-kit.htm
+===================================================================
+--- fcgi-2.4.0.orig/doc/fcgi-devel-kit.htm
++++ fcgi-2.4.0/doc/fcgi-devel-kit.htm
+@@ -19,7 +19,7 @@
+ </HEAD>
+ <BODY>
+ <P CLASS="c1">
+- <IMG BORDER="0" SRC="../images/fcgi-hd.gif" ALT="[[FastCGI]]"><BR CLEAR="all">
++ <IMG BORDER="0" SRC="images/fcgi-hd.gif" ALT="[[FastCGI]]"><BR CLEAR="all">
+ </P>
+ <H3 CLASS="c2">
+ FastCGI Developer&#39;s Kit
+Index: fcgi-2.4.0/doc/fcgi-java.htm
+===================================================================
+--- fcgi-2.4.0.orig/doc/fcgi-java.htm
++++ fcgi-2.4.0/doc/fcgi-java.htm
+@@ -20,7 +20,7 @@
+ </HEAD>
+ <BODY>
+ <DIV CLASS="c1">
+- <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="../images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
++ <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
+ </DIV>
+ <BR CLEAR="all">
+ <DIV CLASS="c1">
+Index: fcgi-2.4.0/doc/fcgi-perf.htm
+===================================================================
+--- fcgi-2.4.0.orig/doc/fcgi-perf.htm
++++ fcgi-2.4.0/doc/fcgi-perf.htm
+@@ -19,7 +19,7 @@
+ </HEAD>
+ <BODY>
+ <DIV CLASS="c1">
+- <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="../images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
++ <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
+ </DIV>
+ <BR CLEAR="all">
+ <DIV CLASS="c1">
+Index: fcgi-2.4.0/doc/fcgi-perl.htm
+===================================================================
+--- fcgi-2.4.0.orig/doc/fcgi-perl.htm
++++ fcgi-2.4.0/doc/fcgi-perl.htm
+@@ -19,7 +19,7 @@
+ </HEAD>
+ <BODY>
+ <DIV CLASS="c1">
+- <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="../images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
++ <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
+ </DIV>
+ <BR CLEAR="all">
+
+Index: fcgi-2.4.0/doc/fcgi-tcl.htm
+===================================================================
+--- fcgi-2.4.0.orig/doc/fcgi-tcl.htm
++++ fcgi-2.4.0/doc/fcgi-tcl.htm
+@@ -19,7 +19,7 @@
+ </HEAD>
+ <BODY>
+ <DIV CLASS="c1">
+- <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="../images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
++ <A HREF="http://fastcgi.com"><IMG BORDER="0" SRC="images/fcgi-hd.gif" ALT="[[FastCGI]]"></A>
+ </DIV>
+ <BR CLEAR="all">
+ <DIV CLASS="c1">
diff --git a/main/fcgi/APKBUILD b/main/fcgi/APKBUILD
new file mode 100644
index 00000000000..fc208006cb6
--- /dev/null
+++ b/main/fcgi/APKBUILD
@@ -0,0 +1,42 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=fcgi
+pkgver=2.4.0
+pkgrel=0
+pkgdesc="FAST CGI(fcgi) is a language independent, high performant extension to CGI"
+url="http://www.fastcgi.com"
+license="GPL"
+depends="uclibc"
+makedepends=""
+subpackages="$pkgname-dev"
+source="http://www.fastcgi.com/dist/${pkgname}-${pkgver}.tar.gz
+20-fcgi-2.4.0-clientdata-pointer.patch
+30-fcgi-2.4.0-html-updates.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ export LIBS="$LIBS -lm"
+
+ # seems like there is no way to disable c++ from configure script
+ # the row below helps us to build even if g++ is installed on system
+ export CXX=false
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-shared
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="d15060a813b91383a9f3c66faf84867e fcgi-2.4.0.tar.gz
+d2654525f06451c99b8cdd4cc00a963b 20-fcgi-2.4.0-clientdata-pointer.patch
+f26b536786f70b30a2d91c83d56e944c 30-fcgi-2.4.0-html-updates.patch"
diff --git a/main/fetchmail/APKBUILD b/main/fetchmail/APKBUILD
new file mode 100644
index 00000000000..092556638ab
--- /dev/null
+++ b/main/fetchmail/APKBUILD
@@ -0,0 +1,44 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=fetchmail
+pkgver=6.3.9
+pkgrel=3
+pkgdesc="A remote-mail retrieval and forwarding utility"
+url="http://fetchmail.berlios.de/"
+license="GPL"
+depends=
+makedepends="openssl-dev python"
+install="fetchmail.pre-install fetchmail.post-install"
+subpackages="$pkgname-doc fetchmailconf"
+source="http://download.berlios.de/fetchmail/$pkgname-$pkgver.tar.bz2
+ $install
+ fetchmail.initd"
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-ssl \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -Dm755 "$srcdir"/fetchmail.initd "$pkgdir"/etc/init.d/fetchmail
+ install -d "$pkgdir"/var/lib/fetchmail "$pkgdir"/var/run/fetchmail
+}
+
+fetchmailconf() {
+ depends="python"
+ pkgdesc="A GUI for generating fetchmail configuration files"
+ install=
+ mkdir -p "$subpkgdir"/usr/bin
+ cd "$pkgdir"
+ mv usr/bin/fetchmailconf "$subpkgdir"/usr/bin/
+ mv usr/lib "$subpkgdir"/usr/
+}
+
+md5sums="72c20ad2b9629f1a109668b05a84d823 fetchmail-6.3.9.tar.bz2
+5a2fc8e8b3115fe2b9bf23503fb8f0a4 fetchmail.pre-install
+4b451d102e92926b6b6c1774f4260310 fetchmail.post-install
+22e9ac1d8385db05da15e01fd5c831e4 fetchmail.initd"
diff --git a/main/fetchmail/fetchmail.initd b/main/fetchmail/fetchmail.initd
new file mode 100755
index 00000000000..a1ed1ec8371
--- /dev/null
+++ b/main/fetchmail/fetchmail.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+
+pidfile=/var/run/fetchmail/fetchmail.pid
+
+depend() {
+ need net
+ use mta
+}
+
+checkconfig() {
+ if [ ! -f /etc/fetchmailrc ]; then
+ eerror "Configuration file /etc/fetchmailrc not found"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting fetchmail"
+ start-stop-daemon --start --quiet \
+ --chuid fetchmail --exec /usr/bin/fetchmail \
+ -- -d ${polling_period:-300} -f /etc/fetchmailrc \
+ --pidfile ${pidfile} -i /var/lib/fetchmail/.fetchids
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping fetchmail"
+ start-stop-daemon --stop --quiet --pidfile ${pidfile}
+ eend ${?}
+}
+
diff --git a/main/fetchmail/fetchmail.post-install b/main/fetchmail/fetchmail.post-install
new file mode 100644
index 00000000000..b16bfcc3e42
--- /dev/null
+++ b/main/fetchmail/fetchmail.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+chown fetchmail:fetchmail /var/*/fetchmail
diff --git a/main/fetchmail/fetchmail.pre-install b/main/fetchmail/fetchmail.pre-install
new file mode 100644
index 00000000000..4a1b630e008
--- /dev/null
+++ b/main/fetchmail/fetchmail.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -h /var/lib/fetchmail -s /bin/false -D fetchmail 2>/dev/null
+exit 0
diff --git a/main/flac/APKBUILD b/main/flac/APKBUILD
new file mode 100644
index 00000000000..a5626e1c446
--- /dev/null
+++ b/main/flac/APKBUILD
@@ -0,0 +1,30 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=flac
+pkgver=1.2.1
+pkgrel=0
+pkgdesc="Free Lossless Audio Codec"
+url="http://flac.sourceforge.net/"
+license="custom:Xiph LGPL GPL FDL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc libogg"
+makedepends="libogg-dev"
+source="http://downloads.sf.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz
+ "
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver || return 1
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --enable-shared \
+ --enable-ogg \
+ --disable-sse \
+ --disable-rpath \
+ --disable-cpplibs \
+ --with-pic || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -Dm0644 COPYING.Xiph \
+ "$pkgdir"/usr/share/licenses/$pkgname/COPYING.Xiph
+}
+md5sums="153c8b15a54da428d1f0fadc756c22c7 flac-1.2.1.tar.gz"
diff --git a/main/fping/APKBUILD b/main/fping/APKBUILD
new file mode 100644
index 00000000000..11b4f1819a8
--- /dev/null
+++ b/main/fping/APKBUILD
@@ -0,0 +1,23 @@
+pkgname=fping
+pkgver=2.4_beta2
+_myver=2.4b2_to
+pkgrel=1
+pkgdesc="A utility to ping multiple hosts at once"
+url="http://www.fping.com/"
+license="fping"
+depends="uclibc"
+subpackages="$pkgname-doc"
+
+# what happened to upstream download? use gentoo distfiles meanwhile
+#source="http://www.$pkgname.com/download/$pkgname-${myver}.tar.gz"
+source=http://distfiles.gentoo.org/distfiles/fping-${_myver}.tar.gz
+
+
+build () {
+ cd $startdir/src/$pkgname-${_myver}
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make install DESTDIR="$pkgdir"
+}
+md5sums="d5e8be59e307cef76bc479e1684df705 fping-2.4b2_to.tar.gz"
diff --git a/main/freetds/APKBUILD b/main/freetds/APKBUILD
new file mode 100644
index 00000000000..5e58429d9c0
--- /dev/null
+++ b/main/freetds/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Michael Mason <ms13sp@gmail.com>
+pkgname=freetds
+pkgver=0.82
+pkgrel=1
+pkgdesc="Tabular Datastream Library"
+url="http://www.freetds.org/"
+license="GPL"
+depends=
+makedepends="unixodbc-dev readline-dev"
+install=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="3df6b2e83fd420e90f1becbd1162990a freetds-0.82.tar.gz"
diff --git a/main/freetype/10-bytecode.patch b/main/freetype/10-bytecode.patch
new file mode 100644
index 00000000000..dd901ad64b7
--- /dev/null
+++ b/main/freetype/10-bytecode.patch
@@ -0,0 +1,29 @@
+--- include/freetype/config/ftoption.h.old 2006-05-12 02:05:49.000000000 +0800
++++ include/freetype/config/ftoption.h 2006-10-02 01:22:50.000000000 +0800
+@@ -436,7 +436,7 @@
+ /* Do not #undef this macro here, since the build system might */
+ /* define it for certain configurations only. */
+ /* */
+-/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
++#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
+
+ /*************************************************************************/
+@@ -448,7 +448,7 @@
+ /* FT_PARAM_TAG_UNPATENTED_HINTING; or when the debug hook */
+ /* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally activated. */
+ /* */
+-#define TT_CONFIG_OPTION_UNPATENTED_HINTING
++#undef TT_CONFIG_OPTION_UNPATENTED_HINTING
+
+
+ /*************************************************************************/
+@@ -480,7 +480,7 @@
+ /* http://partners.adobe.com/asn/developer/opentype/glyf.html */
+ /* http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html */
+ /* */
+-#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
++#define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
+
+
+ /*************************************************************************/
diff --git a/main/freetype/20-enable-spr.patch b/main/freetype/20-enable-spr.patch
new file mode 100644
index 00000000000..217912aa1f2
--- /dev/null
+++ b/main/freetype/20-enable-spr.patch
@@ -0,0 +1,11 @@
+--- include/freetype/config/ftoption.h.spf 2007-01-18 14:27:34.000000000 -0500
++++ include/freetype/config/ftoption.h 2007-01-18 14:27:48.000000000 -0500
+@@ -92,7 +92,7 @@
+ /* This is done to allow FreeType clients to run unmodified, forcing */
+ /* them to display normal gray-level anti-aliased glyphs. */
+ /* */
+-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
++#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+
+
+ /*************************************************************************/
diff --git a/main/freetype/30-enable-valid.patch b/main/freetype/30-enable-valid.patch
new file mode 100644
index 00000000000..b61a792219b
--- /dev/null
+++ b/main/freetype/30-enable-valid.patch
@@ -0,0 +1,20 @@
+--- modules.cfg.orig 2006-07-07 21:01:09.000000000 -0400
++++ modules.cfg 2006-07-07 21:01:54.000000000 -0400
+@@ -110,7 +110,7 @@
+ AUX_MODULES += cache
+
+ # TrueType GX/AAT table validation. Needs ftgxval.c below.
+-# AUX_MODULES += gxvalid
++AUX_MODULES += gxvalid
+
+ # Support for streams compressed with gzip (files with suffix .gz).
+ #
+@@ -124,7 +124,7 @@
+
+ # OpenType table validation. Needs ftotval.c below.
+ #
+-# AUX_MODULES += otvalid
++AUX_MODULES += otvalid
+
+ # Auxiliary PostScript driver component to share common code.
+ #
diff --git a/main/freetype/40-memcpy-fix.patch b/main/freetype/40-memcpy-fix.patch
new file mode 100644
index 00000000000..95c1cd6430c
--- /dev/null
+++ b/main/freetype/40-memcpy-fix.patch
@@ -0,0 +1,14 @@
+--- src/psaux/psobjs.c~ 2006-04-26 16:38:17.000000000 +0200
++++ src/psaux/psobjs.c 2006-09-10 15:01:13.000000000 +0200
+@@ -165,6 +165,11 @@
+ return PSaux_Err_Invalid_Argument;
+ }
+
++ if ( length < 0 ) {
++ FT_ERROR(( "ps_table_add: invalid length\n" ));
++ return PSaux_Err_Invalid_Argument;
++ }
++
+ /* grow the base block if needed */
+ if ( table->cursor + length > table->capacity )
+ {
diff --git a/main/freetype/APKBUILD b/main/freetype/APKBUILD
new file mode 100644
index 00000000000..e7f2a87ffc2
--- /dev/null
+++ b/main/freetype/APKBUILD
@@ -0,0 +1,41 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=freetype
+pkgver=2.3.8
+pkgrel=0
+pkgdesc="TrueType font rendering library"
+url="http://freetype.sourceforge.net"
+license="GPL"
+depends="zlib"
+makedepends="zlib-dev"
+subpackages="$pkgname-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+10-bytecode.patch
+20-enable-spr.patch
+30-enable-valid.patch
+40-memcpy-fix.patch
+"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for i in "$srcdir"/*.patch; do
+ msg "Applying ${i}"
+ patch -p0 -i $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-static
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+}
+
+md5sums="ebd7d255fd72b7f86c94501b80c50009 freetype-2.3.8.tar.gz
+9ff19e742968c29e3ba52b08d6bf0a50 10-bytecode.patch
+376b94c06b113a62a3437e4130bb3fc3 20-enable-spr.patch
+3f6c5739843dcbc110ee0f243c4f6bdb 30-enable-valid.patch
+bd2d808a0c00dcf9f1d1c0a9a8227ad9 40-memcpy-fix.patch"
diff --git a/main/gawk/APKBUILD b/main/gawk/APKBUILD
new file mode 100644
index 00000000000..5bcd518d236
--- /dev/null
+++ b/main/gawk/APKBUILD
@@ -0,0 +1,30 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gawk
+pkgver=3.1.6
+pkgrel=1
+pkgdesc="GNU awk pattern-matching language"
+url="http://www.gnu.org/software/gawk/gawk.html"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install="$pkgname.post-deinstall"
+subpackages="$pkgname-doc"
+source="http://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="b237751aef53c9ead9644e376bc53386 gawk-3.1.6.tar.gz
+b84506d253e04db3c5af9016fead45a3 gawk.post-deinstall"
diff --git a/main/gawk/gawk.post-deinstall b/main/gawk/gawk.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/gawk/gawk.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/gd/APKBUILD b/main/gd/APKBUILD
new file mode 100644
index 00000000000..75cd56cc48c
--- /dev/null
+++ b/main/gd/APKBUILD
@@ -0,0 +1,32 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=gd
+pkgver=2.0.35
+pkgrel=2
+pkgdesc="Library for the dynamic creation of images by programmers"
+url="http://www.libgd.org/"
+license="custom"
+depends=
+makedepends="libpng-dev jpeg-dev freetype-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://www.libgd.org/releases/${pkgname}-${pkgver}.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ find -name configure | xargs touch
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-png \
+ --with-freetype \
+ --with-jpeg \
+ --without-xpm \
+ --without-fontconfig
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -D -m644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+md5sums="6c6c3dbb7bf079e0bb5fbbfd3bb8a71c gd-2.0.35.tar.bz2"
diff --git a/main/gdb/50_all_gdb-pie-1.patch b/main/gdb/50_all_gdb-pie-1.patch
new file mode 100644
index 00000000000..a20771f6898
--- /dev/null
+++ b/main/gdb/50_all_gdb-pie-1.patch
@@ -0,0 +1,1330 @@
+2007-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Port to GDB-6.7.1.
+
+2007-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Port to post-GDB-6.7.1 multi-PC breakpoints.
+
+2007-11-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * solib-svr4.c (svr4_current_sos): Fix segfault on NULL EXEC_BFD.
+
+2008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Port to GDB-6.8pre.
+
+2008-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Port to gdb-6.7.50.20080227.
+
+Index: gdb/dwarf2read.c
+===================================================================
+--- a/gdb/dwarf2read.c 2008-02-27 08:57:20.000000000 +0100
++++ b/gdb/dwarf2read.c 2008-02-27 08:57:31.000000000 +0100
+@@ -1217,7 +1217,7 @@ dwarf2_build_psymtabs (struct objfile *o
+ else
+ dwarf2_per_objfile->loc_buffer = NULL;
+
+- if (mainline
++ if ((mainline == 1)
+ || (objfile->global_psymbols.size == 0
+ && objfile->static_psymbols.size == 0))
+ {
+Index: gdb/auxv.c
+===================================================================
+--- a/gdb/auxv.c 2008-01-16 17:27:37.000000000 +0100
++++ b/gdb/auxv.c 2008-02-27 08:57:31.000000000 +0100
+@@ -80,7 +80,7 @@ procfs_xfer_auxv (struct target_ops *ops
+ Return 1 if an entry was read into *TYPEP and *VALP. */
+ int
+ target_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
+- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
++ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp)
+ {
+ const int sizeof_auxv_field = TYPE_LENGTH (builtin_type_void_data_ptr);
+ gdb_byte *ptr = *readptr;
+@@ -105,9 +105,10 @@ target_auxv_parse (struct target_ops *op
+ an error getting the information. On success, return 1 after
+ storing the entry's value field in *VALP. */
+ int
+-target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
++target_auxv_search (struct target_ops *ops, ULONGEST match, CORE_ADDR *valp)
+ {
+- CORE_ADDR type, val;
++ CORE_ADDR val;
++ ULONGEST at_type;
+ gdb_byte *data;
+ LONGEST n = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL, &data);
+ gdb_byte *ptr = data;
+@@ -117,10 +118,10 @@ target_auxv_search (struct target_ops *o
+ return n;
+
+ while (1)
+- switch (target_auxv_parse (ops, &ptr, data + n, &type, &val))
++ switch (target_auxv_parse (ops, &ptr, data + n, &at_type, &val))
+ {
+ case 1: /* Here's an entry, check it. */
+- if (type == match)
++ if (at_type == match)
+ {
+ xfree (data);
+ *valp = val;
+@@ -143,7 +144,8 @@ target_auxv_search (struct target_ops *o
+ int
+ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
+ {
+- CORE_ADDR type, val;
++ CORE_ADDR val;
++ ULONGEST at_type;
+ gdb_byte *data;
+ LONGEST len = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL,
+ &data);
+@@ -153,14 +155,14 @@ fprint_target_auxv (struct ui_file *file
+ if (len <= 0)
+ return len;
+
+- while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
++ while (target_auxv_parse (ops, &ptr, data + len, &at_type, &val) > 0)
+ {
+ extern int addressprint;
+ const char *name = "???";
+ const char *description = "";
+ enum { dec, hex, str } flavor = hex;
+
+- switch (type)
++ switch (at_type)
+ {
+ #define TAG(tag, text, kind) \
+ case tag: name = #tag; description = text; flavor = kind; break
+@@ -213,7 +215,7 @@ fprint_target_auxv (struct ui_file *file
+ }
+
+ fprintf_filtered (file, "%-4s %-20s %-30s ",
+- paddr_d (type), name, description);
++ paddr_d (at_type), name, description);
+ switch (flavor)
+ {
+ case dec:
+Index: gdb/auxv.h
+===================================================================
+--- a/gdb/auxv.h 2008-01-01 23:53:09.000000000 +0100
++++ b/gdb/auxv.h 2008-02-27 08:57:31.000000000 +0100
+@@ -35,14 +35,14 @@ struct target_ops; /* Forward declarati
+ Return 1 if an entry was read into *TYPEP and *VALP. */
+ extern int target_auxv_parse (struct target_ops *ops,
+ gdb_byte **readptr, gdb_byte *endptr,
+- CORE_ADDR *typep, CORE_ADDR *valp);
++ ULONGEST *typep, CORE_ADDR *valp);
+
+ /* Extract the auxiliary vector entry with a_type matching MATCH.
+ Return zero if no such entry was found, or -1 if there was
+ an error getting the information. On success, return 1 after
+ storing the entry's value field in *VALP. */
+ extern int target_auxv_search (struct target_ops *ops,
+- CORE_ADDR match, CORE_ADDR *valp);
++ ULONGEST match, CORE_ADDR *valp);
+
+ /* Print the contents of the target's AUXV on the specified file. */
+ extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops);
+Index: gdb/breakpoint.h
+===================================================================
+--- a/gdb/breakpoint.h 2008-02-01 17:24:46.000000000 +0100
++++ b/gdb/breakpoint.h 2008-02-27 08:57:31.000000000 +0100
+@@ -144,6 +144,7 @@ enum enable_state
+ automatically enabled and reset when the call
+ "lands" (either completes, or stops at another
+ eventpoint). */
++ bp_startup_disabled,
+ bp_permanent /* There is a breakpoint instruction hard-wired into
+ the target's code. Don't try to write another
+ breakpoint instruction on top of it, or restore
+@@ -823,6 +824,10 @@ extern void remove_thread_event_breakpoi
+
+ extern void disable_breakpoints_in_shlibs (void);
+
++extern void disable_breakpoints_at_startup (int silent);
++
++extern void re_enable_breakpoints_at_startup (void);
++
+ /* This function returns TRUE if ep is a catchpoint. */
+ extern int ep_is_catchpoint (struct breakpoint *);
+
+Index: gdb/symfile-mem.c
+===================================================================
+--- a/gdb/symfile-mem.c 2008-01-01 23:53:13.000000000 +0100
++++ b/gdb/symfile-mem.c 2008-02-27 08:57:31.000000000 +0100
+@@ -108,7 +108,7 @@ symbol_file_add_from_memory (struct bfd
+ }
+
+ objf = symbol_file_add_from_bfd (nbfd, from_tty,
+- sai, 0, OBJF_SHARED);
++ sai, 2, OBJF_SHARED);
+
+ /* This might change our ideas about frames already looked at. */
+ reinit_frame_cache ();
+Index: gdb/infrun.c
+===================================================================
+--- a/gdb/infrun.c 2008-02-27 08:57:20.000000000 +0100
++++ b/gdb/infrun.c 2008-02-27 08:57:31.000000000 +0100
+@@ -2277,6 +2277,11 @@ process_event_stop_test:
+ #endif
+ target_terminal_inferior ();
+
++ /* For PIE executables, we dont really know where the
++ breakpoints are going to be until we start up the
++ inferior. */
++ re_enable_breakpoints_at_startup ();
++
+ /* If requested, stop when the dynamic linker notifies
+ gdb of events. This allows the user to get control
+ and place breakpoints in initializer routines for
+Index: gdb/objfiles.c
+===================================================================
+--- a/gdb/objfiles.c 2008-01-01 23:53:12.000000000 +0100
++++ b/gdb/objfiles.c 2008-02-27 08:57:31.000000000 +0100
+@@ -49,6 +49,9 @@
+ #include "source.h"
+ #include "addrmap.h"
+
++#include "auxv.h"
++#include "elf/common.h"
++
+ /* Prototypes for local functions */
+
+ static void objfile_alloc_data (struct objfile *objfile);
+@@ -260,7 +263,19 @@ init_entry_point_info (struct objfile *o
+ CORE_ADDR
+ entry_point_address (void)
+ {
+- return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
++ int ret;
++ CORE_ADDR entry_addr;
++
++ /* Find the address of the entry point of the program from the
++ auxv vector. */
++ ret = target_auxv_search (&current_target, AT_ENTRY, &entry_addr);
++ if (ret == 1)
++ return entry_addr;
++ /*if (ret == 0 || ret == -1)*/
++ else
++ {
++ return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
++ }
+ }
+
+ /* Create the terminating entry of OBJFILE's minimal symbol table.
+Index: gdb/solib-svr4.c
+===================================================================
+--- a/gdb/solib-svr4.c 2008-02-27 08:57:19.000000000 +0100
++++ b/gdb/solib-svr4.c 2008-02-27 08:59:06.000000000 +0100
+@@ -31,6 +31,8 @@
+ #include "gdbcore.h"
+ #include "target.h"
+ #include "inferior.h"
++#include "auxv.h"
++#include "command.h"
+
+ #include "gdb_assert.h"
+
+@@ -246,7 +248,9 @@ static char *debug_loader_name;
+
+ /* Local function prototypes */
+
++#if 0
+ static int match_main (char *);
++#endif
+
+ static CORE_ADDR bfd_lookup_symbol (bfd *, char *);
+
+@@ -349,10 +353,12 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
+ int arch_size, step, sect_size;
+ long dyn_tag;
+ CORE_ADDR dyn_ptr, dyn_addr;
++ CORE_ADDR entry_addr;
+ gdb_byte *bufend, *bufstart, *buf;
+ Elf32_External_Dyn *x_dynp_32;
+ Elf64_External_Dyn *x_dynp_64;
+ struct bfd_section *sect;
++ int ret;
+
+ if (abfd == NULL)
+ return 0;
+@@ -360,19 +366,74 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
+ if (arch_size == -1)
+ return 0;
+
++ /* The auxv vector based relocatable files reading is limited to the main
++ executable. */
++ gdb_assert (abfd == exec_bfd || ptr == NULL);
++
++ if (ptr != NULL)
++ {
++ /* Find the address of the entry point of the program from the
++ auxv vector. */
++ ret = target_auxv_search (&current_target, AT_ENTRY, &entry_addr);
++
++ if (ret == 0 || ret == -1)
++ {
++ /* No auxv info, maybe an older kernel. Fake our way through. */
++ entry_addr = bfd_get_start_address (exec_bfd);
++
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: program entry address not found. Using bfd's 0x%s for %s\n",
++ paddr_nz (entry_addr), exec_bfd->filename);
++ }
++ else
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: found program entry address 0x%s for %s\n",
++ paddr_nz (entry_addr), exec_bfd->filename);
++ }
++ }
++
+ /* Find the start address of the .dynamic section. */
+ sect = bfd_get_section_by_name (abfd, ".dynamic");
+ if (sect == NULL)
+- return 0;
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: .dynamic section not found in %s -- return now\n",
++ exec_bfd->filename);
++ return 0;
++ }
++ else
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: .dynamic section found in %s\n",
++ exec_bfd->filename);
++ }
++
+ dyn_addr = bfd_section_vma (abfd, sect);
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: .dynamic addr 0x%s\n",
++ paddr_nz (dyn_addr));
+
+ /* Read in .dynamic from the BFD. We will get the actual value
+ from memory later. */
+ sect_size = bfd_section_size (abfd, sect);
+ buf = bufstart = alloca (sect_size);
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: read in .dynamic section\n");
+ if (!bfd_get_section_contents (abfd, sect,
+ buf, 0, sect_size))
+- return 0;
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: couldn't read .dynamic section -- return now\n");
++ return 0;
++ }
+
+ /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */
+ step = (arch_size == 32) ? sizeof (Elf32_External_Dyn)
+@@ -405,9 +466,43 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
+ CORE_ADDR ptr_addr;
+
+ ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
++ if (ptr != NULL)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: unrelocated ptr addr 0x%s\n",
++ paddr_nz (ptr_addr));
++ ptr_addr += entry_addr - bfd_get_start_address (exec_bfd);
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: relocated ptr addr 0x%s"
++ " (auxv entry 0x%s, bfd start address 0x%s)"
++ " for %s\n",
++ paddr_nz (ptr_addr), paddr_nz (entry_addr),
++ paddr_nz (bfd_get_start_address (exec_bfd)),
++ exec_bfd->filename);
++ }
+ if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
+- dyn_ptr = extract_typed_address (ptr_buf,
+- builtin_type_void_data_ptr);
++ {
++ dyn_ptr = extract_typed_address (ptr_buf,
++ builtin_type_void_data_ptr);
++ if (ptr != NULL)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: Tag entry has value 0x%s -- return now\n",
++ paddr_nz (dyn_ptr));
++ }
++ }
++ else
++ {
++ if (ptr != NULL)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "elf_locate_base: Couldn't read tag entry value -- return now\n");
++ }
++ }
+ *ptr = dyn_ptr;
+ }
+ return 1;
+@@ -544,6 +639,10 @@ solib_svr4_r_map (void)
+ {
+ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
+
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "solib_svr4_r_map: read at 0x%s\n",
++ paddr_nz (debug_base + lmo->r_map_offset));
+ return read_memory_typed_address (debug_base + lmo->r_map_offset,
+ builtin_type_void_data_ptr);
+ }
+@@ -713,6 +812,11 @@ svr4_current_sos (void)
+ struct so_list *head = 0;
+ struct so_list **link_ptr = &head;
+ CORE_ADDR ldsomap = 0;
++ const char *filename = exec_bfd ? exec_bfd->filename : "<none>";
++
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: exec_bfd %s\n", filename);
+
+ /* Always locate the debug struct, in case it has moved. */
+ debug_base = 0;
+@@ -721,10 +825,19 @@ svr4_current_sos (void)
+ /* If we can't find the dynamic linker's base structure, this
+ must not be a dynamically linked executable. Hmm. */
+ if (! debug_base)
+- return svr4_default_sos ();
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: no DT_DEBUG found in %s -- return now\n",
++ filename);
++ return svr4_default_sos ();
++ }
+
+ /* Walk the inferior's link map list, and build our list of
+ `struct so_list' nodes. */
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: walk link map in %s\n", filename);
+ lm = solib_svr4_r_map ();
+
+ while (lm)
+@@ -740,23 +853,103 @@ svr4_current_sos (void)
+ new->lm_info->lm = xzalloc (lmo->link_map_size);
+ make_cleanup (xfree, new->lm_info->lm);
+
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: read lm at 0x%s\n", paddr_nz(lm));
+ read_memory (lm, new->lm_info->lm, lmo->link_map_size);
+
+ lm = LM_NEXT (new);
+
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: is first link entry? %d\n",
++ IGNORE_FIRST_LINK_MAP_ENTRY (new));
++
+ /* For SVR4 versions, the first entry in the link map is for the
+ inferior executable, so we must ignore it. For some versions of
+ SVR4, it has no name. For others (Solaris 2.3 for example), it
+ does have a name, so we can no longer use a missing name to
+ decide when to ignore it. */
+- if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
+- free_so (new);
++ if (exec_bfd != NULL && IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
++ {
++ /* It is the first link map entry, i.e. it is the main executable. */
++
++ if (bfd_get_start_address (exec_bfd) == entry_point_address ())
++ {
++ /* Non-pie case, main executable has not been relocated. */
++ free_so (new);
++ }
++ else
++ {
++ /* Pie case, main executable has been relocated. */
++ struct so_list *gdb_solib;
++
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: Processing first link map entry\n");
++ strncpy (new->so_name, exec_bfd->filename,
++ SO_NAME_MAX_PATH_SIZE - 1);
++ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
++ strcpy (new->so_original_name, new->so_name);
++ /*new->main = 1;*/
++ new->main_relocated = 0;
++
++ if (debug_solib)
++ {
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: Processing nameless DSO\n");
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: adding name %s\n",
++ new->so_name);
++ }
++
++ for (gdb_solib = master_so_list ();
++ gdb_solib;
++ gdb_solib = gdb_solib->next)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: compare gdb %s and new %s\n",
++ gdb_solib->so_name, new->so_name);
++ if (strcmp (gdb_solib->so_name, new->so_name) == 0)
++ if (gdb_solib->main_relocated)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: found main relocated\n");
++ break;
++ }
++ }
++
++ if ((gdb_solib && !gdb_solib->main_relocated) || (!gdb_solib))
++ {
++ add_to_target_sections (0 /*from_tty*/, &current_target, new);
++ new->main = 1;
++ }
++
++ /* We need this in the list of shared libs we return because
++ solib_add_stub will loop through it and add the symbol file. */
++ new->next = 0;
++ *link_ptr = new;
++ link_ptr = &new->next;
++ }
++ } /* End of IGNORE_FIRST_LINK_MAP_ENTRY */
+ else
+ {
++ /* This is not the first link map entry, i.e. is not the main
++ executable. Note however that it could be the DSO supplied on
++ certain systems (i.e. Linux 2.6) containing information about
++ the vsyscall page. We must ignore such entry. This entry is
++ nameless (just like the one for the main executable, sigh). */
++
+ int errcode;
+ char *buffer;
+
+ /* Extract this shared object's name. */
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: read LM_NAME\n");
++
+ target_read_string (LM_NAME (new), &buffer,
+ SO_NAME_MAX_PATH_SIZE - 1, &errcode);
+ if (errcode != 0)
+@@ -764,23 +957,35 @@ svr4_current_sos (void)
+ safe_strerror (errcode));
+ else
+ {
+- strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
+- new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
+- strcpy (new->so_original_name, new->so_name);
+- }
+- xfree (buffer);
+-
+- /* If this entry has no name, or its name matches the name
+- for the main executable, don't include it in the list. */
+- if (! new->so_name[0]
+- || match_main (new->so_name))
+- free_so (new);
+- else
+- {
+- new->next = 0;
+- *link_ptr = new;
+- link_ptr = &new->next;
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: LM_NAME is <%s>\n",
++ buffer);
++ /* The name could be empty, in which case it is the
++ system supplied DSO. */
++ if (strcmp (buffer, "") == 0)
++ free_so (new);
++ else
++ {
++ strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
++ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
++ strcpy (new->so_original_name, new->so_name);
++ if (debug_solib)
++ {
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: Processing DSO: %s\n",
++ new->so_name);
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_current_sos: first link entry %d\n",
++ IGNORE_FIRST_LINK_MAP_ENTRY (new));
++ }
++
++ new->next = 0;
++ *link_ptr = new;
++ link_ptr = &new->next;
++ }
+ }
++ xfree (buffer);
+ }
+
+ /* On Solaris, the dynamic linker is not in the normal list of
+@@ -796,6 +1001,9 @@ svr4_current_sos (void)
+ if (head == NULL)
+ return svr4_default_sos ();
+
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog, "svr4_current_sos: ENDS %s\n", filename);
++
+ return head;
+ }
+
+@@ -875,7 +1083,7 @@ svr4_fetch_objfile_link_map (struct objf
+ /* On some systems, the only way to recognize the link map entry for
+ the main executable file is by looking at its name. Return
+ non-zero iff SONAME matches one of the known main executable names. */
+-
++#if 0
+ static int
+ match_main (char *soname)
+ {
+@@ -889,6 +1097,7 @@ match_main (char *soname)
+
+ return (0);
+ }
++#endif
+
+ /* Return 1 if PC lies in the dynamic symbol resolution code of the
+ SVR4 run time loader. */
+@@ -1040,6 +1249,11 @@ enable_break (void)
+ /* Find the .interp section; if not found, warn the user and drop
+ into the old breakpoint at symbol code. */
+ interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
++
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "enable_break: search for .interp in %s\n",
++ exec_bfd->filename);
+ if (interp_sect)
+ {
+ unsigned int interp_sect_size;
+@@ -1074,6 +1288,9 @@ enable_break (void)
+ if (tmp_fd >= 0)
+ tmp_bfd = bfd_fopen (tmp_pathname, gnutarget, FOPEN_RB, tmp_fd);
+
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "enable_break: opening %s\n", tmp_pathname);
+ if (tmp_bfd == NULL)
+ goto bkpt_at_symbol;
+
+@@ -1180,6 +1397,9 @@ enable_break (void)
+ if (sym_addr != 0)
+ {
+ create_solib_event_breakpoint (load_addr + sym_addr);
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "enable_break: solib bp set\n");
+ return 1;
+ }
+
+@@ -1440,6 +1660,8 @@ svr4_solib_create_inferior_hook (void)
+ while (stop_signal != TARGET_SIGNAL_TRAP);
+ stop_soon = NO_STOP_QUIETLY;
+ #endif /* defined(_SCO_DS) */
++
++ disable_breakpoints_at_startup (1);
+ }
+
+ static void
+@@ -1620,6 +1842,75 @@ svr4_lp64_fetch_link_map_offsets (void)
+
+ return lmp;
+ }
++void
++info_linkmap_command (char *cmd, int from_tty)
++{
++ CORE_ADDR lm;
++
++ /* Make sure we've looked up the inferior's dynamic linker's base
++ structure. */
++ if (! debug_base)
++ {
++ debug_base = locate_base ();
++
++ /* If we can't find the dynamic linker's base structure, this
++ must not be a dynamically linked executable. Hmm. */
++ if (! debug_base)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_print_linkmap: no DT_DEBUG found in %s -- return now\n",
++ exec_bfd->filename);
++ return;
++ }
++ }
++
++ /* Walk the inferior's link map list, and print the info. */
++
++ lm = solib_svr4_r_map ();
++ while (lm)
++ {
++ int errcode;
++ char *buffer;
++ CORE_ADDR load_addr;
++
++ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
++ struct so_list *new
++ = (struct so_list *) xmalloc (sizeof (struct so_list));
++ struct cleanup *old_chain = make_cleanup (xfree, new);
++
++ memset (new, 0, sizeof (*new));
++
++ new->lm_info = xmalloc (sizeof (struct lm_info));
++ make_cleanup (xfree, new->lm_info);
++
++ new->lm_info->lm = xmalloc (lmo->link_map_size);
++ make_cleanup (xfree, new->lm_info->lm);
++ memset (new->lm_info->lm, 0, lmo->link_map_size);
++
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "svr4_print_linkmap: read lm at 0x%s\n", paddr_nz(lm));
++ read_memory (lm, new->lm_info->lm, lmo->link_map_size);
++
++ lm = LM_NEXT (new);
++
++ /* Load address. */
++ load_addr = LM_ADDR_CHECK (new, NULL);
++ /* Shared object's name. */
++ target_read_string (LM_NAME (new), &buffer,
++ SO_NAME_MAX_PATH_SIZE - 1, &errcode);
++ make_cleanup (xfree, buffer);
++ if (errcode != 0)
++ {
++ warning ("svr4_print_linkmap: Can't read pathname for load map: %s\n",
++ safe_strerror (errcode));
++ }
++ fprintf_filtered (gdb_stdout, "%-8s %-30s\n", paddr(load_addr), buffer);
++ do_cleanups (old_chain);
++ }
++}
++
+
+
+ struct target_so_ops svr4_so_ops;
+@@ -1678,4 +1969,7 @@ _initialize_svr4_solib (void)
+ svr4_so_ops.in_dynsym_resolve_code = svr4_in_dynsym_resolve_code;
+ svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol;
+ svr4_so_ops.same = svr4_same;
++
++ add_info ("linkmap", info_linkmap_command,
++ "Display the inferior's linkmap.");
+ }
+Index: gdb/varobj.c
+===================================================================
+--- a/gdb/varobj.c 2008-02-04 08:49:04.000000000 +0100
++++ b/gdb/varobj.c 2008-02-27 08:57:31.000000000 +0100
+@@ -1078,6 +1078,62 @@ install_new_value (struct varobj *var, s
+ return changed;
+ }
+
++void
++varobj_refresh (void)
++{
++ struct varobj *var;
++ struct varobj_root *croot;
++ int mycount = rootcount;
++ char * name;
++
++ croot = rootlist;
++ while ((croot != NULL) && (mycount > 0))
++ {
++ var = croot->rootvar;
++
++ /* Get rid of the memory for the old expression. This also
++ leaves var->root->exp == NULL, which is ok for the parsing
++ below. */
++ free_current_contents (&var->root->exp);
++
++ value_free (var->value);
++ var->type = NULL;
++
++ name = xstrdup (var->name);
++
++ /* Reparse the expression. Wrap the call to parse expression,
++ so we can return a sensible error. */
++ if (!gdb_parse_exp_1 (&name, var->root->valid_block, 0, &var->root->exp))
++ {
++ return;
++ }
++
++ /* We definitively need to catch errors here.
++ If evaluate_expression succeeds we got the value we wanted.
++ But if it fails, we still go on with a call to evaluate_type() */
++ if (gdb_evaluate_expression (var->root->exp, &var->value))
++ {
++ /* no error */
++ release_value (var->value);
++ if (value_lazy (var->value))
++ gdb_value_fetch_lazy (var->value);
++ }
++ else
++ var->value = evaluate_type (var->root->exp);
++
++ var->type = value_type (var->value);
++
++ mycount--;
++ croot = croot->next;
++ }
++
++ if (mycount || (croot != NULL))
++ warning
++ ("varobj_refresh: assertion failed - wrong tally of root vars (%d:%d)",
++ rootcount, mycount);
++}
++
++
+ /* Update the values for a variable and its children. This is a
+ two-pronged attack. First, re-parse the value for the root's
+ expression to see if it's changed. Then go all the way
+Index: gdb/solist.h
+===================================================================
+--- a/gdb/solist.h 2008-01-07 16:19:58.000000000 +0100
++++ b/gdb/solist.h 2008-02-27 08:57:31.000000000 +0100
+@@ -61,6 +61,8 @@ struct so_list
+ bfd *abfd;
+ char symbols_loaded; /* flag: symbols read in yet? */
+ char from_tty; /* flag: print msgs? */
++ char main; /* flag: is this the main executable? */
++ char main_relocated; /* flag: has it been relocated yet? */
+ struct objfile *objfile; /* objfile for loaded lib */
+ struct section_table *sections;
+ struct section_table *sections_end;
+@@ -127,9 +129,15 @@ void free_so (struct so_list *so);
+ /* Return address of first so_list entry in master shared object list. */
+ struct so_list *master_so_list (void);
+
++/* Return address of first so_list entry in master shared object list. */
++struct so_list *master_so_list (void);
++
+ /* Find solib binary file and open it. */
+ extern int solib_open (char *in_pathname, char **found_pathname);
+
++/* Add the list of sections in so_list to the target to_sections. */
++extern void add_to_target_sections (int, struct target_ops *, struct so_list *);
++
+ /* FIXME: gdbarch needs to control this variable */
+ extern struct target_so_ops *current_target_so_ops;
+
+@@ -140,4 +148,6 @@ struct symbol *solib_global_lookup (cons
+ const domain_enum domain,
+ struct symtab **symtab);
+
++/* Controls the printing of debugging output. */
++extern int debug_solib;
+ #endif
+Index: gdb/varobj.h
+===================================================================
+--- a/gdb/varobj.h 2008-01-30 08:17:31.000000000 +0100
++++ b/gdb/varobj.h 2008-02-27 08:57:31.000000000 +0100
+@@ -122,4 +122,6 @@ extern void varobj_invalidate (void);
+
+ extern int varobj_editable_p (struct varobj *var);
+
++extern void varobj_refresh(void);
++
+ #endif /* VAROBJ_H */
+Index: gdb/symfile.c
+===================================================================
+--- a/gdb/symfile.c 2008-01-29 23:47:20.000000000 +0100
++++ b/gdb/symfile.c 2008-02-27 08:57:31.000000000 +0100
+@@ -47,6 +47,7 @@
+ #include "readline/readline.h"
+ #include "gdb_assert.h"
+ #include "block.h"
++#include "varobj.h"
+ #include "observer.h"
+ #include "exec.h"
+ #include "parser-defs.h"
+@@ -778,7 +779,7 @@ syms_from_objfile (struct objfile *objfi
+
+ /* Now either addrs or offsets is non-zero. */
+
+- if (mainline)
++ if (mainline == 1)
+ {
+ /* We will modify the main symbol table, make sure that all its users
+ will be cleaned up if an error occurs during symbol reading. */
+@@ -806,7 +807,7 @@ syms_from_objfile (struct objfile *objfi
+
+ We no longer warn if the lowest section is not a text segment (as
+ happens for the PA64 port. */
+- if (!mainline && addrs && addrs->other[0].name)
++ if (/*!mainline &&*/ addrs && addrs->other[0].name)
+ {
+ asection *lower_sect;
+ asection *sect;
+@@ -975,17 +976,21 @@ new_symfile_objfile (struct objfile *obj
+ /* If this is the main symbol file we have to clean up all users of the
+ old main symbol file. Otherwise it is sufficient to fixup all the
+ breakpoints that may have been redefined by this symbol file. */
+- if (mainline)
++ if (mainline == 1)
+ {
+ /* OK, make it the "real" symbol file. */
+ symfile_objfile = objfile;
+
+ clear_symtab_users ();
+ }
+- else
++ else if (mainline == 0)
+ {
+ breakpoint_re_set ();
+ }
++ else
++ {
++ /* Don't reset breakpoints or it will screw up PIE. */
++ }
+
+ /* We're done reading the symbol file; finish off complaints. */
+ clear_complaints (&symfile_complaints, 0, verbo);
+@@ -1028,7 +1033,7 @@ symbol_file_add_with_addrs_or_offsets (b
+ interactively wiping out any existing symbols. */
+
+ if ((have_full_symbols () || have_partial_symbols ())
+- && mainline
++ && (mainline == 1)
+ && from_tty
+ && !query ("Load new symbol table from \"%s\"? ", name))
+ error (_("Not confirmed."));
+@@ -1212,6 +1217,10 @@ symbol_file_clear (int from_tty)
+ symfile_objfile->name)
+ : !query (_("Discard symbol table? "))))
+ error (_("Not confirmed."));
++#ifdef CLEAR_SOLIB
++ CLEAR_SOLIB ();
++#endif
++
+ free_all_objfiles ();
+
+ /* solib descriptors may have handles to objfiles. Since their
+@@ -2466,6 +2475,8 @@ reread_symbols (void)
+ /* Discard cleanups as symbol reading was successful. */
+ discard_cleanups (old_cleanups);
+
++ init_entry_point_info (objfile);
++
+ /* If the mtime has changed between the time we set new_modtime
+ and now, we *want* this to be out of date, so don't call stat
+ again now. */
+@@ -2834,6 +2845,7 @@ clear_symtab_users (void)
+ breakpoint_re_set ();
+ set_default_breakpoint (0, 0, 0, 0);
+ clear_pc_function_cache ();
++ varobj_refresh ();
+ observer_notify_new_objfile (NULL);
+
+ /* Clear globals which might have pointed into a removed objfile.
+Index: gdb/breakpoint.c
+===================================================================
+--- a/gdb/breakpoint.c 2008-02-27 08:57:20.000000000 +0100
++++ b/gdb/breakpoint.c 2008-02-27 08:57:31.000000000 +0100
+@@ -923,7 +923,7 @@ update_watchpoint (struct breakpoint *b,
+ value_release_to_mark (mark);
+
+ /* Look at each value on the value chain. */
+- for (; v; v = next)
++ for (; v; v = value_next (v))
+ {
+ /* If it's a memory location, and GDB actually needed
+ its contents to evaluate the expression, then we
+@@ -3882,7 +3882,8 @@ describe_other_breakpoints (CORE_ADDR pc
+ printf_filtered (" (thread %d)", b->thread);
+ printf_filtered ("%s%s ",
+ ((b->enable_state == bp_disabled ||
+- b->enable_state == bp_call_disabled)
++ b->enable_state == bp_call_disabled ||
++ b->enable_state == bp_startup_disabled)
+ ? " (disabled)"
+ : b->enable_state == bp_permanent
+ ? " (permanent)"
+@@ -4534,6 +4535,62 @@ disable_breakpoints_in_unloaded_shlib (s
+ }
+ }
+
++void
++disable_breakpoints_at_startup (int silent)
++{
++ struct breakpoint *b;
++ int disabled_startup_breaks = 0;
++
++ if (bfd_get_start_address (exec_bfd) != entry_point_address ())
++ {
++ ALL_BREAKPOINTS (b)
++ {
++ if (((b->type == bp_breakpoint) ||
++ (b->type == bp_hardware_breakpoint)) &&
++ b->enable_state == bp_enabled &&
++ !b->loc->duplicate)
++ {
++ b->enable_state = bp_startup_disabled;
++ if (!silent)
++ {
++ if (!disabled_startup_breaks)
++ {
++ target_terminal_ours_for_output ();
++ warning ("Temporarily disabling breakpoints:");
++ }
++ disabled_startup_breaks = 1;
++ warning ("breakpoint #%d addr 0x%s", b->number, paddr_nz(b->loc->address));
++ }
++ }
++ }
++ }
++}
++
++/* Try to reenable any breakpoints after startup. */
++void
++re_enable_breakpoints_at_startup (void)
++{
++ struct breakpoint *b;
++
++ if (bfd_get_start_address (exec_bfd) != entry_point_address ())
++ {
++ ALL_BREAKPOINTS (b)
++ if (b->enable_state == bp_startup_disabled)
++ {
++ char buf[1];
++
++ /* Do not reenable the breakpoint if the shared library
++ is still not mapped in. */
++ if (target_read_memory (b->loc->address, buf, 1) == 0)
++ {
++ /*printf ("enabling breakpoint at 0x%s\n", paddr_nz(b->loc->address));*/
++ b->enable_state = bp_enabled;
++ }
++ }
++ }
++}
++
++
+ static void
+ create_fork_vfork_event_catchpoint (int tempflag, char *cond_string,
+ enum bptype bp_kind)
+Index: gdb/solib.c
+===================================================================
+--- a/gdb/solib.c 2008-01-07 16:19:58.000000000 +0100
++++ b/gdb/solib.c 2008-02-27 08:57:31.000000000 +0100
+@@ -79,6 +79,8 @@ set_solib_ops (struct gdbarch *gdbarch,
+
+ /* external data declarations */
+
++int debug_solib;
++
+ /* FIXME: gdbarch needs to control this variable, or else every
+ configuration needs to call set_solib_ops. */
+ struct target_so_ops *current_target_so_ops;
+@@ -102,6 +104,8 @@ The search path for loading non-absolute
+ value);
+ }
+
++void add_to_target_sections (int, struct target_ops *, struct so_list *);
++
+ /*
+
+ GLOBAL FUNCTION
+@@ -391,7 +395,6 @@ free_so (struct so_list *so)
+ xfree (so);
+ }
+
+-
+ /* Return address of first so_list entry in master shared object list. */
+ struct so_list *
+ master_so_list (void)
+@@ -399,7 +402,6 @@ master_so_list (void)
+ return so_list_head;
+ }
+
+-
+ /* A small stub to get us past the arg-passing pinhole of catch_errors. */
+
+ static int
+@@ -411,15 +413,40 @@ symbol_add_stub (void *arg)
+ /* Have we already loaded this shared object? */
+ ALL_OBJFILES (so->objfile)
+ {
+- if (strcmp (so->objfile->name, so->so_name) == 0)
++ /* Found an already loaded shared library. */
++ if (strcmp (so->objfile->name, so->so_name) == 0
++ && !so->main)
+ return 1;
++ /* Found an already loaded main executable. This could happen in
++ two circumstances.
++ First case: the main file has already been read in
++ as the first thing that gdb does at startup, and the file
++ hasn't been relocated properly yet. Therefor we need to read
++ it in with the proper section info.
++ Second case: it has been read in with the correct relocation,
++ and therefore we need to skip it. */
++ if (strcmp (so->objfile->name, so->so_name) == 0
++ && so->main
++ && so->main_relocated)
++ return 1;
+ }
+
+ sap = build_section_addr_info_from_section_table (so->sections,
+ so->sections_end);
+
+- so->objfile = symbol_file_add (so->so_name, so->from_tty,
+- sap, 0, OBJF_SHARED);
++ if (so->main)
++ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "symbol_add_stub: adding symbols for main\n");
++ so->objfile = symbol_file_add (so->so_name, /*so->from_tty*/ 0,
++ sap, 1, 0);
++ so->main_relocated = 1;
++ }
++ else
++ so->objfile = symbol_file_add (so->so_name, so->from_tty,
++ sap, 0, OBJF_SHARED);
++
+ free_section_addr_info (sap);
+
+ return (1);
+@@ -545,6 +572,10 @@ update_solib_list (int from_tty, struct
+ }
+ else
+ {
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "update_solib_list: compare gdb:%s and inferior:%s\n",
++ gdb->so_original_name, i->so_original_name);
+ if (! strcmp (gdb->so_original_name, i->so_original_name))
+ break;
+ }
+@@ -599,28 +630,7 @@ update_solib_list (int from_tty, struct
+ /* Fill in the rest of each of the `struct so_list' nodes. */
+ for (i = inferior; i; i = i->next)
+ {
+- i->from_tty = from_tty;
+-
+- /* Fill in the rest of the `struct so_list' node. */
+- catch_errors (solib_map_sections, i,
+- "Error while mapping shared library sections:\n",
+- RETURN_MASK_ALL);
+-
+- /* If requested, add the shared object's sections to the TARGET's
+- section table. Do this immediately after mapping the object so
+- that later nodes in the list can query this object, as is needed
+- in solib-osf.c. */
+- if (target)
+- {
+- int count = (i->sections_end - i->sections);
+- if (count > 0)
+- {
+- int space = target_resize_to_sections (target, count);
+- memcpy (target->to_sections + space,
+- i->sections,
+- count * sizeof (i->sections[0]));
+- }
+- }
++ add_to_target_sections (from_tty, target, i);
+
+ /* Notify any observer that the shared object has been
+ loaded now that we've added it to GDB's tables. */
+@@ -716,6 +726,41 @@ solib_add (char *pattern, int from_tty,
+ }
+ }
+
++void
++add_to_target_sections (int from_tty, struct target_ops *target, struct so_list *solib)
++{
++ /* If this is set, then the sections have been already added to the
++ target list. */
++ if (solib->main)
++ return;
++
++ solib->from_tty = from_tty;
++
++ /* Fill in the rest of the `struct so_list' node. */
++ catch_errors (solib_map_sections, solib,
++ "Error while mapping shared library sections:\n",
++ RETURN_MASK_ALL);
++
++ /* If requested, add the shared object's sections to the TARGET's
++ section table. Do this immediately after mapping the object so
++ that later nodes in the list can query this object, as is needed
++ in solib-osf.c. */
++ if (target)
++ {
++ int count = (solib->sections_end - solib->sections);
++ if (count > 0)
++ {
++ int space = target_resize_to_sections (target, count);
++ if (debug_solib)
++ fprintf_unfiltered (gdb_stdlog,
++ "add_to_target_sections: add %s to to_sections\n",
++ solib->so_original_name);
++ memcpy (target->to_sections + space,
++ solib->sections,
++ count * sizeof (solib->sections[0]));
++ }
++ }
++}
+
+ /*
+
+@@ -1035,4 +1080,12 @@ This takes precedence over the environme
+ reload_shared_libraries,
+ show_solib_search_path,
+ &setlist, &showlist);
++
++ add_setshow_boolean_cmd ("solib", no_class, &debug_solib,
++ _("\
++Set debugging of GNU/Linux shlib module.\n"), _("\
++Show debugging status of GNU/Linux shlib module.\n"), _("\
++Enables printf debugging output of GNU/Linux shlib module.\n"),
++ NULL, NULL,
++ &setdebuglist, &showdebuglist);
+ }
+Index: gdb/elfread.c
+===================================================================
+--- a/gdb/elfread.c 2008-01-01 23:53:09.000000000 +0100
++++ b/gdb/elfread.c 2008-02-27 08:57:31.000000000 +0100
+@@ -644,7 +644,7 @@ elf_symfile_read (struct objfile *objfil
+ /* If we are reinitializing, or if we have never loaded syms yet,
+ set table to empty. MAINLINE is cleared so that *_read_psymtab
+ functions do not all also re-initialize the psymbol table. */
+- if (mainline)
++ if (mainline == 1)
+ {
+ init_psymbol_list (objfile, 0);
+ mainline = 0;
+Index: gdb/Makefile.in
+===================================================================
+--- a/gdb/Makefile.in 2008-02-27 08:57:20.000000000 +0100
++++ b/gdb/Makefile.in 2008-02-27 08:57:31.000000000 +0100
+@@ -1914,7 +1914,7 @@ amd64-tdep.o: amd64-tdep.c $(defs_h) $(a
+ $(dummy_frame_h) $(frame_h) $(frame_base_h) $(frame_unwind_h) \
+ $(inferior_h) $(gdbcmd_h) $(gdbcore_h) $(objfiles_h) $(regcache_h) \
+ $(regset_h) $(symfile_h) $(gdb_assert_h) $(amd64_tdep_h) \
+- $(i387_tdep_h)
++ $(i387_tdep_h) $(exceptions_h)
+ annotate.o: annotate.c $(defs_h) $(annotate_h) $(value_h) $(target_h) \
+ $(gdbtypes_h) $(breakpoint_h)
+ arch-utils.o: arch-utils.c $(defs_h) $(arch_utils_h) $(buildsym_h) \
+Index: gdb/amd64-tdep.c
+===================================================================
+--- a/gdb/amd64-tdep.c 2008-02-27 08:57:19.000000000 +0100
++++ b/gdb/amd64-tdep.c 2008-02-27 08:57:31.000000000 +0100
+@@ -36,6 +36,7 @@
+ #include "symfile.h"
+ #include "dwarf2-frame.h"
+ #include "gdb_assert.h"
++#include "exceptions.h"
+
+ #include "amd64-tdep.h"
+ #include "i387-tdep.h"
+@@ -731,16 +732,28 @@ amd64_alloc_frame_cache (void)
+ Any function that doesn't start with this sequence will be assumed
+ to have no prologue and thus no valid frame pointer in %rbp. */
+
+-static CORE_ADDR
+-amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+- struct amd64_frame_cache *cache)
++struct amd64_analyze_prologue_data
++ {
++ CORE_ADDR pc, current_pc;
++ struct amd64_frame_cache *cache;
++ CORE_ADDR retval;
++ };
++
++static int
++amd64_analyze_prologue_1 (void *data_pointer)
+ {
++ struct amd64_analyze_prologue_data *data = data_pointer;
++ CORE_ADDR pc = data->pc, current_pc = data->current_pc;
++ struct amd64_frame_cache *cache = data->cache;
+ static gdb_byte proto[3] = { 0x48, 0x89, 0xe5 }; /* movq %rsp, %rbp */
+ gdb_byte buf[3];
+ gdb_byte op;
+
+ if (current_pc <= pc)
+- return current_pc;
++ {
++ data->retval = current_pc;
++ return 1;
++ }
+
+ op = read_memory_unsigned_integer (pc, 1);
+
+@@ -753,18 +766,57 @@ amd64_analyze_prologue (CORE_ADDR pc, CO
+
+ /* If that's all, return now. */
+ if (current_pc <= pc + 1)
+- return current_pc;
++ {
++ data->retval = current_pc;
++ return 1;
++ }
+
+ /* Check for `movq %rsp, %rbp'. */
+ read_memory (pc + 1, buf, 3);
+ if (memcmp (buf, proto, 3) != 0)
+- return pc + 1;
++ {
++ data->retval = pc + 1;
++ return 1;
++ }
+
+ /* OK, we actually have a frame. */
+ cache->frameless_p = 0;
+- return pc + 4;
++ data->retval = pc + 4;
++ return 1;
+ }
+
++ data->retval = pc;
++ return 1;
++}
++
++/* Catch memory read errors and return just PC in such case.
++ It occurs very early on enable_break->new_symfile_objfile->
++ ->breakpoint_re_set->decode_line_1->decode_variable_1->
++ ->find_function_start_sal */
++
++static CORE_ADDR
++amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
++ struct amd64_frame_cache *cache)
++{
++ int status;
++ struct amd64_analyze_prologue_data data;
++ struct ui_file *saved_gdb_stderr;
++
++ /* Suppress error messages. */
++ saved_gdb_stderr = gdb_stderr;
++ gdb_stderr = ui_file_new ();
++
++ data.pc = pc;
++ data.current_pc = current_pc;
++ data.cache = cache;
++ status = catch_errors (amd64_analyze_prologue_1, &data, "", RETURN_MASK_ALL);
++
++ /* Stop suppressing error messages. */
++ ui_file_delete (gdb_stderr);
++ gdb_stderr = saved_gdb_stderr;
++
++ if (status)
++ return data.retval;
+ return pc;
+ }
+
diff --git a/main/gdb/50_all_gdb-pie-2.patch b/main/gdb/50_all_gdb-pie-2.patch
new file mode 100644
index 00000000000..946d0550181
--- /dev/null
+++ b/main/gdb/50_all_gdb-pie-2.patch
@@ -0,0 +1,2122 @@
+Index: gdb-6.8/gdb/testsuite/configure
+===================================================================
+--- gdb-6.8.orig/gdb/testsuite/configure 2007-12-29 06:01:30.000000000 -0800
++++ gdb-6.8/gdb/testsuite/configure 2008-03-30 09:00:52.000000000 -0700
+@@ -3104,7 +3104,7 @@
+
+
+
+- ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
++ ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.pie/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
+ cat >confcache <<\_ACEOF
+ # This file is a shell script that caches the results of configure
+ # tests run on this system so they can be shared between configure
+@@ -3665,6 +3665,7 @@
+ "gdb.dwarf2/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.dwarf2/Makefile" ;;
+ "gdb.fortran/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.fortran/Makefile" ;;
+ "gdb.server/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.server/Makefile" ;;
++ "gdb.pie/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.pie/Makefile" ;;
+ "gdb.java/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.java/Makefile" ;;
+ "gdb.mi/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.mi/Makefile" ;;
+ "gdb.modula2/Makefile" ) CONFIG_FILES="$CONFIG_FILES gdb.modula2/Makefile" ;;
+Index: gdb-6.8/gdb/testsuite/configure.ac
+===================================================================
+--- gdb-6.8.orig/gdb/testsuite/configure.ac 2007-10-25 13:30:26.000000000 -0700
++++ gdb-6.8/gdb/testsuite/configure.ac 2008-03-30 09:00:22.000000000 -0700
+@@ -114,7 +114,7 @@
+ gdb.ada/Makefile \
+ gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
+ gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \
+- gdb.fortran/Makefile gdb.server/Makefile \
++ gdb.fortran/Makefile gdb.server/Makefile gdb.pie/Makefile \
+ gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile \
+ gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
+ gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
+Index: gdb-6.8/gdb/testsuite/gdb.pie/Makefile.in
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/Makefile.in 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,19 @@
++VPATH = @srcdir@
++srcdir = @srcdir@
++
++EXECUTABLES =
++MISCELLANEOUS = arch.inc
++
++all info install-info dvi install uninstall installcheck check:
++ @echo "Nothing to be done for $@..."
++
++clean mostlyclean:
++ -rm -f *~ *.o a.out *.x *.ci *.tmp
++ -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES)
++ -rm -f $(MISCELLANEOUS)
++
++distclean maintainer-clean realclean: clean
++ -rm -f *~ core
++ -rm -f Makefile config.status config.log
++ -rm -f *-init.exp
++ -rm -fr *.log summary detail *.plog *.sum *.psum site.*
+Index: gdb-6.8/gdb/testsuite/gdb.pie/attach.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/attach.c 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,20 @@
++/* This program is intended to be started outside of gdb, and then
++ attached to by gdb. Thus, it simply spins in a loop. The loop
++ is exited when & if the variable 'should_exit' is non-zero. (It
++ is initialized to zero in this program, so the loop will never
++ exit unless/until gdb sets the variable to non-zero.)
++ */
++#include <stdio.h>
++
++int should_exit = 0;
++
++int main ()
++{
++ int local_i = 0;
++
++ while (! should_exit)
++ {
++ local_i++;
++ }
++ return 0;
++}
+Index: gdb-6.8/gdb/testsuite/gdb.pie/attach.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/attach.exp 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,432 @@
++# Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
++
++# 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. */
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++if $tracelevel then {
++ strace $tracelevel
++ }
++
++set prms_id 0
++set bug_id 0
++
++# On HP-UX 11.0, this test is causing a process running the program
++# "attach" to be left around spinning. Until we figure out why, I am
++# commenting out the test to avoid polluting tiamat (our 11.0 nightly
++# test machine) with these processes. RT
++#
++# Setting the magic bit in the target app should work. I added a
++# "kill", and also a test for the R3 register warning. JB
++if { [istarget "hppa*-*-hpux*"] } {
++ return 0
++}
++
++# are we on a target board
++if [is_remote target] then {
++ return 0
++}
++
++set testfile "attach"
++set srcfile ${testfile}.c
++set srcfile2 ${testfile}2.c
++set binfile ${objdir}/${subdir}/${testfile}
++set binfile2 ${objdir}/${subdir}/${testfile}2
++set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
++set cleanupfile ${objdir}/${subdir}/${testfile}.awk
++
++#execute_anywhere "rm -f ${binfile} ${binfile2}"
++remote_exec build "rm -f ${binfile} ${binfile2}"
++# For debugging this test
++#
++#log_user 1
++
++# Clean out any old files from past runs.
++#
++remote_exec build "${cleanupfile}"
++
++# build the first test case
++#
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++# Build the in-system-call test
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if [get_compiler_info ${binfile}] {
++ return -1
++}
++
++proc do_attach_tests {} {
++ global gdb_prompt
++ global binfile
++ global escapedbinfile
++ global srcfile
++ global testfile
++ global objdir
++ global subdir
++ global timeout
++
++ # Start the program running and then wait for a bit, to be sure
++ # that it can be attached to.
++ #
++ set testpid [eval exec $binfile &]
++ exec sleep 2
++
++ # Verify that we cannot attach to nonsense.
++ #
++ send_gdb "attach abc\n"
++ gdb_expect {
++ -re ".*Illegal process-id: abc.*$gdb_prompt $"\
++ {pass "attach to nonsense is prohibited"}
++ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
++ {
++ # Response expected from /proc-based systems.
++ pass "attach to nonsense is prohibited"
++ }
++ -re "Attaching to.*$gdb_prompt $"\
++ {fail "attach to nonsense is prohibited (bogus pid allowed)"}
++ -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"}
++ timeout {fail "(timeout) attach to nonsense is prohibited"}
++ }
++
++ # Verify that we cannot attach to what appears to be a valid
++ # process ID, but is a process that doesn't exist. Traditionally,
++ # most systems didn't have a process with ID 0, so we take that as
++ # the default. However, there are a few exceptions.
++ #
++ set boguspid 0
++ if { [istarget "*-*-*bsd*"] } {
++ # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead
++ # (which should have the desired effect on any version of
++ # FreeBSD, and probably other *BSD's too).
++ set boguspid -1
++ }
++ send_gdb "attach $boguspid\n"
++ gdb_expect {
++ -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\
++ {
++ # Response expected on ptrace-based systems (i.e. HP-UX 10.20).
++ pass "attach to nonexistent process is prohibited"
++ }
++ -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\
++ {
++ # Response expected on ttrace-based systems (i.e. HP-UX 11.0).
++ pass "attach to nonexistent process is prohibited"
++ }
++ -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\
++ {pass "attach to nonexistent process is prohibited"}
++ -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\
++ {pass "attach to nonexistent process is prohibited"}
++ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
++ {
++ # Response expected from /proc-based systems.
++ pass "attach to nonexistent process is prohibited"
++ }
++ -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"}
++ timeout {
++ fail "(timeout) attach to nonexistent process is prohibited"
++ }
++ }
++
++ # Verify that we can attach to the process by first giving its
++ # executable name via the file command, and using attach with
++ # the process ID.
++ #
++ # (Actually, the test system appears to do this automatically
++ # for us. So, we must also be prepared to be asked if we want
++ # to discard an existing set of symbols.)
++ #
++ send_gdb "file $binfile\n"
++ gdb_expect {
++ -re "Load new symbol table from.*y or n.*$" {
++ send_gdb "y\n"
++ gdb_expect {
++ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
++ {pass "(re)set file, before attach1"}
++ -re "$gdb_prompt $" {fail "(re)set file, before attach1"}
++ timeout {fail "(timeout) (re)set file, before attach1"}
++ }
++ }
++ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
++ {pass "set file, before attach1"}
++ -re "$gdb_prompt $" {fail "set file, before attach1"}
++ timeout {fail "(timeout) set file, before attach1"}
++ }
++
++ send_gdb "attach $testpid\n"
++ gdb_expect {
++ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\
++ {pass "attach1, after setting file"}
++ -re "$gdb_prompt $" {fail "attach1, after setting file"}
++ timeout {fail "(timeout) attach1, after setting file"}
++ }
++
++ # Verify that we can "see" the variable "should_exit" in the
++ # program, and that it is zero.
++ #
++ send_gdb "print should_exit\n"
++ gdb_expect {
++ -re ".* = 0.*$gdb_prompt $"\
++ {pass "after attach1, print should_exit"}
++ -re "$gdb_prompt $" {fail "after attach1, print should_exit"}
++ timeout {fail "(timeout) after attach1, print should_exit"}
++ }
++
++ # Detach the process.
++ #
++ send_gdb "detach\n"
++ gdb_expect {
++ -re "Detaching from program: .*$escapedbinfile.*$gdb_prompt $"\
++ {pass "attach1 detach"}
++ -re "$gdb_prompt $" {fail "attach1 detach"}
++ timeout {fail "(timeout) attach1 detach"}
++ }
++
++ # Wait a bit for gdb to finish detaching
++ #
++ exec sleep 5
++
++ # Purge the symbols from gdb's brain. (We want to be certain
++ # the next attach, which won't be preceded by a "file" command,
++ # is really getting the executable file without our help.)
++ #
++ set old_timeout $timeout
++ set timeout 15
++ send_gdb "file\n"
++ gdb_expect {
++ -re ".*gdb internal error.*$" {
++ fail "Internal error, prob. Memory corruption"
++ }
++ -re "No executable file now.*Discard symbol table.*y or n.*$" {
++ send_gdb "y\n"
++ gdb_expect {
++ -re "No symbol file now.*$gdb_prompt $"\
++ {pass "attach1, purging symbols after detach"}
++ -re "$gdb_prompt $" {fail "attach1, purging symbols after detach"}
++ timeout {fail "(timeout) attach1, purging symbols after detach"}
++ }
++ }
++ -re "$gdb_prompt $" {fail "attach1, purging file after detach"}
++ timeout {
++ fail "(timeout) attach1, purging file after detach"
++ }
++ }
++ set timeout $old_timeout
++
++ # Verify that we can attach to the process just by giving the
++ # process ID.
++ #
++ send_gdb "attach $testpid\n"
++ gdb_expect {
++ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
++ {pass "attach2"}
++ -re "$gdb_prompt $" {fail "attach2"}
++ timeout {fail "(timeout) attach2"}
++ }
++
++ # Verify that we can modify the variable "should_exit" in the
++ # program.
++ #
++ send_gdb "set should_exit=1\n"
++ gdb_expect {
++ -re "$gdb_prompt $" {pass "after attach2, set should_exit"}
++ timeout {fail "(timeout) after attach2, set should_exit"}
++ }
++
++ # Verify that the modification really happened.
++ #
++ send_gdb "tbreak 19\n"
++ gdb_expect {
++ -re "Breakpoint .*at.*$srcfile, line 19.*$gdb_prompt $"\
++ {pass "after attach2, set tbreak postloop"}
++ -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"}
++ timeout {fail "(timeout) after attach2, set tbreak postloop"}
++ }
++ send_gdb "continue\n"
++ gdb_expect {
++ -re "main.*at.*$srcfile:19.*$gdb_prompt $"\
++ {pass "after attach2, reach tbreak postloop"}
++ -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"}
++ timeout {fail "(timeout) after attach2, reach tbreak postloop"}
++ }
++
++ # Allow the test process to exit, to cleanup after ourselves.
++ #
++ send_gdb "continue\n"
++ gdb_expect {
++ -re "Program exited normally.*$gdb_prompt $"\
++ {pass "after attach2, exit"}
++ -re "$gdb_prompt $" {fail "after attach2, exit"}
++ timeout {fail "(timeout) after attach2, exit"}
++ }
++
++ # Make sure we don't leave a process around to confuse
++ # the next test run (and prevent the compile by keeping
++ # the text file busy), in case the "set should_exit" didn't
++ # work.
++ #
++ remote_exec build "kill -9 ${testpid}"
++ # Start the program running and then wait for a bit, to be sure
++ # that it can be attached to.
++ #
++ set testpid [eval exec $binfile &]
++ exec sleep 2
++
++ # Verify that we can attach to the process, and find its a.out
++ # when we're cd'd to some directory that doesn't contain the
++ # a.out. (We use the source path set by the "dir" command.)
++ #
++ send_gdb "dir ${objdir}/${subdir}\n"
++ gdb_expect {
++ -re ".*Source directories searched: .*$gdb_prompt $"\
++ {pass "set source path"}
++ -re "$gdb_prompt $" {fail "set source path"}
++ timeout {fail "(timeout) set source path"}
++ }
++
++ send_gdb "cd /tmp\n"
++ gdb_expect {
++ -re ".*Working directory /tmp.*$gdb_prompt $"\
++ {pass "cd away from process' a.out"}
++ -re "$gdb_prompt $" {fail "cd away from process' a.out"}
++ timeout {fail "(timeout) cd away from process' a.out"}
++ }
++
++ # Explicitly flush out any knowledge of the previous attachment.
++ send_gdb "symbol\n"
++ gdb_expect {
++ -re ".*Discard symbol table from.*y or n. $"\
++ {send_gdb "y\n"
++ gdb_expect {
++ -re ".*No symbol file now.*$gdb_prompt $"\
++ {pass "before attach3, flush symbols"}
++ -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
++ timeout {fail "(timeout) before attach3, flush symbols"}
++ }
++ }
++ -re ".*No symbol file now.*$gdb_prompt $"\
++ {pass "before attach3, flush symbols"}
++ -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
++ timeout {fail "(timeout) before attach3, flush symbols"}
++ }
++ send_gdb "exec\n"
++ gdb_expect {
++ -re ".*No executable file now.*$gdb_prompt $"\
++ {pass "before attach3, flush exec"}
++ -re "$gdb_prompt $" {fail "before attach3, flush exec"}
++ timeout {fail "(timeout) before attach3, flush exec"}
++ }
++
++ send_gdb "attach $testpid\n"
++ gdb_expect {
++ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
++ {pass "attach when process' a.out not in cwd"}
++ -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"}
++ timeout {fail "(timeout) attach when process' a.out not in cwd"}
++ }
++
++ send_gdb "kill\n"
++ gdb_expect {
++ -re ".*Kill the program being debugged.*y or n. $"\
++ {send_gdb "y\n"
++ gdb_expect {
++ -re "$gdb_prompt $" {pass "after attach3, exit"}
++ timeout {fail "(timeout) after attach3, exit"}
++ }
++ }
++ -re "$gdb_prompt $" {fail "after attach3, exit"}
++ timeout {fail "(timeout) after attach3, exit"}
++ }
++
++ # Another "don't leave a process around"
++ remote_exec build "kill -9 ${testpid}"
++}
++
++proc do_call_attach_tests {} {
++ global gdb_prompt
++ global binfile2
++
++ # Start the program running and then wait for a bit, to be sure
++ # that it can be attached to.
++ #
++ set testpid [eval exec $binfile2 &]
++ exec sleep 2
++
++ # Attach
++ #
++ gdb_test "file $binfile2" ".*" "force switch to gdb64, if necessary"
++ send_gdb "attach $testpid\n"
++ gdb_expect {
++ -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" {
++ fail "attach call, read register 3 error"
++ }
++ -re "Attaching to.*process $testpid.*libc.*$gdb_prompt $" {
++ pass "attach call"
++ }
++ -re "$gdb_prompt $" {fail "attach call"}
++ timeout {fail "(timeout) attach call"}
++ }
++
++ # See if other registers are problems
++ #
++ send_gdb "i r r3\n"
++ gdb_expect {
++ -re ".*warning: reading register.*$gdb_prompt $" {
++ pass "CHFts23490: known bug"
++ }
++ -re ".*r3.*$gdb_prompt $" {
++ pass "Bug fixed, Yayyy!"
++ }
++ timeout { fail "timeout on info reg" }
++ }
++
++ # Get rid of the process
++ #
++ gdb_test "p should_exit = 1" ".*"
++ gdb_test "c" ".*Program exited normally.*"
++
++ # Be paranoid
++ #
++ remote_exec build "kill -9 ${testpid}"
++
++}
++
++
++# Start with a fresh gdb
++#
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++# This is a test of gdb's ability to attach to a running process.
++#
++do_attach_tests
++
++# Test attaching when the target is inside a system call
++#
++gdb_exit
++gdb_start
++
++gdb_reinitialize_dir $srcdir/$subdir
++do_call_attach_tests
++
++return 0
+Index: gdb-6.8/gdb/testsuite/gdb.pie/attach2.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/attach2.c 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,24 @@
++/* This program is intended to be started outside of gdb, and then
++ attached to by gdb. Thus, it simply spins in a loop. The loop
++ is exited when & if the variable 'should_exit' is non-zero. (It
++ is initialized to zero in this program, so the loop will never
++ exit unless/until gdb sets the variable to non-zero.)
++ */
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++
++int should_exit = 0;
++
++int main ()
++{
++ int local_i = 0;
++
++ sleep( 10 ); /* System call causes register fetch to fail */
++ /* This is a known HPUX "feature" */
++ while (! should_exit)
++ {
++ local_i++;
++ }
++ return (0);
++}
+Index: gdb-6.8/gdb/testsuite/gdb.pie/break.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/break.c 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,146 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
++ Foundation, Inc.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++#ifdef vxworks
++
++# include <stdio.h>
++
++/* VxWorks does not supply atoi. */
++static int
++atoi (z)
++ char *z;
++{
++ int i = 0;
++
++ while (*z >= '0' && *z <= '9')
++ i = i * 10 + (*z++ - '0');
++ return i;
++}
++
++/* I don't know of any way to pass an array to VxWorks. This function
++ can be called directly from gdb. */
++
++vxmain (arg)
++char *arg;
++{
++ char *argv[2];
++
++ argv[0] = "";
++ argv[1] = arg;
++ main (2, argv, (char **) 0);
++}
++
++#else /* ! vxworks */
++# include <stdio.h>
++# include <stdlib.h>
++#endif /* ! vxworks */
++
++#ifdef PROTOTYPES
++extern int marker1 (void);
++extern int marker2 (int a);
++extern void marker3 (char *a, char *b);
++extern void marker4 (long d);
++#else
++extern int marker1 ();
++extern int marker2 ();
++extern void marker3 ();
++extern void marker4 ();
++#endif
++
++/*
++ * This simple classical example of recursion is useful for
++ * testing stack backtraces and such.
++ */
++
++#ifdef PROTOTYPES
++int factorial(int);
++
++int
++main (int argc, char **argv, char **envp)
++#else
++int
++main (argc, argv, envp)
++int argc;
++char *argv[], **envp;
++#endif
++{
++#ifdef usestubs
++ set_debug_traps(); /* set breakpoint 5 here */
++ breakpoint();
++#endif
++ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
++ fprintf (stderr, "usage: factorial <number>\n");
++ return 1;
++ }
++ printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
++ /* set breakpoint 12 here */
++ marker1 (); /* set breakpoint 11 here */
++ marker2 (43); /* set breakpoint 20 here */
++ marker3 ("stack", "trace"); /* set breakpoint 21 here */
++ marker4 (177601976L);
++ argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
++ return argc; /* set breakpoint 10 here */
++}
++
++#ifdef PROTOTYPES
++int factorial (int value)
++#else
++int factorial (value)
++int value;
++#endif
++{
++ if (value > 1) { /* set breakpoint 7 here */
++ value *= factorial (value - 1);
++ }
++ return (value); /* set breakpoint 19 here */
++}
++
++#ifdef PROTOTYPES
++int multi_line_if_conditional (int a, int b, int c)
++#else
++int multi_line_if_conditional (a, b, c)
++ int a, b, c;
++#endif
++{
++ if (a /* set breakpoint 3 here */
++ && b
++ && c)
++ return 0;
++ else
++ return 1;
++}
++
++#ifdef PROTOTYPES
++int multi_line_while_conditional (int a, int b, int c)
++#else
++int multi_line_while_conditional (a, b, c)
++ int a, b, c;
++#endif
++{
++ while (a /* set breakpoint 4 here */
++ && b
++ && c)
++ {
++ a--, b--, c--;
++ }
++ return 0;
++}
+Index: gdb-6.8/gdb/testsuite/gdb.pie/break.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/break.exp 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,973 @@
++# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
++# 2000, 2002, 2003, 2004
++# Free Software Foundation, Inc.
++
++# 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.
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++# This file was written by Rob Savoye. (rob@cygnus.com)
++
++# Test the same stuff but with PIE executables
++
++if $tracelevel then {
++ strace $tracelevel
++}
++
++
++#
++# test running programs
++#
++set prms_id 0
++set bug_id 0
++
++set testfile "break"
++set srcfile ${testfile}.c
++set srcfile1 ${testfile}1.c
++set binfile ${objdir}/${subdir}/${testfile}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if [get_compiler_info ${binfile}] {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++if [target_info exists gdb_stub] {
++ gdb_step_for_stub;
++}
++#
++# test simple breakpoint setting commands
++#
++
++# Test deleting all breakpoints when there are none installed,
++# GDB should not prompt for confirmation.
++# Note that gdb-init.exp provides a "delete_breakpoints" proc
++# for general use elsewhere.
++
++send_gdb "delete breakpoints\n"
++gdb_expect {
++ -re "Delete all breakpoints.*$" {
++ send_gdb "y\n"
++ gdb_expect {
++ -re "$gdb_prompt $" {
++ fail "Delete all breakpoints when none (unexpected prompt)"
++ }
++ timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" }
++ }
++ }
++ -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" }
++ timeout { fail "Delete all breakpoints when none (timeout)" }
++}
++
++#
++# test break at function
++#
++gdb_test "break main" \
++ "Breakpoint.*at.* file .*$srcfile, line.*" \
++ "breakpoint function"
++
++#
++# test break at quoted function
++#
++gdb_test "break \"marker2\"" \
++ "Breakpoint.*at.* file .*$srcfile1, line.*" \
++ "breakpoint quoted function"
++
++#
++# test break at function in file
++#
++gdb_test "break $srcfile:factorial" \
++ "Breakpoint.*at.* file .*$srcfile, line.*" \
++ "breakpoint function in file"
++
++set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
++
++#
++# test break at line number
++#
++# Note that the default source file is the last one whose source text
++# was printed. For native debugging, before we've executed the
++# program, this is the file containing main, but for remote debugging,
++# it's wherever the processor was stopped when we connected to the
++# board. So, to be sure, we do a list command.
++#
++gdb_test "list main" \
++ ".*main \\(argc, argv, envp\\).*" \
++ "use `list' to establish default source file"
++gdb_test "break $bp_location1" \
++ "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \
++ "breakpoint line number"
++
++#
++# test duplicate breakpoint
++#
++gdb_test "break $bp_location1" \
++ "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \
++ "breakpoint duplicate"
++
++set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
++
++#
++# test break at line number in file
++#
++gdb_test "break $srcfile:$bp_location2" \
++ "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \
++ "breakpoint line number in file"
++
++set bp_location3 [gdb_get_line_number "set breakpoint 3 here"]
++set bp_location4 [gdb_get_line_number "set breakpoint 4 here"]
++
++#
++# Test putting a break at the start of a multi-line if conditional.
++# Verify the breakpoint was put at the start of the conditional.
++#
++gdb_test "break multi_line_if_conditional" \
++ "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \
++ "breakpoint at start of multi line if conditional"
++
++gdb_test "break multi_line_while_conditional" \
++ "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
++ "breakpoint at start of multi line while conditional"
++
++set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
++set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
++
++#
++# check to see what breakpoints are set
++#
++if [target_info exists gdb_stub] {
++ set main_line $bp_location5
++} else {
++ set main_line $bp_location6
++}
++
++if {$hp_aCC_compiler} {
++ set proto "\\(int\\)"
++} else {
++ set proto ""
++}
++
++set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
++set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
++set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
++
++gdb_test "info break" \
++ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).*
++\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
++\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \
++ "breakpoint info"
++
++# FIXME: The rest of this test doesn't work with anything that can't
++# handle arguments.
++# Huh? There doesn't *appear* to be anything that passes arguments
++# below.
++if [istarget "mips-idt-*"] then {
++ return
++}
++
++#
++# run until the breakpoint at main is hit. For non-stubs-using targets.
++#
++if ![target_info exists use_gdb_stub] {
++ if [istarget "*-*-vxworks*"] then {
++ send_gdb "run vxmain \"2\"\n"
++ set timeout 120
++ verbose "Timeout is now $timeout seconds" 2
++ } else {
++ send_gdb "run\n"
++ }
++ gdb_expect {
++ -re "The program .* has been started already.*y or n. $" {
++ send_gdb "y\n"
++ exp_continue
++ }
++ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
++ { pass "run until function breakpoint" }
++ -re ".*$gdb_prompt $" { fail "run until function breakpoint" }
++ timeout { fail "run until function breakpoint (timeout)" }
++ }
++} else {
++ if ![target_info exists gdb_stub] {
++ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
++ }
++}
++
++#
++# run until the breakpoint at a line number
++#
++gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
++ "run until breakpoint set at a line number"
++
++#
++# Run until the breakpoint set in a function in a file
++#
++for {set i 6} {$i >= 1} {incr i -1} {
++ gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
++ "run until file:function($i) breakpoint"
++}
++
++#
++# Run until the breakpoint set at a quoted function
++#
++gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \
++ "run until quoted breakpoint"
++#
++# run until the file:function breakpoint at a line number in a file
++#
++gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
++ "run until file:linenum breakpoint"
++
++# Test break at offset +1
++set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
++
++gdb_test "break +1" \
++ "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
++ "breakpoint offset +1"
++
++# Check to see if breakpoint is hit when stepped onto
++
++gdb_test "step" \
++ ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
++ "step onto breakpoint"
++
++#
++# delete all breakpoints so we can start over, course this can be a test too
++#
++delete_breakpoints
++
++#
++# test temporary breakpoint at function
++#
++
++gdb_test "tbreak main" "Breakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
++
++#
++# test break at function in file
++#
++
++gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" \
++ "Temporary breakpoint function in file"
++
++#
++# test break at line number
++#
++send_gdb "tbreak $bp_location1\n"
++gdb_expect {
++ -re "Breakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
++ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
++ timeout { fail "breakpoint line number #1 (timeout)" }
++}
++
++gdb_test "tbreak $bp_location6" "Breakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2"
++
++#
++# test break at line number in file
++#
++send_gdb "tbreak $srcfile:$bp_location2\n"
++gdb_expect {
++ -re "Breakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
++ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
++ timeout { fail "Temporary breakpoint line number in file #1 (timeout)" }
++}
++
++set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
++gdb_test "tbreak $srcfile:$bp_location11" "Breakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2"
++
++#
++# check to see what breakpoints are set (temporary this time)
++#
++gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\]
++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
++\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\]
++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
++\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
++ "Temporary breakpoint info"
++
++
++#***********
++
++# Verify that catchpoints for fork, vfork and exec don't trigger
++# inappropriately. (There are no calls to those system functions
++# in this test program.)
++#
++if ![runto_main] then { fail "break tests suppressed" }
++
++send_gdb "catch\n"
++gdb_expect {
++ -re "Catch requires an event name.*$gdb_prompt $"\
++ {pass "catch requires an event name"}
++ -re "$gdb_prompt $"\
++ {fail "catch requires an event name"}
++ timeout {fail "(timeout) catch requires an event name"}
++}
++
++
++set name "set catch fork, never expected to trigger"
++send_gdb "catch fork\n"
++gdb_expect {
++ -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
++ {pass $name}
++ -re "Catch of fork not yet implemented.*$gdb_prompt $"
++ {pass $name}
++ -re "$gdb_prompt $"
++ {fail $name}
++ timeout {fail "(timeout) $name"}
++}
++
++
++set name "set catch vfork, never expected to trigger"
++send_gdb "catch vfork\n"
++
++# If we are on HP-UX 10.20, we expect an error message to be
++# printed if we type "catch vfork" at the gdb gdb_prompt. This is
++# because on HP-UX 10.20, we cannot catch vfork events.
++
++if [istarget "hppa*-hp-hpux10.20"] then {
++ gdb_expect {
++ -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
++ {pass $name}
++ -re "$gdb_prompt $"
++ {fail $name}
++ timeout {fail "(timeout) $name"}
++ }
++} else {
++ gdb_expect {
++ -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
++ {pass $name}
++ -re "Catch of vfork not yet implemented.*$gdb_prompt $"
++ {pass $name}
++ -re "$gdb_prompt $"
++ {fail $name}
++ timeout {fail "(timeout) $name"}
++ }
++}
++
++set name "set catch exec, never expected to trigger"
++send_gdb "catch exec\n"
++gdb_expect {
++ -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
++ {pass $name}
++ -re "Catch of exec not yet implemented.*$gdb_prompt $"
++ {pass $name}
++ -re "$gdb_prompt $" {fail $name}
++ timeout {fail "(timeout) $name"}
++}
++
++# Verify that GDB responds gracefully when asked to set a breakpoint
++# on a nonexistent source line.
++#
++send_gdb "break 999\n"
++gdb_expect {
++ -re "No line 999 in file .*$gdb_prompt $"\
++ {pass "break on non-existent source line"}
++ -re "$gdb_prompt $"\
++ {fail "break on non-existent source line"}
++ timeout {fail "(timeout) break on non-existent source line"}
++}
++
++# Run to the desired default location. If not positioned here, the
++# tests below don't work.
++#
++gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1"
++
++
++# Verify that GDB allows one to just say "break", which is treated
++# as the "default" breakpoint. Note that GDB gets cute when printing
++# the informational message about other breakpoints at the same
++# location. We'll hit that bird with this stone too.
++#
++send_gdb "break\n"
++gdb_expect {
++ -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
++ {pass "break on default location, 1st time"}
++ -re "$gdb_prompt $"\
++ {fail "break on default location, 1st time"}
++ timeout {fail "(timeout) break on default location, 1st time"}
++}
++
++send_gdb "break\n"
++gdb_expect {
++ -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
++ {pass "break on default location, 2nd time"}
++ -re "$gdb_prompt $"\
++ {fail "break on default location, 2nd time"}
++ timeout {fail "(timeout) break on default location, 2nd time"}
++}
++
++send_gdb "break\n"
++gdb_expect {
++ -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
++ {pass "break on default location, 3rd time"}
++ -re "$gdb_prompt $"\
++ {fail "break on default location, 3rd time"}
++ timeout {fail "(timeout) break on default location, 3rd time"}
++}
++
++send_gdb "break\n"
++gdb_expect {
++ -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
++ {pass "break on default location, 4th time"}
++ -re "$gdb_prompt $"\
++ {fail "break on default location, 4th time"}
++ timeout {fail "(timeout) break on default location, 4th time"}
++}
++
++# Verify that a "silent" breakpoint can be set, and that GDB is indeed
++# "silent" about its triggering.
++#
++if ![runto_main] then { fail "break tests suppressed" }
++
++send_gdb "break $bp_location1\n"
++gdb_expect {
++ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\
++ {pass "set to-be-silent break bp_location1"}
++ -re "$gdb_prompt $"\
++ {fail "set to-be-silent break bp_location1"}
++ timeout {fail "(timeout) set to-be-silent break bp_location1"}
++}
++
++send_gdb "commands $expect_out(1,string)\n"
++send_gdb "silent\n"
++send_gdb "end\n"
++gdb_expect {
++ -re ".*$gdb_prompt $"\
++ {pass "set silent break bp_location1"}
++ timeout {fail "(timeout) set silent break bp_location1"}
++}
++
++send_gdb "info break $expect_out(1,string)\n"
++gdb_expect {
++ -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\
++ {pass "info silent break bp_location1"}
++ -re "$gdb_prompt $"\
++ {fail "info silent break bp_location1"}
++ timeout {fail "(timeout) info silent break bp_location1"}
++}
++send_gdb "continue\n"
++gdb_expect {
++ -re "Continuing.\r\n$gdb_prompt $"\
++ {pass "hit silent break bp_location1"}
++ -re "$gdb_prompt $"\
++ {fail "hit silent break bp_location1"}
++ timeout {fail "(timeout) hit silent break bp_location1"}
++}
++send_gdb "bt\n"
++gdb_expect {
++ -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\
++ {pass "stopped for silent break bp_location1"}
++ -re "$gdb_prompt $"\
++ {fail "stopped for silent break bp_location1"}
++ timeout {fail "(timeout) stopped for silent break bp_location1"}
++}
++
++# Verify that GDB can at least parse a breakpoint with the
++# "thread" keyword. (We won't attempt to test here that a
++# thread-specific breakpoint really triggers appropriately.
++# The gdb.threads subdirectory contains tests for that.)
++#
++set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
++send_gdb "break $bp_location12 thread 999\n"
++gdb_expect {
++ -re "Unknown thread 999.*$gdb_prompt $"\
++ {pass "thread-specific breakpoint on non-existent thread disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "thread-specific breakpoint on non-existent thread disallowed"}
++ timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
++}
++send_gdb "break $bp_location12 thread foo\n"
++gdb_expect {
++ -re "Junk after thread keyword..*$gdb_prompt $"\
++ {pass "thread-specific breakpoint on bogus thread ID disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "thread-specific breakpoint on bogus thread ID disallowed"}
++ timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
++}
++
++# Verify that GDB responds gracefully to a breakpoint command with
++# trailing garbage.
++#
++send_gdb "break $bp_location12 foo\n"
++gdb_expect {
++ -re "Junk at end of arguments..*$gdb_prompt $"\
++ {pass "breakpoint with trailing garbage disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "breakpoint with trailing garbage disallowed"}
++ timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
++}
++
++# Verify that GDB responds gracefully to a "clear" command that has
++# no matching breakpoint. (First, get us off the current source line,
++# which we know has a breakpoint.)
++#
++send_gdb "next\n"
++gdb_expect {
++ -re ".*$gdb_prompt $"\
++ {pass "step over breakpoint"}
++ timeout {fail "(timeout) step over breakpoint"}
++}
++send_gdb "clear 81\n"
++gdb_expect {
++ -re "No breakpoint at 81..*$gdb_prompt $"\
++ {pass "clear line has no breakpoint disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "clear line has no breakpoint disallowed"}
++ timeout {fail "(timeout) clear line has no breakpoint disallowed"}
++}
++send_gdb "clear\n"
++gdb_expect {
++ -re "No breakpoint at this line..*$gdb_prompt $"\
++ {pass "clear current line has no breakpoint disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "clear current line has no breakpoint disallowed"}
++ timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
++}
++
++# Verify that we can set and clear multiple breakpoints.
++#
++# We don't test that it deletes the correct breakpoints. We do at
++# least test that it deletes more than one breakpoint.
++#
++gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
++gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
++gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
++
++# Verify that a breakpoint can be set via a convenience variable.
++#
++send_gdb "set \$foo=$bp_location11\n"
++gdb_expect {
++ -re "$gdb_prompt $"\
++ {pass "set convenience variable \$foo to bp_location11"}
++ timeout {fail "(timeout) set convenience variable \$foo to bp_location11"}
++}
++send_gdb "break \$foo\n"
++gdb_expect {
++ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\
++ {pass "set breakpoint via convenience variable"}
++ -re "$gdb_prompt $"\
++ {fail "set breakpoint via convenience variable"}
++ timeout {fail "(timeout) set breakpoint via convenience variable"}
++}
++
++# Verify that GDB responds gracefully to an attempt to set a
++# breakpoint via a convenience variable whose type is not integer.
++#
++send_gdb "set \$foo=81.5\n"
++gdb_expect {
++ -re "$gdb_prompt $"\
++ {pass "set convenience variable \$foo to 81.5"}
++ timeout {fail "(timeout) set convenience variable \$foo to 81.5"}
++}
++send_gdb "break \$foo\n"
++gdb_expect {
++ -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
++ {pass "set breakpoint via non-integer convenience variable disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "set breakpoint via non-integer convenience variable disallowed"}
++ timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
++}
++
++# Verify that we can set and trigger a breakpoint in a user-called function.
++#
++send_gdb "break marker2\n"
++gdb_expect {
++ -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\
++ {pass "set breakpoint on to-be-called function"}
++ -re "$gdb_prompt $"\
++ {fail "set breakpoint on to-be-called function"}
++ timeout {fail "(timeout) set breakpoint on to-be-called function"}
++}
++send_gdb "print marker2(99)\n"
++gdb_expect {
++ -re "The program being debugged stopped while in a function called from GDB.\r\nWhen the function .marker2$proto. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$gdb_prompt $"\
++ {pass "hit breakpoint on called function"}
++ -re "$gdb_prompt $"\
++ {fail "hit breakpoint on called function"}
++ timeout {fail "(timeout) hit breakpoint on called function"}
++}
++
++# As long as we're stopped (breakpointed) in a called function,
++# verify that we can successfully backtrace & such from here.
++#
++# In this and the following test, the _sr4export check apparently is needed
++# for hppa*-*-hpux.
++#
++send_gdb "bt\n"
++gdb_expect {
++ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\
++ {pass "backtrace while in called function"}
++ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\
++ {pass "backtrace while in called function"}
++ -re "$gdb_prompt $"\
++ {fail "backtrace while in called function"}
++ timeout {fail "(timeout) backtrace while in called function"}
++}
++
++# Return from the called function. For remote targets, it's important to do
++# this before runto_main, which otherwise may silently stop on the dummy
++# breakpoint inserted by GDB at the program's entry point.
++#
++send_gdb "finish\n"
++gdb_expect {
++ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\
++ {pass "finish from called function"}
++ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\
++ {pass "finish from called function"}
++ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\
++ {pass "finish from called function"}
++ -re "$gdb_prompt $"\
++ {fail "finish from called function"}
++ timeout {fail "(timeout) finish from called function"}
++}
++
++# Verify that GDB responds gracefully to a "finish" command with
++# arguments.
++#
++if ![runto_main] then { fail "break tests suppressed" }
++
++send_gdb "finish 123\n"
++gdb_expect {
++ -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
++ {pass "finish with arguments disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "finish with arguments disallowed"}
++ timeout {fail "(timeout) finish with arguments disallowed"}
++}
++
++# Verify that GDB responds gracefully to a request to "finish" from
++# the outermost frame. On a stub that never exits, this will just
++# run to the stubs routine, so we don't get this error... Thus the
++# second condition.
++#
++
++send_gdb "finish\n"
++gdb_expect {
++ -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
++ {pass "finish from outermost frame disallowed"}
++ -re "Run till exit from.*\r\n$gdb_prompt $" {
++ pass "finish from outermost frame disallowed"
++ }
++ -re "$gdb_prompt $"\
++ {fail "finish from outermost frame disallowed"}
++ timeout {fail "(timeout) finish from outermost frame disallowed"}
++}
++
++# Verify that we can explicitly ask GDB to stop on all shared library
++# events, and that it does so.
++#
++if [istarget "hppa*-*-hpux*"] then {
++ if ![runto_main] then { fail "break tests suppressed" }
++
++ send_gdb "set stop-on-solib-events 1\n"
++ gdb_expect {
++ -re "$gdb_prompt $"\
++ {pass "set stop-on-solib-events"}
++ timeout {fail "(timeout) set stop-on-solib-events"}
++ }
++
++ send_gdb "run\n"
++ gdb_expect {
++ -re ".*Start it from the beginning.*y or n. $"\
++ {send_gdb "y\n"
++ gdb_expect {
++ -re ".*Stopped due to shared library event.*$gdb_prompt $"\
++ {pass "triggered stop-on-solib-events"}
++ -re "$gdb_prompt $"\
++ {fail "triggered stop-on-solib-events"}
++ timeout {fail "(timeout) triggered stop-on-solib-events"}
++ }
++ }
++ -re "$gdb_prompt $"\
++ {fail "rerun for stop-on-solib-events"}
++ timeout {fail "(timeout) rerun for stop-on-solib-events"}
++ }
++
++ send_gdb "set stop-on-solib-events 0\n"
++ gdb_expect {
++ -re "$gdb_prompt $"\
++ {pass "reset stop-on-solib-events"}
++ timeout {fail "(timeout) reset stop-on-solib-events"}
++ }
++}
++
++# Hardware breakpoints are unsupported on HP-UX. Verify that GDB
++# gracefully responds to requests to create them.
++#
++if [istarget "hppa*-*-hpux*"] then {
++ if ![runto_main] then { fail "break tests suppressed" }
++
++ send_gdb "hbreak\n"
++ gdb_expect {
++ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
++ {pass "hw breaks disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "hw breaks disallowed"}
++ timeout {fail "(timeout) hw breaks disallowed"}
++ }
++
++ send_gdb "thbreak\n"
++ gdb_expect {
++ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
++ {pass "temporary hw breaks disallowed"}
++ -re "$gdb_prompt $"\
++ {fail "temporary hw breaks disallowed"}
++ timeout {fail "(timeout) temporary hw breaks disallowed"}
++ }
++}
++
++#********
++
++
++#
++# Test "next" over recursive function call.
++#
++
++proc test_next_with_recursion {} {
++ global gdb_prompt
++ global decimal
++ global binfile
++
++ if [target_info exists use_gdb_stub] {
++ # Reload the program.
++ delete_breakpoints
++ gdb_load ${binfile};
++ } else {
++ # FIXME: should be using runto
++ gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
++
++ delete_breakpoints
++ }
++
++ gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
++
++ # Run until we call factorial with 6
++
++ if [istarget "*-*-vxworks*"] then {
++ send_gdb "run vxmain \"6\"\n"
++ } else {
++ gdb_run_cmd
++ }
++ gdb_expect {
++ -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
++ -re ".*$gdb_prompt $" {
++ fail "run to factorial(6)";
++ gdb_suppress_tests;
++ }
++ timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
++ }
++
++ # Continue until we call factorial recursively with 5.
++
++ if [gdb_test "continue" \
++ "Continuing.*Break.* factorial .value=5. .*" \
++ "continue to factorial(5)"] then { gdb_suppress_tests }
++
++ # Do a backtrace just to confirm how many levels deep we are.
++
++ if [gdb_test "backtrace" \
++ "#0\[ \t\]+ factorial .value=5..*" \
++ "backtrace from factorial(5)"] then { gdb_suppress_tests }
++
++ # Now a "next" should position us at the recursive call, which
++ # we will be performing with 4.
++
++ if [gdb_test "next" \
++ ".* factorial .value - 1.;.*" \
++ "next to recursive call"] then { gdb_suppress_tests }
++
++ # Disable the breakpoint at the entry to factorial by deleting them all.
++ # The "next" should run until we return to the next line from this
++ # recursive call to factorial with 4.
++ # Buggy versions of gdb will stop instead at the innermost frame on
++ # the line where we are trying to "next" to.
++
++ delete_breakpoints
++
++ if [istarget "mips*tx39-*"] {
++ set timeout 60
++ }
++ # We used to set timeout here for all other targets as well. This
++ # is almost certainly wrong. The proper timeout depends on the
++ # target system in use, and how we communicate with it, so there
++ # is no single value appropriate for all targets. The timeout
++ # should be established by the Dejagnu config file(s) for the
++ # board, and respected by the test suite.
++ #
++ # For example, if I'm running GDB over an SSH tunnel talking to a
++ # portmaster in California talking to an ancient 68k board running
++ # a crummy ROM monitor (a situation I can only wish were
++ # hypothetical), then I need a large timeout. But that's not the
++ # kind of knowledge that belongs in this file.
++
++ gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
++ "next over recursive call"
++
++ # OK, we should be back in the same stack frame we started from.
++ # Do a backtrace just to confirm.
++
++ set result [gdb_test "backtrace" \
++ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
++ "backtrace from factorial(5.1)"]
++ if { $result != 0 } { gdb_suppress_tests }
++
++ if [target_info exists gdb,noresults] { gdb_suppress_tests }
++ gdb_continue_to_end "recursive next test"
++ gdb_stop_suppressing_tests;
++}
++
++test_next_with_recursion
++
++
++#********
++
++# build a new file with optimization enabled so that we can try breakpoints
++# on targets with optimized prologues
++
++set binfileo2 ${objdir}/${subdir}/${testfile}o2
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++if [get_compiler_info ${binfileo2}] {
++ return -1
++}
++
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfileo2}
++
++if [target_info exists gdb_stub] {
++ gdb_step_for_stub;
++}
++
++#
++# test break at function
++#
++gdb_test "break main" \
++ "Breakpoint.*at.* file .*$srcfile, line.*" \
++ "breakpoint function, optimized file"
++
++#
++# test break at function
++#
++gdb_test "break marker4" \
++ "Breakpoint.*at.* file .*$srcfile1, line.*" \
++ "breakpoint small function, optimized file"
++
++#
++# run until the breakpoint at main is hit. For non-stubs-using targets.
++#
++if ![target_info exists use_gdb_stub] {
++ if [istarget "*-*-vxworks*"] then {
++ send_gdb "run vxmain \"2\"\n"
++ set timeout 120
++ verbose "Timeout is now $timeout seconds" 2
++ } else {
++ send_gdb "run\n"
++ }
++ gdb_expect {
++ -re "The program .* has been started already.*y or n. $" {
++ send_gdb "y\n"
++ exp_continue
++ }
++ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
++ { pass "run until function breakpoint, optimized file" }
++ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
++ { pass "run until function breakpoint, optimized file (code motion)" }
++ -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" }
++ timeout { fail "run until function breakpoint, optimized file (timeout)" }
++ }
++} else {
++ if ![target_info exists gdb_stub] {
++ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
++ }
++}
++
++#
++# run until the breakpoint at a small function
++#
++
++#
++# Add a second pass pattern. The behavior differs here between stabs
++# and dwarf for one-line functions. Stabs preserves two line symbols
++# (one before the prologue and one after) with the same line number,
++# but dwarf regards these as duplicates and discards one of them.
++# Therefore the address after the prologue (where the breakpoint is)
++# has no exactly matching line symbol, and GDB reports the breakpoint
++# as if it were in the middle of a line rather than at the beginning.
++
++set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
++set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
++send_gdb "continue\n"
++gdb_expect {
++ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
++ pass "run until breakpoint set at small function, optimized file"
++ }
++ -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
++ pass "run until breakpoint set at small function, optimized file"
++ }
++ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
++ # marker4() is defined at line 46 when compiled with -DPROTOTYPES
++ pass "run until breakpoint set at small function, optimized file (line bp_location14)"
++ }
++ -re ".*$gdb_prompt " {
++ fail "run until breakpoint set at small function, optimized file"
++ }
++ timeout {
++ fail "run until breakpoint set at small function, optimized file (timeout)"
++ }
++}
++
++
++# Reset the default arguments for VxWorks
++if [istarget "*-*-vxworks*"] {
++ set timeout 10
++ verbose "Timeout is now $timeout seconds" 2
++ send_gdb "set args main\n"
++ gdb_expect -re ".*$gdb_prompt $" {}
++}
+Index: gdb-6.8/gdb/testsuite/gdb.pie/break1.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/break1.c 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,44 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
++ Foundation, Inc.
++
++ 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.
++
++ Please email any bugs, comments, and/or additions to this file to:
++ bug-gdb@prep.ai.mit.edu */
++
++/* The code for this file was extracted from the gdb testsuite
++ testcase "break.c". */
++
++/* The following functions do nothing useful. They are included
++ simply as places to try setting breakpoints at. They are
++ explicitly "one-line functions" to verify that this case works
++ (some versions of gcc have or have had problems with this).
++
++ These functions are in a separate source file to prevent an
++ optimizing compiler from inlining them and optimizing them away. */
++
++#ifdef PROTOTYPES
++int marker1 (void) { return (0); } /* set breakpoint 15 here */
++int marker2 (int a) { return (1); } /* set breakpoint 8 here */
++void marker3 (char *a, char *b) {} /* set breakpoint 17 here */
++void marker4 (long d) {} /* set breakpoint 14 here */
++#else
++int marker1 () { return (0); } /* set breakpoint 16 here */
++int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */
++void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */
++void marker4 (d) long d; {} /* set breakpoint 13 here */
++#endif
+Index: gdb-6.8/gdb/testsuite/gdb.pie/corefile.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/corefile.exp 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,243 @@
++# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
++# Free Software Foundation, Inc.
++
++# 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.
++
++# Please email any bugs, comments, and/or additions to this file to:
++# bug-gdb@prep.ai.mit.edu
++
++# This file was written by Fred Fish. (fnf@cygnus.com)
++
++if $tracelevel then {
++ strace $tracelevel
++}
++
++set prms_id 0
++set bug_id 0
++
++# are we on a target board
++if ![isnative] then {
++ return
++}
++
++set testfile "coremaker"
++set srcfile ${testfile}.c
++set binfile ${objdir}/${subdir}/${testfile}
++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } {
++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
++}
++
++# Create and source the file that provides information about the compiler
++# used to compile the test case.
++if [get_compiler_info ${binfile}] {
++ return -1;
++}
++
++# Create a core file named "corefile" rather than just "core", to
++# avoid problems with sys admin types that like to regularly prune all
++# files named "core" from the system.
++#
++# Arbitrarily try setting the core size limit to "unlimited" since
++# this does not hurt on systems where the command does not work and
++# allows us to generate a core on systems where it does.
++#
++# Some systems append "core" to the name of the program; others append
++# the name of the program to "core"; still others (like Linux, as of
++# May 2003) create cores named "core.PID". In the latter case, we
++# could have many core files lying around, and it may be difficult to
++# tell which one is ours, so let's run the program in a subdirectory.
++set found 0
++set coredir "${objdir}/${subdir}/coredir.[getpid]"
++file mkdir $coredir
++catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
++# remote_exec host "${binfile}"
++foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
++ if [remote_file build exists $i] {
++ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
++ set found 1
++ }
++}
++# Check for "core.PID".
++if { $found == 0 } {
++ set names [glob -nocomplain -directory $coredir core.*]
++ if {[llength $names] == 1} {
++ set corefile [file join $coredir [lindex $names 0]]
++ remote_exec build "mv $corefile ${objdir}/${subdir}/corefile"
++ set found 1
++ }
++}
++if { $found == 0 } {
++ # The braindamaged HPUX shell quits after the ulimit -c above
++ # without executing ${binfile}. So we try again without the
++ # ulimit here if we didn't find a core file above.
++ # Oh, I should mention that any "braindamaged" non-Unix system has
++ # the same problem. I like the cd bit too, it's really neat'n stuff.
++ catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
++ foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
++ if [remote_file build exists $i] {
++ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
++ set found 1
++ }
++ }
++}
++
++# Try to clean up after ourselves.
++remote_file build delete [file join $coredir coremmap.data]
++remote_exec build "rmdir $coredir"
++
++if { $found == 0 } {
++ warning "can't generate a core file - core tests suppressed - check ulimit -c"
++ return 0
++}
++
++#
++# Test that we can simply startup with a "-core=corefile" command line arg
++# and recognize that the core file is a valid, usable core file.
++# To do this, we must shutdown the currently running gdb and restart
++# with the -core args. We can't use gdb_start because it looks for
++# the first gdb prompt, and the message we are looking for occurs
++# before the first prompt. Also, we can't include GDBFLAGS because
++# if it is empty, this confuses gdb with an empty argument that it
++# grumbles about (said grumbling currently being ignored in gdb_start).
++# **FIXME**
++#
++# Another problem is that on some systems (solaris for example), there
++# is apparently a limit on the length of a fully specified path to
++# the coremaker executable, at about 80 chars. For this case, consider
++# it a pass, but note that the program name is bad.
++
++gdb_exit
++if $verbose>1 then {
++ send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
++}
++
++set oldtimeout $timeout
++set timeout [expr "$timeout + 60"]
++verbose "Timeout is now $timeout seconds" 2
++eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
++expect {
++ -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
++ fail "args: -core=corefile (couldn't find regs)"
++ }
++ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
++ pass "args: -core=corefile"
++ }
++ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
++ pass "args: -core=corefile (with bad program name)"
++ }
++ -re ".*registers from core file: File in wrong format.* $" {
++ fail "args: -core=corefile (could not read registers from core file)"
++ }
++ -re ".*$gdb_prompt $" { fail "args: -core=corefile" }
++ timeout { fail "(timeout) starting with -core" }
++}
++
++
++#
++# Test that startup with both an executable file and -core argument.
++# See previous comments above, they are still applicable.
++#
++
++close;
++
++if $verbose>1 then {
++ send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n"
++}
++
++
++eval "spawn $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile";
++expect {
++ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
++ pass "args: execfile -core=corefile"
++ }
++ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
++ pass "args: execfile -core=corefile (with bad program name)"
++ }
++ -re ".*registers from core file: File in wrong format.* $" {
++ fail "args: execfile -core=corefile (could not read registers from core file)"
++ }
++ -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" }
++ timeout { fail "(timeout) starting with -core" }
++}
++set timeout $oldtimeout
++verbose "Timeout is now $timeout seconds" 2
++
++close;
++
++# Now restart normally.
++
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++gdb_load ${binfile}
++
++# Test basic corefile recognition via core-file command.
++
++send_gdb "core-file $objdir/$subdir/corefile\n"
++gdb_expect {
++ -re ".* program is being debugged already.*y or n. $" {
++ # gdb_load may connect us to a gdbserver.
++ send_gdb "y\n"
++ exp_continue;
++ }
++ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
++ pass "core-file command"
++ }
++ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
++ pass "core-file command (with bad program name)"
++ }
++ -re ".*registers from core file: File in wrong format.* $" {
++ fail "core-file command (could not read registers from core file)"
++ }
++ -re ".*$gdb_prompt $" { fail "core-file command" }
++ timeout { fail "(timeout) core-file command" }
++}
++
++# Test correct mapping of corefile sections by printing some variables.
++
++gdb_test "print coremaker_data" "\\\$$decimal = 202"
++gdb_test "print coremaker_bss" "\\\$$decimal = 10"
++gdb_test "print coremaker_ro" "\\\$$decimal = 201"
++
++gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
++
++# Somehow we better test the ability to read the registers out of the core
++# file correctly. I don't think the other tests do this.
++
++gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
++gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp"
++
++# Test ability to read mmap'd data
++
++gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file"
++setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*"
++set test "accessing mmapped data in core file"
++gdb_test_multiple "x/8bd buf2" "$test" {
++ -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" {
++ pass "$test"
++ }
++ -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" {
++ fail "$test (mapping failed at runtime)"
++ }
++ -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" {
++ fail "$test (mapping address not found in core file)"
++ }
++}
++
++# test reinit_frame_cache
++
++gdb_load ${binfile}
++gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\).*" "up in corefile.exp (reinit)"
++
++gdb_test "core" "No core file now."
+Index: gdb-6.8/gdb/testsuite/gdb.pie/coremaker.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8/gdb/testsuite/gdb.pie/coremaker.c 2008-03-30 08:59:12.000000000 -0700
+@@ -0,0 +1,142 @@
++/* Copyright 1992, 1993, 1994, 1995, 1996, 1999
++ Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ 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. */
++
++/* Simple little program that just generates a core dump from inside some
++ nested function calls. */
++
++#include <stdio.h>
++#include <sys/types.h>
++#include <fcntl.h>
++#include <sys/mman.h>
++#include <signal.h>
++#include <stdlib.h>
++#include <unistd.h>
++
++#ifndef __STDC__
++#define const /**/
++#endif
++
++#define MAPSIZE (8 * 1024)
++
++/* Don't make these automatic vars or we will have to walk back up the
++ stack to access them. */
++
++char *buf1;
++char *buf2;
++
++int coremaker_data = 1; /* In Data section */
++int coremaker_bss; /* In BSS section */
++
++const int coremaker_ro = 201; /* In Read-Only Data section */
++
++/* Note that if the mapping fails for any reason, we set buf2
++ to -1 and the testsuite notices this and reports it as
++ a failure due to a mapping error. This way we don't have
++ to test for specific errors when running the core maker. */
++
++void
++mmapdata ()
++{
++ int j, fd;
++
++ /* Allocate and initialize a buffer that will be used to write
++ the file that is later mapped in. */
++
++ buf1 = (char *) malloc (MAPSIZE);
++ for (j = 0; j < MAPSIZE; ++j)
++ {
++ buf1[j] = j;
++ }
++
++ /* Write the file to map in */
++
++ fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666);
++ if (fd == -1)
++ {
++ perror ("coremmap.data open failed");
++ buf2 = (char *) -1;
++ return;
++ }
++ write (fd, buf1, MAPSIZE);
++
++ /* Now map the file into our address space as buf2 */
++
++ buf2 = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
++ if (buf2 == (char *) -1)
++ {
++ perror ("mmap failed");
++ return;
++ }
++
++ /* Verify that the original data and the mapped data are identical.
++ If not, we'd rather fail now than when trying to access the mapped
++ data from the core file. */
++
++ for (j = 0; j < MAPSIZE; ++j)
++ {
++ if (buf1[j] != buf2[j])
++ {
++ fprintf (stderr, "mapped data is incorrect");
++ buf2 = (char *) -1;
++ return;
++ }
++ }
++}
++
++void
++func2 ()
++{
++ int coremaker_local[5];
++ int i;
++
++#ifdef SA_FULLDUMP
++ /* Force a corefile that includes the data section for AIX. */
++ {
++ struct sigaction sa;
++
++ sigaction (SIGABRT, (struct sigaction *)0, &sa);
++ sa.sa_flags |= SA_FULLDUMP;
++ sigaction (SIGABRT, &sa, (struct sigaction *)0);
++ }
++#endif
++
++ /* Make sure that coremaker_local doesn't get optimized away. */
++ for (i = 0; i < 5; i++)
++ coremaker_local[i] = i;
++ coremaker_bss = 0;
++ for (i = 0; i < 5; i++)
++ coremaker_bss += coremaker_local[i];
++ coremaker_data = coremaker_ro + 1;
++ abort ();
++}
++
++void
++func1 ()
++{
++ func2 ();
++}
++
++int main ()
++{
++ mmapdata ();
++ func1 ();
++ return 0;
++}
++
diff --git a/main/gdb/APKBUILD b/main/gdb/APKBUILD
new file mode 100644
index 00000000000..a851da31415
--- /dev/null
+++ b/main/gdb/APKBUILD
@@ -0,0 +1,41 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gdb
+pkgver=6.8
+pkgrel=3
+pkgdesc="The GNU Debugger"
+url="http://sources.redhat.com/gdb/"
+license="GPL3"
+depends=
+makedepends="ncurses-dev expat-dev"
+subpackages="$pkgname-doc"
+source="http://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.bz2
+ 50_all_gdb-pie-1.patch
+ 50_all_gdb-pie-2.patch
+ "
+# patches were found here:
+# http://distfiles.gentoo.org/distfiles/$pkgname-$pkgver-patches-1.3.tar.lzma
+
+build () {
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --disable-nls \
+ --without-system-readline \
+ --disable-werror \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ rm -f "$pkgdir"/usr/share/info/dir
+ # those are provided by binutils
+ rm -rf "$pkgdir"/usr/include
+ rm -rf "$pkgdir"/usr/lib
+}
+
+md5sums="c9da266b884fb8fa54df786dfaadbc7a gdb-6.8.tar.bz2
+7d5bcb23ffbadb9ce6ac24f37003f619 50_all_gdb-pie-1.patch
+33992db76732d26c6d1a3703b52e2c94 50_all_gdb-pie-2.patch"
diff --git a/main/gdbm/10-gdbm-1.8.3-fix-install-ownership.patch b/main/gdbm/10-gdbm-1.8.3-fix-install-ownership.patch
new file mode 100644
index 00000000000..139ef99d7ee
--- /dev/null
+++ b/main/gdbm/10-gdbm-1.8.3-fix-install-ownership.patch
@@ -0,0 +1,45 @@
+Install with proper ownership.
+
+http://bugs.gentoo.org/24178
+
+--- Makefile.in
++++ Makefile.in
+@@ -14,10 +14,6 @@
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
+ INSTALL_DATA = @INSTALL_DATA@
+
+-# File ownership and group
+-BINOWN = bin
+-BINGRP = bin
+-
+ MAKEINFO = makeinfo
+ TEXI2DVI = texi2dvi
+
+@@ -131,22 +127,17 @@
+ $(INSTALL_ROOT)$(includedir) $(INSTALL_ROOT)$(man3dir) \
+ $(INSTALL_ROOT)$(infodir)
+ $(LIBTOOL) $(INSTALL) -c libgdbm.la $(INSTALL_ROOT)$(libdir)/libgdbm.la
+- $(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) gdbm.h \
+- $(INSTALL_ROOT)$(includedir)/gdbm.h
+- $(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/gdbm.3 \
+- $(INSTALL_ROOT)$(man3dir)/gdbm.3
+- $(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/gdbm.info \
+- $(INSTALL_ROOT)$(infodir)/gdbm.info
++ $(INSTALL_DATA) gdbm.h $(INSTALL_ROOT)$(includedir)/gdbm.h
++ $(INSTALL_DATA) $(srcdir)/gdbm.3 $(INSTALL_ROOT)$(man3dir)/gdbm.3
++ $(INSTALL_DATA) $(srcdir)/gdbm.info $(INSTALL_ROOT)$(infodir)/gdbm.info
+
+ install-compat:
+ $(srcdir)/mkinstalldirs $(INSTALL_ROOT)$(libdir) \
+ $(INSTALL_ROOT)$(includedir)
+ $(LIBTOOL) $(INSTALL) -c libgdbm_compat.la \
+ $(INSTALL_ROOT)$(libdir)/libgdbm_compat.la
+- $(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/dbm.h \
+- $(INSTALL_ROOT)$(includedir)/dbm.h
+- $(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/ndbm.h \
+- $(INSTALL_ROOT)$(includedir)/ndbm.h
++ $(INSTALL_DATA) $(srcdir)/dbm.h $(INSTALL_ROOT)$(includedir)/dbm.h
++ $(INSTALL_DATA) $(srcdir)/ndbm.h $(INSTALL_ROOT)$(includedir)/ndbm.h
+
+ #libgdbm.a: $(OBJS) gdbm.h
+ # rm -f libgdbm.a
diff --git a/main/gdbm/20-gdbm-1.8.3-compat-linking.patch b/main/gdbm/20-gdbm-1.8.3-compat-linking.patch
new file mode 100644
index 00000000000..1337d08f5b2
--- /dev/null
+++ b/main/gdbm/20-gdbm-1.8.3-compat-linking.patch
@@ -0,0 +1,19 @@
+Since libgdbm_compat uses libgdbm, make sure we link it in.
+
+http://bugs.gentoo.org/165263
+
+--- Makefile.in
++++ Makefile.in
+@@ -161,10 +161,10 @@
+ $(LIBTOOL) --mode=link $(CC) -o libgdbm.la -rpath $(libdir) \
+ -version-info $(SHLIB_VER) $(LOBJS)
+
+-libgdbm_compat.la: $(C_LOBJS) gdbm.h
++libgdbm_compat.la: $(C_LOBJS) gdbm.h libgdbm.la
+ rm -f libgdbm_compat.la
+ $(LIBTOOL) --mode=link $(CC) -o libgdbm_compat.la -rpath $(libdir) \
+- -version-info $(SHLIB_VER) $(C_LOBJS)
++ -version-info $(SHLIB_VER) $(C_LOBJS) libgdbm.la
+
+ gdbm.h: gdbm.proto gdbmerrno.h gdbm.proto2
+ rm -f gdbm.h
diff --git a/main/gdbm/30-gdbm-1.8.3-build.patch b/main/gdbm/30-gdbm-1.8.3-build.patch
new file mode 100644
index 00000000000..084f5a1d247
--- /dev/null
+++ b/main/gdbm/30-gdbm-1.8.3-build.patch
@@ -0,0 +1,21 @@
+Respect system LDFLAGS when generating gdbm libs
+
+http://bugs.gentoo.org/209730
+
+--- Makefile.in
++++ Makefile.in
+@@ -146,12 +146,12 @@
+
+ libgdbm.la: $(LOBJS) gdbm.h
+ rm -f libgdbm.la
+- $(LIBTOOL) --mode=link $(CC) -o libgdbm.la -rpath $(libdir) \
++ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o libgdbm.la -rpath $(libdir) \
+ -version-info $(SHLIB_VER) $(LOBJS)
+
+ libgdbm_compat.la: $(C_LOBJS) gdbm.h libgdbm.la
+ rm -f libgdbm_compat.la
+- $(LIBTOOL) --mode=link $(CC) -o libgdbm_compat.la -rpath $(libdir) \
++ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o libgdbm_compat.la -rpath $(libdir) \
+ -version-info $(SHLIB_VER) $(C_LOBJS) libgdbm.la
+
+ gdbm.h: gdbm.proto gdbmerrno.h gdbm.proto2
diff --git a/main/gdbm/APKBUILD b/main/gdbm/APKBUILD
new file mode 100644
index 00000000000..e20966b3234
--- /dev/null
+++ b/main/gdbm/APKBUILD
@@ -0,0 +1,40 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=gdbm
+pkgver=1.8.3
+pkgrel=0
+pkgdesc="GNU dbm is a set of database routines that use extensible hashing"
+url="http://www.gnu.org/software/gdbm/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages="$pkgname-dev $pkgname-dev"
+source="ftp://ftp.nluug.nl/pub/gnu/gdbm/gdbm-1.8.3.tar.gz
+30-gdbm-1.8.3-build.patch
+20-gdbm-1.8.3-compat-linking.patch
+10-gdbm-1.8.3-fix-install-ownership.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p0 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --includedir=/usr/include/gdbm \
+ --disable-dependency-tracking \
+ --enable-fast-install
+ make || return 1
+ make INSTALL_ROOT="$pkgdir" install || return 1
+ make INSTALL_ROOT="$pkgdir" install-compat || return 1
+ mv "${pkgdir}"/usr/include/gdbm/gdbm.h "${pkgdir}"/usr/include/
+
+}
+
+md5sums="1d1b1d5c0245b1c00aff92da751e9aa1 gdbm-1.8.3.tar.gz
+5e76bc4f51640434e4279e940f6c73fb 30-gdbm-1.8.3-build.patch
+c8e2323a9e075d5c947cb7c7aeae5384 20-gdbm-1.8.3-compat-linking.patch
+4c7b88079898d7cb380e95c8ae99a9f9 10-gdbm-1.8.3-fix-install-ownership.patch"
diff --git a/main/gettext/APKBUILD b/main/gettext/APKBUILD
new file mode 100644
index 00000000000..958e1131c8e
--- /dev/null
+++ b/main/gettext/APKBUILD
@@ -0,0 +1,23 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=gettext
+pkgver=0.17
+pkgrel=0
+pkgdesc="GNU locale utilities"
+url="http://www.gnu.org/software/gettext/gettext.html"
+license='GPL'
+depends="libiconv expat ncurses"
+makedepends="libiconv-dev"
+source="ftp://ftp.mirror.nl/pub/mirror/gnu/gettext/gettext-0.17.tar.gz"
+subpackages="$pkgname-doc $pkgname-dev"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ unset MAKEFLAGS
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+}
+
+md5sums="58a2bc6d39c0ba57823034d55d65d606 gettext-0.17.tar.gz"
diff --git a/main/ghostscript/APKBUILD b/main/ghostscript/APKBUILD
new file mode 100644
index 00000000000..e387f850f30
--- /dev/null
+++ b/main/ghostscript/APKBUILD
@@ -0,0 +1,45 @@
+# Contributor: Cameron Banta <cbanta@gmail.com>
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=ghostscript
+pkgver=8.64
+pkgrel=0
+pkgdesc="An interpreter for the PostScript language and for PDF"
+url="http://ghostscript.com/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages="$pkgname-doc"
+source="http://ghostscript.com/releases/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-drivers=FILES \
+ --disable-cups --disable-gtk --disable-cairo \
+ --docdir=/usr/share/doc/"$pkgname"
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ # license and copying
+ install -m644 -D "$srcdir/$pkgname-$pkgver/LICENSE" \
+ "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+ install -m644 -D "$srcdir/$pkgname-$pkgver/doc/COPYING" \
+ "$pkgdir/usr/share/licenses/$pkgname/COPYING"
+
+
+
+ # make the doc and examples more alpine like
+ # (the --docdir above doesn't seem to work so good)
+ mkdir -p "$pkgdir/usr/share/doc/$pkgname"
+ mv "$pkgdir/usr/share/$pkgname/$pkgver/doc" "$pkgdir/usr/share/doc/$pkgname"
+ mv "$pkgdir/usr/share/$pkgname/$pkgver/examples" "$pkgdir/usr/share/doc/$pkgname"
+
+
+}
+
+md5sums="dd927ecf7e4db38b62be3dc17b1b04d2 ghostscript-8.64.tar.gz"
diff --git a/main/glib/APKBUILD b/main/glib/APKBUILD
new file mode 100644
index 00000000000..e06678d9897
--- /dev/null
+++ b/main/glib/APKBUILD
@@ -0,0 +1,33 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=glib
+pkgver=2.20.4
+pkgrel=2
+pkgdesc="Common C routines used by Gtk+ and other libs"
+url="http://www.gtk.org"
+license='GPL'
+depends=
+makedepends="gettext-dev libiconv-dev pkgconfig"
+source="http://ftp.gnome.org/pub/gnome/sources/glib/${pkgver%.*}/glib-$pkgver.tar.bz2"
+subpackages="$pkgname-doc $pkgname-dev"
+
+depends_dev="perl gettext-dev libiconv-dev pkgconfig"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # busybox env does not handle the -w after perl. we remove it for now
+ sed -i -e '1,1s/ -w//' gobject/glib-mkenums.in
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+}
+
+# move the stuff in /usr/bin to the glib-dev package
+dev() {
+ default_dev
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+md5sums="346916673c0eab72191cf44b4afe535f glib-2.20.4.tar.bz2"
diff --git a/main/gnats/APKBUILD b/main/gnats/APKBUILD
new file mode 100644
index 00000000000..535f46ee424
--- /dev/null
+++ b/main/gnats/APKBUILD
@@ -0,0 +1,32 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gnats
+pkgver=4.1.0
+pkgrel=2
+pkgdesc="The GNU Bug Tracking System"
+url="http://www.gnu.org/software/gnats/"
+license="GPL-2"
+depends="uclibc postfix"
+makedepends="texinfo"
+install="gnats.pre-install"
+source="http://ftp.gnu.org/pub/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ $install"
+subpackages="$pkgname-doc"
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # make install needs gnats user
+ sudo sh $srcdir/$install pre_install || return 1
+
+ AWK=awk ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --sharedstatedir=/var/lib \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+ rm -f "$pkgdir"/gnats.el
+}
+
+md5sums="2add3df79336f2e193c8a9a513aefe22 gnats-4.1.0.tar.gz
+4ccae685ca8d5ed857c2a26f1e2fbc7c gnats.pre-install"
diff --git a/main/gnats/gnats.pre-install b/main/gnats/gnats.pre-install
new file mode 100644
index 00000000000..0a2e5a589be
--- /dev/null
+++ b/main/gnats/gnats.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -h /var/lib/gnatsdb -D gnats 2>/dev/null
+exit 0
diff --git a/main/gnupg/APKBUILD b/main/gnupg/APKBUILD
new file mode 100644
index 00000000000..fa1387b7db9
--- /dev/null
+++ b/main/gnupg/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gnupg
+pkgver=2.0.10
+pkgrel=0
+pkgdesc="GNU Privacy Guard 2 - a PGP replacement tool"
+url="http://www.gnupg.org/"
+license="GPL"
+depends="curl zlib libksba libgcrypt libgpg-error pth pinentry libiconv"
+makedepends="curl-dev libassuan libksba-dev libgcrypt-dev libgpg-error-dev
+ pth-dev zlib-dev libiconv-dev"
+subpackages="$pkgname-doc"
+source="ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-$pkgver.tar.bz2"
+
+build () {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="1cb778dd555f87685a8fde2f7113725e gnupg-2.0.10.tar.bz2"
diff --git a/main/gnutls/APKBUILD b/main/gnutls/APKBUILD
new file mode 100644
index 00000000000..f8dd61f2d5e
--- /dev/null
+++ b/main/gnutls/APKBUILD
@@ -0,0 +1,28 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gnutls
+pkgver=2.8.1
+pkgrel=0
+pkgdesc="A library which provides a secure connection"
+url="http://www.gnu.org/software/gnutls/"
+license="GPL"
+depends=
+makedepends="libgcrypt-dev libgpg-error-dev zlib-dev"
+install=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://ftp.gnu.org/pub/gnu/gnutls/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make -j1 || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+}
+
+md5sums="be209095e12cff0dd5e15c3cc08d2851 gnutls-2.8.1.tar.bz2"
diff --git a/main/gperf/APKBUILD b/main/gperf/APKBUILD
new file mode 100644
index 00000000000..cc97c06d5c7
--- /dev/null
+++ b/main/gperf/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gperf
+pkgver=3.0.4
+pkgrel=0
+pkgdesc="Perfect hash function generator."
+url="http://www.gnu.org/software/gperf/"
+license="GPL"
+subpackages="$pkgname-doc"
+depends="uclibc libgcc uclibc++"
+makedepends="uclibc++-dev"
+source="ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ export CXX=g++-uc
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="c1f1db32fb6598d6a93e6e88796a8632 gperf-3.0.4.tar.gz"
diff --git a/main/grep/APKBUILD b/main/grep/APKBUILD
new file mode 100644
index 00000000000..4bdc96472a2
--- /dev/null
+++ b/main/grep/APKBUILD
@@ -0,0 +1,30 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer:
+pkgname=grep
+pkgver=2.5.4
+pkgrel=1
+pkgdesc="Searches input files for lines containing a match to a specified pattern"
+url="http://www.gnu.org/software/grep/grep.html"
+license="GPL"
+depends="uclibc pcre"
+makedepends="pcre-dev"
+install="$pkgname.post-deinstall"
+subpackages="$pkgname-doc"
+source="http://mirrors.kernel.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="92258031d98d4f12dfc6a6d24057e672 grep-2.5.4.tar.gz
+b84506d253e04db3c5af9016fead45a3 grep.post-deinstall"
diff --git a/main/grep/grep.post-deinstall b/main/grep/grep.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/grep/grep.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/gross/APKBUILD b/main/gross/APKBUILD
new file mode 100644
index 00000000000..2dac13a66aa
--- /dev/null
+++ b/main/gross/APKBUILD
@@ -0,0 +1,57 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gross
+pkgver=1.0.1
+pkgrel=2
+pkgdesc="Greylisting of suspicious sources"
+url="http://code.google.com/p/gross/"
+license="BSD"
+depends=
+makedepends="c-ares-dev autoconf automake libtool sed"
+install="$pkgname.pre-install $pkgname.post-install $pkgname.pre-upgrade
+ $pkgname.post-upgrade"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://gross.googlecode.com/files/$pkgname-$pkgver.tar.gz
+ grossd.initd
+ grossd.confd
+ gross-1.0.1-configure.ac.patch
+ gross-1.0.1-default-conf.patch
+ gross-1.0.1-user.patch
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for _i in ../*.patch; do
+ msg "Applying $_i..."
+ patch -p1 < $_i || return 1
+ done
+ msg "Running autotools..."
+ aclocal --force && autoconf && automake --add-missing \
+ && libtoolize --force --copy || return 1
+
+ export lt_SED='/bin/sed'
+ export lt_cv_path_SED='/bin/sed'
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+
+ make -j1 || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -dD "$pkgdir"/var/run/gross
+ install -m755 -D "$srcdir"/grossd.initd "$pkgdir"/etc/init.d/grossd
+ install -m644 -D "$srcdir"/grossd.confd "$pkgdir"/etc/conf.d/grossd
+}
+
+md5sums="f8f81b36850dcda30cb81799b9cee3b6 gross-1.0.1.tar.gz
+b0d8635b64c4a90d72c49e868f4c4c32 grossd.initd
+5ca1c6e51c3243236e6564480b20279b grossd.confd
+bb75b119ac96b8f99831ce6df810003f gross-1.0.1-configure.ac.patch
+7c504b653c71dcf7b192bc487b3516fd gross-1.0.1-default-conf.patch
+16e184d59d520db565388f010cc75e83 gross-1.0.1-user.patch
+8f6e45b98888dbb9971f7681bf431f6f gross.pre-install
+4b55d1c5534167946cc11376d1b05c34 gross.post-install
+87e7d76dace9cedf61efc04cdb6a905c gross.pre-upgrade
+46df3a643ba26f3eb2d6a09f616e421d gross.post-upgrade"
diff --git a/main/gross/gross-1.0.1-configure.ac.patch b/main/gross/gross-1.0.1-configure.ac.patch
new file mode 100644
index 00000000000..80f9ea77621
--- /dev/null
+++ b/main/gross/gross-1.0.1-configure.ac.patch
@@ -0,0 +1,20 @@
+--- a/configure.ac.orig 2008-05-29 16:18:56 +0000
++++ b/configure.ac 2008-05-30 09:10:48 +0000
+@@ -52,7 +52,7 @@
+ then
+ AC_DEFINE([USE_SEM_OPEN], [], [Use sem_open() instead of sem_init()])
+ else
+- AC_SEARCH_LIBS(sem_init, [rt], ,
++ AC_SEARCH_LIBS(sem_init, [rt pthread], ,
+ AC_MSG_ERROR([Can't compile without semaphores.])
+ )
+ fi
+@@ -101,7 +101,7 @@
+ AC_MSG_CHECKING([whether to disable dnsbl checking])
+ AC_ARG_ENABLE(dnsbl,
+ AC_HELP_STRING([--disable-dnsbl], [Disable dnsbl checking]),
+- [AC_MSG_RESULT([yes]) ; dnsbl="no"],
++ [AC_MSG_RESULT([yes]) ; dnsbl="$enableval"],
+ [AC_MSG_RESULT([no]) ; dnsbl="yes"]
+ )
+
diff --git a/main/gross/gross-1.0.1-default-conf.patch b/main/gross/gross-1.0.1-default-conf.patch
new file mode 100644
index 00000000000..39cd90709d9
--- /dev/null
+++ b/main/gross/gross-1.0.1-default-conf.patch
@@ -0,0 +1,17 @@
+diff -ru gross-1.0.1.orig/doc/examples/grossd.conf gross-1.0.1/doc/examples/grossd.conf
+--- gross-1.0.1.orig/doc/examples/grossd.conf 2008-06-03 09:27:37 +0000
++++ gross-1.0.1/doc/examples/grossd.conf 2008-06-03 09:31:33 +0000
+@@ -71,11 +71,13 @@
+ # 'statefile' is the full path of the file that the server will use to
+ # store the state information.
+ # statefile = /var/db/grossd.state
++statefile = /var/db/gross/state
+
+ # 'pidfile' is the full path of the file grossd writes its pid into.
+ # You can set parameter 'check', if you want to keep grossd
+ # from starting if pidfile already exists.
+ # pidfile = /var/run/grossd.pid;check
++pidfile = /var/run/gross/grossd.pid
+
+ # 'log_method' is used to list all the possible logging facilities.
+ # currently only syslog is implemented
diff --git a/main/gross/gross-1.0.1-user.patch b/main/gross/gross-1.0.1-user.patch
new file mode 100644
index 00000000000..a20279f0030
--- /dev/null
+++ b/main/gross/gross-1.0.1-user.patch
@@ -0,0 +1,72 @@
+Index: src/gross.c
+===================================================================
+--- a/src/gross.c (revision 491)
++++ b/src/gross.c (working copy)
+@@ -553,7 +553,7 @@
+ void
+ usage(void)
+ {
+- printf("Usage: grossd [-CDdhnPprV] [-f configfile]\n");
++ printf("Usage: grossd [-CDdhnPpruV] [-f configfile]\n");
+ printf(" -C create statefile and exit\n");
+ printf(" -D Enable debug logging (insane verbosity with -DD)\n");
+ printf(" -d Run grossd as a foreground process\n");
+@@ -563,6 +563,7 @@
+ printf(" -p file write the process id in a pidfile\n");
+ printf(" -P file same as -p, but pid file must not exist\n");
+ printf(" -r disable replication\n");
++ printf(" -u user run gross as user\n");
+ printf(" -V version information\n");
+ exit(EXIT_USAGE);
+ }
+@@ -612,6 +613,7 @@
+ pool_limits_t limits;
+ sigset_t mask, oldmask;
+ struct passwd *pwd;
++ char *user = "nobody";
+
+ #ifdef DNSBL
+ dns_check_info_t *dns_check_info;
+@@ -623,7 +625,7 @@
+ daemon_shutdown(EXIT_FATAL, "Couldn't initialize context");
+
+ /* command line arguments */
+- while ((c = getopt(argc, argv, ":drf:VCDnp:P:")) != -1) {
++ while ((c = getopt(argc, argv, ":drf:VCDnp:P:u:")) != -1) {
+ switch (c) {
+ case 'd':
+ ctx->config.flags |= FLG_NODAEMON;
+@@ -663,6 +665,9 @@
+ ctx->config.flags |= FLG_CHECK_PIDFILE;
+ ctx->config.flags |= FLG_CREATE_PIDFILE;
+ break;
++ case 'u':
++ user = optarg;
++ break;
+ case 'h':
+ usage();
+ break;
+@@ -675,16 +680,16 @@
+
+ /* grossd doesn't need to be running as root */
+ if (geteuid() == 0) {
+- logstr(GLOG_DEBUG, "Running as root: setuid() to 'nobody'");
+- pwd = getpwnam("nobody");
++ logstr(GLOG_DEBUG, "Running as root: setuid() to '%s'", user);
++ pwd = getpwnam(user);
+ if (NULL == pwd)
+- daemon_shutdown(EXIT_FATAL, "Running as root: can't find user 'nobody'");
++ daemon_shutdown(EXIT_FATAL, "Running as root: can't find user '%s'", user);
+ if (setgid(pwd->pw_gid) != 0)
+- daemon_shutdown(EXIT_FATAL, "Running as root: can't setgid(%d) to 'nobody': %s",
+- pwd->pw_gid, strerror(errno));
++ daemon_shutdown(EXIT_FATAL, "Running as root: can't setgid(%d) to '%s': %s",
++ pwd->pw_gid, user, strerror(errno));
+ if (setuid(pwd->pw_uid) != 0)
+- daemon_shutdown(EXIT_FATAL, "Running as root: can't setuid(%d) to 'nobody': %s",
+- pwd->pw_uid, strerror(errno));
++ daemon_shutdown(EXIT_FATAL, "Running as root: can't setuid(%d) to '%s': %s",
++ pwd->pw_uid, user, strerror(errno));
+ }
+
+ config = default_config();
diff --git a/main/gross/gross.post-install b/main/gross/gross.post-install
new file mode 100644
index 00000000000..df06670a418
--- /dev/null
+++ b/main/gross/gross.post-install
@@ -0,0 +1,2 @@
+#!/bin/sh
+chown -R gross:gross /var/run/gross
diff --git a/main/gross/gross.post-upgrade b/main/gross/gross.post-upgrade
new file mode 100644
index 00000000000..1e52785e15e
--- /dev/null
+++ b/main/gross/gross.post-upgrade
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+moved=
+for i in /etc/runlevels/*/gross; do
+ if [ -L $i ]; then
+ mv ${i} ${i}d
+ moved=1
+ fi
+done
+
+if [ -n "$moved" ]; then
+ echo " *"
+ echo " * NOTICE: /etc/init.d/gross is renamed to /etc/init.d/grossd"
+ echo " *"
+fi
+
diff --git a/main/gross/gross.pre-install b/main/gross/gross.pre-install
new file mode 100644
index 00000000000..c3844d7a5e5
--- /dev/null
+++ b/main/gross/gross.pre-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+adduser -H -s /bin/false -D gross 2>/dev/null
+exit 0
diff --git a/main/gross/gross.pre-upgrade b/main/gross/gross.pre-upgrade
new file mode 100644
index 00000000000..90361bcc655
--- /dev/null
+++ b/main/gross/gross.pre-upgrade
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+old=/etc/conf.d/gross
+new=/etc/conf.d/grossd
+
+if [ -f "$old" ] && [ ! -f "$new" ]; then
+ mv "$old" "$new"
+ echo " *"
+ echo " * NOTICE: $old was renamed to $new"
+ echo " *"
+fi
+
diff --git a/main/gross/grossd.confd b/main/gross/grossd.confd
new file mode 100644
index 00000000000..646e12f9d74
--- /dev/null
+++ b/main/gross/grossd.confd
@@ -0,0 +1,6 @@
+#
+# Specify daemon $OPTS here.
+#
+
+OPTS=""
+
diff --git a/main/gross/grossd.initd b/main/gross/grossd.initd
new file mode 100644
index 00000000000..3d1c43d7088
--- /dev/null
+++ b/main/gross/grossd.initd
@@ -0,0 +1,35 @@
+#!/sbin/runscript
+
+NAME="grossd"
+DAEMON="/usr/sbin/$NAME"
+DAEMON_USER="gross"
+DAEMON_GROUP="gross"
+
+depend() {
+ need net
+}
+
+check_config() {
+ if [ ! -f /var/db/gross/state ] ; then
+ einfo "Generating Gross database..."
+ install -dD -o${DAEMON_USER} -g${DAEMON_GROUP} /var/db/gross
+ ${DAEMON} -Cu ${DAEMON_USER} > /dev/null
+ fi
+}
+
+start() {
+ check_config || return 1
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet \
+ --exec ${DAEMON} -- \
+ -p /var/run/gross/grossd.pid \
+ -u ${DAEMON_USER} ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --pidfile /var/run/gross/grossd.pid
+ eend $?
+}
+
diff --git a/main/gzip/APKBUILD b/main/gzip/APKBUILD
new file mode 100644
index 00000000000..eb06884d6d5
--- /dev/null
+++ b/main/gzip/APKBUILD
@@ -0,0 +1,34 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gzip
+pkgver=1.3.12
+pkgrel=2
+pkgdesc="A popular data compression program"
+subpackages="$pkgname-doc"
+url="http://www.gnu.org/software/gzip/"
+license="GPL2"
+depends=
+makedepends=
+install="$pkgname.post-deinstall"
+source="http://ftp.gnu.org/gnu/gzip/gzip-1.3.12.tar.gz
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # avoid text relocation
+ export DEFS="NO_ASM"
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --disable-nls \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR=$pkgdir install
+
+ mkdir -p "$pkgdir"/bin
+ mv "$pkgdir"/usr/bin/gzip "$pkgdir"/usr/bin/gunzip "$pkgdir"/bin/
+ ln -s /bin/gzip "$pkgdir"/usr/bin/gzip
+ ln -s /bin/gunzip "$pkgdir"/usr/bin/gunzip
+}
+md5sums="b5bac2d21840ae077e0217bc5e4845b1 gzip-1.3.12.tar.gz
+b84506d253e04db3c5af9016fead45a3 gzip.post-deinstall"
diff --git a/main/gzip/gzip.post-deinstall b/main/gzip/gzip.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/gzip/gzip.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/haserl/APKBUILD b/main/haserl/APKBUILD
new file mode 100644
index 00000000000..2c4e08e4930
--- /dev/null
+++ b/main/haserl/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=haserl
+pkgver=0.9.25
+pkgrel=1
+pkgdesc="Html And Shell Embedded Report Language"
+url="http://haserl.sourceforge.net/"
+license="GPL-2"
+depends="lua uclibc"
+makedepends="lua-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr --with-lua || return 1
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+ chmod 4111 "$pkgdir"/usr/bin/haserl
+}
+
+md5sums="906c634a2af4ac3a4b656ef4e244c4cd haserl-0.9.25.tar.gz"
diff --git a/main/heimdal/001_all_heimdal-no_libedit.patch b/main/heimdal/001_all_heimdal-no_libedit.patch
new file mode 100644
index 00000000000..a551bdce158
--- /dev/null
+++ b/main/heimdal/001_all_heimdal-no_libedit.patch
@@ -0,0 +1,10 @@
+--- cf/krb-readline.m4 2005-06-16 18:28:32.000000000 +0200
++++ cf/krb-readline.m4 2005-06-27 23:17:06.000000000 +0200
+@@ -6,7 +6,6 @@
+ dnl el_init
+
+ AC_DEFUN([KRB_READLINE],[
+-AC_FIND_FUNC_NO_LIBS(el_init, edit, [], [], [$LIB_tgetent])
+ if test "$ac_cv_func_el_init" = yes ; then
+ AC_CACHE_CHECK(for four argument el_init, ac_cv_func_el_init_four,[
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
diff --git a/main/heimdal/002_all_heimdal-fPIC.patch b/main/heimdal/002_all_heimdal-fPIC.patch
new file mode 100644
index 00000000000..c67dbae7646
--- /dev/null
+++ b/main/heimdal/002_all_heimdal-fPIC.patch
@@ -0,0 +1,12 @@
+--- lib/editline/Makefile.am 2005-06-16 18:28:44.000000000 +0200
++++ lib/editline/Makefile.am 2005-06-27 23:21:02.000000000 +0200
+@@ -41,6 +41,9 @@
+
+ EXTRA_DIST = $(man_MANS)
+
++$(libeditline_la_OBJECTS): %.lo: %.c
++ $(LTCOMPILE) -fPIC -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
++
+ snprintf.c:
+ $(LN_S) $(srcdir)/../roken/snprintf.c .
+ strdup.c:
diff --git a/main/heimdal/003_all_heimdal-rxapps.patch b/main/heimdal/003_all_heimdal-rxapps.patch
new file mode 100644
index 00000000000..40fc05f083d
--- /dev/null
+++ b/main/heimdal/003_all_heimdal-rxapps.patch
@@ -0,0 +1,22 @@
+--- appl/kx/rxtelnet.in 2005-06-16 18:29:10.000000000 +0200
++++ appl/kx/rxtelnet.in 2005-06-27 23:21:34.000000000 +0200
+@@ -2,7 +2,7 @@
+ # $Id: rxtelnet.in,v 1.31 2004/03/07 17:22:06 lha Exp $
+ #
+ usage="Usage: $0 [-l username] [-k] [-fF] [-t args_to_telnet] [-x args_to_xterm] [-K args_to_kx] [-w term_emulator] [-b telnet_binary] [-n] [-v] [-h | --help] [--version] host [port]"
+-binary=telnet
++binary=ktelnet
+ term=
+ kx_args=-P
+ while true
+--- appl/kx/rxterm.in 2005-06-16 18:29:10.000000000 +0200
++++ appl/kx/rxterm.in 2005-06-27 23:21:55.000000000 +0200
+@@ -2,7 +2,7 @@
+ # $Id: rxterm.in,v 1.23 2002/03/18 17:37:34 joda Exp $
+ #
+ usage="Usage: $0 [-l username] [-k] [-f] [-r rsh_args] [-x xterm_args] [-K kx_args] [-w term_emulator] [-b rsh_binary][-v] [-h | --help] [--version] host"
+-binary=rsh
++binary=krsh
+ term=xterm
+ while true
+ do
diff --git a/main/heimdal/005_all_heimdal-suid_fix.patch b/main/heimdal/005_all_heimdal-suid_fix.patch
new file mode 100644
index 00000000000..35a9ed9f6b4
--- /dev/null
+++ b/main/heimdal/005_all_heimdal-suid_fix.patch
@@ -0,0 +1,20 @@
+--- appl/su/Makefile.am 2005-06-16 18:27:46.000000000 +0200
++++ appl/su/Makefile.am 2005-06-27 23:25:21.000000000 +0200
+@@ -7,6 +7,7 @@
+ bin_PROGRAMS = su
+ bin_SUIDS = su
+ su_SOURCES = su.c supaths.h
++su_LDFLAGS = -Wl,-z,now
+ man_MANS = su.1
+
+ LDADD = $(LIB_kafs) \
+--- appl/otp/Makefile.am 2005-06-16 18:28:46.000000000 +0200
++++ appl/otp/Makefile.am 2005-06-27 23:25:40.000000000 +0200
+@@ -8,6 +8,7 @@
+ bin_SUIDS = otp
+ otp_SOURCES = otp.c otp_locl.h
+ otpprint_SOURCES = otpprint.c otp_locl.h
++otp_LDFLAGS = -Wl,-z,now
+
+ man_MANS = otp.1 otpprint.1
+
diff --git a/main/heimdal/013_all_heimdal-pthread-lib.patch b/main/heimdal/013_all_heimdal-pthread-lib.patch
new file mode 100644
index 00000000000..19f8794075f
--- /dev/null
+++ b/main/heimdal/013_all_heimdal-pthread-lib.patch
@@ -0,0 +1,11 @@
+--- heimdal-0.7.1/cf/pthreads.m4.old 2005-09-09 12:12:28.000000000 +0000
++++ heimdal-0.7.1/cf/pthreads.m4 2005-09-17 22:23:23.000000000 +0000
+@@ -32,7 +32,7 @@
+ 2.*)
+ native_pthread_support=yes
+ PTHREADS_CFLAGS=-pthread
+- PTHREADS_LIBS=-pthread
++ PTHREADS_LIBS=-lpthread
+ ;;
+ esac
+ ;;
diff --git a/main/heimdal/014_all_heimdal-path.patch b/main/heimdal/014_all_heimdal-path.patch
new file mode 100644
index 00000000000..36a86f1f93b
--- /dev/null
+++ b/main/heimdal/014_all_heimdal-path.patch
@@ -0,0 +1,50 @@
+--- appl/rcp/rcp.c.old 2006-05-03 13:31:59.398493625 +0200
++++ appl/rcp/rcp.c 2006-05-03 13:32:04.494485981 +0200
+@@ -34,7 +34,7 @@
+ #include "rcp_locl.h"
+ #include <getarg.h>
+
+-#define RSH_PROGRAM "rsh"
++#define RSH_PROGRAM "krsh"
+
+ struct passwd *pwd;
+ uid_t userid;
+--- appl/rcp/rcp_locl.h.old 2006-05-03 02:30:31.602025409 +0200
++++ appl/rcp/rcp_locl.h 2006-05-03 02:30:35.886018983 +0200
+@@ -64,4 +64,4 @@
+ #define _PATH_CP "/bin/cp"
+ #endif
+ #undef _PATH_RSH
+-#define _PATH_RSH BINDIR "/rsh"
++#define _PATH_RSH BINDIR "/krsh"
+--- appl/telnet/telnetd/telnetd.h.old 2006-05-03 02:23:14.582680939 +0200
++++ appl/telnet/telnetd/telnetd.h 2006-05-03 02:23:23.746667193 +0200
+@@ -192,7 +192,7 @@
+ #endif
+
+ #undef _PATH_LOGIN
+-#define _PATH_LOGIN BINDIR "/login"
++#define _PATH_LOGIN BINDIR "/klogin"
+
+ /* fallbacks */
+
+--- appl/login/shadow.c.old 2006-05-05 06:31:29.517138115 +0200
++++ appl/login/shadow.c 2006-05-05 06:32:26.433052741 +0200
+@@ -38,7 +38,7 @@
+ #ifdef HAVE_SHADOW_H
+
+ #ifndef _PATH_CHPASS
+-#define _PATH_CHPASS "/usr/bin/passwd"
++#define _PATH_CHPASS "/usr/bin/kpasswd"
+ #endif
+
+ static int
+@@ -52,7 +52,7 @@
+ printf("fork /bin/passwd");
+ exit(1);
+ case 0:
+- execlp(_PATH_CHPASS, "passwd", who->pw_name, (char *) 0);
++ execlp(_PATH_CHPASS, "kpasswd", who->pw_name, (char *) 0);
+ exit(1);
+ default:
+ waitpid(pid, &status, 0);
diff --git a/main/heimdal/022_all_heimdal-as-needed.patch b/main/heimdal/022_all_heimdal-as-needed.patch
new file mode 100644
index 00000000000..69c791778a5
--- /dev/null
+++ b/main/heimdal/022_all_heimdal-as-needed.patch
@@ -0,0 +1,22 @@
+--- lib/roken/Makefile.am.old 2007-11-05 19:42:53.000000000 +0100
++++ lib/roken/Makefile.am 2007-11-05 19:43:12.000000000 +0100
+@@ -107,7 +107,7 @@
+ ifaddrs.hin \
+ vis.hin
+
+-libroken_la_LIBADD = @LTLIBOBJS@
++libroken_la_LIBADD = @LTLIBOBJS@ $(LIB_crypt)
+
+ $(LTLIBOBJS) $(libroken_la_OBJECTS): roken.h $(XHEADERS)
+
+--- lib/editline/Makefile.am.old 2007-11-05 19:46:08.000000000 +0100
++++ lib/editline/Makefile.am 2007-11-05 20:06:54.000000000 +0100
+@@ -36,6 +36,8 @@
+ unix.h \
+ $(EXTRA_SOURCE)
+
++libeditline_la_LIBADD = $(LIB_tgetent)
++
+ EXTRA_SOURCE = $(ES)
+
+ libel_compat_la_SOURCES = edit_compat.c edit_compat.h
diff --git a/main/heimdal/APKBUILD b/main/heimdal/APKBUILD
new file mode 100644
index 00000000000..a494e201a62
--- /dev/null
+++ b/main/heimdal/APKBUILD
@@ -0,0 +1,161 @@
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=heimdal
+pkgver=1.2.1
+pkgrel=3
+pkgdesc="An implementation of Kerberos 5"
+url="http://www.h5l.org/"
+license="BSD"
+depends=
+makedepends="gawk readline-dev e2fsprogs-dev sqlite-dev autoconf automake
+ libtool pkgconfig"
+install=
+subpackages="$pkgname-doc $pkgname-dev $pkgname-ftp $pkgname-telnet \
+$pkgname-su $pkgname-rsh $pkgname-rcp $pkgname-pagsh $pkgname-kf"
+source="http://www.h5l.org/dist/src/$pkgname-$pkgver.tar.gz
+001_all_heimdal-no_libedit.patch
+002_all_heimdal-fPIC.patch
+003_all_heimdal-rxapps.patch
+005_all_heimdal-suid_fix.patch
+013_all_heimdal-pthread-lib.patch
+014_all_heimdal-path.patch
+022_all_heimdal-as-needed.patch
+heimdal-system_sqlite.patch
+heimdal-r23235-kb5-libwind_la.patch
+heimdal-r23238-kb5_locl_h-wind_h.patch
+"
+
+# krb5.h needs com_err.h
+depends_dev="e2fsprogs-dev"
+
+build() {
+ [ -e /usr/lib/libasn1.so ] && echo "## remove old heimdal pkg first ##" && return 1
+
+ cd "$srcdir/$pkgname-$pkgver"
+
+ patch -Np0 -i ../../001_all_heimdal-no_libedit.patch || return 1
+ patch -Np0 -i ../../002_all_heimdal-fPIC.patch || return 1
+ patch -Np0 -i ../../003_all_heimdal-rxapps.patch || return 1
+ patch -Np0 -i ../../005_all_heimdal-suid_fix.patch || return 1
+ patch -Np1 -i ../../013_all_heimdal-pthread-lib.patch || return 1
+ patch -Np0 -i ../../014_all_heimdal-path.patch || return 1
+ patch -Np0 -i ../../022_all_heimdal-as-needed.patch || return 1
+ patch -Np0 -i ../../heimdal-system_sqlite.patch || return 1
+ patch -Np2 -i ../../heimdal-r23235-kb5-libwind_la.patch || return 1
+ patch -Np2 -i ../../heimdal-r23238-kb5_locl_h-wind_h.patch || return 1
+
+ # name clash with ruserpass in netdb.h
+ sed -i -e 's/ruserpass/ruserpw/g' appl/ftp/ftp/*.[ch] || return 1
+
+ sed -i -e 's|var/heimdal|var/lib/heimdal|g' configure.in \
+ doc/setup.texi doc/heimdal.info kadmin/kadmind.8 kdc/kdc.8 \
+ lib/hdb/hdb.h lib/krb5/krb5.conf.5 lib/krb5/krb5.conf.cat5
+
+ sh ./autogen.sh || return 1
+
+ export LDFLAGS="${LDFLAGS} -Wl,--as-needed"
+
+ ./configure --prefix=/usr \
+ --enable-shared=yes --without-x \
+ --disable-berkeley-db \
+ --disable-netinfo \
+ --with-readline-lib=/usr/lib \
+ --with-readline-include=/usr/include/readline \
+ --with-openssl=/usr
+
+ make || return 1
+ make DESTDIR="$pkgdir" exec_prefix=/usr sysconfdir=/etc \
+ mandir=/usr/share/man infodir=/usr/share/info datadir=/var/lib/heimdal \
+ localstatedir=/var/lib/heimdal libexecdir=/usr/sbin install
+
+ install -m644 -D krb5.conf ${pkgdir}/etc/krb5.conf || return 1
+ install -m755 -D ../../heimdal-kadmind.init ${pkgdir}/etc/init.d/heimdal-kadmind
+ install -m755 -D ../../heimdal-kdc.init ${pkgdir}/etc/init.d/heimdal-kdc
+ install -m755 -D ../../heimdal-kpasswdd.init ${pkgdir}/etc/init.d/heimdal-kpasswdd
+
+ # Remove editline, we use libreadline
+ rm ${pkgdir}/usr/lib/libeditline.* || return 1
+ rm ${pkgdir}/usr/include/editline.h || return 1
+ rm ${pkgdir}/usr/share/man/man3/editline.* || return 1
+
+ # Rename daemons and their manpages
+ for i in telnetd ftpd rshd; do
+ mv ${pkgdir}/usr/share/man/man8/${i}.8 ${pkgdir}/usr/share/man/man8/k${i}.8 || return 1
+ mv ${pkgdir}/usr/sbin/${i} ${pkgdir}/usr/sbin/k${i} || return 1
+ done
+
+ # Rename clients and their manpages
+ for i in rcp rsh telnet ftp su login; do
+ if [ -f ${pkgdir}/usr/share/man/man1/${i}.1 ]; then
+ mv ${pkgdir}/usr/share/man/man1/${i}.1 ${pkgdir}/usr/share/man/man1/k${i}.1 || return 1
+ fi
+ mv ${pkgdir}/usr/bin/${i} ${pkgdir}/usr/bin/k${i} || return 1
+ done
+ rm -rf ${pkgdir}/usr/share/man/cat{1,3,5,8}
+
+ # Remove conflicts
+ rm ${pkgdir}/usr/share/man/man5/ftpusers.5*
+
+ # Compress info pages
+ for page in heimdal hx509; do
+ gzip -9 ${pkgdir}/usr/share/info/${page}.info
+ done
+
+ # Install the license
+ install -d ${pkgdir}/usr/share/licenses/${pkgname}
+ install -D -m644 ${srcdir}/${pkgname}-${pkgver}/LICENSE \
+ ${pkgdir}/usr/share/licenses/${pkgname}/ || return 1
+}
+
+ftp() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/kftp $subpkgdir/usr/bin/kftp
+ mkdir -p $subpkgdir/usr/sbin/
+ mv $pkgdir/usr/sbin/kftpd $subpkgdir/usr/sbin/kftpd
+}
+
+telnet() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/ktelnet $subpkgdir/usr/bin/ktelnet
+ mkdir -p $subpkgdir/usr/sbin/
+ mv $pkgdir/usr/sbin/ktelnetd $subpkgdir/usr/sbin/ktelnetd
+}
+
+su() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/ksu $subpkgdir/usr/bin/ksu
+}
+
+rsh() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/krsh $subpkgdir/usr/bin/krsh
+ mkdir -p $subpkgdir/usr/sbin/
+ mv $pkgdir/usr/sbin/krshd $subpkgdir/usr/sbin/krshd
+}
+
+rcp() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/krcp $subpkgdir/usr/bin/krcp
+}
+
+pagsh() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/pagsh $subpkgdir/usr/bin/pagsh
+}
+
+kf() {
+ mkdir -p $subpkgdir/usr/bin/
+ mv $pkgdir/usr/bin/kf $subpkgdir/usr/bin/kf
+}
+
+md5sums="6e5028077e2a6b101a4a72801ba71b9e heimdal-1.2.1.tar.gz
+98e28f11f906c967aac22d6184102c9e 001_all_heimdal-no_libedit.patch
+6d5571bdedba2e2423b90bccdbac2c0a 002_all_heimdal-fPIC.patch
+2feec3924ee5230b54175b4d4000c872 003_all_heimdal-rxapps.patch
+45aeb207f360f9f4e9e0fabc8bfeecbc 005_all_heimdal-suid_fix.patch
+1b8665b771c4eb6b56ea8582c96e56e3 013_all_heimdal-pthread-lib.patch
+8208ae8c0b6ff5ab4f64af1693e9e396 014_all_heimdal-path.patch
+d7649e078c87d2ca997080f0deb527c0 022_all_heimdal-as-needed.patch
+949a389ebe7652861b2e178a7e0f1ed9 heimdal-system_sqlite.patch
+072f6b2550693adb30117394b1dd354e heimdal-r23235-kb5-libwind_la.patch
+7b4537b0e8bde95214211091e55eacf5 heimdal-r23238-kb5_locl_h-wind_h.patch"
diff --git a/main/heimdal/heimdal-kadmind.init b/main/heimdal/heimdal-kadmind.init
new file mode 100755
index 00000000000..b58ac994dfa
--- /dev/null
+++ b/main/heimdal/heimdal-kadmind.init
@@ -0,0 +1,24 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-crypt/heimdal/files/heimdal-kadmind,v 1.3 2004/09/13 22:44:54 solar Exp $
+
+depend() {
+ need net
+ use heimdal-kdc
+ after logger
+}
+
+start() {
+ ebegin "Starting heimdal kadmind"
+ /usr/sbin/kadmind &
+ echo $! > /var/run/heimdal-kadmind.pid
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping heimdal kadmind"
+ start-stop-daemon --stop --quiet --exec \
+ /usr/sbin/kadmind
+ eend $?
+}
diff --git a/main/heimdal/heimdal-kdc.init b/main/heimdal/heimdal-kdc.init
new file mode 100755
index 00000000000..753a101c301
--- /dev/null
+++ b/main/heimdal/heimdal-kdc.init
@@ -0,0 +1,23 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-crypt/heimdal/files/heimdal-kdc,v 1.2 2004/09/13 15:40:34 dragonheart Exp $
+
+depend() {
+ need net
+ after logger
+}
+
+start() {
+ ebegin "Starting heimdal kdc"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/kdc -- --detach
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping heimdal kdc"
+ start-stop-daemon --stop --quiet --exec \
+ /usr/sbin/kdc
+ eend $?
+}
diff --git a/main/heimdal/heimdal-kpasswdd.init b/main/heimdal/heimdal-kpasswdd.init
new file mode 100755
index 00000000000..517cb862109
--- /dev/null
+++ b/main/heimdal/heimdal-kpasswdd.init
@@ -0,0 +1,24 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-crypt/heimdal/files/heimdal-kpasswdd,v 1.3 2004/09/13 22:44:54 solar Exp $
+
+depend() {
+ need net
+ use heimdal-kdc
+ after logger
+}
+
+start() {
+ ebegin "Starting heimdal kpasswdd"
+ start-stop-daemon --background --start --quiet --exec \
+ /usr/sbin/kpasswdd
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping heimdal kpasswdd"
+ start-stop-daemon --stop --quiet --exec \
+ /usr/sbin/kpasswdd
+ eend $?
+}
diff --git a/main/heimdal/heimdal-r23235-kb5-libwind_la.patch b/main/heimdal/heimdal-r23235-kb5-libwind_la.patch
new file mode 100644
index 00000000000..88c02e598c6
--- /dev/null
+++ b/main/heimdal/heimdal-r23235-kb5-libwind_la.patch
@@ -0,0 +1,10 @@
+--- trunk/heimdal/lib/krb5/Makefile.am 2008-06-01 22:25:41 UTC (rev 23234)
++++ trunk/heimdal/lib/krb5/Makefile.am 2008-06-01 22:25:53 UTC (rev 23235)
+@@ -57,6 +57,7 @@
+ $(LIB_com_err) \
+ $(LIB_hcrypto) \
+ $(top_builddir)/lib/asn1/libasn1.la \
++ ../wind/libwind.la \
+ $(LIBADD_roken) \
+ $(LIB_door_create) \
+ $(LIB_dlopen)
diff --git a/main/heimdal/heimdal-r23238-kb5_locl_h-wind_h.patch b/main/heimdal/heimdal-r23238-kb5_locl_h-wind_h.patch
new file mode 100644
index 00000000000..5390b2cf69a
--- /dev/null
+++ b/main/heimdal/heimdal-r23238-kb5_locl_h-wind_h.patch
@@ -0,0 +1,11 @@
+--- trunk/heimdal/lib/krb5/krb5_locl.h 2008-06-01 22:26:24 UTC (rev 23237)
++++ trunk/heimdal/lib/krb5/krb5_locl.h 2008-06-01 22:26:43 UTC (rev 23238)
+@@ -131,6 +131,8 @@
+ #include <parse_time.h>
+ #include <base64.h>
+
++#include <wind.h>
++
+ #include "crypto-headers.h"
+
+
diff --git a/main/heimdal/heimdal-system_sqlite.patch b/main/heimdal/heimdal-system_sqlite.patch
new file mode 100644
index 00000000000..2f8254e4d6b
--- /dev/null
+++ b/main/heimdal/heimdal-system_sqlite.patch
@@ -0,0 +1,56 @@
+diff -Naur tmp-old/configure.in tmp-new/configure.in
+--- configure.in 2008-06-08 08:06:38.000000000 +0000
++++ configure.in 2008-06-08 08:15:29.000000000 +0000
+@@ -104,6 +104,8 @@
+
+ KRB_PTHREADS
+
++PKG_CHECK_MODULES([sqlite], [sqlite3])
++
+ AC_ARG_ENABLE(dce,
+ AS_HELP_STRING([--enable-dce],[if you want support for DCE/DFS PAG's]))
+ if test "$enable_dce" = yes; then
+diff -Naur tmp-old/lib/Makefile.am tmp-new/lib/Makefile.am
+--- lib/Makefile.am 2008-06-07 16:53:11.000000000 +0000
++++ lib/Makefile.am 2008-06-07 16:55:58.000000000 +0000
+@@ -18,6 +18,6 @@
+ dir_hcrypto = hcrypto
+ endif
+
+-SUBDIRS = roken vers editline $(dir_com_err) sl wind asn1 sqlite \
++SUBDIRS = roken vers editline $(dir_com_err) sl wind asn1 \
+ $(dir_hcrypto) hx509 krb5 ntlm kafs gssapi hdb kadm5 \
+ auth $(dir_45) $(dir_otp) $(dir_dce)
+diff -Naur tmp-old/lib/krb5/Makefile.am tmp-new/lib/krb5/Makefile.am
+--- lib/krb5/Makefile.am 2008-06-07 16:54:02.000000000 +0000
++++ lib/krb5/Makefile.am 2008-06-08 08:17:00.000000000 +0000
+@@ -2,7 +2,7 @@
+
+ include $(top_srcdir)/Makefile.am.common
+
+-AM_CPPFLAGS += $(INCLUDE_krb4) $(INCLUDE_hcrypto) -I../com_err -I$(srcdir)/../com_err -I$(srcdir)/../sqlite
++AM_CPPFLAGS += $(INCLUDE_krb4) $(INCLUDE_hcrypto) -I../com_err -I$(srcdir)/../com_err $(sqlite_CFLAGS)
+
+ bin_PROGRAMS = verify_krb5_conf
+
+@@ -53,7 +53,7 @@
+
+ libkrb5_la_LIBADD = \
+ $(LIB_pkinit) \
+- ../sqlite/libsqlite.la \
++ $(sqlite_LIBS) \
+ $(LIB_com_err) \
+ $(LIB_hcrypto) \
+ $(top_builddir)/lib/asn1/libasn1.la \
+diff -Naur tmp-old/lib/krb5/scache.c tmp-new/lib/krb5/scache.c
+--- lib/krb5/scache.c 2008-06-07 16:54:30.000000000 +0000
++++ lib/krb5/scache.c 2008-06-07 17:01:43.000000000 +0000
+@@ -32,7 +32,7 @@
+ */
+
+ #include "krb5_locl.h"
+-#include "sqlite3.h"
++#include <sqlite3.h>
+
+ RCSID("$Id: heimdal-system_sqlite.patch,v 1.1 2008/06/11 07:27:47 mueli Exp $");
+
diff --git a/main/htop/APKBUILD b/main/htop/APKBUILD
new file mode 100644
index 00000000000..b6e4ee88801
--- /dev/null
+++ b/main/htop/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer:Carlo Landmeter
+pkgname=htop
+pkgver=0.8.1
+pkgrel=1
+pkgdesc="An interactive process viewer for Linux"
+url="http://htop.sourceforge.net"
+license='GPL'
+depends='ncurses ncurses-terminfo uclibc'
+makedepends="ncurses-dev"
+source="http://surfnet.dl.sourceforge.net/sourceforge/htop/$pkgname-$pkgver.tar.gz"
+
+subpackages="$pkgname-doc"
+
+build() {
+ cd $startdir/src/$pkgname-$pkgver
+ ./configure --prefix=/usr --mandir=/usr/share/man
+ make || return 1
+ make prefix=$startdir/pkg/usr mandir=$startdir/pkg/usr/share/man install
+}
+
+md5sums='f0b259ca29175656de48bf0fa0a2e619 htop-0.8.1.tar.gz'
diff --git a/main/hunspell/APKBUILD b/main/hunspell/APKBUILD
new file mode 100644
index 00000000000..6883855aee4
--- /dev/null
+++ b/main/hunspell/APKBUILD
@@ -0,0 +1,23 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=hunspell
+pkgver=1.2.8
+pkgrel=0
+pkgdesc="Spell checker and morphological analyzer library and program"
+url="http://hunspell.sourceforge.net/"
+license="GPL LGPL MPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="libgcc uclibc++"
+makedepends="uclibc++-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir/hunspell-$pkgver"
+ export CXX="${CXX_UC:-g++-uc}"
+
+ ./configure --prefix=/usr --disable-static || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ rm -rf "$pkgdir"/usr/share/locale/locale.alias
+}
+md5sums="1177af54a09e320d2c24015f29c3a93e hunspell-1.2.8.tar.gz"
diff --git a/main/hylafax/APKBUILD b/main/hylafax/APKBUILD
new file mode 100644
index 00000000000..42450d46782
--- /dev/null
+++ b/main/hylafax/APKBUILD
@@ -0,0 +1,82 @@
+# Contributor: Cameron Banta <cbanta@gmail.com>
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=hylafax
+pkgver=4.4.4
+pkgrel=0
+pkgdesc="Sends and receives faxes"
+url="http://www.hylafax.org/"
+license="custom"
+#depends on gcc for libgcc_s.so, it's scripts are hardcoded to bash
+depends="ghostscript bash"
+makedepends="zlib-dev tiff-dev uclibc++-dev"
+install="hylafax.post-install"
+subpackages="$pkgname-doc"
+source="ftp://ftp.hylafax.org/source/$pkgname-$pkgver.tar.gz
+ $install
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # Patch configure c++ problem
+ sed -i -e 's:"iostream.h":<iostream>\n using namespace std;:g' \
+ configure
+
+ # the configure script does not handle ccache or distcc
+ export CC=gcc
+ ./configure --nointeractive --disable-pam \
+ --with-CXX=/usr/bin/g++-uc \
+ --with-DIR_BIN=/usr/bin \
+ --with-DIR_SBIN=/usr/sbin \
+ --with-DIR_LIB=/usr/lib \
+ --with-DIR_LIBEXEC=/usr/sbin \
+ --with-DIR_LIBDATA=/var/spool/"$pkgname"/lib \
+ --with-DIR_LOCKS=/var/lock \
+ --with-DIR_MAN=/usr/share/man \
+ --with-DIR_SPOOL=/var/spool/"$pkgname" \
+ --with-DIR_HTML=/usr/share/doc/"$pkgname"/html \
+ --with-PATH_IMPRIP="" \
+ --with-SYSVINIT=no \
+ --with-REGEX=yes \
+ --with-LIBTIFF="-ltiff -lz" \
+ --with-DSO=auto \
+ --with-PATH_EGETTY=/bin/false \
+ --with-PATH_VGETTY=/bin/false \
+ || return 1
+ make -j1 || return 1
+
+ # this makefile has issues installing, it doesn't use the standard
+ # install - but the following seems to work
+ mkdir -p "${pkgdir}"/usr/bin "${pkgdir}"/usr/sbin
+ mkdir -p "${pkgdir}"/usr/lib/"$pkgname" "${pkgdir}"/usr/share/man
+ mkdir -p "${pkgdir}"/var/spool/"$pkgname"
+ mkdir -p "${pkgdir}"/var/spool/"$pkgname"/lib
+ touch "${pkgdir}"/var/spool/"$pkgname"/lib/pagesizes
+ chown uucp:uucp "${pkgdir}"/var/spool/"$pkgname"
+ chmod 0600 "${pkgdir}"/var/spool/"$pkgname"
+
+ make \
+ BIN="${pkgdir}/usr/bin" \
+ SBIN="${pkgdir}/usr/sbin" \
+ LIBDIR="${pkgdir}/usr/lib" \
+ LIB="${pkgdir}/usr/lib" \
+ LIBEXEC="${pkgdir}/usr/sbin" \
+ LIBDATA="${pkgdir}/var/spool/$pkgname"/lib \
+ MAN="${pkgdir}/usr/share/man" \
+ SPOOL="${pkgdir}/var/spool/$pkgname" \
+ HTMLDIR="${pkgdir}/usr/share/doc/$pkgname/html" \
+ install || return 1
+
+
+ install -m644 -D "$srcdir/$pkgname-$pkgver/COPYRIGHT" \
+ "$pkgdir"/usr/share/licenses/$pkgname/COPYRIGHT
+ install -m644 -D "$srcdir/$pkgname-$pkgver/README" \
+ "$pkgdir"/usr/share/doc/$pkgname/README
+
+
+ # init.d script is created by faxsetup
+ # - which the user runs after install
+}
+
+md5sums="4beb3d438ca6c4f00f1d94f9643e6668 hylafax-4.4.4.tar.gz
+a3553e6fc4de30e80759abe5c663c85b hylafax.post-install"
diff --git a/main/hylafax/hylafax.post-install b/main/hylafax/hylafax.post-install
new file mode 100644
index 00000000000..839f96f543c
--- /dev/null
+++ b/main/hylafax/hylafax.post-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+echo " *"
+echo " * Please run faxsetup to configure hylafax"
+echo " *"
diff --git a/main/hypermail/APKBUILD b/main/hypermail/APKBUILD
new file mode 100644
index 00000000000..6e4f412374c
--- /dev/null
+++ b/main/hypermail/APKBUILD
@@ -0,0 +1,36 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=hypermail
+pkgver=2.2.0
+pkgrel=0
+pkgdesc="Mail Archiver"
+url="http://www.hypermail-project.org"
+license="GPL"
+depends="uclibc pcre lua"
+makedepends="pcre-dev bison"
+install=
+subpackages=""
+source="http://www.hypermail-project.org/$pkgname-$pkgver.tar.gz
+ mdir2mbox.lua"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-httpddir=/var/www \
+ --with-cgidir=/var/www/cgi-bin
+ make || return 1
+ #does not understand DESTDIR so going to install ourselves
+ #make DESTDIR="$pkgdir" install
+
+ install -m755 -D archive/rdmsg "$pkgdir"/usr/bin/rdmsg
+ install -m755 -D archive/msg2archive "$pkgdir"/usr/bin/msgarchive
+ install -m755 -D src/hypermail "$pkgdir"/usr/bin/hypermail
+ install -m755 -D "$srcdir"/mdir2mbox.lua "$pkgdir"/usr/bin/mdir2mbox.lua
+
+}
+
+md5sums="a064e36780ee41409c8c973f9c69927f hypermail-2.2.0.tar.gz
+079b00d4ea667a0efd6fd370b1a4d5d8 mdir2mbox.lua"
diff --git a/main/hypermail/mdir2mbox.lua b/main/hypermail/mdir2mbox.lua
new file mode 100644
index 00000000000..dd883e02dbe
--- /dev/null
+++ b/main/hypermail/mdir2mbox.lua
@@ -0,0 +1,96 @@
+#!/usr/bin/lua
+-- This script takes a mlmmj archive "maildir format" directory and
+-- writes out an mbox formatted file to stdout
+-- Copyright (c) 2009 N. Angelacos under the GPL 2 License
+
+require "posix"
+
+-- command line parser, or exit
+check_command_line = function ()
+ local source_dir = arg[1]
+ local source_time = arg[2]
+
+ if (source_dir == nil ) then
+ io.stderr:write("mdir2mbox source_dir [hours]\n" ..
+ "Writes an mbox formatted file to stdout from the files in source_dir\n" ..
+ "If [hours] is given, then only files newer then [hours] are processed\n")
+ os.exit(-1)
+ end
+
+ if (posix.stat(source_dir, "type") ~= "directory") then
+ io.stderr:write(source_dir .. " is not a directory\n")
+ os.exit(-1)
+ end
+
+ return source_dir, source_time
+end
+
+-- Get candidates
+get_candidates = function (source, hours)
+ local all = posix.dir(source)
+ local candidates = {}
+ local timestamp = 0
+
+ if (hours) then
+ timestamp = os.time() - hours * 3600
+ end
+
+ for k,v in ipairs(all) do
+ local st = posix.stat(source .. "/" .. v)
+ if (st) and (st.type == "regular") and (st.mtime > timestamp) then
+ table.insert(candidates,source .. "/" .. v)
+ end
+ end
+
+ return candidates
+end
+
+file_to_mbox = function (path)
+ local fh = io.open(path)
+ if (fh == nil) then
+ return
+ end
+ local headers = ""
+ local l = ""
+ -- get headers
+ repeat
+ headers = headers .. l
+ l = (fh:read("*l") or "" ) .. "\n"
+ until (#l == 1)
+
+ local from = string.match("\n" .. headers, "\nFrom: ([^\n]*)")
+ if from == nil then
+ from = string.match("\n" .. headers, "\nReply-To: ([^\n]*)")
+ end
+ if from == nil then
+ from = "<nobody@nowhere.com>"
+ end
+ from = string.match(from, "<([^>]*)>") or string.match(from, "([^ ]*)")
+
+
+ local date = string.match("\n" .. headers, "\nDate: ([^\n]*)")
+ if date == nil then
+ date = os.date ("%c", posix.stat(path, "mtime"))
+ end
+ local weekday,day,month,year,time,offset = string.match(date, "([^,]*), +(%d+) (%a+) (%d+) ([%d:]*) ([%d]*)")
+
+ print ("From " .. from .. " " .. string.format("%s %s %s %s %s", weekday, month, day, time, year, offset ))
+ print (headers)
+
+ -- get rest of message
+ repeat
+ local foo = fh:read("*l")
+ if foo then
+ print(foo)
+ end
+ until (foo == nil)
+
+fh:close()
+end
+
+candidates = get_candidates(check_command_line ())
+
+for k,v in ipairs(candidates) do
+ file_to_mbox(v)
+end
+print ("")
diff --git a/main/iaxmodem/APKBUILD b/main/iaxmodem/APKBUILD
new file mode 100644
index 00000000000..f1f2b21c3a2
--- /dev/null
+++ b/main/iaxmodem/APKBUILD
@@ -0,0 +1,54 @@
+# Contributor: Cameron Banta <cbanta@gmail.com>
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=iaxmodem
+pkgver=1.2.0
+pkgrel=1
+pkgdesc="Softmodem for hylafax that connects to VOIP gateway with IAX"
+url="http://iaxmodem.sourceforge.net/"
+license="GPL"
+depends="uclibc tiff"
+makedepends="tiff-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ nocxx.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # purge usless C++ check
+ patch lib/libiax2/configure < ../nocxx.patch || return 1
+
+ ./configure
+ make || return 1
+ install -m755 -s -D "$srcdir/$pkgname-$pkgver/iaxmodem" \
+ "$pkgdir/usr/sbin/iaxmodem"
+ mkdir -p "$pkgdir/etc/iaxmodem"
+ mkdir -p "$pkgdir/var/log/iaxmodem"
+
+ #library licenses
+ install -m644 -D "$srcdir/$pkgname-$pkgver/lib/libiax2/COPYING" \
+ "$pkgdir"/usr/share/licenses/$pkgname/libiax2.COPYING
+ install -m644 -D "$srcdir/$pkgname-$pkgver/lib/libiax2/COPYING.LIB" \
+ "$pkgdir"/usr/share/licenses/$pkgname/libiax2.COPYING.LIB
+
+ install -m644 -D "$srcdir/$pkgname-$pkgver/lib/spandsp/COPYING" \
+ "$pkgdir"/usr/share/licenses/$pkgname/libspandsp.COPYING
+
+ #docs
+ install -m644 -D "$srcdir/$pkgname-$pkgver/README" \
+ "$pkgdir/usr/share/doc/$pkgname/README"
+ install -m644 -D "$srcdir/$pkgname-$pkgver/FAQ" \
+ "$pkgdir/usr/share/doc/$pkgname/FAQ"
+
+ install -m644 -D "$srcdir/$pkgname-$pkgver/iaxmodem-cfg.ttyIAX" \
+ "$pkgdir/usr/share/doc/$pkgname/iaxmodem-cfg.ttyIAX"
+ install -m644 -D "$srcdir/$pkgname-$pkgver/iaxmodem.init.debian" \
+ "$pkgdir/usr/share/doc/$pkgname/iaxmodem.init.debian"
+ install -m644 -D "$srcdir/$pkgname-$pkgver/config.ttyIAX" \
+ "$pkgdir/usr/share/doc/$pkgname/config.ttyIAX"
+
+}
+
+md5sums="f8b26cfeed188e5c1dcbc5ae5ef923b3 iaxmodem-1.2.0.tar.gz
+28513788ba4d556ccd538867dc6205ab nocxx.patch"
diff --git a/main/iaxmodem/iaxmodem.confd b/main/iaxmodem/iaxmodem.confd
new file mode 100644
index 00000000000..082a920e0b1
--- /dev/null
+++ b/main/iaxmodem/iaxmodem.confd
@@ -0,0 +1,7 @@
+# Configfile for /etc/init.d/iaxmodem
+
+# Set the priority of the iaxmodem process
+# Value: (highest) -20..19 (lowest)
+#
+#IAXMODEM_NICE="-5"
+
diff --git a/main/iaxmodem/iaxmodem.initd b/main/iaxmodem/iaxmodem.initd
new file mode 100644
index 00000000000..d6f2c947ac8
--- /dev/null
+++ b/main/iaxmodem/iaxmodem.initd
@@ -0,0 +1,43 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-misc/iaxmodem/files/iaxmodem.initd,v 1.1 2008/10/14 23:53:39 sbriesen Exp $
+
+description="IAXmodem"
+description_reload="Reread configuration file and make the appropriate changes"
+extra_started_commands="reload"
+command="/usr/sbin/iaxmodem"
+pidfile="/var/run/iaxmodem.pid"
+name="iaxmodem"
+
+depend() {
+ use asterisk
+ need net
+}
+
+start() {
+ ebegin "Starting ${description}"
+ start-stop-daemon --start --quiet --pidfile "${pidfile}" \
+ --env TMPDIR="/tmp" --nice ${IAXMODEM_NICE:-0} --exec "${command}"
+ eend ${?}
+}
+
+stop() {
+ local childs=""
+ ebegin "Stopping ${description}"
+ # start-stop-daemon doesn't kill childs reliable, so we
+ # use a combination of pgrep + start-stop-daemon + kill
+ [ -s "${pidfile}" ] && childs=$(pgrep -P $(cat "${pidfile}"))
+ start-stop-daemon --stop --quiet --pidfile "${pidfile}" --retry TERM/10/KILL/5
+ if eend ${?}; then
+ # if there're still childs running, kill them!
+ [ -n "${childs}" ] && kill -KILL ${childs} 2>/dev/null
+ return 0
+ fi
+}
+
+reload() {
+ ebegin "Reloading ${description} configuration"
+ start-stop-daemon --stop --signal HUP --pidfile "${pidfile}"
+ eend ${?}
+}
diff --git a/main/iaxmodem/nocxx.patch b/main/iaxmodem/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/iaxmodem/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/icu/APKBUILD b/main/icu/APKBUILD
new file mode 100644
index 00000000000..c2150b3ec8e
--- /dev/null
+++ b/main/icu/APKBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=icu
+pkgver=4.2.1
+_ver=4_2_1
+pkgrel=0
+pkgdesc="International Components for Unicode library"
+url="http://www.icu-project.org/"
+license="custom:icu"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=""
+makedepends="uclibc++-dev"
+source="http://download.icu-project.org/files/icu4c/${pkgver}/${pkgname}4c-$_ver-src.tgz"
+
+build ()
+{
+ cd "$srcdir"/icu/source
+ export CXX=g++-uc
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install || return 1
+ chmod +x "$pkgdir"/usr/bin/icu-config
+ install -Dm644 "$srcdir"/icu/license.html \
+ "$pkgdir"/usr/share/licenses/icu/license.html
+}
+md5sums="e3738abd0d3ce1870dc1fd1f22bba5b1 icu4c-4_2_1-src.tgz"
diff --git a/main/imagemagick/APKBUILD b/main/imagemagick/APKBUILD
new file mode 100644
index 00000000000..183b1e82ccc
--- /dev/null
+++ b/main/imagemagick/APKBUILD
@@ -0,0 +1,35 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=imagemagick
+pkgver=6.5.3.10
+_pkgver=6.5.3-10
+pkgrel=0
+pkgdesc="A collection of tools and libraries for many image formats"
+url="http://www.imagemagick.org/"
+license="GPL"
+depends=
+makedepends="zlib-dev libpng-dev jpeg-dev freetype-dev perl-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-$_pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/ImageMagick-${_pkgver}"
+
+ # fix doc dir, Gentoo bug 91911
+ sed -i -e \
+ 's:DOCUMENTATION_PATH="${DATA_DIR}/doc/${DOCUMENTATION_RELATIVE_PATH}":DOCUMENTATION_PATH="/usr/share/doc/imagemagick":g' \
+ configure || die
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --without-threads \
+ --without-x \
+ --with-modules
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+}
+
+md5sums="d33621ea195792aeeec79900e7d1e395 ImageMagick-6.5.3-10.tar.gz"
diff --git a/main/iproute2-qos/APKBUILD b/main/iproute2-qos/APKBUILD
new file mode 100644
index 00000000000..902ff0c1aef
--- /dev/null
+++ b/main/iproute2-qos/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Ilya Strelkin <iilluzion@gmail.com>
+# Maintainer: Ilya Strelkin <iilluzion@gmail.com>
+pkgname=iproute2-qos
+pkgver=0.1
+pkgrel=0
+pkgdesc="Scripts to set up quality of service with iproute2"
+url="http://git.alpinelinux.org/cgit/aports"
+license="GPL"
+depends="iproute2"
+makedepends=""
+source="qos.initd qos.confd setup-qos"
+
+build() {
+ install -m755 -D "$srcdir"/setup-qos "$pkgdir"/usr/sbin/setup-qos
+ install -m755 -D "$srcdir"/qos.initd "$pkgdir"/etc/init.d/qos
+ install -m644 -D "$srcdir"/qos.confd "$pkgdir"/etc/conf.d/qos
+}
+
+md5sums="024b3e5b6f6cca09a729ce265898a0c7 qos.initd
+d4cc8ff1e36312cbe816c1540c4f2d92 qos.confd
+785aff5d4284c47038a009797c576e34 setup-qos"
diff --git a/main/iproute2-qos/qos.confd b/main/iproute2-qos/qos.confd
new file mode 100644
index 00000000000..60d4093726a
--- /dev/null
+++ b/main/iproute2-qos/qos.confd
@@ -0,0 +1,314 @@
+###########################################################################################################
+#
+# Traffic Control configuration
+#
+# Copyright (c) 2009 iilluzion
+#
+# Distributed under GPL-2
+#
+###########################################################################################################
+##### MAIN CONFIGURATION PARAMETERS
+####
+### uplink and downlink rates should be set very precisely
+## RATE_SUB_PERCENT should be set to allow the Router to control a queue
+#
+###########################################################################################################
+# Specify the upload speed of your internet connection (kbit, mbit).
+# Since ISPs tend to overestimate the speeds they offer, it would
+# probably be best if you measure this on a free line.
+#
+### UPLINK_RATE=128kbit
+### UPLINK_RATE=256kbit
+UPLINK_RATE=512kbit
+
+
+###########################################################################################################
+# Specify the download speed of your internet connection (kbit, mbit).
+#
+### DOWNLINK_RATE=256kbit
+### DOWNLINK_RATE=512kbit
+DOWNLINK_RATE=1024kbit
+
+
+###########################################################################################################
+# In order to prevent traffic queuing at the ISP side or in your modem,
+# we shape to a slightly lower rate. This way the bottleneck is the router,
+# not the ISP or modem, which allows us more direct control of shaping.
+#
+### RATE_SUB_PERCENT=20
+### RATE_SUB_PERCENT=15
+RATE_SUB_PERCENT=10
+
+
+###########################################################################################################
+# Specify the local network speed (kbit, mbit)
+#
+LAN_RATE=9mbit
+
+
+###########################################################################################################
+##### ADVANCED CONFIGURATION PARAMETERS
+####
+###
+##
+#
+###########################################################################################################
+# Helper Functions
+#
+# Convert rate to bites per second format (bits)
+bits()
+{
+ RATE=0
+ R_RATE=$1
+ R_NUMBER=`echo "$R_RATE" | sed -e "s/[^0-9]//g"`
+ R_UNIT=`echo "$R_RATE" | sed -e "s/[0-9]//g"`
+
+ if [ "$R_UNIT" == "" ]; then
+ R_UNIT="kbit"
+ fi
+
+ if [ "$R_UNIT" == "kbps" ]; then R_RATE=$(($R_NUMBER * 1024 * 8))
+ elif [ "$R_UNIT" == "mbps" ]; then R_RATE=$(($R_NUMBER * 1024 * 1024 * 8))
+ elif [ "$R_UNIT" == "mbit" ]; then R_RATE=$(($R_NUMBER * 1024 * 1024))
+ elif [ "$R_UNIT" == "kbit" ]; then R_RATE=$(($R_NUMBER * 1024))
+ elif [ "$R_UNIT" == "bps" ]; then R_RATE=$(($R_NUMBER * 8))
+ else
+ echo "Unknown unit '$R_UNIT' (mbps, mbit, kbit, bps)"
+ fi
+
+ echo "$R_RATE"
+}
+
+###########################################################################################################
+# Define supported Queuing Disciplines
+#
+QDISCS="prio|tbf|htb|hfsc|sfq|red|pfifo"
+
+
+###########################################################################################################
+# Traffic Control parameters will be calculated depending on link directions
+#
+DIRECTION=$1
+
+
+###########################################################################################################
+# Specify the network devices that are connected to the internet.
+# If you are a dialup or PPPoE user, you have to re-run the QoS script
+# every time you connect.
+#
+### WAN_DEVICES="ppp0"
+WAN_DEVICES="$(ip route show 0.0.0.0/0 | grep dev | sed 's/.*dev //' | awk '{print $1}')"
+ WAN_DEVICES="$WAN_DEVICES $(ip addr | grep gre | egrep -v "gre0" | awk '/^[0-9]/ { gsub(":", ""i, $2); print $2}' | cut -f 1 -d'@')"
+
+
+###########################################################################################################
+# Specify the network devices which are connected with your local network segments.
+#
+### LAN_DEVICES="eth1"
+LAN_DEVICES=`awk -F: 'NR > 2 { print $1 }' /proc/net/dev | egrep -v "lo|gre0|$(echo $WAN_DEVICES | sed s/" "/"|"/g)"`
+
+
+###########################################################################################################
+# Calculaton of WAN up/down link rates
+#
+DIRECTION=${DIRECTION:-ALL}
+ if [ $DIRECTION = "ALL" ]; then
+ DEVICES="$WAN_DEVICES $LAN_DEVICES"
+ fi
+
+ if [ $DIRECTION = "UP" ]; then
+ WAN_RATE=`bits $UPLINK_RATE`
+ DEVICES=$WAN_DEVICES
+ fi
+
+ if [ $DIRECTION = "DOWN" ]; then
+ WAN_RATE=`bits $DOWNLINK_RATE`
+ DEVICES=$LAN_DEVICES
+ fi
+
+ WAN_SUB_RATE=$((WAN_RATE - (RATE_SUB_PERCENT * WAN_RATE / 100)))
+ INTERACTIVE_RATE=$((WAN_SUB_RATE / 5))
+ PRIVILEGED_RATE=$((WAN_SUB_RATE / 2))
+ BESTEFFORT_RATE=$((WAN_SUB_RATE / 3))
+
+ OUT_OF_WAN_RATE=`bits $LAN_RATE`
+ OUT_OF_WAN_RATE=$((OUT_OF_WAN_RATE - WAN_RATE))
+
+
+###########################################################################################################
+# Specify root Queuing Disciplines
+#
+# Recommendations:
+# htb: if link is not congested or you want to control busrts of traffic; recommended for downstream.
+# hfsc: if link is congested and you need to control guarantees of delay; recommended for upstream.
+# dmax = 50-100 [ms] = 50000-100000 [microsec]
+# umax = MIN (rate * (dmax / 1000), 1500) [b]
+# prio: if rate is variable and you want to be sure that interactive traffic has ultimate priority
+# none: if no egress shaping is desired
+# (in this case you may want to setup only ingress policing)
+#
+DOWNLINK_QDISC=htb
+### DOWNLINK_QDISC=hfsc
+### DOWNLINK_QDISC=prio
+### DOWNLINK_QDISC=none
+#
+UPLINK_QDISC=hfsc
+### UPLINK_QDISC=htb
+### UPLINK_QDISC=prio
+### UPLINK_QDISC=none
+
+
+###########################################################################################################
+# Calculation of Queuing Discipline parameters
+#
+INTERACTIVE_PRIO_LATENCY=50000
+INTERACTIVE_PRIO_BURST=$((INTERACTIVE_RATE / 100 / 8))
+#
+INTERACTIVE_HFSC_DMAX=50000
+INTERACTIVE_HFSC_UMAX=$((INTERACTIVE_RATE * INTERACTIVE_HFSC_DMAX / 1000 / 1000))
+ [ $INTERACTIVE_HFSC_UMAX -gt 1500 ] && INTERACTIVE_HFSC_UMAX=1500
+#
+PRIVILEGED_HFSC_DMAX=100000
+PRIVILEGED_HFSC_UMAX=$((PRIVILEGED_RATE * PRIVILEGED_HFSC_DMAX / 1000 / 1000))
+ [ $PRIVILEGED_HFSC_UMAX -gt 1500 ] && PRIVILEGED_HFSC_UMAX=1500
+
+
+###########################################################################################################
+# Specify INGRESS policing
+#
+# Recommendations:
+# none: if link is not congested
+# police: if link is constantly congested
+#
+### DOWNLINK_INGRESS=police
+DOWNLINK_INGRESS=none
+### UPLINK_INGRESS=police
+UPLINK_INGRESS=none
+
+
+###########################################################################################################
+# Calculation of policing bursts
+# burst = rate / 17 (taken basing on experemental results)
+#
+POLICE_BURST_SCALE=17
+ INTERACTIVE_POLICE_BURST=$((INTERACTIVE_RATE / POLICE_BURST_SCALE))
+ PRIVILEGED_POLICE_BURST=$((PRIVILEGED_RATE / POLICE_BURST_SCALE))
+ BESTEFFORT_POLICE_BURST=$((BESTEFFORT_RATE / POLICE_BURST_SCALE))
+
+
+###########################################################################################################
+# Specify leaf Queuing Disciplines
+# Recommendations:
+# "pfifo limit 5": Interactive, Priviledged (real-time streams, IPSEC)
+# "sfq perturb 10": Best-Effort (TCP sessions or best-effort class traffic)
+# "red <parameters>": Best-Effort (hightly congested links or high-speed Internet [> 10Mbit/sec])
+# Random Early Detect (RED) parameters calculation:
+# min = maximum delay * rate (dalay ~ 200ms = 0.2sec) [b]
+# max = 3 * min [b]
+# avpkt = 1000 (MTU 1500)
+# limit = 8 * max [b]
+# burst = (min + min + max)/(3 * avpkt) [b]
+# probability = 0.02
+INTERACTIVE_LEAF_QDISC="pfifo limit 5"
+PRIVILEGED_LEAF_QDISC="pfifo limit 5"
+### BESTEFFORT_LEAF_QDISC="sfq perturb 10"
+#
+RED_DELAY=200
+RED_MIN=$((RED_DELAY * BESTEFFORT_RATE / 1000 / 8)) # devided on 8 since rate given in bit/s so we get bytes
+RED_MAX=$((3 * RED_MIN))
+RED_AVPKT=1000
+RED_PROB=0.02
+RED_BURST=$(((RED_MIN + RED_MIN + RED_MAX) / (3 * RED_AVPKT)))
+RED_LIMIT=$((8 * RED_MAX))
+#
+ BESTEFFORT_LEAF_QDISC="red min $RED_MIN max $RED_MAX burst $RED_BURST limit $RED_LIMIT probability $RED_PROB avpkt $RED_AVPKT"
+#
+LAN_LEAF_QDISC="sfq perturb 10"
+
+
+###########################################################################################################
+# Specify filter rules (see tc, tc-filters man page).
+# You may have multiple <CLASS-NAME>_FILTER_<n> items.
+# Maximum 100 filter items are allowed for each class
+#
+# Interactive Class Traffic Filters
+#
+# UDP
+#
+INTERACTIVE_FILTER_1="protocol ip prio 100 u32 match ip protocol 0x11 0xff"
+#
+# ICMP
+#
+INTERACTIVE_FILTER_2="protocol ip prio 100 u32 match ip protocol 0x1 0xff"
+#
+# ACK with payload < 64 bytes (32-bit version)
+#
+INTERACTIVE_FILTER_3="protocol ip prio 100 u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16 0x0000 0xffc0 at 2 match u8 0x10 0xff at 33"
+#
+# ACK with payload < 64 bytes
+#
+INTERACTIVE_FILTER_4="protocol ip prio 100 u32 match ip protocol 6 0xff match u8 0x10 0xff at nexthdr+13 match u16 0x0000 0xffc0 at 2"
+#
+# TOS: 0x10, 0x18, 0xb8(ef)
+#
+INTERACTIVE_FILTER_5="protocol ip prio 100 u32 match ip tos 0x10 0xff"
+INTERACTIVE_FILTER_6="protocol ip prio 100 u32 match ip tos 0x18 0xff"
+INTERACTIVE_FILTER_7="protocol ip prio 100 u32 match ip tos 0xb8 0xff"
+
+
+###########################################################################################################
+# Priviledged Class Traffic Filters
+#
+# SSH
+#
+PRIVILEGED_FILTER_1="protocol ip prio 100 u32 match ip dport 22 0xffff"
+PRIVILEGED_FILTER_2="protocol ip prio 100 u32 match ip sport 22 0xffff"
+#
+# Remote Desktop
+#
+PRIVILEGED_FILTER_3="protocol ip prio 100 u32 match ip dport 3389 0xffff"
+PRIVILEGED_FILTER_4="protocol ip prio 100 u32 match ip sport 3389 0xffff"
+#
+# ESP
+#
+PRIVILEGED_FILTER_5="protocol ip prio 100 u32 match ip protocol 0x32 0xff"
+#
+# AH
+#
+PRIVILEGED_FILTER_6="protocol ip prio 100 u32 match ip protocol 0x33 0xff"
+#
+# TOS: 0x88(af41)
+#
+PRIVILEGED_FILTER_7="protocol ip prio 100 u32 match ip tos 0x88 0xff"
+#
+# IPSEC-NAT
+#
+PRIVILEGED_FILTER_8="protocol ip prio 90 u32 match ip protocol 0x11 0xff match ip dport 4500 0xffff"
+PRIVILEGED_FILTER_9="protocol ip prio 90 u32 match ip protocol 0x11 0xff match ip sport 4500 0xffff"
+
+
+###########################################################################################################
+# Best-Effort Class Traffic Filters
+# By default ALL unclassified traffic is being assined to Best-Effort class
+# You may specify additional filters here
+#
+# Examples: Any traffic from/to 192.168.1.0/24 network will be unconditionally classified as best-effort
+#
+### BESTEFFORT_FILTER_1="protocol ip prio 3 u32 match ip src 192.168.1.0/24"
+### BESTEFFORT_FILTER_2="protocol ip prio 4 u32 match ip dst 192.168.1.0/24"
+#
+
+###########################################################################################################
+# LAN Class Traffic Filters
+#
+# Traffic Originated from router
+#
+# Example:
+###LAN_FILTER_1="protocol ip prio 10 u32 match ip src 192.168.1.10"
+
+#
+##
+###
+####
+##### END OF GENERIC ALPINE SETUP
+###########################################################################################################
diff --git a/main/iproute2-qos/qos.initd b/main/iproute2-qos/qos.initd
new file mode 100644
index 00000000000..b543748691e
--- /dev/null
+++ b/main/iproute2-qos/qos.initd
@@ -0,0 +1,293 @@
+#!/sbin/runscript
+#
+###########################################################################################################
+# Traffic Control startup script
+#
+# Copyright (c) 2009 iilluzion
+#
+# Distributed under GPL-2
+###########################################################################################################
+
+PROGRAM=qos
+CONFIG=/etc/conf.d/qos
+DEBUG=0 #1
+
+opts="compile"
+
+depend()
+{
+ need net
+}
+
+checkconfig() {
+ if [ ! -e $CONFIG ] ; then
+ eerror "You need to create $CONFIG first."
+ return 1
+ fi
+}
+
+usage()
+{
+ echo "usage: $PROGRAM [status|compile|start|stop|restart]"
+ echo " status: View statistics"
+ echo " compile: Generate traffic control commands"
+ echo " start: Start traffic control"
+ echo " stop: Stop traffic control"
+ echo " restart: Restart traffic control"
+}
+
+configure()
+{
+ source $CONFIG $1
+}
+
+reset()
+{
+ for DEV in $DEVICES; do
+ tc qdisc show dev $DEV | grep -v "pfifo_fast" | egrep -q "$QDISCS" && $ECHO tc qdisc del dev $DEV root
+ tc qdisc show dev $DEV | grep -v "pfifo_fast" | grep -q ingress && $ECHO tc qdisc del dev $DEV ingress
+ done
+}
+
+set_leaf_qdisc()
+{
+ DEV=$1
+ PARENT_CLASSID=$2
+ PARENT_CLASSID=${PARENT_CLASSID:-1}
+
+ if [ ! "$QDISC_CMD" = "prio" ]; then
+ $ECHO tc qdisc add dev $DEV parent $PARENT_CLASSID:40 handle 40 $INTERACTIVE_LEAF_QDISC
+ fi
+
+ $ECHO tc qdisc add dev $DEV parent $PARENT_CLASSID:50 handle 50 $PRIVILEGED_LEAF_QDISC
+ $ECHO tc qdisc add dev $DEV parent $PARENT_CLASSID:60 handle 60 $BESTEFFORT_LEAF_QDISC
+
+ if [ $DIRECTION = "DOWN" ]; then
+ $ECHO tc qdisc add dev $DEV parent $PARENT_CLASSID:70 handle 70 $LAN_LEAF_QDISC
+ fi
+
+ $ECHO
+}
+
+set_filters()
+{
+ CLASS_TYPES="INTERACTIVE PRIVILEGED BESTEFFORT"
+ if [ $DIRECTION = "DOWN" ]; then
+ CLASS_TYPES=$CLASS_TYPES" LAN"
+ fi
+
+ PRIVILEGED_FILTER_FLOWID=50
+ BESTEFFORT_FILTER_FLOWID=60
+ LAN_FILTER_FLOWID=70
+
+ for DEV in $DEVICES; do
+ for CLASS_TYPE in $CLASS_TYPES; do
+ if [ "$QDISC_CMD" = "prio" -a "$CLASS_TYPE" = "INTERACTIVE" ]; then
+ PARENT_CLASSID=1
+ INTERACTIVE_FILTER_FLOWID=1
+ else
+ PARENT_CLASSID=$1
+ PARENT_CLASSID=${PARENT_CLASSID:-1}
+ INTERACTIVE_FILTER_FLOWID=40
+ fi
+
+ for FILTER_NUM in `seq 1 100`; do
+ eval FILTER="\$$CLASS_TYPE"_FILTER_$FILTER_NUM
+ [ -z "$FILTER" ] && break
+ eval FILTER_FLOWID="\$$CLASS_TYPE"_FILTER_FLOWID
+ $ECHO tc filter add dev $DEV parent $PARENT_CLASSID:0 $FILTER flowid $PARENT_CLASSID:$FILTER_FLOWID
+ done
+ done
+
+ $ECHO
+ done
+}
+
+set_htb()
+{
+ for DEV in $DEVICES; do
+ $ECHO tc qdisc add dev $DEV root handle 1 htb default 60
+ $ECHO tc class add dev $DEV parent 1: classid 1:2 htb rate $LAN_RATE
+ $ECHO tc class add dev $DEV parent 1:2 classid 1:30 htb rate $WAN_SUB_RATE
+ $ECHO tc class add dev $DEV parent 1:30 classid 1:40 htb rate $INTERACTIVE_RATE prio 1
+ $ECHO tc class add dev $DEV parent 1:30 classid 1:50 htb rate $PRIVILEGED_RATE ceil $WAN_SUB_RATE prio 3
+ $ECHO tc class add dev $DEV parent 1:30 classid 1:60 htb rate $BESTEFFORT_RATE ceil $WAN_SUB_RATE prio 6
+
+ if [ $DIRECTION = "DOWN" ]; then
+ $ECHO tc class add dev $DEV parent 1:2 classid 1:70 htb rate $OUT_OF_WAN_RATE prio 7
+ fi
+
+ set_leaf_qdisc $DEV
+
+ $ECHO
+ done
+
+ set_filters
+}
+
+set_hfsc()
+{
+ for DEV in $DEVICES; do
+ $ECHO tc qdisc add dev $DEV root handle 1 hfsc default 60
+ $ECHO tc class add dev $DEV parent 1: classid 1:2 hfsc sc rate $LAN_RATE ul rate $LAN_RATE
+ $ECHO tc class add dev $DEV parent 1:2 classid 1:30 hfsc sc rate $WAN_SUB_RATE ul rate $WAN_SUB_RATE
+ $ECHO tc class add dev $DEV parent 1:30 classid 1:40 hfsc sc umax $INTERACTIVE_HFSC_UMAX dmax $INTERACTIVE_HFSC_DMAX rate $INTERACTIVE_RATE ul rate $INTERACTIVE_RATE
+ $ECHO tc class add dev $DEV parent 1:30 classid 1:50 hfsc sc umax $PRIVILEGED_HFSC_UMAX dmax $PRIVILEGED_HFSC_DMAX rate $PRIVILEGED_RATE ul rate $WAN_SUB_RATE
+ $ECHO tc class add dev $DEV parent 1:30 classid 1:60 hfsc sc rate $BESTEFFORT_RATE ul rate $WAN_SUB_RATE
+
+ if [ $DIRECTION = "DOWN" ]; then
+ $ECHO tc class add dev $DEV parent 1:2 classid 1:70 hfsc sc rate $OUT_OF_WAN_RATE ul rate $OUT_OF_WAN_RATE
+ fi
+
+ set_leaf_qdisc $DEV
+
+ $ECHO
+ done
+
+ set_filters
+}
+
+set_prio()
+{
+ PARENT_CLASSID=10
+ for DEV in $DEVICES; do
+ $ECHO tc qdisc add dev $DEV root handle 1 prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # by default unclassified traffic goes to flowid 1:2
+ $ECHO tc qdisc add dev $DEV parent 1:1 handle 40: tbf rate $INTERACTIVE_RATE burst $INTERACTIVE_PRIO_BURST latency $INTERACTIVE_PRIO_LATENCY
+ $ECHO tc qdisc add dev $DEV parent 1:2 handle $PARENT_CLASSID: htb default 60
+ $ECHO tc class add dev $DEV parent $PARENT_CLASSID: classid $PARENT_CLASSID:30 htb rate $WAN_SUB_RATE
+ $ECHO tc class add dev $DEV parent $PARENT_CLASSID:30 classid $PARENT_CLASSID:50 htb rate $PRIVILEGED_RATE ceil $WAN_SUB_RATE prio 3
+ $ECHO tc class add dev $DEV parent $PARENT_CLASSID:30 classid $PARENT_CLASSID:60 htb rate $BESTEFFORT_RATE ceil $WAN_SUB_RATE prio 6
+
+ if [ $DIRECTION = "DOWN" ]; then
+ $ECHO tc class add dev $DEV parent 10:1 classid $PARENT_CLASSID:70 htb rate $OUT_OF_WAN_RATE prio 7
+ fi
+
+ set_leaf_qdisc $DEV $PARENT_CLASSID
+
+ $ECHO
+ done
+
+ set_filters $PARENT_CLASSID
+}
+
+set_police()
+{
+ CLASS_TYPES="INTERACTIVE PRIVILEGED"
+ INTERACTIVE_POLICE_FLOWID=1
+ PRIVILEGED_POLICE_FLOWID=2
+
+ for DEV in $DEVICES; do
+ $ECHO tc qdisc add dev $DEV handle ffff: ingress
+
+ for CLASS_TYPE in $CLASS_TYPES; do
+ for FILTER_NUM in `seq 1 100`; do
+ eval FILTER="\$$CLASS_TYPE"_FILTER_$FILTER_NUM
+ [ -z "$FILTER" ] && break
+ eval FILTER_FLOWID="\$$CLASS_TYPE"_POLICE_FLOWID
+ eval FILTER_RATE="\$$CLASS_TYPE"_RATE
+ eval FILTER_BURST="\$$CLASS_TYPE"_POLICE_BURST
+ $ECHO tc filter add dev $DEV parent ffff: $FILTER police rate $FILTER_RATE burst $FILTER_BURST continue flowid $FILTER_FLOWID:
+ done
+ done
+
+ $ECHO tc filter add dev $DEV parent ffff: protocol ip prio 999 u32 match ip src 0.0.0.0/0 police rate $BESTEFFORT_RATE burst $BESTEFFORT_POLICE_BURST drop flowid :3
+
+ $ECHO
+ done
+}
+
+get_stats()
+{
+ for DEV in $WAN_DEVICES $LAN_DEVICES; do
+ echo $DEV Statistics
+ echo
+ echo " Classes:"
+ echo "--------------------------"
+ $ECHO tc -s class show dev $DEV
+
+ echo
+ echo " Leaf Queuing Disciplines:"
+ echo "--------------------------"
+ $ECHO tc -s qdisc show dev $DEV
+
+ echo
+ echo " EGRESS Filters:"
+ echo "--------------------------"
+ $ECHO tc -s filter show dev $DEV
+ $ECHO tc -s filter show dev $DEV parent 10: # if PRIO qdisc is applied
+
+ echo
+ echo " INGRESS Policing Filters:"
+ echo "--------------------------"
+ $ECHO tc -s filter show dev $DEV parent ffff:
+
+ echo
+ echo
+ done
+}
+
+compile()
+{
+ DEBUG=1
+
+ start
+}
+
+start()
+{
+ checkconfig || return 1
+
+ if [ $DEBUG -gt 0 ]; then
+ ECHO="echo"
+ else
+ ebegin "Starting QoS"
+ fi
+
+ for LINK_DIRECTION in UP DOWN; do
+ configure $LINK_DIRECTION
+ reset
+
+ eval QDISC_CMD="\$$LINK_DIRECTION"LINK_QDISC
+ if [ ! "$QDISC_CMD" = "none" ]; then
+ set_$QDISC_CMD
+ fi
+
+ eval INGRESS_CMD="\$$LINK_DIRECTION"LINK_INGRESS
+ if [ ! "$INGRESS_CMD" = "none" ]; then
+ set_$INGRESS_CMD
+ fi
+ done
+
+ if [ $DEBUG -eq 0 ]; then
+ eend $?
+ fi
+}
+
+stop()
+{
+ checkconfig || return 1
+
+ if [ $DEBUG -gt 0 ]; then
+ ECHO="echo"
+ else
+ ebegin "Stopping QoS"
+ fi
+
+ configure ALL
+ reset
+
+ if [ $DEBUG -eq 0 ]; then
+ eend $?
+ fi
+}
+
+restart()
+{
+ stop
+ start
+}
+
+status()
+{
+ get_stats
+}
diff --git a/main/iproute2-qos/setup-qos b/main/iproute2-qos/setup-qos
new file mode 100644
index 00000000000..5d5c601268d
--- /dev/null
+++ b/main/iproute2-qos/setup-qos
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+PREFIX=
+. "$PREFIX/lib/libalpine.sh"
+
+conf="$ROOT/etc/conf.d/qos"
+
+cfgval() {
+ awk -F= "/^$1/ {print \$2}" $conf 2>/dev/null
+}
+
+setcfg() {
+ local key=$1
+ local value=$2
+ sed -i "s/^\\(\\#\\)*$key=.*/$key=$value/" "$conf"
+ if ! grep "^$key=" "$conf" >/dev/null ; then
+ echo "$key=$value" >> "$conf"
+ fi
+}
+
+apk_add iproute2
+
+if [ -f "$conf" ] ; then
+ _UPLINK_RATE=$(cfgval UPLINK_RATE)
+ _DOWNLINK_RATE=$(cfgval DOWNLINK_RATE)
+ _RATE_SUB_PERCENT=$(cfgval RATE_SUB_PERCENT)
+else
+ echo "Configuration file '$conf' not found"
+ exit 1
+fi
+
+echo "**********************************************************************"
+echo "Since ISPs tend to overestimate the speeds they offer, it would probably be best"
+echo " if you measure this on a free line to set values very precisely."
+echo "**********************************************************************"
+echo
+echon "Specify the upload speed of your internet connection (mbps, mbit, kbit, kbps, bps): [$_UPLINK_RATE] "
+ default_read _UPLINK_RATE $_UPLINK_RATE
+echo
+echon "Specify the download speed of your internet connection (mbps, mbit, kbit, kbps, bps): [$_DOWNLINK_RATE] "
+ default_read _DOWNLINK_RATE $_DOWNLINK_RATE
+echo
+echo "**********************************************************************"
+echo "In order to prevent traffic queuing at the ISP side or in your modem,"
+echo " you should set a slightly lower rate than real one."
+echo "This way the bottleneck is the router,"
+echo " not the ISP or modem, which allows to control the queue."
+echo "**********************************************************************"
+echo
+echon "Specify amount of percents: [$_RATE_SUB_PERCENT] "
+ default_read _RATE_SUB_PERCENT $_RATE_SUB_PERCENT
+
+echon "Start QoS? (y/n) [y] "
+ default_read startqos "y"
+ case "$startqos" in
+ [Yy]*) /etc/init.d/qos start;;
+ esac
+
+echon "Make QoS to be started on boot? (y/n) [y] "
+ default_read bootstartqos "y"
+ case "$bootstartqos" in
+ [Yy]*) rc_add qos;;
+ esac
+
+setcfg UPLINK_RATE $_UPLINK_RATE
+setcfg DOWNLINK_RATE $_DOWNLINK_RATE
+setcfg RATE_SUB_PERCENT $_RATE_SUB_PERCENT
diff --git a/main/ipsec-tools/00-verify-cert-leak.patch b/main/ipsec-tools/00-verify-cert-leak.patch
new file mode 100644
index 00000000000..9e678133591
--- /dev/null
+++ b/main/ipsec-tools/00-verify-cert-leak.patch
@@ -0,0 +1,11 @@
+--- a/src/racoon/crypto_openssl.c 20 Apr 2009 13:22:41 -0000 1.18
++++ b/src/racoon/crypto_openssl.c 29 Apr 2009 10:48:51 -0000
+@@ -510,7 +510,7 @@
+ X509_STORE_CTX_set_flags (csc, X509_V_FLAG_CRL_CHECK_ALL);
+ #endif
+ error = X509_verify_cert(csc);
+- X509_STORE_CTX_cleanup(csc);
++ X509_STORE_CTX_free(csc);
+
+ /*
+ * if x509_verify_cert() is successful then the value of error is
diff --git a/main/ipsec-tools/20-natoa-fix.patch b/main/ipsec-tools/20-natoa-fix.patch
new file mode 100644
index 00000000000..91d7224e2a6
--- /dev/null
+++ b/main/ipsec-tools/20-natoa-fix.patch
@@ -0,0 +1,33 @@
+Fix nat-oa parsing when rekeying.
+
+From: Timo Teras <timo.teras@iki.fi>
+
+
+---
+
+ src/racoon/handler.c | 11 +++++++++++
+ 1 files changed, 11 insertions(+), 0 deletions(-)
+
+
+diff --git a/src/racoon/handler.c b/src/racoon/handler.c
+index 6f91beb..960b5b3 100644
+--- a/src/racoon/handler.c
++++ b/src/racoon/handler.c
+@@ -736,6 +736,17 @@ initph2(iph2)
+ oakley_delivm(iph2->ivm);
+ iph2->ivm = NULL;
+ }
++
++#ifdef ENABLE_NATT
++ if (iph2->natoa_src) {
++ racoon_free(iph2->natoa_src);
++ iph2->natoa_src = NULL;
++ }
++ if (iph2->natoa_dst) {
++ racoon_free(iph2->natoa_dst);
++ iph2->natoa_dst = NULL;
++ }
++#endif
+ }
+
+ /*
diff --git a/main/ipsec-tools/30-natt-ports-cleanup.patch b/main/ipsec-tools/30-natt-ports-cleanup.patch
new file mode 100644
index 00000000000..19360347dac
--- /dev/null
+++ b/main/ipsec-tools/30-natt-ports-cleanup.patch
@@ -0,0 +1,393 @@
+From Yvan Vanhullebus: Use SADB_X_EXT_NAT_T_* consistently for passing the
+
+From: Timo Teras <timo.teras@iki.fi>
+
+NAT-T port information.
+---
+
+ src/libipsec/libpfkey.h | 12 ++++++++
+ src/libipsec/pfkey.c | 49 +++++++++++++++++++++++++++++++++
+ src/racoon/isakmp.c | 11 +++++++
+ src/racoon/isakmp_inf.c | 37 +++++++++++++------------
+ src/racoon/pfkey.c | 69 +++++++++++++++++++++++++++++++++--------------
+ src/racoon/pfkey.h | 1 +
+ 6 files changed, 140 insertions(+), 39 deletions(-)
+
+
+diff --git a/src/libipsec/libpfkey.h b/src/libipsec/libpfkey.h
+index 8a503dd..c9b228b 100644
+--- a/src/libipsec/libpfkey.h
++++ b/src/libipsec/libpfkey.h
+@@ -117,6 +117,10 @@ u_int pfkey_set_softrate __P((u_int, u_int));
+ u_int pfkey_get_softrate __P((u_int));
+ int pfkey_send_getspi __P((int, u_int, u_int, struct sockaddr *,
+ struct sockaddr *, u_int32_t, u_int32_t, u_int32_t, u_int32_t));
++int pfkey_send_getspi_nat __P((int, u_int, u_int,
++ struct sockaddr *, struct sockaddr *, u_int8_t, u_int16_t, u_int16_t,
++ u_int32_t, u_int32_t, u_int32_t, u_int32_t));
++
+ int pfkey_send_update2 __P((struct pfkey_send_sa_args *));
+ int pfkey_send_add2 __P((struct pfkey_send_sa_args *));
+ int pfkey_send_delete __P((int, u_int, u_int,
+@@ -155,6 +159,14 @@ int pfkey_send_migrate __P((int, struct sockaddr *, struct sockaddr *,
+ caddr_t, int, u_int32_t));
+ #endif
+
++/* XXX should be somewhere else !!!
++ */
++#ifdef SADB_X_NAT_T_NEW_MAPPING
++#define PFKEY_ADDR_X_PORT(ext) (ntohs(((struct sadb_x_nat_t_port *)ext)->sadb_x_nat_t_port_port))
++#define PFKEY_ADDR_X_NATTYPE(ext) ( ext != NULL && ((struct sadb_x_nat_t_type *)ext)->sadb_x_nat_t_type_type )
++#endif
++
++
+ int pfkey_open __P((void));
+ void pfkey_close __P((int));
+ int pfkey_set_buffer_size __P((int, int));
+diff --git a/src/libipsec/pfkey.c b/src/libipsec/pfkey.c
+index 0a944c2..b39ffca 100644
+--- a/src/libipsec/pfkey.c
++++ b/src/libipsec/pfkey.c
+@@ -380,10 +380,12 @@ pfkey_get_softrate(type)
+ * -1 : error occured, and set errno.
+ */
+ int
+-pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
++pfkey_send_getspi_nat(so, satype, mode, src, dst, natt_type, sport, dport, min, max, reqid, seq)
+ int so;
+ u_int satype, mode;
+ struct sockaddr *src, *dst;
++ u_int8_t natt_type;
++ u_int16_t sport, dport;
+ u_int32_t min, max, reqid, seq;
+ {
+ struct sadb_msg *newmsg;
+@@ -431,6 +433,14 @@ pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
+ len += sizeof(struct sadb_spirange);
+ }
+
++#ifdef SADB_X_EXT_NAT_T_TYPE
++ if(natt_type||sport||dport){
++ len += sizeof(struct sadb_x_nat_t_type);
++ len += sizeof(struct sadb_x_nat_t_port);
++ len += sizeof(struct sadb_x_nat_t_port);
++ }
++#endif
++
+ if ((newmsg = CALLOC((size_t)len, struct sadb_msg *)) == NULL) {
+ __ipsec_set_strerror(strerror(errno));
+ return -1;
+@@ -466,6 +476,32 @@ pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
+ return -1;
+ }
+
++#ifdef SADB_X_EXT_NAT_T_TYPE
++ /* Add nat-t messages */
++ if (natt_type) {
++ p = pfkey_set_natt_type(p, ep, SADB_X_EXT_NAT_T_TYPE,
++ natt_type);
++ if (!p) {
++ free(newmsg);
++ return -1;
++ }
++
++ p = pfkey_set_natt_port(p, ep, SADB_X_EXT_NAT_T_SPORT,
++ sport);
++ if (!p) {
++ free(newmsg);
++ return -1;
++ }
++
++ p = pfkey_set_natt_port(p, ep, SADB_X_EXT_NAT_T_DPORT,
++ dport);
++ if (!p) {
++ free(newmsg);
++ return -1;
++ }
++ }
++#endif
++
+ /* proccessing spi range */
+ if (need_spirange) {
+ struct sadb_spirange spirange;
+@@ -501,6 +537,17 @@ pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
+ return len;
+ }
+
++int
++pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
++ int so;
++ u_int satype, mode;
++ struct sockaddr *src, *dst;
++ u_int32_t min, max, reqid, seq;
++{
++ return pfkey_send_getspi_nat(so, satype, mode, src, dst, 0, 0, 0,
++ min, max, reqid, seq);
++}
++
+ /*
+ * sending SADB_UPDATE message to the kernel.
+ * The length of key material is a_keylen + e_keylen.
+diff --git a/src/racoon/isakmp.c b/src/racoon/isakmp.c
+index c8670f6..fe51653 100644
+--- a/src/racoon/isakmp.c
++++ b/src/racoon/isakmp.c
+@@ -3324,6 +3324,17 @@ purge_remote(iph1)
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
++#ifdef SADB_X_NAT_T_NEW_MAPPING
++ if (PFKEY_ADDR_X_NATTYPE(mhp[SADB_X_EXT_NAT_T_TYPE])) {
++ /* NAT-T is enabled for this SADB entry; copy
++ * the ports from NAT-T extensions */
++ if(mhp[SADB_X_EXT_NAT_T_SPORT] != NULL)
++ set_port(src, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_SPORT]));
++ if(mhp[SADB_X_EXT_NAT_T_DPORT] != NULL)
++ set_port(dst, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_DPORT]));
++ }
++#endif
++
+ if (sa->sadb_sa_state != SADB_SASTATE_LARVAL &&
+ sa->sadb_sa_state != SADB_SASTATE_MATURE &&
+ sa->sadb_sa_state != SADB_SASTATE_DYING) {
+diff --git a/src/racoon/isakmp_inf.c b/src/racoon/isakmp_inf.c
+index 1ada07f..a712825 100644
+--- a/src/racoon/isakmp_inf.c
++++ b/src/racoon/isakmp_inf.c
+@@ -1128,8 +1128,7 @@ purge_ipsec_spi(dst0, proto, spi, n)
+ size_t i;
+ caddr_t mhp[SADB_EXT_MAX + 1];
+ #ifdef ENABLE_NATT
+- struct sadb_x_nat_t_type *natt_type;
+- struct sadb_x_nat_t_port *natt_port;
++ int natt_port_forced;
+ #endif
+
+ plog(LLV_DEBUG2, LOCATION, NULL,
+@@ -1184,22 +1183,25 @@ purge_ipsec_spi(dst0, proto, spi, n)
+ continue;
+ }
+ #ifdef ENABLE_NATT
+- natt_type = (void *)mhp[SADB_X_EXT_NAT_T_TYPE];
+- if (natt_type && natt_type->sadb_x_nat_t_type_type) {
++ if (PFKEY_ADDR_X_NATTYPE(mhp[SADB_X_EXT_NAT_T_TYPE])) {
+ /* NAT-T is enabled for this SADB entry; copy
+ * the ports from NAT-T extensions */
+- natt_port = (void *)mhp[SADB_X_EXT_NAT_T_SPORT];
+- if (extract_port(src) == 0 && natt_port != NULL)
+- set_port(src, ntohs(natt_port->sadb_x_nat_t_port_port));
+-
+- natt_port = (void *)mhp[SADB_X_EXT_NAT_T_DPORT];
+- if (extract_port(dst) == 0 && natt_port != NULL)
+- set_port(dst, ntohs(natt_port->sadb_x_nat_t_port_port));
+- }else{
+- /* Force default UDP ports, so CMPSADDR will match SAs with NO encapsulation
+- */
++ if (extract_port(src) == 0 &&
++ mhp[SADB_X_EXT_NAT_T_SPORT] != NULL) {
++ set_port(src, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_SPORT]));
++ }
++
++ if (extract_port(dst) == 0 &&
++ mhp[SADB_X_EXT_NAT_T_DPORT] != NULL) {
++ set_port(dst, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_DPORT]));
++ }
++ natt_port_forced = 0;
++ } else {
++ /* Force default UDP ports, so
++ * CMPSADDR will match SAs with NO encapsulation */
+ set_port(src, PORT_ISAKMP);
+ set_port(dst, PORT_ISAKMP);
++ natt_port_forced = 1;
+ }
+ #endif
+ plog(LLV_DEBUG2, LOCATION, NULL, "src: %s\n", saddr2str(src));
+@@ -1215,10 +1217,9 @@ purge_ipsec_spi(dst0, proto, spi, n)
+ }
+
+ #ifdef ENABLE_NATT
+- if (natt_type == NULL ||
+- ! natt_type->sadb_x_nat_t_type_type) {
+- /* Set back port to 0 if it was forced to default UDP port
+- */
++ if (natt_port_forced) {
++ /* Set back port to 0 if it was forced
++ * to default UDP port */
+ set_port(src, 0);
+ set_port(dst, 0);
+ }
+diff --git a/src/racoon/pfkey.c b/src/racoon/pfkey.c
+index 610cc09..c210c5e 100644
+--- a/src/racoon/pfkey.c
++++ b/src/racoon/pfkey.c
+@@ -769,6 +769,28 @@ keylen_ealg(enctype, encklen)
+ return res;
+ }
+
++void
++pk_fixup_sa_addresses(mhp)
++ caddr_t *mhp;
++{
++ struct sockaddr *src, *dst;
++ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
++ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
++#ifdef ENABLE_NATT
++ if (PFKEY_ADDR_X_NATTYPE(mhp[SADB_X_EXT_NAT_T_TYPE])) {
++ /* NAT-T is enabled for this SADB entry; copy
++ * the ports from NAT-T extensions */
++ if(mhp[SADB_X_EXT_NAT_T_SPORT] != NULL)
++ set_port(src, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_SPORT]));
++ if(mhp[SADB_X_EXT_NAT_T_DPORT] != NULL)
++ set_port(dst, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_DPORT]));
++ }
++#else
++ set_port(src, 0);
++ set_port(dst, 0);
++#endif
++}
++
+ int
+ pfkey_convertfromipsecdoi(proto_id, t_id, hashtype,
+ e_type, e_keylen, a_type, a_keylen, flags)
+@@ -866,6 +888,8 @@ pk_sendgetspi(iph2)
+ struct saprop *pp;
+ struct saproto *pr;
+ u_int32_t minspi, maxspi;
++ u_int8_t natt_type = 0;
++ u_int16_t sport = 0, dport = 0;
+
+ if (iph2->side == INITIATOR)
+ pp = iph2->proposal;
+@@ -919,19 +943,27 @@ pk_sendgetspi(iph2)
+ }
+
+ #ifdef ENABLE_NATT
+- if (! pr->udp_encap) {
+- /* Remove port information, that SA doesn't use it */
+- set_port(iph2->src, 0);
+- set_port(iph2->dst, 0);
++ if (pr->udp_encap) {
++ natt_type = iph2->ph1->natt_options->encaps_type;
++ sport=extract_port(src);
++ dport=extract_port(dst);
+ }
+ #endif
++ /* Always remove port information, it will be sent in
++ * SADB_X_EXT_NAT_T_[S|D]PORT if needed */
++ set_port(src, 0);
++ set_port(dst, 0);
++
+ plog(LLV_DEBUG, LOCATION, NULL, "call pfkey_send_getspi\n");
+- if (pfkey_send_getspi(
++ if (pfkey_send_getspi_nat(
+ lcconf->sock_pfkey,
+ satype,
+ mode,
+ dst, /* src of SA */
+ src, /* dst of SA */
++ natt_type,
++ dport,
++ sport,
+ minspi, maxspi,
+ pr->reqid_in, iph2->seq) < 0) {
+ plog(LLV_ERROR, LOCATION, NULL,
+@@ -1157,13 +1189,13 @@ pk_sendupdate(iph2)
+ #ifdef SADB_X_EXT_NAT_T_FRAG
+ sa_args.l_natt_frag = iph2->ph1->rmconf->esp_frag;
+ #endif
+- } else {
+- /* Remove port information, that SA doesn't use it */
+- set_port(sa_args.src, 0);
+- set_port(sa_args.dst, 0);
+ }
+-
+ #endif
++ /* Always remove port information, it will be sent in
++ * SADB_X_EXT_NAT_T_[S|D]PORT if needed */
++ set_port(sa_args.src, 0);
++ set_port(sa_args.dst, 0);
++
+ /* more info to fill in */
+ sa_args.spi = pr->spi;
+ sa_args.reqid = pr->reqid_in;
+@@ -1236,6 +1268,7 @@ pk_recvupdate(mhp)
+ return -1;
+ }
+ msg = (struct sadb_msg *)mhp[0];
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+ sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
+@@ -1328,7 +1361,6 @@ pk_recvupdate(mhp)
+ /* Force the update of ph2's ports, as there is at least one
+ * situation where they'll mismatch with ph1's values
+ */
+-
+ #ifdef ENABLE_NATT
+ set_port(iph2->src, extract_port(iph2->ph1->local));
+ set_port(iph2->dst, extract_port(iph2->ph1->remote));
+@@ -1456,17 +1488,12 @@ pk_sendadd(iph2)
+ #ifdef SADB_X_EXT_NAT_T_FRAG
+ sa_args.l_natt_frag = iph2->ph1->rmconf->esp_frag;
+ #endif
+- } else {
+- /* Remove port information, that SA doesn't use it */
+- set_port(sa_args.src, 0);
+- set_port(sa_args.dst, 0);
+ }
+-
+-#else
+- /* Remove port information, it is not used without NAT-T */
++#endif
++ /* Always remove port information, it will be sent in
++ * SADB_X_EXT_NAT_T_[S|D]PORT if needed */
+ set_port(sa_args.src, 0);
+ set_port(sa_args.dst, 0);
+-#endif
+
+ /* more info to fill in */
+ sa_args.spi = pr->spi_p;
+@@ -1596,6 +1623,7 @@ pk_recvexpire(mhp)
+ }
+ msg = (struct sadb_msg *)mhp[0];
+ sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+@@ -1721,6 +1749,7 @@ pk_recvacquire(mhp)
+ }
+ msg = (struct sadb_msg *)mhp[0];
+ xpl = (struct sadb_x_policy *)mhp[SADB_X_EXT_POLICY];
++ pk_fixup_sa_addresses(mhp);
+ sp_src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ sp_dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+@@ -1971,6 +2000,7 @@ pk_recvdelete(mhp)
+ }
+ msg = (struct sadb_msg *)mhp[0];
+ sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+@@ -2709,7 +2739,6 @@ pk_recvspddump(mhp)
+ return -1;
+ }
+ msg = (struct sadb_msg *)mhp[0];
+-
+ saddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_SRC];
+ daddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_DST];
+ xpl = (struct sadb_x_policy *)mhp[SADB_X_EXT_POLICY];
+diff --git a/src/racoon/pfkey.h b/src/racoon/pfkey.h
+index a3acd1c..f1b037d 100644
+--- a/src/racoon/pfkey.h
++++ b/src/racoon/pfkey.h
+@@ -52,6 +52,7 @@ extern struct pfkey_st *pfkey_getpst __P((caddr_t *, int, int));
+ extern int pk_checkalg __P((int, int, int));
+
+ struct ph2handle;
++extern void pk_fixup_sa_addresses __P((caddr_t *mhp));
+ extern int pk_sendgetspi __P((struct ph2handle *));
+ extern int pk_sendupdate __P((struct ph2handle *));
+ extern int pk_sendadd __P((struct ph2handle *));
diff --git a/main/ipsec-tools/40-cmpsaddr-cleanup.patch b/main/ipsec-tools/40-cmpsaddr-cleanup.patch
new file mode 100644
index 00000000000..c5e3e4b3304
--- /dev/null
+++ b/main/ipsec-tools/40-cmpsaddr-cleanup.patch
@@ -0,0 +1,1403 @@
+Get rid of CMPSADDR hack in port comparisons. Trac #295.
+
+From: Timo Teras <timo.teras@iki.fi>
+
+
+---
+
+ src/racoon/admin.c | 37 ++++---
+ src/racoon/grabmyaddr.c | 22 ++--
+ src/racoon/handler.c | 41 +++-----
+ src/racoon/handler.h | 7 -
+ src/racoon/isakmp.c | 90 ++++-------------
+ src/racoon/isakmp_cfg.c | 9 --
+ src/racoon/isakmp_inf.c | 111 ++++-----------------
+ src/racoon/isakmp_quick.c | 29 +++---
+ src/racoon/nattraversal.c | 8 +-
+ src/racoon/pfkey.c | 52 +++-------
+ src/racoon/policy.c | 22 ++--
+ src/racoon/remoteconf.c | 30 +-----
+ src/racoon/remoteconf.h | 3 -
+ src/racoon/sockmisc.c | 234 +++------------------------------------------
+ src/racoon/sockmisc.h | 15 +--
+ src/racoon/throttle.c | 2
+ 16 files changed, 170 insertions(+), 542 deletions(-)
+
+
+diff --git a/src/racoon/admin.c b/src/racoon/admin.c
+index 576e191..b67e545 100644
+--- a/src/racoon/admin.c
++++ b/src/racoon/admin.c
+@@ -167,6 +167,14 @@ end:
+ return error;
+ }
+
++static int admin_ph1_delete_sa(struct ph1handle *iph1, void *arg)
++{
++ if (iph1->status >= PHASE1ST_ESTABLISHED)
++ isakmp_info_send_d1(iph1);
++ purge_remote(iph1);
++ return 0;
++}
++
+ /*
+ * main child's process.
+ */
+@@ -257,7 +265,7 @@ admin_process(so2, combuf)
+ break;
+ }
+
+- iph1 = getph1byaddrwop(src, dst);
++ iph1 = getph1byaddr(src, dst, 0);
+ if (iph1 == NULL) {
+ l_ac_errno = ENOENT;
+ break;
+@@ -292,30 +300,25 @@ admin_process(so2, combuf)
+
+ case ADMIN_DELETE_SA: {
+ struct ph1handle *iph1;
+- struct sockaddr *dst;
+- struct sockaddr *src;
++ struct ph1selector sel;
+ char *loc, *rem;
+
+- src = (struct sockaddr *)
++ memset(&sel, 0, sizeof(sel));
++ sel.local = (struct sockaddr *)
+ &((struct admin_com_indexes *)
+ ((caddr_t)com + sizeof(*com)))->src;
+- dst = (struct sockaddr *)
++ sel.remote = (struct sockaddr *)
+ &((struct admin_com_indexes *)
+ ((caddr_t)com + sizeof(*com)))->dst;
+
+- loc = racoon_strdup(saddrwop2str(src));
+- rem = racoon_strdup(saddrwop2str(dst));
++ loc = racoon_strdup(saddr2str(sel.local));
++ rem = racoon_strdup(saddr2str(sel.remote));
+ STRDUP_FATAL(loc);
+ STRDUP_FATAL(rem);
+
+- if ((iph1 = getph1byaddrwop(src, dst)) == NULL) {
+- plog(LLV_ERROR, LOCATION, NULL,
+- "phase 1 for %s -> %s not found\n", loc, rem);
+- } else {
+- if (iph1->status >= PHASE1ST_ESTABLISHED)
+- isakmp_info_send_d1(iph1);
+- purge_remote(iph1);
+- }
++ plog(LLV_INFO, LOCATION, NULL,
++ "admin delete-sa %s %s\n", loc, rem);
++ enumph1(&sel, admin_ph1_delete_sa, NULL);
+
+ racoon_free(loc);
+ racoon_free(rem);
+@@ -360,7 +363,7 @@ admin_process(so2, combuf)
+ plog(LLV_INFO, LOCATION, NULL,
+ "Flushing all SAs for peer %s\n", rem);
+
+- while ((iph1 = getph1bydstaddrwop(dst)) != NULL) {
++ while ((iph1 = getph1bydstaddr(dst)) != NULL) {
+ loc = racoon_strdup(saddrwop2str(iph1->local));
+ STRDUP_FATAL(loc);
+
+@@ -429,7 +432,7 @@ admin_process(so2, combuf)
+ l_ac_errno = -1;
+
+ /* connected already? */
+- ph1 = getph1byaddrwop(src, dst);
++ ph1 = getph1byaddr(src, dst, 0);
+ if (ph1 != NULL) {
+ event_list = &ph1->evt_listeners;
+ if (ph1->status == PHASE1ST_ESTABLISHED)
+diff --git a/src/racoon/grabmyaddr.c b/src/racoon/grabmyaddr.c
+index f866dd5..cb1b638 100644
+--- a/src/racoon/grabmyaddr.c
++++ b/src/racoon/grabmyaddr.c
+@@ -100,7 +100,7 @@ myaddr_configured(addr)
+ return TRUE;
+
+ LIST_FOREACH(cfg, &configured, chain) {
+- if (cmpsaddrstrict(addr, (struct sockaddr *) &cfg->addr) == 0)
++ if (cmpsaddr(addr, (struct sockaddr *) &cfg->addr) == 0)
+ return TRUE;
+ }
+
+@@ -116,7 +116,7 @@ myaddr_open(addr, udp_encap)
+
+ /* Already open? */
+ LIST_FOREACH(my, &opened, chain) {
+- if (cmpsaddrstrict(addr, (struct sockaddr *) &my->addr) == 0)
++ if (cmpsaddr(addr, (struct sockaddr *) &my->addr) == 0)
+ return TRUE;
+ }
+
+@@ -156,7 +156,7 @@ myaddr_open_all_configured(addr)
+
+ LIST_FOREACH(cfg, &configured, chain) {
+ if (addr != NULL &&
+- cmpsaddrwop(addr, (struct sockaddr *) &cfg->addr) != 0)
++ cmpsaddr(addr, (struct sockaddr *) &cfg->addr) != 0)
+ continue;
+ if (!myaddr_open((struct sockaddr *) &cfg->addr, cfg->udp_encap))
+ return FALSE;
+@@ -187,8 +187,8 @@ myaddr_close_all_open(addr)
+ for (my = LIST_FIRST(&opened); my; my = next) {
+ next = LIST_NEXT(my, chain);
+
+- if (!cmpsaddrwop((struct sockaddr *) &addr,
+- (struct sockaddr *) &my->addr))
++ if (!cmpsaddr((struct sockaddr *) &addr,
++ (struct sockaddr *) &my->addr))
+ myaddr_delete(my);
+ }
+ }
+@@ -261,7 +261,7 @@ myaddr_getfd(addr)
+ struct myaddr *my;
+
+ LIST_FOREACH(my, &opened, chain) {
+- if (cmpsaddrstrict((struct sockaddr *) &my->addr, addr) == 0)
++ if (cmpsaddr((struct sockaddr *) &my->addr, addr) == 0)
+ return my->fd;
+ }
+
+@@ -273,19 +273,13 @@ myaddr_getsport(addr)
+ struct sockaddr *addr;
+ {
+ struct myaddr *my;
+- int bestmatch_port = -1;
+
+ LIST_FOREACH(my, &opened, chain) {
+- if (cmpsaddrstrict((struct sockaddr *) &my->addr, addr) == 0)
++ if (cmpsaddr((struct sockaddr *) &my->addr, addr) == 0)
+ return extract_port((struct sockaddr *) &my->addr);
+- if (cmpsaddrwop((struct sockaddr *) &my->addr, addr) != 0)
+- continue;
+- if (bestmatch_port == -1 ||
+- extract_port((struct sockaddr *) &my->addr) == PORT_ISAKMP)
+- bestmatch_port = extract_port((struct sockaddr *) &my->addr);
+ }
+
+- return bestmatch_port;
++ return PORT_ISAKMP;
+ }
+
+ void
+diff --git a/src/racoon/handler.c b/src/racoon/handler.c
+index 960b5b3..b33986f 100644
+--- a/src/racoon/handler.c
++++ b/src/racoon/handler.c
+@@ -120,11 +120,11 @@ enumph1(sel, enum_func, enum_arg)
+ LIST_FOREACH(p, &ph1tree, chain) {
+ if (sel != NULL) {
+ if (sel->local != NULL &&
+- CMPSADDR(sel->local, p->local) != 0)
++ cmpsaddr(sel->local, p->local) != 0)
+ continue;
+
+ if (sel->remote != NULL &&
+- CMPSADDR(sel->remote, p->remote) != 0)
++ cmpsaddr(sel->remote, p->remote) != 0)
+ continue;
+ }
+
+@@ -201,17 +201,12 @@ getph1(rmconf, local, remote, flags)
+ "status %d, skipping\n", p->status);
+ continue;
+ }
+- if (flags & GETPH1_F_WITHOUT_PORTS) {
+- if (local != NULL && cmpsaddrwop(local, p->local) != 0)
+- continue;
+- if (remote != NULL && cmpsaddrwop(remote, p->remote) != 0)
+- continue;
+- } else {
+- if (local != NULL && CMPSADDR(local, p->local) != 0)
+- continue;
+- if (remote != NULL && CMPSADDR(remote, p->remote) != 0)
+- continue;
+- }
++
++ if (local != NULL && cmpsaddr(local, p->local) != 0)
++ continue;
++
++ if (remote != NULL && cmpsaddr(remote, p->remote) != 0)
++ continue;
+
+ plog(LLV_DEBUG2, LOCATION, NULL, "matched\n");
+ return p;
+@@ -287,8 +282,8 @@ void migrate_dying_ph12(iph1)
+ if (p->status < PHASE1ST_DYING)
+ continue;
+
+- if (CMPSADDR(iph1->local, p->local) == 0
+- && CMPSADDR(iph1->remote, p->remote) == 0)
++ if (cmpsaddr(iph1->local, p->local) == 0
++ && cmpsaddr(iph1->remote, p->remote) == 0)
+ migrate_ph12(p, iph1);
+ }
+ }
+@@ -518,11 +513,11 @@ enumph2(sel, enum_func, enum_arg)
+ continue;
+
+ if (sel->src != NULL &&
+- CMPSADDR(sel->src, p->src) != 0)
++ cmpsaddr(sel->src, p->src) != 0)
+ continue;
+
+ if (sel->dst != NULL &&
+- CMPSADDR(sel->dst, p->dst) != 0)
++ cmpsaddr(sel->dst, p->dst) != 0)
+ continue;
+ }
+
+@@ -586,8 +581,8 @@ getph2byid(src, dst, spid)
+
+ LIST_FOREACH(p, &ph2tree, chain) {
+ if (spid == p->spid &&
+- cmpsaddrwild(src, p->src) == 0 &&
+- cmpsaddrwild(dst, p->dst) == 0){
++ cmpsaddr(src, p->src) == 0 &&
++ cmpsaddr(dst, p->dst) == 0){
+ /* Sanity check to detect zombie handlers
+ * XXX Sould be done "somewhere" more interesting,
+ * because we have lots of getph2byxxxx(), but this one
+@@ -614,8 +609,8 @@ getph2bysaddr(src, dst)
+ struct ph2handle *p;
+
+ LIST_FOREACH(p, &ph2tree, chain) {
+- if (cmpsaddrstrict(src, p->src) == 0 &&
+- cmpsaddrstrict(dst, p->dst) == 0)
++ if (cmpsaddr(src, p->src) == 0 &&
++ cmpsaddr(dst, p->dst) == 0)
+ return p;
+ }
+
+@@ -918,7 +913,7 @@ getcontacted(remote)
+ struct contacted *p;
+
+ LIST_FOREACH(p, &ctdtree, chain) {
+- if (cmpsaddrstrict(remote, p->remote) == 0)
++ if (cmpsaddr(remote, p->remote) == 0)
+ return p;
+ }
+
+@@ -997,7 +992,7 @@ check_recvdpkt(remote, local, rbuf)
+ /*
+ * the packet was processed before, but the remote address mismatches.
+ */
+- if (cmpsaddrstrict(remote, r->remote) != 0)
++ if (cmpsaddr(remote, r->remote) != 0)
+ return 2;
+
+ /*
+diff --git a/src/racoon/handler.h b/src/racoon/handler.h
+index c31753d..8f19c88 100644
+--- a/src/racoon/handler.h
++++ b/src/racoon/handler.h
+@@ -467,7 +467,6 @@ extern int enumph1 __P((struct ph1selector *ph1sel,
+ void *enum_arg));
+
+ #define GETPH1_F_ESTABLISHED 0x0001
+-#define GETPH1_F_WITHOUT_PORTS 0x0002
+
+ extern struct ph1handle *getph1 __P((struct remoteconf *rmconf,
+ struct sockaddr *local,
+@@ -476,10 +475,8 @@ extern struct ph1handle *getph1 __P((struct remoteconf *rmconf,
+
+ #define getph1byaddr(local, remote, est) \
+ getph1(NULL, local, remote, est ? GETPH1_F_ESTABLISHED : 0)
+-#define getph1byaddrwop(local, remote) \
+- getph1(NULL, local, remote, GETPH1_F_WITHOUT_PORTS)
+-#define getph1bydstaddrwop(remote) \
+- getph1(NULL, NULL, remote, GETPH1_F_WITHOUT_PORTS)
++#define getph1bydstaddr(remote) \
++ getph1(NULL, NULL, remote, 0)
+
+ #ifdef ENABLE_HYBRID
+ struct ph1handle *getph1bylogin __P((char *));
+diff --git a/src/racoon/isakmp.c b/src/racoon/isakmp.c
+index fe51653..0de16d1 100644
+--- a/src/racoon/isakmp.c
++++ b/src/racoon/isakmp.c
+@@ -475,8 +475,8 @@ isakmp_main(msg, remote, local)
+ /* Floating ports for NAT-T */
+ if (NATT_AVAILABLE(iph1) &&
+ ! (iph1->natt_flags & NAT_PORTS_CHANGED) &&
+- ((cmpsaddrstrict(iph1->remote, remote) != 0) ||
+- (cmpsaddrstrict(iph1->local, local) != 0)))
++ ((cmpsaddr(iph1->remote, remote) != 0) ||
++ (cmpsaddr(iph1->local, local) != 0)))
+ {
+ /* prevent memory leak */
+ racoon_free(iph1->remote);
+@@ -517,7 +517,7 @@ isakmp_main(msg, remote, local)
+ #endif
+
+ /* must be same addresses in one stream of a phase at least. */
+- if (cmpsaddrstrict(iph1->remote, remote) != 0) {
++ if (cmpsaddr(iph1->remote, remote) != 0) {
+ char *saddr_db, *saddr_act;
+
+ saddr_db = racoon_strdup(saddr2str(iph1->remote));
+@@ -643,7 +643,7 @@ isakmp_main(msg, remote, local)
+ "exchange received.\n");
+ return -1;
+ }
+- if (cmpsaddrstrict(iph1->remote, remote) != 0) {
++ if (cmpsaddr(iph1->remote, remote) != 0) {
+ plog(LLV_WARNING, LOCATION, remote,
+ "remote address mismatched. "
+ "db=%s\n",
+@@ -1275,6 +1275,12 @@ isakmp_ph2begin_i(iph1, iph2)
+ }
+ #endif
+
++ /* fixup ph2 ports for this ph1 */
++ if (extract_port(iph2->src) == 0)
++ set_port(iph2->src, extract_port(iph1->local));
++ if (extract_port(iph2->dst) == 0)
++ set_port(iph2->dst, extract_port(iph1->remote));
++
+ /* found ISAKMP-SA. */
+ plog(LLV_DEBUG, LOCATION, NULL, "===\n");
+ plog(LLV_DEBUG, LOCATION, NULL, "begin QUICK mode.\n");
+@@ -1353,15 +1359,6 @@ isakmp_ph2begin_r(iph1, msg)
+ delph2(iph2);
+ return -1;
+ }
+-#if (!defined(ENABLE_NATT)) || (defined(BROKEN_NATT))
+- if (set_port(iph2->dst, 0) == NULL ||
+- set_port(iph2->src, 0) == NULL) {
+- plog(LLV_ERROR, LOCATION, NULL,
+- "invalid family: %d\n", iph2->dst->sa_family);
+- delph2(iph2);
+- return -1;
+- }
+-#endif
+
+ /* add new entry to isakmp status table */
+ insph2(iph2);
+@@ -2186,23 +2183,12 @@ isakmp_post_acquire(iph2)
+ return 0;
+ }
+
+- /*
+- * Search isakmp status table by address and port
+- * If NAT-T is in use, consider null ports as a
+- * wildcard and use IKE ports instead.
++ /*
++ * XXX Searching by IP addresses + ports might fail on
++ * some cases, we should use the ISAKMP identity to search
++ * matching ISAKMP.
+ */
+-#ifdef ENABLE_NATT
+- if (!extract_port(iph2->src) && !extract_port(iph2->dst)) {
+- if ((iph1 = getph1byaddrwop(iph2->src, iph2->dst)) != NULL) {
+- set_port(iph2->src, extract_port(iph1->local));
+- set_port(iph2->dst, extract_port(iph1->remote));
+- }
+- } else {
+- iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
+- }
+-#else
+ iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
+-#endif
+
+ /* no ISAKMP-SA found. */
+ if (iph1 == NULL) {
+@@ -2380,26 +2366,8 @@ isakmp_chkph1there(iph2)
+ return;
+ }
+
+- /*
+- * Search isakmp status table by address and port
+- * If NAT-T is in use, consider null ports as a
+- * wildcard and use IKE ports instead.
+- */
+-#ifdef ENABLE_NATT
+- if (!extract_port(iph2->src) && !extract_port(iph2->dst)) {
+- plog(LLV_DEBUG2, LOCATION, NULL, "CHKPH1THERE: extract_port.\n");
+- if( (iph1 = getph1byaddrwop(iph2->src, iph2->dst)) != NULL){
+- plog(LLV_DEBUG2, LOCATION, NULL, "CHKPH1THERE: found a ph1 wop.\n");
+- }
+- } else {
+- plog(LLV_DEBUG2, LOCATION, NULL, "CHKPH1THERE: searching byaddr.\n");
+- iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
+- if(iph1 != NULL)
+- plog(LLV_DEBUG2, LOCATION, NULL, "CHKPH1THERE: found byaddr.\n");
+- }
+-#else
++ /* Search isakmp status table by address and port */
+ iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
+-#endif
+
+ /* XXX Even if ph1 as responder is there, should we not start
+ * phase 2 negotiation ? */
+@@ -3321,20 +3289,10 @@ purge_remote(iph1)
+ msg = next;
+ continue;
+ }
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+-#ifdef SADB_X_NAT_T_NEW_MAPPING
+- if (PFKEY_ADDR_X_NATTYPE(mhp[SADB_X_EXT_NAT_T_TYPE])) {
+- /* NAT-T is enabled for this SADB entry; copy
+- * the ports from NAT-T extensions */
+- if(mhp[SADB_X_EXT_NAT_T_SPORT] != NULL)
+- set_port(src, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_SPORT]));
+- if(mhp[SADB_X_EXT_NAT_T_DPORT] != NULL)
+- set_port(dst, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_DPORT]));
+- }
+-#endif
+-
+ if (sa->sadb_sa_state != SADB_SASTATE_LARVAL &&
+ sa->sadb_sa_state != SADB_SASTATE_MATURE &&
+ sa->sadb_sa_state != SADB_SASTATE_DYING) {
+@@ -3346,22 +3304,14 @@ purge_remote(iph1)
+ * check in/outbound SAs.
+ * Select only SAs where src == local and dst == remote (outgoing)
+ * or src == remote and dst == local (incoming).
+- * XXX we sometime have src/dst ports set to 0 and want to match
+- * iph1->local/remote with ports set to 500. This is a bug, see trac:2
+ */
+-#ifdef ENABLE_NATT
+- if ((cmpsaddrmagic(iph1->local, src) || cmpsaddrmagic(iph1->remote, dst)) &&
+- (cmpsaddrmagic(iph1->local, dst) || cmpsaddrmagic(iph1->remote, src))) {
+- msg = next;
+- continue;
+- }
+-#else
+- if ((CMPSADDR(iph1->local, src) || CMPSADDR(iph1->remote, dst)) &&
+- (CMPSADDR(iph1->local, dst) || CMPSADDR(iph1->remote, src))) {
++ if ((cmpsaddr(iph1->local, src) ||
++ cmpsaddr(iph1->remote, dst)) &&
++ (cmpsaddr(iph1->local, dst) ||
++ cmpsaddr(iph1->remote, src))) {
+ msg = next;
+ continue;
+ }
+-#endif
+
+ proto_id = pfkey2ipsecdoi_proto(msg->sadb_msg_satype);
+ iph2 = getph2bysaidx(src, dst, proto_id, sa->sadb_sa_spi);
+diff --git a/src/racoon/isakmp_cfg.c b/src/racoon/isakmp_cfg.c
+index 62916f8..df763f8 100644
+--- a/src/racoon/isakmp_cfg.c
++++ b/src/racoon/isakmp_cfg.c
+@@ -1151,15 +1151,6 @@ isakmp_cfg_send(iph1, payload, np, flags, new_exchange)
+ goto end;
+ }
+
+-#if (!defined(ENABLE_NATT)) || (defined(BROKEN_NATT))
+- if (set_port(iph2->dst, 0) == NULL ||
+- set_port(iph2->src, 0) == NULL) {
+- plog(LLV_ERROR, LOCATION, NULL,
+- "invalid family: %d\n", iph1->remote->sa_family);
+- delph2(iph2);
+- goto end;
+- }
+-#endif
+ iph2->side = INITIATOR;
+ iph2->status = PHASE2ST_START;
+
+diff --git a/src/racoon/isakmp_inf.c b/src/racoon/isakmp_inf.c
+index a712825..6fa3498 100644
+--- a/src/racoon/isakmp_inf.c
++++ b/src/racoon/isakmp_inf.c
+@@ -903,15 +903,6 @@ isakmp_info_send_common(iph1, payload, np, flags)
+ delph2(iph2);
+ goto end;
+ }
+-#if (!defined(ENABLE_NATT)) || (defined(BROKEN_NATT))
+- if (set_port(iph2->dst, 0) == NULL ||
+- set_port(iph2->src, 0) == NULL) {
+- plog(LLV_ERROR, LOCATION, NULL,
+- "invalid family: %d\n", iph1->remote->sa_family);
+- delph2(iph2);
+- goto end;
+- }
+-#endif
+ iph2->side = INITIATOR;
+ iph2->status = PHASE2ST_START;
+ iph2->msgid = isakmp_newmsgid2(iph1);
+@@ -1127,9 +1118,6 @@ purge_ipsec_spi(dst0, proto, spi, n)
+ u_int64_t created;
+ size_t i;
+ caddr_t mhp[SADB_EXT_MAX + 1];
+-#ifdef ENABLE_NATT
+- int natt_port_forced;
+-#endif
+
+ plog(LLV_DEBUG2, LOCATION, NULL,
+ "purge_ipsec_spi:\n");
+@@ -1169,6 +1157,7 @@ purge_ipsec_spi(dst0, proto, spi, n)
+ msg = next;
+ continue;
+ }
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+ lt = (struct sadb_lifetime*)mhp[SADB_EXT_LIFETIME_HARD];
+@@ -1182,28 +1171,7 @@ purge_ipsec_spi(dst0, proto, spi, n)
+ msg = next;
+ continue;
+ }
+-#ifdef ENABLE_NATT
+- if (PFKEY_ADDR_X_NATTYPE(mhp[SADB_X_EXT_NAT_T_TYPE])) {
+- /* NAT-T is enabled for this SADB entry; copy
+- * the ports from NAT-T extensions */
+- if (extract_port(src) == 0 &&
+- mhp[SADB_X_EXT_NAT_T_SPORT] != NULL) {
+- set_port(src, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_SPORT]));
+- }
+
+- if (extract_port(dst) == 0 &&
+- mhp[SADB_X_EXT_NAT_T_DPORT] != NULL) {
+- set_port(dst, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_DPORT]));
+- }
+- natt_port_forced = 0;
+- } else {
+- /* Force default UDP ports, so
+- * CMPSADDR will match SAs with NO encapsulation */
+- set_port(src, PORT_ISAKMP);
+- set_port(dst, PORT_ISAKMP);
+- natt_port_forced = 1;
+- }
+-#endif
+ plog(LLV_DEBUG2, LOCATION, NULL, "src: %s\n", saddr2str(src));
+ plog(LLV_DEBUG2, LOCATION, NULL, "dst: %s\n", saddr2str(dst));
+
+@@ -1211,19 +1179,11 @@ purge_ipsec_spi(dst0, proto, spi, n)
+
+ /* don't delete inbound SAs at the moment */
+ /* XXX should we remove SAs with opposite direction as well? */
+- if (CMPSADDR(dst0, dst)) {
++ if (cmpsaddr(dst0, dst)) {
+ msg = next;
+ continue;
+ }
+
+-#ifdef ENABLE_NATT
+- if (natt_port_forced) {
+- /* Set back port to 0 if it was forced
+- * to default UDP port */
+- set_port(src, 0);
+- set_port(dst, 0);
+- }
+-#endif
+ for (i = 0; i < n; i++) {
+ plog(LLV_DEBUG, LOCATION, NULL,
+ "check spi(packet)=%u spi(db)=%u.\n",
+@@ -1354,37 +1314,33 @@ isakmp_info_recv_initialcontact(iph1, protectedph2)
+ msg = (struct sadb_msg *)buf->v;
+ end = (struct sadb_msg *)(buf->v + buf->l);
+
+- while (msg < end) {
++ for (; msg < end; msg = next) {
+ if ((msg->sadb_msg_len << 3) < sizeof(*msg))
+ break;
++
+ next = (struct sadb_msg *)((caddr_t)msg + (msg->sadb_msg_len << 3));
+- if (msg->sadb_msg_type != SADB_DUMP) {
+- msg = next;
++ if (msg->sadb_msg_type != SADB_DUMP)
+ continue;
+- }
+
+ if (pfkey_align(msg, mhp) || pfkey_check(mhp)) {
+ plog(LLV_ERROR, LOCATION, NULL,
+ "pfkey_check (%s)\n", ipsec_strerror());
+- msg = next;
+ continue;
+ }
+
+ if (mhp[SADB_EXT_SA] == NULL
+ || mhp[SADB_EXT_ADDRESS_SRC] == NULL
+- || mhp[SADB_EXT_ADDRESS_DST] == NULL) {
+- msg = next;
++ || mhp[SADB_EXT_ADDRESS_DST] == NULL)
+ continue;
+- }
++
+ sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+ if (sa->sadb_sa_state != SADB_SASTATE_MATURE
+- && sa->sadb_sa_state != SADB_SASTATE_DYING) {
+- msg = next;
++ && sa->sadb_sa_state != SADB_SASTATE_DYING)
+ continue;
+- }
+
+ /*
+ * RFC2407 4.6.3.3 INITIAL-CONTACT is the message that
+@@ -1394,39 +1350,18 @@ isakmp_info_recv_initialcontact(iph1, protectedph2)
+ * racoon only deletes SA which is matched both the
+ * source address and the destination accress.
+ */
+-#ifdef ENABLE_NATT
+- /*
+- * XXX RFC 3947 says that whe MUST NOT use IP+port to find old SAs
+- * from this peer !
+- */
+- if(iph1->natt_flags & NAT_DETECTED){
+- if (CMPSADDR(iph1->local, src) == 0 &&
+- CMPSADDR(iph1->remote, dst) == 0)
+- ;
+- else if (CMPSADDR(iph1->remote, src) == 0 &&
+- CMPSADDR(iph1->local, dst) == 0)
+- ;
+- else {
+- msg = next;
+- continue;
+- }
+- } else
+-#endif
+- /* If there is no NAT-T, we don't have to check addr + port...
+- * XXX what about a configuration with a remote peers which is not
+- * NATed, but which NATs some other peers ?
+- * Here, the INITIAl-CONTACT would also flush all those NATed peers !!
+- */
+- if (cmpsaddrwop(iph1->local, src) == 0 &&
+- cmpsaddrwop(iph1->remote, dst) == 0)
+- ;
+- else if (cmpsaddrwop(iph1->remote, src) == 0 &&
+- cmpsaddrwop(iph1->local, dst) == 0)
+- ;
+- else {
+- msg = next;
++
++ /*
++ * Check that the IP and port match. But this is not optimal,
++ * since NAT-T can make the peer have multiple different
++ * ports. Correct thing to do is delete all entries with
++ * same identity. -TT
++ */
++ if ((cmpsaddr(iph1->local, src) != 0 ||
++ cmpsaddr(iph1->remote, dst) != 0) &&
++ (cmpsaddr(iph1->local, dst) != 0 ||
++ cmpsaddr(iph1->remote, src) != 0))
+ continue;
+- }
+
+ /*
+ * Make sure this is an SATYPE that we manage.
+@@ -1438,10 +1373,8 @@ isakmp_info_recv_initialcontact(iph1, protectedph2)
+ msg->sadb_msg_satype)
+ break;
+ }
+- if (i == pfkey_nsatypes) {
+- msg = next;
++ if (i == pfkey_nsatypes)
+ continue;
+- }
+
+ plog(LLV_INFO, LOCATION, NULL,
+ "purging spi=%u.\n", ntohl(sa->sadb_sa_spi));
+@@ -1461,8 +1394,6 @@ isakmp_info_recv_initialcontact(iph1, protectedph2)
+ remph2(iph2);
+ delph2(iph2);
+ }
+-
+- msg = next;
+ }
+
+ vfree(buf);
+diff --git a/src/racoon/isakmp_quick.c b/src/racoon/isakmp_quick.c
+index 804c1bf..46c84c1 100644
+--- a/src/racoon/isakmp_quick.c
++++ b/src/racoon/isakmp_quick.c
+@@ -610,17 +610,19 @@ quick_i2recv(iph2, msg0)
+ error = ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED;
+ goto end;
+ }
++#ifdef ENABLE_NATT
++ set_port(iph2->natoa_src,
++ extract_port((struct sockaddr *) &proposed_addr));
++#endif
+
+- if (cmpsaddrstrict((struct sockaddr *) &proposed_addr,
+- (struct sockaddr *) &got_addr) == 0) {
++ if (cmpsaddr((struct sockaddr *) &proposed_addr,
++ (struct sockaddr *) &got_addr) == 0) {
+ plog(LLV_DEBUG, LOCATION, NULL,
+ "IDci matches proposal.\n");
+ #ifdef ENABLE_NATT
+ } else if (iph2->natoa_src != NULL
+- && cmpsaddrwop(iph2->natoa_src,
+- (struct sockaddr *) &got_addr) == 0
+- && extract_port((struct sockaddr *) &proposed_addr) ==
+- extract_port((struct sockaddr *) &got_addr)) {
++ && cmpsaddr(iph2->natoa_src,
++ (struct sockaddr *) &got_addr) == 0) {
+ plog(LLV_DEBUG, LOCATION, NULL,
+ "IDci matches NAT-OAi.\n");
+ #endif
+@@ -656,16 +658,19 @@ quick_i2recv(iph2, msg0)
+ goto end;
+ }
+
+- if (cmpsaddrstrict((struct sockaddr *) &proposed_addr,
+- (struct sockaddr *) &got_addr) == 0) {
++#ifdef ENABLE_NATT
++ set_port(iph2->natoa_dst,
++ extract_port((struct sockaddr *) &proposed_addr));
++#endif
++
++ if (cmpsaddr((struct sockaddr *) &proposed_addr,
++ (struct sockaddr *) &got_addr) == 0) {
+ plog(LLV_DEBUG, LOCATION, NULL,
+ "IDcr matches proposal.\n");
+ #ifdef ENABLE_NATT
+ } else if (iph2->natoa_dst != NULL
+- && cmpsaddrwop(iph2->natoa_dst,
+- (struct sockaddr *) &got_addr) == 0
+- && extract_port((struct sockaddr *) &proposed_addr) ==
+- extract_port((struct sockaddr *) &got_addr)) {
++ && cmpsaddr(iph2->natoa_dst,
++ (struct sockaddr *) &got_addr) == 0) {
+ plog(LLV_DEBUG, LOCATION, NULL,
+ "IDcr matches NAT-OAr.\n");
+ #endif
+diff --git a/src/racoon/nattraversal.c b/src/racoon/nattraversal.c
+index f23341a..92095de 100644
+--- a/src/racoon/nattraversal.c
++++ b/src/racoon/nattraversal.c
+@@ -379,8 +379,8 @@ natt_keepalive_add (struct sockaddr *src, struct sockaddr *dst)
+ struct natt_ka_addrs *ka = NULL, *new_addr;
+
+ TAILQ_FOREACH (ka, &ka_tree, chain) {
+- if (cmpsaddrstrict(ka->src, src) == 0 &&
+- cmpsaddrstrict(ka->dst, dst) == 0) {
++ if (cmpsaddr(ka->src, src) == 0 &&
++ cmpsaddr(ka->dst, dst) == 0) {
+ ka->in_use++;
+ plog (LLV_INFO, LOCATION, NULL, "KA found: %s (in_use=%u)\n",
+ saddr2str_fromto("%s->%s", src, dst), ka->in_use);
+@@ -443,8 +443,8 @@ natt_keepalive_remove (struct sockaddr *src, struct sockaddr *dst)
+ plog (LLV_DEBUG, LOCATION, NULL, "KA tree dump: %s (in_use=%u)\n",
+ saddr2str_fromto("%s->%s", src, dst), ka->in_use);
+
+- if (cmpsaddrstrict(ka->src, src) == 0 &&
+- cmpsaddrstrict(ka->dst, dst) == 0 &&
++ if (cmpsaddr(ka->src, src) == 0 &&
++ cmpsaddr(ka->dst, dst) == 0 &&
+ -- ka->in_use <= 0) {
+
+ plog (LLV_DEBUG, LOCATION, NULL, "KA removing this one...\n");
+diff --git a/src/racoon/pfkey.c b/src/racoon/pfkey.c
+index c210c5e..3778ef2 100644
+--- a/src/racoon/pfkey.c
++++ b/src/racoon/pfkey.c
+@@ -774,8 +774,12 @@ pk_fixup_sa_addresses(mhp)
+ caddr_t *mhp;
+ {
+ struct sockaddr *src, *dst;
++
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
++ set_port(src, PORT_ISAKMP);
++ set_port(dst, PORT_ISAKMP);
++
+ #ifdef ENABLE_NATT
+ if (PFKEY_ADDR_X_NATTYPE(mhp[SADB_X_EXT_NAT_T_TYPE])) {
+ /* NAT-T is enabled for this SADB entry; copy
+@@ -785,9 +789,6 @@ pk_fixup_sa_addresses(mhp)
+ if(mhp[SADB_X_EXT_NAT_T_DPORT] != NULL)
+ set_port(dst, PFKEY_ADDR_X_PORT(mhp[SADB_X_EXT_NAT_T_DPORT]));
+ }
+-#else
+- set_port(src, 0);
+- set_port(dst, 0);
+ #endif
+ }
+
+@@ -949,10 +950,6 @@ pk_sendgetspi(iph2)
+ dport=extract_port(dst);
+ }
+ #endif
+- /* Always remove port information, it will be sent in
+- * SADB_X_EXT_NAT_T_[S|D]PORT if needed */
+- set_port(src, 0);
+- set_port(dst, 0);
+
+ plog(LLV_DEBUG, LOCATION, NULL, "call pfkey_send_getspi\n");
+ if (pfkey_send_getspi_nat(
+@@ -1009,6 +1006,7 @@ pk_recvgetspi(mhp)
+ }
+ msg = (struct sadb_msg *)mhp[0];
+ sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
++ pk_fixup_sa_addresses(mhp);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]); /* note SA dir */
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+@@ -1183,18 +1181,14 @@ pk_sendupdate(iph2)
+ #ifdef ENABLE_NATT
+ if (pr->udp_encap) {
+ sa_args.l_natt_type = iph2->ph1->natt_options->encaps_type;
+- sa_args.l_natt_sport = extract_port (iph2->ph1->remote);
+- sa_args.l_natt_dport = extract_port (iph2->ph1->local);
++ sa_args.l_natt_sport = extract_port(iph2->ph1->remote);
++ sa_args.l_natt_dport = extract_port(iph2->ph1->local);
+ sa_args.l_natt_oa = iph2->natoa_src;
+ #ifdef SADB_X_EXT_NAT_T_FRAG
+ sa_args.l_natt_frag = iph2->ph1->rmconf->esp_frag;
+ #endif
+ }
+ #endif
+- /* Always remove port information, it will be sent in
+- * SADB_X_EXT_NAT_T_[S|D]PORT if needed */
+- set_port(sa_args.src, 0);
+- set_port(sa_args.dst, 0);
+
+ /* more info to fill in */
+ sa_args.spi = pr->spi;
+@@ -1358,14 +1352,6 @@ pk_recvupdate(mhp)
+ /* turn off schedule */
+ sched_cancel(&iph2->scr);
+
+- /* Force the update of ph2's ports, as there is at least one
+- * situation where they'll mismatch with ph1's values
+- */
+-#ifdef ENABLE_NATT
+- set_port(iph2->src, extract_port(iph2->ph1->local));
+- set_port(iph2->dst, extract_port(iph2->ph1->remote));
+-#endif
+-
+ /*
+ * since we are going to reuse the phase2 handler, we need to
+ * remain it and refresh all the references between ph1 and ph2 to use.
+@@ -1418,7 +1404,7 @@ pk_sendadd(iph2)
+ racoon_free(sa_args.src);
+ racoon_free(sa_args.dst);
+ return -1;
+- }
++ }
+
+ for (pr = iph2->approval->head; pr != NULL; pr = pr->next) {
+ /* validity check */
+@@ -1490,11 +1476,6 @@ pk_sendadd(iph2)
+ #endif
+ }
+ #endif
+- /* Always remove port information, it will be sent in
+- * SADB_X_EXT_NAT_T_[S|D]PORT if needed */
+- set_port(sa_args.src, 0);
+- set_port(sa_args.dst, 0);
+-
+ /* more info to fill in */
+ sa_args.spi = pr->spi_p;
+ sa_args.reqid = pr->reqid_out;
+@@ -1559,6 +1540,7 @@ pk_recvadd(mhp)
+ return -1;
+ }
+ msg = (struct sadb_msg *)mhp[0];
++ pk_fixup_sa_addresses(mhp);
+ src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+ sa = (struct sadb_sa *)mhp[SADB_EXT_SA];
+@@ -1749,7 +1731,9 @@ pk_recvacquire(mhp)
+ }
+ msg = (struct sadb_msg *)mhp[0];
+ xpl = (struct sadb_x_policy *)mhp[SADB_X_EXT_POLICY];
+- pk_fixup_sa_addresses(mhp);
++ /* acquire does not have nat-t ports; so do not bother setting
++ * the default port 500; just use the port zero for wildcard
++ * matching the get a valid natted destination */
+ sp_src = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_SRC]);
+ sp_dst = PFKEY_ADDR_SADDR(mhp[SADB_EXT_ADDRESS_DST]);
+
+@@ -2884,8 +2868,8 @@ migrate_ph1_ike_addresses(iph1, arg)
+ u_int16_t port;
+
+ /* Already up-to-date? */
+- if (cmpsaddrwop(iph1->local, ma->local) == 0 &&
+- cmpsaddrwop(iph1->remote, ma->remote) == 0)
++ if (cmpsaddr(iph1->local, ma->local) == 0 &&
++ cmpsaddr(iph1->remote, ma->remote) == 0)
+ return 0;
+
+ if (iph1->status < PHASE1ST_ESTABLISHED) {
+@@ -2985,8 +2969,8 @@ migrate_ph2_ike_addresses(iph2, arg)
+ migrate_ph1_ike_addresses(iph2->ph1, arg);
+
+ /* Already up-to-date? */
+- if (CMPSADDR(iph2->src, ma->local) == 0 &&
+- CMPSADDR(iph2->dst, ma->remote) == 0)
++ if (cmpsaddr(iph2->src, ma->local) == 0 &&
++ cmpsaddr(iph2->dst, ma->remote) == 0)
+ return 0;
+
+ /* save src/dst as sa_src/sa_dst before rewriting */
+@@ -3206,8 +3190,8 @@ migrate_ph2_one_isr(spid, isr_cur, xisr_old, xisr_new)
+ "changing address families (%d to %d) for endpoints.\n",
+ osaddr->sa_family, nsaddr->sa_family);
+
+- if (CMPSADDR(osaddr, (struct sockaddr *)&saidx->src) ||
+- CMPSADDR(odaddr, (struct sockaddr *)&saidx->dst)) {
++ if (cmpsaddr(osaddr, (struct sockaddr *) &saidx->src) ||
++ cmpsaddr(odaddr, (struct sockaddr *) &saidx->dst)) {
+ plog(LLV_DEBUG, LOCATION, NULL, "SADB_X_MIGRATE: "
+ "mismatch of addresses in saidx and xisr.\n");
+ return -1;
+diff --git a/src/racoon/policy.c b/src/racoon/policy.c
+index 850fa6b..058753f 100644
+--- a/src/racoon/policy.c
++++ b/src/racoon/policy.c
+@@ -141,16 +141,18 @@ getsp_r(spidx, iph2)
+ saddr2str(iph2->src));
+ plog(LLV_DEBUG, LOCATION, NULL, "src2: %s\n",
+ saddr2str((struct sockaddr *)&spidx->src));
+- if (cmpsaddrwop(iph2->src, (struct sockaddr *)&spidx->src)
+- || spidx->prefs != prefixlen)
++
++ if (cmpsaddr(iph2->src, (struct sockaddr *) &spidx->src) ||
++ spidx->prefs != prefixlen)
+ return NULL;
+
+ plog(LLV_DEBUG, LOCATION, NULL, "dst1: %s\n",
+ saddr2str(iph2->dst));
+ plog(LLV_DEBUG, LOCATION, NULL, "dst2: %s\n",
+ saddr2str((struct sockaddr *)&spidx->dst));
+- if (cmpsaddrwop(iph2->dst, (struct sockaddr *)&spidx->dst)
+- || spidx->prefd != prefixlen)
++
++ if (cmpsaddr(iph2->dst, (struct sockaddr *) &spidx->dst) ||
++ spidx->prefd != prefixlen)
+ return NULL;
+
+ plog(LLV_DEBUG, LOCATION, NULL, "looks to be transport mode\n");
+@@ -198,11 +200,11 @@ cmpspidxstrict(a, b)
+ || a->ul_proto != b->ul_proto)
+ return 1;
+
+- if (cmpsaddrstrict((struct sockaddr *)&a->src,
+- (struct sockaddr *)&b->src))
++ if (cmpsaddr((struct sockaddr *) &a->src,
++ (struct sockaddr *) &b->src))
+ return 1;
+- if (cmpsaddrstrict((struct sockaddr *)&a->dst,
+- (struct sockaddr *)&b->dst))
++ if (cmpsaddr((struct sockaddr *) &a->dst,
++ (struct sockaddr *) &b->dst))
+ return 1;
+
+ #ifdef HAVE_SECCTX
+@@ -259,7 +261,7 @@ cmpspidxwild(a, b)
+ a, b->prefs, saddr2str((struct sockaddr *)&sa1));
+ plog(LLV_DEBUG, LOCATION, NULL, "%p masked with /%d: %s\n",
+ b, b->prefs, saddr2str((struct sockaddr *)&sa2));
+- if (cmpsaddrwild((struct sockaddr *)&sa1, (struct sockaddr *)&sa2))
++ if (cmpsaddr((struct sockaddr *)&sa1, (struct sockaddr *)&sa2))
+ return 1;
+
+ #ifndef __linux__
+@@ -277,7 +279,7 @@ cmpspidxwild(a, b)
+ a, b->prefd, saddr2str((struct sockaddr *)&sa1));
+ plog(LLV_DEBUG, LOCATION, NULL, "%p masked with /%d: %s\n",
+ b, b->prefd, saddr2str((struct sockaddr *)&sa2));
+- if (cmpsaddrwild((struct sockaddr *)&sa1, (struct sockaddr *)&sa2))
++ if (cmpsaddr((struct sockaddr *)&sa1, (struct sockaddr *)&sa2))
+ return 1;
+
+ #ifdef HAVE_SECCTX
+diff --git a/src/racoon/remoteconf.c b/src/racoon/remoteconf.c
+index 73d80bc..88c622c 100644
+--- a/src/racoon/remoteconf.c
++++ b/src/racoon/remoteconf.c
+@@ -200,15 +200,9 @@ rmconf_match_type(rmsel, rmconf)
+ /* Check address */
+ if (rmsel->remote != NULL) {
+ if (rmconf->remote->sa_family != AF_UNSPEC) {
+- if (rmsel->flags & GETRMCONF_F_NO_PORTS) {
+- if (cmpsaddrwop(rmsel->remote,
+- rmconf->remote) != 0)
+- return 0;
+- } else {
+- if (cmpsaddrstrict(rmsel->remote,
+- rmconf->remote) != 0)
+- return 0;
+- }
++ if (cmpsaddr(rmsel->remote, rmconf->remote) != 0)
++ return 0;
++
+ /* Address matched */
+ ret = 2;
+ }
+@@ -262,7 +256,7 @@ void rmconf_selector_from_ph1(rmsel, iph1)
+ struct ph1handle *iph1;
+ {
+ memset(rmsel, 0, sizeof(*rmsel));
+- rmsel->flags = GETRMCONF_F_NO_PORTS;
++ rmsel->flags = 0;
+ rmsel->remote = iph1->remote;
+ rmsel->etype = iph1->etype;
+ rmsel->approval = iph1->approval;
+@@ -357,22 +351,8 @@ getrmconf(remote, flags)
+ int n = 0;
+
+ memset(&ctx, 0, sizeof(ctx));
+- ctx.sel.flags = flags | GETRMCONF_F_NO_PORTS;
++ ctx.sel.flags = flags;
+ ctx.sel.remote = remote;
+-#ifndef ENABLE_NATT
+- /*
+- * We never have ports set in our remote configurations, but when
+- * NAT-T is enabled, the kernel can have policies with ports and
+- * send us an acquire message for a destination that has a port set.
+- * If we do this port check here, we don't find the remote config.
+- *
+- * In an ideal world, we would be able to have remote conf with
+- * port, and the port could be a wildcard. That test could be used.
+- */
+- if (remote->sa_family != AF_UNSPEC &&
+- extract_port(remote) != IPSEC_PORT_ANY)
+- ctx.sel.flags &= ~GETRMCONF_F_NO_PORTS;
+-#endif /* ENABLE_NATT */
+
+ if (enumrmconf(&ctx.sel, rmconf_find, &ctx) != 0) {
+ plog(LLV_ERROR, LOCATION, remote,
+diff --git a/src/racoon/remoteconf.h b/src/racoon/remoteconf.h
+index 38faf03..b2e9e4a 100644
+--- a/src/racoon/remoteconf.h
++++ b/src/racoon/remoteconf.h
+@@ -189,8 +189,7 @@ extern int enumrmconf __P((struct rmconfselector *rmsel,
+ void *enum_arg));
+
+ #define GETRMCONF_F_NO_ANONYMOUS 0x0001
+-#define GETRMCONF_F_NO_PORTS 0x0002
+-#define GETRMCONF_F_NO_PASSIVE 0x0004
++#define GETRMCONF_F_NO_PASSIVE 0x0002
+
+ #define RMCONF_ERR_MULTIPLE ((struct remoteconf *) -1)
+
+diff --git a/src/racoon/sockmisc.c b/src/racoon/sockmisc.c
+index 5c1f9c7..2bc2177 100644
+--- a/src/racoon/sockmisc.c
++++ b/src/racoon/sockmisc.c
+@@ -80,87 +77,28 @@
+ const int niflags = 0;
+
+ /*
+- * compare two sockaddr without port number.
+- * OUT: 0: equal.
+- * 1: not equal.
+- */
+-int
+-cmpsaddrwop(addr1, addr2)
+- const struct sockaddr *addr1;
+- const struct sockaddr *addr2;
+-{
+- caddr_t sa1, sa2;
+-
+- if (addr1 == 0 && addr2 == 0)
+- return 0;
+- if (addr1 == 0 || addr2 == 0)
+- return 1;
+-
+-#ifdef __linux__
+- if (addr1->sa_family != addr2->sa_family)
+- return 1;
+-#else
+- if (addr1->sa_len != addr2->sa_len
+- || addr1->sa_family != addr2->sa_family)
+- return 1;
+-
+-#endif /* __linux__ */
+-
+- switch (addr1->sa_family) {
+- case AF_UNSPEC:
+- break;
+- case AF_INET:
+- sa1 = (caddr_t)&((struct sockaddr_in *)addr1)->sin_addr;
+- sa2 = (caddr_t)&((struct sockaddr_in *)addr2)->sin_addr;
+- if (memcmp(sa1, sa2, sizeof(struct in_addr)) != 0)
+- return 1;
+- break;
+-#ifdef INET6
+- case AF_INET6:
+- sa1 = (caddr_t)&((struct sockaddr_in6 *)addr1)->sin6_addr;
+- sa2 = (caddr_t)&((struct sockaddr_in6 *)addr2)->sin6_addr;
+- if (memcmp(sa1, sa2, sizeof(struct in6_addr)) != 0)
+- return 1;
+- if (((struct sockaddr_in6 *)addr1)->sin6_scope_id !=
+- ((struct sockaddr_in6 *)addr2)->sin6_scope_id)
+- return 1;
+- break;
+-#endif
+- default:
+- return 1;
+- }
+-
+- return 0;
+-}
+-
+-/*
+ * compare two sockaddr with port, taking care wildcard.
+ * addr1 is a subject address, addr2 is in a database entry.
+ * OUT: 0: equal.
+ * 1: not equal.
+ */
+ int
+-cmpsaddrwild(addr1, addr2)
++cmpsaddr(addr1, addr2)
+ const struct sockaddr *addr1;
+ const struct sockaddr *addr2;
+ {
+ caddr_t sa1, sa2;
+ u_short port1, port2;
+
+- if (addr1 == 0 && addr2 == 0)
+- return 0;
+- if (addr1 == 0 || addr2 == 0)
+- return 1;
++ if (addr1 == NULL && addr2 == NULL)
++ return CMPSADDR_MATCH;
+
+-#ifdef __linux__
+- if (addr1->sa_family != addr2->sa_family)
+- return 1;
+-#else
+- if (addr1->sa_len != addr2->sa_len
+- || addr1->sa_family != addr2->sa_family)
+- return 1;
++ if (addr1 == NULL || addr2 == NULL)
++ return CMPSADDR_MISMATCH;
+
+-#endif /* __linux__ */
++ if (addr1->sa_family != addr2->sa_family ||
++ sysdep_sa_len(addr1) != sysdep_sa_len(addr2))
++ return CMPSADDR_MISMATCH;
+
+ switch (addr1->sa_family) {
+ case AF_UNSPEC:
+@@ -170,12 +108,8 @@ cmpsaddrwild(addr1, addr2)
+ sa2 = (caddr_t)&((struct sockaddr_in *)addr2)->sin_addr;
+ port1 = ((struct sockaddr_in *)addr1)->sin_port;
+ port2 = ((struct sockaddr_in *)addr2)->sin_port;
+- if (!(port1 == IPSEC_PORT_ANY ||
+- port2 == IPSEC_PORT_ANY ||
+- port1 == port2))
+- return 1;
+ if (memcmp(sa1, sa2, sizeof(struct in_addr)) != 0)
+- return 1;
++ return CMPSADDR_MISMATCH;
+ break;
+ #ifdef INET6
+ case AF_INET6:
+@@ -183,155 +117,23 @@ cmpsaddrwild(addr1, addr2)
+ sa2 = (caddr_t)&((struct sockaddr_in6 *)addr2)->sin6_addr;
+ port1 = ((struct sockaddr_in6 *)addr1)->sin6_port;
+ port2 = ((struct sockaddr_in6 *)addr2)->sin6_port;
+- if (!(port1 == IPSEC_PORT_ANY ||
+- port2 == IPSEC_PORT_ANY ||
+- port1 == port2))
+- return 1;
+ if (memcmp(sa1, sa2, sizeof(struct in6_addr)) != 0)
+- return 1;
++ return CMPSADDR_MISMATCH;
+ if (((struct sockaddr_in6 *)addr1)->sin6_scope_id !=
+ ((struct sockaddr_in6 *)addr2)->sin6_scope_id)
+- return 1;
++ return CMPSADDR_MISMATCH;
+ break;
+ #endif
+ default:
+- return 1;
++ return CMPSADDR_MISMATCH;
+ }
+
+- return 0;
+-}
+-
+-/*
+- * compare two sockaddr with port, taking care specific situation:
+- * one addr has 0 as port, and the other has 500 (network order), return equal
+- * OUT: 0: equal.
+- * 1: not equal.
+- */
+-int
+-cmpsaddrmagic(addr1, addr2)
+- const struct sockaddr *addr1;
+- const struct sockaddr *addr2;
+-{
+- caddr_t sa1, sa2;
+- u_short port1, port2;
+-
+- if (addr1 == 0 && addr2 == 0)
+- return 0;
+- if (addr1 == 0 || addr2 == 0)
+- return 1;
+-
+-#ifdef __linux__
+- if (addr1->sa_family != addr2->sa_family)
+- return 1;
+-#else
+- if (addr1->sa_len != addr2->sa_len
+- || addr1->sa_family != addr2->sa_family)
+- return 1;
++ if (port1 == port2 ||
++ port1 == IPSEC_PORT_ANY ||
++ port2 == IPSEC_PORT_ANY)
++ return CMPSADDR_MATCH;
+
+-#endif /* __linux__ */
+-
+- switch (addr1->sa_family) {
+- case AF_UNSPEC:
+- break;
+- case AF_INET:
+- sa1 = (caddr_t)&((struct sockaddr_in *)addr1)->sin_addr;
+- sa2 = (caddr_t)&((struct sockaddr_in *)addr2)->sin_addr;
+- port1 = ((struct sockaddr_in *)addr1)->sin_port;
+- port2 = ((struct sockaddr_in *)addr2)->sin_port;
+- plog(LLV_DEBUG, LOCATION, NULL, "cmpsaddr_magic: port1 == %d, port2 == %d\n", port1, port2);
+- if (!((port1 == IPSEC_PORT_ANY && port2 == ntohs(PORT_ISAKMP)) ||
+- (port2 == IPSEC_PORT_ANY && port1 == ntohs(PORT_ISAKMP)) ||
+- (port1 == port2))){
+- plog(LLV_DEBUG, LOCATION, NULL, "cmpsaddr_magic: ports mismatch\n");
+- return 1;
+- }
+- plog(LLV_DEBUG, LOCATION, NULL, "cmpsaddr_magic: ports matched\n");
+- if (memcmp(sa1, sa2, sizeof(struct in_addr)) != 0)
+- return 1;
+- break;
+-#ifdef INET6
+- case AF_INET6:
+- sa1 = (caddr_t)&((struct sockaddr_in6 *)addr1)->sin6_addr;
+- sa2 = (caddr_t)&((struct sockaddr_in6 *)addr2)->sin6_addr;
+- port1 = ((struct sockaddr_in6 *)addr1)->sin6_port;
+- port2 = ((struct sockaddr_in6 *)addr2)->sin6_port;
+- if (!((port1 == IPSEC_PORT_ANY && port2 == PORT_ISAKMP) ||
+- (port2 == IPSEC_PORT_ANY && port1 == PORT_ISAKMP) ||
+- (port1 == port2)))
+- return 1;
+- if (memcmp(sa1, sa2, sizeof(struct in6_addr)) != 0)
+- return 1;
+- if (((struct sockaddr_in6 *)addr1)->sin6_scope_id !=
+- ((struct sockaddr_in6 *)addr2)->sin6_scope_id)
+- return 1;
+- break;
+-#endif
+- default:
+- return 1;
+- }
+-
+- return 0;
+-}
+-
+-/*
+- * compare two sockaddr with strict match on port.
+- * OUT: 0: equal.
+- * 1: not equal.
+- */
+-int
+-cmpsaddrstrict(addr1, addr2)
+- const struct sockaddr *addr1;
+- const struct sockaddr *addr2;
+-{
+- caddr_t sa1, sa2;
+- u_short port1, port2;
+-
+- if (addr1 == 0 && addr2 == 0)
+- return 0;
+- if (addr1 == 0 || addr2 == 0)
+- return 1;
+-
+-#ifdef __linux__
+- if (addr1->sa_family != addr2->sa_family)
+- return 1;
+-#else
+- if (addr1->sa_len != addr2->sa_len
+- || addr1->sa_family != addr2->sa_family)
+- return 1;
+-
+-#endif /* __linux__ */
+-
+- switch (addr1->sa_family) {
+- case AF_INET:
+- sa1 = (caddr_t)&((struct sockaddr_in *)addr1)->sin_addr;
+- sa2 = (caddr_t)&((struct sockaddr_in *)addr2)->sin_addr;
+- port1 = ((struct sockaddr_in *)addr1)->sin_port;
+- port2 = ((struct sockaddr_in *)addr2)->sin_port;
+- if (port1 != port2)
+- return 1;
+- if (memcmp(sa1, sa2, sizeof(struct in_addr)) != 0)
+- return 1;
+- break;
+-#ifdef INET6
+- case AF_INET6:
+- sa1 = (caddr_t)&((struct sockaddr_in6 *)addr1)->sin6_addr;
+- sa2 = (caddr_t)&((struct sockaddr_in6 *)addr2)->sin6_addr;
+- port1 = ((struct sockaddr_in6 *)addr1)->sin6_port;
+- port2 = ((struct sockaddr_in6 *)addr2)->sin6_port;
+- if (port1 != port2)
+- return 1;
+- if (memcmp(sa1, sa2, sizeof(struct in6_addr)) != 0)
+- return 1;
+- if (((struct sockaddr_in6 *)addr1)->sin6_scope_id !=
+- ((struct sockaddr_in6 *)addr2)->sin6_scope_id)
+- return 1;
+- break;
+-#endif
+- default:
+- return 1;
+- }
+-
+- return 0;
++ return CMPSADDR_WOP_MATCH;
+ }
+
+ /* get local address against the destination. */
+@@ -1129,7 +931,7 @@ naddr_score(const struct netaddr *naddr, const struct sockaddr *saddr)
+ free(a2);
+ free(a3);
+ }
+- if (cmpsaddrwop(&sa, &naddr->sa.sa) == 0)
++ if (cmpsaddr(&sa, &naddr->sa.sa) == 0)
+ return naddr->prefix + port_score;
+
+ return -1;
+diff --git a/src/racoon/sockmisc.h b/src/racoon/sockmisc.h
+index fcc286f..0a58f44 100644
+--- a/src/racoon/sockmisc.h
++++ b/src/racoon/sockmisc.h
+@@ -54,16 +54,11 @@ struct netaddr {
+
+ extern const int niflags;
+
+-extern int cmpsaddrwop __P((const struct sockaddr *, const struct sockaddr *));
+-extern int cmpsaddrwild __P((const struct sockaddr *, const struct sockaddr *));
+-extern int cmpsaddrstrict __P((const struct sockaddr *, const struct sockaddr *));
+-extern int cmpsaddrmagic __P((const struct sockaddr *, const struct sockaddr *));
+-
+-#ifdef ENABLE_NATT
+-#define CMPSADDR(saddr1, saddr2) cmpsaddrstrict((saddr1), (saddr2))
+-#else
+-#define CMPSADDR(saddr1, saddr2) cmpsaddrwop((saddr1), (saddr2))
+-#endif
++#define CMPSADDR_MATCH 0
++#define CMPSADDR_WOP_MATCH 1
++#define CMPSADDR_MISMATCH 2
++
++extern int cmpsaddr __P((const struct sockaddr *, const struct sockaddr *));
+
+ extern struct sockaddr *getlocaladdr __P((struct sockaddr *));
+
+diff --git a/src/racoon/throttle.c b/src/racoon/throttle.c
+index 5ab62c3..64b566b 100644
+--- a/src/racoon/throttle.c
++++ b/src/racoon/throttle.c
+@@ -104,7 +104,7 @@ restart:
+ goto restart;
+ }
+
+- if (cmpsaddrwop(addr, (struct sockaddr *)&te->host) == 0) {
++ if (cmpsaddr(addr, (struct sockaddr *) &te->host) == 0) {
+ found = 1;
+ break;
+ }
diff --git a/main/ipsec-tools/50-reverse-connect.patch b/main/ipsec-tools/50-reverse-connect.patch
new file mode 100644
index 00000000000..c49eae347f3
--- /dev/null
+++ b/main/ipsec-tools/50-reverse-connect.patch
@@ -0,0 +1,207 @@
+When new ISAKMP is required, allow incoming reverse connection to take
+
+From: Timo Teras <timo.teras@iki.fi>
+
+over pending phase1:s. Useful when the other party is firewalled or NATted.
+---
+
+ src/racoon/admin.c | 12 ++++++++++++
+ src/racoon/evt.c | 13 +++++++++++++
+ src/racoon/evt.h | 3 +++
+ src/racoon/handler.c | 28 +++++++++++++++++++++-------
+ src/racoon/isakmp.c | 39 ++++++++++++++++++++++++++++++++++-----
+ 5 files changed, 83 insertions(+), 12 deletions(-)
+
+
+diff --git a/src/racoon/admin.c b/src/racoon/admin.c
+index b67e545..710c9bf 100644
+--- a/src/racoon/admin.c
++++ b/src/racoon/admin.c
+@@ -414,11 +414,23 @@ admin_process(so2, combuf)
+ struct sockaddr *dst;
+ struct sockaddr *src;
+ char *name = NULL;
++ char *loc, *rem;
+
+ ndx = (struct admin_com_indexes *) ((caddr_t)com + sizeof(*com));
+ src = (struct sockaddr *) &ndx->src;
+ dst = (struct sockaddr *) &ndx->dst;
+
++ loc = racoon_strdup(saddr2str(src));
++ rem = racoon_strdup(saddr2str(dst));
++ STRDUP_FATAL(loc);
++ STRDUP_FATAL(rem);
++
++ plog(LLV_INFO, LOCATION, NULL,
++ "admin establish-sa %x %s %s\n",
++ com->ac_proto, loc, rem);
++ racoon_free(loc);
++ racoon_free(rem);
++
+ if (com->ac_cmd == ADMIN_ESTABLISH_SA &&
+ com->ac_len > sizeof(*com) + sizeof(*ndx))
+ name = (char *) ((caddr_t) ndx + sizeof(*ndx));
+diff --git a/src/racoon/evt.c b/src/racoon/evt.c
+index 4ce1334..000c1f8 100644
+--- a/src/racoon/evt.c
++++ b/src/racoon/evt.c
+@@ -396,4 +396,17 @@ evt_list_cleanup(list)
+ evt_unsubscribe(LIST_FIRST(list));
+ }
+
++void
++evt_list_move(from, to)
++ struct evt_listener_list *from, *to;
++{
++ struct evt_listener *l;
++
++ while (!LIST_EMPTY(from)) {
++ l = LIST_FIRST(from);
++ LIST_REMOVE(l, ll_chain);
++ LIST_INSERT_HEAD(to, l, ll_chain);
++ }
++}
++
+ #endif /* ENABLE_ADMINPORT */
+diff --git a/src/racoon/evt.h b/src/racoon/evt.h
+index 0ce65bd..ba7fb57 100644
+--- a/src/racoon/evt.h
++++ b/src/racoon/evt.h
+@@ -124,6 +124,8 @@ void evt_phase2 __P((const struct ph2handle *ph2, int type, vchar_t *optdata));
+ vchar_t *evt_dump __P((void));
+
+ int evt_subscribe __P((struct evt_listener_list *list, int fd));
++void evt_list_move __P((struct evt_listener_list *from,
++ struct evt_listener_list *to));
+ void evt_list_init __P((struct evt_listener_list *list));
+ void evt_list_cleanup __P((struct evt_listener_list *list));
+
+@@ -136,6 +138,7 @@ void evt_list_cleanup __P((struct evt_listener_list *list));
+ #define evt_phase2(ph2, type, optdata) ;
+
+ #define evt_subscribe(eventlist, fd) ;
++#deifne evt_list_move(from, to) ;
+ #define evt_list_init(eventlist) ;
+ #define evt_list_cleanup(eventlist) ;
+ #define evt_get_fdmask(nfds, fdset) nfds
+diff --git a/src/racoon/handler.c b/src/racoon/handler.c
+index b33986f..9fd3817 100644
+--- a/src/racoon/handler.c
++++ b/src/racoon/handler.c
+@@ -269,26 +269,40 @@ migrate_ph12(old_iph1, new_iph1)
+ }
+
+ /*
+- * the iph1 is new, migrate all phase2s that belong to a dying or dead ph1
++ * the iph1 is new, migrate all phase2s that belong to a dying or dead ph1.
+ */
+ void migrate_dying_ph12(iph1)
+ struct ph1handle *iph1;
+ {
+- struct ph1handle *p;
++ struct ph1handle *p, *next;
+
+- LIST_FOREACH(p, &ph1tree, chain) {
++ for (p = LIST_FIRST(&ph1tree); p; p = next) {
++ next = LIST_NEXT(p, chain);
+ if (p == iph1)
+ continue;
+- if (p->status < PHASE1ST_DYING)
++
++ /* Same remote? */
++ if (cmpsaddr(iph1->local, p->local) > CMPSADDR_WOP_MATCH ||
++ cmpsaddr(iph1->remote, p->remote) > CMPSADDR_WOP_MATCH ||
++ iph1->rmconf != p->rmconf)
+ continue;
+
+- if (cmpsaddr(iph1->local, p->local) == 0
+- && cmpsaddr(iph1->remote, p->remote) == 0)
++ /* migrate phase2:s from expiring entries */
++ if (p->status >= PHASE1ST_DYING)
+ migrate_ph12(p, iph1);
++
++ /* and allow reverse connections to release
++ * pending connections that do not work due
++ * to firewall or nat */
++ if (iph1->side == RESPONDER && p->side == INITIATOR &&
++ p->status < PHASE1ST_MSG3RECEIVED) {
++ evt_list_move(&p->evt_listeners, &iph1->evt_listeners);
++ remph1(p);
++ delph1(p);
++ }
+ }
+ }
+
+-
+ /*
+ * dump isakmp-sa
+ */
+diff --git a/src/racoon/isakmp.c b/src/racoon/isakmp.c
+index 0de16d1..2dfda2f 100644
+--- a/src/racoon/isakmp.c
++++ b/src/racoon/isakmp.c
+@@ -2138,13 +2138,33 @@ isakmp_ph2delete(iph2)
+
+ remph2(iph2);
+ delph2(iph2);
+-
+- return;
+ }
+
+ /* %%%
+ * Interface between PF_KEYv2 and ISAKMP
+ */
++
++static void
++isakmp_chkph2there(p)
++ struct sched *p;
++{
++ struct ph2handle *iph2 = container_of(p, struct ph2handle, sce);
++ struct ph2handle *tmp;
++
++ /* Check if a similar phase2 appared meanwhile */
++ remph2(iph2);
++ tmp = getph2byid(iph2->src, iph2->dst, iph2->spid);
++ if (tmp == NULL) {
++ /* Nope, lets start this then */
++ insph2(iph2);
++ isakmp_chkph1there(iph2);
++ } else {
++ /* Yes, delete this initiation attempt as redundant */
++ evt_phase2(iph2, EVT_PHASE2_UP, NULL);
++ delph2(iph2);
++ }
++}
++
+ /*
+ * receive ACQUIRE from kernel, and begin either phase1 or phase2.
+ * if phase1 has been finished, begin phase2.
+@@ -2220,8 +2240,14 @@ isakmp_post_acquire(iph2)
+ /*NOTREACHED*/
+ }
+
+- /* found established ISAKMP-SA */
+- /* i.e. iph1->status == PHASE1ST_ESTABLISHED */
++ /* found established ISAKMP-SA, if this is a RESPONDER ISAKMP-SA
++ * add a small delay; this will make sure the initiator gets
++ * an first attempt at rekeying, and usually avoids duplicate ph2:s */
++ if (iph1->side == RESPONDER) {
++ iph2->retry_checkph1 = 1;
++ sched_schedule(&iph2->sce, 1, isakmp_chkph2there);
++ return 0;
++ }
+
+ /* found ISAKMP-SA. */
+ plog(LLV_DEBUG, LOCATION, NULL, "begin QUICK mode.\n");
+@@ -2388,7 +2414,10 @@ isakmp_chkph1there(iph2)
+ plog(LLV_DEBUG2, LOCATION, NULL, "dst: %s\n", saddr2str(iph2->dst));
+
+ /* begin quick mode */
+- (void)isakmp_ph2begin_i(iph1, iph2);
++ if (isakmp_ph2begin_i(iph1, iph2)) {
++ remph2(iph2);
++ delph2(iph2);
++ }
+ return;
+ }
+
diff --git a/main/ipsec-tools/60-debug-quick.patch b/main/ipsec-tools/60-debug-quick.patch
new file mode 100644
index 00000000000..a5c3346ee99
--- /dev/null
+++ b/main/ipsec-tools/60-debug-quick.patch
@@ -0,0 +1,211 @@
+debugging prints for quick mode errors
+
+From: Timo Teras <timo.teras@iki.fi>
+
+
+---
+
+ src/racoon/isakmp.c | 21 ++++++++++++++-------
+ src/racoon/isakmp_quick.c | 46 ++++++++++++++++++++++++++++++++++++++-------
+ 2 files changed, 53 insertions(+), 14 deletions(-)
+
+
+diff --git a/src/racoon/isakmp.c b/src/racoon/isakmp.c
+index 2dfda2f..87ce598 100644
+--- a/src/racoon/isakmp.c
++++ b/src/racoon/isakmp.c
+@@ -817,7 +817,8 @@ ph1_main(iph1, msg)
+
+ if (iph1->side == RESPONDER && iph1->status == PHASE1ST_START) {
+ plog(LLV_ERROR, LOCATION, iph1->remote,
+- "failed to pre-process packet.\n");
++ "failed to pre-process ph1 packet (side: %d, status %d).\n",
++ iph1->side, iph1->status);
+ return -1;
+ } else {
+ /* ignore the error and keep phase 1 handler */
+@@ -845,7 +846,8 @@ ph1_main(iph1, msg)
+ [iph1->side]
+ [iph1->status])(iph1, msg) != 0) {
+ plog(LLV_ERROR, LOCATION, iph1->remote,
+- "failed to process packet.\n");
++ "failed to process ph1 packet (side: %d, status: %d).\n",
++ iph1->side, iph1->status);
+ return -1;
+ }
+
+@@ -997,7 +999,8 @@ quick_main(iph2, msg)
+ [iph2->status])(iph2, msg);
+ if (error != 0) {
+ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
+- "failed to pre-process packet.\n");
++ "failed to pre-process ph2 packet (side: %d, status %d).\n",
++ iph2->side, iph2->status);
+ if (error == ISAKMP_INTERNAL_ERROR)
+ return 0;
+ isakmp_info_send_n1(iph2->ph1, error, NULL);
+@@ -1025,7 +1028,8 @@ quick_main(iph2, msg)
+ [iph2->side]
+ [iph2->status])(iph2, msg) != 0) {
+ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
+- "failed to process packet.\n");
++ "failed to process ph2 packet (side: %d, status: %d).\n",
++ iph2->side, iph2->status);
+ return -1;
+ }
+
+@@ -1233,7 +1237,8 @@ isakmp_ph1begin_r(msg, remote, local, etype)
+ [iph1->side]
+ [iph1->status])(iph1, msg) < 0) {
+ plog(LLV_ERROR, LOCATION, remote,
+- "failed to process packet.\n");
++ "failed to process ph1 packet (side: %d, status: %d).\n",
++ iph1->side, iph1->status);
+ remph1(iph1);
+ delph1(iph1);
+ return -1;
+@@ -1386,7 +1391,8 @@ isakmp_ph2begin_r(iph1, msg)
+ [iph2->status])(iph2, msg);
+ if (error != 0) {
+ plog(LLV_ERROR, LOCATION, iph1->remote,
+- "failed to pre-process packet.\n");
++ "failed to pre-process ph2 packet (side: %d, status: %d).\n",
++ iph2->side, iph2->status);
+ if (error != ISAKMP_INTERNAL_ERROR)
+ isakmp_info_send_n1(iph2->ph1, error, NULL);
+ /*
+@@ -1404,7 +1410,8 @@ isakmp_ph2begin_r(iph1, msg)
+ [iph2->side]
+ [iph2->status])(iph2, msg) < 0) {
+ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
+- "failed to process packet.\n");
++ "failed to process ph2 packet (side: %d, status: %d).\n",
++ iph2->side, iph2->status);
+ /* don't release handler */
+ return -1;
+ }
+diff --git a/src/racoon/isakmp_quick.c b/src/racoon/isakmp_quick.c
+index 46c84c1..2657407 100644
+--- a/src/racoon/isakmp_quick.c
++++ b/src/racoon/isakmp_quick.c
+@@ -495,18 +495,27 @@ quick_i2recv(iph2, msg0)
+ "isn't supported.\n");
+ break;
+ }
+- if (isakmp_p2ph(&iph2->sa_ret, pa->ptr) < 0)
++ if (isakmp_p2ph(&iph2->sa_ret, pa->ptr) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "duplicate ISAKMP_NPTYPE_SA.\n");
+ goto end;
++ }
+ break;
+
+ case ISAKMP_NPTYPE_NONCE:
+- if (isakmp_p2ph(&iph2->nonce_p, pa->ptr) < 0)
++ if (isakmp_p2ph(&iph2->nonce_p, pa->ptr) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "duplicate ISAKMP_NPTYPE_NONCE.\n");
+ goto end;
++ }
+ break;
+
+ case ISAKMP_NPTYPE_KE:
+- if (isakmp_p2ph(&iph2->dhpub_p, pa->ptr) < 0)
++ if (isakmp_p2ph(&iph2->dhpub_p, pa->ptr) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "duplicate ISAKMP_NPTYPE_KE.\n");
+ goto end;
++ }
+ break;
+
+ case ISAKMP_NPTYPE_ID:
+@@ -517,6 +526,8 @@ quick_i2recv(iph2, msg0)
+ if (isakmp_p2ph(&idcr, pa->ptr) < 0)
+ goto end;
+ } else {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "too many ISAKMP_NPTYPE_ID payloads.\n");
+ goto end;
+ }
+ break;
+@@ -557,6 +568,8 @@ quick_i2recv(iph2, msg0)
+ iph2->natoa_dst = daddr;
+ else {
+ racoon_free(daddr);
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "too many ISAKMP_NPTYPE_NATOA payloads.\n");
+ goto end;
+ }
+ }
+@@ -718,6 +731,8 @@ quick_i2recv(iph2, msg0)
+
+ /* validity check SA payload sent from responder */
+ if (ipsecdoi_checkph2proposal(iph2) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "proposal check failed.\n");
+ error = ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN;
+ goto end;
+ }
+@@ -1077,8 +1092,11 @@ quick_r1recv(iph2, msg0)
+ }
+ /* decrypt packet */
+ msg = oakley_do_decrypt(iph2->ph1, msg0, iph2->ivm->iv, iph2->ivm->ive);
+- if (msg == NULL)
++ if (msg == NULL) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "Packet decryption failed.\n");
+ goto end;
++ }
+
+ /* create buffer for using to validate HASH(1) */
+ /*
+@@ -1162,18 +1180,27 @@ quick_r1recv(iph2, msg0)
+ "Multi SAs isn't supported.\n");
+ goto end;
+ }
+- if (isakmp_p2ph(&iph2->sa, pa->ptr) < 0)
++ if (isakmp_p2ph(&iph2->sa, pa->ptr) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "duplicate ISAKMP_NPTYPE_SA.\n");
+ goto end;
++ }
+ break;
+
+ case ISAKMP_NPTYPE_NONCE:
+- if (isakmp_p2ph(&iph2->nonce_p, pa->ptr) < 0)
++ if (isakmp_p2ph(&iph2->nonce_p, pa->ptr) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "duplicate ISAKMP_NPTYPE_NONCE.\n");
+ goto end;
++ }
+ break;
+
+ case ISAKMP_NPTYPE_KE:
+- if (isakmp_p2ph(&iph2->dhpub_p, pa->ptr) < 0)
++ if (isakmp_p2ph(&iph2->dhpub_p, pa->ptr) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "duplicate ISAKMP_NPTYPE_KE.\n");
+ goto end;
++ }
+ break;
+
+ case ISAKMP_NPTYPE_ID:
+@@ -1241,6 +1268,9 @@ quick_r1recv(iph2, msg0)
+ iph2->natoa_src = daddr;
+ else {
+ racoon_free(daddr);
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "received too many NAT-OA payloads.\n");
++ error = ISAKMP_NTYPE_PAYLOAD_MALFORMED;
+ goto end;
+ }
+ }
+@@ -1333,6 +1363,8 @@ quick_r1recv(iph2, msg0)
+ case 0:
+ /* select single proposal or reject it. */
+ if (ipsecdoi_selectph2proposal(iph2) < 0) {
++ plog(LLV_ERROR, LOCATION, iph2->ph1->remote,
++ "no proposal chosen.\n");
+ error = ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN;
+ goto end;
+ }
diff --git a/main/ipsec-tools/APKBUILD b/main/ipsec-tools/APKBUILD
new file mode 100644
index 00000000000..b947b9b6956
--- /dev/null
+++ b/main/ipsec-tools/APKBUILD
@@ -0,0 +1,59 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ipsec-tools
+pkgver=0.8_alpha20090422
+_myver=0.8-alpha20090422
+pkgrel=0
+pkgdesc="User-space IPsec tools for various IPsec implementations"
+url="http://ipsec-tools.sourceforge.net/"
+license="BSD"
+depends="openssl uclibc"
+makedepends="openssl-dev bison flex"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$_myver.tar.gz
+ racoon.initd
+ racoon.confd
+ 00-verify-cert-leak.patch
+ 20-natoa-fix.patch
+ 30-natt-ports-cleanup.patch
+ 40-cmpsaddr-cleanup.patch
+ 50-reverse-connect.patch
+ 60-debug-quick.patch
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$_myver"
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 -i $i || return 1
+ done
+ sed -i 's:-Werror::g' configure
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var/lib \
+ --with-kernel-headers=/usr/include \
+ --disable-security-context \
+ --enable-adminport \
+ --enable-dpd \
+ --enable-frag \
+ --enable-hybrid \
+ --enable-ipv6 \
+ --enable-natt
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -D -m755 ../racoon.initd "$pkgdir"/etc/init.d/racoon
+ install -D -m644 ../racoon.confd "$pkgdir"/etc/conf.d/racoon
+}
+
+md5sums="8327401b5d1aa91e9c554d2cc536f823 ipsec-tools-0.8-alpha20090422.tar.gz
+16d66458442750e6401fa459e93172b7 racoon.initd
+788e3de82c1c6532dab0dc0c19c1bf40 racoon.confd
+e0abf570c29519e8e36406dfc3bbe3c8 00-verify-cert-leak.patch
+2adb8796c75f62811b08c8370c75312c 20-natoa-fix.patch
+17b3f05426537afa1e94947c39b10163 30-natt-ports-cleanup.patch
+5fcaf5a01340132d4bfe55997bc5c60b 40-cmpsaddr-cleanup.patch
+91eb6da2726c4ed83df990f6908a7553 50-reverse-connect.patch
+baa13d7f0f48955c792f7fcd42a8587a 60-debug-quick.patch"
diff --git a/main/ipsec-tools/racoon.confd b/main/ipsec-tools/racoon.confd
new file mode 100644
index 00000000000..66f8ed76744
--- /dev/null
+++ b/main/ipsec-tools/racoon.confd
@@ -0,0 +1,19 @@
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-firewall/ipsec-tools/files/racoon.conf.d,v 1.3 2004/07/14 23:29:57 agriffis Exp $
+
+# Config file for /etc/init.d/racoon
+
+# See the manual pages for racoon or run `racoon --help`
+# for valid command-line options
+
+RACOON_OPTS="-4"
+
+RACOON_CONF="/etc/racoon/racoon.conf"
+RACOON_PSK_FILE="/etc/racoon/psk.txt"
+SETKEY_CONF="/etc/ipsec.conf"
+
+# Comment or remove the following if you don't want the policy tables
+# to be flushed when racoon is stopped.
+
+RACOON_RESET_TABLES="true"
diff --git a/main/ipsec-tools/racoon.initd b/main/ipsec-tools/racoon.initd
new file mode 100644
index 00000000000..16fdec7e3a3
--- /dev/null
+++ b/main/ipsec-tools/racoon.initd
@@ -0,0 +1,58 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ before netmount
+ use net
+}
+
+checkconfig() {
+ if [ ! -e ${SETKEY_CONF} ] ; then
+ eerror "You need to configure setkey before starting racoon."
+ return 1
+ fi
+ if [ ! -e ${RACOON_CONF} ] ; then
+ eerror "You need a configuration file to start racoon."
+ return 1
+ fi
+ if [ ! -z ${RACOON_PSK_FILE} ] ; then
+ if [ ! -f ${RACOON_PSK_FILE} ] ; then
+ eerror "PSK file not found as specified."
+ eerror "Set RACOON_PSK_FILE in /etc/conf.d/racoon."
+ return 1
+ fi
+ case "`ls -Lldn ${RACOON_PSK_FILE}`" in
+ -r--------*)
+ ;;
+ *)
+ eerror "Your defined PSK file should be mode 400 for security!"
+ return 1
+ ;;
+ esac
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ einfo "Loading ipsec policies from ${SETKEY_CONF}."
+ /usr/sbin/setkey -f ${SETKEY_CONF}
+ if [ $? -eq 1 ] ; then
+ eerror "Error while loading ipsec policies"
+ fi
+ ebegin "Starting racoon"
+ start-stop-daemon -S -x /usr/sbin/racoon -- -f ${RACOON_CONF} ${RACOON_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping racoon"
+ start-stop-daemon -K -p /var/run/racoon.pid
+ eend $?
+ if [ -n "${RACOON_RESET_TABLES}" ]; then
+ ebegin "Flushing policy entries"
+ /usr/sbin/setkey -F
+ /usr/sbin/setkey -FP
+ eend $?
+ fi
+}
diff --git a/main/iptraf/APKBUILD b/main/iptraf/APKBUILD
new file mode 100644
index 00000000000..95e9de3f35b
--- /dev/null
+++ b/main/iptraf/APKBUILD
@@ -0,0 +1,37 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=iptraf
+pkgver=3.0.0
+pkgrel=0
+pkgdesc="IP Network Monitoring Software"
+url="http://iptraf.seoul.org"
+license="GPL"
+depends="uclibc ncurses"
+makedepends="ncurses-dev"
+install=
+subpackages="$pkgname-doc"
+source="ftp://iptraf.seul.org/pub/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver/src"
+
+ sed -i -e s:/var/local/iptraf:/var/lib/iptraf: \
+ -e s:/usr/local/bin:/usr/sbin: dirs.h
+ make CFLAGS="$CFLAGS" DEBUG="" TARGET="/usr/sbin" \
+ WORKDIR="/var/lib/iptraf" || return 1
+
+ for sbin in iptraf rvnamed; do
+ /bin/install -D -m755 $sbin $pkgdir/usr/sbin/$sbin
+ done
+
+ cd ../Documentation
+ for man in *.8; do
+ /bin/install -D -m644 $man $pkgdir/usr/share/man/man8/$man
+ done
+
+ for dir in lib log run; do
+ /bin/mkdir -p $pkgdir/var/$dir/iptraf
+ done
+}
+
+md5sums="377371c28ee3c21a76f7024920649ea8 iptraf-3.0.0.tar.gz"
diff --git a/main/iputils/APKBUILD b/main/iputils/APKBUILD
new file mode 100644
index 00000000000..02face483a5
--- /dev/null
+++ b/main/iputils/APKBUILD
@@ -0,0 +1,28 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=iputils
+pkgver=20071127
+pkgrel=1
+pkgdesc="IP Configuration Utilities (and Ping)"
+url="http://www.linuxfoundation.org/en/Net:Iputils"
+license="GPL"
+install=$pkgname.post-install
+depends="uclibc"
+source="http://www.skbuff.net/$pkgname/$pkgname-s$pkgver.tar.bz2
+ $pkgname-20070202-no-open-max.patch
+ $install"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-s$pkgver
+ patch -Np1 -i ../iputils-20070202-no-open-max.patch || return 1
+ make KERNEL_INCLUDE=/usr/include || return 1
+ for i in arping clockdiff rarpd rdisc tftpd tracepath tracepath6; do
+ install -D -m755 $i "$pkgdir"/usr/sbin/$i
+ done
+ for i in ping ping6 traceroute6; do
+ install -D -m4755 $i "$pkgdir"/bin/$i
+ done
+}
+md5sums="12245e9927d60ff5cf4a99d265bcb7d3 iputils-s20071127.tar.bz2
+a2cbc0174dd883f68297aa7f3e7c4f5c iputils-20070202-no-open-max.patch
+b84506d253e04db3c5af9016fead45a3 iputils.post-install"
diff --git a/main/iputils/iputils-20070202-no-open-max.patch b/main/iputils/iputils-20070202-no-open-max.patch
new file mode 100644
index 00000000000..5013ba4fdc0
--- /dev/null
+++ b/main/iputils/iputils-20070202-no-open-max.patch
@@ -0,0 +1,16 @@
+the OPEN_MAX define has been removed in newer kernel headers so use the
+proper method of getting the value dynamically
+
+http://bugs.gentoo.org/195861
+
+--- a/rdisc.c
++++ b/rdisc.c
+@@ -247,7 +247,7 @@ void do_fork(void)
+ if ((pid=fork()) != 0)
+ exit(0);
+
+- for (t = 0; t < OPEN_MAX; t++)
++ for (t = 0; t < sysconf(_SC_OPEN_MAX); t++)
+ if (t != s)
+ close(t);
+
diff --git a/main/iputils/iputils.post-install b/main/iputils/iputils.post-install
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/iputils/iputils.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/irssi/APKBUILD b/main/irssi/APKBUILD
new file mode 100644
index 00000000000..bdb3c16c929
--- /dev/null
+++ b/main/irssi/APKBUILD
@@ -0,0 +1,34 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=irssi
+pkgver=0.8.13
+#_pkgver=0.8.13-rc1
+pkgrel=0
+pkgdesc="A modular textUI IRC client with IPv6 support"
+url="http://irssi.org/"
+license='GPL'
+depends="glib ncurses ncurses-terminfo openssl"
+makedepends="glib-dev openssl-dev ncurses-dev perl-dev pkgconfig g++"
+source="http://irssi.org/files/irssi-${pkgver}.tar.bz2"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-perl"
+
+build() {
+ cd "$srcdir/$pkgname-${pkgver}"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --with-perl=module
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+perl() {
+ depends="$pkgname perl"
+ mkdir -p "$subpkgdir"/usr/share/irssi
+ mv "$pkgdir"/usr/share/irssi/scripts "$subpkgdir"/usr/share/irssi/
+ mkdir -p "$subpkgdir"/usr/lib/irssi
+ mv "$pkgdir"/usr/lib/irssi/modules "$subpkgdir"/usr/lib/irssi/
+ mv "$pkgdir"/usr/lib/perl5 "$subpkgdir"/usr/lib/
+}
+
+md5sums="0d6fc2203832b514eff014fffd574664 irssi-0.8.13.tar.bz2"
diff --git a/main/jpeg/APKBUILD b/main/jpeg/APKBUILD
new file mode 100644
index 00000000000..c795091a4d2
--- /dev/null
+++ b/main/jpeg/APKBUILD
@@ -0,0 +1,35 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=jpeg
+pkgver=7
+pkgrel=0
+pkgdesc="JPEG image tools"
+url="http://www.ijg.org/"
+license="AS-IS"
+depends=
+makedepends=
+install=
+subpackages="$pkgname-doc $pkgname-dev libjpeg"
+source="http://www.ijg.org/files/jpegsrc.v${pkgver}.tar.gz"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-shared
+ make || return 1
+ make -j1 install DESTDIR="$pkgdir"
+ install -Dm644 jpegint.h "$pkgdir"/usr/include/jpegint.h
+}
+
+libjpeg() {
+ pkgdesc="JPEG image library"
+ install -d "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libjpeg* "$subpkgdir"/usr/lib/
+}
+
+
+md5sums="382ef33b339c299b56baf1296cda9785 jpegsrc.v7.tar.gz"
diff --git a/main/json4lua/APKBUILD b/main/json4lua/APKBUILD
new file mode 100644
index 00000000000..bceb0ca836a
--- /dev/null
+++ b/main/json4lua/APKBUILD
@@ -0,0 +1,15 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=json4lua
+pkgver=0.9.20
+pkgrel=0
+pkgdesc="JSON encoding / decoding module for Lua"
+url="http://json.luaforge.net/"
+license="GPL-2"
+depends="lua"
+source="http://luaforge.net/frs/download.php/1375/JSON4Lua-$pkgver.zip"
+
+build() {
+ install -D "$srcdir"/json/json.lua "$pkgdir"/usr/share/lua/5.1/json.lua
+}
+
+md5sums="0a2071a24d7752f52d5cc9cac8800743 JSON4Lua-0.9.20.zip"
diff --git a/main/ksymoops/APKBUILD b/main/ksymoops/APKBUILD
new file mode 100644
index 00000000000..d8cc04fdf7d
--- /dev/null
+++ b/main/ksymoops/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ksymoops
+pkgver=2.4.11
+pkgrel=0
+pkgdesc="A Linux kernel Oops file troubleshooting tool"
+url="ftp://ftp.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4"
+license="GPL-2"
+depends="uclibc"
+makedepends="!gettext !libiconv"
+source="ftp://ftp.kernel.org/pub/linux/utils/kernel/$pkgname/v2.4/$pkgname-$pkgver.tar.bz2
+ $pkgname-2.4.11-build.patch
+ "
+subpackages="$pkgname-doc"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ patch -p1 < ../$pkgname-2.4.11-build.patch || return 1
+ make || return 1
+ make install \
+ INSTALL_PREFIX="$pkgdir"/usr \
+ INSTALL_MANDIR="$pkgdir"/usr/share/man
+}
+md5sums="4a8249e182a5dbc75e566d162e9f3314 ksymoops-2.4.11.tar.bz2
+bad82d31c7d15431fc022be237791d59 ksymoops-2.4.11-build.patch"
diff --git a/main/less/APKBUILD b/main/less/APKBUILD
new file mode 100644
index 00000000000..0567914a5e8
--- /dev/null
+++ b/main/less/APKBUILD
@@ -0,0 +1,28 @@
+# Contributor: Cameron Banta <cbanta@gmail.com>
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=less
+pkgver=429
+pkgrel=0
+pkgdesc="File pager"
+url="http://www.greenwoodsoftware.com/less/"
+license="GPL"
+depends="uclibc ncurses"
+makedepends="ncurses-dev"
+install="$pkgname.post-deinstall"
+subpackages="$pkgname-doc"
+source="http://www.greenwoodsoftware.com/$pkgname/$pkgname-$pkgver.tar.gz
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="206f2f13b9b0a35e45df660fcb6af31d less-429.tar.gz
+b84506d253e04db3c5af9016fead45a3 less.post-deinstall"
diff --git a/main/less/less.post-deinstall b/main/less/less.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/less/less.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/lftp/APKBUILD b/main/lftp/APKBUILD
new file mode 100644
index 00000000000..239573c1212
--- /dev/null
+++ b/main/lftp/APKBUILD
@@ -0,0 +1,31 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=lftp
+pkgver=3.7.14
+pkgrel=1
+pkgdesc="LFTP is sophisticated ftp/http client"
+url="http://lftp.yar.ru/"
+license="GPL"
+depends=
+makedepends="openssl-dev uclibc++-dev readline-dev ncurses-dev gettext-dev"
+subpackages="$pkgname-doc"
+source="http://ftp.yars.free.net/pub/source/lftp/lftp-${pkgver}.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ export CXX=g++-uc
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/lftp \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-modules \
+ --disable-nls \
+ --with-openssl
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+}
+
+md5sums="723d372833d6a94c15cc78cc98565517 lftp-3.7.14.tar.bz2"
diff --git a/main/lha/APKBUILD b/main/lha/APKBUILD
new file mode 100644
index 00000000000..705e51e0773
--- /dev/null
+++ b/main/lha/APKBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=lha
+pkgver=1.14i
+pkgrel=0
+pkgdesc="Compression and archive utility for LH-7 format archives"
+url="http://www.infor.kanazawa-it.ac.jp/~ishii/lhaunix/"
+license="custom"
+subpackages="$pkgname-doc"
+depends="uclibc"
+makedepends=""
+install=
+source="http://osdn.dl.sourceforge.jp/lha/22231/$pkgname-$pkgver-ac20050924p1.tar.gz"
+
+build ()
+{
+ cd $srcdir/$pkgname-$pkgver-ac20050924p1
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make "DESTDIR=$pkgdir" install
+ #install -D -m755 $srcdir/lha $pkgdir/usr/bin/lha
+}
+
+md5sums="9f52430410928ba4390a73a41a36d56f lha-1.14i-ac20050924p1.tar.gz"
diff --git a/main/libao/APKBUILD b/main/libao/APKBUILD
new file mode 100644
index 00000000000..a82ba465879
--- /dev/null
+++ b/main/libao/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libao
+pkgver=0.8.8
+pkgrel=1
+pkgdesc="Cross-platform audio output library and plugins"
+url="http://www.xiph.org/ao"
+license="GPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc alsa-lib"
+makedepends="alsa-lib-dev"
+source="http://downloads.xiph.org/releases/ao/$pkgname-$pkgver.tar.gz"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --enable-alsa09 \
+ --disable-esd \
+ --disable-arts
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="b92cba3cbcf1ee9bc221118a85d23dcd libao-0.8.8.tar.gz"
diff --git a/main/libart-lgpl/APKBUILD b/main/libart-lgpl/APKBUILD
new file mode 100644
index 00000000000..3ac38769a06
--- /dev/null
+++ b/main/libart-lgpl/APKBUILD
@@ -0,0 +1,19 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libart-lgpl
+pkgver=2.3.20
+pkgrel=0
+pkgdesc="A library for high-performance 2D graphics"
+url="http://www.levien.com/libart/"
+license="LGPL"
+depends="uclibc"
+subpackages="$pkgname-dev"
+source="http://ftp.gnome.org/pub/GNOME/sources/libart_lgpl/2.3/libart_lgpl-$pkgver.tar.bz2
+ "
+
+build() {
+ cd "$srcdir"/libart_lgpl-$pkgver
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="d0ce67f2ebcef1e51a83136c69242a73 libart_lgpl-2.3.20.tar.bz2"
diff --git a/main/libassuan/APKBUILD b/main/libassuan/APKBUILD
new file mode 100644
index 00000000000..2b2498c49ef
--- /dev/null
+++ b/main/libassuan/APKBUILD
@@ -0,0 +1,18 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libassuan
+pkgver=1.0.5
+pkgrel=0
+pkgdesc="Libassuan is the IPC library used by some GnuPG related software"
+url="ftp://ftp.gnupg.org/gcrypt/libgcrypt"
+license="GPL"
+makedepends="pth-dev"
+subpackages="$pkgname-doc"
+source="ftp://ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="c2db0974fcce4401f48f3fa41c4edc5a libassuan-1.0.5.tar.bz2"
diff --git a/main/libcap/APKBUILD b/main/libcap/APKBUILD
new file mode 100644
index 00000000000..731729c03a0
--- /dev/null
+++ b/main/libcap/APKBUILD
@@ -0,0 +1,23 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libcap
+pkgver=2.16
+pkgrel=1
+pkgdesc="POSIX 1003.1e capabilities"
+license="GPL"
+url="http://www.friedhoff.org/posixfilecaps.html"
+depends=
+makedepends="perl"
+source="http://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/$pkgname-$pkgver.tar.gz
+ include-order.patch
+ "
+subpackages="$pkgname-doc $pkgname-dev"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ patch -p1 < ../include-order.patch || return 1
+
+ make lib=/lib prefix=/usr LIBATTR=no DESTDIR="$pkgdir" install
+}
+md5sums="9e075fda242c4070ba76407064c13302 libcap-2.16.tar.gz
+db5c78e0ab579bb6723fff5ebb2fd530 include-order.patch"
diff --git a/main/libcap/include-order.patch b/main/libcap/include-order.patch
new file mode 100644
index 00000000000..88c5fcc6c83
--- /dev/null
+++ b/main/libcap/include-order.patch
@@ -0,0 +1,16 @@
+diff -ur a/progs/capsh.c b/progs/capsh.c
+--- a/progs/capsh.c 2009-07-24 07:14:03.000000000 +0000
++++ b/progs/capsh.c 2009-07-24 07:14:19.000000000 +0000
+@@ -12,11 +12,11 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <sys/wait.h>
+ #include <sys/prctl.h>
+ #include <sys/capability.h>
+ #include <unistd.h>
+ #include <errno.h>
+-#include <sys/wait.h>
+
+ /* prctl based API for altering character of current process */
+ #define PR_GET_KEEPCAPS 7
diff --git a/main/libconfig/APKBUILD b/main/libconfig/APKBUILD
new file mode 100644
index 00000000000..13185722c9b
--- /dev/null
+++ b/main/libconfig/APKBUILD
@@ -0,0 +1,23 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libconfig
+pkgver=1.3.2
+pkgrel=0
+pkgdesc="a simple library for manipulating structured configuration files"
+url="http://www.hyperrealm.com/libconfig/"
+license='LGPL'
+depends="uclibc"
+makedepends="g++"
+source="http://www.hyperrealm.com/$pkgname/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc $pkgname-dev"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --disable-cxx
+ make || return 1
+ make -j1 DESTDIR="$pkgdir/" install
+}
+
+md5sums="094a82afd382aa2305c6cc3c06025c2d libconfig-1.3.2.tar.gz"
diff --git a/main/libexif/APKBUILD b/main/libexif/APKBUILD
new file mode 100644
index 00000000000..c9f244b09d6
--- /dev/null
+++ b/main/libexif/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libexif
+pkgver=0.6.17
+pkgrel=0
+pkgdesc="A library to parse an EXIF file and read the data from those tags"
+url="http://sourceforge.net/projects/libexif"
+license="LGPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+makedepends=
+source="http://downloads.sf.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="f7cf4e623a48c9a3b13f7f95f0a41015 libexif-0.6.17.tar.bz2"
diff --git a/main/libgcrypt/APKBUILD b/main/libgcrypt/APKBUILD
new file mode 100644
index 00000000000..efe95c1abf3
--- /dev/null
+++ b/main/libgcrypt/APKBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libgcrypt
+pkgver=1.4.4
+pkgrel=1
+pkgdesc="general purpose crypto library based on the code used in GnuPG"
+url="http://www.gnupg.org"
+license="LGPL"
+depends=
+makedepends="libgpg-error-dev texinfo"
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+depends_dev="libgpg-error-dev"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ ./configure --build=${CHOST:-i486-alpine-linux-uclibc} \
+ --prefix=/usr \
+ --enable-padlock-support \
+ --disable-static
+
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install || return 1
+ rm -f ${pkgdir}/usr/share/info/dir
+}
+md5sums="34105aa927e23c217741966496b97e67 libgcrypt-1.4.4.tar.bz2"
diff --git a/main/libgcrypt/nocxx.patch b/main/libgcrypt/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/libgcrypt/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/libgpg-error/APKBUILD b/main/libgpg-error/APKBUILD
new file mode 100644
index 00000000000..24cac436068
--- /dev/null
+++ b/main/libgpg-error/APKBUILD
@@ -0,0 +1,32 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libgpg-error
+pkgver=1.7
+pkgrel=0
+pkgdesc="Support library for libgcrypt"
+url="http://www.gnupg.org"
+license="LGPL"
+depends="uclibc"
+subpackages="$pkgname-dev $pkgname-lisp"
+source="ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.bz2
+ nocxx.patch
+ "
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ msg "Punting useless check for cpp..."
+ patch configure < ../nocxx.patch || return 1
+
+ ./configure --prefix=/usr \
+ --disable-nls
+
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+lisp() {
+ mkdir -p "$subpkgdir"/usr/
+ mv "$pkgdir"/usr/share "$subpkgdir"/usr/share/
+}
+
+md5sums="62c0d09d1e76c5b6da8fff92314c4665 libgpg-error-1.7.tar.bz2
+28513788ba4d556ccd538867dc6205ab nocxx.patch"
diff --git a/main/libgpg-error/nocxx.patch b/main/libgpg-error/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/libgpg-error/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/libiconv/APKBUILD b/main/libiconv/APKBUILD
new file mode 100644
index 00000000000..6cd441ca6e1
--- /dev/null
+++ b/main/libiconv/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=libiconv
+pkgver=1.12
+pkgrel=0
+pkgdesc="GNU charset conversion library for libc which doesn't implement it"
+url="http://www.gnu.org/software/libiconv"
+license='LGPL'
+depends="uclibc"
+source="http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz"
+subpackages="$pkgname-doc $pkgname-dev"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+}
+
+md5sums="c2be282595751535a618ae0edeb8f648 libiconv-1.12.tar.gz"
diff --git a/main/libid3tag/APKBUILD b/main/libid3tag/APKBUILD
new file mode 100644
index 00000000000..9410e353c63
--- /dev/null
+++ b/main/libid3tag/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=libid3tag
+pkgver=0.15.1b
+pkgrel=0
+pkgdesc="id3 tagger for mp3"
+url="http://www.underbit.com/products/mad/"
+license="GPL"
+depends="zlib"
+makedepends="uclibc++-dev zlib-dev"
+install=
+subpackages="$pkgname-dev"
+source="ftp://ftp.mars.org/pub/mpeg/libid3tag-0.15.1b.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="e5808ad997ba32c498803822078748c3 libid3tag-0.15.1b.tar.gz"
diff --git a/main/libidn/APKBUILD b/main/libidn/APKBUILD
new file mode 100644
index 00000000000..afcb59c788a
--- /dev/null
+++ b/main/libidn/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libidn
+pkgver=1.15
+pkgrel=0
+pkgdesc="An encode and decode library for internationalized domain names"
+url="http://www.gnu.org/software/libidn/"
+license="GPL"
+depends=
+makedepends=""
+install=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://ftp.gnu.org/gnu/libidn/$pkgname-$pkgver.tar.gz"
+
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="482a25b7b223e52f967fafd284a1a992 libidn-1.15.tar.gz"
diff --git a/main/libksba/APKBUILD b/main/libksba/APKBUILD
new file mode 100644
index 00000000000..47049370023
--- /dev/null
+++ b/main/libksba/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libksba
+pkgver=1.0.3
+pkgrel=0
+pkgdesc="Libksba is a CMS and X.509 access library"
+url="ftp://ftp.gnupg.org/gcrypt/alpha/libksba"
+license="GPL"
+depends="libgpg-error uclibc"
+makedepends="libgpg-error-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR=$startdir/pkg install
+}
+md5sums="91682491186d4ed43fff351aab2f5aad libksba-1.0.3.tar.bz2"
diff --git a/main/libmcrypt/APKBUILD b/main/libmcrypt/APKBUILD
new file mode 100644
index 00000000000..905d880f6f7
--- /dev/null
+++ b/main/libmcrypt/APKBUILD
@@ -0,0 +1,24 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=libmcrypt
+pkgver=2.5.8
+pkgrel=0
+pkgdesc="A library which provides a uniform interface to several symmetric encryption algorithms"
+url="http://mcrypt.sourceforge.net/"
+license="GPL"
+depends="uclibc"
+makedepends="libtool uclibc++-dev"
+install=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://downloads.sourceforge.net/mcrypt/${pkgname}-${pkgver}.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="c4f491dd411a09e9de3b8702ea6f73eb libmcrypt-2.5.8.tar.bz2"
diff --git a/main/libnet/APKBUILD b/main/libnet/APKBUILD
new file mode 100644
index 00000000000..e756acc0eca
--- /dev/null
+++ b/main/libnet/APKBUILD
@@ -0,0 +1,36 @@
+# Contributor: Mika Havela <mika.havela@gmail.com>
+# Maintainer: Your Name <youremail@domain.com>
+pkgname=libnet
+pkgver=1.1.2.1
+pkgrel=0
+pkgdesc="A generic networking API that provides access to several protocols."
+url="http://www.packetfactory.net/libnet/"
+license="BSD"
+depends="uclibc"
+makedepends="autoconf automake libtool"
+subpackages="$pkgname-dev"
+source="http://www.packetfactory.net/libnet/dist/$pkgname-$pkgver.tar.gz
+ libnet-1.1.2.1-autotools.patch
+ libnet-1.1.2.1-fix-chksum.patch
+ "
+
+build() {
+ local i
+ cd "$srcdir/$pkgname"
+ for i in ../*.patch; do
+ msg "Applyting $i"
+ patch -p1 < $i || return 1
+ done
+
+ aclocal
+ libtoolize --force || return 1
+ autoconf && automake || return 1
+
+ ./configure --prefix=/usr
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="be845c41170d72c7db524f3411b50256 libnet-1.1.2.1.tar.gz
+7e928170600bea8ed4a0d079b83c80ac libnet-1.1.2.1-autotools.patch
+668189bf87cda8daeaf250146bd88331 libnet-1.1.2.1-fix-chksum.patch"
diff --git a/main/libnet/libnet-1.1.2.1-autotools.patch b/main/libnet/libnet-1.1.2.1-autotools.patch
new file mode 100644
index 00000000000..0f4c65094db
--- /dev/null
+++ b/main/libnet/libnet-1.1.2.1-autotools.patch
@@ -0,0 +1,79 @@
+Patch ripped from Debian. Add support for building a shared
+libnet library (for PIC loving). Also fixes typo for installing
+the libnet-config script.
+
+http://bugs.gentoo.org/show_bug.cgi?id=82926
+
+--- libnet-1.1.2.1.orig/src/Makefile.am
++++ libnet-1.1.2.1/src/Makefile.am
+@@ -8,9 +8,9 @@
+
+ include $(top_srcdir)/Makefile.am.common
+
+-lib_LIBRARIES = libnet.a
++lib_LTLIBRARIES = libnet.la
+
+-libnet_a_SOURCES = libnet_asn1.c \
++libnet_la_SOURCES = libnet_asn1.c \
+ libnet_build_802.1q.c \
+ libnet_build_802.1x.c \
+ libnet_build_802.2.c \
+@@ -57,15 +57,20 @@
+ libnet_version.c \
+ libnet_write.c
+
+-EXTRA_libnet_a_SOURCES = libnet_link_bpf.c \
+- libnet_link_dlpi.c \
+- libnet_link_linux.c \
+- libnet_link_nit.c \
+- libnet_link_none.c \
+- libnet_link_pf.c \
+- libnet_link_snit.c \
+- libnet_link_snoop.c \
+- libnet_link_win32.c
+-
+-libnet_a_LIBADD = @LIBOBJS@
++libnet_la_LIBADD = @LTLIBOBJS@
+
++# Here are a set of rules to help you update your library version
++# information:
++#
++# 1. If the library source code has changed at all since the last
++# update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
++#
++# 2. If any interfaces have been added, removed, or changed since the
++# last update, increment CURRENT, and set REVISION to 0.
++#
++# 3. If any interfaces have been added since the last public release,
++# then increment AGE.
++#
++# 4. If any interfaces have been removed since the last public release,
++# then set AGE to 0.
++libnet_la_LDFLAGS = -version-info 4:0:3 # CURRENT[:REVISION[:AGE]]
+--- libnet-1.1.2.1.orig/configure.in
++++ libnet-1.1.2.1/configure.in
+@@ -21,7 +21,7 @@
+ dnl
+ AC_PROG_CC
+ AC_PROG_INSTALL
+-AC_PROG_RANLIB
++AC_PROG_LIBTOOL
+
+ AC_CHECK_HEADERS(sys/sockio.h)
+
+--- libnet-1.1.2.1.orig/Makefile.am
++++ libnet-1.1.2.1/Makefile.am
+@@ -12,4 +12,4 @@
+
+ EXTRA_DIST = Makefile.am.common
+
+-bin_scripts = libnet-config
++bin_SCRIPTS = libnet-config
+--- libnet-1.1.2.1.orig/sample/Makefile.am
++++ libnet-1.1.2.1/sample/Makefile.am
+@@ -60,4 +60,4 @@
+ ip_link_SOURCES = ip_link.c
+ sebek_SOURCES = sebek.c
+
+-LDADD = $(top_srcdir)/src/libnet.a
++LDADD = $(top_srcdir)/src/libnet.la
diff --git a/main/libnet/libnet-1.1.2.1-fix-chksum.patch b/main/libnet/libnet-1.1.2.1-fix-chksum.patch
new file mode 100644
index 00000000000..e6f9bbc6dd2
--- /dev/null
+++ b/main/libnet/libnet-1.1.2.1-fix-chksum.patch
@@ -0,0 +1,27 @@
+Fix a bug in chksum calculation for odd sized UDP packets.
+
+http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=284729
+
+--- libnet-1.1.2.1/src/libnet_checksum.c
++++ libnet-1.1.2.1/src/libnet_checksum.c
+@@ -42,8 +42,10 @@
+ libnet_in_cksum(u_int16_t *addr, int len)
+ {
+ int sum;
++ u_int16_t last_byte;
+
+ sum = 0;
++ last_byte = 0;
+
+ while (len > 1)
+ {
+@@ -52,7 +54,8 @@
+ }
+ if (len == 1)
+ {
+- sum += *(u_int16_t *)addr;
++ *(u_int8_t*)&last_byte = *(u_int8_t*)addr;
++ sum += last_byte;
+ }
+
+ return (sum);
diff --git a/main/libnetfilter_conntrack/APKBUILD b/main/libnetfilter_conntrack/APKBUILD
new file mode 100644
index 00000000000..7f3aee35a97
--- /dev/null
+++ b/main/libnetfilter_conntrack/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libnetfilter_conntrack
+pkgver=0.0.99
+pkgrel=0
+pkgdesc="programming interface (API) to the in-kernel connection tracking state table"
+url="http://www.netfilter.org/projects/libnetfilter_conntrack/"
+license="GPL-2"
+depends="uclibc libnfnetlink"
+makedepends="pkgconfig libnfnetlink-dev"
+subpackages="$pkgname-dev"
+source="http://www.netfilter.org/projects/$pkgname/files/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="960c3d347d7f4e3fe7437aa198f36e6e libnetfilter_conntrack-0.0.99.tar.bz2"
diff --git a/main/libnfnetlink/APKBUILD b/main/libnfnetlink/APKBUILD
new file mode 100644
index 00000000000..63519aec0ca
--- /dev/null
+++ b/main/libnfnetlink/APKBUILD
@@ -0,0 +1,24 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libnfnetlink
+pkgver=0.0.41
+pkgrel=0
+pkgdesc="low-level library for netfilter related kernel/userspace communication"
+url="http://www.netfilter.org/projects/libnfnetlink/"
+license="GPL-2"
+depends="uclibc"
+makedepends=""
+subpackages="$pkgname-dev"
+source="http://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="5d844ea1f557bad0364d5b85cd10c796 libnfnetlink-0.0.41.tar.bz2"
diff --git a/main/libogg/APKBUILD b/main/libogg/APKBUILD
new file mode 100644
index 00000000000..8cfbf96871c
--- /dev/null
+++ b/main/libogg/APKBUILD
@@ -0,0 +1,25 @@
+# Contributor: Mika Havela <mika.havela@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+
+pkgname=libogg
+pkgver=1.1.3
+pkgrel=0
+pkgdesc="Ogg bitstream and framing library"
+url="http://xiph.org/ogg/"
+license="as-is"
+depends=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://downloads.xiph.org/releases/ogg/$pkgname-$pkgver.tar.gz
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+md5sums="eaf7dc6ebbff30975de7527a80831585 libogg-1.1.3.tar.gz"
diff --git a/main/libogg/nocxx.patch b/main/libogg/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/libogg/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/libpng/APKBUILD b/main/libpng/APKBUILD
new file mode 100644
index 00000000000..3d97159ebc7
--- /dev/null
+++ b/main/libpng/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=libpng
+pkgver=1.2.37
+pkgrel=0
+pkgdesc="Portable Network Graphics library"
+url="http://www.libpng.org/"
+license="GPL"
+depends=
+makedepends="zlib-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
+
+depends_dev="zlib-dev"
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE || return 1
+}
+
+md5sums="7480dbbf9f6c3297faf6fe52ec9b91ab libpng-1.2.37.tar.gz"
diff --git a/main/libpri/APKBUILD b/main/libpri/APKBUILD
new file mode 100644
index 00000000000..d4d90a81038
--- /dev/null
+++ b/main/libpri/APKBUILD
@@ -0,0 +1,33 @@
+# Contributor: Timo Teras <timo.teras@iki.fi>
+# Maintainer: Timo Teras <timo.teras@iki.fi>
+pkgname=libpri
+pkgver=1.4.9
+pkgrel=1
+pkgdesc="Primary Rate ISDN (PRI) library"
+url="http://www.asterisk.orig"
+license="GPL"
+depends=""
+makedepends=""
+install=
+subpackages="$pkgname-dev"
+source="http://downloads.digium.com/pub/telephony/libpri/releases/$pkgname-$pkgver.tar.gz
+ libpri-cflags.patch
+ libpri-1.4.9-i14292.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1;
+ done
+
+ make LDCONFIG="echo" || return 1
+ make LDCONFIG="echo" INSTALL_PREFIX="$pkgdir" install
+
+ # install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ # install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+}
+
+md5sums="97332edeaa2de0320d85fda88afb96f9 libpri-1.4.9.tar.gz
+8df2ca48ce7db4f1a8604b0904bc9394 libpri-cflags.patch
+240e4057980c88f2c2576c5c25744c70 libpri-1.4.9-i14292.patch"
diff --git a/main/libpri/libpri-1.4.9-i14292.patch b/main/libpri/libpri-1.4.9-i14292.patch
new file mode 100644
index 00000000000..27ed1b8d432
--- /dev/null
+++ b/main/libpri/libpri-1.4.9-i14292.patch
@@ -0,0 +1,5668 @@
+Index: .version
+===================================================================
+--- a/.version (.../tags/1.4.9) (revision 700)
++++ b/.version (.../team/group/issue14292) (revision 700)
+@@ -1 +1 @@
+-1.4.9
++1.4.9-issue14292
+Index: pri_facility.c
+===================================================================
+--- a/pri_facility.c (.../tags/1.4.9) (revision 700)
++++ b/pri_facility.c (.../team/group/issue14292) (revision 700)
+@@ -171,7 +171,7 @@
+
+ struct addressingdataelements_presentednumberunscreened {
+ char partyaddress[21];
+- char partysubaddress[21];
++ char notused[21];
+ int npi; /* Numbering Plan Indicator */
+ int ton; /* Type Of Number */
+ int pres; /* Presentation */
+@@ -179,6 +179,15 @@
+
+ struct addressingdataelements_presentednumberscreened {
+ char partyaddress[21];
++ char notused[21];
++ int npi; /* Numbering Plan Indicator */
++ int ton; /* Type Of Number */
++ int pres; /* Presentation */
++ int scrind; /* Screening Indicator */
++};
++
++struct addressingdataelements_presentedaddressscreened {
++ char partyaddress[21];
+ char partysubaddress[21];
+ int npi; /* Numbering Plan Indicator */
+ int ton; /* Type Of Number */
+@@ -186,6 +195,35 @@
+ int scrind; /* Screening Indicator */
+ };
+
++struct addressingdataelements_addressscreened {
++ char partyaddress[21];
++ char partysubaddress[21];
++ int npi; /* Numbering Plan Indicator */
++ int ton; /* Type Of Number */
++ int notused;
++ int scrind; /* Screening Indicator */
++};
++
++struct addressingdataelements_partysubaddress {
++ char notused[21];
++ char partysubaddress[21];
++};
++
++struct nameelements_name {
++ char name[51];
++ int characterset;
++ int namepres;
++};
++
++struct nameelements_nameset {
++ char name[51];
++ int characterset;
++};
++
++struct nameelements_namedata {
++ char name[51];
++};
++
+ #define PRI_CHECKOVERFLOW(size) \
+ if (msgptr - message + (size) >= sizeof(message)) { \
+ *msgptr = '\0'; \
+@@ -225,6 +263,92 @@
+ }
+ #undef PRI_CHECKOVERFLOW
+
++static const char *namepres_to_str(int namepres)
++{
++ return (namepres == 0) ? "Restricted" : "Allowed";
++}
++
++static const char *characterset_to_str(int characterset)
++{
++ switch (characterset) {
++ case CHARACTER_SET_UNKNOWN:
++ return "Unknown";
++ case CHARACTER_SET_ISO8859_1:
++ return "ISO8859-1";
++ case CHARACTER_SET_ISO8859_2:
++ return "ISO8859-2";
++ case CHARACTER_SET_ISO8859_3:
++ return "ISO8859-3";
++ case CHARACTER_SET_ISO8859_4:
++ return "ISO8859-4";
++ case CHARACTER_SET_ISO8859_5:
++ return "ISO8859-5";
++ case CHARACTER_SET_ISO8859_7:
++ return "ISO8859-7";
++ default:
++ return "illegal value";
++ }
++}
++
++static const char *diversionreason_to_str(struct pri *pri, int diversionreason)
++{
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ switch (diversionreason) {
++ case QSIG_DIVERT_REASON_UNKNOWN:
++ return "Unknown";
++ case QSIG_DIVERT_REASON_CFU:
++ return "Call Forwarding Unconditional";
++ case QSIG_DIVERT_REASON_CFB:
++ return "Call Forwarding Busy";
++ case QSIG_DIVERT_REASON_CFNR:
++ return "Call Forwarding No Reply";
++ default:
++ return "invalid value";
++ }
++ } else {
++ switch(diversionreason) {
++ case Q952_DIVERT_REASON_UNKNOWN:
++ return "Unknown";
++ case Q952_DIVERT_REASON_CFU:
++ return "Call Forwarding Unconditional";
++ case Q952_DIVERT_REASON_CFB:
++ return "Call Forwarding Busy";
++ case Q952_DIVERT_REASON_CFNR:
++ return "Call Forwarding No Reply";
++ case Q952_DIVERT_REASON_CD:
++ return "Call Deflection";
++ case Q952_DIVERT_REASON_IMMEDIATE:
++ return "Call Deflection Immediate";
++ default:
++ return "invalid value";
++ }
++ }
++}
++
++static const char *callstatus_to_str(int callstatus)
++{
++ switch (callstatus) {
++ case 0:
++ return "answered";
++ case 1:
++ return "alerting";
++ default:
++ return "illegal value";
++ }
++}
++
++static const char *enddesignation_to_str(int enddesignation)
++{
++ switch (enddesignation) {
++ case 0:
++ return "primaryEnd";
++ case 1:
++ return "secondaryEnd";
++ default:
++ return "illegal value";
++ }
++}
++
+ int redirectingreason_from_q931(struct pri *pri, int redirectingreason)
+ {
+ switch(pri->switchtype) {
+@@ -350,8 +474,25 @@
+ }
+ }
+
+-int asn1_name_decode(void * data, int len, char *namebuf, int buflen)
++static int presentation_to_subscription(struct pri *pri, int presentation)
+ {
++ /* derive subscription value from presentation value */
++
++ switch (presentation & PRES_RESTRICTION) {
++ case PRES_ALLOWED:
++ return QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR;
++ case PRES_RESTRICTED:
++ return QSIG_NOTIFICATION_WITHOUT_DIVERTED_TO_NR;
++ case PRES_UNAVAILABLE: /* Number not available due to interworking */
++ return QSIG_NOTIFICATION_WITHOUT_DIVERTED_TO_NR; /* ?? QSIG_NO_NOTIFICATION */
++ default:
++ pri_message(pri, "!! Unknown Q.SIG presentationIndicator 0x%02x\n", presentation);
++ return QSIG_NOTIFICATION_WITHOUT_DIVERTED_TO_NR;
++ }
++}
++
++int asn1_name_decode(void *data, int len, char *namebuf, int buflen)
++{
+ struct rose_component *comp = (struct rose_component*)data;
+ int datalen = 0, res = 0;
+
+@@ -361,11 +502,13 @@
+ } else
+ datalen = res = comp->len;
+
+- if (datalen > buflen) {
++ if (datalen > buflen - 1) {
+ /* Truncate */
+ datalen = buflen;
+ }
+ memcpy(namebuf, comp->data, datalen);
++ namebuf[datalen] = '\0';
++
+ return res + 2;
+ }
+
+@@ -407,42 +550,230 @@
+ return res;
+ }
+
+-static int rose_number_digits_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++static int rose_namedata_decode(struct pri *pri, unsigned char *data, int len, int implicit, struct nameelements_namedata *value)
+ {
+ int i = 0;
+ struct rose_component *comp = NULL;
+ unsigned char *vdata = data;
+- int datalen = 0;
+- int res = 0;
++ int res;
+
+ do {
++ /* NameData */
++ if (!implicit) {
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_OCTETSTRING, "Don't know what to do if NameData is of type 0x%x\n");
++
++ data = comp->data;
++ if (comp->len == ASN1_LEN_INDEF) {
++ len = strlen((char *)comp->data);
++ res = len + 2 + 2;
++ } else {
++ len = comp->len;
++ res = len + 2;
++ }
++ } else
++ res = len;
++
++ if (len > sizeof(value->name)-1) {
++ pri_message(pri, "!! Oversized NameData component (%d)\n", len);
++ return -1;
++ }
++
++ memcpy(value->name, data, len);
++ value->name[len] = '\0';
++
++ return res;
++ }
++ while(0);
++
++ return -1;
++}
++
++static int rose_namedata_encode(struct pri *pri, unsigned char *dst, int implicit, char *name)
++{
++ int size = 0;
++ struct rose_component *comp;
++ int namesize;
++
++ namesize = strlen(name);
++ if (namesize > 50 ) {
++ pri_message(pri, "!! Encoding of oversized NameData component failed (%d)\n", namesize);
++ return -1;
++ } else if (namesize == 0){
++ pri_message(pri, "!! Encoding of undersized NameData component failed (%d)\n", namesize);
++ return -1;
++ }
++
++ if (!implicit) {
++ /* constructor component (0x04,len) */
++ comp = (struct rose_component *)dst;
++ comp->type = ASN1_OCTETSTRING;
++ comp->len = 2 + namesize;
++ size += 2;
++ dst += 2;
++ }
++
++ memcpy(dst, name, namesize);
++ size += namesize;
++
++ return size;
++}
++
++static int rose_nameset_decode(struct pri *pri, unsigned char *data, int len, int implicit, struct nameelements_nameset *value)
++{
++ int size;
++ int i = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++ int characterset;
++
++ value->characterset = CHARACTER_SET_ISO8859_1;
++
++ do {
++ /* NameSet */
++ if (!implicit) {
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_SEQUENCE, "Don't know what to do if NameSet is of type 0x%x\n");
++ SUB_COMPONENT(comp, i);
++ }
++
++ /* nameData NameData */
+ GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_NUMERICSTRING, "Don't know what to do with PublicPartyNumber ROSE component type 0x%x\n");
+- if(comp->len > 20 && comp->len != ASN1_LEN_INDEF) {
+- pri_message(pri, "!! Oversized NumberDigits component (%d)\n", comp->len);
++ size = rose_namedata_decode(pri, (u_int8_t *)comp, len, 0, (struct nameelements_namedata *)value);
++ if (size < 0)
+ return -1;
++ i += size;
++
++ if (i < len) {
++ /* characterSet CharacterSet OPTIONAL */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if CharacterSet is of type 0x%x\n");
++ ASN1_GET_INTEGER(comp, characterset);
++ NEXT_COMPONENT(comp, i);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " NameSet: Received characterSet=%s(%d)\n", characterset_to_str(characterset), characterset);
++ value->characterset = characterset;
+ }
+- if (comp->len == ASN1_LEN_INDEF) {
+- datalen = strlen((char *)comp->data);
+- res = datalen + 2;
+- } else
+- res = datalen = comp->len;
+-
+- memcpy(value->partyaddress, comp->data, datalen);
+- value->partyaddress[datalen] = '\0';
+
+- return res + 2;
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " NameSet: '%s', characterSet=%s(%d) i=%d len=%d\n", value->name, characterset_to_str(value->characterset), value->characterset, i, len);
++
++ return i;
+ }
+ while(0);
+
+ return -1;
+ }
+
+-static int rose_public_party_number_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++static int rose_name_decode(struct pri *pri, unsigned char *data, int len, struct nameelements_name *value)
+ {
+ int i = 0;
++ int size = 0;
+ struct rose_component *comp = NULL;
+ unsigned char *vdata = data;
++
++ value->name[0] = '\0';
++ value->characterset = CHARACTER_SET_UNKNOWN;
++ value->namepres = -1;
++
++ do {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] namePresentationAllowedSimple */
++ size = rose_namedata_decode(pri, comp->data, comp->len, 1, (struct nameelements_namedata *)value);
++ if (size < 0)
++ return -1;
++ i += (size + 2);
++ value->characterset = CHARACTER_SET_ISO8859_1;
++ value->namepres = 1;
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] namePresentationAllowedExtended */
++ size = rose_nameset_decode(pri, comp->data, comp->len, 1, (struct nameelements_nameset *)value);
++ if (size < 0)
++ return -1;
++ i += (size + 2);
++ value->namepres = 1;
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] namePresentationRestrictedSimple */
++ size = rose_namedata_decode(pri, comp->data, comp->len, 1, (struct nameelements_namedata *)value);
++ if (size < 0)
++ return -1;
++ i += (size + 2);
++ value->characterset = CHARACTER_SET_ISO8859_1;
++ value->namepres = 0;
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] namePresentationRestrictedExtended */
++ size = rose_nameset_decode(pri, comp->data, comp->len, 1, (struct nameelements_nameset *)value);
++ if (size < 0)
++ return -1;
++ i += (size + 2);
++ value->namepres = 0;
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_4): /* [4] nameNotAvailable */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_7): /* [7] namePresentationRestrictedNull */
++ i += (comp->len + 2);
++ value->name[0] = '\0';
++ value->characterset = CHARACTER_SET_UNKNOWN;
++ value->namepres = 0;
++ break;
++ default:
++ pri_message(pri, "!! Unknown Name component received 0x%x\n", comp->type);
++ return -1;
++ }
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Name: '%s' i=%d len=%d\n", value->name, i, len);
++ return i;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_number_digits_decode(struct pri *pri, unsigned char *data, int len, int implicit, struct addressingdataelements_presentednumberunscreened *value)
++{
++ int i = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++ int res = 0;
++
++ do {
++ if (!implicit) {
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_NUMERICSTRING, "Don't know what to do with NumberDigits ROSE component type 0x%x\n");
++
++ data = comp->data;
++ if (comp->len == ASN1_LEN_INDEF) {
++ len = strlen((char *)comp->data);
++ res = len + 2 + 2;
++ } else {
++ len = comp->len;
++ res = len + 2;
++ }
++ } else
++ res = len;
++
++ if (len > sizeof(value->partyaddress)-1) {
++ pri_message(pri, "!! Oversized NumberDigits component (%d)\n", len);
++ return -1;
++ }
++
++ memcpy(value->partyaddress, data, len);
++ value->partyaddress[len] = '\0';
++
++ return res;
++ }
++ while(0);
++
++ return -1;
++}
++
++static int rose_public_party_number_decode(struct pri *pri, unsigned char *data, int len, int implicit, struct addressingdataelements_presentednumberunscreened *value)
++{
++ int i = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
+ int ton;
+ int res = 0;
+
+@@ -450,13 +781,19 @@
+ return -1;
+
+ do {
++ if (!implicit) {
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_SEQUENCE, "Don't know what to do if PublicPartyNumber is of type 0x%x\n");
++ SUB_COMPONENT(comp, i);
++ }
++
+ GET_COMPONENT(comp, i, vdata, len);
+ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with PublicPartyNumber ROSE component type 0x%x\n");
+ ASN1_GET_INTEGER(comp, ton);
+ NEXT_COMPONENT(comp, i);
+ ton = typeofnumber_for_q931(pri, ton);
+
+- res = rose_number_digits_decode(pri, call, &vdata[i], len-i, value);
++ res = rose_number_digits_decode(pri, &vdata[i], len-i, 0, value);
+ if (res < 0)
+ return -1;
+ value->ton = ton;
+@@ -467,8 +804,48 @@
+ return -1;
+ }
+
+-static int rose_private_party_number_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++static int rose_public_party_number_encode(struct pri *pri, unsigned char *dst, int implicit, unsigned char ton, char *num)
+ {
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ int numsize;
++
++ numsize = strlen(num);
++ if (numsize > 20 ) {
++ pri_message(pri, "!! Encoding of oversized PublicPartyNumber component failed (%d)\n", numsize);
++ return -1;
++ }
++
++ if (!implicit) {
++ /* constructor component (0x30,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), dst, i);
++ ASN1_PUSH(compstk, compsp, comp);
++ } else
++ comp = (struct rose_component *)dst;
++
++ /* publicTypeOfNumber (0x0a,0x01,ton)*/
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, dst, i, ton);
++
++ /* publicNumberDigits */
++
++ /* tag component NumericString (0x12,len) */
++ ASN1_ADD_SIMPLE(comp, ASN1_NUMERICSTRING, dst, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* NumericString */
++ memcpy(comp->data, num, numsize);
++ i += numsize;
++
++ ASN1_FIXUP(compstk, compsp, dst, i);
++
++ if (!implicit)
++ ASN1_FIXUP(compstk, compsp, dst, i);
++
++ return i;
++}
++
++static int rose_private_party_number_decode(struct pri *pri, unsigned char *data, int len, int implicit, struct addressingdataelements_presentednumberunscreened *value)
++{
+ int i = 0;
+ struct rose_component *comp = NULL;
+ unsigned char *vdata = data;
+@@ -476,18 +853,24 @@
+ int res = 0;
+
+ if (len < 2)
+- return -1;
++ return -1;
+
+ do {
++ if (!implicit) {
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_SEQUENCE, "Don't know what to do if PrivatePartyNumber is of type 0x%x\n");
++ SUB_COMPONENT(comp, i);
++ }
++
+ GET_COMPONENT(comp, i, vdata, len);
+ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with PrivatePartyNumber ROSE component type 0x%x\n");
+ ASN1_GET_INTEGER(comp, ton);
+ NEXT_COMPONENT(comp, i);
+ ton = typeofnumber_for_q931(pri, ton);
+
+- res = rose_number_digits_decode(pri, call, &vdata[i], len-i, value);
++ res = rose_number_digits_decode(pri, &vdata[i], len-i, 0, value);
+ if (res < 0)
+- return -1;
++ return -1;
+ value->ton = ton;
+
+ return res + 3;
+@@ -496,7 +879,7 @@
+ return -1;
+ }
+
+-static int rose_address_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++static int rose_address_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
+ {
+ int i = 0;
+ struct rose_component *comp = NULL;
+@@ -506,65 +889,59 @@
+ do {
+ GET_COMPONENT(comp, i, vdata, len);
+
++ /* PartyNumber */
+ switch(comp->type) {
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] unknownPartyNumber */
+- res = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] unknownPartyNumber, IMPLICIT NumberDigits */
++ res = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
+ if (res < 0)
+ return -1;
+ value->npi = PRI_NPI_UNKNOWN;
+ value->ton = PRI_TON_UNKNOWN;
+ break;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] unknownPartyNumber */
+- res = asn1_copy_string(value->partyaddress, sizeof(value->partyaddress), comp);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] publicPartyNumber, IMPLICIT PublicPartyNumber */
++ res = rose_public_party_number_decode(pri, comp->data, comp->len, 1, value);
+ if (res < 0)
+ return -1;
+- value->npi = PRI_NPI_UNKNOWN;
+- value->ton = PRI_TON_UNKNOWN;
++ value->npi = PRI_NPI_E163_E164;
+ break;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] publicPartyNumber */
+- res = rose_public_party_number_decode(pri, call, comp->data, comp->len, value);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_3): /* [3] dataPartyNumber, IMPLICIT NumberDigits */
++ res = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
+ if (res < 0)
+ return -1;
+- value->npi = PRI_NPI_E163_E164;
+- break;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_2): /* [2] nsapEncodedNumber */
+- pri_message(pri, "!! NsapEncodedNumber isn't handled\n");
+- return -1;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] dataPartyNumber */
+- if(rose_number_digits_decode(pri, call, comp->data, comp->len, value))
+- return -1;
+ value->npi = PRI_NPI_X121 /* ??? */;
+ value->ton = PRI_TON_UNKNOWN /* ??? */;
+ pri_message(pri, "!! dataPartyNumber isn't handled\n");
+ return -1;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_4): /* [4] telexPartyNumber */
+- res = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_4): /* [4] telexPartyNumber, IMPLICIT NumberDigits */
++ res = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
+ if (res < 0)
+ return -1;
+ value->npi = PRI_NPI_F69 /* ??? */;
+ value->ton = PRI_TON_UNKNOWN /* ??? */;
+ pri_message(pri, "!! telexPartyNumber isn't handled\n");
+ return -1;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5): /* [5] priavePartyNumber */
+- res = rose_private_party_number_decode(pri, call, comp->data, comp->len, value);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5): /* [5] privatePartyNumber, IMPLICIT PrivatePartyNumber */
++ res = rose_private_party_number_decode(pri, comp->data, comp->len, 1, value);
+ if (res < 0)
+- return -1;
++ return -1;
+ value->npi = PRI_NPI_PRIVATE;
+ break;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_8): /* [8] nationalStandardPartyNumber */
+- res = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_8): /* [8] nationalStandardPartyNumber, IMPLICIT NumberDigits */
++ res = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
+ if (res < 0)
+ return -1;
+ value->npi = PRI_NPI_NATIONAL;
+ value->ton = PRI_TON_NATIONAL;
+ break;
+ default:
+- pri_message(pri, "!! Unknown Party number component received 0x%X\n", comp->type);
++ pri_message(pri, "!! Unknown PartyNumber component received 0x%X\n", comp->type);
+ return -1;
+ }
+ ASN1_FIXUP_LEN(comp, res);
+ NEXT_COMPONENT(comp, i);
+- if(i < len)
++
++ /* PartySubaddress OPTIONAL */
++ if (i < len)
+ pri_message(pri, "!! not all information is handled from Address component\n");
+ return res + 2;
+ }
+@@ -573,14 +950,176 @@
+ return -1;
+ }
+
+-static int rose_presented_number_unscreened_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++static int rose_party_number_encode(struct pri *pri, unsigned char *dst, unsigned char ton, char *num)
+ {
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ int numsize, size;
++
++ numsize = strlen(num);
++ if (numsize > 20 ) {
++ pri_message(pri, "!! Encoding of oversized PartyNumber component failed (%d)\n", numsize);
++ return -1;
++ }
++
++#if 0
++ /* tag component unknownPartyNumber (0x80,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), dst, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* unknownPartyNumber, implicid NumberDigits */
++ memcpy(comp->data, num, numsize);
++ i += numsize;
++
++ ASN1_FIXUP(compstk, compsp, dst, i);
++#endif
++
++ /* tag component publicPartyNumber (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), dst, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* publicPartyNumber, implicid PublicPartyNumber */
++ size = rose_public_party_number_encode(pri, comp->data, 1, ton, num);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, dst, i);
++
++ return i;
++}
++
++static int rose_party_number_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++{
+ int i = 0;
+ int size = 0;
+ struct rose_component *comp = NULL;
+ unsigned char *vdata = data;
+
++ do {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] IMPLICIT NumberDigits -- default: unknownPartyNumber */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PartyNumber: UnknownPartyNumber len=%d\n", len);
++ size = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
++ if (size < 0)
++ return -1;
++ value->npi = PRI_NPI_UNKNOWN;
++ value->ton = PRI_TON_UNKNOWN;
++ break;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] IMPLICIT PublicPartyNumber */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PartyNumber: PublicPartyNumber len=%d\n", len);
++ size = rose_public_party_number_decode(pri, comp->data, comp->len, 1, value);
++ if (size < 0)
++ return -1;
++ value->npi = PRI_NPI_E163_E164;
++ break;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_3): /* [3] IMPLICIT NumberDigits -- not used: dataPartyNumber */
++ pri_message(pri, "!! PartyNumber: dataPartyNumber is reserved!\n");
++ size = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
++ if (size < 0)
++ return -1;
++ value->npi = PRI_NPI_X121 /* ??? */;
++ value->ton = PRI_TON_UNKNOWN /* ??? */;
++ break;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_4): /* [4] IMPLICIT NumberDigits -- not used: telexPartyNumber */
++ pri_message(pri, "!! PartyNumber: telexPartyNumber is reserved!\n");
++ size = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
++ if (size < 0)
++ return -1;
++ value->npi = PRI_NPI_F69 /* ??? */;
++ value->ton = PRI_TON_UNKNOWN /* ??? */;
++ break;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5): /* [5] IMPLICIT PrivatePartyNumber */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PartyNumber: PrivatePartyNumber len=%d\n", len);
++ size = rose_private_party_number_decode(pri, comp->data, comp->len, 1, value);
++ if (size < 0)
++ return -1;
++ value->npi = PRI_NPI_PRIVATE;
++ break;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_8): /* [8] IMPLICIT NumberDigits -- not used: nationalStandatdPartyNumber */
++ pri_message(pri, "!! PartyNumber: nationalStandardPartyNumber is reserved!\n");
++ size = rose_number_digits_decode(pri, comp->data, comp->len, 1, value);
++ if (size < 0)
++ return -1;
++ value->npi = PRI_NPI_NATIONAL;
++ value->ton = PRI_TON_NATIONAL;
++ break;
++
++ default:
++ pri_message(pri, "Invalid PartyNumber component 0x%X\n", comp->type);
++ return -1;
++ }
++ ASN1_FIXUP_LEN(comp, size);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PartyNumber: '%s' size=%d len=%d\n", value->partyaddress, size, len);
++ return size;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_presented_number_unscreened_encode(struct pri *pri, unsigned char *dst, unsigned char presentation, unsigned char ton, char *num)
++{
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ int numsize, size;
++
++ numsize = strlen(num);
++ if (numsize > 20 ) {
++ pri_message(pri, "!! Encoding of oversized PresentedNumberUnscreened component failed (%d)\n", numsize);
++ return -1;
++ }
++
++ switch (presentation & PRES_RESTRICTION) {
++ case PRES_ALLOWED:
++ /* tag component [0] presentationAllowedAddress (0xa0,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), dst, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* PartyNumber */
++ size = rose_party_number_encode(pri, comp->data, ton, num);
++ if (size < 0)
++ return -1;
++ i += size;
++ ASN1_FIXUP(compstk, compsp, dst, i);
++ break;
++ case PRES_RESTRICTED:
++ /* tag component [1] presentationRestricted (0x81,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), dst, i);
++ break;
++ case PRES_UNAVAILABLE:
++ /* tag component [2] numberNotAvailableDueToInterworking (0x82,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), dst, i);
++ /* ASN1_FIXUP(compstk, compsp, dst, i); */
++ break;
++ default:
++ pri_message(pri, "!! Undefined presentation value for PresentedNumberUnscreened: 0x%x\n", presentation);
++ return -1;
++ }
++
++ return i;
++}
++
++static int rose_presented_number_unscreened_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
++{
++ int i = 0;
++ int size = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++
+ /* Fill in default values */
++ value->partyaddress[0] = '\0';
+ value->ton = PRI_TON_UNKNOWN;
+ value->npi = PRI_NPI_E163_E164;
+ value->pres = -1; /* Data is not available */
+@@ -591,7 +1130,7 @@
+ switch(comp->type) {
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] presentationAllowedNumber */
+ value->pres = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
+- size = rose_address_decode(pri, call, comp->data, comp->len, value);
++ size = rose_address_decode(pri, comp->data, comp->len, value);
+ ASN1_FIXUP_LEN(comp, size);
+ return size + 2;
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1): /* [1] IMPLICIT presentationRestricted */
+@@ -610,7 +1149,7 @@
+ return 2;
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] presentationRestrictedNumber */
+ value->pres = PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
+- size = rose_address_decode(pri, call, comp->data, comp->len, value) + 2;
++ size = rose_address_decode(pri, comp->data, comp->len, value) + 2;
+ ASN1_FIXUP_LEN(comp, size);
+ return size + 2;
+ default:
+@@ -623,17 +1162,482 @@
+ return -1;
+ }
+
++static int rose_number_screened_encode(struct pri *pri, unsigned char *dst, int implicit, unsigned char ton, unsigned char screenind, char *num)
++{
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ int numsize, size;
++
++ numsize = strlen(num);
++ if (numsize > 20 ) {
++ pri_message(pri, "!! Encoding of oversized NumberScreened component failed (%d)\n", numsize);
++ return -1;
++ }
++
++ if (!implicit) {
++ /* constructor component (0x30,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), dst, i);
++ ASN1_PUSH(compstk, compsp, comp);
++ } else
++ comp = (struct rose_component *)dst;
++
++ /* PartyNumber */
++ size = rose_party_number_encode(pri, (u_int8_t *)comp, ton, num);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ /* ScreeningIndicator (0x0a,0x01,screenind) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, dst, i, screenind);
++
++ if (!implicit)
++ ASN1_FIXUP(compstk, compsp, dst, i);
++
++ return i;
++}
++
++static int rose_number_screened_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_presentednumberscreened *value)
++{
++ int i = 0;
++ int size = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++
++ int scrind = -1;
++
++ do {
++ /* Party Number */
++ GET_COMPONENT(comp, i, vdata, len);
++ size = rose_party_number_decode(pri, (u_int8_t *)comp, comp->len + 2, (struct addressingdataelements_presentednumberunscreened*) value);
++ if (size < 0)
++ return -1;
++ comp->len = size;
++ NEXT_COMPONENT(comp, i);
++
++ /* Screening Indicator */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with NumberScreened ROSE component type 0x%x\n");
++ ASN1_GET_INTEGER(comp, scrind);
++ // Todo: scrind = screeningindicator_for_q931(pri, scrind);
++ NEXT_COMPONENT(comp, i);
++
++ value->scrind = scrind;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " NumberScreened: '%s' ScreeningIndicator=%d i=%d len=%d\n", value->partyaddress, scrind, i, len);
++
++ return i-2; // We do not have a sequence header here.
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_presented_number_screened_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_presentednumberscreened *value)
++{
++ int i = 0;
++ int size = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++
++ /* Fill in default values */
++ value->partyaddress[0] = '\0';
++ value->ton = PRI_TON_UNKNOWN;
++ value->npi = PRI_NPI_UNKNOWN;
++ value->pres = -1; /* Data is not available */
++ value->scrind = 0;
++
++ do {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] IMPLICIT presentationAllowedNumber */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedNumberScreened: presentationAllowedNumber comp->len=%d\n", comp->len);
++ value->pres = PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
++ size = rose_number_screened_decode(pri, comp->data, comp->len, value);
++ if (size < 0)
++ return -1;
++ ASN1_FIXUP_LEN(comp, size);
++ return size + 2;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1): /* [1] IMPLICIT presentationRestricted */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedNumberScreened: presentationRestricted comp->len=%d\n", comp->len);
++ if (comp->len != 0) { /* must be NULL */
++ pri_error(pri, "!! Invalid PresentationRestricted component received (len != 0)\n");
++ return -1;
++ }
++ value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
++ return 2;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] IMPLICIT numberNotAvailableDueToInterworking */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedNumberScreened: NumberNotAvailableDueToInterworking comp->len=%d\n", comp->len);
++ if (comp->len != 0) { /* must be NULL */
++ pri_error(pri, "!! Invalid NumberNotAvailableDueToInterworking component received (len != 0)\n");
++ return -1;
++ }
++ value->pres = PRES_NUMBER_NOT_AVAILABLE;
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedNumberScreened: numberNotAvailableDueToInterworking Type=0x%X i=%d len=%d size=%d\n", comp->type, i, len);
++ return 2;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] IMPLICIT presentationRestrictedNumber */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedNumberScreened: presentationRestrictedNumber comp->len=%d\n", comp->len);
++ value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
++ size = rose_number_screened_decode(pri, comp->data, comp->len, value);
++ if (size < 0)
++ return -1;
++ ASN1_FIXUP_LEN(comp, size);
++ return size + 2;
++
++ default:
++ pri_message(pri, "Invalid PresentedNumberScreened component 0x%X\n", comp->type);
++ }
++ return -1;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_partysubaddress_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_partysubaddress *value)
++{
++ int i = 0;
++ int size = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++
++ int odd_count_indicator = -1;
++ value->partysubaddress[0] = '\0';
++
++ do {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_CONSTRUCTOR | ASN1_SEQUENCE): /* UserSpecifiedSubaddress */
++ /* SubaddressInformation */
++ SUB_COMPONENT(comp, i);
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_OCTETSTRING, "Don't know what to do if SubaddressInformation is of type 0x%x\n");
++ size = asn1_name_decode(comp->data, comp->len, value->partysubaddress, sizeof(value->partysubaddress));
++ if (size < 0)
++ return -1;
++ i += size;
++
++ /* oddCountIndicator BOOLEAN OPTIONAL */
++ if (i < len) {
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_BOOLEAN, "Don't know what to do if SubaddressInformation is of type 0x%x\n");
++
++ ASN1_GET_INTEGER(comp, odd_count_indicator);
++ NEXT_COMPONENT(comp, i);
++ }
++ case (ASN1_OCTETSTRING): /* NSAPSubaddress */
++ size = asn1_name_decode((u_int8_t *)comp, comp->len + 2, value->partysubaddress, sizeof(value->partysubaddress));
++ if (size < 0)
++ return -1;
++ i += size;
++ break;
++ default:
++ pri_message(pri, "Invalid PartySubaddress component 0x%X\n", comp->type);
++ return -1;
++ }
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PartySubaddress: '%s', oddCountIndicator=%d, i=%d len=%d\n", value->partysubaddress, odd_count_indicator, i, len);
++
++ return i;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_address_screened_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_addressscreened *value)
++{
++ int i = 0;
++ int size = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++
++ int scrind;
++ value->partysubaddress[0] = '\0';
++
++ /* SEQUENCE AddressScreened */
++ do {
++ /* PartyNumber */
++ GET_COMPONENT(comp, i, vdata, len);
++ size = rose_party_number_decode(pri, (u_int8_t *)comp, comp->len + 2, (struct addressingdataelements_presentednumberunscreened *)value);
++ if (size < 0)
++ return -1;
++ comp->len = size;
++ NEXT_COMPONENT(comp, i);
++
++ /* ScreeningIndicator */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with AddressScreened ROSE component type 0x%x\n");
++ ASN1_GET_INTEGER(comp, scrind);
++ NEXT_COMPONENT(comp, i);
++
++ if (i < len) {
++ /* PartySubaddress OPTIONAL */
++ GET_COMPONENT(comp, i, vdata, len);
++ size = rose_partysubaddress_decode(pri, (u_int8_t *)comp, comp->len + 2, (struct addressingdataelements_partysubaddress *)value);
++ if (size < 0)
++ return -1;
++ i += size;
++ }
++
++ value->scrind = scrind;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " AddressScreened: '%s' ScreeningIndicator=%d i=%d len=%d\n", value->partyaddress, scrind, i, len);
++
++ return i-2;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_presented_address_screened_decode(struct pri *pri, unsigned char *data, int len, struct addressingdataelements_presentedaddressscreened *value)
++{
++ int i = 0;
++ int size = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = data;
++
++ /* Fill in default values */
++ value->partyaddress[0] = '\0';
++ value->partysubaddress[0] = '\0';
++ value->npi = PRI_NPI_UNKNOWN;
++ value->ton = PRI_TON_UNKNOWN;
++ value->pres = -1; /* Data is not available */
++ value->scrind = 0;
++
++ do {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] IMPLICIT presentationAllowedAddress */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedAddressScreened: presentationAllowedAddress comp->len=%d\n", comp->len);
++ value->pres = PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
++ size = rose_address_screened_decode(pri, comp->data, comp->len, (struct addressingdataelements_addressscreened *)value);
++ if (size < 0)
++ return -1;
++ ASN1_FIXUP_LEN(comp, size);
++ return size + 2;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1): /* [1] IMPLICIT presentationRestricted */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedAddressScreened: presentationRestricted comp->len=%d\n", comp->len);
++ if (comp->len != 0) { /* must be NULL */
++ pri_error(pri, "!! Invalid PresentationRestricted component received (len != 0)\n");
++ return -1;
++ }
++ value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
++ return 2;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] IMPLICIT numberNotAvailableDueToInterworking */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedAddressScreened: NumberNotAvailableDueToInterworking comp->len=%d\n", comp->len);
++ if (comp->len != 0) { /* must be NULL */
++ pri_error(pri, "!! Invalid NumberNotAvailableDueToInterworking component received (len != 0)\n");
++ return -1;
++ }
++ value->pres = PRES_NUMBER_NOT_AVAILABLE;
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedAddressScreened: numberNotAvailableDueToInterworking Type=0x%X i=%d len=%d size=%d\n", comp->type, i, len);
++ return 2;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] IMPLICIT presentationRestrictedAddress */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " PresentedAddressScreened: presentationRestrictedAddress comp->len=%d\n", comp->len);
++ value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
++ size = rose_address_screened_decode(pri, comp->data, comp->len, (struct addressingdataelements_addressscreened *)value);
++ if (size < 0)
++ return -1;
++ ASN1_FIXUP_LEN(comp, size);
++ return size + 2;
++
++ default:
++ pri_message(pri, "Invalid PresentedAddressScreened component 0x%X\n", comp->type);
++ }
++ return -1;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_diverting_leg_information1_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
++{
++ int i = 0;
++ struct addressingdataelements_presentednumberunscreened nominatednr;
++ int diversion_reason;
++ int subscription_option;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = sequence->data;
++ int size = 0;
++ memset(&nominatednr, 0, sizeof(nominatednr));
++
++ /* Data checks */
++ if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
++ pri_message(pri, "Invalid DivertingLegInformation1Type argument\n");
++ return -1;
++ }
++
++ if (sequence->len == ASN1_LEN_INDEF) {
++ len -= 4; /* For the 2 extra characters at the end
++ and two characters of header */
++ } else
++ len -= 2;
++
++ do {
++ /* diversionReason DiversionReason */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid diversionReason type 0x%X of ROSE divertingLegInformation1 component received\n");
++ ASN1_GET_INTEGER(comp, diversion_reason);
++ NEXT_COMPONENT(comp, i);
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received diversionReason: %s(%d)\n", diversionreason_to_str(pri, diversion_reason), diversion_reason);
++
++ diversion_reason = redirectingreason_for_q931(pri, diversion_reason);
++
++ /* subscriptionOption SubscriptionOption */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid subscriptionOption type 0x%X of ROSE divertingLegInformation1 component received\n");
++ ASN1_GET_INTEGER(comp, subscription_option);
++ NEXT_COMPONENT(comp, i);
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received subscriptionOption: %d\n", subscription_option);
++
++ /* nominatedNr PartyNumber */
++ GET_COMPONENT(comp, i, vdata, len);
++ size = rose_party_number_decode(pri, (u_int8_t *)comp, comp->len + 2, &nominatednr);
++ if (size < 0)
++ return -1;
++
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, " Received nominatedNr '%s'\n", nominatednr.partyaddress);
++ pri_message(pri, " ton = %d, npi = %d\n\n", nominatednr.ton, nominatednr.npi);
++ }
++
++ call->divleginfo1activeflag = 1;
++ if (subscription_option == QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR) {
++ libpri_copy_string(call->divertedtonum, nominatednr.partyaddress, sizeof(call->divertedtonum));
++ } else {
++ call->divertedtonum[0] = '\0';
++ }
++ call->divertedtopres = (subscription_option == QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR) ? PRES_ALLOWED_USER_NUMBER_NOT_SCREENED : PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
++ call->divertedtoplan = ((nominatednr.ton & 0x07) << 4) | (nominatednr.npi & 0x0f);
++ call->divertedtoreason = diversion_reason;
++ call->divertedtocount++;
++
++ return 0;
++ }
++ while (0);
++
++ return -1;
++}
++
++int rose_diverting_leg_information1_encode(struct pri *pri, q931_call *call)
++{
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ unsigned char buffer[256];
++ int size;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Encode divertingLegInformation1\n");
++
++ /* Protocol Profile = 0x1f (Networking Extensions) (0x9f) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Network Facility Extension */
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ /* tag component NetworkFacilityExtension (0xaa, len ) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* sourceEntity (0x80,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* endPINX(0) */
++
++ /* destinationEntity (0x82,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* endPINX(0) */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
++
++ /* Network Protocol Profile */
++ /* - not included - */
++
++ /* Interpretation APDU (0x8b,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* discardAnyUnrecognisedInvokePdu(0) */
++
++ /* Service APDU(s): */
++
++ /* ROSE InvokePDU (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* ROSE InvokeID (0x02,0x01,invokeid) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
++
++ /* ROSE operationId (0x02,0x01,0x14)*/
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_DIVERTING_LEG_INFORMATION1);
++
++ /* constructor component (0x30,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* diversionReason (0x0a,0x01,diversionreason) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, redirectingreason_from_q931(pri, call->divertedtoreason));
++
++ /* subscriptionOption (0x0a,0x01,subscriptionoption) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, presentation_to_subscription(pri, call->divertedtopres));
++
++ /* nominatedNr */
++
++ /* tag component publicPartyNumber (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* publicPartyNumber, implicid PublicPartyNumber */
++ size = rose_public_party_number_encode(pri, &buffer[i], 1, (call->divertedtoplan & 0x70) >> 4, call->divertedtonum);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(call, Q931_FACILITY, buffer, i, NULL, NULL))
++ return -1;
++
++ return 0;
++}
++
+ static int rose_diverting_leg_information2_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
+ {
+ int i = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = sequence->data;
++ int size = 0;
++
+ int diversion_counter;
+ int diversion_reason;
+- char origcalledname[50] = "", redirectingname[50] = "";
++ int original_diversion_reason = QSIG_DIVERT_REASON_UNKNOWN;
++ struct nameelements_name redirectingname = { "", CHARACTER_SET_UNKNOWN, 0 };
++ struct nameelements_name origcalledname = { "", CHARACTER_SET_UNKNOWN, 0 };;
+ struct addressingdataelements_presentednumberunscreened divertingnr;
+- struct addressingdataelements_presentednumberunscreened originalcallednr;
+- struct rose_component *comp = NULL;
+- unsigned char *vdata = sequence->data;
+- int res = 0;
++ struct addressingdataelements_presentednumberunscreened originalcallednr;
+ memset(&divertingnr, 0, sizeof(divertingnr));
+ memset(&originalcallednr, 0, sizeof(originalcallednr));
+
+@@ -644,249 +1648,429 @@
+ }
+
+ if (sequence->len == ASN1_LEN_INDEF) {
+- len -= 4; /* For the 2 extra characters at the end
+- * and two characters of header */
++ len -= 4; /* For the 2 extra characters at the end
++ and two characters of header */
+ } else
+ len -= 2;
+
+ do {
+- /* diversionCounter stuff */
++ /* diversionCounter */
+ GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do it diversionCounter is of type 0x%x\n");
++ CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if diversionCounter is of type 0x%x\n");
+ ASN1_GET_INTEGER(comp, diversion_counter);
+ NEXT_COMPONENT(comp, i);
+
+- /* diversionReason stuff */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received diversionCounter: %d\n", diversion_counter);
++
++ /* diversionReason DiversionReason */
+ GET_COMPONENT(comp, i, vdata, len);
+ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid diversionReason type 0x%X of ROSE divertingLegInformation2 component received\n");
+ ASN1_GET_INTEGER(comp, diversion_reason);
+ NEXT_COMPONENT(comp, i);
+
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received diversionReason: %s(%d)\n", diversionreason_to_str(pri, diversion_reason), diversion_reason);
++
+ diversion_reason = redirectingreason_for_q931(pri, diversion_reason);
+-
+- if(pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Redirection reason: %d, total diversions: %d\n", diversion_reason, diversion_counter);
+- pri_message(NULL, "Length of message is %d\n", len);
+
+- for(; i < len; NEXT_COMPONENT(comp, i)) {
++ /* Type SEQUENCE specifies an ordered list of component types. *
++ * We decode all components but for simplicity we don't check the order. */
++ while (i < len) {
+ GET_COMPONENT(comp, i, vdata, len);
++
+ switch(comp->type) {
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0):
+- call->origredirectingreason = redirectingreason_for_q931(pri, comp->data[0]);
++ /* originalDiversionReason */
++ ASN1_GET_INTEGER(comp, original_diversion_reason);
++ NEXT_COMPONENT(comp,i);
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Received reason for original redirection %d\n", call->origredirectingreason);
++ pri_message(pri, " Received originalDiversionReason: %s(%d)\n", diversionreason_to_str(pri, original_diversion_reason), original_diversion_reason);
++ original_diversion_reason = redirectingreason_for_q931(pri, original_diversion_reason);
+ break;
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1):
+- res = rose_presented_number_unscreened_decode(pri, call, comp->data, comp->len, &divertingnr);
+- /* TODO: Fix indefinite length form hacks */
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
+- if (res < 0)
++ /* divertingNr */
++ size = rose_presented_number_unscreened_decode(pri, comp->data, comp->len, &divertingnr);
++ if (size < 0)
+ return -1;
++ ASN1_FIXUP_LEN(comp, size);
++ comp->len = size;
++ NEXT_COMPONENT(comp,i);
+ if (pri->debug & PRI_DEBUG_APDU) {
+ pri_message(pri, " Received divertingNr '%s'\n", divertingnr.partyaddress);
+ pri_message(pri, " ton = %d, pres = %d, npi = %d\n", divertingnr.ton, divertingnr.pres, divertingnr.npi);
+ }
+ break;
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_2):
+- res = rose_presented_number_unscreened_decode(pri, call, comp->data, comp->len, &originalcallednr);
+- if (res < 0)
++ /* originalCalledNr */
++ size = rose_presented_number_unscreened_decode(pri, comp->data, comp->len, &originalcallednr);
++ if (size < 0)
+ return -1;
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
++ ASN1_FIXUP_LEN(comp, size);
++ comp->len = size;
++ NEXT_COMPONENT(comp,i);
+ if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, " Received originalcallednr '%s'\n", originalcallednr.partyaddress);
++ pri_message(pri, " Received originalCalledNr '%s'\n", originalcallednr.partyaddress);
+ pri_message(pri, " ton = %d, pres = %d, npi = %d\n", originalcallednr.ton, originalcallednr.pres, originalcallednr.npi);
+ }
+ break;
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3):
+- res = asn1_name_decode(comp->data, comp->len, redirectingname, sizeof(redirectingname));
+- if (res < 0)
++ /* redirectingName */
++ size = rose_name_decode(pri, comp->data, comp->len, &redirectingname);
++ if (size < 0)
+ return -1;
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
++ i += (size + 2);
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Received RedirectingName '%s'\n", redirectingname);
++ pri_message(pri, " Received RedirectingName '%s', namepres %s(%d), characterset %s(%d)\n",
++ redirectingname.name, namepres_to_str(redirectingname.namepres), redirectingname.namepres,
++ characterset_to_str(redirectingname.characterset), redirectingname.characterset);
+ break;
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_4):
+- res = asn1_name_decode(comp->data, comp->len, origcalledname, sizeof(origcalledname));
+- if (res < 0)
++ /* originalCalledName */
++ size = rose_name_decode(pri, comp->data, comp->len, &origcalledname);
++ if (size < 0)
+ return -1;
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
++ i += (size + 2);
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Received Originally Called Name '%s'\n", origcalledname);
++ pri_message(pri, " Received OriginalCalledName '%s', namepres %s(%d), characterset %s(%d)\n",
++ origcalledname.name, namepres_to_str(origcalledname.namepres), origcalledname.namepres,
++ characterset_to_str(origcalledname.characterset), origcalledname.characterset);
+ break;
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5):
+- pri_message(pri, "!! Ignoring DivertingLegInformation2 component 0x%X\n", comp->type);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5): /* [5] IMPLICIT Extension */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_6): /* [6] IMPLICIT SEQUENCE OF Extension */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "!! Ignoring DivertingLegInformation2 component 0x%X\n", comp->type);
++ NEXT_COMPONENT(comp, i);
+ break;
+ default:
+- if (comp->type == 0 && comp->len == 0) {
+- break; /* Found termination characters */
+- }
+- pri_message(pri, "!! Invalid DivertingLegInformation2 component received 0x%X\n", comp->type);
++ pri_message(pri, "!! Invalid DivertingLegInformation2 component received 0x%X\n", comp->type);
+ return -1;
+ }
+ }
+
+ if (divertingnr.pres >= 0) {
+- call->redirectingplan = divertingnr.npi;
++ call->redirectingplan = ((divertingnr.ton & 0x07) << 4) | (divertingnr.npi & 0x0f);
+ call->redirectingpres = divertingnr.pres;
+ call->redirectingreason = diversion_reason;
+ libpri_copy_string(call->redirectingnum, divertingnr.partyaddress, sizeof(call->redirectingnum));
+- pri_message(pri, " Received redirectingnum '%s' (%d)\n", call->redirectingnum, (int)call->redirectingnum[0]);
+ }
+ if (originalcallednr.pres >= 0) {
+- call->origcalledplan = originalcallednr.npi;
++ call->origcalledplan = ((originalcallednr.ton & 0x07) << 4) | (originalcallednr.npi & 0x0f);
+ call->origcalledpres = originalcallednr.pres;
+ libpri_copy_string(call->origcallednum, originalcallednr.partyaddress, sizeof(call->origcallednum));
+- pri_message(pri, " Received origcallednum '%s' (%d)\n", call->origcallednum, (int)call->origcallednum[0]);
+ }
+- libpri_copy_string(call->redirectingname, redirectingname, sizeof(call->redirectingname));
+- libpri_copy_string(call->origcalledname, origcalledname, sizeof(call->origcalledname));
++
++ if (redirectingname.namepres != 0) {
++ libpri_copy_string(call->redirectingname, redirectingname.name, sizeof(call->redirectingname));
++ } else {
++ call->redirectingname[0] = '\0';
++ }
++
++ if (origcalledname.namepres != 0) {
++ libpri_copy_string(call->origcalledname, origcalledname.name, sizeof(call->origcalledname));
++ } else {
++ call->origcalledname[0] = '\0';
++ }
++
++ call->origredirectingreason = original_diversion_reason;
++ call->redirectingcount = diversion_counter;
++
+ return 0;
+ }
+ while (0);
+
+ return -1;
+ }
+-
++
+ static int rose_diverting_leg_information2_encode(struct pri *pri, q931_call *call)
+ {
+- int i = 0, j, compsp = 0;
++ int i = 0, compsp = 0;
+ struct rose_component *comp, *compstk[10];
+ unsigned char buffer[256];
+- int len = 253;
+-
+-#if 0 /* This is not required by specifications */
+- if (!strlen(call->callername)) {
+- return -1;
++ int size;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Encode divertingLegInformation2\n");
++
++ /* Protocol Profile = 0x1f (Networking Extensions) (0x9f) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Network Facility Extension */
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ /* tag component NetworkFacilityExtension (0xaa, len ) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* sourceEntity (0x80,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* endPINX(0) */
++
++ /* destinationEntity (0x82,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* endPINX(0) */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
+ }
+-#endif
+
+- buffer[i] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
+- i++;
+- /* Interpretation component */
+- ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0x00 /* Discard unrecognized invokes */);
+-
++ /* Network Protocol Profile */
++ /* - not included - */
++
++ /* Interpretation APDU (0x8b,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* discardAnyUnrecognisedInvokePdu(0) */
++
++ /* Service APDU(s): */
++
++ /* ROSE InvokePDU (0xa1,len) */
+ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
+-
+ ASN1_PUSH(compstk, compsp, comp);
+- /* Invoke component contents */
+- /* Invoke ID */
++
++ /* ROSE InvokeID (0x02,0x01,invokeid) */
+ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
+- /* Operation Tag */
+-
+- /* ROSE operationId component */
++
++ /* ROSE operationId (0x02,0x01,0x15)*/
+ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_DIVERTING_LEG_INFORMATION2);
+
+- /* ROSE ARGUMENT component */
++ /* constructor component (0x30,len) */
+ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
+ ASN1_PUSH(compstk, compsp, comp);
+- /* ROSE DivertingLegInformation2.diversionCounter component */
+- /* Always is 1 because other isn't available in the current design */
++
++ /* diversionCounter always is 1 because other isn't available in the current design */
++ /* diversionCounter (0x02,0x01,0x01) */
+ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, 1);
+-
+- /* ROSE DivertingLegInformation2.diversionReason component */
++
++ /* diversionReason (0x0a,0x01,redirectingreason) */
+ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, redirectingreason_from_q931(pri, call->redirectingreason));
+-
+- /* ROSE DivertingLegInformation2.divertingNr component */
++
++ /* originalDiversionReason */
++ /* - not included - */
++
++ /* divertingNr */
++
++ /* tag component divertingNr (0xa1,len) */
+ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
+-
+ ASN1_PUSH(compstk, compsp, comp);
+- /* Redirecting information always not screened */
+-
+- switch(call->redirectingpres) {
+- case PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
+- case PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
+- if (call->redirectingnum && strlen(call->redirectingnum)) {
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
+- ASN1_PUSH(compstk, compsp, comp);
+- /* NPI of redirected number is not supported in the current design */
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
+- ASN1_PUSH(compstk, compsp, comp);
+- ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, typeofnumber_from_q931(pri, call->redirectingplan >> 4));
+- j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, call->redirectingnum, strlen(call->redirectingnum));
+- if (j < 0)
+- return -1;
+-
+- i += j;
+- ASN1_FIXUP(compstk, compsp, buffer, i);
+- ASN1_FIXUP(compstk, compsp, buffer, i);
+- break;
+- }
+- /* fall through */
+- case PRES_PROHIB_USER_NUMBER_PASSED_SCREEN:
+- case PRES_PROHIB_USER_NUMBER_NOT_SCREENED:
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), buffer, i);
+- break;
+- /* Don't know how to handle this */
+- case PRES_ALLOWED_NETWORK_NUMBER:
+- case PRES_PROHIB_NETWORK_NUMBER:
+- case PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN:
+- case PRES_PROHIB_USER_NUMBER_FAILED_SCREEN:
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), buffer, i);
+- break;
+- default:
+- pri_message(pri, "!! Undefined presentation value for redirecting number: %d\n", call->redirectingpres);
+- case PRES_NUMBER_NOT_AVAILABLE:
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i);
+- break;
+- }
++
++ size = rose_presented_number_unscreened_encode(pri, &buffer[i], call->redirectingpres, typeofnumber_from_q931(pri, (call->redirectingplan & 0x70) >> 4), call->redirectingnum);
++ if (size < 0)
++ return -1;
++ i += size;
+ ASN1_FIXUP(compstk, compsp, buffer, i);
+
+- /* ROSE DivertingLegInformation2.originalCalledNr component */
+- /* This information isn't supported by current design - duplicate divertingNr */
++ /* originalCalledNr */
++ /* - not included - */
++
++#if 0
++ /* The originalCalledNr is unknown here. Its the same as divertingNr if the call *
++ * is diverted only once but we don't know if its diverted one ore more times. */
++
++ /* originalCalledNr */
++
++ /* tag component originalCalledNr (0xa2,len) */
+ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_2), buffer, i);
+ ASN1_PUSH(compstk, compsp, comp);
+- /* Redirecting information always not screened */
+- switch(call->redirectingpres) {
+- case PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
+- case PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN:
+- if (call->redirectingnum && strlen(call->redirectingnum)) {
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
+- ASN1_PUSH(compstk, compsp, comp);
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
+- ASN1_PUSH(compstk, compsp, comp);
+- ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, typeofnumber_from_q931(pri, call->redirectingplan >> 4));
+-
+- j = asn1_string_encode(ASN1_NUMERICSTRING, &buffer[i], len - i, 20, call->redirectingnum, strlen(call->redirectingnum));
+- if (j < 0)
++
++ size = rose_presented_number_unscreened_encode(pri, &buffer[i], call->redirectingpres, typeofnumber_from_q931(pri, (call->redirectingplan & 0x70) >> 4), call->redirectingnum);
++ if (size < 0)
++ return -1;
++ i += size;
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++#endif
++
++ /* redirectingName */
++ if (call->redirectingname[0]) {
++ /* tag component redirectingName (0xa3,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* tag component namePresentationAllowedSimple (0x80,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* namePresentationAllowedSimple, implicid NameData */
++ size = rose_namedata_encode(pri, &buffer[i], 1, call->redirectingname);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
++
++ /* originalCalledName */
++ /* - not included - */
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(call, Q931_SETUP, buffer, i, NULL, NULL))
++ return -1;
++
++ return 0;
++}
++
++static int rose_diverting_leg_information3_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
++{
++ int i = 0;
++ struct nameelements_name redirectionname = { "", CHARACTER_SET_UNKNOWN, 0 };
++ int presentation_allowed_indicator;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = sequence->data;
++ int size = 0;
++
++ /* Data checks */
++ if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
++ pri_message(pri, "Invalid DivertingLegInformation3Type argument\n");
++ return -1;
++ }
++
++ if (sequence->len == ASN1_LEN_INDEF) {
++ len -= 4; /* For the 2 extra characters at the end
++ and two characters of header */
++ } else
++ len -= 2;
++
++ do {
++ /* presentationAllowedIndicator */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_BOOLEAN, "Don't know what to do if presentationAllowedIndicator is of type 0x%x\n");
++ ASN1_GET_INTEGER(comp, presentation_allowed_indicator);
++ NEXT_COMPONENT(comp, i);
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received presentationAllowedIndicator: %d\n", presentation_allowed_indicator);
++
++ /* Type SEQUENCE specifies an ordered list of component types. *
++ * We decode all components but for simplicity we don't check the order. */
++ while (i < len) {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0):
++ /* redirectionName */
++ size = rose_name_decode(pri, comp->data, comp->len, &redirectionname);
++ if (size < 0)
+ return -1;
+-
+- i += j;
+- ASN1_FIXUP(compstk, compsp, buffer, i);
+- ASN1_FIXUP(compstk, compsp, buffer, i);
++ i += (size + 2);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received RedirectionName '%s', namepres %s(%d), characterset %s(%d)\n",
++ redirectionname.name, namepres_to_str(redirectionname.namepres), redirectionname.namepres,
++ characterset_to_str(redirectionname.characterset), redirectionname.characterset);
+ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] IMPLICIT Extension */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_2): /* [2] IMPLICIT SEQUENCE OF Extension */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "!! Ignoring DivertingLegInformation3 component 0x%X\n", comp->type);
++ NEXT_COMPONENT(comp, i);
++ break;
++ default:
++ pri_message(pri, "!! Invalid DivertingLegInformation3 component received 0x%X\n", comp->type);
++ return -1;
+ }
+- /* fall through */
+- case PRES_PROHIB_USER_NUMBER_PASSED_SCREEN:
+- case PRES_PROHIB_USER_NUMBER_NOT_SCREENED:
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), buffer, i);
+- break;
+- /* Don't know how to handle this */
+- case PRES_ALLOWED_NETWORK_NUMBER:
+- case PRES_PROHIB_NETWORK_NUMBER:
+- case PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN:
+- case PRES_PROHIB_USER_NUMBER_FAILED_SCREEN:
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), buffer, i);
+- break;
+- default:
+- pri_message(pri, "!! Undefined presentation value for redirecting number: %d\n", call->redirectingpres);
+- case PRES_NUMBER_NOT_AVAILABLE:
+- ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i);
+- break;
++ }
++
++ call->divleginfo3activeflag = 1;
++ if ((redirectionname.namepres != 0) && (presentation_allowed_indicator != 0)) {
++ libpri_copy_string(call->divertedtoname, redirectionname.name, sizeof(call->divertedtoname));
++ } else {
++ call->divertedtoname[0] = '\0';
++ }
++
++ return 0;
+ }
+- ASN1_FIXUP(compstk, compsp, buffer, i);
+-
+- /* Fix length of stacked components */
+- while(compsp > 0) {
++ while (0);
++
++ return -1;
++}
++
++int rose_diverting_leg_information3_encode(struct pri *pri, q931_call *call, int messagetype)
++{
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ unsigned char buffer[256];
++ int size;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Encode divertingLegInformation3\n");
++
++ /* Protocol Profile = 0x1f (Networking Extensions) (0x9f) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Network Facility Extension */
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ /* tag component NetworkFacilityExtension (0xaa, len ) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* sourceEntity (0x80,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* endPINX(0) */
++
++ /* destinationEntity (0x82,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* endPINX(0) */
+ ASN1_FIXUP(compstk, compsp, buffer, i);
+ }
+-
+- if (pri_call_apdu_queue(call, Q931_SETUP, buffer, i, NULL, NULL))
++
++ /* Network Protocol Profile */
++ /* - not included - */
++
++ /* Interpretation APDU (0x8b,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* discardAnyUnrecognisedInvokePdu(0) */
++
++ /* Service APDU(s): */
++
++ /* ROSE InvokePDU (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* ROSE InvokeID (0x02,0x01,invokeid) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
++
++ /* ROSE operationId (0x02,0x01,0x16)*/
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_DIVERTING_LEG_INFORMATION3);
++
++ /* constructor component (0x30,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* 'connectedpres' also indicates if name presentation is allowed */
++ if (((call->divertedtopres & 0x60) >> 5) == 0) {
++ /* presentation allowed */
++
++ /* presentationAllowedIndicator (0x01,0x01,0xff) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_BOOLEAN, buffer, i, 0xff); /* true(255) */
++
++ /* redirectionName */
++
++ /* tag component redirectionName (0xa0,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ if (call->divertedtoname[0]) {
++ /* tag component namePresentationAllowedSimple (0x80,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* namePresentationAllowedSimple, implicid NameData */
++ size = rose_namedata_encode(pri, &buffer[i], 1, call->divertedtoname);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ } else {
++ /* presentation restricted */
++
++ /* presentationAllowedIndicator (0x01,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_BOOLEAN, buffer, i, 0); /* false(0) */
++
++ /* - don't include redirectionName, component is optional - */
++ }
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(call, messagetype, buffer, i, NULL, NULL))
+ return -1;
+-
++
+ return 0;
+ }
+
+@@ -1644,7 +2828,7 @@
+ switch (comp1->type) {
+ /* TODO: charged number is untested - please report! */
+ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* chargedNumber (0xA0) */
+- if(rose_presented_number_unscreened_decode(pri, call, comp1->data, comp1->len, &chargednr) != 0)
++ if(rose_presented_number_unscreened_decode(pri, comp1->data, comp1->len, &chargednr) != 0)
+ return -1;
+ pri_message(pri, "!! not handled: Received ChargedNr '%s' \n", chargednr.partyaddress);
+ pri_message(pri, " ton = %d, pres = %d, npi = %d\n", chargednr.ton, chargednr.pres, chargednr.npi);
+@@ -1740,302 +2924,407 @@
+ }
+ /* End AOC */
+
+-static int rose_calling_name_decode(struct pri *pri, q931_call *call, struct rose_component *choice, int len)
++/* ===== Call Transfer Supplementary Service (ECMA-178) ===== */
++
++static int rose_call_transfer_complete_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
+ {
+ int i = 0;
+ struct rose_component *comp = NULL;
+- unsigned char *vdata = choice->data;
+- int characterSet = 1;
+- switch (choice->type) {
+- case ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE:
+- memcpy(call->callername, choice->data, choice->len);
+- call->callername[choice->len] = 0;
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Received simple calling name '%s'\n", call->callername);
+- return 0;
++ unsigned char *vdata = sequence->data;
++ int size = 0;
+
+- case ROSE_NAME_PRESENTATION_ALLOWED_EXTENDED:
+- do {
+- GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_OCTETSTRING, "Don't know what to do if nameData is of type 0x%x\n");
+- memcpy(call->callername, comp->data, comp->len);
+- call->callername[comp->len] = 0;
+- NEXT_COMPONENT(comp, i);
++ struct addressingdataelements_presentednumberscreened redirection_number;
++ struct nameelements_name redirectionname = { "", CHARACTER_SET_UNKNOWN, 0 };
++ char basiccallinfoelements[257] = "";
++ int call_status = 0; /* answered(0) */
++ int end_designation;
+
+- GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if CharacterSet is of type 0x%x\n");
+- ASN1_GET_INTEGER(comp, characterSet);
+- }
+- while (0);
+-
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Received extended calling name '%s', characterset %d\n", call->callername, characterSet);
+- return 0;
+- case ROSE_NAME_PRESENTATION_RESTRICTED_SIMPLE:
+- case ROSE_NAME_PRESENTATION_RESTRICTED_EXTENDED:
+- case ROSE_NAME_PRESENTATION_RESTRICTED_NULL:
+- case ROSE_NAME_NOT_AVAIL:
+- default:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "Do not handle argument of type 0x%X\n", choice->type);
+- return -1;
++ /* Data checks */
++ if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
++ pri_message(pri, "Invalid callTransferComplete argument. (Not a sequence)\n");
++ return -1;
+ }
+-}
+-/* ===== Call Transfer Supplementary Service (ECMA-178) ===== */
+
+-static int rose_party_number_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value)
+-{
+- int i = 0;
+- int size = 0;
+- struct rose_component *comp = NULL;
+- unsigned char *vdata = data;
++ if (sequence->len == ASN1_LEN_INDEF) {
++ len -= 4; /* For the 2 extra characters at the end
++ and two characters of header */
++ } else
++ len -= 2;
+
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " CT-Complete: len=%d\n", len);
+
++ /* CTCompleteArg SEQUENCE */
+ do {
++ /* endDesignation EndDesignation */
+ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid endDesignation type 0x%X of ROSE callTransferComplete component received\n");
++ ASN1_GET_INTEGER(comp, end_designation);
++ NEXT_COMPONENT(comp, i);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " CT-Complete: Received endDesignation=%s(%d)\n", enddesignation_to_str(end_designation), end_designation);
+
+- switch(comp->type) {
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] IMPLICIT NumberDigits -- default: unknownPartyNumber */
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PartyNumber: UnknownPartyNumber len=%d\n", len);
+- size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
+- if (size < 0)
+- return -1;
+- value->npi = PRI_NPI_UNKNOWN;
+- value->ton = PRI_TON_UNKNOWN;
+- break;
++ /* redirectionNumber PresentedNumberScreened */
++ GET_COMPONENT(comp, i, vdata, len);
++ size = rose_presented_number_screened_decode(pri, (u_int8_t *)comp, comp->len + 2, &redirection_number);
++ if (size < 0)
++ return -1;
++ comp->len = size;
++ NEXT_COMPONENT(comp, i);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " CT-Complete: Received redirectionNumber=%s\n", redirection_number.partyaddress);
+
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] IMPLICIT PublicPartyNumber */
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PartyNumber: PublicPartyNumber len=%d\n", len);
+- size = rose_public_party_number_decode(pri, call, comp->data, comp->len, value);
+- if (size < 0)
+- return -1;
+- value->npi = PRI_NPI_E163_E164;
+- break;
++ /* Type SEQUENCE specifies an ordered list of component types. *
++ * We decode all components but for simplicity we don't check the order. */
++ while (i < len) {
++ GET_COMPONENT(comp, i, vdata, len);
+
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] IMPLICIT NumberDigits -- not used: dataPartyNumber */
+- pri_message(pri, "!! PartyNumber: dataPartyNumber is reserved!\n");
+- size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
++ switch(comp->type) {
++ case (ASN1_APPLICATION):
++ /* basicCallInfoElements PSS1InformationElement OPTIONAL */
++ size = asn1_name_decode((u_int8_t *)comp, comp->len + 2, basiccallinfoelements, sizeof(basiccallinfoelements));
+ if (size < 0)
+ return -1;
+- value->npi = PRI_NPI_X121 /* ??? */;
+- value->ton = PRI_TON_UNKNOWN /* ??? */;
++ i += size;
++ if (pri->debug & PRI_DEBUG_APDU) {
++ int j;
++ pri_message(pri, " CT-Complete: Received basicCallInfoElements\n");
++ pri_message(pri, " ");
++ for (j = 0; basiccallinfoelements[j] != '\0'; j++)
++ pri_message(pri, "%02x ", (u_int8_t)basiccallinfoelements[j]);
++ pri_message(pri, "\n");
++ }
+ break;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_4): /* [4] IMPLICIT NumberDigits -- not used: telexPartyNumber */
+- pri_message(pri, "!! PartyNumber: telexPartyNumber is reserved!\n");
+- size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] namePresentationAllowedSimple */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] namePresentationAllowedExtended */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] namePresentationRestrictedSimple */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] namePresentationRestrictedExtended */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_4): /* [4] nameNotAvailable */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_7): /* [7] namePresentationRestrictedNull */
++ /* redirectionName Name OPTIONAL */
++ size = rose_name_decode(pri, (u_int8_t *)comp, comp->len + 2, &redirectionname);
+ if (size < 0)
+ return -1;
+- value->npi = PRI_NPI_F69 /* ??? */;
+- value->ton = PRI_TON_UNKNOWN /* ??? */;
++ i += size;
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " CT-Complete: Received RedirectionName '%s', namepres %s(%d), characterset %s(%d)\n",
++ redirectionname.name, namepres_to_str(redirectionname.namepres), redirectionname.namepres,
++ characterset_to_str(redirectionname.characterset), redirectionname.characterset);
+ break;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_5): /* [5] IMPLICIT PrivatePartyNumber */
++ case (ASN1_ENUMERATED):
++ /* callStatus CallStatus DEFAULT answered */
++ ASN1_GET_INTEGER(comp, call_status);
++ NEXT_COMPONENT(comp,i);
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PartyNumber: PrivatePartyNumber len=%d\n", len);
+- size = rose_private_party_number_decode(pri, call, comp->data, comp->len, value);
+- if (size < 0)
+- return -1;
+- value->npi = PRI_NPI_PRIVATE;
++ pri_message(pri, " CT-Complete: Received callStatus=%s(%d)\n", callstatus_to_str(call_status), call_status);
+ break;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_8): /* [8] IMPLICIT NumberDigits -- not used: nationalStandatdPartyNumber */
+- pri_message(pri, "!! PartyNumber: nationalStandardPartyNumber is reserved!\n");
+- size = rose_number_digits_decode(pri, call, comp->data, comp->len, value);
+- if (size < 0)
+- return -1;
+- value->npi = PRI_NPI_NATIONAL;
+- value->ton = PRI_TON_NATIONAL;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_9): /* [9] IMPLICIT Extension */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_10): /* [10] IMPLICIT SEQUENCE OF Extension */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "!! CT-Complete: Ignoring CallTransferComplete component 0x%X\n", comp->type);
++ NEXT_COMPONENT(comp, i);
+ break;
+-
+ default:
+- pri_message(pri, "Invalid PartyNumber component 0x%X\n", comp->type);
++ pri_message(pri, "!! CT-Complete: Invalid CallTransferComplete component received 0x%X\n", comp->type);
+ return -1;
++ }
+ }
+- ASN1_FIXUP_LEN(comp, size);
++
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PartyNumber: '%s' size=%d len=%d\n", value->partyaddress, size, len);
+- return size;
++ pri_message(pri, " CT-Complete: callStatus=%s(%d)\n", callstatus_to_str(call_status), call_status);
++
++ call->ctcompleteflag = 1;
++ if ((redirection_number.pres & PRES_RESTRICTION) == PRES_ALLOWED) {
++ libpri_copy_string(call->ctcompletenum, redirection_number.partyaddress, sizeof(call->ctcompletenum));
++ } else {
++ call->ctcompletenum[0] = '\0';
++ }
++ call->ctcompletepres = redirection_number.pres;
++ call->ctcompleteplan = ((redirection_number.ton & 0x07) << 4) | (redirection_number.npi & 0x0f);
++ call->ctcompletecallstatus = call_status;
++
++ if (redirectionname.namepres != 0) {
++ libpri_copy_string(call->ctcompletename, redirectionname.name, sizeof(call->ctcompletename));
++ } else {
++ call->ctcompletename[0] = '\0';
++ }
++
++ return 0;
+ }
+ while (0);
+
+ return -1;
+ }
+
+-
+-static int rose_number_screened_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberscreened *value)
++static int rose_call_transfer_complete_encode(struct pri *pri, q931_call *call, int call_status)
+ {
+- int i = 0;
+- int size = 0;
+- struct rose_component *comp = NULL;
+- unsigned char *vdata = data;
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ unsigned char buffer[256];
++ int size;
+
+- int scrind = -1;
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Encode CallTransferComplete\n");
+
+- do {
+- /* Party Number */
+- GET_COMPONENT(comp, i, vdata, len);
+- size = rose_party_number_decode(pri, call, (u_int8_t *)comp, comp->len + 2, (struct addressingdataelements_presentednumberunscreened*) value);
++ /* Protocol Profile = 0x1f (Networking Extensions) (0x9f) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Network Facility Extension */
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ /* tag component NetworkFacilityExtension (0xaa, len ) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* sourceEntity (0x80,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* endPINX(0) */
++
++ /* destinationEntity (0x82,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* endPINX(0) */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
++
++ /* Network Protocol Profile */
++ /* - not included - */
++
++ /* Interpretation APDU (0x8b,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* discardAnyUnrecognisedInvokePdu(0) */
++
++ /* Service APDU(s): */
++
++ /* ROSE InvokePDU (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* ROSE InvokeID (0x02,0x01,invokeid) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
++
++ /* ROSE operationId (0x02,0x01,0x0c)*/
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, ROSE_CALL_TRANSFER_COMPLETE);
++
++
++ /* CTCompleteArg */
++
++ /* constructor component (0x30,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++
++ /* endDesignation (0x0a,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 0); /* primaryEnd(0) */
++
++
++ /* redirectionNumber PresentedNumberScreened */
++
++ /* tag component presentationAllowedAddress (0xa0,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* presentationAllowedAddress, implicit NumberScreened */
++ size = rose_number_screened_encode(pri, &buffer[i], 1, typeofnumber_from_q931(pri, (call->connectedplan & 0x70) >> 4), call->connectedpres & 0x03, call->connectednum);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ /* basicCallInfoElements */
++ /* - not included - */
++
++#if 0
++ /* basicCallInfoElements (0x40,0x00) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_APPLICATION| ASN1_TAG_0), buffer, i);
++#endif
++
++ /* redirectionName */
++ if (call->connectedname[0]) {
++ /* tag component namePresentationAllowedSimple (0x80,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* namePresentationAllowedSimple, implicid NameData */
++ size = rose_namedata_encode(pri, &buffer[i], 1, call->connectedname);
+ if (size < 0)
+ return -1;
+- comp->len = size;
+- NEXT_COMPONENT(comp, i);
++ i += size;
+
+- /* Screening Indicator */
+- GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Don't know what to do with NumberScreened ROSE component type 0x%x\n");
+- ASN1_GET_INTEGER(comp, scrind);
+- // Todo: scrind = screeningindicator_for_q931(pri, scrind);
+- NEXT_COMPONENT(comp, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
+
+- value->scrind = scrind;
++ if (call_status) {
++ /* callStatus (0x0a,0x01,0x01) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 1); /* alerting(1) */
++ } else {
++ /* callStatus */
++ /* - not included, default: answered(0) - */
++#if 0
++ /* callStatus (0x0a,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_ENUMERATED, buffer, i, 0); /* answered(0) */
++#endif
++ }
+
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " NumberScreened: '%s' ScreeningIndicator=%d i=%d len=%d\n", value->partyaddress, scrind, i, len);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
+
+- return i-2; // We do not have a sequence header here.
+- }
+- while (0);
++ if (pri_call_apdu_queue(call, Q931_FACILITY, buffer, i, NULL, NULL))
++ return -1;
+
+- return -1;
++ return 0;
+ }
+
+-
+-static int rose_presented_number_screened_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberscreened *value)
++static int rose_call_transfer_active_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
+ {
+ int i = 0;
++ struct rose_component *comp = NULL;
++ unsigned char *vdata = sequence->data;
+ int size = 0;
+- struct rose_component *comp = NULL;
+- unsigned char *vdata = data;
+
+- /* Fill in default values */
+- value->ton = PRI_TON_UNKNOWN;
+- value->npi = PRI_NPI_UNKNOWN;
+- value->pres = -1; /* Data is not available */
++ struct addressingdataelements_presentedaddressscreened connectedaddress;
++ struct nameelements_name connectedname = { "", CHARACTER_SET_UNKNOWN, 0 };
++ char basiccallinfoelements[257] = "";
+
++ /* Data checks */
++ if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
++ pri_message(pri, "Invalid callTransferActive argument. (Not a sequence)\n");
++ return -1;
++ }
++
++ if (sequence->len == ASN1_LEN_INDEF) {
++ len -= 4; /* For the 2 extra characters at the end
++ and two characters of header */
++ } else
++ len -= 2;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " CT-Active: len=%d\n", len);
++
++ /* CTActiveArg SEQUENCE */
+ do {
++ /* connectedAddress PresentedAddressScreened */
+ GET_COMPONENT(comp, i, vdata, len);
++ size = rose_presented_address_screened_decode(pri, (u_int8_t *)comp, comp->len + 2, &connectedaddress);
++ if (size < 0)
++ return -1;
++ comp->len = size;
++ NEXT_COMPONENT(comp, i);
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, " CT-Active: Received connectedAddress=%s\n", connectedaddress.partyaddress);
++ }
+
+- switch(comp->type) {
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* [0] IMPLICIT presentationAllowedNumber */
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PresentedNumberScreened: presentationAllowedNumber comp->len=%d\n", comp->len);
+- value->pres = PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+- size = rose_number_screened_decode(pri, call, comp->data, comp->len, value);
++ /* Type SEQUENCE specifies an ordered list of component types. *
++ * We decode all components but for simplicity we don't check the order. */
++ while (i < len) {
++ GET_COMPONENT(comp, i, vdata, len);
++
++ switch(comp->type) {
++ case (ASN1_APPLICATION):
++ /* basiccallinfoelements PSS1InformationElement OPTIONAL */
++ size = asn1_name_decode((u_int8_t *)comp, comp->len + 2, basiccallinfoelements, sizeof(basiccallinfoelements));
+ if (size < 0)
+ return -1;
+- ASN1_FIXUP_LEN(comp, size);
+- return size + 2;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1): /* [1] IMPLICIT presentationRestricted */
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PresentedNumberScreened: presentationRestricted comp->len=%d\n", comp->len);
+- if (comp->len != 0) { /* must be NULL */
+- pri_error(pri, "!! Invalid PresentationRestricted component received (len != 0)\n");
+- return -1;
++ i += size;
++ if (pri->debug & PRI_DEBUG_APDU) {
++ int j;
++ pri_message(pri, " CT-Active: Received basicCallInfoElements\n");
++ pri_message(pri, " ");
++ for (j = 0; basiccallinfoelements[j] != '\0'; j++)
++ pri_message(pri, "%02x ", (u_int8_t)basiccallinfoelements[j]);
++ pri_message(pri, "\n");
+ }
+- value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
+- return 2;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] IMPLICIT numberNotAvailableDueToInterworking */
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PresentedNumberScreened: NumberNotAvailableDueToInterworking comp->len=%d\n", comp->len);
+- if (comp->len != 0) { /* must be NULL */
+- pri_error(pri, "!! Invalid NumberNotAvailableDueToInterworking component received (len != 0)\n");
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] namePresentationAllowedSimple */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] namePresentationAllowedExtended */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2): /* [2] namePresentationRestrictedSimple */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] namePresentationRestrictedExtended */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_4): /* [4] nameNotAvailable */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_7): /* [7] namePresentationRestrictedNull */
++ /* connectedName Name OPTIONAL */
++ size = rose_name_decode(pri, (u_int8_t *)comp, comp->len + 2, &connectedname);
++ if (size < 0)
+ return -1;
+- }
+- value->pres = PRES_NUMBER_NOT_AVAILABLE;
++ i += size;
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PresentedNumberScreened: numberNotAvailableDueToInterworking Type=0x%X i=%d len=%d size=%d\n", comp->type, i, len);
+- return 2;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_3): /* [3] IMPLICIT presentationRestrictedNumber */
++ pri_message(pri, " CT-Active: Received ConnectedName '%s', namepres %s(%d), characterset %s(%d)\n",
++ connectedname.name, namepres_to_str(connectedname.namepres), connectedname.namepres,
++ characterset_to_str(connectedname.characterset), connectedname.characterset);
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_9): /* [9] IMPLICIT Extension */
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_10): /* [10] IMPLICIT SEQUENCE OF Extension */
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " PresentedNumberScreened: presentationRestrictedNumber comp->len=%d\n", comp->len);
+- value->pres = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN;
+- size = rose_number_screened_decode(pri, call, comp->data, comp->len, value);
+- if (size < 0)
+- return -1;
+- ASN1_FIXUP_LEN(comp, size);
+- return size + 2;
++ pri_message(pri, "!! CT-Active: Ignoring CallTransferActive component 0x%X\n", comp->type);
++ NEXT_COMPONENT(comp, i);
++ break;
++ default:
++ pri_message(pri, "!! CT-Active: Invalid CallTransferActive component received 0x%X\n", comp->type);
++ return -1;
++ }
++ }
+
+- default:
+- pri_message(pri, "Invalid PresentedNumberScreened component 0x%X\n", comp->type);
++ call->ctactiveflag = 1;
++ if ((connectedaddress.pres & PRES_RESTRICTION) == PRES_ALLOWED) {
++ libpri_copy_string(call->ctactivenum, connectedaddress.partyaddress, sizeof(call->ctactivenum));
++ } else {
++ call->ctactivenum[0] = '\0';
+ }
+- return -1;
++ call->ctactivepres = connectedaddress.pres;
++ call->ctactiveplan = ((connectedaddress.ton & 0x07) << 4) | (connectedaddress.npi & 0x0f);
++
++ if (connectedname.namepres != 0) {
++ libpri_copy_string(call->ctactivename, connectedname.name, sizeof(call->ctactivename));
++ } else {
++ call->ctactivename[0] = '\0';
++ }
++
++ return 0;
+ }
+ while (0);
+
+ return -1;
+ }
+
+-
+-static int rose_call_transfer_complete_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
++#if 0
++static int rose_call_transfer_update_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
+ {
+ int i = 0;
+ struct rose_component *comp = NULL;
+ unsigned char *vdata = sequence->data;
+ int res = 0;
+
+- int end_designation = 0;
+ struct addressingdataelements_presentednumberscreened redirection_number;
+- char redirection_name[50] = "";
+- int call_status = 0;
+ redirection_number.partyaddress[0] = 0;
+- redirection_number.partysubaddress[0] = 0;
++ char redirection_name[51] = "";
+ call->callername[0] = 0;
+ call->callernum[0] = 0;
+
+-
+ /* Data checks */
+ if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
+- pri_message(pri, "Invalid callTransferComplete argument. (Not a sequence)\n");
++ pri_message(pri, "Invalid callTransferUpdate argument. (Not a sequence)\n");
+ return -1;
+ }
+
+ if (sequence->len == ASN1_LEN_INDEF) {
+- len -= 4; /* For the 2 extra characters at the end
+- * and two characters of header */
++ len -= 4; /* For the 2 extra characters at the end
++ and two characters of header */
+ } else
+ len -= 2;
+
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: len=%d\n", len);
++ pri_message(pri, " CT-Update: len=%d\n", len);
+
+ do {
+- /* End Designation */
+- GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid endDesignation type 0x%X of ROSE callTransferComplete component received\n");
+- ASN1_GET_INTEGER(comp, end_designation);
+- NEXT_COMPONENT(comp, i);
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: Received endDesignation=%d\n", end_designation);
+-
+-
+ /* Redirection Number */
+ GET_COMPONENT(comp, i, vdata, len);
+- res = rose_presented_number_screened_decode(pri, call, (u_int8_t *)comp, comp->len + 2, &redirection_number);
++ res = rose_presented_number_screened_decode(pri, (u_int8_t *)comp, comp->len + 2, &redirection_number);
+ if (res < 0)
+ return -1;
+ comp->len = res;
+ if (res > 2) {
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: Received redirectionNumber=%s\n", redirection_number.partyaddress);
++ pri_message(pri, " CT-Update: Received redirectionNumber=%s\n", redirection_number.partyaddress);
+ strncpy(call->callernum, redirection_number.partyaddress, 20);
+ call->callernum[20] = 0;
+ }
+ NEXT_COMPONENT(comp, i);
+
+-
+-#if 0 /* This one is optional. How do we check if it is there? */
+- /* Basic Call Info Elements */
+- GET_COMPONENT(comp, i, vdata, len);
+- NEXT_COMPONENT(comp, i);
+-#endif
+-
+-
+ /* Redirection Name */
+ GET_COMPONENT(comp, i, vdata, len);
+ res = asn1_name_decode((u_int8_t *)comp, comp->len + 2, redirection_name, sizeof(redirection_name));
+@@ -2047,16 +3336,14 @@
+ comp->len = res;
+ NEXT_COMPONENT(comp, i);
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: Received redirectionName '%s'\n", redirection_name);
++ pri_message(pri, " CT-Update: Received redirectionName '%s'\n", redirection_name);
+
+
+- /* Call Status */
++#if 0 /* This one is optional. How do we check if it is there? */
++ /* Basic Call Info Elements */
+ GET_COMPONENT(comp, i, vdata, len);
+- CHECK_COMPONENT(comp, ASN1_ENUMERATED, "Invalid callStatus type 0x%X of ROSE callTransferComplete component received\n");
+- ASN1_GET_INTEGER(comp, call_status);
+ NEXT_COMPONENT(comp, i);
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: Received callStatus=%d\n", call_status);
++#endif
+
+
+ /* Argument Extension */
+@@ -2078,8 +3365,8 @@
+ comp->len = res;
+
+ default:
+- pri_message(pri, " CT-Complete: !! Unknown argumentExtension received 0x%X\n", comp->type);
+- return -1;
++ pri_message(pri, " CT-Update: !! Unknown argumentExtension received 0x%X\n", comp->type);
++ return -1;
+ }
+ #else
+ GET_COMPONENT(comp, i, vdata, len);
+@@ -2088,7 +3375,7 @@
+ #endif
+
+ if(i < len)
+- pri_message(pri, " CT-Complete: !! not all information is handled !! i=%d / len=%d\n", i, len);
++ pri_message(pri, " CT-Update: !! not all information is handled !! i=%d / len=%d\n", i, len);
+
+ return 0;
+ }
+@@ -2096,26 +3383,422 @@
+
+ return -1;
+ }
++#endif
+
++/* ===== End Call Transfer Supplementary Service (ECMA-178) ===== */
+
+-static int rose_call_transfer_update_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
++
++
++static int rose_calling_name_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
+ {
++ struct nameelements_name callingname;
++ int res;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle callingName\n");
++
++ res = rose_name_decode(pri, (u_int8_t *)sequence, sequence->len + 2, &callingname);
++ if (res < 0)
++ return -1;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received CallingName '%s', namepres: %s(%d), characterset %s(%d)\n",
++ callingname.name, namepres_to_str(callingname.namepres), callingname.namepres,
++ characterset_to_str(callingname.characterset), callingname.characterset);
++
++ if (callingname.namepres >= 0) {
++ libpri_copy_string(call->callername, callingname.name, sizeof(call->callername));
++ }
++
++ return 0;
++}
++
++static int rose_called_name_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
++{
++ struct nameelements_name calledname;
++ int res;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle calledName\n");
++
++ res = rose_name_decode(pri, (u_int8_t *)sequence, sequence->len + 2, &calledname);
++ if (res < 0)
++ return -1;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received CalledName '%s', namepres %s(%d), characterset %s(%d)\n",
++ calledname.name, namepres_to_str(calledname.namepres), calledname.namepres,
++ characterset_to_str(calledname.characterset), calledname.characterset);
++
++ if (calledname.namepres != 0) {
++ libpri_copy_string(call->calledname, calledname.name, sizeof(call->calledname));
++ } else {
++ call->calledname[0] = '\0';
++ }
++
++ return 0;
++}
++
++int rose_called_name_encode(struct pri *pri, q931_call *call, int messagetype)
++{
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ unsigned char buffer[256];
++ int size;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Encode calledName\n");
++
++ /* Protocol Profile = 0x1f (Networking Extensions) (0x9f) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Network Facility Extension */
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ /* tag component NetworkFacilityExtension (0xaa, len ) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* sourceEntity (0x80,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* endPINX(0) */
++
++ /* destinationEntity (0x82,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* endPINX(0) */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
++
++ /* Network Protocol Profile */
++ /* - not included - */
++
++ /* Interpretation APDU (0x8b,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* discardAnyUnrecognisedInvokePdu(0) */
++
++ /* Service APDU(s): */
++
++ /* ROSE InvokePDU (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* ROSE InvokeID (0x02,0x01,invokeid) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
++
++ /* ROSE operationId (0x02,0x01,0x02)*/
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, SS_CNOP_CALLEDNAME);
++
++ /* tag component namePresentationAllowedSimple (0x80,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* namePresentationAllowedSimple, implicid NameData */
++ size = rose_namedata_encode(pri, &buffer[i], 1, call->connectedname);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(call, messagetype, buffer, i, NULL, NULL))
++ return -1;
++
++ return 0;
++}
++
++static int rose_connected_name_decode(struct pri *pri, q931_call *call, struct rose_component *sequence, int len)
++{
++ struct nameelements_name connectedname;
++ int res;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle connectedName\n");
++
++ res = rose_name_decode(pri, (u_int8_t *)sequence, sequence->len + 2, &connectedname);
++ if (res < 0)
++ return -1;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Received ConnectedName '%s', namepres %s(%d), characterset %s(%d)\n",
++ connectedname.name, namepres_to_str(connectedname.namepres), connectedname.namepres,
++ characterset_to_str(connectedname.characterset), connectedname.characterset);
++
++ if (connectedname.namepres != 0) {
++ libpri_copy_string(call->connectedname, connectedname.name, sizeof(call->connectedname));
++ } else {
++ call->connectedname[0] = '\0';
++ }
++
++ return 0;
++}
++
++int rose_connected_name_encode(struct pri *pri, q931_call *call, int messagetype)
++{
++ int i = 0, compsp = 0;
++ struct rose_component *comp, *compstk[10];
++ unsigned char buffer[256];
++ int size;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Encode connectedName\n");
++
++ /* Protocol Profile = 0x1f (Networking Extensions) (0x9f) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Network Facility Extension */
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ /* tag component NetworkFacilityExtension (0xaa, len ) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* sourceEntity (0x80,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* endPINX(0) */
++
++ /* destinationEntity (0x82,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* endPINX(0) */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ }
++
++ /* Network Protocol Profile */
++ /* - not included - */
++
++ /* Interpretation APDU (0x8b,0x01,0x00) */
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* discardAnyUnrecognisedInvokePdu(0) */
++
++ /* Service APDU(s): */
++
++ /* ROSE InvokePDU (0xa1,len) */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* ROSE InvokeID (0x02,0x01,invokeid) */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri));
++
++ /* ROSE operationId (0x02,0x01,0x02)*/
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, SS_CNOP_CONNECTEDNAME);
++
++ /* tag component namePresentationAllowedSimple (0x80,len) */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* namePresentationAllowedSimple, implicid NameData */
++ size = rose_namedata_encode(pri, &buffer[i], 1, call->connectedname);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(call, messagetype, buffer, i, NULL, NULL))
++ return -1;
++
++ return 0;
++}
++
++/* ===== Begin Call Completion Supplementary Service (ETS 300 366/ECMA 186) ===== */
++/* operationId e.g. QSIG_CCBSRINGOUT, QSIG_CC_CANCEL */
++int add_qsigCcInv_facility_ie (struct pri *pri, q931_call *c, int messagetype)
++{
+ int i = 0;
++ unsigned char buffer[256];
++ struct rose_component *comp = NULL, *compstk[10];
++ int compsp = 0;
++ u_int8_t operationId = c->ccoperation;
++
++ /* 1 Byte 0x80 | 0x1F = 9F Protocol Profile */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Interpretation component */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i); /* 2. Byte NEtwork Facility Extension 0xAA = ASN1_CONTEXT_SPECIFIC(0x80) | (ASN1_CONSTRUCTOR 0x20) 0x0A (Tag laut Standard) */
++ ASN1_PUSH(compstk, compsp, comp);
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* (0x80, 0x01(len), 0x00) endPTNX */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* (0x82, 0x01(len), 0x00) endPTNX */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* 0x8B, 0x01(len), 0x00 discard */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i); /* 0xA1, 0xXX (len of Invoke Sequenz) invoke APDU */
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* Invoke ID */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri)); /* 0x02 0x01 0xXX */
++
++ /* Operation ID: QSIG_CCBSRINGOUT, QSIG_CC_CANCEL */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, operationId); /* 0x02 0x01 0x1f/0x1c */
++
++ /* CcExtension */
++ ASN1_ADD_SIMPLE(comp, ASN1_NULL, buffer, i); /* 0x05 0x00 */
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(c, messagetype, buffer, i, NULL, NULL))
++ return -1;
++
++ return 0;
++}
++
++static int rose_cc_ringout_inv_decode(struct pri *pri, struct qsig_cc_extension *cc_extension, struct rose_component *choice, int len) {
++ int i = 0;
++ cc_extension->cc_extension_tag = 0;
++
++ do {
++ switch(choice->type) {
++ case (ASN1_NULL): /* none NULL */
++ cc_extension->cc_extension_tag = ASN1_NULL;
++ return 0;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_14): /* single [14] IMPLICIT Extension */
++ cc_extension->cc_extension_tag = ASN1_TAG_14;
++ return 0;
++
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_15): /* multiple [15] IMPLICIT SEQUENCE OF Extension */
++ cc_extension->cc_extension_tag = ASN1_TAG_15;
++ return 0;
++
++ default:
++ if (choice->type == 0 && choice->len == 0) {
++ return 0;
++ }
++ pri_message(pri, "!! Invalid ss-cc-optional-Arg component received 0x%X\n", choice->type);
++ return -1;
++ }
++
++ if (i < len)
++ pri_message(pri, " ss-cc-extension: !! not all information is handled !! i=%d / len=%d\n", i, len);
++
++ return 0;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_cc_optional_arg_decode(struct pri *pri, q931_call *call, struct qsig_cc_optional_arg *cc_optional_arg , struct rose_component *choice, int len) {
++ int i = 0;
++ int res = 0;
+ struct rose_component *comp = NULL;
++ unsigned char *vdata = choice->data;
++ struct addressingdataelements_presentednumberunscreened numberA;
++ struct addressingdataelements_presentednumberunscreened numberB;
++
++ cc_optional_arg->cc_extension.cc_extension_tag = 0;
++ cc_optional_arg->number_A[0] = '\0';
++ cc_optional_arg->number_B[0] = '\0';
++
++ do {
++ switch(choice->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_0): /* fullArg [0] IMPLICIT SEQUENCE */
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " ss-cc-optional-Arg: len=%d\n", len);
++
++ numberA.partyaddress[0] = '\0';
++
++ /* numberA */
++ GET_COMPONENT(comp, i, vdata, len);
++ res += rose_party_number_decode(pri, (u_int8_t *)comp, comp->len + 2, &numberA);
++ if (res < 0)
++ return -1;
++ comp->len = res;
++ if (res > 2) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " ss-cc-optional-Arg: Received numberA=%s\n", numberA.partyaddress);
++ strncpy(cc_optional_arg->number_A, numberA.partyaddress, 20);
++ cc_optional_arg->number_A[20] = '\0';
++ }
++ NEXT_COMPONENT(comp, i);
++
++ numberB.partyaddress[0] = '\0';
++
++ /* numberB */
++ GET_COMPONENT(comp, i, vdata, len);
++ res = rose_party_number_decode(pri, (u_int8_t *)comp, comp->len + 2, &numberB);
++ if (res < 0)
++ return -1;
++ comp->len = res;
++ if (res > 2) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " ss-cc-optional-Arg: Received numberB=%s\n", numberB.partyaddress);
++ strncpy(cc_optional_arg->number_B, numberB.partyaddress, 20);
++ cc_optional_arg->number_B[20] = '\0';
++ }
++ NEXT_COMPONENT(comp, i);
++
++ /* service */ /* PSS1InformationElement */
++ GET_COMPONENT(comp, i, vdata, len);
++ NEXT_COMPONENT(comp, i);
++
++ /* optional */
++ for (; i < len; NEXT_COMPONENT(comp, i)) {
++ GET_COMPONENT(comp, i, vdata, len);
++ switch(comp->type) {
++ case (ASN1_NULL): /* */
++ cc_optional_arg->cc_extension.cc_extension_tag = ASN1_NULL;
++ NEXT_COMPONENT(comp, i);
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_14): /* */
++ NEXT_COMPONENT(comp, i);
++ break;
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_15): /* */
++ NEXT_COMPONENT(comp, i);
++ break;
++ default:
++ if (comp->type == 0 && comp->len == 0) {
++ return 0;
++ break; /* Found termination characters */
++ }
++ pri_message(pri, "!! Invalid ss-cc-optional-Arg component received 0x%X\n", comp->type);
++ return -1;
++ }
++ }
++
++ if (i < len)
++ pri_message(pri, " ss-cc-optional-Arg: !! not all information is handled !! i=%d / len=%d\n", i, len);
++
++ return 0;
++
++ /* extArg CcExtension */
++ case (ASN1_NULL): /* none NULL */
++ cc_optional_arg->cc_extension.cc_extension_tag = ASN1_NULL;
++ return 0;
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_14): /* single [14] IMPLICIT Extension */
++ cc_optional_arg->cc_extension.cc_extension_tag = ASN1_TAG_14;
++ return 0;
++
++
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_15): /* multiple [15] IMPLICIT SEQUENCE OF Extension */
++ cc_optional_arg->cc_extension.cc_extension_tag = ASN1_TAG_15;
++ return 0;
++
++ default:
++ if (choice->type == 0 && choice->len == 0) {
++ return 0;
++ }
++ pri_message(pri, "!! Invalid ss-cc-optional-Arg component received 0x%X\n", choice->type);
++ return -1;
++ }
++
++ if (i < len)
++ pri_message(pri, " ss-cc-optional-Arg: !! not all information is handled !! i=%d / len=%d\n", i, len);
++
++ return 0;
++ }
++ while (0);
++
++ return -1;
++}
++
++static int rose_cc_request_result_decode(struct pri *pri, struct qsig_cc_request_res *cc_request_res , struct rose_component *sequence, int len)
++{
++ int i = 0;
++ struct rose_component *comp = NULL;
+ unsigned char *vdata = sequence->data;
+- int res = 0;
+
+- struct addressingdataelements_presentednumberscreened redirection_number;
+- redirection_number.partyaddress[0] = 0;
+- redirection_number.partysubaddress[0] = 0;
+- char redirection_name[50] = "";
+- call->callername[0] = 0;
+- call->callernum[0] = 0;
++ cc_request_res->no_path_reservation = 0; /* Default FALSE */
++ cc_request_res->retain_service = 0; /* Default FALSE */
++ cc_request_res->cc_extension.cc_extension_tag = 0;
+
+-
+ /* Data checks */
+ if (sequence->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
+- pri_message(pri, "Invalid callTransferComplete argument. (Not a sequence)\n");
++ pri_message(pri, "Invalid cc request result argument. (Not a sequence)\n");
+ return -1;
+ }
+
+@@ -2126,75 +3809,55 @@
+ len -= 2;
+
+ if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: len=%d\n", len);
++ pri_message(pri, " CC-request-Return-Result: len=%d\n", len);
+
+ do {
+- /* Redirection Number */
+- GET_COMPONENT(comp, i, vdata, len);
+- res = rose_presented_number_screened_decode(pri, call, (u_int8_t *)comp, comp->len + 2, &redirection_number);
+- if (res < 0)
+- return -1;
+- comp->len = res;
+- if (res > 2) {
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: Received redirectionNumber=%s\n", redirection_number.partyaddress);
+- strncpy(call->callernum, redirection_number.partyaddress, 20);
+- call->callernum[20] = 0;
+- }
+- NEXT_COMPONENT(comp, i);
++ /* defaults and optional */
++ for (; i < len; NEXT_COMPONENT(comp, i)) {
++ GET_COMPONENT(comp, i, vdata, len);
++ switch(comp->type) {
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0):
++ /* no-path-reservation */
++ ASN1_GET_INTEGER(comp, cc_request_res->no_path_reservation);
++ NEXT_COMPONENT(comp, i);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " cc request result: Received noPathReservation=%d\n", cc_request_res->no_path_reservation);
++ break;
+
+- /* Redirection Name */
+- GET_COMPONENT(comp, i, vdata, len);
+- res = asn1_name_decode((u_int8_t *)comp, comp->len + 2, redirection_name, sizeof(redirection_name));
+- if (res < 0)
+- return -1;
+- memcpy(call->callername, comp->data, comp->len);
+- call->callername[comp->len] = 0;
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
+- NEXT_COMPONENT(comp, i);
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " CT-Complete: Received redirectionName '%s'\n", redirection_name);
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1):
++ /* retain_service */
++ ASN1_GET_INTEGER(comp, cc_request_res->retain_service);
++ NEXT_COMPONENT(comp, i);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " cc request result: Received retainService=%d\n", cc_request_res->retain_service);
++ break;
+
++ case (ASN1_NULL): /* */
++ cc_request_res->cc_extension.cc_extension_tag = ASN1_NULL;
++ NEXT_COMPONENT(comp, i);
++ break;
+
+-#if 0 /* This one is optional. How do we check if it is there? */
+- /* Basic Call Info Elements */
+- GET_COMPONENT(comp, i, vdata, len);
+- NEXT_COMPONENT(comp, i);
+-#endif
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_14):
++ cc_request_res->cc_extension.cc_extension_tag = ASN1_TAG_14;
++ NEXT_COMPONENT(comp, i);
++ break;
+
++ case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_15):
++ cc_request_res->cc_extension.cc_extension_tag = ASN1_TAG_15;
++ NEXT_COMPONENT(comp, i);
++ break;
+
+- /* Argument Extension */
+-#if 0 /* Not supported */
+- GET_COMPONENT(comp, i, vdata, len);
+- switch (comp->type) {
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_9): /* [9] IMPLICIT Extension */
+- res = rose_extension_decode(pri, call, comp->data, comp->len, &redirection_number);
+- if (res < 0)
+- return -1;
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
+-
+- case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_10): /* [10] IMPLICIT SEQUENCE OF Extension */
+- res = rose_sequence_of_extension_decode(pri, call, comp->data, comp->len, &redirection_number);
+- if (res < 0)
+- return -1;
+- ASN1_FIXUP_LEN(comp, res);
+- comp->len = res;
+-
+ default:
+- pri_message(pri, " CT-Complete: !! Unknown argumentExtension received 0x%X\n", comp->type);
++ if (comp->type == 0 && comp->len == 0) {
++ break; /* Found termination characters */
++ }
++ pri_message(pri, "!! Invalid ss-cc-optional-Arg component received 0x%X\n", comp->type);
+ return -1;
++ }
+ }
+-#else
+- GET_COMPONENT(comp, i, vdata, len);
+- ASN1_FIXUP_LEN(comp, res);
+- NEXT_COMPONENT(comp, i);
+-#endif
+
+- if(i < len)
+- pri_message(pri, " CT-Complete: !! not all information is handled !! i=%d / len=%d\n", i, len);
+-
++ if (i < len)
++ pri_message(pri, " ss-cc-optional-Arg: !! not all information is handled !! i=%d / len=%d\n", i, len);
+ return 0;
+ }
+ while (0);
+@@ -2202,11 +3865,18 @@
+ return -1;
+ }
+
++static int rose_ccbs_request_result_decode(struct pri *pri, struct qsig_cc_request_res *cc_request_res , struct rose_component *sequence, int len)
++{
++ return rose_cc_request_result_decode(pri, cc_request_res , sequence, len);
++}
+
+-/* ===== End Call Transfer Supplementary Service (ECMA-178) ===== */
++static int rose_ccnr_request_result_decode(struct pri *pri, struct qsig_cc_request_res *cc_request_res , struct rose_component *sequence, int len)
++{
++ return rose_cc_request_result_decode(pri, cc_request_res , sequence, len);
++}
++/* ===== End Call Completion Supplementary Service (ETS 300 366/ECMA 186) ===== */
+
+
+-
+ int rose_reject_decode(struct pri *pri, q931_call *call, q931_ie *ie, unsigned char *data, int len)
+ {
+ int i = 0;
+@@ -2267,7 +3937,7 @@
+
+ return 0;
+ } else {
+- pri_message(pri, "Unable to handle return result on switchtype %d!\n", pri->switchtype);
++ pri_message(pri, "Unable to handle reject on switchtype %d!\n", pri->switchtype);
+ return -1;
+ }
+
+@@ -2275,6 +3945,20 @@
+
+ return -1;
+ }
++
++
++static struct subcommand *get_ptr_subcommand(struct subcommands *sub)
++{
++ if (sub->counter_subcmd < MAX_SUBCOMMANDS) {
++ int count = sub->counter_subcmd;
++ sub->counter_subcmd++;
++ return &sub->subcmd[count];
++ }
++
++ return NULL;
++}
++
++
+ int rose_return_error_decode(struct pri *pri, q931_call *call, q931_ie *ie, unsigned char *data, int len)
+ {
+ int i = 0;
+@@ -2283,6 +3967,7 @@
+ unsigned char *vdata = data;
+ struct rose_component *comp = NULL;
+ char *invokeidstr, *errorstr;
++ struct subcommand *c_subcmd;
+
+ do {
+ /* Invoke ID stuff */
+@@ -2329,9 +4014,39 @@
+ pri_error(pri, "\tERROR: %s\n", errorstr);
+
+ return 0;
++ } else if (pri->switchtype == PRI_SWITCH_QSIG) {
++ switch (errorvalue) {
++ case 1008:
++ errorstr = "Unspecified";
++ break;
++ case 1012:
++ errorstr = "Remote user busy again";
++ break;
++ case 1013:
++ errorstr = "Failure to match";
++ break;
++ default:
++ errorstr = "Unknown";
++ }
++
++ c_subcmd = get_ptr_subcommand(&call->subcmds);
++ if (!c_subcmd) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE RETURN ERROR %i - more than %d facilities !\n", errorvalue, MAX_SUBCOMMANDS);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ }
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE RETURN RESULT %i: %s\n", errorvalue, errorstr);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ c_subcmd->cmd = CMD_CC_ERROR;
++ c_subcmd->cc_error.error_value = errorvalue;
++ return 0;
+ } else {
+- pri_message(pri, "Unable to handle return result on switchtype %d!\n", pri->switchtype);
+- return -1;
++ pri_message(pri, "Unable to handle return error on switchtype %d!\n", pri->switchtype);
+ }
+
+ } while(0);
+@@ -2346,6 +4061,8 @@
+ int invokeidvalue = -1;
+ unsigned char *vdata = data;
+ struct rose_component *comp = NULL;
++ int res;
++ struct subcommand *c_subcmd;
+
+ do {
+ /* Invoke ID stuff */
+@@ -2392,11 +4109,90 @@
+ return -1;
+ }
+ } else if (pri->switchtype == PRI_SWITCH_QSIG) {
+- switch (invokeidvalue) {
+- case 0x13:
+- if (pri->debug & PRI_DEBUG_APDU) pri_message(pri, "Successfully completed QSIG CF callRerouting!\n");
++ int operation_tag;
++
++ /* sequence is optional */
++ if (i >= len)
+ return 0;
++
++ /* Data checks, sequence is optional */
++ GET_COMPONENT(comp, i, vdata, len);
++ if (comp->type != (ASN1_CONSTRUCTOR | ASN1_SEQUENCE)) { /* Constructed Sequence */
++ pri_message(pri, "No arguments on cc-return result\n");
++ return 0;
+ }
++
++ if (comp->len == ASN1_LEN_INDEF) {
++ len -= 2; /* For the 2 extra characters at the end*/
++ }
++
++ /* Traverse the contents of this sequence */
++ SUB_COMPONENT(comp, i);
++
++ /* Operation Tag */
++ GET_COMPONENT(comp, i, vdata, len);
++ CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if second ROSE component is of type 0x%x\n");
++ ASN1_GET_INTEGER(comp, operation_tag);
++ NEXT_COMPONENT(comp, i);
++
++ /* No argument - return with error */
++ if (i >= len)
++ return -1;
++
++ /* Arguement Tag */
++ GET_COMPONENT(comp, i, vdata, len);
++ if (!comp->type)
++ return -1;
++
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " [ Handling operation %d ]\n", operation_tag);
++ switch (operation_tag) {
++ case QSIG_CF_CALLREROUTING:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "Successfully completed QSIG CF callRerouting!\n");
++ return 0;
++
++ case QSIG_CC_CCBSREQUEST:
++ c_subcmd = get_ptr_subcommand(&call->subcmds);
++ if (!c_subcmd) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: return_result CcCcbsRequest - more than %d facilities !\n", operation_tag, MAX_SUBCOMMANDS);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ }
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CcCcbsRequest\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ c_subcmd->cmd = CMD_CC_CCBSREQUEST_RR;
++ res = rose_ccbs_request_result_decode(pri, &c_subcmd->cc_ccbs_rr.cc_request_res, comp, len-i);
++ return res;
++
++ case QSIG_CC_CCNRREQUEST:
++ c_subcmd = get_ptr_subcommand(&call->subcmds);
++ if (!c_subcmd) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: return_result CcCcnrRequest - more than %d facilities !\n", operation_tag, MAX_SUBCOMMANDS);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ }
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CcCcnrRequest\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ c_subcmd->cmd = CMD_CC_CCNRREQUEST_RR;
++ res = rose_ccnr_request_result_decode(pri, &c_subcmd->cc_ccnr_rr.cc_request_res, comp, len-i);
++ return res;
++
++ default:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ }
+ } else {
+ pri_message(pri, "Unable to handle return result on switchtype %d!\n", pri->switchtype);
+ return -1;
+@@ -2414,6 +4210,7 @@
+ int operation_tag;
+ unsigned char *vdata = data;
+ struct rose_component *comp = NULL, *invokeid = NULL, *operationid = NULL;
++ struct subcommand *c_subcmd;
+
+ do {
+ /* Invoke ID stuff */
+@@ -2444,126 +4241,294 @@
+
+ if (pri->debug & PRI_DEBUG_APDU)
+ pri_message(pri, " [ Handling operation %d ]\n", operation_tag);
+- switch (operation_tag) {
+- case SS_CNID_CALLINGNAME:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, " Handle Name display operation\n");
+- return rose_calling_name_decode(pri, call, comp, len-i);
+- case ROSE_CALL_TRANSFER_IDENTIFY:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "ROSE %i: CallTransferIdentify - not handled!\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- return -1;
+- case ROSE_CALL_TRANSFER_ABANDON:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "ROSE %i: CallTransferAbandon - not handled!\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- return -1;
+- case ROSE_CALL_TRANSFER_INITIATE:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "ROSE %i: CallTransferInitiate - not handled!\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- return -1;
+- case ROSE_CALL_TRANSFER_SETUP:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "ROSE %i: CallTransferSetup - not handled!\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- return -1;
+- case ROSE_CALL_TRANSFER_ACTIVE:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "ROSE %i: CallTransferActive - not handled!\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- return -1;
+- case ROSE_CALL_TRANSFER_COMPLETE:
+- if (pri->debug & PRI_DEBUG_APDU)
+- {
+- pri_message(pri, "ROSE %i: Handle CallTransferComplete\n", operation_tag);
++
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++
++ switch (operation_tag) {
++ case SS_CNID_CALLINGNAME:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: Handle CallingName\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return rose_calling_name_decode(pri, call, comp, len-i);
++ case SS_CNOP_CALLEDNAME:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: Handle CalledName\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return rose_called_name_decode(pri, call, comp, len-i);
++ case SS_CNOP_CONNECTEDNAME:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: Handle ConnectedName\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return rose_connected_name_decode(pri, call, comp, len-i);
++ case ROSE_CALL_TRANSFER_IDENTIFY:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferIdentify - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return rose_call_transfer_complete_decode(pri, call, comp, len-i);
+- case ROSE_CALL_TRANSFER_UPDATE:
+- if (pri->debug & PRI_DEBUG_APDU)
+- {
+- pri_message(pri, "ROSE %i: Handle CallTransferUpdate\n", operation_tag);
++ return -1;
++ case ROSE_CALL_TRANSFER_ABANDON:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferAbandon - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return rose_call_transfer_update_decode(pri, call, comp, len-i);
+- case ROSE_SUBADDRESS_TRANSFER:
+- if (pri->debug & PRI_DEBUG_APDU)
+- pri_message(pri, "ROSE %i: SubaddressTransfer - not handled!\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- return -1;
+- case ROSE_DIVERTING_LEG_INFORMATION2:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: Handle CallingName\n", operation_tag);
+- dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return rose_diverting_leg_information2_decode(pri, call, comp, len-i);
+- case ROSE_AOC_NO_CHARGING_INFO_AVAILABLE:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC No Charging Info Available - not handled!", operation_tag);
+- dump_apdu (pri, comp->data, comp->len);
+- }
+- return -1;
+- case ROSE_AOC_CHARGING_REQUEST:
+- return aoc_aoce_charging_request_decode(pri, call, (u_int8_t *)comp, comp->len + 2);
+- case ROSE_AOC_AOCS_CURRENCY:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC-S Currency - not handled!", operation_tag);
++ return -1;
++ case ROSE_CALL_TRANSFER_INITIATE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferInitiate - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return -1;
+- case ROSE_AOC_AOCS_SPECIAL_ARR:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC-S Special Array - not handled!", operation_tag);
++ return -1;
++ case ROSE_CALL_TRANSFER_SETUP:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferSetup - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return -1;
+- case ROSE_AOC_AOCD_CURRENCY:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC-D Currency - not handled!", operation_tag);
++ return -1;
++ case ROSE_CALL_TRANSFER_ACTIVE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: Handle CallTransferActive\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return -1;
+- case ROSE_AOC_AOCD_CHARGING_UNIT:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC-D Charging Unit - not handled!", operation_tag);
++ return rose_call_transfer_active_decode(pri, call, comp, len-i);
++ case ROSE_CALL_TRANSFER_COMPLETE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CallTransferComplete\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return rose_call_transfer_complete_decode(pri, call, comp, len-i);
++ case ROSE_CALL_TRANSFER_UPDATE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferUpdate - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return -1;
+- case ROSE_AOC_AOCE_CURRENCY:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC-E Currency - not handled!", operation_tag);
++ return -1;
++ case ROSE_SUBADDRESS_TRANSFER:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: SubaddressTransfer - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
+- }
+- return -1;
+- case ROSE_AOC_AOCE_CHARGING_UNIT:
+- return aoc_aoce_charging_unit_decode(pri, call, (u_int8_t *)comp, comp->len + 2);
+- if (0) { /* the following function is currently not used - just to make the compiler happy */
+- aoc_aoce_charging_unit_encode(pri, call, call->aoc_units); /* use this function to forward the aoc-e on a bridged channel */
++ return -1;
++ case ROSE_DIVERTING_LEG_INFORMATION1:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle DivertingLegInformation1\n");
++ return rose_diverting_leg_information1_decode(pri, call, comp, len-i);
++ case ROSE_DIVERTING_LEG_INFORMATION2:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle DivertingLegInformation2\n");
++ return rose_diverting_leg_information2_decode(pri, call, comp, len-i);
++ case ROSE_DIVERTING_LEG_INFORMATION3:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle DivertingLegInformation3\n");
++ return rose_diverting_leg_information3_decode(pri, call, comp, len-i);
++ case SS_ANFPR_PATHREPLACEMENT:
++ /* Clear Queue */
++ res = pri_call_apdu_queue_cleanup(call->bridged_call);
++ if (res) {
++ pri_message(pri, "Could not Clear queue ADPU\n");
++ return -1;
++ }
++ anfpr_pathreplacement_respond(pri, call, ie);
++ break;
++ case QSIG_CC_CCBSREQUEST:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcbsRequest - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case QSIG_CC_CCNRREQUEST:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcnrRequest - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case QSIG_CC_CANCEL:
++ c_subcmd = get_ptr_subcommand(&call->subcmds);
++ if (!c_subcmd) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcCancel - more than %d facilities !\n", operation_tag, MAX_SUBCOMMANDS);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ }
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CcCancel\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ c_subcmd->cmd = CMD_CC_CANCEL_INV;
++ res = rose_cc_optional_arg_decode(pri, call, &c_subcmd->cc_cancel_inv.cc_optional_arg, comp, len-i);
++ return res;
++ case QSIG_CC_EXECPOSIBLE:
++ c_subcmd = get_ptr_subcommand(&call->subcmds);
++ if (!c_subcmd) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcExecposible - more than %d facilities !\n", operation_tag, MAX_SUBCOMMANDS);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ }
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CcExecposible\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ c_subcmd->cmd = CMD_CC_EXECPOSIBLE_INV;
++ res = rose_cc_optional_arg_decode(pri, call, &c_subcmd->cc_execposible_inv.cc_optional_arg, comp, len-i);
++ return res;
++ case QSIG_CC_PATHRESERVE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcPathreserve - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case QSIG_CC_RINGOUT:
++ c_subcmd = get_ptr_subcommand(&call->subcmds);
++ if (!c_subcmd) {
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcRingout - more than %d facilities !\n", operation_tag, MAX_SUBCOMMANDS);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ }
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CcRingout\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ c_subcmd->cmd = CMD_CC_RINGOUT_INV;
++ res = rose_cc_ringout_inv_decode(pri, &c_subcmd->cc_ringout_inv.cc_extension, comp, len-i);
++ return res;
++ case QSIG_CC_SUSPEND:
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CcSuspend\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
+ return 0;
+- }
+- case ROSE_AOC_IDENTIFICATION_OF_CHARGE:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "ROSE %i: AOC Identification Of Charge - not handled!", operation_tag);
++ case QSIG_CC_RESUME:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: invoke CcResume - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ default:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
+ }
+- return -1;
+- case SS_ANFPR_PATHREPLACEMENT:
+- /* Clear Queue */
+- res = pri_call_apdu_queue_cleanup(call->bridged_call);
+- if (res) {
+- pri_message(pri, "Could not Clear queue ADPU\n");
+- return -1;
+- }
+- anfpr_pathreplacement_respond(pri, call, ie);
+- break;
+- default:
+- if (pri->debug & PRI_DEBUG_APDU) {
+- pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
++ } else { /* pri->switchtype == PRI_SWITCH_QSIG */
++
++ switch (operation_tag) {
++ case SS_CNID_CALLINGNAME:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: Handle CallingName\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return rose_calling_name_decode(pri, call, comp, len-i);
++ case ROSE_CALL_TRANSFER_IDENTIFY:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferIdentify - not handled!\n", operation_tag);
+ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case ROSE_CALL_TRANSFER_ABANDON:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferAbandon - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case ROSE_CALL_TRANSFER_INITIATE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferInitiate - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case ROSE_CALL_TRANSFER_SETUP:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferSetup - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case ROSE_CALL_TRANSFER_ACTIVE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: Handle CallTransferActive\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return rose_call_transfer_active_decode(pri, call, comp, len-i);
++ case ROSE_CALL_TRANSFER_COMPLETE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ {
++ pri_message(pri, "ROSE %i: Handle CallTransferComplete\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return rose_call_transfer_complete_decode(pri, call, comp, len-i);
++ case ROSE_CALL_TRANSFER_UPDATE:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: CallTransferUpdate - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case ROSE_SUBADDRESS_TRANSFER:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "ROSE %i: SubaddressTransfer - not handled!\n", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ return -1;
++ case ROSE_DIVERTING_LEG_INFORMATION2:
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, " Handle DivertingLegInformation2\n");
++ return rose_diverting_leg_information2_decode(pri, call, comp, len-i);
++ case ROSE_AOC_NO_CHARGING_INFO_AVAILABLE:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC No Charging Info Available - not handled!", operation_tag);
++ dump_apdu (pri, comp->data, comp->len);
++ }
++ return -1;
++ case ROSE_AOC_CHARGING_REQUEST:
++ return aoc_aoce_charging_request_decode(pri, call, (u_int8_t *)comp, comp->len + 2);
++ case ROSE_AOC_AOCS_CURRENCY:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC-S Currency - not handled!", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ case ROSE_AOC_AOCS_SPECIAL_ARR:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC-S Special Array - not handled!", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ case ROSE_AOC_AOCD_CURRENCY:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC-D Currency - not handled!", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ case ROSE_AOC_AOCD_CHARGING_UNIT:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC-D Charging Unit - not handled!", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ case ROSE_AOC_AOCE_CURRENCY:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC-E Currency - not handled!", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ case ROSE_AOC_AOCE_CHARGING_UNIT:
++ return aoc_aoce_charging_unit_decode(pri, call, (u_int8_t *)comp, comp->len + 2);
++ if (0) { /* the following function is currently not used - just to make the compiler happy */
++ aoc_aoce_charging_unit_encode(pri, call, call->aoc_units); /* use this function to forward the aoc-e on a bridged channel */
++ return 0;
++ }
++ case ROSE_AOC_IDENTIFICATION_OF_CHARGE:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "ROSE %i: AOC Identification Of Charge - not handled!", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
++ case SS_ANFPR_PATHREPLACEMENT:
++ /* Clear Queue */
++ res = pri_call_apdu_queue_cleanup(call->bridged_call);
++ if (res) {
++ pri_message(pri, "Could not Clear queue ADPU\n");
++ return -1;
++ }
++ anfpr_pathreplacement_respond(pri, call, ie);
++ break;
++ default:
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "!! Unable to handle ROSE operation %d", operation_tag);
++ dump_apdu (pri, (u_int8_t *)comp, comp->len + 2);
++ }
++ return -1;
+ }
+- return -1;
+ }
+ } while(0);
+
+@@ -2619,15 +4584,119 @@
+ return 0;
+ }
+
++/* ===== Begin Call Completion Supplementary Service (ETS 300 366/ECMA 186) ===== */
++/* operationId e.g. QSIG_CC_CCBS_REQUEST and QSIG_CC_CCNR_REQUEST */
++static int add_qsigCcRequestArg_facility_ie (struct pri *pri, q931_call *c)
++{
++ int size = 0;
++ int i = 0;
++ unsigned char buffer[256];
++ struct rose_component *comp = NULL, *compstk[10];
++ int compsp = 0;
++ u_int8_t operationId = c->ccoperation;
++ char *numberA = c->callernum;
++ char *numberB = c->callednum;
++
++ /* 1 Byte 0x80 | 0x1F = 9F Protocol Profile (0x93 wäre altes QSIG oder DDS1) */
++ buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
++
++ /* Interpretation component */
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i); /* 2. Byte NEtwork Facility Extension 0xAA = ASN1_CONTEXT_SPECIFIC(0x80) | (ASN1_CONSTRUCTOR 0x20) 0x0A (Tag laut Standard) */
++ ASN1_PUSH(compstk, compsp, comp);
++
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0); /* (0x80, 0x01(len), 0x00) endPTNX */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); /* (0x82, 0x01(len), 0x00) endPTNX */
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++#if 0
++ ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); /* 0x8B, 0x01(len), 0x00 discard */
++#endif
++ ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i); /* 0xA1, 0xXX (len of Invoke Sequenz) invoke APDU */
++ ASN1_PUSH(compstk, compsp, comp);
++
++ /* Invoke ID */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, get_invokeid(pri)); /* InvokeID 0x02 0x01 0xXX */
++
++ /*CcbsRequest ::= 40 or CcnrRequest ::= 27 */
++ /* Operation ID: CCBS/CCNR */
++ ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, operationId); /* 0x02 0x01 0x28/0x1b */
++
++ /* ccbs/ccnr request argument */
++ /* PresentedNumberUnscreened */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i); /*0x30 0xXX (len)*/
++ ASN1_PUSH(compstk, compsp, comp);
++ /* (0xA0, 0x01(len)) presentationAlloweAddress [0] PartyNumber */
++ /* (0xA1, 0xXX (len) publicPartyNumber [1] IMPLICIT PublicPartyNumber */
++ /* (0x0A, 0x01, 0x00 ) type of public party number = subscriber number */
++ /* (0x12, 0xXX (len), 0xXX .. 0xXX) numeric string */
++ size = rose_presented_number_unscreened_encode(pri, &buffer[i], PRES_ALLOWED, Q932_TON_UNKNOWN, numberA);
++ if (size < 0)
++ return -1;
++ i += size;
++
++ /* (0xA1, 0xXX (len) [1] IMPLICIT PublicPartyNumber */
++ ASN1_ADD_SIMPLE(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++ /* (0x0A, 0x01, 0x00 ) type of public party number = subscriber number */
++ /* (0x12, 0xXX (len), 0xXX .. 0xXX) numeric string */
++ size = rose_public_party_number_encode(pri, comp->data, 1, Q932_TON_UNKNOWN, numberB);
++ if (size < 0)
++ return -1;
++ i += size;
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ /* (0x40, 0xXX (len), 0xXX .. 0xXX) pSS1InfoElement */
++ ASN1_ADD_SIMPLE(comp, (ASN1_APPLICATION | ASN1_TAG_0 ), buffer, i);
++ ASN1_PUSH(compstk, compsp, comp);
++ buffer[i++] = (0x04); /* add Bearer Capability IE */
++ buffer[i++] = (0x03); /* len*/
++ buffer[i++] = (0x80); /* ETSI Standard, Speech */
++ buffer[i++] = (0x90); /* circuit mode, 64kbit/s */
++ buffer[i++] = (0xa3); /* level1 protocol, a-law */
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++#if 0
++ /* can-retain-service [12] IMPLICIT BOOLEAN DEFAULT FALSE,*/
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_12), buffer, i, 0); /* 0x1C, 0x01(len), 0x00 false */
++#endif
++ /* retain-sig-connection [13] IMPLICIT BOOLEAN OPTIONAL, --TRUE: sign. connection to be retained */
++ ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_13), buffer, i, 1); /* 0x1D, 0x01(len), 0x01 true */
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ ASN1_FIXUP(compstk, compsp, buffer, i);
++
++ if (pri_call_apdu_queue(c, Q931_SETUP, buffer, i, NULL, NULL))
++ return -1;
++
++ return 0;
++}
++/* ===== End Call Completion Supplementary Service (ETS 300 366/ECMA 186) ===== */
++
+ int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
+ {
+ if (!pri->sendfacility)
+ return 0;
+
+ if (pri->switchtype == PRI_SWITCH_QSIG) { /* For Q.SIG it does network and cpe operations */
+- if (call->redirectingnum[0])
++ if (call->redirectingnum[0])
+ rose_diverting_leg_information2_encode(pri, call);
+ add_callername_facility_ies(pri, call, 1);
++ if (call->ccoperation) {
++ switch(call->ccoperation) {
++ case 0:
++ break;
++ case QSIG_CC_CCBSREQUEST:
++ case QSIG_CC_CCNRREQUEST:
++ add_qsigCcRequestArg_facility_ie(pri, call);
++ break;
++ case QSIG_CC_RINGOUT:
++ add_qsigCcInv_facility_ie(pri, call, Q931_SETUP);
++ break;
++ default:
++ break;
++ }
++ }
+ return 0;
+ }
+
+@@ -2665,3 +4734,26 @@
+ return 0;
+ }
+
++int qsig_initiate_diverting_leg_information1(struct pri *pri, q931_call *call)
++{
++ rose_diverting_leg_information1_encode(pri, call);
++
++ if (q931_facility(pri, call)) {
++ pri_message(pri, "Could not schedule facility message for divertingLegInfo1\n");
++ return -1;
++ }
++
++ return 0;
++}
++
++int qsig_initiate_call_transfer_complete(struct pri *pri, q931_call *call, int call_status)
++{
++ rose_call_transfer_complete_encode(pri, call, call_status);
++
++ if (q931_facility(pri, call)) {
++ pri_message(pri, "Could not schedule facility message for callTransferComplete\n");
++ return -1;
++ }
++
++ return 0;
++}
+Index: pri_timers.h
+===================================================================
+--- a/pri_timers.h (.../tags/1.4.9) (revision 700)
++++ b/pri_timers.h (.../team/group/issue14292) (revision 700)
+@@ -62,6 +62,7 @@
+ -1, /* T322 */ \
+ 2500, /* TM20 - Q.921 Appendix IV */ \
+ 3, /* NM20 - Q.921 Appendix IV */ \
++ 45*60*1000 /* CC-Timer2 45 min */\
+ }
+
+ /* XXX Only our default timers are setup now XXX */
+Index: pri_facility.h
+===================================================================
+--- a/pri_facility.h (.../tags/1.4.9) (revision 700)
++++ b/pri_facility.h (.../team/group/issue14292) (revision 700)
+@@ -38,14 +38,6 @@
+ #define Q932_PROTOCOL_GAT 0x16
+ #define Q932_PROTOCOL_EXTENSIONS 0x1F
+
+-/* Argument values */
+-#define ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE 0x80
+-#define ROSE_NAME_PRESENTATION_RESTRICTED_NULL 0x87
+-#define ROSE_NAME_PRESENTATION_ALLOWED_EXTENDED 0xA1
+-#define ROSE_NAME_PRESENTATION_RESTRICTED_SIMPLE 0xA2
+-#define ROSE_NAME_PRESENTATION_RESTRICTED_EXTENDED 0xA3
+-#define ROSE_NAME_NOT_AVAIL 0x84
+-
+ /* Component types */
+ #define COMP_TYPE_INTERPRETATION 0x8B
+ #define COMP_TYPE_NETWORK_PROTOCOL_PROFILE 0x92
+@@ -65,10 +57,11 @@
+ #define ROSE_CALL_TRANSFER_COMPLETE 12
+ #define ROSE_CALL_TRANSFER_UPDATE 13
+ #define ROSE_SUBADDRESS_TRANSFER 14
++#define QSIG_CF_CALLREROUTING 19
+ /* Q.952 ROSE operations (Diverting) */
+-#define ROSE_DIVERTING_LEG_INFORMATION1 18
+-#define ROSE_DIVERTING_LEG_INFORMATION2 0x15
+-#define ROSE_DIVERTING_LEG_INFORMATION3 19
++#define ROSE_DIVERTING_LEG_INFORMATION1 20
++#define ROSE_DIVERTING_LEG_INFORMATION2 21
++#define ROSE_DIVERTING_LEG_INFORMATION3 22
+ /* Q.956 ROSE operations (Advice Of Charge) */
+ #define ROSE_AOC_NO_CHARGING_INFO_AVAILABLE 26
+ #define ROSE_AOC_CHARGING_REQUEST 30
+@@ -81,12 +74,27 @@
+ #define ROSE_AOC_IDENTIFICATION_OF_CHARGE 37
+ /* Q.SIG operations */
+ #define SS_CNID_CALLINGNAME 0
++#define SS_CNOP_CALLEDNAME 1
++#define SS_CNOP_CONNECTEDNAME 2
+ #define SS_ANFPR_PATHREPLACEMENT 4
+-#define SS_DIVERTING_LEG_INFORMATION2 21
+ #define SS_MWI_ACTIVATE 80
+ #define SS_MWI_DEACTIVATE 81
+ #define SS_MWI_INTERROGATE 82
+
++/* ECMA 186 */
++#define QSIG_CC_CCNRREQUEST PRI_CC_CCNRREQUEST /* 27 */
++#define QSIG_CC_CANCEL PRI_CC_CANCEL /* 28 */
++#define QSIG_CC_EXECPOSIBLE 29
++#define QSIG_CC_PATHRESERVE 30
++#define QSIG_CC_RINGOUT 31
++#define QSIG_CC_SUSPEND 32
++#define QSIG_CC_RESUME 33
++#define QSIG_CC_CCBSREQUEST PRI_CC_CCBSREQUEST /* 40 */
++
++#define QSIG_CC_UNSPECIFIED 1008
++#define QSIG_CC_REMOTE_USER_BUSY_AGAIN 1012
++#define QSIG_CC_FAILURE_TO_MATCH 1013
++
+ /* ROSE definitions and data structures */
+ #define INVOKE_IDENTIFIER 0x02
+ #define INVOKE_LINKED_IDENTIFIER 0x80
+@@ -128,6 +136,12 @@
+ #define ASN1_TAG_7 0x07
+ #define ASN1_TAG_8 0x08
+ #define ASN1_TAG_9 0x09
++#define ASN1_TAG_10 0x0a
++#define ASN1_TAG_11 0x0b
++#define ASN1_TAG_12 0x0c
++#define ASN1_TAG_13 0x0d
++#define ASN1_TAG_14 0x0e
++#define ASN1_TAG_15 0x0f
+
+ /* ASN.1 Identifier Octet - Primitive/Constructor Bit */
+ #define ASN1_PC_MASK 0x20
+@@ -169,6 +183,20 @@
+ #define Q932_TON_SUBSCRIBER 0x04
+ #define Q932_TON_ABBREVIATED 0x06
+
++/* Q.SIG Character Sets. Listed in ISO/IEC 8859 */
++#define CHARACTER_SET_UNKNOWN 0x00
++#define CHARACTER_SET_ISO8859_1 0x01
++#define CHARACTER_SET_ISO8859_2 0x03
++#define CHARACTER_SET_ISO8859_3 0x04
++#define CHARACTER_SET_ISO8859_4 0x05
++#define CHARACTER_SET_ISO8859_5 0x06
++#define CHARACTER_SET_ISO8859_7 0x07
++
++/* Q.SIG Subscription Option. Listed in ECMA-174 */
++#define QSIG_NO_NOTIFICATION 0x00
++#define QSIG_NOTIFICATION_WITHOUT_DIVERTED_TO_NR 0x01
++#define QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR 0x02
++
+ /* RLT related Operations */
+ #define RLT_SERVICE_ID 0x3e
+ #define RLT_OPERATION_IND 0x01
+@@ -314,6 +342,18 @@
+ /* starts a QSIG Path Replacement */
+ int anfpr_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2);
+
++int qsig_initiate_diverting_leg_information1(struct pri *pri, q931_call *call);
++
++int qsig_initiate_call_transfer_complete(struct pri *pri, q931_call *call, int call_status);
++
++int rose_diverting_leg_information1_encode(struct pri *pri, q931_call *call);
++
++int rose_diverting_leg_information3_encode(struct pri *pri, q931_call *call, int messagetype);
++
++int rose_connected_name_encode(struct pri *pri, q931_call *call, int messagetype);
++
++int rose_called_name_encode(struct pri *pri, q931_call *call, int messagetype);
++
+ /* Use this function to queue a facility-IE born APDU onto a call
+ * call is the call to use, messagetype is any one of the Q931 messages,
+ * apdu is the apdu data, apdu_len is the length of the apdu data */
+@@ -325,6 +365,8 @@
+ /* Adds the "standard" APDUs to a call */
+ int pri_call_add_standard_apdus(struct pri *pri, q931_call *call);
+
++int add_qsigCcInv_facility_ie (struct pri *pri, q931_call *c, int messagetype);
++
+ int asn1_dump(struct pri *pri, void *comp, int len);
+
+ #endif /* _PRI_FACILITY_H */
+Index: libpri.h
+===================================================================
+--- a/libpri.h (.../tags/1.4.9) (revision 700)
++++ b/libpri.h (.../team/group/issue14292) (revision 700)
+@@ -81,6 +81,7 @@
+ #define PRI_EVENT_NOTIFY 16 /* Notification received */
+ #define PRI_EVENT_PROGRESS 17 /* When we get CALL_PROCEEDING or PROGRESS */
+ #define PRI_EVENT_KEYPAD_DIGIT 18 /* When we receive during ACTIVE state */
++#define PRI_EVENT_FACILITY 19 /* Facility received */
+
+ /* Simple states */
+ #define PRI_STATE_DOWN 0
+@@ -135,16 +136,45 @@
+ #define PRI_UNKNOWN 0x0
+
+ /* Presentation */
+-#define PRES_ALLOWED_USER_NUMBER_NOT_SCREENED 0x00
+-#define PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN 0x01
+-#define PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN 0x02
+-#define PRES_ALLOWED_NETWORK_NUMBER 0x03
+-#define PRES_PROHIB_USER_NUMBER_NOT_SCREENED 0x20
+-#define PRES_PROHIB_USER_NUMBER_PASSED_SCREEN 0x21
+-#define PRES_PROHIB_USER_NUMBER_FAILED_SCREEN 0x22
+-#define PRES_PROHIB_NETWORK_NUMBER 0x23
+-#define PRES_NUMBER_NOT_AVAILABLE 0x43
++#define PRES_NUMBER_TYPE 0x03
++#define PRES_USER_NUMBER_UNSCREENED 0x00
++#define PRES_USER_NUMBER_PASSED_SCREEN 0x01
++#define PRES_USER_NUMBER_FAILED_SCREEN 0x02
++#define PRES_NETWORK_NUMBER 0x03
+
++#define PRES_RESTRICTION 0x60
++#define PRES_ALLOWED 0x00
++#define PRES_RESTRICTED 0x20
++#define PRES_UNAVAILABLE 0x40
++#define PRES_RESERVED 0x60
++
++#define PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \
++ (PRES_ALLOWED | PRES_USER_NUMBER_UNSCREENED)
++
++#define PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \
++ (PRES_ALLOWED | PRES_USER_NUMBER_PASSED_SCREEN)
++
++#define PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \
++ (PRES_ALLOWED | PRES_USER_NUMBER_FAILED_SCREEN)
++
++#define PRES_ALLOWED_NETWORK_NUMBER \
++ (PRES_ALLOWED | PRES_NETWORK_NUMBER)
++
++#define PRES_PROHIB_USER_NUMBER_NOT_SCREENED \
++ (PRES_RESTRICTED | PRES_USER_NUMBER_UNSCREENED)
++
++#define PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \
++ (PRES_RESTRICTED | PRES_USER_NUMBER_PASSED_SCREEN)
++
++#define PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \
++ (PRES_RESTRICTED | PRES_USER_NUMBER_FAILED_SCREEN)
++
++#define PRES_PROHIB_NETWORK_NUMBER \
++ (PRES_RESTRICTED | PRES_NETWORK_NUMBER)
++
++#define PRES_NUMBER_NOT_AVAILABLE \
++ (PRES_UNAVAILABLE | PRES_NETWORK_NUMBER)
++
+ /* Causes for disconnection */
+ #define PRI_CAUSE_UNALLOCATED 1
+ #define PRI_CAUSE_NO_ROUTE_TRANSIT_NET 2 /* !Q.SIG */
+@@ -303,8 +333,141 @@
+ #define PRI_NSF_ATT_MULTIQUEST 0xF0
+ #define PRI_NSF_CALL_REDIRECTION_SERVICE 0xF7
+
++/* ECMA 186 */
++#define PRI_CC_CCNRREQUEST 27
++#define PRI_CC_CANCEL 28
++#define PRI_CC_CCBSREQUEST 40
++
+ typedef struct q931_call q931_call;
+
++/* Connected line update source code */
++enum PRI_CONNECTED_LINE_UPDATE_SOURCE {
++ PRI_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, /* Update for unknown reason (May be interpreted to mean from answer) */
++ PRI_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, /* Update from normal call answering */
++ PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER, /* Update from call transfer(active) (Party has already answered) */
++ PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING /* Update from call transfer(alerting) (Party has not answered yet) */
++};
++
++/* Information needed to identify an endpoint in a call. */
++struct pri_party_id {
++ char number[256]; /* Subscriber phone number */
++ char name[256]; /* Subscriber name */
++ int number_type; /* Q.931 encoded "type of number" and "numbering plan identification" */
++ int number_presentation; /* Q.931 encoded "presentation indicator" and "screening indicator" */
++};
++
++/* Connected Line/Party information */
++struct pri_party_connected_line {
++ struct pri_party_id id; /* Connected party ID */
++ int source; /* Information about the source of an update .
++ * enum PRI_CONNECTED_LINE_UPDATE_SOURCE values
++ * for Normal-Answer, Call-transfer */
++};
++
++/* Redirecting Line information.
++ * RDNIS (Redirecting Directory Number Information Service)
++ * Where a call diversion or transfer was invoked. */
++struct pri_party_redirecting {
++ struct pri_party_id from; /* Who is redirecting the call (Sent to the party the call is redirected toward) */
++ struct pri_party_id to; /* Call is redirecting to a new party (Sent to the caller) */
++ int count; /* Number of times the call was redirected */
++ int reason; /* Redirection reasons */
++};
++
++/* Structures for qsig_cc_facilities */
++struct qsig_cc_extension {
++ int cc_extension_tag;
++ char extension[256];
++};
++
++struct qsig_cc_optional_arg {
++ char number_A[256];
++ char number_B[256];
++ int service;
++ struct qsig_cc_extension cc_extension;
++};
++
++struct qsig_cc_request_res {
++ int no_path_reservation;
++ int retain_service;
++ struct qsig_cc_extension cc_extension;
++};
++
++/* Command derived from Facility */
++#define CMD_REDIRECTING 1
++#define CMD_CONNECTEDLINE 2
++#define CMD_CC_CCBSREQUEST_RR 3
++#define CMD_CC_CCNRREQUEST_RR 4
++#define CMD_CC_CANCEL_INV 5
++#define CMD_CC_EXECPOSIBLE_INV 6
++#define CMD_CC_RINGOUT_INV 7
++#define CMD_CC_SUSPEND_INV 8
++#define CMD_CC_ERROR 9
++
++#define CCERROR_UNSPECIFIED 1008
++#define CCERROR_REMOTE_USER_BUSY_AGAIN 1012
++#define CCERROR_FAILURE_TO_MATCH 1013
++
++struct cmd_connectedline {
++ struct pri_party_connected_line connected;
++};
++
++struct cmd_redirecting {
++ struct pri_party_redirecting redirecting;
++};
++
++struct cmd_cc_ccbs_rr {
++ struct qsig_cc_request_res cc_request_res;
++};
++
++struct cmd_cc_ccnr_rr {
++ struct qsig_cc_request_res cc_request_res;
++};
++
++struct cmd_cc_cancel_inv {
++ struct qsig_cc_optional_arg cc_optional_arg;
++};
++
++struct cmd_cc_execposible_inv {
++ struct qsig_cc_optional_arg cc_optional_arg;
++};
++
++struct cmd_cc_suspend_inv {
++ struct qsig_cc_extension cc_extension;
++};
++
++struct cmd_cc_ringout_inv {
++ struct qsig_cc_extension cc_extension;
++};
++
++struct cmd_cc_error {
++ int error_value;
++};
++
++struct subcommand {
++ int cmd;
++ union {
++ struct cmd_connectedline connectedline;
++ struct cmd_redirecting redirecting;
++ struct cmd_cc_ccbs_rr cc_ccbs_rr;
++ struct cmd_cc_ccnr_rr cc_ccnr_rr;
++ struct cmd_cc_cancel_inv cc_cancel_inv;
++ struct cmd_cc_execposible_inv cc_execposible_inv;
++ struct cmd_cc_suspend_inv cc_suspend_inv;
++ struct cmd_cc_ringout_inv cc_ringout_inv;
++ struct cmd_cc_error cc_error;
++ };
++};
++
++/* Max number of subcommands per event message */
++#define MAX_SUBCOMMANDS 4
++
++struct subcommands {
++ int counter_subcmd;
++ struct subcommand subcmd[MAX_SUBCOMMANDS];
++};
++
++
+ typedef struct pri_event_generic {
+ /* Events with no additional information fall in this category */
+ int e;
+@@ -328,6 +491,11 @@
+ int progressmask;
+ q931_call *call;
+ char useruserinfo[260]; /* User->User info */
++ char calledname[256];
++ char callednum[256];
++ int calledpres;
++ int calledplan;
++ struct subcommands subcmds;
+ } pri_event_ringing;
+
+ typedef struct pri_event_answer {
+@@ -338,6 +506,12 @@
+ int progressmask;
+ q931_call *call;
+ char useruserinfo[260]; /* User->User info */
++ char connectednum[256];
++ char connectedname[256];
++ int connectedpres;
++ int connectedplan;
++ int source;
++ struct subcommands subcmds;
+ } pri_event_answer;
+
+ typedef struct pri_event_facname {
+@@ -351,6 +525,14 @@
+ int callingplan; /* Dialing plan of Calling entity */
+ } pri_event_facname;
+
++struct pri_event_facility {
++ int e;
++ int channel;
++ int cref;
++ q931_call *call;
++ struct subcommands subcmds;
++};
++
+ #define PRI_CALLINGPLANANI
+ #define PRI_CALLINGPLANRDNIS
+ typedef struct pri_event_ring {
+@@ -383,6 +565,9 @@
+ char origcallednum[256];
+ int callingplanorigcalled; /* Dialing plan of Originally Called Number */
+ int origredirectingreason;
++ int redirectingpres;
++ int redirectingcount;
++ struct subcommands subcmds;
+ } pri_event_ring;
+
+ typedef struct pri_event_hangup {
+@@ -393,6 +578,7 @@
+ q931_call *call; /* Opaque call pointer */
+ long aoc_units; /* Advise of Charge number of charged units */
+ char useruserinfo[260]; /* User->User info */
++ struct subcommands subcmds;
+ } pri_event_hangup;
+
+ typedef struct pri_event_restart_ack {
+@@ -445,6 +631,7 @@
+ pri_event_setup_ack setup_ack; /* SETUP_ACKNOWLEDGE structure */
+ pri_event_notify notify; /* Notification */
+ pri_event_keypad_digit digit; /* Digits that come during a call */
++ struct pri_event_facility facility;
+ } pri_event;
+
+ struct pri;
+@@ -531,6 +718,12 @@
+ Set non-isdn to non-zero if you are not connecting to ISDN equipment */
+ int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
+
++/* Give connected line information to a call */
++int pri_connected_line_update(struct pri *pri, q931_call *call, struct pri_party_connected_line *connected);
++
++/* Give redirection information to a call */
++int pri_redirecting_update(struct pri *pri, q931_call *call, struct pri_party_redirecting *redirecting);
++
+ /* Set CRV reference for GR-303 calls */
+
+
+@@ -558,7 +751,12 @@
+
+ /* Create a new call */
+ q931_call *pri_new_call(struct pri *pri);
++q931_call *pri_new_nochannel_call(struct pri *pri, int *cr);
+
++q931_call *pri_find_call(struct pri *pri, int cr);
++
++void pri_call_set_cc_operation(q931_call *call, int cc_operation);
++
+ /* Retrieve CRV reference for GR-303 calls. Returns >0 on success. */
+ int pri_get_crv(struct pri *pri, q931_call *call, int *callmode);
+
+@@ -584,6 +782,11 @@
+ int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
+ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
+ int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
++void pri_sr_set_redirecting_name(struct pri_sr *sr, char *name);
++
++int pri_sr_set_ccringout(struct pri_sr *sr, int ccringout);
++int pri_sr_set_ccbsnr(struct pri_sr *sr, int ccbsnr);
++
+ #define PRI_USER_USER_TX
+ /* Set the user user field. Warning! don't send binary data accross this field */
+ void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars);
+@@ -595,7 +798,10 @@
+ /* Set a call has a call indpendent signalling connection (i.e. no bchan) */
+ int pri_sr_set_connection_call_independent(struct pri_sr *req);
+
+-/* Send an MWI indication to a remote location. If activate is non zero, activates, if zero, decativates */
++/* Set a no channel call (i.e. QSIG-CCBS/CCNR) */
++int pri_sr_set_no_channel_call(struct pri_sr *req);
++
++/* Send an MWI indication to a remote location. If activate is non zero, activates, if zero, deactivates */
+ int pri_mwi_activate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
+
+ /* Send an MWI deactivate request to a remote location */
+@@ -698,6 +904,7 @@
+ #define PRI_TIMER_TM20 28 /* maximum time avaiting XID response */
+ #define PRI_TIMER_NM20 29 /* number of XID retransmits */
+
++#define PRI_TIMER_CCBST2 30 /* maximum time on completion of CC Call */
+ /* Get PRI version */
+ const char *pri_get_version(void);
+
+Index: pri.c
+===================================================================
+--- a/pri.c (.../tags/1.4.9) (revision 700)
++++ b/pri.c (.../team/group/issue14292) (revision 700)
+@@ -166,6 +166,8 @@
+ return PRI_TIMER_T321;
+ else if (!strcasecmp(timer, "T322"))
+ return PRI_TIMER_T322;
++ else if (!strcasecmp(timer, "CCT2"))
++ return PRI_TIMER_CCBST2;
+ else
+ return -1;
+ }
+@@ -348,6 +350,8 @@
+ return "Restart ACK";
+ case PRI_EVENT_FACNAME:
+ return "FacName";
++ case PRI_EVENT_FACILITY:
++ return "Facility";
+ case PRI_EVENT_INFO_RECEIVED:
+ return "Info Received";
+ case PRI_EVENT_PROCEEDING:
+@@ -551,6 +555,131 @@
+ return q931_connect(pri, call, channel, nonisdn);
+ }
+
++int pri_connected_line_update(struct pri *pri, q931_call *call, struct pri_party_connected_line *connected)
++{
++ if (!pri || !call)
++ return -1;
++
++ libpri_copy_string(call->connectednum, connected->id.number, sizeof(call->connectednum));
++ libpri_copy_string(call->connectedname, connected->id.name, sizeof(call->connectedname));
++ call->connectedplan = connected->id.number_type;
++ call->connectedpres = connected->id.number_presentation;
++
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ switch (call->ourcallstate) {
++ case Q931_CALL_STATE_ACTIVE:
++ /* immediately send callTransferComplete APDU, callStatus=answered(0) */
++ qsig_initiate_call_transfer_complete(pri, call, 0);
++ break;
++ case Q931_CALL_STATE_OVERLAP_RECEIVING:
++ case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
++ /* queue updates for next ALERTING */
++ if (call->connectedname[0]) {
++ /* queue connectedName to be send with next Q931_ALERTING */
++ rose_called_name_encode(pri, call, Q931_ALERTING);
++ }
++
++ if (call->divertedstate != DIVERTEDSTATE_NONE) {
++ libpri_copy_string(call->divertedtonum, connected->id.number, sizeof(call->divertedtonum));
++ libpri_copy_string(call->divertedtoname, connected->id.name, sizeof(call->divertedtoname));
++ call->divertedtoplan = connected->id.number_type;
++ call->divertedtopres = connected->id.number_presentation;
++
++ if ((call->divertedstate == DIVERTEDSTATE_DIVERTED) && call->divertedtonum[0]) {
++ /* immediately send divertingLegInformation1 APDU */
++ qsig_initiate_diverting_leg_information1(pri, call);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO1SEND;
++ }
++ if ((call->divertedstate == DIVERTEDSTATE_DIVLEGINFO1SEND) && call->divertedtoname[0]) {
++ /* queue divertingLegInformation3 to be send with next Q931_ALERTING */
++ rose_diverting_leg_information3_encode(pri, call, Q931_ALERTING);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO3SEND;
++ }
++ }
++ break;
++ case Q931_CALL_STATE_CALL_RECEIVED:
++ /* queue updates for next CONNECT */
++ if (call->connectedname[0] && ((call->divertedstate == DIVERTEDSTATE_NONE) || (call->divertedstate == DIVERTEDSTATE_DIVLEGINFO3SEND))) {
++ /* queue connectedName to be send with next Q931_CONNECT */
++ rose_connected_name_encode(pri, call, Q931_CONNECT);
++ }
++
++ if (call->divertedstate != DIVERTEDSTATE_NONE) {
++ libpri_copy_string(call->divertedtonum, connected->id.number, sizeof(call->divertedtonum));
++ libpri_copy_string(call->divertedtoname, connected->id.name, sizeof(call->divertedtoname));
++ call->divertedtoplan = connected->id.number_type;
++ call->divertedtopres = connected->id.number_presentation;
++
++ if ((call->divertedstate == DIVERTEDSTATE_DIVERTED) && call->divertedtonum[0]) {
++ /* queue divertingLegInformation1 to be send with next Q931_FACILITY */
++ rose_diverting_leg_information1_encode(pri, call);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO1SEND;
++
++ if (call->divertedtoname[0]) {
++ /* queue divertingLegInformation3 to be send with next Q931_FACILITY */
++ rose_diverting_leg_information3_encode(pri, call, Q931_FACILITY);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO3SEND;
++ }
++
++ /* immediately send Q931_FACILITY */
++ if (q931_facility(pri, call)) {
++ pri_message(pri, "Could not schedule facility message for divertingLegInfo1+3\n");
++ }
++ }
++ if ((call->divertedstate == DIVERTEDSTATE_DIVLEGINFO1SEND) && call->divertedtoname[0]) {
++ /* queue divertingLegInformation3 to be send with next Q931_CONNECT */
++ rose_diverting_leg_information3_encode(pri, call, Q931_CONNECT);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO3SEND;
++ }
++ }
++ break;
++ }
++ }
++
++ return 0;
++}
++
++int pri_redirecting_update(struct pri *pri, q931_call *call, struct pri_party_redirecting *redirecting)
++{
++ if (!pri || !call)
++ return -1;
++
++ libpri_copy_string(call->divertedtonum, redirecting->to.number, sizeof(call->divertedtonum));
++ libpri_copy_string(call->divertedtoname, redirecting->to.name, sizeof(call->divertedtoname));
++ call->divertedtoplan = redirecting->to.number_type;
++ call->divertedtopres = redirecting->to.number_presentation;
++ call->divertedtoreason = redirecting->reason;
++
++ if (pri->switchtype == PRI_SWITCH_QSIG) {
++ switch (call->ourcallstate) {
++ case Q931_CALL_STATE_ACTIVE:
++ /* immediately send callTransferComplete APDU, callStatus=alerting(1) */
++ qsig_initiate_call_transfer_complete(pri, call, 1);
++ break;
++ case Q931_CALL_STATE_OVERLAP_RECEIVING:
++ case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
++ call->divertedstate = DIVERTEDSTATE_DIVERTED;
++
++ if (call->divertedtonum[0]) {
++ /* immediately send divertingLegInformation1 APDU */
++ qsig_initiate_diverting_leg_information1(pri, call);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO1SEND;
++ }
++ if ((call->divertedstate == DIVERTEDSTATE_DIVLEGINFO1SEND) && call->divertedtoname[0]) {
++ /* queue divertingLegInformation3 to be send with next Q931_ALERTING */
++ rose_diverting_leg_information3_encode(pri, call, Q931_ALERTING);
++ call->divertedstate = DIVERTEDSTATE_DIVLEGINFO3SEND;
++ }
++ break;
++ default:
++ pri_message(pri, "Redirecting update in state %d\n", call->ourcallstate);
++ break;
++ }
++ }
++
++ return 0;
++}
++
+ #if 0
+ /* deprecated routines, use pri_hangup */
+ int pri_release(struct pri *pri, q931_call *call, int cause)
+@@ -637,6 +766,17 @@
+ return q931_new_call(pri);
+ }
+
++q931_call *pri_new_nochannel_call(struct pri *pri, int *cr)
++{
++ q931_call *call;
++ if (!pri)
++ return NULL;
++ call = q931_new_call(pri);
++ if (cr)
++ *cr = call->cr;
++ return call;
++}
++
+ void pri_dump_event(struct pri *pri, pri_event *e)
+ {
+ if (!pri || !e)
+@@ -679,6 +819,15 @@
+ return 0;
+ }
+
++int pri_sr_set_no_channel_call(struct pri_sr *req)
++{
++ if (!req)
++ return -1;
++
++ req->nochannelsignalling = 1;
++ return 0;
++}
++
+ /* Don't call any other pri functions on this */
+ int pri_mwi_activate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called,
+ int calledplan)
+@@ -829,6 +978,10 @@
+ struct q921_frame *f;
+ int q921outstanding = 0;
+ #endif
++ q931_call *cur, *prev;
++ struct pri *master;
++ int counter = 0;
++
+ if (!pri)
+ return NULL;
+
+@@ -862,10 +1015,57 @@
+ len += sprintf(buf + len, "T309 Timer: %d\n", pri->timers[PRI_TIMER_T309]);
+ len += sprintf(buf + len, "T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]);
+ len += sprintf(buf + len, "N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]);
++ len += sprintf(buf + len, "CCT2 Timer: %d\n", pri->timers[PRI_TIMER_CCBST2]);
++ /* Find the master - He has the call pool */
++ if (pri->master)
++ master = pri->master;
++ else
++ master = pri;
+
++ cur = *master->callpool;
++ prev = NULL;
++ while(cur) {
++ if (cur->cctimer2) {
++ struct timeval tv;
++ int time_ms_to_go, time_to_go_min, time_to_go_sec;
++ gettimeofday(&tv, NULL);
++ time_ms_to_go = (pri->pri_sched[cur->cctimer2].when.tv_sec - tv.tv_sec)*1000;
++ time_to_go_min = time_ms_to_go/1000/60;
++ time_to_go_sec = (time_ms_to_go-(time_to_go_min*60*1000))/1000;
++
++ len += sprintf(buf + len, "%d. Active Q.931 Call: %p cr=%d: (%dmin %dsec)\n",
++ ++counter, cur, cur->cr,
++ time_to_go_min, time_to_go_sec);
++ } else {
++ len += sprintf(buf + len, "%d. Active Q.931 Call: %p cr=%d\n", ++counter, cur, cur->cr);
++ }
++ cur = cur->next;
++ }
++
+ return strdup(buf);
+ }
+
++q931_call *pri_find_call(struct pri *pri, int cr)
++{
++ q931_call *cur;
++ struct pri *master;
++
++ /* Find the master - He has the call pool */
++ if (pri->master)
++ master = pri->master;
++ else
++ master = pri;
++
++ cur = *master->callpool;
++ while(cur) {
++ if (cur->cr == cr)
++ return cur;
++ cur = cur->next;
++ }
++
++ return NULL;
++}
++
+ int pri_get_crv(struct pri *pri, q931_call *call, int *callmode)
+ {
+ return q931_call_getcrv(pri, call, callmode);
+@@ -936,3 +1136,25 @@
+ sr->redirectingreason = reason;
+ return 0;
+ }
++
++void pri_sr_set_redirecting_name(struct pri_sr *sr, char *name)
++{
++ sr->redirectingname = name;
++}
++
++int pri_sr_set_ccringout(struct pri_sr *sr, int ccringout)
++{
++ sr->ccringout = ccringout;
++ return 0;
++}
++
++int pri_sr_set_ccbsnr(struct pri_sr *sr, int ccbsnr)
++{
++ sr->ccbsnr = ccbsnr;
++ return 0;
++}
++
++void pri_call_set_cc_operation(q931_call *call, int cc_operation)
++{
++ call->ccoperation = cc_operation;
++}
+Index: pri_internal.h
+===================================================================
+--- a/pri_internal.h (.../tags/1.4.9) (revision 700)
++++ b/pri_internal.h (.../team/group/issue14292) (revision 700)
+@@ -36,6 +36,12 @@
+ #define DBGHEAD __FILE__ ":%d %s: "
+ #define DBGINFO __LINE__,__PRETTY_FUNCTION__
+
++/* divertedstate */
++#define DIVERTEDSTATE_NONE 0
++#define DIVERTEDSTATE_DIVERTED 1
++#define DIVERTEDSTATE_DIVLEGINFO1SEND 2
++#define DIVERTEDSTATE_DIVLEGINFO3SEND 3
++
+ struct pri_sched {
+ struct timeval when;
+ void (*callback)(void *data);
+@@ -47,7 +53,7 @@
+ enum q931_mode;
+
+ /* No more than 128 scheduled events */
+-#define MAX_SCHED 128
++#define MAX_SCHED 128+256 /* 256 ccT2 timer events*/
+
+ #define MAX_TIMERS 32
+
+@@ -142,13 +148,17 @@
+ int calledplan;
+ int userl1;
+ int numcomplete;
++ char *redirectingname;
+ char *redirectingnum;
+ int redirectingplan;
+ int redirectingpres;
+ int redirectingreason;
+ int justsignalling;
++ int nochannelsignalling;
++ int ccbsnr;
+ const char *useruserinfo;
+ int transferable;
++ int ccringout;
+ };
+
+ /* Internal switch types */
+@@ -202,6 +212,7 @@
+
+ int sentchannel;
+ int justsignalling; /* for a signalling-only connection */
++ int nochannelsignalling;
+
+ int progcode; /* Progress coding */
+ int progloc; /* Progress Location */
+@@ -225,12 +236,19 @@
+ char callernum[256];
+ char callername[256];
+
++ int ccoperation; /* QSIG_CCBSREQUEST/QSIG_CCNRREQUEST */
++ int ccrequestresult;
++ int cctimer2; /* Timer for QSIG-timer2 */
++ /* QSIG cc infos (receive) */
++ struct subcommands subcmds;
++
+ char keypad_digits[64]; /* Buffer for digits that come in KEYPAD_FACILITY */
+
+ int ani2; /* ANI II */
+
+ int calledplan;
+ int nonisdn;
++ char calledname[256];
+ char callednum[256]; /* Called Number */
+ int complete; /* no more digits coming */
+ int newcall; /* if the received message has a new call reference value */
+@@ -241,6 +259,7 @@
+ int redirectingplan;
+ int redirectingpres;
+ int redirectingreason;
++ int redirectingcount;
+ char redirectingnum[256]; /* Number of redirecting party */
+ char redirectingname[256]; /* Name of redirecting party */
+
+@@ -251,6 +270,39 @@
+ char origcalledname[256]; /* Original name of person being called */
+ char origcallednum[256]; /* Orignal number of person being called */
+
++ int connectedplan;
++ int connectedpres;
++ char connectednum[256];
++ char connectedname[256];
++
++ /* divertingLegInformation1 */
++ int divleginfo1activeflag;
++ int divertedtoplan;
++ int divertedtopres;
++ int divertedtoreason;
++ char divertedtonum[256];
++ int divertedtocount;
++
++ /* divertingLegInformation3 */
++ int divleginfo3activeflag;
++ char divertedtoname[256];
++ int divertedstate;
++
++ /* callTransferComplete */
++ int ctcompleteflag;
++ int ctcompletepres;
++ int ctcompleteplan;
++ char ctcompletenum[256];
++ char ctcompletename[256];
++ int ctcompletecallstatus;
++
++ /* callTransferActive */
++ int ctactiveflag;
++ int ctactivepres;
++ int ctactiveplan;
++ char ctactivenum[256];
++ char ctactivename[256];
++
+ int useruserprotocoldisc;
+ char useruserinfo[256];
+ char callingsubaddr[256]; /* Calling parties sub address */
+Index: q921.c
+===================================================================
+--- a/q921.c (.../tags/1.4.9) (revision 700)
++++ b/q921.c (.../team/group/issue14292) (revision 700)
+@@ -268,12 +268,31 @@
+ pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
+ }
+
++static void q921_send_queued_iframes(struct pri *pri)
++{
++ struct q921_frame *f;
++
++ f = pri->txqueue;
++ while(f && (pri->windowlen < pri->window)) {
++ if (!f->transmitted) {
++ /* Send it now... */
++ if (pri->debug & PRI_DEBUG_Q921_DUMP)
++ pri_message(pri, "-- Finally transmitting %d, since window opened up (%d)\n", f->h.n_s, pri->windowlen);
++ f->transmitted++;
++ pri->windowlen++;
++ f->h.n_r = pri->v_r;
++ f->h.p_f = 0;
++ q921_transmit(pri, (q921_h *)(&f->h), f->len);
++ }
++ f = f->next;
++ }
++}
++
+ static pri_event *q921_ack_rx(struct pri *pri, int ack, int send_untransmitted_frames)
+ {
+ int x;
+ int cnt=0;
+ pri_event *ev;
+- struct q921_frame *f;
+ /* Make sure the ACK was within our window */
+ for (x=pri->v_a; (x != pri->v_s) && (x != ack); Q921_INC(x));
+ if (x != ack) {
+@@ -309,20 +328,7 @@
+ if (!pri->busy && send_untransmitted_frames) {
+ pri->retrans = 0;
+ /* Search for something to send */
+- f = pri->txqueue;
+- while(f && (pri->windowlen < pri->window)) {
+- if (!f->transmitted) {
+- /* Send it now... */
+- if (pri->debug & PRI_DEBUG_Q921_DUMP)
+- pri_message(pri, "-- Finally transmitting %d, since window opened up (%d)\n", f->h.n_s, pri->windowlen);
+- f->transmitted++;
+- pri->windowlen++;
+- f->h.n_r = pri->v_r;
+- f->h.p_f = 0;
+- q921_transmit(pri, (q921_h *)(&f->h), f->len);
+- }
+- f = f->next;
+- }
++ q921_send_queued_iframes(pri);
+ }
+ if (pri->debug & PRI_DEBUG_Q921_DUMP)
+ pri_message(pri, "-- Waiting for acknowledge, restarting T200 counter\n");
+@@ -515,7 +521,7 @@
+ pri->txqueue = f;
+ /* Immediately transmit unless we're in a recovery state, or the window
+ size is too big */
+- if (!pri->retrans && !pri->busy) {
++ if ((pri->q921_state == Q921_LINK_CONNECTION_ESTABLISHED) && (!pri->retrans && !pri->busy)) {
+ if (pri->windowlen < pri->window) {
+ pri->windowlen++;
+ q921_transmit(pri, (q921_h *)(&f->h), f->len);
+@@ -532,9 +538,14 @@
+ pri_schedule_del(pri, pri->t203_timer);
+ pri->t203_timer = 0;
+ }
+- if (pri->debug & PRI_DEBUG_Q921_DUMP)
+- pri_message(pri, "Starting T_200 timer\n");
+- reschedule_t200(pri);
++
++ /* Check this so that we don't try to send frames while multi frame mode is down */
++ if (pri->q921_state == Q921_LINK_CONNECTION_ESTABLISHED) {
++ if (pri->debug & PRI_DEBUG_Q921_DUMP)
++ pri_message(pri, "Starting T_200 timer\n");
++
++ reschedule_t200(pri);
++ }
+ } else {
+ pri_error(pri, "!! Out of memory for Q.921 transmit\n");
+ return -1;
+@@ -776,9 +787,6 @@
+
+ static pri_event *q921_dchannel_up(struct pri *pri)
+ {
+- /* Reset counters, etc */
+- q921_reset(pri);
+-
+ /* Stop any SABME retransmissions */
+ if (pri->sabme_timer) {
+ pri_schedule_del(pri, pri->sabme_timer);
+@@ -799,6 +807,8 @@
+ /* Notify Layer 3 */
+ q931_dl_indication(pri, PRI_EVENT_DCHAN_UP);
+
++ q921_send_queued_iframes(pri);
++
+ /* Report event that D-Channel is now up */
+ pri->ev.gen.e = PRI_EVENT_DCHAN_UP;
+ return &pri->ev;
+Index: q931.c
+===================================================================
+--- a/q931.c (.../tags/1.4.9) (revision 700)
++++ b/q931.c (.../team/group/issue14292) (revision 700)
+@@ -362,6 +362,11 @@
+ /* We are ready to transmit single IE only */
+ if (order > 1)
+ return 0;
++
++ if (call->nochannelsignalling) {
++ ie->data[pos++] = 0xac;
++ return pos + 2;
++ }
+
+ if (call->justsignalling) {
+ ie->data[pos++] = 0xac; /* Read the standards docs to figure this out
+@@ -804,7 +809,13 @@
+ ie->data[1] = 0x90;
+ return 4;
+ }
+-
++
++ if (call->nochannelsignalling) {
++ ie->data[0] = 0xa8;
++ ie->data[1] = 0x80;
++ return 4;
++ }
++
+ if (call->justsignalling) {
+ ie->data[0] = 0xa8;
+ ie->data[1] = 0x80;
+@@ -992,12 +1003,45 @@
+ prefix, ie->data[2] >> 7, redirection_reason2str(ie->data[2] & 0x7f), ie->data[2] & 0x7f);
+ break;
+ }
+- }
+- while(!(ie->data[i++]& 0x80));
++ } while(!(ie->data[i++]& 0x80));
+ q931_get_number(cnum, sizeof(cnum), ie->data + i, ie->len - i);
+ pri_message(pri, " '%s' ]\n", cnum);
+ }
+
++static FUNC_RECV(receive_connected_number)
++{
++ int i = 0;
++
++ /* To follow Q.931 (4.5.1), we must search for start of octet 4 by
++ walking through all bytes until one with ext bit (8) set to 1 */
++ do {
++ switch(i) {
++ case 0:
++ call->connectedplan = ie->data[i] & 0x7f;
++ break;
++ case 1:
++ call->connectedpres = ie->data[i] & 0x7f;
++ break;
++ }
++ } while(!(ie->data[i++] & 0x80));
++ q931_get_number((unsigned char *) call->connectednum, sizeof(call->connectednum), ie->data + i, ie->len - i);
++
++ return 0;
++}
++
++static FUNC_SEND(transmit_connected_number)
++{
++ int datalen = strlen(call->connectednum);
++ if (datalen > 0) {
++ ie->data[0] = call->connectedplan;
++ ie->data[1] = 0x80 | call->connectedpres;
++ memcpy(ie->data + 2, call->connectednum, strlen(call->connectednum));
++ return datalen + 4;
++ }
++
++ return 0;
++}
++
+ static FUNC_DUMP(dump_connected_number)
+ {
+ unsigned char cnum[256];
+@@ -1015,8 +1059,7 @@
+ prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
+ break;
+ }
+- }
+- while(!(ie->data[i++]& 0x80));
++ } while(!(ie->data[i++]& 0x80));
+ q931_get_number(cnum, sizeof(cnum), ie->data + i, ie->len - i);
+ pri_message(pri, " '%s' ]\n", cnum);
+ }
+@@ -1040,8 +1083,7 @@
+ call->redirectingreason = ie->data[i] & 0x0f;
+ break;
+ }
+- }
+- while(!(ie->data[i++] & 0x80));
++ } while(!(ie->data[i++] & 0x80));
+ q931_get_number((unsigned char *) call->redirectingnum, sizeof(call->redirectingnum), ie->data + i, ie->len - i);
+ return 0;
+ }
+@@ -2183,7 +2225,7 @@
+ { 1, Q931_IE_CALL_STATUS, "Call Status" },
+ { 1, Q931_IE_CHANGE_STATUS, "Change Status" },
+ { 1, Q931_IE_CONNECTED_ADDR, "Connected Number", dump_connected_number },
+- { 1, Q931_IE_CONNECTED_NUM, "Connected Number", dump_connected_number },
++ { 1, Q931_IE_CONNECTED_NUM, "Connected Number", dump_connected_number, receive_connected_number, transmit_connected_number },
+ { 1, Q931_IE_ORIGINAL_CALLED_NUMBER, "Original Called Number", dump_redirecting_number, receive_redirecting_number, transmit_redirecting_number },
+ { 1, Q931_IE_USER_USER_FACILITY, "User-User Facility" },
+ { 1, Q931_IE_UPDATE, "Update" },
+@@ -2478,8 +2520,7 @@
+ maxlen -= res;
+ iet = (q931_ie *)((char *)iet + res);
+ }
+- }
+- while (res > 0 && order < ies_count);
++ } while (res > 0 && order < ies_count);
+ if (have_shift && total_res) {
+ if (Q931_IE_CODESET(ies[x].ie))
+ *codeset = Q931_IE_CODESET(ies[x].ie);
+@@ -2820,9 +2861,9 @@
+ return send_message(pri, c, Q931_CALL_PROCEEDING, call_proceeding_ies);
+ }
+ #ifndef ALERTING_NO_PROGRESS
+-static int alerting_ies[] = { Q931_PROGRESS_INDICATOR, Q931_IE_USER_USER, -1 };
++static int alerting_ies[] = { Q931_PROGRESS_INDICATOR, Q931_IE_USER_USER, Q931_IE_FACILITY, -1 };
+ #else
+-static int alerting_ies[] = { -1 };
++static int alerting_ies[] = { Q931_IE_FACILITY, -1 };
+ #endif
+
+ int q931_alerting(struct pri *pri, q931_call *c, int channel, int info)
+@@ -2841,7 +2882,7 @@
+ return send_message(pri, c, Q931_ALERTING, alerting_ies);
+ }
+
+-static int connect_ies[] = { Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, -1 };
++static int connect_ies[] = { Q931_CHANNEL_IDENT, Q931_PROGRESS_INDICATOR, Q931_IE_CONNECTED_NUM, Q931_IE_FACILITY, -1 };
+
+ int q931_setup_ack(struct pri *pri, q931_call *c, int channel, int nonisdn)
+ {
+@@ -2923,6 +2964,18 @@
+ q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
+ }
+
++static void pri_cctimer2_timeout(void *data)
++{
++ int cause = 16;
++ struct q931_call *c = data;
++ struct pri *pri = c->pri;
++ if (pri->debug & PRI_DEBUG_Q931_STATE)
++ pri_message(pri, "Timed out no-channel call\n");
++ c->ccoperation = QSIG_CC_CANCEL;
++ /* normal clear cause */
++ q931_hangup(pri, c, cause);
++}
++
+ int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
+ {
+ if (channel) {
+@@ -2954,7 +3007,7 @@
+ return send_message(pri, c, Q931_CONNECT, connect_ies);
+ }
+
+-static int release_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, -1 };
++static int release_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, Q931_IE_FACILITY, -1 };
+
+ int q931_release(struct pri *pri, q931_call *c, int cause)
+ {
+@@ -3002,7 +3055,7 @@
+ return send_message(pri, c, Q931_RESTART, restart_ies);
+ }
+
+-static int disconnect_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, -1 };
++static int disconnect_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, Q931_IE_FACILITY, -1 };
+
+ int q931_disconnect(struct pri *pri, q931_call *c, int cause)
+ {
+@@ -3030,6 +3083,8 @@
+
+ static int cis_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_CALLED_PARTY_NUMBER, -1 };
+
++static int nochannel_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_SENDING_COMPLETE, -1 };
++
+ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
+ {
+ int res;
+@@ -3055,6 +3110,7 @@
+ c->nonisdn = req->nonisdn;
+ c->newcall = 0;
+ c->justsignalling = req->justsignalling;
++ c->nochannelsignalling = req->nochannelsignalling;
+ c->complete = req->numcomplete;
+ if (req->exclusive)
+ c->chanflags = FLAG_EXCLUSIVE;
+@@ -3082,6 +3138,10 @@
+ }
+ if (req->redirectingnum) {
+ libpri_copy_string(c->redirectingnum, req->redirectingnum, sizeof(c->redirectingnum));
++ if (req->redirectingname)
++ libpri_copy_string(c->redirectingname, req->redirectingname, sizeof(c->redirectingname));
++ else
++ c->redirectingname[0] = '\0';
+ c->redirectingplan = req->redirectingplan;
+ if ((pri->switchtype == PRI_SWITCH_DMS100) ||
+ (pri->switchtype == PRI_SWITCH_ATT4ESS)) {
+@@ -3092,6 +3152,7 @@
+ c->redirectingpres = req->redirectingpres;
+ c->redirectingreason = req->redirectingreason;
+ } else {
++ c->redirectingname[0] = '\0';
+ c->redirectingnum[0] = '\0';
+ c->redirectingplan = PRI_UNKNOWN;
+ c->redirectingpres = PRES_NUMBER_NOT_AVAILABLE;
+@@ -3113,12 +3174,19 @@
+ else
+ c->progressmask = 0;
+
++ if (req->ccringout)
++ c->ccoperation = QSIG_CC_RINGOUT;
++ if (req->ccbsnr)
++ c->ccoperation = req->ccbsnr;
++
+ pri_call_add_standard_apdus(pri, c);
+
+ if (pri->subchannel && !pri->bri)
+ res = send_message(pri, c, Q931_SETUP, gr303_setup_ies);
+ else if (c->justsignalling)
+ res = send_message(pri, c, Q931_SETUP, cis_setup_ies);
++ else if (c->nochannelsignalling)
++ res = send_message(pri, c, Q931_SETUP, nochannel_setup_ies);
+ else
+ res = send_message(pri, c, Q931_SETUP, setup_ies);
+ if (!res) {
+@@ -3132,7 +3200,7 @@
+
+ }
+
+-static int release_complete_ies[] = { Q931_IE_USER_USER, -1 };
++static int release_complete_ies[] = { Q931_IE_USER_USER, Q931_IE_FACILITY, -1 };
+
+ static int q931_release_complete(struct pri *pri, q931_call *c, int cause)
+ {
+@@ -3187,6 +3255,18 @@
+ /* We'll send RELEASE with these causes */
+ disconnect = 0;
+ }
++ if (c->nochannelsignalling) {
++ if (c->ccoperation == QSIG_CC_CANCEL) {
++ add_qsigCcInv_facility_ie(pri, c, Q931_RELEASE);
++ }
++ if (c->cctimer2) {
++ pri_schedule_del(pri, c->cctimer2);
++ c->cctimer2 = 0;
++ pri_message(pri, "NEW_HANGUP DEBUG: stop CC-Timer2\n");
++ }
++ disconnect = 0;
++ }
++
+ /* All other causes we send with DISCONNECT */
+ switch(c->ourcallstate) {
+ case Q931_CALL_STATE_NULL:
+@@ -3227,6 +3307,10 @@
+ break;
+ case Q931_CALL_STATE_ACTIVE:
+ /* received CONNECT */
++ if (c->nochannelsignalling) {
++ q931_release(pri,c,cause);
++ break;
++ }
+ q931_disconnect(pri,c,cause);
+ break;
+ case Q931_CALL_STATE_DISCONNECT_REQUEST:
+@@ -3260,6 +3344,132 @@
+ return 0;
+ }
+
++static void clr_subcommands(struct subcommands *sub)
++{
++ sub->counter_subcmd = 0;
++}
++
++static struct subcommand *get_ptr_subcommand(struct subcommands *sub)
++{
++ if (sub->counter_subcmd < MAX_SUBCOMMANDS) {
++ int count = sub->counter_subcmd;
++ sub->counter_subcmd++;
++ return &sub->subcmd[count];
++ }
++
++ return NULL;
++}
++
++static struct subcommand *get_ptr_q931_subcommand_by_index(struct subcommands *sub, int index)
++{
++ if (index < MAX_SUBCOMMANDS) {
++ sub->counter_subcmd--;
++ return &sub->subcmd[index];
++ }
++
++ return NULL;
++}
++
++static int q931_facilities2eventfacilities(struct pri *pri, q931_call *c, struct subcommands *subcmds)
++{
++ int facilitypos;
++ int facility_number;
++ struct subcommand *c_subcmd;
++ struct subcommand *e_subcmd;
++
++ if (c->subcmds.counter_subcmd) {
++ facility_number = c->subcmds.counter_subcmd;
++
++ for (facilitypos = 0; facilitypos < facility_number; facilitypos++) {
++ c->subcmds.counter_subcmd--;
++ c_subcmd = get_ptr_q931_subcommand_by_index(&c->subcmds, facilitypos);
++ e_subcmd = get_ptr_subcommand(subcmds);
++ if (c_subcmd && e_subcmd) {
++ switch (c_subcmd->cmd) {
++ case CMD_CC_CCBSREQUEST_RR:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_ccbs_rr, &e_subcmd->cc_ccbs_rr, sizeof(c_subcmd->cc_ccbs_rr));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_CCBSREQUEST) (%d/%d)\n",
++ e_subcmd->cc_ccbs_rr.cc_request_res.no_path_reservation,
++ e_subcmd->cc_ccbs_rr.cc_request_res.retain_service);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ c->ccrequestresult = 1;
++ break;
++ case CMD_CC_CCNRREQUEST_RR:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_ccnr_rr, &e_subcmd->cc_ccnr_rr, sizeof(c_subcmd->cc_ccnr_rr));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_CCNRREQUEST) (%d/%d)\n",
++ e_subcmd->cc_ccnr_rr.cc_request_res.no_path_reservation,
++ e_subcmd->cc_ccnr_rr.cc_request_res.retain_service);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ c->ccrequestresult = 1;
++ break;
++ case CMD_CC_CANCEL_INV:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_cancel_inv, &e_subcmd->cc_cancel_inv, sizeof(c_subcmd->cc_cancel_inv));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_CANCEL) (%s/%s)\n",
++ e_subcmd->cc_cancel_inv.cc_optional_arg.number_A,
++ e_subcmd->cc_cancel_inv.cc_optional_arg.number_B);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ break;
++ case CMD_CC_EXECPOSIBLE_INV:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_execposible_inv, &e_subcmd->cc_execposible_inv, sizeof(c_subcmd->cc_execposible_inv));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_EXECPOSIBLE) (%s/%s)\n",
++ e_subcmd->cc_execposible_inv.cc_optional_arg.number_A,
++ e_subcmd->cc_execposible_inv.cc_optional_arg.number_B);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ break;
++ case CMD_CC_RINGOUT_INV:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_ringout_inv, &e_subcmd->cc_ringout_inv, sizeof(c_subcmd->cc_ringout_inv));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_RINGOUT) (%d)\n",
++ e_subcmd->cc_ringout_inv.cc_extension.cc_extension_tag);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ break;
++ case CMD_CC_SUSPEND_INV:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_suspend_inv, &e_subcmd->cc_suspend_inv, sizeof(c_subcmd->cc_suspend_inv));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_SUSPEND) (%d)\n",
++ e_subcmd->cc_suspend_inv.cc_extension.cc_extension_tag);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ break;
++ case CMD_CC_ERROR:
++ e_subcmd->cmd = c_subcmd->cmd;
++ memcpy(&c_subcmd->cc_error, &e_subcmd->cc_error, sizeof(c_subcmd->cc_error));
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "facility(QSIG_CC_ERROR) (%d)\n",
++ e_subcmd->cc_error.error_value);
++ if (pri->debug & PRI_DEBUG_APDU)
++ pri_message(pri, "counter_subcmd(%d)\n", subcmds->counter_subcmd);
++ break;
++ default:
++ pri_error(pri, "Don't know how to handle Facility subcmd %d\n", c_subcmd->cmd);
++ break;
++ }
++ }
++ }
++#if 0
++ } else {
++ pri_message(pri, "No facilities specified\n");
++#endif
++ }
++ return 0;
++}
++
++
+ int q931_receive(struct pri *pri, q931_h *h, int len)
+ {
+ q931_mh *mh;
+@@ -3312,6 +3522,7 @@
+ break;
+ case Q931_FACILITY:
+ c->callername[0] = '\0';
++ c->subcmds.counter_subcmd = 0;
+ break;
+ case Q931_SETUP:
+ if (pri->debug & PRI_DEBUG_Q931_STATE)
+@@ -3339,6 +3550,7 @@
+ c->redirectingplan = -1;
+ c->redirectingpres = -1;
+ c->redirectingreason = -1;
++ c->redirectingcount = 0;
+ c->origcalledplan = -1;
+ c->origcalledpres = -1;
+ c->origredirectingreason = -1;
+@@ -3346,6 +3558,29 @@
+ c->origcallednum[0] = '\0';
+ c->redirectingname[0] = '\0';
+ c->origcalledname[0] = '\0';
++ c->connectedplan = -1;
++ c->connectedpres = -1;
++ c->connectednum[0] = '\0';
++ c->connectedname[0] = '\0';
++ c->divleginfo1activeflag = 0;
++ c->divertedtocount = 0;
++ c->divertedtoplan = -1;
++ c->divertedtopres = -1;
++ c->divertedtoreason = -1;
++ c->divertedtonum[0] = '\0';
++ c->divleginfo3activeflag = 0;
++ c->divertedtoname[0] = '\0';
++ c->divertedstate = DIVERTEDSTATE_NONE;
++ c->ctcompleteflag = 0;
++ c->ctcompleteplan = -1;
++ c->ctcompletepres = -1;
++ c->ctcompletenum[0] = '\0';
++ c->ctcompletename[0] = '\0';
++ c->ctactiveflag = 0;
++ c->ctactiveplan = -1;
++ c->ctactivepres = -1;
++ c->ctactivenum[0] = '\0';
++ c->ctactivename[0] = '\0';
+ c->useruserprotocoldisc = -1;
+ c->useruserinfo[0] = '\0';
+ c->complete = 0;
+@@ -3353,7 +3588,9 @@
+ c->aoc_units = -1;
+ /* Fall through */
+ case Q931_CONNECT:
++ c->ccrequestresult = 0;
+ case Q931_ALERTING:
++ c->subcmds.counter_subcmd = 0;
+ case Q931_PROGRESS:
+ c->useruserinfo[0] = '\0';
+ c->cause = -1;
+@@ -3369,6 +3606,7 @@
+ break;
+ case Q931_RELEASE:
+ case Q931_DISCONNECT:
++ c->subcmds.counter_subcmd = 0;
+ c->cause = -1;
+ c->causecode = -1;
+ c->causeloc = -1;
+@@ -3383,6 +3621,7 @@
+ pri_schedule_del(pri, c->retranstimer);
+ c->retranstimer = 0;
+ c->useruserinfo[0] = '\0';
++ c->subcmds.counter_subcmd = 0;
+ /* Fall through */
+ case Q931_STATUS:
+ c->cause = -1;
+@@ -3539,6 +3778,9 @@
+ if (!c->newcall) {
+ break;
+ }
++
++ clr_subcommands(&pri->ev.ring.subcmds);
++
+ if (c->progressmask & PRI_PROG_CALLER_NOT_ISDN)
+ c->nonisdn = 1;
+ c->newcall = 0;
+@@ -3570,7 +3812,9 @@
+ libpri_copy_string(pri->ev.ring.redirectingname, c->redirectingname, sizeof(pri->ev.ring.redirectingname));
+ libpri_copy_string(pri->ev.ring.useruserinfo, c->useruserinfo, sizeof(pri->ev.ring.useruserinfo));
+ c->useruserinfo[0] = '\0';
++ pri->ev.ring.redirectingpres = c->redirectingpres;
+ pri->ev.ring.redirectingreason = c->redirectingreason;
++ pri->ev.ring.redirectingcount = c->redirectingcount;
+ pri->ev.ring.origredirectingreason = c->origredirectingreason;
+ pri->ev.ring.flexible = ! (c->chanflags & FLAG_EXCLUSIVE);
+ pri->ev.ring.cref = c->cr;
+@@ -3578,15 +3822,21 @@
+ pri->ev.ring.layer1 = c->userl1;
+ pri->ev.ring.complete = c->complete;
+ pri->ev.ring.ctype = c->transcapability;
+- pri->ev.ring.redirectingreason = c->redirectingreason;
+ pri->ev.ring.progress = c->progress;
+ pri->ev.ring.progressmask = c->progressmask;
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending ring event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.ring.cref, c->nochannelsignalling, pri->ev.ring.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.ring.subcmds);
+ return Q931_RES_HAVEEVENT;
+ case Q931_ALERTING:
+ if (c->newcall) {
+ q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
+ break;
+ }
++ clr_subcommands(&pri->ev.ringing.subcmds);
++
+ UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_CALL_DELIVERED);
+ c->peercallstate = Q931_CALL_STATE_CALL_RECEIVED;
+ pri->ev.e = PRI_EVENT_RINGING;
+@@ -3595,8 +3845,26 @@
+ pri->ev.ringing.call = c;
+ pri->ev.ringing.progress = c->progress;
+ pri->ev.ringing.progressmask = c->progressmask;
++
++ if (c->divleginfo3activeflag) {
++ c->divleginfo3activeflag = 0;
++ libpri_copy_string(pri->ev.ringing.calledname, c->divertedtoname, sizeof(pri->ev.ringing.calledname));
++ libpri_copy_string(pri->ev.ringing.callednum, (c->divertedtonum[0]) ? c->divertedtonum : c->callednum, sizeof(pri->ev.ringing.callednum));
++ pri->ev.ringing.calledpres = c->divertedtopres;
++ pri->ev.ringing.calledplan = c->divertedtoplan;
++ } else {
++ libpri_copy_string(pri->ev.ringing.calledname, c->calledname, sizeof(pri->ev.ringing.calledname));
++ libpri_copy_string(pri->ev.ringing.callednum, (c->divertedtonum[0]) ? c->divertedtonum : c->callednum, sizeof(pri->ev.ringing.callednum));
++ pri->ev.ringing.calledpres = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
++ pri->ev.ringing.calledplan = c->calledplan;
++ }
+ libpri_copy_string(pri->ev.ringing.useruserinfo, c->useruserinfo, sizeof(pri->ev.ringing.useruserinfo));
+ c->useruserinfo[0] = '\0';
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending ringing event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.ringing.cref, c->nochannelsignalling, pri->ev.ringing.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.ringing.subcmds);
+
+ cur = c->apdus;
+ while (cur) {
+@@ -3617,6 +3885,8 @@
+ q931_status(pri, c, PRI_CAUSE_WRONG_MESSAGE);
+ break;
+ }
++ clr_subcommands(&pri->ev.answer.subcmds);
++
+ UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_ACTIVE);
+ c->peercallstate = Q931_CALL_STATE_CONNECT_REQUEST;
+ pri->ev.e = PRI_EVENT_ANSWER;
+@@ -3625,31 +3895,166 @@
+ pri->ev.answer.call = c;
+ pri->ev.answer.progress = c->progress;
+ pri->ev.answer.progressmask = c->progressmask;
++ libpri_copy_string(pri->ev.answer.connectednum, c->connectednum, sizeof(pri->ev.answer.connectednum));
++ libpri_copy_string(pri->ev.answer.connectedname, c->connectedname, sizeof(pri->ev.answer.connectedname));
++ pri->ev.answer.connectedpres = c->connectedpres;
++ pri->ev.answer.connectedplan = c->connectedplan;
++ pri->ev.answer.source = PRI_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+ libpri_copy_string(pri->ev.answer.useruserinfo, c->useruserinfo, sizeof(pri->ev.answer.useruserinfo));
+ c->useruserinfo[0] = '\0';
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending answer event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.answer.cref, c->nochannelsignalling, pri->ev.answer.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.answer.subcmds);
+ q931_connect_acknowledge(pri, c);
++ if (c->nochannelsignalling) {
++ if (c->ccrequestresult) {
++ pri_message(pri, "Q931_CONNECT: start CC-Timer2\n");
++ c->cctimer2 = pri_schedule_event(pri, pri->timers[PRI_TIMER_CCBST2], pri_cctimer2_timeout, c);
++ }
++ return Q931_RES_HAVEEVENT;
++ }
+ if (c->justsignalling) { /* Make sure WE release when we initiatie a signalling only connection */
+ q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
+ break;
+ } else
+ return Q931_RES_HAVEEVENT;
+ case Q931_FACILITY:
+- if (c->newcall) {
+- q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
+- break;
++ {
++ int haveevent = 0;
++ clr_subcommands(&pri->ev.facility.subcmds);
++
++ if (c->newcall) {
++ q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
++ break;
++ }
++ if (c->subcmds.counter_subcmd) {
++ pri->ev.e = PRI_EVENT_FACILITY;
++ pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
++ pri->ev.facility.cref = c->cr;
++ pri->ev.facility.call = c;
++
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending facility event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.facility.cref, c->nochannelsignalling, pri->ev.facility.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.facility.subcmds);
++ haveevent = 1;
++ }
++ if (c->ctcompleteflag) {
++ c->ctcompleteflag = 0;
++
++ if (c->ctcompletecallstatus == 0) {
++ /* answered(0) */
++ struct subcommand *subcmd;
++
++ pri_message(pri, "Got CT-Complete, callStatus = answered(0)\n");
++ pri->ev.e = PRI_EVENT_FACILITY;
++ pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
++ pri->ev.facility.call = c;
++
++ subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
++ if (subcmd) {
++ struct cmd_connectedline *cmdcl = &subcmd->connectedline;
++
++ subcmd->cmd = CMD_CONNECTEDLINE;
++ libpri_copy_string(cmdcl->connected.id.number, c->ctcompletenum, sizeof(cmdcl->connected.id.number));
++ libpri_copy_string(cmdcl->connected.id.name, c->ctcompletename, sizeof(cmdcl->connected.id.name));
++ cmdcl->connected.id.number_type = c->ctcompleteplan;
++ cmdcl->connected.id.number_presentation = c->ctcompletepres;
++ cmdcl->connected.source = PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
++ haveevent = 1;
++ pri_message(pri, "CT-Complete, sending facility/CMD_CONNECTEDLINE (%s/%s)\n", cmdcl->connected.id.name, cmdcl->connected.id.number);
++ }
++ } else if (c->ctcompletecallstatus == 1) {
++ /* alerting(1) */
++ struct subcommand *subcmd;
++
++ pri_message(pri, "Got CT-Complete, callStatus = alerting(1)\n");
++ pri->ev.e = PRI_EVENT_FACILITY;
++ pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
++ pri->ev.facility.call = c;
++
++ subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
++ if (subcmd) {
++ struct cmd_redirecting *cmdr = &subcmd->redirecting;
++
++ subcmd->cmd = CMD_REDIRECTING;
++ libpri_copy_string(cmdr->redirecting.from.number, c->connectednum, sizeof(cmdr->redirecting.from.number));
++ libpri_copy_string(cmdr->redirecting.from.name, c->connectedname, sizeof(cmdr->redirecting.from.name));
++ cmdr->redirecting.from.number_type = c->connectedplan;
++ cmdr->redirecting.from.number_presentation = c->connectedpres;
++ libpri_copy_string(cmdr->redirecting.to.number, c->ctcompletenum, sizeof(cmdr->redirecting.to.number));
++ libpri_copy_string(cmdr->redirecting.to.name, c->ctcompletename, sizeof(cmdr->redirecting.to.name));
++ cmdr->redirecting.to.number_type = c->ctcompleteplan;
++ cmdr->redirecting.to.number_presentation = c->ctcompletepres;
++ cmdr->redirecting.count = 0;
++ cmdr->redirecting.reason = PRI_REDIR_UNKNOWN;
++ haveevent = 1;
++ pri_message(pri, "CT-Complete, sending facility/CMD_REDIRECTING (%s/%s)\n", cmdr->redirecting.to.name, cmdr->redirecting.to.number);
++ }
++ } else {
++ pri_message(pri, "illegal value for callStatus=%d\n", c->ctcompletecallstatus);
++ }
++ } else if (c->ctactiveflag) {
++ struct subcommand *subcmd;
++
++ c->ctactiveflag = 0;
++
++ pri_message(pri, "Got CT-Active\n");
++ pri->ev.e = PRI_EVENT_FACILITY;
++ pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
++ pri->ev.facility.call = c;
++
++ subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
++ if (subcmd) {
++ struct cmd_connectedline *cmdcl = &subcmd->connectedline;
++
++ subcmd->cmd = CMD_CONNECTEDLINE;
++ libpri_copy_string(cmdcl->connected.id.number, c->ctcompletenum, sizeof(cmdcl->connected.id.number));
++ libpri_copy_string(cmdcl->connected.id.name, c->ctcompletename, sizeof(cmdcl->connected.id.name));
++ cmdcl->connected.id.number_type = c->ctcompleteplan;
++ cmdcl->connected.id.number_presentation = c->ctcompletepres;
++ cmdcl->connected.source = PRI_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
++ haveevent = 1;
++ pri_message(pri, "CT-Active, sending facility CMD_CONNECTEDLINE (%s/%s)\n", cmdcl->connected.id.name, cmdcl->connected.id.number);
++ }
++ }
++ else if (c->divleginfo1activeflag) {
++ struct subcommand *subcmd;
++
++ c->divleginfo1activeflag = 0;
++
++ pri_message(pri, "Got DivertingLegInformation1\n");
++ pri->ev.e = PRI_EVENT_FACILITY;
++ pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
++ pri->ev.facility.call = c;
++
++ subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
++ if (subcmd) {
++ struct cmd_redirecting *cmdr = &subcmd->redirecting;
++
++ subcmd->cmd = CMD_REDIRECTING;
++ libpri_copy_string(cmdr->redirecting.from.number, c->callednum, sizeof(cmdr->redirecting.from.number));
++ cmdr->redirecting.from.name[0] = '\0';
++ cmdr->redirecting.from.number_type = c->calledplan;
++ cmdr->redirecting.from.number_presentation = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
++ libpri_copy_string(cmdr->redirecting.to.number, c->divertedtonum, sizeof(cmdr->redirecting.to.number));
++ cmdr->redirecting.to.name[0] = '\0';
++ cmdr->redirecting.to.number_type = c->divertedtoplan;
++ cmdr->redirecting.to.number_presentation = c->divertedtopres;
++ cmdr->redirecting.count = c->divertedtocount;
++ cmdr->redirecting.reason = c->divertedtoreason;
++ haveevent = 1;
++ pri_message(pri, "DivertingLegInformation1, sending facility/CMD_REDIRECTING (%s/%s)\n", cmdr->redirecting.to.name, cmdr->redirecting.to.number);
++ }
++ }
++
++ if (haveevent)
++ return Q931_RES_HAVEEVENT;
+ }
+- pri->ev.e = PRI_EVENT_FACNAME;
+- libpri_copy_string(pri->ev.facname.callingname, c->callername, sizeof(pri->ev.facname.callingname));
+- libpri_copy_string(pri->ev.facname.callingnum, c->callernum, sizeof(pri->ev.facname.callingnum));
+- pri->ev.facname.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
+- pri->ev.facname.callingpres = c->callerpres;
+- pri->ev.facname.callingplan = c->callerplan;
+- pri->ev.facname.cref = c->cr;
+- pri->ev.facname.call = c;
+-#if 0
+- pri_message(pri, "Sending facility event (%s/%s)\n", pri->ev.facname.callingname, pri->ev.facname.callingnum);
+-#endif
+- return Q931_RES_HAVEEVENT;
++ break;
+ case Q931_PROGRESS:
+ if (missingmand) {
+ q931_status(pri, c, PRI_CAUSE_MANDATORY_IE_MISSING);
+@@ -3757,6 +4162,8 @@
+ }
+ break;
+ case Q931_RELEASE_COMPLETE:
++ clr_subcommands(&pri->ev.hangup.subcmds);
++
+ UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_NULL);
+ c->peercallstate = Q931_CALL_STATE_NULL;
+ pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
+@@ -3766,6 +4173,11 @@
+ pri->ev.hangup.aoc_units = c->aoc_units;
+ libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
+ c->useruserinfo[0] = '\0';
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending hangup event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.hangup.cref, c->nochannelsignalling, pri->ev.hangup.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.hangup.subcmds);
+ /* Free resources */
+ if (c->alive) {
+ pri->ev.e = PRI_EVENT_HANGUP;
+@@ -3783,6 +4195,8 @@
+ q931_hangup(pri,c,c->cause);
+ break;
+ case Q931_RELEASE:
++ clr_subcommands(&pri->ev.hangup.subcmds);
++
+ if (missingmand) {
+ /* Force cause to be mandatory IE missing */
+ c->cause = PRI_CAUSE_MANDATORY_IE_MISSING;
+@@ -3801,6 +4215,11 @@
+ pri->ev.hangup.aoc_units = c->aoc_units;
+ libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
+ c->useruserinfo[0] = '\0';
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending hangup event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.hangup.cref, c->nochannelsignalling, pri->ev.hangup.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.hangup.subcmds);
+ /* Don't send release complete if they send us release
+ while we sent it, assume a NULL state */
+ if (c->newcall)
+@@ -3809,6 +4228,8 @@
+ return Q931_RES_HAVEEVENT;
+ break;
+ case Q931_DISCONNECT:
++ clr_subcommands(&pri->ev.hangup.subcmds);
++
+ if (missingmand) {
+ /* Still let user call release */
+ c->cause = PRI_CAUSE_MANDATORY_IE_MISSING;
+@@ -3835,6 +4256,11 @@
+ pri->ev.hangup.aoc_units = c->aoc_units;
+ libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
+ c->useruserinfo[0] = '\0';
++ if (pri->debug & PRI_DEBUG_APDU) {
++ pri_message(pri, "Sending hangup event (%d) nochannelsignalling (%d) facility_number (%d)\n",
++ pri->ev.hangup.cref, c->nochannelsignalling, pri->ev.hangup.subcmds.counter_subcmd);
++ }
++ q931_facilities2eventfacilities(pri, c, &pri->ev.hangup.subcmds);
+ if (c->alive)
+ return Q931_RES_HAVEEVENT;
+ else
+
+Property changes on: .
+___________________________________________________________________
+Added: automerge
+ + *
+Added: automerge-propname
+ + issue14292-integrated
+Added: svnmerge-integrated
+ + /branches/1.4:1-688
+Added: automerge-email
+ + rmudgett@digium.com
+Added: issue14292-integrated
+ + /team/group/issue14068:1-699
+
diff --git a/main/libpri/libpri-cflags.patch b/main/libpri/libpri-cflags.patch
new file mode 100644
index 00000000000..7bf31c7ac1b
--- /dev/null
+++ b/main/libpri/libpri-cflags.patch
@@ -0,0 +1,21 @@
+Index: Makefile
+===================================================================
+--- a/Makefile (revision 650)
++++ b/Makefile (working copy)
+@@ -43,7 +43,7 @@
+ DYNAMIC_LIBRARY:=libpri.so.$(SONAME)
+ STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o version.o
+ DYNAMIC_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo version.lo
+-CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_COUNTERS)
++CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_COUNTERS)
+ INSTALL_PREFIX=$(DESTDIR)
+ INSTALL_BASE=/usr
+ libdir?=$(INSTALL_BASE)/lib
+@@ -102,7 +102,6 @@
+ ifneq (${OSARCH},SunOS)
+ install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include
+ install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
+- if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi
+ ( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
+ install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
+ if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(libdir); fi
diff --git a/main/libsamplerate/APKBUILD b/main/libsamplerate/APKBUILD
new file mode 100644
index 00000000000..786d6c1e9a4
--- /dev/null
+++ b/main/libsamplerate/APKBUILD
@@ -0,0 +1,18 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libsamplerate
+pkgver=0.1.7
+pkgrel=0
+pkgdesc="Secret Rabbit Code - aka Sample Rate Converter for audio"
+url="http://www.mega-nerd.com/SRC/index.html"
+subpackages="$pkgname-dev"
+license="GPL"
+depends="uclibc"
+source="http://www.mega-nerd.com/SRC/$pkgname-$pkgver.tar.gz"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="ad093e60ec44f0a60de8e29983ddbc0f libsamplerate-0.1.7.tar.gz"
diff --git a/main/libsndfile/APKBUILD b/main/libsndfile/APKBUILD
new file mode 100644
index 00000000000..471c45a6576
--- /dev/null
+++ b/main/libsndfile/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libsndfile
+pkgver=1.0.20
+pkgrel=0
+pkgdesc="A C library for reading and writing files containing sampled sound"
+url="http://www.mega-nerd.com/libsndfile"
+license="LGPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="alsa-lib flac uclibc"
+makedepends="alsa-lib-dev flac-dev uclibc++-dev"
+source="http://www.mega-nerd.com/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ export CXX="g++-uc"
+ ./configure --prefix=/usr \
+ --disable-sqlite \
+ || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="e0553e12c7a467af44693e95e2eac668 libsndfile-1.0.20.tar.gz"
diff --git a/main/libtasn1/APKBUILD b/main/libtasn1/APKBUILD
new file mode 100644
index 00000000000..27f71e8056d
--- /dev/null
+++ b/main/libtasn1/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libtasn1
+pkgver=2.2
+pkgrel=0
+pkgdesc="The ASN.1 library used in GNUTLS"
+url="http://www.gnu.org/software/gnutls/"
+license="GPL3 LGPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+makedepends="texinfo"
+install=
+source="ftp://ftp.gnu.org/gnu/gnutls/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="14cc361500d2e768a8a6ec538ce3fecb libtasn1-2.2.tar.gz"
diff --git a/main/libtheora/APKBUILD b/main/libtheora/APKBUILD
new file mode 100644
index 00000000000..e3b3999a3d5
--- /dev/null
+++ b/main/libtheora/APKBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libtheora
+pkgver=1.0
+pkgrel=1
+pkgdesc="An open video codec developed by the Xiph.org"
+url="http://www.xiph.org"
+license="custom"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+makedepends="libvorbis-dev libogg-dev"
+source="http://downloads.xiph.org/releases/theora/$pkgname-$pkgver.tar.bz2"
+
+depends_dev="libogg-dev"
+build ()
+{
+ cd "$srcdir"/libtheora-$pkgver
+ ./configure --prefix=/usr \
+ --enable-shared \
+ --disable-static || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -m755 -d ""$pkgdir"/usr/share/licenses/$pkgname"
+ install -m644 LICENSE COPYING "$pkgdir"/usr/share/licenses/$pkgname/
+}
+md5sums="c963937053f45a7878954bed37ceb182 libtheora-1.0.tar.bz2"
diff --git a/main/libusb-compat/APKBUILD b/main/libusb-compat/APKBUILD
new file mode 100644
index 00000000000..23e16cfa57b
--- /dev/null
+++ b/main/libusb-compat/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libusb-compat
+pkgver=0.1.0
+pkgrel=0
+pkgdesc="Compatility for older libusb"
+url="http://libusb.sourceforge.net/"
+license="LGPL"
+subpackages="$pkgname-dev"
+depends="uclibc libusb"
+makedepends="libusb-dev"
+source="http://downloads.sourceforge.net/libusb/$pkgname-$pkgver.tar.bz2"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr --disable-build-docs
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="652e1d9e6c6912fd924a5ad204f6d48b libusb-compat-0.1.0.tar.bz2"
diff --git a/main/libusb/APKBUILD b/main/libusb/APKBUILD
new file mode 100644
index 00000000000..7234ad31dfd
--- /dev/null
+++ b/main/libusb/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libusb
+pkgver=1.0.1
+pkgrel=0
+pkgdesc="Library to enable user space application programs to communicate with USB devices"
+url="http://libusb.sourceforge.net/"
+license="LGPL"
+subpackages="$pkgname-dev"
+depends="uclibc"
+makedepends=""
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr --disable-build-docs
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="8fb0e066678a0d294894b5b2969cb4b3 libusb-1.0.1.tar.bz2"
diff --git a/main/libvorbis/APKBUILD b/main/libvorbis/APKBUILD
new file mode 100644
index 00000000000..c4c0713435c
--- /dev/null
+++ b/main/libvorbis/APKBUILD
@@ -0,0 +1,23 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libvorbis
+pkgver=1.2.0
+pkgrel=0
+pkgdesc="Vorbis codec library"
+url="http://www.xiph.org/ogg/vorbis/"
+license="custom"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="libogg uclibc"
+makedepends="libogg-dev g++"
+#source="http://people.xiph.org/~giles/2008/$pkgname-$pkgver.tar.gz"
+source="http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --disable-static || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+md5sums="478646358c49f34aedcce58948793619 libvorbis-1.2.0.tar.gz"
diff --git a/main/libxml2/APKBUILD b/main/libxml2/APKBUILD
new file mode 100644
index 00000000000..a135ade72c9
--- /dev/null
+++ b/main/libxml2/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=libxml2
+pkgver=2.7.3
+pkgrel=0
+pkgdesc="XML parsing library, version 2"
+url="http://www.xmlsoft.org/"
+license="MIT"
+depends="zlib"
+makedepends="zlib-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="ftp://ftp.xmlsoft.org/${pkgname}/${pkgname}-${pkgver}.tar.gz
+ nocxx.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch configure < ../nocxx.patch
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+ install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+md5sums="8f4fda3969237c2a33bdb1583b5d06b2 libxml2-2.7.3.tar.gz
+28513788ba4d556ccd538867dc6205ab nocxx.patch"
diff --git a/main/libxml2/nocxx.patch b/main/libxml2/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/libxml2/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/libxslt/APKBUILD b/main/libxslt/APKBUILD
new file mode 100644
index 00000000000..8f6ce293800
--- /dev/null
+++ b/main/libxslt/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libxslt
+pkgver=1.1.24
+pkgrel=0
+pkgdesc="XML stylesheet transformation library"
+url="http://xmlsoft.org/XSLT/"
+license="custom"
+depends="libxml2 libgcrypt libgpg-error"
+makedepends="libxml2-dev libgcrypt-dev libgpg-error-dev python"
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://xmlsoft.org/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -D -m644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+md5sums="e83ec5d27fc4c10c6f612879bea9a153 libxslt-1.1.24.tar.gz"
diff --git a/main/lighttpd/APKBUILD b/main/lighttpd/APKBUILD
new file mode 100644
index 00000000000..0abe6dea707
--- /dev/null
+++ b/main/lighttpd/APKBUILD
@@ -0,0 +1,81 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lighttpd
+pkgver=1.4.23
+pkgrel=0
+pkgdesc="a secure, fast, compliant and very flexible web-server"
+url="http://www.lighttpd.net/"
+license="custom"
+install="$pkgname.pre-install $pkgname.post-install"
+depends=
+makedepends="flex pcre-dev openssl-dev zlib-dev bzip2-dev lua-dev pkgconfig"
+source="http://www.$pkgname.net/download/$pkgname-$pkgver.tar.bz2
+ $pkgname.initd
+ $pkgname.confd
+ $install
+ $pkgname.logrotate
+ spawn-fcgi.confd
+ spawn-fcgi.initd
+ lighttpd.conf
+ mime-types.conf
+ mod_cgi.conf
+ mod_fastcgi.conf
+ "
+subpackages="$pkgname-dev $pkgname-doc"
+
+build() {
+ local i
+ cd $srcdir/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --enable-lfs \
+ --libdir=/usr/lib/lighttpd \
+ --without-mysql \
+ --without-ldap \
+ --without-attr \
+ --without-kerberos5 \
+ --without-fam \
+ --without-webdav-props \
+ --without-webdav-locks \
+ --without-gdbm \
+ --without-memcache \
+ --with-bzip2 \
+ --with-openssl \
+ --with-lua || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ # create dirs
+ install -d -m755 "$pkgdir"/var/run/lighttpd/ \
+ "$pkgdir"/var/log/lighttpd/ \
+ "$pkgdir"/etc/lighttpd/ \
+ "$pkgdir"/var/www/localhost/htdocs
+
+ # lighttpd
+ install -D -m755 "$srcdir"/lighttpd.initd "$pkgdir"/etc/init.d/lighttpd
+ install -D -m644 "$srcdir"/lighttpd.confd "$pkgdir"/etc/conf.d/lighttpd
+ install -D -m644 "$srcdir"/lighttpd.logrotate \
+ "$pkgdir"/etc/logrotate.d/lighttpd
+
+ # spawn-fcgi
+ install -D -m755 "$srcdir"/spawn-fcgi.initd \
+ "$pkgdir"/etc/init.d/spawn-fcgi
+ install -D -m644 "$srcdir"/spawn-fcgi.confd \
+ "$pkgdir"/etc/conf.d/spawn-fcgi
+
+ # config files
+ for i in lighttpd.conf mime-types.conf mod_cgi.conf mod_fastcgi.conf; do
+ install -m644 "$srcdir"/$i "$pkgdir"/etc/lighttpd/$i
+ done
+}
+md5sums="0ab6bb7b17bf0f515ce7dce68e5e215a lighttpd-1.4.23.tar.bz2
+6910842e8ba496e8aa984ab30a46eb72 lighttpd.initd
+0dede109282bfe685bdec6b35f0e4b6b lighttpd.confd
+e250fe505d07733e920348bea0909c29 lighttpd.pre-install
+6e0e81296d854887e11bc4f8d6f998d7 lighttpd.post-install
+ad091c9157134890499f26d170352c9f lighttpd.logrotate
+1d925aed297ec4541fb230dd19e11bc1 spawn-fcgi.confd
+78bc6ceac57ecaa47abf4d5df857fe57 spawn-fcgi.initd
+df5b2360ea380d988bf16905ab214286 lighttpd.conf
+fef397e7bcf1b741dea211a555e1803c mime-types.conf
+9c1407e95f62ed22da66c4ef5f69c3b5 mod_cgi.conf
+f3363e39832f1b6678468b482d121afb mod_fastcgi.conf"
diff --git a/main/lighttpd/lighttpd.conf b/main/lighttpd/lighttpd.conf
new file mode 100644
index 00000000000..778a4062b6f
--- /dev/null
+++ b/main/lighttpd/lighttpd.conf
@@ -0,0 +1,321 @@
+###############################################################################
+# Default lighttpd.conf for Gentoo.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/lighttpd.conf,v 1.3 2005/09/01 14:22:35 ka0ttic Exp $
+###############################################################################
+
+# {{{ variables
+var.basedir = "/var/www/localhost"
+var.logdir = "/var/log/lighttpd"
+var.statedir = "/var/lib/lighttpd"
+# }}}
+
+# {{{ modules
+# At the very least, mod_access and mod_accesslog should be enabled.
+# All other modules should only be loaded if necessary.
+# NOTE: the order of modules is important.
+server.modules = (
+# "mod_rewrite",
+# "mod_redirect",
+# "mod_alias",
+ "mod_access",
+# "mod_cml",
+# "mod_trigger_b4_dl",
+# "mod_auth",
+# "mod_status",
+# "mod_setenv",
+# "mod_proxy",
+# "mod_simple_vhost",
+# "mod_evhost",
+# "mod_userdir",
+# "mod_compress",
+# "mod_ssi",
+# "mod_usertrack",
+# "mod_expire",
+# "mod_secdownload",
+# "mod_rrdtool",
+# "mod_webdav",
+ "mod_accesslog"
+)
+# }}}
+
+# {{{ includes
+include "mime-types.conf"
+# uncomment for cgi support
+# include "mod_cgi.conf"
+# uncomment for php/fastcgi support
+# include "mod_fastcgi.conf"
+# }}}
+
+# {{{ server settings
+server.username = "lighttpd"
+server.groupname = "lighttpd"
+
+server.document-root = var.basedir + "/htdocs"
+server.pid-file = "/var/run/lighttpd.pid"
+
+server.errorlog = var.logdir + "/error.log"
+# log errors to syslog instead
+# server.errorlog-use-syslog = "enable"
+
+server.indexfiles = ("index.php", "index.html",
+ "index.htm", "default.htm")
+
+# server.tag = "lighttpd"
+
+server.follow-symlink = "enable"
+
+# event handler (defaults to "poll")
+# see performance.txt
+#
+# for >= linux-2.4
+# server.event-handler = "linux-rtsig"
+# for >= linux-2.6
+# server.event-handler = "linux-sysepoll"
+# for FreeBSD
+# server.event-handler = "freebsd-kqueue"
+
+# chroot to directory (defaults to no chroot)
+# server.chroot = "/"
+
+# bind to port (defaults to 80)
+# server.port = 81
+
+# bind to name (defaults to all interfaces)
+# server.bind = "grisu.home.kneschke.de"
+
+# error-handler for status 404
+# server.error-handler-404 = "/error-handler.html"
+# server.error-handler-404 = "/error-handler.php"
+
+# Format: <errorfile-prefix><status-code>.html
+# -> ..../status-404.html for 'File not found'
+# server.errorfile-prefix = var.basedir + "/error/status-"
+
+# FAM support for caching stat() calls
+# requires that lighttpd be built with USE=fam
+# server.stat-cache-engine = "fam"
+# }}}
+
+# {{{ mod_staticfile
+
+# which extensions should not be handled via static-file transfer
+# (extensions that are usually handled by mod_cgi, mod_fastcgi, etc).
+static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi")
+# }}}
+
+# {{{ mod_accesslog
+accesslog.filename = var.logdir + "/access.log"
+# }}}
+
+# {{{ mod_dirlisting
+# enable directory listings
+# dir-listing.activate = "enable"
+#
+# don't list hidden files/directories
+# dir-listing.hide-dotfiles = "enable"
+#
+# use a different css for directory listings
+# dir-listing.external-css = "/path/to/dir-listing.css"
+#
+# list of regular expressions. files that match any of the
+# specified regular expressions will be excluded from directory
+# listings.
+# dir-listing.exclude = ("^\.", "~$")
+# }}}
+
+# {{{ mod_access
+# see access.txt
+
+url.access-deny = ("~", ".inc")
+# }}}
+
+# {{{ mod_userdir
+# see userdir.txt
+#
+# userdir.path = "public_html"
+# userdir.exclude-user = ("root")
+# }}}
+
+# {{{ mod_ssi
+# see ssi.txt
+#
+# ssi.extension = (".shtml")
+# }}}
+
+# {{{ mod_ssl
+# see ssl.txt
+#
+# ssl.engine = "enable"
+# ssl.pemfile = "server.pem"
+# }}}
+
+# {{{ mod_status
+# see status.txt
+#
+# status.status-url = "/server-status"
+# status.config-url = "/server-config"
+# }}}
+
+# {{{ mod_simple_vhost
+# see simple-vhost.txt
+#
+# If you want name-based virtual hosting add the next three settings and load
+# mod_simple_vhost
+#
+# document-root =
+# virtual-server-root + virtual-server-default-host + virtual-server-docroot
+# or
+# virtual-server-root + http-host + virtual-server-docroot
+#
+# simple-vhost.server-root = "/home/weigon/wwwroot/servers/"
+# simple-vhost.default-host = "grisu.home.kneschke.de"
+# simple-vhost.document-root = "/pages/"
+# }}}
+
+# {{{ mod_compress
+# see compress.txt
+#
+# compress.cache-dir = var.statedir + "/cache/compress"
+# compress.filetype = ("text/plain", "text/html")
+# }}}
+
+# {{{ mod_proxy
+# see proxy.txt
+#
+# proxy.server = ( ".php" =>
+# ( "localhost" =>
+# (
+# "host" => "192.168.0.101",
+# "port" => 80
+# )
+# )
+# )
+# }}}
+
+# {{{ mod_auth
+# see authentication.txt
+#
+# auth.backend = "plain"
+# auth.backend.plain.userfile = "lighttpd.user"
+# auth.backend.plain.groupfile = "lighttpd.group"
+
+# auth.backend.ldap.hostname = "localhost"
+# auth.backend.ldap.base-dn = "dc=my-domain,dc=com"
+# auth.backend.ldap.filter = "(uid=$)"
+
+# auth.require = ( "/server-status" =>
+# (
+# "method" => "digest",
+# "realm" => "download archiv",
+# "require" => "user=jan"
+# ),
+# "/server-info" =>
+# (
+# "method" => "digest",
+# "realm" => "download archiv",
+# "require" => "valid-user"
+# )
+# )
+# }}}
+
+# {{{ mod_rewrite
+# see rewrite.txt
+#
+# url.rewrite = (
+# "^/$" => "/server-status"
+# )
+# }}}
+
+# {{{ mod_redirect
+# see redirect.txt
+#
+# url.redirect = (
+# "^/wishlist/(.+)" => "http://www.123.org/$1"
+# )
+# }}}
+
+# {{{ mod_evhost
+# define a pattern for the host url finding
+# %% => % sign
+# %0 => domain name + tld
+# %1 => tld
+# %2 => domain name without tld
+# %3 => subdomain 1 name
+# %4 => subdomain 2 name
+#
+# evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/"
+# }}}
+
+# {{{ mod_expire
+# expire.url = (
+# "/buggy/" => "access 2 hours",
+# "/asdhas/" => "access plus 1 seconds 2 minutes"
+# )
+# }}}
+
+# {{{ mod_rrdtool
+# see rrdtool.txt
+#
+# rrdtool.binary = "/usr/bin/rrdtool"
+# rrdtool.db-name = var.statedir + "/lighttpd.rrd"
+# }}}
+
+# {{{ mod_setenv
+# see setenv.txt
+#
+# setenv.add-request-header = ( "TRAV_ENV" => "mysql://user@host/db" )
+# setenv.add-response-header = ( "X-Secret-Message" => "42" )
+# }}}
+
+# {{{ mod_trigger_b4_dl
+# see trigger_b4_dl.txt
+#
+# trigger-before-download.gdbm-filename = "/home/weigon/testbase/trigger.db"
+# trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" )
+# trigger-before-download.trigger-url = "^/trigger/"
+# trigger-before-download.download-url = "^/download/"
+# trigger-before-download.deny-url = "http://127.0.0.1/index.html"
+# trigger-before-download.trigger-timeout = 10
+# }}}
+
+# {{{ mod_cml
+# see cml.txt
+#
+# don't forget to add index.cml to server.indexfiles
+# cml.extension = ".cml"
+# cml.memcache-hosts = ( "127.0.0.1:11211" )
+# }}}
+
+# {{{ mod_webdav
+# see webdav.txt
+#
+# $HTTP["url"] =~ "^/dav($|/)" {
+# webdav.activate = "enable"
+# webdav.is-readonly = "enable"
+# }
+# }}}
+
+# {{{ extra rules
+#
+# set Content-Encoding and reset Content-Type for browsers that
+# support decompressing on-thy-fly (requires mod_setenv)
+# $HTTP["url"] =~ "\.gz$" {
+# setenv.add-response-header = ("Content-Encoding" => "x-gzip")
+# mimetype.assign = (".gz" => "text/plain")
+# }
+
+# $HTTP["url"] =~ "\.bz2$" {
+# setenv.add-response-header = ("Content-Encoding" => "x-bzip2")
+# mimetype.assign = (".bz2" => "text/plain")
+# }
+#
+# }}}
+
+# {{{ debug
+# debug.log-request-header = "enable"
+# debug.log-response-header = "enable"
+# debug.log-request-handling = "enable"
+# debug.log-file-not-found = "enable"
+# }}}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/main/lighttpd/lighttpd.confd b/main/lighttpd/lighttpd.confd
new file mode 100644
index 00000000000..70d4170555b
--- /dev/null
+++ b/main/lighttpd/lighttpd.confd
@@ -0,0 +1,12 @@
+# /etc/conf.d/lighttpd
+
+# Location of a shell used by the 'include_shell' directive
+# in the lighttpd's configuration file
+#export SHELL="/bin/bash"
+
+# Location of the lighttpd configuration file
+LIGHTTPD_CONF="/etc/lighttpd/lighttpd.conf"
+
+# Location of the lighttpd pid file
+LIGHTTPD_PID="/var/run/lighttpd.pid"
+
diff --git a/main/lighttpd/lighttpd.initd b/main/lighttpd/lighttpd.initd
new file mode 100644
index 00000000000..80aaacc5e59
--- /dev/null
+++ b/main/lighttpd/lighttpd.initd
@@ -0,0 +1,67 @@
+#!/sbin/runscript
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/lighttpd.initd-1.4.13-r3,v 1.2 2007/10/12 20:54:46 swegener Exp $
+
+opts="reload graceful"
+
+depend() {
+ need net
+ use mysql logger spawn-fcgi ldap slapd
+ after famd
+ after sshd
+}
+
+checkconfig() {
+ if [ ! -f "${LIGHTTPD_CONF}" ] ; then
+ ewarn "${LIGHTTPD_CONF} does not exist."
+ return 1
+ fi
+
+ /usr/sbin/lighttpd -t -f ${LIGHTTPD_CONF} >/dev/null
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting lighttpd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/lighttpd \
+ --pidfile "${LIGHTTPD_PID}" -- -f "${LIGHTTPD_CONF}"
+ eend $?
+}
+
+stop() {
+ local rv=0
+ ebegin "Stopping lighttpd"
+ start-stop-daemon --stop --quiet --pidfile "${LIGHTTPD_PID}"
+ eend $?
+}
+
+reload() {
+ if ! service_started "${SVCNAME}" ; then
+ eerror "${SVCNAME} isn't running"
+ return 1
+ fi
+ checkconfig || return 1
+
+ ebegin "Re-opening lighttpd log files"
+ start-stop-daemon --stop --oknodo --quiet --pidfile "${LIGHTTPD_PID}" \
+ --signal HUP
+ eend $?
+}
+
+graceful() {
+ if ! service_started "${SVCNAME}" ; then
+ eerror "${SVCNAME} isn't running"
+ return 1
+ fi
+ checkconfig || return 1
+
+ ebegin "Gracefully stopping lighttpd"
+ start-stop-daemon --stop --oknodo --quiet --pidfile "${LIGHTTPD_PID}" \
+ --signal INT
+ if eend $? ; then
+ rm -f "${LIGHTTPD_PID}"
+ start
+ fi
+}
diff --git a/main/lighttpd/lighttpd.logrotate b/main/lighttpd/lighttpd.logrotate
new file mode 100644
index 00000000000..76f0ef3ff58
--- /dev/null
+++ b/main/lighttpd/lighttpd.logrotate
@@ -0,0 +1,17 @@
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/lighttpd.logrotate,v 1.2 2006/05/30 19:49:29 bangert Exp $
+# lighttpd logrotate script for Gentoo
+
+/var/log/lighttpd/*.log {
+ daily
+ missingok
+ copytruncate
+ rotate 7
+ compress
+ notifempty
+ sharedscripts
+ postrotate
+ if [ -f /var/run/lighttpd.pid ]; then \
+ /etc/init.d/lighttpd reload > /dev/null 2>&1 || true ; \
+ fi;
+ endscript
+}
diff --git a/main/lighttpd/lighttpd.post-install b/main/lighttpd/lighttpd.post-install
new file mode 100644
index 00000000000..5b116a6375e
--- /dev/null
+++ b/main/lighttpd/lighttpd.post-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+chown lighttpd:lighttpd /var/*/lighttpd
+exit 0
diff --git a/main/lighttpd/lighttpd.pre-install b/main/lighttpd/lighttpd.pre-install
new file mode 100644
index 00000000000..4682680d6b6
--- /dev/null
+++ b/main/lighttpd/lighttpd.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -h /var/www/localhost/htdocs -s /bin/false -D lighttpd 2>/dev/null
+exit 0
diff --git a/main/lighttpd/mime-types.conf b/main/lighttpd/mime-types.conf
new file mode 100644
index 00000000000..3c365777395
--- /dev/null
+++ b/main/lighttpd/mime-types.conf
@@ -0,0 +1,76 @@
+###############################################################################
+# Default mime-types.conf for Gentoo.
+# include'd from lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mime-types.conf,v 1.2 2005/08/27 12:36:13 ka0ttic Exp $
+###############################################################################
+
+# {{{ mime types
+mimetype.assign = (
+ ".pdf" => "application/pdf",
+ ".sig" => "application/pgp-signature",
+ ".spl" => "application/futuresplash",
+ ".class" => "application/octet-stream",
+ ".ps" => "application/postscript",
+ ".torrent" => "application/x-bittorrent",
+ ".dvi" => "application/x-dvi",
+ ".gz" => "application/x-gzip",
+ ".pac" => "application/x-ns-proxy-autoconfig",
+ ".swf" => "application/x-shockwave-flash",
+ ".tar.gz" => "application/x-tgz",
+ ".tgz" => "application/x-tgz",
+ ".tar" => "application/x-tar",
+ ".zip" => "application/zip",
+ ".mp3" => "audio/mpeg",
+ ".m3u" => "audio/x-mpegurl",
+ ".wma" => "audio/x-ms-wma",
+ ".wax" => "audio/x-ms-wax",
+ ".ogg" => "application/ogg",
+ ".wav" => "audio/x-wav",
+ ".gif" => "image/gif",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".png" => "image/png",
+ ".xbm" => "image/x-xbitmap",
+ ".xpm" => "image/x-xpixmap",
+ ".xwd" => "image/x-xwindowdump",
+ ".css" => "text/css",
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".js" => "text/javascript",
+ ".asc" => "text/plain",
+ ".c" => "text/plain",
+ ".h" => "text/plain",
+ ".cc" => "text/plain",
+ ".cpp" => "text/plain",
+ ".hh" => "text/plain",
+ ".hpp" => "text/plain",
+ ".conf" => "text/plain",
+ ".log" => "text/plain",
+ ".text" => "text/plain",
+ ".txt" => "text/plain",
+ ".diff" => "text/plain",
+ ".patch" => "text/plain",
+ ".ebuild" => "text/plain",
+ ".eclass" => "text/plain",
+ ".rtf" => "application/rtf",
+ ".bmp" => "image/bmp",
+ ".tif" => "image/tiff",
+ ".tiff" => "image/tiff",
+ ".ico" => "image/x-icon",
+ ".dtd" => "text/xml",
+ ".xml" => "text/xml",
+ ".mpeg" => "video/mpeg",
+ ".mpg" => "video/mpeg",
+ ".mov" => "video/quicktime",
+ ".qt" => "video/quicktime",
+ ".avi" => "video/x-msvideo",
+ ".asf" => "video/x-ms-asf",
+ ".asx" => "video/x-ms-asf",
+ ".wmv" => "video/x-ms-wmv",
+ ".bz2" => "application/x-bzip",
+ ".tbz" => "application/x-bzip-compressed-tar",
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
+ )
+# }}}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/main/lighttpd/mod_cgi.conf b/main/lighttpd/mod_cgi.conf
new file mode 100644
index 00000000000..1cb3770f9b2
--- /dev/null
+++ b/main/lighttpd/mod_cgi.conf
@@ -0,0 +1,33 @@
+###############################################################################
+# mod_cgi.conf
+# include'd by lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mod_cgi.conf,v 1.1 2005/08/27 12:36:13 ka0ttic Exp $
+###############################################################################
+
+#
+# see cgi.txt for more information on using mod_cgi
+#
+
+server.modules += ("mod_cgi")
+
+# NOTE: this requires mod_alias
+alias.url = (
+ "/cgi-bin/" => var.basedir + "/cgi-bin/"
+)
+
+#
+# Note that you'll also want to enable the
+# cgi-bin alias via mod_alias (above).
+#
+
+$HTTP["url"] =~ "^/cgi-bin/" {
+ # disable directory listings
+ dir-listing.activate = "disable"
+ # only allow cgi's in this directory
+ cgi.assign = (
+ ".pl" => "/usr/bin/perl",
+ ".cgi" => "/usr/bin/perl"
+ )
+}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/main/lighttpd/mod_fastcgi.conf b/main/lighttpd/mod_fastcgi.conf
new file mode 100644
index 00000000000..ca1369af79e
--- /dev/null
+++ b/main/lighttpd/mod_fastcgi.conf
@@ -0,0 +1,17 @@
+###############################################################################
+# mod_fastcgi.conf
+# include'd by lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mod_fastcgi.conf-1.4.13-r2,v 1.1 2007/04/01 23:22:00 robbat2 Exp $
+###############################################################################
+
+server.modules += ("mod_fastcgi")
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "socket" => "/var/run/lighttpd/lighttpd-fastcgi-php-" + PID + ".socket",
+ "bin-path" => "/usr/bin/php-cgi"
+ )
+ )
+ )
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/main/lighttpd/spawn-fcgi.confd b/main/lighttpd/spawn-fcgi.confd
new file mode 100644
index 00000000000..2a88806ae0d
--- /dev/null
+++ b/main/lighttpd/spawn-fcgi.confd
@@ -0,0 +1,35 @@
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/spawn-fcgi.confd,v 1.1 2005/02/14 11:39:01 ka0ttic Exp $
+
+# Configuration file for the FCGI-Part of /etc/init.d/lighttpd
+
+## Set this to "yes" to enable SPAWNFCGI
+ENABLE_SPAWNFCGI="yes"
+
+## ABSOLUTE path to the spawn-fcgi binary
+SPAWNFCGI="/usr/bin/spawn-fcgi"
+
+## ABSOLUTE path to the PHP binary
+FCGIPROGRAM="/usr/bin/php-cgi"
+
+## bind to tcp-port on localhost
+FCGIPORT="1026"
+
+## number of PHP childs to spawn
+PHP_FCGI_CHILDREN=5
+
+## number of request server by a single php-process until is will be restarted
+PHP_FCGI_MAX_REQUESTS=1000
+
+## IP adresses where PHP should access server connections from
+FCGI_WEB_SERVER_ADDRS="127.0.0.1"
+
+# allowed environment variables sperated by spaces
+ALLOWED_ENV="PATH USER"
+# do NOT change line below
+ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
+
+## if this script is run as root switch to the following user
+USERID=lighttpd
+GROUPID=lighttpd
diff --git a/main/lighttpd/spawn-fcgi.initd b/main/lighttpd/spawn-fcgi.initd
new file mode 100644
index 00000000000..63daa75081f
--- /dev/null
+++ b/main/lighttpd/spawn-fcgi.initd
@@ -0,0 +1,51 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/spawn-fcgi.initd,v 1.2 2007/04/02 12:46:08 uberlord Exp $
+
+SPAWNFCGI_PID="/var/run/spawn-fcgi.pid"
+
+depend() {
+ need net
+}
+
+start() {
+ local my_end
+
+ ebegin "Starting spawn-fcgi"
+ export PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS
+
+ EX="${SPAWNFCGI} -p ${FCGIPORT} -f ${FCGIPROGRAM} -u ${USERID} \
+ -g ${GROUPID} -C ${PHP_FCGI_CHILDREN}"
+
+ # copy the allowed environment variables
+ unset E
+ for i in ${ALLOWED_ENV}; do
+ E="${E} ${i}=${!i}"
+ done
+
+ # clean environment and set up a new one
+ env - ${E} ${EX} 2>${SPAWNFCGI_PID}
+ my_end=$?
+ if [ "$my_end" != "0" ]; then
+ [ -f ${SPAWNFCGI_PID} ] && rm -f ${SPAWNFCGI_PID}
+ eend $my_end
+ fi
+
+ #extract parent-process-id and write it back to the file
+ FCGI_PPID=`cat ${SPAWNFCGI_PID} | cut -d':' -f4`
+ echo ${FCGI_PPID} > ${SPAWNFCGI_PID}
+ eend 0
+}
+
+stop() {
+ ebegin "Stopping spawn-fcgi"
+ if ! kill `cat ${SPAWNFCGI_PID}` ; then
+ eend $?
+ return 1
+ fi
+ if [ -w ${SPAWNFCGI_PID} ]; then
+ rm ${SPAWNFCGI_PID}
+ fi
+ eend 0
+}
diff --git a/main/links/APKBUILD b/main/links/APKBUILD
new file mode 100644
index 00000000000..2d11cf9dba7
--- /dev/null
+++ b/main/links/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=links
+pkgver=2.2
+pkgrel=0
+pkgdesc="A text WWW browser, similar to Lynx"
+url="http://atrey.karlin.mff.cuni.cz/~clock/twibright/links/"
+license="GPL"
+subpackages="$pkgname-doc"
+# the bzip2 lib is linked static so we dont need in depends
+depends="zlib openssl"
+makedepends="pkgconfig zlib-dev openssl-dev bzip2-dev"
+source="http://$pkgname.twibright.com/download/$pkgname-$pkgver.tar.bz2"
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --enable-javascript \
+ --disable-graphics \
+ --without-x \
+ --disable-nls || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="bf5b20529a2a811701c5af52b28ebdd4 links-2.2.tar.bz2"
diff --git a/main/lm_sensors/APKBUILD b/main/lm_sensors/APKBUILD
new file mode 100644
index 00000000000..0327dc77518
--- /dev/null
+++ b/main/lm_sensors/APKBUILD
@@ -0,0 +1,63 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lm_sensors
+pkgver=3.1.1
+pkgrel=0
+pkgdesc="Collection of user space tools for general SMBus access and hardware monitoring."
+url="http://www.lm-sensors.org/"
+license="GPL"
+depends="sysfsutils rrdtool"
+makedepends="perl rrdtool-dev bison flex"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-detect"
+#install=sensors.install
+source="http://dl.lm-sensors.org/lm-sensors/releases/$pkgname-$pkgver.tar.bz2
+ lm_sensors-3.1.0-sensors-detect-alpine.patch
+ fancontrol.initd
+ lm_sensors.initd
+ sensord.confd
+ sensord.initd
+ "
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+
+ sed -i -e 's:^# \(PROG_EXTRA\):\1:' Makefile
+ # Respect LDFLAGS
+ sed -i -e 's/\$(LIBDIR)$/\$(LIBDIR) \$(LDFLAGS)/g' Makefile
+ sed -i -e 's/\$(LIBSHSONAME) -o/$(LIBSHSONAME) \$(LDFLAGS) -o/g' \
+ lib/Module.mk
+
+ export CFLAGS="$CFLAGS -fno-stack-protector"
+
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+ make PREFIX=/usr user || return 1
+ make user_install \
+ PREFIX=/usr \
+ MANDIR=/usr/share/man \
+ DESTDIR="$pkgdir" || return 1
+
+ cd "$srcdir"
+ install -Dm755 fancontrol.initd "$pkgdir"/etc/init.d/fancontrol
+ install -Dm755 lm_sensors.initd "$pkgdir"/etc/init.d/lm_sensors
+ install -Dm755 sensord.initd "$pkgdir"/etc/init.d/sensord
+ install -Dm755 sensord.confd "$pkgdir"/etc/conf.d/sensord
+}
+
+detect() {
+ depends="perl"
+ pkgdesc="Detection/migration scripts for lm_sensors"
+ mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/sbin
+ cd "$pkgdir"
+ mv usr/bin/sensors-conf-convert "$subpkgdir"/usr/bin/
+ mv usr/sbin/sensors-detect "$subpkgdir"/usr/bin/
+}
+
+md5sums="613d7cfa23b70c0abae3fabb0a72ff5f lm_sensors-3.1.1.tar.bz2
+b6e7de1a1768f7a6ea2e00c226331877 lm_sensors-3.1.0-sensors-detect-alpine.patch
+58f4c9193a903711ace7fa0754693bd2 fancontrol.initd
+2c7e97203da2c39bc9fbfc2a4849cfd4 lm_sensors.initd
+82e075236a61334abb3adf46280380d3 sensord.confd
+6f3a880988e7cdbcb20870e3c6d1e554 sensord.initd"
diff --git a/main/lm_sensors/fancontrol.initd b/main/lm_sensors/fancontrol.initd
new file mode 100644
index 00000000000..fb163abc23b
--- /dev/null
+++ b/main/lm_sensors/fancontrol.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/files/fancontrol-init.d,v 1.1 2007/05/17 07:31:41 phreak Exp $
+
+CONFIG=/etc/fancontrol
+PID=/var/run/fancontrol.pid
+
+depend() {
+ after lm_sensors
+}
+
+checkconfig() {
+ if [ ! -f ${CONFIG} ]; then
+ eerror "Configuration file ${CONFIG} not found"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting fancontrol"
+ start-stop-daemon --start --quiet --background --pidfile ${PID} \
+ --exec /usr/sbin/fancontrol -- ${CONFIG}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping fancontrol"
+ start-stop-daemon --stop --pidfile ${PID}
+ eend ${?}
+}
diff --git a/main/lm_sensors/lm_sensors-3.1.0-sensors-detect-alpine.patch b/main/lm_sensors/lm_sensors-3.1.0-sensors-detect-alpine.patch
new file mode 100644
index 00000000000..9271c6bac2a
--- /dev/null
+++ b/main/lm_sensors/lm_sensors-3.1.0-sensors-detect-alpine.patch
@@ -0,0 +1,39 @@
+diff -ru lm_sensors-3.1.0.orig/prog/detect/sensors-detect lm_sensors-3.1.0/prog/detect/sensors-detect
+--- lm_sensors-3.1.0.orig/prog/detect/sensors-detect 2009-04-14 07:14:22.000000000 +0000
++++ lm_sensors-3.1.0/prog/detect/sensors-detect 2009-04-14 07:44:48.000000000 +0000
+@@ -5282,19 +5282,24 @@
+ }
+ }
+
+- my $have_sysconfig = -d '/etc/sysconfig';
+- printf "Do you want to \%s /etc/sysconfig/lm_sensors? (\%s): ",
+- (-e '/etc/sysconfig/lm_sensors' ? 'overwrite' : 'generate'),
+- ($have_sysconfig ? 'YES/no' : 'yes/NO');
++ my $config = '/etc/conf.d/lm_sensors';
++ my $have_config = -f $config;
++ printf "Do you want to \%s \%s? (\%s): ",
++ (-e $config ? 'overwrite' : 'generate'),
++ $config,
++ ($have_config ? 'YES/no' : 'yes/NO');
+ $_ = <STDIN>;
+- if (($have_sysconfig and not m/^\s*n/i) or m/^\s*y/i) {
+- unless ($have_sysconfig) {
+- mkdir('/etc/sysconfig', 0777)
+- or die "Sorry, can't create /etc/sysconfig ($!)";
+- }
+- open(local *SYSCONFIG, ">/etc/sysconfig/lm_sensors")
+- or die "Sorry, can't create /etc/sysconfig/lm_sensors ($!)";
++ if (($have_config and not m/^\s*n/i) or m/^\s*y/i) {
++ open(local *SYSCONFIG, ">$config")
++ or die "Sorry, can't create $config ($!)";
+ print SYSCONFIG "# Generated by sensors-detect on " . scalar localtime() . "\n";
++ print SYSCONFIG
++ "\n".
++ "# Load modules at startup\n".
++ "LOADMODULES=yes\n\n".
++ "# Initialize sensors at startup\n".
++ "INITSENSORS=yes\n\n";
++
+ print SYSCONFIG <<'EOT';
+ # This file is sourced by /etc/init.d/lm_sensors and defines the modules to
+ # be loaded/unloaded.
diff --git a/main/lm_sensors/lm_sensors.initd b/main/lm_sensors/lm_sensors.initd
new file mode 100644
index 00000000000..18fb3537062
--- /dev/null
+++ b/main/lm_sensors/lm_sensors.initd
@@ -0,0 +1,105 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/files/lm_sensors-3-init.d,v 1.1 2008/03/17 07:59:28 dberkholz Exp $
+
+checkconfig() {
+ if [ ! -f /etc/conf.d/lm_sensors ]; then
+ eerror "/etc/conf.d/lm_sensors does not exist, try running sensors-detect"
+ return 1
+ fi
+
+ if [ "${LOADMODULES}" = "yes" -a -f /proc/modules ]; then
+ if [ -z "${MODULE_0}" ]; then
+ eerror "MODULE_0 is not set in /etc/conf.d/lm_sensors, try running sensors-detect"
+ return 1
+ fi
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ if [ "${LOADMODULES}" = "yes" -a -f /proc/modules ]; then
+ einfo "Loading lm_sensors modules..."
+
+ mount | grep sysfs >/dev/null 2>&1
+ if [ ${?} = 0 ]; then
+ if ! ( [ -e /sys/i2c ] || [ -e /sys/bus/i2c ] ); then
+ ebegin " Loading i2c-core"
+ modprobe i2c-core >/dev/null 2>&1
+ if [ ${?} != 0 ]; then
+ eerror " Could not load i2c-core!"
+ eend 1
+ fi
+ ( [ -e /sys/i2c ] || [ -e /sys/bus/i2c ] ) || return 1
+ eend 0
+ fi
+ elif ! [ -e /proc/sys/dev/sensors ]; then
+ ebegin " Loading i2c-proc"
+ modprobe i2c-proc >/dev/null 2>&1
+ if [ ${?} != 0 ]; then
+ eerror " Could not load i2c-proc!"
+ eend 1
+ fi
+ [ -e /proc/sys/dev/sensors ] || return 1
+ eend 0
+ fi
+
+ i=0
+ while true; do
+ module=`eval echo '$'MODULE_${i}`
+ module_args=`eval echo '$'MODULE_${i}_ARGS`
+ if [ -z "${module}" ]; then
+ break
+ fi
+ ebegin " Loading ${module}"
+ modprobe ${module} ${module_args} >/dev/null 2>&1
+ eend $?
+ i=$(($i+1))
+ done
+ fi
+
+ if [ "${INITSENSORS}" = "yes" ]; then
+ if ! [ -f /etc/sensors3.conf ]; then
+ eerror "/etc/sensors3.conf does not exist!"
+ return 1
+ fi
+
+ ebegin "Initializing sensors"
+ /usr/bin/sensors -s >/dev/null 2>&1
+ eend ${?}
+ fi
+}
+
+stop() {
+ checkconfig || return 1
+
+ if [ "${LOADMODULES}" = "yes" -a -f /proc/modules ]; then
+ einfo "Unloading lm_sensors modules..."
+
+ # find the highest possible MODULE_ number
+ i=0
+ while true; do
+ module=`eval echo '$'MODULE_${i}`
+ if [ -z "${module}" ] ; then
+ break
+ fi
+ i=$(($i+1))
+ done
+
+ while [ ${i} -gt 0 ]; do
+ i=$(($i-1))
+ module=`eval echo '$'MODULE_${i}`
+ ebegin " Unloading ${module}"
+ rmmod ${module} >/dev/null 2>&1
+ eend $?
+ done
+
+ if [ -e /proc/sys/dev/sensors ] ; then
+ ebegin " Unloading i2c-proc"
+ rmmod i2c-proc >/dev/null 2>&1
+ eend $?
+ fi
+ fi
+}
diff --git a/main/lm_sensors/sensord.confd b/main/lm_sensors/sensord.confd
new file mode 100644
index 00000000000..d82841aebd4
--- /dev/null
+++ b/main/lm_sensors/sensord.confd
@@ -0,0 +1,3 @@
+# Extra options to pass to the sensord daemon,
+# see sensord(8) for more information
+SENSORD_OPTIONS=""
diff --git a/main/lm_sensors/sensord.initd b/main/lm_sensors/sensord.initd
new file mode 100644
index 00000000000..cb99dce3f05
--- /dev/null
+++ b/main/lm_sensors/sensord.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/files/sensord-init.d,v 1.1 2007/05/17 07:31:41 phreak Exp $
+
+CONFIG=/etc/sensors.conf
+
+depend() {
+ need logger
+ use lm_sensors
+}
+
+checkconfig() {
+ if [ ! -f ${CONFIG} ]; then
+ eerror "Configuration file ${CONFIG} not found"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting sensord"
+ start-stop-daemon --start --exec /usr/sbin/sensord \
+ -- --config-file ${CONFIG} ${SENSORD_OPTIONS}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping sensord"
+ start-stop-daemon --stop --pidfile /var/run/sensord.pid
+ eend ${?}
+}
diff --git a/main/lm_sensors/sensors.install b/main/lm_sensors/sensors.install
new file mode 100644
index 00000000000..d593f841449
--- /dev/null
+++ b/main/lm_sensors/sensors.install
@@ -0,0 +1,12 @@
+post_install() {
+ echo ">>> to control the lm_sensors daemon type"
+ echo ">>> \"/etc/rc.d/sensors start|stop|restart\" "
+ echo ">>> --------------------------------------"
+ echo ">>> before you can use the fancontrol daemon"
+ echo ">>> first create a fancontrol config file, use \"pwmconfig\""
+ echo ">>> then type \"/etc/rc.d/fancontrol start|stop|restart\" "
+ echo ">>> --------------------------------------"
+ echo ">>> to decode memory SPD timings modprobe eeprom module"
+ echo ">>> and get this perl script from"
+ echo ">>> \"http://www.lm-sensors.org/browser/lm-sensors/trunk/prog/eeprom/decode-dimms.pl\""
+}
diff --git a/main/logrotate/APKBUILD b/main/logrotate/APKBUILD
new file mode 100644
index 00000000000..e29b27e1eab
--- /dev/null
+++ b/main/logrotate/APKBUILD
@@ -0,0 +1,23 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=logrotate
+pkgver=3.7.8
+pkgrel=0
+pkgdesc="Tool to rotate logfiles"
+url="https://fedorahosted.org/logrotate/"
+license="GPL"
+depends="uclibc popt"
+makedepends="popt-dev wget"
+subpackages="$pkgname-doc"
+source="https://fedorahosted.org/releases/l/o/logrotate/logrotate-3.7.8.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make || return 1
+ install -Dm755 logrotate "$pkgdir"/usr/sbin/logrotate
+ install -Dm644 logrotate.8 "$pkgdir"/usr/share/man/man8/logrotate.8
+ install -Dm644 examples/logrotate-default "$pkgdir"/etc/logrotate.conf
+ install -Dm644 examples/logrotate.cron "$pkgdir"/etc/logrotate.cron
+}
+
+md5sums="b3589bea6d8d5afc8a84134fddaae973 logrotate-3.7.8.tar.gz"
diff --git a/main/lpc/APKBUILD b/main/lpc/APKBUILD
new file mode 100644
index 00000000000..af2b8a089d0
--- /dev/null
+++ b/main/lpc/APKBUILD
@@ -0,0 +1,18 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lpc
+pkgver=1.0.0
+pkgrel=0
+pkgdesc="Lua Process Call"
+url="http://lua.net-core.org/sputnik.lua?p=Telesto:About"
+license="MIT/X11"
+depends="uclibc lua-dev"
+source="http://lua.net-core.org/dl/telesto/lpc-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS -shared"
+ # does not respect DESTDIR
+ make install PREFIX="$pkgdir"/usr
+}
+
+md5sums="fce047808fbdfe3f9439557c7afae871 lpc-1.0.0.tar.gz"
diff --git a/main/lua/APKBUILD b/main/lua/APKBUILD
new file mode 100644
index 00000000000..5e41bc03ad2
--- /dev/null
+++ b/main/lua/APKBUILD
@@ -0,0 +1,48 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lua
+pkgver=5.1.4
+pkgrel=2
+pkgdesc="A powerful light-weight programming language designed for extending applications."
+url="http://www.lua.org/"
+license="MIT"
+depends=
+makedepends="readline-dev libtool"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://www.$pkgname.org/ftp/$pkgname-$pkgver.tar.gz
+ lua-5.1-make.patch
+ lua-5.1-module_paths.patch
+ "
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ # correct lua versioning
+ sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:4:1/' src/Makefile
+
+ # we want packages to find our things
+ sed -i -e 's:/usr/local:/usr:' etc/lua.pc
+
+ cd src
+ make CFLAGS=" -DLUA_USE_LINUX $CFLAGS" \
+ RPATH="/usr/lib" \
+ LUA_LIBS="-lreadline" \
+ LIB_LIBS="-lm -ldl" \
+ V=$pkgver \
+ gentoo_all || return 1
+
+ cd "$srcdir/$pkgname-$pkgver"
+ make INSTALL_TOP="$pkgdir"/usr INSTALL_LIB="$pkgdir"/usr/lib \
+ V=$pkgver gentoo_install || return 1
+
+ install -D -m 644 etc/lua.pc "$pkgdir"/usr/lib/pkgconfig/lua.pc
+ install -D -m 644 doc/lua.1 "$pkgdir"/usr/share/man/man1/lua.1
+ install -D -m 644 doc/luac.1 "$pkgdir"/usr/share/man/man1/luac.1
+}
+md5sums="d0870f2de55d59c1c8419f36e8fac150 lua-5.1.4.tar.gz
+0145ff6036eb6bfdab427dc8f0c3f3c0 lua-5.1-make.patch
+e60ef15deefb72a5930c498f1184aced lua-5.1-module_paths.patch"
diff --git a/main/lua/lua-5.1-make.patch b/main/lua/lua-5.1-make.patch
new file mode 100644
index 00000000000..d051a21cb63
--- /dev/null
+++ b/main/lua/lua-5.1-make.patch
@@ -0,0 +1,64 @@
+--- lua-5.1.1.orig/Makefile 2006-06-02 12:53:38.000000000 +0200
++++ lua-5.1.1/Makefile 2006-11-16 02:16:53.000000000 +0100
+@@ -127,3 +127,22 @@
+ .PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho newer
+
+ # (end of Makefile)
++
++# Use libtool for binary installs, etc.
++
++export V
++export LIBTOOL = libtool --quiet --tag=CC
++# See libtool manual about how to set this
++
++gentoo_clean:
++ cd src; $(MAKE) $@
++
++gentoo_test: gentoo_linux
++ test/lua.static test/hello.lua
++
++gentoo_install:
++ mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB)
++ cd src; $(LIBTOOL) --mode=install $(INSTALL_EXEC) lua luac $(INSTALL_BIN)
++ cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
++ cd src; $(LIBTOOL) --mode=install $(INSTALL_DATA) liblua.la $(INSTALL_LIB)
++ cd src; $(LIBTOOL) --mode=install $(INSTALL_DATA) liblua.a $(INSTALL_LIB)
+--- lua-5.1.1.orig/src/Makefile 2006-03-22 01:41:49.000000000 +0100
++++ lua-5.1.1/src/Makefile 2006-11-16 02:10:27.000000000 +0100
+@@ -176,3 +176,36 @@
+ ltm.h lzio.h lmem.h lopcodes.h lundump.h
+
+ # (end of Makefile)
++
++export LIBTOOL = libtool --quiet --tag=CC
++export LIB_VERSION = 6:1:1
++
++# The following rules use libtool for compiling and linking in order to
++# provide shared library support.
++
++LIB_NAME = liblua.la
++LIB_OBJS = $(CORE_O:.o=.lo) $(LIB_O:.o=.lo)
++
++%.lo %.o: %.c
++ $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
++
++$(LIB_NAME): $(LIB_OBJS)
++ $(LIBTOOL) --mode=link $(CC) -version-info $(LIB_VERSION) \
++ -rpath $(RPATH) -o $(LIB_NAME) $(LIB_OBJS) $(LIB_LIBS)
++
++$(LIB_NAME:.la=.a): $(LIB_OBJS)
++ $(LIBTOOL) --mode=link $(CC) -static -o $(LIB_NAME:.la=.a) $(LIB_OBJS)
++
++$(LUA_T): $(LUA_O) $(LIB_NAME)
++ $(LIBTOOL) --mode=link $(CC) -Wl,-E -o $@ $(LUA_O) $(LUA_LIBS) -llua
++
++lua_test: $(LUA_O) $(LIB_NAME)
++ $(LIBTOOL) --mode=link $(CC) -static -Wl,-E -o $@ $(LUA_O) $(LIB_NAME) $(LUA_LIBS)
++
++$(LUAC_T): $(LUAC_O) $(LIB_NAME)
++ $(LIBTOOL) --mode=link $(CC) -static -o $@ $(LUAC_O) $(LIB_NAME)
++
++gentoo_clean:
++ $(LIBTOOL) --mode=clean $(RM) $(ALL_O:.o=.lo) $(LIB_NAME) lua luac
++
++gentoo_all: $(LIB_NAME) $(LIB_NAME:.la=.a) $(LUA_T) lua_test $(LUAC_T)
diff --git a/main/lua/lua-5.1-module_paths.patch b/main/lua/lua-5.1-module_paths.patch
new file mode 100644
index 00000000000..29ac4c3bf4b
--- /dev/null
+++ b/main/lua/lua-5.1-module_paths.patch
@@ -0,0 +1,30 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## src_luaconf.h.dpatch by John V. Belmonte <jbelmonte@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Set Lua's default PATH and CPATH.
+
+@DPATCH@
+diff -urNad trunk~/src/luaconf.h trunk/src/luaconf.h
+--- trunk~/src/luaconf.h 2006-02-10 12:44:06.000000000 -0500
++++ trunk/src/luaconf.h 2006-02-17 21:32:55.000000000 -0500
+@@ -83,13 +83,17 @@
+
+ #else
+ #define LUA_ROOT "/usr/local/"
++#define LUA_ROOT2 "/usr/"
+ #define LUA_LDIR LUA_ROOT "share/lua/5.1/"
++#define LUA_LDIR2 LUA_ROOT2 "share/lua/5.1/"
+ #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
++#define LUA_CDIR2 LUA_ROOT2 "lib/lua/5.1/"
+ #define LUA_PATH_DEFAULT \
+ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
+- LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
++ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
++ LUA_LDIR2"?.lua;" LUA_LDIR2"?/init.lua"
+ #define LUA_CPATH_DEFAULT \
+- "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
++ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR2"?.so;" LUA_CDIR"loadall.so"
+ #endif
+
+
diff --git a/main/luaposix/APKBUILD b/main/luaposix/APKBUILD
new file mode 100644
index 00000000000..7b85aeafdf0
--- /dev/null
+++ b/main/luaposix/APKBUILD
@@ -0,0 +1,18 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=luaposix
+pkgver=5.1.4
+pkgrel=0
+pkgdesc="POSIX library for Lua"
+url="http://luaforge.net/projects/luaposix/"
+license="MIT"
+depends="uclibc"
+makedepends="lua-dev"
+source="http://luaforge.net/frs/download.php/3572/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make PREFIX=/usr || return 1
+ make PREFIX=/usr DESTDIR="$pkgdir" install
+}
+
+md5sums="073019b1a52bfddb94e2521553b47ef5 luaposix-5.1.4.tar.gz"
diff --git a/main/luasql-postgres/APKBUILD b/main/luasql-postgres/APKBUILD
new file mode 100644
index 00000000000..36756ca6573
--- /dev/null
+++ b/main/luasql-postgres/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Mika Havela <mika.havela@gmail.com>
+# Maintainer: Mika Havela <mika.havela@gmail.com>
+pkgname=luasql-postgres
+pkgver=2.1.1
+pkgrel=0
+pkgdesc="LuaSQL is a simple interface from Lua to a DBMS"
+url="http://www.keplerproject.org/luasql/"
+license="MIT"
+depends="lua"
+makedepends="lua-dev postgresql-dev"
+install=
+subpackages=
+source="http://luaforge.net/frs/download.php/2686/luasql-$pkgver.tar.gz
+ config.new
+ "
+
+build() {
+ cd "$srcdir/luasql-$pkgver"
+ cp "$srcdir/config.new" config
+
+ make || return 1
+ mkdir -p "$pkgdir"/usr/lib/lua/5.1/luasql
+ cp src/postgres.so "$pkgdir"/usr/lib/lua/5.1/luasql
+}
+
+md5sums="63bdd57de4b9d1be336ba112d8cb69eb luasql-2.1.1.tar.gz
+6ee28fa90394da6a7e38cf507d56ba80 config.new"
diff --git a/main/luasql-postgres/config.new b/main/luasql-postgres/config.new
new file mode 100644
index 00000000000..a8650c55118
--- /dev/null
+++ b/main/luasql-postgres/config.new
@@ -0,0 +1,59 @@
+# Driver (leave uncommented ONLY the line with the name of the driver)
+#T= mysql
+#T= oci8
+#T= odbc
+T= postgres
+#T= sqlite
+#T=sqlite3
+
+# Installation directories
+
+# Default prefix
+PREFIX = /usr
+
+# System's libraries directory (where binary libraries are installed)
+LUA_LIBDIR= $(PREFIX)/lib/lua/5.1
+
+# System's lua directory (where Lua libraries are installed)
+LUA_DIR= $(PREFIX)/share/lua/5.1
+
+# Lua includes directory
+LUA_INC= $(PREFIX)/include
+
+# Lua version number (first and second digits of target version)
+LUA_VERSION_NUM= 514
+
+# OS dependent
+LIB_OPTION= -shared #for Linux
+#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
+
+LIBNAME= $T.so
+COMPAT_DIR= ../compat/src
+
+# Compilation parameters
+# Driver specific
+######## MySQL
+#DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz
+#DRIVER_INCS= -I/usr/local/mysql/include
+######## Oracle OCI8
+#DRIVER_LIBS= -L/home/oracle/OraHome1/lib -lz -lclntsh
+#DRIVER_INCS= -I/home/oracle/OraHome1/rdbms/demo -I/home/oracle/OraHome1/rdbms/public
+######## PostgreSQL
+DRIVER_LIBS= -L/usr/pgsql/lib -lpq
+DRIVER_INCS= -I/usr/pgsql/include
+######## SQLite
+#DRIVER_LIBS= -lsqlite
+#DRIVER_INCS=
+######## SQLite3
+#DRIVER_LIBS= -L/opt/local/lib -lsqlite3
+#DRIVER_INCS= -I/opt/local/include
+######## ODBC
+#DRIVER_LIBS= -L/usr/local/lib -lodbc
+#DRIVER_INCS= -DUNIXODBC -I/usr/local/include
+
+WARN= -Wall -Wmissing-prototypes -Wmissing-declarations -ansi -pedantic
+INCS= -I$(LUA_INC)
+CFLAGS= -O2 $(WARN) -I$(COMPAT_DIR) $(DRIVER_INCS) $(INCS) $(DEFS)
+CC= gcc
+
+# $Id: config,v 1.8 2007/10/27 22:55:27 carregal Exp $
diff --git a/main/lzo/APKBUILD b/main/lzo/APKBUILD
new file mode 100644
index 00000000000..a9f2b912e15
--- /dev/null
+++ b/main/lzo/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Michael Mason <ms13sp@gmail.com>
+pkgname=lzo
+pkgver=2.03
+pkgrel=0
+pkgdesc="LZO -- a real-time data compression library"
+url="http://www.oberhumer.com/opensource/lzo"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages="$pkgname-dev"
+source="http://www.oberhumer.com/opensource/lzo/download/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-shared
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="0c3d078c2e8ea5a88971089a2f02a726 lzo-2.03.tar.gz"
diff --git a/main/man-pages/APKBUILD b/main/man-pages/APKBUILD
new file mode 100644
index 00000000000..b47b21cbfdb
--- /dev/null
+++ b/main/man-pages/APKBUILD
@@ -0,0 +1,28 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=man-pages
+pkgver=3.21
+_posixver=2003-a
+pkgrel=0
+pkgdesc="Linux man pages"
+url="http://www.kernel.org/doc/man-pages/"
+license="GPL"
+depends="man"
+makedepends=""
+options="!strip"
+source="http://www.kernel.org/pub/linux/docs/$pkgname/$pkgname-$pkgver.tar.gz
+ http://www.kernel.org/pub/linux/docs/$pkgname/$pkgname-posix/$pkgname-posix-${_posixver}.tar.bz2"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ mkdir -p "$srcdir"/$pkgname-$pkgver/man0
+ for sect in 0 1 3; do
+ sed -i "/^\.so /s/man${sect}p/man$sect/" \
+ "$srcdir"/$pkgname-posix-${_posixver}/man${sect}p/*
+ mv "$srcdir"/$pkgname-posix-${_posixver}/man${sect}p/* \
+ "$srcdir"/$pkgname-$pkgver/man$sect/
+ done
+ make prefix="$pkgdir"/usr install || return 1
+}
+md5sums="05eb6e209375f24cd40c7b106323d1c3 man-pages-3.21.tar.gz
+7c78aff03c0a6767ba483d34f19e4b09 man-pages-posix-2003-a.tar.bz2"
diff --git a/main/man/APKBUILD b/main/man/APKBUILD
new file mode 100644
index 00000000000..c6940dbf3b2
--- /dev/null
+++ b/main/man/APKBUILD
@@ -0,0 +1,35 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=man
+pkgver=1.6f
+pkgrel=1
+pkgdesc="A utility for reading man pages"
+url="http://primates.ximian.com/~flucifredi/man/"
+license="GPL"
+depends="groff"
+subpackages="$pkgname-doc"
+source="http://primates.ximian.com/~flucifredi/$pkgname/$pkgname-$pkgver.tar.gz
+ whatis.periodic.daily
+ $pkgname-troff.patch"
+
+build () {
+ local i
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 -i $i || return 1
+ done
+
+ ./configure -confdir=/etc +sgid +fhs +lang none
+
+ make || return 1
+ make PREFIX="$pkgdir" install || return 1
+
+ sed -i -e "s|-Tlatin1||g" \
+ -e "s|less -is|less|g" \
+ "$pkgdir"/etc/man.conf
+ install -D -m744 ../whatis.periodic.daily \
+ "$pkgdir"/etc/periodic/daily/whatis
+}
+md5sums="67aaaa6df35215e812fd7d89472c44b6 man-1.6f.tar.gz
+9cb02e4491777430a9ad3b503e87ec0d whatis.periodic.daily
+21541cb3073259f7fb9335675ca41b0e man-troff.patch"
diff --git a/main/man/man-troff.patch b/main/man/man-troff.patch
new file mode 100644
index 00000000000..e08e9316b21
--- /dev/null
+++ b/main/man/man-troff.patch
@@ -0,0 +1,16 @@
+diff -Naur man-1.5p-orig/src/man.conf.in man-1.5p/src/man.conf.in
+--- man-1.5p-orig/src/man.conf.in 2005-01-08 10:50:45.000000000 -0800
++++ man-1.5p/src/man.conf.in 2005-03-18 13:22:17.000000000 -0800
+@@ -88,9 +88,9 @@
+ # If you have a new troff (version 1.18.1?) and its colored output
+ # causes problems, add the -c option to TROFF, NROFF, JNROFF.
+ #
+-TROFF @troff@
+-NROFF @nroff@
+-JNROFF @jnroff@
++TROFF @troff@ -c
++NROFF @nroff@ -c
++JNROFF @jnroff@ -c
+ EQN @eqn@
+ NEQN @neqn@
+ JNEQN @jneqn@
diff --git a/main/man/whatis.periodic.daily b/main/man/whatis.periodic.daily
new file mode 100755
index 00000000000..00d40dd9af3
--- /dev/null
+++ b/main/man/whatis.periodic.daily
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Make sure MANPATH is complete
+. /etc/profile
+. /etc/profile.d/* 2>/dev/null
+
+# Update the "whatis" database
+/usr/sbin/makewhatis -u -w
+
diff --git a/main/md5/APKBUILD b/main/md5/APKBUILD
new file mode 100644
index 00000000000..93e3747a921
--- /dev/null
+++ b/main/md5/APKBUILD
@@ -0,0 +1,19 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=md5
+pkgver=1.1.2
+pkgrel=0
+pkgdesc="Basic cryptographic facilities for Lua"
+url="http://www.keplerproject.org/md5/"
+license="MIT"
+depends="uclibc lua"
+makedepends="lua-dev"
+source="http://luaforge.net/frs/download.php/3355/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make CFLAGS="$CFLAGS" || return 1
+ make PREFIX="$pkgdir"/usr install
+}
+
+md5sums="68874cff64547f2157d5ecdc3572b544 md5-1.1.2.tar.gz"
diff --git a/main/mini_httpd/APKBUILD b/main/mini_httpd/APKBUILD
new file mode 100644
index 00000000000..4f7167e709c
--- /dev/null
+++ b/main/mini_httpd/APKBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=mini_httpd
+pkgver=1.19
+pkgrel=1
+pkgdesc="Small forking webserver with ssl and ipv6 support"
+url="http://www.acme.com/software/mini_httpd/"
+license="BSD"
+depends=
+makedepends="openssl-dev"
+subpackages="$pkgname-doc"
+source="http://www.acme.com/software/mini_httpd/$pkgname-$pkgver.tar.gz
+ $pkgname.conf.sample
+ $pkgname.initd
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make CFLAGS="${CFLAGS} -DUSE_SSL" \
+ LDFLAGS="${LDFLAGS}" \
+ SSL_LIBS="-lssl -lcrypto" \
+ || return 1
+# SSL_DEFS="-DUSE_SSL" \
+
+ # does not respect DESTDIR
+ make install \
+ BINDIR="$pkgdir"/usr/sbin \
+ MANDIR="$pkgdir"/usr/share/man
+
+ # rename htpasswd to mini_htpasswd
+ mv "$pkgdir"/usr/sbin/htpasswd "$pkgdir"/usr/sbin/mini_htpasswd
+ mv "$pkgdir"/usr/share/man/man1/htpasswd.1 \
+ "$pkgdir"/usr/share/man/man1/mini_htpasswd.1
+
+ mkdir -p "$pkgdir"/var/www/localhost/htdocs
+ install -D -m644 ../mini_httpd.conf.sample \
+ "$pkgdir"/etc/mini_httpd.conf
+ install -D -m755 ../mini_httpd.initd "$pkgdir"/etc/init.d/mini_httpd
+}
+
+md5sums="7c68293ad265ecfe2edea917912f6f1f mini_httpd-1.19.tar.gz
+ec656aadd4751a3f4f6e8c788a5237f2 mini_httpd.conf.sample
+804e5cba1537bddac195e64b5b50d609 mini_httpd.initd"
diff --git a/main/mini_httpd/mini_httpd.conf.sample b/main/mini_httpd/mini_httpd.conf.sample
new file mode 100644
index 00000000000..397a331ad30
--- /dev/null
+++ b/main/mini_httpd/mini_httpd.conf.sample
@@ -0,0 +1,50 @@
+## /etc/mini_httpd.conf
+##
+## do not leave empty lines in here!
+## format is: key=value
+##
+## run in debug-mode?
+#debug
+##
+## what interface to bind to?
+## (default is binding to any interface)
+#host=www.example.org
+port=80
+#port=443
+user=nobody
+##
+## The DOCROOT
+dir=/var/www/localhost/htdocs
+##
+## CGI:
+## ? match a single char
+## * matches any string excluding "/"
+## ** matches any string including "/"
+## separate multiple patterns with "|"
+#cgipat=**.sh|**.cgi
+##
+## chroot:
+chroot
+#nochroot
+##
+logfile=/var/log/mini_httpd.log
+##
+#charset=iso-8859-1
+##
+## control the caching: (in secs)
+#maxage 60
+##
+## useless setting (just modifies the http-header)
+## (see mini_httpd(8) and http://www.w3.org/P3P/ for more info)
+#p3p
+##
+## virtual hosting:
+#vhost
+##
+## cache-control: send this "max-age" in all HTTP-responses:
+#max-age=0
+##
+## ssl:
+#nossl
+#ssl
+#certfile=/etc/mini_httpd/mini_httpd.pem
diff --git a/main/mini_httpd/mini_httpd.initd b/main/mini_httpd/mini_httpd.initd
new file mode 100644
index 00000000000..4460a539ef5
--- /dev/null
+++ b/main/mini_httpd/mini_httpd.initd
@@ -0,0 +1,25 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/www-servers/mini_httpd/files/mini_httpd.init,v 1.2 2007/08/26 21:20:21 bangert Exp $
+
+pidfile=/var/run/${SVCNAME}.pid
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting $SVCNAME"
+ start-stop-daemon --quiet --start --exec /usr/sbin/mini_httpd \
+ --pidfile $pidfile -- -i $pidfile \
+ ${MINI_HTTPD_OPTS:--C /etc/${SVCNAME}.conf}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping $SVCNAME"
+ start-stop-daemon --quiet --stop --pidfile $pidfile
+ eend $?
+}
+
diff --git a/main/mlmmj/APKBUILD b/main/mlmmj/APKBUILD
new file mode 100644
index 00000000000..96649fd6b6d
--- /dev/null
+++ b/main/mlmmj/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=mlmmj
+pkgver=1.2.16
+pkgrel=0
+pkgdesc="Mailing list managing made joyful"
+url="http://mlmmj.org/"
+license="MIT"
+subpackages="$pkgname-doc"
+depends="uclibc"
+source="http://mlmmj.mmj.dk/files/$pkgname-$pkgver.tar.bz2 "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ configure --prefix=/usr
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install || return 1
+ install -d "$pkgdir"/usr/share/mlmmj/texts
+ cp -r listtexts/* "$pkgdir"/usr/share/mlmmj/texts/
+}
+md5sums="9ea7ba91ccb55b9edf3e5148537364e3 mlmmj-1.2.16.tar.bz2"
diff --git a/main/mpg123/APKBUILD b/main/mpg123/APKBUILD
new file mode 100644
index 00000000000..4a13dea81a1
--- /dev/null
+++ b/main/mpg123/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=mpg123
+pkgver=1.8.1
+pkgrel=0
+pkgdesc="A console based real time MPEG Audio Player for Layer 1, 2 and 3"
+url="http://sourceforge.net/projects/mpg123"
+license="GPL2 LGPL2"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+makedepends="pkgconfig libtool alsa-lib-dev"
+source="http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --disable-dependency-tracking \
+ --with-ipv6 \
+ --with-pic \
+ --with-optimization=0 \
+ --with-cpu=i386_fpu \
+ --with-audio="alsa oss" || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+md5sums="856893f14b29b1cddf4aba32469860b4 mpg123-1.8.1.tar.bz2"
diff --git a/main/mysql/APKBUILD b/main/mysql/APKBUILD
new file mode 100644
index 00000000000..de03c127da1
--- /dev/null
+++ b/main/mysql/APKBUILD
@@ -0,0 +1,70 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=mysql
+pkgver=5.0.83
+pkgrel=0
+pkgdesc="A fast SQL database server"
+url="http://www.mysql.com/"
+license='GPL'
+depends=
+makedepends="libtool uclibc++-dev readline-dev openssl-dev ncurses-dev zlib-dev"
+source="http://sunsite.informatik.rwth-aachen.de/mysql/Downloads/MySQL-5.0/${pkgname}-${pkgver}.tar.gz
+$pkgname.initd
+$pkgname.mycnf"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-test libmysqlclient $pkgname-client"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ export CXX=g++-uc
+ ./configure --prefix=/usr --libexecdir=/usr/sbin \
+ --localstatedir=/var/lib/mysql \
+ --disable-assembler --with-pthread \
+ --without-raid --without-libwrap \
+ --without-pstack --without-docs \
+ --without-embedded-server --with-openssl \
+ --without-mysqlfs --without-vio \
+ --without-bench --without-debug \
+ --with-unix-socket-path=/var/run/mysqld/mysqld.sock \
+ --with-innodb --mandir=/usr/share/man || return 1
+ make || return 1
+ make -j1 DESTDIR="$pkgdir/" install
+ install -Dm 755 "$startdir"/$pkgname.initd $pkgdir/etc/init.d/$pkgname
+ install -Dm 644 "$startdir"/$pkgname.mycnf $pkgdir/etc/mysql/my.cnf
+ install -dDo mysql $pkgdir/var/log/mysql
+ install -dDo mysql $pkgdir/var/run/mysqld
+}
+
+libmysqlclient() {
+ pkgdesc="MySQL client library"
+ mkdir -p "$subpkgdir"/usr/lib/mysql
+ mv "$pkgdir"/usr/lib/mysql/libmysqlclient.so* "$subpkgdir"/usr/lib/mysql
+ # make symlinks
+ cd "$subpkgdir"/usr/lib
+ for i in mysql/*; do
+ ln -s "$i" "${i##*/}"
+ done
+}
+
+test() {
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/mysql-test "$subpkgdir"/usr/
+}
+
+client() {
+ pkgdesc="client for the MySQL database"
+ install=""
+ local bins="myisam_ftdump mysql mysqlaccess mysqladmin mysqlbug mysqlcheck
+ mysql_client_test mysqldump mysqldumpslow mysql_explain_log mysql_find_rows
+ mysql_fix_extensions mysqlimport mysqlshow mysql_tableinfo mysqltestmanagerc
+ mysqltestmanager-pwgen mysql_waitpid"
+
+ mkdir -p "$subpkgdir"/usr/bin/
+
+ for i in $bins; do
+ mv "$pkgdir"/usr/bin/${i} "$subpkgdir"/usr/bin/
+ done
+}
+
+md5sums="051392064a1e32cca5c23a593908b10e mysql-5.0.83.tar.gz
+3ce9827b22d8fbbb29d83a91cbe98ffc mysql.initd
+15a7e3ddd6a40bf5a1eb3a8c69d9c34c mysql.mycnf"
diff --git a/main/mysql/mysql.initd b/main/mysql/mysql.initd
new file mode 100644
index 00000000000..8f841646b87
--- /dev/null
+++ b/main/mysql/mysql.initd
@@ -0,0 +1,38 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/dev-db/mysql/files/mysql.init,v 1.7 2004/07/14 21:41:15 agriffis Exp $
+
+depend() {
+ need net
+ use dns
+}
+
+checkconfig() {
+ if [ ! -f /etc/mysql/my.cnf ] ; then
+ eerror "No /etc/mysql/my.cnf file exists!"
+ fi
+
+ dir=`my_print_defaults -c /etc/mysql/my.cnf mysqld | grep -- --datadir | sed -e "s|^.*=\(.*\)|\1|"`
+
+ if [ ! -d $dir/mysql ] ; then
+ eerror "You dont appear to have the mysql database installed yet."
+ eerror "Please run /usr/bin/mysql_install_db --user=mysql to have this done..."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting mysqld"
+ /usr/bin/mysqld_safe --defaults-file=/etc/mysql/my.cnf >/dev/null 2>&1 &
+ eend $?
+}
+
+stop () {
+ ebegin "Stopping mysqld"
+ start-stop-daemon --stop --quiet \
+ --pidfile=/var/run/mysqld/mysqld.pid --retry 20
+ eend $?
+}
+
diff --git a/main/mysql/mysql.mycnf b/main/mysql/mysql.mycnf
new file mode 100644
index 00000000000..6df0334eff8
--- /dev/null
+++ b/main/mysql/mysql.mycnf
@@ -0,0 +1,49 @@
+# The following values assume you have at least 32M RAM!
+
+[client]
+#password = my_password
+port = 3306
+socket = /var/run/mysqld/mysqld.sock
+
+[safe_mysqld]
+err-log = /var/log/mysql/mysql.err
+
+[mysqld]
+# this disabled mysqld from listing on any interface.
+# Use localhost to connect to socket
+# If you need networking comment out the following line
+skip-networking
+
+# If innodb is needed commend next line
+# if not leave this to increase performance
+skip-innodb
+
+innodb_file_per_table
+user = mysql
+pid-file = /var/run/mysqld/mysqld.pid
+socket = /var/run/mysqld/mysqld.sock
+port = 3306
+
+# Only enable this if you really need it
+# eats resources.
+#log = /var/log/mysql/mysql.log
+
+basedir = /usr
+datadir = /var/lib/mysql
+tmpdir = /tmp
+language = /usr/share/mysql/english
+skip-locking
+set-variable = key_buffer=16M
+set-variable = max_allowed_packet=1M
+set-variable = thread_stack=128K
+
+[mysqldump]
+quick
+set-variable = max_allowed_packet=1M
+
+[mysql]
+#no-auto-rehash # faster start of mysql but no tab completition
+
+[isamchk]
+set-variable = key_buffer=16M
+
diff --git a/main/nano/APKBUILD b/main/nano/APKBUILD
new file mode 100644
index 00000000000..ab2a8bfc56e
--- /dev/null
+++ b/main/nano/APKBUILD
@@ -0,0 +1,33 @@
+# Contributor: ms13sp <ms13sp@gmail.com>
+# Maintainer: ms13sp <ms13sp@gmail.com>
+pkgname=nano
+pkgver=2.0.9
+pkgmaj=2.0
+pkgrel=1
+pkgdesc="Text Editor. GNU nano is designed to be a free replacement for the Pico text editor."
+url="http://www.nano-editor.org/"
+license="GPL"
+depends="ncurses uclibc ncurses-terminfo"
+makedepends="ncurses-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://www.nano-editor.org/dist/v$pkgmaj/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-tiny \
+ --disable-nls \
+ --disable-speller
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ # install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ # install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+}
+
+md5sums="2be94dc43fb60fff4626a2401a977220 nano-2.0.9.tar.gz"
diff --git a/main/ncftp/APKBUILD b/main/ncftp/APKBUILD
new file mode 100644
index 00000000000..4a43f4582c8
--- /dev/null
+++ b/main/ncftp/APKBUILD
@@ -0,0 +1,38 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=ncftp
+pkgver=3.2.2
+pkgrel=1
+pkgdesc="A set of free application programs implementing FTP"
+url="http://www.ncftp.com/"
+license="custom"
+depends="uclibc"
+makedepends="ncurses-dev"
+install="$pkgname.post-install"
+source="ftp://ftp.$pkgname.com/$pkgname/$pkgname-$pkgver-src.tar.bz2
+$pkgname.post-install"
+subpackages="$pkgname-doc $pkgname-bookmarks"
+
+build () {
+ cd "${srcdir}/${pkgname}-${pkgver}" || return 1
+ install -d "${pkgdir}"/usr/share | return 1
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man || return 1
+ cd "${srcdir}/${pkgname}-${pkgver}"/libncftp
+ make shared || return 1
+ make PREFIX="${pkgdir}"/usr soinstall || return 1
+ cd "${srcdir}/${pkgname}-${pkgver}" || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -D doc/LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}"/LICENSE || return 1
+}
+
+bookmarks () {
+ depends="ncurses"
+ install=""
+ mkdir -p "$subpkgdir"/usr/bin || return 1
+ mv "$pkgdir"/usr/bin/ncftpbookmarks "$subpkgdir"/usr/bin/ || return 1
+}
+
+md5sums="b2b4b2fd38c81754b8f13895d784d491 ncftp-3.2.2-src.tar.bz2
+b2f4e60fb769c6c9461f28979efa087d ncftp.post-install"
diff --git a/main/ncftp/ncftp.post-install b/main/ncftp/ncftp.post-install
new file mode 100644
index 00000000000..e1ccb7b8393
--- /dev/null
+++ b/main/ncftp/ncftp.post-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+echo '*'
+echo '* If you like to install the ncurses based bookmark manager run: '
+echo '*'
+echo '* apk_add ncftp-bookmarks'
+echo '*'
+exit 0
diff --git a/main/neon/APKBUILD b/main/neon/APKBUILD
new file mode 100644
index 00000000000..76d099e4716
--- /dev/null
+++ b/main/neon/APKBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=neon
+pkgver=0.28.4
+pkgrel=1
+pkgdesc="HTTP and WebDAV client library with a C interface"
+url="http://www.webdav.org/neon/"
+license="GPL LGPL"
+depends="openssl zlib expat"
+makedepends="expat-dev openssl-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://www.webdav.org/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build () {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --with-ssl \
+ --with-expat \
+ --without-gssapi \
+ --disable-nls \
+ --disable-socks \
+ --enable-shared \
+ --disable-static \
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="6c3b94362af743d046e198e9fcbe4a85 neon-0.28.4.tar.gz"
diff --git a/main/net-snmp/APKBUILD b/main/net-snmp/APKBUILD
new file mode 100644
index 00000000000..ac497cb9b3d
--- /dev/null
+++ b/main/net-snmp/APKBUILD
@@ -0,0 +1,57 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=net-snmp
+pkgver=5.4.2.1
+pkgrel=0
+pkgdesc="Simple Network Management Protocol"
+url="http://www.net-snmp.org/"
+license="GPL"
+depends=
+makedepends="perl-dev"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-tools"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+snmpd.initd
+snmpd.confd
+snmptrapd.initd
+snmptrapd.confd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ export lt_cv_sys_max_cmd_len=8192
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/snmp \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-default-snmp-version="3" \
+ --with-sys-contact="root@unknown" \
+ --with-sys-location="unknown" \
+ --with-logfile="/var/log/net-snmpd.log" \
+ --enable-ucd-snmp-compatibility \
+ --with-persistent-directory="/var/lib/net-snmp" \
+ --enable-shared \
+ --enable-as-needed
+
+ make -j1 || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/snmpd.initd "$pkgdir"/etc/init.d/snmpd
+ install -m644 -D "$srcdir"/snmpd.confd "$pkgdir"/etc/conf.d/snmpd
+ install -m755 -D "$srcdir"/snmptrapd.initd "$pkgdir"/etc/init.d/snmptrapd
+ install -m644 -D "$srcdir"/snmptrapd.confd "$pkgdir"/etc/conf.d/snmptrapd
+ install -m644 -D EXAMPLE.conf "$pkgdir"/etc/snmp/snmpd.conf.example
+ mkdir -p "$pkgdir"/var/lib/net-snmp
+}
+
+tools() {
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr
+}
+
+
+md5sums="984932520143f0c8bf7b7ce1fc9e1da1 net-snmp-5.4.2.1.tar.gz
+941e257218aa773b33696a2c7222a14e snmpd.initd
+96510a2f3bc9f21648b03f7e8d76c0d3 snmpd.confd
+c5198c350991637849595dba93019bda snmptrapd.initd
+363f7728a76bdfc46e29b7e1f5cf4950 snmptrapd.confd"
diff --git a/main/net-snmp/snmpd.confd b/main/net-snmp/snmpd.confd
new file mode 100644
index 00000000000..ad48a1d94d1
--- /dev/null
+++ b/main/net-snmp/snmpd.confd
@@ -0,0 +1,14 @@
+# Initial (empty) options.
+OPTS=""
+
+# Enable connection logging.
+#SNMPD_FLAGS="${OPTS} -a"
+
+# Enable syslog and disable file log.
+#SNMPD_FLAGS="${OPTS} -Lsd -Lf /dev/null"
+
+# Enable agentx socket as /var/agentx/master
+# *NOTE* Before uncommenting this, make sure
+# the /var/agentx directory exists.
+#SNMPD_FLAGS="${OPTS} -x /var/agentx/master"
+
diff --git a/main/net-snmp/snmpd.initd b/main/net-snmp/snmpd.initd
new file mode 100644
index 00000000000..49beda58d82
--- /dev/null
+++ b/main/net-snmp/snmpd.initd
@@ -0,0 +1,30 @@
+#!/sbin/runscript
+
+NAME=snmpd
+DAEMON=/usr/sbin/$NAME
+
+depend() {
+ use logger
+ need net
+}
+
+checkconfig() {
+ if [ ! -e /etc/snmp/snmpd.conf ] ; then
+ eerror "You need an /etc/snmp/snmpd.conf config file to run snmpd"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet --background \
+ --exec ${DAEMON} -- -p /var/run/${NAME}.pid ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid
+ eend $?
+}
diff --git a/main/net-snmp/snmptrapd.confd b/main/net-snmp/snmptrapd.confd
new file mode 100644
index 00000000000..d9cee614ea4
--- /dev/null
+++ b/main/net-snmp/snmptrapd.confd
@@ -0,0 +1,12 @@
+# extra flags to pass to snmptrapd
+OPTS=""
+
+# ignore authentication failure traps
+#SNMPTRAPD_FLAGS="${OPTS} -a"
+
+# log messages to specified file
+#SNMPTRAPD_FLAGS="${OPTS} -Lf /var/log/snmptrapd.log"
+
+# log messages to syslog with the specified facility
+# where facility is: 'd' = LOG_DAEMON, 'u' = LOG_USER, [0-7] = LOG_LOCAL[0-7]
+#SNMPTRAPD_FLAGS="${OPTS} -Ls d"
diff --git a/main/net-snmp/snmptrapd.initd b/main/net-snmp/snmptrapd.initd
new file mode 100644
index 00000000000..bf56233ab6a
--- /dev/null
+++ b/main/net-snmp/snmptrapd.initd
@@ -0,0 +1,22 @@
+#!/sbin/runscript
+
+NAME=snmptrapd
+DAEMON=/usr/sbin/$NAME
+
+depend() {
+ use logger
+ need net
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet --background \
+ --exec ${DAEMON} -- -p /var/run/${NAME}.pid ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid
+ eend $?
+}
diff --git a/main/newt/APKBUILD b/main/newt/APKBUILD
new file mode 100644
index 00000000000..dc81b8b6709
--- /dev/null
+++ b/main/newt/APKBUILD
@@ -0,0 +1,35 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=newt
+pkgver=0.52.8
+pkgrel=0
+pkgdesc="Redhat's Newt windowing toolkit development files"
+url="http://www.redhat.com/"
+license="LGPL-2"
+depends="uclibc slang popt ncurses"
+makedepends="slang-dev popt-dev python-dev ncurses-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://distfiles.gentoo.org/distfiles/$pkgname-$pkgver.tar.gz
+ $pkgname-0.52.7-notcl.patch
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ sed -i -e 's:-lslang:-lslang -lncurses:g' \
+ -e 's:instroot:DESTDIR:g' Makefile.in || return 1
+
+ ./configure --prefix=/usr \
+ --without-gpm \
+ --without-tcl \
+ --disable-nls
+ make -j1 RPM_OPT_FLAGS="$CFLAGS" || return 1
+ # TODO: fix the make install target to not try install po files
+ make -j1 DESTDIR="$pkgdir" prefix="/usr" RPM_OPT_FLAGS="ERROR" install \
+ || true
+}
+md5sums="0daef93590e9b6fd3419c871e75f9fa7 newt-0.52.8.tar.gz
+6780156f3b66a3f05efe1ee821617031 newt-0.52.7-notcl.patch"
diff --git a/main/newt/newt-0.52.7-notcl.patch b/main/newt/newt-0.52.7-notcl.patch
new file mode 100644
index 00000000000..b9f86e6b605
--- /dev/null
+++ b/main/newt/newt-0.52.7-notcl.patch
@@ -0,0 +1,35 @@
+--- newt-0.52.7/Makefile.in.orig 2008-01-15 16:57:12.000000000 +0100
++++ newt-0.52.7/Makefile.in 2008-01-15 16:58:38.000000000 +0100
+@@ -15,7 +15,7 @@
+ PYTHONVERS = @PYTHONVERS@
+ WHIPTCLSO = @WHIPTCLSO@
+
+-PROGS = test whiptail $(WHIPTCLSO) testgrid testtree showchars showkey
++PROGS = test whiptail testgrid testtree showchars showkey
+ TESTOBJS = test.o testgrid.o testtree.o showchars.o showkey.o
+ NDIALOGOBJS = whiptail.o dialogboxes.o
+ WHIPTCLOBJS = shared/whiptcl.o shared/dialogboxes.o
+@@ -78,9 +78,6 @@
+ whiptail: $(NDIALOGOBJS) $(LIBNEWTSH)
+ $(CC) -g -o whiptail $(NDIALOGOBJS) -L . -lnewt $(LIBS) -lpopt
+
+-whiptcl.so: $(WHIPTCLOBJS) $(LIBNEWTSH)
+- $(CC) -shared $(SHCFLAGS) -o whiptcl.so $(WHIPTCLOBJS) -L . -lnewt $(LIBTCL) -lslang -lpopt -lm
+-
+ $(LIBNEWT): $(LIBOBJS)
+ ar rv $@ $^
+
+@@ -120,12 +117,11 @@
+ install -m 644 whiptail.1 $(instroot)/$(man1dir)
+ make -C po datadir=$(instroot)/$(datadir) install
+
+-install-sh: sharedlib $(WHIPTCLSO) _snackmodule.so
++install-sh: sharedlib _snackmodule.so
+ [ -d $(instroot)/$(libdir) ] || install -m 755 -d $(instroot)/$(libdir)
+ install -m 755 $(LIBNEWTSH) $(instroot)/$(libdir)
+ ln -sf $(LIBNEWTSONAME) $(instroot)/$(libdir)/libnewt.so
+ ln -sf $(LIBNEWTSH) $(instroot)/$(libdir)/$(LIBNEWTSONAME)
+- [ -n "$(WHIPTCLSO)" ] && install -m 755 whiptcl.so $(instroot)/$(libdir) || :
+ for ver in $(PYTHONVERS) ; do \
+ [ -d $(instroot)/$(libdir)/$$ver/site-packages ] || install -m 755 -d $(instroot)/$(libdir)/$$ver/site-packages ;\
+ install -m 755 $$ver/_snackmodule.so $(instroot)/$(libdir)/$$ver/site-packages ;\
diff --git a/main/nfs-utils/APKBUILD b/main/nfs-utils/APKBUILD
new file mode 100644
index 00000000000..b9225f96635
--- /dev/null
+++ b/main/nfs-utils/APKBUILD
@@ -0,0 +1,54 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=nfs-utils
+pkgver=1.2.0
+pkgrel=0
+pkgdesc="kernel-mode NFS"
+url="http://nfs.sourceforge.net/"
+license="GPL"
+depends="portmap"
+makedepends="e2fsprogs-dev"
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/nfs/$pkgname-$pkgver.tar.bz2
+ nfs.initd
+ nfs.confd
+ nfs.exports
+ nfs-utils-no-exec.patch
+ nfs-utils-mtab-sym.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for i in "$srcdir"/*.patch; do
+ msg "Applying $i"
+ patch -p0 -i "${i}" || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --without-tcp-wrappers \
+ --disable-nfsv4 \
+ --enable-uuid \
+ --disable-gss \
+ --enable-mount \
+ --enable-nfsv3 \
+ --with-statedir=/var/lib/nfs
+
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/nfs.initd "$pkgdir"/etc/init.d/nfs
+ install -m644 -D "$srcdir"/nfs.confd "$pkgdir"/etc/conf.d/nfs
+ install -m644 -D "$srcdir"/nfs.exports "$pkgdir"/etc/exports
+ #mkdir -p "$pkgdir"/usr/lib/nfs
+ install -m755 -D tools/rpcgen/rpcgen "$pkgdir"/usr/bin/rpcgen
+}
+
+md5sums="779cf81044e92cb51ad590960e7b3671 nfs-utils-1.2.0.tar.bz2
+4538f67470c916f8da9c76a17e314906 nfs.initd
+09135438d6df50b868bbe5a2260f973c nfs.confd
+4f1bb7b2412ce5952ecb5ec22d8ed99d nfs.exports
+5e0963b0889e779ff36af0299d17d6cb nfs-utils-no-exec.patch
+a3a7338f8de3ac37c1ffc05bdcb77d16 nfs-utils-mtab-sym.patch"
diff --git a/main/nfs-utils/nfs-utils-mtab-sym.patch b/main/nfs-utils/nfs-utils-mtab-sym.patch
new file mode 100644
index 00000000000..1ebbd99b574
--- /dev/null
+++ b/main/nfs-utils/nfs-utils-mtab-sym.patch
@@ -0,0 +1,38 @@
+--- utils/mount/fstab.c
++++ utils/mount/fstab.c
+@@ -57,7 +57,7 @@ mtab_does_not_exist(void) {
+ return var_mtab_does_not_exist;
+ }
+
+-static int
++int
+ mtab_is_a_symlink(void) {
+ get_mtab_info();
+ return var_mtab_is_a_symlink;
+--- utils/mount/fstab.h
++++ utils/mount/fstab.h
+@@ -7,6 +7,7 @@
+ #define _PATH_FSTAB "/etc/fstab"
+ #endif
+
++int mtab_is_a_symlink(void);
+ int mtab_is_writable(void);
+ int mtab_does_not_exist(void);
+ void reset_mtab_info(void);
+--- utils/mount/mount.c
++++ utils/mount/mount.c
+@@ -230,6 +230,13 @@ create_mtab (void) {
+ int flags;
+ mntFILE *mfp;
+
++ /* Avoid writing if the mtab is a symlink to /proc/mounts, since
++ that would create a file /proc/mounts in case the proc filesystem
++ is not mounted, and the fchmod below would also fail. */
++ if (mtab_is_a_symlink()) {
++ return EX_SUCCESS;
++ }
++
+ lock_mtab();
+
+ mfp = nfs_setmntent (MOUNTED, "a+");
+
diff --git a/main/nfs-utils/nfs-utils-no-exec.patch b/main/nfs-utils/nfs-utils-no-exec.patch
new file mode 100644
index 00000000000..94a73d366f4
--- /dev/null
+++ b/main/nfs-utils/nfs-utils-no-exec.patch
@@ -0,0 +1,13 @@
+--- utils/mount/mount.c Wed Apr 8 09:25:26 2009
++++ utils/mount/mount.c Wed Apr 8 09:25:26 2009
+@@ -407,10 +407,6 @@
+ mount_error(NULL, mount_point, ENOTDIR);
+ return 1;
+ }
+- if (access(mount_point, X_OK) < 0) {
+- mount_error(NULL, mount_point, errno);
+- return 1;
+- }
+
+ return 0;
+ }
diff --git a/main/nfs-utils/nfs.confd b/main/nfs-utils/nfs.confd
new file mode 100644
index 00000000000..98a143a654d
--- /dev/null
+++ b/main/nfs-utils/nfs.confd
@@ -0,0 +1,30 @@
+# /etc/conf.d/nfs
+
+# If you wish to set the port numbers for lockd,
+# please see /etc/sysctl.conf
+
+# Number of servers to be started up by default
+OPTS_RPC_NFSD="8"
+
+# Options to pass to rpc.mountd
+# ex. OPTS_RPC_MOUNTD="-p 32767"
+OPTS_RPC_MOUNTD=""
+
+# Options to pass to rpc.statd
+# ex. OPTS_RPC_STATD="-p 32765 -o 32766"
+OPTS_RPC_STATD=""
+
+# Options to pass to rpc.idmapd
+OPTS_RPC_IDMAPD=""
+
+# Options to pass to rpc.gssd
+OPTS_RPC_GSSD=""
+
+# Options to pass to rpc.svcgssd
+OPTS_RPC_SVCGSSD=""
+
+# Options to pass to rpc.rquotad (requires sys-fs/quota)
+OPTS_RPC_RQUOTAD=""
+
+# Timeout (in seconds) for exportfs
+EXPORTFS_TIMEOUT=30
diff --git a/main/nfs-utils/nfs.exports b/main/nfs-utils/nfs.exports
new file mode 100644
index 00000000000..dc0b8392714
--- /dev/null
+++ b/main/nfs-utils/nfs.exports
@@ -0,0 +1,7 @@
+# /etc/exports
+#
+# See exports(5) for a description.
+
+# use exportfs -arv to reread
+#/export 192.168.1.10(rw,no_root_squash)
+
diff --git a/main/nfs-utils/nfs.initd b/main/nfs-utils/nfs.initd
new file mode 100644
index 00000000000..e9711d914db
--- /dev/null
+++ b/main/nfs-utils/nfs.initd
@@ -0,0 +1,154 @@
+#!/sbin/runscript
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-fs/nfs-utils/files/nfs.initd,v 1.18 2009/02/27 01:41:55 vapier Exp $
+
+opts="reload"
+
+# This variable is used for controlling whether or not to run exportfs -ua;
+# see stop() for more information
+restarting=no
+
+# The binary locations
+exportfs=/usr/sbin/exportfs
+ mountd=/usr/sbin/rpc.mountd
+ nfsd=/usr/sbin/rpc.nfsd
+smnotify=/usr/sbin/sm-notify
+
+depend() {
+ local myneed=""
+ if [ -e /etc/exports ] ; then
+ if awk '!/^[[:space:]]*#/ && $2 ~ /sec=/ { exit 0 } END { exit 1 }' /etc/exports ; then
+ myneed="${myneed} rpc.svcgssd"
+ fi
+ fi
+ config /etc/exports
+ need portmap rpc.statd ${myneed}
+ use ypbind net dns rpc.rquotad rpc.idmapd rpc.svcgssd
+ after quota
+}
+
+mkdir_nfsdirs() {
+ local d
+ for d in rpc_pipefs v4recovery v4root ; do
+ d="/var/lib/nfs/${d}"
+ [ ! -d "${d}" ] && mkdir -p "${d}"
+ done
+}
+
+waitfor_exportfs() {
+ local pid=$1
+ ( sleep ${EXPORTFS_TIMEOUT:-30}; kill -9 $pid 2>/dev/null ) &
+ wait $1
+}
+
+mount_nfsd() {
+ if [ -e /proc/modules ] ; then
+ # Make sure nfs support is loaded in the kernel #64709
+ if ! grep -qs nfsd /proc/filesystems ; then
+ modprobe -q nfsd
+ fi
+ # Restart idmapd if needed #220747
+ if grep -qs nfsd /proc/modules ; then
+ killall -q -HUP rpc.idmapd
+ fi
+ fi
+
+ # This is the new "kernel 2.6 way" to handle the exports file
+ if grep -qs nfsd /proc/filesystems ; then
+ if ! grep -qs "nfsd /proc/fs/nfsd" /proc/mounts ; then
+ ebegin "Mounting nfsd filesystem in /proc"
+ mount -t nfsd -o nodev,noexec,nosuid nfsd /proc/fs/nfsd
+ eend $?
+ fi
+ fi
+}
+
+start_it() {
+ ebegin "Starting NFS $1"
+ shift
+ "$@"
+ eend $?
+ ret=$((ret + $?))
+}
+start() {
+ mount_nfsd
+ mkdir_nfsdirs
+
+ # Exportfs likes to hang if networking isn't working.
+ # If that's the case, then try to kill it so the
+ # bootup process can continue.
+ if grep -qs '^[[:space:]]*/' /etc/exports ; then
+ ebegin "Exporting NFS directories"
+ ${exportfs} -r &
+ waitfor_exportfs $!
+ eend $?
+ fi
+
+ local ret=0
+ start_it mountd ${mountd} ${OPTS_RPC_MOUNTD}
+ start_it daemon ${nfsd} ${OPTS_RPC_NFSD}
+ [ -x "${smnotify}" ] && start_it smnotify ${smnotify} ${OPTS_SMNOTIFY}
+ return ${ret}
+}
+
+stop() {
+ local ret=0
+
+ # Don't check NFSSERVER variable since it might have changed,
+ # instead use --oknodo to smooth things over
+ ebegin "Stopping NFS mountd"
+ start-stop-daemon --stop --oknodo --exec ${mountd}
+ eend $?
+ ret=$((ret + $?))
+
+ # nfsd sets its process name to [nfsd] so don't look for $nfsd
+ ebegin "Stopping NFS daemon"
+ start-stop-daemon --stop --oknodo --name nfsd --user root --signal 2
+ eend $?
+ ret=$((ret + $?))
+ # in case things don't work out ... #228127
+ rpc.nfsd 0
+
+ # When restarting the NFS server, running "exportfs -ua" probably
+ # isn't what the user wants. Running it causes all entries listed
+ # in xtab to be removed from the kernel export tables, and the
+ # xtab file is cleared. This effectively shuts down all NFS
+ # activity, leaving all clients holding stale NFS filehandles,
+ # *even* when the NFS server has restarted.
+ #
+ # That's what you would want if you were shutting down the NFS
+ # server for good, or for a long period of time, but not when the
+ # NFS server will be running again in short order. In this case,
+ # then "exportfs -r" will reread the xtab, and all the current
+ # clients will be able to resume NFS activity, *without* needing
+ # to umount/(re)mount the filesystem.
+ if [ "${restarting}" = no -o "${RC_CMD}" = "restart" ] ; then
+ ebegin "Unexporting NFS directories"
+ # Exportfs likes to hang if networking isn't working.
+ # If that's the case, then try to kill it so the
+ # shutdown process can continue.
+ ${exportfs} -ua &
+ waitfor_exportfs $!
+ eend $?
+ fi
+
+ return ${ret}
+}
+
+reload() {
+ # Exportfs likes to hang if networking isn't working.
+ # If that's the case, then try to kill it so the
+ # bootup process can continue.
+ ebegin "Reloading /etc/exports"
+ ${exportfs} -r 1>&2 &
+ waitfor_exportfs $!
+ eend $?
+}
+
+restart() {
+ # See long comment in stop() regarding "restarting" and exportfs -ua
+ restarting=yes
+ svc_stop
+ svc_start
+}
diff --git a/main/ngircd/APKBUILD b/main/ngircd/APKBUILD
new file mode 100644
index 00000000000..2f618a0776c
--- /dev/null
+++ b/main/ngircd/APKBUILD
@@ -0,0 +1,36 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ngircd
+pkgver=14.1
+pkgrel=0
+pkgdesc="Next Generation IRC Daemon"
+url="http://ngircd.barton.de/"
+license="GPL"
+makedepends=""
+makedepends="openssl-dev zlib-dev"
+install="$pkgname.pre-install"
+source="ftp://ftp.berlios.de/pub/$pkgname/$pkgname-$pkgver.tar.gz
+ $pkgname.initd
+ $install"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ sed -i \
+ -e "s:/usr/local/etc/ngircd.motd:/etc/ngircd/ngircd.motd:" \
+ -e "s:;ServerUID = 65534:ServerUID = ngircd:" \
+ -e "s:;ServerGID = 65534:ServerGID = nogroup:" \
+ doc/sample-ngircd.conf
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/ngircd \
+ --mandir=/usr/share/man \
+ --without-ident \
+ --with-openssl
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -Dm755 ../$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+}
+
+md5sums="eef90855414c35bfb6590d17e24ee06f ngircd-14.1.tar.gz
+1a91f517ef865b51d67b77ceb28e4261 ngircd.initd
+c8fbedf0690f35ba565e6a1937afd4fb ngircd.pre-install"
diff --git a/main/ngircd/ngircd.initd b/main/ngircd/ngircd.initd
new file mode 100644
index 00000000000..807d844e8d9
--- /dev/null
+++ b/main/ngircd/ngircd.initd
@@ -0,0 +1,21 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-irc/ngircd/files/ngircd.init.d,v 1.3 2006/01/02 15:31:27 swegener Exp $
+
+depend() {
+ need net
+ provide ircd
+}
+
+start() {
+ ebegin "Starting ngIRCd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/ngircd
+ eend $? "Failed to start ngIRCd"
+}
+
+stop() {
+ ebegin "Stopping ngIRCd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/ngircd
+ eend $? "Failed to stop ngIRCd"
+}
diff --git a/main/ngircd/ngircd.pre-install b/main/ngircd/ngircd.pre-install
new file mode 100644
index 00000000000..062e37ae4f7
--- /dev/null
+++ b/main/ngircd/ngircd.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -H -h /etc/ngircd -s /bin/false -D ngircd 2>/dev/null
+exit 0
diff --git a/main/nmap/APKBUILD b/main/nmap/APKBUILD
new file mode 100644
index 00000000000..bb04078768c
--- /dev/null
+++ b/main/nmap/APKBUILD
@@ -0,0 +1,47 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=nmap
+pkgver=4.76
+pkgrel=2
+pkgdesc="A network exploration tool and security/port scanner"
+url="http:/nmap.org"
+license="custom:GPL"
+depends="pcre libpcap uclibc++ openssl lua"
+makedepends="uclibc++-dev libpcap-dev openssl-dev lua-dev"
+install=
+subpackages="$pkgname-doc $pkgname-nse"
+source="http://nmap.org/dist/$pkgname-$pkgver.tgz
+ nmap-4.53-uclibc++-output.cc.patch
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ export CXX=g++-uc
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --without-zenmap \
+ --with-liblua=/usr/include \
+ --with-openssl=/usr/lib
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ # install custom GPL2 license
+ install -D -m644 COPYING ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
+}
+
+nse() {
+ mkdir -p "$subpkgdir"/usr/share/$pkgname
+ mv "$pkgdir"/usr/share/$pkgname/nselib "$subpkgdir"/usr/share/$pkgname/
+ mv "$pkgdir"/usr/share/$pkgname/scripts "$subpkgdir"/usr/share/$pkgname/
+}
+
+md5sums="54b5c9e3f44c1adde17df68170eb7cfe nmap-4.76.tgz
+507b0936aaafaeddebad309b0924de39 nmap-4.53-uclibc++-output.cc.patch"
diff --git a/main/nmap/nmap-4.53-uclibc++-output.cc.patch b/main/nmap/nmap-4.53-uclibc++-output.cc.patch
new file mode 100644
index 00000000000..3253fc26b31
--- /dev/null
+++ b/main/nmap/nmap-4.53-uclibc++-output.cc.patch
@@ -0,0 +1,11 @@
+--- nmap/output.cc.orig 2007-12-15 09:54:07.000000000 -0800
++++ nmap/output.cc 2007-12-15 09:54:19.000000000 -0800
+@@ -1904,7 +1904,7 @@
+
+ /* Compares this record to another. First compare the directory names, then
+ compare the file names. */
+- bool operator<(const struct data_file_record& other) {
++ bool operator<(const struct data_file_record& other) const {
+ int cmp;
+
+ cmp = dir.compare(other.dir);
diff --git a/main/ntfs-3g/APKBUILD b/main/ntfs-3g/APKBUILD
new file mode 100644
index 00000000000..5575e696de1
--- /dev/null
+++ b/main/ntfs-3g/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ntfs-3g
+pkgver=2009.4.4
+pkgrel=0
+pkgdesc="A userspace ntfs driver with write support"
+url="http://www.ntfs-3g.org"
+license="GPL"
+depends="uclibc"
+makedepends=""
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://www.ntfs-3g.org/${pkgname}-${pkgver}.tgz
+ nocxx.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch configure < ../nocxx.patch || return 1
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" LDCONFIG=: install
+
+}
+
+md5sums="e0b5c170f088a8d82968f0a6b34d31da ntfs-3g-2009.4.4.tgz
+28513788ba4d556ccd538867dc6205ab nocxx.patch"
diff --git a/main/ntfs-3g/nocxx.patch b/main/ntfs-3g/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/ntfs-3g/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/oidentd/APKBUILD b/main/oidentd/APKBUILD
new file mode 100644
index 00000000000..130283f72ac
--- /dev/null
+++ b/main/oidentd/APKBUILD
@@ -0,0 +1,34 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=oidentd
+pkgver=2.0.8
+pkgrel=0
+pkgdesc="Configurable IDENT server that supports NAT/IP masq."
+url="http://dev.ojnk.net/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/ojnk/$pkgname-$pkgver.tar.gz
+oidentd.conf
+oidentd.initd
+oidentd.confd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ install -D -m644 "$srcdir"/$pkgname.conf "$pkgdir"/etc/$pkgname.conf
+
+}
+
+md5sums="c3d9a56255819ef8904b867284386911 oidentd-2.0.8.tar.gz
+d9c40e4d6a0bde685a359ad49b4eada2 oidentd.conf
+89a027c3b8245f6c5e79930d16d485f7 oidentd.initd
+05a43d3987754f179f4e31bbe61ff315 oidentd.confd"
diff --git a/main/oidentd/oidentd.conf b/main/oidentd/oidentd.conf
new file mode 100644
index 00000000000..03b28d82780
--- /dev/null
+++ b/main/oidentd/oidentd.conf
@@ -0,0 +1,22 @@
+# Configuration for oidentd
+# see oidentd.conf(5)
+#
+default {
+ default {
+ deny spoof
+ deny spoof_all
+ deny spoof_privport
+ allow random
+ allow random_numeric
+ allow numeric
+ deny hide
+ }
+}
+
+# you may want to hide root connections
+#user "root" {
+# default {
+# force reply "UNKNOWN"
+# }
+#}
+
diff --git a/main/oidentd/oidentd.confd b/main/oidentd/oidentd.confd
new file mode 100644
index 00000000000..3116889e67e
--- /dev/null
+++ b/main/oidentd/oidentd.confd
@@ -0,0 +1,4 @@
+# oidentd start-up options
+USER="nobody"
+GROUP="nobody"
+OPTIONS=""
diff --git a/main/oidentd/oidentd.initd b/main/oidentd/oidentd.initd
new file mode 100644
index 00000000000..c40b058dac8
--- /dev/null
+++ b/main/oidentd/oidentd.initd
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-misc/oidentd/files/oidentd-2.0.7-init,v 1.4 2007/10/24 11:38:14 uberlord Exp $
+
+depend() {
+ need net
+}
+
+check_config() {
+ if [ -z "${USER}" ]
+ then
+ eerror "Please set \$USER in /etc/conf.d/oidentd!"
+ return 1
+ fi
+ if [ -z "${GROUP}" ]
+ then
+ eerror "Please set \$GROUP in /etc/conf.d/oidentd!"
+ return 1
+ fi
+
+ if [ "$(sysctl -n security.bsd.see_other_uids 2>/dev/null)" = "0" ]; then
+ eerror "${SVCNAME} cannot work if the sysctl security.bsd.see_other_uids is 0"
+ return 1
+ fi
+}
+
+
+start() {
+ check_config || return 1
+ ebegin "Starting oidentd"
+ OPTIONS="${OPTIONS} -u ${USER} -g ${GROUP}"
+ start-stop-daemon --start --quiet --exec /usr/sbin/oidentd -- $OPTIONS
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping oidentd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/oidentd
+ eend $?
+}
+
diff --git a/main/openldap/APKBUILD b/main/openldap/APKBUILD
new file mode 100644
index 00000000000..bb4db8296e2
--- /dev/null
+++ b/main/openldap/APKBUILD
@@ -0,0 +1,80 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=openldap
+pkgver=2.4.16
+pkgrel=1
+pkgdesc="LDAP Server"
+url="http://www.openldap.org/"
+license="custom"
+depends="db openssl uclibc libldap"
+makedepends="db-dev openssl-dev groff"
+subpackages="$pkgname-dev $pkgname-doc libldap"
+install="$pkgname.pre-install $pkgname.post-install"
+source="ftp://ftp.$pkgname.org/pub/OpenLDAP/$pkgname-release/$pkgname-$pkgver.tgz
+ openldap-2.4-ppolicy.patch
+ openldap-2.4.11-libldap_r.patch
+ $install
+ slapd.initd
+ slapd.confd
+ slurpd.initd
+ "
+
+# berkdb crypt ipv6 ssl
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --libexecdir=/usr/sbin \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var/lib/openldap \
+ --enable-slapd \
+ --enable-bdb \
+ --enable-hdb \
+ --enable-crypt \
+ --enable-dynamic \
+ --enable-dnssrv=mod \
+ --enable-ldap=mod \
+ --enable-meta=mod \
+ --enable-monitor=mod \
+ --enable-null=mod \
+ --enable-passwd=mod \
+ --enable-relay=mod \
+ --enable-shell=mod \
+ --enable-sock=mod \
+ --with-tls=openssl
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -d "$pkgdir"/var/run/openldap
+ sed -i -e 's:/var/lib/openldap/run:/var/run/openldap:g' \
+ "$pkgdir"/etc/openldap/slapd.conf
+
+ chmod g+r "$pkgdir"/etc/openldap/slapd.conf
+ install -Dm755 ../slapd.initd "$pkgdir"/etc/init.d/slapd
+ install -Dm755 ../slapd.confd "$pkgdir"/etc/conf.d/slapd
+ install -Dm755 ../slurpd.initd "$pkgdir"/etc/init.d/slurpd
+}
+
+libldap() {
+ depends="uclibc openssl"
+ pkgdesc="OpenLDAP libraries"
+ install=
+ mkdir -p "$subpkgdir"/usr "$subpkgdir"/etc/openldap
+ mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
+ mv "$pkgdir"/etc/openldap/ldap.conf "$subpkgdir"/etc/openldap/
+}
+
+md5sums="ed5b86e9d2b372d10edfe3bb59fee165 openldap-2.4.16.tgz
+2524e490ba334a760fa57057c16da7a9 openldap-2.4-ppolicy.patch
+d19d0502f046078ecd737e29e7552fa8 openldap-2.4.11-libldap_r.patch
+07b1fae35627ea4216dccce33c0b8c69 openldap.pre-install
+f38a6f1de624c17cc0cb6776a089880b openldap.post-install
+13d0e57e54df945671e975acdfb48636 slapd.initd
+b672311fca605c398240cd37a2ae080a slapd.confd
+ba44f1a0e62cb88c68aa64e4a39847fa slurpd.initd"
diff --git a/main/openldap/openldap-2.4-ppolicy.patch b/main/openldap/openldap-2.4-ppolicy.patch
new file mode 100644
index 00000000000..c05790e3e29
--- /dev/null
+++ b/main/openldap/openldap-2.4-ppolicy.patch
@@ -0,0 +1,13 @@
+diff -urN ./clients.orig/tools/common.c ./clients/tools/common.c
+--- ./clients.orig/tools/common.c 2007-09-01 01:13:50.000000000 +0200
++++ ./clients/tools/common.c 2008-01-13 21:50:06.000000000 +0100
+@@ -1262,8 +1262,8 @@
+ int nsctrls = 0;
+
+ #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
++ LDAPControl c;
+ if ( ppolicy ) {
+- LDAPControl c;
+ c.ldctl_oid = LDAP_CONTROL_PASSWORDPOLICYREQUEST;
+ c.ldctl_value.bv_val = NULL;
+ c.ldctl_value.bv_len = 0;
diff --git a/main/openldap/openldap-2.4.11-libldap_r.patch b/main/openldap/openldap-2.4.11-libldap_r.patch
new file mode 100644
index 00000000000..448249a3b58
--- /dev/null
+++ b/main/openldap/openldap-2.4.11-libldap_r.patch
@@ -0,0 +1,11 @@
+diff -Nuar openldap-2.4.11.orig/servers/slapd/slapi/Makefile.in openldap-2.4.11/servers/slapd/slapi/Makefile.in
+--- openldap-2.4.11.orig/servers/slapd/slapi/Makefile.in 2008-02-11 15:26:49.000000000 -0800
++++ openldap-2.4.11/servers/slapd/slapi/Makefile.in 2008-10-14 02:10:18.402799262 -0700
+@@ -37,6 +37,7 @@
+ XLIBS = $(LIBRARY)
+ XXLIBS =
+ NT_LINK_LIBS = $(AC_LIBS)
++UNIX_LINK_LIBS = ../../../libraries/libldap_r/libldap_r.la $(LTHREAD_LIBS)
+
+ XINCPATH = -I$(srcdir)/.. -I$(srcdir)
+ XDEFS = $(MODULES_CPPFLAGS)
diff --git a/main/openldap/openldap.post-install b/main/openldap/openldap.post-install
new file mode 100644
index 00000000000..1d6affdfee0
--- /dev/null
+++ b/main/openldap/openldap.post-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+chown -R ldap:ldap /var/lib/openldap /var/run/openldap
+chgrp ldap /etc/openldap/slapd.conf
diff --git a/main/openldap/openldap.pre-install b/main/openldap/openldap.pre-install
new file mode 100644
index 00000000000..b208a9f5f2e
--- /dev/null
+++ b/main/openldap/openldap.pre-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+adduser -h /usr/lib/openldap -s /bin/false -S -D ldap 2>/dev/null || true
diff --git a/main/openldap/slapd.confd b/main/openldap/slapd.confd
new file mode 100644
index 00000000000..2240ad3f302
--- /dev/null
+++ b/main/openldap/slapd.confd
@@ -0,0 +1,9 @@
+# conf.d file for openldap
+#
+# To enable both the standard unciphered server and the ssl encrypted
+# one uncomment this line or set any other server starting options
+# you may desire.
+#
+# OPTS="-h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
+# Uncomment the below to use the new slapd configuration for openldap 2.3
+#OPTS="-F /etc/openldap/slapd.d -h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
diff --git a/main/openldap/slapd.initd b/main/openldap/slapd.initd
new file mode 100644
index 00000000000..1637d3335ae
--- /dev/null
+++ b/main/openldap/slapd.initd
@@ -0,0 +1,20 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-nds/openldap/files/slapd-initd,v 1.2 2008/10/14 10:29:44 robbat2 Exp $
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting ldap-server"
+ eval start-stop-daemon --start --pidfile /var/run/openldap/slapd.pid --exec /usr/sbin/slapd -- -u ldap -g ldap "${OPTS}"
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ldap-server"
+ start-stop-daemon --stop --signal 2 --quiet --pidfile /var/run/openldap/slapd.pid
+ eend $?
+}
diff --git a/main/openldap/slurpd.initd b/main/openldap/slurpd.initd
new file mode 100644
index 00000000000..f5aa2ead5a3
--- /dev/null
+++ b/main/openldap/slurpd.initd
@@ -0,0 +1,22 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-nds/openldap/files/slurpd-initd,v 1.1 2007/01/16 23:22:02 jokey Exp $
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting slurpd"
+ start-stop-daemon --start --quiet \
+ --exec /usr/lib/openldap/slurpd
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping slurpd"
+ start-stop-daemon --stop --quiet \
+ --exec /usr/lib/openldap/slurpd
+ eend $?
+}
diff --git a/main/opennhrp/APKBUILD b/main/opennhrp/APKBUILD
new file mode 100644
index 00000000000..c72d0d269cd
--- /dev/null
+++ b/main/opennhrp/APKBUILD
@@ -0,0 +1,33 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=opennhrp
+pkgver=0.11
+pkgrel=0
+pkgdesc="NBMA Next Hop Resolution Protocol daemon"
+url="http://sourceforge.net/projects/opennhrp"
+license="GPL-3"
+depends=
+makedepends="c-ares-dev"
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2
+ opennhrp-0.9.3-peer-up-bgp.patch
+ $pkgname.initd
+ $pkgname.confd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ sed -i -e 's/-Werror//' Make.rules
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -Dm755 "$srcdir"/opennhrp.initd "$pkgdir"/etc/init.d/opennhrp
+ install -Dm644 "$srcdir"/opennhrp.confd "$pkgdir"/etc/cond.d/opennhrp
+}
+md5sums="473dace79e7eefe0a0b79159a2c61cb5 opennhrp-0.11.tar.bz2
+f81539fc92800bb79668dda119a97d1d opennhrp-0.9.3-peer-up-bgp.patch
+85821b61c02427146b866b7582157cfd opennhrp.initd
+8eee86233728dc0d156bbfee6d98f338 opennhrp.confd"
diff --git a/main/opennhrp/opennhrp-0.9.2-fix-false-assert.patch b/main/opennhrp/opennhrp-0.9.2-fix-false-assert.patch
new file mode 100644
index 00000000000..67b44ab5d21
--- /dev/null
+++ b/main/opennhrp/opennhrp-0.9.2-fix-false-assert.patch
@@ -0,0 +1,13 @@
+diff -ru opennhrp-0.9.2.orig/nhrp/nhrp_peer.c opennhrp-0.9.2/nhrp/nhrp_peer.c
+--- opennhrp-0.9.2.orig/nhrp/nhrp_peer.c 2009-02-02 13:12:46 +0000
++++ opennhrp-0.9.2/nhrp/nhrp_peer.c 2009-02-02 13:36:51 +0000
+@@ -1260,7 +1260,8 @@
+ {
+ char tmp[NHRP_PEER_FORMAT_LEN];
+
+- NHRP_BUG_ON(peer->flags & NHRP_PEER_FLAG_REMOVED);
++ if (peer->flags & NHRP_PEER_FLAG_REMOVED)
++ return;
+
+ nhrp_debug("Removing %s %s",
+ nhrp_peer_type[peer->type],
diff --git a/main/opennhrp/opennhrp-0.9.3-peer-up-bgp.patch b/main/opennhrp/opennhrp-0.9.3-peer-up-bgp.patch
new file mode 100644
index 00000000000..60e4827d6fe
--- /dev/null
+++ b/main/opennhrp/opennhrp-0.9.3-peer-up-bgp.patch
@@ -0,0 +1,11 @@
+diff -ru opennhrp-0.9.3.orig/etc/opennhrp-script opennhrp-0.9.3/etc/opennhrp-script
+--- opennhrp-0.9.3.orig/etc/opennhrp-script 2009-02-26 10:35:38 +0000
++++ opennhrp-0.9.3/etc/opennhrp-script 2009-02-26 10:52:26 +0000
+@@ -15,6 +15,7 @@
+ echo "Create link from $NHRP_SRCADDR ($NHRP_SRCNBMA) to $NHRP_DESTADDR ($NHRP_DESTNBMA)"
+ racoonctl establish-sa -w isakmp inet $NHRP_SRCNBMA $NHRP_DESTNBMA || exit 1
+ racoonctl establish-sa -w esp inet $NHRP_SRCNBMA $NHRP_DESTNBMA gre || exit 1
++ vtysh -d bgpd -c "clear bgp $NHRP_DESTADDR" 2>/dev/null || true
+ ;;
+ peer-down)
+ echo "Delete link from $NHRP_SRCADDR ($NHRP_SRCNBMA) to $NHRP_DESTADDR ($NHRP_DESTNBMA)"
diff --git a/main/opennhrp/opennhrp.confd b/main/opennhrp/opennhrp.confd
new file mode 100644
index 00000000000..c3bece169e6
--- /dev/null
+++ b/main/opennhrp/opennhrp.confd
@@ -0,0 +1,2 @@
+# Uncomment the row below to enable verbose logging.
+#OPENNHRP_OPTS=-v
diff --git a/main/opennhrp/opennhrp.initd b/main/opennhrp/opennhrp.initd
new file mode 100755
index 00000000000..ac7ea6a572e
--- /dev/null
+++ b/main/opennhrp/opennhrp.initd
@@ -0,0 +1,32 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmpd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $
+
+PIDFILE=/var/run/opennhrp.pid
+
+depend() {
+ use logger
+ need net
+}
+
+checkconfig() {
+ if [ ! -e /etc/opennhrp/opennhrp.conf ] ; then
+ eerror "You need an /etc/opennhrp/opennhrp.conf config file to run opennhrp"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting opennhrp"
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --exec /usr/sbin/opennhrp -- -d -p $PIDFILE 2> /dev/null
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping opennhrp"
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE
+ eend $?
+}
diff --git a/main/openvpn/APKBUILD b/main/openvpn/APKBUILD
new file mode 100644
index 00000000000..3b927139d10
--- /dev/null
+++ b/main/openvpn/APKBUILD
@@ -0,0 +1,54 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=openvpn
+pkgver=2.0.9
+pkgrel=0
+pkgdesc="A robust, and highly configurable VPN (Virtual Private Network)"
+url="http://openvpn.sourceforge.net/"
+license="custom"
+subpackages="$pkgname-doc"
+depends="openssl iproute2 lzo"
+makedepends="openssl-dev lzo-dev"
+install=
+source="http://$pkgname.net/release/$pkgname-$pkgver.tar.gz
+ openvpn-2.0.9-persistent.patch
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --enable-ssl \
+ --enable-crypto \
+ --disable-threads
+
+ make || return 1
+
+ cd plugin/down-root
+ make || return 1
+ cd ../..
+
+ make DESTDIR="$pkgdir" install || return 1
+
+ # install plugins
+ install -d "$pkgdir"/usr/lib/$pkgname
+ cp plugin/*/*.so "$pkgdir"/usr/lib/$pkgname
+
+ # install easy-rsa
+ sed -i -e 's/--directory/-d/g; s/--mode/-m/g' easy-rsa/2.0/Makefile
+ make -C easy-rsa/2.0 DESTDIR="$pkgdir" \
+ PREFIX=usr/share/openvpn/easy-rsa \
+ install
+
+ # install examples
+ mkdir -p "$pkgdir"/usr/share/doc/$pkgname/examples
+ cp -a sample-config-files "$pkgdir"/usr/share/doc/$pkgname/examples
+ install -D -m644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+
+}
+md5sums="60745008b90b7dbe25fe8337c550fec6 openvpn-2.0.9.tar.gz
+a9075ceb8552980519132cc27fda85ac openvpn-2.0.9-persistent.patch"
diff --git a/main/openvpn/openvpn-2.0.9-persistent.patch b/main/openvpn/openvpn-2.0.9-persistent.patch
new file mode 100644
index 00000000000..e042124ea49
--- /dev/null
+++ b/main/openvpn/openvpn-2.0.9-persistent.patch
@@ -0,0 +1,44 @@
+diff -ru openvpn-2.0.9~/init.c openvpn-2.0.9/init.c
+--- openvpn-2.0.9~/init.c 2008-05-13 23:21:30.000000000 +0200
++++ openvpn-2.0.9/init.c 2008-05-13 23:22:51.000000000 +0200
+@@ -347,7 +347,8 @@
+ msg (M_FATAL|M_OPTERR,
+ "options --mktun or --rmtun should only be used together with --dev");
+ tuncfg (options->dev, options->dev_type, options->dev_node,
+- options->tun_ipv6, options->persist_mode);
++ options->tun_ipv6, options->persist_mode,
++ &options->tuntap_options);
+ return true;
+ }
+ #endif
+diff -ru openvpn-2.0.9~/tun.c openvpn-2.0.9/tun.c
+--- openvpn-2.0.9~/tun.c 2008-05-13 23:21:30.000000000 +0200
++++ openvpn-2.0.9/tun.c 2008-05-13 23:22:51.000000000 +0200
+@@ -1095,13 +1095,14 @@
+ #ifdef TUNSETPERSIST
+
+ void
+-tuncfg (const char *dev, const char *dev_type, const char *dev_node, bool ipv6, int persist_mode)
++tuncfg (const char *dev, const char *dev_type, const char *dev_node, bool ipv6, int persist_mode, const struct tuntap_options *options)
+ {
+ struct tuntap *tt;
+
+ ALLOC_OBJ (tt, struct tuntap);
+ clear_tuntap (tt);
+ tt->type = dev_type_enum (dev, dev_type);
++ tt->options = *options;
+ open_tun (dev, dev_type, dev_node, ipv6, tt);
+ if (ioctl (tt->fd, TUNSETPERSIST, persist_mode) < 0)
+ msg (M_ERR, "Cannot ioctl TUNSETPERSIST(%d) %s", persist_mode, dev);
+diff -ru openvpn-2.0.9~/tun.h openvpn-2.0.9/tun.h
+--- openvpn-2.0.9~/tun.h 2008-05-13 23:21:30.000000000 +0200
++++ openvpn-2.0.9/tun.h 2008-05-13 23:22:51.000000000 +0200
+@@ -194,7 +194,7 @@
+ int read_tun (struct tuntap* tt, uint8_t *buf, int len);
+
+ void tuncfg (const char *dev, const char *dev_type, const char *dev_node,
+- bool ipv6, int persist_mode);
++ bool ipv6, int persist_mode, const struct tuntap_options *options);
+
+ const char *guess_tuntap_dev (const char *dev,
+ const char *dev_type,
diff --git a/main/openvpn/openvpn.initd b/main/openvpn/openvpn.initd
new file mode 100644
index 00000000000..a6e4529e1c8
--- /dev/null
+++ b/main/openvpn/openvpn.initd
@@ -0,0 +1,63 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+VPNDIR="/etc/openvpn"
+VPN="${SVCNAME#*.}"
+if [ -n "${VPN}" ] && [ "${SVCNAME}" != "openvpn" ]; then
+ VPNPID="/var/run/openvpn.${VPN}.pid"
+else
+ VPNPID="/var/run/openvpn.pid"
+fi
+VPNCONF="${VPNDIR}/${VPN}.conf"
+
+depend() {
+ need localmount net
+ before netmount
+ after bootmisc
+}
+
+checktundevice() {
+ if [ ! -e /dev/net/tun ]; then
+ if ! modprobe tun ; then
+ eerror "TUN/TAP support is not available in this kernel"
+ return 1
+ fi
+ fi
+ if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then
+ ebegin "Detected broken /dev/net/tun symlink, fixing..."
+ rm -f /dev/net/tun
+ ln -s /dev/misc/net/tun /dev/net/tun
+ eend $?
+ fi
+}
+
+start() {
+ ebegin "Starting ${SVCNAME}"
+
+ checktundevice || return 1
+
+ if [ ! -e "${VPNCONF}" ]; then
+ eend 1 "${VPNCONF} does not exist"
+ return 1
+ fi
+
+ local args=""
+ # If the config file does not specify the cd option, we do
+ # But if we specify it, we override the config option which we do not want
+ if ! grep -q "^[ \t]*cd[ \t].*" "${VPNCONF}" ; then
+ args="${args} --cd ${VPNDIR}"
+ fi
+
+ start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \
+ -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon ${args}
+ eend $? "Check your logs to see why startup failed"
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${VPNPID}"
+ eend $?
+}
+
+# vim: ts=4
diff --git a/main/p7zip/APKBUILD b/main/p7zip/APKBUILD
new file mode 100644
index 00000000000..38d6760282b
--- /dev/null
+++ b/main/p7zip/APKBUILD
@@ -0,0 +1,36 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=p7zip
+pkgver=4.65
+pkgrel=0
+pkgdesc="A command-line port of the 7zip compression utility"
+url="http://p7zip.sourceforge.net"
+license="GPL"
+subpackages="$pkgname-doc"
+depends="uclibc uclibc++ libgcc"
+makedepends="bash uclibc++-dev"
+#install=p7zip.install
+source="http://downloads.sourceforge.net/sourceforge/$pkgname/${pkgname}_${pkgver}_src_all.tar.bz2
+ p7zip-cc-cxx.patch"
+
+build ()
+{
+ cd "$srcdir"/${pkgname}_${pkgver}
+ patch -p1 -i ../p7zip-cc-cxx.patch || return 1
+ sed -i "s|usr/local|usr|g" makefile
+ export CXX=${UC_CXX:-g++-uc}
+
+ make all3 OPTFLAGS="${CXXFLAGS}" || return 1
+ make install DEST_HOME="$pkgdir"/usr DEST_MAN="$pkgdir"/usr/share/man \
+ DEST_SHARE_DOC="http://www.bugaco.com/7zip"
+
+# echo "creating dir"
+# mkdir -p "$pkgdir"/usr/share/doc/p7zip/DOCS
+# install -m555 bin/7z.so "$pkgdir"/usr/lib/p7zip/
+ sed -i "s|"$pkgdir"/usr|/usr|g" "$pkgdir"/usr/bin/7z
+ sed -i "s|"$pkgdir"/usr|/usr|g" "$pkgdir"/usr/bin/7za
+ sed -i "s|"$pkgdir"/usr|/usr|g" "$pkgdir"/usr/bin/7zr
+# install -m755 -D contrib/VirtualFileSystemForMidnightCommander/u7z "$pkgdir"/usr/share/mc/extfs/u7z
+}
+
+md5sums="f78ed232436dc8f8be25a2f95d4e5f9a p7zip_4.65_src_all.tar.bz2
+8e8f415267bb5db179e4a8ed75985244 p7zip-cc-cxx.patch"
diff --git a/main/p7zip/p7zip-cc-cxx.patch b/main/p7zip/p7zip-cc-cxx.patch
new file mode 100644
index 00000000000..d06708b4bbe
--- /dev/null
+++ b/main/p7zip/p7zip-cc-cxx.patch
@@ -0,0 +1,22 @@
+--- a/makefile.machine 2009-05-29 07:24:22.000000000 +0000
++++ b/makefile.machine 2009-05-29 07:25:22.000000000 +0000
+@@ -2,6 +2,8 @@
+ # makefile for Linux (x86, PPC, alpha ...)
+ #
+
++CXX ?= g++
++CC ?= gcc
+ OPTFLAGS=-O
+
+ ALLFLAGS=${OPTFLAGS} -s \
+@@ -9,8 +11,8 @@
+ -DNDEBUG -D_REENTRANT -DENV_UNIX \
+ $(LOCAL_FLAGS)
+
+-CXX=g++ $(ALLFLAGS)
+-CC=gcc $(ALLFLAGS)
++CXX += $(ALLFLAGS)
++CC += $(ALLFLAGS)
+ CC_SHARED=-fPIC
+ LINK_SHARED=-fPIC -shared
+
diff --git a/main/pciutils/APKBUILD b/main/pciutils/APKBUILD
new file mode 100644
index 00000000000..1c41b6d07b4
--- /dev/null
+++ b/main/pciutils/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=pciutils
+pkgver=3.1.2
+pkgrel=0
+pkgdesc="PCI bus configuration space access library and tools"
+url="http://mj.ucw.cz/pciutils.html"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install=
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://www.kernel.org/pub/software/utils/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make ZLIB=no PREFIX=/usr SHAREDIR=/usr/share/hwdata MANDIR=/usr/share/man all || return 1
+ make PREFIX=${pkgdir}/usr SHAREDIR=${pkgdir}/usr/share/hwdata MANDIR=${pkgdir}/usr/share/man install
+
+ install -d ${pkgdir}/usr/lib
+ install -m644 lib/libpci.a ${pkgdir}/usr/lib
+ for i in config.h header.h pci.h types.h; do
+ install -D -m 644 lib/${i} ${pkgdir}/usr/include/pci/${i}
+ done
+
+}
+
+md5sums="b6cc13955ad769a25c475a87d2ef5596 pciutils-3.1.2.tar.gz"
diff --git a/main/pcmciautils/APKBUILD b/main/pcmciautils/APKBUILD
new file mode 100644
index 00000000000..f11f6e06bfa
--- /dev/null
+++ b/main/pcmciautils/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=pcmciautils
+pkgver=015
+pkgrel=0
+pkgdesc="Utilities for inserting and removing PCMCIA cards"
+url="http://kernel.org/pub/linux/utils/kernel/pcmcia/pcmcia.html"
+license="GPL"
+subpackages="$pkgname-doc"
+depends="uclibc sysfsutils"
+makedepends="sysfsutils-dev bison flex"
+source="http://kernel.org/pub/linux/utils/kernel/pcmcia/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+# sed -i -e 's,/usr/bin/install,/bin/install,g' Makefile
+ make build/ccdv || return 1
+ make LEX=flex || return 1
+ make DESTDIR="$pkgdir"/ install
+ ln -sf pccardctl "$pkgdir"/sbin/lspcmcia
+}
+md5sums="9e12435c8b6cf7bf59894e90e480b4aa pcmciautils-015.tar.bz2"
diff --git a/main/pcre/APKBUILD b/main/pcre/APKBUILD
new file mode 100644
index 00000000000..f2749d6a3ea
--- /dev/null
+++ b/main/pcre/APKBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=pcre
+pkgver=7.9
+pkgrel=0
+pkgdesc="Perl-compatible regular expression library"
+url="http://pcre.sourceforge.net"
+license="BSD"
+depends="uclibc"
+makedepends=""
+source="ftp://ftp.csx.cam.ac.uk/pub/software/programming/$pkgname/$pkgname-$pkgver.tar.bz2"
+subpackages="$pkgname-dev $pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --disable-cpp \
+ --enable-utf8 \
+ --with-match-limit-recursion=8192 \
+ --htmldir=/usr/share/doc/$pkgname-$pkgver/html \
+ --docdir=/usr/share/doc/$pkgname-$pkgver
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+
+md5sums="b6a9669d1863423f01ea46cdf00f93dc pcre-7.9.tar.bz2"
diff --git a/main/perl-archive-zip/APKBUILD b/main/perl-archive-zip/APKBUILD
new file mode 100644
index 00000000000..2f78683eeca
--- /dev/null
+++ b/main/perl-archive-zip/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-archive-zip
+_realname=Archive-Zip
+pkgver=1.26
+pkgrel=0
+pkgdesc="Provide a perl interface to ZIP archive files."
+url="http://search.cpan.org/dist/Archive-Zip/"
+license="GPL PerlArtistic"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="a2e1cc1d99dbaebc41421295c93f61b5 Archive-Zip-1.26.tar.gz"
diff --git a/main/perl-convert-binhex/APKBUILD b/main/perl-convert-binhex/APKBUILD
new file mode 100644
index 00000000000..e0cc0b30d14
--- /dev/null
+++ b/main/perl-convert-binhex/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-convert-binhex
+_realname=Convert-BinHex
+pkgver=1.119
+pkgrel=0
+pkgdesc="Extract data from Macintosh BinHex files"
+url="http://search.cpan.org/~eryq/Convert-BinHex-1.119/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/E/ER/ERYQ/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="ba70ad1772abac6270078f28197a7961 Convert-BinHex-1.119.tar.gz"
diff --git a/main/perl-convert-tnef/APKBUILD b/main/perl-convert-tnef/APKBUILD
new file mode 100644
index 00000000000..352e26e7283
--- /dev/null
+++ b/main/perl-convert-tnef/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-convert-tnef
+_realname=Convert-TNEF
+pkgver=0.17
+pkgrel=0
+pkgdesc="Perl module to read TNEF files"
+url="http://search.cpan.org/~dougw/Convert-TNEF-0.17/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/D/DO/DOUGW/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="31cddf42fae9495b4a686b17ec68d7e0 Convert-TNEF-0.17.tar.gz"
diff --git a/main/perl-convert-uulib/APKBUILD b/main/perl-convert-uulib/APKBUILD
new file mode 100644
index 00000000000..b35d517dea0
--- /dev/null
+++ b/main/perl-convert-uulib/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-convert-uulib
+_realname=Convert-UUlib
+pkgver=1.12
+pkgrel=0
+pkgdesc="Perl interface to the uulib library"
+url="http://search.cpan.org/~mlehmann/Convert-UUlib-1.12/UUlib.pm"
+license="Artistic GPL2"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/M/ML/MLEHMANN/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="360d29db09aa7692d8873b336b7ec9d7 Convert-UUlib-1.12.tar.gz"
diff --git a/main/perl-crypt-openssl-random/APKBUILD b/main/perl-crypt-openssl-random/APKBUILD
new file mode 100644
index 00000000000..0b1e8ea995a
--- /dev/null
+++ b/main/perl-crypt-openssl-random/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-crypt-openssl-random
+_realname=Crypt-OpenSSL-Random
+pkgver=0.04
+pkgrel=0
+pkgdesc="RSA encoding and decoding, using the openSSL libraries"
+url="http://search.cpan.org/~iroberts/Crypt-OpenSSL-Random-0.04/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev openssl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/I/IR/IROBERTS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="c56ac5dbdd46122eb9b8da59613b7b0a Crypt-OpenSSL-Random-0.04.tar.gz"
diff --git a/main/perl-crypt-openssl-rsa/APKBUILD b/main/perl-crypt-openssl-rsa/APKBUILD
new file mode 100644
index 00000000000..4acae984809
--- /dev/null
+++ b/main/perl-crypt-openssl-rsa/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-crypt-openssl-rsa
+_realname=Crypt-OpenSSL-RSA
+pkgver=0.25
+pkgrel=0
+pkgdesc="RSA encoding and decoding, using the openSSL libraries"
+url="http://search.cpan.org/~iroberts/Crypt-OpenSSL-RSA-0.25/"
+license="Unknown"
+depends="perl perl-crypt-openssl-random"
+makedepends="perl-dev openssl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/I/IR/IROBERTS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="fdf19c9093f47cffb851ae937d053c14 Crypt-OpenSSL-RSA-0.25.tar.gz"
diff --git a/main/perl-db/APKBUILD b/main/perl-db/APKBUILD
new file mode 100644
index 00000000000..929d5872275
--- /dev/null
+++ b/main/perl-db/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-db
+_realname=BerkeleyDB
+pkgver=0.38
+pkgrel=0
+pkgdesc="Perl extension for Berkeley DB version 2, 3 or 4"
+url="http://search.cpan.org/~pmqs/BerkeleyDB-0.38/"
+license="GPL PerlArtistic"
+depends="perl db"
+makedepends="perl-dev db-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/P/PM/PMQS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="33a0c1a9d566a3f5fc71601a165d8335 BerkeleyDB-0.38.tar.gz"
diff --git a/main/perl-db_file/APKBUILD b/main/perl-db_file/APKBUILD
new file mode 100644
index 00000000000..7d3edc3ab1b
--- /dev/null
+++ b/main/perl-db_file/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-db_file
+_realname=DB_File
+pkgver=1.820
+pkgrel=0
+pkgdesc="Perl5 access to Berkeley DB"
+url="http://search.cpan.org/~pmqs/DB_File-1.820/"
+license="GPL PerlArtistic"
+depends="perl db"
+makedepends="perl-dev db-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/P/PM/PMQS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="28979bee29d8075b0dffab02fe29df6e DB_File-1.820.tar.gz"
diff --git a/main/perl-digest-sha1/APKBUILD b/main/perl-digest-sha1/APKBUILD
new file mode 100644
index 00000000000..0b0909c5dc6
--- /dev/null
+++ b/main/perl-digest-sha1/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-digest-sha1
+_realname=Digest-SHA1
+pkgver=2.12
+pkgrel=0
+pkgdesc="Perl interface to the SHA-1 algorithm"
+url="http://search.cpan.org/~gaas/Digest-SHA1-2.12/"
+license="GPL PerlArtistic"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="eeb0292868801a202bd7ead87b291374 Digest-SHA1-2.12.tar.gz"
diff --git a/main/perl-getopt-long/APKBUILD b/main/perl-getopt-long/APKBUILD
new file mode 100644
index 00000000000..431f52a9899
--- /dev/null
+++ b/main/perl-getopt-long/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-getopt-long
+_realname=Getopt-Long
+pkgver=2.38
+pkgrel=0
+pkgdesc="Extended processing of command line options"
+url="http://search.cpan.org/~jv/Getopt-Long-2.38/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/J/JV/JV/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="4d38c78300e79a7fde4700e88759c2b3 Getopt-Long-2.38.tar.gz"
diff --git a/main/perl-html-parser/APKBUILD b/main/perl-html-parser/APKBUILD
new file mode 100644
index 00000000000..fb7ea012555
--- /dev/null
+++ b/main/perl-html-parser/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-html-parser
+_realname=HTML-Parser
+pkgver=3.60
+pkgrel=0
+pkgdesc="Parse section of HTML documents"
+url="http://search.cpan.org/~gaas/HTML-Parser-3.60/"
+license="GPL PerlArtistic"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="fb97ea7e5bd832b079d8660732f9d8d9 HTML-Parser-3.60.tar.gz"
diff --git a/main/perl-inline/APKBUILD b/main/perl-inline/APKBUILD
new file mode 100644
index 00000000000..f8e350c1da0
--- /dev/null
+++ b/main/perl-inline/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-inline
+_realname=Inline
+pkgver=0.45
+pkgrel=0
+pkgdesc="Write Perl subroutines in other programming languages"
+url="http://search.cpan.org/~sisyphus/Inline-0.45/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/S/SI/SISYPHUS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="63140a6c911f1576fdee71ba4457610f Inline-0.45.tar.gz"
diff --git a/main/perl-io-stringy/APKBUILD b/main/perl-io-stringy/APKBUILD
new file mode 100644
index 00000000000..f25ce2164c4
--- /dev/null
+++ b/main/perl-io-stringy/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-io-stringy
+_realname=IO-stringy
+pkgver=2.110
+pkgrel=0
+pkgdesc="A Perl module for I/O on in-core objects like strings and arrays"
+url="http://search.cpan.org/~dskoll/IO-stringy-2.110/"
+license="unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/D/DS/DSKOLL/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="2e6a976cfa5521e815c1fdf4006982de IO-stringy-2.110.tar.gz"
diff --git a/main/perl-mail-clamav/APKBUILD b/main/perl-mail-clamav/APKBUILD
new file mode 100644
index 00000000000..c8ef7ea723f
--- /dev/null
+++ b/main/perl-mail-clamav/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mail-clamav
+_realname=Mail-ClamAV
+pkgver=0.29
+pkgrel=0
+pkgdesc="Perl extension for the clamav virus scanner"
+url="http://search.cpan.org/~converter/Mail-ClamAV-0.29/"
+license="Unknown"
+depends="perl clamav"
+makedepends="perl-dev perl-inline perl-parse-recdescent clamav-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/C/CO/CONVERTER/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ sed -i -e 's%\(clamav-config --version\)%sh /usr/bin/\1%' Makefile.PL
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make -j1 || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="737ea1c041d9312cdcfe5b85eb45428e Mail-ClamAV-0.29.tar.gz"
diff --git a/main/perl-mail-dkim/APKBUILD b/main/perl-mail-dkim/APKBUILD
new file mode 100644
index 00000000000..7fc9d69ed3d
--- /dev/null
+++ b/main/perl-mail-dkim/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mail-dkim
+_realname=Mail-DKIM
+pkgver=0.36
+pkgrel=0
+pkgdesc="Signs/verifies Internet mail with DKIM/DomainKey signatures"
+url="http://search.cpan.org/~jaslong/Mail-DKIM-0.36/"
+license="unknown"
+depends="perl perl-net-dns perl-net-ip perl-mail-tools perl-crypt-openssl-rsa"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/J/JA/JASLONG/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="b6681a7b3cc21c0976205d4ad616455d Mail-DKIM-0.36.tar.gz"
diff --git a/main/perl-mail-domainkeys/APKBUILD b/main/perl-mail-domainkeys/APKBUILD
new file mode 100644
index 00000000000..be3f83df067
--- /dev/null
+++ b/main/perl-mail-domainkeys/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mail-domainkeys
+_realname=Mail-DomainKeys
+pkgver=1.0
+pkgrel=0
+pkgdesc="A perl implementation of DomainKeys"
+url="http://search.cpan.org/~anthonyu/Mail-DomainKeys-1.0/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/A/AN/ANTHONYU/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="a4565f21ada263cf34c55f50d7eb9944 Mail-DomainKeys-1.0.tar.gz"
diff --git a/main/perl-mail-spamassassin/APKBUILD b/main/perl-mail-spamassassin/APKBUILD
new file mode 100644
index 00000000000..6a3c884616d
--- /dev/null
+++ b/main/perl-mail-spamassassin/APKBUILD
@@ -0,0 +1,25 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mail-spamassassin
+_realname=Mail-SpamAssassin
+pkgver=3.2.5
+pkgrel=0
+pkgdesc="Spam detector and markup engine"
+url="http://search.cpan.org/~jmason/Mail-SpamAssassin-3.2.5/"
+license="unknown"
+depends="perl perl-digest-sha1 perl-html-parser perl-net-dns perl-db_file
+perl-mail-spf razor"
+makedepends="perl-dev zlib-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/J/JM/JMASON/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="7fdc1651d0371c4a7f95ac9ae6f828a6 Mail-SpamAssassin-3.2.5.tar.gz"
diff --git a/main/perl-mail-spf/APKBUILD b/main/perl-mail-spf/APKBUILD
new file mode 100644
index 00000000000..372398d65fb
--- /dev/null
+++ b/main/perl-mail-spf/APKBUILD
@@ -0,0 +1,24 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mail-spf
+_realname=Mail-SPF
+pkgver=2.006
+pkgrel=0
+pkgdesc="An object-oriented implementation of Sender Policy Framework"
+url="http://search.cpan.org/~jmehnle/Mail-SPF-v2.006/"
+license="GPL PerlArtistic"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/J/JM/JMEHNLE/mail-spf/$_realname-v$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-v$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="4da41591b612560627ddbc6026b047a3 Mail-SPF-v2.006.tar.gz"
diff --git a/main/perl-mail-tools/APKBUILD b/main/perl-mail-tools/APKBUILD
new file mode 100644
index 00000000000..0e133c30e74
--- /dev/null
+++ b/main/perl-mail-tools/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mail-tools
+_realname=MailTools
+pkgver=2.04
+pkgrel=0
+pkgdesc="Manipulation of electronic mail addresses"
+url="http://search.cpan.org/~markov/MailTools-2.04/"
+license="GPL PerlArtistic"
+depends="perl perl-time-date perl-test-pod"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/M/MA/MARKOV/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="d21ea4f375d1e5f3da6b0a4e8ba1e2c6 MailTools-2.04.tar.gz"
diff --git a/main/perl-mime-tools/APKBUILD b/main/perl-mime-tools/APKBUILD
new file mode 100644
index 00000000000..1bbfe33fec6
--- /dev/null
+++ b/main/perl-mime-tools/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-mime-tools
+_realname=MIME-tools
+pkgver=5.427
+pkgrel=0
+pkgdesc="Perl modules for parsing (and creating!) MIME entities"
+url="http://search.cpan.org/~doneill/MIME-tools-5.427/"
+license="PerlArtistic GPL"
+depends="perl perl-io-stringy perl-mail-tools perl-convert-binhex"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/D/DO/DONEILL/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="4333caa7238cb9eafb5f7fb39fcbd8e7 MIME-tools-5.427.tar.gz"
diff --git a/main/perl-net-dns/APKBUILD b/main/perl-net-dns/APKBUILD
new file mode 100644
index 00000000000..2ce850ee4db
--- /dev/null
+++ b/main/perl-net-dns/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-net-dns
+_realname=Net-DNS
+pkgver=0.65
+pkgrel=0
+pkgdesc="Perl interface to the DNS resolver"
+url="http://search.cpan.org/dist/Archive-Zip/"
+license="unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/O/OL/OLAF/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="54e5a12a20de39b954a93723927ac789 Net-DNS-0.65.tar.gz"
diff --git a/main/perl-net-ip/APKBUILD b/main/perl-net-ip/APKBUILD
new file mode 100644
index 00000000000..d959c43d0a6
--- /dev/null
+++ b/main/perl-net-ip/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-net-ip
+_realname=Net-IP
+pkgver=1.25
+pkgrel=0
+pkgdesc="Perl extension for manipulating IPv4/IPv6 addresses"
+url="http://search.cpan.org/~manu/Net-IP-1.25/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/M/MA/MANU/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="a49c0b02a9b793ff60191cdafc0c202e Net-IP-1.25.tar.gz"
diff --git a/main/perl-net-server/APKBUILD b/main/perl-net-server/APKBUILD
new file mode 100644
index 00000000000..9e0bc32ca49
--- /dev/null
+++ b/main/perl-net-server/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-net-server
+_realname=Net-Server
+pkgver=0.97
+pkgrel=0
+pkgdesc="Extensible, general Perl server engine"
+url="http://search.cpan.org/~rhandom/Net-Server-0.97/"
+license="unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/R/RH/RHANDOM/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="f884b6c5b1d2698a82bbc7ba659690a1 Net-Server-0.97.tar.gz"
diff --git a/main/perl-parse-recdescent/APKBUILD b/main/perl-parse-recdescent/APKBUILD
new file mode 100644
index 00000000000..8ee87e58b7d
--- /dev/null
+++ b/main/perl-parse-recdescent/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-parse-recdescent
+_realname=Parse-RecDescent
+pkgver=1.96.0
+pkgrel=0
+pkgdesc="Generate Recursive-Descent Parsers"
+url="http://search.cpan.org/~dconway/Parse-RecDescent-1.96.0/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/D/DC/DCONWAY/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="373dc01e102d81d01a4fb1431c5ff3fb Parse-RecDescent-1.96.0.tar.gz"
diff --git a/main/perl-test-pod/APKBUILD b/main/perl-test-pod/APKBUILD
new file mode 100644
index 00000000000..df47aee249f
--- /dev/null
+++ b/main/perl-test-pod/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-test-pod
+_realname=Test-Pod
+pkgver=1.26
+pkgrel=0
+pkgdesc="Check for POD errors in files"
+url="http://search.cpan.org/~petdance/Test-Pod-1.26/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/P/PE/PETDANCE/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="2f259135656ac4549b65a4f14f07b7c6 Test-Pod-1.26.tar.gz"
diff --git a/main/perl-time-date/APKBUILD b/main/perl-time-date/APKBUILD
new file mode 100644
index 00000000000..1c02dfe1648
--- /dev/null
+++ b/main/perl-time-date/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-time-date
+_realname=TimeDate
+pkgver=1.16
+pkgrel=0
+pkgdesc="Date formating subroutines"
+url="http://search.cpan.org/~gbarr/TimeDate-1.16/"
+license="Unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="b3cc35a7cabd106ac8829d2f2ff4bd9d TimeDate-1.16.tar.gz"
diff --git a/main/perl-unix-syslog/APKBUILD b/main/perl-unix-syslog/APKBUILD
new file mode 100644
index 00000000000..59ece194b0c
--- /dev/null
+++ b/main/perl-unix-syslog/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-unix-syslog
+_realname=Unix-Syslog
+pkgver=1.1
+pkgrel=0
+pkgdesc="Perl interface to the UNIX syslog(3) calls"
+url="http://search.cpan.org/~mharnisch/Unix-Syslog-1.1/"
+license="unknown"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/M/MH/MHARNISCH/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor \
+ PERL_ARCHLIB=/usr/lib/perl5/5.10.0/i686-linux || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="73d78e309fe9508ffc9a54d84d79aac9 Unix-Syslog-1.1.tar.gz"
diff --git a/main/perl-uri-escape/APKBUILD b/main/perl-uri-escape/APKBUILD
new file mode 100644
index 00000000000..4cd3b727e7f
--- /dev/null
+++ b/main/perl-uri-escape/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=perl-uri-escape
+_realname=URI
+pkgver=1.38
+pkgrel=0
+pkgdesc="Uniform Resource Identifiers (absolute and relative)"
+url="http://search.cpan.org/~gaas/URI-1.38/"
+license="GPL PerlArtistic"
+depends="perl"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/$_realname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="35fba2715eb8ac56e8e30244ae69ff65 URI-1.38.tar.gz"
diff --git a/main/perl-uri/APKBUILD b/main/perl-uri/APKBUILD
new file mode 100644
index 00000000000..e95b8411c93
--- /dev/null
+++ b/main/perl-uri/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=perl-uri
+pkgver=1.37
+pkgrel=0
+pkgdesc="Perl Module: form Resource Identifiers (absolute and relative)"
+url="http://search.cpan.org/dist/URI/"
+license="PerlArtistic"
+subpackages="$pkgname-doc"
+depends="perl"
+makedepends=""
+source="http://www.cpan.org/authors/id/G/GA/GAAS/URI-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/URI-$pkgver
+ perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make install DESTDIR="$pkgdir" || return 1
+ find "$pkgdir" -name perllocal.pod -delete
+ find "$pkgdir" -name .packlist -delete
+}
+md5sums="b81b3610b78654e11c099f74a5247860 URI-1.37.tar.gz"
diff --git a/main/perl-xml-parser/APKBUILD b/main/perl-xml-parser/APKBUILD
new file mode 100644
index 00000000000..7dc23116cea
--- /dev/null
+++ b/main/perl-xml-parser/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=perl-xml-parser
+_name=XML-Parser
+pkgver=2.36
+pkgrel=0
+pkgdesc="XML::Parser - an XML parser module for perl"
+url="http://search.cpan.org/dist/XML-Parser/"
+license="GPL PerlArtistic"
+depends="perl expat uclibc"
+makedepends="expat-dev"
+source="http://search.cpan.org/CPAN/authors/id/M/MS/MSERGEANT/XML-Parser-$pkgver.tar.gz"
+
+build () {
+ cd "$srcdir"/$_name-$pkgver
+ perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make MAN1EXT=1p MAN3EXT=3pm || return 1
+ make install MAN1EXT=1p MAN3EXT=3pm DESTDIR="$pkgdir" || return 1
+ find "$pkgdir" -name perllocal.pod -delete
+ find "$pkgdir" -name .packlist -delete
+}
+md5sums="1b868962b658bd87e1563ecd56498ded XML-Parser-2.36.tar.gz"
diff --git a/main/perl-xml-simple/APKBUILD b/main/perl-xml-simple/APKBUILD
new file mode 100644
index 00000000000..74d2ecbe199
--- /dev/null
+++ b/main/perl-xml-simple/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=perl-xml-simple
+pkgver=2.18
+pkgrel=0
+pkgdesc="Simple XML parser for perl"
+url="http://search.cpan.org/dist/XML-Simple/"
+license="PerlArtistic"
+subpackages="$pkgname-doc"
+depends="perl-xml-parser perl"
+makedepends="perl-dev"
+source="ftp://ftp.cpan.org/pub/CPAN/authors/id/G/GR/GRANTM/XML-Simple-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/XML-Simple-$pkgver
+ perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ find "$pkgdir" -name '.packlist' -delete
+ find "$pkgdir" -name 'perllocal.pod' -delete
+}
+md5sums="593aa8001e5c301cdcdb4bb3b63abc33 XML-Simple-2.18.tar.gz"
diff --git a/main/pgcluster/APKBUILD b/main/pgcluster/APKBUILD
new file mode 100644
index 00000000000..9d92b9b65b3
--- /dev/null
+++ b/main/pgcluster/APKBUILD
@@ -0,0 +1,51 @@
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=pgcluster
+pkgver=1.9.0_rc5
+_myver=1.9.0rc5
+pkgrel=1
+pkgdesc="PostgreSQL with multi-master cluster/replication patch"
+url="http://pgfoundry.org/projects/pgcluster/"
+license="BSD"
+depends=
+makedepends="readline-dev openssl-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-libpq $pkgname-client"
+source="http://pgfoundry.org/frs/download.php/1705/$pkgname-$_myver.tar.gz
+ $pkgname.initd
+ $pkgname.confd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$_myver || return 1
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --with-docdir=/usr/share/doc \
+ --with-openssl \
+ || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ install -D -m755 "$srcdir"/$pkgname.initd \
+ "$pkgdir"/etc/init.d/$pkgname
+ install -D -m644 "$srcdir"/$pkgname.confd \
+ "$pkgdir"/etc/conf.d/$pkgname || return 1
+}
+
+libpq() {
+ depends=
+ pkgdesc="PGCluster libraries"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpq.so* "$subpkgdir"/usr/lib/
+}
+
+client() {
+ depends=
+ pkgdesc="PGCluster client"
+ mkdir -p "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/psql "$subpkgdir"/usr/bin/
+}
+
+
+md5sums="d2fe705e25a01c19c8f8daa1fbcc55d1 pgcluster-1.9.0rc5.tar.gz
+ad21a30c7fd5ce9de1290c317492a0e5 pgcluster.initd
+503f94824fc7a385a831d7e55b74f9a0 pgcluster.confd"
diff --git a/main/pgcluster/pgcluster.confd b/main/pgcluster/pgcluster.confd
new file mode 100644
index 00000000000..9e1376eec70
--- /dev/null
+++ b/main/pgcluster/pgcluster.confd
@@ -0,0 +1,57 @@
+# PostgreSQL's Database Directory
+PGDATA="/var/lib/postgresql/pgcluster"
+
+# PostgreSQL User
+PGUSER="postgres"
+
+# PostgreSQL Group
+PGGROUP="postgres"
+
+# control what gets started by init script
+PG_START_DB="yes"
+PG_START_REPLICATE="yes"
+PG_START_LB="no"
+
+# Extra options to run postmaster with, e.g.:
+# -N is the maximal number of client connections
+# -B is the number of shared buffers and has to be at least 2x the value for -N
+# Please read the man-page to postmaster for more options. Many of these options
+# can be set directly in the configuration-file.
+#PGOPTS="-N 512 -B 1024"
+
+
+# SERVER SHUTDOWN:
+# The server will receive 3 signals in the worst case:
+# 1. SIGTERM
+# This signals the server to ignore new connections and to
+# wait for all clients to end their transactions before shutting down.
+# Use WAIT_FOR_DISCONNECT to control how much time the clients
+# should have until the next signal is being sent.
+# 2. SIGINT
+# Tell the server to forcefully disconnect all clients.
+# Terminating a client results in a rollback of the open transactions for this client.
+# Use WAIT_FOR_CLEANUP to determine how much time the server has
+# for cleanup.
+# 3. SIGQUIT
+# This will terminate the server immediately and results in a recovery run for the next start.
+
+# Wait for clients to disconnect
+WAIT_FOR_DISCONNECT=30
+
+# Time the server has to clean up
+WAIT_FOR_CLEANUP=60
+
+# Time the server has to quit (with a recover-run on next startup)
+# Set to 0 to deactivate it
+WAIT_FOR_QUIT=60
+
+# Comment this out if you don't want to wait for the server to
+# startup before continuing. For example, if this server is a
+# PITR log shipping based replication standby
+WAIT_FOR_START="-w"
+
+# If you have to export environment variables for the database process,
+# this can be done here.
+#
+# Example:
+# export R_HOME="/usr/lib/R"
diff --git a/main/pgcluster/pgcluster.initd b/main/pgcluster/pgcluster.initd
new file mode 100644
index 00000000000..fb5cdfdf352
--- /dev/null
+++ b/main/pgcluster/pgcluster.initd
@@ -0,0 +1,172 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-8.3,v 1.4 2008/09/28 22:53:02 caleb Exp $
+
+opts="${opts} reload setup"
+
+depend() {
+ use net
+ provide postgresql
+}
+
+checkconfig() {
+ if [ ! -d "$PGDATA" ] ; then
+ eerror "Directory not found: $PGDATA"
+ eerror "Please make sure that PGDATA points to the right path."
+ eerror "You can run '/etc/init.d/pgcluster setup' to setup a new database cluster."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ #ebegin "Starting PostgreSQL"
+
+ if [ -f "$PGDATA/postmaster.pid" ] ; then
+ rm -f "$PGDATA/postmaster.pid"
+ fi
+
+ local retval
+
+ if [ ${PG_START_DB} == "yes" ]; then
+ ebegin "Starting PGCluster database instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl start ${WAIT_FOR_START} -o '--silent-mode=true ${PGOPTS}'" >/dev/null
+ retval=$?
+ if [ $retval -ne 0 ]; then
+ eend $retval
+ else
+
+ # The following is to catch the case of an already running server
+ # in which pg_ctl doesn't know to which server it connected to and false reports the server as 'up'
+ sleep 2
+ if [ ! -f "$PGDATA/postmaster.pid" ] ; then
+ eerror "The pid-file doesn't exist but pg_ctl reported a running server."
+ eerror "Please check whether there is another server running on the same port or read the log-file."
+ eend 1
+ else
+ local pid=$(grep "^[0-9]\+" "$PGDATA/postmaster.pid")
+ test -d /proc/"${pid}"
+ eend $?
+ fi
+ fi
+ fi
+
+ if [ ${PG_START_REPLICATE} == "yes" ]; then
+ ebegin "Starting PGCluster replicate instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pgreplicate -D ${PGDATA} -l" >/dev/null
+ retval=$?
+ sleep 1
+ if [ ! -f "$PGDATA/pgreplicate.pid" ] ; then
+ eerror "Where's the pid file?"
+ eend 1
+ else
+ local pid=$(grep "^[0-9]\+" "$PGDATA/pgreplicate.pid")
+ test -d /proc/"${pid}"
+ eend $?
+ fi
+ fi
+
+ if [ ${PG_START_LB} == "yes" ]; then
+ ebegin "Starting PGCluster load balancer instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pglb -D ${PGDATA} -l" >/dev/null
+ retval=$?
+ sleep 1
+ if [ ! -f "$PGDATA/pglb.pid" ] ; then
+ eerror "Where's the pid file?"
+ eend 1
+ else
+ local pid=$(grep "^[0-9]\+" "$PGDATA/pglb.pid")
+ test -d /proc/"${pid}"
+ eend $?
+ fi
+ fi
+ return
+}
+
+stop() {
+ local retval
+
+ if [ ${PG_START_LB} == "yes" ]; then
+ ebegin "Stopping PGCluster Load Balancer instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pglb -D ${PGDATA} -l stop" >/dev/null
+ eend $?
+ fi
+ if [ ${PG_START_REPLICATE} == "yes" ]; then
+ ebegin "Stopping PGCluster Replicate instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pgreplicate -D ${PGDATA} -l stop" >/dev/null
+ eend $?
+ fi
+
+
+ if [ ${PG_START_DB} == "yes" ]; then
+ ebegin "Stopping PGCLuster database (this can take up to $(( ${WAIT_FOR_DISCONNECT} + ${WAIT_FOR_CLEANUP} )) seconds)"
+ if [ ! -f "$PGDATA/postmaster.pid" ] ; then
+ ewarn "$PGDATA/postmaster.pid not found. Was it running?"
+ eend 1
+ return 0
+ fi
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -t ${WAIT_FOR_DISCONNECT} -m smart" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ ewarn "Some clients did not disconnect within ${WAIT_FOR_DISCONNECT} seconds."
+ ewarn "Going to shutdown the server anyway."
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -m fast" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ if [ ${WAIT_FOR_QUIT} -eq 0 ] ; then
+ eerror "Server did not shut down and sending the SIGQUIT has been disabled."
+ eend $retval
+ return $retval
+ fi
+
+ ewarn "Shutting down the server gracefully failed."
+ ewarn "Forcing it to shutdown which leads to a recover-run on next startup."
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -m immediate" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ eerror "Forced shutdown failed!!! Something is wrong with your system, please take care of it manually."
+ eend $?
+ fi
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl reload" >/dev/null
+ eend $?
+}
+
+setup() {
+ ebegin "Creating a new PGCluster database cluster"
+ if [ -d "${PGDATA}" ] ; then
+ eend 1 "${PGDATA} already exist"
+ return
+ fi
+ mkdir -p "${PGDATA}"
+ chown -Rf postgres:postgres "${PGDATA}"
+ chmod 0700 "${PGDATA}"
+ cd "${PGDATA}" # to avoid the: could not change directory to "/root"
+ su -c "/usr/bin/initdb --pgdata ${PGDATA}" postgres
+ einfo "You can use the '/etc/init.d/pgcluster' script to run PostgreSQL instead"
+ einfo "of 'pg_ctl'."
+ eend $?
+}
+
diff --git a/main/pgpool/APKBUILD b/main/pgpool/APKBUILD
new file mode 100644
index 00000000000..980b3019a87
--- /dev/null
+++ b/main/pgpool/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Cameron <cbanta@gmail.com>
+# Maintainer: Cameron <cbanta@gmail.com>
+pkgname=pgpool
+_opkgname=pgpool-II
+pkgver=2.2.2
+pkgrel=0
+pkgdesc="Pgpool II is a connection pooling/replication server for PostgreSQL."
+url="http://pgfoundry.org/projects/pgpool/"
+license="BSD"
+makedepends="postgresql-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://pgfoundry.org/frs/download.php/2191/$_opkgname-$pkgver.tar.gz
+ $pkgname.initd"
+
+build() {
+ cd "$srcdir/$_opkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+}
+
+md5sums="6f14514ed4ed5368ad3ab7e2d4c5136b pgpool-II-2.2.2.tar.gz
+21573def15ffd08a07221569ef54c149 pgpool.initd"
diff --git a/main/pgpool/pgpool.initd b/main/pgpool/pgpool.initd
new file mode 100644
index 00000000000..d577cf9e161
--- /dev/null
+++ b/main/pgpool/pgpool.initd
@@ -0,0 +1,24 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+depend() {
+ need net
+ use postgresql
+}
+
+start() {
+ ebegin "Starting pgpool-II"
+ start-stop-daemon --start --quiet --exec /usr/bin/pgpool --f /etc/pgpool.conf -F /etc/pcp.conf
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping pgpool-II"
+ start-stop-daemon --stop --quiet --pidfile /var/run/pgpool.pid
+ result=$?
+ eend $result
+}
+
diff --git a/main/php-apc/APKBUILD b/main/php-apc/APKBUILD
new file mode 100644
index 00000000000..d3460aaa569
--- /dev/null
+++ b/main/php-apc/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=php-apc
+pkgver=3.1.2
+pkgrel=0
+pkgdesc="Alternative PHP Cache"
+url="http://pecl.php.net/package/APC"
+license="PHP"
+depends="php"
+makedepends="php-dev autoconf pcre-dev"
+subpackages=""
+source="http://pecl.php.net/get/APC-${pkgver}.tgz
+apc.ini"
+
+build() {
+ cd "$srcdir/APC-${pkgver}"
+
+ phpize || return 1
+ ./configure --enable-apc \
+ --disable-apc-mmap \
+ --with-php-config=/usr/bin/php-config
+ make || return 1
+ make INSTALL_ROOT=$pkgdir install || return 1
+ install -D -m644 "$srcdir"/apc.ini "$pkgdir"/etc/php/conf.d/apc.ini
+
+}
+
+md5sums="0a18cf164b3e044e27edd4c1d8c3145c APC-3.1.2.tgz
+1be423cbc197a302abd50cfd5834258b apc.ini"
diff --git a/main/php-apc/apc.ini b/main/php-apc/apc.ini
new file mode 100644
index 00000000000..eb8a7e8f2c8
--- /dev/null
+++ b/main/php-apc/apc.ini
@@ -0,0 +1,11 @@
+;PHP suggest APC settings
+extension=apc.so
+;apc.enabled=1
+;apc.shm_segments=1
+;apc.shm_size=128
+;apc.ttl=7200
+;apc.user_ttl=7200
+;apc.num_files_hint=1024
+;apc.mmap_file_mask=/tmp/apc.XXXXXX
+;apc.enable_cli=1
+
diff --git a/main/php-fileinfo/APKBUILD b/main/php-fileinfo/APKBUILD
new file mode 100644
index 00000000000..8e72f404c3c
--- /dev/null
+++ b/main/php-fileinfo/APKBUILD
@@ -0,0 +1,26 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=php-fileinfo
+pkgver=1.0.4
+pkgrel=0
+pkgdesc="This extension allows retrieval of information regarding vast majority of file."
+url="http://pecl.php.net/package/Fileinfo"
+license="PHP"
+depends="file php"
+makedepends="autoconf php-dev file-dev"
+install=""
+source="http://pecl.php.net/get/Fileinfo-$pkgver.tgz
+ magic.patch"
+
+build ()
+{
+ cd $srcdir/Fileinfo-$pkgver
+ patch -p1 -i "$srcdir"/magic.patch || return 1
+ phpize || return 1
+ ./configure --prefix=/usr || return 1
+ make || return 1
+ make INSTALL_ROOT="$pkgdir" install || return 1
+ echo ';extension=fileinfo.so' > fileinfo.ini
+ install -D -m644 fileinfo.ini "$pkgdir"/etc/php/conf.d/fileinfo.ini
+}
+md5sums="2854e749db157365c769cb9496f5586f Fileinfo-1.0.4.tgz
+e2689b892a795f1b9c601997dd48edab magic.patch"
diff --git a/main/php-fileinfo/magic.patch b/main/php-fileinfo/magic.patch
new file mode 100644
index 00000000000..7f939e8b886
--- /dev/null
+++ b/main/php-fileinfo/magic.patch
@@ -0,0 +1,13 @@
+--- a/config.m4 2006-11-07 22:31:19.000000000 +0100
++++ b/config.m4 2009-04-19 20:23:37.923512186 +0200
+@@ -47,8 +47,8 @@
+ -L$FILEINFO_DIR/lib
+ ])
+
+- MAGIC_MIME_DIRS="/usr/local/share/file /usr/share/file /usr/share/misc/file /etc /usr/share/misc"
+- MAGIC_MIME_FILENAMES="magic magic.mime"
++ MAGIC_MIME_DIRS="/usr/share/misc/file"
++ MAGIC_MIME_FILENAMES="magic.mgc"
+
+ for i in $MAGIC_MIME_DIRS; do
+ for j in $MAGIC_MIME_FILENAMES; do
diff --git a/main/php/APKBUILD b/main/php/APKBUILD
new file mode 100644
index 00000000000..f1a36a24e9a
--- /dev/null
+++ b/main/php/APKBUILD
@@ -0,0 +1,144 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=php
+pkgver=5.2.10
+pkgrel=0
+pkgdesc="The PHP language runtime engine"
+url="http://www.php.net/"
+license="PHP-3"
+depends=
+makedepends="pcre-dev libxml2-dev libiconv-dev openssl-dev zlib-dev bzip2-dev
+ curl-dev libpng-dev jpeg-dev freetype-dev libmcrypt-dev mysql-dev
+ sqlite-dev libtool libltdl postgresql-dev"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-bcmath $pkgname-bz2
+ $pkgname-calendar $pkgname-curl $pkgname-exif $pkgname-ftp $pkgname-gd
+ $pkgname-iconv $pkgname-json $pkgname-mcrypt $pkgname-mime_magic
+ $pkgname-mysql $pkgname-mysqli $pkgname-openssl $pkgname-pdo
+ $pkgname-pdo_mysql $pkgname-pdo_sqlite $pkgname-posix $pkgname-session
+ $pkgname-shmop $pkgname-soap $pkgname-sockets $pkgname-sqlite
+ $pkgname-sysvmsg $pkgname-sysvsem $pkgname-sysvshm $pkgname-xmlrpc
+ $pkgname-zip $pkgname-zlib $pkgname-postgresql $pkgname-pdo_pgsql"
+source="http://www.php.net/distributions/${pkgname}-${pkgver}.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --build=${CHOST:-i486-alpine-linux-uclibc} \
+ --prefix=/usr \
+ --sysconfdir=/etc/php \
+ --with-layout=GNU \
+ --with-config-file-path=/etc/php \
+ --with-config-file-scan-dir=/etc/php/conf.d \
+ --enable-inline-optimization \
+ --disable-debug \
+ --disable-rpath \
+ --disable-static \
+ --enable-shared \
+ --mandir=/usr/share/man \
+ --with-openssl=shared \
+ --with-zlib=shared \
+ --enable-bcmath=shared \
+ --with-bz2=shared \
+ --enable-calendar=shared \
+ --with-curl=shared \
+ --enable-exif=shared \
+ --enable-ftp=shared \
+ --with-gd=shared \
+ --with-jpeg-dir=shared,/usr \
+ --with-png-dir=shared,/usr \
+ --enable-gd-native-ttf \
+ --enable-mbstring=shared \
+ --with-mcrypt=shared \
+ --with-mysql=shared \
+ --with-mysql-sock=/tmp/mysql.sock \
+ --with-mysql=shared \
+ --with-mysqli=shared \
+ --with-pear=/usr/share/pear \
+ --enable-pdo=shared \
+ --with-pdo-mysql=shared \
+ --with-pdo-sqlite=shared,/usr \
+ --enable-fastcgi \
+ --with-sqlite=shared \
+ --enable-sqlite-utf8 \
+ --enable-shmop=shared \
+ --enable-soap=shared \
+ --enable-sysvmsg=shared \
+ --enable-sysvsem=shared \
+ --enable-sysvshm=shared \
+ --enable-zip=shared \
+ --enable-posix=shared \
+ --enable-sockets=shared \
+ --enable-xml \
+ --with-ttf=shared \
+ --enable-session=shared \
+ --with-regex=php \
+ --with-pcre-regex=/usr \
+ --enable-mbstring=all \
+ --enable-mbregex \
+ --enable-json=shared \
+ --with-iconv=shared \
+ --with-xmlrpc=shared \
+ --enable-cgi \
+ --with-freetype-dir=shared,/usr \
+ --with-mime-magic=shared \
+ --enable-discard-path \
+ --enable-force-cgi-redirect \
+ --disable-cli \
+ --with-pgsql=shared \
+ --with-pdo-pgsql=shared \
+ --with-pic
+
+ make || return 1
+ make -j1 INSTALL_ROOT="$pkgdir" install || return 1
+ install -D -m644 php.ini-recommended "$pkgdir"/etc/php/php.ini
+}
+
+_mv_mod() {
+ local d=usr/lib/php/20060613
+ mkdir -p "$subpkgdir/$d"
+ mv "$pkgdir/$d/${1}.so" "$subpkgdir/$d/" || return 1
+ # last one removed the dir
+ rmdir "$pkgdir/$d" 2>/dev/null
+ return 0
+}
+
+bcmath() { _mv_mod bcmath; }
+bz2() { _mv_mod bz2; }
+calendar() { _mv_mod calendar; }
+curl() { _mv_mod curl; }
+exif() { _mv_mod exif; }
+ftp() { _mv_mod ftp; }
+gd() { _mv_mod gd; }
+iconv() { _mv_mod iconv; }
+json() { _mv_mod json; }
+mcrypt() { _mv_mod mcrypt; }
+mime_magic() { _mv_mod mime_magic; }
+mysql() { _mv_mod mysql; }
+mysqli() { _mv_mod mysqli; }
+openssl() { _mv_mod openssl; }
+pdo() { _mv_mod pdo; }
+pdo_mysql() { _mv_mod pdo_mysql; }
+pdo_sqlite() { _mv_mod pdo_sqlite; }
+posix() { _mv_mod posix; }
+session() { _mv_mod session; }
+shmop() { _mv_mod shmop; }
+soap() { _mv_mod soap; }
+sockets() { _mv_mod sockets; }
+sqlite() { _mv_mod sqlite; }
+sysvmsg() { _mv_mod sysvmsg; }
+sysvsem() { _mv_mod sysvsem; }
+sysvshm() { _mv_mod sysvshm; }
+xmlrpc() { _mv_mod xmlrpc; }
+zip() { _mv_mod zip; }
+zlib() { _mv_mod zlib; }
+postgresql() { _mv_mod pgsql; }
+pdo_pgsql() { _mv_mod pdo_pgsql; }
+
+# devleoper package
+dev() {
+ default_dev
+ mkdir -p "$subpkgdir"/usr/lib/php/
+ mv "$pkgdir"/usr/lib/php/build "$subpkgdir"/usr/lib/php/
+}
+
+md5sums="15c7b5a87f57332d6fc683528e28247b php-5.2.10.tar.bz2"
diff --git a/main/pinentry/APKBUILD b/main/pinentry/APKBUILD
new file mode 100644
index 00000000000..5322ebe7a2c
--- /dev/null
+++ b/main/pinentry/APKBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=pinentry
+pkgver=0.7.5
+_uiconv_ver=0.3
+pkgrel=0
+pkgdesc="Collection of simple PIN or passphrase entry dialogs which utilize the Assuan protocol"
+url="http://www.gnupg.org/aegypten2"
+license="GPL-2"
+depends="ncurses libcap"
+makedepends="ncurses-dev libcap-dev"
+subpackages="$pkgname-doc"
+source="ftp://ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.gz
+ http://git.alpinelinux.org/cgit/uiconv/snapshot/uiconv-$_uiconv_ver.tar.bz2
+ "
+
+build () {
+ # we build it against uiconv to avoid the bloaty GNU libiconv.
+ # it will be linked statically so we don't need it in depends
+ cd "$srcdir/uiconv-$_uiconv_ver"
+ make
+ make DESTDIR="$srcdir" PREFIX=/uiconv install
+
+ cd "$srcdir"/$pkgname-$pkgver
+
+ # the configure script have a broken --with-libiconv-prefix option
+ # so we set the -I and -L flags hard
+ export CFLAGS="$CFLAGS -I $srcdir/uiconv/include"
+ export LDFLAGS="$LDFLAGS -L $srcdir/uiconv/lib"
+
+ ./configure --prefix=/usr \
+ --disable-pinentry-gtk \
+ --disable-pinentry-gtk2 \
+ --disable-pinentry-qt \
+ --enable-pinentry-curses \
+ --enable-fallback-curses \
+ --with-libiconv-prefix="$srcdir"/uiconv
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="ca492afbbb59cd19f1c875533f18b269 pinentry-0.7.5.tar.gz
+5cd7f80085324d08cb976fec674cd98d uiconv-0.3.tar.bz2"
diff --git a/main/pingu/APKBUILD b/main/pingu/APKBUILD
new file mode 100644
index 00000000000..fdd91972ab0
--- /dev/null
+++ b/main/pingu/APKBUILD
@@ -0,0 +1,23 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=pingu
+pkgver=0.3
+pkgrel=0
+pkgdesc="Small daemon that pings hosts and executes a script when status change"
+url="http://git.alpinelinux.org/cgit/pingu"
+license="GPL"
+depends="uclibc"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
+ pingu.initd
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make || return 1
+ make BINDIR=/usr/sbin DESTDIR="$pkgdir" install
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+}
+
+md5sums="59f9c927a80c71d85f2363e314a25197 pingu-0.3.tar.bz2
+d2162d9c02a66691bb6360f4f2d9d701 pingu.initd"
diff --git a/main/pingu/pingu.initd b/main/pingu/pingu.initd
new file mode 100644
index 00000000000..39301f80e48
--- /dev/null
+++ b/main/pingu/pingu.initd
@@ -0,0 +1,27 @@
+#!/sbin/runscript
+
+# Sample init.d file for alpine linux.
+
+NAME=pingu
+DAEMON=/usr/bin/$NAME
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet \
+ --pidfile /var/run/${NAME}.pid \
+ --exec ${DAEMON} -- -d
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet \
+ --exec ${DAEMON} \
+ --pidfile /var/run/${NAME}.pid
+ eend $?
+}
+
diff --git a/main/portmap/APKBUILD b/main/portmap/APKBUILD
new file mode 100644
index 00000000000..7539f314aa7
--- /dev/null
+++ b/main/portmap/APKBUILD
@@ -0,0 +1,39 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=portmap
+pkgver=6.0
+pkgrel=2
+pkgdesc="RPC connection manager"
+url="http://neil.brown.name/portmap/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install="$pkgname.pre-install"
+subpackages="$pkgname-doc"
+source="http://neil.brown.name/$pkgname/$pkgname-$pkgver.tgz
+ $pkgname-6.0-tcpd.patch
+ $install
+ $pkgname.confd
+ $pkgname.initd"
+
+build ()
+{
+ cd "$srcdir"/portmap_$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ make NO_TCP_WRAPPER=NO || return 1
+ mkdir -p "$pkgdir"/sbin
+ mkdir -p "$pkgdir"/usr/share/man/man8
+ make BASEDIR="$pkgdir" install
+ mkdir -p "$pkgdir"/etc/init.d "$pkgdir"/etc/conf.d
+ install -m 755 "$startdir"/$pkgname.initd $pkgdir/etc/init.d/$pkgname
+ install -m 644 "$startdir"/$pkgname.confd $pkgdir/etc/conf.d/$pkgname
+}
+
+md5sums="ac108ab68bf0f34477f8317791aaf1ff portmap-6.0.tgz
+bdcd217a0d459c75116d0b5aa90a372b portmap-6.0-tcpd.patch
+b726a64e91b47244a7539288338c6bbd portmap.pre-install
+56b0f47cda2003f3394ef7c37ec4cdff portmap.confd
+2944aa0387aba4ed6219d7856e5e8fb0 portmap.initd"
diff --git a/main/portmap/portmap-6.0-tcpd.patch b/main/portmap/portmap-6.0-tcpd.patch
new file mode 100644
index 00000000000..c6af8f8c80b
--- /dev/null
+++ b/main/portmap/portmap-6.0-tcpd.patch
@@ -0,0 +1,18 @@
+Enable compile without tcp-wrappers
+
+Patch by Timothy Redaelli <drizzt@gentoo.org>
+
+http://bugs.gentoo.org/178242
+
+--- portmap_6.0/pmap_check.c
++++ portmap_6.0/pmap_check.c
+@@ -44,7 +44,9 @@
+ #include <netinet/in.h>
+ #include <rpc/rpcent.h>
+ #endif
++#ifdef HOSTS_ACCESS
+ #include <tcpd.h>
++#endif
+ #include <arpa/inet.h>
+ #include <grp.h>
+
diff --git a/main/portmap/portmap.confd b/main/portmap/portmap.confd
new file mode 100644
index 00000000000..c2756c992b4
--- /dev/null
+++ b/main/portmap/portmap.confd
@@ -0,0 +1,5 @@
+# /etc/conf.d/portmap: config file for /etc/init.d/portmap
+
+# Options for `portmap`.
+# For a full list, just run `portmap -h`.
+#PORTMAP_OPTS="-l"
diff --git a/main/portmap/portmap.initd b/main/portmap/portmap.initd
new file mode 100644
index 00000000000..65d23d74849
--- /dev/null
+++ b/main/portmap/portmap.initd
@@ -0,0 +1,46 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-nds/portmap/files/portmap.rc6,v 1.12 2007/06/13 07:52:44 vapier Exp $
+
+depend() {
+ use net
+ before inetd
+ before xinetd
+}
+
+start() {
+ ebegin "Starting portmap"
+ start-stop-daemon --start --quiet --exec /sbin/portmap -- ${PORTMAP_OPTS}
+ local ret=$?
+ eend ${ret}
+ # without, if a service depending on portmap is started too fast,
+ # connecting to portmap will fail -- azarah
+ sleep 1
+ return ${ret}
+}
+
+stop() {
+ ebegin "Stopping portmap"
+ start-stop-daemon --stop --quiet --exec /sbin/portmap
+ eend $?
+}
+
+restart() {
+ # Dump the portmapper's table before stopping
+ ebegin "Saving portmap table"
+ local pmap=$(pmap_dump)
+ eend $?
+
+ # Stop and restart portmapper
+ svc_stop
+ sleep 1
+ svc_start
+
+ # Reload the portmapper's table
+ if [ -n "${pmap}" ] ; then
+ ebegin "Reloading portmap table"
+ echo "${pmap}" | pmap_set
+ eend $?
+ fi
+}
diff --git a/main/portmap/portmap.pre-install b/main/portmap/portmap.pre-install
new file mode 100644
index 00000000000..b0dcfb9c5c1
--- /dev/null
+++ b/main/portmap/portmap.pre-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+adduser -h /dev/null -s /bin/false -D rpc 2>/dev/null || true
diff --git a/main/postfix/APKBUILD b/main/postfix/APKBUILD
new file mode 100644
index 00000000000..71a9199c071
--- /dev/null
+++ b/main/postfix/APKBUILD
@@ -0,0 +1,151 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=postfix
+pkgver=2.6.2
+pkgrel=3
+pkgdesc="Secure and fast drop-in replacement for Sendmail (MTA)"
+url="http://www.postfix.org/"
+license="IPL-1"
+depends=
+makedepends="db-dev pcre-dev openssl-dev postgresql-dev mysql-dev openldap-dev cyrus-sasl-dev perl"
+install="$pkgname.pre-install $pkgname.post-install"
+subpackages="$pkgname-doc $pkgname-ldap $pkgname-mysql $pkgname-pcre
+ $pkgname-pgsql"
+source="ftp://ftp.porcupine.org/mirrors/$pkgname-release/official/$pkgname-$pkgver.tar.gz
+ $pkgname.initd
+ $install
+ postfix-2.6.1-dynamicmaps.patch
+ dynamicmaps.cf
+ postfix-ldap.post-install
+ postfix-mysql.post-install
+ postfix-pcre.post-install
+ postfix-pgsql.post-install
+ "
+
+# the dynamic maps patch is taken from mandriva
+# http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/postfix/current/SOURCES
+
+_shared_libs() {
+ file --mime-type "$@" | \
+ awk '$2 == "application/x-sharedlib" {print $1}' | \
+ tr -d :
+}
+
+build () {
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+ cp ../dynamicmaps.cf conf/
+
+ sed -i -e "s|#define HAS_NIS|//#define HAS_NIS|g" \
+ -e "/^#define ALIAS_DB_MAP/s|:/etc/aliases|:/etc/postfix/aliases|" \
+ src/util/sys_defs.h || return 1
+ sed -i -e "s:/usr/local/:/usr/:g" conf/master.cf || return 1
+
+ # needed for dynamic maps.
+ local ccargs="-DHAS_DLOPEN -DHAS_SHL_LOAD"
+ local auxlibs="$LDFLAGS -lpthread -lcrypt"
+
+ ccargs="$ccargs -DDEF_DAEMON_DIR=\\\"/usr/lib/postfix\\\""
+
+ # pcre
+ ccargs="$ccargs -DHAS_PCRE"
+ #auxlibs="$auxlibs -lpcre"
+
+ # ssl
+ ccargs="$ccargs -DUSE_TLS"
+ auxlibs="$auxlibs -lssl -lcrypto"
+
+ ## dovecot-sasl
+ #ccargs="$ccargs -DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\\\"dovecot\\\""
+
+ # cyrus sasl
+ ccargs="$ccargs -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl"
+ auxlibs="$auxlibs -lsasl2"
+
+ # postgresql
+ ccargs="$ccargs -DHAS_PGSQL -I$(pg_config --includedir)"
+ #auxlibs="$auxlibs -lpq -L$(pg_config --libdir)"
+
+ # mysql
+ ccargs="$ccargs -DHAS_MYSQL $(mysql_config --include)"
+ #auxlibs="$auxlibs -lmysqlclient -lm -lz"
+
+ # compile
+ make DEBUG="" \
+ OPT="$CFLAGS" \
+ CCARGS="$ccargs" \
+ AUXLIBS="$auxlibs" \
+ makefiles || return 1
+
+ make OPT="$CFLAGS" || return 1
+
+ for i in $(_shared_libs lib/*.a); do
+ j=${i#lib/lib}
+ ln -s ${i#lib/} lib/libpostfix-${j%.a}.so.1
+ done
+
+ # install to pkgdir
+ LD_LIBRARY_PATH=$PWD/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} make \
+ non-interactive-package \
+ install_root="$pkgdir" \
+ config_directory=/usr/share/doc/$pkgname/defaults \
+ readme_directory=/usr/share/doc/$pkgname/readme \
+ manpage_directory=/usr/share/man \
+ || return 1
+
+ install -d "$pkgdir"/usr/lib
+ for i in $(_shared_libs lib/*.a); do
+ j=${i#lib/lib}
+ install $i "$pkgdir"/usr/lib/libpostfix-${j%.a}.so.1 || return 1
+ done
+
+ # fix permissions
+ for i in postdrop postqueue; do
+ chgrp postdrop "$pkgdir"/usr/sbin/$i
+ chmod g+s "$pkgdir"/usr/sbin/$i
+ done
+
+ mkdir -p "$pkgdir"/etc/postfix
+ mv "$pkgdir"/usr/share/doc/$pkgname/defaults/*.cf \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/aliases \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/canonical \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/generic \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/header_checks \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/relocated \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/transport \
+ "$pkgdir"/usr/share/doc/$pkgname/defaults/virtual \
+ "$pkgdir"/etc/postfix/ || return 1
+
+ install -d -o postfix -g postfix "$pkgdir"/var/spool/postfix
+ install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/${pkgname}/LICENSE
+}
+
+_mv_dict() {
+ local m=$1
+ shift
+ pkgdesc="$m map support for postfix"
+ depends=
+ install="postfix-${m}.post-install"
+ mkdir -p "$subpkgdir"/usr/lib/postfix
+ mv "$pkgdir"/usr/lib/postfix/dict_${m}.so \
+ "$subpkgdir"/usr/lib/postfix/
+}
+
+ldap() { _mv_dict ldap ; }
+mysql() { _mv_dict mysql ;}
+pcre() { _mv_dict pcre ; }
+pgsql() { _mv_dict pgsql ; }
+
+md5sums="1f0edbd521d2b0473626f4d61e8bb4eb postfix-2.6.2.tar.gz
+8416354d402f3be288fa98b60af86240 postfix.initd
+2bfc3864183694e5484ac073bb0cb7ef postfix.pre-install
+0064d45c2c8a46c374b55c4abc46cfb2 postfix.post-install
+d45552cfdcd911d0934c0cb7816c4011 postfix-2.6.1-dynamicmaps.patch
+442efd1a95b0c061dfb8ab75456e0f24 dynamicmaps.cf
+2ebe51a882eb9d6d7866583eb6af3969 postfix-ldap.post-install
+2ebe51a882eb9d6d7866583eb6af3969 postfix-mysql.post-install
+fd16ec00b60269c4ede4a0a0a514cefa postfix-pcre.post-install
+2ebe51a882eb9d6d7866583eb6af3969 postfix-pgsql.post-install"
diff --git a/main/postfix/dynamicmaps.cf b/main/postfix/dynamicmaps.cf
new file mode 100644
index 00000000000..dfe21105525
--- /dev/null
+++ b/main/postfix/dynamicmaps.cf
@@ -0,0 +1,16 @@
+# Postfix dynamic maps configuration file.
+#
+# The first match found is the one that is used. Wildcards are not
+# supported.
+#
+#type location of .so file name of open function
+#==== ============================= =====================
+#ldap /usr/lib/postfix/dict_ldap.so dict_ldap_open
+#mysql /usr/lib/postfix/dict_mysql.so dict_mysql_open
+#pcre /usr/lib/postfix/dict_pcre.so dict_pcre_open
+#regex /usr/lib/postfix/dict_pcre.so dict_pcre_open
+#pgsql /usr/lib/postfix/dict_pgsql.so dict_pgsql_open
+
+# apk tools will manage the lines below
+## AUTO BEGIN ##
+## AUTO END ##
diff --git a/main/postfix/postfix-2.6.1-dynamicmaps.patch b/main/postfix/postfix-2.6.1-dynamicmaps.patch
new file mode 100644
index 00000000000..630abedc3ba
--- /dev/null
+++ b/main/postfix/postfix-2.6.1-dynamicmaps.patch
@@ -0,0 +1,5273 @@
+diff -ruN a/conf/postfix-files b/conf/postfix-files
+--- a/conf/postfix-files 2009-06-01 12:27:42.000000000 +0000
++++ b/conf/postfix-files 2009-06-01 13:08:26.000000000 +0000
+@@ -65,6 +65,10 @@
+ $queue_directory/trace:d:$mail_owner:-:700:ucr
+ $daemon_directory/anvil:f:root:-:755
+ $daemon_directory/bounce:f:root:-:755
++$daemon_directory/dict_ldap.so:f:root:-:755
++$daemon_directory/dict_pcre.so:f:root:-:755
++$daemon_directory/dict_mysql.so:f:root:-:755
++$daemon_directory/dict_pgsql.so:f:root:-:755
+ $daemon_directory/cleanup:f:root:-:755
+ $daemon_directory/discard:f:root:-:755
+ $daemon_directory/error:f:root:-:755
+@@ -94,6 +98,11 @@
+ $daemon_directory/trivial-rewrite:f:root:-:755
+ $daemon_directory/verify:f:root:-:755
+ $daemon_directory/virtual:f:root:-:755
++/usr/lib/libpostfix-dns.so.1:f:root:-:755
++/usr/lib/libpostfix-global.so.1:f:root:-:755
++/usr/lib/libpostfix-tls.so.1:f:root:-:755
++/usr/lib/libpostfix-master.so.1:f:root:-:755
++/usr/lib/libpostfix-util.so.1:f:root:-:755
+ $daemon_directory/nqmgr:h:$daemon_directory/qmgr
+ $daemon_directory/lmtp:h:$daemon_directory/smtp
+ $command_directory/postalias:f:root:-:755
+@@ -117,6 +126,7 @@
+ $config_directory/aliases:f:root:-:644:p1
+ $config_directory/bounce.cf.default:f:root:-:644:1
+ $config_directory/canonical:f:root:-:644:p1
++$config_directory/dynamicmaps.cf:f:root:-:644:p
+ $config_directory/cidr_table:f:root:-:644:o
+ $config_directory/generic:f:root:-:644:p1
+ $config_directory/generics:f:root:-:644:o
+diff -ruN a/src/dns/Makefile.in b/src/dns/Makefile.in
+--- a/src/dns/Makefile.in 2009-06-01 12:27:43.000000000 +0000
++++ b/src/dns/Makefile.in 2009-06-01 13:08:26.000000000 +0000
+@@ -14,7 +14,7 @@
+ LIB_DIR = ../../lib
+ INC_DIR = ../../include
+
+-.c.o:; $(CC) $(CFLAGS) -c $*.c
++.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
+
+ all: $(LIB)
+
+@@ -31,12 +31,10 @@
+ root_tests:
+
+ $(LIB): $(OBJS)
+- $(AR) $(ARFL) $(LIB) $?
+- $(RANLIB) $(LIB)
++ gcc -shared -Wl,-soname,libpostfix-dns.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
+
+ $(LIB_DIR)/$(LIB): $(LIB)
+ cp $(LIB) $(LIB_DIR)
+- $(RANLIB) $(LIB_DIR)/$(LIB)
+
+ update: $(LIB_DIR)/$(LIB) $(HDRS)
+ -for i in $(HDRS); \
+diff -ruN a/src/global/Makefile.in b/src/global/Makefile.in
+--- a/src/global/Makefile.in 2009-06-01 12:27:43.000000000 +0000
++++ b/src/global/Makefile.in 2009-06-01 13:08:26.000000000 +0000
+@@ -34,7 +34,7 @@
+ canon_addr.o cfg_parser.o cleanup_strerror.o cleanup_strflags.o \
+ clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \
+ defer.o deliver_completed.o deliver_flock.o deliver_pass.o \
+- deliver_request.o dict_ldap.o dict_mysql.o dict_pgsql.o \
++ deliver_request.o \
+ dict_proxy.o domain_list.o dot_lockfile.o dot_lockfile_as.o \
+ dsb_scan.o dsn.o dsn_buf.o dsn_mask.o dsn_print.o dsn_util.o \
+ ehlo_mask.o ext_prop.o file_id.o flush_clnt.o header_opts.o \
+@@ -103,10 +103,13 @@
+ LIB_DIR = ../../lib
+ INC_DIR = ../../include
+ MAKES =
++LDAPSO = dict_ldap.so
++MYSQLSO = dict_mysql.so
++PGSQLSO = dict_pgsql.so
+
+-.c.o:; $(CC) $(CFLAGS) -c $*.c
++.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
+
+-all: $(LIB)
++all: $(LIB) $(LDAPSO) $(MYSQLSO) $(PGSQLSO)
+
+ $(OBJS): ../../conf/makedefs.out
+
+@@ -116,14 +119,30 @@
+ test: $(TESTPROG)
+
+ $(LIB): $(OBJS)
+- $(AR) $(ARFL) $(LIB) $?
+- $(RANLIB) $(LIB)
++ gcc -shared -Wl,-soname,libpostfix-global.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
++
++$(LDAPSO): dict_ldap.o $(LIB) ../../lib/libglobal.a
++ gcc -shared -Wl,-soname,dict_ldap.so -o $@ $? -lldap -llber -L../../lib -lutil -L. -lglobal
++
++$(MYSQLSO): dict_mysql.o $(LIB) ../../lib/libglobal.a
++ gcc -shared -Wl,-soname,dict_mysql.so -o $@ $? -lmysqlclient -L. -lutil -lglobal
++
++$(PGSQLSO): dict_pgsql.o $(LIB) ../../lib/libglobal.a
++ gcc -shared -Wl,-soname,dict_pgsql.so -o $@ $? -lpq -L. -lutil -lglobal
+
+ $(LIB_DIR)/$(LIB): $(LIB)
+ cp $(LIB) $(LIB_DIR)
+- $(RANLIB) $(LIB_DIR)/$(LIB)
+
+-update: $(LIB_DIR)/$(LIB) $(HDRS)
++../../libexec/$(LDAPSO): $(LDAPSO)
++ cp $(LDAPSO) ../../libexec
++
++../../libexec/$(MYSQLSO): $(MYSQLSO)
++ cp $(MYSQLSO) ../../libexec
++
++../../libexec/$(PGSQLSO): $(PGSQLSO)
++ cp $(PGSQLSO) ../../libexec
++
++update: $(LIB_DIR)/$(LIB) ../../libexec/$(LDAPSO) ../../libexec/$(MYSQLSO) ../../libexec/$(PGSQLSO) $(HDRS)
+ -for i in $(HDRS); \
+ do \
+ cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
+@@ -491,7 +510,7 @@
+ lint $(DEFS) $(SRCS) $(LINTFIX)
+
+ clean:
+- rm -f *.o $(LIB) *core $(TESTPROG) junk
++ rm -f *.o $(LIB) $(LDAPSO) $(MYSQLSO) $(PGSQLSO) *core $(TESTPROG) junk
+ rm -rf printfck
+
+ tidy: clean
+diff -ruN a/src/global/Makefile.in.orig b/src/global/Makefile.in.orig
+--- a/src/global/Makefile.in.orig 1970-01-01 00:00:00.000000000 +0000
++++ b/src/global/Makefile.in.orig 2009-06-01 13:07:56.000000000 +0000
+@@ -0,0 +1,2018 @@
++SHELL = /bin/sh
++SRCS = abounce.c anvil_clnt.c been_here.c bounce.c bounce_log.c \
++ canon_addr.c cfg_parser.c cleanup_strerror.c cleanup_strflags.c \
++ clnt_stream.c conv_time.c db_common.c debug_peer.c debug_process.c \
++ defer.c deliver_completed.c deliver_flock.c deliver_pass.c \
++ deliver_request.c dict_ldap.c dict_mysql.c dict_pgsql.c \
++ dict_proxy.c domain_list.c dot_lockfile.c dot_lockfile_as.c \
++ dsb_scan.c dsn.c dsn_buf.c dsn_mask.c dsn_print.c dsn_util.c \
++ ehlo_mask.c ext_prop.c file_id.c flush_clnt.c header_opts.c \
++ header_token.c input_transp.c int_filt.c is_header.c log_adhoc.c \
++ mail_addr.c mail_addr_crunch.c mail_addr_find.c mail_addr_map.c \
++ mail_command_client.c mail_command_server.c mail_conf.c \
++ mail_conf_bool.c mail_conf_int.c mail_conf_long.c mail_conf_raw.c \
++ mail_conf_str.c mail_conf_time.c mail_connect.c mail_copy.c \
++ mail_date.c mail_dict.c mail_error.c mail_flush.c mail_open_ok.c \
++ mail_params.c mail_pathname.c mail_queue.c mail_run.c \
++ mail_scan_dir.c mail_stream.c mail_task.c mail_trigger.c maps.c \
++ mark_corrupt.c match_parent_style.c mbox_conf.c mbox_open.c \
++ mime_state.c mkmap_cdb.c mkmap_db.c mkmap_dbm.c mkmap_open.c \
++ mkmap_sdbm.c msg_stats_print.c msg_stats_scan.c mynetworks.c \
++ mypwd.c namadr_list.c off_cvt.c opened.c own_inet_addr.c \
++ pipe_command.c post_mail.c quote_821_local.c quote_822_local.c \
++ rcpt_buf.c rcpt_print.c rec_attr_map.c rec_streamlf.c rec_type.c \
++ recipient_list.c record.c remove.c resolve_clnt.c resolve_local.c \
++ rewrite_clnt.c scache_clnt.c scache_multi.c scache_single.c \
++ sent.c smtp_stream.c split_addr.c string_list.c strip_addr.c \
++ sys_exits.c timed_ipc.c tok822_find.c tok822_node.c tok822_parse.c \
++ tok822_resolve.c tok822_rewrite.c tok822_tree.c trace.c \
++ user_acl.c valid_mailhost_addr.c verify.c verify_clnt.c \
++ verp_sender.c wildcard_inet_addr.c xtext.c delivered_hdr.c \
++ fold_addr.c header_body_checks.c mkmap_proxy.c data_redirect.c \
++ match_service.c mail_conf_nint.c
++OBJS = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \
++ canon_addr.o cfg_parser.o cleanup_strerror.o cleanup_strflags.o \
++ clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \
++ defer.o deliver_completed.o deliver_flock.o deliver_pass.o \
++ deliver_request.o dict_ldap.o dict_mysql.o dict_pgsql.o \
++ dict_proxy.o domain_list.o dot_lockfile.o dot_lockfile_as.o \
++ dsb_scan.o dsn.o dsn_buf.o dsn_mask.o dsn_print.o dsn_util.o \
++ ehlo_mask.o ext_prop.o file_id.o flush_clnt.o header_opts.o \
++ header_token.o input_transp.o int_filt.o is_header.o log_adhoc.o \
++ mail_addr.o mail_addr_crunch.o mail_addr_find.o mail_addr_map.o \
++ mail_command_client.o mail_command_server.o mail_conf.o \
++ mail_conf_bool.o mail_conf_int.o mail_conf_long.o mail_conf_raw.o \
++ mail_conf_str.o mail_conf_time.o mail_connect.o mail_copy.o \
++ mail_date.o mail_dict.o mail_error.o mail_flush.o mail_open_ok.o \
++ mail_params.o mail_pathname.o mail_queue.o mail_run.o \
++ mail_scan_dir.o mail_stream.o mail_task.o mail_trigger.o maps.o \
++ mark_corrupt.o match_parent_style.o mbox_conf.o mbox_open.o \
++ mime_state.o mkmap_cdb.o mkmap_db.o mkmap_dbm.o mkmap_open.o \
++ mkmap_sdbm.o msg_stats_print.o msg_stats_scan.o mynetworks.o \
++ mypwd.o namadr_list.o off_cvt.o opened.o own_inet_addr.o \
++ pipe_command.o post_mail.o quote_821_local.o quote_822_local.o \
++ rcpt_buf.o rcpt_print.o rec_attr_map.o rec_streamlf.o rec_type.o \
++ recipient_list.o record.o remove.o resolve_clnt.o resolve_local.o \
++ rewrite_clnt.o scache_clnt.o scache_multi.o scache_single.o \
++ sent.o smtp_stream.o split_addr.o string_list.o strip_addr.o \
++ sys_exits.o timed_ipc.o tok822_find.o tok822_node.o tok822_parse.o \
++ tok822_resolve.o tok822_rewrite.o tok822_tree.o trace.o \
++ user_acl.o valid_mailhost_addr.o verify.o verify_clnt.o \
++ verp_sender.o wildcard_inet_addr.o xtext.o delivered_hdr.o \
++ fold_addr.o header_body_checks.o mkmap_proxy.o data_redirect.o \
++ match_service.o mail_conf_nint.o
++HDRS = abounce.h anvil_clnt.h been_here.h bounce.h bounce_log.h \
++ canon_addr.h cfg_parser.h cleanup_user.h clnt_stream.h config.h \
++ conv_time.h db_common.h debug_peer.h debug_process.h defer.h \
++ deliver_completed.h deliver_flock.h deliver_pass.h deliver_request.h \
++ dict_ldap.h dict_mysql.h dict_pgsql.h dict_proxy.h domain_list.h \
++ dot_lockfile.h dot_lockfile_as.h dsb_scan.h dsn.h dsn_buf.h \
++ dsn_mask.h dsn_print.h dsn_util.h ehlo_mask.h ext_prop.h \
++ file_id.h flush_clnt.h header_opts.h header_token.h input_transp.h \
++ int_filt.h is_header.h lex_822.h log_adhoc.h mail_addr.h \
++ mail_addr_crunch.h mail_addr_find.h mail_addr_map.h mail_conf.h \
++ mail_copy.h mail_date.h mail_dict.h mail_error.h mail_flush.h \
++ mail_open_ok.h mail_params.h mail_proto.h mail_queue.h mail_run.h \
++ mail_scan_dir.h mail_stream.h mail_task.h mail_version.h maps.h \
++ mark_corrupt.h match_parent_style.h mbox_conf.h mbox_open.h \
++ mime_state.h mkmap.h msg_stats.h mynetworks.h mypwd.h namadr_list.h \
++ off_cvt.h opened.h own_inet_addr.h pipe_command.h post_mail.h \
++ qmgr_user.h qmqp_proto.h quote_821_local.h quote_822_local.h \
++ quote_flags.h rcpt_buf.h rcpt_print.h rec_attr_map.h rec_streamlf.h \
++ rec_type.h recipient_list.h record.h resolve_clnt.h resolve_local.h \
++ rewrite_clnt.h scache.h sent.h smtp_stream.h split_addr.h \
++ string_list.h strip_addr.h sys_exits.h timed_ipc.h tok822.h \
++ trace.h user_acl.h valid_mailhost_addr.h verify.h verify_clnt.h \
++ verp_sender.h wildcard_inet_addr.h xtext.h delivered_hdr.h \
++ fold_addr.h header_body_checks.h data_redirect.h match_service.h
++TESTSRC = rec2stream.c stream2rec.c recdump.c
++DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE)
++CFLAGS = $(DEBUG) $(OPT) $(DEFS)
++INCL =
++LIB = libglobal.a
++TESTPROG= domain_list dot_lockfile mail_addr_crunch mail_addr_find \
++ mail_addr_map mail_date maps mynetworks mypwd namadr_list \
++ off_cvt quote_822_local rec2stream recdump resolve_clnt \
++ resolve_local rewrite_clnt stream2rec string_list tok822_parse \
++ quote_821_local mail_conf_time mime_state strip_addr \
++ verify_clnt xtext anvil_clnt scache ehlo_mask \
++ valid_mailhost_addr own_inet_addr header_body_checks \
++ data_redirect
++
++LIBS = ../../lib/libutil.a
++LIB_DIR = ../../lib
++INC_DIR = ../../include
++MAKES =
++
++.c.o:; $(CC) $(CFLAGS) -c $*.c
++
++all: $(LIB)
++
++$(OBJS): ../../conf/makedefs.out
++
++Makefile: Makefile.in
++ cat ../../conf/makedefs.out $? >$@
++
++test: $(TESTPROG)
++
++$(LIB): $(OBJS)
++ $(AR) $(ARFL) $(LIB) $?
++ $(RANLIB) $(LIB)
++
++$(LIB_DIR)/$(LIB): $(LIB)
++ cp $(LIB) $(LIB_DIR)
++ $(RANLIB) $(LIB_DIR)/$(LIB)
++
++update: $(LIB_DIR)/$(LIB) $(HDRS)
++ -for i in $(HDRS); \
++ do \
++ cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
++ done
++ cd $(INC_DIR); chmod 644 $(HDRS)
++
++dot_lockfile: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++tok822_parse: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++rec2stream: rec2stream.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++stream2rec: stream2rec.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++recdump: recdump.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++namadr_list: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++domain_list: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mynetworks: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++resolve_clnt: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++rewrite_clnt: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++quote_822_local: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++off_cvt: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mail_addr_map: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mail_addr_find: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++maps: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mypwd: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mail_date: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++resolve_local: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mail_addr_crunch: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++string_list: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++local_transport: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++quote_821_local: quote_821_local.c $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIBS) $(SYSLIBS)
++
++mail_conf_time: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++mime_state: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++strip_addr: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++verify_clnt: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++xtext: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++anvil_clnt: $(LIB) $(LIBS)
++ mv $@.o junk
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++ mv junk $@.o
++
++scache: scache.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++ehlo_mask: ehlo_mask.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++valid_mailhost_addr: valid_mailhost_addr.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++own_inet_addr: own_inet_addr.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++header_body_checks: header_body_checks.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++data_redirect: data_redirect.c $(LIB) $(LIBS)
++ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
++
++tests: tok822_test mime_tests strip_addr_test tok822_limit_test \
++ xtext_test scache_multi_test ehlo_mask_test \
++ namadr_list_test mail_conf_time_test header_body_checks_tests
++
++mime_tests: mime_test mime_nest mime_8bit mime_dom mime_trunc mime_cvt \
++ mime_cvt2 mime_cvt3 mime_garb1 mime_garb2 mime_garb3 mime_garb4
++
++header_body_checks_tests: header_body_checks_null_test \
++ header_body_checks_warn_test header_body_checks_prepend_test \
++ header_body_checks_ignore_test header_body_checks_replace_test
++
++root_tests: rewrite_clnt_test resolve_clnt_test
++
++tok822_test: tok822_parse tok822_parse.in tok822_parse.ref
++ ./tok822_parse <tok822_parse.in >tok822_parse.tmp 2>&1
++ diff tok822_parse.ref tok822_parse.tmp
++ rm -f tok822_parse.tmp
++
++mime_test: mime_state mime_test.in mime_test.ref
++ ./mime_state <mime_test.in >mime_test.tmp
++ diff mime_test.ref mime_test.tmp
++ rm -f mime_test.tmp
++
++mime_nest: mime_state mime_nest.in mime_nest.ref
++ ./mime_state <mime_nest.in >mime_nest.tmp
++ diff mime_nest.ref mime_nest.tmp
++ rm -f mime_nest.tmp
++
++mime_8bit: mime_state mime_8bit.in mime_8bit.ref
++ ./mime_state <mime_8bit.in >mime_8bit.tmp
++ diff mime_8bit.ref mime_8bit.tmp
++ rm -f mime_8bit.tmp
++
++mime_dom: mime_state mime_dom.in mime_dom.ref
++ ./mime_state <mime_dom.in >mime_dom.tmp
++ diff mime_dom.ref mime_dom.tmp
++ rm -f mime_dom.tmp
++
++mime_trunc: mime_state mime_trunc.in mime_trunc.ref
++ ./mime_state <mime_trunc.in >mime_trunc.tmp
++ diff mime_trunc.ref mime_trunc.tmp
++ rm -f mime_trunc.tmp
++
++mime_cvt: mime_state mime_cvt.in mime_cvt.ref
++ ./mime_state <mime_cvt.in >mime_cvt.tmp
++ diff mime_cvt.ref mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++mime_cvt2: mime_state mime_cvt.in2 mime_cvt.ref2
++ ./mime_state <mime_cvt.in2 >mime_cvt.tmp
++ diff mime_cvt.ref2 mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++mime_cvt3: mime_state mime_cvt.in3 mime_cvt.ref3
++ ./mime_state <mime_cvt.in3 >mime_cvt.tmp
++ diff mime_cvt.ref3 mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++mime_garb1: mime_state mime_garb1.in mime_garb1.ref
++ ./mime_state <mime_garb1.in >mime_cvt.tmp
++ diff mime_garb1.ref mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++mime_garb2: mime_state mime_garb2.in mime_garb2.ref
++ ./mime_state <mime_garb2.in >mime_cvt.tmp
++ diff mime_garb2.ref mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++mime_garb3: mime_state mime_garb3.in mime_garb3.ref
++ ./mime_state <mime_garb3.in >mime_cvt.tmp
++ diff mime_garb3.ref mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++mime_garb4: mime_state mime_garb4.in mime_garb4.ref
++ ./mime_state <mime_garb4.in >mime_cvt.tmp
++ diff mime_garb4.ref mime_cvt.tmp
++ rm -f mime_cvt.tmp
++
++tok822_limit_test: tok822_parse tok822_limit.in tok822_limit.ref
++ ./tok822_parse <tok822_limit.in >tok822_limit.tmp
++ diff tok822_limit.ref tok822_limit.tmp
++ rm -f tok822_limit.tmp
++
++strip_addr_test: strip_addr strip_addr.ref
++ ./strip_addr 2>strip_addr.tmp
++ diff strip_addr.ref strip_addr.tmp
++ rm -f strip_addr.tmp
++
++xtext_test: xtext
++ ./xtext <xtext.c | od -cb >xtext.tmp
++ od -cb <xtext.c >xtext.ref
++ cmp xtext.ref xtext.tmp
++ rm -f xtext.ref xtext.tmp
++
++# Requires: Postfix running, root privileges
++
++rewrite_clnt_test: rewrite_clnt rewrite_clnt.in rewrite_clnt.ref
++ @set -- `id`; case "$$1" in \
++ *"(root)") ;; \
++ *) echo 'This test requires root privilege'; exit 1;; \
++ esac
++ @test -n "`postconf -h remote_header_rewrite_domain`" || { \
++ echo 'This test requires non-empty remote_header_rewrite_domain'; exit 1; }
++ ./rewrite_clnt <rewrite_clnt.in >rewrite_clnt.tmp
++ sed -e "s/MYDOMAIN/`postconf -h mydomain`/" \
++ -e "s/INVALID_DOMAIN/`postconf -h remote_header_rewrite_domain`/" \
++ rewrite_clnt.ref | diff - rewrite_clnt.tmp
++ rm -f rewrite_clnt.tmp
++
++# Requires: Postfix, root, relayhost=$mydomain, no transport map
++
++resolve_clnt_test: resolve_clnt resolve_clnt.in resolve_clnt.ref
++ @set -- `id`; case "$$1" in \
++ *"(root)") ;; \
++ *) echo 'This test requires root privilege'; exit 1;; \
++ esac
++ @test "`postconf -h relayhost`" = '$$mydomain' || { \
++ echo 'This test requires relayhost=$$mydomain'; exit 1; }
++ @test "`postconf -h transport_maps`" = "" || { \
++ echo 'This test requires no transport map'; exit 1; }
++ sed -e "s/MYDOMAIN/`postconf -h mydomain`/g" \
++ -e "s/MYHOSTNAME/`postconf -h myhostname`/g" \
++ resolve_clnt.in | ./resolve_clnt >resolve_clnt.tmp
++ sed -e "s/MYDOMAIN/`postconf -h mydomain`/g" \
++ -e "s/MYHOSTNAME/`postconf -h myhostname`/g" \
++ -e "s/RELAYHOST/`postconf -h mydomain`/g" \
++ resolve_clnt.ref | diff - resolve_clnt.tmp
++ rm -f resolve_clnt.tmp
++
++scache_multi_test: scache scache_multi.in scache_multi.ref
++ ./scache <scache_multi.in >scache_multi.tmp
++ diff scache_multi.ref scache_multi.tmp
++ rm -f scache_multi.tmp
++
++ehlo_mask_test: ehlo_mask ehlo_mask.in ehlo_mask.ref
++ ./ehlo_mask <ehlo_mask.in >ehlo_mask.tmp
++ diff ehlo_mask.ref ehlo_mask.tmp
++ rm -f ehlo_mask.tmp
++
++namadr_list_test: namadr_list namadr_list.in namadr_list.ref
++ -sh namadr_list.in >namadr_list.tmp 2>&1
++ diff namadr_list.ref namadr_list.tmp
++ rm -f namadr_list.tmp
++
++mail_conf_time_test: mail_conf_time mail_conf_time.ref
++ ./mail_conf_time >mail_conf_time.tmp
++ diff mail_conf_time.ref mail_conf_time.tmp
++ rm -f mail_conf_time.tmp
++
++header_body_checks_null_test: header_body_checks header_body_checks_null.ref
++ ./header_body_checks "" "" "" "" \
++ <mime_test.in >header_body_checks_null.tmp 2>&1
++ cmp header_body_checks_null.ref header_body_checks_null.tmp
++ ./header_body_checks static:dunno static:dunno static:dunno static:dunno \
++ <mime_test.in >header_body_checks_null.tmp 2>&1
++ cmp header_body_checks_null.ref header_body_checks_null.tmp
++ ./header_body_checks static:ok static:ok static:ok static:ok \
++ <mime_test.in >header_body_checks_null.tmp 2>&1
++ cmp header_body_checks_null.ref header_body_checks_null.tmp
++ rm -f header_body_checks_null.tmp
++
++header_body_checks_warn_test: header_body_checks header_body_checks_warn.ref
++ ./header_body_checks static:warn static:warn static:warn static:warn \
++ <mime_test.in >header_body_checks_warn.tmp 2>&1
++ cmp header_body_checks_warn.ref header_body_checks_warn.tmp
++ rm -f header_body_checks_warn.tmp
++
++header_body_checks_prepend_test: header_body_checks header_body_checks_prepend.ref
++ echo /./ prepend header: head >header_body_checks_head
++ echo /./ prepend header: mime >header_body_checks_mime
++ echo /./ prepend header: nest >header_body_checks_nest
++ echo /./ prepend body >header_body_checks_body
++ ./header_body_checks regexp:header_body_checks_head regexp:header_body_checks_mime \
++ regexp:header_body_checks_nest regexp:header_body_checks_body \
++ <mime_test.in >header_body_checks_prepend.tmp 2>&1
++ cmp header_body_checks_prepend.ref header_body_checks_prepend.tmp
++ rm -f header_body_checks_prepend.tmp header_body_checks_head header_body_checks_mime header_body_checks_nest header_body_checks_body
++
++# Note: the IGNORE action will not strip empty lines. Postfix maps
++# currently never see null query strings because some map types raise
++# errors. We can eliminate this restriction by allowing individual
++# map types to advertise whether they can handle null queries.
++header_body_checks_ignore_test: header_body_checks header_body_checks_ignore.ref
++ ./header_body_checks static:ignore static:ignore static:ignore static:ignore \
++ <mime_test.in >header_body_checks_ignore.tmp 2>&1
++ cmp header_body_checks_ignore.ref header_body_checks_ignore.tmp
++ rm -f header_body_checks_ignore.tmp header_body_checks_head header_body_checks_mime header_body_checks_nest header_body_checks_body
++
++header_body_checks_replace_test: header_body_checks header_body_checks_replace.ref
++ echo /./ replace header: head >header_body_checks_head
++ echo /./ replace header: mime >header_body_checks_mime
++ echo /./ replace header: nest >header_body_checks_nest
++ echo /./ replace body >header_body_checks_body
++ ./header_body_checks regexp:header_body_checks_head regexp:header_body_checks_mime \
++ regexp:header_body_checks_nest regexp:header_body_checks_body \
++ <mime_test.in >header_body_checks_replace.tmp 2>&1
++ cmp header_body_checks_replace.ref header_body_checks_replace.tmp
++ rm -f header_body_checks_replace.tmp header_body_checks_head header_body_checks_mime header_body_checks_nest header_body_checks_body
++
++printfck: $(OBJS) $(PROG)
++ rm -rf printfck
++ mkdir printfck
++ cp *.h printfck
++ sed '1,/^# do not edit/!d' Makefile >printfck/Makefile
++ set -e; for i in *.c; do printfck -f .printfck $$i >printfck/$$i; done
++ cd printfck; make "INC_DIR=../../../include" `cd ..; ls *.o`
++
++lint:
++ lint $(DEFS) $(SRCS) $(LINTFIX)
++
++clean:
++ rm -f *.o $(LIB) *core $(TESTPROG) junk
++ rm -rf printfck
++
++tidy: clean
++
++depend: $(MAKES)
++ (sed '1,/^# do not edit/!d' Makefile.in; \
++ set -e; for i in [a-z][a-z0-9]*.c; do \
++ $(CC) -E $(DEFS) $(INCL) $$i | grep -v '[<>]' | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \
++ -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' \
++ -e 's/o: \.\//o: /' -e p -e '}' ; \
++ done | sort -u) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in
++ @$(EXPORT) make -f Makefile.in Makefile 1>&2
++
++# do not edit below this line - it is generated by 'make depend'
++abounce.o: ../../include/attr.h
++abounce.o: ../../include/events.h
++abounce.o: ../../include/iostuff.h
++abounce.o: ../../include/msg.h
++abounce.o: ../../include/mymalloc.h
++abounce.o: ../../include/sys_defs.h
++abounce.o: ../../include/vbuf.h
++abounce.o: ../../include/vstream.h
++abounce.o: ../../include/vstring.h
++abounce.o: abounce.c
++abounce.o: abounce.h
++abounce.o: bounce.h
++abounce.o: deliver_request.h
++abounce.o: dsn.h
++abounce.o: dsn_buf.h
++abounce.o: mail_params.h
++abounce.o: mail_proto.h
++abounce.o: msg_stats.h
++abounce.o: recipient_list.h
++anvil_clnt.o: ../../include/attr.h
++anvil_clnt.o: ../../include/attr_clnt.h
++anvil_clnt.o: ../../include/iostuff.h
++anvil_clnt.o: ../../include/msg.h
++anvil_clnt.o: ../../include/mymalloc.h
++anvil_clnt.o: ../../include/stringops.h
++anvil_clnt.o: ../../include/sys_defs.h
++anvil_clnt.o: ../../include/vbuf.h
++anvil_clnt.o: ../../include/vstream.h
++anvil_clnt.o: ../../include/vstring.h
++anvil_clnt.o: anvil_clnt.c
++anvil_clnt.o: anvil_clnt.h
++anvil_clnt.o: mail_params.h
++anvil_clnt.o: mail_proto.h
++been_here.o: ../../include/htable.h
++been_here.o: ../../include/msg.h
++been_here.o: ../../include/mymalloc.h
++been_here.o: ../../include/stringops.h
++been_here.o: ../../include/sys_defs.h
++been_here.o: ../../include/vbuf.h
++been_here.o: ../../include/vstring.h
++been_here.o: been_here.c
++been_here.o: been_here.h
++bounce.o: ../../include/attr.h
++bounce.o: ../../include/iostuff.h
++bounce.o: ../../include/msg.h
++bounce.o: ../../include/mymalloc.h
++bounce.o: ../../include/sys_defs.h
++bounce.o: ../../include/vbuf.h
++bounce.o: ../../include/vstream.h
++bounce.o: ../../include/vstring.h
++bounce.o: bounce.c
++bounce.o: bounce.h
++bounce.o: defer.h
++bounce.o: deliver_request.h
++bounce.o: dsn.h
++bounce.o: dsn_buf.h
++bounce.o: dsn_print.h
++bounce.o: dsn_util.h
++bounce.o: log_adhoc.h
++bounce.o: mail_params.h
++bounce.o: mail_proto.h
++bounce.o: msg_stats.h
++bounce.o: rcpt_print.h
++bounce.o: recipient_list.h
++bounce.o: trace.h
++bounce.o: verify.h
++bounce_log.o: ../../include/attr.h
++bounce_log.o: ../../include/iostuff.h
++bounce_log.o: ../../include/msg.h
++bounce_log.o: ../../include/mymalloc.h
++bounce_log.o: ../../include/stringops.h
++bounce_log.o: ../../include/sys_defs.h
++bounce_log.o: ../../include/vbuf.h
++bounce_log.o: ../../include/vstream.h
++bounce_log.o: ../../include/vstring.h
++bounce_log.o: ../../include/vstring_vstream.h
++bounce_log.o: bounce_log.c
++bounce_log.o: bounce_log.h
++bounce_log.o: dsn.h
++bounce_log.o: dsn_buf.h
++bounce_log.o: dsn_mask.h
++bounce_log.o: mail_params.h
++bounce_log.o: mail_proto.h
++bounce_log.o: mail_queue.h
++bounce_log.o: rcpt_buf.h
++bounce_log.o: recipient_list.h
++canon_addr.o: ../../include/attr.h
++canon_addr.o: ../../include/iostuff.h
++canon_addr.o: ../../include/mymalloc.h
++canon_addr.o: ../../include/sys_defs.h
++canon_addr.o: ../../include/vbuf.h
++canon_addr.o: ../../include/vstream.h
++canon_addr.o: ../../include/vstring.h
++canon_addr.o: canon_addr.c
++canon_addr.o: canon_addr.h
++canon_addr.o: mail_proto.h
++canon_addr.o: rewrite_clnt.h
++cfg_parser.o: ../../include/argv.h
++cfg_parser.o: ../../include/dict.h
++cfg_parser.o: ../../include/msg.h
++cfg_parser.o: ../../include/mymalloc.h
++cfg_parser.o: ../../include/sys_defs.h
++cfg_parser.o: ../../include/vbuf.h
++cfg_parser.o: ../../include/vstream.h
++cfg_parser.o: ../../include/vstring.h
++cfg_parser.o: cfg_parser.c
++cfg_parser.o: cfg_parser.h
++cfg_parser.o: mail_conf.h
++cleanup_strerror.o: ../../include/msg.h
++cleanup_strerror.o: ../../include/sys_defs.h
++cleanup_strerror.o: ../../include/vbuf.h
++cleanup_strerror.o: ../../include/vstring.h
++cleanup_strerror.o: cleanup_strerror.c
++cleanup_strerror.o: cleanup_user.h
++cleanup_strflags.o: ../../include/msg.h
++cleanup_strflags.o: ../../include/sys_defs.h
++cleanup_strflags.o: ../../include/vbuf.h
++cleanup_strflags.o: ../../include/vstring.h
++cleanup_strflags.o: cleanup_strflags.c
++cleanup_strflags.o: cleanup_user.h
++clnt_stream.o: ../../include/attr.h
++clnt_stream.o: ../../include/events.h
++clnt_stream.o: ../../include/iostuff.h
++clnt_stream.o: ../../include/msg.h
++clnt_stream.o: ../../include/mymalloc.h
++clnt_stream.o: ../../include/sys_defs.h
++clnt_stream.o: ../../include/vbuf.h
++clnt_stream.o: ../../include/vstream.h
++clnt_stream.o: clnt_stream.c
++clnt_stream.o: clnt_stream.h
++clnt_stream.o: mail_params.h
++clnt_stream.o: mail_proto.h
++conv_time.o: ../../include/msg.h
++conv_time.o: ../../include/sys_defs.h
++conv_time.o: conv_time.c
++conv_time.o: conv_time.h
++data_redirect.o: ../../include/argv.h
++data_redirect.o: ../../include/dict.h
++data_redirect.o: ../../include/dict_cdb.h
++data_redirect.o: ../../include/dict_db.h
++data_redirect.o: ../../include/dict_dbm.h
++data_redirect.o: ../../include/msg.h
++data_redirect.o: ../../include/name_code.h
++data_redirect.o: ../../include/split_at.h
++data_redirect.o: ../../include/stringops.h
++data_redirect.o: ../../include/sys_defs.h
++data_redirect.o: ../../include/vbuf.h
++data_redirect.o: ../../include/vstream.h
++data_redirect.o: ../../include/vstring.h
++data_redirect.o: data_redirect.c
++data_redirect.o: data_redirect.h
++data_redirect.o: dict_proxy.h
++data_redirect.o: mail_params.h
++db_common.o: ../../include/argv.h
++db_common.o: ../../include/dict.h
++db_common.o: ../../include/match_list.h
++db_common.o: ../../include/match_ops.h
++db_common.o: ../../include/msg.h
++db_common.o: ../../include/mymalloc.h
++db_common.o: ../../include/sys_defs.h
++db_common.o: ../../include/vbuf.h
++db_common.o: ../../include/vstream.h
++db_common.o: ../../include/vstring.h
++db_common.o: cfg_parser.h
++db_common.o: db_common.c
++db_common.o: db_common.h
++db_common.o: string_list.h
++debug_peer.o: ../../include/match_list.h
++debug_peer.o: ../../include/match_ops.h
++debug_peer.o: ../../include/msg.h
++debug_peer.o: ../../include/sys_defs.h
++debug_peer.o: debug_peer.c
++debug_peer.o: debug_peer.h
++debug_peer.o: mail_params.h
++debug_peer.o: match_parent_style.h
++debug_peer.o: namadr_list.h
++debug_process.o: ../../include/msg.h
++debug_process.o: ../../include/sys_defs.h
++debug_process.o: debug_process.c
++debug_process.o: debug_process.h
++debug_process.o: mail_conf.h
++debug_process.o: mail_params.h
++defer.o: ../../include/attr.h
++defer.o: ../../include/iostuff.h
++defer.o: ../../include/msg.h
++defer.o: ../../include/sys_defs.h
++defer.o: ../../include/vbuf.h
++defer.o: ../../include/vstream.h
++defer.o: ../../include/vstring.h
++defer.o: bounce.h
++defer.o: defer.c
++defer.o: defer.h
++defer.o: deliver_request.h
++defer.o: dsn.h
++defer.o: dsn_buf.h
++defer.o: dsn_print.h
++defer.o: dsn_util.h
++defer.o: flush_clnt.h
++defer.o: log_adhoc.h
++defer.o: mail_params.h
++defer.o: mail_proto.h
++defer.o: mail_queue.h
++defer.o: msg_stats.h
++defer.o: rcpt_print.h
++defer.o: recipient_list.h
++defer.o: trace.h
++defer.o: verify.h
++deliver_completed.o: ../../include/msg.h
++deliver_completed.o: ../../include/sys_defs.h
++deliver_completed.o: ../../include/vbuf.h
++deliver_completed.o: ../../include/vstream.h
++deliver_completed.o: ../../include/vstring.h
++deliver_completed.o: deliver_completed.c
++deliver_completed.o: deliver_completed.h
++deliver_completed.o: rec_type.h
++deliver_completed.o: record.h
++deliver_flock.o: ../../include/iostuff.h
++deliver_flock.o: ../../include/myflock.h
++deliver_flock.o: ../../include/sys_defs.h
++deliver_flock.o: ../../include/vbuf.h
++deliver_flock.o: ../../include/vstring.h
++deliver_flock.o: deliver_flock.c
++deliver_flock.o: deliver_flock.h
++deliver_flock.o: mail_params.h
++deliver_pass.o: ../../include/attr.h
++deliver_pass.o: ../../include/iostuff.h
++deliver_pass.o: ../../include/msg.h
++deliver_pass.o: ../../include/mymalloc.h
++deliver_pass.o: ../../include/split_at.h
++deliver_pass.o: ../../include/sys_defs.h
++deliver_pass.o: ../../include/vbuf.h
++deliver_pass.o: ../../include/vstream.h
++deliver_pass.o: ../../include/vstring.h
++deliver_pass.o: bounce.h
++deliver_pass.o: defer.h
++deliver_pass.o: deliver_pass.c
++deliver_pass.o: deliver_pass.h
++deliver_pass.o: deliver_request.h
++deliver_pass.o: dsb_scan.h
++deliver_pass.o: dsn.h
++deliver_pass.o: dsn_buf.h
++deliver_pass.o: mail_params.h
++deliver_pass.o: mail_proto.h
++deliver_pass.o: msg_stats.h
++deliver_pass.o: rcpt_print.h
++deliver_pass.o: recipient_list.h
++deliver_request.o: ../../include/attr.h
++deliver_request.o: ../../include/iostuff.h
++deliver_request.o: ../../include/msg.h
++deliver_request.o: ../../include/myflock.h
++deliver_request.o: ../../include/mymalloc.h
++deliver_request.o: ../../include/sys_defs.h
++deliver_request.o: ../../include/vbuf.h
++deliver_request.o: ../../include/vstream.h
++deliver_request.o: ../../include/vstring.h
++deliver_request.o: deliver_request.c
++deliver_request.o: deliver_request.h
++deliver_request.o: dsn.h
++deliver_request.o: dsn_print.h
++deliver_request.o: mail_open_ok.h
++deliver_request.o: mail_proto.h
++deliver_request.o: mail_queue.h
++deliver_request.o: msg_stats.h
++deliver_request.o: rcpt_buf.h
++deliver_request.o: recipient_list.h
++delivered_hdr.o: ../../include/htable.h
++delivered_hdr.o: ../../include/msg.h
++delivered_hdr.o: ../../include/mymalloc.h
++delivered_hdr.o: ../../include/stringops.h
++delivered_hdr.o: ../../include/sys_defs.h
++delivered_hdr.o: ../../include/vbuf.h
++delivered_hdr.o: ../../include/vstream.h
++delivered_hdr.o: ../../include/vstring.h
++delivered_hdr.o: ../../include/vstring_vstream.h
++delivered_hdr.o: delivered_hdr.c
++delivered_hdr.o: delivered_hdr.h
++delivered_hdr.o: fold_addr.h
++delivered_hdr.o: header_opts.h
++delivered_hdr.o: is_header.h
++delivered_hdr.o: quote_822_local.h
++delivered_hdr.o: quote_flags.h
++delivered_hdr.o: rec_type.h
++delivered_hdr.o: record.h
++dict_ldap.o: ../../include/argv.h
++dict_ldap.o: ../../include/binhash.h
++dict_ldap.o: ../../include/dict.h
++dict_ldap.o: ../../include/match_list.h
++dict_ldap.o: ../../include/match_ops.h
++dict_ldap.o: ../../include/msg.h
++dict_ldap.o: ../../include/mymalloc.h
++dict_ldap.o: ../../include/stringops.h
++dict_ldap.o: ../../include/sys_defs.h
++dict_ldap.o: ../../include/vbuf.h
++dict_ldap.o: ../../include/vstream.h
++dict_ldap.o: ../../include/vstring.h
++dict_ldap.o: cfg_parser.h
++dict_ldap.o: db_common.h
++dict_ldap.o: dict_ldap.c
++dict_ldap.o: dict_ldap.h
++dict_ldap.o: string_list.h
++dict_mysql.o: ../../include/argv.h
++dict_mysql.o: ../../include/dict.h
++dict_mysql.o: ../../include/events.h
++dict_mysql.o: ../../include/find_inet.h
++dict_mysql.o: ../../include/match_list.h
++dict_mysql.o: ../../include/match_ops.h
++dict_mysql.o: ../../include/msg.h
++dict_mysql.o: ../../include/mymalloc.h
++dict_mysql.o: ../../include/myrand.h
++dict_mysql.o: ../../include/split_at.h
++dict_mysql.o: ../../include/stringops.h
++dict_mysql.o: ../../include/sys_defs.h
++dict_mysql.o: ../../include/vbuf.h
++dict_mysql.o: ../../include/vstream.h
++dict_mysql.o: ../../include/vstring.h
++dict_mysql.o: cfg_parser.h
++dict_mysql.o: db_common.h
++dict_mysql.o: dict_mysql.c
++dict_mysql.o: dict_mysql.h
++dict_mysql.o: string_list.h
++dict_pgsql.o: ../../include/argv.h
++dict_pgsql.o: ../../include/dict.h
++dict_pgsql.o: ../../include/events.h
++dict_pgsql.o: ../../include/find_inet.h
++dict_pgsql.o: ../../include/match_list.h
++dict_pgsql.o: ../../include/match_ops.h
++dict_pgsql.o: ../../include/msg.h
++dict_pgsql.o: ../../include/mymalloc.h
++dict_pgsql.o: ../../include/myrand.h
++dict_pgsql.o: ../../include/split_at.h
++dict_pgsql.o: ../../include/stringops.h
++dict_pgsql.o: ../../include/sys_defs.h
++dict_pgsql.o: ../../include/vbuf.h
++dict_pgsql.o: ../../include/vstream.h
++dict_pgsql.o: ../../include/vstring.h
++dict_pgsql.o: cfg_parser.h
++dict_pgsql.o: db_common.h
++dict_pgsql.o: dict_pgsql.c
++dict_pgsql.o: dict_pgsql.h
++dict_pgsql.o: string_list.h
++dict_proxy.o: ../../include/argv.h
++dict_proxy.o: ../../include/attr.h
++dict_proxy.o: ../../include/dict.h
++dict_proxy.o: ../../include/iostuff.h
++dict_proxy.o: ../../include/msg.h
++dict_proxy.o: ../../include/mymalloc.h
++dict_proxy.o: ../../include/stringops.h
++dict_proxy.o: ../../include/sys_defs.h
++dict_proxy.o: ../../include/vbuf.h
++dict_proxy.o: ../../include/vstream.h
++dict_proxy.o: ../../include/vstring.h
++dict_proxy.o: clnt_stream.h
++dict_proxy.o: dict_proxy.c
++dict_proxy.o: dict_proxy.h
++dict_proxy.o: mail_params.h
++dict_proxy.o: mail_proto.h
++domain_list.o: ../../include/match_list.h
++domain_list.o: ../../include/match_ops.h
++domain_list.o: ../../include/sys_defs.h
++domain_list.o: domain_list.c
++domain_list.o: domain_list.h
++dot_lockfile.o: ../../include/iostuff.h
++dot_lockfile.o: ../../include/mymalloc.h
++dot_lockfile.o: ../../include/stringops.h
++dot_lockfile.o: ../../include/sys_defs.h
++dot_lockfile.o: ../../include/vbuf.h
++dot_lockfile.o: ../../include/vstring.h
++dot_lockfile.o: dot_lockfile.c
++dot_lockfile.o: dot_lockfile.h
++dot_lockfile.o: mail_params.h
++dot_lockfile_as.o: ../../include/msg.h
++dot_lockfile_as.o: ../../include/set_eugid.h
++dot_lockfile_as.o: ../../include/sys_defs.h
++dot_lockfile_as.o: ../../include/vbuf.h
++dot_lockfile_as.o: ../../include/vstring.h
++dot_lockfile_as.o: dot_lockfile.h
++dot_lockfile_as.o: dot_lockfile_as.c
++dot_lockfile_as.o: dot_lockfile_as.h
++dsb_scan.o: ../../include/attr.h
++dsb_scan.o: ../../include/iostuff.h
++dsb_scan.o: ../../include/sys_defs.h
++dsb_scan.o: ../../include/vbuf.h
++dsb_scan.o: ../../include/vstream.h
++dsb_scan.o: ../../include/vstring.h
++dsb_scan.o: dsb_scan.c
++dsb_scan.o: dsb_scan.h
++dsb_scan.o: dsn.h
++dsb_scan.o: dsn_buf.h
++dsb_scan.o: mail_proto.h
++dsn.o: ../../include/msg.h
++dsn.o: ../../include/mymalloc.h
++dsn.o: ../../include/sys_defs.h
++dsn.o: dsn.c
++dsn.o: dsn.h
++dsn_buf.o: ../../include/msg.h
++dsn_buf.o: ../../include/mymalloc.h
++dsn_buf.o: ../../include/sys_defs.h
++dsn_buf.o: ../../include/vbuf.h
++dsn_buf.o: ../../include/vstring.h
++dsn_buf.o: dsn.h
++dsn_buf.o: dsn_buf.c
++dsn_buf.o: dsn_buf.h
++dsn_mask.o: ../../include/msg.h
++dsn_mask.o: ../../include/name_code.h
++dsn_mask.o: ../../include/name_mask.h
++dsn_mask.o: ../../include/sys_defs.h
++dsn_mask.o: ../../include/vbuf.h
++dsn_mask.o: ../../include/vstring.h
++dsn_mask.o: dsn_mask.c
++dsn_mask.o: dsn_mask.h
++dsn_print.o: ../../include/attr.h
++dsn_print.o: ../../include/iostuff.h
++dsn_print.o: ../../include/sys_defs.h
++dsn_print.o: ../../include/vbuf.h
++dsn_print.o: ../../include/vstream.h
++dsn_print.o: dsn.h
++dsn_print.o: dsn_print.c
++dsn_print.o: dsn_print.h
++dsn_print.o: mail_proto.h
++dsn_util.o: ../../include/msg.h
++dsn_util.o: ../../include/mymalloc.h
++dsn_util.o: ../../include/stringops.h
++dsn_util.o: ../../include/sys_defs.h
++dsn_util.o: ../../include/vbuf.h
++dsn_util.o: ../../include/vstring.h
++dsn_util.o: dsn_util.c
++dsn_util.o: dsn_util.h
++ehlo_mask.o: ../../include/name_mask.h
++ehlo_mask.o: ../../include/sys_defs.h
++ehlo_mask.o: ../../include/vbuf.h
++ehlo_mask.o: ../../include/vstring.h
++ehlo_mask.o: ehlo_mask.c
++ehlo_mask.o: ehlo_mask.h
++ext_prop.o: ../../include/name_mask.h
++ext_prop.o: ../../include/sys_defs.h
++ext_prop.o: ../../include/vbuf.h
++ext_prop.o: ../../include/vstring.h
++ext_prop.o: ext_prop.c
++ext_prop.o: ext_prop.h
++ext_prop.o: mail_params.h
++file_id.o: ../../include/msg.h
++file_id.o: ../../include/sys_defs.h
++file_id.o: ../../include/vbuf.h
++file_id.o: ../../include/vstring.h
++file_id.o: file_id.c
++file_id.o: file_id.h
++flush_clnt.o: ../../include/attr.h
++flush_clnt.o: ../../include/iostuff.h
++flush_clnt.o: ../../include/match_list.h
++flush_clnt.o: ../../include/match_ops.h
++flush_clnt.o: ../../include/msg.h
++flush_clnt.o: ../../include/sys_defs.h
++flush_clnt.o: ../../include/vbuf.h
++flush_clnt.o: ../../include/vstream.h
++flush_clnt.o: domain_list.h
++flush_clnt.o: flush_clnt.c
++flush_clnt.o: flush_clnt.h
++flush_clnt.o: mail_flush.h
++flush_clnt.o: mail_params.h
++flush_clnt.o: mail_proto.h
++flush_clnt.o: match_parent_style.h
++fold_addr.o: ../../include/stringops.h
++fold_addr.o: ../../include/sys_defs.h
++fold_addr.o: ../../include/vbuf.h
++fold_addr.o: ../../include/vstring.h
++fold_addr.o: fold_addr.c
++fold_addr.o: fold_addr.h
++header_body_checks.o: ../../include/argv.h
++header_body_checks.o: ../../include/dict.h
++header_body_checks.o: ../../include/msg.h
++header_body_checks.o: ../../include/mymalloc.h
++header_body_checks.o: ../../include/sys_defs.h
++header_body_checks.o: ../../include/vbuf.h
++header_body_checks.o: ../../include/vstream.h
++header_body_checks.o: ../../include/vstring.h
++header_body_checks.o: cleanup_user.h
++header_body_checks.o: dsn_util.h
++header_body_checks.o: header_body_checks.c
++header_body_checks.o: header_body_checks.h
++header_body_checks.o: header_opts.h
++header_body_checks.o: is_header.h
++header_body_checks.o: maps.h
++header_body_checks.o: mime_state.h
++header_body_checks.o: rec_type.h
++header_opts.o: ../../include/htable.h
++header_opts.o: ../../include/msg.h
++header_opts.o: ../../include/stringops.h
++header_opts.o: ../../include/sys_defs.h
++header_opts.o: ../../include/vbuf.h
++header_opts.o: ../../include/vstring.h
++header_opts.o: header_opts.c
++header_opts.o: header_opts.h
++header_token.o: ../../include/msg.h
++header_token.o: ../../include/sys_defs.h
++header_token.o: ../../include/vbuf.h
++header_token.o: ../../include/vstring.h
++header_token.o: header_token.c
++header_token.o: header_token.h
++header_token.o: lex_822.h
++input_transp.o: ../../include/msg.h
++input_transp.o: ../../include/name_mask.h
++input_transp.o: ../../include/sys_defs.h
++input_transp.o: ../../include/vbuf.h
++input_transp.o: ../../include/vstring.h
++input_transp.o: cleanup_user.h
++input_transp.o: input_transp.c
++input_transp.o: input_transp.h
++input_transp.o: mail_params.h
++int_filt.o: ../../include/msg.h
++int_filt.o: ../../include/name_mask.h
++int_filt.o: ../../include/sys_defs.h
++int_filt.o: ../../include/vbuf.h
++int_filt.o: ../../include/vstring.h
++int_filt.o: cleanup_user.h
++int_filt.o: int_filt.c
++int_filt.o: int_filt.h
++int_filt.o: mail_params.h
++is_header.o: ../../include/sys_defs.h
++is_header.o: is_header.c
++is_header.o: is_header.h
++log_adhoc.o: ../../include/attr.h
++log_adhoc.o: ../../include/format_tv.h
++log_adhoc.o: ../../include/msg.h
++log_adhoc.o: ../../include/sys_defs.h
++log_adhoc.o: ../../include/vbuf.h
++log_adhoc.o: ../../include/vstream.h
++log_adhoc.o: ../../include/vstring.h
++log_adhoc.o: dsn.h
++log_adhoc.o: log_adhoc.c
++log_adhoc.o: log_adhoc.h
++log_adhoc.o: mail_params.h
++log_adhoc.o: msg_stats.h
++log_adhoc.o: recipient_list.h
++mail_addr.o: ../../include/stringops.h
++mail_addr.o: ../../include/sys_defs.h
++mail_addr.o: ../../include/vbuf.h
++mail_addr.o: ../../include/vstring.h
++mail_addr.o: mail_addr.c
++mail_addr.o: mail_addr.h
++mail_addr.o: mail_params.h
++mail_addr_crunch.o: ../../include/argv.h
++mail_addr_crunch.o: ../../include/mymalloc.h
++mail_addr_crunch.o: ../../include/sys_defs.h
++mail_addr_crunch.o: ../../include/vbuf.h
++mail_addr_crunch.o: ../../include/vstring.h
++mail_addr_crunch.o: canon_addr.h
++mail_addr_crunch.o: mail_addr_crunch.c
++mail_addr_crunch.o: mail_addr_crunch.h
++mail_addr_crunch.o: resolve_clnt.h
++mail_addr_crunch.o: tok822.h
++mail_addr_find.o: ../../include/argv.h
++mail_addr_find.o: ../../include/dict.h
++mail_addr_find.o: ../../include/msg.h
++mail_addr_find.o: ../../include/mymalloc.h
++mail_addr_find.o: ../../include/stringops.h
++mail_addr_find.o: ../../include/sys_defs.h
++mail_addr_find.o: ../../include/vbuf.h
++mail_addr_find.o: ../../include/vstream.h
++mail_addr_find.o: ../../include/vstring.h
++mail_addr_find.o: mail_addr_find.c
++mail_addr_find.o: mail_addr_find.h
++mail_addr_find.o: mail_params.h
++mail_addr_find.o: maps.h
++mail_addr_find.o: resolve_local.h
++mail_addr_find.o: strip_addr.h
++mail_addr_map.o: ../../include/argv.h
++mail_addr_map.o: ../../include/dict.h
++mail_addr_map.o: ../../include/msg.h
++mail_addr_map.o: ../../include/mymalloc.h
++mail_addr_map.o: ../../include/sys_defs.h
++mail_addr_map.o: ../../include/vbuf.h
++mail_addr_map.o: ../../include/vstream.h
++mail_addr_map.o: ../../include/vstring.h
++mail_addr_map.o: mail_addr_crunch.h
++mail_addr_map.o: mail_addr_find.h
++mail_addr_map.o: mail_addr_map.c
++mail_addr_map.o: mail_addr_map.h
++mail_addr_map.o: maps.h
++mail_command_client.o: ../../include/attr.h
++mail_command_client.o: ../../include/iostuff.h
++mail_command_client.o: ../../include/sys_defs.h
++mail_command_client.o: ../../include/vbuf.h
++mail_command_client.o: ../../include/vstream.h
++mail_command_client.o: mail_command_client.c
++mail_command_client.o: mail_proto.h
++mail_command_server.o: ../../include/attr.h
++mail_command_server.o: ../../include/iostuff.h
++mail_command_server.o: ../../include/sys_defs.h
++mail_command_server.o: ../../include/vbuf.h
++mail_command_server.o: ../../include/vstream.h
++mail_command_server.o: mail_command_server.c
++mail_command_server.o: mail_proto.h
++mail_conf.o: ../../include/argv.h
++mail_conf.o: ../../include/dict.h
++mail_conf.o: ../../include/msg.h
++mail_conf.o: ../../include/mymalloc.h
++mail_conf.o: ../../include/readlline.h
++mail_conf.o: ../../include/safe.h
++mail_conf.o: ../../include/stringops.h
++mail_conf.o: ../../include/sys_defs.h
++mail_conf.o: ../../include/vbuf.h
++mail_conf.o: ../../include/vstream.h
++mail_conf.o: ../../include/vstring.h
++mail_conf.o: mail_conf.c
++mail_conf.o: mail_conf.h
++mail_conf.o: mail_params.h
++mail_conf_bool.o: ../../include/argv.h
++mail_conf_bool.o: ../../include/dict.h
++mail_conf_bool.o: ../../include/msg.h
++mail_conf_bool.o: ../../include/sys_defs.h
++mail_conf_bool.o: ../../include/vbuf.h
++mail_conf_bool.o: ../../include/vstream.h
++mail_conf_bool.o: ../../include/vstring.h
++mail_conf_bool.o: mail_conf.h
++mail_conf_bool.o: mail_conf_bool.c
++mail_conf_int.o: ../../include/argv.h
++mail_conf_int.o: ../../include/dict.h
++mail_conf_int.o: ../../include/msg.h
++mail_conf_int.o: ../../include/mymalloc.h
++mail_conf_int.o: ../../include/stringops.h
++mail_conf_int.o: ../../include/sys_defs.h
++mail_conf_int.o: ../../include/vbuf.h
++mail_conf_int.o: ../../include/vstream.h
++mail_conf_int.o: ../../include/vstring.h
++mail_conf_int.o: mail_conf.h
++mail_conf_int.o: mail_conf_int.c
++mail_conf_long.o: ../../include/argv.h
++mail_conf_long.o: ../../include/dict.h
++mail_conf_long.o: ../../include/msg.h
++mail_conf_long.o: ../../include/mymalloc.h
++mail_conf_long.o: ../../include/stringops.h
++mail_conf_long.o: ../../include/sys_defs.h
++mail_conf_long.o: ../../include/vbuf.h
++mail_conf_long.o: ../../include/vstream.h
++mail_conf_long.o: ../../include/vstring.h
++mail_conf_long.o: mail_conf.h
++mail_conf_long.o: mail_conf_long.c
++mail_conf_nint.o: ../../include/argv.h
++mail_conf_nint.o: ../../include/dict.h
++mail_conf_nint.o: ../../include/msg.h
++mail_conf_nint.o: ../../include/mymalloc.h
++mail_conf_nint.o: ../../include/stringops.h
++mail_conf_nint.o: ../../include/sys_defs.h
++mail_conf_nint.o: ../../include/vbuf.h
++mail_conf_nint.o: ../../include/vstream.h
++mail_conf_nint.o: ../../include/vstring.h
++mail_conf_nint.o: mail_conf.h
++mail_conf_nint.o: mail_conf_nint.c
++mail_conf_raw.o: ../../include/msg.h
++mail_conf_raw.o: ../../include/mymalloc.h
++mail_conf_raw.o: ../../include/sys_defs.h
++mail_conf_raw.o: mail_conf.h
++mail_conf_raw.o: mail_conf_raw.c
++mail_conf_str.o: ../../include/msg.h
++mail_conf_str.o: ../../include/mymalloc.h
++mail_conf_str.o: ../../include/stringops.h
++mail_conf_str.o: ../../include/sys_defs.h
++mail_conf_str.o: ../../include/vbuf.h
++mail_conf_str.o: ../../include/vstring.h
++mail_conf_str.o: mail_conf.h
++mail_conf_str.o: mail_conf_str.c
++mail_conf_time.o: ../../include/argv.h
++mail_conf_time.o: ../../include/dict.h
++mail_conf_time.o: ../../include/msg.h
++mail_conf_time.o: ../../include/mymalloc.h
++mail_conf_time.o: ../../include/stringops.h
++mail_conf_time.o: ../../include/sys_defs.h
++mail_conf_time.o: ../../include/vbuf.h
++mail_conf_time.o: ../../include/vstream.h
++mail_conf_time.o: ../../include/vstring.h
++mail_conf_time.o: conv_time.h
++mail_conf_time.o: mail_conf.h
++mail_conf_time.o: mail_conf_time.c
++mail_connect.o: ../../include/attr.h
++mail_connect.o: ../../include/connect.h
++mail_connect.o: ../../include/iostuff.h
++mail_connect.o: ../../include/msg.h
++mail_connect.o: ../../include/mymalloc.h
++mail_connect.o: ../../include/stringops.h
++mail_connect.o: ../../include/sys_defs.h
++mail_connect.o: ../../include/vbuf.h
++mail_connect.o: ../../include/vstream.h
++mail_connect.o: ../../include/vstring.h
++mail_connect.o: mail_connect.c
++mail_connect.o: mail_proto.h
++mail_connect.o: timed_ipc.h
++mail_copy.o: ../../include/htable.h
++mail_copy.o: ../../include/iostuff.h
++mail_copy.o: ../../include/msg.h
++mail_copy.o: ../../include/safe_open.h
++mail_copy.o: ../../include/stringops.h
++mail_copy.o: ../../include/sys_defs.h
++mail_copy.o: ../../include/vbuf.h
++mail_copy.o: ../../include/vstream.h
++mail_copy.o: ../../include/vstring.h
++mail_copy.o: ../../include/vstring_vstream.h
++mail_copy.o: dsn.h
++mail_copy.o: dsn_buf.h
++mail_copy.o: mail_addr.h
++mail_copy.o: mail_copy.c
++mail_copy.o: mail_copy.h
++mail_copy.o: mail_params.h
++mail_copy.o: mail_queue.h
++mail_copy.o: mark_corrupt.h
++mail_copy.o: mbox_open.h
++mail_copy.o: quote_822_local.h
++mail_copy.o: quote_flags.h
++mail_copy.o: rec_type.h
++mail_copy.o: record.h
++mail_copy.o: sys_exits.h
++mail_date.o: ../../include/msg.h
++mail_date.o: ../../include/sys_defs.h
++mail_date.o: ../../include/vbuf.h
++mail_date.o: ../../include/vstring.h
++mail_date.o: mail_date.c
++mail_date.o: mail_date.h
++mail_dict.o: ../../include/argv.h
++mail_dict.o: ../../include/dict.h
++mail_dict.o: ../../include/msg.h
++mail_dict.o: ../../include/sys_defs.h
++mail_dict.o: ../../include/vbuf.h
++mail_dict.o: ../../include/vstream.h
++mail_dict.o: ../../include/vstring.h
++mail_dict.o: dict_ldap.h
++mail_dict.o: dict_mysql.h
++mail_dict.o: dict_pgsql.h
++mail_dict.o: dict_proxy.h
++mail_dict.o: mail_dict.c
++mail_dict.o: mail_dict.h
++mail_error.o: ../../include/name_mask.h
++mail_error.o: ../../include/sys_defs.h
++mail_error.o: ../../include/vbuf.h
++mail_error.o: ../../include/vstring.h
++mail_error.o: mail_error.c
++mail_error.o: mail_error.h
++mail_flush.o: ../../include/attr.h
++mail_flush.o: ../../include/iostuff.h
++mail_flush.o: ../../include/sys_defs.h
++mail_flush.o: ../../include/vbuf.h
++mail_flush.o: ../../include/vstream.h
++mail_flush.o: mail_flush.c
++mail_flush.o: mail_flush.h
++mail_flush.o: mail_params.h
++mail_flush.o: mail_proto.h
++mail_open_ok.o: ../../include/msg.h
++mail_open_ok.o: ../../include/sys_defs.h
++mail_open_ok.o: ../../include/vbuf.h
++mail_open_ok.o: ../../include/vstream.h
++mail_open_ok.o: ../../include/vstring.h
++mail_open_ok.o: mail_open_ok.c
++mail_open_ok.o: mail_open_ok.h
++mail_open_ok.o: mail_queue.h
++mail_params.o: ../../include/argv.h
++mail_params.o: ../../include/attr.h
++mail_params.o: ../../include/dict.h
++mail_params.o: ../../include/dict_db.h
++mail_params.o: ../../include/get_hostname.h
++mail_params.o: ../../include/inet_addr_list.h
++mail_params.o: ../../include/inet_proto.h
++mail_params.o: ../../include/iostuff.h
++mail_params.o: ../../include/msg.h
++mail_params.o: ../../include/msg_syslog.h
++mail_params.o: ../../include/myaddrinfo.h
++mail_params.o: ../../include/mymalloc.h
++mail_params.o: ../../include/safe.h
++mail_params.o: ../../include/safe_open.h
++mail_params.o: ../../include/stringops.h
++mail_params.o: ../../include/sys_defs.h
++mail_params.o: ../../include/valid_hostname.h
++mail_params.o: ../../include/vbuf.h
++mail_params.o: ../../include/vstream.h
++mail_params.o: ../../include/vstring.h
++mail_params.o: ../../include/vstring_vstream.h
++mail_params.o: mail_conf.h
++mail_params.o: mail_params.c
++mail_params.o: mail_params.h
++mail_params.o: mail_proto.h
++mail_params.o: mail_version.h
++mail_params.o: mynetworks.h
++mail_params.o: own_inet_addr.h
++mail_params.o: recipient_list.h
++mail_params.o: verp_sender.h
++mail_pathname.o: ../../include/attr.h
++mail_pathname.o: ../../include/iostuff.h
++mail_pathname.o: ../../include/stringops.h
++mail_pathname.o: ../../include/sys_defs.h
++mail_pathname.o: ../../include/vbuf.h
++mail_pathname.o: ../../include/vstream.h
++mail_pathname.o: ../../include/vstring.h
++mail_pathname.o: mail_pathname.c
++mail_pathname.o: mail_proto.h
++mail_queue.o: ../../include/argv.h
++mail_queue.o: ../../include/dir_forest.h
++mail_queue.o: ../../include/make_dirs.h
++mail_queue.o: ../../include/msg.h
++mail_queue.o: ../../include/mymalloc.h
++mail_queue.o: ../../include/sane_fsops.h
++mail_queue.o: ../../include/split_at.h
++mail_queue.o: ../../include/sys_defs.h
++mail_queue.o: ../../include/valid_hostname.h
++mail_queue.o: ../../include/vbuf.h
++mail_queue.o: ../../include/vstream.h
++mail_queue.o: ../../include/vstring.h
++mail_queue.o: file_id.h
++mail_queue.o: mail_params.h
++mail_queue.o: mail_queue.c
++mail_queue.o: mail_queue.h
++mail_run.o: ../../include/msg.h
++mail_run.o: ../../include/mymalloc.h
++mail_run.o: ../../include/stringops.h
++mail_run.o: ../../include/sys_defs.h
++mail_run.o: ../../include/vbuf.h
++mail_run.o: ../../include/vstring.h
++mail_run.o: mail_params.h
++mail_run.o: mail_run.c
++mail_run.o: mail_run.h
++mail_scan_dir.o: ../../include/scan_dir.h
++mail_scan_dir.o: ../../include/sys_defs.h
++mail_scan_dir.o: mail_scan_dir.c
++mail_scan_dir.o: mail_scan_dir.h
++mail_stream.o: ../../include/argv.h
++mail_stream.o: ../../include/attr.h
++mail_stream.o: ../../include/iostuff.h
++mail_stream.o: ../../include/msg.h
++mail_stream.o: ../../include/mymalloc.h
++mail_stream.o: ../../include/sane_fsops.h
++mail_stream.o: ../../include/stringops.h
++mail_stream.o: ../../include/sys_defs.h
++mail_stream.o: ../../include/vbuf.h
++mail_stream.o: ../../include/vstream.h
++mail_stream.o: ../../include/vstring.h
++mail_stream.o: cleanup_user.h
++mail_stream.o: mail_params.h
++mail_stream.o: mail_proto.h
++mail_stream.o: mail_queue.h
++mail_stream.o: mail_stream.c
++mail_stream.o: mail_stream.h
++mail_stream.o: opened.h
++mail_task.o: ../../include/safe.h
++mail_task.o: ../../include/sys_defs.h
++mail_task.o: ../../include/vbuf.h
++mail_task.o: ../../include/vstring.h
++mail_task.o: mail_conf.h
++mail_task.o: mail_params.h
++mail_task.o: mail_task.c
++mail_task.o: mail_task.h
++mail_trigger.o: ../../include/attr.h
++mail_trigger.o: ../../include/iostuff.h
++mail_trigger.o: ../../include/msg.h
++mail_trigger.o: ../../include/mymalloc.h
++mail_trigger.o: ../../include/sys_defs.h
++mail_trigger.o: ../../include/trigger.h
++mail_trigger.o: ../../include/vbuf.h
++mail_trigger.o: ../../include/vstream.h
++mail_trigger.o: mail_params.h
++mail_trigger.o: mail_proto.h
++mail_trigger.o: mail_trigger.c
++mail_version.o: mail_version.c
++maps.o: ../../include/argv.h
++maps.o: ../../include/dict.h
++maps.o: ../../include/msg.h
++maps.o: ../../include/mymalloc.h
++maps.o: ../../include/split_at.h
++maps.o: ../../include/stringops.h
++maps.o: ../../include/sys_defs.h
++maps.o: ../../include/vbuf.h
++maps.o: ../../include/vstream.h
++maps.o: ../../include/vstring.h
++maps.o: mail_conf.h
++maps.o: maps.c
++maps.o: maps.h
++mark_corrupt.o: ../../include/attr.h
++mark_corrupt.o: ../../include/msg.h
++mark_corrupt.o: ../../include/set_eugid.h
++mark_corrupt.o: ../../include/sys_defs.h
++mark_corrupt.o: ../../include/vbuf.h
++mark_corrupt.o: ../../include/vstream.h
++mark_corrupt.o: ../../include/vstring.h
++mark_corrupt.o: deliver_request.h
++mark_corrupt.o: dsn.h
++mark_corrupt.o: mail_params.h
++mark_corrupt.o: mail_queue.h
++mark_corrupt.o: mark_corrupt.c
++mark_corrupt.o: mark_corrupt.h
++mark_corrupt.o: msg_stats.h
++mark_corrupt.o: recipient_list.h
++match_parent_style.o: ../../include/match_list.h
++match_parent_style.o: ../../include/match_ops.h
++match_parent_style.o: ../../include/sys_defs.h
++match_parent_style.o: mail_params.h
++match_parent_style.o: match_parent_style.c
++match_parent_style.o: match_parent_style.h
++match_parent_style.o: string_list.h
++match_service.o: ../../include/argv.h
++match_service.o: ../../include/msg.h
++match_service.o: ../../include/mymalloc.h
++match_service.o: ../../include/stringops.h
++match_service.o: ../../include/sys_defs.h
++match_service.o: ../../include/vbuf.h
++match_service.o: ../../include/vstring.h
++match_service.o: match_service.c
++match_service.o: match_service.h
++mbox_conf.o: ../../include/argv.h
++mbox_conf.o: ../../include/name_mask.h
++mbox_conf.o: ../../include/sys_defs.h
++mbox_conf.o: ../../include/vbuf.h
++mbox_conf.o: ../../include/vstring.h
++mbox_conf.o: mail_params.h
++mbox_conf.o: mbox_conf.c
++mbox_conf.o: mbox_conf.h
++mbox_open.o: ../../include/argv.h
++mbox_open.o: ../../include/iostuff.h
++mbox_open.o: ../../include/msg.h
++mbox_open.o: ../../include/myflock.h
++mbox_open.o: ../../include/mymalloc.h
++mbox_open.o: ../../include/safe_open.h
++mbox_open.o: ../../include/sys_defs.h
++mbox_open.o: ../../include/vbuf.h
++mbox_open.o: ../../include/vstream.h
++mbox_open.o: ../../include/vstring.h
++mbox_open.o: deliver_flock.h
++mbox_open.o: dot_lockfile.h
++mbox_open.o: dsn.h
++mbox_open.o: dsn_buf.h
++mbox_open.o: mbox_conf.h
++mbox_open.o: mbox_open.c
++mbox_open.o: mbox_open.h
++mime_state.o: ../../include/msg.h
++mime_state.o: ../../include/mymalloc.h
++mime_state.o: ../../include/sys_defs.h
++mime_state.o: ../../include/vbuf.h
++mime_state.o: ../../include/vstring.h
++mime_state.o: header_opts.h
++mime_state.o: header_token.h
++mime_state.o: is_header.h
++mime_state.o: lex_822.h
++mime_state.o: mail_params.h
++mime_state.o: mime_state.c
++mime_state.o: mime_state.h
++mime_state.o: rec_type.h
++mkmap_cdb.o: ../../include/argv.h
++mkmap_cdb.o: ../../include/dict.h
++mkmap_cdb.o: ../../include/dict_cdb.h
++mkmap_cdb.o: ../../include/mymalloc.h
++mkmap_cdb.o: ../../include/sys_defs.h
++mkmap_cdb.o: ../../include/vbuf.h
++mkmap_cdb.o: ../../include/vstream.h
++mkmap_cdb.o: ../../include/vstring.h
++mkmap_cdb.o: mkmap.h
++mkmap_cdb.o: mkmap_cdb.c
++mkmap_db.o: ../../include/argv.h
++mkmap_db.o: ../../include/dict.h
++mkmap_db.o: ../../include/dict_db.h
++mkmap_db.o: ../../include/msg.h
++mkmap_db.o: ../../include/myflock.h
++mkmap_db.o: ../../include/mymalloc.h
++mkmap_db.o: ../../include/stringops.h
++mkmap_db.o: ../../include/sys_defs.h
++mkmap_db.o: ../../include/vbuf.h
++mkmap_db.o: ../../include/vstream.h
++mkmap_db.o: ../../include/vstring.h
++mkmap_db.o: mail_params.h
++mkmap_db.o: mkmap.h
++mkmap_db.o: mkmap_db.c
++mkmap_dbm.o: ../../include/argv.h
++mkmap_dbm.o: ../../include/dict.h
++mkmap_dbm.o: ../../include/dict_dbm.h
++mkmap_dbm.o: ../../include/msg.h
++mkmap_dbm.o: ../../include/myflock.h
++mkmap_dbm.o: ../../include/mymalloc.h
++mkmap_dbm.o: ../../include/stringops.h
++mkmap_dbm.o: ../../include/sys_defs.h
++mkmap_dbm.o: ../../include/vbuf.h
++mkmap_dbm.o: ../../include/vstream.h
++mkmap_dbm.o: ../../include/vstring.h
++mkmap_dbm.o: mkmap.h
++mkmap_dbm.o: mkmap_dbm.c
++mkmap_open.o: ../../include/argv.h
++mkmap_open.o: ../../include/dict.h
++mkmap_open.o: ../../include/dict_cdb.h
++mkmap_open.o: ../../include/dict_db.h
++mkmap_open.o: ../../include/dict_dbm.h
++mkmap_open.o: ../../include/dict_sdbm.h
++mkmap_open.o: ../../include/msg.h
++mkmap_open.o: ../../include/mymalloc.h
++mkmap_open.o: ../../include/sigdelay.h
++mkmap_open.o: ../../include/sys_defs.h
++mkmap_open.o: ../../include/vbuf.h
++mkmap_open.o: ../../include/vstream.h
++mkmap_open.o: ../../include/vstring.h
++mkmap_open.o: dict_proxy.h
++mkmap_open.o: mkmap.h
++mkmap_open.o: mkmap_open.c
++mkmap_proxy.o: ../../include/argv.h
++mkmap_proxy.o: ../../include/dict.h
++mkmap_proxy.o: ../../include/mymalloc.h
++mkmap_proxy.o: ../../include/sys_defs.h
++mkmap_proxy.o: ../../include/vbuf.h
++mkmap_proxy.o: ../../include/vstream.h
++mkmap_proxy.o: ../../include/vstring.h
++mkmap_proxy.o: dict_proxy.h
++mkmap_proxy.o: mkmap.h
++mkmap_proxy.o: mkmap_proxy.c
++mkmap_sdbm.o: ../../include/argv.h
++mkmap_sdbm.o: ../../include/dict.h
++mkmap_sdbm.o: ../../include/dict_sdbm.h
++mkmap_sdbm.o: ../../include/msg.h
++mkmap_sdbm.o: ../../include/myflock.h
++mkmap_sdbm.o: ../../include/mymalloc.h
++mkmap_sdbm.o: ../../include/stringops.h
++mkmap_sdbm.o: ../../include/sys_defs.h
++mkmap_sdbm.o: ../../include/vbuf.h
++mkmap_sdbm.o: ../../include/vstream.h
++mkmap_sdbm.o: ../../include/vstring.h
++mkmap_sdbm.o: mkmap.h
++mkmap_sdbm.o: mkmap_sdbm.c
++msg_stats_print.o: ../../include/attr.h
++msg_stats_print.o: ../../include/iostuff.h
++msg_stats_print.o: ../../include/sys_defs.h
++msg_stats_print.o: ../../include/vbuf.h
++msg_stats_print.o: ../../include/vstream.h
++msg_stats_print.o: mail_proto.h
++msg_stats_print.o: msg_stats.h
++msg_stats_print.o: msg_stats_print.c
++msg_stats_scan.o: ../../include/attr.h
++msg_stats_scan.o: ../../include/iostuff.h
++msg_stats_scan.o: ../../include/msg.h
++msg_stats_scan.o: ../../include/sys_defs.h
++msg_stats_scan.o: ../../include/vbuf.h
++msg_stats_scan.o: ../../include/vstream.h
++msg_stats_scan.o: ../../include/vstring.h
++msg_stats_scan.o: mail_proto.h
++msg_stats_scan.o: msg_stats.h
++msg_stats_scan.o: msg_stats_scan.c
++mynetworks.o: ../../include/argv.h
++mynetworks.o: ../../include/inet_addr_list.h
++mynetworks.o: ../../include/mask_addr.h
++mynetworks.o: ../../include/msg.h
++mynetworks.o: ../../include/myaddrinfo.h
++mynetworks.o: ../../include/name_mask.h
++mynetworks.o: ../../include/sock_addr.h
++mynetworks.o: ../../include/sys_defs.h
++mynetworks.o: ../../include/vbuf.h
++mynetworks.o: ../../include/vstring.h
++mynetworks.o: been_here.h
++mynetworks.o: mail_params.h
++mynetworks.o: mynetworks.c
++mynetworks.o: mynetworks.h
++mynetworks.o: own_inet_addr.h
++mypwd.o: ../../include/binhash.h
++mypwd.o: ../../include/htable.h
++mypwd.o: ../../include/msg.h
++mypwd.o: ../../include/mymalloc.h
++mypwd.o: ../../include/sys_defs.h
++mypwd.o: mypwd.c
++mypwd.o: mypwd.h
++namadr_list.o: ../../include/match_list.h
++namadr_list.o: ../../include/match_ops.h
++namadr_list.o: ../../include/sys_defs.h
++namadr_list.o: namadr_list.c
++namadr_list.o: namadr_list.h
++off_cvt.o: ../../include/msg.h
++off_cvt.o: ../../include/sys_defs.h
++off_cvt.o: ../../include/vbuf.h
++off_cvt.o: ../../include/vstring.h
++off_cvt.o: off_cvt.c
++off_cvt.o: off_cvt.h
++opened.o: ../../include/msg.h
++opened.o: ../../include/sys_defs.h
++opened.o: ../../include/vbuf.h
++opened.o: ../../include/vstring.h
++opened.o: opened.c
++opened.o: opened.h
++own_inet_addr.o: ../../include/inet_addr_host.h
++own_inet_addr.o: ../../include/inet_addr_list.h
++own_inet_addr.o: ../../include/inet_addr_local.h
++own_inet_addr.o: ../../include/inet_proto.h
++own_inet_addr.o: ../../include/msg.h
++own_inet_addr.o: ../../include/myaddrinfo.h
++own_inet_addr.o: ../../include/mymalloc.h
++own_inet_addr.o: ../../include/sock_addr.h
++own_inet_addr.o: ../../include/stringops.h
++own_inet_addr.o: ../../include/sys_defs.h
++own_inet_addr.o: ../../include/vbuf.h
++own_inet_addr.o: ../../include/vstring.h
++own_inet_addr.o: mail_params.h
++own_inet_addr.o: own_inet_addr.c
++own_inet_addr.o: own_inet_addr.h
++pipe_command.o: ../../include/argv.h
++pipe_command.o: ../../include/chroot_uid.h
++pipe_command.o: ../../include/clean_env.h
++pipe_command.o: ../../include/exec_command.h
++pipe_command.o: ../../include/iostuff.h
++pipe_command.o: ../../include/msg.h
++pipe_command.o: ../../include/msg_vstream.h
++pipe_command.o: ../../include/set_eugid.h
++pipe_command.o: ../../include/set_ugid.h
++pipe_command.o: ../../include/stringops.h
++pipe_command.o: ../../include/sys_defs.h
++pipe_command.o: ../../include/timed_wait.h
++pipe_command.o: ../../include/vbuf.h
++pipe_command.o: ../../include/vstream.h
++pipe_command.o: ../../include/vstring.h
++pipe_command.o: dsn.h
++pipe_command.o: dsn_buf.h
++pipe_command.o: dsn_util.h
++pipe_command.o: mail_copy.h
++pipe_command.o: mail_params.h
++pipe_command.o: pipe_command.c
++pipe_command.o: pipe_command.h
++pipe_command.o: sys_exits.h
++post_mail.o: ../../include/attr.h
++post_mail.o: ../../include/events.h
++post_mail.o: ../../include/iostuff.h
++post_mail.o: ../../include/msg.h
++post_mail.o: ../../include/mymalloc.h
++post_mail.o: ../../include/sys_defs.h
++post_mail.o: ../../include/vbuf.h
++post_mail.o: ../../include/vstream.h
++post_mail.o: ../../include/vstring.h
++post_mail.o: cleanup_user.h
++post_mail.o: int_filt.h
++post_mail.o: mail_date.h
++post_mail.o: mail_params.h
++post_mail.o: mail_proto.h
++post_mail.o: post_mail.c
++post_mail.o: post_mail.h
++post_mail.o: rec_type.h
++post_mail.o: record.h
++quote_821_local.o: ../../include/sys_defs.h
++quote_821_local.o: ../../include/vbuf.h
++quote_821_local.o: ../../include/vstring.h
++quote_821_local.o: quote_821_local.c
++quote_821_local.o: quote_821_local.h
++quote_821_local.o: quote_flags.h
++quote_822_local.o: ../../include/sys_defs.h
++quote_822_local.o: ../../include/vbuf.h
++quote_822_local.o: ../../include/vstring.h
++quote_822_local.o: quote_822_local.c
++quote_822_local.o: quote_822_local.h
++quote_822_local.o: quote_flags.h
++rcpt_buf.o: ../../include/attr.h
++rcpt_buf.o: ../../include/iostuff.h
++rcpt_buf.o: ../../include/mymalloc.h
++rcpt_buf.o: ../../include/sys_defs.h
++rcpt_buf.o: ../../include/vbuf.h
++rcpt_buf.o: ../../include/vstream.h
++rcpt_buf.o: ../../include/vstring.h
++rcpt_buf.o: mail_proto.h
++rcpt_buf.o: rcpt_buf.c
++rcpt_buf.o: rcpt_buf.h
++rcpt_buf.o: recipient_list.h
++rcpt_print.o: ../../include/attr.h
++rcpt_print.o: ../../include/iostuff.h
++rcpt_print.o: ../../include/sys_defs.h
++rcpt_print.o: ../../include/vbuf.h
++rcpt_print.o: ../../include/vstream.h
++rcpt_print.o: mail_proto.h
++rcpt_print.o: rcpt_print.c
++rcpt_print.o: rcpt_print.h
++rcpt_print.o: recipient_list.h
++rec2stream.o: ../../include/sys_defs.h
++rec2stream.o: ../../include/vbuf.h
++rec2stream.o: ../../include/vstream.h
++rec2stream.o: ../../include/vstring.h
++rec2stream.o: rec2stream.c
++rec2stream.o: rec_streamlf.h
++rec2stream.o: rec_type.h
++rec2stream.o: record.h
++rec_attr_map.o: ../../include/attr.h
++rec_attr_map.o: ../../include/iostuff.h
++rec_attr_map.o: ../../include/sys_defs.h
++rec_attr_map.o: ../../include/vbuf.h
++rec_attr_map.o: ../../include/vstream.h
++rec_attr_map.o: mail_proto.h
++rec_attr_map.o: rec_attr_map.c
++rec_attr_map.o: rec_attr_map.h
++rec_attr_map.o: rec_type.h
++rec_streamlf.o: ../../include/sys_defs.h
++rec_streamlf.o: ../../include/vbuf.h
++rec_streamlf.o: ../../include/vstream.h
++rec_streamlf.o: ../../include/vstring.h
++rec_streamlf.o: rec_streamlf.c
++rec_streamlf.o: rec_streamlf.h
++rec_streamlf.o: rec_type.h
++rec_streamlf.o: record.h
++rec_type.o: rec_type.c
++rec_type.o: rec_type.h
++recdump.o: ../../include/msg_vstream.h
++recdump.o: ../../include/sys_defs.h
++recdump.o: ../../include/vbuf.h
++recdump.o: ../../include/vstream.h
++recdump.o: ../../include/vstring.h
++recdump.o: rec_streamlf.h
++recdump.o: rec_type.h
++recdump.o: recdump.c
++recdump.o: record.h
++recipient_list.o: ../../include/msg.h
++recipient_list.o: ../../include/mymalloc.h
++recipient_list.o: ../../include/sys_defs.h
++recipient_list.o: recipient_list.c
++recipient_list.o: recipient_list.h
++record.o: ../../include/msg.h
++record.o: ../../include/mymalloc.h
++record.o: ../../include/stringops.h
++record.o: ../../include/sys_defs.h
++record.o: ../../include/vbuf.h
++record.o: ../../include/vstream.h
++record.o: ../../include/vstring.h
++record.o: off_cvt.h
++record.o: rec_type.h
++record.o: record.c
++record.o: record.h
++remove.o: ../../include/sys_defs.h
++remove.o: ../../include/vbuf.h
++remove.o: ../../include/vstring.h
++remove.o: mail_params.h
++remove.o: remove.c
++resolve_clnt.o: ../../include/attr.h
++resolve_clnt.o: ../../include/events.h
++resolve_clnt.o: ../../include/iostuff.h
++resolve_clnt.o: ../../include/msg.h
++resolve_clnt.o: ../../include/sys_defs.h
++resolve_clnt.o: ../../include/vbuf.h
++resolve_clnt.o: ../../include/vstream.h
++resolve_clnt.o: ../../include/vstring.h
++resolve_clnt.o: ../../include/vstring_vstream.h
++resolve_clnt.o: clnt_stream.h
++resolve_clnt.o: mail_params.h
++resolve_clnt.o: mail_proto.h
++resolve_clnt.o: resolve_clnt.c
++resolve_clnt.o: resolve_clnt.h
++resolve_local.o: ../../include/inet_addr_list.h
++resolve_local.o: ../../include/match_list.h
++resolve_local.o: ../../include/match_ops.h
++resolve_local.o: ../../include/msg.h
++resolve_local.o: ../../include/myaddrinfo.h
++resolve_local.o: ../../include/mymalloc.h
++resolve_local.o: ../../include/sys_defs.h
++resolve_local.o: ../../include/valid_hostname.h
++resolve_local.o: mail_params.h
++resolve_local.o: own_inet_addr.h
++resolve_local.o: resolve_local.c
++resolve_local.o: resolve_local.h
++resolve_local.o: string_list.h
++resolve_local.o: valid_mailhost_addr.h
++rewrite_clnt.o: ../../include/attr.h
++rewrite_clnt.o: ../../include/events.h
++rewrite_clnt.o: ../../include/iostuff.h
++rewrite_clnt.o: ../../include/msg.h
++rewrite_clnt.o: ../../include/sys_defs.h
++rewrite_clnt.o: ../../include/vbuf.h
++rewrite_clnt.o: ../../include/vstream.h
++rewrite_clnt.o: ../../include/vstring.h
++rewrite_clnt.o: ../../include/vstring_vstream.h
++rewrite_clnt.o: clnt_stream.h
++rewrite_clnt.o: mail_params.h
++rewrite_clnt.o: mail_proto.h
++rewrite_clnt.o: quote_822_local.h
++rewrite_clnt.o: quote_flags.h
++rewrite_clnt.o: rewrite_clnt.c
++rewrite_clnt.o: rewrite_clnt.h
++scache.o: ../../include/argv.h
++scache.o: ../../include/events.h
++scache.o: ../../include/msg.h
++scache.o: ../../include/sys_defs.h
++scache.o: ../../include/vbuf.h
++scache.o: ../../include/vstream.h
++scache.o: ../../include/vstring.h
++scache.o: ../../include/vstring_vstream.h
++scache.o: scache.c
++scache.o: scache.h
++scache_clnt.o: ../../include/attr.h
++scache_clnt.o: ../../include/auto_clnt.h
++scache_clnt.o: ../../include/iostuff.h
++scache_clnt.o: ../../include/msg.h
++scache_clnt.o: ../../include/mymalloc.h
++scache_clnt.o: ../../include/stringops.h
++scache_clnt.o: ../../include/sys_defs.h
++scache_clnt.o: ../../include/vbuf.h
++scache_clnt.o: ../../include/vstream.h
++scache_clnt.o: ../../include/vstring.h
++scache_clnt.o: mail_params.h
++scache_clnt.o: mail_proto.h
++scache_clnt.o: scache.h
++scache_clnt.o: scache_clnt.c
++scache_multi.o: ../../include/events.h
++scache_multi.o: ../../include/htable.h
++scache_multi.o: ../../include/msg.h
++scache_multi.o: ../../include/mymalloc.h
++scache_multi.o: ../../include/ring.h
++scache_multi.o: ../../include/sys_defs.h
++scache_multi.o: ../../include/vbuf.h
++scache_multi.o: ../../include/vstring.h
++scache_multi.o: scache.h
++scache_multi.o: scache_multi.c
++scache_single.o: ../../include/events.h
++scache_single.o: ../../include/msg.h
++scache_single.o: ../../include/mymalloc.h
++scache_single.o: ../../include/sys_defs.h
++scache_single.o: ../../include/vbuf.h
++scache_single.o: ../../include/vstring.h
++scache_single.o: scache.h
++scache_single.o: scache_single.c
++sent.o: ../../include/attr.h
++sent.o: ../../include/msg.h
++sent.o: ../../include/sys_defs.h
++sent.o: ../../include/vbuf.h
++sent.o: ../../include/vstream.h
++sent.o: ../../include/vstring.h
++sent.o: bounce.h
++sent.o: defer.h
++sent.o: deliver_request.h
++sent.o: dsn.h
++sent.o: dsn_buf.h
++sent.o: dsn_mask.h
++sent.o: dsn_util.h
++sent.o: log_adhoc.h
++sent.o: mail_params.h
++sent.o: msg_stats.h
++sent.o: recipient_list.h
++sent.o: sent.c
++sent.o: sent.h
++sent.o: trace.h
++sent.o: verify.h
++smtp_stream.o: ../../include/iostuff.h
++smtp_stream.o: ../../include/msg.h
++smtp_stream.o: ../../include/sys_defs.h
++smtp_stream.o: ../../include/vbuf.h
++smtp_stream.o: ../../include/vstream.h
++smtp_stream.o: ../../include/vstring.h
++smtp_stream.o: ../../include/vstring_vstream.h
++smtp_stream.o: smtp_stream.c
++smtp_stream.o: smtp_stream.h
++split_addr.o: ../../include/split_at.h
++split_addr.o: ../../include/sys_defs.h
++split_addr.o: mail_addr.h
++split_addr.o: mail_params.h
++split_addr.o: split_addr.c
++split_addr.o: split_addr.h
++stream2rec.o: ../../include/sys_defs.h
++stream2rec.o: ../../include/vbuf.h
++stream2rec.o: ../../include/vstream.h
++stream2rec.o: ../../include/vstring.h
++stream2rec.o: rec_streamlf.h
++stream2rec.o: rec_type.h
++stream2rec.o: record.h
++stream2rec.o: stream2rec.c
++string_list.o: ../../include/match_list.h
++string_list.o: ../../include/match_ops.h
++string_list.o: ../../include/sys_defs.h
++string_list.o: string_list.c
++string_list.o: string_list.h
++strip_addr.o: ../../include/mymalloc.h
++strip_addr.o: ../../include/sys_defs.h
++strip_addr.o: split_addr.h
++strip_addr.o: strip_addr.c
++strip_addr.o: strip_addr.h
++sys_exits.o: ../../include/msg.h
++sys_exits.o: ../../include/sys_defs.h
++sys_exits.o: ../../include/vbuf.h
++sys_exits.o: ../../include/vstring.h
++sys_exits.o: sys_exits.c
++sys_exits.o: sys_exits.h
++timed_ipc.o: ../../include/msg.h
++timed_ipc.o: ../../include/sys_defs.h
++timed_ipc.o: ../../include/vbuf.h
++timed_ipc.o: ../../include/vstream.h
++timed_ipc.o: mail_params.h
++timed_ipc.o: timed_ipc.c
++timed_ipc.o: timed_ipc.h
++tok822_find.o: ../../include/sys_defs.h
++tok822_find.o: ../../include/vbuf.h
++tok822_find.o: ../../include/vstring.h
++tok822_find.o: resolve_clnt.h
++tok822_find.o: tok822.h
++tok822_find.o: tok822_find.c
++tok822_node.o: ../../include/mymalloc.h
++tok822_node.o: ../../include/sys_defs.h
++tok822_node.o: ../../include/vbuf.h
++tok822_node.o: ../../include/vstring.h
++tok822_node.o: resolve_clnt.h
++tok822_node.o: tok822.h
++tok822_node.o: tok822_node.c
++tok822_parse.o: ../../include/msg.h
++tok822_parse.o: ../../include/stringops.h
++tok822_parse.o: ../../include/sys_defs.h
++tok822_parse.o: ../../include/vbuf.h
++tok822_parse.o: ../../include/vstring.h
++tok822_parse.o: lex_822.h
++tok822_parse.o: quote_822_local.h
++tok822_parse.o: quote_flags.h
++tok822_parse.o: resolve_clnt.h
++tok822_parse.o: tok822.h
++tok822_parse.o: tok822_parse.c
++tok822_resolve.o: ../../include/msg.h
++tok822_resolve.o: ../../include/sys_defs.h
++tok822_resolve.o: ../../include/vbuf.h
++tok822_resolve.o: ../../include/vstring.h
++tok822_resolve.o: resolve_clnt.h
++tok822_resolve.o: tok822.h
++tok822_resolve.o: tok822_resolve.c
++tok822_rewrite.o: ../../include/attr.h
++tok822_rewrite.o: ../../include/iostuff.h
++tok822_rewrite.o: ../../include/msg.h
++tok822_rewrite.o: ../../include/sys_defs.h
++tok822_rewrite.o: ../../include/vbuf.h
++tok822_rewrite.o: ../../include/vstream.h
++tok822_rewrite.o: ../../include/vstring.h
++tok822_rewrite.o: mail_proto.h
++tok822_rewrite.o: resolve_clnt.h
++tok822_rewrite.o: rewrite_clnt.h
++tok822_rewrite.o: tok822.h
++tok822_rewrite.o: tok822_rewrite.c
++tok822_tree.o: ../../include/mymalloc.h
++tok822_tree.o: ../../include/sys_defs.h
++tok822_tree.o: ../../include/vbuf.h
++tok822_tree.o: ../../include/vstring.h
++tok822_tree.o: resolve_clnt.h
++tok822_tree.o: tok822.h
++tok822_tree.o: tok822_tree.c
++trace.o: ../../include/attr.h
++trace.o: ../../include/iostuff.h
++trace.o: ../../include/msg.h
++trace.o: ../../include/sys_defs.h
++trace.o: ../../include/vbuf.h
++trace.o: ../../include/vstream.h
++trace.o: ../../include/vstring.h
++trace.o: bounce.h
++trace.o: deliver_request.h
++trace.o: dsn.h
++trace.o: dsn_buf.h
++trace.o: dsn_print.h
++trace.o: log_adhoc.h
++trace.o: mail_params.h
++trace.o: mail_proto.h
++trace.o: msg_stats.h
++trace.o: rcpt_print.h
++trace.o: recipient_list.h
++trace.o: trace.c
++trace.o: trace.h
++user_acl.o: ../../include/match_list.h
++user_acl.o: ../../include/match_ops.h
++user_acl.o: ../../include/sys_defs.h
++user_acl.o: ../../include/vbuf.h
++user_acl.o: ../../include/vstring.h
++user_acl.o: mail_params.h
++user_acl.o: mypwd.h
++user_acl.o: string_list.h
++user_acl.o: user_acl.c
++user_acl.o: user_acl.h
++valid_mailhost_addr.o: ../../include/msg.h
++valid_mailhost_addr.o: ../../include/myaddrinfo.h
++valid_mailhost_addr.o: ../../include/sys_defs.h
++valid_mailhost_addr.o: ../../include/valid_hostname.h
++valid_mailhost_addr.o: valid_mailhost_addr.c
++valid_mailhost_addr.o: valid_mailhost_addr.h
++verify.o: ../../include/attr.h
++verify.o: ../../include/iostuff.h
++verify.o: ../../include/msg.h
++verify.o: ../../include/sys_defs.h
++verify.o: ../../include/vbuf.h
++verify.o: ../../include/vstream.h
++verify.o: ../../include/vstring.h
++verify.o: deliver_request.h
++verify.o: dsn.h
++verify.o: log_adhoc.h
++verify.o: mail_params.h
++verify.o: mail_proto.h
++verify.o: msg_stats.h
++verify.o: recipient_list.h
++verify.o: verify.c
++verify.o: verify.h
++verify.o: verify_clnt.h
++verify_clnt.o: ../../include/attr.h
++verify_clnt.o: ../../include/iostuff.h
++verify_clnt.o: ../../include/msg.h
++verify_clnt.o: ../../include/sys_defs.h
++verify_clnt.o: ../../include/vbuf.h
++verify_clnt.o: ../../include/vstream.h
++verify_clnt.o: ../../include/vstring.h
++verify_clnt.o: clnt_stream.h
++verify_clnt.o: deliver_request.h
++verify_clnt.o: dsn.h
++verify_clnt.o: mail_params.h
++verify_clnt.o: mail_proto.h
++verify_clnt.o: msg_stats.h
++verify_clnt.o: recipient_list.h
++verify_clnt.o: verify_clnt.c
++verify_clnt.o: verify_clnt.h
++verp_sender.o: ../../include/sys_defs.h
++verp_sender.o: ../../include/vbuf.h
++verp_sender.o: ../../include/vstring.h
++verp_sender.o: mail_params.h
++verp_sender.o: recipient_list.h
++verp_sender.o: verp_sender.c
++verp_sender.o: verp_sender.h
++wildcard_inet_addr.o: ../../include/inet_addr_host.h
++wildcard_inet_addr.o: ../../include/inet_addr_list.h
++wildcard_inet_addr.o: ../../include/msg.h
++wildcard_inet_addr.o: ../../include/myaddrinfo.h
++wildcard_inet_addr.o: ../../include/sys_defs.h
++wildcard_inet_addr.o: wildcard_inet_addr.c
++wildcard_inet_addr.o: wildcard_inet_addr.h
++xtext.o: ../../include/msg.h
++xtext.o: ../../include/sys_defs.h
++xtext.o: ../../include/vbuf.h
++xtext.o: ../../include/vstring.h
++xtext.o: xtext.c
++xtext.o: xtext.h
+diff -ruN a/src/global/mail_conf.c b/src/global/mail_conf.c
+--- a/src/global/mail_conf.c 2009-06-01 12:27:43.000000000 +0000
++++ b/src/global/mail_conf.c 2009-06-01 13:08:26.000000000 +0000
+@@ -182,6 +182,13 @@
+ path = concatenate(var_config_dir, "/", "main.cf", (char *) 0);
+ dict_load_file(CONFIG_DICT, path);
+ myfree(path);
++
++#ifndef NO_DYNAMIC_MAPS
++ path = concatenate(var_config_dir, "/", "dynamicmaps.cf", (char *) 0);
++ dict_open_dlinfo(path);
++ myfree(path);
++#endif
++
+ }
+
+ /* mail_conf_flush - discard configuration dictionary */
+diff -ruN a/src/global/mail_conf.c.orig b/src/global/mail_conf.c.orig
+--- a/src/global/mail_conf.c.orig 1970-01-01 00:00:00.000000000 +0000
++++ b/src/global/mail_conf.c.orig 2009-06-01 13:07:56.000000000 +0000
+@@ -0,0 +1,229 @@
++/*++
++/* NAME
++/* mail_conf 3
++/* SUMMARY
++/* global configuration parameter management
++/* SYNOPSIS
++/* #include <mail_conf.h>
++/*
++/* void mail_conf_read()
++/*
++/* void mail_conf_suck()
++/*
++/* void mail_conf_flush()
++/*
++/* void mail_conf_update(name, value)
++/* const char *name;
++/* const char *value;
++/*
++/* const char *mail_conf_lookup(name)
++/* const char *name;
++/*
++/* const char *mail_conf_eval(string)
++/* const char *string;
++/*
++/* const char *mail_conf_lookup_eval(name)
++/* const char *name;
++/* DESCRIPTION
++/* mail_conf_suck() reads the global Postfix configuration file, and
++/* stores its values into a global configuration dictionary.
++/*
++/* mail_conf_read() invokes mail_conf_suck() and assigns the values
++/* to global variables by calling mail_params_init().
++/*
++/* mail_conf_flush() discards the global configuration dictionary.
++/* This is needed in programs that read main.cf multiple times, to
++/* ensure that deleted parameter settings are handled properly.
++/*
++/* The following routines are wrappers around the generic dictionary
++/* access routines.
++/*
++/* mail_conf_update() updates the named global parameter. This has
++/* no effect on parameters whose value has already been looked up.
++/* The update succeeds or the program terminates with fatal error.
++/*
++/* mail_conf_lookup() looks up the value of the named parameter.
++/* A null pointer result means the parameter was not found.
++/* The result is volatile and should be copied if it is to be
++/* used for any appreciable amount of time.
++/*
++/* mail_conf_eval() recursively expands any $parameters in the
++/* string argument. The result is volatile and should be copied
++/* if it is to be used for any appreciable amount of time.
++/*
++/* mail_conf_lookup_eval() looks up the named parameter, and expands any
++/* $parameters in the result. The result is volatile and should be
++/* copied if it is to be used for any appreciable amount of time.
++/* DIAGNOSTICS
++/* Fatal errors: malformed numerical value.
++/* ENVIRONMENT
++/* MAIL_CONFIG, non-default configuration database
++/* MAIL_VERBOSE, enable verbose mode
++/* FILES
++/* /etc/postfix: default Postfix configuration directory.
++/* SEE ALSO
++/* dict(3) generic dictionary manager
++/* mail_conf_int(3) integer-valued parameters
++/* mail_conf_str(3) string-valued parameters
++/* LICENSE
++/* .ad
++/* .fi
++/* The Secure Mailer license must be distributed with this software.
++/* AUTHOR(S)
++/* Wietse Venema
++/* IBM T.J. Watson Research
++/* P.O. Box 704
++/* Yorktown Heights, NY 10598, USA
++/*--*/
++
++/* System library. */
++
++#include <sys_defs.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++
++/* Utility library. */
++
++#include <msg.h>
++#include <mymalloc.h>
++#include <vstream.h>
++#include <vstring.h>
++#include <dict.h>
++#include <safe.h>
++#include <stringops.h>
++#include <readlline.h>
++
++/* Global library. */
++
++#include "mail_params.h"
++#include "mail_conf.h"
++
++/* mail_conf_checkdir - authorize non-default directory */
++
++static void mail_conf_checkdir(const char *config_dir)
++{
++ VSTRING *buf;
++ VSTREAM *fp;
++ char *path;
++ char *name;
++ char *value;
++ char *cp;
++ int found = 0;
++
++ /*
++ * If running set-[ug]id, require that a non-default configuration
++ * directory name is blessed as a bona fide configuration directory in
++ * the default main.cf file.
++ */
++ path = concatenate(DEF_CONFIG_DIR, "/", "main.cf", (char *) 0);
++ if ((fp = vstream_fopen(path, O_RDONLY, 0)) == 0)
++ msg_fatal("open file %s: %m", path);
++
++ buf = vstring_alloc(1);
++ while (found == 0 && readlline(buf, fp, (int *) 0)) {
++ if (split_nameval(vstring_str(buf), &name, &value) == 0
++ && (strcmp(name, VAR_CONFIG_DIRS) == 0
++ || strcmp(name, VAR_MULTI_CONF_DIRS) == 0)) {
++ while (found == 0 && (cp = mystrtok(&value, ", \t\r\n")) != 0)
++ if (strcmp(cp, config_dir) == 0)
++ found = 1;
++ }
++ }
++ if (vstream_fclose(fp))
++ msg_fatal("read file %s: %m", path);
++ vstring_free(buf);
++
++ if (found == 0) {
++ msg_error("untrusted configuration directory name: %s", config_dir);
++ msg_fatal("specify \"%s = %s\" in %s",
++ VAR_CONFIG_DIRS, config_dir, path);
++ }
++ myfree(path);
++}
++
++/* mail_conf_read - read global configuration file */
++
++void mail_conf_read(void)
++{
++ mail_conf_suck();
++ mail_params_init();
++}
++
++/* mail_conf_suck - suck in the global configuration file */
++
++void mail_conf_suck(void)
++{
++ char *config_dir;
++ char *path;
++
++ /*
++ * Permit references to unknown configuration variable names. We rely on
++ * a separate configuration checking tool to spot misspelled names and
++ * other kinds of trouble. Enter the configuration directory into the
++ * default dictionary.
++ */
++ dict_unknown_allowed = 1;
++ if (var_config_dir)
++ myfree(var_config_dir);
++ if ((config_dir = getenv(CONF_ENV_PATH)) == 0)
++ config_dir = DEF_CONFIG_DIR;
++ var_config_dir = mystrdup(config_dir);
++ set_mail_conf_str(VAR_CONFIG_DIR, var_config_dir);
++
++ /*
++ * If the configuration directory name comes from a different trust
++ * domain, require that it is listed in the default main.cf file.
++ */
++ if (strcmp(var_config_dir, DEF_CONFIG_DIR) != 0 /* non-default */
++ && safe_getenv(CONF_ENV_PATH) == 0 /* non-default */
++ && geteuid() != 0) /* untrusted */
++ mail_conf_checkdir(var_config_dir);
++ path = concatenate(var_config_dir, "/", "main.cf", (char *) 0);
++ dict_load_file(CONFIG_DICT, path);
++ myfree(path);
++}
++
++/* mail_conf_flush - discard configuration dictionary */
++
++void mail_conf_flush(void)
++{
++ if (dict_handle(CONFIG_DICT) != 0)
++ dict_unregister(CONFIG_DICT);
++}
++
++/* mail_conf_eval - expand macros in string */
++
++const char *mail_conf_eval(const char *string)
++{
++#define RECURSIVE 1
++
++ return (dict_eval(CONFIG_DICT, string, RECURSIVE));
++}
++
++/* mail_conf_lookup - lookup named variable */
++
++const char *mail_conf_lookup(const char *name)
++{
++ return (dict_lookup(CONFIG_DICT, name));
++}
++
++/* mail_conf_lookup_eval - expand named variable */
++
++const char *mail_conf_lookup_eval(const char *name)
++{
++ const char *value;
++
++#define RECURSIVE 1
++
++ if ((value = dict_lookup(CONFIG_DICT, name)) != 0)
++ value = dict_eval(CONFIG_DICT, value, RECURSIVE);
++ return (value);
++}
++
++/* mail_conf_update - update parameter */
++
++void mail_conf_update(const char *key, const char *value)
++{
++ dict_update(CONFIG_DICT, key, value);
++}
+diff -ruN a/src/global/mail_dict.c b/src/global/mail_dict.c
+--- a/src/global/mail_dict.c 2009-06-01 12:27:43.000000000 +0000
++++ b/src/global/mail_dict.c 2009-06-01 13:08:26.000000000 +0000
+@@ -45,6 +45,7 @@
+
+ static const DICT_OPEN_INFO dict_open_info[] = {
+ DICT_TYPE_PROXY, dict_proxy_open,
++#ifdef NO_DYNAMIC_MAPS
+ #ifdef HAS_LDAP
+ DICT_TYPE_LDAP, dict_ldap_open,
+ #endif
+@@ -54,6 +55,7 @@
+ #ifdef HAS_PGSQL
+ DICT_TYPE_PGSQL, dict_pgsql_open,
+ #endif
++#endif /* NO_DYNAMIC_MAPS */
+ 0,
+ };
+
+diff -ruN a/src/global/mail_params.c b/src/global/mail_params.c
+--- a/src/global/mail_params.c 2009-06-01 12:27:43.000000000 +0000
++++ b/src/global/mail_params.c 2009-06-01 13:08:26.000000000 +0000
+@@ -79,6 +79,7 @@
+ /* char *var_export_environ;
+ /* char *var_debug_peer_list;
+ /* int var_debug_peer_level;
++/* int var_command_maxtime;
+ /* int var_in_flow_delay;
+ /* int var_fault_inj_code;
+ /* char *var_bounce_service;
+@@ -265,6 +266,7 @@
+ char *var_export_environ;
+ char *var_debug_peer_list;
+ int var_debug_peer_level;
++int var_command_maxtime;
+ int var_fault_inj_code;
+ char *var_bounce_service;
+ char *var_cleanup_service;
+@@ -276,6 +278,7 @@
+ char *var_error_service;
+ char *var_flush_service;
+ char *var_verify_service;
++char *var_scache_service;
+ char *var_trace_service;
+ char *var_proxymap_service;
+ char *var_proxywrite_service;
+diff -ruN a/src/global/mail_params.c.orig b/src/global/mail_params.c.orig
+--- a/src/global/mail_params.c.orig 1970-01-01 00:00:00.000000000 +0000
++++ b/src/global/mail_params.c.orig 2009-06-01 13:07:56.000000000 +0000
+@@ -0,0 +1,752 @@
++/*++
++/* NAME
++/* mail_params 3
++/* SUMMARY
++/* global mail configuration parameters
++/* SYNOPSIS
++/* #include <mail_params.h>
++/*
++/* char *var_myhostname;
++/* char *var_mydomain;
++/* char *var_myorigin;
++/* char *var_mydest;
++/* char *var_relayhost;
++/* char *var_transit_origin;
++/* char *var_transit_dest;
++/* char *var_mail_name;
++/* int var_helpful_warnings;
++/* char *var_syslog_name;
++/* char *var_mail_owner;
++/* uid_t var_owner_uid;
++/* gid_t var_owner_gid;
++/* char *var_sgid_group;
++/* gid_t var_sgid_gid;
++/* char *var_default_privs;
++/* uid_t var_default_uid;
++/* gid_t var_default_gid;
++/* char *var_config_dir;
++/* char *var_daemon_dir;
++/* char *var_data_dir;
++/* char *var_command_dir;
++/* char *var_queue_dir;
++/* int var_use_limit;
++/* int var_idle_limit;
++/* int var_event_drain;
++/* int var_bundle_rcpt;
++/* char *var_procname;
++/* int var_pid;
++/* int var_ipc_timeout;
++/* char *var_pid_dir;
++/* int var_dont_remove;
++/* char *var_inet_interfaces;
++/* char *var_proxy_interfaces;
++/* char *var_inet_protocols;
++/* char *var_mynetworks;
++/* char *var_double_bounce_sender;
++/* int var_line_limit;
++/* char *var_alias_db_map;
++/* int var_message_limit;
++/* char *var_mail_release;
++/* char *var_mail_version;
++/* int var_ipc_idle_limit;
++/* int var_ipc_ttl_limit;
++/* char *var_db_type;
++/* char *var_hash_queue_names;
++/* int var_hash_queue_depth;
++/* int var_trigger_timeout;
++/* char *var_rcpt_delim;
++/* int var_fork_tries;
++/* int var_fork_delay;
++/* int var_flock_tries;
++/* int var_flock_delay;
++/* int var_flock_stale;
++/* int var_disable_dns;
++/* int var_soft_bounce;
++/* time_t var_starttime;
++/* int var_ownreq_special;
++/* int var_daemon_timeout;
++/* char *var_syslog_facility;
++/* char *var_relay_domains;
++/* char *var_fflush_domains;
++/* char *var_mynetworks_style;
++/* char *var_verp_delims;
++/* char *var_verp_filter;
++/* char *var_par_dom_match;
++/* char *var_config_dirs;
++/*
++/* int var_inet_windowsize;
++/* char *var_import_environ;
++/* char *var_export_environ;
++/* char *var_debug_peer_list;
++/* int var_debug_peer_level;
++/* int var_in_flow_delay;
++/* int var_fault_inj_code;
++/* char *var_bounce_service;
++/* char *var_cleanup_service;
++/* char *var_defer_service;
++/* char *var_pickup_service;
++/* char *var_queue_service;
++/* char *var_rewrite_service;
++/* char *var_showq_service;
++/* char *var_error_service;
++/* char *var_flush_service;
++/* char *var_verify_service;
++/* char *var_trace_service;
++/* char *var_proxymap_service;
++/* char *var_proxywrite_service;
++/* int var_db_create_buf;
++/* int var_db_read_buf;
++/* int var_mime_maxdepth;
++/* int var_mime_bound_len;
++/* int var_header_limit;
++/* int var_token_limit;
++/* int var_disable_mime_input;
++/* int var_disable_mime_oconv;
++/* int var_strict_8bitmime;
++/* int var_strict_7bit_hdrs;
++/* int var_strict_8bit_body;
++/* int var_strict_encoding;
++/* int var_verify_neg_cache;
++/* int var_oldlog_compat;
++/* int var_delay_max_res;
++/* char *var_int_filt_classes;
++/* int var_cyrus_sasl_authzid;
++/*
++/* char *var_multi_conf_dirs;
++/* char *var_multi_wrapper;
++/* char *var_multi_group;
++/* char *var_multi_name;
++/* bool var_multi_enable;
++/*
++/* void mail_params_init()
++/*
++/* const char null_format_string[1];
++/* DESCRIPTION
++/* This module (actually the associated include file) define the names
++/* and defaults of all mail configuration parameters.
++/*
++/* mail_params_init() initializes the built-in parameters listed above.
++/* These parameters are relied upon by library routines, so they are
++/* initialized globally so as to avoid hard-to-find errors due to
++/* missing initialization. This routine must be called early, at
++/* least before entering a chroot jail.
++/*
++/* null_format_string is a workaround for gcc compilers that complain
++/* about empty or null format strings.
++/* DIAGNOSTICS
++/* Fatal errors: out of memory; null system or domain name.
++/* LICENSE
++/* .ad
++/* .fi
++/* The Secure Mailer license must be distributed with this software.
++/* AUTHOR(S)
++/* Wietse Venema
++/* IBM T.J. Watson Research
++/* P.O. Box 704
++/* Yorktown Heights, NY 10598, USA
++/*--*/
++
++/* System library. */
++
++#include <sys_defs.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <pwd.h>
++#include <grp.h>
++#include <time.h>
++#include <ctype.h>
++
++#ifdef STRCASECMP_IN_STRINGS_H
++#include <strings.h>
++#endif
++
++/* Utility library. */
++
++#include <msg.h>
++#include <msg_syslog.h>
++#include <get_hostname.h>
++#include <valid_hostname.h>
++#include <stringops.h>
++#include <safe.h>
++#include <safe_open.h>
++#include <mymalloc.h>
++#ifdef HAS_DB
++#include <dict_db.h>
++#endif
++#include <inet_proto.h>
++#include <vstring_vstream.h>
++#include <iostuff.h>
++
++/* Global library. */
++
++#include <mynetworks.h>
++#include <mail_conf.h>
++#include <mail_version.h>
++#include <mail_proto.h>
++#include <verp_sender.h>
++#include <own_inet_addr.h>
++#include <mail_params.h>
++
++ /*
++ * Special configuration variables.
++ */
++char *var_myhostname;
++char *var_mydomain;
++char *var_myorigin;
++char *var_mydest;
++char *var_relayhost;
++char *var_transit_origin;
++char *var_transit_dest;
++char *var_mail_name;
++int var_helpful_warnings;
++char *var_syslog_name;
++char *var_mail_owner;
++uid_t var_owner_uid;
++gid_t var_owner_gid;
++char *var_sgid_group;
++gid_t var_sgid_gid;
++char *var_default_privs;
++uid_t var_default_uid;
++gid_t var_default_gid;
++char *var_config_dir;
++char *var_daemon_dir;
++char *var_data_dir;
++char *var_command_dir;
++char *var_queue_dir;
++int var_use_limit;
++int var_event_drain;
++int var_idle_limit;
++int var_bundle_rcpt;
++char *var_procname;
++int var_pid;
++int var_ipc_timeout;
++char *var_pid_dir;
++int var_dont_remove;
++char *var_inet_interfaces;
++char *var_proxy_interfaces;
++char *var_inet_protocols;
++char *var_mynetworks;
++char *var_double_bounce_sender;
++int var_line_limit;
++char *var_alias_db_map;
++int var_message_limit;
++char *var_mail_release;
++char *var_mail_version;
++int var_ipc_idle_limit;
++int var_ipc_ttl_limit;
++char *var_db_type;
++char *var_hash_queue_names;
++int var_hash_queue_depth;
++int var_trigger_timeout;
++char *var_rcpt_delim;
++int var_fork_tries;
++int var_fork_delay;
++int var_flock_tries;
++int var_flock_delay;
++int var_flock_stale;
++int var_disable_dns;
++int var_soft_bounce;
++time_t var_starttime;
++int var_ownreq_special;
++int var_daemon_timeout;
++char *var_syslog_facility;
++char *var_relay_domains;
++char *var_fflush_domains;
++char *var_mynetworks_style;
++char *var_verp_delims;
++char *var_verp_filter;
++int var_in_flow_delay;
++char *var_par_dom_match;
++char *var_config_dirs;
++
++int var_inet_windowsize;
++char *var_import_environ;
++char *var_export_environ;
++char *var_debug_peer_list;
++int var_debug_peer_level;
++int var_fault_inj_code;
++char *var_bounce_service;
++char *var_cleanup_service;
++char *var_defer_service;
++char *var_pickup_service;
++char *var_queue_service;
++char *var_rewrite_service;
++char *var_showq_service;
++char *var_error_service;
++char *var_flush_service;
++char *var_verify_service;
++char *var_trace_service;
++char *var_proxymap_service;
++char *var_proxywrite_service;
++int var_db_create_buf;
++int var_db_read_buf;
++int var_mime_maxdepth;
++int var_mime_bound_len;
++int var_header_limit;
++int var_token_limit;
++int var_disable_mime_input;
++int var_disable_mime_oconv;
++int var_strict_8bitmime;
++int var_strict_7bit_hdrs;
++int var_strict_8bit_body;
++int var_strict_encoding;
++int var_verify_neg_cache;
++int var_oldlog_compat;
++int var_delay_max_res;
++char *var_int_filt_classes;
++int var_cyrus_sasl_authzid;
++
++char *var_multi_conf_dirs;
++char *var_multi_wrapper;
++char *var_multi_group;
++char *var_multi_name;
++bool var_multi_enable;
++
++const char null_format_string[1] = "";
++
++/* check_myhostname - lookup hostname and validate */
++
++static const char *check_myhostname(void)
++{
++ static const char *name;
++ const char *dot;
++ const char *domain;
++
++ /*
++ * Use cached result.
++ */
++ if (name)
++ return (name);
++
++ /*
++ * If the local machine name is not in FQDN form, try to append the
++ * contents of $mydomain. Use a default domain as a final workaround.
++ */
++ name = get_hostname();
++ if ((dot = strchr(name, '.')) == 0) {
++ if ((domain = mail_conf_lookup_eval(VAR_MYDOMAIN)) == 0)
++ domain = DEF_MYDOMAIN;
++ name = concatenate(name, ".", domain, (char *) 0);
++ }
++ return (name);
++}
++
++/* check_mydomainname - lookup domain name and validate */
++
++static const char *check_mydomainname(void)
++{
++ char *dot;
++
++ /*
++ * Use a default domain when the hostname is not a FQDN ("foo").
++ */
++ if ((dot = strchr(var_myhostname, '.')) == 0)
++ return (DEF_MYDOMAIN);
++ return (dot + 1);
++}
++
++/* check_default_privs - lookup default user attributes and validate */
++
++static void check_default_privs(void)
++{
++ struct passwd *pwd;
++
++ if ((pwd = getpwnam(var_default_privs)) == 0)
++ msg_fatal("file %s/%s: parameter %s: unknown user name value: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, var_default_privs);
++ if ((var_default_uid = pwd->pw_uid) == 0)
++ msg_fatal("file %s/%s: parameter %s: user %s has privileged user ID",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, var_default_privs);
++ if ((var_default_gid = pwd->pw_gid) == 0)
++ msg_fatal("file %s/%s: parameter %s: user %s has privileged group ID",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, var_default_privs);
++}
++
++/* check_mail_owner - lookup owner user attributes and validate */
++
++static void check_mail_owner(void)
++{
++ struct passwd *pwd;
++
++ if ((pwd = getpwnam(var_mail_owner)) == 0)
++ msg_fatal("file %s/%s: parameter %s: unknown user name value: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MAIL_OWNER, var_mail_owner);
++ if ((var_owner_uid = pwd->pw_uid) == 0)
++ msg_fatal("file %s/%s: parameter %s: user %s has privileged user ID",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MAIL_OWNER, var_mail_owner);
++ if ((var_owner_gid = pwd->pw_gid) == 0)
++ msg_fatal("file %s/%s: parameter %s: user %s has privileged group ID",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MAIL_OWNER, var_mail_owner);
++
++ /*
++ * This detects only some forms of sharing. Enumerating the entire
++ * password file name space could be expensive. The purpose of this code
++ * is to discourage user ID sharing by developers and package
++ * maintainers.
++ */
++ if ((pwd = getpwuid(var_owner_uid)) != 0
++ && strcmp(pwd->pw_name, var_mail_owner) != 0)
++ msg_fatal("file %s/%s: parameter %s: user %s has same user ID as %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MAIL_OWNER, var_mail_owner, pwd->pw_name);
++}
++
++/* check_sgid_group - lookup setgid group attributes and validate */
++
++static void check_sgid_group(void)
++{
++ struct group *grp;
++
++ if ((grp = getgrnam(var_sgid_group)) == 0)
++ msg_fatal("file %s/%s: parameter %s: unknown group name: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_SGID_GROUP, var_sgid_group);
++ if ((var_sgid_gid = grp->gr_gid) == 0)
++ msg_fatal("file %s/%s: parameter %s: group %s has privileged group ID",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_SGID_GROUP, var_sgid_group);
++
++ /*
++ * This detects only some forms of sharing. Enumerating the entire group
++ * file name space could be expensive. The purpose of this code is to
++ * discourage group ID sharing by developers and package maintainers.
++ */
++ if ((grp = getgrgid(var_sgid_gid)) != 0
++ && strcmp(grp->gr_name, var_sgid_group) != 0)
++ msg_fatal("file %s/%s: parameter %s: group %s has same group ID as %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_SGID_GROUP, var_sgid_group, grp->gr_name);
++}
++
++/* check_overlap - disallow UID or GID sharing */
++
++static void check_overlap(void)
++{
++ if (strcmp(var_default_privs, var_mail_owner) == 0)
++ msg_fatal("file %s/%s: parameters %s and %s specify the same user %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, VAR_MAIL_OWNER,
++ var_default_privs);
++ if (var_default_uid == var_owner_uid)
++ msg_fatal("file %s/%s: parameters %s and %s: users %s and %s have the same user ID: %ld",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, VAR_MAIL_OWNER,
++ var_default_privs, var_mail_owner,
++ (long) var_owner_uid);
++ if (var_default_gid == var_owner_gid)
++ msg_fatal("file %s/%s: parameters %s and %s: users %s and %s have the same group ID: %ld",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, VAR_MAIL_OWNER,
++ var_default_privs, var_mail_owner,
++ (long) var_owner_gid);
++ if (var_default_gid == var_sgid_gid)
++ msg_fatal("file %s/%s: parameters %s and %s: user %s and group %s have the same group ID: %ld",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_DEFAULT_PRIVS, VAR_SGID_GROUP,
++ var_default_privs, var_sgid_group,
++ (long) var_sgid_gid);
++ if (var_owner_gid == var_sgid_gid)
++ msg_fatal("file %s/%s: parameters %s and %s: user %s and group %s have the same group ID: %ld",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MAIL_OWNER, VAR_SGID_GROUP,
++ var_mail_owner, var_sgid_group,
++ (long) var_sgid_gid);
++}
++
++#ifdef MYORIGIN_FROM_FILE
++
++/* read_param_from_file - read parameter value from file */
++
++static char *read_param_from_file(const char *path)
++{
++ VSTRING *why = vstring_alloc(100);
++ VSTRING *buf = vstring_alloc(100);
++ VSTREAM *fp;
++ char *bp;
++ char *result;
++
++ /*
++ * Ugly macros to make complex expressions less unreadable.
++ */
++#define SKIP(start, var, cond) \
++ for (var = start; *var && (cond); var++);
++
++#define TRIM(s) { \
++ char *p; \
++ for (p = (s) + strlen(s); p > (s) && ISSPACE(p[-1]); p--); \
++ *p = 0; \
++ }
++
++ fp = safe_open(path, O_RDONLY, 0, (struct stat *) 0, -1, -1, why);
++ if (fp == 0)
++ msg_fatal("%s: %s", path, vstring_str(why));
++ vstring_get_nonl(buf, fp);
++ if (vstream_ferror(fp)) /* FIX 20070501 */
++ msg_fatal("%s: read error: %m", path);
++ vstream_fclose(fp);
++ SKIP(vstring_str(buf), bp, ISSPACE(*bp));
++ TRIM(bp);
++ result = mystrdup(bp);
++
++ vstring_free(why);
++ vstring_free(buf);
++ return (result);
++}
++
++#endif
++
++/* mail_params_init - configure built-in parameters */
++
++void mail_params_init()
++{
++ static const CONFIG_STR_TABLE first_str_defaults[] = {
++ VAR_SYSLOG_FACILITY, DEF_SYSLOG_FACILITY, &var_syslog_facility, 1, 0,
++ VAR_INET_PROTOCOLS, DEF_INET_PROTOCOLS, &var_inet_protocols, 1, 0,
++ VAR_MULTI_CONF_DIRS, DEF_MULTI_CONF_DIRS, &var_multi_conf_dirs, 0, 0,
++ VAR_MULTI_WRAPPER, DEF_MULTI_WRAPPER, &var_multi_wrapper, 0, 0,
++ VAR_MULTI_GROUP, DEF_MULTI_GROUP, &var_multi_group, 0, 0,
++ VAR_MULTI_NAME, DEF_MULTI_NAME, &var_multi_name, 0, 0,
++ 0,
++ };
++ static const CONFIG_STR_FN_TABLE function_str_defaults[] = {
++ VAR_MYHOSTNAME, check_myhostname, &var_myhostname, 1, 0,
++ VAR_MYDOMAIN, check_mydomainname, &var_mydomain, 1, 0,
++ 0,
++ };
++ static const CONFIG_STR_TABLE other_str_defaults[] = {
++ VAR_MAIL_NAME, DEF_MAIL_NAME, &var_mail_name, 1, 0,
++ VAR_SYSLOG_NAME, DEF_SYSLOG_NAME, &var_syslog_name, 1, 0,
++ VAR_MAIL_OWNER, DEF_MAIL_OWNER, &var_mail_owner, 1, 0,
++ VAR_SGID_GROUP, DEF_SGID_GROUP, &var_sgid_group, 1, 0,
++ VAR_MYDEST, DEF_MYDEST, &var_mydest, 0, 0,
++ VAR_MYORIGIN, DEF_MYORIGIN, &var_myorigin, 1, 0,
++ VAR_RELAYHOST, DEF_RELAYHOST, &var_relayhost, 0, 0,
++ VAR_DAEMON_DIR, DEF_DAEMON_DIR, &var_daemon_dir, 1, 0,
++ VAR_DATA_DIR, DEF_DATA_DIR, &var_data_dir, 1, 0,
++ VAR_COMMAND_DIR, DEF_COMMAND_DIR, &var_command_dir, 1, 0,
++ VAR_QUEUE_DIR, DEF_QUEUE_DIR, &var_queue_dir, 1, 0,
++ VAR_PID_DIR, DEF_PID_DIR, &var_pid_dir, 1, 0,
++ VAR_INET_INTERFACES, DEF_INET_INTERFACES, &var_inet_interfaces, 1, 0,
++ VAR_PROXY_INTERFACES, DEF_PROXY_INTERFACES, &var_proxy_interfaces, 0, 0,
++ VAR_DOUBLE_BOUNCE, DEF_DOUBLE_BOUNCE, &var_double_bounce_sender, 1, 0,
++ VAR_DEFAULT_PRIVS, DEF_DEFAULT_PRIVS, &var_default_privs, 1, 0,
++ VAR_ALIAS_DB_MAP, DEF_ALIAS_DB_MAP, &var_alias_db_map, 0, 0,
++ VAR_MAIL_RELEASE, DEF_MAIL_RELEASE, &var_mail_release, 1, 0,
++ VAR_MAIL_VERSION, DEF_MAIL_VERSION, &var_mail_version, 1, 0,
++ VAR_DB_TYPE, DEF_DB_TYPE, &var_db_type, 1, 0,
++ VAR_HASH_QUEUE_NAMES, DEF_HASH_QUEUE_NAMES, &var_hash_queue_names, 1, 0,
++ VAR_RCPT_DELIM, DEF_RCPT_DELIM, &var_rcpt_delim, 0, 1,
++ VAR_RELAY_DOMAINS, DEF_RELAY_DOMAINS, &var_relay_domains, 0, 0,
++ VAR_FFLUSH_DOMAINS, DEF_FFLUSH_DOMAINS, &var_fflush_domains, 0, 0,
++ VAR_EXPORT_ENVIRON, DEF_EXPORT_ENVIRON, &var_export_environ, 0, 0,
++ VAR_IMPORT_ENVIRON, DEF_IMPORT_ENVIRON, &var_import_environ, 0, 0,
++ VAR_MYNETWORKS_STYLE, DEF_MYNETWORKS_STYLE, &var_mynetworks_style, 1, 0,
++ VAR_DEBUG_PEER_LIST, DEF_DEBUG_PEER_LIST, &var_debug_peer_list, 0, 0,
++ VAR_VERP_DELIMS, DEF_VERP_DELIMS, &var_verp_delims, 2, 2,
++ VAR_VERP_FILTER, DEF_VERP_FILTER, &var_verp_filter, 1, 0,
++ VAR_PAR_DOM_MATCH, DEF_PAR_DOM_MATCH, &var_par_dom_match, 0, 0,
++ VAR_CONFIG_DIRS, DEF_CONFIG_DIRS, &var_config_dirs, 0, 0,
++ VAR_BOUNCE_SERVICE, DEF_BOUNCE_SERVICE, &var_bounce_service, 1, 0,
++ VAR_CLEANUP_SERVICE, DEF_CLEANUP_SERVICE, &var_cleanup_service, 1, 0,
++ VAR_DEFER_SERVICE, DEF_DEFER_SERVICE, &var_defer_service, 1, 0,
++ VAR_PICKUP_SERVICE, DEF_PICKUP_SERVICE, &var_pickup_service, 1, 0,
++ VAR_QUEUE_SERVICE, DEF_QUEUE_SERVICE, &var_queue_service, 1, 0,
++ VAR_REWRITE_SERVICE, DEF_REWRITE_SERVICE, &var_rewrite_service, 1, 0,
++ VAR_SHOWQ_SERVICE, DEF_SHOWQ_SERVICE, &var_showq_service, 1, 0,
++ VAR_ERROR_SERVICE, DEF_ERROR_SERVICE, &var_error_service, 1, 0,
++ VAR_FLUSH_SERVICE, DEF_FLUSH_SERVICE, &var_flush_service, 1, 0,
++ VAR_VERIFY_SERVICE, DEF_VERIFY_SERVICE, &var_verify_service, 1, 0,
++ VAR_TRACE_SERVICE, DEF_TRACE_SERVICE, &var_trace_service, 1, 0,
++ VAR_PROXYMAP_SERVICE, DEF_PROXYMAP_SERVICE, &var_proxymap_service, 1, 0,
++ VAR_PROXYWRITE_SERVICE, DEF_PROXYWRITE_SERVICE, &var_proxywrite_service, 1, 0,
++ VAR_INT_FILT_CLASSES, DEF_INT_FILT_CLASSES, &var_int_filt_classes, 0, 0,
++ 0,
++ };
++ static const CONFIG_STR_FN_TABLE function_str_defaults_2[] = {
++ VAR_MYNETWORKS, mynetworks, &var_mynetworks, 0, 0,
++ 0,
++ };
++ static const CONFIG_INT_TABLE other_int_defaults[] = {
++ VAR_MAX_USE, DEF_MAX_USE, &var_use_limit, 1, 0,
++ VAR_DONT_REMOVE, DEF_DONT_REMOVE, &var_dont_remove, 0, 0,
++ VAR_LINE_LIMIT, DEF_LINE_LIMIT, &var_line_limit, 512, 0,
++ VAR_MESSAGE_LIMIT, DEF_MESSAGE_LIMIT, &var_message_limit, 0, 0,
++ VAR_HASH_QUEUE_DEPTH, DEF_HASH_QUEUE_DEPTH, &var_hash_queue_depth, 1, 0,
++ VAR_FORK_TRIES, DEF_FORK_TRIES, &var_fork_tries, 1, 0,
++ VAR_FLOCK_TRIES, DEF_FLOCK_TRIES, &var_flock_tries, 1, 0,
++ VAR_DEBUG_PEER_LEVEL, DEF_DEBUG_PEER_LEVEL, &var_debug_peer_level, 1, 0,
++ VAR_FAULT_INJ_CODE, DEF_FAULT_INJ_CODE, &var_fault_inj_code, 0, 0,
++ VAR_DB_CREATE_BUF, DEF_DB_CREATE_BUF, &var_db_create_buf, 1, 0,
++ VAR_DB_READ_BUF, DEF_DB_READ_BUF, &var_db_read_buf, 1, 0,
++ VAR_HEADER_LIMIT, DEF_HEADER_LIMIT, &var_header_limit, 1, 0,
++ VAR_TOKEN_LIMIT, DEF_TOKEN_LIMIT, &var_token_limit, 1, 0,
++ VAR_MIME_MAXDEPTH, DEF_MIME_MAXDEPTH, &var_mime_maxdepth, 1, 0,
++ VAR_MIME_BOUND_LEN, DEF_MIME_BOUND_LEN, &var_mime_bound_len, 1, 0,
++ VAR_DELAY_MAX_RES, DEF_DELAY_MAX_RES, &var_delay_max_res, MIN_DELAY_MAX_RES, MAX_DELAY_MAX_RES,
++ VAR_INET_WINDOW, DEF_INET_WINDOW, &var_inet_windowsize, 0, 0,
++ 0,
++ };
++ static const CONFIG_TIME_TABLE time_defaults[] = {
++ VAR_EVENT_DRAIN, DEF_EVENT_DRAIN, &var_event_drain, 1, 0,
++ VAR_MAX_IDLE, DEF_MAX_IDLE, &var_idle_limit, 1, 0,
++ VAR_IPC_TIMEOUT, DEF_IPC_TIMEOUT, &var_ipc_timeout, 1, 0,
++ VAR_IPC_IDLE, DEF_IPC_IDLE, &var_ipc_idle_limit, 1, 0,
++ VAR_IPC_TTL, DEF_IPC_TTL, &var_ipc_ttl_limit, 1, 0,
++ VAR_TRIGGER_TIMEOUT, DEF_TRIGGER_TIMEOUT, &var_trigger_timeout, 1, 0,
++ VAR_FORK_DELAY, DEF_FORK_DELAY, &var_fork_delay, 1, 0,
++ VAR_FLOCK_DELAY, DEF_FLOCK_DELAY, &var_flock_delay, 1, 0,
++ VAR_FLOCK_STALE, DEF_FLOCK_STALE, &var_flock_stale, 1, 0,
++ VAR_DAEMON_TIMEOUT, DEF_DAEMON_TIMEOUT, &var_daemon_timeout, 1, 0,
++ VAR_IN_FLOW_DELAY, DEF_IN_FLOW_DELAY, &var_in_flow_delay, 0, 10,
++ 0,
++ };
++ static const CONFIG_BOOL_TABLE bool_defaults[] = {
++ VAR_DISABLE_DNS, DEF_DISABLE_DNS, &var_disable_dns,
++ VAR_SOFT_BOUNCE, DEF_SOFT_BOUNCE, &var_soft_bounce,
++ VAR_OWNREQ_SPECIAL, DEF_OWNREQ_SPECIAL, &var_ownreq_special,
++ VAR_STRICT_8BITMIME, DEF_STRICT_8BITMIME, &var_strict_8bitmime,
++ VAR_STRICT_7BIT_HDRS, DEF_STRICT_7BIT_HDRS, &var_strict_7bit_hdrs,
++ VAR_STRICT_8BIT_BODY, DEF_STRICT_8BIT_BODY, &var_strict_8bit_body,
++ VAR_STRICT_ENCODING, DEF_STRICT_ENCODING, &var_strict_encoding,
++ VAR_DISABLE_MIME_INPUT, DEF_DISABLE_MIME_INPUT, &var_disable_mime_input,
++ VAR_DISABLE_MIME_OCONV, DEF_DISABLE_MIME_OCONV, &var_disable_mime_oconv,
++ VAR_VERIFY_NEG_CACHE, DEF_VERIFY_NEG_CACHE, &var_verify_neg_cache,
++ VAR_OLDLOG_COMPAT, DEF_OLDLOG_COMPAT, &var_oldlog_compat,
++ VAR_HELPFUL_WARNINGS, DEF_HELPFUL_WARNINGS, &var_helpful_warnings,
++ VAR_CYRUS_SASL_AUTHZID, DEF_CYRUS_SASL_AUTHZID, &var_cyrus_sasl_authzid,
++ VAR_MULTI_ENABLE, DEF_MULTI_ENABLE, &var_multi_enable,
++ 0,
++ };
++ const char *cp;
++ INET_PROTO_INFO *proto_info;
++
++ /*
++ * Extract syslog_facility early, so that from here on all errors are
++ * logged with the proper facility.
++ */
++ get_mail_conf_str_table(first_str_defaults);
++
++ if (!msg_syslog_facility(var_syslog_facility))
++ msg_fatal("file %s/%s: parameter %s: unrecognized value: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_SYSLOG_FACILITY, var_syslog_facility);
++
++ /*
++ * What protocols should we attempt to support? The result is stored in
++ * the global inet_proto_table variable.
++ */
++ proto_info = inet_proto_init(VAR_INET_PROTOCOLS, var_inet_protocols);
++
++ /*
++ * Variables whose defaults are determined at runtime. Some sites use
++ * short hostnames in the host table; some sites name their system after
++ * the domain.
++ */
++ get_mail_conf_str_fn_table(function_str_defaults);
++ if (!valid_hostname(var_myhostname, DO_GRIPE))
++ msg_fatal("file %s/%s: parameter %s: bad parameter value: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MYHOSTNAME, var_myhostname);
++ if (!valid_hostname(var_mydomain, DO_GRIPE))
++ msg_fatal("file %s/%s: parameter %s: bad parameter value: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_MYDOMAIN, var_mydomain);
++
++ /*
++ * Variables that are needed by almost every program.
++ *
++ * XXX Reading the myorigin value from file is originally a Debian Linux
++ * feature. This code is not enabled by default because of problems: 1)
++ * it re-implements its own parameter syntax checks, and 2) it does not
++ * implement $name expansions.
++ */
++ get_mail_conf_str_table(other_str_defaults);
++#ifdef MYORIGIN_FROM_FILE
++ if (*var_myorigin == '/') {
++ char *origin = read_param_from_file(var_myorigin);
++
++ if (*origin == 0)
++ msg_fatal("%s file %s is empty", VAR_MYORIGIN, var_myorigin);
++ myfree(var_myorigin); /* FIX 20070501 */
++ var_myorigin = origin;
++ }
++#endif
++ get_mail_conf_int_table(other_int_defaults);
++ get_mail_conf_bool_table(bool_defaults);
++ get_mail_conf_time_table(time_defaults);
++ check_default_privs();
++ check_mail_owner();
++ check_sgid_group();
++ check_overlap();
++#ifdef HAS_DB
++ dict_db_cache_size = var_db_read_buf;
++#endif
++ inet_windowsize = var_inet_windowsize;
++
++ /*
++ * Variables whose defaults are determined at runtime, after other
++ * variables have been set. This dependency is admittedly a bit tricky.
++ * XXX Perhaps we should just register variables, and let the evaluator
++ * figure out in what order to evaluate things.
++ */
++ get_mail_conf_str_fn_table(function_str_defaults_2);
++
++ /*
++ * FIX 200412 The IPv6 patch did not call own_inet_addr_list() before
++ * entering the chroot jail on Linux IPv6 systems. Linux has the IPv6
++ * interface list in /proc, which is not available after chrooting.
++ */
++ (void) own_inet_addr_list();
++
++ /*
++ * The PID variable cannot be set from the configuration file!!
++ */
++ set_mail_conf_int(VAR_PID, var_pid = getpid());
++
++ /*
++ * Neither can the start time variable. It isn't even visible.
++ */
++ time(&var_starttime);
++
++ /*
++ * Export the syslog name so children can inherit and use it before they
++ * have initialized.
++ */
++ if ((cp = safe_getenv(CONF_ENV_LOGTAG)) == 0
++ || strcmp(cp, var_syslog_name) != 0)
++ if (setenv(CONF_ENV_LOGTAG, var_syslog_name, 1) < 0)
++ msg_fatal("setenv %s %s: %m", CONF_ENV_LOGTAG, var_syslog_name);
++
++ /*
++ * I have seen this happen just too often.
++ */
++ if (strcasecmp(var_myhostname, var_relayhost) == 0)
++ msg_fatal("%s and %s parameter settings must not be identical: %s",
++ VAR_MYHOSTNAME, VAR_RELAYHOST, var_myhostname);
++
++ /*
++ * XXX These should be caught by a proper parameter parsing algorithm.
++ */
++ if (var_myorigin[strcspn(var_myorigin, ", \t\r\n")])
++ msg_fatal("%s parameter setting must not contain multiple values: %s",
++ VAR_MYORIGIN, var_myorigin);
++
++ if (var_relayhost[strcspn(var_relayhost, ", \t\r\n")])
++ msg_fatal("%s parameter setting must not contain multiple values: %s",
++ VAR_RELAYHOST, var_relayhost);
++
++ /*
++ * One more sanity check.
++ */
++ if ((cp = verp_delims_verify(var_verp_delims)) != 0)
++ msg_fatal("file %s/%s: parameters %s and %s: %s",
++ var_config_dir, MAIN_CONF_FILE,
++ VAR_VERP_DELIMS, VAR_VERP_FILTER, cp);
++}
+diff -ruN a/src/global/mkmap_open.c b/src/global/mkmap_open.c
+--- a/src/global/mkmap_open.c 2009-06-01 12:27:44.000000000 +0000
++++ b/src/global/mkmap_open.c 2009-06-01 13:08:26.000000000 +0000
+@@ -81,7 +81,7 @@
+ * We use a different table (in dict_open.c) when querying maps.
+ */
+ typedef struct {
+- char *type;
++ const char *type;
+ MKMAP *(*before_open) (const char *);
+ } MKMAP_OPEN_INFO;
+
+@@ -156,7 +156,16 @@
+ */
+ for (mp = mkmap_types; /* void */ ; mp++) {
+ if (mp->type == 0)
++#ifndef NO_DYNAMIC_MAPS
++ {
++ static MKMAP_OPEN_INFO oi;
++ oi.before_open=(MKMAP*(*)(const char*))dict_mkmap_func(type);
++ oi.type=type;
++ mp=&oi;
++ }
++#else
+ msg_fatal("unsupported map type: %s", type);
++#endif
+ if (strcmp(type, mp->type) == 0)
+ break;
+ }
+diff -ruN a/src/master/Makefile.in b/src/master/Makefile.in
+--- a/src/master/Makefile.in 2009-06-01 12:27:44.000000000 +0000
++++ b/src/master/Makefile.in 2009-06-01 13:08:26.000000000 +0000
+@@ -20,7 +20,7 @@
+ INC_DIR = ../../include
+ BIN_DIR = ../../libexec
+
+-.c.o:; $(CC) $(CFLAGS) -c $*.c
++.c.o:; $(CC) `for i in $(LIB_OBJ); do [ $$i = $@ ] && echo -fPIC; done` $(CFLAGS) -c $*.c
+
+ all: $(PROG) $(LIB)
+
+@@ -39,12 +39,10 @@
+ root_tests:
+
+ $(LIB): $(LIB_OBJ)
+- $(AR) $(ARFL) $(LIB) $?
+- $(RANLIB) $(LIB)
++ gcc -shared -Wl,-soname,libpostfix-master.so.1 -o $(LIB) $(LIB_OBJ) $(LIBS) $(SYSLIBS)
+
+ $(LIB_DIR)/$(LIB): $(LIB)
+ cp $(LIB) $(LIB_DIR)/$(LIB)
+- $(RANLIB) $(LIB_DIR)/$(LIB)
+
+ $(BIN_DIR)/$(PROG): $(PROG)
+ cp $(PROG) $(BIN_DIR)
+diff -ruN a/src/milter/Makefile.in b/src/milter/Makefile.in
+--- a/src/milter/Makefile.in 2009-06-01 12:27:45.000000000 +0000
++++ b/src/milter/Makefile.in 2009-06-01 13:08:26.000000000 +0000
+@@ -14,7 +14,7 @@
+ INC_DIR = ../../include
+ MAKES =
+
+-.c.o:; $(CC) $(CFLAGS) -c $*.c
++.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
+
+ all: $(LIB)
+
+@@ -30,12 +30,10 @@
+ root_tests:
+
+ $(LIB): $(OBJS)
+- $(AR) $(ARFL) $(LIB) $?
+- $(RANLIB) $(LIB)
++ gcc -shared -Wl,-soname,libpostfix-milter.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
+
+ $(LIB_DIR)/$(LIB): $(LIB)
+ cp $(LIB) $(LIB_DIR)
+- $(RANLIB) $(LIB_DIR)/$(LIB)
+
+ update: $(LIB_DIR)/$(LIB) $(HDRS)
+ -for i in $(HDRS); \
+diff -ruN a/src/postconf/postconf.c b/src/postconf/postconf.c
+--- a/src/postconf/postconf.c 2009-06-01 12:27:45.000000000 +0000
++++ b/src/postconf/postconf.c 2009-06-01 13:08:26.000000000 +0000
+@@ -962,6 +962,16 @@
+ {
+ ARGV *maps_argv;
+ int i;
++#ifndef NO_DYNAMIC_MAPS
++ char *path;
++ char *config_dir;
++
++ var_config_dir = mystrdup((config_dir = safe_getenv(CONF_ENV_PATH)) != 0 ?
++ config_dir : DEF_CONFIG_DIR); /* XXX */
++ path = concatenate(var_config_dir, "/", "dynamicmaps.cf", (char *) 0);
++ dict_open_dlinfo(path);
++ myfree(path);
++#endif
+
+ maps_argv = dict_mapnames();
+ for (i = 0; i < maps_argv->argc; i++)
+diff -ruN a/src/postconf/postconf.c.orig b/src/postconf/postconf.c.orig
+--- a/src/postconf/postconf.c.orig 1970-01-01 00:00:00.000000000 +0000
++++ b/src/postconf/postconf.c.orig 2009-06-01 13:07:57.000000000 +0000
+@@ -0,0 +1,1218 @@
++/*++
++/* NAME
++/* postconf 1
++/* SUMMARY
++/* Postfix configuration utility
++/* SYNOPSIS
++/* .fi
++/* \fBpostconf\fR [\fB-dhnv\fR] [\fB-c \fIconfig_dir\fR]
++/* [\fIparameter ...\fR]
++/*
++/* \fBpostconf\fR [\fB-aAmlv\fR] [\fB-c \fIconfig_dir\fR]
++/*
++/* \fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
++/* [\fIparameter=value ...\fR]
++/*
++/* \fBpostconf\fR [\fB-#v\fR] [\fB-c \fIconfig_dir\fR]
++/* [\fIparameter ...\fR]
++/*
++/* \fBpostconf\fR [\fB-btv\fR] [\fB-c \fIconfig_dir\fR] [\fItemplate_file\fR]
++/* DESCRIPTION
++/* The \fBpostconf\fR(1) command displays the actual values
++/* of configuration parameters, changes configuration parameter
++/* values, or displays other configuration information about
++/* the Postfix mail system.
++/*
++/* Options:
++/* .IP \fB-a\fR
++/* List the available SASL server plug-in types. The SASL
++/* plug-in type is selected with the \fBsmtpd_sasl_type\fR
++/* configuration parameter by specifying one of the names
++/* listed below.
++/* .RS
++/* .IP \fBcyrus\fR
++/* This server plug-in is available when Postfix is built with
++/* Cyrus SASL support.
++/* .IP \fBdovecot\fR
++/* This server plug-in uses the Dovecot authentication server,
++/* and is available when Postfix is built with any form of SASL
++/* support.
++/* .RE
++/* .IP
++/* This feature is available with Postfix 2.3 and later.
++/* .IP \fB-A\fR
++/* List the available SASL client plug-in types. The SASL
++/* plug-in type is selected with the \fBsmtp_sasl_type\fR or
++/* \fBlmtp_sasl_type\fR configuration parameters by specifying
++/* one of the names listed below.
++/* .RS
++/* .IP \fBcyrus\fR
++/* This client plug-in is available when Postfix is built with
++/* Cyrus SASL support.
++/* .RE
++/* .IP
++/* This feature is available with Postfix 2.3 and later.
++/* .IP "\fB-b\fR [\fItemplate_file\fR]"
++/* Display the message text that appears at the beginning of
++/* delivery status notification (DSN) messages, with $\fBname\fR
++/* expressions replaced by actual values. To override the
++/* built-in message text, specify a template file at the end
++/* of the command line, or specify a template file in main.cf
++/* with the \fBbounce_template_file\fR parameter.
++/* To force selection of the built-in message text templates,
++/* specify an empty template file name (in shell language: "").
++/*
++/* This feature is available with Postfix 2.3 and later.
++/* .IP "\fB-c \fIconfig_dir\fR"
++/* The \fBmain.cf\fR configuration file is in the named directory
++/* instead of the default configuration directory.
++/* .IP \fB-d\fR
++/* Print default parameter settings instead of actual settings.
++/* .IP \fB-e\fR
++/* Edit the \fBmain.cf\fR configuration file. The file is copied
++/* to a temporary file then renamed into place. Parameters and
++/* values are specified on the command line. Use quotes in order
++/* to protect shell metacharacters and whitespace.
++/* .IP \fB-h\fR
++/* Show parameter values only, not the ``name = '' label
++/* that normally precedes the value.
++/* .IP \fB-l\fR
++/* List the names of all supported mailbox locking methods.
++/* Postfix supports the following methods:
++/* .RS
++/* .IP \fBflock\fR
++/* A kernel-based advisory locking method for local files only.
++/* This locking method is available on systems with a BSD
++/* compatible library.
++/* .IP \fBfcntl\fR
++/* A kernel-based advisory locking method for local and remote files.
++/* .IP \fBdotlock\fR
++/* An application-level locking method. An application locks a file
++/* named \fIfilename\fR by creating a file named \fIfilename\fB.lock\fR.
++/* The application is expected to remove its own lock file, as well as
++/* stale lock files that were left behind after abnormal termination.
++/* .RE
++/* .IP \fB-m\fR
++/* List the names of all supported lookup table types. In Postfix
++/* configuration files,
++/* lookup tables are specified as \fItype\fB:\fIname\fR, where
++/* \fItype\fR is one of the types listed below. The table \fIname\fR
++/* syntax depends on the lookup table type as described in the
++/* DATABASE_README document.
++/* .RS
++/* .IP \fBbtree\fR
++/* A sorted, balanced tree structure.
++/* This is available on systems with support for Berkeley DB
++/* databases.
++/* .IP \fBcdb\fR
++/* A read-optimized structure with no support for incremental updates.
++/* This is available on systems with support for CDB databases.
++/* .IP \fBcidr\fR
++/* A table that associates values with Classless Inter-Domain Routing
++/* (CIDR) patterns. This is described in \fBcidr_table\fR(5).
++/* .IP \fBdbm\fR
++/* An indexed file type based on hashing.
++/* This is available on systems with support for DBM databases.
++/* .IP \fBenviron\fR
++/* The UNIX process environment array. The lookup key is the variable
++/* name. Originally implemented for testing, someone may find this
++/* useful someday.
++/* .IP \fBhash\fR
++/* An indexed file type based on hashing.
++/* This is available on systems with support for Berkeley DB
++/* databases.
++/* .IP "\fBldap\fR (read-only)"
++/* Perform lookups using the LDAP protocol. This is described
++/* in \fBldap_table\fR(5).
++/* .IP "\fBmysql\fR (read-only)"
++/* Perform lookups using the MYSQL protocol. This is described
++/* in \fBmysql_table\fR(5).
++/* .IP "\fBpcre\fR (read-only)"
++/* A lookup table based on Perl Compatible Regular Expressions. The
++/* file format is described in \fBpcre_table\fR(5).
++/* .IP "\fBpgsql\fR (read-only)"
++/* Perform lookups using the PostgreSQL protocol. This is described
++/* in \fBpgsql_table\fR(5).
++/* .IP "\fBproxy\fR (read-only)"
++/* A lookup table that is implemented via the Postfix
++/* \fBproxymap\fR(8) service. The table name syntax is
++/* \fItype\fB:\fIname\fR.
++/* .IP "\fBregexp\fR (read-only)"
++/* A lookup table based on regular expressions. The file format is
++/* described in \fBregexp_table\fR(5).
++/* .IP \fBsdbm\fR
++/* An indexed file type based on hashing.
++/* This is available on systems with support for SDBM databases.
++/* .IP "\fBstatic\fR (read-only)"
++/* A table that always returns its name as lookup result. For example,
++/* \fBstatic:foobar\fR always returns the string \fBfoobar\fR as lookup
++/* result.
++/* .IP "\fBtcp\fR (read-only)"
++/* Perform lookups using a simple request-reply protocol that is
++/* described in \fBtcp_table\fR(5).
++/* This feature is not included with the stable Postfix release.
++/* .IP "\fBunix\fR (read-only)"
++/* A limited way to query the UNIX authentication database. The
++/* following tables are implemented:
++/* .RS
++/*. IP \fBunix:passwd.byname\fR
++/* The table is the UNIX password database. The key is a login name.
++/* The result is a password file entry in \fBpasswd\fR(5) format.
++/* .IP \fBunix:group.byname\fR
++/* The table is the UNIX group database. The key is a group name.
++/* The result is a group file entry in \fBgroup\fR(5) format.
++/* .RE
++/* .RE
++/* .IP
++/* Other table types may exist depending on how Postfix was built.
++/* .IP \fB-n\fR
++/* Print parameter settings that are not left at their built-in
++/* default value, because they are explicitly specified in main.cf.
++/* .IP "\fB-t\fR [\fItemplate_file\fR]"
++/* Display the templates for delivery status notification (DSN)
++/* messages. To override the built-in templates, specify a
++/* template file at the end of the command line, or specify a
++/* template file in main.cf with the \fBbounce_template_file\fR
++/* parameter. To force selection of the built-in templates,
++/* specify an empty template file name (in shell language:
++/* "").
++/*
++/* This feature is available with Postfix 2.3 and later.
++/* .IP \fB-v\fR
++/* Enable verbose logging for debugging purposes. Multiple \fB-v\fR
++/* options make the software increasingly verbose.
++/* .IP \fB-#\fR
++/* Edit the \fBmain.cf\fR configuration file. The file is copied
++/* to a temporary file then renamed into place. The parameters
++/* specified on the command line are commented-out, so that they
++/* revert to their default values. Specify a list of parameter
++/* names, not name=value pairs. There is no \fBpostconf\fR command
++/* to perform the reverse operation.
++/*
++/* This feature is available with Postfix 2.6 and later.
++/* DIAGNOSTICS
++/* Problems are reported to the standard error stream.
++/* ENVIRONMENT
++/* .ad
++/* .fi
++/* .IP \fBMAIL_CONFIG\fR
++/* Directory with Postfix configuration files.
++/* CONFIGURATION PARAMETERS
++/* .ad
++/* .fi
++/* The following \fBmain.cf\fR parameters are especially relevant to
++/* this program.
++/*
++/* The text below provides only a parameter summary. See
++/* \fBpostconf\fR(5) for more details including examples.
++/* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
++/* The default location of the Postfix main.cf and master.cf
++/* configuration files.
++/* .IP "\fBbounce_template_file (empty)\fR"
++/* Pathname of a configuration file with bounce message templates.
++/* FILES
++/* /etc/postfix/main.cf, Postfix configuration parameters
++/* SEE ALSO
++/* bounce(5), bounce template file format
++/* postconf(5), configuration parameters
++/* README FILES
++/* .ad
++/* .fi
++/* Use "\fBpostconf readme_directory\fR" or
++/* "\fBpostconf html_directory\fR" to locate this information.
++/* .na
++/* .nf
++/* DATABASE_README, Postfix lookup table overview
++/* LICENSE
++/* .ad
++/* .fi
++/* The Secure Mailer license must be distributed with this software.
++/* AUTHOR(S)
++/* Wietse Venema
++/* IBM T.J. Watson Research
++/* P.O. Box 704
++/* Yorktown Heights, NY 10598, USA
++/*--*/
++
++/* System library. */
++
++#include <sys_defs.h>
++#include <sys/stat.h>
++#include <stdio.h> /* rename() */
++#include <pwd.h>
++#include <string.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <ctype.h>
++
++#ifdef USE_PATHS_H
++#include <paths.h>
++#endif
++
++/* Utility library. */
++
++#include <msg.h>
++#include <vstream.h>
++#include <msg_vstream.h>
++#include <get_hostname.h>
++#include <stringops.h>
++#include <htable.h>
++#include <dict.h>
++#include <safe.h>
++#include <mymalloc.h>
++#include <argv.h>
++#include <split_at.h>
++#include <vstring_vstream.h>
++#include <myflock.h>
++#include <inet_proto.h>
++#include <argv.h>
++#include <edit_file.h>
++
++/* Global library. */
++
++#include <mynetworks.h>
++#include <mail_conf.h>
++#include <mail_dict.h>
++#include <mail_proto.h>
++#include <mail_version.h>
++#include <mail_params.h>
++#include <mail_addr.h>
++#include <mbox_conf.h>
++#include <mail_run.h>
++
++/* XSASL library. */
++
++#include <xsasl.h>
++
++ /*
++ * What we're supposed to be doing.
++ */
++#define SHOW_NONDEF (1<<0) /* show non-default settings */
++#define SHOW_DEFS (1<<1) /* show default setting */
++#define SHOW_NAME (1<<2) /* show parameter name */
++#define SHOW_MAPS (1<<3) /* show map types */
++#define EDIT_MAIN (1<<4) /* edit main.cf */
++#define SHOW_LOCKS (1<<5) /* show mailbox lock methods */
++#define SHOW_EVAL (1<<6) /* expand right-hand sides */
++#define SHOW_SASL_SERV (1<<7) /* show server auth plugin types */
++#define SHOW_SASL_CLNT (1<<8) /* show client auth plugin types */
++#define COMMENT_OUT (1<<9) /* #-out selected main.cf entries */
++
++ /*
++ * Lookup table for in-core parameter info.
++ */
++HTABLE *param_table;
++
++ /*
++ * Lookup table for external parameter info.
++ */
++DICT *text_table;
++
++ /*
++ * Declarations generated by scanning actual C source files.
++ */
++#include "time_vars.h"
++#include "bool_vars.h"
++#include "int_vars.h"
++#include "str_vars.h"
++#include "raw_vars.h"
++#include "nint_vars.h"
++
++ /*
++ * Manually extracted.
++ */
++#include "auto_vars.h"
++#include "install_vars.h"
++
++ /*
++ * Lookup tables generated by scanning actual C source files.
++ */
++static const CONFIG_TIME_TABLE time_table[] = {
++#include "time_table.h"
++ 0,
++};
++
++static const CONFIG_BOOL_TABLE bool_table[] = {
++#include "bool_table.h"
++ 0,
++};
++
++static const CONFIG_INT_TABLE int_table[] = {
++#include "int_table.h"
++ 0,
++};
++
++static const CONFIG_STR_TABLE str_table[] = {
++#include "str_table.h"
++#include "auto_table.h" /* XXX */
++#include "install_table.h"
++ 0,
++};
++
++static const CONFIG_RAW_TABLE raw_table[] = {
++#include "raw_table.h"
++ 0,
++};
++
++static const CONFIG_NINT_TABLE nint_table[] = {
++#include "nint_table.h"
++ 0,
++};
++
++ /*
++ * Parameters with default values obtained via function calls.
++ */
++char *var_myhostname;
++char *var_mydomain;
++char *var_mynetworks;
++
++static const char *check_myhostname(void);
++static const char *check_mydomainname(void);
++static const char *check_mynetworks(void);
++
++static const CONFIG_STR_FN_TABLE str_fn_table[] = {
++ VAR_MYHOSTNAME, check_myhostname, &var_myhostname, 1, 0,
++ VAR_MYDOMAIN, check_mydomainname, &var_mydomain, 1, 0,
++ 0,
++};
++static const CONFIG_STR_FN_TABLE str_fn_table_2[] = {
++ VAR_MYNETWORKS, check_mynetworks, &var_mynetworks, 1, 0,
++ 0,
++};
++
++ /*
++ * XXX Global so that call-backs can see it.
++ */
++static int cmd_mode = SHOW_NAME;
++
++/* check_myhostname - lookup hostname and validate */
++
++static const char *check_myhostname(void)
++{
++ static const char *name;
++ const char *dot;
++ const char *domain;
++
++ /*
++ * Use cached result.
++ */
++ if (name)
++ return (name);
++
++ /*
++ * If the local machine name is not in FQDN form, try to append the
++ * contents of $mydomain.
++ */
++ name = get_hostname();
++ if ((dot = strchr(name, '.')) == 0) {
++ if ((domain = mail_conf_lookup_eval(VAR_MYDOMAIN)) == 0)
++ domain = DEF_MYDOMAIN;
++ name = concatenate(name, ".", domain, (char *) 0);
++ }
++ return (name);
++}
++
++/* get_myhostname - look up and store my hostname */
++
++static void get_myhostname(void)
++{
++ const char *name;
++
++ if ((name = mail_conf_lookup_eval(VAR_MYHOSTNAME)) == 0)
++ name = check_myhostname();
++ var_myhostname = mystrdup(name);
++}
++
++/* check_mydomainname - lookup domain name and validate */
++
++static const char *check_mydomainname(void)
++{
++ char *dot;
++
++ /*
++ * Use the hostname when it is not a FQDN ("foo"), or when the hostname
++ * actually is a domain name ("foo.com").
++ */
++ if (var_myhostname == 0)
++ get_myhostname();
++ if ((dot = strchr(var_myhostname, '.')) == 0 || strchr(dot + 1, '.') == 0)
++ return (DEF_MYDOMAIN);
++ return (dot + 1);
++}
++
++/* check_mynetworks - lookup network address list */
++
++static const char *check_mynetworks(void)
++{
++ INET_PROTO_INFO *proto_info;
++ const char *junk;
++
++ if (var_inet_interfaces == 0) {
++ if ((cmd_mode & SHOW_DEFS)
++ || (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0)
++ junk = DEF_INET_INTERFACES;
++ var_inet_interfaces = mystrdup(junk);
++ }
++ if (var_mynetworks_style == 0) {
++ if ((cmd_mode & SHOW_DEFS)
++ || (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0)
++ junk = DEF_MYNETWORKS_STYLE;
++ var_mynetworks_style = mystrdup(junk);
++ }
++ if (var_inet_protocols == 0) {
++ if ((cmd_mode & SHOW_DEFS)
++ || (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0)
++ junk = DEF_INET_PROTOCOLS;
++ var_inet_protocols = mystrdup(junk);
++ proto_info = inet_proto_init(VAR_INET_PROTOCOLS, var_inet_protocols);
++ }
++ return (mynetworks());
++}
++
++/* edit_parameters - edit parameter file */
++
++static void edit_parameters(int cmd_mode, int argc, char **argv)
++{
++ char *config_dir;
++ char *path;
++ EDIT_FILE *ep;
++ VSTREAM *src;
++ VSTREAM *dst;
++ VSTRING *buf = vstring_alloc(100);
++ VSTRING *key = vstring_alloc(10);
++ char *cp;
++ char *edit_key;
++ char *edit_val;
++ HTABLE *table;
++ struct cvalue {
++ char *value;
++ int found;
++ };
++ struct cvalue *cvalue;
++ HTABLE_INFO **ht_info;
++ HTABLE_INFO **ht;
++ int interesting;
++ const char *err;
++
++ /*
++ * Store command-line parameters for quick lookup.
++ */
++ table = htable_create(argc);
++ while ((cp = *argv++) != 0) {
++ if (strchr(cp, '\n') != 0)
++ msg_fatal("-e or -# accepts no multi-line input");
++ while (ISSPACE(*cp))
++ cp++;
++ if (*cp == '#')
++ msg_fatal("-e or -# accepts no comment input");
++ if (cmd_mode & EDIT_MAIN) {
++ if ((err = split_nameval(cp, &edit_key, &edit_val)) != 0)
++ msg_fatal("%s: \"%s\"", err, cp);
++ } else if (cmd_mode & COMMENT_OUT) {
++ if (*cp == 0)
++ msg_fatal("-# requires non-blank parameter names");
++ if (strchr(cp, '=') != 0)
++ msg_fatal("-# requires parameter names only");
++ edit_key = mystrdup(cp);
++ trimblanks(edit_key, 0);
++ edit_val = 0;
++ } else {
++ msg_panic("edit_parameters: unknown mode %d", cmd_mode);
++ }
++ cvalue = (struct cvalue *) mymalloc(sizeof(*cvalue));
++ cvalue->value = edit_val;
++ cvalue->found = 0;
++ htable_enter(table, edit_key, (char *) cvalue);
++ }
++
++ /*
++ * XXX Avoid code duplication by better code decomposition.
++ */
++ if (var_config_dir)
++ myfree(var_config_dir);
++ var_config_dir = mystrdup((config_dir = safe_getenv(CONF_ENV_PATH)) != 0 ?
++ config_dir : DEF_CONFIG_DIR); /* XXX */
++ set_mail_conf_str(VAR_CONFIG_DIR, var_config_dir);
++
++ /*
++ * Open a temp file for the result. This uses a deterministic name so we
++ * don't leave behind thrash with random names.
++ */
++ path = concatenate(var_config_dir, "/", "main.cf", (char *) 0);
++ if ((ep = edit_file_open(path, O_CREAT | O_WRONLY, 0644)) == 0)
++ msg_fatal("open %s%s: %m", path, EDIT_FILE_SUFFIX);
++ dst = ep->tmp_fp;
++
++ /*
++ * Open the original file for input.
++ */
++ if ((src = vstream_fopen(path, O_RDONLY, 0)) == 0) {
++ /* OK to delete, since we control the temp file name exclusively. */
++ (void) unlink(ep->tmp_path);
++ msg_fatal("open %s for reading: %m", path);
++ }
++
++ /*
++ * Copy original file to temp file, while replacing parameters on the
++ * fly. Issue warnings for names found multiple times.
++ */
++#define STR(x) vstring_str(x)
++
++ interesting = 0;
++ while (vstring_get(buf, src) != VSTREAM_EOF) {
++ for (cp = STR(buf); ISSPACE(*cp) /* including newline */ ; cp++)
++ /* void */ ;
++ /* Copy comment, all-whitespace, or empty line. */
++ if (*cp == '#' || *cp == 0) {
++ vstream_fputs(STR(buf), dst);
++ }
++ /* Copy, skip or replace continued text. */
++ else if (cp > STR(buf)) {
++ if (interesting == 0)
++ vstream_fputs(STR(buf), dst);
++ else if (cmd_mode & COMMENT_OUT)
++ vstream_fprintf(dst, "#%s", STR(buf));
++ }
++ /* Copy or replace start of logical line. */
++ else {
++ vstring_strncpy(key, cp, strcspn(cp, " \t\r\n="));
++ cvalue = (struct cvalue *) htable_find(table, STR(key));
++ if ((interesting = !!cvalue) != 0) {
++ if (cvalue->found++ == 1)
++ msg_warn("%s: multiple entries for \"%s\"", path, STR(key));
++ if (cmd_mode & EDIT_MAIN)
++ vstream_fprintf(dst, "%s = %s\n", STR(key), cvalue->value);
++ else if (cmd_mode & COMMENT_OUT)
++ vstream_fprintf(dst, "#%s", cp);
++ else
++ msg_panic("edit_parameters: unknown mode %d", cmd_mode);
++ } else {
++ vstream_fputs(STR(buf), dst);
++ }
++ }
++ }
++
++ /*
++ * Generate new entries for parameters that were not found.
++ */
++ if (cmd_mode & EDIT_MAIN) {
++ for (ht_info = ht = htable_list(table); *ht; ht++) {
++ cvalue = (struct cvalue *) ht[0]->value;
++ if (cvalue->found == 0)
++ vstream_fprintf(dst, "%s = %s\n", ht[0]->key, cvalue->value);
++ }
++ myfree((char *) ht_info);
++ }
++
++ /*
++ * When all is well, rename the temp file to the original one.
++ */
++ if (vstream_fclose(src))
++ msg_fatal("read %s: %m", path);
++ if (edit_file_close(ep) != 0)
++ msg_fatal("close %s%s: %m", path, EDIT_FILE_SUFFIX);
++
++ /*
++ * Cleanup.
++ */
++ myfree(path);
++ vstring_free(buf);
++ vstring_free(key);
++ htable_free(table, myfree);
++}
++
++/* read_parameters - read parameter info from file */
++
++static void read_parameters(void)
++{
++ char *config_dir;
++ char *path;
++
++ /*
++ * A direct rip-off of mail_conf_read(). XXX Avoid code duplication by
++ * better code decomposition.
++ */
++ dict_unknown_allowed = 1;
++ if (var_config_dir)
++ myfree(var_config_dir);
++ var_config_dir = mystrdup((config_dir = safe_getenv(CONF_ENV_PATH)) != 0 ?
++ config_dir : DEF_CONFIG_DIR); /* XXX */
++ set_mail_conf_str(VAR_CONFIG_DIR, var_config_dir);
++ path = concatenate(var_config_dir, "/", "main.cf", (char *) 0);
++ dict_load_file(CONFIG_DICT, path);
++ myfree(path);
++}
++
++/* set_parameters - set parameter values from default or explicit setting */
++
++static void set_parameters(void)
++{
++
++ /*
++ * Populate the configuration parameter dictionary with default settings
++ * or with actual settings.
++ *
++ * Iterate over each entry in str_fn_table, str_fn_table_2, time_table,
++ * bool_table, int_table, str_table, and raw_table. Look up each
++ * parameter name in the configuration parameter dictionary. If the
++ * parameter is not set, take the default value, or take the value from
++ * main.cf, without doing $name expansions. This includes converting
++ * default values from numeric/boolean internal forms to external string
++ * form.
++ *
++ * Once the configuration parameter dictionary is populated, printing a
++ * parameter setting is a matter of querying the configuration parameter
++ * dictionary, optionally expanding of $name values, and printing the
++ * result.
++ */
++}
++
++/* hash_parameters - hash all parameter names so we can find and sort them */
++
++static void hash_parameters(void)
++{
++ const CONFIG_TIME_TABLE *ctt;
++ const CONFIG_BOOL_TABLE *cbt;
++ const CONFIG_INT_TABLE *cit;
++ const CONFIG_STR_TABLE *cst;
++ const CONFIG_STR_FN_TABLE *csft;
++ const CONFIG_RAW_TABLE *rst;
++ const CONFIG_NINT_TABLE *nst;
++
++ param_table = htable_create(100);
++
++ for (ctt = time_table; ctt->name; ctt++)
++ htable_enter(param_table, ctt->name, (char *) ctt);
++ for (cbt = bool_table; cbt->name; cbt++)
++ htable_enter(param_table, cbt->name, (char *) cbt);
++ for (cit = int_table; cit->name; cit++)
++ htable_enter(param_table, cit->name, (char *) cit);
++ for (cst = str_table; cst->name; cst++)
++ htable_enter(param_table, cst->name, (char *) cst);
++ for (csft = str_fn_table; csft->name; csft++)
++ htable_enter(param_table, csft->name, (char *) csft);
++ for (csft = str_fn_table_2; csft->name; csft++)
++ htable_enter(param_table, csft->name, (char *) csft);
++ for (rst = raw_table; rst->name; rst++)
++ htable_enter(param_table, rst->name, (char *) rst);
++ for (nst = nint_table; nst->name; nst++)
++ htable_enter(param_table, nst->name, (char *) nst);
++}
++
++/* show_strval - show string-valued parameter */
++
++static void show_strval(int mode, const char *name, const char *value)
++{
++ if (mode & SHOW_EVAL)
++ value = mail_conf_eval(value);
++
++ if (mode & SHOW_NAME) {
++ vstream_printf("%s = %s\n", name, value);
++ } else {
++ vstream_printf("%s\n", value);
++ }
++}
++
++/* show_intval - show integer-valued parameter */
++
++static void show_intval(int mode, const char *name, int value)
++{
++ if (mode & SHOW_NAME) {
++ vstream_printf("%s = %d\n", name, value);
++ } else {
++ vstream_printf("%d\n", value);
++ }
++}
++
++/* print_bool - print boolean parameter */
++
++static void print_bool(int mode, CONFIG_BOOL_TABLE *cbt)
++{
++ const char *value;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, cbt->name, cbt->defval ? "yes" : "no");
++ } else {
++ value = dict_lookup(CONFIG_DICT, cbt->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, cbt->name, cbt->defval ? "yes" : "no");
++ } else {
++ show_strval(mode, cbt->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, cbt->name, value);
++ }
++ }
++}
++
++/* print_time - print relative time parameter */
++
++static void print_time(int mode, CONFIG_TIME_TABLE *ctt)
++{
++ const char *value;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, ctt->name, ctt->defval);
++ } else {
++ value = dict_lookup(CONFIG_DICT, ctt->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, ctt->name, ctt->defval);
++ } else {
++ show_strval(mode, ctt->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, ctt->name, value);
++ }
++ }
++}
++
++/* print_int - print integer parameter */
++
++static void print_int(int mode, CONFIG_INT_TABLE *cit)
++{
++ const char *value;
++
++ if (mode & SHOW_DEFS) {
++ show_intval(mode, cit->name, cit->defval);
++ } else {
++ value = dict_lookup(CONFIG_DICT, cit->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_intval(mode, cit->name, cit->defval);
++ } else {
++ show_strval(mode, cit->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, cit->name, value);
++ }
++ }
++}
++
++/* print_str - print string parameter */
++
++static void print_str(int mode, CONFIG_STR_TABLE *cst)
++{
++ const char *value;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, cst->name, cst->defval);
++ } else {
++ value = dict_lookup(CONFIG_DICT, cst->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, cst->name, cst->defval);
++ } else {
++ show_strval(mode, cst->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, cst->name, value);
++ }
++ }
++}
++
++/* print_str_fn - print string-function parameter */
++
++static void print_str_fn(int mode, CONFIG_STR_FN_TABLE *csft)
++{
++ const char *value;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, csft->name, csft->defval());
++ } else {
++ value = dict_lookup(CONFIG_DICT, csft->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, csft->name, csft->defval());
++ } else {
++ show_strval(mode, csft->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, csft->name, value);
++ }
++ }
++}
++
++/* print_str_fn_2 - print string-function parameter */
++
++static void print_str_fn_2(int mode, CONFIG_STR_FN_TABLE *csft)
++{
++ const char *value;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, csft->name, csft->defval());
++ } else {
++ value = dict_lookup(CONFIG_DICT, csft->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, csft->name, csft->defval());
++ } else {
++ show_strval(mode, csft->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, csft->name, value);
++ }
++ }
++}
++
++/* print_raw - print raw string parameter */
++
++static void print_raw(int mode, CONFIG_RAW_TABLE * rst)
++{
++ const char *value;
++
++ if (mode & SHOW_EVAL)
++ msg_warn("parameter %s expands at run-time", rst->name);
++ mode &= ~SHOW_EVAL;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, rst->name, rst->defval);
++ } else {
++ value = dict_lookup(CONFIG_DICT, rst->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, rst->name, rst->defval);
++ } else {
++ show_strval(mode, rst->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, rst->name, value);
++ }
++ }
++}
++
++/* print_nint - print new integer parameter */
++
++static void print_nint(int mode, CONFIG_NINT_TABLE * rst)
++{
++ const char *value;
++
++ if (mode & SHOW_EVAL)
++ msg_warn("parameter %s expands at run-time", rst->name);
++ mode &= ~SHOW_EVAL;
++
++ if (mode & SHOW_DEFS) {
++ show_strval(mode, rst->name, rst->defval);
++ } else {
++ value = dict_lookup(CONFIG_DICT, rst->name);
++ if ((mode & SHOW_NONDEF) == 0) {
++ if (value == 0) {
++ show_strval(mode, rst->name, rst->defval);
++ } else {
++ show_strval(mode, rst->name, value);
++ }
++ } else {
++ if (value != 0)
++ show_strval(mode, rst->name, value);
++ }
++ }
++}
++
++/* print_parameter - show specific parameter */
++
++static void print_parameter(int mode, char *ptr)
++{
++
++#define INSIDE(p,t) (ptr >= (char *) t && ptr < ((char *) t) + sizeof(t))
++
++ /*
++ * This is gross, but the best we can do on short notice.
++ */
++ if (INSIDE(ptr, time_table))
++ print_time(mode, (CONFIG_TIME_TABLE *) ptr);
++ if (INSIDE(ptr, bool_table))
++ print_bool(mode, (CONFIG_BOOL_TABLE *) ptr);
++ if (INSIDE(ptr, int_table))
++ print_int(mode, (CONFIG_INT_TABLE *) ptr);
++ if (INSIDE(ptr, str_table))
++ print_str(mode, (CONFIG_STR_TABLE *) ptr);
++ if (INSIDE(ptr, str_fn_table))
++ print_str_fn(mode, (CONFIG_STR_FN_TABLE *) ptr);
++ if (INSIDE(ptr, str_fn_table_2))
++ print_str_fn_2(mode, (CONFIG_STR_FN_TABLE *) ptr);
++ if (INSIDE(ptr, raw_table))
++ print_raw(mode, (CONFIG_RAW_TABLE *) ptr);
++ if (INSIDE(ptr, nint_table))
++ print_nint(mode, (CONFIG_NINT_TABLE *) ptr);
++ if (msg_verbose)
++ vstream_fflush(VSTREAM_OUT);
++}
++
++/* comp_names - qsort helper */
++
++static int comp_names(const void *a, const void *b)
++{
++ HTABLE_INFO **ap = (HTABLE_INFO **) a;
++ HTABLE_INFO **bp = (HTABLE_INFO **) b;
++
++ return (strcmp(ap[0]->key, bp[0]->key));
++}
++
++/* show_maps - show available maps */
++
++static void show_maps(void)
++{
++ ARGV *maps_argv;
++ int i;
++
++ maps_argv = dict_mapnames();
++ for (i = 0; i < maps_argv->argc; i++)
++ vstream_printf("%s\n", maps_argv->argv[i]);
++ argv_free(maps_argv);
++}
++
++/* show_locks - show available mailbox locking methods */
++
++static void show_locks(void)
++{
++ ARGV *locks_argv;
++ int i;
++
++ locks_argv = mbox_lock_names();
++ for (i = 0; i < locks_argv->argc; i++)
++ vstream_printf("%s\n", locks_argv->argv[i]);
++ argv_free(locks_argv);
++}
++
++/* show_sasl - show SASL plug-in types */
++
++static void show_sasl(int what)
++{
++ ARGV *sasl_argv;
++ int i;
++
++ sasl_argv = (what & SHOW_SASL_SERV) ? xsasl_server_types() :
++ xsasl_client_types();
++ for (i = 0; i < sasl_argv->argc; i++)
++ vstream_printf("%s\n", sasl_argv->argv[i]);
++ argv_free(sasl_argv);
++}
++
++/* show_parameters - show parameter info */
++
++static void show_parameters(int mode, char **names)
++{
++ HTABLE_INFO **list;
++ HTABLE_INFO **ht;
++ char **namep;
++ char *value;
++
++ /*
++ * Show all parameters.
++ */
++ if (*names == 0) {
++ list = htable_list(param_table);
++ qsort((char *) list, param_table->used, sizeof(*list), comp_names);
++ for (ht = list; *ht; ht++)
++ print_parameter(mode, ht[0]->value);
++ myfree((char *) list);
++ return;
++ }
++
++ /*
++ * Show named parameters.
++ */
++ for (namep = names; *namep; namep++) {
++ if ((value = htable_find(param_table, *namep)) == 0) {
++ msg_warn("%s: unknown parameter", *namep);
++ } else {
++ print_parameter(mode, value);
++ }
++ }
++}
++
++MAIL_VERSION_STAMP_DECLARE;
++
++/* main */
++
++int main(int argc, char **argv)
++{
++ int ch;
++ int fd;
++ struct stat st;
++ int junk;
++ ARGV *ext_argv = 0;
++
++ /*
++ * Fingerprint executables and core dumps.
++ */
++ MAIL_VERSION_STAMP_ALLOCATE;
++
++ /*
++ * Be consistent with file permissions.
++ */
++ umask(022);
++
++ /*
++ * To minimize confusion, make sure that the standard file descriptors
++ * are open before opening anything else. XXX Work around for 44BSD where
++ * fstat can return EBADF on an open file descriptor.
++ */
++ for (fd = 0; fd < 3; fd++)
++ if (fstat(fd, &st) == -1
++ && (close(fd), open("/dev/null", O_RDWR, 0)) != fd)
++ msg_fatal("open /dev/null: %m");
++
++ /*
++ * Set up logging.
++ */
++ msg_vstream_init(argv[0], VSTREAM_ERR);
++
++ /*
++ * Parse JCL.
++ */
++ while ((ch = GETOPT(argc, argv, "aAbc:deE#hmlntv")) > 0) {
++ switch (ch) {
++ case 'a':
++ cmd_mode |= SHOW_SASL_SERV;
++ break;
++ case 'A':
++ cmd_mode |= SHOW_SASL_CLNT;
++ break;
++ case 'b':
++ if (ext_argv)
++ msg_fatal("specify one of -b and -t");
++ ext_argv = argv_alloc(2);
++ argv_add(ext_argv, "bounce", "-SVnexpand_templates", (char *) 0);
++ break;
++ case 'c':
++ if (setenv(CONF_ENV_PATH, optarg, 1) < 0)
++ msg_fatal("out of memory");
++ break;
++ case 'd':
++ cmd_mode |= SHOW_DEFS;
++ break;
++ case 'e':
++ cmd_mode |= EDIT_MAIN;
++ break;
++
++ /*
++ * People, this does not work unless you properly handle default
++ * settings. For example, fast_flush_domains = $relay_domains
++ * must not evaluate to the empty string when relay_domains is
++ * left at its default setting of $mydestination.
++ */
++#if 0
++ case 'E':
++ cmd_mode |= SHOW_EVAL;
++ break;
++#endif
++ case '#':
++ cmd_mode = COMMENT_OUT;
++ break;
++
++ case 'h':
++ cmd_mode &= ~SHOW_NAME;
++ break;
++ case 'l':
++ cmd_mode |= SHOW_LOCKS;
++ break;
++ case 'm':
++ cmd_mode |= SHOW_MAPS;
++ break;
++ case 'n':
++ cmd_mode |= SHOW_NONDEF;
++ break;
++ case 't':
++ if (ext_argv)
++ msg_fatal("specify one of -b and -t");
++ ext_argv = argv_alloc(2);
++ argv_add(ext_argv, "bounce", "-SVndump_templates", (char *) 0);
++ break;
++ case 'v':
++ msg_verbose++;
++ break;
++ default:
++ msg_fatal("usage: %s [-a (server SASL types)] [-A (client SASL types)] [-b (bounce templates)] [-c config_dir] [-d (defaults)] [-e (edit)] [-# (comment-out)] [-h (no names)] [-l (lock types)] [-m (map types)] [-n (non-defaults)] [-v] [name...]", argv[0]);
++ }
++ }
++
++ /*
++ * Sanity check.
++ */
++ junk = (cmd_mode & (SHOW_DEFS | SHOW_NONDEF | SHOW_MAPS | SHOW_LOCKS | EDIT_MAIN | SHOW_SASL_SERV | SHOW_SASL_CLNT | COMMENT_OUT));
++ if (junk != 0 && ((junk != SHOW_DEFS && junk != SHOW_NONDEF
++ && junk != SHOW_MAPS && junk != SHOW_LOCKS && junk != EDIT_MAIN
++ && junk != SHOW_SASL_SERV && junk != SHOW_SASL_CLNT
++ && junk != COMMENT_OUT)
++ || ext_argv != 0))
++ msg_fatal("specify one of -a, -A, -b, -d, -e, -#, -m, -l and -n");
++
++ /*
++ * Display bounce template information and exit.
++ */
++ if (ext_argv) {
++ if (argv[optind]) {
++ if (argv[optind + 1])
++ msg_fatal("options -b and -t require at most one template file");
++ argv_add(ext_argv, "-o",
++ concatenate(VAR_BOUNCE_TMPL, "=",
++ argv[optind], (char *) 0),
++ (char *) 0);
++ }
++ /* Grr... */
++ argv_add(ext_argv, "-o",
++ concatenate(VAR_QUEUE_DIR, "=", ".", (char *) 0),
++ (char *) 0);
++ mail_conf_read();
++ mail_run_replace(var_daemon_dir, ext_argv->argv);
++ /* NOTREACHED */
++ }
++
++ /*
++ * If showing map types, show them and exit
++ */
++ if (cmd_mode & SHOW_MAPS) {
++ mail_dict_init();
++ show_maps();
++ }
++
++ /*
++ * If showing locking methods, show them and exit
++ */
++ else if (cmd_mode & SHOW_LOCKS) {
++ show_locks();
++ }
++
++ /*
++ * If showing SASL plug-in types, show them and exit
++ */
++ else if (cmd_mode & SHOW_SASL_SERV) {
++ show_sasl(SHOW_SASL_SERV);
++ } else if (cmd_mode & SHOW_SASL_CLNT) {
++ show_sasl(SHOW_SASL_CLNT);
++ }
++
++ /*
++ * Edit main.cf.
++ */
++ else if (cmd_mode & (EDIT_MAIN | COMMENT_OUT)) {
++ edit_parameters(cmd_mode, argc - optind, argv + optind);
++ }
++
++ /*
++ * If showing non-default values, read main.cf.
++ */
++ else {
++ if ((cmd_mode & SHOW_DEFS) == 0) {
++ read_parameters();
++ set_parameters();
++ }
++
++ /*
++ * Throw together all parameters and show the asked values.
++ */
++ hash_parameters();
++ show_parameters(cmd_mode, argv + optind);
++ }
++ vstream_fflush(VSTREAM_OUT);
++ exit(0);
++}
+diff -ruN a/src/postmap/postmap.c b/src/postmap/postmap.c
+--- a/src/postmap/postmap.c 2009-06-01 12:27:45.000000000 +0000
++++ b/src/postmap/postmap.c 2009-06-01 13:08:26.000000000 +0000
+@@ -5,7 +5,7 @@
+ /* Postfix lookup table management
+ /* SYNOPSIS
+ /* .fi
+-/* \fBpostmap\fR [\fB-Nbfhimnoprsvw\fR] [\fB-c \fIconfig_dir\fR]
++/* \fBpostmap\fR [\fB-Nbfhimnoprsuvw\fR] [\fB-c \fIconfig_dir\fR]
+ /* [\fB-d \fIkey\fR] [\fB-q \fIkey\fR]
+ /* [\fIfile_type\fR:]\fIfile_name\fR ...
+ /* DESCRIPTION
+@@ -151,6 +151,8 @@
+ /* .sp
+ /* This feature is available in Postfix version 2.2 and later,
+ /* and is not available for all database types.
++/* .IP \fB-u\fR
++/* Upgrade the database to the current version.
+ /* .IP \fB-v\fR
+ /* Enable verbose logging for debugging purposes. Multiple \fB-v\fR
+ /* options make the software increasingly verbose.
+@@ -723,6 +725,18 @@
+ dict_close(dict);
+ }
+
++/* postmap_upgrade - upgrade a map */
++
++static int postmap_upgrade(const char *map_type, const char *map_name)
++{
++ DICT *dict;
++
++ dict = dict_open3(map_type, map_name, O_RDWR,
++ DICT_FLAG_LOCK|DICT_FLAG_UPGRADE);
++ dict_close(dict);
++ return (dict != 0);
++}
++
+ /* usage - explain */
+
+ static NORETURN usage(char *myname)
+@@ -743,6 +757,7 @@
+ int postmap_flags = POSTMAP_FLAG_AS_OWNER | POSTMAP_FLAG_SAVE_PERM;
+ int open_flags = O_RDWR | O_CREAT | O_TRUNC;
+ int dict_flags = DICT_FLAG_DUP_WARN | DICT_FLAG_FOLD_FIX;
++ int upgrade = 0;
+ char *query = 0;
+ char *delkey = 0;
+ int sequence = 0;
+@@ -787,7 +802,7 @@
+ /*
+ * Parse JCL.
+ */
+- while ((ch = GETOPT(argc, argv, "Nbc:d:fhimnopq:rsvw")) > 0) {
++ while ((ch = GETOPT(argc, argv, "Nbc:d:fhimnopq:rsuvw")) > 0) {
+ switch (ch) {
+ default:
+ usage(argv[0]);
+@@ -804,8 +819,8 @@
+ msg_fatal("out of memory");
+ break;
+ case 'd':
+- if (sequence || query || delkey)
+- msg_fatal("specify only one of -s -q or -d");
++ if (sequence || query || delkey || upgrade)
++ msg_fatal("specify only one of -s -q -u or -d");
+ delkey = optarg;
+ break;
+ case 'f':
+@@ -831,8 +846,8 @@
+ postmap_flags &= ~POSTMAP_FLAG_SAVE_PERM;
+ break;
+ case 'q':
+- if (sequence || query || delkey)
+- msg_fatal("specify only one of -s -q or -d");
++ if (sequence || query || delkey || upgrade)
++ msg_fatal("specify only one of -s -q -u or -d");
+ query = optarg;
+ break;
+ case 'r':
+@@ -840,10 +855,15 @@
+ dict_flags |= DICT_FLAG_DUP_REPLACE;
+ break;
+ case 's':
+- if (query || delkey)
+- msg_fatal("specify only one of -s or -q or -d");
++ if (query || delkey || upgrade)
++ msg_fatal("specify only one of -s or -q or -u or -d");
+ sequence = 1;
+ break;
++ case 'u':
++ if (sequence || query || delkey || upgrade)
++ msg_fatal("specify only one of -s -q -u or -d");
++ upgrade=1;
++ break;
+ case 'v':
+ msg_verbose++;
+ break;
+@@ -914,6 +934,21 @@
+ exit(0);
+ }
+ exit(1);
++ } else if (upgrade) { /* Upgrade the map(s) */
++ int success = 1;
++ if (optind + 1 > argc)
++ usage(argv[0]);
++ while (optind < argc) {
++ if ((path_name = split_at(argv[optind], ':')) != 0) {
++ success &= postmap_upgrade(argv[optind], path_name);
++ } else {
++ success &= postmap_upgrade(var_db_type, path_name);
++ }
++ if (!success)
++ exit(1);
++ optind++;
++ }
++ exit(0);
+ } else { /* create/update map(s) */
+ if (optind + 1 > argc)
+ usage(argv[0]);
+diff -ruN a/src/tls/Makefile.in b/src/tls/Makefile.in
+--- a/src/tls/Makefile.in 2009-06-01 12:27:45.000000000 +0000
++++ b/src/tls/Makefile.in 2009-06-01 13:08:26.000000000 +0000
+@@ -22,7 +22,7 @@
+ INC_DIR = ../../include
+ MAKES =
+
+-.c.o:; $(CC) $(CFLAGS) -c $*.c
++.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
+
+ all: $(LIB)
+
+@@ -38,12 +38,10 @@
+ root_tests:
+
+ $(LIB): $(OBJS)
+- $(AR) $(ARFL) $(LIB) $?
+- $(RANLIB) $(LIB)
++ gcc -shared -Wl,-soname,libpostfix-tls.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
+
+ $(LIB_DIR)/$(LIB): $(LIB)
+ cp $(LIB) $(LIB_DIR)
+- $(RANLIB) $(LIB_DIR)/$(LIB)
+
+ update: $(LIB_DIR)/$(LIB) $(HDRS)
+ -for i in $(HDRS); \
+diff -ruN a/src/util/Makefile.in b/src/util/Makefile.in
+--- a/src/util/Makefile.in 2009-06-01 12:27:45.000000000 +0000
++++ b/src/util/Makefile.in 2009-06-01 13:08:26.000000000 +0000
+@@ -31,21 +31,23 @@
+ vstream_popen.c vstring.c vstring_vstream.c watchdog.c writable.c \
+ write_buf.c write_wait.c sane_basename.c format_tv.c allspace.c \
+ allascii.c load_file.c killme_after.c vstream_tweak.c upass_connect.c \
+- upass_listen.c upass_trigger.c edit_file.c inet_windowsize.c
++ upass_listen.c upass_trigger.c edit_file.c inet_windowsize.c \
++ load_lib.c
+ OBJS = alldig.o allprint.o argv.o argv_split.o attr_clnt.o attr_print0.o \
+ attr_print64.o attr_print_plain.o attr_scan0.o attr_scan64.o \
+ attr_scan_plain.o auto_clnt.o base64_code.o basename.o binhash.o \
+ chroot_uid.o cidr_match.o clean_env.o close_on_exec.o concatenate.o \
+ ctable.o dict.o dict_alloc.o dict_cdb.o dict_cidr.o dict_db.o \
+ dict_dbm.o dict_debug.o dict_env.o dict_ht.o dict_ni.o dict_nis.o \
+- dict_nisplus.o dict_open.o dict_pcre.o dict_regexp.o dict_sdbm.o \
+- dict_static.o dict_tcp.o dict_unix.o dir_forest.o doze.o dummy_read.o \
++ dict_nisplus.o dict_open.o dict_regexp.o \
++ dict_static.o dict_unix.o dir_forest.o doze.o dummy_read.o \
+ dummy_write.o duplex_pipe.o environ.o events.o exec_command.o \
+ fifo_listen.o fifo_trigger.o file_limit.o find_inet.o fsspace.o \
+ fullname.o get_domainname.o get_hostname.o hex_code.o hex_quote.o \
+ host_port.o htable.o inet_addr_host.o inet_addr_list.o \
+ inet_addr_local.o inet_connect.o inet_listen.o inet_proto.o \
+ inet_trigger.o line_wrap.o lowercase.o lstat_as.o mac_expand.o \
++ load_lib.o \
+ mac_parse.o make_dirs.o mask_addr.o match_list.o match_ops.o msg.o \
+ msg_output.o msg_syslog.o msg_vstream.o mvect.o myaddrinfo.o myflock.o \
+ mymalloc.o myrand.o mystrtok.o name_code.o name_mask.o netstring.o \
+@@ -78,7 +80,7 @@
+ msg_output.h msg_syslog.h msg_vstream.h mvect.h myaddrinfo.h myflock.h \
+ mymalloc.h myrand.h name_code.h name_mask.h netstring.h nvtable.h \
+ open_as.h open_lock.h percentm.h posix_signals.h readlline.h ring.h \
+- safe.h safe_open.h sane_accept.h sane_connect.h sane_fsops.h \
++ safe.h safe_open.h sane_accept.h sane_connect.h sane_fsops.h load_lib.h \
+ sane_socketpair.h sane_time.h scan_dir.h set_eugid.h set_ugid.h \
+ sigdelay.h sock_addr.h spawn_command.h split_at.h stat_as.h \
+ stringops.h sys_defs.h timed_connect.h timed_wait.h trigger.h \
+@@ -91,6 +93,7 @@
+ CFLAGS = $(DEBUG) $(OPT) $(DEFS)
+ FILES = Makefile $(SRCS) $(HDRS)
+ INCL =
++PCRESO = dict_pcre.so
+ LIB = libutil.a
+ TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
+ fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \
+@@ -105,10 +108,11 @@
+
+ LIB_DIR = ../../lib
+ INC_DIR = ../../include
++LIBS = $(LIB_DIR)/$(LIB) $(PCRESO)
+
+-.c.o:; $(CC) $(CFLAGS) -c $*.c
++.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
+
+-all: $(LIB)
++all: $(LIB) $(PCRESO)
+
+ $(OBJS): ../../conf/makedefs.out
+
+@@ -117,15 +121,19 @@
+
+ test: $(TESTPROG)
+
++$(PCRESO): dict_pcre.o libutil.a
++ gcc -shared -Wl,-soname,dict_pcre.so -o $@ $? -lpcre -L. -lutil
++
+ $(LIB): $(OBJS)
+- $(AR) $(ARFL) $(LIB) $?
+- $(RANLIB) $(LIB)
++ gcc -shared -Wl,-soname,libpostfix-util.so.1 -o $(LIB) $(OBJS) -ldl $(SYSLIBS)
+
+ $(LIB_DIR)/$(LIB): $(LIB)
+ cp $(LIB) $(LIB_DIR)
+- $(RANLIB) $(LIB_DIR)/$(LIB)
+
+-update: $(LIB_DIR)/$(LIB) $(HDRS)
++../../libexec/$(PCRESO): $(PCRESO)
++ cp $(PCRESO) ../../libexec
++
++update: $(LIBS) ../../libexec/$(PCRESO) $(HDRS)
+ -for i in $(HDRS); \
+ do \
+ cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
+@@ -147,7 +155,8 @@
+ lint $(SRCS)
+
+ clean:
+- rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp
++ rm -f *.o $(LIB) $(PCRESO) *core $(TESTPROG) \
++ junk $(MAKES) *.tmp
+ rm -rf printfck
+
+ tidy: clean
+diff -ruN a/src/util/dict.h b/src/util/dict.h
+--- a/src/util/dict.h 2009-06-01 12:27:45.000000000 +0000
++++ b/src/util/dict.h 2009-06-01 13:08:26.000000000 +0000
+@@ -66,6 +66,7 @@
+ #define DICT_FLAG_NO_UNAUTH (1<<13) /* disallow unauthenticated data */
+ #define DICT_FLAG_FOLD_FIX (1<<14) /* case-fold key with fixed-case map */
+ #define DICT_FLAG_FOLD_MUL (1<<15) /* case-fold key with multi-case map */
++#define DICT_FLAG_UPGRADE (1<<30) /* Upgrade the db */
+ #define DICT_FLAG_FOLD_ANY (DICT_FLAG_FOLD_FIX | DICT_FLAG_FOLD_MUL)
+
+ /* IMPORTANT: Update the dict_mask[] table when the above changes */
+@@ -138,6 +139,11 @@
+ extern DICT *dict_open(const char *, int, int);
+ extern DICT *dict_open3(const char *, const char *, int, int);
+ extern void dict_open_register(const char *, DICT *(*) (const char *, int, int));
++#ifndef NO_DYNAMIC_MAPS
++extern void dict_open_dlinfo(const char *path);
++typedef void* (*dict_mkmap_func_t)(const char *);
++dict_mkmap_func_t dict_mkmap_func(const char *dict_type);
++#endif
+
+ #define dict_get(dp, key) ((const char *) (dp)->lookup((dp), (key)))
+ #define dict_put(dp, key, val) (dp)->update((dp), (key), (val))
+diff -ruN a/src/util/dict_db.c b/src/util/dict_db.c
+--- a/src/util/dict_db.c 2009-06-01 12:27:45.000000000 +0000
++++ b/src/util/dict_db.c 2009-06-01 13:08:26.000000000 +0000
+@@ -664,6 +664,12 @@
+ msg_fatal("set DB cache size %d: %m", dict_db_cache_size);
+ if (type == DB_HASH && db->set_h_nelem(db, DICT_DB_NELM) != 0)
+ msg_fatal("set DB hash element count %d: %m", DICT_DB_NELM);
++ if (dict_flags & DICT_FLAG_UPGRADE) {
++ if (msg_verbose)
++ msg_info("upgrading database %s",db_path);
++ if ((errno = db->upgrade(db,db_path,0)) != 0)
++ msg_fatal("upgrade of database %s: %m",db_path);
++ }
+ #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR > 0)
+ if ((errno = db->open(db, 0, db_path, 0, type, db_flags, 0644)) != 0)
+ msg_fatal("open database %s: %m", db_path);
+diff -ruN a/src/util/dict_dbm.c b/src/util/dict_dbm.c
+--- a/src/util/dict_dbm.c 2009-06-01 12:27:45.000000000 +0000
++++ b/src/util/dict_dbm.c 2009-06-01 13:08:26.000000000 +0000
+@@ -407,6 +407,10 @@
+ char *dbm_path;
+ int lock_fd;
+
++#ifdef HAVE_GDBM
++ msg_fatal("%s: gdbm maps use locking that is incompatible with postfix. Use a hash map instead.",
++ path);
++#endif
+ /*
+ * Note: DICT_FLAG_LOCK is used only by programs that do fine-grained (in
+ * the time domain) locking while accessing individual database records.
+diff -ruN a/src/util/dict_open.c b/src/util/dict_open.c
+--- a/src/util/dict_open.c 2009-06-01 12:27:45.000000000 +0000
++++ b/src/util/dict_open.c 2009-06-01 13:08:26.000000000 +0000
+@@ -44,6 +44,8 @@
+ /* DICT *(*open) (const char *, int, int);
+ /*
+ /* ARGV *dict_mapnames()
++/*
++/* void (*)() dict_mkmap_func(const char *dict_type)
+ /* DESCRIPTION
+ /* This module implements a low-level interface to multiple
+ /* physical dictionary types.
+@@ -159,6 +161,9 @@
+ /*
+ /* dict_mapnames() returns a sorted list with the names of all available
+ /* dictionary types.
++/*
++/* dict_mkmap_func() returns a pointer to the mkmap setup function
++/* for the given map type, as given in /etc/dynamicmaps.cf
+ /* DIAGNOSTICS
+ /* Fatal error: open error, unsupported dictionary type, attempt to
+ /* update non-writable dictionary.
+@@ -183,6 +188,9 @@
+ #include <strings.h>
+ #endif
+
++#include <sys/stat.h>
++#include <unistd.h>
++
+ /* Utility library. */
+
+ #include <argv.h>
+@@ -207,6 +215,27 @@
+ #include <split_at.h>
+ #include <htable.h>
+
++#ifndef NO_DYNAMIC_MAPS
++#include <load_lib.h>
++#include <vstring.h>
++#include <vstream.h>
++#include <vstring_vstream.h>
++#include <mvect.h>
++
++ /*
++ * Interface for dynamic map loading.
++ */
++typedef struct {
++ const char *pattern;
++ const char *soname;
++ const char *openfunc;
++ const char *mkmapfunc;
++} DLINFO;
++
++static DLINFO *dict_dlinfo;
++static DLINFO *dict_open_dlfind(const char *type);
++#endif
++
+ /*
+ * lookup table for available map types.
+ */
+@@ -221,9 +250,11 @@
+ #endif
+ DICT_TYPE_ENVIRON, dict_env_open,
+ DICT_TYPE_UNIX, dict_unix_open,
++#ifdef NO_DYNAMIC_MAPS
+ #ifdef SNAPSHOT
+ DICT_TYPE_TCP, dict_tcp_open,
+ #endif
++#endif
+ #ifdef HAS_SDBM
+ DICT_TYPE_SDBM, dict_sdbm_open,
+ #endif
+@@ -243,9 +274,11 @@
+ #ifdef HAS_NETINFO
+ DICT_TYPE_NETINFO, dict_ni_open,
+ #endif
++#ifdef NO_DYNAMIC_MAPS
+ #ifdef HAS_PCRE
+ DICT_TYPE_PCRE, dict_pcre_open,
+ #endif
++#endif /* NO_DYNAMIC_MAPS */
+ #ifdef HAS_POSIX_REGEXP
+ DICT_TYPE_REGEXP, dict_regexp_open,
+ #endif
+@@ -303,8 +336,31 @@
+ dict_type, dict_name);
+ if (dict_open_hash == 0)
+ dict_open_init();
+- if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0)
+- msg_fatal("unsupported dictionary type: %s", dict_type);
++ if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) {
++#ifdef NO_DYNAMIC_MAPS
++ msg_fatal("%s: unsupported dictionary type: %s", myname, dict_type);
++#else
++ struct stat st;
++ LIB_FN fn[2];
++ DICT *(*open) (const char *, int, int);
++ DLINFO *dl=dict_open_dlfind(dict_type);
++ if (!dl)
++ msg_fatal("%s: unsupported dictionary type: %s: Is the postfix-%s package installed?", myname, dict_type, dict_type);
++ if (stat(dl->soname,&st) < 0) {
++ msg_fatal("%s: unsupported dictionary type: %s (%s not found. Is the postfix-%s package installed?)",
++ myname, dict_type, dl->soname, dict_type);
++ }
++ fn[0].name = dl->openfunc;
++ fn[0].ptr = (void**)&open;
++ fn[1].name = NULL;
++ load_library_symbols(dl->soname, fn, NULL);
++ dict_open_register(dict_type, open);
++ dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type);
++#endif
++ }
++ if (msg_verbose>1) {
++ msg_info("%s: calling %s open routine",myname,dict_type);
++ }
+ if ((dict = dp->open(dict_name, open_flags, dict_flags)) == 0)
+ msg_fatal("opening %s:%s %m", dict_type, dict_name);
+ if (msg_verbose)
+@@ -312,6 +368,36 @@
+ return (dict);
+ }
+
++dict_mkmap_func_t dict_mkmap_func(const char *dict_type)
++{
++ char *myname="dict_mkmap_func";
++ struct stat st;
++ LIB_FN fn[2];
++ dict_mkmap_func_t mkmap;
++ DLINFO *dl;
++#ifndef NO_DYNAMIC_MAPS
++ if (!dict_dlinfo)
++ msg_fatal("dlinfo==NULL");
++ dl=dict_open_dlfind(dict_type);
++ if (!dl)
++ msg_fatal("%s: unsupported dictionary type: %s: Is the postfix-%s package installed?", myname, dict_type, dict_type);
++ if (stat(dl->soname,&st) < 0) {
++ msg_fatal("%s: unsupported dictionary type: %s (%s not found. Is the postfix-%s package installed?)",
++ myname, dict_type, dl->soname, dict_type);
++ }
++ if (!dl->mkmapfunc)
++ msg_fatal("%s: unsupported dictionary type: %s does not allow map creation.", myname, dict_type);
++
++ fn[0].name = dl->mkmapfunc;
++ fn[0].ptr = (void**)&mkmap;
++ fn[1].name = NULL;
++ load_library_symbols(dl->soname, fn, NULL);
++ return mkmap;
++#else
++ return (void(*)())NULL;
++#endif
++}
++
+ /* dict_open_register - register dictionary type */
+
+ void dict_open_register(const char *type,
+@@ -345,6 +431,9 @@
+ HTABLE_INFO **ht;
+ DICT_OPEN_INFO *dp;
+ ARGV *mapnames;
++#ifndef NO_DYNAMIC_MAPS
++ DLINFO *dlp;
++#endif
+
+ if (dict_open_hash == 0)
+ dict_open_init();
+@@ -353,6 +442,13 @@
+ dp = (DICT_OPEN_INFO *) ht[0]->value;
+ argv_add(mapnames, dp->type, ARGV_END);
+ }
++#ifndef NO_DYNAMIC_MAPS
++ if (!dict_dlinfo)
++ msg_fatal("dlinfo==NULL");
++ for (dlp=dict_dlinfo; dlp->pattern; dlp++) {
++ argv_add(mapnames, dlp->pattern, ARGV_END);
++ }
++#endif
+ qsort((void *) mapnames->argv, mapnames->argc, sizeof(mapnames->argv[0]),
+ dict_sort_alpha_cpp);
+ myfree((char *) ht_info);
+@@ -360,6 +456,87 @@
+ return mapnames;
+ }
+
++#ifndef NO_DYNAMIC_MAPS
++#define STREQ(x,y) (x == y || (x[0] == y[0] && strcmp(x,y) == 0))
++
++void dict_open_dlinfo(const char *path)
++{
++ char *myname="dict_open_dlinfo";
++ VSTREAM *conf_fp=vstream_fopen(path,O_RDONLY,0);
++ VSTRING *buf = vstring_alloc(100);
++ char *cp;
++ ARGV *argv;
++ MVECT vector;
++ int nelm=0;
++ int linenum=0;
++
++ dict_dlinfo=(DLINFO*)mvect_alloc(&vector,sizeof(DLINFO),3,NULL,NULL);
++
++ if (!conf_fp) {
++ msg_warn("%s: cannot open %s. No dynamic maps will be allowed.",
++ myname, path);
++ } else {
++ while (vstring_get_nonl(buf,conf_fp) != VSTREAM_EOF) {
++ cp = vstring_str(buf);
++ linenum++;
++ if (*cp == '#' || *cp == '\0')
++ continue;
++ argv = argv_split(cp, " \t");
++ if (argv->argc != 3 && argv->argc != 4) {
++ msg_fatal("%s: Expected \"pattern .so-name open-function [mkmap-function]\" at line %d",
++ myname, linenum);
++ }
++ if (STREQ(argv->argv[0],"*")) {
++ msg_warn("%s: wildcard dynamic map entry no longer supported.",
++ myname);
++ continue;
++ }
++ if (argv->argv[1][0] != '/') {
++ msg_fatal("%s: .so name must begin with a \"/\" at line %d",
++ myname, linenum);
++ }
++ if (nelm >= vector.nelm) {
++ dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+3);
++ }
++ dict_dlinfo[nelm].pattern = mystrdup(argv->argv[0]);
++ dict_dlinfo[nelm].soname = mystrdup(argv->argv[1]);
++ dict_dlinfo[nelm].openfunc = mystrdup(argv->argv[2]);
++ if (argv->argc==4)
++ dict_dlinfo[nelm].mkmapfunc = mystrdup(argv->argv[3]);
++ else
++ dict_dlinfo[nelm].mkmapfunc = NULL;
++ nelm++;
++ argv_free(argv);
++ }
++ }
++ if (nelm >= vector.nelm) {
++ dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+1);
++ }
++ dict_dlinfo[nelm].pattern = NULL;
++ dict_dlinfo[nelm].soname = NULL;
++ dict_dlinfo[nelm].openfunc = NULL;
++ dict_dlinfo[nelm].mkmapfunc = NULL;
++ if (conf_fp)
++ vstream_fclose(conf_fp);
++ vstring_free(buf);
++}
++
++static DLINFO *dict_open_dlfind(const char *type)
++{
++ DLINFO *dp;
++
++ if (!dict_dlinfo)
++ return NULL;
++
++ for (dp=dict_dlinfo; dp->pattern; dp++) {
++ if (STREQ(dp->pattern,type))
++ return dp;
++ }
++ return NULL;
++}
++
++#endif /* !NO_DYNAMIC_MAPS */
++
+ #ifdef TEST
+
+ /*
+diff -ruN a/src/util/load_lib.c b/src/util/load_lib.c
+--- a/src/util/load_lib.c 1970-01-01 00:00:00.000000000 +0000
++++ b/src/util/load_lib.c 2009-06-01 13:08:26.000000000 +0000
+@@ -0,0 +1,135 @@
++/*++
++/* NAME
++/* load_lib 3
++/* SUMMARY
++/* library loading wrappers
++/* SYNOPSIS
++/* #include <load_lib.h>
++/*
++/* extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *);
++/* const char *libname;
++/* LIB_FN *libfuncs;
++/* LIB_FN *libdata;
++/*
++/* DESCRIPTION
++/* This module loads functions from libraries, returnine pointers
++/* to the named functions.
++/*
++/* load_library_symbols() loads all of the desired functions, and
++/* returns zero for success, or exits via msg_fatal().
++/*
++/* SEE ALSO
++/* msg(3) diagnostics interface
++/* DIAGNOSTICS
++/* Problems are reported via the msg(3) diagnostics routines:
++/* library not found, symbols not found, other fatal errors.
++/* LICENSE
++/* .ad
++/* .fi
++/* The Secure Mailer license must be distributed with this software.
++/* AUTHOR(S)
++/* LaMont Jones
++/* Hewlett-Packard Company
++/* 3404 Harmony Road
++/* Fort Collins, CO 80528, USA
++/*
++/* Wietse Venema
++/* IBM T.J. Watson Research
++/* P.O. Box 704
++/* Yorktown Heights, NY 10598, USA
++/*--*/
++
++/* System libraries. */
++
++#include "sys_defs.h"
++#include <stdlib.h>
++#include <stddef.h>
++#include <string.h>
++#if defined(HAS_DLOPEN)
++#include <dlfcn.h>
++#elif defined(HAS_SHL_LOAD)
++#include <dl.h>
++#endif
++
++/* Application-specific. */
++
++#include "msg.h"
++#include "load_lib.h"
++
++extern int load_library_symbols(const char * libname, LIB_FN * libfuncs, LIB_FN * libdata)
++{
++ char *myname = "load_library_symbols";
++ LIB_FN *fn;
++
++#if defined(HAS_DLOPEN)
++ void *handle;
++ char *emsg;
++
++ handle=dlopen(libname,RTLD_NOW);
++ emsg=dlerror();
++ if (emsg) {
++ msg_fatal("%s: dlopen failure loading %s: %s", myname, libname, emsg);
++ }
++
++ if (libfuncs) {
++ for (fn=libfuncs; fn->name; fn++) {
++ *(fn->ptr) = dlsym(handle,fn->name);
++ emsg=dlerror();
++ if (emsg) {
++ msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname,
++ fn->name, libname, emsg);
++ }
++ if (msg_verbose>1) {
++ msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr)));
++ }
++ }
++ }
++
++ if (libdata) {
++ for (fn=libdata; fn->name; fn++) {
++ *(fn->ptr) = dlsym(handle,fn->name);
++ emsg=dlerror();
++ if (emsg) {
++ msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname,
++ fn->name, libname, emsg);
++ }
++ if (msg_verbose>1) {
++ msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr)));
++ }
++ }
++ }
++#elif defined(HAS_SHL_LOAD)
++ shl_t handle;
++
++ handle = shl_load(libname,BIND_IMMEDIATE,0);
++
++ if (libfuncs) {
++ for (fn=libfuncs; fn->name; fn++) {
++ if (shl_findsym(&handle,fn->name,TYPE_PROCEDURE,fn->ptr) != 0) {
++ msg_fatal("%s: shl_findsym failure looking up %s in %s: %m",
++ myname, fn->name, libname);
++ }
++ if (msg_verbose>1) {
++ msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr)));
++ }
++ }
++ }
++
++ if (libdata) {
++ for (fn=libdata; fn->name; fn++) {
++ if (shl_findsym(&handle,fn->name,TYPE_DATA,fn->ptr) != 0) {
++ msg_fatal("%s: shl_findsym failure looking up %s in %s: %m",
++ myname, fn->name, libname);
++ }
++ if (msg_verbose>1) {
++ msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr)));
++ }
++ }
++ }
++
++#else
++ msg_fatal("%s: need dlopen or shl_load support for dynamic libraries",
++ myname);
++#endif
++ return 0;
++}
+diff -ruN a/src/util/load_lib.h b/src/util/load_lib.h
+--- a/src/util/load_lib.h 1970-01-01 00:00:00.000000000 +0000
++++ b/src/util/load_lib.h 2009-06-01 13:08:26.000000000 +0000
+@@ -0,0 +1,41 @@
++#ifndef _LOAD_LIB_H_INCLUDED_
++#define _LOAD_LIB_H_INCLUDED_
++
++/*++
++/* NAME
++/* load_lib 3h
++/* SUMMARY
++/* library loading wrappers
++/* SYNOPSIS
++/* #include "load_lib.h"
++/* DESCRIPTION
++/* .nf
++
++ /*
++ * External interface.
++ */
++/* NULL name terminates list */
++typedef struct LIB_FN {
++ const char *name;
++ void **ptr;
++} LIB_FN;
++
++extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *);
++
++/* LICENSE
++/* .ad
++/* .fi
++/* The Secure Mailer license must be distributed with this software.
++/* AUTHOR(S)
++/* LaMont Jones
++/* Hewlett-Packard Company
++/* 3404 Harmony Road
++/* Fort Collins, CO 80528, USA
++/*
++/* Wietse Venema
++/* IBM T.J. Watson Research
++/* P.O. Box 704
++/* Yorktown Heights, NY 10598, USA
++/*--*/
++
++#endif
diff --git a/main/postfix/postfix-ldap.post-install b/main/postfix/postfix-ldap.post-install
new file mode 100644
index 00000000000..b8d23833b66
--- /dev/null
+++ b/main/postfix/postfix-ldap.post-install
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# update the dynamicmaps.cf
+conf=/etc/postfix/dynamicmaps.cf
+
+sed -i -e '/\#\# AUTO BEGIN/,/\#\# AUTO END/d' $conf
+
+(
+echo '## AUTO BEGIN ##'
+if cd /usr/lib/postfix/; then
+ for i in *.so; do
+ m=${i#dict_}
+ m=${m%.so}
+ echo -e "$m\t/usr/lib/postfix/$i\tdict_${m}_open"
+ done
+fi
+
+echo '## AUTO END ##'
+) >> $conf
diff --git a/main/postfix/postfix-mysql.post-install b/main/postfix/postfix-mysql.post-install
new file mode 100644
index 00000000000..b8d23833b66
--- /dev/null
+++ b/main/postfix/postfix-mysql.post-install
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# update the dynamicmaps.cf
+conf=/etc/postfix/dynamicmaps.cf
+
+sed -i -e '/\#\# AUTO BEGIN/,/\#\# AUTO END/d' $conf
+
+(
+echo '## AUTO BEGIN ##'
+if cd /usr/lib/postfix/; then
+ for i in *.so; do
+ m=${i#dict_}
+ m=${m%.so}
+ echo -e "$m\t/usr/lib/postfix/$i\tdict_${m}_open"
+ done
+fi
+
+echo '## AUTO END ##'
+) >> $conf
diff --git a/main/postfix/postfix-pcre.post-install b/main/postfix/postfix-pcre.post-install
new file mode 100644
index 00000000000..f15b00cf758
--- /dev/null
+++ b/main/postfix/postfix-pcre.post-install
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# update the dynamicmaps.cf
+conf=/etc/postfix/dynamicmaps.cf
+
+sed -i -e '/\#\# AUTO BEGIN/,/\#\# AUTO END/d' $conf
+
+(
+echo '## AUTO BEGIN ##'
+if cd /usr/lib/postfix/; then
+ for i in *.so; do
+ m=${i#dict_}
+ m=${m%.so}
+ echo -e "$m\t/usr/lib/postfix/$i\tdict_${m}_open"
+ # pcre also handles regexp
+ if [ "$m" = "pcre" ]; then
+ echo -e "regex\t/usr/lib/postfix/$i\tdict_${m}_open"
+ fi
+
+ done
+fi
+
+echo '## AUTO END ##'
+) >> $conf
+
diff --git a/main/postfix/postfix-pgsql.post-install b/main/postfix/postfix-pgsql.post-install
new file mode 100644
index 00000000000..b8d23833b66
--- /dev/null
+++ b/main/postfix/postfix-pgsql.post-install
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# update the dynamicmaps.cf
+conf=/etc/postfix/dynamicmaps.cf
+
+sed -i -e '/\#\# AUTO BEGIN/,/\#\# AUTO END/d' $conf
+
+(
+echo '## AUTO BEGIN ##'
+if cd /usr/lib/postfix/; then
+ for i in *.so; do
+ m=${i#dict_}
+ m=${m%.so}
+ echo -e "$m\t/usr/lib/postfix/$i\tdict_${m}_open"
+ done
+fi
+
+echo '## AUTO END ##'
+) >> $conf
diff --git a/main/postfix/postfix.initd b/main/postfix/postfix.initd
new file mode 100644
index 00000000000..b2396b3aea3
--- /dev/null
+++ b/main/postfix/postfix.initd
@@ -0,0 +1,48 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/mail-mta/postfix/files/postfix.rc6.2.5,v 1.3 2008/08/18 14:18:40 falco Exp $
+
+# If you plan to simultaneously use several Postfix instances, don't forget
+# to specify your alternate_config_directories variable in your main main.cf file.
+# Then make a symlink from /etc/init.d/postfix to /etc/init.d/postfix.alt,
+# prepare your new /etc/postfix.alt environment, and at least change these working paths:
+# queue_directory = /var/spool/postfix.alt
+# data_directory = /var/lib/postfix.alt
+
+CONF_DIR="/etc/postfix"
+CONF_OPT="${SVCNAME##*.}"
+if [ -n ${CONF_OPT} -a ${SVCNAME} != "postfix" ]; then
+ CONF_DIR="${CONF_DIR}.${CONF_OPT}"
+fi
+
+opts="${opts} reload"
+
+depend() {
+ use logger dns ypbind amavisd mysql postgresql antivirus postfix_greylist net saslauthd
+ if [ "${SVCNAME}" = "postfix" ]; then
+ provide mta
+ fi
+}
+
+start() {
+ ebegin "Starting postfix (${CONF_DIR})"
+ if [ ! -d ${CONF_DIR} ]; then
+ eend 1 "${CONF_DIR} does not exist"
+ return 1
+ fi
+ /usr/sbin/postfix -c ${CONF_DIR} start >/dev/null 2>&1
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping postfix (${CONF_DIR})"
+ /usr/sbin/postfix -c ${CONF_DIR} stop >/dev/null 2>&1
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading postfix (${CONF_DIR})"
+ /usr/sbin/postfix -c ${CONF_DIR} reload >/dev/null 2>&1
+ eend $?
+}
diff --git a/main/postfix/postfix.post-install b/main/postfix/postfix.post-install
new file mode 100644
index 00000000000..98e01db0bb4
--- /dev/null
+++ b/main/postfix/postfix.post-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+chown postfix /var/spool/postfix/* /var/lib/postfix
+chgrp postdrop /var/spool/postfix/maildrop /var/spool/postfix/public
+
+exit 0
diff --git a/main/postfix/postfix.pre-install b/main/postfix/postfix.pre-install
new file mode 100644
index 00000000000..22414ef615c
--- /dev/null
+++ b/main/postfix/postfix.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+addgroup postfix 2>/dev/null
+addgroup postdrop 2>/dev/null
+adduser postfix -h /var/spool/postfix -G postfix,mail 2>/dev/null
+
+exit 0
diff --git a/main/postgresql/APKBUILD b/main/postgresql/APKBUILD
new file mode 100644
index 00000000000..a2d921ed14a
--- /dev/null
+++ b/main/postgresql/APKBUILD
@@ -0,0 +1,50 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=postgresql
+pkgver=8.3.7
+pkgrel=3
+pkgdesc="A sophisticated object-relational DBMS"
+url="http://www.postgresql.org/"
+license="BSD"
+depends="bbsuid"
+makedepends="readline-dev openssl-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc libpq $pkgname-client"
+source="ftp://ftp.$pkgname.org/pub/source/v$pkgver/$pkgname-$pkgver.tar.bz2
+ $pkgname.initd
+ $pkgname.confd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver || return 1
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --with-docdir=/usr/share/doc \
+ --with-openssl \
+ || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ install -D -m755 "$srcdir"/postgresql.initd \
+ "$pkgdir"/etc/init.d/postgresql
+ install -D -m644 "$srcdir"/postgresql.confd \
+ "$pkgdir"/etc/conf.d/postgresql || return 1
+}
+
+libpq() {
+ depends=
+ pkgdesc="PostgreSQL libraries"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpq.so* "$subpkgdir"/usr/lib/
+}
+
+client() {
+ depends=
+ pkgdesc="PostgreSQL client"
+ mkdir -p "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/psql "$subpkgdir"/usr/bin/
+}
+
+
+md5sums="7b7e91a2221e55fe1b167e663217a96d postgresql-8.3.7.tar.bz2
+6dd7bd7c97252312357a255237115b38 postgresql.initd
+ea3320c56a22f5c305199886c2766387 postgresql.confd"
diff --git a/main/postgresql/postgresql.confd b/main/postgresql/postgresql.confd
new file mode 100644
index 00000000000..56561b0c40c
--- /dev/null
+++ b/main/postgresql/postgresql.confd
@@ -0,0 +1,52 @@
+# PostgreSQL's Database Directory
+PGDATA="/var/lib/postgresql/8.3/data"
+
+# PostgreSQL User
+PGUSER="postgres"
+
+# PostgreSQL Group
+PGGROUP="postgres"
+
+# Extra options to run postmaster with, e.g.:
+# -N is the maximal number of client connections
+# -B is the number of shared buffers and has to be at least 2x the value for -N
+# Please read the man-page to postmaster for more options. Many of these options
+# can be set directly in the configuration-file.
+#PGOPTS="-N 512 -B 1024"
+
+
+# SERVER SHUTDOWN:
+# The server will receive 3 signals in the worst case:
+# 1. SIGTERM
+# This signals the server to ignore new connections and to
+# wait for all clients to end their transactions before shutting down.
+# Use WAIT_FOR_DISCONNECT to control how much time the clients
+# should have until the next signal is being sent.
+# 2. SIGINT
+# Tell the server to forcefully disconnect all clients.
+# Terminating a client results in a rollback of the open transactions for this client.
+# Use WAIT_FOR_CLEANUP to determine how much time the server has
+# for cleanup.
+# 3. SIGQUIT
+# This will terminate the server immediately and results in a recovery run for the next start.
+
+# Wait for clients to disconnect
+WAIT_FOR_DISCONNECT=30
+
+# Time the server has to clean up
+WAIT_FOR_CLEANUP=60
+
+# Time the server has to quit (with a recover-run on next startup)
+# Set to 0 to deactivate it
+WAIT_FOR_QUIT=60
+
+# Comment this out if you don't want to wait for the server to
+# startup before continuing. For example, if this server is a
+# PITR log shipping based replication standby
+WAIT_FOR_START="-w"
+
+# If you have to export environment variables for the database process,
+# this can be done here.
+#
+# Example:
+# export R_HOME="/usr/lib/R"
diff --git a/main/postgresql/postgresql.initd b/main/postgresql/postgresql.initd
new file mode 100644
index 00000000000..3863a49aa40
--- /dev/null
+++ b/main/postgresql/postgresql.initd
@@ -0,0 +1,113 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-8.3,v 1.4 2008/09/28 22:53:02 caleb Exp $
+
+opts="${opts} reload setup"
+
+depend() {
+ use net
+}
+
+checkconfig() {
+ if [ ! -d "$PGDATA" ] ; then
+ eerror "Directory not found: $PGDATA"
+ eerror "Please make sure that PGDATA points to the right path."
+ eerror "You can run '/etc/init.d/postgresql setup' to setup a new database cluster."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting PostgreSQL"
+
+ if [ -f "$PGDATA/postmaster.pid" ] ; then
+ rm -f "$PGDATA/postmaster.pid"
+ fi
+
+ local retval
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl start ${WAIT_FOR_START} -o '--silent-mode=true ${PGOPTS}'" >/dev/null
+ retval=$?
+ [ $retval -ne 0 ] && eend $retval && return $retval
+
+ # The following is to catch the case of an already running server
+ # in which pg_ctl doesn't know to which server it connected to and false reports the server as 'up'
+ sleep 2
+ if [ ! -f "$PGDATA/postmaster.pid" ] ; then
+ eerror "The pid-file doesn't exist but pg_ctl reported a running server."
+ eerror "Please check whether there is another server running on the same port or read the log-file."
+ eend 1
+ return 1
+ fi
+
+ local pid=$(grep "^[0-9]\+" "$PGDATA/postmaster.pid")
+ test -d /proc/"${pid}"
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping PostgreSQL (this can take up to $(( ${WAIT_FOR_DISCONNECT} + ${WAIT_FOR_CLEANUP} )) seconds)"
+
+ local retval
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -t ${WAIT_FOR_DISCONNECT} -m smart" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ ewarn "Some clients did not disconnect within ${WAIT_FOR_DISCONNECT} seconds."
+ ewarn "Going to shutdown the server anyway."
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -m fast" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ if [ ${WAIT_FOR_QUIT} -eq 0 ] ; then
+ eerror "Server did not shut down and sending the SIGQUIT has been disabled."
+ eend $retval
+ return $retval
+ fi
+
+ ewarn "Shutting down the server gracefully failed."
+ ewarn "Forcing it to shutdown which leads to a recover-run on next startup."
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -m immediate" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ eerror "Forced shutdown failed!!! Something is wrong with your system, please take care of it manually."
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl reload" >/dev/null
+ eend $?
+}
+
+setup() {
+ ebegin "Creating a new PostgreSQL database cluster"
+ if [ -d "${PGDATA}" ] ; then
+ eend 1 "${PGDATA} already exist"
+ return
+ fi
+ mkdir -p "${PGDATA}"
+ chown -Rf postgres:postgres "${PGDATA}"
+ chmod 0700 "${PGDATA}"
+ cd "${PGDATA}" # to avoid the: could not change directory to "/root"
+ su -c "/usr/bin/initdb --pgdata ${PGDATA}" postgres
+ einfo "You can use the '/etc/init.d/postgresql' script to run PostgreSQL instead"
+ einfo "of 'pg_ctl'."
+ eend $?
+}
+
diff --git a/main/pth/APKBUILD b/main/pth/APKBUILD
new file mode 100644
index 00000000000..ce5cc5e126e
--- /dev/null
+++ b/main/pth/APKBUILD
@@ -0,0 +1,35 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=pth
+pkgver=2.0.7
+pkgrel=0
+pkgdesc="The GNU Portable Threads."
+url="http://www.gnu.org/software/pth"
+license="LGPL-2.1"
+depends="uclibc"
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ pth-2.0.5-parallelfix.patch
+ pth-2.0.6-ldflags.patch
+ pth-2.0.6-sigstack.patch
+ "
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --mandir=/usr/share/man
+
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+}
+md5sums="9cb4a25331a4c4db866a31cbe507c793 pth-2.0.7.tar.gz
+7bbd4f3328807c740c86db94e93e48ad pth-2.0.5-parallelfix.patch
+942fa4be28117756cd579937b257b9cc pth-2.0.6-ldflags.patch
+04e43157d758a3dc7925c35e6dd1e39c pth-2.0.6-sigstack.patch"
diff --git a/main/pth/pth-2.0.5-parallelfix.patch b/main/pth/pth-2.0.5-parallelfix.patch
new file mode 100644
index 00000000000..1c8200a4cb2
--- /dev/null
+++ b/main/pth/pth-2.0.5-parallelfix.patch
@@ -0,0 +1,15 @@
+--- a/Makefile.in 2005-11-08 05:58:55.000000000 +1100
++++ b/Makefile.in 2005-11-08 06:29:02.000000000 +1100
+@@ -148,10 +148,9 @@
+
+ # be aware of libtool when building the objects
+ .SUFFIXES:
+-.SUFFIXES: .c .o .lo
+-.c.o:
++%.o: %.c $(TARGET_PREQ)
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
+-.c.lo:
++%.lo: %.c $(TARGET_PREQ)
+ $(LIBTOOL) --mode=compile --quiet $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
+
+ # the default target
diff --git a/main/pth/pth-2.0.6-ldflags.patch b/main/pth/pth-2.0.6-ldflags.patch
new file mode 100644
index 00000000000..7a4a5ab3000
--- /dev/null
+++ b/main/pth/pth-2.0.6-ldflags.patch
@@ -0,0 +1,17 @@
+Index: pth-2.0.6/Makefile.in
+===================================================================
+--- pth-2.0.6.orig/Makefile.in
++++ pth-2.0.6/Makefile.in
+@@ -168,10 +168,10 @@ pth_p.h: $(S)pth_p.h.in
+
+ # build the static and possibly shared libraries
+ libpth.la: $(LOBJS)
+- $(LIBTOOL) --mode=link --quiet $(CC) -o libpth.la $(LOBJS) \
++ $(LIBTOOL) --mode=link --quiet $(CC) $(LDFLAGS) -o libpth.la $(LOBJS) \
+ -rpath $(libdir) -version-info `$(SHTOOL) version -lc -dlibtool $(_VERSION_FILE)`
+ libpthread.la: pthread.lo $(LOBJS)
+- $(LIBTOOL) --mode=link --quiet $(CC) -o libpthread.la pthread.lo $(LOBJS) \
++ $(LIBTOOL) --mode=link --quiet $(CC) $(LDFLAGS) -o libpthread.la pthread.lo $(LOBJS) \
+ -rpath $(libdir) -version-info `$(SHTOOL) version -lc -dlibtool $(_VERSION_FILE)`
+
+ # build the manual pages
diff --git a/main/pth/pth-2.0.6-sigstack.patch b/main/pth/pth-2.0.6-sigstack.patch
new file mode 100644
index 00000000000..3914dea7ac6
--- /dev/null
+++ b/main/pth/pth-2.0.6-sigstack.patch
@@ -0,0 +1,22 @@
+diff -urNp pth-2.0.6.old/aclocal.m4 pth-2.0.6/aclocal.m4
+--- pth-2.0.6.old/aclocal.m4 2004-12-31 21:33:19.000000000 +0200
++++ pth-2.0.6/aclocal.m4 2006-09-20 14:46:59.000000000 +0300
+@@ -1522,6 +1522,7 @@ int main(int argc, char *argv[])
+ int sksize;
+ char result[1024];
+ int i;
++exit (1);
+ sksize = 32768;
+ skbuf = (char *)malloc(sksize*2+2*sizeof(union alltypes));
+ if (skbuf == NULL)
+diff -urNp pth-2.0.6.old/configure pth-2.0.6/configure
+--- pth-2.0.6.old/configure 2005-11-22 09:49:21.000000000 +0200
++++ pth-2.0.6/configure 2006-09-20 14:55:23.000000000 +0300
+@@ -24735,6 +24735,7 @@ int main(int argc, char *argv[])
+ int sksize;
+ char result[1024];
+ int i;
++exit (1);
+ sksize = 32768;
+ skbuf = (char *)malloc(sksize*2+2*sizeof(union alltypes));
+ if (skbuf == NULL)
diff --git a/main/python/APKBUILD b/main/python/APKBUILD
new file mode 100644
index 00000000000..d5d38b99ca9
--- /dev/null
+++ b/main/python/APKBUILD
@@ -0,0 +1,33 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=python
+pkgver=2.6.2
+pkgrel=1
+pkgdesc="A high-level scripting language"
+url="http://www.python.org"
+license="custom"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="db expat openssl zlib ncurses uclibc"
+makedepends="db-dev expat-dev openssl-dev zlib-dev ncurses-dev bzip2-dev !gettext"
+source="http://www.$pkgname.org/ftp/$pkgname/$pkgver/Python-$pkgver.tar.bz2
+ $pkgname-2.6-internal-expat.patch
+ "
+
+build() {
+ cd "$srcdir/Python-$pkgver"
+ for i in ../*.patch; do
+ msg "Apply $i"
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --enable-shared \
+ --with-threads \
+ --enable-unicode \
+ --disable-gdbm
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+}
+md5sums="245db9f1e0f09ab7e0faaa0cf7301011 Python-2.6.2.tar.bz2
+9d64df5e0a6aed149a792c7bff16e3d9 python-2.6-internal-expat.patch"
diff --git a/main/python/python-2.6-internal-expat.patch b/main/python/python-2.6-internal-expat.patch
new file mode 100644
index 00000000000..f345db8c8e9
--- /dev/null
+++ b/main/python/python-2.6-internal-expat.patch
@@ -0,0 +1,33 @@
+--- a/setup.py 2008-04-22 12:12:24.613554757 +0300
++++ b/setup.py 2008-04-22 12:13:09.276544063 +0300
+@@ -1035,18 +1035,15 @@
+ #
+ # More information on Expat can be found at www.libexpat.org.
+ #
+- expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')
+- define_macros = [
+- ('HAVE_EXPAT_CONFIG_H', '1'),
+- ]
++ # Use system expat
++ expatinc = '/usr/include'
++ define_macros = []
+
+ exts.append(Extension('pyexpat',
+ define_macros = define_macros,
+ include_dirs = [expatinc],
++ libraries = ['expat'],
+ sources = ['pyexpat.c',
+- 'expat/xmlparse.c',
+- 'expat/xmlrole.c',
+- 'expat/xmltok.c',
+ ],
+ ))
+
+@@ -1058,6 +1055,7 @@
+ exts.append(Extension('_elementtree',
+ define_macros = define_macros,
+ include_dirs = [expatinc],
++ libraries = ['expat'],
+ sources = ['_elementtree.c'],
+ ))
+
diff --git a/main/quagga/APKBUILD b/main/quagga/APKBUILD
new file mode 100644
index 00000000000..aaa3fc64d07
--- /dev/null
+++ b/main/quagga/APKBUILD
@@ -0,0 +1,79 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=quagga
+pkgver=0.99.13
+pkgrel=0
+pkgdesc="A free routing daemon replacing Zebra supporting RIP, OSPF and BGP."
+url="http://quagga.net/"
+license="GPL-2"
+depends="iproute2"
+makedepends="readline-dev ncurses-dev gawk
+ autoconf automake libtool"
+install="$pkgname.pre-install $pkgname.post-install"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://www.quagga.net/download/$pkgname-$pkgver.tar.gz
+ $pkgname-0.99.11-link-libcap.patch
+ $pkgname-0.99.11-ipv6-only.patch
+ $pkgname-0.99.11-del-routes.patch
+ $pkgname-0.99.11-zombie.patch
+ $pkgname-0.99.11-fd-leak.patch
+ bgpd.initd
+ ospf6d.initd
+ ospfd.initd
+ ripd.initd
+ ripngd.initd
+ zebra.initd
+ zebra.confd
+ $install
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ msg "Running autotools..."
+ aclocal || return 1
+ autoconf || return 1
+ automake || return 1
+ libtoolize || return 1
+
+ ./configure --prefix=/usr \
+ --disable-static \
+ --enable-ipv6 \
+ --enable-ospf6d \
+ --enable-rtadv \
+ --enable-user=quagga \
+ --enable-group=quagga \
+ --enable-vty-group=quagga \
+ --enable-vtysh \
+ --sysconfdir=/etc/quagga \
+ --enable-exampledir=/usr/share/doc/quagga/ \
+ --localstatedir=/var/run/quagga \
+ || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -d "$pkgdir"/var/run/quagga
+ for i in zebra ripd ospfd bgpd ripngd ospf6d; do
+ install -Dm755 "$srcdir"/$i.initd "$pkgdir"/etc/init.d/$i
+ done
+ install -Dm644 "$srcdir/zebra.confd" "$pkgdir"/etc/conf.d/zebra
+}
+md5sums="55a7d2dcf016580a7c7412b3518cd942 quagga-0.99.13.tar.gz
+8f99d41a8ed79e51704e8f655d255f29 quagga-0.99.11-link-libcap.patch
+44c517e988273e0e5076d24f3959a125 quagga-0.99.11-ipv6-only.patch
+1cbcf60a637b2577dee4d6df711e1247 quagga-0.99.11-del-routes.patch
+ce345725f2e7240cebe0fd5ac2b2fc48 quagga-0.99.11-zombie.patch
+e2391e19b542ec1743776ca9e36ac11a quagga-0.99.11-fd-leak.patch
+cc109a746273bc0d6aee9d758e7524ab bgpd.initd
+44547b687343ebfed7524cebc5626067 ospf6d.initd
+89b0cf4e70172bfcd195b2869cae28da ospfd.initd
+39b8cb21b55de53af38c94c2f5d85917 ripd.initd
+120ab1b53975ec86e78266f31e935ab6 ripngd.initd
+3490a10510e416ab83d5b4d767136de8 zebra.initd
+c38e884372406e9e59616e436cd26388 zebra.confd
+44b4c3684e4c7300665bf90fa4520af9 quagga.pre-install
+d2181a6401280478b8700cfcee32794e quagga.post-install"
diff --git a/main/quagga/bgpd.initd b/main/quagga/bgpd.initd
new file mode 100644
index 00000000000..b6104235c39
--- /dev/null
+++ b/main/quagga/bgpd.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2003 DataCore GmbH, Amir Guindehi
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/bgpd.init,v 1.1 2005/09/14 11:11:08 mrness Exp $
+
+depend() {
+ need net zebra
+}
+
+checkconfig() {
+ if [ ! -e /etc/quagga/bgpd.conf ] ; then
+ eerror "You need to create /etc/quagga/bgpd.conf first."
+ eerror "An example can be found in /etc/quagga/samples/bgpd.conf.sample"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting bgpd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/bgpd \
+ -- -d -f /etc/quagga/bgpd.conf \
+ --pid_file /var/run/quagga/bgpd.pid
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping bgpd"
+ start-stop-daemon --stop --quiet --pidfile /var/run/quagga/bgpd.pid
+ result=$?
+ eend $result
+}
diff --git a/main/quagga/ospf6d.initd b/main/quagga/ospf6d.initd
new file mode 100644
index 00000000000..6edafe5f745
--- /dev/null
+++ b/main/quagga/ospf6d.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2003 DataCore GmbH, Amir Guindehi
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/ospf6d.init,v 1.1 2005/09/14 11:11:08 mrness Exp $
+
+depend() {
+ need net zebra
+}
+
+checkconfig() {
+ if [ ! -e /etc/quagga/ospf6d.conf ] ; then
+ eerror "You need to create /etc/quagga/ospf6d.conf first."
+ eerror "An example can be found in /etc/quagga/samples/ospf6d.conf.sample"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ospf6d"
+ start-stop-daemon --start --quiet --exec /usr/sbin/ospf6d \
+ -- -d -f /etc/quagga/ospf6d.conf \
+ --pid_file /var/run/quagga/ospf6d.pid
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping ospf6d"
+ start-stop-daemon --stop --quiet --pidfile /var/run/quagga/ospf6d.pid
+ result=$?
+ eend $result
+}
diff --git a/main/quagga/ospfd.initd b/main/quagga/ospfd.initd
new file mode 100644
index 00000000000..f67ca2c154a
--- /dev/null
+++ b/main/quagga/ospfd.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2003 DataCore GmbH, Amir Guindehi
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/ospfd.init,v 1.1 2005/09/14 11:11:08 mrness Exp $
+
+depend() {
+ need net zebra
+}
+
+checkconfig() {
+ if [ ! -e /etc/quagga/ospfd.conf ] ; then
+ eerror "You need to create /etc/quagga/ospfd.conf first."
+ eerror "An example can be found in /etc/quagga/samples/ospfd.conf.sample"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ospfd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/ospfd \
+ -- -d -f /etc/quagga/ospfd.conf \
+ --pid_file /var/run/quagga/ospfd.pid
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping ospfd"
+ start-stop-daemon --stop --quiet --pidfile /var/run/quagga/ospfd.pid
+ result=$?
+ eend $result
+}
diff --git a/main/quagga/quagga-0.99.11-del-routes.patch b/main/quagga/quagga-0.99.11-del-routes.patch
new file mode 100644
index 00000000000..72ee89929cf
--- /dev/null
+++ b/main/quagga/quagga-0.99.11-del-routes.patch
@@ -0,0 +1,44 @@
+From http://lists.quagga.net/pipermail/quagga-dev/2009-January/006362.html
+
+If there are two paralell PtP links to the same router:
+ C * 192.168.101.112/32 is directly connected, p1-4-19-4-20
+ C>* 192.168.101.112/32 is directly connected, p1-4-17-4-18
+and the cable is to one of the ppp links is pulled, Zebra
+deletes both routes instead of just the one that got yanked.
+This fixes it to only delete the route to the interface that
+got yanked.
+---
+This fix was suggested by lsorense at csclub.uwaterloo.ca (Lennart Sorensen)
+who had a similar problem. See [quagga-dev 6355]
+
+ zebra/zebra_rib.c | 9 ++++++++-
+ 1 files changed, 8 insertions(+), 1 deletions(-)
+
+diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
+index 90db932..7a37387 100644
+--- a/zebra/zebra_rib.c
++++ b/zebra/zebra_rib.c
+@@ -1896,6 +1896,13 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
+ inet_ntoa (*gate),
+ ifindex);
+
++ if (IS_ZEBRA_DEBUG_KERNEL && !gate)
++ zlog_debug ("rib_delete_ipv4(): route delete %s/%d directly, %s ifindex %d",
++ inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ),
++ p->prefixlen,
++ ifindex2ifname(ifindex),
++ ifindex);
++
+ /* Lookup route node. */
+ rn = route_node_lookup (table, (struct prefix *) p);
+ if (! rn)
+@@ -1942,7 +1949,7 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
+ break;
+ }
+ /* Make sure that the route found has the same gateway. */
+- else if (gate == NULL ||
++ else if (gate != NULL &&
+ ((nexthop = rib->nexthop) &&
+ (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) ||
+ IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate))))
+
diff --git a/main/quagga/quagga-0.99.11-fd-leak.patch b/main/quagga/quagga-0.99.11-fd-leak.patch
new file mode 100644
index 00000000000..e558d30a6ec
--- /dev/null
+++ b/main/quagga/quagga-0.99.11-fd-leak.patch
@@ -0,0 +1,19 @@
+--- quagga-0.99.11.DIST/bgpd/bgp_fsm.c 2008-09-09 16:18:57.000000000 -0400
++++ quagga-0.99.11/bgpd/bgp_fsm.c 2009-04-13 13:09:25.000000000 -0400
+@@ -1013,11 +1013,11 @@
+ {
+ /* Clearing, */
+ {bgp_ignore, Clearing}, /* BGP_Start */
+- {bgp_ignore, Clearing}, /* BGP_Stop */
+- {bgp_ignore, Clearing}, /* TCP_connection_open */
+- {bgp_ignore, Clearing}, /* TCP_connection_closed */
+- {bgp_ignore, Clearing}, /* TCP_connection_open_failed */
+- {bgp_ignore, Clearing}, /* TCP_fatal_error */
++ {bgp_stop, Clearing}, /* BGP_Stop */
++ {bgp_stop, Clearing}, /* TCP_connection_open */
++ {bgp_stop, Clearing}, /* TCP_connection_closed */
++ {bgp_stop, Clearing}, /* TCP_connection_open_failed */
++ {bgp_stop, Clearing}, /* TCP_fatal_error */
+ {bgp_ignore, Clearing}, /* ConnectRetry_timer_expired */
+ {bgp_ignore, Clearing}, /* Hold_Timer_expired */
+ {bgp_ignore, Clearing}, /* KeepAlive_timer_expired */
diff --git a/main/quagga/quagga-0.99.11-ipv6-only.patch b/main/quagga/quagga-0.99.11-ipv6-only.patch
new file mode 100644
index 00000000000..53636d6b57f
--- /dev/null
+++ b/main/quagga/quagga-0.99.11-ipv6-only.patch
@@ -0,0 +1,29 @@
+On Linux the default behaviour of getaddrinfo is to provide both IPV4 and IPV6
+addresses if available. But the default behaviour of binding to an IPV6 address
+is to handle both the native IPV6 address and IPV4 to IPV6 mapped addresses.
+Without this patch what happens is:
+ 1. First address is IPV6, bind succeeds.
+ 2. Second address is IPV4, bind fails (port already used by IPV6)
+ 3. incoming connections come in on IPV6 listen socket, as IPV4 mapped
+ addresses then BGP gets confused because of client with unexpected address.
+
+The fix is to force IPV6 socket as IPV6 only.
+
+--- a/bgpd/bgp_network.c 2008-08-27 17:59:20.000000000 -0700
++++ b/bgpd/bgp_network.c 2008-08-27 18:02:46.000000000 -0700
+@@ -412,6 +412,15 @@ bgp_socket (struct bgp *bgp, unsigned sh
+ setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
+ #endif
+
++#ifdef IPV6_V6ONLY
++ /* Want only IPV6 on ipv6 socket (not mapped addresses) */
++ if (ainfo->ai_family == AF_INET6) {
++ int on = 1;
++ setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
++ (void *) &on, sizeof (on));
++ }
++#endif
++
+ if (bgpd_privs.change (ZPRIVS_RAISE) )
+ zlog_err ("bgp_socket: could not raise privs");
+
diff --git a/main/quagga/quagga-0.99.11-link-libcap.patch b/main/quagga/quagga-0.99.11-link-libcap.patch
new file mode 100644
index 00000000000..2c1b868d158
--- /dev/null
+++ b/main/quagga/quagga-0.99.11-link-libcap.patch
@@ -0,0 +1,24 @@
+diff -ur quagga-0.99.11.orig/lib/Makefile.am quagga-0.99.11/lib/Makefile.am
+--- quagga-0.99.11.orig/lib/Makefile.am 2008-09-24 15:22:43.000000000 +0000
++++ quagga-0.99.11/lib/Makefile.am 2008-10-09 20:29:17.000000000 +0000
+@@ -18,7 +18,7 @@
+
+ libzebra_la_DEPENDENCIES = @LIB_REGEX@
+
+-libzebra_la_LIBADD = @LIB_REGEX@
++libzebra_la_LIBADD = @LIB_REGEX@ @LIBCAP@
+
+ pkginclude_HEADERS = \
+ buffer.h checksum.h command.h filter.h getopt.h hash.h \
+diff -ur quagga-0.99.11.orig/zebra/Makefile.am quagga-0.99.11/zebra/Makefile.am
+--- quagga-0.99.11.orig/zebra/Makefile.am 2008-09-05 14:27:26.000000000 +0000
++++ quagga-0.99.11/zebra/Makefile.am 2008-10-09 20:29:17.000000000 +0000
+@@ -39,7 +39,7 @@
+ connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
+ interface.h ipforward.h irdp.h router-id.h kernel_socket.h
+
+-zebra_LDADD = $(otherobj) $(LIBCAP) $(LIB_IPV6) ../lib/libzebra.la
++zebra_LDADD = $(otherobj) ../lib/libzebra.la $(LIBCAP) $(LIB_IPV6)
+
+ testzebra_LDADD = $(LIBCAP) $(LIB_IPV6) ../lib/libzebra.la
+
diff --git a/main/quagga/quagga-0.99.11-zombie.patch b/main/quagga/quagga-0.99.11-zombie.patch
new file mode 100644
index 00000000000..ad562df0002
--- /dev/null
+++ b/main/quagga/quagga-0.99.11-zombie.patch
@@ -0,0 +1,29 @@
+
+Currently, when accepting the connection, it can be left as zombie,
+when the peer just initiates a connection, but never sends data (and
+the TCP connection end packets are lost). This happens because for
+accepted connections a temporary new peer entry is created until OPEN
+message is exchanged, and this temporary peer entry does not get the
+hold time parameter set at all.
+
+Signed-off-by: Timo Teras <timo.teras@iki.fi>
+---
+ bgpd/bgp_network.c | 2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
+index 5dbd487..9a4c36d 100644
+--- a/bgpd/bgp_network.c
++++ b/bgpd/bgp_network.c
+@@ -185,6 +185,8 @@ bgp_accept (struct thread *thread)
+ peer->fd = bgp_sock;
+ peer->status = Active;
+ peer->local_id = peer1->local_id;
++ peer->v_holdtime = peer1->v_holdtime;
++ peer->v_keepalive = peer1->v_keepalive;
+
+ /* Make peer's address string. */
+ sockunion2str (&su, buf, SU_ADDRSTRLEN);
+--
+1.5.6.3
+
diff --git a/main/quagga/quagga.post-install b/main/quagga/quagga.post-install
new file mode 100644
index 00000000000..c1c670d2019
--- /dev/null
+++ b/main/quagga/quagga.post-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+chown root:root var/empty
+chown quagga:quagga /var/run/quagga
+exit 0
+
diff --git a/main/quagga/quagga.pre-install b/main/quagga/quagga.pre-install
new file mode 100644
index 00000000000..2643891dc74
--- /dev/null
+++ b/main/quagga/quagga.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+adduser -H -h /var/empty -s /bin/false -D quagga 2>/dev/null
+mkdir -p var/empty
+exit 0
+
diff --git a/main/quagga/ripd.initd b/main/quagga/ripd.initd
new file mode 100644
index 00000000000..987d6ec4b6a
--- /dev/null
+++ b/main/quagga/ripd.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2003 DataCore GmbH, Amir Guindehi
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/ripd.init,v 1.1 2005/09/14 11:11:08 mrness Exp $
+
+depend() {
+ need net zebra
+}
+
+checkconfig() {
+ if [ ! -e /etc/quagga/ripd.conf ] ; then
+ eerror "You need to create /etc/quagga/ripd.conf first."
+ eerror "An example can be found in /etc/quagga/samples/ripd.conf.sample"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ripd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/ripd \
+ -- -d -f /etc/quagga/ripd.conf \
+ --pid_file /var/run/quagga/ripd.pid
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping ripd"
+ start-stop-daemon --stop --quiet --pidfile /var/run/quagga/ripd.pid
+ result=$?
+ eend $result
+}
diff --git a/main/quagga/ripngd.initd b/main/quagga/ripngd.initd
new file mode 100644
index 00000000000..9bf2ff2a872
--- /dev/null
+++ b/main/quagga/ripngd.initd
@@ -0,0 +1,33 @@
+#!/sbin/runscript
+# Copyright 1999-2003 DataCore GmbH, Amir Guindehi
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/ripngd.init,v 1.1 2005/09/14 11:11:08 mrness Exp $
+
+depend() {
+ need net zebra
+}
+
+checkconfig() {
+ if [ ! -e /etc/quagga/ripngd.conf ] ; then
+ eerror "You need to create /etc/quagga/ripngd.conf first."
+ eerror "An example can be found in /etc/quagga/samples/ripngd.conf.sample"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting ripngd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/ripngd \
+ -- -d -f /etc/quagga/ripngd.conf \
+ --pid_file /var/run/quagga/ripngd.pid
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping ripngd"
+ start-stop-daemon --stop --quiet --pidfile /var/run/quagga/ripngd.pid
+ result=$?
+ eend $result
+}
diff --git a/main/quagga/zebra.confd b/main/quagga/zebra.confd
new file mode 100644
index 00000000000..a5256acd04d
--- /dev/null
+++ b/main/quagga/zebra.confd
@@ -0,0 +1,7 @@
+# Additional command-line parameters to run zebra with:
+# -k, --keep_kernel Don't delete old routes which installed by zebra.
+# -l, --log_mode number Set verbose log mode flag
+# -A, --vty_addr addr Set vty's bind address
+# -P, --vty_port port Set vty's port number
+# -r, --retain When program terminates, retain added route by zebra.
+ZEBRA_OPTS="-l 255"
diff --git a/main/quagga/zebra.initd b/main/quagga/zebra.initd
new file mode 100644
index 00000000000..f0cc0084326
--- /dev/null
+++ b/main/quagga/zebra.initd
@@ -0,0 +1,41 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/net-misc/quagga/files/zebra.init,v 1.2 2007/02/25 09:57:18 mrness Exp $
+
+depend() {
+ need net
+}
+
+checkconfig() {
+ if [ ! -e /etc/quagga/zebra.conf ] ; then
+ eerror "You need to create /etc/quagga/zebra.conf first."
+ eerror "An example can be found in /etc/quagga/samples/zebra.conf.sample"
+ return 1
+ fi
+}
+
+cleanup() {
+ ebegin "Cleaning up stale zebra routes..."
+ /usr/sbin/ip route flush proto zebra
+ eend $?
+}
+
+start() {
+ checkconfig || return 1
+ cleanup
+
+ ebegin "Starting zebra"
+ start-stop-daemon --start --quiet --exec /usr/sbin/zebra \
+ -- -d -f /etc/quagga/zebra.conf ${ZEBRA_OPTS} \
+ --pid_file /var/run/quagga/zebra.pid
+ result=$?
+ eend $result
+}
+
+stop() {
+ ebegin "Stopping zebra"
+ start-stop-daemon --stop --quiet --pidfile /var/run/quagga/zebra.pid
+ result=$?
+ eend $result
+}
diff --git a/main/razor/APKBUILD b/main/razor/APKBUILD
new file mode 100644
index 00000000000..7034208641a
--- /dev/null
+++ b/main/razor/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=razor
+_realname=razor-agents
+pkgver=2.84
+pkgrel=0
+pkgdesc="Vipul's Razor is a distributed, collaborative spam detection and filtering network"
+url="http://razor.sourceforge.net/"
+license="Artistic"
+depends="uclibc perl perl-digest-sha1 perl-getopt-long perl-uri-escape"
+makedepends="perl-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://garr.dl.sourceforge.net/sourceforge/razor/$_realname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="8b9a11a6ce020383c32c45d1530d77c2 razor-agents-2.84.tar.bz2"
diff --git a/main/roundcubemail/APKBUILD b/main/roundcubemail/APKBUILD
new file mode 100644
index 00000000000..f56de7b77c9
--- /dev/null
+++ b/main/roundcubemail/APKBUILD
@@ -0,0 +1,19 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=roundcubemail
+pkgver=0.2.2
+pkgrel=0
+pkgdesc="A PHP web-based mail client"
+url="http://www.roundcube.net"
+license="GPL"
+depends="php"
+makedepends=""
+source="http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ _instdir="$pkgdir"/usr/share/webapps/roundcube
+ mkdir -p "${_instdir}"
+ cd "${_instdir}"
+ cp -ra "$srcdir"/roundcubemail-$pkgver/* .
+}
+md5sums="992bd125a5f3c91e81f1eebbdef63575 roundcubemail-0.2.2.tar.gz"
diff --git a/main/rrdtool/APKBUILD b/main/rrdtool/APKBUILD
new file mode 100644
index 00000000000..541a54e85e9
--- /dev/null
+++ b/main/rrdtool/APKBUILD
@@ -0,0 +1,36 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=rrdtool
+pkgver=1.2.30
+pkgrel=0
+pkgdesc="Data logging and graphing application"
+url="http://www.rrdtool.org"
+license="GPL"
+depends="libart-lgpl libpng freetype uclibc"
+makedepends="libart-lgpl-dev libpng-dev freetype-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://oss.oetiker.ch/$pkgname/pub/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+
+ ./configure --prefix=/usr \
+ --disable-tcl \
+ --disable-perl \
+ --disable-perl-site-install \
+ --disable-python \
+ --disable-ruby \
+ --disable-rrdcgi
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ find "$pkgdir" -name '.packlist' -delete
+ find "$pkgdir" -name 'perllocal.pod' -delete
+}
+
+dev() {
+ default_dev
+ mkdir -p "$subpkgdir"/usr/share/$pkgname
+ mv "$pkgdir"/usr/share/$pkgname/examples "$subpkgdir"/usr/share/$pkgname/
+}
+
+md5sums="19b24f7184a8dbf7b48c1bbb565ad9fb rrdtool-1.2.30.tar.gz"
diff --git a/main/rsync/APKBUILD b/main/rsync/APKBUILD
new file mode 100644
index 00000000000..4b0e8f12053
--- /dev/null
+++ b/main/rsync/APKBUILD
@@ -0,0 +1,36 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=rsync
+pkgver=3.0.6
+pkgrel=0
+pkgdesc="A file transfer program to keep remote files in sync"
+url="http://samba.anu.edu.au/rsync/"
+license="GPL3"
+depends="uclibc"
+source="http://$pkgname.samba.org/ftp/$pkgname/$pkgname-$pkgver.tar.gz
+ rsyncd.initd
+ rsyncd.confd
+ rsyncd.conf
+ rsyncd.logrotate
+ "
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./prepare-source || return 1
+ ./configure --prefix=/usr \
+ --with-included-popt \
+ --disable-acl-support \
+ --disable-xattr-support || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -D -m 755 ../rsyncd.initd ${pkgdir}/etc/init.d/rsyncd
+ install -D -m 644 ../rsyncd.conf ${pkgdir}/etc/rsyncd.conf
+ install -D -m 644 ../rsyncd.confd ${pkgdir}/etc/conf.d/rsyncd
+ install -D -m 644 ../rsyncd.logrotate ${pkgdir}/etc/logrotate.d/rsyncd
+}
+
+md5sums="e9865d093a18e4668b9d31b635dc8e99 rsync-3.0.6.tar.gz
+492d13dbba49a9e7c77c89d01b4f617a rsyncd.initd
+e5e62e8cef29e09c22e8ba8152ec1751 rsyncd.confd
+a99211a14af1766ba849035241cd5bb2 rsyncd.conf
+169cafc6907a4c3787bb0462e9d6a5c2 rsyncd.logrotate"
diff --git a/main/rsync/rsyncd.conf b/main/rsync/rsyncd.conf
new file mode 100644
index 00000000000..b6dd5994d40
--- /dev/null
+++ b/main/rsync/rsyncd.conf
@@ -0,0 +1,10 @@
+# /etc/rsyncd.conf
+
+# Minimal configuration file for rsync daemon
+# See rsync(1) and rsyncd.conf(5) man pages for help
+
+# This line is required by the /etc/init.d/rsyncd script
+pid file = /var/run/rsyncd.pid
+use chroot = yes
+read only = yes
+
diff --git a/main/rsync/rsyncd.confd b/main/rsync/rsyncd.confd
new file mode 100644
index 00000000000..c3d897ed2f2
--- /dev/null
+++ b/main/rsync/rsyncd.confd
@@ -0,0 +1,5 @@
+# /etc/conf.d/rsyncd: config file for /etc/init.d/rsyncd
+
+# see man pages for rsync or run `rsync --help`
+# for valid cmdline options
+#RSYNC_OPTS=""
diff --git a/main/rsync/rsyncd.initd b/main/rsync/rsyncd.initd
new file mode 100644
index 00000000000..1b20282296a
--- /dev/null
+++ b/main/rsync/rsyncd.initd
@@ -0,0 +1,23 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/rsync/files/rsyncd.init.d,v 1.5 2007/02/23 11:33:59 uberlord Exp $
+
+depend() {
+ use net
+}
+
+start() {
+ ebegin "Starting rsyncd"
+ start-stop-daemon --start --exec /usr/bin/rsync \
+ --pidfile /var/run/rsyncd.pid \
+ -- --daemon ${RSYNC_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping rsyncd"
+ start-stop-daemon --stop --exec /usr/bin/rsync \
+ --pidfile /var/run/rsyncd.pid
+ eend $?
+}
diff --git a/main/rsync/rsyncd.logrotate b/main/rsync/rsyncd.logrotate
new file mode 100644
index 00000000000..34bcf72d210
--- /dev/null
+++ b/main/rsync/rsyncd.logrotate
@@ -0,0 +1,9 @@
+/var/log/rsync.log {
+ compress
+ maxage 365
+ rotate 7
+ size=+1024k
+ notifempty
+ missingok
+ copytruncate
+}
diff --git a/main/ruby/APKBUILD b/main/ruby/APKBUILD
new file mode 100644
index 00000000000..ffeb781502a
--- /dev/null
+++ b/main/ruby/APKBUILD
@@ -0,0 +1,44 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=ruby
+pkgver=1.8.7_p174
+_pkgver=1.8.7-p174
+pkgrel=1
+pkgdesc="An object-oriented language for quick and easy programming"
+url="http://www.ruby-lang.org/en/"
+license="Ruby"
+depends=
+makedepends="zlib-dev openssl-dev libiconv-dev gdbm-dev db-dev readline-dev"
+subpackages="$pkgname-doc $pkgname-dev"
+source="ftp://ftp.ruby-lang.org/pub/ruby/1.8/${pkgname}-${_pkgver}.tar.bz2"
+#
+# maybe its a good idea to split dep libs to seperate pkg's.
+#
+build() {
+ cd "$srcdir/$pkgname-${_pkgver}"
+
+ # -fomit-frame-pointer makes ruby segfault, see gentoo bug #150413
+ # In many places aliasing rules are broken; play it safe
+ # as it's risky with newer compilers to leave it as it is.
+ export CFLAGS="$CFLAGS -fno-omit-frame-pointer -fno-strict-aliasing"
+
+ # turn off distcc/ccache
+ # http://bugs.alpinelinux.org/issues/show/1
+ export CC=cc
+
+ ./configure --build=${CHOST:-i486-alpine-linux-uclibc} \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-sitedir='/usr/local/lib/site_ruby' \
+ --with-extra-site-search-path='/usr/lib/site_ruby/$(ruby_ver)/i686-linux' \
+ --enable-shared
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}"/COPYING || return 1
+
+}
+
+md5sums="88c45aaf627b4404e5e4273cb03ba2ee ruby-1.8.7-p174.tar.bz2"
diff --git a/main/rubygems/APKBUILD b/main/rubygems/APKBUILD
new file mode 100644
index 00000000000..8ba7c48834c
--- /dev/null
+++ b/main/rubygems/APKBUILD
@@ -0,0 +1,21 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=rubygems
+pkgver=1.3.1
+pkgrel=0
+pkgdesc="Ruby package manager"
+url="http://docs.rubygems.org"
+license="GPL"
+depends="ruby"
+makedepends="ruby-dev"
+source="http://rubyforge.org/frs/download.php/45905/${pkgname}-${pkgver}.tgz
+rubygems-1.3.1-setup.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch -p0 -i "$srcdir"/rubygems-1.3.1-setup.patch
+ ruby setup.rb --prefix=/usr --destdir "$pkgdir"
+}
+
+md5sums="a04ee6f6897077c5b75f5fd1e134c5a9 rubygems-1.3.1.tgz
+40ef7562319ac6f82bbbe7315c78bdbb rubygems-1.3.1-setup.patch"
diff --git a/main/rubygems/rubygems-1.3.1-setup.patch b/main/rubygems/rubygems-1.3.1-setup.patch
new file mode 100644
index 00000000000..3b76ad3f999
--- /dev/null
+++ b/main/rubygems/rubygems-1.3.1-setup.patch
@@ -0,0 +1,53 @@
+--- setup.rb.~1~ 2008-06-22 01:51:11.000000000 +0200
++++ setup.rb 2008-06-28 09:05:54.923666929 +0200
+@@ -128,8 +128,8 @@
+ lib_dir = Gem::ConfigMap[site_or_vendor]
+ bin_dir = Gem::ConfigMap[:bindir]
+ else
+- lib_dir = File.join prefix, 'lib'
+- bin_dir = File.join prefix, 'bin'
++ lib_dir = File.join prefix, Gem::ConfigMap[site_or_vendor]
++ bin_dir = File.join prefix, Gem::ConfigMap[:bindir]
+ end
+ end
+
+@@ -240,19 +240,6 @@
+ end
+ end
+
+-# Remove source caches
+-if install_destdir.empty?
+- require 'rubygems/source_info_cache'
+-
+- user_cache_file = File.join(install_destdir,
+- Gem::SourceInfoCache.user_cache_file)
+- system_cache_file = File.join(install_destdir,
+- Gem::SourceInfoCache.system_cache_file)
+-
+- rm_f user_cache_file if File.writable? File.dirname(user_cache_file)
+- rm_f system_cache_file if File.writable? File.dirname(system_cache_file)
+-end
+-
+ # install RDoc
+
+ gem_doc_dir = File.join Gem.dir, 'doc'
+@@ -262,10 +249,6 @@
+ if File.writable? gem_doc_dir and
+ (not File.exist? rubygems_doc_dir or
+ File.writable? rubygems_doc_dir) then
+- puts "Removing old RubyGems RDoc and ri"
+- Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
+- rm_rf dir
+- end
+
+ def run_rdoc(*args)
+ begin
+@@ -277,7 +260,7 @@
+
+ args << '--quiet'
+ args << '--main' << 'README'
+- args << '.' << 'README' << 'LICENSE.txt' << 'GPL.txt'
++ args << '.' << 'README'
+
+ r = RDoc::RDoc.new
+ r.document args
diff --git a/main/run-parts/APKBUILD b/main/run-parts/APKBUILD
new file mode 100644
index 00000000000..5854fa5d81f
--- /dev/null
+++ b/main/run-parts/APKBUILD
@@ -0,0 +1,19 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=run-parts
+pkgver=3.1.3
+pkgrel=0
+pkgdesc="run-parts from the debianutils package"
+url="http://packages.qa.debian.org/d/debianutils.html"
+license="GPL"
+depends=
+subpackages="$pkgname-doc"
+source="http://ftp.debian.org/debian/pool/main/d/debianutils/debianutils_$pkgver.tar.gz"
+
+build () {
+ cd $srcdir/debianutils-$pkgver
+ ./configure --prefix=/usr
+ make
+ install -D -m755 run-parts $pkgdir/usr/bin/run-parts
+ install -D -m644 run-parts.8 $pkgdir/usr/share/man/man8/run-parts.8
+}
+md5sums="42c759ff41851313bb0b9c419598c04c debianutils_3.1.3.tar.gz"
diff --git a/main/samba/APKBUILD b/main/samba/APKBUILD
new file mode 100644
index 00000000000..c28a6e2de31
--- /dev/null
+++ b/main/samba/APKBUILD
@@ -0,0 +1,99 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=samba
+pkgver=3.3.6
+pkgrel=0
+pkgdesc="Tools to access a server's filespace and printers via SMB"
+url="http://www.samba.org"
+license="GPL3"
+subpackages="$pkgname-dev $pkgname-doc winbind $pkgname-common
+ $pkgname-initscript tdb"
+depends="samba-initscript"
+makedepends="db-dev popt-dev ncurses-dev openldap-dev heimdal-dev"
+source="http://us1.$pkgname.org/$pkgname/ftp/stable/$pkgname-$pkgver.tar.gz
+ samba.initd
+ samba.confd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver/source
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc/samba \
+ --with-configdir=/etc/samba \
+ --localstatedir=/var \
+ --with-fhs \
+ --with-lockdir=/var/cache/samba \
+ --with-piddir=/var/run/samba \
+ --with-logfilebase=/var/log/samba \
+ --without-pam \
+ --with-ads \
+ --with-krb5 \
+ --with-libsmbclient \
+ --with-shared-modules=idmap_rid,imap_ad \
+ --disable-nss-wrapper \
+ --disable-dnssd \
+ --disable-swat
+ make everything || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -d "$pkgdir"/var/log/samba \
+ "$pkgdir"/usr/share/doc/samba
+ cd "$srcdir"/$pkgname-$pkgver
+ cp -r examples "$pkgdir"/usr/share/doc/samba/
+ install -D packaging/RHEL/setup/smbusers "$pkgdir"/etc/samba/smbusers
+}
+
+initscript() {
+ pkgdesc="Init script for Samba"
+ depends=""
+ install -Dm755 $srcdir/samba.initd "$subpkgdir"/etc/init.d/samba
+ install -Dm644 $srcdir/samba.confd "$subpkgdir"/etc/conf.d/samba
+}
+
+_mv_files() {
+ local i
+ for i in "$@"; do
+ mkdir -p "$subpkgdir"/${i%/*}
+ mv "$pkgdir"/$i "$subpkgdir"/$i || return 1
+ done
+}
+
+winbind() {
+ pkgdesc="Samba user and group resolver"
+ depends=
+ cd "$pkgdir"
+ _mv_files \
+ usr/bin/wbinfo \
+ usr/bin/ntlm_auth \
+ usr/sbin/winbindd \
+ usr/lib/samba/idmap \
+ usr/lib/libwbclient*
+}
+
+common() {
+ pkgdesc="Samba common files for both client an servers"
+ depends=
+ cd "$pkgdir"
+ _mv_files \
+ usr/bin/net \
+ usr/bin/nmblookup \
+ usr/bin/smbpasswd \
+ usr/bin/testparm \
+ usr/lib/samba/*.dat \
+ usr/lib/libtalloc* \
+ var/run/samba \
+ var/cache/samba \
+ var/log/samba
+}
+
+tdb() {
+ pkgdesc="Trivial database"
+ depends=
+ cd "$pkgdir"
+ _mv_files \
+ usr/lib/libtdb* \
+ usr/bin/tdb*
+}
+
+md5sums="858cb6c640358be0e81297c5de615a3c samba-3.3.6.tar.gz
+1b701fdb22c52c63b3af0e4a286a9329 samba.initd
+c150433426e18261e6e3eed3930e1a76 samba.confd"
diff --git a/main/samba/samba.confd b/main/samba/samba.confd
new file mode 100644
index 00000000000..3788c3c173c
--- /dev/null
+++ b/main/samba/samba.confd
@@ -0,0 +1,6 @@
+# add "winbindd" to daemon_list if you want start winbind from here as well
+daemon_list="smbd nmbd"
+
+smbd_options="-D"
+nmbd_options="-D"
+#winbindd_options=""
diff --git a/main/samba/samba.initd b/main/samba/samba.initd
new file mode 100644
index 00000000000..d2d395a9897
--- /dev/null
+++ b/main/samba/samba.initd
@@ -0,0 +1,64 @@
+#!/sbin/runscript
+
+opts="reload"
+
+DAEMON=${SVCNAME#samba.}
+if [ "$DAEMON" != "samba" ]; then
+ daemon_list=$DAEMON
+fi
+
+depend() {
+ need net
+}
+
+start_smbd() {
+ start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \
+ ${smbd_options:-"-D"}
+}
+
+stop_smbd() {
+ start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid
+}
+
+start_nmbd() {
+ start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \
+ ${nmbd_options:-"-D"}
+}
+
+stop_nmbd() {
+ start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid
+}
+
+start_winbindd() {
+ start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \
+ $winbindd_options
+}
+
+stop_winbindd() {
+ start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid
+}
+
+start() {
+ for i in $daemon_list; do
+ ebegin "Starting $i"
+ start_$i
+ eend $?
+ done
+}
+
+stop() {
+ for i in $daemon_list; do
+ ebegin "Stopping $i"
+ stop_$i
+ eend $?
+ done
+}
+
+reload() {
+ for i in $daemon_list; do
+ ebegin "Reloading $i"
+ killall -HUP $i
+ eend $?
+ done
+}
+
diff --git a/main/screen/APKBUILD b/main/screen/APKBUILD
new file mode 100644
index 00000000000..ffa48fa2080
--- /dev/null
+++ b/main/screen/APKBUILD
@@ -0,0 +1,33 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer:
+pkgname=screen
+pkgver=4.0.3
+pkgrel=0
+pkgdesc="A window manager that multiplexes a physical terminal"
+url="http://ftp.gnu.org/gnu/screen/"
+license="GPL"
+depends="uclibc ncurses"
+makedepends=""
+install=
+subpackages="$pkgname-doc"
+source="http://ftp.gnu.org/gnu/screen/$pkgname-$pkgver.tar.gz
+ $pkgname-$pkgver.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="8506fd205028a96c741e4037de6e3c42 screen-4.0.3.tar.gz
+243e18daf4b2bbff898fdf0d772fad52 screen-4.0.3.patch"
diff --git a/main/screen/screen-4.0.3.patch b/main/screen/screen-4.0.3.patch
new file mode 100644
index 00000000000..4a90f49b91f
--- /dev/null
+++ b/main/screen/screen-4.0.3.patch
@@ -0,0 +1,272 @@
+--- screen-4.0.3-orig/acls.h Mon Sep 8 14:23:38 2003
++++ screen-4.0.3/acls.h Fri Feb 27 18:32:07 2009
+@@ -20,6 +20,8 @@
+ *
+ ****************************************************************
+ */
++#ifndef _SCREEN_ACLS_H_
++#define _SCREEN_ACLS_H_
+
+ #ifdef MULTIUSER
+
+@@ -91,3 +93,4 @@
+
+ extern int DefaultEsc, DefaultMetaEsc;
+
++#endif /* define _SCREEN_ACLS_H_ */
+--- screen-4.0.3-orig/ansi.h Mon Feb 24 16:55:08 2003
++++ screen-4.0.3/ansi.h Fri Feb 27 18:32:49 2009
+@@ -21,6 +21,8 @@
+ ****************************************************************
+ * $Id: ansi.h,v 1.6 1994/05/31 12:31:28 mlschroe Exp $ FAU
+ */
++#ifndef _SCREEN_ANSI_H_
++#define _SCREEN_ANSI_H_
+
+ #define NATTR 6
+
+@@ -168,3 +170,5 @@
+ # define dw_left(ml, x, enc) 0
+ # define dw_right(ml, x, enc) 0
+ #endif
++
++#endif /* define _SCREEN_ANSI_H_ */
+--- screen-4.0.3-orig/braille.h Sat Apr 28 13:26:42 2001
++++ screen-4.0.3/braille.h Fri Feb 27 18:33:51 2009
+@@ -24,6 +24,8 @@
+ ****************************************************************
+ * $Id: braille.h,v 1.1 1995/09/06 15:51:18 jnweiger Exp jnweiger $ FAU
+ */
++#ifndef _SCREEN_BRAILLE_H_
++#define _SCREEN_BRAILLE_H_
+
+ #ifdef HAVE_BRAILLE
+
+@@ -81,3 +83,5 @@
+ #define BD_FORE bd.bd_dpy->d_fore
+
+ #endif
++
++#endif /* define _SCREEN_BRAILLE_H_ */
+--- screen-4.0.3-orig/display.h Tue Jul 1 14:01:42 2003
++++ screen-4.0.3/display.h Fri Feb 27 18:34:30 2009
+@@ -21,6 +21,8 @@
+ ****************************************************************
+ * $Id: display.h,v 1.9 1994/05/31 12:31:54 mlschroe Exp $ FAU
+ */
++#ifndef _SCREEN_DISPLAY_H_
++#define _SCREEN_DISPLAY_H_
+
+ #ifdef MAPKEYS
+
+@@ -343,3 +345,5 @@
+ #define HSTATUS_MESSAGE 2
+ #define HSTATUS_HS 3
+ #define HSTATUS_ALWAYS (1<<2)
++
++#endif /* define _SCREEN_DISPLAY_H_ */
+--- screen-4.0.3-orig/extern.h Fri Aug 22 12:27:57 2003
++++ screen-4.0.3/extern.h Fri Feb 27 18:35:17 2009
+@@ -21,6 +21,8 @@
+ ****************************************************************
+ * $Id: extern.h,v 1.18 1994/05/31 12:31:57 mlschroe Exp $ FAU
+ */
++#ifndef _SCREEN_EXTERN_H_
++#define _SCREEN_EXTERN_H_
+
+ #if !defined(__GNUC__) || __GNUC__ < 2
+ #undef __attribute__
+@@ -490,3 +492,5 @@
+ # endif
+ #endif
+ extern int EncodeChar __P((char *, int, int, int *));
++
++#endif /* define _SCREEN_EXTERN_H_ */
+--- screen-4.0.3-orig/image.h Fri Dec 5 13:45:41 2003
++++ screen-4.0.3/image.h Fri Feb 27 18:35:53 2009
+@@ -21,8 +21,9 @@
+ ****************************************************************
+ * $Id: image.h,v 1.9 1994/05/31 12:31:54 mlschroe Exp $ FAU
+ */
++#ifndef _SCREEN_IMAGE_H_
++#define _SCREEN_IMAGE_H_
+
+-
+ #undef IFFONT
+ #undef IFCOLOR
+
+@@ -161,3 +162,5 @@
+ # define cole2i(c) ((c) ^ 9)
+ # endif
+ #endif
++
++#endif /* define _SCREEN_IMAGE_H_ */
+--- screen-4.0.3-orig/layer.h Tue Jan 8 15:42:25 2002
++++ screen-4.0.3/layer.h Fri Feb 27 18:36:50 2009
+@@ -22,6 +22,9 @@
+ * $Id: overlay.h,v 1.3 1994/05/31 12:32:31 mlschroe Exp $ FAU
+ */
+
++#ifndef _SCREEN_LAYER_H_
++#define _SCREEN_LAYER_H_
++
+ /*
+ * This is the overlay structure. It is used to create a seperate
+ * layer over the current windows.
+@@ -103,3 +106,4 @@
+ display = olddisplay; \
+ } while(0)
+
++#endif /* define _SCREEN_LAYER_H_ */
+--- screen-4.0.3-orig/logfile.h Tue Jan 8 15:42:27 2002
++++ screen-4.0.3/logfile.h Fri Feb 27 18:37:29 2009
+@@ -22,6 +22,9 @@
+ * $Id: logfile.h,v 1.11 1994/05/31 12:33:27 jnweiger Exp $ FAU
+ */
+
++#ifndef _SCREEN_LOGFILE_H_
++#define _SCREEN_LOGFILE_H_
++
+ struct logfile
+ {
+ struct logfile *next;
+@@ -80,3 +83,5 @@
+ * It closes fd and opens wantfd to access whatever fd accessed.
+ */
+ int lf_move_fd __P((int fd, int wantfd));
++
++#endif /* define _SCREEN_LOGFILE_H_ */
+--- screen-4.0.3-orig/mark.h Tue Jan 8 15:42:30 2002
++++ screen-4.0.3/mark.h Fri Feb 27 18:38:02 2009
+@@ -21,6 +21,8 @@
+ ****************************************************************
+ * $Id: mark.h,v 1.1.1.1 1993/06/16 23:51:13 jnweiger Exp $ FAU
+ */
++#ifndef _SCREEN_MARK_H_
++#define _SCREEN_MARK_H_
+
+ struct markdata
+ {
+@@ -47,3 +49,4 @@
+ #define W2D(y) ((y) - markdata->hist_offset)
+ #define D2W(y) ((y) + markdata->hist_offset)
+
++#endif /* define _SCREEN_MARK_H_ */
+--- screen-4.0.3-orig/os.h Tue Jan 8 15:42:33 2002
++++ screen-4.0.3/os.h Fri Feb 27 18:39:09 2009
+@@ -21,6 +21,8 @@
+ ****************************************************************
+ * $Id: os.h,v 1.10 1994/05/31 12:32:22 mlschroe Exp $ FAU
+ */
++#ifndef _SCREEN_OS_H_
++#define _SCREEN_OS_H_
+
+ #include <stdio.h>
+ #include <errno.h>
+@@ -531,3 +533,4 @@
+ */
+ #define IOSIZE 4096
+
++#endif /* define _SCREEN_OS_H_ */
+--- screen-4.0.3-orig/osdef.h.in Sat Apr 28 13:26:43 2001
++++ screen-4.0.3/osdef.h.in Fri Feb 27 18:38:36 2009
+@@ -27,6 +27,8 @@
+ * mangled the screen source through 'gcc -Wall'.
+ ****************************************************************
+ */
++#ifndef _SCREEN_OSDEF_H_
++#define _SCREEN_OSDEF_H_
+
+ extern int printf __P((char *, ...));
+ extern int fprintf __P((FILE *, char *, ...));
+@@ -199,3 +201,4 @@
+ extern int getloadavg(double *, int);
+ #endif
+
++#endif /* define _SCREEN_OSDEF_H_ */
+--- screen-4.0.3-orig/patchlevel.h Mon Oct 23 13:04:11 2006
++++ screen-4.0.3/patchlevel.h Fri Feb 27 18:40:53 2009
+@@ -523,6 +523,8 @@
+ * (cstone & Rich Felker).
+ * -- DISTRIBUTED
+ */
++#ifndef _SCREEN_PATCHLEVEL_H_
++#define _SCREEN_PATCHLEVEL_H_
+
+ #define ORIGIN "FAU"
+ #define REV 4
+@@ -530,3 +532,5 @@
+ #define PATCHLEVEL 3
+ #define DATE "23-Oct-06"
+ #define STATE ""
++
++#endif /* define _SCREEN_PATCHLEVEL_H_ */
+--- screen-4.0.3-orig/pty.c Mon Sep 8 14:26:18 2003
++++ screen-4.0.3/pty.c Fri Feb 27 19:31:53 2009
+@@ -33,11 +33,6 @@
+ # include <sys/ioctl.h>
+ #endif
+
+-/* for solaris 2.1, Unixware (SVR4.2) and possibly others */
+-#ifdef HAVE_SVR4_PTYS
+-# include <sys/stropts.h>
+-#endif
+-
+ #if defined(sun) && defined(LOCKPTY) && !defined(TIOCEXCL)
+ # include <sys/ttold.h>
+ #endif
+--- screen-4.0.3-orig/sched.h Tue Jan 8 15:42:43 2002
++++ screen-4.0.3/sched.h Fri Feb 27 19:39:49 2009
+@@ -21,6 +21,9 @@
+ ****************************************************************
+ * $Id: sched.h,v 1.1.1.1 1993/06/16 23:51:13 jnweiger Exp $ FAU
+ */
++#ifndef _SCREEN_SCHED_H_
++#define _SCREEN_SCHED_H_
++#include <sys/types.h>
+
+ struct event
+ {
+@@ -41,3 +44,5 @@
+ #define EV_READ 1
+ #define EV_WRITE 2
+ #define EV_ALWAYS 3
++
++#endif /* define _SCREEN_SCHED_H_ */
+--- screen-4.0.3-orig/screen.h Fri Aug 22 12:28:43 2003
++++ screen-4.0.3/screen.h Fri Feb 27 18:42:11 2009
+@@ -22,6 +22,9 @@
+ * $Id: screen.h,v 1.12 1994/05/31 12:32:54 mlschroe Exp $ FAU
+ */
+
++#ifndef _SCREEN_SCREEN_H_
++#define _SCREEN_SCREEN_H_
++
+ #include "os.h"
+
+ #if defined(__STDC__)
+@@ -293,3 +296,5 @@
+ */
+ #define WLIST_NUM 0
+ #define WLIST_MRU 1
++
++#endif /* define _SCREEN_SCREEN_H_ */
+--- screen-4.0.3-orig/window.h Thu Aug 21 14:57:30 2003
++++ screen-4.0.3/window.h Fri Feb 27 18:42:45 2009
+@@ -21,8 +21,9 @@
+ ****************************************************************
+ * $Id: window.h,v 1.11 1994/05/31 12:33:27 mlschroe Exp $ FAU
+ */
++#ifndef _SCREEN_WINDOW_H_
++#define _SCREEN_WINDOW_H_
+
+-
+ /* keep this in sync with the initialisations in window.c */
+ struct NewWindow
+ {
+@@ -315,3 +316,5 @@
+ : &fore->w_mlines[y - fore->w_histheight])
+
+ #define Layer2Window(l) ((struct win *)(l)->l_bottom->l_data)
++
++#endif /* define _SCREEN_WINDOW_H_ */
diff --git a/main/sed/APKBUILD b/main/sed/APKBUILD
new file mode 100644
index 00000000000..99ba1e6f8b6
--- /dev/null
+++ b/main/sed/APKBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sed
+pkgver=4.2.1
+pkgrel=0
+subpackages="$pkgname-doc"
+pkgdesc="GNU stream editor"
+url="http://www.gnu.org/software/sed"
+license="GPL"
+depends=
+makedepends=""
+install="$pkgname.post-deinstall"
+source="ftp://ftp.gnu.org/pub/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-i18n \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="f0fd4d7da574d4707e442285fd2d3b86 sed-4.2.1.tar.gz
+b84506d253e04db3c5af9016fead45a3 sed.post-deinstall"
diff --git a/main/sed/sed.post-deinstall b/main/sed/sed.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/sed/sed.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/sfic/APKBUILD b/main/sfic/APKBUILD
new file mode 100644
index 00000000000..3f781b4dee1
--- /dev/null
+++ b/main/sfic/APKBUILD
@@ -0,0 +1,29 @@
+pkgdesc="Small and Simple File Integrity Checker"
+pkgname=sfic
+pkgver=0.1.7
+pkgrel=1
+depends=uclibc
+license=GPL
+makedepends="autoconf automake samba-dev"
+depends="tdb uclibc"
+arch=i486
+url=http://sfic.sourceforge.net
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ $pkgname-0.1.7-signal.patch"
+
+subpackages="$pkgname-doc"
+
+build() {
+ cd $srcdir/$pkgname-$pkgver
+ patch -p1 < ../$pkgname-0.1.7-signal.patch || return 1
+
+ aclocal
+ autoconf
+ automake --add-missing || return 1
+ ./configure --prefix=/usr
+ make || return 1
+ make install DESTDIR="$pkgdir"
+}
+
+md5sums="6197f7a1e8b0fc4887d4573f67b7bb81 sfic-0.1.7.tar.gz
+e0c284f8b4e355b3ea52927fb02e163a sfic-0.1.7-signal.patch"
diff --git a/main/sfic/sfic-0.1.7-signal.patch b/main/sfic/sfic-0.1.7-signal.patch
new file mode 100644
index 00000000000..54538aac1ab
--- /dev/null
+++ b/main/sfic/sfic-0.1.7-signal.patch
@@ -0,0 +1,10 @@
+--- sfic-0.1.7.orig/src/sfic.c 2009-04-13 13:25:49.000000000 +0000
++++ sfic-0.1.7/src/sfic.c 2009-04-13 13:26:14.000000000 +0000
+@@ -37,6 +37,7 @@
+ #include <dirent.h>
+ #include <stdarg.h>
+
++#include <signal.h>
+ #include <tdb.h>
+
+ #include "heap.h"
diff --git a/main/shorewall-common/APKBUILD b/main/shorewall-common/APKBUILD
new file mode 100644
index 00000000000..1c0a51d8a6b
--- /dev/null
+++ b/main/shorewall-common/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=shorewall-common
+pkgver=4.2.10
+pkgrel=0
+pkgdesc="Shoreline Firewall is an iptables-based firewall for Linux."
+url="http://www.shorewall.net/"
+license="GPL-2"
+depends="iptables iproute2"
+subpackages="$pkgname-doc"
+source="http://www1.shorewall.net/pub/shorewall/4.2/shorewall-$pkgver/shorewall-common-$pkgver.tar.bz2
+ shorewall.initd
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ PREFIX="${pkgdir}" ./install.sh || return 1
+ install -Dm755 "$srcdir"/shorewall.initd "$pkgdir"/etc/init.d/shorewall
+}
+md5sums="49bdbbae8dec65154c4e5538ed3c9865 shorewall-common-4.2.10.tar.bz2
+71fb6da1f50f5c6e9dd35b60b3629531 shorewall.initd"
diff --git a/main/shorewall-common/shorewall.initd b/main/shorewall-common/shorewall.initd
new file mode 100644
index 00000000000..9dda676c574
--- /dev/null
+++ b/main/shorewall-common/shorewall.initd
@@ -0,0 +1,80 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-firewall/shorewall-common/files/shorewall.initd,v 1.2 2008/05/04 13:16:40 pva Exp $
+
+opts="start stop restart clear reset refresh check"
+
+depend() {
+ need net
+ provide firewall
+ after ulogd
+}
+
+start() {
+ ebegin "Starting firewall"
+ /sbin/shorewall -f start 1>/dev/null
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping firewall"
+ /sbin/shorewall stop 1>/dev/null
+ eend $?
+}
+
+restart() {
+ # shorewall comes with its own control script that includes a
+ # restart function, so refrain from calling svc_stop/svc_start
+ # here. Note that this comment is required to fix bug 55576;
+ # runscript.sh greps this script... (09 Jul 2004 agriffis)
+ ebegin "Restarting firewall"
+ /sbin/shorewall status >/dev/null
+ if [ $? != 0 ] ; then
+ svc_start
+ else
+ if [ -f /var/lib/shorewall/restore ] ; then
+ /sbin/shorewall restore
+ else
+ /sbin/shorewall restart 1>/dev/null
+ fi
+ fi
+ eend $?
+}
+
+clear() {
+ # clear will remove all the rules and bring the system to an unfirewalled
+ # state. (21 Nov 2004 eldad)
+
+ ebegin "Clearing all firewall rules and setting policy to ACCEPT"
+ /sbin/shorewall clear
+ eend $?
+}
+
+reset() {
+ # reset the packet and byte counters in the firewall
+
+ ebegin "Resetting the packet and byte counters in the firewall"
+ /sbin/shorewall reset
+ eend $?
+}
+
+refresh() {
+ # refresh the rules involving the broadcast addresses of firewall
+ # interfaces, the black list, traffic control rules and
+ # ECN control rules
+
+ ebegin "Refreshing firewall rules"
+ /sbin/shorewall refresh
+ eend $?
+}
+
+check() {
+ # perform cursory validation of the zones, interfaces, hosts, rules
+ # and policy files. CAUTION: does not parse and validate the generated
+ # iptables commands.
+
+ ebegin "Checking configuration files"
+ /sbin/shorewall check
+ eend $?
+}
diff --git a/main/shorewall-lite/APKBUILD b/main/shorewall-lite/APKBUILD
new file mode 100644
index 00000000000..9c98a3bfdac
--- /dev/null
+++ b/main/shorewall-lite/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=shorewall-lite
+pkgver=4.2.10
+pkgrel=0
+pkgdesc="An iptables-based firewall whose config is handled by a normal Shorewall"
+url="http://www.shorewall.net/"
+license="GPL-2"
+depends="iptables iproute2"
+#subpackages="$pkgname-doc"
+source="http://www1.shorewall.net/pub/shorewall/4.2/shorewall-$pkgver/$pkgname-$pkgver.tar.bz2
+ $pkgname.initd
+ "
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ PREFIX="$pkgdir" ./install.sh || return 1
+ install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+}
+md5sums="ef5958819ba18801bacfe20e67184f2a shorewall-lite-4.2.10.tar.bz2
+17a37c934aeb601ce288f77000253e1e shorewall-lite.initd"
diff --git a/main/shorewall-lite/shorewall-lite.initd b/main/shorewall-lite/shorewall-lite.initd
new file mode 100755
index 00000000000..d2537e8a129
--- /dev/null
+++ b/main/shorewall-lite/shorewall-lite.initd
@@ -0,0 +1,65 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-firewall/shorewall-lite/files/shorewall-lite,v 1.1 2007/05/20 22:32:36 mjolnir Exp $
+
+opts="start stop restart clear reset refresh"
+
+depend() {
+ need net
+ provide firewall
+ after ulogd
+}
+
+start() {
+ ebegin "Starting firewall"
+ /sbin/shorewall-lite -f start 1>/dev/null
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping firewall"
+ /sbin/shorewall-lite stop 1>/dev/null
+ eend $?
+}
+
+restart() {
+ # shorewall comes with its own control script that includes a
+ # restart function, so refrain from calling svc_stop/svc_start
+ # here. Note that this comment is required to fix bug 55576;
+ # runscript.sh greps this script... (09 Jul 2004 agriffis)
+ ebegin "Restarting firewall"
+ if [ -f /var/lib/shorewall-lite/restore ] ; then
+ /sbin/shorewall-lite restore
+ else
+ /sbin/shorewall-lite restart 1>/dev/null
+ fi
+ eend $?
+}
+
+clear() {
+ # clear will remove all the rules and bring the system to an unfirewalled
+ # state. (21 Nov 2004 eldad)
+
+ ebegin "Clearing all firewall rules and setting policy to ACCEPT"
+ /sbin/shorewall-lite clear
+ eend $?
+}
+
+reset() {
+ # reset the packet and byte counters in the firewall
+
+ ebegin "Resetting the packet and byte counters in the firewall"
+ /sbin/shorewall-lite reset
+ eend $?
+}
+
+refresh() {
+ # refresh the rules involving the broadcast addresses of firewall
+ # interfaces, the black list, traffic control rules and
+ # ECN control rules
+
+ ebegin "Refreshing firewall rules"
+ /sbin/shorewall-lite refresh
+ eend $?
+}
diff --git a/main/shorewall-perl/APKBUILD b/main/shorewall-perl/APKBUILD
new file mode 100644
index 00000000000..e601c96a52e
--- /dev/null
+++ b/main/shorewall-perl/APKBUILD
@@ -0,0 +1,16 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=shorewall-perl
+pkgver=4.2.10.3
+_v=4.2.10
+pkgrel=0
+pkgdesc="Shoreline Firewall Perl-based compiler"
+url="http://www.shorewall.net/"
+license="GPL-2"
+depends="shorewall-common"
+source="http://www1.shorewall.net/pub/shorewall/${_v%.*}/shorewall-${_v}/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ PREFIX="$pkgdir" ./install.sh || return 1
+}
+md5sums="f19bed40fe28a905fd08482b9dc5f7ce shorewall-perl-4.2.10.3.tar.bz2"
diff --git a/main/shorewall-shell/APKBUILD b/main/shorewall-shell/APKBUILD
new file mode 100644
index 00000000000..643562f2093
--- /dev/null
+++ b/main/shorewall-shell/APKBUILD
@@ -0,0 +1,17 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=shorewall-shell
+_v=4.2.10
+pkgver=4.2.10
+pkgrel=0
+pkgdesc="Shoreline Firewall shell-based compiler."
+url="http://www.shorewall.net/"
+license="GPL-2"
+depends="shorewall-common"
+#subpackages="$pkgname-doc"
+source="http://www.shorewall.net/pub/shorewall/${_v%.*}/shorewall-$_v/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ PREFIX="$pkgdir" ./install.sh || return 1
+}
+md5sums="d6f7cbc3c502c09921ede920547d5017 shorewall-shell-4.2.10.tar.bz2"
diff --git a/main/shorewall/APKBUILD b/main/shorewall/APKBUILD
new file mode 100644
index 00000000000..735973cc26c
--- /dev/null
+++ b/main/shorewall/APKBUILD
@@ -0,0 +1,16 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=shorewall
+pkgver=4.2.10
+pkgrel=0
+pkgdesc="Meta package for shorewall"
+url="http://www.shorewall.net/"
+license="GPL"
+depends="shorewall-shell"
+makedepends=""
+source=""
+
+build() {
+ mkdir -p "$pkgdir"
+}
+
diff --git a/main/sic/APKBUILD b/main/sic/APKBUILD
new file mode 100644
index 00000000000..72e197ea08b
--- /dev/null
+++ b/main/sic/APKBUILD
@@ -0,0 +1,20 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sic
+pkgver=1.0
+pkgrel=0
+pkgdesc="an extremely simple IRC client"
+url="http://www.suckless.org/programs/sic.html"
+license="GPL"
+depends="uclibc"
+subpackages="$pkgname-doc"
+source="http://code.suckless.org/dl/tools/sic-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make PREFIX=/usr || return 1
+ make DESTDIR="$pkgdir" PREFIX=/usr install
+}
+
+md5sums="d73d07d5de3ea06e9e83b90d26749202 sic-1.0.tar.gz"
diff --git a/main/slang/APKBUILD b/main/slang/APKBUILD
new file mode 100644
index 00000000000..c1fe9620003
--- /dev/null
+++ b/main/slang/APKBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=slang
+pkgver=2.1.4
+pkgrel=0
+pkgdesc="S-Lang is a powerful interpreted language"
+url="http://www.s-lang.org/"
+license="GPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc pcre"
+makedepends="pcre-dev"
+source="ftp://ftp.fu-berlin.de/pub/unix/misc/$pkgname/v2.1/$pkgname-$pkgver.tar.gz
+ slang-2.1.3-uclibc.patch
+ "
+
+build () {
+ cd "$srcdir"/$pkgname-$pkgver
+ for i in ../*.patch; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc || return 1
+ make || return 1
+ make install-all DESTDIR="$pkgdir" || return 1
+}
+md5sums="3516f593bc04975844f26137c18275d2 slang-2.1.4.tar.gz
+56ca82f415578994b6050e769b6b7bc9 slang-2.1.3-uclibc.patch"
diff --git a/main/slang/slang-2.1.3-uclibc.patch b/main/slang/slang-2.1.3-uclibc.patch
new file mode 100644
index 00000000000..d7ed5a8d650
--- /dev/null
+++ b/main/slang/slang-2.1.3-uclibc.patch
@@ -0,0 +1,12 @@
+diff -ur slang-2.1.3.orig/src/slcommon.c slang-2.1.3/src/slcommon.c
+--- slang-2.1.3.orig/src/slcommon.c 2007-01-10 18:09:07.000000000 +0200
++++ slang-2.1.3/src/slcommon.c 2008-03-19 16:09:09.000000000 +0200
+@@ -191,7 +191,7 @@
+ return p;
+ }
+
+-#if !defined(HAVE_ISSETUGID) && defined(__GLIBC__) && (__GLIBC__ >= 2)
++#if !defined(HAVE_ISSETUGID) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !defined(__UCLIBC__)
+ extern int __libc_enable_secure;
+ # define HAVE___LIBC_ENABLE_SECURE 1
+ #endif
diff --git a/main/snort/APKBUILD b/main/snort/APKBUILD
new file mode 100644
index 00000000000..35b4820651b
--- /dev/null
+++ b/main/snort/APKBUILD
@@ -0,0 +1,40 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=snort
+pkgver=2.8.4
+pkgrel=0
+pkgdesc="An open source network intrusion prevention and detection system"
+url="http://www.snort.org/"
+license="GPL"
+depends="uclibc libpcap libnet"
+makedepends="pcre-dev libpcap-dev libnet-dev"
+install="$pkgname.pre-install"
+subpackages="$pkgname-doc $pkgname-dev"
+source="http://www.snort.org/dl/$pkgname-$pkgver.tar.gz
+ nocxx.patch
+ snort.initd
+ snort.confd
+ $install
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch configure < ../nocxx.patch || return 1
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-ipv6 \
+ --enable-gre
+ make -j1 || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+ install -D -m 755 ../snort.initd "$pkgdir"/etc/init.d/snort
+ install -D -m 644 ../snort.confd "$pkgdir"/etc/conf.d/snort
+}
+
+md5sums="193179da8db8aac5ee6b0a751ce7b76d snort-2.8.4.tar.gz
+28513788ba4d556ccd538867dc6205ab nocxx.patch
+b3207150805e7b948d958c6f86e70a5b snort.initd
+446f8d2b3435b8a6be738da978670605 snort.confd
+b9473b349cc9d21faf7b91b591f497d6 snort.pre-install"
diff --git a/main/snort/nocxx.patch b/main/snort/nocxx.patch
new file mode 100644
index 00000000000..beb1ab9006b
--- /dev/null
+++ b/main/snort/nocxx.patch
@@ -0,0 +1,15 @@
+--- a/configure 2004-12-07 21:34:23.205172545 +0000
++++ b/configure 2004-12-07 21:37:17.726654782 +0000
+@@ -5148,10 +5148,8 @@
+ :
+ else
+ { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+-See \`config.log' for more details." >&2;}
+- { (exit 1); exit 1; }; }
++See \`config.log' for more details." >&5;}
++ { echo "C++ sucks, ignoring ..." >&5; }; }
+ fi
+
+ ac_ext=cc
diff --git a/main/snort/snort.confd b/main/snort/snort.confd
new file mode 100644
index 00000000000..d4d240ac966
--- /dev/null
+++ b/main/snort/snort.confd
@@ -0,0 +1,16 @@
+# Config file for /etc/init.d/snort
+
+# This tell snort which interface to listen on (any for every interface)
+IFACE=eth0
+
+# Make sure this matches your IFACE
+PIDFILE=/var/run/snort_$IFACE.pid
+
+# You probably don't want to change this, but in case you do
+LOGDIR="/var/log/snort"
+
+# Probably not this either
+CONF=/etc/snort/snort.conf
+
+# This pulls in the options above
+SNORT_OPTS="-D -u snort -i $IFACE -l $LOGDIR -c $CONF"
diff --git a/main/snort/snort.initd b/main/snort/snort.initd
new file mode 100644
index 00000000000..a5c2b05c47e
--- /dev/null
+++ b/main/snort/snort.initd
@@ -0,0 +1,31 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-analyzer/snort/files/snort.rc7,v 1.3 2007/04/22 06:21:15 dragonheart Exp $
+
+depend() {
+ need net
+}
+
+checkconfig() {
+ if [ ! -e $CONF ] ; then
+ eerror "You need a configuration file to run snort"
+ eerror "There is an example config in /etc/snort/snort.conf.distrib"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting snort"
+ start-stop-daemon --start --quiet --exec /usr/bin/snort \
+ --pidfile ${PIDFILE} \
+ -- ${SNORT_OPTS} >/dev/null 2>&1
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping snort"
+ start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
+ eend $?
+}
diff --git a/main/snort/snort.pre-install b/main/snort/snort.pre-install
new file mode 100644
index 00000000000..e1555163a70
--- /dev/null
+++ b/main/snort/snort.pre-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+adduser -h /var/log/snort -s /bin/false -D snort 2>/dev/null
+exit 0
diff --git a/main/sntpc/APKBUILD b/main/sntpc/APKBUILD
new file mode 100644
index 00000000000..6df6a6efd08
--- /dev/null
+++ b/main/sntpc/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sntpc
+pkgver=0.9
+pkgrel=0
+pkgdesc="Simple NTP client"
+url="http://git.alpinelinux.org/cgit/sntpc"
+license="GPL-2"
+depends="uclibc"
+source="http://git.alpinelinux.org/cgit/sntpc/snapshot/sntpc-$pkgver.tar.bz2
+ sntpc.initd
+ sntpc.confd
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make || return 1
+ install -m755 -D sntpc "$pkgdir"/usr/sbin/sntpc
+ install -m755 -D "$srcdir"/sntpc.initd "$pkgdir"/etc/init.d/sntpc
+ install -m644 -D "$srcdir"/sntpc.confd "$pkgdir"/etc/conf.d/sntpc
+}
+
+md5sums="60c64d975daa3a6f371e9e81538e38db sntpc-0.9.tar.bz2
+c5018237685af2cddb0b4ede1751bee1 sntpc.initd
+4ea1ceee01f94080be86188bde8f9adc sntpc.confd"
diff --git a/main/sntpc/sntpc.confd b/main/sntpc/sntpc.confd
new file mode 100644
index 00000000000..a92e4be8684
--- /dev/null
+++ b/main/sntpc/sntpc.confd
@@ -0,0 +1,9 @@
+#
+# Set time sync interval (in seconds) here.
+# Setting SNTPC_INTERVAL to 0 will make sntp run once and just exit
+#
+
+SNTPC_INTERVAL="0"
+
+# The NTP server to use as time source
+SNTPC_HOST=pool.ntp.org
diff --git a/main/sntpc/sntpc.initd b/main/sntpc/sntpc.initd
new file mode 100644
index 00000000000..a97e51bdbd8
--- /dev/null
+++ b/main/sntpc/sntpc.initd
@@ -0,0 +1,30 @@
+#!/sbin/runscript
+
+NAME=sntpc
+DAEMON=/usr/sbin/$NAME
+
+depend() {
+ need net
+}
+
+start() {
+ local msg opts
+ if [ "$SNTPC_INTERVAL" = "0" ]; then
+ msg="Setting time from NTP source"
+ else
+ msg="Starting ${NAME}"
+ opts="-d"
+ fi
+ ebegin "$msg"
+ start-stop-daemon --start --quiet --name sntpc \
+ --exec ${DAEMON} -- \
+ -i ${SNTPC_INTERVAL} $opts ${SNTPC_HOST}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet \
+ --exec ${DAEMON}
+ eend $?
+}
diff --git a/main/spamassassin/APKBUILD b/main/spamassassin/APKBUILD
new file mode 100644
index 00000000000..3da01a62f2d
--- /dev/null
+++ b/main/spamassassin/APKBUILD
@@ -0,0 +1,30 @@
+# Contributor: Leonardo Arena <rnalrd@gmail.com>
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=spamassassin
+_realname=Mail-SpamAssassin
+pkgver=3.2.5
+pkgrel=0
+pkgdesc="The Powerful #1 Open-Source Spam Filter"
+url="http://spamassassin.apache.org"
+license="Apache"
+depends="perl perl-digest-sha1 perl-html-parser perl-net-dns perl-db_file zlib"
+makedepends="perl-dev zlib-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://www.apache.org/dist/spamassassin/source/$_realname-3.2.5.tar.gz"
+
+build() {
+ cd "$srcdir/$_realname-$pkgver"
+
+ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ install -m755 -D ../../spamd.init $pkgdir/etc/init.d/spamd
+ install -m644 -D ../../spamd.conf $pkgdir/etc/conf.d/spamd.conf
+ mkdir $pkgdir/usr/sbin
+ mv $pkgdir/usr/bin/spamd $pkgdir/usr/sbin/spamd
+ # creates file collision among perl modules
+ rm $pkgdir/usr/lib/perl5/5.10.0/i686-linux/perllocal.pod
+}
+
+md5sums="7fdc1651d0371c4a7f95ac9ae6f828a6 Mail-SpamAssassin-3.2.5.tar.gz"
diff --git a/main/spamassassin/spamd.conf b/main/spamassassin/spamd.conf
new file mode 100644
index 00000000000..b6fca036f2e
--- /dev/null
+++ b/main/spamassassin/spamd.conf
@@ -0,0 +1,46 @@
+# Config file for /etc/init.d/spamd
+
+
+# ***WARNING***
+# spamd was not designed to listed to an untrusted network. spamd
+# is vulnerable to DoS attacks (and eternal doom) if used to listen
+# to an untrusted network.
+#
+
+
+# Some options:
+#
+# -c to create a per user configuration file
+# -H [dir] to switch home dirs for helper apps, dir optional
+# -i [ip] to listen on the specified IP,
+# 127.0.0.1 if omitted,
+# 0.0.0.0 (ie. all) if given without value;
+# must be used in combination with -A to actually allow
+# connections from anybody but localhost
+# -m limit to set the number of children, default 5
+# -u user the user to run spamd as
+# -L if you want to run no net tests
+#
+# for more help look in man spamd
+#
+# Note: if you plan on using the -u flag to spamd you will need to
+# make sure the location of the PID file is writable by that user.
+# This can be done by making the directory /var/run/spamd and
+# changing the owner to the UID that runs spamd. You will then
+# need to edit $pidfile in /etc/init.d/spamd. This should fix the
+# problem with stop/restart in the init scripts.
+#
+# See http://bugs.gentoo.org/show_bug.cgi?id=70124 for a full
+# explanation.
+
+SPAMD_OPTS="-m 5 -c -H"
+
+# spamd stores its pid in this file. If you use the -u option to
+# run spamd under another user, you might need to adjust it.
+
+PIDFILE="/var/run/spamd.pid"
+
+# SPAMD_NICELEVEL lets you set the 'nice'ness of the running
+# spamd process
+
+# SPAMD_NICELEVEL=5
diff --git a/main/spamassassin/spamd.init b/main/spamassassin/spamd.init
new file mode 100644
index 00000000000..89723889f4c
--- /dev/null
+++ b/main/spamassassin/spamd.init
@@ -0,0 +1,39 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/mail-filter/spamassassin/files/3.0.0-spamd.init,v 1.8 2008/05/14 21:25:56 sbriesen Exp $
+
+# NB: Config is in /etc/conf.d/spamd
+
+# Provide a default location if they haven't in /etc/conf.d/spamd
+PIDFILE=${PIDFILE:-/var/run/spamd.pid}
+
+opts="reload"
+
+depend() {
+ need net
+ before mta
+ use logger
+}
+
+start() {
+ ebegin "Starting spamd"
+ start-stop-daemon --start --quiet \
+ --name spamd \
+ --nicelevel ${SPAMD_NICELEVEL:-0} \
+ --exec /usr/sbin/spamd -- -d -r ${PIDFILE} \
+ ${SPAMD_OPTS}
+ eend $? "Failed to start spamd"
+}
+
+stop() {
+ ebegin "Stopping spamd"
+ start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
+ eend $? "Failed to stop spamd"
+}
+
+reload() {
+ ebegin "Reloading configuration"
+ kill -HUP $(< ${PIDFILE})
+ eend $?
+}
diff --git a/main/sqlite/APKBUILD b/main/sqlite/APKBUILD
new file mode 100644
index 00000000000..40a5cd7e443
--- /dev/null
+++ b/main/sqlite/APKBUILD
@@ -0,0 +1,31 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=sqlite
+pkgver=3.6.15
+pkgrel=0
+pkgdesc="A C library that implements an SQL database engine"
+url="http://www.sqlite.org/"
+license="custom"
+depends=""
+makedepends=""
+source="http://www.sqlite.org/$pkgname-$pkgver.tar.gz
+ license.txt"
+
+subpackages="$pkgname-doc $pkgname-dev"
+
+build ()
+{
+ cd ${srcdir}/${pkgname}-${pkgver}
+ ./configure --prefix=/usr \
+ --enable-threadsafe \
+ --disable-static \
+ --disable-tcl \
+ --disable-readline \
+ || return 1
+ make || return 1
+ make DESTDIR=${pkgdir} install || return 1
+ install -Dm0644 sqlite3.1 ${pkgdir}/usr/share/man/man1/sqlite3.1
+ install -Dm644 ${srcdir}/license.txt ${pkgdir}/usr/share/licenses/${pkgname}/license.txt
+}
+
+md5sums="ccde887ffc8a26251f3514d54594ff92 sqlite-3.6.15.tar.gz
+c1cdbc5544034d9012e421e75a5e4890 license.txt"
diff --git a/main/sqlite/license.txt b/main/sqlite/license.txt
new file mode 100644
index 00000000000..118c5d5e60e
--- /dev/null
+++ b/main/sqlite/license.txt
@@ -0,0 +1,33 @@
+SQLite Copyright
+SQLite is in the
+Public Domain
+
+
+All of the deliverable code in SQLite has been dedicated to the public domain by the authors. All code authors, and representatives of the companies they work for, have signed affidavits dedicating their contributions to the public domain and originals of those signed affidavits are stored in a firesafe at the main offices of Hwaci. Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original SQLite code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
+
+The previous paragraph applies to the deliverable code in SQLite - those parts of the SQLite library that you actually bundle and ship with a larger application. Portions of the documentation and some code used as part of the build process might fall under other licenses. The details here are unclear. We do not worry about the licensing of the documentation and build code so much because none of these things are part of the core deliverable SQLite library.
+
+All of the deliverable code in SQLite has been written from scratch. No code has been taken from other projects or from the open internet. Every line of code can be traced back to its original author, and all of those authors have public domain dedications on file. So the SQLite code base is clean and is uncontaminated with licensed code from other projects.
+Obtaining An Explicit License To Use SQLite
+
+Even though SQLite is in the public domain and does not require a license, some users want to obtain a license anyway. Some reasons for obtaining a license include:
+You are using SQLite in a jurisdiction that does not recognize the public domain.
+You are using SQLite in a jurisdiction that does not recognize the right of an author to dedicate their work to the public domain.
+You want to hold a tangible legal document as evidence that you have the legal right to use and distribute SQLite.
+Your legal department tells you that you have to purchase a license.
+
+If you feel like you really have to purchase a license for SQLite, Hwaci, the company that employs the architect and principal developers of SQLite, will sell you one.
+Contributed Code
+
+In order to keep SQLite completely free and unencumbered by copyright, all new contributors to the SQLite code base are asked to dedicate their contributions to the public domain. If you want to send a patch or enhancement for possible inclusion in the SQLite source tree, please accompany the patch with the following statement:
+The author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this code under copyright law.
+
+We are not able to accept patches or changes to SQLite that are not accompanied by a statement such as the above. In addition, if you make changes or enhancements as an employee, then a simple statement such as the above is insufficient. You must also send by surface mail a copyright release signed by a company officer. A signed original of the copyright release should be mailed to:
+Hwaci
+6200 Maple Cove Lane
+Charlotte, NC 28269
+USA
+
+A template copyright release is available in PDF or HTML. You can use this release to make future changes.
+
+see http://www.sqlite.org/copyright.html \ No newline at end of file
diff --git a/main/squid/APKBUILD b/main/squid/APKBUILD
new file mode 100644
index 00000000000..ac840cbbd54
--- /dev/null
+++ b/main/squid/APKBUILD
@@ -0,0 +1,278 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=squid
+pkgver=2.7.6
+_ver=2.7.STABLE6
+pkgrel=5
+pkgdesc="A full-featured Web proxy cache server."
+url="http://www.squid-cache.org"
+install="squid.post-install"
+license="GPL-2"
+depends="$pkgname-errors-english logrotate"
+makedepends="openssl-dev perl-dev autoconf automake"
+subpackages="$pkgname-doc
+ $pkgname-errors-armenian:errors_armenian
+ $pkgname-errors-azerbaijani:errors_azerbaijani
+ $pkgname-errors-bulgarian:errors_bulgarian
+ $pkgname-errors-catalan:errors_catalan
+ $pkgname-errors-czech:errors_czech
+ $pkgname-errors-danish:errors_danish
+ $pkgname-errors-dutch:errors_dutch
+ $pkgname-errors-english:errors_english
+ $pkgname-errors-estonian:errors_estonian
+ $pkgname-errors-finnish:errors_finnish
+ $pkgname-errors-french:errors_french
+ $pkgname-errors-german:errors_german
+ $pkgname-errors-greek:errors_greek
+ $pkgname-errors-hebrew:errors_hebrew
+ $pkgname-errors-hungarian:errors_hungarian
+ $pkgname-errors-italian:errors_italian
+ $pkgname-errors-japanese:errors_japanese
+ $pkgname-errors-korean:errors_korean
+ $pkgname-errors-lithuanian:errors_lithuanian
+ $pkgname-errors-polish:errors_polish
+ $pkgname-errors-portuguese:errors_portuguese
+ $pkgname-errors-romanian:errors_romanian
+ $pkgname-errors-russian-1251:errors_russian_1251
+ $pkgname-errors-russian-koi8-r:errors_russian_koi8_r
+ $pkgname-errors-serbian:errors_serbian
+ $pkgname-errors-simplify_chinese:errors_simplify_chinese
+ $pkgname-errors-slovak:errors_slovak
+ $pkgname-errors-spanish:errors_spanish
+ $pkgname-errors-swedish:errors_swedish
+ $pkgname-errors-traditional_chinese:errors_traditional_chinese
+ $pkgname-errors-turkish:errors_turkish
+ $pkgname-errors-ukrainian-1251:errors_ukrainian_1251
+ $pkgname-errors-ukrainian-koi8-u:errors_ukrainian_koi8_u
+ $pkgname-errors-ukrainian-utf8:errors_ukrainian_utf8"
+
+source="http://www.squid-cache.org/Versions/v2/2.7/${pkgname}-${_ver}.tar.bz2
+ squid.initd
+ squid.confd
+ squid.post-install
+ squid-2.7-gentoo.patch
+ $pkgname.logrotate
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$_ver"
+
+ patch -p1 -i "$srcdir"/squid-2.7-gentoo.patch || return 1
+ touch NEWS AUTHORS
+ aclocal && autoconf && automake -a || return 1
+
+ ./configure --prefix=/usr --datadir=/usr/share/squid \
+ --sysconfdir=/etc/squid --libexecdir=/usr/lib/squid \
+ --localstatedir=/var --enable-auth="basic,digest,ntlm" \
+ --enable-removal-policies="lru,heap" \
+ --enable-digest-auth-helpers="password" \
+ --enable-storeio="aufs,ufs,diskd,coss,null" \
+ --enable-basic-auth-helpers="getpwnam,NCSA,SMB,MSNT,multi-domain-NTLM" \
+ --enable-external-acl-helpers="ip_user,unix_group,wbinfo_group" \
+ --enable-ntlm-auth-helpers="SMB,fakeauth,no_check" \
+ --enable-delay-pools --enable-arp-acl --enable-ssl \
+ --enable-linux-netfilter --enable-ident-lookups \
+ --enable-useragent-log --enable-cache-digests --enable-referer-log \
+ --enable-async-io --enable-truncate --enable-arp-acl \
+ --enable-htcp --enable-carp --enable-poll --with-maxfd=4096 \
+ --enable-follow-x-forwarded-for
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ install -m644 -D "$srcdir"/$pkgname.logrotate \
+ "$pkgdir"/etc/logrotate.d/squid
+
+ mkdir -p "$pkgdir"/var/cache/squid "$pkgdir"/var/log/squid
+ chmod +x "$pkgdir"/usr/lib/squid/*
+}
+
+
+_mv_error() {
+ local d=usr/share/squid/errors
+ mkdir -p "$subpkgdir/$d"
+ mv "$pkgdir/$d/${1}" "$subpkgdir/$d/" || return 1
+ # last one removed the dir
+ rmdir "$pkgdir/$d" 2>/dev/null
+ return 0
+}
+
+errors_armenian() {
+ depends="$pkgname"
+ _mv_error Armenian
+}
+
+errors_azerbaijani() {
+ depends="$pkgname"
+ _mv_error Azerbaijani
+}
+
+errors_bulgarian() {
+ depends="$pkgname"
+ _mv_error Bulgarian
+}
+
+errors_catalan() {
+ depends="$pkgname"
+ _mv_error Catalan
+}
+
+errors_czech() {
+ depends="$pkgname"
+ _mv_error Czech
+}
+
+errors_danish() {
+ depends="$pkgname"
+ _mv_error Danish
+}
+
+errors_dutch() {
+ depends="$pkgname"
+ _mv_error Dutch
+}
+
+errors_english() {
+ depends="$pkgname"
+ _mv_error English
+}
+
+errors_estonian() {
+ depends="$pkgname"
+ _mv_error Estonian
+}
+
+errors_finnish() {
+ depends="$pkgname"
+ _mv_error Finnish
+}
+
+errors_french() {
+ depends="$pkgname"
+ _mv_error French
+}
+
+errors_german() {
+ depends="$pkgname"
+ _mv_error German
+}
+
+errors_greek() {
+ depends="$pkgname"
+ _mv_error Greek
+}
+
+errors_hebrew() {
+ depends="$pkgname"
+ _mv_error Hebrew
+}
+
+errors_hungarian() {
+ depends="$pkgname"
+ _mv_error Hungarian
+}
+
+errors_italian() {
+ depends="$pkgname"
+ _mv_error Italian
+}
+
+errors_japanese() {
+ depends="$pkgname"
+ _mv_error Japanese
+}
+
+errors_korean() {
+ depends="$pkgname"
+ _mv_error Korean
+}
+
+errors_lithuanian() {
+ depends="$pkgname"
+ _mv_error Lithuanian
+}
+
+errors_polish() {
+ depends="$pkgname"
+ _mv_error Polish
+}
+
+errors_portuguese() {
+ depends="$pkgname"
+ _mv_error Portuguese
+}
+
+errors_romanian() {
+ depends="$pkgname"
+ _mv_error Romanian
+}
+
+errors_russian_1251() {
+ depends="$pkgname"
+ _mv_error Russian-1251
+}
+
+errors_russian_koi8_r() {
+ depends="$pkgname"
+ _mv_error Russian-koi8-r
+}
+
+errors_serbian() {
+ depends="$pkgname"
+ _mv_error Serbian
+}
+
+errors_simplify_chinese() {
+ depends="$pkgname"
+ _mv_error Simplify_Chinese
+}
+
+errors_slovak() {
+ depends="$pkgname"
+ _mv_error Slovak
+}
+
+errors_spanish() {
+ depends="$pkgname"
+ _mv_error Spanish
+}
+
+errors_swedish() {
+ depends="$pkgname"
+ _mv_error Swedish
+}
+
+errors_traditional_chinese() {
+ depends="$pkgname"
+ _mv_error Traditional_Chinese
+}
+
+errors_turkish() {
+ depends="$pkgname"
+ _mv_error Turkish
+}
+
+errors_ukrainian_1251() {
+ depends="$pkgname"
+ _mv_error Ukrainian-1251
+}
+
+errors_ukrainian_koi8_u() {
+ depends="$pkgname"
+ _mv_error Ukrainian-koi8-u
+}
+
+errors_ukrainian_utf8() {
+ depends="$pkgname"
+ _mv_error Ukrainian-utf8
+}
+
+
+md5sums="6de3a6a7a56a7ecae092f2d31a04f039 squid-2.7.STABLE6.tar.bz2
+d31f293cf10a90bc3d60aa6428889db5 squid.initd
+44b052db7910f386ef88ddcf69c9ba4e squid.confd
+9bf350646e321f7c38ffeb9af828ec98 squid.post-install
+1d33108353d788b238d9a8877bf2e401 squid-2.7-gentoo.patch
+58823e0b86bc2dc71d270208b7b284b4 squid.logrotate"
diff --git a/main/squid/squid-2.7-gentoo.patch b/main/squid/squid-2.7-gentoo.patch
new file mode 100644
index 00000000000..5ac174dee2b
--- /dev/null
+++ b/main/squid/squid-2.7-gentoo.patch
@@ -0,0 +1,298 @@
+Gentoo squid patch for 2.7.4
+
+http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-proxy/squid/files/squid-2.7.4-gentoo.patch?view=markup
+
+--- squid-2.7.STABLE6/configure.in Wed Feb 4 00:44:06 2009
++++ squid-2.7.STABLE6-patched/configure.in Mon Feb 16 11:56:34 2009
+@@ -18,9 +18,9 @@
+ PRESET_LDFLAGS="$LDFLAGS"
+
+ dnl Set default LDFLAGS
+-if test -z "$LDFLAGS"; then
+- LDFLAGS="-g"
+-fi
++dnl if test -z "$LDFLAGS"; then
++dnl LDFLAGS="-g"
++dnl fi
+
+ dnl Check for GNU cc
+ AC_PROG_CC
+--- squid-2.7.STABLE6/helpers/basic_auth/MSNT/confload.c Wed Jun 26 19:09:48 2002
++++ squid-2.7.STABLE6-patched/helpers/basic_auth/MSNT/confload.c Mon Feb 16 11:56:34 2009
+@@ -24,7 +24,7 @@
+
+ /* Path to configuration file */
+ #ifndef SYSCONFDIR
+-#define SYSCONFDIR "/usr/local/squid/etc"
++#define SYSCONFDIR "/etc/squid"
+ #endif
+ #define CONFIGFILE SYSCONFDIR "/msntauth.conf"
+
+--- squid-2.7.STABLE6/helpers/basic_auth/MSNT/msntauth.conf.default Wed Jun 26 18:44:28 2002
++++ squid-2.7.STABLE6-patched/helpers/basic_auth/MSNT/msntauth.conf.default Mon Feb 16 11:56:34 2009
+@@ -8,6 +8,6 @@
+ server other_PDC other_BDC otherdomain
+
+ # Denied and allowed users. Comment these if not needed.
+-#denyusers /usr/local/squid/etc/msntauth.denyusers
+-#allowusers /usr/local/squid/etc/msntauth.allowusers
++#denyusers /etc/squid/msntauth.denyusers
++#allowusers /etc/squid/msntauth.allowusers
+
+--- squid-2.7.STABLE6/helpers/basic_auth/SMB/Makefile.am Tue May 17 16:56:26 2005
++++ squid-2.7.STABLE6-patched/helpers/basic_auth/SMB/Makefile.am Mon Feb 16 11:56:34 2009
+@@ -14,7 +14,7 @@
+ ## FIXME: autoconf should test for the samba path.
+
+ SMB_AUTH_HELPER = smb_auth.sh
+-SAMBAPREFIX=/usr/local/samba
++SAMBAPREFIX=/usr
+ SMB_AUTH_HELPER_PATH = $(libexecdir)/$(SMB_AUTH_HELPER)
+
+ libexec_SCRIPTS = $(SMB_AUTH_HELPER)
+--- squid-2.7.STABLE6/helpers/basic_auth/SMB/smb_auth.sh Sun Jan 7 23:36:46 2001
++++ squid-2.7.STABLE6-patched/helpers/basic_auth/SMB/smb_auth.sh Mon Feb 16 11:56:34 2009
+@@ -24,7 +24,7 @@
+ read AUTHSHARE
+ read AUTHFILE
+ read SMBUSER
+-read SMBPASS
++read -r SMBPASS
+
+ # Find domain controller
+ echo "Domain name: $DOMAINNAME"
+@@ -47,7 +47,7 @@
+ addropt=""
+ fi
+ echo "Query address options: $addropt"
+-dcip=`$SAMBAPREFIX/bin/nmblookup $addropt "$PASSTHROUGH#1c" | awk '/^[0-9.]+ / { print $1 ; exit }'`
++dcip=`$SAMBAPREFIX/bin/nmblookup $addropt "$PASSTHROUGH#1c" | awk '/^[0-9.]+\..+ / { print $1 ; exit }'`
+ echo "Domain controller IP address: $dcip"
+ [ -n "$dcip" ] || exit 1
+
+--- squid-2.7.STABLE6/helpers/external_acl/session/squid_session.8 Sat Jan 6 17:28:35 2007
++++ squid-2.7.STABLE6-patched/helpers/external_acl/session/squid_session.8 Mon Feb 16 11:56:34 2009
+@@ -35,7 +35,7 @@
+ .P
+ Configuration example using the default automatic mode
+ .IP
+-external_acl_type session ttl=300 negative_ttl=0 children=1 concurrency=200 %LOGIN /usr/local/squid/libexec/squid_session
++external_acl_type session ttl=300 negative_ttl=0 children=1 concurrency=200 %LOGIN /usr/libexec/squid/squid_session
+ .IP
+ acl session external session
+ .IP
+--- squid-2.7.STABLE6/helpers/external_acl/unix_group/squid_unix_group.8 Sun May 14 15:07:24 2006
++++ squid-2.7.STABLE6-patched/helpers/external_acl/unix_group/squid_unix_group.8 Mon Feb 16 11:56:34 2009
+@@ -27,7 +27,7 @@
+ This squid.conf example defines two Squid acls. usergroup1 matches users in group1, and usergroup2
+ matches users in group2 or group3
+ .IP
+-external_acl_type unix_group %LOGIN /usr/local/squid/libexec/squid_unix_group -p
++external_acl_type unix_group %LOGIN /usr/libexec/squid/squid_unix_group -p
+ .IP
+ acl usergroup1 external unix_group group1
+ .IP
+--- squid-2.7.STABLE6/src/Makefile.am Wed Jan 2 15:50:39 2008
++++ squid-2.7.STABLE6-patched/src/Makefile.am Mon Feb 16 11:56:34 2009
+@@ -340,13 +340,13 @@
+ DEFAULT_CONFIG_FILE = $(sysconfdir)/squid.conf
+ DEFAULT_MIME_TABLE = $(sysconfdir)/mime.conf
+ DEFAULT_DNSSERVER = $(libexecdir)/`echo dnsserver | sed '$(transform);s/$$/$(EXEEXT)/'`
+-DEFAULT_LOG_PREFIX = $(localstatedir)/logs
++DEFAULT_LOG_PREFIX = $(localstatedir)/log/squid
+ DEFAULT_CACHE_LOG = $(DEFAULT_LOG_PREFIX)/cache.log
+ DEFAULT_ACCESS_LOG = $(DEFAULT_LOG_PREFIX)/access.log
+ DEFAULT_STORE_LOG = $(DEFAULT_LOG_PREFIX)/store.log
+-DEFAULT_PID_FILE = $(DEFAULT_LOG_PREFIX)/squid.pid
++DEFAULT_PID_FILE = $(localstatedir)/run/squid.pid
+ DEFAULT_NETDB_FILE = $(DEFAULT_LOG_PREFIX)/netdb.state
+-DEFAULT_SWAP_DIR = $(localstatedir)/cache
++DEFAULT_SWAP_DIR = $(localstatedir)/cache/squid
+ DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'`
+ DEFAULT_UNLINKD = $(libexecdir)/`echo unlinkd | sed '$(transform);s/$$/$(EXEEXT)/'`
+ DEFAULT_DISKD = $(libexecdir)/`echo diskd-daemon | sed '$(transform);s/$$/$(EXEEXT)/'`
+--- squid-2.7.STABLE6/src/access_log.c Tue Mar 18 02:48:43 2008
++++ squid-2.7.STABLE6-patched/src/access_log.c Mon Feb 16 11:56:34 2009
+@@ -1261,7 +1261,7 @@
+ LogfileStatus = LOG_ENABLE;
+ }
+ #if HEADERS_LOG
+- headerslog = logfileOpen("/usr/local/squid/logs/headers.log", MAX_URL << 1, 0);
++ headerslog = logfileOpen("/var/log/squid/headers.log", MAX_URL << 1, 0);
+ assert(NULL != headerslog);
+ #endif
+ #if FORW_VIA_DB
+--- squid-2.7.STABLE6/src/cf.data.pre Mon Feb 2 11:28:55 2009
++++ squid-2.7.STABLE6-patched/src/cf.data.pre Mon Feb 16 11:56:34 2009
+@@ -678,6 +678,8 @@
+ acl Safe_ports port 488 # gss-http
+ acl Safe_ports port 591 # filemaker
+ acl Safe_ports port 777 # multiling http
++acl Safe_ports port 901 # SWAT
++acl purge method PURGE
+ acl CONNECT method CONNECT
+ NOCOMMENT_END
+ DOC_END
+@@ -711,6 +713,9 @@
+ # Only allow cachemgr access from localhost
+ http_access allow manager localhost
+ http_access deny manager
++# Only allow purge requests from localhost
++http_access allow purge localhost
++http_access deny purge
+ # Deny requests to unknown ports
+ http_access deny !Safe_ports
+ # Deny CONNECT to other than SSL ports
+@@ -728,6 +733,9 @@
+ # from where browsing should be allowed
+ http_access allow localnet
+
++# Allow the localhost to have access by default
++http_access allow localhost
++
+ # And finally deny all other access to this proxy
+ http_access deny all
+ NOCOMMENT_END
+@@ -3754,11 +3762,11 @@
+
+ NAME: cache_mgr
+ TYPE: string
+-DEFAULT: webmaster
++DEFAULT: root
+ LOC: Config.adminEmail
+ DOC_START
+ Email-address of local cache manager who will receive
+- mail if the cache dies. The default is "webmaster".
++ mail if the cache dies. The default is "root".
+ DOC_END
+
+ NAME: mail_from
+@@ -3787,12 +3795,12 @@
+
+ NAME: cache_effective_user
+ TYPE: string
+-DEFAULT: nobody
++DEFAULT: squid
+ LOC: Config.effectiveUser
+ DOC_START
+ If you start Squid as root, it will change its effective/real
+ UID/GID to the user specified below. The default is to change
+- to UID to nobody. If you define cache_effective_user, but not
++ to UID to squid. If you define cache_effective_user, but not
+ cache_effective_group, Squid sets the GID to the effective
+ user's default group ID (taken from the password file) and
+ supplementary group list from the from groups membership of
+@@ -4429,12 +4437,12 @@
+ NAME: snmp_port
+ TYPE: ushort
+ LOC: Config.Port.snmp
+-DEFAULT: 3401
++DEFAULT: 0
+ IFDEF: SQUID_SNMP
+ DOC_START
+ Squid can now serve statistics and status information via SNMP.
+- By default it listens to port 3401 on the machine. If you don't
+- wish to use SNMP, set this to "0".
++ By default snmp_port is disabled. If you wish to use SNMP,
++ set this to "3401" (or any other number you like).
+ DOC_END
+
+ NAME: snmp_access
+@@ -4505,12 +4513,12 @@
+ NAME: htcp_port
+ IFDEF: USE_HTCP
+ TYPE: ushort
+-DEFAULT: 4827
++DEFAULT: 0
+ LOC: Config.Port.htcp
+ DOC_START
+ The port number where Squid sends and receives HTCP queries to
+- and from neighbor caches. Default is 4827. To disable use
+- "0".
++ and from neighbor caches. To turn it on you want to set it to
++ 4827. By default it is set to "0" (disabled).
+ DOC_END
+
+ NAME: log_icp_queries
+@@ -5407,6 +5415,9 @@
+ If you disable this, it will appear as
+
+ X-Forwarded-For: unknown
++NOCOMMENT_START
++forwarded_for off
++NOCOMMENT_END
+ DOC_END
+
+ NAME: cachemgr_passwd
+--- squid-2.7.STABLE6/src/client_side.c Mon Oct 6 21:27:44 2008
++++ squid-2.7.STABLE6-patched/src/client_side.c Mon Feb 16 11:56:34 2009
+@@ -4706,14 +4706,7 @@
+ debug(83, 2) ("clientNegotiateSSL: Session %p reused on FD %d (%s:%d)\n", SSL_get_session(ssl), fd, fd_table[fd].ipaddr, (int) fd_table[fd].remote_port);
+ } else {
+ if (do_debug(83, 4)) {
+- /* Write out the SSL session details.. actually the call below, but
+- * OpenSSL headers do strange typecasts confusing GCC.. */
+- /* PEM_write_SSL_SESSION(debug_log, SSL_get_session(ssl)); */
+-#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x00908000L
+- PEM_ASN1_write((i2d_of_void *) i2d_SSL_SESSION, PEM_STRING_SSL_SESSION, debug_log, (char *) SSL_get_session(ssl), NULL, NULL, 0, NULL, NULL);
+-#else
+ PEM_ASN1_write(i2d_SSL_SESSION, PEM_STRING_SSL_SESSION, debug_log, (char *) SSL_get_session(ssl), NULL, NULL, 0, NULL, NULL);
+-#endif
+ /* Note: This does not automatically fflush the log file.. */
+ }
+ debug(83, 2) ("clientNegotiateSSL: New session %p on FD %d (%s:%d)\n", SSL_get_session(ssl), fd, fd_table[fd].ipaddr, (int) fd_table[fd].remote_port);
+--- squid-2.7.STABLE6/src/defines.h Mon Sep 24 13:31:19 2007
++++ squid-2.7.STABLE6-patched/src/defines.h Mon Feb 16 11:56:34 2009
+@@ -259,7 +259,7 @@
+
+ /* were to look for errors if config path fails */
+ #ifndef DEFAULT_SQUID_ERROR_DIR
+-#define DEFAULT_SQUID_ERROR_DIR "/usr/local/squid/etc/errors"
++#define DEFAULT_SQUID_ERROR_DIR "/usr/share/squid/errors/English"
+ #endif
+
+ /* gb_type operations */
+--- squid-2.7.STABLE6/src/main.c Thu Sep 25 02:21:52 2008
++++ squid-2.7.STABLE6-patched/src/main.c Mon Feb 16 11:56:34 2009
+@@ -376,6 +376,22 @@
+ asnFreeMemory();
+ }
+
++#if USE_UNLINKD
++static int
++needUnlinkd(void)
++{
++ int i;
++ int r = 0;
++ for (i = 0; i < Config.cacheSwap.n_configured; i++) {
++ if (strcmp(Config.cacheSwap.swapDirs[i].type, "ufs") == 0 ||
++ strcmp(Config.cacheSwap.swapDirs[i].type, "aufs") == 0 ||
++ strcmp(Config.cacheSwap.swapDirs[i].type, "diskd") == 0)
++ r++;
++ }
++ return r;
++}
++#endif
++
+ static void
+ mainReconfigure(void)
+ {
+@@ -614,7 +630,7 @@
+
+ if (!configured_once) {
+ #if USE_UNLINKD
+- unlinkdInit();
++ if (needUnlinkd()) unlinkdInit();
+ #endif
+ urlInitialize();
+ cachemgrInit();
+@@ -636,6 +652,9 @@
+ #endif
+ #if USE_WCCPv2
+ wccp2Init();
++#endif
++#if USE_UNLINKD
++ if (needUnlinkd()) unlinkdInit();
+ #endif
+ serverConnectionsOpen();
+ neighbors_init();
diff --git a/main/squid/squid.confd b/main/squid/squid.confd
new file mode 100644
index 00000000000..14a9ee84bd7
--- /dev/null
+++ b/main/squid/squid.confd
@@ -0,0 +1,15 @@
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-proxy/squid/files/squid.confd,v 1.2 2008/11/30 19:20:44 mrness Exp $
+
+# Config file for /etc/init.d/squid
+
+SQUID_OPTS="-DYC"
+
+# Max. number of filedescriptors to use. You can increase this on a busy
+# cache to a maximum of (currently) 8192 filedescriptors. Default is 1024.
+SQUID_MAXFD=1024
+
+# Kerberos keytab file to use. This is required if you enable kerberos authentication.
+SQUID_KEYTAB=""
+
diff --git a/main/squid/squid.initd b/main/squid/squid.initd
new file mode 100644
index 00000000000..bbdc2bed2ad
--- /dev/null
+++ b/main/squid/squid.initd
@@ -0,0 +1,97 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-proxy/squid/files/squid.initd,v 1.10 2008/11/30 19:20:44 mrness Exp $
+
+opts="${opts} reload rotate"
+
+depend() {
+ need net
+}
+
+# Try to increase the # of filedescriptors we can open.
+maxfds() {
+ [ -n "$SQUID_MAXFD" ] || return
+ [ -f /proc/sys/fs/file-max ] || return 0
+ [ $SQUID_MAXFD -le 8192 ] || SQUID_MAXFD=8192
+ local global_file_max=`cat /proc/sys/fs/file-max`
+ local minimal_file_max=$(($SQUID_MAXFD + 4096))
+ if [ "$global_file_max" -lt $minimal_file_max ]; then
+ echo $minimal_file_max > /proc/sys/fs/file-max
+ fi
+ ulimit -n $SQUID_MAXFD
+}
+
+checkconfig() {
+ maxfds
+
+ local CACHE_SWAP=$(awk '/^[ \t]*cache_dir[ \t]+/ { if ($2 == "coss" ) printf "%s/stripe ", $3 ; else printf "%s/00 ", $3; }' < /etc/squid/squid.conf)
+ [ -z "$CACHE_SWAP" ] && CACHE_SWAP="/var/cache/squid/00"
+
+ local x
+ for x in $CACHE_SWAP ; do
+ if [ ! -e $x ] ; then
+ ebegin "Initializing cache directories"
+ local ORIG_UMASK=$(umask)
+ umask 027
+ local INIT_CACHE_RESPONSE="$(/usr/sbin/squid -z -N -D 2>&1)"
+ if [ $? != 0 ] || echo "$INIT_CACHE_RESPONSE" | grep -q "erminated abnormally" ; then
+ umask $ORIG_UMASK
+ eend 1
+ echo "$INIT_CACHE_RESPONSE"
+ return 1
+ fi
+ umask $ORIG_UMASK
+ eend 0
+ break
+ fi
+ done
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+ ebegin "Starting squid"
+ KRB5_KTNAME="${SQUID_KEYTAB}" /usr/sbin/squid ${SQUID_OPTS}
+ eend $? && sleep 1
+}
+
+stop() {
+ ebegin "Stopping squid"
+ /usr/sbin/squid -k shutdown
+ # Now we have to wait until squid has _really_ stopped.
+ sleep 1
+ if [ -f /var/run/squid.pid ] ; then
+ einfon "Waiting for squid to shutdown ."
+ cnt=0
+ while [ -f /var/run/squid.pid ] ; do
+ cnt=$(expr $cnt + 1)
+ if [ $cnt -gt 60 ] ; then
+ # Waited 120 seconds now. Fail.
+ echo
+ eend 1 "Failed."
+ break
+ fi
+ sleep 2
+ echo -n "."
+ done
+ echo
+ fi
+ eend 0
+}
+
+reload() {
+ checkconfig || return 1
+ ebegin "Reloading squid"
+ /usr/sbin/squid -k reconfigure
+ eend $?
+}
+
+rotate() {
+ service_started squid || return 1
+ ebegin "Rotating logs"
+ /usr/sbin/squid -k rotate
+ eend $?
+}
+
diff --git a/main/squid/squid.logrotate b/main/squid/squid.logrotate
new file mode 100644
index 00000000000..fb3279e0138
--- /dev/null
+++ b/main/squid/squid.logrotate
@@ -0,0 +1,11 @@
+/var/log/squid/*.log {
+ daily
+ compress
+ rotate 5
+ missingok
+ nocreate
+ sharedscripts
+ postrotate
+ /usr/sbin/squid -k rotate
+ endscript
+}
diff --git a/main/squid/squid.post-install b/main/squid/squid.post-install
new file mode 100644
index 00000000000..88df6d26f9e
--- /dev/null
+++ b/main/squid/squid.post-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+chown squid:squid /var/cache/squid /var/log/squid
+exit 0
+
diff --git a/main/ssmtp/APKBUILD b/main/ssmtp/APKBUILD
new file mode 100644
index 00000000000..2f63b689f91
--- /dev/null
+++ b/main/ssmtp/APKBUILD
@@ -0,0 +1,32 @@
+#Contributor: Leonardo Arena <rnalrd@gmail.com>
+pkgname=ssmtp
+pkgver=2.62
+pkgrel=0
+pkgdesc="Extremely simple MTA to get mail off the system to a mail hub"
+subpackages="$pkgname-doc"
+arch=""
+url="http://packages.debian.org/source/lenny/ssmtp"
+license="GPL-2"
+depends="uclibc"
+makedepends="openssl-dev"
+install=
+source="http://ftp.debian.org/debian/pool/main/s/$pkgname/${pkgname}_${pkgver}.orig.tar.gz
+ CVE-2008-3962.patch
+ generate_config.patch"
+
+build() {
+ cd "$srcdir/$pkgname"
+ patch generate_config ../../generate_config.patch
+ sed -i -e 's:$(CC) -o:$(CC) @LDFLAGS@ -o:' Makefile.in
+ patch -p1 ssmtp.c ../../CVE-2008-3962.patch
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --sysconfdir=/etc \
+ --enable-ssl
+ make || return 1
+ make prefix="$pkgdir"/usr etcdir="$pkgdir"/etc mandir="$pkgdir"/usr/share/man install
+}
+md5sums="257ac04e62ab7e3616e220333a1140cb ssmtp_2.62.orig.tar.gz
+18f0686f1b8888d187f06dcff3b6212a CVE-2008-3962.patch
+c70c395fe71589ca8b10b666455d5071 generate_config.patch"
diff --git a/main/ssmtp/CVE-2008-3962.patch b/main/ssmtp/CVE-2008-3962.patch
new file mode 100644
index 00000000000..fca144fa680
--- /dev/null
+++ b/main/ssmtp/CVE-2008-3962.patch
@@ -0,0 +1,14 @@
+--- ssmtp.orig/ssmtp.c
++++ ssmtp/ssmtp.c
+@@ -485,6 +485,11 @@ char *from_format(char *str, bool_t over
+ die("from_format() -- snprintf() failed");
+ }
+ }
++ else {
++ if(snprintf(buf, BUF_SZ, "%s", str) == -1) {
++ die("from_format() -- snprintf() failed");
++ }
++ }
+ }
+
+ #if 0
diff --git a/main/ssmtp/generate_config.patch b/main/ssmtp/generate_config.patch
new file mode 100644
index 00000000000..dd4baf9f8a8
--- /dev/null
+++ b/main/ssmtp/generate_config.patch
@@ -0,0 +1,49 @@
+--- src/ssmtp/generate_config 2004-07-23 05:58:48.000000000 +0000
++++ generate_config 2009-01-27 10:09:11.000000000 +0000
+@@ -4,7 +4,7 @@
+ # Figure out the system's mailname
+ #
+
+-syshostname=`hostname --fqdn`
++syshostname="localhost"
+ if test -f /etc/mailname
+ then
+ mailname="`head -1 /etc/mailname`"
+@@ -15,23 +15,7 @@
+ mailname=$syshostname
+ fi
+
+-echo "Please enter the mail name of your system."
+-echo "This is the hostname portion of the address to be shown"
+-echo "on outgoing news and mail messages headers."
+-echo "The default is $syshostname, your system's host name."
+-echo
+-echo -n "Mail name [$syshostname]: "
+-read mailname
+-echo
+-
+-echo -n "Please enter the SMTP port number [25]: "
+-read smtpport
+-if test -z "$smtpport"
+-then
+- mailhub=$mailhub
+-else
+- mailhub="$mailhub:$smtpport"
+-fi
++mailhub="$mailhub:$smtpport"
+
+ #
+ # Generate configuration file
+@@ -56,11 +40,5 @@
+ # Where will the mail seem to come from?
+ #rewriteDomain=`echo -n $mailname`
+ # The full hostname
+-hostname=`hostname --fqdn`
++#hostname="localhost"
+ EOF
+-
+-echo
+-echo
+-echo "Please check the configuration file $1 for correctness."
+-echo
+-echo
diff --git a/main/strace/APKBUILD b/main/strace/APKBUILD
new file mode 100644
index 00000000000..eb1f88c2fab
--- /dev/null
+++ b/main/strace/APKBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=strace
+pkgver=4.5.18
+pkgrel=0
+pkgdesc="A useful diagnositic, instructional, and debugging tool"
+url="http://sourceforge.net/projects/strace/"
+license="BSD"
+depends="uclibc"
+source="http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.bz2"
+subpackages="$pkgname-doc"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+}
+md5sums="e9449fcee97e6a8ed73934c883c870e0 strace-4.5.18.tar.bz2"
diff --git a/main/subversion/APKBUILD b/main/subversion/APKBUILD
new file mode 100644
index 00000000000..538f77d0be3
--- /dev/null
+++ b/main/subversion/APKBUILD
@@ -0,0 +1,38 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=subversion
+pkgver=1.6.3
+pkgrel=0
+pkgdesc="Replacement for CVS, another versioning system (svn)"
+url="http://subversion.tigris.org/"
+license="apache bsd"
+depends=
+makedepends="apr-dev apr-util-dev expat-dev neon-dev openssl-dev zlib-dev
+ e2fsprogs-dev sqlite-dev"
+install="$pkgname.pre-install"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://svn.collab.net/tarballs/$pkgname-$pkgver.tar.gz
+ svnserve.confd
+ svnserve.initd
+ $install
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --disable-nls \
+ --without-apxs \
+ --disable-javahl \
+ --without-jdk
+
+ make external-all || return 1
+ make local-all || return 1
+ make -j1 DESTDIR="$pkgdir" install || return 1
+
+ install -Dm755 "$srcdir"/svnserve.initd "$pkgdir"/etc/init.d/svnserve
+ install -Dm644 "$srcdir"/svnserve.confd "$pkgdir"/etc/conf.d/svnserve
+}
+md5sums="8357468ed2485b88151c50fb5deb28ca subversion-1.6.3.tar.gz
+d084a7558053784886bc858b94fa9186 svnserve.confd
+06cf9328f63a935654971052a2c3594a svnserve.initd
+bfd0d890c07830f1a6010891dd25fa5c subversion.pre-install"
diff --git a/main/subversion/subversion.pre-install b/main/subversion/subversion.pre-install
new file mode 100644
index 00000000000..fb516ee5a0e
--- /dev/null
+++ b/main/subversion/subversion.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup svnusers 2>/dev/null
+adduser svn -D -h /var/svn -G svnusers 2>/dev/null
+exit 0
+
diff --git a/main/subversion/svnserve.confd b/main/subversion/svnserve.confd
new file mode 100644
index 00000000000..b487a409758
--- /dev/null
+++ b/main/subversion/svnserve.confd
@@ -0,0 +1,10 @@
+# The commented variables in this file are the defaults that are used
+# in the init-script. You don't need to uncomment them except to
+# customize them to different values.
+
+# Options for svnserve
+#SVNSERVE_OPTS="--root=/var/svn"
+
+# User and group as which to run svnserve
+SVNSERVE_USER="svn"
+SVNSERVE_GROUP="svnusers"
diff --git a/main/subversion/svnserve.initd b/main/subversion/svnserve.initd
new file mode 100644
index 00000000000..036d0187e7e
--- /dev/null
+++ b/main/subversion/svnserve.initd
@@ -0,0 +1,44 @@
+#!/sbin/runscript
+# Copyright 2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/dev-util/subversion/files/svnserve.initd,v 1.2 2005/08/25 13:59:48 pauldv Exp $
+
+opts="$opts setup"
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting svnserve"
+ # Ensure that we run from a readable working dir, and that we do not
+ # lock filesystems when being run from such a location.
+ cd /
+ start-stop-daemon --start --quiet --background --make-pidfile \
+ --pidfile /var/run/svnserve.pid --exec /usr/bin/svnserve \
+ --chuid ${SVNSERVE_USER:-apache}:${SVNSERVE_GROUP:-apache} -- \
+ --foreground --daemon ${SVNSERVE_OPTS:---root=/var/svn}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping svnserve"
+ start-stop-daemon --stop --quiet --pidfile /var/run/svnserve.pid
+ eend $?
+}
+
+setup() {
+ local root=${SVNSERVE_ROOT:-/var/svn}
+ ebeging "Setting up svnserve repositories in $root"
+ if [ -e "$root/repos" ]; then
+ eend 1 "$root/repos already exist"
+ return 1
+ fi
+
+ svnadmin create "$root"/repos
+ chown -Rf "${SVNSERVE_USER}:${SVNSERVE_GROUP}" "$root/repos"
+ mkdir -p "$root/conf"
+ chmod -Rf go-rwx "$root/conf"
+ chmod -Rf o-rwx "$root/repos"
+ eend $?
+}
diff --git a/main/sysfsutils/APKBUILD b/main/sysfsutils/APKBUILD
new file mode 100644
index 00000000000..e462aec7052
--- /dev/null
+++ b/main/sysfsutils/APKBUILD
@@ -0,0 +1,24 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sysfsutils
+pkgver=2.1.0
+pkgrel=3
+pkgdesc="System Utilities Based on Sysfs"
+url="http://linux-diag.sourceforge.net/Sysfsutils.html"
+license="GPL LGPL"
+depends="uclibc"
+makedepends=""
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://downloads.sourceforge.net/sourceforge/linux-diag/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir"/ install
+# cd "$srcdir"/pkg
+# mkdir -v lib
+# mv -v usr/lib/libsysfs.so.2* lib/
+# ln -svf ../../lib/libsysfs.so.2 usr/lib/libsysfs.so
+}
+md5sums="14e7dcd0436d2f49aa403f67e1ef7ddc sysfsutils-2.1.0.tar.gz"
diff --git a/main/sysklogd/APKBUILD b/main/sysklogd/APKBUILD
new file mode 100644
index 00000000000..e3fe8badc5d
--- /dev/null
+++ b/main/sysklogd/APKBUILD
@@ -0,0 +1,50 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sysklogd
+pkgver=1.5
+pkgrel=0
+pkgdesc="System and kernel log daemons"
+url="http://www.infodrom.org/projects/sysklogd/"
+license="GPL BSD"
+subpackages="$pkgname-doc"
+depends="logrotate"
+makedepends=""
+source="http://www.infodrom.org/projects/$pkgname/download/$pkgname-$pkgver.tar.gz
+ sysklogd.logrotate
+ sysklogd.initd
+ sysklogd.confd
+ sysklogd-1.4.2-caen-owl-klogd-drop-root.diff
+ sysklogd-1.4.2-caen-owl-syslogd-bind.diff
+ sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff
+ sysklogd-1.5-build.patch
+ LICENSE"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+
+ for i in ../*.patch ../*.diff; do
+ msg "Applying $i..."
+ patch -p1 < $i || return 1
+ done
+
+ export CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
+ make || return 1
+ install -d "$pkgdir"/usr/sbin
+ install -d "$pkgdir"/usr/share/man/man5
+ install -d "$pkgdir"/usr/share/man/man8
+ make INSTALL=install prefix="$pkgdir" install
+ install -D -m644 ../sysklogd.logrotate \
+ "$pkgdir"/etc/logrotate.d/sysklogd
+ install -D -m755 ../sysklogd.initd "$pkgdir"/etc/init.d/sysklogd
+ install -D -m644 ../sysklogd.confd "$pkgdir"/etc/conf.d/sysklogd
+ install -D -m644 ../LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+}
+md5sums="e053094e8103165f98ddafe828f6ae4b sysklogd-1.5.tar.gz
+40304e92b2f6a92e252de24c5e3ca88e sysklogd.logrotate
+9332657663a9f4286e5c61d22c46378f sysklogd.initd
+e25d7b583b7e4bd8be503b89e1771e90 sysklogd.confd
+3b7ba3aa6519f96f11165a7d5900a8b1 sysklogd-1.4.2-caen-owl-klogd-drop-root.diff
+4715e1dd2deb7a9ac137e004210e3154 sysklogd-1.4.2-caen-owl-syslogd-bind.diff
+6c0a416e40a678cf99c454b0e98185c9 sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff
+c71826d1a4f3f7e8ffa57adbfc24f1ce sysklogd-1.5-build.patch
+7930f7ff5038e1318511624e348581cc LICENSE"
diff --git a/main/sysklogd/LICENSE b/main/sysklogd/LICENSE
new file mode 100644
index 00000000000..7e9b5d59c32
--- /dev/null
+++ b/main/sysklogd/LICENSE
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 1983, 1988 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.
+ */
diff --git a/main/sysklogd/sysklogd-1.4.2-caen-owl-klogd-drop-root.diff b/main/sysklogd/sysklogd-1.4.2-caen-owl-klogd-drop-root.diff
new file mode 100644
index 00000000000..40b8817d4e2
--- /dev/null
+++ b/main/sysklogd/sysklogd-1.4.2-caen-owl-klogd-drop-root.diff
@@ -0,0 +1,162 @@
+http://cvsweb.openwall.com/cgi/cvsweb.cgi/~checkout~/Owl/packages/sysklogd/sysklogd-1.4.2-caen-owl-klogd-drop-root.diff?rev=1.2;content-type=text%2Fplain
+diff -upk.orig sysklogd-1.4.2.orig/klogd.8 sysklogd-1.4.2/klogd.8
+--- sysklogd-1.4.2.orig/klogd.8 2005-03-11 16:12:09 +0000
++++ sysklogd-1.4.2/klogd.8 2005-08-18 14:37:47 +0000
+@@ -18,6 +19,12 @@ klogd \- Kernel Log Daemon
+ .RB [ " \-f "
+ .I fname
+ ]
++.RB [ " \-u "
++.I username
++]
++.RB [ " \-j "
++.I chroot_dir
++]
+ .RB [ " \-iI " ]
+ .RB [ " \-n " ]
+ .RB [ " \-o " ]
+@@ -53,6 +60,20 @@ stderr.
+ .BI "\-f " file
+ Log messages to the specified filename rather than to the syslog facility.
+ .TP
++.BI "\-u " username
++Tells klogd to become the specified user and drop root privileges before
++starting logging.
++.TP
++.BI "\-j " chroot_dir
++Tells klogd to
++.BR chroot (2)
++into this directory after initializing.
++This option is only valid if the \-u option is also used to run klogd
++without root privileges.
++Note that the use of this option will prevent \-i and \-I from working
++unless you set up the chroot directory in such a way that klogd can still
++read the kernel module symbols.
++.TP
+ .BI "\-i \-I"
+ Signal the currently executing klogd daemon. Both of these switches control
+ the loading/reloading of symbol information. The \-i switch signals the
+diff -upk.orig sysklogd-1.4.2.orig/klogd.c sysklogd-1.4.2/klogd.c
+--- sysklogd-1.4.2.orig/klogd.c 2005-08-18 12:29:52 +0000
++++ sysklogd-1.4.2/klogd.c 2005-08-18 14:37:47 +0000
+@@ -261,6 +261,8 @@
+ #include <stdarg.h>
+ #include <paths.h>
+ #include <stdlib.h>
++#include <pwd.h>
++#include <grp.h>
+ #include "klogd.h"
+ #include "ksyms.h"
+ #ifndef TESTING
+@@ -315,6 +317,9 @@ static enum LOGSRC {none, proc, kernel}
+ int debugging = 0;
+ int symbols_twice = 0;
+
++char *server_user = NULL;
++char *chroot_dir = NULL;
++int log_flags = 0;
+
+ /* Function prototypes. */
+ extern int ksyslog(int type, char *buf, int len);
+@@ -535,8 +540,9 @@ static enum LOGSRC GetKernelLogSrc(void)
+ * First do a stat to determine whether or not the proc based
+ * file system is available to get kernel messages from.
+ */
+- if ( use_syscall ||
+- ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) )
++ if (!server_user &&
++ (use_syscall ||
++ ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT))))
+ {
+ /* Initialize kernel logging. */
+ ksyslog(1, NULL, 0);
+@@ -983,6 +989,27 @@ static void LogProcLine(void)
+ }
+
+
++static int drop_root(void)
++{
++ struct passwd *pw;
++
++ if (!(pw = getpwnam(server_user))) return -1;
++
++ if (!pw->pw_uid) return -1;
++
++ if (chroot_dir) {
++ if (chdir(chroot_dir)) return -1;
++ if (chroot(".")) return -1;
++ }
++
++ if (setgroups(0, NULL)) return -1;
++ if (setgid(pw->pw_gid)) return -1;
++ if (setuid(pw->pw_uid)) return -1;
++
++ return 0;
++}
++
++
+ int main(argc, argv)
+
+ int argc;
+@@ -1000,7 +1027,7 @@ int main(argc, argv)
+ chdir ("/");
+ #endif
+ /* Parse the command-line. */
+- while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx2")) != EOF)
++ while ((ch = getopt(argc, argv, "c:df:u:j:iIk:nopsvx2")) != EOF)
+ switch((char)ch)
+ {
+ case '2': /* Print lines with symbols twice. */
+@@ -1022,6 +1049,10 @@ int main(argc, argv)
+ case 'I':
+ SignalDaemon(SIGUSR2);
+ return(0);
++ case 'j': /* chroot 'j'ail */
++ chroot_dir = optarg;
++ log_flags |= LOG_NDELAY;
++ break;
+ case 'k': /* Kernel symbol file. */
+ symfile = optarg;
+ break;
+@@ -1037,6 +1068,9 @@ int main(argc, argv)
+ case 's': /* Use syscall interface. */
+ use_syscall = 1;
+ break;
++ case 'u': /* Run as this user */
++ server_user = optarg;
++ break;
+ case 'v':
+ printf("klogd %s.%s\n", VERSION, PATCHLEVEL);
+ exit (1);
+@@ -1045,6 +1079,10 @@ int main(argc, argv)
+ break;
+ }
+
++ if (chroot_dir && !server_user) {
++ fputs("'-j' is only valid with '-u'\n", stderr);
++ exit(1);
++ }
+
+ /* Set console logging level. */
+ if ( log_level != (char *) 0 )
+@@ -1158,7 +1196,7 @@ int main(argc, argv)
+ }
+ }
+ else
+- openlog("kernel", 0, LOG_KERN);
++ openlog("kernel", log_flags, LOG_KERN);
+
+
+ /* Handle one-shot logging. */
+@@ -1191,6 +1229,11 @@ int main(argc, argv)
+ }
+ }
+
++ if (server_user && drop_root()) {
++ syslog(LOG_ALERT, "klogd: failed to drop root");
++ Terminate();
++ }
++
+ /* The main loop. */
+ while (1)
+ {
diff --git a/main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-bind.diff b/main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-bind.diff
new file mode 100644
index 00000000000..ad311a512c0
--- /dev/null
+++ b/main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-bind.diff
@@ -0,0 +1,103 @@
+http://cvsweb.openwall.com/cgi/cvsweb.cgi/~checkout~/Owl/packages/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-bind.diff?rev=1.1;content-type=text%2Fplain
+diff -upk.orig sysklogd-1.4.2.orig/sysklogd.8 sysklogd-1.4.2/sysklogd.8
+--- sysklogd-1.4.2.orig/sysklogd.8 2004-07-09 17:33:32 +0000
++++ sysklogd-1.4.2/sysklogd.8 2005-08-18 14:40:25 +0000
+@@ -15,6 +15,9 @@ sysklogd \- Linux system logging utiliti
+ .I config file
+ ]
+ .RB [ " \-h " ]
++.RB [ " \-i "
++.I IP address
++]
+ .RB [ " \-l "
+ .I hostlist
+ ]
+@@ -104,6 +107,13 @@ Specifying this switch on the command li
+ This can cause syslog loops that fill up hard disks quite fast and
+ thus needs to be used with caution.
+ .TP
++.BI "\-i " "IP address"
++If
++.B syslogd
++is configured to accept log input from a UDP port, specify an IP address
++to bind to, rather than the default of INADDR_ANY. The address must be in
++dotted quad notation, DNS host names are not allowed.
++.TP
+ .BI "\-l " "hostlist"
+ Specify a hostname that should be logged only with its simple hostname
+ and not the fqdn. Multiple hosts may be specified using the colon
+diff -upk.orig sysklogd-1.4.2.orig/syslogd.c sysklogd-1.4.2/syslogd.c
+--- sysklogd-1.4.2.orig/syslogd.c 2005-08-18 14:33:22 +0000
++++ sysklogd-1.4.2/syslogd.c 2005-08-18 14:40:25 +0000
+@@ -774,6 +774,8 @@ char **LocalHosts = NULL; /* these hosts
+ int NoHops = 1; /* Can we bounce syslog messages through an
+ intermediate host. */
+
++char *bind_addr = NULL; /* bind UDP port to this interface only */
++
+ extern int errno;
+
+ /* Function prototypes. */
+@@ -878,7 +880,7 @@ int main(argc, argv)
+ funix[i] = -1;
+ }
+
+- while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
++ while ((ch = getopt(argc, argv, "a:dhf:i:l:m:np:rs:v")) != EOF)
+ switch((char)ch) {
+ case 'a':
+ if (nfunix < MAXFUNIX)
+@@ -895,9 +897,17 @@ int main(argc, argv)
+ case 'h':
+ NoHops = 0;
+ break;
++ case 'i':
++ if (bind_addr) {
++ fprintf(stderr, "Only one -i argument allowed, "
++ "the first one is taken.\n");
++ break;
++ }
++ bind_addr = optarg;
++ break;
+ case 'l':
+ if (LocalHosts) {
+- fprintf (stderr, "Only one -l argument allowed," \
++ fprintf(stderr, "Only one -l argument allowed, "
+ "the first one is taken.\n");
+ break;
+ }
+@@ -1244,7 +1254,7 @@ int main(argc, argv)
+ int usage()
+ {
+ fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
+- " [-s domainlist] [-f conffile]\n");
++ " [-s domainlist] [-f conffile] [-i IP address]\n");
+ exit(1);
+ }
+
+@@ -1286,15 +1296,22 @@ static int create_inet_socket()
+ int fd, on = 1;
+ struct sockaddr_in sin;
+
++ memset(&sin, 0, sizeof(sin));
++ sin.sin_family = AF_INET;
++ sin.sin_port = LogPort;
++ if (bind_addr) {
++ if (!inet_aton(bind_addr, &sin.sin_addr)) {
++ logerror("syslog: not a valid IP address to bind to.");
++ return -1;
++ }
++ }
++
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ logerror("syslog: Unknown protocol, suspending inet service.");
+ return fd;
+ }
+
+- memset(&sin, 0, sizeof(sin));
+- sin.sin_family = AF_INET;
+- sin.sin_port = LogPort;
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, \
+ (char *) &on, sizeof(on)) < 0 ) {
+ logerror("setsockopt(REUSEADDR), suspending inet");
diff --git a/main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff b/main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff
new file mode 100644
index 00000000000..8c3f571f3ca
--- /dev/null
+++ b/main/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff
@@ -0,0 +1,118 @@
+http://cvsweb.openwall.com/cgi/cvsweb.cgi/~checkout~/Owl/packages/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-drop-root.diff?rev=1.1;content-type=text%2Fplain
+diff -upk.orig sysklogd-1.4.2.orig/sysklogd.8 sysklogd-1.4.2/sysklogd.8
+--- sysklogd-1.4.2.orig/sysklogd.8 2005-08-18 14:40:25 +0000
++++ sysklogd-1.4.2/sysklogd.8 2005-08-18 14:41:26 +0000
+@@ -32,6 +32,9 @@ sysklogd \- Linux system logging utiliti
+ .RB [ " \-s "
+ .I domainlist
+ ]
++.RB [ " \-u"
++.IB username
++]
+ .RB [ " \-v " ]
+ .LP
+ .SH DESCRIPTION
+@@ -161,6 +164,19 @@ is specified and the host logging resolv
+ no domain would be cut, you will have to specify two domains like:
+ .BR "\-s north.de:infodrom.north.de" .
+ .TP
++.BI "\-u " "username"
++This causes the
++.B syslogd
++daemon to become the named user before starting up logging.
++
++Note that when this option is in use,
++.B syslogd
++will open all log files as root when the daemon is first started;
++however, after a
++.B SIGHUP
++the files will be reopened as the non-privileged user. You should
++take this into account when deciding the ownership of the log files.
++.TP
+ .B "\-v"
+ Print version and exit.
+ .LP
+diff -upk.orig sysklogd-1.4.2.orig/syslogd.c sysklogd-1.4.2/syslogd.c
+--- sysklogd-1.4.2.orig/syslogd.c 2005-08-18 14:40:25 +0000
++++ sysklogd-1.4.2/syslogd.c 2005-08-18 14:41:26 +0000
+@@ -524,6 +524,10 @@ static char sccsid[] = "@(#)syslogd.c 5.
+ #include <arpa/nameser.h>
+ #include <arpa/inet.h>
+ #include <resolv.h>
++
++#include <pwd.h>
++#include <grp.h>
++
+ #ifndef TESTING
+ #include "pidfile.h"
+ #endif
+@@ -775,6 +779,7 @@ int NoHops = 1; /* Can we bounce syslog
+ intermediate host. */
+
+ char *bind_addr = NULL; /* bind UDP port to this interface only */
++char *server_user = NULL; /* user name to run server as */
+
+ extern int errno;
+
+@@ -827,6 +832,21 @@ static int set_nonblock_flag(int desc)
+ return fcntl(desc, F_SETFL, flags | O_NONBLOCK);
+ }
+
++static int drop_root(void)
++{
++ struct passwd *pw;
++
++ if (!(pw = getpwnam(server_user))) return -1;
++
++ if (!pw->pw_uid) return -1;
++
++ if (initgroups(server_user, pw->pw_gid)) return -1;
++ if (setgid(pw->pw_gid)) return -1;
++ if (setuid(pw->pw_uid)) return -1;
++
++ return 0;
++}
++
+ int main(argc, argv)
+ int argc;
+ char **argv;
+@@ -880,7 +900,7 @@ int main(argc, argv)
+ funix[i] = -1;
+ }
+
+- while ((ch = getopt(argc, argv, "a:dhf:i:l:m:np:rs:v")) != EOF)
++ while ((ch = getopt(argc, argv, "a:dhf:i:l:m:np:rs:u:v")) != EOF)
+ switch((char)ch) {
+ case 'a':
+ if (nfunix < MAXFUNIX)
+@@ -933,6 +953,9 @@ int main(argc, argv)
+ }
+ StripDomains = crunch_list(optarg);
+ break;
++ case 'u':
++ server_user = optarg;
++ break;
+ case 'v':
+ printf("syslogd %s.%s\n", VERSION, PATCHLEVEL);
+ exit (0);
+@@ -1100,6 +1123,11 @@ int main(argc, argv)
+ kill (ppid, SIGTERM);
+ #endif
+
++ if (server_user && drop_root()) {
++ dprintf("syslogd: failed to drop root\n");
++ exit(1);
++ }
++
+ /* Main loop begins here. */
+ for (;;) {
+ int nfds;
+@@ -1254,7 +1282,7 @@ int main(argc, argv)
+ int usage()
+ {
+ fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
+- " [-s domainlist] [-f conffile] [-i IP address]\n");
++ " [-s domainlist] [-f conffile] [-i IP address] [-u username]\n");
+ exit(1);
+ }
+
diff --git a/main/sysklogd/sysklogd-1.5-build.patch b/main/sysklogd/sysklogd-1.5-build.patch
new file mode 100644
index 00000000000..6175cdfe783
--- /dev/null
+++ b/main/sysklogd/sysklogd-1.5-build.patch
@@ -0,0 +1,20 @@
+respect env CC/CFLAGS/CPPFLAGS/LDFLAGS
+
+--- a/Makefile
++++ b/Makefile
+@@ -17,14 +17,12 @@
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+-CC= gcc
+ #SKFLAGS= -g -DSYSV -Wall
+ #LDFLAGS= -g
+-SKFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
++SKFLAGS= $(CFLAGS) $(CPPFLAGS) -DSYSV -Wall -fno-strength-reduce
+ # -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+ # -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
+ # $(shell getconf LFS_SKFLAGS)
+-LDFLAGS= -s
+
+ # Look where your install program is.
+ INSTALL = /usr/bin/install
diff --git a/main/sysklogd/sysklogd.confd b/main/sysklogd/sysklogd.confd
new file mode 100644
index 00000000000..c9735739117
--- /dev/null
+++ b/main/sysklogd/sysklogd.confd
@@ -0,0 +1,6 @@
+# Config file for /etc/init.d/sysklogd
+
+SYSLOGD="-m 0"
+# send warnings and above to the console
+KLOGD="-c 3 -2"
+
diff --git a/main/sysklogd/sysklogd.initd b/main/sysklogd/sysklogd.initd
new file mode 100644
index 00000000000..59db00fc991
--- /dev/null
+++ b/main/sysklogd/sysklogd.initd
@@ -0,0 +1,79 @@
+#!/sbin/runscript
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/app-admin/sysklogd/files/sysklogd.rc6,v 1.12 2007/05/01 12:49:04 uberlord Exp $
+
+opts="reload"
+
+depend() {
+ need clock hostname cron
+ provide logger
+}
+
+start_daemon() {
+ local retval=0
+ local daemon="$1"
+ local options="$2"
+
+ [ -z "${daemon}" ] && return 1
+
+ ebegin "sysklogd -> start: ${daemon}"
+ start-stop-daemon --start --exec /usr/sbin/"${daemon}" \
+ --pidfile /var/run/"${daemon}".pid -- ${options}
+ retval=$?
+ eend ${retval} "Failed to start ${daemon}"
+
+ return ${retval}
+}
+
+stop_daemon() {
+ local retval=0
+ local daemon="$1"
+
+ [ -z "${daemon}" ] && return 1
+
+ ebegin "sysklogd -> stop: ${daemon}"
+ # syslogd can be stubborn some times (--retry 15)...
+ start-stop-daemon --stop --retry 15 --quiet --pidfile /var/run/"${daemon}".pid
+ retval=$?
+ eend ${retval} "Failed to stop ${daemon}"
+
+ return ${retval}
+}
+
+start() {
+ start_daemon "syslogd" "${SYSLOGD}" || return 1
+
+ # vservers should not start klogd
+ [ "$RC_SYS" = "VSERVER" ] && return 0
+ # klogd do not always start proper if started too early
+ sleep 1
+
+ if ! start_daemon "klogd" "${KLOGD}" ; then
+ stop_daemon "syslogd"
+ return 1
+ fi
+
+ return 0
+}
+
+stop() {
+ if [ "$RC_SYS" != "VSERVER" ]; then
+ stop_daemon "klogd" || return 1
+ fi
+ stop_daemon "syslogd" || return 1
+ return 0
+}
+
+reload() {
+ local ret=0
+
+ ebegin "Reloading configuration"
+
+ start-stop-daemon --stop --oknodo --signal HUP --pidfile /var/run/syslogd.pid
+ ret=$((${ret} + $?))
+ start-stop-daemon --stop --oknodo --signal USR1 --pidfile /var/run/klogd.pid
+ ret=$((${ret} + $?))
+
+ eend ${ret}
+}
diff --git a/main/sysklogd/sysklogd.logrotate b/main/sysklogd/sysklogd.logrotate
new file mode 100644
index 00000000000..29afd15bd4e
--- /dev/null
+++ b/main/sysklogd/sysklogd.logrotate
@@ -0,0 +1,6 @@
+/var/log/messages /var/log/auth /var/log/mail /var/log/errors /var/log/kernel {
+ sharedscripts
+ postrotate
+ /etc/init.d/sysklogd --quiet reload
+ endscript
+}
diff --git a/main/sysstat/APKBUILD b/main/sysstat/APKBUILD
new file mode 100644
index 00000000000..f9a1408b7f6
--- /dev/null
+++ b/main/sysstat/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sysstat
+pkgver=9.0.3
+pkgrel=0
+pkgdesc="Performance monitoring tools for Linux"
+url="http://pagesperso-orange.fr/sebastien.godard/"
+license="GPL"
+depends=
+makedepends=""
+subpackages="$pkgname-doc"
+source="http://pagesperso-orange.fr/sebastien.godard/sysstat-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="0b464951596db934418259737cf50a31 sysstat-9.0.3.tar.gz"
diff --git a/main/tar/APKBUILD b/main/tar/APKBUILD
new file mode 100644
index 00000000000..7e713be6c99
--- /dev/null
+++ b/main/tar/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=tar
+pkgver=1.22
+pkgrel=0
+pkgdesc="Utility used to store, backup, and transport files"
+url="http://www.gnu.org"
+license='GPL'
+depends="uclibc"
+install="$pkgname.post-deinstall"
+makedepends=""
+source="ftp://ftp.gnu.org/gnu/tar/$pkgname-$pkgver.tar.gz
+$pkgname.post-deinstall"
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+}
+
+md5sums="efafad1b256e3de410f4fce5335d9c9d tar-1.22.tar.gz
+b84506d253e04db3c5af9016fead45a3 tar.post-deinstall"
diff --git a/main/tar/tar.post-deinstall b/main/tar/tar.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/tar/tar.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/tcl/APKBUILD b/main/tcl/APKBUILD
new file mode 100644
index 00000000000..32a9eff63fb
--- /dev/null
+++ b/main/tcl/APKBUILD
@@ -0,0 +1,33 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=tcl
+pkgver=8.5.7
+pkgrel=0
+pkgdesc="The Tcl scripting language"
+url="http://tcl.sourceforge.net/"
+license="custom"
+depends="uclibc"
+makedepends=""
+source="http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname$pkgver-src.tar.gz"
+subpackages="$pkgname-doc $pkgname-dev"
+
+build ()
+{
+ cd ${srcdir}/tcl${pkgver}/unix
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --disable-64bit
+ make || return 1
+ make INSTALL_ROOT=${pkgdir} install install-private-headers
+ ln -sf tclsh8.5 ${pkgdir}/usr/bin/tclsh
+ install -Dm644 ../license.terms ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
+ sed -i \
+ -e "s,^TCL_BUILD_LIB_SPEC='-L.*/unix,TCL_BUILD_LIB_SPEC='-L/usr/lib," \
+ -e "s,^TCL_SRC_DIR='.*',TCL_SRC_DIR='/usr/include'," \
+ -e "s,^TCL_BUILD_STUB_LIB_SPEC='-L.*/unix,TCL_BUILD_STUB_LIB_SPEC='-L/usr/lib," \
+ -e "s,^TCL_BUILD_STUB_LIB_PATH='.*/unix,TCL_BUILD_STUB_LIB_PATH='/usr/lib," \
+ -e "s,^TCL_LIB_FILE='libtcl8.5..TCL_DBGX..so',TCL_LIB_FILE=\"libtcl8.5\$\{TCL_DBGX\}.so\"," \
+ -e "s,^TCL_CC_SEARCH_FLAGS='\(.*\)',TCL_CC_SEARCH_FLAGS='\1:/usr/lib'," \
+ -e "s,^TCL_LD_SEARCH_FLAGS='\(.*\)',TCL_LD_SEARCH_FLAGS='\1:/usr/lib'," \
+ ${pkgdir}/usr/lib/tclConfig.sh
+}
+md5sums="f70ad8f78b5e4a9f792fe101f22b125f tcl8.5.7-src.tar.gz"
diff --git a/main/tcpdump/APKBUILD b/main/tcpdump/APKBUILD
new file mode 100644
index 00000000000..ad9f5323f42
--- /dev/null
+++ b/main/tcpdump/APKBUILD
@@ -0,0 +1,24 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=tcpdump
+pkgver=4.0.0
+pkgrel=1
+pkgdesc="A tool for network monitoring and data acquisition"
+url="http://www.tcpdump.org"
+license="BSD"
+depends="libpcap openssl"
+makedepends="libpcap-dev openssl-dev"
+source="http://www.$pkgname.org/release/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --enable-ipv6
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ rm -f "$pkgdir"/usr/sbin/tcpdump.4*
+}
+
+md5sums="b22ca72890df2301d922c9f2d17867f9 tcpdump-4.0.0.tar.gz"
diff --git a/main/tcpproxy/APKBUILD b/main/tcpproxy/APKBUILD
new file mode 100644
index 00000000000..a06aacb39a6
--- /dev/null
+++ b/main/tcpproxy/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+pkgname=tcpproxy
+pkgver=2.0.0_beta15
+_realver=2.0.0-beta15
+pkgrel=0
+pkgdesc="Transparent TCP Proxy"
+url="http://www.quietsche-entchen.de/cgi-bin/wiki.cgi/proxies/TcpProxy"
+license="GPL"
+depends=
+makedepends="ctags"
+install=""
+subpackages=""
+source="http://www.quietsche-entchen.de/download/$pkgname-$_realver.tar.gz
+ tcpproxy.initd"
+
+build() {
+ cd "$srcdir/$pkgname-$_realver"
+
+ make || return 1
+
+ install -m755 -D "$pkgname" "$pkgdir"/usr/sbin/"$pkgname"
+ install -Dm 755 "$startdir"/$pkgname.initd $pkgdir/etc/init.d/$pkgname
+}
+
+md5sums="e946f807049d6296f54aa57b5c17f1c8 tcpproxy-2.0.0-beta15.tar.gz
+f13fccf076e24df1352dfb884aa7b880 tcpproxy.initd"
diff --git a/main/tcpproxy/tcpproxy.initd b/main/tcpproxy/tcpproxy.initd
new file mode 100644
index 00000000000..a7fd4292db1
--- /dev/null
+++ b/main/tcpproxy/tcpproxy.initd
@@ -0,0 +1,14 @@
+#!/sbin/runscript
+
+DAEMON=/usr/sbin/tcpproxy
+start() {
+ ebegin "Starting tcpproxy"
+ start-stop-daemon -S -x $DAEMON -- $TCPPROXY_OPTS
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping tcpproxy"
+ start-stop-daemon -K -x $DAEMON
+ eend $?
+}
diff --git a/main/tiff/APKBUILD b/main/tiff/APKBUILD
new file mode 100644
index 00000000000..c580a84a302
--- /dev/null
+++ b/main/tiff/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Michael Mason <ms13sp@gmail.com>
+pkgname=tiff
+pkgver=3.8.2
+pkgrel=0
+pkgdesc="Provides support for the Tag Image File Format or TIFF"
+url="http://www.libtiff.org/"
+license="GPL"
+depends="uclibc"
+subpackages="$pkgname-doc $pkgname-dev"
+source="ftp://ftp.remotesensing.org/pub/lib$pkgname/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-cxx
+ make || return 1
+ make DESTDIR="$pkgdir" install
+
+}
+
+md5sums="fbb6f446ea4ed18955e2714934e5b698 tiff-3.8.2.tar.gz"
diff --git a/main/tinyproxy/APKBUILD b/main/tinyproxy/APKBUILD
new file mode 100644
index 00000000000..046daa8307b
--- /dev/null
+++ b/main/tinyproxy/APKBUILD
@@ -0,0 +1,40 @@
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Michael Mason <ms13sp@gmail.com>
+pkgname=tinyproxy
+pkgver=1.6.3
+pkgrel=0
+pkgdesc="Lightweight HTTP proxy"
+url="https://www.banu.com/tinyproxy/"
+license="GPL"
+depends="uclibc"
+makedepends=""
+install="tinyproxy.install"
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ tinyproxy.initd
+ $install
+ "
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # set default user to tinyproxy:tinyproxy and correct pidfile
+ sed -i -e 's:^User.*:User tinyproxy:' \
+ -e 's:^Group.*:Group tinyproxy:' \
+ -e 's:^PidFile.*:PidFile "/var/run/tinyproxy/tinyproxy.pid":' \
+ doc/tinyproxy.conf
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ mkdir -p "$pkgdir"/var/run/tinyproxy
+ install -Dm755 "$srcdir"/tinyproxy.initd "$pkgdir"/etc/init.d/tinyproxy
+}
+
+md5sums="bd14d029b12621bcfd7ee71b2f4893da tinyproxy-1.6.3.tar.gz
+554da6fc363fbe251f081b342541bef4 tinyproxy.initd
+2f5d9f4a8b7f4c7f1f5b9d59d99839e4 tinyproxy.install"
diff --git a/main/tinyproxy/tinyproxy.initd b/main/tinyproxy/tinyproxy.initd
new file mode 100644
index 00000000000..bee5d041fbd
--- /dev/null
+++ b/main/tinyproxy/tinyproxy.initd
@@ -0,0 +1,45 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/files/tinyproxy.initd,v 1.1 2008/02/16 07:11:25 mrness Exp $
+
+CONFFILE="/etc/tinyproxy/${SVCNAME}.conf"
+
+depend() {
+ use logger dns
+ need net
+}
+
+checkconfig() {
+ if [ ! -f "${CONFFILE}" ]; then
+ eerror "Configuration file ${CONFFILE} not found!"
+ return 1
+ fi
+
+ PIDFILE=$(sed -n -e 's/^[[:space:]]*PidFile[[:space:]]\+"\(.*\)"[[:space:]]*$/\1/p' "${CONFFILE}")
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting tinyproxy"
+ if [ -n "${PIDFILE}" ]; then
+ start-stop-daemon --start --pidfile "${PIDFILE}" --startas /usr/sbin/tinyproxy -- -c "${CONFFILE}"
+ else
+ start-stop-daemon --start --exec /usr/sbin/tinyproxy -- -c "${CONFFILE}"
+ fi
+ eend $?
+}
+
+stop() {
+ checkconfig || return 1
+
+ ebegin "Stopping tinyproxy"
+ if [ -n "${PIDFILE}" ]; then
+ start-stop-daemon --stop --pidfile "${PIDFILE}"
+ else
+ start-stop-daemon --stop --exec /usr/sbin/tinyproxy
+ fi
+ eend $?
+}
diff --git a/main/tinyproxy/tinyproxy.install b/main/tinyproxy/tinyproxy.install
new file mode 100644
index 00000000000..5fa366737be
--- /dev/null
+++ b/main/tinyproxy/tinyproxy.install
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+case "$1" in
+ pre_install)
+ adduser -h /dev/null -s /bin/false -D tinyproxy 2>/dev/null
+ ;;
+ post_install)
+ chown tinyproxy:tinyproxy /var/run/tinyproxy
+ ;;
+esac
+
+# return with success even if user already exist
+exit 0
diff --git a/main/tmux/APKBUILD b/main/tmux/APKBUILD
new file mode 100644
index 00000000000..7edc932264c
--- /dev/null
+++ b/main/tmux/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=tmux
+pkgver=0.9
+pkgrel=0
+pkgdesc="Tool to control multiple terminals from a single terminal"
+url="http://tmux.sourceforge.net/"
+license="BSD"
+depends=""
+makedepends="ncurses-dev"
+install=
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+ build.patch"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch -p1 < ../build.patch || return 1
+
+ ./configure
+ make || return 1
+ make DESTDIR="$pkgdir" PREFIX=/usr install
+
+}
+
+md5sums="2d1df646a6977bb7d9b20e53770d5593 tmux-0.9.tar.gz
+373cabbc35601c3ee71fde0877f5fe83 build.patch"
diff --git a/main/tmux/build.patch b/main/tmux/build.patch
new file mode 100644
index 00000000000..b16c4f4cab5
--- /dev/null
+++ b/main/tmux/build.patch
@@ -0,0 +1,23 @@
+diff -ru tmux-0.9.orig/GNUmakefile tmux-0.9/GNUmakefile
+--- tmux-0.9.orig/GNUmakefile 2009-07-09 08:11:37.000000000 +0000
++++ tmux-0.9/GNUmakefile 2009-07-09 08:12:09.000000000 +0000
+@@ -53,5 +53,5 @@
+ install: all
+ $(INSTALLDIR) $(DESTDIR)$(PREFIX)/bin
+ $(INSTALLBIN) tmux $(DESTDIR)$(PREFIX)/bin/tmux
+- $(INSTALLDIR) $(DESTDIR)$(PREFIX)/man/man1
+- $(INSTALLMAN) tmux.1 $(DESTDIR)$(PREFIX)/man/man1/tmux.1
++ $(INSTALLDIR) $(DESTDIR)$(PREFIX)/share/man/man1
++ $(INSTALLMAN) tmux.1 $(DESTDIR)$(PREFIX)/share/man/man1/tmux.1
+diff -ru tmux-0.9.orig/configure tmux-0.9/configure
+--- tmux-0.9.orig/configure 2009-07-09 08:11:37.000000000 +0000
++++ tmux-0.9/configure 2009-07-09 08:12:20.000000000 +0000
+@@ -82,7 +82,7 @@
+ compat/strtonum.c \
+ compat/getopt.c \
+ compat/vis.c
+-CFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE
++CFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE -std=c99
+ LIBS+= -lcrypt -lutil
+ EOF
+ ;;
diff --git a/main/transmission/APKBUILD b/main/transmission/APKBUILD
new file mode 100644
index 00000000000..0942c1b2a3f
--- /dev/null
+++ b/main/transmission/APKBUILD
@@ -0,0 +1,32 @@
+# Maintainer:Carlo Landmeter
+pkgname=transmission
+pkgver=1.61
+pkgel=0
+pkgdesc="Fast, easy, and fee BitToent client (CLI tools daemon and webinterface)"
+url="http://www.tansmissionbt.com"
+install="$pkgname.pre-install"
+license="MIT"
+depends="curl"
+makedepends="openssl-dev pkgconfig curl-dev g++"
+source="http://download.m0k.org/transmission/files/transmission-$pkgver.tar.bz2
+ transmission-daemon.initd
+ transmission-daemon.confd
+ $pkgname.pre-install"
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man \
+ --disable-gtk \
+ --disable-nls
+ make || return 1
+ make prefix="$pkgdir"/usr mandir="$pkgdir"/usr/share/man install
+ install -D -m755 "$srcdir"/transmission-daemon.initd "$pkgdir"/etc/init.d/transmission-daemon
+ install -D -m644 "$srcdir"/transmission-daemon.confd "$pkgdir"/etc/conf.d/transmission-daemon
+}
+md5sums="0b0428f4a6237a64dc8b7d378ace3f06 transmission-1.61.tar.bz2
+b3b921242bdc3b33a8ac05fc30653b6c transmission-daemon.initd
+89478a70fcd93463e1dd8d751da994da transmission-daemon.confd
+f1c8d94e1f7ff77c23a7e92d3860754d transmission.pre-install"
diff --git a/main/transmission/transmission-daemon.confd b/main/transmission/transmission-daemon.confd
new file mode 100644
index 00000000000..c1f338f07ce
--- /dev/null
+++ b/main/transmission/transmission-daemon.confd
@@ -0,0 +1,18 @@
+#
+# transmission-daemon options
+#
+# -a --acl <list> Access Control List. (Default: +127.0.0.1)
+# -b --blocklist Enable peer blocklists
+# -B --no-blocklist Disable peer blocklists
+# -f --foreground Run in the foreground instead of daemonizing
+# -g --config-dir <path> Where to look for configuration files
+# -p --port <port> RPC port (Default: 9091)
+# -t --auth Require authentication
+# -T --no-auth Don't require authentication
+# -u --username <username> Set username for authentication
+# -v --password <password> Set password for authentication
+# -w --download-dir <path> Where to save downloaded data
+#
+# NOTE: webif does not work without the -f switch
+#
+TD_OPTS="-f -g /var/lib/transmission/.config -w /var/lib/transmission"
diff --git a/main/transmission/transmission-daemon.initd b/main/transmission/transmission-daemon.initd
new file mode 100644
index 00000000000..af9461cc60c
--- /dev/null
+++ b/main/transmission/transmission-daemon.initd
@@ -0,0 +1,21 @@
+#!/sbin/runscript
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting transmission-daemon"
+ start-stop-daemon --start --quiet --background --make-pidfile \
+ --chuid transmission:transmission \
+ --pidfile /var/run/transmission-daemon.pid \
+ --exec /usr/bin/transmission-daemon -- ${TD_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping transmission-daemon"
+ start-stop-daemon --stop --quiet \
+ --pidfile /var/run/transmission-daemon.pid \
+ eend $?
+}
diff --git a/main/transmission/transmission.pre-install b/main/transmission/transmission.pre-install
new file mode 100644
index 00000000000..44a14760f64
--- /dev/null
+++ b/main/transmission/transmission.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+adduser -h /var/lib/transmission -s /bin/false -D transmission 2>/dev/null
+
+exit 0
diff --git a/main/udev/APKBUILD b/main/udev/APKBUILD
new file mode 100644
index 00000000000..d25b5faa492
--- /dev/null
+++ b/main/udev/APKBUILD
@@ -0,0 +1,41 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=udev
+pkgver=142
+pkgrel=0
+pkgdesc="The userspace dev tools (udev)"
+url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
+license="GPL"
+subpackages="$pkgname-dev $pkgname-doc"
+depends="uclibc"
+makedepends=""
+install=
+source="http://www.kernel.org/pub/linux/utils/kernel/hotplug/$pkgname-$pkgver.tar.bz2
+ write_root_link_rule
+ move_tmp_persistent_rules.sh
+ udev-mount.initd
+ udev-postmount.initd
+ udev.initd"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --exec-prefix="" \
+ --with-libdir-name=/lib
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ chmod +x "$pkgdir"/lib/udev/write_*_rules
+ for _i in write_root_link_rule move_tmp_persistent_rules.sh; do
+ install -Dm755 ../$_i "$pkgdir"/lib/udev/$_i
+ done
+ for _i in udev udev-mount udev-postmount; do
+ install -Dm755 ../$_i.initd "$pkgdir"/etc/init.d/$_i
+ done
+}
+md5sums="3edc4cf383dccb06d866c5156d59ddd5 udev-142.tar.bz2
+c9de7581099cdfdcd105666cd98a0f0a write_root_link_rule
+7bf11e11519117f743483c73e0767750 move_tmp_persistent_rules.sh
+12760065a66ccbddc9e3a86a6cd2231c udev-mount.initd
+bffb42859ca508cfe1d9fa0a169ba810 udev-postmount.initd
+e913f8f122e8879252d2a05de7dd7499 udev.initd"
diff --git a/main/udev/move_tmp_persistent_rules.sh b/main/udev/move_tmp_persistent_rules.sh
new file mode 100755
index 00000000000..1a0259798bc
--- /dev/null
+++ b/main/udev/move_tmp_persistent_rules.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+. /etc/init.d/functions.sh
+
+# store persistent-rules that got created while booting
+# when / was still read-only
+store_persistent_rules() {
+ local file dest
+
+ for file in /dev/.udev/tmp-rules--*; do
+ dest=${file##*tmp-rules--}
+ [ "$dest" = '*' ] && break
+ type=${dest##70-persistent-}
+ type=${type%%.rules}
+ ebegin "Saving udev persistent ${type} rules to /etc/udev/rules.d"
+ cat "$file" >> /etc/udev/rules.d/"$dest" && rm -f "$file"
+ eend $? "Failed moving persistent rules!"
+ done
+}
+
+store_persistent_rules
+
+# vim:ts=4
diff --git a/main/udev/udev-mount.initd b/main/udev/udev-mount.initd
new file mode 100755
index 00000000000..839565a5bac
--- /dev/null
+++ b/main/udev/udev-mount.initd
@@ -0,0 +1,83 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+description="Mount tmpfs on /dev"
+[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev
+
+mount_dev_directory()
+{
+ # No options are processed here as they should all be in /etc/fstab
+ ebegin "Mounting /dev"
+ if fstabinfo --quiet /dev; then
+ mount -n /dev
+ else
+ # Some devices require exec, Bug #92921
+ mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev
+ fi
+ eend $?
+}
+
+seed_dev()
+{
+ # Seed /dev with some things that we know we need
+
+ # creating /dev/console, /dev/tty and /dev/tty1 to be able to write
+ # to $CONSOLE with/without bootsplash before udevd creates it
+ [ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
+ [ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1
+ [ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0
+
+ # udevd will dup its stdin/stdout/stderr to /dev/null
+ # and we do not want a file which gets buffered in ram
+ [ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
+
+ # so udev can add its start-message to dmesg
+ [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
+
+ # copy over any persistant things
+ if [ -d /lib/udev/devices ]; then
+ cp -RPp /lib/udev/devices/* /dev 2>/dev/null
+ fi
+
+ # Not provided by sysfs but needed
+ ln -snf /proc/self/fd /dev/fd
+ ln -snf fd/0 /dev/stdin
+ ln -snf fd/1 /dev/stdout
+ ln -snf fd/2 /dev/stderr
+ [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
+
+ # Create problematic directories
+ mkdir -p /dev/pts /dev/shm
+ return 0
+}
+
+
+start()
+{
+ # do not run this on too old baselayout - udev-addon is already loaded!
+ if [ ! -f /etc/init.d/sysfs ]; then
+ eerror "The $SVCNAME init-script is written for baselayout-2!"
+ eerror "Please do not use it with baselayout-1!".
+ return 1
+ fi
+
+ _start
+}
+
+_start()
+{
+ mount_dev_directory || return 1
+
+ # Selinux lovin; /selinux should be mounted by selinux-patched init
+ if [ -x /sbin/restorecon -a -c /selinux/null ]; then
+ restorecon /dev > /selinux/null
+ fi
+
+ # make sure it exists
+ mkdir -p /dev/.udev
+
+ seed_dev
+
+ return 0
+}
diff --git a/main/udev/udev-postmount.initd b/main/udev/udev-postmount.initd
new file mode 100755
index 00000000000..96beb845bb9
--- /dev/null
+++ b/main/udev/udev-postmount.initd
@@ -0,0 +1,31 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/136/udev-postmount.initd,v 1.3 2009/02/23 16:30:53 zzam Exp $
+
+depend() {
+ need localmount
+}
+
+dir_writeable()
+{
+ mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$
+}
+
+start() {
+ # check if this system uses udev
+ [ -d /dev/.udev/ ] || return 0
+
+ # only continue if rules-directory is writable
+ dir_writeable /etc/udev/rules.d || return 0
+
+ # store persistent-rules that got created while booting
+ # when / was still read-only
+ /lib/udev/move_tmp_persistent_rules.sh
+}
+
+stop() {
+ :
+}
+
+# vim:ts=4
diff --git a/main/udev/udev-start.sh b/main/udev/udev-start.sh
new file mode 100644
index 00000000000..87c3a6ac932
--- /dev/null
+++ b/main/udev/udev-start.sh
@@ -0,0 +1,51 @@
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev
+
+compat_volume_nodes()
+{
+ # Only do this for baselayout-1*
+ # This check is likely to get false positives due to some multilib stuff,
+ # but that should not matter, as this can only happen on old openrc versions
+ # no longer available as ebuilds.
+ if [ ! -e /lib/librc.so ]; then
+
+ # Create nodes that udev can't
+ [ -x /sbin/lvm ] && \
+ /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
+ # Running evms_activate on a LiveCD causes lots of headaches
+ [ -z "${CDBOOT}" -a -x /sbin/evms_activate ] && \
+ /sbin/evms_activate -q &>/dev/null
+ fi
+}
+
+start_initd()
+{
+ (
+ . /etc/init.d/"$1"
+ _start
+ )
+}
+
+# mount tmpfs on /dev
+start_initd udev-mount || exit 1
+
+# Create a file so that our rc system knows it's still in sysinit.
+# Existance means init scripts will not directly run.
+# rc will remove the file when done with sysinit.
+# this is no longer needed as of openrc-0.4.0
+touch /dev/.rcsysinit
+
+# load device tarball
+start_initd udev-dev-tarball
+
+# run udevd
+start_initd udev || exit 1
+
+compat_volume_nodes
+
+# inject into boot runlevel
+IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1
+
+# udev started successfully
diff --git a/main/udev/udev.initd b/main/udev/udev.initd
new file mode 100755
index 00000000000..26774ab4acf
--- /dev/null
+++ b/main/udev/udev.initd
@@ -0,0 +1,239 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+description="Run udevd and create the device-nodes"
+
+[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf
+
+rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}}
+
+depend()
+{
+ provide dev
+ if yesno "${rc_device_tarball:-no}"; then
+ need sysfs udev-mount udev-dev-tarball
+ else
+ need sysfs udev-mount
+ fi
+ before checkfs fsck
+
+ # udev does not work inside vservers
+ keyword novserver
+}
+
+cleanup()
+{
+ # fail more gracely and not leave udevd running
+ start-stop-daemon --stop --exec /sbin/udevd
+ exit 1
+}
+
+disable_hotplug_agent()
+{
+ if [ -e /proc/sys/kernel/hotplug ]; then
+ echo "" >/proc/sys/kernel/hotplug
+ fi
+}
+
+root_link()
+{
+ /lib/udev/write_root_link_rule
+}
+
+rules_disable_switch()
+{
+ # this function disables rules files
+ # by creating new files with the same name
+ # in a temp rules directory with higher priority
+ local d=/dev/.udev/rules.d bname="$1" onoff="$2"
+
+ if yesno "${onoff}"; then
+ mkdir -p "$d"
+ echo "# This file disables ${bname} due to /etc/conf.d/udev" \
+ > "${d}/${bname}"
+ else
+ rm -f "${d}/${bname}"
+ fi
+}
+
+start_udevd()
+{
+ # load unix domain sockets if built as module, Bug #221253
+ if [ -e /proc/modules ] ; then
+ modprobe -q unix 2>/dev/null
+ fi
+ ebegin "Starting udevd"
+ start-stop-daemon --start --exec /sbin/udevd -- --daemon
+ eend $?
+}
+
+# populate /dev with devices already found by the kernel
+populate_dev()
+{
+ if get_bootparam "nocoldplug" ; then
+ rc_coldplug="NO"
+ ewarn "Skipping udev coldplug as requested in kernel cmdline"
+ fi
+
+ ebegin "Populating /dev with existing devices through uevents"
+ if yesno "${rc_coldplug}"; then
+ udevadm trigger
+ else
+ # Do not run any init-scripts, Bug #206518
+ udevadm control --env do_not_run_plug_service=1
+
+ # only create device nodes
+ udevadm trigger --attr-match=dev
+
+ # run persistent-net stuff, bug 191466
+ udevadm trigger --subsystem-match=net
+ fi
+ eend $?
+
+ ebegin "Waiting for uevents to be processed"
+ udevadm settle --timeout=${udev_settle_timeout:-60}
+ eend $?
+
+ udevadm control --env do_not_run_plug_service=
+ return 0
+}
+
+# for debugging
+start_udevmonitor()
+{
+ yesno "${udev_monitor:-no}" || return 0
+
+ udevmonitor_log=/dev/.udev/udevmonitor.log
+ udevmonitor_pid=/dev/.udev/udevmonitor.pid
+
+ einfo "udev: Running udevadm monitor ${udev_monitor_opts} to get a log of all events"
+ start-stop-daemon --start --stdout "${udevmonitor_log}" \
+ --make-pidfile --pidfile "${udevmonitor_pid}" \
+ --background --exec /sbin/udevadm -- monitor ${udev_monitor_opts}
+}
+
+stop_udevmonitor()
+{
+ yesno "${udev_monitor:-no}" || return 0
+
+ if yesno "${udev_monitor_keep_running:-no}"; then
+ ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}"
+ else
+ einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}"
+ start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /sbin/udevadm
+ fi
+}
+
+display_hotplugged_services() {
+ local svcfile= svc= services=
+ for svcfile in "${RC_SVCDIR}"/hotplugged/*; do
+ svc="${svcfile##*/}"
+ [ -x "${svcfile}" ] || continue
+
+ # do not display this - better: do only inject it later :)
+ [ "$svc" = "udev-postmount" ] && continue
+
+ services="${services} ${svc}"
+ done
+ [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}"
+}
+
+inject_postmount_initd() {
+ if ! mark_service_hotplugged udev-postmount; then
+ IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1
+ fi
+ #einfo "Injected udev-postmount service"
+}
+
+check_persistent_net()
+{
+ # check if there are problems with persistent-net
+ local syspath= devs= problem=false
+ for syspath in /sys/class/net/*_rename*; do
+ if [ -d "${syspath}" ]; then
+ devs="${devs} ${syspath##*/}"
+ problem=true
+ fi
+ done
+
+ ${problem} || return 0
+
+ eerror "UDEV: Your system has a problem assigning persistent names"
+ eerror "to these network interfaces: ${devs}"
+
+ einfo "Checking persistent-net rules:"
+ # the sed-expression lists all duplicate lines
+ # from the input, like "uniq -d" does, but uniq
+ # is installed into /usr/bin and not available at boot.
+ dups=$(
+ RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules'
+ . /lib/udev/rule_generator.functions
+ find_all_rules 'NAME=' '.*' | \
+ tr ' ' '\n' | \
+ sort | \
+ sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'
+ )
+ if [ -n "${dups}" ]; then
+ ewarn "The rules create multiple entries assigning these names:"
+ eindent
+ ewarn "${dups}"
+ eoutdent
+ else
+ ewarn "Found no duplicate names in persistent-net rules,"
+ ewarn "there must be some other problem!"
+ fi
+ return 1
+}
+
+check_udev_works()
+{
+ # should exist on every system, else udev failed
+ if [ ! -e /dev/zero ]; then
+ eerror "Assuming udev failed somewhere, as /dev/zero does not exist."
+ return 1
+ fi
+ return 0
+}
+
+start()
+{
+ # do not run this on old baselayout where udev-addon gets loaded
+ if [ ! -f /etc/init.d/sysfs ]; then
+ eerror "The $SVCNAME init-script is written for baselayout-2!"
+ eerror "Please do not use it with baselayout-1!".
+ return 1
+ fi
+
+ _start
+
+ display_hotplugged_services
+
+ inject_postmount_initd
+}
+
+_start()
+{
+ root_link
+ rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_disable:-no}"
+ rules_disable_switch 75-cd-aliases-generator.rules ${persistent_cd_disable:-no}
+
+ disable_hotplug_agent
+ start_udevd || cleanup
+ start_udevmonitor
+ populate_dev || cleanup
+
+ check_persistent_net
+
+ check_udev_works || cleanup
+ stop_udevmonitor
+
+ return 0
+}
+
+stop() {
+ ebegin "Stopping udevd"
+ start-stop-daemon --stop --exec /sbin/udevd
+ eend $?
+}
+
diff --git a/main/udev/write_root_link_rule b/main/udev/write_root_link_rule
new file mode 100755
index 00000000000..8eaea117693
--- /dev/null
+++ b/main/udev/write_root_link_rule
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# This script should run before doing udevtrigger at boot.
+# It will create a rule matching the device directory / is on, and
+# creating /dev/root symlink pointing on its device node.
+#
+# This is especially useful for hal looking at /proc/mounts containing
+# a line listing /dev/root as device:
+# /dev/root / reiserfs rw 0 0
+#
+# 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 version 2 of the License.
+#
+# (c) 2007-2008 Matthias Schwarzott <zzam@gentoo.org>
+
+eval $(udevadm info --export --export-prefix="ROOT_" --device-id-of-file=/)
+
+[ $? = 0 ] || exit 0
+[ "$ROOT_MAJOR" = 0 ] && exit 0
+
+DIR=/dev/.udev/rules.d
+[ -d "$DIR" ] || mkdir -p "$DIR"
+RULES=$DIR/10-root-link.rules
+
+echo "# Created by /lib/udev/write_root_link_rule" > "${RULES}"
+echo "# This rule should create /dev/root as link to real root device." >> "${RULES}"
+echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$ROOT_MAJOR\", ENV{MINOR}==\"$ROOT_MINOR\", SYMLINK+=\"root\"" >> "${RULES}"
+
diff --git a/main/uiconv/APKBUILD b/main/uiconv/APKBUILD
new file mode 100644
index 00000000000..3814bb56563
--- /dev/null
+++ b/main/uiconv/APKBUILD
@@ -0,0 +1,17 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=uiconv
+pkgver=0.3
+pkgrel=0
+pkgdesc="Micro iconv implementation"
+url="http://git.alpinelinux.org/cgit/uiconv"
+license="GPL"
+depends="uclibc"
+source="http://git.alpinelinux.org/cgit/$pkgname/snapshots/$pkgname-$pkgver.tar.bz2"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make || return 1
+ make DESTDIR="$pkgdir" PREFIX=/usr/uiconv install
+}
+
+md5sums="5cd7f80085324d08cb976fec674cd98d uiconv-0.3.tar.bz2"
diff --git a/main/unarj/APKBUILD b/main/unarj/APKBUILD
new file mode 100644
index 00000000000..b2e0c72607e
--- /dev/null
+++ b/main/unarj/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=unarj
+pkgver=2.63a
+pkgrel=0
+pkgdesc="Extracting, testing and viewing the contents of archives created with the ARJ archiver"
+url="http://www.arjsoftware.com"
+license="custom"
+subpackages=""
+depends="uclibc"
+makedepends=""
+install=
+source="http://ibiblio.org/pub/Linux/utils/compress/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/${pkgname}-${pkgver}
+ make || return 1
+ install -D -m755 unarj $pkgdir/usr/bin/unarj || return 1
+ #install -D -m644 ../LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
+}
+
+md5sums="a83d139c245f911f22cb1b611ec9768f unarj-2.63a.tar.gz"
diff --git a/main/unfs3/APKBUILD b/main/unfs3/APKBUILD
new file mode 100644
index 00000000000..28de3015711
--- /dev/null
+++ b/main/unfs3/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=unfs3
+pkgver=0.9.22
+pkgrel=0
+pkgdesc="a user-space implementation of the NFSv3 server specification"
+url="http://unfs3.sourceforge.net/"
+license='GPL'
+depends="uclibc"
+makedepends="flex"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
+subpackages="$pkgname-doc"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/share/man
+ make -j1 || return 1
+ make DESTDIR="$pkgdir/" install
+}
+
+md5sums="ddf679a5d4d80096a59f3affc64f16e5 unfs3-0.9.22.tar.gz"
diff --git a/main/unixodbc/APKBUILD b/main/unixodbc/APKBUILD
new file mode 100644
index 00000000000..cd72a165373
--- /dev/null
+++ b/main/unixodbc/APKBUILD
@@ -0,0 +1,27 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=unixodbc
+pkgver=2.2.14
+pkgrel=0
+pkgdesc="ODBC is an open specification to access Data Sources"
+url="http://www.unixodbc.org/"
+license="GPL2"
+depends="readline"
+makedepends="readline-dev"
+subpackages="$pkgname-dev"
+source="http://www.unixodbc.org/unixODBC-${pkgver}.tar.gz"
+
+build() {
+ cd "$srcdir/unixODBC-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-gui=no
+ make || return 1
+ make -j1 DESTDIR="$pkgdir" install
+
+}
+
+md5sums="f47c2efb28618ecf5f33319140a7acd0 unixODBC-2.2.14.tar.gz"
diff --git a/main/unrar/APKBUILD b/main/unrar/APKBUILD
new file mode 100644
index 00000000000..67f33fac05d
--- /dev/null
+++ b/main/unrar/APKBUILD
@@ -0,0 +1,26 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=unrar
+pkgver=3.9.4
+pkgrel=0
+pkgdesc="The RAR uncompression program"
+url="http://www.rarlab.com"
+license="GPL"
+depends=
+makedepends="uclibc++-dev"
+subpackages="$pkgname-doc"
+source="http://www.rarlab.com/rar/unrarsrc-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname"
+
+ export CXX=g++-uc
+
+ make -f makefile.unix || return 1
+ install -Dm755 unrar "$pkgdir"/usr/bin/unrar
+
+ install -Dm644 license.txt "$pkgdir/usr/share/licenses/$pkgname/license.txt"
+
+}
+
+md5sums="1800a2242911fc118f6a2b084d0c22c1 unrarsrc-3.9.4.tar.gz"
diff --git a/main/usbutils/APKBUILD b/main/usbutils/APKBUILD
new file mode 100644
index 00000000000..7dc7905c30a
--- /dev/null
+++ b/main/usbutils/APKBUILD
@@ -0,0 +1,24 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=usbutils
+pkgver=0.82
+pkgrel=1
+pkgdesc="USB Device Utilities"
+url="http://linux-usb.sourceforge.net/"
+license="GPL"
+subpackags="$pkgname-doc"
+depends=
+makedepends="pkgconfig libusb-compat-dev"
+source="http://downloads.sourceforge.net/sourceforge/linux-usb/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir"/$pkgname-$pkgver
+ rm usb.ids
+ wget http://www.linux-usb.org/usb.ids
+ ./configure --prefix=/usr \
+ --datadir=/usr/share/hwdata \
+ --disable-zlib
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+md5sums="6e393cc7423b5d228fa3d34c21481ae4 usbutils-0.82.tar.gz"
diff --git a/main/v86d/APKBUILD b/main/v86d/APKBUILD
new file mode 100644
index 00000000000..8bcdcf6181b
--- /dev/null
+++ b/main/v86d/APKBUILD
@@ -0,0 +1,21 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=v86d
+pkgver=0.1.9
+pkgdesc="userspace helper for uvesafb that runs x86 code in an emulated environment"
+url="http://dev.gentoo.org/~spock/projects/uvesafb/"
+license="GPL2"
+depends="uclibc"
+makedepends="bash"
+source="http://dev.gentoo.org/~spock/projects/uvesafb/archive/$pkgname-$pkgver.tar.bz2
+ modprobe.uvesafb"
+
+build ()
+{
+ cd "$srcdir"/v86d-$pkgver
+ ./configure --with-x86emu
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+ install -D -m644 "$srcdir"/modprobe.uvesafb "$pkgdir"/etc/modprobe.d/uvesafb || return 1
+}
+md5sums="ebbbc8e7013c9544b6ba6981add43831 v86d-0.1.9.tar.bz2
+2d7cc8dc6a41916a13869212d0191147 modprobe.uvesafb"
diff --git a/main/v86d/modprobe.uvesafb b/main/v86d/modprobe.uvesafb
new file mode 100644
index 00000000000..5e46e108833
--- /dev/null
+++ b/main/v86d/modprobe.uvesafb
@@ -0,0 +1,10 @@
+#
+# This file sets the parameters for uvesafb module.
+# The following format should be used:
+# options uvesafb mode=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ...
+#
+# For more details see:
+# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt
+#
+
+options uvesafb mode_option=1024x768-32 scroll=ywrap
diff --git a/main/vala/APKBUILD b/main/vala/APKBUILD
new file mode 100644
index 00000000000..1a03977a057
--- /dev/null
+++ b/main/vala/APKBUILD
@@ -0,0 +1,22 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=vala
+pkgver=0.7.4
+pkgrel=0
+pkgdesc="Compiler for the GObject type system"
+url="http://live.gnome.org/Vala"
+license="LGPL"
+subpackages="$pkgname-doc"
+depends="glib-dev"
+makedepends="libxslt-dev bash glib-dev flex bison"
+source="http://ftp.gnome.org/pub/gnome/sources/$pkgname/0.7/$pkgname-$pkgver.tar.gz"
+
+build ()
+{
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr \
+ --enable-vapigen || return 1
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+}
+
+md5sums="6ca0017be63244aff4d62d5f51f4b31a vala-0.7.4.tar.gz"
diff --git a/main/valgrind/APKBUILD b/main/valgrind/APKBUILD
new file mode 100644
index 00000000000..dcba2983737
--- /dev/null
+++ b/main/valgrind/APKBUILD
@@ -0,0 +1,55 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=valgrind
+pkgver=3.4.1
+pkgrel=1
+pkgdesc="A tool to help find memory-management problems in programs"
+url="http://valgrind.org/"
+license="GPL"
+depends="uclibc"
+# it seems like busybox sed works but the configure script requires GNU sed
+makedepends="sed paxctl pax-utils"
+# from README_PACKAGERS:
+# Don't strip the debug info off lib/valgrind/$platform/vgpreload*.so
+# in the installation tree. Either Valgrind won't work at all, or it
+# will still work if you do, but will generate less helpful error
+# messages.
+options="!strip"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://$pkgname.org/downloads/$pkgname-$pkgver.tar.bz2
+ $pkgname-3.4.0-uclibc.patch
+ "
+
+build() {
+ local i
+ cd "$srcdir/$pkgname-$pkgver"
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p1 < $i || return 1
+ done
+
+ # make sure our CFLAGS are respected
+ sed -e 's:^CFLAGS="-Wno-long-long":CFLAGS="$CFLAGS -Wno-long-long -fno-stack-protector":' \
+ -i configure.in
+
+ ./configure --prefix=/usr \
+ --without-mpicc \
+ --mandir=/usr/share/man || return 1
+
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ # we have options=!strip above so we strip the /usr/bin/* manually
+ strip "$pkgdir"/usr/bin/valgrind \
+ "$pkgdir"/usr/bin/no_op_client_for_valgrind \
+ "$pkgdir"/usr/bin/valgrind-listener \
+ "$pkgdir"/usr/bin/cg_merge
+
+ # pax causes some issues
+ # http://marc.info/?l=gentoo-hardened&m=119512627126298&w=2
+ scanelf "$pkgdir"/usr/lib/valgrind/x86-linux \
+ | awk '$1 == "ET_EXEC" {print $2}' | xargs paxctl -c -m
+
+}
+
+md5sums="b5f039dd2271aaf9ae570ab4116f87c7 valgrind-3.4.1.tar.bz2
+37bc90d0783bc0f8ba5754c8407e3dcc valgrind-3.4.0-uclibc.patch"
diff --git a/main/valgrind/valgrind-3.4.0-uclibc.patch b/main/valgrind/valgrind-3.4.0-uclibc.patch
new file mode 100644
index 00000000000..db6551996e3
--- /dev/null
+++ b/main/valgrind/valgrind-3.4.0-uclibc.patch
@@ -0,0 +1,12 @@
+--- valgrind-3.4.0/drd/drd_pthread_intercepts.c.orig Thu Jan 22 14:37:52 2009
++++ valgrind-3.4.0/drd/drd_pthread_intercepts.c Thu Jan 22 14:38:12 2009
+@@ -122,9 +122,6 @@
+ /* PTHREAD_MUTEX_TIMED_NP */
+ /* PTHREAD_MUTEX_NORMAL */
+ case PTHREAD_MUTEX_DEFAULT:
+-#if defined(HAVE_PTHREAD_MUTEX_ADAPTIVE_NP)
+- case PTHREAD_MUTEX_ADAPTIVE_NP:
+-#endif
+ return mutex_type_default_mutex;
+ }
+ return mutex_type_invalid_mutex;
diff --git a/main/vim/APKBUILD b/main/vim/APKBUILD
new file mode 100644
index 00000000000..3dee6bda28a
--- /dev/null
+++ b/main/vim/APKBUILD
@@ -0,0 +1,519 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=vim
+_srcver=7.2
+_patchver=234
+pkgver=$_srcver.$_patchver
+pkgrel=0
+pkgdesc="advanced text editor"
+url="http://www.vim.org"
+license='GPL'
+depends="ncurses-terminfo"
+makedepends="ncurses-dev"
+subpackages="$pkgname-doc"
+
+# use "abuild patchlist >> APKBUILD" to generate the list of patches
+source="ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
+ ftp://ftp.vim.org/pub/vim/extra/vim-7.2-extra.tar.gz
+ vimrc
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.001
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.002
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.003
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.004
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.005
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.006
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.007
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.008
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.009
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.010
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.011
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.012
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.013
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.014
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.015
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.016
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.017
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.018
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.019
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.020
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.021
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.022
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.023
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.024
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.025
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.026
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.027
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.028
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.029
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.030
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.031
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.032
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.033
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.034
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.035
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.036
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.037
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.038
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.039
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.040
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.041
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.042
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.043
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.044
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.045
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.046
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.047
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.048
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.049
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.050
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.051
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.052
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.053
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.054
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.055
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.056
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.057
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.058
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.059
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.060
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.061
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.062
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.063
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.064
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.065
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.066
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.067
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.068
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.069
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.070
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.071
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.072
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.073
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.074
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.075
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.076
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.077
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.078
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.079
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.080
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.081
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.082
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.083
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.084
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.085
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.086
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.087
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.088
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.089
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.090
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.091
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.092
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.093
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.094
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.095
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.096
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.097
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.098
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.099
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.100
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.101
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.102
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.103
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.104
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.105
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.106
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.107
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.108
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.109
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.110
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.111
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.112
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.113
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.114
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.115
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.116
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.117
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.118
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.119
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.120
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.121
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.122
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.123
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.124
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.125
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.126
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.127
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.128
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.129
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.130
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.131
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.132
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.133
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.134
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.135
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.136
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.137
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.138
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.139
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.140
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.141
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.142
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.143
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.144
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.145
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.146
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.147
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.148
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.149
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.150
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.151
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.152
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.153
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.154
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.155
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.156
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.157
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.158
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.159
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.160
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.161
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.162
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.163
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.164
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.165
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.166
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.167
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.168
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.169
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.170
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.171
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.172
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.173
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.174
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.175
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.176
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.177
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.178
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.179
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.180
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.181
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.182
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.183
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.184
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.185
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.186
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.187
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.188
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.189
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.190
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.191
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.192
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.193
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.194
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.195
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.196
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.197
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.198
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.199
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.200
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.201
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.202
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.203
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.204
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.205
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.206
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.207
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.208
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.209
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.210
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.211
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.212
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.213
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.214
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.215
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.216
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.217
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.218
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.219
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.220
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.221
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.222
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.223
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.224
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.225
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.226
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.227
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.228
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.229
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.230
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.231
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.232
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.233
+ ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.234
+ "
+
+# this generates the patches list
+patchlist() {
+ local i j
+ for i in $(seq 1 $_patchver); do
+ local v=$(printf "%0.3i" $i)
+ echo -e "\tftp://ftp.vim.org/pub/vim/patches/7.2/$_srcver.$v"
+ done
+}
+
+build() {
+ local i
+ cd "$srcdir/${pkgname}72"
+
+ for i in ../"$_srcver".* ; do
+ msg "Applying ${i##*/}"
+ patch -p0 < $i || return 1
+ done
+
+ # Read vimrc from /etc/vim
+ echo '#define SYS_VIMRC_FILE "/etc/vim/vimrc"' >> src/feature.h
+
+ ./configure --prefix=/usr \
+ --without-x \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir/" install
+ install -D "$srcdir"/vimrc "$pkgdir"/etc/vim/vimrc
+}
+
+md5sums="f0901284b338e448bfd79ccca0041254 vim-7.2.tar.bz2
+35e04482f07c57221c9a751aaa3b8dac vim-7.2-extra.tar.gz
+7c2dc4a956cf315e546e347bc349968c 7.2.001
+7f16f80814f1e071a689806c2056b39d 7.2.002
+0de916fdfd450a4a0d95bed44ae2c398 7.2.003
+25cc99ad42b25b16a4610e2fad9cdab4 7.2.004
+a5b7b1c7c5b75aa7d730b0b9aa491558 7.2.005
+a93a72cd40c37da91dc634dc8dddefec 7.2.006
+c2b2b63dea27ddad92668e63797406c5 7.2.007
+e65c8c2223eea5289d8cbef2e867a5de 7.2.008
+ab1566b69bd0e0c82a866f00675ffe0e 7.2.009
+d69f559bfb5436c157e8069a829ca50d 7.2.010
+05334a6bb31402bfd49d82ea6f59a57b 7.2.011
+a11dcd5552f36544a9e27978b5359935 7.2.012
+8bc70978291aadea9c82072b623c955d 7.2.013
+a87826187cb77ad2e567a40c1609eea4 7.2.014
+47a466fbfdbca616f519fc4afa0432df 7.2.015
+fd08bac73d7ffcabf53bd25a63dff893 7.2.016
+0f0284d87f6f52101802dbe1a45d54c3 7.2.017
+38d06ba325b716c1177c1012d781bada 7.2.018
+661ca021fb70c24ef4df229512cfb14b 7.2.019
+cb2c5ca0f9a9718fb635874925432dd8 7.2.020
+9073d2311ae7101c143237a45afb4efa 7.2.021
+48ccb0deec77a3bb91bf967dacb43492 7.2.022
+d77ed8aa4de30d4dbd17a7998ae8f269 7.2.023
+cf983237e5e866ef459870fee2754bac 7.2.024
+ab32defa4b2cfb509ccb34d4858b1223 7.2.025
+5e96c227c7765b1e0f03f44cb5b750f6 7.2.026
+f26b7ee0f271eacbb3652dbdf92dd860 7.2.027
+fc54a3d35bdc7b7a7660c6d2274f7b74 7.2.028
+d53630dc8f3a823f54dfba73dcd47b36 7.2.029
+208f8ed2db2665ebfc17674f78d47c6d 7.2.030
+3387583af86faa78e10be979214071f3 7.2.031
+eca017686205ec8658bf9fa8c73f7af6 7.2.032
+88c91b84ffc772fd57f86475f7ba90f1 7.2.033
+c3d6eaaa0b74df423f90afaaafa3a0de 7.2.034
+f4c35dae581d671dc271407d377f7199 7.2.035
+0ae8b6ed636fc013e2fa6bdabc182041 7.2.036
+1c6501c366cc8df205955f3e4d3ebba9 7.2.037
+ed3479ddb4ded7b74c82af5e50b0e4a6 7.2.038
+2a61f28f6f793c5a43abded6e59b6506 7.2.039
+4c493255ae227498016f30a0002ec1cc 7.2.040
+66bde35426c09d9c666e23215f9a19c9 7.2.041
+99baedef8a9c908774b7ed74deacf184 7.2.042
+87035b208c9377c28d796b1e48ab8aac 7.2.043
+b127def242996b4e7d7e870cab3e4b45 7.2.044
+5233327e4c97d310e3793b223892ea8d 7.2.045
+9ecfa0454f5a329996b273cb12369962 7.2.046
+35e16f4e7198e861a71322fee2cb7909 7.2.047
+84ef9658181f49bfbd7a61ec87dd0b8d 7.2.048
+fc9b65eef81954f6006c307ff11be925 7.2.049
+27a9700e39e266a31df702677acea52c 7.2.050
+89ce3f5b513510fb288a4a301e7494c7 7.2.051
+5992bb56b07a9b9b4e3504f1f2f2c79c 7.2.052
+3fe570c1317fee8a71ede17197358e02 7.2.053
+5b047e8e8413c4807d74a6d9716474a2 7.2.054
+c276080d95de2fafa9706f247c35ff74 7.2.055
+5b65e2654a78dcc4c15dc49dbce5418e 7.2.056
+cab5a9ddf0ab180089d84bf9ec685574 7.2.057
+80991ff846f88222e3266dab6b07e2b8 7.2.058
+89cede639caf8beed5ea071790445e26 7.2.059
+9781d833263060308a9622dd097ad378 7.2.060
+71b4bc625bc1cdd68747262d329db551 7.2.061
+9243a773d19966dbfd98b7aff3fe3ab7 7.2.062
+08155711f8db2dfce217ec5a34253a76 7.2.063
+fd692f9624ec0170800b3d9a2a9a53cb 7.2.064
+ee1a8dc311c7580608e3bd2196a7d042 7.2.065
+8d1d5f8aefabf0abcb54de5247893246 7.2.066
+fa0ccca2decdd2db64947658b04b8c99 7.2.067
+ca5ab057205023613020ca920d903028 7.2.068
+f3e6f3dd76278a9f7e396955faa4ca31 7.2.069
+805cdc76da46e73ae908038e09efae16 7.2.070
+9224b5e9c85fa4d47d418c248aff542e 7.2.071
+ab9250d36651dde9267d1241cac9fb74 7.2.072
+0d77ee653eabe4b7fdb640d768d7c1be 7.2.073
+5b0a423e9f3ca07e5c62d4f0f5803a5c 7.2.074
+d7eccf57f8fc04cf0385f85eff3d989a 7.2.075
+99750c988d0c48f56cb12a04b78aebc2 7.2.076
+1967f5e7fa4cec07bd67cc47925ec3c8 7.2.077
+7b285d2ba24fdd2390b4aaba08fcf5f6 7.2.078
+a3385578174d3867f17ab287276db49b 7.2.079
+ea45aa4d1a74989d361b2a29c1e9ff9b 7.2.080
+3bdf4ec7db7976876a827f2dfa269e89 7.2.081
+590c9aa51fcb808ece4b6b4bfaaaaf30 7.2.082
+2a10abc536f7a69ff3ef353b55b6cb65 7.2.083
+78defaaa03e61955f6624b796efb8655 7.2.084
+869116b3e92e944d40a3e03f9a99816f 7.2.085
+5af26f073ebeba60af90525d68a61725 7.2.086
+639d7a80864afe68132725e377f52f19 7.2.087
+44b152484534fa23c4ff531316a0e518 7.2.088
+990e6a23c4061df0dcc0ab84528a2e1a 7.2.089
+8985dcfe7df6b439e88554e22cf34919 7.2.090
+137faec139470453ca446c015c226e47 7.2.091
+e15782bf5892ad787d149491bfe013e7 7.2.092
+2198caf9e5f422eacde337e9c27677ab 7.2.093
+49ab5014904d459e54a667e1433b4bee 7.2.094
+ba21ee323426561e75ebff23090e4bdb 7.2.095
+7ffef4a30cdcd6d8426e44d3a25df991 7.2.096
+c7264031ad24af960d717189b344e244 7.2.097
+dc7b06bb5c5b11a3d487614287d99a6b 7.2.098
+656c12368934868f35747f3955366142 7.2.099
+15dacd715d6f8c655265bbf77ebaddd4 7.2.100
+65e59923311b136306284319521d70d7 7.2.101
+42e2274c6a3152279720d8623f7916ad 7.2.102
+654ba716e77d092c1c314fed18c7486d 7.2.103
+b839c2c957eb3bb7511ace0b61d5d5fe 7.2.104
+7f37ad0b1573be8bc39a817a21422a4e 7.2.105
+4801df8c2833a683cd1b2a5870565e41 7.2.106
+e6801b619d40efe81428399e26e0486f 7.2.107
+76f17428d216ec6b29036e22397c2765 7.2.108
+db97daa4f1e56440a988e7f5272997c7 7.2.109
+b8752c88429f869dec05232db89018e2 7.2.110
+e8cdc1e862b60215c12265e44b38239d 7.2.111
+e933dd778c6f8687cf1f9f3e550e6cc0 7.2.112
+861729d9d4dc422e45c22bd8e006fc32 7.2.113
+5da3a29b3184af1780a82499343e7587 7.2.114
+b35c7b1cfa2a5f7b45829cd09ac27b7a 7.2.115
+1355cc34fbc7be7eb48fa777e8f49dfb 7.2.116
+8b9c839ec7448691b0a88475f0d0d4f9 7.2.117
+74d97a563ec1b1f1606705097396c391 7.2.118
+2ddd84423b902a2b3594c64c567be0b4 7.2.119
+5394e442f011d47b6d69a7b03984cdf4 7.2.120
+6bdb5e63ca3d79d3dcb7127e14ae3949 7.2.121
+36554c0103cafc8759f3e71ccd56c56f 7.2.122
+841c74d1f3cb8380fa5713d5b9ca2c98 7.2.123
+2489ebcb72280dd50b8756e4ab7d36ed 7.2.124
+10b15d637133b73d825650363d863b58 7.2.125
+b31534667bb741e21479b1e3757c9e21 7.2.126
+71e87e78bea69d8876ff7f6d824c8986 7.2.127
+21da01d371757282bfd402ddd91005ba 7.2.128
+e890b630efa3847c8cdee2f197145b6c 7.2.129
+d3fe3bf37d5c0940f3e751f41d92e817 7.2.130
+3c2aaa22914d06a65bf0f212e43c3ace 7.2.131
+379aa718df5dbcde8215fc4d94062d9f 7.2.132
+6d51f9deb4c2604692f532c118b73ef8 7.2.133
+4acae77b2a217e1cb47040c08e28180d 7.2.134
+4d30bf2c9d2973f5dd1c12468123dc41 7.2.135
+f2ae8cc595933938ee608e040d1256a5 7.2.136
+c613c1e0fac319f05ffe1fa7e27d6600 7.2.137
+e7d02c3dea47fa579366bb1cd025ce5e 7.2.138
+04f7131164b3f46d6365a8faea0e32c6 7.2.139
+e1c0e4fbd985f5a2e5a24a4cfab1112c 7.2.140
+e5a9c7ef44a38057c0c5c1191d9cdf77 7.2.141
+f08f7f966749c2ef20ff87dfeb9bef62 7.2.142
+6b132dad3ad947662d1c370193a14218 7.2.143
+4e2a1d1cb12198a783759f88e6c64fc4 7.2.144
+38877e2ac720e45e5d62cd1089167db3 7.2.145
+cb97aca73a1f4fdd2fac894bba7e43ae 7.2.146
+4219afedebf0172118f2d078d9012995 7.2.147
+49ca89a47315f512c7ee06f5b2617a90 7.2.148
+9197a669e4ee024c1a9218e861e21c7e 7.2.149
+cbdf7ce960ad4646a8884e51bc7e037e 7.2.150
+56b24ce6e78e71c64d05fda51748b01c 7.2.151
+7c088583f063cd09d26f7291d9f5817b 7.2.152
+e966483b6755f4e7b2cd92708a8ff656 7.2.153
+27bcb5f1d5932ee7eaae40ba0a4eb968 7.2.154
+611ab5b97cd9d87a1be0a84e3006b17a 7.2.155
+27fb40dbdb85052a598be88f205484c6 7.2.156
+93a85a3606193b8875f0eba05dba3be3 7.2.157
+808ba7888bdfdf559366dfdf1446dab5 7.2.158
+08bd6d6db2e029beab84b32bf36494e0 7.2.159
+c07df493053267849115b579928a4dae 7.2.160
+e44297c9ed5928e55ca43b4e2b3509ce 7.2.161
+0d4768bd2395f3ebf3ebd7fa4979288c 7.2.162
+032f90bcee8f36ad7b77a17bb76719f0 7.2.163
+21341ed82eb080e590d15dd6368e8d78 7.2.164
+51de241d7d03200a7b3490f40256c633 7.2.165
+9c645166c92865d644fd232760b56494 7.2.166
+a29266c1573ff106366ebdbd460b17ce 7.2.167
+09105d79266562b6afe0179c07149738 7.2.168
+36d18f0e42f0c24722116cb823b52c8a 7.2.169
+a00979f910f29d5062faf15e8670735b 7.2.170
+439a415dab8a77790c7da1526da083f9 7.2.171
+3defcc24541cd3d62fda6cfb4af6ba4b 7.2.172
+5f16d8af9b11f44c8e104abc942152c2 7.2.173
+4949fe9f14ac4f7b2717ddb05968285c 7.2.174
+7462cd9ba69a7eb674aa8e5653fdad63 7.2.175
+4b5c77673b5d62f1a94e4d605e92d81e 7.2.176
+cde1647ab09a432c134d6fbae5ca15dc 7.2.177
+5a126dd404945088b61aaf9d8c2effaa 7.2.178
+a15fe587377fac500d0fae2b1c3adbbf 7.2.179
+d4db5a69da98dbda41429d66e339e515 7.2.180
+8b9dee3c4aeeb563cbff6f3cf0357675 7.2.181
+d5d50f1da385bee588348aaaa5bb2dd7 7.2.182
+77e46725488937910d1cf051760ad11d 7.2.183
+3bdbab52e0ac635962ce9983ef1d9f01 7.2.184
+fa88ae980d6e68f9aa9f9b257f1f3e71 7.2.185
+2262a6034d4cf01859a1d36982f38505 7.2.186
+c98b89c2594d7127574d0bd9838f241a 7.2.187
+8efff5f82388c43183739c280249b643 7.2.188
+bab560f5a4b1809c2859ab632f037135 7.2.189
+63098e6cdb253d83c30f42d3d4469900 7.2.190
+87a02a6db9029357d7e248bcf4923330 7.2.191
+88102a28fb2139fe14a66b2970958166 7.2.192
+66a202b39e36ac062db1432896d8d988 7.2.193
+3ba1ab13de695c1422e0cda65c03503d 7.2.194
+a42b79c5328c30b0951ce67da505a3f4 7.2.195
+f1ece679735785c46b58ed4d791b3880 7.2.196
+352908f71b12a7a30aafd985c338d247 7.2.197
+2a4764a5df5c1d18e4c7fee81074f55c 7.2.198
+61a30d8c51533f08a94ba23025a12f11 7.2.199
+1a21534f09d529a9096c5e9b978187e9 7.2.200
+61e01d2aef1d5c1c3b40d5e927bd83c9 7.2.201
+30df1365ef27c34558d4322cb71c5d83 7.2.202
+24ae52da6519c8f8fbd08676c64eac75 7.2.203
+e75f99a06eb7a03a5cf854505b1d795d 7.2.204
+3e2da4100f83cf2d308545d0c822a196 7.2.205
+4895874100f932e15a8c661fb40a19b1 7.2.206
+e3345b11c12eedd8871b2eeb811c9234 7.2.207
+a7f6deca2df02cc4d23274f3104b94d1 7.2.208
+62e83a3e30fe5b6f96ba276a342faf1c 7.2.209
+296e40f03bf6243583541ca440af802c 7.2.210
+3714237966fa05c9cae8fd4518a42ac4 7.2.211
+3537ef914ffbe5acbdede8d3581ecf41 7.2.212
+9f4b0f8a1dc9c3720eca6028c987fa01 7.2.213
+fb46e419802a06e26d8531628f50aca9 7.2.214
+388c0884878256fca9db1fb1fe9df98e 7.2.215
+cd568cf0b9b751b9ff1151fa6f5f0ae0 7.2.216
+288d5ee4b5ff25caa79446a95cb3ee98 7.2.217
+d86a84a239c25dda5101aac8c365154c 7.2.218
+9c0f11d3c52d1756381231e1c0a6156d 7.2.219
+bfed5d4e0bcae8eb7a7e0806d4367e0a 7.2.220
+3b169a3f976cf1808b12230dd24c0ff5 7.2.221
+a3f9c7d976ad8a49250d0ff3130b6390 7.2.222
+3ca61604214ef919b7bfe4b24eb69518 7.2.223
+5c550bd6e2111c10407b7aca009b1242 7.2.224
+b3ae8fa424e01a0fc67c9ed7393b422e 7.2.225
+6057e1247bd3b1538eef15c532caf881 7.2.226
+932e2a5394788124cbda950bfff327ff 7.2.227
+b97e5d33fa4fb8a1ea1308558bb33d41 7.2.228
+2107c7d981ca14d8e795ae744a903106 7.2.229
+7e98ae111e74676ef88c5e3edce785ed 7.2.230
+2abbb80186d28da703eb329d4247dd41 7.2.231
+5e5cfa4e5ee34cbbdd01c27ece1b7398 7.2.232
+9fa12db95776e9174ca7c95172a48838 7.2.233
+a46776a6914ec2972ada91b33b0cfb39 7.2.234
+97aecde2ab504e543a96bec84b3b5638 vimrc"
diff --git a/main/vim/vimrc b/main/vim/vimrc
new file mode 100644
index 00000000000..e3017342455
--- /dev/null
+++ b/main/vim/vimrc
@@ -0,0 +1,15 @@
+set nocompatible " Use Vim defaults (much better!)
+set bs=2 " Allow backspacing over everything in insert mode
+set ai " Always set auto-indenting on
+set history=50 " keep 50 lines of command history
+set ruler " Show the cursor position all the time
+
+" Don't use Ex mode, use Q for formatting
+map Q gq
+
+" When doing tab completion, give the following files lower priority.
+set suffixes+=.info,.aux,.log,.dvi,.bbl,.out,.o,.lo
+
+set nomodeline
+syntax on
+autocmd BufRead APKBUILD set filetype=sh
diff --git a/main/vsftpd/APKBUILD b/main/vsftpd/APKBUILD
new file mode 100644
index 00000000000..fef929cad66
--- /dev/null
+++ b/main/vsftpd/APKBUILD
@@ -0,0 +1,36 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=vsftpd
+pkgver=2.1.0
+pkgrel=1
+pkgdesc="Very secure ftpd"
+url="http://vsftpd.beasts.org"
+license="GPL"
+depends="openssl"
+makedepends="openssl-dev !libcap-dev"
+subpackages="$pkgname-doc"
+source="ftp://vsftpd.beasts.org/users/cevans/vsftpd-${pkgver}.tar.gz
+vsftpd-enable-ssl.patch
+vsftpd.initd
+vsftpd.confd"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ #Enable SSL support
+ patch -p0 -i "$srcdir"/vsftpd-enable-ssl.patch || return 1
+
+ make || return 1
+
+ install -m755 -D vsftpd "$pkgdir"/usr/sbin/vsftpd
+ install -m644 -D vsftpd.8 "$pkgdir"/usr/share/man/man8/vsftpd.8
+ install -m644 -D vsftpd.conf.5 "$pkgdir"/usr/share/man/man5/vsftpd.conf.5
+ install -m644 -D vsftpd.conf "$pkgdir"/etc/vsftpd.conf
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ mkdir -p "$pkgdir"/usr/share/empty
+}
+
+md5sums="7890b54e7ffa6106ffbdfda53f47fa41 vsftpd-2.1.0.tar.gz
+f3cbaf364cd3c46a2a03b00de9d7e184 vsftpd-enable-ssl.patch
+7edf5990c9f5dda983e918c55c92078e vsftpd.initd
+431dfe7403323e247a88b97beade5d78 vsftpd.confd"
diff --git a/main/vsftpd/vsftpd-enable-ssl.patch b/main/vsftpd/vsftpd-enable-ssl.patch
new file mode 100644
index 00000000000..22161907cdf
--- /dev/null
+++ b/main/vsftpd/vsftpd-enable-ssl.patch
@@ -0,0 +1,11 @@
+--- builddefs.h.orig Sun Mar 1 15:18:09 2009
++++ builddefs.h Sun Mar 1 15:15:24 2009
+@@ -3,7 +3,7 @@
+
+ #undef VSF_BUILD_TCPWRAPPERS
+ #define VSF_BUILD_PAM
+-#undef VSF_BUILD_SSL
++#define VSF_BUILD_SSL
+
+ #endif /* VSF_BUILDDEFS_H */
+
diff --git a/main/vsftpd/vsftpd.confd b/main/vsftpd/vsftpd.confd
new file mode 100644
index 00000000000..0abb80c6e89
--- /dev/null
+++ b/main/vsftpd/vsftpd.confd
@@ -0,0 +1,9 @@
+# Sample conf.d file for alpine linux
+
+#
+# Specify daemon $OPTS here.
+#
+
+OPTS=""
+USER="nobody"
+GROUP="nobody"
diff --git a/main/vsftpd/vsftpd.initd b/main/vsftpd/vsftpd.initd
new file mode 100644
index 00000000000..9e8b124b00e
--- /dev/null
+++ b/main/vsftpd/vsftpd.initd
@@ -0,0 +1,25 @@
+#!/sbin/runscript
+
+NAME=vsftpd
+DAEMON=/usr/sbin/$NAME
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet --background \
+ --make-pidfile --pidfile /var/run/${NAME}.pid \
+ --exec ${DAEMON} -- ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet \
+ --exec ${DAEMON} \
+ --pidfile /var/run/${NAME}.pid \
+ eend $?
+}
+
diff --git a/main/wget/APKBUILD b/main/wget/APKBUILD
new file mode 100644
index 00000000000..b6581fa48ab
--- /dev/null
+++ b/main/wget/APKBUILD
@@ -0,0 +1,29 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Carlo Landmeter <clandmeter at gmail>
+pkgname=wget
+pkgver=1.11.4
+pkgrel=1
+pkgdesc="A network utility to retrieve files from the Web"
+url="http://www.gnu.org/software/wget/wget.html"
+license="GPL3"
+depends="openssl"
+makedepends="openssl-dev"
+subpackages="$pkgname-doc"
+install="wget.post-deinstall"
+source="ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ $install"
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make || return 1
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="69e8a7296c0e12c53bd9ffd786462e87 wget-1.11.4.tar.gz
+b84506d253e04db3c5af9016fead45a3 wget.post-deinstall"
diff --git a/main/wget/wget.post-deinstall b/main/wget/wget.post-deinstall
new file mode 100644
index 00000000000..99b57c46353
--- /dev/null
+++ b/main/wget/wget.post-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+busybox --install -s
diff --git a/main/xvidcore/APKBUILD b/main/xvidcore/APKBUILD
new file mode 100644
index 00000000000..64858bf8df1
--- /dev/null
+++ b/main/xvidcore/APKBUILD
@@ -0,0 +1,25 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=xvidcore
+pkgver=1.2.1
+pkgrel=1
+pkgdesc="XviD is an open source MPEG-4 video codec"
+url="http://www.xvid.org/"
+license="GPL"
+subpackages="$pkgname-dev"
+depends=
+makedepends="nasm"
+source="http://downloads.xvid.org/downloads/$pkgname-$pkgver.tar.bz2"
+
+build ()
+{
+ cd "$srcdir"/$pkgname/build/generic
+ ./configure --prefix=/usr \
+ --disable-assembly
+ make || return 1
+ make DESTDIR="$pkgdir" install
+ cd "$pkgdir"/usr/lib
+ mylib=$(basename libxvidcore.so.*)
+ ln -sf ${mylib} libxvidcore.so.4
+ ln -sf ${mylib} libxvidcore.so
+}
+md5sums="8c4470ae8e5a104abedb39f6c70e2a40 xvidcore-1.2.1.tar.bz2"
diff --git a/main/zip/10-zip-3.0-build.patch b/main/zip/10-zip-3.0-build.patch
new file mode 100644
index 00000000000..5ddad23b95a
--- /dev/null
+++ b/main/zip/10-zip-3.0-build.patch
@@ -0,0 +1,36 @@
+respect build environment settings
+
+--- unix/configure Wed Jan 28 22:22:13 2009
++++ unix/configure Wed Jan 28 22:23:54 2009
+@@ -18,7 +18,7 @@
+
+ CC=${1-cc}
+ CFLAGS=${2-"-I. -DUNIX"}
+-LFLAGS1=''
++LFLAGS1="${LDFLAGS}"
+ LFLAGS2=''
+ LN="ln -s"
+
+@@ -118,7 +118,7 @@
+ fi
+
+ # optimization flags
+-if test -n "${CFLAGS_OPT}"; then
++if false; then
+ CFLAGS="${CFLAGS} ${CFLAGS_OPT}"
+ CFLAGS_BZ="${CFLAGS_BZ} ${CFLAGS_OPT}"
+ fi
+@@ -220,13 +220,6 @@
+ echo Check for the C preprocessor
+ # on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
+ CPP="${CC} -E"
+-# solaris as(1) needs -P, maybe others as well ?
+-[ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
+-[ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
+-[ -f /lib/cpp ] && CPP=/lib/cpp
+-[ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
+-[ -f /xenix ] && CPP="${CC} -E"
+-[ -f /lynx.os ] && CPP="${CC} -E"
+
+ echo "#include <stdio.h>" > conftest.c
+ $CPP conftest.c >/dev/null 2>/dev/null || CPP="${CC} -E"
diff --git a/main/zip/20-zip-3.0-exec-stack.patch b/main/zip/20-zip-3.0-exec-stack.patch
new file mode 100644
index 00000000000..d85fb117b08
--- /dev/null
+++ b/main/zip/20-zip-3.0-exec-stack.patch
@@ -0,0 +1,22 @@
+add proper GNU stack markings so we dont get the default: executable
+
+--- crc_i386.S Wed Jan 28 22:22:13 2009
++++ crc_i386.S Wed Jan 28 22:27:04 2009
+@@ -302,3 +302,7 @@
+ #endif /* i386 || _i386 || _I386 || __i386 */
+
+ #endif /* !USE_ZLIB && !CRC_TABLE_ONLY */
++
++#if defined __ELF__ && defined __linux__
++.section .note.GNU-stack,"",@progbits
++#endif
+--- match.S Wed Jan 28 22:22:13 2009
++++ match.S Wed Jan 28 22:27:04 2009
+@@ -405,3 +405,7 @@
+ #endif /* i386 || _I386 || _i386 || __i386 */
+
+ #endif /* !USE_ZLIB */
++
++#if defined __ELF__ && defined __linux__
++.section .note.GNU-stack,"",@progbits
++#endif
diff --git a/main/zip/30-zip-3.0-pic.patch b/main/zip/30-zip-3.0-pic.patch
new file mode 100644
index 00000000000..14a8821b045
--- /dev/null
+++ b/main/zip/30-zip-3.0-pic.patch
@@ -0,0 +1,15 @@
+if our toolchain generates PIC by default, then do not use the hand written
+assembly files as none of it is PIC friendly.
+
+--- unix/configure Wed Jan 28 22:23:54 2009
++++ unix/configure Wed Jan 28 22:29:51 2009
+@@ -228,6 +228,9 @@
+ echo Check if we can use asm code
+ OBJA=""
+ OCRCU8=""
++piclib="$(echo | $CPP -dM $CFLAGS - | grep -i __pic__)"
++echo "Checking if compiler wants to create pic code"
++[ "$piclib" == "" ] && \
+ if eval "$CPP match.S > _match.s 2>/dev/null"; then
+ if test ! -s _match.s || grep error < _match.s > /dev/null; then
+ :
diff --git a/main/zip/APKBUILD b/main/zip/APKBUILD
new file mode 100644
index 00000000000..4998c35b762
--- /dev/null
+++ b/main/zip/APKBUILD
@@ -0,0 +1,30 @@
+# Maintainer: Carlo Landmeter <clandmeter at gmail.com>
+pkgname=zip
+pkgver=3.0
+pkgrel=0
+pkgdesc="Creates PKZIP-compatible .zip files"
+url="http://www.info-zip.org/pub/infozip/Zip.html"
+license="AS IS"
+depends="uclibc"
+makedepends=""
+source="ftp://ftp.info-${pkgname}.org/pub/info${pkgname}/src/${pkgname}30.zip
+10-zip-3.0-build.patch
+20-zip-3.0-exec-stack.patch
+30-zip-3.0-pic.patch"
+subpackages="$pkgname-doc"
+
+build ()
+{
+ cd "${srcdir}/${pkgname}30"
+ for i in ../*.patch; do
+ msg "Applying $i"
+ patch -p0 < $i || return 1
+ done
+ make -f unix/Makefile LOCAL_ZIP="${CFLAGS} ${CPPFLAGS}" prefix=/usr generic || return 1
+ make -f unix/Makefile prefix=${pkgdir}/usr MANDIR=${pkgdir}/usr/share/man install
+}
+
+md5sums="e88492c8abd68fa9cfba72bc08757dba zip30.zip
+c86c527b6ad487aef02954bb1607ff07 10-zip-3.0-build.patch
+f6490facf87e501b5d0c7095949515a7 20-zip-3.0-exec-stack.patch
+f0b90de421d370f1b40b0f681d3829d8 30-zip-3.0-pic.patch"
diff --git a/main/zonenotify/APKBUILD b/main/zonenotify/APKBUILD
new file mode 100644
index 00000000000..9709eba4ee3
--- /dev/null
+++ b/main/zonenotify/APKBUILD
@@ -0,0 +1,18 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=zonenotify
+pkgver=0.1
+pkgrel=0
+pkgdesc="Utility to send NS_NOTIFY packets to slave DNS servers"
+arch=""
+url="http://www.morettoni.net/zonenotify.en.html"
+license='BSD'
+depends="uclibc"
+source="http://www.morettoni.net/bsd/$pkgname-$pkgver.tar.gz"
+
+build() {
+ cd "$srcdir/$pkgname"
+ make || return 1
+ install -D zonenotify "$pkgdir"/usr/bin/zonenotify
+}
+
+md5sums="1cb15b505eaa22440c7a26ea34af2514 zonenotify-0.1.tar.gz"