cdplay now uses libedit!
This commit is contained in:
parent
2aea14c604
commit
6f52aeb8d1
|
@ -1,6 +1,9 @@
|
|||
# $NetBSD: Makefile,v 1.1 1999/06/05 13:22:00 ad Exp $
|
||||
# $NetBSD: Makefile,v 1.2 1999/11/26 18:34:58 msaitoh Exp $
|
||||
|
||||
PROG= cdplay
|
||||
SRCS= cdplay.c
|
||||
|
||||
LDADD+= -ledit -ltermcap
|
||||
DPADD+= ${LIBEDIT} ${LIBTERMCAP}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cdplay.c,v 1.3 1999/09/18 21:15:23 ad Exp $ */
|
||||
/* $NetBSD: cdplay.c,v 1.4 1999/11/26 18:34:58 msaitoh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
|
||||
|
@ -56,12 +56,13 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: cdplay.c,v 1.3 1999/09/18 21:15:23 ad Exp $");
|
||||
__RCSID("$NetBSD: cdplay.c,v 1.4 1999/11/26 18:34:58 msaitoh Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <histedit.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -130,6 +131,12 @@ const char *cdname;
|
|||
int fd = -1;
|
||||
int msf = 1;
|
||||
|
||||
/* for histedit */
|
||||
extern char *__progname; /* from crt0.o */
|
||||
History *hist;
|
||||
HistEvent he;
|
||||
EditLine *elptr;
|
||||
|
||||
int setvol __P((int, int));
|
||||
int read_toc_entrys __P((int));
|
||||
int play_msf __P((int, int, int, int, int, int));
|
||||
|
@ -140,7 +147,7 @@ int opencd __P((void));
|
|||
int play __P((char *));
|
||||
int info __P((char *));
|
||||
int pstatus __P((char *));
|
||||
char *input __P((int *));
|
||||
char *prompt __P((void));
|
||||
void prtrack __P((struct cd_toc_entry *, int));
|
||||
void lba2msf __P((u_long, u_char *, u_char *, u_char *));
|
||||
u_int msf2lba __P((u_char, u_char, u_char));
|
||||
|
@ -193,6 +200,9 @@ main(argc, argv)
|
|||
{
|
||||
char *arg, *p, buf[80];
|
||||
int cmd, len;
|
||||
char *line;
|
||||
const char *elline;
|
||||
int scratch;
|
||||
|
||||
cdname = getenv("MUSIC_CD");
|
||||
if (!cdname)
|
||||
|
@ -250,8 +260,30 @@ main(argc, argv)
|
|||
|
||||
printf("Type `?' for command list\n\n");
|
||||
|
||||
hist = history_init();
|
||||
history(hist, &he, H_SETSIZE, 100); /* 100 elt history buffer */
|
||||
elptr = el_init(__progname, stdin, stdout, stderr);
|
||||
el_set(elptr, EL_EDITOR, "emacs");
|
||||
el_set(elptr, EL_PROMPT, prompt);
|
||||
el_set(elptr, EL_HIST, history, hist);
|
||||
el_source(elptr, NULL);
|
||||
|
||||
for (;;) {
|
||||
arg = input(&cmd);
|
||||
line = NULL;
|
||||
do {
|
||||
if (((elline = el_gets(elptr, &scratch)) != NULL)
|
||||
&& (scratch != 0)){
|
||||
history(hist, &he, H_ENTER, elline);
|
||||
line = strdup(elline);
|
||||
arg = parse(line, &cmd);
|
||||
} else {
|
||||
cmd = CMD_QUIT;
|
||||
fprintf(stderr, "\r\n");
|
||||
arg = 0;
|
||||
break;
|
||||
}
|
||||
} while (!arg);
|
||||
|
||||
if (run(cmd, arg) < 0) {
|
||||
/* XXX damned -Wall */
|
||||
char *null = NULL;
|
||||
|
@ -260,7 +292,11 @@ main(argc, argv)
|
|||
fd = -1;
|
||||
}
|
||||
fflush(stdout);
|
||||
if (line != NULL)
|
||||
free(line);
|
||||
}
|
||||
el_end(elptr);
|
||||
history_end(hist);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -948,23 +984,9 @@ status(trk, min, sec, frame)
|
|||
}
|
||||
|
||||
char *
|
||||
input(cmd)
|
||||
int *cmd;
|
||||
prompt()
|
||||
{
|
||||
static char buf[80];
|
||||
char *p;
|
||||
|
||||
do {
|
||||
fprintf(stderr, "cdplay> ");
|
||||
|
||||
if (!fgets(buf, sizeof(buf), stdin)) {
|
||||
*cmd = CMD_QUIT;
|
||||
fprintf(stderr, "\r\n");
|
||||
return (0);
|
||||
}
|
||||
p = parse(buf, cmd);
|
||||
} while (!p);
|
||||
return (p);
|
||||
return ("cdplay> ");
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
Loading…
Reference in New Issue