comparison duart28/main.c @ 27:2413a54a1bfc

fc-duart28-conf started
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Sep 2023 17:53:21 +0000
parents
children a7393d00996a
comparison
equal deleted inserted replaced
26:49239efbdcc8 27:2413a54a1bfc
1 /*
2 * Main module for fc-duart28-conf utility.
3 */
4
5 #include <ctype.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <strings.h>
10 #include <usb.h>
11
12 extern struct usb_device *find_duart28_usbdev();
13
14 oper_find()
15 {
16 struct usb_device *dev;
17
18 dev = find_duart28_usbdev();
19 if (!dev)
20 printf("No DUART28 adapter found\n");
21 return 0;
22 }
23
24 oper_check_eeprom()
25 {
26 fprintf(stderr, "error: check-eeprom command not yet implemented\n");
27 exit(1);
28 }
29
30 oper_program(newconf)
31 {
32 fprintf(stderr, "error: set command not yet implemented\n");
33 exit(1);
34 }
35
36 main(argc, argv)
37 char **argv;
38 {
39 if (argc < 2)
40 return oper_find();
41 if (!strcmp(argv[1], "find")) {
42 if (argc != 2) {
43 fprintf(stderr,
44 "error: %s find command takes no arguments\n",
45 argv[0]);
46 exit(1);
47 }
48 return oper_find();
49 }
50 if (!strcmp(argv[1], "check-eeprom")) {
51 if (argc != 2) {
52 fprintf(stderr,
53 "error: %s check-eeprom command takes no arguments\n",
54 argv[0]);
55 exit(1);
56 }
57 return oper_check_eeprom();
58 }
59 if (!strcmp(argv[1], "set")) {
60 if (argc != 3) {
61 fprintf(stderr,
62 "error: %s set command takes 1 argument\n",
63 argv[0]);
64 exit(1);
65 }
66 if (!strcmp(argv[2], "C") || !strcmp(argv[2], "S"))
67 return oper_program(argv[2][0]);
68 if (!strcmp(argv[2], "c") || !strcmp(argv[2], "s"))
69 return oper_program(toupper(argv[2][0]));
70 fprintf(stderr, "error: %s set argument must be C or S\n",
71 argv[0]);
72 exit(1);
73 }
74 fprintf(stderr, "%s error: non-understood command \"%s\"\n", argv[0],
75 argv[1]);
76 exit(1);
77 }