/*
 *  Copyright (C)  2000-2001 Marc Wandschneider <mw@kiltdown.org>
 *
 *  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.
 *
 *  For more information look at the file COPYRIGHT in this package
 *
 */
#ifndef _LERROR_H_

/**
 *    This file contains error codes that we will use throughout our 
 * application and system.  The macros 
 *
 * FAILED(code)
 * and
 * SUCCEEDED(code)
 *
 * should be used as much as possible.  Basically, all error codes have
 * their high bit set while success codes do not.  There can be many different
 * success codes, for those cases where you wish to sound a warning or some
 * such thing.
 *
 * This is loosely based on my recollection of the OLE/COM error system, which
 * I haven't had the horror of using in a couple of years.
 */
typedef unsigned int ERRCODE;


/**
 *=------------------------------------------------------------------------=
 *  These routines are used to display actual messages and information 
 * related to errors triggered in the program.
 *=------------------------------------------------------------------------=
 */
void lerrorInit();
void lerrorTerm();

/**
 * Shows a dialog indicating that an error has occurred!!!
 */
void errorShowError(ERRCODE);

/**
 * Sets up rich error information that will be added to error messages. This
 * rich error information is encoded in the localized strings as printf 
 * command sequences or whatever the heck you want to call them.  Thus, you 
 * could have:
 *
 * E_FILE_ERR       ID_E_FILE_ERR:  "There was a file error: %s"
 *
 *      errorSaveRichErrorInfo(strerror(errno))
 *      errorShowError(E_FILE_ERR);
 */
void errorSaveRichErrorInfo(const char *str1, const char *str2 = 0, 
                            const char *str3 = 0, const char *str4 = 0,
                            const char *str5 = 0);


/**
 * Given an error message and the rich error set up for it, return the
 * full string with the rich error information substituted in ...
 */
void errorConstructFullErrorString(ERRCODE, const char * &);


/**
 *=------------------------------------------------------------------------=
 *                              Error Macros
 *=------------------------------------------------------------------------=
 */

/**
 * Indicates whether the given error code is a failure code or not.  evaluates
 * to a boolean.
 */
#define FAILED(code) \
    (((code) & 0x80000000) != 0)

/**
 * Indicates whether the given error code is a success code or not. Evaluates
 * to a boolean.
 */
#define SUCCEEDED(code) \
    (((code) & 0x80000000) == 0)

/**
 * These are a couple of little helper routines that you may or may not
 * find useful.
 */
#define RETURN_ON_FAILURE(code) if (FAILED((code))) return (code);
#define GOTO_ON_FAILURE(code, label) if (FAILED((code))) goto label;



/**
 * The following is a table of error codes and a quick description of what
 * they're used for.
 */
#define EC_FAILURE 0x80000000


//
//
//=-----------------------------------------------------------------------=
// SUCCESS CODES
//
//

/**
 * Used to indicate everything is fine.
 */
#define S_OK                                                    0

/**
 * Executed fine, but something didn't happen that might
 * be interesting.
 */
#define S_FALSE                                                 1

/**
 * It's OK, but there's nothing left.
 */
#define S_EOF                                                   2

/**
 * It's OK, but the element wasn't found.   
 */
#define S_NOTFOUND                                              3

/**
 * It's OK, but something happened worth taking note of.  Private protocol to
 * determine what that was must be established.
 */
#define S_WARNING                                               4

/**
 * Everything ran fine, but there was no data.
 */
#define S_NODATA                                                5

/**
 * Everything ran fine, but we had to create something.
 */
#define S_CREATED                                               6


//
//
//=-----------------------------------------------------------------------=
// FAILURE CODES
//=-----------------------------------------------------------------------=
//
//
#include <errortable.h>

#define _LERROR_H_
#endif // _LERROR_H_




syntax highlighted by Code2HTML, v. 0.9.1