예제 #1
0
파일: ofxCsv.cpp 프로젝트: fkraeutli/ofxCsv
	/**
	 * Load a CSV File.
	 * The default Separator is ",".
	 * The default Comment sign is "#".
	 *
	 * @param path
	 *        Set the file path.
	 */
	void ofxCsv::loadFile(string path){
		
		loadFile(path, ",", "#");
	
	}
예제 #2
0
static int midimain(const void * filename)
{
    int a, notes_used, vol;
    bool is_playing = true;  /* false = paused */

    midi_debug("Loading file");
    mf = loadFile(filename);

    if (mf == NULL)
    {
        midi_debug("Error loading file.");
        return -1;
    }

    if (initSynth(mf, ROCKBOX_DIR "/patchset/patchset.cfg",
        ROCKBOX_DIR "/patchset/drums.cfg") == -1)
        return -1;

    rb->pcm_play_stop();
#if INPUT_SRC_CAPS != 0
    /* Select playback */
    rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
    rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
#endif
    rb->pcm_set_frequency(SAMPLE_RATE); /* 44100 22050 11025 */

    /*
        * tick() will do one MIDI clock tick. Then, there's a loop here that
        * will generate the right number of samples per MIDI tick. The whole
        * MIDI playback is timed in terms of this value.. there are no forced
        * delays or anything. It just produces enough samples for each tick, and
        * the playback of these samples is what makes the timings right.
        *
        * This seems to work quite well. On a laptop, anyway.
        */

    midi_debug("Okay, starting sequencing");

    bpm = mf->div*1000000/tempo;
    number_of_samples = SAMPLE_RATE/bpm;

    /* Skip over any junk in the beginning of the file, so start playing */
    /* after the first note event */
    do
    {
        notes_used = 0;
        for (a = 0; a < MAX_VOICES; a++)
            if (voices[a].isUsed)
                notes_used++;
        tick();
    } while (notes_used == 0);

    playing_time = 0;
    samples_this_second = 0;

    synthbuf();
    rb->pcm_play_data(&get_more, NULL, NULL, 0);

    while (!quit)
    {
    #ifndef SYNC
        synthbuf();
    #endif
        rb->yield();

        /* Prevent idle poweroff */
        rb->reset_poweroff_timer();

        /* Code taken from Oscilloscope plugin */
        switch (rb->button_get(false))
        {
            case BTN_UP:
            case BTN_UP | BUTTON_REPEAT:
            {
                vol = rb->global_settings->volume;
                if (vol < rb->sound_max(SOUND_VOLUME))
                {
                    vol++;
                    rb->sound_set(SOUND_VOLUME, vol);
                    rb->global_settings->volume = vol;
                }
                break;
            }

            case BTN_DOWN:
            case BTN_DOWN | BUTTON_REPEAT:
            {
                vol = rb->global_settings->volume;
                if (vol > rb->sound_min(SOUND_VOLUME))
                {
                    vol--;
                    rb->sound_set(SOUND_VOLUME, vol);
                    rb->global_settings->volume = vol;
                }
                break;
            }

            case BTN_LEFT:
            {
                /* Rewinding is tricky. Basically start the file over */
                /* but run through the tracks without the synth running */
                rb->pcm_play_stop();
                seekBackward(5);
                midi_debug("Rewind to %d:%02d\n", playing_time/60, playing_time%60);
                if (is_playing)
                    rb->pcm_play_data(&get_more, NULL, NULL, 0);
                break;
            }

            case BTN_RIGHT:
            {
                rb->pcm_play_stop();
                seekForward(5);
                midi_debug("Skip to %d:%02d\n", playing_time/60, playing_time%60);
                if (is_playing)
                    rb->pcm_play_data(&get_more, NULL, NULL, 0);
                break;
            }

            case BTN_PLAY:
            {
                if (is_playing)
                {
                    midi_debug("Paused at %d:%02d\n", playing_time/60, playing_time%60);
                    is_playing = false;
                    rb->pcm_play_stop();
                } else
                {
                    midi_debug("Playing from %d:%02d\n", playing_time/60, playing_time%60);
                    is_playing = true;
                    rb->pcm_play_data(&get_more, NULL, NULL, 0);
                }
                break;
            }

#ifdef BTN_RC_QUIT
            case BTN_RC_QUIT:
#endif
            case BTN_QUIT:
                quit = true;
        }
    }
    return 0;
}
예제 #3
0
//---------------------------------------------------------
bool ofxXmlSettings::load(const string & path){
	return loadFile(path);
}
예제 #4
0
//!
//! Change function for the Source File parameter.
//!
void XmlTreeReaderNode::sourceFileChanged ()
{
    // load new source file
    loadFile();
}
예제 #5
0
pgn::File::File(const char* fileName)
{
	loadFile(fileName);
}
예제 #6
0
파일: critstrs.c 프로젝트: CivilPol/sdcboot
int main(int argc, char **argv)
{
	FILE *dat;
	int rc, i, j;
	unsigned long size;

	/*word w;*/
	byte *p;
	/*byte b, *p;*/


	if(argc > 2) {
		puts("CRITSTRS - Generate Critical Error string for a language\n"
			"Useage: CRITSTRS [language]\n"
			"\tIf no language is specified, the default strings are read only.\n"
			"\tThere must be <language>.ERR file in the current directory.\n"
			"Note: DEFAULT.ERR must be present in the current directory, too.");
		return 127;
	}



	if((rc = loadFile(fTXT)) != 0)
		return rc;
	if(argc > 1 && (rc = loadFile(argv[1])) != 0)
		return rc;

/* Now all the strings are cached into memory */

	puts("CRITSTRS: Running validation check");

	i = rc = 0;
	do if(!strg[i].text) {
		fprintf(stderr, "Missing string \"%s\"\n", strg[i].name);
		rc = 46;
	} while(strg[++i].name);
	i = 0;
	do if(!special[i].text) {
		fprintf(stderr, "Missing string \"%s\"\n", special[i].name);
		rc = 47;
	} while(special[++i].name);
	if(rc) return rc;

	/* Create the compacted S14 (keys)
		format: LK..KA..A
			'L': number of K's
			'K': Keycode (== ASCII code)
			'A': Action code
			The number of keycodes is equal to the number of action codes.
			The leftmost keycode is associated to the leftmost action code.
	*/
		/* first: count */
	for(rc = i = 0; i < 4; ++i)
		rc += strlen(special[i].text);
	if((p = (byte*)(strg[STR_KEYS].text = malloc(1 + rc * 2))) == NULL) {
		fputs("Out of memory\n", stderr);
		return 89;
	}
		/* then insert the data */
	*p = 0;
	for(i = 0; i < 4; ++i) {		/* also the action code */
		memcpy(p + 1 + *p, special[i].text, j = strlen(special[i].text));
		memset(p + 1 + *p + rc, i, j);
		*p += (unsigned char)j;
	}

	/* check if the error strings are continueous */
	for(rc = 0, i = STR_ERROR; i < maxNr; ++i)
		if(!strg[i].text) {
			fprintf(stderr, "Missing error string #%d\n", i - STR_ERROR);
			rc = 48;
		}
	if(rc) return rc;
	strg[++maxNr].text = special[4].text;

	puts("CRITSTRS: Dumping CRITER strings resource");

/* Dump the stuff into a file */
	/*if((dat = fopen(fDAT, "wb")) == NULL) {*/
	if((dat = fopen(fDAT, "wt")) == NULL) {
		perror("creating " fDAT);
		return 35;
	}

	/*ska: no resource in this project! startResource(dat, RES_ID_CRITER, 2, MODULE_VERSION);*/
		/* Number of strings EXCEPT trailing "Unknown error" */
	fprintf(dat, "??strings	DB %u\n", maxNr);
	/*b = maxNr;*/
	/*fwrite(&b, sizeof(b), 1, dat);*/
		/* when loaded the pointer to the string, now offset
			within file */
	size = 1l + maxNr * 2;
	for(i = 0; i <= maxNr; ++i) {
		fprintf(dat, "\tDW S%u\n", i);
		/*w = (word)size;*/
		/*fwrite(&w, sizeof(w), 1, dat);*/
		size += i == STR_KEYS? 1 + *(byte*)strg[STR_KEYS].text * 2
			: strlen(strg[i].text) + 1;
	}
	if(size > 0xfffful) {
		fputs("Overall size of Critical Error string database exceeds 64KB\n"
		 , stderr);
		return 37;
	}
		/* Now dump the strings themselves */
	for(i = 0; i <= maxNr; ++i) {
		int l;

		fprintf(dat, "S%u\tDB ", i);
		l = i == STR_KEYS? 1 + *(byte*)strg[STR_KEYS].text * 2
		                 : strlen(strg[i].text) + 1;
		p = (unsigned char*)strg[i].text;
		if(l) {
			while(--l)
				fprintf(dat, "%u,", *p++);
			fprintf(dat, "%u\n", *p);
		}
		/*fwrite(strg[i].text, 1
		 //, i == STR_KEYS? 1 + *(byte*)strg[STR_KEYS].text * 2
		 //               : strlen(strg[i].text) + 1
		 //, dat);*/
	}

	/*ska: no resource in this project! endResource(dat);*/

	fflush(dat);
	if(ferror(dat)) {
		fputs("General write error into: " fDAT "\n", stderr);
		return 36;
	}
	fclose(dat);

	return 0;
}
예제 #7
0
파일: CConfigReader.cpp 프로젝트: Ogimle/ne
CConfigReader::CConfigReader( const char* filename )
{
    loadFile( filename );
}
예제 #8
0
SidTuneBase* SidTuneBase::getFromFiles(const char* fileName, const char **fileNameExtensions, bool separatorIsSlash, SidTuneLoaderFunc loadFile)
{
    if (!loadFile)
        loadFile = &SidTuneBase::loadFile;
    
    buffer_t fileBuf1;

    loadFile(fileName, fileBuf1);

    // File loaded. Now check if it is in a valid single-file-format.
    std::unique_ptr<SidTuneBase> s(PSID::load(fileBuf1));
    if (s.get() == nullptr)
    {
        buffer_t fileBuf2;

        // Try some native C64 file formats
        s.reset(MUS::load(fileBuf1, fileBuf2, 0, true));
        if (s.get() != nullptr)
        {
            // Try to find second file.
            std::string fileName2;
            int n = 0;
            while (fileNameExtensions[n] != nullptr)
            {
                createNewFileName(fileName2, fileName, fileNameExtensions[n]);
                // 1st data file was loaded into "fileBuf1",
                // so we load the 2nd one into "fileBuf2".
                // Do not load the first file again if names are equal.
                if (!stringutils::equal(fileName, fileName2.data(), fileName2.size()))
                {
                    try
                    {
                        loadFile(fileName2.c_str(), fileBuf2);
                        // Check if tunes in wrong order and therefore swap them here
                        if (stringutils::equal(fileNameExtensions[n], ".mus"))
                        {
                            std::unique_ptr<SidTuneBase> s2(MUS::load(fileBuf2, fileBuf1, 0, true));
                            if (s2.get() != nullptr)
                            {
                                s2->acceptSidTune(fileName2.c_str(), fileName, fileBuf2, separatorIsSlash);
                                return s2.release();
                            }
                        }
                        else
                        {
                            std::unique_ptr<SidTuneBase> s2(MUS::load(fileBuf1, fileBuf2, 0, true));
                            if (s2.get() != nullptr)
                            {
                                s2->acceptSidTune(fileName, fileName2.c_str(), fileBuf1, separatorIsSlash);
                                return s2.release();
                            }
                        }
                    // The first tune loaded ok, so ignore errors on the
                    // second tune, may find an ok one later
                    }
                    catch (loadError const &) {}
                }
                n++;
            }

            s->acceptSidTune(fileName, nullptr, fileBuf1, separatorIsSlash);
            return s.release();
        }
    }
    if (s.get() == nullptr) s.reset(p00::load(fileName, fileBuf1));
    if (s.get() == nullptr) s.reset(prg::load(fileName, fileBuf1));

    if (s.get() != nullptr)
    {
        s->acceptSidTune(fileName, nullptr, fileBuf1, separatorIsSlash);
        return s.release();
    }

    throw loadError(ERR_UNRECOGNIZED_FORMAT);
}
예제 #9
0
void MainWindow::open()
{
	QString fileName = QFileDialog::getOpenFileName(this);
	if (!fileName.isEmpty())
		loadFile(fileName);
}
예제 #10
0
파일: demo_2.cpp 프로젝트: Valyrion/FSIA
void Demo_2::run()
{
	LOGI("Window size is: " << win.getSize().x << "x" << win.getSize().y);

	while(win.isOpen())
	{
		while(win.pollEvent(eve))
		{
			
			switch(eve.type)
			{
				case sf::Event::Closed:
					win.close();
					break;
				case sf::Event::KeyPressed:
					switch(eve.key.code)
					{
						case sf::Keyboard::Escape:
							win.close();
							break;
							
						case sf::Keyboard::Up:
							if(imageCheckIndex(imageindex+1))
							{
								setImage(++imageindex);
								updateInfoText();
							}
							break;
							
						case sf::Keyboard::Down:
							if(imageCheckIndex(imageindex-1))
							{
								setImage(--imageindex);
								updateInfoText();
							}
							break;
							
						case sf::Keyboard::Right:
							if(fileCheckIndex(fileindex+1))
							{
								loadFile(++fileindex);
								setImage(imageindex);
								updateInfoText();
							}
							break;
							
						case sf::Keyboard::Left:
							if(fileCheckIndex(fileindex-1))
							{
								loadFile(--fileindex);
								setImage(imageindex);
								updateInfoText();
							}
							break;
							
						case sf::Keyboard::L:
							LOGI("Learning!");
							break;
						
						default:
							break;
					}
					break;
				default:
					break;
			}
		}
		
		frameTime = frameClock.restart().asSeconds();
		
		win.clear(sf::Color(20, 20, 20));
		
		for(auto& box : board)
			win.draw(box);
		win.draw(surround);
		
		win.draw(imageinfo);
		
		win.display();
	}
}
예제 #11
0
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdTalkDef::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(TALK)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(ACTION)
	TOKEN_TABLE(DEFAULT_SPRITESET_FILE)
	TOKEN_TABLE(DEFAULT_SPRITESET)
	TOKEN_TABLE(DEFAULT_SPRITE)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_TALK) {
			_gameRef->LOG(0, "'TALK' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_ACTION: {
			AdTalkNode *node = new AdTalkNode(_gameRef);
			if (node && DID_SUCCEED(node->loadBuffer(params, false))) {
				_nodes.add(node);
			} else {
				delete node;
				node = nullptr;
				cmd = PARSERR_GENERIC;
			}
		}
		break;

		case TOKEN_DEFAULT_SPRITE:
			BaseUtils::setString(&_defaultSpriteFilename, (char *)params);
			break;

		case TOKEN_DEFAULT_SPRITESET_FILE:
			BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params);
			break;

		case TOKEN_DEFAULT_SPRITESET: {
			delete _defaultSpriteSet;
			_defaultSpriteSet = new AdSpriteSet(_gameRef);
			if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) {
				delete _defaultSpriteSet;
				_defaultSpriteSet = nullptr;
				cmd = PARSERR_GENERIC;
			}
		}
		break;


		case TOKEN_EDITOR_PROPERTY:
			parseEditorProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
		_gameRef->LOG(0, "Syntax error in TALK definition");
		return STATUS_FAILED;
	}

	if (cmd == PARSERR_GENERIC) {
		_gameRef->LOG(0, "Error loading TALK definition");
		return STATUS_FAILED;
	}

	delete _defaultSprite;
	delete _defaultSpriteSet;
	_defaultSprite = nullptr;
	_defaultSpriteSet = nullptr;

	if (_defaultSpriteFilename) {
		_defaultSprite = new BaseSprite(_gameRef);
		if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) {
			return STATUS_FAILED;
		}
	}

	if (_defaultSpriteSetFilename) {
		_defaultSpriteSet = new AdSpriteSet(_gameRef);
		if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) {
			return STATUS_FAILED;
		}
	}


	return STATUS_OK;
}
예제 #12
0
void ImFCSCalibrationWizard::on_btnLoadFile_clicked()
{
    emit loadFile();
}
예제 #13
0
PythonEditorWidget::PythonEditorWidget(InviwoMainWindow* ivwwin, InviwoApplication* app)
    : InviwoDockWidget(tr("Python Editor"), ivwwin)
    , settings_("Inviwo", "Inviwo")
    , infoTextColor_(153, 153, 153)
    , errorTextColor_(255, 107, 107)
    , runAction_(nullptr)
    , script_()
    , unsavedChanges_(false)
    , app_(app)
    , appendLog_(true)
{

    setObjectName("PythonEditor");
    settings_.beginGroup("PythonEditor");
    QString lastFile = settings_.value("lastScript", "").toString();
    appendLog_ = settings_.value("appendLog", appendLog_).toBool();
    settings_.endGroup();
    setVisible(false);
    setWindowIcon(QIcon(":/icons/python.png"));

    QMainWindow* mainWindow = new QMainWindow();
    mainWindow->setContextMenuPolicy(Qt::NoContextMenu);
    QToolBar* toolBar = new QToolBar();
    mainWindow->addToolBar(toolBar);
    toolBar->setFloatable(false);
    toolBar->setMovable(false);
    setWidget(mainWindow);

    {
        runAction_ = toolBar->addAction(QIcon(":/icons/python.png"), "Compile and Run");
        runAction_->setShortcut(QKeySequence(tr("F5")));
        runAction_->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        runAction_->setToolTip("Compile and Run Script");
        mainWindow->addAction(runAction_);
        connect(runAction_, &QAction::triggered, [this]() {run(); });
    }
    {
        auto action = toolBar->addAction(QIcon(":/icons/new.png"), tr("&New Script"));
        action->setShortcut(QKeySequence::New);
        action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        action->setToolTip("New Script");
        mainWindow->addAction(action);
        connect(action, &QAction::triggered, [this](){setDefaultText();});
    }
    {
        auto action = toolBar->addAction(QIcon(":/icons/open.png"), tr("&Open Script"));
        action->setShortcut(QKeySequence::Open);
        action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        action->setToolTip("Open Script");
        mainWindow->addAction(action);
        connect(action, &QAction::triggered, [this](){open();});
    }

    {
        auto action = toolBar->addAction(QIcon(":/icons/save.png"), tr("&Save Script"));
        action->setShortcut(QKeySequence::Save);
        action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        action->setToolTip("Save Script");
        mainWindow->addAction(action);
        connect(action, &QAction::triggered, [this](){save();});
    }
    {
        auto action = toolBar->addAction(QIcon(":/icons/saveas.png"), tr("&Save Script As..."));
        action->setShortcut(QKeySequence::SaveAs);
        action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        action->setToolTip("Save Script As...");
        mainWindow->addAction(action);
        connect(action, &QAction::triggered, [this](){saveAs();});
    }
    {
        QIcon icon;
        icon.addFile(":/icons/log-append.png", QSize(), QIcon::Normal, QIcon::On);
        icon.addFile(":/icons/log-clearonrun.png", QSize(), QIcon::Normal, QIcon::Off);

        QString str = (appendLog_ ? "Append Log" : "Clear Log on Run");
        auto action = toolBar->addAction(icon, str);
        action->setShortcut(Qt::ControlModifier + Qt::Key_E);
        action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        action->setCheckable(true);
        action->setChecked(appendLog_);
        action->setToolTip(appendLog_ ? "Append Log" : "Clear Log on Run");
        mainWindow->addAction(action);
        connect(action, &QAction::toggled, [this, action](bool toggle) { 
            appendLog_ = toggle; 
            // update tooltip and menu entry
            QString tglstr = (toggle ? "Append Log" : "Clear Log on Run");
            action->setText(tglstr);
            action->setToolTip(tglstr);
            // update settings
            settings_.beginGroup("PythonEditor");
            settings_.setValue("appendLog", appendLog_);
            settings_.endGroup();
        });
    }
    {
        auto action = toolBar->addAction(QIcon(":/icons/log-clear.png"), "Clear Log Output");
        action->setShortcut(Qt::ControlModifier + Qt::Key_E);
        action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
        action->setToolTip("Clear Log Output");
        mainWindow->addAction(action);
        connect(action, &QAction::triggered, [this](){clearOutput();});
    }

    // Done creating buttons
    QSplitter* splitter = new QSplitter(nullptr);
    splitter->setOrientation(Qt::Vertical);
    pythonCode_ = new PythonTextEditor(nullptr);
    pythonCode_->setObjectName("pythonEditor");
    pythonCode_->setUndoRedoEnabled(true);
    setDefaultText();
    pythonOutput_ = new QTextEdit(nullptr);
    pythonOutput_->setObjectName("pythonConsole");
    pythonOutput_->setReadOnly(true);
    pythonOutput_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    syntaxHighligther_ =
        SyntaxHighligther::createSyntaxHighligther<Python>(pythonCode_->document());

    splitter->addWidget(pythonCode_);
    splitter->addWidget(pythonOutput_);
    splitter->setStretchFactor(0, 1);
    splitter->setStretchFactor(1, 0);
    splitter->setHandleWidth(2);
    // enable QSplitter:hover stylesheet
    // QTBUG-13768 https://bugreports.qt.io/browse/QTBUG-13768
    splitter->handle(1)->setAttribute(Qt::WA_Hover);
    mainWindow->setCentralWidget(splitter);

    QObject::connect(pythonCode_, SIGNAL(textChanged()), this, SLOT(onTextChange()));
    // close this window before the main window is closed
    QObject::connect(ivwwin, &InviwoMainWindow::closingMainWindow, [this]() { delete this; });

    this->updateStyle();

    
    this->resize(500, 700);

    if (app_) {
        app_->getSettingsByType<SystemSettings>()->pythonSyntax_.onChange(
            this, &PythonEditorWidget::updateStyle);
        app_->getSettingsByType<SystemSettings>()->pyFontSize_.onChange(
            this, &PythonEditorWidget::updateStyle);
        app_->registerFileObserver(this);
    }
    unsavedChanges_ = false;

    if (lastFile.size() != 0) loadFile(lastFile.toLocal8Bit().constData(), false);

    setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    setFloating(true);
}
예제 #14
0
파일: BitmapIO.cpp 프로젝트: johan--/gosu
void Gosu::loadImageFile(Gosu::Bitmap& bitmap, const std::wstring& filename)
{
    Buffer buffer;
    loadFile(buffer, filename);
    loadImageFile(bitmap, buffer.frontReader());
}
예제 #15
0
파일: vhdlfile.cpp 프로젝트: dingjiu/qucs
// -------------------------------------------------------
void VHDL_File::createSymbol()
{
  QFontMetrics  metrics(QucsSettings.font);   // get size of text
  int fHeight = metrics.lineSpacing();

  int No = 0;
  TypeNames = "";
  QString tmp, PortNames = loadFile();
  if(!PortNames.isEmpty())
    No = PortNames.count(',') + 1;

  #define HALFWIDTH  17
  int h = 30*((No-1)/2) + 15;
  Lines.append(new Line(-HALFWIDTH, -h, HALFWIDTH, -h,QPen(Qt::darkBlue,2)));
  Lines.append(new Line( HALFWIDTH, -h, HALFWIDTH,  h,QPen(Qt::darkBlue,2)));
  Lines.append(new Line(-HALFWIDTH,  h, HALFWIDTH,  h,QPen(Qt::darkBlue,2)));
  Lines.append(new Line(-HALFWIDTH, -h,-HALFWIDTH,  h,QPen(Qt::darkBlue,2)));

  tmp = QObject::tr("vhdl");
  int w = metrics.width(tmp);
  Texts.append(new Text(w/-2, fHeight/-2, tmp));

  int y = 15-h, i = 0;
  Port *pp;
  while(i<No) {
    Lines.append(new Line(-30,  y,-HALFWIDTH,  y,QPen(Qt::darkBlue,2)));
    pp = new Port(-30,  y);
    Ports.append(pp);
    pp->Type = TypeNames.section(',', i, i);
    tmp = PortNames.section(',', i, i);
    w = metrics.width(tmp);
    Texts.append(new Text(-19-w, y-fHeight-2, tmp));
    i++;

    if(i == No) break;
    Lines.append(new Line(HALFWIDTH,  y, 30,  y,QPen(Qt::darkBlue,2)));
    pp = new Port( 30,  y);
    Ports.append(pp);
    pp->Type = TypeNames.section(',', i, i);
    tmp = PortNames.section(',', i, i);
    Texts.append(new Text( 20, y-fHeight-2, tmp));
    y += 60;
    i++;
  }

  x1 = -30; y1 = -h-2;
  x2 =  30; y2 =  h+2;
  tx = x1+4;
  ty = y2+4;

  // now create/modify properties
  No = 0;
  if(!GenNames.isEmpty())
    No = (GenNames.count(',')) + 1;
  Property * pr = Props.at(1);
  for(i=0; i<No; i++) {
    if (!pr) {
      pr = new Property(GenNames.section(',', i, i),
			GenDefs.section(',', i, i), true,
			QObject::tr("generic variable")+
			" "+QString::number(i+1));
      Props.append(pr);
      pr = 0;
    }
    else {
      pr->Description =
	QObject::tr("generic variable")+" "+QString::number(i+1);
      pr->Name = GenNames.section(',', i, i);
      pr = Props.next();
    }
  }
  // remove remaining properties if necessary
  y=Props.count()-1;
  for(i=No; i<y; i++) {
    Props.removeLast();
  }
}
예제 #16
0
FileLoader::FileLoader(const std::string& filename, Mode m)
    : file(NULL)
{
    loadFile(filename, m);
}
예제 #17
0
int main(int argc, const char *argv[]) {
    char from[MAX_GROUP_NAME];
    char message[MAX_MESSLEN];
    membership_info memb_info;
    int num_groups;
    char target_groups[100][MAX_GROUP_NAME];
    int16 mess_type;
    int endian_mismatch;

    int service_type;
    int loop = 1;
    int rc;
    int ret;
    int i;

    sqlite3 *mydb;
    char *dbName;
    char *zErrMsg;

    connectionStatus status = UNKNOWN;

    char buffer[MAX_GROUP_NAME];
    char sqlBuffer[1024];
    char *member;
    char *host;
    char *tok;
    char ch;
    extern char *optarg;

    char scratch[255];

    global.connected=0;
    global.Group=(char *)NULL;
    global.configFileName=(char *)NULL;
    global.locked = 0;
    global.rawClient =1;
    global.debug = 0;

#ifdef FICL
    global.appDir=(char *)NULL;
#endif

    char *group=(char *)NULL;

    setSymbol("BUILD",__DATE__,LOCK,LOCAL);
    setSymbol("CLIENT","raw",UNLOCK,GLOBAL);
    setSymbol("SPREAD_SERVER","4803",UNLOCK,GLOBAL);
    setSymbol("GROUP","global",UNLOCK,GLOBAL);
    setSymbol("USER","dbCache",LOCK,GLOBAL);
    setSymbol("DEBUG","false",UNLOCK,GLOBAL);
    setSymbol("MODE","local",UNLOCK,GLOBAL);
    setSymbol("START_FILE","./dbCache.rc",UNLOCK,GLOBAL);

    while((ch = getopt(argc, ( char **)argv,"dhc:")) != -1) {
        switch(ch) {
            case 'c':
                setSymbol("START_FILE", optarg,LOCK,GLOBAL);
                break;
            case 'd':
                global.debug=1;
                break;
            case 'h':
                usage();
                exit(0);
                break;
        }
    }

    loadFile(getSymbol("START_FILE"));

    if( global.debug ) {
        setBoolean("DEBUG",1);
    }

    global.debug = getBoolean("DEBUG");

    if(global.debug) {
        dumpGlobals();
        dumpSymbols();
    }

    dbName = getSymbol("DATABASE");

    connectToSpread();

    while(loop) {
        status = UNKNOWN;
        ret = SP_receive(global.Mbox, &service_type, from, 100,
                &num_groups, target_groups,
                &mess_type, &endian_mismatch, sizeof(message), message);

        if (Is_membership_mess (service_type)) {
            ret = SP_get_memb_info(message, service_type, &memb_info);

            if (Is_caused_join_mess(service_type)) {
                status=JOINED;
            } 
            if (Is_caused_leave_mess (service_type)) {
                status = LEFT;
            } 
            if (Is_caused_disconnect_mess (service_type)) {
                status = DISCONNECTED;
            } 
            if (Is_caused_network_mess (service_type)) {
                status = NETWORK;
            }

            rc = sqlite3_open(dbName, &mydb);
            for (i = 0; i < num_groups; i++) {

                if( global.debug) {
                    printf("\t%s\n",(char *) &target_groups[i][0]);
                }

                strcpy(buffer, &target_groups[i][1]);

                member=strtok(buffer,"#");
                host=strtok(NULL,"#");

                if( global.debug) {
                    printf("\t\tMember:%s\n", member);
                    printf("\t\tHost  :%s\n", host);
                }

                statusToText( status, scratch );

                if (JOINED == status ) {
                    sprintf( sqlBuffer,"insert or replace into status  ( member, host, grp, state ) values ( '%s','%s','%s','%s');", member, host,from,scratch);
                }
                if( global.debug) {
                    printf ("%s\n",sqlBuffer);
                }
                rc = sqlite3_exec(mydb, sqlBuffer, 0, 0, &zErrMsg);
            }
            strcpy(buffer, &memb_info.changed_member[1]);
            member=strtok(buffer,"#");
            host=strtok(NULL,"#");

            statusToText( status, scratch );
            sprintf( sqlBuffer, "update status set state='%s' where member = '%s' and host ='%s';",scratch, member,host);

            if( global.debug) {
                printf("CHANGE: %s %s\n",member,host);
                printf("CHANGE: %s\n", scratch);
                printf ("%s\n",sqlBuffer);
            }

            rc = sqlite3_exec(mydb, sqlBuffer, 0, 0, &zErrMsg);

            sqlite3_close(mydb);

        }

    }


    printf("============ After\n");
    dumpGlobals();

    printf("Sender %s\n",from);
    printf("Message >%s<\n",message);

    toSpread(from,"Message recieved\n");

    spreadJoin("TEST");

    sleep(2);

    spreadLeave("TEST");

    sleep(2);

    spreadDisconnect();
}
예제 #18
0
/*
 *  processFile
 */
static void
processFile(char const * pzFile)
{
    char* pzText = loadFile(pzFile); /* full text */
    char* pzScan;  /* Scanning Pointer  */
    char* pzDef;   /* Def block start   */
    char* pzNext;  /* start next search */
    char* pzDta;   /* data value        */
    int   lineNo = 1;
    char* pzOut;
    regmatch_t  matches[MAX_SUBMATCH+1];

    if (pzText == NULL)
        fserr_die("read opening %s\n", pzFile);

    processEmbeddedOptions(pzText);
    pzNext = pzText;

    while (pzScan = pzNext,
           regexec(&define_re, pzScan, COUNT(matches), matches, 0) == 0) {

        static char const zNoEnd[] =
            "Error:  definition in %s at line %d has no end\n";
        static char const zNoSubexp[] =
            "Warning: entry type not found on line %d in %s:\n\t%s\n";

        int  linesInDef = 0;

        /*
         *  Make sure there is a subexpression match!!
         */
        if (matches[1].rm_so == -1) {
            char* pz = NULL;
            char  ch = NUL;

            pzDef = pzScan + matches[0].rm_so;
            if (strlen(pzDef) > 30) {
                pz  = pzDef + 30;
                ch  = *pz;
                *pz = NUL;
            }

            fprintf(stderr, zNoSubexp, lineNo, pzFile, pzDef);
            if (pz != NULL)
                *pz = ch;
            continue;
        }

        pzDef = pzScan + matches[0].rm_so + sizeof("/*=") - 1;
        pzNext = strstr(pzDef, "=*/");
        if (pzNext == NULL)
            die(zNoEnd, pzFile, lineNo);

        *pzNext = NUL;
        pzNext += 3;
        /*
         *  Count the number of lines skipped to the start of the def.
         */
        for (;;) {
            pzScan = strchr(pzScan, '\n');
            if (pzScan++ == NULL)
                break;
            if (pzScan >= pzDef)
                break;
            lineNo++;
        }

        pzOut = pzDta = (char*)malloc(2 * strlen(pzDef) + 8000);

        /*
         *  Count the number of lines in the definition itself.
         *  It will find and stop on the "=* /\n" line.
         */
        pzScan = pzDef;
        for (;;) {
            pzScan = strchr(pzScan, '\n');
            if (pzScan++ == NULL)
                break;
            linesInDef++;
        }

        /*
         *  OK.  We are done figuring out where the boundaries of the
         *  definition are and where we will resume our processing.
         */
        buildDefinition(pzDef, pzFile, lineNo, pzOut);
        pzDta   = (char*)realloc((void*)pzDta, strlen(pzDta) + 1);
        lineNo += linesInDef;

        if (++blkUseCt > blkAllocCt) {
            blkAllocCt += 32;
            papzBlocks = (char**)realloc((void*)papzBlocks,
                                         blkAllocCt * sizeof(char*));
            if (papzBlocks == (char**)NULL)
                die("Realloc error for %d pointers\n", (int)blkAllocCt);
        }
        papzBlocks[ blkUseCt-1 ] = pzDta;
    }

    free((void*)pzText);
}
예제 #19
0
static int s5k6aafx_init(struct v4l2_subdev *sd, u32 val)
{
	//struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct s5k6aafx_state *state = to_state(sd);
	int err = -EINVAL;

	FUNC_ENTR();

#ifdef CONFIG_LOAD_FILE
	err = loadFile();
	if (unlikely(err)) {
		printk("%s: failed to init\n", __func__);
		return err;
	}
#endif

#if defined(CONFIG_CPU_FREQ)
	if (s5pv310_cpufreq_lock(DVFS_LOCK_ID_CAM, CPU_L0))
		printk(KERN_ERR "%s: error : failed lock DVFS\n", __func__);
#endif

	/* set initial regster value */
	if (state->vt_mode == 0)
	{
		printk("%s: load camera common setting \n", __func__);
#ifdef CONFIG_LOAD_FILE
		err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_common");
#else
#ifdef CONFIG_VIDEO_S5K6AAFX_MIPI
		if (system_rev == 4)
			err = s5k6aafx_write_regs(sd, s5k6aafx_common_for_rev05,	sizeof(s5k6aafx_common_for_rev05) / sizeof(s5k6aafx_common_for_rev05[0]));
		else
#endif
			err = s5k6aafx_write_regs(sd, s5k6aafx_common,	sizeof(s5k6aafx_common) / sizeof(s5k6aafx_common[0]));
#endif
	}
	else
	{
		printk("%s: load camera VT call setting \n", __func__);
#ifdef CONFIG_LOAD_FILE
		err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_common");
#else
#ifdef CONFIG_VIDEO_S5K6AAFX_MIPI
		if (system_rev == 4)
			err = s5k6aafx_write_regs(sd, s5k6aafx_vt_common_for_rev05, sizeof(s5k6aafx_vt_common_for_rev05) / sizeof(s5k6aafx_vt_common_for_rev05[0]));
		else 
#endif
			err = s5k6aafx_write_regs(sd, s5k6aafx_vt_common, sizeof(s5k6aafx_vt_common) / sizeof(s5k6aafx_vt_common[0]));
#endif

	}

#if defined(CONFIG_CPU_FREQ)
	s5pv310_cpufreq_lock_free(DVFS_LOCK_ID_CAM);
#endif

	if (unlikely(err))
	{
		printk("%s: failed to init\n", __func__);
		return err;
	}

#if defined(CONFIG_TARGET_LOCALE_LTN)
	//latin_cam VT Cam Antibanding
	if (state->anti_banding == ANTI_BANDING_60HZ)
	{
		err = s5k6aafx_set_60hz_antibanding(sd);
		if (unlikely(err))
		{
			printk("%s: failed to s5k6aafx_set_60hz_antibanding \n", __func__);
			return err;
		}
	}
	//hmin84.park -10.07.06
#endif

	state->set_fmt.width = DEFAULT_WIDTH;
	state->set_fmt.height = DEFAULT_HEIGHT;

	return 0;
}
예제 #20
0
CIniFile::CIniFile ( const string &filename )
{
	content = NULL;
	loadFile(filename);
	parse();
}
예제 #21
0
int main(int argc, char * * argv)
{
if (argc != 3)
{
  printf("usage: ./proj4 input output\n");
  return EXIT_FAILURE;
}

int index = 0;
double x = 0, y=0; 

// Build binary tree
stack * root = loadFile(argv[1], &index);
node * head = nodeCreate(root->stackNode->width, root->stackNode->height, root->stackNode->split, root->stackNode->index-1); //= buildTree(root);
root = StackPop(root);
buildTree(root, head, &head, index);
node * tree = NULL;
tree = nodeArrange(tree, &head);

// Packing
clock_t timeStart = clock();
assignCutline(tree);
setCoord(tree);
clock_t timeEnd = clock();
double packTime = (double) (timeEnd - timeStart) / CLOCKS_PER_SEC;
searchNode(tree, &x, &y, 1);
//printPostorderFull(tree);

//Reset output file and save output
FILE * fptr = fopen(argv[2], "w");
saveTree(tree, argv[2]);

// Screen dump
printf("Preorder: ");
printPreorder(tree);
printf("\n\nInorder: ");
printInorder(tree);
printf("\n\nPostorder: ");
printPostorder(tree);
printf("\n\nWidth: %le", tree->width);
printf("\nHeight: %le", tree->height);
printf("\n\nX-coordinate: %le", x);
printf("\nY-coordinate: %le", y); 
printf("\n");

// Rerooting
box * minBox = malloc(sizeof(box));
minBox->width = tree->width;
minBox->height = tree->height;

timeStart = clock();
// ------------------------------------ to run cases without rerooting, comment out the following lines
while (tree->right->split!='-')
{
tree = reroot(tree, minBox);
decideMin(minBox, tree);
//printPostorderFull(tree);
}
// ------------------------------------
timeEnd = clock();
double rootTime = (double) (timeEnd - timeStart) / CLOCKS_PER_SEC;


printf("\nElapsed Time: %le", packTime);
printf("\n\nBest width: %le", minBox->width);
printf("\nBest height: %le\n", minBox->height);
printf("\nElapsed Time for re-routing: %le\n", rootTime);

// Free stack
while(root!=NULL){
  root = StackPop(root);
}

// Memory management
free(root);
free(minBox);
deleteTree(head);
deleteTree(tree);
fclose(fptr);

return EXIT_SUCCESS;
}
예제 #22
0
    LuaSimpleBindingTest()
    {
        uint8* text = NULL;
        uint32 size = 0;

        if (!loadFile("lua_test.lua", &text, &size, true))
            return;

        lua_simple::LuaSimpleContext context;

        context.runString((const char*)text);

        int32 test_i = 0;
        uint32 test_u = 0;
        float test_f = 0;
        mkString test_s;
        uint8 test_bytes[4] = {0};

        context.registerFunc("getFoo", getFoo);
        context.registerFunc("printFoo", printFoo);

        bool success = true;

        success &= context.callFunc("onInit");

        {
            lua_simple::FunctionCallArgs args;
            args.add(1.23f);
            args.add(2);
            success &= context.callFunc("onUpdate", args);
        }

        success &= context.getGlobalVariable("test_int32").readInt32(test_i);
        success &= context.getGlobalVariable("test_uint32").readUInt32(test_u);
        success &= context.getGlobalVariable("test_float").readFloat(test_f);
        success &= context.getGlobalVariable("test_string").readString(test_s);
        success &= context.getGlobalVariable("test_bytes").readBytes(4, test_bytes);

        {
            lua_simple::FunctionCallArgs args;
            args.add("dupa slonia");
            success &= context.callFunc("onTakeDamage", args);
        }

        context.registerFunc("testCFunc", test);
        context.registerFunc("testCFunc2", test2);
        //context.registerFunc("testCFunc3", test3);
        context.registerFunc("testCFunc4", test4);
        context.registerFunc("testCFunc5", test5);

        success &= context.callFunc("testMyTest");

        success &= context.getGlobalVariable("dupa").getVariableByKey("jeden").readInt32(test_i);

        success &= context.getGlobalVariable("test_int32").readInt32(test_i);
        success &= context.getGlobalVariable("test_uint32").readUInt32(test_u);
        success &= context.getGlobalVariable("test_float").readFloat(test_f);
        success &= context.getGlobalVariable("test_string").readString(test_s);
        success &= context.getGlobalVariable("test_bytes").readBytes(4, test_bytes);

        //success &= context.getGlobalVariable("test_int32").writeInt32(987);
        //success &= context.getGlobalVariable("test_int32").readInt32(test_i);

        MK_ASSERT(success);

        delete[] text;
    }
예제 #23
0
pgn::File::File(const std::string fileName)
{
	loadFile(fileName);
}
예제 #24
0
QMap<QString, QString> proFileTagMap( const QString& text )
{
    QString t = text;
    QMap<QString, QString> tagMap;
    bool stillProcess = true; // If include() has a $$tag then we need to reprocess
    
    while(stillProcess) {

	/* 
	    Strip any commments before we try to include.  We
	    still need to do it after we include to make sure the
	    included file does not have comments
	*/
	t.replace( QRegExp(QString("#[^\n]*\n")), QString(" ") );

	/*
	    Process include() commands.
	    $$PWD is a special case so we have to change it while 
	    we know where the included file is.
        */
	QRegExp callToInclude("include\\s*\\(\\s*([^()\\s]+)\\s*\\)");
	int i = 0;
	while ( (i = callToInclude.search(t, i)) != -1 ) {
	    bool doneWithVar = false;
	    QString fileName = callToInclude.cap(1);
	    QString after = fileName.replace("$$PWD", QDir::currentDirPath());
	    if (!tagMap.isEmpty() && after.contains("$$")) {
		QRegExp var( "\\$\\$[({]?([a-zA-Z0-9_]+)[)}]?" );
		int ii = 0;
		while ((ii = after.find(var, ii)) != -1) {
		    if (tagMap.contains(var.cap(1))) {
			after.replace(ii, var.cap(0).length(), tagMap[var.cap(1)]);
		    } else { // Couldn't find it
			doneWithVar = true;
			break;
		    }
		}
		
	    }
	    if (doneWithVar || !after.contains("$$")) {
		after = loadFile(after);
		QFileInfo fi(callToInclude.cap(1));
		after.replace("$$PWD", fi.dirPath());
		t.replace( i, callToInclude.matchedLength(), after );
	    }
	    i += after.length();
	}

	/*
	    Strip comments, merge lines ending with backslash, add
	    spaces around '=' and '+=', replace '\n' with ';', and
	    simplify white spaces.
	*/
	t.replace( QRegExp(QString("#[^\n]*\n")), QString(" ") );
	t.replace( QRegExp(QString("\\\\[^\n\\S]*\n")), QString(" ") );
	t.replace( "=", QString(" = ") );
	t.replace( "+ =", QString(" += ") );
	t.replace( "\n", QString(";") );
	t = t.simplifyWhiteSpace();
	
	/*
	    Populate tagMap with 'key = value' entries.
	*/
	QStringList lines = QStringList::split( QChar(';'), t );
	QStringList::Iterator line;
	for ( line = lines.begin(); line != lines.end(); ++line ) {
	    QStringList toks = QStringList::split( QChar(' '), *line );
	    
	    if ( toks.count() >= 3 && 
		(toks[1] == QString("=") || toks[1] == QString("+=")) ) {
		QString tag = toks.first();
		int k = tag.findRev( QChar(':') ); // as in 'unix:'
		if ( k != -1 )
		    tag = tag.mid( k + 1 );
		toks.remove( toks.begin() );
		
		QString action = toks.first();
		toks.remove( toks.begin() );
		
		if ( tagMap.contains(tag) ) {
		    if ( action == QString("=") )
			tagMap.replace( tag, toks.join(QChar(' ')) );
		    else
			tagMap[tag] += QChar( ' ' ) + toks.join( QChar(' ') );
		} else {
		    tagMap[tag] = toks.join( QChar(' ') );
		}
	    }
	}
	
	/*
	    Expand $$variables within the 'value' part of a 'key = value'
	    pair.
	*/
	QRegExp var( "\\$\\$[({]?([a-zA-Z0-9_]+)[)}]?" );
	QMap<QString, QString>::Iterator it;
	for ( it = tagMap.begin(); it != tagMap.end(); ++it ) {
	    int i = 0;
	    while ( (i = var.search((*it), i)) != -1 ) {
		int len = var.matchedLength();
		QString invocation = var.cap(1);
		QString after;
		
		if ( invocation == "system" ) {
		    // skip system(); it will be handled in the next pass
		    ++i;
		} else {
		    if ( tagMap.contains(invocation) )
			after = tagMap[invocation];
		    else if (invocation.lower() == "pwd")
			after = QDir::currentDirPath();
		    (*it).replace( i, len, after );
		    i += after.length();
		}
	    }
	}
    
	/*
	  Execute system() calls.
	*/
	QRegExp callToSystem( "\\$\\$system\\s*\\(([^()]*)\\)" );
	for ( it = tagMap.begin(); it != tagMap.end(); ++it ) {
	    int i = 0;
	    while ( (i = callToSystem.search((*it), i)) != -1 ) {
		/*
		  This code is stolen from qmake's project.cpp file.
		  Ideally we would use the same parser, so we wouldn't
		  have this code duplication.
		*/
		QString after;
		char buff[256];
		FILE *proc = QT_POPEN( callToSystem.cap(1).latin1(), "r" );
		while ( proc && !feof(proc) ) {
		    int read_in = (int)fread( buff, 1, 255, proc );
		    if ( !read_in )
			break;
		    for ( int i = 0; i < read_in; i++ ) {
			if ( buff[i] == '\n' || buff[i] == '\t' )
			    buff[i] = ' ';
		    }
		    buff[read_in] = '\0';
		    after += buff;
		}
		(*it).replace( i, callToSystem.matchedLength(), after );
		i += after.length();
	    }
	}
	stillProcess = callToInclude.search(t) != -1;
    }
    return tagMap;
}
예제 #25
0
void pgn::File::loadFile(std::string fileName)
{
	if(fileName.size() > 0)
		loadFile(fileName.c_str());
}
예제 #26
0
파일: spy.cpp 프로젝트: Goodchaild/svofski
int Spy::Bootstrap()
{
    if (m_serial.Setup() != ERR_NONE) {
       info("Spy error: cannot open serial port\n");
       return 0;
    }

    info("Sending bootstrap code to workstation %d\n", m_studentNo);

    uint16_t bootStart, bootEnd;

	// Phase 1: send and run bootstrap code
	{
		char path[strlen(m_ExePath) + strlen(STRAPON) + 2];
		sprintf(path, "%s/%s", m_ExePath, STRAPON);

		FILE* file = fopen(path, "rb");
		uint8_t sig;
		if (file == 0 || fread(&sig, 1, 1, file) != 1) {
			info("Cannot read %s\n", path);
			return 0;
		}
		if (sig != 0xfe) {
			info("Not a BIN file %s\n", path);
			return 0;
		}

		BasicSender basicSender(&m_serial, m_studentNo);

		if (!basicSender.SendCommand("    WIDTH 80:COLOR9,1")) {
			info("Could not send command\n");
			return 0;
		}

		sleep(2);

		if (!basicSender.sendBIN(file, &bootStart, &bootEnd, 0)) {
			info("Bootstrap code upload error\n");
			return 0;
		}
	}

	info("Waiting for remote party...");
	sleep(1);
	info("OK\n");

	// Phase 2: upload memories
	SpyTransport transport(&m_serial);
	{
		info("Uploading zero page\n");
		// Zero page
		transport.SendMemory(m_MSXRAM + 0x0000, 0x0000, 256);

		// MSX-DOS BDOS area .. 0xED00
		uint16_t start = m_MSXRAM[6] | (m_MSXRAM[7] << 8);
		int length = bootStart - start;

		// patch the stupid loaded flag in MSXDOS+1A
		m_MSXRAM[(start & 0xff00) + 0x1A] = 0;

		if (length > 0) {
			info("Uploading memory area %04x-%04x\n", start, start + length);
			transport.SendMemory(m_MSXRAM + start, start, length);

			usleep(20000);

			// 0xED00 + sizeof(Bootstrap) .. EndOfWorkArea
			start = bootEnd;
		} 
		length = 0xf380 - start;

		info("Uploading memory area %04x-%04x\n", start, start + length);
		transport.SendMemory(m_MSXRAM + start, start, length);

		usleep(20000);

		// Net BDOS
		info("Uploading NetBDOS area %04x-%04x\n", 0xe900, 0xe900 + m_BDOSSize);
		transport.SendMemory(m_BDOS, 0xe900, m_BDOSSize);
	}

	// Phase 3: upload file to TPA if specified
	if (m_nfiles > 0) {
		int comsize;
		info("Uploading TPA file %s\n", m_file[0]);
		if ((comsize = loadFile(m_file[0], &m_COMFile, -1)) != 0) {
			transport.SendMemory(m_COMFile, 0x100, comsize);
		}
	}

	info("Launching remote workstation\n");

	// Phase 3: Launch remote station
	transport.SendCommand(2);

	sleep(1);

	return Serve();
}
예제 #27
0
Settings::Settings()
{
	setDefaults();
	loadFile();
}
예제 #28
0
gkBlendFile* gkBlendLoader::loadFile(const gkString& fname, const gkString& scene, const gkString& group)
{
	return loadFile(fname, LO_ALL_SCENES, scene, group);
}
예제 #29
0
void ofApp::dragEvent(ofDragInfo dragInfo) {
	loadFile(dragInfo.files[0]);
}
예제 #30
0
파일: ofxCsv.cpp 프로젝트: fkraeutli/ofxCsv
	/**
	 * Load a CSV File.
	 * The default Comment sign is "#".
	 *
	 * @param path
	 *        Set the file path.
	 * @param separator
	 *        Set the Separator to split CSV file.
	 */
	void ofxCsv::loadFile(string path, string separator){
		
		loadFile(path, separator, "#");
	
	}