patrik08
27th May 2006, 12:39
I have build successful libtidy on qt4
Now how i cann translate this C++ sample to make
bool Clean_Code_utf8(QString incomming_file, QString output_file, QString config_file)
Have anibody experience on tidy? I understand tidy only from php....
#include <tidy.h>
#include <buffio.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char **argv )
{
const char* input = "<title>Foo</title><p>Foo!";
TidyBuffer output = {0};
TidyBuffer errbuf = {0};
int rc = -1;
Bool ok;
TidyDoc tdoc = tidyCreate(); // Initialize "document"
printf( "Tidying:\t%s\n", input );
ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); // Convert to XHTML
if ( ok )
rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics
if ( rc >= 0 )
rc = tidyParseString( tdoc, input ); // Parse the input
if ( rc >= 0 )
rc = tidyCleanAndRepair( tdoc ); // Tidy it up!
if ( rc >= 0 )
rc = tidyRunDiagnostics( tdoc ); // Kvetch
if ( rc > 1 ) // If error, force output.
rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
if ( rc >= 0 )
rc = tidySaveBuffer( tdoc, &output ); // Pretty Print
if ( rc >= 0 )
{
if ( rc > 0 )
printf( "\nDiagnostics:\n\n%s", errbuf.bp );
printf( "\nAnd here is the result:\n\n%s", output.bp );
}
else
printf( "A severe error (%d) occurred.\n", rc );
tidyBufFree( &output );
tidyBufFree( &errbuf );
tidyRelease( tdoc );
return rc;
}
Subversion dir...
svn co http://ciz.ch/svnciz/forms_shop/lib_tidy_src/ libtydy
Compile ok on window...
pro file ....
DEPENDPATH += . include
INCLUDEPATH += . include
TEMPLATE =lib
CONFIG += qt warn_off release staticlib
LANGUAGE = C++
#DEFINES -= UNICODE
DEFINES += NDEBUG THREAD_SAFE=1 TEMP_STORE=2
DESTDIR = ../all_os_libs/
win32:TARGET = tidy
unix:TARGET = tidy
mac:TARGET = tidy
Now how i cann translate this C++ sample to make
bool Clean_Code_utf8(QString incomming_file, QString output_file, QString config_file)
Have anibody experience on tidy? I understand tidy only from php....
#include <tidy.h>
#include <buffio.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char **argv )
{
const char* input = "<title>Foo</title><p>Foo!";
TidyBuffer output = {0};
TidyBuffer errbuf = {0};
int rc = -1;
Bool ok;
TidyDoc tdoc = tidyCreate(); // Initialize "document"
printf( "Tidying:\t%s\n", input );
ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); // Convert to XHTML
if ( ok )
rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics
if ( rc >= 0 )
rc = tidyParseString( tdoc, input ); // Parse the input
if ( rc >= 0 )
rc = tidyCleanAndRepair( tdoc ); // Tidy it up!
if ( rc >= 0 )
rc = tidyRunDiagnostics( tdoc ); // Kvetch
if ( rc > 1 ) // If error, force output.
rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
if ( rc >= 0 )
rc = tidySaveBuffer( tdoc, &output ); // Pretty Print
if ( rc >= 0 )
{
if ( rc > 0 )
printf( "\nDiagnostics:\n\n%s", errbuf.bp );
printf( "\nAnd here is the result:\n\n%s", output.bp );
}
else
printf( "A severe error (%d) occurred.\n", rc );
tidyBufFree( &output );
tidyBufFree( &errbuf );
tidyRelease( tdoc );
return rc;
}
Subversion dir...
svn co http://ciz.ch/svnciz/forms_shop/lib_tidy_src/ libtydy
Compile ok on window...
pro file ....
DEPENDPATH += . include
INCLUDEPATH += . include
TEMPLATE =lib
CONFIG += qt warn_off release staticlib
LANGUAGE = C++
#DEFINES -= UNICODE
DEFINES += NDEBUG THREAD_SAFE=1 TEMP_STORE=2
DESTDIR = ../all_os_libs/
win32:TARGET = tidy
unix:TARGET = tidy
mac:TARGET = tidy