summaryrefslogtreecommitdiff
path: root/sys/src/cmd/abaco
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-07-14 18:37:10 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-07-14 18:37:10 +0200
commita7a90b2f3c8ac762e92753970b5a2daa6746a68b (patch)
tree2278530d81701a9f30a56924e76d5cc9feab4e33 /sys/src/cmd/abaco
parent1bc8f697807a8c93bc0903cb6c9879a4b33ea1d3 (diff)
abaco: remove unused stuff, move pipeline() into util.c
Diffstat (limited to 'sys/src/cmd/abaco')
-rw-r--r--sys/src/cmd/abaco/fns.h2
-rw-r--r--sys/src/cmd/abaco/page.c34
-rw-r--r--sys/src/cmd/abaco/util.c92
3 files changed, 12 insertions, 116 deletions
diff --git a/sys/src/cmd/abaco/fns.h b/sys/src/cmd/abaco/fns.h
index 776d156a0..66563d465 100644
--- a/sys/src/cmd/abaco/fns.h
+++ b/sys/src/cmd/abaco/fns.h
@@ -66,7 +66,7 @@ int forceitem(Item *);
int xtofchar(Rune *, Font *, long);
int istextsel(Page *, Rectangle, int *, int *, Rune *, Font *);
int findctype(char *, int, char *, char *);
-void execproc(void *);
+int pipeline(int fd, char *cmd, ...);
void getimage(Cimage *, Rune *);
Point getpt(Page *p, Point);
Rune *urlcombine(Rune *, Rune *);
diff --git a/sys/src/cmd/abaco/page.c b/sys/src/cmd/abaco/page.c
index 200419ee2..43a356a59 100644
--- a/sys/src/cmd/abaco/page.c
+++ b/sys/src/cmd/abaco/page.c
@@ -147,40 +147,6 @@ closeimages(Page *p)
}
static
-int
-pipeline(int fd, char *cmd, ...)
-{
- Channel *sync;
- Exec *e;
- int p[2], q[2];
- va_list a;
-
- if(pipe(p)<0 || pipe(q)<0)
- error("can't create pipe");
- close(p[0]);
- p[0] = fd;
- sync = chancreate(sizeof(ulong), 0);
- if(sync == nil)
- error("can't create channel");
- e = emalloc(sizeof(Exec));
- e->p[0] = p[0];
- e->p[1] = p[1];
- e->q[0] = q[0];
- e->q[1] = q[1];
- va_start(a, cmd);
- e->cmd = vsmprint(cmd, a);
- va_end(a);
- e->sync = sync;
- proccreate(execproc, e, STACK);
- recvul(sync);
- chanfree(sync);
- close(p[0]);
- close(p[1]);
- close(q[1]);
- return q[0];
-}
-
-static
Cimage *
loadimg(Rune *src, int x , int y)
{
diff --git a/sys/src/cmd/abaco/util.c b/sys/src/cmd/abaco/util.c
index ecdb7c3ed..bb69f1947 100644
--- a/sys/src/cmd/abaco/util.c
+++ b/sys/src/cmd/abaco/util.c
@@ -655,7 +655,7 @@ validurl(Rune *r)
return TRUE;
}
-void
+static void
execproc(void *v)
{
Channel *sync;
@@ -687,107 +687,37 @@ execproc(void *v)
error("can't exec");
}
-static void
-writeproc(void *v)
-{
- Channel *sync;
- void **a;
- char *s;
- long np;
- int fd, i, n;
-
- threadsetname("writeproc");
- a = v;
- sync = a[0];
- fd = (int)a[1];
- s = a[2];
- np =(long)a[3];
- free(a);
-
- for(i=0; i<np; i+=n){
- n = np-i;
- if(n > BUFSIZE)
- n = BUFSIZE;
- if(write(fd, s+i, n) != n)
- break;
- }
- close(fd);
- sendul(sync, i);
-}
-
-char *
-uhtml(char *cs, char *s, long *np)
+int
+pipeline(int fd, char *cmd, ...)
{
Channel *sync;
Exec *e;
- long i, n;
- void **a;
- char buf[BUFSIZE], cmd[50];
- char *t;
int p[2], q[2];
-
- if(s==nil || *s=='\0' || *np==0){
- werrstr("uhtml failed: no data");
- return s;
- }
+ va_list a;
if(pipe(p)<0 || pipe(q)<0)
error("can't create pipe");
-
+ close(p[0]);
+ p[0] = fd;
sync = chancreate(sizeof(ulong), 0);
if(sync == nil)
error("can't create channel");
-
- snprint(cmd, sizeof cmd, (cs != nil && *cs != '\0') ? "uhtml -c %s" : "uthml", cs);
e = emalloc(sizeof(Exec));
e->p[0] = p[0];
e->p[1] = p[1];
e->q[0] = q[0];
e->q[1] = q[1];
- e->cmd = cmd;
+ va_start(a, cmd);
+ e->cmd = vsmprint(cmd, a);
+ va_end(a);
e->sync = sync;
proccreate(execproc, e, STACK);
recvul(sync);
chanfree(sync);
close(p[0]);
+ close(p[1]);
close(q[1]);
-
- /* in case uhtml fails */
- t = s;
- sync = chancreate(sizeof(ulong), 0);
- if(sync == nil)
- error("can't create channel");
-
- a = emalloc(4*sizeof(void *));
- a[0] = sync;
- a[1] = (void *)p[1];
- a[2] = s;
- a[3] = (void *)*np;
- proccreate(writeproc, a, STACK);
-
- i = 0;
- s = nil;
- while((n = read(q[0], buf, sizeof(buf))) > 0){
- s = erealloc(s, i+n+1);
- memmove(s+i, buf, n);
- i += n;
- s[i] = '\0';
- }
- n = recvul(sync);
- if(n != *np)
- fprint(2, "uhtml failed: did not write %ld; wrote %uld\n", *np, n);
-
- *np = i;
- chanfree(sync);
- close(q[0]);
-
- if(s == nil){
- fprint(2, "uhtml failed: can't convert charset=%s\n", cs);
- return t;
- }
- free(t);
-
- return s;
+ return q[0];
}
static