Revision eca395a2 ALTOclient/ALTOclient.c

View differences:

ALTOclient/ALTOclient.c
444 444

  
445 445
	memset(alto_reply_buf_nano, 0, ALTO_REP_BUF_SIZE);
446 446

  
447
	//bytesRead = xmlNanoHTTPRead(ctx, &alto_reply_buf_nano, ALTO_REP_BUF_SIZE);
447
//	bytesSum = xmlNanoHTTPRead(ctx, &alto_reply_buf_nano, ALTO_REP_BUF_SIZE);
448 448
	#define BLOCK_SIZE 4096
449 449
	bytesRead = xmlNanoHTTPRead(ctx, alto_reply_buffer_ptr, BLOCK_SIZE);
450 450
	bytesSum += bytesRead;
......
464 464
	fwrite(output, 1, strlen(output), f);
465 465
	fclose(f);*/
466 466

  
467
	result = xmlRecoverMemory(alto_reply_buf_nano, bytesRead);
467
	result = xmlRecoverMemory(alto_reply_buf_nano, bytesSum);
468 468
//
469 469
// TODO: PushParser doesn't work yet somehow..
470 470
//
......
918 918

  
919 919
	xmlNode *cur = NULL;
920 920
	cur = xmlDocGetRootElement(doc);
921
	xmlChar *overall_rating, *ipprefix = NULL;
921
	xmlChar *overall_rating = NULL;
922
	xmlChar *ipprefix = NULL;
922 923

  
923 924
	while(cur!=NULL){
924 925
		if(!xmlStrcmp(cur->name, BAD_CAST "cnd_hla")){
925 926
			overall_rating = xmlGetProp(cur, BAD_CAST "overall_rating");
926 927
		}if(!xmlStrcmp(cur->name, BAD_CAST "ipprefix")){
927 928
			ipprefix = xmlGetProp(cur, BAD_CAST "prefix");
929
			if (!ipprefix) {
930
				alto_debugf("Couldn't find ipprefix!\n");
931
				break;
932
			}
928 933

  
929 934
			// create the ALTO element
930 935
			struct alto_db_element_t *element;
931 936
			element = malloc(sizeof(ALTO_DB_ELEMENT_T));
932 937
			element->host = get_ALTO_host_IP((char*) ipprefix);
933 938
			element->host_mask = get_ALTO_host_mask((char*) ipprefix);
934
			element->rating = atoi(overall_rating);
939
			if (overall_rating) {
940
				element->rating = atoi(overall_rating);
941
				alto_debugf("rating %s = %d\n", ipprefix, overall_rating);
942
			} else {
943
				overall_rating = 0;
944
				alto_debugf("rating %s = %d (DEFAULT, host not in DB!)\n", ipprefix, overall_rating);
945
			}
935 946

  
936 947
			// and add this element to the db
937 948
			alto_add_element(db, element);

Also available in: Unified diff