示例#1
0
scanstate* readfd_open(const char *path, size_t bufsiz)
{
    scanstate *ss;
    int fd;

    fd = open(path, O_RDONLY);
    if(fd < 0) {
        return NULL;
    }

    ss = dynscan_create(bufsiz);
    if(!ss) {
        close(fd);
        return NULL;
    }

    return readfd_attach(ss, fd);
}
示例#2
0
文件: readfd.c 项目: wjk/re2c-win32
scanstate* readfd_open(const char *path, size_t bufsiz)
{
    scanstate *ss;
    int fd;

	// _open() is marked as deprecated due to security concerns; however,
	// using the suggested function, _sopen_s(), is overkill for my needs here.
	// Thus, I suppress the deprecation warning for this statement only.
#pragma warning(suppress: 4996)
    fd = _open(path, O_RDONLY);
    if(fd < 0) {
        return NULL;
    }

    ss = dynscan_create(bufsiz);
    if(!ss) {
        _close(fd);
        return NULL;
    }

    return readfd_attach(ss, fd);
}