50 lines
976 B
C
50 lines
976 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stdarg.h>
|
||
|
#include <string.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include <patty/kiss.h>
|
||
|
|
||
|
static void usage(int argc, char **argv, const char *message, ...) {
|
||
|
if (message) {
|
||
|
va_list args;
|
||
|
|
||
|
va_start(args, message);
|
||
|
vfprintf(stderr, message, args);
|
||
|
fprintf(stderr, "\n");
|
||
|
va_end(args);
|
||
|
}
|
||
|
|
||
|
fprintf(stderr, "usage: %s kiss.cap\n", argv[0]);
|
||
|
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char **argv) {
|
||
|
patty_kiss_tnc *tnc;
|
||
|
ssize_t len;
|
||
|
void *frame;
|
||
|
int port;
|
||
|
|
||
|
if (argc != 2) {
|
||
|
usage(argc, argv, "No TNC device provided");
|
||
|
}
|
||
|
|
||
|
if ((tnc = patty_kiss_tnc_open(argv[1], 330)) == NULL) {
|
||
|
perror("Unable to open TNC");
|
||
|
|
||
|
exit(127);
|
||
|
}
|
||
|
|
||
|
while ((len = patty_kiss_tnc_recv(tnc, &frame, &port)) > 0) {
|
||
|
write(fileno(stdout), frame, len);
|
||
|
|
||
|
fprintf(stderr, "Got %ld byte frame\n", len);
|
||
|
}
|
||
|
|
||
|
patty_kiss_tnc_close(tnc);
|
||
|
|
||
|
return 0;
|
||
|
}
|