How to compress char array to compressed html page using Zlib

I have a CGI application in C that creates an html page, saving the char * as an html page:

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

called

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

How to use zlib to input the input array of outputFile char and display a page with a zip header with the appropriate headers?

Will gzopen be used instead of my saveTextFile function?

Any advice is appreciated. Thanks.

0
source share
1 answer

Got it -

//****************************************************************************************
    //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*********************************************************************************** 
+1
source

All Articles