static void proc_reset(ft_proc_t* proc) { proc->pid = 0; proc->child = false; proc->done = false; proc->procval = 0; proc->imagepath = 0; proc->ipcfd = -1; proc->symfiles = ft_list_init(); proc->watchpoints = ft_list_init(); proc->interactiv = false; ft_proc_reset_swdep(proc); }
void ft_list_push_front(t_list **list, t_link *link) { if (*list == NULL) ft_list_init(list, link); else { link->next = (*list)->head; (*list)->head = link; (*list)->size++; } }
void put_weights(t_map *map) { t_list queue; t_room *curr; ft_list_init(&queue, NULL); map->end->weight = 0; ft_list_add_front(&queue, map->end, sizeof(t_room)); while (queue.size >= 1) { curr = ft_list_remove_back(&queue); add_neighbours_to_queue(curr, &queue); } cut(map); map->start->ants = map->ants; }
/* Get all symbols */ ft_error_t elf_getsyms(struct ft_list** symfiles, ft_symfile_t* symfile) { ft_list_t* sections; sections = ft_list_init(); if (elf_sections_to_list(symfile->mmptr, symfile->mmlen, §ions) == 0 && elf_sections_get_informations(symfile->mmptr, symfile->mmlen, sections) == 0 && elf_get_exported_symbols(symfile, sections, &symfile->symlist) == 0 && elf_get_dependencies(symfile->mmptr, symfile->mmlen, sections, &symfile->symlist, symfiles) == 0) ; /* ft_list_foreach(symfile->symlist, symbol_dump_fn, 0); */ ft_list_release(§ions, section_release); return FT_ERR_SUCCESS; }
void ft_define_way(t_map *map, int index, int i) { t_elem *elem; map->ants[i]->way = ft_list_init(map->ants[i]->way); elem = map->roads->first; while (index-- > 0) elem = elem->next; elem = ((t_list *)elem->value)->first; while (elem != NULL) { ft_list_push(map->ants[i]->way , ft_list_new(elem->value, sizeof(t_room *))); elem = elem->next; } map->ants[i]->room = map->ants[i]->way->first; }
static int elf_get_dependencies(const char* mmptr, size_t mmlen, ft_list_t* sections, ft_list_t** symbols, ft_list_t** symfiles) { /* Dependencies can be found in the DT_NEEDED entries of the dynamic section. */ Elf32_Ehdr* ehdr; unsigned int ndyn; unsigned int maxdyn; Elf32_Dyn* pdyn; ft_list_t* node; ft_list_t* libpaths; ft_list_t* nodepath; elf_section_t* dynamic; elf_section_t* strtab; char sopath[256]; /* Get the string section, this is subject to change */ ehdr = (Elf32_Ehdr*)mmptr; CHECK_MMAP(mmptr, mmlen, ehdr); /* node = ft_list_lkp(sections, match_section_bytype_fn, (void*)§ype); */ node = ft_list_lkp(sections, match_section_byname_fn, (void*)".dynstr"); if (node == 0) return -1; strtab = (elf_section_t*)node->data; /* Bootstrap the path list */ libpaths = ft_list_init(); ft_list_push_front(&libpaths, (void*)"/usr/lib/"); ft_list_push_front(&libpaths, (void*)"/lib/"); ft_list_push_front(&libpaths, (void*)"/usr/local/lib/"); /* Walk and find dynamic */ for (node = sections; node; node = node->next) { dynamic = (elf_section_t*)node->data; if (dynamic->type == SHT_DYNAMIC) { maxdyn = dynamic->size / sizeof(Elf32_Dyn); pdyn = (Elf32_Dyn*)dynamic->data; /* First pass to get the -rpath related data */ for (ndyn = 0; ndyn < maxdyn; ++ndyn) { if (pdyn[ndyn].d_tag == DT_RPATH) ft_list_push_front(&libpaths, (void*)(strtab->data + pdyn[ndyn].d_un.d_val)); } /* Second pass to get library names */ for (ndyn = 0; ndyn < maxdyn; ++ndyn) { if (pdyn[ndyn].d_tag == DT_NEEDED) { nodepath = libpaths; while (nodepath) { snprintf(sopath, sizeof(sopath), "%s/%s", (char*)nodepath->data, strtab->data + pdyn[ndyn].d_un.d_val); if (ft_symbol_list_from_file(symfiles, sopath) == FT_ERR_SUCCESS) nodepath = 0; else nodepath = nodepath->next; } } } } } /* Release the path list */ ft_list_release(&libpaths, 0); return 0; }