/* * This routine is like ffopen, except it expects all parameters */ ffopenf(const char *name, int flags, mode_t mode, long cbits, int cblks, struct ffsw *pstat) { int narg; _ffopen_t fd; int retfd; int aifound; union spec_u *fdspec; struct gl_o_inf gloinf; assign_info ai; struct fdinfo *nfio; extern union spec_u *_g_fdc_spec(); aifound = _assign_asgcmd_info(name, -1, ASN_G_FF | ASN_G_ALL, &ai, NULL, 1); if (aifound == -1) { ERETURN(pstat, errno, 0); } if (aifound == 1 && ai.F_filter_flg) fdspec = &ai.F_filter[0]; else fdspec = NULL; (void) memset(&gloinf, 0, sizeof(gloinf)); gloinf.aip = aifound ? &ai : NULL; fd = _ffopen(name, flags, mode, fdspec, pstat, cbits, cblks, NULL, &gloinf); #if defined(_CRAY1) || defined(__mips) if (fd != _FFOPEN_ERR && MULTI_ON) { nfio = NULL; if (_ff_top_lock(fd, &nfio, pstat) < 0) fd = _FFOPEN_ERR; if (nfio != NULL) fd = (_ffopen_t)nfio; } #endif /* * ffopen returns an int. Call a routine which associates an * int with what is returned by _ffopen */ #if defined(__mips) || defined(_LITTLE_ENDIAN) retfd = _ff_fdinfo_to_int(fd, pstat); #else retfd = (int)fd; #endif /* should check chain of layers here for sanity */ return(retfd); }
int ffopens( const char *name, int flags, int mode, long cbits, ...) #endif { int retfd, length; _ffopen_t fd; union spec_u specs[MAX_SPEC]; #if !defined(__mips) && !defined(_LITTLE_ENDIAN) char *cspec; int cblks; struct ffsw *stat; va_list ap; #endif struct gl_o_inf gloinf; struct fdinfo *nfio; /* * The cblks argument was not passed in UNICOS 7.0 and previous. */ #if !defined(__mips) && !defined(_LITTLE_ENDIAN) va_start(ap, cbits); switch (_numargs()) { case 6: cblks = 0; stat = va_arg(ap, struct ffsw *); cspec = va_arg(ap, char *); break; default: /* 7 or more args */ cblks = va_arg(ap, int); stat = va_arg(ap, struct ffsw *); cspec = va_arg(ap, char *); break; } va_end(ap); #endif /* * Initialize global open information structure. */ (void) memset(&gloinf, 0, sizeof(gloinf)); gloinf.aip = NULL; if (cspec == NULL) cspec = ""; length = _parse_forstr(specs, cspec, MAX_SPEC, NO, _LELVL_RETURN); if (length <= 0) ERETURN(stat, FDC_ERR_BADSPC, 0); fd = _ffopen(name, flags, mode, specs, stat, cbits, cblks, NULL, &gloinf); #if defined(_CRAY1) || defined(__mips) if (fd != _FFOPEN_ERR && MULTI_ON) { nfio = NULL; if (_ff_top_lock(fd, &nfio, stat) < 0) fd = _FFOPEN_ERR; if (nfio != NULL) fd = (_ffopen_t)nfio; } #endif #if defined(__mips) || defined(_LITTLE_ENDIAN) /* * ffopens returns an int. Call a routine which associates an * int with what is returned by _ffopen */ retfd = _ff_fdinfo_to_int(fd, stat); #else retfd = (int)fd; #endif return(retfd); }
ffopen(const char *name, int flags, ...) { int narg; int cblks; _ffopen_t fd; int retfd; int aifound; mode_t mode; long cbits; va_list ap; union spec_u *fdspec; struct gl_o_inf gloinf; assign_info ai; struct fdinfo *nfio; extern union spec_u *_g_fdc_spec(); struct ffsw *pstat, locstat; #ifdef _CRAY NUMARG(narg); #elif defined(__mips) || defined(_LITTLE_ENDIAN) /* mode is passed only when O_CREAT is set */ if (flags & O_CREAT) narg = 3; else narg = 2; #else narg = 6; #endif mode = 0; cbits = 0; cblks = 0; pstat = &locstat; /* * New usage only allows 5 params. (what does this mean ???) */ va_start(ap, flags); if (narg >= 3) #if defined(BUILD_OS_DARWIN) mode = (mode_t) va_arg(ap, int); #else /* defined(BUILD_OS_DARWIN) */ mode = va_arg(ap, mode_t); #endif /* defined(BUILD_OS_DARWIN) */ if (narg >= 4) cbits = va_arg(ap, long); if (narg >= 5) pstat = va_arg(ap, struct ffsw *); if (narg >= 6) cblks = va_arg(ap, int); va_end(ap); aifound = _assign_asgcmd_info(name, -1, ASN_G_FF | ASN_G_ALL, &ai, NULL, 1); if (aifound == -1) { ERETURN(pstat, errno, 0); } if (aifound == 1 && ai.F_filter_flg) fdspec = &ai.F_filter[0]; else fdspec = NULL; (void) memset(&gloinf, 0, sizeof(gloinf)); gloinf.aip = aifound ? &ai : NULL; fd = _ffopen(name, flags, mode, fdspec, pstat, cbits, cblks, NULL, &gloinf); #if defined(_CRAY1) || defined(__mips) if (fd != _FFOPEN_ERR && MULTI_ON) { nfio = NULL; if (_ff_top_lock(fd, &nfio, pstat) < 0) fd = _FFOPEN_ERR; if (nfio != NULL) fd = (_ffopen_t)nfio; } #endif /* * ffopen returns an int. Call a routine which associates an * int with what is returned by _ffopen */ #if defined(__mips) || defined(_LITTLE_ENDIAN) retfd = _ff_fdinfo_to_int(fd, pstat); #else retfd = (int)fd; #endif /* should check chain of layers here for sanity */ if (narg < 4) errno = locstat.sw_error; return(retfd); }