1 /*
2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Project.xs contains XS wrappers for the project database maniplulation
6 * functions as provided by libproject and described in getprojent(3EXACCT).
7 */
8
9 /* Solaris includes. */
10 #include <zone.h>
11 #include <project.h>
12 #include <pool.h>
13 #include <sys/pool_impl.h>
14 #include <rctl.h>
15 #include <stdio.h>
16
17 /* Perl includes. */
18 #include "EXTERN.h"
19 #include "perl.h"
20 #include "XSUB.h"
21
22 /*
143 const char *user_name
144 uint_t flags
145
146 void
147 activeprojects()
148 PREINIT:
149 int nitems;
150 PPCODE:
151 PUTBACK;
152 nitems = 0;
153 project_walk(&pwalk_cb, (void*)&nitems);
154 XSRETURN(nitems);
155
156 void
157 getprojent()
158 PREINIT:
159 struct project proj, *projp;
160 char buf[PROJECT_BUFSZ];
161 PPCODE:
162 PUTBACK;
163 if (projp = getprojent(&proj, buf, sizeof (buf))) {
164 XSRETURN(pushret_project(projp));
165 } else {
166 XSRETURN_EMPTY;
167 }
168
169 void
170 setprojent()
171
172 void
173 endprojent()
174
175 void
176 getprojbyname(name)
177 char *name
178 PREINIT:
179 struct project proj, *projp;
180 char buf[PROJECT_BUFSZ];
181 PPCODE:
182 PUTBACK;
183 if (projp = getprojbyname(name, &proj, buf, sizeof (buf))) {
184 XSRETURN(pushret_project(projp));
185 } else {
186 XSRETURN_EMPTY;
187 }
188
189 void
190 getprojbyid(id)
191 projid_t id
192 PREINIT:
193 struct project proj, *projp;
194 char buf[PROJECT_BUFSZ];
195 PPCODE:
196 PUTBACK;
197 if (projp = getprojbyid(id, &proj, buf, sizeof (buf))) {
198 XSRETURN(pushret_project(projp));
199 } else {
200 XSRETURN_EMPTY;
201 }
202
203 void
204 getdefaultproj(user)
205 char *user
206 PREINIT:
207 struct project proj, *projp;
208 char buf[PROJECT_BUFSZ];
209 PPCODE:
210 PUTBACK;
211 if (projp = getdefaultproj(user, &proj, buf, sizeof (buf))) {
212 XSRETURN(pushret_project(projp));
213 } else {
214 XSRETURN_EMPTY;
215 }
216
217 void
218 fgetprojent(fh)
219 FILE *fh
220 PREINIT:
221 struct project proj, *projp;
222 char buf[PROJECT_BUFSZ];
223 PPCODE:
224 PUTBACK;
225 if (projp = fgetprojent(fh, &proj, buf, sizeof (buf))) {
226 XSRETURN(pushret_project(projp));
227 } else {
228 XSRETURN_EMPTY;
229 }
230
231 bool
232 inproj(user, proj)
233 char *user
234 char *proj
235 PREINIT:
236 char buf[PROJECT_BUFSZ];
237 CODE:
238 RETVAL = inproj(user, proj, buf, sizeof (buf));
239
240
241 int
242 getprojidbyname(proj)
243 char *proj
244 PREINIT:
245 int id;
246 PPCODE:
247 if ((id = getprojidbyname(proj)) == -1) {
248 XSRETURN_UNDEF;
249 } else {
250 XSRETURN_IV(id);
251 }
252
253
254 # rctl_get_info(name)
255 #
256 # For the given rctl name, returns the list
257 # ($max, $flags), where $max is the integer value
258 # of the system rctl, and $flags are the rctl's
259 # global flags, as returned by rctlblk_get_global_flags
260 #
261 # This function is private to Project.pm
262 void
263 rctl_get_info(name)
264 char *name
265 PREINIT:
266 rctlblk_t *blk1 = NULL;
267 rctlblk_t *blk2 = NULL;
268 rctlblk_t *tmp = NULL;
269 rctl_priv_t priv;
270 rctl_qty_t value;
271 int flags;
272 int ret;
273 int err = 0;
274 char string[24]; /* 24 will always hold a uint64_t */
275 PPCODE:
276 Newc(0, blk1, rctlblk_size(), char, rctlblk_t);
277 if (blk1 == NULL) {
278 err = 1;
279 goto out;
280 }
281 Newc(1, blk2, rctlblk_size(), char, rctlblk_t);
282 if (blk2 == NULL) {
283 err = 1;
284 goto out;
285 }
286 ret = getrctl(name, NULL, blk1, RCTL_FIRST);
287 if (ret != 0) {
288 err = 1;
289 goto out;
290 }
291 priv = rctlblk_get_privilege(blk1);
|
1 /*
2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2014 Racktop Systems.
4 */
5 /*
6 * Project.xs contains XS wrappers for the project database maniplulation
7 * functions as provided by libproject and described in getprojent(3EXACCT).
8 */
9
10 /* Solaris includes. */
11 #include <zone.h>
12 #include <project.h>
13 #include <pool.h>
14 #include <sys/pool_impl.h>
15 #include <rctl.h>
16 #include <stdio.h>
17
18 /* Perl includes. */
19 #include "EXTERN.h"
20 #include "perl.h"
21 #include "XSUB.h"
22
23 /*
144 const char *user_name
145 uint_t flags
146
147 void
148 activeprojects()
149 PREINIT:
150 int nitems;
151 PPCODE:
152 PUTBACK;
153 nitems = 0;
154 project_walk(&pwalk_cb, (void*)&nitems);
155 XSRETURN(nitems);
156
157 void
158 getprojent()
159 PREINIT:
160 struct project proj, *projp;
161 char buf[PROJECT_BUFSZ];
162 PPCODE:
163 PUTBACK;
164 if ((projp = getprojent(&proj, buf, sizeof (buf)))) {
165 XSRETURN(pushret_project(projp));
166 } else {
167 XSRETURN_EMPTY;
168 }
169
170 void
171 setprojent()
172
173 void
174 endprojent()
175
176 void
177 getprojbyname(name)
178 char *name
179 PREINIT:
180 struct project proj, *projp;
181 char buf[PROJECT_BUFSZ];
182 PPCODE:
183 PUTBACK;
184 if ((projp = getprojbyname(name, &proj, buf, sizeof (buf)))) {
185 XSRETURN(pushret_project(projp));
186 } else {
187 XSRETURN_EMPTY;
188 }
189
190 void
191 getprojbyid(id)
192 projid_t id
193 PREINIT:
194 struct project proj, *projp;
195 char buf[PROJECT_BUFSZ];
196 PPCODE:
197 PUTBACK;
198 if ((projp = getprojbyid(id, &proj, buf, sizeof (buf)))) {
199 XSRETURN(pushret_project(projp));
200 } else {
201 XSRETURN_EMPTY;
202 }
203
204 void
205 getdefaultproj(user)
206 char *user
207 PREINIT:
208 struct project proj, *projp;
209 char buf[PROJECT_BUFSZ];
210 PPCODE:
211 PUTBACK;
212 if ((projp = getdefaultproj(user, &proj, buf, sizeof (buf)))) {
213 XSRETURN(pushret_project(projp));
214 } else {
215 XSRETURN_EMPTY;
216 }
217
218 void
219 fgetprojent(fh)
220 FILE *fh
221 PREINIT:
222 struct project proj, *projp;
223 char buf[PROJECT_BUFSZ];
224 PPCODE:
225 PUTBACK;
226 if ((projp = fgetprojent(fh, &proj, buf, sizeof (buf)))) {
227 XSRETURN(pushret_project(projp));
228 } else {
229 XSRETURN_EMPTY;
230 }
231
232 bool
233 inproj(user, proj)
234 char *user
235 char *proj
236 PREINIT:
237 char buf[PROJECT_BUFSZ];
238 CODE:
239 RETVAL = inproj(user, proj, buf, sizeof (buf));
240 OUTPUT:
241 RETVAL
242
243
244 int
245 getprojidbyname(proj)
246 char *proj
247 PREINIT:
248 int id;
249 PPCODE:
250 if ((id = getprojidbyname(proj)) == -1) {
251 XSRETURN_UNDEF;
252 } else {
253 XSRETURN_IV(id);
254 }
255
256
257 # rctl_get_info(name)
258 #
259 # For the given rctl name, returns the list
260 # ($max, $flags), where $max is the integer value
261 # of the system rctl, and $flags are the rctl's
262 # global flags, as returned by rctlblk_get_global_flags
263 #
264 # This function is private to Project.pm
265 void
266 rctl_get_info(name)
267 char *name
268 PREINIT:
269 rctlblk_t *blk1 = NULL;
270 rctlblk_t *blk2 = NULL;
271 rctlblk_t *tmp = NULL;
272 rctl_priv_t priv;
273 rctl_qty_t value;
274 int flags = 0;
275 int ret;
276 int err = 0;
277 char string[24]; /* 24 will always hold a uint64_t */
278 PPCODE:
279 Newc(0, blk1, rctlblk_size(), char, rctlblk_t);
280 if (blk1 == NULL) {
281 err = 1;
282 goto out;
283 }
284 Newc(1, blk2, rctlblk_size(), char, rctlblk_t);
285 if (blk2 == NULL) {
286 err = 1;
287 goto out;
288 }
289 ret = getrctl(name, NULL, blk1, RCTL_FIRST);
290 if (ret != 0) {
291 err = 1;
292 goto out;
293 }
294 priv = rctlblk_get_privilege(blk1);
|