FreeCalypso > hg > freecalypso-tools
comparison rvinterf/libasync/init.c @ 63:09b4fd9b3827
rvinterf/libasync: use the newly adopted exit code convention
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 26 Oct 2016 22:00:39 +0000 |
| parents | e7502631a0f9 |
| children | c1aadfcd185f |
comparison
equal
deleted
inserted
replaced
| 62:2dd9dbe3f4a7 | 63:09b4fd9b3827 |
|---|---|
| 1 /* | 1 /* |
| 2 * This module contains the common initialization code for fc-tmsh and g23sh. | 2 * This module contains the common initialization code for fc-shell and fc-tmsh. |
| 3 */ | 3 */ |
| 4 | 4 |
| 5 #include <sys/types.h> | 5 #include <sys/types.h> |
| 6 #include <sys/socket.h> | 6 #include <sys/socket.h> |
| 7 #include <sys/un.h> | 7 #include <sys/un.h> |
| 10 #include <strings.h> | 10 #include <strings.h> |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 #include "pktmux.h" | 13 #include "pktmux.h" |
| 14 #include "localsock.h" | 14 #include "localsock.h" |
| 15 #include "exitcodes.h" | |
| 15 | 16 |
| 16 extern char *socket_pathname; | 17 extern char *socket_pathname; |
| 17 extern int sock; | 18 extern int sock; |
| 18 | 19 |
| 19 connect_local_socket() | 20 connect_local_socket() |
| 24 int rc; | 25 int rc; |
| 25 | 26 |
| 26 sock = socket(AF_UNIX, SOCK_STREAM, 0); | 27 sock = socket(AF_UNIX, SOCK_STREAM, 0); |
| 27 if (sock < 0) { | 28 if (sock < 0) { |
| 28 perror("socket(AF_UNIX, SOCK_STREAM, 0)"); | 29 perror("socket(AF_UNIX, SOCK_STREAM, 0)"); |
| 29 exit(1); | 30 exit(ERROR_UNIX); |
| 30 } | 31 } |
| 31 | 32 |
| 32 local.sun_family = AF_UNIX; | 33 local.sun_family = AF_UNIX; |
| 33 strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path)); | 34 strncpy(local.sun_path, socket_pathname, sizeof(local.sun_path)); |
| 34 local.sun_path[sizeof(local.sun_path) - 1] = '\0'; | 35 local.sun_path[sizeof(local.sun_path) - 1] = '\0'; |
| 46 #endif | 47 #endif |
| 47 | 48 |
| 48 rc = connect(sock, (struct sockaddr *) &local, namelen); | 49 rc = connect(sock, (struct sockaddr *) &local, namelen); |
| 49 if (rc != 0) { | 50 if (rc != 0) { |
| 50 perror(socket_pathname); | 51 perror(socket_pathname); |
| 51 exit(1); | 52 exit(ERROR_RVINTERF); |
| 52 } | 53 } |
| 53 | 54 |
| 54 return(0); | 55 return(0); |
| 55 } | 56 } |
| 56 | 57 |
