/* * Fget and fput transmit variable blocks of data to and from a file */ #include int fget(buffer, length, fd) char *buffer; /* To where */ int length; /* maximum length */ FILE *fd; /* Which file */ { int actual; if (fread(&actual, sizeof (int), 1, fd) != 1) return (0); if (actual > length) actual = length; return(fread(buffer, sizeof (char), actual, fd) * sizeof (char)); } int fput(buffer, length, fd) char *buffer; /* From where */ int length; /* How many bytes */ FILE *fd; /* Which file */ { fwrite(&length, sizeof (int), 1, fd); return (fwrite(buffer, sizeof (char), length, fd)); }