2 * Copyright (C) 2011-2012 Red Hat Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef WRAPPI_INTERNAL_H_
20 #define WRAPPI_INTERNAL_H_
25 #define STREQ(a,b) (strcmp((a),(b)) == 0)
26 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
27 #define STRNEQ(a,b) (strcmp((a),(b)) != 0)
28 #define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
29 #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
30 #define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
31 #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
32 #define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
33 #define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
35 struct wrap_internal_h {
36 char *error; /* Last error on this handle, NULL is none. */
37 int errnum; /* errno, or 0 if there was no errno set. */
38 const char *error_func; /* Function where the error occurred, if known. */
42 /* The "internal" part of the handle must always appear at the
43 * beginning of the handle structure. For the remote case, this
44 * contains a cut-down handle which is what non-local entry points
45 * are permitted to touch. For the local case, the full handle is
46 * cast to (struct wrap_internal_h *).
48 struct wrap_internal_h internal;
50 /* Fields that follow the 'internal' structure only exist
51 * on the local side of a connection.
54 /* Connection URL. If scheme = NULL, it means we're using the local
61 /* Declare an error, setting the error field in the handle. */
62 #define set_error(fs...) \
63 wrap_int_set_error ((struct wrap_internal_h *)w, __func__, fs)
64 #define set_error_errno(fs...) \
65 wrap_int_set_error_errno ((struct wrap_internal_h *)w, (errno), __func__, fs)
67 extern void wrap_int_set_error (struct wrap_internal_h *w, const char *func, const char *fs, ...);
68 extern void wrap_int_set_error_errno (struct wrap_internal_h *w, int errnum, const char *func, const char *fs, ...);
70 #endif /* WRAPPI_INTERNAL_H_ */