Commit | Line | Data |
---|---|---|
2acaaee4 KM |
1 | /* Copyright (c) 1979 Regents of the University of California */ |
2 | ||
492cc5d3 | 3 | static char sccsid[] = "@(#)UNPACK.c 1.2 %G%"; |
2acaaee4 KM |
4 | |
5 | #include "h01errs.h" | |
6 | ||
7 | /* | |
8 | * unpack(z,a,i) | |
9 | * | |
10 | * with: z and a as in pack | |
11 | * | |
12 | * semantics: for j := u to v do | |
13 | * a[j-u+i] := z[j] | |
14 | */ | |
15 | ||
16 | UNPACK(i, a, z, size_a, lb_a, ub_a, size_z) | |
17 | ||
492cc5d3 | 18 | long i; /* subscript into a to begin packing */ |
2acaaee4 KM |
19 | char *a; /* pointer to structure a */ |
20 | char *z; /* pointer to structure z */ | |
492cc5d3 KM |
21 | long size_a; /* sizeof(a_type) */ |
22 | long lb_a; /* lower bound of structure a */ | |
23 | long ub_a; /* (upper bound of a) - (lb_a + sizeof(z_type)) */ | |
24 | long size_z; /* sizeof(z_type) */ | |
2acaaee4 KM |
25 | { |
26 | int subscr; | |
27 | register char *cp; | |
28 | register char *zp = z; | |
29 | register char *limit; | |
30 | ||
31 | subscr = i - lb_a; | |
32 | if (subscr < 0 || subscr > ub_a) { | |
33 | ERROR(EPACK, i); | |
34 | return; | |
35 | } | |
36 | cp = &a[subscr * size_a]; | |
37 | limit = cp + size_z; | |
38 | do { | |
39 | *cp++ = *zp++; | |
40 | } while (cp < limit); | |
41 | } |