#include <stdio.h>
#include <stdlib.h>
#include "error_management.h"
#include "format_data.h"
Go to the source code of this file.
Functions | |
void | format_data (char *_path, char *_pattern, int n_arg) |
int | main (int argc, char *argv[]) |
void format_data | ( | char * | _path, | |
char * | _pattern, | |||
int | n_arg | |||
) |
Definition at line 37 of file UTILS/PROGRAMS/WINDOWS/DATA_EXTRACT/main.c.
References _data, ASSERT, format_data_get_data(), and n_data.
Referenced by main().
00038 { 00039 char *_buffer; 00040 int n, n_data; 00041 FILE *_file; 00042 float *_data; 00043 00044 ASSERT(_path); 00045 00046 // Open the file 00047 _file = fopen(_path, "rb"); 00048 ASSERT(_file); 00049 // Get the length of the file and store it into n 00050 fseek(_file, 0, SEEK_END); 00051 n = ftell(_file); 00052 // allocate a buffer of the size of the file 00053 _buffer = (char *) malloc(n + 1); 00054 ASSERT(_buffer); 00055 _buffer[n] = '\0'; 00056 // Go to the beginning of the file 00057 fseek(_file, 0, SEEK_SET); 00058 // Read it 00059 fread(_buffer, 1, n, _file); 00060 fclose(_file); 00061 00062 // Extract data from a buffer 00063 n_data = format_data_get_data(_buffer, _pattern, n_arg); 00064 00065 free(_buffer); 00066 }
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 69 of file UTILS/PROGRAMS/WINDOWS/DATA_EXTRACT/main.c.
References format_data().
00070 { 00071 00072 // If there arguments passed to this program 00073 if (argc == 4) 00074 format_data(argv[1], argv[2], atoi(argv[3])); 00075 // Else print the usage 00076 else 00077 printf("Usage: DataExtract input_buffer_file_path pattern n_arg\n\r"); 00078 00079 return 0; 00080 }