tmode.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* 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"
tmain()
{
Sfio_t *f;
if(argc > 1)
terror("Can't reopen stdin");
return 0;
}
terror("Opening to write");
terror("sfputc");
if(sfgetc(f) >= 0)
terror("sfgetc");
terror("Opening to read");
if(sfgetc(f) != 'a')
terror("sfgetc2");
if(sfputc(f,'b') >= 0)
terror("sfputc2");
if(sfgetc(f) != 'a')
terror("sfgetc3");
terror("sfputc3");
if(sfclose(f) < 0)
terror("sfclose");
terror("sfpopen");
if(sfgetc(f) != 'a')
terror("sfgetc4");
if(sfgetc(f) != 'b')
terror("sfgetc5");
if(sfgetc(f) >= 0)
terror("sfgetc6");
terror("sfopen");
terror("sfputc1");
sfsetfd(f,-1);
if(sfputc(f,'b') >= 0)
terror("sfputc2");
if(sfclose(f) < 0)
terror("sfclose");
terror("sfopen2");
if(!sfreserve(f,0,-1) )
terror("Failed on buffer getting");
if(sfvalue(f) <= 0)
terror("There is no buffer?");
texit(0);
}