-/* $OpenBSD: crunchgen.c,v 1.12 2013/11/23 22:51:41 deraadt Exp $ */
+/* $OpenBSD: crunchgen.c,v 1.13 2014/01/11 04:44:15 deraadt Exp $ */
/*
* Copyright (c) 1994 University of Maryland
#include <sys/stat.h>
#include <sys/param.h>
-#define CRUNCH_VERSION "0.3"
+#define CRUNCH_VERSION "1.3"
#define MAXLINELEN 16384
#define MAXFIELDS 2048
int verbose = 1, readcache = 1, elf_names, elf_mangle; /* options */
int reading_cache;
-void status(char *str);
void out_of_memory(void);
void add_string(strlst_t ** listp, char *str);
int is_dir(char *pathname);
void (*f) (int c, char **v);
FILE *cf;
- snprintf(line, sizeof(line), "reading %s", filename);
- status(line);
strlcpy(curfilename, filename, sizeof curfilename);
if ((cf = fopen(curfilename, "r")) == NULL) {
gen_specials_cache();
gen_output_cfile();
gen_output_makefile();
- status("");
- fprintf(stderr,
- "Run \"make -f %s objs exe\" to build crunched binary.\n",
- outmkname);
}
void
strlst_t *s;
int i;
- snprintf(line, sizeof(line), "filling in parms for %s", p->name);
- status(line);
-
if (!p->ident)
p->ident = genident(p->name);
if (!p->srcdir) {
FILE *cachef;
prog_t *p;
- snprintf(line, sizeof(line), "generating %s", cachename);
- status(line);
-
if ((cachef = fopen(cachename, "w")) == NULL) {
perror(cachename);
goterror = 1;
prog_t *p;
FILE *outmk;
- snprintf(line, sizeof(line), "generating %s", outmkname);
- status(line);
-
if ((outmk = fopen(outmkname, "w")) == NULL) {
perror(outmkname);
goterror = 1;
prog_t *p;
strlst_t *s;
- snprintf(line, sizeof(line), "generating %s", outcfname);
- status(line);
-
if ((outcf = fopen(outcfname, "w")) == NULL) {
perror(outcfname);
goterror = 1;
output_strlst(outmk, p->objpaths);
fprintf(outmk, "%s_stub.c:\n", p->name);
- fprintf(outmk, "\techo \""
+ fprintf(outmk, "\t@echo \""
"int _crunched_%s_stub(int argc, char **argv, char **envp)"
- "{return main(argc,argv,envp);}\" >$@\n",
+ " { return main(argc, argv, envp); }\" >$@\n",
p->ident);
fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)\n",
p->name, p->name, p->ident);
fprintf(outf, "\n");
}
-void
-status(char *str)
-{
- static int lastlen = 0;
- int len, spaces;
-
- if (!verbose)
- return;
-
- len = strlen(str);
- spaces = lastlen - len;
- if (spaces < 1)
- spaces = 1;
-
- fprintf(stderr, " [%s]%*.*s\r", str, spaces, spaces, " ");
- fflush(stderr);
- lastlen = len;
-}
-
void
out_of_memory(void)
{