catch.h

00001 /*
00002  * Copyright (C) 2014- The University of Notre Dame
00003  * This software is distributed under the GNU General Public License.
00004  * See the file COPYING for details.
00005  */
00006 
00007 #ifndef CATCH_H
00008 #define CATCH_H
00009 
00010 #include <errno.h>
00011 #include <string.h>
00012 
00013 #define THROW_QUIET(e) \
00014         do {\
00015                 rc = (e);\
00016                 goto out;\
00017         } while (0)
00018 
00019 #define CATCH(expr) \
00020         do {\
00021                 rc = (expr);\
00022                 if (rc) {\
00023                         debug(D_DEBUG, "%s: %s:%d[%s] error: %d `%s'", __func__, __FILE__, __LINE__, CCTOOLS_SOURCE, rc, strerror(rc));\
00024                         goto out;\
00025                 }\
00026         } while (0)
00027 
00028 #define CATCHUNIX(expr) \
00029         do {\
00030                 rc = (expr);\
00031                 if (rc == -1) {\
00032                         rc = errno;\
00033                         debug(D_DEBUG, "%s: %s:%d[%s] unix error: -1 (errno = %d) `%s'", __func__, __FILE__, __LINE__, CCTOOLS_SOURCE, rc, strerror(rc));\
00034                         goto out;\
00035                 }\
00036         } while (0)
00037 
00038 #define CATCHUNIXIGNORE(expr,err) \
00039         do {\
00040                 rc = (expr);\
00041                 if (rc == -1 && errno != err) {\
00042                         rc = errno;\
00043                         debug(D_DEBUG, "%s: %s:%d[%s] unix error: -1 (errno = %d) `%s'", __func__, __FILE__, __LINE__, CCTOOLS_SOURCE, rc, strerror(rc));\
00044                         goto out;\
00045                 }\
00046         } while (0)
00047 
00048 #define RCUNIX(rc) (rc == 0 ? 0 : (errno = rc, -1))
00049 
00050 #endif
00051 
00052 /* vim: set noexpandtab tabstop=4: */

Generated on 14 Apr 2016 for cctools by  doxygen 1.4.7