-/* $OpenBSD: graphics.c,v 1.8 2009/10/27 23:59:23 deraadt Exp $ */
+/* $OpenBSD: graphics.c,v 1.9 2014/07/13 13:00:40 tedu Exp $ */
/* $NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $ */
/*-
getAChar(void)
{
int c;
-#ifdef BSD
+
if ((c = getchar()) == EOF && feof(stdin))
quit(0);
return (c);
-#endif
-#ifdef SYSV
- while ((c = getchar()) == -1 && errno == EINTR) ;
- return(c);
-#endif
}
void
quit(int dummy)
{
int c, y, x;
-#ifdef BSD
struct itimerval itv;
-#endif
getyx(input, y, x);
wmove(input, 2, 0);
c = getchar();
if (c == EOF || c == 'y') {
/* disable timer */
-#ifdef BSD
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, NULL);
-#endif
-#ifdef SYSV
- alarm(0);
-#endif
fflush(stdout);
clear();
refresh();
PLANE *pp;
int warning = 0;
-#ifdef BSD
wclear(planes);
-#endif
wmove(planes, 0,0);
-#ifdef SYSV
- wclrtobot(planes);
-#endif
wprintw(planes, "Time: %-4d Safe: %d", clck, safe_planes);
wmove(planes, 2, 0);
loser(const PLANE *p, const char *s)
{
int c;
-#ifdef BSD
struct itimerval itv;
-#endif
/* disable timer */
-#ifdef BSD
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, NULL);
-#endif
-#ifdef SYSV
- alarm(0);
-#endif
wmove(input, 0, 0);
wclrtobot(input);
-/* $OpenBSD: log.c,v 1.17 2009/10/27 23:59:23 deraadt Exp $ */
+/* $OpenBSD: log.c,v 1.18 2014/07/13 13:00:40 tedu Exp $ */
/* $NetBSD: log.c,v 1.3 1995/03/21 15:04:21 cgd Exp $ */
/*-
if (score_fp == NULL)
return (-1);
-#ifdef BSD
- if (flock(fileno(score_fp), LOCK_EX) < 0)
-#endif
-#ifdef SYSV
- while (lockf(fileno(score_fp), F_LOCK, 1) < 0)
-#endif
- {
+ if (flock(fileno(score_fp), LOCK_EX) < 0) {
perror("flock");
return (-1);
}
}
putchar('\n');
}
-#ifdef BSD
flock(fileno(score_fp), LOCK_UN);
-#endif
-#ifdef SYSV
- /* lock will evaporate upon close */
-#endif
-#if 0
- fclose(score_fp);
-#else
fflush(score_fp);
fsync(fileno(score_fp));
rewind(score_fp);
-#endif
printf("%2s: %-31s %-18s %4s %9s %4s\n", "#", "name",
"game", "time", "real time", "safe");
puts("-------------------------------------------------------------------------------");
-/* $OpenBSD: main.c,v 1.21 2009/10/27 23:59:23 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.22 2014/07/13 13:00:40 tedu Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
/*-
char *name, *ptr, *seed;
struct sigaction sa;
gid_t gid;
-#ifdef BSD
struct itimerval itv;
-#endif
open_score_file();
signal(SIGINT, quit);
signal(SIGQUIT, quit);
-#ifdef BSD
signal(SIGTSTP, SIG_IGN);
signal(SIGSTOP, SIG_IGN);
-#endif
signal(SIGHUP, log_score_quit);
signal(SIGTERM, log_score_quit);
sa.sa_flags = 0;
sigaction(SIGALRM, &sa, (struct sigaction *)0);
-#ifdef BSD
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 1;
itv.it_interval.tv_sec = sp->update_secs;
itv.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, NULL);
-#endif
-#ifdef SYSV
- alarm(sp->update_secs);
-#endif
for (;;) {
if (getcommand() != 1)
planewin();
else {
-#ifdef BSD
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, NULL);
-#endif
-#ifdef SYSV
- alarm(0);
-#endif
update(0);
-#ifdef BSD
itv.it_value.tv_sec = sp->update_secs;
itv.it_value.tv_usec = 0;
itv.it_interval.tv_sec = sp->update_secs;
itv.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, NULL);
-#endif
-#ifdef SYSV
- alarm(sp->update_secs);
-#endif
}
}
}
-/* $OpenBSD: update.c,v 1.12 2009/10/27 23:59:23 deraadt Exp $ */
+/* $OpenBSD: update.c,v 1.13 2014/07/13 13:00:40 tedu Exp $ */
/*-
* Copyright (c) 1990, 1993
int i, dir_diff, unclean;
PLANE *pp, *p1, *p2;
-#ifdef SYSV
- alarm(0);
- signal(SIGALRM, update);
-#endif
-
clck++;
erase_all();
*/
if ((random() % sp->newplane_time) == 0)
addplane();
-
-#ifdef SYSV
- alarm(sp->update_secs);
-#endif
}
const char *