home *** CD-ROM | disk | FTP | other *** search
- /*
- o_attr.c
- */
- /* Copyright (c) 1994 Christian F. Tschudin. All rights reserved.
-
- Distributed under the terms of the GNU General Public License
- version 2 of june 1991 as published by the Free Software
- Foundation, Inc.
-
- This file is part of M0.
-
- M0 is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY. No author or distributor accepts responsibility to anyone for
- the consequences of using it or for whether it serves any particular
- purpose or works at all, unless he says so in writing. Refer to the GNU
- General Public License for full details.
-
- Everyone is granted permission to copy, modify and redistribute M0, but
- only under the conditions described in the GNU General Public License.
- A copy of this license is supposed to have been given to you along with
- M0 so you can know your rights and responsibilities. It should be in a
- file named LICENSE. Among other things, the copyright notice and this
- notice must be preserved on all copies. */
-
- #include <time.h>
- #include <stdlib.h>
-
- #include "l_proto.h"
- #include "o_proto.h"
-
- retcode
- o_getattr()
- {
- int mask;
-
- load_1_arg(ei, ep);
-
- mask = epattr(ep) & A_ALL;
- decrefp(current, ei, ep);
- ei = current->os[current->osp-1] = new_element(current, T_INT);
- eaddr(current, ei)->V.i = mask;
-
- return OK;
- }
-
-
- retcode
- o_setattr()
- {
- int mask;
-
- load_2_args(oi, mi, op, mp);
-
- if (eptype(mp) != T_INT)
- return ERR_TYPE_CHECK;
- mask = mp->V.i;
- if (mask < 0 || mask > A_ALL)
- return ERR_RANGE_CHECK;
-
- if (!(epattr(op) & A_WRITE))
- return ERR_ACCESS_CHECK;
-
- epattr(op) &= mask | ~A_ALL;
-
- decrefp(current, mi, mp);
- decrefp(current, oi, op);
- current->osp -= 2;
-
- return OK;
- }
-