Allow dumping the shared memory data with dgamelaunch -D
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@567 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
3f50414639
commit
ef9018dff1
|
@ -589,6 +589,41 @@ shm_init(struct dg_shm **shm_dg_data, struct dg_shm_game **shm_dg_game)
|
||||||
#endif /* USE_SHMEM */
|
#endif /* USE_SHMEM */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SHMEM
|
||||||
|
void
|
||||||
|
shm_dump()
|
||||||
|
{
|
||||||
|
struct dg_shm *shm_dg_data = NULL;
|
||||||
|
struct dg_shm_game *shm_dg_game = NULL;
|
||||||
|
int di, unused = -1;
|
||||||
|
shm_init(&shm_dg_data, &shm_dg_game);
|
||||||
|
shm_sem_wait(shm_dg_data);
|
||||||
|
for (di = 0; di < shm_dg_data->max_n_games; di++) {
|
||||||
|
if (shm_dg_game[di].in_use) {
|
||||||
|
if (unused != -1) {
|
||||||
|
if (unused != di-1)
|
||||||
|
fprintf(stderr, "%i-%i:\tunused\n", unused, di-1);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%i:\tunused\n", unused);
|
||||||
|
unused = -1;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%i:\t\"%s\"\twatchers:%li\n", di, shm_dg_game[di].ttyrec_fn, shm_dg_game[di].nwatchers);
|
||||||
|
} else {
|
||||||
|
if (unused == -1) unused = di;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (unused != -1) {
|
||||||
|
if (unused != di-1)
|
||||||
|
fprintf(stderr, "%i-%i:\tunused\n", unused, di-1);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%i:\tunused\n", unused);
|
||||||
|
unused = -1;
|
||||||
|
}
|
||||||
|
shm_sem_post(shm_dg_data);
|
||||||
|
shmdt(shm_dg_data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
inprogressmenu (int gameid)
|
inprogressmenu (int gameid)
|
||||||
{
|
{
|
||||||
|
@ -2278,7 +2313,7 @@ main (int argc, char** argv)
|
||||||
|
|
||||||
__progname = basename(strdup(argv[0]));
|
__progname = basename(strdup(argv[0]));
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "qh:pf:aeW:S")) != -1)
|
while ((c = getopt(argc, argv, "qh:pf:aeW:SD")) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
@ -2320,6 +2355,15 @@ main (int argc, char** argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'D': /* dump the shared memory block data */
|
||||||
|
#ifdef USE_SHMEM
|
||||||
|
shm_dump();
|
||||||
|
#else
|
||||||
|
if (!silent) fprintf(stderr, "warning: dgamelaunch was compiled without shmem.\n");
|
||||||
|
#endif
|
||||||
|
graceful_exit(0);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break; /*ignore */
|
break; /*ignore */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue