[comp.sources.x] v11i080: xsunclock - enhacned oclock, Patch2, Part01/01

pfuetz@agd.fhg.de (02/15/91)

Submitted-by: pfuetz@agd.fhg.de
Posting-number: Volume 11, Issue 80
Archive-name: xsunclock/patch2
Patch-To: xsunclock: Volume XXX, Issue XXX

#!/bin/sh
# To unshare, sh or unshar this file
echo clmask.bit 1>&2
sed -e 's/^X//' > clmask.bit <<'E!O!F! clmask.bit'
X#define clock_mask_width 48
X#define clock_mask_height 48
Xstatic char clock_mask_bits[] = {
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x07, 0x00,
X   0x00, 0xf8, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x1f, 0x00,
X   0x00, 0xfe, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x7f, 0x00,
X   0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x01,
X   0xe0, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03,
X   0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07,
X   0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f,
X   0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f,
X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f,
X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f,
X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f,
X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f,
X   0xfc, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f,
X   0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07,
X   0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x03,
X   0xe0, 0xff, 0xff, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x01,
X   0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0x7f, 0x00,
X   0x00, 0xfe, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x1f, 0x00,
X   0x00, 0xf8, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x07, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00};
E!O!F! clmask.bit
echo clock.bit 1>&2
sed -e 's/^X//' > clock.bit <<'E!O!F! clock.bit'
X#define clock_width 48
X#define clock_height 48
X#define clock_x_hot -1
X#define clock_y_hot -1
Xstatic char clock_bits[] = {
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x07, 0x00,
X   0x00, 0xf8, 0x87, 0xf1, 0x0f, 0x00, 0x00, 0xfc, 0x80, 0x81, 0x1f, 0x00,
X   0x00, 0x3e, 0x80, 0x01, 0x3e, 0x00, 0x00, 0x9f, 0x01, 0xc0, 0x7c, 0x00,
X   0x80, 0x8f, 0x01, 0xc0, 0xf8, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x01,
X   0xe0, 0x03, 0x00, 0x00, 0xe0, 0x03, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03,
X   0xf0, 0x00, 0x00, 0x40, 0x80, 0x07, 0xf0, 0x06, 0x00, 0xe0, 0xb0, 0x07,
X   0x78, 0x06, 0x00, 0xf0, 0x30, 0x0f, 0x78, 0x00, 0x00, 0x78, 0x00, 0x0f,
X   0x78, 0x00, 0x00, 0x3c, 0x00, 0x0f, 0x3c, 0x00, 0x00, 0x1e, 0x00, 0x1e,
X   0x3c, 0x00, 0x00, 0x0f, 0x00, 0x1e, 0x3c, 0x00, 0x80, 0x07, 0x00, 0x1e,
X   0x3c, 0x00, 0xc0, 0x03, 0x00, 0x7e, 0xfc, 0x01, 0xc0, 0x03, 0xc0, 0x7f,
X   0xfc, 0x01, 0x80, 0x07, 0xc0, 0x7f, 0x3c, 0x00, 0x00, 0x0f, 0x00, 0x7e,
X   0x3c, 0x00, 0x00, 0x1e, 0x00, 0x1e, 0x3c, 0x00, 0x00, 0x1c, 0x00, 0x1e,
X   0x7c, 0x00, 0x00, 0x08, 0x00, 0x0f, 0x78, 0x00, 0x00, 0x00, 0x00, 0x0f,
X   0x78, 0x06, 0x00, 0x00, 0x30, 0x0f, 0xf0, 0x06, 0x00, 0x00, 0xb0, 0x07,
X   0xf0, 0x00, 0x00, 0x00, 0x80, 0x07, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03,
X   0xe0, 0x03, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x01,
X   0x80, 0x8f, 0x01, 0xc0, 0xf8, 0x00, 0x00, 0x9f, 0x01, 0xc0, 0x7c, 0x00,
X   0x00, 0x3e, 0x80, 0x01, 0x3e, 0x00, 0x00, 0xfc, 0x80, 0x81, 0x1f, 0x00,
X   0x00, 0xf8, 0x87, 0xf1, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x07, 0x00,
X   0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00};
E!O!F! clock.bit
echo libsst.c 1>&2
sed -e 's/^X//' > libsst.c <<'E!O!F! libsst.c'
X/* libsst.c - SPARC sound tools library
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include <fcntl.h>
X#include "libsst.h"
X
X#define AUDBUF 1024
X
Xint
Xsst_open(play_level, record_level)
X    int play_level, record_level;
X    {
X    int fd, i, gr, ger, gx;
X    struct audio_ioctl ai;
X    char *getenv(), *ep;
X
X    fd = open( "/dev/audio", O_RDWR );
X    if ( fd < 0 )
X	{
X	perror( "sst_open: open /dev/audio" );
X	return( 1 );
X	}
X
X    /* Shrink audio device's queue size, to cut down time delay. */
X    i = AUDBUF;
X    if ( ioctl( fd, AUDIOSETQSIZE, &i ) < 0 )
X	{
X	perror( "sst_open: SETQSIZE" );
X	return( 1 );
X	}
X
X    /* Set gains.  -10 <= ger <= 18,  -18 <= gr <= 12,  -18 <= gx <= 12. */
X    if (!play_level) 
X    {
X	play_level = 75;
X	if ( (ep = getenv( "SST_PLAY" )) != NULL )
X	{
X	    play_level = atoi( ep );
X	    if ( play_level < 0 || play_level > 99 )
X	    {
X		fprintf( stderr, "sst_open: SST_PLAY must be between 0 and 99\n" );
X		return( 1 );
X	    }
X	}
X    }
X    if (!record_level) 
X    {
X	record_level = 75;
X	if ( (ep = getenv( "SST_RECORD" )) != NULL )
X	{
X	    record_level = atoi( ep );
X	    if ( record_level < 0 || record_level > 99 )
X	    {
X		fprintf( stderr, "sst_open: SST_RECORD must be between 0 and 99\n" );
X		return( 1 );
X	    }
X	}
X    }
X
X    play_level = play_level * 59 / 100 - 28;
X    ger = play_level / 2;
X    gr = play_level - ger;
X    if ( ger < -10 )
X	{
X	ger = -10;
X	gr = play_level - ger;
X	}
X    if ( gr > 12 )
X	{
X	gr = 12;
X	ger = play_level - gr;
X	}
X    gx = record_level * 31 / 100 - 18;
X    sst_set_gr( fd, gr );
X    sst_set_ger( fd, ger );
X    sst_set_gx( fd, gx );
X
X    /*  Initialize the MMR2 register to send the output to either
X    **  the speaker or the earphone jack, depending on SST_EARPHONES.
X    */
X    ai.control = AUDIO_MAP_MMR2;
X    if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
X	{
X	perror( "sst_open: GETREG MMR2" );
X	return( 1 );
X	}
X    if ( (ep = getenv( "SST_EARPHONES" )) != NULL )
X	ai.data[0] &= ~AUDIO_MMR2_BITS_LS;
X    else
X	ai.data[0] |= AUDIO_MMR2_BITS_LS;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_open: SETREG MMR2" );
X	return( 1 );
X	}
X
X    return fd;
X    }
X
Xvoid
Xsst_close( fd )
Xint fd;
X    {
X    struct audio_ioctl ai;
X
X    ai.control = AUDIO_MAP_MMR1;
X    ai.data[0] = 0;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_close: SETREG MMR1" );
X	}
X    ai.control = AUDIO_MAP_MMR2;
X    ai.data[0] = 0;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_close: SETREG MMR2" );
X	}
X    close( fd );
X    }
X
X/* These are tables of values to be loaded into various gain registers.
X*/
X
Xstatic unsigned char ger_table[][2] = {
X    0xaa,	0xaa,	/* -10db */
X    0x79,	0xac,
X    0x41,	0x99,
X    0x9c,	0xde,
X    0x74,	0x9c,	/* -6db */
X    0x6a,	0xae,
X    0xab,	0xdf,
X    0x64,	0xab,
X    0x2a,	0xbd,
X    0x5c,	0xce,
X    0x00,	0x99,	/* 0db */
X    0x43,	0xdd,
X    0x52,	0xef,
X    0x55,	0x42,
X    0x31,	0xdd,
X    0x43,	0x1f,
X    0x40,	0xdd,	/* 6db */
X    0x44,	0x0f,
X    0x31,	0x1f,
X    0x10,	0xdd,
X    0x41,	0x0f,
X    0x60,	0x0b,
X    0x42,	0x10,	/* 12db */
X    0x11,	0x0f,
X    0x72,	0x00,
X    0x21,	0x10,
X    0x22,	0x00,
X    0x00,	0x0b,
X    0x00,	0x0f,	/* 18db */
X    };
X
X
Xstatic unsigned char gr_gx_table[][2] = {
X    0x8b,	0x7c,	/* -18db */
X    0x8b,	0x35,
X    0x8b,	0x24,
X    0x91,	0x23,
X    0x91,	0x2a,
X    0x91,	0x3b,
X    0x91,	0xf9,	/* -12db */
X    0x91,	0xb6,
X    0x91,	0xa4,
X    0x92,	0x32,
X    0x92,	0xaa,
X    0x93,	0xb3,
X    0x9f,	0x91,	/* -6db */
X    0x9b,	0xf9,
X    0x9a,	0x4a,
X    0xa2,	0xa2,
X    0xaa,	0xa3,
X    0xbb,	0x52,
X    0x08,	0x08,	/* 0db */
X    0x3d,	0xac,
X    0x25,	0x33,
X    0x21,	0x22,
X    0x12,	0xa2,
X    0x11,	0x3b,
X    0x10,	0xf2,	/* 6db */
X    0x02,	0xca,
X    0x01,	0x5a,
X    0x01,	0x12,
X    0x00,	0x32,
X    0x00,	0x13,
X    0x00,	0x0e,	/* 12db */
X    };
X
Xvoid
Xsst_set_ger( fd, value )
Xint fd, value;
X    {
X    struct audio_ioctl ai;
X
X    if ( ( value < -10 ) || ( value > 18 ) )
X	{
X	fprintf( stderr, "sst_set_ger: GER %d out of range\n", value );
X	return;
X	}
X
X    /*  Add 10 to the value to get the index into the table.  */
X    ai.control = AUDIO_MAP_GER;
X    ai.data[0] = ger_table[value + 10][1];
X    ai.data[1] = ger_table[value + 10][0];
X
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_ger: SETREG GER" );
X	}
X
X    ai.control = AUDIO_MAP_MMR1;
X    if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_ger: GETREG MMR1" );
X	}
X    ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GER;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_ger: SETREG MMR1" );
X	}
X    }
X
Xvoid
Xsst_set_gr( fd, value )
Xint fd, value;
X    {
X    struct audio_ioctl ai;
X
X    if ( ( value < -18 ) || ( value > 12 ) )
X	{
X	fprintf( stderr, "sst_set_gr: GR %d out of range\n", value );
X	return;
X	}
X
X    ai.control = AUDIO_MAP_GR;
X    ai.data[0] = gr_gx_table[value + 18][1];
X    ai.data[1] = gr_gx_table[value + 18][0];
X
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_gr: SETREG GR" );
X	}
X
X    ai.control = AUDIO_MAP_MMR1;
X    if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_gr: GETREG MMR1" );
X	}
X    ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GR;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_gr: SETREG MMR1" );
X	}
X    }
X
Xvoid
Xsst_set_gx( fd, value )
Xint fd, value;
X    {
X    struct audio_ioctl ai;
X
X    if ( ( value < -18 ) || ( value > 12 ) )
X	{
X	fprintf( stderr, "sst_set_gx: GX %d out of range\n", value );
X	return;
X	}
X
X    /*  We add 18 to get the index into the table, since entry 0 represents
X    *  -18db.
X    */
X    ai.control = AUDIO_MAP_GX;
X    ai.data[0] = gr_gx_table[value + 18][1];
X    ai.data[1] = gr_gx_table[value + 18][0];
X
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_gx: SETREG GX" );
X	}
X
X    ai.control = AUDIO_MAP_MMR1;
X    if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_gx: GETREG MMR1" );
X	}
X    ai.data[0] |= AUDIO_MMR1_BITS_LOAD_GX;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_set_gx: SETREG MMR1" );
X	}
X    }
X
Xvoid
Xsst_tones( fd, dhz1, dhz2, thz, rhz, usec )
Xint fd, dhz1, dhz2, thz, rhz, usec;
X    {
X    struct audio_ioctl ai;
X    int dval1, dval2, tval, rval;
X    unsigned char oldmmr2, newmmr2;
X
X    if ( dhz1 == 0 )
X	dval1 = 0;
X    else
X	{
X	dval1 = ( dhz1 * 128 + 63 ) / 1000;
X	if ( ( dval1 < 1 ) || ( dval1 > 255 ) )
X	    {
X	    fprintf(stderr, "sst_tones: dhz1 %d out of range\n", dhz1 );
X	    return;
X	    }
X	}
X
X    if ( dhz2 == 0 )
X	dval2 = 0;
X    else
X	{
X	dval2 = ( dhz2 * 128 + 63 ) / 1000;
X	if ( ( dval2 < 1 ) || ( dval2 > 255 ) )
X	    {
X	    fprintf(stderr, "sst_tones: dhz2 %d out of range\n", dhz2 );
X	    return;
X	    }
X	}
X
X    if ( thz == 0 )
X	tval = 0;
X    else
X	{
X	tval = ( thz * 128 + 63 ) / 2000;
X	if ( ( tval < 1 ) || ( tval > 255 ) )
X	    {
X	    fprintf(stderr, "sst_tones: thz %d out of range\n", thz );
X	    return;
X	    }
X	}
X
X    if ( rhz == 0 )
X	rval = 0;
X    else
X	{
X	rval = ( rhz * 128 + 63 ) / 2000;
X	if ( ( rval < 1 ) || ( rval > 255 ) )
X	    {
X	    fprintf(stderr, "sst_tones: rhz %d out of range\n", dhz2 );
X	    return;
X	    }
X	}
X
X    if ( ( dval1 != 0 || dval2 != 0 ) && ( tval != 0 || rval != 0 ) )
X	{
X	fprintf(stderr, "sst_tones: cannot use DTMF and TONE or RINGER at the same time\n", dhz2 );
X	return;
X	}
X
X    if ( tval != 0 && rval != 0 )
X	{
X	fprintf(stderr, "sst_tones: cannot use TONE and RINGER at the same time\n", dhz2 );
X	return;
X	}
X
X    ai.control = AUDIO_MAP_MMR2;
X    if ( ioctl( fd, AUDIOGETREG, &ai ) < 0 )
X	{
X	perror( "sst_tones: GETREG MMR2" );
X	}
X    oldmmr2 = newmmr2 = ai.data[0];
X
X    if ( dval1 != 0 || dval2 != 0 )
X	{
X	newmmr2 |= AUDIO_MMR2_BITS_DTMF;
X	ai.control = AUDIO_MAP_FTGR;
X	ai.data[0] = dval1;
X	ai.data[1] = dval2;
X	if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	    {
X	    perror( "sst_tones: SETREG FTGR" );
X	    }
X	}
X
X    if ( tval != 0 )
X	{
X	newmmr2 |= AUDIO_MMR2_BITS_TONE;
X	ai.control = AUDIO_MAP_FTGR;
X	ai.data[0] = tval;
X	ai.data[1] = 0;
X	if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	    {
X	    perror( "sst_tones: SETREG FTGR" );
X	    }
X	}
X
X    if ( rval != 0 )
X	{
X	newmmr2 |= AUDIO_MMR2_BITS_RINGER;
X	ai.control = AUDIO_MAP_FTGR;
X	ai.data[0] = rval;
X	ai.data[1] = 0;
X	if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	    {
X	    perror( "sst_tones: SETREG FTGR" );
X	    }
X	}
X
X    ai.control = AUDIO_MAP_MMR2;
X    ai.data[0] = newmmr2;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_tones: SETREG MMR2" );
X	}
X
X    usleep( usec );
X
X    ai.data[0] = oldmmr2;
X    if ( ioctl( fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "sst_tones: SETREG MMR2" );
X	}
X    }
X
Xvoid
Xsst_dtmf( fd, dial, usecper, usecpause )
Xint fd, usecper, usecpause;
Xchar *dial;
X    {
X    char *cp;
X
X    for ( cp = dial; *cp != '\0'; cp++ )
X	{
X	switch ( *cp )
X	    {
X	    case '1': sst_tones( fd, 703, 1211, 0, 0, usecper ); break;
X	    case '2': sst_tones( fd, 703, 1336, 0, 0, usecper ); break;
X	    case '3': sst_tones( fd, 703, 1492, 0, 0, usecper ); break;
X	    case 'A': sst_tones( fd, 703, 1648, 0, 0, usecper ); break;
X	    case '4': sst_tones( fd, 773, 1211, 0, 0, usecper ); break;
X	    case '5': sst_tones( fd, 773, 1336, 0, 0, usecper ); break;
X	    case '6': sst_tones( fd, 773, 1492, 0, 0, usecper ); break;
X	    case 'B': sst_tones( fd, 773, 1648, 0, 0, usecper ); break;
X	    case '7': sst_tones( fd, 859, 1211, 0, 0, usecper ); break;
X	    case '8': sst_tones( fd, 859, 1336, 0, 0, usecper ); break;
X	    case '9': sst_tones( fd, 859, 1492, 0, 0, usecper ); break;
X	    case 'C': sst_tones( fd, 859, 1648, 0, 0, usecper ); break;
X	    case '*': sst_tones( fd, 945, 1211, 0, 0, usecper ); break;
X	    case '0': sst_tones( fd, 945, 1336, 0, 0, usecper ); break;
X	    case '#': sst_tones( fd, 945, 1492, 0, 0, usecper ); break;
X	    case 'D': sst_tones( fd, 945, 1648, 0, 0, usecper ); break;
X
X	    case ' ': case '-': case '(': case ')': case '+':
X	    continue;	/* ignore */
X
X	    case ',': usleep( usecper ); break;	/* big pause */
X
X	    default:
X	    fprintf( stderr, "sst_dtmf: unknown dialing code '%c'\n", *cp );
X	    }
X	usleep( usecpause );
X	}
X    }
E!O!F! libsst.c
echo libsst.h 1>&2
sed -e 's/^X//' > libsst.h <<'E!O!F! libsst.h'
X/* libsst.h - include file for SPARC sound tools library
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <sys/ioctl.h>
X#ifdef SUNOS4_1
X#define AUDIO_4_0_3_COMPAT
X#define AUDIO_CHIP
X#include <sbusdev/audio_79C30.h>
X#include <multimedia/libaudio.h>
X#include <multimedia/audio_device.h>
X#else
X#include <sbusdev/audioreg.h>
X#endif
X#include <sun/audioio.h>
X
X#define SAMPLES_PER_SECOND 8192
X
Xint sst_open( );
Xvoid sst_close( /* int fd */ );
X
Xvoid sst_set_ger( /* int fd, value */ );
Xvoid sst_set_gr( /* int fd, value */ );
Xvoid sst_set_gx( /* int fd, value */ );
X
Xvoid sst_tones( /* int fd, dhz1, dhz2, thz, rhz, usec */ );
Xvoid sst_dtmf( /* int fd, char *dial, int usecper, usecpause */ );
E!O!F! libsst.h
echo libst.c 1>&2
sed -e 's/^X//' > libst.c <<'E!O!F! libst.c'
X/* libst.c - portable sound tools library
X*/
X
X/*
X** This routine converts from linear to ulaw.
X**
X** Craig Reese: IDA/Supercomputing Research Center
X** Joe Campbell: Department of Defense
X** 29 September 1989
X**
X** References:
X** 1) CCITT Recommendation G.711  (very difficult to follow)
X** 2) "A New Digital Technique for Implementation of Any
X**     Continuous PCM Companding Law," Villeret, Michel,
X**     et al. 1973 IEEE Int. Conf. on Communications, Vol 1,
X**     1973, pg. 11.12-11.17
X** 3) MIL-STD-188-113,"Interoperability and Performance Standards
X**     for Analog-to_Digital Conversion Techniques,"
X**     17 February 1987
X**
X** Input: Signed 16 bit linear sample
X** Output: 8 bit ulaw sample
X*/
X
X#define ZEROTRAP    /* turn on the trap as per the MIL-STD */
X#define BIAS 0x84   /* define the add-in bias for 16 bit samples */
X#define CLIP 32635
X
Xunsigned char
Xst_linear_to_ulaw( sample )
Xint sample;
X    {
X    static int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
X                               4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
X                               5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
X                               5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
X                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
X                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
X                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
X                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
X                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
X    int sign, exponent, mantissa;
X    unsigned char ulawbyte;
X
X    /* Get the sample into sign-magnitude. */
X    sign = (sample >> 8) & 0x80;		/* set aside the sign */
X    if ( sign != 0 ) sample = -sample;		/* get magnitude */
X    if ( sample > CLIP ) sample = CLIP;		/* clip the magnitude */
X
X    /* Convert from 16 bit linear to ulaw. */
X    sample = sample + BIAS;
X    exponent = exp_lut[( sample >> 7 ) & 0xFF];
X    mantissa = ( sample >> ( exponent + 3 ) ) & 0x0F;
X    ulawbyte = ~ ( sign | ( exponent << 4 ) | mantissa );
X#ifdef ZEROTRAP
X    if ( ulawbyte == 0 ) ulawbyte = 0x02;	/* optional CCITT trap */
X#endif
X
X    return ulawbyte;
X    }
X
X/*
X** This routine converts from ulaw to 16 bit linear.
X**
X** Craig Reese: IDA/Supercomputing Research Center
X** 29 September 1989
X**
X** References:
X** 1) CCITT Recommendation G.711  (very difficult to follow)
X** 2) MIL-STD-188-113,"Interoperability and Performance Standards
X**     for Analog-to_Digital Conversion Techniques,"
X**     17 February 1987
X**
X** Input: 8 bit ulaw sample
X** Output: signed 16 bit linear sample
X*/
X
Xint
Xst_ulaw_to_linear_slow( ulawbyte )
Xunsigned char ulawbyte;
X    {
X    static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
X    int sign, exponent, mantissa, sample;
X
X    ulawbyte = ~ ulawbyte;
X    sign = ( ulawbyte & 0x80 );
X    exponent = ( ulawbyte >> 4 ) & 0x07;
X    mantissa = ulawbyte & 0x0F;
X    sample = exp_lut[exponent] + ( mantissa << ( exponent + 3 ) );
X    if ( sign != 0 ) sample = -sample;
X
X    return sample;
X    }
E!O!F! libst.c
echo libst.h 1>&2
sed -e 's/^X//' > libst.h <<'E!O!F! libst.h'
X/* libst.h - include file for portable sound tools library
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#define SAMPLES_PER_SECOND 8192
X
X#define MINLIN -32768
X#define MAXLIN 32767
X#define LINCLIP(x) do { if ( x < MINLIN ) x = MINLIN ; else if ( x > MAXLIN ) x = MAXLIN; } while ( 0 )
X
Xunsigned char st_linear_to_ulaw( /* int sample */ );
Xint st_ulaw_to_linear_slow( /* unsigned char ulawbyte */ );
X
X/*
X** This macro converts from ulaw to 16 bit linear, faster.
X**
X** Jef Poskanzer
X** 23 October 1989
X**
X** Input: 8 bit ulaw sample
X** Output: signed 16 bit linear sample
X*/
X#define st_ulaw_to_linear(ulawbyte) ulaw_table[ulawbyte]
X
Xstatic int ulaw_table[256] = {
X    -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
X    -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
X    -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
X    -11900, -11388, -10876, -10364,  -9852,  -9340,  -8828,  -8316,
X     -7932,  -7676,  -7420,  -7164,  -6908,  -6652,  -6396,  -6140,
X     -5884,  -5628,  -5372,  -5116,  -4860,  -4604,  -4348,  -4092,
X     -3900,  -3772,  -3644,  -3516,  -3388,  -3260,  -3132,  -3004,
X     -2876,  -2748,  -2620,  -2492,  -2364,  -2236,  -2108,  -1980,
X     -1884,  -1820,  -1756,  -1692,  -1628,  -1564,  -1500,  -1436,
X     -1372,  -1308,  -1244,  -1180,  -1116,  -1052,   -988,   -924,
X      -876,   -844,   -812,   -780,   -748,   -716,   -684,   -652,
X      -620,   -588,   -556,   -524,   -492,   -460,   -428,   -396,
X      -372,   -356,   -340,   -324,   -308,   -292,   -276,   -260,
X      -244,   -228,   -212,   -196,   -180,   -164,   -148,   -132,
X      -120,   -112,   -104,    -96,    -88,    -80,    -72,    -64,
X       -56,    -48,    -40,    -32,    -24,    -16,     -8,      0,
X     32124,  31100,  30076,  29052,  28028,  27004,  25980,  24956,
X     23932,  22908,  21884,  20860,  19836,  18812,  17788,  16764,
X     15996,  15484,  14972,  14460,  13948,  13436,  12924,  12412,
X     11900,  11388,  10876,  10364,   9852,   9340,   8828,   8316,
X      7932,   7676,   7420,   7164,   6908,   6652,   6396,   6140,
X      5884,   5628,   5372,   5116,   4860,   4604,   4348,   4092,
X      3900,   3772,   3644,   3516,   3388,   3260,   3132,   3004,
X      2876,   2748,   2620,   2492,   2364,   2236,   2108,   1980,
X      1884,   1820,   1756,   1692,   1628,   1564,   1500,   1436,
X      1372,   1308,   1244,   1180,   1116,   1052,    988,    924,
X       876,    844,    812,    780,    748,    716,    684,    652,
X       620,    588,    556,    524,    492,    460,    428,    396,
X       372,    356,    340,    324,    308,    292,    276,    260,
X       244,    228,    212,    196,    180,    164,    148,    132,
X       120,    112,    104,     96,     88,     80,     72,     64,
X	56,     48,     40,     32,     24,     16,      8,      0 };
E!O!F! libst.h
echo play.c 1>&2
sed -e 's/^X//' > play.c <<'E!O!F! play.c'
X/* play.c - play a sound file on the speaker
X **
X ** Copyright (C) 1989 by Jef Poskanzer.
X **
X ** Permission to use, copy, modify, and distribute this software and its
X ** documentation for any purpose and without fee is hereby granted, provided
X ** that the above copyright notice appear in all copies and that both that
X ** copyright notice and this permission notice appear in supporting
X ** documentation.  This software is provided "as is" without express or
X ** implied warranty.
X */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <sys/file.h>
X#include <sys/signal.h>
X#include "libsst.h"
X
X#define MYBUF 256
X
Xint sst_fd;
X
Xvoid (*sighup_handler)();
Xvoid (*sigint_handler)();
X
Xplay_sound(sound_file, volume)
X    char *sound_file;
X    int volume;
X{
X    int rrtn, wrtn;
X    unsigned char buf[MYBUF];
X    int file_fd;
X    int sighandler();
X    
X    sst_fd = sst_open(volume,0);
X    sighup_handler = signal( SIGHUP, sighandler );
X    sigint_handler = signal( SIGINT, sighandler );
X    
X    file_fd = open( sound_file, O_RDONLY );
X    if ( file_fd < 0 )
X    {
X	perror( sound_file );
X	return( 1 );
X    }
X#ifdef SUNOS4_1
X    {
X    int err;
X    Audio_hdr Dev_hdr;
X    Audio_hdr File_hdr;
X
X    err = audio_get_play_config( sst_fd, &Dev_hdr );
X
X    if ( err != AUDIO_SUCCESS )
X    {
X	perror( "Not a valid audio device" );
X	return( 1 );
X    }
X
X    err = audio_read_filehdr( file_fd, &File_hdr, (char *) NULL, 0 );
X
X    if ( err != AUDIO_SUCCESS )
X    {
X	perror( "Not a valid audio file" );
X	return( 1 );
X    }
X
X    /* Shameless pilfered from /usr/demo/SOUND/play.c */
X    if ( audio_cmp_hdr(&Dev_hdr, &File_hdr) != 0 ) {
X	if ( audio_drain( sst_fd, FALSE) != AUDIO_SUCCESS) {
X	    perror( "draining audio device" );
X	    return( 1 );
X	}
X    /* Fancy code to reconfigure audio device for given file header omitted */
X    }
X    }
X#endif
X    
X    for ( ; ; )
X    {
X	rrtn = read( file_fd, buf, MYBUF );
X	if ( rrtn < 0 )
X	{
X	    perror( "read" );
X	    return( 1 );
X	}
X	if ( rrtn == 0 )
X	    break;
X	
X	for ( ; ; )
X	{
X	    wrtn = write( sst_fd, buf, rrtn );
X	    if ( wrtn < 0 )
X	    {
X		perror( "write" );
X		return( 1 );
X	    }
X	    if ( wrtn != 0 )
X		break;
X	    usleep( 1000 );
X	}
X	if ( wrtn != rrtn )
X	{
X	    fprintf( stderr, "play: rrtn = %d, wrtn = %d\n", rrtn, wrtn );
X	    return( 1 );
X	}
X    }
X    
X    close(file_fd);
X#ifdef SUNOS4_1
X    if ( audio_drain( sst_fd, FALSE) != AUDIO_SUCCESS) {
X	perror( "draining audio device" );
X	return( 1 );
X    }
X#endif
X    sst_close( sst_fd );
X    (void) signal( SIGHUP, sighup_handler );
X    (void) signal( SIGINT, sigint_handler );
X}
X
Xstatic int
Xsighandler(sig, code, scp, addr)
X    int sig, code;
X    struct sigcontext *scp;
X    char *addr;
X{
X    sst_close( sst_fd );
X    if (sig == SIGHUP && sighup_handler)
X	(*sighup_handler)(sig, code, scp, addr);
X    else if (sigint_handler)
X	(*sigint_handler)(sig, code, scp, addr);
X    exit( 1 );
X}
E!O!F! play.c
echo transform.c 1>&2
sed -e 's/^X//' > transform.c <<'E!O!F! transform.c'
X/*
X * transformed coordinate system objects for X
X */
X
X# include	<X11/Xlib.h>
X# include	"transform.h"
X
Xstatic XPoint *
XTranslatePoints (points, n_points, t, mode)
XTPoint	*points;
Xint	n_points;
XTransform	*t;
Xint	mode;
X{
X	XPoint	*xpoints;
X	int	i;
X	double	xoff = 0.0, yoff = 0.0;
X
X	xpoints = (XPoint *) malloc (n_points * sizeof (*xpoints));
X	if (!xpoints)
X		return 0;
X	for (i = 0; i < n_points; i++) {
X		xpoints[i].x = Xx(points[i].x + xoff, points[i].y + yoff, t);
X		xpoints[i].y = Xy(points[i].x + xoff, points[i].y + yoff, t);
X		if (mode == CoordModePrevious) {
X			xoff += points[i].x;
X			yoff += points[i].y;
X		}
X	}
X	return xpoints;
X}
X
XTFillPolygon (dpy, d, gc, t, points, n_points, shape, mode)
Xregister Display	*dpy;
XDrawable		d;
XGC			gc;
XTransform		*t;
XTPoint			*points;
Xint			n_points;
Xint			shape;
Xint			mode;
X{
X	XPoint	*xpoints;
X
X	xpoints = TranslatePoints (points, n_points, t, mode);
X	if (xpoints) {
X		XFillPolygon (dpy, d, gc, xpoints, n_points, shape,
X				CoordModeOrigin);
X		free (xpoints);
X	}
X}
X
XTDrawArc (dpy, d, gc, t, x, y, width, height, angle1, angle2)
X	register Display	*dpy;
X	Drawable		d;
X	GC			gc;
X	Transform		*t;
X	double			x, y, width, height;
X	int			angle1, angle2;
X{
X	int	xx, xy, xw, xh;
X
X	xx = Xx(x,y,t);
X	xy = Xy(x,y,t);
X	xw = Xwidth (width, height, t);
X	xh = Xheight (width, height, t);
X	if (xw < 0) {
X		xx += xw;
X		xw = -xw;
X	}
X	if (xh < 0) {
X		xy += xh;
X		xh = -xh;
X	}
X	XDrawArc (dpy, d, gc, xx, xy, xw, xh, angle1, angle2);
X}
X
XTFillArc (dpy, d, gc, t, x, y, width, height, angle1, angle2)
X	register Display	*dpy;
X	Drawable		d;
X	GC			gc;
X	Transform		*t;
X	double			x, y, width, height;
X	int			angle1, angle2;
X{
X	int	xx, xy, xw, xh;
X
X	xx = Xx(x,y,t);
X	xy = Xy(x,y,t);
X	xw = Xwidth (width, height, t);
X	xh = Xheight (width, height, t);
X	if (xw < 0) {
X		xx += xw;
X		xw = -xw;
X	}
X	if (xh < 0) {
X		xy += xh;
X		xh = -xh;
X	}
X	XFillArc (dpy, d, gc, xx, xy, xw, xh, angle1, angle2);
X}
X
XSetTransform (t, xx1, xx2, xy1, xy2, tx1, tx2, ty1, ty2)
XTransform	*t;
Xint		xx1, xx2, xy1, xy2;
Xdouble		tx1, tx2, ty1, ty2;
X{
X	t->mx = ((double) xx2 - xx1) / (tx2 - tx1);
X	t->bx = ((double) xx1) - t->mx * tx1;
X	t->my = ((double) xy2 - xy1) / (ty2 - ty1);
X	t->by = ((double) xy1) - t->my * ty1;
X}
E!O!F! transform.c
echo transform.h 1>&2
sed -e 's/^X//' > transform.h <<'E!O!F! transform.h'
X/*
X * header file for transformed coordinate system.  No rotations
X * supported, as elipses cannot be rotated in X.
X */
X
Xtypedef struct _transform {
X	double	mx, bx;
X	double	my, by;
X} Transform;
X
Xtypedef struct _TPoint {
X	double	x, y;
X} TPoint;
X
Xtypedef struct _TRectangle {
X	double	x, y, width, height;
X} TRectangle;
X
X# define Xx(x,y,t)	((int)((t)->mx * (x) + (t)->bx + 0.5))
X# define Xy(x,y,t)	((int)((t)->my * (y) + (t)->by + 0.5))
X# define Xwidth(w,h,t)	((int)((t)->mx * (w) + 0.5))
X# define Xheight(w,h,t)	((int)((t)->my * (h) + 0.5))
X# define Tx(x,y,t)	((((double) (x)) - (t)->bx) / (t)->mx)
X# define Ty(x,y,t)	((((double) (y)) - (t)->by) / (t)->my)
X# define Twidth(w,h,t)	(((double) (w)) / (t)->mx)
X# define Theight(w,h,t)	(((double) (h)) / (t)->my)
E!O!F! transform.h
echo xclock.c 1>&2
sed -e 's/^X//' > xclock.c <<'E!O!F! xclock.c'
X#ifndef lint
Xstatic char rcsid[] = "$XConsortium: xclock.c,v 1.28 89/12/11 15:51:32 kit Exp $";
X#endif /* lint */
X
X/*
X * xclock --  Hacked from Tony Della Fera's much hacked clock program.
X */
X
X/*
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X#include <stdio.h>
X#include <X11/Xatom.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X
X#include "Clock.h"
X#include <X11/Xaw/Cardinals.h>
X#include "clock.bit"
X#include "clmask.bit"
X
Xextern void exit();
Xstatic void quit();
X
X/* Command line options table.  Only resources are entered here...there is a
X   pass over the remaining options after XtParseCommand is let loose. */
X
Xstatic XrmOptionDescRec options[] = {
X{"-chime",	"*clock.chime",		XrmoptionNoArg,		"TRUE"},
X{"-hd",		"*clock.hands",		XrmoptionSepArg,	NULL},
X{"-hands",	"*clock.hands",		XrmoptionSepArg,	NULL},
X{"-hl",		"*clock.highlight",	XrmoptionSepArg,	NULL},
X{"-highlight",	"*clock.highlight",	XrmoptionSepArg,	NULL},
X{"-update",	"*clock.update",	XrmoptionSepArg,	NULL},
X{"-padding",	"*clock.padding",	XrmoptionSepArg,	NULL},
X{"-d",		"*clock.analog",	XrmoptionNoArg,		"FALSE"},
X{"-digital",	"*clock.analog",	XrmoptionNoArg,		"FALSE"},
X{"-analog",	"*clock.analog",	XrmoptionNoArg,		"TRUE"},
X{"-hoursound",        "*clock.hourSound",     XrmoptionSepArg,         NULL},
X{"-quarterpastsound", "*clock.quarterPastSound", XrmoptionSepArg,NULL},
X{"-halfpastsound", "*clock.halfPastSound", XrmoptionSepArg,    NULL},
X{"-quarterofsound", "*clock.quarterOfSound", XrmoptionSepArg,    NULL},
X{"-chimesound",       "*clock.chimeSound",    XrmoptionSepArg,         NULL},
X{"-volume",   "*clock.volume",        XrmoptionSepArg,         "75"},
X};
X
X
Xstatic XtActionsRec xclock_actions[] = {
X    { "quit",	quit },
X};
X
Xstatic Atom wm_delete_window;
X
X/*
X * Report the syntax for calling xclock.
X */
XSyntax(call)
X	char *call;
X{
X	(void) printf ("Usage: %s [-analog] [-bw <pixels>] [-digital]\n", call);
X	(void) printf ("       [-fg <color>] [-bg <color>] [-hd <color>]\n");
X	(void) printf ("       [-hl <color>] [-bd <color>]\n");
X	(void) printf ("       [-fn <font_name>] [-help] [-padding <pixels>]\n");
X	(void) printf ("       [-rv] [-update <seconds>] [-display displayname]\n");
X	(void) printf ("       [-geometry geom]\n");
X       fprintf(stderr,
X"       [-hoursound {file}] [-quarterpastsound {sound}]\n");
X       fprintf(stderr,
X"       [-halfpastsound {file}] [-quarterofsound {sound}]\n");
X       fprintf(stderr,
X"       [-chimes {file}] [-volume {int}]\n\n");
X	exit(1);
X}
X
Xvoid main(argc, argv)
X    int argc;
X    char **argv;
X{
X    Widget toplevel;
X    Arg arg;
X    Pixmap icon_pixmap = None;
X    XtAppContext app_con;
X
X    toplevel = XtAppInitialize (&app_con, "XClock", options, XtNumber(options),
X				&argc, argv, NULL, NULL, ZERO);
X    if (argc != 1) Syntax(argv[0]);
X
X    XtAppAddActions (app_con, xclock_actions, XtNumber(xclock_actions));
X
X    /*
X     * This is a hack so that f.delete will do something useful in this
X     * single-window application.
X     */
X    XtOverrideTranslations(toplevel, 
X		    XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));
X
X    XtSetArg(arg, XtNiconPixmap, &icon_pixmap);
X    XtGetValues(toplevel, &arg, ONE);
X    if (icon_pixmap == None) {
X	arg.value = (XtArgVal)XCreateBitmapFromData(XtDisplay(toplevel),
X				       XtScreen(toplevel)->root,
X				       clock_bits, clock_width, clock_height);
X	XtSetValues (toplevel, &arg, ONE);
X    }
X    XtSetArg(arg, XtNiconMask, &icon_pixmap);
X    XtGetValues(toplevel, &arg, ONE);
X    if (icon_pixmap == None) {
X	arg.value = (XtArgVal)XCreateBitmapFromData(XtDisplay(toplevel),
X				       XtScreen(toplevel)->root,
X				       clock_mask_bits, clock_mask_width, 
X				       clock_mask_height);
X	XtSetValues (toplevel, &arg, ONE);
X    }
X
X    XtCreateManagedWidget ("clock", clockWidgetClass, toplevel, NULL, ZERO);
X    XtRealizeWidget (toplevel);
X    wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW",
X				    False);
X    (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
X			    &wm_delete_window, 1);
X    XtAppMainLoop (app_con);
X}
X
X
Xstatic void quit (w, event, params, num_params)
X    Widget w;
X    XEvent *event;
X    String *params;
X    Cardinal *num_params;
X{
X    if (event->type == ClientMessage &&
X	event->xclient.data.l[0] != wm_delete_window) {
X	XBell (XtDisplay(w), 0);
X	return;
X    }
X    XCloseDisplay (XtDisplay(w));
X    exit (0);
X}
E!O!F! xclock.c
echo xclock.man 1>&2
sed -e 's/^X//' > xclock.man <<'E!O!F! xclock.man'
X.TH XCLOCK 1 "Release 4" "X Version 11"
X.SH NAME
Xxclock - analog / digital clock for X
X.SH SYNOPSIS
X.ta 8n
X\fBxclock\fP	[-\fItoolkitoption\fP ...] [-help] [-analog] [-digital]
X        [-chime] [-hd \fIcolor\fP] [-hl \fIcolor\fP] [-update \fIseconds\fP]
X.br
X	[-padding \fInumber\fP] [-hoursound \fIfilename\fP]
X.br
X        [-quarterpastsound \fIfilename\fP]
X.br
X        [-halfpastsound \fIfilename\fP] [-quarterofsound \fIfilename\fP]
X.br
X        [-chimesound \fIfilename\fP] [-volume \fIpercentage\fP]
X.SH DESCRIPTION
XThe
X.I xclock 
Xprogram displays the time in analog or digital form.  The time is continuously
Xupdated at a frequency which may be specified by the user.  This program is
Xnothing more than a wrapper around the Athena Clock widget. It
Xoptionally plays sounds on the quarter hour and chimes on the
Xhour on a Sun SPARCstation.
X.SH OPTIONS
X.I Xclock
Xaccepts all of the standard X Toolkit command line options along with the 
Xadditional options listed below:
X.TP 8
X.B \-help
XThis option indicates that a brief summary of the allowed options should be
Xprinted on the standard error.
X.TP 8
X.B \-analog 
XThis option indicates that a conventional 12 hour clock face with tick marks
Xand hands should be used.  This is the default.
X.TP 8
X.B \-digital
XThis option indicates that a 24 hour digital clock should be used.
X.TP 8
X.B \-chime
XThis option indicates that the clock should chime 
Xonce on the half hour and twice on the hour.
X.TP 8
X.B \-hd \fIcolor\fP
XThis option specifies the color of the hands on an analog clock.  The default
Xis \fIblack\fP.
X.TP 8
X.B \-hl \fIcolor\fP
XThis option specifies the color of the edges of the hands on an analog clock,
Xand is only useful on color displays.  The default is \fIblack\fP.
X.TP 8
X.B \-update \fIseconds\fP
XThis option specifies the frequency in seconds at which \fIxclock\fP
Xshould update its display.  If the clock is obscured and then exposed,
Xit will be updated immediately.  A value of less than 30 seconds will enable a
Xsecond hand on an analog clock.  The default is 60 seconds.
X.TP 8
X.B \-padding \fInumber\fP
XThis option specifies the width in pixels of the padding 
Xbetween the window border and clock text or picture.  The default is 10
Xon a digital clock and 8 on an analog clock.
X.TP 8
X.B \-hoursound \fIfilename\fB
XChoose sound to play on the hour.
X.TP 8
X.B \-quarterpastsound \fIfilename\fB
XChoose sound to play at quarter past the hour.
X.TP 8
X.B \-halfpastsound \fIfilename\fB
XChoose sound to play at half past the hour.
X.TP 8
X.B \-quarterofsound \fIfilename\fB
XChoose sound to play at fifteen minutes before the hour.
X.TP 8
X.B \-chimeSound \fIfilename\fB
XChoose the sound to play as a chime on the hour. The number of
Xtimes the sound is played corresponds to the hour that the time is.
X.TP 8
X.B \-volume \fIpercentage\fB
XChoose the volume with which all sounds are played. The default
Xis 75%.
X.SH X DEFAULTS
XThis program uses the 
X.I Athena Clock
Xwidget.  It understands all of the core resource names and classes as well as:
X.PP
X.TP 8
X.B width (\fPclass\fB Width)
XSpecifies the width of the clock.  The default for analog clocks is 164
Xpixels; the default for digital clocks is whatever is needed to hold the 
Xclock when displayed in the chosen font.
X.TP 8
X.B height (\fPclass\fB Height)
XSpecifies the height of the clock.  The default for analog clocks is 164
Xpixels; the default for digital clocks is whatever is needed to hold the
Xclock when displayed in the chosen font.
X.TP 8
X.B update (\fPclass\fB Interval)
XSpecifies the frequency in seconds at which the time should be redisplayed.
X.TP 8
X.B foreground (\fPclass\fB Foreground)
XSpecifies the color for the tic marks. The default is depends on whether
X\fIreverseVideo\fP is specified.  If \fIreverseVideo\fP is specified
Xthe default is \fIlwhite\fP, otherwise the default is \fIblack\fP. 
X
X.TP 8
X.B hands (\fPclass\fB Foreground)
XSpecifies the color of the insides of the clock's hands. The default is 
Xdepends on whether
X\fIreverseVideo\fP is specified.  If \fIreverseVideo\fP is specified
Xthe default is \fIlwhite\fP, otherwise the default is \fIblack\fP.
X.TP 8
X.B highlight (\fPclass\fB Foreground)
XSpecifies the color used to highlight the clock's hands. The default is
X depends on whether
X\fIreverseVideo\fP is specified.  If \fIreverseVideo\fP is specified
Xthe default is \fIlwhite\fP, otherwise the default is \fIblack\fP.
X.TP 8
X.B analog (\fPclass\fB Boolean)
XSpecifies whether or not an analog clock should be used instead of a digital
Xone.  The default is True.
X.TP 8
X.B chime (\fPclass\fB Boolean)
XSpecifies whether or not a bell should be rung on the hour and half hour.
X.TP 8
X.B padding (\fPclass\fB Margin)
XSpecifies the amount of internal padding in pixels to be used.  The default is
X8.
X.TP 8
X.B font (\fPclass\fB Font)
XSpecifies the font to be used for the digital clock.  Note that variable width
Xfonts currently will not always display correctly.
X.TP 8
X.B hourSound (\fPclass\fB HourSound)
XSpecifies the sound to play on the hour.
X.TP 8
X.B quarterPastSound (\fPclass\fB QuarterPastSound)
XSpecifies the sound to play at quarter past the hour.
X.TP 8
X.B halfPastSound (\fPclass\fB HalfPastSound)
XSpecifies the sound to play at half past the hour.
X.TP 8
X.B quarterOfSound (\fPclass\fB QuarterOfSound)
XSpecifies the sound to play at fifteen minutes before the hour.
X.TP 8
X.B chimesound (\fPclass\fB ChimeSound)
XSpecifies the sound to play as a chime on the hour. The
Xnumber  of  times the sound is played corresponds to
Xthe hour that the time is.
X.TP 8
X.B volume (\fPclass\fB Volume)
XSpecifies the volume with which all sounds are  played.
X.SH WIDGETS
XIn order to specify resources, it is useful to know the hierarchy of
Xthe widgets which compose \fIxclock\fR.  In the notation below,
Xindentation indicates hierarchical structure.  The widget class name
Xis given first, followed by the widget instance name.
X.sp
X.nf
X.TA .5i 
X.ta .5i 
XXClock  xclock
X	Clock  clock
X.fi
X.sp
X.SH ENVIRONMENT
X.PP
X.TP 8
X.B DISPLAY
Xto get the default host and display number.
X.TP 8
X.B XENVIRONMENT
Xto get the name of a resource file that overrides the global resources
Xstored in the RESOURCE_MANAGER property.
X.SH FILES
X/usr/lib/X11/app-defaults/XClock - specifies required resources
X.SH "SEE ALSO"
XX(1), xrdb(1), time(3C), Athena Clock widget
X.SH BUGS
X.I Xclock
Xbelieves the system clock.
X.PP
XWhen in digital mode, the string should be centered automatically.
X.SH COPYRIGHT
XCopyright 1988, Massachusetts Institute of Technology.
X.br
XSee \fIX(1)\fP for a full statement of rights and permissions.
X.SH AUTHORS
XTony Della Fera (MIT-Athena, DEC)
X.br
XDave Mankins (MIT-Athena, BBN)
X.br
XEd Moy (UC Berkeley)
X.br
XSound hacks by Mike Wagner, Siemens Corporate Research 
Xadded by Matthias Pfuetzner
X.br
XSPARCstation sound interface by Jef Poskanzer
E!O!F! xclock.man
===== end of part 02 ====
The reason I posted this second part a second time is because I got
mail errors while posting this second part for the first time.

Sorry if this is redundant.

Matthias
-----
            @work:            | Matthias Pfuetzner  |         @home:
  ZGDV, Wilhelminenstrasse 7  | 6100 Darmstadt, FRG |  Lichtenbergstrasse 73
    +49 6151 155-164 or -101  \    <- Tel.nr. ->    /     +49 6151 75717
   pfuetzner@agd.fhg.de    pfuetzner@zgdvda.UUCP    XBR1YD3U@DDATHD21.BITNET


--
Dan Heller
------------------------------------------------
O'Reilly && Associates 		      Zyrcom Inc
Senior Writer			       President
argv@ora.com			argv@zipcode.com