X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Finternal.h;fp=lib%2Finternal.h;h=b9cc57c8f26da8073c4b37de6a53167be06cbfb3;hb=53126578ee08c0bd3b3987959fb7d768deb5aedc;hp=2213d7bec809c09d3ebf853a3256dfaa2d12ff55;hpb=f4ef980b13bde6e00fa918e35fd834a9fe824d0e;p=wrappi.git diff --git a/lib/internal.h b/lib/internal.h index 2213d7b..b9cc57c 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -19,8 +19,52 @@ #ifndef WRAPPI_INTERNAL_H_ #define WRAPPI_INTERNAL_H_ +#include +#include + +#define STREQ(a,b) (strcmp((a),(b)) == 0) +#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) +#define STRNEQ(a,b) (strcmp((a),(b)) != 0) +#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0) +#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0) +#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0) +#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0) +#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0) +#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0) + +struct wrap_internal_h { + char *error; /* Last error on this handle, NULL is none. */ + int errnum; /* errno, or 0 if there was no errno set. */ + const char *error_func; /* Function where the error occurred, if known. */ +}; + struct wrap_h { - int error_flag; + /* The "internal" part of the handle must always appear at the + * beginning of the handle structure. For the remote case, this + * contains a cut-down handle which is what non-local entry points + * are permitted to touch. For the local case, the full handle is + * cast to (struct wrap_internal_h *). + */ + struct wrap_internal_h internal; + + /* Fields that follow the 'internal' structure only exist + * on the local side of a connection. + */ + + /* Connection URL. If scheme = NULL, it means we're using the local + * code. + */ + const char *scheme; + const char *hostname; }; +/* Declare an error, setting the error field in the handle. */ +#define set_error(fs...) \ + wrap_int_set_error ((struct wrap_internal_h *)w, __func__, fs) +#define set_error_errno(fs...) \ + wrap_int_set_error_errno ((struct wrap_internal_h *)w, (errno), __func__, fs) + +extern void wrap_int_set_error (struct wrap_internal_h *w, const char *func, const char *fs, ...); +extern void wrap_int_set_error_errno (struct wrap_internal_h *w, int errnum, const char *func, const char *fs, ...); + #endif /* WRAPPI_INTERNAL_H_ */