diff -r a76cbe676bf1 -r 2317b8d644fa thermferm/server.c --- a/thermferm/server.c Sun Aug 10 20:01:17 2014 +0200 +++ b/thermferm/server.c Sun Aug 10 21:22:17 2014 +0200 @@ -16,7 +16,7 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with EC-65K; see the file COPYING. If not, write to the Free + * along with ThermFerm; see the file COPYING. If not, write to the Free * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *****************************************************************************/ @@ -226,13 +226,13 @@ opt = strtok(NULL, " \0"); if (opt == NULL) { - srv_send((char *)"502 Missing command option"); + srv_send((char *)"501 Subcommand missing"); return 1; } param = strtok(NULL, "\0"); if (strcmp(opt, (char *)"LIST") == 0) { - srv_send((char *)"212 bus devices:"); + srv_send((char *)"212 Devices list follows:"); for (device = Config.devices; device; device = device->next) { srv_send((char *)"%s,%s,%d,%d,%s,%s", device->uuid, device->address, device->subdevice, device->inuse, device->comment, DEVDIR[device->direction]); } @@ -241,7 +241,7 @@ } if (param == NULL) { - srv_send((char *)"502 Missing command parameter"); + srv_send((char *)"502 Parameter missing"); return 1; } @@ -279,12 +279,12 @@ } } } - syslog(LOG_NOTICE, "Device with uuid %s added", device->uuid); - srv_send((char *)"211 Device with uuid %s added", device->uuid); + syslog(LOG_NOTICE, "Device %s added", device->uuid); + srv_send((char *)"211 Device %s added", device->uuid); return 0; } else { - srv_send((char *)"506 Wrong device parameter"); + srv_send((char *)"503 Parameter error"); return 1; } } @@ -292,11 +292,11 @@ if (strcmp(opt, (char *)"DEL") == 0) { if (delete_Device(param)) { - syslog(LOG_NOTICE, "Deleted device with %s", param); + syslog(LOG_NOTICE, "Device %s deleted", param); srv_send((char *)"211 Device %s deleted", param); return 0; } else { - srv_send((char *)"440 Delete Device: No such device %s", param); + srv_send((char *)"440 No such device"); return 1; } } @@ -304,7 +304,7 @@ if (strcmp(opt, (char *)"GET") == 0) { for (device = Config.devices; device; device = device->next) { if (strcmp(device->uuid, param) == 0) { - srv_send((char *)"213 Device %s record follows:", device->uuid); + srv_send((char *)"213 Device record follows:"); srv_send((char *)"TYPE,%s", DEVTYPE[device->type]); srv_send((char *)"DIRECTION,%s", DEVDIR[device->direction]); srv_send((char *)"VALUE,%d", device->value); @@ -426,7 +426,7 @@ return 1; } - srv_send((char *)"502 Unknown command option"); + srv_send((char *)"504 Subcommand error"); return 1; } @@ -446,7 +446,7 @@ opt = strtok(NULL, "\0"); if (opt == NULL) { - srv_send((char *)"502 Missing command option"); + srv_send((char *)"501 Subcommand missing"); return 1; } @@ -556,7 +556,7 @@ } } - srv_send((char *)"502 Unknown command option"); + srv_send((char *)"504 Subcommand error"); return 1; } @@ -590,7 +590,7 @@ param = strtok(NULL, "\0"); if (param == NULL) { - srv_send((char *)"501 Parameter missing"); + srv_send((char *)"502 Parameter missing"); return 1; } @@ -628,7 +628,7 @@ return 0; } - srv_send((char *)"502 Unknown command option"); + srv_send((char *)"504 Subcommand error"); return 1; } @@ -664,7 +664,7 @@ /* * Fermenting profiles */ - srv_send((char *)"212 profiles:"); + srv_send((char *)"212 Profiles list follows:"); for (profile = Config.profiles; profile; profile = profile->next) { j = 0; for (step = profile->steps; step; step = step->next) @@ -677,7 +677,7 @@ param = strtok(NULL, "\0"); if (param == NULL) { - srv_send((char *)"501 Parameter missing"); + srv_send((char *)"502 Parameter missing"); return 1; } @@ -703,25 +703,25 @@ } } - syslog(LOG_NOTICE, "Profile \"%s\" with uuid %s added", param, profile->uuid); - srv_send((char *)"211 Profile \"%s\" with uuid %s added", param, profile->uuid); + syslog(LOG_NOTICE, "Profile %s added", profile->uuid); + srv_send((char *)"211 Profile %s added", profile->uuid); return 0; } else if (strcmp(opt, (char *)"DEL") == 0) { if (delete_Profile(param)) { - syslog(LOG_NOTICE, "Deleted Profile with %s", param); + syslog(LOG_NOTICE, "Profile %s deleted", param); srv_send((char *)"211 Profile %s deleted", param); return 0; } else { - srv_send((char *)"440 Delete Profile: No such profile%s", param); + srv_send((char *)"440 No such profile"); return 1; } } else if (strcmp(opt, (char *)"GET") == 0) { for (profile = Config.profiles; profile; profile = profile->next) { if (strcmp(profile->uuid, param) == 0) { - srv_send((char *)"213 Profile %s record follows:", profile->uuid); + srv_send((char *)"213 Profile record follows:"); srv_send((char *)"UUID,%s", profile->uuid); srv_send((char *)"NAME,%s", profile->name); srv_send((char *)"INITTEMP,%.1f", profile->inittemp); @@ -762,7 +762,7 @@ fprintf(stdout, "recv: \"%s\"\n", ibuf); } if (strcmp(ibuf, (char *)".") == 0) { - srv_send((char *)"219 Accepted Device record"); + srv_send((char *)"219 Accepted Profile record"); return 0; } kwd = strtok(ibuf, ",\0"); @@ -841,7 +841,7 @@ } if (strcmp(ibuf, (char *)".") == 0) { - srv_send((char *)"219 Accepted profile steps"); + srv_send((char *)"219 Accepted Profile steps"); return 0; } sstep = strtok(ibuf, ",\0"); @@ -880,7 +880,7 @@ return 1; } - srv_send((char *)"502 Unknown command option"); + srv_send((char *)"504 Subcommand error"); return 1; } @@ -982,13 +982,13 @@ opt = strtok(NULL, " \0"); if (opt == NULL) { - srv_send((char *)"501 Parameter missing"); + srv_send((char *)"501 Subcommand missing"); return 1; } param = strtok(NULL, "\0"); if ((strcmp(opt, (char *)"LIST") == 0) && (param == NULL)) { - srv_send((char *)"212 Fermenter Units list follows:"); + srv_send((char *)"212 Fermenter list follows:"); for (unit = Config.units; unit; unit = unit->next) { srv_send((char *)"%s,%s,%s", unit->uuid, unit->name, UNITMODE[unit->mode]); } @@ -997,7 +997,7 @@ } if (param == NULL) { - srv_send((char *)"501 Parameter missing"); + srv_send((char *)"502 Parameter missing"); return 1; } @@ -1034,18 +1034,18 @@ } } - syslog(LOG_NOTICE, "Unit with uuid %s added", unit->uuid); - srv_send((char *)"211 Unit with uuid %s added", unit->uuid); + syslog(LOG_NOTICE, "Unit %s added", unit->uuid); + srv_send((char *)"211 Unit %s added", unit->uuid); return 0; } if (strcmp(opt, (char *)"DEL") == 0) { if (delete_Unit(param)) { - syslog(LOG_NOTICE, "Deleted Unit with %s", param); + syslog(LOG_NOTICE, "Unit %s deleted", param); srv_send((char *)"211 Unit %s deleted", param); return 0; } else { - srv_send((char *)"440 Delete Unit: No such unit %s", param); + srv_send((char *)"440 No such unit"); return 1; } } @@ -1053,7 +1053,7 @@ if (strcmp(opt, (char *)"GET") == 0) { for (unit = Config.units; unit; unit = unit->next) { if (strcmp(param, unit->uuid) == 0) { - srv_send((char *)"213 Unit %s listing follows:", unit->uuid); + srv_send((char *)"213 Unit listing follows:"); srv_send((char *)"NAME,%s", unit->name); srv_send((char *)"UUID,%s", unit->uuid); srv_send((char *)"VOLUME,%2f", unit->volume); @@ -1088,7 +1088,7 @@ return 1; } } - srv_send((char *)"410 No such unit"); + srv_send((char *)"440 No such unit"); return 1; } @@ -1297,12 +1297,12 @@ } } } - srv_send((char *)"440 No such device"); + srv_send((char *)"440 No such unit"); return 1; } - srv_send((char *)"502 Unknown command option"); + srv_send((char *)"504 Subcommand error"); return 1; } @@ -1382,7 +1382,7 @@ srv_send((char *)"."); } else if (strncmp(buf, "LCD", 3) == 0) { #ifdef HAVE_WIRINGPI_H - srv_send((char *)"201 information follows"); + srv_send((char *)"201 Information follows"); for (j = 0; j < 4; j++) { sprintf(obuf, " "); obuf[20] = '\0'; @@ -1403,8 +1403,6 @@ if (cmd_unit(buf) == 0) wrconfig(); } else { - if (debug) - fprintf(stdout, "unknown command \"%s\"\n", buf); srv_send((char *)"500 Unknown command"); } }