libxdas_api_read.c

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002  * Copyright (c) 2006, Novell, Inc.
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions are 
00007  * met:
00008  * 
00009  *     * Redistributions of source code must retain the above copyright 
00010  *       notice, this list of conditions and the following disclaimer.
00011  *     * Redistributions in binary form must reproduce the above copyright 
00012  *       notice, this list of conditions and the following disclaimer in the 
00013  *       documentation and/or other materials provided with the distribution.
00014  *     * Neither the name of the Novell nor the names of its contributors 
00015  *       may be used to endorse or promote products derived from this 
00016  *       software without specific prior written permission.
00017  * 
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00020  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00021  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
00022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00025  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
00026  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *--------------------------------------------------------------------------*/
00030 
00039 #include <xdas.h>
00040 #include <xdas_debug.h>
00041 
00042 #include "libxdas_impl.h"
00043 
00044 #include <malloc.h>
00045 #include <string.h>
00046 
00047 /*---------------------------------------------------------------------------
00048  */
00049 XDASXPC int XDASAPI xdas_close_audit_stream(
00050       int * minor_status,
00051       xdas_audit_ref_t das_ref,
00052       xdas_audit_stream_t * audit_stream_ref)
00053 {
00054    xdas_session * xs;
00055    xdas_stream * xt;
00056    int bit_bucket;
00057 
00058    /* check parameters */
00059    if (!minor_status)
00060       minor_status = &bit_bucket;
00061    *minor_status = 0;
00062 
00063    xdas_assert(das_ref != 0);
00064    if (das_ref == 0)
00065       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00066 
00067    xs = xdas_validate_session(das_ref);
00068    xdas_assert(xs != 0);
00069    if (xs == 0)
00070       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00071 
00072    if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_READ))
00073       return XDAS_S_AUTHORIZATION_FAILURE;
00074 
00075    xdas_assert(audit_stream_ref != 0 && *audit_stream_ref != 0);
00076    if (audit_stream_ref == 0 || *audit_stream_ref == 0)
00077       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_AUDIT_STREAM;
00078 
00079    xt = xdas_validate_stream(*audit_stream_ref);
00080    xdas_assert(xt != 0);
00081    if (xt == 0)
00082       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_AUDIT_STREAM;
00083 
00084    xdas_internal_close_audit_stream(xt);
00085    *audit_stream_ref = 0;
00086    return XDAS_S_NOT_SUPPORTED;
00087 }
00088 
00089 /*---------------------------------------------------------------------------
00090  */
00091 XDASXPC int XDASAPI xdas_get_next(
00092       int * minor_status,
00093       xdas_audit_ref_t das_ref,
00094       xdas_audit_stream_t audit_stream_ref,
00095       unsigned max_records,
00096       xdas_buffer_t audit_record_buffer,
00097       unsigned * no_of_records)
00098 {
00099    xdas_session * xs;
00100    xdas_stream * xt;
00101    int bit_bucket;
00102 
00103    /* check parameters */
00104    if (!minor_status)
00105       minor_status = &bit_bucket;
00106    *minor_status = 0;
00107 
00108    xdas_assert(das_ref != 0);
00109    if (das_ref == 0)
00110       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00111 
00112    xs = xdas_validate_session(das_ref);
00113    xdas_assert(xs != 0);
00114    if (xs == 0)
00115       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00116 
00117    if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_READ))
00118       return XDAS_S_AUTHORIZATION_FAILURE;
00119 
00120    xdas_assert(audit_stream_ref != 0);
00121    if (audit_stream_ref == 0)
00122       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_AUDIT_STREAM;
00123 
00124    xt = xdas_validate_stream(audit_stream_ref);
00125    xdas_assert(xt != 0);
00126    if (xt == 0)
00127       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_AUDIT_STREAM;
00128 
00129    return xdas_internal_get_next(minor_status, xt, max_records, 
00130          audit_record_buffer, no_of_records);
00131 }
00132 
00133 /*---------------------------------------------------------------------------
00134  */
00135 XDASXPC int XDASAPI xdas_open_audit_stream(
00136       int * minor_status,
00137       xdas_audit_ref_t das_ref,
00138       xdas_audit_stream_t * audit_stream_ref)
00139 {
00140    xdas_session * xs;
00141    xdas_stream * xt;
00142    int rv, bit_bucket;
00143 
00144    /* check parameters */
00145    if (!minor_status)
00146       minor_status = &bit_bucket;
00147    *minor_status = 0;
00148 
00149    xdas_assert(das_ref != 0);
00150    if (das_ref == 0)
00151       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00152 
00153    xs = xdas_validate_session(das_ref);
00154    xdas_assert(xs != 0);
00155    if (xs == 0)
00156       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00157 
00158    if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_READ))
00159       return XDAS_S_AUTHORIZATION_FAILURE;
00160 
00161    xdas_assert(audit_stream_ref != 0);
00162    if (audit_stream_ref == 0)
00163       return XDAS_S_CALL_INACCESSIBLE_WRITE | XDAS_S_INVALID_AUDIT_STREAM;
00164 
00165    /* create a blank stream context structure */
00166    *audit_stream_ref = 0;
00167    if ((xt = (xdas_stream *)malloc(sizeof(*xt))) == 0)
00168       return (*minor_status = OXDAS_MS_OUT_OF_MEMORY), XDAS_S_FAILURE;
00169    memset(xt, 0, sizeof(*xt));
00170    xt->signature = XDAS_STREAM_SIG;
00171 
00172    if ((rv = xdas_internal_open_audit_stream(minor_status, 
00173          xs, xt)) != XDAS_S_COMPLETE)
00174       xdas_internal_close_audit_stream(xt);
00175    else
00176       *audit_stream_ref = (xdas_audit_stream_t)xt;
00177 
00178    return rv;
00179 }
00180 
00181 /*---------------------------------------------------------------------------
00182  */
00183 XDASXPC int XDASAPI xdas_parse_record(
00184       int * minor_status,
00185       xdas_audit_ref_t das_ref,
00186       xdas_buffer_t audit_record_buffer,
00187       unsigned record_number,
00188       xdas_audit_record_t audit_record)
00189 {
00190    xdas_session * xs;
00191    int bit_bucket;
00192 
00193    /* check parameters */
00194    if (!minor_status)
00195       minor_status = &bit_bucket;
00196    *minor_status = 0;
00197 
00198    xdas_assert(das_ref != 0);
00199    if (das_ref == 0)
00200       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00201 
00202    xs = xdas_validate_session(das_ref);
00203    xdas_assert(xs != 0);
00204    if (xs == 0)
00205       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00206 
00207    if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_READ))
00208       return XDAS_S_AUTHORIZATION_FAILURE;
00209 
00210    return xdas_internal_parse_record(minor_status, audit_record_buffer, 
00211          record_number, audit_record);
00212 }
00213 
00214 /*---------------------------------------------------------------------------
00215  */
00216 XDASXPC int XDASAPI xdas_rewind_audit_stream(
00217       int * minor_status,
00218       xdas_audit_ref_t das_ref,
00219       xdas_audit_stream_t audit_stream_ref)
00220 {
00221    xdas_session * xs;
00222    xdas_stream * xt;
00223    int bit_bucket;
00224 
00225    /* check parameters */
00226    if (!minor_status)
00227       minor_status = &bit_bucket;
00228    *minor_status = 0;
00229 
00230    xdas_assert(das_ref != 0);
00231    if (das_ref == 0)
00232       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_DAS_REF;
00233 
00234    xs = xdas_validate_session(das_ref);
00235    xdas_assert(xs != 0);
00236    if (xs == 0)
00237       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_DAS_REF;
00238 
00239    if (!xdas_session_has_rights(xs, XDAS_AUDIT_SERVICE | XDAS_AUDIT_READ))
00240       return XDAS_S_AUTHORIZATION_FAILURE;
00241 
00242    xdas_assert(audit_stream_ref != 0);
00243    if (audit_stream_ref == 0)
00244       return XDAS_S_CALL_INACCESSIBLE_READ | XDAS_S_INVALID_AUDIT_STREAM;
00245 
00246    xt = xdas_validate_stream(audit_stream_ref);
00247    xdas_assert(xt != 0);
00248    if (xt == 0)
00249       return XDAS_S_CALL_BAD_STRUCTURE | XDAS_S_INVALID_AUDIT_STREAM;
00250 
00251    return xdas_internal_rewind_audit_stream(minor_status, xt);
00252 }
00253 

Generated on Thu Aug 20 22:33:05 2009 for OpenXDAS by  doxygen 1.5.6