2003-12-30 22:30:32 +01:00
|
|
|
/* IMPORTANT defines */
|
|
|
|
|
|
|
|
#ifndef __DGAMELAUNCH_H
|
|
|
|
#define __DGAMELAUNCH_H
|
|
|
|
|
2004-07-03 21:19:28 +02:00
|
|
|
#include "config.h"
|
2004-01-19 19:14:08 +01:00
|
|
|
#include <sys/param.h>
|
2004-01-04 03:03:26 +01:00
|
|
|
#include <sys/types.h>
|
2004-01-02 05:35:46 +01:00
|
|
|
#include <time.h>
|
|
|
|
|
2004-02-22 06:57:36 +01:00
|
|
|
#ifndef ARRAY_SIZE
|
|
|
|
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
|
|
|
#endif
|
|
|
|
|
2007-03-29 22:14:55 +02:00
|
|
|
|
|
|
|
/* max # of different games playable from within this dgl */
|
2008-01-01 22:41:17 +01:00
|
|
|
/*#define DIFF_GAMES 4*/
|
2007-03-29 22:14:55 +02:00
|
|
|
|
2008-01-01 18:03:05 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DGLTIME_DGLSTART = 0, /* when someone telnets in */
|
|
|
|
DGLTIME_LOGIN, /* right after user login */
|
|
|
|
DGLTIME_REGISTER, /* right after new nick is registered */
|
|
|
|
DGLTIME_GAMESTART, /* right before a game is started */
|
|
|
|
NUM_DGLTIMES
|
|
|
|
} dglcmd_times;
|
|
|
|
|
|
|
|
struct dg_cmdpart
|
|
|
|
{
|
|
|
|
dglcmd_times cmd;
|
|
|
|
char *param1;
|
|
|
|
char *param2;
|
|
|
|
struct dg_cmdpart *next;
|
|
|
|
};
|
|
|
|
|
2003-12-30 22:30:32 +01:00
|
|
|
struct dg_user
|
|
|
|
{
|
2007-12-27 20:52:48 +01:00
|
|
|
#ifdef USE_SQLITE3
|
|
|
|
long id;
|
|
|
|
#endif
|
2003-12-31 20:47:49 +01:00
|
|
|
char *username;
|
|
|
|
char *email;
|
|
|
|
char *env;
|
|
|
|
char *password;
|
|
|
|
int flags;
|
2003-12-30 22:30:32 +01:00
|
|
|
};
|
|
|
|
|
2003-12-31 20:47:49 +01:00
|
|
|
struct dg_banner
|
|
|
|
{
|
|
|
|
char **lines;
|
|
|
|
unsigned int len;
|
|
|
|
};
|
|
|
|
|
2004-01-02 05:35:46 +01:00
|
|
|
struct dg_game
|
|
|
|
{
|
|
|
|
char *ttyrec_fn;
|
|
|
|
char *name;
|
|
|
|
char *date;
|
|
|
|
char *time;
|
|
|
|
time_t idle_time;
|
2004-03-04 14:58:03 +01:00
|
|
|
int ws_row, ws_col; /* Window size */
|
2007-04-01 12:11:38 +02:00
|
|
|
int gamenum;
|
2004-01-02 05:35:46 +01:00
|
|
|
};
|
|
|
|
|
2004-01-05 02:25:38 +01:00
|
|
|
struct dg_config
|
|
|
|
{
|
2004-04-03 21:27:42 +02:00
|
|
|
char* game_path;
|
|
|
|
char* game_name;
|
2007-04-01 12:11:38 +02:00
|
|
|
char* shortname;
|
2004-01-05 02:25:38 +01:00
|
|
|
char* rcfile;
|
|
|
|
char* spool;
|
2007-03-29 22:14:55 +02:00
|
|
|
char* inprogressdir;
|
|
|
|
int num_args; /* # of bin_args */
|
|
|
|
char **bin_args; /* args for game binary */
|
|
|
|
char *rc_fmt;
|
2008-01-01 18:03:05 +01:00
|
|
|
struct dg_cmdpart *cmdqueue;
|
2007-03-29 22:14:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dg_globalconfig
|
|
|
|
{
|
|
|
|
char* chroot;
|
|
|
|
char* dglroot;
|
|
|
|
char* banner;
|
|
|
|
unsigned long max;
|
2007-03-31 13:10:07 +02:00
|
|
|
int max_newnick_len; /* maximum length of new registered names. must be less than 20 chars. */
|
2007-03-29 22:14:55 +02:00
|
|
|
char* shed_user;
|
|
|
|
char* shed_group;
|
|
|
|
uid_t shed_uid;
|
|
|
|
gid_t shed_gid;
|
2007-03-31 23:18:32 +02:00
|
|
|
char* passwd;
|
2007-03-31 23:29:45 +02:00
|
|
|
char* lockfile;
|
2007-04-09 18:42:14 +02:00
|
|
|
int allow_registration; /* allow registering new nicks */
|
2008-01-01 18:03:05 +01:00
|
|
|
|
|
|
|
struct dg_cmdpart *cmdqueue[NUM_DGLTIMES];
|
2004-01-05 02:25:38 +01:00
|
|
|
};
|
|
|
|
|
2008-01-01 18:03:05 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DGLCMD_NONE = 0,
|
|
|
|
DGLCMD_MKDIR, /* mkdir foo */
|
|
|
|
DGLCMD_CHDIR, /* chdir foo */
|
|
|
|
DGLCMD_CP, /* cp foo bar */
|
|
|
|
DGLCMD_UNLINK, /* unlink foo */
|
|
|
|
DGLCMD_SETENV /* setenv foo bar */
|
|
|
|
} dglcmd_actions;
|
2007-12-24 19:09:15 +01:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SORTMODE_NONE = 0,
|
2007-12-25 17:27:30 +01:00
|
|
|
SORTMODE_USERNAME,
|
|
|
|
SORTMODE_IDLETIME,
|
2007-12-24 19:09:15 +01:00
|
|
|
NUM_SORTMODES
|
|
|
|
} dg_sortmode;
|
|
|
|
|
|
|
|
static const char *SORTMODE_NAME[] = {
|
|
|
|
"Unsorted",
|
2007-12-25 17:27:30 +01:00
|
|
|
"Username",
|
|
|
|
"Idletime",
|
2007-12-24 19:09:15 +01:00
|
|
|
"",
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-01-30 03:49:29 +01:00
|
|
|
/* Global variables */
|
2004-01-05 02:25:38 +01:00
|
|
|
extern char* config; /* file path */
|
2007-03-29 22:14:55 +02:00
|
|
|
extern struct dg_config **myconfig;
|
2004-01-30 03:49:29 +01:00
|
|
|
extern char *chosen_name;
|
|
|
|
extern int loggedin;
|
2004-01-31 07:23:02 +01:00
|
|
|
extern int silent;
|
2004-02-01 09:20:28 +01:00
|
|
|
extern int set_max;
|
2004-01-05 02:25:38 +01:00
|
|
|
|
2007-03-29 22:14:55 +02:00
|
|
|
extern struct dg_globalconfig globalconfig;
|
|
|
|
|
|
|
|
extern int num_games;
|
|
|
|
|
2004-01-30 03:49:29 +01:00
|
|
|
/* dgamelaunch.c */
|
|
|
|
extern void create_config(void);
|
|
|
|
extern void ttyrec_getmaster(void);
|
|
|
|
extern char *gen_ttyrec_filename(void);
|
2007-03-29 22:14:55 +02:00
|
|
|
extern char *gen_inprogress_lock(int game, pid_t pid, char *ttyrec_filename);
|
2004-01-30 03:49:29 +01:00
|
|
|
extern void catch_sighup(int signum);
|
2007-03-29 22:14:55 +02:00
|
|
|
extern void loadbanner(int game, struct dg_banner *ban);
|
2004-01-30 03:49:29 +01:00
|
|
|
extern void drawbanner(unsigned int start_line, unsigned int howmany);
|
2007-03-29 22:14:55 +02:00
|
|
|
extern char *dgl_format_str(int game, struct dg_user *me, char *str);
|
2008-01-01 18:03:05 +01:00
|
|
|
|
|
|
|
extern int dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me);
|
|
|
|
|
2007-03-29 22:14:55 +02:00
|
|
|
extern struct dg_game **populate_games(int game, int *l);
|
2007-12-24 19:09:15 +01:00
|
|
|
|
|
|
|
extern struct dg_game **sort_games(struct dg_game **games, int len, dg_sortmode sortmode);
|
|
|
|
|
2007-03-29 22:14:55 +02:00
|
|
|
extern void inprogressmenu(int gameid);
|
2004-02-05 20:38:17 +01:00
|
|
|
extern void change_email(void);
|
2004-02-13 23:30:59 +01:00
|
|
|
extern int changepw(int dowrite);
|
2004-01-30 03:49:29 +01:00
|
|
|
extern void domailuser(char *username);
|
|
|
|
extern void drawmenu(void);
|
|
|
|
extern void freefile(void);
|
|
|
|
extern void initcurses(void);
|
2004-01-31 04:04:58 +01:00
|
|
|
extern void loginprompt(int from_ttyplay);
|
2004-01-30 03:49:29 +01:00
|
|
|
extern void newuser(void);
|
2004-06-12 02:11:18 +02:00
|
|
|
extern void autologin(char *user, char *pass);
|
2004-01-30 03:49:29 +01:00
|
|
|
extern int passwordgood(char *cpw);
|
|
|
|
extern int readfile(int nolock);
|
2007-12-27 20:52:48 +01:00
|
|
|
extern struct dg_user *userexist(char *cname, int isnew);
|
2007-03-29 22:14:55 +02:00
|
|
|
extern void write_canned_rcfile(int game, char *target);
|
|
|
|
extern void editoptions(int game);
|
2004-01-30 03:49:29 +01:00
|
|
|
extern void writefile(int requirenew);
|
|
|
|
extern void graceful_exit(int status);
|
2007-03-29 22:14:55 +02:00
|
|
|
extern int purge_stale_locks(int game);
|
|
|
|
extern int menuloop(void);
|
2004-02-22 10:37:15 +01:00
|
|
|
extern void ttyrec_getpty(void);
|
2004-02-22 06:57:36 +01:00
|
|
|
#if !defined(BSD) && !defined(__linux__)
|
|
|
|
extern int mysetenv (const char* name, const char* value, int overwrite);
|
|
|
|
#else
|
|
|
|
# define mysetenv setenv
|
|
|
|
#endif
|
2004-07-03 21:19:28 +02:00
|
|
|
#ifndef HAVE_SETPROCTITLE
|
|
|
|
void compat_init_setproctitle(int argc, char *argv[]);
|
|
|
|
void setproctitle(const char *fmt, ...);
|
|
|
|
#endif
|
2004-01-02 07:14:34 +01:00
|
|
|
|
2004-01-04 02:05:22 +01:00
|
|
|
/* strlcpy.c */
|
2004-01-04 03:19:12 +01:00
|
|
|
extern size_t strlcpy (char *dst, const char *src, size_t siz);
|
2004-01-04 08:35:14 +01:00
|
|
|
extern size_t strlcat (char *dst, const char *src, size_t siz);
|
2004-01-04 02:05:22 +01:00
|
|
|
|
2004-01-19 12:58:31 +01:00
|
|
|
/* mygetnstr.c */
|
|
|
|
extern int mygetnstr(char *buf, int maxlen, int doecho);
|
|
|
|
|
2003-12-30 22:30:32 +01:00
|
|
|
#endif
|