## @file
# This file is used to define class Configuration
#
# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import os
## Configuration
#
# This class is used to define all items in configuration file
#
# @param Filename: The name of configuration file, the default is config.ini
#
## Identify to if check all items
# 1 - Check all items and ignore all other detailed items
# 0 - Not check all items, the tool will go through all other detailed items to decide to check or not
#
## Identify to if automatically correct mistakes
# 1 - Automatically correct
# 0 - Not automatically correct
# Only the following check points can be automatically corrected, others not listed below are not supported even it is 1
#
# GeneralCheckTab
# GeneralCheckIndentation
# GeneralCheckLine
# GeneralCheckCarriageReturn
# SpaceCheckAll
#
# List customized Modifer here, split with ','
# Defaultly use the definition in class DataType
## General Checking
# Check whether NO Tab is used, replaced with spaces
# The width of Tab
# Check whether the indentation is followed coding style
# The width of indentation
# Check whether no line is exceeding defined widty
# The width of a line
# Check whether no use of _asm in the source file
# Check whether no use of "#progma" in source file except "#pragma pack(#)".
# Check whether there is a carriage return at the end of the file
# Check whether the file exists
# Check whether file has non ACSII char
## Space Checking
## Predicate Expression Checking
# Check whether Boolean values, variable type BOOLEAN not use explicit comparisons to TRUE or FALSE
# Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).
# Check whether a comparison of any pointer to zero must be done via the NULL type
## Headers Checking
# Check whether File header exists
# Check whether Function header exists
# Check whether Meta data File header Comment End with '##'
# Check whether C File header Comment content start with two spaces
# Check whether C File header Comment's each reference at list should begin with a bullet character '-'
# Check whether C File header Comment have the License immediately after the ""Copyright"" line
## C Function Layout Checking
# Check whether return type exists and in the first line
# Check whether any optional functional modifiers exist and next to the return type
# Check whether the next line contains the function name, left justified, followed by the beginning of the parameter list
# Check whether the closing parenthesis is on its own line and also indented two spaces
# Check whether the function prototypes in include files have the same form as function definitions
# Check whether the body of a function is contained by open and close braces that must be in the first column
# Check whether the data declarations is the first code in a module.
# Check whether no initialization of a variable as part of its declaration
# Check whether no use of STATIC for functions
## Include Files Checking
#Check whether having include files with same name
# Check whether all include file contents is guarded by a #ifndef statement.
# the #ifndef must be the first line of code following the file header comment
# the #endif must appear on the last line in the file
# Check whether include files contain only public or only private data
# Check whether include files NOT contain code or define data variables
## Declarations and Data Types Checking
# Check whether no use of int, unsigned, char, void, static, long in any .c, .h or .asl files.
# Check whether the modifiers IN, OUT, OPTIONAL, and UNALIGNED are used only to qualify arguments to a function and should not appear in a data type declaration
# Check whether the EFIAPI modifier should be used at the entry of drivers, events, and member functions of protocols
# Check whether Enumerated Type has a 'typedef' and the name is capital
# Check whether Structure Type has a 'typedef' and the name is capital
# Check whether having same Structure
# Check whether Union Type has a 'typedef' and the name is capital
## Naming Conventions Checking
# Check whether only capital letters are used for #define declarations
# Check whether only capital letters are used for typedef declarations
# Check whether the #ifndef at the start of an include file uses both prefix and postfix underscore characters, '_'.
# Rule for path name, variable name and function name
# 1. First character should be upper case
# 2. Existing lower case in a word
# 3. No space existence
# Check whether the path name followed the rule
# Check whether the variable name followed the rule
# Check whether the function name followed the rule
# Check whether NO use short variable name with single character
## Doxygen Checking
# Check whether the file headers are followed Doxygen special documentation blocks in section 2.3.5
# Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5
# Check whether the first line of text in a comment block is a brief description of the element being documented.
# The brief description must end with a period.
# Check whether comment lines with '///< ... text ...' format, if it is used, it should be after the code section.
# Check whether only Doxygen commands allowed to mark the code are @bug and @todo.
## Meta-Data File Processing Checking
# Check whether each file defined in meta-data exists
# Generate a list for all files defined in meta-data files
# The path of log file
# Check whether all Library Instances defined for a given module (or dependent library instance) match the module's type.
# Each Library Instance must specify the Supported Module Types in its INF file,
# and any module specifying the library instance must be one of the supported types.
# Check whether a Library Instance has been defined for all dependent library classes
# Check whether the Library Instances specified by the LibraryClasses sections are listed in order of dependencies
# Check whether the unnecessary inclusion of library classes in the INF file
# Check whether an INF file is specified in the FDF file, but not in the DSC file, then the INF file must be for a Binary module only
# Not to report error and warning related OS include file such as "windows.h" and "stdio.h"
# Check whether a PCD is set in a DSC file or the FDF file, but not in both.
# Check whether PCD settings in the FDF file can only be related to flash.
# Check whether PCDs used in INF files but not specified in DSC or FDF files
# Check whether all files under module directory are described in INF files
# Check whether the PCD is correctly used in C function via its type
# Check whether there are FILE_GUID duplication among different INF files
#
# The check points in this section are reserved
#
# GotoStatementCheckAll = 0
#
# The directory listed here will not be parsed, split with ','
self.SkipDirList = []
# A list for binary file ext name
self.BinaryExtList = []
LineNo = 0
if Line != '':
continue