From 5bae92695c8487c0f55c232af7bab91077435a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edvin?= Date: Wed, 28 Jan 2009 17:08:08 +0000 Subject: [PATCH] cli_sftw -> cli_ftw, and hide old cli_ftw git-svn-id: file:///var/lib/svn/clamav-devel/branches/clamd-proto@4658 77e5149b-7576-45b1-b177-96237e5ba77b --- ChangeLog | 5 +++++ clamd/session.c | 2 +- libclamav/others.h | 8 +++----- libclamav/others_common.c | 9 +++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd1d4a7ba..ea03f94c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jan 28 19:31:56 EET 2009 (edwin) +------------------------------------ + * clamd/session.c, libclamav/others.h, libclamav/others_common.c: + cli_sftw -> cli_ftw, and hide old cli_ftw + Wed Jan 28 19:25:28 EET 2009 (edwin) ------------------------------------ * clamd/scanner.c, clamd/scanner.h, clamd/session.c, diff --git a/clamd/session.c b/clamd/session.c index 0738f5564..723fa9080 100644 --- a/clamd/session.c +++ b/clamd/session.c @@ -214,7 +214,7 @@ int command(client_conn_t *conn, int timeout) thrmgr_setactivetask(buff+strlen(CMD13)+1, CMD13); int maxdirrec = optget(opts, "MaxDirectoryRecursion")->numarg; - if (cli_sftw(path, CLI_FTW_STD, maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data) == CL_EMEM) + if (cli_ftw(path, CLI_FTW_STD, maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data) == CL_EMEM) if(optget(opts, "ExitOnOOM")->enabled) return COMMAND_SHUTDOWN; thrmgr_group_waitforall(&group, &ok, &error, &total); diff --git a/libclamav/others.h b/libclamav/others.h index 3a4890e9f..bfb99d21a 100644 --- a/libclamav/others.h +++ b/libclamav/others.h @@ -409,12 +409,10 @@ typedef int (*cli_ftw_cb)(struct stat *stat_buf, char *filename, const char *msg * returns we don't know the infected/notinfected status of the directory yet! * Due to this if the callback scans synchronously it should store the infected * status in its cbdata. + * This works for both files and directories. It stats the path to determine + * which one it is. + * If it is a file, it simply calls the callback once, otherwise recurses. */ int cli_ftw(const char *base, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data); -/* Like cli_ftw() but works both for files and directories. - * If it is a file, it simply calls the callback once, otherwise recurses. - * Path must point to malloced memory, that will be freed. */ -int cli_sftw(const char *path, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data); - #endif diff --git a/libclamav/others_common.c b/libclamav/others_common.c index 4fb0193cf..7b9b9cff4 100644 --- a/libclamav/others_common.c +++ b/libclamav/others_common.c @@ -384,16 +384,17 @@ static int handle_filetype(const char *fname, int flags, return CL_SUCCESS; } +static int cli_ftw_dir(const char *dirname, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data); static int handle_entry(struct dirent_data *entry, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data) { if (!entry->is_dir) { return callback(entry->statbuf, entry->filename, NULL, visit_file, data); } else { - return cli_ftw(entry->dirname, flags, maxdepth, callback, data); + return cli_ftw_dir(entry->dirname, flags, maxdepth, callback, data); } } -int cli_sftw(const char *path, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data) +int cli_ftw(const char *path, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data) { struct stat statbuf; enum filetype ft = ft_unknown; @@ -411,7 +412,7 @@ int cli_sftw(const char *path, int flags, int maxdepth, cli_ftw_cb callback, str return handle_entry(&entry, flags, maxdepth, callback, data); } -int cli_ftw(const char *dirname, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data) +static int cli_ftw_dir(const char *dirname, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data) { DIR *dd; #if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) @@ -601,7 +602,7 @@ int main(int argc, char *argv[]) if (argc != 2) return 1; data.data = &files; - cli_ftw(argv[1], CLI_FTW_STD, 16, tst_cb, &data); + cli_ftw_dir(argv[1], CLI_FTW_STD, 16, tst_cb, &data); return 0; } #endif