... | ... |
@@ -4,6 +4,12 @@ |
4 | 4 |
* |
5 | 5 |
* Author: aCaB |
6 | 6 |
* |
7 |
+ * These functions are actions that may be taken when a sample alerts. |
|
8 |
+ * The user may wish to: |
|
9 |
+ * - move file to destination directory. |
|
10 |
+ * - copy file to destination directory. |
|
11 |
+ * - remove (delete) the file. |
|
12 |
+ * |
|
7 | 13 |
* This program is free software; you can redistribute it and/or modify |
8 | 14 |
* it under the terms of the GNU General Public License version 2 as |
9 | 15 |
* published by the Free Software Foundation. |
... | ... |
@@ -83,7 +89,7 @@ static void action_move(const char *filename) |
83 | 83 |
char *nuname; |
84 | 84 |
int fd = getdest(filename, &nuname), copied = 0; |
85 | 85 |
|
86 |
- if (fd < 0 || (rename(filename, nuname) && (copied = 1) && filecopy(filename, nuname))) { |
|
86 |
+ if (fd < 0 || (rename(filename, nuname) && ((copied = 1)) && filecopy(filename, nuname))) { |
|
87 | 87 |
logg("!Can't move file %s\n", filename); |
88 | 88 |
notmoved++; |
89 | 89 |
if (nuname) unlink(nuname); |
... | ... |
@@ -134,6 +140,10 @@ static int isdir(void) |
134 | 134 |
return 1; |
135 | 135 |
} |
136 | 136 |
|
137 |
+/* |
|
138 |
+ * Call this function at the beginning to configure the user preference. |
|
139 |
+ * Later, call the "action" callback function to perform the selection action. |
|
140 |
+ */ |
|
137 | 141 |
int actsetup(const struct optstruct *opts) |
138 | 142 |
{ |
139 | 143 |
int move = optget(opts, "move")->enabled; |
... | ... |
@@ -4,6 +4,12 @@ |
4 | 4 |
* |
5 | 5 |
* Authors: aCaB |
6 | 6 |
* |
7 |
+ * These functions are actions that may be taken when a sample alerts. |
|
8 |
+ * The user may wish to: |
|
9 |
+ * - move file to destination directory. |
|
10 |
+ * - copy file to destination directory. |
|
11 |
+ * - remove (delete) the file. |
|
12 |
+ * |
|
7 | 13 |
* This program is free software; you can redistribute it and/or modify |
8 | 14 |
* it under the terms of the GNU General Public License version 2 as |
9 | 15 |
* published by the Free Software Foundation. |
... | ... |
@@ -24,8 +30,22 @@ |
24 | 24 |
|
25 | 25 |
#include "shared/optparser.h" |
26 | 26 |
|
27 |
+/** |
|
28 |
+ * @brief Callback function to perform the action requested when actsetup() was invoked. |
|
29 |
+ * |
|
30 |
+ * @param filename |
|
31 |
+ */ |
|
27 | 32 |
extern void (*action)(const char *); |
33 |
+ |
|
34 |
+/** |
|
35 |
+ * @brief Select the appropriate callback function based on the configuration options. |
|
36 |
+ * |
|
37 |
+ * @param opts Application configuration options. |
|
38 |
+ * @return int 0 if success. |
|
39 |
+ * @return int 1 if move or copy were selected but the destination directory does not exist. |
|
40 |
+ */ |
|
28 | 41 |
int actsetup(const struct optstruct *opts); |
42 |
+ |
|
29 | 43 |
extern unsigned int notremoved, notmoved; |
30 | 44 |
|
31 | 45 |
#endif |