Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
8950ac03
Commit
8950ac03
authored
May 07, 2001
by
Andrew Tridgell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imported new snprintf.c from samba, got rid of slprintf
parent
26ef00bd
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
834 additions
and
717 deletions
+834
-717
acconfig.h
acconfig.h
+2
-0
backup.c
backup.c
+4
-4
clientserver.c
clientserver.c
+1
-1
configure.in
configure.in
+27
-1
exclude.c
exclude.c
+1
-1
generator.c
generator.c
+2
-2
io.c
io.c
+1
-1
snprintf.c
lib/snprintf.c
+770
-653
log.c
log.c
+7
-7
options.c
options.c
+8
-8
receiver.c
receiver.c
+4
-4
rsync.c
rsync.c
+1
-1
socket.c
socket.c
+1
-1
util.c
util.c
+5
-33
No files found.
acconfig.h
View file @
8950ac03
...
...
@@ -14,3 +14,5 @@
#undef HAVE_GETTIMEOFDAY_TZ
#undef HAVE_SOCKETPAIR
#undef HAVE_SECURE_MKSTEMP
#undef HAVE_C99_VSNPRINTF
backup.c
View file @
8950ac03
...
...
@@ -39,7 +39,7 @@ static int make_simple_backup(char *fname)
return
0
;
}
s
l
printf
(
fnamebak
,
sizeof
(
fnamebak
),
"%s%s"
,
fname
,
backup_suffix
);
s
n
printf
(
fnamebak
,
sizeof
(
fnamebak
),
"%s%s"
,
fname
,
backup_suffix
);
if
(
do_rename
(
fname
,
fnamebak
)
!=
0
)
{
/* cygwin (at least version b19) reports EINVAL */
if
(
errno
!=
ENOENT
&&
errno
!=
EINVAL
)
{
...
...
@@ -92,9 +92,9 @@ static int make_bak_dir(char *fname,char *bak_path)
while
(
strncmp
(
bak_path
,
"./"
,
2
)
==
0
)
bak_path
+=
2
;
if
(
bak_path
[
strlen
(
bak_path
)
-
1
]
!=
'/'
)
{
s
l
printf
(
fullpath
,
sizeof
(
fullpath
),
"%s/"
,
bak_path
);
s
n
printf
(
fullpath
,
sizeof
(
fullpath
),
"%s/"
,
bak_path
);
}
else
{
s
l
printf
(
fullpath
,
sizeof
(
fullpath
),
"%s"
,
bak_path
);
s
n
printf
(
fullpath
,
sizeof
(
fullpath
),
"%s"
,
bak_path
);
}
p
=
fullpath
;
q
=&
fullpath
[
strlen
(
fullpath
)];
/* End of bak_path string */
...
...
@@ -208,7 +208,7 @@ static int keep_backup(char *fname)
return
0
;
}
s
l
printf
(
keep_name
,
sizeof
(
keep_name
),
"%s/%s"
,
backup_dir
,
fname
);
s
n
printf
(
keep_name
,
sizeof
(
keep_name
),
"%s/%s"
,
backup_dir
,
fname
);
#ifdef HAVE_MKNOD
...
...
clientserver.c
View file @
8950ac03
...
...
@@ -499,7 +499,7 @@ int daemon_main(void)
rsyserr
(
FLOG
,
errno
,
"failed to create pid file %s"
,
pid_file
);
exit_cleanup
(
RERR_FILEIO
);
}
s
l
printf
(
pidbuf
,
sizeof
(
pidbuf
),
"%d
\n
"
,
pid
);
s
n
printf
(
pidbuf
,
sizeof
(
pidbuf
),
"%d
\n
"
,
pid
);
write
(
fd
,
pidbuf
,
strlen
(
pidbuf
));
close
(
fd
);
}
...
...
configure.in
View file @
8950ac03
...
...
@@ -127,7 +127,7 @@ AC_FUNC_MEMCMP
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf setsid glob strpbrk)
AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf
asprintf
setsid glob strpbrk)
AC_CHECK_FUNCS(strlcat strlcpy mtrace)
AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
...
...
@@ -231,6 +231,32 @@ if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
fi
AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
#include <stdarg.h>
void foo(const char *format, ...) {
va_list ap;
int len;
char buf[5];
va_start(ap, format);
len = vsnprintf(0, 0, format, ap);
va_end(ap);
if (len != 5) exit(1);
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
exit(0);
}
main() { foo("hello"); }
],
rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
AC_DEFINE(HAVE_C99_VSNPRINTF)
fi
AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
AC_TRY_RUN([#include <stdlib.h>
#include <sys/types.h>
...
...
exclude.c
View file @
8950ac03
...
...
@@ -398,7 +398,7 @@ void add_cvs_excludes(void)
add_exclude
(
cvs_ignore_list
[
i
],
0
);
if
((
p
=
getenv
(
"HOME"
))
&&
strlen
(
p
)
<
(
MAXPATHLEN
-
12
))
{
s
l
printf
(
fname
,
sizeof
(
fname
),
"%s/.cvsignore"
,
p
);
s
n
printf
(
fname
,
sizeof
(
fname
),
"%s/.cvsignore"
,
p
);
add_exclude_file
(
fname
,
0
,
0
);
}
...
...
generator.c
View file @
8950ac03
...
...
@@ -56,7 +56,7 @@ static int skip_file(char *fname,
if
(
compare_dest
!=
NULL
)
{
if
(
access
(
fname
,
0
)
!=
0
)
{
s
l
printf
(
fnamecmpdest
,
MAXPATHLEN
,
"%s/%s"
,
s
n
printf
(
fnamecmpdest
,
MAXPATHLEN
,
"%s/%s"
,
compare_dest
,
fname
);
fname
=
fnamecmpdest
;
}
...
...
@@ -329,7 +329,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if
((
statret
==
-
1
)
&&
(
compare_dest
!=
NULL
))
{
/* try the file at compare_dest instead */
int
saveerrno
=
errno
;
s
l
printf
(
fnamecmpbuf
,
MAXPATHLEN
,
"%s/%s"
,
compare_dest
,
fname
);
s
n
printf
(
fnamecmpbuf
,
MAXPATHLEN
,
"%s/%s"
,
compare_dest
,
fname
);
statret
=
link_stat
(
fnamecmpbuf
,
&
st
);
if
(
!
S_ISREG
(
st
.
st_mode
))
statret
=
-
1
;
...
...
io.c
View file @
8950ac03
...
...
@@ -595,7 +595,7 @@ void io_printf(int fd, const char *format, ...)
int
len
;
va_start
(
ap
,
format
);
len
=
vs
l
printf
(
buf
,
sizeof
(
buf
),
format
,
ap
);
len
=
vs
n
printf
(
buf
,
sizeof
(
buf
),
format
,
ap
);
va_end
(
ap
);
if
(
len
<
0
)
exit_cleanup
(
RERR_STREAMIO
);
...
...
lib/snprintf.c
View file @
8950ac03
This diff is collapsed.
Click to expand it.
log.c
View file @
8950ac03
...
...
@@ -286,7 +286,7 @@ void rprintf(enum logcode code, const char *format, ...)
int
len
;
va_start
(
ap
,
format
);
len
=
vs
l
printf
(
buf
,
sizeof
(
buf
),
format
,
ap
);
len
=
vs
n
printf
(
buf
,
sizeof
(
buf
),
format
,
ap
);
va_end
(
ap
);
if
(
len
>
sizeof
(
buf
)
-
1
)
exit_cleanup
(
RERR_MESSAGEIO
);
...
...
@@ -311,7 +311,7 @@ void rsyserr(enum logcode code, int errcode, const char *format, ...)
char
*
sysmsg
;
va_start
(
ap
,
format
);
len
=
vs
l
printf
(
buf
,
sizeof
(
buf
),
format
,
ap
);
len
=
vs
n
printf
(
buf
,
sizeof
(
buf
),
format
,
ap
);
va_end
(
ap
);
if
(
len
>
sizeof
(
buf
)
-
1
)
exit_cleanup
(
RERR_MESSAGEIO
);
...
...
@@ -392,18 +392,18 @@ static void log_formatted(enum logcode code,
case
'h'
:
if
(
am_daemon
)
n
=
client_name
(
0
);
break
;
case
'a'
:
if
(
am_daemon
)
n
=
client_addr
(
0
);
break
;
case
'l'
:
s
l
printf
(
buf2
,
sizeof
(
buf2
),
"%.0f"
,
s
n
printf
(
buf2
,
sizeof
(
buf2
),
"%.0f"
,
(
double
)
file
->
length
);
n
=
buf2
;
break
;
case
'p'
:
s
l
printf
(
buf2
,
sizeof
(
buf2
),
"%d"
,
s
n
printf
(
buf2
,
sizeof
(
buf2
),
"%d"
,
(
int
)
getpid
());
n
=
buf2
;
break
;
case
'o'
:
n
=
op
;
break
;
case
'f'
:
s
l
printf
(
buf2
,
sizeof
(
buf2
),
"%s/%s"
,
s
n
printf
(
buf2
,
sizeof
(
buf2
),
"%s/%s"
,
file
->
basedir
?
file
->
basedir
:
""
,
f_name
(
file
));
clean_fname
(
buf2
);
...
...
@@ -422,7 +422,7 @@ static void log_formatted(enum logcode code,
b
=
stats
.
total_read
-
initial_stats
->
total_read
;
}
s
l
printf
(
buf2
,
sizeof
(
buf2
),
"%.0f"
,
(
double
)
b
);
s
n
printf
(
buf2
,
sizeof
(
buf2
),
"%.0f"
,
(
double
)
b
);
n
=
buf2
;
break
;
case
'c'
:
...
...
@@ -433,7 +433,7 @@ static void log_formatted(enum logcode code,
b
=
stats
.
total_read
-
initial_stats
->
total_read
;
}
s
l
printf
(
buf2
,
sizeof
(
buf2
),
"%.0f"
,
(
double
)
b
);
s
n
printf
(
buf2
,
sizeof
(
buf2
),
"%.0f"
,
(
double
)
b
);
n
=
buf2
;
break
;
}
...
...
options.c
View file @
8950ac03
...
...
@@ -327,7 +327,7 @@ static int check_refuse_options(char *ref, int opt)
while
((
p
=
strstr
(
ref
,
name
)))
{
if
((
p
==
ref
||
p
[
-
1
]
==
' '
)
&&
(
p
[
len
]
==
' '
||
p
[
len
]
==
0
))
{
s
l
printf
(
err_buf
,
sizeof
(
err_buf
),
s
n
printf
(
err_buf
,
sizeof
(
err_buf
),
"The '%s' option is not supported by this server
\n
"
,
name
);
return
1
;
}
...
...
@@ -418,7 +418,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
* rprintf? Everybody who gets this message
* ought to send it to the client and also to
* the logs. */
s
l
printf
(
err_buf
,
sizeof
(
err_buf
),
s
n
printf
(
err_buf
,
sizeof
(
err_buf
),
"hard links are not supported on this %s
\n
"
,
am_server
?
"server"
:
"client"
);
rprintf
(
FERROR
,
"ERROR: hard links not supported on this platform
\n
"
);
...
...
@@ -471,7 +471,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
default:
/* FIXME: If --daemon is specified, then errors for later
* parameters seem to disappear. */
s
l
printf
(
err_buf
,
sizeof
(
err_buf
),
s
n
printf
(
err_buf
,
sizeof
(
err_buf
),
"%s%s: %s
\n
"
,
am_server
?
"on remote machine: "
:
""
,
poptBadOption
(
pc
,
POPT_BADOPTION_NOALIAS
),
...
...
@@ -568,22 +568,22 @@ void server_options(char **args,int *argc)
if
(
x
!=
1
)
args
[
ac
++
]
=
argstr
;
if
(
block_size
!=
BLOCK_SIZE
)
{
s
l
printf
(
bsize
,
sizeof
(
bsize
),
"-B%d"
,
block_size
);
s
n
printf
(
bsize
,
sizeof
(
bsize
),
"-B%d"
,
block_size
);
args
[
ac
++
]
=
bsize
;
}
if
(
max_delete
&&
am_sender
)
{
s
l
printf
(
mdelete
,
sizeof
(
mdelete
),
"--max-delete=%d"
,
max_delete
);
s
n
printf
(
mdelete
,
sizeof
(
mdelete
),
"--max-delete=%d"
,
max_delete
);
args
[
ac
++
]
=
mdelete
;
}
if
(
io_timeout
)
{
s
l
printf
(
iotime
,
sizeof
(
iotime
),
"--timeout=%d"
,
io_timeout
);
s
n
printf
(
iotime
,
sizeof
(
iotime
),
"--timeout=%d"
,
io_timeout
);
args
[
ac
++
]
=
iotime
;
}
if
(
bwlimit
)
{
s
l
printf
(
bw
,
sizeof
(
bw
),
"--bwlimit=%d"
,
bwlimit
);
s
n
printf
(
bw
,
sizeof
(
bw
),
"--bwlimit=%d"
,
bwlimit
);
args
[
ac
++
]
=
bw
;
}
...
...
@@ -602,7 +602,7 @@ void server_options(char **args,int *argc)
args
[
ac
++
]
=
"--size-only"
;
if
(
modify_window_set
)
{
s
l
printf
(
mwindow
,
sizeof
(
mwindow
),
"--modify-window=%d"
,
s
n
printf
(
mwindow
,
sizeof
(
mwindow
),
"--modify-window=%d"
,
modify_window
);
args
[
ac
++
]
=
mwindow
;
}
...
...
receiver.c
View file @
8950ac03
...
...
@@ -179,7 +179,7 @@ static int get_tmpname(char *fnametmp, char *fname)
rprintf
(
FERROR
,
"filename too long
\n
"
);
return
0
;
}
s
l
printf
(
fnametmp
,
MAXPATHLEN
,
"%s/.%s.XXXXXX"
,
tmpdir
,
f
);
s
n
printf
(
fnametmp
,
MAXPATHLEN
,
"%s/.%s.XXXXXX"
,
tmpdir
,
f
);
return
1
;
}
...
...
@@ -192,11 +192,11 @@ static int get_tmpname(char *fnametmp, char *fname)
if
(
f
)
{
*
f
=
0
;
s
l
printf
(
fnametmp
,
MAXPATHLEN
,
"%s/.%s.XXXXXX"
,
s
n
printf
(
fnametmp
,
MAXPATHLEN
,
"%s/.%s.XXXXXX"
,
fname
,
f
+
1
);
*
f
=
'/'
;
}
else
{
s
l
printf
(
fnametmp
,
MAXPATHLEN
,
".%s.XXXXXX"
,
fname
);
s
n
printf
(
fnametmp
,
MAXPATHLEN
,
".%s.XXXXXX"
,
fname
);
}
return
1
;
...
...
@@ -372,7 +372,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if
((
fd1
==
-
1
)
&&
(
compare_dest
!=
NULL
))
{
/* try the file at compare_dest instead */
s
l
printf
(
fnamecmpbuf
,
MAXPATHLEN
,
"%s/%s"
,
s
n
printf
(
fnamecmpbuf
,
MAXPATHLEN
,
"%s/%s"
,
compare_dest
,
fname
);
fnamecmp
=
fnamecmpbuf
;
fd1
=
do_open
(
fnamecmp
,
O_RDONLY
,
0
);
...
...
rsync.c
View file @
8950ac03
...
...
@@ -91,7 +91,7 @@ int delete_file(char *fname)
if
(
strcmp
(
dname
,
"."
)
==
0
||
strcmp
(
dname
,
".."
)
==
0
)
continue
;
s
l
printf
(
buf
,
sizeof
(
buf
),
"%s/%s"
,
fname
,
dname
);
s
n
printf
(
buf
,
sizeof
(
buf
),
"%s/%s"
,
fname
,
dname
);
if
(
verbose
>
0
)
rprintf
(
FINFO
,
"deleting %s
\n
"
,
buf
);
if
(
delete_file
(
buf
)
!=
0
)
{
...
...
socket.c
View file @
8950ac03
...
...
@@ -32,7 +32,7 @@ static int establish_proxy_connection(int fd, char *host, int port)
char
buffer
[
1024
];
char
*
cp
;
s
l
printf
(
buffer
,
sizeof
(
buffer
),
"CONNECT %s:%d HTTP/1.0
\r\n\r\n
"
,
host
,
port
);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"CONNECT %s:%d HTTP/1.0
\r\n\r\n
"
,
host
,
port
);
if
(
write
(
fd
,
buffer
,
strlen
(
buffer
))
!=
strlen
(
buffer
))
{
rprintf
(
FERROR
,
"failed to write to proxy: %s
\n
"
,
strerror
(
errno
));
...
...
util.c
View file @
8950ac03
...
...
@@ -558,10 +558,7 @@ void glob_expand(char *base1, char **argv, int *argc, int maxargs)
s
=
strdup
(
s
);
if
(
!
s
)
out_of_memory
(
"glob_expand"
);
base
=
(
char
*
)
malloc
(
strlen
(
base1
)
+
3
);
if
(
!
base
)
out_of_memory
(
"glob_expand"
);
sprintf
(
base
,
" %s/"
,
base1
);
if
(
asprintf
(
&
base
,
" %s/"
,
base1
)
<=
0
)
out_of_memory
(
"glob_expand"
);
q
=
s
;
while
((
p
=
strstr
(
q
,
base
))
&&
((
*
argc
)
<
maxargs
))
{
...
...
@@ -588,33 +585,6 @@ void strlower(char *s)
}
}
/* this is like vsnprintf but it always null terminates, so you
can fit at most n-1 chars in */
int
vslprintf
(
char
*
str
,
int
n
,
const
char
*
format
,
va_list
ap
)
{
int
ret
=
vsnprintf
(
str
,
n
,
format
,
ap
);
if
(
ret
>=
n
||
ret
<
0
)
{
str
[
n
-
1
]
=
0
;
return
-
1
;
}
str
[
ret
]
=
0
;
return
ret
;
}
/* like snprintf but always null terminates */
int
slprintf
(
char
*
str
,
int
n
,
char
*
format
,
...)
{
va_list
ap
;
int
ret
;
va_start
(
ap
,
format
);
ret
=
vslprintf
(
str
,
n
,
format
,
ap
);
va_end
(
ap
);
return
ret
;
}
void
*
Realloc
(
void
*
p
,
int
size
)
{
if
(
!
p
)
return
(
void
*
)
malloc
(
size
);
...
...
@@ -987,9 +957,9 @@ int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
{
static
int
(
*
fn
)();
int
ret
;
char
cmd
[
1024
]
;
char
*
cmd
;
sprintf
(
cmd
,
"/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'"
,
asprintf
(
&
cmd
,
"/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'"
,
getpid
(),
getpid
(),
getpid
());
if
(
!
fn
)
{
...
...
@@ -1002,6 +972,8 @@ int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
system
(
cmd
);
free
(
cmd
);
return
ret
;
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment