libold

Section: C Library Functions (3)
Updated: 2003-12-23
Index Return to Main Contents
 

NAME

libold - A library to interface with old, the Open Lock Daemon

 

SYNOPSIS

#include <old.h>

#define OLD_PORT

int old_connect( char *host, int port);

int old_lock( int fd, char *s);

int old_unlock( int fd, char *s);

int old_trylock( int fd, char *s);

 

DESCRIPTION

The libold library is an interface to old, the Open Lock Daemon, which is described in old(1).

It provides an abstract, high level interface to the normal locking operations so that any application can use the server without having to worry about the underlying layer.  

FUNCTIONS

The functions provided are quite simple and well-known, they refer to the normal operations that are performed on locks, and, except for old_connect(), all have the same prototype: they receive a file descriptor (fd) which identifies a connection with the lock server opened with old_connect() (which is described below), and a string that identifies the resource to operate on.

old_connect() is special because it must be called before any other, and is used to establish the network connection with the lock server. It accepts two parameters: the first one is a string identifying the host to connect, which can be an IP address or the name of the host which will be resolved; and the second one is the port to connect to, it should be the same one the server is expecting connections. When possible, use the default defined in OLD_PORT.

old_lock() is used to lock the given resource, and it will block until the lock is granted. It returns 1 on success, and -1 if there was a fail in delivering the command to the server.

old_unlock() releases the lock on the given resource. It returns 1 on success, 0 on failure (for example if the object wasn't locked in the first place), and -1 if there was a failure in delivering the command to the server.

old_trylock() attempts to lock the resource, but does not block. It returns 1 if the object was locked, 0 if not (because it was locked and it would block), and -1 if there was a failure in delivering the command to the server.  

SEE ALSO

old(1)  

AUTHOR

old was written by Alberto Bertogli (albertogli@telpin.com.ar). The website is at http://users.auriga.wearlab.de/~alb/old/


 

Index

NAME
SYNOPSIS
DESCRIPTION
FUNCTIONS
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 18:53:59 GMT, December 23, 2003