summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/blabouncer.c b/blabouncer.c
index 89add3e..c7b5f6f 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -715,42 +715,56 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
// see if there's anything from stdin (unless we're in background/daemon mode)
if (!settings->background && FD_ISSET(STDIN, &rfds)) {
- debugprint(DEBUG_FULL, "reading stdin!\n");
+ debugprint(DEBUG_FULL, "dochat(): stdin: reading stdin!\n");
char outgoingmsg[MAXDATASIZE]; // String to send to server
+ outgoingmsg[0] = '\0';
int outgoingmsgrc; // Return code from getstdin() for outgoing message
outgoingmsgrc = getstdin(NULL, outgoingmsg, sizeof(outgoingmsg));
if (outgoingmsgrc == NO_INPUT) {
- printf("\nError! No input.\n");
+ printf("Error, no input.\n");
+ debugprint(DEBUG_SOME, "dochat(): stdin: Error, no input.\n");
+ continue;
} else if (outgoingmsgrc == TOO_LONG) {
- printf ("Error! Too long. Would have allowed up to: [%s]\n", outgoingmsg);
+ debugprint(DEBUG_SOME, "dochat(): stdin: Error, input too long. Max length is %d.\n", MAXDATASIZE - 1);
+ printf ("Error, input too long. Max length is %d.\n", MAXDATASIZE - 1);
+ continue;
+ } else {
+ debugprint(DEBUG_FULL, "dochat(): stdin: Got '%s'.\n", outgoingmsg);
}
// STDIN based commands for debugging
if (strncmp(outgoingmsg, "listchannels", strlen("listchannels")) == 0) {
printf("STDIN command starting: listchannels\n");
+ debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command starting: listchannels\n");
int channelcount = getchannelcount(channels, ircdstate.maxchannelcount);
for (int i = 0; i < ircdstate.maxchannelcount; i++) {
printf("Checking channel[%d] out of %d.\n", i, channelcount);
+ debugprint(DEBUG_FULL, "dochat(): stdin: Checking channel[%d] out of %d.\n", i, channelcount);
// Skip this one if it's a blank channel
if (!channels[i].name[0]) {
- debugprint(DEBUG_FULL, "Skipping blank channel channel[%d].\n", i);
+ debugprint(DEBUG_FULL, "dochat(): stdin: Skipping blank channel channel[%d].\n", i);
continue;
}
+ debugprint(DEBUG_FULL, "dochat(): stdin: Found channel '%s'.\n", channels[i].name);
printf("Found channel '%s'.\n", channels[i].name);
}
+ debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command complete: listchannels\n");
printf("STDIN command complete: listchannels\n");
+
continue;
}
+ debugprint(DEBUG_FULL, "dochat(): stdin: '%s' not processed as a command, sending to server.\n", outgoingmsg);
// sourcefd = 0 as this is a trusted message
sendtoserver(server_ssl, outgoingmsg, strlen(outgoingmsg), 0, clients, settings);
+ continue;
}
// go through all the remaining sockets to see if there's anything from the client sockets (either new connections or existing clients sending messages)