#!/usr/bin/env perl #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # /* Functions for on-the-fly commentary on a tool's work. */ # # Copyright (C) 2000-2001 Ximian, Inc. # # Authors: Hans Petter Jansson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Library General Public License as published # by the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. require "___scriptsdir___/general.pl"; require "___scriptsdir___/gettext.pl"; # --- Progress printing --- # $xst_progress_current = 0; # Compat with old $progress_max use. $xst_progress_last_percentage = 0; sub xst_progress { my $prc = $_[0]; # /* Don't go backwards. */ $prc = $xst_progress_last_percentage if ($prc < $xst_progress_last_percentage); # /* Don't go above 99%. */ $prc = 99 if ($prc >= 100); if ($xst_progress && (int $prc > int $xst_progress_last_percentage)) { &xst_report ("progress", $prc); $xst_progress_last_percentage = $prc; } } sub xst_progress_begin { &xst_progress (0); } sub xst_progress_end { &xst_progress (99); } sub xst_print_progress # Compat with old $progress_max use. { my $prc; $xst_progress_current++; &xst_progress (($xst_progress_current * 100) / $progress_max); } # --- Report printing --- # sub xst_report_set_threshold { $xst_report_threshold = $_[0]; } sub xst_report_enter { # This has been trivialized because it is not working # correctly at the moment and is causing some trouble. # /* We'll probably replace this with something smarter */ # (like a detail-level value in the report hash) # when the report strings are used at the gui-level again. # $xst_report_level ++; $xst_report_level = 0; } sub xst_report_leave { # $xst_report_level --; $xst_report_level = 0; } $xst_report_level = 0; $xst_report_started = 0; sub xst_report { my ($key, @args) = @_; my ($mayor, $minor, $str, $format, $res); &xst_debug_print_line ("Non-existing report key $key") if !exists $xst_report_message{$key}; ($mayor, $str) = @{$xst_report_message{$key}}; $xst_report_started = 1 if !$xst_report_started && $key eq "begin" && $mayor eq "sys"; if ($key ne "progress") { return if ($xst_report_level >= $xst_report_threshold || !$xst_report_started); } # Report (--report) output is machine-readable. if ($xst_do_report) { print STDOUT join ("::", $key, $str, @args) . "\n"; } # Verbose (--verbose) output is human-readable only. $format = "$str\n"; $res = sprintf ($format, @args); print STDERR $res if $xst_do_verbose; &xst_debug_print_indented_string ($xst_report_level, "report $key: $res"); } # This disables reporting. &xst_report_set_threshold (0); &textdomain ("ximian-setup-tools"); %xst_report_message = ( "begin" => ["sys", _("Start of work report.")], "end" => ["sys", _("End of work report.")], "progress" => ["sys", _("%d")], "compat" => ["info", _("%s.")], "platform_list" => ["sys", _("Supported: [%s]")], "platform_unsup" => ["error", _("Your platform [%s] is not supported.")], "platform_undet" => ["error", _("Unable to determine host platform.")], "platform_success" => ["sys", _("Configuring for platform [%s].")], "xml_unexp_tag" => ["error", _("Unexpected tag [%s].")], "xml_unexp_arg" => ["error", _("Unexpected argument [%s] to tag [%s].")], "file_open_read_failed" => ["warn", _("Could not open [%s] for reading.")], "file_open_read_success" => ["info", _("Reading options from [%s].")], "file_open_write_failed" => ["error", _("Failed to write to [%s].")], "file_open_write_create" => ["warn", _("Could not find [%s] for writing. Creating [%s].")], "file_open_write_success" => ["info", _("Writing to [%s].")], "file_create_path" => ["info", _("Directory [%s] created.")], "file_backup_rotate" => ["info", _("Backup directory [%s] was rotated.")], "file_backup_success" => ["info", _("Saved backup for [%s].")], "file_open_filter_failed" => ["warn", _("No file to patch: [%s].")], "file_open_filter_create" => ["warn", _("Could not find [%s] for patching. Creating [%s].")], "file_open_filter_success" => ["info", _("Found [%s]. Patching [%s].")], "file_buffer_load" => ["info", _("Loading file [%s] to buffer.")], "file_buffer_save" => ["info", _("Saving buffer to file [%s].")], "file_run" => ["info", _("Running command [%s].")], "file_locate_tool_success" => ["info", _("Found tool [%s].")], "file_locate_tool_failed" => ["warn", _("Couldn't find tool [%s].")], "parse_table" => ["info", _("Parsing option [%s].")], "parse_trivial" => ["info", _("Trivialy passing [%s].")], "parse_split" => ["info", _("Getting option [%s] from [%s].")], "parse_split_hash" => ["info", _("Getting configuration from [%s].")], "parse_split_hash_cont" => ["info", _("Getting configuration from [%s].")], "parse_sh" => ["info", _("Getting shell option [%s] from [%s].")], "parse_kw" => ["info", _("Getting keyword [%s] from [%s].")], "parse_line_first" => ["info", _("Getting information from [%s].")], "parse_chat" => ["info", _("Getting chat information from [%s].")], "parse_ini" => ["info", _("Getting option [%s] from [%s], section [%s].")], "parse_ifaces_str" => ["info", _("Getting option [%s] from interface [%s].")], "parse_ifaces_kw" => ["info", _("Getting keyword [%s] from interface [%s].")], "parse_ifaces_kw_strange" => ["warn", _("Keyword for interface [%s] in [%s] had unexpected value.")], "replace_split" => ["info", _("Replacing key [%s] in [%s].")], "replace_sh" => ["info", _("Replacing shell var [%s] in [%s].")], "replace_kw" => ["info", _("Replacing keyword [%s] in [%s].")], "replace_line_first" => ["info", _("Replacing contents of file [%s].")], "replace_chat" => ["info", _("Replacing values in [%s].")], "replace_ini" => ["info", _("Replacing variable [%s] in section [%s] of [%s].")], "replace_ifaces_str" => ["info", _("Replacing option [%s] from interface [%s].")], "replace_ifaces_kw" => ["info", _("Replacing keyword [%s] from interface [%s].")], "service_status_running" => ["info", _("Service [%s] is running.")], "service_status_stopped" => ["info", _("Service [%s] is stopped.")], "service_sysv_not_found" => ["warn", _("Could not find SystemV scripts for service [%s].")], "service_sysv_no_runlevel" => ["warn", _("Could not find SystemV runlevel [%s] directory [%s].")], "service_sysv_remove_link" => ["info", _("Removed SystemV link [%s].")], "service_sysv_add_link" => ["info", _("Created SystemV link [%s].")], "service_sysv_op_unk" => ["error", _("Unknown initd operation [%s].")], "service_sysv_op_success" => ["info", _("Service [%s] %s.")], "service_sysv_op_failed" => ["warn", _("Service [%s] cound not be %s.")], "network_dialing_get" => ["info", _("Loading ISP configurations.")], "network_iface_active_get" => ["info", _("Finding active interfaces.")], "network_iface_is_active" => ["info", _("Checking if interface [%s] is active.")], "network_hostname_set" => ["info", _("Setting hostname to [%s].")], "network_dialing_set" => ["info", _("Saving ISP configurations.")], "network_remove_pap" => ["info", _("Removing entry [%s] from [%s].")], "network_iface_set" => ["info", _("Configuring interface [%s].")], "network_iface_activate" => ["info", _("Activating interface [%s].")], "network_iface_deactivate" => ["info", _("Deactivating interface [%s].")], "network_ifaces_set" => ["info", _("Setting up interfaces.")], "network_get_pap_passwd" => ["info", _("Getting PAP/CHAP password for [%s] from [%s].")], "network_get_ppp_option" => ["info", _("Getting option [%s] from [%s].")], "network_set_ppp_option" => ["info", _("Setting option [%s] in [%s].")], "network_set_ppp_connect" => ["info", _("Setting connect option in [%s].")], "network_get_ppp_unsup" => ["info", _("Getting additional options from [%s].")], "network_set_ppp_unsup" => ["info", _("Setting additional options in [%s].")], "network_bootproto_unsup" => ["warn", _("Boot method [%s] for interface [%s] not supported.")], "network_get_remote" => ["info", _("Getting remote address for interface [%s].")], "network_set_remote" => ["info", _("Setting remote address for interface [%s].")], "network_ensure_lo" => ["info", _("Ensuring loopback interface configuration.")], "boot_lilo_failed" => ["warn", _("Failed to run lilo.")], "boot_lilo_success" => ["info", _("Succesfully executed lilo.")], "disks_fstab_add" => ["info", _("Adding [%s] to fstab.")], "disks_partition_probe" => ["info", _("Looking for partitions on [%s].")], "disks_size_query" => ["info", _("Querying size of [%s].")], "disks_mount" => ["info", _("Mounting [%s].")], "disks_umount" => ["info", _("Unmounting [%s].")], "disks_mount_error" => ["error", _("Could not find mount tools. No mounting done.")], "memory_swap_found" => ["info", _("Found swap entry [%s].")], "memory_swap_probe" => ["info", _("Looking for swap entries.")], "print_no_printtool" => ["warn", _("No printtool setup in directory [%s].")], "time_timezone_scan" => ["info", _("Scanning timezones.")], "time_timezone_cmp" => ["info", _("Scanning timezones: [%s].")], "time_timezone_set" => ["info", _("Setting timezone as [%s].")], "time_localtime_set" => ["info", _("Setting local time as [%s].")], "users_getting_db" => ["info", _("Getting user database.")] ); 1;