
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.35-trace/%M%
#   Revision:		%I%
#   First Edition:	1995/12/06
#   Last Mod.:		%U%, %G%
#
#   Authors:		Jens Hamisch, Jens.Hamisch@Strawberry.COM
#
#   Description:	Testuite testsequence
#   Command:
#   Modulefiles:
#   Sub-Command:
#
#   Comment:	%C{
#			Initialization for the tracing' part of the testsuite
#		}C%
#
##############################################################################

if { [info exists env(testsuite)] } {
    unset env(testsuite)
}

#
#  Check the configuration
#

if { [info exists config_file] } {

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_LOAD" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_load "+.\\*"
	} else {
	    set trace_load $value
	}
    } else {
	set trace_load "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_UNLOAD" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_unload "+.\\*"
	} else {
	    set trace_unload $value
	}
    } else {
	set trace_unload "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_SWITCH" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_switch "+.\\*"
	} else {
	    set trace_switch $value
	}
    } else {
	set trace_switch "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_DISP" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_disp "+.\\*"
	} else {
	    set trace_disp $value
	}
    } else {
	set trace_disp "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_LIST" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_list "+.\\*"
	} else {
	    if { ![ regexp {["](.*)["]} $value hit trace_list ] } {
		set trace_list $value
	    }
	}
    } else {
	set trace_list "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_AVAIL" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_avail "+.\\*"
	} else {
	    set trace_avail $value
	}
    } else {
	set trace_avail "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_HELP" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_help "+.\\*"
	} else {
	    set trace_help $value
	}
    } else {
	set trace_help "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_INIT" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_init "+.\\*"
	} else {
	    set trace_init $value
	}
    } else {
	set trace_init "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_USE" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_use "+.\\*"
	} else {
	    set trace_use $value
	}
    } else {
	set trace_use "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_UNUSE" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_unuse "+.\\*"
	} else {
	    set trace_unuse $value
	}
    } else {
	set trace_unuse "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_UPDATE" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_update "+.\\*"
	} else {
	    set trace_update $value
	}
    } else {
	set trace_update "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_PURGE" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_purge "+.\\*"
	} else {
	    set trace_purge $value
	}
    } else {
	set trace_purge "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_CLEAR" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_clear "+.\\*"
	} else {
	    set trace_clear $value
	}
    } else {
	set trace_clear "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_APROPOS" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_apropos "+.\\*"
	} else {
	    set trace_apropos $value
	}
    } else {
	set trace_apropos "-.\\*"
    }

    if { ![catch {
	set tmp [exec grep "#define WITH_TRACE_WHATIS" $config_file] } ] } {
	regexp {#define WITH_TRACE_[A-Z]+ (.*)$} $tmp hit value
	if { "$value" == "_all_on" } {
	    set trace_whatis "+.\\*"
	} else {
	    set trace_whatis $value
	}
    } else {
	set trace_whatis "-.\\*"
    }

#
#  Default versions (if no config file is available)
#

} else {
    set trace_load "-.\\*"
    set trace_unload "-.\\*"
    set trace_switch "-.\\*"
    set trace_disp "-.\\*"
    set trace_list "-.\\*"
    set trace_avail "-.\\*"
    set trace_help "-.\\*"
    set trace_init "-.\\*"
    set trace_use "-.\\*"
    set trace_unuse "-.\\*"
    set trace_update "-.\\*"
    set trace_purge "-.\\*"
    set trace_clear "-.\\*"
    set trace_whatis "-.\\*"
    set trace_apropos "-.\\*"
}

#
#  Verbosity
#

if { $verbose > 1 } {
    send_user "Default tracing configuration:\n"
    send_user "\tLOAD:\t$trace_load\n"
    send_user "\tUNLOAD:\t$trace_unload\n"
    send_user "\tSWITCH:\t$trace_switch\n"
    send_user "\tDISPL:\t$trace_disp\n"
    send_user "\tLIST:\t$trace_list\n"
    send_user "\tAVAIL:\t$trace_avail\n"
    send_user "\tHELP:\t$trace_help\n"
    send_user "\tINIT:\t$trace_init\n"
    send_user "\tUSE:\t$trace_use\n"
    send_user "\tUNUSE:\t$trace_unuse\n"
    send_user "\tUPDATE:\t$trace_update\n"
    send_user "\tPURGE:\t$trace_purge\n"
    send_user "\tCLEAR:\t$trace_clear\n"
    send_user "\tWHATIS:\t$trace_whatis\n"
    send_user "\tAPROPOS:\t$trace_apropos\n"
}

#
#  Cleanup
#

if { [info exists tmp] } { unset tmp }
if { [info exists hit] } { unset hit }
if { [info exists value] } { unset value }
