Example #1
0
static int
show_external (CT ct, int serial, int alternate)
{
    struct exbody *e = (struct exbody *) ct->c_ctparams;
    CT p = e->eb_content;

    if (!type_ok (p, 0))
	return OK;

    return show_switch (p, serial, alternate);
}
Example #2
0
static void
show_single_message (CT ct, char *form)
{
    sigset_t set, oset;

    int status;

    /* Allow user executable bit so that temporary directories created by
     * the viewer (e.g., lynx) are going to be accessible */
    umask (ct->c_umask & ~(0100));

    /*
     * If you have a format file, then display
     * the message headers.
     */
    if (form)
	DisplayMsgHeader(ct, form);
    else
	xpid = 0;

    /* Show the body of the message */
    show_switch (ct, 1, 0);

    if (ct->c_fp) {
	fclose (ct->c_fp);
	ct->c_fp = NULL;
    }
    if (ct->c_ceclosefnx)
	(*ct->c_ceclosefnx) (ct);

    /* block a few signals */
    sigemptyset (&set);
    sigaddset (&set, SIGHUP);
    sigaddset (&set, SIGINT);
    sigaddset (&set, SIGQUIT);
    sigaddset (&set, SIGTERM);
    sigprocmask (SIG_BLOCK, &set, &oset);

    while (wait (&status) != NOTOK) {
	pidcheck (status);
	continue;
    }

    /* reset the signal mask */
    sigprocmask (SIG_SETMASK, &oset, &set);

    xpid = 0;
    flush_errors ();
}
Example #3
0
void show_stmt(is_stmt* node, int tablevel)
{
	if (!node)
	{
		tab(tablevel);
	
		printf(";\n");
		return;
	}

	if (node->type != t_stmt_stmt_list)
		tab(1);

	tab(tablevel-1);
	switch (node->type)
	{
		case t_stmt_stmt_list:
			printf("{\n");
	
			show_stmt_list(node->data.stmt_list, tablevel);		

			tab(tablevel-1);
			printf("}\n");
			break;

		case t_stmt_var_stmt:
			show_var_stmt(node->data.var); /* prints its own ';' to be according to yacc */
			break;

		case t_stmt_assign:
			show_assign_op(node->data.assign);
			printf(";\n");
			break;

		case t_stmt_incr:
			show_incr_op(node->data.incr);
			printf(";\n");
			break;

		case t_stmt_if:
			show_if(node->data.if_stmt, tablevel);
			printf("\n");			/* empty line after if/else */
			break;

		case t_stmt_loop:
			show_loop_stmt(node->data.loop, tablevel);
			printf("\n"); 			/* empty line after loops */
			break;

		case t_stmt_func_call:
			show_func_call(node->data.func_call);
			printf(";\n");
			break;

		case t_stmt_switch:
			show_switch(node->data.switch_stmt, tablevel);
			printf("\n");			/* empty line after switch */
			break;

		case t_stmt_break:
			show_break(node->data.break_stmt);
			printf(";\n");
			break;

		case t_stmt_continue:
			show_continue(node->data.continue_stmt);
			printf(";\n");
			break;

		case t_stmt_return:
			show_return(node->data.return_stmt);
			printf(";\n");
			break;	
	}
}
Example #4
0
static int
show_multi_internal (CT ct, int serial, int alternate)
{
    int	alternating, nowalternate, nowserial, result;
    struct multipart *m = (struct multipart *) ct->c_ctparams;
    struct part *part;
    CT p;
    sigset_t set, oset;

    alternating = 0;
    nowalternate = alternate;

    if (ct->c_subtype == MULTI_PARALLEL) {
	nowserial = serialsw;
    } else if (ct->c_subtype == MULTI_ALTERNATE) {
	nowalternate = 1;
	alternating  = 1;
	nowserial = serial;
    } else {
	/*
	 * multipart/mixed
	 * mutlipart/digest
	 * unknown subtypes of multipart (treat as mixed per rfc2046)
	 */
	nowserial = serial;
    }

    /* block a few signals */
    if (!nowserial) {
	sigemptyset (&set);
	sigaddset (&set, SIGHUP);
	sigaddset (&set, SIGINT);
	sigaddset (&set, SIGQUIT);
	sigaddset (&set, SIGTERM);
	sigprocmask (SIG_BLOCK, &set, &oset);
    }

/*
 * alternate   -> we are a part inside an multipart/alternative
 * alternating -> we are a multipart/alternative 
 */

    result = alternate ? NOTOK : OK;

    for (part = m->mp_parts; part; part = part->mp_next) {
	p = part->mp_part;

	if (part_ok (p, 1) && type_ok (p, 1)) {
	    int	inneresult;

	    inneresult = show_switch (p, nowserial, nowalternate);
	    switch (inneresult) {
		case NOTOK:
		    if (alternate && !alternating) {
			result = NOTOK;
			goto out;
		    }
		    continue;

		case OK:
		case DONE:
		    if (alternating) {
			result = DONE;
			break;
		    }
		    if (alternate) {
			alternate = nowalternate = 0;
			if (result == NOTOK)
			    result = inneresult;
		    }
		    continue;
	    }
	    break;
	}
    }

    if (alternating && !part) {
	if (!alternate)
	    content_error (NULL, ct, "don't know how to display any of the contents");
	result = NOTOK;
	goto out;
    }

    if (serial && !nowserial) {
	pid_t pid;
	int kids;
	int status;

	kids = 0;
	for (part = m->mp_parts; part; part = part->mp_next) {
	    p = part->mp_part;

	    if (p->c_pid > OK) {
		if (kill (p->c_pid, 0) == NOTOK)
		    p->c_pid = 0;
		else
		    kids++;
	    }
	}

	while (kids > 0 && (pid = wait (&status)) != NOTOK) {
	    pidcheck (status);

	    for (part = m->mp_parts; part; part = part->mp_next) {
		p = part->mp_part;

		if (xpid == pid)
		    xpid = 0;
		if (p->c_pid == pid) {
		    p->c_pid = 0;
		    kids--;
		    break;
		}
	    }
	}
    }

out:
    if (!nowserial) {
	/* reset the signal mask */
	sigprocmask (SIG_SETMASK, &oset, &set);
    }

    return result;
}
Example #5
0
static int show_scope(ivl_scope_t net, void*x)
{
      unsigned idx;
      const char *is_auto;

      fprintf(out, "scope: %s (%u parameters, %u signals, %u logic)",
	      ivl_scope_name(net), ivl_scope_params(net),
	      ivl_scope_sigs(net), ivl_scope_logs(net));

      is_auto = ivl_scope_is_auto(net) ? "automatic " : "";
      switch (ivl_scope_type(net)) {
	  case IVL_SCT_MODULE:
	    fprintf(out, " module %s%s", ivl_scope_tname(net),
                    ivl_scope_is_cell(net) ? " (cell)" : "");
	    break;
	  case IVL_SCT_FUNCTION:
	    fprintf(out, " function %s%s", is_auto, ivl_scope_tname(net));
	    break;
	  case IVL_SCT_BEGIN:
	    fprintf(out, " begin : %s", ivl_scope_tname(net));
	    break;
	  case IVL_SCT_FORK:
	    fprintf(out, " fork : %s", ivl_scope_tname(net));
	    break;
	  case IVL_SCT_TASK:
	    fprintf(out, " task %s%s", is_auto, ivl_scope_tname(net));
	    break;
	  default:
	    fprintf(out, " type(%u) %s", ivl_scope_type(net),
		    ivl_scope_tname(net));
	    break;
      }

      fprintf(out, " time units = 1e%d\n", ivl_scope_time_units(net));
      fprintf(out, " time precision = 1e%d\n", ivl_scope_time_precision(net));

      for (idx = 0 ;  idx < ivl_scope_attr_cnt(net) ;  idx += 1) {
	    ivl_attribute_t attr = ivl_scope_attr_val(net, idx);
	    switch (attr->type) {
		case IVL_ATT_VOID:
		  fprintf(out, "  (* %s *)\n", attr->key);
		  break;
		case IVL_ATT_STR:
		  fprintf(out, "  (* %s = \"%s\" *)\n", attr->key,
			  attr->val.str);
		  break;
		case IVL_ATT_NUM:
		  fprintf(out, "  (* %s = %ld *)\n", attr->key,
			  attr->val.num);
		  break;
	    }
      }

      for (idx = 0 ;  idx < ivl_scope_params(net) ;  idx += 1)
	    show_parameter(ivl_scope_param(net, idx));

      for (idx = 0 ; idx < ivl_scope_enumerates(net) ; idx += 1)
	    show_enumerate(ivl_scope_enumerate(net, idx));

      for (idx = 0 ;  idx < ivl_scope_sigs(net) ;  idx += 1)
	    show_signal(ivl_scope_sig(net, idx));

      for (idx = 0 ;  idx < ivl_scope_events(net) ;  idx += 1)
	    show_event(ivl_scope_event(net, idx));

      for (idx = 0 ;  idx < ivl_scope_logs(net) ;  idx += 1)
	    show_logic(ivl_scope_log(net, idx));

      for (idx = 0 ;  idx < ivl_scope_lpms(net) ;  idx += 1)
	    show_lpm(ivl_scope_lpm(net, idx));

      for (idx = 0 ; idx < ivl_scope_switches(net) ; idx += 1)
	    show_switch(ivl_scope_switch(net, idx));

      switch (ivl_scope_type(net)) {
	  case IVL_SCT_FUNCTION:
	  case IVL_SCT_TASK:
	    fprintf(out, "  scope function/task definition\n");
	    if (ivl_scope_def(net) == 0) {
		  fprintf(out, "  ERROR: scope missing required task definition\n");
		  stub_errors += 1;
	    } else {
		  show_statement(ivl_scope_def(net), 6);
	    }
	    break;

	  default:
	    if (ivl_scope_def(net)) {
		  fprintf(out, "  ERROR: scope has an attached task definition:\n");
		  show_statement(ivl_scope_def(net), 6);
		  stub_errors += 1;
	    }
	    break;
      }

      fprintf(out, "end scope %s\n", ivl_scope_name(net));
      return ivl_scope_children(net, show_scope, 0);
}