Exemplo n.º 1
0
#include "list.c"

#undef T

/*
** two simple fnuctions for my example
*/

static void	init_link(t_a *l)
{
  static int i = 0;

  l->i = i++;
}

static void	print_list(T_LIST(t_a) **l)
{
  if (*l)
  {
    printf("i : %d\n", (*l)->value.i);
    print_list(&(*l)->next);
  }
}

/*
** Here, I create a list of 20 nodes
** Then, I delete some node
** FInally, I display my list and I delete it
*/

int	main()
Exemplo n.º 2
0
 *
 *  Copyright (C) 2002 by Massimiliano Ghilardi
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 */


#define T_TEMPLATE T_MAP(TEMPLATE)

hwfont T_CAT3(Tutf_,T_TEMPLATE,_to_UTF_16)[0x100] = {
#define EL(x) T_UTF(UTF_16,x),
    T_LIST(T_TEMPLATE,EL)
#undef EL
};

hwfont T_CAT(Tutf_UTF_16_to_,T_TEMPLATE) (hwfont c)
{
#define EL(x) +1
    enum {
        n = T_NLIST(T_TEMPLATE,EL) + 0, /* +0 in case T_NLIST() expands to nothing */
        n_power_of_2 = NEXT_POWER_OF_2(n)
    };
#undef EL
    
    static utf16_hash_table * table = NULL;
    
    /* a single 8-bit charset obviously cannot contain all unicode chars. this is just a best effort. */
Exemplo n.º 3
0
/*
 *
 *  Copyright (C) 2002,2018 by Massimiliano Ghilardi
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 */

hwfont Tutf_CP437_to_UTF_32[0x100] = {
#define EL(x) T_UTF(UTF_32,x),
	T_LIST(CP437,EL)
#undef EL
};

hwfont Tutf_UTF_32_to_CP437(hwfont c)
{
#define EL(x) +1
    enum {
        n = T_NLIST(CP437,EL) + 1,    /* +1 to manually map T_UTF_32_CHECK_MARK -> T_CP437_SQUARE_ROOT below */
        n_power_of_2 = NEXT_POWER_OF_2(n)
    };
#undef EL
    
    static utf32_hash_table * table = NULL;
    
    /* Codepage 437 (VGA) obviously cannot contain all unicode chars. this is just a best effort. */
    if (!table) {
	table = utf32_hash_create(Tutf_CP437_to_UTF_32, n, n_power_of_2);