-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsaveutils.h
95 lines (88 loc) · 2.26 KB
/
saveutils.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* =============================================================================
* PROGRAM: ularn
* FILENAME: saveutils.h
*
* DESCRIPTION:
* This module contains utilities used in loading and saving games.
*
* =============================================================================
* EXPORTED VARIABLES
*
* FileSum : The current checksum for the file being written/read.
*
* =============================================================================
* EXPORTED FUNCTIONS
*
* sum : Checksum calculation function
* bwrite : Binary write with checksum update
* bread : Binary read with checksum update.
*
* =============================================================================
*/
#ifndef __SAVEUTILS_H
# define __SAVEUTILS_H
# include <stdio.h>
/*
* This is the current checksum value for bread and bwrite.
*/
extern int FileSum;
/* =============================================================================
* FUNCTION: sum
*
* DESCRIPTION:
* Checksum calculation function.
*
* PARAMETERS:
*
* data : A pointer to the data to be checksummed
*
* n : The number of bytes in Data to be checksummed
*
* RETURN VALUE:
*
* The checksum of data.
*/
unsigned int sum(unsigned char *data, int n);
/* =============================================================================
* FUNCTION: bwrite
*
* DESCRIPTION:
* Binary write function with checksum update.
* Writes the binary data to the specified file and updates the FileSum for
* the data written.
*
* PARAMETERS:
*
* fp : A pointer to the file being written
*
* buf : A pointer to the buffer to write.
*
* num : The number of characters in buf to write.
*
* RETURN VALUE:
*
* None.
*/
void bwrite(FILE *fp, char *buf, long num);
/* =============================================================================
* FUNCTION: bread
*
* DESCRIPTION:
* Binary read function with checksum update.
* Read the binary data from the specified file and updates the FileSum for
* the data read.
*
* PARAMETERS:
*
* fp : A pointer to the file being read
*
* buf : A pointer to the buffer to store the read data.
*
* num : The number of characters be read into buf.
*
* RETURN VALUE:
*
* None.
*/
void bread(FILE *fp, char *buf, long num);
#endif