Annotation of embedaddon/rsync/ifuncs.h, revision 1.1
1.1 ! misho 1: /* Inline functions for rsync.
! 2: *
! 3: * Copyright (C) 2007-2008 Wayne Davison
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify
! 6: * it under the terms of the GNU General Public License as published by
! 7: * the Free Software Foundation; either version 3 of the License, or
! 8: * (at your option) any later version.
! 9: *
! 10: * This program is distributed in the hope that it will be useful,
! 11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
! 12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 13: * GNU General Public License for more details.
! 14: *
! 15: * You should have received a copy of the GNU General Public License along
! 16: * with this program; if not, visit the http://fsf.org website.
! 17: */
! 18:
! 19: static inline void
! 20: alloc_xbuf(xbuf *xb, size_t sz)
! 21: {
! 22: if (!(xb->buf = new_array(char, sz)))
! 23: out_of_memory("alloc_xbuf");
! 24: xb->size = sz;
! 25: xb->len = xb->pos = 0;
! 26: }
! 27:
! 28: static inline void
! 29: realloc_xbuf(xbuf *xb, size_t sz)
! 30: {
! 31: char *bf = realloc_array(xb->buf, char, sz);
! 32: if (!bf)
! 33: out_of_memory("realloc_xbuf");
! 34: xb->buf = bf;
! 35: xb->size = sz;
! 36: }
! 37:
! 38: static inline int
! 39: to_wire_mode(mode_t mode)
! 40: {
! 41: #ifdef SUPPORT_LINKS
! 42: #if _S_IFLNK != 0120000
! 43: if (S_ISLNK(mode))
! 44: return (mode & ~(_S_IFMT)) | 0120000;
! 45: #endif
! 46: #endif
! 47: return mode;
! 48: }
! 49:
! 50: static inline mode_t
! 51: from_wire_mode(int mode)
! 52: {
! 53: #if _S_IFLNK != 0120000
! 54: if ((mode & (_S_IFMT)) == 0120000)
! 55: return (mode & ~(_S_IFMT)) | _S_IFLNK;
! 56: #endif
! 57: return mode;
! 58: }
! 59:
! 60: static inline char *
! 61: d_name(struct dirent *di)
! 62: {
! 63: #ifdef HAVE_BROKEN_READDIR
! 64: return (di->d_name - 2);
! 65: #else
! 66: return di->d_name;
! 67: #endif
! 68: }
! 69:
! 70: static inline int
! 71: isDigit(const char *ptr)
! 72: {
! 73: return isdigit(*(unsigned char *)ptr);
! 74: }
! 75:
! 76: static inline int
! 77: isPrint(const char *ptr)
! 78: {
! 79: return isprint(*(unsigned char *)ptr);
! 80: }
! 81:
! 82: static inline int
! 83: isSpace(const char *ptr)
! 84: {
! 85: return isspace(*(unsigned char *)ptr);
! 86: }
! 87:
! 88: static inline int
! 89: isLower(const char *ptr)
! 90: {
! 91: return islower(*(unsigned char *)ptr);
! 92: }
! 93:
! 94: static inline int
! 95: isUpper(const char *ptr)
! 96: {
! 97: return isupper(*(unsigned char *)ptr);
! 98: }
! 99:
! 100: static inline int
! 101: toLower(const char *ptr)
! 102: {
! 103: return tolower(*(unsigned char *)ptr);
! 104: }
! 105:
! 106: static inline int
! 107: toUpper(const char *ptr)
! 108: {
! 109: return toupper(*(unsigned char *)ptr);
! 110: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>