| 9 |
* * |
* * |
| 10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
| 11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
| 12 |
* the Free Software Foundation; either version 2 of the License, or * |
* the Free Software Foundation; either version 3 of the License, or * |
| 13 |
* (at your option) any later version. * |
* (at your option) any later version. * |
| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 20 |
#include <stdio.h> |
#include <stdio.h> |
| 21 |
#include <string.h> |
#include <string.h> |
| 22 |
|
|
| 23 |
int split_line(const char *buffer, int max_len, int *p_eol) |
unsigned int split_line(const char *buffer, int max_len, int *p_eol) |
| 24 |
{ |
{ |
| 25 |
int len = strnlen(buffer, LINE_BUFFER_LEN); |
size_t len = strnlen(buffer, LINE_BUFFER_LEN); |
| 26 |
int display_len = 0; |
int display_len = 0; |
| 27 |
int i = 0; |
unsigned int i = 0; |
| 28 |
*p_eol = 0; |
*p_eol = 0; |
| 29 |
|
|
| 30 |
if (len == 0) |
if (len == 0) |
| 47 |
*p_eol = 1; |
*p_eol = 1; |
| 48 |
break; |
break; |
| 49 |
} |
} |
| 50 |
|
|
| 51 |
if (c == '\033' && buffer[i + 1] == '[') // Skip control sequence |
if (c == '\033' && buffer[i + 1] == '[') // Skip control sequence |
| 52 |
{ |
{ |
| 53 |
i += 2; |
i += 2; |
| 54 |
while(i < len && buffer[i] != 'm') |
while (i < len && buffer[i] != 'm') |
| 55 |
{ |
{ |
| 56 |
i++; |
i++; |
| 57 |
} |
} |
| 82 |
return i; |
return i; |
| 83 |
} |
} |
| 84 |
|
|
| 85 |
int split_file_lines(FILE *fin, int max_len, long *p_line_offsets, int max_line_cnt) |
unsigned int split_file_lines(FILE *fin, int max_len, long *p_line_offsets, int max_line_cnt) |
| 86 |
{ |
{ |
| 87 |
char buffer[LINE_BUFFER_LEN]; |
char buffer[LINE_BUFFER_LEN]; |
| 88 |
char *p_buf = buffer; |
char *p_buf = buffer; |
| 89 |
int line_cnt = 0; |
unsigned int line_cnt = 0; |
| 90 |
int len = 0; |
unsigned int len = 0; |
| 91 |
int end_of_line = 0; |
int end_of_line = 0; |
| 92 |
p_line_offsets[line_cnt] = 0L; |
p_line_offsets[line_cnt] = 0L; |
| 93 |
|
|
| 94 |
while (fgets(p_buf, sizeof(buffer) - len, fin)) |
while (fgets(p_buf, (int)(sizeof(buffer) - len), fin)) |
| 95 |
{ |
{ |
| 96 |
p_buf = buffer; |
p_buf = buffer; |
| 97 |
while (1) |
while (1) |