Blame sb16/fw_writer.c

Packit Service f0277f
/*
Packit Service f0277f
 * firmware writer for SoundBlaster 16 ASP sound cards
Packit Service f0277f
 * Copyright (c) 2006 Clemens Ladisch <clemens@ladisch.de>
Packit Service f0277f
 *
Packit Service f0277f
 *
Packit Service f0277f
 * Permission to use, copy, modify, and distribute this software for any
Packit Service f0277f
 * purpose with or without fee is hereby granted, provided that the above
Packit Service f0277f
 * copyright notice and this permission notice appear in all copies.
Packit Service f0277f
 *
Packit Service f0277f
 * The software is provided "as is" and the author disclaims all warranties
Packit Service f0277f
 * with regard to this software including all implied warranties of
Packit Service f0277f
 * merchantability and fitness. In no event shall the author be liable for
Packit Service f0277f
 * any special, direct, indirect, or consequential damages or any damages
Packit Service f0277f
 * whatsoever resulting from loss of use, data or profits, whether in an
Packit Service f0277f
 * action of contract, negligence or other tortious action, arising out of
Packit Service f0277f
 * or in connection with the use or performance of this software.
Packit Service f0277f
 */
Packit Service f0277f
Packit Service f0277f
#include <stdio.h>
Packit Service f0277f
#include <stdlib.h>
Packit Service f0277f
Packit Service f0277f
#include "sb16_csp_codecs.h"
Packit Service f0277f
Packit Service f0277f
static void write_file(const char *filename,
Packit Service f0277f
		       const unsigned char data[], size_t size)
Packit Service f0277f
{
Packit Service f0277f
	FILE *f;
Packit Service f0277f
Packit Service f0277f
	fprintf(stderr, "writing %s ...\n", filename);
Packit Service f0277f
	f = fopen(filename, "wb");
Packit Service f0277f
	if (!f) {
Packit Service f0277f
		perror("cannot create file");
Packit Service f0277f
		exit(EXIT_FAILURE);
Packit Service f0277f
	}
Packit Service f0277f
	if (fwrite(data, 1, size, f) != size ||
Packit Service f0277f
	    fclose(f) == EOF) {
Packit Service f0277f
		perror("cannot write");
Packit Service f0277f
		exit(EXIT_FAILURE);
Packit Service f0277f
	}
Packit Service f0277f
}
Packit Service f0277f
Packit Service f0277f
int main(void)
Packit Service f0277f
{
Packit Service f0277f
#define WRITE(data) write_file(#data ".csp", data, sizeof data)
Packit Service f0277f
	WRITE(mulaw_main);
Packit Service f0277f
	WRITE(alaw_main);
Packit Service f0277f
	WRITE(ima_adpcm_init);
Packit Service f0277f
	WRITE(ima_adpcm_playback);
Packit Service f0277f
	WRITE(ima_adpcm_capture);
Packit Service f0277f
	return 0;
Packit Service f0277f
}