Mercurial > geeqie.yaz
comparison src/remote.c @ 673:fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
author | zas_ |
---|---|
date | Fri, 16 May 2008 12:16:49 +0000 |
parents | 8268cbe682f1 |
children | c0dda0ffb931 |
comparison
equal
deleted
inserted
replaced
672:913eb0ba99a6 | 673:fbebf5cf4a55 |
---|---|
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 if (error) | 93 if (error) |
94 { | 94 { |
95 printf("error reading socket: %s\n", error->message); | 95 log_printf("error reading socket: %s\n", error->message); |
96 g_error_free(error); | 96 g_error_free(error); |
97 } | 97 } |
98 | 98 |
99 work = queue; | 99 work = queue; |
100 while (work) | 100 while (work) |
129 RemoteClient *client; | 129 RemoteClient *client; |
130 GIOChannel *channel; | 130 GIOChannel *channel; |
131 | 131 |
132 if (g_list_length(rc->clients) > SERVER_MAX_CLIENTS) | 132 if (g_list_length(rc->clients) > SERVER_MAX_CLIENTS) |
133 { | 133 { |
134 printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS); | 134 log_printf("maximum remote clients of %d exceeded, closing connection\n", SERVER_MAX_CLIENTS); |
135 close(fd); | 135 close(fd); |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 client = g_new0(RemoteClient, 1); | 139 client = g_new0(RemoteClient, 1); |
170 unsigned int alen; | 170 unsigned int alen; |
171 | 171 |
172 fd = accept(rc->fd, NULL, &alen); | 172 fd = accept(rc->fd, NULL, &alen); |
173 if (fd == -1) | 173 if (fd == -1) |
174 { | 174 { |
175 printf("error accepting socket: %s\n", strerror(errno)); | 175 log_printf("error accepting socket: %s\n", strerror(errno)); |
176 return TRUE; | 176 return TRUE; |
177 } | 177 } |
178 | 178 |
179 remote_server_client_add(rc, fd); | 179 remote_server_client_add(rc, fd); |
180 | 180 |
204 int fd; | 204 int fd; |
205 GIOChannel *channel; | 205 GIOChannel *channel; |
206 | 206 |
207 if (remote_server_exists(path)) | 207 if (remote_server_exists(path)) |
208 { | 208 { |
209 printf("Address already in use: %s\n", path); | 209 log_printf("Address already in use: %s\n", path); |
210 return NULL; | 210 return NULL; |
211 } | 211 } |
212 | 212 |
213 fd = socket(PF_UNIX, SOCK_STREAM, 0); | 213 fd = socket(PF_UNIX, SOCK_STREAM, 0); |
214 if (fd == -1) return NULL; | 214 if (fd == -1) return NULL; |
217 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX); | 217 sun_path_len = MIN(strlen(path) + 1, UNIX_PATH_MAX); |
218 strncpy(addr.sun_path, path, sun_path_len); | 218 strncpy(addr.sun_path, path, sun_path_len); |
219 if (bind(fd, &addr, sizeof(addr)) == -1 || | 219 if (bind(fd, &addr, sizeof(addr)) == -1 || |
220 listen(fd, REMOTE_SERVER_BACKLOG) == -1) | 220 listen(fd, REMOTE_SERVER_BACKLOG) == -1) |
221 { | 221 { |
222 printf("error subscribing to socket: %s\n", strerror(errno)); | 222 log_printf("error subscribing to socket: %s\n", strerror(errno)); |
223 close(fd); | 223 close(fd); |
224 return NULL; | 224 return NULL; |
225 } | 225 } |
226 | 226 |
227 rc = g_new0(RemoteConnection, 1); | 227 rc = g_new0(RemoteConnection, 1); |
312 if (write(rc->fd, text, strlen(text)) == -1 || | 312 if (write(rc->fd, text, strlen(text)) == -1 || |
313 write(rc->fd, "\n", 1) == -1) | 313 write(rc->fd, "\n", 1) == -1) |
314 { | 314 { |
315 if (sigpipe_occured) | 315 if (sigpipe_occured) |
316 { | 316 { |
317 printf("SIGPIPE writing to socket: %s\n", rc->path); | 317 log_printf("SIGPIPE writing to socket: %s\n", rc->path); |
318 } | 318 } |
319 else | 319 else |
320 { | 320 { |
321 printf("error writing to socket: %s\n", strerror(errno)); | 321 log_printf("error writing to socket: %s\n", strerror(errno)); |
322 } | 322 } |
323 ret = FALSE;; | 323 ret = FALSE;; |
324 } | 324 } |
325 else | 325 else |
326 { | 326 { |
491 { | 491 { |
492 layout_set_path(NULL, filename); | 492 layout_set_path(NULL, filename); |
493 } | 493 } |
494 else | 494 else |
495 { | 495 { |
496 printf("remote sent filename that does not exist:\"%s\"\n", filename); | 496 log_printf("remote sent filename that does not exist:\"%s\"\n", filename); |
497 } | 497 } |
498 | 498 |
499 g_free(filename); | 499 g_free(filename); |
500 } | 500 } |
501 | 501 |
642 { | 642 { |
643 entry->func(offset, data); | 643 entry->func(offset, data); |
644 } | 644 } |
645 else | 645 else |
646 { | 646 { |
647 printf("unknown remote command:%s\n", text); | 647 log_printf("unknown remote command:%s\n", text); |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 void remote_help(void) | 651 void remote_help(void) |
652 { | 652 { |