/[anubis]/anubis/src/exec.c
ViewVC logotype

Diff of /anubis/src/exec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by gray, Fri Feb 7 22:59:57 2003 UTC revision 1.4 by gray, Thu Mar 6 18:34:54 2003 UTC
# Line 190  make_local_connection(char *exec_path, c Line 190  make_local_connection(char *exec_path, c
190  char *  char *
191  external_program(int *rs, char *path, char *src, char *dst, int dstsize)  external_program(int *rs, char *path, char *src, char *dst, int dstsize)
192  {  {
193          int status;          char *ret;
         int fd;  
         int n;  
194          char tmp[LINEBUFFER+1];          char tmp[LINEBUFFER+1];
         char *buf = 0;  
195          char **args = 0;          char **args = 0;
196          char *a = 0; /* args */          char *a = 0; /* args */
197          char *p = 0; /* path */          char *p = 0; /* path */
# Line 219  external_program(int *rs, char *path, ch Line 216  external_program(int *rs, char *path, ch
216                  else                  else
217                          a = path;                          a = path;
218          }          }
219            
220          args = gen_execargs(a);          args = gen_execargs(a);
221          fd = make_local_connection(p, args);          ret = exec_argv(rs, args, src, dst, dstsize);
222          xfree_pptr(args);          xfree_pptr(args);
223            return ret;
224    }
225    
226    char *
227    exec_argv(int *rs, char **argv, char *src, char *dst, int dstsize)
228    {
229            int status;
230            int fd;
231            int n;
232            char *buf;
233            
234            fd = make_local_connection(argv[0], argv);
235          if (fd == -1) {          if (fd == -1) {
236                  *rs = -1;                  *rs = -1;
237                  return 0;                  return 0;
# Line 241  external_program(int *rs, char *path, ch Line 250  external_program(int *rs, char *path, ch
250          memset(dst, 0, dstsize);          memset(dst, 0, dstsize);
251    
252          if (dst && dstsize) { /* static array */          if (dst && dstsize) { /* static array */
253                  while ((n = read(fd, buf, DATABUFFER)) > 0)                  while ((n = read(fd, buf, DATABUFFER)) > 0) {
                 {  
254                          strncat(dst, buf, dstsize);                          strncat(dst, buf, dstsize);
255                          memset(buf, 0, DATABUFFER + 1);                          memset(buf, 0, DATABUFFER + 1);
256                          dstsize -= n;                          dstsize -= n;
257                          if (dstsize < 1)                          if (dstsize < 1)
258                                  break;                                  break;
259                  }                  }
260          }          } else { /* dynamic array */
         else { /* dynamic array */  
261                  dst = (char *)xmalloc(1);                  dst = (char *)xmalloc(1);
262                  while ((n = read(fd, buf, DATABUFFER)) > 0)                  while ((n = read(fd, buf, DATABUFFER)) > 0) {
263                  {                          dst = xrealloc(dst, strlen(dst) + n + 1);
                         dst = (char *)xrealloc((char *)dst, strlen(dst) + n + 1);  
264                          strncat(dst, buf, n);                          strncat(dst, buf, n);
265                          memset(buf, 0, DATABUFFER + 1);                          memset(buf, 0, DATABUFFER + 1);
266                  }                  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26