SOURCES: recordio.diff (NEW) - add to PLD cvs
glen
glen at pld-linux.org
Mon Oct 10 18:50:44 CEST 2005
Author: glen Date: Mon Oct 10 16:50:44 2005 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- add to PLD cvs
---- Files affected:
SOURCES:
recordio.diff (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/recordio.diff
diff -u /dev/null SOURCES/recordio.diff:1.1
--- /dev/null Mon Oct 10 18:50:44 2005
+++ SOURCES/recordio.diff Mon Oct 10 18:50:39 2005
@@ -0,0 +1,161 @@
+*** ucspi-tcp-0.88/recordio.c Sat Mar 18 16:18:42 2000
+--- ucspi-tcp-0.88-maex/recordio.c Thu May 22 22:29:40 2003
+***************
+*** 1,3 ****
+--- 1,11 ----
++ /* only "record io" if the environment variable
++ RECORDIO is set */
++ #define __mENVCHECK
++
++ /* add "recordio: pid n: remote_host:remote_ip" in front
++ of the ">" "<" records */
++ #define __mLOGGING
++
+ #include "sig.h"
+ #include "buffer.h"
+ #include "strerr.h"
+***************
+*** 16,27 ****
+--- 24,91 ----
+ char recordbuf[512];
+ buffer ssrecord = BUFFER_INIT(write,2,recordbuf,sizeof recordbuf);
+
++ #ifdef __mENVCHECK
++ #include "env.h"
++
++ char *env_recordio;
++ #endif /* __mENVCHECK */
++
++ #ifdef __mLOGGING
++ #include "env.h"
++ #include "stralloc.h"
++
++ stralloc logs_pidhostinfo = {0};
++
++ void log_init()
++ {
++ char strnum[FMT_ULONG];
++ char *remotehost;
++ char *remoteip;
++ /*
++ char *remoteinfo;
++ char *remoteport;
++ */
++
++ remoteip = env_get("TCPREMOTEIP");
++ if (!remoteip) remoteip = "unknown";
++ remotehost = env_get("TCPREMOTEHOST");
++ if (!remotehost) remotehost = "unknown";
++ /*
++ remoteinfo = env_get("TCPREMOTEINFO");
++ if (!remoteinfo) remoteinfo = "";
++ remoteport = env_get("TCPREMOTEPORT");
++ if (!remoteport) remoteport = "";
++ */
++
++ if (!stralloc_copys(&logs_pidhostinfo, "recordio: pid ")) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ strnum[fmt_ulong(strnum,getpid())] = 0;
++ if (!stralloc_cats(&logs_pidhostinfo, strnum)) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, ": ")) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++
++ if (!stralloc_cats(&logs_pidhostinfo, remotehost)) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, ":")) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, remoteip)) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ /*
++ if (!stralloc_cats(&logs_pidhostinfo, ":")) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, remoteinfo)) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, ":")) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, remoteport)) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ if (!stralloc_cats(&logs_pidhostinfo, " ")) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ */
++ if (!stralloc_0(&logs_pidhostinfo)) strerr_die2sys(111,FATAL,"unable to allocate memory: ");
++ }
++ #endif /* __mLOGGING */
++
+ void record(char *buf,int len,char *direction) /* 1 <= len <= 256 */
+ {
+ int i;
+
+ while (len) {
++ #ifdef __mLOGGING
++ buffer_puts(&ssrecord, logs_pidhostinfo.s);
++ #else
+ buffer_puts(&ssrecord,pid);
++ #endif /* __mLOGGING */
+ buffer_puts(&ssrecord,direction);
+
+ i = byte_chr(buf,len,'\n');
+***************
+*** 101,107 ****
+ if (r <= 0) {
+ leftstatus = -1;
+ close(fdleft);
+! buffer_puts(&ssrecord,pid);
+ buffer_puts(&ssrecord," < [EOF]\n");
+ buffer_flush(&ssrecord);
+ }
+--- 165,175 ----
+ if (r <= 0) {
+ leftstatus = -1;
+ close(fdleft);
+! #ifdef __mLOGGING
+! buffer_puts(&ssrecord, logs_pidhostinfo.s);
+! #else
+! buffer_puts(&ssrecord,pid);
+! #endif /* __mLOGGING */
+ buffer_puts(&ssrecord," < [EOF]\n");
+ buffer_flush(&ssrecord);
+ }
+***************
+*** 121,127 ****
+ if (ioright && ioright->revents) {
+ r = read(fdright,rightbuf,sizeof rightbuf);
+ if (r <= 0) {
+! buffer_puts(&ssrecord,pid);
+ buffer_puts(&ssrecord," > [EOF]\n");
+ buffer_flush(&ssrecord);
+ break;
+--- 189,199 ----
+ if (ioright && ioright->revents) {
+ r = read(fdright,rightbuf,sizeof rightbuf);
+ if (r <= 0) {
+! #ifdef __mLOGGING
+! buffer_puts(&ssrecord, logs_pidhostinfo.s);
+! #else
+! buffer_puts(&ssrecord,pid);
+! #endif /* __mLOGGING */
+ buffer_puts(&ssrecord," > [EOF]\n");
+ buffer_flush(&ssrecord);
+ break;
+***************
+*** 151,156 ****
+--- 223,238 ----
+ if (argc < 2)
+ strerr_die1x(100,"recordio: usage: recordio program [ arg ... ]");
+
++ #ifdef __mLOGGING
++ log_init();
++ #endif /* __mLOGGING */
++
++ #ifdef __mENVCHECK
++ env_recordio = env_get("RECORDIO");
++
++ if (env_recordio) {
++ #endif /* __mENVCHECK */
++
+ if (pipe(piin) == -1)
+ strerr_die2sys(111,FATAL,"unable to create pipe: ");
+ if (pipe(piout) == -1)
+***************
+*** 172,177 ****
+--- 254,263 ----
+ strerr_die2sys(111,FATAL,"unable to move descriptors: ");
+ if (fd_move(1,piout[1]) == -1)
+ strerr_die2sys(111,FATAL,"unable to move descriptors: ");
++
++ #ifdef __mENVCHECK
++ }
++ #endif /* __mENVCHECK */
+
+ pathexec_run(argv[1],argv + 1,envp);
+ strerr_die4sys(111,FATAL,"unable to run ",argv[1],": ");
================================================================
More information about the pld-cvs-commit
mailing list