Code

1. Was erroneously using tokptr vice key.
authoranthony <anthony>
Tue, 6 Jun 2006 03:14:39 +0000 (03:14 +0000)
committeranthony <anthony>
Tue, 6 Jun 2006 03:14:39 +0000 (03:14 +0000)
2. Changed calls to strcmp to strncmp so that
only definate ranges where being compared.

src/apcups.c

index b9a500d00f64769b08d66d77f8e467330daf84d8..7a1cc065b9286d19cf15dae7a4075f83d65e4dd8 100644 (file)
@@ -416,21 +416,21 @@ static int apc_query_server (char *host, int port,
                        value = atof (tokptr);
                        PRINT_VALUE (key, value);
 
-                       if (strcmp ("LINEV", key) == 0)
+                       if (strncmp ("LINEV", key,5) == 0)
                                apcups_detail->linev = value;
-                       else if (strcmp ("BATTV", tokptr) == 0)
+                       else if (strncmp ("BATTV", key,5) == 0) 
                                apcups_detail->battv = value;
-                       else if (strcmp ("ITEMP", tokptr) == 0)
+                       else if (strncmp ("ITEMP", key,5) == 0)
                                apcups_detail->itemp = value;
-                       else if (strcmp ("LOADPCT", tokptr) == 0)
+                       else if (strncmp ("LOADPCT", key,7) == 0)
                                apcups_detail->loadpct = value;
-                       else if (strcmp ("BCHARGE", tokptr) == 0)
+                       else if (strncmp ("BCHARGE", key,7) == 0)
                                apcups_detail->bcharge = value;
-                       else if (strcmp ("OUTPUTV", tokptr) == 0)
+                       else if (strncmp ("OUTPUTV", key,7) == 0)
                                apcups_detail->outputv = value;
-                       else if (strcmp ("LINEFREQ", tokptr) == 0)
+                       else if (strncmp ("LINEFREQ", key,8) == 0)
                                apcups_detail->linefreq = value;
-                       else if (strcmp ("TIMELEFT", tokptr) == 0)
+                       else if (strncmp ("TIMELEFT", key,8) == 0)
                                apcups_detail->timeleft = value;
 
                        tokptr = strtok (NULL, ":");
@@ -446,7 +446,6 @@ static int apc_query_server (char *host, int port,
                net_close(&sockfd);
        }
 
-
        return (0);
 }