getenvc.c

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------------*/
00002 /* INRIA 2006 */
00003 /* Scilab */
00004 /*-----------------------------------------------------------------------------------*/ 
00005 #ifdef _MSC_VER
00006         #include <Windows.h> /* GetEnvironmentVariable */
00007 #else
00008         #include <stdlib.h> /* getenv */
00009 #endif
00010 #include <string.h> /* strlen */
00011 #include "getenvc.h"
00012 /*-----------------------------------------------------------------------------------*/
00013 void C2F(getenvc)(int *ierr,char *var,char *buf,int *buflen,int *iflag)
00014 {
00015         #ifdef _MSC_VER
00016         if (GetEnvironmentVariable(var,buf,(DWORD)buflen)==0)
00017         {
00018                 if ( *iflag == 1 ) sciprint("You must define the environment variable %s\r\n",var);
00019                 *ierr=1;
00020         }
00021         else
00022         {
00023                 *buflen = strlen(buf);
00024                 *ierr=0;
00025         }
00026         #else
00027         char *local;
00028         if ( (local=getenv(var)) == 0)
00029         {
00030                 if ( *iflag == 1 ) sciprint("You must define the environment variable %s\r\n",var);
00031                 *ierr=1;
00032         }
00033         else 
00034         {
00035                 strncpy(buf,local,*buflen);
00036                 *buflen = strlen(buf);
00037                 *ierr=0;
00038         }
00039         #endif
00040 }
00041 /*-----------------------------------------------------------------------------------*/
00042 

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