-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,302 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "kernel.h" | ||
#include "eBat.h" | ||
#include "eBatRuntime.h" | ||
|
||
/** | ||
* Проверка наличии файла или папки | ||
* @module FileIO.Exits | ||
* @param path Путь к файлу | ||
* @return 1 - Если файл найден или 0 - если нет | ||
*/ | ||
int bat_runtime_fileio_exist(char* path){ | ||
/// Insert your code | ||
bat_debug("[RUNTIME] [FileIO] [Exits] %s\n", path); | ||
bool ret = file_exists(path); | ||
return ret; | ||
} | ||
|
||
int bat_runtime_fileio_write(const char *filename, const char *text, int mode) { | ||
/// Insert your code | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "kernel.h" | ||
#include "eBat.h" | ||
#include "eBatRuntime.h" | ||
|
||
int bat_strtol(char *string) { | ||
int number = 0; | ||
int sign = 1; | ||
int i = 0; | ||
|
||
// Пропускаем пробелы в начале строки | ||
while (string[i] == ' ' && string[i] != '\0') { | ||
i++; | ||
} | ||
|
||
// Обработка знака | ||
if (string[i] == '-' || string[i] == '+') { | ||
sign = (string[i] == '-' ? -1 : 1); | ||
i++; | ||
} | ||
|
||
// Извлечение цифр | ||
while (isdigit(string[i]) && string[i] != '\0') { | ||
number = number * 10 + (string[i] - '0'); | ||
i++; | ||
} | ||
|
||
return number * sign; | ||
} | ||
void bat_trim(char* string){ | ||
int start = 0, end = strlen(string) - 1; | ||
while (string[start] == ' ' || string[start] == '\t' || string[start] == '\n' || string[start] == 0xD){ | ||
start++; | ||
} | ||
while (string[end] == ' ' || string[end] == '\t' || string[end] == '\n' || string[end] == 0xD){ | ||
end--; | ||
} | ||
for (int i = 0; i <= end - start; i++){ | ||
string[i] = string[i + start]; | ||
} | ||
string[end - start + 1] = '\0'; | ||
} | ||
|
||
void bat_str_debug(char* string){ | ||
return; | ||
bat_debug(" |--- String debug: '%s'\n", string); | ||
int len = strlen(string); | ||
for (int i = 0; i < len; i++){ | ||
bat_debug(" |--- [%d | %d] [0x%x] '%c'\n", i+1, len, string[i], string[i]); | ||
} | ||
} | ||
|
||
char* bat_strdup(const char *str) { | ||
// Проверяем, не является ли указатель NULL | ||
if (str == NULL) { | ||
return NULL; | ||
} | ||
|
||
// Получаем длину исходной строки | ||
size_t len = strlen(str); | ||
|
||
// Выделяем память для новой строки (включая один байт для нулевого терминатора) | ||
char *copy = (char*)malloc(len + 1); | ||
memset(copy, 0, len + 1); | ||
if (copy == NULL) { | ||
return NULL; // Проверка на успешное выделение памяти | ||
} | ||
|
||
// Копируем строку в новую память | ||
strcpy(copy, str); | ||
|
||
return copy; // Возвращаем указатель на новую строку | ||
} | ||
|
||
char* bat_toLower(char* str) { | ||
int i; | ||
for (i = 0; str[i] != '\0'; i++) { | ||
if (str[i] >= 'A' && str[i] <= 'Z') { // Проверяем, является ли символ заглавным | ||
str[i] = str[i] + 32; // Преобразуем в строчную букву | ||
} | ||
} | ||
return str; // Возвращаем изменённую строку | ||
} | ||
|
||
char* bat_toUpper(char *str) { | ||
int i; | ||
for (i = 0; str[i] != '\0'; i++) { | ||
if (str[i] >= 'a' && str[i] <= 'z') { | ||
str[i] = str[i] - 32; | ||
} | ||
} | ||
return str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "kernel.h" | ||
#include "eBat.h" | ||
#include "eBatRuntime.h" | ||
|
||
int bar_runtime_system_exec(int argc, char** argv){ | ||
/// Insert your code to execute the "echo" command | ||
bat_debug("[RUNTIME] [System] [EXEC] Count: %d\n", argc); | ||
int ret = cli_handler_ebat(argc, argv); | ||
return ret; | ||
} | ||
|
||
/** | ||
* Вывод текста на экран | ||
* @module System.Echo | ||
* @param text - Строка для вывода текст | ||
*/ | ||
void bat_runtime_system_echo(char* text, int newline, int endline){ | ||
/// Insert your code to execute the "echo" command | ||
bat_debug("[RUNTIME] [System] [ECHO] %s\n", text); | ||
if (text == NULL){ | ||
return; | ||
} | ||
|
||
//printf("%s%s%s", (newline == 1?"< ":""), text, (endline == 1?" \n":" ")); | ||
tty_printf("%s%s%s", (newline == 1?"< ":""), text, (endline == 1?" \n":" ")); | ||
} | ||
|
||
/** | ||
* Установка значения переменной | ||
* @param key - Ключ | ||
* @param val - Значение | ||
*/ | ||
void bat_runtime_system_set(char* key, char* val){ | ||
/// Insert your code | ||
//bat_debug("[RUNTIME] [System] [SET] '%s' => '%s'\n", key, val); | ||
//printf("[RUNTIME] [System] [SET] '%s' => '%s'\n", key, val); | ||
//bat_toUpper(key); | ||
//char* get = bat_runtime_system_get(key); | ||
|
||
int len_key = (key == NULL?0:strlen(key)); | ||
int len_val = (val == NULL?0:strlen(val)); | ||
|
||
if (key == NULL){ | ||
return; | ||
} | ||
if (val == NULL || len_val == 0){ | ||
variable_write(key,""); | ||
} | ||
} | ||
|
||
/** | ||
* Получение значения переменной | ||
* @param key - Ключ | ||
*/ | ||
char* bat_runtime_system_get(char* key){ | ||
/// Insert your code | ||
bat_debug("[RUNTIME] [System] [GET] '%s'\n", key); | ||
//bat_toUpper(key); | ||
return variable_read(key); | ||
} | ||
|
||
|
||
void bat_runtime_system_pause(){ | ||
/// Insert your code | ||
bat_debug("[RUNTIME] [System] [Pause]\n"); | ||
bat_runtime_system_echo("Please, press button", 1, 1); | ||
getIntKeyboardWait(); | ||
///getchar(); - Функция которая ожидает ввода любой клавиши | ||
} |
Oops, something went wrong.