home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / h / cPLog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-17  |  2.0 KB  |  58 lines

  1. /*
  2.   cPLog.h - Emerald checkPoint log file manager
  3.  
  4.   Copyright 1987,1988 Clinton Jeffery
  5.   Last edit: 4/28/88
  6.  
  7.                         *** PRIMITIVES  ***
  8.  
  9.   CP_StartRecover()  Start the recovery process (prepare for reads)
  10.   CP_Recover()       Read and reconstruct a log file entry
  11.   CP_EndRecover()    End the recovery procss (prepare for writes)
  12.  
  13.               *** IMITATION LARGE MESSAGE SEND ***
  14.   CP_StartEntry()    Start a new (appending) log file entry
  15.   CP_PutData()       Put some data (appending) into the log file entry
  16.   CP_EndEntry()      Complete the current log file entry (and flush)
  17.  
  18.   * Side effects
  19.   Space is allocated to hold the input data by CP_Recover
  20.   If the module is compiled with -DCPNEWLOG, it generates a new
  21.   (garbage-collected) login file with each kernel startup.  For this
  22.   reason, CP_StartEntry AND CP_ReadEntry return the offset k at which
  23.   the object is located (in the new log file).
  24.  
  25.   Revision history:
  26.   4/28/88 cjeffery : Mods to use replicants as the standard logfile unit
  27. */
  28.  
  29. /* here are some read-only variables; they are defined for macros */
  30. extern FILE *LF;
  31.  
  32. extern long CP_StartEntry();
  33.  
  34. #define CP_GetData(x,y,n)            replicant_read((x),(y),(n))
  35. #define CP_PutData(data,n)           replicant_write(CP_replicant,(char *)(data),(n))
  36. #define CP_Seek(rp,offset,fromwhere) replicant_seek((replicantPtr)(rp),(offset),(fromwhere))
  37. #define CP_EndEntry(f)               replicant_diskwrite(CP_replicant,(f))
  38. #define CP_CurrentPosition           (CP_replicant->ptr)
  39.  
  40. /*
  41.   CP_InitRecover opens the log file specified for reading/writing.
  42.   -DCPNEWLOG causes it to also open strcat(name,".cpnewlog") for writing.
  43.   EndRecover seeks to the end of the log file; -DCPNEWLOG causes it
  44.   to instead close both files, delete the old log file, and rename and
  45.   reopen the new log file to the old name.
  46. */
  47.  
  48. extern CP_InitRecover();
  49. extern CP_EndRecover();
  50. extern CP_Recover();
  51.  
  52. #define FAIL(s) { \
  53.   KMDTrace("Checkpoint", 3, s); \
  54.   return -1; \
  55. }
  56.  
  57. #define SUCCEED return 1
  58.