#ifndef __Global_h__ # define __Global_h__ # include "MString.h" # include "CGIFormattedData.h" # include "CGIFormData.h" # include "StreamReader.h" # include "JFile.h" # include namespace jet { class __mysql; class __imap; class Tag; class Global { public: Global(char **envp); virtual ~Global(); void dump(); bool sessionExists(coreutils::MString sessionId); void addSession(coreutils::MString sessionId, __mysql *mysql); void removeSession(coreutils::MString sessionId); __mysql * getSession(coreutils::MString sessionId); bool imapSessionExists(coreutils::MString sessionId); void addImapSession(coreutils::MString sessionId, __imap *imap); void removeImapSession(coreutils::MString sessionId); __imap * getImapSession(coreutils::MString sessionId); coreutils::ZString getSessionVariable(coreutils::MString &splitName); void outputHeaders(); void setupFormData(coreutils::ZString &formdata); void setupFormURLEncoded(coreutils::ZString &formdata); char *errorCursor = NULL; coreutils::CGIFormattedData cookies; /// /// cgiReader backs cgiData below - it must outlive it, since /// CGIFormData (a Parser) only holds a reference to it, not its own /// copy of the request body. Declared before cgiData so it's /// constructed first and destroyed last (member destruction order /// mirrors declaration order). /// coreutils::StreamReader cgiReader; coreutils::CGIFormData *cgiData = NULL; /// /// sessionFile backs $[@name] (read) and /// (write) - a JSON file at sessiondir/.json, loaded when /// opened and saved automatically when destroyed (JFile/MFile's own /// RAII behavior - see MFile.cpp). NULL unless cgi mode and the /// sessiondir keyword are both active for this request. /// coreutils::JFile *sessionFile = NULL; std::map variables; std::map sessions; std::map headers; std::map tags; // Populated once per compiled .jtc module's own entry function (see // jetc's TAGDEF codegen) - a top-level definition // that jetc could compile directly registers its own render // function here under its lowercase name, same key convention as // `tags` above. __dotag checks this first before falling back to // the text-based findTagDefinition()/processContainer() path (see // __dotag.cpp), avoiding a full re-parse of the definition's body // on every invocation. A miss here (a locally-scoped/nested tag // definition, or content that was never compiled at all) is always // safe - it just means the existing interpreted path runs exactly // as it always has; this is a pure additive fast path, never a // replacement for `tags`, which every TAGDEF still populates too. std::map compiledTags; char **envp; bool cgi = false; bool session = false; coreutils::MString sessionId; // Deliberately the LAST member declared in Global - appended // here, after every pre-existing field, rather than inserted // earlier among them, so this addition does not shift the // memory offset of any field that existed before it. See // __imap.h for what registers here. std::map imapSessions; }; } #endif