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 m

⟦6a39409c0⟧ TextFile

    Length: 4212 (0x1074)
    Types: TextFile
    Names: »move.c«

Derivation

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

TextFile

/* move.c - */

#ifndef	lint
static char *rcsid = "$Header: /f/osi/quipu/dish/RCS/move.c,v 6.0 89/03/18 23:40:51 mrose Rel $";
#endif

/* 
 * $Header: /f/osi/quipu/dish/RCS/move.c,v 6.0 89/03/18 23:40:51 mrose Rel $
 *
 *
 * $Log:	move.c,v $
 * Revision 6.0  89/03/18  23:40:51  mrose
 * Release 5.0
 * 
 */

/*
 *				  NOTICE
 *
 *    Acquisition, use, and distribution of this module and related
 *    materials are subject to the restrictions of a license agreement.
 *    Consult the Preface in the User's Manual for the full terms of
 *    this agreement.
 *
 */


#include "quipu/util.h"
#include "quipu/name.h"

extern DN       dn;
extern PS       opt;
extern PS       rps;
extern char move_flag;

DN	fixed_pos = NULLDN;

extern LLog    *log_dua;

call_moveto (argc,argv)
int argc;
char ** argv;
{
char pwd_flag = FALSE;
char check_move = TRUE;
int x;

	if (argc == 1) {
		Usage (argv[0]);
		return;
	}
	
	move_flag = FALSE;

	for (x = 1; x < argc; x++) {
		if (test_arg (argv[x],"-pwd",1)) 
			pwd_flag = TRUE;
		else if (test_arg (argv[x],"-nopwd",3)) 
			pwd_flag = FALSE;
		else if (test_arg (argv[x],"-check",1)) 
			check_move = TRUE;
		else if (test_arg (argv[x],"-nocheck",3)) 
			check_move = FALSE;
		else if (move (argv[x]) == OK) {
			if (move_flag == TRUE) {
				ps_print (rps,"Too many parameters !\n");
				Usage (argv[0]);
				return;
			}
			move_flag = TRUE;
		} else {
			move_flag = FALSE;
			Usage (argv[0]);
			return;
		}
	}

	if (check_move)
		if (test_move_dn() != TRUE) {
			move_flag = FALSE;
			return;
		}

	if (move_flag == TRUE)
		consolidate_move ();
		
	if (pwd_flag) {
		dn_print (rps, fixed_pos, READOUT);
		ps_print (rps, "\n");
	}

}

consolidate_move ()
{
	if (move_flag) {
		move_flag = FALSE;
		dn_free (fixed_pos);
		fixed_pos = dn_cpy (dn);
	}
}

set_current_pos ()
{
	move_flag = FALSE;
	dn_free (dn);
	dn = dn_cpy (fixed_pos);
}

move (arg)
char           *arg;
{
	extern int print_parse_errors;

	DN              user_down ();
	DN              str2dn_aux ();
	DN		sequence_dn();
	DN              tmpdn;
	char *		ptr;
	char		alias = FALSE;

	LLOG (log_dua, LLOG_DEBUG, ("Dish:- Entering move..."));
	print_parse_errors = FALSE;

	if (*arg == '-') {
		print_parse_errors = TRUE;
		return (NOTOK);	   /* can't be a move if it starts with a minus */
	}

	if (*arg == '+')
		arg++;  /* old style call */

	ptr = arg;
	while (*ptr != 0) {
		if (! isdigit (*ptr))
			break;
		ptr++;
	}

	if (*ptr == 0) {
		/* sequence move */
		dn_free (dn);
		dn = dn_cpy (sequence_dn(atoi(arg)));
		print_parse_errors = TRUE;
		if (dn == NULLDN) {
			ps_printf (opt,"Invalid sequence number %s\n",arg);
			return (NOTOK);
		} else
			return (OK);
	}

	if ((ptr = index (arg,'@')) != NULLCP) {
		*ptr = 0;

		if (*arg == 0) {
			/* from root */
			dn_free (dn);
			dn = NULLDN;
			*ptr ='@';
			arg = ++ptr;
			if (*arg == 0) {
				print_parse_errors = TRUE;
				return (OK);    /* @ -> move to root */
			}
			if ((ptr = index (arg,'@')) != NULLCP)
				*ptr = 0;
		}
	} else {
		dn_free (dn);
		dn = dn_cpy (fixed_pos);
	}
	
	if (strcmp (arg,"..") == 0) {
		do {
			DN              dnptr;
			DN              trail;

			if (dn == NULLDN) {
				print_parse_errors = TRUE;
				ps_print (opt, "Can't go back past root\n");
				return (NOTOK);
			}
			if (dn->dn_parent == NULLDN) {
				dn_free (dn);
		 		dn = NULLDN;
			} else {
				for (dnptr = dn; dnptr->dn_parent != NULLDN; dnptr = dnptr->dn_parent)
					trail = dnptr;

				dn_comp_free (dnptr);
				trail->dn_parent = NULLDN;
			}
			if  (ptr == NULLCP) {
				print_parse_errors = TRUE;
				return (OK);
			}
			arg = ++ptr;
			if ((ptr = index (arg,'@')) != NULLCP) 
				*ptr = 0;
		} while (strcmp (arg,"..") == 0);
	}

	if (ptr != NULL)
		*ptr = '@';
	
	if ((tmpdn = str2dn_aux (arg,&alias)) != NULLDN) {
		if (dn == NULLDN)
			dn = tmpdn;
		else {
			if (alias) {
				dn_free (dn);
				dn = tmpdn;
			} else
				dn_append (dn,tmpdn);
		}
		print_parse_errors = TRUE;
		return (OK);
	} else {
		print_parse_errors = TRUE;
		return (NOTOK);
	}
		
}

test_move_dn ()
{
char * name = "moveto";
	
	/* Might do something else here... */
	/* current policy is to read the entry and cache it ! */

	return (read_cache (1,&name));
}