diff options
Diffstat (limited to 'libXau')
-rw-r--r-- | libXau/AuDispose.c | 97 | ||||
-rw-r--r-- | libXau/AuFileName.c | 147 | ||||
-rw-r--r-- | libXau/AuGetAddr.c | 221 | ||||
-rw-r--r-- | libXau/AuGetBest.c | 343 | ||||
-rw-r--r-- | libXau/AuLock.c | 237 | ||||
-rw-r--r-- | libXau/AuRead.c | 217 | ||||
-rw-r--r-- | libXau/AuUnlock.c | 121 | ||||
-rw-r--r-- | libXau/AuWrite.c | 139 | ||||
-rw-r--r-- | libXau/Autest.c | 150 | ||||
-rw-r--r-- | libXau/include/X11/Xauth.h | 278 | ||||
-rw-r--r-- | libXau/man/Xau.man | 5 |
11 files changed, 960 insertions, 995 deletions
diff --git a/libXau/AuDispose.c b/libXau/AuDispose.c index cb6f85cd6..164fe947d 100644 --- a/libXau/AuDispose.c +++ b/libXau/AuDispose.c @@ -1,50 +1,47 @@ -/* $Xorg: AuDispose.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuDispose.c,v 1.4 2001/07/25 15:04:48 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <stdlib.h> - -void -XauDisposeAuth (Xauth *auth) -{ - if (auth) { - if (auth->address) (void) free (auth->address); - if (auth->number) (void) free (auth->number); - if (auth->name) (void) free (auth->name); - if (auth->data) { - (void) bzero (auth->data, auth->data_length); - (void) free (auth->data); - } - free ((char *) auth); - } - return; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdlib.h>
+
+void
+XauDisposeAuth (Xauth *auth)
+{
+ if (auth) {
+ if (auth->address) (void) free (auth->address);
+ if (auth->number) (void) free (auth->number);
+ if (auth->name) (void) free (auth->name);
+ if (auth->data) {
+ (void) bzero (auth->data, auth->data_length);
+ (void) free (auth->data);
+ }
+ free ((char *) auth);
+ }
+ return;
+}
diff --git a/libXau/AuFileName.c b/libXau/AuFileName.c index b21b048cd..4419070bc 100644 --- a/libXau/AuFileName.c +++ b/libXau/AuFileName.c @@ -1,75 +1,72 @@ -/* $Xorg: AuFileName.c,v 1.5 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuFileName.c,v 3.6 2001/07/25 15:04:48 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <X11/Xos.h> -#include <stdlib.h> - -char * -XauFileName (void) -{ - const char *slashDotXauthority = "/.Xauthority"; - char *name; - static char *buf; - static int bsize; -#ifdef WIN32 - char dir[128]; -#endif - int size; - - if ((name = getenv ("XAUTHORITY"))) - return name; - name = getenv ("HOME"); - if (!name) { -#ifdef WIN32 - (void) strcpy (dir, "/users/"); - if ((name = getenv("USERNAME"))) { - (void) strcat (dir, name); - name = dir; - } - if (!name) -#endif - return NULL; - } - size = strlen (name) + strlen(&slashDotXauthority[1]) + 2; - if (size > bsize) { - if (buf) - free (buf); - buf = malloc ((unsigned) size); - if (!buf) - return NULL; - bsize = size; - } - strcpy (buf, name); - strcat (buf, slashDotXauthority + (name[1] == '\0' ? 1 : 0)); - return buf; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+#include <stdlib.h>
+
+char *
+XauFileName (void)
+{
+ const char *slashDotXauthority = "/.Xauthority";
+ char *name;
+ static char *buf;
+ static int bsize;
+#ifdef WIN32
+ char dir[128];
+#endif
+ int size;
+
+ if ((name = getenv ("XAUTHORITY")))
+ return name;
+ name = getenv ("HOME");
+ if (!name) {
+#ifdef WIN32
+ (void) strcpy (dir, "/users/");
+ if ((name = getenv("USERNAME"))) {
+ (void) strcat (dir, name);
+ name = dir;
+ }
+ if (!name)
+#endif
+ return NULL;
+ }
+ size = strlen (name) + strlen(&slashDotXauthority[1]) + 2;
+ if (size > bsize) {
+ if (buf)
+ free (buf);
+ buf = malloc ((unsigned) size);
+ if (!buf)
+ return NULL;
+ bsize = size;
+ }
+ strcpy (buf, name);
+ strcat (buf, slashDotXauthority + (name[1] == '\0' ? 1 : 0));
+ return buf;
+}
diff --git a/libXau/AuGetAddr.c b/libXau/AuGetAddr.c index 6275531be..f26c58ba4 100644 --- a/libXau/AuGetAddr.c +++ b/libXau/AuGetAddr.c @@ -1,112 +1,109 @@ -/* $Xorg: AuGetAddr.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuGetAddr.c,v 1.5 2001/12/14 19:54:36 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <X11/Xos.h> - -static int -binaryEqual (_Xconst char *a, _Xconst char *b, int len) -{ - while (len--) - if (*a++ != *b++) - return 0; - return 1; -} - -Xauth * -XauGetAuthByAddr ( -#if NeedWidePrototypes -unsigned int family, -unsigned int address_length, -#else -unsigned short family, -unsigned short address_length, -#endif -_Xconst char* address, -#if NeedWidePrototypes -unsigned int number_length, -#else -unsigned short number_length, -#endif -_Xconst char* number, -#if NeedWidePrototypes -unsigned int name_length, -#else -unsigned short name_length, -#endif -_Xconst char* name) -{ - FILE *auth_file; - char *auth_name; - Xauth *entry; - - auth_name = XauFileName (); - if (!auth_name) - return NULL; - if (access (auth_name, R_OK) != 0) /* checks REAL id */ - return NULL; - auth_file = fopen (auth_name, "rb"); - if (!auth_file) - return NULL; - for (;;) { - entry = XauReadAuth (auth_file); - if (!entry) - break; - /* - * Match when: - * either family or entry->family are FamilyWild or - * family and entry->family are the same and - * address and entry->address are the same - * and - * either number or entry->number are empty or - * number and entry->number are the same - * and - * either name or entry->name are empty or - * name and entry->name are the same - */ - - if ((family == FamilyWild || entry->family == FamilyWild || - (entry->family == family && - address_length == entry->address_length && - binaryEqual (entry->address, address, (int)address_length))) && - (number_length == 0 || entry->number_length == 0 || - (number_length == entry->number_length && - binaryEqual (entry->number, number, (int)number_length))) && - (name_length == 0 || entry->name_length == 0 || - (entry->name_length == name_length && - binaryEqual (entry->name, name, (int)name_length)))) - break; - XauDisposeAuth (entry); - } - (void) fclose (auth_file); - return entry; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+
+static int
+binaryEqual (_Xconst char *a, _Xconst char *b, int len)
+{
+ while (len--)
+ if (*a++ != *b++)
+ return 0;
+ return 1;
+}
+
+Xauth *
+XauGetAuthByAddr (
+#if NeedWidePrototypes
+unsigned int family,
+unsigned int address_length,
+#else
+unsigned short family,
+unsigned short address_length,
+#endif
+_Xconst char* address,
+#if NeedWidePrototypes
+unsigned int number_length,
+#else
+unsigned short number_length,
+#endif
+_Xconst char* number,
+#if NeedWidePrototypes
+unsigned int name_length,
+#else
+unsigned short name_length,
+#endif
+_Xconst char* name)
+{
+ FILE *auth_file;
+ char *auth_name;
+ Xauth *entry;
+
+ auth_name = XauFileName ();
+ if (!auth_name)
+ return NULL;
+ if (access (auth_name, R_OK) != 0) /* checks REAL id */
+ return NULL;
+ auth_file = fopen (auth_name, "rb");
+ if (!auth_file)
+ return NULL;
+ for (;;) {
+ entry = XauReadAuth (auth_file);
+ if (!entry)
+ break;
+ /*
+ * Match when:
+ * either family or entry->family are FamilyWild or
+ * family and entry->family are the same and
+ * address and entry->address are the same
+ * and
+ * either number or entry->number are empty or
+ * number and entry->number are the same
+ * and
+ * either name or entry->name are empty or
+ * name and entry->name are the same
+ */
+
+ if ((family == FamilyWild || entry->family == FamilyWild ||
+ (entry->family == family &&
+ address_length == entry->address_length &&
+ binaryEqual (entry->address, address, (int)address_length))) &&
+ (number_length == 0 || entry->number_length == 0 ||
+ (number_length == entry->number_length &&
+ binaryEqual (entry->number, number, (int)number_length))) &&
+ (name_length == 0 || entry->name_length == 0 ||
+ (entry->name_length == name_length &&
+ binaryEqual (entry->name, name, (int)name_length))))
+ break;
+ XauDisposeAuth (entry);
+ }
+ (void) fclose (auth_file);
+ return entry;
+}
diff --git a/libXau/AuGetBest.c b/libXau/AuGetBest.c index ae2b748dc..7d001526f 100644 --- a/libXau/AuGetBest.c +++ b/libXau/AuGetBest.c @@ -1,173 +1,170 @@ -/* $Xorg: AuGetBest.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuGetBest.c,v 1.7 2001/12/14 19:54:36 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <X11/Xos.h> -#ifdef XTHREADS -#include <X11/Xthreads.h> -#endif -#ifdef hpux -#define X_INCLUDE_NETDB_H -#define XOS_USE_NO_LOCKING -#include <X11/Xos_r.h> -#endif - -static int -binaryEqual (_Xconst char *a, _Xconst char *b, int len) -{ - while (len--) - if (*a++ != *b++) - return 0; - return 1; -} - -Xauth * -XauGetBestAuthByAddr ( -#if NeedWidePrototypes - unsigned int family, - unsigned int address_length, -#else - unsigned short family, - unsigned short address_length, -#endif - _Xconst char* address, -#if NeedWidePrototypes - unsigned int number_length, -#else - unsigned short number_length, -#endif - _Xconst char* number, - int types_length, - char** types, - _Xconst int* type_lengths) -{ - FILE *auth_file; - char *auth_name; - Xauth *entry; - Xauth *best; - int best_type; - int type; -#ifdef hpux - char *fully_qual_address; - unsigned short fully_qual_address_length; -#endif - - auth_name = XauFileName (); - if (!auth_name) - return NULL; - if (access (auth_name, R_OK) != 0) /* checks REAL id */ - return NULL; - auth_file = fopen (auth_name, "rb"); - if (!auth_file) - return NULL; - -#ifdef hpux - if (family == FamilyLocal) { -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - struct hostent *hostp; - - /* make sure we try fully-qualified hostname */ - if ((hostp = _XGethostbyname(address,hparams)) != NULL) { - fully_qual_address = hostp->h_name; - fully_qual_address_length = strlen(fully_qual_address); - } - else - { - fully_qual_address = NULL; - fully_qual_address_length = 0; - } - } -#endif /* hpux */ - - best = NULL; - best_type = types_length; - for (;;) { - entry = XauReadAuth (auth_file); - if (!entry) - break; - /* - * Match when: - * either family or entry->family are FamilyWild or - * family and entry->family are the same and - * address and entry->address are the same - * and - * either number or entry->number are empty or - * number and entry->number are the same - * and - * either name or entry->name are empty or - * name and entry->name are the same - */ - - if ((family == FamilyWild || entry->family == FamilyWild || - (entry->family == family && - ((address_length == entry->address_length && - binaryEqual (entry->address, address, (int)address_length)) -#ifdef hpux - || (family == FamilyLocal && - fully_qual_address_length == entry->address_length && - binaryEqual (entry->address, fully_qual_address, - (int) fully_qual_address_length)) -#endif - ))) && - (number_length == 0 || entry->number_length == 0 || - (number_length == entry->number_length && - binaryEqual (entry->number, number, (int)number_length)))) - { - if (best_type == 0) - { - best = entry; - break; - } - for (type = 0; type < best_type; type++) - if (type_lengths[type] == entry->name_length && - !(strncmp (types[type], entry->name, entry->name_length))) - { - break; - } - if (type < best_type) - { - if (best) - XauDisposeAuth (best); - best = entry; - best_type = type; - if (type == 0) - break; - continue; - } - } - XauDisposeAuth (entry); - } - (void) fclose (auth_file); - return best; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#ifdef hpux
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+static int
+binaryEqual (_Xconst char *a, _Xconst char *b, int len)
+{
+ while (len--)
+ if (*a++ != *b++)
+ return 0;
+ return 1;
+}
+
+Xauth *
+XauGetBestAuthByAddr (
+#if NeedWidePrototypes
+ unsigned int family,
+ unsigned int address_length,
+#else
+ unsigned short family,
+ unsigned short address_length,
+#endif
+ _Xconst char* address,
+#if NeedWidePrototypes
+ unsigned int number_length,
+#else
+ unsigned short number_length,
+#endif
+ _Xconst char* number,
+ int types_length,
+ char** types,
+ _Xconst int* type_lengths)
+{
+ FILE *auth_file;
+ char *auth_name;
+ Xauth *entry;
+ Xauth *best;
+ int best_type;
+ int type;
+#ifdef hpux
+ char *fully_qual_address;
+ unsigned short fully_qual_address_length;
+#endif
+
+ auth_name = XauFileName ();
+ if (!auth_name)
+ return NULL;
+ if (access (auth_name, R_OK) != 0) /* checks REAL id */
+ return NULL;
+ auth_file = fopen (auth_name, "rb");
+ if (!auth_file)
+ return NULL;
+
+#ifdef hpux
+ if (family == FamilyLocal) {
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ /* make sure we try fully-qualified hostname */
+ if ((hostp = _XGethostbyname(address,hparams)) != NULL) {
+ fully_qual_address = hostp->h_name;
+ fully_qual_address_length = strlen(fully_qual_address);
+ }
+ else
+ {
+ fully_qual_address = NULL;
+ fully_qual_address_length = 0;
+ }
+ }
+#endif /* hpux */
+
+ best = NULL;
+ best_type = types_length;
+ for (;;) {
+ entry = XauReadAuth (auth_file);
+ if (!entry)
+ break;
+ /*
+ * Match when:
+ * either family or entry->family are FamilyWild or
+ * family and entry->family are the same and
+ * address and entry->address are the same
+ * and
+ * either number or entry->number are empty or
+ * number and entry->number are the same
+ * and
+ * either name or entry->name are empty or
+ * name and entry->name are the same
+ */
+
+ if ((family == FamilyWild || entry->family == FamilyWild ||
+ (entry->family == family &&
+ ((address_length == entry->address_length &&
+ binaryEqual (entry->address, address, (int)address_length))
+#ifdef hpux
+ || (family == FamilyLocal &&
+ fully_qual_address_length == entry->address_length &&
+ binaryEqual (entry->address, fully_qual_address,
+ (int) fully_qual_address_length))
+#endif
+ ))) &&
+ (number_length == 0 || entry->number_length == 0 ||
+ (number_length == entry->number_length &&
+ binaryEqual (entry->number, number, (int)number_length))))
+ {
+ if (best_type == 0)
+ {
+ best = entry;
+ break;
+ }
+ for (type = 0; type < best_type; type++)
+ if (type_lengths[type] == entry->name_length &&
+ !(strncmp (types[type], entry->name, entry->name_length)))
+ {
+ break;
+ }
+ if (type < best_type)
+ {
+ if (best)
+ XauDisposeAuth (best);
+ best = entry;
+ best_type = type;
+ if (type == 0)
+ break;
+ continue;
+ }
+ }
+ XauDisposeAuth (entry);
+ }
+ (void) fclose (auth_file);
+ return best;
+}
diff --git a/libXau/AuLock.c b/libXau/AuLock.c index 69b1fd69a..45d6b71a3 100644 --- a/libXau/AuLock.c +++ b/libXau/AuLock.c @@ -1,120 +1,117 @@ -/* $Xorg: AuLock.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuLock.c,v 3.6 2002/05/31 18:45:43 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <X11/Xos.h> -#include <sys/stat.h> -#include <errno.h> -#include <time.h> -#define Time_t time_t -#ifndef X_NOT_POSIX -#include <unistd.h> -#else -#ifndef WIN32 -extern unsigned sleep (); -#else -#include <X11/Xwindows.h> -#define link rename -#endif -#endif -#ifdef __UNIXOS2__ -#define link rename -#endif - -int -XauLockAuth ( -_Xconst char *file_name, -int retries, -int timeout, -long dead) -{ - char creat_name[1025], link_name[1025]; - struct stat statb; - Time_t now; - int creat_fd = -1; - - if (strlen (file_name) > 1022) - return LOCK_ERROR; - (void) strcpy (creat_name, file_name); - (void) strcat (creat_name, "-c"); - (void) strcpy (link_name, file_name); - (void) strcat (link_name, "-l"); - if (stat (creat_name, &statb) != -1) { - now = time ((Time_t *) 0); - /* - * NFS may cause ctime to be before now, special - * case a 0 deadtime to force lock removal - */ - if (dead == 0 || now - statb.st_ctime > dead) { - (void) unlink (creat_name); - (void) unlink (link_name); - } - } - - while (retries > 0) { - if (creat_fd == -1) { - creat_fd = open (creat_name, O_WRONLY | O_CREAT | O_EXCL, 0600); - if (creat_fd == -1) { - if (errno != EACCES) - return LOCK_ERROR; - } else - (void) close (creat_fd); - } - if (creat_fd != -1) { -#ifndef X_NOT_POSIX - /* The file system may not support hard links, and pathconf should tell us that. */ - if (1 == pathconf(creat_name, _PC_LINK_MAX)) { - if (-1 == rename(creat_name, link_name)) { - /* Is this good enough? Perhaps we should retry. TEST */ - return LOCK_ERROR; - } else { - return LOCK_SUCCESS; - } - } else { -#endif - if (link (creat_name, link_name) != -1) - return LOCK_SUCCESS; - if (errno == ENOENT) { - creat_fd = -1; /* force re-creat next time around */ - continue; - } - if (errno != EEXIST) - return LOCK_ERROR; -#ifndef X_NOT_POSIX - } -#endif - } - (void) sleep ((unsigned) timeout); - --retries; - } - return LOCK_TIMEOUT; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <time.h>
+#define Time_t time_t
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#else
+#ifndef WIN32
+extern unsigned sleep ();
+#else
+#include <X11/Xwindows.h>
+#define link rename
+#endif
+#endif
+#ifdef __UNIXOS2__
+#define link rename
+#endif
+
+int
+XauLockAuth (
+_Xconst char *file_name,
+int retries,
+int timeout,
+long dead)
+{
+ char creat_name[1025], link_name[1025];
+ struct stat statb;
+ Time_t now;
+ int creat_fd = -1;
+
+ if (strlen (file_name) > 1022)
+ return LOCK_ERROR;
+ (void) strcpy (creat_name, file_name);
+ (void) strcat (creat_name, "-c");
+ (void) strcpy (link_name, file_name);
+ (void) strcat (link_name, "-l");
+ if (stat (creat_name, &statb) != -1) {
+ now = time ((Time_t *) 0);
+ /*
+ * NFS may cause ctime to be before now, special
+ * case a 0 deadtime to force lock removal
+ */
+ if (dead == 0 || now - statb.st_ctime > dead) {
+ (void) unlink (creat_name);
+ (void) unlink (link_name);
+ }
+ }
+
+ while (retries > 0) {
+ if (creat_fd == -1) {
+ creat_fd = open (creat_name, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ if (creat_fd == -1) {
+ if (errno != EACCES)
+ return LOCK_ERROR;
+ } else
+ (void) close (creat_fd);
+ }
+ if (creat_fd != -1) {
+#ifndef X_NOT_POSIX
+ /* The file system may not support hard links, and pathconf should tell us that. */
+ if (1 == pathconf(creat_name, _PC_LINK_MAX)) {
+ if (-1 == rename(creat_name, link_name)) {
+ /* Is this good enough? Perhaps we should retry. TEST */
+ return LOCK_ERROR;
+ } else {
+ return LOCK_SUCCESS;
+ }
+ } else {
+#endif
+ if (link (creat_name, link_name) != -1)
+ return LOCK_SUCCESS;
+ if (errno == ENOENT) {
+ creat_fd = -1; /* force re-creat next time around */
+ continue;
+ }
+ if (errno != EEXIST)
+ return LOCK_ERROR;
+#ifndef X_NOT_POSIX
+ }
+#endif
+ }
+ (void) sleep ((unsigned) timeout);
+ --retries;
+ }
+ return LOCK_TIMEOUT;
+}
diff --git a/libXau/AuRead.c b/libXau/AuRead.c index 9979c1dfc..09e454336 100644 --- a/libXau/AuRead.c +++ b/libXau/AuRead.c @@ -1,110 +1,107 @@ -/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <stdlib.h> - -static int -read_short (unsigned short *shortp, FILE *file) -{ - unsigned char file_short[2]; - - if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) - return 0; - *shortp = file_short[0] * 256 + file_short[1]; - return 1; -} - -static int -read_counted_string (unsigned short *countp, char **stringp, FILE *file) -{ - unsigned short len; - char *data; - - if (read_short (&len, file) == 0) - return 0; - if (len == 0) { - data = NULL; - } else { - data = malloc ((unsigned) len); - if (!data) - return 0; - if (fread (data, (int) sizeof (char), (int) len, file) != len) { - bzero (data, len); - free (data); - return 0; - } - } - *stringp = data; - *countp = len; - return 1; -} - -Xauth * -XauReadAuth (FILE *auth_file) -{ - Xauth local; - Xauth *ret; - - if (read_short (&local.family, auth_file) == 0) - return NULL; - if (read_counted_string (&local.address_length, &local.address, auth_file) == 0) - return NULL; - if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) { - if (local.address) free (local.address); - return NULL; - } - if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) { - if (local.address) free (local.address); - if (local.number) free (local.number); - return NULL; - } - if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) { - if (local.address) free (local.address); - if (local.number) free (local.number); - if (local.name) free (local.name); - return NULL; - } - ret = (Xauth *) malloc (sizeof (Xauth)); - if (!ret) { - if (local.address) free (local.address); - if (local.number) free (local.number); - if (local.name) free (local.name); - if (local.data) { - bzero (local.data, local.data_length); - free (local.data); - } - return NULL; - } - *ret = local; - return ret; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdlib.h>
+
+static int
+read_short (unsigned short *shortp, FILE *file)
+{
+ unsigned char file_short[2];
+
+ if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ return 0;
+ *shortp = file_short[0] * 256 + file_short[1];
+ return 1;
+}
+
+static int
+read_counted_string (unsigned short *countp, char **stringp, FILE *file)
+{
+ unsigned short len;
+ char *data;
+
+ if (read_short (&len, file) == 0)
+ return 0;
+ if (len == 0) {
+ data = NULL;
+ } else {
+ data = malloc ((unsigned) len);
+ if (!data)
+ return 0;
+ if (fread (data, (int) sizeof (char), (int) len, file) != len) {
+ bzero (data, len);
+ free (data);
+ return 0;
+ }
+ }
+ *stringp = data;
+ *countp = len;
+ return 1;
+}
+
+Xauth *
+XauReadAuth (FILE *auth_file)
+{
+ Xauth local;
+ Xauth *ret;
+
+ if (read_short (&local.family, auth_file) == 0)
+ return NULL;
+ if (read_counted_string (&local.address_length, &local.address, auth_file) == 0)
+ return NULL;
+ if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) {
+ if (local.address) free (local.address);
+ return NULL;
+ }
+ if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ return NULL;
+ }
+ if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ return NULL;
+ }
+ ret = (Xauth *) malloc (sizeof (Xauth));
+ if (!ret) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ if (local.data) {
+ bzero (local.data, local.data_length);
+ free (local.data);
+ }
+ return NULL;
+ }
+ *ret = local;
+ return ret;
+}
diff --git a/libXau/AuUnlock.c b/libXau/AuUnlock.c index 460effe86..072331e34 100644 --- a/libXau/AuUnlock.c +++ b/libXau/AuUnlock.c @@ -1,62 +1,59 @@ -/* $Xorg: AuUnlock.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuUnlock.c,v 1.4 2001/12/14 19:54:36 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <X11/Xos.h> - -int -XauUnlockAuth ( -_Xconst char *file_name) -{ -#ifndef WIN32 - char creat_name[1025]; -#endif - char link_name[1025]; - - if (strlen (file_name) > 1022) - return 0; -#ifndef WIN32 - (void) strcpy (creat_name, file_name); - (void) strcat (creat_name, "-c"); -#endif - (void) strcpy (link_name, file_name); - (void) strcat (link_name, "-l"); - /* - * I think this is the correct order - */ -#ifndef WIN32 - (void) unlink (creat_name); -#endif - (void) unlink (link_name); - - return 1; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <X11/Xos.h>
+
+int
+XauUnlockAuth (
+_Xconst char *file_name)
+{
+#ifndef WIN32
+ char creat_name[1025];
+#endif
+ char link_name[1025];
+
+ if (strlen (file_name) > 1022)
+ return 0;
+#ifndef WIN32
+ (void) strcpy (creat_name, file_name);
+ (void) strcat (creat_name, "-c");
+#endif
+ (void) strcpy (link_name, file_name);
+ (void) strcat (link_name, "-l");
+ /*
+ * I think this is the correct order
+ */
+#ifndef WIN32
+ (void) unlink (creat_name);
+#endif
+ (void) unlink (link_name);
+
+ return 1;
+}
diff --git a/libXau/AuWrite.c b/libXau/AuWrite.c index 5852759d6..2ad7a07af 100644 --- a/libXau/AuWrite.c +++ b/libXau/AuWrite.c @@ -1,71 +1,68 @@ -/* $Xorg: AuWrite.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xau/AuWrite.c,v 1.3 2001/01/17 19:42:24 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> - -static int -write_short (unsigned short s, FILE *file) -{ - unsigned char file_short[2]; - - file_short[0] = (s & (unsigned)0xff00) >> 8; - file_short[1] = s & 0xff; - if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) - return 0; - return 1; -} - -static int -write_counted_string (unsigned short count, char *string, FILE *file) -{ - if (write_short (count, file) == 0) - return 0; - if (fwrite (string, (int) sizeof (char), (int) count, file) != count) - return 0; - return 1; -} - -int -XauWriteAuth (FILE *auth_file, Xauth *auth) -{ - if (write_short (auth->family, auth_file) == 0) - return 0; - if (write_counted_string (auth->address_length, auth->address, auth_file) == 0) - return 0; - if (write_counted_string (auth->number_length, auth->number, auth_file) == 0) - return 0; - if (write_counted_string (auth->name_length, auth->name, auth_file) == 0) - return 0; - if (write_counted_string (auth->data_length, auth->data, auth_file) == 0) - return 0; - return 1; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+
+static int
+write_short (unsigned short s, FILE *file)
+{
+ unsigned char file_short[2];
+
+ file_short[0] = (s & (unsigned)0xff00) >> 8;
+ file_short[1] = s & 0xff;
+ if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
+ return 0;
+ return 1;
+}
+
+static int
+write_counted_string (unsigned short count, char *string, FILE *file)
+{
+ if (write_short (count, file) == 0)
+ return 0;
+ if (fwrite (string, (int) sizeof (char), (int) count, file) != count)
+ return 0;
+ return 1;
+}
+
+int
+XauWriteAuth (FILE *auth_file, Xauth *auth)
+{
+ if (write_short (auth->family, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->address_length, auth->address, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->number_length, auth->number, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->name_length, auth->name, auth_file) == 0)
+ return 0;
+ if (write_counted_string (auth->data_length, auth->data, auth_file) == 0)
+ return 0;
+ return 1;
+}
diff --git a/libXau/Autest.c b/libXau/Autest.c index 12b8cbf25..966e0d13f 100644 --- a/libXau/Autest.c +++ b/libXau/Autest.c @@ -1,76 +1,74 @@ -/* $Xorg: Autest.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <stdio.h> -#include <stdlib.h> - -int -main (int argc, char **argv) -{ - Xauth test_data; - char *name = "XAU-TEST-1"; - char *data = "Do not begin the test until instructed to do so."; - char *file = NULL; - int state = 0; - FILE *output; - - while (*++argv) { - if (!strcmp (*argv, "-file")) - file = *++argv; - else if (state == 0) { - name = *argv; - ++state; - } else if (state == 1) { - data = *argv; - ++state; - } - } - test_data.family = 0; - test_data.address_length = 0; - test_data.address = ""; - test_data.number_length = 0; - test_data.number = ""; - test_data.name_length = strlen (name); - test_data.name = name; - test_data.data_length = strlen (data); - test_data.data = data; - if (!file) { - output = tmpfile(); - } else { - output = fopen (file, "w"); - } - if (output) { - state = XauWriteAuth (output, &test_data); - fclose (output); - } - return (state = 1) ? 0 : 1; -} +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xauth.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char **argv)
+{
+ Xauth test_data;
+ char *name = "XAU-TEST-1";
+ char *data = "Do not begin the test until instructed to do so.";
+ char *file = NULL;
+ int state = 0;
+ FILE *output;
+
+ while (*++argv) {
+ if (!strcmp (*argv, "-file"))
+ file = *++argv;
+ else if (state == 0) {
+ name = *argv;
+ ++state;
+ } else if (state == 1) {
+ data = *argv;
+ ++state;
+ }
+ }
+ test_data.family = 0;
+ test_data.address_length = 0;
+ test_data.address = "";
+ test_data.number_length = 0;
+ test_data.number = "";
+ test_data.name_length = strlen (name);
+ test_data.name = name;
+ test_data.data_length = strlen (data);
+ test_data.data = data;
+ if (!file) {
+ output = tmpfile();
+ } else {
+ output = fopen (file, "w");
+ }
+ if (output) {
+ state = XauWriteAuth (output, &test_data);
+ fclose (output);
+ }
+ return (state = 1) ? 0 : 1;
+}
diff --git a/libXau/include/X11/Xauth.h b/libXau/include/X11/Xauth.h index ace975d84..ec8375a35 100644 --- a/libXau/include/X11/Xauth.h +++ b/libXau/include/X11/Xauth.h @@ -1,141 +1,137 @@ -/* $Xorg: Xauth.h,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/* $XFree86: xc/lib/Xau/Xauth.h,v 1.5 2001/12/14 19:54:36 dawes Exp $ */ - -#ifndef _Xauth_h -#define _Xauth_h - -typedef struct xauth { - unsigned short family; - unsigned short address_length; - char *address; - unsigned short number_length; - char *number; - unsigned short name_length; - char *name; - unsigned short data_length; - char *data; -} Xauth; - -#ifndef _XAUTH_STRUCT_ONLY - -# include <X11/Xfuncproto.h> -# include <X11/Xfuncs.h> - -# include <stdio.h> - -# define FamilyLocal (256) /* not part of X standard (i.e. X.h) */ -# define FamilyWild (65535) -# define FamilyNetname (254) /* not part of X standard */ -# define FamilyKrb5Principal (253) /* Kerberos 5 principal name */ -# define FamilyLocalHost (252) /* for local non-net authentication */ - - -_XFUNCPROTOBEGIN - -char *XauFileName(void); - -Xauth *XauReadAuth( -FILE* /* auth_file */ -); - -int XauLockAuth( -_Xconst char* /* file_name */, -int /* retries */, -int /* timeout */, -long /* dead */ -); - -int XauUnlockAuth( -_Xconst char* /* file_name */ -); - -int XauWriteAuth( -FILE* /* auth_file */, -Xauth* /* auth */ -); - -Xauth *XauGetAuthByAddr( -#if NeedWidePrototypes -unsigned int /* family */, -unsigned int /* address_length */, -#else -unsigned short /* family */, -unsigned short /* address_length */, -#endif -_Xconst char* /* address */, -#if NeedWidePrototypes -unsigned int /* number_length */, -#else -unsigned short /* number_length */, -#endif -_Xconst char* /* number */, -#if NeedWidePrototypes -unsigned int /* name_length */, -#else -unsigned short /* name_length */, -#endif -_Xconst char* /* name */ -); - -Xauth *XauGetBestAuthByAddr( -#if NeedWidePrototypes -unsigned int /* family */, -unsigned int /* address_length */, -#else -unsigned short /* family */, -unsigned short /* address_length */, -#endif -_Xconst char* /* address */, -#if NeedWidePrototypes -unsigned int /* number_length */, -#else -unsigned short /* number_length */, -#endif -_Xconst char* /* number */, -int /* types_length */, -char** /* type_names */, -_Xconst int* /* type_lengths */ -); - -void XauDisposeAuth( -Xauth* /* auth */ -); - -_XFUNCPROTOEND - -/* Return values from XauLockAuth */ - -# define LOCK_SUCCESS 0 /* lock succeeded */ -# define LOCK_ERROR 1 /* lock unexpectely failed, check errno */ -# define LOCK_TIMEOUT 2 /* lock failed, timeouts expired */ - -#endif /* _XAUTH_STRUCT_ONLY */ - -#endif /* _Xauth_h */ +/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#ifndef _Xauth_h
+#define _Xauth_h
+
+typedef struct xauth {
+ unsigned short family;
+ unsigned short address_length;
+ char *address;
+ unsigned short number_length;
+ char *number;
+ unsigned short name_length;
+ char *name;
+ unsigned short data_length;
+ char *data;
+} Xauth;
+
+#ifndef _XAUTH_STRUCT_ONLY
+
+# include <X11/Xfuncproto.h>
+# include <X11/Xfuncs.h>
+
+# include <stdio.h>
+
+# define FamilyLocal (256) /* not part of X standard (i.e. X.h) */
+# define FamilyWild (65535)
+# define FamilyNetname (254) /* not part of X standard */
+# define FamilyKrb5Principal (253) /* Kerberos 5 principal name */
+# define FamilyLocalHost (252) /* for local non-net authentication */
+
+
+_XFUNCPROTOBEGIN
+
+char *XauFileName(void);
+
+Xauth *XauReadAuth(
+FILE* /* auth_file */
+);
+
+int XauLockAuth(
+_Xconst char* /* file_name */,
+int /* retries */,
+int /* timeout */,
+long /* dead */
+);
+
+int XauUnlockAuth(
+_Xconst char* /* file_name */
+);
+
+int XauWriteAuth(
+FILE* /* auth_file */,
+Xauth* /* auth */
+);
+
+Xauth *XauGetAuthByAddr(
+#if NeedWidePrototypes
+unsigned int /* family */,
+unsigned int /* address_length */,
+#else
+unsigned short /* family */,
+unsigned short /* address_length */,
+#endif
+_Xconst char* /* address */,
+#if NeedWidePrototypes
+unsigned int /* number_length */,
+#else
+unsigned short /* number_length */,
+#endif
+_Xconst char* /* number */,
+#if NeedWidePrototypes
+unsigned int /* name_length */,
+#else
+unsigned short /* name_length */,
+#endif
+_Xconst char* /* name */
+);
+
+Xauth *XauGetBestAuthByAddr(
+#if NeedWidePrototypes
+unsigned int /* family */,
+unsigned int /* address_length */,
+#else
+unsigned short /* family */,
+unsigned short /* address_length */,
+#endif
+_Xconst char* /* address */,
+#if NeedWidePrototypes
+unsigned int /* number_length */,
+#else
+unsigned short /* number_length */,
+#endif
+_Xconst char* /* number */,
+int /* types_length */,
+char** /* type_names */,
+_Xconst int* /* type_lengths */
+);
+
+void XauDisposeAuth(
+Xauth* /* auth */
+);
+
+_XFUNCPROTOEND
+
+/* Return values from XauLockAuth */
+
+# define LOCK_SUCCESS 0 /* lock succeeded */
+# define LOCK_ERROR 1 /* lock unexpectely failed, check errno */
+# define LOCK_TIMEOUT 2 /* lock failed, timeouts expired */
+
+#endif /* _XAUTH_STRUCT_ONLY */
+
+#endif /* _Xauth_h */
diff --git a/libXau/man/Xau.man b/libXau/man/Xau.man index 0688f49ef..12deda077 100644 --- a/libXau/man/Xau.man +++ b/libXau/man/Xau.man @@ -1,6 +1,3 @@ -.\" $Xorg: Xau.man,v 1.3 2000/08/17 19:41:54 cpqbld Exp $
-.\" $XdotOrg$
-.\"
.\" Copyright (c) 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,8 +23,6 @@ .\" dealing in this Software without prior written authorization from the
.\" X Consortium.
.\"
-.\" $XFree86: xc/doc/man/Xau/Xau.man,v 1.2 2001/01/27 18:20:19 dawes Exp $
-.\"
.TH Xau __libmansuffix__ __xorgversion__
.SH NAME
Xau library: XauFileName, XauReadAuth, XauLockAuth, XauUnlockAuth,
|