diff options
Diffstat (limited to 'all_pairs/source/susan/wccfile.c')
| -rw-r--r-- | all_pairs/source/susan/wccfile.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/all_pairs/source/susan/wccfile.c b/all_pairs/source/susan/wccfile.c deleted file mode 100644 index 42db3db..0000000 --- a/all_pairs/source/susan/wccfile.c +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 1 | #include "wccfile.h" | ||
| 2 | #define EOFX -1 | ||
| 3 | |||
| 4 | size_x susan_wccfread(void* ptr, size_x size, size_x count, struct wccFILE* stream) | ||
| 5 | { | ||
| 6 | if ( susan_wccfeof( stream ) ) { | ||
| 7 | return EOFX; | ||
| 8 | } | ||
| 9 | |||
| 10 | unsigned i = stream->cur_pos, i2 = 0; | ||
| 11 | size_x number_of_chars_to_read = | ||
| 12 | stream->size - stream->cur_pos >= size * count ? | ||
| 13 | size * count : stream->size - stream->cur_pos; | ||
| 14 | _Pragma( "loopbound min 7220 max 7220" ) | ||
| 15 | while (i < stream->cur_pos + number_of_chars_to_read) { | ||
| 16 | ((unsigned char*)ptr)[i2++] = stream->data[i++]; | ||
| 17 | } | ||
| 18 | stream->cur_pos += number_of_chars_to_read; | ||
| 19 | return number_of_chars_to_read; | ||
| 20 | } | ||
| 21 | |||
| 22 | int susan_wccfgetc(struct wccFILE *stream) | ||
| 23 | { | ||
| 24 | if ( susan_wccfeof( stream ) ) { | ||
| 25 | return EOFX; | ||
| 26 | } else { | ||
| 27 | return stream->data[stream->cur_pos++]; | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | char *susan_wccfgets(char *str, int num, struct wccFILE *stream ) | ||
| 32 | { | ||
| 33 | if ( !stream || susan_wccfeof( stream ) || !str || num <= 0 ) { | ||
| 34 | return 0; | ||
| 35 | } | ||
| 36 | |||
| 37 | int pos = 0; | ||
| 38 | _Pragma( "loopbound min 58 max 58" ) | ||
| 39 | while ( pos < num - 1 && !susan_wccfeof( stream ) ) { | ||
| 40 | str[pos] = stream->data[stream->cur_pos]; | ||
| 41 | if ( str[pos] == '\n' ) { | ||
| 42 | break; | ||
| 43 | } | ||
| 44 | |||
| 45 | stream->cur_pos++; | ||
| 46 | pos++; | ||
| 47 | } | ||
| 48 | str[pos++] = '\0'; | ||
| 49 | |||
| 50 | return str; | ||
| 51 | } | ||
| 52 | |||
| 53 | int susan_wccfseek(struct wccFILE* stream, long int offset, enum _Origin_ origin) | ||
| 54 | { | ||
| 55 | if (origin == WCCSEEK_SET) { | ||
| 56 | stream->cur_pos = offset; | ||
| 57 | return 0; | ||
| 58 | } else if (origin == WCCSEEK_CUR) { | ||
| 59 | stream->cur_pos += offset; | ||
| 60 | return 0; | ||
| 61 | } else if (origin == WCCSEEK_END) { | ||
| 62 | stream->cur_pos = stream->size + offset; | ||
| 63 | return 0; | ||
| 64 | } | ||
| 65 | return -1; | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | int susan_wccfgetpos(struct wccFILE* stream, unsigned* position) | ||
| 70 | { | ||
| 71 | *position = stream->cur_pos; | ||
| 72 | return 0; | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | int susan_wccfeof(struct wccFILE* stream) | ||
| 77 | { | ||
| 78 | return stream->cur_pos == stream->size ? 1 : 0; | ||
| 79 | } | ||
