List Info

Thread: libpng equivalent of errno?




libpng equivalent of errno?
user name
2007-02-17 23:26:29
Hi.

In general, programming under POSIX, I can get information
about
errors by reading errno:

if (read(fd, buf, len) == -1)
  switch (errno) {
    case EIO: handle_io_error(); break;
    case EAGAIN:
    case EWOULDBLOCK:
      printf("waiting...n");
      break;
    default:
      break;
  }

With libpng, of course I can set my own error handlers, but
how can I get more information about exactly what error
occurred? Currently, I'm checking errno inside my custom
IO functions, but what about, for example, when a file
turns out not to be a PNG file? Of course I could check
that
the error string is 'Not a PNG file' inside an error
handler,
but this seems messy. I'd much rather do something like:

   if (png->errno == LIBPNG_ERROR_NOTPNG)
     handle_invalid_png();

Is this possible, currently?

thanks,
MC

------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
png-mng-implement mailing list
png-mng-implementlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/png-m
ng-implement

Re: libpng equivalent of errno?
country flaguser name
United States
2007-02-18 08:23:24
At 05:26 AM 2/18/2007 +0000, mal content wrote:
>Of course I could check that
>the error string is 'Not a PNG file' inside an error
handler,
>but this seems messy.

That's all there is right now.  We did lay some of the
groundwork
for error-number handling a few years ago but there is still
a
little work to be done, namely embedding an error-number
string
in each error or warning message.  It's on my to-do list for
libpng-1.4.0

Glenn

------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
png-mng-implement mailing list
png-mng-implementlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/png-m
ng-implement

Re: libpng equivalent of errno?
user name
2007-02-18 08:58:31
On 18/02/07, Glenn Randers-Pehrson <glennrpcomcast.net> wrote:
> At 05:26 AM 2/18/2007 +0000, mal content wrote:
> >Of course I could check that
> >the error string is 'Not a PNG file' inside an
error handler,
> >but this seems messy.
>
> That's all there is right now.  We did lay some of the
groundwork
> for error-number handling a few years ago but there is
still a
> little work to be done, namely embedding an
error-number string
> in each error or warning message.  It's on my to-do
list for libpng-1.4.0
>

I look forward to it.

thanks,
MC

------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
png-mng-implement mailing list
png-mng-implementlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/png-m
ng-implement

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )