working demo
This commit is contained in:
parent
43d1c4a1ce
commit
fd8bdecb53
BIN
FIGlib-test
Executable file
BIN
FIGlib-test
Executable file
Binary file not shown.
69
FIGlib.h
69
FIGlib.h
@ -54,7 +54,7 @@
|
|||||||
#define DEFAULTFONTDIR "fonts"
|
#define DEFAULTFONTDIR "fonts"
|
||||||
#endif
|
#endif
|
||||||
#ifndef DEFAULTFONTFILE
|
#ifndef DEFAULTFONTFILE
|
||||||
#define DEFAULTFONTFILE "standard.flf"
|
#define DEFAULTFONTFILE "standard"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -927,32 +927,11 @@ void getparams()
|
|||||||
int columns,infoprint;
|
int columns,infoprint;
|
||||||
char *controlname,*env;
|
char *controlname,*env;
|
||||||
|
|
||||||
if ((myname = strrchr(Myargv[0],DIRSEP))!=NULL) {
|
|
||||||
myname++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
myname = Myargv[0];
|
|
||||||
}
|
|
||||||
fontdirname = DEFAULTFONTDIR;
|
|
||||||
env = getenv("FIGLET_FONTDIR");
|
env = getenv("FIGLET_FONTDIR");
|
||||||
if (env!=NULL) {
|
if (env!=NULL) {
|
||||||
fontdirname = env;
|
fontdirname = env;
|
||||||
}
|
}
|
||||||
fontname = DEFAULTFONTFILE;
|
|
||||||
cfilelist = NULL;
|
|
||||||
cfilelistend = &cfilelist;
|
|
||||||
commandlist = NULL;
|
|
||||||
commandlistend = &commandlist;
|
|
||||||
smushoverride = SMO_NO;
|
|
||||||
deutschflag = 0;
|
|
||||||
justification = -1;
|
|
||||||
right2left = -1;
|
|
||||||
paragraphflag = 0;
|
|
||||||
infoprint = -1;
|
infoprint = -1;
|
||||||
cmdinput = 0;
|
|
||||||
outputwidth = DEFAULTCOLUMNS;
|
|
||||||
gn[1] = 0x80;
|
|
||||||
gr = 1;
|
|
||||||
while ((c = getopt(Myargc,Myargv,"ADEXLRI:xlcrpntvm:w:d:f:C:NFskSWo"))!= -1) {
|
while ((c = getopt(Myargc,Myargv,"ADEXLRI:xlcrpntvm:w:d:f:C:NFskSWo"))!= -1) {
|
||||||
/* Note: -F is not a legal option -- prints a special err message. */
|
/* Note: -F is not a legal option -- prints a special err message. */
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -1100,7 +1079,6 @@ void getparams()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (optind!=Myargc) cmdinput = 1; /* force cmdinput if more arguments */
|
if (optind!=Myargc) cmdinput = 1; /* force cmdinput if more arguments */
|
||||||
outlinelenlimit = outputwidth-1;
|
|
||||||
if (infoprint>=0) {
|
if (infoprint>=0) {
|
||||||
printinfo(infoprint);
|
printinfo(infoprint);
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -2000,12 +1978,43 @@ inchr getinchr()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fig_init(argc, argv)
|
||||||
|
int argc;
|
||||||
|
char** argv;
|
||||||
|
{
|
||||||
|
Myargc = argc;
|
||||||
|
Myargv = argv;
|
||||||
|
|
||||||
|
if ((myname = strrchr(Myargv[0],DIRSEP))!=NULL) {
|
||||||
|
myname++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myname = Myargv[0];
|
||||||
|
}
|
||||||
|
fontdirname = DEFAULTFONTDIR;
|
||||||
|
fontname = DEFAULTFONTFILE;
|
||||||
|
cfilelist = NULL;
|
||||||
|
cfilelistend = &cfilelist;
|
||||||
|
commandlist = NULL;
|
||||||
|
commandlistend = &commandlist;
|
||||||
|
smushoverride = SMO_NO;
|
||||||
|
deutschflag = 0;
|
||||||
|
justification = -1;
|
||||||
|
right2left = -1;
|
||||||
|
paragraphflag = 0;
|
||||||
|
cmdinput = 0;
|
||||||
|
outputwidth = DEFAULTCOLUMNS;
|
||||||
|
gn[1] = 0x80;
|
||||||
|
gr = 1;
|
||||||
|
outlinelenlimit = outputwidth-1;
|
||||||
|
}
|
||||||
|
|
||||||
void f(c)
|
void f(c)
|
||||||
inchr c;
|
const inchr c;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int char_not_added;
|
int char_not_added;
|
||||||
int wordbreakmode = 0;
|
static int wordbreakmode = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char_not_added = 0;
|
char_not_added = 0;
|
||||||
@ -2069,8 +2078,14 @@ inchr c;
|
|||||||
}
|
}
|
||||||
|
|
||||||
} while (char_not_added);
|
} while (char_not_added);
|
||||||
|
}
|
||||||
|
|
||||||
if (outlinelen!=0) {
|
void fs(string)
|
||||||
printline();
|
char* string;
|
||||||
|
{
|
||||||
|
char* str_ptr = string;
|
||||||
|
while(*str_ptr!=0){
|
||||||
|
f(*str_ptr);
|
||||||
|
++str_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
Makefile
8
Makefile
@ -54,7 +54,8 @@ DEFAULTFONTFILE = standard
|
|||||||
|
|
||||||
VERSION = 2.2.5
|
VERSION = 2.2.5
|
||||||
DIST = figlet-$(VERSION)
|
DIST = figlet-$(VERSION)
|
||||||
OBJS = figlet.o zipio.o crc.o inflate.o utf8.o
|
LIBOBJS = zipio.o crc.o inflate.o utf8.o
|
||||||
|
OBJS = $(LIBOBJS) figlet.o
|
||||||
BINS = figlet chkfont figlist showfigfonts
|
BINS = figlet chkfont figlist showfigfonts
|
||||||
MANUAL = figlet.6 chkfont.6 figlist.6 showfigfonts.6
|
MANUAL = figlet.6 chkfont.6 figlist.6 showfigfonts.6
|
||||||
DFILES = Makefile Makefile.tc $(MANUAL) $(OBJS:.o=.c) chkfont.c getopt.c \
|
DFILES = Makefile Makefile.tc $(MANUAL) $(OBJS:.o=.c) chkfont.c getopt.c \
|
||||||
@ -70,6 +71,11 @@ all: $(BINS)
|
|||||||
figlet: $(OBJS)
|
figlet: $(OBJS)
|
||||||
$(LD) $(LDFLAGS) -o $@ $(OBJS)
|
$(LD) $(LDFLAGS) -o $@ $(OBJS)
|
||||||
|
|
||||||
|
figlib: $(LIBOBJS)
|
||||||
|
$(CC) -shared -o libfiglib.so $(LIBOBJS)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) -I /home/anon/Swap/figlet/ -L /home/anon/Swap/figlet/ \
|
||||||
|
tests/FIGlib.c -o FIGlib-test -lfiglib
|
||||||
|
|
||||||
chkfont: chkfont.o
|
chkfont: chkfont.o
|
||||||
$(LD) $(LDFLAGS) -o $@ chkfont.o
|
$(LD) $(LDFLAGS) -o $@ chkfont.o
|
||||||
|
|
||||||
|
10
figlet.c
10
figlet.c
@ -16,11 +16,9 @@ int argc;
|
|||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
inchr c,c2;
|
inchr c,c2;
|
||||||
int i;
|
|
||||||
int last_was_eol_flag;
|
int last_was_eol_flag;
|
||||||
|
|
||||||
Myargc = argc;
|
fig_init(argc, argv);
|
||||||
Myargv = argv;
|
|
||||||
getparams();
|
getparams();
|
||||||
readcontrolfiles();
|
readcontrolfiles();
|
||||||
readfont();
|
readfont();
|
||||||
@ -58,7 +56,11 @@ char *argv[];
|
|||||||
if ((c>'\0' && c<' ' && c!='\n') || c==127) continue;
|
if ((c>'\0' && c<' ' && c!='\n') || c==127) continue;
|
||||||
|
|
||||||
f(c);
|
f(c);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outlinelen!=0) {
|
||||||
|
printline();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
BIN
libfiglib.so
Executable file
BIN
libfiglib.so
Executable file
Binary file not shown.
@ -7,8 +7,14 @@ char *argv[];
|
|||||||
{
|
{
|
||||||
//fontinfo fi;
|
//fontinfo fi;
|
||||||
//readfont(&fi);
|
//readfont(&fi);
|
||||||
|
fig_init();
|
||||||
|
fontdirname = "fonts/";
|
||||||
|
readcontrolfiles();
|
||||||
readfont();
|
readfont();
|
||||||
inchrline = "test";
|
linealloc();
|
||||||
|
fs("Hello ");
|
||||||
|
fs("World!");
|
||||||
|
printline();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user