16cd6a6acSopenharmony_ci#ifndef _SEPOL_USERS_H_
26cd6a6acSopenharmony_ci#define _SEPOL_USERS_H_
36cd6a6acSopenharmony_ci
46cd6a6acSopenharmony_ci#include <sepol/policydb.h>
56cd6a6acSopenharmony_ci#include <sepol/user_record.h>
66cd6a6acSopenharmony_ci#include <sepol/handle.h>
76cd6a6acSopenharmony_ci#include <stddef.h>
86cd6a6acSopenharmony_ci
96cd6a6acSopenharmony_ci#ifdef __cplusplus
106cd6a6acSopenharmony_ciextern "C" {
116cd6a6acSopenharmony_ci#endif
126cd6a6acSopenharmony_ci
136cd6a6acSopenharmony_ci/* Modify the user, or add it, if the key is not found */
146cd6a6acSopenharmony_ciextern int sepol_user_modify(sepol_handle_t * handle,
156cd6a6acSopenharmony_ci			     sepol_policydb_t * policydb,
166cd6a6acSopenharmony_ci			     const sepol_user_key_t * key,
176cd6a6acSopenharmony_ci			     const sepol_user_t * data);
186cd6a6acSopenharmony_ci
196cd6a6acSopenharmony_ci/* Return the number of users */
206cd6a6acSopenharmony_ciextern int sepol_user_count(sepol_handle_t * handle,
216cd6a6acSopenharmony_ci			    const sepol_policydb_t * p, unsigned int *response);
226cd6a6acSopenharmony_ci
236cd6a6acSopenharmony_ci/* Check if the specified user exists */
246cd6a6acSopenharmony_ciextern int sepol_user_exists(sepol_handle_t * handle,
256cd6a6acSopenharmony_ci			     const sepol_policydb_t * policydb,
266cd6a6acSopenharmony_ci			     const sepol_user_key_t * key, int *response);
276cd6a6acSopenharmony_ci
286cd6a6acSopenharmony_ci/* Query a user - returns the user or NULL if not found */
296cd6a6acSopenharmony_ciextern int sepol_user_query(sepol_handle_t * handle,
306cd6a6acSopenharmony_ci			    const sepol_policydb_t * p,
316cd6a6acSopenharmony_ci			    const sepol_user_key_t * key,
326cd6a6acSopenharmony_ci			    sepol_user_t ** response);
336cd6a6acSopenharmony_ci
346cd6a6acSopenharmony_ci/* Iterate the users
356cd6a6acSopenharmony_ci * The handler may return:
366cd6a6acSopenharmony_ci * -1 to signal an error condition,
376cd6a6acSopenharmony_ci * 1 to signal successful exit
386cd6a6acSopenharmony_ci * 0 to signal continue */
396cd6a6acSopenharmony_ciextern int sepol_user_iterate(sepol_handle_t * handle,
406cd6a6acSopenharmony_ci			      const sepol_policydb_t * policydb,
416cd6a6acSopenharmony_ci			      int (*fn) (const sepol_user_t * user,
426cd6a6acSopenharmony_ci					 void *fn_arg), void *arg);
436cd6a6acSopenharmony_ci
446cd6a6acSopenharmony_ci#ifdef __cplusplus
456cd6a6acSopenharmony_ci}
466cd6a6acSopenharmony_ci#endif
476cd6a6acSopenharmony_ci
486cd6a6acSopenharmony_ci#endif
49