Tuesday, 09 March 2010

Editline v1.13.0 Available!

First release with the new name. Available from the usual places:

Report bugs to the EMAIL found in the README file.

posted at: 23:11 | path: /hacks | permanent link to this entry

Saturday, 30 January 2010

On reviving pimd and mrouted

I'm unsure if I should take any pride in this, they are old and stale projects that probably should have been forgotten a long time ago. But the original pimd and mrouted multicast routing prodocols have been revived at github.org.

We need them at work and I were a bit tired of digging around the Internet for patches trying to keep them running on our ever evolving new platform. So I sat down a couple of week-ends and read up a bit on pimd and mrouted, collecting patches from the usual places as well as some unexpected places, before creating the projects.

Yes, I am aware of the effort to extend Quagga with a native pimd and I will definitely look into that in due course.

Starting these projects using GIT actually brings closure for me. If anything I can rest assured that my efforts can easily be picked up by someone else should I loose interest.

To those of you having trouble building and using pimd/mrouted, please include build logs and full debug logs in your emails requesting help. Thanks!

posted at: 13:23 | path: /hacks | permanent link to this entry

Sunday, 11 October 2009

Log rotation for sysklogd

I have been using the BusyBox syslogd for a while now. It's nice and small, but sometimes a bit too limited. Due to the resource limitations of my target system I've been dreading having to pull in something else. But recently the lack of standard syslog features, most notably support for more than one remote syslog server and the ability to, e.g., split debug and warning messages to separate log files, have forced me to shop around a bit.

I found sysklogd to be small enough but yet competent. It's the default in most Debian and Ubuntu installations and is a descendant of BSD. So I started playing with it, only to find out (again!) that the BusyBox guys really know what they are doing. The BusyBox syslogd support automatic log rotation, has a a neat circular buffer which a logread tool can hook into and supports double buffering. The one feature I cannot do without is the built-in support for rotating log files. My system is embedded and I don't want to drag in logrotate(8), or cron for that matter, only to rotate a few files. Also, there are several problems with having external scripts do the log rotation.

So, I set about porting the BusyBox log rotation code to sysklogd. Here is the first patch, which will be updated whenever I find bugs, make additions or changes.

When it is done and feels stable enough I'll submit it upstream. If not for general inclusion then perhaps it fits into the contributed patches category.

posted at: 12:48 | path: /hacks | permanent link to this entry

Thursday, 23 July 2009

Micro Snake

Wow, it would seem I've started a series of miniature games. Yesterday I released Micro Snake on Freshmeat. Like last time, it's a very small implementation with as few dependencies as possible, made for playing on dumb ASCII/ANSI vt100 terminals.

The project is a refactor of an original DOS game by Simon Huggins. Thank you Simon for allowing me to reuse your work!

Like most code I publish these days it's under the ISC License.

Download the code and try it out!

posted at: 12:07 | path: /hacks | permanent link to this entry

Sunday, 14 June 2009

Editline First Post

For a while now I've been maintaining a port of Minix editline library libedit. Mainly for my own purposes, or rather on behalf of Westermo WeOS, where it is used in the CLI. This library is the same as the Debian editline package, even though the origin of that package is somewhat unclear to me.

Today I decided to adjust the package name and bump the version number to indicate that my port is the same, and now slightly more advanced, than the Debian version. To that end I've now changed the repository name and prepared for merging with Debian. Getting this work accepted back into Debian is a completely different issue.

Get the code as a Bazaar branch, or view its change log through the Loggerhead web interface:

I now intend to do some further integration work, adapting the debian/ directory from editline-1.12-5 and smoothing out any remaining issues before I release 1.13.0.

posted at: 20:44 | path: /hacks | permanent link to this entry

Saturday, 13 June 2009

Micro Tetris™

I just published the unobfuscated version of the 1989 IOCCC Best Game entry, Tetris™. See the original author, John Tromp's home page for the game for details. But suffice it to say, this is an extremely bare bones version of the classic game and very similar to the BSD games' version.

Actually, this similarity in board layout, key combinations and feel led me to do some archaeological digging. I dowloaded the BSD games collection and, after having called GNU Indent on the obfuscated code, I started noticing such extreme similarities that just could not be coincidental. The layout and constructs of the code are virtually the same, so I can only conclude that they must share the same ancestor. Maybe this code is that ancestor, considering that the BSD Tetris is copyrighted in 1992 and this version stems from 1989, it is maybe not a completly illogical conclusion.

See for yourself.

posted at: 00:04 | path: /hacks | permanent link to this entry

Sunday, 05 April 2009

Brief libev update

I have now updated the libev examples. It took me a while, but during that time I have been hard at work converting two of our network daemons to use libev. As of today the upcoming Westermo WeOS uses libev in both its rstpd and igmpd implementations.

Updated example code:

Enjoy, and feel free to contact me if you have any questions or comments on the code. For libev specific help I can really recommend its mailing list!

posted at: 23:53 | path: /hacks | permanent link to this entry

Saturday, 28 March 2009

The Marvellous libev

A very good friend of mine recently told me about a neat event library, libev. Usually when he drops me links like that it takes me a couple of years to react and finally adopt.

This time it only took me about a month.

He has actually showed me lots of very useful stuff throughout the years, and even though we used GNU/Linux at university, he was one those hard core people who showed me the path into a successful full-time career as a Linux developer. I don't think I have ever thanked you properly for that, Jakob!

As it turns out libev was exactly what I have been looking for, for years! Way back in 2005 when I switched jobs I started working with a scary home brew code base ported to Linux from VxWorks. From the original code only the basic state machine, basic election algorithms and some other minor glue code remains. I have slowly refactored the code base into something, hopefully, more maintainable.

The one missing piece was the timer implementation. The old code used to create a new pthread for each new timeout. I tried replacing it with code of my own that was based on Don Libes "Implementing Software Timers". As it turns out libev already has (working) timers, in fact, it has taken an even more complete approach and made almost everything into events with callbacks, perfect for state machines!

After having done some initial testing of the libev timers I put on a big smile and fired up Emacs to investigate what other parts of that home brew code base were eligible for replacement, when i suddenly hit me: the state machine consists of a couple of threads that pass messages between them using msgsnd() and msgrcv(), bad old XSI IPC primitives. Bad guys that don't use standard file descriptors. A quick and dirty hack confirms it. I started looking around and I had a vague recollection of some message primitives that actually used file descriptors. On the mailing list Marc was extremely quick to answer my questions and with his help I eventually found the mq_overview(7) man page:

Polling message queue descriptors
On Linux, a message queue descriptor is actually a file descriptor, and can be monitored using select(2), poll(2), or epoll(7). This is not portable.

Wow, I could hardly wait until I, later that day, could get my hands on the keyboard again and try it out! Yes, the POSIX message queue primitives work! Here is my sample message queue code. Compile it in Emacs with M-x compile

Thus far I must say I can really recommend libev. Even though it isn't ISC licensed it's dual licensed under the 2-clause BSD license and the GNU GPL. In my case I'll go with the 2-clause BSD license, which according to Wikipedia is "functionally equivalent" to the MIT license.

posted at: 23:00 | path: /hacks | permanent link to this entry

Sunday, 08 February 2009

Minix editline v0.3.0

It's here! Fresh, new and packed with new features! Well, really just one new major feature — support for ANSI arrow keys. A good enough reason to bump the minor version number. :-)

Get it from the usual FTP location:

posted at: 22:35 | path: /hacks | permanent link to this entry

Saturday, 08 November 2008

Minix editline v0.2.2

Oups! It seems I forgot to announce the v0.2.2 release of the Minix editline library. It was made official in Bazaar over a month ago, 2008-10-02, but it was not until today that the tarball was created and uploaded to the FTP.

The most noteworthy in this release is support for command completion with the addition of rl_complete() and rl_list_possib(). Two function pointers that easily can be overloaded by the user. See the examples section of the tree for example usage.

Get it from the usual FTP location:

posted at: 20:24 | path: /hacks | permanent link to this entry