📄 shell_common.c
字号:
///////////////////////////////////////////////////////////////////////////////////
#include "general.h"
#include "s_isdirreg.h"
#include "the_syscalls.h"
#include "shell_head.h"
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
void check_cmdline(void)
{
int temp_index;
for (temp_index = command_ret - 1; temp_index >= 0; temp_index--)
if (command_buf[temp_index] == 0x20)
command_buf[temp_index + 2] = 0;
else
command_buf[temp_index + 2] = command_buf[temp_index];
command_buf[0] = command_buf[1] = command_buf[command_ret + 2] = 0;
//////////////////////////////////
for (temp_index = 0; temp_index <= command_ret + 2; temp_index++)
command_buf0[temp_index] = command_buf[temp_index];
while (temp_index < 256)
{
command_buf0[temp_index] = 0;
temp_index++;
}
//////////////////////////////////
command_index = 0;
command_params= 0;
temp_index = command_ret + 2;
while (temp_index >= 0)
{
while ((temp_index >= 0) && (command_buf[temp_index] == 0))
temp_index--;
while ((temp_index >= 0) && command_buf[temp_index])
temp_index--;
if (temp_index >= 0)
{
command_buf[temp_index] = command_index;
command_index = temp_index;
command_params++;
}
temp_index--;
}
return;
}
///////////////////////////////////////////////////////////////////////////////////
void show_Dirs_Files(int cur_line)
{
int j, temp_flag;
unsigned long temp_size,temp_datetime;
for (j = 0; j < NAME_LEN; j++)
path0_buf[j + 6] = dir_buffer[cur_line * (NAME_LEN + 9) + j];
if (shell_driver)
temp_flag = S_ISDIR(dir_buffer[cur_line * (NAME_LEN + 9) + NAME_LEN]);
else
temp_flag = S_MSDOS_ISDIR(dir_buffer[cur_line * (NAME_LEN + 9) + NAME_LEN]);
j = 0;
while ((j < NAME_LEN) && path0_buf[j + 6])
j++;
while (j < NAME_LEN + 3)
{
path0_buf[j + 6] = 0x20;
j++;
}
if (temp_flag)
{
show_string("<DIR>" ,path0_buf + NAME_LEN + 9);
shell_nrDirs++;
}
else
{
show_string(" ",path0_buf + NAME_LEN + 9);
temp_datetime = *((unsigned long *)(dir_buffer + cur_line * (NAME_LEN + 9) + NAME_LEN + 1));
temp_size = *((unsigned long *)(dir_buffer + cur_line * (NAME_LEN + 9) + NAME_LEN + 5));
show_size_datetime(temp_size, temp_datetime, path0_buf + NAME_LEN + 15);
shell_nrFiles++;
}
the_screen_call18(path0_buf);
return;
}
///////////////////////////////////////////////////////////////////////////////////
void show_nrDirs_nrFiles(void)
{
show_string("" ,path0_buf + 6);
the_screen_call18(path0_buf);
show_number(shell_nrDirs ,path0_buf + 6);
show_string(" Dir(s)" ,path0_buf + 13);
the_screen_call18(path0_buf);
show_number(shell_nrFiles ,path0_buf + 6);
show_string(" File(s)" ,path0_buf + 13);
the_screen_call18(path0_buf);
show_string("" ,path0_buf + 6);
the_screen_call18(path0_buf);
return;
}
///////////////////////////////////////////////////////////////////////////////////
void show_size_datetime(unsigned long size, unsigned long datetime, unsigned char * buf)
{
unsigned char * temp_pChar;
unsigned long temp_long;
unsigned char temp_char0,temp_char1;
temp_pChar = buf;
show_number(size,temp_pChar);
temp_pChar = temp_pChar + 7;
*temp_pChar++ = 0x20;
*temp_pChar++ = 0x20;
*temp_pChar++ = 0x20;
////////////////////////////////////////
temp_long = (datetime >> 21) & 0x0f;
temp_char0 = (temp_long / 10) + 0x30;
temp_char1 = (temp_long % 10) + 0x30;
*temp_pChar++ = temp_char0;
*temp_pChar++ = temp_char1;
*temp_pChar++ = '-';
////////////////////////////////////////
temp_long = (datetime >> 16) & 0x1f;
temp_char0 = (temp_long / 10) + 0x30;
temp_char1 = (temp_long % 10) + 0x30;
*temp_pChar++ = temp_char0;
*temp_pChar++ = temp_char1;
*temp_pChar++ = '-';
////////////////////////////////////////
temp_long = (datetime >> 25) & 0x7f;
temp_long = (temp_long + 80) % 100;
temp_char0 = (temp_long / 10) + 0x30;
temp_char1 = (temp_long % 10) + 0x30;
*temp_pChar++ = temp_char0;
*temp_pChar++ = temp_char1;
*temp_pChar++ = ' ';
////////////////////////////////////////
temp_long = (datetime >> 11) & 0x1f;
temp_char0 = (temp_long / 10) + 0x30;
temp_char1 = (temp_long % 10) + 0x30;
*temp_pChar++ = temp_char0;
*temp_pChar++ = temp_char1;
*temp_pChar++ = ':';
////////////////////////////////////////
temp_long = (datetime >> 5) & 0x3f;
temp_char0 = (temp_long / 10) + 0x30;
temp_char1 = (temp_long % 10) + 0x30;
*temp_pChar++ = temp_char0;
*temp_pChar++ = temp_char1;
*temp_pChar++ = 0;
////////////////////////////////////////
return;
}
///////////////////////////////////////////////////////////////////////////////////
void show_number(unsigned long number, unsigned char * buf)
{
unsigned char * temp_pChar, * temp_pChar0;
temp_pChar = buf + 6;
*temp_pChar-- = number % 10;
number = number / 10;
*temp_pChar-- = number % 10;
number = number / 10;
*temp_pChar-- = number % 10;
number = number / 10;
*temp_pChar-- = number % 10;
number = number / 10;
*temp_pChar-- = number % 10;
number = number / 10;
*temp_pChar-- = number % 10;
number = number / 10;
*temp_pChar-- = number % 10;
number = number / 10;
temp_pChar = buf;
temp_pChar0 = buf + 5;
while ((temp_pChar <= temp_pChar0) && (*temp_pChar == 0))
{
*temp_pChar = 0x20;
temp_pChar++;
}
temp_pChar0++;
while (temp_pChar <= temp_pChar0)
{
*temp_pChar = *temp_pChar + 0x30;
temp_pChar++;
}
return;
}
///////////////////////////////////////////////////////////////////////////////////
void show_string(const char * str, unsigned char * buf)
{
while (*str)
*buf++ = *str++;
*buf++ = 0;
return;
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -