Revision 1641
| trunk/nntpgrab_core/nntpconnection.c (revision 1641) | ||
|---|---|---|
| 929 | 929 | 
                  nntpgrab_core_emit_part_progress_update(FALSE, conn->server_info.servername, conn->poll_fd.fd, conn->file->subject, conn->part->part_num, conn->article_bytes_downloaded, conn->part->size);  | 
              
| 930 | 930 | 
                  }  | 
              
| 931 | 931 | 
                   | 
              
| 932 | 
                  /* Do we have enough useful data? */  | 
              |
| 933 | 
                      if (length < 5) {
                 | 
              |
| 934 | 
                  /* Nope, push the data back in the recv buffer and try again later */  | 
              |
| 935 | 
                   | 
              |
| 936 | 
                  /* If the read_msg call returned less then 5 bytes the buffer must be empty */  | 
              |
| 937 | 
                  g_return_if_fail(conn->recv_buffer_length == 0);  | 
              |
| 938 | 
                   | 
              |
| 939 | 
                  memcpy(conn->recv_buffer, buf, length);  | 
              |
| 940 | 
                  conn->recv_buffer_length = length;  | 
              |
| 941 | 
                   | 
              |
| 942 | 
                  return;  | 
              |
| 943 | 
                  }  | 
              |
| 944 | 
                   | 
              |
| 945 | 932 | 
                  /* Check for the end sequence */  | 
              
| 946 | 
                  if (!strncmp(buf + length - 5, "\r\n.\r\n", 5) ||  | 
              |
| 947 | 
                          !strncmp(buf + length - 3, "\n.\n", 3)) {
                 | 
              |
| 933 | 
                  if ((length >= 5 && !strncmp(buf + length - 5, "\r\n.\r\n", 5)) ||  | 
              |
| 934 | 
                          (length >= 3 && !strncmp(buf + length - 3, "\n.\n", 3))) {
                 | 
              |
| 948 | 935 | 
                   | 
              
| 949 | 936 | 
                  /* End sequence found! */  | 
              
| 950 | 937 | 
                   | 
              
| 951 | 938 | 
                  /* Calculate the number of bytes we don't need to write to disk */  | 
              
| 952 | 
                          if (!strncmp(buf + length - 5, "\r\n.\r\n", 5)) {
                 | 
              |
| 939 | 
                          if (length >= 5 && !strncmp(buf + length - 5, "\r\n.\r\n", 5)) {
                 | 
              |
| 953 | 940 | 
                  length -= 5;  | 
              
| 954 | 941 | 
                          } else {
                 | 
              
| 955 | 942 | 
                  length -= 3;  | 
              
| branches/nntpgrab-0.6/nntpgrab_core/nntpconnection.c (revision 1641) | ||
|---|---|---|
| 917 | 917 | 
                  nntpgrab_core_emit_part_progress_update(FALSE, conn->server_info.servername, conn->poll_fd.fd, conn->file->subject, conn->part->part_num, conn->article_bytes_downloaded, conn->part->size);  | 
              
| 918 | 918 | 
                  }  | 
              
| 919 | 919 | 
                   | 
              
| 920 | 
                  /* Do we have enough useful data? */  | 
              |
| 921 | 
                      if (length < 5) {
                 | 
              |
| 922 | 
                  /* Nope, push the data back in the recv buffer and try again later */  | 
              |
| 923 | 
                   | 
              |
| 924 | 
                  /* If the read_msg call returned less then 5 bytes the buffer must be empty */  | 
              |
| 925 | 
                  g_return_if_fail(conn->recv_buffer_length == 0);  | 
              |
| 926 | 
                   | 
              |
| 927 | 
                  memcpy(conn->recv_buffer, buf, length);  | 
              |
| 928 | 
                  conn->recv_buffer_length = length;  | 
              |
| 929 | 
                   | 
              |
| 930 | 
                  return;  | 
              |
| 931 | 
                  }  | 
              |
| 932 | 
                   | 
              |
| 933 | 920 | 
                  /* Check for the end sequence */  | 
              
| 934 | 
                  if (!strncmp(buf + length - 5, "\r\n.\r\n", 5) ||  | 
              |
| 935 | 
                          !strncmp(buf + length - 3, "\n.\n", 3)) {
                 | 
              |
| 921 | 
                  if ((length >= 5 && !strncmp(buf + length - 5, "\r\n.\r\n", 5)) ||  | 
              |
| 922 | 
                          (length >= 3 && !strncmp(buf + length - 3, "\n.\n", 3))) {
                 | 
              |
| 936 | 923 | 
                   | 
              
| 937 | 924 | 
                  /* End sequence found! */  | 
              
| 938 | 925 | 
                   | 
              
| 939 | 926 | 
                  /* Calculate the number of bytes we don't need to write to disk */  | 
              
| 940 | 
                          if (!strncmp(buf + length - 5, "\r\n.\r\n", 5)) {
                 | 
              |
| 927 | 
                          if (length >= 5 && !strncmp(buf + length - 5, "\r\n.\r\n", 5)) {
                 | 
              |
| 941 | 928 | 
                  length -= 5;  | 
              
| 942 | 929 | 
                          } else {
                 | 
              
| 943 | 930 | 
                  length -= 3;  | 
              
Also available in: Unified diff
NNTPGrab

