annotate calypso/targetfd.c @ 7:b25d4dfe5798

fcsim-calypso-be actually works now
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 05:33:51 +0000
parents deeeef558279
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <stdio.h>
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdlib.h>
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <unistd.h>
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 int target_fd;
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 parse_target_fd_opt(argc, argv)
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 char **argv;
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 {
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 extern char *optarg;
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 int c;
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 while ((c = getopt(argc, argv, "C:")) != EOF) {
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 switch (c) {
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 case 'C':
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 target_fd = atoi(optarg);
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 continue;
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 case '?':
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 default:
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 /* error msg already printed */
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 exit(1);
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 }
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (!target_fd) {
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 fprintf(stderr, "error: target fd must be given with -C\n");
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 exit(1);
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return(0);
deeeef558279 fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }