dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libbsm / common / adrm.c
blobef6571969964dc8b9a424976465999c6b82e5144
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Adr memory based translations
32 #include <stdio.h>
33 #include <sys/types.h>
34 #include <bsm/audit.h>
35 #include <bsm/audit_record.h>
37 void
38 adrm_start(adr_t *adr, char *p)
40 adr->adr_stream = p;
41 adr->adr_now = p;
45 * adrm_char - pull out characters
47 void
48 adrm_char(adr_t *adr, char *cp, int count)
50 while (count-- > 0)
51 *cp++ = *adr->adr_now++;
55 * adrm_short - pull out shorts
57 void
58 adrm_short(adr_t *adr, short *sp, int count)
60 while (count-- > 0) {
61 *sp = *adr->adr_now++ << 8;
62 *sp++ += ((short)*adr->adr_now++) & 0x00ff;
67 * adrm_int32 - pull out int
69 void adrm_int(adr_t *adr, int32_t *lp, int count);
70 void adrm_long(adr_t *adr, int32_t *lp, int count);
71 #pragma weak adrm_int = adrm_int32
72 #pragma weak adrm_long = adrm_int32
74 void
75 adrm_int32(adr_t *adr, int32_t *lp, int count)
77 int i;
79 for (; count-- > 0; lp++) {
80 *lp = 0;
81 for (i = 0; i < 4; i++) {
82 *lp <<= 8;
83 *lp += ((int32_t)*adr->adr_now++) & 0x000000ff;
88 void
89 adrm_uid(adr_t *adr, uid_t *up, int count)
91 int i;
93 for (; count-- > 0; up++) {
94 *up = 0;
95 for (i = 0; i < 4; i++) {
96 *up <<= 8;
97 *up += ((uid_t)*adr->adr_now++) & 0x000000ff;
102 void
103 adrm_int64(adr_t *adr, int64_t *lp, int count)
105 int i;
107 for (; count-- > 0; lp++) {
108 *lp = 0;
109 for (i = 0; i < 8; i++) {
110 *lp <<= 8;
111 *lp += ((int64_t)*adr->adr_now++) & 0x00000000000000ff;
116 void adrm_u_int(adr_t *adr, uint32_t *cp, int count);
117 void adrm_u_long(adr_t *adr, uint32_t *cp, int count);
118 #pragma weak adrm_u_int = adrm_u_int32
119 #pragma weak adrm_u_long = adrm_u_int32
121 void
122 adrm_u_int32(adr_t *adr, uint32_t *cp, int count)
124 adrm_int32(adr, (int32_t *)cp, count);
127 void
128 adrm_u_char(adr_t *adr, uchar_t *cp, int count)
130 adrm_char(adr, (char *)cp, count);
133 void
134 adrm_u_int64(adr_t *adr, uint64_t *lp, int count)
136 adrm_int64(adr, (int64_t *)lp, count);
139 void
140 adrm_u_short(adr_t *adr, ushort_t *sp, int count)
142 adrm_short(adr, (short *)sp, count);
146 * adrm_putint32 - pack in int32
148 #pragma weak adrm_putint = adrm_putint32
149 #pragma weak adrm_putlong = adrm_putint32
150 void
151 adrm_putint32(adr_t *adr, int32_t *lp, int count)
153 int i; /* index for counting */
154 int32_t l; /* value for shifting */
156 for (; count-- > 0; lp++) {
157 for (i = 0, l = *lp; i < 4; i++) {
158 *adr->adr_now++ = (char)((l & (int32_t)0xff000000) >>
159 (int)24);
160 l <<= (int)8;