Metropoli BBS
VIEWER: lovfsfn.c MODE: TEXT (ASCII)
/*Copyright (C) 1992, 1995 by Thomas Glen Smith.  All Rights Reserved.*/
/* lovfsfn APL2 V1.0.0 *************************************************
* Called from apllov1 to read a function definition during a )load.    *
***********************************************************************/
#define INCLUDES APLCB+APLFUNCI+APLMEM+APLTOKEN+IO+STDIO+STRING
#include "includes.h"
Aplfunc lovfsfn(fp,flags)
int fp; /* file descriptor handle */
int flags; /* aplflags, already read by apllov_ */
{
	Execqfxa; Expunge; Lovfscb; Lovfsfp;
	Aplfunc func;
	int cbflags,iw,jw;
	int *ip;

	if (NULL == (func = execqfxa(NULL))) return(NULL); /* out of memory */
	func->funcflag = flags;
	iw = read(fp, &(func->functype), sizeof(int));
	iw = read(fp, &(func->functotl), sizeof(int));
	iw = read(fp, &(func->funcstmt), sizeof(int));
	if (NULL == (ip = malloc(jw = func->funcstmt * sizeof(int))))
		return(expunge(func)); /* free memory, return NULL */
	func->functokc = ip; /* Point to array to token counters. */
	iw = read(fp, func->functokc, jw); /* Read array of token counters. */
	iw = read(fp, &cbflags, sizeof(cbflags)); /* read aplflags */
	func->functext = lovfscb(fp,cbflags); /* read aplcb for text */
	jw = func->functotl * sizeof(struct apltoken);
	if (NULL == (func->functary = malloc(jw)) ||
	   (NULL == (func->functokp = malloc(
		func->funcstmt * sizeof(Apltoken)))))
		return(expunge(func)); /* free memory, return NULL */
	else
		return(lovfsfp(fp,func,jw)); /* finish reading function */
}
[ RETURN TO DIRECTORY ]