diff -ru --exclude=configure --exclude=aumix.pot --exclude=Makefile.in aumix-2.7/acconfig.h aumix-2.7+getopt_long/acconfig.h --- aumix-2.7/acconfig.h Mon Jun 26 22:51:42 2000 +++ aumix-2.7+getopt_long/acconfig.h Thu Mar 15 13:45:38 2001 @@ -59,6 +59,13 @@ recommended. */ #undef HAVE_GETMOUSE +/* Define these if you have the GNU getopt_long() function. */ +#undef HAVE_GETOPT +#undef HAVE_GETOPTLIB + +/* Define this if you have getopt.h. */ +#undef HAVE_GETOPT_H + /* Define this if you have the ncurses library and want to use it. */ #undef HAVE_LIBNCURSES diff -ru --exclude=configure --exclude=aumix.pot --exclude=Makefile.in aumix-2.7/config.h.in aumix-2.7+getopt_long/config.h.in --- aumix-2.7/config.h.in Sat Dec 25 08:53:54 1999 +++ aumix-2.7+getopt_long/config.h.in Thu Mar 15 13:52:06 2001 @@ -105,6 +105,13 @@ recommended. */ #undef HAVE_GETMOUSE +/* Define these if you have the GNU getopt_long() function. */ +#undef HAVE_GETOPT +#undef HAVE_GETOPTLIB + +/* Define this if you have getopt.h. */ +#undef HAVE_GETOPT_H + /* Define this if you have the ncurses library and want to use it. */ #undef HAVE_LIBNCURSES diff -ru --exclude=configure --exclude=aumix.pot --exclude=Makefile.in aumix-2.7/configure.in aumix-2.7+getopt_long/configure.in --- aumix-2.7/configure.in Thu Jul 13 04:33:30 2000 +++ aumix-2.7+getopt_long/configure.in Thu Mar 15 13:48:27 2001 @@ -19,6 +19,24 @@ AC_PROG_INSTALL AC_PROG_LN_S +dnl for getopt_long +dnl On Linux, this function is in libc. On FreeBSD, it is in a separate, +dnl optional library. +dnl +AC_CHECK_LIB(gnugetopt, getopt_long, libgnugetopt=on, libgnugetopt=off) +if test $libgnugetopt = on; then + LIBS="-lgnugetopt $LIBS" + AC_DEFINE(HAVE_GETOPTLIB) +fi +AC_CHECK_LIB(c, getopt_long, gnugetopt=on, gnugetopt=off) +if test $gnugetopt = on; then + AC_DEFINE(HAVE_GETOPTLIB) +fi +AC_CHECK_HEADER(getopt.h, getopt_h=on, getopt_h=off) +if test $getopt_h = on; then + AC_DEFINE(HAVE_GETOPT_H) +fi + dnl Checks for libraries. dnl for NetBSD and OpenBSD diff -ru --exclude=configure --exclude=aumix.pot --exclude=Makefile.in aumix-2.7/src/common.c aumix-2.7+getopt_long/src/common.c --- aumix-2.7/src/common.c Thu Jul 13 04:33:30 2000 +++ aumix-2.7+getopt_long/src/common.c Thu Mar 15 22:10:21 2001 @@ -109,6 +109,72 @@ char *mopt; char *scheme_name; extern char *optarg; +/* + struct option { + const char *name; + int has_arg; + int *flag; + int val; + }; + + name is the name of the long option. + + has_arg + is: no_argument (or 0) if the option does not take + an argument, required_argument (or 1) if the option + requires an argument, or optional_argument (or 2) + if the option takes an optional argument. + + flag specifies how results are returned for a long + option. If flag is NULL, then getopt_long() + returns val. (For example, the calling program may + set val to the equivalent short option character.) + Otherwise, getopt_long() returns 0, and flag points + to a variable which is set to val if the option is + found, but left unchanged if the option is not + found. + + val is the value to return, or to load into the + variable pointed to by flag. + + The last element of the array has to be filled with + zeroes. + +*/ +static int optiontestflag =0; + const struct option longopts[] = + { + {"help", no_argument, NULL, OPTHELP}, + {"query", no_argument, NULL, OPTQUERY}, + {"volume", required_argument, NULL, OPT_VOLUME}, + {"bass", required_argument, NULL, OPT_BASS}, + {"treble", required_argument, NULL, OPT_TREBLE}, + {"synth", required_argument, NULL, OPT_SYNTH}, + {"pcm", required_argument, NULL, OPT_PCM}, + {"speaker", required_argument, NULL, OPT_SPEAKER}, + {"line", required_argument, NULL, OPT_LINE}, + {"mic", required_argument, NULL, OPT_MIC}, + {"cd", required_argument, NULL, OPT_CD}, + {"imix", required_argument, NULL, OPT_IMIX}, + {"altpcm", required_argument, NULL, OPT_ALTPCM}, + {"reclev", required_argument, NULL, OPT_RECLEV}, + {"igain", required_argument, NULL, OPT_IGAIN}, + {"ogain", required_argument, NULL, OPT_OGAIN}, + {"line1", required_argument, NULL, OPT_LINE1}, + {"line2", required_argument, NULL, OPT_LINE2}, + {"line3", required_argument, NULL, OPT_LINE3}, + {"digital1", required_argument, NULL, OPT_DIGITAL1}, + {"digital2", required_argument, NULL, OPT_DIGITAL2}, + {"digital3", required_argument, NULL, OPT_DIGITAL3}, + {"phonein", required_argument, NULL, OPT_PHONEIN}, + {"phoneout", required_argument, NULL, OPT_PHONEOUT}, + {"video", required_argument, NULL, OPT_VIDEO}, + {"radio", required_argument, NULL, OPT_RADIO}, + {"monitor", required_argument, NULL, OPT_MONITOR}, + {"version", no_argument, NULL, OPTVERSION}, + {0, 0, 0, 0} + }; + int usage_ok = 1; int main(int argc, char *argv[]) @@ -128,7 +194,7 @@ but we do it anyway because it makes sense for line1, line2 and line3. */ while (TRUE) { - optn = getopt(argc, argv, "hILqSd:f:C:v:b:t:s:w:P:p:l:m:c:x:W:R:r:i:o:1:2:3:"); + optn = getopt_long(argc, argv, "hILqSd:f:C:v:b:t:s:w:P:p:l:m:c:x:W:R:r:i:o:1:2:3:",longopts, 0); if (optn == -1) break; /* Funny, strchr() returns a pointer to char, according to the man page, @@ -142,6 +208,87 @@ } else { usage_ok = 0; switch (optn) { + case OPT_VOLUME: + InitializeAndAdjust(SOUND_MIXER_VOLUME); + break; + case OPT_BASS: + InitializeAndAdjust(SOUND_MIXER_BASS); + break; + case OPT_TREBLE: + InitializeAndAdjust(SOUND_MIXER_TREBLE); + break; + case OPT_SYNTH: + InitializeAndAdjust(SOUND_MIXER_SYNTH); + break; + case OPT_PCM: + InitializeAndAdjust(SOUND_MIXER_PCM); + break; + case OPT_SPEAKER: + InitializeAndAdjust(SOUND_MIXER_SPEAKER); + break; + case OPT_LINE: + InitializeAndAdjust(SOUND_MIXER_LINE); + break; + case OPT_MIC: + InitializeAndAdjust(SOUND_MIXER_MIC); + break; + case OPT_CD: + InitializeAndAdjust(SOUND_MIXER_CD); + break; + case OPT_IMIX: + InitializeAndAdjust(SOUND_MIXER_IMIX); + break; + case OPT_ALTPCM: + InitializeAndAdjust(SOUND_MIXER_ALTPCM); + break; + case OPT_RECLEV: + InitializeAndAdjust(SOUND_MIXER_RECLEV); + break; + case OPT_IGAIN: + InitializeAndAdjust(SOUND_MIXER_IGAIN); + break; + case OPT_OGAIN: + InitializeAndAdjust(SOUND_MIXER_OGAIN); + break; + case OPT_LINE1: + InitializeAndAdjust(SOUND_MIXER_LINE1); + break; + case OPT_LINE2: + InitializeAndAdjust(SOUND_MIXER_LINE2); + break; + case OPT_LINE3: + InitializeAndAdjust(SOUND_MIXER_LINE3); + break; + case OPT_DIGITAL1: + InitializeAndAdjust(SOUND_MIXER_DIGITAL1); + break; + case OPT_DIGITAL2: + InitializeAndAdjust(SOUND_MIXER_DIGITAL2); + break; + case OPT_DIGITAL3: + InitializeAndAdjust(SOUND_MIXER_DIGITAL3); + break; + case OPT_PHONEIN: + InitializeAndAdjust(SOUND_MIXER_PHONEIN); + break; + case OPT_PHONEOUT: + InitializeAndAdjust(SOUND_MIXER_PHONEOUT); + break; + case OPT_VIDEO: + InitializeAndAdjust(SOUND_MIXER_VIDEO); + break; + case OPT_RADIO: + InitializeAndAdjust(SOUND_MIXER_RADIO); + usage_ok = 0; + break; + case OPT_MONITOR: + InitializeAndAdjust(SOUND_MIXER_MONITOR); + break; + case OPTVERSION: + printf("aumix version %s\n", VERSION); + usage_ok = 0; + break; + case OPTQUERY: case 'q': /* query */ optarg = "q"; if (mixer_fd == -1) @@ -184,10 +331,11 @@ interactive = IN_ANY; break; #endif /* defined (HAVE_CURSES) || defined (HAVE_GTK) */ - case 'h': /* Show help. */ + case OPTHELP: /* Show help and exit successfully. */ + case 'h': Usage(EXIT_SUCCESS); break; - default: /* Show help. */ + default: /* Show help and exit with an error. */ Usage(EXIT_FAILURE); } } @@ -279,6 +427,14 @@ exit(EXIT_FAILURE); else return; /* warn */ +} + +void InitializeAndAdjust(int device) +{ + usage_ok = 0; + if (mixer_fd == -1) + ErrorExitWarn(InitializeMixer(device_filename), 'e'); + ErrorExitWarn(SetShowNoninter(device), 'e'); } int LoadSettings(void) diff -ru --exclude=configure --exclude=aumix.pot --exclude=Makefile.in aumix-2.7/src/common.h aumix-2.7+getopt_long/src/common.h --- aumix-2.7/src/common.h Mon Jun 26 22:51:42 2000 +++ aumix-2.7+getopt_long/src/common.h Thu Mar 15 22:11:12 2001 @@ -16,9 +16,38 @@ #endif /* FALSE */ #include #include /* getenv() */ -#ifdef __linux__ +#ifdef HAVE_GETOPT_H +#define _GNU_SOURCE #include /* getopt() */ -#endif /* __linux__ */ +#define OPT_VOLUME 66000 +#define OPT_BASS 66001 +#define OPT_TREBLE 66002 +#define OPT_SYNTH 66003 +#define OPT_PCM 66004 +#define OPT_SPEAKER 66005 +#define OPT_LINE 66006 +#define OPT_MIC 66007 +#define OPT_CD 66008 +#define OPT_IMIX 66009 /* Recording monitor */ +#define OPT_ALTPCM 66010 +#define OPT_RECLEV 66011 /* Recording level */ +#define OPT_IGAIN 66012 /* Input gain */ +#define OPT_OGAIN 66013 /* Output gain */ +#define OPT_LINE1 66014 /* Input source 1 (aux1) */ +#define OPT_LINE2 66015 /* Input source 2 (aux2) */ +#define OPT_LINE3 66016 /* Input source 3 (line) */ +#define OPT_DIGITAL1 66017 /* Digital (input) 1 */ +#define OPT_DIGITAL2 66018 /* Digital (input) 2 */ +#define OPT_DIGITAL3 66019 /* Digital (input) 3 */ +#define OPT_PHONEIN 66020 /* Phone input */ +#define OPT_PHONEOUT 66021 /* Phone output */ +#define OPT_VIDEO 66022 /* Video/TV (audio) in */ +#define OPT_RADIO 66023 /* Radio in */ +#define OPT_MONITOR 66024 /* Monitor (usually mic) volume */ +#define OPTHELP 67000 +#define OPTQUERY 67001 +#define OPTVERSION 67002 +#endif /* HAVE_GETOPT_H */ #include #include #include @@ -97,6 +126,7 @@ int ReadWriteMixer(int device, char *rw, int *left, int *right, char *rp); #endif /* 0 */ int SetShowNoninter(int dev); +void InitializeAndAdjust(int device); int LoadSettings(void); int SaveSettings(void); void I18nInitialize(void); diff -ru --exclude=configure --exclude=aumix.pot --exclude=Makefile.in aumix-2.7/src/gtk.h aumix-2.7+getopt_long/src/gtk.h --- aumix-2.7/src/gtk.h Wed Apr 12 08:02:04 2000 +++ aumix-2.7+getopt_long/src/gtk.h Thu Mar 15 14:00:09 2001 @@ -4,6 +4,7 @@ #include #include #include +#include GdkBitmap *rmask; GdkBitmap *pmask; -- Trevor Johnson http://jpj.net/~trevor/gpgkey.txt _______________________________________________ aumix mailing list - aumix@www.linuxatlax.org http://www.linuxatlax.org/mailman/listinfo/aumix