Adding Multiple Mice Support to FLTK using MPX
For a while now I’ve been working on modifying FLTK to support multiple Mice. We need this functionality for applications we are working on. FLTK was chosen for a number of reasons.
- It’s light weight
- It’s cross platform
- It was already in use by the applications being extended.
cgit upgrade & gitweb retired
With CGit v0.8 supporting, atom feeds, patch targets and also the clone-url option, it’s time to finally rid ourselves of the memory hungry gitweb. Hence cgit.fd.o has been upgraded and gitweb been pointed to cgit.fd.o. There’s also a bucket load of redirects in place to support this. Hence all the old gitweb url’s should correctly translate into cgit urls.
jhbuild just won’t build! (aka Include path madness)
I’ve been recently trying to work out why jhbuild fails to build xorg on my FreeBSD box. Traditionally I compile to /usr/local/ however after wanting to experiment with MPX I’ve set things up so that I compile to /usr/local/MPX
Sadly this kept breaking in xorg/lib/libX11 with the error:
Clearchain Website Updated
It’s been a while now but I’ve finally got around to updating the clearchain website. The old mediawiki based instance was nice, friendly to edit but also required syntax to edit it. After a while arguing with the syntax it gets to the point where all you really want to do is use the website rather than maintain it. Hence Clearchain lives now as a blog site. Making good use of the wordpress software.
Word press is easy to use, has a graphical editor and just makes life easier. It’s ironic actually as all the old site really was was a blog with a few pages, it just forced mediawiki to do something it wasn’t really intended for. Now however, we’ve got things right and we’re using blogging software. There will certainly be a number of things broken after the pages have been migrated and the old blog was not shifted. Hence the blog is starting new with only previous useful pages being shifted.
stl::set
Working with Mark’s dnl code, we came across an interesting issue. Mark had used the stl::set class for some of his code and whilst it compiled fine under Visual Studio, it failed to compile under gcc/g++. With the error:
dnlCommon/Logger.cpp: In member function 'void dnlCommon::Logger::setMask(std::ostream&, std::bitset<5ul>)': dnlCommon/Logger.cpp:64: error: invalid initialization of reference of type 'dnlCommon::Logger::LoggerPair&' from expression of type 'const dnlCommon::Logger::LoggerPair' /usr/local/lib/gcc-4.0.4/include/c++/bits/stl_algo.h: In function '_OutputIterator std::remove_copy(_InputIterator, _InputIterator, _OutputIterator, const _Tp&) [with _InputIterator = std::_Rb_tree_const_iterator<dnlCommon::Logger::LoggerPair>, _OutputIterator = std::_Rb_tree_const_iterator<dnlCommon::Logger::LoggerPair>, _Tp = dnlCommon::Logger::LoggerPair]': /usr/local/lib/gcc-4.0.4/include/c++/bits/stl_algo.h:1112: instantiated from '_ForwardIterator std::remove(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::_Rb_tree_const_iterator<dnlCommon::Logger::LoggerPair>, _Tp = dnlCommon::Logger::LoggerPair]' dnlCommon/Logger.cpp:54: instantiated from here /usr/local/lib/gcc-4.0.4/include/c++/bits/stl_algo.h:1037: error: passing 'const dnlCommon::Logger::LoggerPair' as 'this' argument of 'dnlCommon::Logger::LoggerPair& dnlCommon::Logger::LoggerPair::operator=(const dnlCommon::Logger::LoggerPair&)' discards qualifiers
It turned out that the issue occurred with the assignment operator (operator = ) on the stl::set class. Tracing the problem we found that set<TYPE>::iterator is const rather than non cost. Hence calling stl functions that made use of the iterators but also the assignment operator would fail.
Looking further into the problem I found:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 103. set::iterator is required to be modifiable,
// but this allows modification of keys.
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
Hmm, that’s strange. A bit of googling revieled the problem to be an issue with the stl standard. Fixes to gcc/g++ are listed at http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html in particular error 103 is listed at http://gcc.gnu.org/onlinedocs/libstdc++/ext/lwg-defects.html#103
So it looks like the bug was ratified by the C++ committee in 1998 and it still isn’t fixed in Visual Studio 2005 (VC++ 8.0) !
FreeBSD VPN
FreeBSD VPN
This document describes how to setup both the server side and client side for a PPTP connection with MPPE encryption that works for windows, MacOsX and other freebsd boxes.
The basic process:
- Install & configure pptpserver on the freebsd server - Configure ppp on the freebsd server - Setup the clients
[edit] 1. Installing pptpserver
This part is handled really easily as it pptp server exists in the ports collections. Hence all you need to do is:
cd /usr/port/net/poptop make install
To configure pptp modify /usr/local/etc/pptp.conf\\ Put the following lines in the file:
localip 192.168.2.1 remoteip 192.168.2.56-75 # Listen on the outside interface only listen 130.220.37.202
[edit] Configure ppp on the freebsd server
Edit /etc/ppp/ppp.conf and set the following target only:
pptp:
set ifaddr 192.168.1.1 192.168.1.56-192.168.1.74 255.255.255.255
set dns 192.168.0.1
set nbns 192.168.0.1
disable pap
disable utmp
disable passwdauth
#enable chap # MPPE Requirest chap81/MSChapV2
enable MSChapV2
enable mppe # Enable Encrptions
set log Phase Chat LCP IPCP CCP tun command # Debugging
set timeout 0 # Don't drop the connection
# # Force 128 bit encryption with a key change every packet # MacOSX only works with stateless connections and the are more # secure anyway - just less efficient. set mppe 128 stateless
# Disable compression - freebsd clients try to use it but it breaks mppe disable deflate pred1 deny deflate pred1 set server /var/run/pptp_ppp_%d "" 0700 accept dns # Enable clients to request dns details disable ipv6cp # Disable ipv6 enable proxy # Enable proxying addresses on the local net for clients
Now modify/create /etc/ppp/ppp.secret and put in it:
someuser userpassword 192.168.1.75
Now ’someuser’ can log in with the password ‘userpassword’ and will get an IP address of 192.168.1.75. If you don’t want to specify the ip, just leave the 3rd parameter off that line of the file.
[edit] Setup Clients
This section details how to setup various clients
[edit] Windows XP
- Create a new VPN connection - Specify host - Specify Usename / password - Hit connect
[edit] FreeBSD
Freebsd works with MPPE out the box. Simply setup the following in /etc/ppp.conf
MYVPN: set authname someuser set authkey userpassword disable pred1 enable proxy disable ipv6cp set timeout 0 add default HISADDR
Install pptpclient
cd /usr/ports/net/pptpclient make install
Now run it with: pptp serverip MYVPN\\ ie:
pptp 130.220.37.2 MYVPN
[edit] Mac OsX
Simply configure the GUI tool.
Stl::reverse iterator
I was coding a little program a while back when I found a Quirk about the stl reverse_iterator. Use of the iterator is quite easy until you have to delete from one. I tried the normal way of:
vector<sometype>::reverse_iterator myiterator... .. .. myvector.erase(myiterator).
only to find the code didn’t compile. A little baffled I started to looking into why. It turns out you Can’t’ delete from a reverse iterator directly. So the question is How do you delete from a reverse iterator?.
Not wanting to do a full forward traversal to get to the same point I did some Googling. Eventually I found the page: http://www.ddj.com/dept/cpp/184401406
which explains why you can’t delete from the reverse iterator. More importantly it indicates a way that you can delete from the reverse_iterator. So how?
void Manager::raiseWindow(WMWindow* wmwindow)
{
vector<WMWindow*>::reverse_iterator it = windows.rbegin();
while(it != windows.rend())
{
if (*it == wmwindow)
{
// why ++it see http://www.ddj.com/dept/cpp/184401406
windows.erase((++it).base());
windows.push_back(wmwindow);
break;
}
it++;
}
wmwindow->raise();
}
</code>
Gives an example of how to do it. However, be aware, doing the above erase, invalidates the iterator so don’t go trying to use it again afterwards! }
Splitting A Patch
Have you ever been working on code, gone off on a side tangent and then realized you don’t have a valid patch of the code you’ve been working on? So you run diff -du, cvs diff, git diff or some other diff and suddenly realize you have a mix of old changes and new changes. Some you want to submit, others you don’t. What you really want to do is break those changes apart and apply only the ones you want.
Sadly, there is no tool to do that.. until now!
SplitPatch.rb
Peter Hutterer, whilst working at the Wearable Computer Lab at University of South Australia faced this very problem. So he wrote the program, splitpatch.
splitpatch will allow you to take a diff of a file and either:
- Split the patch up into change to the respective patched files
- Split the patch up into individual hunks, where each hunk can be applied separately
Usage
To use splitpatch, you’ll need ruby installed. Then simply use:
splitpatch.rb YOURPATCHFILE
To split YOURPATCHFILE into a valid patch per file contained within the patch. Or
splitpatch.rb --hunks YOURPATCHFILE
To split the patch file into individual chunks which can be applied, using patch
Download
Splitpatch can be downloaded from:
http://www.clearchain.com/~benjsc/download/splitpatch/splitpatch.rb
Patch File Format
For those who don’t think splitpatch will do what they want, here’s at least some info about the format of a patch file.
@@ -143,6 +143,13 @@
- the first number is the starting line for this hunk in oldfile
- the second number is the number of original source lines in this hunk (this includes lines marked with “-”)
- the third number is the starting line for this hunk in newfile
- the last number is the number of lines after the hunk has been applied.
Many thanks to Peter Hutterer for this valuable trip into a patch.
Setting up Sendmail with TLS & Auth support under FreeBSD
In order to setup a secure mail transport agent (MTA) that helps eliminate some spam and also allows roaming client support, some sort of authentication mechanisim must be added when setting up a MTA. In my case I’m using FreeBSD 4.9 with sendmail as my MTA. Setting Up Sendmail
LDAPAddressBook
LDAP is a great protocol. It allows multiple clients to obtain data about virtually anything that you can think of. The LDAPAddressBook project is a project to determine a LDAP Schema that works in the following clients:
- Mozilla Thunderbird
- Windows Address Book
- OS X Address Book
- Squirrel Mail
In fact any client that supports LDAP.