Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
c590c647
Commit
c590c647
authored
Oct 04, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
Nov 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Xau files: adapt code to match upstream libXau 1.0.9
parent
5929dfde
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
50 deletions
+55
-50
AuDispose.c
nx-X11/lib/src/AuDispose.c
+4
-6
AuFileName.c
nx-X11/lib/src/AuFileName.c
+32
-16
AuGetBest.c
nx-X11/lib/src/AuGetBest.c
+7
-15
AuRead.c
nx-X11/lib/src/AuRead.c
+12
-13
No files found.
nx-X11/lib/src/AuDispose.c
View file @
c590c647
/*
/*
Copyright 1988, 1998 The Open Group
Copyright 1988, 1998 The Open Group
...
@@ -32,13 +31,12 @@ in this Software without prior written authorization from The Open Group.
...
@@ -32,13 +31,12 @@ in this Software without prior written authorization from The Open Group.
#include <stdlib.h>
#include <stdlib.h>
void
void
XauDisposeAuth
(
auth
)
XauDisposeAuth
(
Xauth
*
auth
)
Xauth
*
auth
;
{
{
if
(
auth
)
{
if
(
auth
)
{
if
(
auth
->
address
)
(
void
)
free
(
auth
->
address
);
free
(
auth
->
address
);
if
(
auth
->
number
)
(
void
)
free
(
auth
->
number
);
free
(
auth
->
number
);
if
(
auth
->
name
)
(
void
)
free
(
auth
->
name
);
free
(
auth
->
name
);
if
(
auth
->
data
)
{
if
(
auth
->
data
)
{
(
void
)
bzero
(
auth
->
data
,
auth
->
data_length
);
(
void
)
bzero
(
auth
->
data
,
auth
->
data_length
);
(
void
)
free
(
auth
->
data
);
(
void
)
free
(
auth
->
data
);
...
...
nx-X11/lib/src/AuFileName.c
View file @
c590c647
/*
/*
Copyright 1988, 1998 The Open Group
Copyright 1988, 1998 The Open Group
...
@@ -30,44 +29,61 @@ in this Software without prior written authorization from The Open Group.
...
@@ -30,44 +29,61 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif
#include <nx-X11/Xauth.h>
#include <nx-X11/Xauth.h>
#include <nx-X11/Xos.h>
#include <nx-X11/Xos.h>
#include <assert.h>
#include <stdlib.h>
#include <stdlib.h>
static
char
*
buf
=
NULL
;
static
void
free_filename_buffer
(
void
)
{
free
(
buf
);
buf
=
NULL
;
}
char
*
char
*
XauFileName
()
XauFileName
(
void
)
{
{
char
*
slashDotXauthority
=
"/.Xauthority"
;
c
onst
c
har
*
slashDotXauthority
=
"/.Xauthority"
;
char
*
name
;
char
*
name
;
static
char
*
buf
;
static
size_t
bsize
;
static
int
bsize
;
static
int
atexit_registered
=
0
;
#ifdef WIN32
#ifdef WIN32
char
dir
[
128
];
char
dir
[
128
];
#endif
#endif
int
size
;
size_t
size
;
if
((
name
=
getenv
(
"XAUTHORITY"
)))
if
((
name
=
getenv
(
"XAUTHORITY"
)))
return
name
;
return
name
;
name
=
getenv
(
"HOME"
);
name
=
getenv
(
"HOME"
);
if
(
!
name
)
{
if
(
!
name
)
{
#ifdef WIN32
#ifdef WIN32
(
void
)
strcpy
(
dir
,
"/users/"
);
if
((
name
=
getenv
(
"USERNAME"
)))
{
if
((
name
=
getenv
(
"USERNAME"
)))
{
(
void
)
strcat
(
dir
,
name
);
snprintf
(
dir
,
sizeof
(
dir
),
"/users/%s"
,
name
);
name
=
dir
;
name
=
dir
;
}
}
if
(
!
name
)
if
(
!
name
)
#endif
#endif
return
0
;
return
NULL
;
}
}
size
=
strlen
(
name
)
+
strlen
(
&
slashDotXauthority
[
1
])
+
2
;
size
=
strlen
(
name
)
+
strlen
(
&
slashDotXauthority
[
1
])
+
2
;
if
(
size
>
bsize
)
{
if
((
size
>
bsize
)
||
(
buf
==
NULL
))
{
if
(
buf
)
free
(
buf
);
free
(
buf
);
buf
=
malloc
((
unsigned
)
size
);
assert
(
size
>
0
);
if
(
!
buf
)
buf
=
malloc
(
size
);
return
0
;
if
(
!
buf
)
{
bsize
=
0
;
return
NULL
;
}
if
(
!
atexit_registered
)
{
atexit
(
free_filename_buffer
);
atexit_registered
=
1
;
}
bsize
=
size
;
bsize
=
size
;
}
}
s
trcpy
(
buf
,
name
);
s
nprintf
(
buf
,
bsize
,
"%s%s"
,
name
,
strcat
(
buf
,
slashDotXauthority
+
(
name
[
1
]
==
'\0'
?
1
:
0
));
slashDotXauthority
+
(
name
[
0
]
==
'/'
&&
name
[
1
]
==
'\0'
?
1
:
0
));
return
buf
;
return
buf
;
}
}
nx-X11/lib/src/AuGetBest.c
View file @
c590c647
/*
/*
Copyright 1988, 1998 The Open Group
Copyright 1988, 1998 The Open Group
...
@@ -34,14 +33,7 @@ in this Software without prior written authorization from The Open Group.
...
@@ -34,14 +33,7 @@ in this Software without prior written authorization from The Open Group.
#include <nx-X11/Xthreads.h>
#include <nx-X11/Xthreads.h>
#endif
#endif
static
int
#define binaryEqual(a, b, len) (memcmp(a, b, len) == 0)
binaryEqual
(
_Xconst
char
*
a
,
_Xconst
char
*
b
,
int
len
)
{
while
(
len
--
)
if
(
*
a
++
!=
*
b
++
)
return
0
;
return
1
;
}
Xauth
*
Xauth
*
XauGetBestAuthByAddr
(
XauGetBestAuthByAddr
(
...
@@ -72,14 +64,14 @@ XauGetBestAuthByAddr (
...
@@ -72,14 +64,14 @@ XauGetBestAuthByAddr (
auth_name
=
XauFileName
();
auth_name
=
XauFileName
();
if
(
!
auth_name
)
if
(
!
auth_name
)
return
0
;
return
NULL
;
if
(
access
(
auth_name
,
R_OK
)
!=
0
)
/* checks REAL id */
if
(
access
(
auth_name
,
R_OK
)
!=
0
)
/* checks REAL id */
return
0
;
return
NULL
;
auth_file
=
fopen
(
auth_name
,
"rb"
);
auth_file
=
fopen
(
auth_name
,
"rb"
);
if
(
!
auth_file
)
if
(
!
auth_file
)
return
0
;
return
NULL
;
best
=
0
;
best
=
NULL
;
best_type
=
types_length
;
best_type
=
types_length
;
for
(;;)
{
for
(;;)
{
entry
=
XauReadAuth
(
auth_file
);
entry
=
XauReadAuth
(
auth_file
);
...
@@ -101,11 +93,11 @@ XauGetBestAuthByAddr (
...
@@ -101,11 +93,11 @@ XauGetBestAuthByAddr (
if
((
family
==
FamilyWild
||
entry
->
family
==
FamilyWild
||
if
((
family
==
FamilyWild
||
entry
->
family
==
FamilyWild
||
(
entry
->
family
==
family
&&
(
entry
->
family
==
family
&&
((
address_length
==
entry
->
address_length
&&
((
address_length
==
entry
->
address_length
&&
binaryEqual
(
entry
->
address
,
address
,
(
int
)
address_length
))
binaryEqual
(
entry
->
address
,
address
,
address_length
))
)))
&&
)))
&&
(
number_length
==
0
||
entry
->
number_length
==
0
||
(
number_length
==
0
||
entry
->
number_length
==
0
||
(
number_length
==
entry
->
number_length
&&
(
number_length
==
entry
->
number_length
&&
binaryEqual
(
entry
->
number
,
number
,
(
int
)
number_length
))))
binaryEqual
(
entry
->
number
,
number
,
number_length
))))
{
{
if
(
best_type
==
0
)
if
(
best_type
==
0
)
{
{
...
...
nx-X11/lib/src/AuRead.c
View file @
c590c647
...
@@ -46,7 +46,7 @@ read_short (unsigned short *shortp, FILE *file)
...
@@ -46,7 +46,7 @@ read_short (unsigned short *shortp, FILE *file)
*/
*/
for
(;;)
{
for
(;;)
{
if
(
fread
((
char
*
)
file_short
,
(
int
)
sizeof
(
file_short
),
1
,
file
)
!=
1
)
{
if
(
fread
((
char
*
)
file_short
,
sizeof
(
file_short
),
1
,
file
)
!=
1
)
{
if
(
errno
==
EINTR
&&
ferror
(
file
))
{
if
(
errno
==
EINTR
&&
ferror
(
file
))
{
perror
(
"Reading from auth file"
);
perror
(
"Reading from auth file"
);
clearerr
(
file
);
clearerr
(
file
);
...
@@ -57,7 +57,7 @@ read_short (unsigned short *shortp, FILE *file)
...
@@ -57,7 +57,7 @@ read_short (unsigned short *shortp, FILE *file)
break
;
break
;
}
}
#else
#else
if
(
fread
((
char
*
)
file_short
,
(
int
)
sizeof
(
file_short
),
1
,
file
)
!=
1
)
if
(
fread
((
char
*
)
file_short
,
sizeof
(
file_short
),
1
,
file
)
!=
1
)
return
0
;
return
0
;
#endif
#endif
*
shortp
=
file_short
[
0
]
*
256
+
file_short
[
1
];
*
shortp
=
file_short
[
0
]
*
256
+
file_short
[
1
];
...
@@ -73,7 +73,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
...
@@ -73,7 +73,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
if
(
read_short
(
&
len
,
file
)
==
0
)
if
(
read_short
(
&
len
,
file
)
==
0
)
return
0
;
return
0
;
if
(
len
==
0
)
{
if
(
len
==
0
)
{
data
=
0
;
data
=
NULL
;
}
else
{
}
else
{
data
=
malloc
((
unsigned
)
len
);
data
=
malloc
((
unsigned
)
len
);
if
(
!
data
)
if
(
!
data
)
...
@@ -81,7 +81,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
...
@@ -81,7 +81,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
#ifdef NX_TRANS_SOCKET
#ifdef NX_TRANS_SOCKET
for
(;;)
for
(;;)
{
{
if
(
fread
(
data
,
(
int
)
sizeof
(
char
),
(
int
)
len
,
file
)
!=
len
)
if
(
fread
(
data
,
sizeof
(
char
),
len
,
file
)
!=
len
)
{
{
if
(
errno
==
EINTR
&&
ferror
(
file
))
if
(
errno
==
EINTR
&&
ferror
(
file
))
{
{
...
@@ -96,7 +96,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
...
@@ -96,7 +96,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
break
;
break
;
}
}
#else
#else
if
(
fread
(
data
,
(
int
)
sizeof
(
char
),
(
int
)
len
,
file
)
!=
len
)
{
if
(
fread
(
data
,
sizeof
(
char
),
len
,
file
)
!=
len
)
{
bzero
(
data
,
len
);
bzero
(
data
,
len
);
free
(
data
);
free
(
data
);
return
0
;
return
0
;
...
@@ -109,30 +109,29 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
...
@@ -109,30 +109,29 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
}
}
Xauth
*
Xauth
*
XauReadAuth
(
auth_file
)
XauReadAuth
(
FILE
*
auth_file
)
FILE
*
auth_file
;
{
{
Xauth
local
;
Xauth
local
;
Xauth
*
ret
;
Xauth
*
ret
;
if
(
read_short
(
&
local
.
family
,
auth_file
)
==
0
)
if
(
read_short
(
&
local
.
family
,
auth_file
)
==
0
)
return
0
;
return
NULL
;
if
(
read_counted_string
(
&
local
.
address_length
,
&
local
.
address
,
auth_file
)
==
0
)
if
(
read_counted_string
(
&
local
.
address_length
,
&
local
.
address
,
auth_file
)
==
0
)
return
0
;
return
NULL
;
if
(
read_counted_string
(
&
local
.
number_length
,
&
local
.
number
,
auth_file
)
==
0
)
{
if
(
read_counted_string
(
&
local
.
number_length
,
&
local
.
number
,
auth_file
)
==
0
)
{
free
(
local
.
address
);
free
(
local
.
address
);
return
0
;
return
NULL
;
}
}
if
(
read_counted_string
(
&
local
.
name_length
,
&
local
.
name
,
auth_file
)
==
0
)
{
if
(
read_counted_string
(
&
local
.
name_length
,
&
local
.
name
,
auth_file
)
==
0
)
{
free
(
local
.
address
);
free
(
local
.
address
);
free
(
local
.
number
);
free
(
local
.
number
);
return
0
;
return
NULL
;
}
}
if
(
read_counted_string
(
&
local
.
data_length
,
&
local
.
data
,
auth_file
)
==
0
)
{
if
(
read_counted_string
(
&
local
.
data_length
,
&
local
.
data
,
auth_file
)
==
0
)
{
free
(
local
.
address
);
free
(
local
.
address
);
free
(
local
.
number
);
free
(
local
.
number
);
free
(
local
.
name
);
free
(
local
.
name
);
return
0
;
return
NULL
;
}
}
ret
=
(
Xauth
*
)
malloc
(
sizeof
(
Xauth
));
ret
=
(
Xauth
*
)
malloc
(
sizeof
(
Xauth
));
if
(
!
ret
)
{
if
(
!
ret
)
{
...
@@ -143,7 +142,7 @@ FILE *auth_file;
...
@@ -143,7 +142,7 @@ FILE *auth_file;
bzero
(
local
.
data
,
local
.
data_length
);
bzero
(
local
.
data
,
local
.
data_length
);
free
(
local
.
data
);
free
(
local
.
data
);
}
}
return
0
;
return
NULL
;
}
}
*
ret
=
local
;
*
ret
=
local
;
return
ret
;
return
ret
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment