diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-05-30 12:42:22 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-05-30 16:01:58 +0200 |
commit | 880149f48e58ac93697fd19a90df6b31a2242659 (patch) | |
tree | 6c12d99d5b445d003a85dc4ecad8541361a5b867 | |
parent | cff6f809da556624fb1de34725935278093182e1 (diff) | |
download | mupdf-880149f48e58ac93697fd19a90df6b31a2242659.tar.xz |
Generate C-includable version of Adobe CA certificate
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | certs/AdobeCA.p7c | bin | 0 -> 1236 bytes | |||
-rw-r--r-- | scripts/bin2hex.c | 100 | ||||
-rw-r--r-- | win32/generate.bat | 6 | ||||
-rw-r--r-- | win32/generated.vcproj | 4 |
5 files changed, 118 insertions, 2 deletions
@@ -133,6 +133,7 @@ libs_v8: libs $(FITZ_V8_LIB) CMAPDUMP := $(OUT)/cmapdump FONTDUMP := $(OUT)/fontdump CQUOTE := $(OUT)/cquote +BIN2HEX := $(OUT)/bin2hex CMAP_CNS_SRC := $(wildcard cmaps/cns/*) CMAP_GB_SRC := $(wildcard cmaps/gb/*) @@ -143,6 +144,7 @@ FONT_DROID_SRC := fonts/droid/DroidSans.ttf fonts/droid/DroidSansMono.ttf FONT_CJK_SRC := fonts/droid/DroidSansFallback.ttf FONT_CJK_FULL_SRC := fonts/droid/DroidSansFallbackFull.ttf JAVASCRIPT_SRC := pdf/pdf_util.js +ADOBECA_SRC := certs/AdobeCA.p7c $(GEN)/cmap_cns.h : $(CMAP_CNS_SRC) $(QUIET_GEN) $(CMAPDUMP) $@ $(CMAP_CNS_SRC) @@ -165,21 +167,27 @@ $(GEN)/font_cjk_full.h : $(FONT_CJK_FULL_SRC) $(GEN)/js_util.h : $(JAVASCRIPT_SRC) $(QUIET_GEN) $(CQUOTE) $@ $(JAVASCRIPT_SRC) +$(GEN)/adobe_ca.h : $(ADOBECA_SRC) + $(QUIET_GEN) $(BIN2HEX) $@ $(ADOBECA_SRC) + CMAP_HDR := $(addprefix $(GEN)/, cmap_cns.h cmap_gb.h cmap_japan.h cmap_korea.h) FONT_HDR := $(GEN)/font_base14.h $(GEN)/font_droid.h $(GEN)/font_cjk.h $(GEN)/font_cjk_full.h JAVASCRIPT_HDR := $(GEN)/js_util.h +ADOBECA_HDR := $(GEN)/adobe_ca.h ifeq "$(CROSSCOMPILE)" "" $(CMAP_HDR) : $(CMAPDUMP) | $(GEN) $(FONT_HDR) : $(FONTDUMP) | $(GEN) $(JAVASCRIPT_HDR) : $(CQUOTE) | $(GEN) +$(ADOBECA_HDR) : $(BIN2HEX) | $(GEN) endif -generate: $(CMAP_HDR) $(FONT_HDR) $(JAVASCRIPT_HDR) +generate: $(CMAP_HDR) $(FONT_HDR) $(JAVASCRIPT_HDR) $(ADOBECA_HDR) $(OUT)/pdf_cmap_table.o : $(CMAP_HDR) $(OUT)/pdf_fontfile.o : $(FONT_HDR) $(OUT)/pdf_js.o : $(JAVASCRIPT_HDR) +$(OUT)/crypto_pkcs7_openssl.o : $(ADOBECA_HDR) $(OUT)/cmapdump.o : pdf/pdf_cmap.c pdf/pdf_cmap_parse.c # --- Tools and Apps --- diff --git a/certs/AdobeCA.p7c b/certs/AdobeCA.p7c Binary files differnew file mode 100644 index 00000000..711d5bda --- /dev/null +++ b/certs/AdobeCA.p7c diff --git a/scripts/bin2hex.c b/scripts/bin2hex.c new file mode 100644 index 00000000..e02ff31a --- /dev/null +++ b/scripts/bin2hex.c @@ -0,0 +1,100 @@ +/* bin2hex.c -- Turn the contents of a file into an array of unsigned chars */ + +#include <stdio.h> +#include <string.h> + +/* We never want to build memento versions of the cquote util */ +#undef MEMENTO + +static void +clean(char *p) +{ + while (*p) + { + if ((*p == '/') || (*p == '.') || (*p == '\\') || (*p == '-')) + *p = '_'; + p ++; + } +} + +int +main(int argc, char **argv) +{ + FILE *fi, *fo; + char name[256]; + char *realname; + int i, j, c; + int bol = 1; + + if (argc < 3) + { + fprintf(stderr, "usage: bin2hex output.h lots of text files\n"); + return 1; + } + + fo = fopen(argv[1], "wb"); + if (!fo) + { + fprintf(stderr, "cquote: could not open output file '%s'\n", argv[1]); + return 1; + } + + fprintf(fo, "/* This is an automatically generated file. Do not edit. */\n"); + + for (i = 2; i < argc; i++) + { + realname = strrchr(argv[i], '/'); + if (!realname) + realname = strrchr(argv[i], '\\'); + if (realname) + realname ++; + else + realname = argv[i]; + + if (strlen(realname) > (sizeof name - 1)) + { + fprintf(stderr, "bin2hex: file name too long\n"); + if (fclose(fo)) + { + fprintf(stderr, "bin2hex: could not close output file '%s'\n", argv[1]); + return 1; + } + return 1; + } + + strcpy(name, realname); + clean(name); + + fi = fopen(argv[i], "rb"); + + j = 0; + while ((c = fgetc(fi)) != EOF) + { + if (j != 0) + { + fputc(',', fo); + fputc(j%8 == 0 ? '\n' : ' ', fo); + } + + fprintf(fo, "0x%02x", c); + j++; + } + + fputc('\n', fo); + + if (fclose(fi)) + { + fprintf(stderr, "bin2hex: could not close input file '%s'\n", argv[i]); + return 1; + } + + } + + if (fclose(fo)) + { + fprintf(stderr, "bin2hex: could not close output file '%s'\n", argv[1]); + return 1; + } + + return 0; +} diff --git a/win32/generate.bat b/win32/generate.bat index fa6c6d51..6ee830f0 100644 --- a/win32/generate.bat +++ b/win32/generate.bat @@ -6,10 +6,12 @@ if not exist generated mkdir generated cl /nologo -Ifitz -Ipdf scripts/fontdump.c cl /nologo -Ifitz -Ipdf scripts/cmapdump.c cl /nologo -Ifitz -Ipdf scripts/cquote.c +cl /nologo -Ifitz -Ipdf scripts/bin2hex.c if not exist fontdump.exe goto usage if not exist cmapdump.exe goto usage if not exist cquote.exe goto usage +if not exist bin2hex.exe goto usage if not exist generated/font_base14.h fontdump.exe generated/font_base14.h fonts/Dingbats.cff fonts/NimbusMonL-Bold.cff fonts/NimbusMonL-BoldObli.cff fonts/NimbusMonL-Regu.cff fonts/NimbusMonL-ReguObli.cff fonts/NimbusRomNo9L-Medi.cff fonts/NimbusRomNo9L-MediItal.cff fonts/NimbusRomNo9L-Regu.cff fonts/NimbusRomNo9L-ReguItal.cff fonts/NimbusSanL-Bold.cff fonts/NimbusSanL-BoldItal.cff fonts/NimbusSanL-Regu.cff fonts/NimbusSanL-ReguItal.cff fonts/StandardSymL.cff @@ -29,7 +31,9 @@ if not exist generated/cmap_korea.h cmapdump.exe generated/cmap_korea.h cmaps/ko if not exist generated/js_util.h cquote.exe generated/js_util.h pdf/pdf_util.js -del cmapdump.obj fontdump.obj cquote.obj cmapdump.exe fontdump.exe cquote.exe +if not exist generated/adobe_ca.h bin2hex.exe generated/adobe_ca.h certs/AdobeCA.p7c + +del cmapdump.obj fontdump.obj cquote.obj bin2hex.obj cmapdump.exe fontdump.exe cquote.exe bin2hex.exe goto fin diff --git a/win32/generated.vcproj b/win32/generated.vcproj index a692a9d4..4fef3694 100644 --- a/win32/generated.vcproj +++ b/win32/generated.vcproj @@ -84,6 +84,10 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File + RelativePath="..\scripts\bin2hex.c" + > + </File> + <File RelativePath="..\scripts\cmapdump.c" > </File> |