Revision: 14676
Author: adrian.chadd
Date: Wed May 19 20:24:38 2010
Log: Break out a couple of the telnet-related functions from src/ftp.c to
libsqftp/.
This isn't the best place for them! It'll suffice for now.
http://code.google.com/p/lusca-cache/source/detail?r=14676
Added:
/branches/LUSCA_HEAD/libsqftp/ftp_util.h
Modified:
/branches/LUSCA_HEAD/libsqftp/ftp_util.c
/branches/LUSCA_HEAD/src/ftp.c
=======================================
--- /dev/null
+++ /branches/LUSCA_HEAD/libsqftp/ftp_util.h Wed May 19 20:24:38 2010
@@ -0,0 +1,7 @@
+#ifndef __LUSCA_FTPUTIL_H__
+#define __LUSCA_FTPUTIL_H__
+
+extern char * escapeIAC(const char *buf);
+extern char * decodeTelnet(char *buf);
+
+#endif
=======================================
--- /branches/LUSCA_HEAD/libsqftp/ftp_util.c Wed May 19 20:20:46 2010
+++ /branches/LUSCA_HEAD/libsqftp/ftp_util.c Wed May 19 20:24:38 2010
@@ -0,0 +1,45 @@
+#include "../include/config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#include <assert.h>
+
+#include "../include/util.h"
+
+/* escapes any IAC (0xFF) characters. Returns a new string */
+char *
+escapeIAC(const char *buf)
+{
+ int n;
+ char *ret;
+ unsigned const char *p;
+ unsigned char *r;
+ for (p = (unsigned const char *) buf, n = 1; *p; n++, p++)
+ if (*p == 255)
+ n++;
+ ret = xmalloc(n);
+ for (p = (unsigned const char *) buf, r = (unsigned char *) ret; *p;
p++) {
+ *r++ = *p;
+ if (*p == 255)
+ *r++ = 255;
+ }
+ *r++ = '\0';
+ assert((r - (unsigned char *) ret) == n);
+ return ret;
+}
+
+/* removes any telnet options. Same string returned */
+char *
+decodeTelnet(char *buf)
+{
+ char *p = buf;
+ while ((p = strstr(p, "\377\377")) != NULL) {
+ p++;
+ memmove(p, p + 1, strlen(p + 1) + 1);
+ }
+ return buf;
+}
+
=======================================
--- /branches/LUSCA_HEAD/src/ftp.c Mon Feb 2 11:49:00 2009
+++ /branches/LUSCA_HEAD/src/ftp.c Wed May 19 20:24:38 2010
@@ -35,6 +35,8 @@
#include "squid.h"
+#include "../libsqftp/ftp_util.h"
+
static const char *const crlf = "\r\n";
static char cbuf[1024];
@@ -1164,40 +1166,6 @@
}
/* ======================================================================
*/
-
-/* escapes any IAC (0xFF) characters. Returns a new string */
-static char *
-escapeIAC(const char *buf)
-{
- int n;
- char *ret;
- unsigned const char *p;
- unsigned char *r;
- for (p = (unsigned const char *) buf, n = 1; *p; n++, p++)
- if (*p == 255)
- n++;
- ret = xmalloc(n);
- for (p = (unsigned const char *) buf, r = (unsigned char *) ret; *p;
p++) {
- *r++ = *p;
- if (*p == 255)
- *r++ = 255;
- }
- *r++ = '\0';
- assert((r - (unsigned char *) ret) == n);
- return ret;
-}
-
-/* removes any telnet options. Same string returned */
-static char *
-decodeTelnet(char *buf)
-{
- char *p = buf;
- while ((p = strstr(p, "\377\377")) != NULL) {
- p++;
- memmove(p, p + 1, strlen(p + 1) + 1);
- }
- return buf;
-}
static void
ftpWriteCommand(const char *buf, FtpStateData * ftpState)
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.