Fix commandCallHanler
parent
47948489ed
commit
250c2b868b
15
include/ui.h
15
include/ui.h
|
@ -9,10 +9,16 @@
|
|||
|
||||
#define MAX_COMMAND_LEN 200
|
||||
|
||||
void clearExtraInput()
|
||||
{
|
||||
int c;
|
||||
while ((c = getchar()) != '\n' && c != EOF) {}
|
||||
}
|
||||
|
||||
int getString(char* str, const int size)
|
||||
{
|
||||
char* buf = (char*) malloc(size + 1);
|
||||
if (gets(buf) == NULL)
|
||||
if (fgets(buf, size, stdin) == NULL)
|
||||
{
|
||||
return GETSTRING_ERR_RE;
|
||||
}
|
||||
|
@ -28,7 +34,7 @@ int getString(char* str, const int size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int commandCallHandler()
|
||||
char* commandCallHandler()
|
||||
{
|
||||
char* command = (char*) malloc(MAX_COMMAND_LEN);
|
||||
char* buf = (char*) malloc(MAX_COMMAND_LEN);
|
||||
|
@ -37,11 +43,12 @@ int commandCallHandler()
|
|||
result = getString(command, MAX_COMMAND_LEN-1);
|
||||
if (result == 0)
|
||||
{
|
||||
// Разбиваем на лексемы и обрабатываем команду
|
||||
strcpy(buf, command);
|
||||
return buf;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue