*/
msg = CtdlFetchMessage(msgnum, 1);
if (msg != NULL) {
+ int len, rlen;
+ char *pCh;
+
if (msg->cm_fields['V'] == NULL){
/* local message, no enVelope */
StrBuf *Buf;
if (msg->cm_fields['U'] == NULL) {
msg->cm_fields['U'] = strdup("(no subject)");
}
- snprintf(buf, sizeof buf, "[%s] %s", CC->room.QRname, msg->cm_fields['U']);
- free(msg->cm_fields['U']);
- msg->cm_fields['U'] = strdup(buf);
+
+ len = strlen(msg->cm_fields['U']);
+ rlen = strlen(CC->room.QRname);
+ pCh = strstr(msg->cm_fields['U'], CC->room.QRname);
+ if ((pCh == NULL) ||
+ (*(pCh + rlen) != ']') ||
+ (pCh == msg->cm_fields['U']) ||
+ (*(pCh - 1) != '[')
+ )
+ {
+ char *pBuff;
+
+ rlen += len + 4;
+ pBuff = malloc (rlen * sizeof(char));
+
+ snprintf(pBuff, rlen, "[%s] %s", CC->room.QRname, msg->cm_fields['U']);
+ free(msg->cm_fields['U']);
+ msg->cm_fields['U'] = pBuff;
+ }
+ /* else we won't modify the buffer, since the roomname is already here. */
/* Set the recipient of the list message to the
* email address of the room itself.
int download_len = 0L;
int bytes_received = 0L;
char buf[SIZ];
- static char pbuf[IGNET_PACKET_SIZE];
char tempfilename[PATH_MAX];
char permfilename[PATH_MAX];
int plen;
if (buf[0] == '6') {
plen = extract_int(&buf[4], 0);
- if (sock_read(sock, pbuf, plen, 1) < 0) {
+ StrBuf *pbuf = NewStrBuf();
+ if (socket_read_blob(sock, pbuf, plen, CLIENT_TIMEOUT) != plen) {
+ CtdlLogPrintf(CTDL_INFO, "Short read from peer; aborting.\n");
fclose(fp);
unlink(tempfilename);
+ FreeStrBuf(&pbuf);
return;
}
- fwrite((char *) pbuf, plen, 1, fp);
+ fwrite(ChrPtr(pbuf), plen, 1, fp);
bytes_received += plen;
+ FreeStrBuf(&pbuf);
}
}
}
CtdlLogPrintf(CTDL_DEBUG, "%s\n", buf);
- CtdlLogPrintf(CTDL_NOTICE, "Received %ld octets from <%s>\n", download_len, remote_nodename);
/*
* Now move the temp file to its permanent location.
}
CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
- CCC->sReadBuf = NewStrBuf();
+ CCC->SBuf.Buf = NewStrBuf();
CCC->sMigrateBuf = NewStrBuf();
- CCC->sPos = NULL;
+ CCC->SBuf.ReadWritePointer = NULL;
/* Read the server greeting */
if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
sock_puts(&sock, "QUIT");
bail:
- FreeStrBuf(&CCC->sReadBuf);
+ FreeStrBuf(&CCC->SBuf.Buf);
FreeStrBuf(&CCC->sMigrateBuf);
if (sock != -1)
sock_close(sock);