diff options
| author | Jason Rumney | 2007-10-25 23:56:53 +0000 |
|---|---|---|
| committer | Jason Rumney | 2007-10-25 23:56:53 +0000 |
| commit | d22b00e51653ed4c81d1e078f1aa4ff9eb6b1a5b (patch) | |
| tree | 8d6c097b22d8236599ce024885366212a6b15b1f /lib-src | |
| parent | a7d9e21f3c5bd0c80e3a404ce37a3136eae8e036 (diff) | |
| download | emacs-d22b00e51653ed4c81d1e078f1aa4ff9eb6b1a5b.tar.gz emacs-d22b00e51653ed4c81d1e078f1aa4ff9eb6b1a5b.zip | |
(sock_err_message): New function.
(set_tcp_socket): Use it.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 5 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 27 |
2 files changed, 30 insertions, 2 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index a09ba2c078c..c9599fee81d 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2007-10-25 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * emacsclient.c (sock_err_message): New function. | ||
| 4 | (set_tcp_socket): Use it. | ||
| 5 | |||
| 1 | 2007-09-27 Jason Rumney <jasonr@gnu.org> | 6 | 2007-09-27 Jason Rumney <jasonr@gnu.org> |
| 2 | 7 | ||
| 3 | * makefile.w32-in (emacsclient, emacsclientw): Link to COMCTL32. | 8 | * makefile.w32-in (emacsclient, emacsclientw): Link to COMCTL32. |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index c7f0bcf5613..adc580e4768 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -395,6 +395,29 @@ extern int errno; | |||
| 395 | char send_buffer[SEND_BUFFER_SIZE + 1]; | 395 | char send_buffer[SEND_BUFFER_SIZE + 1]; |
| 396 | int sblen = 0; /* Fill pointer for the send buffer. */ | 396 | int sblen = 0; /* Fill pointer for the send buffer. */ |
| 397 | 397 | ||
| 398 | /* On Windows, the socket library was historically separate from the standard | ||
| 399 | C library, so errors are handled differently. */ | ||
| 400 | void | ||
| 401 | sock_err_message (function_name) | ||
| 402 | char *function_name; | ||
| 403 | { | ||
| 404 | #ifdef WINDOWSNT | ||
| 405 | char* msg = NULL; | ||
| 406 | |||
| 407 | FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | ||
| 408 | | FORMAT_MESSAGE_ALLOCATE_BUFFER | ||
| 409 | | FORMAT_MESSAGE_ARGUMENT_ARRAY, | ||
| 410 | NULL, WSAGetLastError (), 0, (LPTSTR)&msg, 0, NULL); | ||
| 411 | |||
| 412 | message (TRUE, "%s: %s: %s\n", progname, function_name, msg); | ||
| 413 | |||
| 414 | LocalFree (msg); | ||
| 415 | #else | ||
| 416 | message (TRUE, "%s: %s: %s\n", progname, function_name, strerror (errno)); | ||
| 417 | #endif | ||
| 418 | } | ||
| 419 | |||
| 420 | |||
| 398 | /* Let's send the data to Emacs when either | 421 | /* Let's send the data to Emacs when either |
| 399 | - the data ends in "\n", or | 422 | - the data ends in "\n", or |
| 400 | - the buffer is full (but this shouldn't happen) | 423 | - the buffer is full (but this shouldn't happen) |
| @@ -646,7 +669,7 @@ set_tcp_socket () | |||
| 646 | */ | 669 | */ |
| 647 | if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) | 670 | if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) |
| 648 | { | 671 | { |
| 649 | message (TRUE, "%s: socket: %s\n", progname, strerror (errno)); | 672 | sock_err_message ("socket"); |
| 650 | return INVALID_SOCKET; | 673 | return INVALID_SOCKET; |
| 651 | } | 674 | } |
| 652 | 675 | ||
| @@ -655,7 +678,7 @@ set_tcp_socket () | |||
| 655 | */ | 678 | */ |
| 656 | if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) | 679 | if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) |
| 657 | { | 680 | { |
| 658 | message (TRUE, "%s: connect: %s\n", progname, strerror (errno)); | 681 | sock_err_message ("connect"); |
| 659 | return INVALID_SOCKET; | 682 | return INVALID_SOCKET; |
| 660 | } | 683 | } |
| 661 | 684 | ||