#include "captcha.hpp" #include #include #define GIFSIZE 17646 extern "C" { const int gifsize = GIFSIZE; void captcha( unsigned char im[70*200], unsigned char l[6]); void makegif(unsigned char im[70*200], unsigned char gif[gifsize]); } struct captcha generateCaptcha( ) { struct captcha c; unsigned char l[6]; unsigned char *im = new unsigned char[70*200]; unsigned char *gif = new unsigned char[gifsize]; captcha( im, l ); c.text = std::string( (char *)l ); std::ostringstream raws( std::stringstream::out | std::stringstream::binary ); makegif( im, gif ); raws.write( (char *)gif, gifsize ); std::string raw = raws.str( ); std::istringstream in( std::ios_base::in | std::ios_base::binary ); in.str( raw ); base64::encoder E; std::string base_s; base_s.reserve( 3 * gifsize ); std::ostringstream base( base_s, std::stringstream::out | std::stringstream::binary ); E.encode( in, base ); c.base64 = base.str( ); delete gif; delete im; return c; }