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 ** $TOG: cm_delete.c /main/7 1998/04/20 12:48:43 mgreess $
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_delete.c 1.29 95/03/17 Copyr 1993 Sun Microsystems, Inc.";
54 #include <EUSCompat.h>
61 #include <sys/resource.h>
67 #include <Dt/EnvControlP.h>
76 #if !defined(NL_CAT_LOCALE)
77 #define NL_CAT_LOCALE 0
81 static nl_catd DT_catd;
82 static char cm_target[256] = ""; /* target for table (user@host) */
83 static char cm_date[256] = ""; /* appointment date */
84 static char cm_view[16] = "day"; /* view span (day,week,month) */
85 static int cm_today = 0; /* today's date (in epoch time) */
86 static int cm_index = 0; /* index to change/delete */
89 grab(char**argv, /* command line arguments */
90 char *buf, /* buffer for keyed data */
93 if (!argv || !*argv) return(argv);
94 cm_strcpy (buf,*argv++);
95 while(argv && *argv) {
96 if (*(*argv) == stop_key) break;
98 cm_strcat(buf,*argv++);
105 cm_args(int argc, char **argv)
108 while (++argv && *argv) {
112 argv = grab(++argv,cm_target,'-');
115 argv = grab(++argv,cm_date,'-');
118 argv = grab(++argv,cm_view,'-');
121 fprintf(stderr,catgets(DT_catd, 1, 187, "Usage:\n\tdtcm_delete [-c calendar] [-d <mm/dd/yy>] [-v view]\n"));
127 int main(int argc, char **argv)
130 char index[10], *target = NULL, *date = NULL, *view = NULL,
133 CSA_entry_handle *list;
134 CSA_session_handle c_handle;
135 CSA_return_code stat;
136 CSA_calendar_user csa_user;
143 setlocale(LC_ALL, "");
144 _DtEnvControl(DT_ENV_SET); /* set up environment variables */
145 DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
146 cm_tty_load_props(&p);
147 cm_args(argc,argv); /* parse command line */
148 target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();
152 if (cmfns_use_fns(p)) {
153 cmfns_lookup_calendar(target, buf, sizeof(buf));
157 if (cm_strlen(cm_date)) date = cm_date;
158 if (cm_strlen(cm_view)) view = cm_view;
160 uname = cm_target2name(target);
161 loc = cm_target2location(target);
163 csa_user.user_name = target;
164 csa_user.user_type = 0;
165 csa_user.calendar_user_extensions = NULL;
166 csa_user.calendar_address = target;
167 stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
169 if (stat != CSA_SUCCESS) {
170 char *format = strdup(catgets(DT_catd, 1, 188,
171 "\nCould not open calendar %s\n"));
172 fprintf(stderr, format,
173 target ? target : catgets(DT_catd, 1, 189, "UNKNOWN"));
179 version = get_data_version(c_handle);
182 if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date,
183 view, &list, p)) <= 0) {
184 csa_logoff(c_handle, NULL);
189 fprintf(stdout, catgets(DT_catd, 1, 190,
190 "Item to delete (number)? "));
191 fgets(index, 9, stdin);
192 fprintf(stdout,"\n\n");
193 if (*index < '0' || *index > '9') {
197 cm_index = atoi(index);
199 cm_tty_delete(DT_catd, c_handle, version,
201 memset(index, '\0', 10);
206 csa_logoff(c_handle, NULL);