FILE *id;
#endif
FILE *newerr;
+#ifdef COMPILE_CONSOLE
+ bool detach_session = 0;
+#else
bool detach_session = 1;
+#endif
struct module_entry_t *m;
void (*handle)();
int queue_timeout;
DESC *d, *dnext;
#ifndef COMPILE_CONSOLE
- int avail_descriptors;
#ifdef INFO_SLAVE
union sockaddr_u addr;
socklen_t addr_len;
int newsock;
#endif
+ int avail_descriptors;
#endif /* COMPILE_CONSOLE */
unsigned long input_ready, output_ready;
int notify_fd = -1;
#ifdef COMPILE_CONSOLE
d = initializesock(0, "localhost", "127.0.0.1", 0);
- if (STDIN_FILENO >= maxd)
- maxd = STDIN_FILENO + 1;
+ if (2 >= maxd)
+ maxd = 3;
#else
if (!restarting) {
sock = make_socket(port, SOCK_STREAM, NULL, NULL, MUSH_IP_ADDR);
for (d = descriptor_list; d; d = dnext) {
dnext = d->next;
+#ifdef COMPILE_CONSOLE
+ if (d->descriptor == 0) {
+ input_ready = FD_ISSET(STDIN_FILENO, &input_set);
+ output_ready = FD_ISSET(STDOUT_FILENO, &output_set);
+ } else {
+ input_ready = FD_ISSET(d->descriptor, &input_set);
+ output_ready = FD_ISSET(d->descriptor, &output_set);
+ }
+ if (input_ready) {
+ if (!process_input(d, output_ready)) {
+ shutdownsock(d);
+ if(d->descriptor == 0)
+ return;
+ continue;
+ }
+ }
+ if (output_ready) {
+ if (!process_output(d)) {
+ shutdownsock(d);
+ if (d->descriptor == 0)
+ return;
+ }
+ }
+#else /* COMPILE_CONSOLE */
input_ready = FD_ISSET(d->descriptor, &input_set);
output_ready = FD_ISSET(d->descriptor, &output_set);
if (input_ready) {
shutdownsock(d);
}
}
+#endif /* COMPILE_CONSOLE */
}
}
}
#endif /* COMPILE_CONSOLE */
for (qp = &d->output.head; ((cur = *qp) != NULL);) {
+#ifdef COMPILE_CONSOLE
+ if (d->descriptor == 0)
+ cnt = write(STDOUT_FILENO, cur->start, cur->nchars);
+ else {
+#else /* COMPILE_CONSOLE */
#ifdef HAVE_WRITEV
if (cur->nxt
#ifdef HAVE_SSL
}
} else {
#endif /* HAVE_WRITEV */
-#ifndef COMPILE_CONSOLE
#ifdef HAS_OPENSSL
if (d->ssl) {
cnt = 0;
for (d = descriptor_list; d; d = dnext) {
dnext = d->next;
-#ifndef COMPILE_CONSOLE
+#ifdef COMPILE_CONSOLE
+ if(d->descriptor == 0) {
+ write(STDOUT_FILENO, T(shutdown_message), strlen(T(shutdown_message)));
+ write(STDOUT_FILENO, "\r\n", 2);
+ } else {
+ send(d->descriptor, T(shutdown_message), strlen(T(shutdown_message)), 0);
+ send(d->descriptor, "\r\n", 2, 0);
+ if (shutdown(d->descriptor, 2) < 0)
+ perror("shutdown");
+ closesocket(d->descriptor);
+ }
+#else /* COMPILE_CONSOLE */
#ifdef HAS_OPENSSL
if (!d->ssl) {
#endif