ecppc archivo.ecpp
g++ -c -fPIC archivo.cpp
Con esto tenemos un .so que es lo que será ejecutado por el servidor (avisandole por un archivo de configuración).
Ejemplo de código de una calculadora (el original):
<%args>
double arg1 = 0; // typed parameter with default value
double arg2 = 0; // typed parameter with default value
char op = ' '; // typed parameter with default value
method = "post"; // parameter with default type std::string
<{ // <= this starts a c++-processing-block
double result = 0.0;
bool result_ok = true;
switch (op)
{
case '+': result = arg1 + arg2; break;
case '-': result = arg1 - arg2; break;
case '*': result = arg1 * arg2; break;
case '/': result = arg1 / arg2; break;
default: result_ok = false;
}
}> <# <= this terminates a c++-processing-block (and this is a ecpp-comment) #>
<html>
<head>
<title>Calculatortitle>
head>
<body bgcolor=#ffffcc>
<h1>Tommi's Tnt-Calculatorh1>
<form method=<$method$>> <# print value of a c++-variable #>
<# you can output other types as well - arg1 and arg2 are of type double.
They just need a outputstream-operator #>
<input type="text" name="arg1" value="<$arg1$>"> <br>
<input type="text" name="arg2" value="<$arg2$>"> <br>
<input type="submit" name="op" value="+">
<input type="submit" name="op" value="-">
<input type="submit" name="op" value="*">
<input type="submit" name="op" value="/">
% if (method == "get") { // '%' in the first column makes a c++-one-liner
% }
form>
% if (result_ok) {
<hr>
<$arg1$> <$op$> <$arg2$> = <$result$>
% }
body>
html>
Sin duda bastente copado para ponerse a revisar y sacarle jugo.
La web oficial: http://www.tntnet.org
0 comentarios:
Publicar un comentario