tgetr.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder/***********************************************************************
11d6ec73ee5550e00cb56b221bdbeb709142e779Christian Maeder* This software is part of the ast package *
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder* Copyright (c) 1999-2011 AT&T Intellectual Property *
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder* and is licensed under the *
eca29a7be76eb73944ec19b06eda3d6a9e6e543dChristian Maeder* Eclipse Public License, Version 1.0 *
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder* by AT&T Intellectual Property *
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder* A copy of the License is available at *
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder* http://www.eclipse.org/org/documents/epl-v10.html *
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder* Information and Software Systems Research *
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder* AT&T Research *
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder* Florham Park NJ *
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder* Glenn Fowler <gsf@research.att.com> *
23f8d286586ff38a9e73052b2c7c04c62c5c638fChristian Maeder***********************************************************************/
62925f4a144f45b5ed1e7c841f891d13f51e553dChristian Maeder char buf[50], *s, *string = "111\n222\n333";
cdaff0507c1b7240e2660dbb311f9c4646a6d14aChristian Maeder if(!(s = sfgetr(f,'\n',SF_STRING|SF_LOCKR)) || strcmp(s,"111") != 0)
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maeder terror("sfgetr should have failed because of locking");
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder if(!(s = sfgetr(f,'\n',SF_STRING)) || strcmp(s,"222") != 0)
836e72a3c413366ba9801726f3b249c7791cb9caChristian Maeder terror("sfgetr should have failed because of partial record");
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder terror("sfgetr should have succeeded getting partial record");
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder /* test type == -1 and type == 1 modes */
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder if(!(s = sfgetr(f,'\n',1)) || strcmp(s,"111") != 0)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder terror("sfgetr failed in compatible mode");
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder if(!(s = sfgetr(f,'\n',SF_STRING|SF_LOCKR)) || strcmp(s,"222") != 0)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder terror("sfgetr should have failed due to locking");
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder terror("sfgetr should have failed because record is incomplete");
fa45d098e1c9d468f128be9505eb7e5b2705b304Christian Maeder if(!(s = sfgetr(f,0,-1)) || strcmp(s,"333") != 0)
25612a7b3ce708909298d5426406592473880a20Christian Maeder terror("sfgetr failed in getting last partial record");
0b75edd800cef1a3b695f24df39d13f1ceace257Christian Maeder if(!(f = sftmp(0)) )
18b709ce961d68328da768318dcc70067f066d86Christian Maeder for(n = 0; n < 10; ++n) /* each record is 100 bytes */
18b709ce961d68328da768318dcc70067f066d86Christian Maeder { for(i = 0; i < 100; ++i)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder sfmaxr(n, 1); /* set maximum record size */
18b709ce961d68328da768318dcc70067f066d86Christian Maeder if((i = sfmaxr(0, 0)) != n)
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder if((i = sfmaxr(0, 0)) != n)