|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: G T
Length: 2079 (0x81f)
Types: TextFile
Names: »GB.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Gb/GB.c«
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* GB.c --
* main loop, prints instructions, grabs command line from
* standard output, executes command.
*/
#include "vars.h"
#include "races.h"
#include <curses.h>
#include <sys/stat.h>
struct stat buf;
#include <signal.h>
#include <strings.h>
#include <pwd.h>
struct passwd *passwd;
#include <setjmp.h>
jmp_buf main_jenv;
int God = 0;
extern char telegram_file[50];
main()
{
int notified=0,s,i;
char c,commstr[MAXCOMMSTRSIZE];
int maim_handler();
int maim_stardata;
setegid(PLAYER_GROUP_ID);
srandom(getpid());
initscr();
printf("Galactic Bloodshed ver %s\ntype 'help' for help.\n", VERS);
openstardata(&maim_stardata);
getsdata(maim_stardata,&Sdata);
for (s=0; s<Sdata.numstars; s++)
getstar(maim_stardata,&(Stars[s]),s);
close(maim_stardata);
passwd = getpwuid(geteuid());
if (!strcmp(passwd->pw_name, PLAYER_GOD)) {
God = 1;
printf("Login as what player? ");
scanf("%s",commstr);
getchr();
} else sprintf(commstr,"%s", getlogin() );
i = Getracenum(commstr);
if (!i) enroll(commstr);
else getrace(&Race,i);
Playernum = Race->Playernum;
if (God)
printf("Logging in as player %d.\n",Playernum);
docommand("cs"); /* chdir to home scope */
Dir.zoom = 1.0;
setjmp(main_jenv); /* set up environment for jump if error */
sprintf(telegram_file, "%s.%d", TELEGRAMFL, Playernum);
/* used in several routines, + each csh command */
do {
signal(SIGINT, maim_handler );
stat(telegram_file, &buf);
if (buf.st_size > notified) {
printf("\nYou have telegram(s) waiting.\n\n");
notified = buf.st_size;
}
printf("%s",Dir.prompt);
i = 0;
while ((c=getchr()) != '\n' && i<MAXCOMMSTRSIZE)
commstr[i++] = c;
commstr[i] = '\0';
if (*commstr==EOF) {
clearerr(stdin);
*commstr = '\0';
}
} while (docommand(commstr));
endwin();
/* printf("\nhalelujah!\n\n");*/
}
maim_handler(sig, code/*, scp*/)
int sig,code;
/*void *scp; /* supposed to be struct sigcontext */
{
putchar('\n');
longjmp(main_jenv,1);
}