summaryrefslogtreecommitdiffstats
path: root/libpoldiff/include/poldiff/type_map.h
blob: 56eb742230e07321f81af96bd73dec3cb38b000c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
 *  @file
 *  Public interface for type equivalence mapping for semantic
 *  difference calculations.
 *
 *  @author Jeremy A. Mowery jmowery@tresys.com
 *  @author Jason Tang jtang@tresys.com
 *
 *  Copyright (C) 2006-2007 Tresys Technology, LLC
 *
 *  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
 */

#ifndef POLDIFF_TYPE_MAP_H
#define POLDIFF_TYPE_MAP_H

#ifdef	__cplusplus
extern "C"
{
#endif

#include <poldiff/poldiff.h>
#include <apol/vector.h>

	typedef struct poldiff_type_remap_entry poldiff_type_remap_entry_t;

/**
 *  Note that a type(s) from the original policy should be remapped in
 *  the modified policy.  Subsequent diffs will treat type(s) in
 *  orig_names to be equivalent to type(s) in mod_names.  The created
 *  remap entry will be marked as enabled.
 *
 *  It is an error for the size of both vectors to be greater than
 *  one.
 *
 *  Note that you may only remap primary types, not attributes nor
 *  aliases.
 *
 *  @param diff The difference structure associated with the types.
 *  Note that renaming a type will reset the status of previously run
 *  difference calculations and they will need to be rerun.
 *  @param orig_names A vector of type names (char *) in the original
 *  policy.
 *  @param mod_name A vector of type names (char *) in the modified
 *  policy to consider equivalent.
 *
 *  @return 0 on success or < 0 on error; if the call fails, errno
 *  will be set and the poldiff object remains unchanged.
 */
	extern int poldiff_type_remap_create(poldiff_t * diff, const apol_vector_t * orig_names, const apol_vector_t * mod_names);

/**
 *  Get a vector of all identified type remap entries.  The caller may
 *  then manipulate this list by selectively enabling/disabling
 *  individual entries.
 *
 *  @param diff The difference structure associated with the types
 *  remaps.
 *
 *  @return Vector of poldiff_type_remap_entry_t objects.  The caller
 *  should not destroy this vector.
 */
	extern apol_vector_t *poldiff_type_remap_get_entries(const poldiff_t * diff);

/**
 *  Remove a poldiff_type_remap_entry object.  This function will
 *  destroy the entry object afterwards.
 *
 *  @param diff The difference structure associated with the types
 *  remaps.
 *  @param entry Type remap entry to remove and destroy.
 */
	extern void poldiff_type_remap_entry_remove(poldiff_t * diff, poldiff_type_remap_entry_t * entry);

/**
 *  Allocate and return a sorted vector of type names (char *)
 *  corresponding to the original types within a
 *  poldiff_type_remap_entry_t object.  The strings themselves are to
 *  be considered immutable; if the caller needs them for future use
 *  it should duplicate them.
 *
 *  @param diff Difference structure, for error reporting.
 *  @param entry Remap entry from which to get type names.
 *
 *  @return Vector of type names.  The caller is responsible for
 *  calling apol_vector_destroy() afterwards.  Upon error return NULL
 *  and set errno.
 */
	extern apol_vector_t *poldiff_type_remap_entry_get_original_types(const poldiff_t * diff,
									  const poldiff_type_remap_entry_t * entry);

/**
 *  Allocate and return a sorted vector of type names (char *)
 *  corresponding to the modified types within a
 *  poldiff_type_remap_entry_t object.  The strings themselves are to
 *  be considered immutable; if the caller needs them for future use
 *  it should duplicate them.
 *
 *  @param diff Difference structure, for error reporting.
 *  @param entry Remap entry from which to get type names.
 *
 *  @return Vector of type names.  The caller is responsible for
 *  calling apol_vector_destroy() afterwards.  Upon error return NULL
 *  and set errno.
 */
	extern apol_vector_t *poldiff_type_remap_entry_get_modified_types(const poldiff_t * diff,
									  const poldiff_type_remap_entry_t * entry);

/**
 *  Given a poldiff_type_remap_entry_t object, determine if was
 *  an inferred mapping or not.
 *
 *  @param entry Remap entry from which to get its inference status.
 *
 *  @return 1 if it was inferred, 0 if not, < 0 on error.
 */
	extern int poldiff_type_remap_entry_get_is_inferred(const poldiff_type_remap_entry_t * entry);

/**
 *  Given a poldiff_type_remap_entry_t object, determine if it is
 *  enabled or not.
 *
 *  @param entry Remap entry from which to get its enabled status.
 *
 *  @return 1 if it is enabled, 0 if not, < 0 on error.
 */
	extern int poldiff_type_remap_entry_get_is_enabled(const poldiff_type_remap_entry_t * entry);

/**
 *  Enable or disable a poldiff_type_remap_entry_t object.
 *
 *  @param entry Remap entry from which to set its enabled status.
 *  @param enabled 0 to disable this entry, non-zero to enable it.
 */
	extern void poldiff_type_remap_entry_set_enabled(poldiff_type_remap_entry_t * entry, int enabled);

#ifdef	__cplusplus
}
#endif

#endif				       /* POLDIFF_TYPE_MAP_H */