Annotation of 42BSD/bin/awk/freeze.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)freeze.c   4.2 8/11/83";
                      3: #endif
                      4: 
                      5: #include "stdio.h"
                      6: freeze(s) char *s;
                      7: {      int fd;
                      8:        unsigned int *len;
                      9:        len = (unsigned int *)sbrk(0);
                     10:        if((fd = creat(s, 0666)) < 0) {
                     11:                perror(s);
                     12:                return(1);
                     13:        }
                     14:        write(fd, &len, sizeof(len));
                     15:        write(fd, (char *)0, len);
                     16:        close(fd);
                     17:        return(0);
                     18: }
                     19: 
                     20: thaw(s) char *s;
                     21: {      int fd;
                     22:        unsigned int *len;
                     23:        if(*s == 0) {
                     24:                fprintf(stderr, "empty restore file\n");
                     25:                return(1);
                     26:        }
                     27:        if((fd = open(s, 0)) < 0) {
                     28:                perror(s);
                     29:                return(1);
                     30:        }
                     31:        read(fd, &len, sizeof(len));
                     32:        (void) brk(len);
                     33:        read(fd, (char *)0, len);
                     34:        close(fd);
                     35:        return(0);
                     36: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.