|
|
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: T t
Length: 2602 (0xa2a)
Types: TextFile
Names: »telegram.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Gb/telegram.c«
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* telegram.c -- send a telegram to user
*/
#include "vars.h"
#include "races.h"
#include "ships.h"
#include <ctype.h>
#include <signal.h>
#include <strings.h>
#include <setjmp.h>
extern jmp_buf main_jenv;
extern char telegram_buf[AUTO_TELEG_SIZE];
telegram(APcount, argn,args)
int APcount;
int argn;
char args[MAXARGS][COMMANDSIZE];
{
racetype *alien;
placetype where;
planettype *pl;
int c,i,numraces,recp = -1;
bool Place = 0;
char telefl[50], tbuf[200], tmbuf[40], r[RNAMESIZE];
int telegram_pdata,telegram_handler();
signal(SIGINT, telegram_handler);
if (!enufAP(Sdata.AP,APcount) && Dir.level!=LEVEL_UNIV
&& !enufAP(Stars[Dir.snum]->AP,APcount) )
telegram_handler();
if (argn<2) { /* recipient not specified */
printf("To whom/where? ");
scanf("%[^\n]",r);
getchr();
} else
strncpy(r,args[1],RNAMESIZE);
if (r[0] == '/' || r[0]=='#' || r[0]=='.' || r[0]==CHAR_CURR_SCOPE) {
Place = 1;
where = Getplace(r,1);
if (where.err)
telegram_handler();
} else {
GetPlayer(r, &recp, &alien);
if ( recp == -1) {
printf("Player does not exist.\n");
telegram_handler();
}
}
printf("Enter telegram for %s,\n ending with ctrl-D.\n\n",
Place ? Dispplace(&where) : alien->name );
printf("Subject : ");
teleg_add("", telegram_buf);
if (Place) {
sprintf(tbuf, "Message received at %s%s.\n",
where.level==LEVEL_SHIP ? "ship " : "", Dispplace(&where) );
teleg_add(tbuf, telegram_buf);
}
i = 0;
while ( (c=getchr()) != EOF) {
ungetc(c,stdin);
scanf("%199[^\n]", tbuf);
getchr();
i += strlen(tbuf);
teleg_add(tbuf, telegram_buf);
printf("%d : ",TELEGRAM_SIZE - i );
}
/* send it */
if (!Place)
teleg_send(Playernum, recp, telegram_buf);
else
switch (where.level) {
case LEVEL_STAR:
for (i=1; i<MAXPLAYERS; i++)
if (isset(Stars[where.snum]->inhabited,i))
teleg_send(Playernum, i, telegram_buf);
break;
case LEVEL_PLAN:
openpdata(&telegram_pdata);
getplanet(telegram_pdata, &pl, Stars[where.snum]->planetpos[where.pnum]);
close(telegram_pdata);
for (i=1; i<MAXPLAYERS; i++)
if (pl->info[i-1].numsectsowned)
teleg_send(Playernum, i, telegram_buf);
break;
case LEVEL_SHIP:
teleg_send(Playernum, where.shipptr->owner, telegram_buf);
break;
case LEVEL_UNIV:
printf("We're sorry, no one is there to receive your call.\n");
break;
}
/* get rid of ctrl-D problem */
clearerr(stdin);
printf("\nMessage delivered.\n");
}
telegram_handler(sig, code, scp)
{
longjmp(main_jenv,1);
}