Ets_Files_Diff_Generate()
Note: Requires OPNET Development Kit
Abstract
Compares two ASCII files and displays the differences using HTML output.
Syntax
Ets_Files_Diff_Generate (infile1_path, infile2_path, output_path, diff_options, num_of_diffs)
| Argument | Type | Description |
|---|---|---|
infile1_path |
const char * |
The complete path, including file name. |
infile2_path |
const char * |
The complete path, including file name. |
output_path |
const char * |
The complete path, including file name. The output file is an HTML file. |
diff_options |
EtsT_Files_Diff_Options * |
Formatting options. See Table 25. |
num_of_diffs |
int * |
The number of differences found. The number of differences is included in the HTML output. |
Return Type
EtsT_Compcode
EtsC_Compcode_Success when function succeeded, EtsC_Compcode_Failure when failed.
Header
ets_api_diff.h
Details
Allows you to compare two ASCII files. The HTML output displays the differences between the two files. The HTML output includes
- The HTML header
- A legend designating the symbols and colors of the differences (additions, changes, deletions)
- The number of changes Note that consecutive changes (for example, multiple deleted lines) is counted as one change.
- Two panes showing the changes between the specified files
The EtsT_Files_Diff_Options specify formatting characteristics. The formatting options are listed in the following table.
Table 25: EtsT_Files_Dif_Options—Formatting Options
| Argument | Type | Description |
|---|---|---|
ignore_white_space |
unsigned int |
Ignore blank spaces and tabs. Set to 1 to ignore white space characters. Otherwise, set to 0. Extra spaces at the end of lines are ignored. Note: When whitespace is ignored, changed consecutive spaces are “collapsed” to a single space in the HTML output. Therefore, the output may not exactly resemble the actual file. |
strike_out_text |
unsigned int |
Use strikeout text file2 to indicate text that is present in file1, but not in file2. Set to 1 to use strike out text. Otherwise, set to 0. |
context_lines_only |
unsigned int |
Show only differences and corresponding context lines. Set to 1 to show only differences. Otherwise, set to 0. Use this attribute when performing a difference on large files to save time (for determining the changes and rendering the HTML output.) |
num_context_line |
int |
Number of context lines shown above and below differences. Used with context_lines_only. The default is 5. |
show_progress |
unsigned int |
Show progress bar while differences between the two files are generated. Set to 1 to show progress bar. Otherwise, set to 0. |
file1_title |
const char * |
Title to display in the output for file1. |
file2_title |
const char * |
Title to display in the output for file2. |
html_output_header_buffer‘ |
const char * |
HTML header to be prepended to the output. |
error_log_buffer |
char * |
Error log used to log errors. The error log captures possible errors, including unable to locate specified files or read/write permission issues. No HTML output is generated if an error is produced. |
len_error_log_buffer |
int |
Length of error log. Note: You must allocate memory for the length of the error log buffer before passing it in the function. |
html_output_footer_buffer |
const char * |
HTML footer to be appended to the output. |
Before using the Ets_Files_Diff_Generate function, you must allocate memory for the length of the error log buffer.
For example:
/* Allocate error log buffer length */
/* Allocate error log buffer length */
char error_buffer[1024];
/* Compare two ASCII files */
char input_file1[] = "C;\users\jsmith\op_models\file1";
char input_file2[] = "C;\users\jsmith\op_models\file2";
char output_file[] = "C;\users\jsmith\op_models\output.html";
int num_diffs;
EtsT_Compcode retval;
/* Perform file difference between file1 and file2 */
EtsT_Files_Diff_Options options;
options.ignore_white_space=0;
options.strike_out_text=1;
options.context_lines_only=1;
options.num_context_line=5;
options.show_progress=0;
file1_title=”file1”;
file2_title=”File2”;
options.html_output_header_buffer=”<H2>File Differences:</H2>”;
options.error_log_buffer=error_buffer;
options.len_error_log_buffer=1024
options.html_output_footer_buffer=”<H2>End of Output</H2>”;
retval = Ets_Files_Diff_Generate
(input_file1, input_file2, output_file, &options, &num_diffs);