blob: 921af68d4fbdc08eb6b0eb2c5602c1147c3087c0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include "rijndael_enc_libc.h"
int rijndael_enc_toupper( int c )
{
if ( ( c >= 'a' ) && ( c <= 'z' ) )
return c - 'a' + 'A';
return c;
}
unsigned long rijndael_enc_fread( void *ptr, unsigned long size,
unsigned long count, struct rijndael_enc_FILE *stream )
{
unsigned i = stream->cur_pos, i2 = 0;
unsigned long number_of_chars_to_read =
stream->size - stream->cur_pos >= size * count ?
size * count : stream->size - stream->cur_pos;
_Pragma( "loopbound min 10 max 16" )
while ( i < stream->cur_pos + number_of_chars_to_read )
( ( unsigned char * )ptr )[i2++] = stream->data[i++];
stream->cur_pos += number_of_chars_to_read;
return number_of_chars_to_read;
}
unsigned long rijndael_enc_fwrite( const void *ptr, unsigned long size,
unsigned long count, struct rijndael_enc_FILE *stream )
{
unsigned i = stream->cur_pos, i2 = 0;
unsigned long number_of_chars_to_write =
stream->size - stream->cur_pos >= size * count ?
size * count : stream->size - stream->cur_pos;
_Pragma( "loopbound min 0 max 0" )
while ( i < stream->cur_pos + number_of_chars_to_write )
stream->data[i++] = ( ( unsigned char * )ptr )[i2++];
stream->cur_pos += number_of_chars_to_write;
return number_of_chars_to_write;
}
int rijndael_enc_fseek( struct rijndael_enc_FILE *stream, long int offset,
Origin origin )
{
if ( origin == RIJNDAEL_ENC_SEEK_SET ) {
stream->cur_pos = offset;
return 0;
} else
if ( origin == RIJNDAEL_ENC_SEEK_CUR ) {
stream->cur_pos += offset;
return 0;
} else
if ( origin == RIJNDAEL_ENC_SEEK_END ) {
stream->cur_pos = stream->size + offset;
return 0;
}
return -1;
}
int rijndael_enc_fgetpos( struct rijndael_enc_FILE *stream,
unsigned *position )
{
*position = stream->cur_pos;
return 0;
}
int rijndael_enc_feof( struct rijndael_enc_FILE *stream )
{
return stream->cur_pos == stream->size ? 1 : 0;
}
|