mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-29 08:43:42 -04:00
use short options when getopt.h isn't present
This commit is contained in:
parent
f4e8bc9625
commit
f3b6ef46f9
@ -23,13 +23,20 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
char *av0;
|
||||
|
||||
@ -176,8 +183,7 @@ size_t patch_hdr(unsigned char *hdr, size_t hdr_len,
|
||||
|
||||
bytes_per_sample = channel_count * ((sample_bit_length + 7) / 8);
|
||||
|
||||
if (samples == 0)
|
||||
{
|
||||
if (samples == 0) {
|
||||
samples = sample_rate * sec;
|
||||
samples += ((sample_rate / 100) * (us / 10)) / 1000;
|
||||
}
|
||||
@ -227,6 +233,11 @@ static void usage(int exitval)
|
||||
fprintf(stderr,
|
||||
"--samples and --length are mutually exclusive.\n");
|
||||
|
||||
#ifndef HAVE_GETOPT_H
|
||||
fprintf(stderr,
|
||||
"\n\nLong options are not availabl eon this system.\n");
|
||||
#endif
|
||||
|
||||
exit(exitval);
|
||||
}
|
||||
|
||||
@ -249,9 +260,12 @@ int main(int argc, char **argv)
|
||||
else
|
||||
av0 = argv[0];
|
||||
|
||||
while ((c = getopt_long(argc, argv, "+hl:o:s:", longopts, NULL)) != EOF)
|
||||
switch(c)
|
||||
{
|
||||
#ifdef HAVE_GETOPT_H
|
||||
while ((c = getopt_long(argc, argv, "+hl:o:s:", longopts, NULL)) != EOF) {
|
||||
#else
|
||||
while ((c = getopt(argc, argv, "hl:o:s:")) != -1) {
|
||||
#endif
|
||||
switch(c) {
|
||||
case 'h':
|
||||
usage(0);
|
||||
/*NOTREACHED*/
|
||||
@ -274,10 +288,12 @@ int main(int argc, char **argv)
|
||||
} else {
|
||||
us = 0;
|
||||
}
|
||||
|
||||
if ((sec == 0) && (us == 0)) {
|
||||
fprintf(stderr, "%s: Invalid -l argument (zero is not acceptable).\n", av0);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (samples != 0) {
|
||||
fprintf(stderr, "%s: Parameters -s and -l are mutually exclusive.\n", av0);
|
||||
exit(-1);
|
||||
@ -312,6 +328,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "%s: Bad command line option -%c.\n", av0, optopt);
|
||||
usage(-1);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
Loading…
x
Reference in New Issue
Block a user