8030 libmvect: uninitialized variable
[unleashed.git] / usr / src / lib / libbsm / common / adr.c
blobabc2d9a3fb6b5cda78415e3a782ba9feb5299e7d
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 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 * Adr memory based encoding
31 #include <sys/types.h>
32 #include <bsm/audit.h>
33 #include <bsm/libbsm.h>
34 #include <bsm/audit_record.h>
36 void
37 adr_start(adr_t *adr, char *p)
39 adr->adr_stream = p;
40 adr->adr_now = p;
43 int
44 adr_count(adr_t *adr)
46 return (((intptr_t)adr->adr_now) - ((intptr_t)adr->adr_stream));
51 * adr_char - pull out characters
53 void
54 adr_char(adr_t *adr, char *cp, int count)
56 while (count-- > 0)
57 *adr->adr_now++ = *cp++;
61 * adr_short - pull out shorts
63 void
64 adr_short(adr_t *adr, short *sp, int count)
67 for (; count-- > 0; sp++) {
68 *adr->adr_now++ = (char)((*sp >> 8) & 0x00ff);
69 *adr->adr_now++ = (char)(*sp & 0x00ff);
74 * adr_ushort - pull out ushorts
76 void
77 adr_ushort(adr_t *adr, ushort_t *sp, int count)
80 for (; count-- > 0; sp++) {
81 *adr->adr_now++ = (char)((*sp >> 8) & 0x00ff);
82 *adr->adr_now++ = (char)(*sp & 0x00ff);
87 * adr_int32 - pull out uint32
89 #pragma weak adr_long = adr_int32
90 void
91 adr_long(adr_t *adr, int32_t *lp, int count);
92 void
93 adr_int32(adr_t *adr, int32_t *lp, int count)
95 int i; /* index for counting */
96 uint32_t l; /* value for shifting */
98 for (; count-- > 0; lp++) {
99 for (i = 0, l = *(uint32_t *)lp; i < 4; i++) {
100 *adr->adr_now++ =
101 (char)((uint32_t)(l & 0xff000000) >> 24);
102 l <<= 8;
108 * adr_uid
111 void
112 adr_uid(adr_t *adr, uid_t *up, int count)
114 int i; /* index for counting */
115 uid_t l; /* value for shifting */
117 for (; count-- > 0; up++) {
118 for (i = 0, l = *(uint32_t *)up; i < 4; i++) {
119 *adr->adr_now++ =
120 (char)((uint32_t)(l & 0xff000000) >> 24);
121 l <<= 8;
127 * adr_int64 - pull out uint64_t
129 void
130 adr_int64(adr_t *adr, int64_t *lp, int count)
132 int i; /* index for counting */
133 uint64_t l; /* value for shifting */
135 for (; count-- > 0; lp++) {
136 for (i = 0, l = *(uint64_t *)lp; i < 8; i++) {
137 *adr->adr_now++ = (char)
138 ((uint64_t)(l & 0xff00000000000000ULL) >> 56);
139 l <<= 8;