* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.140 2002-01-30 22:02:03 adam Exp $
+ * $Id: client.c,v 1.141 2002-02-01 23:59:49 adam Exp $
*/
#include <stdio.h>
struct timeval tv_start, tv_end;
#endif
-void wait_and_handle_responce()
+void wait_and_handle_responce()
{
int res;
Z_APDU *apdu;
- if (conn
-#ifdef USE_SELECT
- && FD_ISSET(cs_fileno(conn), &input)
-#endif
- )
+ if (conn)
{
do
{
((double) tv_start.tv_usec / 1e6 + tv_start.tv_sec));
#endif
}
+ xfree (netbuffer);
}
for(;*p; ++p) {
if(!isspace(*p)) {
lastnonspace = p;
- };
- };
+ }
+ }
if(lastnonspace)
*(++lastnonspace) = 0;
- };
+ }
for (i = 0; cmd[i].cmd; i++)
if (res >= 2)
wait_and_handle_responce();
- if(apdu_file) fflush(apdu_file);
- if(marcdump) fflush(marcdump);
+ if(apdu_file)
+ fflush(apdu_file);
+ if(marcdump)
+ fflush(marcdump);
}
static void client(void)
{
+ char line[1024];
+
+ line[1023] = '\0';
#if HAVE_GETTIMEOFDAY
gettimeofday (&tv_start, 0);
while (1)
{
-#ifdef USE_SELECT
- fd_set input;
-#endif
- char line[1024];
-
- {
+ char *line_in = NULL;
#if HAVE_READLINE_READLINE_H
- char* line_in=NULL;
+ if (isatty(0))
+ {
line_in=readline(C_PROMPT);
if (!line_in)
break;
if (*line_in)
add_history(line_in);
#endif
- strcpy(line,line_in);
+ strncpy(line, line_in, 1023);
free (line_in);
-#else
+ }
+#endif
+ if (!line_in)
+ {
char *end_p;
printf (C_PROMPT);
fflush(stdout);
break;
if ((end_p = strchr (line, '\n')))
*end_p = '\0';
-#endif
+ }
process_cmd_line(line);
}
- }
}
int main(int argc, char **argv)