summaryrefslogtreecommitdiff
path: root/extra/input.c
blob: dcb2a98891c58873d43aba2a94497e4a63d36622 (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
/*
 * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "simulation.h"

void *entry_input(void *ptr)
{
	char *got, buf[80];
	char *str, *word, *saveptr;
	int argc;
	char *argv[40];
	int ret;

	do {
		printf("lightbar%% ");
		got = fgets(buf, sizeof(buf), stdin);
		if (got) {
			argc = 0;
			argv[argc++] = "lightbar";
			word = str = buf;
			while (word && argc < ARRAY_SIZE(argv)) {
				word = strtok_r(str, " \t\r\n", &saveptr);
				if (word)
					argv[argc++] = word;
				str = 0;
			}
			argv[argc] = 0;
			ret = fake_consolecmd_lightbar(argc, argv);
			if (ret)
				printf("ERROR %d\n", ret);
		}

	} while (got);

	exit(0);

	return 0;
}