mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
Add src/theme/xbm/parse.c
This commit is contained in:
parent
d80a7b518f
commit
f86394a997
7 changed files with 125 additions and 13 deletions
1
tools/xbm/.gitignore
vendored
1
tools/xbm/.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
xbm-tokenize
|
||||
xbm-parse
|
||||
|
|
|
|||
|
|
@ -3,13 +3,17 @@ CFLAGS += -I../../include
|
|||
LDFLAGS += `pkg-config --cflags --libs cairo`
|
||||
ASAN += -fsanitize=address
|
||||
|
||||
PROGS = xbm-tokenize
|
||||
PROGS = xbm-tokenize xbm-parse
|
||||
DEP_TOKENIZE = ../../src/common/buf.c ../../src/theme/xbm/tokenize.c
|
||||
DEP_PARSE = $(DEP_TOKENIZE) ../../src/theme/xbm/parse.c
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
xbm-tokenize: xbm-tokenize.c $(DEP_TOKENIZE)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(ASAN)
|
||||
|
||||
xbm-parse: xbm-parse.c $(DEP_PARSE)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(ASAN)
|
||||
|
||||
clean :
|
||||
$(RM) $(PROGS)
|
||||
|
|
|
|||
23
tools/xbm/xbm-parse.c
Normal file
23
tools/xbm/xbm-parse.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "xbm.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct token *tokens;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s <xbm-file>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *buffer = xbm_read_file(argv[1]);
|
||||
if (!buffer)
|
||||
exit(EXIT_FAILURE);
|
||||
tokens = xbm_tokenize(buffer);
|
||||
free(buffer);
|
||||
|
||||
xbm_create_bitmap(tokens);
|
||||
free(tokens);
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ int main(int argc, char **argv)
|
|||
char *buffer = read_file(argv[1]);
|
||||
if (!buffer)
|
||||
exit(EXIT_FAILURE);
|
||||
tokens = tokenize(buffer);
|
||||
tokens = xbm_tokenize(buffer);
|
||||
free(buffer);
|
||||
for (struct token *t = tokens; t->type; t++)
|
||||
printf("%s\n", t->name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue