Deleted Added
full compact
prompt.c (37010) prompt.c (37011)
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: prompt.c,v 1.4 1998/05/27 22:43:37 brian Exp $
26 * $Id: prompt.c,v 1.5 1998/06/15 19:06:53 brian Exp $
27 */
28
29#include <sys/param.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33#include <sys/un.h>
34

--- 115 unchanged lines hidden (view full) ---

150 struct prompt *p = descriptor2prompt(d);
151 return p->fd_in >= 0 && FD_ISSET(p->fd_in, fdset);
152}
153
154
155static void
156prompt_ShowHelp(struct prompt *p)
157{
27 */
28
29#include <sys/param.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33#include <sys/un.h>
34

--- 115 unchanged lines hidden (view full) ---

150 struct prompt *p = descriptor2prompt(d);
151 return p->fd_in >= 0 && FD_ISSET(p->fd_in, fdset);
152}
153
154
155static void
156prompt_ShowHelp(struct prompt *p)
157{
158 prompt_Printf(p, "The following commands are available:\r\n");
159 prompt_Printf(p, " ~p\tEnter Packet mode\r\n");
160 prompt_Printf(p, " ~-\tDecrease log level\r\n");
161 prompt_Printf(p, " ~+\tIncrease log level\r\n");
162 prompt_Printf(p, " ~t\tShow timers\r\n");
163 prompt_Printf(p, " ~m\tShow memory map\r\n");
164 prompt_Printf(p, " ~.\tTerminate program\r\n");
165 prompt_Printf(p, " ~?\tThis help\r\n");
158 prompt_Printf(p, "The following commands are available:\n");
159 prompt_Printf(p, " ~p\tEnter Packet mode\n");
160 prompt_Printf(p, " ~t\tShow timers\n");
161 prompt_Printf(p, " ~m\tShow memory map\n");
162 prompt_Printf(p, " ~.\tTerminate program\n");
163 prompt_Printf(p, " ~?\tThis help\n");
166}
167
168static void
169prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
170{
171 struct prompt *p = descriptor2prompt(d);
172 int n;
173 char ch;

--- 71 unchanged lines hidden (view full) ---

245 prompt_TtyCommandMode(p);
246 p->nonewline = 0;
247 prompt_Required(p);
248 break;
249 case 't':
250 timer_Show(0, p);
251 break;
252 case 'm':
164}
165
166static void
167prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
168{
169 struct prompt *p = descriptor2prompt(d);
170 int n;
171 char ch;

--- 71 unchanged lines hidden (view full) ---

243 prompt_TtyCommandMode(p);
244 p->nonewline = 0;
245 prompt_Required(p);
246 break;
247 case 't':
248 timer_Show(0, p);
249 break;
250 case 'm':
253 mbuf_Show(NULL);
251 {
252 struct cmdargs arg;
253
254 arg.cmdtab = NULL;
255 arg.cmd = NULL;
256 arg.argc = 0;
257 arg.argn = 0;
258 arg.argv = NULL;
259 arg.bundle = bundle;
260 arg.cx = p->TermMode;
261 arg.prompt = p;
262
263 mbuf_Show(&arg);
264 }
254 break;
255 default:
256 if (physical_Write(p->TermMode->physical, &ch, n) < 0) {
257 log_Printf(LogERROR, "error writing to modem: %s\n", strerror(errno));
258 prompt_TtyCommandMode(p);
259 }
260 break;
261 }

--- 76 unchanged lines hidden (view full) ---

338 }
339}
340
341void
342prompt_Printf(struct prompt *p, const char *fmt,...)
343{
344 if (p && p->active) {
345 va_list ap;
265 break;
266 default:
267 if (physical_Write(p->TermMode->physical, &ch, n) < 0) {
268 log_Printf(LogERROR, "error writing to modem: %s\n", strerror(errno));
269 prompt_TtyCommandMode(p);
270 }
271 break;
272 }

--- 76 unchanged lines hidden (view full) ---

349 }
350}
351
352void
353prompt_Printf(struct prompt *p, const char *fmt,...)
354{
355 if (p && p->active) {
356 va_list ap;
357
346 va_start(ap, fmt);
358 va_start(ap, fmt);
347 vfprintf(p->Term, fmt, ap);
348 fflush(p->Term);
359 prompt_vPrintf(p, fmt, ap);
349 va_end(ap);
360 va_end(ap);
350 p->nonewline = 1;
351 }
352}
353
354void
355prompt_vPrintf(struct prompt *p, const char *fmt, va_list ap)
356{
357 if (p && p->active) {
361 }
362}
363
364void
365prompt_vPrintf(struct prompt *p, const char *fmt, va_list ap)
366{
367 if (p && p->active) {
358 vfprintf(p->Term, fmt, ap);
368 char nfmt[LINE_LEN];
369 const char *pfmt;
370
371 if (p->TermMode) {
372 /* Stuff '\r' in front of '\n' 'cos we're in raw mode */
373 int len = strlen(fmt);
374
375 if (len && len < sizeof nfmt - 1 && fmt[len-1] == '\n') {
376 strcpy(nfmt, fmt);
377 strcpy(nfmt + len - 1, "\r\n");
378 pfmt = nfmt;
379 } else
380 pfmt = fmt;
381 } else
382 pfmt = fmt;
383 vfprintf(p->Term, pfmt, ap);
359 fflush(p->Term);
360 p->nonewline = 1;
361 }
362}
363
364void
365prompt_TtyInit(struct prompt *p)
366{

--- 159 unchanged lines hidden ---
384 fflush(p->Term);
385 p->nonewline = 1;
386 }
387}
388
389void
390prompt_TtyInit(struct prompt *p)
391{

--- 159 unchanged lines hidden ---