예제 #1
0
/* Return a pointer to a string containing the name of the symbol of
   the error source in the error value ERR.  Returns NULL if the error
   code is not known.  */
const char *libidmef_strsource_sym(libidmef_error_t err)
{
  	libidmef_error_source_t source = libidmef_error_source(err);

  	if ( msgidxof(source) == msgidxof(LIBIDMEF_ERROR_SOURCE_DIM) )
    		return NULL;

  	return msgstr + msgidx[msgidxof(source)];
}
예제 #2
0
/* Return the error string for ERR in the user-supplied buffer BUF of
   size BUFLEN.  This function is, in contrast to gpg_strerror,
   thread-safe if a thread-safe strerror_r() function is provided by
   the system.  If the function succeeds, 0 is returned and BUF
   contains the string describing the error.  If the buffer was not
   large enough, ERANGE is returned and BUF contains as much of the
   beginning of the error string as fits into the buffer.  */
int
gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen)
{
  gpg_err_code_t code = gpg_err_code (err);
  const char *errstr;
  size_t errstr_len;
  size_t cpy_len;

  if (code & GPG_ERR_SYSTEM_ERROR)
    {
      int no = gpg_err_code_to_errno (code);
      if (no)
	{
	  int system_err = system_strerror_r (no, buf, buflen);

	  if (system_err != EINVAL)
	    {
	      if (buflen)
		buf[buflen - 1] = '\0';
	      return system_err;
	    }
	}
      code = GPG_ERR_UNKNOWN_ERRNO;
    }

  errstr = dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]);
  errstr_len = strlen (errstr) + 1;
  cpy_len = errstr_len < buflen ? errstr_len : buflen;
  memcpy (buf, errstr, cpy_len);
  if (buflen)
    buf[buflen - 1] = '\0';

  return cpy_len == errstr_len ? 0 : ERANGE;
}
예제 #3
0
/* Return a pointer to a string containing the name of the symbol of
   the error code in the error value ERR.  Returns NULL if the error
   code is not known.  */
const char *prelude_strerror_sym(prelude_error_t err)
{
	int idx;
  	prelude_error_code_t code = prelude_error_get_code(err);

  	if ( code & PRELUDE_ERROR_SYSTEM_ERROR ) {
      		code &= ~PRELUDE_ERROR_SYSTEM_ERROR;
      
      		idx = errnos_msgidxof (code);
      		if ( idx >= 0 )
			return errnos_msgstr + errnos_msgidx[idx];
      		else
			return NULL;
    	}

  	if ( msgidxof(code) == msgidxof(PRELUDE_ERROR_CODE_DIM) )
    		return NULL;

	return msgstr + msgidx[msgidxof(code)];
}
예제 #4
0
/* Return a pointer to a string containing the name of the symbol of
   the error code in the error value ERR.  Returns NULL if the error
   code is not known.  */
const char *
gpg_strerror_sym (gpg_error_t err)
{
  gpg_err_code_t code = gpg_err_code (err);

  if (code & GPG_ERR_SYSTEM_ERROR)
    {
      int idx;

      code &= ~GPG_ERR_SYSTEM_ERROR;
      idx = errnos_msgidxof (code);
      if (idx >= 0)
	return errnos_msgstr + errnos_msgidx[idx];
      else
	return NULL;
    }

  if (msgidxof (code) == msgidxof (GPG_ERR_CODE_DIM))
    return NULL;

  return msgstr + msgidx[msgidxof (code)];
}
예제 #5
0
/* Return a pointer to a string containing a description of the error
   code in the error value ERR.  This function is not thread-safe.  */
const char *
gpg_strerror (gpg_error_t err)
{
  gpg_err_code_t code = gpg_err_code (err);

  if (code & GPG_ERR_SYSTEM_ERROR)
    {
      int no = gpg_err_code_to_errno (code);
      if (no)
	return strerror (no);
      else
	code = GPG_ERR_UNKNOWN_ERRNO;
    }
  return dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]);
}
예제 #6
0
/* Return a pointer to a string containing a description of the error
   code in the error value ERR.  This function is not thread-safe.  */
const char *libiodef_strerror(libiodef_error_t err)
{
	int no;
  	libiodef_error_code_t code = libiodef_error_get_code(err);

  	if ( code & LIBIODEF_ERROR_SYSTEM_ERROR ) {
      		no = libiodef_error_code_to_errno(code);
      		if ( no )
			return strerror(no);
      		else
			code = LIBIODEF_ERROR_UNKNOWN_ERRNO;
    	}
        
  	return dgettext(PACKAGE, msgstr + msgidx[msgidxof((int)code)]);
}
예제 #7
0
/* Return a pointer to a string containing a description of the error
   code in the error value ERR.  This function is not thread-safe.  */
const char *requiem_strerror(requiem_error_t err)
{
	int no;
  	requiem_error_code_t code = requiem_error_get_code(err);

        if ( requiem_error_is_verbose(err) )
                return _requiem_thread_get_error();
        
  	if ( code & REQUIEM_ERROR_SYSTEM_ERROR ) {
      		no = requiem_error_code_to_errno(code);
      		if ( no )
			return strerror(no);
      		else
			code = REQUIEM_ERROR_UNKNOWN_ERRNO;
    	}
        
  	return dgettext(PACKAGE, msgstr + msgidx[msgidxof((int)code)]);
}
예제 #8
0
/* Return a pointer to a string containing a description of the error
   code in the error value ERR.  This function is not thread-safe.  */
const char *prelude_strerror(prelude_error_t err)
{
	int no;
  	prelude_error_code_t code = prelude_error_get_code(err);

        if ( prelude_error_is_verbose(err) )
                return _prelude_thread_get_error();
        
  	if ( code & PRELUDE_ERROR_SYSTEM_ERROR ) {
      		no = prelude_error_code_to_errno(code);
      		if ( no )
			return strerror(no);
      		else
			code = PRELUDE_ERROR_UNKNOWN_ERRNO;
    	}
        
  	return dgettext(PACKAGE, msgstr + msgidx[msgidxof((int)code)]);
}
예제 #9
0
/* Return a pointer to a string containing a description of the error
   source in the error value ERR.  */
const char *prelude_strsource(prelude_error_t err)
{
        prelude_error_source_t source = prelude_error_get_source(err);
        return dgettext(PACKAGE, msgstr + msgidx[msgidxof((int) source)]);
}
예제 #10
0
/* Return a pointer to a string containing a description of the error
   source in the error value ERR.  */
const char *
gpg_strsource (gpg_error_t err)
{
  gpg_err_source_t source = gpg_err_source (err);
  return dgettext (PACKAGE, msgstr + msgidx[msgidxof (source)]);
}
예제 #11
0
/* Return a pointer to a string containing a description of the error
   source in the error value ERR.  */
const char *libiodef_strsource(libiodef_error_t err)
{
        libiodef_error_source_t source = libiodef_error_get_source(err);
        return dgettext(PACKAGE, msgstr + msgidx[msgidxof((int) source)]);
}