From 4a25d9dfd7c17d85e87d4bc645467554fb1adbea Mon Sep 17 00:00:00 2001 From: kramm Date: Mon, 5 Jun 2006 07:54:06 +0000 Subject: [PATCH] added -C option --- src/swfc.c | 20 +++++++++++++++----- src/swfc.doc | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/swfc.c b/src/swfc.c index db5ae8b..8e7977b 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -44,6 +44,7 @@ static char * outputname = "output.swf"; static int verbose = 2; static int optimize = 0; static int override_outputname = 0; +static int do_cgi = 0; static struct options_t options[] = { {"h", "help"}, @@ -68,6 +69,10 @@ int args_callback_option(char*name,char*val) optimize = 1; return 0; } + else if(!strcmp(name, "C")) { + do_cgi = 1; + return 0; + } else if(!strcmp(name, "v")) { verbose ++; return 0; @@ -119,7 +124,7 @@ static void syntaxerror(char*format, ...) va_start(arglist, format); vsprintf(buf, format, arglist); va_end(arglist); - printf("\"%s\", line %d column %d: error- %s\n", filename, line, column, buf); + fprintf(stderr, "\"%s\", line %d column %d: error- %s\n", filename, line, column, buf); exit(1); } @@ -130,7 +135,7 @@ static void warning(char*format, ...) va_start(arglist, format); vsprintf(buf, format, arglist); va_end(arglist); - printf("\"%s\", line %d column %d: warning- %s\n", filename, line, column, buf); + fprintf(stderr, "\"%s\", line %d column %d: warning- %s\n", filename, line, column, buf); } static void readToken() @@ -673,11 +678,16 @@ static void s_endSWF() warning("Empty bounding box for movie"); } - fi = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); + if(do_cgi) + fi = fileno(stdout); + else + fi = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); if(fi<0) { syntaxerror("couldn't create output file %s", filename); } - if(swf->compressed) + if(do_cgi) + {if(swf_WriteCGI(swf)<0) syntaxerror("WriteCGI() failed.\n");} + else if(swf->compressed) {if(swf_WriteSWC(fi, swf)<0) syntaxerror("WriteSWC() failed.\n");} else {if(swf_WriteSWF(fi, swf)<0) syntaxerror("WriteSWF() failed.\n");} @@ -3192,7 +3202,7 @@ int main (int argc,char ** argv) file = generateTokens(filename); if(!file) { - printf("parser returned error.\n"); + fprintf(stderr, "parser returned error.\n"); return 1; } pos=0; diff --git a/src/swfc.doc b/src/swfc.doc index 829fbd7..763a6c5 100644 --- a/src/swfc.doc +++ b/src/swfc.doc @@ -8,6 +8,8 @@ Compiles a file written in sc (SWF Script) into a number of SWF files. Print short help message and exit -V, --version Print version info and exit +-C, --cgi + Output to stdout (for use in CGI environments) -v, --verbose Increase verbosity. Increase verbosity. Use more than one \fB-v\fR for greater effect. -- 1.7.10.4