2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*******************************************************************************
27 ** static char sccsid[] = "@(#)util.h 1.38 94/12/20 Copyr 1991 Sun Microsystems, Inc.";
29 ** $XConsortium: util.h /main/5 1995/11/03 10:39:22 rswiston $
31 ** RESTRICTED CONFIDENTIAL INFORMATION:
33 ** The information in this document is subject to special
34 ** restrictions in a confidential disclosure agreement between
35 ** HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
36 ** document outside HP, IBM, Sun, USL, SCO, or Univel without
37 ** Sun's specific written approval. This document and all copies
38 ** and derivative works thereof must be returned or destroyed at
41 ** Copyright 1993 Sun Microsystems, Inc. All rights reserved.
43 *******************************************************************************/
46 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
47 * (c) Copyright 1993, 1994 International Business Machines Corp. *
48 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
49 * (c) Copyright 1993, 1994 Novell, Inc. *
55 #include <sys/types.h>
63 #define DATAVER1 1 /* RPC versions 1 & 2 */
64 #define DATAVER2 2 /* RPC version 3 */
65 #define DATAVER3 3 /* RPC version 4 and RPC version 5 with
67 #define DATAVER4 4 /* RPC version 5 with new data store */
68 #define DATAVER_ARCHIVE -1 /* archive version. Nothing is read_only */
76 #define DOTS(a) (a[0]=='.' && (a[1]==0 || (a[1]=='.' && a[2]==0)))
78 typedef struct lines {
83 typedef enum {appt_read, appt_write} Allocation_reason;
86 ** Structure for list of properties
88 typedef struct Pentry {
108 * This convenience structure is used by the utility functions to set pointers
109 * to the actual data array so hard coding indexes into the array elsewhere
110 * in the front end isn't necessary.
114 * Read-only attributes
116 CSA_attribute *identifier;
117 CSA_attribute *modified_time;
118 CSA_attribute *author;
119 CSA_attribute *number_recurrence;
122 * Read-write attributes
126 CSA_attribute *subtype;
127 CSA_attribute *private;
128 CSA_attribute *end_time;
129 CSA_attribute *show_time;
131 CSA_attribute *state;
132 CSA_attribute *repeat_type;
133 CSA_attribute *repeat_times;
134 CSA_attribute *repeat_interval;
135 CSA_attribute *repeat_week_num;
136 CSA_attribute *recurrence_rule;
138 CSA_attribute *flash;
140 CSA_attribute *popup;
141 CSA_attribute *sequence_end_date;
144 * The actual name array and count
147 CSA_attribute_reference *names;
151 * The actual data array and count
153 CSA_attribute *attrs;
156 /* Whether the structure has been filled in with a query */
159 Allocation_reason reason;
161 /* the version of the back end this appointment structure
168 * This convenience structure is used by the entry_to_cal, attrs_to_cal, and
169 * cal_to_attrs utility functions
173 * Read-only attributes
175 CSA_attribute *cal_name;
176 CSA_attribute *server_version;
177 CSA_attribute *num_entries;
178 CSA_attribute *cal_size;
181 * Read-write attributes
183 CSA_attribute *access_list;
184 CSA_attribute *time_zone;
187 * The actual name array and count
190 CSA_attribute_reference *names;
194 * The actual data array and count
196 CSA_attribute *attrs;
199 /* Whether the structure has been filled in with a query */
202 Allocation_reason reason;
204 /* the version of the back end this calendar structure
211 * Utility functions to to provide pointers into the arrays passed back and
212 * forth to the backend. These functions and structures make hard coding
213 * indexes into the arrays unnecessary.
215 extern Dtcm_appointment *allocate_appt_struct P((Allocation_reason , int, ...));
216 extern CSA_return_code query_appt_struct P((CSA_session_handle,
218 Dtcm_appointment *));
219 extern Dtcm_calendar *allocate_cal_struct P((Allocation_reason, int, ...));
220 extern CSA_return_code query_cal_struct P((CSA_session_handle,
222 extern void free_appt_struct P((Dtcm_appointment**));
223 extern void free_cal_struct P((Dtcm_calendar**));
225 extern boolean_t cal_ident_index_ro P((int, int));
226 extern boolean_t entry_ident_index_ro P((int, int));
227 extern CSA_enum cal_ident_index_tag P((int));
228 extern CSA_enum entry_ident_index_tag P((int));
229 extern boolean_t ident_name_ro P((char*, int));
230 extern void initialize_cal_attr P((int, CSA_attribute*,
231 Allocation_reason, int));
232 extern void initialize_entry_attr P((int, CSA_attribute*,
233 Allocation_reason, int));
234 extern void set_appt_links P((Dtcm_appointment*));
235 extern void set_cal_links P((Dtcm_calendar*));
236 extern void scrub_cal_attr_list P((Dtcm_calendar*));
237 extern void setup_range P((CSA_attribute**,
238 CSA_enum**, int*, time_t,
239 time_t, CSA_sint32, CSA_sint32,
241 extern void free_range P((CSA_attribute**,
245 * Other utilty functions
247 extern int blank_buf P((char*));
248 extern int embedded_blank P((char*));
249 extern char *ckalloc P(());
250 extern char *cm_def_printer P(());
251 extern char *cm_get_credentials P(());
252 extern char *cm_get_local_domain P(());
253 extern char *cm_get_local_host P(());
254 extern char *cm_get_uname P(());
255 extern char *cm_pqtarget P((char*));
256 extern char *cm_strcat P((char*, char*));
257 extern char *cm_strcpy P((char*, char*));
258 extern char *cm_strdup P((char*));
259 extern int cm_strlen P((char*));
260 extern char *cm_target2domain P((char*));
261 extern char *cm_target2host P((char*));
262 extern char *cm_target2location P((char*));
263 extern char *cm_target2name P((char*));
264 extern char *cr_to_str P((char*));
265 extern void destroy_lines P((Lines*));
266 extern void expand_esc_chars P((char*));
267 extern char *get_head P((char*, char));
268 extern char *get_tail P((char*, char));
269 extern void print_tick P((time_t));
270 extern boolean_t same_path P((char*, char*));
271 extern boolean_t same_user P((char*, char*));
272 extern char *str_to_cr P((char*));
273 extern char *strncat P(());
274 extern char *substr P((char*, int, int n));
275 extern void syserr P((char*, int, int, int));
276 extern Lines *text_to_lines P((char*, int));
277 extern int get_data_version P((CSA_session_handle));
278 extern int get_server_version P((CSA_session_handle));
279 extern CSA_sint32 privacy_set P((Dtcm_appointment *));
280 extern CSA_sint32 showtime_set P((Dtcm_appointment *));
281 extern int max P((int, int));
282 extern int min P((int, int));
283 extern int parse_date P((OrderingType, SeparatorType, char*, char*, char*, char*));
285 extern int datestr2mdy P((char*, OrderingType, SeparatorType, char*));
286 extern void format_tick P((time_t, OrderingType, SeparatorType, char*));
287 extern void format_time P((Tick, DisplayType, char*));
290 * In Motif you can't associate user data with items in a list. To get around
291 * this we have the following simple functions that maintain a list of
292 * user data. We use the intrinscs coding style to reinforce the
293 * relationship these routines have to the XmList* functions.
295 typedef struct _CmDataItem {
296 struct _CmDataItem *next;
300 typedef struct _CmDataList {
306 extern CmDataList *CmDataListCreate P((void));
307 extern void CmDataListDestroy P((CmDataList *, int));
308 extern int CmDataListAdd P((CmDataList *, void *, int));
309 extern void *CmDataListGetData P((CmDataList *, int));
310 extern void *CmDataListDeletePos P((CmDataList *, int, int));
311 extern void CmDataListDeleteAll P((CmDataList *, int));