Пример #1
0
int			parser(char **argv, t_cloud *data)
{
	FT_INIT(char *, line, NULL);
	FT_INIT(double, pos_y, 0);
	FT_INIT(int, fd, 0);
	FT_INIT(int, verif, 1);
	FT_INIT(t_node*, list, NULL);
	if ((fd = open(argv[1], O_RDONLY)) == -1)
		error_fdf("Error open file");
	while (verif)
	{
		if (!(verif = get_next_line(fd, &line)))
			break ;
		if (!list)
			MULTI(data->start_node, list, build_list(pos_y, data, line));
		else
		{
			list->next  = build_list(pos_y, data, line);
			list = list->next;
		}
		while (list && list->next)
			list = list->next;
		if (line)
			ft_strdel(&line);
		pos_y++;
	}
	return (0);
}
Пример #2
0
int				check_lemin(char *line, t_check *check, t_cells **cells)
{
	FT_INIT(int, nb_args, check_nb_args(line));
	if (!line)
		return (find_way(check));
	if (ft_strchr(line, '#') &&
	(ft_strcmp(line, "##start") && ft_strcmp(line, "##end")))
		return (1);
	if (!check->ants && nb_args == 1 && nb_ants(line, check, 1))
		return (1);
	if (check->ants && start_end_min(line, check))
		return (nb_args == 1 ? 1 : 0);
	if (check->ants && nb_args == 3
	&& (check->start || check->end || !(*cells)))
	{
		build_list(cells, check, line);
		if (check->start)
			check->start_cell = ft_strdup((*cells)->name);
		else if (check->end)
			check->end_cell = ft_strdup((*cells)->name);
		MULTI(check->start, check->end, 0);
		return (1);
	}
	if (check->ants && check->start_list
	&& nb_args <= 3 && !build_list(cells, check, line))
		return (0);
	return (1);
}
Пример #3
0
void test_list_inspect(void)
{
  pn_list_t *l = build_list(0, END);
  test_inspect(l, "[]");
  pn_free(l);

  l = build_list(0, pn_string("one"), END);
  test_inspect(l, "[\"one\"]");
  pn_free(l);

  l = build_list(0,
                 pn_string("one"),
                 pn_string("two"),
                 END);
  test_inspect(l, "[\"one\", \"two\"]");
  pn_free(l);

  l = build_list(0,
                 pn_string("one"),
                 pn_string("two"),
                 pn_string("three"),
                 END);
  test_inspect(l, "[\"one\", \"two\", \"three\"]");
  pn_free(l);
}
Пример #4
0
/***********************************************************************
 *           RELAY16_InitDebugLists
 *
 * Build the relay include/exclude function lists.
 */
void RELAY16_InitDebugLists(void)
{
    OBJECT_ATTRIBUTES attr;
    UNICODE_STRING name;
    char buffer[1024];
    HANDLE root, hkey;
    DWORD count;
    WCHAR *str;
    static const WCHAR configW[] = {'S','o','f','t','w','a','r','e','\\',
                                    'W','i','n','e','\\',
                                    'D','e','b','u','g',0};
    static const WCHAR RelayIncludeW[] = {'R','e','l','a','y','I','n','c','l','u','d','e',0};
    static const WCHAR RelayExcludeW[] = {'R','e','l','a','y','E','x','c','l','u','d','e',0};
    static const WCHAR SnoopIncludeW[] = {'S','n','o','o','p','I','n','c','l','u','d','e',0};
    static const WCHAR SnoopExcludeW[] = {'S','n','o','o','p','E','x','c','l','u','d','e',0};

    RtlOpenCurrentUser( KEY_READ, &root );
    attr.Length = sizeof(attr);
    attr.RootDirectory = root;
    attr.ObjectName = &name;
    attr.Attributes = 0;
    attr.SecurityDescriptor = NULL;
    attr.SecurityQualityOfService = NULL;
    RtlInitUnicodeString( &name, configW );

    /* @@ Wine registry key: HKCU\Software\Wine\Debug */
    if (NtOpenKey( &hkey, KEY_READ, &attr )) hkey = 0;
    NtClose( root );
    if (!hkey) return;

    str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)buffer)->Data;
    RtlInitUnicodeString( &name, RelayIncludeW );
    if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
    {
        debug_relay_includelist = build_list( str );
    }

    RtlInitUnicodeString( &name, RelayExcludeW );
    if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
    {
        debug_relay_excludelist = build_list( str );
    }

    RtlInitUnicodeString( &name, SnoopIncludeW );
    if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
    {
        debug_snoop_includelist = build_list( str );
    }

    RtlInitUnicodeString( &name, SnoopExcludeW );
    if (!NtQueryValueKey( hkey, &name, KeyValuePartialInformation, buffer, sizeof(buffer), &count ))
    {
        debug_snoop_excludelist = build_list( str );
    }
    NtClose( hkey );
}
 TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) 
 {
     if(root==NULL)
         return NULL;
     if(p==NULL)
         return q;
     if(q==NULL)
         return p;
     list<TreeNode*> pp,qq;
     build_list(root,p,pp);
     pp.push_front(root);
     build_list(root,q,qq);
     qq.push_front(root);
     return find_common_node(pp,qq);
 }
Пример #6
0
int				main(int ac, char **av)
{
	t_env	env;

	if (!(isatty(0)))
		error_quit("Invalid stdin, please run from terminal");
	g_env = &env;
	env.old_width = 0;
	env.old_height = 0;
	env.list_size = ac - 1;
	env.items = NULL;
	get_tty_fd(&env);
	build_list(&env, ac, av);
	env.curr = env.items;
	init_signals();
	tgetent(0, getenv("TERM"));
	if (!(env.caps = malloc(sizeof(*env.caps))))
		error_quit("Failed to malloc env caps");
	init_caps(env.caps);
	key_codes_init(&env);
	terminal_catch();
	env.fd = 2;
	while (1)
	{
		draw_list(&env);
		read_stdin(&env);
	}
}
Пример #7
0
const GridList* AtomGridCell::get_list()
{
  if (!getlistcalled) {
    build_list();
  }
  return gridlist;
}
Пример #8
0
// Simulate
static void bench_pending(void) {
  // These parameters give us 262140 items to track
  const size_t tree_depth = 7;
  const size_t num_files_per_dir = 8;
  const size_t num_dirs_per_dir = 4;
  w_string_t *root_name = w_string_new("/some/path");
  struct pending_list list;
  const size_t alloc_size = 280000;
  struct timeval start, end;

  list.pending = calloc(alloc_size, sizeof(struct watchman_pending_fs));
  list.avail = list.pending;
  list.end = list.pending + alloc_size;

  // Build a list ordered from the root (top) down to the leaves.
  build_list(&list, root_name, tree_depth, num_files_per_dir, num_dirs_per_dir);
  diag("built list with %u items", list.avail - list.pending);

  // Benchmark insertion in top-down order.
  {
    struct watchman_pending_collection coll;
    struct watchman_pending_fs *item;
    size_t drained = 0;

    w_pending_coll_init(&coll);

    gettimeofday(&start, NULL);
    for (item = list.pending; item < list.avail; item++) {
      w_pending_coll_add(&coll, item->path, item->now, item->flags);
    }
    drained = process_items(&coll);

    gettimeofday(&end, NULL);
    diag("took %.3fs to insert %u items into pending coll",
         w_timeval_diff(start, end), drained);
  }

  // and now in reverse order; this is from the leaves of the filesystem
  // tree up to the root, or bottom-up.  This simulates the workload of
  // a recursive delete of a filesystem tree.
  {
    struct watchman_pending_collection coll;
    struct watchman_pending_fs *item;
    size_t drained = 0;

    w_pending_coll_init(&coll);

    gettimeofday(&start, NULL);
    for (item = list.avail - 1; item >= list.pending; item--) {
      w_pending_coll_add(&coll, item->path, item->now, item->flags);
    }

    drained = process_items(&coll);

    gettimeofday(&end, NULL);
    diag("took %.3fs to reverse insert %u items into pending coll",
         w_timeval_diff(start, end), drained);
  }
}
Пример #9
0
List *xdap_late_read_contig_data(void)
{
    List *contig_details;

    if (cur_contig_index > io.num_contigs)
        contig_details = nil;
    else {
        bap_rl_file_rec rl_line;
        int length;
        int index;
        int left_end;
        int right_end;

        index = io.max_gels-cur_contig_index;
        bap_read_rl(&io,index,&rl_line);
        length = rl_line.clines.length;
        left_end = rl_line.clines.left_end;
        right_end = rl_line.clines.right_end;

        contig_details =
            build_list(
                atom_str(contig_rec),
                build_list(
                    atom_str(contig_index),
                    atom_int(index),
                    nil),
                build_list(
                    atom_str(contig_length),
                    atom_int(length),
                    nil),
                build_list(
                    atom_str(contig_left_end),
                    atom_int(left_end),
                    nil),
                build_list(
                    atom_str(contig_right_end),
                    atom_int(right_end),
                    nil),
                nil);

        cur_contig_index++;
    }

    return contig_details;

}
Пример #10
0
void CSortD::Quick_Sort (ARY_LIST input, int *piDEMSort)
{
    build_list(input, piDEMSort);  // Build array A
    //debug_print (0, 0,
    //  "List to be sorted in ascending order:", piDEMSort);
    if (n > 0) 
       qsort (0, n - 1, piDEMSort);
}
Пример #11
0
static List *db_details(void)
{

    return
        build_list(
            build_list(
                atom_str(db_max_db_size),
                atom_int(io.max_db_size),
                nil),
            build_list(
                atom_str(db_max_gels),
                atom_int(io.max_gels),
                nil),
            build_list(
                atom_str(db_max_gel_length),
                atom_int(io.max_gel_length),
                nil),
            build_list(
                atom_str(db_data_class),
                atom_int(io.data_class),
                nil),
            build_list(
                atom_str(db_num_gels),
                atom_int(io.num_gels),
                nil),
            build_list(
                atom_str(db_num_contigs),
                atom_int(io.num_contigs),
                nil),
            nil);

}
TEST(SimpleList, EraseLast)
{
    int arr1[] = {1, 2};
    ListNode<int> *myList = build_list(arr1, 2);
    ListNode<int> *newHead = erase<int>(myList, 1);
    ASSERT_TRUE(newHead != NULL);
    EXPECT_EQ(1, newHead->value);
    EXPECT_EQ(NULL, newHead->next);

    newHead = erase<int>(newHead, 0);
    EXPECT_EQ(NULL, newHead);

    int arr2[] = {1, 2, 3, 4, 5, 6, 7};
    myList = build_list(arr2, 7);
    newHead = erase<int>(myList, 6);
    EXPECT_EQ("[1,2,3,4,5,6]", trace<int>(newHead));
    clear<int>(newHead);
}
Пример #13
0
//costruisce una "Queue" a partire da un array. Usa il metodo insert
list* queue_build(void* new_object_array [], int object_number){
	list *new_list;
	new_list = build_list(new_object_array[0]);
	for (int i = 1; i<object_number; i++) {
		queue_insert(new_list, new_object_array[i]);	
	}
	
	return new_list;
}
Пример #14
0
//costruisce un "Tree" a partire da un array. Usa il metodo insert
list* tree_build(int (*compare)(void* ,void* ), void* new_object_array [], int object_number){
	list *new_list;
	new_list = build_list(new_object_array[0]);
	for (int i = 1; i<object_number; i++) {
		tree_insert(new_list, compare, new_object_array[i]);	
	}
	
	return new_list;
}
int
main()
{
    std::list<int> const data = build_list();
    test_pop_back(data);
    test_pop_front(data);
    test_push_back(data);
    test_push_front(data);
    return boost::report_errors();
}
Пример #16
0
static int list_val(void)
{
    YAP_Term in = YAP_ARG1;
    YAP_Term out = YAP_ARG2;
    char buffer[256];

    YAP_StringToBuffer(in, buffer, BUFSIZE);
    YAP_Term res = build_list(get_list(buffer), 0);

    return YAP_Unify(out, res);
}
Пример #17
0
int 
main()
{
    std::list<int> const data = build_list();
    test_assign(data);
    test_assign2(data);
    test_back(data);
    test_begin(data);
    test_clear(data);
    return boost::report_errors();
}
Пример #18
0
int
main()
{
    std::list<int> const data = build_list();
    test_rbegin(data);
    test_rend(data);
    test_resize(data);
    test_size(data);
    test_splice(data);
    return boost::report_errors();
}
Пример #19
0
int main(int argc, char* argv[]) {

	struct list_type* list = build_list();

	struct list_type* el = lookup_list(list);

	free_list(list);

    ___cl_pt_build_fail();

	return 0;
}
Пример #20
0
static List *file_details(void)
{
    return
        build_list(
            atom_str(db_files),
            build_list(
                atom_str(db_files_arch),
                atom_str(io.ar_file),
                nil),
            build_list(
                atom_str(db_files_rel),
                atom_str(io.rl_file),
                nil),
            build_list(
                atom_str(db_files_seq),
                atom_str(io.sq_file),
                nil),
            build_list(
                atom_str(db_files_tag),
                atom_str(io.tg_file),
                nil),

            build_list(
                atom_str(db_files_com),
                atom_str(io.cc_file),
                nil),
            nil
        );
}
Пример #21
0
static YAP_Term build_list(list l, int current_pos)
{
    if (l.size > 0)
    {
        if (l.nDims > 1)
        {
            YAP_Term curr_term = YAP_MkAtomTerm(YAP_LookupAtom("[]"));
            int cDims = l.dims[0], i, j, k, inc = cDims;

            for (i = cDims - 1; i >= 0; i--)
            {
                list newL;
                newL.nDims = l.nDims - 1;
                newL.size = l.size / cDims;
                k = 0;

                for (j = 1; j < l.nDims; j++)
                    newL.dims[j - 1] = l.dims[j];
                for (j = i; j < l.size; j += inc)
                    newL.values[k++] = l.values[j];

                curr_term = YAP_MkPairTerm(build_list(newL, 0), curr_term);
            }

            return curr_term;
        }
        else
        {
            YAP_Term curr_term = get_term(l.values[current_pos]);
            if (current_pos == l.size - 1)
                return YAP_MkPairTerm(curr_term, 
                                      YAP_MkAtomTerm(YAP_LookupAtom("[]")));
            else
                return YAP_MkPairTerm(curr_term, 
                                      build_list(l, current_pos + 1));
        }
    }

    return YAP_MkAtomTerm(YAP_LookupAtom("[]"));
}
Пример #22
0
int
main()
{
    BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value));
    BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value));

    std::list<int> const data = build_list();
    test_rbegin(data);
    test_rend(data);
    test_resize(data);
    test_size(data);
    test_splice(data);
    return boost::report_errors();
}
    bool build_list(TreeNode *root,TreeNode *node,list<TreeNode*> &ll)
{
    if(node==root)
    {
        //ll.push_back(root);
        return true;
    }
    if(root==NULL)
        return false;
    bool a=build_list(root->left,node,ll);
    bool b=build_list(root->right,node,ll);
    if(a)
    {
        ll.push_front(root->left);
        return true;
    }
    else if(b)
    {
        ll.push_front(root->right);
        return true;
    }
    else
        return false;
}
Пример #24
0
List *xdap_late_read_header(void)
/*
**
*/
{
    List *files;
    List *details;

    files = file_details();
    details = db_details();

    return
        join_list(
            build_list(
                atom_str(db_from),
                nil),
            details,
            build_list(
                files,
                nil),
            nil);


}
Пример #25
0
int
main()
{
    BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value));
    BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value));

    std::list<int> const data = build_list();
    test_empty(data);
    test_end(data);
    test_erase(data);
    test_front(data);
    test_get_allocator(data);
    test_insert(data);
    test_max_size(data);
    return boost::report_errors();
}
Пример #26
0
int main(int argc, char **argv)
{
    node_ptr list = NULL;

    build_list(&list);
    printf("Original linklist:\n");
    print_list(list);

    reverse_list(&list);
    printf("\nReverse linklist:\n");
    print_list(list);

    free_list(list);

    return 0;
}
Пример #27
0
void fs_var_log(void) {
	build_list("/var/log");
	
	// create /var/log if it doesn't exit
	if (is_dir("/var/log")) {
		// extract group id for /var/log/wtmp
		struct stat s;
		gid_t wtmp_group = 0;
		if (stat("/var/log/wtmp", &s) == 0)
			wtmp_group = s.st_gid;
		
		// mount a tmpfs on top of /var/log
		if (arg_debug)
			printf("Mounting tmpfs on /var/log\n");
		if (mount("tmpfs", "/var/log", "tmpfs", MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME | MS_REC,  "mode=755,gid=0") < 0)
			errExit("mounting /var/log");
		fs_logger("tmpfs /var/log");
		
		build_dirs();
		release_all();
		
		// create an empty /var/log/wtmp file
		/* coverity[toctou] */
		FILE *fp = fopen("/var/log/wtmp", "w");
		if (fp)
			fclose(fp);
		if (chown("/var/log/wtmp", 0, wtmp_group) < 0)
			errExit("chown");
		if (chmod("/var/log/wtmp", S_IRUSR | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH ) < 0)
			errExit("chmod");
		fs_logger("touch /var/log/wtmp");
			
		// create an empty /var/log/btmp file
		fp = fopen("/var/log/btmp", "w");
		if (fp)
			fclose(fp);
		if (chown("/var/log/btmp", 0, wtmp_group) < 0)
			errExit("chown");
		if (chmod("/var/log/btmp", S_IRUSR | S_IWRITE | S_IRGRP | S_IWGRP) < 0)
			errExit("chmod");
		fs_logger("touch /var/log/btmp");
	}
	else
		fprintf(stderr, "Warning: cannot mount tmpfs on top of /var/log\n");
}
Пример #28
0
void fs_var_log(void) {
	build_list("/var/log");
	
	// create /var/log if it does't exit
	struct stat s;
	if (is_dir("/var/log")) {
		// mount a tmpfs on top of /var/log
		if (arg_debug)
			printf("Mounting tmpfs on /var/log\n");
		if (mount("tmpfs", "/var/log", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC,  "mode=755,gid=0") < 0)
			errExit("mounting /var/log");
		
		build_dirs();
		release_all();
	}
	else
		fprintf(stderr, "Warning: cannot mount tmpfs in top of /var/log\n");
}
Пример #29
0
int main(void)
{
	node *head = build_list();
	node *head_back = head;
	int count = 0;
	time_t then;

	puts("So you have a list:");
	while (head != NULL) {
		count++;
		printf("\tNode %d - %d\n", count, head->data);
		head = head->next;
	}
	head = head_back;

	printf("You're sure you wanna delete it?");
	printf("\n\t...\t... ? : ");
	time(&then);
	while (difftime(time(NULL), then) < DELAY)
		;
	char answer = toupper(getchar());

	switch (answer) {
		case 'Y':
			printf("\nOkey...\n\t....\t...\n\n");
			time(&then);
			while (difftime(time(NULL), then) < DELAY)
				;
			if (DeleteList(head))
				puts("Done!\n");
			else {
				puts("The list begged me for mervy .. and.. you know me");
				puts("Couldn't do it.\nThe list is still alive & kicking!\n");
			}
			break;
		case 'N':
			puts("You have a big heart!\n");
			break;
		default:
			puts("I know man, hard to press [Y] or [N] :-|\n");
	}
	
	return 0;
}
Пример #30
0
static void test_build_list(void)
{
  pn_list_t *l = build_list(0,
                            pn_string("one"),
                            pn_string("two"),
                            pn_string("three"),
                            END);

  assert(pn_list_size(l) == 3);

  assert(pn_strequals(pn_string_get((pn_string_t *) pn_list_get(l, 0)),
                      "one"));
  assert(pn_strequals(pn_string_get((pn_string_t *) pn_list_get(l, 1)),
                      "two"));
  assert(pn_strequals(pn_string_get((pn_string_t *) pn_list_get(l, 2)),
                      "three"));

  pn_free(l);
}