figlet/figlet.c
2023-03-11 22:52:14 +01:00

65 lines
1.2 KiB
C

#include "FIGlib.h"
/****************************************************************************
main
The main program, of course.
Reads characters 1 by 1 from stdin, and makes lines out of them using
addchar. Handles line breaking, (which accounts for most of the
complexity in this function).
****************************************************************************/
int main(argc,argv)
int argc;
char *argv[];
{
inchr c,c2;
int i;
int last_was_eol_flag;
Myargc = argc;
Myargv = argv;
getparams();
readcontrolfiles();
readfont();
linealloc();
last_was_eol_flag = 0;
#ifdef TLF_FONTS
toiletfont = 0;
#endif
while ((c = getinchr())!=EOF) {
if (c=='\n'&&paragraphflag&&!last_was_eol_flag) {
ungetinchr(c2 = getinchr());
c = ((isascii(c2)&&isspace(c2))?'\n':' ');
}
last_was_eol_flag = (isascii(c)&&isspace(c)&&c!='\t'&&c!=' ');
if (deutschflag) {
if (c>='[' && c<=']') {
c = deutsch[c-'['];
}
else if (c >='{' && c <= '~') {
c = deutsch[c-'{'+3];
}
}
c = handlemapping(c);
if (isascii(c)&&isspace(c)) {
c = (c=='\t'||c==' ') ? ' ' : '\n';
}
if ((c>'\0' && c<' ' && c!='\n') || c==127) continue;
f(c);
}
return 0;
}