Expand|Select|Wrap|Line Numbers
- void findPacketHeaders(char *inputFile, char *outputFile)
- {
- /* Open file */
- fpInput = fopen(inputFile, "rb");
- fpOutput = fopen(outputFile, "w");
- /* check if fpInput exists */
- if (!fpInput)
- {
- fprintf(stderr, "Unable to open file %s", inputFile);
- return;
- }
- /* Read fpInput contents into buffer */
- do
- {
- if (fgetc(fpInput) == 0x25 && fgetc(fpInput) == 0xEB)
- {
- getPacketHeaderSegments(fpInput, pktHeader, fpOutput);
- }
- }while(!feof(fpInput));
- fclose(fpInput);
- fclose(fpOutput);
- }
FILE *fpInput, *fpOutput;
packetHeader pktHeader;
are global variables and they do work correctly.
This is my implementation of the timer:
Expand|Select|Wrap|Line Numbers
- void findPacketHeaders(char *inputFile, char *outputFile)
- {
- //FILE *fpInput, *fpOutput;
- //packetHeader pktHeader;
- pktHeader.packetSyncPattern = 0xEB25;
- /* Open file */
- fpInput = fopen(inputFile, "rb");
- fpOutput = fopen(outputFile, "w");
- /* check if fpInput exists */
- if (!fpInput)
- {
- fprintf(stderr, "Unable to open file %s", inputFile);
- return;
- }
- processTimer->Interval = 10;
- processTimer->Enabled = true;
- fclose(fpInput);
- fclose(fpOutput);
- }
- private: System::Void processTimer_Tick(System::Object^ sender, System::EventArgs^ e)
- {
- /* Read fpInput contents into buffer */
- richTextBox_console->AppendText(fgetc(fpInput).ToString("X") + "\n");
- if (fgetc(fpInput) == 0x25 && fgetc(fpInput) == 0xEB)
- {
- getPacketHeaderSegments(fpInput, pktHeader, fpOutput);
- }
- if(feof(fpInput))
- {
- /* break out of this */
- processTimer->Enabled = false;
- }
- }