praudit.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* File name: praudit.h
* praudit.c defines, globals
*/
#ifndef _PRAUDIT_H
#define _PRAUDIT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* DEFINES */
/*
* output value types
*/
#define PRA_INT32 0
#define PRA_UINT32 1
#define PRA_INT64 2
#define PRA_UINT64 3
#define PRA_SHORT 4
#define PRA_USHORT 5
#define PRA_CHAR 6
#define PRA_UCHAR 7
#define PRA_STRING 8
#define PRA_HEX32 9
#define PRA_HEX64 10
#define PRA_SHEX 11
#define PRA_OCT 12
#define PRA_BYTE 13
#define PRA_OUTREC 14
#define PRA_LOCT 15
/*
* Formatting flags
*/
/*
* source of audit data (data_mode)
*/
#define FILEMODE 1
#define PIPEMODE 2
#define BUFMODE 3
/*
* max. number of audit file names entered on command line
*/
#define MAXFILENAMES 100
/*
* max. size of file name
*/
/*
* used to store value to be output
*/
typedef union u_tag {
short short_val;
char char_val;
char uchar_val;
char *string_val;
} u_tag_t;
typedef struct u_val {
int uvaltype;
} uval_t;
/*
* Strings and things for xml prolog & ending printing.
*/
#define prolog1 "<?xml version='1.0' encoding='UTF-8' ?>\n"
#define prolog2 "\n<!DOCTYPE audit PUBLIC " \
"'-//Sun Microsystems, Inc.//DTD Audit V1//EN' " \
#define prolog_xsl "<?xml-stylesheet type='text/xsl' " \
/* Special main element: */
#define xml_start "<audit>"
#define xml_ending "\n</audit>\n"
/*
* used to save context for print_audit and related functions.
*/
#define SEP_SIZE 4
struct pr_context {
int format;
int data_mode;
signed char tokenid; /* initial token ID */
int audit_rec_len;
char *audit_rec_start;
char *inbuf_start;
char *inbuf_last; /* ptr to byte after latest completed */
/* header or file token in the input */
int inbuf_totalsize;
char *outbuf_p;
char *outbuf_start;
char *outbuf_last; /* ptr to byte after latest completed */
/* header or file token in the output */
int outbuf_remain_len;
int pending_flag; /* open of extended tag not completed */
int current_rec; /* id of current record */
};
typedef struct pr_context pr_context_t;
extern void init_tokens(void);
extern int is_file_token(int);
extern int is_header_token(int);
extern int is_token(int);
extern char *bu2string(char basic_unit);
extern int convert_char_to_string(char printmode, char c, char *p);
extern int convert_short_to_string(char printmode, short c, char *p);
extern char *htp2string(char print_sugg);
/*
* Functions that format audit data
*/
extern int print_audit(const int, const char *);
extern int print_audit_buf(char **, int *, char **, int *, const int,
const char *);
extern void print_audit_xml_prolog(void);
extern void print_audit_xml_ending(void);
extern int print_audit_xml_prolog_buf(char *out_buf,
const int out_buf_len);
extern int print_audit_xml_ending_buf(char *out_buf,
const int out_buf_len);
#ifdef __cplusplus
}
#endif
#endif /* _PRAUDIT_H */