HTML Tidy  5.4.0
The HTACG Tidy HTML Project
tidy.c File Reference

Data Structures

struct  AllOption_t
 Array holding all options. More...
 
struct  CmdOptDesc
 The struct and subsequent array keep the help output structured because we also output all of this stuff as as XML. More...
 
struct  OptionDesc
 Structure maintains a description of an option. More...
 

Macros

#define SPRTF   printf
 

Typedefs

typedef void(* OptionFunc) (TidyDoc, TidyOption, OptionDesc *)
 

Enumerations

enum  CmdOptCategory {
  CmdOptFileManip,
  CmdOptCatFIRST = CmdOptFileManip,
  CmdOptProcDir,
  CmdOptCharEnc,
  CmdOptMisc,
  CmdOptXML,
  CmdOptCatLAST
}
 This enum is used to categorize the options for help output. More...
 

Functions

static tmbstr cleanup_description (ctmbstr description)
 Cleans up the HTML-laden option descriptions for console output. More...
 
static int cmpOpt (const void *e1_, const void *e2_)
 A simple option comparator. More...
 
static ctmbstr ConfigCategoryName (TidyConfigCategory id)
 Returns the configuration category name for the specified configuration category id. More...
 
static const char * cutToWhiteSpace (const char *s, uint offset, char *sbuf)
 Used by print2Columns and print3Columns to manage whitespace. More...
 
static void ForEachOption (TidyDoc tdoc, OptionFunc OptionPrint)
 An iterator for the unsorted options. More...
 
static void ForEachSortedOption (TidyDoc tdoc, OptionFunc OptionPrint)
 An iterator for the sorted options. More...
 
static tmbstr get_escaped_name (ctmbstr name)
 Escape a name for XML output. More...
 
static ctmbstr get_final_name (ctmbstr prog)
 Returns the final name of the tidy executable. More...
 
static tmbstr get_option_names (const CmdOptDesc *pos)
 Retrieve the options' names from the structure as a single string. More...
 
static tmbstr GetAllowedValues (TidyOption topt, const OptionDesc *d)
 Retrieves allowed values for an option. More...
 
static tmbstr GetAllowedValuesFromPick (TidyOption topt)
 Retrieves allowed values from an option's pick list. More...
 
static void GetOption (TidyDoc tdoc, TidyOption topt, OptionDesc *d)
 Create OptionDesc "d" related to "opt". More...
 
static void getSortedOption (TidyDoc tdoc, AllOption_t *tOption)
 Returns options sorted. More...
 
static void help (ctmbstr prog)
 Handles the -help service. More...
 
static Bool isAutoBool (TidyOption topt)
 Utility to determine if an option is an AutoBool. More...
 
static void lang_help (void)
 Handles the -lang help service. More...
 
static void localize_option_names (CmdOptDesc *pos)
 Option names aren't localized, but the sample fields are, for example <file> should be <archivo> in Spanish. More...
 
int main (int argc, char **argv)
 MAIN – let's do something here. More...
 
static void optionDescribe (TidyDoc tdoc, char *tag)
 Handles the -help-option service. More...
 
static void optionhelp (TidyDoc tdoc)
 Handles the -help-config service. More...
 
static void optionvalues (TidyDoc tdoc)
 Handles the -show-config service. More...
 
static void outOfMemory (void)
 Exits with an error in the event of an out of memory condition. More...
 
static void print1Column (const char *fmt, uint l1, const char *c1)
 Outputs one column of text. More...
 
static void print2Columns (const char *fmt, uint l1, uint l2, const char *c1, const char *c2)
 Outputs two columns of text. More...
 
static void print3Columns (const char *fmt, uint l1, uint l2, uint l3, const char *c1, const char *c2, const char *c3)
 Outputs three columns of text. More...
 
static void print_help_option (void)
 Outputs a complete help option (text) More...
 
static void print_xml_help_option (void)
 Outputs a complete help option (XML) More...
 
static void print_xml_help_option_element (ctmbstr element, ctmbstr name)
 Outputs an XML element for an option. More...
 
static void PrintAllowedValues (TidyOption topt, const OptionDesc *d)
 Prints an option's allowed values. More...
 
static void PrintAllowedValuesFromPick (TidyOption topt)
 Prints an option's allowed value as specified in its pick list. More...
 
static void printOption (TidyDoc ARG_UNUSED(tdoc), TidyOption topt, OptionDesc *d)
 Prints a single option. More...
 
static void printOptionValues (TidyDoc ARG_UNUSED(tdoc), TidyOption topt, OptionDesc *d)
 Prints the option value for a given option. More...
 
static void printXMLCrossRef (TidyDoc tdoc, TidyOption topt)
 Prints for XML an option's . More...
 
static void printXMLDescription (TidyDoc tdoc, TidyOption topt)
 Prints for XML an option's . More...
 
static void printXMLOption (TidyDoc tdoc, TidyOption topt, OptionDesc *d)
 Prints for XML an option. More...
 
static void printXMLOptionString (TidyDoc tdoc, TidyOption topt, OptionDesc *d)
 Handles the printing of option description for -xml-options-strings service. More...
 
static Bool samefile (ctmbstr filename1, ctmbstr filename2)
 Indicates whether or not two filenames are the same. More...
 
static tmbstr stringWithFormat (const ctmbstr fmt,...)
 Create a new string with a format and arguments. More...
 
static void tidy_cleanup ()
 Handles exit cleanup. More...
 
void tidyPrintTidyLanguageNames (ctmbstr format)
 Prints the languages the are currently built into Tidy, using the specified format string. More...
 
void tidyPrintWindowsLanguageNames (ctmbstr format)
 Prints the Windows language names that Tidy recognizes, using the specified format string. More...
 
static void unknownOption (uint c)
 Provides the unknown option output. More...
 
static void version (void)
 Handles the -version service. More...
 
static void xml_error_strings (TidyDoc tdoc)
 Handles the -xml-error-strings service. More...
 
static void xml_help (void)
 Provides the -xml-help service. More...
 
static void xml_options_strings (TidyDoc tdoc)
 Handles the -xml-options-strings service. More...
 
static void xml_strings (void)
 Handles the -xml-strings service. More...
 
static void XMLoptionhelp (TidyDoc tdoc)
 Handles the -xml-config service. More...
 

Variables

struct {
uint key
 Key to fetch the localized string. More...
 
ctmbstr mnemonic
 Used in XML as a class. More...
 
cmdopt_catname []
 This array contains headings that will be used in help ouput. More...
 
static const CmdOptDesc cmdopt_defs []
 
static FILE * errout = NULL
 
static const char fmt [] = "%-27.27s %-9.9s %-40.40s\n"
 
static const char helpfmt [] = " %-25.25s %-52.52s\n"
 Format strings and decorations used in output. More...
 
static const char helpul [] = "-----------------------------------------------------------------"
 
static const char ul [] = "================================================================="
 
static const char valfmt [] = "%-27.27s %-9.9s %-1.1s%-39.39s\n"
 

Data Structure Documentation

◆ AllOption_t

struct AllOption_t

Array holding all options.

Contains a trailing sentinel.

Data Fields
TidyOption topt[N_TIDY_OPTIONS]

◆ CmdOptDesc

struct CmdOptDesc

The struct and subsequent array keep the help output structured because we also output all of this stuff as as XML.

Data Fields
CmdOptCategory cat Category.
ctmbstr eqconfig Equivalent configuration option.
uint key Key to fetch the localized description.
ctmbstr name1 Name.
ctmbstr name2 Name.
ctmbstr name3 Name.
uint subKey Secondary substitution key.

◆ OptionDesc

struct OptionDesc

Structure maintains a description of an option.

Data Fields
ctmbstr cat Category.
ctmbstr def default
Bool haveVals if yes, vals is valid
ctmbstr name Name.
tmbchar tempdefs[80] storage for default such as integer
ctmbstr type "String, ...
ctmbstr vals Potential values.

If NULL, use an external function

Macro Definition Documentation

◆ SPRTF

#define SPRTF   printf

Typedef Documentation

◆ OptionFunc

typedef void(* OptionFunc) (TidyDoc, TidyOption, OptionDesc *)

Enumeration Type Documentation

◆ CmdOptCategory

This enum is used to categorize the options for help output.

Enumerator
CmdOptFileManip 
CmdOptCatFIRST 
CmdOptProcDir 
CmdOptCharEnc 
CmdOptMisc 
CmdOptXML 
CmdOptCatLAST 

Function Documentation

◆ cleanup_description()

static tmbstr cleanup_description ( ctmbstr  description)
static

Cleans up the HTML-laden option descriptions for console output.

It's just a simple HTML filtering/replacement function. Will return an allocated string.

◆ cmpOpt()

static int cmpOpt ( const void *  e1_,
const void *  e2_ 
)
static

A simple option comparator.

◆ ConfigCategoryName()

static ctmbstr ConfigCategoryName ( TidyConfigCategory  id)
static

Returns the configuration category name for the specified configuration category id.

This will be used as an XML class attribute value.

◆ cutToWhiteSpace()

static const char* cutToWhiteSpace ( const char *  s,
uint  offset,
char *  sbuf 
)
static

Used by print2Columns and print3Columns to manage whitespace.

◆ ForEachOption()

static void ForEachOption ( TidyDoc  tdoc,
OptionFunc  OptionPrint 
)
static

An iterator for the unsorted options.

◆ ForEachSortedOption()

static void ForEachSortedOption ( TidyDoc  tdoc,
OptionFunc  OptionPrint 
)
static

An iterator for the sorted options.

◆ get_escaped_name()

static tmbstr get_escaped_name ( ctmbstr  name)
static

Escape a name for XML output.

◆ get_final_name()

static ctmbstr get_final_name ( ctmbstr  prog)
static

Returns the final name of the tidy executable.

◆ get_option_names()

static tmbstr get_option_names ( const CmdOptDesc pos)
static

Retrieve the options' names from the structure as a single string.

◆ GetAllowedValues()

static tmbstr GetAllowedValues ( TidyOption  topt,
const OptionDesc d 
)
static

Retrieves allowed values for an option.

◆ GetAllowedValuesFromPick()

static tmbstr GetAllowedValuesFromPick ( TidyOption  topt)
static

Retrieves allowed values from an option's pick list.

◆ GetOption()

static void GetOption ( TidyDoc  tdoc,
TidyOption  topt,
OptionDesc d 
)
static

Create OptionDesc "d" related to "opt".

◆ getSortedOption()

static void getSortedOption ( TidyDoc  tdoc,
AllOption_t tOption 
)
static

Returns options sorted.

◆ help()

static void help ( ctmbstr  prog)
static

Handles the -help service.

◆ isAutoBool()

static Bool isAutoBool ( TidyOption  topt)
static

Utility to determine if an option is an AutoBool.

◆ lang_help()

static void lang_help ( void  )
static

Handles the -lang help service.

◆ localize_option_names()

static void localize_option_names ( CmdOptDesc pos)
static

Option names aren't localized, but the sample fields are, for example <file> should be <archivo> in Spanish.

◆ main()

int main ( int  argc,
char **  argv 
)

MAIN – let's do something here.

◆ optionDescribe()

static void optionDescribe ( TidyDoc  tdoc,
char *  tag 
)
static

Handles the -help-option service.

◆ optionhelp()

static void optionhelp ( TidyDoc  tdoc)
static

Handles the -help-config service.

◆ optionvalues()

static void optionvalues ( TidyDoc  tdoc)
static

Handles the -show-config service.

◆ outOfMemory()

static void outOfMemory ( void  )
static

Exits with an error in the event of an out of memory condition.

◆ print1Column()

static void print1Column ( const char *  fmt,
uint  l1,
const char *  c1 
)
static

Outputs one column of text.

◆ print2Columns()

static void print2Columns ( const char *  fmt,
uint  l1,
uint  l2,
const char *  c1,
const char *  c2 
)
static

Outputs two columns of text.

◆ print3Columns()

static void print3Columns ( const char *  fmt,
uint  l1,
uint  l2,
uint  l3,
const char *  c1,
const char *  c2,
const char *  c3 
)
static

Outputs three columns of text.

◆ print_help_option()

static void print_help_option ( void  )
static

Outputs a complete help option (text)

◆ print_xml_help_option()

static void print_xml_help_option ( void  )
static

Outputs a complete help option (XML)

◆ print_xml_help_option_element()

static void print_xml_help_option_element ( ctmbstr  element,
ctmbstr  name 
)
static

Outputs an XML element for an option.

◆ PrintAllowedValues()

static void PrintAllowedValues ( TidyOption  topt,
const OptionDesc d 
)
static

Prints an option's allowed values.

◆ PrintAllowedValuesFromPick()

static void PrintAllowedValuesFromPick ( TidyOption  topt)
static

Prints an option's allowed value as specified in its pick list.

◆ printOption()

static void printOption ( TidyDoc   ARG_UNUSEDtdoc,
TidyOption  topt,
OptionDesc d 
)
static

Prints a single option.

◆ printOptionValues()

static void printOptionValues ( TidyDoc   ARG_UNUSEDtdoc,
TidyOption  topt,
OptionDesc d 
)
static

Prints the option value for a given option.

◆ printXMLCrossRef()

static void printXMLCrossRef ( TidyDoc  tdoc,
TidyOption  topt 
)
static

Prints for XML an option's .

◆ printXMLDescription()

static void printXMLDescription ( TidyDoc  tdoc,
TidyOption  topt 
)
static

Prints for XML an option's .

◆ printXMLOption()

static void printXMLOption ( TidyDoc  tdoc,
TidyOption  topt,
OptionDesc d 
)
static

Prints for XML an option.

◆ printXMLOptionString()

static void printXMLOptionString ( TidyDoc  tdoc,
TidyOption  topt,
OptionDesc d 
)
static

Handles the printing of option description for -xml-options-strings service.

◆ samefile()

static Bool samefile ( ctmbstr  filename1,
ctmbstr  filename2 
)
static

Indicates whether or not two filenames are the same.

◆ stringWithFormat()

static tmbstr stringWithFormat ( const ctmbstr  fmt,
  ... 
)
static

Create a new string with a format and arguments.

◆ tidy_cleanup()

static void tidy_cleanup ( )
static

Handles exit cleanup.

◆ tidyPrintTidyLanguageNames()

void tidyPrintTidyLanguageNames ( ctmbstr  format)

Prints the languages the are currently built into Tidy, using the specified format string.

◆ tidyPrintWindowsLanguageNames()

void tidyPrintWindowsLanguageNames ( ctmbstr  format)

Prints the Windows language names that Tidy recognizes, using the specified format string.

◆ unknownOption()

static void unknownOption ( uint  c)
static

Provides the unknown option output.

◆ version()

static void version ( void  )
static

Handles the -version service.

◆ xml_error_strings()

static void xml_error_strings ( TidyDoc  tdoc)
static

Handles the -xml-error-strings service.

This service is primarily helpful to developers who need to generate an updated list of strings to expect when using TidyReportFilter3. Included in the output is the current string associated with the error symbol.

◆ xml_help()

static void xml_help ( void  )
static

Provides the -xml-help service.

◆ xml_options_strings()

static void xml_options_strings ( TidyDoc  tdoc)
static

Handles the -xml-options-strings service.

This service is primarily helpful to developers and localizers to test that option description strings as represented on screen output are correct and do not break tidy.

◆ xml_strings()

static void xml_strings ( void  )
static

Handles the -xml-strings service.

This service was primarily helpful to developers and localizers to compare localized strings to the built in en strings. It's probably better to use our POT/PO workflow with your favorite tools, or simply diff the language header files directly. Important: The attribute id is not a specification, promise, or part of an API. You must not depend on this value.

◆ XMLoptionhelp()

static void XMLoptionhelp ( TidyDoc  tdoc)
static

Handles the -xml-config service.

Variable Documentation

◆ cmdopt_catname

const { ... } cmdopt_catname[]
Initial value:
= {
{ "file-manip", TC_STRING_FILE_MANIP },
{ "process-directives", TC_STRING_PROCESS_DIRECTIVES },
{ "char-encoding", TC_STRING_CHAR_ENCODING },
{ "misc", TC_STRING_MISC },
{ "xml", TC_STRING_XML }
}
Definition: language.h:181
Definition: language.h:183
Definition: language.h:184
Definition: language.h:182
Definition: language.h:177

This array contains headings that will be used in help ouput.

◆ cmdopt_defs

const CmdOptDesc cmdopt_defs[]
static
Initial value:
= {
{ CmdOptFileManip, "-output <%s>", TC_OPT_OUTPUT, TC_LABEL_FILE, "output-file: <%s>", "-o <%s>" },
{ CmdOptFileManip, "-config <%s>", TC_OPT_CONFIG, TC_LABEL_FILE, NULL },
{ CmdOptFileManip, "-file <%s>", TC_OPT_FILE, TC_LABEL_FILE, "error-file: <%s>", "-f <%s>" },
{ CmdOptFileManip, "-modify", TC_OPT_MODIFY, 0, "write-back: yes", "-m" },
{ CmdOptProcDir, "-indent", TC_OPT_INDENT, 0, "indent: auto", "-i" },
{ CmdOptProcDir, "-wrap <%s>", TC_OPT_WRAP, TC_LABEL_COL, "wrap: <%s>", "-w <%s>" },
{ CmdOptProcDir, "-upper", TC_OPT_UPPER, 0, "uppercase-tags: yes", "-u" },
{ CmdOptProcDir, "-clean", TC_OPT_CLEAN, 0, "clean: yes", "-c" },
{ CmdOptProcDir, "-bare", TC_OPT_BARE, 0, "bare: yes", "-b" },
{ CmdOptProcDir, "-gdoc", TC_OPT_GDOC, 0, "gdoc: yes", "-g" },
{ CmdOptProcDir, "-numeric", TC_OPT_NUMERIC, 0, "numeric-entities: yes", "-n" },
{ CmdOptProcDir, "-errors", TC_OPT_ERRORS, 0, "markup: no", "-e" },
{ CmdOptProcDir, "-quiet", TC_OPT_QUIET, 0, "quiet: yes", "-q" },
{ CmdOptProcDir, "-omit", TC_OPT_OMIT, 0, "omit-optional-tags: yes" },
{ CmdOptProcDir, "-xml", TC_OPT_XML, 0, "input-xml: yes" },
{ CmdOptProcDir, "-asxml", TC_OPT_ASXML, 0, "output-xhtml: yes", "-asxhtml" },
{ CmdOptProcDir, "-ashtml", TC_OPT_ASHTML, 0, "output-html: yes" },
{ CmdOptProcDir, "-access <%s>", TC_OPT_ACCESS, TC_LABEL_LEVL, "accessibility-check: <%s>" },
{ CmdOptCharEnc, "-raw", TC_OPT_RAW, 0, NULL },
{ CmdOptCharEnc, "-ascii", TC_OPT_ASCII, 0, NULL },
{ CmdOptCharEnc, "-latin0", TC_OPT_LATIN0, 0, NULL },
{ CmdOptCharEnc, "-latin1", TC_OPT_LATIN1, 0, NULL },
{ CmdOptCharEnc, "-iso2022", TC_OPT_ISO2022, 0, NULL },
{ CmdOptCharEnc, "-utf8", TC_OPT_UTF8, 0, NULL },
{ CmdOptCharEnc, "-mac", TC_OPT_MAC, 0, NULL },
{ CmdOptCharEnc, "-win1252", TC_OPT_WIN1252, 0, NULL },
{ CmdOptCharEnc, "-ibm858", TC_OPT_IBM858, 0, NULL },
{ CmdOptCharEnc, "-utf16le", TC_OPT_UTF16LE, 0, NULL },
{ CmdOptCharEnc, "-utf16be", TC_OPT_UTF16BE, 0, NULL },
{ CmdOptCharEnc, "-utf16", TC_OPT_UTF16, 0, NULL },
{ CmdOptCharEnc, "-big5", TC_OPT_BIG5, 0, NULL },
{ CmdOptCharEnc, "-shiftjis", TC_OPT_SHIFTJIS, 0, NULL },
{ CmdOptMisc, "-version", TC_OPT_VERSION, 0, NULL, "-v" },
{ CmdOptMisc, "-help", TC_OPT_HELP, 0, NULL, "-h", "-?" },
{ CmdOptMisc, "-help-config", TC_OPT_HELPCFG, 0, NULL },
{ CmdOptMisc, "-show-config", TC_OPT_SHOWCFG, 0, NULL },
{ CmdOptMisc, "-help-option <%s>", TC_OPT_HELPOPT, TC_LABEL_OPT, NULL },
{ CmdOptMisc, "-language <%s>", TC_OPT_LANGUAGE, TC_LABEL_LANG, "language: <%s>" },
{ CmdOptXML, "-xml-help", TC_OPT_XMLHELP, 0, NULL },
{ CmdOptXML, "-xml-config", TC_OPT_XMLCFG, 0, NULL },
{ CmdOptXML, "-xml-strings", TC_OPT_XMLSTRG, 0, NULL },
{ CmdOptXML, "-xml-error-strings", TC_OPT_XMLERRS, 0, NULL },
{ CmdOptXML, "-xml-options-strings", TC_OPT_XMLOPTS, 0, NULL },
{ CmdOptMisc, NULL, 0, 0, NULL }
}
Definition: language.h:143
Definition: language.h:123
Definition: language.h:144
Definition: language.h:146
Definition: language.h:140
Definition: language.h:122
Definition: language.h:162
Definition: language.h:136
Definition: language.h:126
Definition: language.h:127
Definition: language.h:134
Definition: language.h:131
Definition: language.h:156
Definition: language.h:132
Definition: language.h:163
Definition: tidy.c:200
Definition: language.h:153
Definition: language.h:158
Definition: language.h:160
Definition: tidy.c:199
Definition: tidy.c:197
Definition: language.h:120
Definition: language.h:137
Definition: language.h:168
Definition: language.h:135
Definition: language.h:159
Definition: language.h:145
Definition: tidy.c:201
Definition: language.h:149
Definition: language.h:121
Definition: language.h:141
Definition: language.h:124
Definition: language.h:152
Definition: language.h:167
Definition: language.h:151
Definition: language.h:155
Definition: language.h:129
Definition: language.h:164
Definition: language.h:148
Definition: language.h:142
Definition: tidy.c:202
Definition: language.h:139
Definition: language.h:165
Definition: language.h:138
Definition: language.h:150
Definition: language.h:154
Definition: language.h:128
Definition: language.h:147
Definition: language.h:133
Definition: language.h:161
Definition: language.h:130
Definition: language.h:166
Definition: language.h:157

◆ errout

FILE* errout = NULL
static

◆ fmt

const char fmt[] = "%-27.27s %-9.9s %-40.40s\n"
static

◆ helpfmt

const char helpfmt[] = " %-25.25s %-52.52s\n"
static

Format strings and decorations used in output.

◆ helpul

const char helpul[] = "-----------------------------------------------------------------"
static

◆ ul

const char ul[] = "================================================================="
static

◆ valfmt

const char valfmt[] = "%-27.27s %-9.9s %-1.1s%-39.39s\n"
static