mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
merged feature filan -s
This commit is contained in:
commit
749b745c8a
4 changed files with 30 additions and 15 deletions
9
CHANGES
9
CHANGES
|
@ -35,13 +35,16 @@ corrections:
|
||||||
replaced the select() calls by poll() to cleanly fix the problems with
|
replaced the select() calls by poll() to cleanly fix the problems with
|
||||||
many file descriptors already open
|
many file descriptors already open
|
||||||
|
|
||||||
Makefile now supports datarootdir (thanks to Camillo Lugaresi for
|
|
||||||
providing the patch)
|
|
||||||
|
|
||||||
porting:
|
porting:
|
||||||
socat should now build under MacOS X 10.4 (thanks to Camillo Lugaresi for
|
socat should now build under MacOS X 10.4 (thanks to Camillo Lugaresi for
|
||||||
providing the patch)
|
providing the patch)
|
||||||
|
|
||||||
|
further changes:
|
||||||
|
filan -s prefixes output with FD number if more than one FD
|
||||||
|
|
||||||
|
Makefile now supports datarootdir (thanks to Camillo Lugaresi for
|
||||||
|
providing the patch)
|
||||||
|
|
||||||
####################### V 1.6.0.1:
|
####################### V 1.6.0.1:
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
|
|
7
fdname.c
7
fdname.c
|
@ -1,5 +1,5 @@
|
||||||
/* source: fdname.c */
|
/* source: fdname.c */
|
||||||
/* Copyright Gerhard Rieger 2003-2007 */
|
/* Copyright Gerhard Rieger 2003-2008 */
|
||||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
/* the subroutine sockname prints the basic info about the address of a socket
|
/* the subroutine sockname prints the basic info about the address of a socket
|
||||||
|
@ -32,7 +32,7 @@ int unixame(int fd, FILE *outfile);
|
||||||
int tcpname(int fd, FILE *outfile);
|
int tcpname(int fd, FILE *outfile);
|
||||||
|
|
||||||
|
|
||||||
int fdname(const char *file, int fd, FILE *outfile) {
|
int fdname(const char *file, int fd, FILE *outfile, const char *numform) {
|
||||||
struct stat buf = {0};
|
struct stat buf = {0};
|
||||||
int filetype;
|
int filetype;
|
||||||
Debug1("checking file descriptor %u", fd);
|
Debug1("checking file descriptor %u", fd);
|
||||||
|
@ -46,6 +46,9 @@ int fdname(const char *file, int fd, FILE *outfile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filetype = (buf.st_mode&S_IFMT)>>12;
|
filetype = (buf.st_mode&S_IFMT)>>12;
|
||||||
|
if (numform != NULL) {
|
||||||
|
fprintf(outfile, numform, fd);
|
||||||
|
}
|
||||||
return statname(file, fd, filetype, outfile);
|
return statname(file, fd, filetype, outfile);
|
||||||
} else {
|
} else {
|
||||||
if (Stat(file, &buf) < 0) {
|
if (Stat(file, &buf) < 0) {
|
||||||
|
|
5
filan.h
5
filan.h
|
@ -1,5 +1,5 @@
|
||||||
/* source: filan.h */
|
/* source: filan.h */
|
||||||
/* Copyright Gerhard Rieger 2001-2007 */
|
/* Copyright Gerhard Rieger 2001-2008 */
|
||||||
|
|
||||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ extern int ipan(int fd, FILE *outfile);
|
||||||
extern int ip6an(int fd, FILE *outfile);
|
extern int ip6an(int fd, FILE *outfile);
|
||||||
#endif /* WITH_SOCKET */
|
#endif /* WITH_SOCKET */
|
||||||
|
|
||||||
extern int fdname(const char *file, int fd, FILE *outfile);
|
extern
|
||||||
|
int fdname(const char *file, int fd, FILE *outfile, const char *numform);
|
||||||
|
|
||||||
#endif /* !defined(__filan_h_included) */
|
#endif /* !defined(__filan_h_included) */
|
||||||
|
|
24
filan_main.c
24
filan_main.c
|
@ -1,5 +1,5 @@
|
||||||
/* source: filan_main.c */
|
/* source: filan_main.c */
|
||||||
/* Copyright Gerhard Rieger 2001-2006 */
|
/* Copyright Gerhard Rieger 2001-2008 */
|
||||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
const char copyright[] = "filan by Gerhard Rieger - see http://www.dest-unreach.org/socat/";
|
const char copyright[] = "filan by Gerhard Rieger - see http://www.dest-unreach.org/socat/";
|
||||||
|
@ -23,7 +23,8 @@ static void filan_usage(FILE *fd);
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
const char **arg1, *a;
|
const char **arg1, *a;
|
||||||
const char *filename = NULL, *waittimetxt;
|
const char *filename = NULL, *waittimetxt;
|
||||||
unsigned int m = 0, n = 1024; /* this is default on my Linux */
|
unsigned int m = 0; /* first FD (default) */
|
||||||
|
unsigned int n = FD_SETSIZE; /* last excl. */
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int style = 0;
|
int style = 0;
|
||||||
struct timespec waittime = { 0, 0 };
|
struct timespec waittime = { 0, 0 };
|
||||||
|
@ -57,7 +58,7 @@ int main(int argc, const char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m = strtoul(a, (char **)&a, 0);
|
m = strtoul(a, (char **)&a, 0);
|
||||||
n = m+1;
|
n = m;
|
||||||
break;
|
break;
|
||||||
case 'n': if (arg1[0][2]) {
|
case 'n': if (arg1[0][2]) {
|
||||||
a = *arg1+2;
|
a = *arg1+2;
|
||||||
|
@ -168,6 +169,9 @@ int main(int argc, const char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
filan_file(filename, fdout);
|
filan_file(filename, fdout);
|
||||||
} else {
|
} else {
|
||||||
|
if (m == n) {
|
||||||
|
++n;
|
||||||
|
}
|
||||||
for (i = m; i < n; ++i) {
|
for (i = m; i < n; ++i) {
|
||||||
filan_fd(i, fdout);
|
filan_fd(i, fdout);
|
||||||
}
|
}
|
||||||
|
@ -189,12 +193,16 @@ int main(int argc, const char *argv[]) {
|
||||||
Debug2("open(\"%s\", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0700): %s",
|
Debug2("open(\"%s\", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0700): %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
}
|
}
|
||||||
fdname(filename, fd, fdout);
|
fdname(filename, fd, fdout, NULL);
|
||||||
#endif
|
#endif
|
||||||
fdname(filename, -1, fdout);
|
fdname(filename, -1, fdout, NULL);
|
||||||
} else {
|
} else {
|
||||||
for (i = m; i < n; ++i) {
|
if (m == n) {
|
||||||
fdname("", i, fdout);
|
fdname("", m, fdout, NULL);
|
||||||
|
} else {
|
||||||
|
for (i = m; i < n; ++i) {
|
||||||
|
fdname("", i, fdout, "%5u ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +233,7 @@ static void filan_usage(FILE *fd) {
|
||||||
fputs(" -ls log to stderr (default if no other log)\n", fd);
|
fputs(" -ls log to stderr (default if no other log)\n", fd);
|
||||||
#endif
|
#endif
|
||||||
fputs(" -i<fdnum> only analyze this fd\n", fd);
|
fputs(" -i<fdnum> only analyze this fd\n", fd);
|
||||||
fputs(" -n<fdnum> analyze all fds from 0 up to fdnum-1 (default: 1024)\n", fd);
|
fprintf(fd, " -n<fdnum> analyze all fds from 0 up to fdnum-1 (default: %u)\n", FD_SETSIZE);
|
||||||
fputs(" -s simple output with just type and socket address or path\n", fd);
|
fputs(" -s simple output with just type and socket address or path\n", fd);
|
||||||
/* fputs(" -c alternate device visualization\n", fd);*/
|
/* fputs(" -c alternate device visualization\n", fd);*/
|
||||||
fputs(" -f<filename> analyze file system entry\n", fd);
|
fputs(" -f<filename> analyze file system entry\n", fd);
|
||||||
|
|
Loading…
Reference in a new issue