~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/tclsci/sci_gateway/c/sci_TCL_GetVersion.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3
3
 * Copyright (C) 2005 - INRIA - Allan CORNET
4
 
 * 
 
4
 *
5
5
 * This file must be used under the terms of the CeCILL.
6
6
 * This source file is licensed as described in the file COPYING, which
7
7
 * you should have received as part of this distribution.  The terms
8
 
 * are also available at    
 
8
 * are also available at
9
9
 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10
10
 *
11
11
 */
15
15
#include "Scierror.h"
16
16
#include "localization.h"
17
17
#if _MSC_VER
18
 
  #include "strdup_windows.h"
 
18
#include "strdup_windows.h"
19
19
#endif
20
20
/*--------------------------------------------------------------------------*/
21
 
int sci_TCL_GetVersion(char *fname,unsigned long l)
 
21
int sci_TCL_GetVersion(char *fname, unsigned long l)
22
22
{
23
 
        static int l1,n1,m1;
24
 
        int major=0;
25
 
        int minor=0;
26
 
        int patchLevel=0;
27
 
        int type=0;
28
 
        char *output=NULL ;
29
 
        char VersionString[256];
30
 
        char ReleaseType[256];
31
 
 
32
 
        CheckRhs(0,1);
33
 
        CheckLhs(1,1);
34
 
 
35
 
        Tcl_GetVersion(&major, &minor, &patchLevel, &type);
36
 
 
37
 
        if (Rhs == 0)
38
 
        {
39
 
                switch (type)
40
 
                {
41
 
                        case TCL_ALPHA_RELEASE:
42
 
                                strcpy(ReleaseType,_("Alpha Release"));
43
 
                                break;
44
 
                        case TCL_BETA_RELEASE:
45
 
                                strcpy(ReleaseType,_("Beta Release"));
46
 
                                break;
47
 
                        case TCL_FINAL_RELEASE:
48
 
                                strcpy(ReleaseType,_("Final Release"));
49
 
                                break;
50
 
                        default:
51
 
                                strcpy(ReleaseType,_("Unknown Release"));
52
 
                                break;
53
 
                }
54
 
 
55
 
                sprintf(VersionString,"TCL/TK %d.%d.%d %s",major,minor,patchLevel,ReleaseType);
56
 
                output=strdup(VersionString);
57
 
                n1=1;
58
 
                CreateVarFromPtr(Rhs+ 1,STRING_DATATYPE,(m1=(int)strlen(output), &m1),&n1,&output);
59
 
                if (output) {FREE(output);output=NULL;}
60
 
 
61
 
                LhsVar(1) = Rhs+1;
62
 
                PutLhsVar();
63
 
        }
64
 
        else
65
 
        {
66
 
                if (GetType(1) == sci_strings)
67
 
                {
68
 
                        char *Param=NULL;
69
 
 
70
 
                        GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
71
 
                        Param=cstk(l1);
72
 
 
73
 
                        if (strcmp(Param,"numbers") == 0)
74
 
                        {
75
 
                                int *VERSIONMATRIX=NULL;
76
 
                                VERSIONMATRIX=(int *)MALLOC( (4)*sizeof(int) );
77
 
 
78
 
                                VERSIONMATRIX[0]=(int)major;
79
 
                                VERSIONMATRIX[1]=(int)minor;
80
 
                                VERSIONMATRIX[2]=(int)patchLevel;
81
 
                                VERSIONMATRIX[3]=(int)type;
82
 
 
83
 
                                m1=1;
84
 
                                n1=4;
85
 
                                CreateVarFromPtr(Rhs+1,MATRIX_OF_INTEGER_DATATYPE, &m1, &n1 ,&VERSIONMATRIX);
86
 
                if (VERSIONMATRIX){     FREE(VERSIONMATRIX); VERSIONMATRIX=NULL;}
87
 
                                LhsVar(1)=Rhs+1;
88
 
                                PutLhsVar();
89
 
                                
90
 
                        }
91
 
                        else
92
 
                        {
93
 
                                Scierror(999,_("%s: Wrong value for input argument #%d: '%s' expected.\n"),fname, 1, "numbers");
94
 
                        }
95
 
                }
96
 
                else
97
 
                {
98
 
                        Scierror(999,_("%s: Wrong type for input argument #%d: String expected.\n"),fname, 1);
99
 
                }
100
 
 
101
 
        }
102
 
        return 0;
 
23
    static int l1, n1, m1;
 
24
    int major = 0;
 
25
    int minor = 0;
 
26
    int patchLevel = 0;
 
27
    int type = 0;
 
28
    char *output = NULL ;
 
29
    char VersionString[256];
 
30
    char ReleaseType[256];
 
31
 
 
32
    CheckRhs(0, 1);
 
33
    CheckLhs(1, 1);
 
34
 
 
35
    Tcl_GetVersion(&major, &minor, &patchLevel, &type);
 
36
 
 
37
    if (Rhs == 0)
 
38
    {
 
39
        switch (type)
 
40
        {
 
41
            case TCL_ALPHA_RELEASE:
 
42
                strcpy(ReleaseType, _("Alpha Release"));
 
43
                break;
 
44
            case TCL_BETA_RELEASE:
 
45
                strcpy(ReleaseType, _("Beta Release"));
 
46
                break;
 
47
            case TCL_FINAL_RELEASE:
 
48
                strcpy(ReleaseType, _("Final Release"));
 
49
                break;
 
50
            default:
 
51
                strcpy(ReleaseType, _("Unknown Release"));
 
52
                break;
 
53
        }
 
54
 
 
55
        sprintf(VersionString, "TCL/TK %d.%d.%d %s", major, minor, patchLevel, ReleaseType);
 
56
        output = strdup(VersionString);
 
57
        n1 = 1;
 
58
        m1 = (int)strlen(output);
 
59
        CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, &m1, &n1, &output);
 
60
        if (output)
 
61
        {
 
62
            FREE(output);
 
63
            output = NULL;
 
64
        }
 
65
 
 
66
        LhsVar(1) = Rhs + 1;
 
67
        PutLhsVar();
 
68
    }
 
69
    else
 
70
    {
 
71
        if (GetType(1) == sci_strings)
 
72
        {
 
73
            char *Param = NULL;
 
74
 
 
75
            GetRhsVar(1, STRING_DATATYPE, &m1, &n1, &l1);
 
76
            Param = cstk(l1);
 
77
 
 
78
            if (strcmp(Param, "numbers") == 0)
 
79
            {
 
80
                int *VERSIONMATRIX = NULL;
 
81
                VERSIONMATRIX = (int *)MALLOC( (4) * sizeof(int) );
 
82
 
 
83
                VERSIONMATRIX[0] = (int)major;
 
84
                VERSIONMATRIX[1] = (int)minor;
 
85
                VERSIONMATRIX[2] = (int)patchLevel;
 
86
                VERSIONMATRIX[3] = (int)type;
 
87
 
 
88
                m1 = 1;
 
89
                n1 = 4;
 
90
                CreateVarFromPtr(Rhs + 1, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1 , &VERSIONMATRIX);
 
91
                if (VERSIONMATRIX)
 
92
                {
 
93
                    FREE(VERSIONMATRIX);
 
94
                    VERSIONMATRIX = NULL;
 
95
                }
 
96
                LhsVar(1) = Rhs + 1;
 
97
                PutLhsVar();
 
98
 
 
99
            }
 
100
            else
 
101
            {
 
102
                Scierror(999, _("%s: Wrong value for input argument #%d: '%s' expected.\n"), fname, 1, "numbers");
 
103
            }
 
104
        }
 
105
        else
 
106
        {
 
107
            Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
 
108
        }
 
109
 
 
110
    }
 
111
    return 0;
103
112
}
104
113
/*--------------------------------------------------------------------------*/