This is set-vol.c in view mode; [Download] [Up]
/*
* Displays and sets the mute status and volume on a NeXT.
*
* Version: 1.1
* Christopher J. Kane (kane@cs.purdue.edu)
*
* Released into the public domain, October 19, 1992.
*/
#include <sound/sound.h>
#include <stdio.h>
extern volatile void exit(int);
extern int getopt(int, char **, char *);
extern char *optarg;
#define SETTORANGE(v,min,max) v = (v<min?min:(v>max?max:v))
#define MINVOL 0
#define MAXVOL 43
#define USAGE \
"Usage: %s [-s] [-m | -M] [-l <left_vol>] [-r <right_vol>] [-v <vol>]\n"\
"\tDisplays and optionally sets the mute and volume settings.\n" \
"\tOptions: (in any order)\n" \
"\t -s silent mode; settings are not displayed\n" \
"\t -m unmute external speakers\n" \
"\t -M mute external speakers\n" \
"\t -l set volume of left speaker\n" \
"\t -r set volume of right speaker\n" \
"\t -v set both speakers; shorthand for '-l <vol> -r <vol>'\n" \
"\tIf both -m and -M are specified, the rightmost of them has effect.\n"\
"\tThe parameters <left_vol>, <right_vol>, and <vol> should be\n" \
"\tintegers in the range %i (minimum volume) to %i (maximum volume).\n\n"
#define OUTSTR "\nExternal speaker is%s muted.\n"\
"Left speaker volume: %i\n" \
"Right speaker volume: %i\n\n"
void main(int argc, char *argv[])
{
int mute, left, right, silent=0, ret;
if ((ret=SNDGetMute(&mute)) != SND_ERR_NONE) {
fprintf(stderr, "%s\n", SNDSoundError(ret));
exit(1);
}
SNDGetVolume(&left, &right);
if (argc > 1) {
int c;
while ((c = getopt(argc, argv, "mMsl:r:v:h"))!=EOF)
switch (c) {
case 'm':
mute = 1; break;
case 'M':
mute = 0; break;
case 's':
silent = 1; break;
case 'l':
left = atoi(optarg); break;
case 'r':
right = atoi(optarg); break;
case 'v':
left = right = atoi(optarg); break;
case 'h':
default :
fprintf(stderr, USAGE, argv[0], MINVOL,
MAXVOL);
exit(1);
}
SETTORANGE(left, MINVOL, MAXVOL);
SETTORANGE(right, MINVOL, MAXVOL);
SNDSetMute(mute);
SNDSetVolume(left, right);
}
if (!silent)
printf(OUTSTR, (mute?" NOT":""), left, right);
exit(0);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.