| 1 | /* |
| 2 | * Copyright 2014 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Author: |
| 20 | * Šimon Lukašík |
| 21 | */ |
| 22 | #ifndef DS_RDS_SESSION_H |
| 23 | #define DS_RDS_SESSION_H |
| 24 | |
| 25 | #ifdef HAVE_CONFIG_H |
| 26 | #include <config.h> |
| 27 | #endif |
| 28 | |
| 29 | #include "oscap.h" |
| 30 | #include "oscap_source.h" |
| 31 | #include "scap_ds.h" |
| 32 | #include "oscap_export.h" |
| 33 | |
| 34 | /** |
| 35 | * The ds_rds_session is structure tight closely to oscap_source. |
| 36 | * |
| 37 | * The ds_rds_session represents opened DataStream collection file. |
| 38 | * It caches certain data to facilitate common queries and use cases |
| 39 | * of DataStream consumers. |
| 40 | */ |
| 41 | struct ds_rds_session; |
| 42 | |
| 43 | /** |
| 44 | * Create new ds_rds_session from existing oscap_source. This assumes that |
| 45 | * the given oscap_source represents result DataStream (ARF). This function |
| 46 | * does not own the oscap_source, but it needs it for operation. |
| 47 | * @memberof ds_rds_session |
| 48 | * @param source The oscap_source representing a result datastream |
| 49 | * @returns newly created ds_rds_session structure |
| 50 | */ |
| 51 | OSCAP_API struct ds_rds_session *ds_rds_session_new_from_source(struct oscap_source *source); |
| 52 | |
| 53 | /** |
| 54 | * Dispose ds_rds_session structure. |
| 55 | * @memberof ds_rds_session |
| 56 | * @param rds_session The session to dispose |
| 57 | */ |
| 58 | OSCAP_API void ds_rds_session_free(struct ds_rds_session *rds_session); |
| 59 | |
| 60 | /** |
| 61 | * Get Result DataStream index |
| 62 | * @memberof ds_rds_session |
| 63 | * @param session Session to query RDS index from |
| 64 | * @returns Result DataStream index owned by session |
| 65 | */ |
| 66 | OSCAP_API struct rds_index *ds_rds_session_get_rds_idx(struct ds_rds_session *session); |
| 67 | |
| 68 | /** |
| 69 | * Set target directory for the component files |
| 70 | * @memberof ds_rds_session |
| 71 | * @param session The Result DataStream session |
| 72 | * @param target_dir PAth to the target storage dir |
| 73 | * @returns 0 on success |
| 74 | */ |
| 75 | OSCAP_API int ds_rds_session_set_target_dir(struct ds_rds_session *session, const char *target_dir); |
| 76 | |
| 77 | /** |
| 78 | * Store cached component files to the hard drive |
| 79 | * @memberof ds_rds_session |
| 80 | * @param session The Result DataStream session |
| 81 | * @returns zero on success |
| 82 | */ |
| 83 | OSCAP_API int ds_rds_session_dump_component_files(struct ds_rds_session *session); |
| 84 | |
| 85 | /** |
| 86 | * Select arf:report from result DataStream and return it in form of oscap_source. |
| 87 | * @memberof ds_rds_session |
| 88 | * @param session The Result DataStream session |
| 89 | * @param report_id The ID of arf:report. Session will find the first, if this argument is NULL. |
| 90 | * this arguement is NULL. |
| 91 | * @returns oscap_source owned by the ds_rds_session or NULL on error |
| 92 | */ |
| 93 | OSCAP_API struct oscap_source *ds_rds_session_select_report(struct ds_rds_session *session, const char *report_id); |
| 94 | |
| 95 | /** |
| 96 | * Select arf:report-request from result DataStream and return it in form of oscap_source. |
| 97 | * @memberof ds_rds_session |
| 98 | * @param session The Result DataStream session |
| 99 | * @param report_request_id The id of arf:report-request. Session will find the report_request |
| 100 | * related (see arf:relationship) to the last selected report. If there was no report selected |
| 101 | * session will error out. |
| 102 | * @returns oscap_source owned by the ds_rds_session or NULL on error |
| 103 | */ |
| 104 | OSCAP_API struct oscap_source *ds_rds_session_select_report_request(struct ds_rds_session *session, const char *report_request_id); |
| 105 | |
| 106 | /** |
| 107 | * Replace currently selected report with the content of the source. The previously |
| 108 | * returned oscap_source assiciated with the selected report will be disposed. |
| 109 | * The source will become owned by the session. |
| 110 | * @memberof ds_rds_session |
| 111 | * @param session The Result DataStream session |
| 112 | * @param source The oscap_source to replase selected report with. |
| 113 | * @returns 0 on success |
| 114 | */ |
| 115 | OSCAP_API int ds_rds_session_replace_report_with_source(struct ds_rds_session *session, struct oscap_source *source); |
| 116 | |
| 117 | /** |
| 118 | * Returns HTML representation of the given result datastream |
| 119 | * @memberof ds_rds_session |
| 120 | * @param rds_session The ds_rds_session to build HTML from |
| 121 | * @returns a buffer of HTML content that should be freed by the caller |
| 122 | */ |
| 123 | |
| 124 | #endif |