Пример #1
0
/*
 * putLog()
 *
 * This function stores the given log record into ctdllog.sys.
 */
void putLog(logBuffer *lBuf, int n)
{
    long int s, r;

    r = LB_TOTAL_SIZE;
    s = n * r;
    n   *= 3;

    crypte(lBuf, LB_SIZE, n);		/* encode buffer	*/

    fseek(logfl, s, 0);

    if (fwrite(lBuf, LB_SIZE, 1, logfl) != 1) {
	crashout("?putLog-write fail (1)!");
    }

    if (fwrite(lBuf->lbrgen, GEN_BULK, 1, logfl) != 1) {
	crashout("?putLog-write fail (2)!");
    }

    if (fwrite(lBuf->lbMail, MAIL_BULK, 1, logfl) != 1) {
	crashout("?putLog-write fail (3)!");
    }

    if (fwrite(lBuf->lastvisit, RM_BULK, 1, logfl) != 1) {
	crashout("?putLog-write fail (4)!");
    }

    crypte(lBuf, LB_SIZE, n);	/* encode buffer	*/

    fflush(logfl);
}
Пример #2
0
/*
 * getMsgChar()
 *
 * This function returns sequential chars from CtdlMsg.Sys.
 */
int getMsgChar()
{
    long work;
    int  toReturn;

    if (GMCCache) {     /* someone did an unGetMsgChar() --return it    */
	toReturn= GMCCache;
	GMCCache= '\0';
	return (toReturn & 0xFF);
    }

    mFile1.oldChar     = mFile1.thisChar;
    mFile1.oldSector   = mFile1.thisSector;

    toReturn = mFile1.sectBuf[mFile1.thisChar];
    toReturn &= 0xFF;   /* Only want the lower 8 bits */

    mFile1.thisChar    = ++mFile1.thisChar % MSG_SECT_SIZE;
    if (mFile1.thisChar == 0) {
	/* time to read next sector in: */
	mFile1.thisSector  = ++mFile1.thisSector % cfg.maxMSector;
	work = mFile1.thisSector;
	work *= MSG_SECT_SIZE;
	fseek(msgfl, work, 0);
	if (fread(mFile1.sectBuf, MSG_SECT_SIZE, 1, msgfl) != 1) {
	    crashout("?nextMsgChar-read fail");
	}
	crypte(mFile1.sectBuf, MSG_SECT_SIZE, 0);
    }
    return(toReturn);
}
Пример #3
0
/*
 * getLog()
 *
 * This loads requested log record into the specified RAM buffer.
 */
void getLog(logBuffer *lBuf, int n)
{
    long int s, r;

    if (lBuf == &logBuf)   thisLog      = n;

    r = LB_TOTAL_SIZE;		/* To get away from overflows   */
    s = n * r;			/* This should be offset	*/
    n *= 3;

    fseek(logfl, s, 0);

    if (fread(lBuf, LB_SIZE, 1, logfl) != 1) {
	crashout("?getLog-read fail//EOF detected (1)!");
    }

    crypte(lBuf, LB_SIZE, n);	/* decode buffer    */

    if (fread(lBuf->lbrgen, GEN_BULK, 1, logfl) != 1) {
	crashout("?getLog-read fail//EOF detected (2)!");
    }

    if (fread(lBuf->lbMail, MAIL_BULK, 1, logfl) != 1) {
	crashout("?getLog-read fail//EOF detected (3)!");
    }

    if (fread(lBuf->lastvisit, RM_BULK, 1, logfl) != 1) {
	crashout("?getLog-read fail//EOF detected (4)!");
    }
}
Пример #4
0
/*
 * startAt()
 *
 * This function sets the location to begin reading a message from. This is
 * usually only the sector, since byte offset within the sector is not
 * saved.
 */
void startAt(FILE *whichmsg, struct mBuf *mFile, SECTOR_ID sect, int byt)
{
    long temp;

    GMCCache  = '\0';   /* cache to unGetMsgChar() into */

    if (sect >= cfg.maxMSector) {
	printf("?startAt s=%u,b=%d", sect, byt);
	return ;   /* Don't crash anymore, just skip the msg */
    }
    mFile->thisChar    = byt;
    mFile->thisSector  = sect;

    temp = sect;
    temp *= MSG_SECT_SIZE;
    fseek(whichmsg, temp, 0);
    if (fread(mFile->sectBuf, MSG_SECT_SIZE, 1, whichmsg) != 1) {
	crashout("?startAt read fail");
    }
    crypte(mFile->sectBuf, MSG_SECT_SIZE, 0);
}