• C++ Apache Module

    C/C++, Programming

    Apache HTTP server is the world's most widely used web server software today, so why dont we take advantage to use it and create a module and extend functionalities using C++ programming.

    I made a simple C++ module and yet friendly to learn especially for the beginners.

    Here are the things that you should pay attention:

    1. Handler function
    2. Hook function
    3. Module declaration data 
    4. module initialisation 

     

    Handler function

    static int invadev_handler(request_rec* r)
    {
        if (!r->handler || strcmp(r->handler, "invadev"))
            return DECLINED;
         
        ap_set_content_type(r, "text/html;charset=ascii");

        ap_rputs("\n", r);
        ap_rputs("Invadev: C/C++ Tutorial", r);

        ap_rputs("Welcome to Invadev C++ Module in Apache!", r);

        return OK;

    }

     


    Hook function

    static void register_hooks(apr_pool_t* pool)
    {
        ap_hook_handler(invadev_handler, NULL, NULL, APR_HOOK_MIDDLE);
    }


    Module Declaration Data 

    module AP_MODULE_DECLARE_DATA invadev_module = {
        STANDARD20_MODULE_STUFF,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        register_hooks
    };


    Module Initialisation

    LoadModule invadev_module modules/mod_invadev.so

        SetHandler invadev

     

    Please follow the instructions accordinglly as instructed in the movie, and if you cannot play the video please click here [Youtube: C++ Module Apache].

    If you have any question please do not forget to leave a comments below.

    Stay Learn and Stay Young

  • blog comments powered by Disqus
  • Support Us
  • Help this website up and running by buying me a coffee for only $0.50.