Introduction
Introduction Statistics Contact Development Disclaimer Help
Use dprintf in favor of fprint (simplifies things). - sam - An updated version …
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit ec84c62a4e5e7aba660c0d9ecec6c991e3c40f23
parent f93ac2f46c3330c20f6d2bd79d46464620ea8165
Author: Rob King <[email protected]>
Date: Tue, 6 Sep 2016 12:31:30 -0500
Use dprintf in favor of fprint (simplifies things).
Diffstat:
include/libc.h | 1 -
libframe/misc.c | 12 ------------
sam/io.c | 4 ++--
sam/mesg.c | 4 ++--
sam/rasp.c | 2 +-
sam/sam.c | 8 ++++----
sam/shell.c | 2 +-
sam/sys.c | 2 +-
samterm/main.c | 2 +-
samterm/mesg.c | 9 +++------
samterm/unix.c | 6 +++---
11 files changed, 18 insertions(+), 34 deletions(-)
---
diff --git a/include/libc.h b/include/libc.h
@@ -47,7 +47,6 @@ extern char* utfutf(char*, char*);
/*
* Miscellaneous functions
*/
-extern void fprint(int, char *, ...);
extern int notify (void(*)(void *, char *));
extern int errstr(char *);
extern char* getuser(void);
diff --git a/libframe/misc.c b/libframe/misc.c
@@ -9,18 +9,6 @@
#endif
#include <errno.h>
-void
-fprint(int fd, char *z, ...)
-{
- va_list args;
- char buf[2048]; /* pick reasonable blocksize */
-
- va_start(args, z);
- vsprintf(buf, z, args);
- write(fd, buf, strlen(buf));
- va_end(args);
-}
-
int errstr(char *buf)
{
diff --git a/sam/io.c b/sam/io.c
@@ -183,7 +183,7 @@ bootterm(char *machine, char **argv, char **end)
argv[0] = "samterm";
*end = 0;
execvp(samterm, argv);
- fprint(2, "can't exec: ");
+ fprintf(stderr, "can't exec: ");
perror(samterm);
_exits("damn");
}
@@ -200,7 +200,7 @@ bootterm(char *machine, char **argv, char **end)
argv[0] = "samterm";
*end = 0;
execvp(samterm, argv);
- fprint(2, "can't exec: ");
+ fprintf(stderr, "can't exec: ");
perror(samterm);
_exits("damn");
case -1:
diff --git a/sam/mesg.c b/sam/mesg.c
@@ -89,7 +89,7 @@ journal(int out, char *s)
if(fd <= 0)
fd = create("/tmp/sam.out", 1, 0666L);
- fprint(fd, "%s%s\n", out? "out: " : "in: ", s);
+ dprintf(fd, "%s%s\n", out? "out: " : "in: ", s);
}
void
@@ -199,7 +199,7 @@ inmesg(Tmesg type)
panic("rcv error");
default:
- fprint(2, "unknown type %d\n", type);
+ fprintf(stderr, "unknown type %d\n", type);
panic("rcv unknown");
case Tversion:
diff --git a/sam/rasp.c b/sam/rasp.c
@@ -34,7 +34,7 @@ toterminal(File *f, int toterm)
while(Bread(t, (Rune*)&hdr, sizeof(hdr)/RUNESIZE, p0) > 0){
switch(hdr.g.cs.c){
default:
- fprint(2, "char %c %.2x\n", hdr.g.cs.c, hdr.g.cs.c);
+ fprintf(stderr, "char %c %.2x\n", hdr.g.cs.c, hdr.g.cs…
panic("unknown in toterminal");
case 'd':
diff --git a/sam/sam.c b/sam/sam.c
@@ -149,7 +149,7 @@ rescue(void)
io = create(buf, 1, 0700);
if(io<0)
return;
- fprint(io, "samsave() {\n"
+ dprintf(io, "samsave() {\n"
" echo \"${1}?\"\n"
" read yn < /dev/tty\n"
" case \"${yn}\" in\n"
@@ -164,10 +164,10 @@ rescue(void)
free(c);
}else
sprint(buf, "nameless.%d", nblank++);
- fprint(io, "samsave %s <<'---%s'\n", buf, buf);
+ dprintf(io, "samsave %s <<'---%s'\n", buf, buf);
addr.r.p1 = 0, addr.r.p2 = f->nrunes;
writeio(f);
- fprint(io, "\n---%s\n", (char *)buf);
+ dprintf(io, "\n---%s\n", (char *)buf);
}
}
@@ -181,7 +181,7 @@ panic(char *s)
downloaded = 0;
dprint("sam: panic: %s\n", s);
if(wasd)
- fprint(2, "sam: panic: %s\n", s);
+ fprintf(stderr, "sam: panic: %s\n", s);
rescue();
abort();
}
diff --git a/sam/shell.c b/sam/shell.c
@@ -84,7 +84,7 @@ plan9(File *f, int type, String *s, int nest)
exits(retcode? "error" : 0);
}
if(pid==-1){
- fprint(2, "Can't fork?!\n");
+ fprintf(stderr, "Can't fork?!\n");
exits("fork");
}
dup(pipe2[0], 0);
diff --git a/sam/sys.c b/sam/sys.c
@@ -36,7 +36,7 @@ Read(int f, void *a, int n)
lastfile->state = Readerr;
errstr(buf);
if (downloaded)
- fprint(2, "read error: %s\n", buf);
+ fprintf(stderr, "read error: %s\n", buf);
rescue();
exits("read");
}
diff --git a/samterm/main.c b/samterm/main.c
@@ -945,7 +945,7 @@ outcmd(void)
void
panic(char *s)
{
- fprint(2, "samterm:panic: ");
+ fprintf(stderr, "samterm:panic: ");
perror(s);
abort();
}
diff --git a/samterm/mesg.c b/samterm/mesg.c
@@ -58,7 +58,7 @@ rcv(void)
state = 0;
continue;
}
- fprint(2, "type %d count %d\n", h.type, count);
+ fprintf(stderr, "type %d count %d\n", h.type, …
panic("count>DATASIZE");
}
if(count == 0)
@@ -98,7 +98,6 @@ inmesg(Hmesg type, int count)
int i, m;
long l, l2;
Flayer *lp;
- char syscmd[512];
m = inshort(0);
l = inlong(2);
@@ -106,7 +105,7 @@ inmesg(Hmesg type, int count)
case -1:
panic("rcv error");
default:
- fprint(2, "type %d\n", type);
+ fprintf(stderr, "type %d\n", type);
panic("rcv unknown");
case Hversion:
@@ -307,9 +306,7 @@ inmesg(Hmesg type, int count)
int fifofd = open(exname, O_WRONLY);
if (fifofd >= 0)
{
- memset(syscmd, 0, 512);
- snprintf(syscmd, 511, "%s", (char *)indata);
- write(fifofd, syscmd, 511);
+ dprintf(fifofd, "%511s", (char *)indata);
close(fifofd);
}
}
diff --git a/samterm/unix.c b/samterm/unix.c
@@ -52,13 +52,13 @@ dumperrmsg(int count, int type, int count0, int c)
int i;
cp = (uchar *) rcvstring();
- fprint(2, "samterm: host mesg: count %d %ux %ux %ux %s...ignored\n",
+ fprintf(stderr, "samterm: host mesg: count %d %ux %ux %ux %s...ignored…
count, type, count0, c, cp);
i = 0;
while (*cp) {
- fprint(2, "%x ", *cp);
+ fprintf(stderr, "%x ", *cp);
if (i++ >= 20) {
- fprint(2, "\n");
+ fprintf(stderr, "\n");
i = 0;
}
cp++;
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.