summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-08-01 13:06:24 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-08-01 13:06:24 +0200
commitb408b386e1b996a8b5e6041e68c1801547b4487e (patch)
tree9a94efe65fed50e2064320ade62772231ad79bbe /sys
parentd6fb42f496c6053598907ce2cbb0b6536a25d201 (diff)
mothra: cleanup url handling
Diffstat (limited to 'sys')
-rw-r--r--sys/src/cmd/mothra/getpix.c12
-rw-r--r--sys/src/cmd/mothra/mothra.c2
-rw-r--r--sys/src/cmd/mothra/mothra.h2
3 files changed, 9 insertions, 7 deletions
diff --git a/sys/src/cmd/mothra/getpix.c b/sys/src/cmd/mothra/getpix.c
index 4428959d5..0ab52afc5 100644
--- a/sys/src/cmd/mothra/getpix.c
+++ b/sys/src/cmd/mothra/getpix.c
@@ -25,24 +25,25 @@ char *pixcmd[]={
void getimage(Rtext *t, Www *w){
int pfd[2];
Action *ap;
- Url url;
+ Url *url;
Image *b;
int fd, typ;
char err[512], buf[80], *s;
Pix *p;
ap=t->user;
- seturl(&url, ap->image, w->url->fullname);
+ url=emalloc(sizeof(Url));
+ seturl(url, ap->image, w->url->fullname);
for(p=w->pix;p!=nil; p=p->next)
if(strcmp(ap->image, p->name)==0 && ap->width==p->width && ap->height==p->height){
t->b = p->b;
w->changed=1;
return;
}
- fd=urlget(&url, -1);
+ fd=urlget(url, -1);
if(fd==-1){
Err:
- snprint(err, sizeof(err), "[img: %s: %r]", url.reltext);
+ snprint(err, sizeof(err), "[img: %s: %r]", urlstr(url));
free(t->text);
t->text=strdup(err);
w->changed=1;
@@ -82,8 +83,7 @@ void getimage(Rtext *t, Www *w){
t->b=b;
w->changed=1;
Out:
- free(url.basename);
- free(url.reltext);
+ freeurl(url);
}
void getpix(Rtext *t, Www *w){
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c
index abb5750f0..b35c08a1b 100644
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -991,7 +991,7 @@ void geturl(char *urlname, int post, int plumb, int map){
selurl(urlname);
selection->map=map;
- message("getting %s", selection->reltext);
+ message("getting %s", urlstr(selection));
esetcursor(&patientcurs);
for(;;){
if((fd=urlget(selection, post)) < 0){
diff --git a/sys/src/cmd/mothra/mothra.h b/sys/src/cmd/mothra/mothra.h
index 80d79269c..0d4553cf8 100644
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -82,6 +82,7 @@ void plrdhtml(char *, int, Www *);
void plrdplain(char *, int, Www *);
void htmlerror(char *, int, char *, ...); /* user-supplied routine */
void seturl(Url *, char *, char *);
+void freeurl(Url *);
Url *selurl(char *);
void getpix(Rtext *, Www *);
ulong countpix(void *p);
@@ -99,6 +100,7 @@ int filetype(int, char *, int);
int snooptype(int);
void mkfieldpanel(Rtext *);
void geturl(char *, int, int, int);
+char *urlstr(Url *);
int urlpost(Url*, char*);
int urlget(Url*, int);
int urlresolve(Url *);