diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-05-05 13:19:37 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-05-05 13:19:37 +0000 |
commit | c6e0c2d3f66468bf0dc4e71f4e96ccfca86b93c5 (patch) | |
tree | 1f6f65e4d4b91da48baff77a20c0f2ffa10aabfc /Build/source/utils/xpdfopen/utils.c | |
parent | c53b86a4f756fd2a535206176fa9a3f36485ca34 (diff) |
xpdfopen 0.80 (replacing pdfopen 0.5)
git-svn-id: svn://tug.org/texlive/trunk@18111 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/xpdfopen/utils.c')
-rw-r--r-- | Build/source/utils/xpdfopen/utils.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Build/source/utils/xpdfopen/utils.c b/Build/source/utils/xpdfopen/utils.c new file mode 100644 index 00000000000..a75be79a02e --- /dev/null +++ b/Build/source/utils/xpdfopen/utils.c @@ -0,0 +1,46 @@ +/* + * utils.c: Items common to pdfopen and pdfclose. + * + * Copyright (C) 2010 Jim Diamond <jim.diamond@acadiau.ca> + * You may freely use, modify and/or distribute this file. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "utils.h" +#include "xpdfopen.h" + +extern char * progname; + +/* + * Allocate memory and create a window name. + * Return a pointer to the new string or NULL on failure. + * + * The caller is responsible for free()ing the memory allocated here. + * + * Note: acroread (at least AR 7, 8, 9) uses only the basename in the + * window title. + * xpdf uses the whole file name. + * Other PDF viewers may need other treatment. + */ + +char * +make_window_name(const char * fmt, const char * filename) +{ + char * window_name; + const char * title_name; + + title_name = filename; + if (strrchr(title_name, '/') != NULL + && strncasecmp(fmt, XPDF_WIN_NAME, strlen(XPDF_WIN_NAME))) + title_name = strrchr(title_name, '/') + 1; + + window_name = malloc(strlen(fmt) + strlen(title_name) + 1); + if (window_name != NULL) + sprintf(window_name, fmt, title_name); + else + fprintf(stderr, "%s: out of memory\n", progname); + + return window_name; +} |