#!/usr/bin/perl -w # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU 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 General Public License for more details. # # You should have received a copy of the GNU 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. use strict; # Begin configuration my $rep = "/home/arnaud/testing/"; # ------------------------ # Do not edit after this ! # ------------------------ # ---------------------------- # ***** Function listing ***** # ---------------------------- # Defines the architecture of the working directories my $directory_contains_active = "active/"; # Directory where links for active modules are (default active/) my $directory_contains_all = "default/"; # Directory where all the modules are (default default/) # Function to retrieves directories present in another directory. # Requires the path to the directory to search in. # Returns an array with directories names. sub get_content_dir { # Initializing variables my ($get_content_dir_dir,@get_content_dir_return,@get_content_dir_files,$get_content_dir_file); ($get_content_dir_dir) = @_; # If possible, open directory, else, report an error opendir DIR, $get_content_dir_dir or die "$get_content_dir_dir is not a valid directory"; # Reads the content of the directory @get_content_dir_files = readdir DIR; # Processes for each file/directory viewed in this directory foreach $get_content_dir_file (@get_content_dir_files) { # Selects only directories useful (except . and ..) if ( -d $get_content_dir_dir.$get_content_dir_file && $get_content_dir_file ne "." && $get_content_dir_file ne ".." ) { push(@get_content_dir_return,$get_content_dir_file); } } # Returns the array with every directory name return @get_content_dir_return; } # End of function get_content_dir # Function to create a table with active modules # Returns an array with dirs of active modules sub get_modules_actives { # Initializing variables my ($get_modules_actives_dir) = @_; my @get_modules_actives_return; # Retrieving modules in the active directory @get_modules_actives_return = &get_content_dir($get_modules_actives_dir."modules/".$directory_contains_active); return @get_modules_actives_return; } # End of function get_modules_active # Function to determine if a module is in the directory # Requires the module and the directory array # Returns 1 for TRUE, 0 for FALSE sub get_module { # Initializing all the variables my ($get_module_name,@get_module_array) = @_; my $get_module_module; # Processes for each module in the array foreach $get_module_module (@get_module_array) { # Returns 1 if module is present if ($get_module_module eq $get_module_name) { return 1; } } # Returns 0 in any other case return 0; } # End of function get_module # Function to get list of inactives modules # Requires two arrays, one for active modules, and another for modules list # Returns an array containing inactives modules sub get_modules_inactives { # Initializing all necessary variables no strict 'refs'; my ($get_modules_inactives_modules_actives,$get_modules_inactives_modules_list) = @_; my @get_modules_inactives_return; my $get_modules_inactives_process; # Processing by looking in the first array given foreach $get_modules_inactives_process (@$get_modules_inactives_modules_list) { if (get_module($get_modules_inactives_process,@$get_modules_inactives_modules_actives) == 0) { push (@get_modules_inactives_return,$get_modules_inactives_process); } } return @get_modules_inactives_return; } # End of function get_modules_inactives # ------------------------ # ***** Main program ***** # ------------------------ # Gets beginning execution time # FIND FUNCTION TO INSERT HERE TO GET MICROTIME # Builds arrays containing lists of modules my @modules_actives = &get_modules_actives($rep); my @modules_list = &get_content_dir($rep."modules/".$directory_contains_all); my @modules_inactives = &get_modules_inactives(\@modules_actives,\@modules_list); # Retrieves arguments given (#1,#2,#3) my (@args) = (shift,shift,shift); # Begin the cases only if an argument is given if ($args[0]) { # ------------------------------------------------ # ----- Processing with creation of database ----- # ------------------------------------------------ if ($args[0] eq "create") { } } else { } # Gets ending execution tile # FIND FUNCTION TO INSERT HERE TO GET MICROTIME