Playing Audio CDs?

Scott Heyano slh at wolf.cs.washington.edu
Fri Jan 25 05:52:29 AEST 1991


Here is the program, as you can see it has been posted before.

#! /bin/sh
##From milton!dali.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!decwrl!ucbvax!mindcrf.UUCP!karish Wed May 02 12:31:52 PDT 1990
##Article 1563 of comp.unix.aix:
##Path: milton!dali.cs.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!decwrl!ucbvax!mindcrf.UUCP!karish
##>From: karish at mindcrf.UUCP
##Newsgroups: comp.unix.aix
##Subject: Motif CD control panel [ LONG ]
##Keywords: CD-ROM music X
##Message-ID: <9008092330.AA22918 at mindcrf.mindcraft.com>
##Date: 9 Aug 90 23:30:49 GMT
##Sender: daemon at ucbvax.BERKELEY.EDU
##Organization: Mindcraft, Inc.
##Lines: 847
##
##
##    [ I saw several requests for a program like this early this
##    summer, but no one posted one.  So, here it is: Bruce Greer's
##    Motif interface for using the IBM CD-ROM drive to play music CDs.
##    Useful for sites like ours that have more CD-ROM drives than
##    info database discs.  Enjoy!   -- Chuck ]
##
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README.play Makefile play.c
# Wrapped by karish at bullwinkle.mindcraft.com on Thu Aug  9 16:13:54 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README.play' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README.play'\"
else
echo shar: Extracting \"'README.play'\" \(1630 characters\)
sed "s/^X//" >'README.play' <<'END_OF_FILE'
X			README.play
X			Version 1.2
X
XPLAY is a motif interface to the CD ROM that allows you to
Xplay audio CDs.  I haven't bothered to figure out permission
Xrestrictions involved with opening the CD device, so at this
Xpoint, you need to be root to run PLAY.  There is nothing
Xfancy about PLAY.  All it really lets you do is pick a track
Xand play it.  Since the first release, I've been shown how to
Xreference tracks beyond #9, so now you can play any track on
Xany CD.  Once you start the player on any particular
Xtrack, it will play until it's done or until the end of the
XCD.
X
XTo build the executable, just type "make" and the Makefile
Xshould do the rest.
X
XThis code comes with no guarantees, warranties, or
Xresponsibilities.  Feel free to distribute it.  I was just
Xtrying to figure out how to use motif.  If you have any
Xuseful ideas, or know where there's more documentation on the
XCD command codes, feel free to enlighten me.
X
X
XBruce Greer	CAMBRIDG(GREER)
XCambridge Porting Center
X(617)576-9324	tie 767-9324
X
X
X-----------
X
X- If the executable is owned by root and has the S_ISUID bit set,
X  (-r-sr-xr-x == 4555) it'll work OK for an ordinary user.
X
X- I've taken the explicit .c.o rule out of the Makefile; the default
X  rule works fine.
X
X- If anyone knows whether the Toshiba CD drive used by IBM supports
X  the pause function or can report the track number currently playing,
X  I'm sure lots of us would like to hear about it.  As things are now,
X  the `track' indication on the control panel just reports the last
X  track selected, not the track that's playing.
X
XChuck Karish
Xkarish at mindcraft.com
X(415) 323-9000
X9 August 1990
END_OF_FILE
if test 1630 -ne `wc -c <'README.play'`; then
    echo shar: \"'README.play'\" unpacked with wrong size!
fi
# end of 'README.play'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(75 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#	Makefile for PLAY
X#
Xall:  play.o
X	cc -o play play.o -lX11 -lXt -lXm -lIM
END_OF_FILE
if test 75 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'play.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'play.c'\"
else
echo shar: Extracting \"'play.c'\" \(30027 characters\)
sed "s/^X//" >'play.c' <<'END_OF_FILE'
X/********************************/
X/*	Motif CD Player		*/
X/*				*/
X/*  Author:  Bruce Greer	*/
X/*	     CAMBRIDG(GREER)	*/
X/*  Tie:     767-9324		*/
X/********************************/
X
X/*	c includes	*/
X#include	<stdio.h>
X#include	"fcntl.h"
X#include	<sys/ioctl.h>
X#include	<sys/cdrom.h>
X
X/*	Xt Intrinsics	*/
X#include	<X11/IntrinsicP.h>
X#include	<X11/Intrinsic.h>
X#include	<X11/ShellP.h>
X#include	<X11/Shell.h>
X#include	<X11/StringDefs.h>
X
X/*	motif includes	*/
X#include	<Xm/Xm.h>
X#include	<Xm/DrawnB.h>
X#include	<Xm/Frame.h>
X#include	<Xm/Form.h>
X#include	<Xm/Label.h>
X#include	<Xm/PushB.h>
X#include	<Xm/PushBG.h>
X#include	<Xm/RowColumn.h>
X#include	<Xm/TextP.h>
X#include	<Xm/Text.h>
X
X/*	global variables	*/
XDisplay		*display;
XWindow		window;
Xint		current_track, current_function;
Xint		top_track=50;
XWidget		trackBox, functionBox;
Xint		fd,rc;
Xextern		errno;
Xuchar		track;
X
Xtypedef enum cd_function {
X		CD_STOP,
X		CD_PLAY
X} ;
X
X#define		CMD_PLAY	0xC0
X#define		CMD_STOP	0xC1
X#define		CMD_EJECT	0xC4
X
X/*	bitmap data		*/
X#define play_width 64
X#define play_height 64
Xstatic char play_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x3f,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
X   0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
X   0xff, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00,
X   0x00, 0xc0, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
X   0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
X   0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x80, 0xff, 0xff,
X   0xff, 0xff, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
X   0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x80, 0xff, 0xff,
X   0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
X   0x00, 0xc0, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
X   0xff, 0x0f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
X   0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x03,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
X
X#define stop_width 64
X#define stop_height 64
Xstatic char stop_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
X   0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
X   0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
X
X#define ahead_width 64
X#define ahead_height 64
Xstatic char ahead_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x40,
X   0x00, 0x00, 0x38, 0x00, 0x00, 0x06, 0x00, 0xc0, 0x00, 0x00, 0x38, 0x00,
X   0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x38, 0x00, 0x00, 0x1e, 0x00, 0xc0,
X   0x03, 0x00, 0x38, 0x00, 0x00, 0x3c, 0x00, 0x80, 0x07, 0x00, 0x38, 0x00,
X   0x00, 0x7c, 0x00, 0x80, 0x0f, 0x00, 0x38, 0x00, 0x00, 0xfc, 0x00, 0x80,
X   0x1f, 0x00, 0x38, 0x00, 0x00, 0xfc, 0x01, 0x80, 0x3f, 0x00, 0x38, 0x00,
X   0x00, 0xfc, 0x03, 0x80, 0x7f, 0x00, 0x38, 0x00, 0x00, 0xfc, 0x07, 0x80,
X   0xff, 0x00, 0x38, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0xff, 0x01, 0x38, 0x00,
X   0x00, 0xf8, 0x1f, 0x00, 0xff, 0x03, 0x38, 0x00, 0x00, 0xf8, 0x3f, 0x00,
X   0xff, 0x07, 0x38, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0xff, 0x0f, 0x38, 0x00,
X   0x00, 0xf8, 0xff, 0x00, 0xff, 0x1f, 0x38, 0x00, 0x00, 0xf8, 0xff, 0x01,
X   0xff, 0x3f, 0x38, 0x00, 0x00, 0xf0, 0xff, 0x03, 0xfe, 0x7f, 0x38, 0x00,
X   0x00, 0xf0, 0xff, 0x07, 0xfe, 0xff, 0x38, 0x00, 0x00, 0xf0, 0xff, 0x0f,
X   0xfe, 0xff, 0x39, 0x00, 0x00, 0xf0, 0xff, 0x0f, 0xfe, 0xff, 0x39, 0x00,
X   0x00, 0xf0, 0xff, 0x07, 0xfe, 0xff, 0x38, 0x00, 0x00, 0xf0, 0xff, 0x03,
X   0xfe, 0x7f, 0x38, 0x00, 0x00, 0xf0, 0xff, 0x01, 0xfe, 0x3f, 0x38, 0x00,
X   0x00, 0xf8, 0xff, 0x00, 0xff, 0x1f, 0x38, 0x00, 0x00, 0xf8, 0x7f, 0x00,
X   0xff, 0x0f, 0x38, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0xff, 0x07, 0x38, 0x00,
X   0x00, 0xf8, 0x1f, 0x00, 0xff, 0x03, 0x38, 0x00, 0x00, 0xf8, 0x0f, 0x00,
X   0xff, 0x01, 0x38, 0x00, 0x00, 0xf8, 0x07, 0x00, 0xff, 0x00, 0x38, 0x00,
X   0x00, 0xfc, 0x03, 0x80, 0x7f, 0x00, 0x38, 0x00, 0x00, 0xfc, 0x01, 0x80,
X   0x3f, 0x00, 0x38, 0x00, 0x00, 0xfc, 0x00, 0x80, 0x1f, 0x00, 0x38, 0x00,
X   0x00, 0x7c, 0x00, 0x80, 0x0f, 0x00, 0x38, 0x00, 0x00, 0x3c, 0x00, 0x80,
X   0x07, 0x00, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x80, 0x03, 0x00, 0x38, 0x00,
X   0x00, 0x0e, 0x00, 0xc0, 0x01, 0x00, 0x38, 0x00, 0x00, 0x06, 0x00, 0xc0,
X   0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x38, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
X
X#define back_width 64
X#define back_height 64
Xstatic char back_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
X   0x02, 0x00, 0x40, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
X   0x00, 0x1c, 0x00, 0x80, 0x03, 0x00, 0x70, 0x00, 0x00, 0x1c, 0x00, 0xc0,
X   0x01, 0x00, 0x38, 0x00, 0x00, 0x1c, 0x00, 0xe0, 0x01, 0x00, 0x3c, 0x00,
X   0x00, 0x1c, 0x00, 0xf0, 0x01, 0x00, 0x3e, 0x00, 0x00, 0x1c, 0x00, 0xf8,
X   0x01, 0x00, 0x3f, 0x00, 0x00, 0x1c, 0x00, 0xfc, 0x01, 0x80, 0x3f, 0x00,
X   0x00, 0x1c, 0x00, 0xfe, 0x01, 0xc0, 0x3f, 0x00, 0x00, 0x1c, 0x00, 0xff,
X   0x00, 0xe0, 0x1f, 0x00, 0x00, 0x1c, 0x80, 0xff, 0x00, 0xf0, 0x1f, 0x00,
X   0x00, 0x1c, 0xc0, 0xff, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x1c, 0xe0, 0xff,
X   0x00, 0xfc, 0x1f, 0x00, 0x00, 0x1c, 0xf0, 0xff, 0x00, 0xfe, 0x1f, 0x00,
X   0x00, 0x1c, 0xf8, 0xff, 0x00, 0xff, 0x1f, 0x00, 0x00, 0x1c, 0xfc, 0x7f,
X   0x80, 0xff, 0x0f, 0x00, 0x00, 0x1c, 0xfe, 0x7f, 0xc0, 0xff, 0x0f, 0x00,
X   0x00, 0x1c, 0xff, 0x7f, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x9c, 0xff, 0x7f,
X   0xf0, 0xff, 0x0f, 0x00, 0x00, 0x9c, 0xff, 0x7f, 0xf0, 0xff, 0x0f, 0x00,
X   0x00, 0x1c, 0xff, 0x7f, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x1c, 0xfe, 0x7f,
X   0xc0, 0xff, 0x0f, 0x00, 0x00, 0x1c, 0xfc, 0xff, 0x80, 0xff, 0x1f, 0x00,
X   0x00, 0x1c, 0xf8, 0xff, 0x00, 0xff, 0x1f, 0x00, 0x00, 0x1c, 0xf0, 0xff,
X   0x00, 0xfe, 0x1f, 0x00, 0x00, 0x1c, 0xe0, 0xff, 0x00, 0xfc, 0x1f, 0x00,
X   0x00, 0x1c, 0xc0, 0xff, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x1c, 0x80, 0xff,
X   0x00, 0xf0, 0x1f, 0x00, 0x00, 0x1c, 0x00, 0xff, 0x01, 0xe0, 0x3f, 0x00,
X   0x00, 0x1c, 0x00, 0xfe, 0x01, 0xc0, 0x3f, 0x00, 0x00, 0x1c, 0x00, 0xfc,
X   0x01, 0x80, 0x3f, 0x00, 0x00, 0x1c, 0x00, 0xf8, 0x01, 0x00, 0x3f, 0x00,
X   0x00, 0x1c, 0x00, 0xf0, 0x01, 0x00, 0x3e, 0x00, 0x00, 0x1c, 0x00, 0xe0,
X   0x01, 0x00, 0x3c, 0x00, 0x00, 0x1c, 0x00, 0xc0, 0x03, 0x00, 0x78, 0x00,
X   0x00, 0x1c, 0x00, 0x80, 0x03, 0x00, 0x70, 0x00, 0x00, 0x1c, 0x00, 0x00,
X   0x03, 0x00, 0x60, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x02, 0x00, 0x40, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
X
X/*	prototype functions	*/
Xvoid	CreateControlWindow();
Xvoid	CreateControlButtons();
XWidget	MyXtInitialize();
Xvoid	DoPlay();
Xvoid	DoStop();
Xvoid	DoAhead();
Xvoid	DoBack();
Xvoid	DoEject();
Xvoid	DoQuit();
Xvoid	cd_cmd();
Xvoid	open_cd();
X
X
X/************************/
X/*	main()		*/
X/************************/
Xvoid main (argc, argv)
X   int	argc;
X   char	**argv;
X{
X   TopLevelShellWidget	shell;
X
X/*  initialize toolkit  */
X   shell = (TopLevelShellWidget)MyXtInitialize (argv);
X
X/*  create Control Window  */
X   CreateControlWindow (shell);
X
X/*  realize widgets	*/
X   XtRealizeWidget (shell);
X
X/*  open cd player  */
X   open_cd ();
X
X/*  main loop  */
X   XtMainLoop();
X
X}	/* end main */
X
X/********************************************************************/
X/*                       MyXtInitialize()                           */
X/********************************************************************/
XWidget MyXtInitialize(argv)
X   char **argv;
X{
X   Widget                  eggShell;
X   Arg                     args[10];
X   int                     windowID = 0, n;
X   int                     argc = 0;
X
X   if (argv[1]) sscanf(argv[1], "%d", &windowID);
X
X   XtToolkitInitialize();
X
X   /* the class name of the application is the name of the application, */
X   /* with the 1st letter changed to uppercase unless it starts with an */
X   /* 'X'.  in that case, the X is capital and the 2nd letter as well.  */
X   /* application_name = argv[0],  application_class = "XMSetClass".    */
X
X   display = XtOpenDisplay(NULL, NULL, argv[0], "Cd", NULL, 0, &argc, argv);
X   if (!display) { fprintf(stderr, "Error open display.\n");  exit(1); }
X
X   n = 0;
X   XtSetArg(args[n], XmNwidth, 330);  n++;
X   XtSetArg(args[n], XmNheight, 150);  n++;
X   XtSetArg(args[n], XmNallowShellResize, True);  n++;
X   eggShell = XtAppCreateShell(argv[0], "Cd", applicationShellWidgetClass, display, args, n);
X/* eggShell = XtCreateApplicationShell(argv[0], applicationShellWidgetClass, args, n); */
X
X   if (windowID) eggShell->core.window = windowID;
X
X   return eggShell;
X}
X/********************************/
X/*	CreateControlWindow	*/
X/********************************/
Xvoid CreateControlWindow (shell)
X   Widget	shell;
X{
X   int		x, y, w=320, h=201, halfHeight;
X   int		n;
X   unsigned int	d;
X   Window	root;
X   Arg		args[10];
X   Widget	frame, form, menubar, statFrame, controlFrame;
X   Widget	statRowCol, statLabel1, statText1;
X   Widget	statLabel2, statText2, quitButton, ejectButton;
X   XmString	text;
X
X/* get window and display values for shell widget */
X   if (window = XtWindow (shell)){
X      XGetGeometry (display, window, &root, &x, &y, &w, &h, &d);
X      }
X
X/* create the Frame widget */
X   n = 0;
X   XtSetArg (args[n], XmNwidth, w);  n++;
X   XtSetArg (args[n], XmNheight, h);  n++;
X   frame = XmCreateFrame (shell, "frame", args, n);
X   XtManageChild (frame);
X
X/* create the Form widget */
X   n = 0;
X   form = XmCreateForm (frame, "form", args, n);
X   XtManageChild (form);
X
X/* create menu bar */
X   n = 0;
X   XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM);  n++;
X   XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM);  n++;
X   XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM);  n++;
X   menubar = XmCreateMenuBar (form, "MenuBar", args, n);
X   XtManageChild (menubar);
X
X/* set up status display */
X   halfHeight = h / 2;
X   n = 0;
X   XtSetArg (args[n], XmNwidth, w);  n++;
X   XtSetArg (args[n], XmNheight, halfHeight);  n++;
X   XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET);  n++;
X   XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM);  n++;
X   XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM);  n++;
X   XtSetArg (args[n], XmNtopWidget, menubar);  n++;
X   statFrame = XmCreateFrame (form, "statFrame", args, n);
X   XtManageChild (statFrame);
X
X/* set up status row/col widget */
X   n = 0;
X   XtSetArg (args[n], XmNorientation, XmHORIZONTAL);  n++;
X   statRowCol = XmCreateRowColumn (statFrame, "statRowCol", args, n);
X   XtManageChild (statRowCol);
X
X/* add eject and quit buttons */
X   n = 0;
X   text = XmStringCreateLtoR ("Eject", XmSTRING_DEFAULT_CHARSET);
X   XtSetArg (args[n], XmNlabelType, XmSTRING);  n++;
X   XtSetArg (args[n], XmNlabelString, text);  n++;
X   ejectButton = XmCreatePushButton (statRowCol, "ejectButton", args, n);
X   XtManageChild (ejectButton);
X   XtAddCallback (ejectButton, XmNactivateCallback, DoEject, NULL);
X   n = 0;
X   text = XmStringCreateLtoR ("Quit", XmSTRING_DEFAULT_CHARSET);
X   XtSetArg (args[n], XmNlabelType, XmSTRING);  n++;
X   XtSetArg (args[n], XmNlabelString, text);  n++;
X   quitButton = XmCreatePushButton (statRowCol, "quitButton", args, n);
X   XtManageChild (quitButton);
X   XtAddCallback (quitButton, XmNactivateCallback, DoQuit, NULL);
X
X/* put in the status labels and text */
X   n = 0;
X   text = XmStringCreateLtoR ("Track", XmSTRING_DEFAULT_CHARSET);
X   XtSetArg (args[n], XmNlabelType, XmSTRING);  n++;
X   XtSetArg (args[n], XmNleftOffset, 5);  n++;
X   XtSetArg (args[n], XmNlabelString, text);  n++;
X   statLabel1 = XmCreateLabel (statRowCol, "statLabel1", args, n);
X   n = 0;
X   XtSetArg (args[n], XmNeditable, FALSE);  n++;
X   XtSetArg (args[n], XmNcolumns, 2);  n++;
X   XtSetArg (args[n], XmNautoShowCursorPosition, FALSE);  n++;
X   XtSetArg (args[n], XmNcursorPositionVisible, FALSE);  n++;
X   statText1 = XmCreateText (statRowCol, "statText1", args, n);
X   XmTextSetString (statText1, " 0");
X   XtManageChild (statLabel1);
X   XtManageChild (statText1);
X   trackBox = statText1;
X
X   n = 0;
X   text = XmStringCreateLtoR ("Function", XmSTRING_DEFAULT_CHARSET);
X   XtSetArg (args[n], XmNleftOffset, 5);  n++;
X   XtSetArg (args[n], XmNlabelType, XmSTRING);  n++;
X   XtSetArg (args[n], XmNlabelString, text);  n++;
X   statLabel2 = XmCreateLabel (statRowCol, "statLabel2", args, n);
X   n = 0;
X   XtSetArg (args[n], XmNeditable, FALSE);  n++;
X   XtSetArg (args[n], XmNcolumns, 4);  n++;
X   XtSetArg (args[n], XmNautoShowCursorPosition, FALSE);  n++;
X   XtSetArg (args[n], XmNcursorPositionVisible, FALSE);  n++;
X   statText2 = XmCreateText (statRowCol, "statText2", args, n);
X   XmTextSetString (statText2, "STOP");
X   XtManageChild (statLabel2);
X   XtManageChild (statText2);
X   functionBox = statText2;
X
X/* set up control button frame */
X   n = 0;
X   XtSetArg (args[n], XmNwidth, w);  n++;
X   XtSetArg (args[n], XmNheight, halfHeight);  n++;
X   XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET);  n++;
X   XtSetArg (args[n], XmNtopWidget, statFrame);  n++;
X   controlFrame = XmCreateFrame (form, "controlFrame", args, n);
X   XtManageChild (controlFrame);
X
X/* create control buttons */
X   CreateControlButtons (controlFrame);
X
X}	/* end CreateControlWindow */
X
X
X/********************************/
X/*	CreateControlButtons	*/
X/********************************/
Xvoid CreateControlButtons (frame)
X   Widget	frame;
X{
X   Widget	controlRowCol, backButton, stopButton, playButton;
X   Widget	aheadButton;
X   Pixmap	playPixmap, stopPixmap, aheadPixmap, backPixmap;
X   int		n;
X   Arg		args[10];
X
X/* set up control row/col widget */
X   n = 0;
X   XtSetArg (args[n], XmNorientation, XmHORIZONTAL);  n++;
X   controlRowCol = XmCreateRowColumn (frame, "controlRowCol", args, n);
X   XtManageChild (controlRowCol);
X
X/* create control pixmaps */
X   stopPixmap = XCreatePixmapFromBitmapData (display, 
X	DefaultRootWindow(display), stop_bits, stop_width, stop_height,
X	BlackPixel(display,DefaultScreen(display)),
X	frame->core.background_pixel,
X	DefaultDepth(display,DefaultScreen(display)));
X   
X   backPixmap = XCreatePixmapFromBitmapData (display, 
X	DefaultRootWindow(display), back_bits, back_width, back_height,
X	BlackPixel(display,DefaultScreen(display)),
X	frame->core.background_pixel,
X	DefaultDepth(display,DefaultScreen(display)));
X   
X   aheadPixmap = XCreatePixmapFromBitmapData (display, 
X	DefaultRootWindow(display), ahead_bits, ahead_width, ahead_height,
X	BlackPixel(display,DefaultScreen(display)),
X	frame->core.background_pixel,
X	DefaultDepth(display,DefaultScreen(display)));
X   
X   playPixmap = XCreatePixmapFromBitmapData (display, 
X	DefaultRootWindow(display), play_bits, play_width, play_height,
X	BlackPixel(display,DefaultScreen(display)),
X	frame->core.background_pixel,
X	DefaultDepth(display,DefaultScreen(display)));
X
X/* create button widgets */
X   n = 0;
X   XtSetArg (args[n], XmNwidth, back_width);  n++;
X   XtSetArg (args[n], XmNheight, back_height);  n++;
X   XtSetArg (args[n], XmNlabelPixmap, backPixmap);  n++;
X   XtSetArg (args[n], XmNlabelType, XmPIXMAP);  n++;
X   XtSetArg (args[n], XmNpushButtonEnabled, TRUE);  n++;
X   XtSetArg (args[n], XmNshadowThickness, 5);  n++;
X   backButton = XmCreateDrawnButton (controlRowCol, "backButton", args, n);
X   XtManageChild (backButton);
X   XtAddCallback (backButton, XmNactivateCallback, DoBack, NULL);
X   
X   n = 0;
X   XtSetArg (args[n], XmNwidth, stop_width);  n++;
X   XtSetArg (args[n], XmNheight, stop_height);  n++;
X   XtSetArg (args[n], XmNlabelPixmap, stopPixmap);  n++;
X   XtSetArg (args[n], XmNlabelType, XmPIXMAP);  n++;
X   XtSetArg (args[n], XmNpushButtonEnabled, TRUE);  n++;
X   XtSetArg (args[n], XmNshadowThickness, 5);  n++;
X   stopButton = XmCreateDrawnButton (controlRowCol, "stopButton", args, n);
X   XtManageChild (stopButton);
X   XtAddCallback (stopButton, XmNactivateCallback, DoStop, NULL);
X   
X   n = 0;
X   XtSetArg (args[n], XmNwidth, play_width);  n++;
X   XtSetArg (args[n], XmNheight, play_height);  n++;
X   XtSetArg (args[n], XmNlabelPixmap, playPixmap);  n++;
X   XtSetArg (args[n], XmNlabelType, XmPIXMAP);  n++;
X   XtSetArg (args[n], XmNpushButtonEnabled, TRUE);  n++;
X   XtSetArg (args[n], XmNshadowThickness, 5);  n++;
X   playButton = XmCreateDrawnButton (controlRowCol, "playButton", args, n);
X   XtManageChild (playButton);
X   XtAddCallback (playButton, XmNactivateCallback, DoPlay, NULL);
X   
X   n = 0;
X   XtSetArg (args[n], XmNwidth, ahead_width);  n++;
X   XtSetArg (args[n], XmNheight, ahead_height);  n++;
X   XtSetArg (args[n], XmNlabelPixmap, aheadPixmap);  n++;
X   XtSetArg (args[n], XmNlabelType, XmPIXMAP);  n++;
X   XtSetArg (args[n], XmNpushButtonEnabled, TRUE);  n++;
X   XtSetArg (args[n], XmNshadowThickness, 5);  n++;
X   aheadButton = XmCreateDrawnButton (controlRowCol, "aheadButton", args, n);
X   XtManageChild (aheadButton);
X   XtAddCallback (aheadButton, XmNactivateCallback, DoAhead, NULL);
X
X}	/* end of CreateControlButtons */
X
X/************************/
X/*	DoStop		*/
X/************************/
Xvoid DoStop(widget, client_data, call_data)
X   Widget	widget;
X   caddr_t	client_data;
X   caddr_t	call_data;
X{
X/* stop player */
X   if (current_function == CD_PLAY)
X      cd_cmd (current_track, CMD_STOP);
X
X/* set current function to stop */
X   current_function = CD_STOP;
X   XmTextSetString (functionBox, "STOP");
X}	/* end of DoStop */
X
X/************************/
X/*	DoAhead		*/
X/************************/
Xvoid DoAhead(widget, client_data, call_data)
X   Widget	widget;
X   caddr_t	client_data;
X   caddr_t	call_data;
X{
Xchar	track_string[5];
X
X/* increment current track */
X   if (current_track < top_track)
X      current_track++;
X   sprintf (track_string, "%2d", current_track);
X   XmTextSetString (trackBox, track_string);
X   if (current_function == CD_PLAY)
X      cd_cmd (current_track, CMD_PLAY);
X}	/* end of DoAhead */
X
X/************************/
X/*	DoBack		*/
X/************************/
Xvoid DoBack(widget, client_data, call_data)
X   Widget	widget;
X   caddr_t	client_data;
X   caddr_t	call_data;
X{
Xchar	track_string[5];
X
X/* decrement current track */
X   if (current_track > 1)
X      current_track--;
X   sprintf (track_string, "%2d", current_track);
X   XmTextSetString (trackBox, track_string);
X   if (current_function == CD_PLAY)
X      cd_cmd (current_track, CMD_PLAY);
X}	/* end of DoBack */
X
X/************************/
X/*	DoEject		*/
X/************************/
Xvoid DoEject(widget, client_data, call_data)
X   Widget	widget;
X   caddr_t	client_data;
X   caddr_t	call_data;
X{
Xchar	track_string[5];
X
X   current_function = CD_STOP;
X   current_track = 0;
X   sprintf (track_string, "%2d", current_track);
X   XmTextSetString (functionBox, "STOP");
X   cd_cmd (current_track, CMD_EJECT);
X   top_track = 50;
X}	/* end of DoEject */
X
X/************************/
X/*	DoQuit		*/
X/************************/
Xvoid DoQuit(widget, client_data, call_data)
X   Widget	widget;
X   caddr_t	client_data;
X   caddr_t	call_data;
X{
Xexit(0);
X}	/* end of DoQuit */
X
X/************************/
X/*	DoPlay		*/
X/************************/
Xvoid DoPlay(widget, client_data, call_data)
X   Widget	widget;
X   caddr_t	client_data;
X   caddr_t	call_data;
X{
Xchar	track_string[5];
X
X/* set current function to play */
X   current_function = CD_PLAY;
X   XmTextSetString (functionBox, "PLAY");
X
X
X/* play current track */
X   if (!current_track)
X      current_track = 1; 
X   sprintf (track_string, "%2d", current_track);
X   XmTextSetString (trackBox, track_string);
X
X   cd_cmd (current_track, CMD_PLAY);
X}	/* end of DoPlay */
X
X 
Xint pass_thru(track, cmd)
Xuchar track;
Xuchar cmd;
X{
X	uchar			adj_track;
X	char			track_string[5];
X        struct sc_iocmd         pt;
X        char                    menuopt;
X        int                     i, rc;
X	static int		retry;
X 
X	/* Convert decimal number to hex  10 -> 16 11-> 17 */
X	adj_track = (track / 10) * 16 + (track % 10);
X
X        /* Issue 2 test unit ready's */
X        for (i=0 ; i<2 ; i++) {
X                pt.command_length = 0x06;
X                pt.scsi_cdb[0] = 0x00;
X                pt.scsi_cdb[1] = 0x00;
X                pt.scsi_cdb[2] = 0x00;
X                pt.scsi_cdb[3] = 0x00;
X                pt.scsi_cdb[4] = 0x00;
X                pt.scsi_cdb[5] = 0x00;
X                pt.flags              = 0x00;
X                pt.buffer             = 0x00;
X                pt.data_length        = 0x00;
X                pt.timeout_value      = 0x05;
X                pt.status_validity    = 0x00;
X                pt.scsi_bus_status    = 0x00;
X                pt.adapter_status     = 0x00;
X                rc = ioctl(fd, CDIOCMD, &pt);
X        }
X	if (retry) {
X	   retry = FALSE;
X	   return (rc);
X	   }
X        if (rc == -1) {
X		retry = TRUE;
X   		XmTextSetString (functionBox, "WAIT");
X		XFlush (display);
X		sleep (3);
X		if ((rc = pass_thru(track, cmd)) == -1)
X   			XmTextSetString (functionBox, "NOCD");
X		else {
X		     if (current_function == CD_PLAY)
X   			XmTextSetString (functionBox, "PLAY");
X		     else
X   			XmTextSetString (functionBox, "STOP");
X		     rc = pass_thru(track, cmd);
X		     }
X                return(rc);
X        }
X        /* issue the cd command */
X        pt.command_length = 0x0A;
X        pt.scsi_cdb[0] = cmd;
X        pt.scsi_cdb[1] = 0x01;    /* was 0x01 */
X        pt.scsi_cdb[2] = adj_track;
X        for (i = 3 ; i < 9 ; i ++) {
X                pt.scsi_cdb[i] = 0x00;
X        }
X        pt.scsi_cdb[9] = 0x80;
X        pt.flags              = SC_ASYNC;
X        pt.buffer             = 0x00;
X        pt.data_length        = 0x00;
X        pt.timeout_value      = 0x05;
X        pt.status_validity    = 0x00;
X        pt.scsi_bus_status    = 0x00;
X        pt.adapter_status     = 0x00;
X        rc = ioctl(fd, CDIOCMD, &pt);
X        if (rc == -1) {
X#ifdef DEBUG
X                printf("\nioctl failed.  errno = %d", errno);
X                printf("\n\nstatus_validity = %.2X",pt.status_validity);
X                printf("\nscsi_bus_status = %.2X", pt.scsi_bus_status);
X                printf("\nadapter_status = %.2X", pt.adapter_status);
X#endif
X
X		current_track--;
X		top_track = current_track;
X		sprintf (track_string, "%2d", current_track);
X		XmTextSetString (trackBox, track_string);
X		cd_cmd (current_track, CMD_PLAY);
X        }
X        return(rc);
X}
X 
Xvoid cd_cmd(track, cmd)
Xint track;
Xuchar cmd;
X{
X   if (track != -1) {
X      rc = pass_thru(track, cmd);
X      }
X   else
X      printf("\nError in track number.\n");
X}
X
Xvoid open_cd ()
X{
X/* open cd player */
X   if ( (fd = openx("/dev/rcd0", O_RDONLY, NULL, SC_DIAGNOSTIC)) < 0) {
X		fprintf (stderr, "Failed to open /dev/rcd0\n");
X		exit (0);
X                    return; }
X}	/* end of open_cd */
END_OF_FILE
if test 30027 -ne `wc -c <'play.c'`; then
    echo shar: \"'play.c'\" unpacked with wrong size!
fi
# end of 'play.c'
fi
echo shar: End of shell archive.
exit 0



More information about the Comp.unix.aix mailing list