Blame library/adutil.h

Packit 8586cb
/*
Packit 8586cb
 * adcli
Packit 8586cb
 *
Packit 8586cb
 * Copyright (C) 2012 Red Hat Inc.
Packit 8586cb
 *
Packit 8586cb
 * This program is free software; you can redistribute it and/or modify
Packit 8586cb
 * it under the terms of the GNU Lesser General Public License as
Packit 8586cb
 * published by the Free Software Foundation; either version 2.1 of
Packit 8586cb
 * the License, or (at your option) any later version.
Packit 8586cb
 *
Packit 8586cb
 * This program is distributed in the hope that it will be useful, but
Packit 8586cb
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8586cb
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 8586cb
 * Lesser General Public License for more details.
Packit 8586cb
 *
Packit 8586cb
 * You should have received a copy of the GNU Lesser General Public
Packit 8586cb
 * License along with this program; if not, write to the Free Software
Packit 8586cb
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
Packit 8586cb
 * MA 02110-1301 USA
Packit 8586cb
 *
Packit 8586cb
 * Author: Stef Walter <stefw@gnome.org>
Packit 8586cb
 */
Packit 8586cb
Packit 8586cb
#ifndef ADUTIL_H_
Packit 8586cb
#define ADUTIL_H_
Packit 8586cb
Packit 8586cb
#include <stdlib.h>
Packit 8586cb
#include <stdbool.h>
Packit 8586cb
Packit 8586cb
typedef enum {
Packit 8586cb
	/* Successful completion */
Packit 8586cb
	ADCLI_SUCCESS = 0,
Packit 8586cb
Packit 8586cb
	/*
Packit 8586cb
	 * Invalid input or unexpected system behavior.
Packit 8586cb
	 *
Packit 8586cb
	 * This is almost always caused by a bug, or completely broken
Packit 8586cb
	 * system configuration or state. This is returned when memory
Packit 8586cb
	 * allocation fails, but the process will almost certainly have
Packit 8586cb
	 * been killed first.
Packit 8586cb
	 *
Packit 8586cb
	 * This is returned for invalid inputs (such an unexpected
Packit 8586cb
	 * NULL) to adcli.
Packit 8586cb
	 */
Packit 8586cb
	ADCLI_ERR_UNEXPECTED = -2,
Packit 8586cb
Packit 8586cb
	/*
Packit 8586cb
	 * A general failure, that doesn't fit into the other categories.
Packit 8586cb
	 * Not much the caller can do.
Packit 8586cb
	 */
Packit 8586cb
	ADCLI_ERR_FAIL = -3,
Packit 8586cb
Packit 8586cb
	/*
Packit 8586cb
	 * A problem with the active directory or connecting to it.
Packit 8586cb
	 */
Packit 8586cb
	ADCLI_ERR_DIRECTORY = -4,
Packit 8586cb
Packit 8586cb
	/*
Packit 8586cb
	 * A logic problem with the configuration of the local system, or
Packit 8586cb
	 * the settings passed into adcli.
Packit 8586cb
	 */
Packit 8586cb
	ADCLI_ERR_CONFIG = -5,
Packit 8586cb
Packit 8586cb
	/*
Packit 8586cb
	 * Invalid credentials.
Packit 8586cb
	 *
Packit 8586cb
	 * The credentials are invalid, or don't have the necessary
Packit 8586cb
	 * access rights.
Packit 8586cb
	 */
Packit 8586cb
	ADCLI_ERR_CREDENTIALS = -6,
Packit 8586cb
} adcli_result;
Packit 8586cb
Packit 8586cb
typedef enum {
Packit 8586cb
	ADCLI_MESSAGE_INFO,
Packit 8586cb
	ADCLI_MESSAGE_WARNING,
Packit 8586cb
	ADCLI_MESSAGE_ERROR
Packit 8586cb
} adcli_message_type;
Packit 8586cb
Packit 8586cb
const char *      adcli_result_to_string        (adcli_result res);
Packit 8586cb
Packit 8586cb
int               adcli_mem_clear               (void *data,
Packit 8586cb
                                                 size_t length);
Packit 8586cb
Packit 8586cb
Packit 8586cb
typedef void      (* adcli_message_func)        (adcli_message_type type,
Packit 8586cb
                                                 const char *message);
Packit 8586cb
Packit 8586cb
void              adcli_set_message_func        (adcli_message_func message_func);
Packit 8586cb
Packit 8586cb
void              adcli_clear_last_error        (void);
Packit 8586cb
Packit 8586cb
const char *      adcli_get_last_error          (void);
Packit 8586cb
Packit 8586cb
#endif /* ADUTIL_H_ */