static gboolean command_line_eval_cb (const GMatchInfo *info, GString *res, gpointer data) { ReplaceData *replace_data = data; char *r = NULL; char *match; match = g_match_info_fetch (info, 0); if (strcmp (match, "%U") == 0) r = create_file_list (replace_data->file_list, get_uri_func, replace_data->quote_values); else if (strcmp (match, "%F") == 0) r = create_file_list (replace_data->file_list, get_filename_func, replace_data->quote_values); else if (strcmp (match, "%B") == 0) r = create_file_list (replace_data->file_list, get_basename_func, replace_data->quote_values); else if (strcmp (match, "%N") == 0) r = create_file_list (replace_data->file_list, get_basename_wo_ext_func, replace_data->quote_values); else if (strcmp (match, "%E") == 0) r = create_file_list (replace_data->file_list, get_ext_func, replace_data->quote_values); else if (strcmp (match, "%P") == 0) r = create_file_list (replace_data->file_list, get_parent_func, replace_data->quote_values); else if (strncmp (match, "%attr", 5) == 0) { r = create_attribute_list (replace_data->file_list, match, replace_data->quote_values); if (r == NULL) *replace_data->error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_FAILED, _("Malformed command")); } else if (strncmp (match, "%ask", 4) == 0) { r = ask_value (replace_data, match, replace_data->error); if ((r != NULL) && replace_data->quote_values) { char *q; q = g_shell_quote (r); g_free (r); r = q; } } if (r != NULL) g_string_append (res, r); g_free (r); g_free (match); return FALSE; }
void do_poke() { unsigned char *videomem,string[80]; int ancho,retorno,address,old_value,new_value; videomem=screen->pixels; ancho=screen->w; clean_screen(); while(1) { print_string(videomem,"Type address to POKE",-1,32,15,0,ancho); print_string(videomem,"(ESC to exit)",-1,52,12,0,ancho); retorno=ask_value(&address,84,65535); clean_screen(); if (retorno==2) { return; } if ((address<16384) && ((ordenador.mode128k != 3) || (1 != (ordenador.mport2 & 0x01)))) { print_string(videomem,"That address is ROM memory.",-1,13,15,0,ancho); continue; } switch (address & 0x0C000) { case 0x0000: old_value= (*(ordenador.block0 + address)); break; case 0x4000: old_value= (*(ordenador.block1 + address)); break; case 0x8000: old_value= (*(ordenador.block2 + address)); break; case 0xC000: old_value= (*(ordenador.block3 + address)); break; default: old_value=0; break; } print_string(videomem,"Type new value to POKE",-1,32,15,0,ancho); print_string(videomem,"(ESC to cancel)",-1,52,12,0,ancho); sprintf(string,"Address: %d; old value: %d\n",address,old_value); print_string(videomem,string,-1,130,14,0,ancho); retorno=ask_value(&new_value,84,255); clean_screen(); if (retorno==2) { continue; } switch (address & 0x0C000) { case 0x0000: (*(ordenador.block0 + address))=new_value; break; case 0x4000: (*(ordenador.block1 + address))=new_value; break; case 0x8000: (*(ordenador.block2 + address))=new_value; break; case 0xC000: (*(ordenador.block3 + address))=new_value; break; default: break; } sprintf(string,"Set address %d from %d to %d\n",address,old_value,new_value); print_string(videomem,string,-1,130,14,0,ancho); } }
void ask_int_choice (int mask, char *macro, char *question, int format, int defa, char *choices) { int num, i; if (dump_only) { for (i = 0; i < OPT_LAST; i++) if (mask == B (i)) { unsigned int j; for (j = 0; j < strlen (choices); j++) if (choices[j] == '\'') choices[j] = '_'; printf ("\nif [ \"$CONFIG_%s\" = \"y\" ]; then\n", hw_table[i].macro); if (format == FMT_INT) printf ("int '%s %s' %s %d\n", question, choices, macro, defa); else printf ("hex '%s %s' %s %x\n", question, choices, macro, defa); printf ("fi\n"); } } else { if (!(mask & selected_options)) return; fprintf (stderr, "\n%s\n", question); if (strcmp (choices, "")) fprintf (stderr, "Possible values are: %s\n", choices); if (format == FMT_INT) { if (defa == -1) fprintf (stderr, "\t(-1 disables this feature)\n"); fprintf (stderr, "The default value is %d\n", defa); fprintf (stderr, "Enter the value: "); num = ask_value ("%d", defa); if (num == -1) return; fprintf (stderr, "%s set to %d.\n", question, num); printf ("#define %s %d\n", macro, num); } else { if (defa == 0) fprintf (stderr, "\t(0 disables this feature)\n"); fprintf (stderr, "The default value is %x\n", defa); fprintf (stderr, "Enter the value: "); num = ask_value ("%x", defa); if (num == 0) return; fprintf (stderr, "%s set to %x.\n", question, num); printf ("#define %s 0x%x\n", macro, num); } } }