Back to C…
February 12, 2008 on 8:09 pm | In General | 1 CommentThe past couple of months i have been experimenting with a new version control software called Fossil, available from http://www.fossil-scm.org. While it’s not as mature as, say, CVS or Subversion, it has some really killer features which make it stand out (e.g. can run as a standalone server, a command-line app, or a CGI app, it has a built-in wiki, and a built-in bug/ticket system is in the works). It is my firm belief that in a year or so Fossil will be in an outstanding position to sweep the market for distributed version control for small projects. The fact that it can run as a CGI service opens it up to many users who currently can’t run their own Subversion or CVS servers (e.g. me).
So far the only significant feature which Fossil doesn’t have, which i truly miss, is that it doesn’t store access rights for files (e.g. it can’t store the executable bit for scripts). Dr. D. Richard Hipp, Fossil’s author (and author of sqlite), wrote a few days ago in the fossil mailing list post that early versions of Fossil had that feature but that it “didn’t work out”, so he pulled it.
After sending several mails and a bug fix or two to Dr. Hipp he gave me write access to the Fossil repo, so i’ve been hacking on it the past week or two. It’s been a wonderful chance to get back into C programming. While C was my 3rd computer language (after BASIC and Pascal), i haven’t actually used it for anything significant since 1995, so my C is a bit rusty. While C++ is, by far, my language of choice, some of the techniques which Fossil uses internally are downright cool and have inspired me to take a fresh look at C. Part of that “fresh look” has meant hacking around in C, and that hacking is itself stored in a public Fossil repository:
http://wanderinghorse.net/cgi-bin/fossil-c-snippets.cgi
Probably my favourite part of that code so far is the vappendf() family of functions, which work similarly to printf() but can send their output to arbitrary channels, instead of just to stdout or a FILE handle. i found a Public Domain implementation of printf() (from the sqlite3 source tree) and modified it to send its output to a callback function. This makes it possible to send printf-processed output to, e.g., C++ strings or streams, GUI widgets, arbitrary file handles, etc. (Note that printf() itself is not used in the implementation, but appendf() and friends are functionally equivalent to [f]printf(), plus a couple of extensions.) Together with the “clob” (C blobs) API (also in that repo, hacked together last weekend) they provide a complete framework for buffering/accumulating string output, e.g. like Fossil does when it generates web pages. (In fact, the clob API is a reimplementation of the Blob support in Fossil.)
My current long-term goal (i.e. “fantasy”) is to, bit by bit, reimplement or refactor the Fossil source base into a generic application platform. That would allow really rich applications can be written in C/C++ for use as CGIs, standalone web servers, or console applications. Fossil’s engine is based largely on sqlite3, which means that such apps would have a significant amount of built-in serialization support.
Anyway… back to hacking…
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^