[Csync2] sqlite and inotify
Dennis Schafroth
dennis at schafroth.dk
Wed Jan 16 18:52:25 CET 2008
I have created a patch to get csync2 running with sqlite3.
-------------- next part --------------
diff -C 3 csync2-1.34/action.c csync2-1.34a/action.c
*** csync2-1.34/action.c 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/action.c 2007-12-30 20:17:52.000000000 +0100
***************
*** 69,75 ****
"SELECT filename from action WHERE command = '%s' "
"and logfile = '%s'", command, logfile)
{
! textlist_add(&tl, SQL_V[0], 0);
} SQL_END;
mark = strstr(command_clr, "%%");
--- 69,75 ----
"SELECT filename from action WHERE command = '%s' "
"and logfile = '%s'", command, logfile)
{
! textlist_add(&tl, csync_db_get_column_text(SQL_STMT, 0), 0);
} SQL_END;
mark = strstr(command_clr, "%%");
***************
*** 130,136 ****
SQL_BEGIN("Checking for sceduled commands",
"SELECT command, logfile FROM action GROUP BY command, logfile")
{
! textlist_add2(&tl, SQL_V[0], SQL_V[1], 0);
} SQL_END;
for (t = tl; t != 0; t = t->next)
--- 130,136 ----
SQL_BEGIN("Checking for sceduled commands",
"SELECT command, logfile FROM action GROUP BY command, logfile")
{
! textlist_add2(&tl, csync_db_get_column_text(SQL_STMT, 0), csync_db_get_column_text(SQL_STMT, 1), 0);
} SQL_END;
for (t = tl; t != 0; t = t->next)
Only in csync2-1.34a/: action.o
Only in csync2-1.34a/: cfgfile_parser.c
Only in csync2-1.34a/: cfgfile_parser.h
Only in csync2-1.34a/: cfgfile_parser.o
Only in csync2-1.34a/: cfgfile_scanner.c
Only in csync2-1.34a/: cfgfile_scanner.o
diff -C 3 csync2-1.34/check.c csync2-1.34a/check.c
*** csync2-1.34/check.c 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/check.c 2007-12-30 20:15:58.000000000 +0100
***************
*** 159,166 ****
"SELECT filename from file where "
"filename = '%s' %s ORDER BY filename", url_encode(file), where_rec)
{
! const char *filename = url_decode(SQL_V[0]);
! if ( lstat_strict(prefixsubst(filename), &st) != 0 || csync_check_pure(filename) )
textlist_add(&tl, filename, 0);
} SQL_END;
--- 159,167 ----
"SELECT filename from file where "
"filename = '%s' %s ORDER BY filename", url_encode(file), where_rec)
{
! const char *filename = url_decode(csync_db_get_column_text(SQL_STMT, 0));
!
! if ( lstat_strict(prefixsubst(filename), &st) != 0 || csync_check_pure(filename) )
textlist_add(&tl, filename, 0);
} SQL_END;
***************
*** 231,237 ****
"filename = '%s'", url_encode(file))
{
if ( !csync_cmpchecktxt(checktxt,
! url_decode(SQL_V[0])) ) {
csync_debug(2, "File has changed: %s\n", file);
this_is_dirty = 1;
}
--- 232,238 ----
"filename = '%s'", url_encode(file))
{
if ( !csync_cmpchecktxt(checktxt,
! url_decode(csync_db_get_column_text(SQL_STMT, 0) ) )) {
csync_debug(2, "File has changed: %s\n", file);
this_is_dirty = 1;
}
Only in csync2-1.34a/: check.o
Only in csync2-1.34a/: checktxt.o
Only in csync2-1.34a/: config.h
diff -C 3 csync2-1.34/config.h.in csync2-1.34a/config.h.in
*** csync2-1.34/config.h.in 2007-07-24 23:04:24.000000000 +0200
--- csync2-1.34a/config.h.in 2007-12-30 22:37:33.000000000 +0100
***************
*** 6,13 ****
/* Define to 1 if you have the `rsync' library (-lrsync). */
#undef HAVE_LIBRSYNC
! /* Define to 1 if you have the `sqlite' library (-lsqlite). */
! #undef HAVE_LIBSQLITE
/* Name of package */
#undef PACKAGE
--- 6,13 ----
/* Define to 1 if you have the `rsync' library (-lrsync). */
#undef HAVE_LIBRSYNC
! /* Define to 1 if you have the `sqlite3' library (-lsqlite3). */
! #undef HAVE_LIBSQLITE3
/* Name of package */
#undef PACKAGE
diff -C 3 csync2-1.34/config.log csync2-1.34a/config.log
*** csync2-1.34/config.log 2007-12-30 22:35:00.000000000 +0100
--- csync2-1.34a/config.log 2007-12-30 23:27:48.000000000 +0100
***************
*** 1,10 ****
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
! It was created by csync2 configure 1.34, which was
generated by GNU Autoconf 2.61. Invocation command line was
! $ ./configure
## --------- ##
## Platform. ##
--- 1,10 ----
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
! It was created by csync2 configure 1.34a, which was
generated by GNU Autoconf 2.61. Invocation command line was
! $ ./configure --disable-gnutls
## --------- ##
## Platform. ##
***************
*** 117,128 ****
configure:3451: result: lex.yy
configure:3456: checking lex library
configure:3475: gcc -o conftest -g -O2 conftest.c >&5
! /tmp/ccQXTsjh.o: In function `input':
! /home/dennis/csync2-1.34/lex.yy.c:1133: undefined reference to `yywrap'
! /tmp/ccQXTsjh.o: In function `yylex':
! /home/dennis/csync2-1.34/lex.yy.c:840: undefined reference to `yywrap'
! /tmp/ccQXTsjh.o: In function `main':
! /home/dennis/csync2-1.34/conftest.l:17: undefined reference to `yywrap'
collect2: ld returned 1 exit status
configure:3481: $? = 1
configure: failed program was:
--- 117,128 ----
configure:3451: result: lex.yy
configure:3456: checking lex library
configure:3475: gcc -o conftest -g -O2 conftest.c >&5
! /tmp/ccIYwbOs.o: In function `input':
! /home/dennis/csync2-1.34a/lex.yy.c:1133: undefined reference to `yywrap'
! /tmp/ccIYwbOs.o: In function `yylex':
! /home/dennis/csync2-1.34a/lex.yy.c:840: undefined reference to `yywrap'
! /tmp/ccIYwbOs.o: In function `main':
! /home/dennis/csync2-1.34a/conftest.l:17: undefined reference to `yywrap'
collect2: ld returned 1 exit status
configure:3481: $? = 1
configure: failed program was:
***************
*** 1869,1908 ****
configure:3613: gcc -o conftest -g -O2 conftest.c -lrsync >&5
configure:3619: $? = 0
configure:3637: result: yes
! configure:3674: checking for sqlite_exec in -lsqlite
! configure:3709: gcc -o conftest -g -O2 conftest.c -lsqlite -lrsync >&5
! /usr/bin/ld: cannot find -lsqlite
! collect2: ld returned 1 exit status
! configure:3715: $? = 1
! configure: failed program was:
! | /* confdefs.h. */
! | #define PACKAGE_NAME "csync2"
! | #define PACKAGE_TARNAME "csync2"
! | #define PACKAGE_VERSION "1.34"
! | #define PACKAGE_STRING "csync2 1.34"
! | #define PACKAGE_BUGREPORT "clifford at clifford.at"
! | #define PACKAGE "csync2"
! | #define VERSION "1.34"
! | #define YYTEXT_POINTER 1
! | #define HAVE_LIBRSYNC 1
! | /* end confdefs.h. */
! |
! | /* Override any GCC internal prototype to avoid an error.
! | Use char because int might match the return type of a GCC
! | builtin and then its argument prototype would still apply. */
! | #ifdef __cplusplus
! | extern "C"
! | #endif
! | char sqlite_exec ();
! | int
! | main ()
! | {
! | return sqlite_exec ();
! | ;
! | return 0;
! | }
! configure:3733: result: no
! configure:3743: error: libsqlite is required
## ---------------- ##
## Cache variables. ##
--- 1869,1898 ----
configure:3613: gcc -o conftest -g -O2 conftest.c -lrsync >&5
configure:3619: $? = 0
configure:3637: result: yes
! configure:3674: checking for sqlite3_exec in -lsqlite3
! configure:3709: gcc -o conftest -g -O2 conftest.c -lsqlite3 -lrsync >&5
! configure:3715: $? = 0
! configure:3733: result: yes
! configure:4260: creating ./config.status
!
! ## ---------------------- ##
! ## Running config.status. ##
! ## ---------------------- ##
!
! This file was extended by csync2 config.status 1.34a, which was
! generated by GNU Autoconf 2.61. Invocation command line was
!
! CONFIG_FILES =
! CONFIG_HEADERS =
! CONFIG_LINKS =
! CONFIG_COMMANDS =
! $ ./config.status
!
! on watergate.schafroth.dk
!
! config.status:641: creating Makefile
! config.status:641: creating config.h
! config.status:900: executing depfiles commands
## ---------------- ##
## Cache variables. ##
***************
*** 1931,1937 ****
ac_cv_env_target_alias_value=
ac_cv_lib_lex=-lfl
ac_cv_lib_rsync_rs_sig_file=yes
! ac_cv_lib_sqlite_sqlite_exec=no
ac_cv_objext=o
ac_cv_path_install='/usr/bin/install -c'
ac_cv_prog_AWK=gawk
--- 1921,1927 ----
ac_cv_env_target_alias_value=
ac_cv_lib_lex=-lfl
ac_cv_lib_rsync_rs_sig_file=yes
! ac_cv_lib_sqlite3_sqlite3_exec=yes
ac_cv_objext=o
ac_cv_path_install='/usr/bin/install -c'
ac_cv_prog_AWK=gawk
***************
*** 1949,1969 ****
## Output variables. ##
## ----------------- ##
! ACLOCAL='${SHELL} /home/dennis/csync2-1.34/missing --run aclocal-1.7'
AMDEPBACKSLASH='\'
AMDEP_FALSE='#'
AMDEP_TRUE=''
! AMTAR='${SHELL} /home/dennis/csync2-1.34/missing --run tar'
! AUTOCONF='${SHELL} /home/dennis/csync2-1.34/missing --run autoconf'
! AUTOHEADER='${SHELL} /home/dennis/csync2-1.34/missing --run autoheader'
! AUTOMAKE='${SHELL} /home/dennis/csync2-1.34/missing --run automake-1.7'
AWK='gawk'
CC='gcc'
CCDEPMODE='depmode=gcc3'
CFLAGS='-g -O2'
CPPFLAGS=''
CYGPATH_W='echo'
! DEFS=''
DEPDIR='.deps'
ECHO_C=''
ECHO_N='-n'
--- 1939,1959 ----
## Output variables. ##
## ----------------- ##
! ACLOCAL='${SHELL} /home/dennis/csync2-1.34a/missing --run aclocal-1.7'
AMDEPBACKSLASH='\'
AMDEP_FALSE='#'
AMDEP_TRUE=''
! AMTAR='${SHELL} /home/dennis/csync2-1.34a/missing --run tar'
! AUTOCONF='${SHELL} /home/dennis/csync2-1.34a/missing --run autoconf'
! AUTOHEADER='${SHELL} /home/dennis/csync2-1.34a/missing --run autoheader'
! AUTOMAKE='${SHELL} /home/dennis/csync2-1.34a/missing --run automake-1.7'
AWK='gawk'
CC='gcc'
CCDEPMODE='depmode=gcc3'
CFLAGS='-g -O2'
CPPFLAGS=''
CYGPATH_W='echo'
! DEFS='-DHAVE_CONFIG_H'
DEPDIR='.deps'
ECHO_C=''
ECHO_N='-n'
***************
*** 1981,2005 ****
LIBGNUTLS_CONFIG=''
LIBGNUTLS_LIBS=''
LIBOBJS=''
! LIBS='-lrsync '
LTLIBOBJS=''
! MAKEINFO='${SHELL} /home/dennis/csync2-1.34/missing --run makeinfo'
OBJEXT='o'
PACKAGE='csync2'
PACKAGE_BUGREPORT='clifford at clifford.at'
PACKAGE_NAME='csync2'
! PACKAGE_STRING='csync2 1.34'
PACKAGE_TARNAME='csync2'
! PACKAGE_VERSION='1.34'
PATH_SEPARATOR=':'
PRIVATE_LIBRSYNC_FALSE=''
PRIVATE_LIBRSYNC_TRUE='#'
PRIVATE_LIBSQLITE_FALSE=''
! PRIVATE_LIBSQLITE_TRUE=''
SET_MAKE=''
SHELL='/bin/sh'
STRIP=''
! VERSION='1.34'
YACC='bison -y'
YFLAGS=''
ac_ct_CC='gcc'
--- 1971,1995 ----
LIBGNUTLS_CONFIG=''
LIBGNUTLS_LIBS=''
LIBOBJS=''
! LIBS='-lsqlite3 -lrsync '
LTLIBOBJS=''
! MAKEINFO='${SHELL} /home/dennis/csync2-1.34a/missing --run makeinfo'
OBJEXT='o'
PACKAGE='csync2'
PACKAGE_BUGREPORT='clifford at clifford.at'
PACKAGE_NAME='csync2'
! PACKAGE_STRING='csync2 1.34a'
PACKAGE_TARNAME='csync2'
! PACKAGE_VERSION='1.34a'
PATH_SEPARATOR=':'
PRIVATE_LIBRSYNC_FALSE=''
PRIVATE_LIBRSYNC_TRUE='#'
PRIVATE_LIBSQLITE_FALSE=''
! PRIVATE_LIBSQLITE_TRUE='#'
SET_MAKE=''
SHELL='/bin/sh'
STRIP=''
! VERSION='1.34a'
YACC='bison -y'
YFLAGS=''
ac_ct_CC='gcc'
***************
*** 2014,2025 ****
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
! exec_prefix='NONE'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
! install_sh='/home/dennis/csync2-1.34/install-sh'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
librsync_source_file=''
--- 2004,2015 ----
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
! exec_prefix='${prefix}'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
! install_sh='/home/dennis/csync2-1.34a/install-sh'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
librsync_source_file=''
***************
*** 2029,2035 ****
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
! prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
--- 2019,2025 ----
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
! prefix='/usr/local'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
***************
*** 2043,2054 ****
#define PACKAGE_NAME "csync2"
#define PACKAGE_TARNAME "csync2"
! #define PACKAGE_VERSION "1.34"
! #define PACKAGE_STRING "csync2 1.34"
#define PACKAGE_BUGREPORT "clifford at clifford.at"
#define PACKAGE "csync2"
! #define VERSION "1.34"
#define YYTEXT_POINTER 1
#define HAVE_LIBRSYNC 1
! configure: exit 1
--- 2033,2045 ----
#define PACKAGE_NAME "csync2"
#define PACKAGE_TARNAME "csync2"
! #define PACKAGE_VERSION "1.34a"
! #define PACKAGE_STRING "csync2 1.34a"
#define PACKAGE_BUGREPORT "clifford at clifford.at"
#define PACKAGE "csync2"
! #define VERSION "1.34a"
#define YYTEXT_POINTER 1
#define HAVE_LIBRSYNC 1
+ #define HAVE_LIBSQLITE3 1
! configure: exit 0
Only in csync2-1.34a/: config.status
diff -C 3 csync2-1.34/configure csync2-1.34a/configure
*** csync2-1.34/configure 2007-07-24 23:04:25.000000000 +0200
--- csync2-1.34a/configure 2007-12-30 22:37:29.000000000 +0100
***************
*** 1,6 ****
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
! # Generated by GNU Autoconf 2.61 for csync2 1.34.
#
# Report bugs to <clifford at clifford.at>.
#
--- 1,6 ----
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
! # Generated by GNU Autoconf 2.61 for csync2 1.34a.
#
# Report bugs to <clifford at clifford.at>.
#
***************
*** 574,581 ****
# Identity of this package.
PACKAGE_NAME='csync2'
PACKAGE_TARNAME='csync2'
! PACKAGE_VERSION='1.34'
! PACKAGE_STRING='csync2 1.34'
PACKAGE_BUGREPORT='clifford at clifford.at'
ac_unique_file="csync2.c"
--- 574,581 ----
# Identity of this package.
PACKAGE_NAME='csync2'
PACKAGE_TARNAME='csync2'
! PACKAGE_VERSION='1.34a'
! PACKAGE_STRING='csync2 1.34a'
PACKAGE_BUGREPORT='clifford at clifford.at'
ac_unique_file="csync2.c"
***************
*** 1179,1185 ****
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
! \`configure' configures csync2 1.34 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
--- 1179,1185 ----
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
! \`configure' configures csync2 1.34a to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
***************
*** 1245,1251 ****
if test -n "$ac_init_help"; then
case $ac_init_help in
! short | recursive ) echo "Configuration of csync2 1.34:";;
esac
cat <<\_ACEOF
--- 1245,1251 ----
if test -n "$ac_init_help"; then
case $ac_init_help in
! short | recursive ) echo "Configuration of csync2 1.34a:";;
esac
cat <<\_ACEOF
***************
*** 1345,1351 ****
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
! csync2 configure 1.34
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
--- 1345,1351 ----
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
! csync2 configure 1.34a
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
***************
*** 1359,1365 ****
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
! It was created by csync2 $as_me 1.34, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
--- 1359,1365 ----
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
! It was created by csync2 $as_me 1.34a, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
***************
*** 1997,2003 ****
# Define the identity of the package.
PACKAGE='csync2'
! VERSION='1.34'
cat >>confdefs.h <<_ACEOF
--- 1997,2003 ----
# Define the identity of the package.
PACKAGE='csync2'
! VERSION='1.34a'
cat >>confdefs.h <<_ACEOF
***************
*** 3671,3683 ****
else
! { echo "$as_me:$LINENO: checking for sqlite_exec in -lsqlite" >&5
! echo $ECHO_N "checking for sqlite_exec in -lsqlite... $ECHO_C" >&6; }
! if test "${ac_cv_lib_sqlite_sqlite_exec+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
! LIBS="-lsqlite $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
--- 3671,3683 ----
else
! { echo "$as_me:$LINENO: checking for sqlite3_exec in -lsqlite3" >&5
! echo $ECHO_N "checking for sqlite3_exec in -lsqlite3... $ECHO_C" >&6; }
! if test "${ac_cv_lib_sqlite3_sqlite3_exec+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
! LIBS="-lsqlite3 $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
***************
*** 3691,3701 ****
#ifdef __cplusplus
extern "C"
#endif
! char sqlite_exec ();
int
main ()
{
! return sqlite_exec ();
;
return 0;
}
--- 3691,3701 ----
#ifdef __cplusplus
extern "C"
#endif
! char sqlite3_exec ();
int
main ()
{
! return sqlite3_exec ();
;
return 0;
}
***************
*** 3718,3747 ****
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
! ac_cv_lib_sqlite_sqlite_exec=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
! ac_cv_lib_sqlite_sqlite_exec=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
! { echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite_sqlite_exec" >&5
! echo "${ECHO_T}$ac_cv_lib_sqlite_sqlite_exec" >&6; }
! if test $ac_cv_lib_sqlite_sqlite_exec = yes; then
cat >>confdefs.h <<_ACEOF
! #define HAVE_LIBSQLITE 1
_ACEOF
! LIBS="-lsqlite $LIBS"
else
! { { echo "$as_me:$LINENO: error: libsqlite is required" >&5
! echo "$as_me: error: libsqlite is required" >&2;}
{ (exit 1); exit 1; }; }
fi
--- 3718,3747 ----
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
! ac_cv_lib_sqlite3_sqlite3_exec=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
! ac_cv_lib_sqlite3_sqlite3_exec=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
! { echo "$as_me:$LINENO: result: $ac_cv_lib_sqlite3_sqlite3_exec" >&5
! echo "${ECHO_T}$ac_cv_lib_sqlite3_sqlite3_exec" >&6; }
! if test $ac_cv_lib_sqlite3_sqlite3_exec = yes; then
cat >>confdefs.h <<_ACEOF
! #define HAVE_LIBSQLITE3 1
_ACEOF
! LIBS="-lsqlite3 $LIBS"
else
! { { echo "$as_me:$LINENO: error: libsqlite3 is required" >&5
! echo "$as_me: error: libsqlite3 is required" >&2;}
{ (exit 1); exit 1; }; }
fi
***************
*** 4553,4559 ****
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
! This file was extended by csync2 $as_me 1.34, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
--- 4553,4559 ----
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
! This file was extended by csync2 $as_me 1.34a, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
***************
*** 4606,4612 ****
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
! csync2 config.status 1.34
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
--- 4606,4612 ----
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
! csync2 config.status 1.34a
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff -C 3 csync2-1.34/configure.ac csync2-1.34a/configure.ac
*** csync2-1.34/configure.ac 2007-12-30 22:35:52.000000000 +0100
--- csync2-1.34a/configure.ac 2007-12-30 22:36:22.000000000 +0100
***************
*** 17,23 ****
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Process this file with autoconf to produce a configure script.
! AC_INIT(csync2, 1.34, clifford at clifford.at)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR(csync2.c)
--- 17,23 ----
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Process this file with autoconf to produce a configure script.
! AC_INIT(csync2, 1.34a, clifford at clifford.at)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR(csync2.c)
***************
*** 47,53 ****
AS_HELP_STRING([--with-libsqlite-source=source-tar-file],
[build this libsqlite and link statically against it (hack! hack!)]),
AC_SUBST([libsqlite_source_file], $withval),
! AC_CHECK_LIB([sqlite], [sqlite_exec], , [AC_MSG_ERROR(libsqlite is required)])
)
AM_CONDITIONAL([PRIVATE_LIBSQLITE], [test -n "$libsqlite_source_file"])
--- 47,53 ----
AS_HELP_STRING([--with-libsqlite-source=source-tar-file],
[build this libsqlite and link statically against it (hack! hack!)]),
AC_SUBST([libsqlite_source_file], $withval),
! AC_CHECK_LIB([sqlite3], [sqlite3_exec], , [AC_MSG_ERROR(libsqlite3 is required)])
)
AM_CONDITIONAL([PRIVATE_LIBSQLITE], [test -n "$libsqlite_source_file"])
Only in csync2-1.34a/: conn.o
Only in csync2-1.34a/: csync2
diff -C 3 csync2-1.34/csync2.c csync2-1.34a/csync2.c
*** csync2-1.34/csync2.c 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/csync2.c 2007-12-30 20:14:11.000000000 +0100
***************
*** 36,41 ****
--- 36,43 ----
#include <errno.h>
#include <signal.h>
#include <ctype.h>
+ #include <syslog.h>
+ #include <sqlite3.h>
#ifdef REAL_DBDIR
# undef DBDIR
***************
*** 57,62 ****
--- 59,65 ----
int csync_error_count = 0;
int csync_debug_level = 0;
FILE *csync_debug_out = 0;
+ int csync_syslog = 0;
int csync_server_child_pid = 0;
int csync_timestamps = 0;
***************
*** 293,299 ****
return 1;
}
! while ( (opt = getopt(argc, argv, "W:s:Ftp:G:P:C:D:N:HBAIXULSTMRvhcuoimfxrd")) != -1 ) {
switch (opt) {
case 'W':
csync_dump_dir_fd = atoi(optarg);
--- 296,302 ----
return 1;
}
! while ( (opt = getopt(argc, argv, "W:s:Ftp:G:P:C:D:N:HBAIXULlSTMRvhcuoimfxrd")) != -1 ) {
switch (opt) {
case 'W':
csync_dump_dir_fd = atoi(optarg);
***************
*** 349,354 ****
--- 352,361 ----
case 'v':
csync_debug_level++;
break;
+ case 'l':
+ csync_syslog = 1;
+ openlog("csync2", LOG_ODELAY, LOG_LOCAL0);
+ break;
case 'h':
if ( mode != MODE_NONE ) help(argv[0]);
mode = MODE_HINT;
***************
*** 582,589 ****
SQL_BEGIN("Check all hints",
"SELECT filename, recursive FROM hint")
{
! textlist_add(&tl, url_decode(SQL_V[0]),
! atoi(SQL_V[1]));
} SQL_END;
for (t = tl; t != 0; t = t->next) {
--- 589,596 ----
SQL_BEGIN("Check all hints",
"SELECT filename, recursive FROM hint")
{
! textlist_add(&tl, url_decode(csync_db_get_column_text(SQL_STMT, 0)),
! csync_db_get_column_int(SQL_STMT, 0));
} SQL_END;
for (t = tl; t != 0; t = t->next) {
***************
*** 659,665 ****
"SELECT filename FROM file WHERE filename = '%s' %s",
url_encode(realname), where_rec)
{
! char *filename = strdup(url_encode(SQL_V[0]));
csync_mark(filename, 0, 0);
free(filename);
} SQL_END;
--- 666,672 ----
"SELECT filename FROM file WHERE filename = '%s' %s",
url_encode(realname), where_rec)
{
! char *filename = strdup(url_encode(csync_db_get_column_text(SQL_STMT, 0) ));
csync_mark(filename, 0, 0);
free(filename);
} SQL_END;
***************
*** 695,701 ****
SQL_BEGIN("DB Dump - Hint",
"SELECT recursive, filename FROM hint ORDER BY filename")
{
! printf("%s\t%s\n", SQL_V[0], url_decode(SQL_V[1]));
retval = -1;
} SQL_END;
break;
--- 702,708 ----
SQL_BEGIN("DB Dump - Hint",
"SELECT recursive, filename FROM hint ORDER BY filename")
{
! printf("%s\t%s\n", csync_db_get_column_text(SQL_STMT, 0), url_decode( csync_db_get_column_text(SQL_STMT, 1)));
retval = -1;
} SQL_END;
break;
***************
*** 705,712 ****
SQL_BEGIN("DB Dump - File",
"SELECT checktxt, filename FROM file ORDER BY filename")
{
! if (csync_find_next(0, url_decode(SQL_V[1]))) {
! printf("%s\t%s\n", url_decode(SQL_V[0]), url_decode(SQL_V[1]));
retval = -1;
}
} SQL_END;
--- 712,720 ----
SQL_BEGIN("DB Dump - File",
"SELECT checktxt, filename FROM file ORDER BY filename")
{
! if (csync_find_next(0, url_decode(csync_db_get_column_text(SQL_STMT, 1)))) {
! printf("%s\t%s\n", url_decode(csync_db_get_column_text(SQL_STMT, 0)),
! url_decode(csync_db_get_column_text(SQL_STMT, 1)));
retval = -1;
}
} SQL_END;
***************
*** 717,724 ****
SQL_BEGIN("DB Dump - File",
"SELECT checktxt, filename FROM file ORDER BY filename")
{
! if ( csync_match_file_host(url_decode(SQL_V[1]), argv[optind], argv[optind+1], 0) ) {
! printf("%s\t%s\n", url_decode(SQL_V[0]), url_decode(SQL_V[1]));
retval = -1;
}
} SQL_END;
--- 725,733 ----
SQL_BEGIN("DB Dump - File",
"SELECT checktxt, filename FROM file ORDER BY filename")
{
! if ( csync_match_file_host(url_decode(csync_db_get_column_text(SQL_STMT, 1)), argv[optind], argv[optind+1], 0) ) {
! printf("%s\t%s\n", url_decode(csync_db_get_column_text(SQL_STMT, 0)),
! url_decode(csync_db_get_column_text(SQL_STMT, 1)));
retval = -1;
}
} SQL_END;
***************
*** 769,777 ****
SQL_BEGIN("DB Dump - Dirty",
"SELECT force, myname, peername, filename FROM dirty ORDER BY filename")
{
! if (csync_find_next(0, url_decode(SQL_V[3]))) {
! printf("%s\t%s\t%s\t%s\n", atoi(SQL_V[0]) ? "force" : "chary",
! url_decode(SQL_V[1]), url_decode(SQL_V[2]), url_decode(SQL_V[3]));
retval = -1;
}
} SQL_END;
--- 778,786 ----
SQL_BEGIN("DB Dump - Dirty",
"SELECT force, myname, peername, filename FROM dirty ORDER BY filename")
{
! if (csync_find_next(0, url_decode(csync_db_get_column_text(SQL_STMT, 3)))) {
! printf("%s\t%s\t%s\t%s\n", csync_db_get_column_int(SQL_STMT, 0) ? "force" : "chary",
! url_decode(csync_db_get_column_text(SQL_STMT, 1)), url_decode(csync_db_get_column_text(SQL_STMT, 2)), url_decode(csync_db_get_column_text(SQL_STMT, 3)));
retval = -1;
}
} SQL_END;
diff -C 3 csync2-1.34/csync2.h csync2-1.34a/csync2.h
*** csync2-1.34/csync2.h 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/csync2.h 2007-12-30 23:28:26.000000000 +0100
***************
*** 88,116 ****
extern void csync_db_sql(const char *err, const char *fmt, ...);
extern void* csync_db_begin(const char *err, const char *fmt, ...);
! extern int csync_db_next(void *vmx, const char *err,
! int *pN, const char ***pazValue, const char ***pazColName);
extern void csync_db_fin(void *vmx, const char *err);
#define SQL(e, s, ...) csync_db_sql(e, s, ##__VA_ARGS__)
#define SQL_BEGIN(e, s, ...) \
{ \
char *SQL_ERR = e; \
! void *SQL_VM = csync_db_begin(SQL_ERR, s, ##__VA_ARGS__); \
int SQL_COUNT = 0; \
while (1) { \
! const char **SQL_V, **SQL_N; \
int SQL_C; \
! if ( !csync_db_next(SQL_VM, SQL_ERR, \
! &SQL_C, &SQL_V, &SQL_N) ) break; \
SQL_COUNT++;
#define SQL_FIN }{
#define SQL_END \
} \
! csync_db_fin(SQL_VM, SQL_ERR); \
}
extern int db_blocking_mode;
--- 88,118 ----
extern void csync_db_sql(const char *err, const char *fmt, ...);
extern void* csync_db_begin(const char *err, const char *fmt, ...);
! extern int csync_db_next(void *vmx, const char *err);
extern void csync_db_fin(void *vmx, const char *err);
+ extern char *csync_db_get_column_text(void *vmx, int row);
+ extern int csync_db_get_column_int(void *vmx, int row);
+
#define SQL(e, s, ...) csync_db_sql(e, s, ##__VA_ARGS__)
#define SQL_BEGIN(e, s, ...) \
{ \
char *SQL_ERR = e; \
! void *SQL_STMT = csync_db_begin(SQL_ERR, s, ##__VA_ARGS__); \
int SQL_COUNT = 0; \
while (1) { \
! /* const char **SQL_V, **SQL_N; */ \
int SQL_C; \
! if ( !csync_db_next(SQL_STMT, SQL_ERR) ) \
! break; \
SQL_COUNT++;
#define SQL_FIN }{
#define SQL_END \
} \
! csync_db_fin(SQL_STMT, SQL_ERR); \
}
extern int db_blocking_mode;
***************
*** 303,308 ****
--- 305,311 ----
extern int csync_error_count;
extern int csync_debug_level;
+ extern int csync_syslog;
extern FILE *csync_debug_out;
extern long csync_last_printtime;
Only in csync2-1.34a/: csync2.h~
Only in csync2-1.34a/: csync2.log
Only in csync2-1.34a/: csync2.o
Common subdirectories: csync2-1.34/cygwin and csync2-1.34a/cygwin
diff -C 3 csync2-1.34/daemon.c csync2-1.34a/daemon.c
*** csync2-1.34/daemon.c 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/daemon.c 2007-12-30 22:55:45.000000000 +0100
***************
*** 98,170 ****
{
static char error_buffer[1024];
const struct csync_group *g = NULL;
- while ( (g=csync_find_next(g, filename)) ) {
- if (g->backup_directory && g->backup_generations > 0) {
- int bak_dir_len = strlen(g->backup_directory);
- int filename_len = strlen(filename);
- char backup_filename[bak_dir_len + filename_len + 10];
- char backup_otherfilename[bak_dir_len + filename_len + 10];
- int fd_in, fd_out, i;
-
- fd_in = open(filename, O_RDONLY);
- if (fd_in < 0) return 0;
-
- memcpy(backup_filename, g->backup_directory, bak_dir_len);
- for (i=0; i<filename_len; i++)
- backup_filename[bak_dir_len+i] =
- filename[i] == '/' ? '_' : filename[i];
- backup_filename[bak_dir_len] = '/';
- memcpy(backup_otherfilename, backup_filename,
- bak_dir_len + filename_len);
-
- for (i=g->backup_generations-1; i; i--) {
- snprintf(backup_filename+bak_dir_len+filename_len, 10, ".%d", i-1);
- snprintf(backup_otherfilename+bak_dir_len+filename_len, 10, ".%d", i);
- rename(backup_filename, backup_otherfilename);
- }
-
- strcpy(backup_filename+bak_dir_len+filename_len, ".0");
- fd_out = open(backup_filename, O_WRONLY|O_CREAT, 0600);
-
- if (fd_out < 0) {
- snprintf(error_buffer, 1024,
- "Open error while backing up '%s': %s\n",
- filename, strerror(errno));
- cmd_error = error_buffer;
- close(fd_in);
- return 1;
- }
-
- while (1) {
- char buffer[512];
- int read_len = read(fd_in, buffer, 512);
- int write_len = 0;
-
- if (read_len <= 0)
- break;
! while (write_len < read_len) {
! int rc = write(fd_out, buffer+write_len, read_len-write_len);
! if (rc <= 0) {
! snprintf(error_buffer, 1024,
! "Write error while backing up '%s': %s\n",
! filename, strerror(errno));
! cmd_error = error_buffer;
! close(fd_in);
! close(fd_out);
! return 1;
! }
! write_len += rc;
! }
! }
! close(fd_in);
! close(fd_out);
! }
}
!
return 0;
}
struct csync_command {
char *text;
int check_perm;
--- 98,250 ----
{
static char error_buffer[1024];
const struct csync_group *g = NULL;
! while ( (g=csync_find_next(g, filename)) ) {
! if (g->backup_directory && g->backup_generations > 0) {
!
! int bak_dir_len = strlen(g->backup_directory);
! int filename_len = strlen(filename);
! char backup_filename[bak_dir_len + filename_len + 10];
! char backup_otherfilename[bak_dir_len + filename_len + 10];
! int fd_in, fd_out, i;
! int lastSlash;
! mode_t mode;
! csync_debug(0, "backup\n");
!
! fd_in = open(filename, O_RDONLY);
! if (fd_in < 0)
! return 0;
!
! memcpy(backup_filename, g->backup_directory, bak_dir_len);
! backup_filename[bak_dir_len] = 0;
! mode = 0777;
!
!
! for (i=filename_len; i> 0; i--)
! if (filename[i] == '/') {
! lastSlash = i;
! break;
! }
!
! for (i=0; i < filename_len; i++) {
! // Create directories in filename
! // TODO: Get the mode from the orig. dir
! if (filename[i] == '/' && i <= lastSlash) {
!
! backup_filename[bak_dir_len+i] = 0;
!
! csync_debug(0, "mkdir %s \n", backup_filename);
!
! mkdir(backup_filename, mode);
! // Dont check the empty string.
! if (i!= 0)
! csync_setBackupFileStatus(backup_filename, bak_dir_len);
!
! }
! backup_filename[bak_dir_len+i] = filename[i];
! }
!
! backup_filename[bak_dir_len + filename_len] = 0;
! backup_filename[bak_dir_len] = '/';
! memcpy(backup_otherfilename, backup_filename,
! bak_dir_len + filename_len);
!
! for (i=g->backup_generations-1; i; i--) {
!
! if (i != 1)
! snprintf(backup_filename+bak_dir_len+filename_len, 10, ".%d", i-1);
! else
! snprintf(backup_filename+bak_dir_len+filename_len, 10, "");
!
! snprintf(backup_otherfilename+bak_dir_len+filename_len, 10, ".%d", i);
!
! int rc = rename(backup_filename, backup_otherfilename);
! csync_debug(0, "renaming backup files %s to %s. rc = %d\n",
! backup_filename, backup_otherfilename, rc);
!
! }
!
! /* strcpy(backup_filename+bak_dir_len+filename_len, ""); */
!
! fd_out = open(backup_filename, O_WRONLY|O_CREAT, 0600);
!
! if (fd_out < 0) {
! snprintf(error_buffer, 1024,
! "Open error while backing up '%s': %s\n",
! filename, strerror(errno));
! cmd_error = error_buffer;
! close(fd_in);
! return 1;
! }
!
! csync_debug(0,"Copying data from %s to backup file %s \n", filename, backup_filename);
!
! int rc = csync_copy_file(fd_in, fd_out);
! if (rc != 0) {
! csync_debug(0, "csync_backup error 2\n");
!
! snprintf(error_buffer, 1024,
! "Write error while backing up '%s': %s\n",
! filename, strerror(errno));
!
! cmd_error = error_buffer;
! return 1;
! }
! csync_setBackupFileStatus(backup_filename, bak_dir_len);
! csync_debug(0, "csync_backup loop end\n");
! }
}
! csync_debug(0, "csync_backup end\n");
return 0;
}
+ int csync_copy_file(int fd_in, int fd_out)
+ {
+ char buffer[512];
+ int read_len = read(fd_in, buffer, 512);
+
+ while (read_len > 0) {
+ int write_len = 0;
+
+ while (write_len < read_len) {
+ int rc = write(fd_out, buffer+write_len, read_len-write_len);
+ if (rc == -1) {
+ close(fd_in);
+ close(fd_out);
+ return -rc;
+ }
+ write_len += rc;
+ }
+ read_len = read(fd_in, buffer, 512);
+ }
+ close(fd_in);
+ close(fd_out);
+ return 0;
+ }
+
+ /* get the mode from the orig directory.
+ Looking from the back_dir_len should produce the original dir.
+ */
+ int csync_setBackupFileStatus(char *filename, int backupDirLength) {
+
+ struct stat buf;
+ int rc = stat((filename + backupDirLength), &buf);
+ if (rc == 0 ) {
+
+ rc = chown(filename, buf.st_uid, buf.st_gid);
+ csync_debug(0, "Changing owner of %s to user %d and group %d, rc= %d \n",
+ filename, buf.st_uid, buf.st_gid, rc);
+
+ rc = chmod(filename, buf.st_mode);
+ csync_debug(0, "Changing mode of %s to mode %d, rc= %d \n",
+ filename, buf.st_mode, rc);
+
+ }
+ else
+ csync_debug(0, "Error getting mode and owner ship from %s \n", (filename + backupDirLength));
+
+ };
+
struct csync_command {
char *text;
int check_perm;
***************
*** 443,450 ****
strcmp(tag[2], "-") ? url_encode(tag[2]) : "",
strcmp(tag[2], "-") ? "'" : "")
{
! if ( csync_match_file_host(url_decode(SQL_V[1]), tag[1], peer, (const char **)&tag[3]) )
! conn_printf("%s\t%s\n", SQL_V[0], SQL_V[1]);
} SQL_END;
break;
--- 523,530 ----
strcmp(tag[2], "-") ? url_encode(tag[2]) : "",
strcmp(tag[2], "-") ? "'" : "")
{
! if ( csync_match_file_host(url_decode(csync_db_get_column_text(SQL_STMT, 1)), tag[1], peer, (const char **)&tag[3]) )
! conn_printf("%s\t%s\n", csync_db_get_column_text(SQL_STMT, 0), csync_db_get_column_text(SQL_STMT, 1));
} SQL_END;
break;
Only in csync2-1.34a/: daemon.o
diff -C 3 csync2-1.34/db.c csync2-1.34a/db.c
*** csync2-1.34/db.c 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/db.c 2007-12-30 21:07:58.000000000 +0100
***************
*** 19,25 ****
*/
#include "csync2.h"
! #include <sqlite.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
--- 19,25 ----
*/
#include "csync2.h"
! #include <sqlite3.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
***************
*** 33,39 ****
int db_blocking_mode = 1;
int db_sync_mode = 1;
! static sqlite *db = 0;
static int get_dblock_timeout()
{
--- 33,39 ----
int db_blocking_mode = 1;
int db_sync_mode = 1;
! static sqlite3 *db = 0;
static int get_dblock_timeout()
{
***************
*** 128,171 ****
void csync_db_open(const char *file)
{
! db = sqlite_open(file, 0, 0);
! if ( db == 0 )
csync_fatal("Can't open database: %s\n", file);
/* ignore errors on table creation */
in_sql_query++;
! sqlite_exec(db,
"CREATE TABLE file ("
" filename, checktxt,"
" UNIQUE ( filename ) ON CONFLICT REPLACE"
")",
0, 0, 0);
! sqlite_exec(db,
"CREATE TABLE dirty ("
" filename, force, myname, peername,"
" UNIQUE ( filename, peername ) ON CONFLICT IGNORE"
")",
0, 0, 0);
! sqlite_exec(db,
"CREATE TABLE hint ("
" filename, recursive,"
" UNIQUE ( filename, recursive ) ON CONFLICT IGNORE"
")",
0, 0, 0);
! sqlite_exec(db,
"CREATE TABLE action ("
" filename, command, logfile,"
" UNIQUE ( filename, command ) ON CONFLICT IGNORE"
")",
0, 0, 0);
! sqlite_exec(db,
"CREATE TABLE x509_cert ("
" peername, certdata,"
" UNIQUE ( peername ) ON CONFLICT IGNORE"
")",
0, 0, 0);
if (!db_sync_mode)
! sqlite_exec(db, "PRAGMA synchronous = OFF", 0, 0, 0);
in_sql_query--;
}
--- 128,171 ----
void csync_db_open(const char *file)
{
! int rc = sqlite3_open(file, &db);
! if ( rc != SQLITE_OK )
csync_fatal("Can't open database: %s\n", file);
/* ignore errors on table creation */
in_sql_query++;
! sqlite3_exec(db,
"CREATE TABLE file ("
" filename, checktxt,"
" UNIQUE ( filename ) ON CONFLICT REPLACE"
")",
0, 0, 0);
! sqlite3_exec(db,
"CREATE TABLE dirty ("
" filename, force, myname, peername,"
" UNIQUE ( filename, peername ) ON CONFLICT IGNORE"
")",
0, 0, 0);
! sqlite3_exec(db,
"CREATE TABLE hint ("
" filename, recursive,"
" UNIQUE ( filename, recursive ) ON CONFLICT IGNORE"
")",
0, 0, 0);
! sqlite3_exec(db,
"CREATE TABLE action ("
" filename, command, logfile,"
" UNIQUE ( filename, command ) ON CONFLICT IGNORE"
")",
0, 0, 0);
! sqlite3_exec(db,
"CREATE TABLE x509_cert ("
" peername, certdata,"
" UNIQUE ( peername ) ON CONFLICT IGNORE"
")",
0, 0, 0);
if (!db_sync_mode)
! sqlite3_exec(db, "PRAGMA synchronous = OFF", 0, 0, 0);
in_sql_query--;
}
***************
*** 178,184 ****
SQL("COMMIT TRANSACTION", "COMMIT TRANSACTION");
tqueries_counter = -10;
}
! sqlite_close(db);
begin_commit_recursion--;
db = 0;
}
--- 178,184 ----
SQL("COMMIT TRANSACTION", "COMMIT TRANSACTION");
tqueries_counter = -10;
}
! sqlite3_close(db);
begin_commit_recursion--;
db = 0;
}
***************
*** 199,205 ****
csync_debug(2, "SQL: %s\n", sql);
while (1) {
! rc = sqlite_exec(db, sql, 0, 0, 0);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
--- 199,205 ----
csync_debug(2, "SQL: %s\n", sql);
while (1) {
! rc = sqlite3_exec(db, sql, 0, 0, 0);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
***************
*** 216,226 ****
void* csync_db_begin(const char *err, const char *fmt, ...)
{
! sqlite_vm *vm;
char *sql;
va_list ap;
int rc, busyc = 0;
!
va_start(ap, fmt);
vasprintf(&sql, fmt, ap);
va_end(ap);
--- 216,226 ----
void* csync_db_begin(const char *err, const char *fmt, ...)
{
! sqlite3_stmt *stmt;
char *sql;
va_list ap;
int rc, busyc = 0;
! char *ppTail;
va_start(ap, fmt);
vasprintf(&sql, fmt, ap);
va_end(ap);
***************
*** 229,237 ****
csync_db_maybegin();
csync_debug(2, "SQL: %s\n", sql);
!
while (1) {
! rc = sqlite_compile(db, sql, 0, &vm, 0);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
--- 229,237 ----
csync_db_maybegin();
csync_debug(2, "SQL: %s\n", sql);
!
while (1) {
! rc = sqlite3_prepare_v2(db, sql, 1000, &stmt, &ppTail);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
***************
*** 242,260 ****
csync_fatal("Database Error: %s [%d]: %s\n", err, rc, sql);
free(sql);
! return vm;
}
! int csync_db_next(void *vmx, const char *err,
! int *pN, const char ***pazValue, const char ***pazColName)
{
! sqlite_vm *vm = vmx;
int rc, busyc = 0;
csync_debug(4, "Trying to fetch a row from the database.\n");
while (1) {
! rc = sqlite_step(vm, pN, pazValue, pazColName);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
--- 242,272 ----
csync_fatal("Database Error: %s [%d]: %s\n", err, rc, sql);
free(sql);
! return stmt;
! }
!
! char *csync_db_get_column_text(void *vmx, int row) {
! sqlite3_stmt *stmt = vmx;
! int rc, busyc = 0;
! return sqlite3_column_text(stmt, 0);
}
! int csync_db_get_column_int(void *vmx, int row) {
! sqlite3_stmt *stmt = vmx;
! int rc, busyc = 0;
! return sqlite3_column_int(stmt, 0);
! }
!
!
! int csync_db_next(void *vmx, const char *err)
{
! sqlite3_stmt *stmt = vmx;
int rc, busyc = 0;
csync_debug(4, "Trying to fetch a row from the database.\n");
while (1) {
! rc = sqlite3_step(stmt);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
***************
*** 270,282 ****
void csync_db_fin(void *vmx, const char *err)
{
! sqlite_vm *vm = vmx;
int rc, busyc = 0;
csync_debug(2, "SQL Query finished.\n");
while (1) {
! rc = sqlite_finalize(vm, 0);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
--- 282,294 ----
void csync_db_fin(void *vmx, const char *err)
{
! sqlite3_stmt *stmt = vmx;
int rc, busyc = 0;
csync_debug(2, "SQL Query finished.\n");
while (1) {
! rc = sqlite3_finalize(stmt);
if ( rc != SQLITE_BUSY ) break;
if (busyc++ > get_dblock_timeout()) { db = 0; csync_fatal(DEADLOCK_MESSAGE); }
csync_debug(2, "Database is busy, sleeping a sec.\n");
Only in csync2-1.34a/: db.o
Only in csync2-1.34a/: .deps
diff -C 3 csync2-1.34/error.c csync2-1.34a/error.c
*** csync2-1.34/error.c 2007-12-30 23:18:32.000000000 +0100
--- csync2-1.34a/error.c 2007-12-30 23:10:17.000000000 +0100
***************
*** 26,31 ****
--- 26,32 ----
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
+ #include <syslog.h>
long csync_last_printtime = 0;
FILE *csync_timestamp_out = 0;
***************
*** 104,110 ****
va_start(ap, fmt);
vfprintf(csync_debug_out, fmt, ap);
va_end(ap);
!
csync_db_close();
csync_last_printtime = 0;
--- 105,114 ----
va_start(ap, fmt);
vfprintf(csync_debug_out, fmt, ap);
va_end(ap);
! if (errno) {
! fprintf(csync_debug_out, "\nError No: %d Error: %s\n",
! errno, strerror(errno));
! }
csync_db_close();
csync_last_printtime = 0;
***************
*** 119,136 ****
if ( csync_debug_level < lv ) return;
! csync_printtime();
! if (csync_timestamps)
! csync_printtime_prefix();
! if ( csync_server_child_pid )
! fprintf(csync_debug_out, "<%d> ", csync_server_child_pid);
! va_start(ap, fmt);
! vfprintf(csync_debug_out, fmt, ap);
! va_end(ap);
! csync_messages_printed++;
}
--- 123,148 ----
if ( csync_debug_level < lv ) return;
! if (!csync_syslog) {
! csync_printtime();
! if (csync_timestamps)
! csync_printtime_prefix();
! if ( csync_server_child_pid )
! fprintf(csync_debug_out, "<%d> ", csync_server_child_pid);
! va_start(ap, fmt);
! vfprintf(csync_debug_out, fmt, ap);
! va_end(ap);
! csync_messages_printed++;
! }
! else {
! va_start(ap,fmt);
! vsyslog(LOG_DEBUG, fmt, ap);
! va_end(ap);
! }
!
}
Only in csync2-1.34: error.c~
Only in csync2-1.34a/: error.o
Only in csync2-1.34a/: getrealfn.o
Only in csync2-1.34a/: groups.o
Only in csync2-1.34a/: Makefile
diff -C 3 csync2-1.34/Makefile.in csync2-1.34a/Makefile.in
*** csync2-1.34/Makefile.in 2007-07-24 23:04:25.000000000 +0200
--- csync2-1.34a/Makefile.in 2007-12-30 22:37:29.000000000 +0100
***************
*** 215,221 ****
DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure AUTHORS \
COPYING ChangeLog INSTALL Makefile.am NEWS TODO aclocal.m4 \
cfgfile_parser.c cfgfile_parser.h cfgfile_scanner.c config.h.in \
! configure.ac depcomp install-sh missing mkinstalldirs
SOURCES = $(csync2_SOURCES)
all: $(BUILT_SOURCES) config.h
--- 215,221 ----
DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure AUTHORS \
COPYING ChangeLog INSTALL Makefile.am NEWS TODO aclocal.m4 \
cfgfile_parser.c cfgfile_parser.h cfgfile_scanner.c config.h.in \
! configure configure.ac depcomp install-sh missing mkinstalldirs
SOURCES = $(csync2_SOURCES)
all: $(BUILT_SOURCES) config.h
Only in csync2-1.34a/: out
Only in csync2-1.34a/: prefixsubst.o
Only in csync2-1.34a/: rsync.o
Only in csync2-1.34a/: stamp-h1
diff -C 3 csync2-1.34/update.c csync2-1.34a/update.c
*** csync2-1.34/update.c 2007-07-24 23:04:18.000000000 +0200
--- csync2-1.34a/update.c 2007-12-30 20:22:22.000000000 +0100
***************
*** 44,50 ****
}
if ( file )
csync_debug(0, "While syncing file %s:\n", file);
! csync_debug(0, "ERROR from peer %s: %s", host, line);
csync_error_count++;
return !strcmp(line, "File is also marked dirty here!") ? 1 : 2;
}
--- 44,52 ----
}
if ( file )
csync_debug(0, "While syncing file %s:\n", file);
! else
! file = "<no file>";
! csync_debug(0, "ERROR from peer(%s): %s %s", file, host, line);
csync_error_count++;
return !strcmp(line, "File is also marked dirty here!") ? 1 : 2;
}
***************
*** 545,556 ****
"SELECT filename, myname, force FROM dirty WHERE peername = '%s' "
"ORDER by filename ASC", url_encode(peername))
{
! const char *filename = url_decode(SQL_V[0]);
int i, use_this = patnum == 0;
for (i=0; i<patnum && !use_this; i++)
if ( compare_files(filename, patlist[i], recursive) ) use_this = 1;
if (use_this)
! textlist_add2(&tl, filename, url_decode(SQL_V[1]), atoi(SQL_V[2]));
} SQL_END;
/* just return if there are no files to update */
--- 547,558 ----
"SELECT filename, myname, force FROM dirty WHERE peername = '%s' "
"ORDER by filename ASC", url_encode(peername))
{
! const char *filename = url_decode(csync_db_get_column_text(SQL_STMT, 0));
int i, use_this = patnum == 0;
for (i=0; i<patnum && !use_this; i++)
if ( compare_files(filename, patlist[i], recursive) ) use_this = 1;
if (use_this)
! textlist_add2(&tl, filename, url_decode(csync_db_get_column_text(SQL_STMT, 1)), csync_db_get_column_int(SQL_STMT, 2) );
} SQL_END;
/* just return if there are no files to update */
***************
*** 626,632 ****
SQL_BEGIN("Get hosts from dirty table",
"SELECT peername FROM dirty GROUP BY peername ORDER BY random()")
{
! textlist_add(&tl, url_decode(SQL_V[0]), 0);
} SQL_END;
for (t = tl; t != 0; t = t->next) {
--- 628,634 ----
SQL_BEGIN("Get hosts from dirty table",
"SELECT peername FROM dirty GROUP BY peername ORDER BY random()")
{
! textlist_add(&tl, url_decode(csync_db_get_column_text(SQL_STMT, 0)), 0);
} SQL_END;
for (t = tl; t != 0; t = t->next) {
***************
*** 682,704 ****
conn_printf("TYPE %s %s\n", g->key, filename);
if ( read_conn_status(0, peername) ) goto finish;
! /* FIXME
! * verify type of file first!
! * (symlink vs. file vs. dir vs. whatever)
! */
!
! /* avoid unwanted side effects due to special chars in filenames,
! * pass them in the environment */
! snprintf(buffer,512,"%s:%s",myname,filename);
! setenv("my_label",buffer,1);
! snprintf(buffer,512,"%s:%s",peername,filename);
! setenv("peer_label",buffer,1);
! snprintf(buffer,512,"%s",filename);
! setenv("diff_file",buffer,1);
! /* XXX no error check on setenv
! * (could be insufficient space in environment) */
! snprintf(buffer, 512, "diff -Nus --label \"$peer_label\" - --label \"$my_label\" \"$diff_file\"");
old_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
p = popen(buffer, "w");
--- 684,693 ----
conn_printf("TYPE %s %s\n", g->key, filename);
if ( read_conn_status(0, peername) ) goto finish;
! printf("--- %s:%s\n+++ %s:%s\n", peername, filename, myname, filename);
! fflush(stdout);
! snprintf(buffer, 512, "diff -Nu - '%s' | tail -n +3", filename);
old_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
p = popen(buffer, "w");
***************
*** 798,804 ****
filename ? url_encode(filename) : "",
filename ? "'" : "")
{
! char *l_file = strdup(url_decode(SQL_V[1])), *l_checktxt = strdup(url_decode(SQL_V[0]));
if ( csync_match_file_host(l_file, myname, peername, 0) ) {
if ( remote_eof ) {
got_remote_eof:
--- 787,793 ----
filename ? url_encode(filename) : "",
filename ? "'" : "")
{
! char *l_file = strdup(url_decode(csync_db_get_column_text(SQL_STMT, 1))), *l_checktxt = strdup(url_decode(csync_db_get_column_text(SQL_STMT, 0)));
if ( csync_match_file_host(l_file, myname, peername, 0) ) {
if ( remote_eof ) {
got_remote_eof:
***************
*** 936,952 ****
const struct csync_group *g = 0;
const struct csync_group_host *h;
! const char *filename = url_decode(SQL_V[0]);
while ((g=csync_find_next(g, filename)) != 0) {
! if (!strcmp(g->myname, SQL_V[1]))
for (h = g->host; h; h = h->next) {
! if (!strcmp(h->hostname, SQL_V[2]))
goto this_dirty_record_is_ok;
}
}
! textlist_add2(&tl, SQL_V[0], SQL_V[2], 0);
this_dirty_record_is_ok:
;
--- 925,941 ----
const struct csync_group *g = 0;
const struct csync_group_host *h;
! const char *filename = url_decode(csync_db_get_column_text(SQL_STMT, 0));
while ((g=csync_find_next(g, filename)) != 0) {
! if (!strcmp(g->myname, csync_db_get_column_text(SQL_STMT, 1)))
for (h = g->host; h; h = h->next) {
! if (!strcmp(h->hostname, csync_db_get_column_text(SQL_STMT, 2)))
goto this_dirty_record_is_ok;
}
}
! textlist_add2(&tl, csync_db_get_column_text(SQL_STMT, 0), csync_db_get_column_text(SQL_STMT, 2), 0);
this_dirty_record_is_ok:
;
***************
*** 962,969 ****
SQL_BEGIN("Query file DB",
"SELECT filename FROM file")
{
! if (!csync_find_next(0, url_decode(SQL_V[0])))
! textlist_add(&tl, SQL_V[0], 0);
} SQL_END;
for (t = tl; t != 0; t = t->next) {
csync_debug(1, "Removing %s from file db.\n", t->value);
--- 951,958 ----
SQL_BEGIN("Query file DB",
"SELECT filename FROM file")
{
! if (!csync_find_next(0, url_decode(csync_db_get_column_text(SQL_STMT, 0))))
! textlist_add(&tl, csync_db_get_column_text(SQL_STMT, 0), 0);
} SQL_END;
for (t = tl; t != 0; t = t->next) {
csync_debug(1, "Removing %s from file db.\n", t->value);
Only in csync2-1.34a/: update.o
Only in csync2-1.34a/: urlencode.o
-------------- next part --------------
Beside the sqlite3 stuff, I also also changed the backup to include
the directory structure and added support for syslog logging.
There is no support for inotify in 1.34, but it is something I would
like to see myself.
cheers,
Dennis Schafroth
On 16/01/2008, at 18.15, Vincent R?gnard wrote:
> Hi all,
>
> I have been playing this days with this very nice piece of software.
>
> I have 2 questions.
>
> I have been unable to build csyn2 (latest stable) with sqlite3
> (3.4.2), configure is unable to handle /usr/lib/libsqlite3.so*. No
> problem to build it with sqlite 2.8. Is csync2 yet not compatible
> with sqlite3 ? Or is it possible to have it work "some way" with
> sqlite3 ?
>
> Reading the paper (very nice job!), we imagine a pleasant built-in
> inotify feature. I saw how to use it with the external incron trick.
> But I am wondering if there is like an internal inotify facility
> directly inside csync2 (ie. not requiring the external daemon) ?
>
> --
> Vincent R?gnard
> vregnard at tbs-internet.com
> TBS-internet.com
> 027 630 5902
>
> _______________________________________________
> Csync2 mailing list
> Csync2 at lists.linbit.com
> http://lists.linbit.com/mailman/listinfo/csync2
More information about the Csync2
mailing list