static int archive_buffer_load(EditBuffer *b, FILE *f) { /* Launch subprocess to list archive contents */ char cmd[1024]; ArchiveType *atp; atp = find_archive_type(b->filename); if (atp) { eb_clear(b); eb_printf(b, " Directory of %s archive %s\n", atp->name, b->filename); snprintf(cmd, sizeof(cmd), atp->list_cmd, b->filename); new_shell_buffer(b, get_basename(b->filename), NULL, cmd, SF_INFINITE | SF_BUFED_MODE); /* XXX: should check for archiver error */ /* XXX: should delay BF_SAVELOG until buffer is fully loaded */ b->flags |= BF_READONLY; return 0; } else { eb_printf(b, "Cannot find archiver\n"); return -1; } }
static int wget_buffer_load(EditBuffer *b, FILE *f) { /* Launch wget subprocess to retrieve contents */ char cmd[1024]; eb_clear(b); snprintf(cmd, sizeof(cmd), "wget -q -O - %s", b->filename); new_shell_buffer(b, get_basename(b->filename), NULL, cmd, SF_INFINITE | SF_AUTO_CODING | SF_AUTO_MODE); /* XXX: should check for wget error */ /* XXX: should delay BF_SAVELOG until buffer is fully loaded */ b->flags |= BF_READONLY; return 0; }
/* * NAME: cmdbuf->edit() * DESCRIPTION: edit a new file */ int cb_edit(cmdbuf *cb) { io iob; not_in_global(cb); if (cb->edit > 0 && !(cb->flags & CB_EXCL)) { error("No write since last change (edit! overrides)"); } getfname(cb, cb->fname); if (cb->fname[0] == '\0') { error("No current filename"); } Alloc::staticMode(); eb_clear(cb->edbuf); Alloc::dynamicMode(); cb->flags &= ~CB_NOIMAGE; cb->edit = 0; cb->first = cb->cthis = 0; memset(cb->mark, '\0', sizeof(cb->mark)); cb->buf = 0; memset(cb->zbuf, '\0', sizeof(cb->zbuf)); cb->undo = (block) -1; /* not 0! */ output("\"%s\" ", cb->fname); if (!io_load(cb->edbuf, cb->fname, cb->first, &iob)) { error("is unreadable"); } io_show(&iob); if (iob.zero > 0 || iob.split > 0 || iob.ill) { /* the editbuffer in memory is not a perfect image of the file read */ cb->flags |= CB_NOIMAGE; } cb->cthis = iob.lines; return 0; }
static int compress_buffer_load(EditBuffer *b, FILE *f) { /* Launch subprocess to expand compressed contents */ char cmd[1024]; CompressType *ctp; ctp = find_compress_type(b->filename); if (ctp) { eb_clear(b); snprintf(cmd, sizeof(cmd), ctp->load_cmd, b->filename); new_shell_buffer(b, get_basename(b->filename), NULL, cmd, SF_INFINITE | SF_AUTO_CODING | SF_AUTO_MODE); /* XXX: should check for archiver error */ /* XXX: should delay BF_SAVELOG until buffer is fully loaded */ b->flags |= BF_READONLY; return 0; } else { eb_printf(b, "cannot find compressor\n"); return -1; } }