void Mission::doModule( missionNode *node, int mode )
{
    if (mode == SCRIPT_PARSE) {
        string name = node->attr_value( "name" );
        if (parsemode == PARSE_DECL) {
            if ( name.empty() ) {
                fatalError( node, mode, "you have to give a module name" );
                assert( 0 );
            }
            if (runtime.modules[name] != NULL) {
                fatalError( node, mode, "there can only be one module with name "+name );
                assert( 0 );
            }
            if (name == "director")
                director = node;
            node->script.name = name;

            varInstMap *cvmap = new varInstMap;
            node->script.classvars.push_back( cvmap );
            node->script.classinst_counter = 0;
            debug( 10, node, mode, "created classinst 0" );

            runtime.modules[name] = node;             //add this module to the list of known modules
        }
        scope_stack.push_back( node );

        current_module = node;

        debug( 5, node, mode, "added module "+name+" to list of known modules" );
    }
    if (mode == SCRIPT_RUN) {
        //SCRIPT_RUN
        runtime.cur_thread->module_stack.push_back( node );
        runtime.cur_thread->classid_stack.push_back( 0 );
    }
    vector< easyDomNode* >::const_iterator siter;
    for (siter = node->subnodes.begin(); siter != node->subnodes.end(); siter++) {
        missionNode *snode = (missionNode*) *siter;
        if (snode->tag == DTAG_SCRIPT) {
            varInst *vi = doScript( snode, mode );
            deleteVarInst( vi );
        } else if (snode->tag == DTAG_DEFVAR) {
            doDefVar( snode, mode );
        } else if (snode->tag == DTAG_GLOBALS) {
            doGlobals( snode, mode );
        } else if (snode->tag == DTAG_IMPORT) {
            doImport( snode, mode );
        } else {
            fatalError( snode, mode, "unkown node type for module subnodes" );
            assert( 0 );
        }
    }
    if (mode == SCRIPT_PARSE) {
        scope_stack.pop_back();
    } else {
        runtime.cur_thread->module_stack.pop_back();
        runtime.cur_thread->classid_stack.pop_back();
    }
}
Example #2
0
void KviMircServersIniImport::start()
{
	//KviCString buffer;
	QString buffer;
	if(!KviFileDialog::askForOpenFileName(buffer,__tr("Choose a servers.ini file"),0,KVI_FILTER_INI,false,true,g_pMainWindow))return;

	doImport(buffer);
	delete this;
}
Example #3
0
KoFilter::ConversionStatus MpxjImport::convert(const QByteArray& from, const QByteArray& to)
{
    kDebug(planMpxjDbg()) << from << to;
    if ( to != "application/x-vnd.kde.plan" || ! mimeTypes().contains( from ) ) {
        kDebug(planMpxjDbg())<<"Bad mime types:"<<from<<"->"<<to;
        return KoFilter::BadMimeType;
    }
    bool batch = false;
    if ( m_chain->manager() ) {
        batch = m_chain->manager()->getBatchMode();
    }
    if (batch) {
        //TODO
        kDebug(planMpxjDbg()) << "batch mode not implemented";
        return KoFilter::NotImplemented;
    }
    KoDocument *part = m_chain->outputDocument();
    if ( ! part ) {
        kDebug(planMpxjDbg()) << "could not open document";
        return KoFilter::InternalError;
    }
    QString inputFile = m_chain->inputFile();
    kDebug(planMpxjDbg())<<"Import from:"<<inputFile;
    QTemporaryDir *tmp = new QTemporaryDir();
    QString outFile( tmp->path() + "/maindoc.xml" );
    kDebug(planMpxjDbg())<<"Temp file:"<<outFile;
    KoFilter::ConversionStatus sts = doImport( inputFile.toUtf8(), outFile.toUtf8() );
    kDebug(planMpxjDbg())<<"doImport returned:"<<(sts == KoFilter::OK);
    if ( sts == KoFilter::OK ) {
        QFile file( outFile );
        KoXmlDocument doc;
        if ( ! doc.setContent( &file ) ) {
            kDebug(planMpxjDbg()) << "could not read maindoc.xml";
            sts = KoFilter::InternalError;
        } else if ( ! part->loadXML( doc, 0 ) ) {
            kDebug(planMpxjDbg()) << "failed to load maindoc.xml";
            sts = KoFilter::InternalError;
        }
    }
    delete tmp;
    return sts;
}
Example #4
0
osg::Image* QuicktimeImportExport::readFromStream(std::istream & inStream, const std::string& fileTypeHint, long sizeHint) 
{
    char* content = NULL;
    long length = 0;
     if (sizeHint != 0) 
    {
        length = sizeHint;
        content = new char[length];
        inStream.read (content,length);
    }
    else 
    {
        int readBytes(0), newBytes(0);
        
        char buffer[10240];
        
        while (!inStream.eof()) {
            inStream.read(buffer, 10240);
            newBytes = inStream.gcount();
            if (newBytes > 0) {
                char* newcontent = new char[readBytes + newBytes];
            
                if (readBytes > 0)
                    memcpy(newcontent, content, readBytes);
                
                memcpy(&newcontent[readBytes], &buffer, newBytes);
                readBytes += newBytes;
                if (content) delete[] content;
                content = newcontent;
            }
        }
        length = readBytes;
    }
    
    osg::Image* img = doImport(reinterpret_cast<unsigned char*>(content), length, fileTypeHint);
    
    if (content) delete[] content;
    return img;
 }
Example #5
0
int rpmcliImportPubkeys(rpmts ts, ARGV_const_t argv)
{
    int res = 0;
    for (ARGV_const_t arg = argv; arg && *arg; arg++) {
	const char *fn = *arg;
	uint8_t *buf = NULL;
	ssize_t blen = 0;
	char *t = NULL;
	int iorc;

	/* If arg looks like a keyid, then attempt keyserver retrieve. */
	if (rstreqn(fn, "0x", 2)) {
	    const char * s = fn + 2;
	    int i;
	    for (i = 0; *s && isxdigit(*s); s++, i++)
		{};
	    if (i == 8 || i == 16) {
		t = rpmExpand("%{_hkp_keyserver_query}", fn+2, NULL);
		if (t && *t != '%')
		    fn = t;
	    }
	}

	/* Read the file and try to import all contained keys */
	iorc = rpmioSlurp(fn, &buf, &blen);
	if (iorc || buf == NULL || blen < 64) {
	    rpmlog(RPMLOG_ERR, _("%s: import read failed(%d).\n"), fn, iorc);
	    res++;
	} else {
	    res += doImport(ts, fn, (char *)buf, blen);
	}
	
	free(t);
	free(buf);
    }
    return res;
}
Example #6
0
void doNumpyInitPackage()
{
  doImport();
}