[Anet-checkins] CVS: ANet/ANet_Daemon/Common ANetCommon.h,1.2,1.3 Files.h,1.5,1.6
Status: Abandoned
Brought to you by:
benad
From: Benoit N. <be...@us...> - 2001-12-18 01:16:32
|
Update of /cvsroot/anet/ANet/ANet_Daemon/Common In directory usw-pr-cvs1:/tmp/cvs-serv15311/ANet/ANet_Daemon/Common Modified Files: ANetCommon.h Files.h Log Message: "" Index: ANetCommon.h =================================================================== RCS file: /cvsroot/anet/ANet/ANet_Daemon/Common/ANetCommon.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ANetCommon.h 2001/12/12 20:05:09 1.2 --- ANetCommon.h 2001/12/18 01:16:29 1.3 *************** *** 44,46 **** --- 44,51 ---- #endif //__MACTYPES__ + typedef char boolean; + + #define FALSE 0 + #define TRUE 1 + #endif Index: Files.h =================================================================== RCS file: /cvsroot/anet/ANet/ANet_Daemon/Common/Files.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Files.h 2001/12/12 20:05:09 1.5 --- Files.h 2001/12/18 01:16:29 1.6 *************** *** 30,42 **** --- 30,225 ---- */ + /*! + \brief Initializes an <CODE>ANetFile</CODE> structure. + \return A properly initialized ANetFile structure + \see ANetGetSetFilePath() ANetWriteFile() + + This function returns a properly <CODE>ANetFile</CODE> structure. This does not + create any new file; to create a new file, set it's path to the new + file's location (with <CODE>ANetGetSetFilePath()</CODE>), then write some data in + the file (with <CODE>ANetWriteFile()</CODE>); + */ ANetFile ANetInitFile(); + + /*! + \brief Gets or sets the file path of an <CODE>ANetFile</CODE>. + \param f The file + \param path A memory block. It contains a NULL terminated string. + \param set If <CODE>0</CODE>, the function will put the file's path, as a NULL + terminated string, in path. Otherwise, the function will set the + file's path to function result. + + \return + \li <CODE>0</CODE>: No error + \li <CODE>1</CODE>: Can't change path + \li <CODE>2</CODE>: Invalid path + \li <CODE>3</CODE>: path is invalid or not big enough + \li <CODE>4</CODE>: file is open + \li <CODE>60</CODE>: File is busy ("busy" flag is true) + + This function will not set or get the file path of the <CODE>ANetFile</CODE> + structure pointed by <CODE>f</CODE>. You cannot change the path of the file while + it is open or busy. Also not, all paths are accepted on every + operating system, and so it is recommended that you do not go outside + the directory that contains the ANet daemon. + */ UInt32 ANetGetSetFilePath(ANetFile *f, ANetMemoryTag path, UInt8 set); + + /*! + \brief Gets or sets the asynchronous flag of an <CODE>ANetFile</CODE>. + \param f The file + \param async A byte containing the "async" flag value; if 0, the file is + used synchronously, otherwise it is used asynchronously. + \param set If 0, the value of the "async" flag of the file is put in the + byte pointed by async. Otherwise, the value of "async" of the file is + set to the value pointed by async. + + \return + \li <CODE>0</CODE>: No error + \li <CODE>1</CODE>: Invalid pointer for async + \li <CODE>60</CODE>: File is busy ("busy" flag is true). + + This function gets or sets the value of the "async" flag of a + <CODE>ANetFile</CODE> structure. If the "async" flag is true, then all the I/O + operations done on the file will be asynchronous. Note that on some + operating systems some functions might not support asynchronous I/O. + */ UInt32 ANetGetSetFileAsync(ANetFile *f, UInt8 *async, UInt8 set); + + /*! + \brief Returns the value of the "busy"flag of an <CODE>ANetFile</CODE>. + \param f The file + \result + \li <CODE>0</CODE>: the file is not busy + \li <CODE>1</CODE>: the file is busy + + This function returns the value of "busy" flag of the file. When the + "busy" flag is 1, the file is current busy doing some IO, because + it's "async" flag is true (see <CODE>ANetGetSetFileAsync()</CODE>) and some IO has + not finished. + \see ANetGetSetFileAsync() + */ UInt8 ANetIsFileBusy(ANetFile *f); + + + /*! + \brief Gets the size of a file pointed by an <CODE>ANetFile</CODE>. + \param f The file + \param size A pointer to an unsigned 32 bit value containing the file size, + in bytes. + + \return + \li <CODE>0</CODE>: no error + \li <CODE>1</CODE>: can't get the file size + \li <CODE>2</CODE>: file does not exist + \li <CODE>3</CODE>: invalid pointer for size + \li <CODE>60</CODE>: file is busy ("busy" flag is true) + + This function returns in the value pointed by size the size, in + bytes, of the file. The file must exists and not be busy to be able + to call this function. This function can be also used to know if a + file exists at some location. + */ UInt32 ANetGetFileSize(ANetFile *f, UInt32 *size); + + /*! + \brief Opens a file pointed by an <CODE>ANetFile</CODE>. + \param f The file to open + + \return + \li <CODE>0</CODE>: no error + \li <CODE>1</CODE>: can't open the file + \li <CODE>60</CODE>: file is busy ("busy" flag is true) + + This function opens the file pointed by <CODE>f</CODE>. While it is not required + to open the file before using any of the following file operations, + it is highly recommended that you open the file if you plan to do + several operations on it. If the file is set to asynchronous mode + (set <CODE>ANetGetSetFileAsync()</CODE>), then the function will immediately + return and will set the "busy" flag to true, until the operation is + done, when the "busy" flag will set to false again. + \see ANetGetSetFileAsync() + */ UInt32 ANetOpenFile(ANetFile *f); + + /*! + \brief Closes a file pointed by an <CODE>ANetFile</CODE>. + \param f The file to close + + \return + \li <CODE>0</CODE>: no error + \li <CODE>1</CODE>: can't close the file + \li <CODE>60</CODE>: file is busy ("busy" flag is true) + + Closes the file pointed by f that was previously opened by + <CODE>ANetOpenFile()</CODE>. If the file is set to asynchronous mode (see + <CODE>ANetGetSetFileAsync()</CODE>), then the function will immediately return and + will set the "async" flag to true until the operation is done, when + the "async" flag will be set to false again. + \see ANetOpenFile() ANetGetSetFileAsync() + */ UInt32 ANetCloseFile(ANetFile *f); + + /*! + \brief Reads data from a file pointed bu an <CODE>ANetFile</CODE>. + \param f The file to read from + \param startPos Starting position of the data to be read. + The first possible position in a file is 0. + \param length The amount of data to read + \param buffer Buffer in which the read data will be put. + \param read Pointer to the amount of bytes read. + + \return + \li <CODE>0</CODE>: No error + \li <CODE>1</CODE>: can't open the file + \li <CODE>2</CODE>: can't close the file after operation + \li <CODE>3</CODE>: can't read from the file + \li <CODE>4</CODE>: file doesn't exist + \li <CODE>5</CODE>: bad value for startPos (<CODE>startPos >= filesize</CODE>) + \li <CODE>6</CODE>: bad value for length (<CODE>startPos + length > filesize</CODE>) + \li <CODE>7</CODE>: buffer invalid or too small + \li <CODE>60</CODE>: file is busy ("busy" flag is true) + + This function reads bytes <CODE>startPos</CODE> to <CODE>endPos - 1</CODE> of the file into the + buffer. The buffer must be big enough to contain the data that was + read. Once the data is read, the value pointed by read will be + changed to the number of bytes read into the buffer. If the value of + read is smaller than <CODE>length</CODE>, then you can safely assume that the file + was fully read. If the <CODE>ANetOpenFile()</CODE> function was not previously + called on the file pointed by <CODE>f</CODE>, then this function will open the + file before the read operation and close the file after the read + operation. Otherwise, this function will not close the file after the + read operation. This function does not support files bigger than + <CODE>2^32</CODE> bytes. If the file is set to asynchronous mode (see + <CODE>ANetGetSetFileAsync()</CODE>), then the function will immediatly return and + will set the "async" flag to true until the operation is done, when + the "async" flag will be set to false again. + */ UInt32 ANetReadFile(ANetFile *f, UInt32 startPos, UInt32 length, ANetMemoryTag buffer, UInt32 *read); + + /*! + \brief Writes at the end of a file pointed by an <CODE>ANetFile</CODE>. + \param f The file + \param buffer the data to write + + \return + \li <CODE>0</CODE>: no error + \li <CODE>1</CODE>: can't open the file + \li <CODE>2</CODE>: can't close the file after operation + \li <CODE>3</CODE>: can't write to file + \li <CODE>4</CODE>: buffer is invalid + \li <CODE>60</CODE>: file is busy ("busy" flag is true) + + This function writes the bytes in buffer at the end of the file. If + the file does not already exist, a new file is created. If you want + to write to a new file, use <CODE>ANetDeleteFile()</CODE> first. If the file is set + to asynchronous mode (see <CODE>ANetGetSetFileAsync()</CODE>), then the function + will immediatly return and will set the "async" flag to true until + the operation is done, when the "async" flag will be set to false + again. + \see ANetDeleteFile() ANetGetSetFileAsync() + */ UInt32 ANetWriteFile(ANetFile *f, ANetMemoryTag buffer); + UInt32 ANetWriteFileAt(ANetFile *f, ANetMemoryTag buffer, UInt32 pos); UInt32 ANetDeleteFile(ANetFile *f); |