예제 #1
0
/*--------------------------------------------------------------------------*/
char *getModuleVersionInfoAsString(char *modulename)
{
    char *infoString = NULL;

    if (modulename)
    {
        if (strcmp(modulename, SCILAB_STRING) == 0)
        {
            infoString = getScilabVersionAsString();
            return infoString;
        }
    }

    if (with_module(modulename))
    {
#define LineMax 1024
        char versionstring[LineMax];
        int version_module_major = 0;
        int version_module_minor = 0;
        int version_module_maintenance = 0;
        int version_module_revision = 0;
        if (getversionmodule(modulename, &version_module_major, &version_module_minor,
                             &version_module_maintenance, versionstring,
                             &version_module_revision))
        {
            infoString = strdup(versionstring);
        }
    }
    return infoString;
}
예제 #2
0
/*--------------------------------------------------------------------------*/
static char *getCommandByFileExtension(char *File,char *FileExtension)
{
    char *command = NULL;

    if (FileExtension)
    {
        if ( (stricmp(FileExtension, BIN_EXTENSION_FILE) == 0) ||
            (stricmp(FileExtension, SAV_EXTENSION_FILE) == 0) ||
            (stricmp(FileExtension, SOD_EXTENSION_FILE) == 0))
        {
            command = buildCommand(FORMAT_BIN_SCE_EXTENSION_FILES, File);
        }
        else
            if ( (stricmp(FileExtension, COS_EXTENSION_FILE) == 0) ||
                (stricmp(FileExtension, COSF_EXTENSION_FILE) == 0) ||
                (stricmp(FileExtension, ZCOS_EXTENSION_FILE) == 0) ||
                (stricmp(FileExtension, XCOS_EXTENSION_FILE) == 0))
            {
                if (with_module("xcos"))
                {
                    command = buildCommand(FORMAT_COS_COSF_XCOS_EXTENSION_FILES, File);
                }
                else
                {
                    command = strdup(XCOS_NOT_INSTALLED);
                }
            }
            else
                if (stricmp(FileExtension,SCI_EXTENSION_FILE) == 0)
                {
                    command = buildCommand(FORMAT_SCI_EXTENSION_FILES, File);
                }
                else
                    if ( (stricmp(FileExtension, SCE_EXTENSION_FILE) == 0) || (stricmp(FileExtension, TST_EXTENSION_FILE) == 0) || (stricmp(FileExtension, DEM_EXTENSION_FILE) == 0) )
                    {
                        command = buildCommand(FORMAT_SCE_TST_EXTENSION_FILES, File);
                    }
                    else
                        if (stricmp(FileExtension, SCG_EXTENSION_FILE) == 0)
                        {
                            command = buildCommand(FORMAT_SCG_EXTENSION_FILES, File);
                        }
                        else
                        {
                            command = buildCommand(FORMAT_UNKNOW_EXTENSION_FILES, File);
                        }
    }
    return command;
}
예제 #3
0
/*--------------------------------------------------------------------------*/
int* getModuleVersion(char *modulename, int *sizeArrayReturned)
{
    int *returnedArray = NULL;

    if (modulename)
    {
        if (strcmp(modulename, SCILAB_STRING) == 0)
        {
            returnedArray = getScilabVersion(sizeArrayReturned);
            return returnedArray;
        }
    }

    if (with_module(modulename))
    {
#define LineMax 1024
        char versionstring[LineMax];
        int version_module_major = 0;
        int version_module_minor = 0;
        int version_module_maintenance = 0;
        int version_module_revision = 0;

        if (getversionmodule(modulename, &version_module_major, &version_module_minor,
                             &version_module_maintenance, versionstring,
                             &version_module_revision))
        {
            returnedArray = (int *)MALLOC(sizeof(int) * DEFAULT_VERSION_ARRAY_SIZE);
            if (returnedArray)
            {
                returnedArray[0] = version_module_major;
                returnedArray[1] = version_module_minor;
                returnedArray[2] = version_module_maintenance;
                returnedArray[3] = version_module_revision;
                *sizeArrayReturned = DEFAULT_VERSION_ARRAY_SIZE;
            }
            else
            {
                *sizeArrayReturned = 0;
            }
        }
    }
    else
    {
        *sizeArrayReturned = 0;
    }
    return returnedArray;
}
예제 #4
0
/*--------------------------------------------------------------------------*/
struct gateway_struct *readGateway(char *modulename)
{
    struct gateway_struct *content = NULL;

    if (modulename)
    {
        char *XmlFile = getModuleXmlFilename(modulename);
        if (XmlFile)
        {
            content = readGatewayXmlFile(XmlFile);
            FREE(XmlFile);
            XmlFile = NULL;
        }
        else
        {
            /* module exists but without gateway */
            if ( with_module(modulename) )
            {
                content = (struct gateway_struct *)MALLOC(sizeof(struct gateway_struct));
                if (content)
                {
                    content->dimLists = 0;
                    content->gatewayIdList = NULL;
                    content->primitivesList = NULL;
                    content->primiviteIdList = NULL;
                }
            }
            else /* not exist */
            {
                content = NULL;
            }
        }
    }

    return content;
}
예제 #5
0
/*--------------------------------------------------------------------------*/ 
int Console_Main(int argc, char **argv)
{
    int iExitCode = 0;
    int argcount = 0, lpath = 0;
    InitScriptType pathtype = SCILAB_SCRIPT;
    char *path = NULL;
    char *ScilabDirectory = NULL;
    int i=0;

    my_argc = -1;

    forbiddenToUseScilab();

    setScilabMode(SCILAB_NW);

    setCommandLineArgs(argv, argc);

    for (i=0;i<argc;i++)
    {
        my_argv[i] = argv[i];
    }
    my_argc = argc;

    ScilabDirectory = getScilabDirectory(FALSE);

    if (ScilabDirectory == NULL)
    {
        // This message must never occur, but ...
        MessageBox (NULL, "ERROR" , "Cannot determine the Scilab directory (SCI).", MB_ICONSTOP | MB_OK);
        exit(1);
    }
    else
    {
        FREE(ScilabDirectory);
        ScilabDirectory = NULL;
    }

    argcount = my_argc;
    while (argcount > 0)
    {
        argcount--;
        if (_stricmp (my_argv[argcount], "-NS") == 0) startupf = 1;
        else if ( _stricmp(my_argv[argcount],"-NB") == 0) { sci_show_banner = 0; }
        else if (_stricmp (my_argv[argcount], "-NWNI") == 0)
        {
            setScilabMode(SCILAB_NWNI);
        }
        else if (_stricmp (my_argv[argcount], "-F") == 0 && argcount + 1 < my_argc)
        {
            path = my_argv[argcount + 1];
            lpath = (int) strlen (my_argv[argcount + 1]);
        }
        else if (_stricmp (my_argv[argcount], "-E") == 0 && argcount + 1 < my_argc)
        {
            path = my_argv[argcount + 1];
            lpath = (int) strlen (my_argv[argcount + 1]);
            pathtype = SCILAB_CODE;
        }
        else if ( _stricmp(my_argv[argcount],"-MEM") == 0 && argcount + 1 < my_argc)
        {
            memory = Max(atoi( my_argv[argcount + 1]),MIN_STACKSIZE );
        } 
        else if ( _stricmp(my_argv[argcount],"-TEXMACS") == 0 )
        {
            setScilabMode(SCILAB_NWNI);
            settexmacs();
        }
        else if ( _stricmp(my_argv[argcount],"-NOGUI") == 0 )
        {
            setScilabMode(SCILAB_NWNI);
        }
        else if ( (_stricmp (my_argv[argcount],"-VERSION")==0) ||
            (_stricmp (my_argv[argcount],"-VER")==0) )
        {
            disp_scilab_version();
            exit(1);
        }
        else if ( _stricmp(my_argv[argcount],"-L") == 0 && argcount + 1 < my_argc)
        {
            char *language = my_argv[argcount + 1];
            setLanguageFromCommandLine(language);
        }
        else if ( (_stricmp (my_argv[argcount],"-H")==0) ||
            (_stricmp (my_argv[argcount],"-?")==0) ||
            (_stricmp (my_argv[argcount],"-HELP")==0) )
        {
            printf("scilex <Options> : run Scilab.\n");
            printf("Arguments : passes Arguments to Scilab, This Arguments can be retreived\n  by the Scilab function sciargs.\n"); 
            printf("-e Instruction : execute the scilab instruction given in Instruction argument.\n"); 
            printf("-f File : execute the scilab script given in File argument.\n"); 
            printf("  '-e' and '-f' options are mutually exclusive.\n\n"); 
            printf("-l lang : it fixes the user language.\n\n" ); 
            printf("-mem N : set the initial stacksize.\n"); 
            printf("-ns : if this option is present the startup file scilab.start is not executed.\n"); 
            printf("-nb : if this option is present then scilab welcome banner is not displayed.\n"); 
            printf("-nouserstartup : don't execute user startup files SCIHOME/.scilab or SCIHOME/scilab.ini.\n"); 
            printf("-nw : start Scilab without specialized Scilab Window.\n"); 
            printf("-nwni : start Scilab without user interaction (batch mode).\n"); 
            printf("-nogui : start Scilab without GUI,tcl/tk and user interaction (batch mode).\n"); 
            printf("-texmacs : reserved for WinTeXMacs.\n"); 
            printf("-version : print product version and exit.\n"); 
            printf("\n");
            exit(1);
        }
    }

    if (!with_module("jvm")) 
    {
        /* no module jvm then we force NWNI mode */
        setScilabMode(SCILAB_NWNI);
    }

    if (getScilabMode() != SCILAB_NWNI) CreateScilabHiddenWndThread();

    if ( (getScilabMode() == SCILAB_NWNI) || (getScilabMode() == SCILAB_NW) )
    {
        SaveConsoleColors();
        if (getScilabMode() == SCILAB_NW)
        {
            RenameConsole();
            UpdateConsoleColors();
        }

        iExitCode = sci_windows_main (&startupf, path, (InitScriptType)pathtype, &lpath,memory);

    }
    else
    {
        MessageBox(NULL,"-nw or -nwni not found","ERROR",MB_ICONWARNING);
        iExitCode = 1;
    }
    return iExitCode;
}
예제 #6
0
/*--------------------------------------------------------------------------*/
BOOL with_tk(void)
{
    return with_module(TCLSCI_MODULE_NAME) && (getScilabMode() != SCILAB_NWNI);
}
예제 #7
0
/*--------------------------------------------------------------------------*/
types::Function::ReturnValue sci_getversion(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
    if (in.size() > 2)
    {
        Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "getversion", 0, 2);
        return types::Function::Error;
    }

    if (in.size() == 0)
    {
        if (_iRetCount != 1 && _iRetCount != 2)
        {
            Scierror(78, _("%s: Wrong number of output argument(s): %d to %d expected.\n"), "getveresion", 1, 2);
            return types::Function::Error;
        }

        wchar_t *pwstVer = getScilabVersionAsWideString();
        types::String* pOut1 = new types::String(pwstVer);
        out.push_back(pOut1);
        FREE(pwstVer);

        if (_iRetCount == 2)
        {
            int iOption = 0;
            wchar_t** pwstOption = getScilabVersionOptions(&iOption);
            types::String* pOut2 = new types::String(1, iOption);
            pOut2->set(pwstOption);
            out.push_back(pOut2);
            freeArrayOfWideString(pwstOption, iOption);
        }

    }
    else if (in.size() == 1)
    {
        if (in[0]->isString() == false || in[0]->getAs<types::String>()->isScalar() == false)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), "getversion", 1);
            return types::Function::Error;
        }

        if (_iRetCount != 1)
        {
            Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "getveresion", 1);
            return types::Function::Error;
        }

        wchar_t* pwstModule = in[0]->getAs<types::String>()->get()[0];
        if (with_module(pwstModule) || (wcscmp(pwstModule, L"scilab") == 0))
        {
            int versionSize = 0;
            int *version = getModuleVersion(pwstModule, &versionSize);
            if (version == NULL)
            {
                Scierror(999, _("%s: Wrong file version.xml %s.\n"), "getversion", pwstModule);
                return types::Function::Error;
            }

            types::Double* pOut = new types::Double(1, versionSize);
            pOut->setInt(version);
            out.push_back(pOut);
            FREE(version);
        }
    }
    else //in.size() == 2
    {
        if (in[0]->isString() == false || in[0]->getAs<types::String>()->getSize() != 1)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), "getversion", 1);
            return types::Function::Error;
        }

        if (in[1]->isString() == false || in[1]->getAs<types::String>()->getSize() != 1)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), "getversion", 2);
            return types::Function::Error;
        }

        wchar_t* pwstModule = in[0]->getAs<types::String>()->get()[0];
        wchar_t* pwstOption = in[1]->getAs<types::String>()->get()[0];

        if ( with_module(pwstModule) || (wcscmp(pwstModule, L"scilab") == 0) )
        {
            if ( wcscmp(pwstOption, VERSION_STRING) == 0)
            {
                wchar_t *pwstInfo = getModuleVersionInfoAsString(pwstModule);
                types::String* pOut = new types::String(pwstInfo);
                out.push_back(pOut);
                FREE(pwstInfo);
            }
        }
    }

    return types::Function::OK;
}
예제 #8
0
/*--------------------------------------------------------------------------*/
BOOL getversionmodule(wchar_t* _pwstModule,
                      int *sci_version_major,
                      int *sci_version_minor,
                      int *sci_version_maintenance,
                      wchar_t* _pwstSciVersionString,
                      int *sci_version_revision)
{
    BOOL bOK = FALSE;

    if (with_module(_pwstModule))
    {
        char* filename_VERSION_module = NULL;
        char* pstModule = wide_string_to_UTF8(_pwstModule);
        char* SciPath = NULL;
        int len = 0;

        SciPath = getSCI();
        len = (int)strlen(FORMATVERSIONFILENAME) + (int)strlen(SciPath) + (int)strlen(pstModule) + 1;
        filename_VERSION_module = (char*)MALLOC(sizeof(char) * len);
        sprintf(filename_VERSION_module, FORMATVERSIONFILENAME, SciPath, pstModule);
        if (SciPath)
        {
            FREE(SciPath);
            SciPath = NULL;
        }

        if (FileExist(filename_VERSION_module))
        {
            char *encoding = GetXmlFileEncoding(filename_VERSION_module);

            /* Don't care about line return / empty line */
            xmlKeepBlanksDefault(0);

            /* check if the XML file has been encoded with utf8 (unicode) or not */
            if ( stricmp("utf-8", encoding) == 0)
            {
                xmlDocPtr doc = NULL;
                xmlXPathContextPtr xpathCtxt = NULL;
                xmlXPathObjectPtr xpathObj = NULL;

                int version_major = 0;
                int version_minor = 0;
                int version_maintenance = 0;
                int version_revision = 0;
                wchar_t *pwstSciVersionString = 0;

                {
                    BOOL bConvert = FALSE;
                    char *shortfilename_VERSION_module = getshortpathname(filename_VERSION_module, &bConvert);
                    if (shortfilename_VERSION_module)
                    {
                        doc = xmlParseFile (shortfilename_VERSION_module);
                        FREE(shortfilename_VERSION_module);
                        shortfilename_VERSION_module = NULL;
                    }
                }

                if (doc == NULL)
                {
                    fprintf(stderr, _("Error: Could not parse file %s\n"), filename_VERSION_module);
                    return FALSE;
                }

                xpathCtxt = xmlXPathNewContext(doc);
                xpathObj = xmlXPathEval((const xmlChar*)"//MODULE_VERSION/VERSION", xpathCtxt);

                if (xpathObj && xpathObj->nodesetval->nodeMax)
                {

                    xmlAttrPtr attrib = xpathObj->nodesetval->nodeTab[0]->properties;
                    while (attrib != NULL)
                    {
                        if (xmlStrEqual (attrib->name, (const xmlChar*) "major"))
                        {
                            /* we found <major> */
                            const char *str = (const char*)attrib->children->content;
                            version_major = atoi(str);
                        }
                        else if (xmlStrEqual (attrib->name, (const xmlChar*)"minor"))
                        {
                            /* we found <minor> */
                            const char *str = (const char*)attrib->children->content;
                            version_minor = atoi(str);
                        }
                        else if (xmlStrEqual (attrib->name, (const xmlChar*)"maintenance"))
                        {
                            /* we found <maintenance> */
                            const char *str = (const char*)attrib->children->content;
                            version_maintenance = atoi(str);
                        }
                        else if (xmlStrEqual (attrib->name, (const xmlChar*)"revision"))
                        {
                            /* we found <revision> */
                            const char *str = (const char*)attrib->children->content;
                            version_revision = atoi(str);
                        }
                        else if (xmlStrEqual (attrib->name, (const xmlChar*)"string"))
                        {
                            /* we found <string> */
                            const char *str = (const char*)attrib->children->content;
                            pwstSciVersionString = to_wide_string(str);
                        }

                        attrib = attrib->next;
                    }

                    *sci_version_major = version_major;
                    *sci_version_minor = version_minor;
                    *sci_version_maintenance = version_maintenance;
                    *sci_version_revision = version_revision;
                    wcscpy(_pwstSciVersionString, pwstSciVersionString);
                    if (pwstSciVersionString)
                    {
                        FREE(pwstSciVersionString);
                        pwstSciVersionString = NULL;
                    }
                }
                else
                {
                    fprintf(stderr, _("Error: Not a valid version file %s (should start with <MODULE_VERSION> and contain <VERSION major='' minor='' maintenance='' revision='' string=''>)\n"), filename_VERSION_module);
                    return FALSE;
                }
                if (xpathObj)
                {
                    xmlXPathFreeObject(xpathObj);
                }
                if (xpathCtxt)
                {
                    xmlXPathFreeContext(xpathCtxt);
                }
                xmlFreeDoc (doc);
            }
            else
            {
                fprintf(stderr, _("Error: Not a valid version file %s (encoding not 'utf-8') Encoding '%s' found\n"), filename_VERSION_module, encoding);
            }

            if (encoding)
            {
                FREE(encoding);
                encoding = NULL;
            }
            bOK = TRUE;
        }
        else
        {
            // version.xml does not exist but module exists then we returns scilab version
            *sci_version_major =  SCI_VERSION_MAJOR;
            *sci_version_minor = SCI_VERSION_MINOR;
            *sci_version_maintenance = SCI_VERSION_MAINTENANCE;
            *sci_version_revision = SCI_VERSION_TIMESTAMP;
            wcscpy(_pwstSciVersionString, L"");
            bOK = TRUE;
        }

        if (filename_VERSION_module)
        {
            FREE(filename_VERSION_module);
            filename_VERSION_module = NULL;
        }
    }
    return bOK;
}