browse.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
* All rights reserved.
*/
/*
#pragma ident "%Z%%M% %I% %E% SMI"
* Copyright (c) 1994
* Open Software Foundation, Inc.
*
* Permission is hereby granted to use, copy, modify and freely distribute
* the software in this file and its documentation for any purpose without
* fee, provided that the above copyright notice appears in all copies and
* that both the copyright notice and this permission notice appear in
* supporting documentation. Further, provided that the name of Open
* Software Foundation, Inc. ("OSF") not be used in advertising or
* publicity pertaining to distribution of the software without prior
* written permission from OSF. OSF makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
/*
* Copyright (c) 1996 X Consortium
* Copyright (c) 1995, 1996 Dalrymple Consulting
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the X Consortium and
* Dalrymple Consulting shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without prior
* written authorization.
*/
/* ________________________________________________________________________
*
* Module for interactive browsing.
*
* Entry points for this module:
* Browse() interactive browser
* ________________________________________________________________________
*/
#ifndef lint
static char *RCSid =
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "general.h"
static void PrElemPlusID(Element_t *);
/* ______________________________________________________________________ */
static char *br_help_msg[] = {
" ls List info about current element in tree",
" (context, children, attributes, etc.)",
" cd N ... Change to Nth elememt child, where N is shown by 'ls'.",
" N may also be '/' (top) or '..' (up).",
" cd id I Change to elememt whose ID is I",
" data N Show data of Nth data node",
" where Show current position in the tree",
" id I Show path to element with id I",
" (using '?' for I will lists all IDs and their paths)",
" find S Find elements matching spec S. Recognized syntaxes:",
" find attr <name> <value>",
" find cont <string>",
" find parent <gi-name>",
" find child <gi-name>",
" find gi <gi-name>",
" q rel gi Query: report if elem 'gi' has relation to current elem",
" ('rel' is one of 'child parent ancestor descendant",
" sibling sibling+ sibling+1 sibling- sibling-1 cousin')",
"",
" tran file [outfile]",
" With trans spec in 'file' translate into 'outfile' (stdout)",
" sdata file Read SDATA map file (for translations).",
" cmap file Read character map file (for translations).",
" stat Print statistics (how often elements occur, etc.)",
" sum Print elem usage summary (# of children, depth, etc.)",
" tree Print document hierarchy as a tree",
" cont Print context of each element",
};
/* ______________________________________________________________________ */
void
Browse()
{
char *Prompt;
Element_t *e;
int i, n, ac;
else Prompt = "=> ";
continue;
}
ac = 20;
if (av[1]) {
continue;
}
for (i=1; i<ac; i++) {
continue;
}
continue;
}
printf("Expecting digit, '..', or '/', got '%s'.\n",
av[i]);
break;
}
else {
break;
}
}
}
}
}
printf("No data at this node.\n");
}
}
/* show where we are in the tree */
/* show where we are in the tree */
/* perform query printing paths to matching elements */
/* list locations where specified ID(s) occur */
if (ac <= 1) continue;
else {
/* short: "id i1 i2 ...", long: "id -l i1 i2 ..." */
else n = 1;
for (i=n; i<ac; i++) {
if ((e = FindElemByID(av[i]))) {
if (n == 2) { /* long (multiline) format */
if (n != i) putchar('\n');
PrintLocation(e, stdout);
}
else PrElemPlusID(e);
}
}
}
}
/* show and set variables */
}
}
/* print summary of tag usage */
else PrintElemSummary(DocTree);
}
/* print element tree */
else PrintElemTree(DocTree);
}
/* print statistics */
else PrintStats(DocTree);
}
/* print context of each element of tree */
else PrintContext(DocTree);
}
/* print translation, given transpec */
if (ac > 2){
perror("Can not open output file");
continue;
}
}
}
}
}
sv = br_help_msg;
}
/* quit (control-D also works) */
else
}
}
/* ______________________________________________________________________ */
/* Do the "ls" command.
* Arguments:
* Pointer to element under consideration.
* Arg count from command line (this command, not the shell command).
* Arg vector.
*/
static void
Element_t *e,
int ac,
char **av
)
{
int i;
for(i=0; i<e->ncont; i++) {
}
return;
}
if (e->parent)
if (e->natts) {
for (i=0; i<e->natts; i++)
}
if (e->entity) {
printf("Entity & notation information:\n");
}
if (e->my_eorder >= 0)
if (e->necont) {
}
if (e->ndcont) {
for(i=0; i<e->ndcont; i++) {
else
}
}
}
/* ______________________________________________________________________ */
/* Perform query. Syntax: find relationship gi. Tells whether gi has
* given relationship to current element. Result (message) sent to stdout.
* Args:
* Pointer to element under consideration.
* Pointer to name of relationship. (see FindRelByName() for names)
* Pointer to GI to look for.
*/
static void
Element_t *e,
char *rel,
char *gi
)
{
char *cp;
Relation_t r;
return;
}
}
/* ______________________________________________________________________ */
/* Print path to the element and its ID (if it has one) on a single line.
* Arguments:
* Pointer to element under consideration.
*/
static void
Element_t *e
)
{
}
/* ______________________________________________________________________ */
/* Print path to the element and its ID (if it has one) on a single line.
* Arguments:
* Pointer to element under consideration.
*/
static void
Element_t *e,
char **av
)
{
}
/* Shorthand for defining simple finctions, which are just interfaces to
* calling QRelation(). DescendTree() only passes ptr to element. */
static void
Element_t *e,
char **av
)
{
char *atval;
PrElemPlusID(e);
}
static void
Element_t *e,
char **av
)
{
int i;
for (i=0; i<e->ncont; i++) {
PrElemPlusID(e);
return;
}
}
}
/* Find an element, given the criteria on its command line.
* Arguments:
* Pointer to element under consideration.
*/
static void
Element_t *e,
char **av
)
{
av++;
else e = DocTree;
}
/* ______________________________________________________________________ */