/* show_helpfile() - Displays a help file to the screen. Parameters: hlpname - Base name of the help file to show. Returns: Nothing. Notes: This function is really just a wrapper for show_file() that adds in the help prefix and suffix as well. */ void show_helpfile(unsigned char *hlpname) { top_output(OUT_SCREEN, getlang("HelpPrefix")); show_file(hlpname, SCRN_RESETCOL); top_output(OUT_SCREEN, getlang("HelpSuffix")); }
int main(int argc, char **argv) { setcfgfilename(argv[0]); readoptions(); timer_init(); atexit(cleanup); #if UNIX signal(SIGINT, finish); #endif gettermsize(); getlang(); if (argc > 1) { #if ALLEGRO && WIN32 && !ALLEGRO_USE_CONSOLE freopen("stdout.tmp", "w", stdout); #endif proc_args(argv+1, argc-1); } gettermoptions(); #ifdef SOCKET startup(socket_fd>0 ? 2+is_inet() : 0); #else startup(0); #endif #if !NO_MENU writeconfig_message(); #endif return 0; }
void poker_displayhand(poker_game_typ *dhgame, char *dhhand) { XINT dhd; unsigned char ltname[41]; top_output(OUT_SCREEN, getlang("PokerDispHandPref")); for (dhd = 0; dhd < dhgame->numcards; dhd++) { top_output(OUT_SCREEN, getlang("PokerDispCardPref")); itoa(pokerdefcardsuits[dhhand[dhd]] + 1, outnum[0], 10); sprintf(ltname, "CardShrtColour%s", outnum[0]); top_output(OUT_SCREEN, getlang(ltname)); itoa(pokerdefcardvals[dhhand[dhd]], outnum[0], 10); sprintf(ltname, "CardShrtSngValue%s", outnum[0]); top_output(OUT_SCREEN, getlang(ltname)); itoa(pokerdefcardsuits[dhhand[dhd]] + 1, outnum[0], 10); // Change A below to check for IBM ASCII pref... sprintf(ltname, "CardShrtSngSuit%c%s", 'A', outnum[0]); top_output(OUT_SCREEN, getlang(ltname)); top_output(OUT_SCREEN, getlang("PokerDispCardSuf")); } top_output(OUT_SCREEN, getlang("PokerDispHandSuf")); }
static htsmsg_t * tmdb_load_movie_cast(const char *lookup_id) { char url[300]; char errbuf[256]; buf_t *result; snprintf(url, sizeof(url), "http://api.themoviedb.org/3/movie/%s/casts", lookup_id); retry: tmdb_check_rate_limit(); int http_response_code = 0; struct http_header_list response_headers; LIST_INIT(&response_headers); result = fa_load(url, FA_LOAD_ERRBUF(errbuf, sizeof(errbuf)), FA_LOAD_QUERY_ARG("api_key", TMDB_APIKEY), FA_LOAD_QUERY_ARG("language", getlang()), FA_LOAD_RESPONSE_HEADERS(&response_headers), FA_LOAD_PROTOCOL_CODE(&http_response_code), FA_LOAD_FLAGS(FA_COMPRESSION), NULL); if(result == NULL) { if(http_response_code == 429) { tmdb_handle_rate_limit(&response_headers); goto retry; } http_headers_free(&response_headers); TRACE(TRACE_INFO, "TMDB", "Load error %s", errbuf); return NULL; } http_headers_free(&response_headers); htsmsg_t *doc = htsmsg_json_deserialize2(buf_cstr(result), errbuf, sizeof(errbuf)); if(doc == NULL) { TRACE(TRACE_ERROR, "TMDB", "Got bad JSON from %s -- %s", url, errbuf); } buf_release(result); return doc; }
static int tmdb_configure(void) { hts_mutex_lock(&tmdb_mutex); if(!tmdb_configured) { buf_t *result; char errbuf[256]; result = fa_load("http://api.themoviedb.org/3/configuration", FA_LOAD_ERRBUF(errbuf, sizeof(errbuf)), FA_LOAD_QUERY_ARG("api_key", TMDB_APIKEY), FA_LOAD_QUERY_ARG("language", getlang()), FA_LOAD_FLAGS(FA_COMPRESSION | FA_IMPORTANT), NULL); if(result == NULL) { TRACE(TRACE_INFO, "TMDB", "Unable to get configuration -- %s", errbuf); goto done; } htsmsg_t *doc = htsmsg_json_deserialize2(buf_cstr(result), errbuf, sizeof(errbuf)); buf_release(result); if(doc == NULL) { TRACE(TRACE_ERROR, "TMDB", "Got bad JSON from config -- %s", errbuf); goto done; } tmdb_parse_config(doc); htsmsg_release(doc); tmdb_configured = 1; } done: hts_mutex_unlock(&tmdb_mutex); return !tmdb_configured; }
void poker_endgamedisplay(poker_game_typ *egame) { XINT egd, xxq, maxnamlen; ///!!! this func! for (egd = 0, maxnamlen = 0; egd < MAXNODES; egd++) { if (egame->player[egd].node > -1) { if (strlen(handles[egd].string) > maxnamlen) { maxnamlen = strlen(handles[egd].string); } } } top_output(OUT_SCREEN, getlang("PokerHandsWere")); for (egd = 0; egd < egame->maxpl; egd++) { if (egame->player[egd].node > -1) { sprintf(outbuf, "^l%*s ", maxnamlen, handles[egame->player[egd].node].string); top_output(OUT_SCREEN, outbuf); poker_displayhand(egame, egame->player[egd].cards); top_output(OUT_SCREEN, " "); xxq = wherex(); top_output(OUT_SCREEN, poker_getshortname(egame, egame->player[egd].cards)); od_repeat(' ', 20 - (wherex() - xxq)); if (egame->winners[egd]) { top_output(OUT_SCREEN, " ^I^k<-- Winner!^A^h"); } top_output(OUT_SCREEN, "\r\n"); } } }
/* help_proc() - Process the HELP command. Parameters: helpwds - Number of words in the command string. Returns: Nothing. */ void help_proc(XINT helpwds) { // Will need to change the order to the order proc'd later. char hused = 0; /* Flag if a help file has been shown or not. */ unsigned char *helpfile = NULL; /* Name of help file to show. */ /* In this function, basically every command is checked to see if it follows the HELP command. If a match is found, the name of the file to show is set, as is a flag. */ /* Due to the simplicity of this function, comments have been kept to a minimum. */ /* Regular commands. */ if (!hused && (helpwds < 2 || checkcmdmatch(get_word(1), getlang("CmdsHelp")))) { hused = 1; helpfile = "HELP_HLP"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsQuit"))) { hused = 1; helpfile = "HELPQUIT"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsCommands"))) { hused = 1; helpfile = "HELPCMDS"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsColourHelp"))) { hused = 1; helpfile = "HELPCHLP"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsTime"))) { hused = 1; helpfile = "HELPTIME"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsWho"))) { hused = 1; helpfile = "HELP_WHO"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsProfile"))) { hused = 1; helpfile = "HELPPROF"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsLookUp"))) { hused = 1; helpfile = "HELPLKUP"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsNodes"))) { hused = 1; helpfile = "HELPNODS"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPage"))) { hused = 1; helpfile = "HELPPAGE"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsForget"))) { hused = 1; helpfile = "HELP_FGT"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsRemember"))) { hused = 1; helpfile = "HELPRMBR"; } // May need slight mods below /* Whispers have two command forms; each is checked. */ if (!hused && (checkcmdmatch(get_word(1), getlang("CmdsWhisperLong1")) || checkcmdmatch(get_word(1), getlang("WhisperShortChar")))) { hused = 1; helpfile = "HELPWHIS"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsGA"))) { hused = 1; helpfile = "HELP_GA1"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsGA2"))) { hused = 1; helpfile = "HELP_GA2"; } // May need slight mods below /* Directed messages have two command forms; each is checked. */ if (!hused && (checkcmdmatch(get_word(1), getlang("CmdsDirectedLong1")) || checkcmdmatch(get_word(1), getlang("DirectedShortChar")))) { hused = 1; helpfile = "HELP_DIR"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsJoin"))) { hused = 1; helpfile = "HELPJOIN"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPrivChat"))) { hused = 1; helpfile = "HELPCHAT"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsPrivDenyChat"))) { hused = 1; helpfile = "HELPDENY"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsLogOff"))) { hused = 1; helpfile = "HELPLGOF"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsConfList"))) { hused = 1; helpfile = "HELPCLST"; } /* Multi-part commands. If a valid secondary command is recognized then its specific help file will be shown, otherwise a general help file for the multi-part command will be shown. */ if (!hused && checkcmdmatch(get_word(1), getlang("CmdsAction"))) { hused = 1; helpfile = "HELPACT0"; if (helpwds >= 2) { if (checkcmdmatch(get_word(2), getlang("CmdsActionList"))) helpfile = "HELPACT1"; if (checkcmdmatch(get_word(2), getlang("CmdsActionOn"))) helpfile = "HELPACT2"; if (checkcmdmatch(get_word(2), getlang("CmdsActionOff"))) helpfile = "HELPACT3"; } } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsChange"))) { hused = 1; helpfile = "HELPCHG0"; if (helpwds >= 2) { if (checkcmdmatch(get_word(2), getlang("CmdsChangeHandle"))) helpfile = "HELPCHG1"; if (checkcmdmatch(get_word(2), getlang("CmdsChangeEMessage"))) helpfile = "HELPCHG2"; if (checkcmdmatch(get_word(2), getlang("CmdsChangeXMessage"))) helpfile = "HELPCHG3"; if (checkcmdmatch(get_word(2), getlang("CmdsChangeSex"))) helpfile = "HELPCHG4"; if (checkcmdmatch(get_word(2), getlang("CmdsChangeChatMode"))) helpfile = "HELPCHG5"; if (checkcmdmatch(get_word(2), getlang("CmdsChangeListed"))) helpfile = "HELPCHG6"; } } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsSysop"))) { hused = 1; helpfile = "HELPSYS0"; if (helpwds >= 2) { if (checkcmdmatch(get_word(2), getlang("CmdsSysopClear"))) helpfile = "HELPSYS1"; if (checkcmdmatch(get_word(2), getlang("CmdsSysopToss"))) helpfile = "HELPSYS2"; if (checkcmdmatch(get_word(2), getlang("CmdsSysopZap"))) helpfile = "HELPSYS3"; if (checkcmdmatch(get_word(2), getlang("CmdsSysopSetSec"))) helpfile = "HELPSYS4"; } } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsModerator"))) { hused = 1; helpfile = "HELPMOD0"; if (helpwds >= 2) { if (checkcmdmatch(get_word(2), getlang("CmdsModTopicChg"))) helpfile = "HELPMOD1"; if (checkcmdmatch(get_word(2), getlang("CmdsModModChg"))) helpfile = "HELPMOD2"; if (checkcmdmatch(get_word(2), getlang("CmdsModBan"))) helpfile = "HELPMOD3"; if (checkcmdmatch(get_word(2), getlang("CmdsModUnBan"))) helpfile = "HELPMOD4"; if (checkcmdmatch(get_word(2), getlang("CmdsModInvite"))) helpfile = "HELPMOD5"; if (checkcmdmatch(get_word(2), getlang("CmdsModUnInvite"))) helpfile = "HELPMOD6"; } } /* Non-command help topics. */ if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpTopics"))) { hused = 1; helpfile = "HELP_TOP"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpGeneral"))) { hused = 1; helpfile = "HELP_GEN"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpActions"))) { hused = 1; helpfile = "HELPACTS"; } if (!hused && checkcmdmatch(get_word(1), getlang("CmdsHelpChannels"))) { hused = 1; helpfile = "HELPCHAN"; } if (hused) { /* Show the help file if one was set. */ show_helpfile(helpfile); } else { /* Unknown command. */ top_output(OUT_SCREEN, getlang("NoHelpAvailable")); } }