afsconfig-and-rcsid-all-around-20010705
[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 <afs/param.h>
17 #include <afsconfig.h>
18
19 RCSID("$Header$");
20
21 #include <sys/types.h>
22 #ifdef AFS_NT40_ENV
23 #include <winsock2.h>
24 #else
25 #include <netinet/in.h>
26 #endif
27 #include <rx/xdr.h>
28 #include <rx/rx.h>
29 #include <ptclient.h>
30 #include "acl.h"
31
32 int acl_HtonACL(acl)
33 struct acl_accessList *acl;
34 {
35     /* Converts the access list defined by acl to network order.  Returns 0 always. */
36
37     int i;
38     if (htonl(1) == 1) return(0);       /* no swapping needed */
39     for (i = 0; i < acl->positive; i++) {
40         acl->entries[i].id = htonl(acl->entries[i].id);
41         acl->entries[i].rights = htonl(acl->entries[i].rights);
42     }
43     for (i = acl->total - 1; i >= acl->total - acl->negative; i--) {
44         acl->entries[i].id = htonl(acl->entries[i].id);
45         acl->entries[i].rights = htonl(acl->entries[i].rights);
46     }
47     acl->size = htonl(acl->size);
48     acl->version = htonl(acl->version);
49     acl->total = htonl(acl->total);
50     acl->positive = htonl(acl->positive);
51     acl->negative = htonl(acl->negative);
52     return(0);
53 }
54
55 int acl_NtohACL(acl)
56 struct acl_accessList *acl;
57 {
58     /* Converts the access list defined by acl to network order. Returns 0 always. */
59
60     int i;
61     if (ntohl(1) == 1) return(0);       /* no swapping needed */
62     acl->size = ntohl(acl->size);
63     acl->version = ntohl(acl->version);
64     acl->total = ntohl(acl->total);
65     acl->positive = ntohl(acl->positive);
66     acl->negative = ntohl(acl->negative);
67     for (i = 0; i < acl->positive; i++) {
68         acl->entries[i].id = ntohl(acl->entries[i].id);
69         acl->entries[i].rights = ntohl(acl->entries[i].rights);
70     }
71     for (i = acl->total - 1; i >= acl->total - acl->negative; i--) {
72         acl->entries[i].id = ntohl(acl->entries[i].id);
73         acl->entries[i].rights = ntohl(acl->entries[i].rights);
74     }
75     return(0);
76 }
77