Exemple #1
0
int main(int argc, char **argv)
{
	int		cnt;
	char		index[10], *target = NULL, *date = NULL, *view = NULL,
			*uname, *loc;
	Props		*p = NULL;
	CSA_entry_handle	*list;
	CSA_session_handle	c_handle;
	CSA_return_code		stat;
	CSA_calendar_user	csa_user;
	int			version;
#ifdef FNS
	char		buf[256];
#endif

	init_time();
	setlocale(LC_ALL, "");
	_DtEnvControl(DT_ENV_SET); /* set up environment variables */
	DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
	cm_tty_load_props(&p);
	cm_args(argc,argv);		/* parse command line */
	target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();

#ifdef FNS
	dtfns_init();
	if (cmfns_use_fns(p)) {
		cmfns_lookup_calendar(target, buf, sizeof(buf));
		target = buf;
	}
#endif
	if (cm_strlen(cm_date)) date = cm_date;
	if (cm_strlen(cm_view)) view = cm_view;

	uname = cm_target2name(target);
	loc = cm_target2location(target);

	csa_user.user_name = target;
	csa_user.user_type = 0;
	csa_user.calendar_user_extensions = NULL;
	csa_user.calendar_address = target;
	stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);

	if (stat != CSA_SUCCESS) {
	  	char *format = strdup(catgets(DT_catd, 1, 188,
					   "\nCould not open calendar %s\n"));
		fprintf(stderr, format,
			target ? target : catgets(DT_catd, 1, 189, "UNKNOWN"));
		free(format);
		free(uname);
		free(loc);
		exit(1);
	}
	version = get_data_version(c_handle);

	while (!cm_index) {
		if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, 
					view, &list, p)) <= 0) {
			csa_logoff(c_handle, NULL);
			free(uname);
			free(loc);
			exit(0);
		}
		fprintf(stdout, catgets(DT_catd, 1, 190,
				       "Item to delete (number)? "));
		fgets(index, 9, stdin);
		fprintf(stdout,"\n\n");
		if (*index < '0' || *index > '9') {
			csa_free(list);
			break;
		}
		cm_index = atoi(index);
		if (cnt >= cm_index)
			cm_tty_delete(DT_catd, c_handle, version, 
				      cm_index - 1, list);
		memset(index, '\0', 10);
		csa_free(list);
		cm_index = 0;
	}

	csa_logoff(c_handle, NULL);
	props_clean_up(p);
	free(p);
	free(uname);
	free(loc);
	return 0;
}
Exemple #2
0
void
main(int argc, char **argv)
{
	int		cnt, status = 0;
	char		*date = NULL, *view = NULL, *target = NULL,
			*start = NULL, *end = NULL, *repeat = NULL,
			*numrepeat = NULL, *what = NULL, *uname, *loc;
	Props		*p = NULL;
	CSA_entry_handle	*list;
	CSA_session_handle	c_handle;
	CSA_return_code		stat;
	CSA_calendar_user	csa_user;
	DisplayType		dt;
	int			version;
	char			date_str[256];
#ifdef FNS
	char		buf[256];
#endif

	init_time();
        _DtEnvControl(DT_ENV_SET); /* set up environment variables */
	setlocale(LC_ALL, "");
	DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
	cm_tty_load_props(&p);
	dt = get_int_prop(p, CP_DEFAULTDISP);
#ifdef FNS
	dtfns_init();
#endif

	if (argc > 1)
	{
		cm_args(argc,argv);		/* parse command line */
		if (cm_strlen(cm_target)) 
			target = cm_target;
		else
			target = cm_get_credentials();
#ifdef FNS
		if (cmfns_use_fns(p)) {
			cmfns_lookup_calendar(target, buf, sizeof(buf));
			target = buf;
		}
#endif
		uname = cm_target2name(target);
		loc = cm_target2location(target);

		csa_user.user_name = target;
		csa_user.user_type = 0;
		csa_user.calendar_user_extensions = NULL;
		csa_user.calendar_address = target;
		stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
		if (stat != CSA_SUCCESS) {
		  	char *format = cm_strdup(catgets(DT_catd, 1, 206, 
					   "\nCould not open calendar %s\n"));
			fprintf(stderr, format,
				target ? target : 
				catgets(DT_catd, 1, 209, "UNKNOWN"));
			free(format);
			free(uname);
			free(loc);
			exit(1);
		}
		version = get_data_version(c_handle);
		if (!cm_date[0])
        		format_tick(now(), get_int_prop(p, CP_DATEORDERING),
		    		    get_int_prop(p, CP_DATESEPARATOR), cm_date);
		if (cm_strlen(cm_date)) date = cm_date;
		if (cm_strlen(cm_view)) view = cm_view;
		if (cm_strlen(cm_start)) start = cm_start;

		if (!cm_end[0] && cm_start[0]) {
			format_time((int)cm_getdate(cm_start, NULL) + hrsec,
				    dt, cm_end);
		}

		if (cm_strlen(cm_end)) end = cm_end;
		if (cm_strlen(cm_repeatstr)) repeat = cm_repeatstr;
		if (cm_strlen(cm_for)) numrepeat = cm_for;
		if (cm_strlen(cm_what)) what = cm_what;
		if (!cm_appt_file[0])
			status = cm_tty_insert(DT_catd, c_handle, version, 
				      date, start, end, repeat, numrepeat,
				      what, NULL, p);
		else
			status = cm_tty_insert(DT_catd, c_handle, version, date,
				      start, end, repeat, numrepeat,
				      what, cm_appt_file, p);
	} else {
		prompt_for_insert(p);
		if (cm_strlen(cm_target)) target = cm_target;
		uname = cm_target2name(target);
		loc = cm_target2location(target);

		csa_user.user_name = target;
		csa_user.user_type = 0;
		csa_user.calendar_user_extensions = NULL;
		csa_user.calendar_address = target;
		stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);
		if (stat !=CSA_SUCCESS) {
		  	char *format = cm_strdup(catgets(DT_catd, 1, 206, 
					   "\nCould not open calendar %s\n"));
			fprintf(stderr, format, 
				target ? target : 
				catgets(DT_catd, 1, 209, "UNKNOWN"));
			free(format);
			free(uname);
			free(loc);
			exit(1);
		}
		version = get_data_version(c_handle);
		if (cm_strlen(cm_date)) date = cm_date;
		if (cm_strlen(cm_view)) view = cm_view;
		if (cm_strlen(cm_start)) start = cm_start;
		if (cm_strlen(cm_end)) end = cm_end;
		if (cm_strlen(cm_repeatstr)) repeat = cm_repeatstr;
		if (cm_strlen(cm_for)) numrepeat = cm_for;
		if (cm_strlen(cm_what)) what = cm_what;
		status = cm_tty_insert(DT_catd, c_handle, version, date, 
			      start, end, repeat, numrepeat, what, NULL, p);
	}
	if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, 
					&list, p)) > 0)
		csa_free(list);
	csa_logoff(c_handle, NULL);
	props_clean_up(p);
	free(p);
	free(uname);
	free(loc);
        exit(status);
}
Exemple #3
0
int main(int argc, char **argv)
{
	int		cnt;
	char		*target = NULL, *date = NULL, *view = NULL,
			*uname, *loc;
	Props		*p = NULL;
	CSA_session_handle	c_handle;
	CSA_entry_handle	*list;
	CSA_return_code		stat;
	CSA_calendar_user	csa_user;
	int			version;
#ifdef FNS
	char		buf[256];
#endif

	init_time();
	_DtEnvControl(DT_ENV_SET); /* set up environment variables */
	setlocale(LC_ALL, "");
	DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE);
	cm_tty_load_props(&p);
	cm_args(argc,argv);		/* parse command line */

	target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials();
#ifdef FNS
	dtfns_init();
	if (cmfns_use_fns(p)) {
		cmfns_lookup_calendar(target, buf, sizeof(buf));
		target = buf;
	}
#endif
	uname = cm_target2name(target);
	loc = cm_target2location(target);

	csa_user.user_name = target;
	csa_user.user_type = 0;
	csa_user.calendar_user_extensions = NULL;
	csa_user.calendar_address = target;
	stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL);

	if (stat != CSA_SUCCESS) {
		char *format = cm_strdup(catgets(DT_catd, 1, 208, 
				   "\nCould not open calendar \"%s\"\n"));
		fprintf(stderr, format, 
			target ? target : catgets(DT_catd, 1, 209, "UNKNOWN"));
		free(format);
		free(uname);
		free(loc);
		exit(1);
	}
	version = get_data_version(c_handle);
	if (cm_strlen(cm_date)) date = cm_date;
	if (cm_strlen(cm_view)) view = cm_view;

	if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, 
				 &list, p)) > 0)
		csa_free(list);
	csa_logoff(c_handle, NULL);
	props_clean_up(p);
	free(p);
	free(uname);
	free(loc);
	return 0;
}