File:  [Research Unix] / researchv10dc / cmd / icon / pi / pil / seek.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

/*
 *	SEEK
 *
 *	Seek to position in stream
 *
 *	Stephen B. Wampler
 *
 *	Last modified 5/2/86 by Ralph E. Griswold
 *
*/

#include "../h/rt.h"

/*
 * seek(file,offset,start) - seek to offset byte from start in file.
 */

FncDcl(seek,3)
   {
   long l1, l2;
   int status;
   FILE *fd;
   long ftell();

   if (Arg1.dword != D_File)
      runerr(106);

   defint(&Arg2, &l1, 0);
   defshort(&Arg3, 0);

   fd = BlkLoc(Arg1)->file.fd;

   if ((BlkLoc(Arg1)->file.status == 0) ||
       (fseek(fd, l1, Arg3.vword.integr) == -1))
      Fail;
   Mkint(ftell(fd), &Arg0);
   Return;
   }

unix.superglobalmegacorp.com

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