aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-04 18:13:31 -0800
committerH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-04 18:13:31 -0800
commit88ead2b6e4144749ef0e1f761dfdde3c4b16fa7f (patch)
treecd05cecee3dfeb3df47ffc6dfd1e77b2d632910d
parent4dd5eb6a3221c2c94d96b9e22caf0e73b4dc67df (diff)
downloadabc80-88ead2b6e4144749ef0e1f761dfdde3c4b16fa7f.tar.gz
abc80-88ead2b6e4144749ef0e1f761dfdde3c4b16fa7f.tar.xz
abc80-88ead2b6e4144749ef0e1f761dfdde3c4b16fa7f.zip
abcprintd: fix fileop state machine; add debugging printfs
Fix the fileop state machine. Disable daemonizing and add some debugging printfs for the moment.
-rw-r--r--tools/abcprintd.c4
-rw-r--r--tools/fileop.c19
2 files changed, 16 insertions, 7 deletions
diff --git a/tools/abcprintd.c b/tools/abcprintd.c
index 5925e55..15ff502 100644
--- a/tools/abcprintd.c
+++ b/tools/abcprintd.c
@@ -232,7 +232,9 @@ int main(int argc, char *argv[])
memcpy(lpr_argv, argv+optind+1, sizeof(char *)*(lpr_argc+1));
}
- daemon(0,0);
+ fprintf(stderr, "filedir = %s\n", file_op_dir);
+
+ // daemon(0,0);
print_setup(&tf, &ps);
diff --git a/tools/fileop.c b/tools/fileop.c
index cce13df..ccb3b13 100644
--- a/tools/fileop.c
+++ b/tools/fileop.c
@@ -1,3 +1,4 @@
+#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
@@ -110,7 +111,7 @@ static const char my_tolower[256] =
static void do_open(int fd, uint16_t ix, char *name)
{
- char *path, *p;
+ char *path, *p, *p0;
int opl;
int i;
bool nodot;
@@ -131,12 +132,14 @@ static void do_open(int fd, uint16_t ix, char *name)
path = alloca(opl+14);
memcpy(path, file_op_dir, opl);
p = path+opl;
- *p++ = '/';
+ if (p[-1] != '/')
+ *p++ = '/';
nodot = true;
+ p0 = p;
for (i = 0; i < 11; i++) {
if (name[i] != ' ') {
- if (i >= 8 && !nodot) {
+ if (i >= 8 && nodot) {
*p++ = '.';
nodot = false;
}
@@ -144,11 +147,14 @@ static void do_open(int fd, uint16_t ix, char *name)
}
}
- if (p == path+opl+1) {
+ if (p == p0) {
/* Empty filename */
send_reply(fd, 128+21); /* File not found */
return;
}
+ *p = '\0';
+
+ fprintf(stderr, "open %s mode %s\n", path, modes[cmd[0] & 3]);
fm = calloc(1, sizeof(struct file_info *));
if (!fm) {
@@ -337,6 +343,8 @@ bool file_op(unsigned char c, int fd)
static unsigned char lenbuf[2];
uint16_t ix, len;
+ fprintf(stderr, "<%02X %c>\n", c, isprint(c) ? c : '.');
+
*bytep++ = c;
if (--byte_count)
return true; /* More to do... */
@@ -416,7 +424,6 @@ bool file_op(unsigned char c, int fd)
/* unless otherwise specified, back to command mode */
bytep = cmd;
byte_count = 4;
+ state = st_op;
return false;
}
-
-