All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tiago Maluta <maluta_tiago@yahoo.com.br>
To: Steve Graegert <graegerts@gmail.com>
Cc: Angel Tsankov <fn42551@fmi.uni-sofia.bg>,
	linux-c-programming@vger.kernel.org
Subject: Re: How does one get the description of an errno value
Date: Sun, 15 Mar 2009 10:43:06 +0000	[thread overview]
Message-ID: <49BCDBBA.3000209@yahoo.com.br> (raw)
In-Reply-To: <6a00c8d50903150420ke10afcfs7c78a11355c5957a@mail.gmail.com>

Steve,

> The following code snippet should do it.  It basically sets errno
> manually and outputs the associated error message.
> 
> --- BEGIN ---
> 
> #define _ALL_SOURCE
> 
> #include <stdio.h>
> #include <errno.h> /* for _MAX_ERRNO */
> 

I've searched in headers on /usr/include for MAX_ERRNO but not found.
Where MAX_ERRNO is defined?

A *very* simple workaround was check for "Unknown" word, so I tried:

int main(void) {
	int i=0;
	extern int errno;
	char str[128];

	while (strncmp(str,"Unknown",7)) {
		sprintf(str,"%s",strerror(i));
		fprintf(stderr, "%3d", i);
		errno = i;
		perror(" ");
		i++;
	}

	return (0);
}


But there is "Unknown" between valid error messages.
I think there is a better way to do it....


Best regards,

--tm


  reply	other threads:[~2009-03-15 10:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-15 10:46 How does one get the description of an errno value Angel Tsankov
2009-03-15 11:20 ` Bert Wesarg
2009-03-15 11:20 ` Steve Graegert
2009-03-15 10:43   ` Tiago Maluta [this message]
2009-03-15 13:09     ` Sergio Luis
2009-03-15 13:10     ` Steve Graegert
     [not found]     ` <a913862f0903150619o43657d87q2f45dbdbc7071659@mail.gmail.com>
     [not found]       ` <49BD1E25.4010305@yahoo.com.br>
2009-03-15 18:13         ` Akos Marton
2009-03-16  1:23   ` Jon Mayo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49BCDBBA.3000209@yahoo.com.br \
    --to=maluta_tiago@yahoo.com.br \
    --cc=fn42551@fmi.uni-sofia.bg \
    --cc=graegerts@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.