Moving inline functions into its own .h file.
[rsync/rsync.git] / ifuncs.h
CommitLineData
5dafe360
WD
1/* Inline functions. */
2
3static inline void
4alloc_xbuf(xbuf *xb, size_t sz)
5{
6 if (!(xb->buf = new_array(char, sz)))
7 out_of_memory("alloc_xbuf");
8 xb->size = sz;
9 xb->len = xb->pos = 0;
10}
11
12static inline void
13realloc_xbuf(xbuf *xb, size_t sz)
14{
15 char *bf = realloc_array(xb->buf, char, sz);
16 if (!bf)
17 out_of_memory("realloc_xbuf");
18 xb->buf = bf;
19 xb->size = sz;
20}
21
22static inline int
23to_wire_mode(mode_t mode)
24{
25#ifdef SUPPORT_LINKS
26#if _S_IFLNK != 0120000
27 if (S_ISLNK(mode))
28 return (mode & ~(_S_IFMT)) | 0120000;
29#endif
30#endif
31 return mode;
32}
33
34static inline mode_t
35from_wire_mode(int mode)
36{
37#if _S_IFLNK != 0120000
38 if ((mode & (_S_IFMT)) == 0120000)
39 return (mode & ~(_S_IFMT)) | _S_IFLNK;
40#endif
41 return mode;
42}
43
44static inline int
45isDigit(const char *ptr)
46{
47 return isdigit(*(unsigned char *)ptr);
48}
49
50static inline int
51isPrint(const char *ptr)
52{
53 return isprint(*(unsigned char *)ptr);
54}
55
56static inline int
57isSpace(const char *ptr)
58{
59 return isspace(*(unsigned char *)ptr);
60}
61
62static inline int
63isLower(const char *ptr)
64{
65 return islower(*(unsigned char *)ptr);
66}
67
68static inline int
69isUpper(const char *ptr)
70{
71 return isupper(*(unsigned char *)ptr);
72}
73
74static inline int
75toLower(const char *ptr)
76{
77 return tolower(*(unsigned char *)ptr);
78}
79
80static inline int
81toUpper(const char *ptr)
82{
83 return toupper(*(unsigned char *)ptr);
84}