+int writes(int fd, const char *str)
+{
+ int len = strlen(str);
+
+ if( len != write(fd, str, len) )
+ {
+ return 1;
+ }
+ return 0;
+}
+
+char *ReadStatus(int FD)
+{
+ char tmpbuf[32];
+ int len;
+ len = read(FD, tmpbuf, sizeof(tmpbuf)-1);
+ tmpbuf[len] = 0;
+ char *msg = strchr(tmpbuf, ',');
+ if( !msg ) {
+ fprintf(stderr, "Door returned malformed data (no ',')\n");
+ return NULL;
+ }
+ msg ++;
+ char *end = strchr(tmpbuf, ';');
+ if( !end ) {
+ fprintf(stderr, "Door returned malformed data (no ';')\n");
+ return NULL;
+ }
+ *end = '\0';
+
+ return strdup(msg);
+}