summaryrefslogtreecommitdiff
path: root/fxotune.c
blob: 6bdaeba6aec43e476b5f99af00c6ae7be7b2a12f (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/zaptel.h>
#include "wctdm.h"

int main (int argc , char **argv)
{
	char zapdev[80] = "";
	int fd;
	
	if (argc < 4) {
		fprintf(stdout, "Usage:\n");
		fprintf(stdout, "%s [zap device] echocan [0-7]\n", argv[0]);
		exit(1);
	}

	strncpy(zapdev, argv[1], sizeof(zapdev));

	fd = open(zapdev, O_RDWR);
	if (fd < 0) {
		fprintf(stderr, "open: %s\n", strerror(errno));
		exit(1);
	}
	
	if (!strcasecmp(argv[2], "echocan")) {
		int modeno = atoi(argv[3]);

		if (modeno < 0 || modeno > 7) {
			fprintf(stdout, "Echo canceller coefficient settings must be between 0 and 7.\n");
			exit(1);
		}

		if (ioctl(fd, WCTDM_SET_ECHOTUNE, &modeno)) {
			fprintf(stdout, "echotune: %s\n", strerror(errno));
			exit(1);
		}
		exit(0);
	}
	exit(0);
}