check_if_png: clarify comments.
Before this patch check_if_png() comment was kind of misleading because it talked about the behaviour of png_sig_cmp() which isn't the same as check_if_png().
This commit is contained in:
parent
e8005d43c6
commit
09cc95b989
2 changed files with 11 additions and 4 deletions
|
@ -146,8 +146,8 @@ fail:
|
||||||
|
|
||||||
/* hacked from https://dev.w3.org/Amaya/libpng/example.c
|
/* hacked from https://dev.w3.org/Amaya/libpng/example.c
|
||||||
*
|
*
|
||||||
* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
|
* Check if a file is a PNG image using png_sig_cmp(). Returns 1 if the given
|
||||||
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
|
* file is a PNG and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
#define PNG_BYTES_TO_CHECK 4
|
#define PNG_BYTES_TO_CHECK 4
|
||||||
int check_if_png(const char *filename)
|
int check_if_png(const char *filename)
|
||||||
|
@ -164,7 +164,11 @@ int check_if_png(const char *filename)
|
||||||
if (fread(buf, 1, PNG_BYTES_TO_CHECK, infile) != PNG_BYTES_TO_CHECK)
|
if (fread(buf, 1, PNG_BYTES_TO_CHECK, infile) != PNG_BYTES_TO_CHECK)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. */
|
/*
|
||||||
|
* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
|
||||||
|
* png_sig_cmp() returns zero if the image is a PNG and nonzero if it
|
||||||
|
* isn't a PNG.
|
||||||
|
*/
|
||||||
if (png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0)
|
if (png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0)
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ void dump_cells(const struct quirc_code *code);
|
||||||
*/
|
*/
|
||||||
int load_jpeg(struct quirc *q, const char *filename);
|
int load_jpeg(struct quirc *q, const char *filename);
|
||||||
|
|
||||||
/* check if a file is a PNG image. */
|
/* Check if a file is a PNG image.
|
||||||
|
*
|
||||||
|
* returns 1 if the given file is a PNG and 0 otherwise.
|
||||||
|
*/
|
||||||
int check_if_png(const char *filename);
|
int check_if_png(const char *filename);
|
||||||
|
|
||||||
/* Read a PNG image into the decoder.
|
/* Read a PNG image into the decoder.
|
||||||
|
|
Loading…
Reference in a new issue