Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

flock.h

Go to the documentation of this file.
00001 /*! \file flock.h
00002     Header file for flock.c.
00003  */
00004 
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008 
00009 #ifndef FLOCK_HD
00010 
00011   #include <stdio.h>
00012   #include <unistd.h>
00013   #include <sys/types.h>
00014   #include <sys/stat.h>
00015   #include <fcntl.h>
00016   #include <string.h>
00017   #include <stdarg.h>
00018 
00019   #ifdef LINUX
00020   #include <sys/file.h>
00021   #endif
00022 
00023   #ifdef SUN
00024 
00025 /*************************************************************************/
00026 /* Note 1:                                                               */
00027 /*                                                                       */
00028 /* In the SunOS header file "sys/varargs.h" you can read that:           */
00029 /*                                                                       */
00030 /* Many compilation systems depend upon the use of special functions     */
00031 /* built into the the compilation system to handle variable argument     */
00032 /* lists and stack allocations.  The method to obtain this in SunOS      */
00033 /* is to define the feature test macro "__BUILTIN_VA_ARG_INCR" which     */
00034 /* enables the following special built-in functions:                     */
00035 /*      __builtin_alloca                                                 */
00036 /*      __builtin_va_alist                                               */
00037 /*      __builtin_va_arg_incr                                            */
00038 /* It is intended that the compilation system define this feature test   */
00039 /* macro, not the user of the system.                                    */
00040 /*                                                                       */
00041 /* ...                                                                   */
00042 /* Do not follow these rules ... I've tried and it does not work.        */
00043 /*                                                                       */
00044 /* Note 2:                                                               */
00045 /*                                                                       */
00046 /* In the SunOS' man page for "va_start()", they tell you to include the */
00047 /* header file "sys/varargs.h". Don't do that because it is wrong. You   */
00048 /* must include "stdarg.h" instead.                                      */
00049 /*************************************************************************/
00050 
00051   #include <fcntl.h>
00052 
00053   #endif
00054 
00055 
00056   /*! \brief Size, in bytes, of the buffer used by copy_file_with_lock() for I/O operations.
00057    */
00058 
00059   #define COPY_IOBUFF_SIZE   4096
00060 
00061   /*! \brief Return value for the function my_logger(). This means that the argument 'buffer' is too small.
00062    */
00063 
00064   #define LOG_BUFFER_OVERFLOW  -1
00065 
00066   /*! \brief Return value for the function my_logger(). The function can not write to the file (which name is specified
00067              as first argument).
00068    */
00069 
00070   #define LOG_WRITE_ERROR      -2
00071 
00072   /*! \brief Return value for the function my_logger(). The function can not open the file (which name is specified
00073              as first argument).
00074    */
00075 
00076   #define LOG_OPEN_ERROR       -3
00077 
00078   /*! \brief Return value for the function my_logger(). The function can not close the file (which name is specified
00079              as first argument).
00080    */
00081 
00082   #define LOG_CLOSE_ERROR      -4
00083 
00084   /*! \brief Return value for the function my_logger(). The function can not lock the file (which name is specified
00085              as first argument).
00086    */
00087 
00088   #define LOG_LOCK_ERROR       -5
00089 
00090   /*! \brief Return value for the function my_logger(). The function succed. Everything is fine.
00091    */
00092 
00093   #define LOG_OK               -6
00094 
00095   /*! \brief Return value for the function copy_file_with_lock(). Can not open the source file.
00096    */
00097 
00098   #define COPY_SRC_OPEN_ERROR  -1
00099 
00100   /*! \brief Return value for the function copy_file_with_lock(). Can not open the destination file.
00101    */
00102 
00103   #define COPY_DST_OPEN_ERROR  -2
00104 
00105   /*! \brief Return value for the function copy_file_with_lock(). Lock on the destination file failed.
00106    */
00107 
00108   #define COPY_LOCK_ERROR      -3
00109 
00110   /*! \brief Return value for the function copy_file_with_lock(). Can not stat() the srouce file.
00111    */
00112 
00113   #define COPY_STAT_ERROR      -4
00114 
00115   /*! \brief Return value for the function copy_file_with_lock(). Error while reading the source file.
00116    */
00117 
00118   #define COPY_READ_ERROR      -5
00119 
00120   /*! \brief Return value for the function copy_file_with_lock(). Error while writing to the destination file.
00121    */
00122 
00123   #define COPY_WRITE_ERROR     -6
00124 
00125   /*! \brief Return value for the function copy_file_with_lock(). Error while unlocking the destinatination file.
00126    */
00127 
00128   #define COPY_UNLOCK_ERROR    -7
00129 
00130   /*! \brief Return value for the function copy_file_with_lock(). Error while closing the source file.
00131    */
00132 
00133   #define COPY_SRC_CLOSE_ERROR -8
00134 
00135   /*! \brief Return value for the function copy_file_with_lock(). Error while closing the destination file.
00136    */
00137 
00138   #define COPY_DST_CLOSE_ERROR -9
00139 
00140   /*! \brief Return value for the function copy_file_with_lock(). File successfully copied.
00141    */
00142 
00143   #define COPY_OK               0
00144 
00145 
00146   int lock_file(int fd);
00147   int unlock_file(int fd);
00148   int my_logger(char *file_name, char *buffer, int buffsize, char *format, ...);
00149   int append_file_with_lock (char *src, char *dst);
00150 
00151 #define FLOCK_HD
00152 #endif
00153 
00154 
00155 #ifdef __cplusplus
00156 }
00157 #endif
00158 

Generated on Thu Apr 3 16:23:43 2003 for Common_C_libraries by doxygen1.3-rc1