summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <>2014-11-02 13:30:25 +0000
committerroot <>2014-11-02 13:30:25 +0000
commit435e606775643af093145dc005cd4703aaaaefdb (patch)
tree1a9482014f8881e6b44a1d9a0eb8aa0568d72f74
parent23b92637bd8f1ec197a3bca1fca9ac638172c55d (diff)
downloadnca-435e606775643af093145dc005cd4703aaaaefdb.tar.gz
nca-435e606775643af093145dc005cd4703aaaaefdb.tar.bz2
nca-435e606775643af093145dc005cd4703aaaaefdb.zip
-rw-r--r--nca.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/nca.c b/nca.c
index f469b9e..eb17095 100644
--- a/nca.c
+++ b/nca.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.2 2014/11/02 13:30:25 root
+ * fish
+ *
* Revision 1.1 2006/03/18 11:38:27 root
* *** empty log message ***
*
@@ -33,7 +36,7 @@ static char rcsid[] = "$Id$";
*
* Revision 1.2 2002/11/17 14:24:45 root
* *** empty log message ***
- *
+
* Revision 1.1 2002/11/17 14:24:34 root
* Initial revision
*
@@ -51,6 +54,7 @@ static char rcsid[] = "$Id$";
#include <errno.h>
#include <syscall.h>
#include <endian.h>
+#include <string.h>
#define ESCAPE '\001'
@@ -83,6 +87,7 @@ do_moan (int ret, char *what, int where)
snprintf (buf, sizeof (buf) - 1,
__FILE__ ", line %d: %s == %d (err=%d:%s)\n\r\n\r",
where, what, ret, errno,strerror (errno));
+ write (1, buf, strlen (buf));
write (2, buf, strlen (buf));
sleep (2);
}
@@ -92,11 +97,33 @@ do_moan (int ret, char *what, int where)
+void do_write(int fd,void *ptr,size_t len)
+{
+int writ;
+
+#if 0
+while (len) {
+writ=len;
+writ=write(fd,ptr,writ );
+if (write<=0) {
+perror("write");
+usleep(10000);
+} else {
+ptr+=writ;
+len-=writ;
+}
+
+}
+#else
+fwrite(ptr,1,len,stdout);
+#endif
+}
+
void
writestr (int fd, char *s)
{
- MOAN (write (fd, s, strlen (s)));
+ do_write (fd, s, strlen (s));
}
void
@@ -172,6 +199,7 @@ put_char (unsigned char *c, int a)
static int cf = -1;
static int cb = -1;
static int ch = -1;
+ unsigned char d=*c;
if (ca != a)
{
@@ -192,7 +220,9 @@ put_char (unsigned char *c, int a)
writestr (1, buf);
}
- MOAN (write (1, c, 1));
+
+ if ((d<32) ||( d>126)) d=' ';
+ do_write (1, &d, 1);
}
@@ -209,7 +239,7 @@ cls (void)
{
moveto (0, 0);
put_char (" ", 0x7);
- MOAN (write (1, "\033[2J", 4));
+ do_write (1, "\033[2J", 4);
moveto (0, 0);
}
@@ -219,6 +249,7 @@ update_output (State old, State new)
{
int x, y, cx, cy;
unsigned char *nrptr = new->data;
+ int changed=0;
if ((old->w != new->w) || (old->h != new->h))
{
@@ -234,6 +265,7 @@ update_output (State old, State new)
#else
put_char (nptr, *(nptr + 1));
#endif
+ changed++;
nptr += 2;
}
@@ -276,6 +308,8 @@ update_output (State old, State new)
#endif
cx++;
+ changed++;
+
}
nptr += 2;
@@ -285,7 +319,13 @@ update_output (State old, State new)
orptr += 2 * old->w;
}
}
+
+if ((new->x != old->x) ||( new->y!=old->y)) {
moveto (new->x, new->y);
+ changed++;
+}
+
+if (changed) fflush(stdout);
}
void
@@ -346,13 +386,13 @@ do_escape (void)
case 's':
MOAN(tcsetattr (0, TCSANOW, &oldtios));
- MOAN(write (1, "\033[m\033[2J", 7));
+ do_write (1, "\033[m\033[2J", 7);
moveto (0, 0);
- MOAN (execl ("/bin/sh", "-", (char *) 0));
+ MOAN (execl ("/bin/sh", "sh", (char *) 0));
break;
case 'q':
MOAN(tcsetattr (0, TCSANOW, &oldtios));
- MOAN(write (1, "\033[m\033[2J", 7));
+ do_write (1, "\033[m\033[2J", 7);
moveto (0, 0);
exit (0);
}