1: #include "old.h" 2: 3: save() 4: { 5: int i; 6: int f; 7: 8: f = creat("chess.out", 0666); 9: if(f < 0) { 10: printf("cannot create file\n"); 11: return; 12: } 13: write(f, clktim, 4); 14: write(f, &bookp, 2); 15: write(f, &moveno, 2); 16: write(f, &game, 2); 17: i = amp-ambuf; 18: write(f, &i, 2); 19: write(f, &mantom, 2); 20: write(f, &value, 2); 21: write(f, &ivalue, 2); 22: write(f, &depth, 2); 23: write(f, &flag, 2); 24: write(f, &eppos, 2); 25: write(f, &bkpos, 2); 26: write(f, &wkpos, 2); 27: write(f, board, 128); 28: write(f, ambuf, i*2); 29: close(f); 30: } 31: 32: restore() 33: { 34: int i; 35: int f; 36: 37: f = open("chess.out", 0); 38: if(f < 0) { 39: printf("cannot open file\n"); 40: return; 41: } 42: read(f, clktim, 4); 43: read(f, &bookp, 2); 44: read(f, &moveno, 2); 45: read(f, &game, 2); 46: read(f, &i, 2); 47: amp = ambuf+i; 48: read(f, &mantom, 2); 49: read(f, &value, 2); 50: read(f, &ivalue, 2); 51: read(f, &depth, 2); 52: read(f, &flag, 2); 53: read(f, &eppos, 2); 54: read(f, &bkpos, 2); 55: read(f, &wkpos, 2); 56: read(f, board, 128); 57: read(f, ambuf, i*2); 58: close(f); 59: }