Convert connection functions to return error objects.
This commit is contained in:
parent
ac17ae62fe
commit
0aa96bfc7a
|
@ -44,6 +44,8 @@ typedef struct {
|
||||||
CARD16 length;
|
CARD16 length;
|
||||||
} XCBSetupGeneric;
|
} XCBSetupGeneric;
|
||||||
|
|
||||||
|
static const int error_connection = 1;
|
||||||
|
|
||||||
static int set_fd_flags(const int fd)
|
static int set_fd_flags(const int fd)
|
||||||
{
|
{
|
||||||
long flags = fcntl(fd, F_GETFL, 0);
|
long flags = fcntl(fd, F_GETFL, 0);
|
||||||
|
@ -199,7 +201,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info)
|
||||||
|
|
||||||
c = calloc(1, sizeof(XCBConnection));
|
c = calloc(1, sizeof(XCBConnection));
|
||||||
if(!c)
|
if(!c)
|
||||||
return 0;
|
return (XCBConnection *) &error_connection;
|
||||||
|
|
||||||
c->fd = fd;
|
c->fd = fd;
|
||||||
|
|
||||||
|
@ -215,7 +217,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info)
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
XCBDisconnect(c);
|
XCBDisconnect(c);
|
||||||
return 0;
|
return (XCBConnection *) &error_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include "xcbext.h"
|
#include "xcbext.h"
|
||||||
#include "xcbint.h"
|
#include "xcbint.h"
|
||||||
|
|
||||||
|
static const int error_connection = 1;
|
||||||
|
|
||||||
int XCBPopcount(CARD32 mask)
|
int XCBPopcount(CARD32 mask)
|
||||||
{
|
{
|
||||||
unsigned long y;
|
unsigned long y;
|
||||||
|
@ -212,11 +214,11 @@ XCBConnection *XCBConnect(const char *displayname, int *screenp)
|
||||||
XCBAuthInfo auth;
|
XCBAuthInfo auth;
|
||||||
|
|
||||||
if(!XCBParseDisplay(displayname, &host, &display, screenp))
|
if(!XCBParseDisplay(displayname, &host, &display, screenp))
|
||||||
return 0;
|
return (XCBConnection *) &error_connection;
|
||||||
fd = _xcb_open(host, display);
|
fd = _xcb_open(host, display);
|
||||||
free(host);
|
free(host);
|
||||||
if(fd == -1)
|
if(fd == -1)
|
||||||
return 0;
|
return (XCBConnection *) &error_connection;
|
||||||
|
|
||||||
_xcb_get_auth_info(fd, &auth);
|
_xcb_get_auth_info(fd, &auth);
|
||||||
c = XCBConnectToFD(fd, &auth);
|
c = XCBConnectToFD(fd, &auth);
|
||||||
|
@ -231,11 +233,11 @@ XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *displayname, XCBAuthI
|
||||||
char *host;
|
char *host;
|
||||||
|
|
||||||
if(!XCBParseDisplay(displayname, &host, &display, screenp))
|
if(!XCBParseDisplay(displayname, &host, &display, screenp))
|
||||||
return 0;
|
return (XCBConnection *) &error_connection;
|
||||||
fd = _xcb_open(host, display);
|
fd = _xcb_open(host, display);
|
||||||
free(host);
|
free(host);
|
||||||
if(fd == -1)
|
if(fd == -1)
|
||||||
return 0;
|
return (XCBConnection *) &error_connection;
|
||||||
|
|
||||||
return XCBConnectToFD(fd, auth);
|
return XCBConnectToFD(fd, auth);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue