1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/*
* $Id: ftell.c,v 1.1 2005/03/31 13:13:00 baud Exp $
*/
/*
* Copyright (C) 1990-2002 by IN2P3 CC Philippe Gaillardon
* All rights reserved
*/
#ifndef lint
static char sccsid[] = "@(#)$RCSfile: ftell.c,v $ $Revision: 1.1 $ $Date: 2005/03/31 13:13:00 $ IN2P3 CC Philippe Gaillardon";
#endif /* not lint */
/* ftell.c Remote File I/O - get current file position. */
/*
* System remote file I/O definitions
*/
#define RFIO_KERNEL 1
#include "rfio.h"
#include "rfio_rfilefdt.h"
long rfio_ftell(fp)
RFILE *fp;
{
long rc;
INIT_TRACE("RFIO_TRACE");
TRACE(1, "rfio", "rfio_ftell(%x)", fp);
/*
* Checking fp validity
*/
if (fp == NULL) {
errno = EBADF;
TRACE(2,"rfio","rfio_ftell() : FILE ptr is NULL ");
END_TRACE();
return -1;
}
/*
* The file is local : this is the only way to detect it !
*/
if (rfio_rfilefdt_findptr(fp,FINDRFILE_WITH_SCAN) == -1) {
TRACE(2,"rfio","rfio_ftell() : using local ftell() ");
rc = ftell((FILE *)fp);
if ( rc < 0 ) serrno = 0;
rfio_errno = 0;
END_TRACE();
return rc;
}
TRACE(2,"rfio","rfio_ftell() : after remoteio") ;
/*
* Checking magic number
*/
if (fp->magic != RFIO_MAGIC) {
int fps = fp->s;
serrno = SEBADVERSION;
TRACE(2,"rfio","rfio_ftell() : Bad magic number");
free((char *)fp);
(void) close(fps);
END_TRACE();
return -1;
}
/* Just use rfio_lseek */
rc = rfio_lseek(fp->s, 0, SEEK_CUR);
END_TRACE();
return rc;
}
|