/************** Begin of vos.h *******************************************/
/**********************************************************
* 版权所有 (C)2002, 深圳市中兴通讯股份有限公司。
*
* 文件名称： vos.h
* 文件标识：
* 内容摘要： 操作系统封装层头文件（主要是所包含头文件、数据结构、接口等）
* 其它说明： 无
* 当前版本： V1.0
* 作    者： 王泽民
* 完成日期： 2003/08/10
*
* 修改记录1：
*    修改日期：
*    版 本 号：
*    修 改 人：
*    修改内容：
**********************************************************/
#ifndef _VOS_H_
#define _VOS_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "voscfg.h"
	/**********************************************************
	*                          宏定义                         *
	**********************************************************/

#define    VOS_NULL                      0x0

#define    VOS_TRUE                      1
#define    VOS_FALSE                     0

#define    VOS_SUCCESS                   0     /* PSOS返回值                    */
#define    VOS_PCBINDEXNO                0     /* 保存pcbindex的便条寄存器号    */
#define    VOS_TASKPRINO                 1     /* 保存任务优先级的便条寄存器号  */
#define    VOS_TICKNUM                   1     /* 中断的tick数                  */
#define    TIMER_SCAN_EVENT              (WORD32)(1<<15)
#define    MEMLEAK_SCAN_EVENT            (WORD32)(1<<16)
#define    MAX_LENGTH_BUF                512

#define    VOS_NO_WAIT                   0x0
#define    VOS_WAIT_FOREVER              -1

#define    VOS_SEM_DELETE_SAFE           0x04
#define    VOS_SEM_INVERSION_SAFE        0x08

#define    VOS_VM_STATE_MASK_VALID       0x03
#define    VOS_VM_STATE_MASK_WRITABLE    0x0c
#define    VOS_VM_STATE_MASK_CACHEABLE   0x30
#define    VOS_VM_STATE_MASK_WBACK       0x40
#define    VOS_VM_STATE_MASK_GLOBAL      0x80
#define    VOS_VM_STATE_MASK_GUARDED     0x80

#define    VOS_VM_STATE_VALID            0x01
#define    VOS_VM_STATE_VALID_NOT        0x00
#define    VOS_VM_STATE_WRITABLE         0x04
#define    VOS_VM_STATE_WRITABLE_NOT     0x00
#define    VOS_VM_STATE_CACHEABLE        0x10
#define    VOS_VM_STATE_CACHEABLE_NOT    0x00
#define    VOS_VM_STATE_WBACK			 0x40
#define    VOS_VM_STATE_WBACK_NOT		 0x00
#define    VOS_VM_STATE_GLOBAL			 0x80
#define    VOS_VM_STATE_GLOBAL_NOT		 0x00
#define    VOS_VM_STATE_GUARDED			 0x80
#define    VOS_VM_STATE_GUARDED_NOT		 0x00

#define    MAXCOUNTSEM                   10000
#define    VOS_MAX_PATH_LEN              50
#define    VOS_MAX_FILENAME_LEN          60
#define    VOS_MAX_EXP_FILENAME_LEN      8

#if OS_TYPE == OS_VXWORKS
#define    NULL_TASKID               ERROR
#define    NULL_SEMID                NULL
#define    NULL_MSGQID               NULL
#define    NULL_MSGGET               0
#define    DIR_CODE                  0x2f    /* 定义符号 "/" */
#define    DIR_CONCATE_CODE            "/"
#endif

#if OS_TYPE == OS_WINNT
#define    NULL_TASKID               NULL
#define    NULL_SEMID                NULL
#define    NULL_MSGQID               NULL
#define    NULL_MSGGET               0
#define    DIR_CODE                  0x5c    /* 定义符号" \" */
#define    DIR_CONCATE_CODE            "\\"
#define    RDONLY                    0
#define    WRONLY                    1
#define    RDWR                      2
#define    WINNT_ERROR               -1    
#endif

#if OS_TYPE == OS_PSOS
#define    NULL_TASKID               0xffffffff
#define    NULL_SEMID                0xffffffff
#define    NULL_MSGQID               0xffffffff
#define    NULL_MSGGET               0xffffffff
#define    MSG_Q_FIFO                0x00
#define    MSG_Q_PRIORITY            0x01
#define    MSG_PRI_NORMAL            0x00
#define    MSG_PRI_URGENT            0x01
#define    RAM_BLOCKS                2*360  /* RAM disk块大小 */
#define    RAM_PATH_LENGTH           80
#define    MIN_EXPAN_BLOCKS          10
#endif

#if OS_TYPE == OS_LINUX
#ifdef VXWORKS_TO_LINUX
#define    NULL_TASKID               ERROR
#define    NULL_SEMID                NULL
#define    NULL_MSGQID               NULL
#else
#define    NULL_TASKID               0xffffffff
#define    NULL_SEMID                0xffffffff
#define    NULL_MSGQID               0xffffffff
#endif
#define    NULL_MSGGET               0
#define    DIR_CODE                  0x2f  /* 定义符号 "/" */

#endif

#if OS_TYPE == OS_KLINUX
#define    NULL_TASKID               ERROR
#define    NULL_SEMID                 NULL
#define    NULL_MSGQID              NULL
#define    TRUE   1
#define    FALSE 0
#define    DIR_CONCATE_CODE        "/"
#define    DIR_CODE                0x2f
#define    VOS_ISDIR(mode)    ((mode & S_IFMT) == S_IFDIR)    /* 判断是否是目录 */
	// #define    malloc(size) __vmalloc(size,GFP_KERNEL |__GFP_HIGHMEM, PAGE_KERNEL)
	//#define    free(buf)      vfree(buf)
#define    printf  printk
#endif


	/************** SOCKET & TCP ***************/
#define NELEMENTS(array)  (sizeof (array) / sizeof ((array) [0]))

#ifndef HASMAX
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
#endif
#endif

#ifndef HASMIN
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif
#endif 


#if (OS_TYPE == OS_VXWORKS)
#define SOCKET_ERROR     ERROR
#define SOMAXCONN        5
#define VOS_EWOULDBLOCK  EWOULDBLOCK
#define VOS_ECONNRESET   ECONNRESET
#endif

#if (OS_TYPE == OS_WINNT)
	/* 数组中元素个数 */
	///(pclint检测注释掉该行)#define NELEMENTS(array)  (sizeof (array) / sizeof ((array) [0]))
#define CloseSocket closesocket
#define bcopy(src,dst,size) memcpy(dst,src,size)
#define errnoGet         WSAGetLastError
	typedef long int STATUS ;
#define VOS_EWOULDBLOCK WSAEWOULDBLOCK
#define VOS_ECONNRESET WSAECONNRESET
#endif


#if ((OS_TYPE == OS_LINUX) ||(OS_TYPE == OS_KLINUX))
	typedef unsigned long ULONG;
#define errnoGet() errno
#define SOCKET_ERROR     ERROR
#define SOMAXCONN	128
#define VOS_EWOULDBLOCK  EWOULDBLOCK
#define VOS_ECONNRESET ECONNRESET

#endif

#if ((OS_TYPE == OS_VXWORKS) || (OS_TYPE == OS_LINUX)||(OS_TYPE == OS_KLINUX))
	typedef int SOCKET;
#endif

	/**************** VOS TIMER *******************/

	/* 时钟中断精度10ms */
#define  TIMER_RESOLUTION    10 


#if (OS_TYPE == OS_WINNT)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <mmsystem.h>
#define  VOS_TIMERCALLBACK     LPTIMECALLBACK  
#define  VOS_TIMER_ID          WORD32 
#define  INVALID_VOS_TIMERID   0
#endif

#if (OS_TYPE == OS_VXWORKS)
#define  VOS_TIMERCALLBACK     FUNCPTR  
#define  VOS_TIMER_ID          WDOG_ID 
#define  INVALID_VOS_TIMERID   NULL

#define  TIMER_ONESHOT         0
#define  TIMER_PERIODIC        1
#endif

#if (OS_TYPE == OS_PSOS)
#define  VOS_TIMERCALLBACK     LPVOID  
#define  VOS_TIMER_ID          WORD32 
#define  INVALID_VOS_TIMERID   0xffffffff
#endif

#if (OS_TYPE == OS_LINUX)
	typedef  void(*VOS_TIMERCALLBACK)(int);
#define  VOS_TIMER_ID          WORD32 
#define  INVALID_VOS_TIMERID   0
#endif

#if (OS_TYPE == OS_KLINUX)
#ifndef HZ
#define HZ 100
#endif     
	extern unsigned long volatile jiffies;

	typedef  void(*VOS_TIMERCALLBACK)(WORD32);
	typedef  struct timer_list    *VOS_TIMER_ID;
#define  INVALID_VOS_TIMERID   NULL    
#endif

	/**************** VOS VOLUME *******************/
#define        VOLNAME_LENGTH            10


	/**********************************************************
	*                          类型定义                       *
	**********************************************************/

#if    OS_TYPE == OS_VXWORKS
#define    VOS_ISDIR(mode)    ((mode & S_IFMT) == S_IFDIR)    /* 判断是否是目录 */
#define    VOS_ISCHR(mode)    ((mode & S_IFMT) == S_IFCHR)    /* 是否 是特殊字符 */
#define    VOS_ISBLK(mode)    ((mode & S_IFMT) == S_IFBLK)    /* 判断是否是特殊块 */
#define    VOS_ISREG(mode)    ((mode & S_IFMT) == S_IFREG)    /* 判断是否正规块 */
#define    VOS_ISFIFO(mode)   ((mode & S_IFMT) == S_IFIFO)    /* 判断是否fifo  */
#elif OS_TYPE== OS_WINNT
#define    VOS_ISDIR(mode)    ((mode & _S_IFMT) == _S_IFDIR)    /* 判断是否是目录 */
#define    VOS_ISCHR(mode)    ((mode & _S_IFMT) == _S_IFCHR)    /* 是否 是特殊字符 */
#define    VOS_ISBLK(mode)    ((mode & _S_IFMT) == _S_IFBLK)    /* 判断是否是特殊块 */
#define    VOS_ISREG(mode)    ((mode & _S_IFMT) == _S_IFREG)      /* 判断是否正规块 */
#define    VOS_ISFIFO(mode)   ((mode & _S_IFMT) == _S_IFIFO)    /* 判断是否fifo  */
#endif


	/* ID类型定义 */
#if OS_TYPE == OS_VXWORKS
	typedef SWORD32  TASK_ID;
	typedef PART_ID  MEMPART_ID;
	typedef FUNCPTR  VOS_FUNCPTR;
	typedef WIND_TCB TASK_TCB;	
#endif

#if OS_TYPE == OS_PSOS
	typedef WORD32  TASK_ID;
	typedef VOS_VOIDFUNCPTR  VOS_FUNCPTR;
	typedef WORD32  SEM_ID;
	typedef WORD32  MSG_Q_ID;
	typedef WORD32  MEMPART_ID;	
#endif

#if OS_TYPE == OS_WINNT
	typedef HANDLE   TASK_ID;
	typedef HANDLE   SEM_ID;
	typedef HANDLE   MEMPART_ID;
	typedef HANDLE   MSG_Q_ID;
	typedef LPTHREAD_START_ROUTINE VOS_FUNCPTR;	
#endif

#if OS_TYPE == OS_LINUX
	typedef void        VOID;
	typedef pthread_t	TASK_ID;
	typedef sem_t *		SEM_ID; 
#ifndef PART_ID
#define PART_ID int
#endif /*wenhm,050826*/
	typedef PART_ID     MEMPART_ID;
	typedef void*       VOS_FUNCPTR; 
	///typedef void (*AutoRunHandler)(void);
	typedef WORD32      MSG_RECEIVE;/*yangyp*/    
	typedef WORD32      MSG_Q_ID;

	///typedef FUNCPTR     VOS_FUNCPTR; 
	///typedef WIND_TCB    TASK_TCB;
	///typedef WORD16      VOS_TIMER_ID;/*yangyp*/
	///typedef WORD32		SEM_ID;
	///typedef SWORD32     TASK_ID;
#endif
#if OS_TYPE == OS_KLINUX
	typedef void        VOID;
	typedef pthread_t	TASK_ID;
	typedef sem_t*		SEM_ID; 
	/*typedef PART_ID     MEMPART_ID;
	typedef FUNCPTR     VOS_FUNCPTR;
	typedef WIND_TCB    TASK_TCB;*/
	typedef WORD32      MEMPART_ID;
	typedef void*       VOS_FUNCPTR;
	typedef WORD32      MSG_RECEIVE;/*yangyp*/
	typedef WORD16      VOS_TIMER_ID;/*yangyp*/
	typedef WORD32      MSG_Q_ID;
#endif


	/* VOS_STATUS: VOS层函数返回值 */
	typedef enum
	{
		VOS_ERROR = -1,
		VOS_OK = 0,
	}VOS_STATUS;

	/* VOS_SEM_STATE  二进制信号量初始状态 */
	typedef enum
	{
		VOS_SEM_EMPTY,
		VOS_SEM_FULL
	}VOS_SEM_STATE;

	/* 信号量队列类型:先进先出或优先级 */
	typedef enum
	{
		VOS_SEM_Q_FIFO,
		VOS_SEM_Q_PRIORITY
	}VOS_SEM_QUEUE_TYPE;

	/* 消息优先级 */
	typedef enum
	{
		VOS_MSG_PRI_NORMAL,
		VOS_MSG_PRI_URGENT
	}VOS_MSG_TYPE;

	/* 消息排队类型:先进先出或优先级 */
	typedef enum
	{
		VOS_MSG_Q_FIFO,
		VOS_MSG_Q_PRIORITY
	}VOS_MSGQUE_TYPE;

	/* 任务状态 */
	typedef enum
	{
		VOS_TASK_STATUS_NULL,
		VOS_TASK_STATUS_RUNNING,
		VOS_TASK_STATUS_READY,
		VOS_TASK_STATUS_PEND,
		VOS_TASK_STATUS_SUSPEND,
		VOS_TASK_STATUS_DEBUG,
		VOS_TASK_STATUS_DEAD
	}VOS_TASK_STATUS;

	/* 参数和返回值为VOID的函数定义 */
	typedef   VOID(*VOS_VOIDFUNCPTR)(VOID);

	/**********************************************************
	*                          数据结构定义                   *
	**********************************************************/

	/* 系统时钟 */
	typedef struct tagSYS_CLOCK
	{
		WORD16             wSysYear;
		WORD16             wSysMon;
		WORD16             wSysDay;
		WORD16             wSysHour;
		WORD16             wSysMin;
		WORD16             wSysSec;
		WORD16             wSysWeek;
		WORD16             wMilliSec;
	}T_SYS_CLOCK;

#undef st_atime
#undef st_mtime
#undef st_ctime
	/* 文件状态描述 */
	typedef struct tagFileStat
	{
		WORD32  st_dev;
		WORD32  st_ino;
		WORD16  st_mode;
		SWORD16 st_nlink;
		SWORD16 st_uid;
		SWORD16 st_gid;
		WORD32  st_rdev;
		SWORD32 st_size;
		SWORD32 st_atime;
		SWORD32 st_mtime;
		SWORD32 st_ctime;
	}T_FileStat;


	/* added by 温辉敏,文件的访问属性*/
	enum Permissions {
		/// File has world execute permission
		WorldExecute = 1,   
		/// File has world write permission
		WorldWrite = 2,     
		/// File has world read permission
		WorldRead = 4,      
		/// File has group execute permission
		GroupExecute = 8,   
		/// File has group write permission
		GroupWrite = 16,    
		/// File has group read permission
		GroupRead = 32,     
		/// File has owner execute permission
		UserExecute = 64,   
		/// File has owner write permission
		UserWrite = 128,    
		/// File has owner read permission
		UserRead = 256,     
		/// All possible permissions.
		AllPermissions = 0x1ff,   
		/// Owner read & write plus group and world read permissions.
		DefaultPerms = UserRead|UserWrite|GroupRead|WorldRead,
		/// Owner read & write & execute plus group and world read & exectute permissions.
		DefaultDirPerms = DefaultPerms|UserExecute|GroupExecute|WorldExecute		
	};

#if OS_TYPE == OS_WINNT
	/**
	下面结构当和MINIAce一起使用时,
	os_dirent.h中相应的结构产生的冲突,而os_dirent.h结构中采用了ACE_LACKS_STRUCT_DIR才会生效,
	因此可以设定vos.h中不采用ACE_LACKS_STRUCT_DIR宏定义时它的结构dirent才生效. 
	added by wenhm in 2007.05.16
	*/
#ifndef ACE_LACKS_STRUCT_DIR
	/* 路径入口 */
	struct  dirent
	{
		unsigned short d_ino;
		unsigned short d_off;
		unsigned short d_reclen;
		CHAR     d_name [VOS_MAX_FILENAME_LEN + 1];
	};
#endif


	/* 目录项的定义 */
	typedef struct
	{
		SWORD32       dd_fd;        /* 打开目录的文件描述 */
		SWORD32       dd_cookie;    /* 目录中的文件特定标示filesys-specific marker within dir */
		struct dirent dd_dirent;    /* 路径入口 */
	}DIR;


#endif



	/**********************************************************
	*                          函数原型                       *
	**********************************************************/

	/******************  任务管理模块 ************************/
	TASK_ID       VOS_CreateTask(CHAR *pTaskName, SWORD32 priority,
		SWORD32 options, SWORD32 stackSize,
		VOS_FUNCPTR pTaskEntry, SWORD32 arg1,
		SWORD32 arg2, SWORD32 arg3, SWORD32 arg4,
		SWORD32 arg5, SWORD32 arg6, SWORD32 arg7,
		SWORD32 arg8, SWORD32 arg9, SWORD32 arg10);

	VOS_STATUS    VOS_DeleteTask(TASK_ID taskId);
	VOS_STATUS    VOS_SuspendTask(TASK_ID taskId);
	VOS_STATUS    VOS_ResumeTask(TASK_ID  taskId);
	VOS_STATUS    VOS_SetPriority(TASK_ID TaskId, SWORD32 newPriority);
	SWORD32       VOS_GetPriority(TASK_ID TaskId);

	VOS_STATUS    VOS_DelayTask(SWORD32 delayTime);
	TASK_ID       VOS_GetSelfTaskID(VOID);
	VOS_STATUS    VOS_SuspendSelf(VOID);

	VOS_TASK_STATUS VOS_GetTaskStatus(TASK_ID taskId);
	VOID          VOS_CheckStack(TASK_ID taskId);


	/************** 二进制信号量与计数信号量 *****************/
	SEM_ID        VOS_CreateBSem(SWORD32 options, VOS_SEM_STATE initialState);
	SEM_ID        VOS_CreateCSem(SWORD32 options, SWORD32 initialState);
	SEM_ID        VOS_CreateMSem(SWORD32 options);
	VOS_STATUS    VOS_DeleteSem(SEM_ID semId);
	VOS_STATUS    VOS_TakeSem(SEM_ID semId, SWORD32 timeout);
	VOS_STATUS    VOS_GiveSem(SEM_ID semId);


	/**************** 内存管理模块 ***************************/
	MEMPART_ID    VOS_CreateMemPart(CHAR *pPool, WORD32 poolSize);
	VOID         *VOS_AllocMemPart(MEMPART_ID memPartId, WORD32 size);
	VOS_STATUS    VOS_FreeMemPart(MEMPART_ID memPartId, CHAR *pBlock);

	CHAR         *VOS_GetPhysMemTop(VOID);
	WORD32        VOS_GetRnFreeInfo(WORD32 dwRnId);

	/********************* 中断处理 ******* ******************/
	SWORD32       VOS_LockInt();
	VOID          VOS_UnlockInt(SWORD32 dwLevel);


	/********************* 消息队列 **************************/
	MSG_Q_ID      VOS_CreateMsgQue(WORD32 dwMaxMsgNum,
		WORD32 dwMaxMsgLength,
		BYTE ucOptions);
	VOS_STATUS    VOS_DeleteMsgQue(MSG_Q_ID wMsgId);
	VOS_STATUS    VOS_SendMsg(MSG_Q_ID wMsgId,
		CHAR *pcMsgData,
		WORD32 dwlen,
		SWORD32 dwtimeout,
		BYTE ucPrior);
	WORD32        VOS_ReceiveMsg(MSG_Q_ID wMsgId,
		CHAR  *pcMsgDataBuffer,
		WORD32 dwlen,
		SWORD32 iTimeout);
	WORD32        VOS_GetCurMsgs(MSG_Q_ID wMsgId);


	/********************* 时钟模块 **************************/
	VOS_STATUS    VOS_ConnectClk(VOS_VOIDFUNCPTR clkIntEntry);
	SWORD32       VOS_GetSysClkRate(VOID);
	WORD32        VOS_GetTick();
	VOS_STATUS    VOS_IniSysClk(T_SYS_CLOCK *pSysSoftClk);
	VOS_STATUS    VOS_SetSysClkRate(SWORD32 sdTicPerSend);

	VOS_STATUS    VOS_TimeSet(T_SYS_CLOCK *pSysSoftClk);
	VOS_STATUS    VOS_TimeGet(T_SYS_CLOCK *pSysSoftClk);

	VOS_TIMER_ID VOS_RelTimer(
		WORD32 dwTimeLength, 
		VOS_TIMERCALLBACK lpTimeProc,
		WORD32 dwUser,
		WORD32 dwEvents			 
		);

	VOS_TIMER_ID VOS_AbsTimer(
		T_SYS_CLOCK tRelTimerSet, 
		VOS_TIMERCALLBACK lpTimeProc,
		WORD32 dwUser,
		WORD32 dwEvents			 
		);

	VOS_TIMER_ID VOS_PerTimer(
		WORD32 dwTimeLength, 			 
		VOS_TIMERCALLBACK lpTimeProc,
		WORD32 dwUser,
		WORD32 dwEvents			 
		);

	VOS_STATUS   VOS_TimerKill(VOS_TIMER_ID TimerId);


	/********************* 错误异常 **************************/
	SWORD32       VOS_GetErrno(VOID);
	VOID          VOS_AddExcHook(VOS_FUNCPTR excHookEntry);

	/********************* 初始化VOS *************************/
	VOS_STATUS    VOS_InitVOS(VOID);


	/****************** 当前进程PCB操作 **********************/
	VOS_STATUS    VOS_SetCurPCBIndex(WORD16  wIndex);
	WORD16        VOS_GetCurPCBIndex(VOID);
	VOS_STATUS    VOS_FreeTlsData(VOID);

	/******************      事件模块   **********************/
	VOS_STATUS    VOS_SendEvent(TASK_ID taskId, WORD32 dwEvents);
	VOS_STATUS    VOS_ReceiveEvent(WORD32 dwEvents, WORD32 dwTimeout,
		WORD32 *ptEventsR);


	/******************  调试打印函数  **********************/
	VOID          VOS_Display(const CHAR *fmt, ... );


	/********************文件系统模块**********************/
	SWORD32       VOS_Create(CHAR *pcFileName);
	VOS_STATUS    VOS_Delete(CHAR *pcFileName);
	SWORD32       VOS_Open(CHAR *pcFileName,SWORD32 sdwFlag,SWORD32 sdwMode);
	VOS_STATUS    VOS_Close(SWORD32 sdwFileHandle);
	VOS_STATUS    VOS_Rename(CHAR *pcOldFileName,CHAR *pcNewFileName);
	SWORD32       VOS_Read(SWORD32 sdFileHandle,VOID *pBuffer,SWORD32 sdCount);
	SWORD32       VOS_Write(SWORD32 sdFileHandle,VOID *pBuffer,SWORD32 sdCount);
	SWORD32       VOS_FileLength(CHAR *pcFileName);
	SWORD32       VOS_Lseek(SWORD32 sdFileHandle,SWORD32 sdOffset,SWORD32 sdOrigin);
	VOS_STATUS    VOS_CreateDir(CHAR *pcDirName);
	VOS_STATUS    VOS_DeleteDir(CHAR *pcDirName);
	VOS_STATUS    VOS_RenameDir(CHAR *pcOldDirName,CHAR *pcNewDirName);
	DIR           *VOS_OpenDir(CHAR *pcDirName);
	struct dirent *VOS_ReadDir(DIR *pDir);
	VOS_STATUS    VOS_CloseDir(DIR *pDir);
	VOS_STATUS    VOS_Stat(CHAR *pcFileName, T_FileStat *pStat);
	VOS_STATUS    VOS_CreateMemDev(CHAR      *pcRamDiskName,
		CHAR      *pcRamAddr,
		SWORD32   sdwCHARsPerBlk,
		SWORD32   sdwBlksPerTrack,
		SWORD32   sdwNBlocks,
		SWORD32   sdwBlkOffset);
	VOS_STATUS    VOS_StartFtpServer(LPVOID   pLoginRtn,
		SWORD32  sdwStackSize);

	VOS_STATUS    VOS_StopFtpServer(VOID);

#if OS_TYPE == OS_PSOS
	VOS_STATUS    VOS_FileSystemInit(VOID);
#endif

	/****************** SOCKET **********************/
	VOS_STATUS  VOS_InitSocketLib(VOID);
	SOCKET      VOS_Socket(SWORD32 family, SWORD32 type,SWORD32 protocol );
	VOS_STATUS  VOS_Bind(SWORD32 s, const struct sockaddr * name,  SWORD32 namelen);
	VOS_STATUS  VOS_Accept(SOCKET s ,struct sockaddr * addr,SWORD32* addrlen );
	VOS_STATUS  VOS_Listen(SOCKET s ,SWORD32 backlog );
	SWORD32     VOS_Send(SOCKET s,const char * buffer,SWORD32 len, SWORD32 flags);
	SWORD32     VOS_Recv(SOCKET s,const char * buffer,SWORD32 len,SWORD32 flags);
	VOS_STATUS  VOS_CloseSocket(SOCKET s);
	VOS_STATUS  VOS_CleanUp(void);
	VOS_STATUS  VOS_ConnectWithTimeout(SOCKET s,  struct sockaddr * adrs,  int adrsLen,
	struct timeval *  timeVal );
	SWORD32     VOS_SendTo(SOCKET s,const char *buffer,SWORD32 len, SWORD32 flags,
	struct sockaddr *to, int tolen );
	SWORD32     VOS_SendSocketMsg(SOCKET s,  struct msghdr  *mp, SWORD32 flags);
	SWORD32     VOS_RecvFrom(SOCKET s,const char *buffer,SWORD32 len, SWORD32 flags,
	struct sockaddr *from, int  * pFromLen);
	SWORD32     VOS_RecvSocketMsg(SOCKET s,  struct msghdr  *mp, SWORD32 flags);
	VOS_STATUS  VOS_Shutdown(SOCKET s, int how);
	VOS_STATUS  VOS_SetSockOpt (SOCKET s,  int level,  int  optname, char * optval, int optlen );
	VOS_STATUS  VOS_GetSockOpt (SOCKET s,  int level,  int  optname, char * optval, int *optlen );
	VOS_STATUS  VOS_GetSockName(SOCKET s,   struct sockaddr * name,   int * namelen);
	VOS_STATUS  VOS_GetPeerName (SOCKET s, struct sockaddr * name, int * namelen);
	SWORD32     VOS_Select(int width, fd_set  *pReadFds, fd_set  * pWriteFds,
		fd_set * pExceptFds, struct timeval * pTimeOut);
	SWORD32     VOS_Ioctl(int fd, int function,int arg);

	/****************** Exec **********************/
	VOS_STATUS VOS_Exec(
		const CHAR * strFile,		///要执行的程序名称
		const CHAR * strArgs		///要传入的命令行参数
		);

	VOS_STATUS VOS_ExecByFork(
		const CHAR * strFile,	///要执行的程序名称
		const CHAR * strArgs	///要传入的命令行参数
		);

	VOS_STATUS VOS_ForceDelete(CHAR *pcFileName);

	SWORD32 VOS_Chmod(
		const CHAR * pcFileName, ///文件名
		int iPermissions         ///要进行设置的文件属性
		);

	VOS_STATUS VOS_SetRLimit(const int iCoreFileSize);

	VOS_STATUS VOS_GetTimeOfDay(struct timeval *tv, struct timezone *tz);

#ifdef __cplusplus
}
#endif


#endif
/************** End of vos.h *******************************************/