1 /* Inline functions for rsync.
3 * Copyright (C) 2007-2020 Wayne Davison
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.
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.
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.
20 alloc_xbuf(xbuf
*xb
, size_t sz
)
22 xb
->buf
= new_array(char, sz
);
24 xb
->len
= xb
->pos
= 0;
28 realloc_xbuf(xbuf
*xb
, size_t sz
)
30 char *bf
= realloc_array(xb
->buf
, char, sz
);
40 memset(xb
, 0, sizeof (xbuf
));
44 to_wire_mode(mode_t mode
)
47 #if _S_IFLNK != 0120000
49 return (mode
& ~(_S_IFMT
)) | 0120000;
56 from_wire_mode(int mode
)
58 #if _S_IFLNK != 0120000
59 if ((mode
& (_S_IFMT
)) == 0120000)
60 return (mode
& ~(_S_IFMT
)) | _S_IFLNK
;
66 d_name(struct dirent
*di
)
68 #ifdef HAVE_BROKEN_READDIR
69 return (di
->d_name
- 2);
76 init_stat_x(stat_x
*sx_p
)
79 sx_p
->acc_acl
= sx_p
->def_acl
= NULL
;
87 free_stat_x(stat_x
*sx_p
)
91 extern int preserve_acls
;
98 extern int preserve_xattrs
;
105 static inline char *my_strdup(const char *str
, const char *file
, int line
)
107 int len
= strlen(str
)+1;
108 char *buf
= my_alloc(do_malloc
, len
, 1, file
, line
);
109 memcpy(buf
, str
, len
);