def __get_terminal(self, name):
        # pylint: disable=line-too-long, too-many-return-statements, too-many-branches, too-many-statements

        if name == "constant_crc_init":
            if self.__get_init_value() == None:
                return  self.__pretty_bool(False)
            else:
                return   self.__pretty_bool(True)

        if name == "constant_crc_table":
            if self.opt.width != None and self.opt.poly != None and self.opt.reflect_in != None:
                return  self.__pretty_bool(True)
            else:
                return   self.__pretty_bool(False)

        elif name == "simple_crc_update_def":
            if self.opt.algorithm in set([self.opt.algo_bit_by_bit, self.opt.algo_bit_by_bit_fast]):
                if self.opt.width != None and self.opt.poly != None and self.opt.reflect_in != None:
                    return  self.__pretty_bool(True)
            elif self.opt.algorithm == self.opt.algo_table_driven:
                if self.opt.width != None and self.opt.reflect_in != None:
                    return  self.__pretty_bool(True)
            return  self.__pretty_bool(False)

        elif name == "inline_crc_finalize":
            if self.opt.algorithm in set([self.opt.algo_bit_by_bit_fast, self.opt.algo_table_driven]) and \
                    (self.opt.width != None and self.opt.reflect_in != None and self.opt.reflect_out != None and self.opt.xor_out != None):
                return  self.__pretty_bool(True)
            else:
                return  self.__pretty_bool(False)

        elif name == "simple_crc_finalize_def":
            if self.opt.algorithm == self.opt.algo_bit_by_bit:
                if self.opt.width != None and self.opt.poly != None and self.opt.reflect_out != None and self.opt.xor_out != None:
                    return  self.__pretty_bool(True)
            elif self.opt.algorithm == self.opt.algo_bit_by_bit_fast:
                if self.opt.width != None and self.opt.reflect_out != None and self.opt.xor_out != None:
                    return  self.__pretty_bool(True)
            elif self.opt.algorithm == self.opt.algo_table_driven:
                if self.opt.width != None and self.opt.reflect_in != None and self.opt.reflect_out != None and self.opt.xor_out != None:
                    return  self.__pretty_bool(True)
            return  self.__pretty_bool(False)

        elif name == "use_reflect_func":
            if self.opt.reflect_out == None or self.opt.reflect_in == None:
                return  self.__pretty_bool(True)
            elif self.opt.algorithm == self.opt.algo_table_driven:
                if self.opt.reflect_in != self.opt.reflect_out:
                    return  self.__pretty_bool(True)
            elif self.opt.algorithm == self.opt.algo_bit_by_bit:
                if self.opt.reflect_in:
                    return  self.__pretty_bool(True)
                if self.opt.reflect_out:
                    return  self.__pretty_bool(True)
            elif self.opt.algorithm == self.opt.algo_bit_by_bit_fast:
                if self.opt.reflect_in:
                    return  self.__pretty_bool(True)
                if self.opt.reflect_out:
                    return  self.__pretty_bool(True)
            return  self.__pretty_bool(False)

        elif name == "static_reflect_func":
            if self.opt.algorithm == self.opt.algo_table_driven:
                return  self.__pretty_bool(False)
            elif self.opt.reflect_out != None and self.opt.algorithm == self.opt.algo_bit_by_bit_fast:
                return  self.__pretty_bool(False)
            else:
                return  self.__pretty_bool(True)

        elif name == "crc_algorithm":
            if self.opt.algorithm == self.opt.algo_bit_by_bit:
                return  "bit-by-bit"
            elif self.opt.algorithm == self.opt.algo_bit_by_bit_fast:
                return  "bit-by-bit-fast"
            elif self.opt.algorithm == self.opt.algo_table_driven:
                return  "table-driven"
            else:
                return  "UNDEFINED"

        elif name == "crc_table_init":
            return  self.__get_table_init()
        elif name == "crc_table_core_algorithm_nonreflected":
            return  self.__get_tbl_core_nonreflected()
        elif name == "crc_table_core_algorithm_reflected":
            return  self.__get_tbl_core_reflected()

        elif name == "header_protection":
            return  self.__pretty_hdrprotection()

        elif name == "crc_init_value":
            ret = self.__get_init_value()
            if ret == None:
                return  ""
            else:
                return  ret

        elif name == "crc_final_value":
            return  """\
$if ($crc_algorithm == "table-driven") {:
$if ($crc_reflect_in == $crc_reflect_out) {:
crc ^ $crc_xor_out\
:} $else {:
$crc_reflect_function(crc, $crc_width) ^ $crc_xor_out\
:}:} $elif ($crc_reflect_out == True) {:
$crc_reflect_function(crc, $crc_width) ^ $crc_xor_out\
:} $else {:
crc ^ $crc_xor_out\
:}"""
        elif name == "h_template":
            return  """\
$source_header
#ifndef $header_protection
#define $header_protection

$if ($include_files != Undefined) {:
$include_files
:}
#include <stdlib.h>
$if ($c_std != C89) {:
#include <stdint.h>
:}
$if ($undefined_parameters == True and $c_std != C89) {:
#include <stdbool.h>
:}

#ifdef __cplusplus
extern "C" {
#endif


/**
 * The definition of the used algorithm.
 *
 * This is not used anywhere in the generated code, but it may be used by the
 * application code to call algoritm-specific code, is desired.
 *****************************************************************************/
$if ($crc_algorithm == "bit-by-bit") {:
#define CRC_ALGO_BIT_BY_BIT 1
:} $elif ($crc_algorithm == "bit-by-bit-fast") {:
#define CRC_ALGO_BIT_BY_BIT_FAST 1
:} $elif ($crc_algorithm == "table-driven") {:
#define CRC_ALGO_TABLE_DRIVEN 1
:} $else {:
#define CRC_ALGO_UNKNOWN 1
:}


/**
 * The type of the CRC values.
 *
 * This type must be big enough to contain at least $cfg_width bits.
 *****************************************************************************/
typedef $underlying_crc_t $crc_t;


$if ($undefined_parameters == True) {:
/**
 * The configuration type of the CRC algorithm.
 *****************************************************************************/
typedef struct {
$if ($crc_width == Undefined) {:
    unsigned int width;     /*!< The width of the polynomial */
:}
$if ($crc_poly == Undefined) {:
    $crc_t poly;             /*!< The CRC polynomial */
:}
$if ($crc_reflect_in == Undefined) {:
    $c_bool reflect_in;         /*!< Whether the input shall be reflected or not */
:}
$if ($crc_xor_in == Undefined) {:
    $crc_t xor_in;           /*!< The initial value of the algorithm */
:}
$if ($crc_reflect_out == Undefined) {:
    $c_bool reflect_out;        /*!< Wether the output shall be reflected or not */
:}
$if ($crc_xor_out == Undefined) {:
    $crc_t xor_out;          /*!< The value which shall be XOR-ed to the final CRC value */
:}
$if ($crc_width == Undefined) {:

    /* internal parameters */
    $crc_t msb_mask;             /*!< a bitmask with the Most Significant Bit set to 1
                                     initialise as (crc_t)1u << (width - 1) */
    $crc_t crc_mask;             /*!< a bitmask with all width bits set to 1
                                     initialise as (cfg->msb_mask - 1) | cfg->msb_mask */
    unsigned int crc_shift;     /*!< a shift count that is used when width < 8
                                     initialise as cfg->width < 8 ? 8 - cfg->width : 0 */
:}
} $cfg_t;


:}
$if ($use_reflect_func == True and $static_reflect_func != True) {:
$crc_reflect_doc
$crc_reflect_function_def;


:}
$if ($crc_algorithm == "table-driven" and $constant_crc_table != True) {:
$crc_table_gen_doc
$crc_table_gen_function_def;


:}
$crc_init_doc
$if ($constant_crc_init == False) {:
$crc_init_function_def;
:} $elif ($c_std == C89) {:
#define $crc_init_function()      ($crc_init_value)
:} $else {:
static inline $crc_init_function_def$nop
{
    return $crc_init_value;
}
:}


$crc_update_doc
$crc_update_function_def;


$crc_finalize_doc
$if ($inline_crc_finalize == True) {:
$if ($c_std == C89) {:
#define $crc_finalize_function(crc)      ($crc_final_value)
:} $else {:
static inline $crc_finalize_function_def$nop
{
    return $crc_final_value;
}
:}
:} $else {:
$crc_finalize_function_def;
:}


#ifdef __cplusplus
}           /* closing brace for extern "C" */
#endif

#endif      /* $header_protection */
"""

        elif name == "source_header":
            return  """\
/**
 * \\file $filename
 * Functions and types for CRC checks.
 *
 * Generated on $datetime,
 * by $program_version, $program_url
 * using the configuration:
 *    Width         = $crc_width
 *    Poly          = $crc_poly
 *    Xor_In        = $crc_xor_in
 *    ReflectIn     = $crc_reflect_in
 *    Xor_Out       = $crc_xor_out
 *    ReflectOut    = $crc_reflect_out
 *    Algorithm     = $crc_algorithm
$if ($crc_slice_by > 1) {:
 *    SliceBy       = $crc_slice_by
:}
 *****************************************************************************/\
"""

        elif name == "crc_reflect_doc":
            return  """\
/**
 * Reflect all bits of a \\a data word of \\a data_len bytes.
 *
 * \\param data         The data word to be reflected.
 * \\param data_len     The width of \\a data expressed in number of bits.
 * \\return             The reflected data.
 *****************************************************************************/\
"""

        elif name == "crc_reflect_function_def":
            return  """\
$crc_t $crc_reflect_function($crc_t data, size_t data_len)\
"""

        elif name == "crc_reflect_function_gen":
            return  """\
$if ($use_reflect_func == True) {:
$if ($crc_reflect_in == Undefined or $crc_reflect_in == True or $crc_reflect_out == Undefined or $crc_reflect_out == True) {:
$crc_reflect_doc
$crc_reflect_function_def$nop
{
    unsigned int i;
    $crc_t ret;

    ret = data & 0x01;
    for (i = 1; i < data_len; i++) {
        data >>= 1;
        ret = (ret << 1) | (data & 0x01);
    }
    return ret;
}


:}
:}"""

        elif name == "crc_init_function_gen":
            return  """\
$if ($constant_crc_init == False) {:
$crc_init_doc
$crc_init_function_def$nop
{
$if ($crc_algorithm == "bit-by-bit") {:
    unsigned int i;
    $c_bool bit;
    $crc_t crc = $cfg_xor_in;
    for (i = 0; i < $cfg_width; i++) {
        bit = crc & 0x01;
        if (bit) {
            crc = ((crc ^ $cfg_poly) >> 1) | $cfg_msb_mask;
        } else {
            crc >>= 1;
        }
    }
    return crc & $cfg_mask;
:} $elif ($crc_algorithm == "bit-by-bit-fast") {:
    return $cfg_xor_in & $cfg_mask;
:} $elif ($crc_algorithm == "table-driven") {:
$if ($crc_reflect_in == Undefined) {:
    if ($cfg_reflect_in) {
        return $crc_reflect_function($cfg_xor_in & $cfg_mask, $cfg_width);
    } else {
        return $cfg_xor_in & $cfg_mask;
    }
:} $elif ($crc_reflect_in == True) {:
    return $crc_reflect_function($cfg_xor_in & $cfg_mask, $cfg_width);
:} $else {:
    return $cfg_xor_in & $cfg_mask;
:}
:}
}


:}"""

        elif name == "crc_update_function_gen":
            return  """\
$crc_table_driven_func_gen
$crc_update_doc
$crc_update_function_def$nop
{
    const unsigned char *d = (const unsigned char *)data;
$if ($crc_algorithm == "bit-by-bit") {:
    unsigned int i;
    $c_bool bit;
    unsigned char c;

    while (data_len--) {
$if ($crc_reflect_in == Undefined) {:
        if ($cfg_reflect_in) {
            c = $crc_reflect_function(*d++, 8);
        } else {
            c = *d++;
        }
:} $elif ($crc_reflect_in == True) {:
        c = $crc_reflect_function(*d++, 8);
:} $else {:
        c = *d++;
:}
        for (i = 0; i < 8; i++) {
            bit = $if ($c_std == C89) {:!!(crc & $cfg_msb_mask):} $else {:crc & $cfg_msb_mask:};
            crc = (crc << 1) | ((c >> (7 - i)) & 0x01);
            if (bit) {
                crc ^= $cfg_poly;
            }
        }
        crc &= $cfg_mask;
    }
    return crc & $cfg_mask;
:} $elif ($crc_algorithm == "bit-by-bit-fast") {:
    unsigned int i;
    $c_bool bit;
    unsigned char c;

    while (data_len--) {
$if ($crc_reflect_in == Undefined) {:
        if ($cfg_reflect_in) {
            c = $crc_reflect_function(*d++, 8);
        } else {
            c = *d++;
        }
:} $else {:
        c = *d++;
:}
$if ($crc_reflect_in == True) {:
        for (i = 0x01; i & 0xff; i <<= 1){::}
:} $else {:
        for (i = 0x80; i > 0; i >>= 1){::}
:} {
            bit = $if ($c_std == C89) {:!!(crc & $cfg_msb_mask):} $else {:crc & $cfg_msb_mask:};
            if (c & i) {
                bit = !bit;
            }
            crc <<= 1;
            if (bit) {
                crc ^= $cfg_poly;
            }
        }
        crc &= $cfg_mask;
    }
    return crc & $cfg_mask;
:} $elif ($crc_algorithm == "table-driven") {:
    unsigned int tbl_idx;

$if ($crc_reflect_in == Undefined) {:
    if (cfg->reflect_in) {
        while (data_len--) {
$crc_table_core_algorithm_reflected
            d++;
        }
    } else {
        while (data_len--) {
$crc_table_core_algorithm_nonreflected
            d++;
        }
    }
:} $else {:
$if ($crc_slice_by > 1) {:
    const uint32_t *d32 = (const uint32_t *)d;
    while (data_len >= $crc_slice_by)
    {
#if __BYTE_ORDER == __BIG_ENDIAN
        $crc_t d1 = *d32++ ^ le16toh(crc);
$if ($crc_slice_by >= 8) {:
        $crc_t d2 = *d32++;
$if ($crc_slice_by >= 16) {:
        $crc_t d3 = *d32++;
        $crc_t d4 = *d32++;
:}:}
        crc  =
$if ($crc_slice_by == 4) {:
            crc_table[ 0][ d1        & 0xffu] ^
            crc_table[ 1][(d1 >>  8) & 0xffu] ^
            crc_table[ 2][(d1 >> 16) & 0xffu] ^
            crc_table[ 3][(d1 >> 24) & 0xffu];
:} $elif ($crc_slice_by == 8) {:
            crc_table[ 0][ d2        & 0xffu] ^
            crc_table[ 1][(d2 >>  8) & 0xffu] ^
            crc_table[ 2][(d2 >> 16) & 0xffu] ^
            crc_table[ 3][(d2 >> 24) & 0xffu] ^
            crc_table[ 4][ d1        & 0xffu] ^
            crc_table[ 5][(d1 >>  8) & 0xffu] ^
            crc_table[ 6][(d1 >> 16) & 0xffu] ^
            crc_table[ 7][(d1 >> 24) & 0xffu];
:} $elif ($crc_slice_by == 16) {:
            crc_table[ 0][ d4        & 0xffu] ^
            crc_table[ 1][(d4 >>  8) & 0xffu] ^
            crc_table[ 2][(d4 >> 16) & 0xffu] ^
            crc_table[ 3][(d4 >> 24) & 0xffu] ^
            crc_table[ 4][ d3        & 0xffu] ^
            crc_table[ 5][(d3 >>  8) & 0xffu] ^
            crc_table[ 6][(d3 >> 16) & 0xffu] ^
            crc_table[ 7][(d3 >> 24) & 0xffu] ^
            crc_table[ 8][ d2        & 0xffu] ^
            crc_table[ 9][(d2 >>  8) & 0xffu] ^
            crc_table[10][(d2 >> 16) & 0xffu] ^
            crc_table[11][(d2 >> 24) & 0xffu] ^
            crc_table[12][ d1        & 0xffu] ^
            crc_table[13][(d1 >>  8) & 0xffu] ^
            crc_table[14][(d1 >> 16) & 0xffu] ^
            crc_table[15][(d1 >> 24) & 0xffu];
:}
#else
        $crc_t d1 = *d32++ ^ crc;
$if ($crc_slice_by >= 8) {:
        $crc_t d2 = *d32++;
$if ($crc_slice_by >= 16) {:
        $crc_t d3 = *d32++;
        $crc_t d4 = *d32++;
:}:}
        crc  =
$if ($crc_slice_by == 4) {:
            crc_table[ 0][(d1 >> 24) & 0xffu] ^
            crc_table[ 1][(d1 >> 16) & 0xffu] ^
            crc_table[ 2][(d1 >>  8) & 0xffu] ^
            crc_table[ 3][ d1        & 0xffu];
:} $elif ($crc_slice_by == 8) {:
            crc_table[ 0][(d2 >> 24) & 0xffu] ^
            crc_table[ 1][(d2 >> 16) & 0xffu] ^
            crc_table[ 2][(d2 >>  8) & 0xffu] ^
            crc_table[ 3][ d2        & 0xffu] ^
            crc_table[ 4][(d1 >> 24) & 0xffu] ^
            crc_table[ 5][(d1 >> 16) & 0xffu] ^
            crc_table[ 6][(d1 >>  8) & 0xffu] ^
            crc_table[ 7][ d1        & 0xffu];
:} $elif ($crc_slice_by == 16) {:
            crc_table[ 0][(d4 >> 24) & 0xffu] ^
            crc_table[ 1][(d4 >> 16) & 0xffu] ^
            crc_table[ 2][(d4 >>  8) & 0xffu] ^
            crc_table[ 3][ d4        & 0xffu] ^
            crc_table[ 4][(d3 >> 24) & 0xffu] ^
            crc_table[ 5][(d3 >> 16) & 0xffu] ^
            crc_table[ 6][(d3 >>  8) & 0xffu] ^
            crc_table[ 7][ d3        & 0xffu] ^
            crc_table[ 8][(d2 >> 24) & 0xffu] ^
            crc_table[ 9][(d2 >> 16) & 0xffu] ^
            crc_table[10][(d2 >>  8) & 0xffu] ^
            crc_table[11][ d2        & 0xffu] ^
            crc_table[12][(d1 >> 24) & 0xffu] ^
            crc_table[13][(d1 >> 16) & 0xffu] ^
            crc_table[14][(d1 >>  8) & 0xffu] ^
            crc_table[15][ d1        & 0xffu];
:}
#endif

        data_len -= $crc_slice_by;
    }

    /* Remaining bytes with the standard algorithm */
    d = (const unsigned char *)d32;
:}
    while (data_len--) {
$if ($crc_reflect_in == True) {:
$crc_table_core_algorithm_reflected
:} $elif ($crc_reflect_in == False) {:
$crc_table_core_algorithm_nonreflected
:}
        d++;
    }
:}
    return crc & $cfg_mask;
:}
}


"""

        elif name == "crc_finalize_function_gen":
            return  """\
$if ($inline_crc_finalize != True) {:
$crc_finalize_doc
$crc_finalize_function_def$nop
{
$if ($crc_algorithm == "bit-by-bit") {:
    unsigned int i;
    $c_bool bit;

    for (i = 0; i < $cfg_width; i++) {
        bit = $if ($c_std == C89) {:!!(crc & $cfg_msb_mask):} $else {:crc & $cfg_msb_mask:};
        crc = (crc << 1) | 0x00;
        if (bit) {
            crc ^= $cfg_poly;
        }
    }
$if ($crc_reflect_out == Undefined) {:
    if ($cfg_reflect_out) {
        crc = $crc_reflect_function(crc, $cfg_width);
    }
:} $elif ($crc_reflect_out == True) {:
    crc = $crc_reflect_function(crc, $cfg_width);
:}
    return (crc ^ $cfg_xor_out) & $cfg_mask;
:} $elif ($crc_algorithm == "bit-by-bit-fast") {:
$if ($crc_reflect_out == Undefined) {:
    if (cfg->reflect_out) {
        crc = $crc_reflect_function(crc, $cfg_width);
    }
:} $elif ($crc_reflect_out == True) {:
    crc = $crc_reflect_function(crc, $cfg_width);
:}
    return (crc ^ $cfg_xor_out) & $cfg_mask;
:} $elif ($crc_algorithm == "table-driven") {:
$if ($crc_reflect_in == Undefined or $crc_reflect_out == Undefined) {:
$if ($crc_reflect_in == Undefined and $crc_reflect_out == Undefined) {:
    if (cfg->reflect_in == !cfg->reflect_out):}
$elif ($crc_reflect_out == Undefined) {:
    if ($if ($crc_reflect_in == True) {:!:}cfg->reflect_out):}
$elif ($crc_reflect_in == Undefined) {:
    if ($if ($crc_reflect_out == True) {:!:}cfg->reflect_in):} {
        crc = $crc_reflect_function(crc, $cfg_width);
    }
:} $elif ($crc_reflect_in != $crc_reflect_out) {:
    crc = $crc_reflect_function(crc, $cfg_width);
:}
    return (crc ^ $cfg_xor_out) & $cfg_mask;
:}
}


:}"""

        elif name == "crc_table_driven_func_gen":
            return  """\
$if ($crc_algorithm == "table-driven" and $constant_crc_table != True) {:
$crc_table_gen_doc
$crc_table_gen_function_def
{
    $crc_t crc;
    unsigned int i, j;

    for (i = 0; i < $cfg_table_width; i++) {
$if ($crc_reflect_in == Undefined) {:
        if (cfg->reflect_in) {
            crc = $crc_reflect_function(i, $cfg_table_idx_width);
        } else {
            crc = i;
        }
:} $elif ($crc_reflect_in == True) {:
        crc = $crc_reflect_function(i, $cfg_table_idx_width);
:} $else {:
        crc = i;
:}
$if ($crc_shift != 0) {:
        crc <<= ($cfg_width - $cfg_table_idx_width + $cfg_shift);
:} $else {:
        crc <<= ($cfg_width - $cfg_table_idx_width);
:}
        for (j = 0; j < $cfg_table_idx_width; j++) {
            if (crc & $cfg_msb_mask_shifted) {
                crc = (crc << 1) ^ $cfg_poly_shifted;
            } else {
                crc = crc << 1;
            }
        }
$if ($crc_reflect_in == Undefined) {:
        if (cfg->reflect_in) {
$if ($crc_shift != 0) {:
            crc = $crc_reflect_function(crc >> $cfg_shift, $cfg_width) << $cfg_shift;
:} $else {:
            crc = $crc_reflect_function(crc, $cfg_width);
:}
        }
:} $elif ($crc_reflect_in == True) {:
$if ($crc_shift != 0) {:
        crc = $crc_reflect_function(crc >> $cfg_shift, $cfg_width) << $cfg_shift;
:} $else {:
        crc = $crc_reflect_function(crc, $cfg_width);
:}
:}
        crc_table[i] = (crc & $cfg_mask_shifted) >> $cfg_shift;
    }
}


:}"""

        elif name == "crc_table_gen_doc":
            return  """\
/**
 * Populate the private static crc table.
 *
 * \\param cfg  A pointer to a initialised $cfg_t structure.
 * \\return     void
 *****************************************************************************/\
"""

        elif name == "crc_table_gen_function_def":
            return  """\
void $crc_table_gen_function(const $cfg_t *cfg)\
"""

        elif name == "crc_init_doc":
            return  """\
/**
 * Calculate the initial crc value.
 *
$if ($use_cfg_t == True) {:
 * \\param cfg  A pointer to a initialised $cfg_t structure.
:}
 * \\return     The initial crc value.
 *****************************************************************************/\
"""

        elif name == "crc_init_function_def":
            return  """\
$if ($constant_crc_init == False) {:
$crc_t $crc_init_function(const $cfg_t *cfg)\
:} $else {:
$crc_t $crc_init_function(void)\
:}\
"""

        elif name == "crc_update_doc":
            return  """\
/**
 * Update the crc value with new data.
 *
 * \\param crc      The current crc value.
$if ($simple_crc_update_def != True) {:
 * \\param cfg      A pointer to a initialised $cfg_t structure.
:}
 * \\param data     Pointer to a buffer of \\a data_len bytes.
 * \\param data_len Number of bytes in the \\a data buffer.
 * \\return         The updated crc value.
 *****************************************************************************/\
"""

        elif name == "crc_update_function_def":
            return  """\
$if ($simple_crc_update_def != True) {:
$crc_t $crc_update_function(const $cfg_t *cfg, $crc_t crc, const void *data, size_t data_len)\
:} $else {:
$crc_t $crc_update_function($crc_t crc, const void *data, size_t data_len)\
:}\
"""

        elif name == "crc_finalize_doc":
            return  """\
/**
 * Calculate the final crc value.
 *
$if ($simple_crc_finalize_def != True) {:
 * \\param cfg  A pointer to a initialised $cfg_t structure.
:}
 * \\param crc  The current crc value.
 * \\return     The final crc value.
 *****************************************************************************/\
"""

        elif name == "crc_finalize_function_def":
            return  """\
$if ($simple_crc_finalize_def != True) {:
$crc_t $crc_finalize_function(const $cfg_t *cfg, $crc_t crc)\
:} $else {:
$crc_t $crc_finalize_function($crc_t crc)\
:}\
"""

        elif name == "c_template":
            return  """\
$source_header
$if ($include_files != Undefined) {:
$include_files
:}
#include "$header_filename"     /* include the header file generated with pycrc */
#include <stdlib.h>
$if ($c_std != C89) {:
#include <stdint.h>
$if ($undefined_parameters == True or $crc_algorithm == "bit-by-bit" or $crc_algorithm == "bit-by-bit-fast") {:
#include <stdbool.h>
:}
:}
$if ($crc_slice_by > 1) {:
#include <endian.h>
:}

$if ($use_reflect_func == True and $static_reflect_func == True) {:
static $crc_reflect_function_def;

:}
$c_table_gen\
$crc_reflect_function_gen\
$crc_init_function_gen\
$crc_update_function_gen\
$crc_finalize_function_gen\
"""

        elif name == "c_table_gen":
            return  """\
$if ($crc_algorithm == "table-driven") {:
/**
 * Static table used for the table_driven implementation.
$if ($undefined_parameters == True) {:
 * Must be initialised with the $crc_init_function function.
:}
 *****************************************************************************/
$if ($constant_crc_table != True) {:
static $crc_t crc_table[$crc_table_width];
:} $else {:
static const $crc_t crc_table$if ($crc_slice_by > 1) {:[$crc_slice_by]:}[$crc_table_width] = $crc_table_init;
:}

:}"""

        elif name == "main_template":
            return  """\
$if ($include_files != Undefined) {:
$include_files
:}
#include <stdio.h>
#include <getopt.h>
$if ($undefined_parameters == True) {:
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
:}
$if ($c_std != C89) {:
#include <stdbool.h>
:}
#include <string.h>

static char str[256] = "123456789";
static $c_bool verbose = $c_false;

void print_params($if ($undefined_parameters == True) {:const $cfg_t *cfg:} $else {:void:});
$getopt_template

void print_params($if ($undefined_parameters == True) {:const $cfg_t *cfg:} $else {:void:})
{
    char format[20];

$if ($c_std == C89) {:
    sprintf(format, "%%-16s = 0x%%0%dlx\\n", (unsigned int)($cfg_width + 3) / 4);
    printf("%-16s = %d\\n", "width", (unsigned int)$cfg_width);
    printf(format, "poly", (unsigned long int)$cfg_poly);
    printf("%-16s = %s\\n", "reflect_in", $if ($crc_reflect_in == Undefined) {:$cfg_reflect_in ? "true": "false":} $else {:$if ($crc_reflect_in == True) {:"true":} $else {:"false":}:});
    printf(format, "xor_in", (unsigned long int)$cfg_xor_in);
    printf("%-16s = %s\\n", "reflect_out", $if ($crc_reflect_out == Undefined) {:$cfg_reflect_out ? "true": "false":} $else {:$if ($crc_reflect_out == True) {:"true":} $else {:"false":}:});
    printf(format, "xor_out", (unsigned long int)$cfg_xor_out);
    printf(format, "crc_mask", (unsigned long int)$cfg_mask);
    printf(format, "msb_mask", (unsigned long int)$cfg_msb_mask);
:} $else {:
    snprintf(format, sizeof(format), "%%-16s = 0x%%0%dllx\\n", (unsigned int)($cfg_width + 3) / 4);
    printf("%-16s = %d\\n", "width", (unsigned int)$cfg_width);
    printf(format, "poly", (unsigned long long int)$cfg_poly);
    printf("%-16s = %s\\n", "reflect_in", $if ($crc_reflect_in == Undefined) {:$cfg_reflect_in ? "true": "false":} $else {:$if ($crc_reflect_in == True) {:"true":} $else {:"false":}:});
    printf(format, "xor_in", (unsigned long long int)$cfg_xor_in);
    printf("%-16s = %s\\n", "reflect_out", $if ($crc_reflect_out == Undefined) {:$cfg_reflect_out ? "true": "false":} $else {:$if ($crc_reflect_out == True) {:"true":} $else {:"false":}:});
    printf(format, "xor_out", (unsigned long long int)$cfg_xor_out);
    printf(format, "crc_mask", (unsigned long long int)$cfg_mask);
    printf(format, "msb_mask", (unsigned long long int)$cfg_msb_mask);
:}
}

/**
 * C main function.
 *
 * \\return     0 on success, != 0 on error.
 *****************************************************************************/
int main(int argc, char *argv[])
{
$if ($undefined_parameters == True) {:
    $cfg_t cfg = {
$if ($crc_width == Undefined) {:
            0,      /* width */
:}
$if ($crc_poly == Undefined) {:
            0,      /* poly */
:}
$if ($crc_xor_in == Undefined) {:
            0,      /* xor_in */
:}
$if ($crc_reflect_in == Undefined) {:
            0,      /* reflect_in */
:}
$if ($crc_xor_out == Undefined) {:
            0,      /* xor_out */
:}
$if ($crc_reflect_out == Undefined) {:
            0,      /* reflect_out */
:}
$if ($crc_width == Undefined) {:

            0,      /* crc_mask */
            0,      /* msb_mask */
            0,      /* crc_shift */
:}
    };
:}
    $crc_t crc;

$if ($undefined_parameters == True) {:
    get_config(argc, argv, &cfg);
:} $else {:
    get_config(argc, argv);
:}
$if ($crc_algorithm == "table-driven" and $constant_crc_table != True) {:
    $crc_table_gen_function(&cfg);
:}
    crc = $crc_init_function($if ($constant_crc_init != True) {:&cfg:});
    crc = $crc_update_function($if ($simple_crc_update_def != True) {:&cfg, :}crc, (void *)str, strlen(str));
    crc = $crc_finalize_function($if ($simple_crc_finalize_def != True) {:&cfg, :}crc);

    if (verbose) {
        print_params($if ($undefined_parameters == True) {:&cfg:});
    }
$if ($c_std == C89) {:
    printf("0x%lx\\n", (unsigned long int)crc);
:} $else {:
    printf("0x%llx\\n", (unsigned long long int)crc);
:}
    return 0;
}
"""

        elif name == "getopt_template":
            return  """\
$if ($crc_reflect_in == Undefined or $crc_reflect_out == Undefined) {:
static $c_bool atob(const char *str);
:}
$if ($crc_poly == Undefined or $crc_xor_in == Undefined or $crc_xor_out == Undefined) {:
static crc_t xtoi(const char *str);
:}
static int get_config(int argc, char *argv[]$if ($undefined_parameters == True) {:, $cfg_t *cfg:});


$if ($crc_reflect_in == Undefined or $crc_reflect_out == Undefined) {:
$c_bool atob(const char *str)
{
    if (!str) {
        return 0;
    }
    if (isdigit(str[0])) {
        return ($c_bool)atoi(str);
    }
    if (tolower(str[0]) == 't') {
        return $c_true;
    }
    return $c_false;
}

:}
$if ($crc_poly == Undefined or $crc_xor_in == Undefined or $crc_xor_out == Undefined) {:
crc_t xtoi(const char *str)
{
    crc_t ret = 0;

    if (!str) {
        return 0;
    }
    if (str[0] == '0' && tolower(str[1]) == 'x') {
        str += 2;
        while (*str) {
            if (isdigit(*str))
                ret = 16 * ret + *str - '0';
            else if (isxdigit(*str))
                ret = 16 * ret + tolower(*str) - 'a' + 10;
            else
                return ret;
            str++;
        }
    } else if (isdigit(*str)) {
        while (*str) {
            if (isdigit(*str))
                ret = 10 * ret + *str - '0';
            else
                return ret;
            str++;
        }
    }
    return ret;
}


:}
static int get_config(int argc, char *argv[]$if ($undefined_parameters == True) {:, $cfg_t *cfg:})
{
    int c;
    int option_index;
    static struct option long_options[] = {
$if ($crc_width == Undefined) {:
        {"width",           1, 0, 'w'},
:}
$if ($crc_poly == Undefined) {:
        {"poly",            1, 0, 'p'},
:}
$if ($crc_reflect_in == Undefined) {:
        {"reflect-in",      1, 0, 'n'},
:}
$if ($crc_xor_in == Undefined) {:
        {"xor-in",          1, 0, 'i'},
:}
$if ($crc_reflect_out == Undefined) {:
        {"reflect-out",     1, 0, 'u'},
:}
$if ($crc_xor_out == Undefined) {:
        {"xor-out",         1, 0, 'o'},
:}
        {"verbose",         0, 0, 'v'},
        {"check-string",    1, 0, 's'},
$if ($crc_width == Undefined) {:
        {"table-idx-with",  1, 0, 't'},
:}
        {0, 0, 0, 0}
    };

    while (1) {
        option_index = 0;

        c = getopt_long(argc, argv, "w:p:n:i:u:o:s:vt", long_options, &option_index);
        if (c == -1)
            break;

        switch (c) {
            case 0:
                printf("option %s", long_options[option_index].name);
                if (optarg)
                    printf(" with arg %s", optarg);
                printf("\\n");
$if ($crc_width == Undefined) {:
            case 'w':
                cfg->width = atoi(optarg);
                break;
:}
$if ($crc_poly == Undefined) {:
            case 'p':
                cfg->poly = xtoi(optarg);
                break;
:}
$if ($crc_reflect_in == Undefined) {:
            case 'n':
                cfg->reflect_in = atob(optarg);
                break;
:}
$if ($crc_xor_in == Undefined) {:
            case 'i':
                cfg->xor_in = xtoi(optarg);
                break;
:}
$if ($crc_reflect_out == Undefined) {:
            case 'u':
                cfg->reflect_out = atob(optarg);
                break;
:}
$if ($crc_xor_out == Undefined) {:
            case 'o':
                cfg->xor_out = xtoi(optarg);
                break;
:}
            case 's':
                memcpy(str, optarg, strlen(optarg) < sizeof(str) ? strlen(optarg) + 1 : sizeof(str));
                str[sizeof(str) - 1] = '\\0';
                break;
            case 'v':
                verbose = $c_true;
                break;
$if ($crc_width == Undefined) {:
            case 't':
                /* ignore --table_idx_width option */
                break;
:}
            case '?':
                return -1;
            case ':':
                fprintf(stderr, "missing argument to option %c\\n", c);
                return -1;
            default:
                fprintf(stderr, "unhandled option %c\\n", c);
                return -1;
        }
    }
$if ($crc_width == Undefined) {:
    cfg->msb_mask = (crc_t)1u << (cfg->width - 1);
    cfg->crc_mask = (cfg->msb_mask - 1) | cfg->msb_mask;
    cfg->crc_shift = cfg->width < 8 ? 8 - cfg->width : 0;
:}

$if ($crc_poly == Undefined) {:
    cfg->poly &= $cfg_mask;
:}
$if ($crc_xor_in == Undefined) {:
    cfg->xor_in &= $cfg_mask;
:}
$if ($crc_xor_out == Undefined) {:
    cfg->xor_out &= $cfg_mask;
:}
    return 0;
}\
"""


    # function __pretty_str
    ###############################################################################
open file called *filename* with mode *mode*.
dataset/ETHPy150Open tpircher/pycrc/crc_symtable.py/SymbolTable.__get_terminal--crossover with--dataset/ETHPy150Open CGATOxford/cgat/CGAT/IOTools.py/openFile