void llvm_print(const char *userfile, int lineno, T &obj, ADDON addon = ADDON()) { std::string unformatted = llvm_to_str(*obj); std::string formatted = dlog_format_string_to_html(unformatted); if (outputmode == DLOG_OUTPUT_BOTH || outputmode == DLOG_OUTPUT_FILE) { tag_handler("notag"); fdata << DIV("notag") << br << CALLINFO << NBSP << BROWN(addon.getString()) << NBSP << BOLD(" Data : <br>") << formatted << EDIV; } if (outputmode == DLOG_OUTPUT_BOTH || outputmode == DLOG_OUTPUT_STDOUT) { if (addon.getString().length() != 0) std::cout << "Addon: " << addon.getString() << "\n"; std::cout << unformatted << "\n"; } fdata.flush(); }
void WDL_CursesEditor::draw(int lineidx) { const int VISIBLE_LINES = getVisibleLines(); int paney[2], paneh[2]; const int pane_divy=GetPaneDims(paney, paneh); #ifdef WDL_IS_FAKE_CURSES if (m_cursesCtx) { CURSES_INSTANCE->offs_y[0]=m_paneoffs_y[0]; CURSES_INSTANCE->offs_y[1]=m_paneoffs_y[1]; CURSES_INSTANCE->div_y=pane_divy; CURSES_INSTANCE->tot_y=m_text.GetSize(); CURSES_INSTANCE->scrollbar_topmargin = m_top_margin; CURSES_INSTANCE->scrollbar_botmargin = m_bottom_margin; } #endif attrset(A_NORMAL); if (lineidx >= 0) { int comment_state = GetCommentStateForLineStart(lineidx); WDL_FastString *s=m_text.Get(lineidx); if (s) { int y=lineidx-m_paneoffs_y[0]; if (y >= 0 && y < paneh[0]) { doDrawString(paney[0]+y, 0, lineidx, s->Get(), COLS, &comment_state, min(s->GetLength(), m_offs_x)); } y=lineidx-m_paneoffs_y[1]; if (y >= 0 && y < paneh[1]) { doDrawString(paney[1]+y, 0, lineidx, s->Get(), COLS, &comment_state, min(s->GetLength(), m_offs_x)); } } return; } __curses_invalidatefull((win32CursesCtx*)m_cursesCtx,false); draw_top_line(); attrset(A_NORMAL); bkgdset(A_NORMAL); move(m_top_margin,0); clrtoeol(); int pane, i; for (pane=0; pane < 2; ++pane) { int ln=m_paneoffs_y[pane]; int y=paney[pane]; int h=paneh[pane]; int comment_state=GetCommentStateForLineStart(ln); for(i=0; i < h; ++i, ++ln, ++y) { WDL_FastString *s=m_text.Get(ln); if (!s) { move(y,0); clrtoeol(); } else { doDrawString(y,0,ln,s->Get(),COLS,&comment_state,min(m_offs_x,s->GetLength())); } } } attrset(m_color_bottomline); bkgdset(m_color_bottomline); if (m_bottom_margin>0) { move(LINES-1, 0); #define BOLD(x) { attrset(m_color_bottomline|A_BOLD); addstr(x); attrset(m_color_bottomline&~A_BOLD); } if (m_selecting) { mvaddstr(LINES-1,0,"SELECTING ESC:cancel Ctrl+("); BOLD("C"); addstr("opy "); BOLD("X"); addstr(":cut "); BOLD("V"); addstr(":paste)"); } else { mvaddstr(LINES-1, 0, "Ctrl+("); if (m_pane_div <= 0.0 || m_pane_div >= 1.0) { BOLD("P"); addstr("ane "); } else { BOLD("O"); addstr("therpane "); addstr("no"); BOLD("P"); addstr("anes "); } BOLD("F"); addstr("ind "); addstr("ma"); BOLD("T"); addstr("ch"); draw_bottom_line(); addstr(")"); } #undef BOLD clrtoeol(); } attrset(0); bkgdset(0); __curses_invalidatefull((win32CursesCtx*)m_cursesCtx,true); }
int main(int argc, char **argv) { int res, i; int use_ppdev=0; int use_ppio=0; int io_specified=0; int reset_and_exit=0, status_line=1, loop=0, play_and_exit=0; char *filename; FILE *fptr=NULL; id666_tag tag; struct timeval tv_before, tv_now; signal(SIGINT, signal_handler); while((res =getopt(argc, argv, "rslvhxed" #ifdef PPDEV_SUPPORTED "p" #endif #ifdef PPIO_SUPPORTED "i" #endif ))>=0) { switch(res) { case 'd': g_debug = 1; break; case 'e': g_use_embedded = 1; break; case 'v': g_verbose = 1; break; case 's': status_line = 0; break; case 'l': loop = 1; break; case 'r': reset_and_exit = 1; break; case 'h': printhelp(); return 0; case 'x': play_and_exit = 1; break; #ifdef PPDEV_SUPPORTED case 'p': use_ppdev = 1; io_specified = 1; break; #endif #ifdef PPIO_SUPPORTED case 'i': use_ppio = 1; io_specified = 1; break; #endif case '?': fprintf(stderr, "Unknown argument. try -h\n"); return -1; } } if (argc-optind<=0 && !reset_and_exit) { fprintf(stderr, "No file specified. Try -h\n"); return -2; } #ifdef PPDEV_SUPPORTED if (!io_specified) { use_ppdev = 1; io_specified = 1; } #endif #ifdef PPIO_SUPPORTED if (!io_specified) { use_ppio = 1; io_specified = 1; } #endif if (!io_specified) { fprintf(stderr, "No io layer for apu compiled\n"); return -3; } #ifdef PPDEV_SUPPORTED if (use_ppdev) { apu_ops = apu_ppdev_getOps(); } else #endif #ifdef PPIO_SUPPORTED if (use_ppio) { apu_ops = apu_ppio_getOps(); } #endif apu_setOps(apu_ops); /* initialize the interface with the module. * (Open device, get io permissions, etc...) */ if (apu_ops->init("")<0) { return 1; } if (reset_and_exit) { if (g_verbose) { printf("Resetting APU\n"); } apu_reset(); return 0; } for (i = optind; i<argc; i++) { if (g_exit_now) { break; } filename = argv[i]; fptr = fopen(filename, "rb"); if (fptr==NULL) { perror("fopen"); return 1; } read_id666(fptr, &tag); g_playing = 1; time_t start, end; start = time (NULL); printf("Now loading '%s'", filename); if (g_use_embedded) { printf(" using 'embedded' algo\n"); if (LoadAPU_embedded(fptr)<0) { break; } } else { printf(" \n"); if (LoadAPU(fptr)<0) { break; } } end = time (NULL); printf("Took %ld seconds to load APU.\n", (end - start) ); if (!g_playing) { continue; } // next if (g_exit_now) { break; } BOLD(); printf("Title: "); NORMAL(); printf("%s\n", tag.title); BOLD(); printf("Game Title: "); NORMAL(); printf("%s\n", tag.game_title); BOLD(); printf("Dumper: "); NORMAL(); printf("%s\n", tag.name_of_dumper); BOLD(); printf("Comments: "); NORMAL(); printf("%s\n", tag.comments); BOLD(); printf("Seconds: "); NORMAL(); printf("%s\n", tag.seconds_til_fadeout); fclose(fptr); if (play_and_exit) { return 0; } gettimeofday(&tv_before, NULL); { int elaps_sec; int num_sec = atoi(tag.seconds_til_fadeout); int last_elaps_sec=-1; if (num_sec<1 || num_sec>999) { num_sec = 150; } if (strlen(tag.title)==0) { strncpy(tag.title, filename, 32); } if (g_exit_now) { break; } while (g_playing) { gettimeofday(&tv_now, NULL); elaps_sec = tv_now.tv_sec - tv_before.tv_sec; if (elaps_sec > num_sec) { break; } if (status_line) { if (last_elaps_sec != elaps_sec) { if (!loop) { BOLD(); printf("Time: "); NORMAL(); printTime(elaps_sec); printf(" ["); printTime(num_sec - elaps_sec); printf("] of "); printTime(num_sec); printf(" \r"); } else { BOLD(); printf("Time: "); NORMAL(); printTime(elaps_sec); printf(" \r"); } } last_elaps_sec = elaps_sec; fflush(stdout); } usleep(7500); // update every 75 ms } if (g_playing) printf("\nFinished playing.\n"); apu_reset(); if (g_exit_now) { break; } } } apu_reset(); return 0; }
static void cmd_chaninfo(int idx, char *par) { char *chname = NULL, work[512] = ""; struct chanset_t *chan = NULL; int cnt = 0; if (!par[0]) { chname = dcc[idx].u.chat->con_chan; if (chname[0] == '*') { dprintf(idx, "Your console channel is invalid.\n"); return; } } else { chname = newsplit(&par); get_user_flagrec(dcc[idx].user, &user, chname); if (!glob_master(user) && !chan_master(user)) { dprintf(idx, "You don't have access to %s.\n", chname); return; } } if (!strcasecmp(chname, "default")) chan = chanset_default; else chan = findchan_by_dname(chname); if (!chan || (chan && privchan(user, chan, PRIV_OP))) { dprintf(idx, "No such channel.\n"); return; } else { char nick[HANDLEN + 1] = "", date[81] = ""; int deflag = 0; if (chan->added_ts) { strftime(date, sizeof date, "%c %Z", gmtime(&(chan->added_ts))); } else date[0] = 0; if (chan->added_by && chan->added_by[0]) strlcpy(nick, chan->added_by, sizeof(nick)); else nick[0] = 0; putlog(LOG_CMDS, "*", "#%s# chaninfo %s", dcc[idx].nick, chname); if (nick[0] && date[0]) dprintf(idx, "Settings for channel %s (Added %s by %s%s%s):\n", chan->dname, date, BOLD(idx), nick, BOLD_END(idx)); else dprintf(idx, "Settings for channel %s:\n", chan->dname); /* FIXME: SHOW_CHAR() here */ get_mode_protect(chan, work, sizeof(work)); dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None"); dprintf(idx, "Groups: %s\n", chan->groups && chan->groups->length() ? static_cast<bd::String>(chan->groups->join(" ")).c_str() : "None"); dprintf(idx, "FiSH Key: %s\n", chan->fish_key[0] ? chan->fish_key : "not set"); // dprintf(idx, "Protect topic (topic) : %s\n", chan->topic[0] ? chan->topic : ""); /* Chanchar template * dprintf(idx, "String temp: %s\n", chan->temp[0] ? chan->temp : "NULL"); */ dprintf(idx, "Channel flags:\n"); work[0] = 0; SHOW_FLAG("autoop", channel_autoop(chan)); SHOW_FLAG("backup", channel_backup(chan)); SHOW_FLAG("bitch", channel_bitch(chan)); SHOW_FLAG("botbitch", channel_botbitch(chan)); SHOW_FLAG("closed", channel_closed(chan)); SHOW_FLAG("cycle", channel_cycle(chan)); SHOW_FLAG("enforcebans", channel_enforcebans(chan)); SHOW_FLAG("fastop", channel_fastop(chan)); SHOW_FLAG("floodban", channel_floodban(chan)); SHOW_FLAG("inactive", channel_inactive(chan)); SHOW_FLAG("nodesynch", channel_nodesynch(chan)); SHOW_FLAG("private", channel_privchan(chan)); SHOW_FLAG("protect", channel_protect(chan)); SHOW_FLAG("rbl", channel_rbl(chan)); if (HAVE_TAKE) SHOW_FLAG("take", channel_take(chan)); SHOW_FLAG("voice", channel_voice(chan)); SHOW_FLAG("voicebitch", channel_voicebitch(chan)); SHOW_FLAG("", 0); SHOW_FLAG("dynamicbans", channel_dynamicbans(chan)); SHOW_FLAG("userbans", !channel_nouserbans(chan)); SHOW_FLAG("dynamicexempts", channel_dynamicexempts(chan)); SHOW_FLAG("userexempts", !channel_nouserexempts(chan)); SHOW_FLAG("dynamicinvites", channel_dynamicinvites(chan)); SHOW_FLAG("userinvites", !channel_nouserinvites(chan)); SHOW_FLAG("", 0); work[0] = 0; /* Chanflag template * SHOW_FLAG("template", channel_template(chan)); * also include %ctemp in dprintf. */ work[0] = cnt = 0; /* Chanint template * SHOW_INT("Desc: ", integer, "YES", "NO"); */ dprintf(idx, "Channel settings:\n"); deflag = chan->bad_cookie; SHOW_INT("Auto-delay: ", chan->auto_delay, NULL, "None"); SHOW_INT("Bad-cookie:" , chan->bad_cookie, DEFLAG_STR, "Ignore"); SHOW_INT("Ban-time: ", chan->ban_time, NULL, "Forever"); SHOW_INT("Ban-type: ", chan->ban_type, NULL, "3"); SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!"); SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!"); SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!"); SHOW_INT("Closed-Exempt:", chan->closed_exempt_mode, F_STR(chan->closed_exempt_mode), "None"); SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever"); SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR(chan->flood_exempt_mode), "None"); SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't"); SHOW_INT("Caps-Limit(%): ", chan->capslimit, NULL, "None"); SHOW_INT("Color-Limit: ", chan->colorlimit, NULL, "None"); SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever"); SHOW_INT("Knock: ", chan->knock_flags, F_STR(chan->knock_flags), "None"); SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled"); deflag = chan->manop; SHOW_INT("Manop: ", chan->manop, DEFLAG_STR, "Ignore"); deflag = chan->mdop; SHOW_INT("Mdop: ", chan->mdop, DEFLAG_STR, "Ignore"); deflag = chan->mop; SHOW_INT("Mop: ", chan->mop, DEFLAG_STR, "Ignore"); deflag = chan->revenge; SHOW_INT("Revenge: ", chan->revenge, DEFLAG_STR, "Ignore"); SHOW_INT("Protect-backup: ", chan->protect_backup, "Do!", "Don't!"); SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!"); SHOW_INT("Voice-moderate:", chan->voice_moderate, "Do!", "Don't!"); dprintf(idx, "Flood settings: chan bytes ctcp join kick deop nick mjoin mpub mbytes mctcp\n"); dprintf(idx, " number: %3d %4d %3d %3d %3d %3d %3d %3d %3d %4d %3d\n", chan->flood_pub_thr, chan->flood_bytes_thr, chan->flood_ctcp_thr, chan->flood_join_thr, chan->flood_kick_thr, chan->flood_deop_thr, chan->flood_nick_thr, chan->flood_mjoin_thr, chan->flood_mpub_thr, chan->flood_mbytes_thr, chan->flood_mctcp_thr); dprintf(idx, " time : %3u %4u %3u %3u %3u %3u %3u %3u %3u %4u %4u\n", chan->flood_pub_time, chan->flood_bytes_time, chan->flood_ctcp_time, chan->flood_join_time, chan->flood_kick_time, chan->flood_deop_time, chan->flood_nick_time, chan->flood_mjoin_time, chan->flood_mpub_time, chan->flood_mbytes_time, chan->flood_mctcp_time); } }
int main(int argc, char **argv) { int r, tmp, fi, random=0; char Buffer[1024]; char length_str[256], fade_str[256], volume[256], title_str[256]; char tmp_str[256]; char *tag; soundLowPass = 0; soundEcho = 0; soundQuality = 0; DetectSilence=1; silencelength=5; IgnoreTrackLength=0; DefaultLength=150000; TrailingSilence=1000; playforever=0; while((r=getopt(argc, argv, "hlsrieWL:t:"))>=0) { char *e; switch(r) { case 'h': printf("playgsf version %s (based on Highly Advanced version %s)\n\n", VERSION_STR, HA_VERSION_STR); printf("Usage: ./playgsf [options] files...\n\n"); printf(" -l Enable low pass filer\n"); printf(" -s Detect silence\n"); printf(" -L Set silence length in seconds (for detection). Default 5\n"); printf(" -t Set default track length in milliseconds. Default 150000 ms\n"); printf(" -i Ignore track length (use default length)\n"); printf(" -e Endless play\n"); printf(" -r Play files in random order\n"); printf(" -W output to 'output.wav' rather than soundcard\n"); printf(" -h Displays what you are reading right now\n"); return 0; break; case 'i': IgnoreTrackLength = 1; break; case 'l': soundLowPass = 1; break; case 's': DetectSilence = 1; break; case 'L': silencelength = strtol(optarg, &e, 0); if (e==optarg) { fprintf(stderr, "Bad value\n"); return 1; } break; case 'e': playforever = 1; break; case 't': DefaultLength = strtol(optarg, &e, 0); if (e==optarg) { fprintf(stderr, "Bad value\n"); return 1; } break; case 'r': random = 1; break; case 'W': fileoutput = 1; break; case '?': fprintf(stderr, "Unknown argument. try -h\n"); return 1; break; } } if (argc-optind<=0) { printf("No files specified! For help, try -h\n"); return 1; } if (random) { shuffle_list(&argv[optind], argc-optind); } printf("playgsf version %s (based on Highly Advanced version %s)\n\n", VERSION_STR, HA_VERSION_STR); signal(SIGINT, signal_handler); tag = (char*)malloc(50001); fi = optind; while (!g_must_exit && fi < argc) { decode_pos_ms = 0; seek_needed = -1; TrailingSilence=1000; r = GSFRun(argv[fi]); if (!r) { fi++; continue; } g_playing = 1; psftag_readfromfile((void*)tag, argv[fi]); BOLD(); printf("Filename: "); NORMAL(); printf("%s\n", basename(argv[fi])); BOLD(); printf("Channels: "); NORMAL(); printf("%d\n", sndNumChannels); BOLD(); printf("Sample rate: "); NORMAL(); printf("%d\n", sndSamplesPerSec); if (!psftag_getvar(tag, "title", title_str, sizeof(title_str)-1)) { BOLD(); printf("Title: "); NORMAL(); printf("%s\n", title_str); } if (!psftag_getvar(tag, "artist", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("Artist: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "game", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("Game: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "year", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("Year: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "copyright", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("Copyright: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "gsfby", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("GSF By: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "tagger", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("Tagger: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "comment", tmp_str, sizeof(tmp_str)-1)) { BOLD(); printf("Comment: "); NORMAL(); printf("%s\n", tmp_str); } if (!psftag_getvar(tag, "fade", fade_str, sizeof(fade_str)-1)) { FadeLength = LengthFromString(fade_str); BOLD(); printf("Fade: "); NORMAL(); printf("%s (%d ms)\n", fade_str, FadeLength); } if (!psftag_raw_getvar(tag, "length", length_str, sizeof(length_str)-1)) { TrackLength = LengthFromString(length_str) + FadeLength; BOLD(); printf("Length: "); NORMAL(); printf("%s (%d ms) ", length_str, TrackLength); if (IgnoreTrackLength) { printf("(ignored)"); TrackLength = DefaultLength; } printf("\n"); } else { TrackLength = DefaultLength; } /* Must be done after GSFrun so sndNumchannels and * sndSamplesPerSec are set to valid values */ ao_initialize(); ao_sample_format format_ao = { 16, sndSamplesPerSec, sndNumChannels, AO_FMT_LITTLE }; if(fileoutput) { snd_ao = ao_open_file(ao_driver_id("wav"), "output.wav", 1, &format_ao, NULL); } else { snd_ao = ao_open_live(ao_default_driver_id(), &format_ao, NULL); } while(g_playing) { int remaining = TrackLength - (int)decode_pos_ms; if (remaining<0) { // this happens during silence period remaining = 0; } EmulationLoop(); BOLD(); printf("Time: "); NORMAL(); printf("%02d:%02d.%02d ", (int)(decode_pos_ms/1000.0)/60, (int)(decode_pos_ms/1000.0)%60, (int)(decode_pos_ms/10.0)%100); if (!playforever) { /*BOLD();*/ printf("["); /*NORMAL();*/ printf("%02d:%02d.%02d", remaining/1000/60, (remaining/1000)%60, (remaining/10%100) ); /*BOLD();*/ printf("] of "); /*NORMAL();*/ printf("%02d:%02d.%02d ", TrackLength/1000/60, (TrackLength/1000)%60, (TrackLength/10%100)); } BOLD(); printf(" GBA Cpu: "); NORMAL(); printf("%02d%% ", cpupercent); printf(" \r"); fflush(stdout); } printf("\n--\n"); ao_close(snd_ao); fi++; } ao_shutdown(); return 0; }