FreeCalypso > hg > freecalypso-sw
comparison rvinterf/lowlevel/localsock.c @ 187:f5f8776f7c66
rvinterf: added -s option for changing the local socket pathname
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Sun, 24 Nov 2013 23:25:59 +0000 |
| parents | ec040f521cc2 |
| children | 549e6cd1e77d |
comparison
equal
deleted
inserted
replaced
| 186:faa31a47f102 | 187:f5f8776f7c66 |
|---|---|
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 #include "../localsock.h" | 13 #include "../localsock.h" |
| 14 #include "client.h" | 14 #include "client.h" |
| 15 | 15 |
| 16 static char sockpath[] = "/tmp/rvinterf_socket"; | |
| 17 | |
| 18 int listener; | 16 int listener; |
| 19 | 17 |
| 20 extern struct client *client_head; | 18 extern struct client *client_head; |
| 21 extern int max_fd; | 19 extern int max_fd; |
| 20 extern char *socket_pathname; | |
| 22 | 21 |
| 23 create_listener_socket() | 22 create_listener_socket() |
| 24 { | 23 { |
| 25 /* local socket binding voodoo copied from osmocon */ | 24 /* local socket binding voodoo copied from osmocon */ |
| 26 struct sockaddr_un local; | 25 struct sockaddr_un local; |
| 32 perror("socket(AF_UNIX, SOCK_STREAM, 0)"); | 31 perror("socket(AF_UNIX, SOCK_STREAM, 0)"); |
| 33 exit(1); | 32 exit(1); |
| 34 } | 33 } |
| 35 | 34 |
| 36 local.sun_family = AF_UNIX; | 35 local.sun_family = AF_UNIX; |
| 37 strncpy(local.sun_path, sockpath, sizeof(local.sun_path)); | 36 strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path)); |
| 38 local.sun_path[sizeof(local.sun_path) - 1] = '\0'; | 37 local.sun_path[sizeof(local.sun_path) - 1] = '\0'; |
| 39 unlink(local.sun_path); | 38 unlink(local.sun_path); |
| 40 | 39 |
| 41 /* we use the same magic that X11 uses in Xtranssock.c for | 40 /* we use the same magic that X11 uses in Xtranssock.c for |
| 42 * calculating the proper length of the sockaddr */ | 41 * calculating the proper length of the sockaddr */ |
