summaryrefslogtreecommitdiff
path: root/packages/gsm/files/magician/ldisc.patch
blob: 30d4a8812a01af93a646d1c6fa6d21c8cdc65e61 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Index: gsm/src/gsmd/gsmd.c
===================================================================
--- gsm.orig/src/gsmd/gsmd.c	2007-03-29 15:29:31.000000000 +0200
+++ gsm/src/gsmd/gsmd.c	2007-03-29 15:33:07.000000000 +0200
@@ -32,6 +32,7 @@
 #define _GNU_SOURCE
 #include <getopt.h>
 
+#include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -150,6 +151,7 @@
 	{ "speed", 1, NULL, 's' },
 	{ "logfile", 1, NULL, 'l' },
 	{ "hwflow", 0, NULL, 'F' },
+	{ "ldisc", 1, NULL, 'D' },
 	{ "leak-report", 0, NULL, 'L' },
 	{ 0, 0, 0, 0 }
 };
@@ -165,6 +167,7 @@
 	       "\t-p dev\t--device dev\tSpecify serial device to be used\n"
 	       "\t-s spd\t--speed spd\tSpecify speed in bps (9600,38400,115200,...)\n"
 	       "\t-F\t--hwflow\tHardware Flow Control (RTS/CTS)\n"
+	       "\t-D\t--ldisc num\tSet line discipline (0=N_TTY,...)\n"
 	       "\t-L\t--leak-report\tLeak Report of talloc memory allocator\n"
 	       "\t-l file\t--logfile file\tSpecify a logfile to log to\n"
 	       );
@@ -191,6 +194,7 @@
 	int daemonize = 0;
 	int bps = 115200;
 	int hwflow = 0;
+	int ldisc = 0;
 	char *device = "/dev/ttyUSB0";
 	char *logfile = "syslog";
 
@@ -202,7 +206,7 @@
 	gsmd_tallocs = talloc_named_const(NULL, 1, "GSMD");
 
 	/*FIXME: parse commandline, set daemonize, device, ... */
-	while ((argch = getopt_long(argc, argv, "FVLdhp:s:l:", opts, NULL)) != -1) {
+	while ((argch = getopt_long(argc, argv, "FVLdhp:s:l:D:", opts, NULL)) != -1) {
 		switch (argch) {
 		case 'V':
 			/* FIXME */
@@ -232,6 +236,8 @@
 				fprintf(stderr, "can't open logfile `%s'\n", optarg);
 				exit(2);
 			}
+		case 'D':
+			ldisc = atoi(optarg);
 			break;
 		}
 	}
@@ -249,6 +255,11 @@
 		exit(1);
 	}
 
+	if (ldisc && ioctl(fd, TIOCSETD, &ldisc) < 0) {
+		fprintf(stderr, "can't set line discipline\n");
+		exit(1);
+	}
+
 	if (gsmd_initialize(&g) < 0) {
 		fprintf(stderr, "internal error\n");
 		exit(1);