// -------------------------------------------------------------------------- // -------------------------------------------------------------------------- bool t_scenario_cut_scene_info::write( std::streambuf & stream ) const { put< t_uint16 >( stream, k_current_format_version ); return write_string16( stream, m_text ) && write_string16( stream, get_keyword( m_image_id ) ) && write_string16( stream, get_keyword( m_voice_over_id ) ); }
void parse_xc_func(int & x_func, int & c_func, const std::string & xc) { // Default values - no functional used. x_func=0; c_func=0; // Check if there is a dash in the input. size_t dpos=xc.find('-',0); if(dpos!=std::string::npos) { // OK, there is a dash. // Exchange part is std::string x=xc.substr(0,dpos); // and correlation part is std::string c=xc.substr(dpos+1,xc.size()-dpos); // Functionals are x_func=find_func(x); c_func=find_func(c); } else { // No dash, so this should be an exchange-correlation functional. x_func=find_func(xc); c_func=0; } /* // Check functionals if(is_correlation(x_func) && !is_exchange_correlation(x_func)) { ERROR_INFO(); print_info(x_func,0); throw std::runtime_error("Refusing to use a correlation functional as exchange.\n"); } if(is_exchange(c_func)) { ERROR_INFO(); print_info(c_func,0); throw std::runtime_error("Refusing to use an exchange functional as correlation.\n"); } */ // Sanity check: don't try to use kinetic energy functionals. if(is_kinetic(x_func)) { ERROR_INFO(); std::ostringstream oss; oss << "The wanted functional "<< get_keyword(x_func) << " is a kinetic energy functional.\n"; throw std::runtime_error(oss.str()); } if(is_kinetic(c_func)) { ERROR_INFO(); std::ostringstream oss; oss << "The wanted functional "<< get_keyword(c_func) << " is a kinetic energy functional.\n"; throw std::runtime_error(oss.str()); } }
// ---------------------------------------------------------------------------- // get a sound for a creature // ---------------------------------------------------------------------------- static t_sound_ptr get_sound( t_creature_type creature, t_combat_actor_action_id action ) { static bool initialized = false; static t_sound_cache caches[k_creature_type_count][k_combat_actor_action_count]; if (!initialized) { t_creature_type index; t_combat_actor_action_id id; std::string name; for (index = t_creature_type(0); index < k_creature_type_count; enum_incr(index)) { for (id = t_combat_actor_action_id(0); id < k_combat_actor_action_count; enum_incr(id)) { name = get_keyword( index ); name += "."; name += get_combat_actor_action_name( id ); caches[index][id] = t_sound_cache( name ); } } initialized = true; } t_sound_ptr result = caches[creature][action].get(); if (result == 0) if ( action == k_combat_actor_action_melee_down || action == k_combat_actor_action_melee_up) return get_sound( creature, k_combat_actor_action_melee ); return result; }
void parse_header (header the_header, register char *where) { register header old = the_header; do { char *field; register char *keyword = get_keyword (the_header->text->string, &field); if (strcmp (keyword, "TO") == 0) where = add_field (the_header->text->continuation, field, where); else if (strcmp (keyword, "CC") == 0) where = add_field (the_header->text->continuation, field, where); else if (strcmp (keyword, "BCC") == 0) { where = add_field (the_header->text->continuation, field, where); the_header->previous->next = the_header->next; the_header->next->previous = the_header->previous; } else if (strcmp (keyword, "FCC") == 0) setup_files (the_header->text->continuation, field); the_header = the_header->next; } while (the_header != old); *where = '\0'; return; }
void print_info(int x_func, int c_func) { if(is_exchange_correlation(x_func)) { printf("Used exchange-correlation functional is %s, ",get_keyword(x_func).c_str()); print_info(x_func); } else { if(is_exchange(x_func)) { printf("Used exchange functional is %s, ",get_keyword(x_func).c_str()); print_info(x_func); } else printf("No exchange functional.\n"); if(is_correlation(c_func)) { printf("\nUsed correlation functional is %s, ",get_keyword(c_func).c_str()); print_info(c_func); printf("\n"); } else printf("\nNo correlation functional.\n\n"); } }
int read_and_parse_shell () { keyword_t key; prompt(); fgets(read_buffer,BUFFER_LENGTH,stdin); read_next_char (); key = get_keyword (); return key.code; }
static void test_keywords(CuTest * tc) { const char * data = "{\"keywords\": { \"de\" : { \"move\" : \"NACH\", \"study\" : [ \"LERNEN\", \"STUDIEREN\" ] }}}"; const struct locale * lang; cJSON *json = cJSON_Parse(data); test_cleanup(); lang = get_or_create_locale("de"); CuAssertPtrNotNull(tc, json); CuAssertIntEquals(tc, NOKEYWORD, get_keyword("potato", lang)); json_config(json); CuAssertIntEquals(tc, K_STUDY, get_keyword("studiere", lang)); CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang)); CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang)); CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "keyword::study")); test_cleanup(); }
void gmcommands(void) { region **rp = ®ions; while (*rp) { region *r = *rp; unit **up = &r->units; while (*up) { unit *u = *up; struct order *ord; for (ord = u->orders; ord; ord = ord->next) { if (get_keyword(ord) == K_GM) { do_command(&g_root, u, ord); } } if (u == *up) up = &u->next; } if (*rp == r) rp = &r->next; } }
// ------------------------------------------------------------------------- // get properties for a given artifact image // ------------------------------------------------------------------------- t_bitmap_layer_ptr get_icon( t_artifact_type artifact ) { assert( !is_cut( artifact ) ); static bool initialized = false; static t_bitmap_pool k_artifact_icons; static int icon_ids[ k_artifact_type_count ]; static t_bitmap_group_cache caches[] = { "icons.artifacts.armor", "icons.artifacts.item", "icons.artifacts.special", "icons.artifacts.weapon" }; if (!initialized) { std::vector<t_string_pair> layer_names( k_artifact_type_count ); t_artifact_type artifact; initialized = true; for (artifact = t_artifact_type(0); artifact < k_artifact_type_count; enum_incr(artifact)) { t_string_pair & layer_name = layer_names[ artifact ]; t_artifact_properties const & properties = get_properties( artifact ); if ( !properties.cut ) { layer_name.value = get_properties( artifact ).file_id; layer_name.keyword = get_keyword( artifact ); } else layer_name.value = 0; } k_artifact_icons = t_bitmap_pool( caches, &(*layer_names.begin()), layer_names.size() ); } return k_artifact_icons.get( artifact ); }
/* Compute the total size of all recipient names stored in THE_HEADER. * The result says how big to make the buffer to pass to parse_header. */ int args_size(header the_header) { register header old = the_header; register line_list rem; register int size = 0; do { char *field; register char *keyword = get_keyword(the_header->text->string, &field); if ((strcmp(keyword, "TO") == 0) || (strcmp(keyword, "CC") == 0) || (strcmp(keyword, "BCC") == 0)) { size += 1 + strlen (field); for (rem = the_header->text->continuation; rem != NIL; rem = rem->continuation) size += (1 + strlen(rem->string)); } the_header = the_header->next; } while (the_header != old); return size; }
/* Take args arguments at argv and attempt to perform the operation specified */ void parseline(int args, char *argv[]) { int i; int j; enum keyword command; /* command to execute */ if (hist != NULL) { /* save the command to history file */ timestamp(); for (i = 0; i < args; i++) /* all args */ fprintf(hist, "%s ", argv[i]); fputs("\n", hist); } if ((args == 0) /* empty line */ ||(*argv[0] == '#')) /* or a comment, */ return; if (args == MAXARGS) { /* too many arguments, */ fprintf(stderr, "Too many arguments to %s, this can't be right\n", argv[0]); return; } command = get_keyword(argv[0], &keyword_set); dowait = 0; /* initialize flags */ force = 0; /* initialize flags */ vflag = 0; /* initialize flags */ Verbose = 0; /* initialize flags */ recurse = 0; /* initialize flags */ sflag = 0; /* initialize flags */ objectname = NULL; /* no name yet */ /* * first handle generic options * We don't use getopt(3) because * getopt doesn't allow merging flags * (for example, -fr). */ for (i = 1; (i < args) && (argv[i][0] == '-'); i++) { /* while we have flags */ for (j = 1; j < strlen(argv[i]); j++) switch (argv[i][j]) { #if VINUMDEBUG case 'd': /* -d: debug */ debug = 1; break; #endif case 'f': /* -f: force */ force = 1; break; case 'i': /* interval */ interval = 0; if (argv[i][j + 1] != '\0') /* operand follows, */ interval = atoi(&argv[i][j + 1]); /* use it */ else if (args > (i + 1)) /* another following, */ interval = atoi(argv[++i]); /* use it */ if (interval == 0) /* nothing valid, */ fprintf(stderr, "-i: no interval specified\n"); break; case 'n': /* -n: get name */ if (i == args - 1) { /* last arg */ fprintf(stderr, "-n requires a name parameter\n"); return; } objectname = argv[++i]; /* pick it up */ j = strlen(argv[i]); /* skip the next parm */ break; case 'r': /* -r: recurse */ recurse = 1; break; case 's': /* -s: show statistics */ sflag = 1; break; case 'S': SSize = 0; if (argv[i][j + 1] != '\0') /* operand follows, */ SSize = atoi(&argv[i][j + 1]); /* use it */ else if (args > (i + 1)) /* another following, */ SSize = atoi(argv[++i]); /* use it */ if (SSize == 0) /* nothing valid, */ fprintf(stderr, "-S: no size specified\n"); break; case 'v': /* -v: verbose */ vflag++; break; case 'V': /* -V: Very verbose */ vflag++; Verbose++; break; case 'w': /* -w: wait for completion */ dowait = 1; break; default: fprintf(stderr, "Invalid flag: %s\n", argv[i]); } } /* Pass what we have left to the command to handle it */ for (j = 0; j < (sizeof(funkeys) / sizeof(struct funkey)); j++) { if (funkeys[j].kw == command) { /* found the command */ funkeys[j].fun(args - i, &argv[i], &argv[0]); return; } } fprintf(stderr, "Unknown command: %s\n", argv[0]); }
boolean has_keyword (char *field) { char *ignored; return (get_keyword (field, &ignored) != ((char *) NULL)); }
// --------------------------------------------------------------------- // create buttons // --------------------------------------------------------------------- void t_campaign_selection_dialog::create_buttons() { int i; t_bitmap_layer const* layer; t_window* window; t_screen_point point(0,0); t_screen_rect rect; t_button* button; t_help_block const& help = get_help_block( "shared" ); t_help_block const& campaign_help = get_help_block( "campaign_selection" ); // create cancel button rect = m_layout->find( "cancel_button" )->get_rect(); button = new t_button( g_cancel_button.get(), rect.top_left(), this ); button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::cancel_clicked ) ); set_help( button, help, "cancel" ); for( i = 0; i < k_campaign_count; ++i ) { std::string const & keyword = get_keyword( k_campaign_ids[ i ] ); std::string name = keyword; name += "_campaign"; layer = m_layout->find( name ); rect = layer->get_rect(); button = new t_button( rect.top_left(), this ); set_help( button, campaign_help, keyword ); switch( k_campaign_ids[ i ] ) { case k_standard_campaign_order: button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::order_clicked ) ); // if( m_enabled[k_standard_campaign_order] ) layer = g_order_intro.get()->find( "frame 001" ); // else // layer = g_order_intro_completed.get()->find( "frame 001" ); break; case k_standard_campaign_might: button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::might_clicked ) ); // if( m_enabled[k_standard_campaign_might] ) layer = g_might_intro.get()->find( "frame 001" ); // else // layer = g_might_intro_completed.get()->find( "frame 001" ); break; case k_standard_campaign_life: button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::life_clicked ) ); // if( m_enabled[k_standard_campaign_life] ) layer = g_life_intro.get()->find( "frame 001" ); // else // layer = g_life_intro_completed.get()->find( "frame 001" ); break; case k_standard_campaign_death: button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::death_clicked ) ); // if( m_enabled[k_standard_campaign_death] ) layer = g_death_intro.get()->find( "frame 001" ); // else // layer = g_death_intro_completed.get()->find( "frame 001" ); break; case k_standard_campaign_nature: button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::nature_clicked ) ); // if( m_enabled[k_standard_campaign_nature] ) layer = g_nature_intro.get()->find( "frame 001" ); // else // layer = g_nature_intro_completed.get()->find( "frame 001" ); break; case k_standard_campaign_chaos: button->set_click_handler( bound_handler(*this, &t_campaign_selection_dialog::chaos_clicked ) ); // if( m_enabled[k_standard_campaign_chaos] ) layer = g_chaos_intro.get()->find( "frame 001" ); // else // layer = g_chaos_intro_completed.get()->find( "frame 001" ); break; } window = new t_bitmap_layer_window( layer, point, button ); button->set_released_image( window ); } }
int is_keyword(pointer p) { return get_keyword(p)->type == TYPE_KEYWORD; }