summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/euptexdir/euptexextra.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2014-05-05 15:20:05 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2014-05-05 15:20:05 +0000
commitcadfe1d86c3647e87489c9b017b204bf81bf367c (patch)
treefc50cfbdd4d9c8c3adbca48071cfe0f6f9e9babb /Build/source/texk/web2c/euptexdir/euptexextra.c
parent4293a52a3030bd12a329509dec779b57e0323355 (diff)
add a primitive pdffiledump for eptex and euptex
git-svn-id: svn://tug.org/texlive/trunk@33846 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/euptexdir/euptexextra.c')
-rw-r--r--Build/source/texk/web2c/euptexdir/euptexextra.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/euptexdir/euptexextra.c b/Build/source/texk/web2c/euptexdir/euptexextra.c
index 1497c967625..d0c1b8d0af9 100644
--- a/Build/source/texk/web2c/euptexdir/euptexextra.c
+++ b/Build/source/texk/web2c/euptexdir/euptexextra.c
@@ -10,3 +10,58 @@
/* Hand-coded routines for TeX or Metafont in C. */
#include <lib/texmfmp.c>
+
+void getfiledump(int s, int offset, int length)
+{
+ FILE *f;
+ int read, i;
+ poolpointer data_ptr;
+ poolpointer data_end;
+ char *file_name;
+
+ if (length == 0) {
+ /* empty result string */
+ return;
+ }
+
+ if (poolptr + 2 * length + 1 >= poolsize) {
+ /* no place for result */
+ poolptr = poolsize;
+ /* error by str_toks that calls str_room(1) */
+ return;
+ }
+
+ file_name = kpse_find_tex(makecfilename(s));
+ if (file_name == NULL) {
+ return; /* empty string */
+ }
+
+ /* read file data */
+ f = fopen(file_name, FOPEN_RBIN_MODE);
+ if (f == NULL) {
+ free(file_name);
+ return;
+ }
+ recorder_record_input(file_name);
+ if (fseek(f, offset, SEEK_SET) != 0) {
+ free(file_name);
+ return;
+ }
+ /* there is enough space in the string pool, the read
+ data are put in the upper half of the result, thus
+ the conversion to hex can be done without overwriting
+ unconverted bytes. */
+ data_ptr = poolptr + length;
+ read = fread(&strpool[data_ptr], sizeof(char), length, f);
+ fclose(f);
+
+ /* convert to hex */
+ data_end = data_ptr + read;
+ for (; data_ptr < data_end; data_ptr++) {
+ i = snprintf((char *) &strpool[poolptr], 3,
+ "%.2X", (unsigned int) strpool[data_ptr]);
+ check_nprintf(i, 3);
+ poolptr += i;
+ }
+ free(file_name);
+}