2 * Copyright 2021 Olaf Wintermann
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
28 #include <ucx/string.h>
36 #define MZCP_ENV_HOME "HOME"
37 #define MZCP_CFG_BASE ".config"
38 #define MZCP_CFG_DIR ".config/mizunara"
39 #define MZCP_COPY_DIR "copy"
41 #define CLIENT_MSG_BUFSIZE 512
43 #define MAX_COPY_THREADS 32
47 typedef struct SrcFile SrcFile;
48 typedef struct MZLock MZLock;
49 typedef struct MZQueue MZQueue;
61 pthread_mutex_t mutex;
67 * src file path relative to CPSettings.from
72 * is the file a directory
77 * file successfully copied
82 * processing this file depends on another file (directory)
87 * lock used for waiting, until this resource is successfully copied
97 const char* mzcp_get_cfgdir(void);
98 const char* mzcp_get_copydir(void);
100 int mzcp_copy(CPSettings *settings);
102 int mzcp_start_scan(CPSettings *settings);
103 void* scan_run(void *data);
105 int enqueue_file(SrcFile *file);
107 int mzcp_start_copy_threads(CPSettings *settings);
108 void* copy_run(void *data);