ApVSys : Application Versioning System

      Copyright (C) 2002 Arnaud BERTRAND
      web-site: http://www.apvsys.org


Goal

The ap-environment file is a kind of setup script executed before each command related to a tool or version of a tool. This file can be written in C, perl, sh, csh, bash, ksh or tcsh and must be located in the root directory of the tool/version: $APVSYS_ROOT/OsName/vOsVersion/ToolName/vToolVersion/ap-environment.xx

Warning: The extension of ap-environment.xx determines which interpreter will start according to the following list.

 so   -> C compiled code
 pl   -> perl
 sh   -> sh
 csh  -> csh
 bash -> bash
 ksh  -> ksh
 tcsh -> tcsh

The priority order is the order above with .so having greatest priority but it would be very strange to require 2 ap-environment.xx files for the same version of a tool!

Some variables and functions are available for use in these scripts:


Predefined environment variables:


Predifined functions:

of course, the syntax of these commands depends on the language used. Please read the syntax section.


The syntax

To show the syntax, an example will be shown for each language:

C-mode : ap-environment.so

This file is the only one which has to be compiled. It comes from ap-environment.c and must contains the function int apenvironment(int argc, char** argv). This functions must return 1 if successful. To compile ap-environment.c, the script apv-envCompile MUST be used. Here is an example:

 int apenvironment(int argc, char **argv) {
   printf("--- C environment setting ---\n");
   loadenv("apv-child1",0,argc,argv);
   loadenv("apv-child2","v2.0",argc,argv);
   set_env("APVEXAMPLE","C tested");
   set_env("APVUNIQ","c:ca:cb:ca:ca:c:cc"); 
   uniquify_env(getenv("APVUNIQ"));
   set_env("APVAPPEND","first:set");
   set_env("APVPREPEND","first:set");
   append_env("APVAPPEND", "second:set");
   prepend_env("APVPREPEND", "second:set");
   printf("--- END C environment setting ---\n");
   return 1;
 }

IMPORTANT NOTE: loadenv must contains 4 arguments and the last two arguments are argc, argv.

Perl-mode : ap-environment.pl

 print "--- perl environment setting ---\n";
 &loadenv("apv-child1");
 &loadenv("apv-child2", "v2.0");
 $ENV{APVEXAMPLE}="perl tested";
 $ENV{APVUNIQ}=&uniquify_env("pl:pla:plb:pla:pla:pl:plc");
 $ENV{APVAPPEND}="first:set";
 $ENV{APVPREPEND}="first:set";
 &append_env("APVAPPEND", "second:set");
 &prepend_env("APVPREPEND", "second:set");
 print "--- END perl environment setting ---\n";

sh-mode : ap-environment.sh ( same syntax for .bash and .ksh )

 echo "--- sh environment setting ---"
 loadenv "apv-child1"
 loadenv "apv-child2" "v2.0"
 APVEXAMPLE="sh tested"
 APVUNIQ=`uniquify_env "sh:sha:shb:sha:sha:sh:shc"`
 APVAPPEND="first:set"
 APVPREPEND="first:set"
 append_env APVAPPEND "second:set"
 prepend_env APVPREPEND "second:set"
 export APVUNIQ
 export APVEXAMPLE
 echo "--- END sh environment setting ---"

csh-mode : ap-environment.csh ( same syntax for .tcsh )

 echo "--- csh environment setting ---"
 loadenv "apv-child1"
 loadenv "apv-child2" "v2.0"
 setenv APVEXAMPLE "csh tested"
 setenv APVUNIQ `uniquify_env "csh:csha:cshb:csha:csha:csh:cshc"`
 setenv APVAPPEND "first:set"
 setenv APVPREPEND "first:set"
 append_env APVAPPEND "second:set"
 prepend_env APVPREPEND "second:set"
 echo "--- END csh environment setting ---"


SEE ALSO

apvsys-intro(1) ap-environment(1) apv(1) apv-linktool(1) apv-regtool(1) apv-setdefault(1) apv-osmirror(1) apv-nativeoscheck(1) apv-dbcheck(1) apv-lib(1) apv-xcheck(1)