From 92a426f8ec4c4d4a13357ed2ac8837c821979e30 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 8 May 2002 00:41:11 +0000 Subject: [PATCH] Added LF to CRLF expansion in message import/post routine. Incremented version number to 2.31. --- src/sbbs3/smbutil.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/sbbs3/smbutil.c b/src/sbbs3/smbutil.c index 315502e35f..7f91bd49d0 100644 --- a/src/sbbs3/smbutil.c +++ b/src/sbbs3/smbutil.c @@ -35,7 +35,7 @@ * Note: If this box doesn't appear square, then you need to fix your tabs. * ****************************************************************************/ -#define SMBUTIL_VER "2.30" +#define SMBUTIL_VER "2.31" #define NOANALYSIS (1L<<0) @@ -166,7 +166,20 @@ static void truncsp(char *str) str[c]=0; } +/*****************************************************************************/ +// Expands Unix LF to CRLF +/*****************************************************************************/ +ulong lf_expand(BYTE* inbuf, ulong inlen, BYTE* outbuf) +{ + ulong i,j; + for(i=j=0;i<inlen;i++) { + if(inbuf[i]=='\n' && (!i || inbuf[i-1]!='\r')) + outbuf[j++]='\r'; + outbuf[j++]=inbuf[i]; + } + return(j); +} /****************************************************************************/ /* Adds a new message to the message base */ @@ -178,6 +191,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address, char buf[128]; char pad=0; char* msgtxt=NULL; + char* newtxt; long msgtxtlen; ushort xlat,net; int i; @@ -199,6 +213,16 @@ void postmsg(char type, char* to, char* to_number, char* to_address, msgtxtlen+=i; } + if((newtxt=(char*)malloc(msgtxtlen*2))==NULL) { + fprintf(stderr,"\n\7malloc(%ld) failure\n",msgtxtlen*2); + exit(1); + } + + /* Expand LFs to CRLFs */ + msgtxtlen=lf_expand(msgtxt, msgtxtlen, newtxt); + free(msgtxt); + msgtxt=newtxt; + /* Allocate space in message base */ length=msgtxtlen+sizeof(xlat); /* for translation string */ if(!(smb.status.attr&SMB_HYPERALLOC)) { -- GitLab