]> arthur.barton.de Git - netatalk.git/blob - libatalk/compat/rquota_xdr.c
Initial revision
[netatalk.git] / libatalk / compat / rquota_xdr.c
1 /* taken from the quota-1.55 used on linux. here's the bsd copyright:
2  *
3  * Copyright (c) 1980, 1990 Regents of the University of California. All
4  * rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by Robert Elz at
7  * The University of Melbourne.
8  */
9
10 #include <stdio.h> /* to get __GNU_LIBRARY__ */
11
12 static int _xdr_rquota_dummy;
13
14 /* list of machines that don't have these functions:
15         solaris
16         linux libc5
17 */
18 #if defined(NEED_RQUOTA) || (defined(sun) && defined(__svr4__)) || \
19 (defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ < 6)
20
21 #include <rpc/rpc.h>
22 #include <rpcsvc/rquota.h>
23
24 bool_t
25 xdr_getquota_args(xdrs, objp)
26         XDR *xdrs;
27         getquota_args *objp;
28 {
29         if (!xdr_string(xdrs, &objp->gqa_pathp, RQ_PATHLEN)) {
30                 return (FALSE);
31         }
32         if (!xdr_int(xdrs, &objp->gqa_uid)) {
33                 return (FALSE);
34         }
35         return (TRUE);
36 }
37
38
39 bool_t
40 xdr_rquota(xdrs, objp)
41         XDR *xdrs;
42         rquota *objp;
43 {
44         if (!xdr_int(xdrs, &objp->rq_bsize)) {
45                 return (FALSE);
46         }
47         if (!xdr_bool(xdrs, &objp->rq_active)) {
48                 return (FALSE);
49         }
50         if (!xdr_u_int(xdrs, &objp->rq_bhardlimit)) {
51                 return (FALSE);
52         }
53         if (!xdr_u_int(xdrs, &objp->rq_bsoftlimit)) {
54                 return (FALSE);
55         }
56         if (!xdr_u_int(xdrs, &objp->rq_curblocks)) {
57                 return (FALSE);
58         }
59         if (!xdr_u_int(xdrs, &objp->rq_fhardlimit)) {
60                 return (FALSE);
61         }
62         if (!xdr_u_int(xdrs, &objp->rq_fsoftlimit)) {
63                 return (FALSE);
64         }
65         if (!xdr_u_int(xdrs, &objp->rq_curfiles)) {
66                 return (FALSE);
67         }
68         if (!xdr_u_int(xdrs, &objp->rq_btimeleft)) {
69                 return (FALSE);
70         }
71         if (!xdr_u_int(xdrs, &objp->rq_ftimeleft)) {
72                 return (FALSE);
73         }
74         return (TRUE);
75 }
76
77
78
79
80 bool_t
81 xdr_gqr_status(xdrs, objp)
82         XDR *xdrs;
83         gqr_status *objp;
84 {
85         if (!xdr_enum(xdrs, (enum_t *)objp)) {
86                 return (FALSE);
87         }
88         return (TRUE);
89 }
90
91
92 bool_t
93 xdr_getquota_rslt(xdrs, objp)
94         XDR *xdrs;
95         getquota_rslt *objp;
96 {
97         if (!xdr_gqr_status(xdrs, &objp->status)) {
98                 return (FALSE);
99         }
100         switch (objp->status) {
101         case Q_OK:
102                 if (!xdr_rquota(xdrs, &objp->getquota_rslt_u.gqr_rquota)) {
103                         return (FALSE);
104                 }
105                 break;
106         case Q_NOQUOTA:
107                 break;
108         case Q_EPERM:
109                 break;
110         default:
111                 return (FALSE);
112         }
113         return (TRUE);
114 }
115 #endif