#ifndef PA__ERROR_H
#define PA__ERROR_H

/*
 * PaVS - Pasky's Version System, advanced version control system
 * Copyright (C) 2003  Petr Baudis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef __cplusplus
extern "C" {
#endif


/* Here, we define the error codes as returned by individual command handlers.
 * Appropriate error message is emitted and we exit with the associated error
 * code. */

/* FYI: When modifying this enum, do not forget to appropriately modify also
 * the {pe_errmsgs} array in error.c ! */

enum pa_errcode {
	PENONE,		/* No error */
	PEARGMISSING,	/* Missing argument */
	PEARGINVAL,	/* Invalid argument */
	PEARGMANY,	/* Too many arguments */
	PENOMEM,	/* Out of memory */
	PENOENT,	/* File not found */
	PEPERM,		/* Permission denied */
	PESYS,		/* Misc. system/libc call failure */
	PEMISC,		/* Miscovery error */

	/* ---- the errors list end here */

	PE_MAX,

	/* & this enum with this mask to get the real error code. */
	PE_MASK = 0xff,

	/* ---- the |-able flags list end here */

	/* This flag will make the pa core not to emit the error message by
	 * itself. Thus, the errocode will be used only as the exit code.
	 * This is useful when you want to print the error message by yourself
	 * (ie. in some more detail, which is always encouraged). */
	PEF_SILENT = 0x100,
};


/* This function will convert {enum pa_errcode} to an appropriate string
 * message. It ignores the flag bits. */
/* Returns the string message pointer or NULL upon error. */
char *pa_errmsg (enum pa_errcode code);


#ifdef __cplusplus
}
#endif

#endif
