Thread: Difflib from python in C?

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    6

    Difflib from python in C?

    Hi,

    I am writing web security tool in C and I need to compare pages depending on variable input values. But modern web pages change content after each refresh (counters, clocks, ads ...) so it's hard to determine which of content changes are depending on user input and which are not. I've found python library difflib with SequenceMatcher class (sqlmap is also using it) which can be really helpful. It compares two data structures (e.g strings) and than returns float (0-1) indicating how different they are. Is there something similar I can use in C? Or I have to port this library in C myself?

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Its quite difficult to understand what your looking for. But in term of comparing the only library function which i can think of strcmp/strncmp the nearest. I don’t think there is anything as such as the difflib does in C. Unless anyone else might know any of library which do the text difference.

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    6
    I am just searching for python's difflib sequencematcher alternative for C OR some other way to determine if page content was modified after input change (on pages that change content on every refresh). I know difflib method isn't 100 %, but I've checked sqlmap and it works pretty well. If I wasn't clear.

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Maybe you can give some code and people can translate it to C. If you use a function or a class with a specific way it might be able to easily be reproduced in C

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    6
    I know C pretty well. In fact, don't know python at all. I don't have problem with translating python to C, but i want to aviod this. I just want to know if there is some library in C which provides api like SequenceMatcher class in difflib python library. Look at my previous post.

  6. #6
    Registered User
    Join Date
    Feb 2009
    Posts
    6
    I've found something that helped me. Just google for
    Ratcliff/Obershelp pattern recognition and Levenshtein distance

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Python --> C
    By Macha in forum C Programming
    Replies: 71
    Last Post: 05-28-2010, 06:18 PM
  2. Replies: 16
    Last Post: 11-01-2009, 12:10 AM
  3. python c api
    By ralu. in forum C Programming
    Replies: 0
    Last Post: 03-01-2009, 01:19 PM
  4. C and Python
    By alexnb185 in forum Tech Board
    Replies: 5
    Last Post: 04-11-2008, 11:11 PM
  5. Python
    By Xterria in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 05-05-2002, 04:08 PM

Tags for this Thread