Skip to content

Instantly share code, notes, and snippets.

@makestuff
Created October 16, 2013 17:46
Show Gist options
  • Save makestuff/7011896 to your computer and use it in GitHub Desktop.
Save makestuff/7011896 to your computer and use it in GitHub Desktop.
const char *fileName;
unsigned long chan = strtoul(dumpOpt->sval[0], (char**)&fileName, 10);
FILE *file = NULL;
struct ReadReport readReport = {0,};
CHECK_STATUS(*fileName!=':', FLP_ARGS, cleanup);
fileName++;
printf("Copying from channel %lu to %s", chan, fileName);
file = fopen(fileName, "wb");
CHECK_STATUS(!file, FLP_CANNOT_SAVE, cleanup);
sigRegisterHandler();
fStatus = flSelectConduit(handle, conduit, &error);
CHECK_STATUS(fStatus, FLP_LIBERR, cleanup);
fStatus = flReadChannelAsyncSubmit(handle, (uint8)chan, 22528, &error);
CHECK_STATUS(fStatus, FLP_LIBERR, cleanup);
do {
fStatus = flReadChannelAsyncSubmit(handle, (uint8)chan, 22528, &error);
CHECK_STATUS(fStatus, FLP_LIBERR, cleanup);
fStatus = flReadChannelAsyncAwait(handle, &readReport, &error);
CHECK_STATUS(fStatus, FLP_LIBERR, cleanup);
fwrite(readReport.data, 1, readReport.actualLength, file);
printf(".");
} while ( !sigIsRaised() );
printf("\nCaught SIGINT, quitting...\n");
fStatus = flReadChannelAsyncAwait(handle, &readReport, &error);
CHECK_STATUS(fStatus, FLP_LIBERR, cleanup);
fwrite(readReport.data, 1, readReport.actualLength, file);
fclose(file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment