From: Pierre Habouzit Date: Sun, 26 Nov 2006 16:38:21 +0000 (+0100) Subject: move more functions in file.c X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=8336b26fc23c7943bf6681ba2c290bb5cd2c54b8;p=apps%2Fmadmutt.git move more functions in file.c Signed-off-by: Pierre Habouzit --- diff --git a/headers.c b/headers.c index 8b69cc5..e9775d5 100644 --- a/headers.c +++ b/headers.c @@ -55,7 +55,7 @@ void mutt_edit_headers (const char *editor, return; } - mtime = mutt_decrease_mtime (path, &st); + mtime = m_decrease_mtime(path, &st); mutt_edit_file (editor, path); stat (path, &st); diff --git a/lib-lib/file.c b/lib-lib/file.c index aee3580..946d867 100644 --- a/lib-lib/file.c +++ b/lib-lib/file.c @@ -28,6 +28,8 @@ #include "lib-lib.h" +#include + #ifndef O_NOFOLLOW # define O_NOFOLLOW 0 #endif @@ -353,7 +355,7 @@ int mutt_copy_bytes(FILE *in, FILE *out, ssize_t size) /****************************************************************************/ -/* ligben-like funcs */ +/* path manipulations */ /****************************************************************************/ const char *mutt_basename(const char *f) @@ -521,3 +523,31 @@ FILE *m_tempfile(char *dst, ssize_t n, const char *dir, const char *fmt) int fd = m_tempfd(dst, n, dir, fmt); return fd < 0 ? NULL : fdopen(fd, "w+"); } + +/****************************************************************************/ +/* misc */ +/****************************************************************************/ + +/* Decrease a file's modification time by 1 second */ +time_t m_decrease_mtime(const char *path, struct stat *st) +{ + struct utimbuf utim; + struct stat _st; + time_t mtime; + + if (!st) { + if (stat(path, &_st) == -1) + return -1; + st = &_st; + } + + if ((mtime = st->st_mtime) == time(NULL)) { + mtime -= 1; + utim.actime = mtime; + utim.modtime = mtime; + utime(path, &utim); + } + + return mtime; +} + diff --git a/lib-lib/file.h b/lib-lib/file.h index bc153a8..1b242c3 100644 --- a/lib-lib/file.h +++ b/lib-lib/file.h @@ -64,7 +64,7 @@ int mutt_copy_stream(FILE *, FILE *); int mutt_copy_bytes(FILE *, FILE *, ssize_t); /****************************************************************************/ -/* ligben-like funcs */ +/* path manipulations */ /****************************************************************************/ const char *mutt_basename(const char *); @@ -80,4 +80,10 @@ ssize_t m_quotefile_fmt(char *, ssize_t, const char *, const char *); int m_tempfd(char *dst, ssize_t n, const char *dir, const char *fmt); FILE *m_tempfile(char *dst, ssize_t n, const char *dir, const char *fmt); +/****************************************************************************/ +/* misc */ +/****************************************************************************/ + +time_t m_decrease_mtime(const char *f, struct stat *st); + #endif /* MUTT_LIB_LIB_FILE_H */ diff --git a/muttlib.c b/muttlib.c index 87662ec..1f6b751 100644 --- a/muttlib.c +++ b/muttlib.c @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -605,29 +604,6 @@ void mutt_sleep (short s) sleep(MAX(s, SleepTime)); } -/* Decrease a file's modification time by 1 second */ -time_t mutt_decrease_mtime (const char *f, struct stat *st) -{ - struct utimbuf utim; - struct stat _st; - time_t mtime; - - if (!st) { - if (stat (f, &_st) == -1) - return -1; - st = &_st; - } - - if ((mtime = st->st_mtime) == time (NULL)) { - mtime -= 1; - utim.actime = mtime; - utim.modtime = mtime; - utime (f, &utim); - } - - return mtime; -} - const char *mutt_make_version (int full) { static char vstring[STRING]; diff --git a/protos.h b/protos.h index 9093cea..20b04ac 100644 --- a/protos.h +++ b/protos.h @@ -38,7 +38,6 @@ CONTENT *mutt_get_content_info (const char *fname, BODY * b); int mutt_cmp_header (const HEADER*, const HEADER*); -time_t mutt_decrease_mtime (const char *, struct stat *); int is_from (const char *, char *, ssize_t, time_t *); const char *mutt_charset_hook (const char *); diff --git a/send.c b/send.c index d282321..ed87f4b 100644 --- a/send.c +++ b/send.c @@ -8,7 +8,6 @@ */ #include -#include #include #include @@ -1376,7 +1375,7 @@ int ci_send_message (int flags, /* send mode */ if (!(flags & SENDBATCH)) { struct stat st; - time_t mtime = mutt_decrease_mtime (msg->content->filename, NULL); + time_t mtime = m_decrease_mtime(msg->content->filename, NULL); mutt_update_encoding (msg->content);