loadversion.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "loadversion.h"
#include "with_module.h"
#include "setgetSCIpath.h"
#include "MALLOC.h"

Include dependency graph for loadversion.c:

Go to the source code of this file.

Defines

#define FORMATFILENAMEVERSION   "%s/modules/%s/VERSION"
#define SCI_VERSION_MAJOR_keyword   "SCI_VERSION_MAJOR"
#define SCI_VERSION_MINOR_keyword   "SCI_VERSION_MINOR"
#define SCI_VERSION_MAINTENANCE_keyword   "SCI_VERSION_MAINTENANCE"
#define SCI_VERSION_STRING_keyword   "SCI_VERSION_STRING"
#define SCI_VERSION_REVISION_keyword   "SCI_VERSION_REVISION"
#define LineMaxSize   1024

Functions

BOOL FileExist (char *filename)
BOOL getversionmodule (char *modulename, int *sci_version_major, int *sci_version_minor, int *sci_version_maintenance, char *sci_version_string, int *sci_version_revision)


Define Documentation

#define FORMATFILENAMEVERSION   "%s/modules/%s/VERSION"

Definition at line 13 of file loadversion.c.

Referenced by getversionmodule().

#define LineMaxSize   1024

#define SCI_VERSION_MAINTENANCE_keyword   "SCI_VERSION_MAINTENANCE"

Definition at line 16 of file loadversion.c.

Referenced by getversionmodule().

#define SCI_VERSION_MAJOR_keyword   "SCI_VERSION_MAJOR"

Definition at line 14 of file loadversion.c.

Referenced by getversionmodule().

#define SCI_VERSION_MINOR_keyword   "SCI_VERSION_MINOR"

Definition at line 15 of file loadversion.c.

Referenced by getversionmodule().

#define SCI_VERSION_REVISION_keyword   "SCI_VERSION_REVISION"

Definition at line 18 of file loadversion.c.

Referenced by getversionmodule().

#define SCI_VERSION_STRING_keyword   "SCI_VERSION_STRING"

Definition at line 17 of file loadversion.c.

Referenced by getversionmodule().


Function Documentation

BOOL FileExist ( char *  filename  ) 

Definition at line 12 of file FileExist.c.

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 }

BOOL getversionmodule ( char *  modulename,
int sci_version_major,
int sci_version_minor,
int sci_version_maintenance,
char *  sci_version_string,
int sci_version_revision 
)

Definition at line 22 of file loadversion.c.

References FALSE, FileExist(), FORMATFILENAMEVERSION, FREE, getSCIpath(), j, len, LineMaxSize, MALLOC, NULL, retval(), SCI_VERSION_MAINTENANCE_keyword, SCI_VERSION_MAJOR_keyword, SCI_VERSION_MINOR_keyword, SCI_VERSION_REVISION_keyword, SCI_VERSION_STRING_keyword, TRUE, and with_module().

Referenced by getversion_one_rhs(), and getversion_two_rhs().

00028 {
00029         BOOL bOK=FALSE;
00030 
00031 
00032         if (with_module(modulename))
00033         {
00034                 char *filename_VERSION_module=NULL;
00035                 char *SciPath=NULL;
00036                 int len=0;
00037 
00038                 SciPath=getSCIpath();
00039                 len=strlen(FORMATFILENAMEVERSION)+strlen(SciPath)+strlen(modulename)+1;
00040                 filename_VERSION_module=(char*)MALLOC(sizeof(char)*len);
00041                 sprintf(filename_VERSION_module,FORMATFILENAMEVERSION,SciPath,modulename);
00042 
00043                 if (FileExist(filename_VERSION_module))
00044                 {
00045                         #define LineMaxSize 1024
00046                         char Line[LineMaxSize];
00047                         FILE *pFile;
00048 
00049                         pFile=fopen(filename_VERSION_module,"rt");
00050                         while (fgets(Line, LineMaxSize,pFile))
00051                         {
00052                                 int retval=0;
00053                                 char SCI_VERSION_TYPE[32];
00054 
00055                                 retval=sscanf(Line,"%s",SCI_VERSION_TYPE);
00056 
00057                                 if ( strcmp(SCI_VERSION_TYPE,SCI_VERSION_MAJOR_keyword) == 0 )
00058                                 {
00059                                         retval=sscanf(Line,"%s %d",SCI_VERSION_TYPE,sci_version_major);
00060                                 }
00061                                 else if ( strcmp(SCI_VERSION_TYPE,SCI_VERSION_MINOR_keyword) == 0 )
00062                                 {
00063                                         retval=sscanf(Line,"%s %d",SCI_VERSION_TYPE,sci_version_minor);
00064                                 }
00065                                 else if ( strcmp(SCI_VERSION_TYPE,SCI_VERSION_MAINTENANCE_keyword) == 0 )
00066                                 {
00067                                         retval=sscanf(Line,"%s %d",SCI_VERSION_TYPE,sci_version_maintenance);
00068                                 }
00069                                 else if ( strcmp(SCI_VERSION_TYPE,SCI_VERSION_STRING_keyword) == 0 )
00070                                 {
00071                                         int j=0;
00072                                         strncpy(sci_version_string,&Line[strlen(SCI_VERSION_STRING_keyword)],LineMaxSize);
00073                                         for (j=strlen(sci_version_string);j>0;j--)
00074                                         {
00075                                                 if (sci_version_string[j] == '\n')
00076                                                 {
00077                                                         sci_version_string[j]='\0';
00078                                                         break;
00079                                                 }
00080                                         }
00081                                 }
00082                                 else if ( strcmp(SCI_VERSION_TYPE,SCI_VERSION_REVISION_keyword) == 0 )
00083                                 {
00084                                         retval=sscanf(Line,"%s %d",SCI_VERSION_TYPE,sci_version_revision);
00085                                 }
00086                         }
00087                         fclose(pFile);
00088                         bOK=TRUE;
00089                 }
00090                 if (SciPath){FREE(SciPath);SciPath=NULL;}
00091                 if (filename_VERSION_module) {FREE(filename_VERSION_module);filename_VERSION_module=NULL;}
00092         }
00093         return bOK;
00094 }

Here is the call graph for this function:

Here is the caller graph for this function:


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