diff options
Diffstat (limited to 'Build/source/utils/xpdfopen/pdfclose.c')
-rw-r--r-- | Build/source/utils/xpdfopen/pdfclose.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Build/source/utils/xpdfopen/pdfclose.c b/Build/source/utils/xpdfopen/pdfclose.c new file mode 100644 index 00000000000..121a42762f9 --- /dev/null +++ b/Build/source/utils/xpdfopen/pdfclose.c @@ -0,0 +1,71 @@ +/* + * pdfclose.c + * + * Modified by Jim Diamond (jim.diamond@acadiau.ca) 2010/04/21 + * and Peter Breitenlohner <tex-live@tug.org> (2009). + * + * This program does not take a viewer argument, and just tries to close + * any known viewer displaying the given file. + * + * V 0.80 + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "sendx.h" +#include "xpdfopen.h" +#include "utils.h" + + +char * progname; /* set in main(); NOT static! */ + + + +static void +usage(void) +{ + fprintf(stderr, "Usage: %s <file.pdf>\n", progname); +} + + + +static int +try_name(const char * filename, const char * title_format) +{ + char * winname; + int ret ; + + winname = make_window_name(title_format, filename); + if (winname == NULL) + return 99; + + ret = sendx_control_token("W", winname); + free(winname); + + return ret; +} + + + +int +main (int argc, char * argv[]) +{ + progname = argv[0]; + + if (argc != 2) + { + usage(); + return EXIT_FAILURE; + } + + if (try_name(argv[1], AR9_WIN_NAME_FMT)) /* both AR8 and AR9 */ + if (try_name(argv[1], XPDF_WIN_NAME_FMT)) + if (try_name(argv[1], AR7_WIN_NAME_FMT)) + if (try_name(argv[1], AR5_WIN_NAME_FMT)) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} |