예제 #1
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
void Tmainwin::cmd_stepscript()
{
	if (G_curscript()==NULL)
	{
		reporterror(this,_text("There is no script present"));
		return;
	}
	scriptaction_pre();
	QString error;
	if (!G_curscript()->exec_isstarted())
	{
		if (!G_curscript()->exec_start(error))
		{
			scriptaction_post();
			scriptsourceview->scrollinside_sel();
			reporterror(this,error);
		}
		scriptaction_post();
	}
	else
	{
		if (!G_curscript()->exec_stepone(error)) reporterror(this,error);
		scriptaction_post();
	}
}
예제 #2
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_rmdir(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	imgtool_image *image = NULL;
	imgtool_partition *partition = NULL;
	int partition_index = 0;

	err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_RW, &image);
	if (err)
		goto done;

	err = imgtool_partition_open(image, partition_index, &partition);
	if (err)
		goto done;

	err = imgtool_partition_delete_directory(partition, argv[2]);
	if (err)
		goto done;

done:
	if (partition)
		imgtool_partition_close(partition);
	if (image)
		imgtool_image_close(image);
	if (err)
		reporterror(err, c, argv[0], argv[1], argv[2], NULL, NULL);
	return err ? -1 : 0;
}
예제 #3
0
파일: SC_source.cpp 프로젝트: pvaut/Z-Flux
void TSC_source::load(StrPtr ifilename)
{
	QTextfile file;
	QString line;

	try{

		lines.reset();
		readonly=false;
		debugline=-1;
		cursor_linenr=0;cursor_colnr=0;
		modified=false;
		scrollposy=0;

		filename=ifilename;
		file.openread(ifilename);
		while (!file.isend())
		{
			file.readline(line);
			lines.add(new QString(line));
		}
		file.close();
	}
	catch(QError error)
	{
		reporterror(error);
	}

	if (lines.G_count()<=0) lines.add(new QString);
	undos_reset();
}
예제 #4
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
void Tmainwin::openactivescripts()
{
	addlog(_text("Opening active scripts"),+1);
	TQXpanel *sourcepanel=G_panel_byname(_qstr("Source"));
	if (sourcepanel==NULL)
	{
		ASSERT(false);
		return;
	}
	sourcepanel->customtabs_init(scriptsourceview);

	try{
		QTextfile fl;
		QString filename,line;
		FormatString(filename,_qstr("^1\\openscripts.txt"),G_datadir());
		fl.openread(filename);
		fl.readline(line);
		int activescriptnr=qstr2int(line);
		while(!fl.isend())
		{
			fl.readline(line);
			if (line.G_length()>0)
			{
				try{
					TSC_script *script1=new TSC_script(&GetTSCenv());
					script1->G_source().load(line);
					scripts.add(script1);
					sourcepanel->customtabs_add(script1->G_source().G_filename());
				} catch(QError err)
				{
					QString errstr;
					FormatString(errstr,_text("Unable to open script file ^1: ^2"),line,err.G_content());
					reporterror(errstr);
				}
			}
		}
		fl.close();
		if ((activescriptnr>=0)&&(activescriptnr<scripts.G_count()))
			G_sourcetabbar()->change_tab(activescriptnr);
		else
			scriptsourceview->Set_script(scripts[0]);
		addlog(_text("Active scripts opened"),-1);
	} catch(QError &err)
	{
		reporterror(err.G_content());
	}
}
예제 #5
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_getall(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	imgtool_image *image = NULL;
	imgtool_partition *partition = NULL;
	imgtool_directory *imgenum = NULL;
	imgtool_dirent ent;
	filter_getinfoproc filter;
	int unnamedargs;
	const char *path = NULL;
	int arg;
	int partition_index = 0;

	err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_READ, &image);
	if (err)
		goto done;

	err = imgtool_partition_open(image, partition_index, &partition);
	if (err)
		goto done;

	arg = 2;
	if ((argc > 2) && (argv[2][0] != '-'))
	{
		path = argv[arg++];
	}

	unnamedargs = parse_options(argc, argv, arg, arg, NULL, &filter, NULL);
	if (unnamedargs < 0)
		goto done;

	err = imgtool_directory_open(partition, path, &imgenum);
	if (err)
		goto done;

	memset(&ent, 0, sizeof(ent));

	while (((err = imgtool_directory_get_next(imgenum, &ent)) == 0) && !ent.eof)
	{
		fprintf(stdout, "Retrieving %s (%u bytes)\n", ent.filename, (unsigned int) ent.filesize);

		err = imgtool_partition_get_file(partition, ent.filename, NULL, NULL, filter);
		if (err)
			goto done;
	}

done:
	if (imgenum)
		imgtool_directory_close(imgenum);
	if (partition)
		imgtool_partition_close(partition);
	if (image)
		imgtool_image_close(image);
	if (err)
		reporterror(err, c, argv[0], argv[1], NULL, NULL, NULL);
	return err ? -1 : 0;
}
예제 #6
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
void Tmainwin::cmd_runscript()
{
	if (G_curscript()==NULL)
	{
		reporterror(this,_text("There is no script present"));
		return;
	}
	G_3DCosmos().Reset_requeststop();
	QString error;
	scriptaction_pre();
	if (!exec_run(error))
//	if (!G_curscript()->exec_run(error))
	{
		scriptaction_post();
		scriptsourceview->scrollinside_sel();
		reporterror(this,error);
	}
	else scriptaction_post();
}
예제 #7
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
void Tmainwin::cmd_stopscript()
{
	if (G_curscript()==NULL)
	{
		reporterror(this,_text("There is no script present"));
		return;
	}
	G_curscript()->exec_stop();
	scriptsourceview->redraw();
	scriptvarview->redraw();
}
예제 #8
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
void Tmainwin::cmd_refreshproperties()
{
	try{
//		propertyview->tranfercontent();
		objtreeview->Set_cursor(NULL);
	}
	catch (QError &err)
	{
		reporterror(this,err);
	}
}
예제 #9
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
void initlog()
{
	logfilename=datadir+_qstr("/log.txt");
	FILE *fp=_wfopen(logfilename,_qstr("w"));
	if (fp==NULL)
	{
		reporterror(TFormatString(_text("Unable to create log file ^1"),logfilename));
		logfilename="";
	}
	fclose(fp);
	addlog(_text("================================= START LOG FILE ========================================"));
	logfilestarted=true;
}
예제 #10
0
파일: main.c 프로젝트: coinhelper/jsmess
static int cmd_readsector(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	imgtool_image *img;
	imgtool_stream *stream = NULL;
	void *buffer = NULL;
	UINT32 size, track, head, sector;

	/* attempt to open image */
	err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_READ, &img);
	if (err)
		goto done;

	track = atoi(argv[2]);
	head = atoi(argv[3]);
	sector = atoi(argv[4]);

	err = imgtool_image_get_sector_size(img, track, head, sector, &size);
	if (err)
		goto done;

	buffer = malloc(size);
	if (!buffer)
	{
		err = IMGTOOLERR_OUTOFMEMORY;
		goto done;
	}

	err = imgtool_image_read_sector(img, track, head, sector, buffer, size);
	if (err)
		goto done;


	stream = stream_open(argv[5], OSD_FOPEN_WRITE);
	if (!stream)
	{
		err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
		goto done;
	}

	stream_write(stream, buffer, size);

done:
	if (buffer)
		free(buffer);
	if (stream)
		stream_close(stream);
	if (err)
		reporterror(err, c, argv[0], argv[1], NULL, NULL, 0);
	return err ? -1 : 0;
}
예제 #11
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_listdriveroptions(const struct command *c, int argc, char *argv[])
{
	const imgtool_module *mod;
	const option_guide *opt_guide;
	const char *opt_spec;

	mod = imgtool_find_module(argv[0]);
	if (!mod)
		goto error;

	fprintf(stdout, "Driver specific options for module '%s':\n\n", argv[0]);

	/* list write options */
	opt_guide = (const option_guide *) imgtool_get_info_ptr(&mod->imgclass, IMGTOOLINFO_PTR_WRITEFILE_OPTGUIDE);
	opt_spec = imgtool_get_info_string(&mod->imgclass, IMGTOOLINFO_STR_WRITEFILE_OPTSPEC);
	if (opt_guide)
	{
		fprintf(stdout, "Image specific file options (usable on the 'put' command):\n\n");
		listoptions(opt_guide, opt_spec);
		puts("\n");
	}
	else
	{
		fprintf(stdout, "No image specific file options\n\n");
	}

	/* list create options */
	opt_guide = mod->createimage_optguide;
	if (opt_guide)
	{
		fprintf(stdout, "Image specific creation options (usable on the 'create' command):\n\n");
		listoptions(opt_guide, mod->createimage_optspec);
		puts("\n");
	}
	else
	{
		fprintf(stdout, "No image specific creation options\n\n");
	}

	return 0;

error:
	reporterror((imgtoolerr_t)(IMGTOOLERR_MODULENOTFOUND|IMGTOOLERR_SRC_MODULE), c, argv[0], NULL, NULL, NULL, NULL);
	return -1;
}
예제 #12
0
파일: main.cpp 프로젝트: rjw57/buri-mame
static int cmd_readsector(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	imgtool_image *img;
	imgtool_stream *stream = nullptr;
	dynamic_buffer buffer;
	UINT32 size, track, head, sector;

	/* attempt to open image */
	err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_READ, &img);
	if (err)
		goto done;

	track = atoi(argv[2]);
	head = atoi(argv[3]);
	sector = atoi(argv[4]);

	err = imgtool_image_get_sector_size(img, track, head, sector, &size);
	if (err)
		goto done;

	buffer.resize(size);

	err = imgtool_image_read_sector(img, track, head, sector, &buffer[0], size);
	if (err)
		goto done;


	stream = stream_open(argv[5], OSD_FOPEN_WRITE);
	if (!stream)
	{
		err = (imgtoolerr_t)(IMGTOOLERR_FILENOTFOUND | IMGTOOLERR_SRC_NATIVEFILE);
		goto done;
	}

	stream_write(stream, &buffer[0], size);

done:
	if (stream)
		stream_close(stream);
	if (err)
		reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr);
	return err ? -1 : 0;
}
예제 #13
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_get(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	imgtool_image *image = NULL;
	imgtool_partition *partition = NULL;
	const char *filename;
	char *new_filename;
	int unnamedargs = 0;
	filter_getinfoproc filter;
	const char *fork;
	int partition_index = 0;

	err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_READ, &image);
	if (err)
		goto done;

	err = imgtool_partition_open(image, partition_index, &partition);
	if (err)
		goto done;

	filename = interpret_filename(argv[2]);

	unnamedargs = parse_options(argc, argv, 3, 4, NULL, &filter, &fork);
	if (unnamedargs < 0)
		goto done;

	new_filename = (unnamedargs == 4) ? argv[3] : NULL;

	err = imgtool_partition_get_file(partition, filename, fork, new_filename, filter);
	if (err)
		goto done;

	err = IMGTOOLERR_SUCCESS;

done:
	if (err)
		reporterror(err, c, argv[0], argv[1], argv[2], argv[3], NULL);
	if (partition)
		imgtool_partition_close(partition);
	if (image)
		imgtool_image_close(image);
	return (err || (unnamedargs < 0)) ? -1 : 0;
}
예제 #14
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_create(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	int unnamedargs;
	const imgtool_module *module;
	option_resolution *resolution = NULL;

	module = imgtool_find_module(argv[0]);
	if (!module)
	{
		err = (imgtoolerr_t)(IMGTOOLERR_MODULENOTFOUND | IMGTOOLERR_SRC_MODULE);
		goto error;
	}

	if (module->createimage_optguide && module->createimage_optspec)
	{
		resolution = option_resolution_create(module->createimage_optguide, module->createimage_optspec);
		if (!resolution)
		{
			err = IMGTOOLERR_OUTOFMEMORY;
			goto error;
		}
	}

	unnamedargs = parse_options(argc, argv, 2, 3, resolution, NULL, NULL);
	if (unnamedargs < 0)
		return -1;

	err = imgtool_image_create(module, argv[1], resolution, NULL);
	if (err)
		goto error;

	if (resolution)
		option_resolution_close(resolution);
	return 0;

error:
	if (resolution)
		option_resolution_close(resolution);
	reporterror(err, c, argv[0], argv[1], NULL, NULL, 0);
	return -1;
}
예제 #15
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_identify(const struct command *c, int argc, char *argv[])
{
	imgtool_module *modules[128];
	imgtoolerr_t err;
	int i;

	err = imgtool_identify_file(argv[0], modules, ARRAY_LENGTH(modules));
	if (err)
		goto error;

	for (i = 0; modules[i]; i++)
	{
		printf("%.16s %s\n", modules[i]->name, modules[i]->description);
	}

	return 0;

error:
	reporterror(err, c, NULL, argv[0], NULL, NULL, 0);
	return -1;
}
예제 #16
0
Tcyclorbit2::Tcyclorbit2(StrPtr ifilename, double accuracy, double iscalefactor)
{
	try{
		FILE *fp;
		char termtype[1000];
		int order;
		double A,B,C;

		addlog(TFormatString(_text("Loading stock cyclic orbit ^1"),ifilename));

		scalefactor=iscalefactor;
		if (_wfopen_s(&fp,ifilename,_qstr("r"))!=0) throw QError(TFormatString(_text("Unable to find cycl file ^1"),ifilename));

		expa_L.reset(accuracy);
		expa_B.reset(accuracy);
		expa_R.reset(accuracy/100.0);

		//preset for L & B
		expa_L.maxA=2*Pi*accuracy;expa_L.fixedaccuracy=true;
		expa_B.maxA=2*Pi*accuracy;expa_B.fixedaccuracy=true;

		expa_R.maxA=1.0;

		bool ok=true;
		for(;(ok)&&(!feof(fp));)
		{
			if (fscanf(fp,"%s %d %lf %lf %lf\n",termtype,&order,&A,&B,&C)==5)
			{
				if (stricmp(termtype,"L")==0) expa_L.try_addterm(order,A,B,C);
				if (stricmp(termtype,"B")==0) expa_B.try_addterm(order,A,B,C);
				if (stricmp(termtype,"R")==0) expa_R.try_addterm(order,A,B,C);
			}
		}
		fclose(fp);
	}
	catch(QError &err)
	{
		reporterror(err.G_content());
	}
}
예제 #17
0
파일: main.cpp 프로젝트: rjw57/buri-mame
static int cmd_create(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	int unnamedargs;
	const imgtool_module *module;
	std::unique_ptr<util::option_resolution> resolution;

	module = imgtool_find_module(argv[0]);
	if (!module)
	{
		err = (imgtoolerr_t)(IMGTOOLERR_MODULENOTFOUND | IMGTOOLERR_SRC_MODULE);
		goto error;
	}

	if (module->createimage_optguide && module->createimage_optspec)
	{
		try { resolution.reset(new util::option_resolution(module->createimage_optguide, module->createimage_optspec)); }
		catch (...)
		{
			err = IMGTOOLERR_OUTOFMEMORY;
			goto error;
		}
	}

	unnamedargs = parse_options(argc, argv, 2, 3, resolution.get(), nullptr, nullptr);
	if (unnamedargs < 0)
		return -1;

	err = imgtool_image_create(module, argv[1], resolution.get(), nullptr);
	if (err)
		goto error;

	return 0;

error:
	reporterror(err, c, argv[0], argv[1], nullptr, nullptr, nullptr);
	return -1;
}
예제 #18
0
파일: regex.cpp 프로젝트: RedSnapper/Obyx
	//• Regex private methods compile(), matcher(), reporterror() ------
	size_t Regex::matcher(const string& pattern,const string& scope,const int offset,int*& ov,int& ovc) {
		size_t inner_result = 0;
		int exec_result = 0;
		pcre* re = nullptr;
		pcre_extra* rx = nullptr;
		type_regex_cache::const_iterator it = regex_cache.find(pattern);
		if (it != regex_cache.end()) {
			re = ((*it).second.first);
			rx = ((*it).second.second);
			exec_result = pcre_exec(re,rx,scope.c_str(),(unsigned int)scope.length(),offset,mt_options,ov,ovc);
		} else {
			if ( compile(pattern,re,rx) ) {
				regex_cache.insert(type_regex_cache::value_type(pattern,pair<pcre*,pcre_extra*>(re,rx)));
				exec_result = pcre_exec(re,rx,scope.c_str(),(unsigned int)scope.length(),offset,mt_options,ov,ovc);
			}
		}
		if ( exec_result < 1 ) { 
			if (exec_result != -1) reporterror(exec_result);
			inner_result = 0;
		} else {
			inner_result = exec_result;
		}
		return inner_result;
	}
예제 #19
0
파일: lxplib.c 프로젝트: WeyrSDev/gamecode3
static int parse_aux (lua_State *L, lxp_userdata *xpu, const char *s,
                      size_t len) {
  luaL_Buffer b;
  int status;
  xpu->L = L;
  xpu->state = XPSok;
  xpu->b = &b;
  lua_settop(L, 2);
  lua_getref(L, xpu->tableref);  /* to be used by handlers */
  status = XML_Parse(xpu->parser, s, (int)len, s == NULL);
  if (xpu->state == XPSstring) dischargestring(xpu);
  if (xpu->state == XPSerror) {  /* callback error? */
    lua_rawgeti(L, LUA_REGISTRYINDEX, xpu->tableref);  /* get original msg. */
    lua_error(L);
  }
  if (s == NULL) xpu->state = XPSfinished;
  if (status) {
    lua_pushboolean(L, 1);
    return 1;
  }
  else { /* error */
    return reporterror(xpu);
  }
}
예제 #20
0
int cmd_testsuite(struct command *c, int argc, char *argv[])
{
	const char *testsuitefile;
	FILE *inifile;
	const imgtool_module *module = NULL;
	char buffer[1024];
	char buffer2[1024];
	char filename[1024];
	char *filename_base;
	size_t filename_len;
	char *s;
	char *s2;
	const char *directive;
	const char *directive_value;
	imgtool_image *img = NULL;
	imgtool_directory *imgenum;
	imgtool_dirent imgdirent;
	int err = -1, i;

	testsuitefile = argv[0];

	/* open the testsuite file */
	inifile = fopen(testsuitefile, "r");
	if (!inifile)
	{
		fprintf(stderr, "*** cannot open testsuite file '%s'\n", testsuitefile);
		goto error;
	}

	/* change to the current directory of the test suite */
	strncpyz(filename, testsuitefile, sizeof(filename));
	s = filename + strlen(filename) - 1;
	while((*s != '/') && (*s != '\\'))
		*(s--) = '\0';
	filename_base = s+1;
	filename_len = filename_base - filename;

	while(!feof(inifile))
	{
		buffer[0] = '\0';
		fgets(buffer, sizeof(buffer) / sizeof(buffer[0]), inifile);

		if (buffer[0] != '\0')
		{
			s = buffer + strlen(buffer) -1;
			while(isspace(*s))
				*(s--) = '\0';
		}
		s = buffer;
		while(isspace(*s))
			s++;

		if (*s == '[')
		{
			s2 = strchr(s, ']');
			if (!s2)
				goto syntaxerror;
			*s2 = '\0';
			module = findimagemodule(s+1);
			if (!module)
			{
				fprintf(stderr, "*** unrecognized imagemodule '%s'\n", s+1);
				goto error;
			}
			imgtool_test(module);
		}
		else if (isalpha(*s))
		{
			directive = s;
			while(isalpha(*s))
				s++;
			while(isspace(*s))
				*(s++) = '\0';

			if (*s != '=')
			{
				fprintf(stderr, "*** expected '='\n");
				goto error;
			}
			*(s++) = '\0';
			while(isspace(*s))
				s++;
			directive_value = s;

			if (!mame_stricmp(directive, "imagefile"))
			{
				/* imagefile directive */
				if (img)
					imgtool_image_close(img);
				strncpyz(filename_base, directive_value, filename_len);
				err = imgtool_image_open(module, filename, OSD_FOPEN_READ, &img);
				if (err)
					goto error;

				fprintf(stdout, "%s\n", filename);
			}
			else if (!mame_stricmp(directive, "files"))
			{
				/* files directive */
				if (!img)
					goto needimgmodule;
				err = imgtool_directory_open(img, &imgenum);
				if (err)
					goto error;

				memset(&imgdirent, 0, sizeof(imgdirent));
				imgdirent.fname = buffer2;
				imgdirent.fname_len = sizeof(buffer2);
				while(((err = imgtool_directory_get_next(imgenum, &imgdirent)) == 0) && imgdirent.fname[0])
				{
					i = strlen(buffer2);
					buffer2[i++] = ',';
					imgdirent.fname = &buffer2[i];
					imgdirent.fname_len = sizeof(buffer2) - i;
				}
				imgtool_directory_close(imgenum);
				if (err)
					goto error;
				i = strlen(buffer2);
				if (i > 0)
					buffer2[i-1] = '\0';

				if (strcmp(directive_value, buffer2))
				{
					fprintf(stderr, "*** expected files '%s', but instead got '%s'", directive_value, buffer2);
					goto error;
				}
			}
			else
			{
				fprintf(stderr, "*** unrecognized directive '%s'\n", directive);
				goto done;
			}
		}
	}
	err = 0;
	goto done;

needimgmodule:
	fprintf(stderr, "*** need [format] declaration before any directives\n");
	goto error;

syntaxerror:
	fprintf(stderr, "*** syntax error: %s\n", buffer);
	goto error;

error:
	if (err && (err != -1))
		reporterror(err, c, module ? module->name : NULL, filename, NULL, NULL, NULL);

done:
	if (inifile)
		fclose(inifile);
	if (img)
		imgtool_image_close(img);
	return err;
}
예제 #21
0
int main()
{
	int ch;
	
	initscr();			/* start curses	*/
	raw();				/* disable line buffering */
	keypad(stdscr, TRUE);
	noecho();

	start_color();
	use_default_colors();
	init_pair(10, COLOR_WHITE, COLOR_RED);

	statuswin = subwin(stdscr, 1, 0, 0, 0);
	hdrwin = subwin(stdscr, 1, 0, 1, 0);

	blockpad = newpad(1000, 60);

	errorw = statuswin;

	wclear(stdscr);

	db_connect();
	if (db_is_connected())
	{
		reporterror("connected");
		rels = db_fetch_relations(&nrels);
		if (rels)
			display_relations(hdrwin, blockpad, rels, nrels);
	}

	move_selection(0);
	refresh();

	for (;;)
	{
		refresh_screen();

		ch = getch();

		werase(statuswin);
		wrefresh(statuswin);

		switch (ch)
		{
			case KEY_UP:
				if (displayed_block != InvalidBlockNumber)
					scroll_blockpad(-1);
				else
					move_selection(-1);
				break;
			case KEY_DOWN:
				if (displayed_block != InvalidBlockNumber)
					scroll_blockpad(1);
				else
					move_selection(1);
				break;
			case KEY_NPAGE:
				if (displayed_block != InvalidBlockNumber)
					scroll_blockpad(15);
				else
					move_selection(15);
				break;
			case KEY_PPAGE:
				if (displayed_block != InvalidBlockNumber)
					scroll_blockpad(-15);
				else
					move_selection(-15);
				break;

			case KEY_ENTER:
			case KEY_RIGHT:
				if (displayed_block == InvalidBlockNumber)
				{
					block = db_fetch_block(rels[selected_rel].relname, "main", 0);
					if (block)
					{
						blockpad_pos_save = blockpad_pos;
						blockpad_pos = 0;
						displayed_block = 0;
						display_block(hdrwin, blockpad, block, displayed_block);
					}
				}
				else
				{
					displayed_block++;
					block = db_fetch_block(rels[selected_rel].relname, "main", displayed_block);
					if (block)
					{
						blockpad_pos_save = blockpad_pos;
						blockpad_pos = 0;
						display_block(hdrwin, blockpad, block, displayed_block);
					}
				}
				break;

			case KEY_LEFT:
				if (displayed_block != InvalidBlockNumber)
				{
					displayed_block--;
					if (displayed_block == InvalidBlockNumber)
					{
						blockpad_pos = blockpad_pos_save;
						if (displayed_block == InvalidBlockNumber)
						{
							display_relations(hdrwin, blockpad, rels, nrels);
							mvwchgat(blockpad, selected_rel, 0, 40, A_REVERSE, 0, NULL);
						}
					}
					else
					{
						block = db_fetch_block(rels[selected_rel].relname, "main", displayed_block);
						if (block)
						{
							blockpad_pos_save = blockpad_pos;
							blockpad_pos = 0;
							display_block(hdrwin, blockpad, block, displayed_block);
						}
					}

				}
				break;

			case 'g':				/* goto block */
				if (displayed_block != InvalidBlockNumber)
				{
					char str[11];
					BlockNumber blkno;
					char *endptr;

					werase(hdrwin);
					mvwprintw(hdrwin, 0, 0, "Goto block: ");
					refresh_screen();
					echo();
					getnstr(str, sizeof(str) - 1);
					noecho();

					blkno = strtoul(str, &endptr, 10);
					if (*endptr != '\0')
					{
						werase(hdrwin);
						mvwprintw(hdrwin, 0, 0, "Invalid block number");
					}
					else
					{
						block = db_fetch_block(rels[selected_rel].relname, "main", blkno);
						if (block)
						{
							displayed_block = blkno;
							blockpad_pos_save = blockpad_pos;
							blockpad_pos = 0;
							display_block(hdrwin, blockpad, block, displayed_block);
						}
					}
				}
				break;

			case 'q':
				endwin();			/* End curses mode		  */
				exit(0);
				break;
			default:
				reporterror("unknown key: %c", ch);
		}
	}
	endwin();			/* End curses mode		  */

	return 0;
}
예제 #22
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_dir(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err;
	int total_count, total_size, freespace_err;
	UINT64 freespace;
	imgtool_image *image = NULL;
	imgtool_partition *partition = NULL;
	imgtool_directory *imgenum = NULL;
	imgtool_dirent ent;
	char buf[512];
	char last_modified[19];
	const char *path;
	int partition_index = 0;

	/* attempt to open image */
	err = imgtool_image_open_byname(argv[0], argv[1], OSD_FOPEN_READ, &image);
	if (err)
		goto done;

	/* attempt to open partition */
	err = imgtool_partition_open(image, partition_index, &partition);
	if (err)
		goto done;

	path = argc > 2 ? argv[2] : NULL;

	err = imgtool_directory_open(partition, path, &imgenum);
	if (err)
		goto done;

	memset(&ent, 0, sizeof(ent));
	last_modified[0] = '\0';
	total_count = 0;
	total_size = 0;

	fprintf(stdout, "Contents of %s:%s\n", argv[1], path ? path : "");

	imgtool_image_info(image, buf, sizeof(buf));
	if (buf[0])
		fprintf(stdout, "%s\n", buf);
	fprintf(stdout, "------------------------------  --------  ---------------  ------------------\n");

	while (((err = imgtool_directory_get_next(imgenum, &ent)) == 0) && !ent.eof)
	{
		if (ent.directory)
			snprintf(buf, sizeof(buf), "<DIR>");
		else
			snprintf(buf, sizeof(buf), "%u", (unsigned int) ent.filesize);

		if (ent.lastmodified_time != 0)
			strftime(last_modified, sizeof(last_modified), "%d-%b-%y %H:%M:%S",
				localtime(&ent.lastmodified_time));

		if (ent.hardlink)
			strcat(ent.filename, " <hl>");

		fprintf(stdout, "%-30s  %8s  %15s  %18s\n", ent.filename, buf, ent.attr, last_modified);

		if (ent.softlink && ent.softlink[0] != '\0')
			fprintf(stdout, "-> %s\n", ent.softlink);

		if (ent.comment && ent.comment[0] != '\0')
			fprintf(stdout, ": %s\n", ent.comment);

		total_count++;
		total_size += ent.filesize;

		memset(&ent, 0, sizeof(ent));
	}

	freespace_err = imgtool_partition_get_free_space(partition, &freespace);

	if (err)
		goto done;

	fprintf(stdout, "------------------------  ------ ---------------\n");
	fprintf(stdout, "%8i File(s)        %8i bytes\n", total_count, total_size);
	if (!freespace_err)
		fprintf(stdout, "                        %8u bytes free\n", (unsigned int) freespace);

done:
	if (imgenum)
		imgtool_directory_close(imgenum);
	if (partition)
		imgtool_partition_close(partition);
	if (image)
		imgtool_image_close(image);
	if (err)
		reporterror(err, c, argv[0], argv[1], NULL, NULL, NULL);
	return err ? -1 : 0;
}
예제 #23
0
파일: main.cpp 프로젝트: pvaut/Z-Flux
	virtual BOOL InitInstance()
	{
		try{
			SetRegistryKey(G_softwarename());

			//boost process priority
			SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);

			AfxInitRichEdit();
	//		AfxEnableControlContainer();
	//		AfxOleInit();

			{//create documents folder
				QString dir;
				GetDocumentsDir(dir);dir+=_qstr("\\");dir+=G_softwarename();
				CreateDirectory(dir,NULL);
			}


			CWinApp::InitInstance();

			//for 3D Connexion
			if (!AfxOleInit())
			{
				AfxMessageBox(L"OLE Init failed");
				return FALSE;
			}
			AfxEnableControlContainer();


			StrChar locstartupdir[600];
			GetCurrentDirectory(599,locstartupdir);
			startupdir=locstartupdir;
			datadir=startupdir+_qstr("/Data");
			{
				QString storeddatadir;
				QParamRead(PARAMLOCATION_REGISTRY,_qstr("DataDirectory"),storeddatadir);
				if (qstrlen(storeddatadir)>0)
					datadir=storeddatadir;
			}

			initlog();
			addlog(TFormatString(_text("Data directory: ^1"),datadir));

			scriptsdir=datadir;scriptsdir+=_qstr("\\Scripts");
			texturesdir=datadir;texturesdir+=_qstr("\\textures");

			addlog(_text("Fetching MAC address"));
			GetMACaddress(MACaddr);
			addlog(MACaddr);

			G_3DCosmos().LoadSettings();
			G_3DCosmos().init();


			loadstockcyclorbits();

			G_QXSys().startup();

			addlog(_text("Loading languages"),+1);
			QTranslate::Get().loadlanguages();
			addlog(_text("Loaded languages"),-1);

			addlog(_text("Creating source code window"),+1);
			mainwin= new Tmainwin();
			mainwin->createwindow(NULL,QString("Source code window"));
			addlog(_text("Source code window created"),-1);
			addlog(_text(""));
			addlog(_text(""));
			mainwin->ShowWindow(m_nCmdShow);
			m_pMainWnd=mainwin;

		}
		catch(QError &err)
		{
			reporterror(err.G_content());
		}

		return TRUE;
	}
예제 #24
0
파일: main.c 프로젝트: dinkc64/mame
static int cmd_put(const struct command *c, int argc, char *argv[])
{
	imgtoolerr_t err = IMGTOOLERR_SUCCESS;
	int i;
	imgtool_image *image = NULL;
	imgtool_partition *partition = NULL;
	const char *filename = NULL;
	int unnamedargs;
	filter_getinfoproc filter;
	const imgtool_module *module;
	option_resolution *resolution = NULL;
	const char *fork;
	const char *new_filename;
	char **filename_list;
	int filename_count;
	int partition_index = 0;
	const option_guide *writefile_optguide;
	const char *writefile_optspec;

	module = imgtool_find_module(argv[0]);
	if (!module)
	{
		err = (imgtoolerr_t)(IMGTOOLERR_MODULENOTFOUND | IMGTOOLERR_SRC_MODULE);
		goto done;
	}

	/* ugh I hate the way this function is set up, this is because the
	 * arguments depend on the partition; something that requires some
	 * rudimentary parsing */
	if (argc >= 2)
	{
		/* open up the image */
		err = imgtool_image_open(module, argv[1], OSD_FOPEN_RW, &image);
		if (err)
			goto done;

		/* open up the partition */
		err = imgtool_partition_open(image, partition_index, &partition);
		if (err)
			goto done;

		writefile_optguide = (const option_guide *) imgtool_partition_get_info_ptr(partition, IMGTOOLINFO_PTR_WRITEFILE_OPTGUIDE);
		writefile_optspec = (const char *)imgtool_partition_get_info_ptr(partition, IMGTOOLINFO_STR_WRITEFILE_OPTSPEC);

		if (writefile_optguide && writefile_optspec)
		{
			resolution = option_resolution_create(writefile_optguide, writefile_optspec);
			if (!resolution)
			{
				err = IMGTOOLERR_OUTOFMEMORY;
				goto done;
			}
		}
	}

	unnamedargs = parse_options(argc, argv, 4, 0xffff, resolution, &filter, &fork);
	if (unnamedargs < 0)
		return -1;

	/* pick out which args are filenames, and which one is the destination */
	new_filename = interpret_filename(argv[unnamedargs - 1]);
	filename_list = &argv[2];
	filename_count = unnamedargs - 3;

	/* loop through the filenames, and put them */
	for (i = 0; i < filename_count; i++)
	{
		filename = filename_list[i];
		printf("Putting file '%s'...\n", filename);
		err = imgtool_partition_put_file(partition, new_filename, fork, filename, resolution, filter);
		if (err)
			goto done;
	}

done:
	if (partition)
		imgtool_partition_close(partition);
	if (image)
		imgtool_image_close(image);
	if (resolution)
		option_resolution_close(resolution);
	if (err)
		reporterror(err, c, argv[0], argv[1], filename, NULL, resolution);
	return err ? -1 : 0;
}