/*Copyright (C) 1992, 1994 by Thomas Glen Smith. All Rights Reserved.*/
/* aplgetc APL2 V1.0.0 *************************************************
* Called by gettcom to obtain input in the APL environment. *
***********************************************************************/
#define INCLUDES STDIO+APLMEM
#include "includes.h"
int aplgetc()
{
Aplgetch; Pop;
typedef struct aplfpq *Aplfpq;
struct aplfpq {
Aplfpq fpnxt; /* next on stack */
FILE *aplfp;
};
extern Aplfpq aplfphd; /* top of input stack */
Aplfpq top;
int ch;
while (aplfphd != NULL) {
if (EOF != (ch = fgetc(aplfphd->aplfp)))
return(ch);
top = pop(&aplfphd); /* pop top element from stack */
fclose(top->aplfp);
free(top);
}
return(aplgetch()); /* no redirection */
}