[Pkg-privacy-commits] [onioncat] 244/340: Imported Upstream version 0.2.2+svn552
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository onioncat.
commit 21480d9392ca83418abb8c5450e885daa64ea14d
Author: intrigeri <intrigeri at boum.org>
Date: Wed Jun 8 02:05:58 2011 +0200
Imported Upstream version 0.2.2+svn552
---
debian/README | 6 -
debian/README.Debian | 6 -
debian/changelog | 20 ----
debian/compat | 1 -
debian/control | 25 -----
debian/copyright | 41 -------
debian/dirs | 1 -
debian/docs | 5 -
debian/init.d | 287 ------------------------------------------------
debian/manpage.1 | 1 -
debian/onioncat.default | 17 ---
debian/rules | 105 ------------------
freebsd/Makefile.ports | 39 -------
freebsd/README | 3 -
freebsd/distinfo | 3 -
freebsd/pkg-descr | 8 --
freebsd/pkg-plist | 1 -
src/ocatfdbuf.c | 215 ------------------------------------
src/ocatfdbuf.h | 43 --------
19 files changed, 827 deletions(-)
diff --git a/debian/README b/debian/README
deleted file mode 100644
index 4cd1ba6..0000000
--- a/debian/README
+++ /dev/null
@@ -1,6 +0,0 @@
-The Debian Package onioncat
-----------------------------
-
-Comments regarding the Package
-
- -- Ferdinand Haselbacher <fhasex20 at cypherpunk.at> Thu, 19 Feb 2009 13:27:29 +0100
diff --git a/debian/README.Debian b/debian/README.Debian
deleted file mode 100644
index 44948f5..0000000
--- a/debian/README.Debian
+++ /dev/null
@@ -1,6 +0,0 @@
-onioncat for Debian
--------------------
-
- There are some issues with tun/tap inside a XEN User Domain (possibly libc6-xen related).
-
- -- Ferdinand Haselbacher <fhasex20 at cypherpunk.at> Thu, 19 Feb 2009 13:27:29 +0100
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index f6e4b03..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,20 +0,0 @@
-onioncat (0.2.0.r514) jaunty; urgency=low
-
- * Upstream svn build debian unstable
-
- -- Bernhard Fischer <rahra at cypherpunk.at> Thu, 09 Sep 2009 14:08:00 +0100
-onioncat (0.12.493) jaunty; urgency=low
-
- * Upstream svn build debian unstable
-
- -- Ferdinand Haselbacher <fhasex20 at cypherpunk.at> Thu, 19 Mar 2009 13:27:29 +0100
-onioncat (0.436) hardy; urgency=low
-
- * Upstream svn build
-
- -- Ferdinand Haselbacher <fhasex20 at cypherpunk.at> Thu, 19 Feb 2009 13:27:29 +0100
-onioncat (0.435) hardy; urgency=low
-
- * Initial Debian Package Release.
-
- -- Ferdinand Haselbacher <fhasex20 at cypherpunk.at> Thu, 19 Feb 2009 13:27:29 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7f8f011..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 38bf262..0000000
--- a/debian/control
+++ /dev/null
@@ -1,25 +0,0 @@
-Source: onioncat
-Section: comm
-Priority: optional
-Maintainer: Ferdinand Haselbacher <fhasex20 at cypherpunk.at>
-Build-Depends: debhelper (>= 7), autotools-dev
-Standards-Version: 3.8.0
-Homepage: http://www.cypherpunk.at/onioncat
-
-Package: onioncat
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, tor
-Description: An IP-Transparent Tor Hidden Service Connector
- OnionCat creates a transparent IP layer on top of Tor's hidden services. It
- transmits any kind of IP-based data transparently through the Tor network on a
- location hidden basis. You can think of it as a point-to-multipoint VPN between
- hidden services.
- OnionCat is a stand-alone application which runs in userland and is a connector
- between Tor and the local OS. Any protocol which is based on IP can be
- transmitted. Of course, UDP and TCP (and probably ICMP) are the most important
- ones but all other protocols can also be forwarded through it. OnionCat is
- based on IPv6 but the since version 0.1.9 also IPv4 packets are forwarded. In
- any case the local OS must support IPv6. See OnionCat and IPv4 for
- configuration of IPv4 transport. OnionCat now also supports TAP devices for
- bridging virtual machines and it supports IPv6 routing.
-
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 30bc4f6..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,41 +0,0 @@
-This package was debianized by:
-
- Ferdinand Haselbacher <fhasex20 at cypherpunk.at> on Thu, 19 Feb 2009 13:27:29 +0100
-
-It was downloaded from:
-
- <http://www.cypherpunk.at/onioncat>
-
-Upstream Author:
-
- <Bernhard R. Fischer>
-
-Copyright:
-
- <Copyright (C) 2008 Bernhard R. Fischer>
-
-License:
-
- This package is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 3 as
- published by the Free Software Foundation.
-
- This package 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 package; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-On Debian systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
-
-The Debian packaging is:
-
- Copyright C) 2009, Ferdinand Haselbacher <fhasex20 at cypherpunk.at>
-
-and is licensed under the GPL, see above.
-
-
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644
index e772481..0000000
--- a/debian/dirs
+++ /dev/null
@@ -1 +0,0 @@
-usr/bin
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index e6b9e0b..0000000
--- a/debian/docs
+++ /dev/null
@@ -1,5 +0,0 @@
-glob_id.txt
-NEWS
-README
-TODO
-hosts.onioncat
diff --git a/debian/init.d b/debian/init.d
deleted file mode 100644
index dd382e3..0000000
--- a/debian/init.d
+++ /dev/null
@@ -1,287 +0,0 @@
-#!/bin/bash
-### BEGIN INIT INFO
-# Provides: onioncat
-# Required-Start: $network $local_fs
-# Required-Stop:
-# Should-Start: $named
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: <OnionCat An IP-Transparent Tor Hidden Service Connector>
-# Description: OnionCat creates a transparent IP layer on top of Tor's Hidden Service
-#
-#
-### END INIT INFO
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-
-DAEMON=/usr/bin/ocat
-NAME=ocat
-NAMEL=onioncat
-DESC="OnionCat Hidden Service Connector"
-LOGDIR=/var/log/tor
-
-PIDFILE=/var/run/$NAME.pid
-
-test -x $DAEMON || exit 0
-
-. /lib/lsb/init-functions
-
-# Default options, these can be overriden by the information
-# at /etc/default/$NAME
-DAEMON_OPTS="" # Additional options given to the server
-
-DIETIME=10 # Time to wait for the server to die, in seconds
- # If this value is set too low you might not
- # let some servers to die gracefully and
- # 'restart' will not work
-
-STARTTIME=1 # Time to wait for the server to start, in seconds
- # If this value is set each time the server is
- # started (on start or restart) the script will
- # stall to try to determine if it is running
- # If it is not set and the server takes time
- # to setup a pid file the log message might
- # be a false positive (says it did not start
- # when it actually did)
-
-LOGFILE=$LOGDIR/$NAMEL.log
-DAEMONUSER="debian-tor" # Users to run the daemons as. If this value
- # is set start-stop-daemon will chuid the server
-
-# Defaults - don't touch, edit /etc/default/onioncat
-ENABLED=0
-
-
-
-# Include defaults if available
-if [ -f /etc/default/$NAMEL ] ; then
- . /etc/default/$NAMEL
-fi
-
-
-
-
-if [ "$ENABLED" = "0" ]; then
- echo "$DESC: disabled, see /etc/default/onioncat"
- exit 0
-fi
-
-
-
-# Use this if you want the user to explicitly set 'RUN' in
-# /etc/default/
-#if [ "x$RUN" != "xyes" ] ; then
-# log_failure_msg "$NAME disabled, please adjust the configuration to your needs "
-# log_failure_msg "and then set RUN to 'yes' in /etc/default/$NAME to enable it."
-# exit 1
-#fi
-
-# Check that the user exists (if we set a user)
-# Does the user exist?
-if [ -n "$DAEMONUSER" ] ; then
- if getent passwd | grep -q "^$DAEMONUSER:"; then
- # Obtain the uid and gid
- DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
- DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
- else
- log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
- exit 1
- fi
-fi
-
-
-set -e
-
-running_pid() {
-# Check if a given process pid's cmdline matches a given name
- pid=$1
- name=$2
- [ -z "$pid" ] && return 1
- [ ! -d /proc/$pid ] && return 1
- cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
- # Is this the expected server
- [ "$cmd" != "$name" ] && return 1
- return 0
-}
-
-running() {
-# Check if the process is running looking at /proc
-# (works for all users)
-
- # No pidfile, probably no daemon present
- [ ! -f "$PIDFILE" ] && return 1
- pid=`cat $PIDFILE`
- running_pid $pid $DAEMON || return 1
- return 0
-}
-
-start_server() {
-# Start the process using the wrapper
- if [ -z "$DAEMONUSER" ] ; then
- start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
- errcode=$?
- else
-# if we are using a daemonuser then change the user id
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
- --exec $DAEMON -- -u $DAEMONUSER -P $PIDFILE $DAEMON_OPTS
- errcode=$?
- fi
- return $errcode
-}
-
-stop_server() {
-# Stop the process using the wrapper
- if [ -z "$DAEMONUSER" ] ; then
- killproc -p $PIDFILE $DAEMON
- errcode=$?
- else
-# if we are using a daemonuser then look for process that match
- start-stop-daemon --stop --quiet --pidfile $PIDFILE \
- --exec $DAEMON
- errcode=$?
- fi
-
- return $errcode
-}
-
-reload_server() {
- [ ! -f "$PIDFILE" ] && return 1
- pid=pidofproc $PIDFILE # This is the daemon's pid
- # Send a SIGHUP
- kill -1 $pid
- return $?
-}
-
-force_stop() {
-# Force the process to die killing it manually
- [ ! -e "$PIDFILE" ] && return
- if running ; then
- kill -15 $pid
- # Is it really dead?
- sleep "$DIETIME"s
- if running ; then
- kill -9 $pid
- sleep "$DIETIME"s
- if running ; then
- echo "Cannot kill $NAME (pid=$pid)!"
- exit 1
- fi
- fi
- fi
- rm -f $PIDFILE
-}
-
-
-case "$1" in
- start)
- log_daemon_msg "Starting $DESC " "$NAME"
- # Check if it's running first
- if running ; then
- log_progress_msg "apparently already running"
- log_end_msg 0
- exit 0
- fi
- if start_server ; then
- # NOTE: Some servers might die some time after they start,
- # this code will detect this issue if STARTTIME is set
- # to a reasonable value
- [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
- if running ; then
- # It's ok, the server started and is running
- log_end_msg 0
- else
- # It is not running after we did start
- log_end_msg 1
- fi
- else
- # Either we could not start it
- log_end_msg 1
- fi
- ;;
- stop)
- log_daemon_msg "Stopping $DESC" "$NAME"
- if running ; then
- # Only stop the server if we see it running
- errcode=0
- stop_server || errcode=$?
- log_end_msg $errcode
- else
- # If it's not running don't do anything
- log_progress_msg "apparently not running"
- log_end_msg 0
- exit 0
- fi
- ;;
- force-stop)
- # First try to stop gracefully the program
- $0 stop
- if running; then
- # If it's still running try to kill it more forcefully
- log_daemon_msg "Stopping (force) $DESC" "$NAME"
- errcode=0
- force_stop || errcode=$?
- log_end_msg $errcode
- fi
- ;;
- restart|force-reload)
- log_daemon_msg "Restarting $DESC" "$NAME"
- errcode=0
- stop_server || errcode=$?
- # Wait some sensible amount, some server need this
- [ -n "$DIETIME" ] && sleep $DIETIME
- start_server || errcode=$?
- [ -n "$STARTTIME" ] && sleep $STARTTIME
- running || errcode=$?
- log_end_msg $errcode
- ;;
- status)
-
- log_daemon_msg "Checking status of $DESC" "$NAME"
- if running ; then
- log_progress_msg "running"
- log_end_msg 0
- else
- log_progress_msg "apparently not running"
- log_end_msg 1
- exit 1
- fi
- ;;
- # Use this if the daemon cannot reload
- reload)
- log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
- log_warning_msg "cannot re-read the config file (use restart)."
- ;;
- # And this if it cann
- #reload)
- #
- # If the daemon can reload its config files on the fly
- # for example by sending it SIGHUP, do it here.
- #
- # If the daemon responds to changes in its config file
- # directly anyway, make this a do-nothing entry.
- #
- # log_daemon_msg "Reloading $DESC configuration files" "$NAME"
- # if running ; then
- # reload_server
- # if ! running ; then
- # Process died after we tried to reload
- # log_progress_msg "died on reload"
- # log_end_msg 1
- # exit 1
- # fi
- # else
- # log_progress_msg "server is not running"
- # log_end_msg 1
- # exit 1
- # fi
- #;;
-
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/debian/manpage.1 b/debian/manpage.1
deleted file mode 120000
index da2878e..0000000
--- a/debian/manpage.1
+++ /dev/null
@@ -1 +0,0 @@
-../man/ocat.1
\ No newline at end of file
diff --git a/debian/onioncat.default b/debian/onioncat.default
deleted file mode 100644
index e7532ac..0000000
--- a/debian/onioncat.default
+++ /dev/null
@@ -1,17 +0,0 @@
-##
-#This is the default Configuration File for Onioncat.
-# You must at least set the right hostname, but before
-# you can do this TOR needs to be configured for Hidden Services
-# For Example:
-# /etc/tor/torrc
-# HiddenServiceDir /var/lib/tor/hidden_service/
-# HiddenServicePort 8060 127.0.0.1:8060
-#
-# After doing so, get your hostname from: /var/lib/tor/hidden_service/hostname
-# and append it to the DAEMON options.
-# For Example:
-# DAEMON_OPTS="gfwljfhnapq91sz4.onion"
-# and !!!! SET ENABLED=1 !!!!
-ENABLED=0
-DAEMONUSER="debian-tor"
-DAEMON_OPTS=""
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 3d16a63..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
-CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
-else
-CROSS= --build $(DEB_BUILD_GNU_TYPE)
-endif
-
-
-
-config.status: configure
- dh_testdir
- # Add here commands to configure the package.
-ifneq "$(wildcard /usr/share/misc/config.sub)" ""
- cp -f /usr/share/misc/config.sub config.sub
-endif
-ifneq "$(wildcard /usr/share/misc/config.guess)" ""
- cp -f /usr/share/misc/config.guess config.guess
-endif
- ./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
-
-
-build: build-stamp
-
-build-stamp: config.status
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
- #docbook-to-man debian/onioncat.sgml > onioncat.1
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp
-
- # Add here commands to clean up after the build process.
- [ ! -f Makefile ] || $(MAKE) distclean
- rm -f config.sub config.guess
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_prep
- dh_installdirs
-
- # Add here commands to install the package into debian/onioncat.
- $(MAKE) DESTDIR=$(CURDIR)/debian/onioncat install
-
-
-# Build architecture-independent files here.
-binary-indep: install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: install
- dh_testdir
- dh_testroot
- dh_installchangelogs ChangeLog
- dh_installdocs
- dh_installexamples
-# dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
- dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
diff --git a/freebsd/Makefile.ports b/freebsd/Makefile.ports
deleted file mode 100644
index ba34aac..0000000
--- a/freebsd/Makefile.ports
+++ /dev/null
@@ -1,39 +0,0 @@
-# ports collection makefile for: onioncat
-# Date created: 2 March 2009
-# Whom: Bernhard R. Fischer, 2048R/5C5FFD47 <bf at abenteuerland.at>
-#
-# $FreeBSD$
-#
-
-PORTNAME= onioncat
-PORTVERSION= 0.1.12.r493
-CATEGORIES= security
-MASTER_SITES= http://www.cypherpunk.at/ocat/download/
-
-MAINTAINER= bf at abenteuerland.at
-COMMENT= A world wide IPv6 VPN based on Tor
-
-RUN_DEPENDS= tor:${PORTSDIR}/security/tor
-
-GNU_CONFIGURE= yes
-OPTIONS= DEBUG "Enable debug output" Off \
- CHECK_IPSRC "disable source ip checking before forwarding" Off
-
-MAN1= ocat.1
-MANCOMPRESSED= no
-
-.include <bsd.port.pre.mk>
-
-.if defined(WITH_DEBUG)
-CONFIGURE_ARGS+= --enable-debug
-.else
-CONFIGURE_ARGS+= --disable-debug
-.endif
-
-.if defined(WITH_CHECK_IPSRC)
-CONFIGURE_ARGS+= --enable-check-ipsrc
-.else
-CONFIGURE_ARGS+= --disable-check-ipsrc
-.endif
-
-.include <bsd.port.post.mk>
diff --git a/freebsd/README b/freebsd/README
deleted file mode 100644
index 191f803..0000000
--- a/freebsd/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This directory is prepared for being included into the FreeBSD ports tree but
-it is neither finished nor submitted to the ports repository.
-
diff --git a/freebsd/distinfo b/freebsd/distinfo
deleted file mode 100644
index a7a3119..0000000
--- a/freebsd/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-MD5 (onioncat-0.1.12.r487.tar.gz) = 8ae160e783bc169b48c2f6cc3b56c4ba
-SHA256 (onioncat-0.1.12.r487.tar.gz) = ff4d44eccae44b800b43a027ddd9f4d6af90757ea0a3889b2383e3513b59ef46
-SIZE (onioncat-0.1.12.r487.tar.gz) = 176326
diff --git a/freebsd/pkg-descr b/freebsd/pkg-descr
deleted file mode 100644
index 6736293..0000000
--- a/freebsd/pkg-descr
+++ /dev/null
@@ -1,8 +0,0 @@
-An IP-Transparent Tor Hidden Service Connector
-
-OnionCat creates a transparent IP layer on top of Tor's hidden services. It
-transmits any kind of IP-based data transparently through the Tor network on a
-location hidden basis. You can think of it as a point-to-multipoint VPN between
-hidden services.
-
-WWW: http://www.cypherpunk.at/onioncat
diff --git a/freebsd/pkg-plist b/freebsd/pkg-plist
deleted file mode 100644
index 5eae200..0000000
--- a/freebsd/pkg-plist
+++ /dev/null
@@ -1 +0,0 @@
-bin/ocat
diff --git a/src/ocatfdbuf.c b/src/ocatfdbuf.c
deleted file mode 100644
index 7ca3e78..0000000
--- a/src/ocatfdbuf.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/* Copyright 2008-2009 Bernhard R. Fischer.
- *
- * This file is part of OnionCat.
- *
- * OnionCat 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 3 of the License.
- *
- * OnionCat 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 OnionCat. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "ocatfdbuf.h"
-
-
-/*! Init fdFile_t structure.
- * The function allocates memory, hence,
- * it must be freed again with fdf_free().
- * @param fd File descriptor if open file.
- * @param delim Delimiting character.
- * @return Pointer to fdFile_t structure or NULL in case of error.
- * In the latter case errno is set appropriately.
- **/
-fdFile_t* fdf_init(int fd, char delim)
-{
- fdFile_t *fdf;
- long flags;
-
- // set fd in non-blocking mode
- if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
- return NULL;
- if ((fcntl(fd, F_SETFL, flags | O_NONBLOCK)) == -1)
- return NULL;
-
- if (!(fdf = malloc(sizeof(fdFile_t))))
- return NULL;
-
- fdf->fd = fd;
- fdf->wp = fdf->rp = fdf->buf;
- fdf->len = 0;
- fdf->delim = delim;
- fdf->eof = 0;
-
- return fdf;
-}
-
-
-void fdf_free(fdFile_t *fdf)
-{
- free(fdf);
-}
-
-
-/*! Block and read data into buffer as soon as it is available.
- * @param fdf Pointer to fdFile_t structure.
- * @return Number of bytes read or -1 if an error occured. In the
- * latter case errno is set appropriately. If the number of
- * bytes is 0, then the buffer is full.
- */
-int fdf_fill(fdFile_t *fdf)
-{
- fd_set rset;
- int maxfd = -1, len;
-
- // cycle write position
- if (fdf->wp >= fdf->buf + FDBUF_SIZE)
- fdf->wp = fdf->buf;
-
- FD_ZERO(&rset);
- FD_SET(fdf->fd, &rset);
-
- if ((maxfd = select(fdf->fd + 1, &rset, NULL, NULL, NULL)) == -1)
- return -1;
-
- if (maxfd != 1)
- // Fatal error. This should never happen.
- exit(1);
-
- // test if write position is behind read position
- if (fdf->wp > fdf->rp)
- len = FDBUF_SIZE - (fdf->wp - fdf->buf);
- // test if write position is before read position
- else if (fdf->wp < fdf->rp)
- len = fdf->rp - fdf->wp;
- // if equal, test if buffer is full
- else if (fdf->len)
- return 0;
- // else the buffer is empty, read to the end
- else
- len = FDBUF_SIZE - (fdf->wp - fdf->buf);
-
- // read bytes into buffer
- if ((len = read(fdf->fd, fdf->wp, len)) == -1)
- return -1;
-
- // test and set end-of-file
- if (!len)
- fdf->eof++;
-
- // advance write position
- fdf->wp += len;
- // increase number of readable bytes
- fdf->len += len;
-
- return len;
-}
-
-
-/*! Copy bytes sequentially out of buffer. fdf_memcpy() does
- * correctly move the read position pointer and decreases
- * the byte counter.
- * @param fdf Pointer to fdFile_t structure.
- * @param buf Pointer to destination memory.
- * @param n Number of bytes to copy. fdf_memcpy() does not check
- * memory boundaries, hence, n must not be larger than
- * fdf->rp - FDBUF_SIZE and buf must be large enough to
- * receive all bytes.
- * @return Number of bytes copied. This should always be n.
- */
-int fdf_memcpy(fdFile_t *fdf, char *buf, int n)
-{
- memcpy(buf, fdf->rp, n);
- fdf->rp += n;
- fdf->len -= n;
- // set read position pointer to the beginning if it reached the end
- if (fdf->rp >= fdf->buf + FDBUF_SIZE)
- fdf->rp = fdf->buf;
- return n;
-}
-
-
-/*! This is similar to fdf_memcpy but it copies memory which is
- * wrapped around and it honors memory boundaries given by n and s.
- * @param fdf Pointer to fdFile_t structure.
- * @param buf Pointer to destination memory.
- * @param n Number of bytes available in buf.
- * @param s Number of bytes to copy.
- * @return Number of bytes copied.
- */
-int fdf_wrpcpy(fdFile_t *fdf, char *buf, int n, int s)
-{
- int len = fdf->buf + FDBUF_SIZE - fdf->rp;
-
- // check if bytes to copy do wrap
- if (s < len)
- len = s;
- // copy part starting at the read position
- if (n < len)
- return fdf_memcpy(fdf, buf, n);
- fdf_memcpy(fdf, buf, len);
- // copy part at the beginning
- buf += len;
- if (n < s)
- return fdf_memcpy(fdf, buf, n - len) + len;
- return fdf_memcpy(fdf, buf, s - len) + len;
-}
-
-
-/*! Read n of bytes from file identified by fdf into buf.
- * The bytes are copied to buf including the delimiter character
- * except buf is too small. In that case it is filled to the
- * maximum and of course does not include the delimiter.
- * @param fdf Pointer to fdFile_t structure.
- * @param buf Pointer to destination memory.
- * @param n Number of bytes available in buf.
- * @return Nuber of bytes actually read or -1 on error.
- */
-int fdf_read(fdFile_t *fdf, char *buf, int n)
-{
- int len;
- char *s = NULL;
-
- for (;;)
- {
- // determine if read buffer is wrapped
- if (fdf->rp + fdf->len <= fdf->buf + FDBUF_SIZE)
- // no
- len = fdf->len;
- else
- // yes
- len = (fdf->buf + FDBUF_SIZE) - fdf->rp;
-
- // search delimiter in unwrapped part behind read position
- if ((s = memchr(fdf->rp, fdf->delim, len)))
- return fdf_wrpcpy(fdf, buf, n, s - fdf->rp + 1);
-
- // test if wrapped part at the beginning of the buffer exists
- if ((fdf->len - len))
- // test if delimiter is found in the wrapped part at the beginning of the buffer
- if ((s = memchr(fdf->buf, fdf->delim, fdf->len - len)))
- return fdf_wrpcpy(fdf, buf, n, s - fdf->buf + len);
-
- // test if buffer is full
- if (fdf->len >= FDBUF_SIZE)
- return fdf_wrpcpy(fdf, buf, n, FDBUF_SIZE);
-
- if (fdf->eof)
- return 0;
-
- if ((len = fdf_fill(fdf)) == -1)
- return -1;
- }
-}
-
diff --git a/src/ocatfdbuf.h b/src/ocatfdbuf.h
deleted file mode 100644
index 8b1bdda..0000000
--- a/src/ocatfdbuf.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright 2008-2009 Bernhard R. Fischer.
- *
- * This file is part of OnionCat.
- *
- * OnionCat 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 3 of the License.
- *
- * OnionCat 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 OnionCat. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef OCATFDBUF_H
-#define OCATFDBUF_H
-
-
-#define FDBUF_SIZE 2048
-
-
-typedef struct fdFile
-{
- int fd; //!< file descriptor
- char buf[FDBUF_SIZE]; //!< buffer
- char *wp; //!< write position
- char *rp; //!< read position
- int len; //!< readable bytes starting at read position
- char delim; //!< delimiting character
- int eof; //!< flag is set if EOF
-} fdFile_t;
-
-
-fdFile_t* fdf_init(int, char);
-void fdf_free(fdFile_t *);
-int fdf_read(fdFile_t *, char *, int);
-
-
-#endif
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git
More information about the Pkg-privacy-commits
mailing list