+
+ if (pos-buffer >= BUFFSIZE)
+ pos = buffer;
+
+ *(pos++) = c;
+
+ if (c == 0x0a) {
+ *(--pos) = 0;
+ if (pos-buffer > 0 && *(--pos) == 0x0d)
+ *pos = 0;
+
+ if (pos-buffer == 0)
+ break;
+
+#ifdef DEBUG
+ printf("%d. %s (%d)\n", lines, buffer, pos-buffer);
+#endif
+ if (lines == 0) {
+ if (strncasecmp("HTTP/", buffer, 5)) {
+ fprintf(stderr, "Wrong answer from server: %s\n", buffer);
+ return -1;
+ }
+
+ pos = buffer;
+ while (*pos != 0) {
+ if (*pos == ' ') {
+ pos++;
+ if(strncmp("200", pos, 3)) {
+ fprintf(stderr, "Wrong result-code: %s\n", buffer);
+ return -1;
+ } else {
+ break;
+ }
+ }
+ pos++;
+ }
+ }
+
+ pos = buffer;
+ lines++;
+ }