mirror of
https://repo.or.cz/socat.git
synced 2025-05-22 13:02:40 +00:00
Procan -V; more C-defines (__GLIBC__, O_*, AI_*, EAI_*)
This commit is contained in:
parent
568c26861b
commit
200ccb24cd
3 changed files with 171 additions and 12 deletions
3
CHANGES
3
CHANGES
|
@ -101,6 +101,9 @@ Features:
|
|||
Procan uses getresuid() and getresgid() when available, to determine
|
||||
the saved set-user-ID.
|
||||
|
||||
Procan prints more C-defines, esp.O_*, AI_*, EAI_*; __GLIBC__;
|
||||
added option -V
|
||||
|
||||
Building:
|
||||
Disabling certain features during configure could break build process.
|
||||
|
||||
|
|
152
procan-cdefs.c
152
procan-cdefs.c
|
@ -15,30 +15,91 @@
|
|||
#include "procan.h"
|
||||
|
||||
int procan_cdefs(FILE *outfile) {
|
||||
/* basic C/system constants */
|
||||
/* System constants */
|
||||
#ifdef __KERNEL__
|
||||
fprintf(outfile, "__KERNEL__ = \"%s\"\n", __KERNEL__);
|
||||
#endif
|
||||
#ifdef __GLIBC__
|
||||
fprintf(outfile, "__GLIBC__ = %d\n", __GLIBC__);
|
||||
#endif
|
||||
/* Basic C/system constants */
|
||||
#ifdef FD_SETSIZE
|
||||
fprintf(outfile, "#define FD_SETSIZE %u\n", FD_SETSIZE);
|
||||
fprintf(outfile, "#define FD_SETSIZE %u\n", FD_SETSIZE);
|
||||
#endif
|
||||
#ifdef NFDBITS
|
||||
fprintf(outfile, "#define NFDBITS %d\n", (int)NFDBITS);
|
||||
fprintf(outfile, "#define NFDBITS %d\n", (int)NFDBITS);
|
||||
#endif
|
||||
#ifdef O_RDONLY
|
||||
fprintf(outfile, "#define O_RDONLY %u\n", O_RDONLY);
|
||||
fprintf(outfile, "#define O_RDONLY %u\n", O_RDONLY);
|
||||
#endif
|
||||
#ifdef O_WRONLY
|
||||
fprintf(outfile, "#define O_WRONLY %u\n", O_WRONLY);
|
||||
fprintf(outfile, "#define O_WRONLY %u\n", O_WRONLY);
|
||||
#endif
|
||||
#ifdef O_RDWR
|
||||
fprintf(outfile, "#define O_RDWR %u\n", O_RDWR);
|
||||
fprintf(outfile, "#define O_RDWR %u\n", O_RDWR);
|
||||
#endif
|
||||
#ifdef O_CREAT
|
||||
fprintf(outfile, "#define O_CREAT 0x%06x\n", O_CREAT);
|
||||
#endif
|
||||
#ifdef O_EXCL
|
||||
fprintf(outfile, "#define O_EXCL 0x%06x\n", O_EXCL);
|
||||
#endif
|
||||
#ifdef O_NOCTTY
|
||||
fprintf(outfile, "#define O_NOCTTY 0x%06x\n", O_NOCTTY);
|
||||
#endif
|
||||
#ifdef O_TRUNC
|
||||
fprintf(outfile, "#define O_TRUNC 0x%06x\n", O_TRUNC);
|
||||
#endif
|
||||
#ifdef O_APPEND
|
||||
fprintf(outfile, "#define O_APPEND 0x%06x\n", O_APPEND);
|
||||
#endif
|
||||
#ifdef O_NONBLOCK
|
||||
fprintf(outfile, "#define O_NONBLOCK 0x%06x\n", O_NONBLOCK);
|
||||
#endif
|
||||
#ifdef O_NDELAY
|
||||
fprintf(outfile, "#define O_NDELAY 0x%06x\n", O_NDELAY);
|
||||
#endif
|
||||
#ifdef O_SYNC
|
||||
fprintf(outfile, "#define O_SYNC 0x%06x\n", O_SYNC);
|
||||
#endif
|
||||
#ifdef O_FSYNC
|
||||
fprintf(outfile, "#define O_FSYNC 0x%06x\n", O_FSYNC);
|
||||
#endif
|
||||
#ifdef O_LARGEFILE
|
||||
fprintf(outfile, "#define O_LARGEFILE 0x%06x\n", O_LARGEFILE);
|
||||
#endif
|
||||
#ifdef O_DIRECTORY
|
||||
fprintf(outfile, "#define O_DIRECTORY 0x%06x\n", O_DIRECTORY);
|
||||
#endif
|
||||
#ifdef O_NOFOLLOW
|
||||
fprintf(outfile, "#define O_NOFOLLOW 0x%06x\n", O_NOFOLLOW);
|
||||
#endif
|
||||
#ifdef O_CLOEXEC
|
||||
fprintf(outfile, "#define O_CLOEXEC 0x%06x\n", O_CLOEXEC);
|
||||
#endif
|
||||
#ifdef O_DIRECT
|
||||
fprintf(outfile, "#define O_DIRECT 0x%06x\n", O_DIRECT);
|
||||
#endif
|
||||
#ifdef O_NOATIME
|
||||
fprintf(outfile, "#define O_NOATIME 0x%06x\n", O_NOATIME);
|
||||
#endif
|
||||
#ifdef O_PATH
|
||||
fprintf(outfile, "#define O_PATH 0x%06x\n", O_PATH);
|
||||
#endif
|
||||
#ifdef O_DSYNC
|
||||
fprintf(outfile, "#define O_DSYNC 0x%06x\n", O_SYNC);
|
||||
#endif
|
||||
#ifdef O_TMPFILE
|
||||
fprintf(outfile, "#define O_TMPFILE 0x%06x\n", O_TMPFILE);
|
||||
#endif
|
||||
#ifdef SHUT_RD
|
||||
fprintf(outfile, "#define SHUT_RD %u\n", SHUT_RD);
|
||||
fprintf(outfile, "#define SHUT_RD %u\n", SHUT_RD);
|
||||
#endif
|
||||
#ifdef SHUT_WR
|
||||
fprintf(outfile, "#define SHUT_WR %u\n", SHUT_WR);
|
||||
fprintf(outfile, "#define SHUT_WR %u\n", SHUT_WR);
|
||||
#endif
|
||||
#ifdef SHUT_RDWR
|
||||
fprintf(outfile, "#define SHUT_RDWR %u\n", SHUT_RDWR);
|
||||
fprintf(outfile, "#define SHUT_RDWR %u\n", SHUT_RDWR);
|
||||
#endif
|
||||
|
||||
/* Compile time controls */
|
||||
|
@ -188,5 +249,78 @@ int procan_cdefs(FILE *outfile) {
|
|||
#ifdef TCP_MAXSEG
|
||||
fprintf(outfile, "#define TCP_MAXSEG %d\n", TCP_MAXSEG);
|
||||
#endif
|
||||
#ifdef AI_PASSIVE
|
||||
fprintf(outfile, "#define AI_PASSIVE 0x%02x\n", AI_PASSIVE);
|
||||
#endif
|
||||
#ifdef AI_CANONNAME
|
||||
fprintf(outfile, "#define AI_CANONNAME 0x%02x\n", AI_CANONNAME);
|
||||
#endif
|
||||
#ifdef AI_NUMERICHOST
|
||||
fprintf(outfile, "#define AI_NUMERICHOST 0x%02x\n", AI_NUMERICHOST);
|
||||
#endif
|
||||
#ifdef AI_V4MAPPED
|
||||
fprintf(outfile, "#define AI_V4MAPPED 0x%02x\n", AI_V4MAPPED);
|
||||
#endif
|
||||
#ifdef AI_ALL
|
||||
fprintf(outfile, "#define AI_ALL 0x%02x\n", AI_ALL);
|
||||
#endif
|
||||
#ifdef AI_ADDRCONFIG
|
||||
fprintf(outfile, "#define AI_ADDRCONFIG 0x%02x\n", AI_ADDRCONFIG);
|
||||
#endif
|
||||
#ifdef EAI_BADFLAGS
|
||||
fprintf(outfile, "#define EAI_BADFLAGS %d\n", EAI_BADFLAGS);
|
||||
#endif
|
||||
#ifdef EAI_NONAME
|
||||
fprintf(outfile, "#define EAI_NONAME %d\n", EAI_NONAME);
|
||||
#endif
|
||||
#ifdef EAI_AGAIN
|
||||
fprintf(outfile, "#define EAI_AGAIN %d\n", EAI_AGAIN);
|
||||
#endif
|
||||
#ifdef EAI_FAIL
|
||||
fprintf(outfile, "#define EAI_FAIL %d\n", EAI_FAIL);
|
||||
#endif
|
||||
#ifdef EAI_FAMILY
|
||||
fprintf(outfile, "#define EAI_FAMILY %d\n", EAI_FAMILY);
|
||||
#endif
|
||||
#ifdef EAI_SOCKTYPE
|
||||
fprintf(outfile, "#define EAI_SOCKTYPE %d\n", EAI_SOCKTYPE);
|
||||
#endif
|
||||
#ifdef EAI_SERVICE
|
||||
fprintf(outfile, "#define EAI_SERVICE %d\n", EAI_SERVICE);
|
||||
#endif
|
||||
#ifdef EAI_MEMORY
|
||||
fprintf(outfile, "#define EAI_MEMORY %d\n", EAI_MEMORY);
|
||||
#endif
|
||||
#ifdef EAI_SYSTEM
|
||||
fprintf(outfile, "#define EAI_SYSTEM %d\n", EAI_SYSTEM);
|
||||
#endif
|
||||
#ifdef EAI_OVERFLOW
|
||||
fprintf(outfile, "#define EAI_OVERFLOW %d\n", EAI_OVERFLOW);
|
||||
#endif
|
||||
#ifdef EAI_NODATA
|
||||
fprintf(outfile, "#define EAI_NODATA %d\n", EAI_NODATA);
|
||||
#endif
|
||||
#ifdef EAI_ADDRFAMILY
|
||||
fprintf(outfile, "#define EAI_ADDRFAMILY %d\n", EAI_ADDRFAMILY);
|
||||
#endif
|
||||
#ifdef EAI_INPROGRESS
|
||||
fprintf(outfile, "#define EAI_INPROGRESS %d\n", EAI_INPROGRESS);
|
||||
#endif
|
||||
#ifdef EAI_CANCELED
|
||||
fprintf(outfile, "#define EAI_CANCELED %d\n", EAI_CANCELED);
|
||||
#endif
|
||||
#ifdef EAI_NOTCANCELED
|
||||
fprintf(outfile, "#define EAI_NOTCANCELED %d\n", EAI_NOTCANCELED);
|
||||
#endif
|
||||
#ifdef EAI_ALLDONE
|
||||
fprintf(outfile, "#define EAI_ALLDONE %d\n", EAI_ALLDONE);
|
||||
#endif
|
||||
#ifdef EAI_INTR
|
||||
fprintf(outfile, "#define EAI_INTR %d\n", EAI_INTR);
|
||||
#endif
|
||||
#ifdef EAI_IDN_ENCODE
|
||||
fprintf(outfile, "#define EAI_IDN_ENCODE %d\n", EAI_IDN_ENCODE);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@ const char copyright[] = "procan by Gerhard Rieger and contributors - send bug r
|
|||
#if HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h> /* select(), fdset on FreeBSD */
|
||||
#endif
|
||||
#if HAVE_SYS_UTSNAME_H
|
||||
#include <sys/utsname.h> /* uname(), struct utsname */
|
||||
#endif
|
||||
#include "mytypes.h"
|
||||
#include "error.h"
|
||||
#include "procan.h"
|
||||
|
@ -22,6 +25,13 @@ const char copyright[] = "procan by Gerhard Rieger and contributors - send bug r
|
|||
#define WITH_HELP 1
|
||||
|
||||
static void procan_usage(FILE *fd);
|
||||
static void procan_version(FILE *fd);
|
||||
|
||||
const char copyright_procan[] = "procan by Gerhard Rieger and contributors - see www.dest-unreach.org";
|
||||
static const char procanversion[] =
|
||||
#include "./VERSION"
|
||||
;
|
||||
static const char timestamp[] = BUILD_DATE;
|
||||
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
|
@ -39,8 +49,8 @@ int main(int argc, const char *argv[]) {
|
|||
case '?': case 'h': procan_usage(stdout); exit(0);
|
||||
#endif /* WITH_HELP */
|
||||
case 'c': procan_cdefs(stdout); exit(0);
|
||||
#if LATER
|
||||
case 'V': procan_version(stdout); exit(0);
|
||||
#if LATER
|
||||
case 'l': diag_set(arg1[0][2], &arg1[0][3]); break;
|
||||
case 'd': diag_set('d', NULL); break;
|
||||
#endif
|
||||
|
@ -80,9 +90,7 @@ static void procan_usage(FILE *fd) {
|
|||
fputs("Usage:\n", fd);
|
||||
fputs("procan [options]\n", fd);
|
||||
fputs(" options:\n", fd);
|
||||
#if LATER
|
||||
fputs(" -V print version information to stdout, and exit\n", fd);
|
||||
#endif
|
||||
#if WITH_HELP
|
||||
fputs(" -?|-h print a help text describing command line options\n", fd);
|
||||
#endif
|
||||
|
@ -100,3 +108,17 @@ static void procan_usage(FILE *fd) {
|
|||
#endif
|
||||
}
|
||||
#endif /* WITH_HELP */
|
||||
|
||||
|
||||
void procan_version(
|
||||
FILE *fd)
|
||||
{
|
||||
struct utsname ubuf;
|
||||
|
||||
fputs(copyright_procan, fd); fputc('\n', fd);
|
||||
fprintf(fd, "procan version %s on %s\n", procanversion, timestamp);
|
||||
uname(&ubuf);
|
||||
fprintf(fd, " running on %s version %s, release %s, machine %s\n",
|
||||
ubuf.sysname, ubuf.version, ubuf.release, ubuf.machine);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue