Changeset 4059 for neercs/trunk/src/attach.c
- Timestamp:
- Nov 29, 2009, 12:29:51 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/attach.c
r3996 r4059 87 87 88 88 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], 90 90 sizeof(myaddr.sun_path) - 1); 91 91 92 unlink(screen_list-> socket_path[socktype]);92 unlink(screen_list->comm.socket_path[socktype]); 93 93 94 94 if (bind(sock, (struct sockaddr *)&myaddr, sizeof(struct sockaddr_un)) < 0) 95 95 { 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; 98 98 close(sock); 99 99 perror("create_socket:bind"); … … 102 102 fcntl(sock, F_SETFL, O_NONBLOCK); 103 103 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; 107 107 108 108 return 0; … … 162 162 memset(&addr, 0, sizeof(addr)); 163 163 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]); 165 165 if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) 166 166 { 167 167 debug("Failed to connect to %s: %s", 168 screen_list-> socket_path[socktype], strerror(errno));168 screen_list->comm.socket_path[socktype], strerror(errno)); 169 169 close(sock); 170 170 return NULL; … … 172 172 fcntl(sock, F_SETFL, O_NONBLOCK); 173 173 174 screen_list-> socket[socktype] = sock;174 screen_list->comm.socket[socktype] = sock; 175 175 176 176 if (socktype == SOCK_SERVER) 177 177 { 178 return socket_to_session(screen_list-> socket_path[socktype]);178 return socket_to_session(screen_list->comm.socket_path[socktype]); 179 179 } 180 180 else … … 193 193 buf[bytes] = '\0'; 194 194 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; 196 196 } 197 197 … … 202 202 char *ret = NULL; 203 203 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); 205 205 if (sockets) 206 206 { … … 384 384 void attach(struct screen_list *screen_list) 385 385 { 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]) 389 389 { 390 390 char *session; … … 401 401 caca_set_cursor(screen_list->dp, 1); 402 402 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, 405 405 SOCK_CLIENT); 406 406 create_socket(screen_list, SOCK_CLIENT); 407 407 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; 411 411 } 412 412 else 413 413 { 414 414 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; 417 417 screen_list->attach = 0; 418 418 }
Note: See TracChangeset
for help on using the changeset viewer.