if (cl->umode & UMODE_LOPER) append_str(&databuf, "O");
if (cl->umode & UMODE_REGISTERED) append_str(&databuf, "r");
if (cl->umode & UMODE_WALLOPS) append_str(&databuf, "w");
- append_str(&databuf, "\n");
+ append_str(&databuf, "\r\n");
send_log(client->FD, databuf.buf, databuf.len, 0);
} else {
copy_strf(&databuf, ":%s 324 %s %s +nt\n", hostname, client->nick, nick);
cl->hostname);
has_output = 1;
}
- append_str(&databuf, "\n");
+ append_str(&databuf, "\r\n");
}
send_log(client->FD, databuf.buf, databuf.len, 0);
} else if(strcmp(command, "WHO") == 0) {
SOCKET SD;
int i;
char client_addr[100];
- char *welcomeMessage = ":irc.patchysicp.xyz NOTICE * :Hello welcome to PatchyIRCD!\n"; // TODO: don't hardcode hostname
puts("[PatchyIRCD]: Starting up...");
fflush(stdout);
inet_ntop(AF_INET, &(serverAddrV4.sin_addr), client_addr, sizeof(client_addr));
printf("Connection accepted from Socket: %"PRISocket", IP: %s PORT: %d\n", newSocket, client_addr, ntohs(serverAddrV4.sin_port));
fflush(stdout);
- send_log(newSocket, welcomeMessage, strlen(welcomeMessage), 0);
+ extern const char *hostname;
+ copy_strf(&databuf, ":%s NOTICE * :Hello welcome to PatchyIRCD!\r\n", hostname);
+ send_log(newSocket, databuf.buf, databuf.len, 0);
// Add to list of sockets
for(i=0;i<CLIENTS;i++) {
if(clients[i] == 0){
inet_ntop(AF_INET6, &(serverAddrV6.sin6_addr), client_addr, sizeof(client_addr));
printf("Connection accepted from Socket: %"PRISocket", IP: %s PORT: %d\n", newSocket, client_addr, ntohs(serverAddrV6.sin6_port));
fflush(stdout);
- send_log(newSocket, welcomeMessage, strlen(welcomeMessage), 0);
+ extern const char *hostname;
+ copy_strf(&databuf, ":%s NOTICE * :Hello welcome to PatchyIRCD!\r\n", hostname);
+ send_log(newSocket, databuf.buf, databuf.len, 0);
// Add to list of sockets
for(i=0;i<CLIENTS;i++) {
if(clients[i] == 0){
for (;;) {
char *end = strchr(s, '%');
if (!end) {
- append_str(d, s);
+ // if format string ends with \n, append \r\n
+ int len = strlen(s);
+ if (len) {
+ if (s[len-1] == '\n' && (len == 1 || s[len-2] != '\r')) {
+ append_strn(d, s, len-1);
+ append_strn(d, "\r\n", 2);
+ } else {
+ append_strn(d, s, len);
+ }
+ }
break;
}
if (end[1] == 's') { // %s