opr: Add UUID handling functions
[openafs.git] / src / opr / opr.h
1 #ifndef OPENAFS_OPR_OPR_H
2 #define OPENAFS_OPR_OPR_H 1
3
4 /* macros */
5
6 /* should use offsetof() if available */
7 #define opr_containerof(ptr, structure, member) \
8    ((structure *)((char *)(ptr)-(char *)(&((structure *)NULL)->member)))
9
10 /* assert.c */
11
12 #ifdef AFS_NT40_ENV
13 # define opr_abort() opr_NTAbort()
14 extern void opr_NTAbort(void);
15 #else
16 # define opr_abort() abort()
17 #endif
18
19 extern void opr_AssertionFailed(char *, int) AFS_NORETURN;
20 extern void opr_AssertFailU(const char *, const char *, int) AFS_NORETURN;
21
22 #define opr_Assert(ex) \
23     do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
24
25 /* casestrcpy.c */
26 #define lcstring opr_lcstring
27 #define ucstring opr_ucstring
28 #define stolower opr_stolower
29 #define stoupper opr_stoupper
30 /* XXX str* is in the implementation namespace when <string.h> is included */
31 #define strcompose opr_strcompose
32
33 extern char *opr_lcstring(char *d, const char *s, int n) AFS_NONNULL((1,2));
34 extern char *opr_ucstring(char *d, const char *s, int n) AFS_NONNULL((1,2));
35 extern void opr_stolower(char *s) AFS_NONNULL(());
36 extern void opr_stoupper(char *s) AFS_NONNULL(());
37 extern char *opr_strcompose(char *buf, size_t len, ...) AFS_NONNULL((1));
38
39 #endif