Ejemplo n.º 1
0
char * getKey(void) {
	int i = 0;
	char * ret = (char *) Malloc(MAX_BUFFER);
	if (terminals[getTTY()].insertShellBuffer == 0) {
		if (getPID() == terminals[getTTY()].foregroundProcess) {
			terminals[getTTY()].blockedPID = getPID();
		}
		block();
	}
	for (; i < terminals[tty].insertShellBuffer; i++) {
		ret[i] = terminals[tty].shellBuffer[i];
	}
	ret[i] = '\0';
	cleanShellBuffer();
	return ret;
}
Ejemplo n.º 2
0
void clear_screen() {
	int procTerm = getTTY();
	if (procTerm == tty)
		k_clear_screen((unsigned char *) 0xB8000);
	else
		k_clear_screen((unsigned char *) terminals[procTerm].video);
	terminals[procTerm].cursorPos = 0;
}
Ejemplo n.º 3
0
void main(int argc, char *argv[])
{
	int opt, noauth = 0;
	char cmdline[1024], *str;

	while ((opt  = getopt(argc, argv, "f")) != EOF)
		switch (opt) {
		case 'f':
			noauth = 1;
			break;
		}
	dup2(0, 1);
	dup2(0, 2);
	net = 1;
	fgets((char *)&cmdline, 1024, stdin);
	if ((str = strtok((char *)&cmdline, " \n\t\v\r")) == NULL)
		help();
	(void)makeaddr(&from, str);
	if ((str = strtok((char *)NULL, " \n\t\v\r")) == NULL)
		help();
	(void)makeaddr(&to, str);
	if ((str = strtok((char *)NULL, " \n\t\v\r")) != NULL)
		(void)strncpy((char *)&to.pe_tty, str, UT_LINESIZE);
	if (to.pe_host == NULL) 
		if (getTTY(&to) == -1)
			exit(1);
	if (strncmp(from.pe_user, "", UT_NAMESIZE) == 0 || from.pe_host ==
	    NULL || strncmp(from.pe_tty, "", UT_LINESIZE) == 0)
		help();
	if (ident(0, &auth) == 0)
		exit(loop(&from, &to, &auth));
	else 
		if (noauth == 0)
			exit(loop(&from, &to, (struct person *)NULL));
		else
			fprintf(stderr, "write: You cannot be authenticated\n");
	exit(1);
}
Ejemplo n.º 4
0
void terminalPrint(char *data) {

	//Returns the terminal in which the actual process is running
	int where = getTTY();
	int * pos = &(terminals[where].cursorPos);
	unsigned char * dirVideo = (unsigned char *) 0xB8000;
	if (interrupt) {
		dirVideo = (unsigned char *) 0xB8000;
		pos = &(terminals[tty].cursorPos);
	} else if (where == tty) {
		dirVideo = (unsigned char *) 0xB8000;
	} else {
		dirVideo = terminals[where].video;
	}
	if ((*data) == 0x08) { // Backspace
		char c = ' ';
		print(&c, (*pos) - 2, dirVideo);
		(*pos) -= 2;
		(*pos) = ((*pos) < 0 ? 0 : (*pos));
	} else if ((*data) == '\n') { // Enter
		char c = ' ';
		int scroll;
		(*pos) = ((*pos) + (160 - ((*pos) % 160)));
		scroll = print(&c, (*pos), dirVideo);
		if (scroll) {
			(*pos) = 80 * 24 * 2;
		}
	} else if ((*data) != 0x09) { //Tab
		int scroll;
		scroll = print(data, (*pos), dirVideo);
		(*pos) += 2;
		if (scroll) {
			(*pos) = 80 * 24 * 2;
		}
	}
}
Ejemplo n.º 5
0
void logout() {
	terminals[getTTY()].user = NULL;
}
Ejemplo n.º 6
0
void setUserToTerm(char * userName) {
	terminals[getTTY()].user = userName;
}
Ejemplo n.º 7
0
char * getTTYUser() {
	return terminals[getTTY()].user;
}
Ejemplo n.º 8
0
void setForegroundProcess(int PID) {
	terminals[getTTY()].foregroundProcess = PID;
}