forked from KolibriOS/kolibrios
SHELL 0.8.2
- big refactoring, now uses libc.obj - added kfetch command git-svn-id: svn://kolibrios.org@8827 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
112c948922
commit
68cf3e4293
@ -1,17 +0,0 @@
|
|||||||
all:
|
|
||||||
fasm start.asm start.o
|
|
||||||
kos32-gcc -c -fno-builtin shell.c
|
|
||||||
kos32-gcc -c -fno-builtin system/kolibri.c
|
|
||||||
kos32-gcc -c -fno-builtin system/stdlib.c
|
|
||||||
kos32-gcc -c -fno-builtin system/string.c
|
|
||||||
kos32-gcc -c -fno-builtin system/ctype.c
|
|
||||||
kos32-ld -nostdlib -T kolibri.ld -o shell start.o kolibri.o stdlib.o string.o ctype.o shell.o
|
|
||||||
kos32-objcopy shell -O binary
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o
|
|
||||||
rm -f bin/rus/shell
|
|
||||||
rm -f bin/eng/shell
|
|
||||||
|
|
||||||
install:
|
|
||||||
cp shell $(DIR)
|
|
@ -1,228 +1,267 @@
|
|||||||
|
Shell 0.8.2 // 13.06.2021 // rgimad
|
||||||
|
* use libj.obj instead of built-in "libc"
|
||||||
|
* big refactoring:
|
||||||
|
- fix indentation
|
||||||
|
- string constants moved to locale/.../globals.h files
|
||||||
|
* add new command - kfetch
|
||||||
|
it is like neofetch for KolibriOS
|
||||||
|
prints logo and main system information.
|
||||||
|
* other fixes
|
||||||
|
|
||||||
|
Shell 0.8.1 // 14.04.2020 - 01.04.2021 // rgimad, turbocat, Kenshin
|
||||||
|
rgimad:
|
||||||
|
* fixed bug with ctrl+v
|
||||||
|
* added navigation in current string by Home, End
|
||||||
|
* directory highlighting in ls command output
|
||||||
|
* Now for incorrect scripts (which doesnt start with #SHS) shell says
|
||||||
|
that they are incorrect, not "File not found".
|
||||||
|
Also, translated comments from russian to english in two files.
|
||||||
|
* added mv command
|
||||||
|
* added ren command
|
||||||
|
* now ls works also with relative pathes
|
||||||
|
* fixed bug in strrchr
|
||||||
|
* fixed bug with cd ../
|
||||||
|
* fixed cd . and cd ./ behavior
|
||||||
|
* added output redirection to file (> >>) for echo command
|
||||||
|
e.g. echo "<html>">123.txt ; echo a b c >> y.txt
|
||||||
|
|
||||||
|
turbocat:
|
||||||
|
* Added new API: SC_GET_PID
|
||||||
|
* Fixed data type pid - unsigned int.
|
||||||
|
* Fixed cmd_ps output pid;
|
||||||
|
* Added new SC_PING api
|
||||||
|
* Renamed from SC_GET_PID to SC_PID
|
||||||
|
* added pkill command
|
||||||
|
|
||||||
|
Kenshin:
|
||||||
|
* shell.inc now suports sc_ping & sc_pid functions
|
||||||
|
* update docs
|
||||||
|
|
||||||
Shell 0.7.7 // 06.02.2017 // Leency
|
Shell 0.7.7 // 06.02.2017 // Leency
|
||||||
* help ⥯¥àì ¢ë¢®¤¨â ᯨ᮪ ª®¬¬ ¤ ¢ âਠª®«®ª¨
|
* help теперь выводит список комманд в три колонки
|
||||||
* ps ⥯¥àì ¢ë¢®¤¨â à §¬¥à Ž‡“, ¨á¯®«ì§ã¥¬ë© ¯à®æ¥áᮬ
|
* ps теперь выводит размер ОЗУ, используемый процессом
|
||||||
* ls ⥯¥àì ¢ë¢®¤¨â ¢á¥ ä ©«ë ¥ ¢ ®¤ã, ¢ ¥áª®«ìª® ª®«®®ª
|
* ls теперь выводит все файлы не в одну, а в несколько колонок
|
||||||
à §¬¥à ª®«®®ª à áç¨âë¢ ¥âáï ¨áå®¤ï ¨§ á ¬®£® ¤«¨®£® ¨¬¥¨ ä ©« ¢ ¯ ¯ª¥
|
размер колонок расчитывается исходя из самого длинного имени файла в папке
|
||||||
áâ àë© ¢ë¢®¤ ᯨ᪮¬ ¯® ¯à¥¦¥¬ã ¤®áâ㯥 ç¥à¥§ ª«îç '-1'
|
старый вывод списком по прежнему доступен через ключ '-1'
|
||||||
|
|
||||||
Shell 0.7.6 // 06.02.2017 // Siemargl
|
Shell 0.7.6 // 06.02.2017 // Siemargl
|
||||||
* ” ©«®¢ë¥ ®¯¥à 樨 ¨á¯®«ì§ãîâ 64-bit à §¬¥àë ä ©«®¢.
|
* Файловые операции используют 64-bit размеры файлов.
|
||||||
cp <file> <dest> ⥯¥àì ¯®¨¬ ¥â, ¥á«¨ <dest> - ª â «®£
|
cp <file> <dest> теперь понимает, если <dest> - каталог
|
||||||
cp ¨á¯®«ì§ã¥â ¡ãä¥à 1Œ¡, ¨«¨ ¥ ¡®«¥¥ ¯®«®¢¨ë ᢮¡®¤®© ¯ ¬ïâ¨
|
cp использует буфер 1Мб, или не более половины свободной памяти
|
||||||
|
|
||||||
Shell 0.7.5 // 06.01.2017 // Siemargl
|
Shell 0.7.5 // 06.01.2017 // Siemargl
|
||||||
* Œ¥«ª¨¥ ¡ £ä¨ªáë, ¨§¬¥¥ «®£¨ª ®¡à ¡®âª¨ áâ५®ª ¢¢¥àå/¢¨§, çâ®¡ë ª ª ã ¢á¥å
|
* Мелкие багфиксы, изменена логика обработки стрелок вверх/вниз, чтобы как у всех
|
||||||
„®¡ ¢«¥ ª®¬ ¤ waitfor ¨ ¢ ਠâ ps á ¯ à ¬¥â஬
|
Добавлена команда waitfor и вариант ps с параметром
|
||||||
|
|
||||||
Shell 0.7.4 // 23.01.2014 // Albom
|
Shell 0.7.4 // 23.01.2014 // Albom
|
||||||
* <20> ¡®â á ¡ãä¥à®¬ ®¡¬¥ (ª®¯¨à®¢ ¨¥ Ctrl+C ¨ ¢áâ ¢ª Ctrl+V áâப¨ 楫¨ª®¬)
|
* Работа с буфером обмена (копирование Ctrl+C и вставка Ctrl+V строки целиком)
|
||||||
|
|
||||||
|
|
||||||
Shell 0.7.3 // 28.11.2013 // Albom
|
Shell 0.7.3 // 28.11.2013 // Albom
|
||||||
* ˆá¯à ¢«¥ ®è¨¡ª á ᨬ¢®«®¬ % ¢ ¨áâ®à¨¨ ª®¬ ¤
|
* Исправлена ошибка с символом % в истории команд
|
||||||
|
|
||||||
|
|
||||||
Shell 0.7.2 // 26.10.2013 // Albom
|
Shell 0.7.2 // 26.10.2013 // Albom
|
||||||
* ” ©« .shell ¯¥à¥¥á¥ ¢ /sys/settings/
|
* Файл .shell перенесен в /sys/settings/
|
||||||
* ˆá¯à ¢«¥ ª®¬ ¤ "cd .."
|
* Исправлена команда "cd .."
|
||||||
|
|
||||||
|
|
||||||
Shell 0.7.1 // 19.10.2013 // Albom
|
Shell 0.7.1 // 19.10.2013 // Albom
|
||||||
* ˆá¯à ¢«¥ ®è¨¡ª , á¢ï§ ï á § ¢¨á ¨¥¬ ¯à¨ ¯®¯ë⪥ çâ¥¨ï ¯ãá⮩ ¨áâ®à¨¨ ª®¬ ¤ (¯® ª« ¢¨è ¬ Up ¨ Down)
|
* Исправлена ошибка, связанная с зависанием при попытке чтения пустой истории команд (по клавишам Up и Down)
|
||||||
|
|
||||||
|
|
||||||
Shell 0.7.0 // 13.10.2013 // Albom
|
Shell 0.7.0 // 13.10.2013 // Albom
|
||||||
* <20>¥à¥à ¡®â ¬®¤ã«ì ¢¢®¤ ª®¬ ¤ë (¤®¡ ¢«¥ ®¡à ¡®âª ª« ¢¨è "¢«¥¢®", "¢¯à ¢®", Del)
|
* Переработан модуль ввода команды (добавлена обработка клавиш "влево", "вправо", Del)
|
||||||
* Œ¥«ª¨¥ ¨á¯à ¢«¥¨ï
|
* Мелкие исправления
|
||||||
|
|
||||||
|
|
||||||
Shell 0.6.4 // 09.10.2013 // Leency
|
Shell 0.6.4 // 09.10.2013 // Leency
|
||||||
* <EFBFBD>®¤¤¥à¦ª ®â®á¨â¥«ìëå ¯ã⥩ ¢ áªà¨¯â å
|
* Поддержка относительных путей в скриптах
|
||||||
|
|
||||||
|
|
||||||
Shell 0.6.3 // 20.09.2013 // Albom
|
Shell 0.6.3 // 20.09.2013 // Albom
|
||||||
* msvc-style âਡãâë ¤«ï ®âª«îç¥¨ï ¢ëà ¢¨¢ ¨ï ¢ áâàãªâãà å (ᯠᨡ® CleverMouse ¨ Kirakishou!)
|
* msvc-style атрибуты для отключения выравнивания в структурах (спасибо CleverMouse и Kirakishou!)
|
||||||
|
|
||||||
|
|
||||||
Shell 0.6.2 // 24.02.2013 // Albom
|
Shell 0.6.2 // 24.02.2013 // Albom
|
||||||
* „®¡ ¢«¥ ®¡à ¡®âª ã¯à ¢«ïîé¨å ᨬ¢®«®¢ (\n, \t, \", \', \\, \?)
|
* Добавлена обработка управляющих символов (\n, \t, \", \', \\, \?)
|
||||||
* Œ¥«ª¨¥ ¨á¯à ¢«¥¨ï
|
* Мелкие исправления
|
||||||
|
|
||||||
|
|
||||||
Shell 0.6.1 // 17.02.2013 // Albom
|
Shell 0.6.1 // 17.02.2013 // Albom
|
||||||
* <EFBFBD>à®áâ ï ®¡à ¡®âª ®è¨¡®ª ¢ãâà¥¨å ª®¬ ¤
|
* Простая обработка ошибок внутренних команд
|
||||||
* Š®¬ ¤ killall âà áä®à¬¨à®¢ ¢ ¯ à ¬¥âà all ª®¬ ¤ë kill
|
* Команда killall трансформирована в параметр all команды kill
|
||||||
* ˆ§¬¥¥ ª®¤¨à®¢ª ä ©« History.txt á 1251 866
|
* Изменена кодировка файла History.txt с 1251 на 866
|
||||||
|
|
||||||
|
|
||||||
Shell 0.6 // 16.02.2013 // Albom
|
Shell 0.6 // 16.02.2013 // Albom
|
||||||
+ „®¡ ¢«¥ ¢®§¬®¦®áâì § ¯ã᪠âì ¯à®£à ¬¬ë, ¨¬¥ ª®â®àëå ¨«¨ ¯ãâì ª ª®â®àë¬ á®¤¥à¦ ⠯஡¥«ë. ˆ¬ï ¯à®£à ¬¬ë (¢®§¬®¦® á ¯ãâñ¬ ª ¥©) ¤«ï í⮣® ¥®¡å®¤¨¬® § ª«îç âì ¢ ª ¢ë窨. ’.¥. ª®¥æ-â® ¬®¦® § ¯ãáâ¨âì ¯à®£à ¬¬ã ¨§ /rd/1/File managers, ¥ ¯¥à¥å®¤ï ¢ ¥ñ
|
+ Добавлена возможность запускать программы, имена которых или путь к которым содержат пробелы. Имя программы (возможно с путём к ней) для этого необходимо заключать в кавычки. Т.е. наконец-то можно запустить программу из /rd/1/File managers, не переходя в неё
|
||||||
+ „®¡ ¢«¥ äãªæ¨ï à §¤¥«¥¨ï áâப®¢®© ¯¥à¥¬¥®© int argc, char* argv[], çâ® ®§ ç ¥â ¢®§¬®¦®áâì ã«ãçè¥¨ï ª®¬ ¤ (®¡à ¡®âª ¥áª®«ìª¨å ¯ à ¬¥â஢)
|
+ Добавлена функция разделения строковой переменной на int argc, char* argv[], что означает возможность улучшения команд (обработка нескольких параметров)
|
||||||
+ „®¡ ¢«¥ ª®¬ ¤ cp (ª®¯¨à®¢ ¨¥ ä ©« ). <20>ਨ¬ ¥â ®¡ï§ â¥«ì® ¤¢ ¯ à ¬¥âà - ¨¬ï ä ©« -¨áâ®ç¨ª ¨ ¨¬ï ä ©« -१ã«ìâ â . ˆ¬¥ ¬®£ãâ ¡ëâì ªà ⪨¬¨ (¢ ⥪ã饬 ª â «®£¥), â ª ¨ á ¯®«ë¬ ¯ãâñ¬ (¤®«¦ë ç¨ âìáï á /). Ž£à ¨ç¥¨¥ à §¬¥à ä ©« - 4 ƒ¡ ©â
|
+ Добавлена команда cp (копирование файла). Принимает обязательно два параметра - имя файла-источника и имя файла-результата. Имена могут быть краткими (в текущем каталоге), так и с полным путём (должны начинаться с /). Ограничение на размер файла - 4 Гбайта
|
||||||
* ˆá¯à ¢«¥ ª®¤¨à®¢ª ¢ á®®¡é¥¨¨ ®¡ ®è¨¡ª¥ ¢ ª®á®«ì®¬ ¯à¨«®¦¥¨¨
|
* Исправлена кодировка в сообщении об ошибке в консольном приложении
|
||||||
* Š« ¢¨è¨ ¨áâ®à¨¨ (¢¢¥àå ¨ ¢¨§) ¯®¬¥ïë ¬¥¦¤ã ᮡ®©
|
* Клавиши истории (вверх и вниз) поменяны между собой
|
||||||
* Š®«¨ç¥á⢮ ª®¬ ¤ ¢ ¨áâ®à¨¨ 㢥«¨ç¥® á ¯ï⨠¤® ¤¥áïâ¨
|
* Количество команд в истории увеличено с пяти до десяти
|
||||||
* “¬¥ì襮 ª®«¨ç¥á⢮ ¯à¥¤ã¯à¥¦¤¥¨© ¯à¨ ª®¬¯¨«ï樨
|
* Уменьшено количество предупреждений при компиляции
|
||||||
* Š®¬ ¤ ccpuid ¯à¥®¡à §®¢ ¢ ¯ à ¬¥âà cpu ª®¬ ¤ë ver
|
* Команда ccpuid преобразована в параметр cpu команды ver
|
||||||
* ˆá¯à ¢«¥¨ï ¢ ¯ ª¥âëå ä ©« å ᡮન
|
* Исправления в пакетных файлах сборки
|
||||||
+ „®¡ ¢«¥ ¯à¨¬¥à ª®á®«ì®£® ¯à¨«®¦¥¨ï áᥬ¡«¥à¥ ¨ ¯ ª¥âë© ä ©« ¤«ï ¥£® ᡮન
|
+ Добавлен пример консольного приложения на ассемблере и пакетный файл для его сборки
|
||||||
|
|
||||||
|
|
||||||
Shell 0.5.4 // 04.06.2012 // Albom
|
Shell 0.5.4 // 04.06.2012 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ˆá¯à ¢«¥ ¨â¥àä¥©á ¨á¯®«ï¥¬ëå ª®á®«ìëå ¯à¨«®¦¥¨©. ’¥¯¥àì ®¨ ¤®«¦ë ᮧ¤ ¢ âì ¡ãä¥à á ¨¬¥¥¬ pid-SHELL, £¤¥ pid - ¨¤¥â¨ä¨ª â®à ¯à®æ¥áá ¡¥§ § £« ¢ëå ã«¥©
|
* Исправлен интерфейс исполняемых консольных приложений. Теперь они должны создавать буфер с именем pid-SHELL, где pid - идентификатор процесса без заглавных нулей
|
||||||
* <EFBFBD>¥¨ª à¨à®¢ ë ª®¬ ¤ë ccpuid, free, killall
|
* Реинкарнированы команды ccpuid, free, killall
|
||||||
+ „®¡ ¢«¥ ª®¬ ¤ history
|
+ Добавлена команда history
|
||||||
|
|
||||||
|
|
||||||
Shell 0.5.3 // 19.04.2012 // Albom
|
Shell 0.5.3 // 19.04.2012 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ˆá¯à ¢«¥¨¥ ¢ ª®¬ ¤¥ pwd
|
* Исправление в команде pwd
|
||||||
|
|
||||||
|
|
||||||
Shell 0.5.2 // 16.04.2012 // Albom
|
Shell 0.5.2 // 16.04.2012 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ˆá¯à ¢«¥¨¥ ¢ ª®¬ ¤¥ ls
|
* Исправление в команде ls
|
||||||
* <EFBFBD>¥§ ç¨â¥«ìë¥ ¤à㣨¥ ¨á¯à ¢«¥¨ï
|
* Незначительные другие исправления
|
||||||
|
|
||||||
|
|
||||||
Shell 0.5.1 // 15.04.2012 // Albom
|
Shell 0.5.1 // 15.04.2012 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* <EFBFBD>¥ª®â®àë¥ ¥§ ç¨â¥«ìë¥ ¨á¯à ¢«¥¨ï
|
* Некоторые незначительные исправления
|
||||||
|
|
||||||
|
|
||||||
Shell 0.5 // 23.03.2012 // Albom
|
Shell 0.5 // 23.03.2012 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* „®¡ ¢«¥ ¯®¤¤¥à¦ª ª®á®«ìëå ¯à¨«®¦¥¨©, ª®â®àë¥ ®¡é îâáï á 襫«®¬ ç¥à¥§ ¨¬¥®¢ ãî ®¡« áâì
|
* Добавлена поддержка консольных приложений, которые общаются с шеллом через именованную область
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.6 // 30.01.2011 // Albom
|
Shell 0.4.6 // 30.01.2011 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ‚६¥® 㤠«¥ë ª®¬ ¤ë killall ¨ ccpuid (çâ®¡ë ¢¥àãâì, ¥®¡å®¤¨¬® à ᪮¬¬¥â¨à®¢ âì 2 áâà®çª¨)
|
* Временно удалены команды killall и ccpuid (чтобы вернуть, необходимо раскомментировать 2 строчки)
|
||||||
* ˆá¯à ¢«¥¨ï ¢ ⥪á⮢ëå áâப å
|
* Исправления в текстовых строках
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.52 // 25.10.2010 // Pterox
|
Shell 0.4.52 // 25.10.2010 // Pterox
|
||||||
=======================================
|
=======================================
|
||||||
* „®¡ ¢«¥ ª®¬ ¤ "killall" - 㡨¢ ¥â ¢á¥ ¯à®æ¥ááë ªà®¬¥ OS/IDLE.
|
* Добавлена команда "killall" - убивает все процессы кроме OS/IDLE.
|
||||||
* ”¨ªáë
|
* Фиксы
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.51 // 21.10.2010 // Pterox
|
Shell 0.4.51 // 21.10.2010 // Pterox
|
||||||
=======================================
|
=======================================
|
||||||
* Š®¬ ¤ "turnoff" ¯¥à¥¨¬¥®¢ ¢ "shutdown", "kerver" 㤠«¥ - ⥯¥àì ¥ñ § ¬¥ï¥â "ver kernel"; 䨪áë.
|
* Команда "turnoff" переименована в "shutdown", "kerver" удалена - теперь её заменяет "ver kernel"; фиксы.
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.5 // 19.10.2010 // Pterox
|
Shell 0.4.5 // 19.10.2010 // Pterox
|
||||||
=======================================
|
=======================================
|
||||||
<EFBFBD>à®£à ¬¬ ⥯¥àì ¬®£®ï§ëª®¢ ï ( £«¨©áª¨©, ¨ àãá᪨© ï§ëª). <20>à®£à ¬¬ ¯®«®áâìî àãá¨ä¨æ¨à®¢ .
|
Программа теперь многоязыковая (английский, и русский язык). Программа полностью русифицированна.
|
||||||
* Š®¬ ¤ "free" ¯¥à¥¨¬¥®¢ ¢ "memory" - ¤«ï â®ç®áâ¨.
|
* Команда "free" переименована в "memory" - для точности.
|
||||||
* „®¡ ¢«¥ë ª®¬ ¤ë turnoff (¢ëª«îç¨âì ª®¬¯ìîâ¥à), kerver (¢¥àá¨ï ï¤à KolibriOS), uptime; reboot ⥯¥àì ¬®¦¥â ¯¥à¥§ £à㦠âì ï¤à® ("reboot kernel")
|
* Добавлены команды turnoff (выключить компьютер), kerver (версия ядра KolibriOS), uptime; reboot теперь может перезагружать ядро ("reboot kernel")
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.4 // 20.08.2010 // Albom
|
Shell 0.4.4 // 20.08.2010 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
1) 襫« ª®à४⮠§ ¢¥àè ¥âáï ¯à¨ § ªàë⨨ ®ª
|
1) шелл корректно завершается при закрытии окна
|
||||||
2) ¨á¯à ¢«¥® ¥éñ 2 ®è¨¡ª¨
|
2) исправлено ещё 2 ошибки
|
||||||
3) ¤®¡ ¢«¥ë 2 ª®¬ ¤ë:
|
3) добавлены 2 команды:
|
||||||
* sleep - ¦¤ âì. ¯ à ¬¥âà - ¢à¥¬ï ¢ á®âëå ç áâïå ᥪã¤ë. ⮫쪮 楫®¥ ç¨á«®.
|
* sleep - ждать. параметр - время в сотых частях секунды. только целое число.
|
||||||
* ccpuid - ¢ë¢®¤ ¢ ª®á®«ì ¨ä®à¬ 樨 (¯®ª áªã¤®) ® ¯à®æ¥áá®à¥. ¯®«ì§ë ¬ «®, ® ¤ ¢® å®â¥« á ª®¬ ¤®© cpuid à §®¡à âìáï (¢ á«¥¤ãî饬 ᥬ¥áâॠ¡ã¤ã áâ㤥⠬ ªãàá ç¨â âì, ¢ª«î稫 à §¡®à ª®¬ ¤ë ¢ ¯à®£à ¬¬ã).
|
* ccpuid - вывод в консоль информации (пока скудно) о процессоре. пользы мало, но давно хотел с командой cpuid разобраться (в следующем семестре буду студентам курс читать, включил разбор команды в программу).
|
||||||
|
|
||||||
¥áâì ¬®£® ¨¤¥©. ¥ª®â®àë¥ «¥£ª® ॠ«¨§ãîâáï, ¥ª®â®àë¥ á«®¦¥¥. ¥á«¨ ¨â¥à¥á®:
|
есть много идей. некоторые легко реализуются, некоторые сложнее. если интересно:
|
||||||
1) ¤®¡ ¢¨âì ¯¥à¥¬¥ãî (®¤ã!), ¢ ª®â®àãî ¡ã¤¥â १ã«ìâ â ¢ ⥪á⮢®© ä®à¬¥ (¥ â® çâ® ¢®§¢à é ¥â äãªæ¨ï) § ¯¨áë¢ âìáï. á ¥© ¬®¦® ¡ã¤¥â à ¡®â âì ¨§ ª®¬ ¤®© áâப¨
|
1) добавить переменную (одну!), в которую будет результат в текстовой форме (не то что возвращает функция) записываться. с ней можно будет работать из командной строки
|
||||||
2) ¢¥¤à¨âì ¯à®áâãî á⥪®¢ãî ¬ è¨ã ¤«ï ¢ëç¨á«¥¨© á ¢¥é¥á⢥묨 ç¨á« ¬¨
|
2) внедрить простую стековую машину для вычислений с вещественными числами
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.3 // 20.08.2010 // Albom
|
Shell 0.4.3 // 20.08.2010 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ‘¬¥áì ¢¥àᨩ 0.4.1 ¨ 0.4.2. ’¥¯¥àì ¢ à娢¥ ¢á¥ ¨áå®¤ë¥ ä ©«ë, ¥®¡å®¤¨¬ë¥ ¤«ï ª®¬¯¨«ï樨 (à ìè¥ ¨á¯®«ì§®¢ «¨áì ®¡ê¥ªâ¨ª¨ á ¬®¨¬¨ ®¡ñà⪠¬¨, ¨á室¨ª¨ ï á 襫«®¬ ¥ ¢ëª« ¤ë¢ «)
|
* Смесь версий 0.4.1 и 0.4.2. Теперь в архиве все исходные файлы, необходимые для компиляции (раньше использовались объектники с моими обёртками, исходники я с шеллом не выкладывал)
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.2 // 28.08.2009 // diamond
|
Shell 0.4.2 // 28.08.2009 // diamond
|
||||||
=======================================
|
=======================================
|
||||||
* „®¡ ¢¨« ª®à४⮥ § ¢¥à襨¥ à ¡®âë ¯à¨ § ªàë⨨ ®ª ª®á®«¨, à ¡®â ¥â ⮫쪮 ç¨ ï á ¯®á«¥¤¥© ¤ ë© ¬®¬¥â ¢¥àᨥ© ¡¨¡«¨®â¥ª¨ («¥¦¨â svn, ¢ª«îç¥ ¢ ®çãî á¡®àªã). <20>¥à¥ª®¬¯¨«¨à®¢ « ¢ VS2008 á LTCG, ¥éñ ¯®è ¬ ¨« á ®¯â¨¬¨§ 樥© ¯® à §¬¥àã
|
* Добавил корректное завершение работы при закрытии окна консоли, работает только начиная с последней на данный момент версией библиотеки (лежит на svn, включена в ночную сборку). Перекомпилировал в VS2008 с LTCG, ещё пошаманил с оптимизацией по размеру
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4.1 // 16.03.2009 // Albom
|
Shell 0.4.1 // 16.03.2009 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ¢¥àá¨ï á ¨á¯à ¢«¥ë¬¨ ®è¨¡ª ¬¨.
|
* версия с исправленными ошибками.
|
||||||
* à ¡®â ¥â ª®¬ ¤ alias, ¤®¡ ¢«¥ ª®¬ ¤ clear.
|
* работает команда alias, добавлена команда clear.
|
||||||
|
|
||||||
|
|
||||||
Shell 0.4 // 12.08.2008 // Albom
|
Shell 0.4 // 12.08.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
1) <EFBFBD> ¡®â ¥â á奬 ¯á¥¢¤®¨¬®¢ (¤® 256 ª®¬ ¤)
|
1) Работает схема псевдонимов (до 256 команд)
|
||||||
- ¯à®á¬®âà ¯® ª®¬ ¤¥ alias (¡¥§ ¯ à ¬¥â஢)
|
- просмотр по команде alias (без параметров)
|
||||||
- ¤®¡ ¢«¥¨¥ ¯á¥¢¤®¨¬ ª®¬ ¤ë á ª« ¢¨ âãàë ¨«¨ ¢ áªà¨¯â¥ (¢ ⮬ ç¨á«¥ ¨ .shell): alias ®¢ ï ª®¬ ¤ = áâ à ï ª®¬ ¤
|
- добавление псевдонима команды с клавиатуры или в скрипте (в том числе и .shell): alias новая команда = старая команда
|
||||||
- ª®¬ ¤ë ॣ¨áâ஧ ¢¨á¨¬ë¥, ¯®í⮬㠯®ª«®¨ª ¬ „Ž‘ ¯à¨¤ñâáï ¢¥á⨠¢ .shell áâப¨ â ª®£® ¢¨¤
|
- команды регистрозависимые, поэтому поклонникам ДОС придётся внести в .shell строки такого вида
|
||||||
alias dir = ls
|
alias dir = ls
|
||||||
alias DIR = ls
|
alias DIR = ls
|
||||||
alias Dir = ls
|
alias Dir = ls
|
||||||
alias DIr = ls
|
alias DIr = ls
|
||||||
¨ â.¤.
|
и т.д.
|
||||||
- ¢áâà®¥ë¥ ª®¬ ¤ë ¯¥à¥ §¢ âì ¥¢®§¬®¦®, ¯à¨¬¥à, ¡¥áá¬ëá«¥ ª®¬ ¤ :
|
- встроенные команды переназвать невозможно, например, бессмысленна команда:
|
||||||
alias ls=somecommand
|
alias ls=somecommand
|
||||||
- ¯à¨ ®â« ¤ª¥ ¯®«ãç « áâà ãî ¨ä®à¬ æ¨î, ® â ª ª ª ã ¬¥ï ¢áñ à ¡®â ¥â, â® ¯®ª ¨§¬¥¥¨© ¢®á¨âì ¥ ¯« ¨àãî
|
- при отладке получал странную информацию, но так как у меня всё работает, то пока изменений вносить не планирую
|
||||||
|
|
||||||
2) ’¥¯¥àì 襫« ¬®¦® § ¯ã᪠âì á ¯ à ¬¥â஬ (¨§ á ¬®£® ᥡï, ¯à¨¬¥à)
|
2) Теперь шелл можно запускать с параметром (из самого себя, например)
|
||||||
- á¨â ªá¨á:
|
- синтаксис:
|
||||||
shell ª®¬ ¤
|
shell команда
|
||||||
- ¯à¨¬¥à:
|
- пример:
|
||||||
shell /sys/somescript
|
shell /sys/somescript
|
||||||
- ¯à¨ í⮬ .shell ¥ § ¯ã᪠¥âáï
|
- при этом .shell не запускается
|
||||||
|
|
||||||
3) <EFBFBD>¥ «¨§®¢ ª®¬ ¤ more
|
3) Реализована команда more
|
||||||
- ¯à®á¬®âà ⥪á⮢ëå ¨ ¡¨ àëå ä ©«®¢ (¢à®¤¥ ¡ë § ¤ ç ¯à®áâ ï, ® ¯à¨è«®áì ¯®¢®§¨âìáï á ã¯à ¢«ïî騬¨ ᨬ¢®« ¬¨)
|
- просмотр текстовых и бинарных файлов (вроде бы задача простая, но пришлось повозиться с управляющими символами)
|
||||||
- ®ç¥ì ¥ ४®¬¥¤ã¥âáï ¯à®á¬ âਢ âì ¡®«ì訥 ä ©«ë
|
- очень не рекомендуется просматривать большие файлы
|
||||||
|
|
||||||
|
|
||||||
Shell 0.3 // 07.08.2008 // Albom
|
Shell 0.3 // 07.08.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
1) ‚®§¬®¦®áâì § ¯ã᪠áªà¨¯â®¢
|
1) Возможность запуска скриптов
|
||||||
* ª ¦¤ ï áâப ¤®«¦ ¯à¥¤áâ ¢«ï¥â ᮡ®© ª®¬ ¤ã
|
* каждая строка должна представляет собой команду
|
||||||
* áâப®© áç¨â ¥âáï ¡®à ᨬ¢®«®¢, ª®â®àë© § ª 稢 ¥âáï CR+LF (Windows) ¨«¨ LF(UNIX) ¨«¨ CR(Mac)
|
* строкой считается набор символов, который заканчивается CR+LF (Windows) или LF(UNIX) или CR(Mac)
|
||||||
* ¥á«¨ áâப ç¨ ¥âáï á #, â® ¢áï áâப (â.¥. ª®¬¬¥â ਩) ¨£®à¨àã¥âáï
|
* если строка начинается с #, то вся строка (т.е. комментарий) игнорируется
|
||||||
* áªà¨¯â ¤®«¦¥ ç¨â âìáï á #SHS
|
* скрипт должен начитаться с #SHS
|
||||||
* ¯à¨ § ¯ã᪥ 襫« ¢â®¬ â¨ç¥áª¨ § ¯ã᪠¥âáï áªà¨¯â .shell
|
* при запуске шелла автоматически запускается скрипт .shell
|
||||||
|
|
||||||
2) ˆáâ®à¨ï ¨§ 5 (¬®¦® ¨§¬¥¨âì ¯à¨ ª®¬¯¨«ï樨) ¢¢¥¤ñëå ª®¬ ¤
|
2) История из 5 (можно изменить при компиляции) введённых команд
|
||||||
* ¯¥à¥¬¥é¥¨¥ ¯® ¨áâ®à¨¨ - UP/DOWN
|
* перемещение по истории - UP/DOWN
|
||||||
|
|
||||||
3) Š®¬ ¤ alias, ª®â®à ï ¯®§¢®«ï¥â ¢¢®¤¨âì ᨮ¨¬ë ¤«ï ª®¬ ¤
|
3) Команда alias, которая позволяет вводить синонимы для команд
|
||||||
* ¤® 256 (¬®¦® ¨§¬¥¨âì ¯à¨ ª®¬¯¨«ï樨) ᨮ¨¬®¢
|
* до 256 (можно изменить при компиляции) синонимов
|
||||||
* ¯®ª à ¡®â ¥â ⮫쪮 ¤®¡ ¢«¥¨¥ ¨ ¯à®á¬®âà ᨮ¨¬®¢, ®âà ¡®âª ¯®ª ¥ ॠ«¨§®¢
|
* пока работает только добавление и просмотр синонимов, а отработка пока не реализована
|
||||||
|
|
||||||
|
|
||||||
Shell 0.2 // 04.08.2008 // Albom
|
Shell 0.2 // 04.08.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* ¤®¡ ¢¨« ®¢ë¥ äãªæ¨¨
|
* добавил новые функции
|
||||||
* ¯¨á « ᮡá⢥ãî ¯à®æ¥¤ãàã ¢¢®¤ ª®¬ ¤ë
|
* написал собственную процедуру ввода команды
|
||||||
|
|
||||||
|
|
||||||
Shell 0.11 // 01.08.2008 // Albom
|
Shell 0.11 // 01.08.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* „®¡ ¢¨« ª®¬ ¤ë free ¨ reboot, ¢ñá ¥ª®â®àë¥ ¨§¬¥¥¨ï, ¨á¯à ¢¨« ©¤¥ë¥ ®è¨¡ª¨
|
* Добавил команды free и reboot, внёс некоторые изменения, исправил найденные ошибки
|
||||||
|
|
||||||
|
|
||||||
Shell 0.1 // 29.07.2008 // Albom
|
Shell 0.1 // 29.07.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* <EFBFBD>¥ «¨§®¢ ë (¥ ¯®«®áâìî) ª®¬ ¤ë: about, cd, date, echo, exit, help, kill, ls, ps, pwd, ver
|
* Реализованы (не полностью) команды: about, cd, date, echo, exit, help, kill, ls, ps, pwd, ver
|
||||||
* <EFBFBD>ਠ§ ¯ã᪥ ¯à®£à ¬¬ë (¥á«¨ ¥ 㪠§ ¯®«ë© ¯ãâì) ® ¨é¥âáï ¢ ª â «®£¥ /rd/1 ¨ ⥪ã饬 ª â «®£¥
|
* При запуске программы (если не указан полный путь) она ищется в каталоге /rd/1 и текущем каталоге
|
||||||
|
|
||||||
|
|
||||||
Shell 0.02 // 27.07.2008 // Albom
|
Shell 0.02 // 27.07.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* <EFBFBD>¥ «¨§®¢ « ª®¬ ¤ë:
|
* Реализовал команды:
|
||||||
exit - ¢ë室
|
exit - выход
|
||||||
ls (á ¯ à ¬¥â஬ ¨ ¡¥§) - ¢ë¢®¤ ᯨ᪠¤¨à¥ªâ®à¨¨
|
ls (с параметром и без) - вывод списка директории
|
||||||
pwd - ⥪ã騩 ª â «®£
|
pwd - текущий каталог
|
||||||
ps - ᯨ᮪ ¯à®æ¥áᮢ ¨ ¨å PID
|
ps - список процессов и их PID
|
||||||
kill - § ¢¥àè¨âì ¯à®æ¥áá ¯® PID
|
kill - завершить процесс по PID
|
||||||
help (á ¯ à ¬¥â஬ ¨ ¡¥§) - ¯®¬®éì
|
help (с параметром и без) - помощь
|
||||||
|
|
||||||
|
|
||||||
Shell 0.01 // 27.07.2008 // Albom
|
Shell 0.01 // 27.07.2008 // Albom
|
||||||
=======================================
|
=======================================
|
||||||
* <EFBFBD>¥è¨« ¯¨á âì äãªæ¨® «ìë© è¥«« ‘¨ á ¨á¯®«ì§®¢ ¨¥¬ console.obj
|
* Решил написать функциональный шелл на Си с использованием console.obj
|
||||||
* <EFBFBD>®ª ᤥ« « äãªæ¨î ®â¤¥«¥¨ï ª®¬ ¤ë ¨ ¯ à ¬¥â஢, â ª¦¥ ॠ«¨§®¢ « ª®¬ ¤ë help (¯®ª ¡¥§ ¯ à ¬¥â஢), ver ¨ exit
|
* Пока сделал функцию отделения команды и параметров, а также реализовал команды help (пока без параметров), ver и exit
|
||||||
|
|
||||||
|
@ -1,26 +1,10 @@
|
|||||||
if tup.getconfig("NO_FASM") ~= "" or tup.getconfig("NO_GCC") ~= "" then return end
|
if tup.getconfig("NO_TCC") ~= "" then return end
|
||||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
|
||||||
tup.include(HELPERDIR .. "/use_gcc.lua")
|
|
||||||
LDFLAGS = LDFLAGS .. " -T kolibri.ld"
|
|
||||||
-- compile shell
|
|
||||||
if tup.getconfig("LANG") == "ru"
|
|
||||||
then C_LANG = "LANG_RUS"
|
|
||||||
else C_LANG = "LANG_ENG" -- this includes default case without config
|
|
||||||
end
|
|
||||||
|
|
||||||
if tup.getconfig("TUP_PLATFORM") == "win32"
|
TCC="kos32-tcc"
|
||||||
-- on win32 '#' is not a special character, but backslash and quotes would be printed as is
|
CFLAGS = "-I../../develop/ktcc/trunk/libc.obj/include"
|
||||||
then tup.rule('echo #define ' .. C_LANG .. ' 1 > %o', {"lang.h"})
|
LDFLAGS = "-nostdlib ../../develop/ktcc/trunk/bin/lib/crt0.o -L../../develop/ktcc/trunk/bin/lib"
|
||||||
-- on unix '#' should be escaped
|
|
||||||
else tup.rule('echo "#define" ' .. C_LANG .. ' 1 > %o', {"lang.h"})
|
|
||||||
end
|
|
||||||
tup.append_table(OBJS, tup.rule("start.asm", "fasm %f %o", "start.o"))
|
|
||||||
compile_gcc{"shell.c", "system/kolibri.c", "system/stdlib.c", "system/string.c", "system/ctype.c", extra_inputs = {"lang.h"}}
|
|
||||||
link_gcc("shell")
|
|
||||||
|
|
||||||
-- compile ASM test
|
LIBS = "-ltcc -lc.obj"
|
||||||
tup.rule("test.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "asmtest")
|
COMMAND=string.format("%s %s %s %s %s", TCC, CFLAGS, LDFLAGS , "%f -o %o", LIBS)
|
||||||
-- compile C test
|
|
||||||
OBJS = {"start.o", "kolibri.o", "stdlib.o", "string.o", "ctype.o"} -- remove shell.o
|
tup.rule("shell.c", COMMAND .. tup.getconfig("KPACK_CMD"), "shell")
|
||||||
compile_gcc{"test.c"}
|
|
||||||
link_gcc("ctest")
|
|
@ -8,9 +8,36 @@
|
|||||||
|
|
||||||
#include "system/boolean.h"
|
#include "system/boolean.h"
|
||||||
#include "system/kolibri.h"
|
#include "system/kolibri.h"
|
||||||
#include "system/stdlib.h"
|
//#include "system/stdlib.h"
|
||||||
#include "system/string.h"
|
//#include "system/string.h"
|
||||||
#include "system/ctype.h"
|
//#include "system/ctype.h"
|
||||||
|
//#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
//--------
|
||||||
|
int strnicmp(const char* string1, const char* string2, unsigned count)
|
||||||
|
{
|
||||||
|
int pc = 0;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (toupper(*string1)<toupper(*string2))
|
||||||
|
return -1;
|
||||||
|
if (toupper(*string1)>toupper(*string2))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (*string1=='\0' || pc == count)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
string1++;
|
||||||
|
string2++;
|
||||||
|
pc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------
|
||||||
|
|
||||||
|
extern int _FUNC(sprintf)(char* buffer, const char* format, ...);
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
@ -18,7 +45,31 @@
|
|||||||
// from main file (shell.c). TODO - in future move to library
|
// from main file (shell.c). TODO - in future move to library
|
||||||
void get_file_dir_loc(char *filepath, char *dir_path);
|
void get_file_dir_loc(char *filepath, char *dir_path);
|
||||||
|
|
||||||
#include "system/console.c"
|
//#include "system/console.c"
|
||||||
|
#include <conio.h>
|
||||||
|
#define con_exit (*con_exit)
|
||||||
|
#define con_set_title (*con_set_title)
|
||||||
|
#define con_write_asciiz (*con_write_asciiz)
|
||||||
|
#define con_write_string (*con_write_string)
|
||||||
|
#define con_printf (*con_printf)
|
||||||
|
#define con_get_flags (*con_get_flags)
|
||||||
|
#define con_set_flags (*con_set_flags)
|
||||||
|
#define con_get_font_height (*con_get_font_height)
|
||||||
|
#define con_get_cursor_height (*con_get_cursor_height)
|
||||||
|
#define con_set_cursor_height (*con_set_cursor_height)
|
||||||
|
#define con_getch (*con_getch)
|
||||||
|
#define con_getch2 (*con_getch2)
|
||||||
|
#define con_kbhit (*con_kbhit)
|
||||||
|
#define con_gets (*con_gets)
|
||||||
|
#define con_gets2_callback (* con_gets2_callback)
|
||||||
|
#define con_gets2 (*con_gets2)
|
||||||
|
#define con_cls (*con_cls)
|
||||||
|
#define con_get_cursor_pos (*con_get_cursor_pos)
|
||||||
|
#define con_set_cursor_pos (*con_set_cursor_pos)
|
||||||
|
|
||||||
|
#define printf con_printf
|
||||||
|
#define gets con_gets
|
||||||
|
#define getch con_getch2
|
||||||
|
|
||||||
#include "cmd/cmd_about.c"
|
#include "cmd/cmd_about.c"
|
||||||
#include "cmd/cmd_help.c"
|
#include "cmd/cmd_help.c"
|
||||||
@ -45,6 +96,7 @@ void get_file_dir_loc(char *filepath, char *dir_path);
|
|||||||
#include "cmd/cmd_shutdown.c"
|
#include "cmd/cmd_shutdown.c"
|
||||||
#include "cmd/cmd_uptime.c"
|
#include "cmd/cmd_uptime.c"
|
||||||
#include "cmd/cmd_history.c"
|
#include "cmd/cmd_history.c"
|
||||||
|
#include "cmd/cmd_kfetch.c"
|
||||||
#include "cmd/cmd_cp.c"
|
#include "cmd/cmd_cp.c"
|
||||||
#include "cmd/cmd_mv.c"
|
#include "cmd/cmd_mv.c"
|
||||||
#include "cmd/cmd_ren.c"
|
#include "cmd/cmd_ren.c"
|
||||||
@ -58,6 +110,5 @@ void get_file_dir_loc(char *filepath, char *dir_path);
|
|||||||
#include "modules/module_alias.c"
|
#include "modules/module_alias.c"
|
||||||
#include "modules/module_parameters.c"
|
#include "modules/module_parameters.c"
|
||||||
|
|
||||||
typedef unsigned int size_t;
|
//typedef unsigned int size_t;
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
2
programs/system/shell/build.sh
Executable file
2
programs/system/shell/build.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
../../develop/ktcc/trunk/source/kos32-tcc -I../../develop/ktcc/trunk/libc.obj/include -nostdlib ../../develop/ktcc/trunk/bin/lib/crt0.o -L../../develop/ktcc/trunk/bin/lib shell.c system/kolibri.c -o shell -ltcc -lc.obj
|
||||||
|
../../other/kpack/linux/kpack shell
|
@ -1,10 +1,6 @@
|
|||||||
|
|
||||||
int cmd_about(char param[])
|
int cmd_about(char param[]) {
|
||||||
{
|
printf(CMD_ABOUT_MSG, SHELL_VERSION);
|
||||||
|
|
||||||
char message[] = {"Shell %s\n\r"};
|
|
||||||
|
|
||||||
printf(message, SHELL_VERSION);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
|
|
||||||
int cmd_alias(char arg[])
|
int cmd_alias(char arg[]) {
|
||||||
{
|
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (NULL == arg || '\0' == arg[0])
|
if (NULL == arg || '\0' == arg[0]) {
|
||||||
{
|
|
||||||
alias_list();
|
alias_list();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,25 @@
|
|||||||
|
|
||||||
|
|
||||||
int cmd_cd(char dir[])
|
int cmd_cd(char dir[])
|
||||||
{
|
{
|
||||||
|
|
||||||
char temp[256];
|
char temp[256];
|
||||||
unsigned result;
|
unsigned result;
|
||||||
|
|
||||||
if (NULL == dir)
|
if (NULL == dir) {
|
||||||
{
|
printf(CMD_CD_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf(" cd <directory>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" cd <え爛<E38188><E7889B><EFBFBD>>\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 == strcmp(dir, ".") || 0 == strcmp(dir, "./") )
|
if ( 0 == strcmp(dir, ".") || 0 == strcmp(dir, "./") )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if ( ( 0 == strcmp(dir, "..") || 0 == strcmp(dir, "../") ) && ( 0 != strcmp(cur_dir, "/")) )
|
if ( ( 0 == strcmp(dir, "..") || 0 == strcmp(dir, "../") ) && ( 0 != strcmp(cur_dir, "/")) ) {
|
||||||
{
|
|
||||||
cur_dir[strlen(cur_dir)-1]='\0';
|
cur_dir[strlen(cur_dir)-1]='\0';
|
||||||
dir_truncate(cur_dir);
|
dir_truncate(cur_dir);
|
||||||
set_cwd(cur_dir);
|
set_cwd(cur_dir);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( '/' == dir[0])
|
if ( '/' == dir[0]) {
|
||||||
{
|
|
||||||
if ( dir_check(dir) )
|
if ( dir_check(dir) )
|
||||||
{
|
{
|
||||||
strcpy(cur_dir, dir);
|
strcpy(cur_dir, dir);
|
||||||
@ -37,15 +28,13 @@ if ( '/' == dir[0])
|
|||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
strcpy(temp, cur_dir);
|
strcpy(temp, cur_dir);
|
||||||
if (cur_dir[strlen(cur_dir)-1] != '/')
|
if (cur_dir[strlen(cur_dir)-1] != '/')
|
||||||
strcat(temp, "/");
|
strcat(temp, "/");
|
||||||
strcat(temp, dir);
|
strcat(temp, dir);
|
||||||
|
|
||||||
if ( dir_check(temp) )
|
if ( dir_check(temp) ) {
|
||||||
{
|
|
||||||
|
|
||||||
strcpy(cur_dir, temp);
|
strcpy(cur_dir, temp);
|
||||||
set_cwd(cur_dir);
|
set_cwd(cur_dir);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_clear(char param[])
|
int cmd_clear(char param[]) {
|
||||||
{
|
|
||||||
con_cls();
|
con_cls();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,7 @@ int cmd_cp(char param[])
|
|||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
#if LANG_ENG
|
printf(CMD_CP_USAGE);
|
||||||
printf(" cp <file_in> <file_out>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" cp <¨áâ®ç¨ª> <१ã«ìâ â>\n\r");
|
|
||||||
#endif
|
|
||||||
parameters_free(argc, argv);
|
parameters_free(argc, argv);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
int cmd_date(char param[])
|
int cmd_date(char param[])
|
||||||
{
|
{
|
||||||
unsigned date;
|
unsigned date;
|
||||||
unsigned time;
|
unsigned time;
|
||||||
|
|
||||||
date = kol_system_date_get();
|
date = kol_system_date_get();
|
||||||
#if LANG_ENG
|
printf(CMD_DATE_DATE_FMT,
|
||||||
printf(" Date [dd.mm.yy]: %x%x.%x%x.%x%x",
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" <20><><EFBFBD><EFBFBD> [い.<2E>.<2E>]: %x%x.%x%x.%x%x",
|
|
||||||
#endif
|
|
||||||
(date&0xf00000)>>20, (date&0xf0000)>>16, // day
|
(date&0xf00000)>>20, (date&0xf0000)>>16, // day
|
||||||
(date&0xf000)>>12, (date&0xf00)>>8, //month
|
(date&0xf000)>>12, (date&0xf00)>>8, //month
|
||||||
(date&0xf0)>>4, (date&0xf) ); // year
|
(date&0xf0)>>4, (date&0xf) ); // year
|
||||||
|
|
||||||
|
|
||||||
time = kol_system_time_get();
|
time = kol_system_time_get();
|
||||||
|
printf(CMD_DATE_TIME_FMT,
|
||||||
#if LANG_ENG
|
|
||||||
printf("\n\r Time [hh:mm:ss]: %x%x:%x%x:%x%x\n\r",
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf("\n\r <20>爛<EFBFBD> [艸:<3A>:瘁]: %x%x:%x%x:%x%x\n\r",
|
|
||||||
#endif
|
|
||||||
(time&0xf0)>>4, (time&0xf), // hours
|
(time&0xf0)>>4, (time&0xf), // hours
|
||||||
(time&0xf000)>>12, (time&0xf00)>>8, // minutes
|
(time&0xf000)>>12, (time&0xf00)>>8, // minutes
|
||||||
(time&0xf00000)>>20, (time&0xf0000)>>16 ); // seconds
|
(time&0xf00000)>>20, (time&0xf0000)>>16 ); // seconds
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
int cmd_exit(char param[])
|
int cmd_exit(char param[])
|
||||||
{
|
{
|
||||||
free(ALIASES);
|
free(ALIASES);
|
||||||
_exit(1);
|
con_exit(1);
|
||||||
kol_exit();
|
kol_exit();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,7 @@ total = kol_system_mem();
|
|||||||
free = kol_system_memfree();
|
free = kol_system_memfree();
|
||||||
used = total - free;
|
used = total - free;
|
||||||
|
|
||||||
#if LANG_ENG
|
printf (CMD_FREE_FMT,
|
||||||
printf (" Total [kB / MB / %%]: %-7d / %-5d / 100\n\r Free [kB / MB / %%]: %-7d / %-5d / %d\n\r Used [kB / MB / %%]: %-7d / %-5d / %d\n\r",
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" ‚ᥣ® [Š<> / Œ<> / %%]: %-7d / %-5d / 100\n\r ‘¢®¡®¤® [Š<> / Œ<> / %%]: %-7d / %-5d / %d\n\r ˆá¯®«ì§ã¥âáï [Š<> / Œ<> / %%]: %-7d / %-5d / %d\n\r",
|
|
||||||
#endif
|
|
||||||
total, total/1024, free, free/1024, (free*100)/total, used, total/1024-free/1024, 100-(free*100)/total );
|
total, total/1024, free, free/1024, (free*100)/total, used, total/1024-free/1024, 100-(free*100)/total );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1,42 +1,26 @@
|
|||||||
|
|
||||||
int cmd_help(char cmd[])
|
int cmd_help(char cmd[]) {
|
||||||
{
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#if LANG_ENG
|
if ( !strlen(cmd) ) {
|
||||||
char available[]={" %d commands available:\n\r"};
|
|
||||||
#elif LANG_RUS
|
|
||||||
char available[]={" Š®«¨ç¥á⢮ ¤®áâã¯ëå ª®¬ ¤: %d\n\r"};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( !strlen(cmd) )
|
|
||||||
{
|
|
||||||
int columns_max=3;
|
int columns_max=3;
|
||||||
printf (available, NUM_OF_CMD);
|
printf (CMD_HELP_AVAIL, NUM_OF_CMD);
|
||||||
for (i = 0; i < NUM_OF_CMD; i++)
|
for (i = 0; i < NUM_OF_CMD; i++) {
|
||||||
{
|
|
||||||
printf(" %-12s", COMMANDS[i].name);
|
printf(" %-12s", COMMANDS[i].name);
|
||||||
if ((i) && ((i+1)%columns_max == 0)) printf("\n\r");
|
if ((i) && ((i+1)%columns_max == 0)) printf("\n\r");
|
||||||
}
|
}
|
||||||
if ((i)%columns_max != 0) printf("\n\r");
|
if ((i)%columns_max != 0) printf("\n\r");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
for (i=0; i<NUM_OF_CMD; i++)
|
for (i=0; i<NUM_OF_CMD; i++)
|
||||||
if ( !strcmp(cmd, COMMANDS[i].name) )
|
if ( !strcmp(cmd, COMMANDS[i].name) ) {
|
||||||
{
|
|
||||||
printf(COMMANDS[i].help);
|
printf(COMMANDS[i].help);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LANG_ENG
|
printf (CMD_HELP_CMD_NOT_FOUND, cmd);
|
||||||
printf (" Command \'%s\' not found.\n\r", cmd);
|
printf (CMD_HELP_AVAIL, NUM_OF_CMD);
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" Š®¬ ¤ \'%s\' ¥ ©¤¥ .\n\r", cmd);
|
|
||||||
#endif
|
|
||||||
printf (available, NUM_OF_CMD);
|
|
||||||
for (i = 0; i < NUM_OF_CMD; i++)
|
for (i = 0; i < NUM_OF_CMD; i++)
|
||||||
printf(" %s\n\r", COMMANDS[i].name);
|
printf(" %s\n\r", COMMANDS[i].name);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
|
|
||||||
int cmd_history(char arg[])
|
int cmd_history(char arg[]) {
|
||||||
{
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
for (i = CMD_HISTORY_NUM_REAL - 1; i >= 0; i--) {
|
||||||
for (i = CMD_HISTORY_NUM_REAL - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
printf("%s\n", CMD_HISTORY[i]);
|
printf("%s\n", CMD_HISTORY[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
/* turbocat2001 */
|
|
||||||
#if LANG_ENG
|
|
||||||
#define HELP "info <object_name>\n"
|
|
||||||
#define FILE_NOT_FOUND "Object '%s' not found!\n"
|
|
||||||
#define OBJECT_INFO "Object '%s' information:\n\n"
|
|
||||||
#define TYPE "Type: "
|
|
||||||
#define DIR "'Folder'"
|
|
||||||
#define PART "'Part'"
|
|
||||||
#define FILE "'File'"
|
|
||||||
#define CREATED "Created: %02d.%02d.%02d %02d:%02d:%02d\n"
|
|
||||||
#define MODIFID "Modified: %02d.%02d.%02d %02d:%02d:%02d\n"
|
|
||||||
#define DATE_TIME " Date Time\n"
|
|
||||||
#define ATTRIB "Attributes: "
|
|
||||||
#define RO "'Read only' "
|
|
||||||
#define HIDDEN "'Hidden' "
|
|
||||||
#define SYS "'System' "
|
|
||||||
#define NOT_ARCHIV "'Not archived' "
|
|
||||||
#define FILE_SIZE "\nFile size: %u KB (%u B)\n"
|
|
||||||
|
|
||||||
#elif LANG_RUS
|
|
||||||
#define HELP "info <¨¬ï_®¡ê¥ªâ >\n"
|
|
||||||
#define FILE_NOT_FOUND "Ž¡ê¥ªâ '%s' ¥ ©¤¥!\n"
|
|
||||||
#define OBJECT_INFO "ˆä®à¬ æ¨ï ®¡ ®¡ê¥ªâ¥ '%s':\n\n"
|
|
||||||
#define TYPE "’¨¯: "
|
|
||||||
#define DIR "'<27> ¯ª '"
|
|
||||||
#define PART "'’®¬'"
|
|
||||||
#define FILE "'” ©«'"
|
|
||||||
#define CREATED "‘®§¤ : %02d.%02d.%02d %02d:%02d:%02d\n"
|
|
||||||
#define MODIFID "ˆ§¬¥ñ: %02d.%02d.%02d %02d:%02d:%02d\n"
|
|
||||||
#define DATE_TIME " „ ⠂६ï\n"
|
|
||||||
#define ATTRIB "€âਡãâë: "
|
|
||||||
#define RO "'’®«ìª® ¤«ï ç⥨ï' "
|
|
||||||
#define HIDDEN "'‘ªàëâë©' "
|
|
||||||
#define SYS "'‘¨á⥬ë©' "
|
|
||||||
#define NOT_ARCHIV "'<27>¥ à娢ë©' "
|
|
||||||
#define FILE_SIZE "\n<> §¬¥à ä ©« : %u K<> (%u <20>)\n"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int cmd_info(char param[])
|
|
||||||
{
|
|
||||||
byte is_dir=0, is_part=0; // Folder or part?
|
|
||||||
char* argv[100];
|
|
||||||
if(1 != parameters_prepare(param, argv)) //get number of parameters
|
|
||||||
{
|
|
||||||
printf(HELP);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
FS_struct_BDVK *info=NULL; // BDVK struct define
|
|
||||||
info=get_bdvk(argv[0]); // Get file info (BDVK)
|
|
||||||
if(info==NULL)
|
|
||||||
{
|
|
||||||
printf(FILE_NOT_FOUND, argv[0]);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
printf(OBJECT_INFO, argv[0]);
|
|
||||||
|
|
||||||
printf(TYPE);
|
|
||||||
if (info->attrib & (1 << 4))
|
|
||||||
{
|
|
||||||
printf(DIR);
|
|
||||||
is_dir=1;
|
|
||||||
}
|
|
||||||
else if (info->attrib & (1 << 3))
|
|
||||||
{
|
|
||||||
printf(PART);
|
|
||||||
is_part=1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(FILE);
|
|
||||||
}
|
|
||||||
printf("\n\n");
|
|
||||||
printf(DATE_TIME); // Show date and time
|
|
||||||
printf(CREATED, info->c_date.d, info->c_date.m, info->c_date.y, info->c_time.h, info->c_time.m, info->c_time.s);
|
|
||||||
printf(MODIFID, info->m_date.d, info->m_date.m, info->m_date.y, info->m_time.h, info->m_time.m, info->m_time.s);
|
|
||||||
printf("\n");
|
|
||||||
printf(ATTRIB); // Show Attributes
|
|
||||||
|
|
||||||
if (info->attrib & (1 << 0))
|
|
||||||
{
|
|
||||||
printf(RO);
|
|
||||||
}
|
|
||||||
if (info->attrib & (1 << 1))
|
|
||||||
{
|
|
||||||
printf(HIDDEN);
|
|
||||||
}
|
|
||||||
if (info->attrib & (1 << 2))
|
|
||||||
{
|
|
||||||
printf(SYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info->attrib & (1 << 5))
|
|
||||||
{
|
|
||||||
printf(NOT_ARCHIV);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
if (!is_dir && (info->size)>=0 && !is_part) // If dir or part then not show file size
|
|
||||||
{
|
|
||||||
printf(FILE_SIZE, info->size/1024, info->size);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
53
programs/system/shell/cmd/cmd_kfetch.c
Normal file
53
programs/system/shell/cmd/cmd_kfetch.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
void get_str_meminfo(char *str) {
|
||||||
|
unsigned mem_all_mib = kol_system_mem() / 1024;
|
||||||
|
unsigned mem_free_mib = kol_system_memfree() / 1024;
|
||||||
|
sprintf(str, "%uMiB / %uMiB", mem_all_mib - mem_free_mib, mem_all_mib);
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmd_kfetch(char param[]) {
|
||||||
|
char *str_krnl_ver = malloc(64);
|
||||||
|
get_str_kernel_version(str_krnl_ver, "%d.%d.%d.%d. SVN-rev.: %d");
|
||||||
|
char *str_uptime = malloc(64);
|
||||||
|
get_str_uptime(str_uptime, "%d day(s), %d:%d:%d.%d");
|
||||||
|
char *str_resolution = malloc(24);
|
||||||
|
ksys_pos_t resol = _ksys_screen_size();
|
||||||
|
sprintf(str_resolution, "%u x %u", resol.x + 1, resol.y + 1);
|
||||||
|
char *str_cpu_info = malloc(16);
|
||||||
|
get_str_cpu_info(str_cpu_info);
|
||||||
|
char *str_meminfo = malloc(24);
|
||||||
|
get_str_meminfo(str_meminfo);
|
||||||
|
|
||||||
|
printf(/*"\033[0;34;40m \033[0m\n\r"*/
|
||||||
|
/*"\033[0;34;40m \033[0m\n\r"*/
|
||||||
|
/*"\033[0;34;40m \033[0m\n\r"*/
|
||||||
|
"\033[0;34;40m .\033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m t\033[0;1;30;40m@\033[0;34;40m.\033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m ;8\033[0;1;30;40m8\033[0;34;40m8\033[0;1;30;40m8\033[0;32;40m.\033[0;34;40m.\033[0;32;40m \033[0;34;40m \033[0;31;40m.\033[0;34;40mS\033[0;1;30;46m88\033[0;1;35;47m8\033[0;35;44mX\033[0;34;40m;\033[0;32;40m.:\033[0;5;30;40mX\033[0;1;30;46mX8\033[0;34;40m8\033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m t\033[0;5;36;40m8\033[0;5;36;46m@ \033[0;5;37;46m%%\033[0;5;37;47m.\033[0;5;37;46m@\033[0;34;46m8\033[0;31;40mt\033[0;34;40m.\033[0;32;40m.\033[0;34;40m \033[0;31;40m \033[0;1;30;40m8\033[0;1;36;46m%%\033[0;5;37;46m8\033[0;5;1;35;44m8\033[0;1;34;45m8\033[0;30;44m8\033[0;32;40m;;\033[0;5;36;40m8\033[0;37;46m@\033[0;5;37;44m8\033[0;5;35;44m:\033[0;1;30;45m8\033[0;5;34;40m8\033[0m\n\r"
|
||||||
|
"\033[0;34;40m@\033[0;5;35;40m8\033[0;1;30;44m8\033[0;5;35;40m8\033[0;35;44m8\033[0;1;30;45m@\033[0;35;44m8\033[0;1;30;45m8\033[0;34;45m8\033[0;1;30;45m8\033[0;1;34;45m8\033[0;1;37;47mt\033[0;5;37;46m@\033[0;1;30;46m8S\033[0;5;37;46m8X\033[0;5;36;46m.t\033[0;1;30;44m8\033[0;31;40m \033[0;32;40m \033[0;34;40m:\033[0;5;36;40m8\033[0;1;30;46m@\033[0;1;34;47m8\033[0;5;37;45m8\033[0;5;35;44m \033[0;1;30;45m8\033[0;1;30;46m88\033[0;36;47m@\033[0;5;37;44m8\033[0;5;35;44m \033[0;5;35;45m;\033[0;5;35;44m.\033[0;37;45m8\033[0;1;30;44mX\033[0;32;40m \033[0m %s\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;32;40m \033[0;34;40m.\033[0;32;40m.\033[0;34;40m;S@\033[0;5;30;40m8\033[0;33;41m8\033[0;1;33;43m;\033[0;5;33;43m \033[0;1;33;47m8\033[0;5;33;43m \033[0;1;33;43mt\033[0;36;47m8\033[0;5;36;46m \033[0;1;36;46m%%\033[0;5;34;40m8\033[0;1;30;46m%%8\033[0;5;37;46mX\033[0;5;36;46m%%\033[0;5;35;45m.\033[0;5;36;44m.\033[0;37;46m8\033[0;1;34;47m@\033[0;1;36;47mX\033[0;5;1;35;44m8\033[0;5;37;44m8\033[0;5;1;34;45m8\033[0;1;35;45m:\033[0;1;34;47m8\033[0;1;30;45m8\033[0;5;34;40m8\033[0;31;40m: \033[0m %s%s\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m.::\033[0;34;40m.\033[0;31;40m;\033[0;1;30;43m8\033[0;5;1;33;41m8\033[0;5;33;43m \033[0;5;33;41m \033[0;5;37;43mX\033[0;5;36;46m8:\033[0;1;36;46mS.\033[0;5;36;46m;@\033[0;1;34;45m88\033[0;1;34;46m8\033[0;1;37;47m.\033[0;5;1;34;45m8\033[0;5;37;45m8\033[0;5;1;34;45m8\033[0;1;35;47m8\033[0;5;1;35;44m8\033[0;5;35;44m \033[0;35;47m8\033[0;35;44m%%\033[0;34;40m;. \033[0;31;40m \033[0m %s%s\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;32;40m \033[0;34;40m .\033[0;31;40m;\033[0;1;30;41m@\033[0;5;31;41mS\033[0;5;33;41m \033[0;5;1;31;43m8\033[0;1;30;43m8\033[0;5;36;46m88\033[0;5;37;46mX\033[0;1;36;47m@\033[0;1;36;46mS\033[0;1;34;47m@\033[0;1;35;47m@\033[0;5;37;44m8\033[0;5;1;34;45m8\033[0;5;35;44m;\033[0;1;34;45m8\033[0;5;35;44m;\033[0;35;47m8\033[0;5;1;35;44m8\033[0;1;30;45m8\033[0;5;35;40m8\033[0;34;40m%%\033[0;32;40m \033[0;34;40m \033[0;31;40m \033[0m %s%s\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m:\033[0;5;33;40mS\033[0;1;32;46m8\033[0;37;43mS\033[0;1;32;47m8\033[0;37;46mS\033[0;5;37;42m8\033[0;5;36;46mX\033[0;36;47m8\033[0;1;30;46m8\033[0;5;35;44mX\033[0;1;34;45m88\033[0;1;30;45m8\033[0;37;45m@\033[0;1;34;45m8\033[0;1;30;45m8\033[0;1;30;44m@\033[0;34;40m8\033[0;32;40m%%\033[0;34;40m; \033[0;32;40m \033[0;34;40m \033[0;31;40m \033[0m %s%s\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m .\033[0;32;40m.@\033[0;1;36;46m%%\033[0;5;36;42m;\033[0;1;33;47mX\033[0;5;37;46m8\033[0;5;37;42m8\033[0;5;33;43m \033[0;5;36;46m8\033[0;1;34;46m8\033[0;1;30;45m8\033[0;34;45m8\033[0;1;30;45m8\033[0;5;34;44m.\033[0;1;30;45m8\033[0;5;34;40m@\033[0;34;40mS:\033[0;32;40m;\033[0;34;40m: \033[0;32;40m \033[0m %s%s\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m \033[0;34;40m.\033[0;31;40m;\033[0;5;36;40m8\033[0;1;36;46mt\033[0;5;36;42m.\033[0;1;33;47m@\033[0;5;36;42m \033[0;1;36;46m@X\033[0;5;36;46mX\033[0;1;36;46mS\033[0;1;30;46mX\033[0;5;34;44m8\033[0;5;35;40m;\033[0;1;30;44mS\033[0;34;40m \033[0;32;40m.\033[0;34;40m.\033[0;31;40m \033[0;34;40m \033[0;32;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m .\033[0;1;30;40mX\033[0;1;30;46m@\033[0;1;36;46m%%\033[0;5;36;42mt\033[0;5;37;43m@\033[0;1;32;47m8\033[0;5;36;46m;\033[0;1;36;46m%%S\033[0;1;30;46m@t\033[0;5;36;40m8\033[0;34;40m. \033[0;31;40m \033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m :;\033[0;5;32;40m8\033[0;1;30;46mS\033[0;32;46m8\033[0;5;32;42m.\033[0;1;32;43m8\033[0;5;37;42m88\033[0;1;36;46mX\033[0;1;30;46m.\033[0;5;36;40mX\033[0;30;44m8\033[0;31;40m:\033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m \033[0;31;40m \033[0;34;40m \033[0;32;40m;\033[0;5;32;40m8\033[0;5;36;40m8\033[0;32;46m8\033[0;5;36;40mt \033[0;1;30;46m8\033[0;5;35;44m8\033[0;37;45m@\033[0;5;35;44m%%\033[0;5;35;40m8\033[0;32;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;32;40m \033[0;31;40m \033[0;34;40m .\033[0;31;40m \033[0;5;34;40mX\033[0;1;30;45m8\033[0;34;45m8\033[0;1;30;45m8\033[0;5;34;44m8\033[0;1;30;45m8\033[0;1;35;47m8\033[0;5;36;44m8\033[0;1;30;40m8\033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;31;40m \033[0;30;44m8\033[0;1;34;45m88\033[0;1;30;45m8\033[0;5;35;44m%%\033[0;1;34;45m8\033[0;5;35;44m;\033[0;5;37;45m8\033[0;34;45m@\033[0;34;40m@\033[0;32;40m.\033[0;31;40m.\033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;32;40m \033[0;34;40m \033[0;31;40m :\033[0;5;35;40m8\033[0;1;34;45m8\033[0;1;30;45m8\033[0;5;35;44m%%\033[0;37;45m@\033[0;5;35;44m:\033[0;5;35;45mS\033[0;5;35;44m%%\033[0;35;47m8\033[0;1;30;44m8\033[0;31;40m.\033[0;34;40m.\033[0;32;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;30;44m8\033[0;1;34;45m888\033[0;5;37;45m@\033[0;35;47m8\033[0;5;35;44mt\033[0;35;47m8\033[0;5;35;44mt\033[0;5;35;45m;\033[0;30;44m8\033[0;32;40m;\033[0;31;40m \033[0;32;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;31;40m.\033[0;1;30;40m8\033[0;5;37;45m@\033[0;5;35;44m:\033[0;1;30;45m8\033[0;5;34;44m \033[0;5;35;45m \033[0;1;34;44m8\033[0;1;35;45m.\033[0;5;34;40mX\033[0;34;40m@\033[0;32;40mS\033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;31;40m \033[0;34;40m.;\033[0;1;30;40m8\033[0;1;30;44m8\033[0;34;40m8\033[0;5;34;40m8\033[0;32;40m%%\033[0;34;40m8;\033[0;32;40m;\033[0;31;40m.\033[0;32;40m \033[0;31;40m \033[0;34;40m \033[0m\n\r"
|
||||||
|
"\033[0;34;40m \033[0;31;40m \033[0;34;40m \033[0;32;40m .\033[0;31;40m .:\033[0;32;40m.\033[0;31;40m.\033[0;32;40m.\033[0;31;40m.\033[0;32;40m.\033[0;31;40m \033[0;32;40m \033[0;34;40m \033[0m\n\r",
|
||||||
|
"\033[0;36mOS\033[0m: KolibriOS", "\033[0;36mKernel\033[0m: ", str_krnl_ver, "\033[0;36mUptime\033[0m: ", str_uptime, "\033[0;36mResolution\033[0m: ", str_resolution, "\033[0;36mCPU\033[0m: ", str_cpu_info, "\033[0;36mMemory\033[0m: ", str_meminfo);
|
||||||
|
|
||||||
|
free(str_krnl_ver);
|
||||||
|
free(str_uptime);
|
||||||
|
free(str_resolution);
|
||||||
|
free(str_cpu_info);
|
||||||
|
free(str_meminfo);
|
||||||
|
return TRUE;
|
||||||
|
}
|
@ -1,31 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
int cmd_kill(char param[])
|
int cmd_kill(char param[])
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned process;
|
unsigned process;
|
||||||
int result;
|
int result;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ( strlen(param) == 0 )
|
if ( strlen(param) == 0 ) {
|
||||||
{
|
printf(CMD_KILL_USAGE);
|
||||||
printf(" kill <PID>\n\r");
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(param, "all"))
|
if (!strcmp(param, "all")) {
|
||||||
{
|
for (i = 2;i<256;i++) {
|
||||||
for (i = 2;i<256;i++)
|
|
||||||
{
|
|
||||||
kol_kill_process(i);
|
kol_kill_process(i);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
process = atoi(param);
|
||||||
process = _atoi(param);
|
if ( 0 != process ) {
|
||||||
if ( 0 != process )
|
|
||||||
{
|
|
||||||
result = kol_process_kill_pid(process);
|
result = kol_process_kill_pid(process);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_ls(char dir[])
|
int cmd_ls(char dir[]) {
|
||||||
{
|
|
||||||
|
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
unsigned *n;
|
unsigned *n;
|
||||||
|
@ -1,24 +1,15 @@
|
|||||||
|
|
||||||
int cmd_mkdir(char dir[])
|
int cmd_mkdir(char dir[]) {
|
||||||
{
|
|
||||||
|
|
||||||
char temp[FILENAME_MAX];
|
char temp[FILENAME_MAX];
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
unsigned result;
|
unsigned result;
|
||||||
|
|
||||||
if (NULL == dir)
|
if (NULL == dir) {
|
||||||
{
|
printf(CMD_MKDIR_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf(" mkdir <directory>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" mkdir <え爛<E38188><E7889B><EFBFBD>>\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 0 == strcmp(dir, ".") || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) ) {
|
||||||
if ( 0 == strcmp(dir, ".") || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
|
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +22,7 @@ k70.p20 = 0;
|
|||||||
|
|
||||||
if ( '/' == dir[0])
|
if ( '/' == dir[0])
|
||||||
k70.p21 = dir;
|
k70.p21 = dir;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
strcpy(temp, cur_dir);
|
strcpy(temp, cur_dir);
|
||||||
if (temp[strlen(temp)-1] != '/')
|
if (temp[strlen(temp)-1] != '/')
|
||||||
strcat(temp, "/"); // add slash
|
strcat(temp, "/"); // add slash
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
|
|
||||||
int cmd_more(char file[])
|
int cmd_more(char file[]) {
|
||||||
{
|
|
||||||
|
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
kol_struct_BDVK bdvk;
|
kol_struct_BDVK bdvk;
|
||||||
unsigned result, i;
|
unsigned result, i;
|
||||||
unsigned long long filesize, pos;
|
unsigned long long filesize, pos;
|
||||||
char buf[81]; //¡ãä¥à
|
char buf[81]; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
char temp[FILENAME_MAX];
|
char temp[FILENAME_MAX];
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
|
|
||||||
if (strlen(file)<1)
|
if (strlen(file)<1) {
|
||||||
{
|
printf (CMD_MORE_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf (" more <filename>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" more <¨¬ï ä ©« >\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +45,11 @@ k70.p16 = (unsigned) &bdvk;
|
|||||||
k70.p20 = 0;
|
k70.p20 = 0;
|
||||||
k70.p21 = temp;
|
k70.p21 = temp;
|
||||||
|
|
||||||
result = kol_file_70(&k70); // ¯®«ãç ¥¬ ¨ä®à¬ æ¨î ® ä ©«¥
|
result = kol_file_70(&k70); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>砥<EFBFBD> <20><><EFBFBD>ଠ<EFBFBD><E0ACA0> <20> 䠩<><E4A0A9>
|
||||||
if ( 0 != result )
|
if ( 0 != result )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
filesize = bdvk.p32; // ¯®«ãç ¥¬ à §¬¥à ä ©«
|
filesize = bdvk.p32; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>砥<EFBFBD> ࠧ<><E0A0A7><EFBFBD> 䠩<><E4A0A9>
|
||||||
|
|
||||||
buf[80]=0;
|
buf[80]=0;
|
||||||
flags = con_get_flags();
|
flags = con_get_flags();
|
||||||
@ -73,7 +67,7 @@ for (pos=0;pos<filesize;pos+=80)
|
|||||||
k70.p20 = 0;
|
k70.p20 = 0;
|
||||||
k70.p21 = temp;
|
k70.p21 = temp;
|
||||||
|
|
||||||
result = kol_file_70(&k70); // ç⥨¥ 80 ᨬ¢®«®¢
|
result = kol_file_70(&k70); // <EFBFBD>⥭<EFBFBD><EFBFBD> 80 ᨬ<><E1A8AC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
for (i=0; i<80; i++)
|
for (i=0; i<80; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,11 +24,7 @@ int cmd_mv(char param[])
|
|||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
#if LANG_ENG
|
printf(CMD_MV_USAGE);
|
||||||
printf(" mv <file_in> <file_out>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" mv <¨áâ®ç¨ª> <१ã«ìâ â>\n\r");
|
|
||||||
#endif
|
|
||||||
parameters_free(argc, argv);
|
parameters_free(argc, argv);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,12 @@
|
|||||||
|
|
||||||
int cmd_pkill(char param[])
|
int cmd_pkill(char param[])
|
||||||
{
|
{
|
||||||
int i = 1, n = 0; int process_count = 0;
|
int i = 1, n = 0; int process_count = 0;
|
||||||
char *buf1k = NULL;
|
char *buf1k = NULL;
|
||||||
unsigned PID=0;
|
unsigned PID=0;
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
|
||||||
#define PKILL_HELP " pkill <¨¬ï_¯à®æ¥áá >\n\r"
|
|
||||||
#define PKILL_KILL " PID: %u - 㡨â\n"
|
|
||||||
#define PKILL_NOT_KILL " PID: %u - ¥ 㡨â\n"
|
|
||||||
#define PKILL_NOT_FOUND " <20>à®æ¥áᮢ á â ª¨¬ ¨¬¥¥¬ ¥ ©¤¥®!\n"
|
|
||||||
#else
|
|
||||||
#define PKILL_HELP " pkill <process_name>\n\r"
|
|
||||||
#define PKILL_KILL " PID: %u - killed\n"
|
|
||||||
#define PKILL_NOT_KILL " PID: %u - not killed\n"
|
|
||||||
#define PKILL_NOT_FOUND " No processes with this name were found!\n"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if(!strlen(param)){
|
if(!strlen(param)){
|
||||||
printf(PKILL_HELP);
|
printf(CMD_PKILL_HELP);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +20,9 @@ int cmd_pkill(char param[])
|
|||||||
if(!strnicmp(buf1k+10, param, 10)){
|
if(!strnicmp(buf1k+10, param, 10)){
|
||||||
memcpy(&PID, buf1k+30 ,sizeof(unsigned));
|
memcpy(&PID, buf1k+30 ,sizeof(unsigned));
|
||||||
if(kol_process_kill_pid(PID)){
|
if(kol_process_kill_pid(PID)){
|
||||||
printf(PKILL_NOT_KILL, PID);
|
printf(CMD_PKILL_NOT_KILL, PID);
|
||||||
}else{
|
}else{
|
||||||
printf(PKILL_KILL, PID);
|
printf(CMD_PKILL_KILL, PID);
|
||||||
}
|
}
|
||||||
process_count++;
|
process_count++;
|
||||||
}
|
}
|
||||||
@ -42,7 +30,7 @@ int cmd_pkill(char param[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!process_count){
|
if(!process_count){
|
||||||
printf(PKILL_NOT_FOUND);
|
printf(CMD_PKILL_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf1k);
|
free(buf1k);
|
||||||
|
@ -15,18 +15,14 @@ sel = param && strlen(param) > 0;
|
|||||||
|
|
||||||
printf (" PID NAME RAM KB\n\r", PID, buf1k+10);
|
printf (" PID NAME RAM KB\n\r", PID, buf1k+10);
|
||||||
|
|
||||||
for (i = 1;;i++)
|
for (i = 1;;i++) {
|
||||||
{
|
|
||||||
n = kol_process_info(i, buf1k);
|
n = kol_process_info(i, buf1k);
|
||||||
memcpy(&PID, buf1k+30 ,sizeof(unsigned));
|
memcpy(&PID, buf1k+30 ,sizeof(unsigned));
|
||||||
STATE = *(buf1k+50);
|
STATE = *(buf1k+50);
|
||||||
if (9 != STATE)
|
if (9 != STATE) {
|
||||||
{
|
if (!sel || 0 == strnicmp(param, buf1k+10, 10)) {
|
||||||
if (!sel || 0 == strnicmp(param, buf1k+10, 10))
|
|
||||||
{
|
|
||||||
printf (" %7u %11s %d\n\r", PID, buf1k+10, (*(int*)(buf1k+26)+1)/1024);
|
printf (" %7u %11s %d\n\r", PID, buf1k+10, (*(int*)(buf1k+26)+1)/1024);
|
||||||
if (sel)
|
if (sel) {
|
||||||
{
|
|
||||||
LAST_PID = PID;
|
LAST_PID = PID;
|
||||||
int cpu_tck = kol_system_cpufreq() / 100;
|
int cpu_tck = kol_system_cpufreq() / 100;
|
||||||
printf (" CPU %d%% RAM %d\n\r", *(int*)buf1k / cpu_tck , *(int*)(buf1k+26)+1);
|
printf (" CPU %d%% RAM %d\n\r", *(int*)buf1k / cpu_tck , *(int*)(buf1k+26)+1);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_pwd(char param[])
|
int cmd_pwd(char param[]) {
|
||||||
{
|
|
||||||
printf (" %s%c\n\r", cur_dir, cur_dir[strlen(cur_dir)-1]=='/'?' ':'/' );
|
printf (" %s%c\n\r", cur_dir, cur_dir[strlen(cur_dir)-1]=='/'?' ':'/' );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_reboot(char param[])
|
int cmd_reboot(char param[]) {
|
||||||
{
|
|
||||||
if (!strcmp(param, "kernel"))
|
if (!strcmp(param, "kernel"))
|
||||||
kol_system_end(4);
|
kol_system_end(4);
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_ren(char param[])
|
int cmd_ren(char param[]) {
|
||||||
{
|
|
||||||
char* argv[100];
|
char* argv[100];
|
||||||
int argc;
|
int argc;
|
||||||
/*
|
/*
|
||||||
@ -9,19 +8,14 @@ int cmd_ren(char param[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
argc = parameters_prepare(param, argv);
|
argc = parameters_prepare(param, argv);
|
||||||
if (argc != 2)
|
if (argc != 2) {
|
||||||
{
|
printf(CMD_REN_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf(" ren <file> <new_name>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" ren <ä ©«> <®¢®¥_¨¬ï>\n\r");
|
|
||||||
#endif
|
|
||||||
parameters_free(argc, argv);
|
parameters_free(argc, argv);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
char *x;
|
//char *x;
|
||||||
if (x = strrchr(argv[1], '/') != 0) // argv[1] must be file name, not path
|
// argv[1] must be file name, not path
|
||||||
{
|
if (strrchr(argv[1], '/') != NULL) {
|
||||||
//printf("%d %s", x, argv[1]);
|
//printf("%d %s", x, argv[1]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
|
|
||||||
int cmd_rm(char file[])
|
int cmd_rm(char file[]) {
|
||||||
{
|
|
||||||
|
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
char temp[FILENAME_MAX];
|
char temp[FILENAME_MAX];
|
||||||
unsigned result;
|
unsigned result;
|
||||||
|
|
||||||
if (NULL == file || strlen(file) == 0)
|
if (NULL == file || strlen(file) == 0) {
|
||||||
{
|
printf (CMD_RM_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf (" rm <filename>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" rm <¨¬ï ä ©« >\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +1,15 @@
|
|||||||
|
|
||||||
int cmd_rmdir(char dir[])
|
int cmd_rmdir(char dir[]) {
|
||||||
{
|
|
||||||
|
|
||||||
char temp[FILENAME_MAX];
|
char temp[FILENAME_MAX];
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
unsigned result;
|
unsigned result;
|
||||||
|
|
||||||
if (NULL == dir || strlen(dir) == 0)
|
if (NULL == dir || strlen(dir) == 0) {
|
||||||
{
|
printf(CMD_RMDIR_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf(" rmdir <directory>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" rmdir <え爛<E38188><E7889B><EFBFBD>>\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( 0 == strcmp(dir, ".") ) || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
|
if ( ( 0 == strcmp(dir, ".") ) || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) ) {
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +22,7 @@ k70.p20 = 0;
|
|||||||
|
|
||||||
if ( '/' == dir[0])
|
if ( '/' == dir[0])
|
||||||
k70.p21 = dir;
|
k70.p21 = dir;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
strcpy(temp, cur_dir);
|
strcpy(temp, cur_dir);
|
||||||
if (temp[strlen(temp)-1] != '/')
|
if (temp[strlen(temp)-1] != '/')
|
||||||
strcat(temp, "/"); // add slash
|
strcat(temp, "/"); // add slash
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_shutdown(char param[])
|
int cmd_shutdown(char param[]) {
|
||||||
{
|
|
||||||
kol_system_end(2);
|
kol_system_end(2);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
|
|
||||||
int cmd_sleep(char param[])
|
int cmd_sleep(char param[]) {
|
||||||
{
|
|
||||||
int delay;
|
int delay;
|
||||||
|
if (!strlen(param)) {
|
||||||
if (!strlen(param))
|
printf(CMD_SLEEP_USAGE);
|
||||||
{
|
|
||||||
#if LANG_ENG
|
|
||||||
printf(" sleep <time in the 1/100 of second>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" sleep <¨â¥à¢ « ¢ á®âëå ¤®«ïx ᥪã¤ë>\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
delay = atoi(param);
|
||||||
delay = _atoi(param);
|
|
||||||
kol_sleep((unsigned)delay);
|
kol_sleep((unsigned)delay);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,27 @@
|
|||||||
|
|
||||||
int cmd_touch(char file[])
|
int cmd_touch(char file[])
|
||||||
{
|
{
|
||||||
|
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
char temp[FILENAME_MAX];
|
char temp[FILENAME_MAX];
|
||||||
unsigned result;
|
unsigned result;
|
||||||
|
|
||||||
if (NULL == file || strlen(file) == 0)
|
if (NULL == file || strlen(file) == 0) {
|
||||||
{
|
printf(CMD_TOUCH_USAGE);
|
||||||
#if LANG_ENG
|
|
||||||
printf(" touch <filename>\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" touch <¨Źď ä ŠŤ >\n\r");
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( 0 == strcmp(file, ".") ) || ( 0 == strcmp(file, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
|
if ( ( 0 == strcmp(file, ".") ) || ( 0 == strcmp(file, "..") ) || ( 0 == strcmp(cur_dir, "/")) ) {
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( '/' == file[0])
|
if ( '/' == file[0]) {
|
||||||
{
|
|
||||||
strcpy(temp, file);
|
strcpy(temp, file);
|
||||||
|
|
||||||
if ( !file_check(temp) )
|
if ( !file_check(temp) )
|
||||||
k70.p00 = 2;
|
k70.p00 = 2;
|
||||||
else
|
else
|
||||||
k70.p00 = 3;
|
k70.p00 = 3;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(temp, cur_dir);
|
strcpy(temp, cur_dir);
|
||||||
if (temp[strlen(temp)-1] != '/')
|
if (temp[strlen(temp)-1] != '/')
|
||||||
strcat(temp, "/"); // add slash
|
strcat(temp, "/"); // add slash
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
int cmd_uptime(char param[])
|
void get_str_uptime(char *str, const char *fmt) {
|
||||||
{
|
|
||||||
unsigned time_tick, up_days, up_hours, up_minutes, up_seconds, up_millisecs;
|
unsigned time_tick, up_days, up_hours, up_minutes, up_seconds, up_millisecs;
|
||||||
|
|
||||||
time_tick = kol_time_tick();
|
time_tick = kol_time_tick();
|
||||||
@ -10,11 +9,12 @@ up_minutes = (time_tick/(60*100))%60;
|
|||||||
up_seconds = (time_tick/100)%60;
|
up_seconds = (time_tick/100)%60;
|
||||||
up_millisecs = (time_tick*10)%100;
|
up_millisecs = (time_tick*10)%100;
|
||||||
|
|
||||||
#if LANG_ENG
|
sprintf (str, fmt, up_days, up_hours, up_minutes, up_seconds, up_millisecs);
|
||||||
printf (" Uptime: %d day(s), %d:%d:%d.%d\n\r", up_days, up_hours, up_minutes, up_seconds, up_millisecs);
|
}
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" Uptime: %d ¤¥©, %d:%d:%d.%d\n\r", up_days, up_hours, up_minutes, up_seconds, up_millisecs);
|
int cmd_uptime(char param[]) {
|
||||||
#endif
|
get_str_uptime(tmpstr, CMD_UPTIME_FMT);
|
||||||
|
printf(tmpstr);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
|
|
||||||
int cmd_ver(char param[])
|
void get_str_kernel_version(char *str, const char *fmt) {
|
||||||
{
|
|
||||||
|
|
||||||
if (!strcmp(param, "kernel"))
|
|
||||||
{
|
|
||||||
char *kvbuf;
|
char *kvbuf;
|
||||||
char *vA, *vB, *vC, *vD;
|
char *vA, *vB, *vC, *vD;
|
||||||
unsigned *Rev;
|
unsigned *Rev;
|
||||||
@ -16,23 +12,13 @@ if (!strcmp(param, "kernel"))
|
|||||||
vD = kvbuf+3;
|
vD = kvbuf+3;
|
||||||
Rev = (unsigned*)(kvbuf + 5);
|
Rev = (unsigned*)(kvbuf + 5);
|
||||||
|
|
||||||
#if LANG_ENG
|
sprintf (str, fmt, *vA, *vB, *vC, *vD, *Rev);
|
||||||
printf (" KolibriOS v%d.%d.%d.%d. Kernel SVN-rev.: %d\n\r", *vA, *vB, *vC, *vD, *Rev);
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" KolibriOS v%d.%d.%d.%d. SVN-ॢ. ï¤à : %d\n\r", *vA, *vB, *vC, *vD, *Rev);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
free(kvbuf);
|
free(kvbuf);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(param, "cpu"))
|
void get_str_cpu_info(char *str) {
|
||||||
{
|
|
||||||
unsigned a, b, c, d;
|
unsigned a, b, c, d;
|
||||||
char str[13];
|
|
||||||
|
|
||||||
str[12] = '\0';
|
|
||||||
|
|
||||||
asm ("cpuid" :
|
asm ("cpuid" :
|
||||||
"=a" (a),
|
"=a" (a),
|
||||||
@ -55,11 +41,22 @@ if (!strcmp(param, "cpu"))
|
|||||||
str[9] = (c&0x0000ff00) >> 8;
|
str[9] = (c&0x0000ff00) >> 8;
|
||||||
str[10] = (c&0x00ff0000) >> 16;
|
str[10] = (c&0x00ff0000) >> 16;
|
||||||
str[11] = (c&0xff000000) >> 24;
|
str[11] = (c&0xff000000) >> 24;
|
||||||
|
str[12] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
printf("%s\n\r", str);
|
int cmd_ver(char param[]) {
|
||||||
|
if (!strcmp(param, "kernel")) {
|
||||||
|
get_str_kernel_version(tmpstr, CMD_VER_FMT1);
|
||||||
|
printf(tmpstr);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(param, "cpu")) {
|
||||||
|
char str[13];
|
||||||
|
get_str_cpu_info(str);
|
||||||
|
printf("%s\n\r", str);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
printf (" Shell v%s\n\r", SHELL_VERSION);
|
printf (" Shell v%s\n\r", SHELL_VERSION);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
int cmd_waitfor(char param[])
|
/* waits for LASTPID or pid in param */
|
||||||
// waits for LASTPID or pid in param
|
int cmd_waitfor(char param[]) {
|
||||||
{
|
|
||||||
|
|
||||||
int i, n, sel, sel_pid;
|
int i, n, sel, sel_pid;
|
||||||
char *buf1k;
|
char *buf1k;
|
||||||
unsigned PID;
|
unsigned PID;
|
||||||
@ -10,27 +8,19 @@ short STATE;
|
|||||||
|
|
||||||
sel = param && strlen(param) > 0;
|
sel = param && strlen(param) > 0;
|
||||||
sel_pid = LAST_PID;
|
sel_pid = LAST_PID;
|
||||||
if (sel)
|
if (sel) {
|
||||||
{
|
sel_pid = atoi(param);
|
||||||
sel_pid = _atoi(param);
|
|
||||||
}
|
}
|
||||||
if (0 == sel_pid)
|
if (0 == sel_pid) return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
#if LANG_ENG
|
printf(CMD_WAITFOR_FMT, sel_pid);
|
||||||
printf(" Awaing finish PID %d\n\r", sel_pid);
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" Ž¦¨¤ ¥¬ § ¢¥à襨ï PID %d\n\r", sel_pid);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
buf1k = malloc(1024);
|
buf1k = malloc(1024);
|
||||||
if (NULL == buf1k)
|
if (NULL == buf1k)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while(1)
|
while(1) {
|
||||||
{
|
for (i = 1;;i++) {
|
||||||
for (i = 1;;i++)
|
|
||||||
{
|
|
||||||
n = kol_process_info(i, buf1k);
|
n = kol_process_info(i, buf1k);
|
||||||
PID = *(buf1k+30);
|
PID = *(buf1k+30);
|
||||||
STATE = *(buf1k+50);
|
STATE = *(buf1k+50);
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
@echo off
|
|
||||||
echo #define LANG_ENG 1 > lang.h
|
|
||||||
fasm start.asm start.o
|
|
||||||
gcc -c -fno-builtin shell.c
|
|
||||||
gcc -c -fno-builtin system/kolibri.c
|
|
||||||
gcc -c -fno-builtin system/stdlib.c
|
|
||||||
gcc -c -fno-builtin system/string.c
|
|
||||||
gcc -c -fno-builtin system/ctype.c
|
|
||||||
ld -nostdlib -T kolibri.ld -o shell start.o kolibri.o stdlib.o string.o ctype.o shell.o
|
|
||||||
objcopy shell -O binary
|
|
||||||
erase lang.h start.o shell.o kolibri.o stdlib.o string.o
|
|
||||||
kpack shell
|
|
||||||
move shell bin\eng\
|
|
||||||
copy locale\eng\.shell bin\eng\
|
|
||||||
pause
|
|
@ -1,15 +0,0 @@
|
|||||||
@echo off
|
|
||||||
echo #define LANG_RUS 1 > lang.h
|
|
||||||
fasm start.asm start.o
|
|
||||||
gcc -c -fno-builtin shell.c
|
|
||||||
gcc -c -fno-builtin system/kolibri.c
|
|
||||||
gcc -c -fno-builtin system/stdlib.c
|
|
||||||
gcc -c -fno-builtin system/string.c
|
|
||||||
gcc -c -fno-builtin system/ctype.c
|
|
||||||
ld -nostdlib -T kolibri.ld -o shell start.o kolibri.o stdlib.o string.o ctype.o shell.o
|
|
||||||
objcopy shell -O binary
|
|
||||||
erase lang.h start.o shell.o kolibri.o stdlib.o string.o ctype.o
|
|
||||||
kpack shell
|
|
||||||
move shell bin\rus\
|
|
||||||
copy locale\rus\.shell bin\rus\
|
|
||||||
pause
|
|
@ -1,14 +0,0 @@
|
|||||||
@echo off
|
|
||||||
fasm start.asm start.o
|
|
||||||
gcc -c -fno-builtin test.c
|
|
||||||
gcc -c -fno-builtin system/kolibri.c
|
|
||||||
gcc -c -fno-builtin system/stdlib.c
|
|
||||||
gcc -c -fno-builtin system/string.c
|
|
||||||
gcc -c -fno-builtin system/ctype.c
|
|
||||||
ld -nostdlib -T kolibri.ld -o test start.o kolibri.o stdlib.o string.o ctype.o test.o
|
|
||||||
objcopy test -O binary
|
|
||||||
erase start.o kolibri.o stdlib.o string.o ctype.o test.o
|
|
||||||
kpack test
|
|
||||||
copy test bin\eng\
|
|
||||||
move test bin\rus\
|
|
||||||
pause
|
|
@ -1,6 +0,0 @@
|
|||||||
@echo off
|
|
||||||
fasm test.asm test_asm
|
|
||||||
kpack test_asm
|
|
||||||
copy test_asm bin\eng\
|
|
||||||
move test_asm bin\rus\
|
|
||||||
pause
|
|
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
#define SHELL_VERSION "0.8.1"
|
#define SHELL_VERSION "0.8.2"
|
||||||
|
|
||||||
extern char PATH[256];
|
char cmdline[256];
|
||||||
extern char PARAM[256];
|
|
||||||
|
char tmpstr[64];
|
||||||
|
|
||||||
char title[64];
|
char title[64];
|
||||||
char cur_dir[FILENAME_MAX];
|
char cur_dir[FILENAME_MAX];
|
||||||
@ -67,6 +68,7 @@ int cmd_shutdown(char arg[]);
|
|||||||
int cmd_uptime(char param[]);
|
int cmd_uptime(char param[]);
|
||||||
int cmd_killall(char process_name[]);
|
int cmd_killall(char process_name[]);
|
||||||
int cmd_history(char arg[]);
|
int cmd_history(char arg[]);
|
||||||
|
int cmd_kfetch(char param[]);
|
||||||
int cmd_cp(char param[]);
|
int cmd_cp(char param[]);
|
||||||
int cmd_mv(char param[]);
|
int cmd_mv(char param[]);
|
||||||
int cmd_ren(char param[]);
|
int cmd_ren(char param[]);
|
||||||
|
@ -14,6 +14,7 @@ const command_t COMMANDS[]=
|
|||||||
{"free", " Displays total, free and used memory\n\r", &cmd_memory},
|
{"free", " Displays total, free and used memory\n\r", &cmd_memory},
|
||||||
{"help", " Gives help on commands. Usage:\n\r help ;it lists all builtins\n\r help <command> ;help on command\n\r", &cmd_help},
|
{"help", " Gives help on commands. Usage:\n\r help ;it lists all builtins\n\r help <command> ;help on command\n\r", &cmd_help},
|
||||||
{"history", " Lists used commands\n\r", &cmd_history},
|
{"history", " Lists used commands\n\r", &cmd_history},
|
||||||
|
{"kfetch", " Prints logo and information about system.\n\r", &cmd_kfetch},
|
||||||
{"kill", " Stops a running process. Usage:\n\r kill <PID of process>\n\r kill all\n\r", &cmd_kill},
|
{"kill", " Stops a running process. Usage:\n\r kill <PID of process>\n\r kill all\n\r", &cmd_kill},
|
||||||
{"pkill", " Kills all processes by name. Usage:\n\r pkill <process_name>\n\r", &cmd_pkill},
|
{"pkill", " Kills all processes by name. Usage:\n\r pkill <process_name>\n\r", &cmd_pkill},
|
||||||
{"ls", " Lists the files in a directory. Usage:\n\r ls ;lists the files in current directory\n\r ls <directory> ;lists the files at specified folder\n\r ls -1 ;lists the files in a single column\n\r", &cmd_ls},
|
{"ls", " Lists the files in a directory. Usage:\n\r ls ;lists the files in current directory\n\r ls <directory> ;lists the files at specified folder\n\r ls -1 ;lists the files in a single column\n\r", &cmd_ls},
|
||||||
@ -32,3 +33,35 @@ const command_t COMMANDS[]=
|
|||||||
{"waitfor", " Stops console waiting while process finish. Usage:\n\r waitfor ;waiting previous started executable LASTPID\n\r waitfor <PID>;awaiting PID finish\n\r", &cmd_waitfor},
|
{"waitfor", " Stops console waiting while process finish. Usage:\n\r waitfor ;waiting previous started executable LASTPID\n\r waitfor <PID>;awaiting PID finish\n\r", &cmd_waitfor},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CMD_ABOUT_MSG "Shell %s\n\r"
|
||||||
|
#define CMD_CD_USAGE " cd <directory>\n\r"
|
||||||
|
#define CMD_CP_USAGE " cp <file_in> <file_out>\n\r"
|
||||||
|
#define CMD_DATE_DATE_FMT " Date [dd.mm.yy]: %x%x.%x%x.%x%x"
|
||||||
|
#define CMD_DATE_TIME_FMT "\n\r Time [hh:mm:ss]: %x%x:%x%x:%x%x\n\r"
|
||||||
|
#define CMD_FREE_FMT " Total [kB / MB / %%]: %-7d / %-5d / 100\n\r Free [kB / MB / %%]: %-7d / %-5d / %d\n\r Used [kB / MB / %%]: %-7d / %-5d / %d\n\r"
|
||||||
|
#define CMD_HELP_AVAIL " %d commands available:\n\r"
|
||||||
|
#define CMD_HELP_CMD_NOT_FOUND " Command \'%s\' not found.\n\r"
|
||||||
|
|
||||||
|
#define CMD_KILL_USAGE " kill <PID>\n\r"
|
||||||
|
#define CMD_MKDIR_USAGE " mkdir <directory>\n\r"
|
||||||
|
#define CMD_MORE_USAGE " more <filename>\n\r"
|
||||||
|
#define CMD_MV_USAGE " mv <file_in> <file_out>\n\r"
|
||||||
|
|
||||||
|
#define CMD_PKILL_HELP " pkill <process_name>\n\r"
|
||||||
|
#define CMD_PKILL_KILL " PID: %u - killed\n"
|
||||||
|
#define CMD_PKILL_NOT_KILL " PID: %u - not killed\n"
|
||||||
|
#define CMD_PKILL_NOT_FOUND " No processes with this name were found!\n"
|
||||||
|
|
||||||
|
#define CMD_REN_USAGE " ren <file> <new_name>\n\r"
|
||||||
|
#define CMD_RM_USAGE " rm <filename>\n\r"
|
||||||
|
#define CMD_RMDIR_USAGE " rmdir <directory>\n\r"
|
||||||
|
#define CMD_SLEEP_USAGE " sleep <time in the 1/100 of second>\n\r"
|
||||||
|
#define CMD_TOUCH_USAGE " touch <filename>\n\r"
|
||||||
|
#define CMD_UPTIME_FMT " Uptime: %d day(s), %d:%d:%d.%d\n\r"
|
||||||
|
#define CMD_VER_FMT1 " KolibriOS v%d.%d.%d.%d. Kernel SVN-rev.: %d\n\r"
|
||||||
|
#define CMD_WAITFOR_FMT " Awaing finish PID %d\n\r"
|
||||||
|
#define EXEC_STARTED_FMT " '%s' started. PID = %d\n\r"
|
||||||
|
#define EXEC_SCRIPT_ERROR_FMT "Error in '%s' : script must start with #SHS line\n\r"
|
||||||
|
#define UNKNOWN_CMD_ERROR " Error!\n\r"
|
||||||
|
#define CON_APP_ERROR " Error in console application.\n\r"
|
||||||
|
#define FILE_NOT_FOUND_ERROR " File '%s' not found.\n\r"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* WARNING: SAVE ONLY IN CP866 ENCODING! */
|
||||||
|
|
||||||
const command_t COMMANDS[]=
|
const command_t COMMANDS[]=
|
||||||
{
|
{
|
||||||
@ -14,6 +15,7 @@ const command_t COMMANDS[]=
|
|||||||
{"free", " <20>®ª §ë¢ ¥â ®¡êñ¬ ®¯¥à ⨢®© ¯ ¬ïâ¨: ¢á¥©, ᢮¡®¤®© ¨ ¨á¯®«ì§ã¥¬®©\n\r", &cmd_memory},
|
{"free", " <20>®ª §ë¢ ¥â ®¡êñ¬ ®¯¥à ⨢®© ¯ ¬ïâ¨: ¢á¥©, ᢮¡®¤®© ¨ ¨á¯®«ì§ã¥¬®©\n\r", &cmd_memory},
|
||||||
{"help", " ‘¯à ¢ª ¯® ª®¬ ¤ ¬. ˆá¯®«ì§®¢ ¨¥:\n\r help ;ᯨ᮪ ¢á¥å ª®¬ ¤\n\r help <ª®¬ ¤ > ;á¯à ¢ª ¯® ª®¬ ¤¥\n\r", &cmd_help},
|
{"help", " ‘¯à ¢ª ¯® ª®¬ ¤ ¬. ˆá¯®«ì§®¢ ¨¥:\n\r help ;ᯨ᮪ ¢á¥å ª®¬ ¤\n\r help <ª®¬ ¤ > ;á¯à ¢ª ¯® ª®¬ ¤¥\n\r", &cmd_help},
|
||||||
{"history", " ‘¯¨á®ª ¨á¯®«ì§®¢ ëå ª®¬ ¤\n\r", &cmd_history},
|
{"history", " ‘¯¨á®ª ¨á¯®«ì§®¢ ëå ª®¬ ¤\n\r", &cmd_history},
|
||||||
|
{"kfetch", " <20>¥ç ⠥⠫®£® ¨ ¨ä®à¬ æ¨î ® á¨á⥬¥.\n\r", &cmd_kfetch},
|
||||||
{"kill", " “¡¨¢ ¥â ¯à®æ¥áá. ˆá¯®«ì§®¢ ¨¥:\n\r kill <PID ¯à®æ¥áá >\n\r kill all\n\r", &cmd_kill},
|
{"kill", " “¡¨¢ ¥â ¯à®æ¥áá. ˆá¯®«ì§®¢ ¨¥:\n\r kill <PID ¯à®æ¥áá >\n\r kill all\n\r", &cmd_kill},
|
||||||
{"pkill", " “¡¨¢ ¥â ¢á¥ ¯à®æ¥ááë ¯® ¨¬¥¨. ˆá¯®«ì§®¢ ¨¥:\n\r pkill <¨¬ï_¯à®æ¥áá >\n\r", &cmd_pkill},
|
{"pkill", " “¡¨¢ ¥â ¢á¥ ¯à®æ¥ááë ¯® ¨¬¥¨. ˆá¯®«ì§®¢ ¨¥:\n\r pkill <¨¬ï_¯à®æ¥áá >\n\r", &cmd_pkill},
|
||||||
{"ls", " ‚뢮¤¨â ᯨ᮪ ä ©«®¢. ˆá¯®«ì§®¢ ¨¥:\n\r ls ;ᯨ᮪ ä ©«®¢ ¢ ⥪ã饬 ª â «®£¥\n\r ls <¤¨à¥ªâ®à¨ï> ;ᯨ᮪ ä ©«®¢ ¨§ § ¤ ®© ¤¨à¥ªâ®à¨¨\n\r", &cmd_ls},
|
{"ls", " ‚뢮¤¨â ᯨ᮪ ä ©«®¢. ˆá¯®«ì§®¢ ¨¥:\n\r ls ;ᯨ᮪ ä ©«®¢ ¢ ⥪ã饬 ª â «®£¥\n\r ls <¤¨à¥ªâ®à¨ï> ;ᯨ᮪ ä ©«®¢ ¨§ § ¤ ®© ¤¨à¥ªâ®à¨¨\n\r", &cmd_ls},
|
||||||
@ -32,3 +34,34 @@ const command_t COMMANDS[]=
|
|||||||
{"waitfor", " <20>ਮáâ ¢«¨¢ ¥â ¢ë¯®«¥¨¥ ª®¬ ¤. ˆá¯®«ì§®¢ ¨¥:\n\r waitfor ;®¦¨¤ ¥¬ ¯à¥¤ë¤ã騩 § ¯ãé¥ë© ¯à®æ¥áá LASTPID\n\r waitfor <PID>;¦¤¥¬ § ¢¥àè¥¨ï ¯à®æ¥áá á 㪠§ ë¬ PID\n\r", &cmd_waitfor},
|
{"waitfor", " <20>ਮáâ ¢«¨¢ ¥â ¢ë¯®«¥¨¥ ª®¬ ¤. ˆá¯®«ì§®¢ ¨¥:\n\r waitfor ;®¦¨¤ ¥¬ ¯à¥¤ë¤ã騩 § ¯ãé¥ë© ¯à®æ¥áá LASTPID\n\r waitfor <PID>;¦¤¥¬ § ¢¥àè¥¨ï ¯à®æ¥áá á 㪠§ ë¬ PID\n\r", &cmd_waitfor},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CMD_ABOUT_MSG "Shell %s\n\r"
|
||||||
|
#define CMD_CD_USAGE " cd <¤¨à¥ªâ®à¨ï>\n\r"
|
||||||
|
#define CMD_CP_USAGE " cp <¨áâ®ç¨ª> <१ã«ìâ â>\n\r"
|
||||||
|
#define CMD_DATE_DATE_FMT " „ â [¤¤.¬¬.££]: %x%x.%x%x.%x%x"
|
||||||
|
#define CMD_DATE_TIME_FMT "\n\r ‚६ï [çç:¬¬:áá]: %x%x:%x%x:%x%x\n\r"
|
||||||
|
#define CMD_FREE_FMT " ‚ᥣ® [Š<> / Œ<> / %%]: %-7d / %-5d / 100\n\r ‘¢®¡®¤® [Š<> / Œ<> / %%]: %-7d / %-5d / %d\n\r ˆá¯®«ì§ã¥âáï [Š<> / Œ<> / %%]: %-7d / %-5d / %d\n\r"
|
||||||
|
#define CMD_HELP_AVAIL " Š®«¨ç¥á⢮ ¤®áâã¯ëå ª®¬ ¤: %d\n\r"
|
||||||
|
#define CMD_HELP_CMD_NOT_FOUND " Š®¬ ¤ \'%s\' ¥ ©¤¥ .\n\r"
|
||||||
|
|
||||||
|
#define CMD_KILL_USAGE " kill <PID>\n\r"
|
||||||
|
#define CMD_MKDIR_USAGE " mkdir <¤¨à¥ªâ®à¨ï>\n\r"
|
||||||
|
#define CMD_MORE_USAGE " more <¨¬ï ä ©« >\n\r"
|
||||||
|
#define CMD_MV_USAGE " mv <¨áâ®ç¨ª> <१ã«ìâ â>\n\r"
|
||||||
|
#define CMD_PKILL_HELP " pkill <¨¬ï ¯à®æ¥áá >\n\r"
|
||||||
|
#define CMD_PKILL_KILL " PID: %u - 㡨â\n"
|
||||||
|
#define CMD_PKILL_NOT_KILL " PID: %u - ¥ 㡨â\n"
|
||||||
|
#define CMD_PKILL_NOT_FOUND " <20>à®æ¥áᮢ á â ª¨¬ ¨¬¥¥¬ ¥ ©¤¥®!\n"
|
||||||
|
|
||||||
|
#define CMD_REN_USAGE " ren <ä ©«> <®¢®¥ ¨¬ï>\n\r"
|
||||||
|
#define CMD_RM_USAGE " rm <¨¬ï ä ©« >\n\r"
|
||||||
|
#define CMD_RMDIR_USAGE " rmdir <¤¨à¥ªâ®à¨ï>\n\r"
|
||||||
|
#define CMD_SLEEP_USAGE " sleep <¨â¥à¢ « ¢ á®âëå ¤®«ïx ᥪã¤ë>\n\r"
|
||||||
|
#define CMD_TOUCH_USAGE " touch <¨¬ï ä ©« >\n\r"
|
||||||
|
#define CMD_UPTIME_FMT " Uptime: %d ¤¥©, %d:%d:%d.%d\n\r"
|
||||||
|
#define CMD_VER_FMT1 " KolibriOS v%d.%d.%d.%d. SVN-ॢ. ï¤à : %d\n\r"
|
||||||
|
#define CMD_WAITFOR_FMT " Ž¦¨¤ ¥¬ § ¢¥à襨ï PID %d\n\r"
|
||||||
|
#define EXEC_STARTED_FMT " '%s' § ¯ãé¥. PID = %d\n\r"
|
||||||
|
#define EXEC_SCRIPT_ERROR_FMT "Žè¨¡ª ¢ '%s' : áªà¨¯â ¤®«¦¥ ç¨ âìáï á® áâà®çª¨ #SHS\n\r"
|
||||||
|
#define UNKNOWN_CMD_ERROR " Žè¨¡ª !\n\r"
|
||||||
|
#define CON_APP_ERROR " Žè¨¡ª ¢ ª®á®«ì®¬ ¯à¨«®¦¥¨¨.\n\r"
|
||||||
|
#define FILE_NOT_FOUND_ERROR " ” ©« '%s' ¥ ©¤¥.\n\r"
|
@ -1,9 +1,5 @@
|
|||||||
|
|
||||||
/// ===========================================================
|
void command_history_add() {
|
||||||
|
|
||||||
void command_history_add()
|
|
||||||
{
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ('\0' == CMD[0]) return;
|
if ('\0' == CMD[0]) return;
|
||||||
@ -23,7 +19,7 @@ if (CMD_HISTORY_NUM_REAL < CMD_HISTORY_NUM-1)
|
|||||||
CMD_HISTORY_NUM_REAL++;
|
CMD_HISTORY_NUM_REAL++;
|
||||||
|
|
||||||
}
|
}
|
||||||
// ============================================================
|
|
||||||
|
|
||||||
char * insert_string( char s1[], unsigned int pos, const char s2[] )
|
char * insert_string( char s1[], unsigned int pos, const char s2[] )
|
||||||
{
|
{
|
||||||
@ -48,7 +44,7 @@ char * insert_string( char s1[], unsigned int pos, const char s2[] )
|
|||||||
return s1;
|
return s1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void command_get()
|
void command_get()
|
||||||
{
|
{
|
||||||
@ -63,14 +59,11 @@ int clipNum; // number of clipboard slots
|
|||||||
char* clipBuf; // clipboard buffer
|
char* clipBuf; // clipboard buffer
|
||||||
char clipCopy[255+12];
|
char clipCopy[255+12];
|
||||||
|
|
||||||
for (;;)
|
for (;;) {
|
||||||
{
|
|
||||||
key = getch();
|
key = getch();
|
||||||
if ( 0 != (key & 0xff) )
|
if ( 0 != (key & 0xff) ) {
|
||||||
{
|
|
||||||
key &= 0xff;
|
key &= 0xff;
|
||||||
switch (key)
|
switch (key) {
|
||||||
{
|
|
||||||
case 27: // ESC
|
case 27: // ESC
|
||||||
for (i = cmdPos; i < cmdLen; i++)
|
for (i = cmdPos; i < cmdLen; i++)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
@ -113,10 +106,10 @@ for (;;)
|
|||||||
|
|
||||||
|
|
||||||
case 22: // Ctrl+V
|
case 22: // Ctrl+V
|
||||||
clipNum = kol_clip_num();
|
clipNum = _ksys_clip_num();
|
||||||
if (clipNum > 0)
|
if (clipNum > 0)
|
||||||
{
|
{
|
||||||
clipBuf = kol_clip_get(clipNum-1);
|
clipBuf = _ksys_clip_get(clipNum-1);
|
||||||
// printf("Length: %d, Type: %d, Encoding: %d\n", (int) *clipBuf, (int)*(clipBuf+4), (int)*(clipBuf+8));
|
// printf("Length: %d, Type: %d, Encoding: %d\n", (int) *clipBuf, (int)*(clipBuf+4), (int)*(clipBuf+8));
|
||||||
if ( (int) *clipBuf > 0 ) // is clipboard empty?
|
if ( (int) *clipBuf > 0 ) // is clipboard empty?
|
||||||
{
|
{
|
||||||
@ -155,7 +148,7 @@ for (;;)
|
|||||||
for (i = 0; i <= cmdLen; i++)
|
for (i = 0; i <= cmdLen; i++)
|
||||||
*(clipCopy+12+i) = CMD[i];
|
*(clipCopy+12+i) = CMD[i];
|
||||||
|
|
||||||
kol_clip_set(12+cmdLen, clipCopy);
|
_ksys_clip_set(12+cmdLen, clipCopy);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -164,8 +157,8 @@ for (;;)
|
|||||||
default:
|
default:
|
||||||
if (cmdLen < 255)
|
if (cmdLen < 255)
|
||||||
{
|
{
|
||||||
if ( kol_key_control() & 0x40 ) // ¥á«¨ ¢ª«îçñ CapsLock
|
if ( kol_key_control() & 0x40 ) // <EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CapsLock
|
||||||
if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // ¥á«¨ ¦ âë è¨äâë
|
if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // <EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
key = tolower(key);
|
key = tolower(key);
|
||||||
else
|
else
|
||||||
key = toupper(key);
|
key = toupper(key);
|
||||||
@ -298,14 +291,13 @@ for (;;)
|
|||||||
case 0: // console window closed
|
case 0: // console window closed
|
||||||
cmd_exit(NULL);
|
cmd_exit(NULL);
|
||||||
|
|
||||||
}
|
} // switch end
|
||||||
|
} // if end
|
||||||
}
|
} // for end
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
int command_get_cmd(char cmd[])
|
int command_get_cmd(char cmd[])
|
||||||
{
|
{
|
||||||
@ -353,11 +345,11 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
typedef int (*handler1_t)(char* arg);
|
typedef int (*handler1_t)(char* arg);
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void command_execute()
|
void command_execute()
|
||||||
{
|
{
|
||||||
@ -376,26 +368,17 @@ if ( !strlen(cmd) )
|
|||||||
strcpy(args, CMD+arg);
|
strcpy(args, CMD+arg);
|
||||||
trim(args);
|
trim(args);
|
||||||
|
|
||||||
for (i = 0; i < NUM_OF_CMD; i++)
|
for (i = 0; i < NUM_OF_CMD; i++) {
|
||||||
{
|
if (!strcmp(cmd, COMMANDS[i].name)) {
|
||||||
if (!strcmp(cmd, COMMANDS[i].name))
|
|
||||||
{
|
|
||||||
result = ((handler1_t)COMMANDS[i].handler)(args);
|
result = ((handler1_t)COMMANDS[i].handler)(args);
|
||||||
if (result == FALSE)
|
if (result == FALSE) {
|
||||||
{
|
printf(UNKNOWN_CMD_ERROR);
|
||||||
#if LANG_ENG
|
|
||||||
printf(" Error!\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf(" Žè¨¡ª !\n\r");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( -1 != alias_search(CMD) ) {
|
||||||
if ( -1 != alias_search(CMD) )
|
|
||||||
{
|
|
||||||
strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD));
|
strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD));
|
||||||
command_execute();
|
command_execute();
|
||||||
return;
|
return;
|
||||||
@ -404,6 +387,3 @@ if ( -1 != alias_search(CMD) )
|
|||||||
executable_run(cmd, args);
|
executable_run(cmd, args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
|
|
||||||
/// ===========================================================
|
int executable_run(char cmd[], char args[]) {
|
||||||
|
|
||||||
int executable_run(char cmd[], char args[])
|
|
||||||
{
|
|
||||||
|
|
||||||
char exec[FILENAME_MAX];
|
char exec[FILENAME_MAX];
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -15,9 +11,7 @@ int executable_run(char cmd[], char args[])
|
|||||||
file_not_found(cmd);
|
file_not_found(cmd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(exec, cur_dir); // check file in current directory
|
strcpy(exec, cur_dir); // check file in current directory
|
||||||
if (exec[strlen(exec)-1] != '/')
|
if (exec[strlen(exec)-1] != '/')
|
||||||
strcat(exec, "/"); // add slash
|
strcat(exec, "/"); // add slash
|
||||||
@ -39,36 +33,22 @@ int executable_run(char cmd[], char args[])
|
|||||||
|
|
||||||
// try to run as a program
|
// try to run as a program
|
||||||
result = program_run(exec, args);
|
result = program_run(exec, args);
|
||||||
if (result > 0)
|
if (result > 0) {
|
||||||
{
|
if ( !program_console(result) ) {
|
||||||
if ( !program_console(result) )
|
|
||||||
{
|
|
||||||
LAST_PID = result;
|
LAST_PID = result;
|
||||||
#if LANG_ENG
|
printf (EXEC_STARTED_FMT, cmd, result);
|
||||||
printf (" '%s' started. PID = %d\n\r", cmd, result);
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" '%s' § ¯ãé¥. PID = %d\n\r", cmd, result);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( script_check(exec) ) // if file is a valid script
|
if ( script_check(exec) ) // if file is a valid script
|
||||||
{
|
{
|
||||||
return script_run(exec, args);
|
return script_run(exec, args);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
#if LANG_ENG
|
printf (EXEC_SCRIPT_ERROR_FMT, cmd);
|
||||||
printf ("Error in '%s' : script must start with #SHS line\n\r", cmd);
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf ("Žè¨¡ª ¢ '%s' : áªà¨¯â ¤®«¦¥ ç¨ âìáï á® áâà®çª¨ #SHS\n\r", cmd);
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
|
|
||||||
/// ===========================================================
|
int parameters_prepare(char *param, char* argv[]) {
|
||||||
|
|
||||||
int parameters_prepare(char *param, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int i, param_len;
|
int i, param_len;
|
||||||
int argc = 1;
|
int argc = 1;
|
||||||
int quote = 0;
|
int quote = 0;
|
||||||
@ -16,16 +12,11 @@ if ( param_len == 0 )
|
|||||||
argv[0] = (char*) malloc(4096);
|
argv[0] = (char*) malloc(4096);
|
||||||
|
|
||||||
argv_len = 0;
|
argv_len = 0;
|
||||||
for (i = 0; i < param_len; i++)
|
for (i = 0; i < param_len; i++) {
|
||||||
{
|
switch (param[i]) {
|
||||||
switch (param[i])
|
|
||||||
{
|
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
if (param[i+1]!='\0')
|
if (param[i+1]!='\0') {
|
||||||
{
|
switch(param[i+1]) {
|
||||||
switch(param[i+1])
|
|
||||||
{
|
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
argv[argc-1][argv_len] = '\n';
|
argv[argc-1][argv_len] = '\n';
|
||||||
@ -56,8 +47,7 @@ for (i = 0; i < param_len; i++)
|
|||||||
case '"':
|
case '"':
|
||||||
if (quote == 0)
|
if (quote == 0)
|
||||||
quote = 1;
|
quote = 1;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
quote = 0;
|
quote = 0;
|
||||||
argv[argc-1][argv_len] = '\0';
|
argv[argc-1][argv_len] = '\0';
|
||||||
argc++;
|
argc++;
|
||||||
@ -69,12 +59,9 @@ for (i = 0; i < param_len; i++)
|
|||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
case 32:
|
case 32:
|
||||||
if (quote == 0)
|
if (quote == 0) {
|
||||||
{
|
if ( ( param[i+1] != 32) || ( param[i+1] != 9) ) {
|
||||||
if ( ( param[i+1] != 32) || ( param[i+1] != 9) )
|
if (argv_len != 0) {
|
||||||
{
|
|
||||||
if (argv_len != 0)
|
|
||||||
{
|
|
||||||
argv[argc-1][argv_len] = '\0';
|
argv[argc-1][argv_len] = '\0';
|
||||||
argc++;
|
argc++;
|
||||||
argv[argc-1] = (char*) malloc(4096);
|
argv[argc-1] = (char*) malloc(4096);
|
||||||
@ -82,27 +69,22 @@ for (i = 0; i < param_len; i++)
|
|||||||
argv_len = 0;
|
argv_len = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
argv[argc-1][argv_len] = param[i];
|
argv[argc-1][argv_len] = param[i];
|
||||||
argv_len++;
|
argv_len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
argv[argc-1][argv_len] = param[i];
|
argv[argc-1][argv_len] = param[i];
|
||||||
argv_len++;
|
argv_len++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
};
|
}; // switch end
|
||||||
}
|
} // for end
|
||||||
|
|
||||||
argv[argc-1][argv_len] = '\0';
|
argv[argc-1][argv_len] = '\0';
|
||||||
|
|
||||||
if ( strlen(argv[argc-1]) == 0 )
|
if ( strlen(argv[argc-1]) == 0 ) {
|
||||||
{
|
|
||||||
free(argv[argc-1]);
|
free(argv[argc-1]);
|
||||||
argc--;
|
argc--;
|
||||||
}
|
}
|
||||||
@ -110,17 +92,9 @@ if ( strlen(argv[argc-1]) == 0 )
|
|||||||
return argc;
|
return argc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void parameters_free(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
|
void parameters_free(int argc, char* argv[]) {
|
||||||
int i;
|
int i;
|
||||||
|
for (i = 0; i < argc; i++) free(argv[i]);
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
free(argv[i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
#include "../program_console.h"
|
#include "../program_console.h"
|
||||||
|
|
||||||
|
|
||||||
int program_console(int pid)
|
int program_console(int pid) {
|
||||||
{
|
|
||||||
|
|
||||||
char name[32];
|
char name[32];
|
||||||
char *buffer;
|
char *buffer;
|
||||||
char *buf1k;
|
char *buf1k;
|
||||||
@ -20,8 +18,7 @@ strcat(name, "-SHELL");
|
|||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
buf1k = NULL;
|
buf1k = NULL;
|
||||||
|
|
||||||
for (i = 0; i < 30; i++)
|
for (i = 0; i < 30; i++) {
|
||||||
{
|
|
||||||
result = kol_buffer_open(name, SHM_OPEN | SHM_WRITE, 0, &buffer);
|
result = kol_buffer_open(name, SHM_OPEN | SHM_WRITE, 0, &buffer);
|
||||||
if (buffer != NULL)
|
if (buffer != NULL)
|
||||||
break;
|
break;
|
||||||
@ -35,13 +32,10 @@ for (i = 0; i < 30; i++)
|
|||||||
size = result;
|
size = result;
|
||||||
|
|
||||||
is_end = 0;
|
is_end = 0;
|
||||||
for (;;)
|
for (;;) {
|
||||||
{
|
|
||||||
|
|
||||||
command = *(buffer);
|
command = *(buffer);
|
||||||
|
|
||||||
switch (command)
|
switch (command) {
|
||||||
{
|
|
||||||
case SC_EXIT:
|
case SC_EXIT:
|
||||||
*buffer = SC_OK;
|
*buffer = SC_OK;
|
||||||
is_end = 1;
|
is_end = 1;
|
||||||
@ -89,20 +83,14 @@ for (i = 0; i < 30; i++)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#if LANG_ENG
|
printf (CON_APP_ERROR);
|
||||||
printf (" Error in console application.\n\r");
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" Žè¨¡ª ¢ ª®á®«ì®¬ ¯à¨«®¦¥¨¨.\n\r");
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
if (is_end)
|
if (is_end) {
|
||||||
{
|
|
||||||
printf("\n\r");
|
printf("\n\r");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
} // for end
|
||||||
|
|
||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
int script_check(char file[])
|
|
||||||
{
|
|
||||||
|
|
||||||
|
int script_check(char file[]) {
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
||||||
@ -23,11 +20,8 @@ int script_check(char file[])
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
int script_run(char exec[], char args[])
|
|
||||||
{
|
|
||||||
|
|
||||||
|
int script_run(char exec[], char args[]) {
|
||||||
kol_struct70 k70;
|
kol_struct70 k70;
|
||||||
kol_struct_BDVK bdvk;
|
kol_struct_BDVK bdvk;
|
||||||
unsigned result, i;
|
unsigned result, i;
|
||||||
@ -72,7 +66,6 @@ int script_run(char exec[], char args[])
|
|||||||
|
|
||||||
for (;;) // script processing
|
for (;;) // script processing
|
||||||
{
|
{
|
||||||
|
|
||||||
if (pos > filesize)
|
if (pos > filesize)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -101,6 +94,3 @@ int script_run(char exec[], char args[])
|
|||||||
free(buf);
|
free(buf);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ void dir_truncate(char dir[]);
|
|||||||
int iswhite(char c);
|
int iswhite(char c);
|
||||||
void trim(char string[]);
|
void trim(char string[]);
|
||||||
void execute();
|
void execute();
|
||||||
void kol_main();
|
|
||||||
|
|
||||||
int executable_run(char cmd[], char args[]);
|
int executable_run(char cmd[], char args[]);
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
int dir_check(char dir[])
|
int dir_check(char dir[])
|
||||||
/// just checks, if dir[] is really a directory
|
/// just checks, if dir[] is really a directory
|
||||||
{
|
{
|
||||||
@ -28,8 +26,6 @@ else
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void dir_truncate(char dir[])
|
void dir_truncate(char dir[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -41,7 +37,6 @@ for (;;i--)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void get_file_dir_loc(char *filepath, char *dir_path)
|
void get_file_dir_loc(char *filepath, char *dir_path)
|
||||||
{
|
{
|
||||||
@ -56,7 +51,6 @@ void get_file_dir_loc(char *filepath, char *dir_path)
|
|||||||
dir_path[pos] = '\0';
|
dir_path[pos] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
int file_check(char file[])
|
int file_check(char file[])
|
||||||
{
|
{
|
||||||
@ -79,25 +73,13 @@ else
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void file_not_found(char file[])
|
void file_not_found(char file[]) {
|
||||||
{
|
printf (FILE_NOT_FOUND_ERROR, file);
|
||||||
#if LANG_ENG
|
|
||||||
printf (" File '%s' not found.\n\r", file);
|
|
||||||
#elif LANG_RUS
|
|
||||||
printf (" ” ©« '%s' ¥ ©¤¥.\n\r", file);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
int iswhite(char c)
|
int iswhite(char c) {return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c)); }
|
||||||
{
|
|
||||||
return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void trim(char string[])
|
void trim(char string[])
|
||||||
{
|
{
|
||||||
@ -125,24 +107,29 @@ for (;i>0;--i)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
|
||||||
void kol_main()
|
// entry point
|
||||||
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int i; for (i = 1; i < argc; i++) {
|
||||||
|
strcat(cmdline, argv[i]);
|
||||||
|
if (i != argc - 1) {
|
||||||
|
strcat(cmdline, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
|
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
|
||||||
|
|
||||||
strcpy(title, "SHELL ");
|
strcpy(title, "SHELL ");
|
||||||
strcat(title, SHELL_VERSION);
|
strcat(title, SHELL_VERSION);
|
||||||
CONSOLE_INIT(title);
|
con_init_opt(-1, -1, -1, -1, title);
|
||||||
|
|
||||||
if (sizeof (kol_struct70) != 25)
|
//printf("argc = %d\ncmdline = '%s'\n", argc, cmdline);
|
||||||
{
|
|
||||||
|
if (sizeof (kol_struct70) != 25) {
|
||||||
printf("Invalid struct align kol_struct70, need to fix compile options\n\r");
|
printf("Invalid struct align kol_struct70, need to fix compile options\n\r");
|
||||||
kol_exit();
|
kol_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//strcpy(cur_dir, PATH);
|
//strcpy(cur_dir, PATH);
|
||||||
//dir_truncate(cur_dir);
|
//dir_truncate(cur_dir);
|
||||||
getcwd(cur_dir, sizeof cur_dir);
|
getcwd(cur_dir, sizeof cur_dir);
|
||||||
@ -152,28 +139,25 @@ con_set_cursor_height(con_get_font_height()-1);
|
|||||||
|
|
||||||
ALIASES = malloc(128*1024);
|
ALIASES = malloc(128*1024);
|
||||||
|
|
||||||
if (!PARAM || PARAM[0] == 0)
|
if (!cmdline || cmdline[0] == 0) {
|
||||||
{
|
strcpy(CMD, argv[0]);
|
||||||
strcpy(CMD, PATH);
|
|
||||||
dir_truncate(CMD);
|
dir_truncate(CMD);
|
||||||
strcat(CMD, ".shell");
|
strcat(CMD, ".shell");
|
||||||
if ( !file_check(CMD) )
|
if ( !file_check(CMD) )
|
||||||
strcpy(CMD, "/sys/settings/.shell");
|
strcpy(CMD, "/sys/settings/.shell");
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
if (cmdline[0] == '/')
|
||||||
{
|
{
|
||||||
if (PARAM[0] == '/')
|
strcpy(cur_dir, cmdline);
|
||||||
{
|
|
||||||
strcpy(cur_dir, PARAM);
|
|
||||||
*(strrchr(cur_dir, '/')+1)=0;
|
*(strrchr(cur_dir, '/')+1)=0;
|
||||||
}
|
}
|
||||||
strcpy(CMD, PARAM);
|
strcpy(CMD, cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
command_execute();
|
command_execute();
|
||||||
|
|
||||||
for (;;)
|
for (;;) {
|
||||||
{
|
|
||||||
//printf("\033[32;1m");
|
//printf("\033[32;1m");
|
||||||
printf ("# ");
|
printf ("# ");
|
||||||
//printf("\033[0m");
|
//printf("\033[0m");
|
||||||
@ -181,8 +165,6 @@ for (;;)
|
|||||||
command_execute();
|
command_execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit(0);
|
con_exit(0);
|
||||||
kol_exit();
|
kol_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ===========================================================
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
format MS COFF
|
|
||||||
|
|
||||||
public Start
|
|
||||||
public _PATH
|
|
||||||
public _PARAM
|
|
||||||
|
|
||||||
extrn Memory
|
|
||||||
extrn hEnd
|
|
||||||
|
|
||||||
extrn _kol_main
|
|
||||||
|
|
||||||
section ".text" code
|
|
||||||
db "MENUET01"
|
|
||||||
dd 1, Start, hEnd, Memory, hStack, _PARAM, _PATH
|
|
||||||
|
|
||||||
Start:
|
|
||||||
|
|
||||||
; èíèöèàëèçàöèÿ êó÷è
|
|
||||||
mov eax, 68
|
|
||||||
mov ebx, 11
|
|
||||||
int 0x40
|
|
||||||
|
|
||||||
; âûçîâ ãëàâíîé ïðîöåäóðû
|
|
||||||
mov eax, _kol_main
|
|
||||||
call eax
|
|
||||||
|
|
||||||
; çàâåðøåíèå ðàáîòû ïðîãðàììû
|
|
||||||
mov eax, -1
|
|
||||||
int 0x40
|
|
||||||
|
|
||||||
section ".bss"
|
|
||||||
|
|
||||||
_PARAM:
|
|
||||||
rb 256
|
|
||||||
|
|
||||||
_PATH:
|
|
||||||
rb 256
|
|
||||||
|
|
||||||
rb 8*1024
|
|
||||||
hStack:
|
|
@ -1,88 +0,0 @@
|
|||||||
|
|
||||||
///===========================
|
|
||||||
|
|
||||||
#define CON_COLOR_BLUE 1
|
|
||||||
#define CON_COLOR_GREEN 2
|
|
||||||
#define CON_COLOR_RED 4
|
|
||||||
#define CON_COLOR_BRIGHT 8
|
|
||||||
/* öâåò ôîíà */
|
|
||||||
#define CON_BGR_BLUE 0x10
|
|
||||||
#define CON_BGR_GREEN 0x20
|
|
||||||
#define CON_BGR_RED 0x40
|
|
||||||
#define CON_BGR_BRIGHT 0x80
|
|
||||||
|
|
||||||
///===========================
|
|
||||||
|
|
||||||
void (* _stdcall con_init)(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
|
|
||||||
void (* _cdecl printf)(const char* format,...);
|
|
||||||
void (* _stdcall _exit)(char bCloseWindow);
|
|
||||||
void (* __stdcall gets)(char* str, int n);
|
|
||||||
int (* __stdcall getch)(void);
|
|
||||||
int (* __stdcall con_get_font_height)(void);
|
|
||||||
int (* __stdcall con_set_cursor_height)(int new_height);
|
|
||||||
unsigned (*__stdcall con_get_flags)(void);
|
|
||||||
unsigned (*__stdcall con_set_flags)(unsigned new_flags);
|
|
||||||
void (*__stdcall con_cls)(void);
|
|
||||||
|
|
||||||
///===========================
|
|
||||||
|
|
||||||
void CONSOLE_INIT(char title[])
|
|
||||||
{
|
|
||||||
kol_struct_import *imp;
|
|
||||||
|
|
||||||
imp = kol_cofflib_load("/sys/lib/console.obj");
|
|
||||||
if (imp == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_init = ( _stdcall void (*)(unsigned, unsigned, unsigned, unsigned, const char*))
|
|
||||||
kol_cofflib_procload (imp, "con_init");
|
|
||||||
if (con_init == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
printf = ( _cdecl void (*)(const char*,...))
|
|
||||||
kol_cofflib_procload (imp, "con_printf");
|
|
||||||
if (printf == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
_exit = ( _stdcall void (*)(char))
|
|
||||||
kol_cofflib_procload (imp, "con_exit");
|
|
||||||
if (_exit == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
gets = ( _stdcall void (*)(char*, int))
|
|
||||||
kol_cofflib_procload (imp, "con_gets");
|
|
||||||
if (gets == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
getch = ( _stdcall int (*)(void))
|
|
||||||
kol_cofflib_procload (imp, "con_getch2");
|
|
||||||
if (getch == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_get_font_height = ( _stdcall int (*)(void))
|
|
||||||
kol_cofflib_procload (imp, "con_get_font_height");
|
|
||||||
if (con_get_font_height == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_set_cursor_height = ( _stdcall int (*)(int))
|
|
||||||
kol_cofflib_procload (imp, "con_set_cursor_height");
|
|
||||||
if (con_set_cursor_height == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_get_flags = ( _stdcall unsigned (*)(void))
|
|
||||||
kol_cofflib_procload (imp, "con_get_flags");
|
|
||||||
if (con_get_flags == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_set_flags = ( _stdcall unsigned (*)(unsigned))
|
|
||||||
kol_cofflib_procload (imp, "con_set_flags");
|
|
||||||
if (con_set_flags == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_cls = ( _stdcall void (*)(void))
|
|
||||||
kol_cofflib_procload (imp, "con_cls");
|
|
||||||
if (con_cls == NULL)
|
|
||||||
kol_exit();
|
|
||||||
|
|
||||||
con_init(-1, -1, -1, -1, title);
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
#include "ctype.h"
|
|
||||||
|
|
||||||
int toupper(int c)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( (c >= 97) && (c <= 122) )
|
|
||||||
return c-32 ;
|
|
||||||
|
|
||||||
if ( (c >= 160) && (c <= 175) )
|
|
||||||
return c-32 ;
|
|
||||||
|
|
||||||
if ( (c >= 224) && (c <= 239) )
|
|
||||||
return c-80 ;
|
|
||||||
|
|
||||||
if ( (c == 241) || (c == 243) || (c == 245) || (c == 247) )
|
|
||||||
return c-1;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tolower(int c)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ( (c >= 65) && (c <= 90) )
|
|
||||||
return c+32 ;
|
|
||||||
|
|
||||||
if ( (c >= 128) && (c <= 143) )
|
|
||||||
return c+32 ;
|
|
||||||
|
|
||||||
if ( (c >= 144) && (c <= 159) )
|
|
||||||
return c+80 ;
|
|
||||||
|
|
||||||
if ( (c == 240) || (c == 242) || (c == 244) || (c == 246) )
|
|
||||||
return c+1;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
int toupper(int c);
|
|
||||||
int tolower(int c);
|
|
@ -354,13 +354,13 @@ asm volatile ("int $0x40"::"a"(18), "b"(14));
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void kol_screen_get_size(unsigned *w, unsigned *h)
|
/*void kol_screen_get_size(unsigned *w, unsigned *h)
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned size;
|
||||||
asm volatile ("int $0x40":"=a"(size):"a"(14));
|
asm volatile ("int $0x40":"=a"(size):"a"(14));
|
||||||
*w = size / 65536;
|
*w = size / 65536;
|
||||||
*h = size % 65536;
|
*h = size % 65536;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ void kol_buffer_close(char name[])
|
|||||||
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name));
|
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
int kol_clip_num()
|
/*int kol_clip_num()
|
||||||
{
|
{
|
||||||
asm volatile ("int $0x40"::"a"(54), "b"(0));
|
asm volatile ("int $0x40"::"a"(54), "b"(0));
|
||||||
}
|
}
|
||||||
@ -435,7 +435,7 @@ asm volatile ("int $0x40"::"a"(54), "b"(1), "c"(n));
|
|||||||
int kol_clip_set(int n, char buffer[])
|
int kol_clip_set(int n, char buffer[])
|
||||||
{
|
{
|
||||||
asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer));
|
asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void set_cwd(const char* cwd)
|
void set_cwd(const char* cwd)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ unsigned kol_system_date_get();
|
|||||||
void kol_path_file2dir(char *dir, char *fname);
|
void kol_path_file2dir(char *dir, char *fname);
|
||||||
void kol_path_full(char *full, char *fname);
|
void kol_path_full(char *full, char *fname);
|
||||||
void kol_screen_wait_rr();
|
void kol_screen_wait_rr();
|
||||||
void kol_screen_get_size(unsigned *w, unsigned *h);
|
//void kol_screen_get_size(unsigned *w, unsigned *h);
|
||||||
unsigned kol_skin_height();
|
unsigned kol_skin_height();
|
||||||
unsigned kol_thread_start(unsigned start, unsigned stack);
|
unsigned kol_thread_start(unsigned start, unsigned stack);
|
||||||
unsigned kol_time_tick();
|
unsigned kol_time_tick();
|
||||||
@ -111,9 +111,9 @@ void kol_get_kernel_ver(char buff16b[]);
|
|||||||
int kol_kill_process(unsigned process);
|
int kol_kill_process(unsigned process);
|
||||||
int kol_buffer_open(char name[], int mode, int size, char **buf);
|
int kol_buffer_open(char name[], int mode, int size, char **buf);
|
||||||
void kol_buffer_close(char name[]);
|
void kol_buffer_close(char name[]);
|
||||||
int kol_clip_num();
|
//int kol_clip_num();
|
||||||
char* kol_clip_get(int n);
|
//char* kol_clip_get(int n);
|
||||||
int kol_clip_set(int n, char buffer[]);
|
//int kol_clip_set(int n, char buffer[]);
|
||||||
void set_cwd(const char* cwd);
|
void set_cwd(const char* cwd);
|
||||||
int getcwd(char *buf, unsigned size);
|
int getcwd(char *buf, unsigned size);
|
||||||
|
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
unsigned int seed_o = 0x45168297;
|
|
||||||
|
|
||||||
|
|
||||||
void srand (unsigned seed)
|
|
||||||
{
|
|
||||||
seed_o = seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int rand (void)
|
|
||||||
{
|
|
||||||
seed_o = seed_o * 0x15a4e35 + 1;
|
|
||||||
return(seed_o >> 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void* malloc(unsigned s)
|
|
||||||
{
|
|
||||||
asm ("int $0x40"::"a"(68), "b"(12), "c"(s) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void free(void *p)
|
|
||||||
{
|
|
||||||
asm ("int $0x40"::"a"(68), "b"(13), "c"(p) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void* realloc(void *p, unsigned s)
|
|
||||||
{
|
|
||||||
asm ("int $0x40"::"a"(68), "b"(20), "c"(p), "d"(s) );
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
#define RAND_MAX 0x7FFFU
|
|
||||||
|
|
||||||
#define isspace(c) ((c)==' ')
|
|
||||||
#define abs(i) (((i)<0)?(-(i)):(i))
|
|
||||||
|
|
||||||
#define random(num) ((rand()*(num))/((RAND_MAX+1)))
|
|
||||||
|
|
||||||
void* malloc(unsigned size);
|
|
||||||
void free(void* pointer);
|
|
||||||
void* realloc(void* pointer, unsigned size);
|
|
||||||
|
|
||||||
void srand (unsigned seed);
|
|
||||||
int rand (void);
|
|
@ -1,221 +0,0 @@
|
|||||||
|
|
||||||
#include "string.h"
|
|
||||||
#include "ctype.h"
|
|
||||||
|
|
||||||
void* memset(void *mem, int c, unsigned size)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for ( i = 0; i < size; i++ )
|
|
||||||
*((char *)mem+i) = (char) c;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void* memcpy(void *dst, const void *src, unsigned size)
|
|
||||||
{
|
|
||||||
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for ( i = 0; i < size; i++)
|
|
||||||
*(char *)(dst+i) = *(char *)(src+i);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int memcmp(const void* buf1, const void* buf2, int count)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0;i<count;i++)
|
|
||||||
{
|
|
||||||
if (*(unsigned char*)buf1<*(unsigned char*)buf2)
|
|
||||||
return -1;
|
|
||||||
if (*(unsigned char*)buf1>*(unsigned char*)buf2)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void strcat(char strDest[], char strSource[])
|
|
||||||
{
|
|
||||||
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
i = j = 0;
|
|
||||||
while (strDest[i] != '\0')
|
|
||||||
i++;
|
|
||||||
|
|
||||||
while ((strDest[i++] = strSource[j++]) != '\0')
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int strcmp(const char* string1, const char* string2)
|
|
||||||
{
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (*string1<*string2)
|
|
||||||
return -1;
|
|
||||||
if (*string1>*string2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (*string1=='\0')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
string1++;
|
|
||||||
string2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int strnicmp(const char* string1, const char* string2, unsigned count)
|
|
||||||
{
|
|
||||||
int pc = 0;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (toupper(*string1)<toupper(*string2))
|
|
||||||
return -1;
|
|
||||||
if (toupper(*string1)>toupper(*string2))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (*string1=='\0' || pc == count)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
string1++;
|
|
||||||
string2++;
|
|
||||||
pc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void strcpy(char strDest[], const char strSource[])
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while ((strDest[i] = strSource[i]) != '\0')
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char* strncpy(char *strDest, const char *strSource, unsigned n)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
if (! n )
|
|
||||||
return strDest;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while ((strDest[i] = strSource[i]) != '\0')
|
|
||||||
if ( (n-1) == i )
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
i++;
|
|
||||||
|
|
||||||
return strDest;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int strlen(const char* string)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i=0;
|
|
||||||
while (*string++) i++;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char* strchr(const char* string, int c)
|
|
||||||
{
|
|
||||||
while (*string)
|
|
||||||
{
|
|
||||||
if (*string==c)
|
|
||||||
return (char*)string;
|
|
||||||
string++;
|
|
||||||
}
|
|
||||||
return (char*)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char* strrchr(const char* string, int c)
|
|
||||||
{
|
|
||||||
char* last_found = 0; // !
|
|
||||||
while (*string)
|
|
||||||
{
|
|
||||||
if (*string==c)
|
|
||||||
{
|
|
||||||
last_found = (char*)string;
|
|
||||||
}
|
|
||||||
string++;
|
|
||||||
}
|
|
||||||
return last_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _itoa(int i, char *s)
|
|
||||||
{
|
|
||||||
int a, b, c, d;
|
|
||||||
a = (i - i%1000)/1000;
|
|
||||||
b = (i - i%100)/100 - a*10;
|
|
||||||
c = (i - i%10)/10 - a*100 - b*10;
|
|
||||||
d = i%10;
|
|
||||||
s[0] = a + '0';
|
|
||||||
s[1] = b + '0';
|
|
||||||
s[2] = c + '0';
|
|
||||||
s[3] = d + '0';
|
|
||||||
s[4] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* reverse: ïåðåâîðà÷èâàåì ñòðîêó s íà ìåñòå */
|
|
||||||
void reverse(char s[])
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
|
|
||||||
c = s[i];
|
|
||||||
s[i] = s[j];
|
|
||||||
s[j] = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* itoa: êîíâåðòèðóåì n â ñèìâîëû â s */
|
|
||||||
void itoa(int n, char s[])
|
|
||||||
{
|
|
||||||
int i, sign;
|
|
||||||
|
|
||||||
if ((sign = n) < 0)
|
|
||||||
n = -n;
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
s[i++] = n % 10 + '0';
|
|
||||||
} while ((n /= 10) > 0);
|
|
||||||
if (sign < 0)
|
|
||||||
s[i++] = '-';
|
|
||||||
s[i] = '\0';
|
|
||||||
reverse(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _atoi ( char *s )
|
|
||||||
{
|
|
||||||
int i, n;
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
for ( i = 0; s[i]!= '\0'; ++i)
|
|
||||||
if ((s[i]<'0') || (s[i]>'9'))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
n = 10 * n + s[i] - '0';
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL ((void*)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void* memset(void *mem, int c, unsigned size);
|
|
||||||
void* memcpy(void *dst, const void *src, unsigned size);
|
|
||||||
int memcmp(const void* buf1, const void* buf2, int count);
|
|
||||||
|
|
||||||
void strcat(char strDest[], char strSource[]);
|
|
||||||
int strcmp(const char* string1, const char* string2);
|
|
||||||
void strcpy(char strDest[], const char strSource[]);
|
|
||||||
char* strncpy(char *strDest, const char *strSource, unsigned n);
|
|
||||||
int strlen(const char* string);
|
|
||||||
char* strchr(const char* string, int c);
|
|
||||||
char* strrchr(const char* string, int c);
|
|
||||||
void _itoa(int i, char *s);
|
|
||||||
void reverse(char *s);
|
|
||||||
void itoa(int i, char *s);
|
|
||||||
int _atoi( char *s );
|
|
||||||
int strnicmp(const char* string1, const char* string2, unsigned count);
|
|
Loading…
Reference in New Issue
Block a user