|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 1566 (0x61e) Types: TextFile Names: »cvcopy.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Crystal/cvcopy.c«
/* cvcopy.c * copy initialization code into the crystal file ************************************************************************/ #include <stdio.h> #include <filehdr.h> #include <ldfcn.h> #include <fcntl.h> #include <sys/stat.h> #include "cvmisc.h" #include "cvinit.h" extern char *malloc(); static char crynam[] = "crystal"; main(argc,argv) int argc; char *argv[]; { auto int r, w; auto char *abuff; auto unsigned length, rlen; auto long where,offset; auto FILE *stream; auto LDFILE *ldptr; auto struct stat cstat; ldptr = NULL; if ((ldptr = ldopen(crynam,ldptr)) == NULL ) { perror(argv[0]); exit(1); } if (ldnsseek(ldptr,".data") == FAILURE) { perror(argv[0]); exit(1); } if ( (r = open(path,O_RDWR)) == EOF) { perror(argv[0]); exit(1); } if ( (w = open(crynam,O_RDWR)) == EOF) { perror(argv[0]); exit(1); } stream = IOPTR(ldptr); offset = ftell(stream); if ((where = lseek(w,offset,0)) == (long)-1 ) { perror(argv[0]); exit(1); } if (fstat(r,&cstat)) { perror(argv[0]); exit(1); } length = cstat.st_size; if ((abuff = malloc(length)) == NULL ) { perror(argv[0]); exit(1); } if ((rlen = read(r,abuff,length)) == EOF || rlen != length) { perror(argv[0]); exit(1); } if (write(w,abuff,length) == EOF) { perror(argv[0]); exit(1); } free(abuff); if (close(r)) { perror(argv[0]); exit(1); } if (close(w)) { perror(argv[0]); exit(1); } if (ldclose(ldptr) == FAILURE) { perror(argv[0]); exit(1); } if (unlink(path) == EOF) { perror(argv[0]); exit(1); } return; }