示例#1
0
int main(void) {
  struct list *l1 = construct_list
    ('a', construct_list
     ('f', construct_list
      ('I', construct_list
       ('*', construct_list
	('e', NULL)))));

  struct list *l2 = construct_list
    ('a', construct_list
     ('f', construct_list
      ('&', NULL)));

  printf("l1 = ");
  print_list(l1);
  printf("\n");

  if (alternata(l1))
    printf("l1 è alternata\n");
  else
    printf("l1 non è alternata\n");

  printf("l2 = ");
  print_list(l2);
  printf("\n");

  if (alternata(l2))
    printf("l2 è alternata\n");
  else
    printf("l2 non è alternata\n");

  return 0;
}
示例#2
0
void add_to_list(LISTENTRY *el, NAUTYGRAPH canong, int m, int order, int *test) {
    int compare;

    compare = order - el->order;
    if (compare == 0) {
        compare = memcmp(canong, el->nautyg, m * order * sizeof (unsigned long));
    }

    if (compare == 0) {
        *test = 0;
    } else if (compare < 0) {
        if (el->smaller == NULL) {
            *test = 1;
            el->smaller = (LISTENTRY *) malloc(sizeof (LISTENTRY));
            if (el->smaller == NULL) {
                fprintf(stderr, "Can not get more memory !\n");
                exit(99);
            }
            construct_list(el->smaller, canong, m, order);
        } else {
            add_to_list(el->smaller, canong, m, order, test);
        }
    } else /* compare > 0 */ {
        if (el->larger == NULL) {
            *test = 1;
            el->larger = (LISTENTRY *) malloc(sizeof (LISTENTRY));
            if (el->larger == NULL) {
                fprintf(stderr, "Can not get more memory !\n");
                exit(99);
            }
            construct_list(el->larger, canong, m, order);
        } else {
            add_to_list(el->larger, canong, m, order, test);
        }
    }

}
示例#3
0
int handle_new_graph(GRAPH *g, LISTENTRY **list) {
    NAUTYGRAPH nautyg, canong;
    nvector lab[MAXORDER], ptn[MAXORDER], orbits[MAXORDER];
    static DEFAULTOPTIONS(options);
    statsblk(stats);
    setword workspace[100 * MAXORDER];
    int m, test, order;

    order = getNewOrder(g);
    options.getcanon = TRUE;
    options.writeautoms = FALSE;
    options.writemarkers = FALSE;

    if ((order % 32) == 0) m = order / 32;
    else m = order / 32 + 1;

    nautyg = (NAUTYGRAPH) calloc(m*order, sizeof (unsigned long));
    canong = (NAUTYGRAPH) calloc(m*order, sizeof (unsigned long));
    if ((nautyg == NULL) || (canong == NULL)) {
        fprintf(stderr, "Can not get more memory (1)!\n");
        exit(99);
    }

    translate(g, nautyg, m, order);
    nauty(nautyg, lab, ptn, NULL, orbits, &options, &stats, workspace, 100, m, order, canong);

    if ((*list) == NULL) {
        test = 1;
        *list = (LISTENTRY *) malloc(sizeof (LISTENTRY));
        if (*list == NULL) {
            fprintf(stderr, "Can not get more memory (0)!\n");
            exit(99);
        }
        construct_list(*list, canong, m, order);
    } else {
        add_to_list(*list, canong, m, order, &test);
    }

    free(nautyg);
    if (test == 0) free(canong); /* sonst wurde er in die Liste geschrieben */

    return (test);
}
示例#4
0
static gboolean
plugin_load (PurplePlugin *plugin)
{
	void *conv_handle, *blist_handle, *conn_handle;

	construct_list();

	if (!notify_is_initted () && !notify_init ("Pidgin")) {
		purple_debug_error (PLUGIN_ID, "libnotify not running!\n");
		return FALSE;
	}

	conv_handle = purple_conversations_get_handle ();
	blist_handle = purple_blist_get_handle ();
	conn_handle = purple_connections_get_handle();

	buddy_hash = g_hash_table_new (NULL, NULL);

	purple_signal_connect (blist_handle, "buddy-signed-on", plugin,
						PURPLE_CALLBACK(notify_buddy_signon_cb), NULL);

	purple_signal_connect (blist_handle, "buddy-signed-off", plugin,
						PURPLE_CALLBACK(notify_buddy_signoff_cb), NULL);

	purple_signal_connect (conv_handle, "received-im-msg", plugin,
						PURPLE_CALLBACK(notify_new_message_cb), NULL);

	purple_signal_connect (conv_handle, "received-chat-msg", plugin,
						PURPLE_CALLBACK(notify_chat_nick), NULL);

	purple_signal_connect (conv_handle, "deleting-conversation", plugin,
						PURPLE_CALLBACK(notify_deleting_conversation_cb), NULL);

	purple_prefs_connect_callback(plugin, "/plugins/gtk/libnotify/triggerMessages",
					(PurplePrefCallback)construct_list, NULL);

	/* used just to not display the flood of guifications we'd get */
	purple_signal_connect (conn_handle, "signed-on", plugin,
						PURPLE_CALLBACK(event_connection_throttle), NULL);

	return TRUE;
}
示例#5
0
void setUp(void)
{
    // This is run before EACH test
    mylist = construct_list(sizeof(test_struct));
    TEST_ASSERT_NOT_NULL(mylist);
}