Commit 6036d3df authored by Pekka Pessi's avatar Pekka Pessi

Using sofia-sip/su_errno.h for error codes not present in win32.

darcs-hash:20060313162517-65a35-a2b29d112c8d9d702da090b93f45883436110783.gz
parent feb42d53
......@@ -52,12 +52,7 @@
#include "sofia-sip/msg_mime.h"
#include <sofia-sip/su_uniqueid.h>
#ifndef EBADMSG
/*xxx -- mela: check the number */
#define EBADMSG 71
#endif
#include <sofia-sip/su_errno.h>
#if !HAVE_MEMMEM
void *memmem(const void *haystack, size_t haystacklen,
......
......@@ -59,10 +59,6 @@
#include "sofia-sip/msg_mclass_hash.h"
#include "sofia-sip/msg_mime.h"
#if !defined(ENOBUFS) && defined(_WIN32)
#define ENOBUFS WSAENOBUFS
#endif
#if HAVE_FUNC
#elif HAVE_FUNCTION
#define __func__ __FUNCTION__
......
......@@ -52,14 +52,7 @@
#include <sofia-sip/su_uniqueid.h>
#include <sofia-sip/string0.h>
#ifndef EALREADY && defined(_WIN32)
#define EALREADY WSAEALREADY
#endif
#ifndef EPROTO && defined(_WIN32)
#define EPROTO 127 /* XXX -- mela: wrong number? */
#endif
#include <sofia-sip/su_errno.h>
#define NONE ((void *)-1)
#define XXX assert(!"implemented")
......
......@@ -69,6 +69,42 @@ int su_seterrno(int);
#endif
#endif
#if defined(_WIN32)
#ifndef ENOBUFS
#define ENOBUFS (10055) /* WSAENOBUFS */
#endif
#ifndef EMSGSIZE
#define EMSGSIZE (10040) /* WSAEMSGSIZE */
#endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT (10043) /* WSAEPROTONOSUPPORT */
#endif
#ifndef EALREADY
#define EALREADY (10037) /* WSAEALREADY */
#endif
#ifndef EBADMSG
# if defined(WSABADMSG)
# define EBADMSG (WSAEBADMSG)
# else
# define EBADMSG (20005)
# endif
#endif
#ifndef EPROTO
# if defined(WSAEPROTO)
# define EPROTO WSAEPROTO
# else
# define EPROTO (20006)
# endif
#endif
#endif
SOFIA_END_DECLS
#endif
......@@ -57,7 +57,9 @@ int su_seterrno(int errcode)
const char *su_strerror(int errcode)
{
static struct { int no; const char *msg; } *msgp, msgs[] = {
struct errmsg { int no; const char *msg; };
static struct errmsg *msgp;
static struct errmsg msgs[] = {
{ 0, "Success" },
{ WSAEINTR, "Interrupted system call" },
{ WSAEBADF, "Bad file descriptor" },
......@@ -119,14 +121,28 @@ const char *su_strerror(int errcode)
{ WSANO_ADDRESS, "No address, look for MX record" },
{ 0, NULL }
};
static struct errmsg sofia_msgs[] = {
{ EBADMSG, "Bad message" },
{ EPROTO, "Protocol error" },
{ 0, NULL }
};
static char buf[64];
for (msgp = msgs; msgp->msg; msgp++) {
if (errcode == msgp->no) {
return msgp->msg;
if (errcode < WSABASEERR)
return strerror(errcode);
if (errcode < 20000)
for (msgp = msgs; msgp->msg; msgp++) {
if (errcode == msgp->no) {
return msgp->msg;
}
}
else
for (msgp = sofia_msgs; msgp->msg; msgp++) {
if (errcode == msgp->no) {
return msgp->msg;
}
}
}
/* This can not overflow, but in other hand, it is not thread-safe */
sprintf(buf, "winsock error %d", errcode);
......
......@@ -97,11 +97,4 @@
#define srandom(x) srand((x))
#define random() rand()
#define ENOBUFS (20001)
#define EMSGSIZE (20002)
#define EPROTONOSUPPORT (20003)
#define EALREADY (20004)
#define EBADMSG (20005)
#define EPROTO (20006)
#define ssize_t SSIZE_T
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment