File: addshare

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (164 lines) | stat: -rw-r--r-- 3,574 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
!! Add sharing between two classes.
!! Calling parameters: 2 lines.
!! Line 1: initiating class, destination class
!! Line 2: list of resources to share.

as_1=!translate internal , to $ $ in $wims_read_parm
!distribute lines $as_1 into as_1,as_l
!distribute words $as_1 into as_1,as_2
as_l=!words2items $as_l

as_t_exo=src def Exindex Extitles
as_t_sheet=sheets
as_t_exam=exams
as_t_doc=doc
as_t_vote=vote
as_t_cdt=cdt
as_t_livret=livret
as_t_forum=forum
as_t_user=.users .userlist .userlist_external
as_t_motd=.motd
as_t_sup=supervisor
as_t_seq=seq
as_t_userphoto=photoboard
as_t_tool=tool
as_t_freework=freeworks
as_list=doc,exo,sheet,exam,vote,cdt,livret,forum,user,motd,sup,livret,seq,userphoto,tool,freework
!if sharing notwordof $wims_prefix
  wims_prefix=$wims_prefix n sharing sharable
!endif

!if all isitemof $as_l
  as_l=$as_list
!else
  !if exam isitemof $as_l
    as_l=!listunion $as_l and sheet
  !endif
  !if sheet iswordof $as_l
    as_l=!listunion $as_l and exo
  !endif
!endif

L_=
!for t in $as_list
  !if $t isitemof $as_l
    L_=$L_ $(as_t_$t)
  !endif
!next t
!if $L_=$empty
  !exit
!endif
as_n1=!defof n_sup\
n_part in wimshome/log/classes/$as_1/neighbors
as_n2=!defof n_sup\
n_part in wimshome/log/classes/$as_2/neighbors
!distribute lines $as_n1 into as_nsup1,as_npart1
!distribute lines $as_n2 into as_nsup2,as_npart2
as_test=!listcomplement user in $as_l
!if ($as_test!=$empty and \
    ($as_2 notitemof $as_nsup1 or $as_1 notitemof $as_nsup2)) or \
    (user isitemof $as_l and \
    ($as_2 notitemof $as_npart1 or $as_1 notitemof $as_npart2))
  error=addshare_noright
  !exit
!endif

1_=!translate internal / to , in $as_1
2_=!translate internal / to , in $as_2
1=!itemcnt $1_
2=!itemcnt $2_
3=$[min($1,$2)]

!for i=1 to $3+1
  !if $(1_[$i]) != $(2_[$i])
    !break
  !endif
!next i

1_=!item $i to -1 of $1_
!if $i<=$2
  4_=!makelist .. for x=$i to $2
  1_=$4_,$1_
!endif
1_=!nonempty items $1_
1_=!nospace $1_
1_=!translate internal , to / in $1_

!for t in $as_list
  !reset sharing_$t
!next t
!readdef wimshome/log/classes/$as_1/neighbors
!for t in $as_l
  !if $(sharing_$t) != $empty
    error=addshare_conflict
    !exit
  !endif
!next t
!for t in $as_list
  !reset sharable_$t
!next t
!readdef wimshome/log/classes/$as_2/neighbors
as_already=
!for t in $as_l
  !if $(sharable_$t) != $empty
    error=addshare_conflict
    !exit
  !endif
  !if $(sharing_$t) != $empty
    !if $(sharing_$t) = $as_1
      as_already=!append item $t to $as_already
    !else
      error=addshare_conflict
      !exit
    !endif
  !endif
!next t
!if $as_already!=$empty
  as_l=!listcomplement $as_already in $as_l
!endif
!for t in $as_list
  !reset sharable_$t
!next t
!readdef wimshome/log/classes/$as_1/neighbors
as_=
!for t in $as_l,all
  sharable_$t=!listunion $(sharable_$t) and $as_2
  as_=$as_\
sharable_$t=$(sharable_$t)
!next t
!setdef $as_ in wimshome/log/classes/$as_1/neighbors
!for t in $as_list
  !reset sharing_$t
!next t
!readdef wimshome/log/classes/$as_2/neighbors
as_=
!for t in $as_l
  as_=$as_\
sharing_$t=$as_1
!next t
sharing_all=!listunion $sharing_all and $as_1
as_=$as_\
sharing_all=$sharing_all
!setdef $as_ in wimshome/log/classes/$as_2/neighbors

as_copy=
!if sheet isitemof $as_l
  as_copy=$1_/.[0-9]*
!endif
!if exam isitemof $as_l
  as_copy=$as_copy $1_/.E[0-9]*
!endif
!if $as_copy!=$empty
  as_copy=cp -f $as_copy . 2>/dev/null
!endif
!if user isitemof $as_l
  as_touch=touch $1_/.userlist_external
!endif

!sh cd $wims_home/log/classes/$as_2\
 rm -Rf $L_\
 $as_touch\
 for f in $L_; do\
  ln -s $1_/$$f .\
 done\
 $as_copy