Write Servlet In C (CC ++ Servlet Page)

xiaoxiao2021-03-06  22

Write Servlet In C (C / C Servlet Page)

By MOD_PEBBLE

Write a sentence before development, Pebble is designed to replace FastCGi, when you use this web language, at least you have a certain understanding of C / C . Otherwise, you may have to face someone else. For the question, such as: pointer, memory ....

What is CSP? What is MOD_PEBBLED?

MOD_PEBBLE is a module based on Apache, providing fast servlet development, providing session, cookie, etc., supports dynamic modification, file extension is .csp, is also a referusion of C / C Servlet Page.

CSP is a high-performance web development language.

With the help of MOD_PEBBLE, you can achieve some common features similar to the ASP, JSP, PHP, such as blending HTML code

Such as

test of Pebble
<%! - This is the first line, no appearance in .C file -%> <% @ include "incmsp"%> <% { Char * id = page-> getParam (page, "id"); if (id) page-> write (page, "
ID: % s
", ID );%>

MOD_PEBBLE supports the following syntax:

1.CSP comment, such annotations do not appear in the generated .C file <%! -> 2.LIB path, one line can only set a path <% @ lib "D: / myproc / compo / lib "%> 3.include path, one line can only set a path <% @ INC" D: / myproc / doodle / include "%> 4.Link parameter <% @ link" -ldoodle "%> 5. Compile parameter <% @ comp "-g2"%> 6. By a CSP file, the included CSP file does not generate the _cspservice () of the main line function, if the include file is changed, it is not possible to load To restart Apache <% @ include "incmsp"%> 7. Code section <% int i; ...%> 8. Function section, can declare function (recommended to expand the way in LIB) <%! INT foo (void) ...%>

CSP operation mechanism

First program the macro script, generate C source file code, and then use GCC to compile into dynamic link libraries, using Apache's DSO load run execution. The syntax is completely C style, so as long as the C language can do things, CSP can be done.

how to install?

First, if it is a Win32 platform, install MINGW, add the path where MINGW GCC.exe is located, install Apache2 (now only support Apache2, Apache1 is not done), and modify httpd.conf

LoadModule Pebble_Module Module / MOD_PEBBLE.DLL

AddHandler Pebble-script .csp

Pebble_path d: / myproc / mod_pebble / bin

Copy MOD_PEBBLE.DLL to the module directory under Apache2, the pebble_path is the PEBBLE buffer directory, so you must provide read and write permissions for this directory for Apache2, otherwise you cannot perform compilation, copy csp.dll to Winnt directory under.

Copy CSP.H to the moduud directory of MINGW, copy libcsp.a to mingw's lib directory, now you can create a test file Hello.csp

<% page-> write (page, "hello, peble! / n");%> When you open Hello.csp, print Hello, Pebbe! The installation is successful.

Since I have just been developed, there is no frequent test, so what you have encountered, I hope to report to me immediately (31-boy@163.com)

Some development instructions:

The design of Pebble is to adapt to the high-intensity work environment. So in the language selection, use the least safe C language, when you choose Pebble, there may be some headache will follow you, I hope you Come and pay attention to the following:

PEBBLE provides two memory pools of different life cycles: Page and Session

Page lifecycle within the current page, application method: void newmem = page-> getpageres (page, 128); so please do not use memory applications within Page in Session!

SESSION's life cycle is in the user's session process, the application method void newmem = page-> getsess (page, 128);

Most important: Please don't try to release the memory you apply from the above two memory pools! If you are your own Malloc's memory, please manage your own!

All functions starting with '_', please don't call, unless you know the peble!

Other treatment ...

Pebble is the time I have used for a week, so there is a lot of bugs, I still have a lot of work.

For example: prevent secondary compilation, module inspection, free module maintenance, other thread safety, database connection pool, etc., I have time to make up.

Up. Give God

转载请注明原文地址:https://www.9cbs.com/read-65338.html

New Post(0)