From baad9b2b637cabbc94f94d2140656d8c84261e1c Mon Sep 17 00:00:00 2001 From: kramm Date: Sat, 5 Apr 2003 19:19:34 +0000 Subject: [PATCH] made output filename optional --- pdf2swf/pdf2swf.1 | 2 +- pdf2swf/pdf2swf.cc | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/pdf2swf/pdf2swf.1 b/pdf2swf/pdf2swf.1 index 1103cf4..7704ee1 100644 --- a/pdf2swf/pdf2swf.1 +++ b/pdf2swf/pdf2swf.1 @@ -3,7 +3,7 @@ pdf2swf - convert PDF files into SWF .SH Synopsis .B pdf2swf -[\fIoptions\fR] \fIfile.pdf\fR -o \fIfile.swf\fR +[\fIoptions\fR] \fIfile.pdf\fR [-o \fIfile.swf\fR] .SH DESCRIPTION This tools converts Acrobat PDF files into Flash SWF Animation files. diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index 2cd110a..4cec4f5 100644 --- a/pdf2swf/pdf2swf.cc +++ b/pdf2swf/pdf2swf.cc @@ -270,7 +270,7 @@ int args_callback_command(char*name, char*val) { void args_callback_usage(char*name) { - printf("Usage: %s [-si] [-j quality] [-p range] [-P password] input.pdf -o output.swf\n", name); + printf("Usage: %s [-si] [-j quality] [-p range] [-P password] input.pdf [-o output.swf]\n", name); printf("\n"); printf("-p --pages=range Convert only pages in range\n"); printf("-P --password=password Use password for deciphering the pdf\n"); @@ -351,6 +351,25 @@ void addfontdir(FILE*database, char* dirname, int*numfonts, char*searchpath) } #endif +char* stripfilename(char*filename, char*newext) +{ + char*last1 = strrchr(filename, '/'); + char*last2 = strrchr(filename, '\\'); + char*pos = filename; + char*name; + char*dot; + if(last1>pos) pos = last1 + 1; + if(last2>pos) pos = last2 + 1; + name = (char*)malloc(strlen(pos)+5); + strcpy(name, pos); + dot = strrchr(name, '.'); + if(dot) { + *dot = 0; + } + strcat(name, newext); + return name; +} + int main(int argn, char *argv[]) { int ret; @@ -369,6 +388,14 @@ int main(int argn, char *argv[]) initLog(0,-1,0,0,-1,loglevel); if(!outputname) { + if(filename) { + outputname = stripfilename(filename, ".swf"); + logf(" Output filename not giving. Writing to %s", outputname); + } + } + + if(!outputname) + { fprintf(stderr, "Please use -o to specify an output file\n"); exit(1); } -- 1.7.10.4