Read a file line by line in C – secure fgets idiom

A pretty common thing to do in any program is read a file line-by-line. In other interpreted or managed languages this is trivial, the standard libraries will make it super easy for you. Just look at how simple it is to do this in Python or Perl or even Shell.
In C its a [...]

tmux, a BSD alternative to GNU Screen

I started using tmux today. Its a terminal multiplexer / task switcher for UNIX-likes, very much in the same vein as GNU Screen. However, its a from-scratch implementation, designed to be clean, sane and easy to configure. The more liberal 3-clause BSD license is a plus also, since it means that [...]

Importing a CVS repository to Google Code Subversion

My C BitTorrent implementation, Unworkable, used to be hosted on an anonymous CVS repository I had running on my server at home. This was fine, until I reinstalled the machine from scratch and didn’t feel like setting up the whole anonymous CVS access again. Its a pretty painful process, unfortunately, although there is [...]

mkpath() – `mkdir -p’ alike in C for UNIX

Most people are probably familiar with the UNIX utility, mkdir(1). The mkdir utility makes directories (surprise surprise). There is a matching mkdir(2) system call available in the POSIX standard C library. The usage is pretty straightforward – how ever, the command-line executable, mkdir(1), supports a useful option -p to “create intermediate directories [...]