home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / EZY110-1.ARJ / STRUCT.ARJ / CLIB.ARJ / LASTREAD.CPP < prev    next >
C/C++ Source or Header  |  1995-03-28  |  1KB  |  33 lines

  1. #include <ezycom.h>
  2. #include <ezylib.h>
  3. #include <stdio.h>
  4.  
  5. // UserRecord is 0 based
  6. // MsgBoard   is 1 based
  7. // MsgNumber  is 1 based
  8.  
  9. word GetNextRead(FILE *hLastComb,word UserRecord,word MsgBoard)
  10. {
  11.   word NextRead;
  12.   fseek(hLastComb,(((longint)UserRecord * (longint)(Constant.MaxMess / 16)) +
  13.                    (longint)((MsgBoard - 1) / 16)) * sizeof(UsersLastRecord) +
  14.                    (longint)(((MsgBoard - 1) % 16) * 2) + 2,SEEK_SET);
  15.   if (fread(&NextRead,sizeof(word),1,hLastComb) == 0)
  16.     NextRead = 0;
  17.   return(NextRead);
  18. }
  19.  
  20. int PutNextRead(FILE *hLastComb,word UserRecord,word MsgBoard,word MsgNumber)
  21. {
  22.   int Success = FALSE;
  23.   if ((MsgBoard <= Constant.MaxMess) && (MsgBoard > 0)) {
  24.     fseek(hLastComb,(((longint)UserRecord * (longint)(Constant.MaxMess / 16)) +
  25.                     (longint)((MsgBoard - 1) / 16)) * (longint)sizeof(UsersLastRecord) +
  26.                     (longint)(((MsgBoard - 1) % 16) * 2) + 2,SEEK_SET);
  27.     if (fwrite(&MsgNumber,sizeof(word),1,hLastComb) == 1)
  28.       Success = TRUE;
  29.   }
  30.   return(Success);
  31. }
  32.  
  33.