Personal.X-Istence.com

Bert JW Regeer (畢傑龍)

Facepalm

The past few days I have been working on some bits and pieces of code, and I facepalmed myself at 0226 in the morning. I opened up an older part of the project, and I had totally forgotten I had written a config parser. It opens up, and it is scrolled half way down the page, so I don't see my Copyright tag on it at the top.

I look it over a few lines, and suddenly I say to myself:

Wow, that is an interesting way of accomplishing that. I would have never thought of that

Interesting trick

Written with security in mind

Line counting, and even tells the user what error it has encountered!

Wanting to know who wrote this code, figuring it was someone I was working with at the time, I read the copyright:

* Copyright 2006 Bert JW Regeer. All rights  reserved.

Yeah, facepalm. Anyway, luckily I do remember why I was writing it, and I wrote down in the sample config file what the config parser is supposed to parse, so I know that it parses stuff like this:

# <sub-system name> {
#       id: <number>;                           # Any number that is not taken
#       program: bin/something;                 # Full path, or take workingdir/<program>. So /usr/local/bin/something in this example.
#       arguments: -user xistence;              # Pass an arbitrary amount of arguments to the program to be executed
#       env: SPECIALSAUCE=yes,MAYO=no;          # Pass environment variables to the executing program.
# }

The config system is there to allow different programs to be run by the daemon depending on user input. So for example, this would be a valid sub-system:

adduser {
    id: 10
    program: bin/specialadduser
    arguments: --skel=/usr/local/skel
}

Anyway, I was pretty damn impressed with my own code from 2 years ago. Now that I have looked at it again, I remember writing it while I was bored during my summer vacation. That same summer vacation I wrote my own regex library, which sadly I have removed from existence, since it was too complicated to maintain. It was however able to do some of the following:

(a*) to look for a followed by any characters, and store it.
a+ to look for 1 or more occurrences of a.
(.*) { (.*) } would also work, it would store whatever it found before a "
{" in an array as position 0, and then whatever was in the curly braces in
array position 1. It is probably for the best that the code is gone, but it
was an interesting exercise none the less.

Maybe later I will post more information. I am heading back to my other code, it is nowhere near finished!