summaryrefslogtreecommitdiff
path: root/src/util/shell.c
blob: 3b13bc9c620888ce303c50bbecd6b8f938138142 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>

#include <libgsmd/libgsmd.h>

#define STDIN_BUF_SIZE	1024

int shell_main(struct lgsmd_handle *lgsmh)
{
	int rc;
	char buf[STDIN_BUF_SIZE+1];
	char rbuf[STDIN_BUF_SIZE+1];
	int rlen = sizeof(rbuf);

	while (1) {
		rc = fscanf(stdin, "%s", buf);
		if (rc == EOF) {
			printf("EOF\n");
			return -1;
		}
		if (rc <= 0) {
			printf("NULL\n");
			continue;
		}
		printf("STR=`%s'\n", buf);
		lgsm_passthrough(lgsmh, buf, rbuf, &rlen);

		printf("RSTR=`%s'\n", rbuf);
	}
}
personal git repositories of Harald Welte. Your mileage may vary