• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Apache API

How can I call API of Apache from a CGI written by C ?

Andrew
0
andrewyu
Asked:
andrewyu
  • 3
  • 3
1 Solution
 
BigRatCommented:
What API? For what purpose?
0
 
andrewyuAuthor Commented:
Apache API ......

Andrew
0
 
monasCommented:
You CAN NOT!

To use apache API you should write apache module, not a cgi program. This means that you should compile your code into apache server.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
andrewyuAuthor Commented:
So, can CGI call the module I wrote ?

Andrew
0
 
monasCommented:
Directly - NO.

Indirectly - maybe. It depends for what purpose you are writing this module.

THe principle is that apache consist of number of modules. When it accepts a request for some document it handles this request in "phases" - or steps. The main steps are:

- converting from URL to filesystem path
- authentication (or finding who requested the document)
- authorization (or finding is he/she allowed to get this document)
- producing of the document
[check apache docs for full explanation]

In every phase corresponding functions from EVERY module is called.

So if you write module you can affect environment where CGI script will be invoked. But CGI module sends cgi-script's output directly to the requestor - therefore there is no possibility to afect data that your script provides.

Of course, you can modify mod_cgi and introduce some kind of possibility to access API via this module. But then this won't be a CGI module anymore. ANd your scripts won't be able to be run on other servers anymore - so you will loose the whole point why the CGI was invented.

      Good Look

0
 
andrewyuAuthor Commented:
So, I must write a HANDLER, right ?

Andrew
0
 
monasCommented:
You did not say me what you want to achieve, therefore I can not say for sure.

But most likely, you have to write module, and every function which is invoked to perform modules' actions in that phase is called HANDLER. THerefore if you will be writing module you will need to write handler. Most likely, several of them.

But before you start at creating new modules check very carefully present modules. Chanses are pretty good that existing modules already provide services to achieve your final result. Possible not in the way you expect them to do this. I wasted my time several times "reinventing wheel".
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now