Regenerate dependencies, function prototypes, remove useless includes, globals,
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
This commit is contained in:
parent
e4779f7f8a
commit
6f11c9053a
12
Makefile
12
Makefile
|
@ -62,7 +62,7 @@ indent:
|
||||||
lex.yy.c: config.l
|
lex.yy.c: config.l
|
||||||
$(LEX) $<
|
$(LEX) $<
|
||||||
|
|
||||||
y.tab.c: config.y
|
y.tab.c y.tab.h: config.y
|
||||||
$(YACC) -d $<
|
$(YACC) -d $<
|
||||||
|
|
||||||
lex.yy.o: lex.yy.c
|
lex.yy.o: lex.yy.c
|
||||||
|
@ -76,9 +76,15 @@ dist: clean
|
||||||
@echo "Created source release $(NAME)-$(VERSION).tar.gz"
|
@echo "Created source release $(NAME)-$(VERSION).tar.gz"
|
||||||
|
|
||||||
# Dependencies - we may auto-generate later
|
# 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
|
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
|
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
|
ttyrec.o: ttyrec.c dgamelaunch.h ttyrec.h io.h
|
||||||
virus.o: virus.c last_char_is.c
|
virus.o: virus.c last_char_is.c
|
||||||
|
y.tab.o: y.tab.c dgamelaunch.h
|
||||||
|
|
|
@ -29,7 +29,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include "dgamelaunch.h"
|
#include "dgamelaunch.h"
|
||||||
|
#include "ttyplay.h"
|
||||||
|
#include "ttyrec.h"
|
||||||
|
|
||||||
/* a request from the author: please leave some remnance of
|
/* a request from the author: please leave some remnance of
|
||||||
* 'based on dgamelaunch version xxx' in any derivative works, or
|
* 'based on dgamelaunch version xxx' in any derivative works, or
|
||||||
|
@ -82,14 +85,7 @@
|
||||||
extern FILE* yyin;
|
extern FILE* yyin;
|
||||||
extern int yyparse ();
|
extern int yyparse ();
|
||||||
|
|
||||||
extern pid_t child; /* nethack process */
|
|
||||||
|
|
||||||
extern int editor_main (int argc, char **argv);
|
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 */
|
/* global variables */
|
||||||
|
|
||||||
|
|
|
@ -54,33 +54,38 @@ struct dg_config
|
||||||
unsigned long max;
|
unsigned long max;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
extern char* config; /* file path */
|
extern char* config; /* file path */
|
||||||
extern struct dg_config *myconfig;
|
extern struct dg_config *myconfig;
|
||||||
|
extern char *chosen_name;
|
||||||
|
extern int loggedin;
|
||||||
|
|
||||||
/* dgamelaunch.c function prototypes */
|
/* dgamelaunch.c */
|
||||||
extern void create_config (void);
|
extern void create_config(void);
|
||||||
extern void ttyrec_getmaster (void);
|
extern void ttyrec_getmaster(void);
|
||||||
extern char* gen_ttyrec_filename (void);
|
extern char *gen_ttyrec_filename(void);
|
||||||
extern char* gen_inprogress_lock (pid_t pid, char* ttyrec_filename);
|
extern char *gen_inprogress_lock(pid_t pid, char *ttyrec_filename);
|
||||||
extern void catch_sighup (int signum);
|
extern void catch_sighup(int signum);
|
||||||
extern void loadbanner (struct dg_banner *ban);
|
extern void loadbanner(struct dg_banner *ban);
|
||||||
extern void drawbanner (unsigned int start_line, unsigned int howmany);
|
extern void drawbanner(unsigned int start_line, unsigned int howmany);
|
||||||
extern struct dg_game **populate_games (int *l);
|
extern struct dg_game **populate_games(int *l);
|
||||||
extern void inprogressmenu (void);
|
extern void inprogressmenu(void);
|
||||||
extern int changepw (void);
|
extern int changepw(void);
|
||||||
extern void domailuser (char *username);
|
extern void domailuser(char *username);
|
||||||
extern void drawmenu (void);
|
extern void drawmenu(void);
|
||||||
extern void freefile (void);
|
extern void freefile(void);
|
||||||
extern void initcurses (void);
|
extern void initcurses(void);
|
||||||
extern void loginprompt (void);
|
extern void loginprompt(void);
|
||||||
extern void newuser (void);
|
extern void newuser(void);
|
||||||
extern int passwordgood (char *cpw);
|
extern int passwordgood(char *cpw);
|
||||||
extern int readfile (int nolock);
|
extern int readfile(int nolock);
|
||||||
extern int userexist (char *cname);
|
extern int userexist(char *cname);
|
||||||
extern void write_canned_rcfile (char *target);
|
extern void write_canned_rcfile(char *target);
|
||||||
extern void editoptions (void);
|
extern void editoptions(void);
|
||||||
extern void writefile (int requirenew);
|
extern void writefile(int requirenew);
|
||||||
extern void graceful_exit (int status);
|
extern void graceful_exit(int status);
|
||||||
|
extern int purge_stale_locks(void);
|
||||||
|
extern void menuloop(void);
|
||||||
|
|
||||||
/* strlcpy.c */
|
/* strlcpy.c */
|
||||||
extern size_t strlcpy (char *dst, const char *src, size_t siz);
|
extern size_t strlcpy (char *dst, const char *src, size_t siz);
|
||||||
|
|
25
ttyplay.c
25
ttyplay.c
|
@ -42,27 +42,15 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
|
||||||
|
#include "dgamelaunch.h"
|
||||||
|
#include "ttyplay.h"
|
||||||
#include "ttyrec.h"
|
#include "ttyrec.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "stripgfx.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;
|
off_t seek_offset_clrscr;
|
||||||
int bstripgfx;
|
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
|
struct timeval
|
||||||
timeval_diff (struct timeval tv1, struct timeval tv2)
|
timeval_diff (struct timeval tv1, struct timeval tv2)
|
||||||
|
@ -210,11 +198,6 @@ ttypread (FILE * fp, Header * h, char **buf, int pread)
|
||||||
{
|
{
|
||||||
initcurses ();
|
initcurses ();
|
||||||
domailuser (chosen_name);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -392,8 +375,6 @@ ttyplay_main (char *ttyfile, int mode, int rstripgfx)
|
||||||
FILE *input = stdin;
|
FILE *input = stdin;
|
||||||
struct termios old, new;
|
struct termios old, new;
|
||||||
|
|
||||||
ttyfile_local = ttyfile;
|
|
||||||
|
|
||||||
/* strip graphics mode flag */
|
/* strip graphics mode flag */
|
||||||
bstripgfx = rstripgfx;
|
bstripgfx = rstripgfx;
|
||||||
if (bstripgfx)
|
if (bstripgfx)
|
||||||
|
|
|
@ -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 */
|
29
ttyrec.c
29
ttyrec.c
|
@ -42,11 +42,10 @@
|
||||||
/*
|
/*
|
||||||
* script
|
* script
|
||||||
*/
|
*/
|
||||||
#include "dgamelaunch.h"
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
@ -62,6 +61,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include "dgamelaunch.h"
|
||||||
#include "ttyrec.h"
|
#include "ttyrec.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
@ -69,31 +69,20 @@
|
||||||
# define XCASE 0
|
# define XCASE 0
|
||||||
#endif
|
#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;
|
int slave;
|
||||||
pid_t child, subchild;
|
pid_t child, subchild;
|
||||||
char* ipfile = NULL;
|
char* ipfile = NULL;
|
||||||
|
|
||||||
|
FILE *fscript;
|
||||||
|
int master;
|
||||||
|
|
||||||
struct termios tt;
|
struct termios tt;
|
||||||
struct winsize win;
|
struct winsize win;
|
||||||
int lb;
|
|
||||||
int l;
|
|
||||||
int aflg;
|
|
||||||
int uflg;
|
int uflg;
|
||||||
|
|
||||||
int
|
int
|
||||||
ttyrec_main (char *username, char* ttyrec_filename)
|
ttyrec_main (char *username, char* ttyrec_filename)
|
||||||
{
|
{
|
||||||
void finish ();
|
|
||||||
char dirname[100];
|
char dirname[100];
|
||||||
|
|
||||||
snprintf (dirname, 100, "%sttyrec/%s", myconfig->dglroot, username);
|
snprintf (dirname, 100, "%sttyrec/%s", myconfig->dglroot, username);
|
||||||
|
@ -157,15 +146,19 @@ doinput ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finish ()
|
finish (int sig)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
register int pid;
|
register int pid;
|
||||||
register int die = 0;
|
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)
|
if (pid == child)
|
||||||
die = 1;
|
die = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (die)
|
if (die)
|
||||||
done ();
|
done ();
|
||||||
|
|
15
ttyrec.h
15
ttyrec.h
|
@ -11,5 +11,20 @@ typedef struct header
|
||||||
}
|
}
|
||||||
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue