Guest User

Untitled

a guest
Feb 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. count = recv(s, buf, sizeof buf, 0);
  2. for(int i=0; i<chunk; i++)
  3. {
  4. if(buf[i]=='<')
  5. if(buf[i+1]=='p')
  6. if(buf[i+2]=='>')
  7. pcount++;>*/
  8. }
  9.  
  10. FILE *f = fdopen(s, "r+b");
  11. size_t pcount = 0;
  12.  
  13. int c = 0;
  14. while (c != EOF)
  15. {
  16. if ((c = fgetc(f)) == '<'
  17. && (c = fgetc(f)) == 'p'
  18. && (c = fgetc(f)) == '>')
  19. {
  20. pcount += 1;
  21. }
  22. }
  23.  
  24. int pstate = 0;
  25.  
  26. ssize_t count = recv(s, buf, sizeof buf, 0);
  27.  
  28. for (ssize_t i = 0; i < count; i++)
  29. {
  30. if (buf[i] == '<') {
  31. pstate = 1;
  32. }
  33. else if (pstate == 1 && buf[i] == 'p') {
  34. pstate = 2;
  35. }
  36. else if (pstate == 2 && buf[i] == '>') {
  37. pcount += 1;
  38. pstate = 0;
  39. }
  40. else {
  41. // if any other character is found,
  42. // or any of these characters was in wrong position
  43. // then reset the state
  44. pstate = 0;
  45. }
  46. }
Add Comment
Please, Sign In to add comment