1 /* backupfile.h -- declarations for making Emacs style backup file names
2
3 Copyright (C) 1990-1992, 1997-1999, 2003-2004, 2009-2023 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 /* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_RETURNS_NONNULL. */
23 #if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25 #endif
26
27 /* Get AT_FDCWD, as a convenience for users of this file. */
28 #include <fcntl.h>
29
30 #include <stdlib.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 /* When to make backup files. */
38 enum backup_type
39 {
40 /* Never make backups. */
41 no_backups,
42
43 /* Make simple backups of every file. */
44 simple_backups,
45
46 /* Make numbered backups of files that already have numbered backups,
47 and simple backups of the others. */
48 numbered_existing_backups,
49
50 /* Make numbered backups of every file. */
51 numbered_backups
52 };
53
54 #define VALID_BACKUP_TYPE(Type) \
55 ((unsigned int) (Type) <= numbered_backups)
56
57 extern char const *simple_backup_suffix;
58
59 void set_simple_backup_suffix (char const *);
60 char *backup_file_rename (int, char const *, enum backup_type)
61 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
62 char *find_backup_file_name (int, char const *, enum backup_type)
63 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
64 _GL_ATTRIBUTE_RETURNS_NONNULL;
65 enum backup_type get_version (char const *context, char const *arg);
66 enum backup_type xget_version (char const *context, char const *arg);
67
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* ! BACKUPFILE_H_ */