-
CGI Design
Hello,
Currently im working on a largish CGI script in C, im wondering how I should go around things performance wise.
A large amount of the content is dynamic, should I... Load 'templates' from files/parse them and then add my values? Or run it as a big program outputting it along the way...
like:
Code:
#include <stdio.h>
int main(void)
{
printf("Content-type: text/html\n\n");
printf( "<html>\n"
"<head>\n"
"<title>%s</title>\n", "Dynamic title!");
}
Note the dynamic title... (as an eg), Or should I load a template from a file then parse it (what's best for performance? (I know this depends on how im parsing it)).
Also, including stdio.h just to read/write to stdin and stdout adds a lot of overhead to my program, Is there a way to reduce this overhead?
Thanks in advance!
-
RE: CGI Design
That would all depend on if you want to have your CGI script as re-usable for other websites, or if you just want it to be done for one website and only that website.
If you want it re-usable, make a file that it will open and read when it begins. This will tell the script things like Title of Site, and other such things. Like a configuration file or something.
If you don't want it that way, then don't and simply place it directly in your code.