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