diff arogue7/main.c @ 219:f9ef86cf22b2

Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents cadff8f047a1
children e1cd27c5464f
line wrap: on
line diff
--- a/arogue7/main.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/main.c	Fri Feb 19 21:02:28 2016 -0500
@@ -32,10 +32,19 @@
 #endif
 
 void open_records(void);
+bool too_much(void);
+bool author(void);
+void chmsg(char *fmt, int arg);
+#ifdef MAXPROCESSES
+int loadav(void);
+#endif
+#ifdef MAXUSERS
+int ucount(void);
+#endif
+bool holiday(void);
 
-main(argc, argv, envp)
-char **argv;
-char **envp;
+int
+main(int argc, char *argv[], char *envp[])
 {
     register char *env;
     int lowtime;
@@ -419,8 +428,7 @@
  */
 
 void
-endit(sig)
-int sig;
+endit(int sig)
 {
     fatal("Ok, if you want to exit that badly, I'll have to allow it\n");
 }
@@ -430,8 +438,8 @@
  *	Exit the program, printing a message.
  */
 
-fatal(s)
-char *s;
+void
+fatal(char *s)
 {
     clear();
     move(lines-2, 0);
@@ -449,8 +457,8 @@
  * rnd:
  *	Pick a very random number.
  */
-rnd(range)
-register int range;
+int
+rnd(int range)
 {
     return(range <= 0 ? 0 : md_rand() % range);
 }
@@ -460,8 +468,8 @@
  *	roll a number of dice
  */
 
-roll(number, sides)
-register int number, sides;
+int
+roll(int number, int sides)
 {
     register int dtotal = 0;
 
@@ -474,8 +482,7 @@
  * handle stop and start signals
  */
 void
-tstp(sig)
-int sig;
+tstp(int sig)
 {
     mvcur(0, cols - 1, lines - 1, 0);
     endwin();
@@ -493,7 +500,8 @@
 }
 # endif
 
-setup()
+void
+setup(void)
 {
 #ifdef CHECKTIME
     int  checkout();
@@ -563,7 +571,8 @@
  * refreshing things and looking at the proper times.
  */
 
-playit()
+void
+playit(void)
 {
     register char *opts;
 
@@ -585,7 +594,8 @@
 /*
  * see if the system is being used too much for this game
  */
-too_much()
+bool
+too_much(void)
 {
 #if MAXPROCESSES
 	if (loadav() > MAXPROCESSES)
@@ -602,7 +612,8 @@
  * author:
  *	See if a user is an author of the program
  */
-author()
+bool
+author(void)
 {
 	switch (md_getuid()) {
 #if AUTHOR
@@ -653,9 +664,8 @@
  * checkout()'s version of msg.  If we are in the middle of a shell, do a
  * printf instead of a msg to avoid the refresh.
  */
-chmsg(fmt, arg)
-char *fmt;
-int arg;
+void
+chmsg(char *fmt, int arg)
 {
 	if (in_shell) {
 		printf(fmt, arg);
@@ -671,7 +681,8 @@
 
 #include <fcntl.h>
 
-loadav()
+int
+loadav(void)
 {
 	char *sarcmd = "sar -v | cut -c17-20 | tail -2";
 	char *gettycmd = "grep getty /etc/inittab | wc -l";
@@ -724,7 +735,9 @@
 #include <sys/types.h>
 #include <utmp.h>
 struct utmp buf;
-ucount()
+
+int
+ucount(void)
 {
 	reg struct utmp *up;
 	reg FILE *utmp;
@@ -751,7 +764,8 @@
  * holiday:
  *	Returns TRUE when it is a good time to play rogue
  */
-holiday()
+bool
+holiday(void)
 {
 #ifdef CHECKTIME
 	long now;