X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;h=e8ddfdb88ad6d72add3bd20d4f66782d108e3a87;hb=406e76774dc83663a76329ac4368460eb086c8d5;hp=2cd110ac251df55d846ea08919c01a62de44bb8f;hpb=e9f46a43e9fe58b997f2ffbe6125a906a67824f2;p=swftools.git diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index 2cd110a..e8ddfdb 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 given. Writing to %s", outputname); + } + } + + if(!outputname) + { fprintf(stderr, "Please use -o to specify an output file\n"); exit(1); }