Esempio n. 1
0
 explicit SAXEventHandler( ::CreateSpace * obj)
     : state(-1)
     , depth(0)
     , handler_0(&obj->SpaceID)
 {
     reset_flags();
 }
Esempio n. 2
0
int w_drop_acc_2(struct sip_msg* msg, char* type_p, char* flags_p)
{
	unsigned long long type=0;
	/* if not set, we reset all flags for the type of accounting requested */
	unsigned long long flags=ALL_ACC_FLAGS;
	unsigned long long flag_mask;

	acc_type_param_t* acc_param;

	acc_ctx_t* acc_ctx=try_fetch_ctx();

	str in;

	if (acc_ctx == NULL) {
		LM_ERR("do_accounting() not used! This function resets flags in "
				"do_accounting()!\n");
		return -1;
	}

	if (type_p != NULL) {
		acc_param = (acc_type_param_t *)type_p;
		if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) {
			type = acc_param->u.ival;
		} else {
			if (pv_printf_s(msg, acc_param->u.pval, &in) < 0) {
				LM_ERR("failed to fetch type value!\n");
				return -1;
			}

			if ((type=do_acc_parse(&in, do_acc_type_parser)) == DO_ACC_ERR) {
				LM_ERR("Invalid expression <%.*s> for acc type!\n", in.len, in.s);
				return -1;
			}
		}
	}

	if (flags_p != NULL) {
		flags= *(unsigned long long*)flags_p;
	}

	flag_mask = type * flags;

	/* reset all flags */
	if (flag_mask == 0) {
		/*
		 * we use this flag in order make the difference between
		 * 0 value (do_accounting never called, callbacks never registered) and
		 * ACC_FLAGS_RESET (do_accounting called, callbacks registered, flag value
		 * changing during script execution)
		 */
		acc_ctx->flags = ACC_FLAGS_RESET;
	} else {
		reset_flags(acc_ctx->flags, flag_mask);
	}

	return 1;
}
Esempio n. 3
0
    void PrepareForReuse()
    {
        depth = 0;
        state = -1;
        the_error.reset();
        reset_flags();
        handler_0.PrepareForReuse();

    }
Esempio n. 4
0
static int bt_detect(struct si_sm_data *bt)
{
	/* It's impossible for the BT status and interrupt registers to be
	   all 1's, (assuming a properly functioning, self-initialized BMC)
	   but that's what you get from reading a bogus address, so we
	   test that first.  The calling routine uses negative logic. */

	if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) return 1;
	reset_flags(bt);
	return 0;
}
Esempio n. 5
0
int w_drop_acc_2(struct sip_msg* msg, char* type_p, char* flags_p)
{
	unsigned long long type=0;
	/* if not set, we reset all flags for the type of accounting requested */
	unsigned long long flags=ALL_ACC_FLAGS;
	unsigned long long flag_mask;
	unsigned long long *context_flags_p=try_fetch_flags();


	acc_type_param_t* acc_param;

	str in;

	if (context_flags_p == NULL) {
		LM_ERR("do_accounting() not used! This function resets flags in "
				"do_accounting()!\n");
		return -1;
	}

	if (type_p != NULL) {
		acc_param = (acc_type_param_t *)type_p;
		if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) {
			type = acc_param->u.ival;
		} else {
			if (pv_printf_s(msg, acc_param->u.pval, &in) < 0) {
				LM_ERR("failed to fetch type value!\n");
				return -1;
			}

			if ((type=do_acc_parse(&in, do_acc_type_parser)) < 0) {
				LM_ERR("Invalid expression <%.*s> for acc type!\n", in.len, in.s);
				return -1;
			}
		}
	}

	if (flags_p != NULL) {
		flags= *(unsigned long long*)flags_p;
	}

	flag_mask = type * flags;

	/* reset all flags */
	if (flag_mask == 0) {
		*context_flags_p = 0;
	} else {
		reset_flags(*context_flags_p, flag_mask);
	}

	return 1;
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const MatrixXd& FX, double JF, const VectorXd& FM,
        const MatrixXd& Sigma, double factor)
{
        //O(1)
        reset_flags();
        N_=FX.rows();
        M_=FX.cols();
        LOG( "MVN: direct init with N=" << N_
                << " and M=" << M_ << std::endl);
        CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_FX(FX);
        set_jacobian(JF);
        set_Sigma(Sigma);
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const VectorXd& Fbar, double JF, const VectorXd& FM, int Nobs,
        const MatrixXd& W, const MatrixXd& Sigma, double factor)
{
        reset_flags();
        N_=Nobs;
        M_=Fbar.rows();
        LOG( "MVN: sufficient statistics init with N=" << N_
                << " and M=" << M_ << std::endl);
        CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_Fbar(Fbar);
        set_W(W);
        set_jacobian(JF);
        set_Sigma(Sigma);
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const MatrixXd& FX, double JF, const VectorXd& FM,
        const MatrixXd& Sigma, double factor) :
  base::Object("Multivariate Normal distribution %1%")
{
        //O(1)
        reset_flags();
        N_=FX.rows();
        M_=FX.cols();
        IMP_LOG_TERSE( "MVN: direct init with N=" << N_
                << " and M=" << M_ << std::endl);
        IMP_USAGE_CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        IMP_USAGE_CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_FX(FX);
        set_jacobian(JF);
        set_Sigma(Sigma);
        use_cg_=false;
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const VectorXd& Fbar, double JF, const VectorXd& FM, int Nobs,
        const MatrixXd& W, const MatrixXd& Sigma, double factor)
  : base::Object("Multivariate Normal distribution %1%")
{
        reset_flags();
        N_=Nobs;
        M_=Fbar.rows();
        IMP_LOG_TERSE( "MVN: sufficient statistics init with N=" << N_
                << " and M=" << M_ << std::endl);
        IMP_USAGE_CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        IMP_USAGE_CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_Fbar(Fbar);
        set_W(W);
        set_jacobian(JF);
        set_Sigma(Sigma);
        use_cg_=false;
}
Esempio n. 10
0
static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
{
	unsigned char status;
	char buf[40]; /* For getting status */
	int i;

	status = BT_STATUS;
	bt->nonzero_status |= status;

	if ((bt_debug & BT_DEBUG_STATES) && (bt->state != bt->last_state))
		printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
			STATE2TXT,
			STATUS2TXT(buf),
			bt->timeout,
			time);
	bt->last_state = bt->state;

	if (bt->state == BT_STATE_HOSED) return SI_SM_HOSED;

	if (bt->state != BT_STATE_IDLE) {	/* do timeout test */

		/* Certain states, on error conditions, can lock up a CPU
		   because they are effectively in an infinite loop with
		   CALL_WITHOUT_DELAY (right back here with time == 0).
		   Prevent infinite lockup by ALWAYS decrementing timeout. */

    	/* FIXME: bt_event is sometimes called with time > BT_NORMAL_TIMEOUT
              (noticed in ipmi_smic_sm.c January 2004) */

		if ((time <= 0) || (time >= BT_NORMAL_TIMEOUT)) time = 100;
		bt->timeout -= time;
		if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) {
			error_recovery(bt, "timed out");
			return SI_SM_CALL_WITHOUT_DELAY;
		}
	}

	switch (bt->state) {

    	case BT_STATE_IDLE:	/* check for asynchronous messages */
		if (status & BT_SMS_ATN) {
			BT_CONTROL(BT_SMS_ATN);	/* clear it */
			return SI_SM_ATTN;
		}
		return SI_SM_IDLE;

	case BT_STATE_XACTION_START:
		if (status & BT_H_BUSY) {
			BT_CONTROL(BT_H_BUSY);
			break;
		}
    		if (status & BT_B2H_ATN) break;
		bt->state = BT_STATE_WRITE_BYTES;
		return SI_SM_CALL_WITHOUT_DELAY;	/* for logging */

	case BT_STATE_WRITE_BYTES:
		if (status & (BT_B_BUSY | BT_H2B_ATN)) break;
		BT_CONTROL(BT_CLR_WR_PTR);
		write_all_bytes(bt);
		BT_CONTROL(BT_H2B_ATN);	/* clears too fast to catch? */
		bt->state = BT_STATE_WRITE_CONSUME;
		return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */

	case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */
        	if (status & (BT_H2B_ATN | BT_B_BUSY)) break;
		bt->state = BT_STATE_B2H_WAIT;
		/* fall through with status */

	/* Stay in BT_STATE_B2H_WAIT until a packet matches.  However, spinning
	   hard here, constantly reading status, seems to hold off the
	   generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */

	case BT_STATE_B2H_WAIT:
    		if (!(status & BT_B2H_ATN)) break;

		/* Assume ordered, uncached writes: no need to wait */
		if (!(status & BT_H_BUSY)) BT_CONTROL(BT_H_BUSY); /* set */
		BT_CONTROL(BT_B2H_ATN);		/* clear it, ACK to the BMC */
		BT_CONTROL(BT_CLR_RD_PTR);	/* reset the queue */
		i = read_all_bytes(bt);
		BT_CONTROL(BT_H_BUSY);		/* clear */
		if (!i) break;			/* Try this state again */
		bt->state = BT_STATE_READ_END;
		return SI_SM_CALL_WITHOUT_DELAY;	/* for logging */

    	case BT_STATE_READ_END:

		/* I could wait on BT_H_BUSY to go clear for a truly clean
		   exit.  However, this is already done in XACTION_START
		   and the (possible) extra loop/status/possible wait affects
		   performance.  So, as long as it works, just ignore H_BUSY */

#ifdef MAKE_THIS_TRUE_IF_NECESSARY

		if (status & BT_H_BUSY) break;
#endif
		bt->seq++;
		bt->state = BT_STATE_IDLE;
		return SI_SM_TRANSACTION_COMPLETE;

	case BT_STATE_RESET1:
    		reset_flags(bt);
    		bt->timeout = BT_RESET_DELAY;
		bt->state = BT_STATE_RESET2;
		break;

	case BT_STATE_RESET2:		/* Send a soft reset */
		BT_CONTROL(BT_CLR_WR_PTR);
		HOST2BMC(3);		/* number of bytes following */
		HOST2BMC(0x18);		/* NetFn/LUN == Application, LUN 0 */
		HOST2BMC(42);		/* Sequence number */
		HOST2BMC(3);		/* Cmd == Soft reset */
		BT_CONTROL(BT_H2B_ATN);
		bt->state = BT_STATE_RESET3;
		break;

	case BT_STATE_RESET3:
		if (bt->timeout > 0) return SI_SM_CALL_WITH_DELAY;
		bt->state = BT_STATE_RESTART;	/* printk in debug modes */
		break;

	case BT_STATE_RESTART:		/* don't reset retries! */
		bt->write_data[2] = ++bt->seq;
		bt->read_count = 0;
		bt->nonzero_status = 0;
		bt->timeout = BT_NORMAL_TIMEOUT;
		bt->state = BT_STATE_XACTION_START;
		break;

	default:	/* HOSED is supposed to be caught much earlier */
		error_recovery(bt, "internal logic error");
		break;
  	}
  	return SI_SM_CALL_WITH_DELAY;
}
Esempio n. 11
0
void check_route(enum e_route_type route_type, int num_switch,
		t_ivec ** clb_opins_used_locally) {

	/* This routine checks that a routing:  (1) Describes a properly         *
	 * connected path for each net, (2) this path connects all the           *
	 * pins spanned by that net, and (3) that no routing resources are       *
	 * oversubscribed (the occupancy of everything is recomputed from        *
	 * scratch).                                                             */

	int inet, ipin, max_pins, inode, prev_node;
	boolean valid, connects;
	boolean * connected_to_route; /* [0 .. num_rr_nodes-1] */
	struct s_trace *tptr;
	boolean * pin_done;

	vpr_printf(TIO_MESSAGE_INFO, "\n");
	vpr_printf(TIO_MESSAGE_INFO, "Checking to ensure routing is legal...\n");

	/* Recompute the occupancy from scratch and check for overuse of routing *
	 * resources.  This was already checked in order to determine that this  *
	 * is a successful routing, but I want to double check it here.          */

	recompute_occupancy_from_scratch(clb_opins_used_locally);
	valid = feasible_routing();
	if (valid == FALSE) {
		vpr_printf(TIO_MESSAGE_ERROR, "Error in check_route -- routing resources are overused.\n");
		exit(1);
	}

	check_locally_used_clb_opins(clb_opins_used_locally, route_type);

	connected_to_route = (boolean *) my_calloc(num_rr_nodes, sizeof(boolean));

	max_pins = 0;
	for (inet = 0; inet < num_nets; inet++)
		max_pins = std::max(max_pins, (clb_net[inet].num_sinks + 1));

	pin_done = (boolean *) my_malloc(max_pins * sizeof(boolean));

	/* Now check that all nets are indeed connected. */

	for (inet = 0; inet < num_nets; inet++) {

		if (clb_net[inet].is_global || clb_net[inet].num_sinks == 0) /* Skip global nets. */
			continue;

		for (ipin = 0; ipin < (clb_net[inet].num_sinks + 1); ipin++)
			pin_done[ipin] = FALSE;

		/* Check the SOURCE of the net. */

		tptr = trace_head[inet];
		if (tptr == NULL) {
			vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d has no routing.\n", inet);
			exit(1);
		}

		inode = tptr->index;
		check_node_and_range(inode, route_type);
		check_switch(tptr, num_switch);
		connected_to_route[inode] = TRUE; /* Mark as in path. */

		check_source(inode, inet);
		pin_done[0] = TRUE;

		prev_node = inode;
		tptr = tptr->next;

		/* Check the rest of the net */

		while (tptr != NULL) {
			inode = tptr->index;
			check_node_and_range(inode, route_type);
			check_switch(tptr, num_switch);

			if (rr_node[prev_node].type == SINK) {
				if (connected_to_route[inode] == FALSE) {
					vpr_printf(TIO_MESSAGE_ERROR, "in check_route: node %d does not link into existing routing for net %d.\n", inode, inet);
					exit(1);
				}
			}

			else {
				connects = check_adjacent(prev_node, inode);
				if (!connects) {
					vpr_printf(TIO_MESSAGE_ERROR, "in check_route: found non-adjacent segments in traceback while checking net %d.\n", inet);
					exit(1);
				}

				if (connected_to_route[inode] && rr_node[inode].type != SINK) {

					/* Note:  Can get multiple connections to the same logically-equivalent     *
					 * SINK in some logic blocks.                                               */

					vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d routing is not a tree.\n", inet);
					exit(1);
				}

				connected_to_route[inode] = TRUE; /* Mark as in path. */

				if (rr_node[inode].type == SINK)
					check_sink(inode, inet, pin_done);

			} /* End of prev_node type != SINK */
			prev_node = inode;
			tptr = tptr->next;
		} /* End while */

		if (rr_node[prev_node].type != SINK) {
			vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d does not end with a SINK.\n", inet);
			exit(1);
		}

		for (ipin = 0; ipin < (clb_net[inet].num_sinks + 1); ipin++) {
			if (pin_done[ipin] == FALSE) {
				vpr_printf(TIO_MESSAGE_ERROR, "in check_route: net %d does not connect to pin %d.\n", inet, ipin);
				exit(1);
			}
		}

		reset_flags(inet, connected_to_route);

	} /* End for each net */

	free(pin_done);
	free(connected_to_route);
	vpr_printf(TIO_MESSAGE_INFO, "Completed routing consistency check successfully.\n");
	vpr_printf(TIO_MESSAGE_INFO, "\n");
}
Esempio n. 12
0
void SaveDepth::create_depth(){
  // cout << CameraMat_ << endl;
  // cout << CameraExtrinsicMat_ << endl;
  // cout << DistCoeff_ << endl;
  // cout << points_.header << endl;
  // stringstream ss;
  // ss << width << " : " << height << endl;
  // cout << ss.str() << endl;
  // cout << points_.header << endl;
  int width = ImageSize_.width;
  int height = ImageSize_.height;
  cv::Mat invR = CameraExtrinsicMat_(cv::Rect(0,0,3,3)).t();
	cv::Mat invT = -invR*(CameraExtrinsicMat_(cv::Rect(3,0,1,3)));
  cv::Mat invR_T = invR.t();
  cv::Mat invT_T = invT.t();

  // cv::Mat depth = cv::Mat::zeros(cv::Size(width, height), CV_8U);
  cv::Mat depth = cv::Mat::zeros(cv::Size(width, height), CV_32F);
  // cv::imwrite(save_path_ + "otameshi" +".jpg", depth);
  // cout << "Height " << points_.height << " Width " << points_.height << endl;
  // cout << "Image height " << ImageSize_.width << " Height " << ImageSize_.height << endl;
  // cout << time_stamp_ << endl;
  // cout << points_.row_step << endl;
  // cout << points_.point_step << endl;
  pcl::PointCloud<pcl::PointXYZI> data_;
  pcl::fromROSMsg(points_, data_);
  int count = 0;



  for (pcl::PointCloud<pcl::PointXYZI>::const_iterator item = data_.begin(); item!=data_.end(); item++){
    // cout << "x " << item->x << endl;
    // cout << "y " << item->y << endl;
    // cout << "z " << item->z << endl;
    // cout << item->intensity << endl;
    cv::Mat point(1, 3, CV_64F);
		point.at<double>(0) = double(item->x);
		point.at<double>(1) = double(item->y);
		point.at<double>(2) = double(item->z);
		point = point * invR_T + invT_T;

    // if (point.at<double>(2) <= 2.5) {
    //   continue;
    // }

    double tmpx = point.at<double>(0) / point.at<double>(2);
		double tmpy = point.at<double>(1)/point.at<double>(2);
		double r2 = tmpx * tmpx + tmpy * tmpy;
		double tmpdist = 1 + DistCoeff_.at<double>(0) * r2
			+ DistCoeff_.at<double>(1) * r2 * r2
			+ DistCoeff_.at<double>(4) * r2 * r2 * r2;

		cv::Point2d imagepoint;
		imagepoint.x = tmpx * tmpdist
			+ 2 * DistCoeff_.at<double>(2) * tmpx * tmpy
			+ DistCoeff_.at<double>(3) * (r2 + 2 * tmpx * tmpx);
		imagepoint.y = tmpy * tmpdist
			+ DistCoeff_.at<double>(2) * (r2 + 2 * tmpy * tmpy)
			+ 2 * DistCoeff_.at<double>(3) * tmpx * tmpy;
		imagepoint.x = CameraMat_.at<double>(0,0) * imagepoint.x + CameraMat_.at<double>(0,2);
		imagepoint.y = CameraMat_.at<double>(1,1) * imagepoint.y + CameraMat_.at<double>(1,2);
    int px = int(imagepoint.x + 0.5);
		int py = int(imagepoint.y + 0.5);

    // cout << "px " << px << endl;
    // cout << "py " << py << endl;

    if(0 <= px && px < width && 0 <= py && py < height){
      count = count + 1;
      if ((depth.at<double>(py, px) == 0) || (depth.at<double>(py, px) > point.at<double>(2))){
        // point.at<double>(2) = point.at<double>(2) * 2;
        depth.at<double>(py, px) = point.at<double>(2) / 255;
        // depth.at<int>(py+1, px) = int(point.at<double>(2));
        // depth.at<int>(py+2, px) = int(point.at<double>(2));
        // depth.at<int>(py+1, px+1) = int(point.at<double>(2));
        // depth.at<int>(py+2, px+1) = int(point.at<double>(2));
        // depth.at<int>(py-1, px) = int(point.at<double>(2));
        // depth.at<int>(py-1, px) = int(point.at<double>(2));
        // depth.at<int>(py-2, px-1) = int(point.at<double>(2));
        // depth.at<int>(py-2, px-1) = int(point.at<double>(2));

      }
      // double distance = point.at<double>(2);
      // cout << "max " << depth.at<double>(py, px) << endl;
      // depth.at<double>(50, 50) = 1;
      // exit(EXIT_FAILURE);
    }

    // exit(EXIT_FAILURE);
  }
  // cout << "count " << count << endl;
  double min, max;
  // cout << "ok1" << endl;
  cv::minMaxLoc(depth, &min, &max);
  // cout << "ok2 " << max  << endl;
  for (int w; w<width; w++){
    for (int h; h<height; h++){
      if (depth.at<double>(h, w) != 0){
        depth.at<double>(h, w) = depth.at<double>(h, w) / max;
      }
    }
  }
  cv::imwrite(save_path_ + "depth_" + time_stamp_ +".jpg", depth);
  cv::imwrite(save_path_ + "rgb_" + time_stamp_ +".jpg", image_);
  // exit(EXIT_FAILURE);
  // cout << data_ << endl;
  // cv::imwrite(save_path_ + "otameshi" +".jpg", depth);
  // cout << "func finish\n";
  reset_flags();
}
Esempio n. 13
0
LogStream::LogStream(logs::LevelFlag lf): level_flag(lf),
                                          file_output(false),
                                          filename("scatter.log") {
	reset_flags();
}
Esempio n. 14
0
/* initiate a report if we previously enabled MC accounting for this t */
static inline void on_missed(struct cell *t, struct sip_msg *req,
					struct sip_msg *reply, int code, unsigned long long *flags)
{
	str new_uri_bk={0,0};
	str dst_uri_bk={0,0};
	unsigned long long flags_to_reset=0;

	if (t->nr_of_outgoings) {
		/* set as new_uri the last branch */
		new_uri_bk = req->new_uri;
		dst_uri_bk = req->dst_uri;
		req->new_uri = t->uac[t->nr_of_outgoings-1].uri;
		req->dst_uri = t->uac[t->nr_of_outgoings-1].duri;
		req->parsed_uri_ok = 0;
	}

	/* set env variables */
	env_set_to( get_rpl_to(t,reply) );
	env_set_code_status( code, reply);

	/* we report on missed calls when the first
	 * forwarding attempt fails; we do not wish to
	 * report on every attempt; so we clear the flags;
	 */

	if (is_evi_mc_on(*flags)) {
		env_set_event(acc_missed_event);
		acc_evi_request( req, reply, is_evi_cdr_on(*flags) );
		flags_to_reset |= DO_ACC_EVI * DO_ACC_MISSED;
	}

	if (is_log_mc_on(*flags)) {
		env_set_text( ACC_MISSED, ACC_MISSED_LEN);
		acc_log_request( req, reply, is_log_cdr_on(*flags) );
		flags_to_reset |= DO_ACC_LOG * DO_ACC_MISSED;
	}

	if (is_aaa_mc_on(*flags)) {
		acc_aaa_request( req, reply, is_aaa_cdr_on(*flags) );
		flags_to_reset |= DO_ACC_AAA * DO_ACC_MISSED;
	}

	if (is_db_mc_on(*flags)) {
		env_set_text(db_table_mc.s, db_table_mc.len);
		acc_db_request( req, reply,&mc_ins_list, is_db_cdr_on(*flags));
		flags_to_reset |= DO_ACC_DB * DO_ACC_MISSED;
	}
/* DIAMETER */
#ifdef DIAM_ACC
	if (is_diam_mc_on(*flags)) {
		acc_diam_request( req, reply );
		flags_to_reset |= DO_ACC_DIAM * DO_ACC_MISSED;
	}
#endif

	/* Reset the accounting missed_flags
	 * These can't be reset in the blocks above, because
	 * it would skip accounting if the flags are identical
	 */

	if (new_uri_bk.s) {
		req->new_uri = new_uri_bk;
		req->dst_uri = dst_uri_bk;
		req->parsed_uri_ok = 0;
	}

	reset_flags(*flags, flags_to_reset);

}
Esempio n. 15
0
void CPU::reset() {
	reset_flags();
	reset_registers();
}
Esempio n. 16
0
/*
 * Portions Copyright 2011 VMware, Inc.
 */
static int bt_detect(struct si_sm_data *bt)
{
	/*
	 * It's impossible for the BT status and interrupt registers to be
	 * all 1's, (assuming a properly functioning, self-initialized BMC)
	 * but that's what you get from reading a bogus address, so we
	 * test that first.  The calling routine uses negative logic.
	 */

	unsigned char bt_status = BT_STATUS;
	unsigned char bt_intmask = BT_INTMASK_R;

	if ((bt_status == 0xFF) || (bt_intmask == 0xFF)) {
		if (bt_debug) {
			printk(KERN_WARNING "IPMI BT: BT__STATUS or BT_MASK is invalid: %d, %d\n",
			       bt_status, bt_intmask);
		}
		return 1;
	}

	/*
	 * Test the R/W bits on the BT interface to ascertain if the device is
	 * truly available. These bits the host to device clear read bit and clear write
	 * bit, bit 0 and 1 on the BT_CNTL register and bit 7 the h/w reset bit of the
	 * BT_INTMASK register.  The R/W bits should return 0 when read
	 */
	if (bt_status & (BT_CLR_WR_PTR | BT_CLR_RD_PTR)) {
		if (bt_debug) {
			printk(KERN_WARNING "IPMI BT: BT_CLR_WR_PTR or BT_CLR_RD_PTR are not 0: %d, %d\n",
			      (bt_status & BT_CLR_WR_PTR), (bt_status & BT_CLR_WR_PTR));
		}
		return 1;
	}

	if(bt_intmask & BT_BMC_HWRST) {
		if (bt_debug) {
			printk(KERN_WARNING "IPMI BT: BT_BMC_HWRST is not 0: %d\n",
			      (bt_intmask & BT_BMC_HWRST));
		}
		return 1;
	}

	/*
	 * The H_BUSY (bit 6) of the BT_CNTL register works as a toggle bit, with
	 * the state of the bit toggling if a 1 is written. No change is seen if 0 is
	 * written. This bit is toggled to further verify the presence of the BT interface
	 */

	// Toggle bit
	BT_CONTROL(BT_H_BUSY);
	if (!((bt_status ^ BT_STATUS) & BT_H_BUSY)) {
		if (bt_debug) {
			printk(KERN_WARNING "IPMI BT: Unable to toggle BT_H_BUSY once\n");
		}
		return 1;
	}
	//Toggle again
	BT_CONTROL(BT_H_BUSY);
	if ((bt_status ^ BT_STATUS) & BT_H_BUSY) {
		if (bt_debug) {
			printk(KERN_WARNING "IPMI BT: Unable to toggle BT_H_BUSY twice\n");
		}
		return 1;
	}

	reset_flags(bt);
	return 0;

}
Esempio n. 17
0
static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
{
	unsigned char status, BT_CAP[8];
	static enum bt_states last_printed = BT_STATE_PRINTME;
	int i;

	status = BT_STATUS;
	bt->nonzero_status |= status;
	if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
		printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
			STATE2TXT,
			STATUS2TXT,
			bt->timeout,
			time);
		last_printed = bt->state;
	}

	/*
	 * Commands that time out may still (eventually) provide a response.
	 * This stale response will get in the way of a new response so remove
	 * it if possible (hopefully during IDLE).  Even if it comes up later
	 * it will be rejected by its (now-forgotten) seq number.
	 */

	if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) {
		drain_BMC2HOST(bt);
		BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
	}

	if ((bt->state != BT_STATE_IDLE) &&
	    (bt->state <  BT_STATE_PRINTME)) {
		/* check timeout */
		bt->timeout -= time;
		if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1))
			return error_recovery(bt,
					      status,
					      IPMI_TIMEOUT_ERR);
	}

	switch (bt->state) {

	/*
	 * Idle state first checks for asynchronous messages from another
	 * channel, then does some opportunistic housekeeping.
	 */

	case BT_STATE_IDLE:
		if (status & BT_SMS_ATN) {
			BT_CONTROL(BT_SMS_ATN);	/* clear it */
			return SI_SM_ATTN;
		}

		if (status & BT_H_BUSY)		/* clear a leftover H_BUSY */
			BT_CONTROL(BT_H_BUSY);

		/* Read BT capabilities if it hasn't been done yet */
		if (!bt->BT_CAP_outreqs)
			BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
					SI_SM_CALL_WITHOUT_DELAY);
		bt->timeout = bt->BT_CAP_req2rsp;
		BT_SI_SM_RETURN(SI_SM_IDLE);

	case BT_STATE_XACTION_START:
		if (status & (BT_B_BUSY | BT_H2B_ATN))
			BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
		if (BT_STATUS & BT_H_BUSY)
			BT_CONTROL(BT_H_BUSY);	/* force clear */
		BT_STATE_CHANGE(BT_STATE_WRITE_BYTES,
				SI_SM_CALL_WITHOUT_DELAY);

	case BT_STATE_WRITE_BYTES:
		if (status & BT_H_BUSY)
			BT_CONTROL(BT_H_BUSY);	/* clear */
		BT_CONTROL(BT_CLR_WR_PTR);
		write_all_bytes(bt);
		BT_CONTROL(BT_H2B_ATN);	/* can clear too fast to catch */
		BT_STATE_CHANGE(BT_STATE_WRITE_CONSUME,
				SI_SM_CALL_WITHOUT_DELAY);

	case BT_STATE_WRITE_CONSUME:
		if (status & (BT_B_BUSY | BT_H2B_ATN))
			BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
		BT_STATE_CHANGE(BT_STATE_READ_WAIT,
				SI_SM_CALL_WITHOUT_DELAY);

	/* Spinning hard can suppress B2H_ATN and force a timeout */

	case BT_STATE_READ_WAIT:
		if (!(status & BT_B2H_ATN))
			BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
		BT_CONTROL(BT_H_BUSY);		/* set */

		/*
		 * Uncached, ordered writes should just proceeed serially but
		 * some BMCs don't clear B2H_ATN with one hit.  Fast-path a
		 * workaround without too much penalty to the general case.
		 */

		BT_CONTROL(BT_B2H_ATN);		/* clear it to ACK the BMC */
		BT_STATE_CHANGE(BT_STATE_CLEAR_B2H,
				SI_SM_CALL_WITHOUT_DELAY);

	case BT_STATE_CLEAR_B2H:
		if (status & BT_B2H_ATN) {
			/* keep hitting it */
			BT_CONTROL(BT_B2H_ATN);
			BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
		}
		BT_STATE_CHANGE(BT_STATE_READ_BYTES,
				SI_SM_CALL_WITHOUT_DELAY);

	case BT_STATE_READ_BYTES:
		if (!(status & BT_H_BUSY))
			/* check in case of retry */
			BT_CONTROL(BT_H_BUSY);
		BT_CONTROL(BT_CLR_RD_PTR);	/* start of BMC2HOST buffer */
		i = read_all_bytes(bt);		/* true == packet seq match */
		BT_CONTROL(BT_H_BUSY);		/* NOW clear */
		if (!i) 			/* Not my message */
			BT_STATE_CHANGE(BT_STATE_READ_WAIT,
					SI_SM_CALL_WITHOUT_DELAY);
		bt->state = bt->complete;
		return bt->state == BT_STATE_IDLE ?	/* where to next? */
			SI_SM_TRANSACTION_COMPLETE :	/* normal */
			SI_SM_CALL_WITHOUT_DELAY;	/* Startup magic */

	case BT_STATE_LONG_BUSY:	/* For example: after FW update */
		if (!(status & BT_B_BUSY)) {
			reset_flags(bt);	/* next state is now IDLE */
			bt_init_data(bt, bt->io);
		}
		return SI_SM_CALL_WITH_DELAY;	/* No repeat printing */

	case BT_STATE_RESET1:
		reset_flags(bt);
		drain_BMC2HOST(bt);
		BT_STATE_CHANGE(BT_STATE_RESET2,
				SI_SM_CALL_WITH_DELAY);

	case BT_STATE_RESET2:		/* Send a soft reset */
		BT_CONTROL(BT_CLR_WR_PTR);
		HOST2BMC(3);		/* number of bytes following */
		HOST2BMC(0x18);		/* NetFn/LUN == Application, LUN 0 */
		HOST2BMC(42);		/* Sequence number */
		HOST2BMC(3);		/* Cmd == Soft reset */
		BT_CONTROL(BT_H2B_ATN);
		bt->timeout = BT_RESET_DELAY * 1000000;
		BT_STATE_CHANGE(BT_STATE_RESET3,
				SI_SM_CALL_WITH_DELAY);

	case BT_STATE_RESET3:		/* Hold off everything for a bit */
		if (bt->timeout > 0)
			return SI_SM_CALL_WITH_DELAY;
		drain_BMC2HOST(bt);
		BT_STATE_CHANGE(BT_STATE_RESTART,
				SI_SM_CALL_WITH_DELAY);

	case BT_STATE_RESTART:		/* don't reset retries or seq! */
		bt->read_count = 0;
		bt->nonzero_status = 0;
		bt->timeout = bt->BT_CAP_req2rsp;
		BT_STATE_CHANGE(BT_STATE_XACTION_START,
				SI_SM_CALL_WITH_DELAY);

	/*
	 * Get BT Capabilities, using timing of upper level state machine.
	 * Set outreqs to prevent infinite loop on timeout.
	 */
	case BT_STATE_CAPABILITIES_BEGIN:
		bt->BT_CAP_outreqs = 1;
		{
			unsigned char GetBT_CAP[] = { 0x18, 0x36 };
			bt->state = BT_STATE_IDLE;
			bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP));
		}
		bt->complete = BT_STATE_CAPABILITIES_END;
		BT_STATE_CHANGE(BT_STATE_XACTION_START,
				SI_SM_CALL_WITH_DELAY);

	case BT_STATE_CAPABILITIES_END:
		i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP));
		bt_init_data(bt, bt->io);
		if ((i == 8) && !BT_CAP[2]) {
			bt->BT_CAP_outreqs = BT_CAP[3];
			bt->BT_CAP_req2rsp = BT_CAP[6] * 1000000;
			bt->BT_CAP_retries = BT_CAP[7];
		} else
			printk(KERN_WARNING "IPMI BT: using default values\n");
		if (!bt->BT_CAP_outreqs)
			bt->BT_CAP_outreqs = 1;
		printk(KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n",
			bt->BT_CAP_req2rsp / 1000000L, bt->BT_CAP_retries);
		bt->timeout = bt->BT_CAP_req2rsp;
		return SI_SM_CALL_WITHOUT_DELAY;

	default:	/* should never occur */
		return error_recovery(bt,
				      status,
				      IPMI_ERR_UNSPECIFIED);
	}
	return SI_SM_CALL_WITH_DELAY;
}
Esempio n. 18
0
Token malpar_next_token(Buffer * sc_buf)
{
		Token t;         /*token to be returned */
		unsigned char c; /* input symbol */
		Buffer *lex_buf; /* temporary buffer for holding lexemes */       
		int accept = NOAS; /* Not Accepting State */
		int state = 0;     /* Start state in the Transition Table */
		int lexstart;      /* current lexeme start offset */ 
 static int forward;  /* current input char offset */                                       
/* 
forward is the offset from the beginning of the char buffer of the
input buffer (sc_buf) to the current character, which is to be processed
by the scanner.
lexstart is the offset from the beginning of the char buffer of the
input buffer (sc_buf) to the first character of the current lexeme,
which is being processed by the scanner.
*/ 
		
		
	   /* DECLARE YOUR VARIABLES HERE IF NEEDED */
 int VID_FLAG = 0; /*flag if start of VID reconised*/
 int FPL_FLAG = 0; /*flag for if FPL*/
 int DIL_FLAG = 0; /*flag for if DIL is reconised*/
 int OIL_FLAG = 0; /*flag for if octal literal is reconised*/
 int ZERO_FLAG = 0; /*flag for if first digit is a 0*/
 int NUM_FLAG = 0; /*flag if number of unknown type is reconised*/
 int i; /*generic counter for a for loop*/
 
 lexstart = sc_buf->addc_offset;
 forward = lexstart;
				
 while (1)/*constant used for infinite loop*/
 { 
	 c = sc_buf->ca_head[forward++];  /*may need to be ++forward if getting wierd errors*/

	 if (isalnum(c)==0 || c=='"')
	 {
		 switch (c)
		 {
		 case '"':
			 {
				 ca_setmark(sc_buf,forward);
				 c = sc_buf->ca_head[forward++];
				 if (c != '"') /*checks to see if it is an empty string*/
				 {
					 while (c = sc_buf->ca_head[forward++])
					 {
						 if (c=='\n' || c=='\r') /*potential weird string error*/
						 {
							 t.code = ERR_T;
							 if ((forward - ca_getmark(sc_buf)) >= 20)
							 {
								 for (i=0;i<17;i++)
								 {
									 t.attribute.err_lex[i] = sc_buf->ca_head[ca_getmark(sc_buf)+1];
								 }
								 t.attribute.err_lex[17]='.';
								 t.attribute.err_lex[18]='.';
								 t.attribute.err_lex[19]='.';
								 t.attribute.err_lex[20]='\0';
							 }
							 else
							 {
								 for (i=0;i<20;i++)
								 {
									 t.attribute.err_lex[i]= sc_buf->ca_head[ca_getmark(sc_buf)+1];
								 }
								 t.attribute.err_lex[20]='\0';
							 }
						 }
						 if (c == '"') 
						 {
							 t.attribute.str_offset = str_LTBL->addc_offset;
							 for (i=(ca_getmark(sc_buf)+1);i<forward;i++) /*forward may point to 1 past the quotation mark*/
							 {
								 ca_addc(str_LTBL,sc_buf->ca_head[i]);
							 }
							 ca_addc(str_LTBL,'\0'); /*end of string marker*/
							 t.code = STR_T;
						 }
					 }
				 }
				 else
				 {
					 t.code = ERR_T;
					 t.attribute.err_lex[0]='R';
					 t.attribute.err_lex[1]='U';
					 t.attribute.err_lex[2]='N';
					 t.attribute.err_lex[3]=' ';
					 t.attribute.err_lex[4]='T';
					 t.attribute.err_lex[5]='I';
					 t.attribute.err_lex[6]='M';
					 t.attribute.err_lex[7]='E';
					 t.attribute.err_lex[8]=' ';
					 t.attribute.err_lex[9]='E';
					 t.attribute.err_lex[10]='R';
					 t.attribute.err_lex[11]='R';
					 t.attribute.err_lex[12]='O';
					 t.attribute.err_lex[13]='R';
					 t.attribute.err_lex[14]=':';
					 t.attribute.err_lex[15]='\0';
				 }
				 break;
			 }
		 case '+':
			 {
				 t.code = ART_OP_T;
				 t.attribute.arr_op = PLUS;
				 break;
			 }

		 case '-':
			 {
				 t.code = ART_OP_T;
				 t.attribute.arr_op = MINUS;
				 break;
			 }

		 case '*':
			 {
				 t.code = ART_OP_T;
				 t.attribute.arr_op = MULT;
				 break;
			 }

		 case '/':
			 {
				 t.code = ART_OP_T;
				 t.attribute.arr_op = DIV;
				 break;
			 }

		 case '{':
			 {
				 t.code = LPR_T;
				 break;
			 }

		 case '}':
			 {
				 t.code = RPR_T;
				 break;
			 }

		 case '>':
			 {
				 t.code = REL_OP_T;
				 t.attribute.rel_op = GT;
				 break;
			 }

		 case '<':
			 {
				 t.code = REL_OP_T;
				 t.attribute.rel_op = LT;
				 break;
			 }

		 case '=':
			 {
				 if (sc_buf->ca_head[forward++] == '=')
				 {
					 t.code = REL_OP_T;
					 t.attribute.rel_op = EQ;
				 }
				 else
				 {
					 forward--;
					t.code = ASS_OP_T;
				 }
				 break;
			 }

		 case ' ':
			 {
				 //c = sc_buf->ca_head[forward++];
				 break;
			 }
		 case '.':
			 {	
				 c= sc_buf->ca_head[forward++];
				 if (c == 'A')
				 {	
					 c= sc_buf->ca_head[forward++];
					 if (c == 'N')
					 {
						 c = sc_buf->ca_head[forward++];
						 if (c =='D')
						 {
							 t.code = LOG_OP_T;
							 t.attribute.log_op = AND;
						 }
						 else
						 {
							 t.code = ERR_T;
						 }
					 }
					 else
					 {
						 t.code = ERR_T;
					 }
				 }
				 if (c == 'O')
				 {
					 c = sc_buf->ca_head[forward++];
					 if (c == 'R')
					 {
						 t.code = LOG_OP_T;
						 t.attribute.log_op = OR;
					 }
					 else 
					 {
						 t.code = ERR_T;
					 }
				 }
				 else
				 {
					 t.code = ERR_T;
				 }
				 break;
			 }
		 case '!':
			 {	
				 c = sc_buf->ca_head[forward++];
				 if (c != '<')
				 {
					 t.code = ERR_T;
					 forward--;
				 }
				 if (c == '=')
				 {
					 t.code = REL_OP_T;
					 t.attribute.rel_op = NE;
				 }
				 else
				 {
					 while (sc_buf->ca_head[forward++] != '\n'){} //move through buffer untill comment is done
				 }
				 break;
			 }
		 case ';':
			 {
				 t.code = EOS_T;
				 break;
			 }
		 case '(':
			 {
				 t.code = LBR_T;
				 break;
			 }
		 case ')':
			 {
				 t.code = RBR_T;
				 break;
			 }
		 case EOF:
			 {
				 t.code=SEOF_T;
				 break;
			 }
		 default:/* may pick up others like string, so wierd errors could come from here*/
			 {
				 t.code = ERR_T;
				 t.attribute.err_lex[0] = c;
				 t.attribute.err_lex[1] = '/0'; /*store end of string inidicator to the string*/
				 break;
			 }
		 }
	 }
	 else /*character is a digit or letter*/
		 /*final state machine*/
	 {
		 ca_setmark(sc_buf,forward);
		 
		 state = 0;
		 lexstart = ca_getmark(sc_buf);
		 state = get_next_state (state,c,&accept);

		 c = sc_buf->ca_head[forward++];

		 while (accept == NOAS)
			 {
				 state = get_next_state(state,c,&accept);
				 if (accept == NOAS) /*if statemet to check if sate has changed*/
				 {
					 c = sc_buf->ca_head[forward++];
				 }
			 }

		 lex_buf = b_create(sc_buf->capacity,sc_buf->inc_factor,sc_buf->mode);

		 if (state == (2||7||8||11))
		 {
			 forward = lexstart;
		 }
		 
		 c = sc_buf->ca_head[lexstart];

		 while (1)
		 {
			 switch (c)/*character most recently added in*/
			 {
			 case 0: /*[a-zA-Z]*/
				 {
					 /*VID or SVID or Keyword may need to take this out check w/ leland*/
					 if (iskeyword(lex_buf->ca_head) != FALSE) /*keyword token found*/
					 {
						 if (lex_buf->addc_offset>0)
						 {
							 forward--; /*character not added to lex_buf move pointer back 1*/
						 }
						 t.code = KW_T;
						 t.attribute.kwt_idx = iskeyword(lex_buf->ca_head); /*set attribute*/
					 }
					 else
					 {
						 /*check to see if any of the identifier flags have been checked*/
						 if (FPL_FLAG!=0||DIL_FLAG!=0||OIL_FLAG!=0||NUM_FLAG!=0)
						 {
							 if (FPL_FLAG == 1) 
							 {
								 if (lex_buf->addc_offset>0)
								 {
									 forward--; /*character not added to lex_buf move pointer back 1*/
								 }
								 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
								 t=aa_table[8](lex_buf->ca_head);
							 }
							 if (DIL_FLAG == 1) 
							 {
								 if (lex_buf->addc_offset>0)
								 {
									 forward--; /*character not added to lex_buf move pointer back 1*/
								 }
								 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
								 t=aa_table[7](lex_buf->ca_head);

							 }
							 if (OIL_FLAG == 1) 
							 {
								 if (lex_buf->addc_offset>0)
								 {
									 forward--; /*character not added to lex_buf move pointer back 1*/
								 }
								 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
								 t=aa_table[12](lex_buf->ca_head);
							 }
							 if (ZERO_FLAG == 1) 
							 {
								 if (lex_buf->addc_offset>0)
								 {
									 forward--; /*character not added to lex_buf move pointer back 1*/
								 }
								 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
								 t=aa_table[7](lex_buf->ca_head);
							 }
							 if (NUM_FLAG==1&&ZERO_FLAG==0) 
							 {
								 if (lex_buf->addc_offset>0)
								 {
									 forward--; /*character not added to lex_buf move pointer back 1*/
								 }
								 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
								 t=aa_table[7](lex_buf->ca_head);
							 }

						 }
						 VID_FLAG = 1; /*set variable identifier flag*/
					 }
					 ca_addc(lex_buf,c);
					 break;
				 }
			 case 1: /*0*/
				 {
					 /*octal or DIL 0 or FPL 0*/
					 if (ZERO_FLAG==1)/*leading 0 and another digit*/
					 {
						 OIL_FLAG=1;
					 }
					 if (FPL_FLAG==0&&NUM_FLAG==0&&DIL_FLAG==0&&ZERO_FLAG==0)
					 {
						 ZERO_FLAG=1; /*identify as a numeric token starting with 0*/
					 }
					 if (NUM_FLAG==1&&ZERO_FLAG==0) /*number with no leading 0*/
					 {
						 /*could be FPL or DIL*/
					 }
					 if (VID_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 VID_FLAG=1;
					 }
					 /*if FPL_FLAG is set it is known to be an FPL*/
					 ca_addc(lex_buf,c);
					 break;
				 }
			 case 2: /*[8-9]*/ 
				 {
					 if (ZERO_FLAG==1&&FPL_FLAG==0&&OIL_FLAG==0&&DIL_FLAG==0)/*leading 0 and no decimal place*/
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 /*number is single 0*/
						 if (lex_buf->addc_offset > 0)
						 {
							 forward--;
						 }
						 t=aa_table[7](lex_buf->ca_head);
					 }
					 if (OIL_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG); /*reset the flags*/
						 if (lex_buf->addc_offset > 0)
						 {
							 forward--; 
						 }
						 t=aa_table[12](lex_buf->ca_head);

					 }
					 if (NUM_FLAG==0&&DIL_FLAG==0&&FPL_FLAG==0) /*no preceeding digits*/
					 {
						 /*could be a DIL or FPL*/
						 NUM_FLAG=1;
					 }
					 if (VID_FLAG==1)/*is already known VID*/
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 VID_FLAG=1;
					 }
					 ca_addc(lex_buf,c);
					 break;
				 }
			 case 3: /*[1-7]*/
				 {
					 if (ZERO_FLAG==1&&OIL_FLAG==1) /*already known oil*/
					 {
						 /*still oil*/
					 }
					 if (ZERO_FLAG==1&&OIL_FLAG==0)/*leading 0 with no other digits*/
					 {
						 OIL_FLAG=1;
					 }
					 if (NUM_FLAG==0&&FPL_FLAG==0&&DIL_FLAG==0)/*no numeric flags set*/
					 {
						 NUM_FLAG=1;
					 }
					 if (VID_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 VID_FLAG=1;
					 }
					 ca_addc(lex_buf,c);
					 break;
				 }
			 case 4: /*.*/
				 {
					 if (NUM_FLAG==0&&ZERO_FLAG==0&&DIL_FLAG==0&&FPL_FLAG==0)/*if no numeric flags are set*/
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 ca_addc(lex_buf,c);
						 t=aa_table[9](lex_buf->ca_head);
					 }
					 if (OIL_FLAG==1) /*if known OIL*/
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 ca_addc(lex_buf,c);
						 t=aa_table[9](lex_buf->ca_head);
					 }
					  if (FPL_FLAG==1) /*if known FPL*/
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 ca_addc(lex_buf,c);
						 t=aa_table[9](lex_buf->ca_head);
					 }
					 if ((DIL_FLAG==1||NUM_FLAG==1)&&FPL_FLAG==0)/*if identified as a DIL or NUM already*/
					 {
						 FPL_FLAG=1;
					 }
					 if (VID_FLAG==1) /*if VID*/
					 {
						 if (lex_buf->addc_offset>0)
						 {
							 forward--; /*character not added to lex_buf move pointer back 1*/
						 }
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t=aa_table[3](lex_buf->ca_head);
					 }
					 ca_addc(lex_buf,c);
					 break;
				 }
			 case 5: /*#*/
				 {
					 if (VID_FLAG==0&&FPL_FLAG==0&&DIL_FLAG==0&&OIL_FLAG==0&&ZERO_FLAG==0)
					 {
						 ca_addc(lex_buf,c);
						 t=aa_table[9](lex_buf->ca_head);
					 }
					 if (FPL_FLAG==1)
					 {
						 if(lex_buf->addc_offset>0)
						 {
							 forward--;
						 }
						 t=aa_table[8](lex_buf->ca_head);
					 }
					 if (VID_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 ca_addc(lex_buf,c);
						 t=aa_table[2](lex_buf->ca_head);
					 }
					 break;
				 }
			 case 6: /*other*/
				 {
					 if (lex_buf->addc_offset!=0)
					 {
						 sc_buf->addc_offset--; /*character never written to lex_buf set pointer back 1*/
					 }
					 if ((c==';'||c ==' ')&&VID_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t = aa_table[2](lex_buf->ca_head);
					 }
					 if ((c==';'||c ==' ')&&FPL_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t=aa_table[8](lex_buf->ca_head);
					 }
					 if ((c==';'||c ==' ')&&DIL_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t=aa_table[7](lex_buf->ca_head);
					 }
					 if ((c==';'||c ==' ')&&OIL_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t=aa_table[11](lex_buf->ca_head);
					 }
					 if ((c==';'||c ==' ')&&NUM_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t=aa_table[11](lex_buf->ca_head);
					 }
					 if ((c==';'||c ==' ')&&ZERO_FLAG==1)
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 t=aa_table[7](lex_buf->ca_head);
					 }
					 else
					 {
						 reset_flags(&FPL_FLAG,&DIL_FLAG,&OIL_FLAG,&ZERO_FLAG,&VID_FLAG,&NUM_FLAG);
						 ca_addc(lex_buf,c);
						 t=aa_table[9](lex_buf->ca_head);
					 }
					 break;
				 }
			 }
			 c=(lex_buf,sc_buf->ca_head[forward++]);/*add next character to the buffer*/
		 }
	 }
	 b_destroy(lex_buf);
	 return t;               
   }//end while(1)
}