Chapter 2


Xau Library

X Version 11, Release 6

Copyright 1988, X Consortium.

Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. MIT makes no representations about the suitability for any purpose of the information in this document. This documentation is provided "as is" without express or implied warranty.


2.1 XAU FUNCTIONS


The use the functions defined in this section, you should include the header file < X11/Xauth.h >.

char *XauFileName ()
XauFileName generates the default authorization file name by first checking the XAUTHORITY environment variable if set, else it returns $HOME/.Xauthority. This name is statically allocated and should not be freed.

Xauth *XauReadAuth (auth_file)
FILE *auth_file;
auth_file specifies authorization file

XauReadAuth reads the next entry from auth_file. The entry is not statically allocated and should be freed by calling XauDisposeAuth.

int XauWriteAuth (auth_file, auth)
FILE *auth_file;
Xauth *auth;
auth_file specifies the authorization file
auth specifies the authorization entry

XauWriteAuth writes an authorization entry to auth_file. It returns 1 on success, 0 on failure.

Xauth *XauGetAuthByAddr (family, address_length, address, number_length, number, name_length, name)
unsigned short family;
unsigned short address_length;
char *address;
unsigned short number_length;
char *number;
unsigned short name_length;
char *name;
family specifies the family
address_length specifies the network address length
address specifies the network address
number_length specifies the display number length
number specifies the display number
name_length specifies the authorization name length
name specifies the authorization name

XauGetAuthByAddr searches for an entry which matches the given network address/display number pair. The entry is not statically allocated and should be freed by calling XauDisposeAuth

int XauLockAuth (file_name, retries, timeout, dead)
char *file_name;
int retries;
int timeout;
long dead;
file_name specifies the authorization file name
retries specifies the number of retry times
timeout specifies the time between each attempt
dead specifies the time. The lock file being more than dead second, is removed.

XauLockAuth does the work necessary to synchronously update an authorization file. First it makes to file names, one with "-c" appended to file_name, the other with "-1" appended. If the "-c" file already exists and is more than dead seconds old, XauLockAuth removes it and the associated "-1" file. To prevent possible synchronization troubles with NFS, a dead value of zero forces the files to be removed. XauLockAuth makes retries attempts to create and link the file names, pausing timeout seconds between each attempt. XauLockAuth retums a collection of values depending on the results.

LOCK_ERROR A system error occurred, either a file_name
which is too long, or an unexpected failure from
a system call. errno may prove useful.
LOCK TIMEOUT retries attempts failed
LOCK_SUCCESS The lock succeeded.
int XauUnlockAuth (file_name)
char *file_name;
file_name specifies the authorization file name

XauUnlockAuth undoes the work of XauLockAuth by unlinking both the "-c" and "-1" file names.

XauDisposeAuth (auth)
Xauth *auth;
auth specifies the authorization entry

XauDisposeAuth frees storage allocated to hold an authorization entry.

Home

Contents Previous Chapter Next Chapter