Back to index

courier  0.68.2
recipenode.h
Go to the documentation of this file.
00001 #ifndef recipenode_h
00002 #define       recipenode_h
00003 
00004 
00005 #include      "buffer.h"
00006 class Recipe;
00007 
00009 //
00010 // RecipeNode class - one "clause" in a recipe file, such as an "if"
00011 // statement, or an expression.
00012 //
00013 // All RecipeNodes which represent a single recipe file are linked in a
00014 // doubly-linked list anchored in their Recipe object.
00015 //
00016 // The RecipeNodes are arranged in a hierarchical format:
00017 //
00018 // prevNode/nextNode is the doubly-linked list anchored in the Recipe
00019 // object.  All RecipeNodes dynamically allocated by the Recipe class
00020 // are on this list.
00021 //
00022 // firstChild/lastChild is a doubly-linked list of RecipeNodes that are
00023 // considered descendants of this node.  For example, a node that
00024 // represents an "||" (logical or operation) will have two descendants,
00025 // the left side, and the right side, of the expression.  This RecipeNode
00026 // itself is on the descendant list of its parent.  All descendants of
00027 // a RecipeNode have the parentNode pointer point to this RecipeNode.
00028 // prevSibling/nextSibling is a doubly-linked list of all descendants of
00029 // a single RecipeNode.
00030 //
00031 // This provides a generic linkage that is used to built a hierarchy that
00032 // represents the logical layout of a recipe file.  The remaining fields
00033 // store information pertaining to each individual kind of a RecipeNode
00034 // object.  The nodeType field designates what kind of a RecipeNode object
00035 // this is, which remaining fields are used depends on the nodeType field.
00036 //
00037 // The Recipe class calls the Evaluate() function of the first RecipeNode
00038 // that represents that entire recipe file.  The set of Evaluate() functions
00039 // are logically involved to actually execute the given recipe file.
00040 //
00042 
00043 class RecipeNode {
00044        RecipeNode *prevNode, *nextNode;   // List of all nodes in
00045                                           // this recipe.
00046 
00047        RecipeNode *parentNode;                   // Parent of this node.
00048        RecipeNode *prevSibling, *nextSibling;    // Siblings of this node.
00049        RecipeNode *firstChild, *lastChild;       // Its own children.
00050 
00051        Buffer str;
00052        int    linenum;
00053 
00054        void dollarexpand(Recipe &, Buffer &);
00055        int dollarexpand(Recipe &, Buffer &, int);
00056 
00057 public:
00058        friend class Recipe;
00059 
00060        enum RecipeNodeType {
00061               statementlist,
00062               assignment,
00063               qstring,
00064               sqstring,
00065               btstring,
00066               regexpr,
00067               add,
00068               subtract,
00069               multiply,
00070               divide,
00071               lessthan,
00072               lessthanoreq,
00073               greaterthan,
00074               greaterthanoreq,
00075               equal,
00076               notequal,
00077               concat,
00078               logicalor,
00079               logicaland,
00080               bitwiseor,
00081               bitwiseand,
00082               logicalnot,
00083               bitwisenot,
00084               strlessthan,
00085               strlessthanoreq,
00086               strgreaterthan,
00087               strgreaterthanoreq,
00088               strequal,
00089               strnotequal,
00090               strlength,
00091               strsubstr,
00092               strregexp,
00093               ifelse,
00094               whileloop,
00095               deliver,
00096               delivercc,
00097               exception,
00098               echo,
00099               xfilter,
00100               dotlock,
00101               flock,
00102               logfile,
00103               log,
00104               include,
00105               exit,
00106               foreach,
00107               getaddr,
00108               lookup,
00109               escape,
00110               to_lower,
00111               to_upper,
00112               hasaddr,
00113               gdbmopen,
00114               gdbmclose,
00115               gdbmfetch,
00116               gdbmstore,
00117               timetoken,
00118               importtoken,
00119               unset
00120               } nodeType;
00121 
00122        RecipeNode(RecipeNodeType);
00123        ~RecipeNode()                             {}
00124        void   Evaluate(Recipe &, Buffer &);
00125 private:
00126        void   AppendSibling(RecipeNode *);
00127        void   EvaluateString(Recipe &r, Buffer &b);
00128 
00129        void EvaluateStrRegExp(Recipe &, Buffer &, Buffer *);
00130        void EvaluateRegExp(Recipe &, Buffer &, Buffer *);
00131 static void   ParseRegExp(const Buffer &, Buffer &, Buffer &);
00132 static int    boolean(const Buffer &);
00133 
00134        void rfc822getaddr(Buffer &);
00135        int rfc822hasaddr(Buffer &);
00136        int rfc822hasaddr(const char *, Buffer &);
00137        void SpecialEscape(Buffer &);
00138        int dolookup(Buffer &, Buffer &, Buffer &);
00139        } ;
00140 #endif