Updated to apply cleanly.
[rsync/rsync-patches.git] / ODBC-dblog.diff
index 540cdde..4aeede1 100644 (file)
 Add support for logging daemon messages to an SQL database.
 
-After applying this patch you'll need to run autoconf and autoheader to
-generate updated versions of "configure" and "config.h.in".
+After applying this patch, run these commands for a successful build:
 
-You'll need to run configure with the --with-ODBC option in order for the
-extended features to be active.
+    autoconf
+    autoheader
+    ./configure --with-ODBC
+    make proto
+    make
 
-Patch provided by Steve Sether.
+Steve Sether writes:
 
-(Tweaked by Wayne Davison for rsync-style purposes but not compiled, so if the
-dblog.c file has a compile problem, it's probably my fault...)
+This patch adds the following options:
 
+"database logging"
+    If set to True, rsync will attempt to connect to
+    the specified datasource and write to the named tables.
+    Defaults to False.
 
---- README-ODBC        2004-02-13 17:08:33.000000000 -0800
-+++ README-ODBC        2004-04-07 22:42:28.000000000 -0700
-@@ -0,0 +1,80 @@
-+This patch adds the following options:
-+
-+"database logging"
-+If set to True, rsync will attempt to connect to
-+the specified datasource and write to the named tables.
-+Defaults to False.
-+
-+
-+"database datasource"
-+Specifies the name of the ODBC data source to use.
-+
-+"database username"
-+The username to use when connecting to the database.
-+
-+"database password"
-+The password to use when connecting to the database.
-+
-+"transfer table name"
-+The name of the transfer table to log to.
-+This table contains individual filenames, file sizes, bytes transferred, checksum bytes transferred, operation (send or receive), and a timestamp.
-+
-+"session table name"
-+The name of the session table to log to.
-+This table contains the username, module name, module path, ip address, process ID, and a timestamp.
-+
-+"exit table name"
-+The name of the exit table to log to.
-+This table contains the total bytes read, total bytes written, total size
-+of all files, error code, line the error occured at, file the error occured at
-+and the text of the error. (most of which will be blank if the program exited normally).
-+
-+
-+"unique id method"
-+Different databases use different methods to get a unique identifier.
-+Some databases support sequence objects, and use various forms of the
-+nextval command to retrieve a unique identifier from it.  Other databases
-+support an autonumber field, and support different methds of retrieving
-+the ID used in the last insert.  Valid values for this option are:
-+
-+      nextval-postgres
-+      uses the syntax of nextval for PostgreSQL databases
-+
-+      nextval-oracle
-+      uses the syntax of nextval for Oracle databases
-+
-+      nextval-db2
-+      uses the syntax of nextval for  DB2 databases
-+
-+      last_insert_id
-+      uses the last_insert_id() command for the MySQL databases
-+
-+      @@IDENTITY
-+      uses the @@IDENTITY command for Sybase databases
-+
-+      custom
-+      Define your own method to get a unique identifier.  See the
-+      "custom unique id select", and the "get custom id before select"
-+      parameters.
-+
-+
-+"sequence name"
-+If your database supports sequences, list the name of the sequence to use
-+for the session unique identifier.
-+
-+"custom unique id select"
-+Only used if you specify the custom method in "unique id method".  This
-+is a SQL statement to be executed to get a unique ID.  This SQL
-+statement must return one column with the unique ID to use for
-+the session ID.  Should be used in concert with the "get custom
-+id before select" parameter.
-+
-+"get custom id before insert"
-+This parameter is ignored unless the "unique id method" is set to custom.
-+If set to true, the "custom unique id select" statement will
-+be executed BEFORE the session row is inserted into the database.
-+(as is done when a sequence is used for unique IDs).
-+If False the statement will be executed after the session
-+row is inserted (as is done when the session ID is automatically generates
-+unique IDs).
-+Defaults to True.
---- Makefile.in        10 Feb 2004 17:06:11 -0000      1.98
-+++ Makefile.in        8 Apr 2004 05:56:31 -0000
-@@ -32,7 +32,7 @@
+"database datasource"
+    Specifies the name of the ODBC data source to use.
+
+"database username"
+    The username to use when connecting to the database.
+
+"database password"
+    The password to use when connecting to the database.
+
+"transfer table name"
+    The name of the transfer table to log to.  This table contains individual
+    filenames, file sizes, bytes transferred, checksum bytes transferred,
+    operation (send or receive), and a timestamp.
+
+"session table name"
+    The name of the session table to log to.  This table contains the username,
+    module name, module path, ip address, process ID, and a timestamp.
+
+"exit table name"
+
+    The name of the exit table to log to.  This table contains the total bytes
+    read, total bytes written, total size of all files, error code, line the
+    error occured at, file the error occured at and the text of the error.
+    (most of which will be blank if the program exited normally).
+
+"unique id method"
+    Different databases use different methods to get a unique identifier.
+    Some databases support sequence objects, and use various forms of the
+    nextval command to retrieve a unique identifier from it.  Other databases
+    support an autonumber field, and support different methds of retrieving
+    the ID used in the last insert.  Valid values for this option are:
+
+       nextval-postgres
+           uses the syntax of nextval for PostgreSQL databases
+
+       nextval-oracle
+           uses the syntax of nextval for Oracle databases
+
+       nextval-db2
+           uses the syntax of nextval for DB2 databases
+
+       last_insert_id
+           uses the last_insert_id() command for the MySQL databases
+
+       @@IDENTITY
+           uses the @@IDENTITY command for Sybase databases
+
+       custom
+           Define your own method to get a unique identifier.  See the
+           "custom unique id select", and the "get custom id before select"
+           parameters.
+
+"sequence name"
+    If your database supports sequences, list the name of the sequence to use
+    for the session unique identifier.
+
+"custom unique id select"
+    Only used if you specify the custom method in "unique id method".  This is
+    a SQL statement to be executed to get a unique ID.  This SQL statement must
+    return one column with the unique ID to use for the session ID.  Should be
+    used in concert with the "get custom id before select" parameter.
+
+"get custom id before insert"
+    This parameter is ignored unless the "unique id method" is set to custom.
+    If set to true, the "custom unique id select" statement will be executed
+    BEFORE the session row is inserted into the database.  (as is done when a
+    sequence is used for unique IDs).  If False the statement will be executed
+    after the session row is inserted (as is done when the session ID is
+    automatically generates unique IDs).  Defaults to True.
+
+
+--- orig/Makefile.in   2004-11-02 16:47:15
++++ Makefile.in        2004-07-03 20:22:18
+@@ -32,7 +32,7 @@ ZLIBOBJ=zlib/deflate.o zlib/infblock.o z
        zlib/inflate.o zlib/inftrees.o zlib/infutil.o zlib/trees.o \
        zlib/zutil.o zlib/adler32.o
  OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o \
@@ -106,47 +99,47 @@ dblog.c file has a compile problem, it's probably my fault...)
  OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \
        fileio.o batch.o clientname.o
  OBJS3=progress.o pipe.o
---- cleanup.c  27 Jan 2004 08:14:33 -0000      1.21
-+++ cleanup.c  8 Apr 2004 05:56:31 -0000
-@@ -138,7 +138,12 @@
-                       code = RERR_VANISHED;
+--- orig/cleanup.c     2005-03-05 18:58:38
++++ cleanup.c  2004-07-03 20:22:18
+@@ -144,8 +144,12 @@ void _exit_cleanup(int code, const char 
+                       code = RERR_PARTIAL;
        }
  
--      if (code) log_exit(code, file, line);
+-      if (code)
 +      if (code) {
-+              log_exit(code, file, line);
-+#ifdef HAVE_LIBODBC
+               log_exit(code, file, line);
++#if HAVE_LIBODBC
 +              db_log_exit(code,file,line);
 +#endif
 +      }
  
-       if (verbose > 2)
-               rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): about to call exit(%d)\n", 
---- clientserver.c     14 Apr 2004 23:33:34 -0000      1.121
-+++ clientserver.c     15 Apr 2004 18:51:14 -0000
-@@ -311,6 +311,9 @@
-       exclude_path_prefix = NULL;
+       if (verbose > 2) {
+               rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): about to call exit(%d)\n",
+--- orig/clientserver.c        2005-05-19 08:52:42
++++ clientserver.c     2004-07-03 20:22:18
+@@ -346,6 +346,9 @@ static int rsync_module(int f_in, int f_
+                  XFLG_ANCHORED2ABS | XFLG_OLD_PREFIXES);
  
        log_init();
-+#ifdef HAVE_LIBODBC
++#if HAVE_LIBODBC
 +      db_log_open();
 +#endif
  
        if (use_chroot) {
                /*
-@@ -429,6 +432,9 @@
-                       rprintf(FINFO,"rsync %s %s from %s@%s (%s)\n",
-                               am_sender?"on":"to",
+@@ -468,6 +471,9 @@ static int rsync_module(int f_in, int f_
+                       rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n",
+                               am_sender ? "on" : "to",
                                request, auth_user, host, addr);
-+#ifdef HAVE_LIBODBC
++#if HAVE_LIBODBC
 +                      db_log_session();
 +#endif
                } else {
-                       rprintf(FINFO,"rsync %s %s from %s (%s)\n",
-                               am_sender?"on":"to",
---- configure.in       9 Apr 2004 18:09:16 -0000       1.190
-+++ configure.in       15 Apr 2004 18:51:14 -0000
-@@ -94,6 +94,8 @@
+                       rprintf(FLOG, "rsync %s %s from %s (%s)\n",
+                               am_sender ? "on" : "to",
+--- orig/configure.in  2005-05-13 22:24:18
++++ configure.in       2004-07-03 20:22:18
+@@ -94,6 +94,8 @@ AC_ARG_WITH(rsync-path,
        [  --with-rsync-path=PATH  set default --rsync-path to PATH (default: rsync)],
        [ RSYNC_PATH="$with_rsync_path" ],
        [ RSYNC_PATH="rsync" ])
@@ -155,23 +148,117 @@ dblog.c file has a compile problem, it's probably my fault...)
  
  AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
  
-@@ -458,6 +460,14 @@
- if test x"$with_included_popt" != x"yes"
- then
+@@ -535,6 +537,14 @@ then
      AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
-+fi
-+
+ fi
 +if test x"$with_ODBC" = x"yes"
 +then
 +    AC_CHECK_HEADERS(sql.h sqlext.h sqltypes.h)
 +    AC_CHECK_LIB(odbc,SQLExecDirect)
 +    EXTRA_OBJECT="$EXTRA_OBJECT dblog.o"
 +    AC_SUBST(EXTRA_OBJECT)
- fi
++fi
++
  AC_MSG_CHECKING([whether to use included libpopt])
---- dblog.c    2004-02-13 17:08:33.000000000 -0800
-+++ dblog.c    2004-04-07 23:18:56.000000000 -0700
+ if test x"$with_included_popt" = x"yes"
+ then
+--- orig/dblog-tables-mysql.sql        2004-07-02 21:35:58
++++ dblog-tables-mysql.sql     2004-07-02 21:35:58
+@@ -0,0 +1,43 @@
++drop table transfer;
++drop table exit;
++drop table session;
++
++CREATE TABLE session (
++      id                      int auto_increment NOT NULL,
++      date                    timestamp NOT NULL,
++      ip_address              varchar(15) NOT NULL,
++      username                varchar(20) NOT NULL,
++      module_name             varchar(20) NOT NULL,
++      module_path             varchar(255) NOT NULL,
++      process_id              int NOT NULL,
++      Primary Key (id)
++);
++
++CREATE TABLE transfer (
++      id                      int auto_increment NOT NULL,
++      session_id              int NOT NULL,
++      date                    timestamp NOT NULL,
++      file_path               varchar(255) NOT NULL,
++      file_name               varchar(255) NOT NULL,
++      file_size               bigint NOT NULL,
++      bytes_transferred       bigint NOT NULL,
++      checksum_bytes_transferred bigint NOT NULL,
++      operation               varchar(20),
++      Primary Key (id),
++      foreign key (session_id) references session (id)
++);
++
++CREATE TABLE exit (
++      id                      int auto_increment NOT NULL,
++      session_id              int NOT NULL,
++      date                    timestamp NOT NULL,
++      total_bytes_written     bigint NOT NULL,
++      total_bytes_read        bigint NOT NULL,
++      total_size              bigint NOT NULL,
++      error_text              varchar(128) NOT NULL,
++      error_code              int NOT NULL,
++      error_file              varchar(64) NOT NULL,
++      error_line              int NOT NULL,
++      Primary Key (id),
++      foreign key (session_id) references session (id)
++);
+--- orig/dblog-tables-postgresql.sql   2004-07-02 21:35:58
++++ dblog-tables-postgresql.sql        2004-07-02 21:35:58
+@@ -0,0 +1,45 @@
++drop table transfer;
++drop table exit;
++drop table session;
++drop sequence session_id_seq;
++create sequence session_id_seq;
++
++CREATE TABLE "session" (
++      "id"                    int NOT NULL,
++      "date"                  timestamp NOT NULL default now(),
++      "ip_address"            varchar(15) NOT NULL,
++      "username"              varchar(20) NOT NULL,
++      "module_name"           varchar(20) NOT NULL,
++      "module_path"           varchar(255) NOT NULL,
++      "process_id"            int NOT NULL,
++      Primary Key (id)
++);
++
++CREATE TABLE "transfer" (
++      "id"                    serial NOT NULL,
++      "session_id"            int NOT NULL,
++      "date"                  timestamp NOT NULL default now(),
++      "file_path"             varchar(512) NOT NULL,
++      "file_name"             varchar(512) NOT NULL,
++      "file_size"             bigint NOT NULL,
++      "bytes_transferred"     bigint NOT NULL,
++      "checksum_bytes_transferred" bigint NOT NULL,
++      "operation"             varchar(20),
++      Primary Key (id),
++      foreign key (session_id) references session (id)
++);
++
++CREATE TABLE "exit" (
++      "id"                    serial NOT NULL,
++      "session_id"            int NOT NULL,
++      "date"                  timestamp NOT NULL default now(),
++      "total_bytes_written"   bigint NOT NULL,
++      "total_bytes_read"      bigint NOT NULL,
++      "total_size"            bigint NOT NULL,
++      "error_text"            varchar(128) NOT NULL,
++      "error_code"            int NOT NULL,
++      "error_file"            varchar(64) NOT NULL,
++      "error_line"            int NOT NULL,
++      Primary Key (id),
++      foreign key (session_id) references session (id)
++);
+--- orig/dblog.c       2004-07-02 21:35:58
++++ dblog.c    2004-07-02 21:35:58
 @@ -0,0 +1,352 @@
 +/*
 + *  ODBC Database logging functions
@@ -182,26 +269,26 @@ dblog.c file has a compile problem, it's probably my fault...)
 +
 +#include "rsync.h"
 +
-+#ifdef HAVE_SQL_H
++#if HAVE_SQL_H
 +#include <sql.h>
 +#else
-+#ifdef HAVE_ODBC_SQL_H
++#if HAVE_ODBC_SQL_H
 +#include <odbc/sql.h>
 +#endif
 +#endif
 +
-+#ifdef HAVE_SQLEXT_H
++#if HAVE_SQLEXT_H
 +#include <sqlext.h>
 +#else
-+#ifdef HAVE_ODBC_SQLEXT_H
++#if HAVE_ODBC_SQLEXT_H
 +#include <odbc/sqlext.h>
 +#endif
 +#endif
 +
-+#ifdef HAVE_SQLTYPES_H
++#if HAVE_SQLTYPES_H
 +#include <sqltypes.h>
 +#else
-+#ifdef HAVE_ODBC_SQLTYPES_H
++#if HAVE_ODBC_SQLTYPES_H
 +#include <odbc/sqltypes.h>
 +#endif
 +#endif
@@ -525,103 +612,9 @@ dblog.c file has a compile problem, it's probably my fault...)
 +              rprintf(FERROR,"Error at db_log_exit: Not connected to database!\n");
 +      }
 +}
---- dblog-tables-mysql.sql     2004-02-13 17:08:33.000000000 -0800
-+++ dblog-tables-mysql.sql     2004-04-07 23:00:13.000000000 -0700
-@@ -0,0 +1,43 @@
-+drop table transfer;
-+drop table exit;
-+drop table session;
-+
-+CREATE TABLE session (
-+      id                      int auto_increment NOT NULL,
-+      date                    timestamp NOT NULL,
-+      ip_address              varchar(15) NOT NULL,
-+      username                varchar(20) NOT NULL,
-+      module_name             varchar(20) NOT NULL,
-+      module_path             varchar(255) NOT NULL,
-+      process_id              int NOT NULL,
-+      Primary Key (id)
-+);
-+
-+CREATE TABLE transfer (
-+      id                      int auto_increment NOT NULL,
-+      session_id              int NOT NULL,
-+      date                    timestamp NOT NULL,
-+      file_path               varchar(255) NOT NULL,
-+      file_name               varchar(255) NOT NULL,
-+      file_size               bigint NOT NULL,
-+      bytes_transferred       bigint NOT NULL,
-+      checksum_bytes_transferred bigint NOT NULL,
-+      operation               varchar(20),
-+      Primary Key (id),
-+      foreign key (session_id) references session (id)
-+);
-+
-+CREATE TABLE exit (
-+      id                      int auto_increment NOT NULL,
-+      session_id              int NOT NULL,
-+      date                    timestamp NOT NULL,
-+      total_bytes_written     bigint NOT NULL,
-+      total_bytes_read        bigint NOT NULL,
-+      total_size              bigint NOT NULL,
-+      error_text              varchar(128) NOT NULL,
-+      error_code              int NOT NULL,
-+      error_file              varchar(64) NOT NULL,
-+      error_line              int NOT NULL,
-+      Primary Key (id),
-+      foreign key (session_id) references session (id)
-+);
---- dblog-tables-postgresql.sql        2004-02-13 17:08:33.000000000 -0800
-+++ dblog-tables-postgresql.sql        2004-04-07 22:59:55.000000000 -0700
-@@ -0,0 +1,45 @@
-+drop table transfer;
-+drop table exit;
-+drop table session;
-+drop sequence session_id_seq;
-+create sequence session_id_seq;
-+
-+CREATE TABLE "session" (
-+      "id"                    int NOT NULL,
-+      "date"                  timestamp NOT NULL default now(),
-+      "ip_address"            varchar(15) NOT NULL,
-+      "username"              varchar(20) NOT NULL,
-+      "module_name"           varchar(20) NOT NULL,
-+      "module_path"           varchar(255) NOT NULL,
-+      "process_id"            int NOT NULL,
-+      Primary Key (id)
-+);
-+
-+CREATE TABLE "transfer" (
-+      "id"                    serial NOT NULL,
-+      "session_id"            int NOT NULL,
-+      "date"                  timestamp NOT NULL default now(),
-+      "file_path"             varchar(512) NOT NULL,
-+      "file_name"             varchar(512) NOT NULL,
-+      "file_size"             bigint NOT NULL,
-+      "bytes_transferred"     bigint NOT NULL,
-+      "checksum_bytes_transferred" bigint NOT NULL,
-+      "operation"             varchar(20),
-+      Primary Key (id),
-+      foreign key (session_id) references session (id)
-+);
-+
-+CREATE TABLE "exit" (
-+      "id"                    serial NOT NULL,
-+      "session_id"            int NOT NULL,
-+      "date"                  timestamp NOT NULL default now(),
-+      "total_bytes_written"   bigint NOT NULL,
-+      "total_bytes_read"      bigint NOT NULL,
-+      "total_size"            bigint NOT NULL,
-+      "error_text"            varchar(128) NOT NULL,
-+      "error_code"            int NOT NULL,
-+      "error_file"            varchar(64) NOT NULL,
-+      "error_line"            int NOT NULL,
-+      Primary Key (id),
-+      foreign key (session_id) references session (id)
-+);
---- loadparm.c 4 Feb 2004 07:31:29 -0000       1.50
-+++ loadparm.c 8 Apr 2004 06:31:18 -0000
-@@ -122,6 +122,17 @@
+--- orig/loadparm.c    2005-02-19 17:38:51
++++ loadparm.c 2004-07-03 20:22:18
+@@ -125,6 +125,17 @@ typedef struct
        BOOL list;
        BOOL use_chroot;
        BOOL transfer_logging;
@@ -639,7 +632,7 @@ dblog.c file has a compile problem, it's probably my fault...)
        BOOL ignore_errors;
        char *uid;
        char *gid;
-@@ -154,6 +165,17 @@
+@@ -159,6 +170,17 @@ static service sDefault =
        True,    /* list */
        True,    /* use chroot */
        False,   /* transfer logging */
@@ -657,7 +650,7 @@ dblog.c file has a compile problem, it's probably my fault...)
        False,   /* ignore errors */
        "nobody",/* uid */
  
-@@ -292,6 +314,17 @@
+@@ -302,6 +324,17 @@ static struct parm_struct parm_table[] =
    {"include",          P_STRING,  P_LOCAL,  &sDefault.include,     NULL,   0},
    {"include from",     P_STRING,  P_LOCAL,  &sDefault.include_from,NULL,   0},
    {"transfer logging", P_BOOL,    P_LOCAL,  &sDefault.transfer_logging,NULL,0},
@@ -675,7 +668,7 @@ dblog.c file has a compile problem, it's probably my fault...)
    {"ignore errors",    P_BOOL,    P_LOCAL,  &sDefault.ignore_errors,NULL,0},
    {"log format",       P_STRING,  P_LOCAL,  &sDefault.log_format,  NULL,   0},
    {"refuse options",   P_STRING,  P_LOCAL,  &sDefault.refuse_options,NULL, 0},
-@@ -359,6 +392,17 @@
+@@ -372,6 +405,17 @@ FN_LOCAL_BOOL(lp_write_only, write_only)
  FN_LOCAL_BOOL(lp_list, list)
  FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
  FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
@@ -693,9 +686,9 @@ dblog.c file has a compile problem, it's probably my fault...)
  FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
  FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
  FN_LOCAL_STRING(lp_uid, uid)
---- log.c      20 Jan 2004 05:15:14 -0000      1.71
-+++ log.c      8 Apr 2004 05:56:32 -0000
-@@ -75,7 +75,7 @@
+--- orig/log.c 2005-04-15 07:08:03
++++ log.c      2004-07-03 20:22:18
+@@ -84,7 +84,7 @@ struct {
  /*
   * Map from rsync error code to name, or return NULL.
   */
@@ -704,81 +697,39 @@ dblog.c file has a compile problem, it's probably my fault...)
  {
        int i;
        for (i = 0; rerr_names[i].name; i++) {
---- main.c     10 Feb 2004 03:54:47 -0000      1.192
-+++ main.c     8 Apr 2004 05:56:32 -0000
-@@ -120,6 +120,9 @@
+--- orig/main.c        2005-05-12 07:51:58
++++ main.c     2004-07-03 20:22:18
+@@ -144,6 +144,9 @@ static void handle_stats(int f)
  
        if (am_daemon) {
                log_exit(0, __FILE__, __LINE__);
-+#ifdef HAVE_LIBODBC
++#if HAVE_LIBODBC
 +              db_log_exit(0,__FILE__,__LINE__);
 +#endif
-               if (f == -1 || !am_sender) return;
+               if (f == -1 || !am_sender)
+                       return;
        }
+--- orig/receiver.c    2005-04-14 01:53:12
++++ receiver.c 2005-03-05 00:31:00
+@@ -640,6 +640,9 @@ int recv_files(int f_in, struct file_lis
  
---- proto.h    14 Apr 2004 23:33:30 -0000      1.188
-+++ proto.h    15 Apr 2004 18:51:15 -0000
-@@ -51,6 +51,12 @@
- int daemon_main(void);
- void setup_protocol(int f_out,int f_in);
- int claim_connection(char *fname,int max_connections);
-+char *sanitizeSql(const char *input);
-+void db_log_open(void);
-+void db_log_close();
-+void db_log_session();
-+void db_log_transfer(struct file_struct *file,struct stats *initial_stats,char *operation);
-+void db_log_exit(int code, const char *file, int line);
- void free_exclude_list(struct exclude_list_struct *listp);
- int check_exclude(struct exclude_list_struct *listp, char *name, int name_is_dir,
-                 const char *type);
-@@ -136,6 +142,17 @@
- BOOL lp_list(int );
- BOOL lp_use_chroot(int );
- BOOL lp_transfer_logging(int );
-+BOOL lp_database_logging(int );
-+char *lp_database_datasource(int );
-+char *lp_database_username(int );
-+char *lp_database_password(int );
-+char *lp_transfer_table_name(int );
-+char *lp_exit_table_name(int );
-+char *lp_session_table_name(int );
-+char *lp_sequence_name(int );
-+char *lp_unique_id_method(int );
-+char *lp_custom_unique_id_select(int );
-+BOOL lp_get_custom_id_before_insert(int );
- BOOL lp_ignore_errors(int );
- BOOL lp_ignore_nonreadable(int );
- char *lp_uid(int );
-@@ -157,6 +174,7 @@
- BOOL lp_load(char *pszFname, int globals_only);
- int lp_numservices(void);
- int lp_number(char *name);
-+char const *rerr_name(int code);
- void log_init(void);
- void log_open(void);
- void log_close(void);
---- receiver.c 23 Mar 2004 16:50:40 -0000      1.75
-+++ receiver.c 8 Apr 2004 05:56:32 -0000
-@@ -453,7 +453,9 @@
-               recv_ok = receive_data(f_in,mapbuf,fd2,fname,file->length);
-               log_recv(file, &initial_stats);
--
-+#ifdef HAVE_LIBODBC
-+              db_log_transfer(file, &initial_stats,"receive");
+               if (!log_before_transfer)
+                       log_item(file, &initial_stats, iflags, NULL);
++#if HAVE_LIBODBC
++              db_log_transfer(file, &initial_stats, "receive");
 +#endif
-               if (mapbuf) unmap_file(mapbuf);
-               if (fd1 != -1) {
+               if (fd1 != -1)
                        close(fd1);
---- sender.c   17 Feb 2004 21:57:44 -0000      1.38
-+++ sender.c   8 Apr 2004 05:56:32 -0000
-@@ -283,6 +283,9 @@
-               } else  {
-                       match_sums(f_out, s, buf, st.st_size);
-                       log_send(file, &initial_stats);
-+#ifdef HAVE_LIBODBC
-+                      db_log_transfer(file, &initial_stats,"send");
+--- orig/sender.c      2005-05-19 08:52:42
++++ sender.c   2005-03-05 00:31:19
+@@ -347,6 +347,9 @@ void send_files(struct file_list *flist,
+               if (!log_before_transfer)
+                       log_item(file, &initial_stats, iflags, NULL);
++#if HAVE_LIBODBC
++              db_log_transfer(file, &initial_stats,"send");
 +#endif
-               }
  
-               if (!read_batch) {
+               if (mbuf) {
+                       j = unmap_file(mbuf);