⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utils.tpl

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 TPL
📖 第 1 页 / 共 2 页
字号:
		} ;	puts ("\n\n") ;	for (k = 0 ; k < length ; k+= sizeof (buffer))	{	readcount = fread (buffer, 1, sizeof (buffer), file) ;		printf ("%08lx : ", SF_COUNT_TO_LONG (offset + k)) ;		for (m = 0 ; m < readcount ; m++)			printf ("%02x ", buffer [m] & 0xFF) ;		for (m = readcount ; m < SIGNED_SIZEOF (buffer) ; m++)			printf ("   ") ;		printf ("  ") ;		for (m = 0 ; m < readcount ; m++)		{	ch = isprint (buffer [m]) ? buffer [m] : '.' ;			putchar (ch) ;			} ;		if (readcount < SIGNED_SIZEOF (buffer))			break ;		putchar ('\n') ;		} ;	puts ("\n") ;	fclose (file) ;} /* hexdump_file */voiddump_log_buffer (SNDFILE *file){	static char	buffer [LOG_BUFFER_SIZE] ;	int			count ;	memset (buffer, 0, LOG_BUFFER_SIZE) ;	/* Get the log buffer data. */	count = sf_command	(file, SFC_GET_LOG_INFO, buffer, LOG_BUFFER_SIZE) ;	if (strlen (buffer) < 1)		puts ("Log buffer empty.\n") ;	else		puts (buffer) ;	return ;} /* dump_log_buffer */SNDFILE *test_open_file_or_die (const char *filename, int mode, SF_INFO *sfinfo, int allow_fd, int line_num){	static int count = 0 ;	SNDFILE *file ;	const char *modestr, *func_name ;	int oflags = 0, omode = 0 ;	/*	** Need to test both sf_open() and sf_open_fd().	** Do so alternately.	*/	switch (mode)	{	case SFM_READ :				modestr = "SFM_READ" ;				oflags = O_RDONLY ;				omode = 0 ;				break ;		case SFM_WRITE :				modestr = "SFM_WRITE" ;				oflags = O_WRONLY | O_CREAT | O_TRUNC ;				omode = S_IRUSR | S_IWUSR | S_IRGRP ;				break ;		case SFM_RDWR :				modestr = "SFM_RDWR" ;				oflags = O_RDWR | O_CREAT ;				omode = S_IRUSR | S_IWUSR | S_IRGRP ;				break ;		default :				printf ("\n\nLine %d: Bad mode.\n", line_num) ;				fflush (stdout) ;				exit (1) ;		} ;#if (defined (__CYGWIN__) || defined (WIN32) || defined (_WIN32))	/* Stupid fscking windows. */	oflags |= O_BINARY ;#endif	if (allow_fd && ((++count) & 1) == 1)	{	int fd ;		if (omode == 0)			fd = open (filename, oflags) ;		else			fd = open (filename, oflags, omode) ;		if (fd < 0)		{	perror ("open") ;			exit (1) ;			} ;		func_name = "sf_open_fd" ;		file = sf_open_fd (fd, mode, sfinfo, SF_TRUE) ;		}	else	{	func_name = "sf_open" ;		file = sf_open (filename, mode, sfinfo) ;		} ;	if (file == NULL)	{	printf ("\n\nLine %d: %s (%s) failed : %s\n\n", line_num, func_name, modestr, sf_strerror (NULL)) ;		dump_log_buffer (file) ;		exit (1) ;		} ;	return file ;} /* test_open_file_or_die */voidtest_read_write_position_or_die (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos){	sf_count_t pos ;	/* Check the current read position. */	if (read_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_READ)) != read_pos)	{	printf ("\n\nLine %d ", line_num) ;		if (pass > 0)			printf ("(pass %d): ", pass) ;		printf ("Read position (%ld) should be %ld.\n", SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (read_pos)) ;		exit (1) ;		} ;	/* Check the current write position. */	if (write_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_WRITE)) != write_pos)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : Write position (%ld) should be %ld.\n",						SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (write_pos)) ;		exit (1) ;		} ;	return ;} /* test_read_write_position */voidtest_seek_or_die (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_pos, int channels, int line_num){	sf_count_t	position ;	const char	*channel_name, *whence_name ;	switch (whence)	{	case SEEK_SET :				whence_name = "SEEK_SET" ;				break ;		case SEEK_CUR :				whence_name = "SEEK_CUR" ;				break ;		case SEEK_END :				whence_name = "SEEK_END" ;				break ;		/* SFM_READ */		case SEEK_SET | SFM_READ :				whence_name = "SFM_READ | SEEK_SET" ;				break ;		case SEEK_CUR | SFM_READ :				whence_name = "SFM_READ | SEEK_CUR" ;				break ;		case SEEK_END | SFM_READ :				whence_name = "SFM_READ | SEEK_END" ;				break ;		/* SFM_WRITE */		case SEEK_SET | SFM_WRITE :				whence_name = "SFM_WRITE | SEEK_SET" ;				break ;		case SEEK_CUR | SFM_WRITE :				whence_name = "SFM_WRITE | SEEK_CUR" ;				break ;		case SEEK_END | SFM_WRITE :				whence_name = "SFM_WRITE | SEEK_END" ;				break ;		default :				printf ("\n\nLine %d: bad whence parameter.\n", line_num) ;				exit (1) ;		} ;	channel_name = (channels == 1) ? "Mono" : "Stereo" ;	if ((position = sf_seek (file, offset, whence)) != new_pos)	{	printf ("\n\nLine %d : %s : sf_seek (file, %ld, %s) returned %ld (should be %ld).\n\n",					line_num, channel_name, SF_COUNT_TO_LONG (offset), whence_name,					SF_COUNT_TO_LONG (position), SF_COUNT_TO_LONG (new_pos)) ;		exit (1) ;		} ;} /* test_seek_or_die */[+ FOR io_operation +][+ FOR io_type +]voidtest_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, int pass, [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num){	sf_count_t count ;	if ((count = sf_[+ (get "op_element") +]_[+ (get "io_element") +] (file, test, [+ (get "count_name") +])) != [+ (get "count_name") +])	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_[+ (get "op_element") +]_[+ (get "io_element") +] failed with short [+ (get "op_element") +] (%ld => %ld).\n",						SF_COUNT_TO_LONG ([+ (get "count_name") +]), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_[+ (get "op_element") +]_[+ (get "io_element") +] */[+ ENDFOR io_type +][+ ENDFOR io_operation +]voiddelete_file (int format, const char *filename){	char rsrc_name [512], *fname ;	unlink (filename) ;	if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SD2)		return ;	/*	** Now try for a resource fork stored as a separate file.	** Grab the un-adulterated filename again.	*/	snprintf (rsrc_name, sizeof (rsrc_name), "%s", filename) ;	if ((fname = strrchr (rsrc_name, '/')) != NULL)		fname ++ ;	else if ((fname = strrchr (rsrc_name, '\\')) != NULL)		fname ++ ;	else		fname = rsrc_name ;	memmove (fname + 2, fname, strlen (fname) + 1) ;	fname [0] = '.' ;	fname [1] = '_' ;	unlink (rsrc_name) ;} /* delete_file */static int allowed_open_files = -1;voidcount_open_files (void){#if (defined (WIN32) || defined (_WIN32))	return ;#else	int k, count = 0 ;	struct stat statbuf ;	if (allowed_open_files > 0)		return ;	for (k = 0 ; k < 1024 ; k++)		if (fstat (k, &statbuf) == 0)			count ++ ;	allowed_open_files = count ;#endif} /* count_open_files */voidincrement_open_file_count (void){	allowed_open_files ++ ;} /* increment_open_file_count */voidcheck_open_file_count_or_die (int lineno){#if (defined (WIN32) || defined (_WIN32))	lineno = 0 ;	return ;#else	int k, count = 0 ;	struct stat statbuf ;	if (allowed_open_files < 0)		count_open_files () ;	for (k = 0 ; k < 1024 ; k++)		if (fstat (k, &statbuf) == 0)			count ++ ;	if (count > allowed_open_files)	{	printf ("\nLine %d : number of open files (%d) > allowed (%d).\n\n", lineno, count, allowed_open_files) ;		exit (1) ;		} ;#endif} /* check_open_file_count_or_die */[+ ESAC +][+ COMMENT Do not edit or modify anything in this comment block. The following line is a file identity tag for the GNU Arch revision control system. arch-tag: b1183d5d-ebd4-4bc5-af50-60d774d6b1f5+]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -