Hi,

I had the need for a fd_gets function and wondered why it was not available.
I tried to write one and sent a patch to you developers.

The patch was made against openssl-0.9.7d but should also work on
openssl-0.9.8 source.

Best Regards,
Dirk

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++
diff -uNr openssl-0.9.7d.orig/crypto/bio/bss_fd.c openssl-0.9.7d.dirk/crypto/bio/bss_fd.c
--- openssl-0.9.7d.orig/crypto/bio/bss_fd.c	2001-02-20 09:12:59.000000000 +0100
+++ openssl-0.9.7d.dirk/crypto/bio/bss_fd.c	2005-08-30 20:13:29.835943832 +0200
@@ -65,6 +65,7 @@
 static int fd_write(BIO *h, const char *buf, int num);
 static int fd_read(BIO *h, char *buf, int size);
 static int fd_puts(BIO *h, const char *str);
+static int fd_gets(BIO *h, char *buf, int size);
 static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
 static int fd_new(BIO *h);
 static int fd_free(BIO *data);
@@ -76,7 +77,7 @@
 	fd_write,
 	fd_read,
 	fd_puts,
-	NULL, /* fd_gets, */
+	fd_gets,
 	fd_ctrl,
 	fd_new,
 	fd_free,
@@ -215,6 +216,22 @@
 	return(ret);
 	}
 
+static int fd_gets(BIO *bp, char *buf, int size)
+        {
+        int ret=0;
+	char *ptr=buf;
+	char *end=buf+size-1;
+
+	while ( (ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n') )
+		ptr++;
+
+       	ptr[0]='\0';
+
+        if (buf[0] != '\0')
+                ret=strlen(buf);
+        return(ret);
+        }
+
 int BIO_fd_should_retry(int i)
 	{
 	int err;

Reply via email to