work/bootstrap/gec17.c
void eif_file_perm(EIF_FILENAME name, char *who, char *what, int flag) {
	int fmode;					/* File mode to be altered */
	rt_stat_buf buf;			/* File statistics */

		/* We need to follow links since `chmod' does follow them to change the permissions. */
	if (eif_file_stat(name, &buf, 1)) {
		esys();
	} else {
		fmode = (int) buf.st_mode;	/* Fetch current file mode */

		switch (*who) {
		case 'u':
			while (*what)
				switch (*what++) {
#ifdef EIF_WINDOWS
				case 's': break;
				case 'r': break;
				case 'w': break;
				case 'x': break;
#else
				case 's':
					if (flag) fmode |= S_ISUID; else fmode &= ~S_ISUID;
					break;
				case 'r':
					if (flag) fmode |= S_IRUSR; else fmode &= ~S_IRUSR;
					break;
				case 'w':
					if (flag) fmode |= S_IWUSR; else fmode &= ~S_IWUSR;
					break;
				case 'x':
					if (flag) fmode |= S_IXUSR; else fmode &= ~S_IXUSR;
					break;
#endif
				default:
					eraise("invalid user permission", EN_EXT);
				}
			break;
		case 'g':
			while (*what)
				switch (*what++) {
				case 's':
#ifdef S_ISGID
					if (flag) fmode |= S_ISGID; else fmode &= ~S_ISGID;
#endif
					break;
				case 'r':
#ifdef S_IRGRP
					if (flag) fmode |= S_IRGRP; else fmode &= ~S_IRGRP;
#endif
					break;
				case 'w':
#ifdef S_IWGRP
					if (flag) fmode |= S_IWGRP; else fmode &= ~S_IWGRP;
#endif
					break;
				case 'x':
#ifdef S_IXGRP
					if (flag) fmode |= S_IXGRP; else fmode &= ~S_IXGRP;
#endif
					break;
				default:
					eraise("invalid group permission", EN_EXT);
				}
			break;
		case 'o':
			while (*what)
				switch (*what++) {
				case 't':
#ifdef S_ISVTX
					if (flag) fmode |= S_ISVTX; else fmode &= ~S_ISVTX;
#endif
					break;
				case 'r':
#ifdef S_IROTH
					if (flag) fmode |= S_IROTH; else fmode &= ~S_IROTH;
#endif
					break;
				case 'w':
#ifdef S_IWOTH
					if (flag) fmode |= S_IWOTH; else fmode &= ~S_IWOTH;
#endif
					break;
				case 'x':
#ifdef S_IXOTH
					if (flag) fmode |= S_IXOTH; else fmode &= ~S_IXOTH;
#endif
					break;
				default:
					eraise("invalid other permission", EN_EXT);
				}
			break;
		default:
			eraise("invalid permission target", EN_EXT);
		}
		eif_file_chmod(name, fmode);
	}
}
/*
 * Change permissions of file `name', using an interface like chmod(1).
 * The flag is true if permissions are to be added, 0 to remove them.
 */
Change permissions of file `name', using an interface like chmod(1).
The flag is true if permissions are to be added, 0 to remove them.
Change permissions of file ` name ' using an interface like chmod ( 1 ) . The flag is true if permissions are to be added 0 to remove them .
void eif_file_perm(EIF_FILENAME name, char *who, char *what, int flag) {
	int fmode;					
	rt_stat_buf buf;			
	if (eif_file_stat(name, &buf, 1)) {
		esys();
	} else {
		fmode = (int) buf.st_mode;	
		switch (*who) {
		case 'u':
			while (*what)
				switch (*what++) {
#ifdef EIF_WINDOWS
				case 's': break;
				case 'r': break;
				case 'w': break;
				case 'x': break;
#else
				case 's':
					if (flag) fmode |= S_ISUID; else fmode &= ~S_ISUID;
					break;
				case 'r':
					if (flag) fmode |= S_IRUSR; else fmode &= ~S_IRUSR;
					break;
				case 'w':
					if (flag) fmode |= S_IWUSR; else fmode &= ~S_IWUSR;
					break;
				case 'x':
					if (flag) fmode |= S_IXUSR; else fmode &= ~S_IXUSR;
					break;
#endif
				default:
					eraise("invalid user permission", EN_EXT);
				}
			break;
		case 'g':
			while (*what)
				switch (*what++) {
				case 's':
#ifdef S_ISGID
					if (flag) fmode |= S_ISGID; else fmode &= ~S_ISGID;
#endif
					break;
				case 'r':
#ifdef S_IRGRP
					if (flag) fmode |= S_IRGRP; else fmode &= ~S_IRGRP;
#endif
					break;
				case 'w':
#ifdef S_IWGRP
					if (flag) fmode |= S_IWGRP; else fmode &= ~S_IWGRP;
#endif
					break;
				case 'x':
#ifdef S_IXGRP
					if (flag) fmode |= S_IXGRP; else fmode &= ~S_IXGRP;
#endif
					break;
				default:
					eraise("invalid group permission", EN_EXT);
				}
			break;
		case 'o':
			while (*what)
				switch (*what++) {
				case 't':
#ifdef S_ISVTX
					if (flag) fmode |= S_ISVTX; else fmode &= ~S_ISVTX;
#endif
					break;
				case 'r':
#ifdef S_IROTH
					if (flag) fmode |= S_IROTH; else fmode &= ~S_IROTH;
#endif
					break;
				case 'w':
#ifdef S_IWOTH
					if (flag) fmode |= S_IWOTH; else fmode &= ~S_IWOTH;
#endif
					break;
				case 'x':
#ifdef S_IXOTH
					if (flag) fmode |= S_IXOTH; else fmode &= ~S_IXOTH;
#endif
					break;
				default:
					eraise("invalid other permission", EN_EXT);
				}
			break;
		default:
			eraise("invalid permission target", EN_EXT);
		}
		eif_file_chmod(name, fmode);
	}
}
void eif_file_perm ( EIF_FILENAME name , char * who , char * what , int flag ) { int fmode ; rt_stat_buf buf ; if ( eif_file_stat ( name , & buf , 1 ) ) { esys ( ) ; } else { fmode = ( int ) buf . st_mode ; switch ( * who ) { case ' ' : while ( * what ) switch ( * what ++ ) { #ifdef EIF_WINDOWS case ' ' : break ; case ' ' : break ; case ' ' : break ; case ' ' : break ; #else case ' ' : if ( flag ) fmode |= S_ISUID ; else fmode &= ~ S_ISUID ; break ; case ' ' : if ( flag ) fmode |= S_IRUSR ; else fmode &= ~ S_IRUSR ; break ; case ' ' : if ( flag ) fmode |= S_IWUSR ; else fmode &= ~ S_IWUSR ; break ; case ' ' : if ( flag ) fmode |= S_IXUSR ; else fmode &= ~ S_IXUSR ; break ; #endif default : eraise ( " " , EN_EXT ) ; } break ; case ' ' : while ( * what ) switch ( * what ++ ) { case ' ' : #ifdef S_ISGID if ( flag ) fmode |= S_ISGID ; else fmode &= ~ S_ISGID ; #endif break ; case ' ' : #ifdef S_IRGRP if ( flag ) fmode |= S_IRGRP ; else fmode &= ~ S_IRGRP ; #endif break ; case ' ' : #ifdef S_IWGRP if ( flag ) fmode |= S_IWGRP ; else fmode &= ~ S_IWGRP ; #endif break ; case ' ' : #ifdef S_IXGRP if ( flag ) fmode |= S_IXGRP ; else fmode &= ~ S_IXGRP ; #endif break ; default : eraise ( " " , EN_EXT ) ; } break ; case ' ' : while ( * what ) switch ( * what ++ ) { case ' ' : #ifdef S_ISVTX if ( flag ) fmode |= S_ISVTX ; else fmode &= ~ S_ISVTX ; #endif break ; case ' ' : #ifdef S_IROTH if ( flag ) fmode |= S_IROTH ; else fmode &= ~ S_IROTH ; #endif break ; case ' ' : #ifdef S_IWOTH if ( flag ) fmode |= S_IWOTH ; else fmode &= ~ S_IWOTH ; #endif break ; case ' ' : #ifdef S_IXOTH if ( flag ) fmode |= S_IXOTH ; else fmode &= ~ S_IXOTH ; #endif break ; default : eraise ( " " , EN_EXT ) ; } break ; default : eraise ( " " , EN_EXT ) ; } eif_file_chmod ( name , fmode ) ; } }
Change permissions of file `name', using an interface like chmod(1).
Change permissions of file ` name ' using an interface like chmod ( 1 ) .
/* File mode to be altered */ /* File statistics */ /* We need to follow links since `chmod' does follow them to change the permissions. */ /* Fetch current file mode */