static void output_citeparts( fields *info, FILE *outptr, int level, int max, int type ) { convert origin[] = { { "ADDRESS", "b:City", LEVEL_ANY }, { "PUBLISHER", "b:Publisher", LEVEL_ANY }, { "EDITION", "b:Edition", LEVEL_ANY } }; int norigin = sizeof( origin ) / sizeof ( convert ); convert parts[] = { { "VOLUME", "b:Volume", LEVEL_ANY }, { "SECTION", "b:Section", LEVEL_ANY }, { "ISSUE", "b:Issue", LEVEL_ANY }, { "NUMBER", "b:Issue", LEVEL_ANY }, { "PUBLICLAWNUMBER", "b:Volume", LEVEL_ANY }, { "SESSION", "b:Issue", LEVEL_ANY }, }; int nparts=sizeof(parts)/sizeof(convert); output_bibkey( info, outptr ); output_type( info, outptr, type ); output_list( info, outptr, origin, norigin ); output_date( info, outptr, level ); output_includedin( info, outptr, type ); output_list( info, outptr, parts, nparts ); output_pages( info, outptr, level ); output_names( info, outptr, level, type ); output_title( info, outptr, 0 ); output_comments( info, outptr, level ); }
void ChemistryMulti::output (Log& log) const { static const symbol chemistry_lib (Chemistry::component); static const symbol chemical_lib (Chemical::component); Chemistry::output (log); output_list (combine, "combine", log, chemistry_lib); output_list (chemicals, "trace", log, chemical_lib); // We can't log identifier_sequence yet. #if 0 output_variable (ignore, log); #endif }
/* * Describe "secondary bonuses" of an item. */ static bool describe_secondary(const object_type *o_ptr, u32b f1) { cptr descs[8]; int cnt = 0; int pval = (o_ptr->pval > 0 ? o_ptr->pval : -o_ptr->pval); /* Collect */ if (f1 & (TR1_MEL)) descs[cnt++] = "melee"; if (f1 & (TR1_ARC)) descs[cnt++] = "archery"; if (f1 & (TR1_STL)) descs[cnt++] = "stealth"; if (f1 & (TR1_PER)) descs[cnt++] = "perception"; if (f1 & (TR1_WIL)) descs[cnt++] = "will"; if (f1 & (TR1_SMT)) descs[cnt++] = "smithing"; if (f1 & (TR1_SNG)) descs[cnt++] = "song"; if (f1 & (TR1_TUNNEL)) descs[cnt++] = "tunneling"; if (f1 & (TR1_DAMAGE_SIDES)) descs[cnt++] = "damage sides"; /* Skip */ if (!cnt) return (FALSE); /* Start */ p_text_out(format("It %s your ", (o_ptr->pval >= 0 ? "improves" : "worsens"))); /* Output list */ output_list(descs, cnt); /* Output end */ p_text_out(format(" by %i. ", pval)); /* We found something */ return (TRUE); }
void my_select() { g_list.first->underline = 1; output_list(); my_setkey(); set_invisible_curs(); my_getkey(); }
/* FIRST(output statement)={OUTPUT} <output statement> -> OUTPUT(<output list>); Author: Kyle Hinskens */ void output_statement(void) { if (lookahead_token.code == KW_T && lookahead_token.attribute.get_int == OUTPUT) { match(KW_T,OUTPUT); match(LPR_T,NO_ATTR); output_list(); match(RPR_T,NO_ATTR); match(EOS_T,NO_ATTR); gen_incode("OUTPUT statement parsed"); } }
static void output_desc_list(cptr intro, cptr list[], int n) { if (n != 0) { /* Output intro */ p_text_out(intro); /* Output list */ output_list(list, n); /* Output end */ p_text_out(". "); } }
static void output_citeparts( fields *info, FILE *outptr, int level, int max, int type ) { convert origin[] = { { "ADDRESS", "b:City", "", LEVEL_ANY }, { "PUBLISHER", "b:Publisher", "", LEVEL_ANY }, { "EDITION", "b:Edition", "", LEVEL_ANY } }; int norigin = sizeof( origin ) / sizeof ( convert ); convert parts[] = { { "VOLUME", "b:Volume", "", LEVEL_ANY }, { "SECTION", "b:Section", "", LEVEL_ANY }, { "ISSUE", "b:Issue", "", LEVEL_ANY }, { "NUMBER", "b:Issue", "", LEVEL_ANY }, { "PUBLICLAWNUMBER", "b:Volume", "", LEVEL_ANY }, { "SESSION", "b:Issue", "", LEVEL_ANY }, { "URL", "b:Url", "", LEVEL_ANY }, { "JSTOR", "b:Url", "http://www.jstor.org/stable/", LEVEL_ANY }, { "ARXIV", "b:Url", "http://arxiv.org/abs/", LEVEL_ANY }, { "PMID", "b:Url", "http://www.ncbi.nlm.nih.gov/pubmed/", LEVEL_ANY }, { "PMC", "b:Url", "http://www.ncbi.nlm.nih.gov/pmc/articles/", LEVEL_ANY }, { "DOI", "b:Url", "http://dx.doi.org/", LEVEL_ANY }, }; int nparts=sizeof(parts)/sizeof(convert); output_bibkey( info, outptr ); output_type( info, outptr, type ); output_list( info, outptr, origin, norigin ); output_date( info, outptr, level ); output_includedin( info, outptr, type ); output_list( info, outptr, parts, nparts ); output_pages( info, outptr, level ); output_names( info, outptr, level, type ); output_maintitle( info, outptr, 0 ); output_comments( info, outptr, level ); }
/* * Describe the special slays and executes of an item. */ static bool describe_slay(const object_type *o_ptr, u32b f1) { cptr slays[8]; int slcnt = 0; /* Unused parameter */ (void)o_ptr; /* Collect brands */ if (f1 & (TR1_SLAY_WOLF)) slays[slcnt++] = "wolves"; if (f1 & (TR1_SLAY_ORC)) slays[slcnt++] = "orcs"; if (f1 & (TR1_SLAY_TROLL)) slays[slcnt++] = "trolls"; if (f1 & (TR1_SLAY_SPIDER)) slays[slcnt++] = "spiders"; if (f1 & (TR1_SLAY_DRAGON)) slays[slcnt++] = "dragons"; if (f1 & (TR1_SLAY_RAUKO)) slays[slcnt++] = "raukar"; if (f1 & (TR1_SLAY_UNDEAD)) slays[slcnt++] = "undead"; /* Describe */ if (slcnt) { if (o_ptr->number == 1) { /* Output intro */ p_text_out("It slays "); } else { /* Output intro */ p_text_out("They slay "); } /* Output list */ output_list(slays, slcnt); /* Output end */ p_text_out(". "); } /* We are done here */ return ((slcnt) ? TRUE : FALSE); }
/* * Describe stat modifications. */ static bool describe_stats(const object_type *o_ptr, u32b f1) { cptr descs[A_MAX]; int cnt = 0; int pval = (o_ptr->pval > 0 ? o_ptr->pval : -o_ptr->pval); /* Abort if the pval is zero */ //if (!pval) return (FALSE); /* Collect stat bonuses */ if (f1 & (TR1_STR)) descs[cnt++] = stat_names_full[A_STR]; if (f1 & (TR1_DEX)) descs[cnt++] = stat_names_full[A_DEX]; if (f1 & (TR1_CON)) descs[cnt++] = stat_names_full[A_CON]; if (f1 & (TR1_GRA)) descs[cnt++] = stat_names_full[A_GRA]; /* Skip */ if (cnt == 0) return (FALSE); /* Shorten to "all stats", if appropriate. */ if (cnt == A_MAX) { p_text_out(format("It %s all your stats", (o_ptr->pval >= 0 ? "increases" : "decreases"))); } else { p_text_out(format("It %s your ", (o_ptr->pval >= 0 ? "increases" : "decreases"))); /* Output list */ output_list(descs, cnt); } /* Output end */ p_text_out(format(" by %i. ", pval)); /* We found something */ return (TRUE); }
/* * Describe abilities granted by an object. */ static bool describe_abilities(const object_type *o_ptr) { cptr ability[8]; int ac = 0; ability_type *b_ptr; int i; // only describe when identified if (!object_known_p(o_ptr) && !(o_ptr->ident & (IDENT_SPOIL))) return (FALSE); // check its abilities for (i = 0; i < o_ptr->abilities; i++) { b_ptr = &b_info[ability_index(o_ptr->skilltype[i], o_ptr->abilitynum[i])]; ability[ac++] = b_name + b_ptr->name; } /* Describe */ if (ac) { /* Output intro */ if (ac == 1) p_text_out("It grants you the ability: "); else p_text_out("It grants you the abilities: "); /* Output list */ output_list(ability, ac); /* Output end (if needed) */ p_text_out(". "); /* It granted abilities */ return (TRUE); } /* No abilities granted */ return (FALSE); }
/* * Describe miscellaneous powers such as see invisible, free action, * permanent light, etc; also note curses and penalties. */ static bool describe_misc_magic(const object_type *o_ptr, u32b f2, u32b f3) { cptr good[7], bad[6]; int gc = 0, bc = 0; bool something = FALSE; /* Throwing weapons. */ if (f3 & (TR3_THROWING)) { good[gc++] = (format("can be thrown effectively (%d squares)",throwing_range(o_ptr))); } /* Collect stuff which can't be categorized */ if (((o_ptr->tval == TV_LIGHT) && artefact_p(o_ptr)) || ((o_ptr->tval != TV_LIGHT) && (f2 & (TR2_LIGHT)))) good[gc++] = "lights the dungeon around you"; if ((f2 & (TR2_LIGHT)) && (o_ptr->tval == TV_LIGHT)) good[gc++] = "burns brightly, increasing your light radius by an additional square"; if (f2 & (TR2_SLOW_DIGEST)) good[gc++] = "reduces your need for food"; if ((f2 & (TR2_RADIANCE)) && (o_ptr->tval == TV_BOW)) good[gc++] = "fires shining arrows"; if ((f2 & (TR2_RADIANCE)) && (o_ptr->tval == TV_BOOTS)) good[gc++] = "lights your path behind you"; if (f2 & (TR2_REGEN)) good[gc++] = "speeds your regeneration (which increases your hunger while active)"; /* Describe */ output_desc_list("It ", good, gc); /* Set "something" */ if (gc) something = TRUE; /* Collect granted powers */ gc = 0; if (f2 & (TR2_SPEED)) good[gc++] = "great speed"; if (f2 & (TR2_FREE_ACT)) good[gc++] = "freedom of movement"; if (f2 & (TR2_SEE_INVIS)) good[gc++] = "the ability to see invisible creatures"; /* Collect penalties */ if (f2 & (TR2_DANGER)) bad[bc++] = "makes you encounter more dangerous creatures (even when not worn)"; if (f2 & (TR2_FEAR)) bad[bc++] = "causes you to panic in combat"; if (f2 & (TR2_HUNGER)) bad[bc++] = "increases your hunger"; if (f2 & (TR2_DARKNESS)) bad[bc++] = "creates an unnatural darkness"; if (f2 & (TR2_SLOWNESS)) bad[bc++] = "slows your movement"; if (f2 & (TR2_AGGRAVATE)) bad[bc++] = "enrages nearby creatures"; if (f2 & (TR2_HAUNTED)) bad[bc++] = "draws wraiths to your level"; /* Deal with cursed stuff */ if (cursed_p(o_ptr)) { if (f3 & (TR3_PERMA_CURSE)) bad[bc++] = "is permanently cursed"; else if (f3 & (TR3_HEAVY_CURSE)) bad[bc++] = "is heavily cursed"; else if (object_known_p(o_ptr)) bad[bc++] = "is cursed"; } /* Describe */ if (gc) { /* Output intro */ p_text_out("It grants you "); /* Output list */ output_list(good, gc); /* Output end (if needed) */ if (!bc) p_text_out(". "); } if (bc) { /* Output intro */ if (gc) p_text_out(", but it also "); else p_text_out("It "); /* Output list */ output_list(bad, bc); /* Output end */ p_text_out(". "); } /* Set "something" */ if (gc || bc) something = TRUE; /* Return "something" */ return (something); }
int main(int argc, char *argv[]) { char *action; char *name; char *prefix; int ret; int fail = 0; char *state; if (argc != 4 || (strcmp(argv[1], "load") && strcmp(argv[1], "save") && strcmp(argv[1], "save+"))) { printf("Brain manipulation\n"); printf("Usage: %s load <name> <filename prefix>\n", argv[0]); printf(" %s save <name> <filename prefix>\n", argv[0]); printf(" %s save+ <name> <filename prefix>\n", argv[0]); return 1; } action = argv[1]; name = argv[2]; prefix = argv[3]; state = "db_connect"; ret = db_connect(); if (ret) goto fail; else log_info("brain", ret, state); state = "db_begin"; ret = db_begin(); if (ret) goto fail; else log_info("brain", ret, state); if (!strcmp(action, "load")) { state = "input_list aux"; ret = input_list(name, prefix, "aux", LIST_AUX); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "input_list ban"; ret = input_list(name, prefix, "ban", LIST_BAN); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "input_list grt"; ret = input_list(name, prefix, "grt", LIST_GREET); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "input_map swp"; ret = input_map(name, prefix, "swp", MAP_SWAP); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "input_brain"; ret = input_brain(name, prefix); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); } else if (!strcmp(action, "save") || !strcmp(action, "save+")) { enum file_type type = FILETYPE_MEGAHAL8; if (!strcmp(action, "save+")) type = FILETYPE_SQLHAL0; state = "output_list aux"; ret = output_list(name, prefix, "aux", LIST_AUX); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "output_list ban"; ret = output_list(name, prefix, "ban", LIST_BAN); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "output_list grt"; ret = output_list(name, prefix, "grt", LIST_GREET); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "output_map swp"; ret = output_map(name, prefix, "swp", MAP_SWAP); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); state = "output_brain"; ret = output_brain(name, type, prefix); if (ret) { log_warn("brain", ret, state); fail = 1; } else log_info("brain", ret, state); } else { fail = 1; } if (fail) { state = "db_rollback"; ret = db_rollback(); if (ret) goto fail; else log_info("brain", ret, state); } else { state = "db_commit"; ret = db_commit(); if (ret) goto fail; else log_info("brain", ret, state); } state = "db_disconnect"; ret = db_disconnect(); if (ret) goto fail; else log_info("brain", ret, state); return 0; fail: log_fatal("brain", ret, state); return 1; }
int main(){ int n = 0; plinked_list l[10]; char Switch = '1'; while(Switch != '0'){ printf("1 - create 2 - add 3 - insert 4 - delete 5 - search 6 - output 7 - destroy 0 - exit\n"); do { Switch = getchar(); } while(Switch > '7' || Switch < '0'); switch(Switch) { case '0': break; case '1':{ l[n++] = create_list(); printf("heave created the NO.%d list\n",n); break; } case '2':{ printf("please input the data and the number of list\n"); int num, s; scanf("%d%d", &num, &s); if(s > n ){ printf("Error!\n"); break; } else{ add_node(num,l[s - 1]); } break; } case '3':{ printf("please input the data, the order and the number of list\n"); int num, cur, s; scanf("%d%d%d", &num, &cur, &s); if(s > n || s <= 0){ printf("Error!\n"); break; } else{ insert_node(num, cur, l[s - 1]); } break; } case '4':{ printf("please intput the order and the number of list\n"); int cur, s; scanf("%d%d", &cur, &s); if(s > n || s <= 0){ printf("Error!\n"); break; } else{ del_node(cur,l[s - 1]); } break; } case '5':{ printf("please input the data and the number of list\n"); int num, s; scanf("%d%d", &num, &s); if(s > n || s <= 0){ printf("Error!\n"); break; } else{ search_node(num,l[s - 1]); } break; } case '6':{ printf("please input the number of list\n"); int s; scanf("%d", &s); if(s > n || s <= 0){ printf("Error!\n"); break; } else{ output_list(l[s - 1]); } break; } case '7':{ printf("please input the number of list\n"); int s; scanf("%d", &s); if(s > n || s <= 0){ printf("Error!\n"); break; } else{ destroy_list(l[s - 1]); } break; } } } return 0; }