version 1.1, 2001/06/27 19:41:45 |
version 1.2, 2001/07/02 20:15:07 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <signal.h> |
#include <signal.h> |
#include <string.h> |
#include <string.h> |
|
#include <errno.h> |
#include <sectok.h> |
#include <sectok.h> |
|
|
#include "sc.h" |
#include "sc.h" |
|
|
#define MAXTOKENS 300 |
#define MAXTOKENS 300 |
#define CARDIOSIZE 200 |
#define CARDIOSIZE 200 |
|
|
|
void onintr(int sigraised); |
|
|
const char usage[] = |
const char usage[] = |
"Usage: sectok [-1234hHf:s:]\n" |
"Usage: sectok [-1234hHf:s:]\n" |
" 1 - 4 : specify card reader number\n" |
" 1 - 4 : specify card reader number\n" |
|
|
" h : this message\n" |
" h : this message\n" |
; |
; |
|
|
int fd = -1, cla, sleepytime; |
int port, fd = -1, cla, sleepytime, interrupted; |
FILE *cmdf; |
FILE *cmdf; |
|
|
int |
int |
|
|
int ac; |
int ac; |
char *av[]; |
char *av[]; |
{ |
{ |
int i, port, tc; |
int i, tc; |
char buf[256], *scriptfile = NULL, *tp, *tv[MAXTOKENS]; |
char buf[256], *scriptfile = NULL, *tp, *tv[MAXTOKENS]; |
|
|
while ((i = getopt(ac, av, "1234c:d:f:Hhs:")) != -1) { |
while ((i = getopt(ac, av, "1234c:d:f:Hhs:")) != -1) { |
|
|
|
|
/* Interactive mode, or script file */ |
/* Interactive mode, or script file */ |
|
|
|
signal(SIGINT, onintr); |
|
|
/* The Main Loop */ |
/* The Main Loop */ |
while (1) { |
while (1) { |
fflush(stdout); |
fflush(stdout); |
|
interrupted = 0; |
if (sleepytime) |
if (sleepytime) |
usleep(sleepytime * 1000); |
usleep(sleepytime * 1000); |
if (cmdf == stdin) { |
if (cmdf == stdin) { |
|
|
fflush(stderr); |
fflush(stderr); |
} |
} |
|
|
if (!fgets(buf, sizeof buf, cmdf)) |
if (!fgets(buf, sizeof buf, cmdf)) { |
break; |
if (interrupted) |
|
continue; |
|
else |
|
break; |
|
} |
if (cmdf != stdin) |
if (cmdf != stdin) |
printf("sectok> %s", buf); |
printf("sectok> %s", buf); |
|
|
|
|
} |
} |
|
|
exit(0); |
exit(0); |
|
} |
|
|
|
void onintr(int sigraised) |
|
{ |
|
interrupted++; |
} |
} |