Category : Files from Magazines
Archive   : JAN92.ZIP
Filename : 3N01028A

 
Output of file : 3N01028A contained in archive : JAN92.ZIP

/*** Listing #2
*/
#include

/*** iDBCCharRplc - Replaces a character in a string.
*
* written by: John G. Nelson, Pacific Software Publishing Inc.
* copyright: Pacific Software Publishing Inc.
* date: 10/91
* purpose: Allows a single (DBC or sbc) character in a DBC
* string to be replaced by another (DBC or sbc) character.
* The replacement only takes place if there is
* sufficient room in the string.
* parameters: pdbcString : Pointer to DBC string.
* iOffset : Byte position of character to be replaced.
* pdbcChar : Incoming character.
* iMaxLen : Length of pdbcField in bytes.
* return: iOffset : Replacement does not have enough room.
* iNewOffset : Offset indicating position of character
* immediately following newly replaced character.
*/
int iDBCRplcChar(
DBC *pdbcString,/* DBC string */
int iOffset, /* Offset */
DBC *pdbcChar, /* DBC */
int iMaxLen) /* Max bytes */
{
int iInChSz, iOutChSz;
int iRoom; /* bytes slots */
int iStrLen;
int i;

iStrLen = strlen(pdbcString);
iRoom = iMaxLen - iStrLen;
iInChSz = (bIsDBC(pdbcChar)) ? 2 : 1;
iOutChSz = (bIsDBC(&pdbcString[iOffset])) ? 2 : 1;

/* check if there is enough room for replacement*/
if ((iInChSz - iOutChSz) > iRoom) {
/* not room to accomodate replacement */
return(iOffset);
}

/* enough room for replacement */

if (-1 == (iInChSz - iOutChSz)) {

/* DBC by SBC replacement case */
/* shift left to delete 2nd byte of OutDBC */
memmove(&pdbcString[iOffset+1],
&pdbcString[iOffset+2],
iStrLen-iOffset);

} else if (1 == (iInChSz-iOutChSz)) {

/* SBC by DBC replacement case */
/* shift right to make room for 2nd byte */
memmove(&pdbcString[iOffset+2],
&pdbcString[iOffset+1],
iStrLen-iOffset);
}

/* replace character */
for (i=0; i pdbcString[iOffset+i] = pdbcChar[i];
}

return (iOffset+iInChSz);

} /* iDBCCharRplc */



  3 Responses to “Category : Files from Magazines
Archive   : JAN92.ZIP
Filename : 3N01028A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/