Jason Tang jtang@tresys.com
Randy Wicks rwicks@tresys.com
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Definition in file bool_diff.h.
#include <apol/vector.h>
#include <poldiff/poldiff.h>
Go to the source code of this file.
Typedefs | |
| typedef poldiff_bool | poldiff_bool_t |
Functions | |
| void | poldiff_bool_get_stats (const poldiff_t *diff, size_t stats[5]) |
| Get an array of statistics for the number of differences of each form for bools. | |
| const apol_vector_t * | poldiff_get_bool_vector (const poldiff_t *diff) |
| Get the vector of bool differences from the boolean difference summary. | |
| char * | poldiff_bool_to_string (const poldiff_t *diff, const void *boolean) |
| Obtain a newly allocated string representation of a difference in a bool. | |
| size_t | poldiff_get_num_added_bools (const poldiff_t *diff) |
| Get the number of added bools from a policy difference structure. | |
| size_t | poldiff_get_num_removed_bools (const poldiff_t *diff) |
| Get the number of removed bools from a policy difference structure. | |
| size_t | poldiff_get_num_modified_bools (const poldiff_t *diff) |
| Get the number of modified bools from a policy difference structure. | |
| const char * | poldiff_bool_get_name (const poldiff_bool_t *boolean) |
| Get the name of the bool from a bool diff. | |
| poldiff_form_e | poldiff_bool_get_form (const void *boolean) |
| Get the form of difference from a bool diff. | |
|
|
Definition at line 37 of file bool_diff.h. Referenced by bool_deep_diff(), bool_free(), bool_new_diff(), make_diff(), poldiff_bool_get_form(), poldiff_bool_get_name(), and poldiff_bool_to_string(). |
|
||||||||||||
|
Get an array of statistics for the number of differences of each form for bools.
Definition at line 52 of file bool_diff.c. References poldiff::bool_diffs, diff, ERR, poldiff_bool_summary::num_added, poldiff_bool_summary::num_modified, poldiff_bool_summary::num_removed, and poldiff_t. 00053 {
00054 if (diff == NULL || stats == NULL) {
00055 ERR(diff, "%s", strerror(EINVAL));
00056 errno = EINVAL;
00057 return;
00058 }
00059 stats[0] = diff->bool_diffs->num_added;
00060 stats[1] = diff->bool_diffs->num_removed;
00061 stats[2] = diff->bool_diffs->num_modified;
00062 stats[3] = 0;
00063 stats[4] = 0;
00064 }
|
|
|
Get the vector of bool differences from the boolean difference summary.
Definition at line 110 of file bool_diff.c. References apol_vector_t, poldiff::bool_diffs, diff, poldiff_bool_summary::diffs, and poldiff_t. Referenced by components_bools_tests(). 00111 {
00112 if (diff == NULL) {
00113 errno = EINVAL;
00114 return NULL;
00115 }
00116 return diff->bool_diffs->diffs;
00117 }
|
|
||||||||||||
|
Obtain a newly allocated string representation of a difference in a bool.
Definition at line 66 of file bool_diff.c. References apol_str_appendf(), diff, ERR, poldiff_bool::form, poldiff_bool::name, poldiff_bool_t, POLDIFF_FORM_ADDED, POLDIFF_FORM_MODIFIED, POLDIFF_FORM_REMOVED, poldiff_t, and poldiff_bool::state. 00067 {
00068 poldiff_bool_t *b = (poldiff_bool_t *) boolean;
00069 size_t len = 0;
00070 char *s = NULL;
00071 if (diff == NULL || boolean == NULL) {
00072 ERR(diff, "%s", strerror(EINVAL));
00073 errno = EINVAL;
00074 return NULL;
00075 }
00076 switch (b->form) {
00077 case POLDIFF_FORM_ADDED:
00078 {
00079 if (apol_str_appendf(&s, &len, "+ %s", b->name) < 0) {
00080 break;
00081 }
00082 return s;
00083 }
00084 case POLDIFF_FORM_REMOVED:
00085 {
00086 if (apol_str_appendf(&s, &len, "- %s", b->name) < 0) {
00087 break;
00088 }
00089 return s;
00090 }
00091 case POLDIFF_FORM_MODIFIED:
00092 {
00093 if (apol_str_appendf
00094 (&s, &len, "* %s (changed from %s)", b->name, (b->state ? "false to true" : "true to false")) < 0) {
00095 break;
00096 }
00097 return s;
00098 }
00099 default:
00100 {
00101 ERR(diff, "%s", strerror(ENOTSUP));
00102 errno = ENOTSUP;
00103 return NULL;
00104 }
00105 }
00106 errno = ENOMEM;
00107 return NULL;
00108 }
|
|
|
Get the number of added bools from a policy difference structure.
|
|
|
Get the number of removed bools from a policy difference structure.
|
|
|
Get the number of modified bools from a policy difference structure.
|
|
|
Get the name of the bool from a bool diff.
Definition at line 119 of file bool_diff.c. References poldiff_bool_t. 00120 {
00121 if (boolean == NULL) {
00122 errno = EINVAL;
00123 return NULL;
00124 }
00125 return boolean->name;
00126 }
|
|
|
Get the form of difference from a bool diff.
Definition at line 128 of file bool_diff.c. References poldiff_bool_t, and poldiff_form_e. Referenced by components_bools_tests(). 00129 {
00130 if (boolean == NULL) {
00131 errno = EINVAL;
00132 return 0;
00133 }
00134 return ((const poldiff_bool_t *)boolean)->form;
00135 }
|