* miscfuncs.h (class NT_readline): New class to implement line-wise

reading from file using native NT functions.
	* miscfuncs.cc (NT_readline::init): New method.
	* mount.cc (mount_info::from_fstab): Utilize NT_readline to read
	fstab files.
This commit is contained in:
Corinna Vinschen
2014-02-08 20:57:27 +00:00
parent abbe1f5320
commit 234074f683
4 changed files with 109 additions and 79 deletions

View File

@ -1,7 +1,7 @@
/* miscfuncs.h: main Cygwin header file.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
This file is part of Cygwin.
@ -23,6 +23,24 @@ BOOL WINAPI ReadPipeOverlapped (HANDLE h, PVOID buf, DWORD len,
BOOL WINAPI WritePipeOverlapped (HANDLE h, LPCVOID buf, DWORD len,
LPDWORD ret_len, DWORD timeout);
/* class for per-line reading using native functions. The caller provides
the file as an POBJECT_ATTRIBUTES, and the buffer space. */
class NT_readline
{
HANDLE fh;
PCHAR buf;
PCHAR got;
PCHAR end;
ULONG buflen;
ULONG len;
ULONG line;
public:
NT_readline () : fh (NULL) {}
bool init (POBJECT_ATTRIBUTES attr, char *buf, ULONG buflen);
PCHAR gets ();
~NT_readline () { if (fh) NtClose (fh); }
};
extern "C" void yield ();
#define import_address(x) __import_address ((void *)(x))