aboutsummaryrefslogtreecommitdiffstats
path: root/swall/scomm.c
blob: a5a2eb7a762bf080e2672643218f90f92e34b0e0 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int echomod = 0;
	char msg[50], com[100];

	while (!feof(stdin)) {

		if (echomod)
			printf("echo ");
		else
			printf("--> ");

		memset(msg, 0, sizeof(msg));
		memset(com, 0, sizeof(com));
		fgets(msg, sizeof(msg), stdin);

		if (!strncmp(msg,"\n", sizeof(msg)))
			continue;
		else if (!strncmp(msg, "exit\n", sizeof(msg))) {

			if (echomod) {
				echomod = 0;
				continue;
			}

			break;
		} else if (!strncmp(msg, "echomod\n", sizeof(msg))) {

			if (echomod)
				echomod = 0;
			else
				echomod = 1;

			continue;
		} else if (!strncmp(msg, "clsme\n", sizeof(msg))) {
			system("clear");
			continue;
		} else if (!strncmp(msg, "clear\n", sizeof(msg))) {
			system("swall clear");
			continue;
		}

		if (echomod)
			snprintf(com, sizeof(com), "swall echo %s", msg);
		else
			snprintf(com, sizeof(com), "swall %s", msg);

		system(com);
	}

	return 0;
}