DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T r

⟦3cbc39da1⟧ TextFile

    Length: 6698 (0x1a2a)
    Types: TextFile
    Names: »read.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/quipu/dish/read.c« 

TextFile

#include "quipu/util.h"
#include "quipu/read.h"
#include "quipu/entry.h"

extern DN       dn;
extern PS       opt;
extern PS       rps;

extern DN       current_dn;
extern Entry    current_entry;
char            value_flag;
char		all_flag;
char		show_all_flag;
Attr_Sequence   as_flag = NULLATTR;
Attr_Sequence   tmp_ignore = NULLATTR;
char            flag_show;
char            doneget;
char 		key_flag;
char		print_format;

extern LLog    *log_dua;

struct ds_read_arg read_arg;

call_read (argc, argv)
int             argc;
char          **argv;
{
	char           *vect[2];
	struct DSError  error;
	struct ds_read_result result;

	vect[0] = "read";

	LLOG (log_dua, LLOG_DEBUG, ("Dish:- Entering read..."));

	if (!doneget) {
		value_flag = TRUE;
		all_flag = TRUE;
		show_all_flag = FALSE;
		if (as_flag != NULLATTR) {
			as_free (as_flag);
			as_flag = NULLATTR;
		}
		flag_show = FALSE;
		key_flag = TRUE;
		
		if ((argc = service_control (opt, argc, argv, &read_arg.rda_common)) == -1)
			return (-1);

		if ( (argc = set_read_flags (argc,argv)) == -1)
			return (-1);

		read_arg.rda_eis.eis_infotypes = value_flag;
		read_arg.rda_eis.eis_allattributes = all_flag;	
		read_arg.rda_eis.eis_select = as_flag;

		if (argc != 1) {
			ps_printf (opt,"Unknown option %s\n",argv[1]);
			return (-1);
		}
	}
	
	read_arg.rda_object = dn;

	if (rebind () != OK)
		return(-2);

	if (ds_read (&read_arg, &error, &result) != DS_OK) {
		ps_printf (opt, "Read failure...\n");
		LLOG (log_dua, LLOG_DEBUG, ("Dish:- read failed..."));
		/* deal with error */
		ds_error (opt, &error);
		return (-2);
	}

	LLOG (log_dua, LLOG_DEBUG, ("Dish:- Successful read..."));
	if (result.rdr_entry.ent_attr == NULLATTR) {
		ps_print (opt, "No attributes\n");
		return (-2);
	}
	if (result.rdr_common.cr_aliasdereferenced) {
		ps_print (rps, "(Alias dereferenced)\n");
	}
	cache_entry (&(result.rdr_entry), read_arg.rda_eis.eis_allattributes, value_flag);

	if (flag_show && !doneget) {	/* If there was a show flag, call */
		doneget = TRUE;
		call_showentry (1, vect);	/* showentry to print it all
						 * out  */
	} else
		doneget = TRUE;

	entryinfo_comp_free (&result.rdr_entry,0);
	LLOG (log_dua, LLOG_DEBUG, ("Dish:- Exiting read..."));

	return (argc);
}




read_cache (argc, argv)
int             argc;
char          **argv;
{
	Entry           read_entry;
	int             x = 1;
	char            noread_flag = FALSE;
	char            do_read = FALSE;
	Attr_Sequence 	as;
	extern int	copy_flag;

	if (doneget)
		return (argc);

	value_flag = TRUE;
	all_flag = TRUE;
	show_all_flag = FALSE;
	if (as_flag != NULLATTR) {
		as_free (as_flag);
		as_flag = NULLATTR;
	}
	flag_show = TRUE;
	key_flag = TRUE;
	doneget = TRUE;

	if ((argc = service_control (opt, argc, argv, &read_arg.rda_common)) == -1)
		return (-1);

	if ( (argc = set_read_flags (argc,argv)) == -1)
		return (-1);

	read_arg.rda_eis.eis_infotypes = value_flag;
	read_arg.rda_eis.eis_allattributes = all_flag;	
	read_arg.rda_eis.eis_select = as_flag;

	if (!copy_flag)
		do_read = TRUE;

	for (x=1; x< argc; x++) {
		if (test_arg (argv[x], "-nocache",4))
			do_read = TRUE;
		else if (test_arg (argv[x], "-cache",2)) 
			noread_flag = TRUE;
		else
			continue;
		shuffle_up (argc--,argv,x--);
	}

	if ((read_entry = local_find_entry (dn, FALSE)) != NULLENTRY) {

		for (as = as_flag; as!= NULLATTR; as = as->attr_link)
			if (as_find_type (read_entry->e_attributes, as->attr_type) == NULL) 
				do_read = TRUE;
		
		if (value_flag && (!read_entry->e_lock))
			do_read = TRUE;

		if ((read_arg.rda_eis.eis_allattributes == 1) && (!read_entry->e_complete))
			do_read = TRUE;

		current_entry = read_entry;
		dn_free (current_dn);
		current_dn = get_copy_dn (read_entry);
	} else 
		do_read = TRUE;

	if (do_read)
		if (noread_flag)
			if (read_entry == NULLENTRY) {
				ps_print (opt, "No data in cache, but '-cache' prevents me reading it!\n");
				return (-1);
			} else
				ps_print (opt, "Read required, but '-cache' specified,\nproceeding using cache...\n");
		else
			return (call_read (argc, argv));

	return (argc);
}


set_read_flags (argc,argv)
int argc;
char ** argv;
{
register int x;
AttributeType at;
extern char allow_move;

	print_format = READOUT;
	tmp_ignore = NULLATTR;

	for (x = 1; x < argc; x++) {
		if (test_arg (argv[x], "-all",1)) {
			show_all_flag = TRUE;
			all_flag = TRUE;
		} else if (test_arg (argv[x], "-noall",3)) {
			show_all_flag = FALSE;
			all_flag = FALSE;
		} else if (test_arg (argv[x], "-value",1))
			value_flag = EIS_ATTRIBUTESANDVALUES;
		else if (test_arg (argv[x], "-novalue",3))
			value_flag = EIS_ATTRIBUTETYPESONLY;
		else if (test_arg (argv[x], "-show",2)) 
			flag_show = TRUE;
		else if (test_arg (argv[x], "-noshow",4))
			flag_show = FALSE;
		else if (test_arg (argv[x], "-key",1)) 
			key_flag = TRUE;
		else if (test_arg (argv[x], "-nokey",3))
			key_flag = FALSE;
		else if (test_arg (argv[x], "-edb",3))
			print_format = EDBOUT;
		else if (test_arg (argv[x], "-sequence",2)) {
			if (x + 1 == argc) {	
				ps_printf (opt, "We need a sequence name.\n");
				return (-1);
			} else {
				shuffle_up (argc--, argv, x);
				set_sequence (argv[x]);
			}
		} else if (test_arg (argv[x],"-types",2)) {
			shuffle_up (argc--, argv, x);
			if (x >= argc) {
				ps_printf (opt,"-types argument missing\n");
				return (-1);
			}
			if ((at = AttrT_new (argv[x])) != NULLAttrT) {
				show_all_flag = TRUE;
				all_flag = FALSE;
				as_flag = as_merge (as_flag,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
			} else {
				ps_printf (opt,"Unknown attribute type %s\n",argv[x]);
				return (-1);
			}
			for (x++; x < argc;) {
				if (*argv[x] == '-') 
					break;
				if ((at = AttrT_new (argv[x])) != NULLAttrT) 
					as_flag = as_merge (as_flag,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
				else
					break;
				shuffle_up (argc--,argv,x);
			}
			x--;
		} else if (test_arg (argv[x],"-notypes",4)) {
			shuffle_up (argc--, argv, x);
			if (x >= argc) {
				ps_printf (opt,"-notypes argument missing\n");
				return (-1);
			}
			if ((at = AttrT_new (argv[x])) != NULLAttrT) {
				tmp_ignore = as_merge (tmp_ignore,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
			} else {
				ps_printf (opt,"Unknown attribute type %s\n",argv[x]);
				return (-1);
			}
			for (x++; x < argc;) {
				if (*argv[x] == '-') 
					break;
				if ((at = AttrT_new (argv[x])) != NULLAttrT) 
					tmp_ignore = as_merge (tmp_ignore,as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO));
				else
					break;
				shuffle_up (argc--,argv,x);
			}
			x--;
		} else if (allow_move) {
			if (move (argv[x]) != OK)
				continue;
		} else 
			continue;

		shuffle_up (argc--,argv,x--);
	}
	return (argc);
}