Annotation of embedaddon/rsync/ifuncs.h, revision 1.1.1.3

1.1       misho       1: /* Inline functions for rsync.
                      2:  *
1.1.1.3 ! misho       3:  * Copyright (C) 2007-2015 Wayne Davison
1.1       misho       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: 
1.1.1.2   misho      38: static inline void
                     39: free_xbuf(xbuf *xb)
                     40: {
                     41:        if (xb->buf)
                     42:                free(xb->buf);
                     43:        memset(xb, 0, sizeof (xbuf));
                     44: }
                     45: 
1.1       misho      46: static inline int
                     47: to_wire_mode(mode_t mode)
                     48: {
                     49: #ifdef SUPPORT_LINKS
                     50: #if _S_IFLNK != 0120000
                     51:        if (S_ISLNK(mode))
                     52:                return (mode & ~(_S_IFMT)) | 0120000;
                     53: #endif
                     54: #endif
                     55:        return mode;
                     56: }
                     57: 
                     58: static inline mode_t
                     59: from_wire_mode(int mode)
                     60: {
                     61: #if _S_IFLNK != 0120000
                     62:        if ((mode & (_S_IFMT)) == 0120000)
                     63:                return (mode & ~(_S_IFMT)) | _S_IFLNK;
                     64: #endif
                     65:        return mode;
                     66: }
                     67: 
                     68: static inline char *
                     69: d_name(struct dirent *di)
                     70: {
                     71: #ifdef HAVE_BROKEN_READDIR
                     72:        return (di->d_name - 2);
                     73: #else
                     74:        return di->d_name;
                     75: #endif
                     76: }
                     77: 
1.1.1.2   misho      78: static inline void
                     79: init_stat_x(stat_x *sx_p)
1.1       misho      80: {
1.1.1.2   misho      81: #ifdef SUPPORT_ACLS
                     82:        sx_p->acc_acl = sx_p->def_acl = NULL;
1.1.1.3 ! misho      83:        sx_p->nfs4_acl = NULL;
1.1.1.2   misho      84: #endif
                     85: #ifdef SUPPORT_XATTRS
                     86:        sx_p->xattr = NULL;
                     87: #endif
1.1       misho      88: }
                     89: 
1.1.1.2   misho      90: static inline void
                     91: free_stat_x(stat_x *sx_p)
1.1       misho      92: {
1.1.1.2   misho      93: #ifdef SUPPORT_ACLS
                     94:     {
                     95:        extern int preserve_acls;
                     96:        if (preserve_acls)
                     97:                free_acl(sx_p);
                     98:     }
                     99: #endif
                    100: #ifdef SUPPORT_XATTRS
                    101:     {
                    102:        extern int preserve_xattrs;
                    103:        if (preserve_xattrs)
                    104:                free_xattr(sx_p);
                    105:     }
                    106: #endif
1.1       misho     107: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>