1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-04 08:30:54 +02:00

17570: tweaks to socket module

This commit is contained in:
Peter Stephenson 2002-08-22 12:08:06 +00:00
parent 29ff4ab0e2
commit 1c5d5bb1f4
4 changed files with 23 additions and 13 deletions

View file

@ -1,3 +1,10 @@
2002-08-22 Peter Stephenson <pws@csr.com>
* 17570: Src/Modules/socket.c, Doc/Zsh/Makefile.in,
Doc/Zsh/mod_socket.yo: Don't use predefined name `sun'; set
length parameter for accept(); fix inclusion of socket module
in documentation.
2002-08-20 Sven Wischnowsky <wischnow@zsh.org>
* 17569: Src/Zle/zle_tricky.c: fix typo in comment

View file

@ -59,7 +59,8 @@ Zsh/mod_compctl.yo Zsh/mod_complete.yo Zsh/mod_complist.yo \
Zsh/mod_computil.yo \
Zsh/mod_deltochar.yo Zsh/mod_example.yo Zsh/mod_files.yo \
Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_parameter.yo Zsh/mod_pcre.yo \
Zsh/mod_sched.yo Zsh/mod_stat.yo Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
Zsh/mod_sched.yo Zsh/mod_socket.yo \
Zsh/mod_stat.yo Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \
Zsh/mod_zprof.yo Zsh/mod_zpty.yo Zsh/mod_zselect.yo \
Zsh/mod_zutil.yo Zsh/mod_tcp.yo

View file

@ -62,3 +62,4 @@ it will wait for one.
In order to elicit more verbose output, use tt(-v).
)
enditem()
)

View file

@ -63,7 +63,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
int err=1, verbose=0, test=0, targetfd=0;
SOCKLEN_T len;
char **dargs;
struct sockaddr_un sun;
struct sockaddr_un soun;
int sfd;
if (ops['v'])
@ -101,12 +101,12 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
return 1;
}
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, localfn, UNIX_PATH_MAX);
soun.sun_family = AF_UNIX;
strncpy(soun.sun_path, localfn, UNIX_PATH_MAX);
if (bind(sfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)))
if (bind(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))
{
zwarnnam(nam, "could not bind to %s: %e", sun.sun_path, errno);
zwarnnam(nam, "could not bind to %s: %e", soun.sun_path, errno);
close(sfd);
return 1;
}
@ -130,7 +130,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
setiparam("REPLY", sfd);
if (verbose)
printf("%s listener is on fd %d\n", sun.sun_path, sfd);
printf("%s listener is on fd %d\n", soun.sun_path, sfd);
return 0;
@ -190,7 +190,8 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
#endif
}
if ((rfd = accept(lfd, (struct sockaddr *)&sun, &len)) == -1)
len = sizeof(soun);
if ((rfd = accept(lfd, (struct sockaddr *)&soun, &len)) == -1)
{
zwarnnam(nam, "could not accept connection: %e", NULL, errno);
return 1;
@ -207,7 +208,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
setiparam("REPLY", sfd);
if (verbose)
printf("new connection from %s is on fd %d\n", sun.sun_path, sfd);
printf("new connection from %s is on fd %d\n", soun.sun_path, sfd);
}
else
{
@ -223,10 +224,10 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
return 1;
}
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, dargs[0], UNIX_PATH_MAX);
soun.sun_family = AF_UNIX;
strncpy(soun.sun_path, dargs[0], UNIX_PATH_MAX);
if ((err = connect(sfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)))) {
if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))) {
zwarnnam(nam, "connection failed: %e", NULL, errno);
close(sfd);
return 1;
@ -241,7 +242,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
setiparam("REPLY", sfd);
if (verbose)
printf("%s is now on fd %d\n", sun.sun_path, sfd);
printf("%s is now on fd %d\n", soun.sun_path, sfd);
}
}