Commit 20f12e86 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac366] Small fixups

parent 13668e95
......@@ -33,10 +33,10 @@ must be a socket, not pipe.
like hton called on them).
The answer to this is either 'S' and then the socket is passed using sendmsg
if it is successful. If it fails, 'E' is returned, followed by either
'S' or 'B' (either socket() or bind() call failed). Then there is one int
(architecture-dependent length and endianess), which is the errno value
after the failure.
if it is successful (it uses our send_fd, you can use recv_fd to read it).
If it fails, 'E' is returned, followed by either 'S' or 'B' (either socket()
or bind() call failed). Then there is one int (architecture-dependent length
and endianess), which is the errno value after the failure.
The creator may also send these messages at any time (but not in the middle
of another message):
......
......@@ -41,15 +41,6 @@ get_sock(const int type, struct sockaddr *bind_addr, const socklen_t addr_len)
return sock;
}
int
send_fd(const int, const int) {
return 0;
}
int
run(const int input_fd, const int output_fd, const get_sock_t get_sock,
const send_fd_t send_fd)
{
// These are macros so they can exit the function
#define READ(WHERE, HOW_MANY) do { \
size_t how_many = (HOW_MANY); \
......@@ -57,15 +48,22 @@ run(const int input_fd, const int output_fd, const get_sock_t get_sock,
return 1; \
} \
} while (0)
#define WRITE(WHAT, HOW_MANY) do { \
if (!write_data(output_fd, (WHAT), (HOW_MANY))) { \
return 2; \
} \
} while (0)
#define DEFAULT \
default: /* Unrecognized part of protocol */ \
WRITE("FI", 2); \
return 3;
int
run(const int input_fd, const int output_fd, const get_sock_t get_sock,
const send_fd_t send_fd)
{
for (;;) {
// Read the command
char command;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment