libacl: Tidy header includes
[openafs.git] / src / libacl / netprocs.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11         Information Technology Center
12         Carnegie-Mellon University
13 */
14
15
16 #include <afsconfig.h>
17 #include <afs/param.h>
18
19 #include <roken.h>
20
21 #include <rx/xdr.h>
22 #include <rx/rx.h>
23 #include <afs/ptclient.h>
24
25 #include "acl.h"
26
27 int
28 acl_HtonACL(struct acl_accessList *acl)
29 {
30     /* Converts the access list defined by acl to network order.  Returns 0 always. */
31
32     int i;
33     if (htonl(1) == 1)
34         return (0);             /* no swapping needed */
35     for (i = 0; i < acl->positive; i++) {
36         acl->entries[i].id = htonl(acl->entries[i].id);
37         acl->entries[i].rights = htonl(acl->entries[i].rights);
38     }
39     for (i = acl->total - 1; i >= acl->total - acl->negative; i--) {
40         acl->entries[i].id = htonl(acl->entries[i].id);
41         acl->entries[i].rights = htonl(acl->entries[i].rights);
42     }
43     acl->size = htonl(acl->size);
44     acl->version = htonl(acl->version);
45     acl->total = htonl(acl->total);
46     acl->positive = htonl(acl->positive);
47     acl->negative = htonl(acl->negative);
48     return (0);
49 }
50
51 int
52 acl_NtohACL(struct acl_accessList *acl)
53 {
54     /* Converts the access list defined by acl to network order. Returns 0 always. */
55
56     int i;
57     if (ntohl(1) == 1)
58         return (0);             /* no swapping needed */
59     acl->size = ntohl(acl->size);
60     acl->version = ntohl(acl->version);
61     acl->total = ntohl(acl->total);
62     acl->positive = ntohl(acl->positive);
63     acl->negative = ntohl(acl->negative);
64     for (i = 0; i < acl->positive; i++) {
65         acl->entries[i].id = ntohl(acl->entries[i].id);
66         acl->entries[i].rights = ntohl(acl->entries[i].rights);
67     }
68     for (i = acl->total - 1; i >= acl->total - acl->negative; i--) {
69         acl->entries[i].id = ntohl(acl->entries[i].id);
70         acl->entries[i].rights = ntohl(acl->entries[i].rights);
71     }
72     return (0);
73 }