static void print_utline(struct utmp ut, FILE *out) { const char *addr_string, *time_string; char buffer[INET6_ADDRSTRLEN]; if (ut.ut_addr_v6[1] || ut.ut_addr_v6[2] || ut.ut_addr_v6[3]) addr_string = inet_ntop(AF_INET6, &(ut.ut_addr_v6), buffer, sizeof(buffer)); else addr_string = inet_ntop(AF_INET, &(ut.ut_addr_v6), buffer, sizeof(buffer)); #if defined(_HAVE_UT_TV) time_string = timetostr(ut.ut_tv.tv_sec); #else time_string = timetostr((time_t)ut.ut_time); /* ut_time is not always a time_t */ #endif cleanse(ut.ut_id); cleanse(ut.ut_user); cleanse(ut.ut_line); cleanse(ut.ut_host); /* pid id user line host addr time */ fprintf(out, "[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15s] [%-28.28s]\n", ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user, 12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host, addr_string, time_string); }
void print_utline(struct utmp ut) { char addr_buf[INET6_ADDRSTRLEN+1]; const char *addr_string, *time_string; void *in_addr = &ut.ut_addr_v6; size_t addr_length = INET6_ADDRSTRLEN; int addr_family = AF_INET6; if (!ut.ut_addr_v6[1] && !ut.ut_addr_v6[2] && !ut.ut_addr_v6[3]) { addr_family = AF_INET; addr_length = INET_ADDRSTRLEN; in_addr = &ut.ut_addr; } if ((addr_string = inet_ntop(addr_family, in_addr, addr_buf, addr_length)) == 0) { addr_buf[0] = '\0'; addr_string = &addr_buf[0]; } time_string = timetostr(ut.ut_time); cleanse(ut.ut_id); cleanse(ut.ut_user); cleanse(ut.ut_line); cleanse(ut.ut_host); /* pid id user line host addr time */ printf("[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n", ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user, 12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host, addr_string, time_string); }
void i_azoth(pob o) { if (o->plus < 0) { mprint("The mercury was poisonous!"); p_poison(25); } else if (o->plus == 0) { mprint("The partially enchanted azoth makes you sick!"); Player.con = ((int) (Player.con / 2)); calc_melee(); } else if (o->blessing < 1) { mprint("The unblessed azoth warps your soul!"); Player.pow = Player.maxpow = ((int) (Player.maxpow / 2)); level_drain(random_range(10),"cursed azoth"); } else { mprint("The azoth fills you with cosmic power!"); if (Player.str > Player.maxstr*2) { mprint("The power rages out of control!"); p_death("overdose of azoth"); } else { heal(10); cleanse(1); Player.mana = calcmana()*3; toggle_item_use(TRUE); Player.str = (Player.maxstr++)*3; toggle_item_use(FALSE); } } }
void print_utline(struct utmp ut) { char *addr_string, *time_string; struct in_addr in; in.s_addr = ut.ut_addr; addr_string = inet_ntoa(in); time_string = timetostr(ut.ut_time); cleanse(ut.ut_id); cleanse(ut.ut_user); cleanse(ut.ut_line); cleanse(ut.ut_host); /* pid id user line host addr time */ printf("[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n", ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user, 12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host, addr_string, time_string); }
int main(int argc, char **argv) { int i; char *output; int j; char *testQuery[11]; /* char *expectedQuery[11]; */ testQuery[0] = "test abc,def test"; testQuery[1] = "test L'oreal `` \"test\" ' *hoho*"; testQuery[2] = "test (test1) (test2) ()"; testQuery[3] = "test abc, def, ghi"; testQuery[4] = "test.(abc @def #g (h [i {j 'k `l"; testQuery[5] = "test a) b] c} d! e? f. g' h: i; j% k` test) a"; testQuery[6] = "http://www.google.co.id/search"; testQuery[7] = "test test123 abc & def"; testQuery[8] = "test 123\n234 b\r"; testQuery[9] = "test [link text](1234567 \"link title\") abc [link text](1234567 \"\")"; testQuery[10] = "‘Tembok China’"; /* expectedQuery[0] = "test abc def test"; */ /* expectedQuery[1] = "test Loreal test hoho"; */ /* expectedQuery[2] = "test test1 test2 "; */ /* expectedQuery[3] = "test abc def ghi"; */ /* expectedQuery[4] = "test abc def g h i j k l"; */ /* expectedQuery[5] = "test a b c d e f g h i j k test a"; */ /* expectedQuery[6] = "http://www.google.co.id/search"; */ /* expectedQuery[7] = "test test123 abc def"; */ /* expectedQuery[8] = "test 123 234 b "; */ /* expectedQuery[9] = "test abc "; */ /* expectedQuery[10] = "Tembok China"; */ for(i=0; i < atoi(argv[1]); i++) { for(j=0; j < 11; j++) { output = cleanse(testQuery[j]); //printf("%s\n", output); /* if(i == 0) { */ /* printf("Is %s == %s ? %d \n", output, expectedQuery[j], strcmp(output, expectedQuery[j])); */ /* } */ free(output); } } return 0; }
void SAESpageWidget::decrypt() //make sure all entry boxes have valid input, then run our decryption alg { QString rawdata = inputE->toPlainText(); if(rawdata.isEmpty()) { QMessageBox::warning(this, "Error", "ERROR: Enter something to convert!"); return; } int pos = 0; QString binKeyfield = binaryE->text(); if(binaryValidator->validate(binKeyfield, pos) != QValidator::Acceptable) { QMessageBox::warning(this, "Error", "ERROR: Enter a valid key first."); return; } cleanse(rawdata); inputValidator->setRegExp(QRegExp("[A-Fa-f0-9]+")); if(inputValidator->validate(rawdata, pos) == QValidator::Invalid) { QMessageBox::warning(this, "Error", "ERROR: invalid Ciphertext input detected." " Input must only consist of Hex (A-F, a-f, 0-9). Commas and spaces are ignored." " Tabs and carriage returns are not accepted."); return; } if(rawdata.size() % 4 != 0) { QMessageBox::warning(this, "Error", "ERROR: number of characters in Ciphertext must be a multiple" " of 4"); return; } // Raw data contains valid Ciphertext, we're good to decrypt! // DECRYPT QString binary = HextoBinary(rawdata); int length = binary.size() / 16; bit16 Key16(binKeyfield.toStdString()); revbit16(Key16); //reverse for Endian conversion QVector<bit16> CTVector; for(int i=0; i<length; i++) { QString temp = binary.mid(i*16, 16); bit16 nextCT(temp.toStdString()); revbit16(nextCT); //reverse for Endian conversion CTVector.push_back(nextCT); } QVector<bit16> PTVector = Full_CBC_SAES_Decrypt(CTVector, Key16); QString PTBinary; for(int i=0; i<PTVector.size(); i++) { for(int j=0; j<16; j++) { if(PTVector[i].test(j)) PTBinary.append("1"); else PTBinary.append("0"); } } outputE->setText(BinarytoPT(PTBinary)); }
/* Prayer occurs at altars, hence the name of the function */ void l_altar() { int i; int deity; char response; if(Current_Environment == E_COUNTRYSIDE) { deity = DRUID; } else { deity = Level->site[Player.x][Player.y].aux; } switch(deity) { case ODIN: print1("This granite altar is graven with a gallows."); break; case SET: print1("This sandstone altar has a black hand drawn on it."); break; case HECATE: print1("This silver altar is inlaid with a black cresent moon."); break; case ATHENA: print1("This golden altar is inscribed with an owl."); break; case DESTINY: print1("This crystal altar is in the form of an omega."); break; case DRUID: print1("This oaken altar is ornately engraved with leaves."); break; default: print1("This rude altar has no markings."); break; } print2("Worship at this altar? [yn] "); if(ynq2() == 'y') { if(Player.rank[PRIESTHOOD] == 0) { increase_priest_rank(deity); } else if(!check_sacrilege(deity)) { if(Blessing) { print1("You have a sense of immanence."); } print2("Request a Blessing, Sacrifice an item, or just Pray [b,s,p] "); response = mcigetc(); while((response != 'b') && (response != 's') && (response != 'p') && (response != ESCAPE)) { response = mcigetc(); } if(response == 'b') { print1("You beg a heavenly benefice."); print2("You hear a gong resonating throughout eternity..."); morewait(); if(Blessing) { print1("A shaft of lecent radiance lances dwon from the heavens!"); print2("You feel uplifted..."); morewait(); gain_experience(Player.rank[PRIESTHOOD] * Player.rank[PRIESTHOOD] * 50); cleanse(1); heal(10); bless(1); Blessing = FALSE; increase_priest_rank(deity); } else { print1("Your ardent plea is ignored."); print2("You feel ashamed."); Player.xp -= (Player.xp / 4); } calc_melee(); } else if(response == 's') { print1("Which item to Sacrifice?"); i = getitem('\0'); if(i == ABORT) { i = 0; } if(Player.possessions[i] == NULL) { print1("You have insulted your deity!"); print2("Not a good idea, as it turns out..."); dispel(-1); p_damage(Player.hp - 1, UNSTOPPABLE, "a god's pique"); } else if(true_item_value(Player.possessions[i]) > (Player.rank[PRIESTHOOD] * Player.rank[PRIESTHOOD] * Player.rank[PRIESTHOOD] * 50)) { print1("With a burst of blue flame, your offering vanishes!"); dispose_lost_objects(1, Player.possessions[i]); print2("A violet nimbus settles around your head and slowly fades."); morewait(); Blessing = TRUE; } else { print1("A darkling glow envelopes your offering!"); print2("The glow slowly fades..."); morewait(); setgamestatus(SUPPRESS_PRINTING); if(Player.possessions[i]->used) { Player.possessions[i]->used = FALSE; item_use(Player.possessions[i]); Player.possessions[i]->blessing = -1 - abs(Player.possessions[i]->blessing); Player.possessions[i]->used = TRUE; item_use(Player.possessions[i]); } else { Player.possessions[i]->blessing = -1 - abs(Player.possessions[i]->blessing); } resetgamestatus(SUPPRESS_PRINTING); } } else if(response == 'p') { if(deity != Player.patron) { print1("Nothing seems to happen."); } else { increase_priest_rank(deity); } } } } }
void l_order(void) { pob newitem; pml ml; print1("The Headquarters of the Order of Paladins."); morewait(); if ((Player.rank[ORDER]==PALADIN) && (Player.level > Justiciarlevel) && gamestatusp(GAVE_STARGEM) && Player.alignment > 300) { print1("You have succeeded in your quest!"); morewait(); print1("The previous Justiciar steps down in your favor."); print2("You are now the Justiciar of Rampart and the Order!"); strcpy(Justiciar,Player.name); for (ml = Level->mlist; ml && (ml->m->id != HISCORE_NPC || ml->m->aux2 != 15); ml = ml->next) /* just scan for current Justicar */; if (ml) { m_remove(ml->m); /* signals "death" -- no credit to player, though */ } Justiciarlevel = Player.level; morewait(); Justiciarbehavior = fixnpc(4); save_hiscore_npc(15); clearmsg(); print1("You are awarded a blessed shield of deflection!"); morewait(); newitem = ((pob) checkmalloc(sizeof(objtype))); *newitem = Objects[OB_DEFLECT]; /* shield of deflection */ newitem->blessing = 9; gain_item(newitem); morewait(); Player.rank[ORDER] = JUSTICIAR; Player.maxstr += 5; Player.str += 5; Player.maxpow += 5; Player.pow += 5; } if (Player.alignment < 1) { if (Player.rank[ORDER] > 0) { print1("You have been tainted by chaos!"); print2("You are stripped of your rank in the Order!"); morewait(); Player.rank[ORDER]= -1; send_to_jail(); } else print1("Get thee hence, minion of chaos!"); } else if (Player.rank[ORDER] == -1) print1("Thou again? Get thee hence, minion of chaos!"); else if (Player.rank[ORDER] == 0) { if (Player.rank[ARENA] != 0) print1("We do not accept bloodstained gladiators into our Order."); else if (Player.rank[LEGION] != 0) print1("Go back to your barracks, mercenary!"); else { print1("Dost thou wish to join our Order? [yn] "); if (ynq1()=='y') { print1("Justiciar "); nprint1(Justiciar); nprint1(" welcomes you to the Order."); print2("'Mayest thou always follow the sublime path of Law.'"); morewait(); print1("You are now a Gallant in the Order."); print2("You are given a horse and a blessed spear."); morewait(); Player.rank[ORDER] = GALLANT; Player.guildxp[ORDER] = 1; setgamestatus(MOUNTED); newitem = ((pob) checkmalloc(sizeof(objtype))); *newitem = Objects[OB_SPEAR]; /* spear */ newitem->blessing = 9; newitem->plus = 1; newitem->known = 2; gain_item(newitem); } } } else { print1("'Welcome back, Paladin.'"); if (!gamestatusp(MOUNTED)) { print2("You are given a new steed."); setgamestatus(MOUNTED); } morewait(); clearmsg(); if ((Player.hp < Player.maxhp) || (Player.status[DISEASED]) || (Player.status[POISONED])) print1("Your wounds are treated by a medic."); cleanse(0); Player.hp = Player.maxhp; if ( Player.food <= 40 ) { Player.food = 40; print2("You get a hot meal from the refectory."); } morewait(); clearmsg(); if (Player.rank[ORDER]==PALADIN) { if (Player.level <= Justiciarlevel) print2("You are not experienced enough to advance."); else if (Player.alignment < 300) print2("You are not sufficiently Lawful as yet to advance."); else print2("You must give the Star Gem to the LawBringer."); } else if (Player.rank[ORDER]==CHEVALIER) { if (Player.guildxp[ORDER] < 4000) print2("You are not experienced enough to advance."); else if (Player.alignment < 200) print2("You are not sufficiently Lawful as yet to advance."); else { print1("You are made a Paladin of the Order!"); print2("You learn the Spell of Heroism and get Mithril Plate!"); morewait(); newitem = ((pob) checkmalloc(sizeof(objtype))); *newitem = Objects[OB_MITHRIL_PLATE]; /* mithril plate armor */ newitem->blessing = 9; newitem->known = 2; gain_item(newitem); morewait(); clearmsg(); print1("To advance you must rescue the Star Gem and return it"); print2("to its owner, the LawBringer, who resides on Star Peak."); morewait(); print1("The Star Gem was stolen by the cursed Prime Sorceror,"); print2("whose headquarters may be found beyond the Astral Plane."); morewait(); print1("The Oracle will send you to the Astral Plane if you"); print2("prove yourself worthy to her."); morewait(); Spells[S_HERO].known = TRUE; Player.rank[ORDER] = PALADIN; } } else if (Player.rank[ORDER]==GUARDIAN) { if (Player.guildxp[ORDER] < 1500) print2("You are not experienced enough to advance."); else if (Player.alignment < 125) print2("You are not yet sufficiently Lawful to advance."); else { Player.rank[ORDER] = CHEVALIER; print1("You are made a Chevalier of the Order!"); print2("You are given a Mace of Disruption!"); morewait(); clearmsg(); newitem = ((pob) checkmalloc(sizeof(objtype))); *newitem = Objects[OB_MACE_DISRUPT]; /* mace of disruption */ newitem->known = 2; gain_item(newitem); } } else if (Player.rank[ORDER]==GALLANT) { if (Player.guildxp[ORDER] < 400) print2("You are not experienced enough to advance."); else if (Player.alignment < 50) print2("You are not Lawful enough to advance."); else { print1("You are made a Guardian of the Order of Paladins!"); print2("You are given a Holy Hand Grenade (of Antioch)."); morewait(); print1("You hear a nasal monotone in the distance...."); print2("'...and the number of thy counting shall be 3...'"); morewait(); clearmsg(); Player.rank[ORDER] = GUARDIAN; newitem = ((pob) checkmalloc(sizeof(objtype))); *newitem = Objects[OB_ANTIOCH]; /* holy hand grenade. */ newitem->known = 2; gain_item(newitem); } } } showflags(); }
void i_lembas(pob o) { heal(10); cleanse(0); Player.food = 40; }
void l_magic_pool(void) { int possibilities=random_range(100); print1("This pool seems to be enchanted...."); if (gamestatusp(MOUNTED)) { if (random_range(2)) { print2("Your horse is polymorphed into a fig newton."); resetgamestatus(MOUNTED); } else print2("Whatever it was, your horse enjoyed it...."); } else if (possibilities == 0) { print1("Oh no! You encounter the DREADED AQUAE MORTIS..."); if (random_range(1000) < Player.level*Player.level*Player.level) { print2("The DREADED AQUAE MORTIS throttles you within inches...."); print3("but for some reason chooses to let you escape."); gain_experience(500); Player.hp = 1; } else p_death("the DREADED AQUAE MORTIS!"); } else if (possibilities < 25) augment(0); else if (possibilities < 30) augment(1); else if (possibilities < 60) augment(-1); else if (possibilities < 65) cleanse(1); else if (possibilities < 80) { if (Player.possessions[O_WEAPON_HAND] != NULL) { print1("You drop your weapon in the pool! It's gone forever!"); dispose_lost_objects(1,Player.possessions[O_WEAPON_HAND]); } else print1("You feel fortunate."); } else if (possibilities < 90) { if (Player.possessions[O_WEAPON_HAND] != NULL) { print1("Your weapon leaves the pool with a new edge...."); Player.possessions[O_WEAPON_HAND]->plus += random_range(10)+1; calc_melee(); } else print1("You feel unfortunate."); } else if (possibilities < 95) { Player.hp += 10; print1("You feel healthier after the dip..."); } else if (possibilities < 99) { print1("Oooh, a tainted pool..."); p_poison(10); } else if (possibilities == 99) { print1("Wow! A pool of azoth!"); heal(10); cleanse(1); Player.mana = calcmana()*3; Player.str = (Player.maxstr++)*3; } print2("The pool seems to have dried up."); Level->site[Player.x][Player.y].locchar = TRAP; Level->site[Player.x][Player.y].p_locf = L_TRAP_PIT; lset(Player.x, Player.y, CHANGED); }