Beispiel #1
0
void do_conversion(m00data_t* data)
{
	debug_print("Beginning file conversion.\n");
	open_files(data);

	fputs(file_head, data->out_file);

	convert_files(data);

	fputs(file_end, data->out_file);

	close_files(data);
}
Beispiel #2
0
int main(int argc, char **argv)
{
/* Make sure we have an argument. */

	if (argc < 2)
	{
		usage(1);
	}

/* Command line variables (with defaults). */

	int nNewAmplitude = -1;
	BOOL fConvertTo8 = FALSE;
	int nPercent = 95;
	char cbExtension[5] = ".WAO";
	char cbDestinationDir[_MAX_PATH] = "";

	char *pSourceName = NULL;

	for (int i = 1; i < argc; i++)
	{
		char *pArg = argv[i];

		if (pArg[0] == '-')
		{
			switch (pArg[1])
			{
				case 'A':
				{
					nNewAmplitude = atoi(pArg+2);
					break;
				}
				case 'P':
				{
					nPercent = atoi(pArg+2);
					break;
				}
				case 'E':
				{
					strncpy(cbExtension+1, pArg+2, 3);
					cbExtension[4] = '\0';
					break;
				}
				case 'D':
				{
					strcpy(cbDestinationDir, pArg+2);
					break;
				}
				case '8':
				{
					fConvertTo8 = TRUE;
					break;
				}
				default:
				{
					printf("\nIllegal switch '%c'\n", pArg[1]);
					usage(2);
				}
			}
		}
		else
		{
			if (pSourceName == NULL)
			{
				pSourceName = pArg;
			}
			else
			{
				printf("\nToo many filenames.\n");
				usage(3);
			}
		}
	}

	if (pSourceName == NULL)
	{
	/* No source file name! */
		usage(1);
	}

/*
// Allocate the histogram array.
*/

	DWORD __huge *pdwHistogram = NULL;

	if (nNewAmplitude != -1)
	{
		if ((pdwHistogram = (DWORD __huge *)halloc(32768, sizeof(DWORD))) == NULL)
		{
			printf("\nUnable to allocate histogram array.\n");
			exit(4);
		}
	}

	convert_files(pSourceName,
					  nNewAmplitude,
					  nPercent,
					  pdwHistogram,
					  fConvertTo8 ? 8 : 16,
					  cbExtension,
					  cbDestinationDir[0] == '\0' ? NULL : cbDestinationDir);
	exit(0);
	return 0;			// To make compiler happy...
}