44 if(strcmp(how,
"pipe") == 0)
46 if(command == NULL)
return -1;
57 else if(strcmp(how,
"stdio") == 0)
66 cptr = strchr(host,
':');
67 if(cptr == NULL)
return -1;
69 int port = atoi(cptr);
70 if(strcmp(host,
"server.localhost") == 0)
76 if(strcmp(host,
"localhost") == 0 && command != NULL)
86 for(
int itry=0; itry<10; itry++)
103 if(
tty == NULL)
return -1;
111 unsigned char *cbuf = (
unsigned char *) buf;
123 else if(
sock != NULL)
126 int ret =
sock->
read(buf,len,timeout);
137 if(timeout > 0) timout = timeout;
138 return tty->
readBlock ((
unsigned char *) buf, len, timout);
142 int ret = read(0,buf,len);
157 else if(
sock != NULL)
171 if(ret <= 0)
return NULL;
176 return fgets(
line,
sizeof(
line)-1,stdin);
186 if(ret < 0)
return ret;
192 else if(
sock != NULL)
216 else if(
sock != NULL)
227 return write(1,buf,len);
239 printf(
"localhost:\n");
240 cli.
start(
"localhost:50500");
242 while((line = cli.
readLine()) != NULL)
244 printf(
"line=%s",line);
245 if(i<5) cli.
printf(
"%s%d\n",
"hallo",i++);
246 else cli.
printf(
"%s\n",
"exit");
251 cli.
start(
"pipe",
"./myecho");
253 while((line = cli.
readLine()) != NULL)
255 ::printf(
"line=%s",line);
256 if(i<5) cli.
printf(
"%s%d\n",
"hallo",i++);
257 else cli.
printf(
"%s\n",
"exit");
263 cli.
printf(
"Bitte tipp was ein\n");
264 printf(
"Du hast '%s' eingegeben\n", cli.
readLine());
int select(int timeout=50)
int readBlock(unsigned char *buf, int len, int timeout=-1)
int printf(const char *format,...)
int write(const void *buf, int len)
const char * readLine(int timeout=0)
int printf(const char *format,...)
int start(const char *how, const char *command=NULL)
int writeBlock(void *buf, int len)
int readLine(unsigned char *buf, int maxlen, int timeout=1000)
int readStr(char *buf, int len, int timeout=0)
int write(const char *buf, int len)
int read(void *buf, int len, int timeout=0)
int rlvsnprintf(char *text, int len, const char *format, va_list ap)
int readBlock(void *buf, int len, int timeout=0)
char line[rl_PRINTF_LENGTH]
virtual ~rlCommandlineInterface()
int rlsystem(const char *command)
int writeBlock(const unsigned char *buf, int len)
int spawn(const char *command)
int printf(const char *format,...)