كيف يمكنني ضغط مصفوفة char في صفحة html مضغوطة باستخدام Zlib

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

سؤال

لدي تطبيق CGI في لغة C يقوم بإنشاء صفحة html عن طريق حفظ char* كصفحة html:

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

كما دعا

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

كيف يمكنني استخدام zlib لاتخاذ as مدخل مصفوفة الأحرف "outputFile" وإخراج صفحة html مضغوطة بالرؤوس المناسبة؟

هل com.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