#include <stdio.h>#include <stdlib.h>#include "getmodules.h"#include "machine.h"#include "MALLOC.h"#include "setgetSCIpath.h"#include "string.h"#include "sciprint.h"Include dependency graph for getmodules.c:

Go to the source code of this file.
Defines | |
| #define | basenamemodulesfile "modules/modules" |
| #define | LineMaxSize 1024 |
| #define | LineMaxSize 1024 |
Functions | |
| BOOL | FileExist (char *filename) |
| static BOOL | AddModules (void) |
| static BOOL | ReadModulesFile (void) |
| static int | GetNumberOfLinesInFile (char *filename) |
| static BOOL | AppendModules (char *filename) |
| static void | cleaningLine (char *source) |
| static BOOL | VerifyModule (char *ModuleName) |
| MODULESLIST * | getmodules (void) |
| BOOL | DisposeModulesInfo (void) |
Variables | |
| static struct MODULESLIST * | ScilabModules = NULL |
| #define basenamemodulesfile "modules/modules" |
| #define LineMaxSize 1024 |
| #define LineMaxSize 1024 |
| static BOOL AddModules | ( | void | ) | [static] |
| static BOOL AppendModules | ( | char * | filename | ) | [static] |
Definition at line 125 of file getmodules.c.
References FALSE, i, LineMaxSize, MALLOC, MODULESLIST::ModuleList, ScilabModules, sciprint(), and VerifyModule().
Referenced by ReadModulesFile().
00126 { 00127 #define LineMaxSize 1024 00128 BOOL bOK=FALSE; 00129 char Line[LineMaxSize]; 00130 int i=0; 00131 FILE *pFile; 00132 00133 pFile=fopen(filename,"rt"); 00134 while (fgets(Line, LineMaxSize,pFile)) 00135 { 00136 if ( VerifyModule(Line) ) 00137 { 00138 ScilabModules->ModuleList[i]=(char*)MALLOC(sizeof(char)*(strlen(Line)+1)); 00139 sprintf(ScilabModules->ModuleList[i],"%s",Line); 00140 i++; 00141 } 00142 else 00143 { 00144 if (Line[0]!=';') /* Starts with a ; => it is a comment */ 00145 { 00146 sciprint("%s module not found.\n",Line); 00147 } 00148 } 00149 } 00150 fclose(pFile); 00151 return bOK; 00152 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void cleaningLine | ( | char * | source | ) | [static] |
Definition at line 154 of file getmodules.c.
Referenced by VerifyModule().
00155 { 00156 int i=0; 00157 for (i=0;i<(int)strlen(source);i++) 00158 { 00159 if ( (source[i]==' ') || (source[i]=='\n') || (source[i]=='\r') ) 00160 { 00161 source[i]='\0'; 00162 break; 00163 } 00164 } 00165 }
Here is the caller graph for this function:

| BOOL DisposeModulesInfo | ( | void | ) |
Definition at line 37 of file getmodules.c.
References FALSE, FREE, i, MODULESLIST::ModuleList, NULL, MODULESLIST::numberofModules, and ScilabModules.
Referenced by TerminateCorePart2().
00038 { 00039 BOOL bOK=FALSE; 00040 if (ScilabModules) 00041 { 00042 int i=0; 00043 for (i=0;i<ScilabModules->numberofModules;i++) 00044 { 00045 if (ScilabModules->ModuleList[i]) 00046 { 00047 FREE(ScilabModules->ModuleList[i]); 00048 ScilabModules->ModuleList[i]=NULL; 00049 } 00050 } 00051 if (ScilabModules->ModuleList) 00052 { 00053 FREE(ScilabModules->ModuleList); 00054 ScilabModules->ModuleList=NULL; 00055 } 00056 ScilabModules->numberofModules=0; 00057 FREE(ScilabModules); 00058 ScilabModules=NULL; 00059 00060 } 00061 00062 return bOK; 00063 }
Here is the caller graph for this function:

| BOOL FileExist | ( | char * | filename | ) |
Definition at line 12 of file FileExist.c.
Referenced by C2F(), CopyAtlas(), ExistModelicac(), GetNumberOfLinesInFile(), getversionmodule(), Load_primitives_from_file(), LoadArrayCPUFromFile(), LoadHashTablesLocalization(), ReadModulesFile(), and VerifyModule().
00013 { 00014 BOOL retour=FALSE; 00015 00016 #ifdef _MSC_VER 00017 WIN32_FIND_DATA FindFileData; 00018 HANDLE handle = FindFirstFile (filename, &FindFileData); 00019 if (handle != INVALID_HANDLE_VALUE) 00020 { 00021 FindClose (handle); 00022 retour=TRUE; 00023 } 00024 else retour=FALSE; 00025 #else 00026 FILE* tmpFile; 00027 if( (tmpFile=fopen(filename,"r")) == FALSE ) 00028 { 00029 retour=FALSE; 00030 } 00031 else 00032 { 00033 fclose(tmpFile); 00034 retour=TRUE; 00035 } 00036 #endif 00037 00038 return retour; 00039 }
Here is the caller graph for this function:

| struct MODULESLIST* getmodules | ( | void | ) |
Definition at line 27 of file getmodules.c.
References MALLOC, NULL, ReadModulesFile(), and ScilabModules.
Referenced by C2F(), InitializeCore(), LoadHashTablesLocalization(), and with_module().
00028 { 00029 if (ScilabModules==NULL) 00030 { 00031 ScilabModules=(struct MODULESLIST *)MALLOC(sizeof(struct MODULESLIST)); 00032 ReadModulesFile(); 00033 } 00034 return ScilabModules; 00035 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int GetNumberOfLinesInFile | ( | char * | filename | ) | [static] |
Definition at line 102 of file getmodules.c.
References FileExist(), LineMaxSize, and VerifyModule().
Referenced by ReadModulesFile().
00103 { 00104 #define LineMaxSize 1024 00105 int ret=0; 00106 FILE *pFile; 00107 00108 if (FileExist(filename)) 00109 { 00110 char Line[LineMaxSize]; 00111 pFile=fopen(filename,"rt"); 00112 while (fgets(Line, LineMaxSize,pFile)) 00113 { 00114 if ( VerifyModule(Line) ) 00115 { 00116 ret++; 00117 } 00118 } 00119 fclose(pFile); 00120 } 00121 00122 return ret; 00123 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static BOOL ReadModulesFile | ( | void | ) | [static] |
Definition at line 65 of file getmodules.c.
References AppendModules(), basenamemodulesfile, FALSE, FileExist(), FREE, GetNumberOfLinesInFile(), getSCIpath(), MALLOC, MODULESLIST::ModuleList, NULL, MODULESLIST::numberofModules, ScilabModules, and sciprint().
Referenced by getmodules().
00066 { 00067 BOOL bOK=FALSE; 00068 char *ModulesFilename=NULL; 00069 char *SciPath=NULL; 00070 00071 SciPath=getSCIpath(); 00072 if (SciPath==NULL) 00073 { 00074 sciprint("The SCI environment variable is not set\n"); 00075 return FALSE; 00076 } 00077 00078 ModulesFilename=(char*)MALLOC((strlen(SciPath)+strlen("/")+strlen(basenamemodulesfile)+1)*sizeof(char)); 00079 sprintf(ModulesFilename,"%s/%s",SciPath,basenamemodulesfile); 00080 FREE(SciPath); 00081 SciPath=NULL; 00082 00083 if (FileExist(ModulesFilename)) 00084 { 00085 int NumberofLines=GetNumberOfLinesInFile(ModulesFilename); 00086 ScilabModules->ModuleList=(char**)MALLOC(sizeof(char*)*NumberofLines); 00087 ScilabModules->numberofModules=NumberofLines; 00088 AppendModules(ModulesFilename); 00089 FREE(ModulesFilename); 00090 ModulesFilename=NULL; 00091 } 00092 else 00093 { 00094 sciprint("Cannot load the module declaration file : %s.\n",ModulesFilename); 00095 FREE(ModulesFilename); 00096 ModulesFilename=NULL; 00097 return FALSE; 00098 } 00099 return bOK; 00100 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static BOOL VerifyModule | ( | char * | ModuleName | ) | [static] |
Definition at line 167 of file getmodules.c.
References cleaningLine(), FALSE, FileExist(), FREE, getSCIpath(), MALLOC, NULL, sciprint(), and TRUE.
Referenced by AppendModules(), and GetNumberOfLinesInFile().
00168 { 00169 BOOL bOK=FALSE; 00170 char *SciPath=NULL; 00171 char *FullPathModuleName=NULL; 00172 00173 cleaningLine(ModuleName); 00174 00175 /* ';' is a comment into the declaration file (modules/modules) */ 00176 if (ModuleName[0]==';') return FALSE; 00177 00178 SciPath=getSCIpath(); 00179 if (SciPath==NULL) 00180 { 00181 sciprint("The SCI environment variable is not set\n"); 00182 return FALSE; 00183 } 00184 00185 FullPathModuleName=(char*)MALLOC((strlen(SciPath)+strlen("%s/modules/%s/etc/%s.start")+(strlen(ModuleName)*2)+1)*sizeof(char)); 00186 sprintf(FullPathModuleName,"%s/modules/%s/etc/%s.start",SciPath,ModuleName,ModuleName); 00187 FREE(SciPath); 00188 SciPath=NULL; 00189 00190 /* ajouter d'autres tests d'existences */ 00191 00192 if (FileExist(FullPathModuleName)) 00193 { 00194 bOK=TRUE; 00195 } 00196 FREE(FullPathModuleName); 00197 FullPathModuleName=NULL; 00198 00199 return bOK; 00200 }
Here is the call graph for this function:

Here is the caller graph for this function:

struct MODULESLIST* ScilabModules = NULL [static] |
Definition at line 18 of file getmodules.c.
Referenced by AppendModules(), DisposeModulesInfo(), getmodules(), and ReadModulesFile().
1.5.1