Created
January 30, 2017 14:07
-
-
Save aont/b1501c5809a96e73c22bc98ea7bd4b53 to your computer and use it in GitHub Desktop.
modify bto_advanced_USBIR_cmd to read data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* before getopt_long */ | |
| FILE* D_fp = NULL; | |
| int D_value; | |
| int D_ret; | |
| /* add D: to getopt_lonf */ | |
| getopt_long(argc, argv, "f:t:c:C:d:D:rsgh", options, &option_index) | |
| /* add case for 'D' */ | |
| case 'D': | |
| data_flag = 1; | |
| D_fp = fopen(optarg, "r"); | |
| while(!feof(D_fp)) { | |
| D_ret = fscanf(D_fp, "%x", &D_value); | |
| if(D_ret!=1) break; | |
| if(data!=NULL){ | |
| data = realloc(data, dataCount + 1); | |
| }else{ | |
| data = malloc(dataCount + 1); | |
| } | |
| data[dataCount++] = (byte)D_value; | |
| D_ret = fscanf(D_fp, ","); | |
| if(D_ret!=0) break; | |
| } | |
| fclose(D_fp); | |
| break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment