printf working

This commit is contained in:
Neale Pickett 2011-10-14 22:10:25 -06:00
parent e42da095d1
commit dc3474df0f
4 changed files with 31 additions and 8 deletions

View File

@ -7,6 +7,7 @@ printf-install: printf-build
$(MAKE) -C packages/printf/src install DESTDIR=$(CURDIR)/$(PRINTF_PKGDIR)
$(call COPYTREE, packages/printf/service, $(PRINTF_PKGDIR)/service)
cp packages/printf/tokens.txt $(PRINTF_PKGDIR)/
printf-clean:
rm -rf $(PRINTF_PKGDIR)

View File

@ -1,3 +1,3 @@
#! /bin/sh
exec chpst -u 9001 -/ /opt/printf/bin ./printf
exec chpst -u 9001 -/ /opt/printf/bin ./printf 3</opt/printf/tokens.txt

View File

@ -19,13 +19,7 @@ record(char *buf) {
}
/* Storage space for tokens */
char *token[5] = {
"printf:xylep-radar-nanox",
"printf:xylep-radar-nanox",
"printf:xylep-radar-nanox",
"printf:xylep-radar-nanox",
"printf:xylep-radar-nanox"
};
char token[5][100];
/* Make this global so the stack isn't gigantic */
char global_fmt[8000] = {0};
@ -41,6 +35,29 @@ main(int argc, char *argv[], char *env[])
int token4_flag = 0;
int i;
/* Read in tokens */
{
FILE *tf = fdopen(3, "r");
if (! tf) {
fprintf(stderr, "No tokens on fd3\n");
return 1;
}
for (i = 0; i < 5; i += 1) {
char *p = fgets(token[i], sizeof(token[i]), tf);
if (! p) {
fprintf(stderr, "Cannot read token %d\n", i);
return 1;
}
/* Replace newline with null */
for (; *p && (*p != '\n'); p += 1);
*p = 0;
}
}
/* Make stderr buffer until lines */
setlinebuf(stderr);

View File

@ -0,0 +1,5 @@
net:xenid-divik-vyhux
net:xodib-recop-zycux
net:xugep-zanuc-fetux
net:ximac-pucaz-zonox
net:xetab-kozyl-megex