diff -c2 unused:source/fifolib382/version.doc version.doc *** unused:source/fifolib382/version.doc Wed Mar 27 08:47:26 1996 --- version.doc Wed Aug 28 21:38:57 1996 *************** *** 4,7 **** --- 4,10 ---- The next version shall be >=2.0 only and thus become smaller. + 38.3 + Introducing Ctrl-C/D/E/F and Ctrl-\ handling in cooked mode. + 38.2 Processed cooked input is no more ignored in raw mode. Cooked Common subdirectories: unused:source/fifolib382/bin and bin Common subdirectories: unused:source/fifolib382/clib and clib Only in : config.cache Only in : config.log Only in : config.status Common subdirectories: unused:source/fifolib382/fd and fd Only in : fifo-383.diffs Only in : fifo-handler Only in : fifo-handler-debug Only in : fifo-handler-debug.o diff -c2 unused:source/fifolib382/fifo-handler.c fifo-handler.c *** unused:source/fifolib382/fifo-handler.c Mon May 13 23:07:22 1996 --- fifo-handler.c Wed Aug 28 23:40:50 1996 *************** *** 42,45 **** --- 42,46 ---- void returnpacket(DosPacket *); static inline char not_console(char *, unsigned char); + static inline short line1_length(FHan *); void xprintf(char *, ...); FHan *OpenHandle(char *, char *, long, long); *************** *** 71,75 **** short Done; /* could be local, but DICE2.06 uses up a register */ ! const char verstring[] = "\0$VER: fifo-handler 38.2 (8.5.96)\r\n"; --- 72,76 ---- short Done; /* could be local, but DICE2.06 uses up a register */ ! const char verstring[] = "\0$VER: fifo-handler 38.3 (28.8.96)\r\n"; *************** *** 132,135 **** --- 133,152 ---- } + static inline short + line1_length(FHan *han) + { + short m = 0; + short n = han->ff_CookIdx; + if (n != 0) { + --n; + do { char c = han->ff_CookBuf[m]; + if (c == CHAR_EOF) return m; + m++; + if (c == '\n') return m; + } while (--n != -1); /* make GCC generate dbra */ + } + return -1; + } + #if !defined(__GNUC__) __stkargs int /* changed from void (jch) */ *************** *** 386,425 **** han->ff_Flags &= ~FHF_STARTCOOK; /* restarted below */ ! if (han->ff_CookBuf && han->ff_CookIdx) { ! n = strlen(han->ff_CookBuf); ! /* read processed cooked input even in raw mode */ ! if (!(han->ff_Flags & FHF_COOKED) ! || n != han->ff_CookIdx /* || han->ff_LRet superfluous */) { ! short add1 = (han->ff_Flags & FHF_COOKED || n != han->ff_CookIdx) ! ? n++ : -1; /* add the newline character */ ! ! D(ebug("Can read %ld chars\n", n)); ! if (n > packet->dp_Arg3) ! n = packet->dp_Arg3; ! else if (add1 >= 0) ! han->ff_CookBuf[add1] = '\n'; ! ! memmove((void *)packet->dp_Arg2, han->ff_CookBuf, n); ! han->ff_CookIdx -= n; ! /* overlapping memory! */ ! memmove(han->ff_CookBuf, han->ff_CookBuf + n, han->ff_CookIdx + 1); ! if (han->ff_CookIdx == 0) ! han->ff_LRet = 0; ! packet->dp_Res1 = n; /* ! * if we blocked on reading the fifo to cook more ! * data, we unblock it here. */ ! han->ff_Flags &= ~FHF_COOKBFUL; ! if (han->ff_Flags & FHF_COOKED && ! !(han->ff_Flags & FHF_RPEND)) { ! RequestFifo(han->ff_FifoR, &han->ff_RdMsg, FREQ_RPEND); ! han->ff_Flags |= FHF_RPEND; ! } ! break; } } if (!(han->ff_Flags & FHF_COOKED)) { --- 403,455 ---- han->ff_Flags &= ~FHF_STARTCOOK; /* restarted below */ ! if (han->ff_CookBuf ! && ((han->ff_Flags & FHF_COOKED) ! ? (0 <= han->ff_CookLen1) ! : han->ff_CookIdx)) { ! /* ! * cooked input is available ! * do not read too much in raw mode, a line at a time ! * this code will fail for dp_Arg3 (# to read) == 0 in raw mode ! */ + n = han->ff_CookLen1; /* 0 means EOF */ + D(ebug("Can read %ld chars\n", n)); + if (n > packet->dp_Arg3) + n = packet->dp_Arg3; + { + long m = n; /* ! * CON: sends EOF in raw mode for a cooked EOF read ! * I choose to transmit ctrl-\ because FIFO: is ! * likely to receive pre-"typed", non-manual input */ + if (m == 0 && !(han->ff_Flags & FHF_COOKED)) m = 1; ! packet->dp_Res1 = m; ! memmove((void *)packet->dp_Arg2, han->ff_CookBuf, m); ! } ! if (n == 0) n = 1; /* skip EOF marker */ ! han->ff_CookIdx -= n; ! /* overlapping memory! */ ! memmove(han->ff_CookBuf, han->ff_CookBuf + n, han->ff_CookIdx); ! if (n < han->ff_CookLen1) { ! han->ff_CookLen1 -= n; ! } else { ! han->ff_CookLen1 = line1_length(han); ! } ! /* ! * if we blocked on reading the fifo to cook more ! * data, we unblock it here. ! */ ! ! han->ff_Flags &= ~FHF_COOKBFUL; ! ! if (han->ff_Flags & FHF_COOKED && ! !(han->ff_Flags & FHF_RPEND)) { ! RequestFifo(han->ff_FifoR, &han->ff_RdMsg, FREQ_RPEND); ! han->ff_Flags |= FHF_RPEND; } + break; } if (!(han->ff_Flags & FHF_COOKED)) { *************** *** 434,439 **** } if (n > 0) { ! /* Hans Verkuil introduced a patch to only read upto \n, ! * however RAW: does not exhibit this behaviour. */ if (n > packet->dp_Arg3) --- 464,469 ---- } if (n > 0) { ! /* Hans Verkuil introduced a patch to only read upto \n, ! * however RAW: does not exhibit this behaviour. */ if (n > packet->dp_Arg3) *************** *** 440,443 **** --- 470,475 ---- n = packet->dp_Arg3; CopyMem(ptr, (void *)packet->dp_Arg2, n); + packet->dp_Res1 = n; + if (ReadFifo(han->ff_FifoR, &ptr, n) < 0) han->ff_Flags |= FHF_REOF; *************** *** 448,452 **** * unblocking from a full buffer. */ - packet->dp_Res1 = n; break; } --- 480,483 ---- *************** *** 487,491 **** } - /* * check for output stopped due to pending input line --- 518,521 ---- *************** *** 495,499 **** */ ! if ((han->ff_Flags & FHF_COOKED) && han->ff_CookIdx && han->ff_LRet == 0) { packet->dp_Arg3 = -packet->dp_Arg3; AddTail((MaxList *)&han->ff_WrWait, &packet->dp_Link->mn_Node); --- 525,529 ---- */ ! if ((han->ff_Flags & FHF_COOKED) && (han->ff_Flags & FHF_WISTOP)) { packet->dp_Arg3 = -packet->dp_Arg3; AddTail((MaxList *)&han->ff_WrWait, &packet->dp_Link->mn_Node); *************** *** 503,507 **** } - /* * limit size of writes to fifo to something the fifo can --- 533,536 ---- *************** *** 633,637 **** } if (han->ff_Flags & FHF_COOKED) { ! if (han->ff_LRet || strlen(han->ff_CookBuf) != han->ff_CookIdx) { packet->dp_Res1 = DOS_TRUE; break; --- 662,666 ---- } if (han->ff_Flags & FHF_COOKED) { ! if (0 <= han->ff_CookLen1) { packet->dp_Res1 = DOS_TRUE; break; *************** *** 676,680 **** packet->dp_Type = ACTION_WAIT_CHAR; if (((WaitTreq *)packet->dp_Res1)->wt_packet) { ! /* input is available */ struct IORequest *ior = (struct IORequest *)packet->dp_Res1; --- 705,709 ---- packet->dp_Type = ACTION_WAIT_CHAR; if (((WaitTreq *)packet->dp_Res1)->wt_packet) { ! /* input is available */ struct IORequest *ior = (struct IORequest *)packet->dp_Res1; *************** *** 698,703 **** break; case FACTION_SCREEN_MODE: /* Mode Bool:TRUE */ ! /* As ACTION_SCREEN_MODE does not give a filehandle, we get it ! * indirectly through the special port. Fold packet type for safety. */ packet->dp_Type = ACTION_SCREEN_MODE; --- 727,732 ---- break; case FACTION_SCREEN_MODE: /* Mode Bool:TRUE */ ! /* As ACTION_SCREEN_MODE does not give a filehandle, we get it ! * indirectly through the special port. Fold packet type for safety. */ packet->dp_Type = ACTION_SCREEN_MODE; *************** *** 708,716 **** if (han->ff_CookBuf == NULL) { /* also NULL when !FHF_READ */ ! /* Normally a shell uses cooked mode and programs might ! * also set cooked mode at exit. Thus if the ! * application did not open FIFO: in cooked mode, it ! * had good reasons to do so and we refuse any change. ! * At least this is good for GNUEmacs (uses "rwesK"). */ packet->dp_Res2 = ERROR_OBJECT_WRONG_TYPE; --- 737,745 ---- if (han->ff_CookBuf == NULL) { /* also NULL when !FHF_READ */ ! /* Normally a shell uses cooked mode and programs might ! * also set cooked mode at exit. Thus if the ! * application did not open FIFO: in cooked mode, it ! * had good reasons to do so and we refuse any change. ! * At least this is good for GNUEmacs (uses "rwesK"). */ packet->dp_Res2 = ERROR_OBJECT_WRONG_TYPE; *************** *** 721,725 **** if (DOSFALSE != packet->dp_Arg1) { /* RAW */ if (han->ff_Flags & FHF_COOKED) { ! han->ff_Flags &= ~(FHF_COOKED|FHF_STARTCOOK|FHF_WIHOLD|FHF_COOKECHOBLK /*|FHF_COOKBFUL --still full */); /* cooked input is available, unblock readers and timers */ --- 750,758 ---- if (DOSFALSE != packet->dp_Arg1) { /* RAW */ if (han->ff_Flags & FHF_COOKED) { ! /* ! * this differs from CON: which unblocks neither ! * readers nor writers until the next character is read ! */ ! han->ff_Flags &= ~(FHF_COOKED|FHF_STARTCOOK|FHF_WIHOLD|FHF_WISTOP|FHF_COOKECHOBLK /*|FHF_COOKBFUL --still full */); /* cooked input is available, unblock readers and timers */ *************** *** 857,860 **** --- 890,894 ---- if (NULL == (han->ff_CookBuf = AllocMem(CB_SIZE, MEMF_CLEAR))) goto fail; + han->ff_CookLen1 = -1; /* lookahead for efficiency */ /* Don't start cooked processing, application may switch to raw mode *************** *** 937,940 **** --- 971,975 ---- long i; short rwakeup = 0; + short eof = 0; char *ptr; *************** *** 948,954 **** for (i = 0; i < n; ++i) { switch(ptr[i]) { case 13: case 10: ! if (han->ff_CookIdx >= CB_SIZE - 2) { han->ff_Flags |= FHF_COOKBFUL; n = --i; --- 983,992 ---- for (i = 0; i < n; ++i) { switch(ptr[i]) { + case 28: /* 28 is ctrl-\ is EOF */ + eof = 1; + /* special marker. Fall through to save some code */ case 13: case 10: ! if (han->ff_CookIdx >= CB_SIZE - 1) { han->ff_Flags |= FHF_COOKBFUL; n = --i; *************** *** 962,973 **** } } ! /* split buffer into \0 terminated strings */ ! han->ff_CookBuf[han->ff_CookIdx++] = 0; ! han->ff_CookBuf[han->ff_CookIdx] = 0; ! han->ff_LRet = 1; rwakeup = 1; break; case 8: ! if (han->ff_CookIdx && han->ff_CookBuf[han->ff_CookIdx-1] != 0) { if (han->ff_FifoW) { if (WriteFifo(han->ff_FifoW, "\010 \010", 3) != 3) { --- 1000,1016 ---- } } ! han->ff_CookBuf[han->ff_CookIdx++] = (eof ? CHAR_EOF : '\n'); ! if (0 > han->ff_CookLen1) { ! /* first line is ready, include \n but don't count EOF */ ! han->ff_CookLen1 = han->ff_CookIdx - eof; ! } ! han->ff_Flags &= ~FHF_WISTOP; ! eof = 0; rwakeup = 1; break; case 8: ! if (han->ff_CookIdx ! && han->ff_CookBuf[han->ff_CookIdx-1] != '\n' ! && han->ff_CookBuf[han->ff_CookIdx-1] != CHAR_EOF) { if (han->ff_FifoW) { if (WriteFifo(han->ff_FifoW, "\010 \010", 3) != 3) { *************** *** 977,987 **** } } ! han->ff_CookBuf[--han->ff_CookIdx] = 0; ! if (han->ff_CookIdx && han->ff_CookBuf[han->ff_CookIdx-1] == 0) ! han->ff_LRet = 1; } break; default: ! if (han->ff_CookIdx >= CB_SIZE - 2) { han->ff_Flags |= FHF_COOKBFUL; n = --i; --- 1020,1056 ---- } } ! --han->ff_CookIdx; ! if (han->ff_CookIdx==0 ! || han->ff_CookBuf[han->ff_CookIdx-1] == '\n' ! || han->ff_CookBuf[han->ff_CookIdx-1] == CHAR_EOF) ! han->ff_Flags &= ~FHF_WISTOP; } break; + #if 0 + case 26: /* test signals */ + SigHandles(han->ff_Node.ln_Name, SIGBREAKF_CTRL_C); + break; + #endif + #if SIGBREAKB_CTRL_F - SIGBREAKB_CTRL_C == 3 + case 3: case 4: case 5: case 6: + SigHandles(han->ff_Node.ln_Name, 1L<<(ptr[i]-3+SIGBREAKB_CTRL_C)); + break; + #else + /* who says the above is not portable? */ + case 3: + SigHandles(han->ff_Node.ln_Name, SIGBREAKF_CTRL_C); + break; + case 4: + SigHandles(han->ff_Node.ln_Name, SIGBREAKF_CTRL_D); + break; + case 5: + SigHandles(han->ff_Node.ln_Name, SIGBREAKF_CTRL_E); + break; + case 6: + SigHandles(han->ff_Node.ln_Name, SIGBREAKF_CTRL_F); + break; + #endif default: ! if (han->ff_CookIdx >= CB_SIZE - 1) { han->ff_Flags |= FHF_COOKBFUL; n = --i; *************** *** 996,1001 **** } han->ff_CookBuf[han->ff_CookIdx++] = ptr[i]; ! han->ff_CookBuf[han->ff_CookIdx] = 0; ! han->ff_LRet = 0; break; } --- 1065,1069 ---- } han->ff_CookBuf[han->ff_CookIdx++] = ptr[i]; ! han->ff_Flags |= FHF_WISTOP; break; } *************** *** 1007,1011 **** */ ! if ((han->ff_Flags & FHF_WIHOLD) && (han->ff_LRet || han->ff_CookIdx == 0)) { han->ff_Flags &= ~FHF_WIHOLD; while ((msg = (Message *)RemHead((MaxList *)&han->ff_WrWait))) --- 1075,1079 ---- */ ! if ((han->ff_Flags & FHF_WIHOLD) && !(han->ff_Flags & FHF_WISTOP)) { han->ff_Flags &= ~FHF_WIHOLD; while ((msg = (Message *)RemHead((MaxList *)&han->ff_WrWait))) Only in : fifo-handler.o Only in : fifo.o Only in : fifolist.c Only in : FILES Only in : FILES-bin Only in : FILES-src diff -c2 unused:source/fifolib382/handler.h handler.h *** unused:source/fifolib382/handler.h Mon May 13 23:07:34 1996 --- handler.h Wed Aug 28 21:43:35 1996 *************** *** 136,139 **** --- 136,141 ---- #define DOS_FALSE 0 + #define CHAR_EOF '\034' + #define CB_SIZE 1024 /* lines buffer */ #define FIFO_SIZE 2048 *************** *** 167,171 **** MaxNode ff_Node; /* fifo node, ln_name holds fifo name */ short ff_Flags; ! short ff_Refs; /* open refs */ SharRead *ff_SRead; /* fifo handle for reading */ void *ff_FifoW; /* fifo handle for writing */ --- 169,173 ---- MaxNode ff_Node; /* fifo node, ln_name holds fifo name */ short ff_Flags; ! /* now longword aligned */ SharRead *ff_SRead; /* fifo handle for reading */ void *ff_FifoW; /* fifo handle for writing */ *************** *** 178,183 **** char *ff_CookBuf;/* cooked buffer handling */ short ff_CookIdx; ! short ff_LRet; MsgPort *ff_SigPort;/* message port instead of task to signal */ } FHan; --- 180,186 ---- char *ff_CookBuf;/* cooked buffer handling */ short ff_CookIdx; ! short ff_Refs; /* open refs */ MsgPort *ff_SigPort;/* message port instead of task to signal */ + short ff_CookLen1;/* length of full first line of input */ } FHan; *************** *** 184,188 **** #define ff_FifoR ff_SRead->sr_FifoR ! #define FHF_COOKED 0x0001 #define FHF_RPEND 0x0002 #define FHF_WAVAIL 0x0004 --- 187,191 ---- #define ff_FifoR ff_SRead->sr_FifoR ! #define FHF_TEE 0x0001 #define FHF_RPEND 0x0002 #define FHF_WAVAIL 0x0004 *************** *** 191,195 **** #define FHF_CLOSEEOF 0x0020 #define FHF_MASTER 0x0040 ! #define FHF_TEE 0x0080 #define FHF_SHELL 0x0100 #define FHF_COOKBFUL 0x0200 /* cooked buffer is full */ --- 194,198 ---- #define FHF_CLOSEEOF 0x0020 #define FHF_MASTER 0x0040 ! #define FHF_COOKED 0x0080 #define FHF_SHELL 0x0100 #define FHF_COOKBFUL 0x0200 /* cooked buffer is full */ *************** *** 198,202 **** #define FHF_WIHOLD 0x1000 /* write hold due to input */ #define FHF_COOKCRLF 0x2000 /* need to write CRLF */ ! #define FHF_RREQUIRED 0x4000 #define FHF_STARTCOOK 0x8000 /* start cooked processing */ --- 201,205 ---- #define FHF_WIHOLD 0x1000 /* write hold due to input */ #define FHF_COOKCRLF 0x2000 /* need to write CRLF */ ! #define FHF_WISTOP 0x4000 /* delay write due to input */ #define FHF_STARTCOOK 0x8000 /* start cooked processing */ Only in : htag.o Common subdirectories: unused:source/fifolib382/inline and inline Common subdirectories: unused:source/fifolib382/inlinef and inlinef Common subdirectories: unused:source/fifolib382/l and l Common subdirectories: unused:source/fifolib382/lib and lib Only in : lib.o Common subdirectories: unused:source/fifolib382/libraries and libraries Common subdirectories: unused:source/fifolib382/libs and libs Common subdirectories: unused:source/fifolib382/proto and proto Only in : remcli.o Only in : t.exp Only in : tag.o Only in : testfifo Only in : testfifo.o Only in : tests