FreeCalypso > hg > fc-usbser-tools
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/duart28/main.c Sat Sep 09 17:53:21 2023 +0000 @@ -0,0 +1,77 @@ +/* + * Main module for fc-duart28-conf utility. + */ + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <usb.h> + +extern struct usb_device *find_duart28_usbdev(); + +oper_find() +{ + struct usb_device *dev; + + dev = find_duart28_usbdev(); + if (!dev) + printf("No DUART28 adapter found\n"); + return 0; +} + +oper_check_eeprom() +{ + fprintf(stderr, "error: check-eeprom command not yet implemented\n"); + exit(1); +} + +oper_program(newconf) +{ + fprintf(stderr, "error: set command not yet implemented\n"); + exit(1); +} + +main(argc, argv) + char **argv; +{ + if (argc < 2) + return oper_find(); + if (!strcmp(argv[1], "find")) { + if (argc != 2) { + fprintf(stderr, + "error: %s find command takes no arguments\n", + argv[0]); + exit(1); + } + return oper_find(); + } + if (!strcmp(argv[1], "check-eeprom")) { + if (argc != 2) { + fprintf(stderr, + "error: %s check-eeprom command takes no arguments\n", + argv[0]); + exit(1); + } + return oper_check_eeprom(); + } + if (!strcmp(argv[1], "set")) { + if (argc != 3) { + fprintf(stderr, + "error: %s set command takes 1 argument\n", + argv[0]); + exit(1); + } + if (!strcmp(argv[2], "C") || !strcmp(argv[2], "S")) + return oper_program(argv[2][0]); + if (!strcmp(argv[2], "c") || !strcmp(argv[2], "s")) + return oper_program(toupper(argv[2][0])); + fprintf(stderr, "error: %s set argument must be C or S\n", + argv[0]); + exit(1); + } + fprintf(stderr, "%s error: non-understood command \"%s\"\n", argv[0], + argv[1]); + exit(1); +}