]> skyeroc.xyz Git - dgamelaunch/commitdiff
Regenerate dependencies, function prototypes, remove useless includes, globals,
authorJoshua Kwan <joshk@triplehelix.org>
Fri, 30 Jan 2004 02:49:29 +0000 (02:49 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Fri, 30 Jan 2004 02:49:29 +0000 (02:49 +0000)
and make code more readable. Move externs into a header file, just tidying up.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@186 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

Makefile
dgamelaunch.c
dgamelaunch.h
ttyplay.c
ttyplay.h [new file with mode: 0644]
ttyrec.c
ttyrec.h

index 171c0bbbb31bc0af050fb2fa5d3b8e4f42e85bbb..b0ec0dc847856d8764563360a934c6f76c1044e2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@ indent:
 lex.yy.c: config.l
        $(LEX) $<
 
-y.tab.c: config.y
+y.tab.c y.tab.h: config.y
        $(YACC) -d $<
 
 lex.yy.o: lex.yy.c
@@ -76,9 +76,15 @@ dist: clean
        @echo "Created source release $(NAME)-$(VERSION).tar.gz"
        
 # Dependencies - we may auto-generate later
-dgamelaunch.o: dgamelaunch.c dgamelaunch.h y.tab.o
+ee.o: ee.c
 io.o: io.c ttyrec.h
+last_char_is.o: last_char_is.c
+mygetnstr.o: mygetnstr.c
+nethackstub.o: nethackstub.c
 stripgfx.o: stripgfx.c stripgfx.h
-ttyplay.o: ttyplay.c ttyrec.h io.h stripgfx.h
+strlcat.o: strlcat.c
+strlcpy.o: strlcpy.c
+ttyplay.o: ttyplay.c dgamelaunch.h ttyplay.h ttyrec.h io.h stripgfx.h
 ttyrec.o: ttyrec.c dgamelaunch.h ttyrec.h io.h
 virus.o: virus.c last_char_is.c
+y.tab.o: y.tab.c dgamelaunch.h
index 860bf7e61bc2eb8d2e7b4889e1fd7387fd537625..073a7844bedf6d05f71eb1dd747fa5671d8f38c1 100644 (file)
  */
 
 #define _GNU_SOURCE
+
 #include "dgamelaunch.h"
+#include "ttyplay.h"
+#include "ttyrec.h"
 
 /* a request from the author: please leave some remnance of
  * 'based on dgamelaunch version xxx' in any derivative works, or
 extern FILE* yyin;
 extern int yyparse ();
 
-extern pid_t child; /* nethack process */
-
 extern int editor_main (int argc, char **argv);
-extern int ttyplay_main (char *ttyfile, int mode, int rstripgfx);
-extern int ttyrec_main (char *username, char* ttyrec_filename);
-extern int master, slave;
-extern struct termios tt;
-extern struct winsize win;
 
 /* global variables */
 
index 0c696d114f607f0384fe1d6c5cbd637e4624ebfd..f712c8bd1a7028c221313f4cd3e2a183d0a5901a 100644 (file)
@@ -54,33 +54,38 @@ struct dg_config
   unsigned long max;
 };
 
+/* Global variables */
 extern char* config; /* file path */
 extern struct dg_config *myconfig;
+extern char *chosen_name;
+extern int loggedin;
 
-/* dgamelaunch.c function prototypes */
-extern void create_config (void);
-extern void ttyrec_getmaster (void);
-extern char* gen_ttyrec_filename (void);
-extern char* gen_inprogress_lock (pid_t pid, char* ttyrec_filename);
-extern void catch_sighup (int signum);
-extern void loadbanner (struct dg_banner *ban);
-extern void drawbanner (unsigned int start_line, unsigned int howmany);
-extern struct dg_game **populate_games (int *l);
-extern void inprogressmenu (void);
-extern int changepw (void);
-extern void domailuser (char *username);
-extern void drawmenu (void);
-extern void freefile (void);
-extern void initcurses (void);
-extern void loginprompt (void);
-extern void newuser (void);
-extern int passwordgood (char *cpw);
-extern int readfile (int nolock);
-extern int userexist (char *cname);
-extern void write_canned_rcfile (char *target);
-extern void editoptions (void);
-extern void writefile (int requirenew);
-extern void graceful_exit (int status);
+/* dgamelaunch.c */
+extern void create_config(void);
+extern void ttyrec_getmaster(void);
+extern char *gen_ttyrec_filename(void);
+extern char *gen_inprogress_lock(pid_t pid, char *ttyrec_filename);
+extern void catch_sighup(int signum);
+extern void loadbanner(struct dg_banner *ban);
+extern void drawbanner(unsigned int start_line, unsigned int howmany);
+extern struct dg_game **populate_games(int *l);
+extern void inprogressmenu(void);
+extern int changepw(void);
+extern void domailuser(char *username);
+extern void drawmenu(void);
+extern void freefile(void);
+extern void initcurses(void);
+extern void loginprompt(void);
+extern void newuser(void);
+extern int passwordgood(char *cpw);
+extern int readfile(int nolock);
+extern int userexist(char *cname);
+extern void write_canned_rcfile(char *target);
+extern void editoptions(void);
+extern void writefile(int requirenew);
+extern void graceful_exit(int status);
+extern int purge_stale_locks(void);
+extern void menuloop(void);
 
 /* strlcpy.c */
 extern size_t strlcpy (char *dst, const char *src, size_t siz);
index b01f9f35be8d3e086b33231e9075a3a0d6781d5d..da61a0e32888cd0e9b664ab48ef541b98f65dedf 100644 (file)
--- a/ttyplay.c
+++ b/ttyplay.c
 #include <termios.h>
 #include <string.h>
 #include <curses.h>
+
+#include "dgamelaunch.h"
+#include "ttyplay.h"
 #include "ttyrec.h"
 #include "io.h"
 #include "stripgfx.h"
 
-extern void domailuser (char *);
-extern void initcurses (void);
-extern char *chosen_name;
-extern int loggedin;
-
-int ttyplay_main (char *ttyfile, int mode, int rstripgfx);
-
 off_t seek_offset_clrscr;
 int bstripgfx;
-char *ttyfile_local;
-
-typedef double (*WaitFunc) (struct timeval prev,
-                            struct timeval cur, double speed);
-typedef int (*ReadFunc) (FILE * fp, Header * h, char **buf, int pread);
-typedef void (*WriteFunc) (char *buf, int len);
-typedef void (*ProcessFunc) (FILE * fp, double speed,
-                             ReadFunc read_func, WaitFunc wait_func);
 
 struct timeval
 timeval_diff (struct timeval tv1, struct timeval tv2)
@@ -210,11 +198,6 @@ ttypread (FILE * fp, Header * h, char **buf, int pread)
                 {
                   initcurses ();
                   domailuser (chosen_name);
-                 /* XXX jilles: just quit out after mail for now */
-#if 0
-                  endwin ();
-                  ttyplay_main (ttyfile_local, 1, 0); /* ICK! Recursive */
-#endif
                   return 0;
                 }
               break;
@@ -392,8 +375,6 @@ ttyplay_main (char *ttyfile, int mode, int rstripgfx)
   FILE *input = stdin;
   struct termios old, new;
 
-  ttyfile_local = ttyfile;
-
   /* strip graphics mode flag */
   bstripgfx = rstripgfx;
   if (bstripgfx)
diff --git a/ttyplay.h b/ttyplay.h
new file mode 100644 (file)
index 0000000..9581a6a
--- /dev/null
+++ b/ttyplay.h
@@ -0,0 +1,16 @@
+#ifndef INCLUDED_ttyplay_h
+#define INCLUDED_ttyplay_h
+
+#include <stdio.h>
+#include "ttyrec.h"
+
+int ttyplay_main (char *ttyfile, int mode, int rstripgfx);
+
+typedef double (*WaitFunc) (struct timeval prev,
+                            struct timeval cur, double speed);
+typedef int (*ReadFunc) (FILE * fp, Header * h, char **buf, int pread);
+typedef void (*WriteFunc) (char *buf, int len);
+typedef void (*ProcessFunc) (FILE * fp, double speed,
+                             ReadFunc read_func, WaitFunc wait_func);
+
+#endif /* !INCLUDED_ttyrec_h */
index f2d9f3ac3c404aefd3c1eb53457cc7413cd9ad60..c37652290f1ebe66f0d0f8d325dabf8cbce33133 100644 (file)
--- a/ttyrec.c
+++ b/ttyrec.c
 /*
  * script
  */
-#include "dgamelaunch.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
 
@@ -62,6 +61,7 @@
 #include <stdlib.h>
 #include <fcntl.h>
 
+#include "dgamelaunch.h"
 #include "ttyrec.h"
 #include "io.h"
 
 # define XCASE 0
 #endif
 
-void done (void);
-void fail (void);
-void fixtty (void);
-void getslave (void);
-void doinput (void);
-void dooutput (void);
-void doshell (char *);
-
-FILE *fscript;
-int master;
 int slave;
 pid_t child, subchild;
 char* ipfile = NULL;
 
+FILE *fscript;
+int master;
+
 struct termios tt;
 struct winsize win;
-int lb;
-int l;
-int aflg;
 int uflg;
 
 int
 ttyrec_main (char *username, char* ttyrec_filename)
 {
-  void finish ();
   char dirname[100];
 
   snprintf (dirname, 100, "%sttyrec/%s", myconfig->dglroot, username);
@@ -157,15 +146,19 @@ doinput ()
 }
 
 void
-finish ()
+finish (int sig)
 {
   int status;
   register int pid;
   register int die = 0;
 
-  while ((pid = wait3 ((int *) &status, WNOHANG, 0)) > 0)
+  (void)sig; /* unused */
+
+  while ((pid = wait3 (&status, WNOHANG, 0)) > 0)
+  {
     if (pid == child)
       die = 1;
+  }
 
   if (die)
     done ();
index c8c623abf99982448c8a5e6257fc690434217c66..9270624b37a0d10c0a48f0451d14a1528e27a8cf 100644 (file)
--- a/ttyrec.h
+++ b/ttyrec.h
@@ -11,5 +11,20 @@ typedef struct header
 }
 Header;
 
+extern void done (void);
+extern void fail (void);
+extern void fixtty (void);
+extern void getslave (void);
+extern void doinput (void);
+extern void dooutput (void);
+extern void doshell (char *);
+extern void finish (int);
+
+extern int ttyrec_main(char *username, char *ttyrec_filename);
+
+extern pid_t child; /* nethack process */
+extern int master, slave;
+extern struct termios tt;
+extern struct winsize win;
 
 #endif