17f7ad59d7e0d9b2d41fdae4b33c3e0968cb27e5
[mmh] / sbr / m_backup.c
1 /*
2 ** m_backup.c -- construct a backup file
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11
12 char *
13 m_backup(char *file)
14 {
15         char *cp;
16         static char buffer[BUFSIZ];
17
18         if ((cp = r1bindex(file, '/')) == file)
19                 snprintf(buffer, sizeof(buffer), "%s%s", backup_prefix, cp);
20         else
21                 snprintf(buffer, sizeof(buffer), "%.*s%s%s", (int)(cp - file),
22                         file, backup_prefix, cp);
23
24         unlink(buffer);
25         return buffer;
26 }