sysdefine.h

来自「AMLOGIC DPF source code」· C头文件 代码 · 共 224 行

H
224
字号
/*******************************************************************
 * 
 *  Copyright C 2004 by Amlogic, Inc. All Rights Reserved.
 *
 *  Description: 
 *
 *  Created: 
 *
 *******************************************************************/

#ifndef SYSDEFINE_H
#define SYSDEFINE_H

#include <sys/types.h>

//from stat.h
struct	stat
{
  dev_t		st_dev;
  ino_t		st_ino;
  mode_t	st_mode;
  nlink_t	st_nlink;
  uid_t		st_uid;
  gid_t		st_gid;
  dev_t		st_rdev;
  off_t		st_size;
  /* SysV/sco doesn't have the rest... But Solaris, eabi does.  */
  time_t	st_atime;
  long		st_spare1;
  time_t	st_mtime;
  long		st_spare2;
  time_t	st_ctime;
  long		st_spare3;
  long		st_blksize;
  long		st_blocks;
  long	st_spare4[2];
};

#define		_IFMT	0170000	/* type of file */
#define		_IFDIR	0040000	/* directory */
#define		_IFCHR	0020000	/* character special */
#define		_IFBLK	0060000	/* block special */
#define		_IFREG	0100000	/* regular */
#define		_IFLNK	0120000	/* symbolic link */
#define		_IFSOCK	0140000	/* socket */
#define		_IFIFO	0010000	/* fifo */

#define	S_IFMT		_IFMT
#define	S_IFDIR		_IFDIR
#define	S_IFCHR		_IFCHR
#define	S_IFBLK		_IFBLK
#define	S_IFREG		_IFREG
#define	S_IFLNK		_IFLNK
#define	S_IFSOCK	_IFSOCK
#define	S_IFIFO		_IFIFO


#define 	S_BLKSIZE  1024 /* size of a block */

#define	S_ISUID		0004000	/* set user id on execution */
#define	S_ISGID		0002000	/* set group id on execution */
#define	S_ISVTX		0001000	/* save swapped text even after use */
#define	S_IREAD		0000400	/* read permission, owner */
#define	S_IWRITE 	0000200	/* write permission, owner */
#define	S_IEXEC		0000100	/* execute/search permission, owner */

#define	S_ENFMT 	0002000	/* enforcement-mode locking */


#define	S_IRWXU 	      0000700	/* rwx, owner */
#define	S_IRUSR	      0000400	/* read permission, owner */
#define	S_IWUSR	      0000200	/* write permission, owner */
#define	S_IXUSR	             0000100	/* execute/search permission, owner */
#define	S_IRWXG	      0000070	/* rwx, group */
#define	S_IRGRP	      0000040	/* read permission, group */
#define	S_IWGRP	      0000020	/* write permission, grougroup */ /*-- Hidden file/dir flag in AVOS --*/
#define	S_IXGRP	      0000010	/* execute/search permission, group */
#define	S_IRWXO            0000007	/* rwx, other */
#define	S_IROTH	      0000004	/* read permission, other */
#define	S_IWOTH	      0000002	/* write permission, other */
#define	S_IXOTH	      0000001	/* execute/search permission, other *//*-- System file/dir flag in AVOS --*/

#define	S_ISBLK(m)	(((m)&_IFMT) == _IFBLK)
#define	S_ISCHR(m)	(((m)&_IFMT) == _IFCHR)
#define	S_ISDIR(m)	(((m)&_IFMT) == _IFDIR)
#define	S_ISFIFO(m)	(((m)&_IFMT) == _IFIFO)
#define	S_ISREG(m)	(((m)&_IFMT) == _IFREG)
#define	S_ISLNK(m)	(((m)&_IFMT) == _IFLNK)
#define	S_ISSOCK(m)	(((m)&_IFMT) == _IFSOCK)

#define S_IRWXUGO	(S_IRWXU|S_IRWXG|S_IRWXO)
#define S_IALLUGO	(S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
#define S_IRUGO		(S_IRUSR|S_IRGRP|S_IROTH)
#define S_IWUGO		(S_IWUSR|S_IWGRP|S_IWOTH)
#define S_IXUGO		(S_IXUSR|S_IXGRP|S_IXOTH)


//from fcntl.h
#define	_FOPEN		(-1)	/* from sys/file.h, kernel use only */
#define	_FREAD		0x0001	/* read enabled */
#define	_FWRITE		0x0002	/* write enabled */
#define	_FNDELAY	0x0004	/* non blocking I/O (4.2 style) */
#define	_FAPPEND	0x0008	/* append (writes guaranteed at the end) */
#define	_FMARK		0x0010	/* internal; mark during gc() */
#define	_FDEFER		0x0020	/* internal; defer for next gc pass */
#define	_FASYNC		0x0040	/* signal pgrp when data ready */
#define	_FSHLOCK	0x0080	/* BSD flock() shared lock present */
#define	_FEXLOCK	0x0100	/* BSD flock() exclusive lock present */
#define	_FCREAT		0x0200	/* open with file create */
#define	_FTRUNC		0x0400	/* open with truncation */
#define	_FEXCL		0x0800	/* error on open if file exists */
#define	_FNBIO		0x1000	/* non blocking I/O (sys5 style) */
#define	_FSYNC		0x2000	/* do all writes synchronously */
#define	_FNONBLOCK	_FNDELAY /* non blocking I/O (POSIX style) */
#define	_FNOCTTY	0x8000	/* don't assign a ctty on this open */

#define	O_ACCMODE	(O_RDONLY|O_WRONLY|O_RDWR)

/*
 * Flag values for open(2) and fcntl(2)
 * The kernel adds 1 to the open modes to turn it into some
 * combination of FREAD and FWRITE.
 */
#define	FD_CLOEXEC	1	/* posix */


#define	O_RDONLY	0		/* +1 == FREAD */
#define	O_WRONLY	1		/* +1 == FWRITE */
#define	O_RDWR		2		/* +1 == FREAD|FWRITE */
#define	O_APPEND	_FAPPEND
#define	O_CREAT		_FCREAT
#define	O_TRUNC		_FTRUNC
#define	O_EXCL		_FEXCL
/*	O_SYNC		_FSYNC		not posix, defined below */
/*	O_NDELAY	_FNDELAY 	set in include/fcntl.h */
/*	O_NDELAY	_FNBIO 		set in 5include/fcntl.h */
#define	O_NONBLOCK	_FNONBLOCK
#define	O_NOCTTY	_FNOCTTY

#define	F_DUPFD		0	/* Duplicate fildes */
#define	F_GETFD		1	/* Get fildes flags (close on exec) */
#define	F_SETFD		2	/* Set fildes flags (close on exec) */
#define	F_GETFL		3	/* Get file flags */
#define	F_SETFL		4	/* Set file flags */
#define	F_GETOWN 	5	/* Get owner - for ASYNC */
#define	F_SETOWN 	6	/* Set owner - for ASYNC */
#define	F_GETLK  	7	/* Get record-locking information */
#define	F_SETLK  	8	/* Set or Clear a record-lock (Non-Blocking) */
#define	F_SETLKW 	9	/* Set or Clear a record-lock (Blocking) */


//from limits.h
#define NAME_MAX 11
#define LNAME_MAX 255
//from dirent.h
typedef struct _dirdesc {
	int	dd_fd;
	long	dd_loc;
	long	dd_size;
	char	*dd_buf;
	int	dd_len;
	long	dd_seek;
//added by rain
//	int  dd_max;

} DIR;

# define __dirfd(dp)	((dp)->dd_fd)

DIR *opendir(const char *);
struct dirent *readdir(DIR *);
void rewinddir(DIR *);
int closedir(DIR *);
void seekdir(DIR *dir, long loc);
long telldir(DIR *dir);

#define SUPPORT_LONG_FILE_NAME

#define MAX_FILE_NAME_LENTH 100


struct dirent {
	long	d_ino;
	off_t	d_off;
	unsigned short	d_reclen;
	/* we need better syntax for variable-sized arrays */
	unsigned char	d_namlen;
	unsigned char	d_lnamlen;
	unsigned		d_mode;
	char		d_name[NAME_MAX + 2]; //add . and \0 Andrew
	char		d_lname[LNAME_MAX + 1];  //change to 16bits. Andrew
};

//from stdio.h
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif

//from unistd.h
#define MAXPATHLEN 1024
#define MAXNAMLEN 1024

#define F_OK 0
#define R_OK 4
#define W_OK 2
#define X_OK 1

/* Endian conversion during byte stream transfer */
#define ENDIAN_ABCD_ABCD		0x00
#define ENDIAN_ABCD_BADC		0x01
#define ENDIAN_ABCD_CDAB		0x02
#define ENDIAN_ABCD_DCBA		0x03


#include <errno.h>

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?