diff --git a/include/crm/error.h b/include/crm/error.h index 2e8d6f5db5..af9fb9fd1c 100644 --- a/include/crm/error.h +++ b/include/crm/error.h @@ -1,55 +1,58 @@ -/* +/* * Copyright (C) 2012 Andrew Beekhof - * + * * 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 software 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRM_ERROR__H # define CRM_ERROR__H # include # include /** * \file * \brief Error codes and asserts * \ingroup core */ /* System error codes - /usr/include/asm-generic/errno.h - /usr/include/asm-generic/errno-base.h */ # define CRM_ASSERT(expr) do { \ if(__unlikely((expr) == FALSE)) { \ crm_abort(__FILE__, __PRETTY_FUNCTION__, __LINE__, #expr, TRUE, FALSE); \ } \ } while(0) # define pcmk_ok 0 -# define PCMK_ERROR_OFFSET 900 /* Replacements on non-linux systems, see include/portability.h */ -# define PCMK_CUSTOM_OFFSET 1000 /* Purely custom codes */ -# define pcmk_err_generic 1001 -# define pcmk_err_no_quorum 1002 -# define pcmk_err_dtd_validation 1003 -# define pcmk_err_transform_failed 1004 -# define pcmk_err_old_data 1005 -# define pcmk_err_diff_failed 1006 -# define pcmk_err_diff_resync 1007 +# define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */ +# define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */ +# define pcmk_err_generic 201 +# define pcmk_err_no_quorum 202 +# define pcmk_err_dtd_validation 203 +# define pcmk_err_transform_failed 204 +# define pcmk_err_old_data 205 +# define pcmk_err_diff_failed 206 +# define pcmk_err_diff_resync 207 +# define pcmk_err_cib_modified 208 +# define pcmk_err_cib_backup 209 +# define pcmk_err_cib_save 210 const char *pcmk_strerror(int rc); const char *bz2_strerror(int rc); #endif diff --git a/include/portability.h b/include/portability.h index 681ddeb477..0487a69829 100644 --- a/include/portability.h +++ b/include/portability.h @@ -1,217 +1,217 @@ #ifndef PORTABILITY_H # define PORTABILITY_H /* * Copyright (C) 2001 Alan Robertson * This software licensed under the GNU LGPL. * * * 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 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 */ # define EOS '\0' # define DIMOF(a) ((int) (sizeof(a)/sizeof(a[0])) ) /* Needs to be defined before any other includes, otherwise some system * headers do not behave as expected! Major black magic... */ # undef _GNU_SOURCE /* in case it was defined on the command line */ # define _GNU_SOURCE /* Please leave this as the first #include - Solaris needs it there */ # ifdef HAVE_CONFIG_H # include # endif /* Prototypes for libreplace functions */ # ifndef HAVE_DAEMON /* We supply a replacement function, but need a prototype */ int daemon(int nochdir, int noclose); # endif /* HAVE_DAEMON */ # ifndef HAVE_SETENV /* We supply a replacement function, but need a prototype */ int setenv(const char *name, const char *value, int why); # endif /* HAVE_SETENV */ # ifndef HAVE_STRERROR /* We supply a replacement function, but need a prototype */ char *strerror(int errnum); # endif /* HAVE_STRERROR */ # ifndef HAVE_STRCHRNUL /* We supply a replacement function, but need a prototype */ char *strchrnul(const char *s, int c_in); # endif /* HAVE_STRCHRNUL */ # ifndef HAVE_ALPHASORT # include int alphasort(const void *dirent1, const void *dirent2); # endif /* HAVE_ALPHASORT */ # ifndef HAVE_STRNLEN size_t strnlen(const char *s, size_t maxlen); # else # define USE_GNU # endif # ifndef HAVE_STRNDUP char *strndup(const char *str, size_t len); # else # define USE_GNU # endif # if NEED_G_HASH_ITER # include typedef struct fake_ghi { GHashTable *hash; int nth; /* current index over the iteration */ int lpc; /* internal loop counter inside g_hash_table_find */ gpointer key; gpointer value; } GHashTableIter; static inline void g_hash_prepend_value(gpointer key, gpointer value, gpointer user_data) { GList **values = (GList **) user_data; *values = g_list_prepend(*values, value); } /* Since: 2.14 */ static inline GList * g_hash_table_get_values(GHashTable * hash_table) { GList *values = NULL; g_hash_table_foreach(hash_table, g_hash_prepend_value, &values); return values; } static inline gboolean g_hash_table_nth_data(gpointer key, gpointer value, gpointer user_data) { GHashTableIter *iter = (GHashTableIter *) user_data; if (iter->lpc++ == iter->nth) { iter->key = key; iter->value = value; return TRUE; } return FALSE; } /* Since: 2.16 */ static inline void g_hash_table_iter_init(GHashTableIter * iter, GHashTable * hash_table) { iter->hash = hash_table; iter->nth = 0; iter->lpc = 0; iter->key = NULL; iter->value = NULL; } static inline gboolean g_hash_table_iter_next(GHashTableIter * iter, gpointer * key, gpointer * value) { gboolean found = FALSE; iter->lpc = 0; iter->key = NULL; iter->value = NULL; if (iter->nth < g_hash_table_size(iter->hash)) { found = ! !g_hash_table_find(iter->hash, g_hash_table_nth_data, iter); iter->nth++; } if (key) *key = iter->key; if (value) *value = iter->value; return found; } /* Since: 2.16 */ static inline void g_hash_table_iter_remove(GHashTableIter * iter) { g_hash_table_remove(iter->hash, iter->key); iter->nth--; /* Or zero to be safe? */ } /* Since: 2.16 */ static inline int g_strcmp0(const char *str1, const char *str2) { if (!str1) return -(str1 != str2); if (!str2) return str1 != str2; return strcmp(str1, str2); } # endif /* !HAVE_LIBGLIB_2_0 */ # ifdef NEED_G_LIST_FREE_FULL # include # include /* Since: 2.28 */ static inline void g_list_free_full(GList * list, GDestroyNotify free_func) { g_list_foreach(list, (GFunc) free_func, NULL); g_list_free(list); } # endif /* Replacement error codes for non-linux */ # ifndef ENOTUNIQ -# define ENOTUNIQ 900 +# define ENOTUNIQ 190 # endif # ifndef ECOMM -# define ECOMM 901 +# define ECOMM 191 # endif # ifndef ELIBACC -# define ELIBACC 902 +# define ELIBACC 192 # endif # ifndef EREMOTEIO -# define EREMOTEIO 903 +# define EREMOTEIO 193 # endif # ifndef EUNATCH -# define EUNATCH 904 +# define EUNATCH 194 # endif # ifndef ENOKEY -# define ENOKEY 905 +# define ENOKEY 195 # endif /* * Some compilers (eg. Sun studio) do not define __FUNCTION__ */ # ifdef __SUNPRO_C # define __FUNCTION__ __func__ # endif # ifdef __MY_UNKNOWN_C # define __FUNCTION__ "__FUNCTION__" # endif #endif /* PORTABILITY_H */