#!/usr/sbin/perl #************************************************************************** #* * #* Copyright (c) 1996 Silicon Graphics, Inc. * #* All Rights Reserved * #* * #* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI * #* * #* The copyright notice above does not evidence any actual of intended * #* publication of such source code, and is an unpublished work by Silicon * #* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is * #* the property of Silicon Graphics, Inc. Any use, duplication or * #* disclosure not specifically authorized by Silicon Graphics is strictly * #* prohibited. * #* * #* RESTRICTED RIGHTS LEGEND: * #* * #* Use, duplication or disclosure by the Government is subject to * #* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in * #* Technical Data and Computer Software clause at DFARS 52.227-7013, * #* and/or in similar or successor clauses in the FAR, DOD or NASA FAR * #* Supplement. Unpublished - rights reserved under the Copyright Laws of * #* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. * #* Shoreline Blvd., Mountain View, CA 94039-7311 * #************************************************************************** # DEMO_errors.pl # # Routines for handling errors 1; # Return true sub Print_Error { local($prompt, $message, $status, $error_message); $prompt = shift; $message = shift; $status = shift; $time_stamp = &Get_Time_Stamp; $error_message = "$time_stamp> $prompt: $message"; &Write_Error_Message("$error_message"); &Take_Error_Action("$status"); } sub Take_Error_Action { local($error_message); if ("$_[0]" ne "$STATUS_MINOR" && "$_[0]" ne "") { $error_message = "$time_stamp> $ERROR_NOTIFY_PROMPT: Script Terminated Due To Errors" if ("$_[0]" eq "$STATUS_SERIOUS"); &Write_Error_Message("$error_message"); &Txt_Pop("Critical Error","$error_message Check error log."); exit 0 if ("$_[0]" eq "$STATUS_SERIOUS"); } } sub Write_Error_Message { local($num_lines, $too_long); $too_long = 0; $num_lines = &Lines_In_Log; $too_long = 1 if ($num_lines >= $ERROR_LOG_MAX_LENGTH); open(LOG, ">>$FILE_ERROR_LOG"); print LOG "$_[0]\n"; close(LOG); if ($too_long) { &Trim_Log($num_lines); } } sub Trim_Log { local($total_lines, $trim_lines); $total_lines = shift; $trim_lines = $total_lines/2; open(LOG, "$FILE_ERROR_LOG"); open(TMP_LOG, ">$FILE_LOG_TMP"); while () { print TMP_LOG $_ if ($. >= $trim_lines); } close(LOG); close(TMP_LOG); rename("$FILE_LOG_TMP", "$FILE_ERROR_LOG"); } sub Lines_In_Log { local($num_lines); open(LOG, "$FILE_ERROR_LOG"); while() { $num_lines = $.; } close(LOG); return($num_lines); } sub Get_Time_Stamp { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @weekday = (Sun,Mon,Tues,Web,Thurs,Fri,Sat); $wday = @weekday[$wday]; @month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); $mon = $month[$mon]; $mday = " $mday" if ($mday <= 9); $hour = " $hour" if ($hour <= 9); $min = "0$min" if ($min <= 9); $sec = "0$sec" if ($sec <= 9); return("$mon $mday $hour:$min:$sec"); } sub Print_Bad_Input_Page { &Print_HTTP_Header("Error! Bad Input"); print "\n"; print "Bad input!\n"; &Print_HTTP_Footer; } sub Print_Directorystate_Error { $title = "Wrong Directory Permissions/Ownership"; print "\n"; print "$title\n -- Fix this first!\n

\n"; } sub Print_Indexstate_Error { $title = "Wrong Index Permissions/Ownership"; print "\n"; print "$title\n\n

\n"; } sub Print_Thumbstate_Error { $title = "Wrong Thumbnail Image Permissions/Ownership"; print "\n"; print "$title\n\n

\n"; } sub Print_Thumbfound_Error { $title = "Thumbnail Image Not Found"; print "\n"; print "$title\n"; print "Use default thumbnail image\n"; print "\n"; print "\n

\n"; } sub Print_Picstate_Error { $title = "Wrong Demo Image Permissions/Ownership"; print "\n"; print "$title\n\n

\n"; } sub Print_Picfound_Error { $title = "Demo Image Not Found"; print "\n"; print "$title\n"; print "Use default demo image\n"; print "\n"; print "\n\n

\n"; } sub Print_Demostate_Error { $title = "Wrong RUN Executable Permissions"; print "\n"; print "$title\n\n

\n"; } sub Print_Demofound_Error { $title = "RUN Executable Not Found"; print "\n"; print "$title\n\n

\n"; } sub Print_Headerstate_Error { $title = "Wrong Header Image Permissions/Ownership"; print "\n"; print "$title\n\n

\n"; }