Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
0b446180
Commit
0b446180
authored
Dec 16, 1991
by
Per Cederqvist
Browse files
New arguments 'viewer' and 'viewer_p' to is_supervisor() and
access_perm(). Rewrote get_last_text().
parent
a56cd720
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/server/text.c
View file @
0b446180
/*
* $Id: text.c,v 0.1
2
1991/12/16
17:44:1
9 ceder Exp $
* $Id: text.c,v 0.1
3
1991/12/16
23:57:3
9 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
...
...
@@ -28,7 +28,7 @@
* All atomic calls that deals with texts.
*/
static
char
*
rcsid
=
"$Id: text.c,v 0.1
2
1991/12/16
17:44:1
9 ceder Exp $"
;
static
char
*
rcsid
=
"$Id: text.c,v 0.1
3
1991/12/16
23:57:3
9 ceder Exp $"
;
#include
<time.h>
#include
<stdlib.h>
...
...
@@ -288,7 +288,7 @@ submit_to(Conf_no conf_no, /* The conference the user is trying to */
for
(
i
=
0
;
i
<
MAX_SUPER_CONF_LOOP
;
i
++
)
{
acc
=
access_perm
(
conf_no
,
conf_c
);
acc
=
access_perm
(
conf_no
,
conf_c
,
ACTPERS
,
ACT_P
);
if
(
acc
<=
none
)
return
0
;
...
...
@@ -1086,7 +1086,8 @@ text_read_access(Text_no text_no,
cached_get_conf_stat
(
misc
->
datum
.
recipient
))
!=
NULL
)
{
if
(
!
recipient
->
type
.
rd_prot
||
is_supervisor
(
misc
->
datum
.
recipient
,
recipient
))
||
is_supervisor
(
misc
->
datum
.
recipient
,
recipient
,
ACTPERS
,
ACT_P
))
{
return
TRUE
;
}
...
...
@@ -1097,7 +1098,8 @@ text_read_access(Text_no text_no,
cached_get_conf_stat
(
misc
->
datum
.
cc_recipient
))
!=
NULL
)
{
if
(
!
recipient
->
type
.
rd_prot
||
is_supervisor
(
misc
->
datum
.
cc_recipient
,
recipient
))
||
is_supervisor
(
misc
->
datum
.
cc_recipient
,
recipient
,
ACTPERS
,
ACT_P
))
{
return
TRUE
;
}
...
...
@@ -1889,7 +1891,8 @@ delete_text( Text_no text_no )
CHK_LOGIN
(
FAILURE
);
GET_T_STAT
(
text_s
,
text_no
,
FAILURE
);
if
(
!
is_supervisor
(
text_s
->
author
,
NULL
)
&&
!
ENA
(
admin
,
5
)
)
if
(
!
is_supervisor
(
text_s
->
author
,
NULL
,
ACTPERS
,
ACT_P
)
&&
!
ENA
(
admin
,
5
)
)
{
kom_errno
=
(
text_read_access
(
text_no
,
text_s
)
?
KOM_NOT_AUTHOR
:
KOM_NO_SUCH_TEXT
);
...
...
@@ -1902,47 +1905,47 @@ delete_text( Text_no text_no )
/*
* Lookup a text according to creation-time.
* The text-no of the text created closest before TIME is returned.
* The text text-no m
us
t not be readable
* The text text-no m
igh
t not be readable
.
*/
extern
Text_no
get_last_text
(
time_t
time
,
Text_no
*
text
)
extern
Success
get_last_text
(
time_t
time
,
Text_no
*
result
)
{
Text_no
lower
=
0
;
Text_no
higher
=
query_next_text_num
();
Text_no
lower
=
1
;
Text_no
higher
=
query_next_text_num
()
-
1
;
Text_stat
*
text_stat
;
Text_no
try
;
Text_no
middle
;
/*
* We search for the text in the interval [lower, higher]
* (inclusive). Middle is set to the middle (rounded towards
* zero), and we search from there and upward until we find a
* text.
*/
while
(
!
(
lower
+
1
==
higher
)
)
while
(
lower
<
higher
)
{
Text_stat
*
text
;
Text_no
try
=
(
lower
+
higher
)
/
2
;
/* Binary search */
int
step
=
0
;
/* Patch to accept nonexisting texts */
middle
=
(
lower
+
higher
)
/
2
+
1
;
/* Binary search */
try
=
middle
;
text_stat
=
NULL
;
while
(
text_stat
==
NULL
&&
try
<=
higher
);
text_stat
=
cached_get_text_stat
(
try
++
);
do
if
(
text_stat
==
NULL
)
higher
=
middle
-
1
;
else
{
try
+=
step
;
/* back and forth around the middle as long */
/* until we find an existing text. */
step
=
(
step
+
(
step
>
0
?
1
:
-
1
))
*
(
-
1
);
text
=
cached_get_text_stat
(
try
);
}
while
(
text
==
NULL
&&
try
>
lower
&&
try
<
higher
);
if
(
try
<=
lower
||
try
>=
higher
)
break
;
/* We did not find any existing text */
if
(
time
>
text
->
creation_time
)
lower
=
try
;
else
/* The intervall is "halved" */
higher
=
try
;
if
(
time
>
text_stat
->
creation_time
)
lower
=
try
;
else
/* The intervall is "halved" */
higher
=
middle
-
1
;
}
}
if
(
lower
!=
0
)
{
*
text
=
lower
;
return
OK
;
/* We found a text */
}
else
{
kom_errno
=
KOM_NO_SUCH_TEXT
;
/* We did not find a text at all */
return
FAILURE
;
}
*
result
=
lower
;
return
OK
;
}
...
...
@@ -2050,9 +2053,9 @@ sub_recipient( Text_no text_no,
GET_C_STAT
(
conf_c
,
conf_no
,
FAILURE
);
if
(
!
is_supervisor
(
text_s
->
author
,
NULL
)
&&
!
is_supervisor
(
conf_no
,
conf_c
)
&&
!
is_sender
(
text_s
,
conf_no
)
)
if
(
!
is_supervisor
(
text_s
->
author
,
NULL
,
ACTPERS
,
ACT_P
)
&&
!
is_supervisor
(
conf_no
,
conf_c
,
ACTPERS
,
ACT_P
)
&&
!
is_sender
(
text_s
,
conf_no
)
)
{
kom_errno
=
KOM_PERM
;
return
FAILURE
;
...
...
@@ -2141,9 +2144,9 @@ sub_comment( Text_no comment, /* 'comment' is no longer a comment */
}
if
(
!
is_supervisor
(
text_s
->
author
,
NULL
)
&&
!
is_supervisor
(
parent_s
->
author
,
NULL
)
&&
!
is_comm_sender
(
text_s
,
parent
)
)
if
(
!
is_supervisor
(
text_s
->
author
,
NULL
,
ACTPERS
,
ACT_P
)
&&
!
is_supervisor
(
parent_s
->
author
,
NULL
,
ACTPERS
,
ACT_P
)
&&
!
is_comm_sender
(
text_s
,
parent
)
)
{
kom_errno
=
KOM_PERM
;
return
FAILURE
;
...
...
@@ -2266,7 +2269,7 @@ get_map (Conf_no conf_no,
CHK_LOGIN
(
FAILURE
);
GET_C_STAT
(
conf_c
,
conf_no
,
FAILURE
);
acc
=
access_perm
(
conf_no
,
conf_c
);
acc
=
access_perm
(
conf_no
,
conf_c
,
ACTPERS
,
ACT_P
);
if
(
acc
<=
none
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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