Пример #1
0
int op_ifjmp(target_x86_t *target_x86, int num)
{
	char line[STR_LINE_SIZE];
	char *line_code;
	char cmd[STR_SIZE];
	char param1[STR_SIZE];
	char param2[STR_SIZE];
	var_t *var;
	int res;
	
	line_code = (char *) array_get(target_x86->array_line, num);
	
	res = sscanf(line_code, "%s %s %s", cmd, param1, param2);
	
	var = target_x86_get_var(target_x86, param1);

	sprintf(line, "mov eax, %s", var->addr);
	add_line(target_x86, TARGET_TEXT, line);
	
	add_line(target_x86, TARGET_TEXT, "cmp eax, 1");
	sprintf(line, "je %s", param2);
	add_line(target_x86, TARGET_TEXT, line);

	return 0;
}
Пример #2
0
char		*get_next_line(int fd)
{
  static int	nbread;
  static char	buff[BUFF_SIZE];
  char		*line;
  int		pos;

  for (line = 0, pos = 0; ; pos++)
    {
      if (begin >= nbread)
        {
          begin = 0;
          if (!(nbread = xread(fd, buff, BUFF_SIZE)))
            return (line);
          pos = 0;
        }
      if (buff[begin + pos] == '\n')
        {
          line = add_line(line, buff, pos);
          return (line);
        }
      if (begin + pos + 1 == nbread)
        line = add_line(line, buff, pos + 1);
    }
}
Пример #3
0
int			get_next_line(int const fd, char **line)
{
	static char	*stock = NULL;
	char		buff[BUFF_SIZE + 1];
	char		*tmp;
	long long	ret;

	if (!line || fd < 0)
		return (-1);
	if (stock == NULL)
		stock = ft_strnew(0);
	while (!ft_strchr(stock, '\n'))
	{
		ret = read(fd, buff, BUFF_SIZE);
		if (ret == -1)
			return (ret);
		if (ret == 0)
			return (add_line(line, stock));
		buff[ret] = '\0';
		tmp = ft_strjoin(stock, buff);
		ft_strdel(&stock);
		stock = tmp;
	}
	return (add_line(line, stock));
}
Пример #4
0
static void 
add_bezier_arc (spline *s,
		double x0, double y0,
		double x1, double y1,
		double x2, double y2,
		double x3, double y3)
{
  double midx01, midx12, midx23, midlsegx, midrsegx, cx,
  midy01, midy12, midy23, midlsegy, midrsegy, cy;
    
  mid_point (x0, y0, x1, y1, &midx01, &midy01);
  mid_point (x1, y1, x2, y2, &midx12, &midy12);
  mid_point (x2, y2, x3, y3, &midx23, &midy23);
  mid_point (midx01, midy01, midx12, midy12, &midlsegx, &midlsegy);
  mid_point (midx12, midy12, midx23, midy23, &midrsegx, &midrsegy);
  mid_point (midlsegx, midlsegy, midrsegx, midrsegy, &cx, &cy);    

  if (can_approx_with_line (x0, y0, midlsegx, midlsegy, cx, cy))
    add_line (s, x0, y0, cx, cy);
  else if ((midx01 != x1) || (midy01 != y1) || (midlsegx != x2)
	   || (midlsegy != y2) || (cx != x3) || (cy != y3))
    add_bezier_arc (s, x0, y0, midx01, midy01, midlsegx, midlsegy, cx, cy);

  if (can_approx_with_line (cx, cy, midx23, midy23, x3, y3))
    add_line (s, cx, cy, x3, y3);
  else if ((cx != x0) || (cy != y0) || (midrsegx != x1) || (midrsegy != y1)
	   || (midx23 != x2) || (midy23 != y2))  
    add_bezier_arc (s, cx, cy, midrsegx, midrsegy, midx23, midy23, x3, y3);
}
Пример #5
0
int op_print(target_x86_t *target_x86, int num)
{
	char line[STR_LINE_SIZE];
	char *line_code;
	char name[STR_SIZE];
	char str[STR_SIZE];
	char cmd[STR_SIZE];
	char param[STR_SIZE];
	var_t *var;
	int res;
	
	line_code = (char *) array_get(target_x86->array_line, num);
	
	res = sscanf(line_code, "%s %s", cmd, param);
	
	var = target_x86_get_var(target_x86, param);

	sprintf(line, "push dword %s", var->addr);
	add_line(target_x86, TARGET_TEXT, line);
	
	sprintf(line, "push dword str_%s", param);
	add_line(target_x86, TARGET_TEXT, line);

	add_line(target_x86, TARGET_TEXT, "call printf");
	add_line(target_x86, TARGET_TEXT, "add esp, 2*4");

	sprintf(name, "str_%s", param);
	sprintf(str, "%s = %%d", param);
	add_data_string(target_x86, name, str);
	
	return 0;
}
Пример #6
0
void DebugLine::add_cone(const Vector3& from, const Vector3& to, f32 radius, const Color4& color, u32 segments)
{
	Vector3 dir = to - from;
	normalize(dir);
	const Vector3 arr[] =
	{
		{ dir.z, dir.z, -dir.x -dir.y },
		{ -dir.y -dir.z, dir.x, dir.x }
	};
	const int idx = ((dir.z != 0.0f) && (-dir.x != dir.y));
	Vector3 right = arr[idx];
	normalize(right);

	const f32 incr = 360.0f / (f32)(segments >= 3 ? segments : 3);
	f32 deg0 = 0.0f;
	for (u32 ss = 0; ss < segments; ++ss, deg0 += incr)
	{
		const f32 rad0 = frad(deg0);
		const f32 rad1 = frad(deg0 + incr);

		const Vector3 from0 = right*cos(-rad0) + cross(dir, right)*sin(-rad0) + dir*dot(dir, right)*(1.0f-cos(-rad0));
		const Vector3 from1 = right*cos(-rad1) + cross(dir, right)*sin(-rad1) + dir*dot(dir, right)*(1.0f-cos(-rad1));

		add_line(from + radius*from0, to, color);
		add_line(from + radius*from0, from + radius*from1, color);
	}
}
Пример #7
0
void DebugDrawManager::add_sphere( const hkVector4& center, float radius, uint32_t color, bool bDepth)
{
    const uint32_t deg_step = 15;
    hkVector4 tmp1, tmp2;
    hkVector4 start, end;

    for (uint32_t deg = 0; deg < 360; deg += deg_step)
    {
        float _rad0 = bx::toRad((float)deg);
        float _rad1 = bx::toRad((float)(deg + deg_step));

        // XZ plane
        start.set(cosf(_rad0) * radius, 0, -sinf(_rad0) * radius);
        end.set(cosf(_rad1) * radius, 0, -sinf(_rad1) * radius);
        tmp1.setAdd(start, center);
        tmp2.setAdd(end, center);
        add_line(tmp1, tmp2, color, bDepth);

        // XY plane
        start.set(cosf(_rad0) * radius, sinf(_rad0) * radius, 0);
        end.set(cosf(_rad1) * radius, sinf(_rad1) * radius, 0);
        tmp1.setAdd(start, center);
        tmp2.setAdd(end, center);
        add_line(tmp1, tmp2, color, bDepth);

        // YZ plane
        start.set(0, sinf(_rad0) * radius, -cosf(_rad0) * radius);
        end.set(0, sinf(_rad1) * radius, -cosf(_rad1) * radius);
        tmp1.setAdd(start, center);
        tmp2.setAdd(end, center);
        add_line(tmp1, tmp2, color, bDepth);
    }
}
Пример #8
0
void DebugDrawManager::add_cycle( const hkVector4& pos, const hkVector4& d, float r, uint32_t color, bool bDepth)
{
#ifdef HAVOK_COMPILE
    hkQuaternion    orientation;
    hkVector4       normal = d;
    const int       steps=64;
    normal.normalize3();
    hkQuaternionUtil::_computeShortestRotation(hkVector4(0,0,1,0),normal, orientation);
    hkVector4       p;
    p.setRotatedDir(orientation,hkVector4(r,0,0,0));
    p.add4(pos);

    for(int i=1;i<=steps;++i)
    {
        const hkReal    angle=i/(hkReal)steps*HK_REAL_PI*2;
        hkVector4       v(0,0,0,0);
        v(0)    =   r*hkMath::cos(angle);
        v(1)    =   r*hkMath::sin(angle);
        hkVector4       c;
        c.setRotatedDir(orientation,v);
        c.add4(pos);
        add_line(p, c, color, bDepth);
        p=c;
    }

    p.setAddMul4(pos, normal, r/4.0f);
    add_line(pos, p, color, bDepth);
#endif
}
int				get_next_line(int const fd, char **line)
{
	static t_list	*lst = NULL;
	t_mem			*mem;
	char			*buff;
	int				ret;

	if (!(buff = ft_strnew(BUFF_SIZE)) || !line || fd < 0 ||
		!(mem = get_mem_fd(fd, &lst)) ||
		!(*line = ft_strnew(1)))
		return (free(buff), EX_ERROR);
	if (*(mem->mem) != '\0')
		if (add_line(line, &(mem->mem), mem->mem) == EX_SUCCESS)
			return (free(buff), EX_SUCCESS);
	mem->mem = EMPTY;
	while ((ret = read(fd, buff, BUFF_SIZE)) > 0)
	{
		if (add_line(line, &(mem->mem), buff) == EX_SUCCESS)
			return (EX_SUCCESS);
		buff = ft_memset(buff, '\0', BUFF_SIZE);
	}
	if (ret < 0)
		return (free(buff), EX_ERROR);
	if (!ret && !ft_strcmp(buff, EMPTY) && !ft_strcmp(*line, EMPTY))
		return (free(buff), EX_EOF);
	return (free(buff), EX_SUCCESS);
}
static void add_string(struct menu_priv_s* priv, char* l) {
  char* eol = strchr(l,'\n');
  int ll =  priv->last_line > 0 ? priv->last_line - 1 : priv->buf_lines-1;

  if(priv->num_lines <= 0 || priv->add_line || eol == l) {
    add_line(priv,l);
    priv->add_line = 0;
    return;
  }

  if(eol) {
    eol[0] = '\0';
    add_string(priv,l);
    if(eol[1]) {
      add_line(priv,eol+1);
      priv->add_line = 0;
    } else
      priv->add_line = 1;
    return;
  }
  priv->lines[ll] = realloc(priv->lines[ll],strlen(priv->lines[ll]) + strlen(l) + 1);
  if ( priv->lines[ll] != NULL )
  {
    strcat(priv->lines[ll],l);
  }
}
Пример #11
0
void print_can_array( int * can_id_print_list, int num_can_ids )
{
    int i, j;

    int print_all_ids = 0;

    if( num_can_ids == 0 )
    {
        print_all_ids = 1;
    }

    add_line( "" );
    add_line( "Raw CAN dump:" );

    for( i = 0; i < CAN_MSG_ARRAY_SIZE; i++ )
    {
        if( print_all_ids && can_msg_array[ i ].can_id > 0 )
        {
            print_info_can_array_index( i );
        }
        else
        {
            for( j = 0; j < num_can_ids; j++ )
            {
                if( can_id_print_list[ j ] == can_msg_array[ i ].can_id )
                {
                    print_info_can_array_index( i );
                }
            }
        }
    }
}
Пример #12
0
void DebugLine::add_axes(const Matrix4x4& m, f32 length)
{
	const Vector3 pos = translation(m);
	add_line(pos, pos + x(m)*length, COLOR4_RED);
	add_line(pos, pos + y(m)*length, COLOR4_GREEN);
	add_line(pos, pos + z(m)*length, COLOR4_BLUE);
}
Пример #13
0
static gboolean
write_section (int fd, struct Node *n, const gchar * params)
{
  Entry *e = n->entries;
  gchar **p;

  add_line (fd, g_strdup_printf ("[%s]", n->gst));

  /* first we add the comments but not for iso-speed */
  if (g_strcmp0 (n->gst, "iso-speed")) {
    while (e->name) {
      if (!add_line (fd, g_strdup_printf ("# %d = %s", e->val, e->name))) {
        return FALSE;
      }
      ++e;
    }
  }

  /* now the actual work */
  g_print ("%s (%s) => %s\n", n->gst, n->droid, params);

  p = g_strsplit (params, ",", -1);

  e = n->entries;
  while (e->name) {
    gchar **tmp = p;
    while (*tmp) {
#if 0
      g_print ("comparing %s and %s\n", e->droid, *tmp);
#endif

      /* focus needs special handling because we use continuous to indicate continuous-picture
       * or continuous-video and droidcamsrc decides depending on the mode */
      if (!g_strcmp0 (*tmp, e->droid) || (!g_strcmp0 (e->droid, "continuous")
              && (!g_strcmp0 (*tmp, "continuous-picture")
                  || !g_strcmp0 (*tmp, "continuous-video")))) {
        if (!add_line (fd, g_strdup_printf ("%d = %s", e->val, e->droid))) {
          g_strfreev (p);
          return FALSE;
        }
        break;
      }
      ++tmp;
    }
    ++e;
  }

  g_strfreev (p);

  write (fd, "\n", 1);

  return TRUE;
}
Пример #14
0
int op_let_un_math(target_x86_t *target_x86, char *str_dst, char *str_src, char *op)
{
	char line[STR_LINE_SIZE];
	var_t *var;

	if( is_variable(str_src) )
	{
		var_t *var;
		
		var = target_x86_get_var(target_x86, str_src);
		str_src = var->addr;
	}
	
	var = target_x86_get_var(target_x86, str_dst);
	str_dst = var->addr;

	sprintf(line, "mov eax, %s", str_src);
	add_line(target_x86, TARGET_TEXT, line);

	if( strcmp(op, "-") == 0 )
	{
		add_line(target_x86, TARGET_TEXT, "neg eax");
	}
	
	if( strcmp(op, "not") == 0 )
	{
		add_line(target_x86, TARGET_TEXT, "neg eax");
	}

	if( strcmp(op, "neg") == 0 )
	{
		add_line(target_x86, TARGET_TEXT, "mov ecx, 0");

		add_line(target_x86, TARGET_TEXT, "cmp eax, 0");
		sprintf(line, "jne .label_%d", target_x86->label_count);
		add_line(target_x86, TARGET_TEXT, line);
		
		add_line(target_x86, TARGET_TEXT, "mov ecx, 1");

		sprintf(line, ".label_%d:", target_x86->label_count);
		add_line(target_x86, TARGET_TEXT, line);
		
		add_line(target_x86, TARGET_TEXT, "mov eax, ecx");

		target_x86->label_count++;
	}
	
	sprintf(line, "mov %s, eax", str_dst);
	add_line(target_x86, TARGET_TEXT, line);
	
	return 0;
}
Пример #15
0
int main(int argc, char *argv[])
{
	struct libscols_table *tb;
	struct libscols_line *ln, *xln;

	setlocale(LC_ALL, "");	/* just to have enable UTF8 chars */

	scols_init_debug(0);

	tb = scols_new_table();
	if (!tb)
		err(EXIT_FAILURE, "faild to create output table");

	scols_table_enable_colors(tb, 1);
	setup_columns(tb);

	ln = add_line(tb, NULL, "A");
	add_line(tb, ln, "aa");
	add_line(tb, ln, "ab");

	ln = add_line(tb, NULL, "B");
	xln = add_line(tb, ln, "ba");
	add_line(tb, xln, "baa");
	add_line(tb, xln, "bab");
	add_line(tb, ln, "bb");

	scols_print_table(tb);
	scols_unref_table(tb);
	return EXIT_SUCCESS;
}
Пример #16
0
int main(int argc, char *argv[])
{
	struct libscols_table *tb;
	struct libscols_symbols *sy;
	struct libscols_cell *title;

	setlocale(LC_ALL, "");	/* just to have enable UTF8 chars */

	scols_init_debug(0);

	tb = scols_new_table();
	if (!tb)
		err(EXIT_FAILURE, "failed to create output table");

	scols_table_enable_colors(tb, isatty(STDOUT_FILENO));
	setup_columns(tb);
	add_line(tb, "foo", "bla bla bla");
	add_line(tb, "bar", "alb alb alb");

	title = scols_table_get_title(tb);

	/* right */
	scols_cell_set_data(title, "This is right title");
	scols_cell_set_color(title, "red");
	scols_cell_set_flags(title, SCOLS_CELL_FL_RIGHT);
	scols_print_table(tb);

	/* center */
	sy = scols_new_symbols();
	if (!sy)
		err_oom();
	scols_table_set_symbols(tb, sy);

	scols_symbols_set_title_padding(sy, "=");
	scols_cell_set_data(title, "This is center title (with padding)");
	scols_cell_set_color(title, "green");
	scols_cell_set_flags(title, SCOLS_CELL_FL_CENTER);
	scols_print_table(tb);

	/* left */
	scols_symbols_set_title_padding(sy, "-");
	scols_cell_set_data(title, "This is left title (with padding)");
	scols_cell_set_color(title, "blue");
	scols_cell_set_flags(title, SCOLS_CELL_FL_LEFT);
	scols_print_table(tb);

	scols_unref_table(tb);
	return EXIT_SUCCESS;
}
Пример #17
0
void DebugDrawManager::add_quad(const hkVector4& center, float width, float height, uint32_t color, bool bDepth)
{
    float x = center.getSimdAt(0);
    float y = center.getSimdAt(1);
    float z = center.getSimdAt(2);
    hkVector4 v0, v1, v2, v3;
    v0.set(x-width/2, y, z-height/2);
    v1.set(x+width/2, y, z-height/2);
    v2.set(x+width/2, y, z+height/2);
    v3.set(x-width/2, y, z+height/2);
    add_line(v0, v1, color, bDepth);
    add_line(v1, v2, color, bDepth);
    add_line(v2, v3, color, bDepth);
    add_line(v3, v0, color, bDepth);
}
Пример #18
0
void DebugDrawManager::add_axis( const hkQsTransform& t, float size , bool bDepth)
{
#ifdef HAVOK_COMPILE
    const hkVector4& start_pos = t.m_translation;
    hkVector4 x_end;
    x_end.setTransformedPos(t, hkVector4(size,0,0));
    hkVector4 y_end;
    y_end.setTransformedPos(t, hkVector4(0,size,0));
    hkVector4 z_end;
    z_end.setTransformedPos(t, hkVector4(0,0,size));
    add_line(start_pos, x_end, RGBA(255,0,0,255), bDepth);
    add_line(start_pos, y_end, RGBA(0,255,0,255), bDepth);
    add_line(start_pos, z_end, RGBA(0,0,255,255), bDepth);
#endif
}
Пример #19
0
int op_end_function(target_x86_t *target_x86, int num)
{
	char line[STR_LINE_SIZE];
	
	//sprintf(line, "; %d", num);
	//add_line(target_x86, TARGET_TEXT, line);
		
	add_line(target_x86, TARGET_TEXT, "");
	add_line(target_x86, TARGET_TEXT, "mov esp, ebp");
	add_line(target_x86, TARGET_TEXT, "pop ebp");
	add_line(target_x86, TARGET_TEXT, "ret");
	add_line(target_x86, TARGET_TEXT, "");

	return 0;
}
Пример #20
0
gfarm_error_t
register_db(void)
{
	gfarm_error_t e, e_save = GFARM_ERR_NO_ERROR;
	int len, lineno;
	char line[LINE_BUFFER_SIZE];

	if (fgets(line, sizeof line, stdin) == NULL)
		return (GFARM_ERR_NO_ERROR);
	len = strlen(line);
	for (lineno = 1;; lineno++) {
		if (len > 0 && line[len - 1] == '\n') {
			line[len - 1] = '\0';
		} else {
			fprintf(stderr, "line %d: too long line\n", lineno);
			if (e_save == GFARM_ERR_NO_ERROR)
				e_save = GFARM_ERR_INVALID_ARGUMENT;
			do {
				if (fgets(line, sizeof line, stdin) == NULL)
					return (e_save);
				len = strlen(line);
			} while (len == 0 || line[len - 1] != '\n');
			continue;
		}
		e = add_line(line, lineno);
		if (e_save == GFARM_ERR_NO_ERROR)
			e_save = e;
		if (fgets(line, sizeof line, stdin) == NULL)
			break;
		len = strlen(line);
	}
	return (e_save);
}
Пример #21
0
static void
place_line_x(int x, int y)
{
    int		    dx, dy;
    canvas_leftbut_proc = null_proc;
    canvas_middlebut_proc = null_proc;
    canvas_rightbut_proc = null_proc;
    canvas_locmove_proc = null_proc;
    canvas_ref_proc = null_proc;
    adjust_pos(x, y, fix_x, fix_y, &x, &y);
    dx = x - fix_x;
    dy = y - fix_y;
    translate_line(new_l, dx, dy);
    clean_up();
    set_latestline(new_l);
    if (return_proc == copy_selected) {
	add_line(new_l);
	adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, True);
	free_linkinfo(&cur_links);
    } else {
	list_add_line(&objects.lines, new_l);
	adjust_links(cur_linkmode, cur_links, dx, dy, 0, 0, 1.0, 1.0, False);
	set_lastposition(fix_x, fix_y);
	set_newposition(x, y);
	set_lastlinkinfo(cur_linkmode, cur_links);
	cur_links = NULL;
	set_action_object(F_MOVE, O_POLYLINE);
    }
    set_modifiedflag();
    redisplay_line(new_l);
    /* turn back on all relevant markers */
    update_markers(new_objmask);
    (*return_proc) ();
    draw_mousefun_canvas();
}
static void enter_cmd(menu_t* menu) {
  history_t* h;
  char input[strlen(mpriv->cur_history->buffer) + strlen(mpriv->prompt) + 1];

  sprintf(input,"%s%s",mpriv->prompt,mpriv->cur_history->buffer);
  add_line(mpriv,input);

  if(mpriv->history == mpriv->cur_history) {
    if(mpriv->history_size >= mpriv->history_max) {
      history_t* i;
      for(i = mpriv->history ; i->prev ; i = i->prev)
	/**/;
      i->next->prev = NULL;
      free(i->buffer);
      free(i);
    } else
      mpriv->history_size++;
    h = calloc(1,sizeof(history_t));
    h->size = 255;
    h->buffer = calloc(h->size,1);
    h->prev = mpriv->history;
    mpriv->history->next = h;
    mpriv->history = h;
  } else
    mpriv->history->buffer[0] = '\0';

  mpriv->cur_history = mpriv->history;
  //mpriv->input = mpriv->cur_history->buffer;
}
Пример #23
0
v3dmc_object load_object(GLchar *filename){
	FILE *file;
	GLint i,npoints,nlines,ntriangles,nquads;
	v3dmc_object obj = object();
	v3dmc_point p;
	v3dmc_line l;
	v3dmc_triangle t;
	v3dmc_quad q;
	file = fopen(filename,"r");
	if(file!=NULL){
		fread(&npoints,sizeof(int),1,file);
		fread(&nlines,sizeof(int),1,file);
		fread(&ntriangles,sizeof(int),1,file);
		fread(&nquads,sizeof(int),1,file);
		for(i=0;i<npoints;i++){
			read_point(file,&p);
			add_point(&obj,p);
		}
		for(i=0;i<nlines;i++){
			fread(&l,sizeof(v3dmc_line),1,file);
			add_line(&obj,l);
		}
		for(i=0;i<ntriangles;i++){
			fread(&t,sizeof(v3dmc_triangle),1,file);
			add_triangle(&obj,t);
		}
		for(i=0;i<nquads;i++){
			fread(&q,sizeof(v3dmc_quad),1,file);
			add_quad(&obj,q);
		}
		fclose(file);
	}
	return obj;
}
Пример #24
0
void load_vocab(vocab_t **listavocab) {
	FILE *vocab;
	char *homedir = NULL;
	
	homedir = (char *)calloc((strlen(getenv("HOME"))+strlen("/.himitsu/save"))+1,sizeof(char));
	strcpy(homedir,getenv("HOME"));
	strcpy((homedir+strlen(homedir)),"/.himitsu");
	vocab = fopen(homedir, "r");
	if (!vocab)
		mkdir(homedir,0755);
	else
		fclose(vocab);
	
	strcpy((homedir+strlen(homedir)),"/save");

	vocab = fopen(homedir, "a");
	if (!vocab)
		exit_mem(EXIT_FAILURE,"Error opening vocabulary file.");
	else if (fclose(vocab) != 0)
		exit_mem(EXIT_FAILURE,"Error closing vocabulary file.");

	vocab = fopen(homedir, "r");
	if (!vocab)
		exit_mem(EXIT_FAILURE,"Vocabulary file can't be opened.");
	else
		add_line(listavocab, vocab,0);

	if (fclose(vocab) != 0) 
		exit_mem(EXIT_FAILURE,"Error closing vocabulary file.\n");
	if (homedir) {
		free(homedir);
		homedir = NULL;
	}
	
}
Пример #25
0
int Program::add_line_at(Line *newline, int position)
{
   if (position <= 0){
     

      newline->set_next(_head); // newline pointe sur le premier.
      _head->set_prev(newline);
      _head = newline;         // newline est maintenant premier.
      ++_length;
      return 1;
   }

   else if (position >= _length)
      add_line(newline);

   else
   {
      
      Line * prec = _head;
     
      // On se place sur le precedent.
      for (int i = 0; i < position - 1; ++i){
	 prec = prec->get_next();
      }

      // On ajuste les pointeurs.
      newline->set_next(prec->get_next());
      prec->set_next(newline);
      ++_length;
      return 1;
   }
   return 1;
}
Пример #26
0
void Console::new_line()
{
	if (m_input.size() == 0)
		return;
	add_line(m_input.c_str());
	m_input.clear();
}
Пример #27
0
void get_simply_LU_fatoration(Matrix *A, Matrix **L, Matrix **U){
	/*
	 *acha a fatoração LU sem tentar permutações
	 * */
	int i, j;
	double l;

	*U = copy_M(A);

	*L = new_M((*U)->rows, (*U)->columns);
		//L matriz triangular inferior especial
	for(i = 0; i < (*L)->rows; i++)
		(*L)->a[i][i] = 1;//diagonal 1
	for(i = 0; i < (*L)->rows; i++)
		for(j = i + 1; j < (*L)->columns; j++)
			(*L)->a[i][j] =0;//superior 0


		
	for(j = 0; j < (*U)->columns; j++)
		{
		if((*U)->a[j][j] == 0)
			printf("A matriz não é regular!\n");
		else
			{
			for(i = j+1; i < (*U)->rows; i++)
				{
				l = -1.0*(*U)->a[i][j]/(*U)->a[j][j];
				add_line((*U), j, l, i);
				(*L)->a[i][j] = -1.0 * l;
				}//end for
			}//end else
		}//end for
	}
Пример #28
0
int	init(char *file, int ***grid, t_unit **unit)
{
  int	fd;
  int	x;
  int	y;
  char	*tmp;

  if (!((fd = my_strlen(file)) > 4 && my_strcmp(file + fd - 4, ".map") == 0 &&
      (fd = open(file, O_RDONLY)) != -1))
    return (my_error(EO));
  my_putstr(FE);
  file[my_strlen(file) - 4] = 0;
  x = 0;
  y = 0;
  *grid = NULL;
  while ((tmp = get_next_line(fd)) != NULL && tmp[0] != 0)
    {
      if (add_line(tmp, grid, &x) == 1)
	return (my_error(GE));
      y += 1;
    }
  if (x < 3 || y < 3)
    return (my_error(GS) - 1);
  return (init_end(*grid, unit, x, y, fd));
}
Пример #29
0
	void ViewCompilerImpl::codegen_constructor(const std::string &name)
	{
		const ViewClassType &type = class_types[name];
		if (type.name.empty())
			return;

		add_line("");
		add_line("\tinline %1::%2()", type.name, type.name);
		add_line("\t{");

		codegen_constructor_add_child(type.children, "");
		codegen_constructor_set_style("", type);
		codegen_constructor_set_value("", type);

		add_line("\t}");
	}
Пример #30
0
Point3D const StatusStructure::process_event(Event* event, EventStructure& event_structure) {
    Point3D result(0.f, 0.f, -1.f);
    Event::EventType type(event->get_type());

    switch (type) {
        case Event::START: {
            StartEvent* start_event(reinterpret_cast<StartEvent*>(event));
            //std::cout << "Processing " << *start_event << std::endl;
            add_line(start_event, event_structure);
        } break;

        case Event::END: {
            EndEvent* end_event(reinterpret_cast<EndEvent*>(event));
            //std::cout << "Processing " << *end_event << std::endl;
            remove_line(end_event, event_structure);
        } break;

        case Event::INTERSECTION: {
            IntersectionEvent* intersection_event(reinterpret_cast<IntersectionEvent*>(event));
            //std::cout << "Processing " << *intersection_event << std::endl;
            swap(intersection_event, event_structure);
            result = intersection_event->get_position();
        } break;

        default: break;

    }
//    std::cout << std::endl;

    return result;
}