diff -urN mcd-0.2c/Makefile mcd-0.3a/Makefile --- mcd-0.2c/Makefile Sun Jul 22 23:53:21 2001 +++ mcd-0.3a/Makefile Fri Jul 27 02:59:39 2001 @@ -19,7 +19,7 @@ all: clean $(PRGS) mcd: $(OBJS) - strip $(S_FLAGS) -x $(OBJS) + strip -x $(S_FLAGS) $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) strip $(S_FLAGS) mcd diff -urN mcd-0.2c/cddb.c mcd-0.3a/cddb.c --- mcd-0.2c/cddb.c Thu Jan 1 01:00:00 1970 +++ mcd-0.3a/cddb.c Fri Jul 27 08:05:34 2001 @@ -0,0 +1,182 @@ +/* + * Author strongly advices against using this code, or a part of it, + * in an application designed to run on any Microsoft(tm) platfrom. + * + * See doc/README for more information about COPYING terms. + */ +#include "mcd.h" +#include + +#define BUFSIZE 1024 /* complete lines must fit ! */ +char port[6], ip[16]; + +static short cddb_parseentry(struct mcd *cd); +static int cddb_getserver(const char *ipport, char *ip, char *port); +static int cddb_opensocket(char *ip, char *port); +static int cddb_readsocket(char *s, int size, int *socket); +static short cddb_abort(struct he *h); + +/* searches a local entry, success returns 0 (needs CDB_PATH!)*/ +static short cddb_parseentry(struct mcd *cd) { + char *fn=malloc(sizeof(char)*PATH_MAX); + int p=0,tr=0,len,fd; /* p=parse;tr=track */ + char ch; + + len=_snprintf(fn,PATH_MAX-1,"%s/%08x", + getenv("CDDB_PATH"),cd_discid(&cd[0])); + fn[len]='\0'; + if ((fd=open(fn,O_RDONLY))<0) { + free(fn); return -1; /* no entry (mostly *g*) */ + } + while (len+=read(fd,&ch,1)>0) { + fn[len-1]=ch; + if (ch=='\n'||ch=='\r') { /* next one */ + p=1;fn[len-1]='\0';len=0; + } + if (p) { /* parse line */ + if (!strncmp(fn, "DTITLE=", 7)) + strncpy(cd->t[0].name, fn+7, strlen(fn)); + if (!strncmp(fn, "TTITLE", 6)) + strncpy(cd->t[++tr].name, fn+8+(int)(tr/10), strlen(fn)); + p=0; + } + } /* while() */ + free(fn); + return 0; +} + +/* gets server from environment, 0 means success + (not always correct, but libc-stuff is to big) */ +static int cddb_getserver(const char *ipport, char *ip, char *port) { + register const char *s=ipport; + register int i; + if (!s) return -1; + for (i=0;*s && *s!=':';s++,i++) ip[i]=*s; /* shall be an ip :} */ + if (i>15) return -1; /* 12+3 */ + ip[i]='\0';s++; + for (i=0;*s;s++,i++) port[i]=*s; + if (i>5) return -1; + port[i]='\0'; + return 0; +} + +/* close connection to server */ +static short cddb_abort(struct he *h) { + write(h->fd,"quit\n",5); + close(h->fd); + free(h->msg); + return CDDB_NOENT; +} + +/* returns socket of server */ +static int cddb_opensocket(char *ip, char *port) { + struct sockaddr_in addr; + int sockfd; + if ((sockfd=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0) + return -1; + addr.sin_family=AF_INET; + addr.sin_port=htons(atoi(port)); + addr.sin_addr.s_addr=inet_addr(ip); + if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr))<0) + return -1; + return sockfd; +} + +/* XXX + warning, can lock the programm, if server is ugly */ +static int cddb_readsocket(char *s, int size, int *socket) { + int i=0,r; + char c; + while ((r=recv(*socket, &c, 1, 0))>0) { + if (i==size) break; + s[i++]=c; + if (c=='\r') break; /* \r\n -> '\n' after while */ + } + if (r<0) return r; + recv(*socket, &c, 1, 0); + s[i]='\0';return i; +} + +/* the global call, fills cd->t[].name, returns CDDB_MODES (mcd.h) */ +int cddb_getentries(struct mcd *cd) { + char *hostname=getenv("HOSTNAME"); + char *logname=getenv("LOGNAME"); + char tmp[16]; /* tracks to str */ + struct he h; + int len,i; + + /* if this is not set, we do nothing! */ + if (getenv("CDDB_PATH")==NULL) + return CDDB_NOENT; + + /* if local entry is here, we take it */ + if (!cddb_parseentry(&cd[0])) + return CDDB_LOCAL; + + /* now, lets get new entry (handles only exact matches) */ + if ((cddb_getserver(getenv("CDDB_SERVER"),ip,port)<0) || + ((h.fd=cddb_opensocket(ip,port))<0) || /* can't connect */ + (hostname==NULL) || (logname==NULL)) /* kiss */ + return CDDB_NOENT; + + h.msg=malloc(sizeof(char)*BUFSIZE+1); + if (!h.msg) return CDDB_NOENT; + + /* small implementation of this protocoll (l8er more?) */ + /* 201 foobar server version ready */ + if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) + return cddb_abort(&h); + if (strncmp("201",h.msg,3)) return cddb_abort(&h); + len=_snprintf(h.msg,BUFSIZE,"cddb hello %s %s mcd %s\n", + logname,hostname,MCD_VERSION); + write(h.fd,h.msg,len); + + /* 200 Hello and welcome user@hostname running mcd version */ + if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) + return cddb_abort(&h); + if (strncmp("200",h.msg,3)) return cddb_abort(&h); + len=_snprintf(h.msg,BUFSIZE,"cddb query %08x %d ", + cd_discid(&cd[0]),cd->title[1]); + for (i=1;i<=cd->title[1];i++) { + len+=_snprintf(tmp, 15, "%d ", cd->t[i].cddb); + strncat(h.msg,tmp,strlen(tmp)); + } + len+=_snprintf(tmp, 15, "%d\n", cd->t[0].cddb); + strncat(h.msg,tmp,strlen(tmp)); + write(h.fd,h.msg,len); + + /* 200 rock a90c9d0c Queen / Innuendo */ + if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) + return cddb_abort(&h); + if (strncmp("200",h.msg,3)) return cddb_abort(&h); + for (i=0;h.msg[i+4]!=' ';i++) tmp[i]=h.msg[i+4]; /* 200 foobar' ' */ + tmp[i]='\0'; + len=_snprintf(h.msg,BUFSIZE,"cddb read %s %08x\n", + tmp,cd_discid(&cd[0])); + write(h.fd,h.msg,len); + + /* 210 rock a90c9d0c CD database entry follows (until terminating `.') */ + if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) + return cddb_abort(&h); + if (strncmp("210",h.msg,3)) return cddb_abort(&h); + len=_snprintf(h.msg,BUFSIZE,"%s/%08x",getenv("CDDB_PATH"),cd_discid(&cd[0])); + + i=open(h.msg,O_WRONLY|O_CREAT,CDDB_CREATMODE); + while ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))>0 && (h.msg[0]!='.')) { + write(i,h.msg,len-1); /* [len]='\r' */ + write(i,"\n",1); + } + if (len<0) return cddb_abort(&h); + close(i); + + /* 230 foobar Goodbye. */ + write(h.fd,"quit\n",5); + /* last recv() isn't usefull, but seems correct :) */ + if ((len=cddb_readsocket(h.msg, BUFSIZE, &h.fd))<0) + return cddb_abort(&h); + if (strncmp("230",h.msg,3)) + return cddb_abort(&h); + + close(h.fd); + free(h.msg); + return CDDB_REMOTE; +} diff -urN mcd-0.2c/cddev.c mcd-0.3a/cddev.c --- mcd-0.2c/cddev.c Mon Jul 23 03:55:11 2001 +++ mcd-0.3a/cddev.c Fri Jul 27 08:01:52 2001 @@ -5,31 +5,48 @@ * See doc/README for more information about COPYING terms. */ #include "mcd.h" +short cddb; /* if 0, we have no entries and no remote stuff */ static void cd_playmsf(struct mcd *cd, struct cdrom_msf *msf); static void cd_playmsf(struct mcd *cd, struct cdrom_msf *msf) { if (cd->status == CDROM_AUDIO_PLAY) { if (ioctl(cd->fd,CDROMPAUSE,NULL)<0) - draw_status("error: stopping",1); + draw_status("error stopping",1); } if (ioctl(cd->fd,CDROMPLAYMSF, msf)<0) - draw_status("error: playing",1); + draw_status("error playing",1); return; } /* GLOBAL */ +/* look at the specs, should do, what they want :) */ +unsigned cd_discid(struct mcd *cd) { + static unsigned cd_cddbsum(register int n) { + register unsigned int ret=0; + while (n>0) { + ret += (n%10); n /= 10; + } + return ret; + } + unsigned int i=1, n=0; + while (i<=cd->title[1]) { + n+=cd_cddbsum(cd->t[i].cddb/75);i++; + } + return ((n%0xff)<<24|(cd->t[0].cddb - cd->t[1].cddb/75)<<8|cd->title[1]); +} + /* open device or exit ! */ int cd_init(const char *cdpath, struct mcd *cd) { cd->fd=open(cdpath,O_RDONLY|O_NONBLOCK); if ((cd->fd<0) || (cd->status=ioctl(cd->fd,CDROM_DISC_STATUS,NULL)<0)) { - _printf("Sorry, can't open cd-device: \"%s\" !\n",cdpath); + _printf("Sorry, can't open cd-device \"%s\" !\n",cdpath); exit(1); } - if (cd->status==(100||105)) return -1; + if (cd->status==(100||105)) return -1; /* audio/mixed */ return 0; } -/* needs correct cd->fd; seems very efficient (no division qnd such) */ +/* needs correct cd->fd; seems very efficient (no division...) */ int cd_readtracks(struct mcd *cd) { struct cdrom_tochdr cdth; /* TocHdr Stuff */ register int i; @@ -49,6 +66,9 @@ cd->t[i].audio=cd->cdte[i].cdte_ctrl & CDROM_DATA_TRACK; cd->t[i].min=cd->cdte[i].cdte_addr.msf.minute; cd->t[i].sec=cd->cdte[i].cdte_addr.msf.second; + cd->t[i].cddb = cd->cdte[i].cdte_addr.msf.minute*60*75 + + cd->cdte[i].cdte_addr.msf.second*75 + + cd->cdte[i].cdte_addr.msf.frame; /* cddb[track] */ cd->t[i-1].min=cd->t[i].min-cd->t[i-1].min; if ((cd->cdte[i].cdte_addr.msf.frame)>37) cd->t[i-1].sec++; /* rounding a bit :) */ if ((cd->t[i-1].sec=cd->t[i].sec-cd->t[i-1].sec)<0) { @@ -66,14 +86,21 @@ cd->t[0].audio=cd->cdte[0].cdte_ctrl & CDROM_DATA_TRACK; cd->t[0].min=cd->cdte[0].cdte_addr.msf.minute; cd->t[0].sec=cd->cdte[0].cdte_addr.msf.second; + cd->t[0].cddb = + cd->cdte[0].cdte_addr.msf.minute*60 + + cd->cdte[0].cdte_addr.msf.second; /* cddb[0] this last id */ cd->t[i-1].min=cd->t[0].min-cd->t[i-1].min; + cd->t[i-1].cddb = cd->cdte[i-1].cdte_addr.msf.minute*60*75 + + cd->cdte[i-1].cdte_addr.msf.second*75 + + cd->cdte[i-1].cdte_addr.msf.frame; /* cddb[last] */ if ((cd->cdte[i].cdte_addr.msf.frame)>37) cd->t[i-1].sec++; /* rounding a bit :) */ if ((cd->t[i-1].sec=cd->t[0].sec-cd->t[i-1].sec)<0) { cd->t[i-1].min--;cd->t[i-1].sec+=60; /* adjust minutes */ } } updates[U_TRACKS]=1; - return cd->title[1]=cdth.cdth_trk1; /* init all these stuff */ + cd->title[1]=cdth.cdth_trk1; /* init all these stuff */ + return cddb=cddb_getentries(&cd[0]); /* cddb is returned to draw.c */ } @@ -85,8 +112,12 @@ if (ioctl(cd->fd,CDROMSUBCHNL,&cd->cds)<0) return -1; /* audiostatus changed */ - if (cd->cds.cdsc_audiostatus!=cd->status) { + if (cd->cds.cdsc_audiostatus!=cd->status) { /* also NO_[DISC|INFO] */ cd->status=cd->cds.cdsc_audiostatus; + if (cd->status==CDS_NO_DISC) { + updates[U_NODISC]=updates[U_ALL]=1; + return -1; + } /* intro */ if (cd->method==M_INTRO && cd->status==CDROM_AUDIO_COMPLETED) { cd->title[0]++; updates[U_TRACKS]=1; @@ -188,7 +219,7 @@ void cd_stop(struct mcd *cd) { if (cd->cds.cdsc_audiostatus == CDROM_AUDIO_PLAY) if (ioctl(cd->fd,CDROMSTOP,NULL)<0) - draw_status("error: stopping",1); + draw_status("error stopping",1); return; } @@ -215,5 +246,6 @@ void cd_close(int *fd) { draw_status("reading cdrom",1); ioctl(*fd,CDROMCLOSETRAY,NULL); + updates[U_ALL]=1; return; } diff -urN mcd-0.2c/doc/CHANGES mcd-0.3a/doc/CHANGES --- mcd-0.2c/doc/CHANGES Mon Jul 23 03:17:16 2001 +++ mcd-0.3a/doc/CHANGES Fri Jul 27 08:10:12 2001 @@ -1,3 +1,15 @@ +0.3a: + cddb works now (only freedb was tested!) + drawing the titelinfo works now correct + updated manpage + updated mcd.lsm + +0.3: + cddb seems buggy somehow, i will fix it :) + added cddb stuff in manpage + added cddb stuff (ip only, no resolving stuff -> no bloat) + added mcd.lsm + 0.2c: fixed play-method repeat cd in cd_start() fixed play-method intro in cd_start() and cd_readsubchannel() @@ -8,5 +20,4 @@ added this file (doc/CHANGES) removed shuffle completly, it will be included if it is stable made cd_readtracks() more efficient - many ugly bugs removed :) - \ No newline at end of file + many ugly bugs removed diff -urN mcd-0.2c/doc/README mcd-0.3a/doc/README --- mcd-0.2c/doc/README Sun Jul 22 18:59:16 2001 +++ mcd-0.3a/doc/README Fri Jul 27 08:09:35 2001 @@ -1,11 +1,12 @@ WHAT IS IT -=========== +============ - mcd is a small (maybe the smallest) cd-player for _linux_ -- it should compile/run out off the box -- it compiles against dietlibc (~11kb static!) +- it compiles/runs out off the box +- it can be compiled against dietlibc (~15kb static!) - working play methods: reapeat cd, repeat track and intro +- since version 0.3, cddb title stuff is also included (0.3a correctly) @@ -33,7 +34,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -AND +!AND! Author strongly advices against using this code, or a part of it, in an application designed to run on any Microsoft(tm) platfrom. @@ -43,21 +44,17 @@ TODO ====== -- term resizing stuff works correct, if not started from mc, because mc seems - to catch the SIGWINCH signal !!! - (btw: a new rewrite of the midnight commander will be my next project ...) +- term resizing works correct, since version 0.2 (if not started from mc + (btw: a new rewrite of the mc will be my next project ...mmc?) - maybe some things of the wishlist... (if someone ask me, i will do it) -- for now, this is the stable release of mcd ! - +- see, if cddb works well WISHLIST ========== -- CD-Text (i like this!) -- maybe cddb (i don't like it much!) -- shuffle isn't really done yet, it is now in my private 0.3 version :) - +- CD-Text (i like this, but may cdrom not) +- shuffle isn't really done yet, it is added if it works well HOMEPAGE diff -urN mcd-0.2c/draw.c mcd-0.3a/draw.c --- mcd-0.2c/draw.c Mon Jul 23 03:13:29 2001 +++ mcd-0.3a/draw.c Fri Jul 27 08:35:59 2001 @@ -3,6 +3,8 @@ * in an application designed to run on any Microsoft(tm) platfrom. * * See doc/README for more information about COPYING terms. + * + * XXX: For smaller terminals, and long titles we need some reordering. */ #include "mcd.h" static void draw_hline(int i, char *ch); /* draw an hline */ @@ -19,7 +21,6 @@ static void draw_box(int x1, int y1, int x2, int y2) { register int i; - show1(C_BOX); /* color */ gotoxy(x1,y1);show1(AC_TL);draw_hline(x2-x1,AC_HL);show1(AC_TR); for (i=1;i!=y2-1;++i) { gotoxy(x1,y1+i);show1(AC_VL); @@ -35,12 +36,11 @@ return; } - /* GLOBAL */ short maxx,maxy; /* screenmaxima */ void draw_tracks(struct mcd *cd) { - register int i=1,m=1; /* title/modifier/realtitle */ + register int i,m; /* title/modifier/realtitle */ int y=0,x=0; /* x,y==diffs to real */ for (i=1;(i<=cd->title[1] && i<=MCD_CDAUDIO_MAX); i++) { @@ -58,17 +58,53 @@ if (i==cd->title[0]) show1(C_NORMAL); /* current */ } + show1(C_STATUS); /* trackmodifier */ gotoxy(13,10); - _printf(C_STATUS "(%d)" C_NORMAL, pluskey); + _printf("(%d)", pluskey); + + if (cddb) { /* if we have cddb */ + gotoxy(57,2);_printf("%08x",cd_discid(&cd[0])); + gotoxy(67,2); + if (cddb==CDDB_LOCAL) show1("(local file)"); + else _printf("(via %s:%s)",ip,port); /* can only be REMOTE */ + + /* titelinfo */ + gotoxy(36,5); _printf("%s",cd->t[0].name); + gotoxy(36,7); _printf("%s",cd->t[cd->title[0]].name); + for (i=strlen(cd->t[cd->title[0]].name)+36;ititle[1];i++) { + gotoxy(16,10+i); + if (i==cd->title[0]) show1(T_BOLD); + _printf("%s",cd->t[i].name); + if (i==cd->title[0]) show1(C_NORMAL); + } + } + } return; } void draw_initscr(void) { + register int i; + show1(C_NORMAL T_CLEAR C_BOX); draw_box(1,1,maxx,maxy); - show1(C_BOX); gotoxyw(1,9, AC_ML);draw_hline(maxx-1,AC_HL); - show1(AC_MR C_HEADLINE); + show1(AC_MR); + if (cddb) { + gotoxy(34,1);show1(AC_MB); + for (i=2;i<9;i++) { + gotoxy(34,i); + show1(AC_VL); + } + gotoxy(34,9);show1(AC_MT); + } + + show1(C_HEADLINE); gotoxyw(3,2, "mcd version " MCD_VERSION); + if (cddb) gotoxyw(36,2,"freedb info (discid: )"); gotoxyw(3,10,"tracklist"); show1(C_DESCRIPT); @@ -77,6 +113,11 @@ gotoxyw(3,6, "Volume:"); gotoxyw(3,7, "Track:"); gotoxyw(3,8, "CD:"); + + if (cddb) { + gotoxyw(36,4, "Artist / Album:"); + gotoxyw(36,6, "Current Title:"); + } return; } @@ -92,21 +133,20 @@ void draw_updatescr(struct mcd *cd) { if (cd_readsubchannel(cd)<0) { - draw_status("no disc",0); + draw_status("no disc (use e/c)",0); + return; } show1(C_NORMAL); if (updates[U_ALL]) { signal(SIGWINCH,tty_resize); - clear(); + show1(C_NORMAL T_CLEAR); tty_getsize(&maxx,&maxy); - if (maxx<42 || maxy<13) { - show2("Sorry, you need at least a termsize of 42x13.\n"); + if (maxx<80 || maxy<13) { + show2(T_NORMAL T_CLEAR "Sorry, you need at least a termsize of 80x13.\n"); tty_mode(TERM_QUIT); } - if ((cd->title[1]=cd_readtracks(&cd[0]))<1) { - draw_status("can't read tracks",1);return; - } + cddb=cd_readtracks(&cd[0]); draw_initscr(); updates[U_TRACKS]=updates[U_STATUS]=updates[U_METHOD]=updates[U_VOLUME]=1; updates[U_ALL]=0; @@ -151,9 +191,11 @@ cd->cds.cdsc_reladdr.msf.second, cd->title[0],cd->title[1]); gotoxy(11,8); - _printf("%02d:%02d", + _printf("%02d:%02d (%02d:%02d)", cd->cds.cdsc_absaddr.msf.minute, - cd->cds.cdsc_absaddr.msf.second); + cd->cds.cdsc_absaddr.msf.second, + cd->cdte[0].cdte_addr.msf.minute, + cd->cdte[0].cdte_addr.msf.second); show1(T_HOME); return; } diff -urN mcd-0.2c/mcd.1 mcd-0.3a/mcd.1 --- mcd-0.2c/mcd.1 Mon Jul 23 03:54:34 2001 +++ mcd-0.3a/mcd.1 Fri Jul 27 08:19:15 2001 @@ -1,5 +1,5 @@ .\" Tino Reichardt -.TH MCD 1 "2001-07-23" "mcd-0.2c" "User commands" +.TH MCD 1 "2001-07-27" "mcd-0.3a" "User commands" .SH "NAME" mcd \- a small cdplayer for linux .SH "SYNOPSIS" @@ -36,7 +36,20 @@ .TS tab (@); l l. -MCD_CDROM@try this cdrom as default, rather then CDROM_DEFAULT from params.h (compile time). +MCD_CDROM@Try this cdrom as default (if unset, CDROM_DEFAULT +@from params.h is used). +CDDB_PATH@path to your local cddb files (if unset, _no_ cddb titelinfo +@is displayed) +CDDB_SERVER@IP:PORT of a freedb server (if unset, only local cddb +@stuff is used, if it exists in $CDDB_PATH/$discid). +LOGNAME@Is used for remote cddb login. +HOSTNAME@Is used for remote cddb login too. +.TE +.SH "FILES" +.TS +tab (@); +l l. +$CDDB_PATH/*@Is used for reeading/writing cddb entries. .TE .SH "RETURN VALUES" .TS @@ -44,17 +57,15 @@ l l. \fB0\fP @no errors occured / normal quit \fB1\fP @the given cd-device isn't a cd-device -\fB2\fP @your cd seems to be sth else then CD-Audio or CD-Mixed +\fB2\fP @your cd seems to be sth. other then a CD-Audio or CD-Mixed .TE .SH "NOTES" Some terminals don't like the default escape-sequences from params.h ... if -so, you have to edit them ! +so, you have to edit them ! Successfully tested terminals are \fBvt100\fP, +\fBlinux\fP, \fBxterm\fP, \fBxterm-color\fP. .PP -Successfully tested terminals are: -.B vt100, -.B linux, -.B xterm, -.B xterm-color +If you haven't direct access to a freedb server, you may use some +port redirector program ... see freshmeat. .SH "AUTHOR" Tino Reichardt .PP diff -urN mcd-0.2c/mcd.c mcd-0.3a/mcd.c --- mcd-0.2c/mcd.c Mon Jul 23 02:22:08 2001 +++ mcd-0.3a/mcd.c Fri Jul 27 07:48:36 2001 @@ -26,6 +26,7 @@ mesg(1,"Sorry, your disc isn't a Mixed-CD or Audio-CD !\n"); exit(2); } + tty_mode(TERM_INIT); signal(SIGINT,mcd_quit); signal(SIGQUIT,mcd_quit); @@ -91,6 +92,7 @@ case 'C': case 'c': cd_close(&cd->fd); + break; case '?': case 'H': case 'h': @@ -120,10 +122,12 @@ break; case 'q': case 'Q': - quit=1; break; + quit=1; + break; case '0': if (!pluskey && !((int)ch-48)) { - draw_status("hey, this isn't valid!",1); break; + draw_status("hey, this isn't valid!",1); + break; } case '1': case '2': @@ -136,10 +140,11 @@ case '9': if ((pluskey*10)+((int)ch-48)>cd->title[1] || (pluskey*10)+((int)ch-48)<1) break; else { - cd->title[0]=((pluskey*10)+((int)ch-48)); - cd_start(&cd[0]); - updates[U_TRACKS]=1; - } break; + cd->title[0]=((pluskey*10)+((int)ch-48)); + cd_start(&cd[0]); + updates[U_TRACKS]=1; + } + break; } /* switch */ } /* select */ } /* while */ @@ -148,7 +153,6 @@ } void mcd_quit(int i) { - show1(C_NORMAL);clear(); - show1(T_BOLD "ByeBye...\n\n" T_NORMAL); + show1(T_NORMAL T_HOME T_CLEAR T_BOLD "ByeBye...\n\n" T_NORMAL); tty_mode(TERM_QUIT); } diff -urN mcd-0.2c/mcd.h mcd-0.3a/mcd.h --- mcd-0.2c/mcd.h Mon Jul 23 03:55:21 2001 +++ mcd-0.3a/mcd.h Fri Jul 27 08:08:33 2001 @@ -8,6 +8,8 @@ #define _MCD_H #include +#include +#include #include #include #include @@ -19,25 +21,34 @@ #include #include #include +#include +#include +#include +#include #include #include "params.h" -#define MCD_VERSION "0.2c" +#define MCD_VERSION "0.3a" -/* METHODS (don't change!) */ -#define M_PLAY_CD 0 /* play whole cd and stop */ -#define M_REPEAT_CD 1 /* play whole cd in endless-loop */ -#define M_REPEAT_TRK 2 /* play current track in endless-loop */ -#define M_INTRO 3 /* play first ten seconds of each track and stop */ - -/* for selected refresh (times are always refr..) */ -#define U_STATUS 0 /* only titles are updated */ -#define U_METHOD 1 /* status-method is updated */ -#define U_VOLUME 2 /* status-volume is updated */ -#define U_TRACKS 3 /* all tracks are updated */ -#define U_ALL 4 /* really ALL is updated */ +/* METHODS */ +#define M_PLAY_CD 0 /* play whole cd and stop */ +#define M_REPEAT_CD 1 /* play whole cd in endless-loop */ +#define M_REPEAT_TRK 2 /* play current track in endless-loop */ +#define M_INTRO 3 /* play first ten seconds of each track and stop */ + +/* UPDATES */ +#define U_NODISC 0 /* nothing... special, for nodisk-status */ +#define U_STATUS 1 /* only titles are updated */ +#define U_METHOD 2 /* status-method is updated */ +#define U_VOLUME 3 /* status-volume is updated */ +#define U_TRACKS 4 /* all tracks are updated */ +#define U_ALL 5 /* really ALL is updated */ + +#define CDDB_NOENT 0 /* no local cddb, no remote access*/ +#define CDDB_LOCAL 1 /* local entry is used */ +#define CDDB_REMOTE 2 /* can download from CDDB_SERVER */ /* ***** */ /* mcd.c */ @@ -45,6 +56,8 @@ int audio; /* current track is audio */ int sec; /* seconds of current title */ int min; /* minutes of current title */ + int cddb; /* cddb-trackid, 0=discid */ + char name[CDDB_TITLEMAX]; /* name of title, 0=artist/cdname (XXX: is fixed sized okay?) */ }; struct mcd { @@ -58,9 +71,21 @@ struct cdrom_tocentry cdte[MCD_CDAUDIO_MAX+1]; /* mainly for playmsf */ }; -extern short maxx,maxy,pluskey,updates[4]; +struct he { + int fd; /* socketfd */ + char *msg; /* some msg */ +}; + +extern short pluskey,updates[4]; extern void mcd_quit(int); /* cleanups + quit */ +/* ****** */ +/* cddb.c */ +extern short cddb; +extern char port[6], ip[16]; + +extern int cddb_getentries(struct mcd *cd); /* fills cd->t[].name, sets cddb variable */ + /* ***** */ /* tty.c */ #define TERM_INIT 0 /* save current value (only one time) */ @@ -70,15 +95,15 @@ extern void tty_resize(int i); /* after changes */ /* aliase */ -#define show1(m) mesg(1,(char*)m) /* to stdout */ -#define show2(m) mesg(2,(char*)m) /* to stderr */ - -#define clear() show1(T_HOME T_CLEAR) -#define gotoxy(x,y) _printf(T_GOTO_XY, y, x) -#define gotoxyw(x,y,t) _printf(T_GOTO_XY "%s", y, x, t) +#define show1(m) mesg(1,(char*)m) /* to stdout */ +#define show2(m) mesg(2,(char*)m) /* to stderr */ +#define gotoxy(x,y) _printf(T_GOTO_XY, y, x) +#define gotoxyw(x,y,t) _printf(T_GOTO_XY "%s", y, x, t) /* ****** */ /* draw.c */ +extern short maxx,maxy; + extern void draw_initscr(void); extern void draw_updatescr(struct mcd *cd); extern void draw_status(char *msg, short update); @@ -87,7 +112,7 @@ /* ****** */ /* misc.c */ extern int select_wait(int fd, int sec); -extern void mesg(int fd, char *msg); /* for writing to the terminal */ +extern void mesg(int fd, char *msg); /* ******* */ /* cddev.c */ @@ -100,6 +125,7 @@ extern void cd_stop(struct mcd *cd); extern void cd_eject(int *fd); extern void cd_close(int *fd); +extern unsigned cd_discid(struct mcd *cd); /* ********* */ /* formats.c */ diff -urN mcd-0.2c/mcd.lsm mcd-0.3a/mcd.lsm --- mcd-0.2c/mcd.lsm Thu Jan 1 01:00:00 1970 +++ mcd-0.3a/mcd.lsm Fri Jul 27 06:16:09 2001 @@ -0,0 +1,16 @@ +Begin3 +Title: mcd +Version: 0.3 +Entered-date: 07/24/2001 +Description: Is a small cd player application with a curses like + interface. Has a track database, supports remote/local cddb + track data, + different play modes and volume control. +Keywords: cd, player, audio, sound, curses, dietlibc, cddb, freedb +Author: Tino Reichardt +Primary-site: http://www.mcmilk.de/projects/mcd/ + ~20kB mcd-0.3a.tar.gz + ~16kB mcd-0.3a.gz (static binary!) +Platforms: Linux, cdrom, sound +Copying-policy: GPL2 +End diff -urN mcd-0.2c/params.h mcd-0.3a/params.h --- mcd-0.2c/params.h Mon Jul 23 03:20:33 2001 +++ mcd-0.3a/params.h Thu Jul 26 07:50:47 2001 @@ -7,6 +7,8 @@ #define _MCD_PARAMS_H #define CDROM_DEFAULT "/dev/cdrom" +#define CDDB_CREATMODE 0644 /* used, for new entries */ +#define CDDB_TITLEMAX 100 /* used, for new entries */ #define MCD_INTRO_TIME 10 /* seconds for the intro */ #define MCD_CDAUDIO_MAX 99 /* maxtracks of the cd (RedBook) */