diff --git a/Global.h b/Global.h index da6693f..b7021e8 100644 --- a/Global.h +++ b/Global.h @@ -1,8 +1,9 @@ #ifndef __Global_h__ -#define __Global_h__ +# define __Global_h__ -#include "MString.h" -#include +# include "MString.h" +# include "CGIFormattedData.h" +# include namespace jet { @@ -25,6 +26,8 @@ namespace jet { void setupFormURLEncoded(coreutils::ZString &formdata); char *errorCursor = NULL; + + coreutils::CGIFormattedData cookies; std::map variables; std::map cgiVariables; std::map sessions; @@ -33,6 +36,7 @@ namespace jet { char **envp; bool cgi = false; bool session = false; + coreutils::MString sessionId; }; diff --git a/Operand.cpp b/Operand.cpp index d2bd0b5..9b5c850 100644 --- a/Operand.cpp +++ b/Operand.cpp @@ -86,10 +86,21 @@ namespace jet { } else throw coreutils::Exception("Expecting ) at end of TRIM expression."); } else if(in.ifNextIgnoreCase("TOUPPER")) { - - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for TOUPPER parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + string = parm1.string.toUpper(); + } else + throw coreutils::Exception("Expecting ) at end of TOUPPER expression."); } else if(in.ifNextIgnoreCase("TOLOWER")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for TOLOWER parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + string = parm1.string.toLower(); + } else + throw coreutils::Exception("Expecting ) at end of TOLOWER expression."); } else if(in.ifNextIgnoreCase("REVERSE")) { } else if(in.ifNextIgnoreCase("CONCAT")) { diff --git a/Tag.cpp b/Tag.cpp index 5344eb2..9120131 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -401,6 +401,9 @@ namespace jet { } else if(variable.ifNext("%")) { renderVariableName(variable, name, modifier); return getenv(name.c_str()); + } else if(variable.ifNext("^")) { + renderVariableName(variable, name, modifier); + return global.cookies.data[variable]; } else { renderVariableName(variable, name, modifier); name.split("."); diff --git a/__jet.cpp b/__jet.cpp index d9b8fe0..4604350 100644 --- a/__jet.cpp +++ b/__jet.cpp @@ -1,5 +1,6 @@ #include "__jet.h" #include "Exception.h" +#include "Global.h" #include #include #include @@ -12,9 +13,7 @@ namespace jet { global.cgi = true; if(keywordDefined("sessiondir")) { - coreutils::ZString cookies = getenv("HTTP_COOKIE"); - storeVariable("cookies", cookies, "global"); - + cookies = getenv("HTTP_COOKIE"); global.session = true; // if request_has_cookie then // pull sessionfile from sessiondir. diff --git a/tests/testvar.jet b/tests/testvar.jet index 89c02b4..b10195f 100755 --- a/tests/testvar.jet +++ b/tests/testvar.jet @@ -21,4 +21,7 @@ $[ix] $[ix] $[test64;tobase64] +$[test64;toupper] + +$[testupperexpr]