void CC_HMACHASH(uint32_t hashlen, const EVP_MD * (*EVP)(void), C_BLOB &Param1, C_BLOB &Param2, C_LONGINT &Param3, C_TEXT &returnValue) { uint8_t *buf = (uint8_t *)calloc(hashlen, sizeof(uint8_t)); HMAC(EVP(), (const void *)Param1.getBytesPtr(), (int)Param1.getBytesLength(), (const unsigned char *)Param2.getBytesPtr(), (int)Param2.getBytesLength(), buf, &hashlen); C_BLOB temp; temp.setBytes((const uint8_t *)buf, hashlen); switch (Param3.getIntValue()) { case 1: temp.toB64Text(&returnValue); break; case 2: temp.toB64Text(&returnValue, true); break; default: temp.toHexText(&returnValue); break; } free(buf); }
/// create attribute list then call event parser's event void ParserImpl :: StartElementHandler( void * parser, const XML_Char * name, const XML_Char ** atts ) { XMLEventParser::Attributes a; unsigned int i = 0; while( atts[i] ) { a.push_back( XMLEventParser::Attribute( atts[i], atts[i+1] ) ); i += 2; } EVP(parser)->OnElementStart( name, a ); }
K kclone(K a)//Deep copy -- eliminate where possible { if(!a) R 0; I t=a->t,n=a->n; K z= 7==t?Kv():newK(t,n); if (4==ABS(t)) DO(n, kS(z)[i]=kS(a)[i]) //memcpy everywhere is better else if(3==ABS(t)) DO(n, kC(z)[i]=kC(a)[i]) else if(2==ABS(t)) DO(n, kF(z)[i]=kF(a)[i]) else if(1==ABS(t)) DO(n, kI(z)[i]=kI(a)[i]) else if(0== t ) DO(n, kK(z)[i]=kclone(kK(a)[i])) else if(5== t ) DO(n, kK(z)[i]=kclone(kK(a)[i])) else if(7== t ) { I k=0; z->t=a->t; I vt=z->n = a->n; K kv; V*v; SW(vt) { CS(1, k=((K)kV(a)[CODE])->n-1; M(z,kv=newK(-4,k+1)) v=(V*)kK(kv); //v[k]=0;//superfluous reminder DO(k, V w=kW(a)[i]; if(VA(w))v[i]=w; //TODO: is this ok for NAMES? see similar code in capture() else { K r=kclone(*(K*)w); //oom V q=newE(LS,r); //oom kap((K*) kV(z)+LOCALS,&q);//oom cd(q);//kap does ci q=EVP(q); //oom free z etc. kap needs checking v[i]=q; } ) ) CS(2, M(z,kv=newK(-4,3)) v=(V*)kK(kv); memcpy(v,kW(a),3*sizeof(V)); )
/// fire event parsers event void ParserImpl :: CharDataHandler( void * parser, const XML_Char *s, int len ) { EVP(parser)->OnText( string( s, len ) ); }
/// fire event parsers event void ParserImpl :: EndElementHandler( void * parser, const XML_Char *name) { EVP(parser)->OnElementEnd( name ); }