/* Uses DOS functions to get or set ALL file attribute bits */

/* Copyright 1986 John Navas II, All Rights Reserved.
FILEATTR is made available for personal, non-commercial use only.  You
are granted a limited license to use FILEATTR, and to copy it and
distribute it, provided that no fee is charged for such copying and
distribution, and that it is ONLY distributed in its original,
unmodified state. */

/* Language: Microsoft C Version 3.00 */

#include <dos.h>
#include <stdio.h>

#define FA_RDONLY	0x01				/* file attributes */
#define FA_HIDDEN	0x02
#define FA_SYSTEM	0x04
#define FA_VOLABL	0x08
#define FA_SUBDIR	0x10
#define FA_ARCHIV	0x20

int fileattr( o, s, a )					/* GET/SET FILE ATTRIBUTES */
int o;									/* 0 = get; 1 = set
char *s;								/* path name */
int a;									/* attributes */
{	
	union REGS reg;

	reg.h.ah = 0x43;					/* chmod */
	reg.h.al = (unsigned char) o;
	reg.x.cx = (unsigned int) a;
	reg.x.dx = (unsigned int) s;
	intdos( &reg, &reg );

	return reg.x.cflag ? EOF : (int) reg.x.cx;
	}
