AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(sys/fcntl.h fcntl.h sys/time.h unistd.h utime.h grp.h)
-AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h)
+AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
+AC_CHECK_HEADERS(sys/filio.h)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_FUNC_MMAP
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS(waitpid strtok pipe getcwd mkdir strdup strerror chown chmod mknod)
-AC_CHECK_FUNCS(fchmod fstat strchr bcopy bzero readlink utime utimes getopt_long)
+AC_CHECK_FUNCS(fchmod fstat strchr bcopy bzero readlink utime utimes)
+AC_CHECK_FUNCS(memmove getopt_long)
echo -n "checking for working fnmatch... "
AC_TRY_RUN([#include <fnmatch.h>
if (mkdir(name,0777) != 0) {
fprintf(stderr,"mkdir %s : %s\n",name,strerror(errno));
exit(1);
+ } else {
+ fprintf(am_server?stderr:stdout,"created directory %s\n",name);
}
if (chdir(name) != 0) {
static int total_data_transfer=0;
+static int check_f_in;
+
+
struct target {
tag t;
int i;
(int)offset,(int)last_match,i,(int)s->sums[i].len,n);
if (n > 0) {
+ read_check(check_f_in);
write_int(f,n);
write_buf(f,buf+last_match,n);
data_transfer += n;
}
-void match_sums(int f,struct sum_struct *s,char *buf,off_t len)
+void match_sums(int f,struct sum_struct *s,char *buf,off_t len,int f_in)
{
last_match = 0;
false_alarms = 0;
matches=0;
data_transfer=0;
+ check_f_in = f_in;
+
if (len > 0 && s->count>0) {
build_hash_table(s);
while (1)
{
+ read_check(f_in);
+
i = read_int(f_in);
if (i == -1) break;
if (!am_server && verbose)
printf("%s\n",fname);
- match_sums(f_out,s,buf,st.st_size);
+ match_sums(f_out,s,buf,st.st_size,f_in);
write_flush(f_out);
unmap_file(buf,st.st_size);
#include <sys/stat.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+
#include <signal.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
total_written += len;
}
+static int num_waiting(int fd)
+{
+ int len=0;
+#ifdef FIONREAD
+ ioctl(fd,FIONREAD,&len);
+#endif
+ return(len);
+}
+
+static char *read_buffer = NULL;
+static char *read_buffer_p = NULL;
+static int read_buffer_len = 0;
+static int read_buffer_size = 0;
+
+
void write_flush(int f)
{
}
+void read_check(int f)
+{
+ int n;
+
+ if (read_buffer_len == 0) {
+ read_buffer_p = read_buffer;
+ }
+
+ if ((n=num_waiting(f)) <= 0)
+ return;
+
+ if (read_buffer_p != read_buffer) {
+ memmove(read_buffer,read_buffer_p,read_buffer_len);
+ read_buffer_p = read_buffer;
+ }
+
+ if (n > (read_buffer_size - read_buffer_len)) {
+ read_buffer_size += n;
+ if (!read_buffer)
+ read_buffer = (char *)malloc(read_buffer_size);
+ else
+ read_buffer = (char *)realloc(read_buffer,read_buffer_size);
+ if (!read_buffer) out_of_memory("read check");
+ read_buffer_p = read_buffer;
+ }
+
+ n = read(f,read_buffer+read_buffer_len,n);
+ if (n > 0) {
+ read_buffer_len += n;
+ }
+}
+
-int readfd(int fd,char *buffer,int N)
+static int readfd(int fd,char *buffer,int N)
{
int ret;
int total=0;
while (total < N)
{
- ret = read(fd,buffer + total,N - total);
+ if (read_buffer_len > 0) {
+ ret = MIN(read_buffer_len,N-total);
+ memcpy(buffer+total,read_buffer_p,ret);
+ read_buffer_p += ret;
+ read_buffer_len -= ret;
+ } else {
+ ret = read(fd,buffer + total,N - total);
+ }
if (ret <= 0)
return total;
return utimes(fname,t);
#endif
}
+
-#define VERSION "1.0"
+#define VERSION "1.1"