char *fl_select_file(const char *path_, char *filters, const char *cap) { const char *caption = cap; if(!caption) caption="Choose File:"; Filter **f = Fl_File_Dialog::build_filters(filters); char *file = select_file(path_, f, caption, Fl_File_Dialog::DEFAULT); if(f) { for(int n=0; f[n]; n++) delete f[n]; delete []f; } return file; }
int main(int argc, char *argv[]) { int i; sfv_list_t *s; srand(gethrtime()); sendfilev_init(argv[1]); sendfilev_init(argv[1]); s = find_sfv_list(argv[1]); assert(s); for (i = 0; i < 10; i++) select_file(s); return (0); }
EXPORT void audgui_import_playlist (void) { int list = aud_playlist_get_active (); int id = aud_playlist_get_unique_id (list); char * filename = select_file (FALSE, NULL); if (! filename) return; if ((list = aud_playlist_by_unique_id (id)) < 0) return; aud_playlist_entry_delete (list, 0, aud_playlist_entry_count (list)); aud_playlist_entry_insert (list, 0, filename, NULL, FALSE); aud_playlist_set_filename (list, filename); g_free (filename); }
EXPORT void audgui_export_playlist (void) { int list = aud_playlist_get_active (); int id = aud_playlist_get_unique_id (list); char * def = aud_playlist_get_filename (list); char * filename = select_file (TRUE, def); str_unref (def); if (! filename || (vfs_file_test (filename, G_FILE_TEST_EXISTS) && ! confirm_overwrite (filename))) return; if ((list = aud_playlist_by_unique_id (id)) < 0) return; aud_playlist_save (list, filename); g_free (filename); }
/* Now walk the file_list_t list and count entries */ flist = fhead.next; for (fl = fhead.next; fl; fl = fl->next) count++; assert(count); if ((s = calloc(1, sizeof (sfv_list_t))) == NULL) { perror("calloc"); return (-1); } if ((s->flist = calloc(count, sizeof (struct file_list))) == NULL) { perror("calloc"); return (-1); } s->nfiles = count; flist = s->flist; (void) strlcpy(s->dir, dir, sizeof (s->dir)); for (fl = fhead.next; fl; fl = fl->next) { (void) memcpy(flist, fl, sizeof (file_list_t)); flist++; } if (sfv_list) { s->next = sfv_list->next; sfv_list->next = s; } else { sfv_list = s; } return (0); } #ifdef HAVE_SENDFILEV /* Linux does not have sendfilev */ static ssize_t do_sendfilev_chunked(sfv_list_t *s, int sock, int csize) { int size, r, n, xferred; struct sendfilevec vec; r = select_file(s); size = 0; vec.sfv_fd = s->flist[r].fd; vec.sfv_flag = 0; while (size < s->flist[r].size) { vec.sfv_off = size; vec.sfv_len = MIN(csize, s->flist[r].size - size); if ((n = sendfilev(sock, &vec, 1, (size_t *)&xferred)) <= 0) return (n); size += n; } return (size); }
void load_z80file() { unsigned char *videomem,*filename; int ancho,retorno; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose the Z80 snapshot file to load",-1,32,13,0,ancho); filename=select_file(load_path_snaps,FILETYPE_Z80); if(filename==NULL) { // Aborted clean_screen(); return; } retorno=load_z80(filename); free(filename); clean_screen(); switch(retorno) { case 0: // all right break; case -1: print_string(videomem,"Error: Can't load that file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); wait_key(); break; case -2: case -3: print_string(videomem,"Error: unsupported snap file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); wait_key(); break; } clean_screen(); }
static void on_record_action(GSimpleAction *action, GVariant *parameter, ReaderWindowPrivate *priv) { gchar *current_filename = cainteoir_settings_get_string(priv->settings, "recording", "filename", nullptr); gchar *current_mimetype = cainteoir_settings_get_string(priv->settings, "recording", "mimetype", "audio/x-vorbis+ogg"); gchar *filename = select_file(GTK_WINDOW(priv->self), i18n("Record Document"), GTK_FILE_CHOOSER_ACTION_SAVE, i18n("_Record"), current_filename, current_mimetype, priv->audio_formats); g_free(current_filename); g_free(current_mimetype); if (!filename) return; gchar *mimetype = nullptr; if (cainteoir_supported_formats_file_info(priv->audio_formats, filename, nullptr, &mimetype)) { CainteoirDocument *doc = reader_document_view_get_document(READER_DOCUMENT_VIEW(priv->view)); CainteoirDocumentIndex *index = reader_document_view_get_document_index(READER_DOCUMENT_VIEW(priv->view)); cainteoir_settings_set_string(priv->settings, "recording", "filename", filename); cainteoir_settings_set_string(priv->settings, "recording", "mimetype", mimetype); cainteoir_settings_save(priv->settings); cainteoir_speech_synthesizers_record(priv->tts, doc, index, filename, mimetype, 0.3); on_speak(priv); g_free(mimetype); g_object_unref(G_OBJECT(index)); g_object_unref(G_OBJECT(doc)); } g_free(filename); }
static void on_open_file_action(GSimpleAction *action, GVariant *parameter, ReaderWindowPrivate *priv) { gchar *current_filename = cainteoir_settings_get_string(priv->settings, "document", "filename", nullptr); gchar *current_mimetype = cainteoir_settings_get_string(priv->settings, "document", "mimetype", "text/plain"); gchar *filename = select_file(GTK_WINDOW(priv->self), i18n("Open Document"), GTK_FILE_CHOOSER_ACTION_OPEN, i18n("_Open"), current_filename, current_mimetype, priv->document_formats); g_free(current_filename); g_free(current_mimetype); if (filename) { reader_window_load_document(READER_WINDOW(priv->self), filename); g_free(filename); } }
void gdb_selectHP(Agent *, void *, void *call_data) { ReplyRequiredInfo *info = (ReplyRequiredInfo *)call_data; #if 0 if (gdb_keyboard_command) { // Use the GDB console to answer this query info->reply = ""; return; } #endif // Fetch previous output lines, in case this is a multi-line message. String s = XmTextGetString(gdb_w); string prompt(s); XtFree(s); prompt = prompt.from(int(messagePosition)) + info->question; // Issue prompt right now _gdb_out(info->question); info->question = ""; // Set and issue reply if (prompt.contains("file name")) { // File selection select_file(prompt, info->reply); } else { // Option selection select_from_gdb(prompt, info->reply); } _gdb_out(info->reply); }
ssize_t do_sendfile(int sock, char *dir, int chunk_size) { off_t off = 0; sfv_list_t *s; s = find_sfv_list(dir); assert(s); int r = select_file(s); if (chunk_size == 0) return (sendfile(sock, s->flist[r].fd, &off, s->flist[r].size)); else { int size = 0; int n; while (size < s->flist[r].size) { if ((n = sendfile(sock, s->flist[r].fd, &off, s->flist[r].size)) < 0) return (n); size += n; } return (size); } }
int item_saveas_action_cb(Ihandle* item_saveas) { return select_file(IupGetDialog(item_saveas), 0); }
void on_button_save_as_clicked (GtkButton *button, gpointer user_data) { select_file ("Save Curve As",curve_save_cb); }
void on_button_open_clicked (GtkButton *button, gpointer user_data) { select_file ("Open Curve",curve_open_cb); }
void VR_Window::open_file() { ///////////////////////////////////////// Select Point Cloud List File ///////////////////////////////// select_file(); printf("\n Point Cloud List File: %s\n", point_cloud_list_file); FILE *fp; fp = fopen(point_cloud_list_file, "r"); if (fp != NULL) { clock_t timer = clock(); pc_file_open = true; char *trash = new char[1024]; while( fgets(trash,1024,fp) != NULL ) { float3 position; uint3 rgb; int check = sscanf(trash, "%f %f %f %d %d %d", &position.x, &position.y, &position.z, &rgb.x, &rgb.y, &rgb.z); if (check == 6) { if ( position.x > cloud->world.min.x && position.x < cloud->world.max.x && position.y > cloud->world.min.y && position.y < cloud->world.max.y && position.z > cloud->world.min.z && position.z < cloud->world.max.z ) { if (position.x > cloud->pcl.max.x) cloud->pcl.max.x = position.x; if (position.x < cloud->pcl.min.x) cloud->pcl.min.x = position.x; if (position.y > cloud->pcl.max.y) cloud->pcl.max.y = position.y; if (position.y < cloud->pcl.min.y) cloud->pcl.min.y = position.y; if (position.z > cloud->pcl.max.z) cloud->pcl.max.z = position.z; if (position.z < cloud->pcl.min.z) cloud->pcl.min.z = position.z; cloud->position.push_back(position); cloud->rgb.push_back(rgb); } } } fclose(fp); if ( cloud->position.size() != cloud->rgb.size() ) { printf("\n Error while reading point list. Different number of positions and color channels. Aborting.\n"); } cloud->pcl.count = cloud->position.size(); printf("\n %d points read from file", cloud->pcl.count ); printf("\n PCList Maximum: %f %f %f", cloud->pcl.max.x, cloud->pcl.max.y, cloud->pcl.max.z ); printf("\n PCList Minimum: %f %f %f", cloud->pcl.min.x, cloud->pcl.min.y, cloud->pcl.min.z ); cloud->pcl.dimension.x = abs( cloud->pcl.max.x - cloud->pcl.min.x ); cloud->pcl.dimension.y = abs( cloud->pcl.max.y - cloud->pcl.min.y ); cloud->pcl.dimension.z = abs( cloud->pcl.max.z - cloud->pcl.min.z ); printf("\n PCList Dimensions: %f %f %f\n", cloud->pcl.dimension.x, cloud->pcl.dimension.y, cloud->pcl.dimension.z ); printf("\n ||| TIME - Load Data File: %f ms\n", ((float)clock() - timer)*1000 / CLOCKS_PER_SEC ); } else { printf("\n Could not open file: %s", point_cloud_list_file); } }
void mapper_tilemap_logic(void) { int i, j; T3F_TILEMAP_LAYER * new_layer = NULL; ALLEGRO_PATH * temp_path = NULL; const char * fn = NULL; int mx, my; if(t3f_key[ALLEGRO_KEY_F3]) { fn = select_file(mapper_last_level_filename, "Open Tilemap", "*.*;*.t3m", ALLEGRO_FILECHOOSER_FILE_MUST_EXIST); if(fn) { if(mapper_tilemap) { t3f_destroy_tilemap(mapper_tilemap); } mapper_tilemap = t3f_load_tilemap(fn); strcpy(mapper_last_level_filename, fn); } t3f_key[ALLEGRO_KEY_F3] = 0; } if(t3f_key[ALLEGRO_KEY_F4]) { if(mapper_tilemap) { t3f_destroy_tilemap(mapper_tilemap); } mapper_tilemap = t3f_create_tilemap(mapper_map_width, mapper_map_height, mapper_map_layers); t3f_key[ALLEGRO_KEY_F4] = 0; } if(mapper_tilemap) { if(t3f_key[ALLEGRO_KEY_F2]) { fn = select_file(mapper_last_level_filename, "Save Tilemap", "*.*;*.t3m", ALLEGRO_FILECHOOSER_SAVE); if(fn) { temp_path = al_create_path(fn); if(temp_path) { al_set_path_extension(temp_path, ".t3m"); t3f_save_tilemap(mapper_tilemap, al_path_cstr(temp_path, '/')); strcpy(mapper_last_level_filename, al_path_cstr(temp_path, '/')); al_destroy_path(temp_path); } } t3f_key[ALLEGRO_KEY_F2] = 0; } mapper_tilemap_move_logic(); if(t3f_key[ALLEGRO_KEY_MINUS]) { mapper_current_tile--; if(mapper_current_tile < 0) { mapper_current_tile = mapper_tileset->tiles - 1; } t3f_key[ALLEGRO_KEY_MINUS] = 0; } if(t3f_key[ALLEGRO_KEY_EQUALS]) { mapper_current_tile++; if(mapper_current_tile >= mapper_tileset->tiles) { mapper_current_tile = 0; } t3f_key[ALLEGRO_KEY_EQUALS] = 0; } if(t3f_key[ALLEGRO_KEY_PGUP]) { if(t3f_key[ALLEGRO_KEY_LCTRL] && mapper_current_layer < mapper_tilemap->layers - 1) { new_layer = mapper_tilemap->layer[mapper_current_layer + 1]; mapper_tilemap->layer[mapper_current_layer + 1] = mapper_tilemap->layer[mapper_current_layer]; mapper_tilemap->layer[mapper_current_layer] = new_layer; } mapper_current_layer++; if(mapper_current_layer >= mapper_tilemap->layers) { mapper_current_layer = 0; } t3f_key[ALLEGRO_KEY_PGUP] = 0; } if(t3f_key[ALLEGRO_KEY_PGDN]) { if(t3f_key[ALLEGRO_KEY_LCTRL] && mapper_current_layer > 0) { new_layer = mapper_tilemap->layer[mapper_current_layer - 1]; mapper_tilemap->layer[mapper_current_layer - 1] = mapper_tilemap->layer[mapper_current_layer]; mapper_tilemap->layer[mapper_current_layer] = new_layer; } mapper_current_layer--; if(mapper_current_layer < 0) { mapper_current_layer = mapper_tilemap->layers - 1; } t3f_key[ALLEGRO_KEY_PGDN] = 0; } if(t3f_key[ALLEGRO_KEY_PAD_MINUS]) { mapper_tilemap->layer[mapper_current_layer]->z -= 1.0; } if(t3f_key[ALLEGRO_KEY_PAD_PLUS]) { mapper_tilemap->layer[mapper_current_layer]->z += 1.0; } if(t3f_key[ALLEGRO_KEY_PAD_ASTERISK]) { if(t3f_key[ALLEGRO_KEY_LCTRL]) { /* reset the scale and offset of the current layer */ if(t3f_key[ALLEGRO_KEY_LSHIFT]) { mapper_tilemap->layer[mapper_current_layer]->scale = 1.0; mapper_tilemap->layer[mapper_current_layer]->x = 0.0; mapper_tilemap->layer[mapper_current_layer]->y = 0.0; } /* scale the current layer so that the tiles are their actual size at the layer's current z-coordinate */ else { mapper_tilemap->layer[mapper_current_layer]->scale = mapper_get_scale(mapper_tilemap->layer[mapper_current_layer]->z); mapper_tilemap->layer[mapper_current_layer]->x = mapper_get_offset_x(mapper_tilemap->layer[mapper_current_layer]->z); mapper_tilemap->layer[mapper_current_layer]->y = mapper_get_offset_y(mapper_tilemap->layer[mapper_current_layer]->z); } } else { mapper_tilemap->layer[mapper_current_layer]->z = 0.0; } t3f_key[ALLEGRO_KEY_PAD_ASTERISK] = 0; } if(t3f_key[ALLEGRO_KEY_S]) { if(t3f_key[ALLEGRO_KEY_LCTRL]) { mapper_tilemap->layer[mapper_current_layer]->flags ^= T3F_TILEMAP_LAYER_STATIC; } else { mapper_tilemap->layer[mapper_current_layer]->flags ^= T3F_TILEMAP_LAYER_SOLID; } t3f_key[ALLEGRO_KEY_S] = 0; } if(t3f_key[ALLEGRO_KEY_INSERT] || t3f_key[ALLEGRO_KEY_I]) { if(mapper_tilemap->layers < 32) { new_layer = t3f_create_tilemap_layer(mapper_tilemap->layer[mapper_current_layer]->width, mapper_tilemap->layer[mapper_current_layer]->height); if(new_layer) { new_layer->x = mapper_tilemap->layer[mapper_current_layer]->x; new_layer->y = mapper_tilemap->layer[mapper_current_layer]->y; new_layer->z = mapper_tilemap->layer[mapper_current_layer]->z; new_layer->scale = mapper_tilemap->layer[mapper_current_layer]->scale; new_layer->speed_x = mapper_tilemap->layer[mapper_current_layer]->speed_x; new_layer->speed_y = mapper_tilemap->layer[mapper_current_layer]->speed_y; if(t3f_key[ALLEGRO_KEY_LCTRL]) { for(i = 0; i < new_layer->height; i++) { for(j = 0; j < new_layer->width; j++) { new_layer->data[i][j] = mapper_tilemap->layer[mapper_current_layer]->data[i][j]; } } } for(i = mapper_tilemap->layers; i > mapper_current_layer; i--) { mapper_tilemap->layer[i] = mapper_tilemap->layer[i - 1]; } mapper_tilemap->layer[mapper_current_layer] = new_layer; mapper_tilemap->layers++; } } t3f_key[ALLEGRO_KEY_INSERT] = 0; t3f_key[ALLEGRO_KEY_I] = 0; } if(t3f_key[ALLEGRO_KEY_DELETE]) { if(mapper_tilemap->layers > 1) { t3f_destroy_tilemap_layer(mapper_tilemap->layer[mapper_current_layer]); for(i = mapper_current_layer; i < mapper_tilemap->layers - 1; i++) { mapper_tilemap->layer[i] = mapper_tilemap->layer[i + 1]; } mapper_tilemap->layers--; if(mapper_current_layer >= mapper_tilemap->layers) { mapper_current_layer = mapper_tilemap->layers - 1; } } t3f_key[ALLEGRO_KEY_DELETE] = 0; } if(t3f_key[ALLEGRO_KEY_1]) { mapper_tilemap->layer[mapper_current_layer]->speed_x = 1.0; mapper_tilemap->layer[mapper_current_layer]->speed_y = 1.0; t3f_key[ALLEGRO_KEY_1] = 0; } if(t3f_key[ALLEGRO_KEY_C]) { mapper_bg_color = 1 - mapper_bg_color; t3f_key[ALLEGRO_KEY_C] = 0; } mapper_tilemap_hover_x = (int)(t3f_mouse_x + mapper_camera.x - mapper_tilemap->layer[mapper_current_layer]->x) / (mapper_tileset->width * mapper_tilemap->layer[mapper_current_layer]->scale); mapper_tilemap_hover_y = (int)(t3f_mouse_y + mapper_camera.y - mapper_tilemap->layer[mapper_current_layer]->y) / (mapper_tileset->height * mapper_tilemap->layer[mapper_current_layer]->scale); if(t3f_key[ALLEGRO_KEY_H]) { if(t3f_key[ALLEGRO_KEY_LSHIFT]) { mapper_tilemap_delete_row(mapper_current_layer, mapper_tilemap_hover_y); } else { mapper_tilemap_insert_row(mapper_current_layer, mapper_tilemap_hover_y); } t3f_key[ALLEGRO_KEY_H] = 0; } if(t3f_key[ALLEGRO_KEY_V]) { if(t3f_key[ALLEGRO_KEY_LSHIFT]) { mapper_tilemap_delete_column(mapper_current_layer, mapper_tilemap_hover_x); } else { mapper_tilemap_insert_column(mapper_current_layer, mapper_tilemap_hover_x); } t3f_key[ALLEGRO_KEY_V] = 0; } t3f_get_mouse_mickeys(&mx, &my, NULL); if(mapper_tilemap_hover_x < 0 || mapper_tilemap_hover_x >= mapper_tilemap->layer[mapper_current_layer]->width || mapper_tilemap_hover_y < 0 || mapper_tilemap_hover_y >= mapper_tilemap->layer[mapper_current_layer]->height) { mapper_tilemap_hover_fail = true; } else { mapper_tilemap_hover_fail = false; if(t3f_mouse_button[0]) { if(t3f_key[ALLEGRO_KEY_LCTRL]) { mapper_tilemap->layer[mapper_current_layer]->x -= mx; mapper_tilemap->layer[mapper_current_layer]->y -= my; } else if(t3f_key[ALLEGRO_KEY_LSHIFT]) { for(i = 0; i < mapper_tilemap->layer[mapper_current_layer]->height; i++) { for(j = 0; j < mapper_tilemap->layer[mapper_current_layer]->width; j++) { mapper_tilemap->layer[mapper_current_layer]->data[j][i] = mapper_current_tile; } } } else { mapper_tilemap->layer[mapper_current_layer]->data[mapper_tilemap_hover_y][mapper_tilemap_hover_x] = mapper_current_tile; } } } mapper_camera.z = mapper_tilemap->layer[mapper_current_layer]->z; } }
void mapper_tileset_logic(void) { const char * fn = NULL; const char * ext = NULL; T3F_ANIMATION * ap = NULL; ALLEGRO_BITMAP * bp = NULL; ALLEGRO_PATH * temp_path = NULL; int i; if(t3f_key[ALLEGRO_KEY_F3]) { fn = select_file(mapper_last_level_filename, "Open Tileset", "*.*;*.t3t", ALLEGRO_FILECHOOSER_FILE_MUST_EXIST); if(fn) { if(mapper_tileset) { t3f_destroy_tileset(mapper_tileset); } mapper_tileset = t3f_load_tileset(fn); strcpy(mapper_last_level_filename, fn); } t3f_key[ALLEGRO_KEY_F3] = 0; } if(t3f_key[ALLEGRO_KEY_F4]) { if(mapper_tileset) { t3f_destroy_tileset(mapper_tileset); } mapper_tileset = t3f_create_tileset(mapper_tile_width, mapper_tile_height); t3f_key[ALLEGRO_KEY_F4] = 0; } if(mapper_tileset) { if(t3f_key[ALLEGRO_KEY_F2]) { fn = select_file(mapper_last_level_filename, "Save Tileset", "*.*;*.t3t", ALLEGRO_FILECHOOSER_SAVE); if(fn) { temp_path = al_create_path(fn); if(temp_path) { al_set_path_extension(temp_path, ".t3t"); t3f_save_tileset(mapper_tileset, al_path_cstr(temp_path, '/')); strcpy(mapper_last_level_filename, al_path_cstr(temp_path, '/')); al_destroy_path(temp_path); } } t3f_key[ALLEGRO_KEY_F2] = 0; } if(t3f_key[ALLEGRO_KEY_INSERT] || t3f_key[ALLEGRO_KEY_I]) { fn = select_file(mapper_last_filename, "Open Animation", "*.*;*.ani;*.pcx;*.png;*.tga;*.jpg", ALLEGRO_FILECHOOSER_FILE_MUST_EXIST); if(fn) { ext = mapper_get_extension(fn); if(!strcmp(ext, "ani")) { ap = t3f_load_animation(fn); if(ap) { t3f_add_tile(mapper_tileset, ap); mapper_current_tile = mapper_tileset->tiles - 1; } } else { bp = al_load_bitmap(fn); if(bp) { mapper_import_tiles(bp); } al_destroy_bitmap(bp); } strcpy(mapper_last_filename, fn); } t3f_key[ALLEGRO_KEY_INSERT] = 0; t3f_key[ALLEGRO_KEY_I] = 0; } if(t3f_key[ALLEGRO_KEY_ENTER]) { fn = select_file(mapper_last_filename, "Open Animation", "*.*;*.ani;*.pcx;*.png;*.tga;*.jpg", ALLEGRO_FILECHOOSER_FILE_MUST_EXIST); if(fn) { ext = mapper_get_extension(fn); if(!strcmp(ext, "t3a")) { ap = t3f_load_animation(fn); if(ap) { t3f_destroy_animation(mapper_tileset->tile[mapper_current_tile]->ap); mapper_tileset->tile[mapper_current_tile]->ap = ap; } } else { bp = al_load_bitmap(fn); if(bp) { if(al_get_bitmap_width(bp) < mapper_tile_width) { al_destroy_bitmap(mapper_tileset->tile[mapper_current_tile]->ap->bitmaps->bitmap[0]); mapper_tileset->tile[mapper_current_tile]->ap->bitmaps->bitmap[0] = bp; } else { mapper_replace_tiles(bp); } } al_destroy_bitmap(bp); } strcpy(mapper_last_filename, fn); } t3f_key[ALLEGRO_KEY_ENTER] = 0; } if(t3f_key[ALLEGRO_KEY_DELETE]) { if(mapper_current_tile < mapper_tileset->tiles) { t3f_destroy_tile(mapper_tileset->tile[mapper_current_tile]); mapper_tilemap_replace_tile(mapper_current_tile, 0); for(i = mapper_current_tile; i < mapper_tileset->tiles - 1; i++) { mapper_tileset->tile[i] = mapper_tileset->tile[i + 1]; mapper_tilemap_replace_tile(i + 1, i); } mapper_tileset->tiles--; } t3f_key[ALLEGRO_KEY_DELETE] = 0; } if(t3f_key[ALLEGRO_KEY_A]) { mapper_view = MAPPER_VIEW_TILE_ANI; t3f_key[ALLEGRO_KEY_A] = 0; } mapper_hover_tile = ((int)t3f_mouse_y / mapper_tile_height) * (t3f_virtual_display_width / mapper_tile_width) + ((int)t3f_mouse_x / mapper_tile_width) % (t3f_virtual_display_width / mapper_tile_width); if(t3f_mouse_button[0] && mapper_hover_tile < mapper_tileset->tiles) { mapper_current_tile = mapper_hover_tile; } } }
void select_tapfile() { unsigned char *videomem,*filename; int ancho,retorno,retval; unsigned char char_id[11]; videomem=screen->pixels; ancho=screen->w; clean_screen(); print_string(videomem,"Choose the TAPE file to load",-1,32,13,0,ancho); filename=select_file(load_path_taps,FILETYPE_TAP_TZX); if(filename==NULL) { // Aborted clean_screen(); return; } ordenador.tape_current_bit=0; ordenador.tape_current_mode=TAP_TRASH; ordenador.next_block= NOBLOCK; if(ordenador.tap_file!=NULL) { fclose(ordenador.tap_file); } if (!strncmp(filename,"smb:",4)) ordenador.tap_file=fopen(filename,"r"); //tinysmb does not work with r+ else ordenador.tap_file=fopen(filename,"r+b"); // read and write ordenador.tape_write = 0; // by default, can't record if(ordenador.tap_file==NULL) retorno=-1; else retorno=0; clean_screen(); strcpy(ordenador.current_tap,filename); free(filename); switch(retorno) { case 0: // all right break; case -1: print_string(videomem,"Error: Can't load that file",-1,232,10,0,ancho); print_string(videomem,"Press any key",-1,248,10,0,ancho); ordenador.current_tap[0]=0; wait_key(); break; } retval=fread(char_id,10,1,ordenador.tap_file); // read the (maybe) TZX header if((!strncmp(char_id,"ZXTape!",7)) && (char_id[7]==0x1A)&&(char_id[8]==1)) { ordenador.tape_file_type = TAP_TZX; create_browser_tzx(ordenador.tap_file); } else { ordenador.tape_file_type = TAP_TAP; create_browser_tap(ordenador.tap_file); } clean_screen(); }
gboolean remove_from_tree(GNode *file, gboolean unmount) { int position = g_list_position(lines, FILE(file)->line); gboolean refresh_needed = FALSE; GList *line_ptr, *line_ptr2; GNode *dir_ptr; if (G_NODE_IS_ROOT(file)) { endwin(); clean_up(); printf("The tree root was removed\n"); exit(EXIT_SUCCESS); } if (g_node_is_ancestor(file, NODE(selected_line))) select_file(file); if (FILE(file)->type == directory_type) { close_directory(file); destroy_directory_content_real(file, FALSE); if (unmount) return TRUE; } else if (FILE(file)->type == file_type) { for (dir_ptr = file->parent; !G_NODE_IS_ROOT(dir_ptr); dir_ptr = dir_ptr->parent) { if (FILE(dir_ptr)->open == FALSE) { g_node_unlink(file); return FALSE; } } if (FILE(dir_ptr)->open == FALSE) { g_node_unlink(file); return FALSE; } } g_node_unlink(file); if (g_list_position(lines, first_line) <= position && position <= g_list_position(lines, last_line)) { if (first_line == FILE(file)->line && selected_line == FILE(file)->line) { selected_line = first_line = g_list_previous(first_line); lines = g_list_delete_link(lines, FILE(file)->line); print_lines(first_line, first_line, FALSE); } else if (position < g_list_position(lines, selected_line)) { if (first_line == FILE(file)->line) first_line = g_list_next(first_line); line_ptr = g_list_previous(FILE(file)->line); lines = g_list_delete_link(lines, FILE(file)->line); if ((line_ptr2 = g_list_previous(first_line)) != NULL) { first_line = line_ptr2; print_lines(first_line, line_ptr, FALSE); } else if ((line_ptr2 = g_list_next(last_line)) != NULL) { last_line = line_ptr2; print_lines(line_ptr, last_line, FALSE); } else print_lines(line_ptr, last_line, TRUE); } else { if (FILE(file)->line == selected_line) selected_line = g_list_previous(selected_line); if (last_line == FILE(file)->line) last_line = g_list_previous(last_line); line_ptr = g_list_previous(FILE(file)->line); lines = g_list_delete_link(lines, FILE(file)->line); if ((line_ptr2 = g_list_next(last_line)) != NULL) { last_line = line_ptr2; print_lines(line_ptr, last_line, FALSE); } else print_lines(line_ptr, last_line, TRUE); } refresh_needed = TRUE; } else { if (last_line == g_list_previous(FILE(file)->line)) { lines = g_list_delete_link(lines, FILE(file)->line); print_lines(last_line, last_line, FALSE); refresh_needed = TRUE; } else lines = g_list_delete_link(lines, FILE(file)->line); } free_node_data(file, NULL); g_node_destroy(file); return refresh_needed; }
/* * Name: list_and_pick * Purpose: To show matching file names and let user pick a file * Date: February 13, 1992 * Passed: dname: directory search pattern * stem: stem of directory search pattern * window: pointer to current window * Returns: return code from pick. rc = OK, then edit a new file. * Notes: real work routine of this function. save the cwd and let the * user search upwards or downwards thru the directory structure. * since we are doing DOS directory functions, we need to check the * return code after each DOS call for critical errors. */ int list_and_pick( char *dname, char *stem, WINDOW *window ) { int rc; DTA dta; /* disk transfer address for findfirst */ DIRECTORY dir; /* contains all info for dir display */ unsigned int cnt; /* number of matching files */ FTYPE *flist, *p; /* pointer to list of matching files */ char cwd[MAX_COLS]; /* save the current working directory in this buff */ char dbuff[MAX_COLS]; /* temporary directory buff */ char prefix[MAX_COLS]; /* directory prefix */ int change_directory = FALSE; int stop; int len; int drive; /* * Some algorithms alloc the maximum possible number of files in * a directory, eg. 256 or 512. Let's count the number of matching * files so we know egxactly how much memory to request from calloc. * Depending on the op system, disk media, disk format, or version of DOS, * the max number of files may vary, anyway, also, additionally. */ rc = my_findfirst( &dta, dname, NORMAL | READ_ONLY | HIDDEN | SYSTEM | SUBDIRECTORY | ARCHIVE ); if (rc != ERROR) { for (cnt=1; (rc = my_findnext( &dta )) == OK;) ++cnt; flist = (FTYPE *)calloc( cnt, sizeof(FTYPE) ); } else flist = NULL; if (rc != ERROR && flist != NULL) { stop = FALSE; /* * If user entered drive name in search pattern, find out the drive and * directory stem. */ if (stem[1] == ':') { /* * If the second character of the search pattern is a ':', the * the first character of the pattern should be the drive. * Convert drive to lower case and get a numerical representation. * CAVEAT: In DOS v 2.x, there may be up to 63 logical drives. * my algorithm may blow up if the number of logical drives * is greater than 'Z'. * For DOS >= 3, the number of drives is limited to 26, I think. */ drive = stem[0]; if (drive < 'a') drive += 32; drive = drive - 'a' + 1; rc = get_current_directory( dbuff, drive ); if (rc == ERROR) stop = TRUE; else { /* * Put drive letter, ':', and '\' in front of current directory. */ prefix[0] = (char)(drive - 1 + 'a'); prefix[1] = ':'; prefix[2] = '\\'; prefix[3] = '\0'; assert( strlen( prefix ) + strlen( dbuff ) < MAX_COLS ); strcpy( cwd, prefix ); strcat( cwd, dbuff ); } /* * else get current directory from default drive */ } else { /* * 0 = default drive. */ drive = 0; rc = get_current_directory( dbuff, drive ); if (rc == ERROR) stop = TRUE; else { /* * Put a '\' in front of the current directory. */ prefix[0] = '\\'; prefix[1] = '\0'; assert( strlen( prefix ) + strlen( dbuff ) < MAX_COLS ); strcpy( cwd, prefix ); strcat( cwd, dbuff ); } } while (stop == FALSE) { /* * If we had enough memory, find all matching file names. Append * '\\' at the end of subdirectory names so user will know if * name is a directory. Might as well find everything, because * i also forget subdirectory names, too. * * when we get here, we have already done: 1) my_findfirst and * my_findnext, 2) counted the number of matching files, and * 3) allocated space. */ p = flist; cnt = 0; rc = my_findfirst( &dta, dname, NORMAL | READ_ONLY | HIDDEN | SYSTEM | SUBDIRECTORY | ARCHIVE ); if (rc != ERROR) { /* * p is pointer that walks down the file info structure. * save the file name, file size, and directory character, * if needed, for each matching file we find. */ assert( strlen( dta.name ) < 14 ); strcpy( p->fname, dta.name ); p->fsize = dta.size; if (dta.attrib & SUBDIRECTORY) strcat( p->fname, "\\" ); for (cnt=1; (rc = my_findnext( &dta )) == OK; ) { ++p; assert( strlen( dta.name ) < 14 ); strcpy( p->fname, dta.name ); p->fsize = dta.size; if (dta.attrib & SUBDIRECTORY) strcat( p->fname, "\\" ); cnt++; } } if (rc != ERROR) { shell_sort( flist, cnt ); /* * figure out number of rows, cols, etc... then display dir list */ setup_directory_window( &dir, cnt ); write_directory_list( flist, dir ); /* * Let user select file name or another search directory. * Save the choice in dbuff. rc == OK if user selected file or dir. */ rc = select_file( flist, stem, &dir ); assert( strlen( flist[dir.select].fname ) < MAX_COLS ); strcpy( dbuff, flist[dir.select].fname ); } /* * give memory back. */ free( flist ); if (rc == ERROR) stop = TRUE; else { len = strlen( dbuff ); /* * If the last character in a file name is '\' then let's * do a dir on selected directory. See the matching * else when the user selects a file. */ if (dbuff[len-1] == '\\') { /* * Stem has subdirectory path. dbuff has selected path. * Create a new dname with stem and dbuff. */ assert( strlen( stem ) + strlen( dbuff ) < MAX_COLS ); strcpy( dname, stem ); strcat( dname, dbuff ); len = strlen( dname ); strcpy( dbuff, dname ); /* * The last character in dbuff is '\', because we append the * '\' to every directory entry in the file list. Replace * it with a NULL char then we will have a valid path name. */ dbuff[len-1] = '\0'; /* * now let's change to the selected subdirectory. */ rc = set_current_directory( dbuff ); if (rc == OK) { /* * Every time we change directories, we need to get the * current directory so we will be sure to have the * correct path. */ rc = get_current_directory( dbuff, drive ); if (rc == OK) { assert( strlen( prefix ) + strlen( dbuff ) < MAX_COLS ); strcpy( dname, prefix ); strcat( dname, dbuff ); change_directory = TRUE; } } /* * Validate the new path and allocate memory for the * matching files. */ if (rc == OK) rc = validate_path( dname, stem ); if (rc == OK) { rc = my_findfirst( &dta, dname, NORMAL | READ_ONLY | HIDDEN | SYSTEM | SUBDIRECTORY | ARCHIVE ); if (rc != ERROR) { for (cnt=1; (rc = my_findnext( &dta )) == OK;) ++cnt; flist = (FTYPE *)calloc( cnt, sizeof(FTYPE) ); } } if (flist == NULL || rc == ERROR) { stop = TRUE; rc = ERROR; } } else { /* * user selected a file. store fname in dname and return. */ rc = OK; stop = TRUE; assert( strlen( stem ) + strlen( dbuff ) < MAX_COLS ); strcpy( dname, stem ); strcat( dname, dbuff ); } } } /* * Go back to the current directory if needed. */ if (change_directory) set_current_directory( cwd ); if (window != NULL) redraw_screen( window ); } else { /* * out of memory */ error( WARNING, window != NULL ? window->bottom_line : g_display.nlines, dir3 ); rc = ERROR; } return( rc ); }
int main() { int fd,atrlen,i,j,len; char mask[100],atr[100],data[100]; fd=serial_init("/dev/smartpoll"); if(send_num_mask(fd, mask)<0) { perror("send_num_mask failed"); return -1; } printf("Mask is : %s\n", mask); if((atrlen = power_up_iso(fd, atr))<0) { perror("power_up_iso failed"); return -1; } printf("ATR: "); for(i=0;i<atrlen;i++) printf("%x ", (unsigned char)atr[i]); printf("\n"); if(select_file(fd, 0x5f00)<0) { printf("Select file failed\n"); return -1; } printf("Selected file 0x5f00\n"); if((len=read_binary(fd, 0, 50, data))<0) { printf("read_binary failed\n"); return -1; } printf("Data (b4 write): "); for(i=0;i<len;i++) printf("%x ", (unsigned char)data[i]); printf("\n"); /* if(erase_binary(fd)<0) return -1; printf("Erased file 0x1f01\n"); */ memset(data,0x05,10); if(update_binary(fd, 0x14, 10, data)<0) return -1; printf("Wrote to file 0x5f00\n"); if((len=read_binary(fd, 0, 50, data))<0) return -1; printf("Data (after write): "); for(i=0;i<len;i++) printf("%x ", (unsigned char)data[i]); printf("\n"); serial_deinit(fd); }
/** Crée l'interface : boutons, intitulés, menus... */ void Ui_MainWindow::setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName(QString::fromUtf8("MainWindow")); actionQuitter = new QAction(MainWindow); actionQuitter->setObjectName(QString::fromUtf8("actionQuitter")); actionFichier = new QAction(MainWindow); actionFichier->setObjectName(QString::fromUtf8("actionFichier")); actionWebcam = new QAction(MainWindow); actionWebcam->setObjectName(QString::fromUtf8("actionWebcam")); centralwidget = new QWidget(MainWindow); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); listWidget = new QListWidget(centralwidget); new QListWidgetItem(listWidget); listWidget->setObjectName(QString::fromUtf8("listWidget")); listWidget->setDragDropMode(QAbstractItemView::InternalMove); cvwidget = new QOpenCVWidget(this); cvwidget->setObjectName(QString::fromUtf8("cvwidget")); label_2 = new QLabel(centralwidget); label_2->setObjectName(QString::fromUtf8("label_2")); label_6 = new QLabel(centralwidget); label_6->setObjectName(QString::fromUtf8("label_6")); comboBox_4 = new QComboBox(centralwidget); comboBox_4->setObjectName(QString::fromUtf8("comboBox_4")); buttonBox_2 = new QDialogButtonBox(centralwidget); buttonBox_2->setObjectName(QString::fromUtf8("buttonBox_2")); apply_button = new QPushButton(tr("Appliquer")); delete_button = new QPushButton(tr("Supprimer")); buttonBox_2->addButton(apply_button, QDialogButtonBox::AcceptRole); buttonBox_2->addButton(delete_button, QDialogButtonBox::RejectRole); comboBox = new QComboBox(centralwidget); comboBox->setObjectName(QString::fromUtf8("comboBox")); MainWindow->setCentralWidget(centralwidget); menubar = new QMenuBar(MainWindow); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 540, 25)); menuFichier = new QMenu(menubar); menuFichier->setObjectName(QString::fromUtf8("menuFichier")); menuOuvrir = new QMenu(menuFichier); menuOuvrir->setObjectName(QString::fromUtf8("menuOuvrir")); MainWindow->setMenuBar(menubar); statusbar = new QStatusBar(MainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); MainWindow->setStatusBar(statusbar); menubar->addAction(menuFichier->menuAction()); menuFichier->addAction(menuOuvrir->menuAction()); menuFichier->addAction(actionQuitter); menuOuvrir->addAction(actionFichier); menuOuvrir->addAction(actionWebcam); may_the_force_be_with_you(); retranslateUi(MainWindow); QObject::connect(actionQuitter, SIGNAL(triggered()), MainWindow, SLOT(close())); QObject::connect(actionFichier, SIGNAL(triggered()), MainWindow, SLOT(select_file())); QObject::connect(buttonBox_2, SIGNAL(accepted()), MainWindow, SLOT(apply_changes())); QObject::connect(buttonBox_2, SIGNAL(rejected()), MainWindow, SLOT(delete_filter())); QObject::connect(actionWebcam, SIGNAL(triggered()), MainWindow, SLOT(select_camera())); QMetaObject::connectSlotsByName(MainWindow); }
ssize_t do_sendfile(int sock, char *dir, int chunk_size) { #if defined(UPERF_FREEBSD) || defined(UPERF_DARWIN) off_t len; #endif off_t off = 0; sfv_list_t *s; s = find_sfv_list(dir); assert(s); int r = select_file(s); if (chunk_size == 0) { #if defined(UPERF_FREEBSD) || defined(UPERF_DARWIN) #if defined(UPERF_FREEBSD) len = 0; if (sendfile(s->flist[r].fd, sock, off, s->flist[r].size, NULL, &len, 0) < 0) { #else len = s->flist[r].size; if (sendfile(s->flist[r].fd, sock, off, &len, NULL, 0) < 0) { #endif return (-1); } else { return (len); } #else return (sendfile(sock, s->flist[r].fd, &off, s->flist[r].size)); #endif } else { #if defined(UPERF_FREEBSD) || defined(UPERF_DARWIN) while (off < s->flist[r].size) { #if defined(UPERF_FREEBSD) len = 0; if (sendfile(s->flist[r].fd, sock, off, chunk_size, NULL, &len, 0) < 0) { #else len = chunk_size; if (sendfile(s->flist[r].fd, sock, off, &len, NULL, 0) < 0) { #endif return (-1); } off += len; } #else while (off < s->flist[r].size) { if (sendfile(sock, s->flist[r].fd, &off, chunk_size) < 0) { return (-1); } } #endif return (s->flist[r].size); } } #ifdef MAIN int main(int argc, char *argv[]) { int i; sfv_list_t *s; srand(gethrtime()); sendfilev_init(argv[1]); sendfilev_init(argv[1]); s = find_sfv_list(argv[1]); assert(s); for (i = 0; i < 10; i++) select_file(s); return (0); }
int main(void) { __Set(BEEP_VOLUME, 0); // USART1 8N1 115200bps debug port RCC->APB2ENR |= RCC_APB2ENR_USART1EN; USART1->BRR = 72000000 / 115200; USART1->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE; gpio_usart1_tx_mode(GPIO_AFOUT_10); gpio_usart1_rx_mode(GPIO_HIGHZ_INPUT); printf("\nBoot!\n"); // Reduce the wait states of the FPGA & LCD interface // It works for me, hopefully it works for you too :) FSMC_BTR1 = 0x10100110; FSMC_BTR2 = 0x10100110; __Set(ADC_CTRL, EN); __Set(ADC_MODE, SEPARATE); alterbios_init(); int status = alterbios_check(); if (status < 0) { char buf[100]; snprintf(buf, sizeof(buf), "AlterBIOS not found or too old: %d\n" "Please install it from https://github.com/PetteriAimonen/AlterBIOS", status); while (1) show_msgbox("AlterBIOS is required", buf); } get_keys(ALL_KEYS); // Clear key buffer while (true) { select_file(amx_filename); get_keys(ANY_KEY); __Clear_Screen(0); char error[50] = {0}; int status = loadprogram(amx_filename, error, sizeof(error)); if (status != 0) { char buffer[200]; snprintf(buffer, sizeof(buffer), "Loading of program %s failed:\n\n" "Error %d: %s\n\n" "%s\n", amx_filename, status, my_aux_StrError(status), error); printf(buffer); printf(amx_filename); show_msgbox("Program load failed", buffer); } else { int idle_func = -1; if (amx_FindPublic(&amx, "@idle", &idle_func) != 0) idle_func = -1; cell ret; status = amx_Exec(&amx, &ret, AMX_EXEC_MAIN); while (status == AMX_ERR_SLEEP) { AMX nested_amx = amx; uint32_t end = get_time() + amx.pri; do { status = doevents(&nested_amx); } while (get_time() < end && status == 0); if (status == 0) status = amx_Exec(&amx, &ret, AMX_EXEC_CONT); else amx = nested_amx; // Report errors properly } if (status == 0 && idle_func != -1) { // Main() exited, keep running idle function. do { status = doevents(&amx); if (status == 0) status = amx_Exec(&amx, &ret, idle_func); } while (status == 0 && ret != 0); } amxcleanup_wavein(&amx); amxcleanup_file(&amx); if (status == AMX_ERR_EXIT && ret == 0) status = 0; // Ignore exit(0), but inform about e.g. exit(1) if (status != 0) { show_pawn_traceback(amx_filename, &amx, status); } else { draw_menubar("Close", "", "", ""); while (!get_keys(BUTTON1)); } } } return 0; }