0

char* を html ページとして保存して html ページを作成する C の CGI アプリケーションがあります。

void saveTextFile(const char *filename, const char *str){.......}  

と呼ばれる

saveTextFile("..\\index.html",outputFile);

zlib を使用して "outputFile" char 配列を入力として受け取り、適切なヘッダーを含む圧縮された html ページを出力するにはどうすればよいですか?

ここで、 saveTextFile関数の代わりにgzopenを使用しますか?

アドバイスをいただければ幸いです。ありがとう。

4

1 に答える 1

1

とった -

//****************************************************************************************
    //ZIP file: Take the char string "outputFile" as input to gzip. Create a zipped html file
    file = gzopen("..\\index.html.gz", "wb"); //create a zipped file
    if (file == NULL) {
        printf("Can't open zipped file");
        exit(1);
    }
    len   = strlen(outputFile); //need to know length of string
    compd = gzwrite(file, outputFile, (unsigned)len); //compress data into .gz file
    cls   = gzclose (file); //close .gz file
    //End zip*********************************************************************************** 
于 2009-05-14T16:06:35.067 に答える