どのように私はZlibのを使用して圧縮されたHTMLページにchar配列を圧縮することができます

StackOverflow https://stackoverflow.com/questions/859155

質問

私は、HTMLページとしてのchar *を保存することで、HTMLページを作成し、CでCGIアプリケーションを持っています

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

タグと呼ばれます
saveTextFile("..\\index.html",outputFile);

どのように私はを入力の "OUTPUTFILE" char配列、出力として適切なヘッダとzip形式のHTMLページを取るためにはzlibを使用していますか?

gzopen の代わりに私のsaveTextFile機能をここで使用されますか?

何かアドバイスが理解されます。おかげます。

役に立ちましたか?

解決

それを手に入れた -

//****************************************************************************************
    //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*********************************************************************************** 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top