378 lines
16 KiB
Perl
Executable File
378 lines
16 KiB
Perl
Executable File
#!/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_add.tree.pl
|
|
#
|
|
# Routines to add and remove new trees
|
|
|
|
1; # Return true
|
|
|
|
# INPUT: %in
|
|
# Create the appropriate add a tree page based on user input
|
|
|
|
sub Generate_Maint_Tree_Page {
|
|
if ($in{$CGI_TREE_ADD_SWITCH}) {
|
|
&Generate_New_Tree_Page;
|
|
} elsif ($in{$CGI_TREE_DELETE_SWITCH}) {
|
|
&Generate_Delete_Tree_Page;
|
|
} elsif ($in{$CGI_TREE_OLD_NAME_SWITCH}) {
|
|
&Generate_Tree_Change_Name_Page;
|
|
} elsif ($in{$CGI_TREE_VIEW_SWITCH}) {
|
|
&Pop_Tree_Demos;
|
|
} else {
|
|
&Print_Main_Tree_Page;
|
|
}
|
|
}
|
|
|
|
# INPUT: %in
|
|
# Delete a tree by performing the following actions
|
|
# - Remove the tree from namespace
|
|
# - Remove the list file
|
|
# - Remove all references to that tree in the "All Demos" list
|
|
# - Remove references in custom lists
|
|
# - Update all tables and demo lists inthe background
|
|
# - Notify user of table update in progress
|
|
# - Print the final page after deletion
|
|
|
|
sub Generate_Delete_Tree_Page {
|
|
local($tree_delete_name, $tree_delete_path, $tree_delete_file, $file_list, @custom_list_files);
|
|
$tree_delete_name = $in{$CGI_TREE_DELETE_SWITCH};
|
|
$tree_delete_path = &Tree_Path_From_Name("$tree_delete_name");
|
|
$tree_delete_file = &Tree_File_From_Name("$tree_delete_name");
|
|
&Delete_Tree_From_Name_Space("$tree_delete_name");
|
|
#remove its list
|
|
`$CMD_RM $PATH_TREES_DIR/$tree_delete_file $CMD_NULLIFY`;
|
|
#remove references in All Demos
|
|
`$CMD_PERL $CMD_PERL_FLAGS 's/.*$TREES_DELIM$tree_delete_name\\n//g' $FILE_DEMOLIST $CMD_NULLIFY`;
|
|
#remove references from custom lists
|
|
@custom_list_files = &List_Custom_List_Files;
|
|
grep(($_ = "$PATH_CUSTOM_DIR/$_"), @custom_list_files);
|
|
$file_list = join(" ", @custom_list_files);
|
|
`$CMD_PERL $CMD_PERL_FLAGS 's/.*$TREES_DELIM$tree_delete_name\\n//g' $file_list $CMD_NULLIFY`;
|
|
&Print_Delete_Tree_Success_Page;
|
|
}
|
|
|
|
# INPUT:($tree_name)
|
|
# Remove a tree from name space
|
|
|
|
sub Delete_Tree_From_Name_Space {
|
|
local($tree_path, $tree_file, $tree_name, $tree_delete_name);
|
|
$tree_delete_name = shift;
|
|
open(NAMESPACE, "$FILE_TREES_NAMESPACE") || &Print_Error("$ERROR_NO_OPEN", "$FILE_TREES_NAMESPACE", "$STATUS_SERIOUS");
|
|
open(TMP_FILE, ">$FILE_NAMESPACE_TMP") || &Print_Error("$ERROR_NO_OPEN", "$FILE_NAMESPACE_TMP", "$STATUS_SERIOUS");
|
|
while (<NAMESPACE>) {
|
|
chop;
|
|
($tree_name, $tree_path, $tree_file) = /(.*)$TREES_DELIM(.*)$TREES_DELIM(.*)/;
|
|
print TMP_FILE "$tree_name$TREES_DELIM$tree_path$TREES_DELIM$tree_file\n" if ("$tree_name" ne "$tree_delete_name");
|
|
}
|
|
close(NAMESPACE);
|
|
close(TMP_FILE);
|
|
rename("$FILE_NAMESPACE_TMP", "$FILE_TREES_NAMESPACE");
|
|
}
|
|
|
|
# INPUT: %in
|
|
# Print the post-delete page
|
|
|
|
sub Print_Delete_Tree_Success_Page {
|
|
&Print_Maint_Top("Demo List Deleted", "$IMGSRC_HEADER_TREE",0,0,1);
|
|
&Print_Error("$ERROR_INFO","Tree \"$in{$CGI_TREE_DELETE_SWITCH}\" deleted.","$STATUS_MINOR");
|
|
print "<font color=red size=+3>I</font><font color=red size=+1>NFORMATION</font><p>\n";
|
|
print "<p>\n";
|
|
print "Demo List <i>$in{$CGI_TREE_DELETE_SWITCH}</i> deleted.";
|
|
print "<p>\n";
|
|
print "Use this utility to make further modifications to your <i>demo lists</i>.\n";
|
|
print "<p>\n";
|
|
print "<p>\n<p>\n<hr noshade>\n";
|
|
&Print_Main_Tree_Forms;
|
|
}
|
|
|
|
# INPUT: %in
|
|
# Create the correct new tree page based on user input
|
|
|
|
sub Generate_New_Tree_Page {
|
|
$in{$CGI_TREE_ADD_SWITCH} = &Make_HTTP_Safe("$in{$CGI_TREE_ADD_SWITCH}");
|
|
if ( &Safe_Tree_Name("$in{$CGI_TREE_ADD_SWITCH}") && &Safe_Tree_Path_Name("$in{$CGI_TREE_PATH_SWITCH}") ) {
|
|
&Add_Tree("$in{$CGI_TREE_ADD_SWITCH}", "$in{$CGI_TREE_PATH_SWITCH}", &Generate_File_Name);
|
|
&Print_Add_Tree_Success_Page;
|
|
} else {
|
|
&Print_Add_Tree_Failure_Page;
|
|
}
|
|
}
|
|
|
|
# INPUT: ($tree_path)
|
|
# Check a tree path to see if it exists and is not already loaded
|
|
|
|
sub Safe_Tree_Path_Name {
|
|
local($doesExist, $notTaken, @treePaths);
|
|
$doesExist = chdir("$_[0]");
|
|
@treeNames = &List_Tree_Names;
|
|
for (@treeNames) {
|
|
push(@treePaths, &Tree_Path_From_Name("$_"));
|
|
}
|
|
$notTaken = (! grep(/^$_[0]$/, @treePaths) );
|
|
return( ($notTaken && $doesExist) );
|
|
}
|
|
|
|
# INPUT: %in
|
|
# Print the post-add failure page
|
|
|
|
sub Print_Add_Tree_Failure_Page {
|
|
&Print_Maint_Top("Error: Can't Create Tree", "$IMGSRC_HEADER_TREE");
|
|
&Print_Error("$ERROR_INFO","Tree \"$in{$CGI_TREE_ADD_SWITCH}\" for \"$in{$CGI_TREE_PATH_SWITCH}\" could not be created.","$STATUS_MINOR");
|
|
print "<font color=red size=+3>I</font><font color=red size=+1>NFORMATION</font><p>\n";
|
|
print "<p>\n";
|
|
print "Demo List <i>$in{$CGI_TREE_ADD_SWITCH}</i> for <i>$in{$CGI_TREE_PATH_SWITCH}</i> could not be created.";
|
|
print "<p>\n";
|
|
print "Use this utility to make further modifications to your <i>demo lists</i>.\n";
|
|
print "<p>\n";
|
|
print "<p>\n<hr noshade>\n";
|
|
&Print_Main_Tree_Forms;
|
|
}
|
|
|
|
# INPUT: ($tree_name, $tree_path, $tree_file, $stop_notify)
|
|
# Add a tree to the interface by performing the following actions
|
|
# - Add the tree to namespace
|
|
# - Parse the list of demos
|
|
# - Update all tables in the background
|
|
# - Notify the user if "$stop_notify" not defined
|
|
|
|
sub Add_Tree {
|
|
local($tree_name, $tree_path, $tree_file);
|
|
$tree_name = shift;
|
|
$tree_path = shift;
|
|
$tree_file = shift;
|
|
# add to namespace
|
|
open(NAMESPACE, ">>$FILE_TREES_NAMESPACE") || &Print_Error("$ERROR_NO_OPEN", "$FILE_TREES_NAMESPACE", "$STATUS_SERIOUS");
|
|
print NAMESPACE "$tree_name$TREES_DELIM$tree_path$TREES_DELIM$tree_file\n";
|
|
close(NAMESPACE);
|
|
}
|
|
|
|
# INPUT: %in
|
|
# Print post-add success page
|
|
|
|
sub Print_Add_Tree_Success_Page {
|
|
&Print_Maint_Top("Demo List Created", "$IMGSRC_HEADER_TREE", 0, 0, 1);
|
|
&Print_Error("$ERROR_INFO","Tree \"$in{$CGI_TREE_ADD_SWITCH}\" created for \"$in{$CGI_TREE_PATH_SWITCH}\".","$STATUS_MINOR");
|
|
print "<font color=red size=+3>I</font><font color=red size=+1>NFORMATION</font><p>\n";
|
|
print "<p>\n";
|
|
print "Demo List <i>$in{$CGI_TREE_ADD_SWITCH}</i> created for <i>$in{$CGI_TREE_PATH_SWITCH}</i> .";
|
|
print "<p>\n";
|
|
print "Use this utility to make further modifications to your trees portfolio.\n";
|
|
print "<p>\n";
|
|
print "<p>\n<hr noshade>\n";
|
|
&Print_Main_Tree_Forms;
|
|
}
|
|
|
|
# INPUT: %in
|
|
# Create appropriate change name page from user input
|
|
|
|
sub Generate_Tree_Change_Name_Page {
|
|
$in{$CGI_TREE_NEW_NAME_SWITCH} = &Make_HTTP_Safe("$in{$CGI_TREE_NEW_NAME_SWITCH}");
|
|
if ( &Safe_Tree_Name("$in{$CGI_TREE_NEW_NAME_SWITCH}") ) {
|
|
&Print_Maint_Top("Tree Name Changed", "$IMGSRC_HEADER_TREE");
|
|
&Change_Tree_Name("$in{$CGI_TREE_OLD_NAME_SWITCH}", "$in{$CGI_TREE_NEW_NAME_SWITCH}");
|
|
&Print_Tree_Name_Change_Success;
|
|
} else {
|
|
&Print_Maint_Top("Error: Can't Change Tree Name", "$IMGSRC_HEADER_TREE");
|
|
&Print_Tree_Name_Change_Failure;
|
|
}
|
|
}
|
|
|
|
# INPUT: ($tree_name)
|
|
# Check to see if tree name is legal
|
|
|
|
sub Safe_Tree_Name {
|
|
local(@names, $name);
|
|
$name = $_[0];
|
|
@names = &List_Tree_Names;
|
|
$oppRet = (! grep(/^$name$/, @names));
|
|
return($oppRet);
|
|
}
|
|
|
|
sub Print_Tree_Name_Change_Failure {
|
|
&Print_Error("$ERROR_INFO","Tree \"$in{$CGI_TREE_OLD_NAME_SWITCH}\" Could Not Be Changed To \"$in{$CGI_TREE_NEW_NAME_SWITCH}\"","$STATUS_MINOR");
|
|
print "<font color=red size=+3>I</font><font color=red size=+1>NFORMATION</font><p>\n";
|
|
print "<p>\n";
|
|
print "The tree <i>$in{$CGI_TREE_OLD_NAME_SWITCH}</i> could not be changed <i>$in{$CGI_TREE_NEW_NAME_SWITCH}</i>.";
|
|
print "<p>\n";
|
|
print "Use this utility to make further modifications to your trees portfolio.\n";
|
|
print "<p>\n";
|
|
print "<p>\n<hr noshade>\n";
|
|
&Print_Main_Tree_Forms;
|
|
}
|
|
|
|
sub Change_Tree_Name {
|
|
local($tree_path, $tree_file, $tree_name, $tree_old_name, $tree_new_name, $file_list, @custom_list_files);
|
|
$tree_old_name = shift;
|
|
$tree_new_name = shift;
|
|
open(NAMESPACE, "$FILE_TREES_NAMESPACE") || &Print_Error("$ERROR_NO_OPEN", "$FILE_TREES_NAMESPACE", "$STATUS_SERIOUS");
|
|
open(TMP_FILE, ">$FILE_NAMESPACE_TMP") || &Print_Error("$ERROR_NO_OPEN", "$FILE_NAMESPACE_TMP", "$STATUS_SERIOUS");
|
|
while (<NAMESPACE>) {
|
|
chop;
|
|
($tree_name, $tree_path, $tree_file) = /(.*)$TREES_DELIM(.*)$TREES_DELIM(.*)/;
|
|
$tree_name = "$tree_new_name" if ("$tree_name" eq "$tree_old_name");
|
|
print TMP_FILE "$tree_name$TREES_DELIM$tree_path$TREES_DELIM$tree_file\n";
|
|
}
|
|
close(NAMESPACE);
|
|
close(TMP_FILE);
|
|
rename("$FILE_NAMESPACE_TMP", "$FILE_TREES_NAMESPACE");
|
|
@custom_list_files = &List_Custom_List_Files;
|
|
grep(($_ = "$PATH_CUSTOM_DIR/$_"), @custom_list_files);
|
|
$file_list = join(" ", $FILE_DEMOLIST, $FILE_TABLE_FEATURES, $FILE_TABLE_MARKETS, $FILE_TABLE_HARDWARE, $FILE_DEFAULT_LIST, @custom_list_files);
|
|
`$CMD_PERL $CMD_PERL_FLAGS 's/$tree_old_name/$tree_new_name/g' $file_list`;
|
|
}
|
|
|
|
sub Make_HTTP_Safe {
|
|
$tmp = shift;
|
|
$tmp =~ tr/'";>:<?+%//d;
|
|
return("$tmp");
|
|
}
|
|
|
|
sub Print_Tree_Name_Change_Success {
|
|
&Print_Error("$ERROR_INFO","Tree \"$in{$CGI_TREE_OLD_NAME_SWITCH}\" Renamed As \"$in{$CGI_TREE_NEW_NAME_SWITCH}\"","$STATUS_MINOR");
|
|
print "<font color=red size=+3>I</font><font color=red size=+1>NFORMATION</font><p>\n";
|
|
print "<p>\n";
|
|
print "The tree <i>$in{$CGI_TREE_OLD_NAME_SWITCH}</i> changed its name to <i>$in{$CGI_TREE_NEW_NAME_SWITCH}</i>.";
|
|
print "<p>\n";
|
|
print "Use this utility to make further modifications to your trees portfolio.\n";
|
|
print "<p>\n";
|
|
print "<p>\n<hr noshade>\n";
|
|
&Print_Main_Tree_Forms;
|
|
}
|
|
|
|
sub Pop_Tree_Demos {
|
|
$file_name = &Tree_File_From_Name("$in{$CGI_TREE_VIEW_SWITCH}");
|
|
$file_name = "$PATH_TREES_DIR/$file_name";
|
|
# &Background_Execute("$CMD_XCONFIRM $CMD_XCONFIRM_HEADER \"Demos in $_[0]\" $CMD_XCONFIRM_FILE $file_name $CMD_XCONFIRM_FLAGS ");
|
|
# `$CMD_XCONFIRM $CMD_XCONFIRM_HEADER \"Demos in $_[0]\" $CMD_XCONFIRM_FILE $file_name $CMD_XCONFIRM_FLAGS $CMD_NULLIFY $CMD_BACKGROUND`;
|
|
&Print_HTTP_Header("$in{$CGI_TREE_VIEW_SWITCH}");
|
|
print "<body bgcolor=white>\n";
|
|
print "<center><b>$in{$CGI_TREE_VIEW_SWITCH}</b></center>\n";
|
|
print "<p>\n";
|
|
print "<ul>\n";
|
|
open(FILE, "$file_name") || &Print_Error("$ERROR_NO_OPEN", "$file_name", "$STATUS_SERIOUS");
|
|
while(<FILE>) {
|
|
print "<li>$_";
|
|
}
|
|
close(FILE);
|
|
print "<\ul>\n";
|
|
&Print_HTTP_Footer;
|
|
}
|
|
|
|
sub Print_Main_Tree_Page {
|
|
local(@lists, $list);
|
|
&Print_Maint_Top("Add a Group of Demos", "$IMGSRC_HEADER_TREE");
|
|
print "<font color=red size=+3>I</font><font color=red size=+1>NFORMATION</font><p>\n";
|
|
print "<p>\n";
|
|
print "Adding a group of demos with this utility creates a <i>demo list</i>.<p> Add, remove, or modify a <i>demo list</i> for a group of demos with this utility.";
|
|
print "<p>\n<hr noshade>\n";
|
|
&Print_Main_Tree_Forms;
|
|
}
|
|
|
|
sub Print_Main_Tree_Forms {
|
|
local(@trees, $tree);
|
|
@trees = &List_Tree_Names;
|
|
&Print_Add_Tree_Form;
|
|
print "<p>\n";
|
|
print "<hr align=left width=78%>\n";
|
|
print "<p>\n";
|
|
if (@trees) {
|
|
print "<font color=red size=+3>P</font><font color=red size=+1>ICK </font> \n";
|
|
print "<font color=red size=+3>D</font><font color=red size=+1>EMO</font>\n";
|
|
print "<font color=red size=+3>L</font><font color=red size=+1>IST</font><p>\n";
|
|
print "<table border=0 marginwidth=0 marginheight=0 cellspacing=0 cellpadding=05>\n";
|
|
}
|
|
foreach $tree ( &alpha(@trees) ) {
|
|
&Print_Tree_Bullet("$tree");
|
|
}
|
|
print "</table>\n" if (@trees);
|
|
print "<p>\n";
|
|
&Print_Look_At_Help;
|
|
&Print_Maint_Bottom;
|
|
&Print_HTTP_Footer;
|
|
}
|
|
|
|
sub Print_Add_Tree_Form {
|
|
print "<font color=red size=+3>A</font><font color=red size=+1>DD </font>\n";
|
|
print "<font color=red size=+3>D</font><font color=red size=+1>EMO</font>\n";
|
|
print "<font color=red size=+3>L</font><font color=red size=+1>IST</font><p>\n";
|
|
print "<form target=$FRAME_MAIN action=\"$WWW_SCRIPT\">\n";
|
|
print "<input type=hidden name=\"$CGI_SWITCH\" value=\"$CGI_MAINT_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_SUB_SWITCH\" value=\"$CGI_MAINT_ADD_TREE_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_MAINT_OUTSIDE_SWITCH\" value=\"$CGI_MAINT_FALSE_FLAG\">\n";
|
|
print "<table bgcolor=$INPUT_BGCOLOR>\n<tr>\n";
|
|
print "<font size=3 color=blue>\n";
|
|
print "<td align=center>\nPath: <input name=\"$CGI_TREE_PATH_SWITCH\" value=";
|
|
print "\"$in{$CGI_TREE_PATH_SWITCH}\"";
|
|
print " size=30><br>\n";
|
|
print "\nName: <input name=\"$CGI_TREE_ADD_SWITCH\" value=\"$in{$CGI_TREE_ADD_SWITCH}\" size=30></br>";
|
|
print "</font><font size=2 color=blue>\n";
|
|
print "<input type=submit value=\"Add List\">\n";
|
|
print "</td>\n</tr>\n</table>\n";
|
|
print "</font>\n";
|
|
print "</form>\n";
|
|
}
|
|
|
|
sub Print_Tree_Bullet {
|
|
local($safe_tree_name);
|
|
undef $safe_tree_name;
|
|
$safe_tree_name = &HTTP_Syntax("$_[0]");
|
|
print "<form target=$FRAME_MAIN method=GET action=\"$WWW_SCRIPT\">\n";
|
|
print "<tr bgcolor=$INPUT_BGCOLOR>\n";
|
|
print "<td colspan=3>\n";
|
|
print "<input type=hidden name=\"$CGI_SWITCH\" value=\"$CGI_MAINT_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_SUB_SWITCH\" value=\"$CGI_MAINT_ADD_TREE_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_MAINT_OUTSIDE_SWITCH\" value=\"$CGI_MAINT_FALSE_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_TREE_OLD_NAME_SWITCH\" value=\"$_[0]\">\n";
|
|
print "<input name=\"$CGI_TREE_NEW_NAME_SWITCH\" value=\"$_[0]\" size=30></td></tr>\n";
|
|
print "<tr bgcolor=$INPUT_BGCOLOR>\n";
|
|
print "<td valign=top><font size=2 color=brown><input type=submit value=\"Change Name\">\n";
|
|
print "</font>\n";
|
|
print "</td>\n";
|
|
print "</form>\n";
|
|
print "<td>\n";
|
|
print "<form onSubmit=\"return PopTreeView(\'$safe_tree_name\')\">\n";
|
|
print "<font size=2 color=blue>\n";
|
|
print "<input type=submit value=\"View Demos\">\n";
|
|
print "</font>\n";
|
|
print "</form>\n";
|
|
print "</td>\n";
|
|
print "<td>\n";
|
|
print "<form target=$FRAME_MAIN method=GET onSubmit=\"return confirmDelete(\'$_[0]\')\" action=\"$WWW_SCRIPT\">\n";
|
|
print "<input type=hidden name=\"$CGI_SWITCH\" value=\"$CGI_MAINT_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_SUB_SWITCH\" value=\"$CGI_MAINT_ADD_TREE_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_MAINT_OUTSIDE_SWITCH\" value=\"$CGI_MAINT_FALSE_FLAG\">\n";
|
|
print "<input type=hidden name=\"$CGI_TREE_DELETE_SWITCH\" value=\"$_[0]\">\n";
|
|
print "<font size=2 color=red>\n";
|
|
print "<input type=submit value=\"Delete List\">\n";
|
|
print "</font>\n";
|
|
print "</form>\n";
|
|
print "</td>\n";
|
|
print "</tr>\n";
|
|
print "<tr><td><p></td></tr>\n";
|
|
}
|