src/nexus.c
changeset 7 844f014409ff
parent 6 240ae8482d64
child 8 be88e543c8ff
equal deleted inserted replaced
6:240ae8482d64 7:844f014409ff
     9 #include <err.h>
     9 #include <err.h>
    10 
    10 
    11 #include "sock.h"
    11 #include "sock.h"
    12 
    12 
    13 #define CONNECT_HOST "irc.fixme.fi"
    13 #define CONNECT_HOST "irc.fixme.fi"
    14 #define CONNECT_SERV "6697"
    14 #define CONNECT_SERV "66976"
    15 #define LINE_LENGTH 512
    15 #define LINE_LENGTH 512
    16 
    16 
    17 struct recvline_state {
    17 struct recvline_state {
    18     size_t tail_offset;
    18     size_t tail_offset;
    19     size_t tail_len;
    19     size_t tail_len;
   110     struct recvline_state recvline_ctx;
   110     struct recvline_state recvline_ctx;
   111     struct error_info err;
   111     struct error_info err;
   112 
   112 
   113     // initialize
   113     // initialize
   114     if (sock_init(&err))
   114     if (sock_init(&err))
   115         errx(1, "sock_init: %s", error_name(ERROR_CODE(&err)));
   115         errx(1, "sock_init: %s", error_msg(&err));
   116 
   116 
   117     memset(&recvline_ctx, 0, sizeof(recvline_ctx));
   117     memset(&recvline_ctx, 0, sizeof(recvline_ctx));
   118     
   118     
   119     // over-simplified connect
   119     // over-simplified connect
   120     if (sock_gnutls_connect(&sock, CONNECT_HOST, CONNECT_SERV, &err))
   120     if (sock_gnutls_connect(&sock, CONNECT_HOST, CONNECT_SERV, &err))
   121         errx(1, "sock_gnutls_connect: %s", error_name(ERROR_CODE(&err)));
   121         errx(1, "sock_gnutls_connect: %s", error_msg(&err));
   122 
   122 
   123     // read lines and dump them out
   123     // read lines and dump them out
   124     do {
   124     do {
   125         // recv
   125         // recv
   126         recvline(sock, line_buf, sizeof(line_buf), &recvline_ctx);
   126         recvline(sock, line_buf, sizeof(line_buf), &recvline_ctx);