Code cleanup

Tue, 17 Jul 2018 11:50:25 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 17 Jul 2018 11:50:25 +0200
changeset 542
73b63f431da2
parent 541
a5530abb16dd
child 543
34e19966114b

Code cleanup

thermferm/server.c file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Mon Jul 16 21:56:24 2018 +0200
+++ b/thermferm/server.c	Tue Jul 17 11:50:25 2018 +0200
@@ -1165,18 +1165,11 @@
 
 /*
  * LIST
- * LIST LOG
  */
 int cmd_list(char *buf)
 {
     char		*opt;
-//    char		*param, *filename, q[5], hr[3], buffer[256], outbuf[256];
-//    char		*date_n, *mode_n, *air_n, *beer_n, *target_lo_n, *target_hi_n, *heater_n, *cooler_n, *room_n, *chiller_n;
-//    char		*heater_u, *cooler_u;
-//    int			heater_l = 0, cooler_l = 0, h = 0, c = 0, heat_used = 0, cool_used = 0, lines = 0, graphstep = 0;
     units_list		*unit;
-//    FILE		*fp;
-//    float		room_t;
 
     opt = strtok(buf, " \0");
     opt = strtok(NULL, " \0");
@@ -1196,130 +1189,8 @@
 	srv_send((char *)"100 Help text follows:");
 	srv_send((char *)"Recognized commands:");
 	srv_send((char *)"LIST                           List available units");
-//	srv_send((char *)"LIST LOG uuid                  List logfile of unit by uuid");
 	srv_send((char *)".");
 	return 0;
-/*
-    } else if (strcmp(opt, (char *)"LOG") == 0) {
-
-	param = strtok(NULL, "\0");
-	if (param == NULL) {
-	    srv_send((char *)"502 Parameter missing");
-	    return 0;
-	}
-
-	q[0] = q[1] = q[2] = q[3] = q[4] = 'a';
-	for (unit = Config.units; unit; unit = unit->next) {
-	    if (strcmp(param, unit->uuid) == 0)
-		break;
-	}
-
-	srv_send((char *)"212 Logfile list follows:");
-	if (getenv((char *)"USER") == NULL) {
-	    filename = xstrcpy((char *)"/root");
-	} else {
-	    filename = xstrcpy(getenv((char *)"HOME"));
-	}
-	filename = xstrcat(filename, (char *)"/.thermferm/log/");
-	filename = xstrcat(filename, unit->name);
-	filename = xstrcat(filename, (char *)".log");
-	if ((fp = fopen(filename, "r"))) {
-*/
-	    /*
-	     * Count the lines in the logfile
-	     */
-/*	    lines = 0;
-	    while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
-		lines++;
-	    }
-	    fseek(fp, 0L, SEEK_SET);
-*/	    /*
-	     * We have counted the lines in the logfile including the header lines.
-	     * The header lines should be ignored but there are so few of them, we
-	     * just include them in the total.
-	     * Now find a reasonable interval of lines to sent to the client.
-	     */
-/*	    for (graphstep = 1; graphstep <= MAX_INTERVALS; graphstep++) {
-		if (lines < GRAPH_DATALINES[graphstep]) {
-		    break;
-		}
-	    }
-	    if (graphstep > MAX_INTERVALS)
-		graphstep = MAX_INTERVALS;
-	    syslog(LOG_NOTICE, "LIST LOG %s: lines=%d, interval=%d, graphstep=%d", unit->name, lines, GRAPH_INTERVAL[graphstep], graphstep);
-
-	    while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
-*/		/*
-		 * 2014-11-15 18:39,BEER,20.312,19.750,20.0,0,NA,NA,NA,78105,NA,NA
-		 */
-//		hr[0] = q[0] = buffer[11];
-//		hr[1] = q[1] = buffer[12];
-//		q[2] = buffer[14];
-//		q[3] = buffer[15];
-//		hr[2] = '\0';
-//		buffer[strlen(buffer) -1] = '\0';
-//		date_n = strtok(buffer, ",\0");		/* timestamp		*/
-//		mode_n = strtok(NULL, ",\0");		/* unit mode		*/
-//		air_n = strtok(NULL, ",\0");		/* air temp		*/
-//		beer_n = strtok(NULL, ",\0");		/* beer temp		*/
-//		target_lo_n = strtok(NULL, ",\0");	/* target low temp	*/
-//		heater_n = strtok(NULL, ",\0");		/* current heater state	*/
-//		cooler_n = strtok(NULL, ",\0");		/* current cooler state	*/
-//		heater_u = strtok(NULL, ",\0");		/* current fan state	*/
-//		heater_u = strtok(NULL, ",\0");		/* current door state	*/
-//		heater_u = strtok(NULL, ",\0");		/* heater use counter	*/
-//		cooler_u = strtok(NULL, ",\0");		/* cooler use counter	*/
-//		room_n = strtok(NULL, ",\0");		/* fan use counter	*/
-//		room_n = strtok(NULL, ",\0");		/* room temperature	*/
-//		target_hi_n = strtok(NULL, ",\0");	/* target high temp	*/
-//		chiller_n = strtok(NULL, ",\0");	/* chiller temp		*/
-
-//		if (strncmp(mode_n, (char *)"Mode", 4)) {
-		    /*
-		     * Output a line at the right intervals
-		     */
-//		    int hour = atoi(hr);
-//		    if (((graphstep == 1)) ||
-//			((graphstep == 2) && (q[3] == '0' || q[3] == '5')) ||
-//			((graphstep == 3) && ((q[2] == '0' && q[3] == '0') || (q[2] == '1' && q[3] == '5') || (q[2] == '3' && q[3] == '0') || (q[2] == '4' && q[3] == '5'))) ||
-//			((graphstep == 4) && ((q[2] == '0' && q[3] == '0') || (q[2] == '3' && q[3] == '0'))) ||
-//			((graphstep == 5) && (q[2] == '0' && q[3] == '0')) ||
-//			((graphstep == 6) && (hour % 2 == 0) && (q[2] == '0' && q[3] == '0')) ||        /* 120 minutes  */
-//			((graphstep == 7) && (hour % 4 == 0) && (q[2] == '0' && q[3] == '0')) ||        /* 240 minutes  */
-//			((graphstep >= 8) && (hour % 8 == 0) && (q[2] == '0' && q[3] == '0')) ) {	/* 480 minutes	*/
-//			heat_used = cool_used = 0;
-//			if (strcmp(heater_u, "NA") && (sscanf(heater_u, "%d", &h) == 1)) {
-//			    if (h && heater_l) {
-//				heat_used = ((h - heater_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60);
-//			    }
-//			}
-//			if (strcmp(cooler_u, "NA") && (sscanf(cooler_u, "%d", &c) == 1)) {
-//			    if (c && cooler_l) {
-//				cool_used = ((c - cooler_l) * 100) / (GRAPH_INTERVAL[graphstep] * 60);
-//			    }
-//			}
-//			if (room_n)
-//			    sscanf(room_n, "%f", &room_t);
-//			else
-//			    room_t = 0.0;
-//			if (target_hi_n == NULL)
-//			    target_hi_n = target_lo_n;
-//			snprintf(outbuf, 255, "%s,%s,%s,%s,%s,%s,%s,%d,%d,%.1f,%s,%s", 
-//					    date_n, mode_n, air_n, beer_n, target_lo_n, heater_n, cooler_n,
-//					    heat_used, cool_used, room_t, target_hi_n, chiller_n);
-//		    	srv_send(outbuf);
-//			if (h && strcmp(heater_u, "NA"))
-//			    heater_l = h;
-//			if (c & strcmp(cooler_u, "NA"))
-//			    cooler_l = c;
-//		    }
-//	    	}
-//	    }
-//	}
-//	free(filename);
-//	filename = NULL;
-//	srv_send((char *)".");
-//	return 0;
     }
 
     srv_send((char *)"504 Subcommand error");

mercurial