Home | History | Annotate | Line # | Download | only in X11
      1 /*
      2 
      3 Copyright 1988, 1998  The Open Group
      4 
      5 Permission to use, copy, modify, distribute, and sell this software and its
      6 documentation for any purpose is hereby granted without fee, provided that
      7 the above copyright notice appear in all copies and that both that
      8 copyright notice and this permission notice appear in supporting
      9 documentation.
     10 
     11 The above copyright notice and this permission notice shall be included in
     12 all copies or substantial portions of the Software.
     13 
     14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     20 
     21 Except as contained in this notice, the name of The Open Group shall not be
     22 used in advertising or otherwise to promote the sale, use or other dealings
     23 in this Software without prior written authorization from The Open Group.
     24 
     25 */
     26 
     27 #ifndef _Xauth_h
     28 #define _Xauth_h
     29 
     30 /* struct xauth is full of implicit padding to properly align the pointers
     31    after the length fields.   We can't clean that up without breaking ABI,
     32    so tell clang not to bother complaining about it. */
     33 #ifdef __clang__
     34 #pragma clang diagnostic push
     35 #pragma clang diagnostic ignored "-Wpadded"
     36 #endif
     37 
     38 typedef struct xauth {
     39     unsigned short   family;
     40     unsigned short   address_length;
     41     char    	    *address;
     42     unsigned short   number_length;
     43     char    	    *number;
     44     unsigned short   name_length;
     45     char    	    *name;
     46     unsigned short   data_length;
     47     char   	    *data;
     48 } Xauth;
     49 
     50 #ifdef __clang__
     51 #pragma clang diagnostic pop
     52 #endif
     53 
     54 #ifndef _XAUTH_STRUCT_ONLY
     55 
     56 # include   <X11/Xfuncproto.h>
     57 # include   <X11/Xfuncs.h>
     58 
     59 # include   <stdio.h>
     60 
     61 # define FamilyLocal (256)	/* not part of X standard (i.e. X.h) */
     62 # define FamilyWild  (65535)
     63 # define FamilyNetname    (254)   /* not part of X standard */
     64 # define FamilyKrb5Principal (253) /* Kerberos 5 principal name */
     65 # define FamilyLocalHost (252)	/* for local non-net authentication */
     66 
     67 
     68 _XFUNCPROTOBEGIN
     69 
     70 #ifndef __has_attribute
     71 # define __has_attribute(x) 0  /* Compatibility with older compilers */
     72 #endif
     73 
     74 #if __has_attribute(access)
     75 # define XAU_ACCESS_ATTRIBUTE(X) __attribute__((access X))
     76 #else
     77 # define XAU_ACCESS_ATTRIBUTE(X)
     78 #endif
     79 
     80 #if __has_attribute(malloc)
     81 # if defined(__clang__) || (defined(__GNUC__) && __GNUC__ < 11)
     82 /* Clang or gcc do not support the optional deallocator argument */
     83 #  define XAU_MALLOC_ATTRIBUTE(X) __attribute__((malloc))
     84 # else
     85 #  define XAU_MALLOC_ATTRIBUTE(X) __attribute__((malloc X))
     86 # endif
     87 #else
     88 # define XAU_MALLOC_ATTRIBUTE(X)
     89 #endif
     90 
     91 char *XauFileName(void);
     92 
     93 void XauDisposeAuth(
     94 Xauth*		/* auth */
     95 );
     96 
     97 XAU_MALLOC_ATTRIBUTE((XauDisposeAuth, 1))
     98 Xauth *XauReadAuth(
     99 FILE*	/* auth_file */
    100 );
    101 
    102 XAU_ACCESS_ATTRIBUTE((read_only, 1)) /* file_name */
    103 int XauLockAuth(
    104 _Xconst char*	/* file_name */,
    105 int		/* retries */,
    106 int		/* timeout */,
    107 long		/* dead */
    108 );
    109 
    110 XAU_ACCESS_ATTRIBUTE((read_only, 1)) /* file_name */
    111 int XauUnlockAuth(
    112 _Xconst char*	/* file_name */
    113 );
    114 
    115 XAU_ACCESS_ATTRIBUTE((read_only, 2)) /* auth */
    116 int XauWriteAuth(
    117 FILE*		/* auth_file */,
    118 Xauth*		/* auth */
    119 );
    120 
    121 XAU_ACCESS_ATTRIBUTE((read_only, 3, 2)) /* address */
    122 XAU_ACCESS_ATTRIBUTE((read_only, 5, 4)) /* number */
    123 XAU_ACCESS_ATTRIBUTE((read_only, 7, 6)) /* name */
    124 Xauth *XauGetAuthByAddr(
    125 #if NeedWidePrototypes
    126 unsigned int	/* family */,
    127 unsigned int	/* address_length */,
    128 #else
    129 unsigned short	/* family */,
    130 unsigned short	/* address_length */,
    131 #endif
    132 _Xconst char*	/* address */,
    133 #if NeedWidePrototypes
    134 unsigned int	/* number_length */,
    135 #else
    136 unsigned short	/* number_length */,
    137 #endif
    138 _Xconst char*	/* number */,
    139 #if NeedWidePrototypes
    140 unsigned int	/* name_length */,
    141 #else
    142 unsigned short	/* name_length */,
    143 #endif
    144 _Xconst char*	/* name */
    145 );
    146 
    147 XAU_ACCESS_ATTRIBUTE((read_only, 3, 2)) /* address */
    148 XAU_ACCESS_ATTRIBUTE((read_only, 5, 4)) /* number */
    149 XAU_ACCESS_ATTRIBUTE((read_only, 7, 6)) /* type_names */
    150 XAU_ACCESS_ATTRIBUTE((read_only, 8, 6)) /* type_lengths */
    151 Xauth *XauGetBestAuthByAddr(
    152 #if NeedWidePrototypes
    153 unsigned int	/* family */,
    154 unsigned int	/* address_length */,
    155 #else
    156 unsigned short	/* family */,
    157 unsigned short	/* address_length */,
    158 #endif
    159 _Xconst char*	/* address */,
    160 #if NeedWidePrototypes
    161 unsigned int	/* number_length */,
    162 #else
    163 unsigned short	/* number_length */,
    164 #endif
    165 _Xconst char*	/* number */,
    166 int		/* types_length */,
    167 char**		/* type_names */,
    168 _Xconst int*	/* type_lengths */
    169 );
    170 
    171 _XFUNCPROTOEND
    172 
    173 /* Return values from XauLockAuth */
    174 
    175 # define LOCK_SUCCESS	0	/* lock succeeded */
    176 # define LOCK_ERROR	1	/* lock unexpectedly failed, check errno */
    177 # define LOCK_TIMEOUT	2	/* lock failed, timeouts expired */
    178 
    179 #endif /* _XAUTH_STRUCT_ONLY */
    180 
    181 #endif /* _Xauth_h */
    182