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

flock.h File Reference

Go to the source code of this file.

Defines

#define COPY_IOBUFF_SIZE   4096
 Size, in bytes, of the buffer used by copy_file_with_lock() for I/O operations.

#define LOG_BUFFER_OVERFLOW   -1
 Return value for the function my_logger(). This means that the argument 'buffer' is too small.

#define LOG_WRITE_ERROR   -2
 Return value for the function my_logger(). The function can not write to the file (which name is specified as first argument).

#define LOG_OPEN_ERROR   -3
 Return value for the function my_logger(). The function can not open the file (which name is specified as first argument).

#define LOG_CLOSE_ERROR   -4
 Return value for the function my_logger(). The function can not close the file (which name is specified as first argument).

#define LOG_LOCK_ERROR   -5
 Return value for the function my_logger(). The function can not lock the file (which name is specified as first argument).

#define LOG_OK   -6
 Return value for the function my_logger(). The function succed. Everything is fine.

#define COPY_SRC_OPEN_ERROR   -1
 Return value for the function copy_file_with_lock(). Can not open the source file.

#define COPY_DST_OPEN_ERROR   -2
 Return value for the function copy_file_with_lock(). Can not open the destination file.

#define COPY_LOCK_ERROR   -3
 Return value for the function copy_file_with_lock(). Lock on the destination file failed.

#define COPY_STAT_ERROR   -4
 Return value for the function copy_file_with_lock(). Can not stat() the srouce file.

#define COPY_READ_ERROR   -5
 Return value for the function copy_file_with_lock(). Error while reading the source file.

#define COPY_WRITE_ERROR   -6
 Return value for the function copy_file_with_lock(). Error while writing to the destination file.

#define COPY_UNLOCK_ERROR   -7
 Return value for the function copy_file_with_lock(). Error while unlocking the destinatination file.

#define COPY_SRC_CLOSE_ERROR   -8
 Return value for the function copy_file_with_lock(). Error while closing the source file.

#define COPY_DST_CLOSE_ERROR   -9
 Return value for the function copy_file_with_lock(). Error while closing the destination file.

#define COPY_OK   0
 Return value for the function copy_file_with_lock(). File successfully copied.

#define FLOCK_HD

Functions

int lock_file (int fd)
 Lock a file.

int unlock_file (int fd)
 Unlock a file.

int my_logger (char *file_name, char *buffer, int buffsize, char *format,...)
 Write data into the log file.

int append_file_with_lock (char *src, char *dst)
 Append a file to another - The destination file is locked.


Detailed Description

Header file for flock.c.

Definition in file flock.h.


Function Documentation

int append_file_with_lock char *    src,
char *    dst
 

Append a file to another - The destination file is locked.

Parameters:
src Pointer to a zero terminated string of characters that represents the name of the source file.
dst Pointer to a zero terminated string of characters that represents the name of the destination file.
Returns:
The function returns COPY_OK if the operation succed. Otherwise, the function may return:
  • COPY_SRC_OPEN_ERROR Can not open the source file.
  • COPY_DST_OPEN_ERROR Can not open the destination file.
  • COPY_LOCK_ERROR Lock on the destination file failed.
  • COPY_STAT_ERROR Can not stat() the srouce file.
  • COPY_READ_ERROR Error while reading the source file.
  • COPY_WRITE_ERROR Error while writing to the destination file.
  • COPY_UNLOCK_ERROR Error while unlocking the destinatination file.
  • COPY_SRC_CLOSE_ERROR Error while closing the source file.
  • COPY_DST_CLOSE_ERROR Error while closing the destination file.

Definition at line 253 of file flock.c.

References COPY_DST_CLOSE_ERROR, COPY_DST_OPEN_ERROR, COPY_IOBUFF_SIZE, COPY_LOCK_ERROR, COPY_OK, COPY_READ_ERROR, COPY_SRC_CLOSE_ERROR, COPY_SRC_OPEN_ERROR, COPY_STAT_ERROR, COPY_UNLOCK_ERROR, COPY_WRITE_ERROR, lock_file(), and unlock_file().

int lock_file int    fd
 

Lock a file.

Parameters:
fd File descriptor that identifies the file to lock.
Returns:
If the lock succed, the function returns 0. Otherwise the function returns 1.

Definition at line 15 of file flock.c.

Referenced by append_file_with_lock(), and my_logger().

int my_logger char *    file_name,
char *    buffer,
int    buffsize,
char *    format,
...   
 

Write data into the log file.

Parameters:
file_name Pointer to a NULL terminated string of characters that contains the name of the log file. Please note that if file_name[0] is equal to 0, then the function does nothing. This may be used to manage debug logging.
buffer Pointer to a memory location used by the function to format the data to print.
buffsize Size of the memory location 'buffer' in bytes.
format Pointer to a NULL terminated string of characters that describes the format of the output. 's' means 'char*', 'd' means 'interger' and 'u' means 'unsigned int'.
Returns:
The function return LOG_OK if the operation succed. Otherwise the function returns LOG_BUFFER_OVERFLOW, LOG_WRITE_ERROR, LOG_OPEN_ERROR, LOG_CLOSE_ERROR or LOG_LOCK_ERROR.

Definition at line 105 of file flock.c.

References INT_MAX_CHAR, lock_file(), LOG_BUFFER_OVERFLOW, LOG_CLOSE_ERROR, LOG_LOCK_ERROR, LOG_OK, LOG_OPEN_ERROR, LOG_WRITE_ERROR, and unlock_file().

Referenced by dfree(), and dmalloc().

int unlock_file int    fd
 

Unlock a file.

Parameters:
fd File descriptor that identifies the file to unlock.
Returns:
If the operation succed, the function returns 0. Otherwise the function returns 1.

Definition at line 53 of file flock.c.

Referenced by append_file_with_lock(), and my_logger().


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