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 ** $XConsortium: cm_admin.c /main/5 1996/07/09 14:48:00 drk $
29 ** RESTRICTED CONFIDENTIAL INFORMATION:
31 ** The information in this document is subject to special
32 ** restrictions in a confidential disclosure agreement between
33 ** HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 ** document outside HP, IBM, Sun, USL, SCO, or Univel without
35 ** Sun's specific written approval. This document and all copies
36 ** and derivative works thereof must be returned or destroyed at
39 ** Copyright 1993 Sun Microsystems, Inc. All rights reserved.
41 *******************************************************************************/
44 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
45 * (c) Copyright 1993, 1994 International Business Machines Corp. *
46 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
47 * (c) Copyright 1993, 1994 Novell, Inc. *
51 static char sccsid[] = "@(#)cm_lookup.c 1.21 94/08/05 Copyr 1993 Sun Microsystems, Inc.";
54 #include <EUSCompat.h>
61 #include <sys/resource.h>
73 #if !defined(NL_CAT_LOCALE)
74 #define NL_CAT_LOCALE 0
77 typedef enum {archive, restore} Admin_mode;
79 static Admin_mode Mode = archive;
80 static char cm_target[MAXPATHLEN];
81 static char cm_start[MAXPATHLEN];
82 static char cm_end[MAXPATHLEN];
83 static char cm_file[MAXPATHLEN];
84 static int Delete = B_FALSE;
85 static FILE *input_stream = stdin;
86 static FILE *output_stream = stdout;
89 static nl_catd DT_catd;
92 grab(char**argv, /* command line arguments */
93 char *buf, /* buffer for keyed data */
96 if (!argv || !*argv) return(argv);
97 cm_strcpy (buf,*argv++);
98 while(argv && *argv) {
99 if (*(*argv) == stop_key) break;
101 cm_strcat(buf,*argv++);
109 fprintf(stderr,catgets(DT_catd, 1, 696, "Usage:\n\tdtcm_admin [ -d ] [ -a action ] [ -c calendar ][ -s <mm/dd/yy> ] [ -e <mm/dd/yy> ] [-f filename]\n"));
113 cm_args(int argc, char **argv)
116 while (++argv && *argv) {
120 if (strcmp(*argv, "archive") == 0)
122 else if (strcmp(*argv, "restore") == 0)
125 fprintf(stderr,catgets(DT_catd, 1, 697, "You have specified an unsupported administration operation \"%s\".\n"), *argv);
131 argv = grab(++argv,cm_target,'-');
134 argv = grab(++argv,cm_start,'-');
137 argv = grab(++argv,cm_end,'-');
140 argv = grab(++argv,cm_file,'-');
154 int main(int argc, char **argv)
157 char *target = NULL, *date = NULL, *view = NULL,
160 CSA_session_handle c_handle;
161 CSA_entry_handle *list;
162 CSA_calendar_user csa_user;
163 CSA_return_code stat;
169 setlocale(LC_ALL, "");
170 DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
171 cm_tty_load_props(&p);
172 cm_args(argc,argv); /* parse command line */
174 target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();
177 if (cmfns_use_fns(p)) {
178 cmfns_lookup_calendar(target, buf, sizeof(buf));
182 uname = cm_target2name(target);
183 loc = cm_target2location(target);
185 /* check to see if the file name parameter makes sense */
188 if (Mode == archive) {
189 if ((output_stream = fopen(cm_file, "w")) == NULL) {
190 fprintf(stderr, catgets(DT_catd, 1, 698, "\nCould not open output file \"%s\"\n"), cm_file);
196 if (Mode == restore) {
197 if ((input_stream = fopen(cm_file, "r")) == NULL) {
198 fprintf(stderr, catgets(DT_catd, 1, 699, "\nCould not open input file \"%s\"\n"), cm_file);
203 csa_user.user_name = target;
204 csa_user.user_type = 0;
205 csa_user.calendar_user_extensions = NULL;
206 csa_user.calendar_address = target;
207 stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
209 if (stat != CSA_SUCCESS) {
210 char *format = XtNewString(catgets(DT_catd, 1, 208,
211 "\nCould not open calendar \"%s\"\n"));
212 fprintf(stderr, format,
213 target ? target : catgets(DT_catd, 1, 209, "UNKNOWN"));
220 csa_logoff(c_handle, NULL);