unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 8b05bddfe5ddb958372a38ed7c1f61cec7bd11c3 3110 bytes (raw)
name: gnu/packages/patches/netcat-openbsd-0005-send-crlf.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
 
From: Aron Xu <aron@debian.org>
Date: Mon, 13 Feb 2012 14:57:45 +0800
Subject: send crlf

---
 nc.1     |    6 ++++--
 netcat.c |   21 +++++++++++++++++----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/nc.1 b/nc.1
index b7014a2..af44976 100644
--- a/nc.1
+++ b/nc.1
@@ -34,7 +34,7 @@
 .Sh SYNOPSIS
 .Nm nc
 .Bk -words
-.Op Fl 46DdhklnrStUuvz
+.Op Fl 46CDdhklnrStUuvz
 .Op Fl I Ar length
 .Op Fl i Ar interval
 .Op Fl O Ar length
@@ -98,6 +98,8 @@ to use IPv4 addresses only.
 Forces
 .Nm
 to use IPv6 addresses only.
+.It Fl C
+Send CRLF as line-ending.
 .It Fl D
 Enable debugging on the socket.
 .It Fl d
@@ -355,7 +357,7 @@ More complicated examples can be built up when the user knows the format
 of requests required by the server.
 As another example, an email may be submitted to an SMTP server using:
 .Bd -literal -offset indent
-$ nc localhost 25 \*(Lt\*(Lt EOF
+$ nc [\-C] localhost 25 \*(Lt\*(Lt EOF
 HELO host.example.com
 MAIL FROM:\*(Ltuser@host.example.com\*(Gt
 RCPT TO:\*(Ltuser2@host.example.com\*(Gt
diff --git a/netcat.c b/netcat.c
index fdaca44..4f4d2bf 100644
--- a/netcat.c
+++ b/netcat.c
@@ -111,6 +111,7 @@
 #define CONNECTION_TIMEOUT 2

 /* Command Line Options */
+int     Cflag = 0;                              /* CRLF line-ending */
 int	dflag;					/* detached, no stdin */
 unsigned int iflag;				/* Interval Flag */
 int	jflag;					/* use jumbo frames if we can */
@@ -180,7 +181,7 @@ main(int argc, char *argv[])
 	sv = NULL;

 	while ((ch = getopt(argc, argv,
-	    "46DdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {
+	    "46CDdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {
 		switch (ch) {
 		case '4':
 			family = AF_INET;
@@ -309,6 +310,9 @@ main(int argc, char *argv[])
 			if (Tflag < 0 || Tflag > 255 || errstr || errno)
 				errx(1, "illegal tos value %s", optarg);
 			break;
+                case 'C':
+                        Cflag = 1;
+                        break;
 		default:
 			usage(1);
 		}
@@ -906,8 +910,16 @@ readwrite(int nfd)
 			else if (n == 0) {
 				goto shutdown_wr;
 			} else {
-				if (atomicio(vwrite, nfd, buf, n) != n)
-					return;
+				if ((Cflag) && (buf[n-1]=='\n')) {
+					if (atomicio(vwrite, nfd, buf, n-1) != (n-1))
+						return;
+					if (atomicio(vwrite, nfd, "\r\n", 2) != 2)
+						return;
+				}
+				else {
+					if (atomicio(vwrite, nfd, buf, n) != n)
+						return;
+				}
 			}
 			}
 			else if (pfd[1].revents & POLLHUP) {
@@ -1139,6 +1151,7 @@ help(void)
 	fprintf(stderr, "\tCommand Summary:\n\
 	\t-4		Use IPv4\n\
 	\t-6		Use IPv6\n\
+	\t-C		Send CRLF as line-ending\n\
 	\t-D		Enable the debug socket option\n\
 	\t-d		Detach from stdin\n\
 	\t-h		This help text\n\
@@ -1172,7 +1185,7 @@ void
 usage(int ret)
 {
 	fprintf(stderr,
-	    "usage: nc [-46DdhjklnrStUuvz] [-I length] [-i interval] [-O length]\n"
+	    "usage: nc [-46CDdhjklnrStUuvz] [-I length] [-i interval] [-O length]\n"
 	    "\t  [-P proxy_username] [-p source_port] [-s source] [-T toskeyword]\n"
 	    "\t  [-V rtable] [-w timeout] [-X proxy_protocol]\n"
 	    "\t  [-x proxy_address[:port]] [destination] [port]\n");
--

debug log:

solving 1a5fc6e ...
found 1a5fc6e in https://yhetil.org/guix-devel/20160622000749.GA27984@shadowwalker/

applying [1/1] https://yhetil.org/guix-devel/20160622000749.GA27984@shadowwalker/
diff --git a/gnu/packages/patches/netcat-openbsd-0005-send-crlf.patch b/gnu/packages/patches/netcat-openbsd-0005-send-crlf.patch
new file mode 100644
index 0000000..1a5fc6e

1:60: space before tab in indent.
 	sv = NULL;
1:62: space before tab in indent.
 	while ((ch = getopt(argc, argv,
1:65: space before tab in indent.
 		switch (ch) {
1:66: space before tab in indent.
 		case '4':
1:67: space before tab in indent.
 			family = AF_INET;
Checking patch gnu/packages/patches/netcat-openbsd-0005-send-crlf.patch...
Applied patch gnu/packages/patches/netcat-openbsd-0005-send-crlf.patch cleanly.
warning: squelched 22 whitespace errors
warning: 27 lines add whitespace errors.

skipping https://yhetil.org/guix-devel/20160622000749.GA27984@shadowwalker/ for 1a5fc6e
index at:
100644 8b05bddfe5ddb958372a38ed7c1f61cec7bd11c3	gnu/packages/patches/netcat-openbsd-0005-send-crlf.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).