powerguru-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Powerguru-commit] [SCM] powerguru branch, master, updated. 63204e297201


From: Rob Savoye
Subject: [Powerguru-commit] [SCM] powerguru branch, master, updated. 63204e297201afa9656e79e698e6446dfa6cb8cd
Date: Fri, 7 Dec 2018 16:48:28 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "powerguru".

The branch, master has been updated
       via  63204e297201afa9656e79e698e6446dfa6cb8cd (commit)
       via  9e79c3319625d9284232bf4e1855c4c79d2a6f17 (commit)
       via  52bfe9f6f0212fb16919359e859ac3de687af734 (commit)
       via  18b2dabae8efd92bcb66c7bc6b8964f711c62885 (commit)
       via  05da692915c364447ded39876b561d7302b94278 (commit)
       via  040bb86c84f16aba7dbc43ba88d3ad5fd7109ef4 (commit)
       via  653453559c8f026eb1dde28f74aaeb935067ae13 (commit)
       via  ec4d70534976277e5720251589beddc2a93f0532 (commit)
       via  d647c27ff95e208501a47d8220238d428f491c4c (commit)
       via  dc7a2567c8fd198a8d0e35a2862d911adb6c88f3 (commit)
       via  2b27313d9b51da89e9659d6f97ce40a46c1784cb (commit)
       via  4db90d3ca3dd0a89c689094bac0400b813c7cd51 (commit)
       via  feec31a525dee5a0c1ff0e8ff128456c7383d316 (commit)
      from  7ae481f5ea8785eef8564650c2c19c55448bd708 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=63204e297201afa9656e79e698e6446dfa6cb8cd


commit 63204e297201afa9656e79e698e6446dfa6cb8cd
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:47:50 2018 -0700

    Drop errcode class, add thrad for console

diff --git a/daemon/main.cc b/daemon/main.cc
index 35e90d0..1a51924 100644
--- a/daemon/main.cc
+++ b/daemon/main.cc
@@ -41,24 +41,23 @@ extern char *optarg;
 
 // local header files
 #include "log.h"
-#include "err.h"
-//#ifdef BUILD_XANTREX
-#include "xantrex-trace.h"
-//#endif
+#ifdef BUILD_XANTREX
+include "xantrex-trace.h"
+#endif
 #ifdef BUILD_OUTBACK
 #include "outbackpower.h"
+#include "msgs.h"
 #endif
-//#ifdef BUILD_OWNET
+#ifdef BUILD_OWNET
 #include "ownet.h"
-//#endif
-#include "console.h"
+#endif
 #include "menuitem.h"
 #include "database.h"
 #include "snmp.h"
 #include "rc.h"
 #include "tcpip.h"
-#include "msgs.h"
 #include "xml.h"
+#include "serial.h"
 
 using namespace std;
 using namespace rcinit;
@@ -72,6 +71,7 @@ alarm_handler2 (int sig);
 
 int curses = 0;
 
+extern void client_handler(void);
 extern void ownet_handler(pdev::Ownet &);
 extern void outback_handler(pdev::Ownet &);
 extern void xantrex_handler(pdev::Ownet &);
@@ -80,13 +80,11 @@ int
 main(int argc, char *argv[])
 {
     int c, i;
-    ErrCond Err;
     string item, str;
     const char *filespec;
     MenuItem ti;
     string hostname;
     bool poll;
-    bool console;
     bool use_db;
     bool snmp;
     bool daemon;
@@ -102,12 +100,9 @@ main(int argc, char *argv[])
 #endif
     retcode_t   ret;
     std::condition_variable alldone;
-#if defined(HAVE_MARIADB) && defined(HAVE_POSTGRESQL)
+#if defined(HAVE_MARIADB) || defined(HAVE_POSTGRESQL)
     Database pdb;
 #endif
-    //    XantrexUI ui;
-    //    Console con;
-
     if (argc == 1) {
         //usage(argv[0]);
     }
@@ -126,7 +121,6 @@ main(int argc, char *argv[])
 
     // Set the option flags to default values. We do it this way to
     // shut up GCC complaining they're not used.
-    console = false;
     poll = false;
     daemon = true;
     client = false;
@@ -146,21 +140,6 @@ main(int argc, char *argv[])
     // the command line arguments.
     RCinitFile config;
     config.load_files();
-#if defined(HAVE_MARIADB) && defined(HAVE_POSTGRESQL)
-    if (config.dbhostGet().size() > 0) {
-        pdb.dbHostSet(config.dbhostGet());
-    }
-    if (config.dbnameGet().size() > 0) {    
-        pdb.dbNameSet(config.dbnameGet());
-    }
-    if (config.dbuserGet().size() > 0) {    
-        pdb.dbUserSet(config.dbuserGet());
-    }
-    if (config.dbpasswdGet().size() > 0) {    
-        pdb.dbPasswdSet(config.dbpasswdGet());
-    }
-#endif
-
     if (config.deviceGet().size() > 0) {    
         filespec = (char *)config.deviceGet().c_str();
     }
@@ -174,23 +153,6 @@ main(int argc, char *argv[])
               //xantrexmode = true;     // FIXME: force xantrex mode for now
               break;
 
-#if 0
-          case 'i':
-              ui.Dump();
-              exit(0);
-              break;
-
-          case 'a':
-              ui.DumpAliases();
-              exit(0);
-              break;
-
-          case 'i':
-              item = strdup(optarg);
-              monitor = true;
-              break;
-#endif
-        
           case 'd':
               filespec = strdup(optarg);
               break;
@@ -199,11 +161,6 @@ main(int argc, char *argv[])
               usage (argv[0]);
               break;
 
-          case 'x':
-              //console = true;
-              //xantrexmode = true;
-              break;
-
           case 'o':
               //outbackmode = true;
               break;
@@ -265,15 +222,15 @@ main(int argc, char *argv[])
         }
     }
 
-    // Open the network connection to the database.
-#if defined(HAVE_MARIADB) && defined(HAVE_POSTGRESQL)
-    if (use_db) {
-        if (!pdb.openDB()) {
-            dbglogfile << "ERROR: Couldn't open database!" << endl;
-            exit(1);
-        }
-    }
-#endif
+//     // Open the network connection to the database.
+// #if defined(HAVE_MARIADB) && defined(HAVE_POSTGRESQL)
+//     if (use_db) {
+//         if (!pdb.openDB()) {
+//             dbglogfile << "ERROR: Couldn't open database!" << endl;
+//             exit(1);
+//         }
+//     }
+// #endif
     // Start the SNMP daemon support.
 #ifdef USE_SNMP
     if (snmp) {
@@ -282,56 +239,24 @@ main(int argc, char *argv[])
     }
 #endif
 
-    Console con;
-    // Open a console for user input
-    con.Open();
-
     dbglogfile << "PowerGuru - 1 Wire Mode" << std::endl;
     pdev::Ownet ownet;
-//#ifdef BUILD_OWNET
-    std::thread first (ownet_handler, std::ref(ownet));     // spawn new 
thread that calls foo()
-//#endif
-#ifdef BUILD_OUTBACK
-    std::thread second (outback_handler, std::ref(ownet));  // spawn new 
thread that calls bar(0)
+    std::thread first (client_handler);
+#ifdef BUILD_OWNET
+    //std::thread second (ownet_handler, std::ref(ownet));
 #endif
 #ifdef BUILD_XANTREX
-    std::thread third (xantrex_handler, std::ref(ownet));  // spawn new thread 
that calls bar(0)
+    std::thread third (xantrex_handler, std::ref(ownet));
 #endif
+#ifdef BUILD_OUTBACK
+    std::thread fourth(outback_handler, std::ref(ownet));
+#endif
+//    std::thread forth (console_handler, std::ref(con));
+//    std::thread forth (msg_handler, std::ref(pdb));
     
-#if 0
-    //if (poll) {
-    int ch;
-    while ((ch = con.Getc()) != 'q') {
-        if (ch > 0) {                // If we have something, process it
-            con.Putc (ch);          // echo inputted character to screen
-            switch (ch) {
-              case '?':
-                  con.Puts("Powerguru daemon\r\n");
-                  con.Puts("\t? - help\r\n");
-                  con.Puts("\r\n");
-                  break;
-              case 'q':
-                  exit(0);
-              case 'r':
-                  std::cout << "XXXXXX: " << 
ownet.getValue("/10.67C6697351FF", "/temperature") << std::endl;
-                  break;
-              case 'd':
-                  ownet.dump();
-                  break;
-            }
-        }
-    }
+#ifdef BUILD_OUTBACK
 
-#endif
-#if defined(HAVE_MARIADB) && defined(HAVE_POSTGRESQL)
-    if (use_db) {
-        if (!pdb.closeDB()) {
-            dbglogfile << "ERROR: Couldn't open database!" << endl;
-            exit(1);
-        }
-    }
-#endif
-    // Network daemon/client mode. Normally we're a network daemon that
+// Network daemon/client mode. Normally we're a network daemon that
     // responses to requests by a remote client. Many house networks
     // are behind a firewall, so the daemon can also connect to a
     // publically accessible host to establish the connection the
@@ -340,7 +265,6 @@ main(int argc, char *argv[])
       
         Msgs msg;
         msg.toggleDebug(true);
-      
         // Make a client connection
         if (client == true) {
             msg.init(hostname);
@@ -391,24 +315,27 @@ main(int argc, char *argv[])
                 if (msg.findTag("command")) {
                     cerr << "Got command message!" << endl;
                 }
-                if (xml.parseXML(str) == ERROR) {
+                if (xml.parseMem(str) == ERROR) {
                     continue;
                 }
             }
             messages.clear();
         }
     }
-    con.Reset();
-    con.Close();
-
+    // con.Reset();
+    // con.Close();
+#endif
     // synchronize threads:
     first.join();                // pauses until first finishes
+#ifdef OWNET
+    second.join();                // pauses until second finishes
+#endif
 #ifdef BUILD_OUTBACK
-    second.join();               // pauses until second finishes
+    fourth.join();               // pauses until second finishes
 #endif
 #ifdef BUILD_XANTREX
     third.join();               // pauses until third finishes
-#end
+#endif
 
     exit(0);
 }
@@ -423,7 +350,6 @@ alarm_handler2 (int sig)
     struct sigaction  act;
 #if 0
     int ch;
-    struct errcond Err;
   
 #if 1
     // If there is keyboard input, stop looking for the old
@@ -435,7 +361,7 @@ alarm_handler2 (int sig)
         return;
     }
 #else
-    datasrc.RecvPacket((unsigned char *)&ch, 1, Err);
+    datasrc.RecvPacket((unsigned char *)&ch, 1);
     dbglogfile << " CH is " << ch << endl;
   
     if (ch > 0) {
@@ -463,7 +389,7 @@ usage (const char *prog)
     cerr << "SNMP Mode:" << endl;
     cerr << "\t-j\t\t\t\tEnable SNMP agent mode" << endl;
     cerr << "\t-r\t\t\t\trun in the background as a daemon." << endl;
-
+#if 0
     // Display the End User options
     cerr << "User Options:" << endl;
     // cerr << "\t-s [heading:item or name]\tSet Item value" << endl;
@@ -482,7 +408,8 @@ usage (const char *prog)
     cerr << "\t-x\t\t\t\tXantrex Console mode" << endl;
     cerr << "\t-o\t\t\t\tOutback Console mode" << endl;
     cerr << "\t-e\t\t\t\tEcho Input Mode" << endl;
-  
+#endif
+
     // Display the Database options
     cerr << "Database Options:" << endl;
     cerr << "\t-m hostname\t\t\tSpecify Database hostname or IP" << endl;

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=9e79c3319625d9284232bf4e1855c4c79d2a6f17


commit 9e79c3319625d9284232bf4e1855c4c79d2a6f17
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:39:06 2018 -0700

    Drop __STDC_HOSTED__ as ancint, everything is supported for ages now.

diff --git a/lib/mariadb.cc b/lib/mariadb.cc
index 36e42bc..5fd997f 100644
--- a/lib/mariadb.cc
+++ b/lib/mariadb.cc
@@ -28,11 +28,7 @@
 #include <sys/time.h>
 #include <cstdio>
 
-#ifdef __STDC_HOSTED__
 #include <sstream>
-#else
-#include <strstream>
-#endif
 
 using namespace std;
 
@@ -259,11 +255,7 @@ Database::queryInsert(vector<meter_data_t *> data)
     unsigned int   i;
     //char           query[QUERYLEN];
     //char           *ptr;
-#ifdef __STDC_HOSTED__
     ostringstream  query;
-#else
-    ostrstream     query;
-#endif
 
     if (data.size() == 0) {
         dbglogfile << "No data to insert." << endl;
@@ -293,11 +285,7 @@ Database::queryInsert(meter_data_t *data)
     struct timeval        tp;
     //char                  query[QUERYLEN];
     char                  *type = "MX";
-#ifdef __STDC_HOSTED__
     std::ostringstream    query;
-#else
-    std::ostrstream       query;
-#endif
 
     query.str("");
     //  memset (query, 0, QUERYLEN);
@@ -371,11 +359,7 @@ Database::queryInsert(meter_data_t *data)
     query << ends;
 #endif
 
-#ifdef __STDC_HOSTED__
     string str = query.str().c_str();
-#else
-    string str = query.str();
-#endif
   
     // Execute the query
     queryInsert(str.c_str());
diff --git a/lib/postgresql.cc b/lib/postgresql.cc
index 140d04a..7540588 100644
--- a/lib/postgresql.cc
+++ b/lib/postgresql.cc
@@ -26,12 +26,7 @@
 #include <iomanip> 
 #include <vector>
 #include <cstdio>
-
-#ifdef __STDC_HOSTED__
 #include <sstream>
-#else
-#include <strstream>
-#endif
 
 using namespace std;
 
@@ -168,11 +163,7 @@ Database::queryInsert(vector<meter_data_t *> data)
     unsigned int   i;
     //char           query[QUERYLEN];
     //char           *ptr;
-#ifdef __STDC_HOSTED__
     ostringstream  query;
-#else
-    ostrstream     query;
-#endif
 
     if (data.size() == 0) {
         dbglogfile << "No data to insert." << endl;
@@ -204,11 +195,7 @@ Database::queryInsert(meter_data_t *data)
     struct timeval        tp;
     //char                  query[QUERYLEN];
     char                  *type = "MX";
-#ifdef __STDC_HOSTED__
     std::ostringstream    query;
-#else
-    std::ostrstream       query;
-#endif
 
     query.str("");
     //  memset (query, 0, QUERYLEN);
@@ -221,11 +208,7 @@ Database::queryInsert(meter_data_t *data)
     ttm->tm_year+= 1900;          // years since 1900
     ttm->tm_mon+=1;               // months since January
 
-#ifdef __STDC_HOSTED__
     string str = query.str().c_str();
-#else
-    string str = query.str();
-#endif
   
     // Execute the query
     queryInsert(str.c_str());

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=52bfe9f6f0212fb16919359e859ac3de687af734


commit 52bfe9f6f0212fb16919359e859ac3de687af734
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:38:39 2018 -0700

    Drop optional XML reader, just use DOM parser

diff --git a/lib/xml.cc b/lib/xml.cc
index 20da003..9608b5d 100644
--- a/lib/xml.cc
+++ b/lib/xml.cc
@@ -134,32 +134,6 @@ XML::extractNode(xmlNodePtr node)
     return xml;
 }
 
-#if 0
-// Read in an XML document from the specified source
-bool
-XML::parseRoot(xmlDocPtr document)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-    xmlNodePtr cur;
-  
-    if (document == 0) {
-        dbglogfile << "ERROR: Can't load XML file!";
-        return false;
-    }
-
-    cur = xmlDocGetRootElement(document);
-  
-    if (cur != NULL) {
-        //    msg.dump(top);
-        // msg.process(top);
-        //node = _nodes->push_back(extractNode(cur));
-        //cur = cur->next;
-    }  
-
-    return true;
-}
-#endif
-
 // This reads in an XML file from disk and parses into into a memory resident
 // tree which can be walked through later.
 bool
@@ -175,34 +149,6 @@ XML::parseMem(const std::string &xml_in)
         return false;
     }
 
-#ifndef USE_DMALLOC
-    //dump_memory_stats(__FUNCTION__, __LINE__, "before xmlParseMemory");
-#endif
-
-#ifdef USE_XMLREADER
-    XMLNode *node = 0;
-    xmlTextReaderPtr reader;
-
-    reader = xmlReaderForMemory(xml_in.c_str(), xml_in.size(), NULL, NULL, 0);
-    if (reader != NULL) {
-        ret = true;
-        while (ret) {
-            ret = xmlTextReaderRead(reader);
-            node = processNode(reader, node);
-        }
-        xmlFreeTextReader(reader);
-        if (ret != false) {xg
-            dbglogfile << "couldn't parse" << xml_in << std::endl;
-            return false;
-        }
-    } else {
-        dbglogfile << "Unable to open " << xml_in << std::endl;
-        return false;
-    }
-    xmlCleanupParser();
-    return true;
-#else
-#ifdef USE_DOM
     xmlInitParser();
   
     _doc = xmlParseMemory(xml_in.c_str(), xml_in.size());
@@ -214,14 +160,8 @@ XML::parseMem(const std::string &xml_in)
     xmlCleanupParser();
     xmlFreeDoc(_doc);
     xmlMemoryDump();
-#endif
-#ifndef USE_DMALLOC
-    //dump_memory_stats(__FUNCTION__, __LINE__, "after xmlParseMemory");
-#endif
 
-    return ret;
-#endif
-  
+    return ret;  
 }
 
 //     XML_READER_TYPE_NONE = 0
@@ -249,115 +189,6 @@ const char *tabs[] = {
     "\t\t\t\t",
 };
 
-#ifdef USE_XMLREADER
-// This is an xmlReader (SAX) based parser. For some reason it core dumps
-// when compiled with GCC 3.x, but works just fine with GCC 4.x.
-const XMLNode &
-XML::processNode(xmlTextReaderPtr reader, XMLNode &node)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-    // dbglogfile << " node is " << node << std::endl;
-    static XMLNode *parent[10];
-    xmlChar *name, *value;
-    int   depth;
-    XMLNode *element;
-    xmlReaderTypes type;
-
-    if (node == 0) {
-        memset(parent, 0, sizeof(XMLNode *));
-    }
-    type = (xmlReaderTypes)xmlTextReaderNodeType(reader);
-    depth = xmlTextReaderDepth(reader);
-    value = xmlTextReaderValue(reader);
-    name = xmlTextReaderName(reader);
-  
-    if (name == NULL)
-        name = xmlStrdup(BAD_CAST "--");
-
-#if 0
-    printf("%d %d %s %d\n",
-           depth,
-           (int)type,
-           name,
-           xmlTextReaderIsEmptyElement(reader));  
-#endif
-
-  
-    //child = node->_children[0];
-    switch(xmlTextReaderNodeType(reader)) {
-      case XML_READER_TYPE_NONE:
-          break;
-      case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: // This is an empty text 
node
-          //dbglogfile << "Whitespace at depth " << depth << std::endl;
-          break;
-      case XML_READER_TYPE_END_ELEMENT:
-          if (depth == 0) {          // This is the last node in the file
-              element = node;
-              break;
-          }
-          parent[depth]->_children.push_back(element);
-          //      dbglogfile << "Pushing element XXX on node "
-          //                 << node->_name << parent[depth]->_name << 
std::endl;
-          //       dbglogfile << "End element at depth %d is %s for parent %s 
%p\n", depth, name,
-//               parent[depth]->_name, parent[depth]);
-          element = parent[depth];
-          break;
-      case XML_READER_TYPE_ELEMENT:
-          element = new XMLNode;
-//      dbglogfile << %sElement at depth %d is %s for node at %p\n", 
tabs[depth], depth, name, element);
-          element->_name = (char *)new char[strlen(reinterpret_cast<const char 
*>(name))+1];
-          memset(element->_name, 0, strlen(reinterpret_cast<const char 
*>(name))+1);
-          strcpy(element->_name, reinterpret_cast<const char *>(name));
-          if (node == 0) {
-              _nodes = element;
-              parent[0] = element;
-          } else {
-              parent[depth] = node;
-              parent[depth+1] = node;
-          }
-          //  xmlTextReaderAttributeCount(reader);
-          if (xmlTextReaderHasAttributes(reader)) {
-              // dbglogfile << Has Attributes!\n");
-              xmlTextReaderMoveToFirstAttribute(reader);
-              processNode(reader, element);
-              while(xmlTextReaderMoveToNextAttribute(reader)) {
-                  processNode(reader, element);
-              }
-          }
-          break;
-      case XML_READER_TYPE_TEXT:
-          element = node;
-//      dbglogfile << %sValue at depth %d is \"%s\" for node at %p\n", 
tabs[depth], depth, value, element);
-          element->_value = (char *)new char[strlen(reinterpret_cast<const 
char *>(value))+1];
-          memset(element->_value, 0, strlen(reinterpret_cast<const char 
*>(value))+1);
-          strcpy(element->_value, reinterpret_cast<const char *>(value));
-          break;
-      case XML_READER_TYPE_ATTRIBUTE:
-          element = node;
-          XMLAttr *attrib = new XMLAttr;
-          attrib->_name = (char *)new char[strlen(reinterpret_cast<const char 
*>(name))+1];
-          memset(attrib->_name, 0, strlen(reinterpret_cast<const char 
*>(name))+1);
-          strcpy(attrib->_name, reinterpret_cast<const char *>(name));
-          attrib->_value = (char *)new char[strlen(reinterpret_cast<const char 
*>(value))+1];
-          memset(attrib->_value, 0, strlen(reinterpret_cast<const char 
*>(value))+1);
-          strcpy(attrib->_value, reinterpret_cast<const char *>(value));
-//     dbglogfile << %sPushing attribute %s, value \"%s\" for node %s\n", 
tabs[depth], name, value, element->_name);
-          element->_attributes.push_back(attrib);
-          break;
-      default:   // FIXME: why does this break GCC 3.3.3 but not 3.4.3 ?
-          log_error("Unsupported XML type %d\n!", type);
-          break;
-    };
-
-    xmlFree(name);
-    if (value != NULL) {
-        xmlFree(value);
-    }
-    //previous_depth = depth;
-    return element;
-}
-#endif
-
 // This reads in an XML file from disk and parses into into a memory resident
 // tree which can be walked through later.
 bool
@@ -368,31 +199,6 @@ XML::parseFile(const std::string &filespec)
   
     //dbglogfile << %s: mem is %d\n", __FUNCTION__, mem);
 
-#ifdef USE_XMLREADER
-    bool ret = true;
-    XMLNode *node = 0;
-    xmlTextReaderPtr reader;  
-  
-    reader = xmlNewTextReaderFilename(filespec);
-    if (reader != NULL) {
-        ret = true;
-        while (ret) {
-            ret = xmlTextReaderRead(reader);
-            node = processNode(reader, node);
-        }
-        xmlFreeTextReader(reader);
-        if (ret != false) {
-            dbglogfile << "couldn't parse" << filespec << std::endl;
-            return false;
-        }
-    } else {
-        dbglogfile << "ERROR: Unable to open %s\n" << filespec << std::endl;
-        return false;
-    }
-    xmlCleanupParser();
-    return true;
-#else
-#ifdef USE_DOM
     xmlInitParser();
     _doc = xmlParseFile(filespec.c_str());
     if (_doc == 0) {
@@ -404,11 +210,8 @@ XML::parseFile(const std::string &filespec)
     xmlCleanupParser();
     xmlFreeDoc(_doc);
     xmlMemoryDump();
+
     return true;
-#else
-#error "You have to enable either a DOM or an xmlReader XML parser"
-#endif
-#endif
 }
 
 // const XMLNode &

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=18b2dabae8efd92bcb66c7bc6b8964f711c62885


commit 18b2dabae8efd92bcb66c7bc6b8964f711c62885
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:37:51 2018 -0700

    Cleanup parameter datatypesm, use std:: explitly

diff --git a/lib/msgs.cc b/lib/msgs.cc
index 9314c70..0dbbfd0 100644
--- a/lib/msgs.cc
+++ b/lib/msgs.cc
@@ -26,25 +26,18 @@
 #include <cstring>
 #include <iterator>
 #include <map>
-#ifdef __STDC_HOSTED__
 # include <sstream>
-#else
-# include <strstream>
-#endif
 #ifdef HAVE_LIBXML
 # include <libxml/encoding.h>
 # include <libxml/xmlwriter.h>
 # include <libxml/debugXML.h>
 # include "xml.h"
 #endif
-#include "database.h"
 #include "log.h"
-#include "err.h"
 #include "msgs.h"
 #include "tcputil.h"
 #include "tcpip.h"
 
-using namespace std;
 Msgs::net_mode_e  Msgs::_net_mode;
 std::map<const char *, Msgs::methodPtr_t> Msgs::_methods;
 std::map<const char *, std::string> Msgs::_cache;
@@ -63,7 +56,7 @@ Msgs::Msgs()
     _version = atof(VERSION);
 }
 
-Msgs::Msgs(std::string host, std::string ip) // : _net_mode(NONET)
+Msgs::Msgs(const std::string &host, const std::string &ip) // : 
_net_mode(NONET)
 {
     // DEBUGLOG_REPORT_FUNCTION;
     Tcputil tu;
@@ -97,24 +90,24 @@ retcode_t
 Msgs::init(net_mode_e mode)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    string hostname = "localhost";
+    std::string hostname = "localhost";
     bool block = true;
   
     if (mode == CLIENT) {
         _net_mode = CLIENT;
         if (createNetClient(hostname)) {
-            dbglogfile << "Connected to server at " << hostname.c_str() << 
endl;
+            dbglogfile << "Connected to server at " << hostname.c_str() << 
std::endl;
             init();                     // initialize the table of pointers
             return SUCCESS;
         } else {
-            dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << endl;
+            dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << std::endl;
         }
     } else if (mode == DAEMON) {
         _net_mode = DAEMON;
         init(DAEMON, block);
-        dbglogfile << "WARNING: ignoring hostname, starting as daemon" << endl;
+        dbglogfile << "WARNING: ignoring hostname, starting as daemon" << 
std::endl;
     } else {
-        dbglogfile << "ERROR: no mode specified! " << endl;
+        dbglogfile << "ERROR: no mode specified! " << std::endl;
         _net_mode = NONET;
     }
     return ERROR;  
@@ -122,7 +115,7 @@ Msgs::init(net_mode_e mode)
 
 // If a hostname is specifed, we force client mode.
 retcode_t
-Msgs::init(net_mode_e mode, std::string hostname)
+Msgs::init(net_mode_e mode, const std::string &hostname)
 {
     DEBUGLOG_REPORT_FUNCTION;
     return init(hostname);
@@ -131,18 +124,18 @@ Msgs::init(net_mode_e mode, std::string hostname)
 // By default, if just a hostname is supplied, we assume it's to establish
 // a network connection to the specified host.
 retcode_t
-Msgs::init(std::string &hostname)
+Msgs::init(const std::string &hostname)
 {
     DEBUGLOG_REPORT_FUNCTION;
   
     if (createNetClient(hostname)) {
-        dbglogfile << "Connected to server at " << hostname << endl;
+        dbglogfile << "Connected to server at " << hostname << std::endl;
         init();                     // initialize the table of pointers
         _net_mode = CLIENT;
         writeNet(heloCreate(_version));
         return SUCCESS;
     } else {
-        dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname  << endl;
+        dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname  << std::endl;
     }
     return ERROR;
 }
@@ -151,22 +144,22 @@ retcode_t
 Msgs::init(net_mode_e mode, bool block)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    string hostname = "localhost";
+    std::string hostname = "localhost";
     if (mode == CLIENT) {
         _net_mode = CLIENT;
         if (createNetClient(hostname)) {
-            dbglogfile << "Connected to server at " << hostname.c_str() << 
endl;
+            dbglogfile << "Connected to server at " << hostname.c_str() << 
std::endl;
             init();                     // initialize the table of pointers
             return SUCCESS;
         } else {
-            dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << endl;
+            dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << std::endl;
         }
     } else if (mode == DAEMON) {
         _net_mode = DAEMON;
         init(true);
-        dbglogfile << "WARNING: ignoring hostname, starting as daemon" << endl;
+        dbglogfile << "WARNING: ignoring hostname, starting as daemon" << 
std::endl;
     } else {
-        dbglogfile << "ERROR: no mode specified! " << endl;
+        dbglogfile << "ERROR: no mode specified! " << std::endl;
         _net_mode = NONET;
     }
     return ERROR;
@@ -179,19 +172,19 @@ Msgs::init(bool block)
     _net_mode = DAEMON;
   
     if (createNetServer()) {
-        dbglogfile << "New server started for remote client." << endl;
+        dbglogfile << "New server started for remote client." << std::endl;
         init();                     // initialize the table of pointers
     } else {
-        dbglogfile << "ERROR: Couldn't create a new server" << endl;
+        dbglogfile << "ERROR: Couldn't create a new server" << std::endl;
     }      
   
     if (newNetConnection(block)) {
-        dbglogfile << "New connection started for remote client." << endl;
+        dbglogfile << "New connection started for remote client." << std::endl;
         _net_mode = DAEMON;
         writeNet(heloCreate(_version));
         return SUCCESS;
     } else {
-        dbglogfile << "ERROR: Couldn't create a new connection!" << endl;
+        dbglogfile << "ERROR: Couldn't create a new connection!" << std::endl;
     }
     return ERROR;
 }
@@ -278,15 +271,15 @@ Msgs::init(void)
     return SUCCESS;
 }
 
-std::string
-Msgs::cacheGet(const char * name) {
+std::string &
+Msgs::cacheGet(const std:;string &name) {
     // DEBUGLOG_REPORT_FUNCTION;
 #if 1
     const char         *tag;
-    string                str;
+    std::string                str;
   
     _body.str("");
-    std::map<const char *, string>::const_iterator it;
+    std::map<const std::string, std::string>::const_iterator it;
     for (it = _cache.begin(); it != _cache.end(); it++) {
         //entry = it->second;
         tag = it->first;
@@ -302,7 +295,7 @@ Msgs::cacheGet(const char * name) {
             return str;
         }
         dbglogfile << "Looking for cache value for XML Tag \"" << tag
-                   << "\" has " << _body.str().c_str() << endl;
+                   << "\" has " << _body.str().c_str() << std::endl;
     }
     return _body.str();
 #else
@@ -311,7 +304,7 @@ Msgs::cacheGet(const char * name) {
 }
 
 retcode_t
-Msgs::cacheAdd(const char * name, string str)
+Msgs::cacheAdd(const std::string &name, const std::string &str)
 {
     // DEBUGLOG_REPORT_FUNCTION;
     _cache[name] = str;
@@ -323,7 +316,7 @@ Msgs::cacheAdd(const char * name, string str)
 
 // Add a function for handling an XML tag to the list.
 void
-Msgs::methodSet(const char * name, methodPtr_t func)
+Msgs::methodSet(const cstd::string &name, methodPtr_t func)
 {
     // DEBUGLOG_REPORT_FUNCTION;
     _methods[name] = func;
@@ -331,7 +324,7 @@ Msgs::methodSet(const char * name, methodPtr_t func)
 
 // Get the function for an XML tag from the list.
 Msgs::methodPtr_t
-Msgs::methodGet(const char * name)
+Msgs::methodGet(const std::string &name)
 {
     //DEBUGLOG_REPORT_FUNCTION;
 #if 1
@@ -350,13 +343,13 @@ Msgs::methodGet(const char * name)
             _body << " doesn't have a function pointer";
         }
         //     dbglogfile << "Looking for method for XML Tag \"" << 
name.c_str()
-        //                << "\" has " << _body.str().c_str() << endl;
+        //                << "\" has " << _body.str().c_str() << std::endl;
         if (strcmp(str, name) == 0) {
             return ptr;
         }
     }
 #else
-    dbglogfile << "\"" << name << "\" method we want" << endl;
+    dbglogfile << "\"" << name << "\" method we want" << std::endl;
     return _methods[name];
 #endif
     //return (methodPtr_t *)0;
@@ -364,7 +357,7 @@ Msgs::methodGet(const char * name)
 
 // Call the function to process an XML node
 retcode_t
-Msgs::methodProcess(const char *name, XMLNode *node)
+Msgs::methodProcess(const std::string &name, XMLNode &node)
 {
     // DEBUGLOG_REPORT_FUNCTION;
     //(this->*_methods.find(name)(node); 
@@ -379,7 +372,7 @@ Msgs::methodsDump(void)
     const char         *name;
     Msgs::methodPtr_t     ptr;
   
-    dbglogfile << "We have " << (int)_methods.size() << " in function table" 
<< endl;
+    dbglogfile << "We have " << (int)_methods.size() << " in function table" 
<< std::endl;
   
     std::map<const char *, Msgs::methodPtr_t>::const_iterator it;
     for (it = _methods.begin(); it != _methods.end(); it++) {
@@ -392,7 +385,7 @@ Msgs::methodsDump(void)
             _body << "no pointer to method";
         }
         dbglogfile << "XML Tag \"" << name
-                   << "\" has " << _body.str().c_str() << endl;
+                   << "\" has " << _body.str().c_str() << std::endl;
     }
 }
 
@@ -402,11 +395,11 @@ Msgs::cacheDump(void)
 {
     DEBUGLOG_REPORT_FUNCTION;
     const char         *name;
-    string                data;
+    std::string                data;
   
-    dbglogfile << "We have " << (int)_cache.size() << " items in the cache" << 
endl;
+    dbglogfile << "We have " << (int)_cache.size() << " items in the cache" << 
std::endl;
   
-    std::map<const char *, string>::const_iterator it;
+    std::map<const std::string, std::string &>::const_iterator it;
     for (it = _cache.begin(); it != _cache.end(); it++) {
         name = it->first;
         data  = it->second;
@@ -417,7 +410,7 @@ Msgs::cacheDump(void)
             _body << "no data";
         }
         dbglogfile << "XML Tag \"" << name
-                   << "\" has " << _body.str().c_str() << endl;
+                   << "\" has " << _body.str().c_str() << std::endl;
     }
 }
 
@@ -432,7 +425,7 @@ Msgs::unimplementedProcess(XMLNode *xml)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
-    dbglogfile << "XML tag \"" << xml->nameGet() << "\" doesn't exist." << 
endl;
+    dbglogfile << "XML tag \"" << xml->nameGet() << "\" doesn't exist." << 
std::endl;
 
     _body.str("");                // erase the current string
     _body << "<powerguru version=\"" << _version << "\">";
@@ -464,16 +457,16 @@ Msgs::process(XMLNode *xml)
     //methodsDump();
   
     if (fptr != 0) {
-        dbglogfile << "XML tag \"" << str << "\" has method pointer" << endl;
+        dbglogfile << "XML tag \"" << str << "\" has method pointer" << 
std::endl;
         ret = (this->*fptr)(xml);
     } else {
-        dbglogfile << "WARNING: XML tag \"" << str << "\" doesn't have a 
method pointer" << endl;
+        dbglogfile << "WARNING: XML tag \"" << str << "\" doesn't have a 
method pointer" << std::endl;
     }
 
     if (ret < 0) {
-        dbglogfile << "ERROR: Got an error from executing function pointer!" 
<< endl;
+        dbglogfile << "ERROR: Got an error from executing function pointer!" 
<< std::endl;
     } else {    
-        dbglogfile << "executed function pointer successfully!" << endl;
+        dbglogfile << "executed function pointer successfully!" << std::endl;
     }
   
     // Process the children too
@@ -489,41 +482,41 @@ Msgs::dump(XMLNode *xml)
     int           child,  i;
     XMLNode       *childnode;
 
-    dbglogfile << "processing node " << xml->nameGet() << endl;
+    dbglogfile << "processing node " << xml->nameGet() << std::endl;
 
     // Process the node's value, if it has one.
     if (xml->valueGet() == 0) {
-        dbglogfile << "No content for node " << xml->nameGet() << endl;
+        dbglogfile << "No content for node " << xml->nameGet() << std::endl;
     } else {
         dbglogfile << "Content for node " << xml->nameGet()
-                   << " is " << xml->valueGet() << endl;
+                   << " is " << xml->valueGet() << std::endl;
     }
   
     // Process the attributes, if any
     if (xml->attributesSize() == 0) {
-        dbglogfile << "\tNo attributes for node " << xml->nameGet() << endl;
+        dbglogfile << "\tNo attributes for node " << xml->nameGet() << 
std::endl;
     } else {
         for (i=0; i<xml->attributesSize(); i++) {
             dbglogfile << "\tAttribute is " << xml->attribGet(i)->nameGet()
-                       << " who's value is " << xml->attribGet(i)->valueGet() 
<< endl;
+                       << " who's value is " << xml->attribGet(i)->valueGet() 
<< std::endl;
         }
     }
 
     // Process the children, if there are any
     if (xml->childrenSize()) {
         dbglogfile << "\tProcessing " << xml->childrenSize() << " children 
nodes for "
-                   << xml->nameGet() << endl;
+                   << xml->nameGet() << std::endl;
         for (child=0; child<xml->childrenSize(); child++) {
             childnode = xml->childGet(child);
             dump(childnode); // setup child node
         }
     } else {
-        dbglogfile << "Node " << xml->nameGet() << " has no children" << endl;
+        dbglogfile << "Node " << xml->nameGet() << " has no children" << 
std::endl;
     }
 }
 
 // These format client side messages to the daemon
-string
+std::string &
 Msgs::statusCreate(meter_data_t *md)
 {
     DEBUGLOG_REPORT_FUNCTION;
@@ -599,8 +592,8 @@ Msgs::statusCreate(meter_data_t *md)
   
     xmlFreeTextWriter(writer);
   
-    //    cerr << "Buffer says: " << (const char *) buf->content << endl;
-    string str = (const char *) buf->content;
+    //    cerr << "Buffer says: " << (const char *) buf->content << std::endl;
+    std::string str = (const char *) buf->content;
     xmlBufferFree(buf);
     return str;
 #endif  
@@ -609,7 +602,7 @@ Msgs::statusCreate(meter_data_t *md)
 // Say "helo" to the connecting program to establish the messaging
 // system. Both ends of the connection use this string to make sure
 // they are speaking the same version of the protocol.
-string
+std::string &
 Msgs::heloCreate(float version)
 {
     DEBUGLOG_REPORT_FUNCTION;
@@ -624,7 +617,7 @@ Msgs::heloCreate(float version)
     return _body.str();
 }
 
-string
+std::string &
 Msgs::metersRequestCreate(std::string str) {
     DEBUGLOG_REPORT_FUNCTION;
     _body.str("");                // erase the current string
@@ -637,10 +630,10 @@ Msgs::metersRequestCreate(std::string str) {
     return _body.str();  
 }
 
-string
+std::string &
 Msgs::metersRequestCreate(xml_meters_e val) {
     DEBUGLOG_REPORT_FUNCTION;
-    string str;
+    std::string str;
 
     switch (val) {
       case CHARGE_AMPS:
@@ -690,7 +683,7 @@ Msgs::metersRequestCreate(xml_meters_e val) {
 }
 
 std::string
-Msgs::metersResponseCreate(const char * type, int val) {
+Msgs::metersResponseCreate(const std::string &type, int val) {
     DEBUGLOG_REPORT_FUNCTION;
     _body.str("");                // erase the current string
     _body << "<powerguru version=\"";
@@ -705,7 +698,7 @@ Msgs::metersResponseCreate(const char * type, int val) {
 }
 
 std::string
-Msgs::metersResponseCreate(const char *type, float val) {
+Msgs::metersResponseCreate(const std::string &type, float val) {
     DEBUGLOG_REPORT_FUNCTION;
     _body.str("");                // erase the current string
     _body << "<powerguru version=\"";
@@ -896,10 +889,10 @@ Msgs::requestCreate(xml_command_e tag)
 
 
 std::string
-Msgs::responseCreate(xml_msg_e type, const char *tag, string val)
+Msgs::responseCreate(xml_msg_e type, const std::string &tag, std::string &val)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    string str;
+    std::string str;
   
     switch (type) {
       case HEARTBEAT:
@@ -954,7 +947,7 @@ Msgs::print_msg(std::string msg)
     int level = 1;
     int start = 0;
     size_t pos;
-    string str, prefix, newmsg;
+    std::string str, prefix, newmsg;
     const char *tabs[] = {
         "\r\n\t",
         "\r\n\t\t",
@@ -965,35 +958,35 @@ Msgs::print_msg(std::string msg)
     };
   
     xmlDebugDumpString(stderr, (const xmlChar *)msg.c_str());
-    //  cerr << "++++++++++++++++++++++" << endl;
+    //  cerr << "++++++++++++++++++++++" << std::endl;
   
     // Strip off the DTD header, as we're not bothering to validate
     // our XML.
-    if ((pos = msg.find("?>\n", start)) != string::npos) {
+    if ((pos = msg.find("?>\n", start)) != std::string::npos) {
         newmsg = msg.substr(pos+3, msg.size());
     } else {
         newmsg = msg;
     }  
 
     start = 0;
-    while ((pos = newmsg.find('\n', start)) != string::npos) {
+    while ((pos = newmsg.find('\n', start)) != std::string::npos) {
         newmsg.erase(pos, 1);
     }  
 
-//   while ((pos = newmsg.find("><", start)) != string::npos) {
+//   while ((pos = newmsg.find("><", start)) != std::string::npos) {
 //     newmsg.insert(pos+1, "GGGGGG");
 //   }  
 
     start = 0;
-    while ((pos = newmsg.find('>', start)) != string::npos) {
+    while ((pos = newmsg.find('>', start)) != std::string::npos) {
         str = newmsg.substr(start, newmsg.find('>', start) - start + 1);
         start += str.size();
-        if ((pos = str.rfind(">", start)) != string::npos) {
+        if ((pos = str.rfind(">", start)) != std::string::npos) {
             //      str.insert(pos+1, "FFFF");
             str.insert(pos+1, tabs[level]);
             level++;
         }
-        if ((pos = str.rfind("</", start)) != string::npos) {
+        if ((pos = str.rfind("</", start)) != std::string::npos) {
             //      cerr << "EEEE";
             //      str.insert(pos, "EEEE");
             level--;
@@ -1003,21 +996,21 @@ Msgs::print_msg(std::string msg)
         cerr << str;
         //    cerr << prefix << str;
     }
-    //cerr << newmsg.substr(start, newmsg.size()) << endl;
+    //cerr << newmsg.substr(start, newmsg.size()) << std::endl;
 }
 
 // These parse incoming messages for the daemon
 retcode_t
-Msgs::statusProcess(XMLNode *node)
+Msgs::statusProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
     //  XMLNode *child;
     //  xmlChar i;
-    string str;
+    std::string str;
     _body.str("");
     _body << _version;
 
-    // dbglogfile <<  node->valueGet() << endl;
+    // dbglogfile <<  node->valueGet() << std::endl;
   
     if (_net_mode == DAEMON) {
         if (strcmp(node->valueGet(),  "sysversion") == 0) {
@@ -1046,20 +1039,20 @@ Msgs::statusProcess(XMLNode *node)
 
 #if 0
         if        (strcmp(node->nameGet(),  "revision") == 0) {
-            //cerr << "VER" << endl;
+            //cerr << "VER" << std::endl;
         } else if (strcmp(node->nameGet(),  "sysversion") == 0) {
-            //cerr << "REV" << endl;
+            //cerr << "REV" << std::endl;
         } else if (strcmp(node->nameGet(),  "opmode") == 0) {
-            //cerr << "OP" << endl;
+            //cerr << "OP" << std::endl;
         } else if (strcmp(node->nameGet(),  "warningmode") == 0) {
-            //cerr << "WARN" << endl;
+            //cerr << "WARN" << std::endl;
         } else if (strcmp(node->nameGet(),  "errormode") == 0) {
-            //cerr << "ERROR" << endl;
+            //cerr << "ERROR" << std::endl;
         }
 #endif
 
-        cacheAdd(node->nameGet(), (const char*)node->valueGet());
-        dbglogfile << "tag \"" << node->nameGet() << "\" has a value of: " << 
node->valueGet() << endl;
+        cacheAdd(node->nameGet(), node->valueGet());
+        dbglogfile << "tag \"" << node->nameGet() << "\" has a value of: " << 
node->valueGet() << std::endl;
     
         return SUCCESS;
     }
@@ -1068,16 +1061,16 @@ Msgs::statusProcess(XMLNode *node)
 }
 
 retcode_t
-Msgs::heloProcess(XMLNode *node)
+Msgs::heloProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    dbglogfile << "WARNING: unimplemented method" << endl;
+    dbglogfile << "WARNING: unimplemented method" << std::endl;
   
     return ERROR;                 // FIXME: implement this method
 }
 
 retcode_t
-Msgs::configProcess(XMLNode *node)
+Msgs::configProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
@@ -1085,25 +1078,25 @@ Msgs::configProcess(XMLNode *node)
 }
 
 retcode_t
-Msgs::metersProcess(XMLNode *node)
+Msgs::metersProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
     dbglogfile << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet()
-               << " and mode is: " << (int)_net_mode << endl;
+               << " and mode is: " << (int)_net_mode << std::endl;
 
     if(_net_mode == DAEMON) {
         //cacheDump();
         //    const unsigned char *xxx = node->nameGet();
-        string value = cacheGet(node->valueGet());
-        dbglogfile << "value for \"" << node->valueGet() << "\" is " << 
value.c_str() << endl;
+        std::string value = cacheGet(node->valueGet());
+        dbglogfile << "value for \"" << node->valueGet() << "\" is " << 
value.c_str() << std::endl;
         if (value.size() == 0) {
         } else {
       
         }
   
-        string str = metersResponseCreate(node->valueGet(), value);
+        std::string str = metersResponseCreate(node->valueGet(), value);
         if (writeNet(str)) {
             return ERROR;
         } else {
@@ -1120,50 +1113,50 @@ Msgs::metersProcess(XMLNode *node)
 }
 
 retcode_t
-Msgs::serverProcess(XMLNode *node)
+Msgs::serverProcess(XMLNode &node)
 {
     //  DEBUGLOG_REPORT_FUNCTION;
     XMLAttr *attr;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->hasAttributes()) {
         if ((attr = node->attribGet(0))) {
             dbglogfile << "\tAttribute is \"" << attr->nameGet()
-                       << "\" with a value of " << attr->valueGet() << endl;
+                       << "\" with a value of " << attr->valueGet() << 
std::endl;
             if (strcmp(attr->valueGet(), (const char *)_thisip.c_str()) != 0) {
-                dbglogfile << "WARNING: IP's don't match!!!!" << endl;
+                dbglogfile << "WARNING: IP's don't match!!!!" << std::endl;
                 return ERROR;
             }
         }
     }
 
     if (strcmp(node->valueGet(), (const char *)_thishost.c_str()) != 0) {
-        dbglogfile << "WARNING: Host's don't match!!!!" << endl;
+        dbglogfile << "WARNING: Host's don't match!!!!" << std::endl;
         return ERROR;
     }
 
-    dbglogfile << "Host and IP data match" << endl;
+    dbglogfile << "Host and IP data match" << std::endl;
     return SUCCESS;
 }
 
 retcode_t
-Msgs::clientProcess(XMLNode *node)
+Msgs::clientProcess(XMLNode &node)
 {
     // DEBUGLOG_REPORT_FUNCTION;
     XMLAttr *attr;
 
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (_remoteip.size() > 0) {
         if (node->hasAttributes()) {
             if ((attr = node->attribGet(0))) {
                 dbglogfile << "\tAttribute is \"" << attr->nameGet()
-                           << "\" with a value of " << attr->valueGet() << 
endl;
+                           << "\" with a value of " << attr->valueGet() << 
std::endl;
                 if (strcmp(attr->valueGet(), (const char *)_remoteip.c_str()) 
!= 0) {
-                    dbglogfile << "WARNING: IP's don't match!!!!" << endl;
+                    dbglogfile << "WARNING: IP's don't match!!!!" << std::endl;
                     return ERROR;
                 }
             }
@@ -1172,7 +1165,7 @@ Msgs::clientProcess(XMLNode *node)
 
     if (_remotehost.size() != 0) {
         if (strcmp(node->valueGet(), (const char *)_remotehost.c_str()) != 0) {
-            dbglogfile << "WARNING: Host's don't match!!!!" << endl;
+            dbglogfile << "WARNING: Host's don't match!!!!" << std::endl;
             return ERROR;
         }
     }
@@ -1182,7 +1175,7 @@ Msgs::clientProcess(XMLNode *node)
 
 // Process the top level header tag.
 retcode_t
-Msgs::powerguruProcess(XMLNode *node)
+Msgs::powerguruProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
     XMLAttr *attr;
@@ -1191,16 +1184,16 @@ Msgs::powerguruProcess(XMLNode *node)
     _body << _version;
   
 //   dbglogfile << "Node is \"" << node->nameGet()
-//              << "\" with a value of " << node->valueGet() << endl;
+//              << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->hasAttributes()) {
         if ((attr = node->attribGet(0))) {
 //       dbglogfile << "\tAttribute is \"" << attr->nameGet().c_str()
-//                  << "\" with a value of " << attr->valueGet().c_str() << 
endl;
+//                  << "\" with a value of " << attr->valueGet().c_str() << 
std::endl;
             if (strcmp((const char *)_body.str().c_str(), (const 
char*)attr->valueGet()) != 0) {
-                dbglogfile << "Versions in header don't match!" << endl;
+                dbglogfile << "Versions in header don't match!" << std::endl;
             } else {
-                dbglogfile << "Versions in header match" << endl;        
+                dbglogfile << "Versions in header match" << std::endl;
             }
         }
     }
@@ -1209,14 +1202,14 @@ Msgs::powerguruProcess(XMLNode *node)
 }
 
 retcode_t
-Msgs::chargeAmpsProcess(XMLNode *node) {
+Msgs::chargeAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1224,26 +1217,26 @@ Msgs::chargeAmpsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::loadAmpsProcess(XMLNode *node) {
+Msgs::loadAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         //    return ERROR;
     }
   
     if (_net_mode == CLIENT) {
-        dbglogfile << "Battery voltage is: " << node->valueGet() << endl;
+        dbglogfile << "Battery voltage is: " << node->valueGet() << std::endl;
     
         return SUCCESS;
     }
 
 #if 0
     if (_net_mode == DAEMON) {
-        string str = metersResponseCreate(node->valueGet(), 
_cache[node->nameGet()]);
+        std::string str = metersResponseCreate(node->valueGet(), 
_cache[node->nameGet()]);
     
         return SUCCESS;
     }
@@ -1253,14 +1246,14 @@ Msgs::loadAmpsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::pvAmpsProcess(XMLNode *node) {
+Msgs::pvAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1268,14 +1261,14 @@ Msgs::pvAmpsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::pvVoltsProcess(XMLNode *node) {
+Msgs::pvVoltsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1283,14 +1276,14 @@ Msgs::pvVoltsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::dailyKwhProcess(XMLNode *node) {
+Msgs::dailyKwhProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1298,14 +1291,14 @@ Msgs::dailyKwhProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::hertzProcess(XMLNode *node) {
+Msgs::hertzProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1313,26 +1306,26 @@ Msgs::hertzProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::batteryVoltsProcess(XMLNode *node) {
+Msgs::batteryVoltsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
 //   dbglogfile << "Node is \"" << node->nameGet()
-//              << "\" with a value of " << node->valueGet() << endl;
+//              << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         //    return ERROR;
     }
 
     if (_net_mode == CLIENT) {
-        dbglogfile << "Battery voltage is: " << node->valueGet() << endl;
+        dbglogfile << "Battery voltage is: " << node->valueGet() << std::endl;
     
         return SUCCESS;
     }
 
 #if 0
     if (_net_mode == DAEMON) {
-        string str = metersResponseCreate(node->valueGet(), 
_cache[node->nameGet()]);
+        std::string str = metersResponseCreate(node->valueGet(), 
_cache[node->nameGet()]);
     
         return SUCCESS;
     }
@@ -1342,14 +1335,14 @@ Msgs::batteryVoltsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::buyAmpsProcess(XMLNode *node) {
+Msgs::buyAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1357,14 +1350,14 @@ Msgs::buyAmpsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::sellAmpsProcess(XMLNode *node) {
+Msgs::sellAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1372,14 +1365,14 @@ Msgs::sellAmpsProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::acVoltsOutProcess(XMLNode *node) {
+Msgs::acVoltsOutProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1387,14 +1380,14 @@ Msgs::acVoltsOutProcess(XMLNode *node) {
 }
   
 retcode_t
-Msgs::ac1InProcess(XMLNode *node) {
+Msgs::ac1InProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1402,14 +1395,14 @@ Msgs::ac1InProcess(XMLNode *node) {
 }
 
 retcode_t
-Msgs::ac2InProcess(XMLNode *node) {
+Msgs::ac2InProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1425,7 +1418,7 @@ Msgs::findTag(std::string tag)
     _body.str("");
 
     _body << "<" << tag << ">";
-    if ((pos = tag.find(_body.str(), 0)) != string::npos) {
+    if ((pos = tag.find(_body.str(), 0)) != std::string::npos) {
         return SUCCESS;
     }
     return ERROR;
@@ -1433,23 +1426,23 @@ Msgs::findTag(std::string tag)
 
 
 retcode_t
-Msgs::commandProcess(XMLNode *node)
+Msgs::commandProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    string str;
+    std::string str;
   
     dbglogfile << "Node is \"" << node->nameGet()
-               << "\" with a value of " << node->valueGet() << endl;
+               << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << endl;
+        dbglogfile << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
 
     _body.str("");
     _body << _version;
 
-    // dbglogfile <<  node->valueGet() << endl;
+    // dbglogfile <<  node->valueGet() << std::endl;
 
     if (_net_mode == DAEMON) {
         if (strcmp(node->valueGet(), "auxilary") == 0) {
@@ -1475,8 +1468,8 @@ Msgs::commandProcess(XMLNode *node)
         if (strcmp(node->nameGet(), "command") == 0) {
             return SUCCESS;
         }
-        cacheAdd(node->nameGet(), (const char*)node->valueGet());
-        dbglogfile << "tag \"" << node->nameGet() << "\" has a value of: " << 
node->valueGet() << endl;
+        cacheAdd(node->nameGet(), node->valueGet());
+        dbglogfile << "tag \"" << node->nameGet() << "\" has a value of: " << 
node->valueGet() << std::endl;
     
         return SUCCESS;
     }
diff --git a/lib/msgs.h b/lib/msgs.h
index 70e6a5f..bd90a92 100644
--- a/lib/msgs.h
+++ b/lib/msgs.h
@@ -1,5 +1,5 @@
 // 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Copyright (C) 2005, 2006-2018.
 //      Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
@@ -28,11 +28,7 @@
 #include <fstream>
 #include <cstring>
 #include <map>
-#ifdef __STDC_HOSTED__
 #include <sstream>
-#else
-#include <strstream>
-#endif
 
 #include "database.h"
 #include "log.h"
@@ -111,101 +107,97 @@ public:
 //   };
 
     Msgs();
-    Msgs(std::string host, std::string ip);
+    Msgs(const std::string &, const std::string &);
     Msgs(Tcpip *tcpip);
     ~Msgs();
 
     retcode_t init(void);
-    retcode_t init(net_mode_e mode);
-    retcode_t init(std::string &hostname);
-    retcode_t init(net_mode_e mode, std::string hostname);
-    retcode_t init(bool block);
-    retcode_t init(net_mode_e mode, bool block);
-  
-    void dump(XMLNode *datain);
-    void process(XMLNode *datain);
+    retcode_t init(net_mode_e);
+    retcode_t init(std::string &);
+    retcode_t init(net_mode_e, const std::string &);
+    retcode_t init(bool);
+    retcode_t init(net_mode_e, bool);
   
+    void dump(XMLNode &);
+    void process(const XMLNode &node);
+    
     // These parse incoming messages for the daemon
-    retcode_t statusProcess(XMLNode *node);
-    retcode_t powerguruProcess(XMLNode *node);
+    retcode_t statusProcess(const XMLNode &node);
+    retcode_t powerguruProcess(const XMLNode &node);
   
-    retcode_t heloProcess(XMLNode *node);
-    retcode_t serverProcess(XMLNode *node);
-    retcode_t clientProcess(XMLNode *node);
+    retcode_t heloProcess(const XMLNode &node);
+    retcode_t serverProcess(const XMLNode &node);
+    retcode_t clientProcess(const XMLNode &node);
   
-    retcode_t configProcess(XMLNode *node);
+    retcode_t configProcess(const XMLNode &node);
 
     // These are all the tags associated with meters
-    retcode_t metersProcess(XMLNode *node);
-    retcode_t chargeAmpsProcess(XMLNode *node);
-    retcode_t loadAmpsProcess(XMLNode *node);
-    retcode_t pvAmpsProcess(XMLNode *node);
-    retcode_t pvVoltsProcess(XMLNode *node);
-    retcode_t dailyKwhProcess(XMLNode *node);
-    retcode_t hertzProcess(XMLNode *node);
-    retcode_t batteryVoltsProcess(XMLNode *node);
-    retcode_t buyAmpsProcess(XMLNode *node);
-    retcode_t sellAmpsProcess(XMLNode *node);
-    retcode_t acVoltsOutProcess(XMLNode *node);
-    retcode_t ac1InProcess(XMLNode *node);
-    retcode_t ac2InProcess(XMLNode *node);
-
-    retcode_t unimplementedProcess(XMLNode *node);
+    retcode_t metersProcess(const XMLNode &node);
+    retcode_t chargeAmpsProcess(const XMLNode &node);
+    retcode_t loadAmpsProcess(const XMLNode &node);
+    retcode_t pvAmpsProcess(const XMLNode &node);
+    retcode_t pvVoltsProcess(const XMLNode &node);
+    retcode_t dailyKwhProcess(const XMLNode &node);
+    retcode_t hertzProcess(const XMLNode &node);
+    retcode_t batteryVoltsProcess(const XMLNode &node);
+    retcode_t buyAmpsProcess(const XMLNode &node);
+    retcode_t sellAmpsProcess(const XMLNode &node);
+    retcode_t acVoltsOutProcess(const XMLNode &node);
+    retcode_t ac1InProcess(const XMLNode &node);
+    retcode_t ac2InProcess(const XMLNode &node);
+
+    retcode_t unimplementedProcess(const XMLNode &node);
 
     // These are all the system commands
-    retcode_t commandProcess(XMLNode *node);
+    retcode_t commandProcess(const XMLNode &node);
 
     // These format client side messages to the daemon
-    std::string statusCreate(meter_data_t *data);
+    std::string &statusCreate(meter_data_t *data);
   
-    std::string heloCreate(float version);
+    std::string &heloCreate(float version);
   
-    std::string configCreate(std::string tag, int value);
-    std::string configCreate(std::string tag, float value);
-    std::string metersRequestCreate(std::string str);
-    std::string metersRequestCreate(xml_meters_e type);
+    std::string &configCreate(const std::string &, int value);
+    std::string &configCreate(const std::string &tag, float value);
+    std::string &metersRequestCreate(const std::string &str);
+    std::string &metersRequestCreate(xml_meters_e type);
 
     // This formats a response from the daemon to the client
-    std::string metersResponseCreate(const char *tag, int val);
-    std::string metersResponseCreate(const char *tag, float val);
-    std::string metersResponseCreate(const char *tag, std::string);
+    std::string &metersResponseCreate(const std::string &tag, int val);
+    std::string &metersResponseCreate(const std::string &tag, float val);
+    std::string &metersResponseCreate(const std::string &tag, const 
std::string &);
 
-    std::string responseCreate(xml_msg_e type, const char *tag, std::string);
+    std::string &responseCreate(xml_msg_e type, const std::string &, const 
std::string &);
   
-    std::string requestCreate(xml_meters_e tag);
-    std::string requestCreate(xml_status_e tag);
-    std::string requestCreate(xml_config_e tag);
-    std::string requestCreate(xml_command_e tag);
+    std::string &requestCreate(xml_meters_e tag);
+    std::string &requestCreate(xml_status_e tag);
+    std::string &requestCreate(xml_config_e tag);
+    std::string &requestCreate(xml_command_e tag);
 
-    std::string packet(void) { return _body.str(); }
+    const std::string &packet(void) { return std::string(); /* _body.str(); */}
     void print_msg(std::string msg);
 
-    void methodSet(const char *name, methodPtr_t func);
-    methodPtr_t methodGet(const char *name);
-    retcode_t methodProcess(const char *name, XMLNode *node);
+    void methodSet(const std::string &, methodPtr_t func);
+    methodPtr_t methodGet(const std::string &name);
+    retcode_t methodProcess(const std::string &name, XMLNode &);
     void methodsDump(void);
 
-    std::string cacheGet(const char *name);
-    retcode_t cacheAdd(const char *name, std::string);
+    std::string cacheGet(const std::string &);
+    retcode_t cacheAdd(const std::string &name, const std::string &);
     void cacheDump(void);
+    
+    std::string &thisIPGet(void) { return _thisip; };
+    std::string &remoteIPGet(void) { return _thishost; }; 
+    std::string &thisHostnameGet(void) { return _remoteip; };
+    std::string &remoteHostnameGet(void) { return _remotehost; };
 
-    std::string thisIPGet(void) { return _thisip; };
-    std::string remoteIPGet(void) { return _thishost; }; 
-    std::string thisHostnameGet(void) { return _remoteip; };
-    std::string remoteHostnameGet(void) { return _remotehost; };
-
-    retcode_t findTag(std::string tag);
+    retcode_t findTag(const std::string &);
   
 private:
     float               _version;
-    static std::map<const char *, methodPtr_t> _methods;
-    static std::map<const char *, std::string> _cache;
+    static std::map<const std::string, methodPtr_t> _methods;
+    static std::map<const std::string, std::string> _cache;
     static net_mode_e   _net_mode;
-#ifdef __STDC_HOSTED__
     std::ostringstream  _body;
-#else
-    std::ostrstream     _body;
-#endif
     std::string         _thisip;
     std::string         _thishost;
     std::string         _remoteip;

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=05da692915c364447ded39876b561d7302b94278


commit 05da692915c364447ded39876b561d7302b94278
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:36:21 2018 -0700

    Add bool to overloaded operators

diff --git a/lib/log.cc b/lib/log.cc
index ce8d19d..83a6a5c 100644
--- a/lib/log.cc
+++ b/lib/log.cc
@@ -141,18 +141,6 @@ LogFile::Close (void) {
     return SUCCESS;
 }
 
-// Overload the input operator, so we can stick a timestamp on
-// the message that gets printed.
-LogFile&
-LogFile::operator << (ErrCond& e) {
-    if (verbose > 0)
-        std::cout << e << std::endl;
-    LogFile::outstream << e;
-    state = INPROGRESS;
-
-    return *this;
-}
-
 LogFile&
 LogFile::operator << (long x)
 {
@@ -160,7 +148,7 @@ LogFile::operator << (long x)
         std::cout << x;
     LogFile::outstream << x;
     state = INPROGRESS;
-  
+
     return *this;
 }
 
@@ -171,7 +159,7 @@ LogFile::operator << (unsigned int x)
         std::cout << x;
     LogFile::outstream << x;
     state = INPROGRESS;
-  
+
     return *this;
 }
 
@@ -201,6 +189,18 @@ LogFile::operator << (double &x)
 }
 
 LogFile&
+LogFile::operator << (bool x)
+{
+    LogFile::outstream << x;
+    if (verbose > 0) {
+        std::cout << x;
+    }
+    state = INPROGRESS;
+
+    return *this;
+}
+
+LogFile&
 LogFile::operator << (int x) {
     
     if (verbose > 0)
@@ -223,8 +223,24 @@ LogFile::operator << (void *ptr) {
 }
 
 LogFile& 
-LogFile::operator << (const std::string &s) {
-    outstream << s;
+LogFile::operator << (const std::string &str) {
+    //outstream << s.c_str();
+    std::string date;
+    logentry = timestamp(date);
+    logentry += ": ";
+
+    if (stamp == true && (state == IDLE || state == OPEN)) {
+        LogFile::state = INPROGRESS;
+       if (verbose > 0)
+           std::cout << logentry  << str;
+        outstream << logentry << str;
+    } else {
+       if (verbose > 0)
+           std::cout << str;
+        outstream << str;
+    }
+//    logentry += str;
+
     return *this;
 }
 
diff --git a/lib/log.h b/lib/log.h
index 8f3f060..7c6a55b 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -86,7 +86,6 @@ public:
     } state;
   
     file_state GetState (void) { return state; }
-    LogFile &operator << (ErrCond&);
     LogFile &operator << (int x);
     LogFile &operator << (long x);
     LogFile &operator << (unsigned int x);

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=040bb86c84f16aba7dbc43ba88d3ad5fd7109ef4


commit 040bb86c84f16aba7dbc43ba88d3ad5fd7109ef4
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:34:48 2018 -0700

    Do useless cleanup on files about to be removed

diff --git a/lib/err.cc b/lib/err.cc
index 7ebb599..957f4cc 100644
--- a/lib/err.cc
+++ b/lib/err.cc
@@ -27,18 +27,10 @@
 
 #include <iostream>
 #include <iomanip>
-#ifdef __STDC_HOSTED__
 #include <sstream>
-#else
-#include <fstream>
-#include <strstream>
-#endif
 
 #include "err.h"
 
-
-using namespace std;
-
 #if 0
 ErrCond::ErrCond(void) {
     ecode = 0;
@@ -53,7 +45,9 @@ ErrCond::ErrCond(int x) {
 ErrCond::~ErrCond(void) {
 }
 
-ErrCond::ErrCond(const char *filein, int linein, const char *funcin, int 
codein, string &s) {
+ErrCond::ErrCond(const std::string &filein, int linein,
+                 const std::string &funcin, int codein,
+                 const std::string &s) {
     file = filein;
     func = funcin;
     line = linein;
@@ -73,7 +67,9 @@ ErrCond::ClearErr(void) {
 }
 
 ErrCond &
-ErrCond::SetMsg (const char *filein, int linein, const char *funcin, int 
codein, string s) {
+ErrCond::SetMsg (const std::string &filein, int linein,
+                 const std::string &funcin, int codein,
+                 const std::stringstring &s) {
     file = filein;
     func = funcin;
     line = linein;
@@ -83,16 +79,11 @@ ErrCond::SetMsg (const char *filein, int linein, const char 
*funcin, int codein,
 }
 
 void
-ErrCond::SetMsg (string &s) {
+ErrCond::SetMsg (const std::string &s) {
     emsg = s;
 }
 
 void
-ErrCond::SetMsg (const char *s) {
-    emsg = s;
-}
- 
-void
 ErrCond::SetMsg (int x, const char *s) {
     ecode = x;
     emsg = s;
@@ -110,14 +101,7 @@ ErrCond::operator << (ostream & (&)(ostream &)) {
 }
 
 ErrCond& 
-ErrCond::operator << (const char *x)
-{
-    emsg += x;
-    return *this;
-}
-
-ErrCond& 
-ErrCond::operator << (string &x)
+ErrCond::operator << (const std::string &x)
 {
     emsg += x;
     return *this;
@@ -141,10 +125,10 @@ ErrCond::operator << (int x)
     return *this;
 }
 
-ostream& 
-operator << (ostream &os, ErrCond& e) {
-    string msg;
-  
+const std::ostream& 
+operator << (const std::ostream &os, ErrCond& e) {
+    std::string msg;
+    
     if (e.GetCode() > EMEDIUMTYPE) {
         msg = "WARNING: ";
     } else {
diff --git a/lib/err.h b/lib/err.h
index 979422e..a6a9b24 100644
--- a/lib/err.h
+++ b/lib/err.h
@@ -1,5 +1,5 @@
 // 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Copyright (C) 2005, 2006 - 2018.
 //      Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
@@ -22,20 +22,10 @@
 // This is the config file as produced by autoconf
 #include "config.h"
         
-#include <stdio.h>
-
+//#include <stdio.h>
 #include <errno.h>
-        
-// This is so we don't get warning from strncpy()
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
+#include <cstring>
 
-// We use a statically allocate string so the C API can be used wihout
 // having to malloc() any memory. And this is it's size.
 #define ERRMSGSIZE 78
         
@@ -136,15 +126,15 @@ public:
     }
 
     ~ErrCond(void);
-    ErrCond(const char *filein, int linein, const char *funcin, int codein, 
std::string &s);
+    ErrCond(const std::string &filein, int linein,
+            const std::string &funcin, int codein, const std::string &s);
     // methods
     void ClearErr(void);
   
-    ErrCond &SetMsg (const char *filein, int linein, const char *funcin, int 
codein, std::string s);
+    ErrCond &SetMsg (const std::string &filein, int linein, const std::string 
&funcin,
+                     int codein, const std::string &s);
 
-    void SetMsg (std::string &s);
-    void SetMsg (const char *s);
-    void SetMsg (int x, const char *s);
+    void SetMsg (const std::string &s);
     void SetCode(int x) { 
         ecode = x;
     }
@@ -154,26 +144,26 @@ public:
     int GetLine(void) { 
         return line;
     }
-    std::string &GetFile(void) { 
+    const std::string &GetFile(void) { 
         return file;
     }
   
-    std::string &GetFunc(void) { 
+    const std::string &GetFunc(void) { 
         return func;
     }
   
-    std::string &GetMsg(void) { 
+    const std::string &GetMsg(void) { 
         return emsg;
     }
 
-    ErrCond& operator << (ErrCond&);
-    ErrCond& operator << (int x);
-    ErrCond& operator << (char const *str);
-    ErrCond& operator << (std::string &str);
-    ErrCond& operator << (void *addr);
+    ErrCond &operator << (ErrCond &);
+    ErrCond &operator << (int x);
+    ErrCond &operator << (char const *str);
+    ErrCond &operator << (std::string &str);
+    ErrCond &operator << (void *addr);
 
     friend std::ostream & operator << (std::ostream &os, ErrCond& e);
-    std::ostream& operator << (std::ostream & (&)(std::ostream &));
+    const std::ostream& operator << (std::ostream & (&)(std::ostream &));
 private:
     std::string file;
     std::string func;

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=653453559c8f026eb1dde28f74aaeb935067ae13


commit 653453559c8f026eb1dde28f74aaeb935067ae13
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:34:16 2018 -0700

    Drop the Errcode class fils.

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5f13d7d..0f7e0ce 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2005, 2006, 2007, 2008,        2009, 2010, 2011
+# Copyright (C) 2005, 2006-2018.
 #      Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
@@ -34,9 +34,9 @@ address@hidden@
 libpguru_la_CPPFLAGS = -I$(top_srcdir)/devices
 libpguru_la_LIBDADD =
 
+#      err.cc err.h
 libpguru_la_SOURCES = \
        proc.cc proc.h \
-       err.cc err.h \
        log.cc log.h \
        rc.cc rc.h \
        serial.cc serial.h \
@@ -46,8 +46,12 @@ libpguru_la_SOURCES = \
        tcputil.cc tcputil.h \
        tcpip.cc tcpip.h
 
+if BUILD_OUTBACK
+libpguru_la_SOURCES += msgs.cc msgs.h
+endif
+
 if BUILD_LIBXML
-libpguru_la_SOURCES += xml.cc xml.h msgs.cc msgs.h
+libpguru_la_SOURCES += xml.cc xml.h
 libpguru_la_CPPFLAGS += $(LIBXML_CPPFLAGS)
 libpguru_la_LIBDADD += $(LIBXML_LIBS)
 endif

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=ec4d70534976277e5720251589beddc2a93f0532


commit ec4d70534976277e5720251589beddc2a93f0532
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 7 14:31:41 2018 -0700

    Much cleanup. Drop useless accessors, fix data types on parameters

diff --git a/lib/tcpip.cc b/lib/tcpip.cc
index 1826e3f..496bada 100644
--- a/lib/tcpip.cc
+++ b/lib/tcpip.cc
@@ -36,20 +36,15 @@
 #include <iostream>
 #include <sys/param.h>
 #include <fcntl.h>
-#ifdef HAVE_LIBXML
-// # include <libxml/encoding.h>
-// # include <libxml/xmlwriter.h>
-// # include <libxml/debugXML.h>
-# include "xml.h"
-#endif
 
 #include "tcpip.h"
 #include "tcputil.h"
 #include "log.h"
 
 //static const char *SERVICENAME = "powerguru";
-static const char *DEFAULTPROTO = "tcp";
-static const short DEFAULTPORT  = 7654;
+const std::string DEFAULTPROTO = "tcp"; // tcp or udp
+const short DEFAULTPORT  = 7654;
+
 static const int INBUF          = 2048;
 static const int DEFAULTTIMEOUT = 5;
 const int BLOCKING_TIMEOUT      = -1;
@@ -60,11 +55,6 @@ extern LogFile dbglogfile;
 #define INADDR_NONE  0xffffffff
 #endif
 
-// FIXME: This is so methods executed via a pointer can still do
-// I/O. It's probably a gross memory corruption problem too.
-int  Tcpip::_sockfd;
-int  Tcpip::_sockIOfd;
-
 Tcpip::Tcpip(void)
 
 {
@@ -76,56 +66,12 @@ Tcpip::~Tcpip(void)
 {    
 }
 
-const std::string&
-Tcpip::remoteIP(void)
-{
-    return inet_ntoa(_client.sin_addr);
-}
-
-const std::string &
-Tcpip::remoteIP(struct in_addr sockin)
-{
-    return inet_ntoa(sockin);
-}
-
-const std::string &
-Tcpip::remoteName(void)
-{
-    return hostByAddrGet(inet_ntoa(_client.sin_addr));
-}
-
-const std::string &
-Tcpip::remoteName(struct in_addr sockin)
-{
-    return hostByAddrGet(inet_ntoa(sockin));
-}
-
 // Description: Create a tcp/ip network server. This creates a server
 //              that listens for incoming socket connections. This
 //              support IP aliasing on the host, and will sequntially
 //              look for IP address to bind this port to.
 retcode_t
-Tcpip::createNetServer(void)
-{
-    return createNetServer(DEFAULTPORT);
-}
-
-retcode_t
-Tcpip::createNetServer(short port)
-{
-    std::string str = DEFAULTPROTO;
-    return createNetServer(port, str);
-}
-
-retcode_t
-Tcpip::createNetServer(std::string &service)
-{
-    std::string str = DEFAULTPROTO;
-    return createNetServer(service, str);
-}
-
-retcode_t
-Tcpip::createNetServer(std::string &service, std::string &proto)
+Tcpip::createNetServer(const std::string &service, const std::string &proto)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
@@ -146,33 +92,34 @@ Tcpip::createNetServer(std::string &service, std::string 
&proto)
 
     // Store the port number
     _port = serv->s_port;
-    _proto = serv->s_proto;
+    //_proto = serv->s_proto;
   
     return createNetServer(serv->s_port, proto);
 }
 
 retcode_t
-Tcpip::createNetServer(short port, std::string &protocol)
+Tcpip::createNetServer(short port, const std::string &protocol)
 {
     DEBUGLOG_REPORT_FUNCTION;
   
-    struct protoent *ppe;
+    struct protoent *ppe = 0;
     struct sockaddr_in sock_in;
     int             on, type;
     int             retries = 0;
     const struct hostent  *host;
-    struct in_addr  *thisaddr, newaddr;
+    struct in_addr  *thisaddr = 0, newaddr;
     in_addr_t       nodeaddr, netaddr;
   
-    host = hostDataGet("localhost");
-    thisaddr = reinterpret_cast<struct in_addr *>(host->h_addr_list[0]);
-    _ipaddr = thisaddr->s_addr;
-    memset(&sock_in, 0, sizeof(sock_in));
+    // host = hostDataGet("localhost");
+    // thisaddr = reinterpret_cast<struct in_addr 
*>(_addrinfo->ai_addr->h_addr_list[0]);
+    thisaddr = &((struct sockaddr_in *)_addrinfo->ai_addr)->sin_addr;
+    //in_addr_t = ipaddr = thisaddr->s_addr;
+    std::memset(&sock_in, 0, sizeof(sock_in));
   
     //  sock_in.sin_addr.s_addr = thisaddr->s_addr;
     sock_in.sin_addr.s_addr = INADDR_ANY;
   
-    _ipaddr = sock_in.sin_addr.s_addr;
+    // ipaddr = sock_in.sin_addr.s_addr;
     sock_in.sin_family = AF_INET;
     sock_in.sin_port = htons(port);
   
@@ -247,7 +194,7 @@ Tcpip::createNetServer(short port, std::string &protocol)
             retries++;
         }
     
-        _hostname = hostByAddrGet(inet_ntoa(sock_in.sin_addr));
+        // _hostname = hostByAddrGet(inet_ntoa(sock_in.sin_addr));
     
 #if 0
         char                ascip[32];
@@ -349,14 +296,12 @@ Tcpip::newNetConnection(bool block)
         }
     
         if (ret == 0) {
-            if (_debug) {
-                dbglogfile <<
-                    "ERROR: The accept() socket for fd #%d timed out waiting 
to write!"
-                           << _sockIOfd << std::endl;
-            }
+            dbglogfile <<
+                "ERROR: The accept() socket for fd #%d timed out waiting to 
write!"
+                       << _sockIOfd << std::endl;
         }
     }
-  
+
     fcntl(_sockIOfd, F_SETFL, O_NONBLOCK); // Don't let accept() block
     _sockfd = accept(_sockIOfd, &fsin, &alen);
   
@@ -373,52 +318,18 @@ Tcpip::newNetConnection(bool block)
     return SUCCESS;
 }
 
-// Description: Create a new conection to a tcp/ip server.
-retcode_t
-Tcpip::createNetClient(void)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-    std::string str = DEFAULTPROTO;
-    std::string host = "localhost";
-  
-    return createNetClient(host, DEFAULTPORT, str);
-}
-
-retcode_t
-Tcpip::createNetClient(short port)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-    std::string str = DEFAULTPROTO;
-    std::string host = "localhost";
-  
-    return createNetClient(host, port, str);
-}
-
-retcode_t
-Tcpip::createNetClient(std::string &hostname, short port)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-    std::string str = DEFAULTPROTO;
-    return createNetClient(hostname, port, str);
-}
-
-retcode_t
-Tcpip::createNetClient(std::string &hostname)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-    std::string str = DEFAULTPROTO;
-    return createNetClient(hostname, DEFAULTPORT, str);
-}
-
 retcode_t
-Tcpip::createNetClient(std::string &hostname, std::string &srvname, 
std::string &protocol)
+Tcpip::createNetClient(const std::string &hostname,
+                       const std::string &srvname,
+                       const std::string &protocol)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    //    return createNetClient(hostname, srvname, "tcp");
+    //return createNetClient(hostname, srvname, "tcp");
 }
 
 retcode_t
-Tcpip::createNetClient(std::string &hostname, short port, std::string 
&protocol)
+Tcpip::createNetClient(const std::string &hostname, short port,
+                       const std::string &protocol)
 {
     DEBUGLOG_REPORT_FUNCTION;
     struct sockaddr_in sock_in;
@@ -436,10 +347,8 @@ Tcpip::createNetClient(std::string &hostname, short port, 
std::string &protocol)
     //  if ((hostname.size() == 0) || (hostname == "localhost")) {
     if (hostname.size() == 0) {
         if (gethostname(thishostname, MAXHOSTNAMELEN) == 0) {
-            if (_debug) {
-                dbglogfile << "The hostname for this machine is "
-                           << thishostname;
-            }
+            dbglogfile << "The hostname for this machine is "
+                       << thishostname;
         } else {
             dbglogfile << "WARNING: Couldn't get the hostname for this 
machine!" << std::endl;
         }
@@ -447,8 +356,8 @@ Tcpip::createNetClient(std::string &hostname, short port, 
std::string &protocol)
         strcpy(thishostname, hostname.c_str());
     }
   
-    const struct hostent *hent = hostByNameGet(thishostname);
-    memcpy(&sock_in.sin_addr, hent->h_addr, hent->h_length);
+    // const struct hostent *hent = hostByNameGet(thishostname);
+    // memcpy(&sock_in.sin_addr, hent->h_addr, hent->h_length);
   
     sock_in.sin_family = AF_INET;
   
@@ -459,7 +368,6 @@ Tcpip::createNetClient(std::string &hostname, short port, 
std::string &protocol)
 #endif
   
     sock_in.sin_port = htons(port);
-    //    sock_in.sin_port = (strtol(srvname.c_str(), &end, 0)) & 0xffff;
   
     // Set the protocol type
     if (protocol == "udp") {
@@ -468,13 +376,7 @@ Tcpip::createNetClient(std::string &hostname, short port, 
std::string &protocol)
         type = SOCK_STREAM;
     }
   
-    if (protoDataGet(protocol) == 0) {
-        dbglogfile << "unable to get <%s> protocol entry\n"
-                   << protoNameGet() << std::endl;
-        return ERROR;
-    }
-  
-    _sockfd = socket(PF_INET, type, protoNumGet());
+    _sockfd = socket(PF_INET, type, _proto->p_proto);
   
     if (_sockfd < 0) {
         dbglogfile << "WARNING: unable to create socket: "
@@ -482,8 +384,7 @@ Tcpip::createNetClient(std::string &hostname, short port, 
std::string &protocol)
         return ERROR;
     }
 
-    if (connect(_sockfd,
-                reinterpret_cast<struct sockaddr *>(&sock_in),
+    if (connect(_sockfd, reinterpret_cast<struct sockaddr *>(&sock_in),
                 sizeof(sock_in)) < 0) {
         retries = 1;
         while (retries-- > 0) {
@@ -515,11 +416,9 @@ Tcpip::createNetClient(std::string &hostname, short port, 
std::string &protocol)
             }
       
             if (ret == 0) {
-                if (_debug) {
-                    dbglogfile <<
-                        "WARNING: The connect() socket for fd #%d timed out 
waiting to write!"
-                               << _sockfd << std::endl;
-                }
+                dbglogfile <<
+                    "WARNING: The connect() socket for fd #%d timed out 
waiting to write!"
+                           << _sockfd << std::endl;
             }
         }
     
@@ -554,40 +453,20 @@ Tcpip::closeConnection(void)
     DEBUGLOG_REPORT_FUNCTION;
 
     if (_sockfd > 0) {
-        closeConnection(_sockfd);
-        _sockIOfd = 0;
-    }
-  
-    return ERROR;
-}
-
-retcode_t
-Tcpip::closeConnection(int fd)
-{
-    DEBUGLOG_REPORT_FUNCTION;
-
-    if (fd > 0) {
-        closeConnection(fd);
+        //closeConnection(_sockfd); FIXME:
+        //close(_sockIOfd);
+        //_sockIOfd = 0;
+        close(_sockfd);
+        _sockfd = 0;
     }
   
     return ERROR;
 }
-
 retcode_t
 Tcpip::closeNet(void)
 {
     DEBUGLOG_REPORT_FUNCTION;
   
-    closeNet(_sockfd);
-    _sockfd = 0;
-  
-    return ERROR;
-}
-
-retcode_t
-Tcpip::closeNet(int sockfd)
-{
-    DEBUGLOG_REPORT_FUNCTION;
     int retries = 0;
   
     // If we can't close the socket, other processes must be
@@ -595,54 +474,43 @@ Tcpip::closeNet(int sockfd)
     // few tries, we give up, cause there must be something
     // wrong.
 
-    if (sockfd <= 0) {
+    if (_sockfd <= 0) {
         return SUCCESS;
     }
   
     while (retries < 3) {
-        if (sockfd) {
+        if (_sockfd) {
             // Shutdown the socket connection
 #if 0
-            if (shutdown(sockfd, SHUT_RDWR) < 0) {
+            if (shutdown(_sockfd, SHUT_RDWR) < 0) {
                 if (errno != ENOTCONN) {
                     dbglogfile << "WARNING: Unable to shutdown socket for fd #"
-                               << sockfd << strerror(errno) << std::endl;
+                               << _sockfd << strerror(errno) << std::endl;
                 } else {
-                    dbglogfile << "The socket using fd #" << sockfd
+                    dbglogfile << "The socket using fd #" << _sockfd
                                << " has been shut down successfully." << 
std::endl;
                     return SUCCESS;
                 }
             }
 #endif 
-            if (close(sockfd) < 0) {
+            if (close(_sockfd) < 0) {
                 dbglogfile <<
                     "WARNING: Unable to close the socket for fd "
-                           <<  sockfd << strerror(errno) << std::endl;
+                           <<  _sockfd << strerror(errno) << std::endl;
                 sleep(1);
                 retries++;
             } else {
-                dbglogfile << "Closed the socket for "
-                           << serviceNameGet()
-                           << " on fd " << sockfd << std::endl;
+                // dbglogfile << "Closed the socket for "
+                //            << (_service->s_name
+                //            << " on fd " << _sockfd << std::endl;
                 return SUCCESS;
             }
         }
     }
-
   
     return ERROR;
 }
 
-void
-Tcpip::toggleDebug(bool val)
-{
-    // Turn on our own debugging
-    _debug = val;
-
-    // Turn on debugging for the utility methods
-    Tcputil::toggleDebug(true);
-}
-
 // Return true if there is data in the socket, otherwise return false.
 retcode_t
 Tcpip::anydata(std::vector<const unsigned char *> &msgs)
@@ -887,96 +755,75 @@ Tcpip::readNet(std::vector<unsigned char> &buf)
     return buf;
 }
 
-// Write data to the socket. We first make sure the socket is ready for
-// data.
-int
-Tcpip::writeNet(const std::string &buffer)
-{
-    return writeNet(_sockfd, buffer.c_str(), buffer.size(), DEFAULTTIMEOUT);
-}
-
-int
-Tcpip::writeNet(char const *buffer, int nbytes)
-{
-    return writeNet(_sockfd, buffer, nbytes,DEFAULTTIMEOUT );
-}
-
 int
-Tcpip::writeNet(int fd, char const *buffer)
-{
-    return writeNet(fd, buffer, strlen(buffer), DEFAULTTIMEOUT);
-}
+Tcpip::writeNet(const std::string &buffer) {
+    const unsigned char *raw = reinterpret_cast<const unsigned char 
*>(buffer.c_str()); 
+    std::vector<unsigned char> str(raw, raw + buffer.size());
 
-int
-Tcpip::writeNet(int fd, char const *buffer, int nbytes)
-{
-    return writeNet(fd, buffer, nbytes, DEFAULTTIMEOUT);
+     return writeNet(str);
 }
 
 int
-Tcpip::writeNet(int fd, char const *buffer, int nbytes, int timeout)
+Tcpip::writeNet(const std::vector<unsigned char> &buffer)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+     DEBUGLOG_REPORT_FUNCTION;
     fd_set              fdset;
     int                 ret = 0;
-    const char         *bufptr;
+    const unsigned char *bufptr;
     struct timeval      tval;
     int                 retries = 3;
   
-    bufptr = buffer;
+    bufptr = buffer.data();
+    int nbytes = buffer.size();
 
-    dbglogfile << "Writing to socket: \r\n\t" << buffer << std::endl;
+    dbglogfile << "Writing data to socket." << std::endl;
 
     while (retries-- > 1) {
         // Wait for the socket to be ready for writing
         if (_sockfd > 2) {
             FD_ZERO(&fdset);
-            FD_SET(fd, &fdset);
+            FD_SET(_sockfd, &fdset);
         } else {
             dbglogfile << "WARNING: Can't do anything with socket fd #!"
-                       << fd << std::endl;
+                       << _sockfd << std::endl;
             return -1;
         }
     
         // Reset the timeout value, since select modifies it on return
-        if (timeout) {
-            tval.tv_sec = timeout;
-        } else {
-            tval.tv_sec = DEFAULTTIMEOUT;
-        }
+        tval.tv_sec = DEFAULTTIMEOUT;
         tval.tv_usec = 100;
-        ret = select(fd+1, NULL, &fdset, NULL, &tval);
+        ret = select(_sockfd+1, NULL, &fdset, NULL, &tval);
     
         // If interupted by a system call, try again
         if (ret == -1 && errno == EINTR) {
             dbglogfile <<
-                "The socket for fd #" << fd << " we interupted by a system 
call!" << std::endl;
+                "The socket for fd #" << _sockfd << " we interupted by a 
system call!" << std::endl;
         }
     
         if (ret == -1) {
-            dbglogfile << "The socket for fd #" << fd
+            dbglogfile << "The socket for fd #" << _sockfd
                        << " never was available for writing!" << std::endl;
             continue;
         }
     
         if (ret == 0) {
             dbglogfile << "The socket for fd #"
-                       << fd << " timed out waiting to write!" << std::endl;
+                       << _sockfd << " timed out waiting to write!" << 
std::endl;
             continue;
         }
-        ret = write(fd, bufptr, nbytes);
+        ret = write(_sockfd, bufptr, nbytes);
         // Add a LF/CR to flush the buffer.
         // write(fd, "\r\n", 2);
     
     
         if (ret == 0) {
-            dbglogfile << "Couldn't write any bytes to fd #" << fd << 
std::endl;
+            dbglogfile << "Couldn't write any bytes to fd #" << _sockfd << 
std::endl;
             return ret;
         }
     
         if (ret < 0) {
             dbglogfile << "Couldn't write " << nbytes << " bytes to fd #"
-                       << fd << std::endl;
+                       << _sockfd << std::endl;
             return ret;
         }
     
@@ -984,17 +831,17 @@ Tcpip::writeNet(int fd, char const *buffer, int nbytes, 
int timeout)
             bufptr += ret;            
             if (ret != nbytes) {
                 dbglogfile << "wrote " << ret << " bytes to fd #"
-                           << fd << " expected " <<  nbytes << std::endl;
+                           << _sockfd << " expected " <<  nbytes << std::endl;
                 retries++;
             } else {
 #if 0
-                dbglogfile << "Wrote " << ret << " bytes to fd #" << fd << 
std::endl;
+                dbglogfile << "Wrote " << ret << " bytes to fd #" << _sockfd 
<< std::endl;
 #endif
                 return ret;
             }
       
             if (ret == 0) {
-                dbglogfile << "Wrote 0 bytes to fd #" << fd << std::endl;
+                dbglogfile << "Wrote 0 bytes to fd #" << _sockfd << std::endl;
             }
         }
     }
@@ -1005,16 +852,13 @@ Tcpip::writeNet(int fd, char const *buffer, int nbytes, 
int timeout)
 Tcpip &
 Tcpip::operator = (Tcpip &tcp) 
 {
-#if 1
     _sockfd = _sockfd;
     _sockIOfd = _sockIOfd;
-    _ipaddr = _ipaddr;
+    //_ipaddr = _ipaddr;
     _hostname = _hostname;
     //memcpy(_client, tcp._client, sizeof(sockaddr_in);
     //_proto = strdup(_proto);
     _port = _port;
-    _debug = _debug;
-#endif
 }
 
 #if 0
diff --git a/lib/tcpip.h b/lib/tcpip.h
index dafcbc0..97897fb 100644
--- a/lib/tcpip.h
+++ b/lib/tcpip.h
@@ -35,6 +35,9 @@
 #include "log.h"
 #include "tcputil.h"
 
+extern const std::string DEFAULTPROTO;
+extern const short DEFAULTPORT;
+
 class Tcpip : public Tcputil
 {
 public:
@@ -43,24 +46,42 @@ public:
 
     // Create a new server. After creating it, then you have to wait for an
     // incoming connection.
-    retcode_t createNetServer(void);
-    retcode_t createNetServer(short port);
-    retcode_t createNetServer(std::string &service);
-    retcode_t createNetServer(std::string &service, std::string &protocol);
-    retcode_t createNetServer(short port, std::string &protocol);
+    retcode_t createNetServer(void) {
+        return createNetServer(DEFAULTPORT);
+    };
+    retcode_t createNetServer(short port) {
+        return createNetServer(port, DEFAULTPROTO);
+    };
+    retcode_t createNetServer(const std::string &service) {
+        return createNetServer(service, DEFAULTPROTO);
+    };
+    retcode_t createNetServer(const std::string &service, const std::string 
&protocol);
+    retcode_t createNetServer(short port, const std::string &protocol);
 
     // Accept a client connection for the current server.
     retcode_t newNetConnection(void);
     retcode_t newNetConnection(bool block);
-  
     // Create a client connection to a tcp/ip server
-    retcode_t createNetClient(void);
-    retcode_t createNetClient(short port);
-    retcode_t createNetClient(std::string &hostname);
-    retcode_t createNetClient(std::string &hostname, short port);
-    retcode_t createNetClient(std::string &hostname, std::string &service);
-    retcode_t createNetClient(std::string &hostname, std::string &service, 
std::string &protocol);
-    retcode_t createNetClient(std::string &hostname, short port, std::string 
&protocol);
+    retcode_t createNetClient(void) {
+        return createNetClient("localhost", DEFAULTPORT, DEFAULTPROTO);
+    };
+    retcode_t createNetClient(short port) {
+        return createNetClient("localhost", port, DEFAULTPROTO);
+    };
+    retcode_t createNetClient(const std::string &hostname) {
+        return createNetClient(hostname, DEFAULTPORT, DEFAULTPROTO);
+    };
+    retcode_t createNetClient(const std::string &hostname, short port) {
+        return createNetClient(hostname, port, DEFAULTPROTO);
+    };
+    retcode_t createNetClient(const std::string &hostname, const std::string 
&service) {
+        return createNetClient(hostname, service, DEFAULTPROTO);
+    };
+    
+    retcode_t createNetClient(const std::string &hostname, const std::string 
&service,
+                              const std::string &protocol);
+    retcode_t createNetClient(const std::string &hostname, short port,
+                              const std::string &protocol);
 
     // If there is any data, process it
     retcode_t anydata(std::vector<const unsigned char *> &msgs);
@@ -70,21 +91,13 @@ public:
     std::vector<unsigned char> &readNet(std::vector<unsigned char> &buf);
   
     // Write to the socket  
+    int writeNet(const std::vector<unsigned char> &buffer);
     int writeNet(const std::string &buffer);
-    int writeNet(char const *buffer, int nbytes);
-    int writeNet(int fd, char const *buffer);
-    int writeNet(int fd, char const *buffer, int nbytes);
-    int writeNet(int fd, char const *buffer, int nbytes, int timeout);
-                                                                           
+
     // Close the connection
     retcode_t closeNet();
-    retcode_t closeNet(int fd);
     retcode_t closeConnection();
-    retcode_t closeConnection(int fd);
 
-    // Change the debug flag
-    void toggleDebug(bool val);  
-  
     // Authenticate the socket connection
     retcode_t authNetClient(void);
     retcode_t authNetServer(void);
@@ -104,16 +117,15 @@ public:
         return bytes;
     }
   
-private:
-    static int               _sockfd;
-    static int               _sockIOfd;
-    in_addr_t                _ipaddr;
-    std::string              _hostname;
-    struct sockaddr_in      _client;
-    std::string              _proto;
-    short                    _port;
-    bool                     _debug;
-    bool                    _console;
+protected:
+    int                 _sockfd;
+    int                 _sockIOfd;
+    //in_addr_t         _ipaddr;
+    std::string         _hostname;
+    struct sockaddr_in _client;
+    //std::string       _proto;
+    short               _port;
+    bool                _console;
 };
 
 // EOF __TCPIP_H__ */
diff --git a/lib/tcputil.cc b/lib/tcputil.cc
index 2daf4d7..35654c9 100644
--- a/lib/tcputil.cc
+++ b/lib/tcputil.cc
@@ -1,6 +1,5 @@
 // 
-// Copyright (C) 2005, 2006 - 2018
-//      Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006 - 2018      Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -37,366 +36,80 @@
 #endif
 
 #include "tcputil.h"
+#include "tcpip.h"
 #include "log.h"
 #include "err.h"
 
-using namespace std;
-
 extern LogFile dbglogfile;
 
 Tcputil::Tcputil(void)
-    : _debug(false)
-{
-    memset(&_host, 0, sizeof(struct hostent)); 
-    memset(&_service, 0, sizeof(struct servent));
-}
-
-Tcputil::~Tcputil(void)
-{
-}
-
-const int
-Tcputil::servicePortGet(void)
-{
-    return servicePortGet(&_service);
-}
-
-const int
-Tcputil::servicePortGet(struct servent *x)
-{
-    if (_debug)
-        {
-            if (x)
-                {
-                    dbglogfile <<  "Port for service entry " << x->s_name
-                               << " is " << ntohs(x->s_port) << endl;
-                }
-        }
-    
-    return x->s_port;
-}
-    
-// Description: get the service name from a struct servent
-//              structure, which describes this connection.
-const std::string
-Tcputil::serviceNameGet(void)
-{
-    return serviceNameGet(&_service);
-}
-
-const std::string
-Tcputil::serviceNameGet(struct servent *x)
-{
-    if (_debug) {
-        if (x) {
-            if (x->s_name) {
-                dbglogfile << "Name for this service entry is " << x->s_name 
<< endl;
-                return x->s_name;
-            }
-        }
-    }
-  
-    return "";
-}
-
-// Description: get the protocol (tcp or udp) from a struct servent
-//              structure, which describes this connection.
-const std::string
-Tcputil::serviceProtoGet(void)
-{
-    return serviceProtoGet(&_service);
-}
-
-const std::string
-Tcputil::serviceProtoGet(struct servent *x)
-{
-    if (_debug)
-        {
-            if (x)
-                {
-                    dbglogfile <<  "Protocol for this service entry is " << 
x->s_proto << endl;
-                }
-        }
-
-    return x->s_proto;
-}
-
-// Description: Lookup the service data for this service entry and protocol.
-const struct servent *
-Tcputil::lookupService(string name, string protocol)
-{
-    return lookupService(&_service, name, protocol);
-}
-
-const struct servent *
-Tcputil::lookupService(string name)
-{
-    return lookupService(&_service, name, "tcp");
-}
-
-const struct servent *
-Tcputil::lookupService(struct servent *entry, string name, string protocol)
-{
-    // Get the service entry from  /etc/services for this 
-    entry = getservbyname(name.c_str(), protocol.c_str());
-
-    if (entry)
-        {
-            memcpy(&_service, entry, sizeof(struct servent));
-            if (_debug)
-                {
-                    dbglogfile <<  "Found service file entry for " << name << 
endl;
-                }
-        }
-    else
-        {
-            if (_debug)
-                {
-                    dbglogfile << "Services file entry " << name << " was not 
found!" << endl;
-                }
-        }
-
-    return entry;
-}
-
-
-// Description: Get the network data for a host.
-const struct hostent *
-Tcputil::hostDataGet(string name)
-{
-    return hostDataGet(&_host, name);
-}
-
-const struct hostent *
-Tcputil::hostDataGet(void)
-{
-    return hostDataGet(&_host, "");
-}
-
-const struct hostent *
-Tcputil::hostDataGet(struct hostent *entry)
-{
-    return hostDataGet(entry, "");
-}
-
-const struct hostent *
-Tcputil::hostDataGet(struct hostent *entry, string name)
+    : _service(0),
+      _proto(0)
 {
+    // Get the hostname of this machine
     char hostname[MAXHOSTNAMELEN];
-
-    memset(hostname, 0, MAXHOSTNAMELEN);
-    
-    if (name.size() != 0) {
-        strcpy(hostname, name.c_str());
+    std::memset(hostname, 0, MAXHOSTNAMELEN);
+    if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
+        _hostname = hostname;
+        dbglogfile << "The hostname for this machine is " << hostname << 
std::endl;
     } else {
-        if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
-            if (_debug) {
-                dbglogfile << "The hostname for this machine is " << hostname 
<< endl;
+        dbglogfile << "WARNING: Couldn't get the hostname for this machine!" 
<< std::endl;
+    }
+
+    dbglogfile << "Has " << numberOfInterfaces() << " interfaces, using 
default one" << std::endl;
+
+    // Get the IP numbers for this machine
+    if (getaddrinfo(hostname, NULL, NULL, &_addrinfo) == 0) {
+        char _address[INET6_ADDRSTRLEN];
+        struct addrinfo *addr = _addrinfo;
+        while (addr->ai_next != 0) {
+            if (addr->ai_socktype == SOCK_DGRAM) {
+                std::memset(_address, 0, INET6_ADDRSTRLEN);
+                _ipaddr = inet_ntop(AF_INET,
+                                    &((struct sockaddr_in 
*)addr->ai_addr)->sin_addr,
+                                    _address, INET6_ADDRSTRLEN);
+                dbglogfile << "The IP number for this machine is " << _ipaddr 
<< std::endl;
             }
-        } else {
-            dbglogfile << "WARNING: Couldn't get the hostname for this 
machine!" << endl;
+            addr = addr->ai_next;
         }
+    } else {
+        dbglogfile << "WARNING: Couldn't get the host entry for this machine!" 
<< std::endl;
     }
     
-    entry = gethostbyname(hostname);
-    
-    if (entry) {
-        memcpy(&_host, entry, sizeof(struct hostent));
-        if (_debug) {
-            dbglogfile <<  "The IP number for this machine is "
-                       << inet_ntoa(*(struct in_addr *)entry->h_addr_list[0]) 
<< endl;
+    _service = getservbyport(DEFAULTPORT, "tcp");
+    if (_service) {
+        dbglogfile <<  "Found service file entry for " << _service->s_name << 
std::endl;
+        _proto = getprotobyname(_service->s_proto);
+        if (_proto) {
+            dbglogfile << "The proto number for " << _proto->p_name
+                       << " is " << _proto->p_proto << std::endl;
+        } else {
+            dbglogfile << "WARNING: Couldn't get the host entry for this 
machine!" << std::endl;
         }
     } else {
-        dbglogfile << "WARNING: Couldn't get the host entry for this machine!" 
<< endl;
+        dbglogfile << "Services file entry for port " << DEFAULTPORT << " was 
not found!" << std::endl;
     }
 
-    return entry;
-}
-
-// Description: Extract the name field from a hostent data structure.
-const string
-Tcputil::hostNameGet(void)
-{
-    return hostNameGet(&_host);
-}
-
-const string
-Tcputil::hostNameGet(struct hostent *x)
-{
-    if (x != 0)
-        {
-            return x->h_name;
-        }
-
-    return "";
 }
 
-// Description: Extract the IP address field from a hostent data
-//              structure, and convert it to a string.
-const string
-Tcputil::hostIPNameGet(void)
-{
-    return hostIPNameGet(&_host);
-}
-
-const string
-Tcputil::hostIPNameGet(struct hostent *x)
-{
-    return inet_ntoa(*reinterpret_cast<struct in_addr *>(x->h_addr_list[0]));
-}
-
-// Description: Extract the IP address field from a hostent data
-//              structure.
-const in_addr_t *
-Tcputil::hostIPGet(void)
-{
-    return hostIPGet(&_host);
-}
-
-const in_addr_t *
-Tcputil::hostIPGet(struct hostent *x)
-{
-    return reinterpret_cast<const in_addr_t *>(x->h_addr_list[0]);
-}
-
-// Description: Extract the IP length field from a hostent data
-//              structure.
-const int
-Tcputil::hostLengthGet(void)
-{
-    return hostLengthGet(&_host);
-}
-
-const int
-Tcputil::hostLengthGet(struct hostent *x)
-{
-    return x->h_length;
-}
-
-// Description: Turn on or off the internal debugging flag for this
-//              class. When true, this displays additional
-//              information to the user.
-void
-Tcputil::toggleDebug(bool val)
-{
-    _debug = val;
-}
-
-
-// Description: Get the protocol data from /etc/protocols
-const struct protoent *
-Tcputil::protoDataGet(void)
-{
-    if (_service.s_proto != 0)
-        return protoDataGet(&_proto, _service.s_proto);
-    else
-        return (struct protoent *)0;
-}
-
-const struct protoent *
-Tcputil::protoDataGet(std::string name)
-{
-    return protoDataGet(&_proto, name);
-}
-
-const struct protoent *
-Tcputil::protoDataGet(struct protoent *entry)
-{
-    return protoDataGet(entry, "");
-}
-
-const struct protoent *
-Tcputil::protoDataGet(struct protoent *entry,
-                      std::string name)
-{
-    char protoname[MAXHOSTNAMELEN];
-    
-    if (name.size() != 0)
-        {
-            strcpy(protoname, name.c_str());
-        }
-
-    entry = getprotobyname(protoname);
- 
-    if (_debug)
-        {
-            if (entry)
-                {
-                    dbglogfile << "The proto number for " << entry->p_name
-                               << " is " << entry->p_proto << endl;
-                }
-            else
-                {
-                    dbglogfile << "WARNING: Couldn't get the host entry for 
this machine!" << endl;
-                }
-        }
-
-    if (entry != 0) 
-        {
-            memcpy(&_proto, entry, sizeof(struct protoent));
-        }
-    
-    return &_proto;
-}
-        
-// Description: Extract the name field from a protoent data structure.
-const string
-Tcputil::protoNameGet(void)
-{
-    return protoNameGet(&_proto);
-}
-
-const string
-Tcputil::protoNameGet(struct protoent *x)
-{
-    return x->p_name;
-}
-
-// Description: Extract the protocol number field from a protoent data
-//              structure.
-const int
-Tcputil::protoNumGet(void)
-{
-    return protoNumGet(&_proto);
-}
-
-const int
-Tcputil::protoNumGet(struct protoent *x)
-{
-    return x->p_proto;
-}
-
-// Description: Get the host name based on an IP number in ASCII format.
-const string
-Tcputil::hostByAddrGet(std::string addr)
+Tcputil::~Tcputil(void)
 {
-    struct in_addr binaddr;
-    
-    inet_pton(AF_INET, addr.c_str(), &binaddr);
-
-    return hostNameGet(gethostbyaddr((const char *)&binaddr, 4, AF_INET));
+    freeaddrinfo(_addrinfo);
 }
 
-const string
-Tcputil::hostByAddrGet(void)
+struct servent *
+Tcputil::lookupService(const std::string &name, const std::string &protocol)
 {
-    return hostNameGet(gethostbyaddr(_host.h_addr_list[0], _host.h_length,
-                                     AF_INET));
-}
+    // Get the service entry from  /etc/services for this 
+    _service = getservbyname(name.c_str(), protocol.c_str());
 
-// Description: Get the host data based on the host name
-const struct hostent *
-Tcputil::hostByNameGet(void)
-{
-    // If no name is supplied, get the data for the localhost
-    return hostDataGet();
-}
+    if (_service) {
+        dbglogfile <<  "Found service file entry for " << name << std::endl;
+    } else {
+        dbglogfile << "Services file entry " << name << " was not found!" << 
std::endl;
+    }
 
-const struct hostent *
-Tcputil::hostByNameGet(std::string host)
-{
-    memcpy(&_host, gethostbyname(host.c_str()), sizeof(struct hostent));
-    return &_host;
+    return _service;
 }
 
 // Description: Get the number of ethernet interfaces on this machine. Some
@@ -414,11 +127,10 @@ Tcputil::numberOfInterfaces(void)
     struct ifconf ifc;
     struct ifreq *ifr;
 #endif
-    if (0 > (fd = socket(AF_INET, SOCK_DGRAM,0)))
-        {
-            dbglogfile << "WARNING: Couldn't get file descriptor for AF_INET 
socket!" << endl;
-            return -1;
-        }
+    if (0 > (fd = socket(AF_INET, SOCK_DGRAM,0))) {
+        dbglogfile << "WARNING: Couldn't get file descriptor for AF_INET 
socket!" << std::endl;
+        return -1;
+    }
 #ifdef SIOCGLIFNUM
     // use AF_INET for IPv4 only or AF_INET6 for IPv6 only
     // note: if using AF_UNSPEC, some interface names may appear twice,
@@ -427,37 +139,34 @@ Tcputil::numberOfInterfaces(void)
     ln.lifn_flags = ln.lifn_count=0;
 
 
-    if(ioctl(fd,SIOCGLIFNUM,&ln) == -1)
-        {
-            dbglogfile << "Couldn't get ethernet interface data!: %s\n"
-                       << strerror(errno) << endl;
-            return -1;
-        }
+    if(ioctl(fd,SIOCGLIFNUM,&ln) == -1) {
+        dbglogfile << "Couldn't get ethernet interface data!: %s\n"
+                   << strerror(errno) << std::endl;
+        return -1;
+    }
 
-    dbglogfile << "There are " <<  << ln.lifn_count " ethernet interfaces." << 
endl;
+    dbglogfile << "There are " <<  << ln.lifn_count " ethernet interfaces." << 
std::endl;
 
     return ln.lifn_count;
 #else
     ifc.ifc_len = sizeof(buf);
     ifc.ifc_req = (struct ifreq *)buf;
     
-    if(ioctl(fd, SIOCGIFCONF, &ifc) == -1)
-        {
-            dbglogfile << "Couldn't get ethernet interface data!: %s"
-                       << strerror(errno) << endl;
-            return -1;
-        }
-
+    if(ioctl(fd, SIOCGIFCONF, &ifc) == -1) {
+        dbglogfile << "Couldn't get ethernet interface data!: %s"
+                   << strerror(errno) << std::endl;
+        return -1;
+    }
+    
     ifr = ifc.ifc_req;
     cplim = buf + ifc.ifc_len;
-    for (cp = buf; cp < cplim; cp += sizeof(ifr->ifr_name) + 
sizeof(ifr->ifr_addr))
-        {
-            ifr = (struct ifreq *) cp;
+    for (cp = buf; cp < cplim; cp += sizeof(ifr->ifr_name) + 
sizeof(ifr->ifr_addr)) {
+        ifr = (struct ifreq *) cp;
 #ifdef NET_DEBUG
-            dbglogfile << "interface name is: " << ifr->ifr_name << endl;
+        dbglogfile << "interface name is: " << ifr->ifr_name << std::endl;
 #endif
-            count++;
-        }
+        count++;
+    }
 #endif
 
     return count;
diff --git a/lib/tcputil.h b/lib/tcputil.h
index 250b20b..2197a92 100644
--- a/lib/tcputil.h
+++ b/lib/tcputil.h
@@ -1,5 +1,5 @@
 // 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Copyright (C) 2005, 2006-2018.
 //      Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
@@ -41,72 +41,27 @@ public:
     Tcputil();
     ~Tcputil();
     
-    // These get the hostent data for this machine
-    const struct hostent *hostDataGet();
-    const struct hostent *hostDataGet(std::string name);
-    const struct hostent *hostDataGet(struct hostent *entry);
-    const struct hostent *hostDataGet(struct hostent *entry,
-                                      std::string hostname);
-    const struct hostent *hostByNameGet();
-    const struct hostent *hostByNameGet(std::string addr);
-    
-    // These get the protoent data for this machine
-    const struct protoent *protoDataGet();
-    const struct protoent *protoDataGet(std::string name);
-    const struct protoent *protoDataGet(struct protoent *entry);
-    const struct protoent *protoDataGet(struct protoent *entry,
-                                        std::string protoname);
-    
     // This gets the servent data that contains the port
     // number as specified by it's /etc/services file entry.
-    const struct servent *lookupService(int number);
-    const struct servent *lookupService(std::string name);
-    const struct servent *lookupService(std::string name,
-                                        std::string protocol);
-    const struct servent *lookupService(struct servent *entry,
-                                        std::string name, std::string 
protocol);
-    
-    // These are accessors that extract the relevant field out
-    // of a struct servent structure as returned by getservbyname().
-    const int servicePortGet();
-    const int servicePortGet(struct servent *x);
-    const std::string serviceNameGet();
-    const std::string serviceNameGet(struct servent *x);
-    const std::string serviceProtoGet();
-    const std::string serviceProtoGet(struct servent *x);
-    
-    // These are accessors that extract the relevant field out
-    // of a struct protoent structure as returned by getprotobyname().
-    const std::string protoNameGet();
-    const std::string protoNameGet(struct protoent *x);
-    const int protoNumGet();
-    const int protoNumGet(struct protoent *x);
-    
-    // These are accessors that extract the relevant fields
-    // out of a struct hostent structure as returned by
-    // gethostbyname()
-    const std::string hostNameGet();
-    const std::string hostNameGet(struct hostent *x);
-    const std::string hostIPNameGet();
-    const std::string hostIPNameGet(struct hostent *x);
-    const int hostLengthGet();
-    const int hostLengthGet(struct hostent *x);
-    const in_addr_t *hostIPGet();
-    const in_addr_t *hostIPGet(struct hostent *x);
-    
-    const std::string hostByAddrGet();
-    const std::string hostByAddrGet(std::string addr);
-    
-    int numberOfInterfaces();
-    
-    // Change the debug flag
-    void toggleDebug(bool val);
+    //struct servent *lookupService(int number);
+    struct servent *lookupService(const std::string &name) {
+        return lookupService(name, "tcp");
+    };
+    struct servent *lookupService(const std::string &name,
+                                  const std::string &protocol);
+    int numberOfInterfaces(void);
+    // Accessors
+    short getPort(void) { return -1; }; // FIXME
+    int getProtocol(void) { return _addrinfo->ai_protocol; };
+    std::string &getHostnamet(void) { return _hostname; };
+    std::string &getIP(void) { return _ipaddr; };
     
-private:
-    bool               _debug;
-    struct hostent     _host;
-    struct servent     _service;
-    struct protoent    _proto;
+protected:
+    std::string        _hostname;
+    std::string        _ipaddr;
+    struct servent     *_service;
+    struct protoent    *_proto;
+    struct addrinfo    *_addrinfo;
 };
 
 // EOF __TCPUTIL_H__

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=d647c27ff95e208501a47d8220238d428f491c4c


commit d647c27ff95e208501a47d8220238d428f491c4c
Author: Rob Savoye <address@hidden>
Date:   Tue Nov 27 20:58:55 2018 -0700

    Add tcp test cases basck in

diff --git a/testsuite/libtests/Makefile.am b/testsuite/libtests/Makefile.am
index e392fda..ae38d94 100644
--- a/testsuite/libtests/Makefile.am
+++ b/testsuite/libtests/Makefile.am
@@ -21,10 +21,10 @@ AUTOMAKE_OPTIONS = dejagnu subdir-objects
 
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib $(LIBXML_CPPFLAGS) 
$(PQ_CPPFLAGS) -DSRCDIR=\"$(srcdir)\"
 
-if BUILD_LIBXML
-noinst_PROGRAMS =  xml-test # tcpip tutil childtcpip
-else
 noinst_PROGRAMS =  tcpip tutil childtcpip
+
+if BUILD_LIBXML
+noinst_PROGRAMS +=  xml-test
 endif
 
 LOG = ../../lib/log.lo
@@ -34,15 +34,14 @@ xml_test_SOURCES = xml-test.cc ../../lib/xml.cc
 xml_test_LDADD = $(LIBXML_LIBS) $(LOG)
 endif
 
-# FIXME: don't build till the code in lib is fixed.
-# tcpip_SOURCES = tcpip-test.cc
-# tcpip_LDADD =  ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
-# tcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
+tcpip_SOURCES = tcpip-test.cc
+tcpip_LDADD =  ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
+tcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
 
-# tutil_SOURCES = tcputil-test.cc
-# tutil_LDADD = ../../lib/tcputil.lo  $(LOG) # ../../lib/libpguru.la
-# tutil_DEPENDENCIES = ../../lib/tcputil.lo $(LOG) # ../../lib/libpguru.la
+tutil_SOURCES = tcputil-test.cc
+tutil_LDADD = ../../lib/tcputil.lo  $(LOG) # ../../lib/libpguru.la
+tutil_DEPENDENCIES = ../../lib/tcputil.lo $(LOG) # ../../lib/libpguru.la
 
-# childtcpip_SOURCES = childtcpip.cc
-# childtcpip_LDADD = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
-# childtcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
+childtcpip_SOURCES = childtcpip.cc
+childtcpip_LDADD = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la
+childtcpip_DEPENDENCIES = ../../lib/tcpip.lo ../../lib/tcputil.lo $(LOG) # 
../../lib/libpguru.la

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=dc7a2567c8fd198a8d0e35a2862d911adb6c88f3


commit dc7a2567c8fd198a8d0e35a2862d911adb6c88f3
Author: Rob Savoye <address@hidden>
Date:   Mon Nov 26 16:13:21 2018 -0700

    Update to a newer version

diff --git a/config.guess b/config.guess
index 2fc3acc..d622a44 100755
--- a/config.guess
+++ b/config.guess
@@ -1,9 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2003-06-17'
+timestamp='2012-02-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -16,24 +17,24 @@ timestamp='2003-06-17'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
-# Originally written by Per Bothner <address@hidden>.
-# Please send patches to <address@hidden>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
+
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <address@hidden> and include a ChangeLog
+# entry.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
 # exits with 0.  Otherwise, it exits with 1.
 #
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
+# You can get the latest version of this script from:
+# 
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -53,7 +54,8 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -66,11 +68,11 @@ Try \`$me --help' for more information."
 while test $# -gt 0 ; do
   case $1 in
     --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit 0 ;;
+       echo "$timestamp" ; exit ;;
     --version | -v )
-       echo "$version" ; exit 0 ;;
+       echo "$version" ; exit ;;
     --help | --h* | -h )
-       echo "$usage"; exit 0 ;;
+       echo "$usage"; exit ;;
     -- )     # Stop option processing
        shift; break ;;
     - )        # Use stdin as input.
@@ -104,7 +106,7 @@ set_cc_for_build='
 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && 
exit \$exitcode" 0 ;
 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 
;
 : ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n 
"$tmp" && test -d "$tmp" ; } ||
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n 
"$tmp" && test -d "$tmp" ; } ||
  { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) 
; } ||
  { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating 
insecure temp directory" >&2 ; } ||
  { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } 
;
@@ -123,7 +125,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
        ;;
  ,,*)   CC_FOR_BUILD=$CC ;;
  ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac ;'
+esac ; set_cc_for_build= ;'
 
 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
 # (address@hidden 1994-08-24)
@@ -136,19 +138,12 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || 
UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-## for Red Hat Linux
-if test -f /etc/redhat-release ; then
-    VENDOR=redhat ;
-else
-    VENDOR= ;
-fi
-
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
        # NetBSD (nbsd) targets should (where applicable) match one or
-       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
        # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
        # switched to ELF, *-*-netbsd* would select the old
        # object file format.  This provides both forward
@@ -165,6 +160,7 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            arm*) machine=arm-unknown ;;
            sh3el) machine=shl-unknown ;;
            sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
            *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
        esac
        # The Operating System including object format, if it has switched
@@ -173,7 +169,7 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            arm*|i386|m68k|ns32k|sh3*|sparc|vax)
                eval $set_cc_for_build
                if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-                       | grep __ELF__ >/dev/null
+                       | grep -q __ELF__
                then
                    # Once all utilities can be ECOFF (netbsdecoff) or a.out 
(netbsdaout).
                    # Return netbsd for either.  FIX?
@@ -183,7 +179,7 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                fi
                ;;
            *)
-               os=netbsd
+               os=netbsd
                ;;
        esac
        # The OS release
@@ -203,50 +199,32 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        # contains redundant information, the shorter form:
        # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
        echo "${machine}-${os}${release}"
-       exit 0 ;;
-    amiga:OpenBSD:*:*)
-       echo m68k-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    arc:OpenBSD:*:*)
-       echo mipsel-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    hp300:OpenBSD:*:*)
-       echo m68k-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    mac68k:OpenBSD:*:*)
-       echo m68k-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    macppc:OpenBSD:*:*)
-       echo powerpc-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    mvme68k:OpenBSD:*:*)
-       echo m68k-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    mvme88k:OpenBSD:*:*)
-       echo m88k-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    mvmeppc:OpenBSD:*:*)
-       echo powerpc-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    pmax:OpenBSD:*:*)
-       echo mipsel-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    sgi:OpenBSD:*:*)
-       echo mipseb-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    sun3:OpenBSD:*:*)
-       echo m68k-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
-    wgrisc:OpenBSD:*:*)
-       echo mipsel-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:OpenBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
-       exit 0 ;;
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
     alpha:OSF1:*:*)
-       if test $UNAME_RELEASE = "V4.0"; then
+       case $UNAME_RELEASE in
+       *4.0)
                UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-       fi
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
        # According to Compaq, /usr/sbin/psrinfo has been available on
        # OSF/1 and Tru64 systems produced since 1995.  I hope that
        # covers most systems running today.  This code pipes the CPU
@@ -284,42 +262,52 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            "EV7.9 (21364A)")
                UNAME_MACHINE="alphaev79" ;;
        esac
+       # A Pn.n version is a patched version.
        # A Vn.n version is a released version.
        # A Tn.n version is a released field test version.
        # A Xn.n version is an unreleased experimental baselevel.
        # 1.2 uses "1.2" for uname -r.
-       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 
's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-       exit 0 ;;
-    Alpha*:OpenVMS:*:*)
-       echo alpha-hp-vms
-       exit 0 ;;
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 
's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+       exitcode=$?
+       trap '' 0
+       exit $exitcode ;;
     Alpha\ *:Windows_NT*:*)
        # How do we know it's Interix rather than the generic POSIX subsystem?
        # Should we change UNAME_MACHINE based on the output of uname instead
        # of the specific Alpha model?
        echo alpha-pc-interix
-       exit 0 ;;
+       exit ;;
     21064:Windows_NT:50:3)
        echo alpha-dec-winnt3.5
-       exit 0 ;;
+       exit ;;
     Amiga*:UNIX_System_V:4.0:*)
        echo m68k-unknown-sysv4
-       exit 0;;
+       exit ;;
     *:[Aa]miga[Oo][Ss]:*:*)
        echo ${UNAME_MACHINE}-unknown-amigaos
-       exit 0 ;;
+       exit ;;
     *:[Mm]orph[Oo][Ss]:*:*)
        echo ${UNAME_MACHINE}-unknown-morphos
-       exit 0 ;;
+       exit ;;
     *:OS/390:*:*)
        echo i370-ibm-openedition
-       exit 0 ;;
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+       echo powerpc-ibm-os400
+       exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
        echo arm-acorn-riscix${UNAME_RELEASE}
-       exit 0;;
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
        echo hppa1.1-hitachi-hiuxmpp
-       exit 0;;
+       exit ;;
     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
        # address@hidden (Earle F. Ake) contributed MIS and NILE.
        if test "`(/bin/universe) 2>/dev/null`" = att ; then
@@ -327,32 +315,51 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        else
                echo pyramid-pyramid-bsd
        fi
-       exit 0 ;;
+       exit ;;
     NILE*:*:*:dcosx)
        echo pyramid-pyramid-svr4
-       exit 0 ;;
+       exit ;;
     DRS?6000:unix:4.0:6*)
        echo sparc-icl-nx6
-       exit 0 ;;
-    DRS?6000:UNIX_SV:4.2*:7*)
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
        case `/usr/bin/uname -p` in
-           sparc) echo sparc-icl-nx7 && exit 0 ;;
+           sparc) echo sparc-icl-nx7; exit ;;
        esac ;;
+    s390x:SunOS:*:*)
+       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 
's/[^.]*//'`
+       exit ;;
     sun4H:SunOS:5.*:*)
        echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit 0 ;;
+       exit ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
        echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit 0 ;;
-    i86pc:SunOS:5.*:*)
-       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit 0 ;;
+       exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+       echo i386-pc-auroraux${UNAME_RELEASE}
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       eval $set_cc_for_build
+       SUN_ARCH="i386"
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH="x86_64"
+           fi
+       fi
+       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
     sun4*:SunOS:6*:*)
        # According to config.sub, this is the proper way to canonicalize
        # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
        # it's likely to be more like Solaris than SunOS4.
        echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit 0 ;;
+       exit ;;
     sun4*:SunOS:*:*)
        case "`/usr/bin/arch -k`" in
            Series*|S4*)
@@ -361,10 +368,10 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        esac
        # Japanese Language versions have a version number like `4.1.3-JL'.
        echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-       exit 0 ;;
+       exit ;;
     sun3*:SunOS:*:*)
        echo m68k-sun-sunos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     sun*:*:4.2BSD:*)
        UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 
2>/dev/null`
        test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
@@ -376,10 +383,10 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                echo sparc-sun-sunos${UNAME_RELEASE}
                ;;
        esac
-       exit 0 ;;
+       exit ;;
     aushp:SunOS:*:*)
        echo sparc-auspex-sunos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
     # "atarist" or "atariste" at least should have a processor
@@ -389,38 +396,41 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-       exit 0 ;;
+       echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
        echo m68k-atari-mint${UNAME_RELEASE}
-        exit 0 ;;
+       exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-       exit 0 ;;
+       echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit 0 ;;
+       echo m68k-milan-mint${UNAME_RELEASE}
+       exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit 0 ;;
+       echo m68k-hades-mint${UNAME_RELEASE}
+       exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit 0 ;;
+       echo m68k-unknown-mint${UNAME_RELEASE}
+       exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
     powerpc:machten:*:*)
        echo powerpc-apple-machten${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     RISC*:Mach:*:*)
        echo mips-dec-mach_bsd4.3
-       exit 0 ;;
+       exit ;;
     RISC*:ULTRIX:*:*)
        echo mips-dec-ultrix${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     VAX*:ULTRIX*:*:*)
        echo vax-dec-ultrix${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     2020:CLIX:*:* | 2430:CLIX:*:*)
        echo clipper-intergraph-clix${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
        eval $set_cc_for_build
        sed 's/^        //' << EOF >$dummy.c
@@ -444,35 +454,36 @@ case 
"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
          exit (-1);
        }
 EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c \
-         && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
-         && exit 0
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
        echo mips-mips-riscos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     Motorola:PowerMAX_OS:*:*)
        echo powerpc-motorola-powermax
-       exit 0 ;;
+       exit ;;
     Motorola:*:4.3:PL8-*)
        echo powerpc-harris-powermax
-       exit 0 ;;
+       exit ;;
     Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
        echo powerpc-harris-powermax
-       exit 0 ;;
+       exit ;;
     Night_Hawk:Power_UNIX:*:*)
        echo powerpc-harris-powerunix
-       exit 0 ;;
+       exit ;;
     m88k:CX/UX:7*:*)
        echo m88k-harris-cxux7
-       exit 0 ;;
+       exit ;;
     m88k:*:4*:R4*)
        echo m88k-motorola-sysv4
-       exit 0 ;;
+       exit ;;
     m88k:*:3*:R3*)
        echo m88k-motorola-sysv3
-       exit 0 ;;
+       exit ;;
     AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       # DG/UX returns AViiON for all architectures
+       UNAME_PROCESSOR=`/usr/bin/uname -p`
        if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
        then
            if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -485,29 +496,29 @@ EOF
        else
            echo i586-dg-dgux${UNAME_RELEASE}
        fi
-       exit 0 ;;
+       exit ;;
     M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
        echo m88k-dolphin-sysv3
-       exit 0 ;;
+       exit ;;
     M88*:*:R3*:*)
        # Delta 88k system running SVR3
        echo m88k-motorola-sysv3
-       exit 0 ;;
+       exit ;;
     XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
        echo m88k-tektronix-sysv3
-       exit 0 ;;
+       exit ;;
     Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
        echo m68k-tektronix-bsd
-       exit 0 ;;
+       exit ;;
     *:IRIX*:*:*)
        echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-       exit 0 ;;
+       exit ;;
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-       echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
-       exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
     i*86:AIX:*:*)
        echo i386-ibm-aix
-       exit 0 ;;
+       exit ;;
     ia64:AIX:*:*)
        if [ -x /usr/bin/oslevel ] ; then
                IBM_REV=`/usr/bin/oslevel`
@@ -515,7 +526,7 @@ EOF
                IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
        fi
        echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-       exit 0 ;;
+       exit ;;
     *:AIX:2:3)
        if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
                eval $set_cc_for_build
@@ -530,15 +541,19 @@ EOF
                        exit(0);
                        }
 EOF
-               $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
-               echo rs6000-ibm-aix3.2.5
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
        elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
                echo rs6000-ibm-aix3.2.4
        else
                echo rs6000-ibm-aix3.2
        fi
-       exit 0 ;;
-    *:AIX:*:[45])
+       exit ;;
+    *:AIX:*:[4567])
        IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk 
'{ print $1 }'`
        if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; 
then
                IBM_ARCH=rs6000
@@ -551,28 +566,28 @@ EOF
                IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
        fi
        echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-       exit 0 ;;
+       exit ;;
     *:AIX:*:*)
        echo rs6000-ibm-aix
-       exit 0 ;;
+       exit ;;
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
        echo romp-ibm-bsd4.4
-       exit 0 ;;
+       exit ;;
     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
        echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-       exit 0 ;;                           # report: romp-ibm BSD 4.3
+       exit ;;                             # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
        echo rs6000-bull-bosx
-       exit 0 ;;
+       exit ;;
     DPX/2?00:B.O.S.:*:*)
        echo m68k-bull-sysv3
-       exit 0 ;;
+       exit ;;
     9000/[34]??:4.3bsd:1.*:*)
        echo m68k-hp-bsd
-       exit 0 ;;
+       exit ;;
     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
        echo m68k-hp-bsd4.4
-       exit 0 ;;
+       exit ;;
     9000/[34678]??:HP-UX:*:*)
        HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
        case "${UNAME_MACHINE}" in
@@ -581,52 +596,52 @@ EOF
            9000/[678][0-9][0-9])
                if [ -x /usr/bin/getconf ]; then
                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 
2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
+                   sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                   case "${sc_cpu_version}" in
+                     523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                     528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                     532)                      # CPU_PA_RISC2_0
+                       case "${sc_kernel_bits}" in
+                         32) HP_ARCH="hppa2.0n" ;;
+                         64) HP_ARCH="hppa2.0w" ;;
                          '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
+                       esac ;;
+                   esac
                fi
                if [ "${HP_ARCH}" = "" ]; then
                    eval $set_cc_for_build
-                   sed 's/^              //' << EOF >$dummy.c
+                   sed 's/^            //' << EOF >$dummy.c
 
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
+               #define _HPUX_SOURCE
+               #include <stdlib.h>
+               #include <unistd.h>
 
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
+               int main ()
+               {
+               #if defined(_SC_KERNEL_BITS)
+                   long bits = sysconf(_SC_KERNEL_BITS);
+               #endif
+                   long cpu  = sysconf (_SC_CPU_VERSION);
 
-                  switch (cpu)
-               {
-               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-               case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-                   switch (bits)
-                       {
-                       case 64: puts ("hppa2.0w"); break;
-                       case 32: puts ("hppa2.0n"); break;
-                       default: puts ("hppa2.0"); break;
-                       } break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-                   puts ("hppa2.0"); break;
-              #endif
-               default: puts ("hppa1.0"); break;
-               }
-                  exit (0);
-              }
+                   switch (cpu)
+                       {
+                       case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+                       case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+                       case CPU_PA_RISC2_0:
+               #if defined(_SC_KERNEL_BITS)
+                           switch (bits)
+                               {
+                               case 64: puts ("hppa2.0w"); break;
+                               case 32: puts ("hppa2.0n"); break;
+                               default: puts ("hppa2.0"); break;
+                               } break;
+               #else  /* !defined(_SC_KERNEL_BITS) */
+                           puts ("hppa2.0"); break;
+               #endif
+                       default: puts ("hppa1.0"); break;
+                       }
+                   exit (0);
+               }
 EOF
                    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && 
HP_ARCH=`$dummy`
                    test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -634,9 +649,19 @@ EOF
        esac
        if [ ${HP_ARCH} = "hppa2.0w" ]
        then
-           # avoid double evaluation of $set_cc_for_build
-           test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
-           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ 
>/dev/null
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep -q __LP64__
            then
                HP_ARCH="hppa2.0w"
            else
@@ -644,11 +669,11 @@ EOF
            fi
        fi
        echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-       exit 0 ;;
+       exit ;;
     ia64:HP-UX:*:*)
        HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
        echo ia64-hp-hpux${HPUX_REV}
-       exit 0 ;;
+       exit ;;
     3050*:HI-UX:*:*)
        eval $set_cc_for_build
        sed 's/^        //' << EOF >$dummy.c
@@ -676,208 +701,266 @@ EOF
          exit (0);
        }
 EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
        echo unknown-hitachi-hiuxwe2
-       exit 0 ;;
+       exit ;;
     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
        echo hppa1.1-hp-bsd
-       exit 0 ;;
+       exit ;;
     9000/8??:4.3bsd:*:*)
        echo hppa1.0-hp-bsd
-       exit 0 ;;
+       exit ;;
     *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
        echo hppa1.0-hp-mpeix
-       exit 0 ;;
+       exit ;;
     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
        echo hppa1.1-hp-osf
-       exit 0 ;;
+       exit ;;
     hp8??:OSF1:*:*)
        echo hppa1.0-hp-osf
-       exit 0 ;;
+       exit ;;
     i*86:OSF1:*:*)
        if [ -x /usr/sbin/sysversion ] ; then
            echo ${UNAME_MACHINE}-unknown-osf1mk
        else
            echo ${UNAME_MACHINE}-unknown-osf1
        fi
-       exit 0 ;;
+       exit ;;
     parisc*:Lites*:*:*)
        echo hppa1.1-hp-lites
-       exit 0 ;;
+       exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
        echo c1-convex-bsd
-        exit 0 ;;
+       exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
        if getsysinfo -f scalar_acc
        then echo c32-convex-bsd
        else echo c2-convex-bsd
        fi
-        exit 0 ;;
+       exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
        echo c34-convex-bsd
-        exit 0 ;;
+       exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
        echo c38-convex-bsd
-        exit 0 ;;
+       exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
        echo c4-convex-bsd
-        exit 0 ;;
+       exit ;;
     CRAY*Y-MP:*:*:*)
        echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit 0 ;;
+       exit ;;
     CRAY*[A-Z]90:*:*:*)
        echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
        | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
              -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
              -e 's/\.[^.]*$/.X/'
-       exit 0 ;;
+       exit ;;
     CRAY*TS:*:*:*)
        echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit 0 ;;
+       exit ;;
     CRAY*T3E:*:*:*)
        echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit 0 ;;
+       exit ;;
     CRAY*SV1:*:*:*)
        echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit 0 ;;
+       exit ;;
     *:UNICOS/mp:*:*)
-       echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 
-       exit 0 ;;
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
        FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit 0 ;;
+       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+       FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+       echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    5000:UNIX_System_V:4.*:*)
+       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+       FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+       echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
        echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     sparc*:BSD/OS:*:*)
        echo sparc-unknown-bsdi${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:BSD/OS:*:*)
        echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-       exit 0 ;;
-    *:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
-       # Determine whether the default compiler uses glibc.
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #include <features.h>
-       #if __GLIBC__ >= 2
-       LIBC=gnu
-       #else
-       LIBC=
-       #endif
-EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
-       echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 
's/[-(].*//'`${LIBC:+-$LIBC}
-       exit 0 ;;
+       exit ;;
+    *:FreeBSD:*:*)
+       UNAME_PROCESSOR=`/usr/bin/uname -p`
+       case ${UNAME_PROCESSOR} in
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 
's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_PROCESSOR}-unknown-freebsd`echo 
${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
     i*:CYGWIN*:*)
        echo ${UNAME_MACHINE}-pc-cygwin
-       exit 0 ;;
-    i*:MINGW*:*)
+       exit ;;
+    *:MINGW*:*)
        echo ${UNAME_MACHINE}-pc-mingw32
-       exit 0 ;;
+       exit ;;
+    i*:MSYS*:*)
+       echo ${UNAME_MACHINE}-pc-msys
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
     i*:PW*:*)
        echo ${UNAME_MACHINE}-pc-pw32
-       exit 0 ;;
-    x86:Interix*:[34]*)
-       echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
-       exit 0 ;;
+       exit ;;
+    *:Interix*:*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           authenticamd | genuineintel | EM64T)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
        echo i${UNAME_MACHINE}-pc-mks
-       exit 0 ;;
+       exit ;;
+    8664:Windows_NT:*)
+       echo x86_64-pc-mks
+       exit ;;
     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
        # How do we know it's Interix rather than the generic POSIX subsystem?
        # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
        # UNAME_MACHINE based on the output of uname instead of i386?
        echo i586-pc-interix
-       exit 0 ;;
+       exit ;;
     i*:UWIN*:*)
        echo ${UNAME_MACHINE}-pc-uwin
-       exit 0 ;;
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
     p*:CYGWIN*:*)
        echo powerpcle-unknown-cygwin
-       exit 0 ;;
+       exit ;;
     prep*:SunOS:5.*:*)
        echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 
's/[^.]*//'`
-       exit 0 ;;
+       exit ;;
     *:GNU:*:*)
+       # the GNU system
        echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo 
${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-       exit 0 ;;
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' 
| tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
     i*86:Minix:*:*)
        echo ${UNAME_MACHINE}-pc-minix
-       exit 0 ;;
+       exit ;;
+    aarch64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    aarch64_be:Linux:*:*)
+       UNAME_MACHINE=aarch64_be
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+       esac
+       objdump --private-headers /bin/sh | grep -q ld.so.1
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
     arm*:Linux:*:*)
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-gnu
+       else
+           if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+               | grep -q __ARM_PCS_VFP
+           then
+               echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+           else
+               echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+           fi
+       fi
+       exit ;;
+    avr32*:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit 0 ;;
+       exit ;;
     cris:Linux:*:*)
-       echo cris-axis-linux-gnu
-       exit 0 ;;
-    ia64:Linux:*:*)
-       echo ${UNAME_MACHINE}-${VENDOR:-unknown}-linux-gnu
-       exit 0 ;;
-    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo ${UNAME_MACHINE}-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    hexagon:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit 0 ;;
-    mips:Linux:*:*)
+       exit ;;
+    i*86:Linux:*:*)
+       LIBC=gnu
        eval $set_cc_for_build
        sed 's/^        //' << EOF >$dummy.c
-       #undef CPU
-       #undef mips
-       #undef mipsel
-       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || 
defined(MIPSEL)
-       CPU=mipsel
-       #else
-       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || 
defined(MIPSEB)
-       CPU=mips
-       #else
-       CPU=
-       #endif
+       #ifdef __dietlibc__
+       LIBC=dietlibc
        #endif
 EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
-       test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
-       ;;
-    mips64:Linux:*:*)
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+       echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
        eval $set_cc_for_build
        sed 's/^        //' << EOF >$dummy.c
        #undef CPU
-       #undef mips64
-       #undef mips64el
+       #undef ${UNAME_MACHINE}
+       #undef ${UNAME_MACHINE}el
        #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || 
defined(MIPSEL)
-       CPU=mips64el
+       CPU=${UNAME_MACHINE}el
        #else
        #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || 
defined(MIPSEB)
-       CPU=mips64
+       CPU=${UNAME_MACHINE}
        #else
        CPU=
        #endif
        #endif
 EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
-       test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
        ;;
-    ppc:Linux:*:*)
-       echo powerpc-${VENDOR:-unknown}-linux-gnu
-       exit 0 ;;
-    ppc64:Linux:*:*)
-       echo powerpc64-${VENDOR:-unknown}-linux-gnu
-       exit 0 ;;
-    alpha:Linux:*:*)
-       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-         EV5)   UNAME_MACHINE=alphaev5 ;;
-         EV56)  UNAME_MACHINE=alphaev56 ;;
-         PCA56) UNAME_MACHINE=alphapca56 ;;
-         PCA57) UNAME_MACHINE=alphapca56 ;;
-         EV6)   UNAME_MACHINE=alphaev6 ;;
-         EV67)  UNAME_MACHINE=alphaev67 ;;
-         EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
-       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
-       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-       exit 0 ;;
+    or32:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    padre:Linux:*:*)
+       echo sparc-unknown-linux-gnu
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
        # Look for CPU level
        case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@@ -885,109 +968,71 @@ EOF
          PA8*) echo hppa2.0-unknown-linux-gnu ;;
          *)    echo hppa-unknown-linux-gnu ;;
        esac
-       exit 0 ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-       echo hppa64-unknown-linux-gnu
-       exit 0 ;;
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-       echo ${UNAME_MACHINE}-${VENDOR:-ibm}-linux-gnu
-       exit 0 ;;
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
     sh64*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit 0 ;;
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
     sh*:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit 0 ;;
+       exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit 0 ;;
+       exit ;;
+    tile*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-gnu
+       exit ;;
     x86_64:Linux:*:*)
-       echo x86_64-${VENDOR:-unknown}-linux-gnu
-       exit 0 ;;
-    i*86:Linux:*:*)
-       # The BFD linker knows what the default object file format is, so
-       # first see if it will tell us. cd to the root directory to prevent
-       # problems with other programs or directories called `ld' in the path.
-       # Set LC_ALL=C to ensure ld outputs messages in English.
-       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
-                        | sed -ne '/supported targets:/!d
-                                   s/[         ][      ]*/ /g
-                                   s/.*supported targets: *//
-                                   s/ .*//
-                                   p'`
-        case "$ld_supported_targets" in
-         elf32-i386)
-               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-               ;;
-         a.out-i386-linux)
-               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-               exit 0 ;;
-         coff-i386)
-               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-               exit 0 ;;
-         "")
-               # Either a pre-BFD a.out linker (linux-gnuoldld) or
-               # one that does not give us useful --help.
-               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
-               exit 0 ;;
-       esac
-       # Determine whether the default compiler is a.out or elf
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #include <features.h>
-       #ifdef __ELF__
-       # ifdef __GLIBC__
-       #  if __GLIBC__ >= 2
-       LIBC=gnu
-       #  else
-       LIBC=gnulibc1
-       #  endif
-       # else
-       LIBC=gnulibc1
-       # endif
-       #else
-       #ifdef __INTEL_COMPILER
-       LIBC=gnu
-       #else
-       LIBC=gnuaout
-       #endif
-       #endif
-EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
-       test x"${LIBC}" != x && echo 
"${UNAME_MACHINE}-${VENDOR:-pc}-linux-${LIBC}" && exit 0
-       test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
-       ;;
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
     i*86:DYNIX/ptx:4*:*)
        # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
        # earlier versions are messed up and put the nodename in both
        # sysname and nodename.
        echo i386-sequent-sysv4
-       exit 0 ;;
+       exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
+       # Unixware is an offshoot of SVR4, but it has its own version
+       # number series starting with 2...
+       # I am not positive that other SVR4 systems won't match this,
        # I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
+       # Use sysv4.2uw... so that sysv4* matches it.
        echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-       exit 0 ;;
+       exit ;;
     i*86:OS/2:*:*)
        # If we were able to find `uname', then EMX Unix compatibility
        # is probably installed.
        echo ${UNAME_MACHINE}-pc-os2-emx
-       exit 0 ;;
+       exit ;;
     i*86:XTS-300:*:STOP)
        echo ${UNAME_MACHINE}-unknown-stop
-       exit 0 ;;
+       exit ;;
     i*86:atheos:*:*)
        echo ${UNAME_MACHINE}-unknown-atheos
-       exit 0 ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
        echo i386-unknown-lynxos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     i*86:*DOS:*:*)
        echo ${UNAME_MACHINE}-pc-msdosdjgpp
-       exit 0 ;;
+       exit ;;
     i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
        UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
        if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
@@ -995,15 +1040,16 @@ EOF
        else
                echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
        fi
-       exit 0 ;;
-    i*86:*:5:[78]*)
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
        case `/bin/uname -X | grep "^Machine"` in
            *486*)           UNAME_MACHINE=i486 ;;
            *Pentium)        UNAME_MACHINE=i586 ;;
            *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
        esac
        echo 
${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
-       exit 0 ;;
+       exit ;;
     i*86:*:3.2:*)
        if test -f /usr/options/cb.name; then
                UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
@@ -1021,73 +1067,86 @@ EOF
        else
                echo ${UNAME_MACHINE}-pc-sysv32
        fi
-       exit 0 ;;
+       exit ;;
     pc:*:*:*)
        # Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i386.
-       echo i386-pc-msdosdjgpp
-        exit 0 ;;
+       # uname -m prints for DJGPP always 'pc', but it prints nothing about
+       # the processor, so we play safe by assuming i586.
+       # Note: whatever this is, it MUST be the same as what config.sub
+       # prints for the "djgpp" host, or else GDB configury will decide that
+       # this is a cross-build.
+       echo i586-pc-msdosdjgpp
+       exit ;;
     Intel:Mach:3*:*)
        echo i386-pc-mach3
-       exit 0 ;;
+       exit ;;
     paragon:*:*:*)
        echo i860-intel-osf1
-       exit 0 ;;
+       exit ;;
     i860:*:4.*:*) # i860-SVR4
        if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
          echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
        else # Add other i860-SVR4 vendors below as they are discovered.
          echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
        fi
-       exit 0 ;;
+       exit ;;
     mini*:CTIX:SYS*5:*)
        # "miniframe"
        echo m68010-convergent-sysv
-       exit 0 ;;
+       exit ;;
     mc68k:UNIX:SYSTEM5:3.51m)
        echo m68k-convergent-sysv
-       exit 0 ;;
+       exit ;;
     M680?0:D-NIX:5.3:*)
        echo m68k-diab-dnix
-       exit 0 ;;
-    M68*:*:R3V[567]*:*)
-       test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 
3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | 
SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 
3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | 
SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
        OS_REL=''
        test -r /etc/.relid \
        && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-         && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-         && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && echo i486-ncr-sysv4 && exit 0 ;;
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+       OS_REL='.3'
+       test -r /etc/.relid \
+           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < 
/etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
        echo m68k-unknown-lynxos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     mc68030:UNIX_System_V:4.*:*)
        echo m68k-atari-sysv4
-       exit 0 ;;
+       exit ;;
     TSUNAMI:LynxOS:2.*:*)
        echo sparc-unknown-lynxos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     rs6000:LynxOS:2.*:*)
        echo rs6000-unknown-lynxos${UNAME_RELEASE}
-       exit 0 ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
        echo powerpc-unknown-lynxos${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     SM[BE]S:UNIX_SV:*:*)
        echo mips-dde-sysv${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     RM*:ReliantUNIX-*:*:*)
        echo mips-sni-sysv4
-       exit 0 ;;
+       exit ;;
     RM*:SINIX-*:*:*)
        echo mips-sni-sysv4
-       exit 0 ;;
+       exit ;;
     *:SINIX-*:*:*)
        if uname -p 2>/dev/null >/dev/null ; then
                UNAME_MACHINE=`(uname -p) 2>/dev/null`
@@ -1095,68 +1154,94 @@ EOF
        else
                echo ns32k-sni-sysv
        fi
-       exit 0 ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <address@hidden>
-        echo i586-unisys-sysv4
-        exit 0 ;;
+       exit ;;
+    PENTIUM:*:4.0*:*)  # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                       # says <address@hidden>
+       echo i586-unisys-sysv4
+       exit ;;
     *:UNIX_System_V:4*:FTX*)
        # From Gerald Hewes <address@hidden>.
        # How about differentiating between stratus architectures? -djm
        echo hppa1.1-stratus-sysv4
-       exit 0 ;;
+       exit ;;
     *:*:*:FTX*)
        # From address@hidden
        echo i860-stratus-sysv4
-       exit 0 ;;
+       exit ;;
+    i*86:VOS:*:*)
+       # From address@hidden
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
     *:VOS:*:*)
        # From address@hidden
        echo hppa1.1-stratus-vos
-       exit 0 ;;
+       exit ;;
     mc68*:A/UX:*:*)
        echo m68k-apple-aux${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     news*:NEWS-OS:6*:*)
        echo mips-sony-newsos6
-       exit 0 ;;
+       exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
        if [ -d /usr/nec ]; then
-               echo mips-nec-sysv${UNAME_RELEASE}
+               echo mips-nec-sysv${UNAME_RELEASE}
        else
-               echo mips-unknown-sysv${UNAME_RELEASE}
+               echo mips-unknown-sysv${UNAME_RELEASE}
        fi
-        exit 0 ;;
+       exit ;;
     BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
        echo powerpc-be-beos
-       exit 0 ;;
+       exit ;;
     BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
        echo powerpc-apple-beos
-       exit 0 ;;
+       exit ;;
     BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
        echo i586-pc-beos
-       exit 0 ;;
+       exit ;;
+    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
+       echo i586-pc-haiku
+       exit ;;
     SX-4:SUPER-UX:*:*)
        echo sx4-nec-superux${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     SX-5:SUPER-UX:*:*)
        echo sx5-nec-superux${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     SX-6:SUPER-UX:*:*)
        echo sx6-nec-superux${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
     Power*:Rhapsody:*:*)
        echo powerpc-apple-rhapsody${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:Rhapsody:*:*)
        echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:Darwin:*:*)
-       case `uname -p` in
-           *86) UNAME_PROCESSOR=i686 ;;
-           powerpc) UNAME_PROCESSOR=powerpc ;;
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           i386)
+               eval $set_cc_for_build
+               if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+                 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo 
'#endif') | \
+                     (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+                     grep IS_64BIT_ARCH >/dev/null
+                 then
+                     UNAME_PROCESSOR="x86_64"
+                 fi
+               fi ;;
+           unknown) UNAME_PROCESSOR=powerpc ;;
        esac
        echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
        UNAME_PROCESSOR=`uname -p`
        if test "$UNAME_PROCESSOR" = "x86"; then
@@ -1164,22 +1249,28 @@ EOF
                UNAME_MACHINE=pc
        fi
        echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:QNX:*:4*)
        echo i386-pc-qnx
-       exit 0 ;;
-    NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
+       exit ;;
+    NEO-?:NONSTOP_KERNEL:*:*)
+       echo neo-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
        echo nsr-tandem-nsk${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:NonStop-UX:*:*)
        echo mips-compaq-nonstopux
-       exit 0 ;;
+       exit ;;
     BS2000:POSIX*:*:*)
        echo bs2000-siemens-sysv
-       exit 0 ;;
+       exit ;;
     DS/*:UNIX_System_V:*:*)
        echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-       exit 0 ;;
+       exit ;;
     *:Plan9:*:*)
        # "uname -m" is not consistent, so use $cputype instead. 386
        # is converted to i386 for consistency with other x86
@@ -1190,28 +1281,53 @@ EOF
            UNAME_MACHINE="$cputype"
        fi
        echo ${UNAME_MACHINE}-unknown-plan9
-       exit 0 ;;
+       exit ;;
     *:TOPS-10:*:*)
        echo pdp10-unknown-tops10
-       exit 0 ;;
+       exit ;;
     *:TENEX:*:*)
        echo pdp10-unknown-tenex
-       exit 0 ;;
+       exit ;;
     KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
        echo pdp10-dec-tops20
-       exit 0 ;;
+       exit ;;
     XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
        echo pdp10-xkl-tops20
-       exit 0 ;;
+       exit ;;
     *:TOPS-20:*:*)
        echo pdp10-unknown-tops20
-       exit 0 ;;
+       exit ;;
     *:ITS:*:*)
        echo pdp10-unknown-its
-       exit 0 ;;
+       exit ;;
     SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
-       exit 0 ;;
+       echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 
's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ 
.*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+    i*86:AROS:*:*)
+       echo ${UNAME_MACHINE}-pc-aros
+       exit ;;
+    x86_64:VMkernel:*:*)
+       echo ${UNAME_MACHINE}-unknown-esx
+       exit ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1234,16 +1350,16 @@ main ()
 #include <sys/param.h>
   printf ("m68k-sony-newsos%s\n",
 #ifdef NEWSOS4
-          "4"
+       "4"
 #else
-         ""
+       ""
 #endif
-         ); exit (0);
+       ); exit (0);
 #endif
 #endif
 
 #if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix"); exit (0);
+  printf ("arm-acorn-riscix\n"); exit (0);
 #endif
 
 #if defined (hp300) && !defined (hpux)
@@ -1332,11 +1448,12 @@ main ()
 }
 EOF
 
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
 
 # Apollos put the system type in the environment.
 
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
 
 # Convex versions that predate uname can use getsysinfo(1)
 
@@ -1345,22 +1462,22 @@ then
     case `getsysinfo -f cpu_type` in
     c1*)
        echo c1-convex-bsd
-       exit 0 ;;
+       exit ;;
     c2*)
        if getsysinfo -f scalar_acc
        then echo c32-convex-bsd
        else echo c2-convex-bsd
        fi
-       exit 0 ;;
+       exit ;;
     c34*)
        echo c34-convex-bsd
-       exit 0 ;;
+       exit ;;
     c38*)
        echo c38-convex-bsd
-       exit 0 ;;
+       exit ;;
     c4*)
        echo c4-convex-bsd
-       exit 0 ;;
+       exit ;;
     esac
 fi
 
@@ -1371,7 +1488,9 @@ This script, last modified $timestamp, has failed to 
recognize
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-    ftp://ftp.gnu.org/pub/gnu/config/
+  
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=2b27313d9b51da89e9659d6f97ce40a46c1784cb


commit 2b27313d9b51da89e9659d6f97ce40a46c1784cb
Author: Rob Savoye <address@hidden>
Date:   Mon Nov 26 16:10:58 2018 -0700

    Update to a newer version

diff --git a/config.sub b/config.sub
index 7cee3d6..c894da4 100755
--- a/config.sub
+++ b/config.sub
@@ -1,9 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2003-06-18'
+timestamp='2012-02-10'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -20,23 +21,25 @@ timestamp='2003-06-18'
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
+
 # Please send patches to <address@hidden>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
+# diff and a properly formatted GNU ChangeLog entry.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
 # Otherwise, we print the canonical config type on stdout and succeed.
 
+# You can get the latest version of this script from:
+# 
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
 # that are meaningful with *any* GNU software.
@@ -70,7 +73,8 @@ Report bugs and patches to <address@hidden>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -83,11 +87,11 @@ Try \`$me --help' for more information."
 while test $# -gt 0 ; do
   case $1 in
     --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit 0 ;;
+       echo "$timestamp" ; exit ;;
     --version | -v )
-       echo "$version" ; exit 0 ;;
+       echo "$version" ; exit ;;
     --help | --h* | -h )
-       echo "$usage"; exit 0 ;;
+       echo "$usage"; exit ;;
     -- )     # Stop option processing
        shift; break ;;
     - )        # Use stdin as input.
@@ -99,7 +103,7 @@ while test $# -gt 0 ; do
     *local*)
        # First pass through any local machine types.
        echo $1
-       exit 0;;
+       exit ;;
 
     * )
        break ;;
@@ -118,10 +122,18 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | 
os2-emx* | rtmk-nova*)
+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -144,10 +156,13 @@ case $os in
        -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
        -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
        -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-       -apple | -axis)
+       -apple | -axis | -knuth | -cray | -microblaze)
                os=
                basic_machine=$1
                ;;
+       -bluegene*)
+               os=-cnk
+               ;;
        -sim | -cisco | -oki | -wec | -winbond)
                os=
                basic_machine=$1
@@ -162,13 +177,17 @@ case $os in
                os=-chorusos
                basic_machine=$1
                ;;
-       -chorusrdb)
-               os=-chorusrdb
+       -chorusrdb)
+               os=-chorusrdb
                basic_machine=$1
-               ;;
+               ;;
        -hiux*)
                os=-hiuxwe2
                ;;
+       -sco6)
+               os=-sco5v6
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
        -sco5)
                os=-sco3.2v5
                basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -185,6 +204,10 @@ case $os in
                # Don't forget version if it is 3.2v4 or newer.
                basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
                ;;
+       -sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
        -sco*)
                os=-sco3.2v2
                basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -226,56 +249,103 @@ case $basic_machine in
        # Some are omitted here because they have special meanings below.
        1750a | 580 \
        | a29k \
+       | aarch64 | aarch64_be \
        | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
        | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | 
alpha64pca5[67] \
-       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | 
avr32 \
+        | be32 | be64 \
+       | bfin \
        | c4x | clipper \
        | d10v | d30v | dlx | dsp16xx \
-       | fr30 | frv \
+       | epiphany \
+       | fido | fr30 | frv \
        | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | hexagon \
        | i370 | i860 | i960 | ia64 \
-       | ip2k \
-       | m32r | m68000 | m68k | m88k | mcore \
+       | ip2k | iq2000 \
+       | le32 | le64 \
+       | lm32 \
+       | m32c | m32r | m32rle | m68000 | m68k | m88k \
+       | maxq | mb | microblaze | mcore | mep | metag \
        | mips | mipsbe | mipseb | mipsel | mipsle \
        | mips16 \
        | mips64 | mips64el \
-       | mips64vr | mips64vrel \
+       | mips64octeon | mips64octeonel \
        | mips64orion | mips64orionel \
+       | mips64r5900 | mips64r5900el \
+       | mips64vr | mips64vrel \
        | mips64vr4100 | mips64vr4100el \
        | mips64vr4300 | mips64vr4300el \
        | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
        | mipsisa32 | mipsisa32el \
        | mipsisa32r2 | mipsisa32r2el \
        | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
        | mipsisa64sb1 | mipsisa64sb1el \
        | mipsisa64sr71k | mipsisa64sr71kel \
        | mipstx39 | mipstx39el \
        | mn10200 | mn10300 \
+       | moxie \
+       | mt \
        | msp430 \
+       | nds32 | nds32le | nds32be \
+       | nios | nios2 \
        | ns16k | ns32k \
-       | openrisc | or32 \
+       | open8 \
+       | or32 \
        | pdp10 | pdp11 | pj | pjl \
-       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | powerpc | powerpc64 | powerpc64le | powerpcle \
        | pyramid \
-       | s390 | s390x \
-       | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | 
sh3ele \
+       | rl78 | rx \
+       | score \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | 
shbe | shle | sh[1234]le | sh3ele \
        | sh64 | sh64le \
-       | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | 
sparcv9b \
-       | strongarm \
-       | tahoe | thumb | tic4x | tic80 | tron \
-       | v850 | v850e \
+       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | 
sparclite \
+       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+       | spu \
+       | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+       | ubicom32 \
+       | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
        | we32k \
-       | x86 | xscale | xstormy16 | xtensa \
-       | z8k)
+       | x86 | xc16x | xstormy16 | xtensa \
+       | z8k | z80)
                basic_machine=$basic_machine-unknown
                ;;
-       m6811 | m68hc11 | m6812 | m68hc12)
-               # Motorola 68HC11/12.
+       c54x)
+               basic_machine=tic54x-unknown
+               ;;
+       c55x)
+               basic_machine=tic55x-unknown
+               ;;
+       c6x)
+               basic_machine=tic6x-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
                basic_machine=$basic_machine-unknown
                os=-none
                ;;
        m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
                ;;
+       ms1)
+               basic_machine=mt-unknown
+               ;;
+
+       strongarm | thumb | xscale)
+               basic_machine=arm-unknown
+               ;;
+       xgate)
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       xscaleeb)
+               basic_machine=armeb-unknown
+               ;;
+
+       xscaleel)
+               basic_machine=armel-unknown
+               ;;
 
        # We use `pc' rather than `unknown'
        # because (1) that's what they normally are, and
@@ -291,59 +361,80 @@ case $basic_machine in
        # Recognize the basic CPU types with company name.
        580-* \
        | a29k-* \
+       | aarch64-* | aarch64_be-* \
        | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
        | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
        | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-       | avr-* \
-       | bs2000-* \
-       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-       | clipper-* | cydra-* \
+       | avr-* | avr32-* \
+       | be32-* | be64-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* \
+       | clipper-* | craynv-* | cydra-* \
        | d10v-* | d30v-* | dlx-* \
        | elxsi-* \
-       | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
        | h8300-* | h8500-* \
        | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | hexagon-* \
        | i*86-* | i860-* | i960-* | ia64-* \
-       | ip2k-* \
-       | m32r-* \
+       | ip2k-* | iq2000-* \
+       | le32-* | le64-* \
+       | lm32-* \
+       | m32c-* | m32r-* | m32rle-* \
        | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-       | m88110-* | m88k-* | mcore-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
        | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
        | mips16-* \
        | mips64-* | mips64el-* \
-       | mips64vr-* | mips64vrel-* \
+       | mips64octeon-* | mips64octeonel-* \
        | mips64orion-* | mips64orionel-* \
+       | mips64r5900-* | mips64r5900el-* \
+       | mips64vr-* | mips64vrel-* \
        | mips64vr4100-* | mips64vr4100el-* \
        | mips64vr4300-* | mips64vr4300el-* \
        | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
        | mipsisa32-* | mipsisa32el-* \
        | mipsisa32r2-* | mipsisa32r2el-* \
        | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
        | mipsisa64sb1-* | mipsisa64sb1el-* \
        | mipsisa64sr71k-* | mipsisa64sr71kel-* \
        | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | mt-* \
        | msp430-* \
-       | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+       | nds32-* | nds32le-* | nds32be-* \
+       | nios-* | nios2-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | open8-* \
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
        | pyramid-* \
-       | romp-* | rs6000-* \
-       | s390-* | s390x-* \
-       | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+       | rl78-* | romp-* | rs6000-* | rx-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* 
| sheb-* | shbe-* \
        | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-       | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
-       | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
-       | tahoe-* | thumb-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | 
sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+       | tahoe-* \
        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+       | tile*-* \
        | tron-* \
-       | v850-* | v850e-* | vax-* \
+       | ubicom32-* \
+       | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+       | vax-* \
        | we32k-* \
-       | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
-       | xtensa-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* \
+       | xstormy16-* | xtensa*-* \
        | ymp-* \
-       | z8k-*)
+       | z8k-* | z80-*)
+               ;;
+       # Recognize the basic CPU types without company name, with glob match.
+       xtensa*)
+               basic_machine=$basic_machine-unknown
                ;;
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
@@ -361,6 +452,9 @@ case $basic_machine in
                basic_machine=a29k-amd
                os=-udi
                ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
        adobe68k)
                basic_machine=m68010-adobe
                os=-scout
@@ -378,6 +472,9 @@ case $basic_machine in
        amd64)
                basic_machine=x86_64-pc
                ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        amdahl)
                basic_machine=580-amdahl
                os=-sysv
@@ -401,6 +498,10 @@ case $basic_machine in
                basic_machine=m68k-apollo
                os=-bsd
                ;;
+       aros)
+               basic_machine=i386-pc
+               os=-aros
+               ;;
        aux)
                basic_machine=m68k-apple
                os=-aux
@@ -409,10 +510,35 @@ case $basic_machine in
                basic_machine=ns32k-sequent
                os=-dynix
                ;;
+       blackfin)
+               basic_machine=bfin-unknown
+               os=-linux
+               ;;
+       blackfin-*)
+               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       bluegene*)
+               basic_machine=powerpc-ibm
+               os=-cnk
+               ;;
+       c54x-*)
+               basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c55x-*)
+               basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       c6x-*)
+               basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        c90)
                basic_machine=c90-cray
                os=-unicos
                ;;
+       cegcc)
+               basic_machine=arm-unknown
+               os=-cegcc
+               ;;
        convex-c1)
                basic_machine=c1-convex
                os=-bsd
@@ -437,12 +563,27 @@ case $basic_machine in
                basic_machine=j90-cray
                os=-unicos
                ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16 | cr16-*)
+               basic_machine=cr16-unknown
+               os=-elf
+               ;;
        crds | unos)
                basic_machine=m68k-crds
                ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
        cris | cris-* | etrax*)
                basic_machine=cris-axis
                ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
        da30 | da30-*)
                basic_machine=m68k-da30
                ;;
@@ -465,6 +606,14 @@ case $basic_machine in
                basic_machine=m88k-motorola
                os=-sysv3
                ;;
+       dicos)
+               basic_machine=i686-pc
+               os=-dicos
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
        dpx20 | dpx20-*)
                basic_machine=rs6000-bull
                os=-bosx
@@ -576,7 +725,6 @@ case $basic_machine in
        i370-ibm* | ibm*)
                basic_machine=i370-ibm
                ;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
        i*86v32)
                basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
                os=-sysv32
@@ -615,6 +763,14 @@ case $basic_machine in
                basic_machine=m68k-isi
                os=-sysv
                ;;
+       m68knommu)
+               basic_machine=m68k-unknown
+               os=-linux
+               ;;
+       m68knommu-*)
+               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
        m88k-omron*)
                basic_machine=m88k-omron
                ;;
@@ -626,10 +782,17 @@ case $basic_machine in
                basic_machine=ns32k-utek
                os=-sysv
                ;;
+       microblaze)
+               basic_machine=microblaze-xilinx
+               ;;
        mingw32)
                basic_machine=i386-pc
                os=-mingw32
                ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
        miniframe)
                basic_machine=m68000-convergent
                ;;
@@ -643,10 +806,6 @@ case $basic_machine in
        mips3*)
                basic_machine=`echo $basic_machine | sed -e 
's/mips3/mips64/'`-unknown
                ;;
-       mmix*)
-               basic_machine=mmix-knuth
-               os=-mmixware
-               ;;
        monitor)
                basic_machine=m68k-rom68k
                os=-coff
@@ -659,10 +818,21 @@ case $basic_machine in
                basic_machine=i386-pc
                os=-msdos
                ;;
+       ms1-*)
+               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               ;;
+       msys)
+               basic_machine=i386-pc
+               os=-msys
+               ;;
        mvs)
                basic_machine=i370-ibm
                os=-mvs
                ;;
+       nacl)
+               basic_machine=le32-unknown
+               os=-nacl
+               ;;
        ncr3000)
                basic_machine=i486-ncr
                os=-sysv4
@@ -727,9 +897,11 @@ case $basic_machine in
        np1)
                basic_machine=np1-gould
                ;;
-       nv1)
-               basic_machine=nv1-cray
-               os=-unicosmp
+       neo-tandem)
+               basic_machine=neo-tandem
+               ;;
+       nse-tandem)
+               basic_machine=nse-tandem
                ;;
        nsr-tandem)
                basic_machine=nsr-tandem
@@ -738,9 +910,12 @@ case $basic_machine in
                basic_machine=hppa1.1-oki
                os=-proelf
                ;;
-       or32 | or32-*)
+       openrisc | openrisc-*)
                basic_machine=or32-unknown
-               os=-coff
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
                ;;
        OSE68000 | ose68000)
                basic_machine=m68000-ericsson
@@ -758,6 +933,14 @@ case $basic_machine in
                basic_machine=i860-intel
                os=-osf
                ;;
+       parisc)
+               basic_machine=hppa-unknown
+               os=-linux
+               ;;
+       parisc-*)
+               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
        pbd)
                basic_machine=sparc-tti
                ;;
@@ -767,6 +950,12 @@ case $basic_machine in
        pc532 | pc532-*)
                basic_machine=ns32k-pc532
                ;;
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       pc98-*)
+               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        pentium | p5 | k5 | k6 | nexgen | viac3)
                basic_machine=i586-pc
                ;;
@@ -796,9 +985,10 @@ case $basic_machine in
                ;;
        power)  basic_machine=power-ibm
                ;;
-       ppc)    basic_machine=powerpc-unknown
+       ppc | ppcbe)    basic_machine=powerpc-unknown
                ;;
-       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+       ppc-* | ppcbe-*)
+               basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
        ppcle | powerpclittle | ppc-le | powerpc-little)
                basic_machine=powerpcle-unknown
@@ -823,6 +1013,10 @@ case $basic_machine in
                basic_machine=i586-unknown
                os=-pw32
                ;;
+       rdos)
+               basic_machine=i386-pc
+               os=-rdos
+               ;;
        rom68k)
                basic_machine=m68k-rom68k
                os=-coff
@@ -833,6 +1027,12 @@ case $basic_machine in
        rtpc | rtpc-*)
                basic_machine=romp-ibm
                ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
        sa29200)
                basic_machine=a29k-amd
                os=-udi
@@ -843,6 +1043,10 @@ case $basic_machine in
        sb1el)
                basic_machine=mipsisa64sb1el-unknown
                ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
        sei)
                basic_machine=mips-sei
                os=-seiux
@@ -854,6 +1058,9 @@ case $basic_machine in
                basic_machine=sh-hitachi
                os=-hms
                ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
        sh64)
                basic_machine=sh64-unknown
                ;;
@@ -875,6 +1082,9 @@ case $basic_machine in
                basic_machine=i860-stratus
                os=-sysv4
                ;;
+       strongarm-* | thumb-*)
+               basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
        sun2)
                basic_machine=m68000-sun
                ;;
@@ -931,17 +1141,9 @@ case $basic_machine in
                basic_machine=t90-cray
                os=-unicos
                ;;
-       tic54x | c54x*)
-               basic_machine=tic54x-unknown
-               os=-coff
-               ;;
-       tic55x | c55x*)
-               basic_machine=tic55x-unknown
-               os=-coff
-               ;;
-       tic6x | c6x*)
-               basic_machine=tic6x-unknown
-               os=-coff
+       tile*)
+               basic_machine=$basic_machine-unknown
+               os=-linux-gnu
                ;;
        tx39)
                basic_machine=mipstx39-unknown
@@ -956,6 +1158,10 @@ case $basic_machine in
        tower | tower-32)
                basic_machine=m68k-ncr
                ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
        udi29k)
                basic_machine=a29k-amd
                os=-udi
@@ -999,9 +1205,16 @@ case $basic_machine in
                basic_machine=hppa1.1-winbond
                os=-proelf
                ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
        xps | xps100)
                basic_machine=xps100-honeywell
                ;;
+       xscale-* | xscalee[bl]-*)
+               basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+               ;;
        ymp)
                basic_machine=ymp-cray
                os=-unicos
@@ -1010,6 +1223,10 @@ case $basic_machine in
                basic_machine=z8k-unknown
                os=-sim
                ;;
+       z80-*-coff)
+               basic_machine=z80-unknown
+               os=-sim
+               ;;
        none)
                basic_machine=none-none
                os=-none
@@ -1029,6 +1246,9 @@ case $basic_machine in
        romp)
                basic_machine=romp-ibm
                ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
        rs6000)
                basic_machine=rs6000-ibm
                ;;
@@ -1045,13 +1265,10 @@ case $basic_machine in
        we32k)
                basic_machine=we32k-att
                ;;
-       sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
                basic_machine=sh-unknown
                ;;
-       sh64)
-               basic_machine=sh64-unknown
-               ;;
-       sparc | sparcv9 | sparcv9b)
+       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
                basic_machine=sparc-sun
                ;;
        cydra)
@@ -1095,9 +1312,12 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
+       # First match some system type aliases
+       # that might get confused with valid system types.
        # -solaris* is a basic system type, with this one exception.
+       -auroraux)
+               os=-auroraux
+               ;;
        -solaris1 | -solaris1.*)
                os=`echo $os | sed -e 's|solaris1|sunos4|'`
                ;;
@@ -1118,25 +1338,31 @@ case $os in
        # Each alternative MUST END IN A *, to match a version number.
        # -sysv* is not here because it comes later, after sysvr4.
        -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
-             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | 
-sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | 
-solaris* \
+             | -sym* | -kopensolaris* \
              | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-             | -aos* \
+             | -aos* | -aros* \
              | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
              | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-             | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* 
\
-             | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | 
-oabi* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -openbsd* | -solidbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
              | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
              | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-             | -chorusos* | -chorusrdb* \
-             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -chorusos* | -chorusrdb* | -cegcc* \
+             | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* 
\
+             | -mingw32* | -linux-gnu* | -linux-android* \
+             | -linux-newlib* | -linux-uclibc* \
+             | -uxpv* | -beos* | -mpeix* | -udk* \
              | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
              | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
              | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
              | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
              | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-             | -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        -qnx*)
@@ -1154,12 +1380,15 @@ case $os in
                os=`echo $os | sed -e 's|nto|nto-qnx|'`
                ;;
        -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-             | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* 
\
              | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
                ;;
        -mac*)
                os=`echo $os | sed -e 's|mac|macos|'`
                ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
        -linux*)
                os=`echo $os | sed -e 's|linux|linux-gnu|'`
                ;;
@@ -1172,6 +1401,9 @@ case $os in
        -opened*)
                os=-openedition
                ;;
+       -os400*)
+               os=-os400
+               ;;
        -wince*)
                os=-wince
                ;;
@@ -1193,6 +1425,9 @@ case $os in
        -atheos*)
                os=-atheos
                ;;
+       -syllable*)
+               os=-syllable
+               ;;
        -386bsd)
                os=-bsd
                ;;
@@ -1215,6 +1450,9 @@ case $os in
        -sinix*)
                os=-sysv4
                ;;
+       -tpf*)
+               os=-tpf
+               ;;
        -triton*)
                os=-sysv3
                ;;
@@ -1251,6 +1489,14 @@ case $os in
        -kaos*)
                os=-kaos
                ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -dicos*)
+               os=-dicos
+               ;;
+       -nacl*)
+               ;;
        -none)
                ;;
        *)
@@ -1273,6 +1519,12 @@ else
 # system, and we'll never get to this point.
 
 case $basic_machine in
+       score-*)
+               os=-elf
+               ;;
+       spu-*)
+               os=-elf
+               ;;
        *-acorn)
                os=-riscix1.2
                ;;
@@ -1285,6 +1537,15 @@ case $basic_machine in
        c4x-* | tic4x-*)
                os=-coff
                ;;
+       tic54x-*)
+               os=-coff
+               ;;
+       tic55x-*)
+               os=-coff
+               ;;
+       tic6x-*)
+               os=-coff
+               ;;
        # This must come before the *-dec entry.
        pdp10-*)
                os=-tops20
@@ -1303,13 +1564,13 @@ case $basic_machine in
                ;;
        m68000-sun)
                os=-sunos3
-               # This also exists in the configure program, but was not the
-               # default.
-               # os=-sunos4
                ;;
        m68*-cisco)
                os=-aout
                ;;
+       mep-*)
+               os=-elf
+               ;;
        mips*-cisco)
                os=-elf
                ;;
@@ -1328,9 +1589,15 @@ case $basic_machine in
        *-be)
                os=-beos
                ;;
+       *-haiku)
+               os=-haiku
+               ;;
        *-ibm)
                os=-aix
                ;;
+       *-knuth)
+               os=-mmixware
+               ;;
        *-wec)
                os=-proelf
                ;;
@@ -1433,7 +1700,7 @@ case $basic_machine in
                        -sunos*)
                                vendor=sun
                                ;;
-                       -aix*)
+                       -cnk*|-aix*)
                                vendor=ibm
                                ;;
                        -beos*)
@@ -1463,9 +1730,15 @@ case $basic_machine in
                        -mvs* | -opened*)
                                vendor=ibm
                                ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
                        -ptx*)
                                vendor=sequent
                                ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
                        -vxsim* | -vxworks* | -windiss*)
                                vendor=wrs
                                ;;
@@ -1490,7 +1763,7 @@ case $basic_machine in
 esac
 
 echo $basic_machine$os
-exit 0
+exit
 
 # Local variables:
 # eval: (add-hook 'write-file-hooks 'time-stamp)

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=4db90d3ca3dd0a89c689094bac0400b813c7cd51


commit 4db90d3ca3dd0a89c689094bac0400b813c7cd51
Author: Rob Savoye <address@hidden>
Date:   Sun Nov 25 21:50:21 2018 -0700

    Only one readNet() now, and uses a std::vector

diff --git a/daemon/threads.cc b/daemon/threads.cc
index d03231c..135a34f 100644
--- a/daemon/threads.cc
+++ b/daemon/threads.cc
@@ -41,28 +41,31 @@ extern char *optarg;
 #endif
 
 #include "log.h"
-#include "err.h"
 #include "ownet.h"
 #include "console.h"
 #include "database.h"
+#include "tcpip.h"
+#include "xml.h"
 
 extern LogFile dbglogfile;
 
 using namespace std::chrono_literals;
 
-#if 0
 void
 console_handler(Console &con)
 {
     DEBUGLOG_REPORT_FUNCTION;
+    
+    // Open a console for user input
+    con.Open();
+    int ch = 0;
     while ((ch = con.Getc()) != 'q') {
         if (ch > 0) {                // If we have something, process it
             con.Putc (ch);          // echo inputted character to screen
             switch (ch) {
               case 'Q':
               case 'q':
-                  con.Puts("Qutting PowerGuru due to user input!\n");
-                  msg.writeNet("quit");
+                  dbglogfile <<"Qutting PowerGuru due to user input!\n" << 
std::endl;
                   con.Reset();
                   exit(0);
                   break;
@@ -76,17 +79,65 @@ console_handler(Console &con)
                   break;
             };
         }
-
+    }
 }
-#endif
 
-//#if defined(HAVE_LIBPQ) && defined(HAVE_MARIADB)
 void
-msg_handler(Database &db)
+client_handler(void)
 {
     DEBUGLOG_REPORT_FUNCTION;
+
+    retcode_t   ret;
+    Tcpip net;
+    net.toggleDebug(true);
+    net.createNetServer(6000);
+    net.newNetConnection(true);
+
+    bool loop = true;
+    std::vector<unsigned char> data;
+    while (loop) {
+        if (net.readNet(data).size() < 0) {
+            dbglogfile << "ERROR: Got error from socket " << std::endl;
+            loop = false;
+        } else {
+            std::string buffer = (char *)data.data();
+            if (buffer[0] == 0) {
+                loop = false;
+                continue;
+            }
+            //if (buffer.size() == 1 && *data.data() == 0) {
+            if (data.size() == 1) {
+                loop = false;
+            }
+            if (data.size() == 0) {
+                sleep(1);
+                continue;
+            }
+            buffer.erase(buffer.find('\n')-1);
+            // if the first character is a <, assume it's in XML formst.
+            if (buffer[0] == '<') {
+                XML xml;
+                xml.parseMem(buffer);
+                dbglogfile << "FIXME:: \"" << xml.nameGet() << "\"" << 
std::endl;
+                if (xml.nameGet() == "command") {
+                    std::cerr << "FIXME: Command: " << xml.valueGet() << 
std::endl;
+                    if (xml.valueGet() == "help") {
+                        net.writeNet("Hello World!\n");
+                    }
+                    
+                } else if (xml.nameGet() == "data") {
+                    std::cerr << "FIXME: DATA: " << xml.valueGet() << 
std::endl;
+                } else {
+                    std::cerr << "FIXME: JUNK: " << xml.valueGet() << 
std::endl;
+                }
+            } else {
+                std::cerr << buffer << std::endl;
+            }
+        }
+    }
+
+    net.closeNet();
 }
-//#endif
 
 #ifdef BUILD_OWNET
 void

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=feec31a525dee5a0c1ff0e8ff128456c7383d316


commit feec31a525dee5a0c1ff0e8ff128456c7383d316
Author: Rob Savoye <address@hidden>
Date:   Sun Nov 25 21:44:23 2018 -0700

    Only one readNet() now, and uses a std::vector

diff --git a/lib/tcpip.cc b/lib/tcpip.cc
index 1244a83..1826e3f 100644
--- a/lib/tcpip.cc
+++ b/lib/tcpip.cc
@@ -46,7 +46,6 @@
 #include "tcpip.h"
 #include "tcputil.h"
 #include "log.h"
-#include "err.h"
 
 //static const char *SERVICENAME = "powerguru";
 static const char *DEFAULTPROTO = "tcp";
@@ -67,14 +66,10 @@ int  Tcpip::_sockfd;
 int  Tcpip::_sockIOfd;
 
 Tcpip::Tcpip(void)
-    : _ipaddr(INADDR_ANY),
-      _proto(0),
-      _debug(false),
-      _console(false)
-      // _sockfd(-1), _sockIOfd(-1), 
+
 {
     // Get the low level host data for this machine
-    hostDataGet();
+    //hostDataGet();
 }
 
 Tcpip::~Tcpip(void)
@@ -684,9 +679,6 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
     while (retries-- > 0) {
         FD_ZERO(&fdset);
         // also return on any input from stdin
-        if (_console) {
-            FD_SET(fileno(stdin), &fdset);
-        }
         FD_SET(fd, &fdset);
     
         tval.tv_sec = 10;
@@ -702,22 +694,17 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
         }
         if (ret == 0) {
             dbglogfile << "There is no data in the socket for fd #" << fd << 
std::endl;
-            msgs.clear();
+            // msgs.clear();
             return SUCCESS;
         }
         if (ret == -1) {
-            dbglogfile << "The socket for fd #%d never was available!"
-                       << fd << std::endl;
+            dbglogfile << "The socket for fd #%d never was available!" << fd 
<< std::endl;
             return ERROR;
         }
         if (ret > 0) {
-            if (FD_ISSET(fileno(stdin), &fdset)) {
-                dbglogfile << "There is data at the console for stdin!" << 
std::endl;
-                msgs.clear();
-                return SUCCESS;
-            }
             dbglogfile << "There is data in the socket for fd #" << fd << 
std::endl;
         }
+
         memset(buf, 0, INBUF);
         if (FD_ISSET(_sockfd, &fdset)) {
             ret = ::read(_sockfd, buf, INBUF-2);
@@ -740,8 +727,8 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
             return ERROR;
         }
         cr = strlen(buf);
-//     dbglogfile << "read " << ret << " bytes, first msg terminates at " << 
cr << std::endl;
-//     dbglogfile << "read " << buf << std::endl;
+        //dbglogfile << "read " << ret << " bytes, first msg terminates at " 
<< cr << std::endl;
+        //dbglogfile << "read " << buf << std::endl;
         ptr = buf;
         // If we get a single XML message, do less work
         if (ret == cr + 1) {
@@ -833,94 +820,71 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
     return SUCCESS;
 }
 
-// Read from the socket
-int
-Tcpip::readNet(char *buffer, int nbytes)
+// This blocks waiting for data on the socket, so it's easy on the cpu. If
+// There is data, it peeks at how many bytes there are in the socket, and
+// allocates a buffer of the exact size.
+std::vector<unsigned char> &
+Tcpip::readNet(std::vector<unsigned char> &buf)
 {
-    return readNet(_sockfd, buffer, nbytes, DEFAULTTIMEOUT);
-}
-
-int
-Tcpip::readNet(int fd, char *buffer, int nbytes)
-{
-    return readNet(fd, buffer, nbytes, DEFAULTTIMEOUT);
-}
-
-int
-Tcpip::readNet(char *buffer, int nbytes, int timeout)
-{
-    return readNet(_sockfd, buffer, nbytes, timeout);
-}
-
-int
-Tcpip::readNet(int fd, char *buffer, int nbytes, int timeout)
-{
-    DEBUGLOG_REPORT_FUNCTION;
+    //DEBUGLOG_REPORT_FUNCTION;
     fd_set              fdset;
     int                 ret = 0;
     struct timeval      tval;
-  
-    // have ensible limits...
-    if (fd == 0 || fd > 100) {
-        return -1;
-    }
-    
+
     // Wait for the socket to be ready for reading
-    if (fd > 2) {
+    if (_sockfd > 2) {
         FD_ZERO(&fdset);
-        FD_SET(fd, &fdset);
+        FD_SET(_sockfd, &fdset);
     } else {
         dbglogfile << "WARNING: Can't do anything with socket fd #"
-                   << fd << std::endl;
-        return -1;
+                   << _sockfd << std::endl;
     }
   
-    // Reset the timeout value, since select modifies it on return
-    if (timeout >= 0) {
-        tval.tv_sec = timeout;
-    } else {
-        tval.tv_sec = DEFAULTTIMEOUT;
-    }
+    tval.tv_sec = DEFAULTTIMEOUT;
     tval.tv_usec = 0;
-    if (timeout != BLOCKING_TIMEOUT) {
-        ret = select(fd+1, &fdset, NULL, NULL, &tval);
-    } else {
-        ret = select(fd+1, &fdset, NULL, NULL, NULL);        
+    ret = select(_sockfd+1, &fdset, NULL, NULL, &tval);
+
+    if (ret <= 0 && tval.tv_sec == 0) {
+        buf.clear();
+        return buf;
     }
-  
+
+    int nbytes = checkBytes();
+    buf.clear();
+    // This is a hack to preset the size of the data in the vector
+    buf.resize(nbytes + 1);
+    unsigned char *buffer = buf.data();
 
     // If interupted by a system call, try again
     if (ret == -1 && errno == EINTR) {
         dbglogfile <<
-            "The socket for fd #" << fd << " we interupted by a system call!"
+            "The socket for fd #" << _sockfd << " we interupted by a system 
call!"
                                   << std::endl;
         dbglogfile << "WARNING: error is " << strerror(errno) << std::endl;
-        return 0;
     }
   
     if (ret == -1) {
-        dbglogfile <<
-            "The socket for fd #" << fd << " never was available for reading!"
-                                  << std::endl;
-        return -1;
+        dbglogfile << "The socket for fd #" << _sockfd << " never was 
available for reading!"
+                   << std::endl;
     }
   
-    if (ret == 0) {
 #if 0                           // FIXME: too verbose
+    if (ret == 0) {
         dbglogfile <<
-            "The socket for fd #" << fd << " timed out waiting to read!" << 
std::endl;
-#endif
-        return 0;
+            "The socket for fd #" << _sockfd << " timed out waiting to read!" 
<< std::endl;
     }
-
-    ret = read(fd, buffer, nbytes);
+#endif
+    ret = read(_sockfd, buffer, nbytes);
 #if 0
     if (ret != 0) {
-        dbglogfile << "Read " << ret << " bytes from fd #" << fd << std::endl;
+        dbglogfile << "Read " << ret << " bytes from fd #" << _sockfd << 
std::endl;
         dbglogfile << "Buffer says " << buffer << std::endl;
+        dbglogfile << "Read " << (int)buf.size() << " bytes from fd #" << 
_sockfd << std::endl;
+        dbglogfile << "Buffer says " << buf.data() << std::endl;
     }
 #endif
-    return ret;
+
+    return buf;
 }
 
 // Write data to the socket. We first make sure the socket is ready for
@@ -932,12 +896,6 @@ Tcpip::writeNet(const std::string &buffer)
 }
 
 int
-Tcpip::writeNet(char const *buffer)
-{
-    return writeNet(_sockfd, buffer, strlen(buffer), DEFAULTTIMEOUT);
-}
-
-int
 Tcpip::writeNet(char const *buffer, int nbytes)
 {
     return writeNet(_sockfd, buffer, nbytes,DEFAULTTIMEOUT );
diff --git a/lib/tcpip.h b/lib/tcpip.h
index 291a717..dafcbc0 100644
--- a/lib/tcpip.h
+++ b/lib/tcpip.h
@@ -28,17 +28,11 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-//#include <netdb.h>
 #include <cstring>
 #include <vector>
-// #ifdef HAVE_LIBXML
-// # include <libxml/encoding.h>
-// # include <libxml/xmlwriter.h>
-// # include <libxml/debugXML.h>
-// #endif
+#include <sys/ioctl.h>
 
 #include "log.h"
-#include "err.h"
 #include "tcputil.h"
 
 class Tcpip : public Tcputil
@@ -73,14 +67,10 @@ public:
     retcode_t anydata(int sockfd, std::vector<const unsigned char *> &msgs);
 
     // Read from the socket
-    int readNet(char *buffer, int nbytes);
-    int readNet(char *buffer, int nbytes, int timeout);
-    int readNet(int fd, char *buffer, int nbytes);
-    int readNet(int fd, char *buffer, int nbytes, int timeout);
+    std::vector<unsigned char> &readNet(std::vector<unsigned char> &buf);
   
     // Write to the socket  
     int writeNet(const std::string &buffer);
-    int writeNet(char const *buffer);
     int writeNet(char const *buffer, int nbytes);
     int writeNet(int fd, char const *buffer);
     int writeNet(int fd, char const *buffer, int nbytes);
@@ -108,15 +98,19 @@ public:
     Tcpip &operator = (Tcpip &tcp);
 
     void checkConsole(void) { _console = true; };
-  
+    int checkBytes() {
+        int bytes = 0;
+        ioctl(_sockfd, FIONREAD, &bytes);
+        return bytes;
+    }
   
 private:
     static int               _sockfd;
     static int               _sockIOfd;
     in_addr_t                _ipaddr;
     std::string              _hostname;
-    struct sockaddr_in    _client;
-    const char              *_proto;
+    struct sockaddr_in      _client;
+    std::string              _proto;
     short                    _port;
     bool                     _debug;
     bool                    _console;

-----------------------------------------------------------------------

Summary of changes:
 config.guess                   | 1029 ++++++++++++++++++++++------------------
 config.sub                     |  473 ++++++++++++++----
 daemon/main.cc                 |  157 ++----
 daemon/threads.cc              |   69 ++-
 lib/Makefile.am                |   10 +-
 lib/err.cc                     |   40 +-
 lib/err.h                      |   44 +-
 lib/log.cc                     |   48 +-
 lib/log.h                      |    1 -
 lib/mariadb.cc                 |   16 -
 lib/msgs.cc                    |  307 ++++++------
 lib/msgs.h                     |  128 +++--
 lib/postgresql.cc              |   17 -
 lib/tcpip.cc                   |  424 +++++------------
 lib/tcpip.h                    |   98 ++--
 lib/tcputil.cc                 |  433 +++--------------
 lib/tcputil.h                  |   83 +---
 lib/xml.cc                     |  201 +-------
 testsuite/libtests/Makefile.am |   25 +-
 19 files changed, 1596 insertions(+), 2007 deletions(-)


hooks/post-receive
-- 
powerguru



reply via email to

[Prev in Thread] Current Thread [Next in Thread]