[Guessnet-devel] [svn] r155 - in trunk: . src tests

Enrico Zini enrico at costa.debian.org
Fri Aug 25 17:57:31 UTC 2006


Author: enrico
Date: Fri Aug 25 17:57:07 2006
New Revision: 155

Removed:
   trunk/src/CommandlineParser.cc
   trunk/src/CommandlineParser.h
   trunk/src/Exception.cc
   trunk/src/Exception.h
   trunk/src/stringf.cc
   trunk/src/stringf.h
Modified:
   trunk/   (props changed)
   trunk/configure.ac
   trunk/src/ChildProcess.cc
   trunk/src/ChildProcess.h
   trunk/src/Exec.cc
   trunk/src/Exec.h
   trunk/src/GuessnetEnvironment.cc
   trunk/src/GuessnetParser.cc
   trunk/src/GuessnetParser.h
   trunk/src/IFace.cc
   trunk/src/IFace.h
   trunk/src/IfaceParser.cc
   trunk/src/IfaceParser.h
   trunk/src/Makefile.am
   trunk/src/NetBuffer.h
   trunk/src/NetSender.cc
   trunk/src/NetSender.h
   trunk/src/NetWatcher.cc
   trunk/src/NetWatcher.h
   trunk/src/PacketMaker.cc
   trunk/src/Parser.cc
   trunk/src/Parser.h
   trunk/src/PeerScanner.cc
   trunk/src/ProcessRunner.cc
   trunk/src/ProcessRunner.h
   trunk/src/Regexp.cc
   trunk/src/Regexp.h
   trunk/src/ScanBag.cc
   trunk/src/Thread.cc
   trunk/src/Thread.h
   trunk/src/TrafficScanner.cc
   trunk/src/guessnet-scan.cc
   trunk/src/guessnet.cc
   trunk/src/nettypes.cc
   trunk/src/nettypes.h
   trunk/tests/Makefile.am
   trunk/tests/test-iface.cc
   trunk/tests/test-netsender.cc
   trunk/tests/test-netwatcher.cc
   trunk/tests/test-processrunner.cc
   trunk/tests/test-scanbag.cc
Log:
 r402 at viaza:  enrico | 2006-08-25 18:54:06 +0100
 Ported to wibble


Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Fri Aug 25 17:57:07 2006
@@ -30,6 +30,8 @@
 AM_PROG_LEX
 AC_PROG_YACC
 
+LIBWIBBLE_DEFS
+
 dnl Check for libnet
 
 #AC_CHECK_HEADER(libnet.h, AC_DEFINE(HAVE_LIBNET_H, 1, libnet.h has been found),

Modified: trunk/src/ChildProcess.cc
==============================================================================
--- trunk/src/ChildProcess.cc	(original)
+++ trunk/src/ChildProcess.cc	Fri Aug 25 17:57:07 2006
@@ -35,26 +35,27 @@
 #include <grp.h>			// getgr*, initgroups
 #include <errno.h>
 
+#include <sstream>
+
 #undef LOGTAG
 #define LOGTAG "ChildProcess"
 
 using namespace std;
-using namespace stringf;
 
-void Process::detachFromTTY() throw (SystemException)
+void Process::detachFromTTY() throw (wibble::exception::System)
 {
 	int devnull = open("/dev/null", O_RDWR);
-	if (devnull == -1) throw FileException(errno, "opening /dev/null for read and write access");
-	if (dup2(devnull, 0) == -1) throw SystemException(errno, "redirecting stdin to /dev/null");
-	if (dup2(devnull, 1) == -1) throw SystemException(errno, "redirecting stdout to /dev/null");
-	if (setsid() == -1) throw SystemException(errno, "trying to become session leader");
-	if (dup2(devnull, 2) == -1) throw SystemException(errno, "redirecting stderr to /dev/null");
+	if (devnull == -1) throw wibble::exception::File("/dev/null", "opening for read and write access");
+	if (dup2(devnull, 0) == -1) throw wibble::exception::System("redirecting stdin to /dev/null");
+	if (dup2(devnull, 1) == -1) throw wibble::exception::System("redirecting stdout to /dev/null");
+	if (setsid() == -1) throw wibble::exception::System("trying to become session leader");
+	if (dup2(devnull, 2) == -1) throw wibble::exception::System("redirecting stderr to /dev/null");
 	close(devnull);
 }
 
 string Process::formatStatus(int status) throw ()
 {
-	string b_status;
+	stringstream b_status;
 
 	bool exited_normally = WIFEXITED(status);
 	int exit_code = exited_normally ? WEXITSTATUS(status) : -1;
@@ -64,29 +65,28 @@
 
 	if (exited_normally)
 		if (exit_code == 0)
-			b_status += "terminated successfully";
+			b_status << "terminated successfully";
 		else
-			addf(b_status, "exited with code %d", exit_code);
+			b_status << "exited with code " << exit_code;
 	else
 	{
-		b_status += "was interrupted";
-		addf(b_status, ", killed by signal %d", signal);
-		if (dumped_core) b_status += " (core dumped)";
+		b_status << "was interrupted, killed by signal " << signal;
+		if (dumped_core) b_status << " (core dumped)";
 	}
 
-	return b_status;
+	return b_status.str();
 }
 
-void Process::chdir(const string& dir) throw (SystemException)
+void Process::chdir(const string& dir) throw (wibble::exception::System)
 {
 	if (::chdir(dir.c_str()) == -1)
-		throw SystemException(errno, "changing working directory to " + dir);
+		throw wibble::exception::System("changing working directory to " + dir);
 }
 
-void Process::chroot(const string& dir) throw (SystemException)
+void Process::chroot(const string& dir) throw (wibble::exception::System)
 {
 	if (::chroot(dir.c_str()) == -1)
-		throw SystemException(errno, "changing root directory to " + dir);
+		throw wibble::exception::System("changing root directory to " + dir);
 }
 
 mode_t Process::umask(mode_t mask) throw ()
@@ -110,81 +110,133 @@
 		return getgrnam(group.c_str());
 }
 
-static void initGroups(const string& name, gid_t gid) throw (SystemException)
+static void initGroups(const string& name, gid_t gid) throw (wibble::exception::System)
 {
 	if (::initgroups(name.c_str(), gid) == -1)
-		throw SystemException(errno, "initializing group access list for user "
-				+ name + " with additional group " + fmt(gid));
+	{
+		stringstream str;
+		str << "initializing group access list for user " << name
+			<< " with additional group " << gid;
+		throw wibble::exception::System(str.str());
+	}
 }
 
 static void set_perms(const string& user, uid_t uid, const string& group, gid_t gid)
-	throw (SystemException)
+	throw (wibble::exception::System)
 {
 	initGroups(user, gid);
 
 	if (setgid(gid) == -1)
-		throw SystemException(errno, "setting group id to " + fmt(gid) + " (" + group + ")");
+	{
+		stringstream str;
+		str << "setting group id to " << gid << " (" << group << ")";
+		throw wibble::exception::System(str.str());
+	}
 
 	if (setegid(gid) == -1)
-		throw SystemException(errno, "setting effective group id to " + fmt(gid) + " (" + group + ")");
+	{
+		stringstream str;
+		str << "setting effective group id to " << gid << " (" << group << ")";
+		throw wibble::exception::System(str.str());
+	}
 
 	if (setuid(uid) == -1)
-		throw SystemException(errno, "setting user id to " + fmt(uid) + " (" + user + ")");
+	{
+		stringstream str;
+		str << "setting user id to " << uid << " (" << user << ")";
+		throw wibble::exception::System(str.str());
+	}
 
 	if (seteuid(uid) == -1)
-		throw SystemException(errno, "setting effective user id to " + fmt(uid) + " (" + user + ")");
+	{
+		stringstream str;
+		str << "setting effective user id to " << uid << " (" << user << ")";
+		throw wibble::exception::System(str.str());
+	}
 }
 
 void Process::setPerms(const string& user)
-	throw (ConsistencyCheckException, SystemException)
+	throw (wibble::exception::Consistency, wibble::exception::System)
 {
 	struct passwd* pw = getUserInfo(user);
 	if (!pw)
-		throw ConsistencyCheckException("User " + user + " does not exist on this system");
+	{
+		stringstream str;
+		str << "User " << user << " does not exist on this system"; 
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 	struct group* gr = getgrgid(pw->pw_gid);
 	if (!gr)
-		throw ConsistencyCheckException("Group " + fmt(pw->pw_gid) +
-				" (primary group of user " + user + ") does not exist on this system");
+	{
+		stringstream str;
+		str << "Group " << pw->pw_gid << " (primary group of user "
+			<< user << ") does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 
 	::set_perms(user, pw->pw_uid, gr->gr_name, gr->gr_gid);
 }
 
 void Process::setPerms(const string& user, const string& group)
-        throw (ConsistencyCheckException, SystemException)
+        throw (wibble::exception::Consistency, wibble::exception::System)
 {
 	struct passwd* pw = getUserInfo(user);
 	if (!pw)
-		throw ConsistencyCheckException("User " + user + " does not exist on this system");
+	{
+		stringstream str;
+		str << "User " << user << " does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 	struct group* gr = getGroupInfo(group);
 	if (!gr)
-		throw ConsistencyCheckException("Group " + group + " does not exist on this system");
+	{
+		stringstream str;
+		str << "Group " << group << " does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 
 	::set_perms(user, pw->pw_uid, group, gr->gr_gid);
 }
 
 void Process::setPerms(uid_t user)
-        throw (ConsistencyCheckException, SystemException)
+        throw (wibble::exception::Consistency, wibble::exception::System)
 {
 	struct passwd* pw = getpwuid(user);
 	if (!pw)
-		throw ConsistencyCheckException("User " + fmt(user) + " does not exist on this system");
+	{
+		stringstream str;
+		str << "User " << user << " does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 	struct group* gr = getgrgid(pw->pw_gid);
 	if (!gr)
-		throw ConsistencyCheckException("Group " + fmt(pw->pw_gid) +
-				" (primary group of user " + fmt(user) + ") does not exist on this system");
+	{
+		stringstream str;
+		str << "Group " << pw->pw_gid
+			<< " (primary group of user " << user << ") does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 
 	::set_perms(pw->pw_name, pw->pw_uid, gr->gr_name, gr->gr_gid);
 }
 
 void Process::setPerms(uid_t user, gid_t group)
-        throw (ConsistencyCheckException, SystemException)
+        throw (wibble::exception::Consistency, wibble::exception::System)
 {
 	struct passwd* pw = getpwuid(user);
 	if (!pw)
-		throw ConsistencyCheckException("User " + fmt(user) + " does not exist on this system");
+	{
+		stringstream str;
+		str << "User " << user << " does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 	struct group* gr = getgrgid(group);
 	if (!gr)
-		throw ConsistencyCheckException("Group " + fmt(group) + " does not exist on this system");
+	{
+		stringstream str;
+		str << "Group " << group << " does not exist on this system";
+		throw wibble::exception::Consistency("setting process permissions", str.str());
+	}
 
 	::set_perms(pw->pw_name, pw->pw_uid, gr->gr_name, gr->gr_gid);
 }
@@ -208,43 +260,46 @@
 	}
 }
 
-static void setLimit(__rlimit_resource_t rlim, int val) throw (SystemException)
+static void setLimit(__rlimit_resource_t rlim, int val) throw (wibble::exception::System)
 {
 	struct rlimit lim;
 	if (getrlimit(rlim, &lim) == -1)
-		throw SystemException(errno, "Getting " + describe_rlimit_res_t(rlim) + " limit");
+		throw wibble::exception::System("Getting " + describe_rlimit_res_t(rlim) + " limit");
 	lim.rlim_cur = val;
 	if (setrlimit(rlim, &lim) == -1)
-		throw SystemException(errno, "Setting " + describe_rlimit_res_t(rlim) +
-				" limit to " + fmt(val));
+	{
+		stringstream str;
+		str << "Setting " << describe_rlimit_res_t(rlim) << " limit to " << val;
+		throw wibble::exception::System(str.str());
+	}
 }
 
-static int getLimit(__rlimit_resource_t rlim, int* max = 0) throw (SystemException)
+static int getLimit(__rlimit_resource_t rlim, int* max = 0) throw (wibble::exception::System)
 {
 	struct rlimit lim;
 	if (getrlimit(rlim, &lim) == -1)
-		throw SystemException(errno, "Getting " + describe_rlimit_res_t(rlim) + " limit");
+		throw wibble::exception::System("Getting " + describe_rlimit_res_t(rlim) + " limit");
 	if (max)
 		*max = lim.rlim_max;
 	return lim.rlim_cur;
 }
 
-int Process::getCPUTimeLimit(int* max) throw (SystemException) { return getLimit(RLIMIT_CPU, max); }
-int Process::getFileSizeLimit(int* max) throw (SystemException) { return getLimit(RLIMIT_FSIZE, max); }
-int Process::getDataMemoryLimit(int* max) throw (SystemException) { return getLimit(RLIMIT_DATA, max); }
-int Process::getCoreSizeLimit(int* max) throw (SystemException) { return getLimit(RLIMIT_CORE, max); }
-int Process::getChildrenLimit(int* max) throw (SystemException) { return getLimit(RLIMIT_NPROC, max); }
-int Process::getOpenFilesLimit(int* max) throw (SystemException) { return getLimit(RLIMIT_NOFILE, max); }
-
-void Process::setCPUTimeLimit(int value) throw (SystemException) { setLimit(RLIMIT_CPU, value); }
-void Process::setFileSizeLimit(int value) throw (SystemException) { setLimit(RLIMIT_FSIZE, value); }
-void Process::setDataMemoryLimit(int value) throw (SystemException) { setLimit(RLIMIT_DATA, value); }
-void Process::setCoreSizeLimit(int value) throw (SystemException) { setLimit(RLIMIT_CORE, value); }
-void Process::setChildrenLimit(int value) throw (SystemException) { setLimit(RLIMIT_NPROC, value); }
-void Process::setOpenFilesLimit(int value) throw (SystemException) { setLimit(RLIMIT_NOFILE, value); }
+int Process::getCPUTimeLimit(int* max) throw (wibble::exception::System) { return getLimit(RLIMIT_CPU, max); }
+int Process::getFileSizeLimit(int* max) throw (wibble::exception::System) { return getLimit(RLIMIT_FSIZE, max); }
+int Process::getDataMemoryLimit(int* max) throw (wibble::exception::System) { return getLimit(RLIMIT_DATA, max); }
+int Process::getCoreSizeLimit(int* max) throw (wibble::exception::System) { return getLimit(RLIMIT_CORE, max); }
+int Process::getChildrenLimit(int* max) throw (wibble::exception::System) { return getLimit(RLIMIT_NPROC, max); }
+int Process::getOpenFilesLimit(int* max) throw (wibble::exception::System) { return getLimit(RLIMIT_NOFILE, max); }
+
+void Process::setCPUTimeLimit(int value) throw (wibble::exception::System) { setLimit(RLIMIT_CPU, value); }
+void Process::setFileSizeLimit(int value) throw (wibble::exception::System) { setLimit(RLIMIT_FSIZE, value); }
+void Process::setDataMemoryLimit(int value) throw (wibble::exception::System) { setLimit(RLIMIT_DATA, value); }
+void Process::setCoreSizeLimit(int value) throw (wibble::exception::System) { setLimit(RLIMIT_CORE, value); }
+void Process::setChildrenLimit(int value) throw (wibble::exception::System) { setLimit(RLIMIT_NPROC, value); }
+void Process::setOpenFilesLimit(int value) throw (wibble::exception::System) { setLimit(RLIMIT_NOFILE, value); }
 
 
-pid_t ChildProcess::fork() throw (SystemException)
+pid_t ChildProcess::fork() throw (wibble::exception::System)
 {
 	flockfile(stdin);
 	flockfile(stdout);
@@ -269,7 +324,7 @@
 
 			// Return the exit status
 			_exit(res);
-		} catch (Exception& e) {
+		} catch (std::exception& e) {
 			//log_err(string(e.type()) + ": " + e.desc());
 		}
 		_exit(EXIT_FAILURE);
@@ -277,7 +332,7 @@
 		funlockfile(stdin);
 		funlockfile(stderr);
 		funlockfile(stdout);
-		throw SystemException(errno, "trying to fork the child process to run action script");
+		throw wibble::exception::System("trying to fork the child process to run action script");
 	} else {
 		funlockfile(stdin);
 		funlockfile(stderr);
@@ -288,20 +343,20 @@
 	}
 }
 
-pid_t ChildProcess::forkAndRedirect(int* stdinfd, int* stdoutfd, int* stderrfd) throw (SystemException)
+pid_t ChildProcess::forkAndRedirect(int* stdinfd, int* stdoutfd, int* stderrfd) throw (wibble::exception::System)
 {
 	int pipes[3][2];
 
 	if (stdinfd)
 	{
 		if (pipe(pipes[0]) == -1)
-			throw SystemException(errno, "trying to create the pipe to connect to child standard input");
+			throw wibble::exception::System("trying to create the pipe to connect to child standard input");
 		*stdinfd = pipes[0][1];
 	}
 	if (stdoutfd)
 	{
 		if (pipe(pipes[1]) == -1)
-			throw SystemException(errno, "trying to create the pipe to connect to child standard output");
+			throw wibble::exception::System("trying to create the pipe to connect to child standard output");
 		*stdoutfd = pipes[1][0];
 		if (stderrfd == stdoutfd)
 			*stderrfd = pipes[1][0];
@@ -310,7 +365,7 @@
 	if (stderrfd && stderrfd != stdoutfd)
 	{
 		if (pipe(pipes[2]) == -1)
-			throw SystemException(errno, "trying to create the pipe to connect to child standard error");
+			throw wibble::exception::System("trying to create the pipe to connect to child standard error");
 		*stderrfd = pipes[2][0];
 	}
 
@@ -330,36 +385,36 @@
 			{
 				// Redirect input from the parent to stdin
 				if (close(pipes[0][1]) == -1)
-					throw SystemException(errno, "closing write end of parent stdin pipe");
+					throw wibble::exception::System("closing write end of parent stdin pipe");
 				if (dup2(pipes[0][0], 0) == -1)
-					throw SystemException(errno, "dup2-ing parent stdin pipe to stdin");
+					throw wibble::exception::System("dup2-ing parent stdin pipe to stdin");
 				if (close(pipes[0][0]) == -1)
-					throw SystemException(errno, "closing original read end of parent stdin pipe");
+					throw wibble::exception::System("closing original read end of parent stdin pipe");
 			}
 
 			if (stdoutfd)
 			{
 				// Redirect output to the parent stdout fd
 				if (close(pipes[1][0]) == -1)
-					throw SystemException(errno, "closing read end of parent stdout pipe");
+					throw wibble::exception::System("closing read end of parent stdout pipe");
 				if (dup2(pipes[1][1], 1) == -1)
-					throw SystemException(errno, "dup2-ing stdout to parent stdout pipe");
+					throw wibble::exception::System("dup2-ing stdout to parent stdout pipe");
 				if (stderrfd == stdoutfd)
 					if (dup2(pipes[1][1], 2) == -1)
-						throw SystemException(errno, "dup2-ing stderr to parent stdout/stderr pipe");
+						throw wibble::exception::System("dup2-ing stderr to parent stdout/stderr pipe");
 				if (close(pipes[1][1]) == -1)
-					throw SystemException(errno, "closing original write end of parent stdout pipe");
+					throw wibble::exception::System("closing original write end of parent stdout pipe");
 			}
 
 			if (stderrfd && stderrfd != stdoutfd)
 			{
 				// Redirect all output to the parent
 				if (close(pipes[2][0]) == -1)
-					throw SystemException(errno, "closing read end of parent stderr pipe");
+					throw wibble::exception::System("closing read end of parent stderr pipe");
 				if (dup2(pipes[2][1], 2) == -1)
-					throw SystemException(errno, "dup2-ing stderr to parent stderr pipe");
+					throw wibble::exception::System("dup2-ing stderr to parent stderr pipe");
 				if (close(pipes[2][1]) == -1)
-					throw SystemException(errno, "closing original write end of parent stderr pipe");
+					throw wibble::exception::System("closing original write end of parent stderr pipe");
 			}
 
 			// Call the process main function
@@ -368,7 +423,7 @@
 			delete _proc;
 			// Return the exit status
 			_exit(res);
-		} catch (Exception& e) {
+		} catch (std::exception& e) {
 			//log_err(string(e.type()) + ": " + e.desc());
 		}
 		_exit(EXIT_FAILURE);
@@ -391,7 +446,7 @@
 			close(pipes[2][0]);
 			close(pipes[2][1]);
 		}
-		throw SystemException(errno, "trying to fork the child process to run action script");
+		throw wibble::exception::System("trying to fork the child process to run action script");
 	} else {
 		funlockfile(stdin);
 		funlockfile(stderr);
@@ -402,15 +457,15 @@
 		try {
 			if (stdinfd)
 				if (close(pipes[0][0]) == -1)
-					throw SystemException(errno, "closing read end of stdin child pipe");
+					throw wibble::exception::System("closing read end of stdin child pipe");
 			if (stdoutfd)
 				if (close(pipes[1][1]) == -1)
-					throw SystemException(errno, "closing write end of stdout child pipe");
+					throw wibble::exception::System("closing write end of stdout child pipe");
 			if (stderrfd && stderrfd != stdoutfd)
 				if (close(pipes[2][1]) == -1)
-					throw SystemException(errno, "closing write end of stderr child pipe");
+					throw wibble::exception::System("closing write end of stderr child pipe");
 			return pid;
-		} catch (SystemException& e) {
+		} catch (wibble::exception::System& e) {
 			// Try to kill the child process if any errors occurs here
 			::kill(pid, 15);
 			throw e;
@@ -418,7 +473,7 @@
 	}
 }
 
-int ChildProcess::wait() throw (SystemException, InterruptedException)
+int ChildProcess::wait() throw (wibble::exception::System, wibble::exception::Interrupted)
 {
 	if (_pid == -1)
 	{
@@ -429,14 +484,14 @@
 	int status;
 	if (waitpid(_pid, &status, 0) == -1)
 		if (errno == EINTR)
-			throw InterruptedException("waiting for child termination");
+			throw wibble::exception::Interrupted("waiting for child termination");
 		else
-			throw SystemException(errno, "waiting for child termination");
+			throw wibble::exception::System("waiting for child termination");
 	_pid = -1;
 	return status;
 }
 
-int ChildProcess::wait(struct rusage* ru) throw (SystemException, InterruptedException)
+int ChildProcess::wait(struct rusage* ru) throw (wibble::exception::System, wibble::exception::Interrupted)
 {
 	if (_pid == -1)
 	{
@@ -447,17 +502,21 @@
 	int status;
 	if (wait4(_pid, &status, 0, ru) == -1)
 		if (errno == EINTR)
-			throw InterruptedException("waiting for child termination");
+			throw wibble::exception::Interrupted("waiting for child termination");
 		else
-			throw SystemException(errno, "waiting for child termination");
+			throw wibble::exception::System("waiting for child termination");
 	_pid = -1;
 	return status;
 }
 
-void ChildProcess::kill(int signal) throw (SystemException)
+void ChildProcess::kill(int signal) throw (wibble::exception::System)
 {
 	if (::kill(_pid, signal) == -1)
-		throw SystemException(errno, "killing process " + fmt(_pid));
+	{
+		stringstream str;
+		str << "killing process " + _pid;
+		throw wibble::exception::System(str.str());
+	}
 }
 	
 
@@ -512,16 +571,16 @@
 		userdb.initgroups(user, gid);
 
 		if (setgid(gid) == -1)
-			throw SystemException(errno, fmt("setting group id to %d (%s)", gid, group));
+			throw wibble::exception::System(fmt("setting group id to %d (%s)", gid, group));
 
 		if (setegid(gid) == -1)
-			throw SystemException(errno, fmt("setting effective group id to %d (%s)", gid, group));
+			throw wibble::exception::System(fmt("setting effective group id to %d (%s)", gid, group));
 
 		if (setuid(uid) == -1)
-			throw SystemException(errno, fmt("setting user id to %d (%s)", uid, user));
+			throw wibble::exception::System(fmt("setting user id to %d (%s)", uid, user));
 
 		if (seteuid(uid) == -1)
-			throw SystemException(errno, fmt("setting effective user id to %d (%s)", uid, user));
+			throw wibble::exception::System(fmt("setting effective user id to %d (%s)", uid, user));
 	} else
 		throw RunnerException("missing the necessary privileges to change permissions");
 }
@@ -604,11 +663,11 @@
 
 	if (_opt_want_child_stdin)
 		if (pipe(pstdin) == -1)
-			throw SystemException(errno, "trying to create the pipe to connect to child standard input");
+			throw wibble::exception::System("trying to create the pipe to connect to child standard input");
 
 	if (_opt_want_child_output)
 		if (pipe(poutput) == -1)
-			throw SystemException(errno, "trying to create the pipe to read the script output");
+			throw wibble::exception::System("trying to create the pipe to read the script output");
 	flockfile(stdout);
 	flockfile(stderr);
 
@@ -630,20 +689,20 @@
 			{
 				// Redirect input from the parent to stdin
 				if (close(pstdin[1]) == -1)
-					throw SystemException(errno, "closing write end of parent pipe");
+					throw wibble::exception::System("closing write end of parent pipe");
 				if (dup2(pstdin[0], 0) == -1)
-					throw SystemException(errno, "dup2-ing parent pipe to stdin");
+					throw wibble::exception::System("dup2-ing parent pipe to stdin");
 			}
 
 			if (_opt_want_child_output)
 			{
 				// Redirect all output to the parent
 				if (close(poutput[0]) == -1)
-					throw SystemException(errno, "closing read end of parent pipe");
+					throw wibble::exception::System("closing read end of parent pipe");
 				if (dup2(poutput[1], 1) == -1)
-					throw SystemException(errno, "dup2-ing stdout to parent pipe");
+					throw wibble::exception::System("dup2-ing stdout to parent pipe");
 				if (dup2(poutput[1], 2) == -1)
-					throw SystemException(errno, "dup2-ing stderr to parent pipe");
+					throw wibble::exception::System("dup2-ing stderr to parent pipe");
 			}
 
 			_exit(main());
@@ -654,7 +713,7 @@
 	} else if (pid < 0) {
 		funlockfile(stderr);
 		funlockfile(stdout);
-		throw SystemException(errno, "trying to fork the child process to run action script");
+		throw wibble::exception::System("trying to fork the child process to run action script");
 	} else {
 		funlockfile(stderr);
 		funlockfile(stdout);
@@ -664,14 +723,14 @@
 			if (_opt_want_child_stdin)
 			{
 				if (close(pstdin[0]) == -1)
-					throw SystemException(errno, "closing read end of stdin child pipe");
+					throw wibble::exception::System("closing read end of stdin child pipe");
 				child_stdin = pstdin[1];
 			}
 
 			if (_opt_want_child_output)
 			{
 				if (close(poutput[1]) == -1)
-					throw SystemException(errno, "closing write end of output child pipe");
+					throw wibble::exception::System("closing write end of output child pipe");
 				child_output = poutput[0];
 			}
 
@@ -699,7 +758,7 @@
 	vector<string> output;
 	FILE* in = fdopen(child_output, "r");
 	if (!in)
-		throw SystemException(errno, "calling fdopen on child output file descriptor");
+		throw wibble::exception::System("calling fdopen on child output file descriptor");
 	
 	string line;
 	int byte_count = 0;
@@ -720,7 +779,7 @@
 			byte_count++;
 		}
 	if (fclose(in) == EOF)
-		throw SystemException(errno, "closing read end of output child pipe");
+		throw wibble::exception::System("closing read end of output child pipe");
 
 	return output;
 }
@@ -733,7 +792,7 @@
 
 	int status;
 	if (waitpid(pid, &status, 0) == -1)
-		throw SystemException(errno, "waiting for child termination");
+		throw wibble::exception::System("waiting for child termination");
 	pid = 0;
 	return status;
 }
@@ -744,7 +803,7 @@
 		throw RunnerException("kill was called but the child was not started");
 
 	if (::kill(pid, sig) == -1)
-		throw SystemException(errno, fmt("killing process %d with signal %d", pid, sig));
+		throw wibble::exception::System(fmt("killing process %d with signal %d", pid, sig));
 }
 
 
@@ -810,7 +869,7 @@
 
 	// Execute the command
 	if (execve(argv0(), argv.get(), env.get()) == -1)
-		throw SystemException(errno, string("Executing ") + argv0());
+		throw wibble::exception::System(string("Executing ") + argv0());
 
 	return EXIT_FAILURE;
 }

Modified: trunk/src/ChildProcess.h
==============================================================================
--- trunk/src/ChildProcess.h	(original)
+++ trunk/src/ChildProcess.h	Fri Aug 25 17:57:07 2006
@@ -22,12 +22,12 @@
  */
 
 #include <sys/types.h>
-#include <Exception.h>
+#include <wibble/exception.h>
 
 class Process
 {
 protected:
-	void detachFromTTY() throw (SystemException);
+	void detachFromTTY() throw (wibble::exception::System);
 
 public:
 	virtual ~Process() {}
@@ -42,40 +42,40 @@
 	static std::string formatStatus(int status) throw ();
 	
 	/// Change working directory
-	static void chdir(const std::string& dir) throw (SystemException);
+	static void chdir(const std::string& dir) throw (wibble::exception::System);
 
 	/// Change root directory
-	static void chroot(const std::string& dir) throw (SystemException);
+	static void chroot(const std::string& dir) throw (wibble::exception::System);
 
 	/// Change umask (always succeeds and returns the previous umask)
 	static mode_t umask(mode_t mask) throw ();
 
 	/// Set user and group permissions
 	static void setPerms(const std::string& user)
-		throw (ConsistencyCheckException, SystemException);
+		throw (wibble::exception::Consistency, wibble::exception::System);
 	static void setPerms(const std::string& user, const std::string& group)
-		throw (ConsistencyCheckException, SystemException);
+		throw (wibble::exception::Consistency, wibble::exception::System);
 	static void setPerms(uid_t user)
-		throw (ConsistencyCheckException, SystemException);
+		throw (wibble::exception::Consistency, wibble::exception::System);
 	static void setPerms(uid_t user, gid_t group)
-		throw (ConsistencyCheckException, SystemException);
+		throw (wibble::exception::Consistency, wibble::exception::System);
 
 	/// Get current resource limits; store also maximum resource limits in max
 	/// if nonzero
-	static int getCPUTimeLimit(int* max = 0) throw (SystemException);
-	static int getFileSizeLimit(int* max = 0) throw (SystemException);
-	static int getDataMemoryLimit(int* max = 0) throw (SystemException);
-	static int getChildrenLimit(int* max = 0) throw (SystemException);
-	static int getOpenFilesLimit(int* max = 0) throw (SystemException);
-	static int getCoreSizeLimit(int* max = 0) throw (SystemException);
+	static int getCPUTimeLimit(int* max = 0) throw (wibble::exception::System);
+	static int getFileSizeLimit(int* max = 0) throw (wibble::exception::System);
+	static int getDataMemoryLimit(int* max = 0) throw (wibble::exception::System);
+	static int getChildrenLimit(int* max = 0) throw (wibble::exception::System);
+	static int getOpenFilesLimit(int* max = 0) throw (wibble::exception::System);
+	static int getCoreSizeLimit(int* max = 0) throw (wibble::exception::System);
 
 	/// Set resource limits
-	static void setCPUTimeLimit(int value) throw (SystemException);
-	static void setFileSizeLimit(int value) throw (SystemException);
-	static void setDataMemoryLimit(int value) throw (SystemException);
-	static void setChildrenLimit(int value) throw (SystemException);
-	static void setOpenFilesLimit(int value) throw (SystemException);
-	static void setCoreSizeLimit(int value) throw (SystemException);
+	static void setCPUTimeLimit(int value) throw (wibble::exception::System);
+	static void setFileSizeLimit(int value) throw (wibble::exception::System);
+	static void setDataMemoryLimit(int value) throw (wibble::exception::System);
+	static void setChildrenLimit(int value) throw (wibble::exception::System);
+	static void setOpenFilesLimit(int value) throw (wibble::exception::System);
+	static void setCoreSizeLimit(int value) throw (wibble::exception::System);
 };
 
 struct rusage;
@@ -92,13 +92,13 @@
 
 	/// For a subprocess to run proc.
 	/// After this function exits successfully, `proc' can safely be deleted.
-	pid_t fork() throw (SystemException);
+	pid_t fork() throw (wibble::exception::System);
 
 	/// Fork a subprocess to run proc.  If one of the std*fd variables is
 	/// non-null, create a pipe connected to the corresponding file descriptor
 	/// of the child process and store the parent end in the std*fd variable.
 	/// After this function exits successfully, `proc' can safely be deleted.
-	pid_t forkAndRedirect(int* stdinfd = 0, int* stdoutfd = 0, int* stderrfd = 0) throw (SystemException);
+	pid_t forkAndRedirect(int* stdinfd = 0, int* stdoutfd = 0, int* stderrfd = 0) throw (wibble::exception::System);
 	
 	/// Get the pid of the child process or (pid_t)-1 if no child is running
 	pid_t pid() const throw () { return _pid; }
@@ -106,15 +106,15 @@
 	/// Wait for the child to finish, returing its exit status.  Return -1 if
 	/// no child is running.
 	/// TODO: gracefully handle the EINTR error code
-	int wait() throw (SystemException, InterruptedException);
+	int wait() throw (wibble::exception::System, wibble::exception::Interrupted);
 
 	/// Wait for the child to finish, returing its exit status and storing
 	/// resource usage informations in `ru'.  Return -1 if no child is running.
 	/// TODO: gracefully handle the EINTR error code
-	int wait(struct rusage* ru) throw (SystemException, InterruptedException);
+	int wait(struct rusage* ru) throw (wibble::exception::System, wibble::exception::Interrupted);
 
 	/// Send the given signal to the process
-	void kill(int signal) throw (SystemException);
+	void kill(int signal) throw (wibble::exception::System);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/Exec.cc
==============================================================================
--- trunk/src/Exec.cc	(original)
+++ trunk/src/Exec.cc	Fri Aug 25 17:57:07 2006
@@ -25,7 +25,6 @@
 #include <string.h>			// strndup
 #include <errno.h>
 
-using namespace stringf;
 using namespace std;
 
 ///// Exec::strlist
@@ -63,10 +62,10 @@
 	ptr[cur++] = strndup(str.data(), str.size());
 }
 
-void Exec::exec() throw (SystemException)
+void Exec::exec() throw (wibble::exception::System)
 {
 	execve(program.c_str(), argv.get(), env.get());
-	throw SystemException(errno, "Executing " + program);
+	throw wibble::exception::System("Executing " + program);
 }
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/Exec.h
==============================================================================
--- trunk/src/Exec.h	(original)
+++ trunk/src/Exec.h	Fri Aug 25 17:57:07 2006
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
-#include "Exception.h"
+#include <wibble/exception.h>
 
 // Base class to construct objects that run child processes
 class Exec
@@ -72,7 +72,7 @@
 	void addEnv(const std::string& envstr) throw () { env.add(envstr); }
 
 	/// execve() the program, never returning if all goes well
-	void exec() throw (SystemException);
+	void exec() throw (wibble::exception::System);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/GuessnetEnvironment.cc
==============================================================================
--- trunk/src/GuessnetEnvironment.cc	(original)
+++ trunk/src/GuessnetEnvironment.cc	Fri Aug 25 17:57:07 2006
@@ -28,17 +28,62 @@
 #endif
 
 #include "GuessnetEnvironment.h"
-#include "CommandlineParser.h"
 #include "Regexp.h"
 
 #include "GuessnetParser.h"
 #include "IfaceParser.h"
 
+#include <wibble/commandline/parser.h>
 #include <set>
 
 #include <stdio.h>
 #include <stdarg.h>
 
+namespace wibble {
+namespace commandline {
+
+struct GuessnetOptions : public StandardParserWithManpage
+{
+public:
+	BoolOption* verbose;
+	BoolOption* debug;
+	BoolOption* ifupdown;
+	StringOption* defprof;
+	IntOption* timeout;
+	IntOption* inittime;
+	ExistingFileOption* configfile;
+
+	GuessnetOptions() 
+		: StandardParserWithManpage(APPNAME, VERSION, 8, "enrico at enricozini.org")
+	{
+		usage = "[options] [iface]";
+		description = "Guess the current network location";
+
+		verbose = add<BoolOption>("verbose", 'v', "verbose", "",
+						"enable verbose output");
+		debug = add<BoolOption>("debug", 0, "debug", "",
+						"enable debugging output (including verbose output)");
+		configfile = add<ExistingFileOption>("configfile", 'C', "config-file", "",
+						"name of the configuration file to read (default: stdin or"
+						"/etc/network/interfaces in ifupdown mode");
+		ifupdown = add<BoolOption>("ifupdown", 'i', "ifupdown-mode", "",
+						"use /etc/network/interfaces file instead of the usual"
+						" guessnet configuration file");
+		defprof = add<StringOption>("defprof", 'd', "default", "name",
+						"profile name to report if no known networks are found"
+						" (defaults to \"none\")");
+		timeout = add<IntOption>("timeout", 't', "timeout", "seconds",
+						"timeout (in seconds) used to wait for response packets"
+						" (defaults to 5 seconds)");
+		inittime = add<IntOption>("inittime", 0, "init-timeout", "seconds",
+						"time (in seconds) to wait for the interface to initialize"
+						" when not found already up (defaults to 3 seconds)");
+	}
+};
+
+}
+}
+
 using namespace std;
 
 static GuessnetEnvironment* instance;
@@ -55,40 +100,38 @@
 	string configFile;
 
 public:
-	StandaloneEnvironment(CommandlineParser& opts)
+	StandaloneEnvironment(wibble::commandline::GuessnetOptions& opts)
 	{
-		// Find out the configuration file to use
-		if (opts.get_argc() > 2)
-			configFile = opts.get_argv()[2];
-		else if (opts.get("configfile").defined())
-			configFile = opts.get("configfile").stringVal();
-
 		// Set verbosity
-		verbose(opts.get("verbose").defined());
-		debug(opts.get("debug").defined());
-
+		verbose(opts.verbose->boolValue());
+		debug(opts.debug->boolValue());
 
 		// Find out the interface to be tested
-		if (opts.get_argc() > 1)
-			iface(opts.get_argv()[1]);
+		if (opts.hasNext())
+			iface(opts.next());
 		else
 			iface("eth0");
 
+		// Find out the configuration file to use
+		if (opts.hasNext())
+			configFile = opts.next();
+		else if (opts.configfile->boolValue())
+			configFile = opts.configfile->stringValue();
 
 		// Find out the default profile name
-		if (opts.get("defprof").defined())
+		if (opts.defprof->boolValue())
 		{
-			defprof(opts.get("defprof").stringVal());
-			::verbose("Default profile set to `%.*s'\n", PFSTR(defprof()));
+			defprof(opts.defprof->stringValue());
+			::verbose("Default profile set to `%s'\n", defprof().c_str());
 		}
 
 		// Find out the test timeout
-		if (opts.get("timeout").defined())
-			timeout(opts.get("timeout").intVal());
+		if (opts.timeout->boolValue())
+			timeout(opts.timeout->intValue());
 
 		// Find out the init timeout
-		if (opts.get("inittime").defined())
-			initTimeout(opts.get("inittime").intVal());
+		if (opts.inittime->boolValue())
+			initTimeout(opts.inittime->intValue());
 
 	}
 
@@ -110,7 +153,7 @@
 	{
 		input = fopen(configFile.c_str(), "rt");
 		if (!input)
-			throw FileException(errno, "opening " + configFile);
+			throw wibble::exception::File(configFile, "opening file");
 	}
 
 	GuessnetParser::parse(input, *this);
@@ -153,7 +196,7 @@
 	set<string> ifupdownProfiles;
 
 public:
-	IfupdownEnvironment(CommandlineParser& opt) :
+	IfupdownEnvironment(wibble::commandline::GuessnetOptions& opt) :
 		StandaloneEnvironment(opt)
 	{
 		// We have a default config file name in ifupdown mode
@@ -241,7 +284,7 @@
 	/* Open the specified config file or stdin if not specified */
 	FILE* input = fopen(configFile.c_str(), "rt");;
 	if (!input)
-		throw FileException(errno, "opening " + configFile);
+		throw wibble::exception::File(configFile, "opening file");
 
 	IfaceParser::parse(input, *this);
 
@@ -250,44 +293,10 @@
 
 void GuessnetEnvironment::init(int argc, const char* argv[])
 {
-	CommandlineParser opts(APPNAME, "[options] [ethernet_interface]", "Guess the current network location");
-	opts.add("version", 'V', "version", "print the program version, then exit");
-	opts.add("configfile", 'C', "config-file",
-			"name of the configuration file to read (default: stdin or"
-			"/etc/network/interfaces in ifupdown mode", "file");
-	opts.add("ifupdown", 'i', "ifupdown-mode",
-			"use /etc/network/interfaces file instead of the usual"
-			" guessnet configuration file");
-	opts.add("defprof", 'd', "default",
-			"profile name to report if no known networks are found"
-			" (defaults to \"none\")", "name");
-	opts.add("timeout", 't', "timeout",
-			"timeout (in seconds) used to wait for response packets"
-			" (defaults to 5 seconds)", "seconds");
-	opts.add("inittime", 0, "init-timeout",
-			"time (in seconds) to wait for the interface to initialize"
-			" when not found already up (defaults to 3 seconds)");
-	opts.add("verbose", 'v', "verbose",
-			"enable verbose operations");
-	opts.add("debug", 0, "debug", 
-			"enable debugging output");
+	wibble::commandline::GuessnetOptions opts;
 
-	// Process the commandline
-	if (!opts.parse(argc, argv))
-	{
-		opts.printHelp();
-		exit(1);
-	}
-	if (opts.get("help").defined())
-	{
-		opts.printHelp();
-		exit(0);
-	}
-	if (opts.get("version").defined())
-	{
-		printf("%s " VERSION "\n", APPNAME);
+	if (opts.parse(argc, (const char**)argv))
 		exit(0);
-	}
 
 	// Check user id
 	/*
@@ -295,9 +304,8 @@
 		fatal_error("You must run this command as root.");
 	*/
 
-
 	// Find out wether we should run in ifupdown mode
-	bool ifupdown_mode = opts.get("ifupdown").defined();
+	bool ifupdown_mode = opts.ifupdown->boolValue();
 	if (!ifupdown_mode)
 	{
 		const char* pname = strrchr(argv[0], '/');

Modified: trunk/src/GuessnetParser.cc
==============================================================================
--- trunk/src/GuessnetParser.cc	(original)
+++ trunk/src/GuessnetParser.cc	Fri Aug 25 17:57:07 2006
@@ -28,20 +28,18 @@
 #endif
 
 #include "GuessnetParser.h"
-#include "stringf.h"
 #include "Regexp.h"
 #include "Environment.h"
 
 #include <string>
 
 using namespace std;
-using namespace stringf;
 
 /* Parse the input from `input'
  * To make it simple, use regexps on input lines instead of implementing a real
  * parser.
  */
-void GuessnetParser::parse(FILE* input, ScanConsumer& sc) throw (Exception)
+void GuessnetParser::parse(FILE* input, ScanConsumer& sc)
 {
 #define MACPATTERN "[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}"
 #define IPPATTERN "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"

Modified: trunk/src/GuessnetParser.h
==============================================================================
--- trunk/src/GuessnetParser.h	(original)
+++ trunk/src/GuessnetParser.h	Fri Aug 25 17:57:07 2006
@@ -27,7 +27,7 @@
 class GuessnetParser
 {
 public:
-	static void parse(FILE* in, ScanConsumer& sc) throw (Exception);
+	static void parse(FILE* in, ScanConsumer& sc);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/IFace.cc
==============================================================================
--- trunk/src/IFace.cc	(original)
+++ trunk/src/IFace.cc	Fri Aug 25 17:57:07 2006
@@ -54,8 +54,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "stringf.h"
-#include "Exception.h"
+#include <iostream>
+
 #include "Exec.h"
 #include "ChildProcess.h"
 #include "Environment.h"
@@ -74,8 +74,6 @@
 #define IFP_ALL_ADDRESSES_VALID(ifp)									\
   ((((ifp) -> addr_flags) & IFP_VALID_ALL) == IFP_VALID_ALL)
 
-
-using namespace stringf;
 using namespace std;
 
 
@@ -89,7 +87,7 @@
 
 typedef enum { IFSTATUS_UP, IFSTATUS_DOWN, IFSTATUS_ERR } interface_status_t;
 
-static interface_status_t interface_detect_beat_mii(int fd, const char *iface) throw (MIIException)
+static interface_status_t interface_detect_beat_mii(int fd, const char *iface) throw (wibble::exception::MII)
 {
     struct ifreq ifr;
     
@@ -97,17 +95,17 @@
     strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)-1);
 
     if (ioctl(fd, SIOCGMIIPHY, &ifr) == -1)
-		throw MIIException(errno, "SIOCGMIIPHY failed");
+		throw wibble::exception::MII("SIOCGMIIPHY failed");
 
     ((unsigned short*) &ifr.ifr_data)[1] = 1;
 
     if (ioctl(fd, SIOCGMIIREG, &ifr) == -1)
-		throw MIIException(errno, "SIOCGMIIREG failed");
+		throw wibble::exception::MII("SIOCGMIIREG failed");
 
     return (((unsigned short*) &ifr.ifr_data)[3] & 0x0016) == 0x0004 ? IFSTATUS_UP : IFSTATUS_DOWN;
 }
 
-static interface_status_t interface_detect_beat_priv(int fd, const char *iface) throw (MIIException)
+static interface_status_t interface_detect_beat_priv(int fd, const char *iface) throw (wibble::exception::MII)
 {
     struct ifreq ifr;
     
@@ -115,17 +113,17 @@
     strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)-1);
 
     if (ioctl(fd, SIOCDEVPRIVATE, &ifr) == -1)
-		throw MIIException(errno, "SIOCDEVPRIVATE failed");
+		throw wibble::exception::MII("SIOCDEVPRIVATE failed");
 
     ((unsigned short*) &ifr.ifr_data)[1] = 1;
 
     if (ioctl(fd, SIOCDEVPRIVATE+1, &ifr) == -1)
-		throw MIIException(errno, "SIOCDEVPRIVATE+1 failed");
+		throw wibble::exception::MII("SIOCDEVPRIVATE+1 failed");
 
     return (((unsigned short*) &ifr.ifr_data)[3] & 0x0016) == 0x0004 ? IFSTATUS_UP : IFSTATUS_DOWN;
 }
 
-static interface_status_t interface_detect_beat_ethtool(int fd, const char *iface) throw (MIIException)
+static interface_status_t interface_detect_beat_ethtool(int fd, const char *iface) throw (wibble::exception::MII)
 {
     struct ifreq ifr;
     struct ethtool_value edata;
@@ -137,13 +135,13 @@
     ifr.ifr_data = (caddr_t) &edata;
 
     if (ioctl(fd, SIOCETHTOOL, &ifr) == -1)
-		throw MIIException(errno, "ETHTOOL_GLINK failed");
+		throw wibble::exception::MII("ETHTOOL_GLINK failed");
 
     return edata.data ? IFSTATUS_UP : IFSTATUS_DOWN;
 }
 
 
-static int get_wlan_qual_old(const char *iface) throw (MIIException)
+static int get_wlan_qual_old(const char *iface) throw (wibble::exception::MII)
 {
     FILE *f;
     char buf[256];
@@ -153,7 +151,7 @@
     l = strlen(iface);
     
     if (!(f = fopen("/proc/net/wireless", "r")))
-		throw MIIException(errno, "Failed to open /proc/net/wireless");
+		throw wibble::exception::MII("Failed to open /proc/net/wireless");
     
     while (fgets(buf, sizeof(buf)-1, f)) {
         bp = buf;
@@ -181,12 +179,12 @@
     fclose(f);
 
     if (q < 0)
-		throw MIIException(errno, "Failed to find interface in /proc/net/wireless");
+		throw wibble::exception::MII("Failed to find interface in /proc/net/wireless");
 
     return q;
 }
 
-static int get_wlan_qual_new(int fd, const char *iface) throw (MIIException)
+static int get_wlan_qual_new(int fd, const char *iface) throw (wibble::exception::MII)
 {
     struct iwreq req;
     struct iw_statistics q;
@@ -200,7 +198,7 @@
     req.u.data.flags = 1;
 
     if (ioctl(fd, SIOCGIWSTATS, &req) < 0)
-		throw MIIException(errno, "Failed to get interface quality");
+		throw wibble::exception::MII("Failed to get interface quality");
 
     memset(&req, 0, sizeof(req));
     strncpy(req.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
@@ -211,7 +209,7 @@
     req.u.data.flags = 0;
      
     if (ioctl(fd, SIOCGIWRANGE, &req) < 0)
-		throw MIIException(errno, "SIOCGIWRANGE failed");
+		throw wibble::exception::MII("SIOCGIWRANGE failed");
     
     /* Test if both qual and level are on their lowest level */
     if (q.qual.qual <= 0 &&
@@ -236,7 +234,7 @@
     return !b || (mac[0] != 0xFF && mac[0] != 0x44 && mac[0] != 0x00);
 }
 
-static interface_status_t interface_detect_beat_wlan(int fd, const char *iface) throw (MIIException)
+static interface_status_t interface_detect_beat_wlan(int fd, const char *iface) throw (wibble::exception::MII)
 {
     uint8_t mac[6];
     int q;
@@ -246,7 +244,7 @@
     strncpy(req.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
      
     if (ioctl(fd, SIOCGIWAP, &req) < 0)
-		throw MIIException(errno, "Failed to get AP address");
+		throw wibble::exception::MII("Failed to get AP address");
 
     memcpy(mac, &(req.u.ap_addr.sa_data), ETH_ALEN);
            
@@ -255,52 +253,52 @@
 
     if ((q = get_wlan_qual_new(fd, iface)) < 0)
         if ((q = get_wlan_qual_old(iface)) < 0)
-			throw MIIException(errno, "Failed to get wireless link quality");
+			throw wibble::exception::MII("Failed to get wireless link quality");
     
     return q > 0 ? IFSTATUS_UP : IFSTATUS_DOWN;
 }
 
-static interface_status_t (*cached_detect_beat_func)(int, const char*) throw (MIIException) = NULL;
+static interface_status_t (*cached_detect_beat_func)(int, const char*) throw (wibble::exception::MII) = NULL;
 
 static interface_status_t detect_beat_auto(int fd, const char *iface)
 {
 	if (cached_detect_beat_func)
 		try {
 			return cached_detect_beat_func(fd, iface);
-		} catch (MIIException& e) {
-			warning("Link beat detection (cached) failed: %.*s\n", PFSTR(e.desc()));
+		} catch (wibble::exception::MII& e) {
+			warning("Link beat detection (cached) failed: %s\n", e.desc().c_str());
 		}
 
 	try {
 		interface_status_t status = interface_detect_beat_mii(fd, iface);
 		cached_detect_beat_func = interface_detect_beat_mii;
 		return status;
-	} catch (MIIException& e) {
-		warning("Link beat detection (mii) failed: %.*s\n", PFSTR(e.desc()));
+	} catch (wibble::exception::MII& e) {
+		warning("Link beat detection (mii) failed: %s\n", e.desc().c_str());
 	}
 
 	try {
 		interface_status_t status = interface_detect_beat_ethtool(fd, iface);
 		cached_detect_beat_func = interface_detect_beat_ethtool;
 		return status;
-	} catch (MIIException& e) {
-		warning("Link beat detection (ethtool) failed: %.*s\n", PFSTR(e.desc()));
+	} catch (wibble::exception::MII& e) {
+		warning("Link beat detection (ethtool) failed: %s\n", e.desc().c_str());
 	}
 
 	try {
 		interface_status_t status = interface_detect_beat_wlan(fd, iface);
 		cached_detect_beat_func = interface_detect_beat_wlan;
 		return status;
-	} catch (MIIException& e) {
-		warning("Link beat detection (wlan) failed: %.*s\n", PFSTR(e.desc()));
+	} catch (wibble::exception::MII& e) {
+		warning("Link beat detection (wlan) failed: %.*s\n", e.desc().c_str());
 	}
 
 	try {
 		interface_status_t status = interface_detect_beat_priv(fd, iface);
 		cached_detect_beat_func = interface_detect_beat_priv;
 		return status;
-	} catch (MIIException& e) {
-		warning("Link beat detection (priv) failed: %.*s\n", PFSTR(e.desc()));
+	} catch (wibble::exception::MII& e) {
+		warning("Link beat detection (priv) failed: %.*s\n", e.desc().c_str());
 	}
 
 	return IFSTATUS_ERR;
@@ -313,7 +311,7 @@
   if ((ioctl (_socket, symbol, _ifr)) < 0)									\
 	{																	\
 	  if (errno != EADDRNOTAVAIL)										\
-		  throw IFaceException(errno, string("getting " #field " for ") + name()); \
+		  throw wibble::exception::IFace(string("getting " #field " for ") + name()); \
 	  (ifp -> addr_flags) &=~ (addr_flag);								\
 	}																	\
   else																	\
@@ -325,10 +323,10 @@
 }
 
 void IFace::read_interface_configuration(struct if_params *ifp)
-	throw (IFaceException)
+	throw (wibble::exception::IFace)
 {
 	if ((ioctl (_socket, SIOCGIFFLAGS, _ifr)) < 0)
-		throw IFaceException(errno, string("getting interface flags for ") + name());
+		throw wibble::exception::IFace(string("getting interface flags for ") + name());
 	ifp->flags = _ifr->ifr_flags;
 
 	(ifp -> addr_flags) = 0;
@@ -340,7 +338,7 @@
   if ((ioctl (_socket, SIOCGIFHWADDR, _ifr)) < 0)
 	{
 	  if (errno != EADDRNOTAVAIL)
-		  throw IFaceException(errno, string("getting hwaddr for ") + name());
+		  throw wibble::exception::IFace(string("getting hwaddr for ") + name());
 	  bzero(&(ifp->hwaddr), sizeof(struct sockaddr));
 	}
   else
@@ -355,12 +353,12 @@
 	{																	\
       memcpy(&(_ifr->ifr_##field), &(ifp.field), sizeof(struct sockaddr));				\
 	  if ((ioctl (_socket, symbol, _ifr)) < 0)					\
-		  throw IFaceException(errno, "setting interface configuration for " + name()); \
+		  throw wibble::exception::IFace("setting interface configuration for " + name()); \
 	}																	\
 }
 
 void IFace::write_interface_configuration(const struct if_params& ifp)
-	throw (IFaceException)
+	throw (wibble::exception::IFace)
 {
   //writeField(fd, ifr, SIOCSIFADDR);
   WRITE_ADDR (SIOCSIFADDR, addr, IFP_VALID_ADDR);
@@ -370,18 +368,19 @@
 
   (_ifr -> ifr_flags) = (ifp . flags);
   if ((ioctl (_socket, SIOCSIFFLAGS, _ifr)) < 0)
-	  throw IFaceException(errno, "setting interface configuration for " + name());
+	  throw wibble::exception::IFace("setting interface configuration for " + name());
 }
 
-IFace::IFace(const string& name) throw (SystemException, IFaceException, MIIException)
+IFace::IFace(const string& name) throw (wibble::exception::System, wibble::exception::IFace, wibble::exception::MII)
 	: _socket(-1), _ifr(0), _up(false), _run(false), _conn(false), _has_iface(false), _has_mii(true)
 {
 	_socket = socket(AF_INET, SOCK_DGRAM, 0);
 	if (_socket == -1)
-		throw SystemException(errno, "opening generic socket");
+		throw wibble::exception::System("opening generic socket");
 
 	_ifr = new struct ifreq;
-	int sz =  (IFNAMSIZ - 1) <? name.size();
+	int sz = name.size();
+	if (sz > IFNAMSIZ - 1) sz = IFNAMSIZ - 1;
 	memcpy(_ifr->ifr_name, name.data(), sz);
 	_ifr->ifr_name[sz] = 0;
 
@@ -401,11 +400,11 @@
 	return _ifr->ifr_name;
 }
 
-void IFace::update() throw (IFaceException, MIIException)
+void IFace::update() throw (wibble::exception::IFace, wibble::exception::MII)
 {
 	try {
 		if (ioctl(_socket, SIOCGIFFLAGS, _ifr) == -1)
-			throw IFaceException(errno, "getting interface flags for " + name());
+			throw wibble::exception::IFace("getting interface flags for " + name());
 			
 		_up = (_ifr->ifr_flags & IFF_UP) != 0;
 		_run = (_ifr->ifr_flags & IFF_RUNNING) != 0;
@@ -434,23 +433,23 @@
 			/*
 			
 			if (ioctl(_socket, SIOCGMIIPHY, _ifr) == -1)
-				throw MIIException(errno, "getting MII informations for " + name());
+				throw wibble::exception::MII("getting MII informations for " + name());
 
 			unsigned short* ifdata = (unsigned short *)&(_ifr->ifr_data);
 			ifdata[1] = 1;
 			if (ioctl(_socket, SIOCGMIIREG, _ifr) == -1)
-				throw MIIException(errno, "reading MII register for " + name());
+				throw wibble::exception::MII("reading MII register for " + name());
 
 			_conn = (ifdata[3] & 0x0016) == 0x0004;
 			*/
 		}
-	} catch (MIIException& e) {
+	} catch (wibble::exception::MII& e) {
 		//log_info("Link beat detection failed for interface " + name() +
 		//		": disabling it.  Error was: " +
 		//		e.type() + ": " + e.desc());
-		verbose("Exception during link beat detection: %s: %.*s\n", e.type(), PFSTR(e.desc()));
+		verbose("Exception during link beat detection: %s: %s\n", e.type(), e.desc().c_str());
 		_has_mii = false;
-	} catch (IFaceException& e) {
+	} catch (wibble::exception::IFace& e) {
 		if (_has_iface)
 		{
 			//log_info("Interface query failed for interface " + name() +
@@ -481,7 +480,7 @@
  * Return true if the interface was down
  */
 if_params IFace::initBroadcast(int timeout)
-	throw (IFaceException)
+	throw (wibble::exception::IFace)
 {
 	if_params res;
 	read_interface_configuration(&res);
@@ -516,13 +515,13 @@
 		((struct sockaddr_in*)&_ifr->ifr_addr)->sin_addr.s_addr = INADDR_ANY;
 
 		if ((ioctl (_socket, SIOCSIFADDR, _ifr)) < 0)
-			throw IFaceException(errno, "setting interface configuration for " + name());
+			throw wibble::exception::IFace("setting interface configuration for " + name());
   
 		if ((ioctl (_socket, SIOCGIFFLAGS, _ifr)) < 0)
-			throw IFaceException(errno, string("getting interface flags for ") + name());
+			throw wibble::exception::IFace(string("getting interface flags for ") + name());
 		_ifr->ifr_flags |= IFF_UP | IFF_RUNNING;
 		if ((ioctl (_socket, SIOCSIFFLAGS, _ifr)) < 0)
-			throw IFaceException(errno, "setting interface configuration for " + name());
+			throw wibble::exception::IFace("setting interface configuration for " + name());
 
 		/*
 		storeEmptyIP(ifp.addr);
@@ -550,7 +549,7 @@
 }
 
 if_params IFace::getConfiguration()
-	throw (IFaceException)
+	throw (wibble::exception::IFace)
 {
 	if_params res;
 	read_interface_configuration(&res);
@@ -558,7 +557,7 @@
 }
 
 if_params IFace::setConfiguration(const if_params& config)
-	throw (IFaceException)
+	throw (wibble::exception::IFace)
 {
 	if_params res;
 	read_interface_configuration(&res);
@@ -573,14 +572,9 @@
 	string s_bcst = addr_flags & IFP_VALID_BROADADDR ? inet_ntoa(broadaddr.sin_addr) : "invalid";
 	string s_mask = addr_flags & IFP_VALID_NETMASK ? inet_ntoa(netmask.sin_addr) : "invalid";
 
-	printf("%.*s dst %.*s bcast %.*s nm %.*s flags %hu aflags %i hwaddrtype %i\n",
-			PFSTR(s_addr),
-			PFSTR(s_dest),
-			PFSTR(s_bcst),
-			PFSTR(s_mask),
-			flags,
-			addr_flags,
-			hwaddr.sa_family);
+	cout << s_addr << " dst " << s_dest << " bcast " << s_bcst << " nm "
+		 << s_mask << " flags " << flags << " aflags " << addr_flags
+		 << " hwaddrtype " << hwaddr.sa_family << endl;
 }
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/IFace.h
==============================================================================
--- trunk/src/IFace.h	(original)
+++ trunk/src/IFace.h	Fri Aug 25 17:57:07 2006
@@ -27,31 +27,37 @@
 
 #include <time.h>
 #include <netinet/in.h>
-#include "Exception.h"
+#include <wibble/exception.h>
 
 struct ifreq;
 
+namespace wibble {
+namespace exception {
+
 /// Exception raised when an error occurs accessing an interface
-class IFaceException : public SystemException
+class IFace : public System
 {
 public:
-	IFaceException(int errorCode, const std::string& context) throw ()
-		: SystemException(errorCode, context) {}
+	IFace(const std::string& context) throw () : System(context) {}
+	IFace(int code, const std::string& context) throw () : System(code, context) {}
 
-	virtual const char* type() const throw () { return "IFaceException"; }
+	virtual const char* type() const throw () { return "IFace"; }
 };
 
 /// Exception raised when an error occurs accessing the MII functionality of an
 /// interface
-class MIIException : public IFaceException
+class MII : public IFace
 {
 public:
-	MIIException(int errorCode, const std::string& context) throw ()
-		: IFaceException(errorCode, context) {}
+	MII(const std::string& context) throw () : IFace(context) {}
+	MII(int code, const std::string& context) throw () : IFace(code, context) {}
 
-	virtual const char* type() const throw () { return "MIIException"; }
+	virtual const char* type() const throw () { return "MII"; }
 };
 
+}
+}
+
 /// Configuration data for a network interface
 struct if_params
 {
@@ -80,17 +86,17 @@
 	bool _has_mii;
 
 	void read_interface_configuration(struct if_params *ifp)
-		throw (IFaceException);
+		throw (wibble::exception::IFace);
 
 	void write_interface_configuration(const struct if_params& ifp)
-		throw (IFaceException);
+		throw (wibble::exception::IFace);
 
-	int mdio_read(int location) throw (MIIException);
+	int mdio_read(int location) throw (wibble::exception::MII);
 
 public:
 	/// Create an object to access informations of the interface whose name
 	/// is in `name'
-	IFace(const std::string& name) throw (SystemException, IFaceException, MIIException);
+	IFace(const std::string& name) throw (wibble::exception::System, wibble::exception::IFace, wibble::exception::MII);
 	~IFace() throw ();
 
 	/// Tell if the interface was up at the time of the last update()
@@ -110,25 +116,25 @@
 	std::string name() const throw ();
 
 	/// Update the interface status
-	void update() throw (IFaceException, MIIException);
+	void update() throw (wibble::exception::IFace, wibble::exception::MII);
 
 	/// Bring the interface up in broadcast mode
 	/**
 	 * Returns a struct if_params descriving the previous interface configuration
 	 */
-	if_params initBroadcast(int timeout) throw (IFaceException);
+	if_params initBroadcast(int timeout) throw (wibble::exception::IFace);
 
 	/// Get the interface configuration
 	/**
 	 * Returns a struct if_params descriving the current interface configuration
 	 */
-	if_params getConfiguration() throw (IFaceException);
+	if_params getConfiguration() throw (wibble::exception::IFace);
 
 	/// Set the interface configuration
 	/**
 	 * Returns a struct if_params descriving the previous interface configuration
 	 */
-	if_params setConfiguration(const if_params& config) throw (IFaceException);
+	if_params setConfiguration(const if_params& config) throw (wibble::exception::IFace);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/IfaceParser.cc
==============================================================================
--- trunk/src/IfaceParser.cc	(original)
+++ trunk/src/IfaceParser.cc	Fri Aug 25 17:57:07 2006
@@ -28,14 +28,12 @@
 #endif
 
 #include "IfaceParser.h"
-#include "stringf.h"
 #include "Regexp.h"
 #include "Environment.h"
 
 #include <map>
 
 using namespace std;
-using namespace stringf;
 
 class Tokenizer
 {
@@ -68,7 +66,6 @@
  * parser.
  */
 void IfaceParser::parse(FILE* input, ScanConsumer& sc)
-	throw (Exception)
 {
 #define ATLINESTART "^[[:blank:]]*(guessnet[0-9]*[[:blank:]]+)?test[0-9]*(-|[[:blank:]]+)"
 #define MACPATTERN "[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}"

Modified: trunk/src/IfaceParser.h
==============================================================================
--- trunk/src/IfaceParser.h	(original)
+++ trunk/src/IfaceParser.h	Fri Aug 25 17:57:07 2006
@@ -27,7 +27,7 @@
 class IfaceParser
 {
 public:
-	static void parse(FILE* in, ScanConsumer& sc) throw (Exception);
+	static void parse(FILE* in, ScanConsumer& sc);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Aug 25 17:57:07 2006
@@ -7,13 +7,7 @@
 
 sbin_PROGRAMS = guessnet guessnet-scan
 
-#noinst_PROGRAMS = tgp
-
-#tgp_SOURCES = stringf.cc Exception.cc nettypes.cc Parser.cc GuessnetParser.cc
-
 guessnet_SOURCES = \
-	stringf.cc \
-	Exception.cc \
 	Buffer.cc \
 	Thread.cc \
 	Exec.cc \
@@ -22,7 +16,6 @@
 	Parser.cc \
 	Scans.cc \
 	ScanBag.cc \
-	CommandlineParser.cc \
 	IFace.cc \
 	Environment.cc \
 	GuessnetEnvironment.cc \
@@ -37,16 +30,13 @@
 	GuessnetParser.cc \
 	IfaceParser.cc \
 	guessnet.cc
-guessnet_LDADD = @LIBNET_LIBS@
+guessnet_LDADD = @LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 guessnet_scan_SOURCES = \
-	stringf.cc \
-	Exception.cc \
 	Buffer.cc \
 	Thread.cc \
 	Exec.cc \
 	ChildProcess.cc \
-	CommandlineParser.cc \
 	IFace.cc \
 	Environment.cc \
 	nettypes.cc \
@@ -54,22 +44,20 @@
 	NetWatcher.cc \
 	TrafficScanner.cc \
 	guessnet-scan.cc
-guessnet_scan_LDADD = @LIBNET_LIBS@
+guessnet_scan_LDADD = @LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 #install-exec-hook:
 #	ln -s guessnet $(sbindir)/guessnet-ifupdown
 
-INCLUDES=@LIBNET_CFLAGS@ -DSCRIPTDIR=\"@scriptdir@\" -DCOMPILE_TESTSUITE
+INCLUDES=@LIBNET_CFLAGS@ @LIBWIBBLE_CFLAGS@ -DSCRIPTDIR=\"@scriptdir@\" -DCOMPILE_TESTSUITE
 
 EXTRA_DIST = \
 	Buffer.h \
 	ChildProcess.h \
-	CommandlineParser.h \
 	DHCPScanner.h \
 	Environment.h \
 	ethtool-kernel.h \
 	ethtool-local.h \
-	Exception.h \
 	Exec.h \
 	GuessnetEnvironment.h \
 	GuessnetParser.h \
@@ -90,7 +78,6 @@
 	Scanner.h \
 	Scans.h \
 	ScriptScanner.h \
-	stringf.h \
 	Thread.h \
 	TrafficScanner.h \
 	wireless.15.h \

Modified: trunk/src/NetBuffer.h
==============================================================================
--- trunk/src/NetBuffer.h	(original)
+++ trunk/src/NetBuffer.h	Fri Aug 25 17:57:07 2006
@@ -24,6 +24,8 @@
 
 #include "Buffer.h"
 
+#include <wibble/exception.h>
+
 class NetBuffer : public Buffer
 {
 public:
@@ -62,27 +64,27 @@
 	}
 	
 	template<class T>
-	const T* cast(unsigned int ofs = 0) const throw (ConsistencyCheckException)
+	const T* cast(unsigned int ofs = 0) const throw (wibble::exception::Consistency)
 	{
 		if (cursor + ofs + sizeof(T) >= size())
-			throw ConsistencyCheckException("Trying to read past the end of the buffer");
+			throw wibble::exception::Consistency("reading from buffer", "tried to read past the end of the buffer");
 		return (const T*)((const char*)data() + cursor + ofs);
 	}
 
-	NetBuffer operator+(unsigned int ofs) throw (ConsistencyCheckException)
+	NetBuffer operator+(unsigned int ofs) throw (wibble::exception::Consistency)
 	{
 		NetBuffer res(*this);
 		res.skip(ofs);
 		return res;
 	}
 	
-	NetBuffer& operator+=(unsigned int ofs) throw (ConsistencyCheckException)
+	NetBuffer& operator+=(unsigned int ofs) throw (wibble::exception::Consistency)
 	{
 		skip(ofs);
 		return *this;
 	}
 	
-	const NetBuffer after(unsigned int ofs) const throw (ConsistencyCheckException)
+	const NetBuffer after(unsigned int ofs) const throw (wibble::exception::Consistency)
 	{
 		NetBuffer res(*this);
 		res.skip(ofs);
@@ -90,7 +92,7 @@
 	}
 	
 	template<class T>
-	const NetBuffer after() const throw (ConsistencyCheckException)
+	const NetBuffer after() const throw (wibble::exception::Consistency)
 	{
 		NetBuffer res(*this);
 		res.skip(sizeof(T));
@@ -98,15 +100,15 @@
 	}
 
 	template<class T>
-	void skip() throw (ConsistencyCheckException)
+	void skip() throw (wibble::exception::Consistency)
 	{
 		skip(sizeof(T));
 	}
 
-	void skip(unsigned int t) throw (ConsistencyCheckException)
+	void skip(unsigned int t) throw (wibble::exception::Consistency)
 	{
 		if (cursor + t >= size())
-			throw ConsistencyCheckException("Trying to skip past the end of the buffer");
+			throw wibble::exception::Consistency("reading from buffer", "tried to skip past the end of the buffer");
 		cursor += t;
 	}
 };

Modified: trunk/src/NetSender.cc
==============================================================================
--- trunk/src/NetSender.cc	(original)
+++ trunk/src/NetSender.cc	Fri Aug 25 17:57:07 2006
@@ -70,12 +70,12 @@
 	Buffer nextPacket() throw ();
 
 public:
-	NetSenderImpl(const string& iface) throw (SystemException, libnetException)
+	NetSenderImpl(const string& iface) throw (wibble::exception::System, wibble::exception::Libnet)
 		: _ref(0), quitRequested(false), iface(iface), local_hardware_addr(0)
 	{
 		DEBUG("LN-Starting\n");
 		if (!(ln_context = libnet_init(LIBNET_LINK_ADV, const_cast<char*>(iface.c_str()), ln_errbuf)))
-			throw libnetException(ln_errbuf, "opening link interface");
+			throw wibble::exception::Libnet(ln_errbuf, "opening link interface");
 		DEBUG("LN-Started %p\n", ln_context);
 	}
 	~NetSenderImpl() throw ()
@@ -97,7 +97,7 @@
 	bool unref() throw () { return --_ref == 0; }
 
 	/// Get the ethernet MAC address for this interface
-	struct libnet_ether_addr* getMACAddress() throw (libnetException);
+	struct libnet_ether_addr* getMACAddress() throw (wibble::exception::Libnet);
 	libnet_t *getLibnetContext() throw () { return ln_context; }
 
 
@@ -107,13 +107,13 @@
 	void requestQuit() throw ();
 };
 
-struct libnet_ether_addr* NetSenderImpl::getMACAddress() throw (libnetException)
+struct libnet_ether_addr* NetSenderImpl::getMACAddress() throw (wibble::exception::Libnet)
 {
 	MutexLock lock(macMutex);
 
 	if (!local_hardware_addr)
 		if (!(local_hardware_addr = libnet_get_hwaddr(ln_context)))
-			throw libnetException(ln_context, "trying to determine local hardware address");
+			throw wibble::exception::Libnet(ln_context, "trying to determine local hardware address");
 
 	return local_hardware_addr;
 }
@@ -136,7 +136,7 @@
 {
 	MutexLock lock(pktMutex);
 	
-	int totDelay = 0;
+	//int totDelay = 0;
 	for (list<TimedPacket>::iterator i = scheduledPackets.begin();
 			i != scheduledPackets.end(); i++)
 	{
@@ -250,12 +250,12 @@
 			}
 			DEBUG("NS-Main-GotPacket\n");
 			if (libnet_write_link(ln_context, (u_char*)b.data(), b.size()) == -1)
-				throw libnetException(ln_context, "writing raw ethernet packet");
+				throw wibble::exception::Libnet(ln_context, "writing raw ethernet packet");
 			DEBUG("NS-Main-Written\n");
 			//fprintf(stderr, "Sent packet\n");
 		}
-	} catch (Exception& e) {
-		error("%s: %.*s.  Quitting NetSender thread.\n", e.type(), PFSTR(e.desc()));
+	} catch (std::exception& e) {
+		error("%s.  Quitting NetSender thread.\n", e.what());
 	}
 	DEBUG("NS-Main-Quit\n");
 	return 0;
@@ -263,7 +263,7 @@
 
 
 
-NetSender::NetSender(const string& iface) throw (SystemException, libnetException)
+NetSender::NetSender(const string& iface) throw (wibble::exception::System, wibble::exception::Libnet)
 {
 	impl = new NetSenderImpl(iface);
 	impl->ref();
@@ -277,7 +277,7 @@
 	impl = ns.impl;
 }
 
-NetSender::~NetSender() throw (SystemException)
+NetSender::~NetSender() throw (wibble::exception::System)
 {
 	DEBUG("NS~-Start\n");
 	if (impl && impl->unref())
@@ -287,8 +287,8 @@
 			//impl->cancel();
 			impl->requestQuit();
 			DEBUG("NS~-Canceled\n");
-		} catch (SystemException& e) {
-			warning("%s: %.*s in NetSender destructor\n", e.type(), PFSTR(e.desc()));
+		} catch (wibble::exception::System& e) {
+			warning("%s in NetSender destructor\n", e.what());
 		}
 		DEBUG("NS~-Deleting\n");
 		delete impl;
@@ -296,7 +296,7 @@
 	}
 }
 
-NetSender& NetSender::operator=(const NetSender& ns) throw (SystemException)
+NetSender& NetSender::operator=(const NetSender& ns) throw (wibble::exception::System)
 {
 	if (ns.impl)
 		ns.impl->ref();  // Do it early to correctly handle the case of x = x;
@@ -305,8 +305,8 @@
 		try {
 			//impl->cancel();
 			impl->requestQuit();
-		} catch (SystemException& e) {
-			warning("%s: %.*s cancelling ovewritten thread in NetSender::operator=\n", e.type(), PFSTR(e.desc()));
+		} catch (wibble::exception::System& e) {
+			warning("%s cancelling overwritten thread in NetSender::operator=\n", e.what());
 		}
 		delete impl;
 	}
@@ -314,7 +314,7 @@
 	return *this;
 }
 
-struct libnet_ether_addr* NetSender::getMACAddress() throw (libnetException)
+struct libnet_ether_addr* NetSender::getMACAddress() throw (wibble::exception::Libnet)
 {
 	return impl->getMACAddress();
 }

Modified: trunk/src/NetSender.h
==============================================================================
--- trunk/src/NetSender.h	(original)
+++ trunk/src/NetSender.h	Fri Aug 25 17:57:07 2006
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "Exception.h"
+#include <wibble/exception.h>
 #include "Buffer.h"
 #include "nettypes.h"
 #include <string>
@@ -30,38 +30,41 @@
 	#include <libnet.h>
 }
 
-class libnetException : public ConsistencyCheckException
+namespace wibble {
+namespace exception {
+
+class Libnet : public Generic
 {
 protected:
 	std::string _libnet_errmsg;
 
 public:
-	libnetException(const libnet_t* ln_context, const std::string& context) throw ()
-		: ConsistencyCheckException(context)
+	Libnet(const libnet_t* ln_context, const std::string& context) throw ()
+		: Generic(context)
 	{
 		const char* msg = libnet_geterror(const_cast<libnet_t*>(ln_context));
 		_libnet_errmsg = msg ? msg : "(can't provide an error message: libnet returned null from libnet_geterror!)";
 	}
-	libnetException(const char* ln_errbuf, const std::string& context) throw ()
-		: ConsistencyCheckException(context), _libnet_errmsg(ln_errbuf) {}
-	libnetException(const std::string& context) throw ()
-		: ConsistencyCheckException(context), _libnet_errmsg() {}
-	~libnetException() throw () {}
+	Libnet(const char* ln_errbuf, const std::string& context) throw ()
+		: Generic(context), _libnet_errmsg(ln_errbuf) {}
+	Libnet(const std::string& context) throw ()
+		: Generic(context), _libnet_errmsg() {}
+	~Libnet() throw () {}
 
-	virtual const char* type() const throw ()
-	{
-		return "libnetException";
-	}
+	virtual const char* type() const throw () { return "libnet"; }
 
 	virtual std::string desc() const throw ()
 	{
 		if (_libnet_errmsg.size())
-			return _libnet_errmsg + " " + _context;
+			return _libnet_errmsg;
 		else
-			return "Unknown libnet error " + _context;
+			return "Unknown libnet error";
 	}
 };
 
+}
+}
+
 /*
  * Injects ethernet packets to a given interface.
  *
@@ -75,12 +78,12 @@
 	NetSenderImpl* impl;
 	
 public:
-	NetSender(const std::string& iface) throw (SystemException, libnetException);
+	NetSender(const std::string& iface) throw (wibble::exception::System, wibble::exception::Libnet);
 	NetSender(const NetSender& f) throw ();
-	~NetSender() throw (SystemException);
-	NetSender& operator=(const NetSender& f) throw (SystemException);
+	~NetSender() throw (wibble::exception::System);
+	NetSender& operator=(const NetSender& f) throw (wibble::exception::System);
 
-	struct libnet_ether_addr* getMACAddress() throw (libnetException);
+	struct libnet_ether_addr* getMACAddress() throw (wibble::exception::Libnet);
 	libnet_t *getLibnetContext() throw ();
 
 	// Send packet once

Modified: trunk/src/NetWatcher.cc
==============================================================================
--- trunk/src/NetWatcher.cc	(original)
+++ trunk/src/NetWatcher.cc	Fri Aug 25 17:57:07 2006
@@ -60,7 +60,7 @@
 	virtual void* main() throw ();
 
 public:
-	NetWatcherImpl(const string& iface) throw (SystemException, pcapException)
+	NetWatcherImpl(const string& iface) throw (wibble::exception::System, wibble::exception::Pcap)
 		: _ref(0), iface(iface), _canceled(false)
 	{
 		char errbuf[PCAP_ERRBUF_SIZE];
@@ -69,7 +69,7 @@
 		// address on the interface
 		if (!(pcap_interface = pcap_open_live (
 						(char*)iface.c_str(), captureSize, 1, 500, errbuf)))
-			throw pcapException (errbuf, "initializing pcap packet capture library");
+			throw wibble::exception::Pcap (errbuf, "initializing pcap packet capture library");
 	}
 	~NetWatcherImpl() throw ()
 	{
@@ -145,7 +145,7 @@
 		{
 			unsigned char* packet = (u_char *)pcap_next (pcap_interface, &pcap_header);
 			if (packet == 0)
-				throw pcapException (pcap_geterr(pcap_interface), "getting a new packet from the network");
+				throw wibble::exception::Pcap (pcap_geterr(pcap_interface), "getting a new packet from the network");
 
 			NetBuffer pkt(packet, captureSize, false);
 
@@ -213,15 +213,15 @@
 				}
 			}
 		}
-	} catch (Exception& e) {
-		error("%s: %.*s.  Quitting NetWatcher thread.\n", e.type(), PFSTR(e.desc()));
+	} catch (std::exception& e) {
+		error("%s.  Quitting NetWatcher thread.\n", e.what());
 	}
 	return 0;
 }
 
 
 
-NetWatcher::NetWatcher(const string& iface) throw (SystemException, pcapException)
+NetWatcher::NetWatcher(const string& iface) throw (wibble::exception::System, wibble::exception::Pcap)
 {
 	impl = new NetWatcherImpl(iface);
 	impl->ref();
@@ -235,7 +235,7 @@
 	impl = ns.impl;
 }
 
-NetWatcher::~NetWatcher() throw (SystemException)
+NetWatcher::~NetWatcher() throw (wibble::exception::System)
 {
 	if (impl && impl->unref())
 	{
@@ -244,7 +244,7 @@
 	}
 }
 
-NetWatcher& NetWatcher::operator=(const NetWatcher& ns) throw (SystemException)
+NetWatcher& NetWatcher::operator=(const NetWatcher& ns) throw (wibble::exception::System)
 {
 	if (ns.impl)
 		ns.impl->ref();  // Do it early to correctly handle the case of x = x;
@@ -279,8 +279,8 @@
 			impl->cancel();
 			impl->join();
 			impl->canceled(true);
-		} catch (SystemException& e) {
-			warning("%s: %.*s when shutting down NetWatcher\n", e.type(), PFSTR(e.desc()));
+		} catch (wibble::exception::System& e) {
+			warning("%s when shutting down NetWatcher\n", e.what());
 		}
 }
 

Modified: trunk/src/NetWatcher.h
==============================================================================
--- trunk/src/NetWatcher.h	(original)
+++ trunk/src/NetWatcher.h	Fri Aug 25 17:57:07 2006
@@ -21,37 +21,40 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
-#include "Exception.h"
+#include <wibble/exception.h>
 #include "NetBuffer.h"
 #include "nettypes.h"
 #include <string>
 
-class pcapException : public ConsistencyCheckException
+namespace wibble {
+namespace exception {
+
+class Pcap : public Generic
 {
 protected:
 	std::string _pcap_errmsg;
 
 public:
-	pcapException(const std::string& pcap_errmsg, const std::string& context) throw ()
-		: ConsistencyCheckException(context), _pcap_errmsg(pcap_errmsg) {}
-	pcapException(const std::string& context) throw ()
-		: ConsistencyCheckException(context), _pcap_errmsg() {}
-	~pcapException() throw () {}
+	Pcap(const std::string& pcap_errmsg, const std::string& context) throw ()
+		: Generic(context), _pcap_errmsg(pcap_errmsg) {}
+	Pcap(const std::string& context) throw ()
+		: Generic(context), _pcap_errmsg() {}
+	~Pcap() throw () {}
 
-	virtual const char* type() const throw ()
-	{
-		return "pcapException";
-	}
+	virtual const char* type() const throw () { return "pcap"; }
 
 	virtual std::string desc() const throw ()
 	{
 		if (_pcap_errmsg.size())
-			return _pcap_errmsg + " " + _context;
+			return _pcap_errmsg;
 		else
-			return "Unknown pcap error " + _context;
+			return "Unknown pcap error";
 	}
 };
 
+}
+}
+
 class PacketListener
 {
 public:
@@ -75,12 +78,12 @@
 	NetWatcherImpl* impl;
 	
 public:
-	NetWatcher(const std::string& iface) throw (SystemException, pcapException);
+	NetWatcher(const std::string& iface) throw (wibble::exception::System, wibble::exception::Pcap);
 	NetWatcher(const NetWatcher& f) throw ();
-	~NetWatcher() throw (SystemException);
-	NetWatcher& operator=(const NetWatcher& f) throw (SystemException);
+	~NetWatcher() throw (wibble::exception::System);
+	NetWatcher& operator=(const NetWatcher& f) throw (wibble::exception::System);
 
-	struct ether_addr* getMACAddress() throw (pcapException);
+	struct ether_addr* getMACAddress() throw (wibble::exception::Pcap);
 
 	void addARPListener(PacketListener* pl) throw ();
 	void addDHCPListener(PacketListener* pl) throw ();

Modified: trunk/src/PacketMaker.cc
==============================================================================
--- trunk/src/PacketMaker.cc	(original)
+++ trunk/src/PacketMaker.cc	Fri Aug 25 17:57:07 2006
@@ -60,7 +60,7 @@
 
 Buffer PacketMaker::makePingRequest(const ether_addr& mac, const IPAddress& src) throw ()
 {
-	unsigned char ether_broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+	//unsigned char ether_broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 	//unsigned char ether_no_addr[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 	struct libnet_ether_addr* localmac = sender.getMACAddress();
 	libnet_t* ln_context = sender.getLibnetContext();
@@ -95,7 +95,7 @@
 				0,			// payload len
 				ln_context,
 				0) == -1)
-		throw libnetException(ln_context, "Building ICMPv4 echo packet");
+		throw wibble::exception::Libnet(ln_context, "Building ICMPv4 echo packet");
 
 	if (libnet_build_ipv4(
 				LIBNET_IPV4_H + LIBNET_ICMPV4_ECHO_H + 0,
@@ -111,7 +111,7 @@
 				0,
 				ln_context,
 				0) == -1)
-		throw libnetException(ln_context, "Building IPv4 packet");
+		throw wibble::exception::Libnet(ln_context, "Building IPv4 packet");
 
 	if (libnet_build_ethernet(
 			(u_char*)&mac,
@@ -119,7 +119,7 @@
 			ETHERTYPE_IP,
 			NULL, 0,
 			ln_context, 0) == -1)
-		throw libnetException(ln_context, "Building Ethernet packet");
+		throw wibble::exception::Libnet(ln_context, "Building Ethernet packet");
 
 	// Construct the packet
 	return buffer_from_libnet(ln_context);

Modified: trunk/src/Parser.cc
==============================================================================
--- trunk/src/Parser.cc	(original)
+++ trunk/src/Parser.cc	Fri Aug 25 17:57:07 2006
@@ -19,25 +19,54 @@
  */
 
 #include "Parser.h"
-#include "stringf.h"
+#include <sstream>
 
-using namespace std;
-using namespace stringf;
+namespace wibble {
+namespace exception {
 
-string ParserException::desc() const throw ()
+static std::string parserContext(const std::string& file, int line) throw ()
 {
-	if (_file.size() > 0)
-		if (_line != -1)
-			return _file + ":" + fmt(_line) + ": " + _context;
-		else
-			return _file + ":" + _context;
+	std::stringstream str;
+	if (line == -1)
+		str << "parsing file " << file;
 	else
-		if (_line != -1)
-			return fmt(_line) + ": " + _context;
-		else
-			return _context;
+		str << file << ":" << line;
+	return str.str();
 }
 
+static std::string parserContext(int line) throw ()
+{
+	std::stringstream str;
+	str << "parsing line " << line;
+	return str.str();
+}
+
+Parser::Parser(const std::string& file, int line, const std::string& error) throw ()
+	: Consistency(parserContext(file, line), error), m_file(file), m_line(line) {}
+Parser::Parser(int line, const std::string& error) throw ()
+	: Consistency(parserContext(line), error), m_line(line) {}
+Parser::Parser(const std::string& context, const std::string& error) throw ()
+	: Consistency(context, error), m_line(-1) {}
+
+void Parser::setLocation(const std::string file, int line) throw ()
+{
+	m_file = file;
+	if (line != -1) m_line = line;
+	m_context[0] = parserContext(m_file, m_line);
+}
+
+void Parser::setLocation(int line) throw ()
+{
+	if (line != -1) m_line = line;
+	m_context[0] = parserContext(m_file, m_line);
+}
+
+}
+}
+
+
+using namespace std;
+
 string DefaultScan::signature() const throw ()
 {
 	return "default";

Modified: trunk/src/Parser.h
==============================================================================
--- trunk/src/Parser.h	(original)
+++ trunk/src/Parser.h	Fri Aug 25 17:57:07 2006
@@ -22,41 +22,40 @@
  */
 
 #include <string>
-#include "Exception.h"
+#include <wibble/exception.h>
 #include "Scans.h"
 #include "ScanConsumer.h"
 #include "nettypes.h"
 
-class ParserException: public ContextException
+namespace wibble {
+namespace exception {
+
+class Parser: public Consistency
 {
 protected:
-	std::string _file;
-	int _line;
+	std::string m_file;
+	int m_line;
 
 public:
-	ParserException(const std::string& file, int line, const std::string& message) throw ()
-		: ContextException(message), _file(file), _line(line) {}
-	ParserException(int line, const std::string& message) throw ()
-		: ContextException(message), _line(line) {}
-	ParserException(const std::string& message) throw ()
-		: ContextException(message), _line(-1) {}
-	~ParserException() throw () {}
-
-	int line() const throw () { return _line; }
-	int line(int line) throw () { return _line = line; }
-
-	const std::string& file() const throw () { return _file; }
-	std::string file() throw () { return _file; }
-	std::string file(const std::string file) throw () { return _file = file; }
-
-	virtual const char* type() const throw ()
-	{
-		return "ParserException";
-	}
+	Parser(const std::string& file, int line, const std::string& error) throw ();
+	Parser(int line, const std::string& error) throw ();
+	Parser(const std::string& context, const std::string& error) throw ();
+	~Parser() throw () {}
+
+	int line() const throw () { return m_line; }
+	const std::string& file() const throw () { return m_file; }
+	std::string file() throw () { return m_file; }
+
+	void setLocation(const std::string file, int line = -1) throw ();
+	void setLocation(int line) throw ();
+
+	virtual const char* type() const throw () { return "Parser"; }
 
-	virtual std::string desc() const throw ();
 };
 
+}
+}
+
 
 // vim:set ts=4 sw=4:
 #endif

Modified: trunk/src/PeerScanner.cc
==============================================================================
--- trunk/src/PeerScanner.cc	(original)
+++ trunk/src/PeerScanner.cc	Fri Aug 25 17:57:07 2006
@@ -79,7 +79,7 @@
 		const PeerScan* scan = *i;
 		if (!scan->hasIP() && MAC_MATCHES(&scan->mac(), packet_header->ether_shost))
 		{
-			debug("Got reply from %.*s\n", PFSTR(fmt(scan->mac())));
+			debug("Got reply from %s\n", fmt(scan->mac()).c_str());
 			succeeded(*i);
 		}
 	}
@@ -97,7 +97,7 @@
 		in_addr* ipv4_him = arp_get_sip(arp_header);
 		ether_addr* mac_him = arp_get_sha(arp_header);
 
-		debug("Got ARP reply from %.*s %.*s\n", PFSTR(fmt(IPAddress(*ipv4_him))), PFSTR(fmt(*mac_him)));
+		debug("Got ARP reply from %s %s\n", fmt(IPAddress(*ipv4_him)).c_str(), fmt(*mac_him).c_str());
 
 		//IPv4_FROM_LIBNET(ipv4_me, arp_header->ar_tpa);
 		//IPv4_FROM_ARP(ipv4_him, arp_header->ar_spa);
@@ -118,7 +118,8 @@
 
 			if (match)
 			{
-				debug("ARP reply from %.*s %.*s matches\n", PFSTR(fmt(IPAddress(*ipv4_him))), PFSTR(fmt(*mac_him)));
+				debug("ARP reply from %s %s matches\n",
+						fmt(IPAddress(*ipv4_him)).c_str(), fmt(*mac_him).c_str());
 				succeeded(*i);
 			}
 		}

Modified: trunk/src/ProcessRunner.cc
==============================================================================
--- trunk/src/ProcessRunner.cc	(original)
+++ trunk/src/ProcessRunner.cc	Fri Aug 25 17:57:07 2006
@@ -28,13 +28,12 @@
 
 #include <sys/types.h>	// pid_t
 #include <sys/wait.h>	// wait
-#include <errno.h>
 
 #include <map>
 #include <queue>
+#include <sstream>
 
 using namespace std;
-using namespace stringf;
 
 //#define DEBUG(args...) fprintf(stderr, ##args)
 #define DEBUG(args...) do {} while(0)
@@ -81,14 +80,14 @@
 			cmd = string(SCRIPTDIR) + "/" + cmdline;
 		}
 		if (!canRun(cmd))
-			throw SystemException(errno, "checking if " + cmd + " can be executed");
+			throw wibble::exception::System("checking if " + cmd + " can be executed");
 		runner.addArg(cmd);
 
 		DEBUG("SCRIPT MAIN Running %.*s\n", PFSTR(cmdline));
 
 		runner.exec();
-	} catch (Exception& e) {
-		fprintf(stderr, "%s: %.*s\n", e.type(), PFSTR(e.desc()));
+	} catch (std::exception& e) {
+		fprintf(stderr, "%s\n", e.what());
 	}
 	return 1;
 }
@@ -109,7 +108,7 @@
 		ProcessListener* listener;
 
 		ProcData(const string& tag, const string& cmdline, ProcessListener* listener) throw ();
-		void run() throw (SystemException);
+		void run() throw (wibble::exception::System);
 	};
 
 	queue<ProcData> queuedForRunning;
@@ -129,7 +128,7 @@
 	/// reaches 0
 	bool unref() throw () { return --_ref == 0; }
 
-	void shutdown() throw (SystemException)
+	void shutdown() throw (wibble::exception::System)
 	{
 		if (running)
 		{
@@ -158,7 +157,7 @@
 	proc = new ChildProcess(script);
 }
 
-void ProcessRunnerImpl::ProcData::run() throw (SystemException)
+void ProcessRunnerImpl::ProcData::run() throw (wibble::exception::System)
 {
 	proc->fork();
 	delete script;
@@ -233,7 +232,7 @@
 						queuedForRunning.pop();
 						d.run();
 						proclist.insert(make_pair(d.proc->pid(), d));
-						debug("run process %.*s pid: %d\n", PFSTR(d.tag), d.proc->pid());
+						debug("run process %s pid: %d\n", d.tag.c_str(), d.proc->pid());
 					}
 				}
 			}
@@ -245,12 +244,12 @@
 				for (map<pid_t, ProcData>::iterator i = proclist.begin();
 						i != proclist.end(); i++)
 				{
-					DEBUG("PRI Perform shutdown of %.*s\n", PFSTR(i->second.tag));
-					debug("still running: %.*s (%d)\n", PFSTR(i->second.tag), i->second.proc->pid());
+					DEBUG("PRI Perform shutdown of %s\n", i->second.tag.c_str());
+					debug("still running: %s (%d)\n", i->second.tag.c_str(), i->second.proc->pid());
 					i->second.proc->kill(9);
 					i->second.proc->wait();
 					delete i->second.proc;
-					DEBUG("PRI Performed shutdown of %.*s\n", PFSTR(i->second.tag));
+					DEBUG("PRI Performed shutdown of %s\n", i->second.tag.c_str());
 				}
 				proclist.clear();
 				DEBUG("PRI Performed shutdown\n");
@@ -270,7 +269,7 @@
 			debug("Wait gave %d\n", pid);
 
 			if (pid == -1)
-				throw SystemException(errno, "Waiting for a child to terminate");
+				throw wibble::exception::System("Waiting for a child to terminate");
 			if (pid == 0)
 			{
 				/*
@@ -293,9 +292,13 @@
 
 				map<pid_t, ProcData>::iterator i = proclist.find(pid);
 				if (i == proclist.end())
-					throw ConsistencyCheckException("Child pid " + fmt(pid) + " exited, but has not been found in the child pid list");
+				{
+					stringstream str;
+					str << "Child pid " << pid << " exited, but has not been found in the child pid list";
+					throw wibble::exception::Consistency(str.str());
+				}
 
-				debug("Notifying termination of %.*s\n", PFSTR(i->second.tag));
+				debug("Notifying termination of %s\n", i->second.tag.c_str());
 
 				string tag = i->second.tag;
 				
@@ -306,15 +309,15 @@
 				// Notify the listener
 				i->second.listener->handleTermination(tag, status);
 			}
-		} catch (Exception& e) {
-			fprintf(stderr, "%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		} catch (std::exception& e) {
+			fprintf(stderr, "%s\n", e.what());
 		}
 	}
 }
 
 
 
-ProcessRunner::ProcessRunner() throw (SystemException)
+ProcessRunner::ProcessRunner() throw (wibble::exception::System)
 {
 	impl = new ProcessRunnerImpl();
 	impl->ref();
@@ -328,13 +331,13 @@
 	impl = ns.impl;
 }
 
-ProcessRunner::~ProcessRunner() throw (SystemException)
+ProcessRunner::~ProcessRunner() throw (wibble::exception::System)
 {
 	if (impl && impl->unref())
 		shutdown();
 }
 
-ProcessRunner& ProcessRunner::operator=(const ProcessRunner& ns) throw (SystemException)
+ProcessRunner& ProcessRunner::operator=(const ProcessRunner& ns) throw (wibble::exception::System)
 {
 	if (ns.impl)
 		ns.impl->ref();  // Do it early to correctly handle the case of x = x;
@@ -350,7 +353,7 @@
 	return impl->addProcess(tag, cmdline, pl);
 }
 
-void ProcessRunner::shutdown() throw (SystemException)
+void ProcessRunner::shutdown() throw (wibble::exception::System)
 {
 	impl->shutdown();
 }

Modified: trunk/src/ProcessRunner.h
==============================================================================
--- trunk/src/ProcessRunner.h	(original)
+++ trunk/src/ProcessRunner.h	Fri Aug 25 17:57:07 2006
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "Exception.h"
+#include <wibble/exception.h>
 #include <string>
 
 class ProcessListener
@@ -44,14 +44,14 @@
 	ProcessRunnerImpl* impl;
 	
 public:
-	ProcessRunner() throw (SystemException);
+	ProcessRunner() throw (wibble::exception::System);
 	ProcessRunner(const ProcessRunner& f) throw ();
-	~ProcessRunner() throw (SystemException);
-	ProcessRunner& operator=(const ProcessRunner& f) throw (SystemException);
+	~ProcessRunner() throw (wibble::exception::System);
+	ProcessRunner& operator=(const ProcessRunner& f) throw (wibble::exception::System);
 
 	void addProcess(const std::string& tag, const std::string& cmdline, ProcessListener* pl) throw ();
 
-	void shutdown() throw (SystemException);
+	void shutdown() throw (wibble::exception::System);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/Regexp.cc
==============================================================================
--- trunk/src/Regexp.cc	(original)
+++ trunk/src/Regexp.cc	Fri Aug 25 17:57:07 2006
@@ -19,41 +19,47 @@
  */
 
 #include "Regexp.h"
+#include <wibble/exception.tcc>
 
-using namespace stringf;
 using namespace std;
 
-////// RegexpException
+namespace wibble {
+namespace exception {
 
-RegexpException::RegexpException(const regex_t& re, int code,
-								const string& context) throw ()
-							: SystemException(code, context)
+////// wibble::exception::Regexp
+
+Regexp::Regexp(const regex_t& re, int code,
+				const string& context) throw ()
+			: Generic(context), m_code(code)
 {
 	int size = 64;
 	char* msg = new char[size];
 	int nsize = regerror(code, &re, msg, size);
-	if (nsize < size)
+	if (nsize > size)
 	{
 		delete[] msg;
 		msg = new char[nsize];
 		regerror(code, &re, msg, nsize);
 	}
-	_message = msg;
-	delete msg;
+	m_message = msg;
+	delete[] msg;
+}
+
+}
 }
 
 
 ////// Regexp
 
 Regexp::Regexp(const string& expr, int match_count, int flags)
-	throw (RegexpException) : pmatch(0), nmatch(match_count)
+	throw (wibble::exception::Regexp) : pmatch(0), nmatch(match_count)
 {
 	if (match_count == 0)
 		flags |= REG_NOSUB;
 
 	int res = regcomp(&re, expr.c_str(), flags);
 	if (res)
-		throw RegexpException(re, res, "Compiling regexp \"" + expr + "\"");
+		throw wibble::exception::Regexp(re, res, "Compiling regexp \"" + expr + "\"");
 
 	if (match_count > 0)
 		pmatch = new regmatch_t[match_count];
@@ -68,7 +74,7 @@
 	
 
 bool Regexp::match(const string& str, int flags)
-	throw(RegexpException)
+	throw(wibble::exception::Regexp)
 {
 	int res;
 	
@@ -84,14 +90,14 @@
 	{
 		case 0:	return true;
 		case REG_NOMATCH: return false;
-		default: throw RegexpException(re, res, "Matching string \"" + str + "\"");
+		default: throw wibble::exception::Regexp(re, res, "Matching string \"" + str + "\"");
 	}
 }
 
-string Regexp::operator[](int idx) throw (OutOfRangeException)
+string Regexp::operator[](int idx) throw (wibble::exception::OutOfRange)
 {
 	if (idx > nmatch)
-		throw ValOutOfRangeException<int>("getting submatch of regexp", "index", idx, 0, nmatch);
+		throw wibble::exception::ValOutOfRange<int>("index", idx, 0, nmatch, "getting submatch of regexp");
 
 	if (pmatch[idx].rm_so == -1)
 		return string();

Modified: trunk/src/Regexp.h
==============================================================================
--- trunk/src/Regexp.h	(original)
+++ trunk/src/Regexp.h	Fri Aug 25 17:57:07 2006
@@ -21,26 +21,36 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
-#include <Exception.h>
+#include <wibble/exception.h>
 #include <sys/types.h>
 #include <regex.h>
 
-////// RegexpException
+namespace wibble {
+namespace exception {
 
-class RegexpException : public SystemException
+////// wibble::exception::Regexp
+
+class Regexp : public wibble::exception::Generic
 {
 protected:
-	std::string _message;
+	int m_code;
+	std::string m_message;
 
 public:
-	RegexpException(const regex_t& re, int code, const std::string& context)
+	Regexp(const regex_t& re, int code, const std::string& context)
 		throw ();
-	~RegexpException() throw () {}
+	~Regexp() throw () {}
+
+	/// Get the regexp error code associated to the exception
+	virtual int code() const throw () { return m_code; }
 
-	virtual const char* type() const throw () { return "RegexpException"; }
-	virtual std::string desc() const throw () { return _message + " " + _context; }
+	virtual const char* type() const throw () { return "Regexp"; }
+	virtual std::string desc() const throw () { return m_message; }
 };
 
+}
+}
+
 class Regexp
 {
 protected:
@@ -50,18 +60,18 @@
 	std::string lastMatch;
 
 public:
-	Regexp(const std::string& expr, int match_count = 0, int flags = 0) throw (RegexpException);
+	Regexp(const std::string& expr, int match_count = 0, int flags = 0) throw (wibble::exception::Regexp);
 	~Regexp() throw ();
 
-	bool match(const std::string& str, int flags = 0) throw (RegexpException);
+	bool match(const std::string& str, int flags = 0) throw (wibble::exception::Regexp);
 	
-	std::string operator[](int idx) throw (OutOfRangeException);
+	std::string operator[](int idx) throw (wibble::exception::OutOfRange);
 };
 
 class ExtendedRegexp : public Regexp
 {
 public:
-	ExtendedRegexp(const std::string& expr, int match_count = 0, int flags = 0) throw (RegexpException)
+	ExtendedRegexp(const std::string& expr, int match_count = 0, int flags = 0) throw (wibble::exception::Regexp)
 		: Regexp(expr, match_count, flags | REG_EXTENDED) {}
 };
 

Modified: trunk/src/ScanBag.cc
==============================================================================
--- trunk/src/ScanBag.cc	(original)
+++ trunk/src/ScanBag.cc	Fri Aug 25 17:57:07 2006
@@ -1,4 +1,5 @@
 #include "ScanBag.h"
+#include <iostream>
 
 using namespace std;
 
@@ -86,13 +87,13 @@
 {
 	for (const_iterator i = begin(); i != end(); i++)
 	{
-		printf("%.*s: ", PFSTR(i->first));
+		cout << i->first << ": ";
 		for (set<string>::const_iterator j = i->second.begin(); j != i->second.end(); j++)
 			if (j == i->second.begin())
-				printf("%.*s", PFSTR(*j));
+				cout << *j;
 			else
-				printf(", %.*s", PFSTR(*j));
-		printf("\n");
+				cout << ", ", *j;
+		cout << endl;
 	}
 }
 

Modified: trunk/src/Thread.cc
==============================================================================
--- trunk/src/Thread.cc	(original)
+++ trunk/src/Thread.cc	Fri Aug 25 17:57:07 2006
@@ -19,25 +19,23 @@
  */
 
 #include "Thread.h"
-#include "stringf.h"
-
+#include <sstream>
 
 using namespace std;
-using namespace stringf;
 
 void* Thread::Starter(void* parm) throw ()
 {
 	return ((Thread*)parm)->main();
 }
 
-void Thread::start() throw (SystemException)
+void Thread::start() throw (wibble::exception::System)
 {
 	int res = pthread_create(&thread, 0, Starter, this);
 	if (res != 0)
-		throw SystemException(res, string("Creating ") + threadTag() + " thread");
+		throw wibble::exception::System(res, string("Creating ") + threadTag() + " thread");
 }
 
-void Thread::startDetached() throw (SystemException)
+void Thread::startDetached() throw (wibble::exception::System)
 {
 	pthread_attr_t thread_attrs;
 	pthread_attr_init(&thread_attrs);
@@ -45,37 +43,41 @@
 	int res = pthread_create(&thread, &thread_attrs, Starter, this);
 	pthread_attr_destroy(&thread_attrs);
 	if (res != 0)
-		throw SystemException(res, string("Creating ") + threadTag() + " thread");
+		throw wibble::exception::System(res, string("Creating ") + threadTag() + " thread");
 }
 
-void* Thread::join() throw (SystemException)
+void* Thread::join() throw (wibble::exception::System)
 {
 	void* result = 0;
 	int res = pthread_join(thread, &result);
 	if (res != 0)
-		throw SystemException(res, string("Joining ") + threadTag() + " thread");
+		throw wibble::exception::System(res, string("Joining ") + threadTag() + " thread");
 	return result;
 }
 
-void Thread::detach() throw (SystemException)
+void Thread::detach() throw (wibble::exception::System)
 {
 	int res = pthread_detach(thread);
 	if (res != 0)
-		throw SystemException(res, string("Detaching ") + threadTag() + " thread");
+		throw wibble::exception::System(res, string("Detaching ") + threadTag() + " thread");
 }
 
-void Thread::cancel() throw (SystemException)
+void Thread::cancel() throw (wibble::exception::System)
 {
 	int res = pthread_cancel(thread);
 	if (res != 0)
-		throw SystemException(res, string("Cancelling ") + threadTag() + " thread");
+		throw wibble::exception::System(res, string("Cancelling ") + threadTag() + " thread");
 }
 
-void Thread::kill(int signal) throw (SystemException)
+void Thread::kill(int signal) throw (wibble::exception::System)
 {
 	int res = pthread_kill(thread, signal);
 	if (res != 0)
-		throw SystemException(res, string("Killing ") + threadTag() + " thread with signal " + fmt(signal));
+	{
+		std::stringstream str;
+		str << "Killing " << threadTag() << " thread with signal " << signal;
+		throw wibble::exception::System(res, str.str());
+	}
 }
 
 

Modified: trunk/src/Thread.h
==============================================================================
--- trunk/src/Thread.h	(original)
+++ trunk/src/Thread.h	Fri Aug 25 17:57:07 2006
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
 
-#include <Exception.h>
+#include <wibble/exception.h>
 #include <pthread.h>
 #include <signal.h>
 
@@ -62,22 +62,22 @@
 	virtual ~Thread() throw () {}
 
 	/// Start the thread
-	void start() throw (SystemException);
+	void start() throw (wibble::exception::System);
 
 	/// Start the thread in the detached state
-	void startDetached() throw (SystemException);
+	void startDetached() throw (wibble::exception::System);
 
 	/// Join the thread
-	void* join() throw (SystemException);
+	void* join() throw (wibble::exception::System);
 
 	/// Put the thread in the detached state
-	void detach() throw (SystemException);
+	void detach() throw (wibble::exception::System);
 
 	/// Send a cancellation request to the thread
-	void cancel() throw (SystemException);
+	void cancel() throw (wibble::exception::System);
 
 	/// Sent a signal to the thread
-	void kill(int signal) throw (SystemException);
+	void kill(int signal) throw (wibble::exception::System);
 };
 
 // vim:set ts=4 sw=4:

Modified: trunk/src/TrafficScanner.cc
==============================================================================
--- trunk/src/TrafficScanner.cc	(original)
+++ trunk/src/TrafficScanner.cc	Fri Aug 25 17:57:07 2006
@@ -28,7 +28,6 @@
 }
 
 using namespace std;
-using namespace stringf;
 
 /*
 static string fmt_ip(unsigned int ip) throw ()

Modified: trunk/src/guessnet-scan.cc
==============================================================================
--- trunk/src/guessnet-scan.cc	(original)
+++ trunk/src/guessnet-scan.cc	Fri Aug 25 17:57:07 2006
@@ -31,9 +31,7 @@
 #include "TrafficScanner.h"
 #include "Mutex.h"
 #include "Environment.h"
-#include "stringf.h"
 
-#include "CommandlineParser.h"
 #include "IFace.h"
 
 #include <stdio.h>
@@ -47,11 +45,47 @@
 #include <net/if.h>
 #include <unistd.h>     // close
 
-
 #include <set>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+
+#include <wibble/commandline/parser.h>
+
+namespace wibble {
+namespace commandline {
+
+struct GuessnetOptions : public StandardParserWithManpage
+{
+public:
+	BoolOption* verbose;
+	BoolOption* debug;
+	IntOption* timeout;
+	IntOption* inittime;
+
+	GuessnetOptions() 
+		: StandardParserWithManpage(APPNAME, VERSION, 8, "enrico at enricozini.org")
+	{
+		usage = "[options] [iface]";
+		description = "Guess the current network location";
+
+		verbose = add<BoolOption>("verbose", 'v', "verbose", "",
+						"enable verbose output");
+		debug = add<BoolOption>("debug", 0, "debug", "",
+						"enable debugging output (including verbose output)");
+		timeout = add<IntOption>("timeout", 't', "timeout", "seconds",
+						"timeout (in seconds) used to wait for response packets"
+						" (defaults to 5 seconds)");
+		inittime = add<IntOption>("inittime", 0, "init-timeout", "seconds",
+						"time (in seconds) to wait for the interface to initialize"
+						" when not found already up (defaults to 3 seconds)");
+	}
+};
+
+}
+}
 
 using namespace std;
-using namespace stringf;
 
 class MainScanner
 {
@@ -72,17 +106,20 @@
 	{
 		unsigned char ipfmt[4];
 		memcpy(ipfmt, &ip, 4);
-		return fmt("%d.%d.%d.%d",
-				(int)ipfmt[0], (int)ipfmt[1], (int)ipfmt[2], (int)ipfmt[3]);
+		stringstream str;
+		str << (int)ipfmt[0] << '.' << (int)ipfmt[1] << '.' << (int)ipfmt[2] << '.' << (int)ipfmt[3];
+		return str.str();
 	}
 
 	inline string fmt_mac(long long int mac) throw ()
 	{
 		unsigned char macfmt[6];
 		memcpy(macfmt, &mac, 6);
-		return fmt("%02x:%02x:%02x:%02x:%02x:%02x",
-				(int)macfmt[0], (int)macfmt[1], (int)macfmt[2],
-				(int)macfmt[3], (int)macfmt[4], (int)macfmt[5]);
+		stringstream str;
+		str << hex << setfill('0') << setw(2)
+			<< (int)macfmt[0] << ':' << (int)macfmt[1] << ':' << (int)macfmt[2] << ':'
+			<< (int)macfmt[3] << ':' << (int)macfmt[4] << ':' << (int)macfmt[5];
+		return str.str();
 	}
 
 	unsigned int netaddr_to_netmask(unsigned int na) throw ()
@@ -103,7 +140,7 @@
 	}
 
 public:
-	MainScanner() throw (Exception) :
+	MainScanner() :
 		sender(Environment::get().iface()),
 		watcher(Environment::get().iface()),
 		trafficScanner(sender),
@@ -114,7 +151,7 @@
 
 	int candidateCount() const throw () { return cand_count; }
 	
-	void shutdown() throw (Exception)
+	void shutdown()
 	{
 		watcher.shutdown();
 	}
@@ -122,19 +159,19 @@
 	void printResults() throw ()
 	{
 		string s;
-		printf("iface <name> inet static\n");
-		printf("\taddress <addr>\n");
+		cout << "iface <name> inet static" << endl;
+		cout << "\taddress <addr>" << endl;
 
 		unsigned int network = trafficScanner.guessed_netaddr;
 		s = fmt_ip(network);
-		printf("\tnetwork %.*s\n", PFSTR(s));
+		cout << "\tnetwork " << s << endl;
 
 		unsigned int netmask = netaddr_to_netmask(network);
 		s = fmt_ip(netmask);
-		printf("\tnetmask %.*s\n", PFSTR(s));
+		cout << "\tnetmask " << s << endl;
 
 		s = fmt_ip(network | ~netmask);
-		printf("\tbroadcast %.*s\n", PFSTR(s));
+		cout << "\tbroadcast " << s << endl;
 
 		for (set<TrafficScanner::mac_key>::const_iterator i = trafficScanner.guessed_gateways.begin();
 				i != trafficScanner.guessed_gateways.end(); i++)
@@ -142,76 +179,53 @@
 			TrafficScanner::HostData& od = trafficScanner.scanData[*i];
 
 			s = fmt_ip(od.addr);
-			printf("\tgateway %.*s\n", PFSTR(s));
+			cout << "\tgateway " << s << endl;
 		
 			string m = fmt_mac(*i);
-			printf("\ttest-peer address %.*s mac %.*s\n", PFSTR(s), PFSTR(m));
+			cout << "\ttest-peer address " << s << " mac " << m << endl;
 		}
 	}
 };
 
 int main (int argc, const char *argv[])
 {
-	CommandlineParser opts(APPNAME, "[options] [ethernet_interface]", "Guess the current network location");
-	opts.add("version", 'V', "version", "print the program version, then exit");
-	opts.add("timeout", 't', "timeout",
-			"timeout (in seconds) used to wait for response packets"
-			" (defaults to 5 seconds)", "seconds");
-	opts.add("inittime", 0, "init-timeout",
-			"time (in seconds) to wait for the interface to initialize"
-			" when not found already up (defaults to 3 seconds)");
-	opts.add("verbose", 'v', "verbose",
-			"enable verbose operations");
-	opts.add("debug", 0, "debug", 
-			"enable debugging output");
+	// Access the interface
+	try {
+	wibble::commandline::GuessnetOptions opts;
 
 	// Process the commandline
-	if (!opts.parse(argc, argv))
-	{
-		opts.printHelp();
-		return 1;
-	}
-	if (opts.get("help").defined())
-	{
-		opts.printHelp();
+	if (opts.parse(argc, argv))
 		return 0;
-	}
-	if (opts.get("version").defined())
-	{
-		printf("%s " VERSION "\n", APPNAME);
-		return 0;
-	}
 
 	// Set verbosity
-	Environment::get().verbose(opts.get("verbose").defined());
-	Environment::get().debug(opts.get("debug").defined());
+	Environment::get().verbose(opts.verbose->boolValue());
+	Environment::get().debug(opts.debug->boolValue());
 
 	// Check user id
 	if (geteuid() != 0)
 		fatal_error("You must run this command as root.");
 
 	// Find out the interface to be tested
-	if (argc > 1)
-		Environment::get().iface(argv[1]);
+	if (opts.hasNext())
+		Environment::get().iface(opts.next());
 
 	// Find out the test timeout
-	if (opts.get("timeout").defined())
-		Environment::get().timeout(opts.get("timeout").intVal());
+	if (opts.timeout->boolValue())
+		Environment::get().timeout(opts.timeout->intValue());
 
 	// Find out the init timeout
-	if (opts.get("inittime").defined())
-		Environment::get().initTimeout(opts.get("inittime").intVal());
+	if (opts.inittime->boolValue())
+		Environment::get().initTimeout(opts.inittime->intValue());
 
-	// Access the interface
-	try {
-		IFace iface(Environment::get().iface());
+
+	IFace iface(Environment::get().iface());
 
 	bool iface_was_down;
 	if_params saved_iface_cfg;
 
 	try {
 		// Install the handler for unexpected exceptions
-		InstallUnexpected installUnexpected;
+		wibble::exception::InstallUnexpected installUnexpected;
 		//FILE* input = 0;
 
 		/* Check if we have to bring up the interface; if yes, do it */
@@ -259,8 +273,8 @@
 
 		// We've shutdown the threads: restore original signals
 		pthread_sigmask(SIG_SETMASK, &oldsigs, &sigs);
-	} catch (Exception& e) {
-		fatal_error("%s: %.*s", e.type(), PFSTR(e.desc()));
+	} catch (std::exception& e) {
+		fatal_error("%s", e.what());
 		return 1;
 	}
 
@@ -268,8 +282,8 @@
 	if (iface_was_down)
 		iface.setConfiguration(saved_iface_cfg);
 
-	} catch (Exception& e) {
-		fatal_error("%s: %.*s", e.type(), PFSTR(e.desc()));
+	} catch (std::exception& e) {
+		fatal_error("%s", e.what());
 		return 1;
 	}
 

Modified: trunk/src/guessnet.cc
==============================================================================
--- trunk/src/guessnet.cc	(original)
+++ trunk/src/guessnet.cc	Fri Aug 25 17:57:07 2006
@@ -37,7 +37,6 @@
 #include "Mutex.h"
 #include "GuessnetEnvironment.h"
 #include "ScanBag.h"
-#include "stringf.h"
 
 #include "IFace.h"
 
@@ -53,14 +52,13 @@
 #include <unistd.h>     // close, geteuid
 #include <pwd.h>		// getpwuid
 
-
 #include <set>
 #include <vector>
+#include <iostream>
 
 #include "Thread.h"
 
 using namespace std;
-using namespace stringf;
 
 class ScanRunner : public ScannerListener, public ScanConsumer
 {
@@ -94,8 +92,8 @@
 			candidates = scanbag.notify(scan);
 			if (candidates.size() == 1)
 				waitCond.broadcast();
-		} catch (Exception& e) {
-			error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		} catch (std::exception& e) {
+			error("%s\n", e.what());
 		}
 	}
 
@@ -156,8 +154,8 @@
 	bool canceled() const throw () { return _canceled; }
 	bool canceled(bool val) throw () { return _canceled = val; }
 	
-	void shutdown() throw (Exception) { canceled(true); }
-	void startScans() throw (SystemException, libnetException, pcapException)
+	void shutdown() { canceled(true); }
+	void startScans()
 	{
 		printf("Scans contents:\n");
 		scanbag.dump();
@@ -168,38 +166,38 @@
 			const Scan* scan = *i;
 			if (const PeerScan* s = dynamic_cast<const PeerScan*>(scan))
 			{
-				debug("Will check network %.*s for IP address %.*s (MAC %.*s)\n",
-						PFSTR(s->name()), PFSTR(fmt(s->ip())), PFSTR(fmt(s->mac())));
+				debug("Will check network %s for IP address %s (MAC %s)\n",
+						s->name().c_str(), fmt(s->ip()).c_str(), fmt(s->mac()).c_str());
 				cand_count++;
 			}
 			else if (const LinkBeatScan* s = dynamic_cast<const LinkBeatScan*>(scan))
 			{
 				//warning("Link-beat detection currently disabled\n");
-				debug("Will test for link beat.  If absent, will return %.*s\n",
-						PFSTR(s->name()));
+				debug("Will test for link beat.  If absent, will return %s\n",
+						s->name().c_str());
 				cand_count++;
 			}
 			else if (const ScriptScan* s = dynamic_cast<const ScriptScan*>(scan))
 			{
-				debug("Will use command '%.*s' to test %.*s\n",
-						PFSTR(s->cmdline()), PFSTR(s->name()));
+				debug("Will use command '%s' to test %s\n",
+						s->cmdline().c_str(), s->name().c_str());
 				cand_count++;
 			}
 			if (const DHCPScan* s = dynamic_cast<const DHCPScan*>(scan))
 			{
-				debug("Will check network %.*s for DHCP service\n",
-						PFSTR(s->name()));
+				debug("Will check network %s for DHCP service\n",
+						s->name().c_str());
 				cand_count++;
 			}
 			else if (const DefaultScan* s = dynamic_cast<const DefaultScan*>(scan))
 			{
-				debug("Default test is %.*s\n",
-						PFSTR(s->name()));
+				debug("Default test is %s\n",
+						s->name().c_str());
 				cand_count++;
 			}
 			else
 				//printf("Unknown test %p\n", scan);
-				printf("Unknown test %.*s: %.*s\n", PFSTR(scan->name()), PFSTR(scan->signature()));
+				printf("Unknown test %s: %s\n", scan->name().c_str(), scan->signature().c_str());
 		}
 
 		start();
@@ -216,11 +214,9 @@
 			const list<const Scan*>& cands = scanbag.getScans();
 			for (list<const Scan*>::const_iterator i = cands.begin();
 					i != cands.end(); i++)
-			{
-				printf("%2d: %.*s (%.*s)\n", num++, PFSTR((*i)->name()), PFSTR((*i)->signature()));
-			}
-			printf(" 0: quit\n");
-			printf("> ");
+				cout << num++ << ": " << (*i)->name() << " (" << (*i)->signature() << ")" << endl;
+			cout << " 0: quit" << endl;
+			cout << "> ";
 			unsigned int res;
 			fscanf(in, "%d", &res);
 			if (res == 0)
@@ -247,12 +243,12 @@
 	ProcessRunner* runner;
 
 	PeerScanner* peerScanner;
-	ScriptScanner* scriptScanner;
 	DHCPScanner* dhcpScanner;
+	ScriptScanner* scriptScanner;
 
 	IFace& iface;
 
-	void startNetScanning() throw (SystemException, libnetException, pcapException)
+	void startNetScanning()
 	{
 		if (!sender)
 			sender = new NetSender(GuessnetEnvironment::get().iface());
@@ -260,7 +256,7 @@
 			watcher = new NetWatcher(GuessnetEnvironment::get().iface());
 	}
 
-	void startPeerScanner() throw (SystemException, libnetException, pcapException)
+	void startPeerScanner()
 	{
 		if (peerScanner)
 			return;
@@ -269,7 +265,7 @@
 		peerScanner = new PeerScanner(*sender, this);
 	}
 
-	void startScriptScanner() throw (SystemException)
+	void startScriptScanner()
 	{
 		if (scriptScanner)
 			return;
@@ -278,7 +274,7 @@
 		scriptScanner = new ScriptScanner(*runner, this);
 	}
 
-	void startDHCPScanner() throw (SystemException, libnetException, pcapException)
+	void startDHCPScanner()
 	{
 		if (dhcpScanner)
 			return;
@@ -288,11 +284,11 @@
 	}
 
 public:
-	MainScanner(IFace& iface) throw (Exception) : ScanRunner(),
+	MainScanner(IFace& iface) : ScanRunner(),
 		sender(0), watcher(0), runner(0), peerScanner(0), dhcpScanner(0), scriptScanner(0),
 		iface(iface) {}
 
-	void shutdown() throw (Exception)
+	void shutdown()
 	{
 		if (watcher)
 			watcher->shutdown();
@@ -300,7 +296,7 @@
 			runner->shutdown();
 	}
 	
-	void startScans() throw (SystemException, libnetException, pcapException)
+	void startScans()
 	{
 		for (list<const Scan*>::const_iterator i = scanbag.getScans().begin();
 				i != scanbag.getScans().end(); i++)
@@ -308,8 +304,8 @@
 			const Scan* scan = *i;
 			if (const PeerScan* s = dynamic_cast<const PeerScan*>(scan))
 			{
-				debug("Will check network %.*s for IP address %.*s (MAC %.*s)\n",
-						PFSTR(s->name()), PFSTR(fmt(s->ip())), PFSTR(fmt(s->mac())));
+				debug("Will check network %s for IP address %s (MAC %s)\n",
+						s->name().c_str(), fmt(s->ip()).c_str(), fmt(s->mac()).c_str());
 
 				startPeerScanner();
 				peerScanner->addCandidate(s);
@@ -320,7 +316,7 @@
 			{
 				//warning("Link-beat detection currently disabled\n");
 				debug("Will test for link beat.  If absent, will return %.*s\n",
-						PFSTR(s->name()));
+						s->name().c_str());
 
 				iface.update();
 				if (!iface.has_mii())
@@ -335,8 +331,8 @@
 			}
 			else if (const ScriptScan* s = dynamic_cast<const ScriptScan*>(scan))
 			{
-				debug("Will use command '%.*s' to test %.*s\n",
-						PFSTR(s->cmdline()), PFSTR(s->name()));
+				debug("Will use command '%s' to test %s\n",
+						s->cmdline().c_str(), s->name().c_str());
 
 				startScriptScanner();
 				scriptScanner->addCandidate(s);
@@ -345,8 +341,8 @@
 			}
 			else if (const DHCPScan* s = dynamic_cast<const DHCPScan*>(scan))
 			{
-				debug("Will check network %.*s for DHCP service\n",
-						PFSTR(s->name()));
+				debug("Will check network %s for DHCP service\n",
+						s->name().c_str());
 
 				startDHCPScanner();
 				dhcpScanner->addCandidate(s);
@@ -355,13 +351,12 @@
 			}
 			else if (const DefaultScan* s = dynamic_cast<const DefaultScan*>(scan))
 			{
-				debug("Default test is %.*s\n",
-						PFSTR(s->name()));
+				debug("Default test is %s\n", s->name().c_str());
 				cand_count++;
 			}
 			else
 				//printf("Unknown test %p\n", scan);
-				printf("Unknown test %.*s: %.*s\n", PFSTR(scan->name()), PFSTR(scan->signature()));
+				printf("Unknown test %s: %s\n", scan->name().c_str(), scan->signature().c_str());
 		}
 
 		if (peerScanner)
@@ -394,7 +389,7 @@
 int main (int argc, const char *argv[])
 {
 	// Install the handler for unexpected exceptions
-	InstallUnexpected installUnexpected;
+	wibble::exception::InstallUnexpected installUnexpected;
 
 	// Access the interface
 	try {
@@ -418,7 +413,7 @@
 			iface_was_down = !iface.up();
 			if (iface_was_down)
 			{
-				verbose("Interface %.*s was down: initializing for broadcast\n", PFSTR(iface.name()));
+				verbose("Interface %s was down: initializing for broadcast\n", iface.name().c_str());
 				saved_iface_cfg = iface.initBroadcast(GuessnetEnvironment::get().initTimeout());
 			}
 
@@ -445,7 +440,7 @@
 			debug("Initialized test subsystems\n");
 
 			scanner.handleScan(new DefaultScan(GuessnetEnvironment::get().defprof()));
-			debug("Added \"default\" test %.*s\n", PFSTR(GuessnetEnvironment::get().defprof()));
+			debug("Added \"default\" test %s\n", GuessnetEnvironment::get().defprof().c_str());
 
 			for (vector<const Scan*>::const_iterator i = scans.begin(); i != scans.end(); i++)
 				scanner.handleScan(*i);
@@ -472,12 +467,12 @@
 			// Output the profile name we found
 			if (profile.size())
 			{
-				printf("%.*s\n", PFSTR(profile));
+				cout << profile << endl;
 			} else {
-				printf("%.*s\n", PFSTR(GuessnetEnvironment::get().defprof()));
+				cout << GuessnetEnvironment::get().defprof() << endl;
 			}
-		} catch (Exception& e) {
-			error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		} catch (std::exception& e) {
+			error("%s\n", e.what());
 			if (geteuid() != 0)
 			{
 				struct passwd *p = getpwuid(geteuid());
@@ -490,8 +485,8 @@
 		if (iface_was_down)
 			iface.setConfiguration(saved_iface_cfg);
 
-	} catch (Exception& e) {
-		error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+	} catch (std::exception& e) {
+		error("%s\n", e.what());
 		if (geteuid() != 0)
 		{
 			struct passwd *p = getpwuid(geteuid());

Modified: trunk/src/nettypes.cc
==============================================================================
--- trunk/src/nettypes.cc	(original)
+++ trunk/src/nettypes.cc	Fri Aug 25 17:57:07 2006
@@ -21,43 +21,42 @@
  */
 
 #include "nettypes.h"
-#include "stringf.h"
+#include <iomanip>
+#include <sstream>
 
 using namespace std;
-using namespace stringf;
-
 
 /* Format an IPv4 address in a static char buffer */
 string fmt(const IPAddress& addr) throw ()
 {
-	string buf;
+	stringstream buf;
 	for (int i = 0; i < 4; i++)
 	{
 		if (i > 0)
-			buf += '.';
-		buf += fmt((int)(((const unsigned char*)(const in_addr*)addr)[i]));
+			buf << '.';
+		buf << (int)(((const unsigned char*)(const in_addr*)addr)[i]);
 	}
-	return buf;
+	return buf.str();
 }
 
 /* Format a MAC address in a static char buffer */
 string fmt(const struct ether_addr& addr) throw ()
 {
-	string buf;
+	stringstream buf;
 	for (int i = 0; i < 6; i++)
 	{
 		if (i > 0)
-			buf += ':';
-		buf += fmt("%02x", (int)(((const unsigned char*)&addr)[i]));
+			buf << ':';
+		buf << hex << setfill('0') << setw(2) << (int)(((const unsigned char*)&addr)[i]);
 	}
-	return buf;
+	return buf.str();
 }
 
-IPAddress::IPAddress(const std::string& str) throw (ConsistencyCheckException)
+IPAddress::IPAddress(const std::string& str) throw (wibble::exception::Consistency)
 {
 	if (inet_aton(str.c_str(), &addr) == 0)
 		// Not valid
-		throw ConsistencyCheckException("parsing IP address \"" + str + "\"");
+		throw wibble::exception::Consistency("parsing IP address \"" + str + "\"", "not a valid IP address");
 }
 
 bool IPAddress::operator==(const IPAddress& ip) const

Modified: trunk/src/nettypes.h
==============================================================================
--- trunk/src/nettypes.h	(original)
+++ trunk/src/nettypes.h	Fri Aug 25 17:57:07 2006
@@ -33,7 +33,7 @@
 								 */
 #include <net/if_arp.h>
 
-#include "Exception.h"
+#include <wibble/exception.h>
 
 extern "C" {
 #include <libnet.h>
@@ -92,7 +92,7 @@
 	IPAddress(const in_addr& addr) throw () : addr(addr) {}
 
 	// Parse an IPV4 address from a dotted-quad string
-	IPAddress(const std::string& str) throw (ConsistencyCheckException);
+	IPAddress(const std::string& str) throw (wibble::exception::Consistency);
 
 	unsigned long int s_addr() const throw () { return addr.s_addr; }
 	const in_addr_t* s_addr_p() const throw () { return &(addr.s_addr); }
@@ -100,6 +100,8 @@
 	operator const struct in_addr*() const { return &addr; }
 	bool operator==(const IPAddress& addr) const;
 	bool operator!=(const IPAddress& addr) const;
+
+	std::string toString() const;
 };
 
 /* Format an IPv4 address in a static char buffer */

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Fri Aug 25 17:57:07 2006
@@ -1,13 +1,11 @@
 TESTS = guessnet-test
 check_PROGRAMS = guessnet-test
 guessnet_test_SOURCES = tut-main.cpp
-guessnet_test_LDADD = @LIBNET_LIBS@ \
+guessnet_test_LDADD = \
 	../src/Buffer.o			\
 	../src/ChildProcess.o		\
-	../src/CommandlineParser.o	\
 	../src/DHCPScanner.o		\
 	../src/Environment.o		\
-	../src/Exception.o		\
 	../src/Exec.o			\
 	../src/GuessnetEnvironment.o	\
 	../src/GuessnetParser.o		\
@@ -24,9 +22,9 @@
 	../src/ScanBag.o		\
 	../src/Scans.o			\
 	../src/ScriptScanner.o		\
-	../src/stringf.o		\
 	../src/Thread.o			\
-	../src/TrafficScanner.o
+	../src/TrafficScanner.o		\
+	@LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 
 #DEFINES := $(shell libnet-config --defines)
@@ -44,58 +42,54 @@
 
 test_iface_SOURCES = \
 	test-iface.cc
-test_iface_LDADD = @LIBNET_LIBS@ \
-	../src/Exception.o \
+test_iface_LDADD = \
 	../src/Environment.o \
-	../src/IFace.o
+	../src/IFace.o \
+	@LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 test_netsender_SOURCES = \
 	test-netsender.cc
-test_netsender_LDADD = @LIBNET_LIBS@ \
-	../src/stringf.o \
+test_netsender_LDADD = \
 	../src/nettypes.o \
-	../src/Exception.o \
 	../src/Environment.o \
 	../src/Buffer.o \
 	../src/Thread.o \
 	../src/IFace.o \
 	../src/PacketMaker.o \
 	../src/NetWatcher.o \
-	../src/NetSender.o
+	../src/NetSender.o \
+	@LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 test_netwatcher_SOURCES = \
 	test-netwatcher.cc
-test_netwatcher_LDADD = @LIBNET_LIBS@ \
-	../src/stringf.o \
-	../src/Exception.o \
+test_netwatcher_LDADD = \
 	../src/Environment.o \
 	../src/Buffer.o \
 	../src/Thread.o \
 	../src/IFace.o \
-	../src/NetWatcher.o
+	../src/NetWatcher.o \
+	@LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 test_processrunner_SOURCES = \
 	test-processrunner.cc
-test_processrunner_LDADD = @LIBNET_LIBS@ \
-	../src/stringf.o \
-	../src/Exception.o \
+test_processrunner_LDADD = \
 	../src/Environment.o \
 	../src/Buffer.o \
 	../src/Thread.o \
 	../src/Exec.o \
 	../src/ChildProcess.o \
-	../src/ProcessRunner.o
+	../src/ProcessRunner.o \
+	@LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
 test_scanbag_SOURCES = \
 	test-scanbag.cc
-test_scanbag_LDADD = @LIBNET_LIBS@ \
-	../src/stringf.o \
+test_scanbag_LDADD = \
 	../src/nettypes.o \
-	../src/Exception.o \
 	../src/Environment.o \
 	../src/ScanBag.o \
-	../src/Parser.o
+	../src/Parser.o \
+	@LIBNET_LIBS@ @LIBWIBBLE_LIBS@
 
-INCLUDES=@LIBNET_CFLAGS@ -DSCRIPTDIR=\"@scriptdir@\" -I ../src
+INCLUDES=@LIBNET_CFLAGS@ @LIBWIBBLE_CFLAGS@ -DSCRIPTDIR=\"@scriptdir@\" -I ../src
 
 EXTRA_DIST = test-guessnet test-ifupdown test-utils.h

Modified: trunk/tests/test-iface.cc
==============================================================================
--- trunk/tests/test-iface.cc	(original)
+++ trunk/tests/test-iface.cc	Fri Aug 25 17:57:07 2006
@@ -6,7 +6,7 @@
 static void printConfig(const char* tag, IFace& iface)
 {
 	if_params ifp = iface.getConfiguration();
-	printf("%-10.10s %.*s: ", tag, PFSTR(iface.name()));
+	printf("%-10.10s %s: ", tag, iface.name().c_str());
 	ifp.print();
 }
 
@@ -27,21 +27,21 @@
 		printConfig("Down", iface);
 		fprintf(stderr, "\t\tConfiguring for broadcast...\n");
 		if_params unconf = iface.initBroadcast(4);
-		printf("%-10.10s %.*s: ", "Pre-Bcast", PFSTR(iface.name()));
+		printf("%-10.10s %s: ", "Pre-Bcast", iface.name().c_str());
 		unconf.print();
 		printConfig("Broadcast", iface);
 		fprintf(stderr, "\t\tIfconfig for broadcast...\n");
 		system("ifconfig");
 		fprintf(stderr, "\t\tReconfiguring interface...\n");
 		if_params bcast = iface.setConfiguration(ifp);
-		printf("%-10.10s %.*s: ", "Pre-Restore", PFSTR(iface.name()));
+		printf("%-10.10s %s: ", "Pre-Restore", iface.name().c_str());
 		bcast.print();
 		printConfig("Restored", iface);
 		fprintf(stderr, "\t\tDone.\n");
 	}
-	catch (Exception& e)
+	catch (std::exception& e)
 	{
-		error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		error("%s\n", e.what());
 		return 1;
 	}
 	return 0;

Modified: trunk/tests/test-netsender.cc
==============================================================================
--- trunk/tests/test-netsender.cc	(original)
+++ trunk/tests/test-netsender.cc	Fri Aug 25 17:57:07 2006
@@ -6,6 +6,8 @@
 
 #include <stdio.h>
 
+#include <iostream>
+
 extern "C" {
 #include <libnet.h>
 }
@@ -17,7 +19,7 @@
 public:
 	virtual void handleARP(struct libnet_arp_hdr* arp_header) throw ()
 	{
-		printf("Seen ARP");
+		cout << "Seen ARP";
 
 		// Parse and check the arp header
 		if (ntohs (arp_header->ar_op) == ARPOP_REPLY)
@@ -29,16 +31,16 @@
 
 			rep += fmt(IPAddress(*ipv4_him)) + " " + fmt(*mac_him);
 
-			printf(" reply from %.*s", PFSTR(rep));
+			cout << " reply from " << rep;
 
 			//IPv4_FROM_LIBNET(ipv4_me, arp_header->ar_tpa);
 			//IPv4_FROM_ARP(ipv4_him, arp_header->ar_spa);
 		}
-		printf("\n");
+		cout << endl;
 	}
 	virtual void handleEthernet(struct libnet_ethernet_hdr* arp_header) throw ()
 	{
-		printf("Seen Ethernet\n");
+		cout << "Seen Ethernet" << endl;
 	}
 // others to come as needed, like:
 // //         // virtual handleDHCP(struct libnet_hdcp_something* hdcp_header) throw () {}
@@ -47,7 +49,7 @@
 static void printConfig(const char* tag, IFace& iface)
 {
 	if_params ifp = iface.getConfiguration();
-	printf("%-10.10s %.*s: ", tag, PFSTR(iface.name()));
+	printf("%-10.10s %s: ", tag, iface.name().c_str());
 	ifp.print();
 }
 
@@ -56,14 +58,14 @@
 	if (argc < 2)
 		fatal_error("Usage: %s <iface>\n", argv[0]);
 	try {
-		InstallUnexpected installUnexpected;
+		wibble::exception::InstallUnexpected installUnexpected;
 
 		{
 			fprintf(stderr, "\t\tTrying libnet setup...\n");
 			libnet_t* ln_context;
 			char ln_errbuf[LIBNET_ERRBUF_SIZE];
 			if (!(ln_context = libnet_init(LIBNET_LINK_ADV, argv[1], ln_errbuf)))
-				throw libnetException(ln_errbuf, "opening link interface");
+				throw wibble::exception::Libnet(ln_errbuf, "opening link interface");
 			fprintf(stderr, "\t\tLibnet deleting %p...\n", ln_context);
 			libnet_destroy(ln_context);
 			fprintf(stderr, "\t\tLibnet tried...\n");
@@ -121,9 +123,9 @@
 		printConfig("Restored", iface);
 		fprintf(stderr, "\t\tDone.\n");
 	}
-	catch (Exception& e)
+	catch (std::exception& e)
 	{
-		error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		error("%s\n", e.what());
 		return 1;
 	}
 	return 0;

Modified: trunk/tests/test-netwatcher.cc
==============================================================================
--- trunk/tests/test-netwatcher.cc	(original)
+++ trunk/tests/test-netwatcher.cc	Fri Aug 25 17:57:07 2006
@@ -26,7 +26,7 @@
 static void printConfig(const char* tag, IFace& iface)
 {
 	if_params ifp = iface.getConfiguration();
-	printf("%-10.10s %.*s: ", tag, PFSTR(iface.name()));
+	printf("%-10.10s %s: ", tag, iface.name().c_str());
 	ifp.print();
 }
 
@@ -35,7 +35,7 @@
 	if (argc < 2)
 		fatal_error("Usage: %s <iface>\n", argv[0]);
 	try {
-		InstallUnexpected installUnexpected;
+		wibble::exception::InstallUnexpected installUnexpected;
 
 		IFace iface(argv[1]);
 		if_params ifp = iface.getConfiguration();
@@ -81,9 +81,9 @@
 		*/
 		fprintf(stderr, "\t\tDone.\n");
 	}
-	catch (Exception& e)
+	catch (std::exception& e)
 	{
-		error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		error("%s\n", e.what());
 		return 1;
 	}
 	return 0;

Modified: trunk/tests/test-processrunner.cc
==============================================================================
--- trunk/tests/test-processrunner.cc	(original)
+++ trunk/tests/test-processrunner.cc	Fri Aug 25 17:57:07 2006
@@ -2,17 +2,19 @@
 #include "ProcessRunner.h"
 
 #include <stdio.h>
+#include <iostream>
 
 #define DEBUG(args...) fprintf(stderr, ##args)
 //#define DEBUG(args...) do {} while(0)
 
+using namespace std;
 
 class ProcessPrinter : public ProcessListener
 {
 public:
 	virtual void handleTermination(const std::string& tag, int status) throw ()
 	{
-		printf("%.*s: terminated with status %d\n", PFSTR(tag), status);
+		cout << tag << ": terminated with status " << status << endl;
 	}
 };
 
@@ -20,7 +22,7 @@
 int main(int argc, char* argv[])
 {
 	try {
-		InstallUnexpected installUnexpected;
+		wibble::exception::InstallUnexpected installUnexpected;
 
 		Environment::get().debug(true);
 
@@ -50,9 +52,9 @@
 
 		fprintf(stderr, "\t\tDone.\n");
 	}
-	catch (Exception& e)
+	catch (std::exception& e)
 	{
-		error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		error("%s", e.what());
 		return 1;
 	}
 	return 0;

Modified: trunk/tests/test-scanbag.cc
==============================================================================
--- trunk/tests/test-scanbag.cc	(original)
+++ trunk/tests/test-scanbag.cc	Fri Aug 25 17:57:07 2006
@@ -3,19 +3,17 @@
 #include "ScanBag.h"
 
 #include <stdio.h>
+#include <iostream.h>
 
 using namespace std;
 
 void printCands(const vector<string>& v)
 {
 	for (vector<string>::const_iterator i = v.begin(); i != v.end(); i++)
-	{
 		if (i != v.begin())
-			printf(", %.*s", PFSTR(*i));
+			cout << ", " << *i;
 		else
-			printf("%.*s", PFSTR(*i));
-
-	}
+			cout << *i;
 }
 
 Scan* s1 = new DefaultScan("default");
@@ -49,7 +47,7 @@
 
 		string res = sb.getLessSpecific();
 		if (res != "default")
-				error("Less specific at the beginning is %.*s instead of \"default\"", PFSTR(res));
+				error("Less specific at the beginning is %s instead of \"default\"", res.c_str());
 
 		vector<string> v;
 
@@ -57,7 +55,7 @@
 		if (v.size() != 1)
 			error("test0 should be the only candidate, but %d candidates are present", v.size());
 		if (v[0] != "test0")
-			error("test0 should be the resulting candidate, but %.*s is the result instead", PFSTR(v[0]));
+			error("test0 should be the resulting candidate, but %s is the result instead", v[0].c_str());
 
 		initScans(sb);
 
@@ -70,20 +68,20 @@
 		if (v.size() != 1)
 			error("test1 should be the only candidate, but %d candidates are present", v.size());
 		if (v[0] != "test1")
-			error("test1 should be the resulting candidate, but %.*s is the result instead", PFSTR(v[0]));
+			error("test1 should be the resulting candidate, but %s is the result instead", v[0].c_str());
 
 		initScans(sb);
 		//sb.dump();
 		v = sb.notify(s4);
 		res = sb.getLessSpecific();
 		if (res != "test2")
-			error("test2 should be the resulting candidate, but %.*s is the result instead", PFSTR(res));
+			error("test2 should be the resulting candidate, but %s is the result instead", res.c_str());
 
 		fprintf(stderr, "\t\tDone.\n");
 	}
-	catch (Exception& e)
+	catch (std::exception& e)
 	{
-		error("%s: %.*s\n", e.type(), PFSTR(e.desc()));
+		error("%s\n", e.what());
 		return 1;
 	}
 	return 0;



More information about the Guessnet-devel mailing list