clsync
Loading...
Searching...
No Matches
clsync.h
Go to the documentation of this file.
1/*
2 clsync - file tree sync utility based on inotify
3
4 Copyright (C) 2013 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __CLSYNC_CLSYNC_H
21#define __CLSYNC_CLSYNC_H
22
23#include <stdio.h>
24#include <stdint.h>
25#include <sys/types.h>
26
27#define CLSYNC_API_VERSION 2
28
30 EOT_UNKNOWN = 0, // Unknown
31 EOT_DOESNTEXIST = 1, // Doesn't exists (not created yet or already deleted)
32 EOT_FILE = 2, // File
33 EOT_DIR = 3, // Directory
34
35 // The value cannot be higher than "65535". It's due to recognize_event() function of mon_*.c
36};
38
40 uint32_t evmask; // event mask, see /usr/include/linux/inotify.h
41 uint32_t flags; // flags, see "enum eventinfo_flags"
42 size_t path_len; // strlen(path)
43 const char *path; // path
44 eventobjtype_t objtype_old; // type of object by path "path" before the event
45 eventobjtype_t objtype_new; // type of object by path "path" after the event
46};
48
49struct ctx;
50struct indexes;
51typedef int ( *api_funct_init ) ( struct ctx *, struct indexes * );
52typedef int ( *api_funct_sync ) ( int n, api_eventinfo_t * );
53typedef int ( *api_funct_rsync ) ( const char *inclist, const char *exclist );
54typedef int ( *api_funct_deinit ) ();
55
57 EVIF_NONE = 0x00000000, // No modifier
58 EVIF_RECURSIVELY = 0x00000001, // Need to be synced recursively
59 EVIF_CONTENTRECURSIVELY = 0x00000002, // Affects recursively only on content of this dir
60};
62
63/**
64 * @brief Writes the list to list-file for "--include-from" option of rsync using array of api_eventinfo_t
65 *
66 * @param[in] indexes_p Pointer to "indexes"
67 * @param[in] listfile File identifier to write to
68 * @param[in] n Number of records in apievinfo
69 * @param[in] apievinfo Pointer to api_eventinfo_t records
70 *
71 * @retval zero Successful
72 * @retval non-zero If got error while deleting the message. The error-code is placed into returned value.
73 *
74 */
75extern int apievinfo2rsynclist ( struct indexes *indexes_p, FILE *listfile, int n, api_eventinfo_t *apievinfo ); // Not tested, yet
76
77/**
78 * @brief Returns currect API version
79 *
80 * @retval api_version Version of clsync's API
81 *
82 */
83extern int clsyncapi_getapiversion();
84
85/**
86 * @brief clsync's wrapper for function "fork()". Should be used instead of "fork()" directly, to notify clsync about child's pid.
87 *
88 * @param[in] ctx_p Pointer to "ctx"
89 *
90 * @retval -1 If error (see "man 2 fork", added error code "ECANCELED" if too many children)
91 * @retval 0 If child
92 * @retval pid Pid of child of parent. (see "man 2 fork")
93 *
94 */
95extern pid_t clsyncapi_fork ( struct ctx *ctx_p );
96
97#endif
98
int(* api_funct_init)(struct ctx *, struct indexes *)
Definition clsync.h:51
eventinfo_flags
Definition clsync.h:56
@ EVIF_NONE
Definition clsync.h:57
@ EVIF_RECURSIVELY
Definition clsync.h:58
@ EVIF_CONTENTRECURSIVELY
Definition clsync.h:59
int apievinfo2rsynclist(struct indexes *indexes_p, FILE *listfile, int n, api_eventinfo_t *apievinfo)
Writes the list to list-file for "--include-from" option of rsync using array of api_eventinfo_t.
Definition sync.c:3171
int clsyncapi_getapiversion()
Returns currect API version.
Definition main.c:550
int(* api_funct_sync)(int n, api_eventinfo_t *)
Definition clsync.h:52
int(* api_funct_rsync)(const char *inclist, const char *exclist)
Definition clsync.h:53
int(* api_funct_deinit)()
Definition clsync.h:54
enum eventinfo_flags eventinfo_flags_t
Definition clsync.h:61
pid_t clsyncapi_fork(struct ctx *ctx_p)
clsync's wrapper for function "fork()". Should be used instead of "fork()" directly,...
Definition sync.c:1060
enum eventobjtype eventobjtype_t
Definition clsync.h:37
eventobjtype
Definition clsync.h:29
@ EOT_DIR
Definition clsync.h:33
@ EOT_DOESNTEXIST
Definition clsync.h:31
@ EOT_FILE
Definition clsync.h:32
@ EOT_UNKNOWN
Definition clsync.h:30
ctx_t * ctx_p
Definition mon_kqueue.c:85
uint32_t flags
Definition clsync.h:41
eventobjtype_t objtype_new
Definition clsync.h:45
size_t path_len
Definition clsync.h:42
const char * path
Definition clsync.h:43
uint32_t evmask
Definition clsync.h:40
eventobjtype_t objtype_old
Definition clsync.h:44
Definition ctx.h:315