extern size_t XML_UnPackValue(CONVOPT *opt, unsigned char *p, ValueStruct *value) { ValueContext *ctx; unsigned char *pp; ctx = New(ValueContext); ctx->root = value; ctx->buff = (xmlChar *)xmalloc(1); ctx->size = 1; ctx->fStart = FALSE; ctx->opt = opt; ctx->value = NULL; memset(ctx->longname, 0, SIZE_LONGNAME + 1); SetNil(value); pp = p; switch (ConvXmlType(opt)) { case XML_TYPE1: xmlSAXUserParseMemory(mondaiSAXHandler1, ctx, (char *)p, strlen((char *)p)); break; case XML_TYPE2: xmlSAXUserParseMemory(mondaiSAXHandler2, ctx, (char *)p, strlen((char *)p)); break; } xmlCleanupParser(); xfree(ctx->buff); xfree(ctx); return (p - pp); }
hb_value_t* hb_plist_parse(const char *buf, size_t len) { xmlSAXHandler parser; parse_data_t pd; pd.stack = queue_new(); pd.tag_stack = queue_new(); pd.key = NULL; pd.value = NULL; pd.plist = NULL; pd.closed_top = 0; memset(&parser, 0, sizeof(parser)); parser.initialized = XML_SAX2_MAGIC; parser.startElement = start_element; parser.endElement = end_element; parser.characters = text_data; parser.warning = parse_warning; parser.error = parse_error; int result = xmlSAXUserParseMemory(&parser, &pd, buf, len); if (result != 0) { hb_error("Plist parse failed"); return NULL; } xmlCleanupParser(); if (pd.key) free(pd.key); if (pd.value) free(pd.value); queue_free(&pd.stack); queue_free(&pd.tag_stack); return pd.plist; }
bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) { /* * this initializes the library and checks potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ LIBXML_TEST_VERSION xmlSAXHandler saxHandler; memset( &saxHandler, 0, sizeof(saxHandler) ); // Using xmlSAXVersion( &saxHandler, 2 ) generate crash as it sets plenty of other pointers... saxHandler.initialized = XML_SAX2_MAGIC; // so we do this to force parsing as SAX2. saxHandler.startElement = &CCSAXParser::startElement; saxHandler.endElement = &CCSAXParser::endElement; saxHandler.characters = &CCSAXParser::textHandler; int result = xmlSAXUserParseMemory( &saxHandler, this, pXMLData, uDataLength ); if ( result != 0 ) { return false; } /* * Cleanup function for the XML library. */ xmlCleanupParser(); /* * this is to debug memory for regression tests */ #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) xmlMemoryDump(); #endif return true; }
int main(int argc, char **argv) { xmlSAXHandler handler; int fd; int mid; if (_parse_cmd(argc, argv)) { _usage(); return -1; } if (_init()) return -1; memset(&handler, 0, sizeof(xmlSAXHandler)); handler.startElement = _element_start; handler.endElement = _element_end; handler.error = _element_error; if (xmlSAXUserParseMemory(&handler, NULL, g_buffer, g_buflen) < 0) { printf("SAX parser error 1\n"); } xmlCleanupParser(); _release(); return 0; }
static LsmDomDocument * _parse_memory (LsmDomDocument *document, LsmDomNode *node, const void *buffer, int size, GError **error) { static LsmDomSaxParserState state; state.document = document; if (node != NULL) state.current_node = node; else state.current_node = LSM_DOM_NODE (document); if (size < 0) size = strlen (buffer); if (xmlSAXUserParseMemory (&sax_handler, &state, buffer, size) < 0) { if (state.document != NULL) g_object_unref (state.document); state.document = NULL; lsm_debug_dom ("[LsmDomParser::from_memory] Invalid document"); g_set_error (error, LSM_DOM_DOCUMENT_ERROR, LSM_DOM_DOCUMENT_ERROR_INVALID_XML, "Invalid document."); } return state.document; }
xmlnode * xmlnode_from_str(const char *str, gssize size) { struct _xmlnode_parser_data *xpd; xmlnode *ret; gsize real_size; g_return_val_if_fail(str != NULL, NULL); real_size = size < 0 ? strlen(str) : size; xpd = g_new0(struct _xmlnode_parser_data, 1); if (xmlSAXUserParseMemory(&xmlnode_parser_libxml, xpd, str, real_size) < 0) { while(xpd->current && xpd->current->parent) xpd->current = xpd->current->parent; if(xpd->current) xmlnode_free(xpd->current); xpd->current = NULL; } ret = xpd->current; if (xpd->error) { ret = NULL; if (xpd->current) xmlnode_free(xpd->current); } g_free(xpd); return ret; }
int SaxHandler::parseMemory( const char* buffer, int size ) { int result = xmlSAXUserParseMemory( &sax, this, buffer, size ); return result; }
void wyBox2DPELoader::parse(char* data, int dataLen) { m_parseState = wyCalloc(1, sizeof(wyParseState)); wyParseState* state = (wyParseState*)m_parseState; state->tags = (int*)wyMalloc(10 * sizeof(int)); state->tags[0] = DOCUMENT; state->num = 1; state->max = 10; state->state = State_ready; state->fixtureDef = new b2FixtureDef(); state->bodyMeta = NULL; state->vertexIndex = 0; // declare handler xmlSAXHandlerV1 saxHandler = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, startElement, endElement, NULL, characters, NULL, NULL, NULL, warning, error, NULL, NULL, NULL, NULL, 0 }; // start to parser xml file xmlSAXUserParseMemory((xmlSAXHandlerPtr)&saxHandler, this, data, dataLen); // clean parser xmlCleanupParser(); if(state->lastKey) wyFree((void*)state->lastKey); delete state->fixtureDef; wyFree(state->tags); wyFree(state); }
NSDictionary<std::string, NSObject*> *dictionaryWithContentsOfFile(const char *pFileName) { FILE *fp = NULL; if( !(fp = fopen(pFileName, "r")) ) { return NULL; } fseek(fp,0,SEEK_END); int size = ftell(fp); fseek(fp,0,SEEK_SET); char *buffer = new char[size+1]; fread(buffer,sizeof(char),size,fp); fclose(fp); /* * this initialize the library and check potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ LIBXML_TEST_VERSION xmlSAXHandler saxHandler; memset( &saxHandler, 0, sizeof(saxHandler) ); // Using xmlSAXVersion( &saxHandler, 2 ) generate crash as it sets plenty of other pointers... saxHandler.initialized = XML_SAX2_MAGIC; // so we do this to force parsing as SAX2. saxHandler.startElement = &plist_startElement; saxHandler.endElement = &plist_endElement; saxHandler.characters = &plist_characters; int result = xmlSAXUserParseMemory( &saxHandler, this, buffer, size ); if ( result != 0 ) { return NULL; } /* * Cleanup function for the XML library. */ xmlCleanupParser(); /* * this is to debug memory for regression tests */ xmlMemoryDump(); delete []buffer; return m_pRootDict; }
bool CCSAXParser::parse(const char *pszFile) { CCFileData data(pszFile, "rt"); unsigned long size = data.getSize(); char *pBuffer = (char*) data.getBuffer(); if (!pBuffer) { return false; } /* * this initialize the library and check potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ LIBXML_TEST_VERSION xmlSAXHandler saxHandler; memset( &saxHandler, 0, sizeof(saxHandler) ); // Using xmlSAXVersion( &saxHandler, 2 ) generate crash as it sets plenty of other pointers... saxHandler.initialized = XML_SAX2_MAGIC; // so we do this to force parsing as SAX2. saxHandler.startElement = &CCSAXParser::startElement; saxHandler.endElement = &CCSAXParser::endElement; saxHandler.characters = &CCSAXParser::textHandler; int result = xmlSAXUserParseMemory( &saxHandler, this, pBuffer, size ); if ( result != 0 ) { return false; } /* * Cleanup function for the XML library. */ xmlCleanupParser(); /* * this is to debug memory for regression tests */ xmlMemoryDump(); return true; }
sipe_xml *sipe_xml_parse(const gchar *string, gsize length) { sipe_xml *result = NULL; if (string && length) { struct _parser_data *pd = g_new0(struct _parser_data, 1); if (xmlSAXUserParseMemory(&parser, pd, string, length)) pd->error = TRUE; if (pd->error) { sipe_xml_free(pd->root); } else { result = pd->root; } g_free(pd); } return result; }
NSDictionary<std::string, NSObject*> *dictionaryWithContentsOfFile(const char *pFileName) { FileData data; unsigned long size = 0; char *pBuffer = (char *) data.getFileData(pFileName, "r", &size); if (! pBuffer) { return NULL; } /* * this initialize the library and check potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ LIBXML_TEST_VERSION xmlSAXHandler saxHandler; memset( &saxHandler, 0, sizeof(saxHandler) ); // Using xmlSAXVersion( &saxHandler, 2 ) generate crash as it sets plenty of other pointers... saxHandler.initialized = XML_SAX2_MAGIC; // so we do this to force parsing as SAX2. saxHandler.startElement = &plist_startElement; saxHandler.endElement = &plist_endElement; saxHandler.characters = &plist_characters; int result = xmlSAXUserParseMemory( &saxHandler, this, pBuffer, size ); if ( result != 0 ) { return NULL; } /* * Cleanup function for the XML library. */ xmlCleanupParser(); /* * this is to debug memory for regression tests */ xmlMemoryDump(); return m_pRootDict; }
EOLIAN static Efl_Object * _xml_sax_base_parse_string(Eo *obj, Xml_Base_Data *pd, const char* document) { EINA_LOG_DBG("Parsing document: %s", document); const Efl_Class *current_class = efl_class_get(obj); EINA_LOG_DBG("obj-type referenced:'%s'\n", efl_class_name_get(current_class)); // Create a parser instance for this request. // TODO this currently is here as having one setup in the constructor // results in function references being lost in transit... xmlSAXHandler parser; memset(&parser, 0, sizeof(xmlSAXHandler)); parser.initialized = XML_SAX2_MAGIC; // Setup parser callbacks and start parsing parser.startDocument = _libxml2_document_start; parser.endDocument = _libxml2_document_end; parser.startElementNs = _libxml2_start; parser.endElementNs = _libxml2_end; parser.characters = _libxml2_char; // TODO fix get location issues in XInclude filter. // TODO Work out why this goes to town and kills the parser.... // parser.setDocumentLocator = _libxml2_set_document_locator; // Just in for debugging at the moment. parser.error = _error; parser.warning = _warning; parser.fatalError = _fatalError; if (xmlSAXUserParseMemory(&parser, obj, document, (int) strlen(document)) < 0 ) { EINA_LOG_ERR("Issue parsing XML document"); }; // Make sure we cleanup the current parser. xmlCleanupParser(); return NULL; //pd->result; }
bool XMLParser::ParseBytes(const unsigned char *bytes, int length, XMLParserDelegate *delegateptr) { // Logger::Debug("[XMLParser::ParseBytes] delegateptr = %p", delegateptr); bool retValue = false; xmlSAXHandler saxHandler = {0}; saxHandler.startDocument = XMLParser::StartDocument; saxHandler.endDocument = XMLParser::EndDocument; saxHandler.startElement = XMLParser::StartElement; saxHandler.endElement = XMLParser::EndElement; saxHandler.characters = XMLParser::Characters; int32 retCode = xmlSAXUserParseMemory( &saxHandler, (void*)delegateptr, (char *)bytes, length); // Logger::Debug("[XMLParser::ParseBytes] retCode = %d", retCode); if(0 <= retCode) { retValue = true; } // Logger::Debug("[XMLParser::ParseBytes] retValue = %d", retValue); return retValue; }
bool read_pb_message_from_xml_memory(google::protobuf::Message *document, const char *buffer, int size) { LIBXML_TEST_VERSION xmlSAXHandler sax; init_xmlSAXHandler(&sax); xmlext::Context context; context.stack.push_back(document); context.paths.push_back(""); int result = xmlSAXUserParseMemory(&sax, &context, buffer, size); context.paths.pop_back(); context.stack.pop_back(); if ( result != 0 ) { printf("Failed to parse document.\n" ); return false; } xmlCleanupParser(); xmlMemoryDump(); return true; }
static int rxml_sax_parser_parse_string(VALUE self, VALUE input) { VALUE str = rb_ivar_get(input, STRING_ATTR); return xmlSAXUserParseMemory((xmlSAXHandlerPtr)&rxml_sax_hander_struct, (void *)self, StringValuePtr(str), RSTRING_LEN(str)); }
/** * Login * @param username * @param password * @return Application API key, or NULL if we couldn't log in */ error_t login_doLogin(const char *username, const char *password) { char baseUrl[PATH_MAX]; char url[PATH_MAX]; char rxBuffer[PROXY_MAX_MSG_LEN]; char headerPassword[PROXY_HEADER_PASSWORD_LEN]; http_param_t params; login_info_t loginInfo; bzero(¶ms, sizeof(params)); xmlSAXHandler saxHandler = { NULL, // internalSubsetHandler, NULL, // isStandaloneHandler, NULL, // hasInternalSubsetHandler, NULL, // hasExternalSubsetHandler, NULL, // resolveEntityHandler, NULL, // getEntityHandler, NULL, // entityDeclHandler, NULL, // notationDeclHandler, NULL, // attributeDeclHandler, NULL, // elementDeclHandler, NULL, // unparsedEntityDeclHandler, NULL, // setDocumentLocatorHandler, NULL, // startDocument NULL, // endDocument _login_xml_startElementHandler, // startElement NULL, // endElement NULL, // reference, _login_xml_charactersHandler, //characters NULL, // ignorableWhitespace NULL, // processingInstructionHandler, NULL, // comment NULL, // warning NULL, // error NULL, // fatal }; // Read the activation URL from the configuration file if(libconfigio_read(proxycli_getConfigFilename(), CONFIGIO_ACTIVATION_URL_TOKEN_NAME, baseUrl, sizeof(baseUrl)) == -1) { printf("Couldn't read %s in file %s, writing default value\n", CONFIGIO_ACTIVATION_URL_TOKEN_NAME, proxycli_getConfigFilename()); libconfigio_write(proxycli_getConfigFilename(), CONFIGIO_ACTIVATION_URL_TOKEN_NAME, DEFAULT_ACTIVATION_URL); strncpy(baseUrl, DEFAULT_ACTIVATION_URL, sizeof(baseUrl)); } snprintf(url, sizeof(url), "%s/login?username=%s", baseUrl, username); snprintf(headerPassword, sizeof(headerPassword), "PASSWORD: %s", password); SYSLOG_INFO("Logging in..."); SYSLOG_INFO("Contacting URL %s\n", url); params.verbose = TRUE; params.timeouts.connectTimeout = HTTPCOMM_DEFAULT_CONNECT_TIMEOUT_SEC; params.timeouts.transferTimeout = HTTPCOMM_DEFAULT_TRANSFER_TIMEOUT_SEC; params.password = headerPassword; libhttpcomm_sendMsg(NULL, CURLOPT_HTTPGET, url, NULL, NULL, NULL, 0, rxBuffer, sizeof(rxBuffer), params, NULL); SYSLOG_INFO("Server returned: \n%s\n", rxBuffer); loginInfo.resultCode = -1; if ( 0 == xmlSAXUserParseMemory(&saxHandler, &loginInfo, rxBuffer, strlen(rxBuffer)) ) { if(loginInfo.resultCode == 0) { printf("Login successful!\n"); SYSLOG_INFO("Login successful"); return SUCCESS; } else { printf("Error logging in\n"); return FAIL; } } printf("Error logging in\n"); return FAIL; }
void DFSAXParserParse(DFSAXParser *parser, const void *data, size_t len) { xmlSAXHandler handler; DFSAXSetup(&handler); xmlSAXUserParseMemory(&handler,parser,data,(int)len); }
/** * Register Device * @return */ error_t registerDevice(void) { char url[PATH_MAX]; char baseUrl[PATH_MAX]; char deviceType[8]; char rxBuffer[PROXY_MAX_MSG_LEN]; char headerApiKey[PROXY_HEADER_KEY_LEN]; char eui64[EUI64_STRING_SIZE+8]; http_param_t params; registrationinfo_info_t registrationInfo; bzero(¶ms, sizeof(params)); xmlSAXHandler saxHandler = { NULL, // internalSubsetHandler, NULL, // isStandaloneHandler, NULL, // hasInternalSubsetHandler, NULL, // hasExternalSubsetHandler, NULL, // resolveEntityHandler, NULL, // getEntityHandler, NULL, // entityDeclHandler, NULL, // notationDeclHandler, NULL, // attributeDeclHandler, NULL, // elementDeclHandler, NULL, // unparsedEntityDeclHandler, NULL, // setDocumentLocatorHandler, NULL, // startDocument NULL, // endDocument _registrationinfo_xml_startElementHandler, // startElement NULL, // endElement NULL, // reference, _registrationinfo_xml_charactersHandler, //characters NULL, // ignorableWhitespace NULL, // processingInstructionHandler, NULL, // comment NULL, // warning NULL, // error NULL, // fatal }; bzero(deviceType, sizeof(deviceType)); bzero(¶ms, sizeof(params)); snprintf(headerApiKey, sizeof(headerApiKey), "FABRUX_API_KEY: %s", login_getApiKey()); // Read the device type from the configuration file if(libconfigio_read(proxycli_getConfigFilename(), CONFIGIO_PROXY_DEVICE_TYPE_TOKEN_NAME, deviceType, sizeof(deviceType)) == -1) { printf("Couldn't read %s in file %s, writing default value\n", CONFIGIO_PROXY_DEVICE_TYPE_TOKEN_NAME, proxycli_getConfigFilename()); libconfigio_write(proxycli_getConfigFilename(), CONFIGIO_PROXY_DEVICE_TYPE_TOKEN_NAME, DEFAULT_PROXY_DEVICETYPE); strncpy(deviceType, DEFAULT_PROXY_DEVICETYPE, sizeof(deviceType)); } // Read the activation URL from the configuration file if(libconfigio_read(proxycli_getConfigFilename(), CONFIGIO_ACTIVATION_URL_TOKEN_NAME, baseUrl, sizeof(baseUrl)) == -1) { printf("Couldn't read %s in file %s, writing default value\n", CONFIGIO_ACTIVATION_URL_TOKEN_NAME, proxycli_getConfigFilename()); libconfigio_write(proxycli_getConfigFilename(), CONFIGIO_ACTIVATION_URL_TOKEN_NAME, DEFAULT_ACTIVATION_URL); strncpy(baseUrl, DEFAULT_ACTIVATION_URL, sizeof(baseUrl)); } eui64_toString(eui64, sizeof(eui64)); // https://developer.presencepro.com/cloud/json/devices/001C42DE23CF-4-33F?productId=4 snprintf(url, sizeof(url), "%s/devices/%s?productId=%s", baseUrl, eui64, deviceType); SYSLOG_INFO("Register device..."); SYSLOG_INFO("Contacting URL %s\n", url); params.verbose = TRUE; params.timeouts.connectTimeout = HTTPCOMM_DEFAULT_CONNECT_TIMEOUT_SEC; params.timeouts.transferTimeout = HTTPCOMM_DEFAULT_TRANSFER_TIMEOUT_SEC; params.key = headerApiKey; libhttpcomm_postMsg(NULL, CURLOPT_HTTPPOST, url, NULL, NULL, "", 0, rxBuffer, sizeof(rxBuffer), params, NULL); SYSLOG_INFO("Server returned: \n%s\n", rxBuffer); registrationInfo.resultCode = -1; if ( 0 == xmlSAXUserParseMemory(&saxHandler, ®istrationInfo, rxBuffer, strlen(rxBuffer)) ) { if(registrationInfo.resultCode == 0) { printf("Register device successful!\n"); SYSLOG_INFO("Register device successful"); return SUCCESS; } else { printf("Error register device\n"); return FAIL; } } printf("Error register device\n"); return FAIL; }
void Stub_Configurations::Deserialize(std::string source) { xmlSAXUserParseMemory(GetXmlHandler(), this, source.c_str(), int(source.length())); xmlCleanupParser(); }
/* <ServiceDiscovery xmlns="urn:dvb:ipisdns:2006"> <PackageDiscovery DomainName="imagenio.es" Version="87"> <Package Id="1"> <PackageName Language="ENG">UTX00</PackageName> <Service> <TextualID ServiceName="597"/> <LogicalChannelNumber>0</LogicalChannelNumber> </Service> <Service> <TextualID ServiceName="1"/> <LogicalChannelNumber>1</LogicalChannelNumber> </Service> <Service> .... .... */ list_s * mtv_parse_file_type_5(const char *xml, const char *tvpackages) { struct type_5_parser_context *ctx = NULL; error_if(NULL == xml, error, "Param Error: empty XML!"); error_if(NULL == tvpackages, error, "Param Error: empty tvpackages"); ctx = _ctx_alloc(); error_if(NULL == ctx, error, "Error Allocating Memory: %s", strerror(errno)); ctx->in_valid_package = false; ctx->tvpackages = (char *)tvpackages; LIBXML_TEST_VERSION; xmlSAXHandler handler = { 0, /* internalSubset */ 0, /* isStandalone */ 0, /* hasInternalSubset */ 0, /* hasExternalSubset */ 0, /* resolveEntity */ (getEntitySAXFunc) _get_entity, /* getEntity */ 0, /* entityDecl */ 0, /* notationDecl */ 0, /* attributeDecl */ 0, /* elementDecl */ 0, /* unparsedEntityDecl */ 0, /* setDocumentLocator */ 0, /* startDocument */ 0, /* endDocument */ (startElementSAXFunc) _start_element, /* startElement */ (endElementSAXFunc) _end_element, /* startElement */ 0, /* reference */ (charactersSAXFunc) _characters, /* characters */ 0, /* ignorableWhitespace */ 0, /* processingInstruction */ 0, /* comment */ (warningSAXFunc) _warning, /* warning */ (errorSAXFunc) _error, /* error */ (fatalErrorSAXFunc) _error, /* fatalError */ 0, /* fatalError //: unused error() get all the errors */ 0, /* getParameterEntity */ 0, /* cdataBlock */ 0, /* externalSubset */ 0, /* initialized */ 0, /* private */ 0, /* startElementNs */ 0, /* endElementNs */ }; int result = xmlSAXUserParseMemory(&handler, ctx, (char *)xml, strlen(xml)); error_if(0 != result, error, "Error Parsing xml: \n%s\n", xml); trace("Hay %zu channels after parsing", list_count(ctx->channels)); error_if (!ctx->channels, error, "Error reading channels order"); error_if (list_count(ctx->channels) == 0, error, "Error reading channels order"); list_s *channels = ctx->channels; ctx->channels = NULL; _ctx_free(ctx); // xmlCleanupParser(); // xmlMemoryDump(); return channels; error: if (ctx) _ctx_free(ctx); xmlCleanupParser(); xmlMemoryDump(); return NULL; }
void Stub_SentimentPhrase::Deserialize(std::string source) { xmlSAXUserParseMemory(GetXmlHandler(), this, source.c_str(), int(source.length())); xmlCleanupParser(); }
void ServiceStatus::Deserialize(std::string source) { xmlSAXHandler* handler = GetXmlHandler(); int result = xmlSAXUserParseMemory(handler, this, source.c_str(), int(source.length())); xmlCleanupParser(); }
/** * Get the activation key from the server * @param key Application API key from logging in * @param locationId The location ID for this user * @return the activation key for this device */ char *getactivationinfo_getDeviceActivationKey(const char *key, int locationId) { char url[PATH_MAX]; char baseUrl[PATH_MAX]; char deviceType[8]; char rxBuffer[PROXY_MAX_MSG_LEN]; char headerApiKey[PROXY_HEADER_KEY_LEN]; http_param_t params; getactivationinfo_info_t getActivationInfo; xmlSAXHandler saxHandler = { NULL, // internalSubsetHandler, NULL, // isStandaloneHandler, NULL, // hasInternalSubsetHandler, NULL, // hasExternalSubsetHandler, NULL, // resolveEntityHandler, NULL, // getEntityHandler, NULL, // entityDeclHandler, NULL, // notationDeclHandler, NULL, // attributeDeclHandler, NULL, // elementDeclHandler, NULL, // unparsedEntityDeclHandler, NULL, // setDocumentLocatorHandler, NULL, // startDocument NULL, // endDocument _getactivationinfo_xml_startElementHandler, // startElement NULL, // endElement NULL, // reference, _getactivationinfo_xml_charactersHandler, //characters NULL, // ignorableWhitespace NULL, // processingInstructionHandler, NULL, // comment NULL, // warning NULL, // error NULL, // fatal }; if(activationKeyValid) { return activationKey; } bzero(deviceType, sizeof(deviceType)); bzero(¶ms, sizeof(params)); snprintf(headerApiKey, sizeof(headerApiKey), "FABRUX_API_KEY: %s", login_getApiKey()); // Read the device type from the configuration file if(libconfigio_read(proxycli_getConfigFilename(), CONFIGIO_PROXY_DEVICE_TYPE_TOKEN_NAME, deviceType, sizeof(deviceType)) == -1) { printf("Couldn't read %s in file %s, writing default value\n", CONFIGIO_PROXY_DEVICE_TYPE_TOKEN_NAME, proxycli_getConfigFilename()); libconfigio_write(proxycli_getConfigFilename(), CONFIGIO_PROXY_DEVICE_TYPE_TOKEN_NAME, DEFAULT_PROXY_DEVICETYPE); strncpy(deviceType, DEFAULT_PROXY_DEVICETYPE, sizeof(deviceType)); } // Read the activation URL from the configuration file if(libconfigio_read(proxycli_getConfigFilename(), CONFIGIO_ACTIVATION_URL_TOKEN_NAME, baseUrl, sizeof(baseUrl)) == -1) { printf("Couldn't read %s in file %s, writing default value\n", CONFIGIO_ACTIVATION_URL_TOKEN_NAME, proxycli_getConfigFilename()); libconfigio_write(proxycli_getConfigFilename(), CONFIGIO_ACTIVATION_URL_TOKEN_NAME, DEFAULT_ACTIVATION_URL); strncpy(baseUrl, DEFAULT_ACTIVATION_URL, sizeof(baseUrl)); } snprintf(url, sizeof(url), "%s/locations/%d/deviceActivation/%s", baseUrl, locationId, deviceType); //SYSLOG_INFO("Getting device activation key..."); SYSLOG_INFO("Contacting URL %s\n", url); params.verbose = TRUE; params.timeouts.connectTimeout = HTTPCOMM_DEFAULT_CONNECT_TIMEOUT_SEC; params.timeouts.transferTimeout = HTTPCOMM_DEFAULT_TRANSFER_TIMEOUT_SEC; params.key = headerApiKey; libhttpcomm_sendMsg(NULL, CURLOPT_HTTPGET, url, NULL, NULL, NULL, 0, rxBuffer, sizeof(rxBuffer), params, NULL); SYSLOG_INFO("Server returned: \n%s\n", rxBuffer); getActivationInfo.resultCode = -1; xmlSAXUserParseMemory(&saxHandler, &getActivationInfo, rxBuffer, strlen(rxBuffer)); if(getActivationInfo.resultCode == 0) { printf("Downloaded the secret activation key!\n"); activationKeyValid = true; return activationKey; } else { printf("Error getting activation key. Check the syslogs.\n"); return NULL; } }