Your browser doesn't seem to support CSS, which this page uses for all styling. Don't be surprised if it looks kinda boring.

[Jump to nav]

gencgi

Summary

This is a Perl script I tossed together to generate a parser for a CGI GET request in C.

There's dozens (at least) of libraries out there to do CGI operations in C. Parse GET requests. Parse POST requests. Build up arrays and trees and suchlike of the contents of the request. All sorts of fancy powerful flexible stuff.

This doesn't do that.

What this does do is generate a parser function and structure designed to be as small as reasonably possible in terms of memory and CPU time. It could be better, of course, but that's because I'm a pretty mediocre programmer. It's reasonably solid (and reasonably elegant), though.

If you're building a big, full-featured interface with a lot of polymorphism, this isn't for you. If, however, you're trying to build a simple, small CGI, especially one that needs to run under tight size constraints (say, on a semi-embedded system), this may be just what you're looking for.

And anyway, it was fun to write.

How to use it

Download and untar the distribution. There's a set of sample files showing off a simplistic usage, and a README file that describes how to customize it for your situation.

Download

This is a little one-off hack, generalized enough to be a N-off hack. It's kinda silly to give it a version number, but what the hell. So, if you will, grab yourself the 1.0 release here.

There's a few comments in the README file about potential expansions for future versions. I don't really plan on making any, since it does all I needed it to do (and more), but if I do, those features will likely be in it. If you have any more requests, suggestions, comments, flames, spitballs, large sums of money, or oaths of fealty to offer, please do email me, and maybe I'll answer sometime.