view loadtools/bpunify.c @ 964:a96cb97b66a2

ringtools/imy: fix duplicate definition of tdma_durations[] The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>, although the present fix is slightly different from the contributed patch: because main.c doesn't need this tdma_durations[] array at all, let's simply remove the reference to this array from main.c rather than turn it into an extern. I no longer remember my original thought flow that resulted (by mistake) in tdma_durations[] being multiply defined in main.c and durations.c. My intent might have been to define all globals in main.c and have the reference in durations.c be an extern - and I missed that extern - but without clear memory, I have no certainty. In any case, having this data array defined in the same module that fills it (durations.c) is sensible, so let's make it the new way.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 31 Aug 2023 19:38:18 +0000
parents 850b4f066d75
children
line wrap: on
line source

/*
 * fc-buzplay: this module implements the unified 'play' command.
 */

#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

set_bu_volume(vol)
	unsigned vol;
{
	char *targv[3], argbuf[16];

	sprintf(argbuf, "%u", vol - 1);
	targv[0] = "buzlev";
	targv[1] = argbuf;
	targv[2] = 0;
	tpinterf_make_cmd(targv);
	if (tpinterf_send_cmd() < 0)
		return(-1);
	return tpinterf_pass_output(1);
}

cmd_play(argc, argv)
	char **argv;
{
	char *filename, *tail;
	int pwt_mode, rc;
	unsigned global_vol;

	filename = argv[1];
	tail = rindex(filename, '.');
	if (!tail) {
unknown:	fprintf(stderr,
		"unable to intuit format of %s, use play-bu or play-pwt\n",
			filename);
		return(-1);
	}
	if (!strcmp(tail, ".buz"))
		pwt_mode = 0;
	else if (!strcmp(tail, ".pwt"))
		pwt_mode = 1;
	else
		goto unknown;
	if (argv[2]) {
		global_vol = strtoul(argv[2], 0, 0);
		if (global_vol < 1 || global_vol > 64) {
			fprintf(stderr,
				"error: invalid global volume argument\n");
			return(-1);
		}
	} else
		global_vol = 64;
	if (pwt_mode)
		return buzplay_pwt_file(filename, global_vol);
	else {
		rc = set_bu_volume(global_vol);
		if (rc)
			return(rc);
		return buzplay_bu_file(filename);
	}
}