Comparar commits

..

61 Commits

Autor SHA1 Mensagem Data
Duncan Mac-Vicar P a75cf60c80 0.0.2 2011-04-08 11:39:35 +02:00
Duncan Mac-Vicar P 67b6e77979 handle errors to the UI 2011-04-08 11:36:53 +02:00
Duncan Mac-Vicar P b0efc506cd increase poll timer to 1 minute 2011-04-08 10:51:18 +02:00
Duncan Mac-Vicar P d1ee08d442 add a mutex for the csync threads 2011-04-08 10:49:28 +02:00
Duncan Mac-Vicar P 0ba4fac32f for csync, accept smb:// urls as well 2011-04-08 10:49:26 +02:00
Duncan Mac-Vicar P 58270990ed force the initial sync even if the list is empty as this point 2011-04-08 10:48:22 +02:00
Duncan Mac-Vicar P 0aa5f51bb5 Use csync as default 2011-04-08 09:58:16 +02:00
Duncan Mac-Vicar P 3ce5932bbd g
Basic implementation of a CSyncFolder

Still waiting for Jann's patches for conflictcopy to hit a stable
release to make it the default.
2011-04-07 19:04:07 +02:00
Duncan Mac-Vicar P 83eeeb4216 Simplify how the event queue works. Now it is just a timer
that gets restarted on every new event, and the processing starts
when no events reset the timer for the event interval.
2011-04-06 22:35:08 +02:00
Duncan Mac-Vicar P 25315dfdec fix warning 2011-04-06 17:03:10 +02:00
Duncan Mac-Vicar P a4c5996f47 Make the folders network state aware 2011-04-06 15:57:18 +02:00
Duncan Mac-Vicar P 65c41b6368 add simple network location infrastructure 2011-04-06 15:22:40 +02:00
Duncan Mac-Vicar P 5162b9def2 missing goal 2011-04-06 13:50:31 +02:00
Duncan Mac-Vicar P 598929a22f better goals 2011-04-06 13:49:58 +02:00
Duncan Mac-Vicar P 098c848e02 Merge branch 'master' of github.com:dmacvicar/mirall 2011-04-06 12:10:33 +02:00
Duncan Mac-Vicar P 293333b28e add license text 2011-04-06 12:10:16 +02:00
Duncan Mac-Vicar P f882fe46e2 Use icons from theme. Qt already handles this in a nice way 2011-04-06 12:09:56 +02:00
Duncan Mac-Vicar P 2411b0c9b7 add proper licensing 2011-04-06 11:48:02 +02:00
Duncan Mac-Vicar P 9a6a87d9af add proper licensing 2011-04-06 11:45:05 +02:00
Duncan Mac-Vicar P 637068236f fix markdown in README 2011-04-06 11:31:54 +02:00
Duncan Mac-Vicar P 5ebaca5b8d preparing for first packaging 2011-04-06 11:28:38 +02:00
Duncan Mac-Vicar P 493b6924c9 Setup the menu for new added folders 2011-04-06 10:56:20 +02:00
Duncan Mac-Vicar P ab86052f8a typo, it is path() not root() 2011-04-06 10:56:16 +02:00
Duncan Mac-Vicar P 79f28c7f10 stop poll timer when syncing, and add path to the debug messages 2011-04-06 10:40:15 +02:00
Duncan Mac-Vicar P c19c9859e3 add alias to folder 2011-04-06 09:52:02 +02:00
Duncan Mac-Vicar P c16fd94150 Fix crash at shutdown.
Menu contains actions from the folders so we should
first delete the tray and the folders later.

Also change QHash in inotify watcher map to QMap as QHash
gives weird crashes with the inotify thread.
2011-04-05 18:31:19 +02:00
Duncan Mac-Vicar P f1d6352f27 working folder wizard, only actual creation of the folder pending 2011-04-05 18:31:14 +02:00
Duncan Mac-Vicar P 9055cdc60d move polling system to Folder where it belongs 2011-04-05 12:16:24 +02:00
Duncan Mac-Vicar P e721acd7e8 add folder wizard class 2011-04-05 11:10:44 +02:00
Duncan Mac-Vicar P 4e45cab2c1 - lot of stability improvements
- the crash with threads goes away by using QMap
- add a polling timer
2011-04-04 18:41:14 +02:00
Duncan Mac-Vicar P 389507d92f Change icon when sync is running 2011-04-04 12:23:30 +02:00
Duncan Mac-Vicar P 5aa1e08558 unused member variable 2011-04-04 11:40:14 +02:00
Duncan Mac-Vicar P 8d5a760d91 implemented dynamic creation of folder configurations
from INI files in user's home directory
2011-04-04 11:36:44 +02:00
Duncan Mac-Vicar P f22caca96b - refactor tests repeat-myself with a cmake macro
- enable cmake testing
2011-03-31 20:26:51 +02:00
Duncan Mac-Vicar P 9ac0397ff9 unneeded 2011-03-31 20:26:32 +02:00
Duncan Mac-Vicar P 3f32499c4e If the first event happens before 5 secs after starting the
program, it will always cause it to queue it to avoid event
flood (5 secs). So don't init the QTime for last event, and then
check if it is null.
2011-03-31 19:07:45 +02:00
Duncan Mac-Vicar P 7bac43c5c3 I missunderstood how mkdtemp worked. Allocate a buffer duplicating
the template. Then free this buffer.
2011-03-31 19:06:30 +02:00
Duncan Mac-Vicar P f917dbc2ad - Use a full sync (without -path) the first time
unison is invoked
- disable -confirmbigdel
2011-03-31 08:19:04 +02:00
Duncan Mac-Vicar P bad489adcc add testcases for unison 2011-03-30 23:36:30 +02:00
Duncan Mac-Vicar P 9d09b7ea5f show only a summary of subdirectories 2011-03-29 22:23:42 +02:00
Duncan Mac-Vicar P 1b19507ca8 * Missing brackets changed all logic around an 'if'
* Improve debug output
2011-03-28 11:54:10 +02:00
Duncan Mac-Vicar P 15579232f7 refactor the notification timer in a new method
some debug messages cleanup
2011-03-27 23:29:45 +02:00
Duncan Mac-Vicar P 6b8589f4dc When syncing, disable event notifier and start accumulating them
until the sync is done. When they are enabled again, a forced
event is scheduled to empty the queue.
2011-03-27 01:26:41 +01:00
Duncan Mac-Vicar P 64e4d531b3 sync process now runs, but no synchronization between sync processes 2011-03-25 18:25:56 +01:00
Duncan Mac-Vicar P f31ddde36d Merge branch 'fix_inotify'
Conflicts:
	src/mirall/folder.cpp
	src/mirall/folder.h
2011-03-22 23:21:56 +01:00
Duncan Mac-Vicar P d885fe39f8 Implement an event queue:
- If FolderWatcher receives a inotify event in less than 5
  seconds from the last one, then the paths are queued and a timer
  is setup for 5 seconds more. New events are queued if a timer
  is running. The next event after the time gap is due will process
  the full path list
2011-03-22 23:03:43 +01:00
Duncan Mac-Vicar P f42169a8fc The unison folder class.
May be factor it out in a external process tool folder type later.
2011-03-21 00:58:53 +01:00
Duncan Mac-Vicar P 25685de4fd move the subfolder list function to FileUtils 2011-03-20 22:43:03 +01:00
Duncan Mac-Vicar P 89361db55d Only fire folderChanged if > 2 seconds since last event 2011-03-20 22:38:33 +01:00
Duncan Mac-Vicar P d53490c67c add accessor for root folder 2011-03-20 22:18:38 +01:00
Duncan Mac-Vicar P 3bb5869183 add some documentation 2011-03-20 22:17:23 +01:00
Duncan Mac-Vicar P ad90a6c05e Make the socket read loop more robust, and handle the EINVAL when
the read buffer is too small.
2011-03-20 22:13:40 +01:00
Duncan Mac-Vicar P 8b5c371012 - listen to the right events
- rename inotify signal
- pass also the cookie
2011-03-19 21:18:43 +01:00
Duncan Mac-Vicar P bd5effe78c - fix inotify/folderwatcher so that it uses full paths
- make the test pass using QSignalSpy
2011-03-18 13:54:32 +01:00
Duncan Mac-Vicar P e6a135273d - introduce a tmp dir class and rm-rf util function
- start a testcase for the folder watcher part
2011-03-18 01:14:45 +01:00
Duncan Mac-Vicar P 03194d3aae Make the inotify interface work with multiple paths 2011-03-17 07:13:30 +01:00
Duncan Mac-Vicar P 5294bee2bf Infrastructure for inotify. To replace QFileSystemWatcher, which, due
to a Qt bug, can't see modified files.
See http://qt.gitorious.org/qt/qt/merge_requests/2301
2011-03-16 14:53:41 +01:00
Duncan Mac-Vicar P e2638aa487 react to its own signals to set the icons 2011-02-17 15:10:06 +01:00
Duncan Mac-Vicar P 0af772f524 fix defines 2011-02-17 15:10:03 +01:00
Duncan Mac-Vicar P cf88820069 rename action to openAction to add also forgetAction and others later 2011-02-17 11:27:05 +01:00
Duncan Mac-Vicar P b7a3fc7ab8 first port to C++ 2011-02-17 00:21:45 +01:00
220 arquivos alterados com 3853 adições e 31019 exclusões
+3 -8
Ver Arquivo
@@ -1,8 +1,3 @@
.*
*.swp
*~$
build*
cscope.*
tags
*~
*.kdev4
build
*flymake*
-2
Ver Arquivo
@@ -1,2 +0,0 @@
Andreas Schneider <asn@cryptomilk.org>
Klaas Freitag <freitag@owncloud.com>
+43 -59
Ver Arquivo
@@ -1,67 +1,51 @@
project(csync C)
cmake_minimum_required(VERSION 2.8)
project(mirall)
set(PACKAGE "mirall")
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
# Required cmake version
cmake_minimum_required(VERSION 2.6.0)
find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest REQUIRED )
find_package(Csync)
# global needed variables
set(APPLICATION_NAME ${PROJECT_NAME})
if(CSYNC_FOUND)
add_definitions(-DWITH_CSYNC)
endif(CSYNC_FOUND)
set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "50")
set(APPLICATION_VERSION_PATCH "0")
macro(add_tests)
foreach( loop_var ${ARGV} )
qt4_automoc(test${loop_var}.cpp)
add_executable(test${loop_var} test${loop_var}.cpp)
target_link_libraries(test${loop_var} ${QT_LIBRARIES} mirall_static)
add_test(test${loop_var} ${CMAKE_CURRENT_BINARY_DIR}/test${loop_var} --catch_system_errors=no)
endforeach( loop_var )
endmacro(add_tests)
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
set(LIBRARY_VERSION "0.1.4")
set(LIBRARY_SOVERSION "0")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake/Modules
set(CPACK_SOURCE_IGNORE_FILES
# hidden files
"/\\\\..+$"
# temporary files
"\\\\.swp$"
# backup files
"~$"
# others
"\\\\.#"
"/#"
"/build/"
"/_build/"
# used before
"\\\\.o$"
"\\\\.lo$"
"\\\\.la$"
"Makefile\\\\.in$"
)
set(CPACK_PACKAGE_VENDOR "Duncan Mac-Vicar P.")
set(CPACK_GENERATOR "TBZ2")
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
include(CPack)
# add definitions
include(DefineCMakeDefaults)
include(DefinePlatformDefaults)
include(DefineCompilerFlags)
include(DefineOptions.cmake)
include(CPackConfig.cmake)
include(DefineInstallationPaths)
# disallow in-source build
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
# add macros
include(MacroAddPlugin)
include(MacroCopyFile)
if (NOT WIN32)
find_package(Iconv)
endif (NOT WIN32)
find_package(CMocka)
if (CMOCKA_FOUND AND UNIT_TESTING)
include(AddCMockaTest)
endif (CMOCKA_FOUND AND UNIT_TESTING)
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake)
if (MEM_NULL_TESTS)
add_definitions(-DCSYNC_MEM_NULL_TESTS)
endif (MEM_NULL_TESTS)
include(CTest)
enable_testing()
add_subdirectory(src)
add_subdirectory(modules)
add_subdirectory(client)
add_subdirectory(config)
add_subdirectory(doc)
if (CMOCKA_FOUND AND UNIT_TESTING)
add_subdirectory(tests)
endif (CMOCKA_FOUND AND UNIT_TESTING)
add_subdirectory(test)
+594 -422
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-27
Ver Arquivo
@@ -1,27 +0,0 @@
include(InstallRequiredSystemLibraries)
# For help take a look at:
# http://www.cmake.org/Wiki/CMake:CPackConfiguration
### general settings
set(CPACK_PACKAGE_NAME "csync")
set(CPACK_PACKAGE_VENDOR "csync")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "User level bidirectional client only file synchronizer")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
### versions
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "50")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
### source package settings
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
include(CPack)
-12
Ver Arquivo
@@ -1,12 +0,0 @@
set(UPDATE_TYPE "true")
set(MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/tests/valgrind-csync.supp)
set(CTEST_PROJECT_NAME "csync")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "mock.cryptomilk.org")
set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}")
set(CTEST_DROP_SITE_CDASH TRUE)
-4
Ver Arquivo
@@ -1,4 +0,0 @@
set(CTEST_CUSTOM_MEMCHECK_IGNORE
${CTEST_CUSTOM_MEMCHECK_IGNORE}
check_std_c_jhash
)
-117
Ver Arquivo
@@ -1,117 +0,0 @@
ChangeLog
==========
version 0.50.0 (released 2013-08-01)
* Added owncloud module.
* Added support for more platforms: FreeBSD, Windows and MacOSX
* Added support for more compilers: CLang, MinGW and latest GCC
* Added a backup mode to the reconciler.
* Added new logging framework (removed log4c dependency).
* Added new config parser (removed iniparser dependency).
* Added cmocka tests.
* Added a way to exported file_tree_walk functions.
* Added capabilities for modules.
* Added possiblity to push information to the modules.
* Added iconv support to support various char sets.
* Added csync_commit() to rerun on the same context.
* Added content checking in conflict case.
* Added callbacks for progress information.
* Added get() and put() functions for modules.
* Improved database: more performance, more integrity checks
* Improved error reporting: status codes, custom errnos
* Fixed serveral bugs.
* Relicensed libcsync to LGPLv2.1+.
version 0.44.0 (released 2010-02-15)
* Migrated sftp module to libssh 0.4.
* Added more cache entries to the default config.
* Added missing requirements.
* Fixed build warnings.
* Fixed some memory leaks using sftp attributes.
* Some code cleanups.
version 0.43.0 (released 2009-05-25)
* Added SFTP support with libssh 0.3.
* Added possibility to pass userdata to the auth function.
* Added a better version function.
* Fixed CMake build.
* Fixed CMake find modules.
* Fixed some flaws in cstd functions.
* Documented all public functions.
version 0.42.0 (released 2009-02-10)
* Small fix in the userguide.
version 0.42.0 rc3 (released 2009-01-23)
libcsync:
* Added checks for unix extensions.
* Added more documentation to the userguide.
* Fixed loading of plugins.
* Fixed call for deletion functions.
* Normalize the path to <hostname>/<path> for the statedb filename.
* More change name of client options to be more descriptive.
version 0.42.0 rc2 (released 2009-01-07)
libcsync:
* Fixed a bug in the creation of the statedb
* Completed userguide
version 0.42.0 rc1 (released 2008-12-04)
libcsync:
* Reduced calls of syscall functions.
* Added own function to create a temporary filename.
* Fixed libsmbclient 3.0.x support.
version 0.42.0 beta1 (released 2008-09-10)
libcsync:
* Added a sftp module using libssh
* Added user guide (just a start)
* Added testcase for update detection
* Added a function to parse an uri to cstdlib
* Updated the manpage
* Fixed some segfaults in cstdlib
* Fixed some memory leaks
csync:
* Improved the auth callback
version 0.42.0 alpha4 (released 2008-07-02)
libcsync:
* Added the possibility to run csync completely without a journal
* Improved chmod calls during propagation. Most of the time we use the
default mode and don't need to call chmod.
* Improved the exclude list handling in the file tree walker. This
increased the speed of the update detection.
* Fixed csync on PPC
* Fixed serveral small bugs
csync:
* Added commandline option to run csync completely without a journal
* Added a manpage
version 0.42.0 alpha3 (released 2008-06-25)
libcsync:
* Added a tree merger to write a complete journal
* Added support to run csync without a journal
* Fixed kerberos support in csync_smb module
* Fixed closing of files after the copy
* Fixed update detection to detect special files (fifo, pipes,
char devices, ..)
* Fixed O_NOATIME flag on open() if we don't have the permission
csync:
* Add a variable to run csync completely without a journal
version 0.42.0 alpha2 (released 2008-06-16)
libcsync:
* Peformance improvements
* Add more directories to the standard exclude file
* Bugfixes
version 0.42.0 alpha1 (released 2008-06-02)
* Initial release
-71
Ver Arquivo
@@ -1,71 +0,0 @@
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)
set(PACKAGE ${APPLICATION_NAME})
set(VERSION ${APPLICATION_VERSION})
set(DATADIR ${DATA_INSTALL_DIR})
set(LIBDIR ${LIB_INSTALL_DIR})
set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
set(BINARYDIR ${CMAKE_BINARY_DIR})
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
# HEADER FILES
check_include_file(argp.h HAVE_ARGP_H)
# FUNCTIONS
if (NOT LINUX)
# librt
check_library_exists(rt nanosleep "" HAVE_LIBRT)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
endif (NOT LINUX)
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
if (HAVE_LIBRT OR HAVE_CLOCK_GETTIME)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
endif (HAVE_LIBRT OR HAVE_CLOCK_GETTIME)
check_library_exists(dl dlopen "" HAVE_LIBDL)
if (HAVE_LIBDL)
find_library(DLFCN_LIBRARY dl)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${DLFCN_LIBRARY})
endif (HAVE_LIBDL)
check_function_exists(asprintf HAVE_ASPRINTF)
if(NOT HAVE_ASPRINTF)
if(MINGW)
add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
endif()
endif()
check_function_exists(fnmatch HAVE_FNMATCH)
if(NOT HAVE_FNMATCH AND WIN32)
find_library(SHLWAPI_LIBRARY shlwapi)
endif()
if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} psapi kernel32)
endif()
check_function_exists(strerror_r HAVE_STRERROR_R)
check_function_exists(utimes HAVE_UTIMES)
check_function_exists(lstat HAVE_LSTAT)
check_function_exists(asprintf HAVE_ASPRINTF)
if (UNIX AND HAVE_ASPRINTF)
add_definitions(-D_GNU_SOURCE)
endif (UNIX AND HAVE_ASPRINTF)
if (WIN32)
check_function_exists(__mingw_asprintf HAVE___MINGW_ASPRINTF)
endif(WIN32)
if (UNIT_TESTING)
set(WITH_UNIT_TESTING ON)
endif (UNIT_TESTING)
set(CSYNC_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "csync required system libraries")
-5
Ver Arquivo
@@ -1,5 +0,0 @@
if ( NOT WIN32 )
option(WITH_ICONV "Build csync with iconv support" ON)
endif()
option(UNIT_TESTING "Build with unit tests" OFF)
option(MEM_NULL_TESTS "Enable NULL memory testing" OFF)
-82
Ver Arquivo
@@ -1,82 +0,0 @@
# How to build from source
## Requirements
### Common requirements
In order to build csync, you need to install several components:
- A C compiler
- [CMake](http://www.cmake.org) >= 2.6.0.
- [check](http://check.sourceforge.net) >= 0.9.5
- [sqlite3](http://www.sqlite.org) >= 3.4
- [libiniparser](http://ndevilla.free.fr/iniparser/) >= 2.10
- [libsmbclient](http://www.samba.org) >= 3.5
- [libssh](http://www.libssh.org) >= 0.5
sqlite3 is a runtime requirement. libsmbclient is needed for
the smb plugin, libssh for the sftp plugin.
Note that these version numbers are version we know works correctly. If you
build and run csync successfully with an older version, please let us know.
## Building
First, you need to configure the compilation, using CMake. Go inside the
`build` dir. Create it if it doesn't exist.
GNU/Linux and MacOS X:
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
### CMake standard options
Here is a list of the most interesting options provided out of the box by CMake.
- CMAKE_BUILD_TYPE: The type of build (can be Debug Release MinSizeRel RelWithDebInfo)
- CMAKE_INSTALL_PREFIX: The prefix to use when running make install (Default to
/usr/local on GNU/Linux and MacOS X)
- CMAKE_C_COMPILER: The path to the C compiler
- CMAKE_CXX_COMPILER: The path to the C++ compiler
### CMake options defined for csync
Options are defined in the following files:
- DefineOptions.cmake
They can be changed with the -D option:
`cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_LOG4C=OFF ..`
### Browsing/editing CMake options
In addition to passing options on the command line, you can browse and edit
CMake options using `cmakesetup` (Windows) or `ccmake` (GNU/Linux and MacOS X).
- Go to the build dir
- On Windows: run `cmakesetup`
- On GNU/Linux and MacOS X: run `ccmake ..`
## Installing
Befor installing you can run the tests if everything is working:
make test
If you want to install csync after compilation run:
make install
## Running
The csync binary can be found in the `build/client` directory.
## About this document
This document is written using [Markdown][] syntax, making it possible to
provide usable information in both plain text and HTML format. Whenever
modifying this document please use [Markdown][] syntax.
[markdown]: http://www.daringfireball.net/projects/markdown
-34
Ver Arquivo
@@ -1,34 +0,0 @@
WHAT IS CSYNC?
==============
csync is a lightweight utility to synchronize files between two directories on
a system or between multiple systems.
It synchronizes bidirectionally and allows the user to keep two copies of files
and directories in sync. csync uses widely adopted protocols, such as smb or
sftp, so that there is no need for a server component. It is a user-level
program which means you dont need to be a superuser or administrator.
CONTRIBUTIONS
=============
If you want to contribute to the development of the software then please join
the mailing list. Patches are accepted preferebly created with git and we are
always glad to receive feedback or suggestions to the address
csync-devel@csync.org.
More information on the various mailing lists can be found at
http://www.csync.org/communication/.
You can also get the sourcecode straight from the git repository - see
http://git.csync.org/
DOCUMENTATION
=============
As a user you can find a userguide which is shipped with this package or is
available at the website. For developers there is doxygen documentation and
comments in the source code itself. See
http://www.csync.org/userguide/
and
http://www.csync.org/api/
+89
Ver Arquivo
@@ -0,0 +1,89 @@
# Mirall
## Introduction
Mirall synchronizes your folders with another computer.
The ultimate goals of Mirall are:
* Network location aware: should not try to sync against your NAS if you are
not in the home network
* It is a zero-interaction tool. So forget about resolving conflicts.
* It should work silently and realiably.
Mirall is in early stages of development, and may still eat your
files or hang your computer.
* Network location awareness not implemented yet
* Current version supports local and remote (SSH) folders.
* It is powered by the great unison (http://www.cis.upenn.edu/~bcpierce/unison/), however
the user does not know and other tools will be incorporated to provide other
functionality.
## Current issues
* No sane way to backup conflicting versions yet
Workaround: delete ~/.local/share/data/Mirall/folders/$ALIAS and restart
* You can't remove folder configurations
* Some tasks block the GUI (initial setup of watchers)
* May be some concurrency issues
## Roadmap
* Improve robustness to minimize user interaction
* Improve feedback and sync results
* Add support for other folder types: tarsnap, duplicity, git (SparkleShare)
## Requirements
* Linux (currently it uses inotify to detect file changes)
* unison installed in the local and remote machine
(you should not care if you got Mirall with your favorite
distribution)
## Download
### openSUSE
* 1-click install available in software.opensuse.org
http://software.opensuse.org/search?q=mirall&baseproject=ALL&lang=en&include_home=true&exclude_debug=true
### Source code
* http://github.com/dmacvicar/mirall
## Building the source code
You need Qt 4.7 and cmake:
mkdir build
cd build
cmake ..
make
To generate a tarball:
mkdir build
cd build
cmake ..
make package_source
## Authors
* Duncan Mac-Vicar P. <duncan@kde.org>
## License
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
+1
Ver Arquivo
@@ -0,0 +1 @@
set(VERSION "0.0.2")
-155
Ver Arquivo
@@ -1,155 +0,0 @@
#!/bin/bash
#
# Last Change: 2008-06-18 14:13:46
#
# Script to build csync on UNIX.
#
# Copyright (c) 2006-2007 Andreas Schneider <asn@cryptomilk.org>
#
SOURCE_DIR=".."
LANG=C
export LANG
SCRIPT="$0"
COUNT=0
while [ -L "${SCRIPT}" ]
do
SCRIPT=$(readlink ${SCRIPT})
COUNT=$(expr ${COUNT} + 1)
if [ ${COUNT} -gt 100 ]; then
echo "Too many symbolic links"
exit 1
fi
done
BUILDDIR=$(dirname ${SCRIPT})
cleanup_and_exit () {
if test "$1" = 0 -o -z "$1" ; then
exit 0
else
exit $1
fi
}
function configure() {
cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
}
function compile() {
CPUCOUNT=$(grep -c processor /proc/cpuinfo)
if [ "${CPUCOUNT}" -gt "1" ]; then
make -j${CPUCOUNT} $1 || cleanup_and_exit $?
else
make $1 || exit $?
fi
}
function clean_build_dir() {
find ! -path "*.svn*" ! -name "*.bat" ! -name "*.sh" ! -name "." -print0 | xargs -0 rm -rf
}
function usage () {
echo "Usage: `basename $0` [--prefix /install_prefix|--build [debug|final]|--clean|--clang|--verbose|--libsuffix (32|64)|--help]"
cleanup_and_exit
}
cd ${BUILDDIR}
OPTIONS="--graphviz=${BUILDDIR}/csync.dot -DUNIT_TESTING=ON"
while test -n "$1"; do
PARAM="$1"
ARG="$2"
shift
case ${PARAM} in
*-*=*)
ARG=${PARAM#*=}
PARAM=${PARAM%%=*}
set -- "----noarg=${PARAM}" "$@"
esac
case ${PARAM} in
*-help|-h)
#echo_help
usage
cleanup_and_exit
;;
*-build)
DOMAKE="1"
BUILD_TYPE="${ARG}"
test -n "${BUILD_TYPE}" && shift
;;
*-clean)
clean_build_dir
cleanup_and_exit
;;
*-clang)
OPTIONS="${OPTIONS} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
;;
*-verbose)
DOVERBOSE="1"
;;
*-memtest)
OPTIONS="${OPTIONS} -DMEM_NULL_TESTS=ON"
;;
*-libsuffix)
OPTIONS="${OPTIONS} -DLIB_SUFFIX=${ARG}"
shift
;;
*-prefix)
OPTIONS="${OPTIONS} -DCMAKE_INSTALL_PREFIX=${ARG}"
shift
;;
*-sysconfdir)
OPTIONS="${OPTIONS} -DSYSCONF_INSTALL_DIR=${ARG}"
shift
;;
----noarg)
echo "$ARG does not take an argument"
cleanup_and_exit
;;
-*)
echo Unknown Option "$PARAM". Exit.
cleanup_and_exit 1
;;
*)
usage
;;
esac
done
if [ ${DOMAKE} -eq 1 ]; then
OPTIONS="${OPTIONS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
fi
if [ -n "${DOVERBOSE}" ]; then
OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=1"
else
OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=0"
fi
test -f "${BUILDDIR}/.build.log" && rm -f ${BUILDDIR}/.build.log
touch ${BUILDDIR}/.build.log
# log everything from here to .build.log
exec 1> >(exec -a 'build logging tee' tee -a ${BUILDDIR}/.build.log) 2>&1
echo "${HOST} started build at $(date)."
echo
configure ${OPTIONS} "$@"
if [ -n "${DOMAKE}" ]; then
test -n "${DOVERBOSE}" && compile VERBOSE=1 || compile
fi
DOT=$(which dot 2>/dev/null)
if [ -n "${DOT}" ]; then
${DOT} -Tpng -o${BUILDDIR}/csync.png ${BUILDDIR}/csync.dot
${DOT} -Tsvg -o${BUILDDIR}/csync.svg ${BUILDDIR}/csync.dot
fi
exec >&0 2>&0 # so that the logging tee finishes
sleep 1 # wait till tee terminates
cleanup_and_exit 0
-57
Ver Arquivo
@@ -1,57 +0,0 @@
project(client C)
set(CLIENT_PUBLIC_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}
CACHE INTERNAL "csync client public include directories"
)
set(CLIENT_PRIVATE_INCLUDE_DIRS
${CMAKE_BINARY_DIR}
${CSYNC_PUBLIC_INCLUDE_DIRS}
${CSTDLIB_PUBLIC_INCLUDE_DIRS}
${ARGP_INCLUDE_DIRS}
)
set(CLIENT_EXECUTABLE
csync_client
CACHE INTERNAL "csync client"
)
set(CLIENT_LINK_LIBRARIES
${CLIENT_EXECUTABLE}
${CSYNC_LIBRARY}
)
if(NOT LINUX)
list(APPEND CLIENT_LINK_LIBRARIES ${ARGP_LIBRARIES})
endif()
set(client_SRCS
csync_client.c
csync_auth.c
)
include_directories(
${CLIENT_PUBLIC_INCLUDE_DIRS}
${CLIENT_PRIVATE_INCLUDE_DIRS}
${CSYNC_PUBLIC_INCLUDE_DIRS}
)
add_executable(${CLIENT_EXECUTABLE} ${client_SRCS})
target_link_libraries(${CLIENT_LINK_LIBRARIES})
set_target_properties(
${CLIENT_EXECUTABLE}
PROPERTIES
OUTPUT_NAME
csync
)
install(
TARGETS
csync_client
DESTINATION
${BIN_INSTALL_DIR}
)
-292
Ver Arquivo
@@ -1,292 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008 by Andreas Schneider <asn@cryptomilk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "csync_auth.h"
#include "c_macro.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/**
* @internal
*
* @brief Get the password from the console.
*
* @param[in] prompt The prompt to display.
*
* @param[in] buf The buffer to fill.
*
* @param[in] len The length of the buffer.
*
* @param[in] verify Should the password be verified?
*
* @return 1 on success, 0 on error.
*/
static int csync_gets(const char *prompt, char *buf, size_t len, int verify) {
char *tmp;
char *ptr = NULL;
int ok = 0;
tmp = malloc(len);
if (tmp == NULL) {
return 0;
}
memset(tmp,'\0',len);
/* read the password */
while (!ok) {
if (buf[0] != '\0') {
fprintf(stdout, "%s[%s] ", prompt, buf);
} else {
fprintf(stdout, "%s", prompt);
}
fflush(stdout);
if (fgets(tmp, len, stdin) == NULL) {
return 0;
}
if ((ptr = strchr(tmp, '\n'))) {
*ptr = '\0';
}
fprintf(stdout, "\n");
if (*tmp) {
strncpy(buf, tmp, len);
}
if (verify) {
char *key_string;
key_string = malloc(len);
if (key_string == NULL) {
break;
}
memset(key_string, '\0', len);
fprintf(stdout, "\nVerifying, please re-enter. %s", prompt);
fflush(stdout);
if (! fgets(key_string, len, stdin)) {
memset(key_string, '\0', len);
SAFE_FREE(key_string);
clearerr(stdin);
continue;
}
if ((ptr = strchr(key_string, '\n'))) {
*ptr = '\0';
}
fprintf(stdout, "\n");
if (strcmp(buf, key_string)) {
printf("\n\07\07Mismatch - try again\n");
memset(key_string, '\0', len);
SAFE_FREE(key_string);
fflush(stdout);
continue;
}
memset(key_string, '\0', len);
SAFE_FREE(key_string);
}
ok = 1;
}
memset(tmp, '\0', len);
free(tmp);
return ok;
}
#ifdef _WIN32
#include <windows.h>
int csync_getpass(const char *prompt,
char *buf,
size_t len,
int echo,
int verify,
void *userdata
) {
/* unused variables */
(void) userdata;
HANDLE h;
DWORD mode = 0;
int ok;
/* fgets needs at least len - 1 */
if (prompt == NULL || buf == NULL || len < 2) {
return -1;
}
/* get stdin and mode */
h = GetStdHandle(STD_INPUT_HANDLE);
if (!GetConsoleMode(h, &mode)) {
return -1;
}
/* disable echo */
if (!echo) {
if (!SetConsoleMode(h, mode & ~ENABLE_ECHO_INPUT)) {
return -1;
}
}
ok = csync_gets(prompt, buf, len, verify);
/* reset echo */
SetConsoleMode(h, mode);
if (!ok) {
memset (buf, '\0', len);
return -1;
}
/* force termination */
buf[len - 1] = '\0';
return 0;
}
#else
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
/**
*
* @brief Get a password from the console.
*
* You should make sure that the buffer is an empty string!
*
* You can also use this function to ask for a username. Then you can fill the
* buffer with the username and it is shows to the users. If the users just
* presses enter the buffer will be untouched.
*
* @code
* char username[128];
*
* snprintf(username, sizeof(username), "john");
*
* csync_getpass("Username:", username, sizeof(username), 1, 0);
* @endcode
*
* The prompt will look like this:
*
* Username: [john]
*
* If you press enter then john is used as the username, or you can type it in
* to change it.
*
* @param[in] prompt The prompt to show to ask for the password.
*
* @param[out] buf The buffer the password should be stored. It NEEDS to be
* empty or filled out.
*
* @param[in] len The length of the buffer.
*
* @param[in] echo Should we echo what you type.
*
* @param[in] verify Should we ask for the password twice.
*
* @return 0 on success, -1 on error.
*/
int csync_getpass(const char *prompt,
char *buf,
size_t len,
int echo,
int verify,
void *userdata
) {
struct termios attr;
struct termios old_attr;
int ok = 0;
int fd = -1;
/* unused variables */
(void) userdata;
/* fgets needs at least len - 1 */
if (prompt == NULL || buf == NULL || len < 2) {
return -1;
}
if (isatty(STDIN_FILENO)) {
ZERO_STRUCT(attr);
ZERO_STRUCT(old_attr);
/* get local terminal attributes */
if (tcgetattr(STDIN_FILENO, &attr) < 0) {
perror("tcgetattr");
return -1;
}
/* save terminal attributes */
memcpy(&old_attr, &attr, sizeof(attr));
if((fd = fcntl(0, F_GETFL, 0)) < 0) {
perror("fcntl");
return -1;
}
/* disable echo */
if (!echo) {
attr.c_lflag &= ~(ECHO);
}
/* write attributes to terminal */
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr) < 0) {
perror("tcsetattr");
return -1;
}
}
/* disable nonblocking I/O */
if (fd & O_NDELAY) {
fcntl(0, F_SETFL, fd & ~O_NDELAY);
}
ok = csync_gets(prompt, buf, len, verify);
if (isatty(STDIN_FILENO)) {
/* reset terminal */
tcsetattr(STDIN_FILENO, TCSANOW, &old_attr);
}
/* close fd */
if (fd & O_NDELAY) {
fcntl(0, F_SETFL, fd);
}
if (!ok) {
memset (buf, '\0', len);
return -1;
}
/* force termination */
buf[len - 1] = '\0';
return 0;
}
#endif
/* vim: set ts=8 sw=2 et cindent: */
-31
Ver Arquivo
@@ -1,31 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008 by Andreas Schneider <asn@cryptomilk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* vim: ft=c.doxygen ts=2 sw=2 et cindent
*/
#ifndef _CSYNC_CLIENT_AUTH_H
#define _CSYNC_CLIENT_AUTH_H
#include <stddef.h>
int csync_getpass(const char *prompt, char *buf, size_t len, int echo, int verify,
void *userdata);
#endif /* _CSYNC_CLIENT_AUTH_H */
-349
Ver Arquivo
@@ -1,349 +0,0 @@
/*
* libcsync -- a library to sync a replica with another
*
* Copyright (c) 2006-2007 by Andreas Schneider <asn@cryptomilk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <csync.h>
#include <c_string.h>
#include <c_alloc.h>
#include "csync_auth.h"
#include "../src/std/c_private.h"
#include "../src/csync_misc.h"
const char *csync_program_version = "csync commandline client "
CSYNC_STRINGIFY(LIBCSYNC_VERSION);
/* Program documentation. */
static char doc[] = "Usage: csync [OPTION...] LOCAL REMOTE\n\
csync -- a user level file synchronizer which synchronizes the files\n\
at LOCAL with the ones at REMOTE.\n\
\n\
-c, --conflict-copys Create conflict copys if file changed on both\n\
sides.\n\
-d, --debug-level=DEBUGLVL Set debug level\n\
--disable-statedb Disable the usage and creation of a statedb.\n\
--dry-run This runs only update detection and reconcilation.\n\
\n\
--exclude-file=<file> Add an additional exclude file\n"
#ifdef WITH_ICONV
" --iconv=codec Request charset conversion of local filenames\n"
#endif
" --test-statedb Test creation of the statedb. Runs update\n\
detection.\n\
--test-update Test the update detection\n\
-?, --help Give this help list\n\
--usage Give a short usage message\n\
-v, --verbose Print progress information about up- and download.\n\
-V, --version Print program version\n\
";
/* The options we understand. */
static const struct option long_options[] =
{
{"exclude-file", required_argument, 0, 0 },
{"debug-level", required_argument, 0, 'd' },
{"disable-statedb", no_argument, 0, 0 },
#ifdef WITH_ICONV
{"iconv", required_argument, 0, 0 },
#endif
{"dry-run", no_argument, 0, 0 },
{"test-statedb", no_argument, 0, 0 },
{"conflict-copies", no_argument, 0, 'c' },
{"test-update", no_argument, 0, 0 },
{"verbose", no_argument, 0, 'v' },
{"version", no_argument, 0, 'V' },
{"usage", no_argument, 0, 'h' },
{0, 0, 0, 0}
};
/* Used by main to communicate with parse_opt. */
struct argument_s {
char *args[2]; /* SOURCE and DESTINATION */
char *exclude_file;
int debug_level;
char *iconv;
int disable_statedb;
int create_statedb;
int update;
int reconcile;
int propagate;
int verbose;
bool with_conflict_copys;
};
static void print_version()
{
printf( "%s\n", csync_program_version );
exit(0);
}
static void print_help()
{
printf( "%s\n", doc );
exit(0);
}
static int c_atoi(const char *string, int *result)
{
char *end = NULL;
int i;
if (string == NULL) {
return -1;
}
i = strtol(string, &end, 10);
if (!(end != NULL && end[0] == '\0')) {
/* error case, the input string had an error. */
return -1;
}
*result = i;
return 0;
}
static int parse_args(struct argument_s *csync_args, int argc, char **argv)
{
while(optind < argc) {
int c = -1;
int rc;
struct option *opt = NULL;
int result = getopt_long( argc, argv, "d:cvVh", long_options, &c );
if( result == -1 ) {
break;
}
switch(result) {
case 'd':
rc = c_atoi(optarg, &csync_args->debug_level);
if (rc < 0) {
fprintf(stderr, "Can't parse debug level argument");
}
break;
case 'c':
csync_args->with_conflict_copys = true;
/* printf("Argument: With conflict copies\n"); */
break;
case 'v':
csync_args->verbose = 1;
break;
case 'V':
print_version();
break;
case 'h':
print_help();
break;
case 0:
opt = (struct option*)&(long_options[c]);
if(c_streq(opt->name, "exclude-file")) {
if (optarg != NULL) {
csync_args->exclude_file = c_strdup(optarg);
/* printf("Argument: exclude-file: %s\n", csync_args->exclude_file); */
}
} else if(c_streq(opt->name, "debug-level")) {
rc = c_atoi(optarg, &csync_args->debug_level);
if (rc < 0) {
fprintf(stderr, "Can't parse debug level argument");
}
} else if(c_streq(opt->name, "disable-statedb")) {
csync_args->disable_statedb = 1;
} else if(c_streq(opt->name, "test-update")) {
csync_args->create_statedb = 0;
csync_args->update = 1;
csync_args->reconcile = 0;
csync_args->propagate = 0;
/* printf("Argument: test-update\n"); */
} else if(c_streq(opt->name, "dry-run")) {
csync_args->create_statedb = 0;
csync_args->update = 1;
csync_args->reconcile = 1;
csync_args->propagate = 0;
/* printf("Argument: dry-run\n" ); */
} else if(c_streq(opt->name, "iconv")) {
if (optarg != NULL) {
csync_args->iconv = c_strdup(optarg);
/* printf("Argument: iconv\n" ); */
}
} else if(c_streq(opt->name, "test-statedb")) {
csync_args->create_statedb = 1;
csync_args->update = 1;
csync_args->reconcile = 0;
csync_args->propagate = 0;
/* printf("Argument: test-statedb\n"); */
} else {
fprintf(stderr, "Argument: No idea what!\n");
}
break;
default:
break;
}
}
return optind;
}
static void _overall_callback(const char *file_name,
int file_no,
int file_cnt,
long long o1,
long long o2,
void *userdata)
{
(void) userdata;
printf("File #%2d/%2d: %s (%lld/%lld bytes)\n", file_no, file_cnt, file_name, o1, o2 );
}
int main(int argc, char **argv) {
int rc = 0;
CSYNC *csync;
char errbuf[256] = {0};
int curser = 0;
int i;
struct argument_s arguments;
/* Default values. */
arguments.exclude_file = NULL;
arguments.debug_level = 4;
arguments.iconv = NULL;
arguments.disable_statedb = 0;
arguments.create_statedb = 0;
arguments.update = 1;
arguments.reconcile = 1;
arguments.propagate = 1;
arguments.with_conflict_copys = false;
arguments.verbose = 0;
parse_args(&arguments, argc, argv);
/* two options must remain as source and target */
/* printf("ARGC: %d -> optind: %d\n", argc, optind ); */
if( argc - optind < 2 ) {
print_help();
}
if (arguments.debug_level) {
csync_set_log_level(arguments.debug_level);
}
if (csync_create(&csync, argv[optind], argv[optind+1]) < 0) {
fprintf(stderr, "csync_create: failed\n");
exit(1);
}
/*
* Protect password from ps listing
* Find and replace :password@ by :********@
*/
for (i = 0; i < argc; i++) {
if (csync_fnmatch("*://*:*@*", argv[i], 0) == 0) {
curser = strlen(argv[i]);
while(curser > 0 && argv[i][curser] != '@') {
curser--;
}
while(curser > 0 && argv[i][curser - 1] != ':') {
curser--;
argv[i][curser] = '*';
}
}
}
csync_set_auth_callback(csync, csync_getpass);
if (arguments.disable_statedb) {
csync_disable_statedb(csync);
}
#ifdef WITH_ICONV
if (arguments.iconv) {
csync_set_iconv_codec(arguments.iconv);
}
#endif
if(arguments.with_conflict_copys)
{
csync_enable_conflictcopys(csync);
}
if (csync_init(csync) < 0) {
perror("csync_init");
rc = 1;
goto out;
}
if (arguments.verbose > 0) {
csync_set_overall_progress_callback(csync, _overall_callback);
}
if (arguments.exclude_file != NULL) {
if (csync_add_exclude_list(csync, arguments.exclude_file) < 0) {
strerror_r(errno, errbuf, sizeof(errbuf));
fprintf(stderr, "csync_add_exclude_list - %s: %s\n",
arguments.exclude_file, errbuf);
rc = 1;
goto out;
}
}
if (arguments.update) {
if (csync_update(csync) < 0) {
perror("csync_update");
rc = 1;
goto out;
}
}
if (arguments.reconcile) {
if (csync_reconcile(csync) < 0) {
perror("csync_reconcile");
rc = 1;
goto out;
}
}
if (arguments.propagate) {
if (csync_propagate(csync) < 0) {
perror("csync_propagate");
rc = 1;
goto out;
}
}
if (arguments.create_statedb) {
csync_set_status(csync, 0xFFFF);
}
out:
csync_destroy(csync);
return rc;
}
-23
Ver Arquivo
@@ -1,23 +0,0 @@
# - ADD_CHECK_TEST(test_name test_source linklib1 ... linklibN)
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007-2010 Andreas Schneider <asn@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
enable_testing()
include(CTest)
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
set(CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
function (ADD_CMOCKA_TEST _testName _testSource)
add_executable(${_testName} ${_testSource})
target_link_libraries(${_testName} ${ARGN})
add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
endfunction (ADD_CMOCKA_TEST)
-22
Ver Arquivo
@@ -1,22 +0,0 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-26
Ver Arquivo
@@ -1,26 +0,0 @@
# - Check whether the C compiler supports a given flag in the
# context of a stack checking compiler option.
# CHECK_C_COMPILER_FLAG_SSP(FLAG VARIABLE)
#
# FLAG - the compiler flag
# VARIABLE - variable to store the result
#
# This actually calls check_c_source_compiles.
# See help for CheckCSourceCompiles for a listing of variables
# that can modify the build.
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckCSourceCompiles)
function(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT})
set(CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
endfunction(CHECK_C_COMPILER_FLAG_SSP)
-27
Ver Arquivo
@@ -1,27 +0,0 @@
# Always include srcdir and builddir in include path
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
# about every subdir
# since cmake 2.4.0
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Put the include dirs which are in the source or build tree
# before all other include dirs, so the headers in the sources
# are prefered over the already installed ones
# since cmake 2.4.1
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# Use colored output
# since cmake 2.4.0
set(CMAKE_COLOR_MAKEFILE ON)
# Define the generic version of the libraries here
set(GENERIC_LIB_VERSION "0.1.0")
set(GENERIC_LIB_SOVERSION "0")
# Set the default build type to release with debug info
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo
CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
)
endif (NOT CMAKE_BUILD_TYPE)
-77
Ver Arquivo
@@ -1,77 +0,0 @@
# define system dependent compiler flags
include(CheckCCompilerFlag)
include(CheckCCompilerFlagSSP)
if (UNIX AND NOT WIN32)
#
# Define GNUCC compiler flags
#
if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
# add -Wconversion ?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
# with -fPIC
check_c_compiler_flag("-fPIC" WITH_FPIC)
if (WITH_FPIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif (WITH_FPIC)
check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
if (WITH_STACK_PROTECTOR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
endif (WITH_STACK_PROTECTOR)
if (CMAKE_BUILD_TYPE)
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel))
check_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
if (WITH_FORTIFY_SOURCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-D_FORTIFY_SOURCE=2")
endif (WITH_FORTIFY_SOURCE)
endif()
endif()
endif (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
#
# Check for large filesystem support
#
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support
execute_process(
COMMAND
getconf LFS64_CFLAGS
OUTPUT_VARIABLE
_lfs_CFLAGS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support
execute_process(
COMMAND
getconf LFS_CFLAGS
OUTPUT_VARIABLE
_lfs_CFLAGS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
if (_lfs_CFLAGS)
string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}")
endif (_lfs_CFLAGS)
endif (UNIX AND NOT WIN32)
if (MSVC)
# Use secure functions by defaualt and suppress warnings about
#"deprecated" functions
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_NONSTDC_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1")
endif (MSVC)
-110
Ver Arquivo
@@ -1,110 +0,0 @@
if (UNIX)
IF (NOT APPLICATION_NAME)
MESSAGE(STATUS "${PROJECT_NAME} is used as APPLICATION_NAME")
SET(APPLICATION_NAME ${PROJECT_NAME})
ENDIF (NOT APPLICATION_NAME)
# Suffix for Linux
SET(LIB_SUFFIX
CACHE STRING "Define suffix of directory name (32/64)"
)
SET(EXEC_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}"
CACHE PATH "Base directory for executables and libraries"
)
SET(SHARE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}/share"
CACHE PATH "Base directory for files which go to share/"
)
SET(DATA_INSTALL_PREFIX
"${SHARE_INSTALL_PREFIX}/${APPLICATION_NAME}"
CACHE PATH "The parent directory where applications can install their data")
# The following are directories where stuff will be installed to
SET(BIN_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/bin"
CACHE PATH "The ${APPLICATION_NAME} binary install dir (default prefix/bin)"
)
SET(SBIN_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/sbin"
CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
)
SET(LIB_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/lib)"
)
SET(LIBEXEC_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/libexec"
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/libexec)"
)
SET(PLUGIN_INSTALL_DIR
"${LIB_INSTALL_DIR}/${APPLICATION_NAME}"
CACHE PATH "The subdirectory relative to the install prefix where plugins will be installed (default is prefix/lib/${APPLICATION_NAME})"
)
SET(INCLUDE_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/include"
CACHE PATH "The subdirectory to the header prefix (default prefix/include)"
)
SET(DATA_INSTALL_DIR
"${DATA_INSTALL_PREFIX}"
CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})"
)
SET(HTML_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/doc/HTML"
CACHE PATH "The HTML install dir for documentation (default data/doc/html)"
)
SET(ICON_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/icons"
CACHE PATH "The icon install dir (default data/icons/)"
)
SET(SOUND_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/sounds"
CACHE PATH "The install dir for sound files (default data/sounds)"
)
SET(LOCALE_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/locale"
CACHE PATH "The install dir for translations (default prefix/share/locale)"
)
SET(XDG_APPS_DIR
"${SHARE_INSTALL_PREFIX}/applications/"
CACHE PATH "The XDG apps dir"
)
SET(XDG_DIRECTORY_DIR
"${SHARE_INSTALL_PREFIX}/desktop-directories"
CACHE PATH "The XDG directory"
)
SET(SYSCONF_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/etc"
CACHE PATH "The ${APPLICATION_NAME} sysconfig install dir (default prefix/etc)"
)
SET(MAN_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/man"
CACHE PATH "The ${APPLICATION_NAME} man install dir (default prefix/man)"
)
SET(INFO_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/info"
CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
)
endif (UNIX)
if (WIN32)
# Same same
set(BIN_INSTALL_DIR "." CACHE PATH "-")
set(SBIN_INSTALL_DIR "." CACHE PATH "-")
set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
set(ICON_INSTALL_DIR "." CACHE PATH "-")
set(SOUND_INSTALL_DIR "." CACHE PATH "-")
set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
set(SYSCONF_INSTALL_DIR "." CACHE PATH "-")
set(MAN_INSTALL_DIR "." CACHE PATH "-")
set(SHARE_INSTALL_PREFIX "." CACHE PATH "-")
endif (WIN32)
-28
Ver Arquivo
@@ -1,28 +0,0 @@
# Set system vars
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX TRUE)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(FREEBSD TRUE)
set(BSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set(OPENBSD TRUE)
set(BSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(NETBSD TRUE)
set(BSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
set(SOLARIS TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
if (CMAKE_SYSTEM_NAME MATCHES "OS2")
set(OS2 TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OS2")
-49
Ver Arquivo
@@ -1,49 +0,0 @@
# - Try to find CMocka
# Once done this will define
#
# CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka
#
# Read-Only variables:
# CMOCKA_FOUND - system has CMocka
# CMOCKA_INCLUDE_DIR - the CMocka include directory
# CMOCKA_LIBRARIES - Link these to use CMocka
# CMOCKA_DEFINITIONS - Compiler switches required for using CMocka
#
#=============================================================================
# Copyright (c) 2011-2012 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
find_path(CMOCKA_INCLUDE_DIR
NAMES
cmocka.h
PATHS
${CMOCKA_ROOT_DIR}/include
)
find_library(CMOCKA_LIBRARY
NAMES
cmocka
PATHS
${CMOCKA_ROOT_DIR}/include
)
if (CMOCKA_LIBRARY)
set(CMOCKA_LIBRARIES
${CMOCKA_LIBRARIES}
${CMOCKA_LIBRARY}
)
endif (CMOCKA_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)
# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view
mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES)
-82
Ver Arquivo
@@ -1,82 +0,0 @@
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIRS - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_DEFINITIONS - Compiler switches required for using Iconv
#
# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckPrototypeDefinition)
find_path(ICONV_INCLUDE_DIR
NAMES
iconv.h sys/iconv.h
)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
check_include_file(iconv.h HAVE_ICONV_H)
check_include_file(sys/iconv.h HAVE_SYS_ICONV_H)
set(CMAKE_REQUIRED_INCLUDES)
find_library(ICONV_LIBRARY
NAMES
iconv
libiconv
PATHS
)
if (ICONV_LIBRARY)
get_filename_component(_ICONV_NAME ${ICONV_LIBRARY} NAME)
get_filename_component(_ICONV_PATH ${ICONV_LIBRARY} PATH)
check_library_exists(${_ICONV_NAME} iconv ${_ICONV_PATH} HAVE_ICONV)
else()
check_function_exists(iconv HAVE_ICONV)
endif()
if (HAVE_ICONV_H OR HAVE_SYS_ICONV_H)
if (HAVE_ICONV_H)
set(_ICONV_PROTO_INCLUDE "iconv.h")
endif (HAVE_ICONV_H)
if (HAVE_SYS_ICONV_H)
set(_ICONV_PROTO_INCLUDE "sys/iconv.h")
endif (HAVE_SYS_ICONV_H)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
check_prototype_definition(iconv
"size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)"
"-1"
${_ICONV_PROTO_INCLUDE}
HAVE_ICONV_CONST)
set(CMAKE_REQUIRED_INCLUDES)
endif (HAVE_ICONV_H OR HAVE_SYS_ICONV_H)
set(ICONV_INCLUDE_DIRS
${ICONV_INCLUDE_DIR}
)
if (ICONV_LIBRARY)
set(ICONV_LIBRARIES
${ICONV_LIBRARIES}
${ICONV_LIBRARY}
)
endif (ICONV_LIBRARY)
include(FindPackageHandleStandardArgs)
if (ICONV_LIBRARIES)
find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_LIBRARIES ICONV_INCLUDE_DIRS)
else()
find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_INCLUDE_DIRS)
endif()
# show the ICONV_INCLUDE_DIRS and ICONV_LIBRARIES variables only in the advanced view
mark_as_advanced(ICONV_INCLUDE_DIRS ICONV_LIBRARIES)
-96
Ver Arquivo
@@ -1,96 +0,0 @@
# - Try to find LibSSH
# Once done this will define
#
# LIBSSH_FOUND - system has LibSSH
# LIBSSH_INCLUDE_DIRS - the LibSSH include directory
# LIBSSH_LIBRARIES - Link these to use LibSSH
# LIBSSH_DEFINITIONS - Compiler switches required for using LibSSH
#
# Copyright (c) 2009 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (LIBSSH_LIBRARIES AND LIBSSH_INCLUDE_DIRS)
# in cache already
set(LIBSSH_FOUND TRUE)
else (LIBSSH_LIBRARIES AND LIBSSH_INCLUDE_DIRS)
find_path(LIBSSH_INCLUDE_DIR
NAMES
libssh/libssh.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include
)
find_library(SSH_LIBRARY
NAMES
ssh
libssh
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
)
if (LIBSSH_INCLUDE_DIR AND SSH_LIBRARY)
set(SSH_FOUND TRUE)
endif (LIBSSH_INCLUDE_DIR AND SSH_LIBRARY)
set(LIBSSH_INCLUDE_DIRS
${LIBSSH_INCLUDE_DIR}
)
if (SSH_FOUND)
set(LIBSSH_LIBRARIES
${LIBSSH_LIBRARIES}
${SSH_LIBRARY}
)
if (LibSSH_FIND_VERSION)
file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MAJOR
REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+")
# Older versions of libssh like libssh-0.2 have LIBSSH_VERSION but not LIBSSH_VERSION_MAJOR
if (LIBSSH_VERSION_MAJOR)
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR})
file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MINOR
REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+")
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR})
file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_PATCH
REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+")
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH})
set(LibSSH_VERSION ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH})
include(FindPackageVersionCheck)
find_package_version_check(LibSSH DEFAULT_MSG)
else (LIBSSH_VERSION_MAJOR)
message(STATUS "LIBSSH_VERSION_MAJOR not found in ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h, assuming libssh is too old")
set(LIBSSH_FOUND FALSE)
endif (LIBSSH_VERSION_MAJOR)
endif (LibSSH_FIND_VERSION)
endif (SSH_FOUND)
# If the version is too old, but libs and includes are set,
# find_package_handle_standard_args will set LIBSSH_FOUND to TRUE again,
# so we need this if() here.
if (LIBSSH_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibSSH DEFAULT_MSG LIBSSH_LIBRARIES LIBSSH_INCLUDE_DIRS)
endif (LIBSSH_FOUND)
# show the LIBSSH_INCLUDE_DIRS and LIBSSH_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES)
endif (LIBSSH_LIBRARIES AND LIBSSH_INCLUDE_DIRS)
-57
Ver Arquivo
@@ -1,57 +0,0 @@
# - Try to find Neon
# Once done this will define
#
# NEON_FOUND - system has Neon
# NEON_INCLUDE_DIRS - the Neon include directory
# NEON_LIBRARIES - Link these to use Neon
# NEON_DEFINITIONS - Compiler switches required for using Neon
#
# Copyright (c) 2011-2013 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (UNIX)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_NEON neon)
endif (PKG_CONFIG_FOUND)
endif (UNIX)
find_path(NEON_INCLUDE_DIR
NAMES
neon/ne_basic.h
PATHS
${_NEON_INCLUDEDIR}
)
find_library(NEON_LIBRARY
NAMES
neon
PATHS
${_NEON_LIBDIR}
)
set(NEON_INCLUDE_DIRS
${NEON_INCLUDE_DIR}
)
if (NEON_LIBRARY)
set(NEON_LIBRARIES
${NEON_LIBRARIES}
${NEON_LIBRARY}
)
endif (NEON_LIBRARY)
if (Neon_FIND_VERSION AND _NEON_VERSION)
set(Neon_VERSION _NEON_VERSION)
endif (Neon_FIND_VERSION AND _NEON_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Neon DEFAULT_MSG NEON_LIBRARIES NEON_INCLUDE_DIRS)
# show the NEON_INCLUDE_DIRS and NEON_LIBRARIES variables only in the advanced view
mark_as_advanced(NEON_INCLUDE_DIRS NEON_LIBRARIES)
-68
Ver Arquivo
@@ -1,68 +0,0 @@
# FIND_PACKAGE_VERSION_CHECK(NAME (DEFAULT_MSG|"Custom failure message"))
# This function is intended to be used in FindXXX.cmake modules files.
# It handles NAME_FIND_VERSION and NAME_VERSION variables in a Module.
#
# Example:
# find_package(LibSSH 0.3.2)
#
# # check for the version and set it
# set(LibSSH_VERSION 0.3.0)
# find_package_version_check(LibSSH DEFAULT_MSG)
#
#
# Copyright (c) 2009 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
function(FIND_PACKAGE_VERSION_CHECK _NAME _FAIL_MSG)
string(TOUPPER ${_NAME} _NAME_UPPER)
set(_AGE "old")
if(${_NAME}_FIND_VERSION_EXACT)
if (${_NAME}_FIND_VERSION VERSION_EQUAL ${_NAME}_VERSION)
# exact version found
set(${_NAME_UPPER}_FOUND TRUE)
else (${_NAME}_FIND_VERSION VERSION_EQUAL ${_NAME}_VERSION)
# exect version not found
set(${_NAME_UPPER}_FOUND FALSE)
# check if newer or older
if (${_NAME}_FIND_VERSION VERSION_LESS ${_NAME}_VERSION)
set(_AGE "new")
else (${_NAME}_FIND_VERSION VERSION_LESS ${_NAME}_VERSION)
set(_AGE "old")
endif (${_NAME}_FIND_VERSION VERSION_LESS ${_NAME}_VERSION)
endif (${_NAME}_FIND_VERSION VERSION_EQUAL ${_NAME}_VERSION)
else (${_NAME}_FIND_VERSION_EXACT)
if (${_NAME}_FIND_VERSION)
if (${_NAME}_VERSION VERSION_LESS ${_NAME}_FIND_VERSION)
set(${_NAME_UPPER}_FOUND FALSE)
set(_AGE "old")
else (${_NAME}_VERSION VERSION_LESS ${_NAME}_FIND_VERSION)
set(${_NAME_UPPER}_FOUND TRUE)
endif (${_NAME}_VERSION VERSION_LESS ${_NAME}_FIND_VERSION)
endif (${_NAME}_FIND_VERSION)
endif(${_NAME}_FIND_VERSION_EXACT)
if ("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
if (${_NAME}_FIND_VERSION_EXACT)
set(_FAIL_MESSAGE "The installed ${_NAME} version ${${_NAME}_VERSION} is too ${_AGE}, version ${${_NAME}_FIND_VERSION} is required.")
else (${_NAME}_FIND_VERSION_EXACT)
set(_FAIL_MESSAGE "The installed ${_NAME} version ${${_NAME}_VERSION} is too ${_AGE}, at least version ${${_NAME}_FIND_VERSION} is required.")
endif (${_NAME}_FIND_VERSION_EXACT)
else ("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
set(_FAIL_MESSAGE "${_FAIL_MSG}")
endif ("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
if (NOT ${_NAME_UPPER}_FOUND)
if (${_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${_FAIL_MESSAGE}")
else (${_NAME}_FIND_REQUIRED)
if (NOT ${_NAME}_FIND_QUIETLY)
message(STATUS "${_FAIL_MESSAGE}")
endif (NOT ${_NAME}_FIND_QUIETLY)
endif (${_NAME}_FIND_REQUIRED)
endif (NOT ${_NAME_UPPER}_FOUND)
set(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
endfunction(FIND_PACKAGE_VERSION_CHECK)
-66
Ver Arquivo
@@ -1,66 +0,0 @@
# - Try to find SMBClient
# Once done this will define
#
# SMBCLIENT_FOUND - system has SMBClient
# SMBCLIENT_INCLUDE_DIRS - the SMBClient include directory
# SMBCLIENT_LIBRARIES - Link these to use SMBClient
# SMBCLIENT_DEFINITIONS - Compiler switches required for using SMBClient
#
# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (SMBCLIENT_LIBRARIES AND SMBCLIENT_INCLUDE_DIRS)
# in cache already
set(SMBCLIENT_FOUND TRUE)
else (SMBCLIENT_LIBRARIES AND SMBCLIENT_INCLUDE_DIRS)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_SMBCLIENT smbclient)
endif (PKG_CONFIG_FOUND)
find_path(SMBCLIENT_INCLUDE_DIR
NAMES
libsmbclient.h
PATHS
${_SMBCLIENT_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(SMBCLIENT_LIBRARY
NAMES
smbclient
PATHS
${_SMBCLIENT_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(SMBCLIENT_INCLUDE_DIRS
${SMBCLIENT_INCLUDE_DIR}
)
if (SMBCLIENT_LIBRARY)
set(SMBCLIENT_LIBRARIES
${SMBCLIENT_LIBRARIES}
${SMBCLIENT_LIBRARY}
)
endif (SMBCLIENT_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SMBClient DEFAULT_MSG SMBCLIENT_LIBRARIES SMBCLIENT_INCLUDE_DIRS)
# show the SMBCLIENT_INCLUDE_DIRS and SMBCLIENT_LIBRARIES variables only in the advanced view
mark_as_advanced(SMBCLIENT_INCLUDE_DIRS SMBCLIENT_LIBRARIES)
endif (SMBCLIENT_LIBRARIES AND SMBCLIENT_INCLUDE_DIRS)
-58
Ver Arquivo
@@ -1,58 +0,0 @@
# - Try to find SQLite3
# Once done this will define
#
# SQLITE3_FOUND - system has SQLite3
# SQLITE3_INCLUDE_DIRS - the SQLite3 include directory
# SQLITE3_LIBRARIES - Link these to use SQLite3
# SQLITE3_DEFINITIONS - Compiler switches required for using SQLite3
#
# Copyright (c) 2009-2013 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (UNIX)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_SQLITE3 sqlite3)
endif (PKG_CONFIG_FOUND)
endif (UNIX)
find_path(SQLITE3_INCLUDE_DIR
NAMES
sqlite3.h
PATHS
${_SQLITE3_INCLUDEDIR}
)
find_library(SQLITE3_LIBRARY
NAMES
sqlite3
PATHS
${_SQLITE3_LIBDIR}
)
set(SQLITE3_INCLUDE_DIRS
${SQLITE3_INCLUDE_DIR}
)
if (SQLITE3_LIBRARY)
set(SQLITE3_LIBRARIES
${SQLITE3_LIBRARIES}
${SQLITE3_LIBRARY}
)
endif (SQLITE3_LIBRARY)
if (SQLite3_FIND_VERSION AND _SQLITE3_VERSION)
set(SQLite3_VERSION _SQLITE3_VERSION)
endif (SQLite3_FIND_VERSION AND _SQLITE3_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLITE3_LIBRARIES SQLITE3_INCLUDE_DIRS)
# show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view
mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)
-21
Ver Arquivo
@@ -1,21 +0,0 @@
# - MACRO_ADD_COMPILE_FLAGS(target_name flag1 ... flagN)
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
# Copyright (c) 2006, Andreas Schneider, <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_COMPILE_FLAGS _target)
get_target_property(_flags ${_target} COMPILE_FLAGS)
if (_flags)
set(_flags ${_flags} ${ARGN})
else (_flags)
set(_flags ${ARGN})
endif (_flags)
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags})
endmacro (MACRO_ADD_COMPILE_FLAGS)
-20
Ver Arquivo
@@ -1,20 +0,0 @@
# - MACRO_ADD_LINK_FLAGS(target_name flag1 ... flagN)
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
# Copyright (c) 2006, Andreas Schneider, <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_LINK_FLAGS _target)
get_target_property(_flags ${_target} LINK_FLAGS)
if (_flags)
set(_flags "${_flags} ${ARGN}")
else (_flags)
set(_flags "${ARGN}")
endif (_flags)
set_target_properties(${_target} PROPERTIES LINK_FLAGS "${_flags}")
endmacro (MACRO_ADD_LINK_FLAGS)
-30
Ver Arquivo
@@ -1,30 +0,0 @@
# - MACRO_ADD_PLUGIN(name [WITH_PREFIX] file1 .. fileN)
#
# Create a plugin from the given source files.
# If WITH_PREFIX is given, the resulting plugin will have the
# prefix "lib", otherwise it won't.
#
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
# Copyright (c) 2006, Andreas Schneider, <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_PLUGIN _target_NAME _with_PREFIX)
if (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_first_SRC)
else (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_first_SRC ${_with_PREFIX})
endif (${_with_PREFIX} STREQUAL "WITH_PREFIX")
add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
if (_first_SRC)
set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
endif (_first_SRC)
endmacro (MACRO_ADD_PLUGIN _name _sources)
-33
Ver Arquivo
@@ -1,33 +0,0 @@
# - macro_copy_file(_src _dst)
# Copies a file to ${_dst} only if ${_src} is different (newer) than ${_dst}
#
# Example:
# macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/icon.png ${CMAKE_CURRENT_BINARY_DIR}/.)
# Copies file icon.png to ${CMAKE_CURRENT_BINARY_DIR} directory
#
# Copyright (c) 2006-2007 Wengo
# Copyright (c) 2006-2008 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING file.
macro (macro_copy_file _src _dst)
# Removes all path containing .svn or CVS or CMakeLists.txt during the copy
if (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
if (CMAKE_VERBOSE_MAKEFILE)
message(STATUS "Copy file from ${_src} to ${_dst}")
endif (CMAKE_VERBOSE_MAKEFILE)
# Creates directory if necessary
get_filename_component(_path ${_dst} PATH)
file(MAKE_DIRECTORY ${_path})
execute_process(
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${_src} ${_dst}
OUTPUT_QUIET
)
endif (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
endmacro (macro_copy_file)
@@ -1,17 +0,0 @@
# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource)
if (_insource)
message(SEND_ERROR "${_errorMessage}")
message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.")
endif (_insource)
endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)
-58
Ver Arquivo
@@ -1,58 +0,0 @@
# - macro_asciidoc2man(inputfile outputfile)
#
# Create a manpage with asciidoc.
# Example: macro_asciidoc2man(foo.txt foo.1)
#
# Copyright (c) 2006, Andreas Schneider, <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(MacroCopyFile)
macro(MACRO_ASCIIDOC2MAN _a2m_input _a2m_output)
find_program(A2X
NAMES
a2x
)
#message("+++ A2X: ${A2X}")
if (A2X)
#message("+++ ${A2X} --doctype=manpage --format=manpage --destination-dir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_a2m_input}")
macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_a2m_input} ${CMAKE_CURRENT_BINARY_DIR}/${_a2m_input})
execute_process(
COMMAND
${A2X} --doctype=manpage --format=manpage ${_a2m_input}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE
A2M_MAN_GENERATED
ERROR_QUIET
)
#message("+++ A2M_MAN_GENERATED: ${A2M_MAN_GENERATED}")
if (A2M_MAN_GENERATED EQUAL 0)
find_file(A2M_MAN_FILE
NAME
${_a2m_output}
PATHS
${CMAKE_CURRENT_BINARY_DIR}
NO_DEFAULT_PATH
)
if (A2M_MAN_FILE)
get_filename_component(A2M_MAN_CATEGORY ${A2M_MAN_FILE} EXT)
string(SUBSTRING ${A2M_MAN_CATEGORY} 1 1 A2M_MAN_CATEGORY)
install(
FILES
${A2M_MAN_FILE}
DESTINATION
${MAN_INSTALL_DIR}/man${A2M_MAN_CATEGORY}
)
endif (A2M_MAN_FILE)
endif (A2M_MAN_GENERATED EQUAL 0)
endif (A2X)
endmacro(MACRO_ASCIIDOC2MAN _a2m_input _a2m_file)
-127
Ver Arquivo
@@ -1,127 +0,0 @@
# -helper macro to add a "doc" target with CMake build system.
# and configure doxy.config.in to doxy.config
#
# target "doc" allows building the documentation with doxygen/dot on WIN32 and Linux
# Creates .chm windows help file if MS HTML help workshop
# (available from http://msdn.microsoft.com/workshop/author/htmlhelp)
# is installed with its DLLs in PATH.
#
#
# Please note, that the tools, e.g.:
# doxygen, dot, latex, dvips, makeindex, gswin32, etc.
# must be in path.
#
# Note about Visual Studio Projects:
# MSVS has its own path environment which may differ from the shell.
# See "Menu Tools/Options/Projects/VC++ Directories" in VS 7.1
#
# author Jan Woetzel 2004-2006
# www.mip.informatik.uni-kiel.de/~jw
FIND_PACKAGE(Doxygen)
IF (DOXYGEN_FOUND)
# click+jump in Emacs and Visual Studio (for doxy.config) (jw)
IF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
SET(DOXY_WARN_FORMAT "\"$file($line) : $text \"")
ELSE (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
SET(DOXY_WARN_FORMAT "\"$file:$line: $text \"")
ENDIF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
# we need latex for doxygen because of the formulas
FIND_PACKAGE(LATEX)
IF (NOT LATEX_COMPILER)
MESSAGE(STATUS "latex command LATEX_COMPILER not found but usually required. You will probably get warnings and user inetraction on doxy run.")
ENDIF (NOT LATEX_COMPILER)
IF (NOT MAKEINDEX_COMPILER)
MESSAGE(STATUS "makeindex command MAKEINDEX_COMPILER not found but usually required.")
ENDIF (NOT MAKEINDEX_COMPILER)
IF (NOT DVIPS_CONVERTER)
MESSAGE(STATUS "dvips command DVIPS_CONVERTER not found but usually required.")
ENDIF (NOT DVIPS_CONVERTER)
FIND_PROGRAM(DOXYGEN_DOT_EXECUTABLE_PATH NAMES dot)
IF (DOXYGEN_DOT_EXECUTABLE_PATH)
SET(DOXYGEN_DOT_FOUND "YES")
ENDIF (DOXYGEN_DOT_EXECUTABLE_PATH)
IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
MESSAGE(STATUS "Generate ${CMAKE_CURRENT_BINARY_DIR}/doxy.config from doxy.config.in")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in
${CMAKE_CURRENT_BINARY_DIR}/doxy.config
@ONLY )
# use (configured) doxy.config from (out of place) BUILD tree:
SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
# use static hand-edited doxy.config from SOURCE tree:
SET(DOXY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
MESSAGE(STATUS "WARNING: using existing ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config instead of configuring from doxy.config.in file.")
ELSE (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
IF (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
# using template doxy.config.in
MESSAGE(STATUS "Generate ${CMAKE_CURRENT_BINARY_DIR}/doxy.config from doxy.config.in")
CONFIGURE_FILE(${CMAKE_MODULE_PATH}/doxy.config.in
${CMAKE_CURRENT_BINARY_DIR}/doxy.config
@ONLY )
SET(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doxy.config")
ELSE (EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
# failed completely...
MESSAGE(SEND_ERROR "Please create ${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in (or doxy.config as fallback)")
ENDIF(EXISTS "${CMAKE_MODULE_PATH}/doxy.config.in")
ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config")
ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doxy.config.in")
ADD_CUSTOM_TARGET(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doxy.config)
# create a windows help .chm file using hhc.exe
# HTMLHelp DLL must be in path!
# fallback: use hhw.exe interactively
IF (WIN32)
FIND_PACKAGE(HTMLHelp)
IF (HTML_HELP_COMPILER)
SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\doc\\html\\index.hhp")
STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
# MESSAGE(SEND_ERROR "DBG HHP_FILE=${HHP_FILE}")
ADD_CUSTOM_TARGET(winhelp ${HTML_HELP_COMPILER} ${HHP_FILE})
ADD_DEPENDENCIES (winhelp doc)
IF (NOT TARGET_DOC_SKIP_INSTALL)
# install windows help?
# determine useful name for output file
# should be project and version unique to allow installing
# multiple projects into one global directory
IF (EXISTS "${PROJECT_BINARY_DIR}/doc/html/index.chm")
IF (PROJECT_NAME)
SET(OUT "${PROJECT_NAME}")
ELSE (PROJECT_NAME)
SET(OUT "Documentation") # default
ENDIF(PROJECT_NAME)
IF (${PROJECT_NAME}_VERSION_MAJOR)
SET(OUT "${OUT}-${${PROJECT_NAME}_VERSION_MAJOR}")
IF (${PROJECT_NAME}_VERSION_MINOR)
SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_MINOR}")
IF (${PROJECT_NAME}_VERSION_PATCH)
SET(OUT "${OUT}.${${PROJECT_NAME}_VERSION_PATCH}")
ENDIF(${PROJECT_NAME}_VERSION_PATCH)
ENDIF(${PROJECT_NAME}_VERSION_MINOR)
ENDIF(${PROJECT_NAME}_VERSION_MAJOR)
# keep suffix
SET(OUT "${OUT}.chm")
#MESSAGE("DBG ${PROJECT_BINARY_DIR}/doc/html/index.chm \n${OUT}")
# create target used by install and package commands
INSTALL(FILES "${PROJECT_BINARY_DIR}/doc/html/index.chm"
DESTINATION "doc"
RENAME "${OUT}"
)
ENDIF(EXISTS "${PROJECT_BINARY_DIR}/doc/html/index.chm")
ENDIF(NOT TARGET_DOC_SKIP_INSTALL)
ENDIF(HTML_HELP_COMPILER)
# MESSAGE(SEND_ERROR "HTML_HELP_COMPILER=${HTML_HELP_COMPILER}")
ENDIF (WIN32)
ENDIF(DOXYGEN_FOUND)
-154
Ver Arquivo
@@ -1,154 +0,0 @@
#!/usr/bin/env ruby
# Simple script to generate simple cmake modules for finding
# libraries (packages)
#
# usage: generate_findpackage_file
# then you will be prompted to enter the required parameters
#
#####################################################################
#
# Copyright (c) 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright (c) 2006 Andreas Schneider <asn@cryptomilk.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
require 'readline'
package=Readline.readline("Name of package: ")
name=Readline.readline("\nYour Name (for copyright): ")
email=Readline.readline("\nYour mail (for copyright): ")
pkgconfig=Readline.readline("\npkgconfig package name (e.g. \"libxml-2.0\", leave empty to skip pkgconfig): ")
header=Readline.readline("\nLook for header (e.g. \"jpeglib.h\" or \"libxml/xpath.h\"): ")
incSubDir=Readline.readline("\nLook for header subdir (e.g. \"libxml2\", empty to skip ): ")
libs=Readline.readline("\nLook for library (e.g. \"xml2\" or \"avcodec avutil\"): ")
t = Time.now
cmakeIncDirName=package.upcase+"_INCLUDE_DIR"
cmakeIncDirNames=package.upcase+"_INCLUDE_DIRS"
cmakeLibNames=package.upcase+"_LIBRARIES"
cmakeDefsName=package.upcase+"_DEFINITIONS"
cmakeFoundName=package.upcase+"_FOUND"
cmakeQuietName=package+"_FIND_QUIETLY"
cmakeRequiredName=package+"_FIND_REQUIRED"
file=File.new("Find#{package}.cmake", "w+")
file.printf("# - Try to find #{package}\n")
file.printf("# Once done this will define\n")
file.printf("#\n")
file.printf("# #{cmakeFoundName} - system has #{package}\n")
file.printf("# #{cmakeIncDirNames} - the #{package} include directory\n")
file.printf("# #{cmakeLibNames} - Link these to use #{package}\n")
file.printf("# #{cmakeDefsName} - Compiler switches required for using #{package}\n")
file.printf("#\n")
file.printf("# Copyright (c) #{t.year} #{name} <#{email}>\n")
file.printf("#\n")
file.printf("# Redistribution and use is allowed according to the terms of the New\n")
file.printf("# BSD license.\n")
file.printf("# For details see the accompanying COPYING-CMAKE-SCRIPTS file.\n")
file.printf("#\n")
file.printf("\n")
file.printf("\n")
file.printf("if (#{cmakeLibNames} AND #{cmakeIncDirNames})\n")
file.printf(" # in cache already\n")
file.printf(" set(#{cmakeFoundName} TRUE)\n")
file.printf("else (#{cmakeLibNames} AND #{cmakeIncDirNames})\n")
if not pkgconfig.empty?
file.printf(" find_package(PkgConfig)\n")
file.printf(" if (PKG_CONFIG_FOUND)\n")
file.printf(" pkg_check_modules(_#{package.upcase} #{pkgconfig})\n")
file.printf(" endif (PKG_CONFIG_FOUND)\n")
end
file.printf("\n")
file.printf(" find_path(#{cmakeIncDirName}\n")
file.printf(" NAMES\n")
file.printf(" #{header}\n")
file.printf(" PATHS\n")
if not pkgconfig.empty?
file.printf(" ${_#{package.upcase}_INCLUDEDIR}\n")
end
file.printf(" /usr/include\n")
file.printf(" /usr/local/include\n")
file.printf(" /opt/local/include\n")
file.printf(" /sw/include\n")
if not incSubDir.empty?
file.printf(" PATH_SUFFIXES\n")
file.printf(" #{incSubDir}\n")
end
file.printf(" )\n")
file.printf("\n")
libs.split(" ").each do |lib|
file.printf(" find_library(#{lib.upcase}_LIBRARY\n")
file.printf(" NAMES\n")
file.printf(" #{lib}\n")
file.printf(" PATHS\n")
if not pkgconfig.empty?
file.printf(" ${_#{package.upcase}_LIBDIR}\n")
end
file.printf(" /usr/lib\n")
file.printf(" /usr/local/lib\n")
file.printf(" /opt/local/lib\n")
file.printf(" /sw/lib\n")
file.printf(" )\n")
file.printf("\n")
end
file.printf(" set(#{cmakeIncDirNames}\n")
file.printf(" ${#{cmakeIncDirName}}\n")
file.printf(" )\n")
file.printf("\n")
libs.split(" ").each do |lib|
file.printf(" if (#{lib.upcase}_LIBRARY)\n")
file.printf(" set(#{cmakeLibNames}\n")
file.printf(" ${#{cmakeLibNames}}\n")
file.printf(" ${#{lib.upcase}_LIBRARY}\n")
file.printf(" )\n")
file.printf(" endif (#{lib.upcase}_LIBRARY)\n")
file.printf("\n")
end
file.printf(" include(FindPackageHandleStandardArgs)\n")
file.printf(" find_package_handle_standard_args(#{package} DEFAULT_MSG #{cmakeLibNames} #{cmakeIncDirNames})\n")
file.printf("\n")
file.printf(" # show the #{cmakeIncDirNames} and #{cmakeLibNames} variables only in the advanced view\n")
file.printf(" mark_as_advanced(#{cmakeIncDirNames} #{cmakeLibNames})\n\n")
file.printf("endif (#{cmakeLibNames} AND #{cmakeIncDirNames})\n\n")
printf("Done, generated Find#{package}.cmake\n")
-135
Ver Arquivo
@@ -1,135 +0,0 @@
#!/usr/bin/env ruby
# simple script to generate CMakeLists.txt for wengophone libs
#
# usage: generate_lib_file
# then you will be prompted to enter the required parameters
#
#####################################################################
#
# Copyright (c) 2006 Andreas Schneider <asn@cryptomilk.org>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
print("Name of project: ")
project=gets.chomp
printf("\n")
print("Other projects to includes (e.g. \"owutil tinyxml\", leave emtpy to skip): ")
otherprojects=gets.chomp
printf("\n")
print("Defininitions (leave empty to skip): ")
definitions=gets.chomp
cmakePublicIncDirName = project.upcase+"_PUBLIC_INCLUDE_DIRS"
cmakePrivateIncDirName = project.upcase+"_PRIVATE_INCLUDE_DIRS"
cmakeLibName = project.upcase+"_LIBRARY"
cmakeLibNames = project.upcase+"_LINK_LIBRARIES"
cmakePublicDefsName = project.upcase+"_PUBLIC_DEFINITIONS"
cmakePrivateDefsName = project.upcase+"_PRIVATE_DEFINITIONS"
file=File.new("CMakeLists.txt", "w+")
file.printf("project(#{project})\n")
file.printf("\n")
file.printf("# needed include directories to build #{project}\n")
file.printf("# saves the variable in internal cache for later use\n")
file.printf("set(#{cmakePublicIncDirName}\n")
file.printf(" ${CMAKE_CURRENT_SOURCE_DIR}\n")
file.printf(" ${CMAKE_CURRENT_SOURCE_DIR}/include\n")
file.printf(" CACHE INTERNAL \"#{project} public include directories\"\n")
file.printf(")\n")
file.printf("\n")
file.printf("set(#{cmakePrivateIncDirName}\n")
otherprojects.split(" ").each do |otherproject|
file.printf(" ${#{otherproject.upcase}_PUBLIC_INCLUDE_DIRS}\n")
end
file.printf(" ${CMAKE_CURRENT_BINARY_DIR}\n")
file.printf(")\n")
file.printf("\n")
file.printf("set(#{cmakeLibName}\n")
file.printf(" #{project}\n")
file.printf(" CACHE INTERNAL \"#{project} library\"\n")
file.printf(")\n")
file.printf("\n")
file.printf("# #{project} lib and dependencies\n")
file.printf("set(#{cmakeLibNames}\n")
file.printf(" #{cmakeLibName}\n")
otherprojects.split(" ").each do |otherproject|
file.printf(" ${#{otherproject.upcase}_LIBRARIES}\n")
end
file.printf(")\n")
file.printf("\n")
if not definitions.empty?
file.printf("set(#{cmakePublicDefsName}\n")
file.printf(" #{definitions}\n")
file.printf(" CACHE INTERNAL \"#{project} public definitions\"\n")
file.printf(")\n")
file.printf("\n")
file.printf("set(#{cmakePrivateDefsName}\n")
file.printf(" #{definitions}\n")
file.printf(")\n")
file.printf("\n")
end
file.printf("set(#{project}_SRCS\n")
file.printf(" files.c\n")
file.printf(")\n")
file.printf("\n")
file.printf("include_directories(\n")
file.printf(" ${#{cmakePublicIncDirName}}\n")
file.printf(" ${#{cmakePrivateIncDirName}}\n")
file.printf(")\n")
file.printf("\n")
if not definitions.empty?
file.printf("add_definitions(\n")
file.printf(" ${#{cmakePublicDefsName}}\n")
file.printf(" ${#{cmakePrivateDefsName}}\n")
file.printf(")\n")
file.printf("\n")
end
file.printf("\n")
file.printf("add_library(${#{cmakeLibName}} STATIC ${#{project}_SRCS})\n")
file.printf("\n")
file.printf("target_link_libraries(${#{cmakeLibNames}})\n")
file.printf("\n")
printf("Generated CMakeLists.txt for #{project}\n")
+16
Ver Arquivo
@@ -0,0 +1,16 @@
FIND_LIBRARY(CSYNC_LIBRARY NAMES csync)
FIND_PATH(CSYNC_INCLUDE_PATH csync.h
HINTS "/usr/include/csync")
SET(CSYNC_INCLUDE_DIR ${CSYNC_INCLUDE_PATH})
# handle the QUIETLY and REQUIRED arguments and set CSYNC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Csync DEFAULT_MSG
CSYNC_LIBRARY CSYNC_INCLUDE_PATH)
MARK_AS_ADVANCED(
CSYNC_INCLUDE_PATH
CSYNC_LIBRARY)
-28
Ver Arquivo
@@ -1,28 +0,0 @@
#cmakedefine PACKAGE "${APPLICATION_NAME}"
#cmakedefine VERSION "${APPLICATION_VERSION}"
#cmakedefine LOCALEDIR "${LOCALE_INSTALL_DIR}"
#cmakedefine DATADIR "${DATADIR}"
#cmakedefine LIBDIR "${LIBDIR}"
#cmakedefine PLUGINDIR "${PLUGINDIR}"
#cmakedefine SYSCONFDIR "${SYSCONFDIR}"
#cmakedefine BINARYDIR "${BINARYDIR}"
#cmakedefine SOURCEDIR "${SOURCEDIR}"
#cmakedefine HAVE_CLOCK_GETTIME
#cmakedefine WITH_LOG4C 1
#cmakedefine WITH_ICONV 1
#cmakedefine HAVE_ARGP_H 1
#cmakedefine HAVE_ICONV_H 1
#cmakedefine HAVE_SYS_ICONV_H 1
#cmakedefine HAVE_STRERROR_R 1
#cmakedefine HAVE_UTIMES 1
#cmakedefine HAVE_LSTAT 1
#cmakedefine HAVE_FNMATCH 1
#cmakedefine HAVE___MINGW_ASPRINTF 1
#cmakedefine HAVE_ICONV 1
#cmakedefine HAVE_ICONV_CONST 1
#cmakedefine WITH_UNIT_TESTING 1
-10
Ver Arquivo
@@ -1,10 +0,0 @@
macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/csync.conf ${CMAKE_CURRENT_BINARY_DIR}/csync.conf)
macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/csync_exclude.conf ${CMAKE_CURRENT_BINARY_DIR}/csync_exclude.conf)
install(
FILES
csync.conf
csync_exclude.conf
DESTINATION
${SYSCONF_INSTALL_DIR}/csync
)
-8
Ver Arquivo
@@ -1,8 +0,0 @@
# max diff time between two recplicas in seconds
max_time_difference = 10
# max directory depth recursion
max_depth = 50
# create a copy for backup for the file which has a conflict
with_confilct_copies = no
-25
Ver Arquivo
@@ -1,25 +0,0 @@
# Exclude patterns (one per line). Blank lines in the file and
# lines starting with '#' are ignored.
#
# You can use shell wildcard patterns. See the manpage of sh(1)
.beagle
.ccache
.csync*
.fontconfig
.java/
.jpi_cache
.kde*/cache-*
.kde*/socket-*
.kde*/tmp-*
.mozilla/plugins
.mozilla/firefox/*/Cache
.netscape/cache/
.snapshot
.thumbnails
# exclude all object file
# *.o
# exclude all bak files
# *.bak
-41
Ver Arquivo
@@ -1,41 +0,0 @@
project(doc C)
# Build the documentation
#
include(UseDoxygen OPTIONAL)
file(GLOB _manpages *.[0-9].txt)
add_custom_target(man
COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/makeman.sh ${_manpages}
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(userguide
COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/makeguide.sh csync.txt
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)
if (UNIX)
install(
FILES
csync.1
DESTINATION
${MAN_INSTALL_DIR}/man1
)
set(DOC_INSTALL_PATH ${SHARE_INSTALL_PREFIX}/doc/csync)
endif(UNIX)
if (WIN32)
set(DOC_INSTALL_PATH ${SHARE_INSTALL_PREFIX}/doc)
endif (WIN32)
install(
DIRECTORY
userguide
DESTINATION
${DOC_INSTALL_PATH}
)
-8
Ver Arquivo
@@ -1,8 +0,0 @@
#
# Customization for csync documentation.
#
[specialwords]
ifndef::doctype-manpage[]
emphasizedwords=(?u)\\?\bCSYNC\b
monospacedwords=(?u)\\?\bcsync\(1\)
endif::doctype-manpage[]
-20
Ver Arquivo
@@ -1,20 +0,0 @@
/*
* cynapses libc functions
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
* Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-26
Ver Arquivo
@@ -1,26 +0,0 @@
/*
*
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
* Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSYNC_X_H
#define _CSYNC_X_H
#endif /* _CSYNC_X_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
-320
Ver Arquivo
@@ -1,320 +0,0 @@
.\" Title: csync
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.74.0 <http://docbook.sf.net/>
.\" Date: 12/13/2008
.\" Manual: [FIXME: manual]
.\" Source: [FIXME: source]
.\" Language: English
.\"
.TH "CSYNC" "1" "12/13/2008" "[FIXME: source]" "[FIXME: manual]"
.\" -----------------------------------------------------------------
.\" * (re)Define some macros
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" toupper - uppercase a string (locale-aware)
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.de toupper
.tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
\\$*
.tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
..
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" SH-xref - format a cross-reference to an SH section
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.de SH-xref
.ie n \{\
.\}
.toupper \\$*
.el \{\
\\$*
.\}
..
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" SH - level-one heading that works better for non-TTY output
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.de1 SH
.\" put an extra blank line of space above the head in non-TTY output
.if t \{\
.sp 1
.\}
.sp \\n[PD]u
.nr an-level 1
.set-an-margin
.nr an-prevailing-indent \\n[IN]
.fi
.in \\n[an-margin]u
.ti 0
.HTML-TAG ".NH \\n[an-level]"
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
\." make the size of the head bigger
.ps +3
.ft B
.ne (2v + 1u)
.ie n \{\
.\" if n (TTY output), use uppercase
.toupper \\$*
.\}
.el \{\
.nr an-break-flag 0
.\" if not n (not TTY), use normal case (not uppercase)
\\$1
.in \\n[an-margin]u
.ti 0
.\" if not n (not TTY), put a border/line under subheading
.sp -.6
\l'\n(.lu'
.\}
..
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" SS - level-two heading that works better for non-TTY output
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.de1 SS
.sp \\n[PD]u
.nr an-level 1
.set-an-margin
.nr an-prevailing-indent \\n[IN]
.fi
.in \\n[IN]u
.ti \\n[SN]u
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.ps \\n[PS-SS]u
\." make the size of the head bigger
.ps +2
.ft B
.ne (2v + 1u)
.if \\n[.$] \&\\$*
..
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" BB/BE - put background/screen (filled box) around block of text
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.de BB
.if t \{\
.sp -.5
.br
.in +2n
.ll -2n
.gcolor red
.di BX
.\}
..
.de EB
.if t \{\
.if "\\$2"adjust-for-leading-newline" \{\
.sp -1
.\}
.br
.di
.in
.ll
.gcolor
.nr BW \\n(.lu-\\n(.i
.nr BH \\n(dn+.5v
.ne \\n(BHu+.5v
.ie "\\$2"adjust-for-leading-newline" \{\
\M[\\$1]\h'1n'\v'+.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
.\}
.el \{\
\M[\\$1]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
.\}
.in 0
.sp -.5v
.nf
.BX
.in
.sp .5v
.fi
.\}
..
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" BM/EM - put colored marker in margin next to block of text
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.de BM
.if t \{\
.br
.ll -2n
.gcolor red
.di BX
.\}
..
.de EM
.if t \{\
.br
.di
.ll
.gcolor
.nr BH \\n(dn
.ne \\n(BHu
\M[\\$1]\D'P -.75n 0 0 \\n(BHu -(\\n[.i]u - \\n(INu - .75n) 0 0 -\\n(BHu'\M[]
.in 0
.nf
.BX
.in
.fi
.\}
..
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "Name"
csync \- A commandline frontent for csync a user level bidirectional file synchronizer\&.
.SH "Synopsis"
.sp
\fBcsync\fR [\fIOPTION\fR\&...] \fISOURCE\fR \fIDESTINATION\fR
.SH "DESCRIPTION"
.sp
csync is a client only bidirectional file synchronizer\&. It synchronizes the content of \fISOURCE\fR with \fIDESTINATION\fR and vice versa\&. The \fIDESTINATION\fR can be a local directory or a remote file server\&.
.sp
You can use csync for different things\&. The intention is to provide Roaming Home Directories for Linux but you can use it to synchronize your music collection or create a backup of a directory\&.
.SH "OPTIONS"
.PP
\fB\-\-create\-statedb\fR
.RS 4
Run update detection and write the statedb (TESTING ONLY!)
.RE
.PP
\fB\-d, \-\-disable\-statedb\fR
.RS 4
Disable the usage and creation of a statedb\&.
.RE
.PP
\fB\-\-exclude\-file=\fR\fB\fI<file>\fR\fR
.RS 4
Add an additional exclude file
.RE
.PP
\fB\-r, \-\-reconcile\fR
.RS 4
Run ONLY update detection and reconcilation This option is for debugging
.RE
.PP
\fB\-u, \-\-update\fR
.RS 4
Run ONLY the update detection This option is for debugging
.RE
.PP
\fB\-?, \-\-help\fR
.RS 4
Print the help list
.RE
.PP
\fB\-V, \-\-version\fR
.RS 4
Print program version
.RE
.SH "EXIT STATUS"
.PP
\fB0\fR
.RS 4
Success
.RE
.PP
\fB1\fR
.RS 4
Failure (syntax or usage error; configuration error; unexpected error)\&.
.RE
.SH "EXAMPLES"
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
csync /home/user /backup/home/user
.sp
.if n \{\
.RS 4
.\}
.fam C
.ps -1
.nf
.BB lightgray
Synchronizer two local directories\&.
.EB lightgray
.fi
.fam
.ps +1
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
csync /home/user smb://server/share/user
.sp
.if n \{\
.RS 4
.\}
.fam C
.ps -1
.nf
.BB lightgray
Synchronize a home directory with a SMB share\&.
.EB lightgray
.fi
.fam
.ps +1
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
csync /home/user smb://user:password@server/share/user
.sp
.if n \{\
.RS 4
.\}
.fam C
.ps -1
.nf
.BB lightgray
Synchronize a home directory with a SMB share and provide username and
password directly\&.
.EB lightgray
.fi
.fam
.ps +1
.if n \{\
.RE
.\}
.RE
.SH "BUGS"
.sp
Please report bugs at https://dev\&.csync\&.org/\&.
.SH "SEE ALSO"
.sp
\fBlibcsync\fR(7)
.SH "AUTHORS"
.sp
Andreas Schneider <mail@cynapses\&.org>
.SH "COPYING"
.sp
Copyright \e(c) 2006\-2008 Andreas Schneider\&. Free use of this software is granted under the terms of the GNU General Public License (GPL)\&.
-104
Ver Arquivo
@@ -1,104 +0,0 @@
csync(1)
========
NAME
----
csync - A commandline frontent for csync a user level bidirectional file
synchronizer.
SYNOPSIS
--------
*csync* ['OPTION'...] 'SOURCE' 'DESTINATION'
DESCRIPTION
-----------
csync is a client only bidirectional file synchronizer. It synchronizes the
content of 'SOURCE' with 'DESTINATION' and vice versa. The 'DESTINATION' can
be a local directory or a remote file server.
You can use csync for different things. The intention is to provide Roaming
Home Directories for Linux but you can use it to synchronize your music
collection or create a backup of a directory.
OPTIONS
-------
*--create-statedb*::
Run update detection and write the statedb
(TESTING ONLY!)
*-d, --disable-statedb*::
Disable the usage and creation of a statedb.
*--exclude-file='<file>'*::
Add an additional exclude file
*-r, --reconcile*::
Run ONLY update detection and reconcilation
This option is for debugging
*-u, --update*::
Run ONLY the update detection
This option is for debugging
*-?, --help*::
Print the help list
*-V, --version*::
Print program version
EXIT STATUS
-----------
*0*::
Success
*1*::
Failure (syntax or usage error; configuration error;
unexpected error).
EXAMPLES
--------
* csync /home/user /backup/home/user
Synchronizer two local directories.
* csync /home/user smb://server/share/user
Synchronize a home directory with a SMB share.
* csync /home/user smb://user:password@server/share/user
Synchronize a home directory with a SMB share and provide username and
password directly.
BUGS
----
Please report bugs at https://dev.csync.org/.
SEE ALSO
--------
*libcsync*(7)
AUTHORS
-------
Andreas Schneider <asn@cryptomilk.org>
COPYING
-------
Copyright \(c) 2006-2008 Andreas Schneider. Free use of this software is
granted under the terms of the GNU General Public License (GPL).
-315
Ver Arquivo
@@ -1,315 +0,0 @@
CSYNC User Guide
================
Andreas Schneider <asn@cryptomilk.org>
:Author Initials: ADS
csync is a lightweight utility to synchronize files between two directories
on a system or between multiple systems.
It synchronizes bidirectionally and allows the user to keep two copies of files
and directories in sync. csync uses widely adopted protocols, such as smb or
sftp, so that there is no need for a server component. It is a user-level
program which means you don't need to be a superuser or administrator.
Together with a Pluggable Authentication Module (PAM), the intent is to provide
Roaming Home Directories for Linux (see <<X80, The PAM Module>>).
Introduction
------------
It is often the case that we have multiple copies (called replicas) of a
filesystem or part of a filesystem (for example on a notebook and desktop
computer). Changes to each replica are often made independently, and as a
result, they do not contain the same information. In that case, a file
synchronizer is used to make them consistent again, without losing any
information.
The goal is to detect conflicting updates (files which have been modified) and
propagate non-conflicting updates to each replica. If there are no conflicts
left, we are done, and the replicas are identical. To resolve or handle
conflicts there are several algorithms available. They will be discussed
one of the following sections.
Basics
------
This section describes some basics of file synchronization.
Paths
~~~~~
A path normally refers to a point which contains a set of files which should be
synchronized. It is specified relative to the root of the replica locally, but
has to be absolute if you use a protocol. The path is just a sequence of names
separated by '/'.
NOTE: The path separator is always a forward slash '/', even for Windows.
csync always uses the absolute path on remote replicas. This could
'sftp://gladiac:secret@myserver/home/gladiac' for sftp.
What is an update?
~~~~~~~~~~~~~~~~~~
The contents of a path could be a file, a directory or a symbolic link
(symbolic links are not supported yet). To be more precise, if the path refers
to:
- a regular file: the contents of the file are the byte stream and the
metadata of the file.
- a directory: then the content is the metadata of the directory.
- a symbolic link: the content is the named file the link points to.
csync keeps a record of each path which has been successfully synchronized. The
path gets compared with the record and if it has changed since the last
synchronization, we have an update. This is done by comparing the modification
or change (modification time of the metadata) time. This is the way how updates
are detected.
What is a conflict?
~~~~~~~~~~~~~~~~~~~
A path is conflicting if it fulfills the following conditions:
1. it has been updated in one replica,
2. it or any of its descendants has been updated on the other replica too, and
3. its contents in are not identical.
File Synchronization
--------------------
The primary goal of the file synchronizer is correctness. It may change
scattered or large parts of the filesystem. Since this in mostly not monitored
by the user, and the file synchronizer is in a position to harm the system,
csync must be safe, even in the case of unexpected errors (e.g. disk full).
What was done to make csync safe is described in the following sections.
One problem concerning correctness is the handling of conflicts. Each file
synchronizer tries to propagate conflicting changes to the other replica. At
the end both replicas should be identical. There are different strategies to
fulfill these goals.
csync is a three-phase file synchronizer. The decision for this design was that
user interaction should be possible and it should be easy to understand the
process. The three phases are update detection, reconciliation and propagation.
These will be described in the following sections.
Update detection
~~~~~~~~~~~~~~~~
There are different strategies for update detection. csync uses a state-based
modtime-inode update detector. This means it uses the modification time to
detect updates. It doesn't require many resources. A record of each file is
stored in a database (called statedb) and compared with the current
modification time during update detection. If the file has changed since the
last synchronization an instruction is set to evaluate it during the
reconciliation phase. If we don't have a record for a file we investigate, it
is marked as new.
It can be difficult to detect renaming of files. This problem is also solved
by the record we store in the statedb. If we don't find the file by the name
in the database, we search for the inode number. If the inode number is found
then the file has been renamed.
Reconciliation
~~~~~~~~~~~~~~
The most important component is the update detector, because the reconciler
depends on it. The correctness of reconciler is mandatory because it can damage
a filesystem. It decides which file:
* Stays untouched
* Has a conflict
* Gets synchronized
* or is *deleted*
A wrong decision of the reconciler leads in most cases to a loss of data. So
there are several conditions which a file synchronizer has to follow.
Algorithms
^^^^^^^^^^
For conflict resolution several different algorithms could be implemented. The
most common algorithms are the merge and the conflict algorithm. The first
is a batch algorithm and the second is one which needs user interaction.
Merge algorithm
+++++++++++++++
The merge algorithm is an algorithm which doesn't need any user interaction. It
is simple and used for example by Microsoft for Roaming Profiles. If it detects
a conflict (the same file changed on both replicas) then it will use the most
recent file and overwrite the other. This means you can loose some data, but
normally you want the latest file.
Conflict algorithm
++++++++++++++++++
This is not implemented yet.
If a file has a conflict the user has to decide which file should be used.
Propagation
~~~~~~~~~~~
The next instance of the file synchronizer is the propagator. It uses the
calculated records to apply them on the current replica.
The propagator uses a two-phase-commit mechanism to simulate an atomic
filesystem operation.
In the first phase we copy the file to a temporary file on the opposite
replica. This has the advantage that we can check if the file which has been
copied to the opposite replica has been transfered successfully. If the
connection gets interrupted during the transfer we still have the original
states of the file. This means no data will be lost.
In the second phase the file on the opposite replica will be overwritten by
the temporary file.
After a successful propagation we have to merge the trees to reflect the
current state of the filesystem tree. This updated tree will be written as a
journal into the state database. It will be used during the update detection of
the next synchronization. See above for a description of the state database
during synchronization.
Robustness
~~~~~~~~~~
This is a very important topic. The file synchronizer should not crash, and if
it has crashed, there should be no loss of data. To achieve this goal there are
several mechanisms which will be discussed in the following sections.
Crash resistance
^^^^^^^^^^^^^^^^
The synchronization process can be interrupted by different events, this can
be:
* the system could be halted due to errors.
* the disk could be full or the quota exceeded.
* the network or power cable could be pulled out.
* the user could force a stop of the synchronization process.
* various communication errors could occur.
That no data will be lost due to an event we enforce the following invariant:
IMPORTANT: At every moment of the synchronization each file, has either its
original content or its correct final content.
This means that the original content can not be incorrect, no data can be lost
until we overwrite it after a successful synchronization. Therefore, each
interrupted synchronization process is a partial sync and can be continued and
completed by simply running csync again. The only problem could be an error of
the filesystem, so we reach this invariant only approximately.
Transfer errors
^^^^^^^^^^^^^^^
With the Two-Phase-Commit we check the file size after the file has transferred
and we are able to detect transfer errors. A more robust approach would be a
transfer protocol with checksums, but this is not doable at the moment. We may
add this in the future.
Future filesystems, like btrfs, will help to compare checksums instead of the
filesize. This will make the synchronization safer. This does not imply that it
is unsafe now, but checksums are safer than simple filesize checks.
Database loss
^^^^^^^^^^^^^
It is possible that the state database could get corrupted. If this happens,
all files get evaluated. In this case the file synchronizer wont delete any
file, but it could occur that deleted files will be restored from the other
replica.
To prevent a corruption or loss of the database if an error occurs or the user
forces an abort, the synchronizer is working on a copy of the database and will
use a Two-Phase-Commit to save it at the end.
Getting started
---------------
Installing csync
~~~~~~~~~~~~~~~~
See the `README` and `INSTALL` files for install prerequisites and
procedures. Packagers should take a look at <<X90, Appendix A: Packager Notes>>.
Using the commandline client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The synopsis of the commandline client is
csync [OPTION...] SOURCE DESTINATION
It synchronizes the content of SOURCE with DESTINATION and vice versa. The
DESTINATION can be a local directory or a remote file server.
csync /home/csync scheme://user:password@server:port/full/path
Examples
^^^^^^^^
To synchronize two local directories:
csync /home/csync/replica1 /home/csync/relplica2
Two synchronizer a local directory with an smb server, use
csync /home/csync smb://rupert.galaxy.site/Users/csync
If you use kerberos, you don't have to specify a username or a password. If you
don't use kerberos, the commandline client will ask about the user and the
password. If you don't want to be prompted, you can specify it on the
commandline:
csync /home/csync smb://csync:secret@rupert.galaxy.site/Users/csync
If you use the sftp protocol and want to specify a port, you do it the
following way:
csync /home/csync sftp://csync@krikkit.galaxy.site:2222/home/csync
The remote destination is supported by plugins. By default csync ships with smb
and sftp support. For more information, see the manpage of csync(1).
Exclude lists
~~~~~~~~~~~~~
csync provides exclude lists with simple shell wildcard patterns. There is a
global exclude list, which is normally located in
'/etc/csync/csync_exclude.conf' and it has already some sane defaults. If you
run csync the first time, it will create an empty exclude list for the user.
This file will be '~/.csync/csync_exclude.conf'. csync considers both
configuration files and an additional one if you specify it.
The entries in the file are newline separated. Use
'/etc/csync/csync_exclude.conf' as an example.
Debug messages and dry run
~~~~~~~~~~~~~~~~~~~~~~~~~~
By default the csync client logs to stderr and you can increase the debug
level with a commandline options.
To simulate a run of the file synchronizer, you should set the priority to
'debug' for the categories 'csync.updater' and 'csync.reconciler' in the config
file '~/.csync/csync_log.conf'. Then run csync with the '--dry-run' option.
This will only run update detection and reconciliation.
[[X80]]
The PAM module
~~~~~~~~~~~~~~
pam_csync is a PAM module to provide roaming home directories for a user
session. This module is aimed at environments with central file servers where a
user wishes to store his home directory. The Authentication Module verifies the
identity of a user and triggers a synchronization with the server on the first
login and the last logout. More information can be found in the manpage of the
module pam_csync(8) or pam itself pam(8).
[[X90]]
Appendix A: Packager Notes
--------------------------
Read the `README`, `INSTALL` and `FAQ` files (in the distribution root
directory).
-1375
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-16
Ver Arquivo
@@ -1,16 +0,0 @@
#!/bin/bash
# Last Change: 2008-07-03 11:08:54
for f in $@; do
test "${f##*/}" = "CMakeLists.txt" && continue
echo -e "\e[32mCreating asciidoc html document ${f%.*}.html\e[0m"
asciidoc \
--attribute=numbered \
--attribute=icons \
--attribute="iconsdir=./images/icons" \
--attribute=toc \
--backend=xhtml11 \
--out-file="$(dirname $f)/userguide/${f%.*}.html" \
$f
rm -f ${f%.*}.xml
done
-9
Ver Arquivo
@@ -1,9 +0,0 @@
#!/bin/bash
# Last Change: 2008-07-03 11:08:54
for f in $@; do
test "${f##*/}" = "CMakeLists.txt" && continue
echo -e "\e[32mCreating manpage ${f%.*}\e[0m"
a2x --doctype=manpage --format=manpage $f
rm -f ${f%.*}.xml
done
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-5
Ver Arquivo
@@ -1,5 +0,0 @@
Replaced the plain DocBook XSL admonition icons with Jimmac's DocBook
icons (http://jimmac.musichall.cz/ikony.php3). I dropped transparency
from the Jimmac icons to get round MS IE and FOP PNG incompatibilies.
Stuart Rackham
Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 329 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 361 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 565 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 617 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 623 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 411 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 640 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 353 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 350 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 345 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 348 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 355 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 344 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 357 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 357 B

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 2.5 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 2.3 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 1.3 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 2.6 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 1.3 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 2.7 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 1.3 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 2.5 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 1.3 KiB

Arquivo binário não exibido.

Antes

Largura:  |  Altura:  |  Tamanho: 2.8 KiB

-81
Ver Arquivo
@@ -1,81 +0,0 @@
project(modules C)
find_package(LibSSH 0.4.0)
find_package(Neon 0.29.0)
set(PLUGIN_VERSION_INSTALL_DIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
set(MODULES_PUBLIC_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
CACHE INTERNAL "modules include directories"
)
set(MODULES_PRIVATE_INCLUDE_DIRS
${CSTDLIB_PUBLIC_INCLUDE_DIRS}
${CSYNC_PUBLIC_INCLUDE_DIRS}
)
set(SMB_PLUGIN
csync_smb
)
set(SFTP_PLUGIN
csync_sftp
)
set(OWNCLOUD_PLUGIN
csync_owncloud
)
include_directories(
${MODULES_PUBLIC_INCLUDE_DIRS}
${MODULES_PRIVATE_INCLUDE_DIRS}
)
find_package(SMBClient)
if(SMBCLIENT_LIBRARY)
include_directories(${SMBCLIENT_INCLUDE_DIRS})
macro_add_plugin(${SMB_PLUGIN} csync_smb.c)
target_link_libraries(${SMB_PLUGIN} ${CSYNC_LIBRARY} ${SMBCLIENT_LIBRARIES})
install(
TARGETS
${SMB_PLUGIN}
DESTINATION
${PLUGIN_VERSION_INSTALL_DIR}
)
endif(SMBCLIENT_LIBRARY)
macro_add_plugin(csync_dummy csync_dummy.c)
target_link_libraries(csync_dummy ${CSYNC_LIBRARY})
if (LIBSSH_FOUND)
macro_add_plugin(${SFTP_PLUGIN} csync_sftp.c)
target_link_libraries(${SFTP_PLUGIN} ${CSYNC_LIBRARY} ${LIBSSH_LIBRARIES})
install(
TARGETS
${SFTP_PLUGIN}
DESTINATION
${PLUGIN_VERSION_INSTALL_DIR}
)
endif (LIBSSH_FOUND)
if (NEON_FOUND)
macro_add_plugin(${OWNCLOUD_PLUGIN} csync_owncloud.c)
target_link_libraries(${OWNCLOUD_PLUGIN} ${CSYNC_LIBRARY} ${NEON_LIBRARY})
install(
TARGETS
${OWNCLOUD_PLUGIN}
DESTINATION
${PLUGIN_VERSION_INSTALL_DIR}
)
endif (NEON_FOUND)
# create test file as bad plugin for the vio testcase
file(WRITE
${CMAKE_CURRENT_BINARY_DIR}/csync_bad.so
"bad plugin"
)
-220
Ver Arquivo
@@ -1,220 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <stdio.h>
#include <time.h>
#include "c_lib.h"
#include "vio/csync_vio_module.h"
#include "vio/csync_vio_file_stat.h"
#ifdef NDEBUG
#define DEBUG_DUMMY(x)
#else
#define DEBUG_DUMMY(x) printf x
#endif
csync_vio_method_handle_t *mh = NULL;
csync_vio_file_stat_t fs;
/*
* file functions
*/
static csync_vio_method_handle_t *dummy_open(const char *durl, int flags, mode_t mode) {
(void) durl;
(void) flags;
(void) mode;
return &mh;
}
static csync_vio_method_handle_t *dummy_creat(const char *durl, mode_t mode) {
(void) durl;
(void) mode;
return &mh;
}
static int dummy_close(csync_vio_method_handle_t *fhandle) {
(void) fhandle;
return 0;
}
static ssize_t dummy_read(csync_vio_method_handle_t *fhandle, void *buf, size_t count) {
(void) fhandle;
(void) buf;
(void) count;
return 0;
}
static ssize_t dummy_write(csync_vio_method_handle_t *fhandle, const void *buf, size_t count) {
(void) fhandle;
(void) buf;
(void) count;
return 0;
}
static off_t dummy_lseek(csync_vio_method_handle_t *fhandle, off_t offset, int whence) {
(void) fhandle;
(void) offset;
(void) whence;
return 0;
}
/*
* directory functions
*/
static csync_vio_method_handle_t *dummy_opendir(const char *name) {
(void) name;
return &mh;
}
static int dummy_closedir(csync_vio_method_handle_t *dhandle) {
(void) dhandle;
return 0;
}
static csync_vio_file_stat_t *dummy_readdir(csync_vio_method_handle_t *dhandle) {
(void) dhandle;
return &fs;
}
static int dummy_mkdir(const char *uri, mode_t mode) {
(void) uri;
(void) mode;
return 0;
}
static int dummy_rmdir(const char *uri) {
(void) uri;
return 0;
}
static int dummy_stat(const char *uri, csync_vio_file_stat_t *buf) {
time_t now;
buf->name = c_basename(uri);
if (buf->name == NULL) {
csync_vio_file_stat_destroy(buf);
return -1;
}
buf->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
time(&now);
buf->mtime = now;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MTIME;
return 0;
}
static int dummy_rename(const char *olduri, const char *newuri) {
(void) olduri;
(void) newuri;
return 0;
}
static int dummy_unlink(const char *uri) {
(void) uri;
return 0;
}
static int dummy_chmod(const char *uri, mode_t mode) {
(void) uri;
(void) mode;
return 0;
}
static int dummy_chown(const char *uri, uid_t owner, gid_t group) {
(void) uri;
(void) owner;
(void) group;
return 0;
}
static int dummy_utimes(const char *uri, const struct timeval *times) {
(void) uri;
(void) times;
return 0;
}
static int dummy_commit() {
return 0;
}
csync_vio_method_t dummy_method = {
.method_table_size = sizeof(csync_vio_method_t),
.open = dummy_open,
.creat = dummy_creat,
.close = dummy_close,
.read = dummy_read,
.write = dummy_write,
.lseek = dummy_lseek,
.opendir = dummy_opendir,
.closedir = dummy_closedir,
.readdir = dummy_readdir,
.mkdir = dummy_mkdir,
.rmdir = dummy_rmdir,
.stat = dummy_stat,
.rename = dummy_rename,
.unlink = dummy_unlink,
.chmod = dummy_chmod,
.chown = dummy_chown,
.utimes = dummy_utimes,
.commit = dummy_commit
};
csync_vio_method_t *vio_module_init(const char *method_name, const char *args,
csync_auth_callback cb, void *userdata) {
DEBUG_DUMMY(("csync_dummy - method_name: %s\n", method_name));
DEBUG_DUMMY(("csync_dummy - args: %s\n", args));
(void) method_name;
(void) args;
(void) cb;
(void) userdata;
mh = (void *) method_name;
fs.mtime = 42;
return &dummy_method;
}
void vio_module_shutdown(csync_vio_method_t *method) {
(void) method;
}
/* vim: set ts=8 sw=2 et cindent: */
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-513
Ver Arquivo
@@ -1,513 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <stdio.h>
#include <libsmbclient.h>
#include "c_lib.h"
#include "c_private.h"
#include "vio/csync_vio_module.h"
#include "vio/csync_vio_file_stat.h"
#ifdef NDEBUG
#define DEBUG_SMB(x)
#else
#define DEBUG_SMB(x) printf x
#endif
SMBCCTX *smb_context = NULL;
csync_auth_callback _authcb = NULL;
void *_userdata;
/*
* Authentication callback for libsmbclient
*/
static void get_auth_data_with_context_fn(SMBCCTX *smb_ctx,
const char *srv,
const char *shr,
char *wg, int wglen,
char *un, int unlen,
char *pw, int pwlen)
{
static int try_krb5 = 1;
char *h;
(void) smb_ctx;
(void) shr;
(void) wg;
(void) wglen;
DEBUG_SMB(("csync_smb - user=%s, workgroup=%s, server=%s, share=%s\n",
un, wg, srv, shr));
/* Don't authenticate for workgroup listing */
if (srv == NULL || srv[0] == '\0') {
DEBUG_SMB(("csync_smb - emtpy server name"));
return;
}
/* Try kerberos authentication if available */
if (try_krb5 && getenv("KRB5CCNAME")) {
try_krb5 = 0;
return;
}
/* check for an existing user */
h = smbc_getUser(smb_ctx);
if (h != NULL) {
/* The username is known from the url. */
DEBUG_SMB(("csync_smb - have username from url: %s\n", h));
if (snprintf(un, unlen, "%s", h) < 0) {
/* Even if that fials, go on. */
}
} else {
if (_authcb != NULL) {
DEBUG_SMB(("csync_smb - execute authentication callback\n"));
(*_authcb) ("Username:", un, unlen, 1, 0, smbc_getOptionUserData(smb_ctx));
}
}
/* Always ask for the password */
if (_authcb != NULL) {
/* Call the passwort prompt */
(*_authcb) ("Password:", pw, pwlen, 0, 0, smbc_getOptionUserData(smb_ctx));
}
DEBUG_SMB(("csync_smb - user=%s, workgroup=%s, server=%s, share=%s\n",
un, wg, srv, shr));
try_krb5 = 1;
return;
}
typedef struct smb_fhandle_s {
int fd;
} smb_fhandle_t;
/*
* file functions
*/
static csync_vio_method_handle_t *_open(const char *durl, int flags, mode_t mode) {
smb_fhandle_t *handle = NULL;
int fd = -1;
if ((fd = smbc_open(durl, flags, mode)) < 0) {
return NULL;
}
handle = c_malloc(sizeof(smb_fhandle_t));
if (handle == NULL) {
return NULL;
}
handle->fd = fd;
return (csync_vio_method_handle_t *) handle;
}
static csync_vio_method_handle_t *_creat(const char *durl, mode_t mode) {
smb_fhandle_t *handle = NULL;
int fd = -1;
if ((fd = smbc_creat(durl, mode)) < 0) {
return NULL;
}
handle = c_malloc(sizeof(smb_fhandle_t));
if (handle == NULL) {
return NULL;
}
handle->fd = fd;
return (csync_vio_method_handle_t *) handle;
}
static int _close(csync_vio_method_handle_t *fhandle) {
int rc = -1;
smb_fhandle_t *handle = NULL;
if (fhandle == NULL) {
errno = EBADF;
return -1;
}
handle = (smb_fhandle_t *) fhandle;
rc = smbc_close(handle->fd);
SAFE_FREE(handle);
return rc;
}
static ssize_t _read(csync_vio_method_handle_t *fhandle, void *buf, size_t count) {
smb_fhandle_t *handle = NULL;
if (fhandle == NULL) {
errno = EBADF;
return (ssize_t) -1;
}
handle = (smb_fhandle_t *) fhandle;
return smbc_read(handle->fd, buf, count);
}
static ssize_t _write(csync_vio_method_handle_t *fhandle, const void *buf, size_t count) {
smb_fhandle_t *handle = NULL;
if (fhandle == NULL) {
errno = EBADF;
return (ssize_t) -1;
}
handle = (smb_fhandle_t *) fhandle;
return smbc_write(handle->fd, (char *) buf, count);
}
static off_t _lseek(csync_vio_method_handle_t *fhandle, off_t offset, int whence) {
smb_fhandle_t *handle = NULL;
if (fhandle == NULL) {
errno = EBADF;
return (off_t) -1;
}
handle = (smb_fhandle_t *) fhandle;
return smbc_lseek(handle->fd, offset, whence);
}
/*
* directory functions
*/
typedef struct smb_dhandle_s {
int dh;
char *path;
} smb_dhandle_t;
static csync_vio_method_handle_t *_opendir(const char *name) {
smb_dhandle_t *handle = NULL;
handle = c_malloc(sizeof(smb_dhandle_t));
if (handle == NULL) {
return NULL;
}
handle->dh = smbc_opendir(name);
if (handle->dh < 0) {
SAFE_FREE(handle);
return NULL;
}
handle->path = c_strdup(name);
return (csync_vio_method_handle_t *) handle;
}
static int _closedir(csync_vio_method_handle_t *dhandle) {
smb_dhandle_t *handle = NULL;
int rc = -1;
if (dhandle == NULL) {
errno = EBADF;
return -1;
}
handle = (smb_dhandle_t *) dhandle;
rc = smbc_closedir(handle->dh);
SAFE_FREE(handle->path);
SAFE_FREE(handle);
return rc;
}
static csync_vio_file_stat_t *_readdir(csync_vio_method_handle_t *dhandle) {
struct smbc_dirent *dirent = NULL;
smb_dhandle_t *handle = NULL;
csync_vio_file_stat_t *file_stat = NULL;
handle = (smb_dhandle_t *) dhandle;
errno = 0;
dirent = smbc_readdir(handle->dh);
if (dirent == NULL) {
return NULL;
}
file_stat = c_malloc(sizeof(csync_vio_file_stat_t));
if (file_stat == NULL) {
return NULL;
}
file_stat->name = c_strndup(dirent->name, dirent->namelen);
file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
switch (dirent->smbc_type) {
case SMBC_FILE_SHARE:
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
file_stat->type = CSYNC_VIO_FILE_TYPE_DIRECTORY;
break;
case SMBC_WORKGROUP:
case SMBC_SERVER:
case SMBC_COMMS_SHARE:
case SMBC_IPC_SHARE:
break;
case SMBC_DIR:
case SMBC_FILE:
file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
if (dirent->smbc_type == SMBC_DIR) {
file_stat->type = CSYNC_VIO_FILE_TYPE_DIRECTORY;
} else {
file_stat->type = CSYNC_VIO_FILE_TYPE_REGULAR;
}
break;
default:
break;
}
return file_stat;
}
static int _mkdir(const char *uri, mode_t mode) {
return smbc_mkdir(uri, mode);
}
static int _rmdir(const char *uri) {
return smbc_rmdir(uri);
}
static int _stat(const char *uri, csync_vio_file_stat_t *buf) {
csync_stat_t sb;
if (smbc_stat(uri, &sb) < 0) {
return -1;
}
buf->name = c_basename(uri);
if (buf->name == NULL) {
csync_vio_file_stat_destroy(buf);
return -1;
}
buf->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
switch(sb.st_mode & S_IFMT) {
case S_IFBLK:
buf->type = CSYNC_VIO_FILE_TYPE_BLOCK_DEVICE;
break;
case S_IFCHR:
buf->type = CSYNC_VIO_FILE_TYPE_CHARACTER_DEVICE;
break;
case S_IFDIR:
buf->type = CSYNC_VIO_FILE_TYPE_DIRECTORY;
break;
case S_IFIFO:
buf->type = CSYNC_VIO_FILE_TYPE_FIFO;
break;
case S_IFLNK:
buf->type = CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK;
break;
case S_IFREG:
buf->type = CSYNC_VIO_FILE_TYPE_REGULAR;
break;
case S_IFSOCK:
buf->type = CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK;
break;
default:
buf->type = CSYNC_VIO_FILE_TYPE_UNKNOWN;
break;
}
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
buf->mode = sb.st_mode;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_PERMISSIONS;
if (buf->type == CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK) {
/* FIXME: handle symlink */
buf->flags = CSYNC_VIO_FILE_FLAGS_SYMLINK;
} else {
buf->flags = CSYNC_VIO_FILE_FLAGS_NONE;
}
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_FLAGS;
buf->device = sb.st_dev;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_DEVICE;
buf->inode = sb.st_ino;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_INODE;
buf->nlink = sb.st_nlink;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_LINK_COUNT;
buf->uid = sb.st_uid;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_UID;
buf->gid = sb.st_gid;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_GID;
buf->size = sb.st_size;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_SIZE;
buf->blksize = sb.st_blksize;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_BLOCK_SIZE;
buf->blkcount = sb.st_blocks;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_BLOCK_COUNT;
buf->atime = sb.st_atime;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_ATIME;
buf->mtime = sb.st_mtime;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MTIME;
buf->ctime = sb.st_ctime;
buf->fields |= CSYNC_VIO_FILE_STAT_FIELDS_CTIME;
return 0;
}
static int _rename(const char *olduri, const char *newuri) {
return smbc_rename(olduri, newuri);
}
static int _unlink(const char *uri) {
return smbc_unlink(uri);
}
static int _chmod(const char *uri, mode_t mode) {
return smbc_chmod(uri, mode);
}
static int _chown(const char *uri, uid_t owner, gid_t group) {
(void) uri;
(void) owner;
(void) group;
/* FIXME: implement smbc_setxattr() */
return 0;
}
static int _utimes(const char *uri, const struct timeval *times) {
return smbc_utimes(uri, (struct timeval *) times);
}
static struct csync_vio_capabilities_s _smb_capabilities = {
.atomar_copy_support = false
};
static struct csync_vio_capabilities_s *_smb_get_capabilities(void)
{
return &_smb_capabilities;
}
csync_vio_method_t _method = {
.method_table_size = sizeof(csync_vio_method_t),
.get_capabilities = _smb_get_capabilities,
.open = _open,
.creat = _creat,
.close = _close,
.read = _read,
.write = _write,
.lseek = _lseek,
.opendir = _opendir,
.closedir = _closedir,
.readdir = _readdir,
.mkdir = _mkdir,
.rmdir = _rmdir,
.stat = _stat,
.rename = _rename,
.unlink = _unlink,
.chmod = _chmod,
.chown = _chown,
.utimes = _utimes
};
csync_vio_method_t *vio_module_init(const char *method_name, const char *args,
csync_auth_callback cb, void *userdata) {
smb_context = smbc_new_context();
DEBUG_SMB(("csync_smb - method_name: %s\n", method_name));
DEBUG_SMB(("csync_smb - args: %s\n", args));
(void) method_name;
(void) args;
(void) cb;
if (smb_context == NULL) {
fprintf(stderr, "csync_smb - failed to create new smbc context\n");
return NULL;
}
if (cb != NULL) {
_authcb = cb;
}
/* set debug level and authentication function callback */
smbc_setDebug(smb_context, 0);
smbc_setOptionUserData(smb_context, userdata);
smbc_setFunctionAuthDataWithContext(smb_context, get_auth_data_with_context_fn);
/* Kerberos support */
smbc_setOptionUseKerberos(smb_context, 1);
smbc_setOptionFallbackAfterKerberos(smb_context, 1);
DEBUG_SMB(("csync_smb - use kerberos = %d\n",
smbc_getOptionUseKerberos(smb_context)));
DEBUG_SMB(("csync_smb - use fallback after kerberos = %d\n",
smbc_getOptionFallbackAfterKerberos(smb_context)));
if (smbc_init_context(smb_context) == NULL) {
fprintf(stderr, "csync_smb - failed to initialize the smbc context");
smbc_free_context(smb_context, 0);
smb_context = NULL;
return NULL;
}
DEBUG_SMB(("csync_smb - KRB5CCNAME = %s\n", getenv("KRB5CCNAME") != NULL ?
getenv("KRB5CCNAME") : "not set"));
smbc_set_context(smb_context);
return &_method;
}
void vio_module_shutdown(csync_vio_method_t *method) {
(void) method;
if (smb_context != NULL) {
/*
* If we have a context, all connections and files will be closed even
* if they are busy.
*/
smbc_free_context(smb_context, 1);
smb_context = NULL;
}
}
/* vim: set ts=8 sw=2 et cindent: */
+35 -96
Ver Arquivo
@@ -1,104 +1,43 @@
project(libcsync C)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include(${QT_USE_FILE})
add_subdirectory(std)
find_package(SQLite3 3.3.9 REQUIRED)
set(CSYNC_PUBLIC_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}
CACHE INTERNAL "csync public include directories"
set(mirall_UI
mirall/folderwizardsourcepage.ui
mirall/folderwizardtargetpage.ui
)
qt4_wrap_ui(mirall_UI_SRCS ${mirall_UI})
set(CSYNC_PRIVATE_INCLUDE_DIRS
${SQLITE3_INCLUDE_DIRS}
${CSTDLIB_PUBLIC_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
set(mirall_SRCS
mirall/application.cpp
mirall/fileutils.cpp
mirall/folder.cpp
mirall/folderwatcher.cpp
mirall/folderwizard.cpp
mirall/gitfolder.cpp
mirall/inotify.cpp
mirall/networklocation.cpp
mirall/temporarydir.cpp
mirall/syncresult.cpp
mirall/unisonfolder.cpp
)
if(CSYNC_FOUND)
set(mirall_SRCS
${mirall_SRCS}
mirall/csyncfolder.cpp
)
include_directories(${CSYNC_INCLUDE_DIR})
endif(CSYNC_FOUND)
qt4_automoc(${mirall_SRCS})
set(CSYNC_LIBRARY
csync
CACHE INTERNAL "csync library"
)
set(CSYNC_LINK_LIBRARIES
${CSYNC_LIBRARY}
${CSTDLIB_LIBRARY}
${CSYNC_REQUIRED_LIBRARIES}
${SQLITE3_LIBRARIES}
)
add_library(mirall_static STATIC ${mirall_SRCS} ${mirall_UI_SRCS})
if(HAVE_ICONV AND WITH_ICONV)
list(APPEND CSYNC_PRIVATE_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
list(APPEND CSYNC_LINK_LIBRARIES ${ICONV_LIBRARIES})
endif()
set(csync_SRCS
csync.c
csync_config.c
csync_exclude.c
csync_log.c
csync_statedb.c
csync_time.c
csync_util.c
csync_misc.c
csync_update.c
csync_reconcile.c
csync_propagate.c
vio/csync_vio.c
vio/csync_vio_handle.c
vio/csync_vio_file_stat.c
vio/csync_vio_local.c
)
if(NOT WIN32)
list(APPEND csync_SRCS csync_lock.c)
endif()
set(csync_HDRS
csync.h
vio/csync_vio.h
vio/csync_vio_file_stat.h
vio/csync_vio_handle.h
vio/csync_vio_method.h
vio/csync_vio_module.h
)
include_directories(
${CSYNC_PUBLIC_INCLUDE_DIRS}
${CSYNC_PRIVATE_INCLUDE_DIRS}
)
add_library(${CSYNC_LIBRARY} SHARED ${csync_SRCS})
target_link_libraries(${CSYNC_LINK_LIBRARIES})
set_target_properties(
${CSYNC_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
)
INSTALL(
TARGETS
${CSYNC_LIBRARY}
LIBRARY DESTINATION
${LIB_INSTALL_DIR}
ARCHIVE DESTINATION
${LIB_INSTALL_DIR}
RUNTIME DESTINATION
${BIN_INSTALL_DIR}
)
INSTALL(
FILES
${csync_HDRS}
DESTINATION
${INCLUDE_INSTALL_DIR}/${APPLICATION_NAME}
)
add_executable(mirall main.cpp)
target_link_libraries(mirall mirall_static)
target_link_libraries(mirall ${QT_LIBRARIES})
if(CSYNC_FOUND)
target_link_libraries(mirall ${CSYNC_LIBRARY})
endif(CSYNC_FOUND)
-1130
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-622
Ver Arquivo
@@ -1,622 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
* Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file csync.h
*
* @brief Application developer interface for csync.
*
* @defgroup csyncPublicAPI csync public API
*
* @{
*/
#ifndef _CSYNC_H
#define _CSYNC_H
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <config.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CSYNC_STRINGIFY(s) CSYNC_TOSTRING(s)
#define CSYNC_TOSTRING(s) #s
/* csync version macros */
#define CSYNC_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
#define CSYNC_VERSION_DOT(a, b, c) a ##.## b ##.## c
#define CSYNC_VERSION(a, b, c) CSYNC_VERSION_DOT(a, b, c)
/* csync version */
#define LIBCSYNC_VERSION_MAJOR 0
#define LIBCSYNC_VERSION_MINOR 50
#define LIBCSYNC_VERSION_MICRO 0
#define LIBCSYNC_VERSION_INT CSYNC_VERSION_INT(LIBCSYNC_VERSION_MAJOR, \
LIBCSYNC_VERSION_MINOR, \
LIBCSYNC_VERSION_MICRO)
#define LIBCSYNC_VERSION CSYNC_VERSION(LIBCSYNC_VERSION_MAJOR, \
LIBCSYNC_VERSION_MINOR, \
LIBCSYNC_VERSION_MICRO)
/*
* csync file declarations
*/
#define CSYNC_CONF_DIR ".csync"
#define CSYNC_CONF_FILE "csync.conf"
#define CSYNC_EXCLUDE_FILE "csync_exclude.conf"
#define CSYNC_LOCK_FILE "lock"
/**
* Instruction enum. In the file traversal structure, it describes
* the csync state of a file.
*/
enum csync_status_codes_e {
CSYNC_STATUS_OK = 0,
CSYNC_STATUS_ERROR = 1024, /* don't use this code,
just use in csync_status_ok */
CSYNC_STATUS_UNSUCCESSFUL,
CSYNC_STATUS_NO_LOCK,
CSYNC_STATUS_STATEDB_LOAD_ERROR,
CSYNC_STATUS_STATEDB_WRITE_ERROR,
CSYNC_STATUS_NO_MODULE,
CSYNC_STATUS_TIMESKEW,
CSYNC_STATUS_FILESYSTEM_UNKNOWN,
CSYNC_STATUS_TREE_ERROR,
CSYNC_STATUS_MEMORY_ERROR,
CSYNC_STATUS_PARAM_ERROR,
CSYNC_STATUS_UPDATE_ERROR,
CSYNC_STATUS_RECONCILE_ERROR,
CSYNC_STATUS_PROPAGATE_ERROR,
CSYNC_STATUS_REMOTE_ACCESS_ERROR,
CSYNC_STATUS_REMOTE_CREATE_ERROR,
CSYNC_STATUS_REMOTE_STAT_ERROR,
CSYNC_STATUS_LOCAL_CREATE_ERROR,
CSYNC_STATUS_LOCAL_STAT_ERROR,
CSYNC_STATUS_PROXY_ERROR,
CSYNC_STATUS_LOOKUP_ERROR,
CSYNC_STATUS_SERVER_AUTH_ERROR,
CSYNC_STATUS_PROXY_AUTH_ERROR,
CSYNC_STATUS_CONNECT_ERROR,
CSYNC_STATUS_TIMEOUT,
CSYNC_STATUS_HTTP_ERROR,
CSYNC_STATUS_PERMISSION_DENIED,
CSYNC_STATUS_NOT_FOUND,
CSYNC_STATUS_FILE_EXISTS,
CSYNC_STATUS_OUT_OF_SPACE,
CSYNC_STATUS_QUOTA_EXCEEDED,
CSYNC_STATUS_SERVICE_UNAVAILABLE,
CSYNC_STATUS_FILE_SIZE_ERROR,
CSYNC_STATUS_CONTEXT_LOST,
CSYNC_STATUS_MERGE_FILETREE_ERROR,
CSYNC_STATUS_CSYNC_STATUS_ERROR,
CSYNC_STATUS_OPENDIR_ERROR,
CSYNC_STATUS_READDIR_ERROR,
CSYNC_STATUS_OPEN_ERROR,
};
typedef enum csync_status_codes_e CSYNC_STATUS;
#ifndef likely
# define likely(x) (x)
#endif
#ifndef unlikely
# define unlikely(x) (x)
#endif
#define CSYNC_STATUS_IS_OK(x) (likely((x) == CSYNC_STATUS_OK))
#define CSYNC_STATUS_IS_ERR(x) (unlikely((x) >= CSYNC_STATUS_ERROR))
#define CSYNC_STATUS_IS_EQUAL(x, y) ((x) == (y))
enum csync_instructions_e {
CSYNC_INSTRUCTION_NONE = 0x00000000,
CSYNC_INSTRUCTION_EVAL = 0x00000001,
CSYNC_INSTRUCTION_REMOVE = 0x00000002,
CSYNC_INSTRUCTION_RENAME = 0x00000004,
CSYNC_INSTRUCTION_NEW = 0x00000008,
CSYNC_INSTRUCTION_CONFLICT = 0x00000010,
CSYNC_INSTRUCTION_IGNORE = 0x00000020,
CSYNC_INSTRUCTION_SYNC = 0x00000040,
CSYNC_INSTRUCTION_STAT_ERROR = 0x00000080,
CSYNC_INSTRUCTION_ERROR = 0x00000100,
/* instructions for the propagator */
CSYNC_INSTRUCTION_DELETED = 0x00000200,
CSYNC_INSTRUCTION_UPDATED = 0x00000400
};
/**
* CSync File Traversal structure.
*
* This structure is passed to the visitor function for every file
* which is seen.
* Note: The file size is missing here because type off_t is depending
* on the large file support in your build. Make sure to check
* that cmake and the callback app are compiled with the same
* setting for it, such as:
* -D_LARGEFILE64_SOURCE or -D_LARGEFILE_SOURCE
*
*/
struct csync_tree_walk_file_s {
const char *path;
/* off_t size; */
time_t modtime;
#ifdef _WIN32
uint32_t uid;
uint32_t gid;
#else
uid_t uid;
gid_t gid;
#endif
mode_t mode;
int type;
enum csync_instructions_e instruction;
};
typedef struct csync_tree_walk_file_s TREE_WALK_FILE;
/**
* csync handle
*/
typedef struct csync_s CSYNC;
typedef int (*csync_auth_callback) (const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata);
typedef void (*csync_log_callback) (int verbosity,
const char *function,
const char *buffer,
void *userdata);
/**
* @brief Check internal csync status.
*
* @param csync The context to check.
*
* @return true if status is error free, false for error states.
*/
bool csync_status_ok(CSYNC *ctx);
/**
* @brief Allocate a csync context.
*
* @param csync The context variable to allocate.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_create(CSYNC **csync, const char *local, const char *remote);
/**
* @brief Initialize the file synchronizer.
*
* This function loads the configuration, the statedb and locks the client.
*
* @param ctx The context to initialize.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_init(CSYNC *ctx);
/**
* @brief Update detection
*
* @param ctx The context to run the update detection on.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_update(CSYNC *ctx);
/**
* @brief Reconciliation
*
* @param ctx The context to run the reconciliation on.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_reconcile(CSYNC *ctx);
/**
* @brief Propagation
*
* @param ctx The context to run the propagation on.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_propagate(CSYNC *ctx);
/**
* @brief Commit the sync results to journal
*
* @param ctx The context to commit.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_commit(CSYNC *ctx);
/**
* @brief Destroy the csync context
*
* Writes the statedb, unlocks csync and frees the memory.
*
* @param ctx The context to destroy.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_destroy(CSYNC *ctx);
/**
* @brief Check if csync is the required version or get the version
* string.
*
* @param req_version The version required.
*
* @return If the version of csync is newer than the version
* required it will return a version string.
* NULL if the version is older.
*
* Example:
*
* @code
* if (csync_version(CSYNC_VERSION_INT(0,42,1)) == NULL) {
* fprintf(stderr, "libcsync version is too old!\n");
* exit(1);
* }
*
* if (debug) {
* printf("csync %s\n", csync_version(0));
* }
* @endcode
*/
const char *csync_version(int req_version);
/**
* @brief Add an additional exclude list.
*
* @param ctx The context to add the exclude list.
*
* @param path The path pointing to the file.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_add_exclude_list(CSYNC *ctx, const char *path);
/**
* @brief Get the config directory.
*
* @param ctx The csync context.
*
* @return The path of the config directory or NULL on error.
*/
const char *csync_get_config_dir(CSYNC *ctx);
/**
* @brief Change the config directory.
*
* @param ctx The csync context.
*
* @param path The path to the new config directory.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_config_dir(CSYNC *ctx, const char *path);
/**
* @brief Remove the complete config directory.
*
* @param ctx The csync context.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_remove_config_dir(CSYNC *ctx);
/**
* @brief Enable the usage of the statedb. It is enabled by default.
*
* @param ctx The csync context.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_enable_statedb(CSYNC *ctx);
/**
* @brief Disable the usage of the statedb. It is enabled by default.
*
* @param ctx The csync context.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_disable_statedb(CSYNC *ctx);
/**
* @brief Check if the statedb usage is enabled.
*
* @param ctx The csync context.
*
* @return 1 if it is enabled, 0 if it is disabled.
*/
int csync_is_statedb_disabled(CSYNC *ctx);
/**
* @brief Get the userdata saved in the context.
*
* @param ctx The csync context.
*
* @return The userdata saved in the context, NULL if an error
* occured.
*/
void *csync_get_userdata(CSYNC *ctx);
/**
* @brief Save userdata to the context which is passed to the auth
* callback function.
*
* @param ctx The csync context.
*
* @param userdata The userdata to be stored in the context.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_userdata(CSYNC *ctx, void *userdata);
/**
* @brief Get the authentication callback set.
*
* @param ctx The csync context.
*
* @return The authentication callback set or NULL if an error
* occured.
*/
csync_auth_callback csync_get_auth_callback(CSYNC *ctx);
/**
* @brief Set the authentication callback.
*
* @param ctx The csync context.
*
* @param cb The authentication callback.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_auth_callback(CSYNC *ctx, csync_auth_callback cb);
/**
* @brief Set the log level.
*
* @param[in] level The log verbosity.
*
* @return 0 on success, < 0 if an error occured.
*/
int csync_set_log_level(int level);
/**
* @brief Get the log verbosity
*
* @return The log verbosity, -1 on error.
*/
int csync_get_log_level(void);
/**
* @brief Get the logging callback set.
*
* @return The logging callback set or NULL if an error
* occured.
*/
csync_log_callback csync_get_log_callback(void);
/**
* @brief Set the logging callback.
*
* @param cb The logging callback.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_log_callback(csync_log_callback cb);
/**
* @brief get the userdata set for the logging callback.
*
* @return The userdata or NULL.
*/
void *csync_get_log_userdata(void);
/**
* @brief Set the userdata passed to the logging callback.
*
* @param[in] data The userdata to set.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_log_userdata(void *data);
/**
* @brief Get the path of the statedb file used.
*
* @param ctx The csync context.
*
* @return The path to the statedb file, NULL if an error occured.
*/
const char *csync_get_statedb_file(CSYNC *ctx);
/**
* @brief Enable the creation of backup copys if files are changed on both sides
*
* @param ctx The csync context.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_enable_conflictcopys(CSYNC *ctx);
/**
* @brief Flag to tell csync that only a local run is intended. Call before csync_init
*
* @param local_only Bool flag to indicate local only mode.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_local_only( CSYNC *ctx, bool local_only );
/**
* @brief Retrieve the flag to tell csync that only a local run is intended.
*
* @return 1: stay local only, 0: local and remote mode
*/
bool csync_get_local_only( CSYNC *ctx );
/* Used for special modes or debugging */
int csync_get_status(CSYNC *ctx);
/* Used for special modes or debugging */
int csync_set_status(CSYNC *ctx, int status);
typedef int csync_treewalk_visit_func(TREE_WALK_FILE* ,void*);
/**
* @brief Walk the local file tree and call a visitor function for each file.
*
* @param ctx The csync context.
* @param visitor A callback function to handle the file info.
* @param filter A filter, built from and'ed csync_instructions_e
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_walk_local_tree(CSYNC *ctx, csync_treewalk_visit_func *visitor, int filter);
/**
* @brief Walk the remote file tree and call a visitor function for each file.
*
* @param ctx The csync context.
* @param visitor A callback function to handle the file info.
* @param filter A filter, built from and'ed csync_instructions_e
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_walk_remote_tree(CSYNC *ctx, csync_treewalk_visit_func *visitor, int filter);
/**
* @brief Get the csync status string.
*
* @param ctx The csync context.
*
* @return A const pointer to a string with more precise status info.
*/
const char *csync_get_status_string(CSYNC *ctx);
#ifdef WITH_ICONV
/**
* @brief Set iconv source codec for filenames.
*
* @param from Source codec.
*
* @return 0 on success, or an iconv error number.
*/
int csync_set_iconv_codec(const char *from);
#endif
/**
* @brief Set a property to module
*
* @param ctx The csync context.
*
* @param key The property key
*
* @param value An opaque pointer to the data.
*
* @return 0 on success, less than 0 if an error occured.
*/
int csync_set_module_property(CSYNC *ctx, const char *key, void *value);
/*
* Progress callbacks.
*/
enum csync_notify_type_e { CSYNC_NOTIFY_START_DOWNLOAD, CSYNC_NOTIFY_START_UPLOAD,
CSYNC_NOTIFY_PROGRESS, CSYNC_NOTIFY_FINISHED_DOWNLOAD,
CSYNC_NOTIFY_FINISHED_UPLOAD };
/**
* @brief Callback definition for individual file progress callback.
*
* @param remote_url The currently handled file.
*
* @param kind The type of progress.
*
* @param o1 The current transmitted bytes.
*
* @param o2 The size of the file.
*/
typedef void (*csync_file_progress_callback) (const char *remote_url, enum csync_notify_type_e kind,
long long o1, long long o2, void *userdata);
/**
* @brief Set a progress callback for individual files.
*
* This callback reports about up- or download progress of a individual file.
*
* @param ctx The csync context.
*
* @param cb The callback
*/
int csync_set_file_progress_callback(CSYNC* ctx, csync_file_progress_callback cb);
/**
* @brief Callback definition for overall progress callback.
*
* @param file_no The current number of up- or downloaded files.
*
* @param file_cnt The overall number of files to transmit.
*
* @param o1 The current transmitted bytes.
*
* @param o2 The overall sum of bytes to transmit.
*
* @param userdata The user data pointer.
*/
typedef void (*csync_overall_progress_callback) (const char *file_name,
int file_no,
int file_cnt,
long long o1,
long long o2,
void *userdata);
/**
* @brief Set a progress callback for the overall files.
*
* This callback reports about overall up- or download progress.
*
* @param ctx The csync context.
*
* @param cb The callback
*/
int csync_set_overall_progress_callback (CSYNC* ctx, csync_overall_progress_callback cb);
#ifdef __cplusplus
}
#endif
/**
* }@
*/
#endif /* _CSYNC_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
-310
Ver Arquivo
@@ -1,310 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <ctype.h>
#include "c_lib.h"
#include "c_private.h"
#include "csync_private.h"
#include "csync_config.h"
#define CSYNC_LOG_CATEGORY_NAME "csync.config"
#include "csync_log.h"
enum csync_config_opcode_e {
COC_UNSUPPORTED = -1,
COC_MAX_TIMEDIFF,
COC_MAX_DEPTH,
COC_WITH_CONFLICT_COPY
};
struct csync_config_keyword_table_s {
const char *name;
enum csync_config_opcode_e opcode;
};
static struct csync_config_keyword_table_s csync_config_keyword_table[] = {
{ "max_depth", COC_MAX_DEPTH },
{ "max_time_difference", COC_MAX_TIMEDIFF },
{ "with_confilct_copies", COC_WITH_CONFLICT_COPY },
{ NULL, COC_UNSUPPORTED }
};
static enum csync_config_opcode_e csync_config_get_opcode(char *keyword) {
int i;
for (i = 0; csync_config_keyword_table[i].name != NULL; i++) {
if (strcasecmp(keyword, csync_config_keyword_table[i].name) == 0) {
return csync_config_keyword_table[i].opcode;
}
}
return COC_UNSUPPORTED;
}
static int _csync_config_copy_default (const char *config) {
int re = 0;
int rc;
#ifdef _WIN32
/* For win32, try to copy the conf file from the directory from where the app was started. */
char buf[MAX_PATH+1];
int len = 0;
/* Get the path from where the application was started */
len = GetModuleFileName(NULL, buf, MAX_PATH);
if(len== 0) {
re = -1;
} else {
/* the path has still owncloud.exe or mirall.exe at the end.
* find it and copy the name of the conf file instead. */
if( c_streq( buf+strlen(buf)-strlen("owncloud.exe"), "owncloud.exe")) {
strcpy(buf+strlen(buf)-strlen("owncloud.exe"), CSYNC_CONF_FILE );
}
if( c_streq( buf+strlen(buf)-strlen("mirall.exe"), "mirall.exe")) {
strcpy(buf+strlen(buf)-strlen("mirall.exe"), CSYNC_CONF_FILE );
}
if(c_copy(buf, config, 0644) < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Could not copy /%s to %s", buf, config );
re = -1;
}
}
#else
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Copy %s/config/%s to %s", SYSCONFDIR,
CSYNC_CONF_FILE, config);
# ifdef WITH_UNIT_TESTING
rc = c_copy(BINARYDIR "/config/" CSYNC_CONF_FILE, config, 0644);
# else
rc = 0;
# endif
if (rc < 0) {
rc = c_copy(SYSCONFDIR "/csync/" CSYNC_CONF_FILE, config, 0644);
}
if (rc < 0) {
re = -1;
}
#endif
return re;
}
static char *csync_config_get_cmd(char **str) {
register char *c;
char *r;
/* Ignore leading spaces */
for (c = *str; *c; c++) {
if (! isblank(*c)) {
break;
}
}
if (*c == '\"') {
for (r = ++c; *c; c++) {
if (*c == '\"') {
*c = '\0';
goto out;
}
}
}
for (r = c; *c; c++) {
if (*c == '\n') {
*c = '\0';
goto out;
}
}
out:
*str = c + 1;
return r;
}
static char *csync_config_get_token(char **str) {
register char *c;
char *r;
c = csync_config_get_cmd(str);
for (r = c; *c; c++) {
if (isblank(*c)) {
*c = '\0';
goto out;
}
}
out:
*str = c + 1;
return r;
}
static int csync_config_get_int(char **str, int notfound) {
char *p, *endp;
int i;
p = csync_config_get_token(str);
if (p && *p) {
i = strtol(p, &endp, 10);
if (p == endp) {
return notfound;
}
return i;
}
return notfound;
}
static const char *csync_config_get_str_tok(char **str, const char *def) {
char *p;
p = csync_config_get_token(str);
if (p && *p) {
return p;
}
return def;
}
static int csync_config_get_yesno(char **str, int notfound) {
const char *p;
p = csync_config_get_str_tok(str, NULL);
if (p == NULL) {
return notfound;
}
if (strncasecmp(p, "yes", 3) == 0) {
return 1;
} else if (strncasecmp(p, "no", 2) == 0) {
return 0;
}
return notfound;
}
static int csync_config_parse_line(CSYNC *ctx,
const char *line,
unsigned int count)
{
enum csync_config_opcode_e opcode;
char *s, *x;
char *keyword;
size_t len;
int i;
x = s = c_strdup(line);
if (s == NULL) {
return -1;
}
/* Remove trailing spaces */
for (len = strlen(s) - 1; len > 0; len--) {
if (! isspace(s[len])) {
break;
}
s[len] = '\0';
}
keyword = csync_config_get_token(&s);
if (keyword == NULL || keyword[0] == '#' ||
keyword[0] == '\0' || keyword[0] == '\n') {
free(x);
return 0;
}
opcode = csync_config_get_opcode(keyword);
switch (opcode) {
case COC_MAX_DEPTH:
i = csync_config_get_int(&s, 50);
if (i > 0) {
ctx->options.max_depth = i;
}
break;
case COC_MAX_TIMEDIFF:
i = csync_config_get_int(&s, 10);
if (i >= 0) {
ctx->options.max_time_difference = i;
}
break;
case COC_WITH_CONFLICT_COPY:
i = csync_config_get_yesno(&s, -1);
if (i > 0) {
ctx->options.with_conflict_copys = true;
} else {
ctx->options.with_conflict_copys = false;
}
break;
case COC_UNSUPPORTED:
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
"Unsupported option: %s, line: %d\n",
keyword, count);
break;
}
free(x);
return 0;
}
int csync_config_parse_file(CSYNC *ctx, const char *config)
{
unsigned int count = 0;
char line[1024] = {0};
char *s;
FILE *f;
/* copy default config, if no config exists */
if (!c_isfile(config)) {
if (_csync_config_copy_default(config) < 0) {
return -1;
}
}
f = fopen(config, "r");
if (f == NULL) {
return 0;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
"Reading configuration data from %s",
config);
s = fgets(line, sizeof(line), f);
while (s != NULL) {
int rc;
count++;
rc = csync_config_parse_line(ctx, line, count);
if (rc < 0) {
fclose(f);
return -1;
}
s = fgets(line, sizeof(line), f);
}
fclose(f);
return 0;
}
-40
Ver Arquivo
@@ -1,40 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSYNC_CONFIG_H
#define _CSYNC_CONFIG_H
/**
* @internal
*
* @brief Load the csync configuration.
*
* @param ctx The csync context to use.
*
* @param config The path to the config file.
*
* @return 0 on success, < 0 on error.
*/
int csync_config_load(CSYNC *ctx, const char *config);
int csync_config_parse_file(CSYNC *ctx, const char *config);
#endif /* _CSYNC_X_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
-198
Ver Arquivo
@@ -1,198 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "c_lib.h"
#include "csync_private.h"
#include "csync_exclude.h"
#include "csync_misc.h"
#define CSYNC_LOG_CATEGORY_NAME "csync.exclude"
#include "csync_log.h"
static int _csync_exclude_add(CSYNC *ctx, const char *string) {
c_strlist_t *list;
if (ctx->excludes == NULL) {
ctx->excludes = c_strlist_new(32);
if (ctx->excludes == NULL) {
return -1;
}
}
if (ctx->excludes->count == ctx->excludes->size) {
list = c_strlist_expand(ctx->excludes, 2 * ctx->excludes->size);
if (list == NULL) {
return -1;
}
ctx->excludes = list;
}
return c_strlist_add(ctx->excludes, string);
}
int csync_exclude_load(CSYNC *ctx, const char *fname) {
int fd = -1;
int i = 0;
int rc = -1;
off_t size;
char *buf = NULL;
char *entry = NULL;
mbchar_t *w_fname;
if (ctx == NULL || fname == NULL) {
return -1;
}
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
w_fname = c_utf8_to_locale(fname);
if (w_fname == NULL) {
return -1;
}
fd = _topen(w_fname, O_RDONLY);
c_free_locale_string(w_fname);
if (fd < 0) {
return -1;
}
size = lseek(fd, 0, SEEK_END);
if (size < 0) {
rc = -1;
goto out;
}
lseek(fd, 0, SEEK_SET);
if (size == 0) {
rc = 0;
goto out;
}
buf = c_malloc(size + 1);
if (buf == NULL) {
rc = -1;
goto out;
}
if (read(fd, buf, size) != size) {
rc = -1;
goto out;
}
buf[size] = '\0';
/* FIXME: Use fgets and don't add duplicates */
entry = buf;
for (i = 0; i < size; i++) {
if (buf[i] == '\n') {
if (entry != buf + i) {
buf[i] = '\0';
if (*entry != '#' || *entry == '\n') {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Adding entry: %s", entry);
rc = _csync_exclude_add(ctx, entry);
if (rc < 0) {
goto out;
}
}
}
entry = buf + i + 1;
}
}
rc = 0;
out:
SAFE_FREE(buf);
close(fd);
return rc;
}
void csync_exclude_destroy(CSYNC *ctx) {
c_strlist_destroy(ctx->excludes);
}
int csync_excluded(CSYNC *ctx, const char *path) {
size_t i;
const char *p;
char *bname;
int rc;
int match = 0;
if (! ctx->options.unix_extensions) {
for (p = path; *p; p++) {
switch (*p) {
case '\\':
case ':':
case '?':
case '*':
case '"':
case '>':
case '<':
case '|':
return 1;
default:
break;
}
}
}
rc = csync_fnmatch(".csync_journal.db*", path, 0);
if (rc == 0) {
return 1;
}
bname = c_basename(path);
if (bname == NULL) {
return 0;
}
rc = csync_fnmatch(".csync_journal.db*", bname, 0);
if (rc == 0) {
match = 1;
goto out;
}
if (ctx->excludes == NULL) {
goto out;
}
for (i = 0; match == 0 && i < ctx->excludes->count; i++) {
rc = csync_fnmatch(ctx->excludes->vector[i], path, 0);
if (rc == 0) {
match = 1;
}
rc = csync_fnmatch(ctx->excludes->vector[i], bname, 0);
if (rc == 0) {
match = 1;
}
}
out:
free(bname);
return match;
}
-55
Ver Arquivo
@@ -1,55 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSYNC_EXCLUDE_H
#define _CSYNC_EXCLUDE_H
/**
* @brief Load exclude list
*
* @param ctx The context of the synchronizer.
* @param fname The filename to load.
*
* @return 0 on success, -1 if an error occured with errno set.
*/
int csync_exclude_load(CSYNC *ctx, const char *fname);
/**
* @brief Destroy the exclude list in memory.
*
* @param ctx The synchronizer context.
*/
void csync_exclude_destroy(CSYNC *ctx);
/**
* @brief Check if the given path should be excluded.
*
* This excludes also paths which can't be used without unix extensions.
*
* @param ctx The synchronizer context.
* @param path The patch to check.
*
* @return 1 if excluded, 0 if not.
*/
int csync_excluded(CSYNC *ctx, const char *path);
#endif /* _CSYNC_EXCLUDE_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
-219
Ver Arquivo
@@ -1,219 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "c_lib.h"
#include "csync_lock.h"
#define CSYNC_LOG_CATEGORY_NAME "csync.lock"
#include "csync_log.h"
static int _csync_lock_create(const char *lockfile) {
int fd = -1;
pid_t pid = 0;
int rc = -1;
char errbuf[256] = {0};
char *ctmpfile = NULL;
char *dir = NULL;
char *buf = NULL;
mode_t mask;
pid = getpid();
dir = c_dirname(lockfile);
if (dir == NULL) {
rc = -1;
goto out;
}
if (asprintf(&ctmpfile, "%s/tmp_lock_XXXXXX", dir) < 0) {
rc = -1;
goto out;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Create temporary lock file: %s", ctmpfile);
mask = umask(0077);
fd = mkstemp(ctmpfile);
umask(mask);
if (fd < 0) {
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"Unable to create temporary lock file: %s - %s",
ctmpfile,
errbuf);
rc = -1;
goto out;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Write pid (%d) to temporary lock file: %s", pid, ctmpfile);
pid = asprintf(&buf, "%d\n", pid);
if (write(fd, buf, pid) == pid) {
/* Create lock file */
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Create a hardlink from %s to %s.", ctmpfile, lockfile);
if (link(ctmpfile, lockfile) < 0 ) {
/* Oops, alredy locked */
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO,
"Already locked: %s - %s",
lockfile,
errbuf);
rc = -1;
goto out;
}
} else {
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"Can't create %s - %s",
ctmpfile,
errbuf);
rc = -1;
goto out;
}
rc = 0;
out:
if (fd > 0) {
close(fd);
}
if (ctmpfile) {
unlink(ctmpfile);
}
SAFE_FREE(buf);
SAFE_FREE(dir);
SAFE_FREE(ctmpfile);
return rc;
}
static pid_t _csync_lock_read(const char *lockfile) {
char errbuf[256] = {0};
char buf[8] = {0};
long int tmp;
ssize_t rc;
int fd;
pid_t pid;
mbchar_t *wlockfile;
/* Read PID from existing lock */
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
wlockfile = c_utf8_to_locale(lockfile);
if (wlockfile == NULL) {
return -1;
}
fd = _topen(wlockfile, O_RDONLY);
c_free_locale_string(wlockfile);
if (fd < 0) {
return -1;
}
rc = read(fd, buf, sizeof(buf));
close(fd);
if (rc <= 0) {
return -1;
}
buf[sizeof(buf) - 1] = '\0';
tmp = strtol(buf, NULL, 10);
if (tmp == 0 || tmp > 0xFFFF || errno == ERANGE) {
/* Broken lock file */
strerror_r(ERANGE, errbuf, sizeof(errbuf));
if (unlink(lockfile) < 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"Unable to remove broken lock %s - %s",
lockfile,
errbuf);
}
return -1;
}
pid = (pid_t)(tmp & 0xFFFF);
/* Check if process is still alive */
if (kill(pid, 0) < 0 && errno == ESRCH) {
/* Process is dead. Remove stale lock. */
wlockfile = c_utf8_to_locale(lockfile);
if (_tunlink(wlockfile) < 0) {
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"Unable to remove stale lock %s - %s",
lockfile,
errbuf);
}
c_free_locale_string(wlockfile);
return -1;
}
return pid;
}
int csync_lock(const char *lockfile) {
/* Check if lock already exists. */
if (_csync_lock_read(lockfile) > 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Aborting, another synchronization process is running.");
return -1;
}
CSYNC_LOG(CSYNC_LOG_PRIORITY_INFO, "Creating lock file: %s", lockfile);
return _csync_lock_create(lockfile);
}
void csync_lock_remove(const char *lockfile) {
char errbuf[256] = {0};
mbchar_t *wlockfile;
/* You can't remove the lock if it is from another process */
if (_csync_lock_read(lockfile) == getpid()) {
wlockfile = c_utf8_to_locale(lockfile);
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Removing lock file: %s", lockfile);
if (_tunlink(wlockfile) < 0) {
strerror_r(errno, errbuf, sizeof(errbuf));
CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR,
"Unable to remove lock %s - %s",
lockfile,
errbuf);
}
c_free_locale_string(wlockfile);
}
}
-66
Ver Arquivo
@@ -1,66 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _CSYNC_LOCK_H
#define _CSYNC_LOCK_H
#include "csync.h"
/**
* @file csync_lock.h
*
* @brief File locking
*
* This prevents csync to start the same synchronization task twice which could
* lead to several problems.
*
* @defgroup csyncLockingInternals csync file lockling internals
* @ingroup csyncInternalAPI
*
* @{
*/
/**
* @brief Lock the client if possible.
*
* This functiion tries to lock the client with a lock file.
*
* @param lockfile The lock file to create.
*
* @return 0 if the lock was successfull, less than 0 if the lock file
* couldn't be created or if it is already locked.
*/
int csync_lock(const char *lockfile);
/**
* @brief Remove the lockfile
*
* Only our own lock can be removed. This function can't remove a lock from
* another client.
*
* @param lockfile The lock file to remove.
*/
void csync_lock_remove(const char *lockfile);
/**
* }@
*/
#endif /* _CSYNC_LOCK_H */
/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
-157
Ver Arquivo
@@ -1,157 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#ifndef _WIN32
#include <sys/time.h>
#else
#include <sys/utime.h>
#endif
#include <time.h>
#include "csync_private.h"
#include "csync_log.h"
CSYNC_THREAD int csync_log_level;
CSYNC_THREAD csync_log_callback csync_log_cb;
CSYNC_THREAD void *csync_log_userdata;
static int current_timestring(int hires, char *buf, size_t len)
{
char tbuf[64];
struct timeval tv;
struct tm *tm;
time_t t;
gettimeofday(&tv, NULL);
t = (time_t) tv.tv_sec;
tm = localtime(&t);
if (tm == NULL) {
return -1;
}
if (hires) {
strftime(tbuf, sizeof(tbuf) - 1, "%Y/%m/%d %H:%M:%S", tm);
snprintf(buf, len, "%s.%06ld", tbuf, tv.tv_usec);
} else {
strftime(tbuf, sizeof(tbuf) - 1, "%Y/%m/%d %H:%M:%S", tm);
snprintf(buf, len, "%s", tbuf);
}
return 0;
}
static void csync_log_stderr(int verbosity,
const char *function,
const char *buffer)
{
char date[64] = {0};
int rc;
rc = current_timestring(1, date, sizeof(date));
if (rc == 0) {
fprintf(stderr, "[%s, %d] %s:", date, verbosity, function);
} else {
fprintf(stderr, "[%d] %s", verbosity, function);
}
fprintf(stderr, " %s\n", buffer);
}
static void csync_log_function(int verbosity,
const char *function,
const char *buffer)
{
csync_log_callback log_fn = csync_get_log_callback();
if (log_fn) {
char buf[1024];
snprintf(buf, sizeof(buf), "%s: %s", function, buffer);
log_fn(verbosity,
function,
buf,
csync_get_log_userdata());
return;
}
csync_log_stderr(verbosity, function, buffer);
}
void csync_log(int verbosity,
const char *function,
const char *format, ...)
{
char buffer[1024];
va_list va;
if (verbosity <= csync_get_log_level()) {
va_start(va, format);
vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
csync_log_function(verbosity, function, buffer);
}
}
int csync_set_log_level(int level) {
if (level < 0) {
return -1;
}
csync_log_level = level;
return 0;
}
int csync_get_log_level(void) {
return csync_log_level;
}
int csync_set_log_callback(csync_log_callback cb) {
if (cb == NULL) {
return -1;
}
csync_log_cb = cb;
return 0;
}
csync_log_callback csync_get_log_callback(void) {
return csync_log_cb;
}
void *csync_get_log_userdata(void)
{
return csync_log_userdata;
}
int csync_set_log_userdata(void *data)
{
csync_log_userdata = data;
return 0;
}
-69
Ver Arquivo
@@ -1,69 +0,0 @@
/*
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file csync_log.h
*
* @brief Logging interface of csync
*
* @defgroup csyncLogInternals csync logging internals
* @ingroup csyncInternalAPI
*
* @{
*/
#ifndef _CSYNC_LOG_H
#define _CSYNC_LOG_H
/* GCC have printf type attribute check. */
#ifdef __GNUC__
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
#else
#define PRINTF_ATTRIBUTE(a,b)
#endif /* __GNUC__ */
enum csync_log_priority_e {
CSYNC_LOG_PRIORITY_NOLOG = 0,
CSYNC_LOG_PRIORITY_FATAL,
CSYNC_LOG_PRIORITY_ALERT,
CSYNC_LOG_PRIORITY_CRIT,
CSYNC_LOG_PRIORITY_ERROR,
CSYNC_LOG_PRIORITY_WARN,
CSYNC_LOG_PRIORITY_NOTICE,
CSYNC_LOG_PRIORITY_INFO,
CSYNC_LOG_PRIORITY_DEBUG,
CSYNC_LOG_PRIORITY_TRACE,
CSYNC_LOG_PRIORITY_NOTSET,
CSYNC_LOG_PRIORITY_UNKNOWN,
};
#define CSYNC_LOG(priority, ...) \
csync_log(priority, __FUNCTION__, __VA_ARGS__)
void csync_log(int verbosity,
const char *function,
const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
/**
* }@
*/
#endif /* _CSYNC_LOG_H */
/* vim: set ft=c.doxygen ts=4 sw=4 et cindent: */

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais