Cooler_

test parse

Apr 24th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. // test parse
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #define BUF 256
  6.  
  7. int
  8. main(void)
  9. {
  10.  char *test = "lol blah blah blablablabla bha bla a href=/site.php?pass=1234 aas href=\"lol.jsp\" blah blah";
  11.  int href = *(int *)"href";
  12.  char *p, *s=(char *)malloc(sizeof(char)*BUF);
  13.  register i, x;
  14.  
  15.  i = 0;
  16.  p = test;
  17.  
  18.  do{
  19.   x = *(int *)p;
  20.   if(x == href && p[4] == '=')
  21.   {
  22.    p += 5;
  23.    do{
  24.     s[i] = *p;
  25.     p++;
  26.     i++;
  27.    }while(*p != ' ' && i < BUF-1);
  28.    s[i] = '\n';
  29.    i++;
  30.   }
  31.   p++;
  32.  }while(p[5] != '\0' && i < BUF-1);
  33.  
  34.  puts(s);
  35.  free(s);
  36.      return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment