| 1 | /* find_all.c |
| 2 | |
| 3 | Example for ftdi_usb_find_all() |
| 4 | |
| 5 | This program is distributed under the GPL, version 2 |
| 6 | */ |
| 7 | |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <ftdi.h>cxx . . $ `<file>/src/ftdi.h`/ |
| 11 | |
| 12 | int maincxx . . $ main(b126dc7c1de90089).(void) |
| 13 | { |
| 14 | int ret, i; |
| 15 | struct ftdi_contextcxx . . $ ftdi_context# *ftdi; |
| 16 | struct ftdi_device_listcxx . . $ ftdi_device_list# *devlist, *curdev; |
| 17 | char manufacturer[128], description[128]; |
| 18 | int retval = EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!; |
| 19 | |
| 20 | if ((ftdi = ftdi_newcxx . . $ ftdi_new(207ff50971a1b30).()) == 0) |
| 21 | { |
| 22 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_new failed\n"); |
| 23 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 24 | } |
| 25 | |
| 26 | if ((ret = ftdi_usb_find_allcxx . . $ ftdi_usb_find_all(c44df5d38c831626).(ftdi, &devlist, 0, 0)) < 0) |
| 27 | { |
| 28 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_usb_find_all failed: %d (%s)\n", ret, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 29 | retval = EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 30 | goto do_deinit; |
| 31 | } |
| 32 | |
| 33 | printfcxx . . $ printf(581fddd72a8db8fc).("Number of FTDI devices found: %d\n", ret); |
| 34 | |
| 35 | i = 0; |
| 36 | for (curdev = devlist; curdev != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; i++) |
| 37 | { |
| 38 | printfcxx . . $ printf(581fddd72a8db8fc).("Checking device: %d\n", i); |
| 39 | if ((ret = ftdi_usb_get_stringscxx . . $ ftdi_usb_get_strings(bc8541491bd45225).(ftdi, curdev->devcxx . . $ ftdi_device_list#dev., manufacturer, 128, description, 128, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0)) < 0) |
| 40 | { |
| 41 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_usb_get_strings failed: %d (%s)\n", ret, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 42 | retval = EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 43 | goto done; |
| 44 | } |
| 45 | printfcxx . . $ printf(581fddd72a8db8fc).("Manufacturer: %s, Description: %s\n\n", manufacturer, description); |
| 46 | curdev = curdev->nextcxx . . $ ftdi_device_list#next.; |
| 47 | } |
| 48 | done: |
| 49 | ftdi_list_freecxx . . $ ftdi_list_free(1a862d998d78d7c5).(&devlist); |
| 50 | do_deinit: |
| 51 | ftdi_freecxx . . $ ftdi_free(a4aec54891bac95c).(ftdi); |
| 52 | |
| 53 | return retval; |
| 54 | } |