Ejemplo n.º 1
0
/******************************************************************************
 *
 *	L I S T P R O C S V A R S (char *name)
 *
 * Used in processing the ICL command "VARS".
 * Lists the variables of procedure name with their current types and values
 * OR, when name is CHARNIL, lists the direct mode variables
 *
 * A PROC entry is always found in the global world symbtab.
 * Its symboltable_part() member, if it has been executed at least once,
 * points to its local symbol table.
 *
 * Search the global symtab for a match (lookup_proc() using the string
 * argument name) and if we find it, we use the symboltable_part() entry
 * as the source of the variables.
 * If name is nil, we use the world symtab as the source.
 * We save the current active symbol table in symbols and restore
 * it once done and we use print_typed_symbols() to do the printing
 * (symtab.c).
 *
 ******************************************************************************
 */
value
listprocsvars(char *name)
{
    if (name != CHARNIL) {
	node *proc;

	if ((proc = lookup_proc(name)) != NODENIL) {
	    symtab *savesym = symbols;

	    symbols = symboltable_part(proc->val);
	    (void) print_typed_symbols(SYM_VARIABLE);
	    symbols = savesym;
	    return trueval;
	} else
	    return exception1(
		"PROCERR  VARS: Unrecognised procedure or command name \"%s\" ",
		name);
    } else {
	symtab *savesym = symbols;

	symbols = world;
	(void) print_typed_symbols(SYM_VARIABLE);
	symbols = savesym;
	return trueval;
    }
}
Ejemplo n.º 2
0
/******************************************************************************
 *
 *	F I L E A P R O C (char *procname,char *filename, char *comm)
 *
 * Saves the procedure 'procname' in the file 'filename' for the command 'comm'.
 *
 * If the procname parameter is CHARNIL then saves all the currently known
 * procedures into the file filename
 * OR
 * if procname is not CHARNIL the procedure is checked to exist (lookup_proc()).
 *
 * The file "filename" is opened for write using iclopenasoutfp()
 * If procname is CHARNIL then forall_typed_symbols() is called with
 * listproc() to print all the procs to the file otherwise listproc() is used
 * once to list the named proc to filename.
 * The file filename is then closed using iclcloseasoutfp().
 *
 ******************************************************************************
 */
value
fileaproc(char *procname, char *filename, char *comm)
{
    extern value iclopenasoutfp (char *whofor, char *filename);	/* output.c */
    extern value iclcloseasoutfp(char *whofor, char *filename);	/* output.c */
    node *proc = NULL;
    value val;

    if (procname != CHARNIL) {				/* Named procedure */
	if( (proc = lookup_proc(procname)) == NODENIL)
	    return exception2(
		"PROCERR  %s: Unrecognised procedure or command name %s",
		comm, procname);
    } else
	if( symbol_total(world, SYM_PROC) == 0)	{	/* No procedures */
	    unlink(filename);
	    return trueval;
	}

    if (isexc(val = iclopenasoutfp(comm, filename)))
	return val;
    if (procname == CHARNIL )				/* All procedures */
	(void) forall_typed_symbols(SYM_PROC, listproc);
    else
	(void) listproc(procname, proc, 0);
    return (iclcloseasoutfp(comm, filename));
}
Ejemplo n.º 3
0
static Pr_ret_t show_attrs(Attributes_t *Attrs, int delta, hpi_ui_print_cb_t proc)
{
	int		i, type, len, del;
	char		tmp[256], *name;
	char		buf[SHOW_BUF_SZ];
	union_type_t	val;
	SaErrorT	rv;
	Pr_ret_t	ret;

	memset(buf, ' ', SHOW_BUF_SZ);
	del = delta << 1;
	len = SHOW_BUF_SZ - del;
	for (i = 0; i < Attrs->n_attrs; i++) {
		name = get_attr_name(Attrs, i);
		if (name == (char *)NULL)
			break;
		rv = get_value(Attrs, i, &val);
		if (rv != SA_OK) continue;
		type = get_attr_type(Attrs, i);
		switch (type) {
			case NO_TYPE:	continue;
			case STRUCT_TYPE:
				snprintf(buf + del, len, "%s:\n", name);
				if (proc(buf) != 0) return(-1);
				rv = get_value(Attrs, i, &val);
				if (rv != SA_OK) continue;
				ret = show_attrs((Attributes_t *)(val.a),
					delta + 1, proc);
				if (ret != HPI_UI_OK) return(HPI_UI_END);
				continue;
			case LOOKUP_TYPE:
				strncpy(tmp, lookup_proc(Attrs->Attrs[i].lunum,
					val.i), 256);
				break;
			case DECODE_TYPE:
				rv = decode_proc(Attrs->Attrs[i].lunum, val.a,
					tmp, 256);
				if (rv != SA_OK) continue;
				break;
			case DECODE1_TYPE:
				rv = decode1_proc(Attrs->Attrs[i].lunum, val.i,
					tmp, 256);
				if (rv != SA_OK) continue;
				break;
			case READING_TYPE:
				if (thres_value(val.a, tmp, 256) != SA_OK)
					continue;
				break;
			case TEXT_BUFF_TYPE:
				snprintf(buf + del, len, "%s: ", name);
				if (proc(buf) != HPI_UI_OK) return(HPI_UI_END);
				ret = print_text_buffer(NULL, val.a, "\n", proc);
				if (ret != HPI_UI_OK) return(HPI_UI_END);
				continue;
			default:
				rv = get_value_as_string(Attrs, i, tmp, 256);
				if (rv != SA_OK) continue;
		};
		snprintf(buf + del, len, "%s: %s\n", name, tmp);
		if (proc(buf) != HPI_UI_OK) return(HPI_UI_END);
	};
	return(0);
}