/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1999-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#include "sftest.h"
static int Type;
static int Sfn;
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
{
switch(type)
{
case SF_WRITE :
Sfn += 1;
return 0;
case SF_CLOSING:
if(Type == SF_CLOSING)
return 0;
case SF_SYNC:
if(Type == SF_CLOSING)
return 0;
}
return -1;
}
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
{ return 0;
}
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
return -1;
}
return 0;
}
#if __STD_C
#else
Sfio_t* f;
size_t n;
#endif
{
if(sfgetc(f) >= 0)
terror("Can't access stream here!");
return 0;
}
tmain()
{
off_t o;
int i;
terror("Can't open file");
terror("Pushing discipline failed");
terror("Did not get push event");
/* this is to test sfraise(NULL,...) */
terror("Can't open file");
Sfn = 0;
terror("sfraise failed");
if(Sfn != 2)
terror("Didn't get right event count");
terror("Did not get pop event");
sfsync(f);
terror("Did not get sync event");
sfpurge(f);
terror("Did not get purge event");
sfclose(f);
if(Type != SF_CLOSING)
terror("Did not get close event");
sfclose(f);
terror("Did not get final event");
terror("Can't open file");
if(sfgetc(f) >= 0)
terror("There should be no data here");
terror("Did not get lock event");
/* test to see if sfclose() preserves seek location */
if(!(f = sftmp(0)) )
terror("Can't create temp file");
for(i = 0; i < sizeof(rbuf); ++i)
rbuf[i] = i;
terror("reading 4 bytes");
for(i = 0; i < 4; ++i)
if(rbuf[i] != i)
terror("wrong 4 bytes");
sfsync(f);
terror("Can't dup file descriptor");
sfclose(f);
texit(0);
}