File *getfinaltarget(File *file) { Map *linkmap = newmap(); if (!linkmap) { errorf("Out of memory?\n"); return NULL; } File *target = NULL; while (isstat(file) && islink(file)) { target = gettarget(file); if (!target) { errorf("Cannot determine target of %s for %s\n", getname(file)); break; } if (inmap(linkmap, getinode(target))) { errorf("Symlink loop in %s\n", getname(file)); /* no file to stat, but want to print the name field */ target = NULL; break; } else { set(linkmap, (uintmax_t)getinode(target), NULL); } file = target; } freemap(linkmap); return target; }
void credits2(void) { int i, ch; int p; int plast = -1; clrscr(); centerprint(aa_imgwidth(context) / 2, aa_imgheight(context) / 3, 3, 128, "The", 0); centerprint(aa_imgwidth(context) / 2, 2 * aa_imgheight(context) / 3, 3, 128, "END", 0); drawptr = decrand; params->randomval = 50; timestuff(0, NULL, draw, 5000000); drawptr = NULL; params->randomval = 0; drawptr = pryc; timestuff(0, NULL, draw, MAXTIME); drawptr = NULL; clrscr(); draw(); load_song("bb3.s3m"); bbupdate(); starttime = endtime = TIME; play(); bbwait(1); for (i = 0; i < LOGOHEIGHT; i++) { aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i, AA_BOLD, "8 8"); if (i) aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8 8"); bbflushwait(100000); } aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8 8"); #define LWIDTH for (i = aa_scrwidth(context) / 2; i; i--) { display8(); displaya(i); bbflushwait(10000); } for (; i < 100; i++) { textclrscr(); displaya(10 * sin(i * M_PI / 100)); display8(); bbflushwait(10000); } aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_DIM, "<PROJECT><PROJECT>"); bbflushwait(100000); aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>"); bbflushwait(100000); aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_BOLD, "<PROJECT><PROJECT>"); bbflushwait(100000); aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>"); bbflushwait(100000); bbwait(1000000); for (i = LOGOY; i > 1; i--) { textclrscr(); displogo(i); bbflushwait(30000); } source = malloc(aa_imgwidth(context) * (aa_imgheight(context))); target = malloc(aa_imgwidth(context) * (aa_imgheight(context))); params->dither = AA_NONE; format(dual ? aa_scrwidth(context) / 2 : aa_scrwidth(context)); p = 0; while (1) { if (p != plast) { getsource(); displaytext(p); gettarget(); morph(); displaytext(p); aa_flush(context); emscripten_sleep(1); plast = p; } again: emscripten_sleep(100); #ifndef __DJGPP__ //ch = aa_getkey(context, 100); ch = AA_NONE; #else while ((ch = bbupdate()) == AA_NONE) ; #endif switch (ch) { case '1': load_song("bb.s3m"); bbupdate(); play(); break; case '2': load_song("bb2.s3m"); bbupdate(); play(); break; case '3': load_song("bb3.s3m"); bbupdate(); play(); break; case 'b': case 'k': case 'B': case 'K': case AA_BACKSPACE: case AA_UP: p -= (aa_scrheight(context) - YSTART) / 2 * (dual + 1); if (p < 0) p = 0; break; case AA_DOWN: case AA_LEFT: case 'f': case 'F': case ' ': case 'j': case 'J': p += (aa_scrheight(context) - YSTART) / 2 * (dual + 1); if (p > textsize) p = textsize; break; case 'q': case 'Q': case AA_ESC: finish_stuff = 0; backconvert(0, 0, aa_scrwidth(context), aa_scrheight(context)); bbupdate(); starttime = endtime = TIME; drawptr = decbright; timestuff(0, NULL, draw, 1000000); textclrscr(); drawptr = NULL; aa_flush(context); emscripten_sleep(1); free(source); free(target); return; default: goto again; } bbupdate(); starttime = endtime = TIME; } }