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]
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 #include <sys/types.h>
30 #include <bsm/audit.h>
31 #include <bsm/libbsm.h>
32 #include <bsm/audit_record.h>
36 * adr_struct.now is used to calculate the record length so
37 * end of record will be recognized.
42 adrf_start(adrf_t
*adrf
, adr_t
*adr
, FILE *fp
)
46 adrf
->adrf_adr
->adr_now
= NULL
;
50 * adrf_char - pull out characters
53 adrf_char(adrf_t
*adrf
, char *cp
, int count
)
55 int c
; /* read character in here */
60 if ((c
= fgetc(adrf
->adrf_fp
)) == EOF
)
63 adrf
->adrf_adr
->adr_now
+= sizeof (char);
69 * adrf_short - pull out shorts
72 adrf_short(adrf_t
*adrf
, short *sp
, int count
)
74 int c
; /* read character in here */
79 if ((c
= fgetc(adrf
->adrf_fp
)) == EOF
)
82 if ((c
= fgetc(adrf
->adrf_fp
)) == EOF
)
85 adrf
->adrf_adr
->adr_now
+= sizeof (short);
91 * adrf_int32 - pull out int32
93 int adrf_int(adrf_t
*adrf
, int32_t *lp
, int count
);
94 int adrf_long(adrf_t
*adrf
, int32_t *lp
, int count
);
96 #pragma weak adrf_int = adrf_int32
97 #pragma weak adrf_long = adrf_int32
100 adrf_int32(adrf_t
*adrf
, int32_t *lp
, int count
)
103 int c
; /* read character in here */
107 for (; count
--; lp
++) {
109 for (i
= 0; i
< 4; i
++) {
110 if ((c
= fgetc(adrf
->adrf_fp
)) == EOF
)
113 *lp
|= c
& 0x000000ff;
115 adrf
->adrf_adr
->adr_now
+= sizeof (int32_t);
121 adrf_int64(adrf_t
*adrf
, int64_t *lp
, int count
)
124 int c
; /* read character in here */
128 for (; count
--; lp
++) {
130 for (i
= 0; i
< 8; i
++) {
131 if ((c
= fgetc(adrf
->adrf_fp
)) == EOF
)
134 *lp
|= c
& 0x00000000000000ff;
136 adrf
->adrf_adr
->adr_now
+= sizeof (int64_t);
141 int adrf_u_int(adrf_t
*adrf
, uint32_t *cp
, int count
);
142 int adrf_u_long(adrf_t
*adrf
, uint32_t *cp
, int count
);
144 #pragma weak adrf_u_int = adrf_u_int32
145 #pragma weak adrf_u_long = adrf_u_int32
148 adrf_u_int32(adrf_t
*adrf
, uint32_t *cp
, int count
)
150 return (adrf_int32(adrf
, (int32_t *)cp
, count
));
154 adrf_u_char(adrf_t
*adrf
, uchar_t
*cp
, int count
)
156 return (adrf_char(adrf
, (char *)cp
, count
));
160 adrf_u_int64(adrf_t
*adrf
, uint64_t *lp
, int count
)
162 return (adrf_int64(adrf
, (int64_t *)lp
, count
));
166 adrf_u_short(adrf_t
*adrf
, ushort_t
*sp
, int count
)
168 return (adrf_short(adrf
, (short *)sp
, count
));
172 adrf_peek(adrf_t
*adrf
)
174 return (ungetc(fgetc(adrf
->adrf_fp
), adrf
->adrf_fp
));