You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2010/01/16 09:04:21 UTC

svn commit: r899896 - in /commons/sandbox/runtime/trunk/src/main/native: configure include/acr_sbuf.h os/unix/exec.c shared/sbuf.c test/testsuite.c

Author: mturk
Date: Sat Jan 16 08:04:19 2010
New Revision: 899896

URL: http://svn.apache.org/viewvc?rev=899896&view=rev
Log:
Add max to sbuf

Modified:
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
    commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=899896&r1=899895&r2=899896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Sat Jan 16 08:04:19 2010
@@ -1000,6 +1000,7 @@
     have_windows=1
     have_uuid_uuid=0
     have_off64t=0
+    have_openpty=0
 else
     have_ktmw32=0
     have_off64t=1
@@ -1018,6 +1019,8 @@
     fi
     ok=`have_library resolv res_init`
     test ".$ok" = .1 && varadds ldflags -lresolv
+    have_openpty=`have_library util openpty`
+    test ".$have_openpty" = .1 && varadds ldflags -lutil
 fi
 
 if [ ".$host" = ".linux" ]; then
@@ -1158,6 +1161,7 @@
 #define HAVE_SELINUX_H        $have_selinux
 #define HAVE_PORT_H           $have_port
 #define HAVE_SQLITE3          $have_sqlite3
+#define HAVE_OPENPTY          $have_openpty
 
 #define HAVE_UNISTD_H         `have_include x unistd`
 #define HAVE_STRING_H         `have_include w string`
@@ -1192,6 +1196,8 @@
 #define HAVE_RESOLV_H         `have_include x resolv`
 #define HAVE_SYS_UN_H         `have_include x sys/un`
 #define HAVE_UCONTEXT_H       `have_include x ucontext`
+#define HAVE_PTY_H            `have_include x pty`
+#define HAVE_UTIL_H           `have_include x util`
 #define HAVE_WCSCASECMP       `have_function w wcscasecmp`
 #define HAVE_STRERROR_R       `have_function x strerror_r`
 #define HAVE_MMAP64           `have_function x mmap64`
@@ -1208,6 +1214,8 @@
 #define HAVE_SIGACTION        `have_function x sigaction`
 #define HAVE_FDWALK           `have_function x fdwalk`
 #define HAVE_SETRLIMIT        `have_function x setrlimit`
+#define HAVE_GRANTPT          `have_function x grantpt`
+#define HAVE_POSIX_OPENPT     `have_function x posix_openpt`
 #define HAVE_DUP3             `have_function c dup3`
 #define HAVE_EPOLL_CREATE1    `have_function c epoll_create1`
 #define HAVE_ACCEPT4          `have_function c accept4`

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h?rev=899896&r1=899895&r2=899896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_sbuf.h Sat Jan 16 08:04:19 2010
@@ -69,6 +69,7 @@
     char            *s_buf;     /* storage buffer */
     size_t           s_size;    /* size of storage buffer */
     size_t           s_len;     /* current length of string */
+    size_t           s_max;     /* maximum storage size */
     int              s_flags;   /* flags */
 };
 
@@ -78,6 +79,7 @@
     wchar_t         *s_buf;     /* storage buffer */
     size_t           s_size;    /* size of storage buffer */
     size_t           s_len;     /* current length of string */
+    size_t           s_max;     /* maximum storage size */
     int              s_flags;   /* flags */
 };
 
@@ -90,6 +92,7 @@
 int      acr_sbuf_init(acr_sbuf_t *, char *, size_t);
 void     acr_sbuf_clear(acr_sbuf_t *);
 int      acr_sbuf_setpos(acr_sbuf_t *, size_t);
+int      acr_sbuf_setmax(acr_sbuf_t *, size_t);
 int      acr_sbuf_bcat(acr_sbuf_t *, const void *, size_t);
 int      acr_sbuf_bcpy(acr_sbuf_t *, const void *, size_t);
 int      acr_sbuf_cat(acr_sbuf_t *, const char *);
@@ -115,6 +118,7 @@
 int      acr_wbuf_init(acr_wbuf_t *, wchar_t *, size_t);
 void     acr_wbuf_clear(acr_wbuf_t *);
 int      acr_wbuf_setpos(acr_wbuf_t *, size_t);
+int      acr_wbuf_setmax(acr_wbuf_t *, size_t);
 int      acr_wbuf_bcat(acr_wbuf_t *, const void *, size_t);
 int      acr_wbuf_bcpy(acr_wbuf_t *, const void *, size_t);
 int      acr_wbuf_cat(acr_wbuf_t *, const wchar_t *);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=899896&r1=899895&r2=899896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Sat Jan 16 08:04:19 2010
@@ -442,7 +442,7 @@
         while (pipelining) {
             npipes = 0;
             if (pipes[PIPE_STDINP_WRS] != -1) {
-                ps[npipes].fd = pipes[PIPE_STDOUT_WRS];
+                ps[npipes].fd = pipes[PIPE_STDINP_WRS];
                 ps[npipes].events  = POLLOUT;
                 ps[npipes].revents = 0;
                 npipes++;
@@ -499,8 +499,11 @@
                         char   buf[512];
 
                         rd = r_read(pipes[PIPE_STDOUT_RDS], buf, sizeof(buf));
-                        if (rd > 0)
+                        if (rd > 0) {
+                            /* TODO: Check for overflow
+                             */
                             acr_sbuf_bcat(&ep->sout, buf, rd);
+                        }
                         else
                             i_close(&pipes[PIPE_STDOUT_RDS]);
                     }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c?rev=899896&r1=899895&r2=899896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c Sat Jan 16 08:04:19 2010
@@ -99,6 +99,8 @@
         return -1;
 
     newsize = acr_sbuf_extendsize(s->s_size + addlen);
+    if (s->s_max > newsize)
+        return -1;
     newbuf  = x_malloc(newsize);
     if (newbuf == NULL)
         return -1;
@@ -206,6 +208,21 @@
 }
 
 /*
+ * Set the sbuf's maximum size.
+ */
+int
+acr_sbuf_setmax(acr_sbuf_t *s, size_t len)
+{
+
+    if (len < s->s_size) {
+        ACR_SET_OS_ERROR(ACR_EINVAL);
+        return -1;
+    }
+    s->s_max = len;
+    return 0;
+}
+
+/*
  * Append a byte string to an sbuf.
  */
 int
@@ -536,6 +553,8 @@
         return -1;
 
     newsize = acr_sbuf_extendsize(s->s_size + addlen);
+    if (s->s_max > newsize)
+        return -1;
     newbuf  = x_malloc(newsize * sizeof(wchar_t));
     if (newbuf == NULL)
         return -1;
@@ -643,6 +662,21 @@
 }
 
 /*
+ * Set the sbuf's maximum size.
+ */
+int
+acr_wbuf_setmax(acr_wbuf_t *s, size_t len)
+{
+
+    if (len < s->s_size) {
+        ACR_SET_OS_ERROR(ACR_EINVAL);
+        return -1;
+    }
+    s->s_max = len;
+    return 0;
+}
+
+/*
  * Append a byte string to an sbuf.
  */
 int

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=899896&r1=899895&r2=899896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sat Jan 16 08:04:19 2010
@@ -690,7 +690,7 @@
 #if defined(WIN32)
     rc = ACR_ExecSubproc(exe, NULL, wargv[0], &wargv[1], NULL);
 #else
-    rc = ACR_ExecSubproc(exe, NULL, argv[0], &argv[1], NULL);
+    rc = ACR_ExecProgram(exe, argv[0], &argv[1], NULL);
 #endif
     fprintf(stdout, "[STDOUT]:\n%s", ACR_ExecStream(exe, 1));
     fprintf(stdout, "[STDERR]:\n%s", ACR_ExecStream(exe, 2));