static long ParseTagData( char * buffer, TagPtr * tag ) { int actuallen = 0; long length; TagPtr tmpTag; length = FixDataMatchingTag(buffer, kXMLTagData); if (length == -1) return -1; tmpTag = NewTag(); if (tmpTag == 0) return -1; //printf("ParseTagData unimplimented\n"); //printf("Data: %s\n", buffer); // getchar(); char* string = BASE64Decode(buffer, strlen(buffer), &actuallen); tmpTag->type = kTagTypeData; tmpTag->string = string; tmpTag->tag = 0; tmpTag->offset = actuallen; // buffer_start ? buffer - buffer_start: 0; tmpTag->tagNext = 0; *tag = tmpTag; return length; }
/** * Get the username and password from the basic authorization header sent by the client * * @param connection The MHD connection structure * @param password a pointer for the password * @return NULL if no username could be found, a pointer * to the username if found * @ingroup authentication */ char * MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char** password) { const char *header; char *decode; const char *separator; char *user; if ( (NULL == (header = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_AUTHORIZATION))) || (0 != strncmp (header, _BASIC_BASE, strlen (_BASIC_BASE))) ) return NULL; header += strlen (_BASIC_BASE); if (NULL == (decode = BASE64Decode (header))) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _("Error decoding basic authentication\n")); #endif return NULL; } /* Find user:password pattern */ if (NULL == (separator = strchr (decode, ':'))) { #ifdef HAVE_MESSAGES MHD_DLOG(connection->daemon, _("Basic authentication doesn't contain ':' separator\n")); #endif free (decode); return NULL; } if (NULL == (user = strdup (decode))) { free (decode); return NULL; } user[separator - decode] = '\0'; /* cut off at ':' */ if (NULL != password) { *password = strdup (separator + 1); if (NULL == *password) { #ifdef HAVE_MESSAGES MHD_DLOG(connection->daemon, _("Failed to allocate memory for password\n")); #endif free (decode); free (user); return NULL; } } free (decode); return user; }
bool AvHNexus::recv(entvars_t* const pev, const char* data, const unsigned int length) { string base64_message(data,length); byte_string message = BASE64Decode(base64_message); Nexus::ClientID client = OFFSET(pev); TunnelToClient::getInstance()->insertMessage(client,message); return true; }