|
|
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 c
Length: 1809 (0x711)
Types: TextFile
Names: »class.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
└─⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/class.c«
#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
#include "sysdep.h"
#include "mem.h"
#include "lists.h"
#include "class.h"
extern struct list ClassList;
extern int sclasscmp();
long lseek();
static char cdesc[DESCSIZE+1], cname[SHORT_BUF], csize[SHORT_BUF];
static char cexp[SHORT_BUF];
struct class cs = { cname, 0, (time_t)0, cdesc };
int CS_FileDes = UNDEFINED;
setcsent()
{
if (CS_FileDes == UNDEFINED) {
CS_FileDes = open(CSFILE, O_RDONLY);
if (CS_FileDes < 0) {
perr(CSFILE);
goodbye(1);
}
}
lseek(CS_FileDes, (long) 0, L_SET)<0 &&
perr("setcsent: lseek failed?!");
return;
}
endcsent()
{
if (CS_FileDes == UNDEFINED)
return;
(void) close(CS_FileDes);
CS_FileDes = UNDEFINED;
return;
}
struct class *
getcsent()
{
register int i;
char c;
if (CS_FileDes == UNDEFINED)
setcsent();
#ifdef SENDMAIL
zerolist(&cs.cs_aliases);
#endif
i = 0;
while (read(CS_FileDes, &c, 1) != 0) {
c &= 0177;
if (c == ' ')
break;
cname[i++] = c;
}
if (i == 0)
return(0);
cname[i] = '\0';
i = 0;
while (read(CS_FileDes, &c, 1) != 0) {
c &= 0177;
if (c == ' ')
break;
csize[i++] = c;
}
csize[i] = '\0';
i = 0;
while (read(CS_FileDes, &c, 1) != 0) {
c &= 0177;
if (c == '\n')
break;
cexp[i++] = c;
}
if (i == 0)
return(0);
cexp[i] = '\0';
/* result of intermediate assignment used in read() to stifle lint */
cs.cs_dsize = i = atoi(csize);
cs.cs_exptime = atoi(cexp);
if (read(CS_FileDes, cs.cs_desc, i) != cs.cs_dsize)
fatal1("%s: bad file format", CSFILE);
cs.cs_desc[cs.cs_dsize] = '\0';
return(&cs);
}
struct class *
getcsnam(name)
char *name;
{
int indx, found;
indx = search_list(&ClassList, name, sclasscmp, &found);
if (found)
return (struct class *) ClassList.l_list[indx];
return (struct class *) 0;
}