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_lookup.c /main/8 1998/04/21 10:21:26 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_lookup.c 1.30 95/03/08 Copyr 1993 Sun Microsystems, Inc.";
54 #include <EUSCompat.h>
61 #include <sys/resource.h>
73 #include <Dt/EnvControlP.h>
75 #if !defined(NL_CAT_LOCALE)
76 #define NL_CAT_LOCALE 0
80 static char cm_target[256] = ""; /* target for table (user@host) */
81 static char cm_date[256] = ""; /* appointment date */
82 static char cm_view[16] = ""; /* view span (day,week,month) */
83 static nl_catd DT_catd;
86 grab(char**argv, /* command line arguments */
87 char *buf, /* buffer for keyed data */
90 if (!argv || !*argv) return(argv);
91 cm_strcpy (buf,*argv++);
92 while(argv && *argv) {
93 if (*(*argv) == stop_key) break;
95 cm_strcat(buf,*argv++);
102 cm_args(int argc, char **argv)
105 while (++argv && *argv) {
109 argv = grab(++argv,cm_target,'-');
112 argv = grab(++argv,cm_date,'-');
115 argv = grab(++argv,cm_view,'-');
118 fprintf(stderr,catgets(DT_catd, 1, 207, "Usage:\n\tdtcm_lookup [ -c calendar ][ -d <mm/dd/yy> ] [ -v view ]\n"));
124 int main(int argc, char **argv)
127 char *target = NULL, *date = NULL, *view = NULL,
130 CSA_session_handle c_handle;
131 CSA_entry_handle *list;
132 CSA_return_code stat;
133 CSA_calendar_user csa_user;
140 _DtEnvControl(DT_ENV_SET); /* set up environment variables */
141 setlocale(LC_ALL, "");
142 DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
143 cm_tty_load_props(&p);
144 cm_args(argc,argv); /* parse command line */
146 target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();
149 if (cmfns_use_fns(p)) {
150 cmfns_lookup_calendar(target, buf, sizeof(buf));
154 uname = cm_target2name(target);
155 loc = cm_target2location(target);
157 csa_user.user_name = target;
158 csa_user.user_type = 0;
159 csa_user.calendar_user_extensions = NULL;
160 csa_user.calendar_address = target;
161 stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
163 if (stat != CSA_SUCCESS) {
164 char *format = cm_strdup(catgets(DT_catd, 1, 208,
165 "\nCould not open calendar \"%s\"\n"));
166 fprintf(stderr, format,
167 target ? target : catgets(DT_catd, 1, 209, "UNKNOWN"));
173 version = get_data_version(c_handle);
174 if (cm_strlen(cm_date)) date = cm_date;
175 if (cm_strlen(cm_view)) view = cm_view;
177 if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view,
180 csa_logoff(c_handle, NULL);