Ignore:
Timestamp:
Nov 29, 2009, 12:29:51 PM (11 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Moved socket-related stuff to struct comm
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/attach.c

    r3996 r4059  
    8787
    8888    myaddr.sun_family = AF_UNIX;
    89     strncpy(myaddr.sun_path, screen_list->socket_path[socktype],
     89    strncpy(myaddr.sun_path, screen_list->comm.socket_path[socktype],
    9090            sizeof(myaddr.sun_path) - 1);
    9191
    92     unlink(screen_list->socket_path[socktype]);
     92    unlink(screen_list->comm.socket_path[socktype]);
    9393
    9494    if (bind(sock, (struct sockaddr *)&myaddr, sizeof(struct sockaddr_un)) < 0)
    9595    {
    96         free(screen_list->socket_path[socktype]);
    97         screen_list->socket_path[socktype] = NULL;
     96        free(screen_list->comm.socket_path[socktype]);
     97        screen_list->comm.socket_path[socktype] = NULL;
    9898        close(sock);
    9999        perror("create_socket:bind");
     
    102102    fcntl(sock, F_SETFL, O_NONBLOCK);
    103103
    104     debug("Listening on %s (%d)", screen_list->socket_path[socktype], sock);
    105 
    106     screen_list->socket[socktype] = sock;
     104    debug("Listening on %s (%d)", screen_list->comm.socket_path[socktype], sock);
     105
     106    screen_list->comm.socket[socktype] = sock;
    107107
    108108    return 0;
     
    162162    memset(&addr, 0, sizeof(addr));
    163163    addr.sun_family = AF_UNIX;
    164     strcpy(addr.sun_path, screen_list->socket_path[socktype]);
     164    strcpy(addr.sun_path, screen_list->comm.socket_path[socktype]);
    165165    if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
    166166    {
    167167        debug("Failed to connect to %s: %s",
    168               screen_list->socket_path[socktype], strerror(errno));
     168              screen_list->comm.socket_path[socktype], strerror(errno));
    169169        close(sock);
    170170        return NULL;
     
    172172    fcntl(sock, F_SETFL, O_NONBLOCK);
    173173
    174     screen_list->socket[socktype] = sock;
     174    screen_list->comm.socket[socktype] = sock;
    175175
    176176    if (socktype == SOCK_SERVER)
    177177    {
    178         return socket_to_session(screen_list->socket_path[socktype]);
     178        return socket_to_session(screen_list->comm.socket_path[socktype]);
    179179    }
    180180    else
     
    193193    buf[bytes] = '\0';
    194194    debug("Requesting attach: %s", buf);
    195     return write(screen_list->socket[SOCK_SERVER], buf, strlen(buf)) <= 0;
     195    return write(screen_list->comm.socket[SOCK_SERVER], buf, strlen(buf)) <= 0;
    196196}
    197197
     
    202202    char *ret = NULL;
    203203
    204     sockets = list_sockets(screen_list->socket_dir, screen_list->session_name);
     204    sockets = list_sockets(screen_list->comm.socket_dir, screen_list->comm.session_name);
    205205    if (sockets)
    206206    {
     
    384384void attach(struct screen_list *screen_list)
    385385{
    386     screen_list->socket_path[SOCK_SERVER] = select_socket(screen_list);
    387 
    388     if (screen_list->socket_path[SOCK_SERVER])
     386    screen_list->comm.socket_path[SOCK_SERVER] = select_socket(screen_list);
     387
     388    if (screen_list->comm.socket_path[SOCK_SERVER])
    389389    {
    390390        char *session;
     
    401401            caca_set_cursor(screen_list->dp, 1);
    402402
    403             screen_list->socket_path[SOCK_CLIENT] =
    404                 build_socket_path(screen_list->socket_dir, session,
     403            screen_list->comm.socket_path[SOCK_CLIENT] =
     404                build_socket_path(screen_list->comm.socket_dir, session,
    405405                                  SOCK_CLIENT);
    406406            create_socket(screen_list, SOCK_CLIENT);
    407407            request_attach(screen_list);
    408             if (screen_list->session_name)
    409                 free(screen_list->session_name);
    410             screen_list->session_name = session;
     408            if (screen_list->comm.session_name)
     409                free(screen_list->comm.session_name);
     410            screen_list->comm.session_name = session;
    411411        }
    412412        else
    413413        {
    414414            fprintf(stderr, "Failed to attach!\n");
    415             free(screen_list->socket_path[SOCK_SERVER]);
    416             screen_list->socket_path[SOCK_SERVER] = NULL;
     415            free(screen_list->comm.socket_path[SOCK_SERVER]);
     416            screen_list->comm.socket_path[SOCK_SERVER] = NULL;
    417417            screen_list->attach = 0;
    418418        }
Note: See TracChangeset for help on using the changeset viewer.