env.c

Go to the documentation of this file.
00001 /* Copyright ENPC/Chancelier Jean-Philippe */
00002 
00003 /********************************
00004  * Set up environment variables if 
00005  * necessary for WIN32 
00006  ********************************/
00007 
00008 #include <windows.h>
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011 
00012 #if (defined _MSC_VER) 
00013 #undef putenv
00014 #define putenv(x) _putenv(x)
00015 #endif
00016 
00017 void SciEnv ()
00018 {
00019   char *p,*p1;
00020   char modname[MAX_PATH+1];
00021   char env[MAX_PATH+1+10];
00022   if (!GetModuleFileName (NULL, modname+1, MAX_PATH))
00023     return;
00024   if ((p = strrchr (modname+1, '\\')) == NULL)
00025     return;
00026   *p = 0;
00027 
00028   /* Set SCI variable */
00029   if ((p = strrchr (modname+1, '\\')))
00030     {
00031       *p = 0;
00032       for (p = modname+1; *p; p++)
00033         {
00034           if (*p == '\\') *p = '/';
00035         }
00036     p = modname + 1;
00037     if ( ( p1 = getenv("SCI"))  == (char *) 0 )
00038         {
00039                 sprintf(env,"SCI=%s",p);
00040                 #ifdef _MSC_VER
00041                         _putenv(env);
00042                 #else
00043                         putenv(env);
00044                 #endif
00045         }
00046   }
00047 }
00048 
00049 
00050 

Generated on Sun Mar 4 15:04:01 2007 for Scilab [trunk] by  doxygen 1.5.1