Skip to content

Instantly share code, notes, and snippets.

@aont
Created January 30, 2017 14:07
Show Gist options
  • Select an option

  • Save aont/b1501c5809a96e73c22bc98ea7bd4b53 to your computer and use it in GitHub Desktop.

Select an option

Save aont/b1501c5809a96e73c22bc98ea7bd4b53 to your computer and use it in GitHub Desktop.
modify bto_advanced_USBIR_cmd to read data
/* 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