Postfix3.3.1
総合概要
データ構造
ファイル
ファイル一覧
大域各種
postfix-3.3.1
src
global
remove.c
[詳解]
1
/*++
2
/* NAME
3
/* REMOVE 3
4
/* SUMMARY
5
/* remove or stash away file
6
/* SYNOPSIS
7
/* \fBint REMOVE(path)\fR
8
/* \fBconst char *path;\fR
9
/* DESCRIPTION
10
/* \fBREMOVE()\fR removes a file, or renames it to a unique name,
11
/* depending on the setting of the boolean \fBvar_dont_remove\fR
12
/* flag.
13
/* DIAGNOSTICS
14
/* The result is 0 in case of success, -1 in case of trouble.
15
/* The global \fBerrno\fR variable reflects the nature of the
16
/* problem.
17
/* FILES
18
/* saved/*, stashed-away files.
19
/* SEE ALSO
20
/* remove(3)
21
/* LICENSE
22
/* .ad
23
/* .fi
24
/* The Secure Mailer license must be distributed with this software.
25
/* AUTHOR(S)
26
/* Wietse Venema
27
/* IBM T.J. Watson Research
28
/* P.O. Box 704
29
/* Yorktown Heights, NY 10598, USA
30
/*--*/
31
32
/* System library. */
33
34
#include <
sys_defs.h
>
35
#include <sys/stat.h>
36
#include <stdio.h>
37
#include <string.h>
38
#include <stdlib.h>
39
#include <unistd.h>
40
#include <
warn_stat.h
>
41
42
/* Utility library. */
43
44
#include <
vstring.h
>
45
46
/* Global library. */
47
48
#include <
mail_params.h
>
49
50
/* REMOVE - squirrel away a file instead of removing it */
51
52
int
REMOVE
(
const
char
*path)
53
{
54
static
VSTRING
*dest;
55
char
*slash;
56
struct
stat
st;
57
58
if
(
var_dont_remove
== 0) {
59
return
(
remove
(path));
60
}
else
{
61
if
(dest == 0)
62
dest =
vstring_alloc
(10);
63
vstring_sprintf
(dest,
"saved/%s"
, ((slash = strrchr(path,
'/'
)) != 0) ?
64
slash + 1 : path);
65
for
(;;) {
66
if
(
stat
(
vstring_str
(dest), &st) < 0)
67
break
;
68
vstring_strcat
(dest,
"+"
);
69
}
70
return
(rename(path,
vstring_str
(dest)));
71
}
72
}
vstring_str
#define vstring_str(vp)
Definition:
vstring.h:71
REMOVE
int REMOVE(const char *path)
Definition:
remove.c:52
stat
#define stat(p, s)
Definition:
warn_stat.h:18
var_dont_remove
int var_dont_remove
Definition:
mail_params.c:257
vstring_alloc
VSTRING * vstring_alloc(ssize_t len)
Definition:
vstring.c:353
VSTRING
Definition:
vstring.h:29
warn_stat.h
vstring.h
vstring_sprintf
VSTRING * vstring_sprintf(VSTRING *vp, const char *format,...)
Definition:
vstring.c:602
sys_defs.h
mail_params.h
vstring_strcat
VSTRING * vstring_strcat(VSTRING *vp, const char *src)
Definition:
vstring.c:459
2018年11月10日(土) 18時59分39秒作成 - Postfix3.3.1 / 構成:
1.8.9.1