Yesterday I worked on template.c removing unused tags and moving large blocks of code to separate functions, some to different files. There are now 26 options with the form:
case '?' : single line of code; break;
4 like this, which I don't see any reason to mess with:
case '?' :
if(MaxSomething > -1) {
printf( number / number );
} else {
printf( number / unlimited );
}
break;and 9 others that are still farily long chunks of code that are very likely to become functions today. I really like the way it looks with all the single line actions in the switch.
I ran into some TmpBuf* variables which were declared in qmailadmin.c and qmailadminx.h then used locally all over the program. I was worried about interaction, so I went through each function in which they appeared, and if they were initialized within the function I renamed them from TmpBuf* to Buffer*, and declared them locally. It turns out there were no interactions, now there is no question - they aren't shared globals any more.
Tom Collins wrote:
> On Jan 8, 2004, at 6:56 PM, Rick Widmer wrote: > >> 1. Does switch/case work with strings? > > No. Only with byte/int/long/word datatypes.
If we want to move from
/cgi-bin/qmailadmin/com/commandname?...
to
/qmailadmin/program.cgi?command=commandname
why not just go with single character commands that we can switch() on?
/qmailadmin/program.cgi?command=c
However, if I was doing this with PHP, a URL might look like:
http://server.x.com/qmailadmin/maildomain.com/name/edit.php
qmailadmin is a PHP program without the .php extension. I use the following settings in httpd.com to make it execute:
<Location /qmailadmin> ForceType applocation/x-httpd-php </Location>
/maildomain.com/username/edit.php would be available in PATH_INFO and used to control operation of the program. This example would be editing [EMAIL PROTECTED] The .php at the end is just there for show, I never actually check the 'file extension'.
That works for PHP. It looks like ScriptAlias will allow something similar for a c program. Are there any objections doing something like this? Is there anyone who would have a hard time controlling the Apache configuration on the mail server? Some web sites can not use the ForceType trick because they can't change their Apache configuration, but I'd be suprised if that was a problem on mail servers. Now is the time to find out if this will be a big problem for someone...
Rick
