home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / gle / util / manip / mjl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-29  |  1.4 KB  |  66 lines

  1. #include "all.h"
  2. #include "edt.h"
  3. #ifdef __TURBOC__
  4. #define DASHCHAR 249
  5. #include <alloc.h>
  6. #include "bios.h"
  7. #include "conio.h"
  8. #include "dir.h"
  9. #else
  10. #define far
  11. #define farcalloc calloc
  12. #define DASHCHAR '.'
  13. #include "vaxconio.h"
  14. #endif
  15. FILE *jouptr;
  16. extern int in_recover,single_step;
  17. init_logging(char *infile)
  18. {
  19.     FILE *jptr;
  20.     unsigned char ccc;
  21.     static char buff[80];
  22.     if (in_recover) {
  23. #ifdef unix
  24.         jouptr = fopen("manip_.j1","r");
  25. #else
  26.         jouptr = fopen("manip_.j1","rb");
  27. #endif
  28.         if (jouptr==NULL) fner("Unable to open/read journal file manip_.j1");
  29.         fread(&ccc,1,1,jouptr);
  30.         fread(buff,1,ccc,jouptr);
  31.         if (strlen(infile)==0) strcpy(infile,buff);
  32.         return;
  33.     }
  34.     unlink("manip_.j3");
  35.     rename("manip_.j2","manip_.j3");
  36.     rename("manip_.j1","manip_.j2");
  37.     jptr = fopen("manip_.j1","wb");
  38.     fputc(strlen(infile),jptr);
  39.     fwrite(infile,1,strlen(infile),jptr);
  40.     if (jptr==NULL) fner("Unable to open journal file manip_.j1");
  41.     fclose(jptr);
  42. }
  43. unsigned char mjl_buff[80];
  44. mjl_key(int c)
  45. {
  46.     int s;
  47.     if (in_recover) return;
  48.     if (c==0) return;
  49.     s = strlen(mjl_buff);
  50.     mjl_buff[s] = c;
  51.     mjl_buff[s+1] = 0;
  52.     if (s>40) mjl_flush();
  53. }
  54. mjl_flush()
  55. {
  56.     FILE *jptr;
  57.     if (in_recover) return;
  58.     if (strlen(mjl_buff)<7) return;
  59.     jptr = fopen("manip_.j1","ab");
  60.     if (jptr==NULL) fner("Unable to append to journal file manip_.j1");
  61.     fwrite(mjl_buff,1,strlen(mjl_buff),jptr);
  62.     fclose(jptr);
  63.     mjl_buff[0] = 0;
  64. }
  65.  
  66.