"Fossies" - the Fresh Open Source Software Archive

Member "tidy-html5-5.8.0/src/tidy-int.h" (16 Jul 2021, 7007 Bytes) of package /linux/www/tidy-html5-5.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "tidy-int.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.7.28_vs_5.8.0.

    1 #ifndef __TIDY_INT_H__
    2 #define __TIDY_INT_H__
    3 
    4 /* tidy-int.h -- internal library declarations
    5 
    6   (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
    7   See tidy.h for the copyright notice.
    8 
    9 */
   10 
   11 #include "tidy.h"
   12 #include "config.h"
   13 #include "lexer.h"
   14 #include "tags.h"
   15 #include "attrs.h"
   16 #include "pprint.h"
   17 #include "access.h"
   18 #include "message.h"
   19 
   20 #ifndef MAX
   21 #define MAX(a,b) (((a) > (b))?(a):(b))
   22 #endif
   23 #ifndef MIN
   24 #define MIN(a,b) (((a) < (b))?(a):(b))
   25 #endif
   26 
   27 /*\
   28  *  Issue #166 - repeated <main> element
   29  *  Change the previous on/off uint flag badForm
   30  *  to a BIT flag to support other than <form>
   31  *  errors. This could be extended more...
   32 \*/
   33 #define flg_BadForm     0x00000001
   34 #define flg_BadMain     0x00000002
   35 
   36 struct _TidyDocImpl
   37 {
   38     /* The Document Tree (and backing store buffer) */
   39     Node                root;       /* This MUST remain the first declared 
   40                                        variable in this structure */
   41     Lexer*              lexer;
   42 
   43     /* Config + Markup Declarations */
   44     TidyConfigImpl          config;
   45     TidyTagImpl             tags;
   46     TidyAttribImpl          attribs;
   47     TidyAccessImpl          access;
   48     TidyMutedMessages       muted;
   49 
   50     /* The Pretty Print buffer */
   51     TidyPrintImpl       pprint;
   52 
   53     /* I/O */
   54     StreamIn*                docIn;
   55     StreamOut*               docOut;
   56     StreamOut*               errout;
   57     TidyReportFilter         reportFilter;
   58     TidyReportCallback       reportCallback;
   59     TidyMessageCallback      messageCallback;
   60     TidyOptCallback          pOptCallback;
   61     TidyConfigCallback       pConfigCallback;
   62     TidyConfigChangeCallback pConfigChangeCallback;
   63     TidyPPProgress           progressCallback;
   64 
   65     /* Parse + Repair Results */
   66     uint                optionErrors;
   67     uint                errors;
   68     uint                warnings;
   69     uint                accessErrors;
   70     uint                infoMessages;
   71     uint                docErrors;
   72     int                 parseStatus;
   73 
   74     uint                badAccess;   /* for accessibility errors */
   75     uint                badLayout;   /* for bad style errors */
   76     uint                badChars;    /* for bad char encodings */
   77     uint                badForm;     /* bit field, for badly placed form tags, or other format errors */
   78     uint                footnotes;   /* bit field, for other footnotes, until formalized */
   79 
   80     Bool                HTML5Mode;   /* current mode is html5 */
   81     Bool                xmlDetected; /* true if XML was used/detected */
   82 
   83     /* Memory allocator */
   84     TidyAllocator*      allocator;
   85 
   86     /* Miscellaneous */
   87     void*               appData;
   88     uint                nClassId;
   89     Bool                inputHadBOM;
   90 
   91 #if PRESERVE_FILE_TIMES
   92     struct utimbuf      filetimes;
   93 #endif
   94     tmbstr              givenDoctype;
   95 };
   96 
   97 /** The basic struct for communicating a message within LibTidy. All of the
   98 **  relevant information pertaining to a message can be retrieved with the
   99 **  accessor functions and one of these records.
  100 */
  101 struct _TidyMessageImpl
  102 {
  103     TidyDocImpl         *tidyDoc;     /* document instance this message is attributed to */
  104     Node                *tidyNode;    /* the node reporting the message, if applicable */
  105     uint                code;         /* the message code */
  106     int                 line;         /* the line message applies to */
  107     int                 column;       /* the column the message applies to */
  108     TidyReportLevel     level;        /* the severity level of the message */
  109     Bool                allowMessage; /* indicates whether or not a filter rejected a message */
  110     Bool                muted;        /* indicates whether or not a configuration mutes this message */
  111     
  112     int                 argcount;    /* the number of arguments */
  113     struct printfArg*   arguments;   /* the arguments' values and types */
  114 
  115     ctmbstr             messageKey;             /* the message code as a key string */
  116 
  117     ctmbstr             messageFormatDefault;   /* the built-in format string */
  118     ctmbstr             messageFormat;          /* the localized format string */
  119 
  120     tmbstr              messageDefault;         /* the message, formatted, default language */
  121     tmbstr              message;                /* the message, formatted, localized */
  122 
  123     tmbstr              messagePosDefault;      /* the position part, default language */
  124     tmbstr              messagePos;             /* the position part, localized */
  125 
  126     ctmbstr             messagePrefixDefault;   /* the prefix part, default language */
  127     ctmbstr             messagePrefix;          /* the prefix part, localized */
  128     
  129     tmbstr              messageOutputDefault;   /* the complete string Tidy would output */
  130     tmbstr              messageOutput;          /* the complete string, localized */
  131 };
  132 
  133 
  134 #define tidyDocToImpl( tdoc )           ((TidyDocImpl*)(tdoc))
  135 #define tidyImplToDoc( doc )            ((TidyDoc)(doc))
  136 
  137 #define tidyMessageToImpl( tmessage )   ((TidyMessageImpl*)(tmessage))
  138 #define tidyImplToMessage( message )    ((TidyMessage)(message))
  139 
  140 #define tidyNodeToImpl( tnod )          ((Node*)(tnod))
  141 #define tidyImplToNode( node )          ((TidyNode)(node))
  142 
  143 #define tidyAttrToImpl( tattr )         ((AttVal*)(tattr))
  144 #define tidyImplToAttr( attval )        ((TidyAttr)(attval))
  145 
  146 #define tidyOptionToImpl( topt )        ((const TidyOptionImpl*)(topt))
  147 #define tidyImplToOption( option )      ((TidyOption)(option))
  148 
  149 
  150 /** Wrappers for easy memory allocation using the document's allocator */
  151 #define TidyDocAlloc(doc, size) TidyAlloc((doc)->allocator, size)
  152 #define TidyDocRealloc(doc, block, size) TidyRealloc((doc)->allocator, block, size)
  153 #define TidyDocFree(doc, block) TidyFree((doc)->allocator, block)
  154 #define TidyDocPanic(doc, msg) TidyPanic((doc)->allocator, msg)
  155 
  156 TY_PRIVATE int          TY_(DocParseStream)( TidyDocImpl* impl, StreamIn* in );
  157 
  158 /*
  159    [i_a] generic node tree traversal code; used in several spots.
  160 
  161    Define your own callback, which returns one of the NodeTraversalSignal values
  162    to instruct the tree traversal routine TraverseNodeTree() what to do.
  163 
  164    Pass custom data to/from the callback using the 'propagate' reference.
  165  */
  166 typedef enum
  167 {
  168     ContinueTraversal,       /* visit siblings and children */
  169     SkipChildren,            /* visit siblings of this node; ignore its children */
  170     SkipSiblings,            /* ignore subsequent siblings of this node; ignore their children; traverse  */
  171     SkipChildrenAndSiblings, /* visit siblings of this node; ignore its children */
  172     VisitParent,             /* REVERSE traversal: visit the parent of the current node */
  173     ExitTraversal            /* terminate traversal on the spot */
  174 } NodeTraversalSignal;
  175 
  176 typedef NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl* doc, Node* node, void *propagate);
  177 
  178 TY_PRIVATE NodeTraversalSignal TY_(TraverseNodeTree)(TidyDocImpl* doc, Node* node, NodeTraversalCallBack *cb, void *propagate);
  179 
  180 #endif /* __TIDY_INT_H__ */