aux-items.h 8.61 KB
Newer Older
1
/*
David Byers's avatar
David Byers committed
2
 * $Id: aux-items.h,v 1.2 1997/10/23 12:37:21 byers Exp $
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
 * Copyright (C) 1994, 1995, 1996  Lysator Academic Computer Association.
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 1, or (at your option) 
 * any later version.
 * 
 * LysKOM is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */
/* Requires kom-types.h */


#define AUX_PREDEFINED_MIN      1
#define AUX_PREDEFINED_MAX      9999
#define AUX_CLIENT_SPECIFIC_MIN 10000
#define AUX_CLIENT_SPECIFIC_MAX 19999
#define AUX_EXPERIMENTAL_MIN    20000
#define AUX_EXPERIMENTAL_MAX    29999

#define AUX_IS_ILLEGAL(x) ((x) < 1)
#define AUX_IS_EXPERIMENTAL(x) ((x) >= AUX_EXPERIMENTAL_MIN && (x) <= AUX_EXPERIMENTAL_MAX)
#define AUX_IS_CLIENT_SPECIFIC(x) ((x) >= AUX_CLIENT_SPECIFIC_MIN && (x) <= AUX_CLIENT_SPECIFIC_MAX)
#define AUX_IS_PREDEFINED(x) (((x) >= AUX_PREDEFINED_MIN && (x) <= AUX_PREDEFINED_MAX) || (x) > AUX_EXPERIMENTAL_MAX)


/*
 * Add aux item ITEM to Aux_item_list LIST. COUNTER is the highest aux_no
 * in the list (counter + 1 is the next aux_no
 */

#define ADD_AUX_ITEM(list, item, counter)                               \
{                                                                       \
    (list).items =                                                      \
        srealloc((list).items,                                          \
                 ((list).length + 1) * sizeof(Aux_item));               \
David Byers's avatar
David Byers committed
51
    copy_aux_item(&(list).items[(list).length], &item);                 \
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
    (counter) += 1;                                                     \
    (list).items[(list).length].aux_no = (counter);                     \
    (list).length += 1;                                                 \
}


typedef struct Aux_item_definition_s {
    char                   *name;
    unsigned long           tag;
    Aux_item_flags          clear_flags;
    Aux_item_flags          set_flags;
    Bool                    author_only;
    Bool                    supervisor_only;
    Bool                    one_per_person;
    Bool                    may_not_delete;
    unsigned long           inherit_limit;
    Bool                    texts;
    Bool                    confs;
    Bool                    letterboxes;
    Bool                    system;
    char                   *validate_regexp;
    struct re_pattern_buffer *cached_re_buf;
    struct Aux_item_definition_s *next;
} Aux_item_definition;

extern Aux_item_definition empty_aux_item_definition;

/*
 * Predefined AUX Items
 */

#define AUX_Content_Type        1
#define AUX_Dont_Comment        2
#define AUX_Private_Comment     3
#define AUX_Quick_Reply         4





/* Inerit items from parent to target. counter is a pointer to
 * highest_aux_item or equivalent. target_creator is the creator
 * of the target object (author for texts, person for persons and
 * conference for conferences */

void aux_inherit_items(Aux_item_list *target, Aux_item_list *parent,
                       unsigned long *counter, Pers_no target_creator);



/* Check for permission to add item to some object. def is NULL or the
 * item definition. item_creator is the person creating the item.
 * object_creator is the person who created the object we're adding
 * the item to. owner_check is FALSE only if we don't want to check
 * author and supervisor related definition flags (when creating a
 * person or conference, for example.) add_to_list is the list of
 * items already on the object or NULL, and start_looking_at is the
 * first position in add_to_list that we should look at.
 *
 * If you think you need to call this, and you're not hacking functions
 * in aux-items.c, you should rethink your strategy. */

Bool aux_item_add_perm(Aux_item *item, Aux_item_definition *def,
                       Pers_no item_creator, Pers_no object_creator,
                       Bool owner_check, Aux_item_list *add_to_list,
                       unsigned long start_looking_at);




/* Prepare the items in list for addition to an object. creator is the
 * person who will add the items. The items in list will be modified.
 * You need to call this before sending the list to any of the other
 * functions. */

void prepare_aux_item_list(Aux_item_list *list, Pers_no creator);
void prepare_aux_item(Aux_item *item, Pers_no creator,
                      Aux_item_definition *def);



/* Find the aux_item_definition for item. Returns a pointer to the
 * definition or NULL if the item's tag is invalid. */

Aux_item_definition *find_aux_item_definition(Aux_item *item);


/* Get a pointer to the item in list with aux-no aux_no. Returns
 * NULL if there is no such item */

Aux_item *find_aux_item(Aux_item_list *list, unsigned long aux_no);



/* Filter the items in original for sending to viewer. Result is a
 * pointer to an empty aux_item_list, in which copies of the items in
 * original will be places. All memory allocated in this call is
 * allocaed with tmp_alloc */

void filter_aux_item_list(Aux_item_list *original,
                          Aux_item_list *result,
                          Pers_no viewer,
                          Person *viewer_p);


/* delete items_to_delete from list_to_delete_from
 * list_to_delete_from and its elements may be modified */

void delete_aux_item_list(Number_list *items_to_delete,
                          Aux_item_list *list_to_delete_from);



/* undelete items in items_to_undelete from list_to_undelete_from
 * list_to_delete_from and its elements may be modified */

void undelete_aux_item_list(Number_list *items_to_undelete,
                            Aux_item_list *list_to_undelete_from);



/* Check if we may delete items_to_delete from list_to_delete_from
 * Elements in items_to_delete may be modified. Sets kom_errno,
 * err_stat and returns FAILURE if deletion of any single item is
 * not allowed */

Success check_delete_aux_item_list(Number_list *items_to_delete,
                                   Aux_item_list *list_to_delete_from);



/* Att item_list to the aux_item_list of text_s. item_creator is the
 * person who is adding the items. Does not check for permission first */
  
void text_stat_add_aux_item_list(Text_stat *text_s, Aux_item_list *item_list,
                                 Pers_no item_creator);



/* Check for permission to add items in list to aux_item_list
 * of text_s. item_creator is the person adding the items. Sets
 * kom_errno and err_stat and returns FAILURE if permission is
 * not granted. You MUST call perpare_aux_item_list on the list
 * before calling this! */

Success text_stat_check_add_aux_item_list(Text_stat *text_s,
                                          Aux_item_list *list,
                                          Pers_no item_creator);



Success conf_stat_check_add_aux_item(Conference          *conf,
                                     Conf_no        conf_no,
                                     Aux_item            *item,
                                     Pers_no              creator,
                                     Aux_item_definition *def);

Success
conf_stat_check_add_aux_item_list(Conference    *conf,
                                  Conf_no        conf_no,
                                  Aux_item_list *list,
                                  Pers_no        creator);
void
conf_stat_add_aux_item(Conference          *conf,
                       Conf_no              conf_no,
                       Aux_item            *item,
                       Aux_item_definition *def);
void
conf_stat_add_aux_item_list(Conference    *conf,
                            Conf_no        conf_no,
                            Aux_item_list *list,
                            Pers_no        creator);
void
system_add_aux_item_list(Info    *info,
                         Aux_item_list *item_list,
                         Pers_no        item_creator);

Success system_check_add_aux_item_list(Info *info,
                                       Aux_item_list *list,
                                       Pers_no creator);

void
initialize_aux_items(char *);

void
aux_item_definition_add(Aux_item_definition *);