12404Sdlw /* 2*2516Sdlw char id_access[] = "@(#)access_.c 1.2"; 32404Sdlw * 42404Sdlw * determine accessability of a file 52404Sdlw * 62404Sdlw * calling format: 72404Sdlw * integer access 82404Sdlw * ierror = access(filename, mode) 92404Sdlw * where: 102404Sdlw * ierror will be 0 for successful access; an error number otherwise. 112404Sdlw * filename is a character string 122404Sdlw * mode is a character string which may include any combination of 132404Sdlw * 'r', 'w', 'x', ' '. (' ' => test for existence) 142404Sdlw */ 152404Sdlw 162404Sdlw #include "../libI77/f_errno.h" 172404Sdlw 182404Sdlw long access_(name, mode, namlen, modlen) 192404Sdlw char *name, *mode; 202404Sdlw long namlen, modlen; 212404Sdlw { 222404Sdlw char buf[128]; 232404Sdlw int m = 0; 242404Sdlw 25*2516Sdlw if (namlen >= sizeof buf) 26*2516Sdlw return((long)(errno=F_ERARG)); 272404Sdlw g_char(name, namlen, buf); 282404Sdlw if (buf[0] == '\0') 29*2516Sdlw return((long)(errno=ENOENT)); 302404Sdlw if (access(buf, 0) < 0) 312404Sdlw return((long)errno); 322404Sdlw while (modlen--) switch(*mode++) 332404Sdlw { 342404Sdlw case 'x': 352404Sdlw m |= 1; 362404Sdlw break; 372404Sdlw 382404Sdlw case 'w': 392404Sdlw m |= 2; 402404Sdlw break; 412404Sdlw 422404Sdlw case 'r': 432404Sdlw m |= 4; 442404Sdlw break; 452404Sdlw } 462404Sdlw if (m > 0 && access(buf, m) < 0) 472404Sdlw return((long)errno); 482404Sdlw return(0L); 492404Sdlw } 50