MOZCE_SHUNT_API int open(const char *pathname, int flags, int mode) { #ifdef API_LOGGING mozce_printf("open called\n"); #endif _initfds(); char modestr[10]; *modestr = '\0'; mode2binstr(mode, modestr); if (*modestr == '\0') return -1; FILE* file = fopen(pathname, modestr); int fd = -1; if (file) { fd = _getnewfd(); _fdtab[fd].fd = fd; _fdtab[fd].file = file; fflush(file); fread(NULL, 0, 0, file); } return fd; }
int _assignfd(int type, HANDLE hnd, int flags) { int fd; WCETRACE(WCE_IO, "_assignfd(%x)", hnd); if ((fd = _getnewfd()) >= 0) _setfd(fd, type, hnd, flags); WCETRACE(WCE_IO, "_assignfd returns %d", fd); return(fd); }