void ls_dir(void *p, size_t size) { t_ls_entry *e; t_node *root; DIR *dir; e = (t_ls_entry *)p; if (e->type != T_DIR || !e->handle || \ (e->stat.st_mode & S_IFSOCK) == S_IFSOCK || \ (e->stat.st_mode & S_IFLNK) == S_IFLNK) return ; handle_path(e->name); dir = opendir(env()->path); ft_err(env()->av, ft_name(env()->path)); if (!dir) handle_path(NULL); else if (!(root = dir_tree(dir))) handle_path(NULL); else { tree_doinf(root, g_ls_select_print(env()->o)); if ((env()->o & O_RECU) == O_RECU) tree_doinf(root, ls_dir); handle_path(NULL); tree_del(&root, NULL); } (void)size; }
static int handle_cache(const char *path, unsigned char *sha1, const char *output) { mmfile_t mmfile[3]; mmbuffer_t result = {NULL, 0}; struct cache_entry *ce; int pos, len, i, hunk_no; struct rerere_io_mem io; int marker_size = ll_merge_marker_size(path); /* * Reproduce the conflicted merge in-core */ len = strlen(path); pos = cache_name_pos(path, len); if (0 <= pos) return -1; pos = -pos - 1; for (i = 0; i < 3; i++) { enum object_type type; unsigned long size; mmfile[i].size = 0; mmfile[i].ptr = NULL; if (active_nr <= pos) break; ce = active_cache[pos++]; if (ce_namelen(ce) != len || memcmp(ce->name, path, len) || ce_stage(ce) != i + 1) break; mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size); mmfile[i].size = size; } for (i = 0; i < 3; i++) { if (!mmfile[i].ptr && !mmfile[i].size) mmfile[i].ptr = xstrdup(""); } ll_merge(&result, path, &mmfile[0], &mmfile[1], "ours", &mmfile[2], "theirs", 0); for (i = 0; i < 3; i++) free(mmfile[i].ptr); memset(&io, 0, sizeof(io)); io.io.getline = rerere_mem_getline; if (output) io.io.output = fopen(output, "w"); else io.io.output = NULL; strbuf_init(&io.input, 0); strbuf_attach(&io.input, result.ptr, result.size, result.size); hunk_no = handle_path(sha1, (struct rerere_io *)&io, marker_size); strbuf_release(&io.input); if (io.io.output) fclose(io.io.output); return hunk_no; }
static int handle_line(struct parsedfile *config, char *line, int lineno) { char *words[10]; static char savedline[MAXLINE]; int nowords = 0, i; /* Save the input string */ strncpy(savedline, line, MAXLINE - 1); savedline[MAXLINE - 1] = (char) 0; /* Tokenize the input string */ nowords = tokenize(line, 10, words); /* Set the spare slots to an empty string to simplify */ /* processing */ for (i = nowords; i < 10; i++) words[i] = ""; if (nowords > 0) { /* Now this can either be a "path" block starter or */ /* ender, otherwise it has to be a pair (<name> = */ /* <value>) */ if (!strcmp(words[0], "path")) { handle_path(config, lineno, nowords, words); } else if (!strcmp(words[0], "}")) { handle_endpath(config, lineno, nowords, words); } else { /* Has to be a pair */ if ((nowords != 3) || (strcmp(words[1], "="))) { show_msg(MSGERR, "Malformed configuration pair " "on line %d in configuration " "file, \"%s\"\n", lineno, savedline); } else if (!strcmp(words[0], "reaches")) { handle_reaches(config, lineno, words[2]); } else if (!strcmp(words[0], "server")) { handle_server(config, lineno, words[2]); } else if (!strcmp(words[0], "server_port")) { handle_port(config, lineno, words[2]); } else if (!strcmp(words[0], "server_type")) { handle_type(config, lineno, words[2]); } else if (!strcmp(words[0], "default_user")) { handle_defuser(config, lineno, words[2]); } else if (!strcmp(words[0], "default_pass")) { handle_defpass(config, lineno, words[2]); } else if (!strcmp(words[0], "local")) { handle_local(config, lineno, words[2]); } else { show_msg(MSGERR, "Invalid pair type (%s) specified " "on line %d in configuration file, " "\"%s\"\n", words[0], lineno, savedline); } } } return(0); }
QString ComplexShapeHandler::handle_pathLst(QXmlStreamReader* reader) { QString returnString; pathEquationIndex = 0; pathEquations = ""; while (!reader->atEnd()) { reader->readNext(); if (reader->isEndElement() && reader->name() == "pathLst") { break; } else if (reader->isStartElement() && reader->name() == "path") { returnString += handle_path(reader); } } return returnString; }
void parse_mom_hierarchy( int fds) { int bytes_read; char buffer[MAXLINE<<10]; char *current; char *parent; char *child; char log_buf[LOCAL_LOG_BUF_SIZE]; int path_index = -1; memset(&buffer, 0, sizeof(buffer)); if ((bytes_read = read_ac_socket(fds, buffer, sizeof(buffer) - 1)) < 0) { snprintf(log_buf, sizeof(log_buf), "Unable to read from mom hierarchy file"); log_err(errno, __func__, log_buf); return; } current = buffer; while (get_parent_and_child(current, &parent, &child, ¤t) == PBSE_NONE) { if (!strncmp(parent,"path",strlen("path"))) handle_path(child, path_index); else { /* non-fatal error */ snprintf(log_buf, sizeof(log_buf), "Found noise in the mom hierarchy file. Ignoring <%s>%s</%s>", parent, child, parent); log_err(-1, __func__, log_buf); } } } /* END parse_mom_hierarchy() */
/* * Scan the path for conflicts, do the "handle_path()" thing above, and * return the number of conflict hunks found. */ static int handle_file(struct index_state *istate, const char *path, unsigned char *hash, const char *output) { int has_conflicts = 0; struct rerere_io_file io; int marker_size = ll_merge_marker_size(istate, path); memset(&io, 0, sizeof(io)); io.io.getline = rerere_file_getline; io.input = fopen(path, "r"); io.io.wrerror = 0; if (!io.input) return error_errno(_("could not open '%s'"), path); if (output) { io.io.output = fopen(output, "w"); if (!io.io.output) { error_errno(_("could not write '%s'"), output); fclose(io.input); return -1; } } has_conflicts = handle_path(hash, (struct rerere_io *)&io, marker_size); fclose(io.input); if (io.io.wrerror) error(_("there were errors while writing '%s' (%s)"), path, strerror(io.io.wrerror)); if (io.io.output && fclose(io.io.output)) io.io.wrerror = error_errno(_("failed to flush '%s'"), path); if (has_conflicts < 0) { if (output) unlink_or_warn(output); return error(_("could not parse conflict hunks in '%s'"), path); } if (io.io.wrerror) return -1; return has_conflicts; }
static int handle_file(const char *path, unsigned char *sha1, const char *output) { int hunk_no = 0; struct rerere_io_file io; int marker_size = ll_merge_marker_size(path); memset(&io, 0, sizeof(io)); io.io.getline = rerere_file_getline; io.input = fopen(path, "r"); io.io.wrerror = 0; if (!io.input) return error("Could not open %s", path); if (output) { io.io.output = fopen(output, "w"); if (!io.io.output) { fclose(io.input); return error("Could not write %s", output); } } hunk_no = handle_path(sha1, (struct rerere_io *)&io, marker_size); fclose(io.input); if (io.io.wrerror) error("There were errors while writing %s (%s)", path, strerror(io.io.wrerror)); if (io.io.output && fclose(io.io.output)) io.io.wrerror = error("Failed to flush %s: %s", path, strerror(errno)); if (hunk_no < 0) { if (output) unlink_or_warn(output); return error("Could not parse conflict hunks in %s", path); } if (io.io.wrerror) return -1; return hunk_no; }
static int handle_cache(const char *path, unsigned char *sha1, const char *output) { mmfile_t mmfile[3] = {{NULL}}; mmbuffer_t result = {NULL, 0}; const struct cache_entry *ce; int pos, len, i, has_conflicts; struct rerere_io_mem io; int marker_size = ll_merge_marker_size(path); /* * Reproduce the conflicted merge in-core */ len = strlen(path); pos = cache_name_pos(path, len); if (0 <= pos) return -1; pos = -pos - 1; while (pos < active_nr) { enum object_type type; unsigned long size; ce = active_cache[pos++]; if (ce_namelen(ce) != len || memcmp(ce->name, path, len)) break; i = ce_stage(ce) - 1; if (!mmfile[i].ptr) { mmfile[i].ptr = read_object_file(&ce->oid, &type, &size); mmfile[i].size = size; } } for (i = 0; i < 3; i++) if (!mmfile[i].ptr && !mmfile[i].size) mmfile[i].ptr = xstrdup(""); /* * NEEDSWORK: handle conflicts from merges with * merge.renormalize set, too? */ ll_merge(&result, path, &mmfile[0], NULL, &mmfile[1], "ours", &mmfile[2], "theirs", NULL); for (i = 0; i < 3; i++) free(mmfile[i].ptr); memset(&io, 0, sizeof(io)); io.io.getline = rerere_mem_getline; if (output) io.io.output = fopen(output, "w"); else io.io.output = NULL; strbuf_init(&io.input, 0); strbuf_attach(&io.input, result.ptr, result.size, result.size); /* * Grab the conflict ID and optionally write the original * contents with conflict markers out. */ has_conflicts = handle_path(sha1, (struct rerere_io *)&io, marker_size); strbuf_release(&io.input); if (io.io.output) fclose(io.io.output); return has_conflicts; }