# HG changeset patch # User Michiel Broek # Date 1403718123 -7200 # Node ID eb9dd60aa7914027d098c30ecdffdb9b866d1708 # Parent c49ab5179bf39e9a9490518e83cba8f4123de7bf Added uuid library diff -r c49ab5179bf3 -r eb9dd60aa791 config.h.in --- a/config.h.in Wed Jun 25 17:18:01 2014 +0200 +++ b/config.h.in Wed Jun 25 19:42:03 2014 +0200 @@ -14,7 +14,3 @@ /* Define if you have the header file. */ #undef HAVE_MOSQUITTO_H - -/* Define if you have the header file. */ -#undef HAVE_LIBXML_PARSER_H - diff -r c49ab5179bf3 -r eb9dd60aa791 configure --- a/configure Wed Jun 25 17:18:01 2014 +0200 +++ b/configure Wed Jun 25 19:42:03 2014 +0200 @@ -2032,7 +2032,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.0.8" +VERSION="0.0.9" COPYRIGHT="Copyright (C) 2014 Michiel Broek, All Rights Reserved" CYEARS="2014" @@ -3597,7 +3597,6 @@ fi -LIBXML2=No { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlParseFile in -lxml2" >&5 $as_echo_n "checking for xmlParseFile in -lxml2... " >&6; } if ${ac_cv_lib_xml2_xmlParseFile+:} false; then : @@ -3650,9 +3649,7 @@ cat >>confdefs.h <<_ACEOF #define HAVE_LIBXML_XMLMEMORY_H 1 _ACEOF - LIBXML2=Yes -else - LIBXML2=No + fi done @@ -3661,6 +3658,66 @@ as_fn_error $? "libxml2 not found" "$LINENO" 5 fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5 +$as_echo_n "checking for uuid_generate in -luuid... " >&6; } +if ${ac_cv_lib_uuid_uuid_generate+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-luuid $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char uuid_generate (); +int +main () +{ +return uuid_generate (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_uuid_uuid_generate=yes +else + ac_cv_lib_uuid_uuid_generate=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5 +$as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; } +if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then : + result=yes +else + result=no +fi + +if test "$result" = "yes"; then + LIBS="$LIBS $(pkg-config --libs uuid)" + CFLAGS="$CFLAGS $(pkg-config --cflags uuid)" + for ac_header in uuid/uuid.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" +if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_UUID_UUID_H 1 +_ACEOF + +fi + +done + +else + as_fn_error $? "libuuid not found" "$LINENO" 5 +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 @@ -5062,7 +5119,6 @@ Version : ............ ${VERSION} Main directory : ..... ${prefix} WiringPi : ........... ${WIRINGPI} - XML2: ................ ${LIBXML2} Now type 'make' and 'sudo make install' " >&5 @@ -5074,7 +5130,6 @@ Version : ............ ${VERSION} Main directory : ..... ${prefix} WiringPi : ........... ${WIRINGPI} - XML2: ................ ${LIBXML2} Now type 'make' and 'sudo make install' " >&6; } diff -r c49ab5179bf3 -r eb9dd60aa791 configure.ac --- a/configure.ac Wed Jun 25 17:18:01 2014 +0200 +++ b/configure.ac Wed Jun 25 19:42:03 2014 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.0.8" +VERSION="0.0.9" COPYRIGHT="Copyright (C) 2014 Michiel Broek, All Rights Reserved" CYEARS="2014" AC_SUBST(PACKAGE) @@ -63,16 +63,23 @@ fi -LIBXML2=No AC_CHECK_LIB(xml2,xmlParseFile,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lxml2" CFLAGS="$CFLAGS $(xml2-config --cflags)" - AC_CHECK_HEADERS(libxml/xmlmemory.h,LIBXML2=Yes,LIBXML2=No) + AC_CHECK_HEADERS(libxml/xmlmemory.h) else AC_MSG_ERROR(libxml2 not found) fi +AC_CHECK_LIB(uuid,uuid_generate,result=yes,result=no) +if test "$result" = "yes"; then + LIBS="$LIBS $(pkg-config --libs uuid)" + CFLAGS="$CFLAGS $(pkg-config --cflags uuid)" + AC_CHECK_HEADERS(uuid/uuid.h) +else + AC_MSG_ERROR(libuuid not found) +fi dnl Checks for header files. @@ -93,7 +100,6 @@ Version : ............ ${VERSION} Main directory : ..... ${prefix} WiringPi : ........... ${WIRINGPI} - XML2: ................ ${LIBXML2} Now type 'make' and 'sudo make install' ]) diff -r c49ab5179bf3 -r eb9dd60aa791 thermferm/server.c --- a/thermferm/server.c Wed Jun 25 17:18:01 2014 +0200 +++ b/thermferm/server.c Wed Jun 25 19:42:03 2014 +0200 @@ -70,6 +70,44 @@ +int unit_add(char *name) +{ + units_list *unit, *tmp; + uuid_t uu; + + unit = (units_list *)malloc(sizeof(units_list)); + unit->next = NULL; + unit->uuid = malloc(37); + uuid_generate(uu); + uuid_unparse(uu, unit->uuid); + unit->name = xstrcpy(name); + unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL; + unit->volume = 0.0; + unit->heater_available = unit->cooler_available = unit->fan_available = FALSE; + unit->air_temp = unit->beer_temp = unit->beer_set = unit->fridge_set = 20.0; + unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = 0; + unit->temp_set_min = 1.0; + unit->temp_set_max = 30.0; + unit->idle_rangeH = 1.0; + unit->idle_rangeL = -1.0; + unit->prof_started = (time_t)0; + + + if (Config.units == NULL) { + Config.units = unit; + } else { + for (tmp = Config.units; tmp; tmp = tmp->next) { + if (tmp->next == NULL) { + tmp->next = unit; + break; + } + } + } + return 0; +} + + + /* * Send message to client */ diff -r c49ab5179bf3 -r eb9dd60aa791 thermferm/thermferm.h --- a/thermferm/thermferm.h Wed Jun 25 17:18:01 2014 +0200 +++ b/thermferm/thermferm.h Wed Jun 25 19:42:03 2014 +0200 @@ -28,6 +28,7 @@ #include #include #include +#include #ifndef HAVE_WIRINGPI_H #include #endif