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

flock.c File Reference

Go to the source code of this file.

Defines

#define DEBUG_TRACE(x)   fprintf (stderr, x)
#define INT_MAX_CHAR   32
 Maximum number of characters for an integer.


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

This file contains funtions used to lock/unlock files.

Definition in file flock.c.


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.
Examples:
test_copy_lock.c.

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.
Examples:
test_flock.c.

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