clsync
Toggle main menu visibility
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
29
enum
eventobjtype
{
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
};
37
typedef
enum
eventobjtype
eventobjtype_t
;
38
39
struct
api_eventinfo
{
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
};
47
typedef
struct
api_eventinfo
api_eventinfo_t
;
48
49
struct
ctx
;
50
struct
indexes
;
51
typedef
int ( *
api_funct_init
) (
struct
ctx
*,
struct
indexes
* );
52
typedef
int ( *
api_funct_sync
) (
int
n,
api_eventinfo_t
* );
53
typedef
int ( *
api_funct_rsync
) (
const
char
*inclist,
const
char
*exclist );
54
typedef
int ( *
api_funct_deinit
) ();
55
56
enum
eventinfo_flags
{
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
};
61
typedef
enum
eventinfo_flags
eventinfo_flags_t
;
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
*/
75
extern
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
*/
83
extern
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
*/
95
extern
pid_t
clsyncapi_fork
(
struct
ctx
*
ctx_p
);
96
97
#endif
98
api_funct_init
int(* api_funct_init)(struct ctx *, struct indexes *)
Definition
clsync.h:51
eventinfo_flags
eventinfo_flags
Definition
clsync.h:56
EVIF_NONE
@ EVIF_NONE
Definition
clsync.h:57
EVIF_RECURSIVELY
@ EVIF_RECURSIVELY
Definition
clsync.h:58
EVIF_CONTENTRECURSIVELY
@ EVIF_CONTENTRECURSIVELY
Definition
clsync.h:59
apievinfo2rsynclist
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
clsyncapi_getapiversion
int clsyncapi_getapiversion()
Returns currect API version.
Definition
main.c:550
api_funct_sync
int(* api_funct_sync)(int n, api_eventinfo_t *)
Definition
clsync.h:52
api_funct_rsync
int(* api_funct_rsync)(const char *inclist, const char *exclist)
Definition
clsync.h:53
api_funct_deinit
int(* api_funct_deinit)()
Definition
clsync.h:54
eventinfo_flags_t
enum eventinfo_flags eventinfo_flags_t
Definition
clsync.h:61
clsyncapi_fork
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
api_eventinfo_t
struct api_eventinfo api_eventinfo_t
Definition
clsync.h:47
eventobjtype_t
enum eventobjtype eventobjtype_t
Definition
clsync.h:37
eventobjtype
eventobjtype
Definition
clsync.h:29
EOT_DIR
@ EOT_DIR
Definition
clsync.h:33
EOT_DOESNTEXIST
@ EOT_DOESNTEXIST
Definition
clsync.h:31
EOT_FILE
@ EOT_FILE
Definition
clsync.h:32
EOT_UNKNOWN
@ EOT_UNKNOWN
Definition
clsync.h:30
ctx_p
ctx_t * ctx_p
Definition
mon_kqueue.c:85
api_eventinfo
Definition
clsync.h:39
api_eventinfo::flags
uint32_t flags
Definition
clsync.h:41
api_eventinfo::objtype_new
eventobjtype_t objtype_new
Definition
clsync.h:45
api_eventinfo::path_len
size_t path_len
Definition
clsync.h:42
api_eventinfo::path
const char * path
Definition
clsync.h:43
api_eventinfo::evmask
uint32_t evmask
Definition
clsync.h:40
api_eventinfo::objtype_old
eventobjtype_t objtype_old
Definition
clsync.h:44
ctx
Definition
ctx.h:315
indexes
Definition
indexes.h:34
Generated on
for clsync by
1.17.0