Esempio n. 1
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%  H t t p U n e s c a p e                                                    %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Method HttpUnescape removes HTTP escaping from a string. If the result
%  string is NULL, it modifies the source string in place, else fills-in
%  the result string. This method returns the resulting string. End-of-line
%  sequences (%0A%0D) are stored as a single new-line character, i.e.
%  carriage-returns (%0D) are not stored.
%
%  The format of the HttpUnescape method is:
%
%      char *HttpUnescape(char *string,char *result)
%
%  A description of each parameter follows:
%
%    o string:  Specifies the string to be converted.
%
%    o result:  Specifies the destination for the converted result. A NULL
%               indicates that the conversion happens "in-place".
%
*/
char *HttpUnescape(char *string,char *result)
{
  char
    *target; /* Where we store the result */

  assert(string != (char *) NULL);
  if (!result) /* If result string is null, */
    result = string; /* modify in place */
  target = result;

  while (*string)
  {
    if (*string == '%'  /* Unescape %xx sequence */
          && isxdigit(string [1]) && isxdigit(string [2]))
      {
        string++;
        *target = DecodeHex ((const char **) &string, 2);
        if (*target != '\r')
          target++; /* We do not store CR's */
      }
    else
      {
        if (*string == '+') /* Spaces are escaped as '+' */
          *target++ = ' ';
        else
          *target++ = *string; /* Otherwise just copy */

        string++;
      }
  }
  *target = '\0'; /* Terminate target string */
  return (result);
}
Esempio n. 2
0
tagIoData* DecodeHex(const char* pData)
{
	static unsigned char* s_decode_buf =(unsigned char*)malloc(65536);

	tagIoData* io = new tagIoData();
	io->buflen = DecodeHex(pData,s_decode_buf,65536);
	io->buf = (unsigned char*)malloc(io->buflen);
	::memcpy(io->buf,s_decode_buf,io->buflen);
	io->pos = 0;
	return io;
}
Esempio n. 3
0
int _tmain(int argc, _TCHAR* argv[])
{
	//{a:"123",b:[1,"2",0.3],c:"汉字"}
	const char* test = "0a0b010363060de6b189e5ad970361060731323303620907010401060332053fd333333333333301";
	
	AMF3::context ctx;
	AMF3::init_context(&ctx,read_data,write_data);

	tagIoData* io = DecodeHex(test);
	AMF3::amf_object_handle obj = AMF3::decode(&ctx,io);

	tagIoData* out = new tagIoData;
	out->buflen = 4096;
	out->buf = (unsigned char*)malloc(out->buflen);
	out->pos = 0;
	AMF3::encode(&ctx,out,obj);

	return 0;
}
Esempio n. 4
0
PrivateKey Literal<PrivateKey>(const std::string &serialized)
{
    PrivateKey key(DecodeHex(serialized));
    return key;
}