#include "irc.h" #include "unix.h" #include "conf.h" #include "debug.h" #include #include #include static int socket_fname(char chname[], char out[], size_t lim) { if (strlen(chname) > 16) return -1; if (snprintf(out, lim, SOCKETDIR"/%s.sock", chname) >= lim) { return -1; } return 0; } int main() { if (irc_connect()) { fputs("falure in irc_connect\n",stderr); return 1; } if (irc_handshake()) { fputs("failure in irc_handshake\n",stderr); return 1; } int unixfd; if ((unixfd = unix_setup("bees2.sock")) == -1) { fputs("failure in unix_setup\n",stderr); return -1; } // pfs[0] is the irc socket // pfs[k>=1] is the unix socket that should send to channel g_chanlist[k-1] struct pollfd *pfs = malloc((1 + g_nchannels) * sizeof(struct pollfd)); pfs[0].fd = g_ircsock; pfs[0].events = POLLIN; char fname[100]; for (int i = 0; irevents & (POLLERR|POLLHUP)) { fputs("unix socket error\n",stderr); return 1; } if (p->revents & POLLIN) { if (unix_handle(p->fd,g_chanlist[i]) == -1) { fputs("unix_handle failure\n",stderr); return 1; } } } } return 0; }