mirror of
https://github.com/moparisthebest/socat
synced 2024-12-22 06:58:47 -05:00
merged feature filan -s
This commit is contained in:
commit
749b745c8a
9
CHANGES
9
CHANGES
@ -35,13 +35,16 @@ corrections:
|
||||
replaced the select() calls by poll() to cleanly fix the problems with
|
||||
many file descriptors already open
|
||||
|
||||
Makefile now supports datarootdir (thanks to Camillo Lugaresi for
|
||||
providing the patch)
|
||||
|
||||
porting:
|
||||
socat should now build under MacOS X 10.4 (thanks to Camillo Lugaresi for
|
||||
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:
|
||||
|
||||
new features:
|
||||
|
7
fdname.c
7
fdname.c
@ -1,5 +1,5 @@
|
||||
/* 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 */
|
||||
|
||||
/* 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 fdname(const char *file, int fd, FILE *outfile) {
|
||||
int fdname(const char *file, int fd, FILE *outfile, const char *numform) {
|
||||
struct stat buf = {0};
|
||||
int filetype;
|
||||
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;
|
||||
if (numform != NULL) {
|
||||
fprintf(outfile, numform, fd);
|
||||
}
|
||||
return statname(file, fd, filetype, outfile);
|
||||
} else {
|
||||
if (Stat(file, &buf) < 0) {
|
||||
|
5
filan.h
5
filan.h
@ -1,5 +1,5 @@
|
||||
/* 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 */
|
||||
|
||||
@ -33,6 +33,7 @@ extern int ipan(int fd, FILE *outfile);
|
||||
extern int ip6an(int fd, FILE *outfile);
|
||||
#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) */
|
||||
|
24
filan_main.c
24
filan_main.c
@ -1,5 +1,5 @@
|
||||
/* 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 */
|
||||
|
||||
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[]) {
|
||||
const char **arg1, *a;
|
||||
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;
|
||||
int style = 0;
|
||||
struct timespec waittime = { 0, 0 };
|
||||
@ -57,7 +58,7 @@ int main(int argc, const char *argv[]) {
|
||||
}
|
||||
}
|
||||
m = strtoul(a, (char **)&a, 0);
|
||||
n = m+1;
|
||||
n = m;
|
||||
break;
|
||||
case 'n': if (arg1[0][2]) {
|
||||
a = *arg1+2;
|
||||
@ -168,6 +169,9 @@ int main(int argc, const char *argv[]) {
|
||||
#endif
|
||||
filan_file(filename, fdout);
|
||||
} else {
|
||||
if (m == n) {
|
||||
++n;
|
||||
}
|
||||
for (i = m; i < n; ++i) {
|
||||
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",
|
||||
filename, strerror(errno));
|
||||
}
|
||||
fdname(filename, fd, fdout);
|
||||
fdname(filename, fd, fdout, NULL);
|
||||
#endif
|
||||
fdname(filename, -1, fdout);
|
||||
fdname(filename, -1, fdout, NULL);
|
||||
} else {
|
||||
for (i = m; i < n; ++i) {
|
||||
fdname("", i, fdout);
|
||||
if (m == n) {
|
||||
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);
|
||||
#endif
|
||||
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(" -c alternate device visualization\n", fd);*/
|
||||
fputs(" -f<filename> analyze file system entry\n", fd);
|
||||
|
Loading…
Reference in New Issue
Block a user