c-snippets  c-snippets


This page is a Fossil source code repository for my collection of C snippets. It's not really a library, but a collection of (partially experimental) stuff. This site is mainly an experiment to try out the Fossil source control system. Fossil is still quite young and has a couple bugs and missing features, so don't expect everything on this site to work.

Code includes...

The code includes a small collection of relatively portable, mostly standlone pieces of C code for doing things like:

  • Managing dynamically-growing strings or blobs. See the clob page.
  • A versatile printf replacement which can append its output to arbitrary channels, e.g. those dynamically-growing strings or blobs. See the vappendf page.
  • Convenient tokenizing of path-like strings. See tokenize_path.c.
  • A generic tokenizer geared towards script-like grammars.


All of this code is released into the Public Domain.

Downloading this code

There are two options for downloading. The first is to log in as the anonymous use and follow the /leaves link. Then find the top-most entry and click that. From there, you can download a zip file containing the latest checked-in source code. Versions of Fossil older than 8 February 2008 will create a zip which unpacks to the current directory, so be sure to first create and 'cd' to the proper target directory before unzipping.

Optionally, you can use fossil:

~> fossil clone \
   http://anonymous:anonymous@fossil.wanderinghorse.net/repos/c-snippets/index.cgi \

(All on one line.)

That will copy the repository to sigslot.fsl, which you can then open with:

~> mkdir csnips
~> cd csnips
~> fossil open ../csnips.fsl

That checks out the files under the current dir. A Makefile for GNU Make is included, and the snippets should be buildable on nearly any platform.


If you are interesting in contributing to this code, there are several options:

  • Send me a patch or code snippet (need not be in "patch" format if it's easy enough to handle).
  • Get in touch with me and we can get you set up with write access to this repo (requires the Fossil tool).
  • Just send me an idea of what it is you'd like to see changed/fixed/added. Oftentimes a simple suggestion is a great catalyst for a feature.
  • Hire Asp.net Programmer