diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
| commit | 386b7d3366f1359a265da207a9cafa3edf553b64 (patch) | |
| tree | c76120c2c138faed822e4ae386be6ef22a738a78 /all_pairs/source/rijndael_dec/rijndael_dec_libc.c | |
| parent | 54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff) | |
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'all_pairs/source/rijndael_dec/rijndael_dec_libc.c')
| -rw-r--r-- | all_pairs/source/rijndael_dec/rijndael_dec_libc.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/all_pairs/source/rijndael_dec/rijndael_dec_libc.c b/all_pairs/source/rijndael_dec/rijndael_dec_libc.c new file mode 100644 index 0000000..00390df --- /dev/null +++ b/all_pairs/source/rijndael_dec/rijndael_dec_libc.c | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | #include "rijndael_dec_libc.h" | ||
| 2 | |||
| 3 | int rijndael_dec_toupper( int c ) | ||
| 4 | { | ||
| 5 | if ( ( c >= 'a' ) && ( c <= 'z' ) ) | ||
| 6 | return c - 'a' + 'A'; | ||
| 7 | return c; | ||
| 8 | } | ||
| 9 | |||
| 10 | unsigned long rijndael_dec_fread( void *ptr, unsigned long size, | ||
| 11 | unsigned long count, struct rijndael_dec_FILE *stream ) | ||
| 12 | { | ||
| 13 | unsigned i = stream->cur_pos, i2 = 0; | ||
| 14 | unsigned long number_of_chars_to_read = | ||
| 15 | stream->size - stream->cur_pos >= size * count ? | ||
| 16 | size * count : stream->size - stream->cur_pos; | ||
| 17 | _Pragma( "loopbound min 10 max 16" ) | ||
| 18 | while ( i < stream->cur_pos + number_of_chars_to_read ) | ||
| 19 | ( ( unsigned char * )ptr )[i2++] = stream->data[i++]; | ||
| 20 | stream->cur_pos += number_of_chars_to_read; | ||
| 21 | return number_of_chars_to_read; | ||
| 22 | } | ||
| 23 | |||
| 24 | unsigned long rijndael_dec_fwrite( const void *ptr, unsigned long size, | ||
| 25 | unsigned long count, struct rijndael_dec_FILE *stream ) | ||
| 26 | { | ||
| 27 | unsigned i = stream->cur_pos, i2 = 0; | ||
| 28 | unsigned long number_of_chars_to_write = | ||
| 29 | stream->size - stream->cur_pos >= size * count ? | ||
| 30 | size * count : stream->size - stream->cur_pos; | ||
| 31 | _Pragma( "loopbound min 0 max 0" ) | ||
| 32 | while ( i < stream->cur_pos + number_of_chars_to_write ) | ||
| 33 | stream->data[i++] = ( ( unsigned char * )ptr )[i2++]; | ||
| 34 | stream->cur_pos += number_of_chars_to_write; | ||
| 35 | return number_of_chars_to_write; | ||
| 36 | } | ||
| 37 | |||
| 38 | int rijndael_dec_fseek( struct rijndael_dec_FILE *stream, long int offset, | ||
| 39 | Origin origin ) | ||
| 40 | { | ||
| 41 | if ( origin == RIJNDAEL_DEC_SEEK_SET ) { | ||
| 42 | stream->cur_pos = offset; | ||
| 43 | return 0; | ||
| 44 | } else | ||
| 45 | if ( origin == RIJNDAEL_DEC_SEEK_CUR ) { | ||
| 46 | stream->cur_pos += offset; | ||
| 47 | return 0; | ||
| 48 | } else | ||
| 49 | if ( origin == RIJNDAEL_DEC_SEEK_END ) { | ||
| 50 | stream->cur_pos = stream->size + offset; | ||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | return -1; | ||
| 54 | } | ||
| 55 | |||
| 56 | int rijndael_dec_fgetpos( struct rijndael_dec_FILE *stream, | ||
| 57 | unsigned *position ) | ||
| 58 | { | ||
| 59 | *position = stream->cur_pos; | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | int rijndael_dec_feof( struct rijndael_dec_FILE *stream ) | ||
| 64 | { | ||
| 65 | return stream->cur_pos == stream->size ? 1 : 0; | ||
| 66 | } | ||
