void do_nistcheck (GtkAction *action) { void *handle; int (*run_nist_tests)(const char *, const char *, int); gchar *datadir = NULL; gchar *fname = NULL; run_nist_tests = gui_get_plugin_function("run_nist_tests", &handle); if (run_nist_tests == NULL) { return; } datadir = g_strdup_printf("%sdata%s", gretl_home(), SLASHSTR); fname = g_strdup_printf("%snist.out", gretl_dotdir()); (*run_nist_tests)(datadir, fname, nist_verbosity(action)); close_plugin(handle); view_file(fname, 0, 1, 78, 400, VIEW_CODEBOOK); g_free(datadir); g_free(fname); }
/* * Run viewer (internal or external) on the currently selected file. * If normal is 1, force internal viewer and raw mode (used for F13). */ static void do_view_cmd (int normal) { int dir, file_idx; /* Directories are viewed by changing to them */ if (S_ISDIR (selection (current_panel)->st.st_mode) || link_isdir (selection (current_panel))) { if (confirm_view_dir && (current_panel->marked || current_panel->dirs_marked)) { if (query_dialog (_(" Confirmation "), _("Files tagged, want to cd?"), 0, 2, _("&Yes"), _("&No")) != 0) { return; } } if (!do_cd (selection (current_panel)->fname, cd_exact)) message (1, MSG_ERROR, _("Cannot change directory")); return; } file_idx = current_panel->selected; while (1) { char *filename; filename = current_panel->dir.list[file_idx].fname; dir = view_file (filename, normal, use_internal_view); if (dir == 0) break; file_idx = scan_for_file (current_panel, file_idx, dir); } }
/** * Run viewer (internal or external) on the currently selected file. * If normal is TRUE, force internal viewer and raw mode (used for F13). */ static void do_view_cmd (gboolean normal) { /* Directories are viewed by changing to them */ if (S_ISDIR (selection (current_panel)->st.st_mode) || link_isdir (selection (current_panel))) { vfs_path_t *fname_vpath; if (confirm_view_dir && (current_panel->marked || current_panel->dirs_marked)) { if (query_dialog (_("Confirmation"), _("Files tagged, want to cd?"), D_NORMAL, 2, _("&Yes"), _("&No")) != 0) { return; } } fname_vpath = vfs_path_from_str (selection (current_panel)->fname); if (!do_cd (fname_vpath, cd_exact)) message (D_ERROR, MSG_ERROR, _("Cannot change directory")); vfs_path_free (fname_vpath); } else { int file_idx; vfs_path_t *filename_vpath; file_idx = current_panel->selected; filename_vpath = vfs_path_from_str (current_panel->dir.list[file_idx].fname); view_file (filename_vpath, normal, use_internal_view != 0); vfs_path_free (filename_vpath); } repaint_screen (); }
void viewlog (gpointer data) { char *tempstr, *txt, *pos; gint textlen; ssize_t len; int fd; #if GTK_MAJOR_VERSION > 1 GtkTextBuffer * textbuf; GtkTextIter iter, iter2; #endif tempstr = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXXXXXX", NULL); if ((fd = mkstemp (tempstr)) < 0) { ftp_log (gftp_logging_error, NULL, _("Error: Cannot open %s for writing: %s\n"), tempstr, g_strerror (errno)); g_free (tempstr); return; } chmod (tempstr, S_IRUSR | S_IWUSR); #if GTK_MAJOR_VERSION == 1 textlen = gtk_text_get_length (GTK_TEXT (logwdw)); txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1); #else textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw)); textlen = gtk_text_buffer_get_char_count (textbuf); gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0); gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, textlen); txt = gtk_text_buffer_get_text (textbuf, &iter, &iter2, 0); /* gtk_text_buffer_get_char_count() returns the number of characters, not bytes. So get the number of bytes that need to be written out */ textlen = strlen (txt); #endif pos = txt; while (textlen > 0) { if ((len = write (fd, pos, textlen)) == -1) { ftp_log (gftp_logging_error, NULL, _("Error: Error writing to %s: %s\n"), tempstr, g_strerror (errno)); break; } textlen -= len; pos += len; } fsync (fd); lseek (fd, 0, SEEK_SET); view_file (tempstr, fd, 1, 1, 0, 1, NULL, NULL); close (fd); g_free (tempstr); g_free (txt); }
void do_olog( char_data* ch, char* argument ) { char* tmp = static_string( ); wizard_data* wizard = (wizard_data*) ch; obj_clss_data* obj_clss; int i; if( *argument == '\0' ) { if( ( obj_clss = wizard->obj_edit ) == NULL ) { send( ch, "You are not editting an object so must specify a vnum.\r\n" ); return; } i = obj_clss->vnum; } else { if( get_obj_index( i = atoi( argument ) ) == NULL ) { send( ch, "There is no object with that vnum.\r\n" ); return; } } sprintf( tmp, "%sobj.%d", OBJ_LOG_DIR, i ); if( !view_file( ch, tmp ) ) send( ch, "That object has no log.\r\n" ); return; }
static int latex_compile_graph_page (void) { char *fname; int err; /* ensure we don't get stale output */ if (gpage.term == GP_TERM_EPS) { fname = gpage_fname(".ps", 0); } else { fname = gpage_fname(".pdf", 0); } gretl_remove(fname); err = latex_compile(gpage_tex_base); if (err == LATEX_ERROR) { char *fname = gpage_fname(".log", 0); view_file(fname, 0, 1, 78, 350, VIEW_FILE); } if (gpage.term == GP_TERM_EPS && !err) { err = dvips_compile(gpage_base); } return err; }
int follow_link(int key) { link_t *link; for (link = links; link; link = link->next) { if (link->key != key) continue; switch (link->which) { case '0': view_file(&config.cmd_text[0], link->host, link->port, link->selector); break; case '1': view_directory(link->host, link->port, link->selector, 1); break; case '7': view_search(link->host, link->port, link->selector); break; case '5': case '9': view_download(link->host, link->port, link->selector); break; case '8': view_telnet(link->host, link->port); break; case 'g': case 'I': case 'p': view_file(&config.cmd_image[0], link->host, link->port, link->selector); break; case 'h': view_file(&config.cmd_browser[0], link->host, link->port, link->selector); break; case 's': view_file(&config.cmd_player[0], link->host, link->port, link->selector); break; default: printf("missing handler [%c]\n", link->which); break; } return 1; /* return the array is broken after view! */ } return 0; }
void do_rlog( char_data* ch, char* ) { char tmp [ ONE_LINE ]; sprintf( tmp, "%sroom.%d", ROOM_LOG_DIR, ch->in_room->vnum ); if( !view_file( ch, tmp ) ) send( "There is no log for this room.\r\n", ch ); return; }
/* Opens file specified by its path on the given line number. */ static void open_selected_file(const char path[], int line_num) { if(access(path, R_OK) == 0) { (void)view_file(path, line_num, -1, 1); } else { show_error_msgf("Can't read file", "File \"%s\" is not readable", path); } }
void view_file_cmd (void) { char *filename; filename = input_expand_dialog (_("View file"), _("Filename:"), MC_HISTORY_FM_VIEW_FILE, selection (current_panel)->fname); if (!filename) return; view_file (filename, 0, use_internal_view); g_free (filename); }
int main(int argc, char** argv) { // Initialize ROS ros::init(argc, argv, "view_pt_cloud_file"); ros::NodeHandle nh; std::string fileName; ros::param::get("~file_name", fileName); view_file( fileName ); ros::spin(); return 0; }
void do_mlog( char_data* ch, char* argument ) { char tmp [ ONE_LINE ]; pfile_data* pfile; char_data* victim = NULL; species_data* species; if( is_number( argument ) ) { if( ( species = get_species( atoi( argument ) ) ) == NULL ) { send( ch, "There is no mob with that vnum.\r\n" ); return; } } else { if( ( pfile = find_pfile_exact( argument ) ) == NULL ) { if( ( victim = one_character( ch, argument, "mlog", (thing_array*) &player_list, (thing_array*) &mob_list ) ) == NULL ) return; if( victim->pcdata != NULL ) pfile = victim->pcdata->pfile; } if( pfile != NULL ) { sprintf( tmp, "%s%s", PLAYER_LOG_DIR, pfile->name ); if( !view_file( ch, tmp ) ) send( ch, "%s has no log.\r\n", pfile->name ); return; } species = victim->species; } sprintf( tmp, "%smob.%d", MOB_LOG_DIR, species->vnum ); if( !view_file( ch, tmp ) ) send( ch, "%s has no log.\r\n", species->Name( ) ); return; }
void view_file_cmd (void) { char *filename; vfs_path_t *vpath; filename = input_expand_dialog (_("View file"), _("Filename:"), MC_HISTORY_FM_VIEW_FILE, selection (current_panel)->fname, INPUT_COMPLETE_FILENAMES); if (filename == NULL) return; vpath = vfs_path_from_str (filename); g_free (filename); view_file (vpath, FALSE, use_internal_view != 0); vfs_path_free (vpath); }
static void on_next_transfer (gftp_transfer * tdata) { intptr_t refresh_files; gftp_file * tempfle; tdata->next_file = 0; for (; tdata->updfle != tdata->curfle; tdata->updfle = tdata->updfle->next) { tempfle = tdata->updfle->data; if (tempfle->done_view || tempfle->done_edit) { if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP) { view_file (tempfle->destfile, 0, tempfle->done_view, tempfle->done_rm, 1, 0, tempfle->file, NULL); } } else if (tempfle->done_rm) tdata->fromreq->rmfile (tdata->fromreq, tempfle->file); if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP) gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1, _("Skipped")); else gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1, _("Finished")); } gftp_lookup_request_option (tdata->fromreq, "refresh_files", &refresh_files); if (refresh_files && tdata->curfle && tdata->curfle->next && compare_request (tdata->toreq, ((gftp_window_data *) tdata->towdata)->request, 1)) gftpui_refresh (tdata->towdata, 1); }
void quick_view_file(FileView *view) { char path[PATH_MAX]; const dir_entry_t *entry; if(curr_stats.load_stage < 2) { return; } if(vle_mode_is(VIEW_MODE)) { return; } if(curr_stats.number_of_windows == 1) { return; } if(draw_abandoned_view_mode()) { return; } ui_view_erase(other_view); entry = &view->dir_entry[view->list_pos]; get_full_path_of(entry, sizeof(path), path); switch(view->dir_entry[view->list_pos].type) { case FT_CHAR_DEV: mvwaddstr(other_view->win, LINE, COL, "File is a Character Device"); break; case FT_BLOCK_DEV: mvwaddstr(other_view->win, LINE, COL, "File is a Block Device"); break; #ifndef _WIN32 case FT_SOCK: mvwaddstr(other_view->win, LINE, COL, "File is a Socket"); break; #endif case FT_FIFO: mvwaddstr(other_view->win, LINE, COL, "File is a Named Pipe"); break; case FT_LINK: if(get_link_target_abs(path, entry->origin, path, sizeof(path)) != 0) { mvwaddstr(other_view->win, LINE, COL, "Cannot resolve Link"); break; } if(!ends_with_slash(path) && is_dir(path)) { strncat(path, "/", sizeof(path) - strlen(path) - 1); } /* break intensionally omitted */ case FT_UNK: default: { const char *viewer; FILE *fp; char *const typed_fname = get_typed_fname(path); viewer = ft_get_viewer(typed_fname); free(typed_fname); if(viewer == NULL && is_dir(path)) { mvwaddstr(other_view->win, LINE, COL, "File is a Directory"); break; } if(is_null_or_empty(viewer)) { fp = os_fopen(path, "rb"); } else { fp = use_info_prog(viewer); } if(fp == NULL) { mvwaddstr(other_view->win, LINE, COL, "Cannot open file"); break; } ui_view_clear(other_view); wattrset(other_view->win, 0); view_file(fp, cfg.wrap_quick_view); fclose(fp); break; } } refresh_view_win(other_view); ui_view_title_update(other_view); }
void quick_view_file(FileView *view) { char buf[PATH_MAX]; if(curr_stats.load_stage < 2) return; if(get_mode() == VIEW_MODE) return; if(curr_stats.number_of_windows == 1) return; werase(other_view->win); werase(other_view->title); mvwaddstr(other_view->title, 0, 0, "File: "); wprint(other_view->title, view->dir_entry[view->list_pos].name); snprintf(buf, sizeof(buf), "%s/%s", view->curr_dir, view->dir_entry[view->list_pos].name); switch(view->dir_entry[view->list_pos].type) { case CHARACTER_DEVICE: mvwaddstr(other_view->win, LINE, COL, "File is a Character Device"); break; case BLOCK_DEVICE: mvwaddstr(other_view->win, LINE, COL, "File is a Block Device"); break; #ifndef _WIN32 case SOCKET: mvwaddstr(other_view->win, LINE, COL, "File is a Socket"); break; #endif case FIFO: mvwaddstr(other_view->win, LINE, COL, "File is a Named Pipe"); break; case LINK: if(get_link_target_abs(buf, view->curr_dir, buf, sizeof(buf)) != 0) { mvwaddstr(other_view->win, LINE, COL, "Cannot resolve Link"); break; } if(!ends_with_slash(buf) && is_dir(buf)) { strncat(buf, "/", sizeof(buf) - strlen(buf) - 1); } /* break intensionally omitted */ case UNKNOWN: default: { const char *viewer; FILE *fp; viewer = get_viewer_for_file(buf); if(viewer == NULL && is_dir(buf)) { mvwaddstr(other_view->win, LINE, COL, "File is a Directory"); break; } if(is_null_or_empty(viewer)) fp = fopen(buf, "r"); else fp = use_info_prog(viewer); if(fp == NULL) { mvwaddstr(other_view->win, LINE, COL, "Cannot open file"); break; } colmgr_reset(); wattrset(other_view->win, 0); view_file(fp, cfg.wrap_quick_view); fclose(fp); } break; } refresh_view_win(other_view); wrefresh(other_view->title); }
static void do_view_or_edit_file (gftp_window_data * fromwdata, int is_view) { GList * templist, * filelist, * newfile; gftp_window_data * towdata; gftp_file * new_fle; char *suffix; int num; if (!check_status (is_view ? _("View") : _("Edit"), fromwdata, 0, 1, 1, 1)) return; towdata = fromwdata == &window1 ? &window2 : &window1; templist = GTK_CLIST (fromwdata->listbox)->selection; num = 0; filelist = fromwdata->files; templist = get_next_selection (templist, &filelist, &num); curfle = filelist->data; if (S_ISDIR (curfle->st_mode)) { if (is_view) ftp_log (gftp_logging_error, NULL, _("View: %s is a directory. Cannot view it.\n"), curfle->file); else ftp_log (gftp_logging_error, NULL, _("Edit: %s is a directory. Cannot edit it.\n"), curfle->file); return; } if (strcmp (gftp_protocols[fromwdata->request->protonum].name, "Local") == 0) view_file (curfle->file, 0, is_view, 0, 1, 1, NULL, fromwdata); else { new_fle = copy_fdata (curfle); if (new_fle->destfile) g_free (new_fle->destfile); if ((suffix = strrchr (curfle->file, '.')) != NULL) { new_fle->destfile = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXX", suffix, NULL); new_fle->fd = mkstemps (new_fle->destfile, strlen (suffix)); } else { new_fle->destfile = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXX", NULL); new_fle->fd = mkstemps (new_fle->destfile, 0); } if (new_fle->fd < 0) { ftp_log (gftp_logging_error, NULL, _("Error: Cannot open %s for writing: %s\n"), new_fle->destfile, g_strerror (errno)); gftp_file_destroy (new_fle, 1); return; } fchmod (new_fle->fd, S_IRUSR | S_IWUSR); if (is_view) { new_fle->done_view = 1; new_fle->done_rm = 1; } else new_fle->done_edit = 1; newfile = g_list_append (NULL, new_fle); gftpui_common_add_file_transfer (fromwdata->request, towdata->request, fromwdata, towdata, newfile); } }