Commit 7bf778b8 authored by rswindell's avatar rswindell
Browse files

Add global socket_errno_str property for cross-platform description of last

socket-related error.
parent 1089beae
......@@ -60,6 +60,7 @@ enum {
GLOB_PROP_ERRNO
,GLOB_PROP_ERRNO_STR
,GLOB_PROP_SOCKET_ERRNO
,GLOB_PROP_SOCKET_ERRNO_STR
};
BOOL DLLCALL js_argc(JSContext *cx, uintN argc, uintN min)
......@@ -84,6 +85,11 @@ static JSBool js_system_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
case GLOB_PROP_SOCKET_ERRNO:
*vp=DOUBLE_TO_JSVAL(ERROR_VALUE);
break;
case GLOB_PROP_SOCKET_ERRNO_STR:
if((js_str=JS_NewStringCopyZ(cx, socket_strerror(socket_errno)))==NULL)
return(JS_FALSE);
*vp = STRING_TO_JSVAL(js_str);
break;
case GLOB_PROP_ERRNO:
*vp=INT_TO_JSVAL(errno);
break;
......@@ -99,11 +105,12 @@ static JSBool js_system_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
#define GLOBOBJ_FLAGS JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_SHARED
static jsSyncPropertySpec js_global_properties[] = {
/* name, tinyid, flags, ver */
/* name, tinyid, flags, ver */
{ "errno" ,GLOB_PROP_ERRNO ,GLOBOBJ_FLAGS, 310 },
{ "errno_str" ,GLOB_PROP_ERRNO_STR ,GLOBOBJ_FLAGS, 310 },
{ "socket_errno" ,GLOB_PROP_SOCKET_ERRNO ,GLOBOBJ_FLAGS, 310 },
{ "errno" ,GLOB_PROP_ERRNO ,GLOBOBJ_FLAGS, 310 },
{ "errno_str" ,GLOB_PROP_ERRNO_STR ,GLOBOBJ_FLAGS, 310 },
{ "socket_errno" ,GLOB_PROP_SOCKET_ERRNO ,GLOBOBJ_FLAGS, 310 },
{ "socket_errno_str" ,GLOB_PROP_SOCKET_ERRNO ,GLOBOBJ_FLAGS, 31800 },
{0}
};
......
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