mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-27 03:50:29 +00:00
Use C99 snprintf everywhere.
This commit is contained in:
parent
0733b9962c
commit
033cc5ca35
@ -1,3 +1,8 @@
|
|||||||
|
2009-02-14 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||||
|
|
||||||
|
* src/common.h src/*.c
|
||||||
|
Use C99 snprintf everywhere.
|
||||||
|
|
||||||
2009-02-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
2009-02-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||||
|
|
||||||
* tests/test_wrapper.sh.in
|
* tests/test_wrapper.sh.in
|
||||||
|
@ -484,7 +484,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
|
|||||||
psf->peak_info->peaks [dword].value = value ;
|
psf->peak_info->peaks [dword].value = value ;
|
||||||
psf->peak_info->peaks [dword].position = position ;
|
psf->peak_info->peaks [dword].position = position ;
|
||||||
|
|
||||||
LSF_SNPRINTF (cptr, sizeof (psf->u.scbuf), " %2d %-12ld %g\n",
|
snprintf (cptr, sizeof (psf->u.scbuf), " %2d %-12ld %g\n",
|
||||||
dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
|
dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
|
||||||
cptr [sizeof (psf->u.scbuf) - 1] = 0 ;
|
cptr [sizeof (psf->u.scbuf) - 1] = 0 ;
|
||||||
psf_log_printf (psf, cptr) ;
|
psf_log_printf (psf, cptr) ;
|
||||||
|
@ -193,7 +193,7 @@ gen_coding_history (char * added_history, int added_history_max, const SF_INFO *
|
|||||||
break ;
|
break ;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
LSF_SNPRINTF (chnstr, sizeof (chnstr), "%uchn", psfinfo->channels) ;
|
snprintf (chnstr, sizeof (chnstr), "%uchn", psfinfo->channels) ;
|
||||||
break ;
|
break ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ gen_coding_history (char * added_history, int added_history_max, const SF_INFO *
|
|||||||
break ;
|
break ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
count = LSF_SNPRINTF (added_history, added_history_max,
|
count = snprintf (added_history, added_history_max,
|
||||||
"A=PCM,F=%u,W=%hu,M=%s,T=%s-%s\r\n",
|
"A=PCM,F=%u,W=%hu,M=%s,T=%s-%s\r\n",
|
||||||
psfinfo->samplerate, width, chnstr, PACKAGE, VERSION) ;
|
psfinfo->samplerate, width, chnstr, PACKAGE, VERSION) ;
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ caf_read_header (SF_PRIVATE *psf)
|
|||||||
|
|
||||||
psf_binheader_readf (psf, "mE8b", &marker, &chunk_size, psf->u.ucbuf, 8) ;
|
psf_binheader_readf (psf, "mE8b", &marker, &chunk_size, psf->u.ucbuf, 8) ;
|
||||||
srate = double64_be_read (psf->u.ucbuf) ;
|
srate = double64_be_read (psf->u.ucbuf) ;
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%5.3f", srate) ;
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%5.3f", srate) ;
|
||||||
psf_log_printf (psf, "%M : %D\n Sample rate : %s\n", marker, chunk_size, psf->u.cbuf) ;
|
psf_log_printf (psf, "%M : %D\n Sample rate : %s\n", marker, chunk_size, psf->u.cbuf) ;
|
||||||
if (marker != desc_MARKER)
|
if (marker != desc_MARKER)
|
||||||
return SFE_CAF_NO_DESC ;
|
return SFE_CAF_NO_DESC ;
|
||||||
@ -315,7 +315,7 @@ caf_read_header (SF_PRIVATE *psf)
|
|||||||
psf->peak_info->peaks [k].value = value ;
|
psf->peak_info->peaks [k].value = value ;
|
||||||
psf->peak_info->peaks [k].position = position ;
|
psf->peak_info->peaks [k].position = position ;
|
||||||
|
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %-12ld %g\n", k, (long) position, value) ;
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %-12ld %g\n", k, (long) position, value) ;
|
||||||
psf_log_printf (psf, psf->u.cbuf) ;
|
psf_log_printf (psf, psf->u.cbuf) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...)
|
|||||||
maxlen = sizeof (psf->header) - maxlen ;
|
maxlen = sizeof (psf->header) - maxlen ;
|
||||||
|
|
||||||
va_start (argptr, format) ;
|
va_start (argptr, format) ;
|
||||||
LSF_VSNPRINTF (start, maxlen, format, argptr) ;
|
vsnprintf (start, maxlen, format, argptr) ;
|
||||||
va_end (argptr) ;
|
va_end (argptr) ;
|
||||||
|
|
||||||
/* Make sure the string is properly terminated. */
|
/* Make sure the string is properly terminated. */
|
||||||
@ -1231,11 +1231,11 @@ psf_get_date_str (char *str, int maxlen)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tmptr)
|
if (tmptr)
|
||||||
LSF_SNPRINTF (str, maxlen, "%4d-%02d-%02d %02d:%02d:%02d UTC",
|
snprintf (str, maxlen, "%4d-%02d-%02d %02d:%02d:%02d UTC",
|
||||||
1900 + timedata.tm_year, timedata.tm_mon, timedata.tm_mday,
|
1900 + timedata.tm_year, timedata.tm_mon, timedata.tm_mday,
|
||||||
timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
||||||
else
|
else
|
||||||
LSF_SNPRINTF (str, maxlen, "Unknown date") ;
|
snprintf (str, maxlen, "Unknown date") ;
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
} /* psf_get_date_str */
|
} /* psf_get_date_str */
|
||||||
|
23
src/common.h
23
src/common.h
@ -811,29 +811,6 @@ const char * str_of_minor_format (int format) ;
|
|||||||
const char * str_of_open_mode (int mode) ;
|
const char * str_of_open_mode (int mode) ;
|
||||||
const char * str_of_endianness (int end) ;
|
const char * str_of_endianness (int end) ;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------------
|
|
||||||
** Here's how we fix systems which don't snprintf / vsnprintf.
|
|
||||||
** Systems without these functions should use the
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if USE_WINDOWS_API
|
|
||||||
#define LSF_SNPRINTF _snprintf
|
|
||||||
#elif (HAVE_SNPRINTF && ! FORCE_MISSING_SNPRINTF)
|
|
||||||
#define LSF_SNPRINTF snprintf
|
|
||||||
#else
|
|
||||||
int missing_snprintf (char *str, size_t n, char const *fmt, ...) ;
|
|
||||||
#define LSF_SNPRINTF missing_snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if USE_WINDOWS_API
|
|
||||||
#define LSF_VSNPRINTF _vsnprintf
|
|
||||||
#elif (HAVE_VSNPRINTF && ! FORCE_MISSING_SNPRINTF)
|
|
||||||
#define LSF_VSNPRINTF vsnprintf
|
|
||||||
#else
|
|
||||||
int missing_vsnprintf (char *str, size_t n, const char *fmt, ...) ;
|
|
||||||
#define LSF_VSNPRINTF missing_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------------
|
||||||
** Extra commands for sf_command(). Not for public use yet.
|
** Extra commands for sf_command(). Not for public use yet.
|
||||||
*/
|
*/
|
||||||
|
@ -123,7 +123,7 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
|
|||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
||||||
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
|
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
|
||||||
LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
|
snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
|
||||||
psf->error = SFE_NO_ERROR ;
|
psf->error = SFE_NO_ERROR ;
|
||||||
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
|
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
|
||||||
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
|
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
|
||||||
@ -142,7 +142,7 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
|
|||||||
** Now try for a resource fork stored as a separate file in the same
|
** Now try for a resource fork stored as a separate file in the same
|
||||||
** directory, but preceded with a dot underscore.
|
** directory, but preceded with a dot underscore.
|
||||||
*/
|
*/
|
||||||
LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
|
snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
|
||||||
psf->error = SFE_NO_ERROR ;
|
psf->error = SFE_NO_ERROR ;
|
||||||
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
|
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
|
||||||
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
|
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
|
||||||
@ -153,7 +153,7 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
|
|||||||
** Now try for a resource fork stored in a separate file in the
|
** Now try for a resource fork stored in a separate file in the
|
||||||
** .AppleDouble/ directory.
|
** .AppleDouble/ directory.
|
||||||
*/
|
*/
|
||||||
LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
|
snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
|
||||||
psf->error = SFE_NO_ERROR ;
|
psf->error = SFE_NO_ERROR ;
|
||||||
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
|
if ((psf->rsrcdes = psf_open_fd (psf->rsrcpath, open_mode)) >= 0)
|
||||||
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
|
{ psf->rsrclength = psf_get_filelen_fd (psf->rsrcdes) ;
|
||||||
@ -568,7 +568,7 @@ psf_log_syserr (SF_PRIVATE *psf, int error)
|
|||||||
/* Only log an error if no error has been set yet. */
|
/* Only log an error if no error has been set yet. */
|
||||||
if (psf->error == 0)
|
if (psf->error == 0)
|
||||||
{ psf->error = SFE_SYSTEM ;
|
{ psf->error = SFE_SYSTEM ;
|
||||||
LSF_SNPRINTF (psf->syserr, sizeof (psf->syserr), "System error : %s.", strerror (error)) ;
|
snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s.", strerror (error)) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
@ -637,7 +637,7 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
|
|||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
||||||
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
|
/* Test for MacOSX style resource fork on HPFS or HPFS+ filesystems. */
|
||||||
LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
|
snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s/rsrc", psf->filepath) ;
|
||||||
psf->error = SFE_NO_ERROR ;
|
psf->error = SFE_NO_ERROR ;
|
||||||
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
|
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
|
||||||
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
|
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
|
||||||
@ -648,7 +648,7 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
|
|||||||
** Now try for a resource fork stored as a separate file in the same
|
** Now try for a resource fork stored as a separate file in the same
|
||||||
** directory, but preceded with a dot underscore.
|
** directory, but preceded with a dot underscore.
|
||||||
*/
|
*/
|
||||||
LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
|
snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s._%s", psf->directory, psf->filename) ;
|
||||||
psf->error = SFE_NO_ERROR ;
|
psf->error = SFE_NO_ERROR ;
|
||||||
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
|
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
|
||||||
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
|
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
|
||||||
@ -659,7 +659,7 @@ psf_open_rsrc (SF_PRIVATE *psf, int open_mode)
|
|||||||
** Now try for a resource fork stored in a separate file in the
|
** Now try for a resource fork stored in a separate file in the
|
||||||
** .AppleDouble/ directory.
|
** .AppleDouble/ directory.
|
||||||
*/
|
*/
|
||||||
LSF_SNPRINTF (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
|
snprintf (psf->rsrcpath, sizeof (psf->rsrcpath), "%s.AppleDouble/%s", psf->directory, psf->filename) ;
|
||||||
psf->error = SFE_NO_ERROR ;
|
psf->error = SFE_NO_ERROR ;
|
||||||
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
|
if ((psf->hrsrc = psf_open_handle (psf->rsrcpath, open_mode)) != NULL)
|
||||||
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
|
{ psf->rsrclength = psf_get_filelen_handle (psf->hrsrc) ;
|
||||||
@ -806,7 +806,7 @@ psf_log_syserr (SF_PRIVATE *psf, int error)
|
|||||||
NULL
|
NULL
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
LSF_SNPRINTF (psf->syserr, sizeof (psf->syserr), "System error : %s", lpMsgBuf) ;
|
snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s", lpMsgBuf) ;
|
||||||
LocalFree (lpMsgBuf) ;
|
LocalFree (lpMsgBuf) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@ -1516,7 +1516,7 @@ psf_log_syserr (SF_PRIVATE *psf, int error)
|
|||||||
/* Only log an error if no error has been set yet. */
|
/* Only log an error if no error has been set yet. */
|
||||||
if (psf->error == 0)
|
if (psf->error == 0)
|
||||||
{ psf->error = SFE_SYSTEM ;
|
{ psf->error = SFE_SYSTEM ;
|
||||||
LSF_SNPRINTF (psf->syserr, sizeof (psf->syserr), "System error : %s", strerror (error)) ;
|
snprintf (psf->syserr, sizeof (psf->syserr), "System error : %s", strerror (error)) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
|
@ -244,7 +244,7 @@ mat4_read_header (SF_PRIVATE *psf)
|
|||||||
|
|
||||||
psf_binheader_readf (psf, "d", &value) ;
|
psf_binheader_readf (psf, "d", &value) ;
|
||||||
|
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " Value : %f\n", value) ;
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " Value : %f\n", value) ;
|
||||||
psf_log_printf (psf, psf->u.cbuf) ;
|
psf_log_printf (psf, psf->u.cbuf) ;
|
||||||
|
|
||||||
if ((rows != 1) || (cols != 1))
|
if ((rows != 1) || (cols != 1))
|
||||||
@ -383,7 +383,7 @@ mat4_marker_to_str (int marker)
|
|||||||
|
|
||||||
/* This is a little unsafe but is really only for debugging. */
|
/* This is a little unsafe but is really only for debugging. */
|
||||||
str [sizeof (str) - 1] = 0 ;
|
str [sizeof (str) - 1] = 0 ;
|
||||||
LSF_SNPRINTF (str, sizeof (str) - 1, "%08X", marker) ;
|
snprintf (str, sizeof (str) - 1, "%08X", marker) ;
|
||||||
return str ;
|
return str ;
|
||||||
} /* mat4_marker_to_str */
|
} /* mat4_marker_to_str */
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ mat5_read_header (SF_PRIVATE *psf)
|
|||||||
{ double samplerate ;
|
{ double samplerate ;
|
||||||
|
|
||||||
psf_binheader_readf (psf, "d", &samplerate) ;
|
psf_binheader_readf (psf, "d", &samplerate) ;
|
||||||
LSF_SNPRINTF (name, sizeof (name), "%f\n", samplerate) ;
|
snprintf (name, sizeof (name), "%f\n", samplerate) ;
|
||||||
psf_log_printf (psf, " Val : %s\n", name) ;
|
psf_log_printf (psf, " Val : %s\n", name) ;
|
||||||
|
|
||||||
psf->sf.samplerate = lrint (samplerate) ;
|
psf->sf.samplerate = lrint (samplerate) ;
|
||||||
|
@ -112,7 +112,7 @@ pvf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||||||
if (psf->is_pipe == SF_FALSE)
|
if (psf->is_pipe == SF_FALSE)
|
||||||
psf_fseek (psf, 0, SEEK_SET) ;
|
psf_fseek (psf, 0, SEEK_SET) ;
|
||||||
|
|
||||||
LSF_SNPRINTF ((char*) psf->header, sizeof (psf->header), "PVF1\n%d %d %d\n",
|
snprintf ((char*) psf->header, sizeof (psf->header), "PVF1\n%d %d %d\n",
|
||||||
psf->sf.channels, psf->sf.samplerate, psf->bytewidth * 8) ;
|
psf->sf.channels, psf->sf.samplerate, psf->bytewidth * 8) ;
|
||||||
|
|
||||||
psf->headindex = strlen ((char*) psf->header) ;
|
psf->headindex = strlen ((char*) psf->header) ;
|
||||||
|
@ -249,9 +249,9 @@ sd2_write_rsrc_fork (SF_PRIVATE *psf, int UNUSED (calc_length))
|
|||||||
rsrc.rsrc_len = sizeof (psf->header) ;
|
rsrc.rsrc_len = sizeof (psf->header) ;
|
||||||
memset (rsrc.rsrc_data, 0xea, rsrc.rsrc_len) ;
|
memset (rsrc.rsrc_data, 0xea, rsrc.rsrc_len) ;
|
||||||
|
|
||||||
LSF_SNPRINTF (str_rsrc [0].value, sizeof (str_rsrc [0].value), "_%d", rsrc.sample_size) ;
|
snprintf (str_rsrc [0].value, sizeof (str_rsrc [0].value), "_%d", rsrc.sample_size) ;
|
||||||
LSF_SNPRINTF (str_rsrc [1].value, sizeof (str_rsrc [1].value), "_%d.000000", rsrc.sample_rate) ;
|
snprintf (str_rsrc [1].value, sizeof (str_rsrc [1].value), "_%d.000000", rsrc.sample_rate) ;
|
||||||
LSF_SNPRINTF (str_rsrc [2].value, sizeof (str_rsrc [2].value), "_%d", rsrc.channels) ;
|
snprintf (str_rsrc [2].value, sizeof (str_rsrc [2].value), "_%d", rsrc.channels) ;
|
||||||
|
|
||||||
for (k = 0 ; k < ARRAY_LEN (str_rsrc) ; k++)
|
for (k = 0 ; k < ARRAY_LEN (str_rsrc) ; k++)
|
||||||
{ if (str_rsrc [k].value_len == 0)
|
{ if (str_rsrc [k].value_len == 0)
|
||||||
|
@ -357,19 +357,19 @@ sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user
|
|||||||
/* Make sure we have a valid set ot virtual pointers. */
|
/* Make sure we have a valid set ot virtual pointers. */
|
||||||
if (sfvirtual->get_filelen == NULL || sfvirtual->seek == NULL || sfvirtual->tell == NULL)
|
if (sfvirtual->get_filelen == NULL || sfvirtual->seek == NULL || sfvirtual->tell == NULL)
|
||||||
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
||||||
LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ;
|
snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if ((mode == SFM_READ || mode == SFM_RDWR) && sfvirtual->read == NULL)
|
if ((mode == SFM_READ || mode == SFM_RDWR) && sfvirtual->read == NULL)
|
||||||
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
||||||
LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ;
|
snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if ((mode == SFM_WRITE || mode == SFM_RDWR) && sfvirtual->write == NULL)
|
if ((mode == SFM_WRITE || mode == SFM_RDWR) && sfvirtual->write == NULL)
|
||||||
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
|
||||||
LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ;
|
snprintf (sf_logbuffer, sizeof (sf_logbuffer), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ sf_error_str (SNDFILE *sndfile, char *str, size_t maxlen)
|
|||||||
errnum = psf->error ;
|
errnum = psf->error ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
LSF_SNPRINTF (str, maxlen, "%s", sf_error_number (errnum)) ;
|
snprintf (str, maxlen, "%s", sf_error_number (errnum)) ;
|
||||||
|
|
||||||
return SFE_NO_ERROR ;
|
return SFE_NO_ERROR ;
|
||||||
} /* sf_error_str */
|
} /* sf_error_str */
|
||||||
@ -825,9 +825,9 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
|||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return (psf->error = SFE_BAD_COMMAND_PARAM) ;
|
return (psf->error = SFE_BAD_COMMAND_PARAM) ;
|
||||||
if (ENABLE_EXPERIMENTAL_CODE)
|
if (ENABLE_EXPERIMENTAL_CODE)
|
||||||
LSF_SNPRINTF (data, datasize, "%s-%s-exp", PACKAGE_NAME, PACKAGE_VERSION) ;
|
snprintf (data, datasize, "%s-%s-exp", PACKAGE_NAME, PACKAGE_VERSION) ;
|
||||||
else
|
else
|
||||||
LSF_SNPRINTF (data, datasize, "%s-%s", PACKAGE_NAME, PACKAGE_VERSION) ;
|
snprintf (data, datasize, "%s-%s", PACKAGE_NAME, PACKAGE_VERSION) ;
|
||||||
return strlen (data) ;
|
return strlen (data) ;
|
||||||
|
|
||||||
case SFC_GET_SIMPLE_FORMAT_COUNT :
|
case SFC_GET_SIMPLE_FORMAT_COUNT :
|
||||||
@ -872,7 +872,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
|||||||
if (sndfile == NULL && command == SFC_GET_LOG_INFO)
|
if (sndfile == NULL && command == SFC_GET_LOG_INFO)
|
||||||
{ if (data == NULL)
|
{ if (data == NULL)
|
||||||
return (psf->error = SFE_BAD_COMMAND_PARAM) ;
|
return (psf->error = SFE_BAD_COMMAND_PARAM) ;
|
||||||
LSF_SNPRINTF (data, datasize, "%s", sf_logbuffer) ;
|
snprintf (data, datasize, "%s", sf_logbuffer) ;
|
||||||
return strlen (data) ;
|
return strlen (data) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@ -957,7 +957,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
|||||||
case SFC_GET_LOG_INFO :
|
case SFC_GET_LOG_INFO :
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return SFE_BAD_COMMAND_PARAM ;
|
return SFE_BAD_COMMAND_PARAM ;
|
||||||
LSF_SNPRINTF (data, datasize, "%s", psf->logbuffer) ;
|
snprintf (data, datasize, "%s", psf->logbuffer) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case SFC_CALC_SIGNAL_MAX :
|
case SFC_CALC_SIGNAL_MAX :
|
||||||
@ -2367,7 +2367,7 @@ validate_psf (SF_PRIVATE *psf)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
save_header_info (SF_PRIVATE *psf)
|
save_header_info (SF_PRIVATE *psf)
|
||||||
{ LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
|
{ snprintf (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
|
||||||
} /* save_header_info */
|
} /* save_header_info */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2375,16 +2375,16 @@ copy_filename (SF_PRIVATE *psf, const char *path)
|
|||||||
{ const char *ccptr ;
|
{ const char *ccptr ;
|
||||||
char *cptr ;
|
char *cptr ;
|
||||||
|
|
||||||
LSF_SNPRINTF (psf->filepath, sizeof (psf->filepath), "%s", path) ;
|
snprintf (psf->filepath, sizeof (psf->filepath), "%s", path) ;
|
||||||
if ((ccptr = strrchr (path, '/')) || (ccptr = strrchr (path, '\\')))
|
if ((ccptr = strrchr (path, '/')) || (ccptr = strrchr (path, '\\')))
|
||||||
ccptr ++ ;
|
ccptr ++ ;
|
||||||
else
|
else
|
||||||
ccptr = path ;
|
ccptr = path ;
|
||||||
|
|
||||||
LSF_SNPRINTF (psf->filename, sizeof (psf->filename), "%s", ccptr) ;
|
snprintf (psf->filename, sizeof (psf->filename), "%s", ccptr) ;
|
||||||
|
|
||||||
/* Now grab the directory. */
|
/* Now grab the directory. */
|
||||||
LSF_SNPRINTF (psf->directory, sizeof (psf->directory), "%s", path) ;
|
snprintf (psf->directory, sizeof (psf->directory), "%s", path) ;
|
||||||
if ((cptr = strrchr (psf->directory, '/')) || (cptr = strrchr (psf->directory, '\\')))
|
if ((cptr = strrchr (psf->directory, '/')) || (cptr = strrchr (psf->directory, '\\')))
|
||||||
cptr [1] = 0 ;
|
cptr [1] = 0 ;
|
||||||
else
|
else
|
||||||
@ -2774,8 +2774,8 @@ error_exit :
|
|||||||
sf_errno = error ;
|
sf_errno = error ;
|
||||||
|
|
||||||
if (error == SFE_SYSTEM)
|
if (error == SFE_SYSTEM)
|
||||||
LSF_SNPRINTF (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
|
snprintf (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
|
||||||
LSF_SNPRINTF (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
|
snprintf (sf_logbuffer, sizeof (sf_logbuffer), "%s", psf->logbuffer) ;
|
||||||
|
|
||||||
switch (error)
|
switch (error)
|
||||||
{ case SF_ERR_SYSTEM :
|
{ case SF_ERR_SYSTEM :
|
||||||
|
@ -30,35 +30,35 @@
|
|||||||
|
|
||||||
#define CMP_0_ARGS(line,err,fmt) \
|
#define CMP_0_ARGS(line,err,fmt) \
|
||||||
{ psf->logindex = 0 ; \
|
{ psf->logindex = 0 ; \
|
||||||
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt)) ; \
|
snprintf (buffer, sizeof (buffer), (fmt)) ; \
|
||||||
psf_log_printf (psf, (fmt)) ; \
|
psf_log_printf (psf, (fmt)) ; \
|
||||||
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CMP_2_ARGS(line,err,fmt,a) \
|
#define CMP_2_ARGS(line,err,fmt,a) \
|
||||||
{ psf->logindex = 0 ; \
|
{ psf->logindex = 0 ; \
|
||||||
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a)) ; \
|
snprintf (buffer, sizeof (buffer), (fmt), (a), (a)) ; \
|
||||||
psf_log_printf (psf, (fmt), (a), (a)) ; \
|
psf_log_printf (psf, (fmt), (a), (a)) ; \
|
||||||
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CMP_4_ARGS(line,err,fmt,a) \
|
#define CMP_4_ARGS(line,err,fmt,a) \
|
||||||
{ psf->logindex = 0 ; \
|
{ psf->logindex = 0 ; \
|
||||||
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \
|
snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \
|
||||||
psf_log_printf (psf, (fmt), (a), (a), (a), (a)) ; \
|
psf_log_printf (psf, (fmt), (a), (a), (a), (a)) ; \
|
||||||
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CMP_5_ARGS(line,err,fmt,a) \
|
#define CMP_5_ARGS(line,err,fmt,a) \
|
||||||
{ psf->logindex = 0 ; \
|
{ psf->logindex = 0 ; \
|
||||||
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \
|
snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \
|
||||||
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a)) ; \
|
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a)) ; \
|
||||||
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CMP_6_ARGS(line,err,fmt,a) \
|
#define CMP_6_ARGS(line,err,fmt,a) \
|
||||||
{ psf->logindex = 0 ; \
|
{ psf->logindex = 0 ; \
|
||||||
LSF_SNPRINTF (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \
|
snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \
|
||||||
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a), (a)) ; \
|
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a), (a)) ; \
|
||||||
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
err += compare_strings_or_die (line, fmt, buffer, psf->logbuffer) ; \
|
||||||
}
|
}
|
||||||
|
10
src/wav.c
10
src/wav.c
@ -490,7 +490,7 @@ wav_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
|
|||||||
psf->peak_info->peaks [dword].value = value ;
|
psf->peak_info->peaks [dword].value = value ;
|
||||||
psf->peak_info->peaks [dword].position = position ;
|
psf->peak_info->peaks [dword].position = position ;
|
||||||
|
|
||||||
LSF_SNPRINTF (cptr, sizeof (psf->u.cbuf), " %2d %-12ld %g\n",
|
snprintf (cptr, sizeof (psf->u.cbuf), " %2d %-12ld %g\n",
|
||||||
dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
|
dword, (long) psf->peak_info->peaks [dword].position, psf->peak_info->peaks [dword].value) ;
|
||||||
cptr [sizeof (psf->u.cbuf) - 1] = 0 ;
|
cptr [sizeof (psf->u.cbuf) - 1] = 0 ;
|
||||||
psf_log_printf (psf, cptr) ;
|
psf_log_printf (psf, cptr) ;
|
||||||
@ -1444,7 +1444,7 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen)
|
|||||||
|
|
||||||
bytesread += psf_binheader_readf (psf, "4", &dword) ;
|
bytesread += psf_binheader_readf (psf, "4", &dword) ;
|
||||||
if (dword != 0)
|
if (dword != 0)
|
||||||
{ LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%f",
|
{ snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f",
|
||||||
(1.0 * 0x80000000) / ((unsigned int) dword)) ;
|
(1.0 * 0x80000000) / ((unsigned int) dword)) ;
|
||||||
psf_log_printf (psf, " Pitch Fract. : %s\n", psf->u.cbuf) ;
|
psf_log_printf (psf, " Pitch Fract. : %s\n", psf->u.cbuf) ;
|
||||||
}
|
}
|
||||||
@ -1455,7 +1455,7 @@ wav_read_smpl_chunk (SF_PRIVATE *psf, unsigned int chunklen)
|
|||||||
psf_log_printf (psf, " SMPTE Format : %u\n", dword) ;
|
psf_log_printf (psf, " SMPTE Format : %u\n", dword) ;
|
||||||
|
|
||||||
bytesread += psf_binheader_readf (psf, "4", &dword) ;
|
bytesread += psf_binheader_readf (psf, "4", &dword) ;
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%02d:%02d:%02d %02d",
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%02d:%02d:%02d %02d",
|
||||||
(dword >> 24) & 0x7F, (dword >> 16) & 0x7F, (dword >> 8) & 0x7F, dword & 0x7F) ;
|
(dword >> 24) & 0x7F, (dword >> 16) & 0x7F, (dword >> 8) & 0x7F, dword & 0x7F) ;
|
||||||
psf_log_printf (psf, " SMPTE Offset : %s\n", psf->u.cbuf) ;
|
psf_log_printf (psf, " SMPTE Offset : %s\n", psf->u.cbuf) ;
|
||||||
|
|
||||||
@ -1593,7 +1593,7 @@ wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen)
|
|||||||
|
|
||||||
bytesread += psf_binheader_readf (psf, "422f", &flags, &rootnote, &q1, &q2) ;
|
bytesread += psf_binheader_readf (psf, "422f", &flags, &rootnote, &q1, &q2) ;
|
||||||
|
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", q2) ;
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", q2) ;
|
||||||
|
|
||||||
psf_log_printf (psf, " Flags : 0x%04x (%s,%s,%s,%s,%s)\n", flags,
|
psf_log_printf (psf, " Flags : 0x%04x (%s,%s,%s,%s,%s)\n", flags,
|
||||||
(flags & 0x01) ? "OneShot" : "Loop",
|
(flags & 0x01) ? "OneShot" : "Loop",
|
||||||
@ -1606,7 +1606,7 @@ wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen)
|
|||||||
rootnote, q1, psf->u.cbuf) ;
|
rootnote, q1, psf->u.cbuf) ;
|
||||||
|
|
||||||
bytesread += psf_binheader_readf (psf, "422f", &beats, &meter_denom, &meter_numer, &tempo) ;
|
bytesread += psf_binheader_readf (psf, "422f", &beats, &meter_denom, &meter_numer, &tempo) ;
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", tempo) ;
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), "%f", tempo) ;
|
||||||
psf_log_printf (psf, " Beats : %d\n Meter : %d/%d\n Tempo : %s\n",
|
psf_log_printf (psf, " Beats : %d\n Meter : %d/%d\n Tempo : %s\n",
|
||||||
beats, meter_numer, meter_denom, psf->u.cbuf) ;
|
beats, meter_numer, meter_denom, psf->u.cbuf) ;
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
|
|||||||
for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++)
|
for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++)
|
||||||
{ bytesread +=
|
{ bytesread +=
|
||||||
psf_binheader_readf (psf, "22", &(wav_fmt->msadpcm.coeffs [k].coeff1), &(wav_fmt->msadpcm.coeffs [k].coeff2)) ;
|
psf_binheader_readf (psf, "22", &(wav_fmt->msadpcm.coeffs [k].coeff1), &(wav_fmt->msadpcm.coeffs [k].coeff2)) ;
|
||||||
LSF_SNPRINTF (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ;
|
snprintf (psf->u.cbuf, sizeof (psf->u.cbuf), " %2d %7d %7d\n", k, wav_fmt->msadpcm.coeffs [k].coeff1, wav_fmt->msadpcm.coeffs [k].coeff2) ;
|
||||||
psf_log_printf (psf, psf->u.cbuf) ;
|
psf_log_printf (psf, psf->u.cbuf) ;
|
||||||
} ;
|
} ;
|
||||||
break ;
|
break ;
|
||||||
|
2
src/xi.c
2
src/xi.c
@ -95,7 +95,7 @@ xi_open (SF_PRIVATE *psf)
|
|||||||
memcpy (pxi->software, PACKAGE "-" VERSION " ", sizeof (pxi->software)) ;
|
memcpy (pxi->software, PACKAGE "-" VERSION " ", sizeof (pxi->software)) ;
|
||||||
|
|
||||||
memset (pxi->sample_name, 0, sizeof (pxi->sample_name)) ;
|
memset (pxi->sample_name, 0, sizeof (pxi->sample_name)) ;
|
||||||
LSF_SNPRINTF (pxi->sample_name, sizeof (pxi->sample_name), "%s", "Sample #1") ;
|
snprintf (pxi->sample_name, sizeof (pxi->sample_name), "%s", "Sample #1") ;
|
||||||
|
|
||||||
pxi->sample_flags = (subformat == SF_FORMAT_DPCM_16) ? 16 : 0 ;
|
pxi->sample_flags = (subformat == SF_FORMAT_DPCM_16) ? 16 : 0 ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user