Changeset 3324
- Timestamp:
- Nov 15, 2008, 12:50:48 AM (14 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/attach.c
r2995 r3324 163 163 } 164 164 165 void attach(struct screen_list* screen_list) 166 { 167 char **sockets; 168 int i; 169 170 sockets = list_sockets(screen_list->socket_dir, screen_list->session_name); 171 if(sockets && sockets[0]) 172 { 173 char *session; 174 for(i=0; sockets[i]; i++); 175 i--; 176 screen_list->socket_path[SOCK_SERVER] = strdup(sockets[i]); 177 session = connect_socket(screen_list, SOCK_SERVER); 178 while(!session && i > 0) 179 { 180 free(screen_list->socket_path[SOCK_SERVER]); 181 i--; 182 screen_list->socket_path[SOCK_SERVER] = strdup(sockets[i]); 183 session = connect_socket(screen_list, SOCK_SERVER); 184 } 185 debug("Connected to session %s", session); 186 if(session) 187 { 188 /* Create main canvas and associated caca window */ 189 screen_list->cv = caca_create_canvas(0, 0); 190 screen_list->dp = caca_create_display(screen_list->cv); 191 if(!screen_list->dp) 192 return; 193 caca_set_cursor(screen_list->dp, 1); 194 195 screen_list->socket_path[SOCK_CLIENT] = 196 build_socket_path(screen_list->socket_dir, session, SOCK_CLIENT); 197 create_socket(screen_list, SOCK_CLIENT); 198 request_attach(screen_list); 199 if(screen_list->session_name) 200 free(screen_list->session_name); 201 screen_list->session_name = session; 202 } 203 else 204 { 205 fprintf(stderr, "Failed to attach!\n"); 206 free(screen_list->socket_path[SOCK_SERVER]); 207 screen_list->socket_path[SOCK_SERVER] = NULL; 208 screen_list->attach = 0; 209 } 210 for(i=0; sockets[i]; i++) 211 free(sockets[i]); 212 free(sockets); 213 } 214 else 215 { 216 fprintf(stderr, "No socket found!\n"); 217 screen_list->attach = 0; 218 } 219 } 220 165 221 int send_event(caca_event_t ev, struct screen_list* screen_list) 166 222 { -
neercs/trunk/src/main.c
r2995 r3324 110 110 if(screen_list->attach) 111 111 { 112 char **sockets;113 112 if(screen_list->nb_to_grab || screen_list->to_start) 114 113 { … … 117 116 } 118 117 119 sockets = list_sockets(screen_list->socket_dir, screen_list->session_name); 120 if(sockets && sockets[0]) 121 { 122 char *session; 123 for(i=0; sockets[i]; i++); 124 i--; 125 screen_list->socket_path[SOCK_SERVER] = strdup(sockets[i]); 126 session = connect_socket(screen_list, SOCK_SERVER); 127 while(!session && i > 0) 128 { 129 free(screen_list->socket_path[SOCK_SERVER]); 130 i--; 131 screen_list->socket_path[SOCK_SERVER] = strdup(sockets[i]); 132 session = connect_socket(screen_list, SOCK_SERVER); 133 } 134 debug("Connected to session %s", session); 135 if(session) 136 { 137 /* Create main canvas and associated caca window */ 138 screen_list->cv = caca_create_canvas(0, 0); 139 screen_list->dp = caca_create_display(screen_list->cv); 140 if(!screen_list->dp) 141 goto end; 142 caca_set_cursor(screen_list->dp, 1); 143 144 screen_list->socket_path[SOCK_CLIENT] = 145 build_socket_path(screen_list->socket_dir, session, SOCK_CLIENT); 146 create_socket(screen_list, SOCK_CLIENT); 147 request_attach(screen_list); 148 if(screen_list->session_name) 149 free(screen_list->session_name); 150 screen_list->session_name = session; 151 } 152 else 153 { 154 fprintf(stderr, "Failed to attach!\n"); 155 free(screen_list->socket_path[SOCK_SERVER]); 156 screen_list->socket_path[SOCK_SERVER] = NULL; 157 screen_list->attach = 0; 158 } 159 for(i=0; sockets[i]; i++) 160 free(sockets[i]); 161 free(sockets); 162 } 163 else 164 { 165 fprintf(stderr, "No socket found!\n"); 166 screen_list->attach = 0; 167 } 118 attach(screen_list); 119 168 120 if(screen_list->forceattach && !screen_list->attach) 169 121 goto end; -
neercs/trunk/src/neercs.h
r2995 r3324 232 232 long long get_us(void); 233 233 234 void attach(struct screen_list* screen_list); 234 235 int detach(struct screen_list* screen_list); 235 236 int request_attach(struct screen_list* screen_list);
Note: See TracChangeset
for help on using the changeset viewer.