]> arthur.barton.de Git - netatalk.git/blob - libatalk/compat/rquota_xdr.c
Mege maste
[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(sun) && defined(__svr4__)) || \
24 (defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ < 6)
25
26 #ifndef u_int
27 #define u_int unsigned
28 #endif
29
30 #include <rpc/rpc.h>
31 #include <rpcsvc/rquota.h>
32
33 bool_t
34 xdr_getquota_args(xdrs, objp)
35         XDR *xdrs;
36         getquota_args *objp;
37 {
38         if (!xdr_string(xdrs, &objp->gqa_pathp, RQ_PATHLEN)) {
39                 return (FALSE);
40         }
41         if (!xdr_int(xdrs, &objp->gqa_uid)) {
42                 return (FALSE);
43         }
44         return (TRUE);
45 }
46
47
48 bool_t
49 xdr_rquota(xdrs, objp)
50         XDR *xdrs;
51         rquota *objp;
52 {
53         if (!xdr_int(xdrs, &objp->rq_bsize)) {
54                 return (FALSE);
55         }
56         if (!xdr_bool(xdrs, &objp->rq_active)) {
57                 return (FALSE);
58         }
59         if (!xdr_u_int(xdrs, &objp->rq_bhardlimit)) {
60                 return (FALSE);
61         }
62         if (!xdr_u_int(xdrs, &objp->rq_bsoftlimit)) {
63                 return (FALSE);
64         }
65         if (!xdr_u_int(xdrs, &objp->rq_curblocks)) {
66                 return (FALSE);
67         }
68         if (!xdr_u_int(xdrs, &objp->rq_fhardlimit)) {
69                 return (FALSE);
70         }
71         if (!xdr_u_int(xdrs, &objp->rq_fsoftlimit)) {
72                 return (FALSE);
73         }
74         if (!xdr_u_int(xdrs, &objp->rq_curfiles)) {
75                 return (FALSE);
76         }
77         if (!xdr_u_int(xdrs, &objp->rq_btimeleft)) {
78                 return (FALSE);
79         }
80         if (!xdr_u_int(xdrs, &objp->rq_ftimeleft)) {
81                 return (FALSE);
82         }
83         return (TRUE);
84 }
85
86
87
88
89 bool_t
90 xdr_gqr_status(xdrs, objp)
91         XDR *xdrs;
92         gqr_status *objp;
93 {
94         if (!xdr_enum(xdrs, (enum_t *)objp)) {
95                 return (FALSE);
96         }
97         return (TRUE);
98 }
99
100
101 bool_t
102 xdr_getquota_rslt(xdrs, objp)
103         XDR *xdrs;
104         getquota_rslt *objp;
105 {
106         if (!xdr_gqr_status(xdrs, &objp->status)) {
107                 return (FALSE);
108         }
109         switch (objp->status) {
110         case Q_OK:
111                 if (!xdr_rquota(xdrs, &objp->getquota_rslt_u.gqr_rquota)) {
112                         return (FALSE);
113                 }
114                 break;
115         case Q_NOQUOTA:
116                 break;
117         case Q_EPERM:
118                 break;
119         default:
120                 return (FALSE);
121         }
122         return (TRUE);
123 }
124 #endif