638 } |
638 } |
639 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) { |
639 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BUSY", "%d", tmp4->busy)) < 0) { |
640 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
640 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
641 return 1; |
641 return 1; |
642 } |
642 } |
643 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) { |
643 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP_LO", "%.1f", tmp4->inittemp_lo)) < 0) { |
|
644 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
645 return 1; |
|
646 } |
|
647 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP_HI", "%.1f", tmp4->inittemp_hi)) < 0) { |
|
648 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
649 return 1; |
|
650 } |
|
651 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_MODE", "%d", tmp4->fridge_mode)) < 0) { |
644 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
652 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
645 return 1; |
653 return 1; |
646 } |
654 } |
647 if (tmp4->steps) { |
655 if (tmp4->steps) { |
648 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) { |
656 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "STEPS")) < 0) { |
664 } |
672 } |
665 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) { |
673 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STEPTIME", "%d", tmp5->steptime)) < 0) { |
666 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
674 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
667 return 1; |
675 return 1; |
668 } |
676 } |
669 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) { |
677 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET_LO", "%.1f", tmp5->target_lo)) < 0) { |
670 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
678 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
679 return 1; |
|
680 } |
|
681 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET_HI", "%.1f", tmp5->target_hi)) < 0) { |
|
682 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
683 return 1; |
|
684 } |
|
685 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_MODE", "%d", tmp5->fridge_mode)) < 0) { |
|
686 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
671 return 1; |
687 return 1; |
672 } |
688 } |
673 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
689 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
674 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
690 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
675 return 1; |
691 return 1; |
1434 prof_step *step, *tmp; |
1450 prof_step *step, *tmp; |
1435 |
1451 |
1436 step = (prof_step *)malloc(sizeof(prof_step)); |
1452 step = (prof_step *)malloc(sizeof(prof_step)); |
1437 step->next = NULL; |
1453 step->next = NULL; |
1438 step->version = 1; |
1454 step->version = 1; |
1439 step->steptime = step->resttime = 0; |
1455 step->steptime = step->resttime = step->fridge_mode = 0; |
1440 step->target = 20.0; |
1456 step->target_lo = step->target_hi = 20.0; |
1441 |
1457 |
1442 cur = cur->xmlChildrenNode; |
1458 cur = cur->xmlChildrenNode; |
1443 while (cur != NULL) { |
1459 while (cur != NULL) { |
1444 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
1460 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
1445 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1461 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1460 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1476 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1461 if (sscanf((const char *)key, "%d", &ival) == 1) |
1477 if (sscanf((const char *)key, "%d", &ival) == 1) |
1462 step->steptime = ival; |
1478 step->steptime = ival; |
1463 xmlFree(key); |
1479 xmlFree(key); |
1464 } |
1480 } |
1465 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) { |
1481 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) { /* Upgrade from single values */ |
1466 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1482 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1467 if (sscanf((const char *)key, "%f", &val) == 1) |
1483 if (sscanf((const char *)key, "%f", &val) == 1) { |
1468 step->target = val; |
1484 step->target_lo = val - 0.2; |
|
1485 step->target_hi = val + 0.2; |
|
1486 } |
|
1487 xmlFree(key); |
|
1488 } |
|
1489 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET_LO"))) { |
|
1490 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1491 if (sscanf((const char *)key, "%f", &val) == 1) |
|
1492 step->target_lo = val; |
|
1493 xmlFree(key); |
|
1494 } |
|
1495 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET_HI"))) { |
|
1496 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1497 if (sscanf((const char *)key, "%f", &val) == 1) |
|
1498 step->target_hi = val; |
|
1499 xmlFree(key); |
|
1500 } |
|
1501 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_MODE"))) { |
|
1502 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1503 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1504 step->fridge_mode = ival; |
1469 xmlFree(key); |
1505 xmlFree(key); |
1470 } |
1506 } |
1471 cur = cur->next; |
1507 cur = cur->next; |
1472 } |
1508 } |
1473 |
1509 |
1509 |
1545 |
1510 profile = (profiles_list *)malloc(sizeof(profiles_list)); |
1546 profile = (profiles_list *)malloc(sizeof(profiles_list)); |
1511 profile->next = NULL; |
1547 profile->next = NULL; |
1512 profile->version = 1; |
1548 profile->version = 1; |
1513 profile->uuid = profile->name = NULL; |
1549 profile->uuid = profile->name = NULL; |
1514 profile->busy = 0; |
1550 profile->busy = profile->fridge_mode = 0; |
1515 profile->inittemp = 20.0; |
1551 profile->inittemp_lo = profile->inittemp_hi = 20.0; |
1516 profile->steps = NULL; |
1552 profile->steps = NULL; |
1517 |
1553 |
1518 cur = cur->xmlChildrenNode; |
1554 cur = cur->xmlChildrenNode; |
1519 while (cur != NULL) { |
1555 while (cur != NULL) { |
1520 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
1556 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
1536 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1572 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1537 if (sscanf((const char *)key, "%d", &ival) == 1) |
1573 if (sscanf((const char *)key, "%d", &ival) == 1) |
1538 profile->busy = ival; |
1574 profile->busy = ival; |
1539 xmlFree(key); |
1575 xmlFree(key); |
1540 } |
1576 } |
1541 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) { |
1577 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) { /* Upgrade from single temp */ |
|
1578 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1579 if (sscanf((const char *)key, "%f", &fval) == 1) { |
|
1580 profile->inittemp_lo = fval - 0.2; |
|
1581 profile->inittemp_hi = fval + 0.2; |
|
1582 } |
|
1583 xmlFree(key); |
|
1584 } |
|
1585 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP_LO"))) { |
1542 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1586 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1543 if (sscanf((const char *)key, "%f", &fval) == 1) |
1587 if (sscanf((const char *)key, "%f", &fval) == 1) |
1544 profile->inittemp = fval; |
1588 profile->inittemp_lo = fval; |
|
1589 xmlFree(key); |
|
1590 } |
|
1591 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP_HI"))) { |
|
1592 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1593 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1594 profile->inittemp_hi = fval; |
|
1595 xmlFree(key); |
|
1596 } |
|
1597 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_MODE"))) { |
|
1598 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1599 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1600 profile->fridge_mode = ival; |
1545 xmlFree(key); |
1601 xmlFree(key); |
1546 } |
1602 } |
1547 if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPS"))) { |
1603 if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPS"))) { |
1548 parseSteps(doc, cur, &(profile)->steps); |
1604 parseSteps(doc, cur, &(profile)->steps); |
1549 } |
1605 } |