Esempio n. 1
0
void		ft_print_comb(void)
{
	char	a;
	char	b;
	char	c;

	a = 0;
	while (a <= '7')
	{
		b = a + 1;
		while (b <= '8')
		{
			c = b + 1;
			while (c <= '9')
			{
				ft_putchar(a);
				ft_putchar(b);
				ft_putchar(c);
				if (a != '7' || b != '8' || c != '9')
					ft_write();
				c++;
			}
			b++;
		}
		a++;
	}
}
Esempio n. 2
0
void	ft_signal_cont(int sigint)
{
	if (sigint != SIGCONT)
		return ;
	tcsetattr(0, TCSADRAIN, &g_term->termios);
	ft_write(g_term);
}
Esempio n. 3
0
static void		flag_ws(t_printf *pf, t_pfopt *opt, wchar_t *wstr)
{
	const int		len = ft_wstrlen(wstr) * 4;
	char			str[len];
	int				length;

	length = ft_wstrnconv(str, wstr,
		(opt->flags & PFLAG_PRECI) ? opt->preci : len);
	margin_before(pf, opt, length);
	ft_write(pf->out, str, length);
	pf->printed += length;
	margin_after(pf, opt, length);
}
Esempio n. 4
0
void	ft_terminal_run(t_term *term)
{
	t_arg	*elem;
	int		key;

	elem = term->arg_list->first;
	ft_write(term);
	ft_move_to(term, elem->position->x, elem->position->y);
	while (42)
	{
		key = 0;
		read(STDIN_FILENO, &key, 4);
		if (term->status)
			ft_check_keys(term, key);
		else if (key == FT_KEY_ESCAPE && !term->status)
			ft_key_quit(term);
		else
			ft_key_return(term);
	}
}
Esempio n. 5
0
int			exec_subformat(t_out *out, char const *fmt, char end, va_list *ap)
{
	uint32_t const	repeat = (out->precision > 0) ? out->precision : 1;
	uint32_t		i;
	t_str_out		str_out;
	int				len;

	str_out = STR_OUT();
	out->precision = 0;
	len = put_subformat(V(&str_out), fmt, end, ap);
	ft_putpad_left(out, str_out.buff_i * repeat);
	i = 0;
	while (i < repeat)
	{
		ft_write(out, str_out.buff, str_out.buff_i);
		i++;
	}
	ft_putpad_right(out, str_out.buff_i * repeat);
	ft_str_out_clear(&str_out);
	return (len);
}
Esempio n. 6
0
void			flag_s(t_printf *pf, t_pfopt *opt)
{
	char			*str;
	int				length;

	str = va_arg(*(pf->ap), char*);
	if ((opt->format == 'S' || opt->length == pflen_l) && str != NULL)
	{
		flag_ws(pf, opt, (wchar_t*)str);
		return ;
	}
	if (str == NULL)
		str = "(null)";
	if (opt->flags & PFLAG_PRECI)
		length = strmaxlen(str, opt->preci);
	else
		length = ft_strlen(str);
	margin_before(pf, opt, length);
	pf->printed += length;
	ft_write(pf->out, str, length);
	margin_after(pf, opt, length);
}
void	ft_print_comb2(void)
{
	int a;
	int b;
	int x;
	int y;

	a = '0';
	b = '0';
	x = '0';
	y = '1';
	while (a <= '9')
	{
		while (b <= '9')
		{
			while (x <= '9')
			{
				while (y <= '9')
				{
 					ft_write(a, b, x, y);
					y++;
				}
			x++;
			if (a != '0' && b == '0')
				y = b + 1;
			else
				y = '0';
			}
		b++;
		x = a;
		y = b + 1;
		}
	a++;
	b = '0';
	}
}
Esempio n. 8
0
unsigned int test_figtree(unsigned int seed, int threadid) {
    figtree_t ft;
    int i;
    byte_index_t j;
    figtree_value_t file[MAX_FILE_SIZE];
    figtree_value_t* res;

    for (j = 0; j < MAX_FILE_SIZE; j++) {
        file[j] = MAGIC;
    }
    ft_init(&ft);

    i = 0;
    while (i < NUM_ITERATIONS) {
        if (((++i) & PRINT_FREQ_MASK) == 0) {
            printf("Thread %d: iteration 0x%x (%d) [height = %d]\n", threadid,
                   i, i, ft.root->HEIGHT);
        }
        byte_index_t start = (byte_index_t) (rand_r(&seed) & BYTE_INDEX_MASK);
        byte_index_t end = start +
            (byte_index_t) (rand_r(&seed) & MAX_WRITE_MASK);
        figtree_value_t value = (figtree_value_t) rand_r(&seed);
        if (end >= MAX_FILE_SIZE) {
            end = MAX_FILE_SIZE - 1;
        }
        ft_write(&ft, start, end, value);
        for (j = start; j <= end; j++) {
            file[j] = value;
        }
        
        for (j = 0; j < MAX_FILE_SIZE; j++) {
            res = ft_lookup(&ft, j);
            if (res == NULL) {
                value = MAGIC;
            } else {
                value = *res;
            }
            if (value != file[j]) {
                fprintf(stderr,
                        "[ERROR] Byte %lu is not 0x%x (instead, it is 0x%x)\n",
                        (long unsigned int) j, (unsigned int) file[j],
                        (unsigned int) value);
                goto done;
            }
        }
        for (start = 0; start < MAX_FILE_SIZE; start++) {
            for (end = start; end < MAX_FILE_SIZE; end++) {
                figiter_t* figiter;
                fig_t fig;

                figiter = ft_read(&ft, start, end);
                j = start;
                while (fti_next(figiter, &fig)) {
                    /* Verify that the fig is in bounds. */
                    if (fig.irange.left < start || fig.irange.right > end
                        || fig.irange.left > fig.irange.right) {
                        fprintf(stderr, "[ERROR] Invalid fig [%lu, %lu]\n",
                                (long unsigned int) fig.irange.left,
                                (long unsigned int) fig.irange.right);
                    }
                    /* Verify that there's nothing in the file before the
                     * range.
                     */
                    for (; j < fig.irange.left; j++) {
                        if (file[j] != (figtree_value_t) MAGIC) {
                            fprintf(stderr,
                                    "[ERROR] Byte %lu is not 0x%x (no range)\n",
                                    (long unsigned int) j,
                                    (unsigned int) file[j]);
                        }
                    }
                    /* Verify that everything in the range is correct. */
                    for (; j <= fig.irange.right; j++) {
                        if (file[j] != fig.value) {
                            fprintf(stderr,
                                    "[ERROR] Byte %lu is not 0x%x (got 0x%x)\n",
                                    (long unsigned int) j,
                                    (unsigned int) file[j],
                                    (unsigned int) value);
                        }
                    }
                }
                /* Make sure that there's nothing past the last range. */
                for (; j <= end; j++) {
                    if (file[j] != (figtree_value_t) MAGIC) {
                        fprintf(stderr,
                                "File at byte %lu is not 0x%x (no range)\n",
                                (long unsigned int) j, (unsigned int) file[j]);
                    }
                }
                fti_free(figiter);
            }
        }
    }

    done:
    printf("Deallocating the Fig Tree...\n");
    ft_dealloc(&ft);

    printf("Done.\n");

    return seed;
}
Esempio n. 9
0
void	ft_signal_write(int sigint)
{
	if (sigint != SIGWINCH)
		return ;
	ft_write(g_term);
}