/[ascend]/trunk/tcltk98/generic/interface/Driver.c
ViewVC logotype

Diff of /trunk/tcltk98/generic/interface/Driver.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 551 by johnpye, Tue Apr 25 23:57:49 2006 UTC revision 552 by johnpye, Sat Apr 29 08:53:04 2006 UTC
# Line 49  Line 49 
49  # undef WIN32_LEAN_AND_MEAN  # undef WIN32_LEAN_AND_MEAN
50  #endif /* __WIN32__ */  #endif /* __WIN32__ */
51    
52    #include <utilities/config.h>
53  #include <utilities/ascMalloc.h>    /* for ascshutdown */  #include <utilities/ascMalloc.h>    /* for ascshutdown */
54  #include <utilities/ascPanic.h>     /* for Asc_Panic */  #include <utilities/ascPanic.h>     /* for Asc_Panic */
55  #include <utilities/ascEnvVar.h>  #include <utilities/ascEnvVar.h>
# Line 81  Line 82 
82  static CONST char DriverID[] = "$Id: Driver.c,v 1.48 2003/08/23 18:43:06 ballan Exp $";  static CONST char DriverID[] = "$Id: Driver.c,v 1.48 2003/08/23 18:43:06 ballan Exp $";
83  #endif  #endif
84    
   
 /*  
  *  The following are the environment variables ASCEND requires.  
  *  If the user does not have the DIST_ENVIRONVAR set in his or her  
  *  environment, a default value is set based on the directory where the  
  *  ascend binary lives.  The other environment variables will be set  
  *  to default values keyed off of DIST_ENVIRONVAR.  See the function  
  *  CheckEnvironmentVars later in this file for the details.  
  */  
 #define DIST_ENVIRONVAR   "ASCENDDIST"  
 #define ASCTK_ENVIRONVAR  "ASCENDTK"  
 #define BITMAP_ENVIRONVAR "ASCENDBITMAPS"  
 #define LIBR_ENVIRONVAR   "ASCENDLIBRARY"  
   
85  /*  /*
86   *  EXPORTED VARIABLES   *  EXPORTED VARIABLES
87   */   */
# Line 500  int AscDriver(int argc, CONST char *argv Line 487  int AscDriver(int argc, CONST char *argv
487   *   *
488   *    CPP_MACRO            ENVIRONMENT VAR    DEFAULT VALUE   *    CPP_MACRO            ENVIRONMENT VAR    DEFAULT VALUE
489   *    =================    ===============    =============   *    =================    ===============    =============
490   *    DIST_ENVIRONVAR      ASCENDDIST         parent of binary's directory   *    DIST_ENVIRONVAR      ASCENDDIST         /usr/share/ascend
491   * AWW20041208:   ASCTK_ENVIRONVAR     ASCENDTK           ASCENDDIST/TK   *    ASCTK_ENVIRONVAR     ASCENDTK           $ASCENDDIST/tcltk
492   *    ASCTK_ENVIRONVAR     ASCENDTK           ASCENDDIST/TK   *    BITMAP_ENVIRONVAR    ASCENDBITMAPS      $ASCENDDIST/tcltk/bitmaps
493   *    BITMAP_ENVIRONVAR    ASCENDBITMAPS      ASCENDTK/bitmaps   *    LIBR_ENVIRONVAR      ASCENDLIBRARY      .:$ASCENDDIST/models
  *    LIBR_ENVIRONVAR      ASCENDLIBRARY  
  * AWW20041209: .:ASCENDDIST/models/libraries:ASCENDDIST/models/examples  
  *       .:ASCENDDIST/../../models  
494   *   *
495   */   */
496  static int AscCheckEnvironVars(Tcl_Interp *interp)  static int AscCheckEnvironVars(Tcl_Interp *interp)
# Line 534  static int AscCheckEnvironVars(Tcl_Inter Line 518  static int AscCheckEnvironVars(Tcl_Inter
518     *  /foo/bar/bin/ascend4, set ASCENDDIST to /foo/bar     *  /foo/bar/bin/ascend4, set ASCENDDIST to /foo/bar
519     *  If Tcl doesn't know where we are---the Tcl command     *  If Tcl doesn't know where we are---the Tcl command
520     *  `info nameofexecutable' returns ""---then ASCENDDIST is set     *  `info nameofexecutable' returns ""---then ASCENDDIST is set
521    
522        /home/john/ascroot/bin/ascend4
523        /home/john/ascroot/share/ascend/
524        
525     *  to "."     *  to "."
526     */     */
527    if( Asc_ImportPathList(DIST_ENVIRONVAR) == 0 ) {    if( Asc_ImportPathList(DIST_ENVIRONVAR) == 0 ) {
# Line 549  static int AscCheckEnvironVars(Tcl_Inter Line 537  static int AscCheckEnvironVars(Tcl_Inter
537        "file nativename [file dirname [file dirname [info nameofexecutable]]]";        "file nativename [file dirname [file dirname [info nameofexecutable]]]";
538      if( Tcl_Eval(interp, cmd) == TCL_OK ) {      if( Tcl_Eval(interp, cmd) == TCL_OK ) {
539        Tcl_DStringGetResult(interp, &ascenddist);        Tcl_DStringGetResult(interp, &ascenddist);
540          Tcl_DStringAppend(&ascenddist, "/share/ascend", -1);
541        if(Asc_SetPathList(DIST_ENVIRONVAR,Tcl_DStringValue(&ascenddist)) != 0) {        if(Asc_SetPathList(DIST_ENVIRONVAR,Tcl_DStringValue(&ascenddist)) != 0) {
542          Asc_Panic(2, "AscCheckEnvironVars",          Asc_Panic(2, "AscCheckEnvironVars",
543                    "Asc_SetPathList() returned Nonzero: "                    "Asc_SetPathList() returned Nonzero: "
# Line 581  static int AscCheckEnvironVars(Tcl_Inter Line 570  static int AscCheckEnvironVars(Tcl_Inter
570                  "Not enough memory to extend the environment");                  "Not enough memory to extend the environment");
571      }      }
572    
573      /*AWW20041209:  Add ``$ASCENDDIST/models'' to the ASCENDLIBRARY envar */      /* Add ``$ASCENDDIST/models'' to the ASCENDLIBRARY envar */
     /* Add ``$ASCENDDIST/../../models'' to the ASCENDLIBRARY envar */  
     Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);  
     Tcl_DStringAppend(&buffer2, "/models", -1);  
     /* Tcl_DStringAppend(&buffer2, "/../../models", -1); AWW */  
     if( NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),  
                                        &buffer1))) {  
       if(Asc_AppendPath(LIBR_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {  
         Asc_Panic(2, "AscCheckEnvironVars",  
                   "Asc_AppendPath() returned Nonzero: "  
                   "Not enough memory to extend the environment");  
       }  
       Tcl_DStringFree(&buffer1);  
     }  
     Tcl_DStringFree(&buffer2);  
574    
     /*  Add ``$ASCENDDIST/models/examples'' to the ASCENDLIBRARY envar */  
     /*AWW20041209 - remove all this:  
575      Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);      Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);
576      Tcl_DStringAppend(&buffer2, "/models/examples", -1);      Tcl_DStringAppend(&buffer2, "/models", -1);
     if( NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),  
                                        &buffer1))) {  
       if(Asc_AppendPath(LIBR_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {  
         Asc_Panic(2, "AscCheckEnvironVars",  
                   "Asc_AppendPath() returned Nonzero: "  
                   "Not enough memory to extend the environment");  
       }  
       Tcl_DStringFree(&buffer1);  
     }  
     Tcl_DStringFree(&buffer2);  
     */  
     /*  Add ``$ASCENDDIST/models/libraries'' to the ASCENDLIBRARY envar */  
     /*    Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);  
     Tcl_DStringAppend(&buffer2, "/models/libraries", -1);  
577      if( NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),      if( NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),
578                                         &buffer1))) {                                         &buffer1))) {
579        if(Asc_AppendPath(LIBR_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {        if(Asc_AppendPath(LIBR_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {
# Line 626  static int AscCheckEnvironVars(Tcl_Inter Line 585  static int AscCheckEnvironVars(Tcl_Inter
585      }      }
586      Tcl_DStringFree(&buffer2);      Tcl_DStringFree(&buffer2);
587    
     up to here */  
   
588      /*  Get the full value of the environment variable and set      /*  Get the full value of the environment variable and set
589       *  $env(ASCENDLIBRARY) in the Tcl code       *  $env(ASCENDLIBRARY) in the Tcl code
590       */       */
# Line 643  static int AscCheckEnvironVars(Tcl_Inter Line 600  static int AscCheckEnvironVars(Tcl_Inter
600    
601    /*    /*
602     *  If the user's environment does not have ASCENDTK set, then set it     *  If the user's environment does not have ASCENDTK set, then set it
603     *  by appending `TK' to ASCENDDIST.  Later in this function, we check     *  by appending 'tcltk' to ASCENDDIST.  Later in this function, we check
604     *  to make sure it is a valid directory by checking for the existence     *  to make sure it is a valid directory by checking for the existence
605     *  of `AscendRC' in that directory.     *  of `AscendRC' in that directory.
606     */     */
# Line 660  static int AscCheckEnvironVars(Tcl_Inter Line 617  static int AscCheckEnvironVars(Tcl_Inter
617      ascfree(tmpenv);      ascfree(tmpenv);
618    } else {    } else {
619      Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);      Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);
620      /* AWW20041208:    Tcl_DStringAppend(&buffer2, "/TK", -1);      /* AWW20041208:    Tcl_DStringAppend(&buffer2, "/tcltk", -1);
621       */       */
622      Tcl_DStringAppend(&buffer2, "/TK", -1);      Tcl_DStringAppend(&buffer2, "/tcltk", -1);
623      if(NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),      if(NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),
624                                        &buffer1))) {                                        &buffer1))) {
625        if( Asc_SetPathList(ASCTK_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {        if( Asc_SetPathList(ASCTK_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {
# Line 693  static int AscCheckEnvironVars(Tcl_Inter Line 650  static int AscCheckEnvironVars(Tcl_Inter
650                 TCL_GLOBAL_ONLY);                 TCL_GLOBAL_ONLY);
651    } else {    } else {
652      Asc_Panic(2, "AscCheckEnvironVars",      Asc_Panic(2, "AscCheckEnvironVars",
653                "ERROR: Cannot find the file \"%s\" in the subdirectory \"TK\"\n"                "ERROR: Cannot find the file \"%s\" in the subdirectory \"tcltk\"\n"
654                "under the directory \"%s\"\n"                "under the directory \"%s\"\n"
655                "Please check the value of the environment variables %s and\n"                "Please check the value of the environment variables %s and\n"
656                "and %s and start ASCEND again.\n",                "and %s and start ASCEND again.\n",
# Line 717  static int AscCheckEnvironVars(Tcl_Inter Line 674  static int AscCheckEnvironVars(Tcl_Inter
674      ascfree(tmpenv);      ascfree(tmpenv);
675    } else {    } else {
676      Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);      Tcl_DStringAppend(&buffer2, Tcl_DStringValue(&ascenddist), -1);
677      Tcl_DStringAppend(&buffer2, "/TK/bitmaps", -1);      Tcl_DStringAppend(&buffer2, "/tcltk/bitmaps", -1);
678      if(NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),      if(NULL != (Tcl_TranslateFileName(interp, Tcl_DStringValue(&buffer2),
679                                        &buffer1))) {                                        &buffer1))) {
680        if(Asc_SetPathList(BITMAP_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {        if(Asc_SetPathList(BITMAP_ENVIRONVAR, Tcl_DStringValue(&buffer1)) != 0) {

Legend:
Removed from v.551  
changed lines
  Added in v.552

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22