int fd;
/* The question we read from client. */
char *question;
+ /* The answer to the client. */
+ const char *answer;
/* How many bytes of the reply we sent so far. */
size_t bytes_sent;
/* Our server. */
struct client *clients[5];
int fd;
struct tevent_fd *fde;
+ const char *last_answer;
};
static ssize_t write_string(int fd, const char *str)
if (len <= 0)
goto fail;
if (input_finished(c->question)) {
- unsigned int i;
-
- for (i = 0; c->question[i]; i++)
- c->question[i] = toupper(c->question[i]);
+ c->answer = talloc_steal(c, c->oserver->last_answer);
+ c->oserver->last_answer
+ = talloc_steal(c->oserver, c->question);
set_state(c, SENDING_ANSWER_PREFIX);
}
break;
case SENDING_ANSWER_PREFIX:
- if (!send_string(c, "Our answer is:\n"))
+ if (!send_string(c, "I believe a better question is "))
goto fail;
break;
case SENDING_ANSWER:
- if (!send_string(c, c->question))
+ if (!send_string(c, c->answer))
goto fail;
break;
default:
talloc_free(oserver);
return NULL;
}
-
+ oserver->last_answer = talloc_strdup(oserver,
+ "how many manly men mendaciously"
+ " mention mending mansions?\n");
+
talloc_set_destructor(oserver, destroy_oserver);
if (setsockopt(oserver->fd, SOL_SOCKET, SO_REUSEADDR,