#endif /* HAVE_CONFIG_H */
#include <stdio.h>
-
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
-
-
+#include <stdbool.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include <netatalk/at.h>
-
#include <atalk/adouble.h>
#include <atalk/vfs.h>
#include <atalk/logger.h>
// ONLY USED IN THIS FILE
#include "fce_api_internal.h"
-#define FCE_TRUE 1
-#define FCE_FALSE 0
-
/* We store our connection data here */
static uint32_t coalesce = 0;
static struct fce_history fce_history_list[FCE_HISTORY_LEN];
}
}
-int fce_handle_coalescation( char *path, int is_dir, int mode )
+bool fce_handle_coalescation(int event, const char *path)
{
/* These two are used to eval our next index in history */
/* the history is unsorted, speed should not be a problem, length is 10 */
struct timeval tv;
if (coalesce == 0)
- return FALSE;
+ return false;
/* After a file creation *ALWAYS* a file modification is produced */
- if ((mode == FCE_FILE_CREATE) && (coalesce & FCE_COALESCE_CREATE))
- return TRUE;
+ if ((event == FCE_FILE_CREATE) && (coalesce & FCE_COALESCE_CREATE))
+ return true;
/* get timestamp */
gettimeofday(&tv, 0);
struct fce_history *fh = &fce_history_list[i];
/* Not inited ? */
- if (fh->tv.tv_sec == 0) {
+ if (fh->fce_h_tv.tv_sec == 0) {
/* we can use it for new elements */
oldest_entry = 0;
oldest_entry_idx = i;
}
/* Too old ? */
- if (get_ms_difftime( &fh->tv, &tv ) > MAX_COALESCE_TIME_MS) {
+ if (get_ms_difftime(&fh->fce_h_tv, &tv ) > MAX_COALESCE_TIME_MS) {
/* Invalidate entry */
- fh->tv.tv_sec = 0;
+ fh->fce_h_tv.tv_sec = 0;
oldest_entry = 0;
oldest_entry_idx = i;
continue;
/* If we find a parent dir wich was created we are done */
- if ((coalesce & FCE_COALESCE_CREATE) && (fh->mode == FCE_DIR_CREATE)) {
+ if ((coalesce & FCE_COALESCE_CREATE) && (fh->fce_h_event == FCE_DIR_CREATE)) {
/* Parent dir ? */
- if (!strncmp(fh->path, path, strlen(fh->path)))
- return TRUE;
+ if (!strncmp(fh->fce_h_path, path, strlen(fh->fce_h_path)))
+ return true;
}
/* If we find a parent dir we should be DELETED we are done */
if ((coalesce & FCE_COALESCE_DELETE)
- && fh->is_dir
- && (mode == FCE_FILE_DELETE || mode == FCE_DIR_DELETE)) {
+ && (event == FCE_FILE_DELETE || event == FCE_DIR_DELETE)) {
/* Parent dir ? */
- if (!strncmp(fh->path, path, strlen(fh->path)))
- return TRUE;
+ if (!strncmp(fh->fce_h_path, path, strlen(fh->fce_h_path)))
+ return true;
}
/* Detect oldest entry for next new entry */
- if (oldest_entry_idx == -1 || fh->tv.tv_sec < oldest_entry) {
- oldest_entry = fh->tv.tv_sec;
+ if (oldest_entry_idx == -1 || fh->fce_h_tv.tv_sec < oldest_entry) {
+ oldest_entry = fh->fce_h_tv.tv_sec;
oldest_entry_idx = i;
}
}
/* We have a new entry for the history, register it */
- fce_history_list[oldest_entry_idx].tv = tv;
- fce_history_list[oldest_entry_idx].mode = mode;
- fce_history_list[oldest_entry_idx].is_dir = is_dir;
- strncpy( fce_history_list[oldest_entry_idx].path, path, MAXPATHLEN);
+ fce_history_list[oldest_entry_idx].fce_h_tv = tv;
+ fce_history_list[oldest_entry_idx].fce_h_event = event;
+ strncpy(fce_history_list[oldest_entry_idx].fce_h_path, path, MAXPATHLEN);
/* we have to handle this event */
- return FALSE;
+ return false;
}
/*
* all|delete|create
*/
-int fce_set_coalesce(char *opt)
+int fce_set_coalesce(const char *opt)
{
char *e;
char *p;
}
free(e);
+
+ return AFP_OK;
}