Open SCAP Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Data Fields
ds_sds_session Struct Reference

Public Member Functions

struct ds_sds_sessionds_sds_session_new_from_source (struct oscap_source *source)
 Create new ds_sds_session from existing oscap_source. More...
 
struct ds_sds_indexds_sds_session_get_sds_idx (struct ds_sds_session *session)
 Get Source DataStream index. More...
 
struct oscap_sourceds_sds_session_select_checklist (struct ds_sds_session *session, const char *datastream_id, const char *component_id, const char *benchmark_id)
 Select Checklist (XCCDF presumably) from DataStream collection. More...
 
struct oscap_sourceds_sds_session_select_tailoring (struct ds_sds_session *session, const char *component_id)
 Select XCCDF Tailoring from DataStream collection. More...
 
int ds_sds_session_set_datastream_id (struct ds_sds_session *session, const char *datastream_id)
 Set the ID of DataStream within collection to use. More...
 
const char * ds_sds_session_get_datastream_id (const struct ds_sds_session *session)
 Return ID of currently selected DataStream within the DataStream collection. More...
 
const char * ds_sds_session_get_checklist_id (const struct ds_sds_session *session)
 Return ID of currently selected component representing XCCDF within the DataStream. More...
 
struct oscap_sourceds_sds_session_get_component_by_href (struct ds_sds_session *session, const char *href)
 Get component from Source DataStream by its href. More...
 
int ds_sds_session_register_component_with_dependencies (struct ds_sds_session *session, const char *container_name, const char *component_id, const char *target_filename)
 Register component and its dependencies to internal cache. More...
 
int ds_sds_session_dump_component_files (struct ds_sds_session *session)
 Store cached component files to the disc. More...
 
int ds_sds_session_set_target_dir (struct ds_sds_session *session, const char *target_dir)
 Set target directory for the component files. More...
 
void ds_sds_session_reset (struct ds_sds_session *session)
 Reset session for further use. More...
 
void ds_sds_session_set_remote_resources (struct ds_sds_session *session, bool allowed, download_progress_calllback_t callback)
 Set property of remote content. More...
 
char * ds_sds_session_get_html_guide (struct ds_sds_session *session, const char *profile_id)
 Returns HTML representation of selected checklist in form of OpenSCAP guide. More...
 

Data Fields

struct oscap_sourcesource
 Source DataStream raw representation.
 
struct ds_sds_indexindex
 Source DataStream index.
 
char * temp_dir
 Temp directory managed by the session.
 
const char * target_dir
 Target directory for current split.
 
const char * datastream_id
 ID of selected datastream.
 
const char * checklist_id
 ID of selected checklist.
 
struct oscap_htablecomponent_sources
 oscap_source for parsed components
 
bool fetch_remote_resources
 Allows loading of external components;.
 
download_progress_calllback_t progress
 Callback to report progress of download.
 

Member Function Documentation

int ds_sds_session_dump_component_files ( struct ds_sds_session session)

Store cached component files to the disc.

Parameters
sessionThe Source DataStream session
Returns
0 on success
const char * ds_sds_session_get_checklist_id ( const struct ds_sds_session session)

Return ID of currently selected component representing XCCDF within the DataStream.

Parameters
sessionThe Source DataStream session
Returns
ID of selected component or NULL
struct oscap_source * ds_sds_session_get_component_by_href ( struct ds_sds_session session,
const char *  href 
)

Get component from Source DataStream by its href.

This assumes that the component has been already cached by the session. You can cache component or its dependencies by calling ds_sds_session_select_checklist or ds_sds_session_register_component_with_dependencies. Returned oscap_source is owned by ds_sds_session.

Parameters
sessionThe Source DataStream session
hrefThe href of the component. The href refers to either file name from the catalogue element or the target name provided previously by caller of upper mentioned functions.
Returns
oscap_source representing the component or NULL
const char * ds_sds_session_get_datastream_id ( const struct ds_sds_session session)

Return ID of currently selected DataStream within the DataStream collection.

Parameters
sessionThe Source DataStream sesssion
Returns
ID of selected datastream or NULL
char * ds_sds_session_get_html_guide ( struct ds_sds_session session,
const char *  profile_id 
)

Returns HTML representation of selected checklist in form of OpenSCAP guide.

Parameters
sessionThe Source DataStream session to generate guide from
profile_idID of XCCDF profile within selected checklist to generate guide for
Returns
a buffer of HTML content that should be freed by the caller
struct ds_sds_index * ds_sds_session_get_sds_idx ( struct ds_sds_session session)

Get Source DataStream index.

Parameters
sessionRegistry to query SDS index from
Returns
source DataStream owned by session
struct ds_sds_session * ds_sds_session_new_from_source ( struct oscap_source source)

Create new ds_sds_session from existing oscap_source.

This assumes that the given oscap_source represents source DataStream. This function does not own the oscap_source, but it needs it for operation.

Parameters
sourceThe oscap_source representing a source datastream
Returns
newly created ds_sds_session structure
int ds_sds_session_register_component_with_dependencies ( struct ds_sds_session session,
const char *  container_name,
const char *  component_id,
const char *  target_filename 
)

Register component and its dependencies to internal cache.

This functions extracts component from selected datastream within collection and all it dependencies. The components may be later queried by ds_sds_session_get_component_by_href.

Parameters
sessionThe Source DataStream session
container_nameThe name of container like: "checks", "checklists", or "dictionaries".
component_idId of component within selected datastream or NULL
targetfilename or NULL
Returns
0 on success
void ds_sds_session_reset ( struct ds_sds_session session)

Reset session for further use.

Rationale: The ds_sds_session is not versatile structure that would allow to work with all the DataStream content at once. The ds_sds_session structure remembers certain selections like: selected datastream within collection, selected checklist, and cached catalogue files. If caller wants to open different checklist with different catalogue, they need to reset the session.

Parameters
sessionThe Source DataStream session to reset
struct oscap_source * ds_sds_session_select_checklist ( struct ds_sds_session session,
const char *  datastream_id,
const char *  component_id,
const char *  benchmark_id 
)

Select Checklist (XCCDF presumably) from DataStream collection.

Parameters may be skipped (passing NULL) to let the ds_sds_session guess them.

Parameters
sessionSource DataStream session to choose from
datastream_idID of DataStream within collection
component_idID of (XCCDF) checklist within datastream
benchmark_idID of Benchmark element within checklist
Returns
XCCDF checklist in form of oscap_source
struct oscap_source * ds_sds_session_select_tailoring ( struct ds_sds_session session,
const char *  component_id 
)

Select XCCDF Tailoring from DataStream collection.

The ds_sds_session_select_checklist needs to be called first. To determine what datastream should be used within collection.

Parameters
sessionSource DataStream session to choose from
component_idID of tailoring file within checklist container
Returns
XCCdF tailoring in form of oscap_source
int ds_sds_session_set_datastream_id ( struct ds_sds_session session,
const char *  datastream_id 
)

Set the ID of DataStream within collection to use.

Note that ds_sds_session_select_checklist may set this automatically.

Parameters
sessionSource DataStream session
datastream_idDataStream ID to set
Returns
0 on success
void ds_sds_session_set_remote_resources ( struct ds_sds_session session,
bool  allowed,
download_progress_calllback_t  callback 
)

Set property of remote content.

Parameters
sessionThe Source DataStream Session
allowedWhether is download of remote resources allowed in this session (defaults to false)
callbackused to notify user about download proceeds. This might be safely set to NULL – ignoring user notification.
int ds_sds_session_set_target_dir ( struct ds_sds_session session,
const char *  target_dir 
)

Set target directory for the component files.

Parameters
sessionThe Source DataStream session
target_dirPath to the target storage dir
Returns
0 on success

The documentation for this struct was generated from the following files: