1 /*******************************************************************************
5 ** $TOG: cm_delete.c /main/7 1998/04/20 12:48:43 mgreess $
7 ** RESTRICTED CONFIDENTIAL INFORMATION:
9 ** The information in this document is subject to special
10 ** restrictions in a confidential disclosure agreement between
11 ** HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
12 ** document outside HP, IBM, Sun, USL, SCO, or Univel without
13 ** Sun's specific written approval. This document and all copies
14 ** and derivative works thereof must be returned or destroyed at
17 ** Copyright 1993 Sun Microsystems, Inc. All rights reserved.
19 *******************************************************************************/
22 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
23 * (c) Copyright 1993, 1994 International Business Machines Corp. *
24 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
25 * (c) Copyright 1993, 1994 Novell, Inc. *
29 static char sccsid[] = "@(#)cm_delete.c 1.29 95/03/17 Copyr 1993 Sun Microsystems, Inc.";
32 #include <EUSCompat.h>
39 #include <sys/resource.h>
45 #include <Dt/EnvControlP.h>
54 #if !defined(NL_CAT_LOCALE)
55 #define NL_CAT_LOCALE 0
59 static nl_catd DT_catd;
60 static char cm_target[256] = ""; /* target for table (user@host) */
61 static char cm_date[256] = ""; /* appointment date */
62 static char cm_view[16] = "day"; /* view span (day,week,month) */
63 static int cm_today = 0; /* today's date (in epoch time) */
64 static int cm_index = 0; /* index to change/delete */
67 grab(char**argv, /* command line arguments */
68 char *buf, /* buffer for keyed data */
71 if (!argv || !*argv) return(argv);
72 cm_strcpy (buf,*argv++);
73 while(argv && *argv) {
74 if (*(*argv) == stop_key) break;
76 cm_strcat(buf,*argv++);
83 cm_args(int argc, char **argv)
86 while (++argv && *argv) {
90 argv = grab(++argv,cm_target,'-');
93 argv = grab(++argv,cm_date,'-');
96 argv = grab(++argv,cm_view,'-');
99 fprintf(stderr,catgets(DT_catd, 1, 187, "Usage:\n\tdtcm_delete [-c calendar] [-d <mm/dd/yy>] [-v view]\n"));
105 int main(int argc, char **argv)
108 char index[10], *target = NULL, *date = NULL, *view = NULL,
111 CSA_entry_handle *list;
112 CSA_session_handle c_handle;
113 CSA_return_code stat;
114 CSA_calendar_user csa_user;
121 setlocale(LC_ALL, "");
122 _DtEnvControl(DT_ENV_SET); /* set up environment variables */
123 DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
124 cm_tty_load_props(&p);
125 cm_args(argc,argv); /* parse command line */
126 target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();
130 if (cmfns_use_fns(p)) {
131 cmfns_lookup_calendar(target, buf, sizeof(buf));
135 if (cm_strlen(cm_date)) date = cm_date;
136 if (cm_strlen(cm_view)) view = cm_view;
138 uname = cm_target2name(target);
139 loc = cm_target2location(target);
141 csa_user.user_name = target;
142 csa_user.user_type = 0;
143 csa_user.calendar_user_extensions = NULL;
144 csa_user.calendar_address = target;
145 stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
147 if (stat != CSA_SUCCESS) {
148 char *format = strdup(catgets(DT_catd, 1, 188,
149 "\nCould not open calendar %s\n"));
150 fprintf(stderr, format,
151 target ? target : catgets(DT_catd, 1, 189, "UNKNOWN"));
157 version = get_data_version(c_handle);
160 if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date,
161 view, &list, p)) <= 0) {
162 csa_logoff(c_handle, NULL);
167 fprintf(stdout, catgets(DT_catd, 1, 190,
168 "Item to delete (number)? "));
169 fgets(index, 9, stdin);
170 fprintf(stdout,"\n\n");
171 if (*index < '0' || *index > '9') {
175 cm_index = atoi(index);
177 cm_tty_delete(DT_catd, c_handle, version,
179 memset(index, '\0', 10);
184 csa_logoff(c_handle, NULL);