42 lines
904 B
C
42 lines
904 B
C
/* Copyright (c) 1984 AT&T */
|
|
/* All Rights Reserved */
|
|
|
|
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
|
|
/* The copyright notice above does not evidence any */
|
|
/* actual or intended publication of such source code. */
|
|
|
|
/* #ident "@(#)awk:freeze.c 1.2" */
|
|
#ident "$Header: /proj/irix6.5.7m/isms/eoe/cmd/oawk/RCS/freeze.c,v 1.3 1986/09/17 19:37:52 scott Exp $"
|
|
#include "stdio.h"
|
|
freeze(s) char *s;
|
|
{ int fd;
|
|
unsigned int *len;
|
|
len = (unsigned int *)sbrk(0);
|
|
if((fd = creat(s, 0666)) < 0) {
|
|
perror(s);
|
|
return(1);
|
|
}
|
|
write(fd, &len, sizeof(len));
|
|
write(fd, (char *)0, len);
|
|
close(fd);
|
|
return(0);
|
|
}
|
|
|
|
thaw(s) char *s;
|
|
{ int fd;
|
|
unsigned int *len;
|
|
if(*s == 0) {
|
|
fprintf(stderr, "empty restore file\n");
|
|
return(1);
|
|
}
|
|
if((fd = open(s, 0)) < 0) {
|
|
perror(s);
|
|
return(1);
|
|
}
|
|
read(fd, &len, sizeof(len));
|
|
(void) brk(len);
|
|
read(fd, (char *)0, len);
|
|
close(fd);
|
|
return(0);
|
|
}
|