mirror of
https://github.com/darlinghq/darling-libxpc.git
synced 2024-11-27 05:30:40 +00:00
Fix style; tie debug output to XPC_DEBUG make option.
This commit is contained in:
parent
1cc56fcd11
commit
718c85f93f
@ -59,8 +59,14 @@ set(SOURCES
|
||||
${UNIX_TRANSPORT_SOURCES}
|
||||
)
|
||||
|
||||
option(XPC_DEBUG "Adds debugging output" OFF)
|
||||
|
||||
if(XPC_DEBUG)
|
||||
add_definitions(-DXPC_DEBUG)
|
||||
endif()
|
||||
|
||||
include_directories(/usr/local/include)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks")
|
||||
add_library(libxpc SHARED ${SOURCES})
|
||||
add_subdirectory(examples)
|
||||
add_library(xpc SHARED ${SOURCES})
|
||||
add_subdirectory(examples)
|
||||
|
@ -155,20 +155,22 @@ unix_port_compare(xpc_port_t p1, xpc_port_t p2)
|
||||
struct unix_port *up1 = (struct unix_port *)p1;
|
||||
struct unix_port *up2 = (struct unix_port *)p2;
|
||||
|
||||
return (strncmp(up1->sun.sun_path, up2->sun.sun_path, sizeof up1->sun.sun_path));
|
||||
return (strncmp(up1->sun.sun_path, up2->sun.sun_path,
|
||||
sizeof up1->sun.sun_path));
|
||||
}
|
||||
|
||||
static dispatch_source_t
|
||||
unix_create_source(xpc_port_t port, dispatch_queue_t tq)
|
||||
{
|
||||
struct unix_port *uport = (struct unix_port *)port;
|
||||
dispatch_source_t source;
|
||||
|
||||
return (dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, (uintptr_t)uport->socket, 0, tq));
|
||||
return (dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,
|
||||
(uintptr_t)uport->socket, 0, tq));
|
||||
}
|
||||
|
||||
static int
|
||||
unix_send(xpc_port_t local, xpc_port_t remote, struct iovec *iov, int niov, struct xpc_resource *res, size_t nres)
|
||||
unix_send(xpc_port_t local, xpc_port_t remote, struct iovec *iov, int niov,
|
||||
struct xpc_resource *res, size_t nres)
|
||||
{
|
||||
struct unix_port *local_port = (struct unix_port *)local;
|
||||
struct unix_port *remote_port = (struct unix_port *)remote;
|
||||
@ -249,7 +251,8 @@ unix_recv(xpc_port_t local, xpc_port_t *remote, struct iovec *iov, int niov,
|
||||
if (recvd < 0)
|
||||
return (-1);
|
||||
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
|
||||
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
if (cmsg->cmsg_type == SCM_CREDS) {
|
||||
recv_creds = (struct cmsgcred *)CMSG_DATA(cmsg);
|
||||
continue;
|
||||
|
@ -32,12 +32,16 @@
|
||||
#include <sys/uio.h>
|
||||
#include "mpack.h"
|
||||
|
||||
#ifdef XPC_DEBUG
|
||||
#define debugf(...) \
|
||||
do { \
|
||||
fprintf(stderr, "%s: ", __func__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while(0);
|
||||
#else
|
||||
#define debugf(...)
|
||||
#endif
|
||||
|
||||
#define _XPC_TYPE_INVALID 0
|
||||
#define _XPC_TYPE_DICTIONARY 1
|
||||
@ -158,8 +162,8 @@ struct xpc_connection {
|
||||
|
||||
struct xpc_resource {
|
||||
int xr_type;
|
||||
#define XPC_RESOURCE_FD 1
|
||||
#define XPC_RESOURCE_SHMEM 2
|
||||
#define XPC_RESOURCE_FD 0x01
|
||||
#define XPC_RESOURCE_SHMEM 0x02
|
||||
union {
|
||||
int xr_fd;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user