CGI Design

This is a discussion on CGI Design within the C Programming forums, part of the General Programming Boards category; Hello, Currently im working on a largish CGI script in C, im wondering how I should go around things performance ...

  1. #1
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459

    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>&#37;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!

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    1

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. which design is better to wrap another class instance
    By George2 in forum C++ Programming
    Replies: 7
    Last Post: 04-13-2008, 12:27 AM
  2. CGI program help please
    By Lince in forum C Programming
    Replies: 3
    Last Post: 08-01-2007, 01:31 AM
  3. Implementing Inheritence into your design
    By bobthebullet990 in forum C++ Programming
    Replies: 6
    Last Post: 08-05-2006, 04:40 PM
  4. Opinions on new site design
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 01-21-2005, 12:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21