Exemple #1
0
/* com */
void syscmd (char *s) {
	register status, sig;

	if (metas (s)) {
		if (usecshell)
			runl(0, cshabsname, cshname, "-f", "-c", s, NULL);
		else
			runl(0, shabsname, shname, "-c", s, NULL);
		return;
	}
	status = doexec (s);
	sig = status & 0177;
	if (! sig)
		return;
	if (sig == 0177)
		outerr("ptrace: ",0);
	else if (sig < numsysmsg && sysmsg [sig])
		outerr(sysmsg [sig],0);
	else
		outerr("Signal %d", sig);
	if (status & 0200)
		outerr(" - core dumped\n",0);
	else
		outerr("\n",0);
}
Exemple #2
0
/* menu */
void shell (void) {
	/* run shell */
	VClear ();
	VSync ();
	VRestore ();
	runl(0, ABSSHELL, SHELL, "-i", NULL);
	VReopen ();
	VClear ();
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
}
Exemple #3
0
/* main, menu */
void mydelete (void) {
	char buf [80];
	register struct file *p;
	register c;

	if (c = tagged ()) {
		/* delete group of files */

		sprintf (buf, "You have selected %d file%s.", c, c>1 ? "s" : "");
		if (getchoice (0, " Delete ", buf, NULL, " Delete ", " Cancel ", NULL))
			return;
		sprintf (buf, "You are DELETING %d selected file%s from", c, c>1 ? "s" : "");
		if (getchoice (1, " Delete ", buf, cur->d.cwd, " Ok ", " Cancel ", NULL))
			return;
		for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p)
			if (p->tag && unlink (p->name) < 0)
				error ("Cannot delete %s", p->name);
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* delete directory */

		if (getchoice (0, " Delete ", "Do you wish to delete directory",
		    p->name, " Delete ", " Cancel ", NULL))
			return;
		if (runl(1, "/bin/rmdir", "rmdir", p->name, NULL)) {
			error ("Cannot delete directory %s", p->name);
			return;
		}
	} else if (c == S_IFREG) {
		/* delete regular file */

		if (getchoice (0, " Delete ", "Do you wish to delete",
		    p->name, " Delete ", " Cancel ", NULL))
			return;
		if (unlink (p->name) < 0) {
			error ("Cannot delete %s", p->name);
			return;
		}
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
}
int main(void)
{
	const unsigned short MainCycle = 60;
	Init(MainCycle);

	LED(3);

	int i;
	for(;;)
	{
		if(ADRead(LEFT_EYE)>BLACK){
			if(ADRead(RIGHT_EYE)>BLACK){
				break;
			}
			else{
				LED(2);
				runl();
			}
		}
		else{
			if(ADRead(RIGHT_EYE)>BLACK){
			LED(1);
			runr();
			}
			else{
				LED(3);
				run();
			}
		}


	}

	Mtr_Run_lv(0, 0, 0, 0, 0, 0);


	return 0;

}
Exemple #5
0
/* main, menu */
void makedir (void) {
	register char *p;

	if (! (p = getstring (60, NULL, " Make directory ", "Create the directory")))
		return;
	switch (exist (p)) {
	default:
	case 'f':
		error ("File %s exists", p);
		break;
	case 'd':
		error ("Directory %s already exists", p);
		break;
	case 0:
		if (runl(1, "/bin/mkdir", "mkdir", p, NULL)) {
			error ("Cannot create directory %s", p);
			break;
		}
		setdir (cur == left ? right : left, NULL);
		setdir (cur, NULL);
		findfile (cur, p);
		break;
	}
}
Exemple #6
0
/* main, menu */
void renmove (void) {
	char buf [MAXPATHLEN+20];
	char *name;
	register struct file *p;
	register c;
	int done, all, ch;
	int exd, exf;

	if (c = tagged ()) {
		/* move group of files */

		sprintf (buf, "Rename or move %d file%s to", c, c>1 ? "s" : "");
		if (! (name = getstring (60, (cur==left?right:left)->cwd,
		    " Rename ", buf)))
			return;
		runset (name);
		exd = exist (name);
		all = 0;
		for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p)
			if (p->tag) {
				sprintf (buf, "%s/%s", name, p->name);
				exf = exd=='d' ? exist (buf) : 0;
				if (exd=='f' || exf=='f') {
					if (! all) {
						ch = getchoice (1, " Rename ", "File exists",
							exf=='f' ? buf : name,
							" Overwrite ", " All ", " Cancel ");
						switch (ch) {
						default:
						case 2:         /* cancel */
							continue;
						case 1:         /* all */
							all = 1;
						}
					}
				} else if (exf == 'd') {
					error ("%s is a directory", buf);
					continue;
				}
				runarg (p->name);
			}
		message (" Move ", "Moving %d file%s to %s ...", c, c>1 ? "s" : "", name);
		done = rundone ("/bin/mv", "mv");
		if (done) {
			endmesg ();
			message (" Move ", "Done");
		} else
			error ("Error while moving %d file%s to %s",
				c, c>1 ? "s" : "", name);
		endmesg ();
		name = 0;
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* rename directory */

		sprintf (buf, "Rename \"%s\" to", strtail (p->name, '/', 60));
		if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf)))
			return;
		exd = exist (name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Rename ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("Directory %s exists", buf);
			return;
		}
		if (runl(1, "/bin/mv", "mv", p->name, name, NULL)) {
			error ("Cannot move %s to %s", p->name, name);
			return;
		}
	} else if (c == S_IFREG) {
		/* move regular file */

		sprintf (buf, "Rename or move \"%s\" to", p->name);
		if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf)))
			return;
		exd = exist (name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Rename ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("%s is a directory", buf);
			return;
		}
		if (runl(1, "/bin/mv", "mv", p->name, name, NULL)) {
			error ("Cannot move %s to %s", p->name, name);
			return;
		}
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
	if (name)
		findfile (cur, name);
}
Exemple #7
0
/* menu */
void makeslink (void) {
	char buf [80];
	char *name;
	register struct file *p;
	register c;
	int done;
	int exd, exf;

	if (c = tagged ()) {
		/* symlink group of files */

		sprintf (buf, "Symlink %d file%s to", c, c>1 ? "s" : "");
		if (! (name = getstring (60, (cur==left?right:left)->cwd,
		    " Symlink ", buf)))
			return;
		runset (name);
		exd = exist (name);
		for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p)
			if (p->tag) {
				sprintf (buf, "%s/%s", name, p->name);
				exf = exd=='d' ? exist (buf) : 0;
				if (exd=='f' || exf=='f') {
					if (getchoice (1, " Symlink ", "File exists",
					    exf=='f' ? buf : name,
					    " Overwrite ", " Cancel ", NULL))
						continue;
				} else if (exf == 'd') {
					error ("%s is a directory", buf);
					continue;
				}
				runarg (p->name);
				p->tag = 0;
			}
		runarg ("-s");
		message (" Symlink ", "Linking %d file%s to %s ...", c, c>1 ? "s" : "", name);
		done = rundone ("/bin/ln", "ln");
		if (done) {
			endmesg ();
			message (" Symlink ", "Done");
		} else
			error ("Error while linking %d file%s to %s",
				c, c>1 ? "s" : "", name);
		endmesg ();
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* symlinking directory */
	} else if (c == S_IFREG) {
		/* symlink regular file */

		sprintf (buf, "Symlink \"%s\" to", p->name);
		if (! (name = getstring (60, (cur==left?right:left)->cwd, " Symlink ", buf)))
			return;
		exd = exist (name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Symlink ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("%s is a directory", buf);
			return;
		}
		if (runl(1, "/bin/ln", "ln", "-s", p->name, name, NULL)) {
			error ("Cannot symlink %s to %s", p->name, name);
			return;
		}
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
}