1 /* backupfile.h -- declarations for making Emacs style backup file names
2
3 Copyright (C) 1990-1992, 1997-1999, 2003-2004, 2009-2021 Free Software
4 Foundation, Inc.
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19 #ifndef BACKUPFILE_H_
20 #define BACKUPFILE_H_
21
22 /* Get AT_FDCWD, as a convenience for users of this file. */
23 #include <fcntl.h>
24
25 #include <stdlib.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31
32 /* When to make backup files. */
33 enum backup_type
34 {
35 /* Never make backups. */
36 no_backups,
37
38 /* Make simple backups of every file. */
39 simple_backups,
40
41 /* Make numbered backups of files that already have numbered backups,
42 and simple backups of the others. */
43 numbered_existing_backups,
44
45 /* Make numbered backups of every file. */
46 numbered_backups
47 };
48
49 #define VALID_BACKUP_TYPE(Type) \
50 ((unsigned int) (Type) <= numbered_backups)
51
52 extern char const *simple_backup_suffix;
53
54 void set_simple_backup_suffix (char const *);
55 char *backup_file_rename (int, char const *, enum backup_type)
56 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
57 char *find_backup_file_name (int, char const *, enum backup_type)
58 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
59 _GL_ATTRIBUTE_RETURNS_NONNULL;
60 enum backup_type get_version (char const *context, char const *arg);
61 enum backup_type xget_version (char const *context, char const *arg);
62
63
64 #ifdef __cplusplus
65 }
66 #endif
67
68 #endif /* ! BACKUPFILE_H_ */