2011-08-07 00:18:26 +04:00
|
|
|
/* $NetBSD: hack.engrave.c,v 1.11 2011/08/06 20:18:26 dholland Exp $ */
|
1997-10-19 20:56:41 +04:00
|
|
|
|
1993-08-02 21:16:36 +04:00
|
|
|
/*
|
2003-04-02 22:36:33 +04:00
|
|
|
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
|
|
|
* Amsterdam
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of the Stichting Centrum voor Wiskunde en
|
|
|
|
* Informatica, nor the names of its contributors may be used to endorse or
|
|
|
|
* promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
|
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
|
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1993-08-02 21:16:36 +04:00
|
|
|
*/
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-08-02 21:16:36 +04:00
|
|
|
#ifndef lint
|
2011-08-07 00:18:26 +04:00
|
|
|
__RCSID("$NetBSD: hack.engrave.c,v 1.11 2011/08/06 20:18:26 dholland Exp $");
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "hack.h"
|
|
|
|
#include "extern.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
struct engr {
|
1997-10-19 20:56:41 +04:00
|
|
|
struct engr *nxt_engr;
|
|
|
|
char *engr_txt;
|
|
|
|
xchar engr_x, engr_y;
|
|
|
|
unsigned engr_lth; /* for save & restore; not length of
|
|
|
|
* text */
|
|
|
|
long engr_time; /* moment engraving was (will be)
|
|
|
|
* finished */
|
|
|
|
xchar engr_type;
|
1993-03-21 12:45:37 +03:00
|
|
|
#define DUST 1
|
|
|
|
#define ENGRAVE 2
|
|
|
|
#define BURN 3
|
2009-08-12 11:28:40 +04:00
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static struct engr *head_engr;
|
|
|
|
|
|
|
|
static void del_engr(struct engr *);
|
|
|
|
|
|
|
|
static struct engr *
|
2009-06-07 22:30:39 +04:00
|
|
|
engr_at(xchar x, xchar y)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ep = head_engr;
|
|
|
|
while (ep) {
|
|
|
|
if (x == ep->engr_x && y == ep->engr_y)
|
|
|
|
return (ep);
|
1993-03-21 12:45:37 +03:00
|
|
|
ep = ep->nxt_engr;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
return ((struct engr *) 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
2009-06-07 22:30:39 +04:00
|
|
|
sengr_at(const char *s, xchar x, xchar y)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ep = engr_at(x, y);
|
|
|
|
char *t;
|
|
|
|
int n;
|
|
|
|
if (ep && ep->engr_time <= moves) {
|
1993-03-21 12:45:37 +03:00
|
|
|
t = ep->engr_txt;
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
if(!strcmp(s,t)) return(1);
|
|
|
|
*/
|
1993-03-21 12:45:37 +03:00
|
|
|
n = strlen(s);
|
1997-10-19 20:56:41 +04:00
|
|
|
while (*t) {
|
|
|
|
if (!strncmp(s, t, n))
|
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
t++;
|
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
u_wipe_engr(int cnt)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!u.uswallow && !Levitation)
|
1993-03-21 12:45:37 +03:00
|
|
|
wipe_engr_at(u.ux, u.uy, cnt);
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
wipe_engr_at(xchar x, xchar y, xchar cnt)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ep = engr_at(x, y);
|
|
|
|
int lth, pos;
|
|
|
|
char ch;
|
|
|
|
if (ep) {
|
|
|
|
if ((ep->engr_type != DUST) || Levitation) {
|
|
|
|
cnt = rn2(1 + 50 / (cnt + 1)) ? 0 : 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
lth = strlen(ep->engr_txt);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (lth && cnt > 0) {
|
|
|
|
while (cnt--) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pos = rn2(lth);
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((ch = ep->engr_txt[pos]) == ' ')
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
|
|
|
ep->engr_txt[pos] = (ch != '?') ? '?' : ' ';
|
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
while (lth && ep->engr_txt[lth - 1] == ' ')
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->engr_txt[--lth] = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
while (ep->engr_txt[0] == ' ')
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->engr_txt++;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!ep->engr_txt[0])
|
|
|
|
del_engr(ep);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
read_engr_at(int x, int y)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ep = engr_at(x, y);
|
|
|
|
if (ep && ep->engr_txt[0]) {
|
|
|
|
switch (ep->engr_type) {
|
|
|
|
case DUST:
|
|
|
|
pline("Something is written here in the dust.");
|
|
|
|
break;
|
|
|
|
case ENGRAVE:
|
|
|
|
pline("Something is engraved here on the floor.");
|
|
|
|
break;
|
|
|
|
case BURN:
|
|
|
|
pline("Some text has been burned here in the floor.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
impossible("Something is written in a very strange way.");
|
|
|
|
}
|
|
|
|
pline("You read: \"%s\".", ep->engr_txt);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
make_engr_at(int x, int y, const char *s)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct engr *ep;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((ep = engr_at(x, y)) != NULL)
|
|
|
|
del_engr(ep);
|
2011-08-07 00:18:26 +04:00
|
|
|
ep = alloc(sizeof(*ep) + strlen(s) + 1);
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->nxt_engr = head_engr;
|
|
|
|
head_engr = ep;
|
|
|
|
ep->engr_x = x;
|
|
|
|
ep->engr_y = y;
|
1997-10-19 20:56:41 +04:00
|
|
|
ep->engr_txt = (char *) (ep + 1);
|
1993-03-21 12:45:37 +03:00
|
|
|
(void) strcpy(ep->engr_txt, s);
|
|
|
|
ep->engr_time = 0;
|
|
|
|
ep->engr_type = DUST;
|
|
|
|
ep->engr_lth = strlen(s) + 1;
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
2009-06-07 22:30:39 +04:00
|
|
|
doengrave(void)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *sp;
|
|
|
|
struct engr *ep, *oep = engr_at(u.ux, u.uy);
|
|
|
|
char buf[BUFSZ];
|
|
|
|
xchar type;
|
|
|
|
int spct; /* number of leading spaces */
|
|
|
|
struct obj *otmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
multi = 0;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uswallow) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("You're joking. Hahaha!"); /* riv05!a3 */
|
1997-10-19 20:56:41 +04:00
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* one may write with finger, weapon or wand */
|
|
|
|
otmp = getobj("#-)/", "write with");
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!otmp)
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (otmp == &zeroobj)
|
1993-03-21 12:45:37 +03:00
|
|
|
otmp = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (otmp && otmp->otyp == WAN_FIRE && otmp->spe) {
|
1993-03-21 12:45:37 +03:00
|
|
|
type = BURN;
|
|
|
|
otmp->spe--;
|
|
|
|
} else {
|
|
|
|
/* first wield otmp */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (otmp != uwep) {
|
|
|
|
if (uwep && uwep->cursed) {
|
|
|
|
/* Andreas Bormann */
|
|
|
|
pline("Since your weapon is welded to your hand,");
|
|
|
|
pline("you use the %s.", aobjnam(uwep, (char *) 0));
|
|
|
|
otmp = uwep;
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!otmp)
|
|
|
|
pline("You are now empty-handed.");
|
|
|
|
else if (otmp->cursed)
|
|
|
|
pline("The %s %s to your hand!",
|
|
|
|
aobjnam(otmp, "weld"),
|
|
|
|
(otmp->quan == 1) ? "itself" : "themselves");
|
|
|
|
else
|
|
|
|
pline("You now wield %s.", doname(otmp));
|
|
|
|
setuwep(otmp);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!otmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
type = DUST;
|
1997-10-19 20:56:41 +04:00
|
|
|
else if (otmp->otyp == DAGGER || otmp->otyp == TWO_HANDED_SWORD ||
|
|
|
|
otmp->otyp == CRYSKNIFE ||
|
|
|
|
otmp->otyp == LONG_SWORD || otmp->otyp == AXE) {
|
1993-03-21 12:45:37 +03:00
|
|
|
type = ENGRAVE;
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((int) otmp->spe <= -3) {
|
1993-03-21 12:45:37 +03:00
|
|
|
type = DUST;
|
|
|
|
pline("Your %s too dull for engraving.",
|
1997-10-19 20:56:41 +04:00
|
|
|
aobjnam(otmp, "are"));
|
|
|
|
if (oep && oep->engr_type != DUST)
|
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
} else
|
|
|
|
type = DUST;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Levitation && type != BURN) { /* riv05!a3 */
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("You can't reach the floor!");
|
1997-10-19 20:56:41 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (oep && oep->engr_type == DUST) {
|
|
|
|
pline("You wipe out the message that was written here.");
|
|
|
|
del_engr(oep);
|
|
|
|
oep = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (type == DUST && oep) {
|
|
|
|
pline("You cannot wipe out the message that is %s in the rock.",
|
|
|
|
(oep->engr_type == BURN) ? "burned" : "engraved");
|
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
pline("What do you want to %s on the floor here? ",
|
1997-10-19 20:56:41 +04:00
|
|
|
(type == ENGRAVE) ? "engrave" : (type == BURN) ? "burn" : "write");
|
1993-03-21 12:45:37 +03:00
|
|
|
getlin(buf);
|
|
|
|
clrlin();
|
|
|
|
spct = 0;
|
|
|
|
sp = buf;
|
1997-10-19 20:56:41 +04:00
|
|
|
while (*sp == ' ')
|
|
|
|
spct++, sp++;
|
1993-03-21 12:45:37 +03:00
|
|
|
len = strlen(sp);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!len || *buf == '\033') {
|
|
|
|
if (type == BURN)
|
|
|
|
otmp->spe++;
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (type) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case DUST:
|
|
|
|
case BURN:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (len > 15) {
|
|
|
|
multi = -(len / 10);
|
1993-03-21 12:45:37 +03:00
|
|
|
nomovemsg = "You finished writing.";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ENGRAVE: /* here otmp != 0 */
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
int len2 = (otmp->spe + 3) * 2 + 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
pline("Your %s dull.", aobjnam(otmp, "get"));
|
1997-10-19 20:56:41 +04:00
|
|
|
if (len2 < len) {
|
1993-03-21 12:45:37 +03:00
|
|
|
len = len2;
|
|
|
|
sp[len] = 0;
|
|
|
|
otmp->spe = -3;
|
|
|
|
nomovemsg = "You cannot engrave more.";
|
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
otmp->spe -= len / 2;
|
1993-03-21 12:45:37 +03:00
|
|
|
nomovemsg = "You finished engraving.";
|
|
|
|
}
|
|
|
|
multi = -len;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (oep)
|
|
|
|
len += strlen(oep->engr_txt) + spct;
|
2011-08-07 00:18:26 +04:00
|
|
|
ep = alloc(sizeof(*ep) + len + 1);
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->nxt_engr = head_engr;
|
|
|
|
head_engr = ep;
|
|
|
|
ep->engr_x = u.ux;
|
|
|
|
ep->engr_y = u.uy;
|
1997-10-19 20:56:41 +04:00
|
|
|
sp = (char *) (ep + 1); /* (char *)ep + sizeof(struct engr) */
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->engr_txt = sp;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (oep) {
|
1993-03-21 12:45:37 +03:00
|
|
|
(void) strcpy(sp, oep->engr_txt);
|
|
|
|
(void) strcat(sp, buf);
|
|
|
|
del_engr(oep);
|
|
|
|
} else
|
|
|
|
(void) strcpy(sp, buf);
|
1997-10-19 20:56:41 +04:00
|
|
|
ep->engr_lth = len + 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->engr_type = type;
|
1997-10-19 20:56:41 +04:00
|
|
|
ep->engr_time = moves - multi;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* kludge to protect pline against excessively long texts */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (len > BUFSZ - 20)
|
|
|
|
sp[BUFSZ - 20] = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
save_engravings(int fd)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ep = head_engr;
|
|
|
|
while (ep) {
|
|
|
|
if (!ep->engr_lth || !ep->engr_txt[0]) {
|
1993-03-21 12:45:37 +03:00
|
|
|
ep = ep->nxt_engr;
|
|
|
|
continue;
|
|
|
|
}
|
2009-06-08 00:25:38 +04:00
|
|
|
bwrite(fd, &(ep->engr_lth), sizeof(ep->engr_lth));
|
|
|
|
bwrite(fd, ep, sizeof(struct engr) + ep->engr_lth);
|
1993-03-21 12:45:37 +03:00
|
|
|
ep = ep->nxt_engr;
|
|
|
|
}
|
2009-06-08 00:25:38 +04:00
|
|
|
bwrite(fd, nul, sizeof(unsigned));
|
1993-03-21 12:45:37 +03:00
|
|
|
head_engr = 0;
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
rest_engravings(int fd)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ep;
|
|
|
|
unsigned lth;
|
1993-03-21 12:45:37 +03:00
|
|
|
head_engr = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
while (1) {
|
2011-08-07 00:00:33 +04:00
|
|
|
mread(fd, <h, sizeof(unsigned));
|
1997-10-19 20:56:41 +04:00
|
|
|
if (lth == 0)
|
|
|
|
return;
|
2011-08-07 00:18:26 +04:00
|
|
|
ep = alloc(sizeof(*ep) + lth);
|
|
|
|
mread(fd, ep, sizeof(*ep) + lth);
|
1993-03-21 12:45:37 +03:00
|
|
|
ep->nxt_engr = head_engr;
|
|
|
|
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
|
|
|
|
head_engr = ep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static void
|
2009-06-07 22:30:39 +04:00
|
|
|
del_engr(struct engr *ep)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct engr *ept;
|
|
|
|
if (ep == head_engr)
|
1993-03-21 12:45:37 +03:00
|
|
|
head_engr = ep->nxt_engr;
|
|
|
|
else {
|
1997-10-19 20:56:41 +04:00
|
|
|
for (ept = head_engr; ept; ept = ept->nxt_engr) {
|
|
|
|
if (ept->nxt_engr == ep) {
|
1993-03-21 12:45:37 +03:00
|
|
|
ept->nxt_engr = ep->nxt_engr;
|
|
|
|
goto fnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impossible("Error in del_engr?");
|
|
|
|
return;
|
1997-10-19 20:56:41 +04:00
|
|
|
fnd: ;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
free((char *) ep);
|
|
|
|
}
|