]> diplodocus.org Git - nmh/blob - sbr/m_backup.c
sendsbr.c: Move interface to own file.
[nmh] / sbr / m_backup.c
1 /* m_backup.c -- construct a backup file
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include "h/mh.h"
9 #include "r1bindex.h"
10 #include "m_backup.h"
11 #include "m_mktemp.h"
12
13
14 char *
15 m_backup (const char *file)
16 {
17 const char *cp;
18 static char buffer[BUFSIZ];
19
20 if ((cp = r1bindex((char *) file, '/')) == file)
21 snprintf(buffer, sizeof(buffer), "%s%s",
22 BACKUP_PREFIX, cp);
23 else
24 snprintf(buffer, sizeof(buffer), "%.*s%s%s", (int)(cp - file), file,
25 BACKUP_PREFIX, cp);
26
27 (void) m_unlink(buffer);
28 return buffer;
29 }