33 lines
722 B
C
33 lines
722 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <termios.h>
|
|
#include <unistd.h>
|
|
|
|
void gettoks(char *src,TOKS *toks,char *cut)
|
|
{
|
|
toks->count=0;
|
|
toks->tok=(char **)calloc(++(toks->count),sizeof(char *));
|
|
*(toks->tok)=strtok(src,cut);
|
|
while(NULL!=*(toks->tok+toks->count-1))
|
|
{
|
|
toks->tok=realloc(toks->tok,sizeof(char *)*(++(toks->count)));
|
|
*(toks->tok+toks->count-1)=strtok(NULL,cut);
|
|
}
|
|
(toks->count)--;
|
|
}
|
|
|
|
char getch( )
|
|
{
|
|
struct termios oldt, newt;
|
|
char ch;
|
|
tcgetattr( STDIN_FILENO, &oldt );
|
|
newt = oldt;
|
|
newt.c_lflag &= ~( ICANON | ECHO );
|
|
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
|
|
ch = getchar();
|
|
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
|
|
return ch;
|
|
}
|
|
|