EnvTclTk.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------------*/
00002 /* INRIA 2006 */
00003 /* Allan CORNET */
00004 /*-----------------------------------------------------------------------------------*/ 
00005 #ifdef _MSC_VER
00006 #include <windows.h>
00007 #else
00008 #define MAX_PATH 512
00009 #include "machine.h"
00010 #endif
00011 
00012 #include <stdio.h>
00013 #include "Errors.h"
00014 #include "tcl.h"
00015 #include "tk.h"
00016 #include "MALLOC.h"
00017 /*-----------------------------------------------------------------------------------*/
00018 extern BOOL ConvertPathUnixToWindowsFormat(char *pathunix,char *pathwindows);
00019 /*-----------------------------------------------------------------------------------*/
00020 BOOL Set_TCL_LIBRARY_PATH(char *DefaultPath)
00021 {
00022         BOOL bOK=FALSE;
00023         
00024         int major=8;
00025         int minor=4; // Par defaut
00026         int patchLevel=0;
00027         int type=0;
00028         
00029         char env[MAX_PATH + 1 + 10];
00030         
00031         char ShortPath[MAX_PATH+1];
00032         char *CopyOfDefaultPath=NULL;
00033 
00034         CopyOfDefaultPath=MALLOC(((int)strlen(DefaultPath)+1)*sizeof(char));
00035 
00036         
00037         Tcl_GetVersion(&major, &minor, &patchLevel, &type);
00038 
00039         /* to be sure that it's windows format */
00040         /* c:\progra~1\scilab-5.0\modules\tclsci\tcl\tcl8.4 */
00041         if (GetShortPathName(DefaultPath,ShortPath,MAX_PATH)==0)
00042         {
00043                 fprintf(stderr,"\n%s\n%s%s.\n",TCL_ERROR35,TCL_ERROR37,DefaultPath);
00044                 if (CopyOfDefaultPath) {FREE(CopyOfDefaultPath);CopyOfDefaultPath=NULL;}
00045 
00046                 ConvertPathUnixToWindowsFormat(ShortPath,CopyOfDefaultPath);
00047                 wsprintf (env, "TCL_LIBRARY=%s\\modules\\tclsci\\tcl\\tcl%d.%d",CopyOfDefaultPath,major,minor);
00048 
00049                 if (CopyOfDefaultPath) {FREE(CopyOfDefaultPath);CopyOfDefaultPath=NULL;}
00050         }
00051         else
00052         {
00053                 ConvertPathUnixToWindowsFormat(ShortPath,CopyOfDefaultPath);
00054                 wsprintf (env, "TCL_LIBRARY=%s\\modules\\tclsci\\tcl\\tcl%d.%d",CopyOfDefaultPath,major,minor);
00055                 
00056                 if (CopyOfDefaultPath) {FREE(CopyOfDefaultPath);CopyOfDefaultPath=NULL;}
00057         }
00058 
00059         if (_putenv (env))
00060         {
00061                 bOK=FALSE;
00062         }
00063         else
00064         {
00065                 bOK=TRUE;
00066         }
00067 
00068         return bOK;
00069 }
00070 /*-----------------------------------------------------------------------------------*/
00071 BOOL Set_TK_LIBRARY_PATH(char *DefaultPath)
00072 {
00073         BOOL bOK=FALSE;
00074         char env[MAX_PATH + 1 + 10];
00075         char ShortPath[MAX_PATH+1];
00076         char *CopyOfDefaultPath=NULL;
00077 
00078         int major=8;
00079         int minor=4; // Par defaut
00080         int patchLevel=0;
00081         int type=0;
00082 
00083         CopyOfDefaultPath=MALLOC(((int)strlen(DefaultPath)+1)*sizeof(char));
00084 
00085         Tcl_GetVersion(&major, &minor, &patchLevel, &type);
00086 
00087         /* to be sure that it's windows format */
00088         /* c:\progra~1\scilab-3.1\modules\tclsci\tcl\tk8.4 */
00089         if (GetShortPathName(DefaultPath,ShortPath,MAX_PATH)==0)
00090         {
00091                 fprintf(stderr,"\n%s\n%s%s.\n",TCL_ERROR36,TCL_ERROR38,DefaultPath);
00092                 if (CopyOfDefaultPath) {FREE(CopyOfDefaultPath);CopyOfDefaultPath=NULL;}
00093 
00094                 ConvertPathUnixToWindowsFormat(ShortPath,CopyOfDefaultPath);
00095                 wsprintf (env, "TK_LIBRARY=%s\\modules\\tclsci\\tcl\\tk%d.%d",CopyOfDefaultPath,major,minor);
00096 
00097                 if (CopyOfDefaultPath) {FREE(CopyOfDefaultPath);CopyOfDefaultPath=NULL;}
00098                 
00099         }
00100         else
00101         {
00102                 ConvertPathUnixToWindowsFormat(ShortPath,CopyOfDefaultPath);
00103                 wsprintf (env, "TK_LIBRARY=%s\\modules\\tclsci\\tcl\\tk%d.%d",CopyOfDefaultPath,major,minor);
00104 
00105                 if (CopyOfDefaultPath) {FREE(CopyOfDefaultPath);CopyOfDefaultPath=NULL;}
00106         }
00107 
00108         if (_putenv (env))
00109         {
00110                 bOK=FALSE;
00111         }
00112         else
00113         {
00114                 bOK=TRUE;
00115         }
00116 
00117         return bOK;
00118 }
00119 /*-----------------------------------------------------------------------------------*/

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