Example #1
0
std::ostream &operator<<(std::ostream &os,
                         const GimbalCalibResidual *residual) {
  os << "P_s: " << array2str(residual->P_s, 3) << std::endl;
  os << "P_d: " << array2str(residual->P_d, 3) << std::endl;
  os << "Q_s: " << array2str(residual->Q_s, 2) << std::endl;
  os << "Q_d: " << array2str(residual->Q_d, 2) << std::endl;
  return os;
}
Example #2
0
const char*	var2str(const anon_nasl_var* v)
{
  static char	s1[16];

  if (v == NULL)
    return NULL;

  switch (v->var_type)
    {
    case VAR2_INT:
      snprintf(s1, sizeof(s1), "%d", v->v.v_int);
      return s1;		/* buggy if called twice in a row */

    case VAR2_STRING:
    case VAR2_DATA:
      return v->v.v_str.s_val == NULL ? "" : (const char*)v->v.v_str.s_val;

    case VAR2_UNDEF:
#if NASL_DEBUG > 1
      nasl_perror(NULL, "var2str: variable %s is undefined!\n", get_var_name(v));
#endif
      return NULL;

    case VAR2_ARRAY:
      return array2str(&v->v.v_arr);

    default:
#if NASL_DEBUG > 0
      nasl_perror(NULL, "var2str: variable %s has unhandled type %d\n",
		  get_var_name(v), v->var_type);
#endif
      return "";
    }
}
Example #3
0
std::ostream &operator<<(std::ostream &os,
                         const calib_gimbal_params_t &params) {
  os << "tau_s: " << array2str(params.tau_s, 6) << std::endl;
  os << "tau_d: " << array2str(params.tau_d, 6) << std::endl;
  os << "w1: " << array2str(params.w1, 3) << std::endl;
  os << "w2: " << array2str(params.w2, 3) << std::endl;
  os << "theta1_offset: " << *params.theta1_offset << std::endl;
  os << "theta2_offset: " << *params.theta2_offset << std::endl;

  // os << "Lamba 1 and 2: " << std::endl;
  // for (int i = 0; i < params.nb_measurements; i++) {
  //   os << params.Lambda1[i] << " " << params.Lambda2[i] << std::endl;
  // }

  return os;
}
Example #4
0
string HQLOperand::as_code_hql() const
{
    switch(type){
    case ID:
        return *data.str;
        break;
    case NIL:
        return "null";
        break;
    case BOOL:
        return data.boolean? "true" : "false";
        break;
    case NUM:
        return num2str(data.num);
        break;
    case STRING:
        return *data.str;
        break;
    case NUM_ARRAY:
    case STR_ARRAY:
        return array2str(data.array);
        break;
    case CONTAINS_ARG:
        return ((*data.array)[0].size()==1 && (*data.array)[0][0] == 0) ?
            "EACH BY " + (*data.array)[1] :
            (*data.array)[0] + " BY " +(*data.array)[1];
        break;
    case NODE:
        return node->to_hql();
        break;
    case COOP:
        return as_coop();
        break;
    case KW:
        switch(data.kw){
        case AUTO:
            return "AUTO";
            break;
        case TAUTO:
            return "*AUTO";
            break;
        case EACH:
            return "EACH";
            break;
        default:
            return "BAD-KW";
        }
        break;
    case FULLNAME:
        return "#" + num2str(data.fullname);
        break;
    default:
        break;
    }
    return "BAD-OBJECT";
}
Example #5
0
/*
 * Callback invoked when a remote device has requested to write to a
 * characteristic or descriptor.
 */
static void gatts_request_write_cb(int conn_id, int trans_id, bt_bdaddr_t *bda,
					int attr_handle, int offset, int length,
					bool need_rsp, bool is_prep,
					uint8_t *value)
{
	char buf[MAX_ADDR_STR_LEN];
	char valbuf[100];

	haltest_info("%s: conn_id=%d trans_id=%d bda=%s attr_handle=0x%x offset=%d length=%d need_rsp=%d is_prep=%d value=%s\n",
			__func__, conn_id, trans_id, bt_bdaddr_t2str(bda, buf),
			attr_handle, offset, length, need_rsp, is_prep,
			array2str(value, length, valbuf, sizeof(valbuf)));
}
Example #6
0
/* Converts btgatt_notify_params_t to string */
static char *btgatt_notify_params_t2str(const btgatt_notify_params_t *data,
								char *buf)
{
	char addr[MAX_ADDR_STR_LEN];
	char srvc_id[MAX_SRVC_ID_STR_LEN];
	char char_id[MAX_CHAR_ID_STR_LEN];
	char value[MAX_HEX_VAL_STR_LEN];

	sprintf(buf, "{bda=%s, srvc_id=%s, char_id=%s, val=%s, is_notify=%u}",
		bt_bdaddr_t2str(&data->bda, addr),
		btgatt_srvc_id_t2str(&data->srvc_id, srvc_id),
		btgatt_gatt_id_t2str(&data->char_id, char_id),
		array2str(data->value, data->len, value, sizeof(value)),
							data->is_notify);
	return buf;
}
Example #7
0
File: exec.c Project: OPSF/uClinux
static char*
cell2str(lex_ctxt* lexic, tree_cell* c)
{
  char	* p;
  tree_cell	*c2;
  nasl_array	*a;

  if (c == NULL || c == FAKE_CELL)
    {
#if NASL_DEBUG > 0
      nasl_perror(lexic, "Cannot convert NULL or FAKE cell to string\n");
#endif
      return NULL;
    }
      
  switch(c->type)
    {
    case CONST_INT:
      p = malloc(16);
      if (p != NULL)
	snprintf(p, 16, "%d", c->x.i_val);
      return p;
      
    case CONST_STR:
    case CONST_DATA:
      if ( c->x.str_val == NULL)
	p = estrdup("");
      else
	p = nasl_strndup(c->x.str_val, c->size);
      return p;

    case REF_ARRAY:
    case DYN_ARRAY:
      a = c->x.ref_val;
      p = (char*)array2str(a);
      return estrdup(p);

    default:
      c2 = nasl_exec(lexic, c);
      p = cell2str(lexic, c2);
      deref_cell(c2);
      if (p == NULL)
	p = estrdup("");
      return p;
    }
}
Example #8
0
static char *btgatt_unformatted_value_t2str(const btgatt_unformatted_value_t *v,
							char *buf, int size)
{
	return array2str(v->value, v->len, buf, size);
}