Kris YotamImport dwm historybc80b522 months agoHistory
67 lines · 1.2 KB · C
RawDownload
#include "IPCClient.h" #include <string.h>#include <sys/epoll.h> #include "util.h" IPCClient *ipc_client_new(int fd){  IPCClient *c = (IPCClient *)malloc(sizeof(IPCClient));   if (c == NULL) return NULL;   // Initialize struct  memset(&c->event, 0, sizeof(struct epoll_event));   c->buffer_size = 0;  c->buffer = NULL;  c->fd = fd;  c->event.data.fd = fd;  c->next = NULL;  c->prev = NULL;  c->subscriptions = 0;   return c;} voidipc_list_add_client(IPCClientList *list, IPCClient *nc){  DEBUG("Adding client with fd %d to list\n", nc->fd);   if (*list == NULL) {    // List is empty, point list at first client    *list = nc;  } else {    IPCClient *c;    // Go to last client in list    for (c = *list; c && c->next; c = c->next)      ;    c->next = nc;    nc->prev = c;  }} voidipc_list_remove_client(IPCClientList *list, IPCClient *c){  IPCClient *cprev = c->prev;  IPCClient *cnext = c->next;   if (cprev != NULL) cprev->next = c->next;  if (cnext != NULL) cnext->prev = c->prev;  if (c == *list) *list = c->next;} IPCClient *ipc_list_get_client(IPCClientList list, int fd){  for (IPCClient *c = list; c; c = c->next) {    if (c->fd == fd) return c;  }   return NULL;} 

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t