-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncs.h
More file actions
81 lines (76 loc) · 2.56 KB
/
funcs.h
File metadata and controls
81 lines (76 loc) · 2.56 KB
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
/*
* return a struct containing the same values as the argument struct
* except that each field has its byte order reversed
*
* RESTRICTION: this function must not use arrays or pointers at all;
* accomplish the byte swapping using shift operators
*/
struct s1 endian_swap_s1_shift (struct s1);
/*
* return a struct containing the same values as the argument struct
* except that each field has its byte order reversed
*
* RESTRICTION: this function must not use shift operators;
* accomplish the byte swapping using pointers and/or arrays
*/
struct s1 endian_swap_s1_ptr (struct s1);
/*
* convert a standard (padded) struct into a packed struct containing
* the same fields
*
* the first argument points to a struct s2_packed, the second
* argument points to a struct s2
*
* therefore, your job is to copy data referenced by the second
* argument into space referenced by the first argument
*
* RESTRICTION: all data movement must be through pointer/array
* operations, no actual struct code is permitted
*/
void pack_s2 (char *, char *);
/*
* convert a packed struct into a stanard (padded) struct containing
* the same fields
*
* the first argument points to a struct s2, the second
* argument points to a struct s2_packed
*
* therefore, your job is to copy data referenced by the second
* argument into space referenced by the first argument
*
* RESTRICTION: all data movement must be through pointer/array
* operations, no actual struct code is permitted
*/
void unpack_S2 (char *, char *);
/*
* convert a struct with full-width fields into a struct containing
* bitfields
*
* the first argument points to a struct s3_bitfield, the second
* argument points to a struct s3
*
* therefore, your job is to copy data referenced by the second
* argument into space referenced by the first argument
*
* RETURN VALUE: if the value in any full-width field cannot be
* represented in its corresponding bitfield, return -1; otherwise
* return 0
*
* RESTRICTION: all data movement must be through pointer/array/shift
* operations, no actual struct code is permitted
*/
int pack_s3 (char *, char *);
/*
* convert a struct with bitfields into a struct containing
* full-width fields
*
* the first argument points to a struct s3, the second
* argument points to a struct s3_bitfield
*
* therefore, your job is to copy data referenced by the second
* argument into space referenced by the first argument
*
* RESTRICTION: all data movement must be through pointer/array/shift
* operations, no actual struct code is permitted
*/
void unpack_s3 (char *, char *);