forked from pacew/armdsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
armhost.c
69 lines (57 loc) · 1.03 KB
/
armhost.c
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
67
68
69
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <fcntl.h>
#include <stdint.h>
#include <errno.h>
#include <sys/select.h>
#include "armdsp.h"
void
usage (void)
{
fprintf (stderr, "usage: armhost [prog]\n");
exit (1);
}
int
main (int argc, char **argv)
{
int c;
char *err;
fd_set rset;
char *prog = NULL;
while ((c = getopt (argc, argv, "v")) != EOF) {
switch (c) {
case 'v':
armdsp_verbose = 1;
break;
default:
usage ();
}
}
if (optind < argc)
prog = argv[optind++];
if (optind != argc)
usage ();
if ((err = armdsp_init (0)) != NULL) {
fprintf (stderr, "armdsp_init error: %s\n", err);
exit (1);
}
if (prog) {
if ((err = armdsp_run (prog)) != NULL) {
fprintf (stderr, "armdsp_run error: %s\n", err);
exit (1);
}
}
while (1) {
FD_ZERO (&rset);
FD_SET (armdsp_fd, &rset);
if (select (armdsp_fd + 1, &rset, NULL, NULL, NULL) < 0) {
perror ("select");
exit (1);
}
if (FD_ISSET (armdsp_fd, &rset))
armdsp_host ();
}
return (0);
}