Пример #1
0
int cmd_touch(char file[])
{

    kol_struct70	k70;
    char		temp[256];
    unsigned	result;

    if (NULL == file)
    {
#if LANG_ENG
        printf("  touch <filename>\n\r");
#elif LANG_RUS
        printf("  touch <имя файла>\n\r");
#endif
        return TRUE;
    }

    if (  ( 0 == strcmp(file, ".") ) || ( 0 == strcmp(file, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
    {
        return FALSE;
    }

    if ( '/' == file[0])
    {
        strcpy(temp, file);

        if ( !file_check(temp) )
            k70.p00 = 2;
        else
            k70.p00 = 3;
    }
    else
    {
        strcpy(temp, cur_dir);
        strcat(temp, file);
        if ( !file_check(temp) )
            k70.p00 = 2;
        else
            k70.p00 = 3;
    }

    k70.p04 = 0;
    k70.p08 = 0;
    k70.p12 = 0;
    k70.p16 = 0;
    k70.p20 = 0;
    k70.p21 = temp;

    result = kol_file_70(&k70);

    if (0 == result)
        return TRUE;
    else
        return FALSE;

}
Пример #2
0
int cmd_rm(char file[])
{

kol_struct70	k70;
char		temp[256];
unsigned	result;

if (NULL == file)
	{
	#if LANG_ENG
		printf ("  rm <filename>\n\r");
	#elif LANG_RUS
		printf ("  rm <имя файла>\n\r");
	#endif
	return TRUE;
	}

if ( '/' == file[0])
	{
	strcpy(temp, file);

	if ( !file_check(temp) )
		{
		return FALSE;
		}
	}
else 
	{
	strcpy(temp, cur_dir);
	strcat(temp, file);
	
	if ( !file_check(temp) )
		{
		return FALSE;
		}
	}

k70.p00 = 8;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
k70.p21 = temp;

result = kol_file_70(&k70);

if (0 == result)
	return TRUE;
else 
	return FALSE;

}
Пример #3
0
void all_print(Z80Regs *regs, char *filename)
{
kol_struct70 file;

file.p00 = 2;
file.p04 = 0;
file.p08 = 0;
file.p12 = sizeof (Z80Regs);
file.p16 = (unsigned)regs;
file.p20 = 0;
file.p21 = filename;

kol_file_70(&file);
}
Пример #4
0
void memory_print(Z80Regs *regs, char *filename)
{
kol_struct70 file;

file.p00 = 2;
file.p04 = 0;
file.p08 = 0;
file.p12 = 64*1024;
file.p16 = (unsigned)(regs->RAM);
file.p20 = 0;
file.p21 = filename;

kol_file_70(&file);
}
Пример #5
0
int cmd_ls(char dir[])
{

kol_struct70	k70;
unsigned	*n;
unsigned	num_of_file;
unsigned	*t;
unsigned	type_of_file;
int		i, result;


k70.p00 = 1;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 10000; 
k70.p16 =  (unsigned) malloc(32+k70.p12*560);
k70.p20 = 0;

/// !!!
// Если ls запускается без параметров, просматриваем текущий каталог
if ( !strlen(dir) )
	k70.p21 = cur_dir;
else
	k70.p21 = dir;

result = kol_file_70(&k70);
if ( !((result==0) || (result==6)) ) // проверяем существование каталога
	{
	free( (void*) k70.p16);
	return FALSE;
	}

n =  (unsigned*) (k70.p16+8);
num_of_file = *n; // число файлов в каталоге

for (i = 0; i < num_of_file; i++)
	{
	printf ("  %s", k70.p16+32+40+(264+40)*i);
	t =  (unsigned*) (k70.p16+32+(264+40)*i);
	type_of_file = *t;
	if ( (0x10 == (type_of_file&0x10)) || (8 == (type_of_file&8)) )
		printf ("/");
	printf ("\n\r");
	}

free((void*)k70.p16);
return TRUE;
}
Пример #6
0
int script_check(char file[])
{

kol_struct70	k70;
char		buf[4];

k70.p00 = 0;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 4; // читать 4 байта
k70.p16 = (unsigned) buf;
k70.p20 = 0;
k70.p21 = file;

kol_file_70(&k70);

if ( !strcmp(buf, script_sign) )
	return TRUE;
else
	return FALSE;
}
Пример #7
0
int script_run(char exec[], char args[])
{

kol_struct70	k70;
kol_struct_BDVK	bdvk;
unsigned	result, filesize, pos, i;
char		*buf; //буфер, куда копируется скрипт

k70.p00 = 5;
k70.p04 = k70.p08 = k70.p12 = 0;
k70.p16 = (unsigned) &bdvk;
k70.p20 = 0;
k70.p21 = exec;

result = kol_file_70(&k70); // получаем информацию о файле
if ( 0 != result ) 
	return FALSE;

filesize = bdvk.p32[0]; // получаем размер файла

buf = malloc(filesize+256);
if (NULL == buf)
	return FALSE;

buf[filesize]=0;

k70.p00 = 0;
k70.p04 = k70.p08 = 0;
k70.p12 = filesize;
k70.p16 = (unsigned) buf;
k70.p20 = 0;
k70.p21 = exec;

result = kol_file_70(&k70); // считываем файл в буфер
if ( 0 != result ) 
	{
	free(buf);
	return FALSE;
	}

pos = 0;

for (;;) // обработка скрипта
	{

	if (pos > filesize)
		break;

	for (i=0;;i++) // считывание строки
		{
		if ((0x0A == buf[pos])||(0x0D == buf[pos])||(0 == buf[pos]))
			{
			pos++;
			CMD[i] = '\0';
			break;
			}
		CMD[i] = buf[pos];
		pos++;
		}

	if ( 0 == strlen(CMD) ) // пустая строка
		continue;

	if ('#' == CMD[0]) // комментарий
		continue;

	command_execute();

	}

free(buf);
return TRUE;
}
Пример #8
0
int cmd_more(char file[])
{

kol_struct70	k70;
kol_struct_BDVK	bdvk;
unsigned	result, filesize, pos, i;
char		buf[81]; //буфер
char		temp[256];
unsigned	flags;

if (strlen(file)<1)
	{
	#if LANG_ENG
		printf ("  more <filename>\n\r");
	#elif LANG_RUS
		printf ("  more <имя файла>\n\r");
	#endif
	return TRUE;
	}

if ( '/' == file[0])
	{
	strcpy(temp, file);

	if ( !file_check(temp) )
		{
		file_not_found(file);
		return FALSE;
		}
	}
else
	{
	strcpy(temp, cur_dir);
	if (temp[strlen(temp)-1] != '/') 
		strcat(temp, "/"); // add slash
	strcat(temp, file);
	
	if ( !file_check(temp) )
		{
		file_not_found(file);
		return FALSE;
		}
	}

k70.p00 = 5;
k70.p04 = k70.p08 = k70.p12 = 0;
k70.p16 = (unsigned) &bdvk;
k70.p20 = 0;
k70.p21 = temp;

result = kol_file_70(&k70); // получаем информацию о файле
if ( 0 != result ) 
	return FALSE;

filesize = bdvk.p32[0]; // получаем размер файла

buf[80]=0;
flags = con_get_flags();

for (pos=0;pos<filesize;pos+=80)
	{

	memset(buf, 0, 80);

	k70.p00 = 0;
	k70.p04 = pos;
	k70.p08 = 0;
	k70.p12 = 80;
	k70.p16 = (unsigned) buf;
	k70.p20 = 0;
	k70.p21 = temp;

	result = kol_file_70(&k70); // чтение 80 символов
	for (i=0; i<80; i++)
		{

		if (27 == buf[i])
			con_set_flags(flags|0x100);
		else con_set_flags(flags);

		printf ("%c", buf[i]);
		}
	if ( 0 != result ) 
		{
		con_set_flags(flags);
		printf ("\n\r");
		return TRUE;	
		}

	}
con_set_flags(flags);
printf ("\n\r");
return TRUE;
}